Python Programs For Lab Practicals
Python Programs For Lab Practicals
OUTPUT:
enter the principal amount:100000
enter the interest rate:8
enter the time in years:3
The Simple Interest Will be: 24000.0
Amount payable is: Rs. 124000.0
OUTPUT:
Enter the length:8
Enter the breath:7
The area of Rectangle is : 56
Enter the value of Side:9
The Perimeter of a square is: 36
4.Write a program to swap two numbers using and without using
a third variable.
Ans.
Swapping without using third variable
a=int(input("enter the value of a: "))
b=int(input("enter the value of b: "))
a,b=b,a
print("a=",a)
print("b=",b)
OUTPUT:
enter the value of a: 10
enter the value of b: 8
a= 8
b= 10
Swapping using third variable
a=int(input("enter the value of a: "))
b=int(input("enter the value of b: "))
temp = a
a=b
b = temp
print("a=",a)
print("b=",b)
OUTPUT:
enter the value of a: 15
enter the value of b: 25
a= 25
b= 15
5. Write a Python Program to print maximum of given three
numbers.
a=int(input("Enter the value of a: "))
b=int(input("Enter the value of b: "))
c=int(input("Enter the value of c: "))
if a>b:
if a>c:
print("The Greatest Number is",a)
else:
print("The Greatest Number is",c)
elif b>c:
print("The Greatest Number is",b)
else:
print("The Greatest Number is",c)
OUTPUT:
Enter the value of a: 8
Enter the value of b: 9
Enter the value of c: 10
The Greatest Number is 10