Skip to content

Latest commit

 

History

History
45 lines (31 loc) · 1.15 KB

File metadata and controls

45 lines (31 loc) · 1.15 KB

Task 2 - Variables

Variables are “named boxes” that hold data. In Python you create one with a simple assignment:

cable_count = 5

Now cable_count stores the integer 5.


Primitive value types

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.


Your exercise

  1. Create a new file called Task_2.py.
  2. Inside it, declare four variables: an integer, a float, a string, and a boolean.
  3. Print each variable on its own line.
  4. Change at least two variables (e.g., add 3 to the integer, adjust the float), then print them again.
  5. 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.