1+ #Variables declaration
2+ name = "Marcus"
3+ age = 20
4+ height = 5.9
5+ is_student = True
6+
7+ #String— Text data:
8+ first_name = "Marcus"
9+ last_name = 'Aurelius' # single or double quotes both work
10+ full_name = first_name + " " + last_name # joining strings is called concatenation
11+ print (full_name ) # Output: Marcus Aurelius
12+
13+ #Integer — whole numbers:
14+
15+ age = 25
16+ year = 2025
17+ score = - 10
18+ print (age + 5 ) # Output: 30
19+ print (year - 36 )
20+ print ("My score is: " , score )
21+
22+ #float — decimal numbers
23+ gpa = 3.75
24+ price = 9.99
25+ pi = 3.14159
26+
27+ #Boolean — True or False only
28+ is_logged_in = True
29+ has_permission = False
30+ # Industry note: Booleans power almost every decision in programming
31+
32+ #Nonetype The absence of value
33+ result = None
34+ # Used when a variable exists but has no value yet
35+ print (result )
36+
37+ #Checking and converting data type:
38+ name = "Marcus"
39+ age = 20
40+ gpa = 3.5
41+
42+ # Check what type a variable is
43+ print (type (name )) # <class 'str'>
44+ print (type (age )) # <class 'int'>
45+ print (type (gpa )) # <class 'float'>
46+
47+ # Convert between types (called Type Casting)
48+ age_as_string = str (age ) # "20"
49+ gpa_as_int = int (gpa ) # 3 (drops the decimal, doesn't round)
50+ number = float ("3.14" ) # 3.14
51+
52+ #Taking input from the user:
53+
54+ name = input ("What is your name? " )
55+ print ("Hello, " + name + "!" )
56+
57+ #⚠️ Important: input() always returns a string, even if the user types a number. So do this when you need a number:
58+
59+ age = int (input ("How old are you? " ))
60+ print ("In 10 years you'll be" , age + 10 )
61+
62+ #f-Strings — The Industry Standard Way to Format Output
63+ name = "Marcus"
64+ age = 20
65+ print (f"Hello { name } , you are { age } years old." )
66+ # Output: Hello Marcus, you are 20 years old.
67+
68+ #Lesson1 Summary:
69+ # Lesson 1 - Variables & Data Types
70+ # Store user info
71+ name = input ("Enter your name: " )
72+ age = int (input ("Enter your age: " ))
73+ city = input ("What city are you from? " )
74+
75+ # Calculate
76+ birth_year = 2025 - age
77+
78+ # Display using f-strings
79+ print (f"Name : { name } " )
80+ print (f"Age : { age } " )
81+ print (f"City : { city } " )
82+ print (f"Born in : { birth_year } " )
83+ print (f"Adult? : { age >= 18 } " )
0 commit comments