Learn Python

Logo color python

Python is a versatile language used in a variety of applications from web development to machine learning. This page will get you up to speed on the basic syntactical elements of the language.

Write Python in 5 Minutes

Let's start writing Python by using the simple interpreter. We can print output to the terminal by using the print command. Let's print out the integer 42. Try typing:

print 42.

Watch videos and take more challenging quizzes below.

Great! Python also uses strings, which are characters wrapped in double quotes. Let's print out your name! Try:

print "[your name]"

Learn more about Python's data types below.

Fantastic! Let's try a more advanced technique called list comprehensions to show how powerful Python can be. Don't worry if you don't understand it, yet! Let's count from 1 to 10! Try typing:

print [x+1 for x in range(10)]

This is a more advanced technique, but you can learn more about for loops below.

Amazing! Another powerful technique is to encapsulate pieces of reusable code into procedures (or functions). We've introduced a function that you can call by running:


Learn more about procedures below.

Final step! Classes are powerful and fundamental concepts to object-oriented programming. They can also contain methods and properties, which can also be procedures!

Run the last command to enter the classroom!


Or, stick around and watch videos about classes below.


Icon valid


Printing, Variables & Arithmetic

Icon checkmark white
Printing & Arithmetic
Icon checkmark white
Icon checkmark white
Variables can Vary

Data Types

Icon checkmark white
Icon checkmark white
Strings & Numbers
Icon checkmark white
Indexing Strings
Icon checkmark white
Icon checkmark white
Nested Lists
Icon checkmark white
Icon checkmark white
Using Dictionaries

Conditional Statements

Icon checkmark white
If Statements
Icon checkmark white


Icon checkmark white
While Loop
Icon checkmark white
Break Statement
Icon checkmark white
For Loop


Icon checkmark white
Icon checkmark white
Using Procedures


Icon checkmark white
Definition of Classes & Methods
Icon checkmark white
Classes vs. Functions
Icon checkmark white
Defining a Class I
Icon checkmark white
Defining a Class II
Icon checkmark white
Defining init

Useful Resources

Just Python

Learn Python the Hard Way

A free online book by Zed Shaw. It's written for novice programmers looking to learn Python. It's organized by topic and has very good explanations and example code throughout. Each section ends with helpful 'Study Drills.'

Python Wiki

This reference might be overwhelming, but it has links, links and more links on everything Python.

Libraries & Frameworks


Flask is a micro web development framework. It's simple to learn, easy to understand, and well-documented. It's great for small to medium sized projects.

Django Framework

Django is a free and open source high-level web framework for Python that is commonly used in Python applications.

Developer Tools

iPython and iPython Notebook

A web-based interactive computational environment that combines code execution, text, mathematics, plots and rich media in a single document.

Python Tutor

A tool to help visualize and walk through source code.


Python Hackers

Share your Python projects with other enthusiastic developers.


This is where to ask specific code-related questions if you’re ever stuck on a problem.

Code Tricks & Examples

Python Code Snippets

A focal point for snippets of Python code that can be used (and reused) for various purposes.

Popular Python Recipes

More code examples to perform specific tasks and various snippets for whatever you might need.

Fun & Practice

Project Euler

This site provides a lot of highly mathematical problems which can be solved with programming. It's a good place for building your 'Procedural Thinking'.

Python Problem Sets

Practice opportunities from the organization that manages the Python language. Some are better than others.

Useful Articles

Python Glossary

A list of commonly used Python terms and their definitions.


A side-by-side reference of Python syntax vs other scripting languages.

Icon globe

Udacity 现已提供中文版本! A Udacity tem uma página em português para você! There's a local version of Udacity for you! Sprechen Sie Deutsch?

Besuchen Sie de.udacity.com und entdecken Sie lokale Angebote, unsere Partnerunternehmen und Udacitys deutschsprachigen Blog.

前往优达学城中文网站 Ir para a página brasileira Go to Indian Site Icon flag de Zu de.udacity.com continue in English