Computer Science
What will be the output produced by following code fragment:
X = 10
X = X + 10
X = X - 5
print (X)
X, Y = X - 2, 22
print (X, Y)
Python
Python Funda
133 Likes
Answer
Output
15
13 22
Explanation
X = 10
⇒ assigns an initial value of 10 to X.X = X + 10
⇒ X = 10 + 10 = 20. So value of X is now 20.X = X - 5
⇒ X = 20 - 5 = 15. X is now 15.print (X)
⇒ print the value of X which is 15.X, Y = X - 2, 22
⇒ X, Y = 13, 22.print (X, Y)
⇒ prints the value of X which is 13 and Y which is 22.
Answered By
49 Likes
Related Questions
Find out the error(s) in following code fragment:
print("X ="X)
Find out the error(s) in following code fragment:
else = 21 - 5
What will be the output produced by following code fragment:
first = 2 second = 3 third = first * second print (first, second, third) first = first + second + third third = second * first print (first, second, third)
What will be the output produced by following code fragment:
side = int(input('side') ) #side given as 7 area = side * side print (side, area)