Computer Science
Predict the output:
x = 40
y = x + 1
x = 20, y + x
print (x, y)
Python
Python Funda
75 Likes
Answer
Output
(20, 81) 41
Explanation
x = 40⇒ assigns an initial value of 40 to x.y = x + 1⇒ y = 40 + 1 = 41. So y becomes 41.x = 20, y + x⇒ x = 20, 41 + 40 ⇒ x = 20, 81. This makes x a Tuple of 2 elements (20, 81).print (x, y)⇒ prints the tuple x and the integer variable y as (20, 81) and 41 respectively.
Answered By
28 Likes
Related Questions
What is the problem with the following code fragment?
name = "Prejith" age = 26 print ("Your name & age are ", name + age)What is the problem with the following code fragment?
a = 3 s = a + 10 a = "New" q = a / 10Predict the output:
x, y = 20, 60 y, x, y = x, y - 10, x + 10 print (x, y)Predict the output:
a, b = 12, 13 c, b = a*2, a/2 print (a, b, c)