You are on page 1of 2

1/16/23, 9:23 AM Assignment 2.

ipynb - Colaboratory

For your second assignment, you should use a loop to iterate through the tuple numbers . For each
of the numbers, you should perform up to 3 operations:

1. If it exists in the add_one set, add one to the number.


2. If it exists in the double set, double the number.
3. If it exists in the negate set, negate the number (i.e., if it's -17 make it 17, and if it's 11 make it
-11).

After these operations are performed, append the number to output_list . When the loop is
finished, print output_list .

hint: your resulting list should be [-25, 16, 21, 14, 6, 0, 23, -2, 24, 2, -18, 24, 2, 14, -22, -4, 22]

numbers = (-25, -16, 21, 14, 6, -1, 23, -2, -24, 2, -18, 24, 1, 7, -22, -5, 22)

add_one = set([-1, -12, 10, -5, 25])
double = set([1, 12, 0, 7, 17])
negate = set([-24, -16, -3, 12, 15])

output_list = []

https://colab.research.google.com/drive/1S9dTMk7P2GRIwBo89LPEIsCn110cX2CL?usp=sharing#scrollTo=0WT91pfsvS68&printMode=true 1/2
1/16/23, 9:23 AM Assignment 2.ipynb - Colaboratory

Colab paid products


-
Cancel contracts here

https://colab.research.google.com/drive/1S9dTMk7P2GRIwBo89LPEIsCn110cX2CL?usp=sharing#scrollTo=0WT91pfsvS68&printMode=true 2/2

You might also like