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

suppose that your friend is moving far away and describing his new location. He mentioned that Derreck gets a lot of precipitation for most of the year, except
What is negative 8 minus negative 4?
Means that a material has spaces that allow water to seep through it?
1589➗84 simplify if possible
How does good experimental conclusion differ from an inference?
Parallel structure is achieved by _____. using the same number of words in each sentence element never using infinitive phrases using grammatically similar cons
If a carbon atom is bonded to two hydrogen atoms and two carbon atoms, what type of bond must exist between the carbon atoms?
where was roy wilkins born
In the story “The forbidden Fruit", what happens after Eve took a bite of the fruit after Adam told her not to?
Emotions are reactions triggered by events or thoughts.