Question:1
Write a python script to take input for two numbers calculate and print their sum?
Sol:
a=int(input("Enter 1st no "))
b=int(input("Enter 2nd no "))
s=a+b
print("1st no = ",a)
print("2nd no = ",b)
print("Sum = ",s)
Output:
Enter 1st no 10 Enter 2nd no 20 1st no = 10 2nd no = 20 Sum = 30 >>>
Question:2
Write a python script to take input for a number calculate and print its square?
Sol:
a=int(input("Enter any no "))
b=a*a
print("Number ",a)
print("Square ",b)
Output:
Enter any no 5 Number 5 Square 25 >>>
Question:3
Write a python script to take input for a number calculate and print its cube?
Sol:
a=int(input("Enter any no "))
b=a*a*a
print("Number ",a)
print("Cube ",b)
Output:
Enter any no 5 Number 5 Cube 125 >>>
Question:4
Write a python script to take input for two numbers to calculate and print their difference?
Sol:
a=int(input("Enter 1st no "))
b=int(input("Enter 2nd no "))
d=a-b
print("1st no = ",a)
print("2nd no = ",b)
print("Difference = ",d)
Output:
Enter 1st no 10 Enter 2nd no 20 1st no = 10 2nd no = 20 Difference = -10 >>>




