-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultilevelNumberGuessingGame.py
More file actions
51 lines (41 loc) · 1.74 KB
/
Copy pathmultilevelNumberGuessingGame.py
File metadata and controls
51 lines (41 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 5 01:20:41 2024
@author: SÜLEYMAN BEYYY
"""
def multilevelNumberGuessingGame():
import random
hardLevel = 5
easyLevel = 10
request = input('Do you want to play? (y/n) ->')
while request == 'y':
print('You have 5 rights at the difficult level and 10 at the easy level.')
levelPreference = input('What is your level preference? (e,d) ->')
guess = int(input('Guess the value chosen by the computer between 1-100 ->'))
reply = random.randint(1,101)
print(reply)
if guess != reply :
if levelPreference == 'e' :
easyLevel -= 1
while guess != reply and easyLevel != 0:
if guess > reply :
easyLevel -= 1
guess = int(input('Guess a smaller number ->'))
else:
easyLevel -= 1
guess = int(input('Guess a larger number ->'))
else :
hardLevel -= 1
while guess != reply and hardLevel != 0:
if guess > reply :
hardLevel -= 1
guess = int(input('Guess a smaller number ->'))
else:
hardLevel -= 1
guess = int(input('Guess a larger number ->'))
if guess != reply and (hardLevel == 0 or easyLevel == 0):
print('You lost...')
elif guess == reply :
print('You won...')
request = input('Do you want to play? (y/n) ->')
multilevelNumberGuessingGame()