Question: Step 1 : Write a function named checkCompany ( ) that takes a value named companyName when called and holds in the secret name of

Step 1: 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'[::-1]
if ( companyName == myCompany ) :
return True
Step 2: Write a function named gameStart () that starts the game with three attempts. (The value of 3 has been assigned to variable name attempts) Within the function, create a while-loop that checks if the attempts are not equal to zero. Within the while-loop, 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 =3
while ( attempts !=0) :
entry = input ( 'Name my favorite car company:')
result = checkCompany( entry )
Step 3: When the same block of the while-loop declaration is in Step 2, create an if-statement 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 1 attempt and display sorry, chances left and the value of attempts:
if ( result == True ) :
print ( 'Winner!')
break
else :
attempts = attempts 1
print ( 'Sorry, chances left:', attempts )
Step 4: Within the same block of the function declared in Step 2, create an if-statement that will check if the value of attempts is equal to zero which it will display to the player Uh-oh! Out of chances!
if ( attempts ==0) :
print ('Uh-oh! Out of chances!')
Step 5: 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 3 attempts to guess my favorite car company!')
print ( 'KGO!')
Step 6: 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 7: Now execute those previously declare functions by just calling on those function's name that was declared in Step 2,5, and 6 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!