Ask Question
11 February, 21:16

g Write a program using integers usernum and x as input, and output usernum divided by x four times. For example, if the input is: 2000 2 where user_num = 2000 and x = 2, then the output must be: 1000 500 250 125 Note: all the values must be printed on the same line. Also, recall that in Python 3, integer division discards fractions. Ex: 6 / / 4 is 1 (the 0.5 is discarded).

+3
Answers (1)
  1. 11 February, 21:51
    0
    The python program to this question as follows:

    Program:

    usernum = 2000 #define variable usernum and assign value

    x=2 #define variable x and assign value

    result = '' #define variable result

    for i in range (4) : #loop for calculate value

    usernum = usernum//x #divide value

    result + = (' '+str (usernum)) #collect value

    print (result) #print value

    Output:

    1000 500 250 125

    Explanation:

    In the above python program code firstly, two integer variable is defined that is "usernum and x" in which variable usernum holds a value that is "2000" and variable x holds a value that is "2", and a string variable result has defined, that store the calculated values.

    In the next step, a for loop is declare that runs four times, in which the usernum variable divides its value by variable x and stores all the values in string variable result. In the last print, function is used to print result variable value.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “g Write a program using integers usernum and x as input, and output usernum divided by x four times. For example, if the input is: 2000 2 ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers