Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 375883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:32:44+00:00 2026-05-12T14:32:44+00:00

I believe the word is recurse instead of ‘start over.’ I’ve created this program

  • 0

I believe the word is “recurse” instead of ‘start over.’ I’ve created this program to hone my multiplication skills in the morning. I can get it to give me a multiplication problem, but how do I get it to ask me another one?

from random import randint

print 'Good Morning Pete!'

X = randint(0, 10)

Y = randint(0, 10)

A = X * Y

Z = int(raw_input('%i * %i = ? ' % (X, Y)))

count = 0

if Z == A:
    count += 1
    print 'Good Job!'
else:
    print 'Sorry!'


if count == '10':
    print 'Time to kill \'em'

how do I get it to spit out a new problem for me to solve? I’m a beginner. Thanks all!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:32:45+00:00Added an answer on May 12, 2026 at 2:32 pm

    Pete, you wouldn’t need recursion in this case, but merely a loop.

    I suggest you put the bulk of the logic of this program (the part that asks the multiplcation problem and check your answer), into a function. Say One Problem(). This function could return 0 if you answered wrong, 1 if you answered correctly and -1 if you entered some key indicating that you want to stop. (BTW, this function is introduced to help you structure the program, make it more readeable but it is not needed for introducing a loop. you could well keep all this stuff inside the loop. Also, you should know that there are other loop constructs in python, for exampe while loops.)

    Then you’d just need in your main section something like that :

    GoodReplyCtr = 0
    for i in range(0, 10):  # or 100 or 1000 if you feel ambitious...
       cc = OneProblem()
       if cc < 0:
            break
       GoodReplyCtr += cc
    
    print(GoodReplyCtr)
    

    The concept of recursion (again not needed here), is when a function calls itself. This is a common practice when navigating graphs (like say the directory structure on you drive C:), or with some mathematical problems. We typically do not need to cover recursion early in the learning of computer languages concepts, but once you have a good mastery of things, you may find it quite useful (and challenging at time 😉 )

    Keep at it! Math and python are cool.

    Edit: One last trick:

    You may find that you need to work on some multiplication tables more than other. Rather than using randint you can use the random’s module random.choice() method to favor some numbers or to eliminate others. for example

    import random
    X = random.choice((2, 3, 4, 6, 7, 8, 9, 7, 9))  # see, no 0, 1,or 5 but more chance to get 7 or 9
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First word of warning, I believe this is a stackoverflow rather than programmers question,
I believe this code may require more effort to comprehend than average, so I'm
I believe this question might have been previously attempted in 2006 on a different
I believe this question applies to any of the For Html helpers, but my
I'm finally learning regexps and training with ack . I believe this uses Perl
I want to check in a Python program if a word is in the
Ok, sorry if this is a repost, I really don't know how to word
The WordPress word editor spits out empty <p> tags like this: <p>&nbsp;</p> . I
I want to add words an opensource Java word splitting program for Khmer (a
Quick question. I have been Googling this all morning, but it's either not there,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.