Jun-03-2020, 06:11 PM
I'm a new Python user and I'm still learning so I decided to write a simple quiz program in Pycharm.
Only problem is I can't find a tutorial anywhere showing me how to design a GUI in Qt designer without re-doing all of the quiz program's code.
Only problem is I can't find a tutorial anywhere showing me how to design a GUI in Qt designer without re-doing all of the quiz program's code.
passed = 0
correct_questions = 0
tries = 3
difficulty_selected = 0
while difficulty_selected == 0:
difficulty = input(
"Enter (E) for 3 attempts on each question, enter (N) for a total of 3 attempts or enter (H) for 1 attempt on each question: ")
if difficulty == "E":
print("Easy selected")
difficulty_selected = "1"
if difficulty == "N":
print("Normal selected")
difficulty_selected = "1"
if difficulty == "H":
print("Hard selected")
difficulty_selected = "1"
tries = 1
print(tries, "Attempt remaining")
if difficulty_selected == 0:
print("Invalid selection")
# Question_1
a = "10"
b = "5 x 2 = "
question_1 = input(b)
while question_1 != a:
tries -= 1
if tries != 0:
print("Wrong answer, try again")
if tries > 1:
print(tries, "Attempts remaining")
if tries == 1:
print(tries, "Attempt remaining")
if tries == 0:
break
question_1 = input(b)
if question_1 == a:
break
if question_1 == a:
print("Correct answer")
passed = 1
correct_questions += 1
else:
if difficulty != "E":
if tries > 0:
print("Failed question")
if tries == 0:
print("Failed")
passed = 0
if difficulty == "E":
passed = 1
print("Wrong answer, failed question")
print("Correct answer = " + a)
# Question_2
a = "15"
b = "5 x 3 = "
if difficulty == "E":
if tries < 3:
print("Number of attempts reset")
print("3 Attempts remaining")
tries = 3
if difficulty == "E":
if passed == 1:
question_1 = input(b)
if difficulty == "N":
if passed == 1:
question_1 = input(b)
if difficulty == "H":
if passed == 1:
question_1 = input(b)
while question_1 != a:
if passed == 0:
break
tries -= 1
if tries != 0:
print("Wrong answer, try again")
if tries > 1:
print(tries, "Attempts remaining")
if tries == 1:
print(tries, "Attempt remaining")
if tries == 0:
break
question_1 = input(b)
if question_1 == a:
break
if question_1 == a:
print("Correct answer")
passed = 1
correct_questions += 1
else:
if passed == 1:
if difficulty != "E":
if tries > 0:
print("Failed question")
if tries == 0:
print("Failed")
passed = 0
if difficulty == "E":
passed = 1
print("Wrong answer, failed question")
print("Correct answer = " + a)
# Question_3
a = "20"
b = "5 x 4 = "
if difficulty == "E":
if tries < 3:
print("Number of attempts reset")
print("3 Attempts remaining")
tries = 3
if difficulty == "E":
if passed == 1:
question_1 = input(b)
if difficulty == "N":
if passed == 1:
question_1 = input(b)
if difficulty == "H":
if passed == 1:
question_1 = input(b)
while question_1 != a:
if passed == 0:
break
tries -= 1
if tries != 0:
print("Wrong answer, try again")
if tries > 1:
print(tries, "Attempts remaining")
if tries == 1:
print(tries, "Attempt remaining")
if tries == 0:
break
question_1 = input(b)
if question_1 == a:
break
if question_1 == a:
print("Correct answer")
passed = 1
correct_questions += 1
else:
if passed == 1:
if difficulty != "E":
if tries > 0:
print("Failed question")
if tries == 0:
print("Failed")
passed = 0
if difficulty == "E":
passed = 1
print("Wrong answer, failed question")
print("Correct answer = " + a)
# Question_4
a = "25"
b = "5 x 5 = "
if difficulty == "E":
if tries < 3:
print("Number of attempts reset")
print("3 Attempts remaining")
tries = 3
if difficulty == "E":
if passed == 1:
question_1 = input(b)
if difficulty == "N":
if passed == 1:
question_1 = input(b)
if difficulty == "H":
if passed == 1:
question_1 = input(b)
while question_1 != a:
if passed == 0:
break
tries -= 1
if tries != 0:
print("Wrong answer, try again")
if tries > 1:
print(tries, "Attempts remaining")
if tries == 1:
print(tries, "Attempt remaining")
if tries == 0:
break
question_1 = input(b)
if question_1 == a:
break
if question_1 == a:
print("Correct answer")
passed = 1
correct_questions += 1
else:
if passed == 1:
if difficulty != "E":
if tries > 0:
print("Failed question")
if tries == 0:
print("Failed")
passed = 0
if difficulty == "E":
passed = 1
print("Wrong answer, failed question")
print("Correct answer = " + a)
if correct_questions > 1:
print(correct_questions, "Questions correct")
if correct_questions == 1:
print(correct_questions, "Question correct")
if tries > 0:
print("Finished")
