3.condition Statement

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

3.Program using conditional statements.

i) if else

a=int(input("Give the a value :"))


b=int(input("Give the b value :"))
if(a>b):
print("a is big")
else:
print("b is big")

Output
Give the a value :10
Give the b value :20
b is big

ii) if elif else

ch = input("Give any character :")


if(ch=='A' or ch=='E' or ch=='I' or ch=='O' or ch=='U'):
print(ch,"is a vowel")
elif(ch=='a' or ch=='e' or ch=='i' or ch=='o' or ch=='u'):
print(ch,"is a vowel")
else:
print("Not a vowel")

Output
Give any character :a
a is a vowel

iii) Nested if

a = int(input("Give the a value :"))

b = int(input("Give the b value :"))

c = int(input("Give the c value :"))

if(a > b):

if(a > c):

print("a is big")

else:
print("c is big")

elif(b > c):

if(b >a):

print("b is big")

else:

print("a is big")

elif(c> a):

if(c>b):

print("c is big")

else:

print("b is big")

else:

print("All numbers are equal")

Output
Give the a value :10

Give the b value :20

Give the c value :30

c is big

You might also like