Question: Step 1 : Write a function named checkCompany ( ) that takes a value named companyName when called and holds in the secret name of
Step : Write a function named checkCompany that takes a value named companyName when called and holds in the secret name of my favorite automobile company. Within the function, if the players guess is correct then return the value of True to the caller:
def checkCompany companyName :
myCompany 'inihgrobmal'::
if companyName myCompany :
return True
Step : Write a function named gameStart that starts the game with three attempts. The value of has been assigned to variable name attempts Within the function, create a whileloop that checks if the attempts are not equal to zero. Within the whileloop, ask the player to guess the company name in which their keyboard value will be stored in a variable called entry. Afterward, assign the previous function name to a variable named result that will pass the value of the entry to the function:
def gameStart :
attempts
while attempts :
entry input 'Name my favorite car company:
result checkCompany entry
Step : When the same block of the whileloop declaration is in Step create an ifstatement that checks if the variable results value is equal to True. If it is then display the words winner and break the loop; else, remove attempt and display sorry, chances left and the value of attempts:
if result True :
print 'Winner!
break
else :
attempts attempts
print 'Sorry, chances left: attempts
Step : Within the same block of the function declared in Step create an ifstatement that will check if the value of attempts is equal to zero which it will display to the player Uhoh Out of chances!
if attempts :
print Uhoh Out of chances!
Step : Create a new function named gameIntro that will simply display three greeting print statements to the player when called:
def gameIntro :
print 'Welcome to the guessing game!
print 'You will have attempts to guess my favorite car company!
print 'KGO!
Step : Create a single line function named gameEnd that will display a single line message towards the end of the game, regardless of the outcome:
def gameEnd :
print 'Thanks for playing the game!
Step : Now execute those previously declare functions by just calling on those function's name that was declared in Step and without passing any values to them:
gameIntro
gameStart
gameEnd
write this on python
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
