Write a function named lucky_sum that accepts two integer values as arguments. The function should calculate...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a function named lucky_sum that accepts two integer values as arguments. The function should calculate and return the sum of the "lucky numbers" which are all of the numbers from the smallest argument to the largest argument that are not divisible by 3. For example, if the numbers 6 and 13 are passed as arguments to the function, your function should sum the numbers 7, 8, 10, 11, and 13, and then return the result. Finally, complete the template's main function so that the program prompts the user to enter two integer values, calculates the lucky sum using your lucky_sum function, and displays the returned value. Notes • The arguments can be given in either order. • The arguments should be included in the sum if they are not divisible by three. • The function should not print anything. Keep all printing in the main function. Test your program with the data in Table 1. Finally, format your program to match the sample terminal. Your output should exactly match the sample output, character for charac- ter, including all white space and punctuation. User input in the sample has been highlighted in Pappy's Purple to distinguish it from the program's output, but your user input does not need to be colored. Save your program as lucky_sum_login.py, where login is your Purdue login. Then submit it along with a screenshot showing a run of all 3 of the test cases. Input Output Lucky Sum First 109 1,559, 964 57 495 -11 -101 -3, 431 Table 1: Lucky Sum test data. Second 2165 42 Terminal $ python lucky_sum_login.py Enter the first integer: 109 Enter the second integer: 2165 The sum of the lucky numbers is 1,559,964. Write a function named lucky_sum that accepts two integer values as arguments. The function should calculate and return the sum of the "lucky numbers" which are all of the numbers from the smallest argument to the largest argument that are not divisible by 3. For example, if the numbers 6 and 13 are passed as arguments to the function, your function should sum the numbers 7, 8, 10, 11, and 13, and then return the result. Finally, complete the template's main function so that the program prompts the user to enter two integer values, calculates the lucky sum using your lucky_sum function, and displays the returned value. Notes • The arguments can be given in either order. • The arguments should be included in the sum if they are not divisible by three. • The function should not print anything. Keep all printing in the main function. Test your program with the data in Table 1. Finally, format your program to match the sample terminal. Your output should exactly match the sample output, character for charac- ter, including all white space and punctuation. User input in the sample has been highlighted in Pappy's Purple to distinguish it from the program's output, but your user input does not need to be colored. Save your program as lucky_sum_login.py, where login is your Purdue login. Then submit it along with a screenshot showing a run of all 3 of the test cases. Input Output Lucky Sum First 109 1,559, 964 57 495 -11 -101 -3, 431 Table 1: Lucky Sum test data. Second 2165 42 Terminal $ python lucky_sum_login.py Enter the first integer: 109 Enter the second integer: 2165 The sum of the lucky numbers is 1,559,964.
Expert Answer:
Answer rating: 100% (QA)
luckysumloginpy Python program to display the sum of lucky numbers between given two integers def lu... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
RSC , Inc. has been a member of the Better Business Bureau for five years. In the past year, RSC has had a number of customer complaints that it has not addressed. In response, what can the BBB do ?
-
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...
-
Using result (8.9), find f(x) when f (x) is (a) x (b) 1/x 5 (c) 1 3x
-
Knowing that P = 25 N and Q = 55 N, determine the components of the forces exerted (a) On member BCDF at C and D, (b) On member ACEG at E. 40 mm B. -150 mu- 150 mm- 100 mm
-
Find and sketch the domain of the function. g(x, y) = ln(x 2 + y 2 9)
-
Continuing Question 5, turn off the lag filter and use a notch filter to improve the performance. Simultaneously adjust Notch Freq and KVP to maximize KVP without inducing peaking in the closed-loop...
-
The supply curve for product X is given by Qsx = - 520 + 20Px. a. Find the inverse supply curve. b. How much surplus do producers receive when Qx = 400? When Qx = 1,200?
-
1. Types of Spectra a. A cool cloud of Helium absorbs light from some nearby stars. You view only the light given off by the cloud, not any stars. Draw the plot that you expect your instruments to...
-
La-Z-Boy Incorporated included the following information in its 2009 annual report (dollars in millions). Define solvency and discuss how this information might be useful in assessing the company??s...
-
Ingrid (43) and Daniel (48) are married but have lived apart since March 15, 2020. They have no divorce decree or separate maintenance agreement. They are both U.S. citizens and have valid social...
-
A single 1-oz serving of tortilla chips contains 260.0 mg of sodium. If an individual ate the entire 15-oz bag, how many grams of sodium would he ingest? If the recommended daily intake of sodium is...
-
Compare the persistence in the export of opium to China and the persistence of the export of opium and its derivatives into the USA.
-
Would an agreement with Interstate by a single distributor on its own be profitable it or risky? Does the answer suggest agreement among distributors?
-
Leaders possess many good and bad traits. List 3 good traits leaders should possess and 3 bad traits leaders should avoid. Explain why you have selected these good and bad traits. Please explain in...
-
For this discussion, you will be able to research online for news articles related to social media misuse. Find an article about social media misuse and write a one-paragraph summary. In your...
-
Comment on the water transport system in sponges. In what ways this system useful to the organism?
-
Compare and contrast licensing and subcontracting.
-
Implement your base class for the hierarchy from the previous exercise. Previous exercise. Consider a program that will keep track of the items in a schools library. Draw a class hierarchy, including...
-
Write a program in a class NumberAboveAverage that counts the number of days that the temperature is above average. Read ten temperatures from the keyboard and place them in an array. Compute the...
-
Suppose that we want to store digitized audio information in a binary file. An audio signal typically does not change much from one sample to the next. In this case, less memory is used if we record...
-
Draw a demand and supply graph for the federal funds market to show the demand and supply of reserves in the current ample-reserves regime. How can the Fed increase the federal funds rate? Show the...
-
What is the zero lower bound in monetary policy? What tools can the Fed use if it wants to implement an expansionary monetary policy at the zero lower bound?
-
How did the Fed hit its target for the federal funds rate in the pre-2008 scarce-reserves regime?
Study smarter with the SolutionInn App