Question: 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

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!