File tree Expand file tree Collapse file tree 5 files changed +68
-2
lines changed Expand file tree Collapse file tree 5 files changed +68
-2
lines changed Original file line number Diff line number Diff line change 14
14
- [ Day 10] ( https://github.com/a092devs/100-days-of-python/tree/master/day10 ) - Functions with Outputs
15
15
- [ Day 11] ( https://github.com/a092devs/100-days-of-python/tree/master/day11 ) - The Blackjack Capstone Project
16
16
- [ Day 12] ( https://github.com/a092devs/100-days-of-python/tree/master/day12 ) - Scope & Number Guessing Game
17
+ - [ Day 13] ( https://github.com/a092devs/100-days-of-python/tree/master/day13 ) - Debugging: How to Find and Fix Errors in your Code
17
18
18
19
19
20
## ⚙ Tools and Technologies Covered
Original file line number Diff line number Diff line change 1
1
import random
2
+ import shutil
2
3
from art import logo
3
4
from replit import clear
4
5
5
6
random_number = random .randint (1 , 100 )
6
7
7
8
def get_diffculty ():
8
9
print (logo )
10
+ welcome = shutil .get_terminal_size ().columns
11
+ print ("Welcome to the number guessing game." .center (welcome ))
9
12
while True :
10
13
difficulty = input ("Choose the difficulty level from 'easy', 'medium' or 'hard': " ).lower ()
11
14
if difficulty == "easy" :
@@ -22,23 +25,28 @@ def get_diffculty():
22
25
print ("Please enter valid diffiulty level." )
23
26
clear ()
24
27
25
- print (f"\t You selected '{ difficulty } ' level with { lives } lives ." )
28
+ print (f"\t You selected '{ difficulty } ' level with { lives } attempts ." )
26
29
27
30
get_diffculty ()
28
31
29
32
def play_game (lives , random_number ):
30
33
while lives > 0 :
31
34
guess = int (input ("\n Guess a number between 1 to 100: " ))
32
35
if guess == random_number :
33
- print (f"\t Amazing, you guessed it right. The number was { guess } . 🫢" )
36
+ print (f"\t Amazing, you guessed it right with { lives - 1 } attempts remaining . The number was { guess } . 🫢" )
34
37
break
35
38
elif guess > random_number :
39
+ clear ()
36
40
print (f"\t The number { guess } is too high. Guess a lower number. 😤" )
37
41
lives -= 1
42
+ print (f"You have { lives } attempts left." )
38
43
elif guess < random_number :
44
+ clear ()
39
45
print (f"\t The number { guess } is too low. Guess a higher number. 😤" )
40
46
lives -= 1
47
+ print (f"You have { lives } attempts left." )
41
48
if lives == 0 :
49
+ clear ()
42
50
print ("\n You ran out of lives. You lose. 😭" )
43
51
44
52
play_game (lives , random_number )
Original file line number Diff line number Diff line change
1
+ # for number in range(1, 101):
2
+ # if number % 3 == 0 or number % 5 == 0:
3
+ # print("FizzBuzz")
4
+ # if number % 3 == 0:
5
+ # print("Fizz")
6
+ # if number % 5 == 0:
7
+ # print("Buzz")
8
+ # else:
9
+ # print([number])
10
+
11
+ for number in range (1 , 101 ):
12
+ if number % 3 == 0 and number % 5 == 0 :
13
+ print ("FizzBuzz" )
14
+ elif number % 3 == 0 :
15
+ print ("Fizz" )
16
+ elif number % 5 == 0 :
17
+ print ("Buzz" )
18
+ else :
19
+ print (number )
Original file line number Diff line number Diff line change
1
+ # year = input("Which year do you want to check?")
2
+
3
+ # if year % 4 == 0:
4
+ # if year % 100 == 0:
5
+ # if year % 400 == 0:
6
+ # print("Leap year.")
7
+ # else:
8
+ # print("Not leap year.")
9
+ # else:
10
+ # print("Leap year.")
11
+ # else:
12
+ # print("Not leap year.")
13
+
14
+ year = int (input ("Which year do you want to check?" ))
15
+
16
+ if year % 4 == 0 :
17
+ if year % 100 == 0 :
18
+ if year % 400 == 0 :
19
+ print ("Leap year." )
20
+ else :
21
+ print ("Not leap year." )
22
+ else :
23
+ print ("Leap year." )
24
+ else :
25
+ print ("Not leap year." )
Original file line number Diff line number Diff line change
1
+ # number = int(input("Which number do you want to check?"))
2
+
3
+ # if number % 2 = 0:
4
+ # print("This is an even number.")
5
+ # else:
6
+ # print("This is an odd number.")
7
+
8
+ number = int (input ("Which number do you want to check?" ))
9
+
10
+ if number % 2 == 0 :
11
+ print ("This is an even number." )
12
+ else :
13
+ print ("This is an odd number." )
You can’t perform that action at this time.
0 commit comments