Loading...

Python Syntax

Python reads one line, runs it, and then moves down. That line is a statement. This page is about how the line is written. The results you already know stay the same: tea from one statement, then lida and tea from two.

The pieces of print("tea")

The name comes first: print, in lowercase. The parentheses hold what should be shown. The quotes tell Python that tea is text, not a name. The quotes stay in the file. The output is the word tea.

Double quotes

python
print("tea")

Take the quotes away and tea becomes a name this page never created, so the program stops. That part is the same as the first page. The new point is the shape of the line.

Single quotes do the same job

print('tea') uses the other quote mark. The statement still shows tea. Pick one mark and close with the same mark. Do not mix them on one piece of text.

Single quotes

python
print('tea')

print("tea') opens with a double quote and closes with a single quote. Python stops before it shows tea. The line is not a finished statement.

One statement on each line

print("lida") is the first statement. print("tea") is the second. Each one owns its line. A blank line between them is skipped. It does not glue the two lines together, and it does not cancel the second print.

A blank line between two statements

python
print("lida")

print("tea")

Read the output from the top. First lida. Then tea. Not lida / tea. If you write both calls on one line, with nothing between them, that line is not valid. This course keeps one statement per line.

The name is spelled in lowercase

print is the function. Print and PRINT are different spellings. Python does not treat them as the same statement.

Every line starts at the left

The lines on this page sit at the left edge. Pushing a line inward changes the program. That move is the next page, not this one.

Left for later

This page does not install Python, does not create a name, and does not start a line with #. Comments and indentation each have their own page. Here you only read the shape of a statement.

Check yourself

  1. print("tea") shows tea. The quotes are not shown.
  2. print('tea') shows tea as well. The marks match.
  3. print("tea') stops. The marks do not match.
  4. A blank line between the two prints still yields lida, then tea.
  5. The name is print, in lowercase.
  6. Lines stay at the left edge. Inward space is the next page.

Misses

  • Mixing " and ' on the same text
  • Dropping the closing parenthesis
  • Writing Print with a capital P
  • Putting two print calls on one line
  • Reading the two lines as lida / tea
  • Indenting a line on this page

Keep

  • A statement is one line Python can run.
  • print("tea") and print('tea') both show tea.
  • Mismatched quotes stop the program.
  • Two statements stay on two lines. A blank line does not remove the second one.
  • The next page is about moving a line inward.

🧠 Test Your Knowledge

Ready to Start

Test Your Knowledge

Challenge yourself with this interactive quiz and see how well you understand the topic

❓
6
Questions
🎯
70%
To Pass
♾️
∞
Time
🔄
∞
Attempts

📝 Instructions

  • Read each question carefully
  • Select the best answer for each question
  • You can retake the quiz as many times as you want
  • Your progress will be shown at the top