- Some very basic but important programs which will make the student familiar with python script mode programming.
- Programs related to taking input for numeric values and performing calculations
Q1. Write a python script to take input for two numbers calculate and print their sum?
Q2. Write a python script to take input for a number calculate and print its square?
Q3. Write a python script to take input for a number, calculate and print its cube?
Q4. Write a python script to take input for two numbers, calculate and print their difference?
Q5. Write a python script to take input for three numbers, calculate and print their product?
Solutions
Q1.
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)
Q2.
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)
Q3.
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)
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)
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)