Exercise 4.3 (Pythons eval() function)
1. Ensure you have viewed the video (associated with this exercise) at this link >>
2. What will be the output of the following program if the user enters 57 in response to the user friendly prompt?
Exercise 4.4 Exercise 1
3. What is the output of the following program if the user enters 123 when prompted?
Exercise 4.3 Example 2
4. If the user enters 21 in response the user friendly prompt of the program below what will be output by the program?
Exercise 4.3 Example 3
5. If the user enters 3.2 in response to the user friendly prompt for the following program an error will occur. What type of error occurs and why does it occur?
Exercise 4.3 Example 4
6. If the user enter 3.2 when prompted by the program below it functions as you would expect. It fixes the issue found when executing the program above. Explain how it has fixed the error.
Exercise 4.3 Example 5
7. What is the output from the program below if the user enters 3 in response to the user friendly prompt. During the execution of the program what is the type of the following variables: inputted_value and result.
What will be the output be from the same program if the user enters 6.5 in response to the user friendly prompt. Again during the execution of the program what is the type of the following variables: inputted_value and result.
What will be the output be from the same program if the user enters 6.5 in response to the user friendly prompt. Again during the execution of the program what is the type of the following variables: inputted_value and result.
Exercise 4.3 Example 6
8. What is the output from the program below if the user enters 7+2+3 in response to the user friendly prompt. During the execution of the program what is the type of the following variables: inputted_value and result.
What will be the output be from the same program if the user enters 1/2 + 5 in response to the user friendly prompt. Again during the execution of the program what is the type of the following variables: inputted_value and result.
What will be the output be from the same program if the user enters 1/2 + 5 in response to the user friendly prompt. Again during the execution of the program what is the type of the following variables: inputted_value and result.
Exercise 4.3 Example 7
9. What is the output from the program below if the user enters x**2+6*x+1 in response to the user friendly prompt.
Exercise 4.3 Example 8
10. Give a reason as to why you should not use the eval() function in your code.
END Next Exercise >>