0% found this document useful (0 votes)
5 views2 pages

If Statements

Uploaded by

amir1384amir1396
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

If Statements

Uploaded by

amir1384amir1396
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

IF_statements

November 6, 2024

1 IF statement
[ ]: num=int(input('enter data:'))
if num%2 == 0:
print('number is even')
print('End of if')

1.1 IF & ELSE statement


[ ]: num=int(input('enter data:'))
if num%2 == 0:
print('number is even')
else:
print('number is odd')
print('End of if')

1.2 Nested IF (1)


[ ]: i, j, k = 7, 5, 3
if i > k:
if j > k:
print('i and j are greater than k')
else:
print('i is less than or equal to k')
print('End of if')

1.3 Nested IF (2)


[ ]: num=int(input('Tell me a number?'))

if num%2 == 0:
if num%3 == 0:
print ("Divisible by 3 and 2")
else:
print ("Divisible by 2 not divisible by 3")
else:
if num%3 == 0:

1
print ("Divisible by 3 not divisible by 2")
else:
print ("not Divisible by 2 not divisible by 3")

1.4 elif (else & if)


[ ]: num=int(input('enter data:'))
if num%3 == 0 and num%2 == 0:
print ("Divisible by 3 and 2")
elif num%3 == 0:
print ("Divisible by 3 not divisible by 2")
elif num%2 == 0:
print ("Divisible by 2 not divisible by 3")
else:
print ("not Divisible by 2 not divisible by 3")
print('End of if')

1.5 The pass statement


[ ]: a = 33
b = 200

if b > a:
pass

You might also like