Bryce H.

asked • 02/25/23

how to do this?

Create a new function in your functions.py script called getAnswer() that takes one numerical argument called answerNumber.

use the following code inside the new getAnswer() function:

if answerNumber == 1:
return 'It is certain'
elif answerNumber == 2:
return 'It is decidedly so'
elif answerNumber == 3:
return 'Yes'
elif answerNumber == 4:
return 'Reply hazy try again'
elif answerNumber == 5:
return 'Ask again later'
elif answerNumber == 6:
return 'Concentrate and ask again'
elif answerNumber == 7:
return 'My reply is no'
elif answerNumber == 8:
return 'Outlook not so good'
elif answerNumber == 9:
return 'Very doubtful'

In the ICE1.py script, use the random generator and generate a number between 1 and 9. Pass the number into the getAnswer() function and print out the users fortune.


2 Answers By Expert Tutors

By:

William M.

tutor
Note: requires Python 3.10 or better for the match: syntax As usual, Python has to call the switch statement (C, C++, Java, JavaScript, Swift, Objective-C) something completely different !
Report

05/31/23

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.