Practice Sheet - BasicLiterals
Practice Sheet - BasicLiterals
Operator Precedence
Conditionals (if-else)
num = 5
if num > :
print("Positive")
num = 7
if num % 2 == 0:
print("Even")
else:
print()
num = 15
if num % 5 == 0:
print("Divisible by 5")
else:
print("Not divisible by 5")
num = -3
if num > 0:
print("Positive")
elif num < 0:
print("Negative")
else:
print("Zero")
a = 3
b = 7
c = 5
if a > b and a > :
print("a is the largest")
elif b > a and b > c:
print("b is the largest")
else:
print("c is the largest")
num = 15
if num % 3 == 0 and num % == 0:
print("Multiple of both 3 and 5")
else:
print("Not a multiple of both")
year = 2020
if year % 4 == 0 and (year % 100 != 0 or year % 400 == ):
print("Leap year")
else:
print("Not a leap year")
char = 'a'
if char in ['a', 'e', 'i', 'o', 'u']:
print("Vowel")
else:
print("Not a vowel")
num = 15
if 10 <= num and num <= :
print("Between 10 and 20")
else:
print("Not between 10 and 20")
s = ""
if :
print("Empty string")
else:
print("Non-empty string")