#pedagogy
1 messages · Page 3 of 1
guys is there a command to make a survey in text channel?
hi guys , ı need help . how can ı accessing the coordinates of the bounding boxes ?
#data-science-and-ml
not here
okey didnt know . ı am new in english .thanks have a good day
???
!pow
Positional vs. Keyword arguments
Functions can take two different kinds of arguments. A positional argument is just the object itself. A keyword argument is a name assigned to an object.
Example
>>> print('Hello', 'world!', sep=', ')
Hello, world!
The first two strings 'Hello' and world!' are positional arguments.
The sep=', ' is a keyword argument.
Note
A keyword argument can be passed positionally in some cases.
def sum(a, b=1):
return a + b
sum(1, b=5)
sum(1, 5) # same as above
Somtimes this is forced, in the case of the pow() function.
The reverse is also true:
>>> def foo(a, b):
... print(a, b)
...
>>> foo(a=1, b=2)
1 2
>>> foo(b=1, a=2)
2 1
More info
• Keyword only arguments
• Positional only arguments
• !tags param-arg (Parameters vs. Arguments)
I am new to leetcode. Do I just type my codes in the red circle? because no matter what I typed, even just copy and paste the answers from the answer section, I got "is not a valid value of type integer"
This channel is for discussion on how to teach, for help try #❓|how-to-get-help 🙂
Hello, everyone! May I ask you why the first one doesn't work and the second does? The first's output should be 1, but it's 0.
def h2(k):
k += 1
def m2():
n = 0
h2(n)
print(n)
m2()
def g1(l):
l *= 2
def m1():
l = [1, 2]
g1(l)
print(l)
m1()
see #❓|how-to-get-help , this is the wrong channel. (but it's because lists are mutable and *= mutates)
Hello everyone ! I want to teach python to someone who is a complete beginner to programming. Goal is to teach core programming concepts using python, rather than python itself. I haven't had great success so far, and I think my teaching methods aren't quite right. Can someone please give me some advice on that ?
My student is at the point where he knows about python syntax and features individually, but is having trouble putting them all together and converting ideas to code. I don't quite remember how I personally got over that step myself.
practice problems
That's what we're currently doing. But I don't really know what problems are appropriate. What should I expect a complete beginner to be able to solve ? How long should I let them think for before giving them a hint ? How should I word my hints ? Right now, after they've been stuck for a while, I just write the solution step by step, making sure they understand what everything means and why everything is as it is. Is that a good method ? Could I be doing better ?
Also, I've been taking exercises from a website called pynative, do you have any better recommendations ?
How long should I let them think for before giving them a hint ? How should I word my hints ?
i think all the questions you've are very context dependent. your hints would be different based on what they're stuck on: if it's syntax they don't know, no amount of hinting will help. if they don't know a specific method, no hinting will help. i would try to stay away from providing code as much as possible.
Right now, after they've been stuck for a while, I just write the solution step by step, making sure they understand what everything means and why everything is as it is
in my experience trying to teach people, it's very easy for them to just believe they understand the solution, rather than actually understanding
Also, I've been taking exercises from a website called pynative, do you have any better recommendations ?
as for where to get practice problems, i like codingbat for beginner exercises and codewars for more intermediate ones
What should I expect a complete beginner to be able to solve
that would depend on what you've taught them :P
I've taught them the syntax and features they need to solve the problems. That is, variable assignment and reassignment, arithmetic, booleans, ifs and elses, fors, whiles, creating and appending to lists, and various other things of that nature.
if they don't know a specific method, no hinting will help
Can you please elaborate on that a bit ?
in my experience trying to teach people, it's very easy for them to just believe they understand the solution, rather than actually understanding
So should I let them be stuck at it for a while longer ?
I don't really know how to teach the ability to translate ideas into code
Can you please elaborate on that a bit ?
by method i mean methods on objects. built-in functions would be included. if they just don't know how to useintto convert say,inputto an int, then even if they have the right idea, they won't be able to write the code
So should I let them be stuck at it for a while longer ?
honestly, i haven't found a good solution for this. what i've settled on currently is to let them try and solve the problem in pseudocode as far as possible, then help them translate into python. this makes sure they are the one solving the problem
by method i mean methods on objects. built-in functions would be included. if they just don't know how to use int to convert say, input to an int, then even if they have the right idea, they won't be able to write the code
Ah, that they know, I made sure they had all the tools they need for a given problem
honestly, i haven't found a good solution for this. what i've settled on currently is to let them try and solve the problem in pseudocode as far as possible, then help them translate into python. this makes sure they are the one solving the problem
Hm I will try that, but I'm afraid the pseudocode will add another layer of complexity. Python itself is very close to pseudocode. Can I please have an example of pseudo code someone you taught gave you ?
it's more english than pseudocode, the idea is to have no barrier to actually solving the problem (as opposed to maybe not knowing python syntax)
for example, for "check if a number is prime" you might do
def is_prime(n):
loop i from 2 to n
if i divides n, return False
return True
Hm ok, and in your opinion, how much time should a beginner put in before being able to output something like that ? Mine is worried they're going too slow
the student is concerned? maybe they should just learn faster lol i'm not sure 🤔 i should ask my person rn tbh lol
as for a serious answer, i'm a bit wary of putting a definite time on it, there's a lot of variability and background detail necessary that i don't know. if the person is relatively competent mathematically, something like this would probably be pretty easy
if the person is relatively competent mathematically
That's not really their strong suit, due to lack of knowledge
the student is concerned?
Yeah, and personally, I think we're going at a decent pace, but they're still worried
I think the perceived speed of their progress (as if there were an actual unit of measure for knowledge) just depends on their frame of reference. if they're learning "slowly", that doesn't tell us anything about their future programming ability. nor does it tell us anything about how smart they are.
Well, I do have to agree...
honestly, i haven't found a good solution for this.
I'll ask around more about that, if there is somewhere I can improve as a teacher, it's here
i have a question
Learning has acceleration. The more you already know the faster you can learn, as long as that new information is somehow related you what you already know (which increases the more you learn). When I start something completely new, I know that it will be slow, and I focus on correctness, not speed. Even if that means that it takes me really long for each part. The speed will come later when my brain puts those slower thoughts into a fast path form. In the case of programming this is common patterns (it's also why learning a new way of doing things is a bit of bump, such as functional programming (but even those bumps go away when you have learned a few different patterns)). If you try learning a game like chess (or any game with simple rules, but emergent complexity (because there is no barrier to entry in terms of having to first memorize a ton of rules or language, etc)) you can notice this transition happening pretty rapidly in a very observable / noticeable way if you pay attention to it while it's happening. Further improvement often requires forcing oneself to not rely on the fast path, and do it slowly, but correctly again. This happens a lot in math and programming and it can feel frustrating to have to slow down again, but being aware that this process is happening may help with that.
TLDR: Learning anything new will always feel like trying to ram your head through a brick wall in the beginning. I have trained myself to enjoy the brick walls.
Thank you ! Hopefully that will be encouraging for my student :>
!otn a squiggle enjoys brick walls
:ok_hand: Added squiggle-enjoys-brick-walls to the names list.
is it me or after learning a few programming languages it is extremely easy to learn another
like 90% of the differences are surface syntax and conventions
the concepts are virtually the same
it depends on the language, but yes, a lot of things are the same. Though it's important to remember that the similarities are often only surface level. A good codebase in one language will be completely different from a codebase in another unless they are exceptionally similar. And with languages like prolog, haskell, even the surface similarities are harder to identify. Regardless, if you know one language well, learning more languages is generally easier.
Core concepts like conditionals, loops, functions ect transfers, what differences is stuff like best practices, what is easiest to work with, ect, ect ... (And ofc a few language specific concepts/details)
(and I now see I am way late to this conversation)
yeah 90% of the time is learning how to use libraries and how to write idiomatic code
cat
Hi!
This is not a shitposting channel. It's a channel about #pedagogy
A variable can contain both a number and a string
The len() function can work with either a number or a string
Any number can be made into a string using the str() function
You can make an integer from any string using the int() function
The find() function can work with either a number or a string
The + operator can work either with two numbers or with two string variables
are there all true or no help if posible
is this a test question lol
this isn't a help channel; see #❓|how-to-get-help. but keep in mind that you can't get help with ongoing exams.
Little late but
integer from any string
is false, since int('a') will raise a ValueError
best way to tutor? im thinkin of tutoring python once i finish my python classes
so far I show em my code, explain it step by step but also feel like its a little cheatsy
help
this channel is for discussion about how to teach computer science, but you can find out how to open your own help thread in #❓|how-to-get-help
oopsy daisies
Is discussing ways to teach yourself more efficiently allowed?
to a limited extent. but it's not a resource suggestion channel.
Please don't randomly ping helpers.
i want help
Also please see #❓|how-to-get-help
This is the wrong channel to ask programming questions in
rn can u help ?
stop asking for help go to #❓|how-to-get-help
ty a lot i just started and i am taking coding course i hope its better then learning by urself
Methods and practices of teaching.
So should we throw students to the fire with a complicated problem set and tell them to use their research skills.
Or baby step and hand hold them through the entire process?
What qualities make a good programmer?
I generally tend to start with babysteps as a lot of the people I teach have only a basic understanding of programming
So I start with numeric operators, just to show off math in Python (Jupyter notebook to be precise, very nice tool to show for teaching)
Then variables (ints, then strings), lists, dictionaries, if/elif/else, for
Then functions, maybe a bit of classes
Then I usually switch over to pandas, as I teach a data-focussed class normally
idiomatic pandas is very different from idiomatic Python; do you do anything to address this with your students?
So more theoretical than practical usage of the language first ? How do you usually end it off?
Yeah, so I show them how it's similar (selection by index like lists, by columns somewhat like a dictionary) so they know where it came from
But it's like teaching two languages side by side, just that teaching pandas is way quicker and more powerful than keeping everything in python for longer
And in other parts of the training they also write bits of flask applications and learn SQL and stuff, it's kind of a broad overview before they dive deeper into their specialisations
For me the goal is to get them to understand data (pre)processing, cleaning, analysis, visualisation
Other trainers teach them about patterns and such
Yeah, a lot of companies are still looking for java devs. And the main trainers have extensive java experience, so that's also a selling points still, that those principles get taught too
And they can be generally helpful to think about design of programs
Although on the data side I haven't found too much of a use for them yet
if one of my coworkers said he was going to subclass a watcher or a facade in one of our projects, I wouldn't know what to do or say.
I would probably just lose my composure and hide somewhere.
So, your job is a form of dev?
Where do you see debugging on the ladder of importance?
All the way up at the top I think
Since I work with my students in Jupyter notebook, most everything is single lines of code or at least very short snippets
That makes it extremely easy to debug for me, but also easy to teach how to approach an error, because usually we just right then have written the code that is throwing an exception
Reading those is such a useful skill to have
Mostly to have people actually start reading them, intently, because nowadays the errors are more and more descriptive and can even offer up the solution
I agree. A good example, is a user on this server posted some code in the general channel asking why the number he wanted was not being output.
`I did some debugging and found he created a function: the parameter being a dictionary of values, but in the function he created a script that made a new dictionary and made the values of the parameter into keys of the new dictionary.
Effectively, the values of input was read and output as keys instead, for the new dictionary. More mix up occurred in the function which made the output even more messy. Which resulted in an unwanted print out.`
In practice, there are large amounts of code to review in a production environment.
But is it efficient to use Jupyter notebooks for all programming?
In the above case, no error was thrown. Only the output was unexpected.
Yeah so, that's the benefit of only working in the early stages of data in Python
There is no real development of any significant code base
So I guess deep debugging like that isn't a thing, as none of them are training to be a Python developer
So, when Python is generally taught. Is it being taught with the intention of the student becoming a Python developer or only as code for supplemental use?
i think most of the time python is taught as part of a CS degree
Never as a Python developer for my students, or well trainees really
The ones that'll use it in their future jobs will do so in a data related position
So Data engineer, analyst, scientist, that kind of thing. They most likely won't ever develop serious software with it. Plus they are trainees, most of their training is going to be on the job, specifically for that job
We only give them a broad kickstart to get them in the door 🙂
Hey. "Python Crash Course" by Eric Matthes is a good pick to revise Python? It's been a year I did something in Python and would like to rehearse it.
This channel is not for resource suggestions
where to start learning python? what sources can i use? ._.
w3schools has a quick and hands-on python starter guide
you can follow that
thank you
w3schools has a lot of misinformation in every Python article. I would avoid it.
can anyone recommend me a major python project idea for college
Hi! This channel is about the methods and practices of teaching.
If you need specific help, I will refer you to #❓|how-to-get-help
thnx
program that predicts house prices
not relevant
Not Python specific but a general coding question around the concept of multiple inheritances and superclasses. For example a language liek C++ has multiple inheritances, is it possible to have a superclass that contains multiple classes within itself? And if so, why not use a superclass like that and use a multiple class inheritance? I saw one example such as input and outputfiles (using a diamond hierarchy) but what other examples could you provide that would help my understanding for the purpose Multiple inheritances serve?
this channel is for talking about teaching techniques, not the actual subject matter.
can anyone help me with using pandas I have a couple of questions?
you can ask in #data-science-and-ml. but ask your actual question. don't ask "can someone help with this question that I haven't asked"
Disregarding whether long-form videos are a good teaching material (probably not), are there any good multi-hour learn-python videos, or can they be discounted as a category without exception?
I know FreeCodeCamp's 4.5 hour video is terrible after watching roughly 30 minutes of various sections, and I dread the idea of reviewing the countless others.
would, say, lectures be fine?
Harvard's cs50p course has a series of lectures, of which a lot are upwards of an hour long
I think a course format is pretty alright, as you get hands on work alongside the lecture
although trying to cram the whole language in a single video might be hard to pull off, and I'm personally not a fan of marathon sessions like that
I may have forgotten about university productions, as I was thinking of the python in a single video videos that youtube is so full of nowadays
but oh boy, is this cs50p class pretty good. 8.5 hours total, even split into 14 videos, might be off-putting to newbies, but the quality is, or at least appears to be, stellar
and an entire video, albeit unlisted and one of the shortest at about 12 minutes, on style? these guys might be the exception
can you copy and paste the actual text? no one is going to want to read this.
Keep in mind this channel is for the discussion of the methods and practices of teaching and not a project showcase.
Hiii
what projects
not sure if this is related to the channel topic (if not, feel free to ping me and tell me to remove) but what kind of techniques did you guys pick up to teach other students (techniques as in from perhaps lecturers or professors you had in the past) and what did you avoid?
I recently did a survey of python textbooks (specifically for analytics) for a course I'm teaching this semester. I found "Intro to Python for Computer Science and Data Science: Learning to Program with AI, Big Data and the Cloud" by Deitel & Deitel to be pretty good with great lecture resources. I have some quibbles around the supplied questions / project assignments, but I can make those up myself.
Any one else have a favorited textbook for teaching Python?
@ancient stone what are the objectives of the course? And what's the full course title?
Learning python, computer science, and data science basics is a lot for one course. Throwing big data and cloud computing in there sounds overly ambitious.
Agreed. The authors bill it as a 2-term book. First ~10 chapters in semester 1, next half in semester 2. Not sure I would really use it for teaching data science, but the first 10 or so chapters are decent (if not slightly slow paced)
I am using it in an intro to analytical programming course - specifically the first ~10 chapters + some content pulled out of McKinny's book around pandas
Basically structuring the course to be foundations of python/oop, and data wrangling with pandas (organizing/cleaning data, ETL at a high level, etc.)
No modelling or anything like that. I went through several, several books and was unimpressed at the content / quality of the book & instructor resources. Just mainly curious what others find useful 🙂
is there liek a suggested roadmap that i can use as inspiration
For teaching Python?
yep
i have a rough idea of what to do but im not sure what i should do to introduce them into more advanced topics like OOP (they are all beginners)
What is the goal? Train them to be app developers, web developers, data engineers, something else?
well you see its a bit of everything
i want them to get there feet wet in every domain to see what it's like and find there interests
then later on they can deep dive on there own
Ah ok, then I would start with the basics: operators, variables, lists, dictionaries, functions, built in methods and functions (think str, int, split, isdigit, that kinda thing), how to find and read docs
yea we already progressed
we only had a 2 hour session and they understand variables lists functions some builtin methods different varaible types
im having them work as a team to create tic tac toe
Then you can branch to classes and OOP, pandas for example for data, perhaps flask for webdev/API, could also do four forms of data gathering: reading files, APIs, databases, and webscraping
and they are almost done (with some guidance ofcourse)
hm ok
also where can i get some good exercises
i think leetcode is a bit of a reach
I mean, I'm biased, I teach a data oriented course, so most of material is data based
Those are math heavy too usually, right?
kinda its very technical and all that
but i really want something thats practical so that they can see a purpose and understand there work better
Try having them load data, clean it, visualise it
For a webpage make a simple Todo list app?
hm was planning on using customtkinter do you suggest a UI library i can use? maybe pycone?
I currently don't have any of my materials on Github yet, otherwise I could share it. Have to get on that
Gui? All I know exists is tkinter and pyqt. There's also textual for an in between gui and commandline
ah your too kind
tkinter is outdated and i think pyqt is too technical customtkinter is a modern version of tkinter
codingbat, codewars
legend
ok thanks for the tips ima see what i can do so far they are absolutely loving it
haha we just finished tic tac toe they where absolutely amazed
I teach a course on Python OOP at two local universities. In order to make the material enjoyable and understandable, I use the pygame extension and explain OOP using "widgets" in windows to build games. I start with simple widgets like buttons, text entry boxes, text display boxes, etc., then build up small GUI games.
I have built a library of these GUI widgets that is available on my GitHub for free: https://github.com/IrvKalb/pygwidgets
Then I turned my course material into a book that is published by No Starch Press: https://nostarch.com/object-oriented-python
(Also available on Amazon)
A collection of user interface widgets in Python for use in programs using Pygame. - GitHub - IrvKalb/pygwidgets: A collection of user interface widgets in Python for use in programs using Pygame.
can someone tell me what is wrong in this and thedifference
Which channel should I ask for help on some VBS code?
I want to automate checking process of google sheet if specific column updated then run colab notebook is there anyone knows how can I do this?
@austere tundra @heady dove @ocean mirage Hi all, this is a channel for discussion on how to teach, for python related help try the specific help channels or the help forum #❓|how-to-get-help
Might be something for off topic? Or a server that specialises in VB/MS languages?
can anyone help me in VARIATIONAL AUTO ENCODER. please ?
This channel is for discussion on how to teach, try #❓|how-to-get-help 🙂
meh. Andragogy seems the more appropriate title for this channel vice Pedagogy.
The meaning of the word's constituent parts in the source language doesn't decide it's meaning in English. "Pedagogy" can and does refer to the practice of teaching in general
I just love when they drop a stack of code first ask questions later 😂
love? in the air?
really guys really 😂
Hi everyone. I just started solving problems on leetcode and i can't solve any of it without looking at the solution, and even when i see it, i barely understand it and need like hour or three to repeat that code without watching. Is that okay to learn like that, or i should learn some more theory before, so at least, i can have some idea about how to solve the problem when see it?
you might be doing problems that are too difficult for your level of knowledge.
perfectly fine way to learn, take 30 minutes on your own then look up, try to understand and implement if u couldnt crack it
should supplement with books etc too so u dont go insane
Hello people! Can someone help with the script? It has a class class WM_OT_popUp(Operator): it should display a list of collections. I am trying to define this list when declaring the col_list variable: EnumProperty(
name="Collections",
items=lambda self, context: self.refresh_collections(context),
)
I tried in this way [(c, c, "") for c in [c.name for c in bpy.data.collections]], but in the first case the function is not called, and in the second return [(c.name, c.name, "") for c in bpy.data.collections.values()]
AttributeError: '_RestrictData' object has no attribute 'collections'
In general, can someone explain how to define a list and each time the button is clicked, update the list of collections so that it remains relevant for selection.
Here is the actual problem area:
class WM_OT_popUp(Operator):
...
col_list: EnumProperty(
name="Collections",
items=lambda self, context: self.refresh_collections(context),
)
def execute(self, context):
...
return{'FINISHED'}
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self)
def refresh_collections(self, context):
return [(c, c, "") for c in[c.name for c in bpy.data.collections]]
This channel is for discussion on how to teach, for help try #❓|how-to-get-help
thanks
!ot try the off topic channels for off topic posts
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
Eh I'm good
@tropic depot I've deleted your message since your post does not have anything to do with this channel's topic
Uhm, I'm a little bit 13 years old and am currently teaching python to two 13 year-olds; one of them is a boy and he is not too much of problem, the only problem is that it's hard for him to switch from Pascal, but I also am teaching a girl, she recently decided to try programming, and I recommended Python since I think it's the easiest to start from, because if she were to learn Pascal syntax it would be pain I think, so for now I gave her the "Automate the boring stuff with python" book and am not sure how is it gonna go, because I had a problem when teaching her chess where she was like "wow, this is quite complicated, why would I need that?" and even if I explain why she needs that she forgets it in like 2 days; I am also not sure about the practice, because you can't learn to code without practice. Now I'm even thinking of telling her to stop learning programming lol
I wouldn't tell her to stop
additionally, asking questions shows that, at the very least, she has some degree of interest in the topic
as for retaining information, a lot of that is done through doing actual projects
hands on practice, that kind of thing
I believe ATBS has practice questions at the bottom of every chapter, you could have her her do those and go over it
Pascal is a great introduction to programming. Its easy to learn
although, do try to have fun with it
When i was at your age, i was studying in school. I went in a pregaming channel, and everyone laugh at me for keep using it. Now in my country they stopped teaching it. You can tell your friend to start with Basic and Pascal" if he likes it he can go and learn pyhton, java, c 🙂
My friend wants to learn Python instead of Pascal, it's just that it's hard for him to start, he still codes in Pascal
thanks for that info, will apply
Im working on an Ai/ML project, that obviously uses Python. I am making a website where this AI/ML will be used. Should I do the backend with nodejs or would it be a better option to use Django for the backend??
up to you. because even though django would ostensibly let you have the model loaded in the same interpreter as the site, you'd probably get better performance having the model in a container.
I just realized we're not in #data-science-and-ml
this channel is for talking about teaching techniques, so please make sure all your messages are about that.
its not a really ai question is just about how he should approach this project
it's more about AI than it is about how to teach programming.
How do I teach a coworker who has a cs degree from 2 years ago but has lost all ability to program. When we peer-program, it ends up with me verbatim telling him what to do like I'm talking to Siri or Alexa and his mind shuts off. If I try to give him a small task he's completely lost
fair enough
are you using a language that they never used as a student, or what?
It's python, and it seems in the last two years of the job, he's not had to do much programming. I'm relatively new to the team. He's just seems to have forgotten it all. It's almost like I want to tell him to go read tutorials or something
to me, this sounds like a problem for management to solve. but idk the dynamic of your workplace.
Talk to your supervisor. Don't try to solve this on your own. It's not a technical issue; it's a personnel issue. Just be polite and say that pair programming sessions are not going very well.
of course
7.3. The assert statement
Assert statements are a convenient way to insert debugging assertions into a program:
assert_stmt ::= "assert" expression ["," expression]
``` The simple form, `assert expression`, is equivalent to
```py
if __debug__:
if not expression: raise AssertionError
```...
does someone knows how to add existing data base in visual studio
Have you considered that he may never have learned programming in the first way and bullshitted his way through the interview process?
I'd try to gauge skill level with some tasks like fizz buzz or some of the early cs50 exercises
but tbh if it's that bad it sounds like an issue for management seeing as the cost/benefit ratio of you teaching him is unlikely to be worth it
Hi guys, I'm a multi-language begginer/intermidiate developer. Lately I haven't done many programming projects but the things that I can do without stopping is interpreted programming languages, I find it really fun. I am trying to get some young and old developer to contribute on a project that I am making wich consists on making a programming language together and everyone helps eachother. Even tho I know some will ruin it I wanted to try. Any tips on how to get the people and start a community? DM if interested.
There is a discord server for programming language enthusiasts, as well as a subreddit
https://www.reddit.com/r/ProgrammingLanguages/
In the "related online communities" tab there is a link to the programming languages discord server
Also I might take a look at your project myself since I'm interested in programming languages ! You can dm me if you'd like to talk about it
I've been trying to come up with projects to work on with the beginner I'm teaching python to. Ideally it should be something :
- That has an appealing end result, something you can interact with in a fun way or that looks cool
- Satisfying at every step of the creation of it, you'd be able to see the project come together gradually at a decently fast pace : add a few lines of code, launch, see more cool stuff happen, repeat
- Expandable upon : my student should be able to easily tweak the code, add features, change values while I'm away
- Not too hard : should be relatively easy to implement without complicated algorithms or data structures
Something like a little game or cool visual effects
Any suggestions ? I'd appreciate them very much !
i think hangman is a great game for beginners
it's simple enough that all it takes is an understanding of a game loop and some string manipulation, but there are many directions to expand it: ASCII art, actual graphics, increasing the word pool, writing an AI for the computer to play against itself, implementing "worst case" hangman
I think hangman is a good idea, we'll try doing that next
Thank you for your suggestion !
i also like games with 2D boards to teach how to separate the backend representation of state from what is displayed to the user
heyyy guyss
I got the assignments due and dont know how to do this assignment
can anyone help me
This channel is for discussion teaching methods. Check out #❓|how-to-get-help if you need help with something
meow
do you guys makeup ur own questions or is there a site that i can use to snag some questions for my students
Ah good idea as well, thank you very much
can somebody help me with python code?
give me a GUI which allows me:
- select photos (multiple)
- select excel file
- input selected photos in dedicated cells A8, D8, A10, D10, A12, D12 so they fit the cell size (it will be default).
- in case of selecting more then 6 photos, copy the sheet and continue inputting photos to mentioned dedicated cells.
how can I d this?
this channel is for discussion about how to teach computer science, but you can find out how to open your own help thread in #❓|how-to-get-help
Can someone suggest websites or videos, how to build my own python projects to practice python?
!resources But this channel is for discussion on how to teach. To get help try #❓|how-to-get-help
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
I tend to make my own
this channel is for discussion about how to teach computer science, but you can find out how to open your own help thread in #❓|how-to-get-help
I am reaching out to you because I am in desperate need of help. I have been struggling with version conflicts between packages for a while now, and it has become increasingly frustrating. I spend hours trying to find the right version of a package, only to have another package not work properly.
I am looking for "THE SOLUTION" to this problem. I need to be able to use an tool that has the latest version from September 2022 and another tool that has its latest version from 2023. Even after finally being able to install both packages without errors, when I try to import a class, it often leads to conflicts with other packages.
My question for you is, what is the solution to this problem? Are there any tools that can check if multiple packages work together? How can I finally put an end to this issue that seems so basic but has become such a hassle?
I would be grateful for any help or advice you can provide.
do u use virtual environments?
if delete my main python folder and reinstall, and reinstall each packages venv its not obligatory no ?
i testing with venv, i tell you
yeah problem, u fixed, but i dont understand how take packages i want without conflict version in the future
@loud charm thanks :DDD, i always have "AttributeError: module 'spleeter' has no attribute 'Separator'" on my flask website, but gg you fix a conflict package
ok ok
u should always use a venv for every project to avoid conflicts
understand!
np !
my other problem, your have idea :
in .py
from spleeter.separator import Separator
separator = spleeter.Separator('spleeter:2stems')
separator.separate_to_file('audio_file.mp3', 'output')
and web site show me : AttributeError: module 'spleeter' has no attribute 'Separator'
@loud charm if you have time, else dont worry
im afraid i dont know the spleeter library sorry
haha dont worry thanks also ❤️
okei np ❤️
this channel is for discussion about how to teach computer science, but you can find out how to open your own help thread in #❓|how-to-get-help
Hello everyone! if you want to level-up your problem solving skills and become good in Data Structures & Algorithms, then you have my DSA channel where you can find Video Editorials of Coding problems and important topics of Data Structures, Algorithms.
Do Subscribe to the channel!
Learn about Linked List Data Structure and win your technical interviews.
Question link: https://leetcode.com/problems/lru-cache/
Like, Subscribe and Share!
#dsa #linkedlist #coding
this server isn't a place for self-promotion. Kindly remove your message
Hi everybody. Can anyone help me? I'm doing a project for a school based on a type of survey, and I want questions on a specific subject to appear when a button is clicked. Doing it on tkinter
@viral panther@buoyant ledge@glacial iron
this channel is for discussion about how to teach computer science, but you can find out how to open your own help thread in #❓|how-to-get-help
Can anyone give me feedback on my guide? https://replit.com/@CataclysmTech/Python-Beginner-Tutorial?v=1
I understand their are typos and misphrasing, but I'm not sure which ones they are
the only valid thing posted so far
Given the frequency of off-topic messages and programming questions in this channel, we have renamed it to #pedagogy. Kindly do not respond to any prior messages in this channel that are not specifically about teaching and programming education. Please direct any comments about this change to #community-meta, and not this channel.
I guess to kick things back off: one of my instructors has a policy of only posting the slides for a lecture after the lecture has taken place. I assume this is to encourage people to attend the lectures, but I wish they were available in advance so that I could look over them ahead of time and write on them on my tablet. What do other people think about this tradeoff?
How does it encourage people to attend lectures?
I have seen lecturers do this because it gives them the opportunity to correct typos or other mistakes in their slides.
hmm well, you can always send out an "errata"
and on the other hand, advanced students can point out mistakes and typos before the lecture even begins
Also, it gives them more time if they don't need to make the slides available in advance. I did once give a lecture where I made a final edit to the slides about five seconds before starting the talk.
When I did PyCon talks, I would publish the slides ahead of time and put a short-link to them in the footer of the slides so that people could get them during the talk if they wanted.
as a person with questionable vision, I do appreciate that 🙂
What I've seen some of my lecturers do (though not necessarily CS ones) is to have two copies of the slides released. One set before the lecture with the slides but not answers and whatnot (leaving the slides blank). During the lecture they'd write stuff on the slides. Afterwards they'd make the final version available with answers.
one of my profs publishes all code examples they're going to use beforehand and encourages us to review them. i don't think there's any incentive to not do that. the attendance thing doesn't really make sense. if someone wasn't going to go because they could see the slides, they would still get the slides, just later
Students aren't always that mature.
There is a non negligible set of kids who would think they don't need to attend it anymore since they got the slides.
Not that it would prevent them from getting access afterwards, but it keeps them on their toes
I think the worse thing is when lecturer doesn't give the slides and doesn't allow people to take photos of the slides during presentation... Had one like that.
Lectures were not obligatory at my course. 🤷 So the number of people going actually showed whether the lecture was interesting and at a good hour. Like there was one lecture where only <20 people were present after a few weeks... From a year of slightly below 120 students
that's also a reason for some of the drop out. College/University do give a lot more freedom than high school and some folks aren't equipped or mature enough to handle it
I dropped out because of burnout and my mental health declining so much I basically couldn't do anything. There are more reasons to what you're saying. From reading stuff on social media, it seems situation like mine is really common with undiagnosed neurodivergent folks
I never said that's the only reason either 😉
I'm indifferent. I skipped many courses though and instead just read the text book myself. Some courses I had to goto class though bc the professor wasnt explicit enough on what chapters and sections to focus and trying to read the whole chapter would result in a lot of wasted effort and bad time management
matplotlib?
please do not respond to messages that are not about pedagogy. please use @viscid mural if you have a question about this.
@pure heron How would you approach the concept of "variable"? Would it be the first thing ever to introduce after "Hello, World" and data types, or immediately upfront then data types then "Hello, World"?
Same with "good coding practice". Do we just let people code, or we immediately introduce good practices as we go along the course?
I start teaching Python from a REPL, showing values (and data types) first, then function calls (to introduce print and Python scripts), and then teach assignment and variables
I think it depends on the practice. For things like camel case vs snake case or tabs vs spaces for indent, I teach them the recommended way right from the start, and mention that it could also be done the other way but that it would be unusual. For things like sorting imports or using Black or adding type annotations to functions, all of that can wait for a long time after they get started. Basically, I try to introduce the Right Way when I'm introducing a concept, I guess
And of course we whip up some intentionally bad code to show what not to do?
Possibly. Depends on the thing. I do a "is this a valid variable name", for instance, and I include a camel case name, and point out that it's valid but not preferred
I see. Thanks for your input geek
oof
I'm wondering what people think about the pedagogical approach of this book: http://www.composingprograms.com/
It's based on the classic book Structure and Interpretation of Computer Programs, but uses Python instead of scheme.
It builds up an understanding of the evaluation, execution, and data models of python in an almost axiomatic way.
Its intended audience is computer science undergraduates who've already done a bit of programming.
i kinda like it. given that i'm the target audience, it seems that do pretty well 🤔.
there definitely is some level of mathematical/intellectual maturity required, i.e. it's quite rigorous. the embedded things where you can step through code are very nice
i think the rigor is a good idea. as long as the reader has the math knowledge needed they get a much better understanding of programming, especially the designing larger programs part
Hi guys, next year (winter 2024), I will be teaching scientific programming which is an introduction to programming to first year college students. These kids are in general science program. I'm already looking for material.
Is Jupyter Notebook a good platform to teach basic programming without the hassle to install software on every laptop?
Notebooks are a double-edged sword. They're nice for beginners because they can see the result of what they're doing as they go along, which if nothing else makes the experience more satisfying. But people who program for the first time in a notebook often begin to think of them as the default way of writing code, which can establish habits that run contrary to code maintainability, reproducibility, or modularity.
(Notebook users are also more likely to post their code or error messages as screenshots, which is really annoying, because you can't copy the text out of them.)
if you need an online editor, replit is probably the best. they even have easy "share link" things to check code if you need it
That is what I'm thinking. But the goal of the class is to teach programming basics to students who most of them will not undergo into a programming cursus later.
you said they're in a general science program. is the goal for them to be able to use numpy and pandas in their subsequent courses?
Not really, most of them they'll go into health related program and about a quarter will go into STEM.
then I wouldn't use notebooks. like public static said, replit is a good online editor/runner that should suit all your needs.
I'll take a look at replit. Is there an offline version or I should just install PyCharm?
pycharm is intended for professionals. it has tons of features that beginners not only won't know how to use, but would find confusing and overwhelming.
For beginners I'd strongly recommend Thonny (https://thonny.org)
Though it does need installation
i use this in school it helped me to start of with!
That is another tool, I'll need to check
What is the simplest Python IDE that can be quickly installed on student laptops, and that makes it easy to install and use modules?
thonny? It ships with python bundled as well, so you wouldn't need to install it.
Are pandas, numpy and matplotlib installed?
no, but all you have to do is pip install pandas numpy matplotlib
I know, but for a classroom full of k12 kids, command line is quite an adventure.
@vale current does Thonny have a package manager a la pycharm?
it's probably just as well that you use replit, though.
There seems to be one
it does, yes
Thanks, Thonny might be the path I'll take to teach python
Mixed with Jupyter Notebook for notes.
Why "for notes"?
might be a bad translation from my side. More like "sharing documents" for my students and playing around with live code.
Will they have assignments where they need to submit py files? Because I wouldn't want them to get too used to notebooks.
They will need to eventually submit .py files. Why would not go with notebooks? Isn't that a good way to explain code and comment on results.
Some notebook natives don't know how to write or run code outside of notebooks, let alone articulate how a notebook is different from a regular py file. But I suppose it's fine if you use both.
It's my plan to use both. I have no intent to go deep into Jupyter, more into Python and its concepts.
Another issue is that to get the visualization effect from notebooks, you have to expose whatever you want to visualize to the global scope. Which is antithetical to modular programming.
I totally agree with you with this
Which is antithetical to modular programming.
But as I stated earlier, the purpose of the course is not to train future developers, but students who know what is programming and in which case it can be useful in there studies.
That's fine, I guess
@loud valve Just realised, this channel is a good place to ask about the thing you were asking about yesterday. Just in case you didn't know it was here.
what did they ask about?
They were asking for good programming exercises to work on with engineers to turn them into software developers.
thinking of doing code clash for my students might be fun what do u guys think?
How old are they
what is the context in which you have these students?
they pretty old also @misty dirge i dont understand what u mean
they first started by knowing nothing about not only python but computers
is this a university course? for what major?
its just a normal course
at what kind of institution? for who?
institution
yes, what kind?
wym 😭
im doing a course on the basics of python programming
is it a high school course? a course you teach on the weekend to people who sign up for it? what?
i teach 2 times a week total of 4 hours anyone older than 16 can sign up
but all my students are like 40+
double my age
the people who sign up for your course, what do you think their motives for doing so are?
some want to become web devs, some engineers and rest just personal work
okay, I had to look up what code clash is. but it looks like a league where people form teams and compete? are you wanting your students to do that, or do you just want your students to solve the problems posed in previous seasons (if those are available)?
ok so basically we where playing code clash in this server ( i also didnt hear of it till yesterday) and essentially we try to solve problems 1. as fast as we can 2. as short as possible and it was amusing
but i just want my students to try and solve the problems as fast as they can
they dont have much confidence i tried to make my own questions they are getting somewhere
but they just dont try and im not sure why so i want to try and make it fun
why "as fast as they can"?
so they can really try and focus on solving the problem
the issue for me is that they tell me the answer
but get confused when i tell them to write it
and i really try to pin point the problem
but i honestly dont know what the issue is apart from them being fairly new
i walked them through multiple times on how to 1. analyze a question 2. how to come up with a solution 3. how to debug 4. how to solve errors
i spent atleast 3/10 lessons on those 4 points (each lesson is 2 hours)
I'm not sure if this is the correct channel to ask, but I recently got accepted into a college for Computer Science. Theres a section in the course that says you can waiver the introduction to programming of a specific language if you already have extensive knowledge in that language (an exam). Does anyone know what that exam usually consists of? Like is it really language specific in the case for python, OOP, functions, imports etc or is this more like conceptually?
The only way to be sure is to ask the college if they have a description of the exam. You should email the department and ask for copies of the old exams. (In most circumstances they will gladly provide these on request.)
I agree with Kyle's answer. The only way that I've ever heard of introductory CS courses being waived is by having taken the AP computer science exam in the US.
Introductory CS courses being like the actual computer science component? Or the language part of it
The section about the waiver references C++, Python and JavaScript as introduction classes you can waiver with the exam
Thank you very much, I will look into that
the "introductory" course for my undergrad CS program was only about programming. Am I to understand that in your program, the first course that you take is one of three options, "Intro to programming in {C++, Python, JavaScript}", and that you can get that first requirement waived via an exam?
Yes the first requirement can be waived, it says by getting an 80% or higher on the exam will allow you to opt out of the introduction class in that specific language
My guess is that this course covers programming basics like loops and conditionals. These can be learned equally well in any mainstream language.
Most likely something like that, I was only a bit concerned because it says on the site that, "The exam consists of programming tasks that will usually take several hours"
Ah you mean the thing on Codingame? (https://www.codingame.com/multiplayer/clashofcode)
Yess
Hi your message has been removed for being off topic and not relevant
Check the channel description
Does anyone have experience of using the PRIMM methodology? I used it a while ago but now i'm less sure about it. Interested to hear experiences.
I guess no one has then!
The only named teaching technique along these lines that my instructors used was POGIL
I had a phone call with Sue (highlighted there) about 3 or 4 years ago when she was developing it all and it was interesting to discuss her findings and research aims.
i'll look up POGIL - I haven't heard of this.
I'm always fascinated by approaches to teaching programming. I think it is a very difficult one to get right
@golden stump it was basically just group worksheets
hmmm - primm is a teaching methodology
one of the principles is that typing in a heap of code is not part of the learning process
but making predictions about existing code does help the learning process
could you explain what PRIMM is about? i've never heard of it
it's short for... predict, run, investigate, modify, make
so you wouldn't do all these stages in a single lesson
but you'd start of a topic with some prediction
and it requires that students look at some code and predict what it will do
and find out after RUNNING whether they're right
investigate gives some chance for trying things out in order to understand what the code does
my big bugbear with it is that students can't be bothered to do the prediction bit
i am profoundly lazy when i'm learning with the "predict" part, and suspect if i put more effort into that when learning new things i'd reap more benefits. would you say your students that actively work on the prediction part level up faster?
how do you deal with impatient students that practically spam iterate different things to try
of those two, Python Crash Course is already on our list of recommended books. (link in the channel description.)
what is the purpose of teaching beginners how to use type hints?
is it obvious what exactly it means, or are people just blindly copy and pasting the code?
I like for beginners to type hint their functions, because I emphasize thinking of each variable/argument/etc in terms of what it represents, and what it is. Which is its type. I see a lot of beginners who will write long winded explanations of what their functions are intended to do at some nebulous level, but they can't articulate what the inputs and outputs are.
What is it about type hints that you think is especially prone to blind copying and pasting? I'm not quite seeing the connection between the first and second parts of your message.
i'm mostly just talking about the syntax, is it immediately obvious what x: int or maybe x: Union[int, str] means to somebody who might just be starting out?
I don't think it's any less clear than how types are conveyed in the function signature syntax of other languages. Union would not be obvious to a programming beginner.
beginners will not always know other languages
I think they're self-explanatory for built in types, if you know what types and functions are.
I know. That's why I said "programming beginners".
i see, i will have to learn more about pedagogy tomorrow it's an interesting topic
Tomorrow, you will have to decide if python is a good language to use for learning algorithms and data structures.
@stone juniper knows what I'm talking about. We're so good at pedagogy.
?
You know sorting algorithms, hash tables, Dijkstras, etc?
a little
i’m not good at anything math or algorithm related honestly lol
@misty dirge what did you mean?
sorry, I was asleep. computer science students always take a course on algorithms and data structures, and some of the data structures (and by extension, the algorithms that use them) are nearly hardware-level abstractions. so something we've debated in this channel is if Python is a good language learning how those algos/data structs work.
For example, when we talk about how long sorting algorithms take to execute, we assume that the amount of time it takes to access or overwrite any index of the array is the same. Which means that you're already abstracting the RAM.
by RAM you mean random access machine?
random access memory
most time complexity calculations assume a random access machine where the memory is just an array
I see. yes, memory as one big array is what I had in mind.
This subject is always something that's interested me because ever since I started taking classes on computer science the professors/teachers almost always weren't the best at coming across to their students
I also hate how professors dont even obey variable naming rules most of the time
which rules are you referring to? in what language?
Python mainly. Professors tend to ignore snake case rules all the time and constantly use one letter variables
one-letter variable names are fine in some contexts. especially if you follow conventions like i being an int that is an index, c being a one-character string, etc.
Yeah but from my experience professors normally use one letter variables for most situations which is where the problem occurs
I've also never had a teacher who uses type hints
I'd rather have a teacher not use type hints than have them use type hints, but mislead students into thinking they do more than they actually do.
naming conventions are pretty mild on the spectrum as far as teaching errors go
more egregious would be like, range(len(...)) loops as default or something
Yeah I do agree it's just something that's very easy to notice
Also I kind of disagree. Not really for small programs because they're not really needed but for larger programs where you're dealing with multiple different data types they do help
Especially if you have an IDE that requires type hints to give you suggestions
I was helping someone earlier who said they had to use range len because "we haven't learned for each loops yet". It was the worst thing I've ever experienced.
Eww
would python crash course 2nd edition (I think its a 2019 print) still be mostly up to date for starting out with python?
it appears that the book uses python 3.6. the latest version of python is 3.11, but none of the additions to the language since then really impact beginner code. so it should be good to use.
interestingly, 3.6 was the most recent version that I think does significantly impact beginner code, because of fstrings.
For a beginner it should be fine.
The projects at the end of the book may be a little out of date, since they require some external packages. But it looks like the basic Python language features described in the book haven't changed.
what books are you thinking of using? @void rain
Ok thanks, i’ll take a look at that one as well!
I have a friend whose trying to throw himself in programming properly. He has decent knowledge of bash, python, C++, and Java, but he's not really above a novice level programmer in any of those languages.
He's been thinking of going into leetcode to teach himself, but I've heard mixed results on it. Are there any alternatives he should shoot for? He does much better when he's given guided instructions and then given a "solve it yourself" problems
leetcode is mostly just algorithm and data structure exercises
i think it's a good tool for practicing but i wouldn't say it would teach you more python
Trying to figure out the right vocabulary to use when explaining some Python stuff.
In f(x,y,z=None), I believe that the term used everywhere for x, y, and z are "arguments", at least at the callsite. But if you look at a good amount of Python docs, for the definition site of functions a lot of docs mention parameters.
Has there ever been a big debate/decision on this?
When they are inside of the function definition they are parameters
The variables values being passed to a function in a call are arguments
def func(parameter1, parameter2):
return parameter1 * parameter2
argument1 = 5
argument2 = 8
result = func(argument1, argument2)
I think the impatient students tend to be lost more quickly. They think they know what's going on but then find they actually don't.
Thanks for the help (a bit ashamed or shows up so prominently in the Python guide!)
the same for methods?
Hello, i am an engineer in coputer science and i have been teaching kids to code, they lately suggested (kinda forced me) to do AI related exercices but they dont seem as excited as before about it.
I come to asl of it is the right thing to do or should i just oppose the idea and stick with normal matrix calculus etc.
how young are these kids? because any "ai" that you can do with people who haven't done university-level math probably wouldn't be considered ai by current ai practitioners.
From 14 to 17 they are just in discord.
I teach as a side hustle.
I mean i show the the theory and make them do the application like linear regession and stuff like that.
at one time, I was planning to do a data science workshop on this server, and my plan was to go over tabular data manipulation, and basic statistical models that you can pull off the shelf of scikit-learn.
strictly speaking you can make one without understanding nearly anything about math other than small error good
getting actually good results, as well as properly understanding how it works, are different topics
I totally agree.
And what happened to that ?
I didn't end up doing it.
Postponing king.
Do you organise courses here ?
Nope. We curate a resources page and have a help system.
Thanks for the information, have a great day.
I don't know that I said anything particularly insightful.
You can always take something out of a discussion.
Any tips for creating python exams for students to take in class? I’ve always done like take home projects or similar and I’m worried about creating a test that students can actually complete in 2ish hours
what material does the exam need to cover?
It’s an intro to python course with some data analytics thrown in. Think data types, structures, functions, conditionals… pandas.
* describe the difference between
** an instance and a class
** an int and a float
** "4" and 4
** a list and a dict
** a list and an array (if you're using numpy)
those would cover types reasonably well.
for functions and boolean logic, you could have code examples with print statements, and ask them to say what would get printed for different inputs.
I don't have any ideas about how to examine people for pandas tbh.
maybe you could give bad pandas code with loops, and ask what pandas methods they would use to rewrite the code without loops.
I know it probably sounds stupid but I didn’t even consider like set questions haha. I should mix some of those in.
you mean questions about sets? because those are python's most underrated data structure. 
Haha sets are great! But I meant like straightforward questions. I structure most of the homework questions to be things like “create a function that takes in a data frame as an argument. Function must return XYZ of the data frame” or something like that. Having them code out problems is always the goal for the homework, of course.
given how dynamic pandas is, I think it would be kind of unfair to ask them to write the pandas solution to a problem with just pencil and paper.
Oh they will have computers haha. Just the exam has to be in class, 2 hours to complete
Sorry if I have the wrong impression
ah. I didn't take any CS exams on computer until covid started.
The thing is with past take home projects… some students finish them in 1-2 hours and weaker students finish them in 10-12 hours. Not exactly ideal to find a balance between the two
what do you know about the 1-2 hour students as compared to the 10-12 hour ones? do you think they had prior experience with python, or programming more generally?
Really?! Huh! All of my coding exams have always been on a computer even when I was in grad school save for 1 SQL course (which was total shit writing out sql by hand)
Varied backgrounds for sure. Grad course with no prerequisite so no real standard cohort
Yeap!
@misty dirge I'm so sorry I'm new to Discord. Thanks
No problem. I suggest reading the channel description at the top of each channel before using it for the first time.
@misty dirge Thank you
Where do you think the line should be drawn between correctness and practicality?
For example, to say reference counted GCs will have a problem dealing with cyclic references is correct. To say that python suffers from it since it uses the same model is not. And going into the details of it all is maybe unnecessary? How would you present this information?
- is it the main subject of the discussion, or merely a tangent?
- how likely it is that the learner will use that knowledge or learn more in depth about that topic later?
if it's a tangent about something that they'll never touch, I would probably not be too fixated on correctness
if it is actually relevant to a project they are working on, you might want to avoid overloading with details, but keep the boundary between "how things actually work" and "imagine it like this" clear enough to avoid causing more issues
(there are also some other factors you may need to consider like overall programming experience/knowledge but I'm not gonna go overly detailed on all possible factors)
Say if you were just teaching how memory management works in python, then?
Right, so perhaps the question is, how much should be taught vs how much of it should be left as an exercise to the reader?
like should you aim for 100% correctness, or perhaps are some things better left as black boxes...
I'm not particularly knowledgeable about memory management myself, but it does sounds like you might want to at least mention on a high-level view how python works around that issue (note: I have no idea myself)
@deft cargo did you want to talk to me here?
@sick current Courtesy ping
I'm planning to (again) write a series of blog post trying to teach Python, as probably numerous of high-visibility people in the community have (idk, I'm spitballing). Thing is, I don't know whether I'm qualified enough to be teaching people. I know (some of) the good practices, I'm fairly confident about my ability to explain things, and I have written projects (though everything is half-arsed completed) so I know my way around some tooling and DevOps. The kicker is that I'm not from CSE (Com Sci & Eng), I don't have deep knowledge into Python nor any topic. I picked up Python and Google as I go, getting feedback from mainly PyDis and self-teaching bits and bobs that I need.
you should have reviewers that knows the details better.
so a technical review that looks at the programming details
you can add on reviewers for the written parts as well
you can also have reviews for the scope, like a tutorial about how to use venv is great, but without meantioning virtualenv pipenv poetry and conda and why they differ are giving people the wrong information even though it is techincally correct
Understood. I have also written an introduction as a way to combat writer's block. I'll export through Hugo later, can I have your glance at it then?
you dont have to feel like your not competent to teach @deft cargo you can offset that by having others help you to review
yes, you can share it with me if youd like
I'll keep discussions public then, my pitfalls can be of help to others
@sick current I'm back from the depths of reality
Do you take ngrok links? I'm behind a VPN of course, and everything is just raw Hugo
It sounds like whatever is being discussed currently depends on context that only PyTH's Alt and eivl know about. If the conversation is about methods and practices for teaching, try framing the discussion in a way that anyone can jump into.
@misty dirge Ye, it was 03:43 local time and I thought eivl was still at his computer, hence the ngrok
I'm trying to figure out how to host the bugger on GH just so I don't have to rely on ngrok and a VPN to make sure ngrok doesn't leak my IP
If this isn't a discussion about methods and practice is for teaching, please move to a different channel
If this is just discussion between you and eivl about a project you're doing, but you don't talk about methods and practices for teaching, it doesn't matter if the project itself has to do with teaching. This is a discussion channel, not a planning channel.
Aight
answer to somebody's question to add no's divisible by 3 and 5 in a given range by user and get their sum:
m=int(input("enter the starting number:"))
n=int(input("enter the ending number:"))
o=n+1
l1=[]
for i in range(m,o):
if i%3 == 0 or i%5 == 0:
l1.append(i)
lsum=(sum(l1))
print(lsum)
This channel is for talking about methods and practices for teaching.
Got it
Hi there, looking to help teach 13/14 yr olds programming. What are some recommendations you all would give for do/don'ts and some ideas on how to best keep their attention?
Every lesson at least once, make a joke or do something fun, even if just for like 3 minutes in the middle, to keep them active
Then also, give them access to the PowerPoints and documents you teach them with, as long as they don’t contain the answers
Bc some of them may find it easier to read it themselves if they don’t understand
Hope that helps a bit
Is pomodoro technique useful for programmers?
it depends on the person and how they work imo, but I'd say give it a couple of tries and see if it fits you
I don't personally use it, but I know a few people who do and they find it helpful
use what you feel comfortable using
Some people like doing bigger breaks, some don't
Some are working machines and don't need rest)))
Is this any good, or is there something better (for Data Science)? Any good statistics courses on Coursera?
I'm currently wanting to write an introductory book/tutorial on Python for beginners. I am a bit stuck on the order in which I want to explain topics. The main problem I have is that explaining a topic fully requires the understanding of some other topic, which sometimes requires the understanding of the initial topic, like a cyclic reference.
I am currently thinking of the following order of the first few chapters:
chapter 1: basic data types (ints, floats, booleans), and item assignment
chapter 2: strings and string manipulation, also covering input and print more in-depth.
chapter 3: if statement and while loop
chapter 4: Custom functions
chapter 4: data structures (lists, tuples, sets, dict)
chapter 5: for-loops (how to use use them with sets, lists, dicts etc., maybe also covering zip and unpacking)
Any opinions or suggestions? (hope this is the right channel for this)
I think data structures a bit earlier? And for loops after if statements and while loops
I also want to focus a bit more on common pitfalls, like in automate the boring stuff they explain item assignment as a labeled box with a value in it, which could result in some common errors where multiple variables refer to the same list f.e.
I chose to first cover data structures, to have a more intuitive understanding of what a for loop does, which is iterate over some iterable. That way also making it more intuitive to understand f.e. for i in range(...): as range is just some iterable like a list.
Then maybe a chapter all about iterators?
Inbetween while loop and for loop?
Instead of just for loops, extend it to all iterators
hmm maybe custom functions after data structures and for loops; and does string manipulation need to be that early?
Yeah It's a bit early :/ So rn I'm thinking
1. basic data types (ints, floats, booleans, **strings**)
2. if statement, while loop
3. data structures (lists, tuples, sets, dicts)
4. string manipulation
5. for loop
6. custom functions
Something like this
I'm not sure if strings should be a separate chapter, there is just a lot of methods to discuss making me think I should
honestly I don't think string manip needs a chapter
mm, what would that consist of? It'd be nice to go over what iterators and iterables are, but I feel it'd be somewhat out of scope for that chapter to get into writing them, especially since I'm assuming they won't have had an exposition to classes at that point.
Yeah exactly, that is why i just want to explain some iterables, to be able to show how a for loop can be used, and maybe dive in further into the book
So where would you think would be a good location/chapter to explain strings and string-methods?
Yeah thats a good point. I just think that the loops should be together in a way
i think it makes sense to just do loops twice. part of the issue is that you're trying to fit concepts that are not python specific into how python does them
which i think is kind of a disservice. makes it more difficult to generalize (again imo)
Yeah, for loops in python are just a completely different beast than other for loops
So what about item assignment. In "automate the boring stuff" the writer explains variables as labeled boxes that you put your values in. This analogy works well for all immutable types, but when the reader has to understand item assignment for mutables like lists, this analogy would be confusing. Should I explain item assignment more clearly early on, or keep the more vague, but easier to understand box analogy, and later on adjust this view on item assignment?
variables as "boxes" was never a good metaphor. not even for immutables.
a = b = 3
is 3 now in two boxes?
I prefer the names and values explanation given by nedbat
yeah, i think approaching it as names or even pointers may be more sensible
I'm not sure they should be in a chapter by themselves. I would just throw them in with OOP and sprinkled throughout the other parts
Yeah I was thinking the same thing, I'll try and make some visualizations for this.
I wouldn't use the word "pointers" so they aren't tricked into thinking that they understand pointers in C. the visual that I like is variables as names written on sticky notes that are put on the objects.
fair enough. i do recall seeing some drawings with arrows showing the correspondence in the nedbat video, and i think that's pretty good
Perhaps, "references?" Variables are references to values (variable name -> value). Pointers are references too, but a pointer variable is actually a reference to a reference (variable name -> pointer (which is a value too) -> value).
(Mapping name to value)
hello
You guys think this is a good visualization/example for variable assignment?
that does look nice, similar to what https://www.youtube.com/watch?v=_AEJHKGk9ns and pythontutor.com use, just with fancier lines
i would prefer straight lines, but yeah it looks ok
though I am not sure how you would visualise a list in this format
pythontutor does it pretty well. i assume you would just have an oval with a list looking thing inside
Yeah it's a little wonky haha. I think having straight lines might make it a bit boring, but might be clearer. I think I would visualize it more like pythontutor when I get to lists.
It's just a rough proof of concept, I can make it prettier if I feel like the example is clear at least.
shouldn't line 3 be num3 = num2?
there's refcount and deallocation info missing in the explanation of figure 2.2.d but i think it should be fine for now
Oh good catch. And not sure what you mean with the second part, I'm not explaining garbage collection yet, just variable assignment.
i do not like it, because it makes it look like num2 and num3 are pointing at the same actual thing
they are
but if you increment num2, it won't increment num3
so they can't be pointing at the same thing
it's more complex than that
is this about pedagogy?
yes
because it makes a new int
sorry stelercus >w<
i mean - maybe i've been explaining it wrong then...
I think this visualization would be more effective for mutable types. Because any integer with the value 17 will point to the same object, but that isn't guaranteed for integers outside the magic range of cached ints.
so does this mean if i do...
num1 = 10
num2 = 10
num3 = num2
Will they all be pointing at the same object, or will num1 be pointing at a different "10" object?
If this is so, I'll have to change how I explain this. 😢
it depends. in cpython they num1 and num2 will be pointing to the same thing, but num3 and num2 are definitely pointing to the same thing
is there a way to tell?
yes, id
for variables that refer to instances of immutable types (like ints), the fact that the variables happen to refer to the same object can't have any runtime effect, except for using the is keyword. so there's no reason to ever check.
for variables that refer to instances of mutable types, it does matter. so it's better to only worry about that kind of thing in the context of mutable types.
cpython has an optimization where all integers between I think -5 and 256 (the actual range doesn't matter in this conversation) are pre-allocated when the interpreter starts, so any equivalent integer variables in that range will share the same object. But that is not part of the language spec.
the more i know, the more i don't know!
in one scope they don't even need to be range(-5, 257) because they're cached in the code object ```py
num0 = 5000
num1 = 5000
print(num0 is num1) # True
how does one explain the concept of vectorisation neatly?
my TLDR explanation is "vectorisation is basically the process of converting an algorithm/operation from operating on a single value at a time to operating on a set of values (i.e. vector, hence the name) at one time."
what if the other party says "but at the end of the day, you still need to iterate over each element in the vector to do said operation, how is that any faster?"
i am not sure how to answer that without going into SIMD and CPU caches which imo might introduce more confusion.
(context is trying to explain why my numpy aglo is faster in this thread https://discord.com/channels/267624335836053506/1087698863831400499)
it might help to distinguish between vectorization as syntax vs vectorization as an optimization. because df['col'].str.split(',') is "vectorized" in the sense that it represents an iterative operation over a batch of data as one expression, but it's not "vectorized" in the sense that there's any optimization.
what if the other party says "but at the end of the day, you still need to iterate over each element in the vector to do said operation, how is that any faster?"
If they want to learn more about how the computer works closer to the bare metal, they're certainly welcome to. But I think most students are content to know that "the operation is performed at a lower level".
right, that's good to know 👍 thanks
heh imagine shilling julia in python discord 😛
but in all seriousness, imo that just shows the student how to do it but not what it actually is
i think it's sufficient to say something like "the cpu can optimize this by doing a bunch of iterations at once"
Hello! I would like to start learning programming, but I'm not sure where to start. I know that I should choose a lx programming, I chose Python, and I would really appreciate if you guys could give me some advices/sources so I can start, bc for me is really difficult to learn something with a lot of information and I think it would be easier if it is possible to save some time.
Thx! 🙂
I'm in the same boat. Why not start here: https://docs.python.org/3/tutorial/index.html ? That's what I'm doing. Gotta start somewhere...
thank you!
Well, it was a starting point, but not a good one for me - after reading this for two hours I feel like I'll never ever be able to learn coding...
@modest prism @grizzled wadi this channel isn't for general python advice. it's for discussing teaching techniques.
resources on how to teach python? more specifically, how to introduce a person on programming using python
what is that person's goal in learning programming? (or your goal for that person?)
I want to introduce this person on the basics of the language and logic, nothing too elaborated/specialized. more of a generic thing.
and as the time progress, I'll be introducing her to more niche things so he can choose a specialization area.
I referred to The Carpentries resources a lot of time, but their context is more towards academia/research . Here's an example: https://software-carpentry.org/lessons/
I have just started learning Python myself. Learning the fundamentals via a 6h Python course from ‘Programming With Mosh’
Clever Programmer has a
12h course, lots of program building to go with it
you should include lists
If you're teaching a total beginner to programming,
I'd recommend starting out from the very basics of it - which boils down to critical thinking and problem solving. trying to come up with a plan/pseudo-code before programming.
as in, being "lazy" and not copy pasting 10 lines of code over and over.
as for the metarials - I'd say a bit of "solving" problems, with turtle¹; then sliding back to variable assignments, data types and functions.
¹not the programming part, simply making the psuedo-code for it.
A quick example,
Given a map and a turtle, which can only do 2 actions - Turn_Left, and Move_Forward
The turtle wants to eat the apple somewhere on the map (given a map with a set place for the apple) - get turtle to apple.
What instructions would you give it?
Now, some people, would just say to turn left 3 times, whenever they would want to go right ‐
Show them that they can simplify it, defining an alias for a set instructions;
Calling (new) function/instruction "turn right", that is just 3 left turns.
Then, it'd be much easier to "code"/give instruction(s) to the turtle.
(in other words - working smarter, not harder)
Please make sure that all your messages are about the methods and practices of teaching, or in response to a message that is.
if I may shift it on topic, what examples would you use to teach recursion? I know fib and factorial, but what are some other ones you might use?
bastard
merge sort is a good one
!mute 993918565063348324 "1 day" Please stay on-topic, don't argue with moderators, and don't call people bastards.
:incoming_envelope: :ok_hand: applied timeout to @weak mortar until <t:1680649821:f> (1 day).
yeah I think mergesort is good, though reportedly some people find quicksort easier to learn
algorithms that involve recursive data structures are popular as well.
you're saying that linked lists aren't useful?
it was mostly facetious. I think linked lists aren't as useful relative to how often they're taught
Parsing a tiny programming language (e.g. PL/0).
Search algorithms (on graphs). Solving the river crossing puzzle with it.
they're a great way to learn OOP, and you can compare their asymptotics to contiguous-memory arrays.
what's the river crossing promotion
A river crossing puzzle is a type of puzzle in which the object is to carry items from one river bank to another, usually in the fewest trips. The difficulty of the puzzle may arise from restrictions on which or how many items can be transported at the same time, or which or how many items may be safely left together. The setting may vary cosm...
oh with the farmer and the animals
Fibonacci may be overused, but it does mean the teacher can demonstrate the O(2^n) implementation that takes eons to compute the 100th number. When I was shown it I remember being impressed how writing such a simple function the wrong way made it almost useless.
I believe that making the backtracking have meaning in a not so abstract way helps a lot. Backtracking in a graph where each edge is an action has concrete meaning as "undo my move."
Getting a feel for going back out of the nested calls.
Graphs are also easily visualized.
by the grace of allah i shall bypass this mute
what about n-queens? i think backtracking is nice in general for learning recursion, but the issue is they're much more involved compared to fib or factorial
Yes, but make sure all your messages are on-topic now.
Of course.
Yes, but chess is already a bit abstract. I like these old school puzzles because they are often designed to involve real world objects to make it easier. They designed it the way that they did on purpose. Often giving it a story.
Also it may be motivating to see how programming might solve a real world problem, even if it's a trivial version.
This also leads nicely into robotics / it's easier to see how that could work.
It is possible to make a physical version with robots moving back and forth over a little river drawn on cardboard.
back in 6th grade we had the TI/lego somethings, which were fun little lego cars you could program. we had a big map with stuff to pick up and drop places or push things, etc
towers of hanoi is pretty classic
solving a maze via backtracking too
Only read this now. I show how assignment works in the first chapter. Then in the chapter on lists I can use the same visualization, to make it clear how this is relevant for lists as well. The whole reason I choose this visualization over "item in a box" is because of mutables like lists ^^
i am also self learning using Mosh course "complete python mastery" without any cs background. is clever programmer a good course to complete with the mosh course? thanks
Like I said I am still a total beginner, learning the fundamentals. I think you cannot go wrong with applying your newly learned skills to projects. Tina Huang and freecodecamp has cool python beginner projects posted on youtube. I am checking out automation projects out myself
ok thanks i will check out tina huang and freecodecamp
No prob, let me know how you liked it
I'm more than nob, gting to @modest urchin si far. Want to buold a api OS on Apache server, to usit on a tutorsbot"is copy rigth".🤣🤣🤣
Help
Ok
I'm a seasoned developer new to Python, and I came into it thinking it might be a great language for beginners. Two weeks a lot of code in, and I have to say, the way arrays and OOP work in Python are so radically different than most other languages that I would hesitate to recommend it as a learning tool. New, budding developers would absolutely handicap themselves using this as an intro to those basic concepts. In my opinion.
@calm haven keep in mind that python lists are not arrays, and they're not trying to be arrays.
but python lists basically implement the same interface as arrays in say, C, so i'm curious to see what you mean by "so radically different"
I've met people who think that pointers are a fundamental for all programmers, and that people who don't start with a language that has them are also "handicapping" themselves. do you agree with that proposition?
That's a very fair statement, actually. But it also reinforces my point, too. Any suitable learning tool should have a reasonably standard implementation of arrays (definition, handling, etc.) So while I can make use of Python and find it useful for particular tasks, I don't see recommending it to beginners. I'm really surprised by to be saying this, as I've heard Python touted as great for beginners VERY often over the years.
I think it's also worth noting that "OOP" is a concept and there's no centralized standard implementation, so different languages will implement it differently
I feel like pointers are more advanced technique, not for beginners.
what do you think is so valuable about heterogeneity and immutable-length that python lists not having them makes the language unsuitable for beginners?
I'm not debating the pros and cons of Python lists and it's basic OOP. I'm just saying that I've found them so radically different from other languages that I would now hesitate to recommend Python as a beginner's learning tool.
a beginner isn't going to be comparing two languages though. why does that matter? (besides, many languages have dynamic arrays, or vectors, like python's lists. JS's ven calls them arrays!)
But if you're taking the position that a pedagogically valuable programming language needs to provide arrays with a specific interface, what is it about that array interface that is so pedagogically valuable?
Because what a beginner learns on cements their understanding of the fundamentals. Or in Python's case, their MISunderstanding of the fundamentals. 🤣
Can you give some examples of what you feel are fundamentals for a beginner programmer?
Array handling should be somewhat similar to C. In Python, you can't do this: bufferArray = [10][2]
As I said before, Python lists are not arrays, and are not trying to be arrays.
why should it be similar to C? they're not learning C, they're learning python
I don't think the starting language matters (the language itself, stuff like being able to just make a new file and go like in Python matters a lot) (except for an extreme case like an esoteric language (as long as it's a reasonable language that is used a decent amount)), but a beginner should probably have a language like C (or another with pointers) under their belt at some point. The mental model of how the computer works on a lower level can save a lot of trouble later (without having to ever really dive into the details later, just being aware is enough).
So, maybe the way express my thinking is....
- I'm not being critical of Python
- Any language for beginners ought to implement arrays and a basic OOP/classes somewhat similar to C/C++
- Ergo, I could not recommend Python as a beginners learning tool
- I'm shocked to be saying this because for 10 years now I've heard about what a great learning tool Python is.
Any language for beginners ought to implement arrays and a basic OOP/classes somewhat similar to C/C++
This seems to be your core argument. Can you provide some more reasons for why you think this?
YES,
Sorry eat and run, but I have to step away for a bit.... It's OK if you guys don't agree with me, you're still awesome!
...and I will still be using python for some cross-platform utilities.
Feel free to elaborate some other time. We like when this channel gets used.
Or at least I do 😛
Right on!
I agree that awareness of lower-level details is important. Some people take the position that one should learn C/++ as a first language. Though I think it's important that beginners feel like they've accomplished something frequently enough to feel like they're making progress, and that C/++ would make that too infrequent.
Yes, C++'s issue is that getting set up, and using other libraries is a mess, since the language does not have modules (until very recently). And the libraries are needed to have interesting IO.
Unfortunately, the alternative (for C++), Rust, adds a bunch of extra stuff that is probably not great for beginners.
Like what?
The enforcement of strict ownership rules.
But I have heard that some like it as a beginning language, so IDK, hard to say. Probably does not matter as in my previous response.
i think rust would be better than c++ if you're going to start with one of them. better the compiler tells you you're wrong than discovering that your code doesn't work for some reason
What I do know is that C and C++ make it difficult to get to the part you actually care about, programming (first you need to learn about what a compiler is, Makefile, etc, etc). And doing interesting things with libraries.
I agree on that. Simply due to better error messages.
I wonder if I should take a hard look at Rust before committing a host of small projects to Python.
If you really want C I would recommend Zig or Odin instead. They are both effectively more modern versions of C, keeping the same style of simplicity, but removing a lot of foot guns and making it easier to be productive immediately.
If you want C++, Rust.
Hmm, it looks like you want OOP, garbage collection, and arrays. I recommend C# (better Java IMO).
Oh, do TONS of work in C, C++ and C#
I need to create some quick, handy, cross-platform utilities. So I thought Python would be a good fit.
Actually, I'm looking at PERL right now.
It's definitely good at that. And has a good book for it: https://automatetheboringstuff.com/
I haven't worked in PERL since the early 2000's, but used to be quite good with it.
No, these utilities must do a lot of file IO and systems and API integrations, in little bits. Both on Linux and Windows. I NEED arrays, some reasonably solid implementation of them, and a basic OOP that doesn't require passing a self reference everywhere and has overloading would be GREAT.
Why do you need arrays exactly? Is it for performance? The utilities part Python has covered, on all platforms, more than any other language.
I am now permanently of the opinion that a pedagogically valuable programming language needs to have literal syntax for some kind of hash table, and no amount of argumentation could ever convince me otherwise.
You mean like {"foo": 10} in Python?
right. any language that doesn't have dedicated syntax for hash tables is immediately and irredeemably disqualified.
Yes, I need arrays. I often read in things line by line from various, proprietary file formats. Read 3 lines, analyze, then read the next x line based on that. Read in lines 1, 3, 8, 15, 24 and check those. Quite often I build small tables in memory using arrays to direct the flow of function calls and their location.
I could go on and on
Yeah I don't see any reason not to have it if your language has a built in map type.
Built in types should usually have some literal associated with them, because you can, because it's built in.
(Otherwise it should not be built in, standard library maybe)
Python seems like a fine, fast tool. I am just shocked it doesn't have arrays. I'm and old school guy and I guess to me, and I know this isn't a popular opinion, but if a language doesn't have arrays, does it even qualify as a programming language?
I don't think that C# or Java have dedicated syntax for the hash tables that come with the language.
If it's not for speed then in Python we often do something like [0] * length.
Yes, I've done this one a few times already.
there are arrays in the python standard library; import array. but it seems extremely arbitrary to say that a programming language must have them.
But the output is unpredictable from application to application. Sometimes that works just Iike I expect, then sometimes is doesn't work at all like I expect.
Java IDK probably not 😦
I know, I get it. It's pretty arbitrary on my part. No argument there.
@calm haven does the revelation that this exists have any significance for you? https://docs.python.org/3/library/array.html
var students = new Dictionary<int, StudentName>()
{
{ 111, new StudentName { FirstName="Sachin", LastName="Karnik", ID=211 } },
{ 112, new StudentName { FirstName="Dina", LastName="Salimzianova", ID=317 } },
{ 113, new StudentName { FirstName="Andy", LastName="Ruth", ID=198 } }
};
C# lets you basically make literals for anything, it has way more fancy features than Java (including stuff for speed, like structs and pointers!).
C# is a pretty powerful language. I've done tons of work with it for years now. I'm a big fan.
Those .NET collections can get you in trouble if performance is key, but with many C# projects, performance is often NOT key and man, they sure are handy to use.
They do provide you with the tools to make your own nice collections though. So if you want to be performance aware, you can use your own (best to do so from the start).
Yeah, it's VERY cool. They've really done well with C#.
I'm just finishing up a major project that has to collect and manage 1000's of measurements a in fractions of a second in C#. It worked out very well. Now, I used all primitive types, so no collections. But that code is FAST.
Here's a python question: What's your go-to for popping a string out of list element and losing the [' and '] so get just you, know... your actual data?
sounds like you want either str.replace or str.split.
Can you give an example? Not exactly sure what you need.
or regex, or slicing or...
I know there are many options just wondering what the common, defacto, what most people do for it.
Example:
names = ["Johnny", "Rotten"]
print ( names[1] )
I want it to print "Rotten" NOT "['Rotten']"
@misty dirge :white_check_mark: Your 3.11 eval job has completed with return code 0.
Rotten
Maybe I typed that wrong.
did you mean to write names[1:]?
Bad example, sorry.
I'm reading 10 lines from a file into a list. When I set a variable (buffer = "") and type buffer = fileLines[3] it returns the contents of fileLines[3] with the brackets and single quote.
So there are few ways to pull it without those, I was trying to get a sense for the "common Python" way most would do for that.
then we're only talking about strings here that happen to look like python lists. not python lists.
if you have strings that look like "['Rotten']", and you know with certainty that every such string will have a [' at the front and a '] in the back, you can do the_string[2:-2] to slice them off.
So that's the kind of goto way. Makes sense.
Or if you prefer: ```py
s = "['Rotten']"
print(s.lstrip("['").rstrip("']"))
Rotten
I wish it didn't load in with those in the first place. That would be nice.
They aren't in the file. Python adds them.
would be the same as just s.strip("[']")
well you need the other way also, ]
that doesn't sound right.
Strip alone would only work for symmetric surroundings.
idts. it can take differing amounts from each side. i don't think they're equivalent, but i can't think of a counterexample
What does the file look like?
In [1]: "['hello']".strip("[']")
Out[1]: 'hello'
In [2]: "['hello']]".strip("[']")
Out[2]: 'hello'
Oh, nice.
Well, some settings I'm reading in actually do have the brackets and I need to keep them because they're meaningful. But when I load in string from a file into a list, every element on the list is padded with "['" and "']".
I think the semantics of strip aren't very obvious. which I suppose is part of why removeprefix and removesuffix were added.
The [2:-2] takes care of it. The replace could get me into trouble.
every element on the list is padded with "['" and "']".
that should not be the case. do you have an example? also, i think this is slightly off topic 😬
Yeah, let me genericize this routine.... brb.
Can I just pop the code in here?
20 lines with space
should probably be in a help thread. (see #1035199133436354600)
I find your argument fascinating because I have worked on Python code written by someone who thought as you do. Everywhere you looked, he preallocated things: Lists were filled with None and dictionaries initialized with placeholder values nearly every time. It made perfect sense for someone like him who had spent his life working in C. But he was making his life harder. Python's lists are dynamic arrays (as in https://en.wikipedia.org/wiki/Dynamic_array) and can be resized in O(1) amortized time. If you never resize a dynamic array, then it's effectively a fixed-length array (as in C) with some tiny extra overhead at creation time. That's how he used them. He had to run some of his logic twice, once to figure out how large the list would be and again to actually fill the list. After all, you have to do that before you allocate your array! But he could have just relied on Python's extra functionality. His code would have been simpler and easier to write.
Yeah. That makes sense. The first app I wrote in Python (week before last) used arrays extensively, but they were all fixed size. The data was known ahead of time. Everything worked great and it was only a little painful to figure it all out. I then started in on putting pieces of code together to assemble into larger utilities I need for work. Often the data is NOT known and needs to be dynamic. It seems like I keep hitting road blocks and have to walk around the block to get next door with Python to get things done in a reasonable way. It's like "Arrays are list, and they're TOTALLY dynamic!" OK, so I start at it in that way get slapped constantly with with either a "bad load" of the data where the array doesn't turn out like I need it to OR "index out of range" errors. Or like Stelercus pointed out, "faking" a 2D array causes problems with string data that I have to manage with some pretty unmaintainable looking work-around code. This past week has been terribly frustrating with Python for me.
So I guess at this point it is starting to feel like Python is something you could have a some fun with, but not something I feel good about putting into production releases.
Good Python style is often quite different from good C style. So, for example, in idiomatic Python it's very hard to get list index out-of-range errors. You generally use constructions like for x in l or, if you need the index (e.g., for mutating the list), for i, x in enumerate(l). But if you're coming for another language, you have to learn idioms like that. My early Python code used for i in range(len(l)), which made sense to me since I was coming from C, but it's not as nice a pattern.
If there's a specific thing you find difficult to do, you could post it and see what others think. There may be an easier way to do it.
But it's not ALL bad. I don't mean to sound like I'm dumping on Python. Things I loved so far: The TK implementation was GREAT. The built-in SQLite, totally awesome! The ease and speed of getting a concept up and running has been mostly good.
"for i in range(len(l))," I've written TONS of these. That might be part of my problem here.
Are you saying that those strings that were formatted like lists were supposed to be nested lists?
You should pretty much never be writing that.
Please don't write this. There's always a better way.
I'm saying that I just needed a simple 2D array to work with.
Can you post a snippet?
There are no 2d arrays. As I have said repeatedly, lists are not arrays. There are nested lists.
LOL. I get that! Just stating what I needed. I really now get that it's NOT HERE in Python. Totally understand.
Actually, one thing that you might find helpful to realize is: Everything in Python is a pointer. Under the hood, in the CPython implementation, every Python object has C type PyObject *.
@misty dirge You were very helpful, thanks again for your time earlier.
A little side note here, please don't do 2D arrays in C/C++ like this. We don't do 2D arrays that way, we use row-major indexing instead into a 1D array.
If you actually want 2D arrays, check out numpy arrays, i.e.
import numpy as np
buffer_array = np.empty((10,2))
Making an array of pointers to arrays in C is terribly inefficient and more error prone due to having to handle more allocation / deallocation.
Oh, I wouldn't load up a bunch of actual pointers in an array.
You could also just say "C is more error prone due to having to handle allocation/deallocation" and save a bunch of words

This is not exactly true, it depends. With region based memory management your memory issues are insignificant (and easy to debug).
I often have to make widely varied software and interfaces work together, so I build small tables in memory to map out the flow of data and functions rapidly. Stuff like that.
What do you use these tables for?
For instance, determine things about the filtering/conversion/etc to apply to inbound data and which other function, API or external file/program to route it to.
I have MULTUPLE connected pieces of hardware and their associated APIs and interfaces to contend with. Plus a STACK of legacy code with some pretty screwed up file formats to IO with.
It sounds to me like you're treating the inputs more-or-less as strings of bytes, and you need these tables to track how each input should be processed.
A more Pythonic way to handle that would be to wrap the file handle (or network socket, etc.) in some kind of object that understands how to process data from that type of input.
Yes, plus more complex, but similar scenarios to solve for.
Depending on how the input is structured, it might be a simple generator function, or a complicated generator function, or some kind of class instance.
My hands get tied often from dealing with legacy code NOBODY wants to touch. "Like, I don't know what shit does, but it works and I'M not gonna be the one to change that!" LOL
Yeah, I feel you. Better not to touch it.
But you can wrap it in something that works better.
Plus our equipment runs is thousands of locations all over the globe, so that adds some limits and caution to what we do as well.
We're actually working a major effort with this right now!
My basic principle when working with untrusted input is to establish sanity first. You turn the input into something you believe in, usually something structured which has been sanity checked somehow. At that point you have a much easier job.
In Python that amounts to having some kind of function or class instance that parses the data and returns something nicer than raw bytes or a raw string.
It usually more of a filtering, conversion and routing concern. Validation is usually built into things upstream of a lot of the code I sling.
This might be more suited for #software-architecture
True, we've gotten pretty far from pedagogy now.
How to teach.
Take a look at the first comment in this channel in the pins.
OH.... yeah, we're WAY off! LOL
pedagogy??
read this: #pedagogy message
hi
hello...what is th best site to study for microsoft intrnational python certificate for college students ...who knows
that would be a question for #career-advice; this channel is to discuss teaching techniques.
oh sorry..thanks
Hello. I read a post a while ago, and I'm curious what y'all think of it: https://viralinstruction.com/posts/defense/ (particularly, the pedagogical discussion about how to teach classes. the rest isn't particularly relevant to the discussion here.)
Notably, the post somewhat advocates for the idea:
Show locked doors before you show a key
In other words, it suggests that, when teaching classes, we should wait until learners see the point, by having seen a program grow out of control in ways that classes can help with. In doing so, they can really understand that yes, they may unlock some previously impossible behaviors, but mostly, they're a way to do the same things you can do already—just far more elegantly, and with language support.
This idea resonated somewhat with me, because when I was introduced to classes, I never really got the point. Dogs and cats, cars and vehicles, whatever it may be, it didn't seem particularly useful. It was only when I got to a point where I was actually modeling many of these complex structures that I really saw the importance, and started using them in meaningful ways.
And I suppose this is a more general concept, as well. In my Java CS class at school, the teacher didn't introduce arrays until pretty late into the course, although they're a fairly integral part of programming. Up until then, students were forced to use variables named x1, x2, x3, or something to a similar effect. Thus, when they were introduced, it was really easy to see why they were used; you could do the same things that you'd been doing by hand (granted, you can do some more as well), but with language features that made it very convenient and usable.
So overall, I'm just curious what you all think of that style of teaching. On the one hand, you have what i described above, but on the other, everyone moves at different paces, and sometimes it's useful to just jump right in and learn all of the basics. Thoughts?
I think its also important, perhaps even more so, to show where classes shouldnt be used
I dont have code examples on hand but we've all seen pointless class filled code that reads more like java than it does python
Classes arent the end game of python programming, showing bad examples and also refactoring/deconstructing them to use dicts/tuples/whatever collection and functions was more helpful to me at least when I was in uni
Could have sworn that theres a Hettinger talk on this but i cant find it, might be mixing it up with another talk
@fallow terrace I think contrived OOP examples ("Cat and Dog inherit from Animal") stem from courses that are oriented towards teaching languages (especially when that language is Java) rather than programming.
I was the TA for an NLP course where all the assignments had to be in Python, but none of the prerequisites taught Python. But all the assignments could be completed using only functions, lists, and dicts.
In my msc we had a class to introduce python to non cs peeps, it didnt cover classes or OOP stuff because the end exam and all the python needed for subsequent modules were feasible with top level functions and the builtin collections as well, it was fun
that's fair. i'd also think that the need for such examples arrives because of the lack thereof for classes in small programs. you don't generally need classes to write good programs in python, and the benefits only arise when you have enough going on. and that's hard to model in small examples without real world context.
but anyway, my point really wasn't the classes, although i know i and the article focused on them. it was more the general philosophy, where you introduce language features as they become needed, rather than all beforehand.
otoh, that's really hard for self-learners. in a classroom environment, you have a teacher who you can always talk to and who knows what you know.
when outside of such environments, you have to figure out how to pace your own learning, which is difficult
In general, introducing something only when its necessary is good practice but imho its just one half of it
Right after showing when something is necessary to solve a problem you should show when the same thing is unnecessary/undesirable for x problem, it rounds off the learning experience
I can imagine java students, after learning to use arrays to avoid v1, v2, ... to go off the other end and always use arrays even though you might only need the one or two variables
Just use pip and venv.
I'm not sure I'd always agree. Sometimes you just need to teach some stuff because it's needed for the "harder stuff" to make sense.
But showing the harder stuff would be bewildering.
If it’s “introduction to programming”, causing the very least setup they need to do before typing in their first program is important. If it’s “Python for someone who knows at least one other programming language”, starting with a bit of tooling hassle that makes experimentation easier my be worth it.
it's not "harder stuff", it's the more annoying way that a certain thing simplifies. for example, maybe you want to teach classes by first using only tuples and free functions. then after making an Employee "class", then you go and teach actual classes
Not quite sure I follow your point.
the idea is that sometimes if you just present solutions, the motivation for the solution isn't quite clear. but if you present the problem before the solution, then it becomes simple to explain why the solution is necessary
Sometimes, sure
But not always. There are times when you just need to learn a heap of fundamentals.
sure. i'm sure it wouldn't always work. but even for fundamentals it's probably still an ok idea, if slightly strange
motivating why you might want to have numeric data types or store a string seems odd, but you probably could still do it
You could, but it's fundamentally flawed.
why?
Well, you don't spend time justifying why you're teaching everything you teach.
why shouldn't you?
No one tells a toddler why you learn the colors, or why you learn to walk, or why you learn to count or why you learn the alphabet.
These are fundamental tools
You learn the fundamentals as a knowledge toolset and then you learn how to apply it.
it might be a waste of time, but it's not "fundamentally flawed"
Yes it is.
Have you tried to have a discussion with a small child about why they should learn different colors?
that's a non-sequitur. we're talking about people learning programming. while they could be small children, they're probably more developed than learning about colors
we're talking about pedagogy
it could be as simple as 1 sentence. "we also want to store text data; we can't do it with an int, so we have a type called str". though i did cheat with a semicolon
for...programming
right - ok so do you get into what an int is, and what memory is and the size of allocating memory before explaining the different data types?
you could, but you don't need to. that's not necessary to say why you need to store numeric data, or to say what an int is, which is something that stores numeric data
exactly - it's not necessary
it's not necessary to say why you need to store numeric data.
but you were maintaining you should explain the WHY first.
but that's not what dawn was suggesting. the proposal wasn't to explain all the low level fundamentals, but just to explain the motivation for why you might do something
the motivation for doing something is the WHY
no, i didn't say
it's not necessary to say why you need to store numeric data.
i was saying that i would not
get into what an int is, and what memory is and the size of allocating memory before explaining the different data types?
i would explain the motivation, even if it's just a single sentence
You did say that it's not necessary to say why you need to store numeric data.
ah. i see why you were confused. i said
that's not necessary to say why you need to store numeric data
but "that" here is referring to the previous sentence in that message, which is that it isn't necessary to explain the low level details
Honestly, this feels like riddles. I'm not really here to argue. I just think some knowledge is pre-requisite and needs to be explained without the "why".
but you still haven't explained why you think it's "fundamentally wrong"
Because you can spend half your time going into depth in a topic when it provides no additional benefit for the learner.
that's an issue with how you implement it, not with the process itself. you can point out many similar failures in any method of teaching
but you wouldn't explain low level memory details to someone that doesn't know what an int is. you would simply say "we want to store numbers, so we have int"
sure. i would say it's probably a waste of time in many cases. but that doesn't make it "fundamentally flawed"
fundamentally flawed
sure. other than just saying something along the lines of "you wouldn't do it", you haven't presented any reasoning
yes i have
Because you can spend half your time going into depth in a topic when it provides no additional benefit for the learner.
this? this could be equally applied even if you didn't give motivation beforehand. it's not specific to this method. it's a symptom of a bad teacher, not a bad process
it doesn't need to be specific... it's fundamental
When you're teaching a complex topic, you have to start with some things that the student already knows, and hook off those.
You can't keep creating more and more hooks and trying to link them all together at the start.
If you do that then you get issues with overloading students.
In short, "cognitive load theory"
It's quite simplistic to say, after the fact, that in retrospect things would have been easier to understand if this, and that, and the other had been mentioned, but that's forgetting that you only understand the link because you've actually joined all this stuff up in your head yourself after consolidation of the previous learning.
It isn't a symptom of a bad teacher if they fail to give you reasons to learn.
It's a symptom of a bad teacher if they don't understand how learning works and then use that knowledge to help you learn.
@noble aurora What topics do you teach?
wdym
Which topics / courses / units are you a teacher of?
python
You can't keep creating more and more hooks and trying to link them all together at the start.
yeah, i totally agree. i don't think that's a good idea
Reducing cognitive load is critical.
The more you waffle about "why", the more you increase cognitive load.
but the original problem is that for some complex topics, the "why" is not immediately evident. if you're going to fix that problem, you're going to have to present the "why" one way or another
or just don't bother
be assured there's a reason for it
this is like the typical argument a student makes for not learning stuff
why do we learn scales in music? Kind of hard to say until you're good at them!
why are you so worried about presenting the why?
because it solves the problem of being confused about why you're learning something
i give up
didn't you just say that was an issue?
Why wouldnt you explain the reasons for teaching something fundamental? Sounds silly
Yes, why do we need scales, where do we encounter them, what can I play with them?
Why should I learn them
"because I said so" isnt valid, youre not dealing with toddlers
Nor would any teacher say, "because I said so"
Already explained, it increases cognitive load.
Contextualizing a concept increases cognitive load? Says who?
any thinking increases cognitive load
Says a plethora of research on teaching and learning.
May as well teach and learn nothing then
why?
you honestly think it's better to teach and learn nothing rather than teach and learn in a sensible way?
Teaching a concept in a vacuum sounds much harder than explaining where it fits in programming, where you'd use it, what problems it solves, etc before getting into the nitty gritty, dont you?
depends on the concept
but that's basically what you implied. if you're not explaining the "why", it just boils down to "learn this because i'm teaching it"
no it's not at all what I implied
you said:
be assured there's a reason for it
that's very simplistic
I feel like you're arguing for the sake of arguing rather than discussing sound pedagogical approaches.
And just because things "sound like" common sense, doesn't mean they are.
not to argue for the sake of arguing, but, isn't "sound like common sense" the definition of common sense
Just because a thing seems like common sense doesn't mean it's actually correct
can you give an example of what you might do in that situation, then? if you don't explain why you might want to learn something, and someone asks why they should learn it
Why dont you explain what you meant by that then?
Smh theres an echo in here
I already have, but no one actually listens
What's your experience of teaching? How many years and at what level?
Its only polite to mention your experience and education before demanding someone else's
Not that any of this is relevant
We might not be teachers but we sure were students and my most hated teachers were the ones who couldnt tell me why im learning X or Y
Well it is, because we're talking pedagogical practice and I'm happy to discuss things, but people are saying "I reckon this, and I reckon that", but none of it matches what teachers are trained to do.
Are you a teacher?
Yes
what is a teacher trained to do when a student asks why they are learning something?
And your response to why should a student learn a concept is? Because you said so?
you're trying to put words into my mouth rather than actually ask. If you're just trying to attack then there's no point discussing.
what is a teacher trained to do when a student asks why they are learning something?
Im trying to guess at your thoughts because you wont express them lmao
I will but you won't actually read them - you just jump to your own.
You just like to pretend to know.
i can only find that you said:
be assured there's a reason for it
Why are you doing this lol, you havent explained, youre just avoiding the questions
It depends on the topic, and it depends on the student asking.
You have an example from this channel on python classes
fair enough. let's say we're talking about python classes like in the original topic. what info do you use about the student to make that decision?
But ordinarily, you don't let the student lead the learning.
The student is hardly leading, theyre asking why youre teaching what youre teaching, very reasonable
Right, so back to the issue. Cognitive load.
You can hold only a certain amount in your head at a time.
How does cognitive load factor into this, you have to teach classes at some point in python, the question is do you explain them in a vacuum without contextualizing them or do you show where they are useful, what problem they solve?
their point is that by contextualizing them, you are increasing cognitive load, making it more difficult to actually learn classes
Is that a fact?
So the aim in a learning episode is to get across a specific set of knowledge. And the more you overload students with extraneous information, the less likely they will understand it.
Examples of their use and what problem they solve is extraneous information? In what world!
In this world.
Are you being serious right now
Yes.
It's not that it's wrong in all circumstances, but it can make it harder for students to learn if they have too many things in short term memory.
So you focus on some specific pieces of knowledge that you then need to work to move from short term to long term memory.
Context could sometimes be valid knowledge, but it often is a massive distraction.
It's one of those education myths that giving context to everything helps.
You can typically hold about 4 to 7 ideas in your head in short term memory. So you have to be sure that the thing you want to cover in half an hour isn't shoved out by some stuff which doesn't actually help.
One of the reasons that tools like DuoLingo work is because they give you 4 to 7 pieces of info at a time and then they focus on getting those into long term memory.
What they don't do is spend time trying to explain the context first. The context comes later.
Duolingo isnt exactly an example of successful education lol
Based on what measure?
Besides, the context mentioned in the original article doesnt come from "short term memories", whatever that means
(and even if it isn't, how does that change the argument?)
Yes it does.
All learning starts off in short term memory. If I tell you a load of facts now, you're going to forget a chunk in an hour, and a bigger chunk in a day
See Ebbinghaus
The concepts built upon arent random lists of facts passed to students
Theyre concepts themselves that are reviewed and practiced
I know
Well, knowledge, yes.
It's not about them being random, it's about the fact you forget stuff. You just do. Having a solid framework to build things on DOES help. But putting extraneous context can seriously muddy the problem.
The musical scales thing is a case in point. Do most students have a clear understanding of why they're learning them?
The context here is already learned concepts tho, why is that extraneous, its stuff they already should be familiar with
I think they probably have an idea that it's to do with dexterity or even finger aim, which has some truth. But the link between that and a harmonic understanding of music? Probably not until they've progressed quite a lot further.
No it isn't, the context is concepts that are abstract that aren't already understood.
So, I have explained my angle on it.
Please go ahead and explain yours.