Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The posted solution does not work 4.3 Repeating With Loops Fill in this code for

ID: 3916863 • Letter: T

Question

The posted solution does not work 4.3 Repeating With Loops Fill in this code for a program that loops through the numbers between 1 and 40. If a number is divisible by 3, print Hip. If the number is divisible by 7, print Hooray. Remember that there may be numbers that are divisible by both 3 and 7, so you'll have to print both messages for those. Fill in the Blanks-Fill in the blanks No, it's not. for number in range 1,40 if number 30 print( "Hip if number print "Hooray" Submit Start over (reset)

Explanation / Answer

Hi i have written the code in python as no proper language is mentioned. I think the code which i have written is self explaintory but still i'll summarize what i am doing. First i am iterating from 1 to 40 using range function in python. I have written range(1,41) because range function starts from the number present in left side and ends with -1 the number from right side. eg: range(start,end+1) as it will not include 41, it will run till 40. Now in the next steps i am first checking if the number is divisible by both 3 & 7 if it is true then it will print "Hip Hooray" otherwise it will go to the else part where it will first check if it is divisible by 3 then print "Hip" else it will check if it is divisible by 7 then print "Hooray"

Code:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote