Please do the following programs.
- Write a python program to access the array element whose index is out of bound and handle the corresponding exception.(Hint: Consider a list having 3 elements (ex: 1,2,3 )but you have to access the fourth element which is not there in that list. So that it raises an exception and it is to be handled.)
- Write a python script to Raise an instance of the Exception class itself.
- Write a function to compute 5.7/0 and use try/except to catch the exceptions.
- Write a python script to verify that every number in the list [2,4,6,8] is even by using assert statement.
- Write a python script to verify that every number in the list [1,3,5,7] is odd by using assert statement.
- Try to write a python script to handle multiple errors with one except statement.(Hint: Initialize two or more errors under try section. You may also use if condition if needed. Use except(first error name,second error name)for handling the errors that occurred.)
- Write a python script to work within specific parameters.(Hint: if you want to limit the user-input to only positive integers, raise an exception. If the user input is 3 it prints 3 as output, if the user gives -3 as input then the output must be “please give a positive number”. You may use while statement if required.)
- Write a python script to raise an exception when you try to access the key value which do not exist in dictionary.(Hint: Create a dictionary and insert some keys and values in it. Then access an element which is not in that dictionary.)