Informatics Practices
Write the output of the following:
num1 = 4
num2 = num1 + 1
num1 = 2
print(num1, num2)
Getting Started
2 Likes
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
1 Like
Related Questions
Consider the statements given below and write Python command to display these statements in both Interactive and Script mode.
Python is easy to learn and write.
It allows us to work in two modes: Interactive mode and Script mode.
Interactive mode is also known as Python Shell and Script mode is also known as Python Editor.
It is a platform-independent language.
We find it interesting to work with Python.Write a code that prints your full name and your birthday as separate strings.
What is the difference between Script mode and Interactive mode in Python?
Write Python statement for the following in interactive mode:
- To display sum of 3, 8.0, 6*12
- To print sum of 16, 5.0, 44.0