Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How do you write this in Python? Write a function called is_positive_or_multiple_of_7 that takes a positive integer n as its parameter. Write a while loop

How do you write this in Python?

image text in transcribed

Write a function called is_positive_or_multiple_of_7 that takes a positive integer n as its parameter. Write a while loop in this function that ends if the number n is a multiple of 7. Otherwise we repeatedly subtract n by 3, as long as the number n is positive. Your function returns the final value of n. For example, if the parameter is given as n=100 , then . your while loop will start because n is positive. As 100 is not a multiple of 7, n becomes 100-3=97 and the next iteration runs. Again, since 97 is not a multiple of 7, it will be reduced to 94. In the next iteration, 94 is not a multiple of 7 yet, so n becomes 94-3=91, and your program goes to the next iteration. Finally, 91 =7*13 is a multiple of 7, which makes the break statement to end the loop, and your function returns 91. Sample Input 1: 100 Sample Output 1: 91

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Accounting And Auditing Research And Databases Practitioner's Desk Reference

Authors: Thomas R. Weirich, Natalie Tatiana Churyk, Thomas C. Pearson

1st Edition

1118334426, 978-1118334423

More Books

Students also viewed these Databases questions

Question

What is expectancy theory?

Answered: 1 week ago

Question

Establish identity. 1 + sin v 2 sec v 1 + sin v cos v

Answered: 1 week ago