From 5c7575b342da292f184c73211c937652b816aef6 Mon Sep 17 00:00:00 2001 From: Ankit Mahato Date: Mon, 24 Oct 2022 18:20:36 +0530 Subject: [PATCH] Update README.md --- README.md | 391 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 391 insertions(+) diff --git a/README.md b/README.md index 68fccd3..590130d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,394 @@ +Table of Contents +================= + +* [Introduction](#introduction) + * [Introduction to Programming Languages](#introduction-to-programming-languages) + * [Introduction to Python](#introduction-to-python) + * [Advantages of Python](#advantages-of-python) + * [Installing Python in Windows](#installing-python-in-windows) + * [Installing Python in macOS (Apple)](#installing-python-in-macos-apple) + * [Execution Modes](#execution-modes) + * [Interactive Mode of Execution](#interactive-mode-of-execution) + * [Script Mode of Execution](#script-mode-of-execution) +* [Python Fundamentals](#python-fundamentals) + * [Tokens: Introduction](#tokens-introduction) + * [Tokens: Keywords](#tokens-keywords) + * [Tokens: Identifiers](#tokens-identifiers) + * [Tokens: Literals](#tokens-literals) + * [Numeric Literals](#numeric-literals) + * [Integer Literals](#integer-literals) + * [Floating Point Literals](#floating-point-literals) + * [Imaginary Literals](#imaginary-literals) + * [Boolean Literals](#boolean-literals) + * [String Literals](#string-literals) + * [Special Literal](#special-literal) + * [Collection of Literals](#collection-of-literals) + * [Tokens: Operators](#tokens-operators) + * [Tokens: Delimiters](#tokens-delimiters) + * [Grouping](#grouping) + * [Punctuation, Decoration and Annotation](#punctuation-decoration-and-annotation) + * [Assignment/Binding](#assignmentbinding) + * [Character Set](#character-set) + * [Blocks and Indentation](#blocks-and-indentation) + * [Comments](#comments) + * [Single Line Comments](#single-line-comments) + * [Multiline comments](#multiline-comments) +* [Variables, Objects & Data Types](#variables-objects--data-types) + * [What are Objects & Variables?](#what-are-objects--variables) + * [Variables & Assignment Statements](#variables--assignment-statements) + * [Assignment](#assignment) + * [Deletion](#deletion) + * [Multiple Assignment](#multiple-assignment) + * [Tuple Swapping](#tuple-swapping) + * [Built-in Data Types](#built-in-data-types) + * [Numeric Types](#numeric-types) + * [Integer Numbers](#integer-numbers) + * [Real or Floating-point Numbers](#real-or-floating-point-numbers) + * [Complex Numbers](#complex-numbers) + * [Boolean](#boolean) + * [Sequence Types](#sequence-types) + * [String](#string) + * [List](#list) + * [Tuple](#tuple) + * [Set Type](#set-type) + * [Mapping Type](#mapping-type) + * [Special Type](#special-type) + * [Type Checking](#type-checking) + * [Type Casting](#type-casting) + * [Implicit Type Casting](#implicit-type-casting) + * [Explicit Type Casting](#explicit-type-casting) + * [int()](#int) + * [float()](#float) + * [str()](#str) + * [tuple()](#tuple-1) + * [list()](#list-1) + * [set()](#set) + * [Mutable & Immutable Data Types](#mutable--immutable-data-types) + * [Immutable Data Types](#immutable-data-types) + * [Mutable Data Types](#mutable-data-types) +* [Input / Output](#input--output) + * [How to Accept User Input](#how-to-accept-user-input) + * [Displaying Output](#displaying-output) +* [Operators & Expressions](#operators--expressions) + * [Introduction to Operators](#introduction-to-operators) + * [Unary Operators](#unary-operators) + * [Binary Operators](#binary-operators) + * [Operators in Python](#operators-in-python) + * [Arithmetic Operators](#arithmetic-operators) + * [Addition](#addition) + * [Subtraction](#subtraction) + * [Multiplication](#multiplication) + * [Division](#division) + * [Floor Division](#floor-division) + * [Modulus](#modulus) + * [Exponent](#exponent) + * [Relational Operators](#relational-operators) + * [Equals to](#equals-to) + * [Not equal to](#not-equal-to) + * [Greater than](#greater-than) + * [Greater than or equal to](#greater-than-or-equal-to) + * [Less than](#less-than) + * [Less than or equal to](#less-than-or-equal-to) + * [Assignment Operators](#assignment-operators) + * [-=](#-) + * [*=](#-1) + * [/=](#-2) + * [//=](#-3) + * [**=](#-4) + * [%=](#-5) + * [Logical Operators](#logical-operators) + * [Logical State of Operands](#logical-state-of-operands) + * [not](#not) + * [or](#or) + * [and](#and) + * [Identity Operators](#identity-operators) + * [Membership Operators](#membership-operators) + * [Expressions](#expressions) + * [Chained Expression](#chained-expression) + * [Conditional Expression](#conditional-expression) + * [Operator Precedence with Examples](#operator-precedence-with-examples) + * [Exercises](#exercises) + * [Example 1](#example-1) + * [Example 2](#example-2) + * [Example 3](#example-3) + * [Example 4](#example-4) + * [Example 5](#example-5) + * [Example 6](#example-6) +* [Errors & Exception Handling](#errors--exception-handling) + * [Error Types](#error-types) + * [Syntax Error](#syntax-error) + * [Script Mode](#script-mode) + * [Interactive Mode](#interactive-mode) + * [Runtime Error](#runtime-error) + * [Examples](#examples) + * [ZeroDivisionError](#zerodivisionerror) + * [NameError](#nameerror) + * [KeyError](#keyerror) + * [TypeError](#typeerror) + * [Logical Error](#logical-error) + * [Example](#example) + * [Exceptions](#exceptions) + * [raise](#raise) + * [assert](#assert) + * [Exception Handling](#exception-handling) +* [Control Flow](#control-flow) + * [Introduction to Control Flow](#introduction-to-control-flow) + * [Sequential Flow](#sequential-flow) + * [Selection Statements: if .. else](#selection-statements-if--else) + * [Examples](#examples-1) + * [Absolute Value](#absolute-value) + * [Sorting 3 Numbers](#sorting-3-numbers) + * [Divisibility](#divisibility) + * [Iteration: for](#iteration-for) + * [List Iteration](#list-iteration) + * [Tuple Iteration](#tuple-iteration) + * [String Iteration](#string-iteration) + * [Range Iteration](#range-iteration) + * [Example #1](#example-1-1) + * [Example #2](#example-2-1) + * [Example #3](#example-3-1) + * [Example #4](#example-4-1) + * [Exercises](#exercises-1) + * [Compound Interest](#compound-interest) + * [Factorial](#factorial) + * [Iteration: while](#iteration-while) + * [Exercises](#exercises-2) + * [Compound Interest](#compound-interest-1) + * [Factorial](#factorial-1) + * [Jump Statements](#jump-statements) + * [pass](#pass) + * [Syntactical Requirement](#syntactical-requirement) + * [Skipping Code Execution](#skipping-code-execution) + * [Placeholders](#placeholders) + * [break](#break) + * [continue](#continue) + * [Nested Loops](#nested-loops) + * [Factorial](#factorial-2) + * [Nested Loop - break](#nested-loop---break) +* [Strings](#strings) + * [Strings: Introduction & Creation](#strings-introduction--creation) + * [Escape Characters](#escape-characters) + * [Unicode Support](#unicode-support) + * [Other Types to String](#other-types-to-string) + * [Accessing Characters of a String](#accessing-characters-of-a-string) + * [Length of String](#length-of-string) + * [String Operations](#string-operations) + * [Slicing](#slicing) + * [Membership](#membership) + * [Concatenation](#concatenation) + * [Repetition](#repetition) + * [Introduction to String Methods](#introduction-to-string-methods) + * [Convert Case of Strings](#convert-case-of-strings) + * [lower()](#lower) + * [upper()](#upper) + * [swapcase()](#swapcase) + * [capitalize()](#capitalize) + * [title()](#title) + * [Check Characters of a String](#check-characters-of-a-string) + * [isalpha()](#isalpha) + * [isdigit()](#isdigit) + * [isalnum()](#isalnum) + * [isascii()](#isascii) + * [islower()](#islower) + * [isupper()](#isupper) + * [isspace()](#isspace) + * [istitle()](#istitle) + * [Split a String](#split-a-string) + * [partition()](#partition) + * [split()](#split) + * [Strip Characters from a String](#strip-characters-from-a-string) + * [lstrip()](#lstrip) + * [rstrip()](#rstrip) + * [strip()](#strip) + * [Check Prefix or Suffix in a String](#check-prefix-or-suffix-in-a-string) + * [Find & Replace Characters in a String](#find--replace-characters-in-a-string) + * [count()](#count) + * [find()](#find) + * [rfind()](#rfind) + * [index()](#index) + * [rindex()](#rindex) + * [replace()](#replace) + * [Traversing a String](#traversing-a-string) + * [for](#for) + * [while](#while) +* [List](#list-2) + * [What is a Python List? How to Create a List?](#what-is-a-python-list-how-to-create-a-list) + * [Accessing Items of a List](#accessing-items-of-a-list) + * [Length of List](#length-of-list) + * [Negative Indexing](#negative-indexing) + * [Modifying a List](#modifying-a-list) + * [Removing Item from a List](#removing-item-from-a-list) + * [List Operations](#list-operations) + * [Membership](#membership-1) + * [Concatenation](#concatenation-1) + * [Repetition](#repetition-1) + * [Slicing](#slicing-1) + * [Traversing a List](#traversing-a-list) + * [Direct Traversal](#direct-traversal) + * [Location or Index Based Traversal](#location-or-index-based-traversal) + * [Built-in Functions that can be used for a List](#built-in-functions-that-can-be-used-for-a-list) + * [Introduction to List Methods](#introduction-to-list-methods) + * [Adding Items to a List](#adding-items-to-a-list) + * [Removing Items from a List](#removing-items-from-a-list) + * [Counting or Locating Items in a List](#counting-or-locating-items-in-a-list) + * [Reversing Items](#reversing-items) + * [Sorting a List](#sorting-a-list) + * [Copying a List](#copying-a-list) + * [Nested List](#nested-list) + * [List Comprehension](#list-comprehension) + * [Member-wise Operation](#member-wise-operation) + * [Filtering or Subsequence](#filtering-or-subsequence) + * [Sample Programs](#sample-programs) + * [Min, Max and Mean](#min-max-and-mean) + * [Without Using Built-in Functions](#without-using-built-in-functions) + * [Using Built-in Functions](#using-built-in-functions) + * [Linear Search](#linear-search) + * [Frequency of Elements](#frequency-of-elements) + * [Without Using Built-in Functions](#without-using-built-in-functions-1) + * [Using Built-in Functions](#using-built-in-functions-1) +* [Tuple](#tuple-2) + * [List vs Tuple](#list-vs-tuple) + * [How to Create Tuple?](#how-to-create-tuple) + * [tuple()](#tuple-3) + * [What is a Singleton?](#what-is-a-singleton) + * [Accessing Items of a Tuple](#accessing-items-of-a-tuple) + * [Length of Tuple](#length-of-tuple) + * [Negative Indexing](#negative-indexing-1) + * [Tuples are Immutable](#tuples-are-immutable) + * [Tuple Operations](#tuple-operations) + * [Membership](#membership-2) + * [Concatenation](#concatenation-2) + * [Repetition](#repetition-2) + * [Tuple Slicing](#tuple-slicing) + * [Traversing a Tuple](#traversing-a-tuple) + * [Direct Traversal](#direct-traversal-1) + * [Location or Index Based Traversal](#location-or-index-based-traversal-1) + * [Built-in Functions that can be used for a Tuple](#built-in-functions-that-can-be-used-for-a-tuple) + * [Locating Items in a Tuple](#locating-items-in-a-tuple) + * [Counting the Occurrence of an Item](#counting-the-occurrence-of-an-item) + * [New Tuple with Reversed Items](#new-tuple-with-reversed-items) + * [New Tuple with Sorted Items](#new-tuple-with-sorted-items) + * [Nested Tuple](#nested-tuple) + * [Understanding the Immutable Nature of Tuples](#understanding-the-immutable-nature-of-tuples) +* [Dictionary](#dictionary) + * [What is a Dictionary?](#what-is-a-dictionary) + * [How to Create a Dictionary](#how-to-create-a-dictionary) + * [Key: Value Pairs](#key-value-pairs) + * [Sequence of (key, value) Tuples](#sequence-of-key-value-tuples) + * [Keyword/Named Arguments](#keywordnamed-arguments) + * [Key and Value Lists](#key-and-value-lists) + * [Keys with Default Value](#keys-with-default-value) + * [Accessing Items (Key:Value) of a Dictionary](#accessing-items-keyvalue-of-a-dictionary) + * [Index Operator []](#index-operator-) + * [get()](#get) + * [Updating a Dictionary](#updating-a-dictionary) + * [Index Operator []](#index-operator--1) + * [update()](#update) + * [setdefault()](#setdefault) + * [Removing an Item (Key:Value) from a Dictionary](#removing-an-item-keyvalue-from-a-dictionary) + * [del](#del) + * [clear()](#clear) + * [pop()](#pop) + * [popitem()](#popitem) + * [Dictionary Operations](#dictionary-operations) + * [Membership](#membership-3) + * [Union](#union) + * [Traversing a Dictionary](#traversing-a-dictionary) + * [Direct Traversal](#direct-traversal-2) + * [Traversing Using Dictionary Methods](#traversing-using-dictionary-methods) + * [Built-in Functions for a Dictionary](#built-in-functions-for-a-dictionary) + * [Number of Items](#number-of-items) + * [Min and Max](#min-and-max) + * [Creating a Copy of a Dictionary](#creating-a-copy-of-a-dictionary) + * [Nested Dictionary](#nested-dictionary) + * [Sample Programs](#sample-programs-1) + * [Frequency of Characters](#frequency-of-characters) + * [Salary Book](#salary-book) +* [Python Standard Library](#python-standard-library) + * [Built-in Functions](#built-in-functions) + * [Mathematical Functions](#mathematical-functions) + * [abs()](#abs) + * [round()](#round) + * [sum()](#sum) + * [min()](#min) + * [max()](#max) + * [pow()](#pow) + * [divmod()](#divmod) + * [Type Functions](#type-functions) + * [Type Checking](#type-checking-1) + * [Built-in Type Functions](#built-in-type-functions) + * [I/O Functions](#io-functions) + * [input()](#input) + * [print()](#print) + * [open()](#open) + * [Base/Unicode Conversion Functions](#baseunicode-conversion-functions) + * [bin()](#bin) + * [oct()](#oct) + * [hex()](#hex) + * [ord()](#ord) + * [chr()](#chr) + * [What are Built-in Modules?](#what-are-built-in-modules) + * [math Module](#math-module) + * [Constants](#constants) + * [Functions](#functions) + * [fabs()](#fabs) + * [gcd()](#gcd) + * [ceil()](#ceil) + * [floor()](#floor) + * [fmod()](#fmod) + * [pow()](#pow-1) + * [sqrt()](#sqrt) + * [sin(), cos() & tan()](#sin-cos--tan) + * [factorial()](#factorial-3) + * [random Module](#random-module) + * [random()](#random) + * [Random Integer from Range](#random-integer-from-range) + * [statistics Module](#statistics-module) + * [Mean](#mean) + * [Median](#median) + * [Mode](#mode) +* [File Handling](#file-handling) + * [File Handling in Python - Introduction & Overview](#file-handling-in-python---introduction--overview) + * [Text Files vs Binary Files - Use Case, File Formats, Examples](#text-files-vs-binary-files---use-case-file-formats-examples) + * [File Opening & Closing](#file-opening--closing) + * [File Reading](#file-reading) + * [Sequential Reading](#sequential-reading) + * [read()](#read) + * [readline()](#readline) + * [readlines()](#readlines) + * [Ad-hoc Reading](#ad-hoc-reading) + * [tell()](#tell) + * [seek()](#seek) + * [Writing a File](#writing-a-file) + * [write()](#write) + * [writelines()](#writelines) + * [Reading & Writing Binary Files using pickle Module](#reading--writing-binary-files-using-pickle-module) + * [Dumping Data](#dumping-data) + * [Loading Data](#loading-data) + * [Example: Traversing a Binary File](#example-traversing-a-binary-file) + * [Reading & Writing a CSV File using csv Module](#reading--writing-a-csv-file-using-csv-module) + * [Reading CSV File](#reading-csv-file) + * [Example 1](#example-1-2) + * [Example 2](#example-2-2) + * [Writing CSV File](#writing-csv-file) + * [Example 3](#example-3-2) +* [User Defined Functions, Modules & Packages](#user-defined-functions-modules--packages) + * [User Defined Functions](#user-defined-functions) + * [Function Structure](#function-structure) + * [Function Header](#function-header) + * [Function Body](#function-body) + * [Parameters and Arguments](#parameters-and-arguments) + * [Scope of Variables](#scope-of-variables) + * [Local Variables](#local-variables) + * [Global Variables](#global-variables) + * [Passing Objects of Mutable Type to a Function](#passing-objects-of-mutable-type-to-a-function) + * [List](#list-3) + * [Dictionary](#dictionary-1) + * [What is a Module? How to Create a Module?](#what-is-a-module-how-to-create-a-module) + * [Executable Scripts / Modules](#executable-scripts--modules) + * [What is a Package? Introduction to PyPi. How to Create a Python Package?](#what-is-a-package-introduction-to-pypi-how-to-create-a-python-package) + + # Introduction ## Introduction to Programming Languages