ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(str(3) + str(3.0), 3 + 3.0, '3' * 3 == '333')
- A. 33 6.0 True
- B. 33.0 6.0 True
- C. 33.0 6 True
- D. 33.0 6.0 False
Correct answer: B. 33.0 6.0 True
str(3.0) gives '3.0', so concatenating with '3' makes '33.0'. Adding an int and a float gives the float 6.0, and repeating the string 3 times gives '333'.
More Python Programming questions
- What is printed? python y = 1 + 1 - 1 2 2 // 4 print(y, 2 2 0, (2 2) 0, -3 2 % 5)
- What is printed? python t = 'racecar' print(t == t[::-1], t.find('car'), t.rfind('c'), t.replace('car', 'CAR', 1))
- What is printed? python s = 'one two three' print(s.split(' '), len(s.split()), s.split(None, 1)[1], '-'.join(s.split()))
- What is printed? python print('ab'.ljust(4, '') + '|', 'ab'.rjust(4, ''), 'ab'.zfill(4), '12'.zfill(1))
- What is printed? python print('%s and %s' % ('A', 'B'), '%(x)d-%(x)05.1f' % {'x': 3}, '%%%d' % 5)
- What is printed? python print(1 / 2 + 1 // 2 + 1 % 2, 1 / 2 2 == 1, 3 1 / 2 == 3 (1 / 2))