Python Syntax Basics: Print, Variables, and Types



Partner With Us

Python Learning Notes

Python Syntax Basics: Print, Variables, and Types

A beginner-friendly Python note on print(), comments, variable naming, basic types, and converting input before doing math.

Share this article

Copy the link, open your phone share sheet, scan the QR code for WeChat, or send by email.




Email

Python Learning Notes

After students understand why Python is a good first language, the next step is learning how to read a small Python program without feeling lost. Syntax is not just punctuation. It is the visible structure that tells us what the program is doing.

Start with print()

The first useful Python command is usually print(). It sends a value to the screen so we can see what the program is doing.

print("Hello World")
print("CP Club", "Python", "Practice")

For beginners, print() is more than output. It is also a simple debugging tool. When a program feels confusing, printing intermediate values can help students check what is happening step by step.

Use Comments to Explain Your Thinking

Python ignores anything after # on the same line. That makes comments useful for explaining intent.

# This prints a greeting
print("Hello World")

A good comment should explain why the code exists, not simply repeat what the code already says.

Variables Give Names to Ideas

A variable stores a value so we can reuse it later. Clear variable names make programs easier to read.

student_score = 86
bonus_points = 4
final_score = student_score + bonus_points
print(final_score)

Python variable names are case-sensitive, so score and Score are different names. In student code, it is better to use lowercase words separated by underscores, also called snake case.

Python Infers Types

Python is dynamically typed. Students do not need to declare a variable type before assigning a value.

age = 12
name = "Ava"
is_ready = True

print(type(age))
print(type(name))
print(type(is_ready))

This flexibility is helpful, but it also means students should pay attention to what kind of value each variable contains.

Convert Input Before Doing Math

User input arrives as text. If we want to do arithmetic, we usually need to convert it with int() or float().

first_score = int(input())
second_score = int(input())
average = (first_score + second_score) / 2
print(average)

This is one of the most common early Python mistakes: trying to add input strings as if they were numbers.

Practice Prompt

Write a short program that:

  1. Reads a student’s name.
  2. Reads two quiz scores.
  3. Converts the scores to integers.
  4. Prints a sentence with the student’s average score.

Key Takeaway

Beginner syntax should be learned through reading and small experiments. Focus first on a few reliable habits: print values, name variables clearly, check types when confused, and convert input before doing math.

Back to Resources



Scroll to Top