Skip to content

Instantly share code, notes, and snippets.

@mgburns
Last active October 16, 2020 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgburns/e837cb1d33612b87abd32224b09157ed to your computer and use it in GitHub Desktop.
Save mgburns/e837cb1d33612b87abd32224b09157ed to your computer and use it in GitHub Desktop.
A lil' fun with the Python REPL
# Basic expressions
1 + 1
# Variables, strings, and tuples
knock_knock = "Who's there?"
knock_knock
knock_knock_joke = ("Interuppting Cow", "Interupting co-", "MOO!!")
call, response, punchline = knock_knock_joke
knock_knock
call
response
punchline
# Lists and slices
todo_list = ["Come up with a Friday Share", "Keep children alive", "Survive 2020"]
todays_todos = todo_list[0]
todays_todos
later_problems = todo_list[1:]
later_problems
# Maps, functions, and module imports from the standard library
awesome_people_by_first_name = {"Mike": ["Burns", "Pelletier", "Swartz"], "Siri": ["Du Pont-Hurley"]}
from random import choice
def who_is_the_best_person_named(first_name):
print(first_name, choice(awesome_people_by_first_name[first_name]))
who_is_the_best_person_named("Mike")
who_is_the_best_person_named("Siri")
# Funny
import this
from __future__ import braces
import antigravity
# But also useful
help()
keywords
topics
NONE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment