Hello-Calc: Python Basics
An interactive introduction to Python's core concepts. Learn about variables, see the list of reserved keywords, understand identifier rules, and see how comments work, all in one place.
1. Variables & Calculation
A variable stores a value. Enter two numbers below to see them stored in variables and then added together.
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
andmyvar
are different).
3. Python Keywords
Keywords are the reserved words in Python; you can't use them as variable names. Tap a keyword to see its purpose.
4. Practice Questions
Test your understanding of the concepts.
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, which is not allowed.2) What is the primary purpose of a comment in code?
How: Comments (starting with
#
in Python) are ignored by the computer and are meant to provide explanations for humans reading the code.