#Python-
Q.What is output for following code? __________________________
y = [4, 5,1j]
y.sort()
A - [1j,4,5]
B - [5,4,1j]
C - [4,5,1j]
D - Type Error
Answers
Answered by
1
Answer:
D.Type error
Explanation:
Because 1j consider as the complex number
Answered by
0
The output of this given code "y = [4, 5,1j] y.sort()" is Type error (Option D)
- When the data type of objects in an operation is incorrect, a TypeError occurs in the Python programming language. If you try to divide an integer by a string, for example, the data types of the integer and the string object will be incompatible.
- By default, the sort() method sorts the list ascending. A function can also be created to determine the sorting criteria (s). To sort in python the words should be in a proper matter like in proper "integer" or any other data type, but obviously not in mix form, like "1j". Hence, this is showing a type error.
#SPJ3
Similar questions