Python Notes

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

PYTHON

1. Introduction-: Python is a programming language that combines the features of


C and Java. It offers elegant style of developing program like C. Python is
developed by Guido Van Rossum in 1991 at the center for mathematics and computer
Science managed by the Dutch Government. The python code is easy to understand and
develop.

2. Features of Python-: Simple, Easy to learn, Open Source, High level language,
Dynamically typed, Platform Independent, Portable and procedure and Object
oriented.

3. Operators-: An operator is a symbol that perform an operation is called


operator, An operator acts on some variables called operands.
Example:- a+b, + is an operator and a,b is an operands.

Types of operators-: There are seven types of operators.

1. Arithmatic Operator-: These operators are used to perform basic arithmatic


operations like additions(+), substraction(-), multiplication(*), division(/),
modulus(%), Exponent operators(**), Integer division or Floor division
operator(//).

2. Assignment Operators-: These operators are useful to store the right side value
to left side variable like assignment operator(=), addition assignment
operator(+=), substraction assignment operator(-=), multiplication assignment
operator(*=), division assignment operator(/=), modulus assignment operator(%=),
Exponent assignment operator(**=) and floor division assignment operator(//=)

3. Relational Operator-: Relational operator are used to compare two quantities. We


can understand whether two values are same or which one is bigger or which
one is lesser, etc using these operators. such as (>, >=, <, <=, ==, !=)

4. Logical Operator-: Logical operator are useful to construct compound conditions.


A compound condition a combination of more than one simple condition. Such as (And,
Or, Not).

5. Boolean Operator-: Boolean operator act upon 'bool' type literals and they
provide 'bool' type output. It means the result provided by boolean operator will
be again either true or false. (and, or, not)

6. Bitwise Operator-: We can use bitwise operator directly on binary numbers or


integer also. When we use these operators on integers, these numbers
converted into bits and then bitwise operators act upon those bits. The
results given by these operators are always in the form of integers.

7. Mathematical Function-: Mathematical function to make easy math fundamental in


python. Python provides built-in function of math.
Example-: To calculate square root value of a number, we need not develop any
logic. We can simply use thr sqrt() function that is already given in 'math' module

4. print()-: We can display the values of variables using the print() function. A
list of variables can be supplied to the print() function.

5. .format()-: After format string, we should write member operator and then
format() method where we should mention the values to be displayed.

6. Input Statement-: To accept input from keyboard, python provides the input()
function. This function takes a value from the keyboard and returns it as a string.

7. split() Method-: The split() method by default splits the values where a space
is found. Hence, while entering the numbers, the user should separate them using a
space. The square brackets [] around the total expression indicates that the input
is accepted as elements of a list.

8. eval() function-: The eval() function takes a string and evaluates the result of
the string by taking it as a python expression.
For Example-: Let's take a string 'a+b-4' where a as 5 and b as 10 if we pass the
string to the eval() function, it will evaluate the string and returns the result.

9. round keyword-: it will take decimal value. for example, you want to take only
two decimal value [round(value, 2)].

10. append-: adds a single element to the end of the list. for example,
list.append(element)

11. class -: It is a user defined data type. Those classes are defined by user, is
called user defined classes. If you want to re-use the program, simply you can
create a class and call it again and again.

12. append method -: append method is used for add the new value in existing array
in the end of indexing of array.

13. sep= -: Add space, special character, number, alphabate and anything between
sentence, digit, etc. like 09-10-2000, A B C and so on
for example -> print('python','is','programming','language' , sep='-')

14. end= -: Add space, special character, number, alphabate and anything at the end
of the word, character, sentence, etc
for example -:

15. set() -: The set can not store non-duplicate items.

16. min() -: The min() function returns the item with the lowest value, or the item
with the lowest value in an iterable. If the values are strings, an alphabetically
comparison is done.

17. max() -: The max() function returns the item with the highest value, or the
item with the highest value in an iterable. If the values are strings, an
alphabetically comparison is done.

18. list() -: List is a collection which is ordered and changeable. Allows


duplicate members.

19. map() -: map() function returns a list of the results after applying the given
function to each item of a given iterable (list, tuple etc.)

20. lambda() -: In Python, anonymous function is a function that is defined without


a name. While normal functions are defined using the def keyword, in Python
anonymous functions are defined using the lambda keyword. Hence, anonymous
functions are also called lambda functions.

You might also like