Question

Tutorial 3: Create a Math Quiz Build a timed math quiz game, where the player must...

Tutorial 3: Create a Math Quiz Build a timed math quiz game, where the player must answer four random arithmetic problems within a specified time. Learn how to generate random numbers using the Random class, trigger events using a Timer control, control program flow using if else statements, and perform basic arithmetic operations.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi,

Please find python propgram for your simple quiz program. In this code i have used random function, timer and some simple arithmetic experession. Please let me know if you have any queries.

Code:

# Quiz on arithmetic expression in Python
from random import *
import time

#Storing questions
questions=["=> 5*2 = ?","=> 10-5 = ?","=> (15-5)/5 = ?","=> 5^2 = ?"]

score = 0
mins = 0
print("This quiz will have random 4 questions and you have total 4 minutes to answer\n")
while mins != 4:
    random_number=randint(0, 3)

    if random_number == 0:

        print(questions[random_number])
        ans=int(input("Give the Answer :"))

        if ans == 10:
            score = score + 1
        else:
            print("Wrong answer.. wait for next question")
            time.sleep(60)
        print ("Your score is : ",score)
        mins += 1
    elif random_number == 1:

        print(questions[random_number])
        ans=int(input("Give the Answer :"))

        if ans == 5:
            score = score + 1
        else:
            print("Wrong answer.. wait for next question")
            time.sleep(60)
        print ("Your score is : ",score)
        mins += 1
    elif random_number == 2:

        print(questions[random_number])
        ans=int(input("Give the Answer :"))

        if ans == 2:
            score = score + 1
        else:
            print("Wrong answer.. wait for next question")
            time.sleep(60)
        print ("Your score is : ",score)
        mins += 1
    elif random_number == 3:

        print(questions[random_number])
        ans=int(input("Give the Answer :"))

        if ans == 25:
            score = score + 1
        else:
            print("Wrong answer.. wait for next question")
            time.sleep(60)
        print ("Your score is : ",score)
        mins += 1

Sample output:

This quiz will have random 4 questions and you have total 4 minutes to answer

=> 10-5 = ?
Give the Answer :2
Wrong answer.. wait for next question
Your score is : 0
=> 5^2 = ?
Give the Answer :10
Your score is : 1
=> (15-5)/5 = ?
Give the Answer :2
Your score is : 2
=> 5^2 = ?
Give the Answer :25
Your score is : 3

Add a comment
Know the answer?
Add Answer to:
Tutorial 3: Create a Math Quiz Build a timed math quiz game, where the player must...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • the goal is to create a c++ programs with small functions where the main delegates series...

    the goal is to create a c++ programs with small functions where the main delegates series of functions where the real work takes place. In this programming assignment, you are not allowed to use global variables. Avoid using break (unless working with a switch statement). Limit your functions to no more than 30 statements of code (not including comments or blank lines). Never use a “return” in the middle of a loop! Program Assignment: When I went to Paris over...

  • Please help me code the following in: JAVA Please create the code in as basic way...

    Please help me code the following in: JAVA Please create the code in as basic way as possible, so I can understand it better :) Full points will be awarded, thanks in advance! Program Description Write a program that demonstrates the skills we've learned throughout this quarter. This type of project offers only a few guidelines, allowing you to invest as much time and polish as you want, as long as you meet the program requirements described below. You can...

  • For this assignment, your job is to create a simple game called Opoly. The objectives of...

    For this assignment, your job is to create a simple game called Opoly. The objectives of this assignment are to: Break down a problem into smaller, easier problems. Write Java methods that call upon other methods to accomplish tasks. Use a seed value to generate random a sequence of random numbers. Learn the coding practice of writing methods that perform a specific task. Opoly works this way: The board is a circular track of variable length (the user determines the...

  • Adv. Java program - create a math quiz

    Create a basic math quiz program that creates a set of 10 randomly generated math questions for the following operations:AdditionSubtractionMultiplicationDivisionModuloExponentThe following source files are already complete and CANNOT be changed:MathQuiz.java (contains the main() method)OperationType.java (defines an enumeration for valid math operations and related functionality)The following source files are incomplete and need to be coded to meet the indicated requirements:MathQuestionable.javaA Random object called RANDOM has already been declared and assigned, and you must not change this assignment in any way.Declare and assign an interface integer called MAX_SMALL and assign it the...

  • Game Description: Most of you have played a very interesting game “Snake” on your old Nokia...

    Game Description: Most of you have played a very interesting game “Snake” on your old Nokia phones (Black & White). Now it is your time to create it with more interesting colors and features. When the game is started a snake is controlled by up, down, left and right keys to eat food which appears on random locations. By eating food snake’s length increases one unit and player’s score increases by 5 points. Food disappears after 15 seconds and appears...

  • For a C program hangman game: Create the function int play_game [play_game ( Game *g )]...

    For a C program hangman game: Create the function int play_game [play_game ( Game *g )] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) (Also the link to program files (hangman.h and library file) is below the existing code section. You can use that to check if the code works) What int play_game needs to do mostly involves calling other functions you've already...

  • Create a basic math quiz program that creates a set of 10 randomly generated math questions for the following operations:

    Create a basic math quiz program that creates a set of 10 randomly generated math questions for the following operations:AdditionSubtractionMultiplicationDivisionModuloExponentThe following source files are already complete and CANNOT be changed:MathQuiz.java (contains the main() method)OperationType.java (defines an enumeration for valid math operations and related functionality)The following source files are incomplete and need to be coded to meet the indicated requirements:MathQuestionable.javaA Random object called RANDOM has already been declared and assigned, and you must not change this assignment in any way.Declare and assign an interface integer called MAX_SMALL and assign it the...

  • Create a basic math quiz program that creates a set of 10 randomly generated math questions for the following operations:

    Create a basic math quiz program that creates a set of 10 randomly generated math questions for the following operations:AdditionSubtractionMultiplicationDivisionModuloExponentThe following source files are already complete and CANNOT be changed:MathQuiz.java (contains the main() method)OperationType.java (defines an enumeration for valid math operations and related functionality)The following source files are incomplete and need to be coded to meet the indicated requirements:MathQuestionable.javaA Random object called RANDOM has already been declared and assigned, and you must not change this assignment in any way.Declare and assign an interface integer called MAX_SMALL and assign it the...

  • Using python 3 to create the UDP Ping Clien and server. Using UDP sockets, you will...

    Using python 3 to create the UDP Ping Clien and server. Using UDP sockets, you will write a client and server program that enables the client to determine the round-trip time (RTT) to the server. To determine the RTT delay, the client records the time on sending a ping request to the server, and then records the time on receiving a ping response from the server. The difference in the two times is the RTT. The ping message contains 2...

  • Piggy back on the programming project one you completed in module 3. You will use some...

    Piggy back on the programming project one you completed in module 3. You will use some of those concepts here again. We will be building this project inside out, start individual quiz and use a for loop to repeat it three times for three students. In this program you will be required to write a python program that generates math quizzes for students in second grade. Your program should do the following Ask the student for their name Provide 3...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT