Answer to Question #260822 in Python for heheeeeeeeeeeee

Question #260822

Instructions:

  1. Input a positive integer. This will serve as the starting point of the loop.
  2. Using a while() loop, print out all the odd numbers starting from the inputted integer, until 0. The outputted numbers must all be separated by line.
  3. Also remember that since the loop goes to descending order, a decrement variable shall be created and decreased per iteration for the loop to terminate when it reaches 0.

Instructions

  1. Create a variable and assign it to an input() function that will accept an integer greater than 0.
  2. Using a while() loop, print out all the odd numbers starting from the inputted integer, until 0. The outputted numbers must all be separated by line, just like that of the sample output.
  3. Also remember that since the loop goes to descending order, a decrement variable shall be created and decreased per iteration for the loop to terminate when it reaches 0.

Input

A line containing an integer.

10

Output

Multiple lines containing an integer.

9
7
5
3
1







1
Expert's answer
2021-11-03T17:47:02-0400


SOLUTION TO THE ABOVE QUESTION


SOLUTION CODE


my_integer_variable = int(input("\nEnter an integer greater than zero: "))

#define a function called input that will take the positive integer grate than 0
def input_function(integer_value):
    my_variable = integer_value
    while my_variable > 0:
        if my_variable % 2 == 1:
            print(my_variable)

        my_variable = my_variable - 1;

#call the above defined function and give it our integer value
if my_integer_variable > 0:
    input_function(my_integer_variable)
else:
    print("The integer value is not greater than zero")


SAMPLE OUTPUT PROGRAM



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog