NIPUNNNNN
NIPUNNNNN
Training Report
On
“ PYTHON ”
Submitted in partial fulfillment of the requirement for the
Award of the degree of
Bachelor of Technology
In
Computer Science and Engineering
(Affiliated to Rajasthan Technical University, Kota)
The project report has been completed under the guidance of Ms. Chetana Pareta
(Ass. Professor, CSE Department) of JEC and is as per the norms and guidance
provided.
Mr. S. S. Saini
(HOD CSE)
www.jeckukas.org
ii
CERTIFICATE
iii
Candidate’s Declaration
“I hereby declare that the project work entitled “Python” submitted to Mr. Sultan Singh
Saini, is a record of an original work done by us under the guidance of Ms. Chetana
Pareta. This project has not been submitted earlier in part or full for the award of any
other degree or diploma of this or any other Institution/University to the best of our
knowledge and belief.
The report embodies the results of my own work and has been written by me. I
have not copied from any other students’ work or from any other sources except
where due reference acknowledgment is made explicitly in the text."
Chirayu Dashora
23EJECS028
iv
Acknowledgment
I would like to express my deepest appreciation to all those who provided me with the
possibility to complete my report. Furthermore, I would like to acknowledge with much
appreciation the crucial role of the other employees and teacher Ms. Chetana Pareta
who permitted me to use the required equipment and necessary materials to complete the
task. I sincerely acknowledge them for extending their valuable guidance, support for
literature, critical reviews of this report, and above all for the moral support they
provided me at all stages of the project. Last but certainly not least, I am deeply grateful
to my family for their unwavering love, support, and understanding throughout this
project. Their encouragement, understanding, and belief in our abilities have been
pivotal in my success. I would like to acknowledge that this project would not have been
possible without the collective efforts, contributions, and support of the organization.
Their involvement has truly made a significant impact on the successful completion of
this project.
v
Abstract
" This report provides an in-depth exploration of Python, beginning with its history and
evolution since its creation by Guido van Rossum in the late 1980s. It delves into the
basic constructs of the language, highlighting its simplicity and readability, which have
contributed to its widespread adoption. The report covers fundamental data types,
including integers, floats, strings, and lists, explaining their uses and operations. It
further discusses operators and control structures such as loops, demonstrating how they
facilitate efficient coding practices. The practical application of Python is showcased
through the Tkinter library, which enables the creation of graphical user interfaces
(GUIs), and Streamlit, a framework for developing interactive web applications. By
examining these libraries, the report illustrates Python's versatility in both desktop and
web development. Through detailed examples and explanations, readers will gain a solid
understanding of Python's basics and its powerful capabilities for building diverse
applications.
vi
TABLE OF CONTENT
TITLE PAGE i
APPROVAL AND INTERNAL GUIDE CERTIFICATE ii
CERTIFICATE iii
CANDIDATE’S DECLARATION iv
ACKNOWLEDGMENT v
ABSTRACT vi
TABLE OF CONTENTS vii - viii
LIST OF FIGURES ix
CONCLUSION 32
REFERENCE 33
vii
4. Hugging Face 23
4.1 Overview of Hugging Face in Python 23
4.2 Using Pre-Trained Models 24
4.3 Working with Specific Models 24
4.4 Popular Tasks 25
4.5 Using Datasets with Hugging Face 26
4.6 Model Hub 27
5. Project Undertaken 27
5.1 Text to Image Converter 27
5.2 Chatbot Application 29
viii
LIST OF FIGURES
S.No. Name of Figures Page No.
Fig 1.1 Sample List Code 4
Fig 1.2 Sample Dictionary Code 5
Fig 1.3 Sample Tuple Code 6
Fig 1.4 Sample Set Code 6
Fig 1.5 Sample String Code 7
Fig 1.6 Sample Data Type Code 7
Fig 1.7 Operators 8
Fig 1.8 Arithematic Operators 9
Fig 3.1 Code for Login Page 21
Fig 3.2 Output of Login Page 22
Fig 5.1 Code for TTI Generator 27
Fig 5.2 Output for TTI Generator 28
Fig 5.3 Code of Chatbot 30
Fig 5.4 Output of Chatbot 31
ix
x
Chapter – 1
PYTHON
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.
1
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.
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 provides very high-level dynamic data types and supports dynamic type
checking.
2
1.3 PYTHON RELEASES
Python 2.1 -April 17, 2001 &Python 2.2 - December 21, 2001 * Python 2.3 - July 29,
2003
Python 2.4 - November 30, 2004 * Python 2.5 -September 19, 2006 * Python 2.6 -
October 1, 2008
Python 3.3 -September 29, 2012 •Python 3.4 -March 16, 2014
Python 35. - September 13, 2015 Python 36. -December 23, 2016
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 (this is
called dynamic typing).
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
3
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.
1.4.1 LISTS-
• Ordered collection of data.
• Supports similar slicing and indexing functionalities as in the case of Strings.
• They are mutable.
• Advantage of a list over a conventional array
• Lists have no size or type constraints(no setting restrictions beforehand).
• They can contain different object types.
1.4.2 DICTIONARY-
Lists are sequences but the dictionaries are mappings. They are mappings between a
unique key and a value pair. These mappings may not retain order.
It is enclosed by curly braces {} and values can be assigned and accessed using square
brackets[].
4
Figure 1.2 Sample Dictionary Code
1.4.3 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, whereas lists use square brackets.
Creating a tuple is as simple as putting different comma-separated values. Optionally you
can put these comma-separated values between parentheses also. For example –
5
1.4.4 SETS-
• A set contains unique and unordered elements and we can construct them by using a set)
function.
• Convert a list into Set-
• 1=[1,2,3,4,1,1,2,3,6,7) • =k set(i)
• k becomes (1,2,3,4,6,7) • Basic Syntax-
• x.add (1)
• x=(1)
• x.add(1)
• This would make no change in x now
1.4.5 STRING
In programming terms, we usually call text a string. When you think of a string as a
collection of letters, the term makes sense.
Al 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.
6
1.4.6 NUMERIC DATA TYPES
Numbers have four types in Python. Int, float, complex, and long.
Arithmetic operators
Assignment operators
Comparison operators
Logical operators
Identity operators
Membership operators
Bitwise operators
7
Fig 1.7 Operators
8
Fig 1.8 Arithmetic Operator
OUTPUT :
ASSIGNMENT OPERATORS :
The Assignment operator is one of the most frequently used operators in Python. The
operator consists of a single equal sign (=), and it operates on two operands. The left-hand
operand is typically a variable, while the right-hand operand is an expression.
COMPARISION OPERATORS:
9
The Python comparison operators allow you to compare numerical values and any other
objects that support them. The table below lists all the currently available comparison
operators in Python:
LOGICAL OPERATORS:
Python logical operators are used to combine conditional statements, allowing you to
perform operations based on multiple conditions. These Python Operators, alongside
arithmetic operators, are special symbols used to carry out computations on values and
variables. In this article, we will discuss logical operators in Python definition and also
look at some Python logical operators programs, to completely grasp the concept.
10
IDENTITY OPERATORS:
Identity operators are used to compare the objects, not if they are equal, but if they are the
same object, with the same memory location:
11
MEMBERSHIP OPERATORS:
The Python membership operators test for the membership of an object in a sequence,
such as strings, lists, or tuples. Python offers two membership operators to check or
validate the membership of a value. They are as follows:
IN OPERATOR :
The in operator is used to check if a character/substring/element exists in a
sequence or not. Evaluate to True if it finds the specified element in a sequence
otherwise False.
NOT IN OPERATOR :
The not in Python operator evaluates to true if it does not find the variable in the
specified sequence and false otherwise.
BITWISE OPERATORS:
Bitwise operators are employed in python to perform bitwise operations on numbers. The
values are first converted to binary, and then manipulations are done bit by bit, hence the
phrase "bitwise operators." The outcome is then displayed in decimal numbers.
12
Bitwise Logical Operator: These operators are employed to execute logical operations
like other logical operators bit by bit. This is akin to using logical operators such as and,
or, and not on a bit level. Except for these basic facts, bitwise and logical operators are
analogous.
Bitwise Shift Operators: These operators multiply or divide an integer number by two by
shifting every individual bit to the left or right. We can use them when we wish to
multiply or divide a value by a power of 2. Python's bitwise operators only work with
integers.
We may wish to describe the code we develop. We might wish to take notes of why a
section of script functions, for instance. We leverage the remarks to accomplish this.
Formulas, procedures, and sophisticated business logic are typically explained with
comments. The Python interpreter overlooks the remarks and solely interprets the script
when running a program. Single-line comments, multi-line comments, and documentation
strings are the 3 types of comments in Python.
Our code is more comprehensible when we use comments in it. It assists us in recalling
why specific sections of code were created by making the program more understandable.
Aside from that, we can leverage comments to overlook specific code while evaluating
other code sections. This simple technique stops some lines from running or creates a fast
pseudo-code for the program.
Single-Line Comments
Single-line remarks in Python have shown to be effective for providing quick descriptions
for parameters, function definitions, and expressions. A single-line comment of Python is
the one that has a hashtag # at the beginning of it and continues until the finish of the line.
13
If the comment continues to the next line, add a hashtag to the subsequent line and
resume the conversation.
Multi-Line Comments
Python does not provide the facility for multi-line comments. However, there are indeed
many ways to create multi-line comments.
In Python, we may use hashtags (#) multiple times to construct multiple lines of
comments. Every line with a (#) before it will be regarded as a single-line comment.
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.
For the ease of programming and to achieve simplicity, python doesn't allow the use of
parentheses for the block level code. In Python, indentation is used to declare a block. If
two statements are at the same indentation level, then they are the part of the same block.
Generally, four spaces are given to indent the statements which are a typical amount of
indentation in python.
Indentation is the most used part of the python language since it declares the block of
code. All the statements of one block are intended at the same level indentation. We will
see how the actual indentation takes place in decision making and other stuff in python.
14
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.
The if-else statement provides an else block combined with the if statement which is
executed in the false case of the condition.
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.
The elif statement works like an if-else-if ladder statement in C. It must be succeeded by
an if statement.
15
Chapter – 2
Generative AI
2.1 About AI
Artificial Intelligence (AI) refers to the simulation of human intelligence in machines that
are programmed to think, learn, and adapt. AI systems are designed to perform tasks that
typically require human intelligence, such as visual perception, speech recognition,
decision-making, and language translation. The field of AI has seen rapid advancements,
especially in recent years, and has become a cornerstone of modern technology. However,
AI is not a completely new concept. Since the early 1000s, AI has been gradually
integrated into various aspects of our daily lives, often without us even realizing it. For
instance, search engines use AI to provide search suggestions based on user behaviour,
translating text between languages in real-time, and even recommending products or
content based on past interactions. These early implementations of AI laid the foundation
for the more sophisticated and advanced AI systems we see today, such as those used in
autonomous vehicles, virtual assistants, and, most recently, Generative AI.
2.1 Generative AI
Generative AI is a subset of artificial intelligence focused on creating new content, ideas,
or solutions by leveraging existing data. Unlike traditional AI systems, which are
16
primarily designed to recognize patterns or make decisions based on predefined rules or
past data, generative AI models are capable of producing novel outputs that resemble the
patterns found in the data they were trained on.
At the core of generative AI are complex models such as Generative Adversarial
Networks (GANs), Variational Autoencoders (VAEs), and Transformer-based
architectures like GPT (Generative Pretrained Transformer). These models are trained on
large datasets and learn to understand the underlying structure of the data. Once trained,
they can generate new content that is often indistinguishable from human-created content.
This includes generating realistic images, composing music, writing text, and even
creating complex designs. or instance, GPT models, like the one used by OpenAI, are
capable of generating
coherent and contextually relevant text based on a given prompt. This has numerous
applications, from writing articles and creating marketing content to answering questions
and assisting with coding tasks. Similarly, GANs have been used to create highly realistic
images of faces, scenes, and objects that do not exist in reality.
Generative AI has profound implications across various industries. In the creative arts, it
can assist in generating new artistic works or providing inspiration. In healthcare, it can
be used to create synthetic data for training models without compromising patient
privacy. In design and engineering, generative AI can explore countless design variations,
helping to innovate faster and more efficiently.
Despite its potential, generative AI also raises ethical and practical concerns. The ability
to create realistic fake content, such as deepfakes, poses significant challenges in areas
like security, privacy, and the spread of misinformation. Therefore, while generative AI
offers exciting possibilities, it also necessitates careful consideration and responsible use.
In conclusion, generative AI represents a significant leap forward in the field of artificial
intelligence, enabling machines to not only learn from data but also to create new,
innovative outputs. Its applications are vast and varied, promising to reshape industries
and creative processes alike.
17
predict the word "blue" as the next word. Language models are crucial in various
applications, such as text generation, speech recognition, machine translation, and more.
LLMs have transformed NLP, enabling applications that were previously unimaginable.
They can generate coherent essays, engage in complex conversations, translate languages
with high accuracy, and even assist in creative writing. However, their vast size and
capability also come with challenges, including the need for massive computational
18
resources and the potential for generating biased or misleading content.
In summary, the transition from traditional neural network language models to large
language models marks a significant milestone in AI and NLP, paving the way for more
advanced and capable systems that can understand and generate human language with
unprecedented accuracy and depth.
Chapter – 3
GUI
Graphical User Interface (GUI) programming in Python allows developers to create user-
friendly interfaces for applications. Python provides several libraries and frameworks to
build GUIs, each with its own strengths and use cases.
A Graphical User Interface (GUI) is a visual interface that allows users to interact with
electronic devices through graphical elements like windows, buttons, icons, and text.
GUIs make it easier for users to interact with software by providing a more intuitive and
visually engaging way to control applications, compared to text-based interfaces. GUIs
are a fundamental aspect of modern software, enhancing user experience by making33
complex tasks more accessible.
Tkinter is a standard Python library used to create GUI applications. It provides a simple
way to design and implement a wide range of GUI elements, such as buttons, labels, text
boxes, menus, and more. Tkinter is often chosen for GUI development in Python due to
its ease of use, cross-platform compatibility, and integration with Python’s extensive
libraries.
Tkinter is built on top of the Tcl/Tk GUI toolkit, a well-established and widely used
toolkit for creating GUIs. It abstracts many of the complexities involved in GUI
programming, allowing developers to focus more on the design and functionality of their
applications rather than on the intricacies of GUI implementation. With Tkinter, even
19
beginners can quickly create functional and visually appealing GUI applications in
Python.
In summary, Tkinter serves as a powerful and accessible tool for developing GUI
applications in Python, providing the essential features needed to build interactive and
user-friendly software.
20
allows you to add more functionality to your applications, such as data visualization,
database management, or even web-based features.
3.4.1 Code:
21
Figure 3.1 Code for login page using tkinter
3.4.2 Output
Chapter 5
PROJECT UNDERTAKEN
27
5.1.6 Code
28
5.1.7 Output
5.2 CHATBOT
5.2.1 Chatbot Application :-
Theory:- below is the detailed explanation of the chatbot application project
5.2.1.1 Imports and Setup
• tkinter and tkinter.scrolledtext: Used to create the GUI application
• requests: Used to make HTTP requests to the Hugging Face API.
• API_URL: The URL endpoint for the Hugging Face BERT model
• headers
Contains the authorization token needed to access the API. Replace
"hf_wiHvXMOuzIypWbtsPnheQEmoSMvdqrzuxqO" with my actual token.
5.2.1.2. Functions:
• This function takes a payload (a dictionary with input data) and sends a POST request to
the Hugging Face API.26
• It returns the JSON response from the API.
• This function retrieves the user's question and context from the text fields
• It sends these inputs to the query function to get a response from the API.
29
• The response is displayed in the response text area of the GUI.
• If there is a KeyError (e.g., if the API response doesn't contain the expected answer
key),
it displays an error message.
5.2.1.3. GUI Setup:
• root = tk.Tk(): Initializes the main window of the application.
• root.title("GenAI QUES & ANS"): Sets the title of the window
• A label (context_label) and a scrolled text widget (context_entry) for the user to input
the context.
• pack() methods are used to add these widgets to the window
• A label (question_label) and a scrolled text widget (question_entry) for the user to input
the question.
• These widgets are also added to the window using pack().
• A button (get_response_button) that triggers the get_response function when clicked.
• Added to the window using pack().
• A label (response_label) and a scrolled text widget (response_text) for displaying the
response from the API.
• The response text area is initially disabled to prevent user edits.
5.2.1.4. Main Loop:-
• root.mainloop():
Starts the Tkinter event loop, which keeps the window
5.2.1.5 Code
30
Figure 5.3 Code of Chatbot
31
5.2.1.6 Output
32
CONCLUSION
This report captures the key learning outcomes from the Summer Industrial Training
Program, which covered essential areas like Python, Streamlit, Tkinter, Generative AI,
and API Integration. Each chapter of the report offers a focused exploration of these
technologies, enhancing my understanding of modern software development practices.
The training began with an introduction to Generative AI, laying the groundwork for
understanding advanced AI models and their applications. The transition from Neural
Network Language Models (NNLM) to Large Language Models (LLM) was discussed,
highlighting the rapid growth in model complexity.
Practical skills were developed through chapters on Tkinter and Streamlit, where I
created interactive applications like a Flipkart login page and a text-to-image generator.
These chapters provided hands-on experience in setting up tools, integrating libraries, and
deploying applications.
The report also delves into API Integration, particularly with Hugging Face models,
demonstrating how pre-trained models can enhance application functionality. This was
exemplified by the development of a Chat Bot, showcasing the practical use of APIs.
Finally, the report covers real-world projects that applied the theoretical knowledge
gained, reinforcing the importance of integrating various technologies to create functional
applications.
In summary, this training significantly advanced my technical skills, providing a solid
foundation for future endeavours in software development. It equipped me with the
knowledge to navigate the complexities of modern tech, preparing me for continued
growth in the field.
33
REFERENCE
34