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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:57:13+00:00 2026-05-26T16:57:13+00:00

Working in python 2.7. I have an argument that takes a list, adds the

  • 0

Working in python 2.7.

I have an argument that takes a list, adds the values of the argument list to the list “team”, and then compares certain positional values and returns win, loss, or tie depending upon the values.

def starterTrans3(starter):
    wins = 0
    losses = 0
    nd = 0
    team = [[1, 0], [1, 0], [0, 5], [3, -1]]
    random.shuffle(team)
    for t, s in zip(team, starter):
        t.extend(s)
    score_add(team, exit_score(team, starter))
    length = len(starter)
    for i in range(0, length):
        if team[i][4] > 0 and (team[i][1] > -team[i][4]) and team[i][2] >= 5:
            wins += 1
        elif team[i][4] < 0 and (team[i][1] <= -team[i][4]):
            losses += 1
        elif (team[i][4] <= 0 and team[i][1] >= -team[i][4]):
            nd += 1
    return wins, losses, nd

I want to be able to simulate the results many times, using random.shuffle(team) to randomly order the team list.

I can do that using:

def MonteCarlo(starter, x):
    for i in range(0, x):
        print starterTrans3(starter)

But I would like to be able to sum all of the wins, losses and ties from all the simulations, and then divide by the number of simulations (in this case x), to get an average of wins, losses, and ties in all of the simulations.

I’ve tried changing the starterTrans function to have a total_wins variable that is equal to += wins, but I haven’t been able to figure it out. Any ideas?

  • 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-26T16:57:14+00:00Added an answer on May 26, 2026 at 4:57 pm

    i may not getting your point, but…

    def MonteCarlo(starter, x):
        result = dict(w=0,l=0,n=0)
        for i in range(0, x):
            w,l,n = starterTrans3(starter)
            result['w']+=w
            result['l']+=l
            result['n']+=n
        return result
    

    or

        return result['w']/float(x),result['l']/float(x),result['n']/float(x)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to have an at-home project now that I'm working on Python/Django at
I have a working Python based program that I want to run as a
I have a working Python script that executes an external command and calls Popen.communicate()
I have a working python 2.7 program that calls a DLL. I am trying
I have recently been working with Python using Komodo Edit and other simpler editors
I'm working on my first object oriented bit of python and I have the
I am working with Google App Engine and Python. I have a model with
I'm wondering if anyone have a good resource for working with Corba in Python?
I have this Python code that I found online and would like to know
I have a working Python 2.6 install and just installed the PyQt4 built for

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.