Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am really struggling with Computer Science. (I have 2 days for the assignment so just take your time.) 1. implement the function flip_sign(data_list, index),

image text in transcribed

I am really struggling with Computer Science.

(I have 2 days for the assignment so just take your time.)

1. implement the function flip_sign(data_list, index), which updates the provided list according to these rules: a. if the index is outside the boundaries of the provided list, print "Index out of bounds" and exit b. if the element at the given index is an integer, reverse the sign of the data found there (example: a 9 becomes -9, a-3 becomes 3) c. In all other cases do nothing at all Notice that this function neither prints nor returns a value. The provided data is altered during the test. Verification means examining the provided data after the test runs. Examples: >>> data = [1,2,3,4] >>> flip_sign (data, 1) >>> data [1, -2, 3, 4] >>> flip_sign (data, 7) Index out of bounds >>> data = [1, 2, 3.7, 4] >>> flip_sign (data, 2) >>> data [1, 2, 3.7, 4]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions