print("Happy Birthday, dear Carol!") %%bash python3 greeting.py def happy_birthday_carol(): print("Happy Birthday, dear Carol!") happy_birthday_carol() happy_birthday_carol def happy_birthday_rise(): print("Happy Birthday, dear Rise!") happy_birthday_rise() def happy_birthday(name): print("Happy Birthday, dear " + name + "!") happy_birthday("Trey") names = ["Carol", "Rise", "Trey", "Alain"] for name in names: happy_birthday(name) def happy_birthday(name): print("Happy Birthday, dear {0}!".format(name)) happy_birthday(100) happy_birthday(3.1415927) happy_birthday("Ƭ̵̬̊") def happy_birthday(name): print("Happy Birthday, dear " + str(name) + "!") str(u'\xff') def print_factors(age): for i in range(1, age + 1): if age % i == 0: print(i) print_factors(32) print_factors(33) def cupcake_tally(guests): """ Given number of party guests, returns how many cupcakes are needed. """ return 2 * guests + 13 cupcake_tally(30) cupcake_tally(guests=1) cupcakes = cupcake_tally(10) print("We need to make {0} cupcakes.".format(cupcakes)) def cupcake_tally(cupcakes, guests): return cupcakes * guests + 13 cupcake_tally(4, 15) print("On the day of Sept 20, 2014, were you at Intro to Python?") answer = input("Answer truthfully, yes or no --> ") if answer == "no": answer = input("Are you sure that you weren't? Tell the truth, now --> ") print("Were you thinking of skipping the workshop to go to Sea World?") answer = input("Answer truthfully, yes or no --> ") if answer == "no": answer = input("Are you sure that you weren't? Tell the truth, now --> ") import random random.randint(1, 6) vegas_die_1 = random.randint(1, 6) vegas_die_2 = random.randint(1, 6) print("First die: " + str(vegas_die_1)) print("Second die: " + str(vegas_die_2)) print("You rolled a " + str(vegas_die_1 + vegas_die_2)) random.choice('abcdefghijklmnopqrstuvwxyz') def random_happy_birthday(names): name = random.choice(names) happy_birthday(name) random_happy_birthday(["Alain", "Carol", "Rise", "Trey"]) from IPython.display import YouTubeVideo # a tutorial about Python at PyCon 2014 in Montreal, Canada by Jessica McKellar YouTubeVideo('MirG-vJOg04')