DS010923 - Practice Questions Based on Conditional Statements

1. Write a Python Program to Check weather a Given Number is odd or Even.
2. Write a Python Program to Check weather a candidate Eligible for Vote or not.
3. Write a Python program to check weather Given Number is Divisible by 7 or Not.
4.Write a program to display “Hello” if a number entered by user is a multiple of five , otherwise print “Bye”.
5. Write a program to accept percentage from the user and display the grade according to the following **
** criteria:

** Marks Grade**
marks > 80: A+ grade
marks > 70 : A grade
marks > 60: B grade
** marks > 50: C grade**
else Failed.

6.Write a program that interprets the Body Mass Index (BMI) based on a user’s weight and height.
It should tell them the interpretation of their BMI based on the BMI value.
• Under 18.5 they are underweight
• Over 18.5 but below 25 they have a normal weight
• Over 25 but below 30 they are slightly overweight
• Over 30 but below 35 they are obese
• Above 35 they are clinically obese.

The BMI is calculated by dividing a person’s weight (in kg) by the square of their height (in m) .
Take height and weight from the user.

7.

Note → All Problems will be solved by Taking input from end user only.

1 Like

1. Write a Python Program to Check weather a Given Number is odd or Even.

number = int(input("Enter a number: "))
if num % 2 == 0:
print(num, “is even”)
else:
print(num, “is odd”)

2. Write a Python Program to Check weather a candidate Eligible for Vote or not.

age = int(input("Enter your age: "))
if age >= 18:
print(“You are eligible to vote.”)
else:
print(“You are not eligible to vote.”)

3. Write a Python program to check weather Given Number is Divisible by 7 or Not.

num = int(input("Enter a number: "))
if num % 7 == 0:
print(num, “is divisible by 7.”)
else:
print(num, “is not divisible by 7.”)

4.Write a program to display “Hello” if a number entered by user is a multiple of five ,
otherwise print “Bye”.

num = int(input("Enter a number: "))
if num % 5 == 0:
print(“Hello”)
else:
print(“Bye”)

5. Write a program to accept percentage from the user and display the grade according to the following **
** criteria:

** Marks Grade
marks > 80: A+ grade
marks > 70 : A grade
marks > 60: B grade
** marks > 50: C grade**
else Failed.

percentage = float(input("Enter your percentage: "))
if percentage > 80:
print(“your grade is A+”)
elif percentage > 70:
print(“your grade is A”)
elif percentage > 60:
print(“your grade is B”)
elif percentage > 50:
print(“your grade is C”)
else:
print(“your Failed”)

6.Write a program that interprets the Body Mass Index (BMI) based on a user’s weight and height.
It should tell them the interpretation of their BMI based on the BMI value.
• Under 18.5 they are underweight
• Over 18.5 but below 25 they have a normal weight
• Over 25 but below 30 they are slightly overweight
• Over 30 but below 35 they are obese
• Above 35 they are clinically obese.
The BMI is calculated by dividing a person’s weight (in kg) by the square of their height (in m) .
Take height and weight from the user.

weight = float(input("Enter your weight in kilograms: "))
height = float(input("Enter your height in meters: "))
bmi = weight/ (height** 2)
if bmi < 18.5:
print(“You are underweight.”)
elif 18.5 <= bmi < 25:
print(“You have a normal weight.”)
elif 25 <= bmi < 30:
print(“You are slightly overweight.”)
elif 30 <= bmi < 35:
print(“You are obese.”)
else:
print(“You are clinically obese.”)

1 Like

#Write a Python Program to Check weather a Given Number is odd or Even.
number = int(input(“input a number :”))
if number%2==0:
print("even number ")
else :
print("this is odd number ")
#Write a Python Program to Check weather a candidate Eligible for Vote or not.
age = int(input(“enter age”))
if age>=18 :
print("congratulation you are eligible caste your vote ")
else :
print("sorry , you are not eligible for caste a vote ")
#Write a Python program to check weather Given Number is Divisible by 7 or Not.
number =int(input("enter a number "))
if number%7==0 :
print(“number is divisible by 7”)
else :
print(“its not divisible by 7”)
#Write a program to display “Hello” if a number entered by user is a multiple of five , otherwise print “Bye”.
number = int(input("enter a number "))
if number%5==0 :
print("hello ")
else :
print("bye ")

1)TO FIND GIVEN NUMBER IS ODD OR EVEN

Number = int(input(“Enter a Number”))
if Number % 2==0:
print(“Number is Even”)
else:
print(“Number is Odd”)

  1. TO FIND ELIGIBLE FOR VOTE OR NOT

Age= int(input(“Enter age of the candidate:”))
if Age>=18:
print(“Candidate is eligible for vote”)
else:
print(“Candidate is not eligible for vote”)

3)TO FIND GIVEN NUMBER IS DIVISBLE BY 7

Number = int(input(“Enter a Number:”))
if Number % 7==0:
print(“Number is Divisible by 7”)
else:
print(“Number is not Divisible by 7”)

  1. IF A NUMBER IS MULTIPLE OF 5 RETURN “HI” ELSE “BYE”

Number= int(input(“Enter a Number:”))
if Number%5==0:
print(“Hi”)
else:
print(“Bye”)

  1. PROGRAM TO ACCEPT PERCENTAGE & DISPLAY BASED ON CRITERIA:

Percentage= float(input(“Enter Percentage of student:”))
if Percentage > 80:
print(“Grade of the student is A+”)
elif Percentage >70:
print(“Grade of the student is A”)
elif Percentage > 60:
print(“Grade of the student is B”)
elif Percentage > 50:
print(“Grade of the student is C”)
else:
print(“Grade of the student is FAILED”)

num = float(input(“enter your percantage :”))
if num>80 :
print("A+ ")
elif num>70 :
print("A ")
elif num>60 :
print("B ")
elif num>50 :
print(“C”)
else :
print("failed ")

  1. Write a Python Program to Check weather a Given Number is odd or Even.
    num=int(input(“enter a number”))
    if num % 2 == 0:
    print(“num is even:”)
    else:
    print(“num is odd:”)

  2. Write a Python Program to Check weather a candidate Eligible for Vote or not.

age = int(input(“enter your age”))
if age > 1:
print(“you are eligible”)
else:
print(“you are not eligible”)

  1. Write a Python program to check weather Given Number is Divisible by 7 or Not.

num = int(input(“enter a num”))
if num % 7 == 0:
print(“num is divisible by 7”)
else:
print(“num is not divisible by 7”)

  1. Write a program to display “Hello” if a number entered by user is a multiple of five ,
    otherwise print “Bye”.

num = int(input(“enter a number”))
if num % 5==0:
print(“Hello”)
else:
print(“Bye”)

  1. Write a program to accept percentage from the user and display the grade according to the following.
    ** criteria:
    ** Marks Grade
    marks > 80: A+ grade
    marks > 70 : A grade
    marks > 60: B grade
    ** marks > 50: C grade**
    else Failed.

percentage = float(input(“enter your percentage”))
if percentage > 80:
print(“A+ Grade”)
elif percentage > 70:
print(“A Grade”)
elif percentage > 60:
print(“B Grade”)
elif percentage > 50:
print(“C Grade”)
else:
print(“Failed”)

  1. Write a Python Program to Check weather a Given Number is odd or Even.
    num=int(input(“enter a number”))
    if num % 2 == 0:
    print(“num is even:”)
    else:
    print(“num is odd:”)

  2. Write a Python Program to Check weather a candidate Eligible for Vote or not.

age = int(input(“enter your age”))
if age > 18:
print(“you are eligible”)
else:
print(“you are not eligible”)

  1. Write a Python program to check weather Given Number is Divisible by 7 or Not.

num = int(input(“enter a num”))
if num % 7 == 0:
print(“num is divisible by 7”)
else:
print(“num is not divisible by 7”)

  1. Write a program to display “Hello” if a number entered by user is a multiple of five ,
    otherwise print “Bye”.

num = int(input(“enter a number”))
if num % 5==0:
print(“Hello”)
else:
print(“Bye”)

  1. Write a program to accept percentage from the user and display the grade according to the following.
    ** criteria:
    ** Marks Grade
    marks > 80: A+ grade
    marks > 70 : A grade
    marks > 60: B grade
    ** marks > 50: C grade**
    else Failed.

percentage = float(input(“enter your percentage”))
if percentage > 80:
print(“A+ Grade”)
elif percentage > 70:
print(“A Grade”)
elif percentage > 60:
print(“B Grade”)
elif percentage > 50:
print(“C Grade”)
else:
print(“Failed”)

1 Like

#1. Write a Python Program to Check weather a Given Number is odd or Even.

num=int(input(“Please Enter a Number”, ))
if(num%2==0):
print("Number is Even : ", num)
else:
print("Number is Odd : ", num)

#2. Write a Python Program to Check weather a candidate Eligible for Vote or not.

age = int(input('Please Enter your age : ’ ))
if(age>=18):
print(“You are eligible for Voting”)
else:
print(“You are not eligible for Voting. Kindly wait”,(18-age),“Years”)

3. Write a Python program to check weather Given Number is Divisible by 7 or Not.

num=int(input("Please Enter Your Number : ",))
if (num%7==0):
print("Your Number is : ",num, “>>> Divisible by 7”)
else:
print("Your Number is : ",num, “>>> Not Divisible by 7”)

#4.Write a program to display “Hello” if a number entered by user is a multiple of five , otherwise print “Bye”.

num = int(input(“Please Enter Your Number”,))
print(“Hello” if (num%5==0) else “Bye”)

#5. Write a program to accept percentage from the user and display the grade according to the following **
#** criteria:
#** Marks Grade**
#marks > 80: A+ grade
#marks > 70 : A grade
#marks > 60: B grade
#** marks > 50: C grade**
#else Failed.

per = float(input(“Enter the Percentage”, ))
if(per>=80):
print(“A+ Grade”)
elif(per>=70 and per<80):
print(“A Grade”)
elif(per>= 60 and per<70):
print(“B Grade”)
elif(per>=50 and per <60):
print(“C Grade”)
else:
print(“Failed”)

#6.Write a program that interprets the Body Mass Index (BMI) based on a user’s weight and height.
#It should tell them the interpretation of their BMI based on the BMI value.
#• Under 18.5 they are underweight
#• Over 18.5 but below 25 they have a normal weight
#• Over 25 but below 30 they are slightly overweight
#• Over 30 but below 35 they are obese
#• Above 35 they are clinically obese.

weight = float(input("Enter Your Weight in Kg : ", ))
hight = float(input("Enter Your Hight in Meter : ",))

BMI = weight/(hight*hight)

if(BMI<18.5):
print(“Underweight”)
elif(BMI>=18.5 and BMI<25):
print(“Normal Weight”)
elif(BMI>=25 and BMI<30):
print(“Slightly Overweight”)
elif(BMI>=30 and BMI<35):
print(“Obese”)
else:
print(“Clinically Obese”)

Write a programe to calculate the electricity bill (acept number of unit from user) acording to the following criteria:

Unit price

first 100 units No Charge

next 100 units Rs 5 rupees per unit

after 200 units Rs 10 rupees per unit

( For Example if units is 350 than total bill amount is Rs 2000)

unit = int(input(“Enter the Electricity Bill Uses Units”,))

bill_amount = 0

if (unit<=100):
print(“No Electricity Bill”)
elif(unit>100 and unit<=200):
bill_amount = (unit-100)*5
print("Electricity Bill is : " ,bill_amount)
elif(unit>200):
bill_amount = (500+(unit-200)*10)
print("Electricity Bill is : ", bill_amount)

1 Like

n = int(input(‘enter the number:’))
if n%2==0:
print(‘even number’)
else:
print(‘odd number’)

2. Write a Python Program to Check weather a candidate Eligible for Vote or not.
age = int(input(‘enter the age of the candidate:’))
if age >= 18:
print(‘eligible for vote’)
else:
print(‘not eligible’)

3. Write a Python program to check weather Given Number is Divisible by 7 or Not.

n = int(input(‘enter the number:’))
if n%7 ==0:
print(n, ‘divisible by 7’)
else:
print(n, ‘not divisible by 7’)

4.Write a program to display “Hello” if a number entered by user is a multiple of five ,
otherwise print “Bye”.

num = int(input("Enter a number: "))
if num % 5 == 0:
print(“Hello”)
else:
print(“Bye”)

  1. Write a program to accept percentage from the user and display the grade according to the following **
    ** criteria:
    ** Marks Grade
    marks > 80: A+ grade
    marks > 70 : A grade
    marks > 60: B grade
    ** marks > 50: C grade**
    else Failed.

marks = float(input(‘enter the marks:’))
if marks > 80:
print(‘A+ grade’)
elif marks > 70:
print(’ A grade’)
elif marks > 60:
Print(‘B grade’)
elif marks >50:
print(‘C grade’)
else:
print(‘Failed’)

6.Write a program that interprets the Body Mass Index (BMI) based on a user’s weight and height.
It should tell them the interpretation of their BMI based on the BMI value.
• Under 18.5 they are underweight
• Over 18.5 but below 25 they have a normal weight
• Over 25 but below 30 they are slightly overweight
• Over 30 but below 35 they are obese
• Above 35 they are clinically obese.
The BMI is calculated by dividing a person’s weight (in kg) by the square of their height (in m) .
Take height and weight from the user.

weight = float(input(‘enter the weight value:’))
height = float(input(‘enter the height value:’))
BMI = weight / (height**2)
if BMI < 18.5 :
print(‘they are underweight’)
elif 18.5 <= BMI < 25 :
print(‘they have a normal weight’)
elif 25<= BMI <30:
print(‘they are slightly overweight’)
elif 30<= BMI < 35 :
print(’ they are obese’)
else:
print(‘they are clinically obese’)

  1. Write a programe to calculate the electricity bill

unit = int(input(‘enter the units:’))
amount=0
if unit<100:
print(‘No Charge’,amount)
elif 100< unit <=200:
amount+=(unit-100)*5
print(‘bill is’ , amount)
elif unit>200:
amount = 500+ (unit-200)*10
print(‘bill amount is’ , amount)

#1. Write a Python Program to Check weather a Given Number is odd or Even.

num=int(input(“Enter the number:”))
if num%2==0:
print(“The Number is Even:”)
else:
print(“The Number is Odd”)

#2. Write a Python Program to Check weather a candidate Eligible for Vote or not.
age=int(input(“Enter the age:”))
if age>=18:
print(“You are Eligible for Voting”)
else:
print(“You are not eligible for Voting”)

#3. Write a Python program to check weather Given Number is Divisible by 7 or Not.

num=int(input(“Enter the number:”))
if num%7==0:
print(“The Number is Divisible by 7”)
else:
print(“The Number is not Divisible by 7”)

#4.Write a program to display “Hello” if a number entered by user is a multiple of five , otherwise print “Bye”.

num=int(input(“Enter the number:”))
if num%5==0:
print(“Hello”)
else:
print(“Bye”)

#5. Write a program to accept percentage from the user and display the grade according to the following.

marks=int(input(“Enter the marks:”))
if marks >= 80:
print(“A+ grade”)
elif marks >= 70 :
print(“A grade”)
elif marks >= 60:
print(“B grade”)
elif marks >= 50:
print(“C grade”)
else:
print(“Failed”)

#6.Write a program that interprets the Body Mass Index (BMI) based on a user’s weight and height.

weight=float(input(“Enter the Weight:”))
height=float(input(“Enter the Height :”))
bmi=weight/(height*height)
if bmi < 18.5:
print(“Underweight”)
elif bmi > 18.5 and bmi < 25:
print(“Normal weight”)
elif bmi > 25 and bmi < 30:
print(“Slightly overweight”)
elif bmi > 30 and bmi <35:
print(“Obese”)
else:
print(“Clinically obese”)

#7. Calculating Electrcity bill

unit=float(input(“Enter the unit:”))
if unit<=100:
print(“Free Electricity”)
elif unit > 100 and unit < 200:
unit = unit5
print(“The total Bill Amount RS”,unit )
else:
unit=unit
10
print(“The total Bill Amount RS”,unit)

# Q-1. Write a Python Program to Check weather a Given Number is odd or Even.

Number = int(input(“Enter your number :”))
if (Number % 2) == 0:
print(“This is even number”)
else:
print(“This is odd number”)

#Q-2. Write a Python Program to Check weather a candidate Eligible for Vote or not.

Age = int(input(“Enter your age :”))
if Age > 18:
print(“You can vote now”)
else:
print(“You can’t vote”)

#Q-3. Write a Python program to check weather Given Number is Divisible by 7 or Not.

Number = int(input(“Enter your number :”))
if Number % 7 ==0 :
print("Given number is divisible by 7 ")
else:
print(“Given number is not divisible by 7”)

#Q-4.Write a program to display “Hello” if a number entered by user is a multiple of five , otherwise print “Bye”.

Number = int(input(“Enter your number :”))
if Number % 5 == 0:
print(“Hello”)
else:
print(“Bye”)

# Q5. Write a program to accept percentage from the user and display the grade according to the following **

# ** Marks Grade**

# marks > 80: A+ grade

# marks > 70 : A grade

# marks > 60: B grade

# marks > 50: C grade

# else Failed.

Percentage = int(input(“Enter your Percentage :”))
if Percentage>=0 and Percentage<100:
if Percentage > 80:
print(“Your grade is A+”)
elif Percentage > 70:
print(“Your grade is A”)
elif Percentage > 60:
print(“Your grade is B”)
elif Percentage > 50:
print(“Your grade is C”)
else:
print(“Failed”)
else:
print(‘Please enter valid percentage’)

# Q-6.Write a program that interprets the Body Mass Index (BMI) based on a user’s weight and height.

# It should tell them the interpretation of their BMI based on the BMI value.

# • Under 18.5 they are underweight

# • Over 18.5 but below 25 they have a normal weight

# • Over 25 but below 30 they are slightly overweight

# • Over 30 but below 35 they are obese

# • Above 35 they are clinically obese.

Weight = int(input(“Enter your weight in kg:”))
Height = int(input(“Enter your height in m:”))
BMI = Weight/Height**2
if BMI < 18.5:
print(“Your are Underweight”)
elif BMI > 18.5 and BMI < 25:
print(“Your are normal weight”)
elif BMI > 25 and BMI < 30:
print(“Your are slightly overweight”)
elif BMI > 30 and BMI < 35:
print(“Your are Obese”)
elif BMI > 35:
print(“You are clinically obese”)

#Q-7. Calculating Electrcity bill

First 100 unit no charge

Next 100 unit Rs 5 per unit

After 200 unit Rs 10 per unit

unit=int(input(“Please enter the your unit :”))
if unit<=100:
print(“You have to paid no charge”)
elif unit > 100 and unit < 200:
unit = unit5
print(“You have to paid amount”,unit )
else:
unit=unit
10
print(“You have to paid amount”,unit)

6)Write a program that interprets the Body Mass Index (BMI) based on a user’s weight and height.

Weight= float(input(“Enter Weight in KG:”))
Height= float(input(“Enter Height in Meter”))
BMI= Weight/Height**2
if BMI<18.5:
print(“You are underweight”)
elif BMI>=18.5 and BMI<25:
print(“You are normal weight”)
elif BMI>25 and BMI<30:
print(“You are slightly overweight”)
elif BMI>30 and BMI<35:
print(“You are obese”)
else:
print(“You are clinically obese”)

7)Calculating Electrcity bill(Based on Units)
Unit= int(input(“Enter No.of units:”))
amount=0
if Unit<=100:
print(“No Charge”)
elif Unit>100 and Unit<200:
amount= amount+(Unit5)
Print(“Bill amount is Rs.”)
else Unit>200:
amount= amount+(unit
10)
print(“Bill amount is Rs.”)

#Write a program that interprets the Body Mass Index (BMI) based on a user’s weight and height.
#It should tell them the interpretation of their BMI based on the BMI value.

Under 18.5 they are underweight

#Over 18.5 but below 25 they have a normal weight
#• Over 25 but below 30 they are slightly overweight

Over 30 but below 35 they are obese

#Above 35 they are clinically obese.

#The BMI is calculated by dividing a person’s weight (in kg) by the square of their height (in m) .
#Take height and weight from the user.
weight = float(input("enter you weight in kilograms : "))
height =float(input("enter your height in meters : "))
bmi = weight/(height**2)
if bmi<18.5 :
print("you are under weight : ")
elif bmi>18<25 :
print("you have normal weight : ")
elif bmi>25<30 :
prin("you are slightly over weight : ")
elif bmi>30<35 :
print("You are obese : ")
elif bmi>35 :
print("you are clinically obese : ")

#1. Write a Python Program to Check weather a Given Number is odd or Even.
num = int(input(“enter a number”))

if num % 2 ==0:
print(“even number”)

else:
print(“odd number”)

#22. Write a Python Program to Check weather a candidate Eligible for Vote or not.

age = int(input(“enter age of voter”))

if age >=18:
print(“eligible to vote”)

else:
print(“voter is not eligible to vote”)

#3. Write a Python program to check weather Given Number is Divisible by 7 or Not.

num= int(input(“enter a number”))

if num % 7 == 0:
print(“number is divisible by 7”)

else:
print(“number is not divisible by 7”)

#4.Write a program to display “Hello” if a number entered by user is a multiple of five , otherwise print “Bye”.

num = int(input(“enter a number”))

if num % 5 == 0:
print(“HELLO”)

else :
print(“BYE”)

5.Write a program to accept percentage from the user and display the grade according to the following

percentage = int(input(“enter your percentage”))

if percentage >= 80:
print(“A+ grade”)

elif percentage >=70:
print(“A grade”)

elif percentage >= 60:
print(“B grade”)

elif percentage >= 50:
print(“C grade”)

else :
print(“failed”)

t.#6.Write a program that interprets the Body Mass Index (BMI) based on a user’s weight and heigh

weight = float(input(“Enter your weight in KG”))
height = float(input(“Enter your height in meters”))

bmi = weight / (height ** 2)

if bmi < 18.5:
print ( “underweight”)
elif 18.5 <= bmi < 25:
print(“normal weight”)
elif 25 <= bmi < 30:
print (“slightly overweight”)
elif 30 <= bmi < 35:
print (“obese”)
else:
print (“clinically obese”)

#7 program to calculate electricity bill.

units = int(input(“enter number of units”))

if units <=100:
bill = 0

elif units <= 200:
bill= (units -100) * 5

else:
bill = (100*5)+((units -200)*10)

print(bill)

num = int(input(“Enter a Number: “))
if (num % 2) == 0:
print(”{0} is Even”.format(num))
else:
print(“{0}is Odd”.format(num))

#Write a program to calcuate the electricity bill according to following criteria…

unit price

first 100 unit 00

next 100 unit rs 5 per unit

after 200 unit rs 10 per unit

unit=int(input("enter unit : "))
rs=0
if unit<100:
print(“no need to pay your bill”)
elif (unit>=100 and unit<=200):
rs=(unit-100)*5
print(“your bill electricity bill is :”,rs)
else :
rs=500+(unit-200)*10
print(“your electricity bill is :”,rs)