21BEC044, Report PDF
21BEC044, Report PDF
learning
An Internship Report
Submitted to
Mr. Narottam singh
Faculty of Engineering
STUDENT’S DECLARATION
I hereby certify that the work which is being presented in the report, entitled “Python with
data science and machine learning” for the award of the degree of “Bachelors of
Technology” submitted in the School of Electronics & Communication, Faculty of
Engineering & Technology, Shri Mata Vaishno Devi University, katra is an authentic record
of my own work conducted at ‘NIELIT’, Jammu.
ii
SHRI MATA VAISHNO DEVI UNIVERSITY
SCHOOL OF ELECTRONICS & COMMUNICATION
ENGINEERING
COPY OF CERTIFICATE
iii
ACKNOWLEDGEMENTS
It is my proud privilege and duty to acknowledge the kind of help and guidance received from
several people in preparation of this report. It would not have been possible to prepare this
report in this form without their valuable help, cooperation and guidance.
First and foremost, I wish to record our sincere gratitude to NILET Coordinators for their
constant support and encouragement in preparation of this report and for conducting
questionnaire. Their contributions and technical support in preparing this report are greatly
acknowledged.
Last but not the least, we wish to thank our parents for financing our studies in this college as
well as for constantly encouraging us to learn engineering. Their personal sacrifice in
providing this opportunity to learn engineering is gratefully acknowledged.
iv
ABSTRACT
This report discusses the training program at NIELIT. It states the concept of python with data
science and machine learning.
It shows a brief background about the palce of training. It mentions some facts about the
department that was responsible for the learning program. The report describes about the
history, characteristic, features, concepts of python programming with project using these
concepts and SQLite database and PyQt toolkit.
v
TABLE OF CONTENTS
STUDENT’S DECLARATION ii
COPY OF CERTIFICATE iii
ACKNOWLEDGEMENTS iv
ABSTRACT v
TABLE OF CONTENTS vi
INTRODUCTION TO PYTHON 1
HISTORY OF PYTHON 1
PYTHON FEATURES 2
TRAINING CONTENTS 3
VARIABLES, EXPRESSIONS AND STATEMENTS 3
OPERATORS AND OPERANDS 4
EXPRESSIONS 4
COMMENTS 5
BOOLEAN EXPRESSIONS 5
CONDITIONAL EXECUTION 6
ALTERNATIVE EXECUTION 7
CHAINED CONDITIONALS 7
PYTHON LOOP 8
FUNCTIONS 9
PROFILE OF THE PROBLEM 9
DATABASE DESIGN 10
PROBLEM ANALYSIS 11
CODE 12
BIBLIOGRAPHY 25
vi
INTRODUCTION TO PYTHON
History of Python
vii
Python was developed by Guido van Rossum in the late eighties and early nineties at the
National Research Institute for Mathematics and Computer Science in the Netherlands.
Python is derived from many other languages, including ABC, Modula-3, C, C++, Algol-68,
Small Talk, and Unix shell and other scripting languages. Python is copyrighted. Like Perl,
Python source code is now available under the GNU General Public License (GPL). Python
is now maintained by a core development team at the institute, although Guido van Rossum
still holds a vital role in directing its progress.
viii
PYTHON FEATURES
Python's features include –
• Easy-to-learn − Python has few keywords, simple structure, and a clearly defined
syntax. This allows the student to pick up the language quickly.
• Easy-to-read − Python code is more clearly defined and visible to the eyes.
• Easy-to-maintain − Python's source code is fairly easy-to-maintain.
• A broad standard library − Python's bulk of the library is very portable and cross
platform compatible on UNIX, Windows, and Macintosh.
• Interactive Mode − Python has support for an interactive mode which allows
interactive testing and debugging of snippets of code.
• Portable − Python can run on a wide variety of hardware platforms and has the same
interface on all platforms.
• Extendable − You can add low-level modules to the Python interpreter. These modules
enable programmers to add to or customize their tools to be more efficient.
• Databases − Python provides interfaces to all major commercial databases.
• GUI Programming − Python supports GUI applications that can be created and ported
to many system calls, libraries and windows systems, such as Windows MFC,
Macintosh, and the X Window system of Unix.
• Scalable − Python provides a better structure and support for large programs than shell
scripting.
• Apart from the above-mentioned features, Python has a big list of good features, few
are listed below −
• It supports functional and structured programming methods as well as OOP.
• It can be used as a scripting language or can be compiled to byte-code for building large
applications.
• It provides very high-level dynamic data types and supports dynamic type checking.
• IT supports automatic garbage collection.
• It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.
TRAINING CONTENTS
1. Introduction to Python
Learn how to install Python, distinguish between important data types and use basic
features of the Python interpreter, IDLE.
2. Using Variables in Python
Learn about numeric, string, sequence and dictionary data types and relevant operations
while practicing Python syntax. 3. Basics of Programming in Python
Learn how to write programs using conditionals, loops, iterators and generators,
functions and modules and packages.
4. Principles of Object-oriented Programming (OOP)
Learn about the important features of Object-oriented Programming while using Classes
and Objects, two main aspects of the OOP paradigm.
5. Connecting to SQLite Database
Learn about relational databases while learning how to store and retrieve data from an
SQLite database through Python.
6. Developing a GUI with PyQT
Learn how to install PyQt5 toolkit, Qt Designer and create a graphical user interface
using common widgets and menu systems.
7. Application of Python in Various Disciplines
Learn about various resources to extend your learning for the Python programming
language.
VARIABLES, EXPRESSIONS AND STATEMENTS
Ⅰ. Variables:
One of the most powerful features of a programming language is the ability to manipulate
variables. A variable is a name that refers to a value
>>> pi = 3.1415926535897931
Ⅱ. Statements:
In general, statements are executed sequentially: The first statement in a function is executed
first, followed by the second, and so on. There may be a situation when you need to execute a
block of code several number of times.
• Programming languages provide various control structures that allow for more
complicated execution paths.
Operators are special symbols that represent computations like addition and multiplication.
The values the operator is applied to are called operands.
hour*60+minute minute/60
5**2
(5+9)*(15-7)
EXPRESSIONS
An expression is a combination of values, variables, and operators. A value all by itself is
considered an expression
17
x +17
COMMENTS
As programs get bigger and more complicated, they get more difficult to read. Formal
languages are dense, and it is often difficult to look at a piece of code and figure out what it is
doing, or why.
For this reason, it is a good idea to add notes to your programs to explain in natural language
what the program is doing. These notes are called comments, and in Python they start with
the # symbol
#This is a comment
print("Hello,World!")
BOOLEAN EXPRESSIONS
A Boolean Expression is an expression that is either true or false. The following examples use
the operator = =, which compares two operands and produces True if they are equal and False
otherwise
>>> 5
==5
True
>>> 5
==6
False
x != y
x>y
x<y
x >= y
x <= y
x is y
x is not y
# x is not equal to y
# x is greater than y
# x is less than y
# x is the same as y
CONDITIONAL EXECUTION
In order to write useful programs, we almost always need the ability to check conditions and
change the behavior of the program accordingly. Conditional statements give us this ability.
The simplest form is the if statement:
if x>0:
print('x is positive')
ALTERNATIVE EXECUTION
A second form of the if statement is alternative execution, in which there are two possibilities
and the condition determines which one gets executed. The syntax looks like this:
if x%2 == 0 :
print('x is even')
else : print('x is
odd’)
CHAINED CONDITIONALS
Sometimes there are more than two possibilities and we need more than two branches. One
way to express a computation like that is a chained conditional:
if x < y:
y')
elif x > y:
else:
1. While loop
2. For loop
Executes a sequence of statements multiple times and abbreviates the code that
3. Nested loops
You can use one or more loop inside any another while, for or do. while loop.
FUNCTIONS
A function is a block of code which only runs when it is called. You can pass data, known as
parameters, into a function. A function can return data as a result.
Creating a Function:
def my_function():
Calling a Function:
def my_function():
print(“function”)
my_function()
Codes:
if num > 0:
print("Positive number")
elif num == 0:
print("Zero")
else:
print("Negative number")
a = False
if num > 1:
if (num % i) == 0:
a= True
break
if a:
else:
print(num, "is a prime number")
temp = num
reverse = 0
remainder = temp % 10
temp = temp // 10
if num == reverse:
print('Palindrome')
else:
print("Not Palindrome")
sum = 0
temp = num
digit = temp % 10
sum += digit ** 3
temp //= 10
if num == sum:
else:
print(num,"is not an Armstrong number")
if(sorted(s1)== sorted(s2)):
else:
check(s1, s2)
if a >= b:
return a
else:
return b
print(maximum(a, b))
if a <= b:
return a
else:
return b
print(minimum(a, b))
largest = a
largest = b
else:
largest = c
return largest
print(maximum(a, b, c))
smallest = 0
smallest = a
if b < a and b < c :
smallest = b
smallest = c
factorial = 1
if num < 0:
elif num == 0:
else:
factorial = factorial*i
n1, n2 = 0, 1
count = 0
if nterms <= 0:
elif nterms == 1:
else:
print("Fibonacci sequence:")
print(n1)
nth = n1 + n2
n1 = n2
n2 = nth
count += 1
if (a == 0):
return b
if (b == 0):
return a
if (a == b):
return a
if (a > b):
return gcd(a-b, b)
a = 98
b = 56
if(gcd(a, b)):
print('not found')
def myfunc(n):
for i in range(0, n):
for j in range(0, i+1):
print("* ",end="")
print("\r")
n=5
myfunc(n)
def myfunc(n):
k=n-1
for i in range(0, n):
for j in range(0, k):
print(end=" ")
k=k-1
for j in range(0, i+1):
print("* ", end="")
print("\r")
n=5
myfunc(n)
17. Write a program to print the following pattern.
def num(n):
num = 1
for i in range(0, n):
num = 1
for j in range(0, i+1):
print(num, end=" ")
num = num + 1
print("\r")
n=5
num(n)
def num(n):
num = 1
for i in range(0, n):
for j in range(0, i+1):
print(num, end=" ")
num = num + 1
print("\r")
n=5
num(n)
def alphapat(n):
num = 65
for i in range(0, n):
for j in range(0, i+1):
ch = chr(num)
print(ch, end=" ")
num = num + 1
print("\r")
n=5
alphapat(n)
def contalpha(n):
num = 65
for i in range(0, n):
for j in range(0, i+1):
ch = chr(num)
print(ch, end=" ")
num = num + 1
print()
n=5
contalpha(n)
https://wiki.python.org/moin/PyQt/Tutorials
https://www.quora.com
https://www.w3schools.com/python