Question: Write a program that converts a given list into a list with binary values: either 1 or 0. If the number in the initial list

Write a program that converts a given list into a list with binary values: either 1 or 0. If the number in the initial list was greater than 0, in the binary list there should be 1, and if the number was less or equal, in the new list you should write 0. Naturally, use the list comprehension and print the result.

Given list: a list with integer numbers, e.g. [5, 0, 4, -10].

Output list: a list consisting of ones and zeros, e.g. [1, 0, 1, 0].

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!