Test Index
CBSE Class 12 Computer Science 2025 Paper Set 4
© examsnet.com
Question : 23 of 37
Marks:
+1,
-0
Write one example of each of the following in Python :(i) Syntax Error(ii) Implicit Type Conversion
Solution:
(i) Syntax ErrorA syntax error occurs when a statement breaks the grammar rules of Python, so the program does not run at all.
print(2 ; 5) # SyntaxError: invalid syntaxAnother example: a missing colon after
if.if x > 5 # SyntaxError: expected ':' print(x)(ii) Implicit Type ConversionPython itself converts one data type to another (a smaller type to a wider type) during an operation, without the programmer asking for it.
x = 10 # inty = 20.5 # floatz = x + y # x is converted to float automaticallyprint(z) # 30.5print(type(z)) # <class 'float'>The int value 10 is converted to the float 10.0 before the addition, so the result is a float.
© examsnet.com
Go to Question: