last lab
This commit is contained in:
44
labPython/lab4/Modul2.py
Executable file
44
labPython/lab4/Modul2.py
Executable file
@@ -0,0 +1,44 @@
|
||||
from random import randint
|
||||
def Gen():
|
||||
cartRandAndPorc = (randint(100, 1000), randint(1, 100))
|
||||
return cartRandAndPorc
|
||||
|
||||
def Question(procent):
|
||||
try:
|
||||
return int(input(f"{procent[1]} процен(т\ов) от числа {procent[0]}: "))
|
||||
except:
|
||||
pass
|
||||
def Proverka(answer, answerTrue):
|
||||
answerTrue = int((answerTrue[0]/100)*answerTrue[1])
|
||||
if answer == answerTrue:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
||||
def Ball(trulest, qCount)->int:
|
||||
point = 100//qCount
|
||||
if trulest == 1:
|
||||
return point
|
||||
else:
|
||||
return 0
|
||||
|
||||
def Mark(points):
|
||||
if points <= 40:
|
||||
return 2
|
||||
elif points <= 60:
|
||||
return 3
|
||||
elif points <= 80:
|
||||
return 4
|
||||
elif points > 80:
|
||||
return 5
|
||||
|
||||
points = 0
|
||||
qCount = int(input("Колличество вопросов: "))
|
||||
for i in range(1, qCount+1):
|
||||
|
||||
print("Вопрос ", i)
|
||||
gen = Gen()
|
||||
answer = Question(gen)
|
||||
points += Ball(Proverka(answer, gen), qCount)
|
||||
|
||||
print(f"Ваша оценка {Mark(points)}, общее число баллов: {points}")
|
||||
Reference in New Issue
Block a user