Q1: Find the error in this code:
'2' + 3
Ans: TypeError: must be str, not int. Fix: '2' + str(3).
Q2: Find the error in this code:
open('nofile.txt').read()
Ans: FileNotFoundError: no such file.
Q3: Find the error in this code:
a = 5 print(b)
Ans: NameError: b is not defined.
Q4: Find the error in this code:
import maths
Ans: ModuleNotFoundError: No module named 'maths'. Correct: import math.
Q5: Find the error in this code:
my_list = (1,2,3); my_list.append(4)
Ans: AttributeError: tuple has no attribute 'append'. Fix: use list.
Q6: Find the error in this code:
x = '10'; y = int(x); print(y+z)
Ans: NameError: z is not defined.
Q7: Find the error in this code:
while True print('hi')
Ans: SyntaxError: missing colon. Fix: while True: print('hi').
Q8: Find the error in this code:
{[1,2]:'val'}
Ans: TypeError: unhashable type: 'list'. Keys must be immutable.
Q9: Find the error in this code:
int('abc')
Ans: ValueError: invalid literal for int().
Q10: Find the error in this code:
my_list = (1,2,3); my_list.append(4)
Ans: AttributeError: tuple has no attribute 'append'. Fix: use list.
Q11: Find the error in this code:
for i in range(5) print(i)
Ans: SyntaxError: missing colon after for statement. Fix: for i in range(5):
Q12: Find the error in this code:
myset = {1,2,3}; print(myset[0])
Ans: TypeError: 'set' object is not subscriptable.
Q13: Find the error in this code:
list = [1,2]; print(list[5])
Ans: IndexError: list index out of range.
Q14: Find the error in this code:
myset = {1,2,3}; print(myset[0])
Ans: TypeError: 'set' object is not subscriptable.
Q15: Find the error in this code:
d = {1:'a',2:'b'}; print(d[3])
Ans: KeyError: 3 not found. Fix: use d.get(3).
Q16: Find the error in this code:
import maths
Ans: ModuleNotFoundError: No module named 'maths'. Correct: import math.
Q17: Find the error in this code:
print('Hello' + 5)
Ans: TypeError: can only concatenate str (not int) to str. Fix: print('Hello' + str(5))
Q18: Find the error in this code:
{[1,2]:'val'}
Ans: TypeError: unhashable type: 'list'. Keys must be immutable.
Q19: Find the error in this code:
while True print('hi')
Ans: SyntaxError: missing colon. Fix: while True: print('hi').
Q20: Find the error in this code:
if True print('yes')
Ans: SyntaxError: missing colon. Fix: if True: print('yes').
Q21: Find the error in this code:
for i in range(5) print(i)
Ans: SyntaxError: missing colon after for statement. Fix: for i in range(5):
Q22: Find the error in this code:
int('abc')
Ans: ValueError: invalid literal for int().
Q23: Find the error in this code:
my_list = (1,2,3); my_list.append(4)
Ans: AttributeError: tuple has no attribute 'append'. Fix: use list.
Q24: Find the error in this code:
open('nofile.txt').read()
Ans: FileNotFoundError: no such file.
Q25: Find the error in this code:
'2' + 3
Ans: TypeError: must be str, not int. Fix: '2' + str(3).
Q26: Find the error in this code:
'2' + 3
Ans: TypeError: must be str, not int. Fix: '2' + str(3).
Q27: Find the error in this code:
d = {1:'a',2:'b'}; print(d[3])
Ans: KeyError: 3 not found. Fix: use d.get(3).
Q28: Find the error in this code:
a = 5 print(b)
Ans: NameError: b is not defined.
Q29: Find the error in this code:
for i in range(5) print(i)
Ans: SyntaxError: missing colon after for statement. Fix: for i in range(5):
Q30: Find the error in this code:
for i in 10: print(i)
Ans: TypeError: 'int' object is not iterable.
Q31: Find the error in this code:
int('abc')
Ans: ValueError: invalid literal for int().
Q32: Find the error in this code:
d = {1:'a',2:'b'}; print(d[3])
Ans: KeyError: 3 not found. Fix: use d.get(3).
Q33: Find the error in this code:
def f(a,b=2,c): return a+b+c
Ans: SyntaxError: non-default argument follows default argument.
Q34: Find the error in this code:
for i in 10: print(i)
Ans: TypeError: 'int' object is not iterable.
Q35: Find the error in this code:
if True print('yes')
Ans: SyntaxError: missing colon. Fix: if True: print('yes').
Q36: Find the error in this code:
open('nofile.txt').read()
Ans: FileNotFoundError: no such file.
Q37: Find the error in this code:
print('Hello' + 5)
Ans: TypeError: can only concatenate str (not int) to str. Fix: print('Hello' + str(5))
Q38: Find the error in this code:
x = [1,2]; x.remove(3)
Ans: ValueError: list.remove(x): x not in list.
Q39: Find the error in this code:
'2' + 3
Ans: TypeError: must be str, not int. Fix: '2' + str(3).
Q40: Find the error in this code:
x = [1,2]; x.remove(3)
Ans: ValueError: list.remove(x): x not in list.
Q41: Find the error in this code:
for i in range(5) print(i)
Ans: SyntaxError: missing colon after for statement. Fix: for i in range(5):
Q42: Find the error in this code:
a = 5 print(b)
Ans: NameError: b is not defined.
Q43: Find the error in this code:
while True print('hi')
Ans: SyntaxError: missing colon. Fix: while True: print('hi').
Q44: Find the error in this code:
if True print('yes')
Ans: SyntaxError: missing colon. Fix: if True: print('yes').
Q45: Find the error in this code:
d = {1:'a',2:'b'}; print(d[3])
Ans: KeyError: 3 not found. Fix: use d.get(3).
Q46: Find the error in this code:
x = '10'; y = int(x); print(y+z)
Ans: NameError: z is not defined.
Q47: Find the error in this code:
import maths
Ans: ModuleNotFoundError: No module named 'maths'. Correct: import math.
Q48: Find the error in this code:
{[1,2]:'val'}
Ans: TypeError: unhashable type: 'list'. Keys must be immutable.
Q49: Find the error in this code:
x = 10/0
Ans: ZeroDivisionError: division by zero.
Q50: Find the error in this code:
x = 10/0
Ans: ZeroDivisionError: division by zero.
Q51: Find the error in this code:
while True print('hi')
Ans: SyntaxError: missing colon. Fix: while True: print('hi').
Q52: Find the error in this code:
list = [1,2]; print(list[5])
Ans: IndexError: list index out of range.
Q53: Find the error in this code:
{[1,2]:'val'}
Ans: TypeError: unhashable type: 'list'. Keys must be immutable.
Q54: Find the error in this code:
list = [1,2]; print(list[5])
Ans: IndexError: list index out of range.
Q55: Find the error in this code:
list = [1,2]; print(list[5])
Ans: IndexError: list index out of range.
Q56: Find the error in this code:
x = '10'; y = int(x); print(y+z)
Ans: NameError: z is not defined.
Q57: Find the error in this code:
x = [1,2]; x.remove(3)
Ans: ValueError: list.remove(x): x not in list.
Q58: Find the error in this code:
lambda x,y= x+y
Ans: SyntaxError: invalid syntax for lambda.
Q59: Find the error in this code:
x = 10/0
Ans: ZeroDivisionError: division by zero.
Q60: Find the error in this code:
myset = {1,2,3}; print(myset[0])
Ans: TypeError: 'set' object is not subscriptable.
Q61: Find the error in this code:
x = [1,2]; x.remove(3)
Ans: ValueError: list.remove(x): x not in list.
Q62: Find the error in this code:
open('nofile.txt').read()
Ans: FileNotFoundError: no such file.
Q63: Find the error in this code:
a = 5 print(b)
Ans: NameError: b is not defined.
Q64: Find the error in this code:
'2' + 3
Ans: TypeError: must be str, not int. Fix: '2' + str(3).
Q65: Find the error in this code:
import maths
Ans: ModuleNotFoundError: No module named 'maths'. Correct: import math.
Q66: Find the error in this code:
open('nofile.txt').read()
Ans: FileNotFoundError: no such file.
Q67: Find the error in this code:
d = {1:'a',2:'b'}; print(d[3])
Ans: KeyError: 3 not found. Fix: use d.get(3).
Q68: Find the error in this code:
def f(a,b=2,c): return a+b+c
Ans: SyntaxError: non-default argument follows default argument.
Q69: Find the error in this code:
print('Hello' + 5)
Ans: TypeError: can only concatenate str (not int) to str. Fix: print('Hello' + str(5))
Q70: Find the error in this code:
for i in 10: print(i)
Ans: TypeError: 'int' object is not iterable.
Q71: Find the error in this code:
print('Hello' + 5)
Ans: TypeError: can only concatenate str (not int) to str. Fix: print('Hello' + str(5))
Q72: Find the error in this code:
x = 10/0
Ans: ZeroDivisionError: division by zero.
Q73: Find the error in this code:
myset = {1,2,3}; print(myset[0])
Ans: TypeError: 'set' object is not subscriptable.
Q74: Find the error in this code:
{[1,2]:'val'}
Ans: TypeError: unhashable type: 'list'. Keys must be immutable.
Q75: Find the error in this code:
while True print('hi')
Ans: SyntaxError: missing colon. Fix: while True: print('hi').
Q76: Find the error in this code:
for i in range(5) print(i)
Ans: SyntaxError: missing colon after for statement. Fix: for i in range(5):
Q77: Find the error in this code:
def f(a,b=2,c): return a+b+c
Ans: SyntaxError: non-default argument follows default argument.
Q78: Find the error in this code:
if True print('yes')
Ans: SyntaxError: missing colon. Fix: if True: print('yes').
Q79: Find the error in this code:
lambda x,y= x+y
Ans: SyntaxError: invalid syntax for lambda.
Q80: Find the error in this code:
list = [1,2]; print(list[5])
Ans: IndexError: list index out of range.
Q81: Find the error in this code:
x = '10'; y = int(x); print(y+z)
Ans: NameError: z is not defined.
Q82: Find the error in this code:
def f(a,b=2,c): return a+b+c
Ans: SyntaxError: non-default argument follows default argument.
Q83: Find the error in this code:
print('Hello' + 5)
Ans: TypeError: can only concatenate str (not int) to str. Fix: print('Hello' + str(5))
Q84: Find the error in this code:
a = 5 print(b)
Ans: NameError: b is not defined.
Q85: Find the error in this code:
x = '10'; y = int(x); print(y+z)
Ans: NameError: z is not defined.
Q86: Find the error in this code:
int('abc')
Ans: ValueError: invalid literal for int().
Q87: Find the error in this code:
for i in 10: print(i)
Ans: TypeError: 'int' object is not iterable.
Q88: Find the error in this code:
def f(a,b=2,c): return a+b+c
Ans: SyntaxError: non-default argument follows default argument.
Q89: Find the error in this code:
lambda x,y= x+y
Ans: SyntaxError: invalid syntax for lambda.
Q90: Find the error in this code:
int('abc')
Ans: ValueError: invalid literal for int().
Q91: Find the error in this code:
import maths
Ans: ModuleNotFoundError: No module named 'maths'. Correct: import math.
Q92: Find the error in this code:
x = 10/0
Ans: ZeroDivisionError: division by zero.
Q93: Find the error in this code:
lambda x,y= x+y
Ans: SyntaxError: invalid syntax for lambda.
Q94: Find the error in this code:
x = [1,2]; x.remove(3)
Ans: ValueError: list.remove(x): x not in list.
Q95: Find the error in this code:
myset = {1,2,3}; print(myset[0])
Ans: TypeError: 'set' object is not subscriptable.
Q96: Find the error in this code:
my_list = (1,2,3); my_list.append(4)
Ans: AttributeError: tuple has no attribute 'append'. Fix: use list.
Q97: Find the error in this code:
lambda x,y= x+y
Ans: SyntaxError: invalid syntax for lambda.
Q98: Find the error in this code:
my_list = (1,2,3); my_list.append(4)
Ans: AttributeError: tuple has no attribute 'append'. Fix: use list.
Q99: Find the error in this code:
for i in 10: print(i)
Ans: TypeError: 'int' object is not iterable.
Q100: Find the error in this code:
if True print('yes')
Ans: SyntaxError: missing colon. Fix: if True: print('yes').