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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started