forked from djumanovdev/Python-Loop-Assignment
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask09.py
More file actions
33 lines (23 loc) · 672 Bytes
/
task09.py
File metadata and controls
33 lines (23 loc) · 672 Bytes
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
# PIN kod ochish o‘yini
from random import randint
PIN = randint(1000, 9999)
attempts = 0
print("4 xonali maxfiy raqam yaratdi")
print("7 urunishda topib ko'ring")
while attempts < 7:
answer = input(f"{attempts + 1}-urinish: PIN kodni kiriting: ")
if not answer.isdigit() or len(answer) != 4:
print("Faqat 4 xonali raqam kiriting.")
continue
answer = int(answer)
attempts += 1
if answer == PIN:
print("Tabriklaymiz, topdingiz!")
break
elif answer > PIN:
print("Juda katta son!")
else:
print("Juda kichik son!")
else:
print("Topolmadiz")
print(f"To'g'ri javob: {PIN}")