나는이 작업을하고 싶었지만 어떤 이유 때문에 꼬리면이 보이지 않게하기 위해 꼬리 사이드 1을 계속 보여주었습니다. 파이썬에서도 새로운 점을 기억하십시오.Quater Toss Guessing Game Python
또한 루프를 만들고 싶습니다. 그들이 그들이 추측 한 번호를 얻지 못하게한다고합니다. 그래서 그들이 아니오 (게임을 다시 시작합니다) 또는 예 (게임에 대한 감사를 전합니다)
이것은 내가 지금까지 가지고있는 것입니다.
import random
print 'Welcome to Heads or Tails Guessing Game'
print ''
print 'Lets say I toss a Quater up in the air. What are the chances it will come up heads or even tails every time split even? 5 times or even 5000 times. Choose an ejucated guess.'
raw_input ('What would your number be? ')
tossQuater, itsHeads, itsTails = 1,1,1
while tossQuater < 5000:
if random.randint(1,500) == 1:
itsHeads = itsHeads + 1
itstails = itsTails + 1
tossQuater = tossQuater + 1
if tossQuater == 1300:
print 'First 1,500 tosses. Heads will come up ' + str(itsHeads) + ' times.' ' But for Tails it came up ' + str(itsTails)+ ' times.'
if tossQuater == 1900:
print 'Second 2,000 tosses. Heads will come up ' + str(itsHeads) + ' times damm!.' ' But for Tails it came up ' + str(itsTails)+ ' times.'
if tossQuater == 3050:
print 'Third and final 1,500 tosses. Heads will come up ' + str(itsHeads) + ' times...' ' But for Tails it came up ' + str(itsTails)+ ' times...'
print ''
print 'Out of 5 times or even 5000 times. Well the number of heads showed out to be.' + str(itsHeads) + ' times! ' ' But from Tails it showed ' + str(itsTails) + ' times..'
raw_input ('\n\nDid the number you choose was the right one?')
'itstails의 =의 itsTails에 대한 quesiotns이있는 경우 문의 주시기, 게임을하고, 동전을 던져하는 기능을 만들었습니다 + 1 '은 새로운 변수를 생성 다른 대문자 사용. (똑같은 사건이 일어 났을 때 Head와 Tails 카운터를 모두 늘리려고하면 논리가 무섭게 깨지기 때문에 아무 의미가 없습니다 ...) – geoffspear
^this ..... try this change 'random. randint (1,2) == 1 : itsHeads의 =의 itsHeads + 다른 1 : itsTails의 =의 itsTails + 1 tossQuater = tossQuater + 1 '나의 부분에 나쁜이었다 엉망 들여 쓰기 –
OPPS에 대한 죄송합니다. 수정 해 주셔서 감사합니다. @Wooble –