Sage-Code Laboratory

Python Tutorial

Python is a high-level dynamic computer language. At this time is the most popular programming language according to Tiobe Index. Python was written by Guido van Rossum as a system scripting language. Many universities are using Python to teach programming concepts of Computer Science.

Course Scope

This tutorial is for very beginners. We have presented the language features in logical order with short examples and notes. We will improve this course using AI. The course will grow from beginner to intermediate level. Python is good entry level language. We will cover fundamental concepts of programming usin Python.

Curriculum

This tutorial is organized like a book. At the end of each page there is a link for the next page. Every page has the index link on top right corner, that will bring you back here. If you wish to go back to a previous chapter, use the browser back button or the index below. If you are first time here, skip the index and read on the entire page. You will use the index later.

Course Index:


  1. syntax
  2. variables
  3. control flow
  4. functions
  5. classes
  6. packages

Python Issues:

Python is a great language if you use it for the right project. It is a productive language, but you should be aware of several limitations before choosing to use Python. There are other languages much better alternatives to Python that we recommand for beginners.

Why is Python slow?

Python was designed to be "user friendly" that is why it is a dynamic typed language and not a static typed language. In dynamic languages you can change value and value type for a variable during runtime. This means there is no code optimization and there must be a garbage collector somewhere that slows down complex processes.

Another problem Python has is the GIL (global interpreter lock) this is hard to explain but it makes multi-core/parallel applications work slow. Actually this problem is resolved still for some reasons python multitasking is sluggish.

But… this it also depend on algorithms you are using. How much data you store in memory and how this data is organized. Python do not have Arrays like C, C++ and Java. Array require fix data length. In Python a collection can hold any kind of data: Numeric, String even other collections. So you can have a list of lists or a dictionary of lists. This is why Python is so slow. It uses dynamic lists.

Python examples

We have set-up several code snippets that you can clone from GitHub, investigate and modify. We have used these examples during the course. You can use replit or jupiter notebook, to create and run code on-line. Feel free to explore:

External Code:


  1. github.com
  2. colab.research
  3. repl.it

Other Resources

Making a large project in Python require practice. Professional developers work locally on desktop computers and laptops. You can setup Python interpreter on your computer. Also there is a nice IDE available called IDLE. To make advanced projects in Python I recommend PyCharm IDE editor that has a community edition.

Python I - Prep Quiz

Next quiz has 100 questions, each question value one point. It is special designed for a mobil device. You can click, tap or scan the image below to start. This quiz does not have time limit, but it requires you to sign-in using your Google account. Break a leg!
Python Quiz

Python Quiz

Privacy Terms: We do not collect your e-mail address but we record your name with the test results on Google drive. If you take more than 80% we will recognize your skill and will endorse you on Linked-in. If you don't agree, you can use name: Anonymous but then we can't endorse your new skills.

Before taking this quiz, you should learn some Python. We organize this tutorial like a book so you can turn page by pressing the link below. Before you do, we advice you to take a break here and stretch your legs. Very important!


Start learning: Python Syntax