Skip to content

Commit aeca589

Browse files
committed
Update the url to ssh
1 parent 90d46e0 commit aeca589

File tree

91 files changed

+13358
-13358
lines changed

Some content is hidden

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

91 files changed

+13358
-13358
lines changed

01_quiz_game/quiz_game.py

+43-43
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
import random
2-
3-
4-
# Dictionary that contain the feature as key and his inventer as value
5-
question_dict = {'Ballpoint pen': 'Biro Brothers', 'Jet Engine': 'Sir Frank Whittle',
6-
'Gramophone': 'Thomas Alva Edison', 'Internal Combustion Engine': 'Otto',
7-
'The Spinning Jeny': 'James Hargreaves', 'the small pox vaccine': 'Edward Jenner',
8-
'Railway air brakes': 'George Westinghouse', 'Electric streetcar': 'Thomas Davenport',
9-
'Electric Generator': 'Michal Faraday', 'Gun Powder': 'Roger Bacon'
10-
}
11-
12-
mark = 0
13-
# Turning the dict keys into a random list
14-
question_list = list(question_dict.keys())
15-
random.shuffle(question_list)
16-
# loop through the random list of questions
17-
for i, key in enumerate(question_list):
18-
print(40 * '-')
19-
print(f'{i + 1}- How invent {key}')
20-
21-
# Give the user 4 choices, be sure that the choices are random and includes the right answer
22-
choices = list(question_dict.values())
23-
random.shuffle(choices)
24-
choices.remove(question_dict[key])
25-
choices = choices[:3]
26-
choices.append(question_dict[key])
27-
random.shuffle(choices)
28-
# Print the choices to the user
29-
for a, b in enumerate(choices):
30-
print(f" {a + 1}- {b}")
31-
32-
# Taking the user answer
33-
response = int(input('Enter your choice : '))
34-
35-
# Evaluating the user answer
36-
if choices[response - 1] == question_dict[key]:
37-
mark += 1.0
38-
else:
39-
mark -= 0.5
40-
41-
print(question_dict[key])
42-
print('-------------------------')
43-
print(f"You have got {mark}/10")
1+
import random
2+
3+
4+
# Dictionary that contain the feature as key and his inventer as value
5+
question_dict = {'Ballpoint pen': 'Biro Brothers', 'Jet Engine': 'Sir Frank Whittle',
6+
'Gramophone': 'Thomas Alva Edison', 'Internal Combustion Engine': 'Otto',
7+
'The Spinning Jeny': 'James Hargreaves', 'the small pox vaccine': 'Edward Jenner',
8+
'Railway air brakes': 'George Westinghouse', 'Electric streetcar': 'Thomas Davenport',
9+
'Electric Generator': 'Michal Faraday', 'Gun Powder': 'Roger Bacon'
10+
}
11+
12+
mark = 0
13+
# Turning the dict keys into a random list
14+
question_list = list(question_dict.keys())
15+
random.shuffle(question_list)
16+
# loop through the random list of questions
17+
for i, key in enumerate(question_list):
18+
print(40 * '-')
19+
print(f'{i + 1}- How invent {key}')
20+
21+
# Give the user 4 choices, be sure that the choices are random and includes the right answer
22+
choices = list(question_dict.values())
23+
random.shuffle(choices)
24+
choices.remove(question_dict[key])
25+
choices = choices[:3]
26+
choices.append(question_dict[key])
27+
random.shuffle(choices)
28+
# Print the choices to the user
29+
for a, b in enumerate(choices):
30+
print(f" {a + 1}- {b}")
31+
32+
# Taking the user answer
33+
response = int(input('Enter your choice : '))
34+
35+
# Evaluating the user answer
36+
if choices[response - 1] == question_dict[key]:
37+
mark += 1.0
38+
else:
39+
mark -= 0.5
40+
41+
print(question_dict[key])
42+
print('-------------------------')
43+
print(f"You have got {mark}/10")

02_number_game/number_game.py

+37-37
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
import random
2-
3-
4-
def game():
5-
# generate a random number between 1 and 10
6-
secret_number = random.randint(1, 10)
7-
8-
guesses = []
9-
while len(guesses) < 5:
10-
try:
11-
# get a number from the player
12-
user_guess = int(input("Enter a number between 1 and 10 "))
13-
except ValueError:
14-
print("That's not a number!")
15-
else:
16-
# compare guess to secret number
17-
if user_guess == secret_number:
18-
print("Well done! You guess it")
19-
break
20-
elif user_guess > secret_number:
21-
print("Too High...")
22-
elif user_guess < secret_number:
23-
print("Too Low...")
24-
else:
25-
print("You miss :-(")
26-
guesses.append(user_guess)
27-
else:
28-
print(f"You didn't get it! My number was {secret_number}")
29-
30-
play_again = input('Do want to play again? Y/N ')
31-
if play_again.lower() != 'n':
32-
game()
33-
else:
34-
print("Bye!!")
35-
36-
37-
game()
1+
import random
2+
3+
4+
def game():
5+
# generate a random number between 1 and 10
6+
secret_number = random.randint(1, 10)
7+
8+
guesses = []
9+
while len(guesses) < 5:
10+
try:
11+
# get a number from the player
12+
user_guess = int(input("Enter a number between 1 and 10 "))
13+
except ValueError:
14+
print("That's not a number!")
15+
else:
16+
# compare guess to secret number
17+
if user_guess == secret_number:
18+
print("Well done! You guess it")
19+
break
20+
elif user_guess > secret_number:
21+
print("Too High...")
22+
elif user_guess < secret_number:
23+
print("Too Low...")
24+
else:
25+
print("You miss :-(")
26+
guesses.append(user_guess)
27+
else:
28+
print(f"You didn't get it! My number was {secret_number}")
29+
30+
play_again = input('Do want to play again? Y/N ')
31+
if play_again.lower() != 'n':
32+
game()
33+
else:
34+
print("Bye!!")
35+
36+
37+
game()

03_shopping_list/shopping_list.py

+46-46
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
# make a list to hold onto our new_items
2-
shopping_list = []
3-
4-
5-
# show the list items
6-
def show_items(lst):
7-
print("Here is your list: ")
8-
for item in lst:
9-
print(f"--> {item}")
10-
11-
12-
# show a helping list
13-
def show_help():
14-
# print out instructions on how to use the app
15-
print("What should we pick up at the store?")
16-
print('''
17-
Enter 'DONE' to stop adding items.
18-
Enter 'HELP' for this help.
19-
Enter 'SHOW' to see your current list.
20-
''')
21-
22-
23-
def add_items(item):
24-
# add new new_items to our List
25-
shopping_list.append(item)
26-
print(f"Added {item}. List now has {len(shopping_list)} items.")
27-
28-
29-
show_help()
30-
31-
while True:
32-
new_item = input("> ")
33-
34-
# be able to quit the app
35-
if new_item == 'DONE':
36-
break
37-
38-
elif new_item == 'SHOW':
39-
show_items(shopping_list)
40-
continue
41-
42-
elif new_item == 'HELP':
43-
show_help()
44-
continue
45-
46-
add_items(new_item)
1+
# make a list to hold onto our new_items
2+
shopping_list = []
3+
4+
5+
# show the list items
6+
def show_items(lst):
7+
print("Here is your list: ")
8+
for item in lst:
9+
print(f"--> {item}")
10+
11+
12+
# show a helping list
13+
def show_help():
14+
# print out instructions on how to use the app
15+
print("What should we pick up at the store?")
16+
print('''
17+
Enter 'DONE' to stop adding items.
18+
Enter 'HELP' for this help.
19+
Enter 'SHOW' to see your current list.
20+
''')
21+
22+
23+
def add_items(item):
24+
# add new new_items to our List
25+
shopping_list.append(item)
26+
print(f"Added {item}. List now has {len(shopping_list)} items.")
27+
28+
29+
show_help()
30+
31+
while True:
32+
new_item = input("> ")
33+
34+
# be able to quit the app
35+
if new_item == 'DONE':
36+
break
37+
38+
elif new_item == 'SHOW':
39+
show_items(shopping_list)
40+
continue
41+
42+
elif new_item == 'HELP':
43+
show_help()
44+
continue
45+
46+
add_items(new_item)

0 commit comments

Comments
 (0)