# random numbers

Page 1 of 1

## 2 Replies - 1538 Views - Last Post: 16 October 2009 - 02:15 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=131507&amp;s=6125c450a6e403c95216b5d4449c693e&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 chrishaizimsque

Reputation: 0
• 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

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

## Re: random numbers

Posted 12 October 2009 - 07:57 PM

chrishaizimsque, 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

### #3 code_m

Reputation: 24
• Posts: 202
• Joined: 21-April 09

## Re: random numbers

Posted 16 October 2009 - 02:15 PM

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