Operators
- Arithmetic Operators
- Bitwise Operators
- Identity Operators
- Logical Operators
- Relational Operators
Arithmetic Operators
Logical Operators
Identity Operators
Relational Operators
Bitwise Operators
Other Operators
Console Input and Output
Other Basics
Random Module
- Python – Generate Random Number
- Python – Generate Random Number of Specific Length
- Python – Generate Random String of Specific Length
- Python – Generate Random Float
- Python – Generate Random Float based on Gaussian Distribution
- Python – Generate Random Float based on Normal Distribution
- Python – Generate Random Float based on Exponential Distribution
- Python – Choose Random Element from a Sequence
- Python – Choose List of Random Elements from a Sequence
- Python – Generate Random Password
- Python – Flip a Coin
Strings
Basics
- Python – Print String to Console Output
- Python – Access characters of string using index
- Python – Check if String is Empty
- Python – String Length
- Python – Substring of a String
- Python – Reverse String
- Python – Slice a String
- Python – Iterate over Words of String
- Python – Find the index of first occurrence of substring in a String
- Python – Find the number of Overlapping Occurrences of a Substring in a String
- Python – Remove White Spaces at Start and End of String
- Python – Convert String to Lowercase Example
- Python – Convert String to Uppercase Example
- Python – Capitalize First Character of String
- Python – List of Strings
- Python – Check if All Strings in a Python List are not Empty
- Python – Get first character of String
- Python – Get last character of String
- Python – Iterate over characters of string
- Python – Compare Strings
- Python – Place Variables in String
- Python – Escape Characters
Contains
Replacements
Split Operations
Sorting
Python List Examples
Python List Operations – Python Lists are kind of arrays that can store items of different datatypes. These series of Python Examples explain CRUD Operations, and element wise operations on Python Lists.
Python Dictionary Examples
Python Dictionary is a datatype that stores non-sequential key:value pairs. This series of Python Examples will let you know how to operate with Python Dictionaries and some of the generally used scenarios.
- Python Dictionary – Introduction to Python Dictionary
- Python Dictionary Methods – Method of dict class
- Python Dictionary Operations – Howtos on Dictionary
Python Set Examples
Python Set is a non-ordered collection of items. Following list of Python Examples will present you about a Set in Python and different methods available for Set class.
- Python Set – Introduction to Python Set
- Python Set Methods – Methods of Set class
- Python Set Operations – Howtos on Set
Python Tuple Examples
Tuple is an immutable and ordered collection or items. Following list of Python Examples will provide more examples for different operations on Tuples.
- Python Tuple
- Python Tuple Operations
- Python Tuple Length
- Python Tuple – While Loop
- Python Tuple – For Loop
Python File Operations
Perform file operations like read, write, append, update, delete on files, folders etc. programmatically with Python.
- Python – Read Text File
- Python – Read Text File Line by Line
- Python – Write String to Text File
- Python – Delete or Remove File
- Python – Create a Directory
- Python – Check if Specified Path is File or Directory
- Python – Get the List of all Files in a Directory and its Sub-directories recursively.
- Python – Append Text to File
- Python – Replace a String in Text File
- Python – Replace multiple spaces with single space in a Text File
- Python – Count Number of Words in a Text File
- Python – Count Number of Characters in a Text File
Python JSON Examples
- Python – Create JSON
- Python – Parse JSON String
- Python – Convert Class Object to JSON
- Python – Convert Tuple to JSON Array
- Python – Convert CSV to JSON
- Python – Convert JSON to Dictionary
- Python – Convert JSON to List
- Python – Convert List to JSON
- Python – Read JSON File
- Python – Write JSON to File
Python CSV Examples
Python Input Output Operations Examples
These examples cover programs that read input from user, or display output to user via console.
- Python Example to Print to Console Output
- Python input() Function
- Python Example to Read Number from Console Input
- Python Example to Read String from Console Input
- Python Print without new line at the end
Python Exception Handling
Exception Handling deals with the possible exceptions that could occur in your programs, and how to handle them using Python statements like try-except, etc.
- Python Try-Except – Handle exceptions thrown at runtime programmatically.
- Python TypeError: method() takes 0 positional arguments but 1 was given
- Python ModuleNotFoundError: No module named ‘openpyxl’
- Python Requests TimeoutError: [WinError 10060] A connection attempt failed
- Python NameError: name ‘string’ is not defined
- Python NameError: name ‘logging’ is not defined
Python Logging Examples
Python logging library helps you manage your logging strategy and how to write useful messages to the log files for maintaining your application.
Get started with Python Logging.
- Python Logging Messages to a Log File
- Python Logging – Set DEBUG Level
- Python Logging – Set INFO Level
- Python Logging – Set WARNING Level
- Python Logging – Set ERROR Level
- Python Logging – Set CRITICAL Level
Python Date and Time
- Python DateTime.now()
- Python DateTime Format
- Python Compare DateTime
- Python – Convert String to Datetime
- Python – Convert Datetime to String
- Python Datetime – Get Month as Number
- Python Datetime – Get Month Name Full Version
- Python Datetime – Get Month Name Short Version
- Python Datetime – Get Day of Month
- Python Datetime – Get Weekday as Number
- Python Datetime – Get Weekday Full Version
- Python Datetime – Get Weekday Short Version
Python sqlite3 Examples
Python sqlite3 library provides a lightweight database that does not require a separate process running to access database. You may use sqlite3 database for prototype developments. And you can easily port this application to larger databases, as sqlite3 uses SQL.
Get started with Python sqlite3 Tutorial. More detailed topics are given below.
- Python sqlite3 – Create Connection Object
- Python sqlite3 – Create Table
- Python sqlite3 – Check if Table Exists
- Python sqlite3 – INSERT INTO table
- Python sqlite3 – SELECT FROM TABLE
- Python sqlite3 – INSERT Multiple Rows to TABLE
- Python sqlite3 – DELETE all rows FROM TABLE
Python Pickle
Python Debugging Examples
Python GUI Examples
Python Tkinter library is used to develop GUI based Python applications.
- Python Tkinter – Set Specific or Fixed Window Size
- Python Tkinter – Window Background Color
- Python Tkinter Button Example
- Python Tkinter – Login Form Example
Python General Examples
- Python – Add Two Numbers
- Python – Average of Two Numbers
- Python – Check if Number is Armstrong
- Python – Find if given year is Leap Year in Georgian Calendar
- Python – Generate a Random Number
- Python – Largest of Three Numbers
- Python – Matrix Transpose
- Python – Matrix Addition
- Python – Palindrome Program
- Python – Smallest of Three Numbers
- Python – Star Pattern Programs
- Python – Sum of Two Numbers
- Python – Sum of First N Natural Numbers
- Python – Swap Two Numbers
Python Programs with Other Applications
- Python – Open URL in Chrome Browser from Python Application
- Python – Open URL in Firefox Browser from Python Application
Python Mathematical Libraries
Numpy
Numpy Tutorial – Complete List of Numpy Examples.
Python Numpy Library is very useful when working with 2D arrays or multidimensional arrays. For example, if you are working with images, you have to store the pixel values in a two or three dimensional arrays.
Python supports only single dimensional arrays. It does not support multidimensional arrays. Numpy is an extension to Python Arrays, that not only supports multidimensional arrays, but also many mathematical operations on them.
Python Pandas Examples
Python pandas is used for data analysis.
- Python Pandas Examples
- Pandas Series Example
- Pandas – Create or Initialize DataFrame
- Pandas DataFrame – Change Column Labels
- Pandas – Construct DataFrame from Dictionary
- Pandas DataFrame – Load Data from CSV File
- Pandas DataFrame – Sort by Column
- Pandas DataFrame – Iterate Rows – iterrows()
- Pandas DataFrame – Add Row
- Pandas DataFrame – Add Column
- Pandas DataFrame – Delete Column
- Pandas Append or Concatenate DataFrames
- Pandas DataFrame – Reset Index
Python Matplotlib Examples
PySpark Examples
Python Image Processing
Pillow
Pillow Tutorial – Python Pillow Library is used to perform Image Processing. It has functions to perform operations on images like: reading pixels of image; modifying pixels at specific locations; resizing; rotating; flipping; adjusting brightness, contrast and sharpness; etc.
Python OpenCV Examples
Python OpenCV library can be used to manipulate images and computer vision problems like object detection, object tracking, etc.
- Python Read Image to Array – OpenCV cv2.imread()
- Python OpenCV cv2.imwrite() – Save Image
- Python OpenCV Resize Image
- Python OpenCV cv2 Find Contours in Image
- Python OpenCV – Add Two Images
- Python Convert Image to Black and White (Binary)
- Python Extract Red Channel from Color Image
- Python Extract Green Channel from Color Image
- Python Extract Blue Channel from Color Image
- Python Remove Green Channel from Color Image
- Python Remove Blue Channel from Color Image
- Python Remove Red Channel from Color Image
Python HTTP
Python Requests
Python Requests is a HTTP library for Python.
- Python Requests – GET
- Python Requests – POST
- Python Requests – PUT
- Python Requests – HEAD
- Python Requests – DELETE
- Python Requests – PATCH
- Python Requests – OPTIONS
- Python Requests – Send Parameters in URL
Python MongoDB – PyMongo
PyMongo helps Python applications to connect to MongoDB and perform operation on the database.
Python MongoDB – PyMongo Tutorial covers basic scenarios when you use MongoDB as your Database for your Python Applications.
Python PDF Examples
Python Natural Language Processing
NLTK
NLTK Tutorial – Python NLTK Library can be used to apply NLP techniques like Classification, Tokenization, Stemming, Lemmatization, Parsing, etc. It has also an interface to connect to different third party corpora.