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

The circle shown here has area πr2. If its radius is tripled in length its new area will be
What effect has the Greco-Roman legal tradition had on civilizations since the fall of the Roman Empire?
PLEASE HELP, WILL MARK BRAINLIEST
solve this equation using the radical equation method
FICA deductions consist of
n the picture of a planet in orbit around its star area a is double that of area b. What is true of the time the planet takes to travel A1A2 as compared to B1B2
How much did it cost to apply for a cb license back in the 70s?
In the school election, votes were cast for sam, mary, and bill in the ratio of 4:3:2. if a total of 2178 votes were cast, how many votes did mary receive?
A major architectural development that appeared in roman architecture was the
what was the name of the original Cambodian empire