diff --git a/Demot/testi.py b/Demot/testi.py new file mode 100644 index 0000000000000000000000000000000000000000..e4d537510a914095e1b60d4d92f1d6d3d4ac68d0 --- /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 5b785da829f81a2f9c703e3c863bf30ad38ab945..438835db3798c701ecf94bb50d26837a487f24f6 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)