Q:

Python | Some of the examples of simple if else

belongs to collection: Python basic programs

0

Python | Some of the examples of simple if else

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Example1: Enter a number and check whether it is 10 or not

a=int(input("Enter A : "))

if a==10:
    print("Equal to 10")
else:
    print("Not Equal to 10")

Output

Enter A : 10
Equal to 10

Example2: Find largest of two numbers

a=int(input("Enter A: "))
b=int(input("Enter B: "))

if a>b:
    g=a
else:
    g=b

print("Greater = ",g)

Output

Enter A: 36
Enter B: 24
Greater =  36

Example3: Find largest of two numbers using single statement

a=int(input("Enter A: "))
b=int(input("Enter B: "))

c= a if a>b else b

print("Greater = ",c)

Output

Enter A: 24
Enter B: 36
Greater =  36

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python basic programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Python | Input age and check eligibility for votin... >>
<< Python program to find floor division...