Notes 1
1. Write a program to print "Hello World"
Program:
print("Hello world")
Output:
Hello world
2. Write a program (WAP) to assign the cost of two mobile phones and find their total cost.
Program:
m1=15000
m2=5000
total=m1+m2
print("Total cost=", total)
Output:
Total cost= 20000
3. Write a program (WAP) to input the cost of two mobile phones and find their total cost.
Program:
m1=int(input("What is the cost of first phone?"))
m2=int(input("What is the cost od secong phone?"))
total=m1+m2
print("Total cost=", total)
Output:
What is the cost of first phone?20000
What is the cost od secong phone?46000
Total cost= 66000
4. WAP to input the speed of 3 trains and calculate their sum and average.
Program:
s1=int(input("Enter the speed of train 1"))
s2=int(input("Enter the speed of train 2"))
s3=int(input("Enter the speed of train 3"))
sum=s1+s2+s3
avg=sum/3
print("Total speed=", sum)
print("Average speed=", avg)
Output:
Enter the speed of train 1150
Enter the speed of train 2200
Enter the speed of train 3300
Total speed= 650
Average speed= 216.66666666666666
5. WAP to input length and breadth to calculate the area of a rectangle.
Program:
l=int(input("Enter the length of rectangle "))
b=int(input("Enter the breadth of rectangle"))
area=l*b
print("Area of a rectangle=", area)
Output:
Enter the length of rectangle 45
Enter the breadth of rectangle5
Area of a rectangle= 225
Notes 2
1. WAP to interchange the values of two numbers using a third variable
Program:
a=int(input("Enter the first number "))
b=int(input("Enter the second number"))
c=a
a=b
b=c
print("First number=", a)
print("Second number=", b)
Output:
Enter the first number 4
Enter the second number5
First number= 5
Second number= 4
2. Write a program to input and find the value of the following expression and then display the output
Z = (a5 + b2 – c9) / 2a
Program:
a=int(input("Enter the value of a "))
b=int(input("Enter the value of b "))
c=int(input("Enter the value of c "))
z=(pow(a,5)+(b*b)-pow(c,9))/(2*a)
print("Result=", z)
Output:
Enter the value of a 2
Enter the value of b 3
Enter the value of c 1
Result= 10.0
3. Write a program to accept the basic salary of a person and then print the total salary if
HRA=25% of basic TA=15% of Basic ENT = 10% of Basic PF = 12% of basic
Gross salary = basic + HRA + TA + ENT
Net salary = Gross salary - PF
Program:
b= float(input("Enter the basic salary of the employee"))
hra=(25*b)/100
ta=(15*b)/100
ent=(10*b)/100
pf=(12*b)/100
gross=b+hra+ta+ent
net=gross-pf
print("Total Gross salary=", gross)
print("Total net salary=", net)
Output:
Enter the basic salary of the employee30000
Total Gross salary= 45000.0
Total net salary= 41400.0
Notes 3
1. WAP to find whether a given number is odd or even
Program:
n=int(input("Enter a number"))
if(n%2==0):
print("Even")
else:
print("Odd")
Output:
Enter a number15
Odd
Enter a number88
Even
2. WAP to input 2 numbers and display the largest number among them/ input age of 2 children and display who is
oldest
Program:
n1=int(input("Enter the first number"))
n2=int(input("Enter the second number"))
if(n1==n2):
print("Both are equal")
if(n1>n2):
print("First number is greatest")
if(n2>n1):
print("Second number is greatest")
Output:
Enter the first number15
Enter the second number18
Second number is greatest
Enter the first number22
Enter the second number19
First number is greatest
Enter the first number5
Enter the second number5
Both are equal
3. WAP to input the age of a person and find whether he is eligible to vote or not.
Program:
age=int(input("Enter the age of the person"))
if(age>=18):
print("Eligible to vote")
else:
print("Not eligible to vote")
Output:
Enter the age of the person45
Eligible to vote
Enter the age of the person11
Not eligible to vote
Notes 4
1. WAP to input the total amount in a bill if the amount is greater than 1000 then a discount of 100 is given, otherwise
no discount is given
Program:
bill=float(input("Enter the total bill amount"))
if(bill>=1000):
print("Discount of 100 Rs is given")
bill=bill-100
print("Amount to be paid=", bill)
else:
print("No discount is given")
Output:
Enter the total bill amount900
No discount is given
2. WAP to input the size of a pizza. If the user chooses “m” display “Medium else display “Large”.
Program:
size=input("Enter the size of the pizza you need m - for medium and l - for large")
if(size=='m'):
print("Medium size pizza")
else:
print("Large size pizza")
Output:
Enter the size of the pizza you need m - for medium and l - for largem
Medium size pizza
Enter the size of the pizza you need m - for medium and l - for largel
Large size pizza
3. WAP to input the income and expenses of an ice cream stall for the month of June. Check, if it is profit or loss
Program:
income=float(input("Enter the income of an ice cream stall for the month of june"))
expense=float(input("Enter the expense of an ice cream stall for the month of june"))
if(income>expense):
print("Profit")
else:
print("loss")
Output:
Enter the income of an ice cream stall for the month of june18000
Enter the expense of an ice cream stall for the month of june10000
Profit
Enter the income of an ice cream stall for the month of june1000
Enter the expense of an ice cream stall for the month of june5000
loss
Notes 5
1. WAP to display the three given elective subject options for a student. If the student chooses the subject code,
display the respective Subject Name
Subject Subject
Code Name
1 Computer
2 Arts
3 Cookery
Program:
print("1- Computer ")
print("2- Arts ")
print("3- Cookery ")
o=int(input("Enter your choice "))
if(o==1):
print("You have opted computer ")
elif(o==2):
print("You have opted Art ")
elif(o==3):
print("You have opted cookery ")
else:
print("Wrong choice")
Output:
1- Computer
2- Arts
3- Cookery
Enter your choice 1
You have opted computer
1- Computer
2- Arts
3- Cookery
Enter your choice 2
You have opted Art
1- Computer
2- Arts
3- Cookery
Enter your choice 3
You have opted cookery
1- Computer
2- Arts
3- Cookery
Enter your choice 10
Wrong choice
2. Write a program that will input the ID, weight and height of a student, and calculate their body mass index
(BMI) and output their ID, BMI and a comment as follows:
A BMI greater than 25 will get the comment ‘OVER WEIGHT’, a BMI between 25 and 19
(inclusive) will get ‘NORMAL’ and a BMI less than 19 will get ‘UNDER WEIGHT’.
Program:
id=int(input("Enter the student ID"))
w=int(input("Enter the weight of the student"))
h=int(input("Enter the height of the student"))
bmi=w/(h*h)
print("ID=", id)
print("Body mass index=", bmi)
if(bmi>25):
print("OVER WEIGHT")
elif(bmi<=25 and bmi>=19):
print("NORMAL")
elif(bmi<19):
print("UNDER WEIGHT")
Output:
Enter the student ID123
Enter the weight of the student100
Enter the height of the student4
ID= 123
Body mass index= 6.25
UNDER WEIGHT
3. WAP to input some amount in indian currency and then convert to different currency value based on the user’s
choice. Follow the table below
Choice Country’s Value
1 Rs. 60 = 1 $ (US)
2 Rs 102= 1 Pounds (UK)
3 Rs 9.68= 1 yuan (Chinese)
4 Rs 13.38= 1 Dinar (Kuwait)
Program:
print("1- US ")
print("2- UK ")
print("3- Chinese ")
print("4- Khuwait ")
c=int(input("Enter your chocie"))
ind=float(input("Enter Indian currency"))
if(c==1):
us=ind/60
print("US Currency value=", us)
elif(c==2):
uk=ind/102
print("UK Currency value=", uk)
elif(c==3):
ch=ind/19.68
print("Chinese Currency value=", ch)
elif(c==4):
ku=ind/13.38
print("kuWait Currency value=", ku)
else:
print("Wrong choice")
Output:
1- US
2- UK
3- Chinese
4- Khuwait
Enter your chocie1
Enter Indian currency5000
US Currency value= 83.33333333333333
1- US
2- UK
3- Chinese
4- Khuwait
Enter your chocie5
Enter Indian currency200
Wrong choice
3. A house owner must pay tax based on the value of the house. WAP to calculate the tax for the given criteria.
House Value Tax Percentage
>=200000 2%
>=100000 1.5%
>=50000 1%
<50000 0
Program:
v=float(input("Enter the value of the house"))
if(v>=200000):
tax=(2*v)/100
elif(v>=100000):
tax=(1.5*v)/100
elif(v>=50000):
tax=(1*v)/100
elif(v<50000):
tax=0
print("Tax amount=", tax)
Output:
Enter the value of the house200000
Tax amount= 4000.0
Enter the value of the house100
Tax amount= 0
Notes 6
1. Write a program to input Name, Roll No and marks of five subjects. The Grade is assigned based on the following
criteria:-
Average marks Grade
90% and above A*
80% - 89% A
70% - 79% B
60% - 69% C
Below 60% D
Program:
name=input("Enter the name of the student")
rn=input("Enter the roll number of the student")
s1=float(input("Enter the marks in subject 1"))
s2=float(input("Enter the marks in subject 2"))
s3=float(input("Enter the marks in subject 3"))
s4=float(input("Enter the marks in subject 4"))
s5=float(input("Enter the marks in subject 5"))
avg=(s1+s2+s3+s4+s5)/5
if(avg>=90):
print("A*")
elif(avg>=80 and avg<=89):
print("A")
elif(avg>=70 and avg<=79):
print("B")
elif(avg>=60 and avg<=69):
print("C")
elif(avg<60):
print("D")
Output:
Enter the name of the studentAnu
Enter the roll number of the student123
Enter the marks in subject 189
Enter the marks in subject 290
Enter the marks in subject 398
Enter the marks in subject 477
Enter the marks in subject 580
A
2. A Textile industry has announced the following festival discounts on the purchase of items, based on the total cost
of the items purchased:
Total cost Discount
percentage
5%
Less than Rs. 2000
25%
Rs. 2001 to Rs.5000
35%
Rs. 5001 to Rs.10000
50%
Above Rs. 10000
Calculate the discount amount and the total amount to be paid by the customer.
Program:
tc=float(input("Enter the total cost of the items purchased"))
if(tc<=2000):
dis=(5*tc)/100
elif(tc>=2001 and tc<=5000):
dis=(25*tc)/100
elif(tc>=5001 and tc<=10000):
dis=(35*tc)/100
elif(tc>10000):
dis=(50*tc)/100
amt=tc-dis
print("Amount to be paid after discount=", amt)
Output:
Enter the total cost of the items purchased1500
Amount to be paid after discount= 1425.0
Enter the total cost of the items purchased15000
Amount to be paid after discount= 7500.0