Python Programming Dated 16-07-2021
Python Programming Dated 16-07-2021
Q1 Write a program to input principal Amount rate and time and calculate simple
interest.
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
Q3. Write a program to input two numbers and swap their values without using third
variable.
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
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.
15/07/2021
Q7 Write a program to input principal Amount rate and time and calculate
amount and compound interest.
Q8. Write a program to input 3 sides of a triangle and calcualte area of triangle
using
heros formaula.
#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.
#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.
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.
Example" WAP to input any number and check whether the entered number is
even or odd.
Example" WAP to input year number and check whether the entered year is
leap year or not.
16/07/2021
if..elif..else statement:
This statement allows us to test number of conditions in the program the condition
which is evaluated to true then statement present on that condtion will be exceuted
if no condition is evaluated to true then statement present on else will be
executed.
Syntax:
if(condtion 1):
statement to be exceuted when condition 1 is true
elif(condtion 2):
statement to be exceuted when condition 2 is true
elif(condtion 3):
statement to be exceuted when condition 3 is true
elif(condtion 4):
statement to be exceuted when condition 4 is true
elif(condtion 5):
statement to be exceuted when condition 5 is true
:
:
:
else:
statement to be exceuted when condition is false
Q1 Write a program to input any number and check whether the entered number is
negative, positive or zero.
H.W.
Q2 Write a program to input day number and display week day using if..elif..else
statement.
Q3. Write a program to input month number and print month name using if..elif..else
statement.
Q4. Write a program to input two numbers and find out the largest number.
a=int(input("Enter First Number"))
b=int(input("Enter Second Number"))
if(a>b):
print("Largest Number is",a)
elif(b>a):
print("Largest Number is",b)
else:
print("Both Numbers are equal")
Q5 Write a program to input three number and find out the largest number.
Q6 Write a program to input four number and find out the largest number.
H.W.
Q7 Write a program to input five number and find out the largest number.
Q8 Write a program to input six number and find out the largest number.
Q9. Write a program to input two numbers and find out the smallest number.
Q10 Write a program to input three number and find out the smallest number.
Q11 Write a program to input four number and find out the smallest number.
Q12 Write a program to input five number and find out the smallest number.
Q13 Write a program to input six number and find out the smallest number.
Q14 Write a program in python that will ask the user to input two numbers and
an operator ( + , - , * , /)and then perform addition, substraction,
multiplication and division
and finally display result.