77#String— Text data:
88first_name = "Marcus"
99last_name = 'Aurelius' # single or double quotes both work
10- full_name = first_name + " " + last_name # joining strings is called concatenation
10+ full_name = first_name + " " + last_name # joining strings is called concatenation
1111print (full_name ) # Output: Marcus Aurelius
1212
1313#Integer — whole numbers:
1414
1515age = 25
1616year = 2025
1717score = - 10
18- print (age + 5 ) # Output: 30
18+ print (age + 5 ) # Output: 30
1919print (year - 36 )
2020print ("My score is: " , score )
2121
22- #float — decimal numbers
22+ #float — decimal numbers
2323gpa = 3.75
2424price = 9.99
2525pi = 3.14159
2626
27- #Boolean — True or False only
27+ #Boolean — True or False only
2828is_logged_in = True
2929has_permission = False
3030# Industry note: Booleans power almost every decision in programming
3131
32- #Nonetype The absence of value
32+ #Nonetype The absence of value
3333result = None
3434# Used when a variable exists but has no value yet
3535print (result )
4040gpa = 3.5
4141
4242# Check what type a variable is
43- print (type (name )) # <class 'str'>
44- print (type (age )) # <class 'int'>
45- print (type (gpa )) # <class 'float'>
43+ print (type (name )) # <class 'str'>
44+ print (type (age )) # <class 'int'>
45+ print (type (gpa )) # <class 'float'>
4646
4747# Convert between types (called Type Casting)
4848age_as_string = str (age ) # "20"
49- gpa_as_int = int (gpa ) # 3 (drops the decimal, doesn't round)
49+ gpa_as_int = int (gpa ) # 3 (drops the decimal, doesn't round)
5050number = float ("3.14" ) # 3.14
5151
5252#Taking input from the user:
6262#f-Strings — The Industry Standard Way to Format Output
6363name = "Marcus"
6464age = 20
65- print (f"Hello { name } , you are { age } years old." )
65+ print (f"Hello {
66+ name
67+ } , you are {
68+ age
69+ } years old." )
6670# Output: Hello Marcus, you are 20 years old.
6771
6872#Lesson1 Summary:
7680birth_year = 2025 - age
7781
7882# 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 } " )
83+ print (f"Name : {
84+ name
85+ } " )
86+ print (f"Age : {
87+ age
88+ } " )
89+ print (f"City : {
90+ city
91+ } " )
92+ print (f"Born in : {
93+ birth_year
94+ } " )
95+ print (f"Adult? : {
96+ age >= 18
97+ } " )
0 commit comments