Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

program language: python 3. Purpose To write a function that accepts input from the user, performs a task and returns an answer Degree of Difficulty:

program language: python 3.

image text in transcribed

Purpose To write a function that accepts input from the user, performs a task and returns an answer Degree of Difficulty: Easy In assignment 1, you created your veryfirst Mad Lib. Recall that a Mad Lib is a word game that usesphrases, whereoneplayer prompts others for a list of words to substitute for blanksinastory. You are going to create another one to practice writing functions and using arguments and return values. Your task is to write a Python function named mad_lib which takes three parameters as input and returns your story. Two of the parameters should be integers and the third should be a string. Ask the user to input values for each of the function arguments from the console. The input text from the console MUST happen OUTSIDE of the mad_lib function, and themad lib function should return a single string that makes up the ENTIRE story. You may assume that the user supplies valid input. Call the mad_lib function with the arguments you read from the console and output its return value to the console. Your story, the output of your function, should include the following . The string argument . The length of the string argument The first integer argument . The second integer argument converted to float Include an appropriate docstring which states the function's purpose. parameters), and return valuels Sample Run Here is an example of how your program's console output might look. Green text was entered by the user, blue text came from data returned by the mad_lib function Enter an integer: 15 And another integer: 72 What is your favorite Pokemon characker: Pikachu Pikachu is a friendly rodent that veighs 72.0kg. It has 7 siblings and its birthday is in 15 days In the example above, the second integer argument, 72, was converted to a floating point value 72.0 in the output displayed on the console, while 7 represents the length of the string argument, Pikachu What to Hand In Hand in your solution in a file called a2q2.py Evaluation 4 marks for correct function header (name and parameters) 1 mark for reading inputs from the console 1 mark for appropriate doscstring 4 marks for correct return value printed on the console (as described above)

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

MFDBS 89 2nd Symposium On Mathematical Fundamentals Of Database Systems Visegrad Hungary June 26 30 1989 Proceedings

Authors: Janos Demetrovics ,Bernhard Thalheim

1989th Edition

3540512519, 978-3540512516

More Books

Students also viewed these Databases questions

Question

e. Compute P(0.25 Answered: 1 week ago

Answered: 1 week ago

Question

3. Evaluate your listeners and tailor your speech to them

Answered: 1 week ago