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
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
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fd2e12e66-ebde-43c5-95e8-47b793663e86%2Ff73d0ead-28cd-4a14-a588-b734e7534d56%2Fisw1kcg_processed.jpeg&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
Introduction
Use an infinite loop to accept inputs inside the function and we are printing x and result only if input x is multiple of num or else we are just skipping that particular iteration
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education