CBSE Class 11 Python @ Home

CBSE Class XI: Python If Condition

Class 11: if condition 3

Question:4
Write a Python script to take input for a number, check and print whether the number is even or not?
Sol:

a=int(input("Enter any no "))
if(a%2==0):
    print("Number is even")
else:
    print("Number is not even")

Question:5
Write a Python script to take input for a number, check and print whether the number is odd or not?
Sol:

a=int(input("Enter any no "))
if(a%2==0):
    print("Number is even")
else:
    print("Number is not even")

Question: 6
Write a python script to take input for name and age of a person check and print whether the person can vote or not?
Sol:

name=input("Enter name ");
age=int(input("Enter any no "))
if(age>=18):
    print("You can vote")
else:
    print("You cannot vote")