Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) Write in Python Programming a) Write a loop that replaces each number in a list named data with its square root if that number

1) Write in Python Programming

a) Write a loop that replaces each number in a list named data with its square root if that number is greater than or equal to zero. Otherwise, keep the number unchanged.

[0, 4 , -2, 9, -4, 16] [0, 2, -2, 3, -4, 4]

b) You have a shopping list of some items. You want to substitute one of the items with some other items.

Write a script that does that. For example:

Your old shopping list is: ['apple', 'pear', 'orange', 'grape']

Enter 3 new items: banana peach kiwi

Enter the item to be replaced: orange

New list: ['apple', 'pear', ['banana', 'peach', 'kiwi'], 'grape']

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

Database Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions