create a program without using loops Sometimes our program might get some data that we'd like...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
create a program without using loops Sometimes our program might get some data that we'd like to sort into multiple categories. In this problem, you will determine if some input numbers are even or odd, and sort them into lists of the 2 categories. Your program, even odd.py should create 2 empty lists named evens and odds. It should prompt the user to enter 2 numbers. For each of the numbers, it should determine whether the number is even or odd, and place the number into the appropriate list. It should also print out a message for each number, either: NUMBER is odd. NUMBER is even. For example: >>> %Run even odd.py Enter a number: 37 Enter a number: 12 37 is odd. 12 is even. Your program should not use loops. Note #1: A integer n is even if n % 2 == 0. It is odd if n % 2 == 1. Note #2: The word "sort" can have two distinct meanings. We can sort items into categories, as in "I sorted my white socks into one drawer and my dark socks into another." Sorting can also describe the process of rearranging a sequence of items into a desired order, as in: "These names need to be sorted alphabetically." This question uses the first meaning of sort: to place into categories. create a program without using loops Sometimes our program might get some data that we'd like to sort into multiple categories. In this problem, you will determine if some input numbers are even or odd, and sort them into lists of the 2 categories. Your program, even odd.py should create 2 empty lists named evens and odds. It should prompt the user to enter 2 numbers. For each of the numbers, it should determine whether the number is even or odd, and place the number into the appropriate list. It should also print out a message for each number, either: NUMBER is odd. NUMBER is even. For example: >>> %Run even odd.py Enter a number: 37 Enter a number: 12 37 is odd. 12 is even. Your program should not use loops. Note #1: A integer n is even if n % 2 == 0. It is odd if n % 2 == 1. Note #2: The word "sort" can have two distinct meanings. We can sort items into categories, as in "I sorted my white socks into one drawer and my dark socks into another." Sorting can also describe the process of rearranging a sequence of items into a desired order, as in: "These names need to be sorted alphabetically." This question uses the first meaning of sort: to place into categories.
Expert Answer:
Answer rating: 100% (QA)
You can achieve the desired functionality in Python without using loops by using recursive functions ... View the full answer
Related Book For
Principles Of Information Security
ISBN: 9780357506431
7th Edition
Authors: Michael E. Whitman, Herbert J. Mattord
Posted Date:
Students also viewed these programming questions
-
A complex pair of eigenvalues are shown on the s-plane below. For this pair of eigenvalues, Wn ? W = ? damping ratio = ? time constant = ? X 2 -1 0 X -2 If r(t) is a step with magnitude 10, Use...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Battleship is a guessing game for two players. The objective of the game is to destroy the opposing player's entire fleet. It is played on four 10 x 10 grids. Two grids (one for each player) are used...
-
3. Given the recurrence relation: Calculate T(n) for n= 1.2.3.4.5. 12 T(n) T(n)= 3T ([n/2])+ 2m +1 T(0) 0 1 2 3 4 5 [10 pts
-
If an X-ray photon is scattered by an electron, does its wavelength change? If so, does it increase or decrease?
-
Diksha and Padmaja are in partnership. Their financial year ends on 31 July. Their partnership agreement provides for: Interest on capital at 4% per annum An annual salary of $4,000 for Padmaja ...
-
Describe the various legal risks for nurses.
-
a. From Williss point of view, is litigation or ADR preferred? Why? b. From Telwedas point of view, is litigation or ADR preferred? Why? c. Which form of ADR could be preferred by the two companies?...
-
Reflective essay on international business trends. It is important that social, political, legal, cultural factors, production factors and their movement across borders, globalization, government...
-
In this lab we will be investigating the relationship between the height of a roller coaster and its speed. Suppose we are interested in the question; Does the height of the roller coaster relate to...
-
Swati Limited is intending to issue its securities on a private placement basis. Explain to the directors of the company, the provisions of the Companies Act, 2013, on the following matters: i) the...
-
What is the definition of control for purposes of a Type B reorganization?
-
When is a trust required to file a federal income tax return? What tax form is used for a trust's federal income tax return?
-
How is the E&P account affected in a redemption?
-
What is the reason that some taxpayers are not entitled to the standard deduction or are entitled to only part of it? Explain.
-
Distinguish between compensation and gifts and identify the tax consequence associated with each.
-
Calculate qualified business income. Chanelle owns Chamber Networks (EIN 74-1234567), a cash-basis sole proprietorship that does network consulting. The business premises are located at 2301 Walden...
-
An access route is being constructed across a field (Figure Q8). Apart from a relatively firm strip of ground alongside the field's longer side AB, the ground is generally marshy. The route can...
-
Emphasize that an attack is a deliberate act that exploits a vulnerability to compromise a controlled system. This attack can consist of specially crafted software that attackers trick users into...
-
Which of the following is a primary responsibility of the CPMT? a. Conducting a building walk-through during an emergency b. Securing financing so that physical infrastructure can be immediately...
-
True or False: In most organizations, the security analyst position is one that is a senior-level position that requires numerous years of experience and certifications.
-
Assume the same facts as in Problem 42. Further assume that next year, Gary sells the SUV for $20,000. a. How much depreciation expense can Gary deduct as a business deduction with respect to the SUV...
-
Describe how liabilities are reported and analyzed.
-
Assume the same facts as in Problem 29, except that Sally has AGI of \($75,000.\) What is her qualified student loan interest deduction in 2019? Problem 29, In 2019, Sally Morris, a single taxpayer,...
Study smarter with the SolutionInn App