Professional Documents
Culture Documents
GOVT. POLYTECHNIC
HAMIRPUR
INDUSTRY TRAINING REPORT
ON
PYTHON PROGRAMMING.
FROM
COMPUTER ENGG.
ANISH
MALHOTRA
(2207302040
02)
Pag e|
2
Acknowledgement
It is my pleasure to be indebted to various people, who
DAILY DIARY
Pag e|
TRAINING
5
OBJECTIVE
To get exposed to the training
organization.
industry.
Contents.
1. WHAT IS PYTHON ?
4. CONTROL FLOW
STATEMENTS ?
5. LOOPS IN PYTHON ?
6. FUNCTIONS IN PYTHON ?
7. FINAL PROJECT.
Pag e|
8
INTRODUCTION OF PYTHON
1 Variable can hold value and every value has a data type -
a. We do not need the define the type of the variable
while declaring.
b. Example:- a=5
2. The variable a hold the integer value 5.
3. User can not define any Data Type.
4. Python interpreter will automatically variable a given integer
Data Type.
a. Python provide the type () function to check the data
type any variable.
2. Declaring variables
3. Multiple Assignment
4. Deleting variables
Declaring variables
1. Python does not bind us to declare a variable
6. Example :- A=10
and 10 is a value of A.
Pag e|
13
Multiple Assignment :-
variables in a singlestatement.
variables.
Example:-
a,b,c=10,20,30
Pag e|
14
print(
a)
print(
b)
print(
c)
values.
Pag e|
15
Deleting variables :-
keyword syntax:-
del<variable_name
> Example :-
x=5
print(x)
del x
print(x)
Python variables:-
Example of python
Pag e|
16
variable:- First Declare
next variable
values A=10
B=10
Pag e|
17
C=A+B
Print(c)
Local variable :-
def
sample():
y=“local”
print(y)
Pag e|
18
sample
()
Global variable :-
def sample():
print(“x inside :-
” ,x sample()
print(“x outside:-”,x)
Example:- a=5
3.The variable a hold the integer value five.
4.User can not define any Data Type.
5.Python interpreter will automatically
c=10.5
Print(type(a))
Pag e|
21
Print(type
(b))
Print(type
(c))
Python Operators
The operator can be defined as a symbol which
operands.
1.Arithmetic operators
2.Comparison operators
3.Assignment Operators
4.Logical Operators
5.Bitwise Operators
6.Membership Operators
7.Identity Operator
Transfer statements
Pag e|
27
Conditional statements :-
The conditional statements are depending on
statements:-
1.if statements
2.If-else
3.If-elif-else
4.Nested if-else
if statements :-
In control statement the if statement is the
Syntax of if
statement:- If
condition:
statement 1
statemen
t2
statemen
tn
Pag e|
29
If-else statement :-
print(“number is positive”)
else:
print(“number is negative”)
If-elif-else :-
If-elif-else condition statement has an elif
conditions one by on
eand if the condition fulfills
num=3
If num >0:
print(“positive”)
Pag e|
32
elif num==0:
print(“zero”)
else:
print(“negative number”)
Pag e|
33
another if statement.
if else: If condition
Pag e|
34
outside:
if condition inside:
statement of
inside if
else:
statement of inside else:
statement of
outside if else:
outside else
Statement outside if block
Pag e|
35
a=int(input(“Enter 1st
value:-”)
b=int(input(“Enter 2st
value:-”) If a>=b:
if a == b:
print(a ‘and’, b, ‘are equal’)
else:
Transfer statements :-
Pag e|
38
below.
Break statement :-
We can use the break statements
for i in number:
if i>40:
break
print(“current number”,i)
Continue statement :-
The continue statement skips the current
iteration.
numbers=[2,3,1
1,7] for I in
numbers:
square=i * I
print(“square of a current number is “, square)
PASS STATEMENT :-
The pass statement is null statement.
operation.
Syntax of pass
statements: for
elements in sequence:
if condition:
pass
Pag e|
43
for i in num:
pass
Pag e|
44
months=[“January”,”june”,”march”,”april”]
for Monday in
months: pass
print(months)
Functions
Every function starts with a “def” keyword.
Every function should have a unique name.
Every function name are not a same any
keyword.
User decide the parameters are given or not.
User decide the arguments are
Types of functions :-
1. Built in function
2. User-defined Function
3. Function calling:-
So, function calling is a simple process.
So, call the function as a function name
function is “ABC”.
Built in function:-
The functions which are come along with
or predefined function.
User-defined function:-
Functions which are created by
def sample():
x=10
print(
x)
sample()
Pag e|
51
Tkinter
• master = Tk()
• Label(master, text='First
Name').grid(row=0)
• Label(master, text='Last
Name').grid(row=1)
• e1 = Entry(master)
• e2 = Entry(master)
• e1.grid(row=0, column=1)
Pag e|
53
• e2.grid(row=1, column=1)
• mainloop()
Pag e|
54
THANK
YOU