In: Computer Science
Python3
Write a program to implement the Pokemon game should ask the user to enter their type and compare it with a randomly chosen computer type and correctly display who wins/ties.
Thanks for the question. Below is the code you will be needing Let me know if you have any doubts or if you need anything to change. Thank You !! ===========================================================================
import random def getComputerChoice(): choices=['Fire','Grass','Water'] return random.choice(choices) def getWinner(userChoice, computerChoice): userChoice=userChoice.title() if userChoice==computerChoice: return 'Its a Draw!' if userChoice=='Fire' and computerChoice=='Grass': return 'You win!' if userChoice=='Grass' and computerChoice=='Water': return 'You win!' if userChoice=='Water' and computerChoice=='Fire': return 'You win!' if computerChoice=='Fire' and userChoice=='Grass': return 'Computer wins!' if computerChoice=='Grass' and userChoice=='Water': return 'Computer wins!' if computerChoice=='Water' and userChoice=='Fire': return 'Computer wins!' return 'Invalid Selection!' def main(): print('Welcome to Pokemon Game') user = input('Enter a type (fire/grass/water): ') computer=getComputerChoice() print('You choose: {} Computer choose: {}'.format(user.title(),computer)) winner = getWinner(user,computer) print(winner) main()
=========================================================================== Thank you so much ! Please do appreciate with an up vote : )