-1
私はちょうどPythonでプログラミングすることを学び始めました。私は自分自身を鍛えるためにロックペーパー - はさみゲームを作ろうとします。whileループ引数が考慮されない
私は変数を作成し、無限ループ
で終了しないように引数を追加する必要がありますので、もしそれが私のcomputer_scoreを考慮していない、whileループ とコードの末尾に問題を抱えていますuser_choice = "Rock"
user_score = 0
computer_score = 0
def fight(user_choice):
if user_choice == "Rock":
scissor = 1
rock = 2
paper = 3
user_choice = rock
computer_choice = randint(1, 3)
print computer_choice
if user_choice == computer_choice:
print 'DRAW!'
elif user_choice > computer_choice:
print 'User win, consciousness can\'t be beaten, you win'
global user_score
user_score += 1
elif user_choice < computer_choice:
print 'Computer win, singularity has been reach'
global computer_score
computer_score += 1
i = 0
while (computer_score < 3 or i < 30):
fight(user_choice)
i = i + 1
'computer_score'が50で、' i'が15であるとします。その状況で 'computer_score <3またはi <30'が評価するものを考えてみましょう。 – Kevin
コンピュータが勝ったときに 'prints 'しているので、選択したものに固有のものではないので、それらの' statement'のうちの1つをランダムに印刷することができます。 –