Python Tutorial for Beginners - Learn Python from Scratch with Examples

Python Tutorial for Beginners - Learn Python from Scratch with Examples

This Python Tutorial for Beginners will help you learn Python programming language and its core concepts with examples from scratch.

This Python Tutorial for Beginners will help you learn Python programming language and its core concepts with examples from scratch.

This Python tutorial video helps you to learn the following concepts:

  • 1:55 What is Python?
  • 3:40 Why is Python popular?
  • 4:55 Features of Python
  • 6:50 Where is Python used in the industry?
  • 7:50 Learning Path
  • 9:15 Career Opportunities
  • 10:30 How Netflix use Python?
  • 11:55 How does it use Python?
  • 18:15 Python Developer Salary
  • 18:50 Who is Python Developer?
  • 19:20 Python Developer Job Trends
  • 21:55 How to become a Python Developer?
  • 23:05 Who is a Python developer?
  • 33:50 Job Roles
  • 41:40 Emerging Job Roles
  • 44:30 Road Map
  • 47:05 Python Installation
  • 54:30 How to run a Python program?
  • 58:35 Best IDE for Python
  • 59:35 What is an IDE?
  • 59:50 Features of an IDE
  • 1:00:50 Best IDEs of Python
  • 1:07:40 PyCharm Tutorial
  • 1:07:42 Introduction to PyCharm
  • 1:09:07 Features of PyCharm
  • 1:28:02 Comments in Python
  • 1:28:52 What are Comments?
  • 1:29:47 When to use Python?
  • 1:30:22 How to write comments in Python?
  • 1:32:22 Types of Comments
  • 1:35:57 Docstring Comments
  • 1:39:02 Variables & Data Types
  • 1:39:17 Variable definition & Declaration
  • 1:41:22 Data Types
  • 1:41:42 Numbers
  • 1:43:12 String
  • 1:46:02 List
  • 1:48:12 Dictionary
  • 1:50:12 Tuple
  • 1:51:27 Set
  • 1:53:52 Type Conversion
  • 1:54:42 Python Collections
  • 1:57:12 Specialised Collections Data Types
  • 2:14:57 Arrays
  • 2:15:32 What is an Array?
  • 2:17:27 How to create Arrays in Python?
  • 2:20:52 Accessing Array Elements
  • 2:22:42 Basic Array Operations
  • 2:24:27 Adding elements to an Array
  • 2:27:52 Removing Elements of an Array
  • 2:33:42 Slicing an Array
  • 2:36:12 Looping through an Array
  • 2:39:57 Hash Table and HashMap
  • 2:41:37 Creating Dictionaries
  • 2:44:02 Nested dictionaries
  • 2:46:52 Performing Operations on Hash Table
  • 2:55:32 Operators in Python
  • 3:13:17 Loops in Python
  • 3:13:52 Why to use Python?
  • 3:16:12 What are Loops?
  • 3:18:07 Loops in Python
  • 3:18:17 While Loop
  • 3:26:22 For Loop
  • 3:32:22 Nested Loop
  • 3:48:12 Patterns in Python
  • 4:24:27 File Handling
  • 4:25:07 Why need File Handling
  • 4:27:02 Types of Files
  • 4:28:37 What is File Handling?
  • 4:29:22 Python File Handling System
  • 4:32:52 File Operations for Reading
  • 4:41:27 Python File Write Method
  • 4:47:37 Decorator
  • 4:48:22 Functions in Python
  • 4:54:07 Decorators in Python
  • 5:08:32 Lambda
  • 5:10:17 How to write Anonymous functions?
  • 5:29:02 Map-Reduce Functions
  • 5:29:47 Introduction to map(), filter(), reduce()
  • 5:46:22 What are Generators?
  • 5:47:32 Normal functions vs Generators
  • 5:48:02 Writing Generators in Python
  • 5:52:57 Generators with Loops
  • 5:53:57 Generator Expressions
  • 5:56:22 Use-Cases
  • 6:02:27 OOPS Concepts
  • 6:03:07 Classes & Objects
  • 6:33:47 Inheritance in Python
  • 6:36:52 Types of Inheritance
  • 6:42:47 Python Super Function
  • 6:44:52 Exception Handling
  • 6:54:42 Try & Except block
  • 7:05:52 Python Module
  • 7:07:47 How to create a Module?
  • 7:17:33 Python Modules Search Path
  • 7:24:23 Date & Time
  • 7:24:58 time module
  • 7:38:23 Numpy
  • 7:38:58 What is Numpy?
  • 7:41:43 Numpy vs List
  • 7:49:03 Numpy Operations
  • 8:05:23 Numpy Special Functions
  • 8:09:58 SciPy
  • 8:10:48 What is Python SciPy?
  • 8:12:23 Basic Functions
  • 8:15:48 Special Functions
  • 8:18:53 Integration Functions
  • 8:24:43 Linear Algebra
  • 8:26:48 Interpolation Functions
  • 8:28:18 Pandas
  • 8:29:18 Data life-cycle
  • 8:31:23 What is Pandas?
  • 8:35:33 Pandas Operations
  • 8:54:13 Example
  • 8:59:38 Python for Statistics
  • 9:02:43 Pydoop
  • 9:04:03 Matplotlib
  • 9:04:28 Data Visualization
  • 9:09:13 Matplotlib
  • 9:10:13 Types of Plots
  • 9:30:13 Multiple Plots
  • 9:32:18 Seaborn
  • 9:32:53 Introduction to Seaborn
  • 9:33:33 Seaborn vs Matplotlib
  • 9:34:28 How to install Seaborn?
  • 9:34:48 Installing Dependencies
  • 9:35:33 Python Seaborn Functions
  • 9:44:23 Multi-Plot Grids
  • 9:47:08 Plot Aesthetics
  • 9:50:58 FIFA Use-case
  • 10:15:33 OpenCV Tutorial
  • 10:16:03 What is Computer Vision?
  • 10:16:48 How computer reads an Image?
  • 10:18:53 What is OpenCV?
  • 10:19:58 Basic operations with OpenCV
  • 10:27:33 Face Detection
  • 10:27:38 Face Detection using OpenCV
  • 10:31:53 Capturing Video
  • 10:43:28 Use-case - Motion Detector
  • 10:54:58 Web Development Framework
  • 10:55:23 What are Frameworks in Python?
  • 11:08:34 Python Web Development
  • 11:09:04 Python Web Development Libraries
  • 11:09:24 Python & Django
  • 11:28:19 Web Scraping
  • 11:33:49 Packages used for web Scraping

Dictionaries in Python - Learn how to work with Python Dictionaries

Dictionaries in Python - Learn how to work with Python Dictionaries

In this Python Dictionaries tutorial, you will learn how to work with Python Dictionaries, an incredibly helpful built-in data type that you will definitely use during your projects. In this Python dictionaries tutorial you'll cover the basic characteristics and learn how to access and manage dictionary data. Learn everything about Python dictionary; how they are created, accessing, adding and removing elements from them and, various built-in methods.


In this article, you will learn how to work with Python Dictionaries, an incredibly helpful built-in data type that you will definitely use during your projects.

In particular, you will learn:

  • What dictionaries are used for and their main characteristics.
  • Why they are important for your programming projects.
  • The "anatomy" of a dictionary: keys, values, and key-value pairs.
  • The specific rules that determine if a value can be a key.
  • How to access, add, modify, and delete key-value pairs.
  • How to check if a key is in a dictionary.
  • What the length of a dictionary represents.
  • How to iterate over dictionaries using for loops.
  • What built-in dictionary methods you can use to leverage the power of this data type.

At the end of this article, we will dive into a simple project to apply your knowledge: we will write a function that creates and returns a dictionary with a particular purpose.

Let's begin! 🔅

🔸 Dictionaries in Context

Let's start by discussing the importance of dictionaries. To illustrate this, let me do a quick comparison with another data type that you are probably familiar with: lists.

When you work with lists in Python, you can access an element using a index, an integer that describes the position of the element in the list. Indices start from zero for the first element and increase by one for every subsequent element in the list. You can see an example right here:

But what if we need to store two related values and keep this "connection" in our code? Right now, we only have single, independent values stored in a list.

Let's say that we want to store names of students and "connect" each name with the grades of each particular student. We want to keep the "connection" between them. How would you do that in Python?

If you use nested lists, things would get very complex and inefficient after adding only a few items because you would need to use two or more indices two access each value, depending on the final list. This is where Python Dictionaries come to the rescue.

Meet Dictionaries

A Python dictionary looks like this (see below). With a dictionary, you can "connect" a value to another value to represent the relationship between them in your code. In this example,"Gino" is "connected" to the integer 15 and the string "Nora" is "connected" to the integer 30.

Let's see the different elements that make a dictionary.

🔹 The "Anatomy" of a Python Dictionary

Since a dictionary "connects" two values, it has two types of elements:

  • Keys: a key is a value used to access another value. Keys are the equivalent of "indices" in strings, lists, and tuples. In dictionaries, to access a value, you use the key, which is a value itself.
  • Values: these are the values that you can access with their corresponding key.

These two elements form what is called a key-value pair (a key with its corresponding value).


This is an example of a Python Dictionary mapping the string "Gino" to the number 15 and the string "Nora" to the number 30:

>>> {"Gino": 15, "Nora": 30}

  • To create a dictionary, we use curly brackets { } .
  • Between these curly brackets, we write key-value pairs separated by a comma.
  • For the key-value pairs, we write the key followed by a colon, a space, and the value that corresponds to the key.

💡 Tips:

  • For readability and style purposes, it is recommended to add a space after each comma to separate the key-value pairs.
  • You can create an empty dictionary with an empty pair of curly brackets {}.

Important Rules for Keys

Not every value can be a key in a Python dictionary. Keys have to follow a set of rules:

According to the Python Documentation:

  • Keys have to be unique within one dictionary.

It is best to think of a dictionary as a set of key: value pairs, with the requirement that the keys are unique (within one dictionary).

  • Keys have to be immutable.

Unlike sequences, which are indexed by a range of numbers, dictionaries are indexed by keys, which can be any immutable type; strings and numbers can always be keys.

  • If the key is a tuple, it can only contain strings, numbers or tuples.

Tuples can be used as keys if they contain only strings, numbers, or tuples; if a tuple contains any mutable object either directly or indirectly, it cannot be used as a key.

  • Lists cannot be keys because they are mutable. This is a consequence of the previous rule.

You can’t use lists as keys, since lists can be modified in place using index assignments, slice assignments, or methods like append() and extend().

💡 Note: Values have no specific rules, they can be either mutable or immutable values.

🔸 Dictionaries in Action

Now let's see how we can work with dictionaries in Python. We are going to access, add, modify, and delete key-value pairs.

We will start working with this dictionary, assigned to the ages variable:

>>> ages = {"Gino": 15, "Nora": 30}

Access Values using Keys

If we need to access the value associated with a specific key, we write the name of the variable that references the dictionary followed by square brackets [] and, within square brackets, the key that corresponds to the value:


This is an example of how we can access the value that corresponds to the string "Gino":

>>> ages = {"Gino": 15, "Nora": 30}
>>> ages["Gino"]

Notice that the syntax is very similar to indexing a string, tuple, or list, but now we are using the key as the index instead of an integer.

If we want to access the value that corresponds to "Nora", we would do this:

>>> ages = {"Gino": 15, "Nora": 30}
>>> ages["Nora"]

💡 Tip: If you try to access a key that does not exist in the dictionary, you will get a KeyError:

>>> ages = {"Gino": 15, "Nora": 30}
>>> ages["Talina"]
Traceback (most recent call last):
  File "<pyshell#10>", line 1, in <module>
KeyError: 'Talina'

Add Key-Value Pairs

If a key-value pair doesn't exist in the dictionary, we can add it. To do this, we write the variable that references the dictionary followed by the key within square brackets, an equal sign, and the new value:

This is an example in IDLE:

>>> ages = {"Gino": 15, "Nora": 30}

# Add the key-value pair "Talina": 24
>>> ages["Talina"] = 24

# The dictionary now has this key-value pair
>>> ages
{'Gino': 15, 'Nora': 30, 'Talina': 24}

Modify a Key-Value Pair

To modify the value associated to a specific key, we use the same syntax that we use to add a new key-value pair, but now we will be assigning the new value to an existing key:

>>> ages = {"Gino": 15, "Nora": 30}

# The key "Gino" already exists in the dictionary, so its associated value
# will be updated to 45.
>>> ages["Gino"] = 45

# The value was updated to 45.
>>> ages
{'Gino': 45, 'Nora': 30}

Deleting a Key-Value Pair

To delete a key-value pair, you would use the del keyword followed by the name of the variable that references the dictionary and, within square brackets [], the key of the key-value pair:

This is an example in IDLE:

>>> ages = {"Gino": 15, "Nora": 30, "Talina": 45}

# Delete the key-value pair "Gino": 15.
>>> del ages["Gino"]

# The key-value pair was deleted.
>>> ages
{'Nora': 30, 'Talina': 45}
🔹 Check if a Key is in a Dictionary

Sometimes, it can be very helpful to check if a key already exists in a dictionary (remember that keys have to be unique).

According to the Python Documentation:

To check whether a single key is in the dictionary, use the in keyword.

>>> ages = {"Gino": 15, "Nora": 30, "Talina": 45}
>>> "Talina" in ages
>>> "Gino" in ages
>>> "Lulu" in ages

The in operator checks the keys, not the values. If we write this:

>>> 15 in ages

We are checking if the key 15 is in the dictionary, not the value. This is why the expression evaluates to False.

💡 Tip: You can use the in operator to check if a value is in a dictionary with .values().

>>> ages = {"Gino": 15, "Nora": 30, "Talina": 45}
>>> 30 in ages.values()
>>> 10 in ages.values()
🔸 Length of a Python Dictionary

The length of a dictionary is the number of key-value pairs it contains. You can check the length of a dictionary with the len() function that we commonly use, just like we check the length of lists, tuples, and strings:

# Two key-value pairs. Length 2.
>>> ages = {"Gino": 15, "Nora": 30}
>>> len(ages)

# Three key-value pairs. Length 3.
>>> ages = {"Gino": 15, "Nora": 30, "Talina": 45}
>>> len(ages)
🔹 Iterating over Dictionaries in Python

You can iterate over dictionaries using a for loop. There are various approaches to do this and they are all equally relevant. You should choose the approach that works best for you, depending on what you are trying to accomplish.

First Option - Iterate over the Keys

We can iterate over the keys of a dictionary like this:

for <key> in <dictionary>:
	# Do this

For example:

>>> ages = {"Gino": 15, "Nora": 30, "Talina": 45}
>>> for student in ages:


Second Option - Iterate over the Key-Value Pairs

To do this, we need to use the built-in method .items(), which allows us to iterate over the key-value pairs as tuples of this format (key, value).

for <key-value-pair-as-tuple> in <dictionary>.items():
	# Do this

For example:

>>> ages = {"Gino": 15, "Nora": 30, "Talina": 45}

>>> for pair in ages.items():

('Gino', 15)
('Nora', 30)
('Talina', 45)

Third Option - Assign Keys and Values to Individual Variables

With .items() and for loops, you can use the power of a tuple assignment to directly assign the keys and values to individual variables that you can use within the loop:

>>> ages = {"Gino": 15, "Nora": 30, "Talina": 45}

# Tuple assignment to assign the key to the variable key 
# and the value to the variable value.
>>> for key, value in ages.items():
	print("Key:", key, "; Value:", value)

Key: Gino ; Value: 15
Key: Nora ; Value: 30
Key: Talina ; Value: 45

Fourth Option - Iterate over the Values

You can iterate over the values of a dictionary using the .values() method.

>>> ages = {"Gino": 15, "Nora": 30, "Talina": 45}
>>> for age in ages.values():

🔸 Dictionary Methods

Dictionaries include very helpful built-in methods that can save you time and work to perform common functionality:


This method removes all the key-value pairs from the dictionary.

>>> ages = {"Gino": 15, "Nora": 30, "Talina": 45}
>>> ages.clear()
>>> ages

.get(, )

This method returns the value associated with the key. Otherwise, it returns the default value that was provided as the second argument (this second argument is optional).

>>> ages = {"Gino": 15, "Nora": 30, "Talina": 45}
>>> ages.get("Nora")
>>> ages.get("Nor", "Not Found")
'Not Found'

If you don't add a second argument, this is equivalent to the previous syntax with square brackets []that you learned:

>>> ages = {"Gino": 15, "Nora": 30, "Talina": 45}
>>> ages["Nora"]
>>> ages.get("Nora")

.pop(, )

This method removes the key-value pair from the dictionary and returns the value.

>>> ages = {"Gino": 15, "Nora": 30, "Talina": 45}
>>> ages.pop("Talina")
>>> ages
{'Gino': 15, 'Nora': 30}


This method replaces the values of a dictionary with the values of another dictionary only for those keys that exist in both dictionaries.

An example of this would be a dictionary with the original grades of three students (see code below). We only want to replace the grades of the students who took the make-up exam (in this case, only one student took the make-up exam, so the other grades should remain unchanged).

>>> grades = {"Gino": 0, "Nora": 98, "Talina": 99}
>>> new_grades = {"Gino": 67}
>>> grades.update(new_grades)
>>> grades
{'Gino': 67, 'Nora': 98, 'Talina': 99}

By using the .update() method, we could update the value associated with the string "Gino" in the original dictionary since this is the only common key in both dictionaries.

The original value would be replaced by the value associated with this key in the dictionary that was passed as argument to .update().

💡 Tips: To learn more about dictionary methods, I recommend reading this article in the Python Documentation.

🔹 Mini Project - A Frequencies Dictionary

Now you will apply your knowledge by writing a function freq_dict that creates and returns a dictionary with the frequency of each element of a list, string, or tuple (the number of times the element appears). The elements will be the keys and the frequencies will be the values.


We will be writing the function step-by-step to see the logic behind each line of code.

  • Step 1: The first thing that we need to do is to write the function header. Notice that this function only takes one argument, the list, string or tuple, which we call data.
def freq_dict(data):
  • Step 2: Then, we need to create an empty dictionary that will map each element of the list, string, or tuple to its corresponding frequency.
def freq_dict(data):
	freq = {}
  • Step 3: Then, we need to iterate over the list, string, or tuple to determine what to do with each element.
def freq_dict(data):
	freq = {}
	for elem in data: 
  • Step 4: If the element has already been included in the dictionary, then the element appears more than once and we need to add 1 to its current frequency. Else, if the element is not in the dictionary already, it's the first time it appears and its initial value should be 1.
def freq_dict(data):
	freq = {}
	for elem in data:
		if elem in freq:
			freq[elem] += 1
			freq[elem] = 1
  • Step 5: Finally, we need to return the dictionary.
def freq_dict(data):
	freq = {}
	for elem in data:
		if elem in freq:
			freq[elem] += 1
			freq[elem] = 1
	return freq

🔔 Important: Since we are assigning the elements as the keys of the dictionary, they have to be of an immutable data type.


Here we have an example of the use of this function. Notice how the dictionary maps each character of the string to how many times it occurs.

>>> def freq_dict(data):
	freq = {}
	for elem in data:
		if elem in freq:
			freq[elem] += 1
			freq[elem] = 1
	return freq

>>> freq_dict("Hello, how are you?")
{'H': 1, 'e': 2, 'l': 2, 'o': 3, ',': 1, ' ': 3, 'h': 1, 'w': 1, 'a': 1, 'r': 1, 'y': 1, 'u': 1, '?': 1}

This is another example applied to a list of integers:

>>> def freq_dict(data):
	freq = {}
	for elem in data:
		if elem in freq:
			freq[elem] += 1
			freq[elem] = 1
	return freq

>>> freq_dict([5, 2, 6, 2, 6, 5, 2, 2, 2])
{5: 2, 2: 5, 6: 2}

Great Work! Now we have the final function.

🎓 In Summary
  • Dictionary are built-in data types in Python that associate (map) keys to values, forming key-value pairs.
  • You can access a value with its corresponding key.
  • Keys have to be of an immutable data type.
  • You can access, add, modify, and delete key-value pairs.
  • Dictionaries offer a wide variety of methods that can help you perform common functionality.

Originally published by Estefania Cassingena Navone at

Python GUI Programming Projects using Tkinter and Python 3

Python GUI Programming Projects using Tkinter and Python 3

Python GUI Programming Projects using Tkinter and Python 3

Learn Hands-On Python Programming By Creating Projects, GUIs and Graphics

Python is a dynamic modern object -oriented programming language
It is easy to learn and can be used to do a lot of things both big and small
Python is what is referred to as a high level language
Python is used in the industry for things like embedded software, web development, desktop applications, and even mobile apps!
SQL-Lite allows your applications to become even more powerful by storing, retrieving, and filtering through large data sets easily
If you want to learn to code, Python GUIs are the best way to start!

I designed this programming course to be easily understood by absolute beginners and young people. We start with basic Python programming concepts. Reinforce the same by developing Project and GUIs.

Why Python?

The Python coding language integrates well with other platforms – and runs on virtually all modern devices. If you’re new to coding, you can easily learn the basics in this fast and powerful coding environment. If you have experience with other computer languages, you’ll find Python simple and straightforward. This OSI-approved open-source language allows free use and distribution – even commercial distribution.

When and how do I start a career as a Python programmer?

In an independent third party survey, it has been revealed that the Python programming language is currently the most popular language for data scientists worldwide. This claim is substantiated by the Institute of Electrical and Electronic Engineers, which tracks programming languages by popularity. According to them, Python is the second most popular programming language this year for development on the web after Java.

Python Job Profiles
Software Engineer
Research Analyst
Data Analyst
Data Scientist
Software Developer
Python Salary

The median total pay for Python jobs in California, United States is $74,410, for a professional with one year of experience
Below are graphs depicting average Python salary by city
The first chart depicts average salary for a Python professional with one year of experience and the second chart depicts the average salaries by years of experience
Who Uses Python?

This course gives you a solid set of skills in one of today’s top programming languages. Today’s biggest companies (and smartest startups) use Python, including Google, Facebook, Instagram, Amazon, IBM, and NASA. Python is increasingly being used for scientific computations and data analysis
Take this course today and learn the skills you need to rub shoulders with today’s tech industry giants. Have fun, create and control intriguing and interactive Python GUIs, and enjoy a bright future! Best of Luck
Who is the target audience?

Anyone who wants to learn to code
For Complete Programming Beginners
For People New to Python
This course was designed for students with little to no programming experience
People interested in building Projects
Anyone looking to start with Python GUI development
Basic knowledge
Access to a computer
Download Python (FREE)
Should have an interest in programming
Interest in learning Python programming
Install Python 3.6 on your computer
What will you learn
Build Python Graphical User Interfaces(GUI) with Tkinter
Be able to use the in-built Python modules for their own projects
Use programming fundamentals to build a calculator
Use advanced Python concepts to code
Build Your GUI in Python programming
Use programming fundamentals to build a Project
Signup Login & Registration Programs
Job Interview Preparation Questions
& Much More

Guide to Python Programming Language

Guide to Python Programming Language

Guide to Python Programming Language

The course will lead you from beginning level to advance in Python Programming Language. You do not need any prior knowledge on Python or any programming language or even programming to join the course and become an expert on the topic.

The course is begin continuously developing by adding lectures regularly.

Please see the Promo and free sample video to get to know more.

Hope you will enjoy it.

Basic knowledge
An Enthusiast Mind
A Computer
Basic Knowledge To Use Computer
Internet Connection
What will you learn
Will Be Expert On Python Programming Language
Build Application On Python Programming Language