ProgrammingModerateTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
x = 12 x //= 5 y = 12 y /= 5 print(x, y, type(x).__name__, type(y).__name__)
- A. 2.4 2.4 float float
- B. 2 2.4 float float
- C. 2 2.4 int float
- D. 2 2 int int
Correct answer: C. 2 2.4 int float
//= keeps an int result, 2. /= always gives a float, 2.4. So x is an int and y is a float.
More Python Programming questions
- What is printed? python import itertools print(list(itertools.islice(itertools.cycle('ab'), 5)), list(itertools.repeat(7, 2)))
- What is printed? python def f(): yield 1 yield 2 print(sum(f()), max(f()), list(zip(f(), f())))
- What is printed? python s = 'a-b-c' print(s.split('-', 1), s.rsplit('-', 1)[-1], s.partition('-')[2])
- What is printed? python print(divmod(-1, 10), divmod(1, -10), -1 % 10)
- What is printed? python words = ['hi', 'there', 'hey'] print(max(words), min(words, key=len), sorted(words, key=lambda w: (len(w), w)))
- What is printed? python print(pow(0, 0), 0 0 == 1, pow(2, -2, 5), pow(0, 0, 5))