Basic Programming Set 2

TOP

Q6. Write a python script to take input for two numbers calculate and print their sum, product , difference and average?

Q7. Write a python script to take input for a number calculate and print its square and cube?

Q8. Write a python script to calculate and print area and perimeter of square?

Q9. Write a python script to calculate and print area and perimeter of rectangle?

Q10. Write a python script to calculate and print area and circumference of circle?

 

Solutions

Q6.

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)
Go Top

Q7.

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)

Go Top

Q8.

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)

Go Top

Q9.

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 widthof rectangle "))
a=l*w
p=2*(l+w)
print("Area = ",a)
print("Perimeter = ",p)

Go Top

Q10.

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)

Go Top

Python Basic Programming Tutorial

Python Introduction     Getting started in Python Programming      Python propgramming fundamentals     Python Operators    Python If Condition     Python for loop    Python range construct      Python While loop    break and continue statements     Different looping techniques     Python List     Python String     Python Functions    Python Inbuilt Functions     Python Recursion     Using Python Library     Python Tuples     Python Dictionary     Python Sets     Python Strings     Python Exception Handling     Python Data File Handling

Visitor Counter

0056734