Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import sys
- symbols = ['Papier', 'Kamień', 'Nożyce']
- def start_game():
- print('Witaj w grze Kamień, papier, nożyce.')
- player_choice = input('Podaj symbol(Kamień[K], Papier[P], Nożyce[N]): ')
- cpu_choice = random.choice(symbols)
- print('Twoj przeciwnik wybral:', cpu_choice)
- who_win(cpu_choice ,player_choice)
- def who_win(cpu_choice, player_choice):
- if cpu_choice == player_choice:
- result = 'tie'
- if player_choice == 'K':
- if cpu_choice == 'Papier':
- result = 'lose'
- elif cpu_choice == 'Nożyce':
- result = 'win'
- if player_choice == 'P':
- if cpu_choice == 'Kamień':
- result = 'win'
- elif cpu_choice == 'Nożyce':
- result = 'lose'
- if player_choice == 'N':
- if cpu_choice == 'Kamień':
- result = 'lose'
- elif cpu_choice == 'Papier':
- result = 'win'
- wynik(result)
- def wynik(result):
- player_score = 0
- cpu_score = 0
- if result == 'tie':
- print('Remis.')
- elif result == 'lose':
- print('Przegrałeś')
- cpu_score += 1
- elif result == 'win':
- print('Wygrałeś')
- player_score += 1
- print('Komputer:',cpu_score, 'Gracz:', player_score)
- play_again()
- def play_again():
- play_again = input('Jeżeli chcesz zagrać ponownie napisz T, w przeciwnym razie napisz N: ')
- if play_again == 'T':
- print('**********************************************')
- start_game()
- elif play_again == 'N':
- sys.exit()
- start_game()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement