@anonymous/UnusualBestXenurusunicinctus

No description

Files

- main.py

main.py

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

```
from random import *
from math import *
rate_of_change = round(sqrt(randint(1,100)),1)*(-1)**randint(-5,5)
initial_x = round(sqrt(randint(1,100)),1)
initial_t = randint(-2,10)
delta_t = 0.5
current_t = initial_t
current_x = initial_x
def get_float(message):
answer = ''
while(not type(answer) == float):
answer = ''
try:
answer = float(raw_input(message))
except ValueError:
print 'Please enter a decimal answer.'
print "\n"
return answer
for i in range(10):
print "Time: %0.2f seconds, Position: %0.2f meters"%(current_t, current_x)
current_t = current_t + delta_t
current_x = current_x + rate_of_change*delta_t
predict_t = current_t + randint(1,6)*delta_t
answer_accepted = False
answer = ''
print "What will the position be at t = %0.2f seconds?"%(predict_t)
predict_x = (predict_t - current_t)*rate_of_change + current_x
answer = get_float('Enter your answer: ')
if(abs(answer-predict_x)<0.05):
print "Nice job, you predicted correctly!"
else:
print "I'm sorry, your prediction was not correct. The correct answer is %0.2f meters."%(predict_x)
```