1234567891011121314151617181920212223242526272829303132333435363738394041 |
- # Copyright (C) 2020, 2019 Girish M
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation; either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- # MA 02110-1301, USA.
- #
- import random
- choice = 'y'
- player_score = 0
- comp_score = 0
- while choice in ['y', 'Y', 'Yes']:
- p = random.choice([1,2,3,4,5,6,7,8,9,10])
- print(p, '- player')
- c = random.choice([1,2,3,4,5,6,7,8,9,10])
- print(c, '- computer')
- if p > c:
- print ("player wins! ")
- player_score += 1
- elif p < c:
- print("computer wins!")
- comp_score += 1
- else:
- print ("It's a tie! no one gets a point.")
- print("Your score so far is: ", player_score)
- print("Computer's score so far is: ", comp_score)
- choice = input("Would you like to play again('y' or 'n')?: ")
- print("Your score is: ", player_score)
- print("Computer score is: ", comp_score)
|