In: Computer Science
An experienced Python programmer in your company wants your assistance calculating the division of the numerator being the sum of all the multipliers of four divided by the denominator of all the multipliers of three using one for loop and one range statement respectively. Both sums of the numerator and denominator respectively are to be calculated using the same range of numbers between (and including) the number 0 and up to (and including) the number 100. The experienced Python programmer gives you a hint that the answer for the requested division is .77243. Please create the script that uses one for loop and will produce the expected output below. Your code must use a loop to receive credit.
Expect Output:
The sum of all multipliers of 4 is: 1300
The sum of all multipliers of 3 is: 1683
1300 divided by 1683 is 0.7724301841948901
#variable to store sum of multipliers of 4
four=0
#variable to store sum of multipliers of 3
three=0
#for each number from 0 to 100
for i in range(0,100+1):
#if i is divisible by 4
if i%4==0:
four+=i
#if i is divisible by 3
if i%3==0:
three+=i
#printing the output
print("The sum of all multipliers of 4 is: {}".format(four))
print("The sum of all multipliers of 3 is: {}".format(three))
print("{} divided by {} is {}".format(four, three, four/three))
The sum of all multipliers of 4 is: 1300 The sum of all multipliers of 3 is: 1683 1300 divided by 1683 is 0.7724301841948901
CODE and OUTPUT
So if you still have any doubt regarding this solution please feel free to ask it in the comment section below and if it is helpful then please upvote this solution, THANK YOU.