Computer Science
What is the result produced by (i) bool (0) (ii) bool (str(0))? Justify the outcome.
Python Data Handling
26 Likes
Answer
(i) bool (0)
The result is False as truth value of 0 is falsetval
(ii) bool (str(0))
The result is True as str(0) converts 0 to string "0". As it becomes a non-empty string so its truth value is truetval
Answered By
11 Likes
Related Questions
Differentiate between a syntax error and a logical error in a python program. When is each type of error likely to be found?
What is the difference between an error and exception?
What will be the output, if input for both the statements is 5 + 4/2.
6 == input ("Value 1:")
6 == int(input ("value 2:"))Following Python code has an expression with all integer values. Why is the result in floating point form?
a, b, c = 2, 3, 6 d = a + b * c/b print(d)