Computer Science
What is the output produced by following code?
a, b = bool(0), bool(0.0)
c, d = str(0), str(0.0)
print (len(a), len(b))
print (len(c), len(d))
Python
Python Data Handling
26 Likes
Answer
The above code will give an error as the line print (len(a), len(b))
is calling len function with bool arguments which is not allowed in Python.
Answered By
14 Likes
Related Questions
Given a string s = "12345". Can you write an expression that gives sum of all the digits shown inside the string s i.e., the program should be able to produce the result as 15 (1+2+3+4+5).
[Hint. Use indexes and convert to integer]Which of the following expressions will result in an error message being displayed when a program containing it is run?
(a) 2.0/4
(b) "3" + "Hello"
(c) 4 % 15
(d) int("5")/float("3")
(e) float("6"/"2")
Predict the output if e is given input as 'True':
a = True b = 0 < 5 print (a == b) print (a is b) c = str (a) d = str (b) print (c == d) print (c is d) e = input ("Enter :") print (c == e) print (c is e)
Following expression does not report an error even if it has a sub-expression with 'divide by zero' problem:
3 or 10/0
What changes can you make to above expression so that Python reports this error?