#Sam Ola
#10/6/2021
#in this lesson i learned how to use if, else, and pass with boolean formatting
#I had some trouble with the last part on task two but i figured it out in the end
if True:
print("True means do something")
else:
print("Not True means do something else")
hot_tea = True
if hot_tea:
print("enjoy some hot tea!")
else:
print("enjoy some tea, and perhaps try hot tea next time.")
someone_i_know = False
if someone_i_know:
print("how have you been?")
else:
# use pass if there is no need to execute code
pass
# changed the value of someone_i_know
someone_i_know = True
if someone_i_know:
print("how have you been?")
else:
pass
sunny_today = True
if sunny_today:
print("it is currently a sunny day here in Raleigh")
else:
pass
sunny_today = False
if sunny_today:
print("it is currently a sunny day here in Raleigh")
else:
pass
# review code and run cell
favorite_book = input("Enter the title of a favorite book: ")
if favorite_book.istitle():
print(favorite_book, "- nice capitalization in that title!")
else:
print(favorite_book, "- consider capitalization throughout for book titles.")
# review code and run cell
a_number = input("enter a positive integer number: ")
if a_number.isdigit():
print(a_number, "is a positive integer")
else:
print(a_number, "is not a positive integer")
# another if
if a_number.isalpha():
print(a_number, "is more like a word")
else:
pass
# review code and run cell
vehicle_type = input('"enter a type of vehicle that starts with "P": ')
if vehicle_type.upper().startswith("P"):
print(vehicle_type, 'starts with "P"')
else:
print(vehicle_type, 'does not start with "P"')
test_string_1 = "welcome"
test_string_2 = "I have $3"
if test_string_1.islower():
print("this is lowercase")
else:
print("this should be lowercase")
if test_string_2.islower():
print("this is lowercase")
else:
print("this should be lowercase")
test_string_1 = "welcome"
test_string_2 = "I have $3"
test_string_3 = "With a function it's efficient to repeat code"
if test_string_1.startswith("w"):
print('this word starts with w')
else:
print('this word does not start w')
if test_string_2.startswith("w"):
print('this word starts with w')
else:
print('this word does not start w')
if test_string_3.swapcase().startswith("w"):
print('this word starts with w')
else:
print('this word does not start w')