Skip to content

Commit 98842c8

Browse files
committed
Exercises completed
1 parent 99576db commit 98842c8

File tree

43 files changed

+216
-14
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+216
-14
lines changed

.learn/resets/01-Console/app.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# print "Hello World!" on the console
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# ✅ ↓ your code here ↓ ✅
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# ✅ ↓ your code here ↓ ✅
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# ✅ ↓ your code here ↓ ✅
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
age = int(input('What is your age?\n'))
2+
# ✅ ↓ CHANGE THE CODE BELOW TO ADD 10 TO AGE ↓ ✅
3+
4+
print("Your age is: "+str(age))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# ✅ ↓ Set the values for my_var1 and my_var2 here ↓ ✅
2+
3+
4+
## Don't change anything below this line
5+
the_new_string = my_var1 + ' ' + my_var2
6+
print(the_new_string)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
a = '</title>'
2+
b = '</html>'
3+
c = '<head>'
4+
d = '</body>'
5+
e = '<html>'
6+
f = '</head>'
7+
g = '<title>'
8+
h = '<body>'
9+
10+
# ❌ ⬆ DON'T CHANGE THE CODE ABOVE ⬆ ❌
11+
12+
# ✅ ↓ start coding below here ↓ ✅
13+
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
total = int(input('How much money do you have in your pocket\n'))
2+
3+
# ✅ ↓ YOUR CODE HERE ↓ ✅
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
user_input = int(input('How many people are coming to your wedding?\n'))
2+
3+
# ❌ ⬆ DON'T CHANGE THE CODE ABOVE ⬆ ❌
4+
5+
6+
if user_input <= 50:
7+
price = 4000
8+
# ✅ ↓ Your code here ↓ ✅
9+
10+
11+
# ❌ ↓ DON'T CHANGE THE CODE BELOW ↓ ❌
12+
print('Your wedding will cost '+str(price)+' dollars')
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import random
2+
3+
def get_randomInt():
4+
# ✅ ↓ CHANGE ONLY THIS ONE LINE BELOW ↓ ✅
5+
random_number = random.random()
6+
return random_number
7+
8+
print(get_randomInt())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def is_odd(my_number):
2+
return (my_number % 2 != 0)
3+
4+
5+
def my_main_code():
6+
# ✅ ↓ Your code here ↓ ✅
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def add_numbers(a,b):
2+
# This is the function's body ✅↓ Write your code here ↓✅
3+
4+
5+
# ❌ ↓ DON'T CHANGE THE CODE BELOW ↓ ❌
6+
print(add_numbers(3,4))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import random
2+
3+
# ✅↓ Write your code here ↓✅
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import random
2+
3+
def get_randomInt():
4+
# ✅↓ Write your code here ↓✅
5+
return None
6+
7+
# ❌ ↓ DON'T CHANGE THE CODE BELOW ↓ ❌
8+
print(get_randomInt())
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def start_counting():
2+
for i in range(10):
3+
print(i)
4+
return i
5+
6+
start_counting()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def standards_maker():
2+
# ✅↓ Write your code here ↓✅
3+
4+
5+
# ✅↓ remember to call the function outside (here) ↓✅
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def fizz_buzz():
2+
# ✅↓ Write your code here ↓✅
3+
4+
# ❌↓ DON'T CHANGE THE CODE BELOW ↓❌
5+
fizz_buzz()
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import random
2+
3+
def get_color(color_number=4):
4+
# Making sure is a number and not a string
5+
color_number = int(color_number)
6+
7+
switcher = {
8+
0:'red',
9+
1:'yellow',
10+
2:'blue',
11+
3:'green',
12+
4:'black'
13+
}
14+
15+
return switcher.get(color_number,"Invalid Color Number")
16+
17+
# ❌ ⬆ DON'T CHANGE THE CODE ABOVE ⬆ ❌
18+
19+
def get_allStudentColors():
20+
example_color = get_color(1)
21+
students_array = []
22+
# ✅ ↓ your loop here ↓ ✅
23+
24+
25+
print(get_allStudentColors())
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import random
2+
3+
bullet_position = 3
4+
5+
def spin_chamber():
6+
chamber_position = random.randint(1,6)
7+
return chamber_position
8+
9+
# ❌ ⬆ DON'T CHANGE THE CODE ABOVE ⬆ ❌
10+
def fire_gun():
11+
# ✅ ↓ your code here ↓ ✅
12+
return None
13+
14+
15+
print(fire_gun())

.learn/resets/18-The-Beatles/app.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# ✅↓ Write your code here ↓✅
2+
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# ✅↓ Write your code here ↓✅

.vscode/settings.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
"editor.minimap.enabled": false,
55
"workbench.editorAssociations": {
66
"*.md": "vscode.markdown.preview.editor"
7-
}
7+
},
8+
"githubPullRequests.ignoredPullRequestBranches": [
9+
"master"
10+
]
811
}

exercises/01-Console/app.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
# print "Hello World!" on the console
1+
# print "Hello World!" on the console
2+
print ("Hello World!")

exercises/02-Declare-Variables/app.py

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
# ✅ ↓ your code here ↓ ✅
2+
color = "Yellow"
3+
print(color)
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
# ✅ ↓ your code here ↓ ✅
1+
# ✅ ↓ your code here ↓ ✅
2+
color = "red"
3+
item = "marker"
4+
5+
print(color, item)
+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
# ✅ ↓ your code here ↓ ✅
2+
variables_are_cool = 2345 * 7323
3+
print(variables_are_cool)
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
age = int(input('What is your age?\n'))
22
# ✅ ↓ CHANGE THE CODE BELOW TO ADD 10 TO AGE ↓ ✅
3-
3+
age +=10
44
print("Your age is: "+str(age))

exercises/06-String-Concatenation/app.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# ✅ ↓ Set the values for my_var1 and my_var2 here ↓ ✅
2-
2+
my_var1 = "Hello"
3+
my_var2 = "World"
34

45
## Don't change anything below this line
56
the_new_string = my_var1 + ' ' + my_var2

exercises/07-Create-a-Basic-HTML/app.py

+2
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@
1111

1212
# ✅ ↓ start coding below here ↓ ✅
1313

14+
html_document = e + c +g +a +f+h+d+b
15+
print(html_document)

exercises/08.1-Your-First-If/app.py

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
total = int(input('How much money do you have in your pocket\n'))
22

33
# ✅ ↓ YOUR CODE HERE ↓ ✅
4+
if total >100:
5+
print("Give me your money!")
6+
elif total >50:
7+
print("Buy me some coffee, you cheap!")
8+
else:
9+
print("You are a poor guy, go away!")

exercises/08.2-How-Much-The-Wedding-Costs/app.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
if user_input <= 50:
77
price = 4000
88
# ✅ ↓ Your code here ↓ ✅
9-
9+
elif user_input <=100:
10+
price = 10000
11+
elif user_input <=200:
12+
price = 15000
13+
elif user_input >200:
14+
price = 20000
1015

1116
# ❌ ↓ DON'T CHANGE THE CODE BELOW ↓ ❌
1217
print('Your wedding will cost '+str(price)+' dollars')

exercises/09-Random-Numbers/app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
def get_randomInt():
44
# ✅ ↓ CHANGE ONLY THIS ONE LINE BELOW ↓ ✅
5-
random_number = random.random()
5+
random_number = random.randint(1,10)
66
return random_number
77

88
print(get_randomInt())

exercises/10-Calling-Your-First-Function/app.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ def is_odd(my_number):
33

44

55
def my_main_code():
6-
# ✅ ↓ Your code here ↓ ✅
6+
# ✅ ↓ Your code here ↓ ✅
7+
print (is_odd(45345))

exercises/10.1-Creating-Your-First-Function/app.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
def add_numbers(a,b):
22
# This is the function's body ✅↓ Write your code here ↓✅
3+
return a + b
34

45

56
# ❌ ↓ DON'T CHANGE THE CODE BELOW ↓ ❌
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
import random
22

33
# ✅↓ Write your code here ↓✅
4+
def generate_random ():
5+
return random.randint(0,9)
6+
7+
print (generate_random)

exercises/12-Rand-From-One-to-Twelve/app.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
def get_randomInt():
44
# ✅↓ Write your code here ↓✅
5-
return None
5+
random_number = random.randrange(1,13)
6+
return random_number
67

78
# ❌ ↓ DON'T CHANGE THE CODE BELOW ↓ ❌
89
print(get_randomInt())

exercises/13-Your-First-Loop/app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
def start_counting():
2-
for i in range(10):
2+
for i in range(12):
33
print(i)
44
return i
55

exercises/14-Create-A-For-Loop/app.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
def standards_maker():
22
# ✅↓ Write your code here ↓✅
3-
3+
for i in range (300):
4+
print('I will ask questions if I am stuck')
5+
46

57
# ✅↓ remember to call the function outside (here) ↓✅
8+
standards_maker()
+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
def fizz_buzz():
22
# ✅↓ Write your code here ↓✅
3-
3+
for i in range (1,101):
4+
if i%3==0 and i%5 == 0:
5+
print("FizzBuzz")
6+
elif i%3==0:
7+
print("Fizz")
8+
elif i%5==0:
9+
print("Buzz")
10+
else:
11+
print(i)
412
# ❌↓ DON'T CHANGE THE CODE BELOW ↓❌
513
fizz_buzz()

exercises/16-Random-Colors-Loop/app.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ def get_allStudentColors():
2020
example_color = get_color(1)
2121
students_array = []
2222
# ✅ ↓ your loop here ↓ ✅
23-
23+
color_number= random.randint(0,3)
24+
for i in range (10):
25+
students_array.append(get_color(color_number))
26+
return students_array
2427

2528
print(get_allStudentColors())

exercises/17-Russian-Roulette/app.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ def spin_chamber():
99
# ❌ ⬆ DON'T CHANGE THE CODE ABOVE ⬆ ❌
1010
def fire_gun():
1111
# ✅ ↓ your code here ↓ ✅
12-
return None
12+
if spin_chamber() == bullet_position:
13+
return 'You are dead!'
14+
else:
15+
return 'Keep playing!'
1316

1417

1518
print(fire_gun())

exercises/18-The-Beatles/app.py

+12
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
11
# ✅↓ Write your code here ↓✅
22

3+
def sing ():
4+
song = ""
5+
for i in range (11):
6+
if i == 4:
7+
song += "there will be an answer,\n"
8+
elif i == 10:
9+
song += "whisper words of wisdom, let it be"
10+
else:
11+
song += "let it be,\n"
12+
return song
13+
14+
sing()

exercises/19-Bottles-Of-Milk/app.py

+8
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
11
# ✅↓ Write your code here ↓✅
2+
def number_of_bottles():
3+
for i in range (99,2,-1):
4+
print(str(i)+" bottles of milk on the wall, " +str(i)+ " bottles of milk. Take one down and pass it around, "+str(i-1)+ " bottles of milk on the wall.")
5+
print("2 bottles of milk on the wall, 2 bottles of milk. Take one down and pass it around, 1 bottle of milk on the wall.")
6+
print("1 bottle of milk on the wall, 1 bottle of milk. Take one down and pass it around, no more bottles of milk on the wall.")
7+
print("No more bottles of milk on the wall, no more bottles of milk. Go to the store and buy some more, 99 bottles of milk on the wall.")
8+
9+
number_of_bottles()

0 commit comments

Comments
 (0)