2 Replies - 1177 Views - Last Post: 16 October 2009 - 02:15 PM Rate Topic: -----

#1 chrishaizimsque  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 12-October 09

random numbers

Posted 12 October 2009 - 04:46 AM

i am trying to get random numbers on the percents at the end on the results heres what i got it works perfectly but the end result is always the same

import random
SERIES = 1000
game = 1
series = 1

while series < SERIES:
teamA = random.randint (1,8)
teamB = random.randint (1,8)
teams = teamA + teamB


if teams == 8:
game = game + 1
series = series + 1


print "In 1000 simulated series Team B won 248 % (SERIES,game)"

print "so I estimate there is a",(game / 20),"% chance they will win"
"the series.`"



In 1000 simulated series Team B won 248 % (SERIES,game)
so I estimate there is a 5 % chance they will win

is what i get everytime


i want to know how to get it to be a random number every time or else match the teachers result becase she got

In 1000 simulated series Team B won 248 series,
so I estimate there is a 24.8% chance they will win the series.




and if any one can please help me i dont know where to start off on here if u start it and leave out a bunch off stuff i can fill the rest in

Write a program that reads in the size of a square and a character and then prints out a hollow square of that size out of the specified character and blanks. Your program should work for squares of all sizes from 1 to 20 inclusive. Here is a sample run of the program,

Is This A Good Question/Topic? 0
  • +

Replies To: random numbers

#2 winracer  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 141
  • Joined: 02-March 09

Re: random numbers

Posted 12 October 2009 - 07:57 PM

View Postchrishaizimsque, on 12 Oct, 2009 - 03:46 AM, said:

i am trying to get random numbers on the percents at the end on the results heres what i got it works perfectly but the end result is always the same

import random
SERIES = 1000
game = 1
series = 1

while series < SERIES:
teamA = random.randint (1,8)
teamB = random.randint (1,8)
teams = teamA + teamB


if teams == 8:
game = game + 1
series = series + 1


print "In 1000 simulated series Team B won 248 % (SERIES,game)"

print "so I estimate there is a",(game / 20),"% chance they will win"
"the series.`"



In 1000 simulated series Team B won 248 % (SERIES,game)
so I estimate there is a 5 % chance they will win

is what i get everytime


i want to know how to get it to be a random number every time or else match the teachers result becase she got

In 1000 simulated series Team B won 248 series,
so I estimate there is a 24.8% chance they will win the series.




and if any one can please help me i dont know where to start off on here if u start it and leave out a bunch off stuff i can fill the rest in

Write a program that reads in the size of a square and a character and then prints out a hollow square of that size out of the specified character and blanks. Your program should work for squares of all sizes from 1 to 20 inclusive. Here is a sample run of the program,





would you not use 248/1000*100 to come up with the 24.8
Was This Post Helpful? 0
  • +
  • -

#3 code_m  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 24
  • View blog
  • Posts: 197
  • Joined: 21-April 09

Re: random numbers

Posted 16 October 2009 - 02:15 PM

Please post in [ code ] [/ code ] tags !

Python is esp important since whitespace matters.... your code is unreadable....
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1