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
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
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

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education