1) Write a program to input three numbers and find the smallest one
# obtaining three integers from the user
num_one = int(input("Enter the first number: "))
num_two = int(input("Enter the second number: "))
num_three = int(input("Enter the third number: "))
print("The smallest number is", end=" ")
# finding the smallest integer and printing it
# if the first integer is the smallest
if num_one < num_two and num_one < num_three:
print(num_one)
# if the second integer is the smallest
elif num_two < num_one and num_two < num_three:
print(num_two)
# if the third integer is the smallest
elif num_three < num_one and num_three < num_two:
print(num_three)
# EXCEPTIONAL CASE: if all the three integers given by the user have an equal value
(num_one=num_two=num_three)
else:
print(num_one)
2) Write a program to swap the values of two variables
# obtaining two words from the user
a = input("Enter the first word: ")
b = input("Enter the second number: ")
# creating additional variable to store the value of word one
placeholder = a
# assigning the value of second variable to first variable
a=b
# assigning the value of first variable stored in placeholder to the
second variable
b = placeholder
# printing both values
print("first word = ", a)
print("second word = ", b)
3) Write a program that asks the user for their name and age. Print a
message addressed to the user that tells the user the year in
which they will turn 100 years old.
# asking the user for their name and age
name = input("What's your name? ")
age = int(input("What's your age? "))
# calculating the year in which the user will turn 100
year = (100 - age) + 2024
# displaying message to the user
print(f"Hello, {name}! You will turn a 100 years old in {year}!")
4) ABC is an India based company that deals with electric and
electronic items. Write a program to calculate total selling price
after levying of GST. To calculate the net price, Central
Government and State Government GST rates are applicable as
given under
Item GST rate
Electrical items <= 5000 5%
Electrical items >= 5000 18%
Electrical items <= 10000 5%
Electrical items >= 10000 12%
# asking the user for the cost of their item
item_price = int(input("What's the price of your item? "))
if item_price <= 5000:
total = item_price + (5/100) * item_price
elif item_price >= 5000:
total = item_price + (18/100) * item_price
elif item_price <= 10000:
total = item_price + (5/100) * item_price
else:
total = item_price + (12/100) * item_price
print("The total selling price is", total)