Write a program that computes the sum of all consecutive integers from 1
to 100
without simply doing 1 + 2 + 3 + ... + 100
. There are multiple ways to do this, but one way is most efficient.
A leap year occurs on any year that is divisible by 4
, except for century years (like 1900
), which must be divisible by 400
to be considered leap years. Write a program that calculates the number of leap years that occurred between 1430
and 2021
.
The factorial
of n
, denoted as n!
, is the product of n
and every positive integer below it.
# For example:
1! = 1
2! = 2 * 1 = 2
3! = 3 * 2 * 1 = 6
4! = 4 * 3 * 2 * 1 = 24
5! = 5 * 4 * 3 * 2 * 1 = 120
Write a program that takes any integer n
as input and calculates n!
Write a program that takes an unsorted list of 5 numbers as input and returns the average of the highest number and the lowest number.
# Example
>>> high_low_average([5,4,2,8,3])
5.0
Write a program that takes a string of characters as input and returns the single most common letter in the statement.
# Examples
>>> most_common_char('hello')
'l'
>>> most_common_char('Lemonade')
'e'