Python Code
Python Code
1 :
# Get user input
else:
total_expense = total_cost
OUTPUT :
Q.2 :
print()
OUTPUT :
Numbers from 1 to 10:
1 2 3 4 5 6 7 8 9 10
Alphabets from A to Z:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Q.3 :
# Initialize variables
sum_natural = 0
i=1
while i <= n:
sum_natural += i
i += 1
OUTPUT :
Enter a positive integer (n): 5
Q.4 :
# Initialize counter
i=1
while True:
i += 1
if i > 10:
break
OUTPUT:
5x1=5
5 x 2 = 10
5 x 3 = 15
5 x 10 = 50
Q.5:
while True:
if first_name.lower() == 'exit':
break
if last_name.lower() == 'exit':
break
print(formatted)
OUTPUT:
Q.7 :
cost = 2500
cost = 4000
else:
cost = 1500
if cost == 0:
else:
Q.7 :
user_info = {
"Name": "Zaid",
"Email-ID": "[email protected]",
"Phone": "9876543210",
"Height": "5'8\"",
print("User Info:")
print(f"{key}: {value}")
user_info.popitem()
additional_info.popitem()
print(user_info)
OUTPUT:
User Info:
Name: Zaid
Email-ID: [email protected]
Phone: 9876543210