Question: Notice that the ASK command prompts the user for input using the name from the ASK command. The assignment page on Canvas will have a

Notice that the ASK command prompts the user for input using the name from the ASK command. The assignment page on Canvas will have a bunch of example scripts. Part of your work is to understand the Tho language so well that you can read the scripts and understand what they do. Task Write a program that: Asks the user for the name of a script to interpret. Opens the named script (its a text file with commands in it), reading the contents. Executes the script line by line. Hints: A Python file has been given to you containing the function isfloat(), which you can import. It takes a string as input, and returns True if the string can be converted to a floating point value, and False if not. The function itself uses exceptions, which you dont need to understand today; its a topic we cover in second year. You will need to read a file using File IO. You will have to look at each line, to see what the command is, and depending on the command, you may need to look at an argument. For the ASK command, use a dictionary to remember the names and values. The keys in your dictio- nary will keys are the names, and the values are the floating point values that the user typed in. The ASK command affects this dictionary, but not the register. The arithmetic commands modify the value in the register R. Your main task is to correctly interpret correct Tho scripts. However, just as it is possible to write Python scripts that have syntax errors or logic errors, it is quite possible to write Tho scripts with syntax errors and logic errors. For this assignment, you are not required to deal with errors in the Tho scripts. If your program crashes because of an error in a Tho script (e.g., DIV 0.0), thats perfectly acceptable for this question. If your program crashes because of an error in your Python program, thats something you

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!