Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Online Systems For Physicians And Medical Professionals How To Use And Access Databases

Authors: Harley Bjelland

1st Edition

1878487442, 9781878487445

Students also viewed these Databases questions

Question

=+Have they changed the way employees view IP?

Answered: 1 week ago