You are on page 1of 5

If Loop:

if condition has three types of syntax's


1)Simple IF(condition)
2)IF-Else
3)Nested IF
4)If-Elif

#Find Biggest among two values using simple if

a=int(input('enter the value of a ')) # takes the input of a


b=int(input('enter the value of b')) #takes the input of b

if(a>b): # checks for the condition (true or false)


print('the biggest number is ',a) #prints if the condition is
true
if(b>a): #checks condition
print('the biggest number is', b) # print value 6 is bigger
#Find Biggest among three values using if-else
a=int(input('enter the value of a '))# takes the input of a
b=int(input('enter the value of b '))# takes the input of b
c=int(input('enter the value of c '))#takes the input of c
if(a>b): #checks if a is bigger than b
if(a>c): # checks if a is also bigger than c
print('the bigger value is ', a)
else: #block to exceute for a<c
print('the bigger value is ', c)
else: #block to check for b is bigger
if(b>c): # checks if b is bigger than c
print('the bigger value is ', b)
else: # block for c is bigger than b
print('the bigger value is ', c)
'the programming code contains nested if statements
to check amongst three values
#convert integer to string if the input is integer

a=int(input('enter the value of a '))

if(type(a)==int):
c=str(a)
k=type(c)
print(c,'is an',k)
else:
print(a)

You might also like