Question: Question 11- Loops : Odd or even Write a for loop that is going to check whether the values in the data_list are even or

Question 11- Loops : Odd or even Write a for loop that is going to check whether the values in the data_list are even or odd. Use a for loop with a conditional to do this. For each value, it should add True to a new list is_even if the value is even and False to is_even if the value is odd.

Question 12- loops : Multiple Conditions Write for a loop that will check each value in data_list to see if they are even or odd and whether they are positive or negative. - If they are both positive and even, encode this as the number 1 - If they are both negative and odd, encode this as the number -1. - otherwise encode this as the number 0 - store the result for each value into a list called num_ type
Logout e Edit View Insert Cell Kernel Widgets Help Trusted Run IC Markdown Validate Show Usage Q11 - Loops: Odd or Even (0.5 points) Write a for loop that is going to check whether the values in data_list are even or odd. Use a for loop with a conditional to do this. For each value, it should add True to a new list is even if the value is even, and False to is_even if the value is odd. In [ ]: # YOUR CODE HERE raise NotImplementedError() is_even In [ ]: Nassert isinstance(is_even, list) assert(len(is_even) len (data_list)) Q12 - Loops: Multiple Conditions (0.75 points) Write a for loop that will check each value in data_list to see if they are even or odd and whether they are positive or negative. If they are both positive and even, encode this as the number 1 If they are both negative and odd, encode this as the number - 1 Otherwise, encode this as the number 0 Store the result for each value into a list called num_type . In [ ]: # YOUR CODE HERE raise NotImplementedError() In [ ]: Nassert isinstance(num_type, list) assert(len(num_type) == len(data_list)) Example: Looping through Dictionaries
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
