Final Project Report
Final Project Report
on
Python
Complete at
Kodacy
Duration
5th May 2023 To 17 th June 2023
Submitted By
Anusha Aarohi Saxena
V Semester
Enrollment No.:21E1EBADF40P002
I hereby declare that the Industrial Training Report on Python completed at Kodacy is
the V semester syllabus during the period from 05 th May 2023 to 17 th June 2023
Engineering College Bikaner for the award of the degree of B.Tech. in Artificial
Certificate
Student Declaration
1. Introduction 1-4
2.2 Variables 5
2.3 Strings 6
2.4 Tuples 6
2.5 List 8
2.8.1 If Statement 20
2.9 Functions 20
3. Project 21-22
4. Conclusion 24
References
Appendices
INTRODUCTION
Python is a widely used high-level, general-purpose, interpreted, dynamic programming
language. Its design philosophy emphasizes code readability, and its syntax allows
programmers to express concepts in fewer lines of code than would be possible in
languages such as C++ or Java. The language provides constructs intended to enable clear
programs on both a small and large scale.
Python supports multiple programming paradigms, including object-oriented, imperative
and functional programming or procedural styles. It features a dynamic type system and
automatic memory management and has a large and comprehensive standard library.
Python interpreters are available for installation on many operating systems, allowing
Python code execution on a wide variety of systems.
1
closed, but I had a home Computer, and not much else on my hands. I decided to write an
interpreter for the new scripting language I had been thinking about lately: a descendant of
ABC that would appeal to Unix/C hackers. I chose Python as a working title for the project,
being in a slightly irreverent mood (and a big fan of Monty Python's Flying Circus).
-Science
- Bioinformatics
2
- System Administration
- Unix
-Web logic
-Web sphere
The things that we can do with Python are as follows:
- System programming
- Graphical User Interface Programming 3 - Internet Scripting
- Component Integration
- Database Programming
-Gaming, Images, XML, Robot and more.
Python is a popular language for machine learning because of its powerful libraries, such
as TensorFlow, PyTorch, and Scikit-learn. These libraries provide a variety of tools and
algorithms for training and deploying machine learning models.
Python is also a popular language for natural language processing (NLP) tasks, such as
text classification, sentiment analysis, and machine translation. There are a number of
Python libraries that are specifically designed for NLP tasks, such as NLTK and spaCy.
• Robotics:
Python is also used in robotics to control robots and to develop AI algorithms for
robots. There are a number of Python libraries that are specifically designed for robotics,
such as ROS and RobotPy.
With libraries like NumPy, Matplotlib, Pandas, etc., developers can efficiently visualize
data, thus making it easier to gain insights and identify patterns that inform the AI model
design. Also, Python excels in data preparation and preprocessing, which are considered
as most crucial steps in building AI models.
3
According to the father of Artificial Intelligence, John McCarthy, it is “The science and engineering of
making intelligent machines, especially intelligent computer programs”.
4
BASICS OF PYTHON
2.1 Data Type
Data types determine whether an object can do something, or whether it just would not
make sense. Other programming languages often determine whether an operation makes
sense for an object by making sure the object can never be stored somewhere where the
operation will be performed on the object (this type system is called static typing). Python
does not do that. Instead it stores the type of an object with the object, and checks when the
operation is performed whether that operation makes sense for that object.
Python has many native data types. Here are the important ones:
Booleans are either True or False.
Numbers can be integers (1 and 2), floats (1.1 and 1.2), fractions (1/2 and 2/3), or even
complex numbers.
Strings are sequences of Unicode characters, e.g. an HTML document.
Bytes and byte arrays, e.g. a JPEG image file.
Lists are ordered sequences of values.
Tuples are ordered, immutable sequences of values.
Sets are unordered bags of values.
2.2 Variables
Variables are nothing but reserved memory locations to store values. This means that when
you create a variable you reserve some space in memory.
Based on the data type of a variable, the interpreter allocates memory and decides what
can be stored in the reserved memory. Therefore, by assigning different data types to
variables, you can store integers, decimals or characters in these variables.
Ex: counter = 100 # An integer assignment miles = 1000.0
floating point name = "John" # A string
2.3 Strings
In programming terms, we usually call text a string. When you think of a string as a
collection of letters, the term makes sense.
All the letters, numbers, and symbols in this book could be a string. For that matter, your
name could be a string, and so could your address.
5
For example -
"Geeksforgeeks" or 'Geeksforgeeks' or "a"
Strings are assigned in “” or ‘’. Strings can be letters, numbers or any kind of characters.
Strings also perform operations like slicing, indexing, extracting
and comparison, for example-
1. string = “hello”
print(string[0])
Output-
“h’ #indexing
2. string = “hello”
print(string[1:4])
Output-
“ell” # slicing
2.4 Tuples
A tuple is a sequence of immutable Python objects. Tuples are sequences, just like lists.
The differences between tuples and lists are, the tuples cannot be changed unlike lists and
tuples use parentheses.
6
Table 2.1 Basic Tuple Operation in Python
7
2.5 List
The list is a most versatile datatype available in Python which can be written as a list of
comma- separated values (items) between square brackets. Important thing about a list is
that items in a list need not be of the same type.
Creating a list is as simple as putting different comma-separated values between square
brackets. For example − list1 = ['physics', 'chemistry', 1997, 2000]; list2 = [1, 2, 3, 4, 5 ];
list3 = ["a", "b", "c", "d"];
Similar to string indices, list indices start at 0, and lists can be sliced, concatenated and so
on.
Now, we shall discuss about basic list operation with the help of list operation.
8
Table 2.3 Basic List Operations
9
Python includes following list methods-
Table 2.5 List Methods used by Python
10
Basically used for arithmetic operations like addition, multiplication, division etc. Few of
them are as follows –
11
Operator Description Syntax
12
OPERATOR NAME DESCRIPTION SYNTAX
13
Operator Description Syntax
i. Logical not
iii.Logical or
14
Operator Description Syntax
15
Operator Description Syntax
Performs Bitwise OR on
|= operands and assign value to a|=b a=a|b
left operand
There are many operators used by Python such as identity operators etc.
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. The following diagram illustrates a loop statement –
A for loop in Python is used to iterate over a sequence (list, tuple, set, dictionary, and
string). Example: The preceding code executes as follows: The variable i is a placeholder
for every item in your iterable object. The loop iterates as many times as the number of
elements and prints the elements serially.
Loops can be used to perform a variety of tasks, such as:
1. Iterating over a list of items
16
2. Processing data in a file
17
Loops Description
Repeats a statement or group of
while loop statements while a given
condition is TRUE. It tests the
condition before executing the
loop body
Executes a sequence of
for loop statements multiple times and
abbreviates the code that
manages the loop variable.
nested loops You can use one or more loop
inside any another while, for or
do..while loop.
Loop Example-
For Loop:
>>> for mynum in [1, 2, 3, 4, 5]: print ("Hello", mynum )
Hello 1
Hello 2
Hello 3
Hello 4
Hello 5
While Loop:
>>> count = 0 >>while(count< 4):
18
2.8 Conditional Statements
Decision making is anticipation of conditions occurring while execution of the program and
specifying actions taken according to the conditions.
Decision structures evaluate multiple expressions which produce TRUE or FALSE as
outcome. You need to determine which action to take and which statements to execute if
outcome is TRUE or FALSE otherwise.
Conditional statements in Python are used to control the flow of execution of a program
based on certain conditions. They are used to make decisions and execute different blocks
of code based on those decisions.
They allow to print result based on comparison.
The conditional statements work upon the basis of the value the condition whether it
evaluate to either true or false and the block of statements gets executed depending upon
the result.
Main conditional statements are as follows-
Statement Description
Example:
19
2.8.1 If Statement:
a=33 b=200
If b>a:
print(“b”)
2.9 Functions
Function blocks begin with the keyword def followed by the function name and parentheses
( ).
Any input parameters or arguments should be placed within these parentheses. You can also
define parameters inside these parentheses.
The first statement of a function can be an optional statement - the documentation string of
the function.
The code block within every function starts with a colon (:) and is indented.
The statement return [expression] exits a function, optionally passing back an expression
to the caller. A return statement with no arguments is the same as return None.
"This prints a passed string into this function" print str return;
# Now you can call print me function print me("I'm first call to user defined function!")
print me("Again second call to the same function")
20
PROJECT
21
Figure 3.2 Statements used in the code and its output in the console
So, this is how our code works using a random library by importing it using the import
keyword and applying random choices to the computer and hence choosing our answer
and comparing it to computer’s answer it is decided that who has won the game.
22
REFERENCES
23
APPENDICES
6.1 Project
Source code for the hence made project is-
import random
while True:
my_answer = input("Choose the answer : snake,water,gun, : ")
if my_answer != "snake" and my_answer != "water" and my_answer != "gun":
print("Please choose the correct option")
continue
computer_answer = random.choice(["snake","water","gun"])
print(f"Computer chooses : {computer_answer}")
if my_answer = computer_answer:
print("YOU TIED")
elif my_answer = "snake" and computer_answer == "water":
print("YOU WON")
elif my_answer = "water" and computer_answer == "gun":
print("YOU WON")
elif my_answer = "gun" and computer_answer == "snake":
print("YOU WON")
else:
print("YOU LOSE , TRY AGAIN")
my_answer = input("do you want play again : yes , no : ")
if my_answer != "yes":
print("YOU DO NOT WANT TO PLAY THEN IT IS OKAY")
break
6.2 Output
24