victoriamoss5898 victoriamoss5898
  • 20-08-2019
  • Computers and Technology
contestada

for number in range(1,51): if number % 3 == 0 and number % 5 == 0: print('XY') elif number % 5 == 0: print('X') elif number % 3 == 0: print('Y')

Respuesta :

Mustela Mustela
  • 24-08-2019

Output of the given code is:

Y

X

Y

Y

X

Y

XY

Y

X

Y

Y

X

Y

XY

Y

X

Y

Y

X

Y

XY

Y

X

Explanation:

In the for loop variable "number" will iterate from 1 to 150(inclusive).

in the "if" condition it is checking that the number is divisible by 3 and 5 both if the number is divisible by both 3 & 5 then it will print XY as output.

In the first "elif", if the number is divisible by 5 only then it will print X

as output.And in the last "elif", if number is divisible by 3 only then it will

print Y as output. Nothing will be printed if all three conditions are FALSE.

Answer Link

Otras preguntas

Situation: Find the age of the skull to the nearest year, Enter the correct answer. A hiker in Africa discovers a skull that contains 32% of its original amount
A die is rolled what is the probability of scoring 4?​
What is the slope of -4, 2 and 3,9
What is the measure of AC? Enter your answer in the box. (4x - 5.5) (5x+25)
What are the solutions to x^2 + 4x - 12 = 0?
Sperm pass through the ______ and connect to a short ejaculatory duct. vas deferens prostrates seminiferous tubules none of the above
solve for x in the diagrams above.
Fats are the most concentrated form of _____.
Which advanced technology helps healthcare professionals monitor patients who have degenerative diseases?
Mens' heights are normally distributed with u 68 in and o 6 in. Womens' heights have u 65 in with o 4 in. Dan is 70 in tall and Amy is 68 in tall. Who is relati