• API
• FAQ
• Tools
• Archive
daily pastebin goal
52%
SHARE
TWEET

# Untitled

a guest Feb 19th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #Initializing the file and beginning the operation
2. inFile = open("marshoot.txt","r")
3.
4. # Get the number of test cases
6. testCases = testCases[3:6]
7.
10.
11. #turn test cases into and integer
12. testCases = int(testCases)
13.
14. #Establish our test case number
15. testCaseNum = 1
16.
17. # Function to do math and compile math results
18. def time_formatter(seconds):
19.     #calculates the time for all units
20.     sec = int(round(seconds, 0))
21.     min = sec // 60
22.     sec = sec % 60
23.     hr = min // 60
24.     min = min % 60
25.     day = hr // 24
26.     hr = hr % 24
27.
28.     #turns values into printable statements
29.     sec = str(sec)
30.     min = str(min)
31.     hr = str(hr)
32.     day = str(day)
33.
34.     #display results
35.     global testCaseNum
36.     print("Test case number " + str(testCaseNum) + ":")
37.     print(day + " days " + hr + " hours " + min + " minutes " + sec + " seconds ")
38.     testCaseNum = testCaseNum + 1
39.
40.
41. #define the loop to tead every line
42. for x in range(testCases):
43.     #split the lines up by spaces
44.     values = line.split(" ")
45.
46.     #get the distance and make it an integer
47.     distance = values[0]
48.     distance = float(distance)
49.     distance = distance * 1000000
50.
51.     #get the speed and make it an integer
52.     speed = values[1]
53.     speed = float(speed)
54.
55.     #Calculate the time it takes
56.     time = ((distance / speed) * 3600)
57.
58.     #call the function to calculate time
59.     time_formatter(time)
60.