Python If Condition Programs | Set 3

Set 1    Set 2    Set 3    Set 4   Set 5  Set 6  Set 7  Set 8  Set 9

Question: 11

Write a python script to take input for a number check and print whether the number is multiple of 5 or 11 not?

Sol:

n=int(input("Enter any no "))
if(n%5==0 or n%11==0):
    print("number is multiple of 5 or 11")
else:
    print("number is not multiple of 5 or 11")

Output:

case 1:
Enter any no 5
number is multiple of 5 or 11
>>>
case 2:
Enter any no 26
number is not multiple of 5 or 11
>>>
case 3:
Enter any no 22
number is multiple of 5 or 11
>>>

Question: 12

Write a python script to take input for a number check and print whether the number is multiple of 5 and 7 not?

Sol:

n=int(input("Enter any no "))
if(n%5==0 and n%11==0):
    print("number is multiple of 5 and 11")
else:
    print("number is not multiple of 5 and 11")

Output:

case 1:
Enter any no 55
number is multiple of 5 and 11
>>>
Enter any no 22
number is not multiple of 5 and 11
>>>
case 3:
Enter any no 45
number is not multiple of 5 and 11
>>>

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 name and age of a personm 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
>>>

Set 1    Set 2    Set 3    Set 4   Set 5  Set 6  Set 7  Set 8  Set 9

Python Basic Programming Tutorial

Python Introduction     Getting started in Python Programming      Python propgramming fundamentals     Python Operators    Python If Condition     Python for loop    Python range construct      Python While loop    break and continue statements     Different looping techniques     Python List     Python String     Python Functions    Python Inbuilt Functions     Python Recursion     Using Python Library     Python Tuples     Python Dictionary     Python Sets     Python Strings     Python Exception Handling     Python Data File Handling