From c1ed3a2b12c3b0c4b29fca2775007c51bd40ded8 Mon Sep 17 00:00:00 2001 From: unknown <AB6912@student.labranet.jamk.fi> Date: Sun, 31 Oct 2021 16:36:30 +0200 Subject: [PATCH] test --- Demot/testi.py | 38 +++++++++++++++++++++++++++++++++++ L12 Luokat ja oliot/L12T03.py | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 Demot/testi.py diff --git a/Demot/testi.py b/Demot/testi.py new file mode 100644 index 0000000..e4d5375 --- /dev/null +++ b/Demot/testi.py @@ -0,0 +1,38 @@ +import random + +class question: + def __init__(self, q, a): + self.q = q + self.a = a + def __str__(self): + return f"{self.q}, {self.a}" + +q1 = question("Testquestion?", "Testanswer") +q2 = question("Testquestion2?", "Testanswer2") +q3 = question("Testquestion?3", "Testanswer3") +questions = [q1, q2, q3] +questionCount = 0 +correctCount = 0 +while True: + if questionCount < 11: + guestion = random.choice(questions) + print(guestion.q) + answer = input("Enter your answer here: ") + if answer == guestion.a: + print("Correct!") + correctCount += 1 + else: + print("Wrong!") + questionCount += 1 + else: + if correctCount == 10: + print(f"You scored {correctCount}/10! Great job!") + elif correctCount > 8: + print(f"You scored {correctCount}/10! Not bad!") + elif correctCount > 5: + print(f"You scored {correctCount}/10! You can definitely do better!") + elif correctCount > 0: + print(f"You scored {correctCount}/10! That wasn't good, better luck next time!") + else: + print(f"You scored {correctCount}/10! You should at least try next time...") + break \ No newline at end of file diff --git a/L12 Luokat ja oliot/L12T03.py b/L12 Luokat ja oliot/L12T03.py index 5b785da..438835d 100644 --- a/L12 Luokat ja oliot/L12T03.py +++ b/L12 Luokat ja oliot/L12T03.py @@ -4,7 +4,7 @@ class Car: self.model = model self.price = price def __str__(self): - return f"{self.brand} {self.model} {str(self.price)}" + return f"{self.brand} {self.model} {self.price}" car1 = Car("Skoda", "Octavia", 3000) car2 = Car("Audi", "A4", 4000) -- GitLab