KnowledgeBoat Logo

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

  1. first = 2 ⇒ assigns an initial value of 2 to first.
  2. second = 3 ⇒ assigns an initial value of 3 to second.
  3. third = first * second ⇒ third = 2 * 3 = 6. So variable third is initialized with a value of 6.
  4. print (first, second, third) ⇒ prints the value of first, second, third as 2, 3 and 6 respectively.
  5. first = first + second + third ⇒ first = 2 + 3 + 6 = 11
  6. third = second * first ⇒ third = 3 * 11 = 33
  7. print (first, second, third) ⇒ prints the value of first, second, third as 11, 3 and 33 respectively.

Answered By

24 Likes


Related Questions