Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

hey i need help finding some types of errors in python. I have come up with two

ID: 440434 • Letter: H

Question

hey i need help finding some types of errors in python. I have come up with two errors so far. for example Code: >>> a produces: NameError Code: >>> 1/0 produces: ZeroDivisionError Can i have more example of errors, i need 8 more. I knew alot of errors but i cant figure out the code to getting those errors. I would really appreciate it if someone can help me out. thanks.

Explanation / Answer

1. IndexError >>> x = [1,2] >>> x[2] would produce IndexError as there is no value with index 2. 2. ValueError >>>x = 'xxx' >>> int(x) would produce ValueError as it cannot produce int value of a string. 3. SyntaxError >>>if(1) this would produce SyntaxError as there is no colon. 4. TypeError >>>str("xxxx")+1 this would produce TypeError as it cannot concatenate str and int 5. KeyError >>> x={"val1":1,"val2":2,} >>>x["val3"] this would produce keyError as there is no key "val3" in the dictionary 6. IOError >>>open("xxx","r") this would produce IOError as there is no file called "xxx" to read. 7. ImportError >>> import xxx this would produce ImportError as there is no module xxx to import 8. IndentationError >>>if(1): >>>print("sometext") this would produce IndentationError as Indentation rule is not followed.