Skip to content

Commit 1839cf7

Browse files
committed
day 4 | forLoop (made some changes in the firsts files just for organization)
1 parent 3fa9d0e commit 1839cf7

11 files changed

+134
-0
lines changed

Diff for: 1_inputs.py renamed to 01-02-03-04_inputs.py

File renamed without changes.

Diff for: 5-6_ifElse.py renamed to 05-06_ifElse.py

File renamed without changes.

Diff for: 7_ifElseNesting.py renamed to 07_ifElseNesting.py

File renamed without changes.

Diff for: 9_Conversion.py renamed to 09_Conversion.py

File renamed without changes.

Diff for: 13_Challenge-GradeGenerator.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Day 13 on Replit
2+
13
print("Exam Grade Calculator")
24
print("")
35

Diff for: 16_whileTrue.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Day 16 on Replit: "while True Loop"
2+
3+
# Fix my code section
4+
5+
# while true:
6+
# color = input("Enter a color: ")
7+
# if color = "red":
8+
# break
9+
# else:
10+
# print("Cool color!")
11+
# print("I don't like red")
12+
13+
while True:
14+
color = input("Enter a color: ")
15+
if color == "red":
16+
break
17+
else:
18+
print("Cool color!")
19+
20+
print("I don't like red")
21+
22+
23+
# Challenge section
24+
print("Fill in the blank lyrics!")
25+
counter = 0
26+
27+
while True:
28+
print("It´s your golden ____.")
29+
word = input("")
30+
if word == "hour":
31+
print("You get it! Beautiful song. You need", counter, "attemps")
32+
break
33+
else:
34+
print("Nope")
35+
print("")
36+
counter += 1
37+
38+
39+

Diff for: 17_whileTrue1.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Day 17 on Replit: "Another Cheat"
2+
3+
# Fix my code section
4+
5+
# while True:
6+
# print("You are in a corridor, do you go left or right?")
7+
# direction = input("> ")
8+
# if direction == "left":
9+
# print("You have fallen to your death")
10+
# break
11+
# elif direction == "right":
12+
# continue
13+
# else:
14+
# print("Ahh! You're a genius, you've won")
15+
# exit
16+
# print("The game is over, you've failed!")
17+
18+
while True:
19+
print("You are in a corridor, do you go left or right?")
20+
direction = input("> ")
21+
if direction == "left":
22+
print("You have fallen to your death")
23+
break
24+
elif direction == "right":
25+
continue
26+
else:
27+
print("Ahh! You're a genius, you've won")
28+
exit()
29+
print("The game is over, you've failed!")

Diff for: 18_Challenge-GuessTheNumber.py

Whitespace-only changes.

Diff for: 19_forLoop.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Day 19 on Replit: "For Loop"
2+
3+
# Fix my code section
4+
5+
# total = 10
6+
# while counter in range 100:
7+
# total += 10
8+
# print("total")
9+
10+
total = 10
11+
while counter in range(100):
12+
total += 10
13+
print("total:", total)
14+
15+
# Challenge section
16+
17+
print("Loan calculator")
18+
print()
19+
20+
money = 1000
21+
22+
for i in range(10):
23+
money = (money * 0.05) + money
24+
print("Year", i, "is", round(money, 2))

Diff for: 20_range.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Day 20 on Replit: "What can range really do?"
2+
3+
# Fix my code section
4+
5+
# while i in range (20, 40, -1):
6+
# print(i)
7+
8+
while i in range (20, 40, 1):
9+
print(i)
10+
11+
# Challenge section
12+
13+
print("List generator")
14+
15+
start = int(input("Start at: "))
16+
increment = int(input("Increment between values: "))
17+
end = int(input("End at:"))
18+
19+
for i in range(start, end+1, increment):
20+
print(i)

Diff for: 21_Challenge-MathGame.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Day 21 on Replit: "Challenge: Math Game"
2+
3+
print("Math Game!")
4+
5+
table = int(input("Choose a multiplication table: "))
6+
points = 0
7+
8+
for i in range(1, 11):
9+
print(i, "x", table, "= ")
10+
multiplication = int(input(">"))
11+
12+
if multiplication == (i * table):
13+
print("Great work!")
14+
print()
15+
points += 1
16+
else:
17+
print("Nope. The answer was", i * table)
18+
print()
19+
20+
print("You scored", points, "out of 10.")

0 commit comments

Comments
 (0)