-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIfStatements.py
45 lines (42 loc) · 990 Bytes
/
IfStatements.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
33
34
35
36
37
38
39
40
41
42
43
44
45
#pcc simple example
cars = ['audi','bmw','subaru','toyota']
for car in cars:
if car == 'bmw':
print(car.upper())
else:
print(car.title())
print()
cities = ['cities','lusaka','harare','lilongwe',]
for city in cities:
if city == 'cities':
print(city.upper())
else:
print(city.title())
print()
#Conditional Tests
#Checking For Inequality
requested_topping = 'mushrooms'
if requested_topping != 'anchovies':
print("Hold the anchovies!")
#Numerical Camparisons
answer = 17
if answer != 42:
print("That is not the correct answer. Please try again!")
age = 19
if age != 21:
print("True")
#Checking Multiple Conditions
age_0 = 19
if age_0 != 22:
print("True")
if age_0 <= 21:
print("True")
if age_0 >= 21:
print("True")
#IfStatement(CodeBasics)
num = input("Enter a Number:")
num = int(num)
if num%2==0:
print("Number is even")
else:
print("Number is odd")