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

  • SEARCH
  • Home
  • 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 8128161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:47:19+00:00 2026-06-06T07:47:19+00:00

what I am wanting to do is randomly generate two numbers that equal a

  • 0

what I am wanting to do is randomly generate two numbers that equal a given number. Yet to allow for this to get the desired answer I want it to be random. That is the problem.

a=(1,2,3,4,5,6,7,8,9,)
from random import choice
b=choice(a)
c=choice(b)
d= c+b
if d == 10:
#then run the rest of the program with the value's c and b in it
#probably something like sys.exit goes here but I am not sure to end \/
else:
# i have tryied a few things here but I am not sure what will loop it around*

(thanks for the help :D)

I have know created a list called ‘right’ and know trying to append values a and b to the list yet that is not working. For I am knowing running the program ‘in for trail in range(100)’ so I get the answer. Yet the values are not appending into the new list right. Which is the problem. Then what I am going to do it read values 0 and 1 in the list right and then use them.(sorry its not that well done for at school)
This is for fractions not adding to a given variable. This bit second but is.

import sys
right=(0)
y=x+x
from trail in range(y)
a=(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)
from random import choice 
A=choice(a)
B=choice(a)
d=A/B
if d==1:
    right.append(A)
    right.append(B)
else:
    x.append(1)
  • 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-06-06T07:47:20+00:00Added an answer on June 6, 2026 at 7:47 am
     from random import choice
    
     a = range(1, 10)
     b = c = 0
     while b + c != 10:
         b = choice(a)
         c = choice(a)  # You meant choice(a) here, right?
    

    But this accomplishes the same thing:

     b = choice(a)
     c = 10 - b
    

    For decimal numbers betweeen 0 and 10:

    from random import uniform
    
    b = uniform(0, 10)
    c = 10 - b
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I noticed that sometimes(randomly) my Mootools ajax request gets send twice. The second request
So, I'm wanting to get a better grasp on how string literals in C++
So right now what I am trying is to randomly get a question from
Im wanting to to display the number of pixels a user has scrolled in
Not wanting this question to be too long, I will skip to an example:
Just wanting to get a bit more of an idea about how Phonegap/Titanium packages
I'm wanting to create an android app that gathers information and then uploads to
I am wanting to pass a decimal number (1.23) to my WCF-REST web service.
I'm wanting to build an application that will tell me how far I've ran.
I have a number of C# software applications that are add-ins for a peice

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.