Variables are “named boxes” that hold data. In Python you create one with a simple assignment:
cable_count = 5Now cable_count stores the integer 5.
Python variables can contain any of the basic (primitive) data types:
rating = 4.20 # float (decimal number)
name = "John" # string (text)
is_admin = True # boolean (True/False)You can even write multi-line strings by using triple quotes:
review = """
Python basics are so easy!
"""Hint: Choose clear, descriptive variable names, they make code easier for everyone (including future you) to read.
- Create a new file called
Task_2.py. - Inside it, declare four variables: an integer, a float, a string, and a boolean.
- Print each variable on its own line.
- Change at least two variables (e.g., add 3 to the integer, adjust the float), then print them again.
- Add a triple-quoted string to describe what you learned and print it.
When you run the file you should see the original values, the updated values, and your multi-line note.