Question: Write a Python program which has two functions: main function and count function. (1) The count function has one parameter my_list (a list object).

Write a Python program which has two functions: main function and count function.   (1) The count function

Write a Python program which has two functions: main function and count function. (1) The count function has one parameter my_list (a list object). It counts how many elements in parameter my_list are positive numbers. This amount will be returned. (2) The main function firstly creates a list and initializes it with the following numbers: 3, 6, 7, -2, 5, 2, 9, -1, 8, -4, 1. Then, it calls the count function to obtain the amount of positive elements. The returned value will be printed in the main function. (3) execute the program by calling the main function. Write a Python program which has two functions: main function and count function. (1) The count function has one parameter my_list (a list object). It counts how many elements in parameter my_list are positive numbers. This amount will be returned. (2) The main function firstly creates a list and initializes it with the following numbers: 3, 6, 7, -2, 5, 2, 9, -1, 8, -4, 1. Then, it calls the count function to obtain the amount of positive elements. The returned value will be printed in the main function. (3) execute the program by calling the main function.

Step by Step Solution

3.46 Rating (149 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

def countmylist Counts how many elements in a list object are positive numbe... View full answer

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 Programming Questions!