Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following function called call_superhero () takes no parameters and returns the string 'Spiderman' or 'Hulk'. def call_superhero () : if random. randint (0, 1)

image text in transcribed
The following function called call_superhero () takes no parameters and returns the string 'Spiderman' or 'Hulk'. def call_superhero () : if random. randint (0, 1) == 0: return 'Spiderman' return 'Hulk' Using the function call_superhero () provided above, write a program that: 1. Asks the user whether they would like to call a superhero ('y' or 'n'). 2. Continues to prompt for and call a superhero until the user enters the string 'n'. 3. Creates and builds a list containing the results of each call to function call superhero () (i.e. a list containing the strings 'Spiderman' and 'Hulk'). You may use method list . append () to add the strings 'Spiderman' and 'Hulk' to the list. 4. Counts how many times the user has called a superhero and displays this to the screen once the user enters 'n' as follows (e.g. if a superhero was called 20 times): Number of superheros called: 20 EX 2 3 4 5 & 8 W E R T Y U S D F G H K Z X C B N M

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

2 What is the difference between primary and secondary research?

Answered: 1 week ago