Python Fundamentals.
75 lectures 09:39:20
Python Fundamentals - Course Overview
Python Fundamentals takes you from zero experience to a complete understanding of key concepts, edge cases, and using Python for real-world application development. You'll move progressively from the basics to working with larger complex applications. After completing this course, you'll have the skills you need to dive into an existing application or start your own project.
An Introduction to Python - Lesson Overview
In this lesson, we will write our first Python program and play with the interpreter through the use of Python interactive shell. We will also take a look at the different ways of running a Python program. Let us cover the following topics:
- An introduction to Python
- Setting up and experiencing Python
- Naming Identifiers
- Python Syntax
An Introduction to Python
Now, let us look at different features of Python, its versions, and glance through a simple Python code.
Setting up and Experiencing Python
Before we begin, let's ensure that we have Python installed on our machine. We will learn to set it up and closely experience the Python interactive shell.
Writing and Running Programs in Python
Let us now write and run a simple 'Hello World' program. We'll also cover writing dynamic scripts in Python.
Naming Identifiers
There are different rules for naming identifiers. Let us learn about them in detail with some reserved words and practical examples. We will also get well-versed with the naming convention to write Python code.
Python Syntax
Let us learn about the syntax of writing Python scripts in detail. In this section, we will cover the following subtopics:
- Block and Inline comment
- Docstrings
- Indentation
An Introduction to Python - Lesson Summary
Let us now summarize our learning from this lesson.
An Introduction to Python - Test Your Knowledge
Variables - Lesson Overview
In this lesson, we'll cover variables, values, and user input function.
Variables, Values, and Data Types
Let us now look at what are variables, values, and data types.
User Input
In this section, we will look at how we can take user input from the keyboard, how to write comments, and the importance of indentation while writing Python code.
Variables - Lesson Summary
Let us now summarize our learning from this lesson.
Variables - Quiz
Data Types - Lesson Overview
In this lesson, we will look at other data types that are supported by Python. Data types classify data, to tell the interpreter how the program intends to utilize that data. Data types define the different operations that can be performed on the data, how the data is stored, and the meaning of the data. Let us cover the following topics:
- Numerical data
- Strings
- Lists
- Booleans
Numerical Data
Now, let us look at different types of numbers—integers, floating point numbers, binary, hexadecimal, and octal numbers—and their representation in Python console.
Strings – Part I
Let us now understand what strings are and what different operations can be performed on a string. We'll also cover indexing of a Python string. This section covers the following subtopics:
- String definition
- String Operations
- Indexing
String – Part II
Now, as you know how strings are indexed, let us look at what more can be done with the indexed strings. This section covers the following subtopics:
String – Part III
In this section, let us understand strings in more detail by covering the following subtopics:
- Strings are immutable
- String interpolation
- The str.format() method
- % formatting
String Methods/Functions
Let us learn the various string methods/functions available in Python along with practical examples.
Data Type - Lists
This is part one of two regarding lists, which we will be going through in this course. This part will act as an introduction, and will not cover the various methods that list objects have, such as extend(), remove(), pop(), and several others. We will go through the second section on lists in a later lesson.
Booleans
Finally, let us look at Booleans and the different comparison and logical operators available and their use.
Data Types - Lesson Summary
Let us now summarize our learning from this lesson.
Data Types - Quiz
Control Statements and Loops - Lesson Overview
In this lesson, we are going to build on the knowledge that we have acquired so far to dive deeper into the beautiful language that is Python. We will explore how Python handles control statements—in simple terms, how Python handles decision making, for instance, resulting to True if 2 + 3 = 5. We will also dive deeper into program flow control. In particular, we will look at how we can run code repeatedly or in a loop.
Control Statements
Let us learn the different types of control statement. This section covers the following subtopics:
- Program flow
- Control statements
- The if statements
- The elif statements
- The if…elif statements
The while Statement
In this section, we'll have a look at the while statement. Along with that, we'll also understand how the while statement differs from the if statement.
Loops
In Python, loops (just as in any other language) are a way to execute a specific block of code several times. Let us understand iterables and the for loop in this section.
The range Function and Nesting Loops
Now, let us understand the functionality of the range function. We’ll also cover how and when to use nested loops.
Breaking Out of Loops
Finally, let us look at how to break out of loops with practical examples of each. The following subtopics will be covered:
- The break Statement
- The continue Statement
- The pass Statement
Control Statements and Loops - Lesson Summary
Let us now summarize our learning from this lesson.
Control Statements - Quiz
Functions - Lesson Overview
In this lesson, we will build on knowledge by implementing what we have learned in the previous lesson, to build functions in Python.
Functions and Its Types
Functions are an integral part of the Python programming language, and a lot of languages. Let us understand functions in more detail through these subtopics:
- Functions
- Built-in functions
- User-defined functions
- Calling a function
Local and Global Variables
In this section, we'll have a look at the local and global variables. We'll also cover defining them through a practical example.
Using main ()
Most other programming languages (for example, Java and C++) require a special function, called main(), which tells the operating system what code to execute when a program is invoked. This is not necessary for Python, but in this section, you will find that it is a good and logical way to structure a program.
Function Arguments
Python supports several types of arguments, namely:
- Required arguments
- Keyword arguments
- Default arguments
- A variable number of arguments
Let us understand each one of them in detail.
Anonymous Functions
This section explains anonymous functions and demonstrates how to create and use anonymous functions.
Functions - Lesson Summary
Let us now summarize our learning from this lesson.
Functions -Quiz
Lists and Tuples - Lesson Overview
In this lesson, we'll delve deep into lists and tuples, right from creating and accessing to describing and implementing various methods with them.
Lists and Tuples - Lists
A list is a data structure that holds ordered collections of related data. Python lists, however, are more flexible and powerful than the traditional lists of other languages. Let us understand lists in more detail through this section.
List Methods
The list data type has some built-in methods that can be used with it. Let us understand their functionality.
List Methods and List Comprehensions
We'll begin this section with a demonstration on the different list methods that we saw in the previous section. We'll also cover another feature of Python, which is a concise way to create lists—list comprehensions.
Tuples
In this section we'll cover the following subtopics:
- Tuples and their properties
- Tuple operations
- Indexing
- Slicing
Let us understand each one of them in detail.
Tuple Methods
This section explains the different tuple methods available in Python.
Lists and Tuples - Lesson Summary
Let us now summarize our learning from this lesson.
Lists and Tuples - Quiz
Dictionaries and Sets - Lesson Overview
In this lesson, we'll understand the working of dictionaries and sets.
Dictionaries
You have already seen lists that hold values that you can access by using indexes. However, what if you wanted to name each value, instead of using an index? For example, suppose that you want to access a list of cake ingredients, but you do not know where in the array it is. In that case, a dictionary would come in handy. Let us understand dictionaries in more detail.
Working with Dictionaries – Part I
Let us now understand the different ways of working with dictionaries such as the various methods in dictionaries and iterating through dictionaries.
Working with Dictionaries – Part II
This section covers the following subtopics:
- Dictionary operations
- Sentence analysers
- Ordered dictionaries
Sets
In this section, we are going to cover sets, which are unique data structures with interesting properties. Let's begin our journey into sets by looking at how to create sets, how to read data from them, and how to remove data from them.
Dictionaries and Sets - Lesson Summary
Let us now summarize our learning from this lesson.
Dictionaries and Sets - Quiz
Object-Oriented Programming - Lesson Overview
At the beginning of this course, we mentioned that Python is multi-paradigm, as it supports solving problems in a functional, imperative, procedural, and object-oriented way. In this lesson, we will be diving into object-oriented programming in Python.
Classes, Objects and Their Attributes
Let us now have a look at the following subtopics:
- A first look at OOP
- Defining a class and instantiating an object
- Adding attributes to an object
The __init__ Method
In Python, the constructor method for an object is named __init__. As its name suggests, it is called when initializing an object of a class. Let us understand the working on the __init__ method in detail.
Methods in Classes
In this section, we'll look at class methods in detail.
Automated Geometric Calculations Scenario
We'll go through a practical example for the usage of methods in classes through this scenario. We'll first look at the steps needed to perform followed by a demonstration of the solution.
Class Attributes
We can define attributes at the class level. Class attributes are bound to the class itself and are shared by all instances as opposed to being bound to each instance. Let us understand class attributes through this section.
Elevator Class Attribute Scenario
Now, let us test our knowledge of class attributes using this scenario. The scenario is followed by a demonstration of the solution.
Class Methods
Class methods differ from instance methods in that they are bound to the class itself and not the instance. As such, they don't have access to instance attributes. Additionally, they can be called through the class itself and don't require the creation of an instance of the class. Let us understand class methods through this section.
Encapsulation and Information Hiding
This section explains one of the key concepts of OOP—encapsulation. Encapsulation is the bundling of data with the methods that operate on that data. It's used to hide the internal state of an object by bundling together and providing methods that can get and set the object state through an interface. This hiding of the internal state of an object is what we refer to as information hiding.
Class Inheritance
We discuss another key feature of OOP in this section—inheritance. Inheritance is a mechanism that allows for a class's implementation to be derived from another class's implementation.
Overriding Methods
In this section we discuss the following subtopics:
- Overriding methods
- Multiple inheritance
- Mixins
Object-Oriented Programming - Lesson Summary
Let us now summarize our learning from this lesson trongObject-Oriented Programming - Quiz
Modules, Packages, and File Operations - Lesson Overview
In the previous lesson, we have covered object-oriented programming in depth. We have covered...