Lists: exercises#

Exercise#

Make a list of the first 7 powers of 3 (\(3^1\), \(3^2\), etc.).

Exercise#

Make a list of the first 100 odd numbers. Check that it’s 100 long.

Important: a for loop doesn’t have to just use range. It can also iterate through a list that you provide. Here’s an example:

for x in [1, 2., 'a']:
    print(x)
1
2.0
a

Exercise: a nested loop#

Write a nested for loop (one loop inside another) that prints a truth table for the ‘or’ operator. Use two variables a and b that take all combinations of True and False, and show the value of (a or b). For example, you should have

a b => (a and b)
True True => True
True False => True
False True => True
False False => False