ajarchiyeva ajarchiyeva
  • 16-12-2020
  • Computers and Technology
contestada

Write python code that outputs numbers that are perfectly divisible by 4 in the range 0-100.

Respuesta :

goodLizard
goodLizard goodLizard
  • 16-12-2020

Explanation:

I'm assuming that when you mean by range 0 - 100, it is inclusive (meaning 100 and 0 are included). If it isn't, change range(101) to range(1, 100).

Code:

for num in range(101):

   if num % 4 == 0:

       print(num)

The modulo operation '%' finds the remainder of the number being divided. For a number to be divisible by 4, the modulus of the number must be equal to 0 when divided by 4.

Hope this helps :)

Answer Link

Otras preguntas

Please answer this for me correctly. THANK YOU!!
Find the slope of the line
Which statement best contrasts roundworms and tapeworms? Roundworms are easier to prevent than tapeworms. Roundworms have stronger survival instincts than tapew
Factor the perfect square trinomial x2 − 12x + 36. A. (x − 6)2 B. (x − 6)(x + 6) C. (x + 6)2 D. (x − 12)2
A cargo ship with LBP 134 m floats at 4.6 m and 4.2 m draught at FP and AP respectively. The centre of flotation is 2 m fwd of amidships and MCTC is 120 tonnes.
Give the Shorthand Electron Configuration for the following elements: Nickel Group of answer choices [Kr] 3d8 4s2 [Ne] 3d6 4s2 [Ar] 3d8 4s2
what is 1 1/4 + 2/14
what does the y intercept of this graph​
15. Find the perimeter of the smaller figure given that the two figures are similar.
Solve each equation using the substitution method. 8t=56