Practical File
Practical File
PRACTICAL FILE
Roll no: 20
Submitted To: Ms. Vishesha Sharma
INDEX
S.NO TOPIC
1 Age Calculator
Write a Python program that asks the user to enter their age.
● If the age is between 0 and 1, print "You are an infant."
● If the age is between 1 to 18, print “You are minor.”
● If the age is between 18 and 60 (inclusive), print "You are an adult."
● If the age is above 60, print "You are a senior citizen."
● If the user enters an invalid age, print “Invalid input”.
Source Code :-
age=float(input("Your age="))
if age < 0:
print("Invalid input")
elif 0 <= age <= 1:
print("You are an infant.")
elif 1 < age < 18:
print("You are a minor.")
elif 18 <= age <= 60:
print("You are an adult.")
elif age > 60:
print("You are a senior citizen.")
else:
print("Invalid input")
Output :-
Program 2:
Source Code :-
Output :-
Program 3:
Source Code :-
name= input("Name of the fruit (Watermelon, Mango, Pear, Apple, Grapefruit, Grapes)=")
name1= name.lower()
if name1== "watermelon" or name1=="mango":
print("Summer Fruit")
elif name1== "pear" or name1=="apple":
print("Winter Fruit")
elif name1=="grapefruit" or name1=="grapes":
print("Autumn Fruit")
Output :-
Program 4
Source Code :-
Output :-
Program 5
Source Code :-
Output: