SIX WEEKS SUMMER TRAINING
REPORT
On
OBJECT ORIENTED PROGRAMMING USING PYTHON
FROM EBOX
Submitted by
Shubham Kumar
Registration No: 11909793
Program Name: BTECH Computer Science and Engineering
Under the Guidance of
Vipin Sharma
(Instructor and Mentor At EBOX)
School of Computer Science & Engineering
Lovely Professional University, Phagwara
(June-July, 2021)
1
DECLARATION
I hereby declare that I have completed my six weeks summer training at EBOX from
21 May, 2021 to 30 June, 2021 under the guidance of Vipin Sharma. I have declared
that I have worked with full dedication during these six weeks of training and my
learning outcomes fulfil the requirements of training for the award of degree of
(Relevant Degree), Lovely Professional University, Phagwara.
Date: August, 2021 Shubham Kumar
Registration No: 11909793
2
ACKNOWLEDGEMENT
The success and final outcome of this internship required a lot of guidance and assistance
from many people and I am extremely privileged to have got this all along the completion of
my internship. All that I have done is only due to such supervision and assistance and I would
not forget to thank them.
I respect and thank the Lovely Professional University, for providing me an opportunity to
do the internship work and giving me ample time to complete it duly.
I owe my deep gratitude to the MOOC called Object Oriented Programming Using Python
and the course instructors from EBOX organization, who took keen interest in creating one
of the best courses out there for students to choose from.
I am thankful to and fortunate enough to get constant encouragement, support and guidance
from all of my friend circle and my family members which helped me in successfully
completing my internship work. Also, I would like to extend my sincere esteem to all the
panel members for taking time and grading my report and for helping me realise my
potential.
3
SUMMER TRAINING CERTIFICATE
4
TABLE OF CONTENTS
S.NO Title page
1. Declaration by student 2
2. Acknowledgement 3
3. Summer Training Certificate 4
4. Introduction 6
5. Technology Learnt 8
6. Reason for Choosing This Technology 9
7. Learning Outcomes 10
8. Gantt Chart 42
9. Bibliography 43
5
INTRODUCTION
The IT industry is booming with artificial intelligence, machine learning and data science applications.
With the new age applications, demand for a python developer has also increased. Ease of access and
readability has made python one of the most popular programming language nowadays. And due to
this I have chosen this course to do as my summer training.
Python is a general-purpose programming language. It is very easy to learn, easy syntax and
readability is one of the reasons why developers are switching to python from other
programming languages. We can use python as object oriented and procedure-oriented
language as well. It is open source and has tons of libraries for various implementations.
Python is a high-level interpreted language, which is best suited for writing python scripts for
automation and code re-usability. It was created in 1991 by Guido Van Rossum. The origin of its name
is inspired by the comedy series called ‘Monty python’.
Python extends the usage of OOPs, which makes code look clean and refactored. Although there are
implementations of OOPs in other programming languages, I am familiar with, like C++, JAVA and
JAVASCRIPT, but none of them comes quite close to the brevity, clarity and the flow that Python
gives
I highly preferred this language because its easy to understand the codes and its readability and
reusability also increases as it looks less complex than any other programming language.
6
In this course I mainly focused on OOPs concepts of python and same will be reflected here in the
report.
I am highly obliged that LPU gave me the opportunity to do this course and become more skillful
and gain more experience in this field. Also at the end I will be showcasing a mini project that I do as
to gain more experience in this language.
7
TECHNOLOGY LEARNT
In this course I learnt about various concepts that are mentioned here:
▪ Python (Fundamentals to Intermediate)
▪ Object Oriented Programming Design
▪ Modules and Packages
▪ String and List Handling
▪ Exception Handling
▪ Functions
▪ File Handling
8
REASON FOR CHOOSING THIS TECHNOLOGY
The primary reason for picking up Python is due to its huge popularity among the
developer circle. It is one of the most powerful languages in terms of development and one
can deploy an application real fast. Moreover, I am a student pursuing IOT which requires
coding in Python in Raspberry bi and various other tools. So, learning this programming language
will give me an upper edge and help me ace my subjects.
Another reason for choosing this technology is because of its reach. Python is implemented
in almost every computer science field known till date. By learning Python, I will be
eligible to pursue any of these fields of interest and ultimately, help me land an amazing
career.
Therefore, due to all of the aforesaid reasons, I decided to dedicate my entire Internship
duration to learn Python Programming.
9
LEARNING OUTCOMES
Learning Python with OOPs has taught me a lot and here is the module I learnt in this course:
1. Python Basics
2. Modules and Packages
3. Strings and Lists Handling
4. Exception Handling
5. Object Oriented Programming
6. Mini Project (Guess the word)
I think this is one the best something I would have learnt in the summer and utilized my time.
This course has been full of experience as there were around 60-70 MCQs and around 14-15
coding questions in each module to solve which not only enhanced my knowledge but also
increased my code writing capability.
10
Python Basics
Let’s start with this introduction to python with keywords and identifiers.
Keywords & Identifiers
Keywords are nothing but special names that are already present in python. We can use these keywords
for specific functionality while writing a python program.
*Source google.com
Identifiers are user defined names that we use to represent variables, classes, functions, modules etc.
`Shubham`
*snippet from my visual studio
Here name is an identifier or we can say a variable of string data type that store Shubham in it.
So, what is variable or data type, lets understand this.
Variables & Data Types
Variables are like a memory location or we can say a container where you can store a value. This
value, you may or may not change in the future.
`Shubham`
Here name, x, y are variables.
To declare a variable in python, you only have to assign a value to it. There are no additional
commands needed to declare a variable in python.
11
Data Types in Python
1. Numbers
2. String
3. List
4. Dictionary
5. Set
6. Tuple
Numbers
Numbers or numerical data type is used for numerical values. We have 4 types of numerical
data types integer, float, complex and boolean.
*Snippet from my visual studio
String
String data type is used to represent characters or alphabets. You can declare a string using
single” or double quotes “”.
List
List in python is like a collection where you can store different values. It need not be uniform
and can have different values. Lists are indexed and can have duplicate values as well. To
declare a list, you have to use square brackets.
Dictionary
A dictionary is unordered and changeable, we use the key value pairs in a dictionary. Since
the keys are unique we can use them as indexes to access the values from a dictionary.
12
Tuple
Tuple is another collection which is ordered and unchangeable. We declare the tuples in
python with round brackets.
Set
A set is a collection which is unordered and unindexed. A set does not have any duplicate
values as well.
In any programming language, the concept of operators plays a vital part. Lets take a look at
operators in python.
Operators
Operators in python are used to do operations between two values or variables. Following are the
different types of operators that we have in python:
• Arithmetic Operators (+, -, *, /, //)
• Logical Operators (and, or, not)
• Assignment Operators (=, /=, += and so on)
• Comparison Operators (= =,!=, >=, <=, >, <,)
• Membership Operators (in)
• Identity Operators (is)
• Bitwise Operators (&, |, ^, ~, >>, <<)
Loops In Python
A loop allows us to execute a group of statements several times. To understand why we use
loops, let’s take an example.
Suppose you want to print the sum of all even numbers until 1000. If you write the logic for
this task without using loops, it is going to be a long and tiresome task.
But if we use a loop, we can write the logic to find the even number, give a condition to iterate
until the number reaches 1000 and print the sum of all the numbers. This will reduce the
complexity of the code and also make it readable as well.
There are following types of loops in python:
1. for loop
2. while loop
3. nested loops
For Loop
A ‘for loop’ is used to execute statements once every iteration. We already know the number
of iterations that are going to execute.
13
A for loop has two blocks, one is where we specify the conditions and then we have the body where
the statements are specified which gets executed on each iteration.
While Loop
The while loop executes the statements as long as the condition is true. We specify the
condition in the beginning of the loop and as soon as the condition is false, the execution stops.
Conditional and Control Statements
Conditional statements in python support the usual logic in the logical statements that we have
in python.
Following are the conditional statements that we have in python:
1. if
2. elif
3. else
The if statement tests the condition, when the condition is true, it executes the statements in
the if block.
When both if and elif statements are false, the execution will move to else statement.
Here is an example of all together.
14
Control statements
Control statements are used to control the flow of execution in the program.
Following are the control statements that we have in python:
1. break
2. continue
3. pass
break
The execution will stop as soon as the loop encounters break.
continue
When the loop encounters continue, the current iteration is skipped and rest of the iterations get
executed.
pass
The pass statement is a null operation. It means that the command is needed syntactically but you do
not wish to execute any command or code.
FUNCTIONS
A function in python is a block of code which will execute whenever it is called. We can pass
parameters in the functions as well. To understand the concept of functions, lets take an example.
Suppose you want to calculate factorial of a number. You can do this by simply executing the logic
to calculate a factorial. But what if you have to do it ten times in a day, writing the same logic again
and again is going to be a long task.
Instead, what you can do is, write the logic in a function. Call that function everytime you need to
calculate the factorial. This will reduce the complexity of your code and save your time as well.
How to Create a Function?
How to Call a Function?
15
Function Parameters
We can pass values in a function using the parameters. We can use also give default values for a
parameter in a function as well.
Lambda Function
A lambda function can take as many numbers of parameters, but there is a catch. It can only have one
expression.
STRING AND LIST HANDLING
Strings and lists are one of the most important and widely useful objects in Python. So much
that Python has provided additional handling operations to make our tasks even easier.
Following are some of the ways in which one can handle Lists:
List Slicing
Slicing is a process of slicing a list into required parts and accessing it without actually
modifying the parent list. In the following code, L is still a list and L1 is a part of List. The
syntax for the same is:
newList = oldList[startIndex : endIndex+1 : step]
L = [1,2,4,5,6]
L1 = L[0:5:2] #[1,4,6]
Length of List
One can easily find the length of the list by using the len() function:
len(L)
Appending an Element
To append an element at the end of the list, use the append() method. The syntax for the
same is:
listName.append(value)
16
Inserting Element at Particular Position
To insert an element at a position, you can use the insert() method. The syntax for the same
is:
listName.insert(index, value)
Extending a List
This is a bit different from appending. In extending, a List can be extended by containing
the elements of another list. For example, if L1 has 5 elements and L2 has 4 elements,
upon extending L2 to L1: L1 will have 9 elements in total. But in the case of appending,
L1 will only have 6 elements. That’s because when you append, the entire L2 elements will
be appended as a single list object. The following code demonstrates the same:
Sorting a List
There are two ways of sorting a list. Using sort() and sorted()
sort() sorts the given list in place while sorted() sorts the list and returns a new list.
Syntax:
listName.sort()
List Comprehension
Perhaps, one of the most powerful way of handling a list is via list comprehension. List
comprehension in Python is an easy and compact syntax for creating a list from a string
or another list. It is a very concise way to create a new list by performing an operation on
each item in the existing list. List comprehension is considerably faster than processing a list
using the for loop. The following code creates a list and populates it with even values
from 0 till 20 all in just one line
evenList = [nums for nums in range(21) if nums%2==0]
Following are the ways to handle a String. But keep in mind that strings are immutable data
types. Therefore, one can’t change the contents of it after assigning the value. So, not all of
the operations of list would be applicable to strings. Here are some ways:
String Slicing:
Similar to Lists, we can slice strings as well, look at the code below:
17
Length of String:
You can use the len() function to get the length of the string as shown below:
Replacing:
You can replace a letter or word in string by using replace() method. It returns the new
replaced string. The syntax for it is given below:
string.replace(‘old value’, ‘new value’)
Splitting String to List
You can convert a given string to a list. It is done by the split() method. The split method
takes in one parameter: the delimiter. The delimiter is a way by which string splits each
word or letter and adds them as an element to a list. split() returns a new list. The syntax is
given below:
newList = stringVar.split(‘delimiter in quotes’)
Upper, Lower and Capitalize casing in String:
You can transform the case to uppercase, lowercase or even capitalize in string. It is done
using the upper(), lower() and capitalize() methods respectively.
Syntax:
String.upper()
String.lower()
String.capitalize()
18
Exceptional Handling
When we are writing a program, if an error occurs the program will stop. But we can handle these
errors/exceptions using the try, except, finally blocks in python.
When the error occurs, the program will not stop and execute the except block.
Finally
When we specify a finally block. It will be executed even if there is an error or not raised by the try
except block.
Raising Exceptions
Now, these were how you would handle inbuilt exceptions. Now if you want to manually
raise an exception, then Python provides you the option for that too!
If you want to raise your exceptions, all you have to do is, simply make use of the raise
keyword inside a try block and then handle it using an except block. The following code
demonstrates its usage:
Note that in the following code snippet, I raised an exception while comparing two strings,
which is totally a valid operation. But I raised a ZeroDivisionError there and handled it
using an except block.
Now that we have understood exception handling concepts. Lets take a look at file handling concepts
in python.
19
File Handling
File handling is an important concept of python programming language. Python has various functions
to create, read, write, delete or update a file.
These are all the functions we can perform with file handling in python.
Alright, this ends the File Handling Section. Now, onto the Object Oriented
Programming using Python section.
20
OOPs Concepts
Python can be used as an object-oriented programming language. Hence, we can use the following
concepts in python:
1. Abstraction
2. Encapsulation
3. Inheritance
4. Polymorphism
Abstraction
Data abstraction refers to displaying only the necessary details and hiding the background tasks.
Abstraction is python is similar to any other programming language.
Like when we print a statement, we don’t know what is happening in the background.
Encapsulation
Encapsulation is the process of wrapping up of data. In python, classes can be a example of
encapsulation where the member functions and variables etc are wrapped into a class.
Polymorphism
Polymorphism is the process in which an object can be used in many forms. The most common
example would be when a parent class reference is used to refer to a child class object.
I will be talking about Inheritance later in this report but first let’s start with classes and objects
concept.
What are Classes?
Classes are like a blueprint for creating objects. We can store various methods/functions in a class.
What are Objects or Instance of a Class?
We create objects to call the methods in a class, or to access the properties of a class.
21
Like any other language python also has constructor which is __init__function.
__init__ function
It is an inbuilt function which is called when a class is being initiated. All classes have __init__
function. We use the __init__ function to assign values to objects or other operations which are
required when an object is being created.
So, as we have learnt about classes and objects let’s discuss Inheritance in python.
Inheritance
Inheritance is an object-oriented concept where a child class inherits all the properties from a parent
class. Following are the types of inheritance we have in python:
1. Single Inheritance
2. Multiple Inheritance
3. Multilevel Inheritance
Single Inheritance
In single inheritance there is only one child class that inherits the properties from a parent class.
Multiple Inheritance
In multiple inheritance, we have two parent classes and one child class that inherits the properties
from both the parent classes.
22
Multilevel Inheritance
In multilevel inheritance, we have one child class that inherits properties from a parent class. The
same child class acts as a parent class for another child class.
Here the Python OOPs concepts comes to an end and I will be showing you my Mini project:
Miniproject: GUESS THE WORD
Since the aim was to capture the OOPs concept and create a project out of it, I decide to
make word game in which I enjoyed a lot writing the code as it was fun making the logic of
the code.
Here is the code I made:
import random
import time
class game:
def play_guess(self,str1):
count=0
limit=5
str2='_'*len(str1)
print(str2)
i=0
while i<len(str1) and count<5:
c=input("enter the character: ")
if(str1[i]==c):
str2=str2[:i]+c+str2[i+1:]
print(str2)
i=i+1
else:
count=count+1
if count == 1:
print(" _____ \n"
" | \n"
" | \n"
" | \n"
" | \n"
" | \n"
" | \n"
"__|__\n")
print("Wrong guess. " + str(limit - count) + " guesses remaining\n")
elif count == 2:
print(" _____ \n"
" | | \n"
23
" | |\n"
" | \n"
" | \n"
" | \n"
" | \n"
"__|__\n")
print("Wrong guess. " + str(limit - count) + " guesses remaining\n")
elif count == 3:
print(" _____ \n"
" | | \n"
" | |\n"
" | | \n"
" | \n"
" | \n"
" | \n"
"__|__\n")
print("Wrong guess. " + str(limit - count) + " guesses remaining\n")
elif count == 4:
print(" _____ \n"
" | | \n"
" | |\n"
" | | \n"
" | O \n"
" | \n"
" | \n"
"__|__\n")
print("Wrong guess. " + str(limit - count) + " last guess remaining\n")
elif count == 5:
print(" _____ \n"
" | | \n"
" | |\n"
" | | \n"
" | O \n"
" | /|\ \n"
" | / \ \n"
"__|__\n")
print("Wrong guess. You are hanged!!!\n")
# print("no. of misses:",count)
ask=input("do you want to play again(y/n):")
return ask
p1=game()
words=["january","border","image","film","promise","kids","lungs","doll","rhyme","damage","plant
s"]
ask='y'
while(ask=='y'):
i = random.choice(words)
ask=p1.play_guess(i)
print("Thanks for playing!!!")
24
Description About The Game
▪ In this game player has to guess the word according to the length.
▪ He has to guess the word letter by letter in the correct dequence.
▪ He will be given five chance in one go to guess a word.
▪ If he does 1 wrong guess no. of chances decrease to 4 and so on.
▪ If he guesses correctly he will be awarded points.
▪ He can play the as many times he wishes.
That’s all in this game and that’s all I have done as my miniproject.
So, with this, the report nears the culmination. It was a great learning experience and
helped me a lot in my current endeavours. Now, I am pretty confident about coding in
Python, a subject which I feared in my semesters and had doubts on the scope of pursuing
this further. I would love to extend my sincere thanks again to EBOX and Lovely
Professional University from the bottom of my hearts for providing me with this
amazing and brilliant course that not only polished my lagging skills, but also opened
many doors of opportunities.
25
Gantt Chart
26
BIBILIOGRAPHY
S.NO Title
1. https://benchmarksgame-
team.pages.debian.net/benchmarksgame/fastest/python.html
2. https://app.e-box.co.in/
3. https://docs.python.org/3/
4. https://xkcd.com/353/
5. https://en.wikipedia.org/wiki/Minimax
6. https://github.com/intel/cve-bin-tool/graphs/contributors
7. https://www.canva.com/
27