You are on page 1of 4

14/07/2021

Q1 Write a program to input principal Amount rate and time and calculate simple
interest.

p=int(input("Enter principal Amount"))


r=int(input("Enter Rate"))
t=int(input("Enter Time"))
si=(p*r*t)/100
print("The Simple Interest is",si)

Q2. Write a program to input two numebrs and swap their values using third variable
Swapping: Interchanging values of variable is called Swapping
Teachinque used in swapping
1) Using third variable
2) Without using third varaible

a=int(input("before Swapping Enter value of a"))


b=int(input("before Swapping Enter value of b"))
c=a
a=b
b=c
print("After Swapping the value of a is",a)
print("After Swapping thr value of b is",b)

Q3. Write a program to input two numbers and swap their values without using third
variable.

a=int(input("before Swapping Enter value of a"))


b=int(input("before Swapping Enter value of b"))
a=a+b
b=a-b
a=a-b
print("After Swapping the value of a is",a)
print("After Swapping thr value of b is",b)

a=10
b=5
a=a+b =10+5 a=15
b=a-b =15-5 b=10
a=a-b=15-10 a=5

Q4. Write a program to input basic salary, da, hra, pf and calculate net salary.
net=basic+da+hra-pf

basic=int(input("Enter basic Salary"))


da=int(input("Enter Daily Allowance DA"))
hra=int(input("Enter House Rent Allowance HRA"))
pf=int(input("Enter Provident Fund Pf"))
net=basic+da+hra-pf
print("The net Salary is",net)

Q5. Write a program to input basic salary and calcualte net salary.
da=50% of basic salary
hra=30% of basic salary
pf=10% of basic salary
net=basic+da+hra-pf
basic=float(input("Enter basic Salary"))
da=(basic*50)/100
hra=(basic*30)/100
pf=(basic*10)/100
net=basic+da+hra-pf
print("The basic salary is",basic)
print("The Da is",da)
print("The hra is",hra)
print("The pf is",pf)
print("The net Salary is",net)

Q6 Write a program to input marks in five subject out of 100 and calculate total
marks,
percentage marks, average marks.

sname=input("Enter Student Name")


eng=float(input("Enter marks in english out of 100"))
math=float(input("Enter marks in maths out of 100"))
phy=float(input("Enter marks in Physics out of 100"))
chem=float(input("Enter marks in Chemistry out of 100"))
comp=float(input("Enter marks in Computer Science out of 100"))
total=eng+math+phy+chem+comp
per=(total/500)*100
avg=total/5
print("___________________________")
print("REPORT CARD OF:",sname)
print("___________________________")
print("The Total marks is",total)
print("The percentage marks is",per)
print("The Average marks is",avg)

15/07/2021

Q7 Write a program to input principal Amount rate and time and calculate
amount and compound interest.

p=float(input("Enter principal Amount"))


r=float(input("Enter Rate"))
t=float(input("Enter Time"))
a=p*(1+r/100)**t
i=a-p
print("The Amount is",a)
print("The Interest is",i)

Q8. Write a program to input 3 sides of a triangle and calcualte area of triangle
using
heros formaula.

a=int(input("Enter First Side of a Triangle"))


b=int(input("Enter Second Side of a Triangle"))
c=int(input("Enter Third Side of a Triangle"))
s=(a+b+c)/2
a=(s*(s-a)*(s-b)*(s-c))**0.5
print("The Area of Triangle is",a)
Q9. Write a parogram to input any number and find out the last digit of that
number.

a=int(input("Enter Any number"))


b=a%10
print("The Last Digit of the number is",b)

#Note:

#b=a%10
# Divide the number a by 10 and remainder will store in variable.

Q10 Write a program to input any Five Digit number and find out the sum of its
first and last digit.

a=int(input("Enter Any Five Digit number"))


b=a//10000
c=a%10
d=b+c
print("The Sum of First and last Digit is",d)

#Tracing
# a=12345 input
# b=a//10000 b=12345//10000 b=1
# c=a%10 =12345%10 c=5
# d=b+c =1+5=6

___________________________________________________________________________________
______

Type-2
Programs based on Conditional
Statement
if statement:
in this statenent first condition is checked and if the condtion is true then
statements are executed. if the condition is false then no statement is
executed.
Syntax:
if(Conditon):
Statement to be executed when condition is True

Example:
WAP to input your age and if your age is greater than equal to 18 then
display the message you are eligible for vote. otherwise display the
message you are not eligible for vote.

age=int(input("Enter your age"))


if(age>=18):
print("You are Eligible for vote")
if(age<18):
print("You are not Eligible for vote")

if..else statement
in this statenent first condition is checked and if the condtion is true then
a set of statement is executed if the conditon is false then another set of
statement is executed.
if(Conditon):
Statement to be executed when condition is True
else:
Statement to be executed when condition is False

Example:
WAP to input your age and if your age is greater than equal to 18 then
display the message you are eligible for vote. Otherwise display the
message you are not eligible for vote.

age=int(input("Enter your age"))


if(age>=18):
print("You are Eligible for vote")
else:
print("You are not Eligible for vote")

Example" WAP to input any number and check whether the entered number is
even or odd.

a=int(input("Enter Any Number"))


if(a%2==0):
print("Even Number")
else:
print("odd Number")

Example" WAP to input year number and check whether the entered year is
leap year or not.

year=int(input("Enter Year Number"))


if(year%4==0):
print("Leap Year")
else:
print("Not a Leap Year")

You might also like