Skip to main content

Question Engine for Trivia Queston DB

Project description

Contributors Forks Stargazers Issues MIT License LinkedIn

PyPi Coveralls PyPiPythonVer


Quiz Engine for Trivia

Getting Started

Quiz Engine for Trivia module

Easy to create a quiz game by using this module.

Prerequisites

You have python 3 installed.

Use

In a terminal do following

pip install tirsvadCLI-quiz_engine_4_trivia
from QuizEngine4Trivia import QuizEngine
import html

quiz = QuizEngine()

while quiz.still_has_questions():

    current = quiz.next_question()

    user_answer: int = -1
    count = 0
    while not 0 <= user_answer <= count:
        count = 0
        print(f"Your score : {quiz.score}\n\n")
        print(f"{html.unescape(current.category)}")
        print(f"{html.unescape(current.question)}\n")

        for possible_answer in current.possible_answers:
            print(f"{count}: {html.unescape(possible_answer)}")
            count += 1
        count -= 1 # roll back last increment
        user_answer = int(input("Answer .:"))

    if quiz.check_answer(current.possible_answers[user_answer]):
        print("You are right")
    else:
        print("You are wrong")

print("You've completed the quiz")
print(f"Your final score was: {quiz.score}/{quiz.question_number}")

# show the right correct answer for those we didn't know the answers on
for result in quiz.get_result():
    if not result[0]:
        print(html.unescape(result[1]))
        print(html.unescape(result[2]))

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

Fork the Project

  1. Fork the Project
  2. Create your Feature Branch
  3. Commit your Changes
  4. Push to the Branch
  5. Open a Pull Request

Example

git checkout -b feature
git commit -m 'Add my feature enhance to project'
git push origin feature

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quizengine4trivia_tirsvadcli-0.0.6.tar.gz (45.5 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page