Hello-Calc: Python Basics

Learn about variables, keywords, identifiers, and comments.

1. Variables & Calculation

A variable stores a value. Enter two numbers to see Python code in action.

2. Identifier Rules

An identifier is the name you give to a variable, function, etc. It must follow these rules:

  • Can contain letters (a-z, A-Z), numbers (0-9), and underscores (_).
  • Cannot start with a number. (e.g., 1st_num is invalid).
  • Cannot be a keyword. (e.g., for is invalid).
  • Is case-sensitive. (myVar and myvar are different).

An identifier is the name you give to a variable. Rules:

  • Can contain letters, numbers, underscores (_).
  • Cannot start with a number.
  • Cannot be a keyword.
  • Is case-sensitive.

👆 Tap any keyword to learn what it does, how to use it, and when you'll need it.

1) Which is a VALID Python variable name?
Answer: user_score_2 follows all rules.
2) What is the purpose of a comment?
Answer: Comments (#) are ignored by Python and explain code to humans.

3. Python Keywords

👆 Tap any keyword to learn what it does, how to use it, and when you'll need it.

4. Practice Questions

Test your understanding.

1) Which of the following is a VALID Python variable name (identifier)?
How: user_score_2 follows all rules.
Why the others are wrong: 2nd_place starts with a number. global is a keyword. user-score contains a hyphen.
2) What is the primary purpose of a comment in code?
How: Comments (starting with # in Python) are ignored by the computer and explain code to humans.