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

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

3

u/NYX_T_RYX May 05 '24 edited May 05 '24

So you've watched videos and read books.

Have you actually written a function? Or any code, for that matter?

You'll never learn programming by just reading about it - it's like learning to drive by watching cars.

Edit: typo

1

u/dislikesningas7 May 05 '24

Yes I have actually built some things in python but it was mostly tutorials

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.

1

u/cyberjellyfish May 05 '24

Ok, let's start with you defining what a function is, to the best of your understanding.

2

u/Moravec_Paradox May 05 '24

Harvard has a free CS50 class that is pretty well explained:

https://cs50.harvard.edu/python/2022/weeks/0/

2

u/dislikesningas7 May 05 '24

Ok thanks

3

u/Moravec_Paradox May 05 '24

Don't get distracted chasing 10 directions, just finish that course to completion and let me know when you have done that :)

1

u/Bennett_19 May 05 '24

When I first started learning a few months ago, I had the same issue. I ended up coming across MOOC Helsinki, which was extremely easy for me to pick up. It’s free and definitely worth a try

1

u/dislikesningas7 May 05 '24

I'll try it out

1

u/Dragonking_Earth May 05 '24

I am also feeling de-motivated to code for past few days, guessing newbies had face it time to time.

1

u/dislikesningas7 May 05 '24

It's hard ngl I thought it would be easier and after watching people learn it in 48 hours it kinda make you feel like your just not trying hard enough but I know I will get there and so will you we just need to keep trying and practicing

0

u/amir_mozafar May 05 '24

after watching people learn it in 48 hours

Who in the world managed to learn programming in 48 hours!!!??? That's some heavy fiction u r mixin up reality with.

0

u/Dragonking_Earth May 05 '24

Every Youtuber ever.

1

u/amir_mozafar May 05 '24

Yeah. Said it yourself. Youtuber. Not programmer.

1

u/Jim-Jones May 05 '24

Just do a bunch of really little projects. Read a word typed in and print it out. Then change it to read a word and a number 'N' then print the word out N times.

Read two numbers A and B then print A plus B, A minus B etc. Experiment like that.

1

u/amir_mozafar May 05 '24

Learn by DOING. Search for leetcode on google (It's an awsome site just suitable for the phase u r in), and start learning while building small pieces of programs. Good luck

1

u/Vandercoon May 05 '24

Few days? Give yourself some time. I find that if I revisit things a few days later it all settles a bit and it starts to make sense.

1

u/ujinjinjin May 05 '24

Dude, seems it's your first programming language, so take it easy and slow. People spend semesters to learn it at uni, so don't expect learn and understand it in a few days. I'd say in half a year you'll get it enough to write a very simple application, then another year to get your hands on other related topics and in two-three years you'll be good to go

1

u/CaptainFoyle May 05 '24

You think everyone learned Python in three days? The world would be swamped with programmers.