CBSE Class 11 Python @ Home

CBSE Class XI: Python If Condition

Class 11: if condition 6

Question: 13
Write a python script to take input for two number check and print the larger number? (Method :1 )
Sol:

a=int(input("Enter 1st no "))
b=int(input("Enter 2nd no "))
if(a>b):
    print("Max no = ",a)
else:
    print("Max no = ",b)
# Output 
Enter 1st no 25
Enter 2nd no 63
Max no = 63
>>>
Enter 1st no 78
Enter 2nd no 69
Max no = 78
>>>

Question: 14

write a python script to take input for two number check and print the larger number? (Method:2 )

Sol:

a=int(input("Enter 1st no "))
b=int(input("Enter 2nd no "))
if(a>b):
    m=a
else:
    m=b
print("Max no = ",m)
# Output
Enter 1st no 52
Enter 2nd no 96
Max no = 96
>>>
Enter 1st no 256
Enter 2nd no 325
Max no = 325
>>>

Question: 15

Write a python script to take input for the 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 age "))
if(age>=18):
    print("You can vote")
else:
    print("You cannot vote")
#Output
Enter name amit
Enter age 15
You cannot vote
>>>
Enter name Sumit
Enter age 21
You can vote
>>>