Introduction to Python
Python is a High level programming language.
It was developed by Guido Van Rossum in 1991.
Python has IDLE (Integrated Development and Learning Environment)
which provides a convenient way to write, test and execute Python Code.
Downloading Python:
Visit Site – [Link]/downloads
Working in Python
There are two modes in python that you can use for programming.
1. Interactive Mode –
It is the default mode that appears when you start Python.
Here you will see Command Prompt (>>>).
It gives you the output immediate for each line of code.
2. Script Mode –
It is used for writing lengthy programs.
It is used to write multiple lines of codes.
Here we can create, edit and save python programs.
Open Script Mode-
File->New File, or Ctrl+N
Execution of Program
Save the File -> Click on Run -> Run Module.
Or
Press F5 Key to Run
a,b and c are variables input is a function which is used to take input from user
Here int is a Datatype
,(Comma) is used to
Message separate message and
print is a function which is used display message or value. value
Printing values stored in
these variables
Variable- Named storage locations in the computer memory which are used to
store data, are called variables.
For eg . a= 10 Data / value
Variable
Rules to write the variable names:-
A variable name must start with an alphabet(capital or small) or an
underscore( _ ).
A variable name can consist of letters, digits, and underscore. No other
character is allowed.
A keyword cannot be used as a variable name.
(for eg. Keyword – print, int, input)
A variable name can be of any length.
Variable names are case-sensitive
(for eg. A and a are different variable names)
Valid Variable Name Invalid Variable Name
1. Empcode 1. 10abc
2. Age189 2. A bc
3. Ab123 3. Ab&h
Data Types – A data type represents the type of data stored in a variable.
Following are the different datatypes:
Data Types Keyword Description For eg.
Values are
1. Integer int It contains positive or negative 15, -85 ,26,
whole numbers (without fraction or 45,-787
decimal)
2. Float float It contains decimal numbers. 15.2, 455.23
3. String str It contains one or more characters ‘Hello’,
put in a single quote, double quote or ‘256’
triple quote. ‘My Name
It can represent alphanumeric data #67’
and symbols. It can also contain
space or null value.
Using input( ) function
input( ) function is used to take values for a variable from the user.
Using print( ) function
print( ) function is used to print a message or value.
Using Separators with print ( )
( , ) – It is used to separate values.
( \t ) – It is used to give tab space between values.
(\n ) – It is used to end a line and start from a new line.