Page 136 - Trackpad_V4.0_c7_Flpbook
P. 136
b. num1 = 8
num2 = 5
if (num1 % 2 == 0 and num2 % 2 == 0):
result = num1 + num2
print("The sum is:", result)
else:
result = num1 * num2
print("The product is:",result)
c. x = 31
if(x > 10):
print("Above ten")
if(x > 20):
print("and also above 20!")
else:
print("but not above 20.")
2. Find the error in the following code and rewrite the code:
a. x = 10
if (x > 5):
print("x is greater than 5")
b. y = 8
if (y > 5):
print("y is greater than 5")
c. x = 10
if (x = 5):
print("x is equal to 5")
3. Competency-based/Application-based questions:
a. Ajit wants to develop a Python program that check the strength of the password entered by the
user based on the following criteria:
Weak: Less than 4 characters
Moderate: 4-8 characters
Strong: More than 8 characters
Which conditional statement should he use?
Premium Edition-VII
134

