Part 1 create a function that takes a string as a parameter


Python

Part 1: Create a function that takes a string as a parameter and attempts to open a file with the string that is passed.

Part 2: Create a function that takes a string as a parameter and attempts to use python's eval() function to evaluate that string as a mathematical expression

Part 3: Create a function that attempts to add a string and an integer together without doing proper type conversion.

Part 4: Create a function that attempts to convert the string 'test' to an int

Part 5: Write a main function that asks the user to select one of the functions above to call. Once the user has made their selection call the appropriate function and catch the error that is created. You should place all of these function calls in one try block. At the end of the try block you should catch at least one specific error that may be generated by each function. Note, it may be possible to for one function to generate more than one possible error. Have a final except block that will catch all errors not caught by your other except blocks.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Part 1 create a function that takes a string as a parameter
Reference No:- TGS01691984

Now Priced at $25 (50% Discount)

Recommended (92%)

Rated (4.4/5)