Kamila-Hamalcikova / Short_python_quiz

Creating short quiz from 3 pairs of questions and answers in Python when using nested dictionary and for and while loops

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python quiz

Description

Purpose was to refresh Python coding basics by creating quiz with 3 questions while avoiding repetition of code. When user answered 3times incorrectly, quiz was shutdown.

I used nested dictionary and iterating through for loop and while loop. It was short exercise from Jedha Fullstack course

Code snippet

# for loop to interate though all questions
for question in questions:

   # ask question
   part = input(quiz[questions[counter]]["Q"])

   # when answer to question is wrong, deduce 1 chance
   while part != (str(quiz[questions[counter]]["A"])).lower():
       nb_chances -= 1
       print("You have {} chances".format(nb_chances))

About

Creating short quiz from 3 pairs of questions and answers in Python when using nested dictionary and for and while loops


Languages

Language:Jupyter Notebook 100.0%