Computer Science
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)
Python
Python Funda
49 Likes
Answer
Output
2 3 6
11 3 33
Explanation
first = 2
⇒ assigns an initial value of 2 to first.second = 3
⇒ assigns an initial value of 3 to second.third = first * second
⇒ third = 2 * 3 = 6. So variable third is initialized with a value of 6.print (first, second, third)
⇒ prints the value of first, second, third as 2, 3 and 6 respectively.first = first + second + third
⇒ first = 2 + 3 + 6 = 11third = second * first
⇒ third = 3 * 11 = 33print (first, second, third)
⇒ prints the value of first, second, third as 11, 3 and 33 respectively.
Answered By
24 Likes
Related Questions
Find out the error(s) in following code fragment:
else = 21 - 5
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)
What will be the output produced by following code fragment:
side = int(input('side') ) #side given as 7 area = side * side print (side, area)
What is the problem with the following code fragment?
a = 3 print(a) b = 4 print(b) s = a + b print(s)