Write a Python program which has two functions: main function and count function. (1)...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Answer rating: 100% (QA)
def countmylist Counts how many elements in a list object are positive numbe... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Now think about your general communication and interactions with the child during each day: Did the child ask you for assistance during the day? How did you respond? Provide an example of how you...
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
What would you suggest to be done and which principles are important to you in this decision? How would you think about the greatest good in this case? As a leader what are your duties and who are...
-
The following matrix is row-equivalent to the augmented matrix of a linear system. Describe the solution set of that system. 1 0 1 5 0000 0013 0000 Find all possible values of a for which the...
-
A used piece of rental equipment has 212 years of useful life remaining. When rented, the equipment brings in $800 per month (paid at the beginning of the month). If the equipment is sold now and...
-
Milan purchased saffron extract, marketed as Americas Hottest New Way to a Flat Belly, online from Dr. Chen. The Web site stated that recently published studies showed a significant weight loss (more...
-
Demonstrate how EVA calculations are made.
-
Tri-State Bank and Trust is considering giving Wilfred Company a loan. Before doing so, management decides that further discussions with Wilfreds accountant may be desirable. One area of particular...
-
Assume ABBA uses the FIFO method of valuing inventory within a Periodic Inventory System. Record Journal Entries for the Purchases and sales of inventory using the Periodic Inventory System....
-
Assuming the data are normal, what is the probability the blade weights from this process will exceed 5.20? What is the probability that weights will be less than 4.80? What is the actual percent of...
-
A local company imports a shipment, the companys Chief Executive Officer is importing a Cross-Wagon motor vehicle he claims for personal use, which exceeds 1500cc but does not exceed 2000cc. The...
-
In the infinitesimal neighborhood surrounding a point in an inviscid flow, the small change in pressure, \(d p\), that corresponds to a small change in velocity, \(d V\), is given by the differential...
-
Self-employed workers in the United States must pay Social Security taxes equal to 12.4% of any income up to \($118,500\) in 2015. This income level of \($118,500\) is known as the cap. Income in...
-
Suppose that the production function is Y = 9K 0.5 N 0.5. With this production function, the marginal product of labor is MPN = 4.5K 0.5 N -0.5 . The capital stock is K = 25 The labor supply curve is...
-
How strong must an electric field in a metal be in order for electrons in the field to have a drift speed of \(10 \mathrm{~mm} / \mathrm{s}\) if the time interval between electron-ion collisions is...
-
Air enters a pipe $(f=0.02)$ of diameter $0.05 \mathrm{~m}$ with stagnation pressure and temperature equal to $1 \mathrm{MPa}$ and $300 \mathrm{~K}$, respectively. The pipe exhausts into the ambient...
-
Meghann went on a hiking adventure, which she finished at a height of 5,000 feet above sea level. At the beginning, she was 5,000 feet above sea level. Which number accurately captures Meghann's...
-
What are the four types of poultry production systems? Explain each type.
-
Here are some class declarations: // emp.h -- header file for abstr_emp class and children #include #include class abstr_emp { private: std::string fname; // abstr_emp's first name std::string lname;...
-
Enhance the String class declaration (that is, upgrade string1.h to string2.h) by doing the following: a. Overload the + operator to allow you to join two strings into one. b. Provide a stringlow()...
-
Write a program that has main() call a user-defined function that takes a distance in light years as an argument and then returns the distance in astronomical units. The program should request the...
-
The \(x\) component of a car's velocity increases from 0 to \(+5.0 \mathrm{~m} / \mathrm{s}\) in \(1.0 \mathrm{~s}\), and then from \(+5.0 \mathrm{~m} / \mathrm{s}\) to \(+10 \mathrm{~m} /...
-
Describe how to determine the \(x\) component of the position of an object at a specific instant, given (a) a graph of position \(x\) as a function of time \(t\) and (b) an equation for \(x(t)\).
-
In an \(x(t)\) curve, what is the significance of a steep slope as opposed to a gentle slope? What is the significance of a curve that slopes downward as you move from left to right along the time...
Study smarter with the SolutionInn App