[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: confusedAAAAAA.png (348 KB, 562x511)
348 KB
348 KB PNG
ls = [1,2,3,4]
for element in ls:
element+=1
#list isn't modified
for i in range(len(ls)):
ls[i]+=1
#list is modified

ls = [[1,2],[3,4]]
for element in ls:
element[0]=0
#list is modified


How would you teach young people learning programming that int/float/string are 'immutable' and Python passes them automatically by value and otherwise objects are passed by reference in for loops and functions?
Obviously they don't know about reference, mutability, dynamic allocation, and all the advanced stuff that has to do more with computer science than with pure algorithm.
Despite all its greatness, Python is very confusing for beginners, there's too much hidden magic for it to make sense. The list variable being just a reference to the beginning of the list for example, I remember struggling with that before I took a C++ class.
>>
>>101562453
Does a babbys first programming class need that kind of detail?
Or, why not actually teach some basic computer science?
>>
>>101562561
No ofc not. But I've had many students (high school) confused with these for loops for example. I only show them how to loop using indices but sometimes with the stuff they see on the internet or when using LLMs they do it the other way. And that not always working the same way feels arbitrary to them lol
If I take a class or two to teach them those subtleties (that's what it is for them), which is not really possible anyway considering how dense the program is and how few hours we have, I fear I'll just confuse many of them. :(
>>
>>101562453
honestly ive never had a meaningful programming class or seen anyone learn programming from a class. everyone i know learned it the hard way, copying and pasting from stack overflow and an exercising an autistic obsession with fighting the compiler
>>
If you try object = object2 it doesn't modify it either.
So the top level can never be modified. Only the insides.
>>
Describe the hotbar of a video game.

Knife, gun, whatever can't be changed. The indexes on the hotbar can. The knife, gun, whatever can be transferred into any slot.

List is a slot that can hold many weapons.

As far a functions. Weapons are duplicated, backpacks are transfered back and forth.
>>
>>101562825
damn it's a very good image dude, thank you. i'll dig into that
>>
File: trump.jpg (31 KB, 454x523)
31 KB
31 KB JPG
>>101562453
>Dead, retarded, misused scripting language by nocoders for nocoders
>how to spread the knowledge ?
It will always be used by fridge IQ 'developers' because real devs can see the truth and use C-style syntax, compiled lingos

Pyjeet needs to finally get banned from github.
>>
>>101562869
python is used by scientists who dont specialize in computer science
>>
>>101562882
don't bother replying to a guy who just repeats what he reads here lol
>>
File: 1716473849297078.png (1.14 MB, 2020x1895)
1.14 MB
1.14 MB PNG
>>101562882
Fair, but... I want the to code in C++ or at least something like golang instead

No seriously, I want Python get replaced by golang, it would make the world a better place.
>>
>>101562914
He's not wrong, though
>>
>>101562453
>How would you teach young people learning programming that int/float/string are 'immutable' and Python passes them automatically by value and otherwise objects are passed by reference in for loops and functions?
you dont.
you teach them C instead because python is not a good language for a beginner

and no, i dont care what redd|t said, python as first language is a retarded idea
t. started with python
>>
>>101562453
ints are immutable, so
element+=1
only reassigns the label.
ls[i]+=1
by the same logic reassigns ls[i], i.e. modifies the list.
Finally,
element[0]=0
modifies a mutable reference (to a list), which is why you're able to modify the list.
>>
>>101564068
And you kept programming because you started with Python and you liked it. With C you'd have hated it bro, be real



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.