Informatics Practices
What will be the output produced by the following code fragment?
first = 2
second = 3
third = first * second
print (first, second, third)
third = second * first
print (first, second, third)
Python Funda
1 Like
Answer
2 3 6
2 3 6
Working
first = 2⇒firstis assigned the value 2.second = 3⇒secondis assigned the value 3.third = first * second⇒thirdis calculated asfirst * second, which is 2 * 3 = 6.print(first, second, third)⇒ The print statement outputs 2 3 6, showing the values offirst,second, andthird.third = second * first⇒thirdis reassigned withsecond * first, which is 3 * 2 = 6.print(first, second, third)⇒ The second print statement outputs 2 3 6 again, reflecting the updated value ofthird.
Answered By
3 Likes
Related Questions
Find out the error(s) in following code fragment:
print("X ="X)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)"Comments are useful and an easy way to enhance readability and understandability of a program." Elaborate with examples.