ninjaducky04
ninjaducky04 ninjaducky04
  • 03-11-2019
  • Computers and Technology
contestada

Write a loop to print the numbers: 11, 21,...51 using Python

Respuesta :

SuperCatLover2000
SuperCatLover2000 SuperCatLover2000
  • 03-11-2019

In this series, we start off with 11 and then keep adding 10 to the each number and print it until we get 51.

The Code:

series = [11]

while series[-1] != 51:

series.append(series[-1] + 10 )

print(*[x for x in series],sep = ',')

We said while the last number of the list is not equal to 51, add 10 to the last number of the list.

'-1' index is for the last number.

So, if the last number of the list is 51, it breaks off and prints the elements in the list separated by a comma.

Answer:

11,21,31,41,51

Hope this helps! :)

Answer Link

Otras preguntas

Identify and explain the two determinants of “Money Demand”
What does M equal in m-5=-10.
Solve: 6x - 8 -2x = -16 * 1 point x = 2 x = 1 x = -2 x = -1
Block B has mass 6.00 kg and sits at rest on a horizontal, frictionless surface. Block A has mass 2.50 kg and sits at rest on top of block B. The coefficient of
Read and choose the correct option to complete the sentence. Elsa y Miquel bajaban por ________ lentamente. la cuerda la rayuela el tobogán el trompo
What is the slope of the line on the graph?
An electron with velocity v = 1.0 ´ 106 m/s is sent between the plates of a capacitor where the electric field is E = 500 V/m. If the distance the electron trav
what are the first three terms for n-4
I need help with the first one only just so I can understand the rest of them
How did the geography of Greece influence Greeks’ interaction with each other