ADVERTISEMENT
Google AdSense Slot (headerLeaderboard)
Set your Publisher ID in src/config/ads.ts to display live ads.
Python Tutorial• 5 min read
Python Variables & Types
Dynamic typing, strings, integers, floats, and booleans
In Python, variables are created when you assign a value to it. There is no declaration keyword like let or var.
Variable Assignment and Types
Python has dynamic typing: you do not need to declare variable types.
Common built-in types: int, float, str, bool.
Use type(variable) to inspect what data type an object holds.
Use casting functions: int(), float(), str() to convert between types.
Python Variables in Action
student_name = "Maya"
student_age = 22
gpa = 3.88
is_enrolled = True
# F-Strings: The modern way to format strings
summary = f"Student: {student_name}, Age: {student_age}, GPA: {gpa}"
print(summary)
print("Type of GPA:", type(gpa))ADVERTISEMENT
Google AdSense Slot (inContentBanner)
Set your Publisher ID in src/config/ads.ts to display live ads.
Test Yourself With Exercise
How do you format variables inside a Python string using modern f-string syntax?