Question
Questions about Python Q1. Here's a little twist on what we had before: a = 5 b = 5 c = 2+3 id(a) id(b) id(c)
Questions about Python
Q1. Here's a little twist on what we had before:
a = 5 b = 5 c = 2+3 id(a) id(b) id(c) id(5)
Group of answer choices
a) These all have the same identity
b) These all have different identities
c) A and B are the same, but the others are different
Q2.
This highlights one difference between numbers and lists in Python: number are immutable, meaning that their values cannot be changed.
You can add items to a sheet of paper (or cross them off) without changing the identity of the sheet of paper. But you try to change the value of 5, then it would no longer be 5. So the Python language doesn't permit you to try to do that.
And since that value cannot be changed, there is no harm in letting many different values refer to that same value, as is visible here.
So that leads to this behavior, which is also different from many other languages:
a = 6 id(a) a = 7 id(a) a
Group of answer choices
a) The identity of A doesn't change, only its value does
b) I'm still getting: SyntaxError: multiple statements found while compiling a single statement
c) The identity of A changes with each new value
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started