Print out the value and double it (multiply by 2). Continue printing and doubling (all on the same line, separated by one space each) as long as the current number is less than 1000, or until 8 numbers have been printed on the line.

Respuesta :

Answer:

value=int(input("Enter the value from where the user wants to starts: "))#Take the value from the user.

i=1#intialize the value of a variable by 1.

while(value<1000) and (i<9):#while loop which prints the value.

   print(value,end=" ")# print the value.

   value=value*2#calculate the value to print.

   i=i+1#calculate the value for the count.

Output:

If the user enter 5, then the output is : "5 10 20 40 80 160 320 640".

If the user enter 5, then the output is : "3 6 12 24 48 96 192 384".

Explanation:

  • The above code is in python language, in which the first line of the program is used to render a message to the user, take the input from the user and store it into value variable after converting it into an integer.
  • Then the loop will calculate the double value and then it prints the value with the help of print function.
  • The end function puts the spaces between numbers.