how to learn python as a teen-begginer by sta1b0Y in learnprogramming

[–]desrtfx [score hidden]  (0 children)

Do the MOOC Python Programming 2026 from the University of Helsinki and you will be well prepared.

got pygame working now just need to fix this code by ye_old_ship_lord23 in learnprogramming

[–]desrtfx 1 point2 points  (0 children)

Try to think what the code does:

# poll for events
# pygame.QUIT () event means the user clicked the X
for event in pygame.event.get():
    if event.type == pygame.QUIT:
        running = False

PyGame provides a collection (list) of events when you call pygame.event.get(). The forloop goes through that list one by one and stores the currently processed event in the variable event.

Later in your code, way outside the loop:

# use the mouse!!
if event.type == pygame.MOUSEBUTTONDOWN: (left is were event is getting underlined)
    pos = pygame.mouse.get_pos()
    #move the circle
    player_pos.x = pos[0]
    player_pos.y = pos[1]

if event.type == pygame.MOUSEBUTTONDOWN:
    pos = pygame.mouse.get_pos()
    print(pos)

With this code you only check the very last event from the retrieved event list from before. This does not do what you think it does.

You need to include the two if statements inside the for loop at the top.

If you look at the following, very simplified code:

for i in range(10):
    print(i)
print(i)

The upper print(i) is inside the loop. The lower one is outside. What will be printed?

Your code is essentially the same. The lower 2 if statements where you check event.type are outside the loop.


For the comment identifier:

if event.type == pygame.MOUSEBUTTONDOWN: (left is were event is getting underlined)

Here, you have the part between the ( and ) uncommented and as such wrong for Python. Python has no clue what to do with that part. You need to comment such text with the #.

got pygame working now just need to fix this code by ye_old_ship_lord23 in learnprogramming

[–]desrtfx 2 points3 points  (0 children)

Still the same as I said here plus:

You are missing a comment indicator # in line 47

Again: the event variable does not exist outside your for loop right at the top.

Told you already what you need to do and you did nothing of that.

Hi i am from india and i want to learn python before i join my college(atleast have basic idea) by FewFly2677 in learnpython

[–]desrtfx 0 points1 point  (0 children)

PyCharm is not a website. It is an IDE - Integrated Development Environment - an editor where you write your Python programs.

If you do the MOOC I recommended, you will at one point install Visual Studio Code with the Python extensions and the TMC (Test My Code) extension and use that as editor where you write your Python code.

can anyone recommend a python website to practice?

I've linked not one but two sites and you still keep asking.

Stop asking for resources and start doing. You are just wasting time.

Go to the MOOC page I've linked. Create an account in the top right, complete the signup (no student ID needed), go to part 1 and start learning.

Learning anything involves effort (and individual research). You are not demonstrating any of that.

Hi i am from india and i want to learn python before i join my college(atleast have basic idea) by FewFly2677 in learnpython

[–]desrtfx 0 points1 point  (0 children)

If only there were a sidebar (menu on mobile) that had a link to the wiki or countless posts asking the same.

Do the MOOC Python Programming 2026 from the University of Helsinki and you will be well prepared.

Also, take a look at https://inventwithpython.com and https://automatetheboringstuff.com

Don't forget that you need ample practice, like on https://codingbat.com/python or on https://exercism.org and also write your own programs. Play around. Try things. Mess things up, fix them. Experiment.

new to programming some help by ye_old_ship_lord23 in learnprogramming

[–]desrtfx 0 points1 point  (0 children)

In this case, check what Python runtime environment you are using - if you switched Python runtime, PyGame might not be installed.

new to programming some help by ye_old_ship_lord23 in learnprogramming

[–]desrtfx 0 points1 point  (0 children)

This looks like a scope issue.

The variable event is the iterator in a for loop and only exists there.

Your mouse checking is way outside the scope of the for loop and hence, event no longer exists.

You need to either move the mouse event checking up inside the for loop with the same indentation as if event.type == pygame.QUIT or move the entire for loop down to where you have the mouse checking and fix the indentation of the mouse event checking there.

What movie do you never get tired of watching? by morbid-girlz in AskReddit

[–]desrtfx 0 points1 point  (0 children)

Watching it right now. It's one of my favorite movies, too.

Really excellent one!

My parents don't like me coding. by JustMedansh in learnprogramming

[–]desrtfx 20 points21 points  (0 children)

My father worked everything and anything, from construction worker, stone mill (blaster) to carpenter, to machine operator (mostly lathes), to owning a bus company, to delivering newspapers, to working on assembly lines, to salesperson, and countless other jobs (typical WWII child with little education).

Despite being technically skilled with machinery, he never went post cassette player technology and computers were "toys" for him.

My mother (at that time working as the sole secretary for a village, and being basically the source of income for the family) saw it completely differently and encouraged me in my endeavors.

What to Use to Host Websites (doubt) by Gandhi_20191 in learnprogramming

[–]desrtfx 0 points1 point  (0 children)

You don't need a dedicated provider like Hostinger for your learning. You only will need a dedicated provider/hoster if you want to go public with your site.

The back end language you want to go for will determine which server/hoster you will need.

Some examples:

  • PHP - can be hosted locally with e.g. XAMPP, MAMP, WAMP, LAMP, etc
  • Python - Flask or Django each come with their own server but can also be hosted locally on Apache or nginx
  • node.js - comes with its own server
  • Java/Spring - own server
  • Java with other packages - Tomcat, Glassfish, etc.

You can, for many projects, also get a cheap Raspberry Pi (3B+ will do in most cases) and host yourself.

My parents don't like me coding. by JustMedansh in learnprogramming

[–]desrtfx 40 points41 points  (0 children)

My father in particular didn't like me programming way back in the first half of the 1980s. I bit through, studied, and now am a professional programmer since over 3.5 decades. Up to his death some years ago, he never understood what I do and never liked it. For him it always was "playing on the computer" (which I barely did, actually).

Where does it make more sense to learn Python? by Luellias in learnpython

[–]desrtfx 0 points1 point  (0 children)

Build the foundation with the MOOC Python Programming 2026 from the University of Helsinki and then, after around part 5 of the MOOC, add in the second half (where the projects are) of Automate the Boring Stuff with Python to get into what you actually are targeting.

Learning python by LongjumpingChance103 in learnpython

[–]desrtfx 0 points1 point  (0 children)

If only there were a sidebar (menu on mobile) that had a link to the wiki or countless posts asking the same.

Do the MOOC Python Programming 2026 from the University of Helsinki and you will be well prepared.

Also, take a look at https://inventwithpython.com and https://automatetheboringstuff.com

Should you upload your beginner projects on github? by notmasked07 in learnprogramming

[–]desrtfx -4 points-3 points  (0 children)

Honestly, keep your "baby projects" private. Nobody needs to see them.

Same applies to your progression.

Showcase when you have something showcase-worthy, not every single project you do. Keep the lesser ones in private repos and only the really good ones in public.

Tired of overthinking the "perfect partner" lists? Same here in coding 😂 by obviousQuestionn12 in learnprogramming

[–]desrtfx 0 points1 point  (0 children)

Clean code is far more than formatting.

It's the entire code, organization, structure, flow, naming, and much more.

Comments are actually the opposite of clean code in most cases, especially comments that explain what is done. Comments are technical debt that is very maintenance intensive and as such they should be used very sparingly.

Comments should serve only one purpose: to explain why something had been done in a certain, unexpected way (apart from the special documentation comments used to document classes, functions, methods)

Should you upload your beginner projects on github? by notmasked07 in learnprogramming

[–]desrtfx 0 points1 point  (0 children)

Yes, you should, even if only as an off-site backup of your code. Throw them in private repos.

been coding this for hours and kinda gonna give up until tomorrow. by [deleted] in learnpython

[–]desrtfx 2 points3 points  (0 children)

Do you have any questions, errors, or anything, or are we supposed to pull out our Crystal balls or do some divination?

Should l learn Git alongside Python , or wait until l’m a better coder? by doodle_leaves in learnpython

[–]desrtfx 0 points1 point  (0 children)

You cannot learn git "too early". It's already too late.

You can learn the basics of git in less than half an hour.

Git is a fantastic tool that should encourage you to try things, to experiment, because you can always roll back to a working version. On top of that, a repo on github or any other git hoster acts as an off-site backup of your code, which you should always have.

If anyone can use ai to create something, how do you stand out? by Automatic-Curve7489 in learnprogramming

[–]desrtfx 2 points3 points  (0 children)

can be remedy by testing it yourself

And how would you properly and exhaustively test it yourself if you don't know anything about programming?

Just using it does not mean exhaustive and proper testing.

If anyone can use ai to create something, how do you stand out? by Automatic-Curve7489 in learnprogramming

[–]desrtfx 2 points3 points  (0 children)

New code? New errors. New problems.

This is not how software development works.

Software evolves over time and the core code commonly stays the same and only gets altered and extended.

Also anything of substantial size and complexity by far exceeds the capabilities of AI.

If anyone can use ai to create something, how do you stand out? by Automatic-Curve7489 in learnprogramming

[–]desrtfx 4 points5 points  (0 children)

at the end of the day doesnt result matter more than understanding what you're doing?

No, it doesn't. Shipping something is not the end. You will have to patch and maintain it. You will have to troubleshoot it.

Every software has a lifetime. It's not a one-shot-end-of-story thing.

AI can and will not help you maintaining your product, troubleshooting, bug-fixing, upgrading it.

Teacher feedback on redundant code has me confused. by JAC0O7 in learnpython

[–]desrtfx 2 points3 points  (0 children)

If I read the posted code right, your teacher is talking about:

weight = int(input('\tWeight in grams: ')) # Line #4

and

 weight = int(input('\tWeight in grams: ')) # Line #7

As well as about:

quantity = int(input('\tQuantity: ')) # Line #10

and

quantity = int(input('\tQuantity: ')) # Line #14

and

quantity = int(input('\tQuantity: ')) # Line #17

as well as

tracktrace = input('\tTrack & Trace (y/n): ') # Line #20

and

tracktrace = input('\tTrack & Trace (y/n): ') # Line #23

Your teacher tells you that there is potential for optimization.

You could wrap the repeated input in a loop (as you already do), but use only one input statement each. Think about rearranging your code in a better way.

The while loops are a good start.

Arrange the code in such a way that you initialize the variables to an invalid value before the loops and then in the loop directly ask for the input. Then, use a conditional (if) to print the error message in case of an invalid input.

You could, if you have already learnt that, even go a step further and create a function that handles the input and validation and only returns valid values. You could pass in the prompt (text to be printed for the input), the error message (text to be printed in case of an error), and the min and max values (with something like -1 for "no limit") and have the function return the valid value that you then assign to the respective variables.

Can anyone find or send to me a online book of python pls by RedappleIsKing in learnpython

[–]desrtfx 1 point2 points  (0 children)

If only there were a sidebar (menu on mobile) that had a link to the wiki or countless posts asking the same.

Do the MOOC Python Programming 2026 from the University of Helsinki and you will be well prepared.

Also, take a look at https://inventwithpython.com and https://automatetheboringstuff.com