Write a Python program that prompts the user to input the size of a list and...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a Python program that prompts the user to input the size of a list and the integers to populate the list and print the list members one by one, the odd numbers in the list and the negative numbers by calling different functions. Your program should have the following requirements: (1) The program should have four functions: a. The get_numbers(size) function should prompt the user to input size integers, which should be stored in a list called my_list and return the list. b. The print_all_numbers(my_list) function should take a list of integers as an argument and print out all the numbers in the list. c. The print_odd_numbers(my_list) function should take a list of integers as an argument and print out all the odd numbers in the list. If there are no odd numbers in the list, it should print "No odd number in the list". d. The print negative_numbers(my_list) function should take a list of integers as an argument and print out all the negative numbers in the list. If there are no negative numbers in the list, it should print "No negative number in the list". (2) Outside the function, you do the following: a. Prompt the user to enter the size of the list (integer). This part is provided in the template file. b. Call the function get_numbers(size) with value entered by the user for size. This function will return the values the user entered as a list called my_list. c. Call the function print_all_numbers(my_list) with my_list as an argument. d. Call the function print_odd_numbers(my_list) with my_list as an argument. e. Call the function print_negative_numbers(my_list) with my_list as an argument. Write a Python program that prompts the user to input the size of a list and the integers to populate the list and print the list members one by one, the odd numbers in the list and the negative numbers by calling different functions. Your program should have the following requirements: (1) The program should have four functions: a. The get_numbers(size) function should prompt the user to input size integers, which should be stored in a list called my_list and return the list. b. The print_all_numbers(my_list) function should take a list of integers as an argument and print out all the numbers in the list. c. The print_odd_numbers(my_list) function should take a list of integers as an argument and print out all the odd numbers in the list. If there are no odd numbers in the list, it should print "No odd number in the list". d. The print negative_numbers(my_list) function should take a list of integers as an argument and print out all the negative numbers in the list. If there are no negative numbers in the list, it should print "No negative number in the list". (2) Outside the function, you do the following: a. Prompt the user to enter the size of the list (integer). This part is provided in the template file. b. Call the function get_numbers(size) with value entered by the user for size. This function will return the values the user entered as a list called my_list. c. Call the function print_all_numbers(my_list) with my_list as an argument. d. Call the function print_odd_numbers(my_list) with my_list as an argument. e. Call the function print_negative_numbers(my_list) with my_list as an argument.
Expert Answer:
Answer rating: 100% (QA)
Heres a Python program that meets your requirements Function to get user input and create a list def ... View the full answer
Related Book For
Introduction To Java Programming And Data Structures Comprehensive Version
ISBN: 9780136520238
12th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
Given a finite field F, let M2(F) denote the set of all 2 Ã 2 matrices with entries from F. As in Example 14.2, (M2(F), +, ¢) becomes a noncommutative ring with unity. a) Determine the...
-
Assessment Description This is a group presentation done face-to-face or online (through Big Blue Button on Moodle). In groups of four or five (to be selected by the lecturer), students will present...
-
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...
-
Describe two methods for determining the molecular mass of a polypeptide. Which is more accurate and why?
-
In a certain town, citizens' groups have identified three intersections as potentially dangerous. They collected the following data. For each intersection, find the probability that a vehicle...
-
Select the correct answer for each of the following questions. 1. On January 1, 20X7, the partners of Casey, Dithers, and Edwards, who share profits and losses in the ratio of 5:3:2, decided to...
-
What is a system property?
-
Robert Perez is a contractor specializing in custom-built jacuzzis. On May 1, 2012, his ledger contains the following data. Raw Materials Inventory ....... $30,000 Work in Process Inventory ..........
-
When is government censorship considered constitutional in the United States? What legal restraints can be used in the U.S. to silence political dissent? What forms of sedition have been historically...
-
On July 31, 2019, Ping Company purchased 90% of Santos Company?s common stock for $2,010,000 cash. Immediately after the acquisition, the two companies? balance sheets were as follows: Santos Company...
-
Sales during the year were 1,020 units. Beginning inventory was 330 units at a cost of $5 per unit. Purchase 1 was 510 units at $6 per unit. Purchase 2 was 790 units at $7 per unit. Required: a....
-
What are the major components of the income statement?
-
Suppose college students are given two options. With option A, the price a student pays for a class is always the equilibrium price. For example, if the equilibrium price to take Economics 101 is...
-
In the absorption of ammonia into water from an air-ammonia mixture at 300 K 300 K and 1 a t m 1 a t m , the individual film coefficients were estimated to be k L = 6.3 c m / h k L = 6.3 c m / h and...
-
A flue gas flows at the rate of 10 k m o l / s 10 k m o l / s at 298 K 298 K and 1 a t m 1 a t m with a S O 2 S O 2 content of 0.15 m o l % 0.15 m o l % . Ninety percent of the sulfur dioxide is to...
-
Create a flow sheet analog to VLE or LLE calculations to find the melting temperature and liquid phase composition for a given solid mixture composition for the following. (a) Ideal solutions of...
-
A farmer harvested 21 fewer bushels of sweet corn this year than the previous year. If the farmer's sweet corn crop is planted across 3 acres, what is the average loss per acre?
-
How many years will it take a $700 balance to grow into $900 in an account earning 5%?
-
Write a program that displays two eyes in an oval, as shown in Figure 31.49c. Exercise31 06 (c)
-
Write a program that plots the log function, as shown in Figure 31.51a. Exercise31_10 (a)
-
Write a Java servlet for Exercise 33.1, as shown in Figure 37.34. Data from Exercise 33.1, Write a server for a client. The client sends loan information (annual interest rate, number of years, and...
-
A diesel engine of mass \(300 \mathrm{~kg}\) and operating speed \(1800 \mathrm{rpm}\) is found to have a rotating unbalance of \(1 \mathrm{~kg}-\mathrm{m}\). It is to be installed on the floor of an...
-
A sensitive electronic system, of mass \(30 \mathrm{~kg}\), is supported by a spring-damper system on the floor of a building that is subject to a harmonic motion in the frequency range \(10...
-
A machine of mass \(1150 \mathrm{~kg}\) is mounted on springs. A piston of mass \(m=25 \mathrm{~kg}\) moves up and down in the machine at a speed of \(600 \mathrm{rpm}\) with a stroke of \(350...
Study smarter with the SolutionInn App