HANDS-ON TIME#

  1. Imagine you are in a Python restaurant which serves menu as a list. And, you are a hungry caterpillar who wants to eat everything! And frankly, you can order your food by print statements. Write a for loop to print the names of the foods that you want to eat.

menu_pycafe = ["one ice-cream cone", "one pickle", "one slice of Swiss cheese", "one slice of salami",
               "one lollipop", "one piece of cherry pie", "one sausage", "one cupcake and one slice of watermelon"]
for i in menu_pycafe:
    print ("I would like " +i)
len(menu_pycafe)
I would like one ice-cream cone
I would like one pickle
I would like one slice of Swiss cheese
I would like one slice of salami
I would like one lollipop
I would like one piece of cherry pie
I would like one sausage
I would like one cupcake and one slice of watermelon
8
  1. You have a time machine which will take you from 2020 to 2050, and you would like to write a count-down script so that you will know which year you are in! Use a while loop to count down and don’t forget to print each year that you pass, Marty!

year_traveled = 2020
print("Starting Year:"+str(year_traveled))
while year_traveled<2050:
    print ("Travel to the Future ->")
    year_traveled = year_traveled +1
    print("Year:"+str(year_traveled))
else:
    print ("Congrats! You arrived at the Future!")
    print("Year:"+str(year_traveled))
Starting Year:2020
Travel to the Future ->
Year:2021
Travel to the Future ->
Year:2022
Travel to the Future ->
Year:2023
Travel to the Future ->
Year:2024
Travel to the Future ->
Year:2025
Travel to the Future ->
Year:2026
Travel to the Future ->
Year:2027
Travel to the Future ->
Year:2028
Travel to the Future ->
Year:2029
Travel to the Future ->
Year:2030
Travel to the Future ->
Year:2031
Travel to the Future ->
Year:2032
Travel to the Future ->
Year:2033
Travel to the Future ->
Year:2034
Travel to the Future ->
Year:2035
Travel to the Future ->
Year:2036
Travel to the Future ->
Year:2037
Travel to the Future ->
Year:2038
Travel to the Future ->
Year:2039
Travel to the Future ->
Year:2040
Travel to the Future ->
Year:2041
Travel to the Future ->
Year:2042
Travel to the Future ->
Year:2043
Travel to the Future ->
Year:2044
Travel to the Future ->
Year:2045
Travel to the Future ->
Year:2046
Travel to the Future ->
Year:2047
Travel to the Future ->
Year:2048
Travel to the Future ->
Year:2049
Travel to the Future ->
Year:2050
Congrats! You arrived at the Future!
Year:2050
years = list(range(2050, 2020,-1))

for i in years:
    while i > 2019:
        print(i)
        i = i-1
2050
2049
2048
2047
2046
2045
2044
2043
2042
2041
2040
2039
2038
2037
2036
2035
2034
2033
2032
2031
2030
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2049
2048
2047
2046
2045
2044
2043
2042
2041
2040
2039
2038
2037
2036
2035
2034
2033
2032
2031
2030
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2048
2047
2046
2045
2044
2043
2042
2041
2040
2039
2038
2037
2036
2035
2034
2033
2032
2031
2030
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2047
2046
2045
2044
2043
2042
2041
2040
2039
2038
2037
2036
2035
2034
2033
2032
2031
2030
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2046
2045
2044
2043
2042
2041
2040
2039
2038
2037
2036
2035
2034
2033
2032
2031
2030
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2045
2044
2043
2042
2041
2040
2039
2038
2037
2036
2035
2034
2033
2032
2031
2030
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2044
2043
2042
2041
2040
2039
2038
2037
2036
2035
2034
2033
2032
2031
2030
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2043
2042
2041
2040
2039
2038
2037
2036
2035
2034
2033
2032
2031
2030
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2042
2041
2040
2039
2038
2037
2036
2035
2034
2033
2032
2031
2030
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2041
2040
2039
2038
2037
2036
2035
2034
2033
2032
2031
2030
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2040
2039
2038
2037
2036
2035
2034
2033
2032
2031
2030
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2039
2038
2037
2036
2035
2034
2033
2032
2031
2030
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2038
2037
2036
2035
2034
2033
2032
2031
2030
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2037
2036
2035
2034
2033
2032
2031
2030
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2036
2035
2034
2033
2032
2031
2030
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2035
2034
2033
2032
2031
2030
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2034
2033
2032
2031
2030
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2033
2032
2031
2030
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2032
2031
2030
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2031
2030
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2030
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2029
2028
2027
2026
2025
2024
2023
2022
2021
2020
2028
2027
2026
2025
2024
2023
2022
2021
2020
2027
2026
2025
2024
2023
2022
2021
2020
2026
2025
2024
2023
2022
2021
2020
2025
2024
2023
2022
2021
2020
2024
2023
2022
2021
2020
2023
2022
2021
2020
2022
2021
2020
2021
2020