-
Notifications
You must be signed in to change notification settings - Fork 0
/
conditionals_exercise2.py
33 lines (25 loc) · 1.12 KB
/
conditionals_exercise2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#######################################################################################################
# Conditionals - Lab Exercise 2 & 3
#
# Use the variable x as you write this program. x will represent a positive integer.
#
# Write a program that determines if x is divisible by 5.
# If yes, print _ is divisible by 5, where the blank is the value of x. If no, print _ is not divisible by 5,
# where the blank is the value of x.
#
# Expected Output
# If x is 50, then the output would be: 50 is divisible by 5 and even.
# If x is 37, then the output would be: 37 is not divisible by 5 or it is odd.
#######################################################################################################
x = 50
if (x % 5 == 0 and x % 2 == 0):
print(str(x) + " is divisible by 5 and even")
else:
print(str(x) + " is not divisible by 5 or it is odd")
# Output => 50 is divisible by 5 and even
x = 37
if (x % 5 == 0 and x % 2 == 0):
print(str(x) + " is divisible by 5 and even")
else:
print(str(x) + " is not divisible by 5 or it is odd")
# Output => 37 is not divisible by 5 or it is odd