Day 1 in-class examples (2020)

In [1]:
print("hello world!")
In [7]:
def say_cat_a_lot():
    for x in range(10):
        print("CAT!!!")
In [5]:
say_cat_a_lot()
CAT!!!
CAT!!!
CAT!!!
CAT!!!
CAT!!!
CAT!!!
CAT!!!
CAT!!!
CAT!!!
CAT!!!

Hey, this is my text answer to the question. Go look at my code in the next cell! Give me my a +++++++

In [8]:
def read_the_paper():
    print("I opened the file!")

def find_the_sees():
    print("found one!  bahahaha!!")

def check_if_eg():
    return False
    
def identify_bad_commas():
    read_the_paper()
    find_the_sees()
    if check_if_eg():
        needs_comma = True
    else:
        needs_comma = False
    return needs_comma

def insert_comma(citation):
    if citation == True:
        return ','
    else:
        return ''
    
    
In [9]:
def caps_and_periods(text):
    return text.upper() + "....."
In [10]:
caps_and_periods("cat")
Out[10]:
'CAT.....'
In [11]:
caps_and_periods("dog, as if dogs matter")
Out[11]:
'DOG, AS IF DOGS MATTER.....'
In [12]:
def addcats(moretext):
    return "CATS CATS CATS are the best " + moretext
In [13]:
lame_animal = "dog"
In [14]:
big_lame_animal = caps_and_periods(lame_animal)
In [15]:
print(big_lame_animal)
DOG.....
In [16]:
addcats(big_lame_animal)
Out[16]:
'CATS CATS CATS are the best DOG.....'
In [17]:
mylist=['dogs', 'bears', 'dinos']
for x in mylist:
    print(addcats(x))
CATS CATS CATS are the best dogs
CATS CATS CATS are the best bears
CATS CATS CATS are the best dinos
In [18]:
for x in mylist:
    if x[0] == 'd':
        print(addcats(x))
CATS CATS CATS are the best dogs
CATS CATS CATS are the best dinos
In [ ]:
 

links