Implement a program that asks the user for a distance and a number of steps, and prints out the remaining distance assuming the person travels in this manner.
Your program should work like this:
Enter a distance: 8
Number of steps: 5
Distance remaining = 0.25 m
Enter a distance: 2.5
Number of steps: 4
Distance remaining = 0.15625 m
my attempt is
- Code: Select all
a = float(input('Enter a distance: '))
b = int(input("Number of steps: "))
print("Distance remaining =", (a / ( 2 ^ b )), "m")
but i don't know what i was meant to do in the 3rd line.
Also a step is a single movement (which might be many meters). Try to think of it as logical steps in a process, rather than a physical walking step.
So step one is 4 meters, step 2 is 2 meters, etc, etc.