Question: Implement a Python function called count_pos that takes a list of numbers as an input parameter and returns the num- ber of elements of that

 Implement a Python function called count_pos that takes a list of

Implement a Python function called count_pos that takes a list of numbers as an input parameter and returns the num- ber of elements of that list that are positive (i.e. > 0). Then, in the ma in, your program should ask the user to input the list, then it should call count_pos function with that list, and print the result. In this question you may assume that the user will follow your instructions and enter a sequence of numbers separated by spaces. You can use str method .strip and .split to handle the user input. Here is a way to ask a user for a list: raw-input = input ("Please inpu t a list of numbers separated by space : ").strip() . split() But now raw-input is a list of strings that look like numbers so you need to create a new list that is a list of equivalent numbers. Three examples of program runs: Please input a list of numbers separated by space: 2 3.5-1-100 There are 2 positive numbers in your list Please input a list of numbers separated by space: 1 0 2201 There are 3 positive numbers in your list Please input a list of numbers separated by space: There are 0 positive numbers in your list Function call example: >countpos( 11, 0, 22.2, 0, 1.0, -10.51

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!