Python
- Python is a general-purpose interpreted, interactive, object-oriented and high-level programming language.
- Guido van Rossum is a Dutch programmer. He is best known as the author of the Python programming language.
- Python language is Easy to learn, Platform independent, Free and open source, Cross-platform language.
- Python can be downloaded from the website: https://www.python.org for free.
- The version Python 3.8.1 was released on 18th December, 2019.
- 'Computational Thinking' is a problem solving approach using the concepts and ideas from computer science.
- The person concerned with 'Computational Thinking' may be known as the 'Computational Thinker'. The 'Computational Thinking' includes the following four stages: Decomposition, Abstraction, Pattern Recognition, Algorithm
- Python programming is used in the field of Artificial Intelligence, developing desktop GUI applications, websites, web applications, etc. Development and Learning Environment.
- The default extension of a Python program file is .py.
- Python allows the user to perform the tasks in two different modes viz. Interactive Mode and Script Mode.
- The three greater-than signs (>>>) which appears on the screen are referred to as the default Python command prompt.
- Python works in two different environments viz. Windows (Graphical User Interface) and the DOS environment (Command Line Interface).
- A letter, a digit or any special symbol is referred to as a character.
In Python, the different character sets are viz. Letters, Digits, Arithmetical Operators, Logical operators, Relational Operators and Special Symbols.
- There are some non-graphic characters, which are used as commands to direct the cursor while printing on the screen. These are said to be the Escape Sequences or Backslash Characters.
- Each individual component of a programming statement is known as a Token, which is a functional and fundamental unit of a computer program.
- The various types of tokens available in Python are:- Literals – Identifiers, Assignments, Punctuators, Separators, Operators, Keywords
- The quantities, which remain fixed throughout the execution of the program, are termed as Literals or Constants.
- The different types of literals are:- Integer Literals, Real Literals, String Literals, Boolean Literals, None Literal
- An identifier is the term used to represent program elements such as function name or class name. The variables used in Python codes are also referred to as Identifiers.
- Assigning means to store constants in variables using a token = symbol which acts as the assignment operator.
- The data type is a type of value stored in a variable, which is used throughout a program to give meaningful result.
- The different data types used in Python are numeric, non-numeric, sequences and dictionary. • A complex number is a combination of a real number and an imaginary number which is represented as a + bj
- Boolean constants are two special (True and False) which can be applied in Python codes t check whether a given logical condition is satisfied or not.
- Type conversion is defined as the method of converting mixed data types into a single type.
- In Python, the type conversion is further categorised into implicit conversion and explicit conversion.
- The explicit conversion is also referred to as type casting.
- In Python, a sequence is referred to as an ordered collection of similar or different data types. • The sequence is further categorised into strings, lists and tuples.
- Dictionary is a collection of data in terms of key-value pairs.Token can be defined as an individual component of the code that carries some meaning and takes part in the execution of the code.
- An operator is basically a symbol or token which performs arithmetical or logical operations to give a meaningful result. .The values which are involved in the operation are termed as operands.
- An arithmetical expression is a set of variables, constants and arithmetical operators used together to yield a meaningful result.
- An arithmetical expression is further categorised into two types viz. pure and impure expression.
- In Python, there are a number of operators to perform various tasks. They are:- Arithmetic Operators, Relational Operators, Logical Operators, Identity Operators, Membership Operators, Bitwise Operators, Assignment Operators, Augmented Assignment Operators, Ternary Operator.
- An arithmetic operator which works on a single operand is referred to as an Unary Operator
- An arithmetic operator which deals with two operands is termed as the Binary Operator
- The arithmetic operators such as + and 5% which are used to carry out some fundamental calculations are said to be binary operators.
- The assignment operator (-) is used to assign a value to a variable.
- When you combine an arithmetic operator with an assignment operator, it is termed as Augmented Assignment Operator.
- The relational operators compare the values of two operands and determine the relationship between them.
- In Python, there are three logical operators viz. and, or and not. These operators yield True or False depending upon the outcome of the associated conditions.
- Ternary operators are also known as conditional expressions. The test condition is written on a single line, replacing the multiline if-else code. It results in either True or False, based on a given condition.
- There are some special types of operators which perform operations on bits, referred to as the Bitwise Operators,
- There are mainly four types of bitwise operators viz. Bitwise AND, Bitwise OR, Bitwise NOT and the Bitwise XOR.
- The precedence of operators is an order which determines the grouping of terms in an expression and decides as to how an expression is evaluated.
Comments are non-executable statements.
The trigonometrical functions viz. sin(), cos( ), tan() accept the argument in radian.
The square root of a negative number will always result in a ValueError.
By default, the print() function takes the default value for end argument as (new line character). In Python, the print() function will always accept the value entered from the keyboard as a string
The sep argument is used to provide reasonable spaces in between the elements to be displayed.
By default, Python language displays the elements separated by a single blank.
random(). To use statistics functions, you need to first import the Python statistics module.
The random function is available in the random module where it generates numbers randomly using
Python provides some useful functions in statistics module viz. mean(), median() and mode().
Python includes various trigonometric functions that perform trigonometric calculations under math module such as sin(), cos(), tari() method. These functions return their trigonometric rations of an angle x (given in radians).
You need to specify import math to perform various tasks under math module (except built-in functions). Python mathematical functions are applied to perform different types of mathematical calculations such as min(), max( ), ceil(), floor(), sqrt(), round(), etc.
The print() function is used to display output of the Python codes on output screen or other output device.
There are two ways to give a comment in Python viz. Single line comment and Multiline comments. A single line comment is given by using hash (#) and a multiline comment by using triple-apostrophe
Comments are used for explaining the programming codes.