ProgrammingModerateTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
t = (1) u = (1,) print(type(t).__name__, type(u).__name__, len(u))
- A. tuple int 0
- B. int tuple 1
- C. tuple tuple 1
- D. int int 1
Correct answer: B. int tuple 1
Parentheses alone do not make a tuple. A comma does, so t is the int 1, while u is a one-element tuple.
More Python Programming questions
- What is printed? python try: print(1.0 // 0.0) except ZeroDivisionError as e: print(e)
- What is printed? python print(int('0x1A', 16), int('1A', 16), int('0x1A', 0))
- What is printed? python print(len(str(10 400 // 3)))
- What is printed? python print(1000000 == 10 6, 0x1F, 1e3 == 1000)
- What is printed? python print(oct(64), hex(-255), bin(0))
- What is printed? python print(ord('A') ^ 32, chr(ord('a') - 32))