Introduction to Python
Python is the clear and powerful OOP language that combine the feature of both C and Java language.Python is a versatile, readable, and beginner-friendly programming language. It uses indentation to define blocks of code and supports various data types, control structures, and functions. With an extensive standard library and third-party modules, Python is ideal for web development, data analysis, automation, and more.
Features:
1.Easy to learn
2.High level language
3.plat-form independent
4.Huge library and scalable
Application
1.Web application (django,flask)
2.Desktop application(tkinter)
3.Game and 3D applications
4.Data science
5.Machine learning(scikit-learn , tenserflow)
6.Data Analysis (matplotlib,seaborn..)
How Python Work
bytecode: Bytecode represent the fixed set of instruction created by python developers representing all types of operations like arithmetic,comparision operations,memory related operations e.t.c. The size of the byte code instruction is 1 byte or 8 bits. We can find the byte code instruction in .pyc file
python compiler: It convert the program source code into bytecode.
PVM (python virtual machine): PVM is a program which provides programming environment. The role of the PVM is to convert the byte code instruction into the machine code so the computer can execute those machine code instruction and display the output. It use the interpreter which understand the bytecode adn convert it into the machine code.
Working process of python
1.Write the source code or program
2.Compile the program using the python compiler
3.Compiler converts the source code into the bytecode.
4.computer or machine doesnot unserstad the bytecode so ww convert it into the machine code using the PVM
5.machoine code instructions are then executed by the processor and resu;ts are display.
Installation process of the python
Identifier
An identifier is a name having a few latters,numbers and special character. It is used to identify a variable,function,symbolic constant,class e.t.c. python is the case sensitive programmimg language.
Variable:
variable is an identifier whose value keeps on changing throughout program. In C,java and other programmimg language variable is an identifier or a name connected to memory location but in a python variable is consider as a tag , that is tied to some value, python consider a value as a object.
In the python memory location is allocated for the value not for the variable.
To find the memory location for any identifier you can use the id() function.
a=10
b=10
x,y,z=1,2,"Go"
print(id(a))
print(id(b))
#output
"""
139809644347920
139809644347920
"""
operators in python
Symbil that perform the opeartions.
1.Arithmetic operators. [+,-,*,/,//,**,%]
2.Comparision operators. [<,>,<=,>=,++,!=] it return True Or False
3.Logical operatots. [and , or , not]
4.Assignment Operators. [=,+=,-+,*=]
5.Bitwise Operators.
These operators is used to perform operations at binary digit levels.
example of operators are : &,!,^,<<,>>
6.Membership Operators.
it is used to test for membership in a sequence such string,list,tuple and dictionary. There are 2 type od memebership operators.
i.in -> it return True if element is found in the sequence
ii.not in -> it return False if element is found in the sequence. reverse of "in" operator
#membership operator
country="Nepal"
district=['kavre','laltipur','bhaktapur']
cricket_player={1:"Parash",2:"Gayandra",3:"Sandeep",4:"Rohit",5:"karan"}
print("N" in country)
print("N" not in country)
print("bhak" in district)
print("kavre" in district)
print(5 in cricket_player)
print("Sandeep" in cricket_player)
"""
True
False
False
True
True
False
"""
7.Identity Operators.
it compare the memory location of the two objects. hence it is possible to know whether two objects are same or not. it has two type
i.is -> compare two objects are same or not
ii. is not -> reverse of "is" operator
#identity operator
country="Nepal"
my_country="Nepal"
a=10
b=10
print( country is my_country)
print(a is not b)
"""
True
False
"""