Python Programming from First Principles: Learn to Code, Think Computationally, and Solve Real-World Problems
PDFEPUB
BOOK 000 · CHAPTER 1 · First Programs

First Programs

On this pageProject 1 — Cultural Greeting GeneratorProject 2 — Timeline PrinterContinue to Basic Concepts

You can now run code in a notebook or a saved Python file. Use that skill to display several lines of information. Both projects below use print(), which displays the text you put inside its quotation marks. Each call produces a line of output. You do not need variables or loops yet.

Project 1 — Cultural Greeting Generator

Start with a program that displays greetings in different languages. Each printed greeting should appear on its own line.

Task:

Write a program that prints greetings in at least three languages (for example, English, German and Spanish). The output below shows one possible selection.

# Write your code under this line
Listing 35 — Project 1 — Cultural Greeting Generator

Expected Output:

Hello!
Hallo!
¡Hola!
Bonjour!
Listing 36 — Project 1 — Cultural Greeting Generator

After printing greetings, the next project adds a simple structure by combining years with events in a timeline.

Project 2 — Timeline Printer

Next, use separate lines to present events in chronological order. Each line should pair a year with a short description.

Task Choose three or four important years and print each year with a short description.

Expected Output:

1492: Columbus reaches the Americas
1789: French Revolution begins
1969: First humans land on the Moon
1989: Fall of the Berlin Wall
Listing 37 — Project 2 — Timeline Printer

Continue to Basic Concepts

Compare each result with the expected output, then change a greeting or add another event. Explain which instruction produces each line. When you are comfortable saving and running these programs, continue to Basic Concepts to learn about values, variables and operators.