GithubHelp home page GithubHelp logo

learning-python's Introduction

Learning Python

Playground for the course Learning Python by Joe Marini on LinkedIn Learning

Preparations

$ python --version
Python 2.7.16

$ python3 --version
Python 3.7.6 

Run /Applications/Python 3.8/Install Certificates.command to install TLS root certificates.

vscode

You can change the Python version used by the Python extension in vscode

  • in the bottom toolbar of vscode
  • in 'python version' under Extensions/Python in the vscode settings (e.g. 'python' for Python v2 and 'python3' for Python v3)

Hello World

Python is an interpreted language (like JavaScript). You don't have to compile the source code and build an executable before you can run it (like Java or C/C++).

from the command line

$ python3 helloWorld.py

from the python shell

$ python3
Python 3.8.1 (v3.8.1:1b293b6006, Dec 18 2019, 14:08:53) (...)
>>> 2+2
4
>>> print("Hello world!")
Hello world!
>>> exit()
$ 

with the vscode debugger

When you open the debug view in vscode for the first time, there are no launch configurations. Click the "create a launch.json file" link and choose "Python file (debug the currently active Python file)". A file .vscode/launch.json will be created:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        }
    ]
}

Now open a *.py file in vscode and in the debug view, hit the "Start debugging" button (green triangle).

Characteristics of the Python language

  • dynamically typed
  • strongly typed
  • single-line comment # some comment
  • multi-line comment (like /* bladibla ... */ in Java) not supported
  • scope defined by colon & indentation (instead of curly braces in Java)
  • no equivalent of the Java switch statement (use if / elif / else instead)
  • for-loops:
    • while(condition):
    • for x in range(5, 10):
    • for x in <collection>:
    • for i,x in enumerate(<collection>): gives you access to the loop counter

Documentation

  • python 3.8 documentation
    • datetime
    • timedelta
      • print ("one week from now it will be: " + str(datetime.now() + timedelta(weeks=1)))
      • supports seconds, minutes, hours, days and weeks; but not months or years!
    • calendar
      • generate a (highly configurable) HTML calendar for a specific month
      • iterate over the weekdays, monthdays, monthdates, yeardays, yeardates, ..
      • calculate the first wednesday of each month, etc. etc.
    • files basic file operations like reading and writing are available by default (no import needed)
    • os information about the OS, environment, path utilities, file descriptors, etc.
    • shutil shell utilities like copy, rename, archive (zip/tar/..)
    • zipfile fine grained control over zip file creation
    • urllib
    • http.client
    • xml.dom
      • xml.dom.minidom a minimal implementation of the Document Object Model interface

datetime formatting

HTML parsing

An example of HTML parsing can be found here.

learning-python's People

Contributors

roelfie avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

jdpc86 yasu094

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.