Python was created by Guido Van Rossum and first released in 1991. It is now one of the most widely used programming languages in the world.
Your basics.py file lists 9 key features:
| Feature | What it means |
|---|---|
| Interpreted | Code runs line by line — no compilation step needed |
| Open source | Free to use, anyone can contribute to Python itself |
| Cross-platform | Same code runs on Windows, Mac, and Linux |
| Base for AI/ML | Libraries like NumPy, TensorFlow, PyTorch are Python-first |
| Bigger community | Huge ecosystem of tutorials, packages, and forums |
| Multi-paradigm | Supports procedural, OOP, and functional styles |
| Dynamic typing | You don't declare variable types — Python figures it out |
| Simple syntax | Reads almost like English — easier to learn and read |
| Extensive libraries | Thousands of ready-made packages via pip |
A comment is a line Python ignores completely. Use # to write one. Comments explain your code for humans.
# This is a comment — Python skips this line print("Hello World") # inline comment is also fine
basics.py starts with # Python Basics and # created by - Guido Van Rossum — those are comments. The actual code is below them.
A variable is a named container that stores a value in memory. Python uses dynamic typing — you don't need to declare the type, just assign a value.
name = "Alice" # stores a string age = 25 # stores an integer height = 5.7 # stores a float is_student = True # stores a boolean
_)Name and name are different variablesif, for, printEvery value in Python has a type. The 4 core types at this stage:
| Type | Keyword | Example | Notes |
|---|---|---|---|
| Integer | int | 42, -7 | Whole numbers, no decimal |
| Float | float | 3.14, -0.5 | Numbers with decimal point |
| String | str | "hello", 'hi' | Text in quotes (single or double) |
| Boolean | bool | True, False | Only two values — capital T and F |
Use type() to check a value's type:
print(type(42)) # <class 'int'> print(type(3.14)) # <class 'float'> print(type("hi")) # <class 'str'> print(type(True)) # <class 'bool'>
You can convert between types using built-in functions:
| Function | Converts to | Example | Result |
|---|---|---|---|
int() | Integer | int("5") | 5 |
float() | Float | float("3.14") | 3.14 |
str() | String | str(42) | "42" |
bool() | Boolean | bool(0) | False |
input() always returns a string, even if the user types a number. You must cast it: int(input("Enter: "))
These are Python's basic output and input functions — exactly what your teacher's basics.py demonstrates.
print("Hello World") # prints text print(42) # prints a number print("Age:", 25) # prints multiple values with space print("Name:" + " Alice") # concatenation (strings only)
name = input("Enter your name: ") # shows prompt, waits for user print("Hello", name) # Always cast numeric input! number = int(input("Enter a number: ")) print(number)
basics.py are exactly this pattern: number = int(input("Enter a number: ")) and print(number)
Try each drill on paper or in your code editor. Reveal the answer only after attempting it yourself.
Write Python code that stores your name in a variable called my_name, your age in my_age, and your height in metres in my_height. Then print all three on separate lines.
my_name = "Joyal" # str my_age = 20 # int my_height = 1.75 # float print(my_name) print(my_age) print(my_height)
Each variable stores a different type: str, int, float.
Ask the user to enter their birth year using input(). Store it as an integer, then calculate and print their age (assume current year is 2026).
birth_year = int(input("Enter your birth year: ")) age = 2026 - birth_year print("Your age is:", age)
Without int(), the subtraction would fail — you can't subtract a string from a number.
Before running code, predict the output of each type() call below. Write your answers, then check by running the code.
print(type("100")) print(type(100)) print(type(100.0)) print(type(True)) print(type(int("100")))
# <class 'str'> — "100" has quotes, so it's a string # <class 'int'> — 100 is a whole number # <class 'float'> — 100.0 has a decimal point # <class 'bool'> — True is a boolean # <class 'int'> — int("100") converts the string to integer
Quotes always make something a string, even if it looks like a number.
1 Who created the Python programming language?
2 What does input() always return, regardless of what the user types?
3 What does dynamic typing mean in Python?
4 Which variable name is invalid in Python?
5 What does print(type(3.14)) output?
# for comments — Python ignores themint, float, str, booltype() to check a value's typeint(), float(), str()input() always returns str — cast it for numbers