python 3 programming questions and answers
Hello friends ,
As we know python is very powerful and high level
language.It is an object-oriented programming language.
Today we will discuss some important programs in python with
solutions.
Python3 programs for practice
Question 1. Write a program to find greatest number among 3
numbers?
Answer:
num1=int(input("Enter first number : "))
num2=int(input("Enter second number : "))
num3=int(input("Enter third number : "))
if(num1>num2) and (num1>num3) :
print("Greatest number is ",num1)
elif(num2>num1) and (num2>num3) :
print("Greatest number is ",num2)
else :
print("Greatest number is ",num3)
num2=int(input("Enter second number : "))
num3=int(input("Enter third number : "))
if(num1>num2) and (num1>num3) :
print("Greatest number is ",num1)
elif(num2>num1) and (num2>num3) :
print("Greatest number is ",num2)
else :
print("Greatest number is ",num3)
Screenshot:
Question 2. Write a program to find odd and even number?
Answer:
num=int(input("Enter any number")) if(num==0) : print("Neither odd nor even number") elif(num%2==0) : print("",num," is even number") else : print("",num," is odd number")
Screenshot:
Question 3. Write a program to find the given number is divisible
by 5 and 11?
Answer:
num=int (input (“Enter any number”))
If(num%5==0) and (num%11==0)
print (“”, num,” is divisible by 5 and 11”)
else:
print (“”,
num,” is not divisible by 5 and 11”)
Screenshot:
Question 4. Write a program to check given character is
vowel or not?
Answer:
ch= input("Enter any character: ")
if(ch=='A' or ch=='a' or ch=='E' or ch=='e' or ch=='I' or ch=='i' or ch=='U' or ch=='u' or ch=='O' or ch=='o'):
print("Its vowel.")
else :
print("It’s not vowel")
Screenshot:
Question 5. Write a program to make choice of following
1.Area of Circle
2.Area of Square
3.Area of Rectangle
Answer:
print("1.Area of Circle")
print("2.Area of Square")
print("3.Area of Rectangle")
choice=int(input("Enter your choice 1,2 or 3 : "))
if(choice==1):
r=int(input("Enter radius : "))
area=3.14*r*r
print("Area of circle : ",area)
elif(choice==2) :
side=int(input("Enter side : "))
area=side*side
print("Area of Square : ",area)
elif(choice==3) :
length=(int(input("Enter length : ")))
breadth=int(input("Enter breadth : "))
print("Area of Rectangle : ",length*breadth)
else :
print("Invalid choice.")
print("2.Area of Square")
print("3.Area of Rectangle")
choice=int(input("Enter your choice 1,2 or 3 : "))
if(choice==1):
r=int(input("Enter radius : "))
area=3.14*r*r
print("Area of circle : ",area)
elif(choice==2) :
side=int(input("Enter side : "))
area=side*side
print("Area of Square : ",area)
elif(choice==3) :
length=(int(input("Enter length : ")))
breadth=int(input("Enter breadth : "))
print("Area of Rectangle : ",length*breadth)
else :
print("Invalid choice.")
Screenshot:
No comments:
Post a Comment