School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,098 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,032 people online right now. Registration is fast and FREE... Join Now!




random numbers

 

random numbers

chrishaizimsque

12 Oct, 2009 - 03:46 AM
Post #1

New D.I.C Head
*

Joined: 11 Oct, 2009
Posts: 5


My Contributions
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,

User is offlineProfile CardPM
+Quote Post


winracer

RE: Random Numbers

12 Oct, 2009 - 06:57 PM
Post #2

D.I.C Head
**

Joined: 2 Mar, 2009
Posts: 103


My Contributions
QUOTE(chrishaizimsque @ 12 Oct, 2009 - 03: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,





would you not use 248/1000*100 to come up with the 24.8
User is offlineProfile CardPM
+Quote Post

code_m

RE: Random Numbers

16 Oct, 2009 - 01:15 PM
Post #3

D.I.C Head
**

Joined: 21 Apr, 2009
Posts: 124



Thanked: 8 times
My Contributions
Please post in [ code ] [/ code ] tags !

Python is esp important since whitespace matters.... your code is unreadable....
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 12:07PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month