REVISION OF THE BASICS OF PYTHON
> Python was created by Guido van Rossum in late 1980s (Released in 1991) at National Research Institute in the Netherland
> It is a case sensitive language.
> Python has a script mode and Internet mode both.
> Indentation: Blocks of code are denoted by line indentation, which is rigidly enforced.
> Comments: A hash sign (#) that is not inside a string literal begins a single line comment.
> Tokens: smallest individual unit in a program is known as a token or a lexical unit.
> Keywords: words that convey a special meaning to the Python compiler are known as keywords.
> Identifiers: These are the names given to different parts of the program.
> Literals: these are the data items that have a fixed value. Operators: These are tokens that trigger some computation.
> Dynamic Typing: In Python, the value that a variable points to has a type. In Python a variable is not assigned any data type it gets the data type of the value it points to at the time of the execution of the program. A variable in Python can be made to point to a value of different data type during the execution of the program.
>Static Typing: In static typing a data type is attached with a variable when it is defined first and it is fixed.
>Multiple Assignment: Python allows you to assign a single value or multiple values to multiple variables in a single statement. to several variables simultaneously
For example: a=b=c=1
a, b, c=1,2, "john"
> Data type : Python offers following built in core data types. These are Numbers, Strings, list, tuple, dictionaries
> Numbers can be either integers, floating point or complex numbers.
> Sequence is an ordered collection of items, indexed by integers starting from 0. Sequenced can be grouped into strings, tuples and lists. >Strings are lines of text that can contain any character. They can be declared with double quotes.
>Lists are used to group other data. They are similar to strays.
>A tuple consists of a number of values separated by commas.
> A set is an unordered collection with no duplicate items.
> Immutable types are those that can never change their value. Integers, floating point numbers, booleans, strings and tuple are Immutable.
>Mutable types are those that allow changes in their contents. lists and dictionaries are mutable.
> A dictionary is an unordered set of key value pairs where the keys are unique.
The order of execution of statements is known as flow of control. A selection construct is a statement blodk statements that is executed when a condition is satisfied. These are also called conditional statements
> The conditional statements in Python have the following forms.
(a) Simple of
(b) The if-else conditional
(c) The if-elif conditional statements
(d) Nested if
> Python provides three types of iterative statements.
(a) Counting loops repeat a certain number of times eg :- for
(b) Conditional loops repeat until a certain condition is satisfied, eg :- while.
(c) Nested loops. An error or a bug is anything in the code that prevents a program from compiling and dunning correctly.
> There are three types of errors :-
(a) Compile Time errors occur at compile time.
These are of two types:
(i) Syntax errors occur when rules of programming language are misused.
(ii) Semantics errors occur when statements are not meaningful.
(b) Run Time errors occur during the execution of a program.
(c) Logical Errors occur due to programmer's mistaken analysis of the error
To remove logical errors is called debugging .
> A list is a standard data type of Python that can store a heterogeneous sequence of values.
(a) These are mutable (ie, modifiable), you can change elements of a list in place.
(b) The lists are depicted through square brackets.
(c) To join two lists use + (concatenation) operator.
(d) List manipulation functions are:-
append(), insert(), extend().sort(), remove(), reverse() and pop().
> Tuples
(a) Tuples are immutable Python sequences, Le. you cannot change elements of a tuple in place.
(b) Tuples store a reference at each index
(c) Tuple manipulation functions are:
Jen(), max(), min(), and tuple().
> Dictionaries
(a) Dictionaries in Python are a collection of some key-value pairs.
(b) These are mutable and unordered collection with elements in the form of a key: value pairs that associate kry
(c) To manipulate dictionaries functions are: len), clear(), has_key.items(), keys(), values(), update()
(d) The membership operators in and not in work with dictionary keys only.
> Strings in Python are stored as individual character in contiguous location, with two way index for each location Strings are immutable and hence item assignment is not supported.
> Following operations can be used on strings
(1) Concatenation '+'
(2) Replications '*'
(3) Membership in and not in
(4) Comparison Operators String Function
==,!=,<,>,<=,>=
> String Functions :-
(i) partition()
(ii) join()
(iii) split()
> Any Python file can be referenced as a module.
> Modules are accessed by using the import statement import statement can
import x, y, z from x import a, b, c.
> Mathematical functions: these can be accessed by importing math module.
(i) sqrt(): find the square root of a specified expression
(ii) pow():compute the power of a number
(iii) fabs(): Returns the absolute value of vas a float.
>The math module of Python provides math functionality.
> The command line sys.argy arguments is another way that we can grab input.
> The basic VO (Input/Output) functions are input) and print)) respectively
> ceil(x): Returns the ceiling of x as a float, the smallest integer value greater than or equal to x.
> floor(x): Returns floor of x as a float, the largest integer value less than or equal tox
> fabs(x): Returns the floating point absolute value of x
> Random Functions: these can be accessed using tandem module
(i) random()
(ii) choice()
> Statistics Module: these can be accessed using statistics module
(i) mean()
(ii) median()
(iii) mode()
Tags
python, python programming, learn python, python tutorial, python coding, learning python, w3schools python, how to learn python, python documentation, python language, python syntax, python basics, tutorialspoint, learn python for free, learn python free, free python course, python learning, python tutorial for beginners, python programming for beginners, learn python online, w3 python, python tutorials, geeks for geeks python, coding basics python, learn python 3, basics of python programming, python coding beginners