Module 1 · before
Computational thinking & Python 6 questions on what this module teaches. Guessing is fine: this is your starting point, not a test. Take the same check again at the end to see what you learned.
1. What does this print? word = 'loss'
n = 9 / 3
print(word.upper() + '!', n) LOSS!3.0 loss! 3.0 LOSS! 3 LOSS! 3.0
2. What does this print? names = ['emma', 'zoe', 'olivia', 'liam', 'ava']
picked = []
for name in names:
if len(name) >= 4:
picked.append(name)
print(picked) 3 ['emma', 'zoe', 'olivia', 'liam', 'ava'] ['olivia'] ['emma', 'olivia', 'liam']
3. What does this print? n = 1
steps = 0
while n < 50:
n = n * 3
steps += 1
print(steps, n) 5 243 4 27 3 27 4 81
4. What does this print? lines = ['zoe\n', ' \n', ' max\n', '\n', 'ivy']
docs = [line.strip() for line in lines if line.strip()]
print(len(docs), docs[1]) 3 zoe 4 max 5 max 3 max
5. count_vowels(word) counts the vowels with a loop, but its last line is print(n) instead of return n. What happens when you run total = count_vowels('ava') + 1? It shows 2, then crashes: the function hands back None, and None + 1 is an error total becomes 3 It shows 3 and total becomes 3 total becomes 2
6. You want to answer "how many names have more than 6 letters?". Which plan breaks the job into the right small steps? Measure each name, keep the ones longer than 6, count what you kept Count all the letters in all the names, then divide by 6 Take each name's first letter, then count how often each letter appears Sort the names, then take the first 6
Answer all 6 to see your result Your answers are saved with a random id, not your name, so we can see which lessons work. Privacy