Author Topic: Learning Python  (Read 2387 times)

0 Members and 2 Guests are viewing this topic.

Offline rstoferTopic starter

  • Super Contributor
  • ***
  • Posts: 9937
  • Country: us
Learning Python
« on: October 08, 2022, 03:38:33 pm »
There are a lot of educational resources dedicated to teaching Python (courses at udemy, among others) but one I hadn't seen was the courseware from Amazon.  They have quite a collection of courses.

Here is a decent program covering both Python and Data Analytics for just $10  https://www.amazon.com/dp/B0B96MY9M8

The good news is that it uses Google Colab which means there is no need to set up a Python environment unless you want to.
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 8177
  • Country: de
  • A qualified hobbyist ;)
Re: Learning Python
« Reply #1 on: October 08, 2022, 05:24:44 pm »
Free and nice interactive online course: https://www.learnpython.org/
 
The following users thanked this post: Jacon

Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 9239
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
Re: Learning Python
« Reply #2 on: October 08, 2022, 06:49:59 pm »
For those a bit more advanced, try this: https://www.youtube.com/c/PythonSimplified/videos
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Online RoGeorge

  • Super Contributor
  • ***
  • Posts: 6806
  • Country: ro
Re: Learning Python
« Reply #3 on: October 08, 2022, 06:58:00 pm »
I like how this guy explains, very clear way of building an understanding,
i.e. his tutorials about classes and decorators are one of the best on YT.
https://www.youtube.com/c/ClearCode/videos

11 hours teaching Python from zero, with examples and exercises.
Has timestamp links in the video description to jump at the needed chapter.
Quote
Introduction
00:00:00 - Intro
00:01:13 - Python in Context
00:06:20 - Installing Python
00:14:20 - Installing a code editor

Part 1 - Python Basics
00:27:57 - How code is executed
00:33:21 - Math operations
00:41:52 - Variables
00:56:37 - Functions
01:03:22 - Methods
01:18:11 - Returning values
01:24:23 - Comments
01:29:38 - More on the order of execution

Part 2 - Datatypes
01:37:53 - Datatypes intro
01:42:15 - Numbers (integers + floating point numbers)
01:48:09 - Strings
02:08:45 - Lists and tuples
02:26:45 - Slicing
02:39:26 - Unpacking
02:44:03 - Strings, tuples and lists
02:52:54 - Dictionaries
03:04:35 - Sets
03:18:26 - Booleans
03:31:39 - Other datatypes

Part 3 - Flow
03:33:32 - Flow intro
03:37:26 - Simple if statements
03:50:34 - Complex if statements
04:06:10 - Match case
04:14:49 - While loops
04:27:29 - For loops
04:42:42 - Flow + linebreaks

Part 4 - Functions
04:50:22 - Function intro
05:04:18 - Parameters
05:16:37 - More on parameters
05:27:30 - Scope
05:44:47 - Lambda functions
05:50:38 - Documenting functions

Part 5 - Data
05:57:03 - Data intro
05:57:51 - Better for loops
06:12:46 - List comprehension
06:30:56 - Other comprehensions
06:37:49 - Sorting data
06:49:11 - Map + Filter
06:58:04 - File handling
07:09:35 - Deleting

Part 6 - Classes
07:13:59 - Classes intro
07:30:21 - Classes in practice
07:43:48 - Dunder methods
08:00:01 - Class and methods
08:13:25 - Scope and classes
08:28:00 - Simple inheritance
08:50:34 - Complex inheritance
09:10:30 - Class extra parts

Part 7 - Modules
09:21:26 - Module intro
09:34:51 - External modules
09:48:41 - Creating modules
09:56:09 - Dunder main

Part 8 - Extra parts
09:59:31 - Intro + input + pass
10:04:22 - Exceptions / Error handling
10:18:56 - Decorators
11:01:27 - Eval + Exec

The ultimate introduction to Python in 2022 [ + Exercises ]





Other more advanced topics:

7 simple tips for python beginners
https://youtu.be/ESTf0ut14N0

Understanding classes and object-oriented programming [Python Tutorial]
https://youtu.be/_vr5faCXFo8

Understanding decorators [Python tutorial]
https://youtu.be/nVdF7QT-Ggg

Creating 10 Apps in Python [ with PySimpleGui ]
https://youtu.be/kQ8DGP9p2LY

Learn Python by making games [ Trailer ]

Offline nigelwright7557

  • Frequent Contributor
  • **
  • Posts: 701
  • Country: gb
    • Electronic controls
Re: Learning Python
« Reply #4 on: October 08, 2022, 07:11:03 pm »
I found Python is a little C like except for some keywords and indentation.
I just got stuck into a website design and grabbed info as I needed it using internet search.
Got there in the end.
 

Offline MikeK

  • Super Contributor
  • ***
  • Posts: 1316
  • Country: us
Re: Learning Python
« Reply #5 on: October 08, 2022, 07:26:24 pm »
"Automate the Boring Stuff With Python" is free online:

https://automatetheboringstuff.com/
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15439
  • Country: fr
Re: Learning Python
« Reply #6 on: October 08, 2022, 07:30:33 pm »
"Automate the Boring StuffPython With PythonStuff" is free online:

 ;D
 

Offline Picuino

  • Super Contributor
  • ***
  • Posts: 1033
  • Country: es
    • Picuino web
Re: Learning Python
« Reply #7 on: October 08, 2022, 07:52:13 pm »
https://docs.python.org/3/tutorial/

This is the official tutorial. In multiple languages.

All documentation:
https://docs.python.org/3/
 

Offline rstoferTopic starter

  • Super Contributor
  • ***
  • Posts: 9937
  • Country: us
Re: Learning Python
« Reply #8 on: October 09, 2022, 06:30:20 pm »
There are dozens of sites offering beginner Python, no doubt.  But does the same program spend the last half of the material on Data Analysis with Matplotlib, Pandas, SQL, and other tasks like building a recommender, scraping the web?

None of these topics are taught in great depth, they are simply introductions for beginners.  But it's a place to start.  In fact, it seems like a perfect place to start before taking a more formal course.  It'll be a few days before I complete the program.  Let's see what I think after I do the work.

 

Online RoGeorge

  • Super Contributor
  • ***
  • Posts: 6806
  • Country: ro
Re: Learning Python
« Reply #9 on: October 10, 2022, 01:02:55 am »
For Pandas, Matplotlib and other popular modules on top of Python, Corey Schafer has a good tutorials channel:
https://www.youtube.com/c/Coreyms

Offline eti

  • Super Contributor
  • ***
  • !
  • Posts: 1801
  • Country: gb
  • MOD: a.k.a Unlokia, glossywhite, iamwhoiam etc
Re: Learning Python
« Reply #10 on: October 10, 2022, 07:50:12 am »
I found Python is a little C like except for some keywords and indentation.
I just got stuck into a website design and grabbed info as I needed it using internet search.
Got there in the end.

Like C? 🤔

Nope. C has speed, and is compiled.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4316
  • Country: us
Re: Learning Python
« Reply #11 on: October 10, 2022, 09:26:08 am »
As I’ve told people: I know python now, which means that I can write python programs that look a lot like C code…


Wrapping your head around all of existing libraries that you OUGHT to be using is a separate skill :-(

 
The following users thanked this post: DiTBho

Offline rstoferTopic starter

  • Super Contributor
  • ***
  • Posts: 9937
  • Country: us
Re: Learning Python
« Reply #12 on: October 10, 2022, 02:34:22 pm »
As I’ve told people: I know python now, which means that I can write python programs that look a lot like C code…


Wrapping your head around all of existing libraries that you OUGHT to be using is a separate skill :-(

In my view, Python is all about the quality libraries.  I'm not sure the world needed another programming language but I do enjoy being able to build on the work of others.

If I can make PL/I look like Fortran, I should have no problem making Python look like C.
 

Offline DiTBho

  • Super Contributor
  • ***
  • Posts: 4247
  • Country: gb
Re: Learning Python
« Reply #13 on: October 13, 2022, 07:48:22 am »
As I’ve told people: I know python now, which means that I can write python programs that look a lot like C code…

Wrapping your head around all of existing libraries that you OUGHT to be using is a separate skill :-(

Worse still, when people integrate that pythong-look-like-C crap into X11 apps
:bullshit: :bullshit: :bullshit: :bullshit:

Ok, I am the kind of person who managed to patch, hack and compile Xsdl for X11 with some python code to "compose" single applications into a nicer screen.

What? Seriously WHAT?  :o :o :o  :wtf:

Yeah, It is called "rootless X11 server" and it requires more complex interaction with OS GUI subsystem. if you did things right then you should write a lot of OS-specific code at X.Org side, otherwise each X11-window (one fo each X11 app) will render inside a SDL window, but since I am lazy and evil and bad ... well  I just created a monster (C code) that needs an X11 server instance for each window, and then a second monster (python code) that "composes" that crap into a single window.

... and ... voila, the last greatest *hit is served!  :scared:

No doubt it's the worst shit on earth which also requires crappy bash script because sdl also requires xkbdcomp for start and put xkbdcomp otherwise it will immediately fail to create colormap and crash down with just a death funeral  "sorry, no screens found" string.

|O )

So ... no doubt it sucks! but hey? at least I don't suggest other people to write that bad things

Next gen: please, don't do this!
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline nigelwright7557

  • Frequent Contributor
  • **
  • Posts: 701
  • Country: gb
    • Electronic controls
Re: Learning Python
« Reply #14 on: November 27, 2022, 12:08:06 pm »
I found Python is a little C like except for some keywords and indentation.
I just got stuck into a website design and grabbed info as I needed it using internet search.
Got there in the end.

Like C? 🤔

Nope. C has speed, and is compiled.
I meant in structure.
I quickly moved from C to Python.
 

Offline rstoferTopic starter

  • Super Contributor
  • ***
  • Posts: 9937
  • Country: us
Re: Learning Python
« Reply #15 on: November 27, 2022, 04:26:20 pm »
Amazon had a short life in the training arena.  They are getting out of the courseware business on December 9th.  OTOH, there are many other resources.

The more I play with machine learning, the more impressed I am with the libraries.  Numpy, Tensorflow, Keras, and all  the others are simply amazing.
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11713
  • Country: my
  • reassessing directives...
Re: Learning Python
« Reply #16 on: November 27, 2022, 05:48:41 pm »
The more I play with machine learning, the more impressed I am with the libraries.  Numpy, Tensorflow, Keras, and all  the others are simply amazing.
can it make coffee for me by just typing a single line of MakeMeCoffee()? given enough effort from people in a certain language infrastructure, it can make wonder, however crappy the language design philosophy from the beginning.. (i'm not saying Python is crappy) the wonder is not in the library, its in the makers who created them...
TensorFlow for C
Numpy is written in C


Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 
The following users thanked this post: SiliconWizard

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6967
  • Country: fi
    • My home page and email address
Re: Learning Python
« Reply #17 on: November 27, 2022, 09:29:21 pm »
Like I keep harping so often, one of the nicest thing about Python is that it can interface to native libraries using only standard Python, with no additional native code or changes to the native code needed.  It means you can create Python bindings to a native library writing only a bit of Python, using e.g. the built-in ctypes and perhaps struct modules.

To me, it means you only write Python code for the topmost "business" logic: in my case, mostly graphical user interfaces.  I used to do a lot of backend web server coding, though.

(There is one interesting Python tricks when using Python under FastCGI, that I'd love to see used more.  If your Python page engine acts like a FastCGI server, you can preload things like the site navigation structure into an object, and then just fork the entire Python process when serving a new client request, like FastCGI servers normally do (with the same implied resource checking limitations and checks suggested).  This cuts down on latency, and means common I/O (to find out the navigation structure to properly implement menus and paths and such) is not unnecessarily duplicated.  Makes a significant difference in practice.  You can even drop privileges based on a quick prefix URL check, before doing any work for the request, and make security bugs slightly less dangerous that way.)

It also means that Python examples where you do serious data processing or computation (without dedicated libraries like numpy/scipy), are not useful.
You want to use Python where its strengths lie, and those are mainly in the high-level concepts.

Because of that, I recommend learning early how to effectively use Python with GUI toolkits.  Currently, I recommend Qt5, via either PySide2 or PyQt5 bindings.  The two are very similar, and really only differ in their dynamic UI building facilities.  QtPy (a Python package) is a thin loader layer on top of either, that provides the same interface to both, by implementing a minimal uic class that PyQt5 provides when using PySide2 bindings.

The main reason for that recommendation is so that you get comfortable how to use 1) derived classes to add your own desired functionality, and 2) event-driven programming model.

With Python and Qt5, I also recommend keeping user interfaces as XML .ui files (that you can save from e.g. Qt Designer), and loading and constructing them at run time using the aforementioned uic class.  For maintenance and adaptability reasons, I strenuously recommend against using any Designer or similar utilities to generate the Python code needed to implement an user interface: that shit is write-only.  It looks nice-ish, and you can make tiny changes, but major revamping is always a complete rewrite.  With .ui files, you just switch to another one, and only have to make sure the existing element names are all implemented and match.

If you dislike Qt, then Gtk is also a possibility, but it looks very, very similar to Qt Python code.  Gtk differs from Qt in that there is just one set of bindings, the ones provided by GObject Introspection, aka GI or gir.  In current Linux distributions, these are packages named gir1.2-library, and a Python gi module (in Linux, typically python3-gi package) builds the bindings to the library using the GI files.  It is quite nifty, actually.  (All you need is import gi; gi.require_version('Gtk','3.0') (for Gtk 3.x); and from gi.repository import Gtk.  Same for any other library that you have GI for.)
The UI builder for Gtk is called Glade, and it too saves .ui files (not compatible with Qt ones) that you can load and instantiate at run time.

Because current Python interpreters can only run one thread of Python code within each process simultaneously, you will soon have to learn to do distributed processing using process-based parallelism.

Personally, I heavily use a Python I/O thread, and Python Queue or toolkit-specific event dispatching to communicate between the main UI thread and the I/O thread.  For communication with a microcontroller or similar, I often use two I/O threads and full-duplex asynchronous comms.  (In Linux, with native serial and USB Serial, I exclusively use termios, not any serial library.)  For computation, that/those I/O threads communicate with other processes that do the heavy computation, using the Python subprocess module.  Note that when using libraries like numpy/scipy/fftw etc., the library code can run concurrently to Python code in a different thread,  which means that there is no problem using e.g. multiple Python threads for computation using these libraries.  It is only Python code that cannot run concurrently in different threads in the same process: different processes, or Python and native code, thread-parallelizes just fine.

If you want Python examples (noting that I only have Linux OS available right now), let me know: I really like to help others learn, and if you can come up with an interesting example scenario, I'd be happy to give it a try.  It's even better if others are willing to point out weaknesses and suggest changes in my suggestions, because then I learn myself too.  I'm of the opinion that one never knows all nor enough, and can and should always keep learning.
« Last Edit: November 27, 2022, 09:31:00 pm by Nominal Animal »
 

Offline Picuino

  • Super Contributor
  • ***
  • Posts: 1033
  • Country: es
    • Picuino web
Re: Learning Python
« Reply #18 on: November 27, 2022, 09:50:58 pm »
TensorFlow for C
Numpy is written in C
So... don't program in Python.
Moreover, considering that in the end the C code is actually compiled to machine code, what you should learn and use is the Assembler, which is the closest thing to the final machine code.

The bad thing about that argument is that it convinces almost nobody. Every language has its niche and for high-level logic a high-level interpreted language is much more flexible and makes programming much easier, such as Python.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf