On Day 3 of my Python challenge,I explored data types.
Data types define the kind of value a variable holds like whether it’s text,a number or True/False.Understanding them is super important because they determine what you can (and cannot) do with a value in Python.
Here’s the code I wrote today:
Here’s the code I wrote today:
# String (text)
name = "Sanaipei Lenapunya"
print(name)
print(type(name))
# Integer (whole number)
age = 15
print(age)
print(type(age))
# Float (decimal number)
height = 10.7
print(height)
print(type(height))
# Boolean (True/False)
is_learning_python = True
print(is_learning_python)
print(type(is_learning_python))
What happened when I ran it?
So each variable has a data type:
"Sanaipei Lenapunya" → str (string)
15 → int (integer)
10.7 → float (decimal number)
True → bool (boolean)
The type() function is super helpful when you’re unsure what type of data you’re working with.
GitHub update:
I saved my file as day3(data_type).py, then pushed it with:
git add 'day3(data_type).py'
git commit -m "data types with type()"
git push
Challenge for you:
Try creating your own variables (e.g., favorite number, your height, whether you like coding).
Use type() to check each one.
Your turn:
What’s the most surprising data type you discovered while testing with type()? Share it in the comments!
Top comments (0)