CBSE Class 11: Python Fundamentals 9

Question:9
Write a python script to calculate and print area and perimeter of rectangle?
Sol:

l=int(input("Enter length of rectangle "))
w=int(input("Enter width of rectangle "))
a=l*w
p=2*(l+w)
print("Area = ",a)
print("Perimeter = ",p)

Output:

Enter length of rectangle 2
Enter width of rectangle 3
Area =  6
Perimeter =  10
>>> 

Question:10
Write a python script to calculate and print area and circumference of the circle?
Sol:

r=float(input("Enter radius of circle "))
a=3.1415*r*r
c=2*3.1415*r
print("Area = ",a)
print("Circumference = ",c)

Output:

Enter radius of circle 2.3
Area =  16.618534999999998
Circumference =  14.450899999999999
>>> 

Question:11
Write a python script to calculate and print Simple Interest?
Sol:

p=float(input("Enter principle  "))
r=float(input("Enter rate "))
t=float(input("Enter time "))
si=(p*r*t)/100
print("SI = ",si)

Output:

Enter principle  1000
Enter rate 5
Enter time 5
SI =  250.0
>>> 

Question:12
Write a python script to take input for two numbers and interchange them (swap them)? (Method :1)(using third variable)
Sol:

a=int(input("Enter 1st no "))
b=int(input("Enter 2nd no "))
print("1st value ",a," 2nd value ",b)
t=a
a=b
b=t
print("1st value ",a," 2nd value ",b)

Output:

Enter 1st no 10
Enter 2nd no 20
1st value  10  2nd value  20
1st value  20  2nd value  10
>>>