Write a function named pi_multiples() that takes an integer parameter num. This function repeatedly asks the user to enter an integer between 2 and 50. Assume the user will always enter an integer, but if the number must end. So, for any integer x entered within the range, your function must do the following: if x is divisible by num (the parameter), it must multiply x by the value of pi (call it result) and maintain a sum of these results. In every iteration of the loop your function must print x and the result. And when the loop terminates your function should return the sum. outside this range, the loop

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.2: Returning A Single Value
Problem 13E
icon
Related questions
Question
Chrome Capture 767x397
Create a python program called code.py.
Write a function named pi_multiples() that takes an integer parameter num. This
function repeatedly asks the user to enter an integer between 2 and 50. Assume the
user will always enter an integer, but if the number is outside this range, the loop
must end. So, for any integer x entered within the range, your function must do the
following; if x is divisible by num (the parameter), it must multiply x by the value of pi
(call it result) and maintain a sum of these results. In every iteration of the loop your
function must print x and the result. And when the loop terminates your function
should return the sum.
To test your function, call pi_multiples() function using any integer number of your
choice (for num) and print the returned value.
Hint: to use the pi value do the following
import math and use math.pi for the value of pi.
frames: 0
0/ 10 secs
Zip your file, name it code.zip, and submit it using the link available in this question.
Transcribed Image Text:Chrome Capture 767x397 Create a python program called code.py. Write a function named pi_multiples() that takes an integer parameter num. This function repeatedly asks the user to enter an integer between 2 and 50. Assume the user will always enter an integer, but if the number is outside this range, the loop must end. So, for any integer x entered within the range, your function must do the following; if x is divisible by num (the parameter), it must multiply x by the value of pi (call it result) and maintain a sum of these results. In every iteration of the loop your function must print x and the result. And when the loop terminates your function should return the sum. To test your function, call pi_multiples() function using any integer number of your choice (for num) and print the returned value. Hint: to use the pi value do the following import math and use math.pi for the value of pi. frames: 0 0/ 10 secs Zip your file, name it code.zip, and submit it using the link available in this question.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,