Skip to content

Instantly share code, notes, and snippets.

@leonchen417
leonchen417 / HW4.py
Created January 30, 2017 19:14
HW4 created by leonchen417 - https://repl.it/FKH6/32
guess_me =7
start = 1
while True:
if guess_me>start:
print('too low',start)
elif guess_me == start:
print('found it',start)
else:
print('too high',start)
break
@leonchen417
leonchen417 / HW4.py
Created January 17, 2017 22:59
HW4 created by leonchen417 - https://repl.it/FKH6/32
guess_me =7
start = 1
while True:
if guess_me>start:
print('too low',start)
elif guess_me == start:
print('found it',start)
else:
print('too high',start)
break
@leonchen417
leonchen417 / Closure,lambda,generator,decorator.py
Created January 13, 2017 22:03
Closure,lambda,generator,decorator created by leonchen417 - https://repl.it/FIoG/31
#Scope and Namespaces
animal = 'friutbat'
def print_global():
print('inside print_global:', animal)
def change_and_print_global(): #error will occur if called
print('inside print_global:', animal)
animal ='catfish'
print('after change', animal)
@leonchen417
leonchen417 / ch4 code-structure.py
Created January 10, 2017 18:21
ch4 code-structure created by leonchen417 - https://repl.it/FEWM/31
'''
# this capitalize input until q is pressed
while True:
stuff = input("String to capitalize [type q to exit]: ")
if stuff =="q":
break
print(stuff.capitalize())
'''
'''
@leonchen417
leonchen417 / ch4 code-structure.py
Created January 10, 2017 18:20
ch4 code-structure created by leonchen417 - https://repl.it/FEWM/31
'''
# this capitalize input until q is pressed
while True:
stuff = input("String to capitalize [type q to exit]: ")
if stuff =="q":
break
print(stuff.capitalize())
'''
'''
@leonchen417
leonchen417 / FDVs-35.py
Created January 9, 2017 02:47
null created by leonchen417 - https://repl.it/FDVs/35
drinks = {
'martini':{'vodka','vermouth'},
'black russian' : {'vodka','kahlua'},
'white russian' : {'cream','vodka','kahlua'}
}
bruss = drinks['black russian']
wruss = drinks['white russian']