Question: Task WEEK 5 LAB Modify the Zodiac program: 1. Replace IF statements with a list 2. Add a loop the program will ask Would you

Task WEEK 5 LAB Modify the Zodiac program:

1. Replace IF statements with a list

2. Add a loop the program will ask Would you like to play again? Type Yes or No If a user types Yes, the program restarts If a user types No, the program quits

3. Add try/except statements to catch errors if a user enters string data instead of numeric

Zodiac program:

import random print('Try your luck, ask me a question') input() def getAnswer(answerNumber): if answerNumber == 1: return 'It is certain' elif answerNumber == 2: return 'It is decidedly so' elif answerNumber == 3: return 'Yes' elif answerNumber == 4: return 'Hazy. Try again' elif answerNumber == 5: return 'Ask again later' elif answerNumber == 6: return 'Concentrate and try again' elif answerNumber == 7: return 'My reply is No' elif answerNumber == 8: return 'Outlook is not so good' elif answerNumber == 9: return 'Very doubtful' r = random.randint(1,9) fortune = getAnswer(r) print(fortune)

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 Databases Questions!