Lab · School of Computer Science & Technology
Lab 1 — Variables & Data Types
Goal
Create variables of each core type, then hit the classic "type" bug and fix it.
Tasks
Create variables for a made-up student:
name(a string),age(an integer),gpa(a float),is_enrolled(a boolean).
Print a sentence using them, e.g.:
Ada is 25 years old, GPA 3.8, enrolled: TrueUse either
+concatenation or an f-string (f"...").The bug: You receive the age as text from a form:
age_text = "25". Try to computeage_text + 5. What happens? Read the error.The fix: Convert the text to a number first, then add 5. Print the result.
Stretch (optional)
- Print the type of each variable with
type(name),type(age), etc. - Try
print(0.1 + 0.2). Is it exactly0.3? Why might that matter when cleaning data?
What you're practicing
Declaring variables, the core types (int/float/str/bool), and type conversion — the everyday reality of turning messy text data into numbers.