Program 1:
Program to obtain side of a square and then calculate its area.
a=int(input("Enter the side of square:"))
sq=a**2
print("Area of square is :",sq)
Program 2:
Program to obtain length and breadth of a rectangle and calculate its area.
l=int(input("Enter length of the rectangle:"))
b=int(input ("Enter breadth of the rectangle:"))
area=l*b
print("Area of rectangle is:",area)
Program 3:
Program to obtain height and base of a triangle and calculate its area.
l=int(input("Enter length of triangle"))
b=int(input("Enter base of triangle"))
area=0.5*b*h
print("Area of triangle is:",area)
Program 4:
Program to obtain a number and print its square and cube.
num=float(input("Enter the number:"))
sq=num*num
cube=num*num*num
print("Square of",num,"is",sq)
print("Cube of",num,"is",cube)
Program-5:
Program to obtain q number and check whether it is even or odd.
num = int(input("Enter a number: "))
if (num % 2) == 0:
print("Number is even.")
else:
print("Number is odd.")
Program-6:
Program to check leap year.
year = int(input("Enter a year: "))
if (year % 4) == 0:
if (year % 100) == 0:
if (year % 400) == 0:
print("It is a leap year")
else:
print("It is not a leap year")
else:
print("It is a leap year")
else:
print("It is not a leap year")
Program-7:
Program to obtain three numbers and print the largest among them.
num1 = int(input("Enter first number: "))
num2=int(input("Enter second number:
"))
num3= int(input("Enter third number: "))
if (num1 >= num2) and (num1 >= num3):
largest = num1
elif (num2 >= num1) and (num2 >=num3):
largest = num2
else:
largest = num3
print("The largest number is", largest)
Practice Programming Questions
Program-1: Write a program to display area of parallelogram.
Program-2: Write a program to obtain BMI(Body Mass Index) of a person.
Program-3: Write a program to obtain square root of a number.
Program-4: Write a program to print Sum of n natural number.
Program-5: Write a program to obtain a number and check whether it is prime or not.
Program-6: Write a program to convert celsius to Fahrenheit.
• Try to solve above programs.
• Tell me if you want the codes to be published as image and not text.
• If you face any problem solving programs then comment and I will reply soon. 😊
YOU ARE READING
Learn Python
RandomCome here to learn Python programming language. All the basics of Python programming language here.
