Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Pls help me with debug python files thank you # save_running_times.py # Chapter

ID: 3889275 • Letter: P

Question

Pls help me with debug python files thank you

# save_running_times.py
# Chapter 6.2 Page 257


def main():
# Get the number of videos in the project.
num_videos = int(input('How many videos are in the project? ')

# Open the file to hold the running times.
video_file = open('video_times.txt', 'w')

# Get each video's running time and write it to the file.
print('Enter the running times for each video.')
  
for count in range(1, num_vidoes + 1):
run_time = float(input('Video #' + str(count) + ': '))
video_file.write(str(run_time) + ' ')

# Close the file.
video_file.close()
print('The times have been saved to video_times.txt.)

# Call the main function
main()

Explanation / Answer

# save_running_times.py
# Chapter 6.2 Page 257

def main():
# Get the number of videos in the project.
num_videos = int(input('How many videos are in the project? ')) # 1.missing closing bracket of int()
# Open the file to hold the running times.
video_file = open('video_times.txt', 'w')
# Get each video's running time and write it to the file.
print('Enter the running times for each video.')
  
for count in range(1, num_videos + 1): #2. variable name should be num_videos but it is num_vidoes
run_time = float(input('Video #' + str(count) + ': '))
video_file.write(str(run_time) + ' ')
# Close the file.
video_file.close()
print('The times have been saved to video_times.txt.') # 3. missing closing single quote inside print method
# Call the main function
main()

'''
sample output

How many videos are in the project? 3
Enter the running times for each video.
Video #1: 1.1
Video #2: 2.2
Video #3: 3.3
The times have been saved to video_times.txt.

'''