{}
A Python course that doesn't leave you guessing. See every step with our code visualizer.
Try it yourself!
A Python course that doesn't leave you guessing. See every step with our code visualizer.
Try it yourself!
run-icon
main.py
def calculate_time_per_set(wpm, avg_words_per_line, lines_per_set): """ Calculate the time (in seconds) to read a set of lines at a given reading speed. Args: wpm (int): Words per minute. avg_words_per_line (float): Average number of words per line. lines_per_set (int): Number of lines in a set. Returns: float: Time in seconds to read the set. """ time_per_set = (60 * lines_per_set * avg_words_per_line) / wpm return time_per_set # User inputs try: print("=== Time Per Set Calculator ===") wpm = int(input("Enter your reading speed (words per minute): ")) avg_words_per_line = float(input("Enter the average words per line: ")) lines_per_set = int(input("Enter the number of lines per set: ")) # Calculation time = calculate_time_per_set(wpm, avg_words_per_line, lines_per_set) print(f"\nTime to read {lines_per_set} lines at {wpm} WPM: {time:.3f} seconds") except ValueError: print("\nError: Please enter valid numerical inputs.")
Output