Problems are arranged in increasing difficulty:
lesser_of_two_evens(2,4) --> 2
lesser_of_two_evens(2,5) --> 5
def lesser_of_two_evens(a,b):
pass
# Check
lesser_of_two_evens(2,4)
# Check
lesser_of_two_evens(2,5)
animal_crackers('Levelheaded Llama') --> True
animal_crackers('Crazy Kangaroo') --> False
def animal_crackers(text):
pass
# Check
animal_crackers('Levelheaded Llama')
# Check
animal_crackers('Crazy Kangaroo')
makes_twenty(20,10) --> True
makes_twenty(12,8) --> True
makes_twenty(2,3) --> False
def makes_twenty(n1,n2):
pass
# Check
makes_twenty(20,10)
# Check
makes_twenty(2,3)
old_macdonald('macdonald') --> MacDonald
Note: 'macdonald'.capitalize()
returns 'Macdonald'
def old_macdonald(name):
pass
# Check
old_macdonald('macdonald')
master_yoda('I am home') --> 'home am I'
master_yoda('We are ready') --> 'ready are We'
Note: The .join() method may be useful here. The .join() method allows you to join together strings in a list with some connector string. For example, some uses of the .join() method:
>>> "--".join(['a','b','c'])
>>> 'a--b--c'
This means if you had a list of words you wanted to turn back into a sentence, you could just join them with a single space string:
>>> " ".join(['Hello','world'])
>>> "Hello world"
def master_yoda(text):
pass
# Check
master_yoda('I am home')
# Check
master_yoda('We are ready')
almost_there(90) --> True
almost_there(104) --> True
almost_there(150) --> False
almost_there(209) --> True
NOTE: abs(num)
returns the absolute value of a number
def almost_there(n):
pass
# Check
almost_there(104)
# Check
almost_there(150)
# Check
almost_there(209)
Given a list of ints, return True if the array contains a 3 next to a 3 somewhere.
has_33([1, 3, 3]) → True
has_33([1, 3, 1, 3]) → False
has_33([3, 1, 3]) → False
def has_33(nums):
pass
# Check
has_33([1, 3, 3])
# Check
has_33([1, 3, 1, 3])
# Check
has_33([3, 1, 3])
paper_doll('Hello') --> 'HHHeeellllllooo'
paper_doll('Mississippi') --> 'MMMiiissssssiiippppppiii'
def paper_doll(text):
pass
# Check
paper_doll('Hello')
# Check
paper_doll('Mississippi')
blackjack(5,6,7) --> 18
blackjack(9,9,9) --> 'BUST'
blackjack(9,9,11) --> 19
def blackjack(a,b,c):
pass
# Check
blackjack(5,6,7)
# Check
blackjack(9,9,9)
# Check
blackjack(9,9,11)
summer_69([1, 3, 5]) --> 9
summer_69([4, 5, 6, 7, 8, 9]) --> 9
summer_69([2, 1, 6, 9, 11]) --> 14
def summer_69(arr):
pass
# Check
summer_69([1, 3, 5])
# Check
summer_69([4, 5, 6, 7, 8, 9])
# Check
summer_69([2, 1, 6, 9, 11])
spy_game([1,2,4,0,0,7,5]) --> True
spy_game([1,0,2,4,0,5,7]) --> True
spy_game([1,7,2,0,4,5,0]) --> False
def spy_game(nums):
pass
# Check
spy_game([1,2,4,0,0,7,5])
# Check
spy_game([1,0,2,4,0,5,7])
# Check
spy_game([1,7,2,0,4,5,0])
count_primes(100) --> 25
By convention, 0 and 1 are not prime.
def count_primes(num):
pass
# Check
count_primes(100)
print_big('a')
out: *
* *
*****
* *
* *
HINT: Consider making a dictionary of possible patterns, and mapping the alphabet to specific 5-line combinations of patterns.
For purposes of this exercise, it's ok if your dictionary stops at "E".
def print_big(letter):
pass
print_big('a')