Python Practical Worksheet 3
Python Practical Worksheet 3
# 2 checks if b is grater than a else prints they #8 checks if a number is positive or negative or
are equal zero
a = 33 number = -5
b = 33 if number > 0:
if b > a: print('Positive number')
print("b is greater than a") elif number < 0:
else : print('Negative number')
print("a and b are equal") else:
print('Zero')
# 3 checks if the values are greater or equal
a = 200 #9 A simple calculator to add and subtract which
b = 33 asks the user if you want to add ,if user types Y
if b > a: it will add the numbers else it will subtract them.
print("b is greater than a")
elif a == b: number1 = 70
print("a and b are equal") number2= 80
else: answer = input(“Do you want to add?(Y/N))
print("a is greater than b") if answer == “Y” :
result = number1 + number2
# 4 checks if both a is greater than b and c is else
greater than a result = number1 - number2
a = 200 print(result)
b = 33
c = 500
if a > b and c > a: #10 make simple calculator to multiply or divide
print("Both conditions are True") using the same logic as above.
grade B
grade C