Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function called madLib that takes in a string and a dictionary. The input dictionary will have keys that are integers and data values

image text in transcribed
image text in transcribed
Write a function called madLib that takes in a string and a dictionary. The input dictionary will have keys that are integers and data values that are strings Your function should replace the word in the original string at each key value with the data for that key value. Your function should return an updated string. 3. Ex: inputString - "Ilike chocolate milk inputDictionary # {0:"we", 3:"cookies") Should return the string "we like chocolate cookies You may find the split() and str) functions for strings and lists to be useful NSY 3010-Fall 2018 Homework #4 Due: 8am, Sept 18 Write a function called multiplyNumbersByAConstant that takes in a list of numbers and a single scalar (these can all be integers or floating point numbers) Using a single list comprehension, make a new list that has the input scalar (number) added to each term in the original list. Your code should return the modified list 4. Ex: For inputist 1,2,3] and scalar 3, the list you would return is [3,6,9

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

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

ISBN: 1583474013, 978-1583474013

More Books

Students also viewed these Databases questions

Question

What is the FOMC directive? Describe its major components.

Answered: 1 week ago

Question

3. What can be done about it?

Answered: 1 week ago