I need an advise on starting with Python

I need an advise if anyone wants to answer my request: Where can i learn proper python code? And some approach learning?
I already know some basics, like booleans, array/list, functions…but when i want to make something i’m like frozen…i don’t understand…

1 Like

Hi and welcome.

A good place to start, is right here: browse the threads and get a feel for how much you know.

How many of the questions here, could you answer?

A good way to learn, is to do some research and ask yourself, “how would I solve that?”

1 Like

By vasi-h via Discussions on Python.org at 21Jul2022 20:14:

I need an advise if anyone wants to answer my request: Where can i
learn proper python code? And some approach learning?
I already know some basics, like booleans, array/list, functions…but
when i want to make something i’m like frozen…i don’t understand…

I get the “when i want to make something i’m like frozen”. That doesn’t
happen to me much with Python these days, but it is a familiar situation
in many new areas.

Normally to me this means some of:

  • I don’t know how to bootstrap a Python script for this
  • I don’t know how to solve the problem itself

For the former, I usually have some standard boilerplate Python for a
new script:

import sys
... import whatever else as it becomes necessary ...

def main(argv):
    ...
    a function to run when invoking this module from the command line
    this will be that main thing:
    - open some data file maybe
    - do things with the data
    - maybe print some results or save to a new data file etc
    ...

... function and class definitions here ...

if __name__ == '__main__':
    sys.exit(main(sys.argv))

Almost all my Python has that basic shape. What does it do:

  • imports always come first
  • the main program comes next so that you can see “what it does”
    immediately
  • all the functions or classes you make come next
  • the if-statement at the bottom is standard boilerplate for when your
    script (a “module”) is invoked as a command i.e. when you run it

This also means: no globals! Just define things in main() and pass
them as required to functions.

For the latter, it can be helpful to write out informally how you, as a
person, would solve the problem. In broad terms. Then make each step
more detailed until the level of detail approaches what you might do in
Python. The start doing the small bits one at a time (a function to do
each small piece); you can then run those functions on etheir own. When
they’re good, make another function to join them together in one of your
higher level steps.

You can do that from the bottom, as described above, with small simple
functions gradually building to the whole thing. Or also from the top,
with a high level function calling other functions. Doing it from the
top in a way tells you what lower level function you might want and what
'shape" they have (what parameters they take and what values they
return).

And you can do both of course.

So:

  • write out an informal description of what you want to do, gradually
    making it more detailed
  • write some of this in Python as it becomes clear enough, from the top
    or from the bottom as required

The bottom low level functions can be tested (run by hand) to debug them
because all the bits from there on down have been written, correctly or
not as it turns out.

And if you have a mental block partway through this, come here and ask
questions. Bring what you’ve done, what you you’re trying to achieve,
and what output there might be.

Cheers,
Cameron Simpson cs@cskk.id.au

1 Like

Thank you for your nice reply. I will definitely put this in practice.

1 Like

I once read that…

The #1 goal of software engineering is to solve real-world problems: you must understand how to translate a real-world problem into a program that solves said problem.

Many of the solutions to real-world problems that can be solved by software engineering, have already been developed, but that does not mean that improvements can’t be made, or customized versions are not needed.

1 Like

I suggest a book or a youtube tutorial. Keep browsing until you find something fitting your learning style. There is an overwhelming number of resources, some of them not very good, unfortunately.

1 Like