Python学習コード ポートフォリオ代わり

①数字ゲーム
import random

num = int(input())* random.randint(1, 10)
print(num)

import random

answer = random.randint(1, 10)
count = 0

while True:
print("Your guess? ", end="")
guess = int(input())
# count = count + 1
count += 1

if answer == guess:
print("Bingo! It took %i guesses!"
%count) break
elif answer > guess:
print("UP!")
else:
print("DOWN!")
import random
hand = ['グー', 'チョキ', 'パー']
print("グー:0, チョキ:1, パー:2")
input = input('あなたの手を入力してください(0, 1, 2で) :')
yourhand = hand[int(input)]
print(f'あなたは :{yourhand}')
com = hand[random.randint(0,2)]
print(f'コンピュータは :{com}')
print('結果は…')
if yourhand == com:
print('あいこ')
elif yourhand == 'グー' and com == 'チョキ':
print('あなたの勝ち')
elif yourhand == 'チョキ' and com == 'パー':
print('あなたの勝ち')
elif yourhand == 'パー' and com == 'グー':
print('あなたの勝ち')
else:
print('あなたの負け')
inserted by FC2 system