0% found this document useful (0 votes)
37 views27 pages

21BEC044, Report PDF

Uploaded by

Nayan Slathia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views27 pages

21BEC044, Report PDF

Uploaded by

Nayan Slathia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 27

Python with Data science and Machine

learning

An Internship Report

Submitted to
Mr. Narottam singh
Faculty of Engineering

in fulfilment of the requirements for the award of the degree


of bachelors in Technology in
School of Electronics & Communication Engineering

Submitted by: KRITEEKA SHARMA (21BEC044)

SCHOOL OF ELECTRONICS & COMMUNICATION ENGINEERING


SHRI MATA VAISHNO DEVI UNIVERSITY KATRA-182320, JAMMU
AND KASHMIR (INDIA)
SHRI MATA VAISHNO DEVI UNIVERSITY
SCHOOL OF ELECTRONICS &
COMMUNICATION 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.

Student’s Name and Signature

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

Python Language Introduction


Python is a widely used general-purpose, high level programming language. It was initially
designed by Guido van Rossum in 1991 and developed by Python Software Foundation. It
was mainly developed for emphasis on code readability, and its syntax allows programmers to
express concepts in fewer lines of code. Python is a programming language that lets you work
quickly and integrate systems more efficiently.
Python is a high-level, interpreted, interactive and object-oriented scripting language. Python
is designed to be highly readable. It uses English keywords frequently where as other
languages use punctuation, and it has fewer syntactical constructions than other languages.

• Python is Interpreted − Python is processed at runtime by the interpreter. You do not


need to compile your program before executing it. This is similar to PERL and PHP.
• Python is Interactive − You can actually sit at a Python prompt and interact with the
interpreter directly to write your programs.
• Python is Object-Oriented − Python supports Object-Oriented style or technique of
programming that encapsulates code within objects.
• Python is a Beginner's Language − Python is a great language for the beginner-level
programmers and supports the development of a wide range of applications from simple
text processing to WWW browsers to games.

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.

• A loop statement allows us to execute a statement or group of statements multiple


times.
OPERATORS AND OPERANDS

Operators are special symbols that represent computations like addition and multiplication.
The values the operator is applied to are called operands.

The operators +, -, *, /, and ** perform addition, subtraction, multiplication, division, and


exponentiation

Example:- 20+32 hour-1

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

(assuming that the variable x has been assigned a value)

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

The others are:

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 greater than or equal to y


# x is less than or equal to y

# x is the same as y

# x is not 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:

print('x is less than

y')

elif x > y:

print('x is greater than y’)

else:

print('x and y are equal')


PYTHON LOOP

Sr.No. Loop Type & Description

1. While loop

Repeats a statement or group of statements while a given condition is TRUE. It

tests the condition before executing the loop body.

2. For loop

Executes a sequence of statements multiple times and abbreviates the code that

manages the loop variable.

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:

In Python a function is defined using the def keyword:

def my_function():

print("Hello from a function")

Calling a Function:

To call a function, use the function name followed by parenthesis:

def my_function():

print(“function”)

my_function()
Codes:

1. Write a program to find the given number is positive or negative.

num = float(input("Enter a number: "))

if num > 0:

print("Positive number")

elif num == 0:

print("Zero")

else:

print("Negative number")

2. Write a program to find the sum of two numbers.

num1 = int(input("Enter Number1: "))

num2 = int(input("Enter Number2: "))

print("sum of given numbers is:", num1 + num2)

3. Write a program to find if the given number is prime or not.

num = int(input("enter a number: "))

a = False

if num > 1:

for i in range(2, num):

if (num % i) == 0:

a= True

break

if a:

print(num, "is not a prime number")

else:
print(num, "is a prime number")

4. Write a program to check if the given number is palindrome or not.

num = int(input("Enter a number: "))

temp = num

reverse = 0

while temp > 0:

remainder = temp % 10

reverse = (reverse * 10) + remainder

temp = temp // 10

if num == reverse:

print('Palindrome')

else:

print("Not Palindrome")

5. Write a program to check if the given number is Armstrong or not

num = int(input("Enter a number: "))

sum = 0

temp = num

while temp > 0:

digit = temp % 10

sum += digit ** 3

temp //= 10

if num == sum:

print(num,"is an Armstrong number")

else:
print(num,"is not an Armstrong number")

6. Write a program to check if the given strings are anagram or not.

def check(s1, s2):

if(sorted(s1)== sorted(s2)):

print("The strings are anagrams.")

else:

print("The strings aren't anagrams.")

s1 = input("Enter string1: ")

s2 = input("Enter string2: ")

check(s1, s2)

7. Write a program to find a maximum of two numbers.

def maximum(a, b):

if a >= b:

return a

else:

return b

a = int(input("Enter a number: "))

b = int(input("Enter a number: "))

print(maximum(a, b))

8. Write a program to find a minimum of two numbers.

def minimum(a, b):

if a <= b:

return a

else:
return b

a = int(input("Enter a number: "))

b = int(input("Enter a number: "))

print(minimum(a, b))

9. Write a program to find a maximum of three numbers.

def maximum(a, b, c):

if (a >= b) and (a >= c):

largest = a

elif (b >= a) and (b >= c):

largest = b

else:

largest = c

return largest

a = int(input("Enter a number: "))

b = int(input("Enter a number: "))

c = int(input("Enter a number: "))

print(maximum(a, b, c))

10. Write a program to find a minimum of three numbers.

a = int(input('Enter first number : '))

b = int(input('Enter second number : '))

c = int(input('Enter third number : '))

smallest = 0

if a < b and a < c :

smallest = a
if b < a and b < c :

smallest = b

if c < a and c < b :

smallest = c

print(smallest, "is the smallest of three numbers.")

11. Write a program to find a factorial of a number.

num = int(input("Enter a number: "))

factorial = 1

if num < 0:

print("Sorry, factorial does not exist for negative numbers")

elif num == 0:

print("The factorial of 0 is 1")

else:

for i in range(1,num + 1):

factorial = factorial*i

print("The factorial of",num,"is",factorial)

12. Write a program to find a fibonacci of a number.

nterms = int(input("How many terms? "))

n1, n2 = 0, 1

count = 0

if nterms <= 0:

print("Please enter a positive integer")

elif nterms == 1:

print("Fibonacci sequence upto",nterms,":")


print(n1)

else:

print("Fibonacci sequence:")

while count < nterms:

print(n1)

nth = n1 + n2

n1 = n2

n2 = nth

count += 1

13. Write a program to find GCD of two numbers.

def gcd(a, b):

if (a == 0):

return b

if (b == 0):

return a

if (a == b):

return a

if (a > b):

return gcd(a-b, b)

return gcd(a, b-a)

a = 98

b = 56

if(gcd(a, b)):

print('GCD of', a, 'and', b, 'is', gcd(a, b))


else:

print('not found')

14. Write a program to print the following pattern.

def myfunc(n):
for i in range(0, n):
for j in range(0, i+1):
print("* ",end="")
print("\r")
n=5
myfunc(n)

16. Write a program to print the following pattern.

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)

18. Write a program to print the following pattern.

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)

19. Write a program to print the following pattern.

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)

20. Write a program to print the following pattern.

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

You might also like