KnowledgeBoat Logo

Informatics Practices

Write the output of the following:

num1 = 4 
num2 = num1 + 1 
num1 = 2
print(num1, num2)

Getting Started

1 Like

Answer

Output
2 5
Explanation

In the above code, num1 is initially assigned the value 4. Then, num2 is set to num1 + 1, resulting in num2 being 5. Subsequently, num1 is reassigned the value 2, changing its original value from 4 to 2. When print(num1, num2) is executed, it displays the current values of num1 and num2, which are 2 and 5, respectively.

Answered By

3 Likes


Related Questions