In order to use map
and filter
you're going to have to get used to lambda
functions. Create lambda functions to do the following things:
- Find the square of a number.
- Find the cube of a number.
- Convert a Fahrenheit temperature to Celsius. (Hint: (5/9)(F - 32))
- Add two numbers.
- Multiple two numbers.
- Join two strings, by placing the space character between them.
Using only a single line map
statement, create a list of the following items:
- The cubes of the numbers 1 through 33.
- All numbers less than 1000 that are evenly divisible by 3.
- Convert these temps from Fahrenheit to Celsuis:
temps = [-42.0, -10.9, 0.0, 20.7, 32.0, 42.0, 101, 273, 320]
- The square of all even, two-digit numbers.
Using only a single filter
statement, solve the following puzzles:
- What positive, odd numbers less than 1000 are evenly divisible by 7 and 13?
- What integers less than 10,000 are both: the square of another integer and evenly divisible by 2?
- How many positive, even numbers less than 1,000,000 are evenly divisible by 99?
Use map
and/or filter
(and maybe sum
) to solve the following puzzles:
- Find all the numbers evenly divisible by 3, below 100.
- Calculate the sum of all the even numbers from 2 to 222.
- Calculate the sum of the first five powers of seven.