Giter VIP home page Giter VIP logo

amzzy78-quiz_game's Introduction

Quiz Game.

Create a skeleton structure to understand how the game is going to oporate by creating four functions: def new_game(): pass def check_answer(): pass def display_score(): pass def play_again(): pass

Seperate functions for readability.

Create a dictionary to hold all the questions and answers. Create a lists of lists for the answers with the key value pairs(A,B,C,D).

website content credit: https://fantasticfungi.com/the-mush-room/mushroom-folklore-the-mushroom-folklore-of-ireland/ code credit: https://www.youtube.com/watch?v=XKHEtdqhLK8

Call the new_game function to begin a new game. Create variables for the answers within the new_game function. guesses = [] correct_guesses = 0 questions_num = 1

Display all questions within a for loop. for key in questions: print(key) Add a new print statement before the print(key) to add some seperation between questions.

Display all the different options for the answers with a nested for loop. for key in questions: print("-----------------------------") print(key) for i in options[question_num-1]: print(i)

Increment each question number after each iteration.
question_num += 1

User input: guess = input("Enter (A, B, C, D): ") Modify for uppercase senario.

Fill in the check_answer function: check_answer(qestions.get(key),guess)

Set up parameters for the check_answer function: def check_answer(answer, guess): if answer == guess: print("CORRECT!") return 1 else: print("WRONG") return 0

Increment each correct guess by 1: correct_guesses += check_answer(qestions.get(key),guess)

Display the final score outside the for loop. display_score(correct_guesses, guesses)

def display_score(correct_guesses, guesses): print("-----------------------------") print("RESULTS") print("-----------------------------") print("Answers: ", end="")

Display questions

for i in questions:
    print(questions.get(i), end="")
print()

Display the guesses.

print("Guesses: ", end="") # Display guesses for i in guesses: print(i, end="") print()

Final score and print

score = int((correct_guesses/len(questions)) * 100) print("Your score is: "+str(score)+"%")

Option to play again

def play_again():

response = input("Do you want to play again? (yes or no): ")
response = response.upper()

if response == "Yes":
    return True
else:
    return False       

amzzy78-quiz_game's People

Contributors

amzzy78 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.