Skip to content

Commit

Permalink
resolved exercises
Browse files Browse the repository at this point in the history
  • Loading branch information
mariskonrad committed Jun 4, 2021
1 parent 947feeb commit 5bd6d19
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
12 changes: 12 additions & 0 deletions MIT-course/04.py
@@ -0,0 +1,12 @@
# Convert the following code into code that uses a for loop.

# prints 2
# prints 4
# prints 6
# prints 8
# prints 10
# prints Goodbye!

for i in range(2, 11, 2):
print(i)
print("Goodbye!")
12 changes: 12 additions & 0 deletions MIT-course/05.py
@@ -0,0 +1,12 @@
# Convert the following code into code that uses a for loop.

# prints Hello!
# prints 10
# prints 8
# prints 6
# prints 4
# prints 2

print("Hello!")
for i in range(10, 1, -2):
print(i)
10 changes: 10 additions & 0 deletions MIT-course/06.py
@@ -0,0 +1,10 @@
# Write a for loop that sums the values 1 through end, inclusive. end is a variable that we define for you.
# So, for example, if we define end to be 6, your code should print out the result:
# 21
# which is 1 + 2 + 3 + 4 + 5 + 6.

end = 6
s = 0
for num in range(0,end + 1):
s = s + num
print(s)

0 comments on commit 5bd6d19

Please sign in to comment.