DMarlon Studio

Lesson 1 · 1 of 20

Hello, world · Python

Your first Python program: print() writes text and results to the console. Run it with one click in DMarlon Studio.

Python · Hello, world in DMarlon Studio: the example's code and its output in the terminal

Every program starts by showing something. In Python you use print(): it writes whatever you put inside the parentheses to the console and moves to the next line.

Text goes between quotes (it is a string). Numbers go without quotes, and Python does the maths before printing: 2 + 3 comes out as 5.

Lines starting with # are comments: Python ignores them, and they explain the code to whoever reads it.

Code · main.py

# Your first program: print() writes a line in the console.print("Hello, world!")print("I am learning Python with DMarlon Studio.")# print() accepts several values and separates them with a space.print("2 + 3 =", 2 + 3)

Output · python3 main.py

Hello, world!
I am learning Python with DMarlon Studio.
2 + 3 = 5

Key points

  • print() writes a line to the console.
  • Text goes between quotes; numbers do not.
  • With commas, print() writes several values separated by a space.
  • # starts a comment.

Exercise

Change the program so it prints your name and age, and on another line how old you will be in 10 years (let Python work it out).