Home
Python Tutorial
Last updated : December 18, 2023
What is Python?
Python is an object-oriented, high-level, interpreted programming language with dynamic semantics. It has a rich set of high-level in-built data structures (data types) which are combined with dynamic typing and data typing. It makes Python a very popular and attractive programming language for rapid application development, and scripting. It is simple, easy to learn, and readable and Python's codes are smaller than codes of other programming languages like C, C++, Java, etc. The codes and relatively less indented which make the code readable/editable for the programmers all the time.
The Python Tutorial
In this Python tutorial, we covered almost all topics starting from basics to advanced topics like Machine learning with Python, Python Pandas, and Python Data Science, this Python tutorial is specifically designed for beginners and professionals.
Python Tutorial Topics
Python Overview
- Introduction to Python
- Why is python so popular?
- Virtual Environment for Python based application
- Install pip on MacOS or OSx
- Executing first program on Python in Different Modes
- What does if __name__ == '__main__': do in Python?
- What __init__ and self do in Python?
- Python | How to upgrade all Python packages with pip?
Python Basics
- Python Keywords
- Python built-in keywords with examples
- Python keywords Reference
- Python Built-in Functions
- Comments in Python
- Block Comments in Python
- How do we create multiline comments in Python?
- How to read/process command line arguments in Python?
Python Data Types
- Python Variables: An Easy Guide With Examples
- Python Data Types (Complete List, Types, and Examples)
- Python Numeric Types
- How to determine a Python variable's type?
- Python type() Method (With Examples)
Python Input/Output
- Python print() function
- Input and Output Operations with Examples in Python
- Taking multiple inputs from the user using split() method in Python
- Fast input / output for competitive programming in Python
- Precision handling in Python
- Python print() function with end parameter
- sep parameter in Python with print() function
- file parameter in Python with print() function
- flush parameter in Python with print() function
- Print multiple variables in Python
- Asking the user for integer input in Python | Limit the user to input only integer value
- Asking the user for input until a valid response in Python
- Input a number in hexadecimal format in Python
- Input a number in octal format in Python
- Input a number in binary format in Python
- Read input as an integer in Python
- Read input as a float in Python
- Parse a string to float in Python (float() function)
Python Operators
- Python Arithmetic Operators
- Python Identity Operators
- Python Membership Operators
- Behavior of increment and decrement operators in Python
- Logical and Bitwise NOT Operators on Boolean in Python
- Python Logical Operators on String
- Python if else Conditional Operator
Python Conditional Statements
- Python Conditional Statements
- Python Conditional Statements with break and continue
Python Control Statements
- Python Loops
- Accessing the index in 'for' loops in Python
- Python Looping Constructs
- Implement do while loop in Python
- Python break Statement
- Python continue Statement
- Python pass Statement
- Python else with for/while statement
- Python Replacement for switch Statement
Python Functions
- Python Functions: Module's, Built-In, and User-Defined
- Different ways to define and call user-defined functions
- Function classifications on the basis of parameters and return values
- Python Function Calls: Call By Value and Reference
- Python Function Parameters: Types and Examples
- Python Default Parameters
- Python Function as Data Type
- Python Lambda Expression/Function
- Python Nested Lambda Function
- Iterating with Python Lambda
- Python map() with Lambda Function
- Python filter() with Lambda Function
- Python reduce() with Lambda Function
- Python - Passing a function as an argument
- Python - Returning a function as a return value
- Python Currying Function
- Python Multiple Function Arguments
Python Strings
- Python Strings and Its Implementation
- Python String Operators with Examples
- Python String Methods (With Examples)
- f-strings in Python 3: Formatted string literals
- How to print to stderr in Python?
- How do you read from stdin in Python?
- Best way to convert string to bytes in Python3
- What exactly do 'u' and 'r' string flags do, and what are raw string literals in Python?
- Python String Comparison
Python Modules
- How to check version of Python modules?
- Create and Import Modules in Python (with Examples)
- Python datetime Module with Examples
- Python calendar Module with Examples
- Python random Module with Examples
- Python sys Module with Examples
- Python time Module with Examples
- Python pprint (Pretty Printer) Module with Examples
- Reloading modules in Python
Python Lists
- Python Lists: A Complete Tutorial with Examples
- Python List Comprehension
-
List Methods
- Python List Programs
- Python List MCQs
Python Object Oriented Concepts
- Python Constructors
- Python Class/Static Variables
- Python Static Methods (with Examples)
- Python Metaclasses Tutorial (with Examples)
- Python @classmethod Vs. @staticmethod
- Python Class & Object Programs
Python Exception Handling
- Exceptions handling in Python
- User-defined Exception in Python
- How to ignore Exceptions in Python?
- How do you test that a Python function throws an exception?
Python Libraries and Functions
- Shallow Copy Vs Deep Copy in Python
- Python Math module methods
- Python OS & Shutil Modules Methods
Python Packages
- Python Packages | How to create and import them?
- How to create Packages (Example of Packages)?
Python Arrays
- Signed and Unsigned Integer Arrays in Python
- Common Data Items and Methods of an Array in Python
- Accessing elements from the array in Python
- Adding elements to an array in Python
- Convert an array to the list using array.tolist() in Python
- Preferred way to retrieve the length of an array in Python
-
Dask array
- Dask Array in Python
Python Numpy
- Python NumPy Tutorial
- Numpy Array Indexing in Python
- Numpy Array Operations in Python
Python Pandas
- Python for data analysis – Pandas
- Pandas DataFrame in Python (With Examples)
- Conditional selection in the DataFrame | Pandas DataFrame
- MultiIndex/Multi-level / Advance Indexing dataFrame | Pandas DataFrame
- Python Pandas – GroupBy
- Python Pandas – Merging, Joining and Concatenating
- Python Pandas – Missing Data
- Python Pandas – Data Input and Output
- Python Pandas Data Operations (With Examples)
Python Dictionary
- Python Dictionaries: A Complete Tutorial With Examples
- 11 Most Useful Python Dictionary Methods with Examples
- OrderedDict in Python (with Examples)
-
Dictionary Methods
-
Dictionary Programs
Python Set
- Sets in Python
-
Set Methods
Python Tuples
- Tuples in Python
- Reverse each tuple in a list of tuples in Python
- Creating tuple without using parenthesis in Python
- Creating a tuple with one element in Python
- Create an empty Python tuple
- Clearing a tuple in Python
- Reinitializing a tuple in Python
- Python Tuple Exercises
Python String Methods
- Python String | len() Method with Example
- Python String | count() Method with Example
- Python String | strip() Method | Remove leading and trailing spaces from string
- Python String | strip() Method | Remove leading and trailing characters from string
- Python String | isdecimal() Method with Example
- Python String | isnumeric() Method with Example
- Python String | isdigit() Method with Example
- Python | Difference between string isdecimal(), isdigit(), isnumeric() and Methods
- Python String | isalnum() and isalpha() Methods with Examples
- Python String | isupper() and islower() Methods with Examples
- Python String | join() Method with Example
- Python String | capitalize() Method with Example
- Python String | find() Method with Example
- Python String | format() Method with Example
- Python | string.upper(), string.lower() and string.title() Methods with Examples
- Python String | endswith() method with example
- Find all the indexes of all the occurrences of a word in a string in Python
- Why is it string.join(list) instead of list.join(string) in Python?
- Remove trailing new line in Python
- How do I check if a string is a number (float) in Python?
- Extracting extension from filename in Python
- Random string generation with upper case letters and digits in Python
- str() vs repr() functions in Python
- Python String formatting: % vs. .format
- What does the 'b' character do in front of a string literal in Python?
Python File methods
- Python File name Property with Example
- Python File mode Property with Example
- Python File encoding Property with Example
- Python File closed Property with Example
- Python File errors Property with Example
- Python File open() Method with Example
- Python File close() Method with Example
- Python File read() Method with Example
- Python File write() Method with Example
- Python File seek() Method with Example
- Python File flush() Method with Example
- Python File fileno() Method with Example
- Python File readable() Method with Example
- Python File writable() Method with Example
- Python File seekable() Method with Example
- Python File isatty() Method with Example
- Python File tell() Method with Example
- Python File readline() Method with Example
- Python File readlines() Method with Example
- Python File writelines() Method with Example
- Python File truncate() Method with Example
File handling in python
- File Handling in Python
- Opening, closing a file/open(), close() functions in Python
- Printing file name, closed status and file mode in Python
- Writing, Reading content of the file in Python
- How to write in an existing file in Python?
- Python | Check if a file exists or not?
- Python | Example of FileNotFoundError
- Python | print the file content along with the filename
- Python | Read file from given index (Example of tell() and seek())
- Python | Input data from the user, save to the file, read and print
- Python | Rename an existing file (Example of os.rename() method)
- Python | Remove an existing file (Example of os.remove() method)
- Importing files from different folder in Python
Python WebSocket
- What is WebSocket and how to use it in Python?
- Basic concepts of WebSocket server in Python
- How to implement a WebSocket server using Tornado?
- Implementation of WebSocket using Socket-IO in Python
- Implementation of WebSocket using Flask Socket IO in Python
- Websocket keep alive in Python
GUI programming using Python and PyQT
- GUI development using Python and PyQT
- Print ‘Hello World’ using Python and PyQT (first PyQT program)
- Print ‘Hello World’ using Python and PyQT -2 (Theory)
- Print ‘Hello World’ using Python and PyQT -2 (Practical)
- PyQt Event handling mechanism
- Event Handling Examples - PyQt
- Event Handling Examples (2)- PyQt
- Button Function and Custom Event – PyQt
- PyQt- Layout management - 1 (Drag and Drop with QtDesigner)
Python GUI programming using tkinter
- GUI programming in Python using tkinter Module
- Python | Text Area and Button in Tkinter
Python Image processing
- Drawing flag of Thailand | Image processing in Python
- Drawing of flag Sweden | Image processing in Python
- Drawing flag of Japan | Image processing in Python
- Coloured image to grayscale using OpenCV in Python
- Find complementary image of the RGB image in Python
- Show different planes of an RGB image in Python
- Resize a grayscale image without using any inbuilt functions in Python
- Resize an RGB image without using any inbuilt functions in Python
- Convert an RGB format Image in an HSV format Image using OpenCV in Python
- Rotate a grayscale image by 180 degree without using any inbuilt function in Python
- Smoothen a grayscale image by performing blurring operation using user defined median blur filter
- Smoothen the image by performing blurring operation on a grayscale image using user defined mean blur filter in Python
- Upscaling the grayscale image in Python
- Upscaling the RGB image in Python
- Read an image and save it as grayscale system using OpenCV python module
- Edge Detection of Image using OpenCV (CV2) in Python
- Cropping an Image using OpenCV in Python
- How to Generate and Read QR Code using Python and OpenCV?
- Capturing mouse click events with Python and OpenCV
- Face and Eye Detection in Python using OpenCV
- Create a Collage of Images with the help of NumPy and Python-OpenCV(CV2)
Python Flask
- Introduction to Web development using Flask
- For loop in Flask template engine
Python Working with Excel
Python Keywords
Exercise of built-in functions
Python Math module methods
Python Math module constants
Python OS & Shutil Modules Methods
Python operator Module Methods
Python Topic-wise MCQs
Find output of programs
- Find output of Python programs -| Set 1 (Mixed topics)
- Find output of Python Programs | Set 1 (Basics)
- Find Output of Python programs | Set 2 (Basics)
Python Competitive Coding Questions
- Python Arithmetic Sequences | Competitive Coding Questions
- Python Power Challenge | Competitive Coding Questions
- Python XOR and Arrays | Competitive Coding Questions
- All Python competitive coding questions
Miscellaneous
- Matrix implementation in Python
- Matrix Multiplication in Python
- Descriptors in Python
- How to call an external command in Python?
- Slice Notation in Python
- Understanding slice notation with examples in Python
- 5 Best Python Web Scraping Libraries
- How do I parse an ISO 8601-formatted date in Python?
- What is the quickest way to HTTP GET in Python?
- timeit() Function with Example in Python
- Optimization using Greedy Algorithm in Python
- Python | Linear Algebra
- Python | Data Visualization
- Perceptron algorithm and its implementation in Python
- Scraping Links from a Webpage in Python
- Text to speech model in Python
- Alarm clock in Python with the help of datetime and pyttsx3
- Sending Emails using SMTP in Python
- Getting old tweets using Getoldtweets3 module in Python
- Automating pdfs in Python
- Rock Paper Scissors Game in Python
- How to download YouTube videos in Python?
- Python | Binary numbers representation (assign, conversion, bitwise operations)
- How to install Tkinter in Python?
- Generators in Python
- List Comprehension vs Generators Expression in Python