CBSE Class 11: Python Fundamentals 8

Question:5
Write a python script to take input for three numbers calculate and print their product?
Sol:

a=int(input("Enter 1st no "))
b=int(input("Enter 2nd no "))
c=int(input("Enter 3rd no "))
p=a*b*c
print("1st no = ",a)
print("2nd no = ",b)
print("3rd no = ",c)
print("Product = ",p)

Output:

Enter 1st no 2
Enter 2nd no 3
Enter 3rd no 6
1st no =  2
2nd no =  3
3rd no =  6
Product =  36
>>> 

Question:6
Write a python script to take input for two numbers calculate and print their sum, product, difference, and average?
Sol:

a=int(input("Enter 1st no "))
b=int(input("Enter 2nd no "))
s=a+b
d=a-b
p=a*b
av=(a+b)/2
print("1st no = ",a)
print("2nd no = ",b)
print("Sum = ",s)
print("Product = ",p)
print("Difference = ",d)
print("Average = ",av)

Output:

Enter 1st no 10
Enter 2nd no 20
1st no =  10
2nd no =  20
Sum =  30
Product =  200
Difference =  -10
Average =  15.0
>>> 

Question:7
Write a python script to take input for a number calculate and print its square and cube?
Sol:

n=int(input("Enter any no "))
s=n*n
c=n*n*n
print("Number = ",n)
print("Square = ",s)
print("Cube = ",c)

Output:

Enter any no 5
Number =  5
Square =  25
Cube =  125
>>> 

Question:8
Write a python script to calculate and print the area and perimeter of the square?
Sol:

s=int(input("Enter side of square "))
a=s*s
p=4*s
print("Side = ",s)
print("Area = ",a)
print("Perimeter = ",p)

Output:

Enter side of square 6
Side =  6
Area =  36
Perimeter =  24
>>>