Explore Westonci.ca, the leading Q&A site where experts provide accurate and helpful answers to all your questions. Get accurate and detailed answers to your questions from a dedicated community of experts on our Q&A platform. Join our Q&A platform to connect with experts dedicated to providing accurate answers to your questions in various fields.

1.21 LAB: Divide by x

Write a program using integers user_num and x as input, and output user_num divided by x three times.


Sagot :

Answer:

Explanation:

The following code is written in Python. It is a function called divide_by_x and takes the user inputs as described. It then raises x to the third power and divides user_num by that number. This gives the same result as user_num divided by x three times. The answer is saved in the variable answer which is then returned to the user.

def divide_by_x(user_num, x):

   answer = user_num / (x**3)

   return answer

The program is an illustration of the division arithmetic operation.

The program in Python, where comments are used to explain each line is as follows:

#This gets input for user_num

user_num = int(input())

#This gets input for x

x = int(input())

This loop is repeated three times

for i in range(1,4):

       #This divides user_num by x, each time

       user_num /= x

       #This prints the required output

       print(user_num)

At the end of the program, user_num is divided three times by x and then printed.

Read more about similar programs at:

https://brainly.com/question/17277570