Addition | + | a + b = 10 |
Subtraction | – | x – y = -5 |
Multiplication | * | a * b = 20 |
Exponent | ** | x3 = 8 |
Division | / | b / a = 10 |
Modulus | % | b % a = 2 |
Countdown Operators | |
import time def count_down(): sec = 10 for count in range(sec): print(sec) sec -= 1 time.sleep(1) return | 10 9 8 7 6 5 4 3 2 1 |
Mad libs (Lists) | |
def mad_libs(words): print(“Once upon a time in the land of ” + words[0] + “, people became confused. ” + “There were so many ” + words[1] + “, but not enough ” + words[2] + “.”) return | Enter a place: Candy Land Enter a thing(plural): coconuts Enter a thing(plural): beluga whales Once upon a time in the land of Candy |
words = [“”, “”, “”] categories = [“place”, “thing(plural)”, “thing(plural)”] for count in range(len(categories)): words[count] = input(“Enter a ” + categories[count]) | Land, people became confused. There were so many coconuts, but not enough beluga whales. |