References:
There are two modes when a cell is highlighted.
lst = [20, 1, -34, 40, -8, 60, 1, 3]
evaluate the following expressions. Write your answers in markdown first then use code to verify your answer.¶
Then use a for loop to append to the list the multiples of 3 from 12 to 2340. Print out the length of this list.
Redo part 1) of this problem but use list comprehensions instead of a for loop.
Use list comprehension as in part 2) but add in the additional condition that the numbers need to be a multiple of 7.
list()
and the range()
function to create a list of even numbers from 2 to 50.¶
sum
to find the sum of a list created in the previous problem.¶
n
. Use list comprehension to create a list factors
which is a list of factors of n
.¶
n
? (Pretty cool!)¶[x for x in range(2, n) if n % x == 0] == []
One sample output:
Mike 2.3
John 3.5
Michele 3.7
Carol 3.2