1๏ธโฃ Creating Variables
name = "Sameer"
age = 25
salary = 35000
is_employee = True
print(name)
print(age)
print(salary)
print(is_employee)
Output
Sameer
25
35000
True
2๏ธโฃ Variables with Different Data Types
student_name = "Ayesha"
roll_no = 12
percentage = 88.5
passed = True
print(student_name)
print(roll_no)
print(percentage)
print(passed)
Output
Ayesha
12
88.5
True
3๏ธโฃ Python Is Case-Sensitive
name = "Saddam"
Name = "Chandini"
print(name)
print(Name)
Output
Saddam
Chandini
4๏ธโฃ Assigning Multiple Variables at Once
name, age, city = "Gousya", 22, "Hyderabad"
print(name)
print(age)
print(city)
Output
Gousya
22
Hyderabad
5๏ธโฃ Variable Reassignment
person = "Sameer"
print(person)
person = "Ayesha"
print(person)
Output
Sameer
Ayesha
6๏ธโฃ Using Variables in Sentences
name = "Chandini"
age = 24
print(name, "is", age, "years old")
Output
Chandini is 24 years old
7๏ธโฃ Simple Calculation Using Variables
salary = 30000
bonus = 5000
total_income = salary + bonus
print("Total Income:", total_income)
Output
Total Income: 35000
8๏ธโฃ Checking Variable Data Types
name = "Saddam"
age = 28
height = 5.7
print(type(name))
print(type(age))
print(type(height))
Output
<class 'str'>
<class 'int'>
<class 'float'>
9๏ธโฃ Taking Input and Storing in Variables
name = input("Enter name: ")
age = input("Enter age: ")
print("Name:", name)
print("Age:", age)
Sample Output
Enter name: Sameer
Enter age: 26
Name: Sameer
Age: 26
๐ Input with Type Conversion
name = input("Enter name: ")
age = int(input("Enter age: "))
print(name, "will be", age + 1, "next year")
Sample Output
Enter name: Ayesha
Enter age: 23
Ayesha will be 24 next year

Leave a Reply