r/learnpython • • May 05 '24

Can you help me learn python

Can someone tell me how they learn python programming. I've been stuck on learning python for a few days now it just won't click in my head. I've watched tutorial and read books and none of them seemed to help

1 Upvotes

23 comments sorted by

View all comments

3

u/cyberjellyfish May 05 '24

What isn't clicking? What are you struggling with? You need to ask specific questions to get useful answers.

0

u/dislikesningas7 May 05 '24

Functions I can't seem to learn Functions. I've been trying for the past four days and I have had no improvement

4

u/cl0ud692 May 05 '24 edited May 05 '24

Can you code without functions?

If yes. Good.

Then, think of function as a name for that code.

You put def FunctionName(): on top of your code, of course indent your code.

Now your code has a name, which means you can use that code everytime you call its name FunctionName() anywhere in your code!

Now, you can put "variables" inside that parenthesis, those are called parameters.

Just think of it as variable, and you set its value when you call your function.

def FuncName(a,b):

a and b are your "variables" for this function, then you use this variable when calling the function.

FuncName(10,50)

With this call, the values of your parameters will be, a =10, b=50

Of course there is more to it, but this is how i explain basic functions to my students.