Introduction of Python - 080915
Introduction of Python - 080915
Python is one of the most popular programming languages used by people world over.It is a high-level computer
programming language .This programming language enables you to create interesting programs that can be used to do
things faster and better.This is similar to English language.
Guido Van Rossum developed python in 1991 at the national Research Institute for mathematics and
computer science in Netherlands.
Python 3.0 was released on 3rd December 2008.
FEATURES OF PYTHON
1.EASY TO LEARN: It is easy to learn programming language,since it has fewer keywords and uses simple
English words.
2.Plateform Independent:The programs written in python can run on different hardware and software
plateforms.Program written in LINUX operating System can be executed in on a machine with different
operating System.
3.FREE AND OPEN SOURCE: Which means it can download without paying.
4.HIGH LEVEL LANGUAGE:An English like language.
5.INTERPRETED LANGUAGE:Programs written in python are executed by an interpreter(lne by line).
6.EXTENSIVE LIBRARY SUPPORT:Python has an extensive inbuilt library which is openlyavailable for every
user.It helps saving your time and efforts.
USES:It can be used to built website,program a robot,develop Artifificial intelligence Application,create virtual
games,perform scientific computation etc.s
Modes in python
IDLE stands for integrated Development Environment. Python interpreter offers the two basic modes to enter
command. Interactive mode & script mode.
1.Interactive mode: In this mode, commands are executed line by line. In this mode codes are typed directly
in the shell window and ouput is also displayed in this window.
2.Script mode: It is used for long program that contain multiple python statements.In this mode , you can
store statements in file in order to use them later.
Keywords:It refers to the reserved words that have specific/predefined meaning to the python interpreter.
Variables:It is a place to store values in computer memories . A variable can hold a single value.
Rules to declare a variable Name
* A variable name must be begin with a letter(uppercase or lowercase) or an underscore.
* Apart from underscore,a variable name can not contain any other symbols,such as comma(,),equal
to(=).hyphen(-),question mark(?), and so on.
*A variable can not have any space.
* A variable name can be arbitrarily long.
* Keyword can not be used as variable names.
* Python is a case-sensetive programming language.
Data Types: integer,string,float,list,Boolean,tuple,dictionary and none. We will study only about integer and
string.
Number:This data type store numeric values.
int: int or integer stores positive or negative numeric values.Integer represents integral numbers,which are
the numbers without decimal point.e.g. x=89,y=-25
float: float or floating point number could be a positive or a negative numeric values with a decimal point
e.g x=6.6,y=8.6
String:String data type refers to set of characters,which are enclosed within single code(‘ ‘) or a double
quotes(“ “)
INPUT () FUNCTION: In a python program, the input () function is used to take a value(input) from the user
And assign it to a variable.
To accept numeric values:
To input integer and float values, you can use int() and float() along with input() function,respectively.
age=int(input(“enter age”))------------------used to take integer value from the user
percentage=float(input(“enter percentage”))---------------used to take float value from the user
To accept text values:
a=input(“enter your hobby”)
PRINT () FUNCTION
EXAM.print(“PYTHON IS AN INTRESTING PROGRAMMING LANGUAGE”)
Print(A,B,C)
Print(A,”\t”,B,”\t”,c)------t used for tab space
Using new line character(\n):print(A,”\n”,B,”\n”,C)
OPERATORS: Are special symbols that are used to perform arithmetic and logical operations on variables and
values, and provide a meaningful result.
Types Of Operators:
Arithmetic Operators: Are used to perform basic mathematical calculations.
Exam: + addition
- Subtraction
* Multiplication
/ division exam 5/2 result 2.5
// division exam 5//2 result 2
% modulas exam 5%2 result 1
** exponential exam 5**2 result 25
Binary operators
Exam 5+2
Unary operators exam +2
String Operators: Only two types of operators used in string such as ‘+’ (addition) and ‘*’(multiplication).
‘+’ operator is used for concatenation(combining) two string
‘*’ is used to reprint or replicate the string values a number of times.so, it is known as replication operator.
Relational Operators: ==(equal to),!=(Not equal to),>(greater than),<(less than),>=(greater than equal to)
<=(less than or equal to)
PROGRAMS
1.Addition of 2 numbers By initialisation
x = 5
y = 10
print(x + y)