Gulberg Green, Islamabad

Programming Fundamentals · Lesson 01

Your first program

Give a computer an instruction and predict what it will display.

A program is a sequence of instructions written in a language a computer can follow. Python reads a simple script from top to bottom. Each instruction changes something or produces a result.

Start by reading the example aloud. The word print asks Python to display a value. The parentheses hold that value, and the quotation marks tell Python it is text. Programmers call a piece of text a string.

To run it yourself, open a Python 3 interpreter or IDLE on your computer. In IDLE, choose File → New File, type the example, save it as hello.py, and choose Run → Run Module. You can also work through this lesson by predicting the output on paper.

Read the example

Python 3
print("Hello, Islamabad!")
print("I am learning Python.")
Expected output
Hello, Islamabad!
I am learning Python.

Each print call produces one line. Python displays the characters inside the quotation marks. The quotation marks themselves are part of the instruction.

Try it yourself

Change the greeting to your own town and add a third line that describes something you would like to build. Which line will appear first?

Show a worked solution
print("Hello, Lahore!")
print("I am learning Python.")
print("I want to build a website.")

Check your understanding

Your lesson quiz

Answer all five questions. Score at least 4 out of 5 (80%) to pass. You can retry as often as you like.

1. What does print("Hello") display?
2. What is a string?
3. Which instruction displays Welcome?
4. If print("First") comes before print("Second"), which line appears first?
5. Which filename fits this Python script?

Quiz progress is saved in this browser. View certificates →

Learn together

Was this lesson helpful?

Comments and reactions are not open yet.

WhatsApp