In: Computer Science
Write a program using integers usernum and x as input, and output usernum divided by x four times. You should prompt the user with the words: Enter the first integer: at which time the users enters a number, and then Enter the second integer: at which time the user enters the second number. The prompts must be EXACTLY as written, including the colon (:) character, or your test cases will fail. Since you are prompting the user for input, you should not enter anything into the (optional) input box below, but input your numbers after your prompts.
Ex: If the input is:
Enter the first integer: 2000 Enter the second integer: 2
Then the output is:
1000 500 250 125
Note: In Python 3, integer division discards fractions. Ex: 6 // 4 is 1 (the 0.5 is discarded).
SOURCE CODE:
*Please follow the comments to better understand the code.
**Please look at the Screenshot below and use this code to copy-paste.
***The code in the below screenshot is neatly indented for better understanding.
# Ask the input for two numbers
usernum = int(input('Enter the first integer: '))
x = int(input('Enter the second integer: '))
# Repeat for 4 times
for i in range(4):
# Print the value of division and end with a space
print(usernum // x, end=' ')
usernum = usernum // x
# If you need to end with a new line character, then use the next line print(), else remove it
print()
=============
Screenshot: