Loops

The questions below are due on Friday June 21, 2024; 10:00:00 PM.
 
You are not logged in.

Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.
For each of the programs below, simulate it by hand using an environment diagram to predict what value will be printed. If you run into issues, first try debugging by hand and then using print statements in Python.
Link to relevant readings:
-- Iteration (all of section 5)

1) Part 1

ids = [3, -5, 1]
i = 0

while i < len(ids):
	ids[i] = ids[-i]
	i += 1

print(ids)
What value is printed?

2) Part 2

word = "summer"
vowels = "aeiou"
out = ""

for char in word:
	if char in vowels:
		char = char.upper()
	out += char

print(word+out)
What value is printed?
Next Exercise: Passwordify
Back to exercises