Question: Write a program in python that asks the user for the position of a virtual character on the x - axis in a coordinate system

Write a program in python that asks the user for the position of a virtual character on the x-axis in a coordinate
system and then allows the user to move the virtual character to the right or left, indicated by the
characters r or l. The user should be able to move the virtual character as often as they wish, but if the input is
neither r nor l the program quits. The new position of the virtual character and instructions for the user are
written out in each iteration.
The valid range on the x-axis, which the virtual character can traverse, is from 1 to 10. If the virtual character is
positioned at either end of the range it will not move when the user tries to move it out of the range.
Further information about the implementation:
If the initial position of the virtual character is not bertween 1 and 10, the program should ask the
user again until the position is valid.
The current position is shown as o, while other positions on the x-axis are shown as x.
You should implement the numbers 1 and 10 and the characters r and l as constants. In Python, a
constant is a variable whose value will not change during execution of the program. It is a good rule to
use capital letters for naming constants.
You should use functions in your implementation. It is fine that your main program contains the loop,
but the body of the loop should, in most part, be a series of function calls.
Scoring
Write a program in python that asks the user for

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!