Report
Report
On
This satisfaction that accompanies the successful completion of the task would be put
incomplete without the mention of the people who made it possible, whose constant guidance
and encouragement, crown the efforts with success.
We convey our gratitude to our esteemed management and honorable Principal,
Dr. M.MOHAN BABU and head of the department, DR.P.JYOTHEESWARI for providing all
the facilities and support.
Cover page i
Certificate ii-iii
Acknowledgment iv
Table of contents 1
1
1. COMPANY
The platform which was founded in 2010, started as a WordPress blog that
aggregated internships across India and articles on education ,technology and skill
gap. YBI Foundation launced its online trainings in 2014. As of 2018, the platform
had
3.5 million students and 80,000 companies.
2
2.0 PYTHON OVERVIEW AND PROJECT
Python can connect to a database systems. It can also read and modify files.
It is used for:
Installation :
to download the latest release of python When we click on the above link, it will
bring us the following page.
3
Step - 2: Click on the Install Now
Double-click the executable file, which is downloaded; the following window will
open. Select Customize installation and proceed. Click on the Add Path check box,
it will set the Python path automatically.
We can also click on the customize installation to choose desired location and
features. Other important thing is install launcher for the all user must be checked.
4
Step - 3 Installation in Process
Now, try to run python on the command prompt. Type the command python -
version in case of python3.
5
Features of python:
6
2.2 USING VARIABLES IN
In Python, numeric data type represent the data which has numeric value.
Numeric value can be integer, floating number or even complex numbers. These
values are defined as int, float and complex class in Python.
Integers :
This value is represented by int class. It contains positive or negative whole
numbers (without fraction or decimal). In Python there is no limit to how long an
integer value can be.
Float:
This value is represented by float class. It is a real number with floating point
representation. It is specified by a decimal point. Optionally, the character e or E
followed by a positive or negative integer may be appended to specify scientific
notation.
Complex Numbers :
Complex number is represented by complex class. It is specified as (real part) +
(imaginary part)j. For example – 2+3j
Note – type() function is used to determine the type of data type.
1. a = 5
2. print("Type of a: ",
type(a)) 3. b = 5.0
4. print("\nType of b: ", type(b))
5. c = 2 + 4j
7
6. print("\nType of c: ", type(c))
Output:
Type of a: <class 'int'>
Type of b: <class 'float'>
Type of c: <class 'complex'>
Strings and sequential :
Example:
print("Hello")
print('Hello')
output:
Hello
Hello
Assign String to a Variable:
Example:
a= "Hello"
print(a)
8
output:
Hello
Multiline Strings:
Example:
output:
Dictionary:
The items in the dictionary are separated with the comma (,) and enclosed in the
curly braces {}.
Example:
9
Output:
10
2.3 BASICS OF PROGRAMMING IN PYTHON
Conditionals:
Decision making is the most important aspect of almost all the programming
languages. As the name implies, decision making allows us to run a particular block
of code for a particular decision. Here, the decisions are made on the validity of
the particular conditions. Condition checking is the backbone of decision making.
If - else The if-else statement is similar to if statement except the fact that,
Statement it also provides the block of the code for the false case of the
condition to be checked. If the condition provided in the if
statement is false, then the else statement will be executed.
The if statement:
The if statement is used to test a particular condition and if the condition is true, it
executes a block of code known as if-block. The condition of if statement can be
any valid logical expression which can be either evaluated to true or false.
11
The syntax of the if-statement is given below.
if expression:
statement
Example 1:
num = int(input("enter the number?"))
if num%2 == 0:
print("Number is even")
Output:
enter the number?
10 Number is even
12
Example 2 : Program to print the largest of the three numbers.
1. a = int(input("Enter a? "));
2. b = int(input("Enter b? "));
3. c = int(input("Enter c? "));
4. if a>b and a>c:
5. print("a is largest");
6. if b>a and b>c:
7. print("b is largest");
8. if c>a and c>b:
9. print("c is largest");
Output:
Enter a? 100
Enter b? 120
Enter c? 130
c is largest
The if-else statement provides an else block combined with the if statement which
is executed in the false case of the condition.
If the condition is true, then the if-block is executed. Otherwise, the else-block is
executed.
13
The syntax of the if-else statement is given below.
if condition:
#block of statements
else:
#another block of statements (else-block)
14
Example 1 :
Output:
Enter your age? 90
You are eligible to vote !!
Example 2:
Output:
enter the number?
10 Number is even
The elif statement enables us to check multiple conditions and execute the specific
block of statements depending upon the true condition among them. We can have
any number of elif statements in our program depending upon our need. However,
using elif is optional.
15
The elif statement works like an if-else-if ladder statement in C. It must be
succeeded by an if statement.
elif expression 2:
# block of statements
elif expression 3:
# block of statements
else:
# block of statements
Example :
1. Example 1
2. number = int(input("Enter the number?"))
3. if number==10:
4. print("number is equals to 10")
5. elif number==50:
6. print("number is equal to 50");
7. elif number==100:
8. print("number is equal to 100");
9. else:
10. print("number is not equal to 10, 50 or 100");
Output:
16
Enter the number?15
number is not equal to 10, 50 or 100
LOOPS:
The following loops are available in Python to fulfil the looping needs. Python
offers 3 choices for running the loops. The basic functionality of all the techniques
is the same, although the syntax and the amount of time required for checking the
condition differ.
The following sorts of loops are available in the Python programming language.
2 For loop This type of loop executes a code block multiple times and
abbreviates the code that manages the loop variable.
17
Loop statements:
Statements used to control loops and change the course of iteration are called
control statements. All the objects produced within the local scope of the loop are
deleted when execution is completed.
Python's for loop is designed to repeatedly execute a code block while iterating
through a list, tuple, dictionary, or other iterable objects of Python. The process of
traversing a sequence is known as iteration.
18
Syntax of the for Loop:
Code:
Output:
The list of squares is [16, 4, 36, 49, 9, 25, 64, 100, 36, 1, 81, 4]
19
Using else Statement with for Loop:
As already said, a for loop executes the code block until the sequence element is
reached. The statement is written right after the for loop is executed after the
execution of the for loop is complete.
Only if the execution is complete does the else statement comes into play. It won't
be executed if we exit the loop or if an error is thrown.
Code
3. # Initiating a loop
4. for s in a string:
5. # giving a condition in if
block 6. if s == "o":
7. print("If block")
8. # if condition is not satisfied then else block will be executed
9. else:
10. print(s)
Output:
P
y
t
h
If block
20
n
L
If block
If block
p
Syntax:
Code:
# Python program to show how to use else statement with for loop
# Creating a sequence
tuple_ = (3, 4, 6, 8, 9, 2, 3, 8, 9, 7)
# Initiating the
loop
for value in tuple_:
if value % 2 != 0:
print(value)
# giving an else statement
else:
print("These are the odd numbers present in the tuple")
Output:
21
3
9
3
9
7
These are the odd numbers present in the tuple
The range() Function:
With the help of the range() function, we may produce a series of numbers.
range(10) will produce values between 0 and 9. (10 numbers).
We can give specific start, stop, and step size values in the manner range(start,
stop, step size).
Code
2. print(range(15))
3. print(list(range(15)))
4. print(list(range(4, 9)))
Output:
range(0, 15)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
[4, 5, 6, 7, 8]
22
[5, 9, 13, 17, 21]
To iterate through a sequence of items, we can apply the range() method in for
loops. We can use indexing to iterate through the given sequence by combining it
with an iterable's len() function. Here's an illustration.
Code:
Output:
PYTHON
LOOPS
SEQUENCE
CONDITION
RANGE
While Loop:
While loops are used in Python to iterate until a specified condition is met.
However, the statement in the program that follows the while loop is executed
once the condition changes to false.
while <condition>:
{ code block}
23
Example:
1. # Python program to show how to use a while loop
2. counter = 0
3. # Initiating the loop
4. while counter < 10: # giving the condition
5. counter = counter + 3
6. print("Python Loops")
Output:
Python Loops
Python Loops
Python Loops
Python Loops
Loop. Code:
1. #Python program to show how to use else statement with the while loop
2. counter = 0
Output:
24
Python Loops
Python Loops
Python Loops
Python Loops
Code block inside the else statement
25
2.4 PRINCIPLES OF OBJECT ORIENTED PROGRAMMING
o Class
o Object
o Method
o Inheritance
o Polymorphism
o Data Abstraction
o Encapsulation
Class:
The class can be defined as a collection of objects. It is a logical entity that has
some specific attributes and methods. For example: if you have an employee class,
then it should contain an attribute and method, i.e. an email id, name, age, salary,
etc.
26
Syntax:
class ClassName:
<statement-1>
.
.
<statement-N>
Object:
The object is an entity that has state and behavior. It may be any real-world object
like the mouse, keyboard, chair, table, pen, etc.
Example:
class car:
def init (self,modelname,
year): self.modelname =
modelname self.year = year
def display(self):
print(self.modelname,self.year)
c1 = car("Toyota", 2016)
c1.display()
Output:
27
Toyota 2016
Method:
Inheritance:
By using inheritance, we can create a class which uses all the properties and
behavior of another class. The new class is known as a derived class or child class,
and the one whose properties are acquired is known as a base class or parent
class.
Polymorphism:
Polymorphism contains two words "poly" and "morphs". Poly means many, and
morph means shape. By polymorphism, we understand that one task can be
performed in different ways. For example - you have a class animal, and all animals
speak. But they speak differently. Here, the "speak" behavior is polymorphic in a
sense and depends on the animal. So, the abstract "animal" concept does not
actually "speak", but specific animals (like dogs and cats) have a concrete
implementation of the action "speak".
28
Encapsulation:
Data Abstraction:
Data abstraction and encapsulation both are often used as synonyms. Both are
nearly synonyms because data abstraction is achieved through encapsulation.
29
2.5 CONNECTING TO SQLITE DATABASE
Consider the below example where we will connect to an SQLite database and
will run a simple query select sqlite_version(); to find the version of the SQLite we
are using.
Example:
import sqlite3
try:
sqliteConnection = sqlite3.connect('sql.db')
30
cursor = sqliteConnection.cursor()
print('DB Init')
query = 'select
sqlite_version();'
cursor.execute(query)
result = cursor.fetchall()
cursor.close()
print('Error occured –
‘,error)
finally:
if sqliteConnection:
sqliteConnection.close()
print('SQLite Connection
closed')
31
Output:
32
2.6 .PROJECT
Create a Fantasy Cricket game in Python. The game should have all the features
displayed in the mock-up screens in the scenario. To calculate the points for each
player, we can use rules similar to the sample rules displayed below.
Sample of Rules:
Batting
● 1 point for 2 runs scored
● Additional 5 points for half century
● Additional 10 points for century
● 2 points for strike rate (runs/balls faced) of 80-100
● Additional 4 points for strike rate>100
● 1 point for hitting a boundary (four) and 2 points for over boundary (six)
Bowling:
● 10 points for each wicket
● Additional 5 points for three wickets per innings
● Additional 10 points for 5 wickets or more in innings
● 4 points for economy rate (runs given per over) between 3.5 and 4.5
● 7 points for economy rate between 2 and 3.5
● 10 points for economy rate less than 2
Fielding:
● 10 points each for catch/stumping/run out
You can check the DataBase created for this Game named Fantasycricket.db.
To execute this program, we need to install PyQt5 which is a Python GUI Library.
And that’s, we are all set to run this program.
33
edited code will not reflect back to the main GUI. To execute the edited “evaluate
teams” code, we need to install the evaluation module.
Instruction to install :-
3. That’s it. Edited “evaluate teams” code will be reflected back to the main GUI.
34
Collecting Evaluation and downloading files:-
In this project, we can create a team based on our Points, We can save the team,
We can view our team, we can modify our team, we can delete our existing team
and we can evaluate the team.
Main files:-
35
Main files:
Options to fill the essential details about player and to get result
36
3.0 conclusion
1. I believe that trail has shown conclusively that it is both possible and desirable
to use python as the principle teaching language.
2. It is free (as in both cost and source code).
37
4.0 REFERENCES
https://trainings.internshala.com/dashboard/
https://www.w3schools.com/
https://internship.aicte-india.org/login_new.php
https://learn.verzeo.in/users/sign_in
38