Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 I'm having trouble with my assignment for creating a math quiz
#1
I received my assignment and these were the instructions:

Write a program that gives a simple Math quizzes. The program should display two random numbers that are to be added together. The program should let the user enter their answer. If the answer is correct then the program should display a message that says Correct Congratulations! If the answer is not correct the program should display the correct answer and a message that says "Incorrect, Better Luck Next Time",  The program should also ask the user if he wants to take another quiz. At the end of the program the should be a report of how many quizzes the user took, along with how many wins and how many losses they had.

I will be looking for functions to be used throughout this program!  Don't forget in order to use the random function you must import the random library

I'm just not sure exactly how to do it. I need help!!
Quote
#2
You should make a start using the things you have learnt so far.
Try to deal with small bits of it at a time and build it up slowly.
When you hit a road block with a particular part, post the code here in python code tags and any error traceback in error tags.
Quote
#3
Question?
Quote
#4
I am confused as to how to make random number add together and have the user input the right or wrong answer. I know how to loop, but I don't know how to have all of the reports at the end for the combined stats.
Quote
#5
(Nov-13-2016, 03:37 PM)thewrongnarwhal Wrote: I am confused as to how to make random number add together and have the user input the right or wrong answer. I know how to loop, but I don't know how to have all of the reports at the end for the combined stats.

Once you have picked up your two random numbers they are just numbers in variables and can be added to each other. Then the user input becomes an integer value in another variable and can be compared to the sum of these two random numbers.

For the final stats, use two counters in the loop, one that is incremented at each execution, and one that is incremented at each successful execution (you don't need a counter for errors, this is just the difference between the two counters you already have.
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Quote
#6
But how do I create a counter in a loop? Also how do I have the output be right or wrong if the user is right or wrong?
Quote
#7
I think you don't understand how to pass arguments to a function,
Let's say you want to create a function that does nothing else but print
whatever you send it x number of times, and print the number associated
with the line being printed

First create the function with the arguments that are required to make it reusable:

def print_numtimes(stuff_to_print, number_of_times):
That will be enough to start to reach your goal
next you have to add the machine that does the magic:

def print_numtimes(stuff_to_print, number_of_times):
    for n in range(number_of_times):  # This will loop number_of_times times
        print('Iteration number {} - {}'.format(n, stuff_to_print))
That's the complete function.
Now, you have to actually execute the function, and pass it some values:
def print_numtimes(stuff_to_print, number_of_times):
    for n in range(number_of_times):  # This will loop number_of_times times
        print('Iteration number {} - {}'.format(n, stuff_to_print))

print_numtimes('Hello there', 5)
And you're done

Now do the same thing with random numbers
Quote
#8
(Nov-14-2016, 12:53 AM)thewrongnarwhal Wrote: But how do I create a counter in a loop?

loopcounter=0
while looping:
    # do loop stuff
    # ...
    loopcounter+=1 # increment counter

# here the loop had ended
print 'Times looped:', loopcounter
nilamo likes this post
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Trouble with Loops in lab assignment jonstryder 6 332 Jul-28-2019, 06:40 PM
Last Post: ThomasL
  Trouble with "Weather Program" Assignment sarah_mb_sues 5 2,582 Aug-10-2018, 02:29 AM
Last Post: ichabod801
  Assignment help: Creating a resulting “wave” from two files AltF4ke 0 737 Apr-20-2018, 02:11 AM
Last Post: AltF4ke

Forum Jump:


Users browsing this thread: 1 Guest(s)