Skip to content

Instantly share code, notes, and snippets.

@jonbesga
Created July 25, 2018 19:44
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 jonbesga/cac10aee265d74b9ba6ebcc60eff8261 to your computer and use it in GitHub Desktop.
Save jonbesga/cac10aee265d74b9ba6ebcc60eff8261 to your computer and use it in GitHub Desktop.
Exercises day 1
# lights_on = True
# if lights_on:
# print('lights are on')
# else:
# print('lights are not on')
# street_light = "blue"
# if street_light == "red":
# print('red')
# elif street_light == "green":
# print('green')
# elif street_light == "yellow":
# print('yellow')
# else:
# print('this color doesn\'t exist in a streetlight')
# light = True
# light = False
# light = 'text'
# light = 1
# my_number = 10
# numbers = [1, 2, 3, 4, 5]
# if my_number not in numbers:
# print('not in sequence')
def is_prized_number(lottery_number):
numbers = [200, 300, 100, 500, 600]
if lottery_number in numbers:
print('congratulations')
else:
print('better luck next time')
# def is_prize_combination(n1, n2, n3, n4, n5):
# numbers = [200, 300, 100, 500, 600]
# if n1 in numbers and n2 in numbers and n3 in numbers and n4 in numbers and n5 in numbers:
# print('congratulations - jackpot')
# elif n1 in numbers and n2 in numbers and n3 in numbers and n4 in numbers and n5 in numbers:
# else:
# print('better luck next time')
def is_prize_combination(my_list_of_numbers, winners):
how_many = 0
for number in my_list_of_numbers:
if number in winners:
how_many += 1 # another way of "how_many = how_many + 1"
if how_many == 3:
return 'well done - winnner'
elif how_many == 4:
return 'well done runner up'
elif how_many == 5:
return 'congratulations winner'
else:
return 'Bad luck - better luck next time'
def print_name(name, quote):
print(quote + ' ' + name)
w1 = [200, 300, 100, 500, 600]
result = is_prize_combination([100, 900, 500, 200], w1)
print_name('Milan', result)
# results = is_prize_combination([100, 900, 500, 200, 500, 600], w3)
# results = is_prize_combination([1, 2, 3, 4, 5], w1)
#
# is_prized_number(100)
# is_prized_number(900)
# is_prized_number(500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment