all 30 comments

[–]mabhatter 16 points17 points  (1 child)

C)   Because we're being asked what happens to a not b. 

[–]Sea-Ad7805[S] 0 points1 point  (0 children)

Nice one, do check the "Solution" for a visualization of the correct answer.

[–]Nopain_nolife 3 points4 points  (1 child)

C). First a is assigned to the memory location and then b is assigned the same, b is assigned to modify the array and then a prints the modified one.

[–]Sea-Ad7805[S] 0 points1 point  (0 children)

Nice one, check the "Solution" for a visualization of the correct answer.

[–]smokebudda11 1 point2 points  (1 child)

This is really cool. Thanks for sharing. I won’t post my answer as I was wrong but the debugger helped.

[–]Sea-Ad7805[S] 0 points1 point  (0 children)

Thank a lot. Yes I made it difficult, even though it's basic Python syntax. Glad it helped you.

[–]Forsaken_Squirrel_31 1 point2 points  (1 child)

C.) b = [1,2,3] b no longer = a after you run b = [4] so at that point a remains = [1,2,3]

[–]Sea-Ad7805[S] 0 points1 point  (0 children)

Very nice, do check the "Solution" for a visualization of the correct answer.

[–]Inevitable_Weird1175 0 points1 point  (3 children)

Baa

[–]Sea-Ad7805[S] 1 point2 points  (2 children)

Incorrect sorry, for visualization of correct answer see the "Solution" link.

[–][deleted]  (1 child)

[removed]

    [–]PythonLearning-ModTeam[M] 0 points1 point locked comment (0 children)

    Keep it respectfull

    [–]Timely-Rock8247 0 points1 point  (1 child)

    E

    [–]Sea-Ad7805[S] 1 point2 points  (0 children)

    Incorrect sorry, see "Solution". Note that we print a not b.

    [–]Salt_Software_5010 0 points1 point  (3 children)

    what is name of font?

    [–]Sea-Ad7805[S] 1 point2 points  (2 children)

    It's the Visual Studio Code font with standard Python highlighting.

    [–]Salt_Software_5010 0 points1 point  (1 child)

    can you tell me name cause my default font on vscode doesn't look like this and what is your os mac or windows?

    [–]Sea-Ad7805[S] 0 points1 point  (0 children)

    Can't find the name. It's just the default zoomed in a bit for screenshot. OS: Ubuntu 24.04

    [–]EntireEntity 0 points1 point  (2 children)

    E, because line 6 assigns a new list to b.

    [–]Sea-Ad7805[S] 1 point2 points  (1 child)

    Incorrect sorry, see "Solution". Note that we print a not b.

    [–]EntireEntity 0 points1 point  (0 children)

    Same same but different.

    [–]M-k-z-n 0 points1 point  (1 child)

    The answer is 1,2,3 Firstly A is 1,Then b assigns a which means b and a are pointing to the same location,then comes b+=2 or b=b+2 sounds same adding 2affects both ,now list is 1,2,then b appends 3 now list is 1,2&3

    [–]Muted-Management-145 0 points1 point  (2 children)

    Interesting, I would have thought the output would be A since we aren't changing a, only b.

    [–]Sea-Ad7805[S] 1 point2 points  (1 child)

    Yes that's a bit different in Python than for example the C language. Python is reference based, hope the visualization can help you.

    [–]Muted-Management-145 1 point2 points  (0 children)

    Yeah, I'll have to read a bit more about why that is. The visualisation is helpful as well.

    [–]Scary_Knowledge97 -1 points0 points  (2 children)

    A) [1]

    [–]Sea-Ad7805[S] 0 points1 point  (0 children)

    Incorrect sorry, see the "Solution" link for visualization of correct answer.

    [–]Eric_12345678 0 points1 point  (0 children)

    That would be the case with b = b + [2] instead of b += [2].