Variables, Types & Operators · Question 20 · Hard
Three type conversions are printed on one line. What is the output?
print(int("101", 2), str(5) * 2, float("1e2"))
- 101 10 100.0
- 5 55 100
- 5 55 100.0
- 5 10 100.0
Answer and explanation
Answer: C. 5 55 100.0
Explanation: int("101", 2) reads the text as a binary number: 4 + 0 + 1 = 5. str(5) is the string "5", and repeating it twice gives "55". float("1e2") is 1 × 10², printed as 100.0.
Previous: A float product is compared with 0.3 in two ways. What does this print?
Practise variables, types & operators
Try a fresh set of variables, types & operators questions with an explanation after every answer, free and without signing up: Variables, Types & Operators practice. Or sit a full placement mock test.
More variables, types & operators questions
- Floor division by a float and a remainder with a negative divisor are printed…
- Five different operators appear in one expression. Following precedence rules…
- A float product is compared with 0.3 in two ways. What does this print?
More python practice
Python Strings · Lists & Tuples · Dictionaries & Sets · Conditions & Loops · Functions & Scope · Comprehensions & Generators · Classes & Objects · Exceptions & Files
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge