-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution #2248
base: master
Are you sure you want to change the base?
Solution #2248
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your submission! While your implementation of the sorted_variables
dictionary is on the right track, there are several critical issues with the logic used to determine the mutability of different data types. Here are the key points to address:
-
Sets (
collection_of_coins
): Sets are mutable, but your current method of checking mutability by creating a new set results in different IDs. Use an in-place operation likeadd
to verify mutability. -
Dictionaries (
marks
): Dictionaries are mutable, but creating a new dictionary withdict(marks)
results in different IDs. Use an in-place operation likeupdate
to check for mutability. -
Tuples (
profile_info
): Tuples are immutable, and your logic correctly identifies this by noting the ID change when attempting to modify. However, you can directly classify tuples as immutable without operations. -
Lists (
my_favourite_films
): Lists are mutable, but your current method of checking by creating a new list results in different IDs. Use an in-place operation likeappend
to verify mutability. -
Strings (
name
): Strings are immutable, and your logic correctly identifies this by noting the ID change when modified. You can directly classify strings as immutable. -
Booleans (
one_is_a_prime_number
): Booleans are immutable, and your logic correctly identifies this by noting the ID change when modified. You can directly classify booleans as immutable. -
Floats (
pi
): Floats are immutable, and your logic correctly identifies this by noting the ID change when modified. You can directly classify floats as immutable. -
Integers (
lucky_number
): Integers are immutable, and your logic correctly identifies this by noting the ID change when modified. You can directly classify integers as immutable.
Please revise your logic to correctly classify each data type based on their inherent mutability. Once these changes are made, your solution will be ready for approval. Keep up the great work, and don't hesitate to reach out if you have any questions! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review
button in the Reviewers tab.
app/main.py
Outdated
sorted_variables = {"mutable": [], "immutable": []} | ||
|
||
# Function that checks if lucky_number is mutable or immutable | ||
if id(lucky_number) == id(lucky_number + 1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic used to check if lucky_number
is mutable is incorrect. Immutable objects like integers will have different IDs when modified, so this check will always classify integers as immutable. Consider revising the logic to directly classify known immutable types like integers.
app/main.py
Outdated
sorted_variables["immutable"].append(lucky_number) | ||
|
||
# Function that checks if pi is mutable or immutable | ||
if id(pi) == id(pi + 1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic used to check if pi
is mutable is incorrect. Floats are immutable, so the ID will change when modified. This check will always classify floats as immutable. Consider revising the logic to directly classify known immutable types like floats.
app/main.py
Outdated
sorted_variables["immutable"].append(pi) | ||
|
||
# Function that checks if one_is_a_prime_number is mutable or immutable | ||
if id(one_is_a_prime_number) == id(one_is_a_prime_number + True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic used to check if one_is_a_prime_number
is mutable is incorrect. Booleans are immutable, so the ID will change when modified. This check will always classify booleans as immutable. Consider revising the logic to directly classify known immutable types like booleans.
app/main.py
Outdated
sorted_variables["immutable"].append(one_is_a_prime_number) | ||
|
||
# Function that checks if name is mutable or immutable | ||
if id(name) == id(name + "s"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic used to check if name
is mutable is incorrect. Strings are immutable, so the ID will change when modified. This check will always classify strings as immutable. Consider revising the logic to directly classify known immutable types like strings.
app/main.py
Outdated
|
||
# Function that checks if my_favourite_films is mutable or immutable | ||
update_my_favourite_films = my_favourite_films | ||
if id(my_favourite_films) != id(update_my_favourite_films + ["2012"]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic used to check if my_favourite_films
is mutable is incorrect. Lists are mutable, but the operation update_my_favourite_films + ["2012"]
creates a new list, so the IDs will differ. Consider using an operation that modifies the list in place, like append
, to check for mutability.
app/main.py
Outdated
sorted_variables["immutable"].append(my_favourite_films) | ||
|
||
# Function that checks if profile_info is mutable or immutable | ||
if profile_info == profile_info + (4,): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic used to check if profile_info
is mutable is incorrect. Tuples are immutable, so the operation profile_info + (4,)
creates a new tuple, and the IDs will differ. This check should classify tuples as immutable directly.
app/main.py
Outdated
sorted_variables["immutable"].append(profile_info) | ||
|
||
# Function that checks if marks is mutable or immutable | ||
if marks == dict(marks): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic used to check if marks
is mutable is incorrect. Dictionaries are mutable, but the operation dict(marks)
creates a new dictionary, so the IDs will differ. Consider using an operation that modifies the dictionary in place, like update
, to check for mutability.
app/main.py
Outdated
sorted_variables["immutable"].append(marks) | ||
|
||
# Function that checks if collection_of_coins is mutable or immutable | ||
if collection_of_coins == set(collection_of_coins): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic used to check if collection_of_coins
is mutable is incorrect. Sets are mutable, but the operation set(collection_of_coins)
creates a new set, so the IDs will differ. Consider using an operation that modifies the set in place, like add
, to check for mutability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on implementing the task requirements by creating the sorted_variables
dictionary with the correct structure! 🎉 Your code effectively classifies most variables based on their mutability. However, there's a critical issue with the classification of sets. Sets, like collection_of_coins
, are mutable and should be included in the "mutable"
list instead of the "immutable"
list.
Please review the comments and make the necessary adjustments to ensure accuracy. Addressing this issue will help you avoid similar problems in the future. Keep up the good work and continue learning from these experiences! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
|
||
sorted_variables["mutable"].append(my_favourite_films) | ||
sorted_variables["mutable"].append(marks) | ||
sorted_variables["mutable"].append(collection_of_coins) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sets are mutable data types. Therefore, collection_of_coins
should be appended to sorted_variables['mutable']
instead of sorted_variables['immutable']
.
No description provided.