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 6578813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:49:10+00:00 2026-05-25T15:49:10+00:00

Working in Python 2.7. I would like to be able to input a number,

  • 0

Working in Python 2.7.

I would like to be able to input a number, and return all the sets of values for x and y that complete the equation win_percentage = observed.

def Rlog5(observed):
    z = float(observed)/1000
    for x in range(350, 650, 1):
        y = 1000 - x
        win_percentage = (float(x)-(float(x)*float(y)))/(float(x)+float(y)-(2*(float(x)*float(y))))
        if win_percentage = observed:
           print (z, float(x), float(y))

When I run the function, I get nothing. No errors, but no values either (I’ve tried with and without the floats for x, but I think it needs them because win_percentage should be a float). The most frustrating part is that I have this code which does basically the same thing, and it works fine:

def solve(numNuggets):
    for numTwenties in range(0, numNuggets/20 + 1):
            for numNines in range(0, (numNuggets - numTwenties*20)/9 + 1):
                numSixes = (numNuggets - numTwenties*20 - numNines*9)/6
                totNuggets = 20*numTwenties + 9*numNines + 6*numSixes
                if totNuggets == numNuggets:
                    print (numSixes, numNines, numTwenties)

I know this kind of a newbie question, but I’m at my wits end…

  • 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-25T15:49:10+00:00Added an answer on May 25, 2026 at 3:49 pm

    As others have noted, you have = where you should have ==, but I assume that’s a typo here, since you would get a syntax error. But you are testing floats for equality, and floats are almost never equal because of their imprecision. Generally, you test to see if two floats are within a small difference of each other, traditionally called epsilon.

    Try this:

    if abs(win_percentage - observed) < 0.000001:
        print etc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working with deeply nested python dicts, I would like to be able to assign
I am working on a web application using Python (Django) and would like to
I'm working on a Python library that interfaces with a web service API. Like
I would like to exchange objects between two python interpreters working on the same
I have a small web.py Python application that I would like to serve under
I am working on a backup script in Python, and would like it to
I need to have an at-home project now that I'm working on Python/Django at
I am working on an algorithm in Python that uses arrays of int64s heavily.
Working in python 2.7. I have an argument that takes a list, adds the
I'm a scientist working mostly with C++, but I would like to find a

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.