Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

luckysumloginpy Python program to display the sum of lucky numbers between given two integers def lu... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions

Question

Compare and contrast licensing and subcontracting.

Answered: 1 week ago

Question

What mental processes allow you to perceive a lemon as yellow?

Answered: 1 week ago