Began 5-2 More Conditional Tests
This commit is contained in:
parent
a189b3ed0c
commit
b73c970b85
47
Chapter_05/5-2_moreConditionalTests.py
Normal file
47
Chapter_05/5-2_moreConditionalTests.py
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# Exercise 5-2 More Conditional Tests
|
||||||
|
# Learning Objective: Write more conditional tests in specific fashions.
|
||||||
|
# a. test for equality of strings.
|
||||||
|
# b. test using lower() method.
|
||||||
|
# c. numerical test involving ==, <=, >=, <, >.
|
||||||
|
# d. test with 'and' & test with 'or' keywords.
|
||||||
|
# e. test if item is in list.
|
||||||
|
# f. test if item is not in list.
|
||||||
|
'''
|
||||||
|
_ _ _ _ _ _ _ _ _ EXERCISE 5-1 _ _ _ _ _ _ _ _ _ _
|
||||||
|
coin = 'heads'
|
||||||
|
print("Is coin == 'heads'? I think so.")
|
||||||
|
print(coin == 'heads')
|
||||||
|
|
||||||
|
print("\nIs coin == 'tails'? I don't believe so.")
|
||||||
|
print(coin == 'tails')
|
||||||
|
|
||||||
|
color = 'black'
|
||||||
|
print("\nIs the color black?")
|
||||||
|
print(color == 'black')
|
||||||
|
|
||||||
|
print("\nIs the color 'white'?")
|
||||||
|
print(color == 'white')
|
||||||
|
|
||||||
|
coin = 'tails'
|
||||||
|
print("\nIs coin == 'heads'? I don't think so.")
|
||||||
|
print(coin == 'heads')
|
||||||
|
|
||||||
|
print("\nIs coin == 'tails'? I believe so.")
|
||||||
|
print(coin == 'tails')
|
||||||
|
|
||||||
|
color = 'white'
|
||||||
|
print("\nIs the color black?")
|
||||||
|
print(color == 'black')
|
||||||
|
|
||||||
|
print("\nIs the color 'white'?")
|
||||||
|
print(color == 'white')
|
||||||
|
|
||||||
|
lightSwitch = 'on'
|
||||||
|
print("\nIs the light on or off? I think its on.")
|
||||||
|
print(lightSwitch == 'on')
|
||||||
|
|
||||||
|
print("\nIs the light off? I don't think it is.")
|
||||||
|
print(lightSwitch == 'off')
|
||||||
|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
||||||
|
|
||||||
|
'''
|
||||||
Loading…
x
Reference in New Issue
Block a user