{{ message }}

Instantly share code, notes, and snippets.

Pamela Fox pamelafox

Created Sep 24, 2021
fUnkyCaSe
View funky_case.py
 def fUnKyCaSe(text): """Returns TEXT in fUnKyCaSe >>> fUnKyCaSe("wats up") 'wAtS Up' """ def toggle_case(letter, should_up_case): return letter.upper() if should_up_case else letter.lower() def up_down(text, should_up_case): if len(text) == 1:
Created Aug 30, 2021
Prime Factors
View prime_factors.py
 def is_prime(n): """Return True iff N is prime. >>> is_prime(1) False >>> is_prime(2) True >>> is_prime(8) False >>> is_prime(21) False
Created Aug 30, 2021
Sum Multiples
View sum_multiples.py
 """" Write a function that sums up the multiples of a given number between a given start and end. If the start or end numbers are also multiples, it should include them in the sum. For example, if the range is 1-12 and the divisor is 4, the function should add 4+8+12, returning 24. """ def sum_multiples(start, end, divisor): """ >>> sum_multiples(1, 12, 4) 24
Created Aug 30, 2021
Count Multiples
View count_multiples.py
 """Write a function that will count the amount of multiples of a given divisor between a given start number and a given end number. It should include the start or end if they are a multiple. For example, if the range is 1 to 12 and the divisor is 3, the function should return 4, since 3, 6, 9, and 12 can all be evenly divided by 3. """ def count_multiples(start, end, divisor): """
Created Aug 30, 2021
Count Evens
View count_evens.py
 """Write a function that will count the number of even numbers between a given start number and a given end number. It should include the start or end if they are even. """ def count_evens(start, end): """ >>> count_evens(2, 2) 1 >>> count_evens(-2, 52) 28 >>> count_evens(237, 500)
Created Aug 30, 2021
Product of numbers
View product_of_numbers.py
 """ This function should return the product of all the numbers from 1 to the given end number (including the end number). It is mostly written for you, but it has several bugs! Tips for debugging: * Read through the code and trace it on paper for small inputs * Try running the tests and observe the output * If you have a hunch, try changing the code and seeing how the output changes
Created Aug 30, 2021