0% found this document useful (0 votes)
66 views16 pages

Samritha It-2 Report

Uploaded by

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

Samritha It-2 Report

Uploaded by

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

ABSTRACT

During my internship at Sync Interns, I engaged in a diverse range of projects aimed at honing my
Python programming skills and exploring various applications of Python in real-world scenarios. The
internship encompassed four main tasks: building an Alarm Clock, implementing OTP Verification,
creating a URL Shortener, and developing a Chatbot.

The Alarm Clock project involved utilizing Python's datetime and tkinter libraries to construct a
functional alarm clock with a user-friendly interface. This project enhanced my understanding of GUI
development and time manipulation in Python, laying a foundation for future endeavors in desktop
application development.

In the OTP Verification task, I delved into generating random 6-digit numbers, sending emails
programmatically, and validating user input. This project provided insights into user authentication
processes and email handling in Python applications, contributing to my understanding of secure
user interactions in software systems.

The URL Shortener project aimed to replicate the functionality of popular online URL shortening
services using Python libraries and APIs. Through this task, I gained experience in working with
external APIs, implementing algorithms for data transformation, and deploying web services,
deepening my knowledge of web development and API integration.

Lastly, the Chatbot project involved a comprehensive nine-step process, including determining
chatbot type, understanding user needs, and designing a chatbot with a distinct personality. This
project allowed me to explore natural language processing techniques, user-centric design principles,
and performance optimization strategies, equipping me with skills relevant to conversational AI
development and user experience design.

Overall, my internship at Sync Interns provided valuable hands-on experience in Python development
and exposed me to diverse applications of the language in software development. Through these
projects, I acquired practical skills, deepened my understanding of software engineering principles,
and gained insights into emerging technologies, positioning myself for success in the dynamic field of
software development.
TASK DESCRIPTION

TASK 1 : ALARM CLOCK USING PYTHON


Objective:
The objective of our project is to implement an alarm clock using Python. Python consists of
some very innovative libraries such as datetime and tkinter which help us to build the project
using the current date and time as well as to provide a user interface to set the alarm
according to the requirement in 24-hour format.
steps to build an Alarm Clock program in Python:

• Importing all the libraries and modules required


• Putting forward a while loop which takes the argument of the time, the user
wants to set the alarm on and automatically breaks when the time is up, with
sound
• Create a display window for user input.

1. Importing all the libraries and modules:


• Tkinter module belongs to a standard library of GUI in Python. It helps us to
create a dialog box with any information that we want to provide or get from the
users.

• Datetime and time modules in python help us to work with the dates and time of
the current day when the user is operating python and to manipulate it too.

• Winsound module provides access to the basic sound playing machinery


provided by Windows platforms. This is useful to generate the sound
immediately when a function is called.

2. Create a while loop:

• Define a function named as alarm() which takes the argument of


(set_alarm_timer).It contains a while loop with a Boolean function True which
makes the program automatic to work.

• time.sleep(1) halts the execution of the further commands given until we get the
time value from the user later in the code and returns the background thread of
the clock time going on at a regular interval.

• Get the current time using current_time which takes the argument
of datetime.datetime.now().

• now is used to print the time and date is used to print the current date by string
conversion using strftime().
• Define another function here named actual_time() which takes in the user value
for setting the alarm in the string format. The same argument of
(set_alarm_timer) as alarm before to execute the while loop which we further use
while making GUI.

• If loop suggests that if the user input time set_alarm_timer matches with the
while loop ongoing time now, the message is printed as” Time to Wake up”.

• winsound.SND_ASYNC plays the system generated sound as soon the condition


satisfies, acting as a reminder for the alarm clock.

3, Creating GUI using tkinter:

• To Initialize tkinter, we pass a command under the name clock as Tk().

• The dialog box has the title as DataFlair Alarm Clock with a geometry of
(400*200). We pass on the heading to mention the time format for 24 hours
using time_format.

• The second heading is given above the user input boxes for the labeling to be
“Hour Min Sec” using addTime.

• Just to make the dialog box look funkier, adding another label as “when to wake
you up” using setYourAlarm.

• Finally make the input boxes such as hourTime, minTime, and secTime which
takes the entry of the time the user wants to set the alarm on in 24-hour format.

• Submit takes the command of the defined function actual_time and executes the
clock as it acts as a set button to start the program.

• Clock.mainloop() is the basic and the last command was given to compile all the
previous commands with their basic settings of color, font, width, axis, etc. and
displays the window as soon as the program is run.

OUTPUT
CONCEPTS USED IN TASK 1
Graphical User Interface (GUI) allows users to interact with software applications through
graphical elements such as windows, buttons, menus, and dialog boxes. In Python, `Tkinter`
is a standard GUI toolkit that comes pre-installed with most Python distributions. It provides
a simple and easy-to-use interface for creating GUI applications.

Here's a detailed explanation of GUI and `Tkinter`:

Graphical User Interface (GUI):


A Graphical User Interface (GUI) is a visual interface that allows users to interact with
software applications using graphical elements rather than text-based commands. GUIs
provide a more intuitive and user-friendly way of interacting with applications, making them
suitable for a wide range of users, including those who may not be familiar with command-
line interfaces.

Key components of GUI include:


- Windows: Containers for displaying application content and user interface elements.
- Widgets: Graphical elements such as buttons, labels, text fields, checkboxes, radio buttons,
sliders, etc., used to interact with the application.
- Layout Managers: Mechanisms for arranging widgets within windows or other containers.
- Event Handling: Handling user interactions such as mouse clicks, keyboard input, and
window resizing.

Tkinter:
`Tkinter` is the standard GUI toolkit for Python. It provides a set of Python wrappers for the
Tk GUI toolkit, which is a cross-platform GUI toolkit used by many programming languages,
including Tcl, Perl, Ruby, and others.

Key features of Tkinter include:


- Ease of Use: `Tkinter` provides a simple and easy-to-use interface for creating GUI
applications in Python. It has a relatively low learning curve, making it suitable for beginners.
- Cross-Platform: Tkinter applications can run on various platforms, including Windows,
macOS, and Linux, without modification.
- Rich Widget Set: Tkinter provides a rich set of built-in widgets for creating common GUI
elements such as buttons, labels, entry fields, text widgets, listboxes, etc.
- Customization: Widgets in Tkinter can be customized using various options and
configurations to suit the requirements of the application.
- Event-Driven Programming: Tkinter applications are event-driven, meaning they respond to
user actions (e.g., mouse clicks, keyboard input) by triggering event handlers.

Tkinter Workflow:
Creating a GUI application with Tkinter typically involves the following steps:
1. Importing Tkinter: Import the `tkinter` module.
2. Creating a Root Window: Create a `Tk()` object, which represents the main window of the
application.
3. Adding Widgets: Create and add widgets (e.g., buttons, labels) to the root window or other
containers (e.g., frames).
4. Configuring Widgets: Customize the appearance and behavior of widgets using widget
options.
5. Layout Management: Use layout managers (e.g., `pack()`, `grid()`, `place()`) to arrange
widgets within containers.
6. Event Handling: Bind event handlers to widgets to respond to user interactions.
7. Running the Event Loop: Call the `mainloop()` method on the root window to start the
event loop, which listens for user events and updates the GUI accordingly.
Overall, Tkinter provides a powerful yet straightforward way to create GUI applications in
Python, making it suitable for a wide range of projects, from simple utilities to complex
desktop applications.
TASK 2 : OTP VERIFICATION USING PYTHON
Objective:
OTP Verification is the process of verifying a user by sending a unique password so that the
user can be verified before completing a registration or payment process. Most of the time,
we get an OTP when we make an online payment, or when we forget our password, or when
creating an account on any online platform. Thus, the sole purpose of an OTP is to verify the
identity of a user by sending a unique password.
OTP verification using Python by following the steps:

1. First, create a 6-digit random number


2. Then store the number in a variable
3. Then we need to write a program to send emails
4. When sending email, we need to use OTP as a message
5. Finally, we need to request two user inputs; first for the user’s email and then for the
OTP that the user has received.

1. Import Libraries: The script begins by importing the necessary libraries. `smtplib` is used
for sending emails, and `random` is used for generating random numbers.

2. Generate OTP: A 6-digit OTP is generated using the `random.randint()` function. The OTP
is stored in a variable named `otp`.

3. Email Configurations: Email configurations such as sender's email address, sender's


password, SMTP server, and SMTP port are defined. These configurations are required to
send emails.

4. Send OTP Function: A function named `send_otp()` is defined to send the OTP via email.
It takes two parameters: `receiver_email` (the email address of the recipient) and `otp` (the
OTP to be sent). Inside the function, an email message is composed with the OTP as the
body, and then sent using the configured SMTP server.

5. Main Function: The `main()` function is defined to execute the main logic of the script. It
performs the following steps:
- Prompts the user to enter their email address.
- Calls the `send_otp()` function to send the OTP to the user's email address.
- Prints a message confirming that the OTP has been sent.
- Prompts the user to enter the OTP they received.
- Compares the entered OTP with the generated OTP to verify if they match.
- Prints a message indicating whether the OTP verification was successful or not.

6. Main Execution: The script checks if it's being run directly (`if __name__ ==
"__main__":`) and if so, calls the `main()` function to start the OTP verification process.

Overall, the script generates a random OTP, sends it to the user's email address, prompts the
user to enter the received OTP, and verifies if the entered OTP matches the generated OTP.

OUTPUT
CONCEPTS USED IN TASK 2:

SMTP Server:
An SMTP server is a computer program or software component that sends emails. It's
responsible for transmitting outgoing email messages from an email client to the recipient's
email server. When you send an email from your email client (such as Gmail, Outlook, or a
custom Python script), the email client connects to an SMTP server to deliver the message.
In the context of OTP verification using Python, you would typically use an SMTP server to
send an email containing the OTP (One-Time Password) to the user's email address. This
SMTP server could be provided by your email service provider (such as Gmail's SMTP server
or Outlook's SMTP server), or you could use a third-party SMTP service.

SMTP Port:
Ports are virtual endpoints for communication in networking. In the case of SMTP, the default
port used for sending emails is port 25. However, due to security reasons and ISP restrictions,
port 25 might be blocked for outgoing connections. In such cases, alternative ports like 587
(submission) or 465 (SMTPS) are commonly used.
- Port 587 (Submission): This port is commonly used for email submission by email clients to
an email server. It supports encryption (STARTTLS) for secure communication.
- Port 465 (SMTPS): This port is used for SMTP over SSL (SMTPS), providing encryption
for secure email transmission.
In the context of OTP verification using Python, you would specify the SMTP server address
(e.g., smtp.gmail.com for Gmail) and the SMTP port (e.g., 587 for submission or 465 for
SMTPS) in your Python code when configuring the SMTP connection to send the OTP email.

Here's a brief overview of how you would typically use SMTP server and port in Python for
OTP verification:
1. Configure the SMTP server address (e.g., smtp.gmail.com) and port (e.g., 587 or 465).
2. Establish a connection to the SMTP server using the smtplib module in Python.
3. Authenticate to the SMTP server using your email credentials (username and password).
4. Compose the email message containing the OTP and send it to the user's email address.
5. Close the SMTP connection after sending the email.

This process ensures that the OTP is securely delivered to the user's email address through the
SMTP server and port specified in your Python code.
TASK 3 : URL SHORTENER USING PYTHON

Objective:

The objective of this code is to take a long URL as input from the user, shorten it using the
TinyURL shortening service provided by the pyshorteners library, and then display the
shortened URL to the user. This can be useful in scenarios where you need to share a concise
version of a long URL, such as in social media posts or SMS messages.
1, import the `pyshorteners` Library:
pyshorteners simplifies the process of URL shortening in Python applications by providing a
convenient and straightforward interface to various URL shortening services, allowing
developers to integrate URL shortening functionalities seamlessly into their projects.import
pyshorteners
This line imports the `pyshorteners` library, which provides functionalities to interact with
various URL shortening services.

2. Get the Long URL from the User:


long_url = input("Enter the URL to shorten: ")
This line prompts the user to enter the long URL that they want to shorten. The `input()`
function waits for the user to input a value, and the entered URL is stored in the variable
`long_url`.

3. Initialize a URL Shortener Object:


type_tiny = pyshorteners.Shortener()
pyshorteners supports various URL shortening services, including but not limited to:
TinyURL
Bitly
is.gd
AdFly
and more...
This line creates an instance of the `Shortener` class provided by the `pyshorteners` library.
This object will be used to interact with URL shortening services.

4. Shorten the URL:


short_url = type_tiny.tinyurl.short(long_url)
This line invokes the `short()` method on the `type_tiny` object, specifying the TinyURL
shortening service as the target. It passes the long URL (`long_url`) as an argument to this
method. The method returns the shortened URL, which is stored in the variable `short_url`.

5. Print the Shortened URL:


print("The Shortened URL is: " + short_url)
This line prints out a message indicating the shortened URL to the console. It concatenates
the message string with the `short_url` variable, displaying the shortened URL generated by
the TinyURL service.
Overall, this code snippet allows users to input a long URL, which is then shortened using the
TinyURL service through the `pyshorteners` library. The shortened URL is then displayed to
the user.

OUTPUT
CONCEPTS USED IN TASK 3

URL Shortener, as the name suggests, is a service to help to reduce the length of the URL so
that it can be shared easily on platforms like Twitter, where number of characters is an issue.
There are so many URL Shorteners available in the market today, that will definitely help you
out to solve the purpose. We will be discussing API implementation of Bitly URL Shortener
and implementation of a Python module pyshorteners. This is basically a library in Python
that provides implementation of few popular URL Shorteners.
Bitly: Bitly provides a platform to shorten URL’s, share them and keep a track of the activity
on the shortened URL. Before starting using Bitly API, you first need to signup on the site to
get an API Key. This is very important to get access to the API to use it for programming.
Pros of URL Shorteners:
Attractive: Using URL Shorteners on Online Social Media exactly started or we can say
became popular due to Twitter. Due to character Limit on Twitter, it was difficult for users to
share long links. This was the only reason that made these URL Shortening services more
popular in a short span of time. With the advent of these services, User was able to share as
much as long URL on Twitter by simply shortening the URL. Thus making the post more
attractive and appealing to the audience/ followers.
Link Analytics: Now a days majority of URL Shortening services provide a new feature,
Tracking. For example, if we consider the case of Bitly, it provides Link Tracking feature.
This feature enables the user to track the user activity-number of clicks, geographic location
of the user who clicked the link on the shortened URL. This helps user to analyze the
popularity of the link. Below is the sample snapshot of Link Analytics report of two links that
were shortened using Bitly.

Cons of URL Shorteners:


Abuse: URL Shortening services are a great source for spammers and hackers to get a hold of
victim computer. They share a link and fool user into clicking the link. Thus, either setting up
the virus in the victim computer or getting important user credentials through fake URL. This
definitely breaches privacy and security of the user. It is very important to keep following
points in mind:
Always check the link before clicking it. The easiest way is just to place your cursor on the
link and you will get an idea where shortened URL is exactly pointing.
Do not click a link shared by unknown person. If a link is shared by email, read the email
carefully for the signs of spammed email. If not a spam email, you can check where link
directs and then click on the link.
Do not share your important credentials like bank details, social media user id-password on
such shared links.
Due to such abuse of URL shortening services, many have been discontinued. It is very
important and difficult to keep domain spam free.
TASK 4 : CHATBOT USING PYTHON
Objective

The objective of the provided Python code for a simple text-based chatbot is to demonstrate
the implementation of a basic conversational agent that can engage in a dialogue with users.
Here are the key objectives of this task:

1. Demonstrate Interaction: The chatbot allows users to interact with it by inputting


messages. It responds to user inputs with predefined responses, simulating a conversation
between the user and the chatbot.

2. Provide Predefined Responses: The chatbot provides predefined responses for specific user
inputs such as greetings ("hi"), inquiries about its well-being ("how are you"), and farewells
("bye"). This allows the chatbot to maintain a basic level of engagement with users.
responses = {
"hi": ["Hello!", "Hi there!", "Hey!"],
"how are you": ["I'm good, thank you!", "Doing well, thanks!", "I'm fine, how about
you?"],
"bye": ["Goodbye!", "Bye!", "See you later!"],
"default": ["Sorry, I didn't understand that.", "Can you please rephrase?", "I'm not sure I
follow."],
}

3. Handle Default Responses: The chatbot includes a default response for inputs that do not
match any predefined responses. This ensures that the chatbot can handle a wider range of
user inputs and provide some form of response even if it doesn't understand the input.
def generate_response(user_input):
user_input = user_input.lower()
if user_input in responses:
return random.choice(responses[user_input])
else:
return random.choice(responses["default"])

4. Demonstrate Basic Programming Concepts: The code demonstrates the use of Python
programming concepts such as dictionaries, functions, loops, conditionals, and user
input/output. It serves as an educational example for beginners learning Python
programming.

6. Provide a Starting Point for Expansion: While the chatbot is simple in its current
form, it can be expanded upon by adding more predefined responses, improving
response logic, integrating natural language processing (NLP) techniques, and
incorporating more sophisticated conversation handling capabilities. The code
provides a starting point for further development and experimentation with chatbot
technologies.
def main():
print("Welcome to the Simple Chatbot!")
print("You can start chatting. Type 'bye' to exit.")

while True:
user_input = input("You: ")
if user_input.lower() == 'bye':
print(generate_response(user_input))
break
else:
print("Bot:", generate_response(user_input))

Overall, the objective of this task is to introduce the concept of chatbots and showcase a basic
implementation using Python, laying the foundation for more advanced chatbot development
in the future.
OUTPUT :
CONCEPTS USED IN TASK 4
Natural Language Processing (NLP) is a field of artificial intelligence (AI) concerned with
the interaction between computers and humans through natural language. In the context of
chatbots, NLP plays a crucial role in understanding and generating human-like responses to
user inputs. Here's a detailed explanation of NLP concepts used in chatbots using Python:
1. Text Preprocessing:
Text preprocessing involves cleaning and preparing text data before it can be used for NLP
tasks. Common preprocessing steps include:
- Tokenization: Splitting text into individual words or tokens.
- Lowercasing: Converting all text to lowercase to standardize the text.
- Removing Punctuation: Removing punctuation marks from text.
- Removing Stopwords: Removing common words (e.g., "the", "is", "and") that don't
contribute much to the meaning of the text.
- Lemmatization/Stemming: Converting words to their base or root form to reduce
inflectional forms.

2. Text Representation:
To process text data, it needs to be converted into a numerical format that machine learning
models can understand. Common text representation techniques include:
- Bag of Words (BoW): Representing text as a collection of word counts or frequencies.
- TF-IDF (Term Frequency-Inverse Document Frequency): Assigning weights to words based
on their frequency in a document relative to their frequency in the corpus.
- Word Embeddings: Representing words as dense vectors in a continuous vector space,
typically learned from large text corpora using techniques like Word2Vec, GloVe, or FastText.

3. Intent Recognition:
Intent recognition involves identifying the purpose or intention behind a user's input. This is
crucial for understanding what action the chatbot should take. Techniques for intent
recognition include:
- Rule-Based Approaches: Defining rules or patterns to match user inputs with predefined
intents.
- Machine Learning Approaches: Training classification models (e.g., SVM, Random Forest,
Neural Networks) on labeled examples to predict the intent of user inputs.
- Pretrained Language Models: Using pretrained language models like BERT, GPT, or LSTM
networks to extract contextual information from user inputs and infer intents.
4. Named Entity Recognition (NER):
NER involves identifying and classifying named entities (e.g., people, organizations,
locations) mentioned in text. This is useful for extracting relevant information from user
inputs. Techniques for NER include:
- Rule-Based Approaches: Defining rules or patterns to identify named entities based on text
patterns and context.
- Machine Learning Approaches: Training sequence labeling models (e.g., CRF, LSTM) on
annotated data to classify words or tokens as named entities or non-entities.

5. Dialogue Management:
Dialogue management involves managing the flow of conversation between the user and the
chatbot. This includes keeping track of context, handling user inputs, generating responses,
and maintaining the overall coherence of the conversation. Techniques for dialogue
management include:
- Finite-State Machines (FSM): Modeling dialogue flow as a set of states and transitions
between states based on user inputs.
- Reinforcement Learning (RL): Training dialogue policies to maximize long-term rewards
(e.g., user satisfaction) through interaction with users.
- Rule-Based Approaches: Defining rules or scripts to handle different dialogue scenarios and
generate appropriate responses.

6. Response Generation:
Response generation involves generating human-like responses to user inputs. This can be
done using various techniques, including:
- Template-Based Responses: Using predefined templates or patterns to generate responses
based on the structure of the user input.
- Rule-Based Approaches: Defining rules or scripts to generate responses based on specific
conditions or context.
- Machine Learning Approaches: Training generative models (e.g., seq2seq models, language
models) on large text corpora to generate responses that are contextually relevant and
coherent.

7. Evaluation and Iteration:


Once a chatbot is built, it needs to be evaluated to assess its performance and effectiveness.
Evaluation metrics may include accuracy, precision, recall, F1-score, and user satisfaction
ratings. Based on the evaluation results, the chatbot can be iteratively improved by refining
its algorithms, adding new features, or collecting more data.

In Python, there are several libraries and frameworks available for implementing NLP tasks
in chatbots, including NLTK, spaCy, scikit-learn, TensorFlow, and PyTorch. These libraries
provide tools and APIs for text preprocessing, feature extraction, model training, and
evaluation, making it easier to build and deploy chatbots with NLP capabilities.

CONCLUSION
In conclusion, the internship at Sync Interns provided a comprehensive learning experience in
Python development, encompassing a variety of practical projects aimed at enhancing skills
and exploring real-world applications.
The projects undertaken, including building an Alarm Clock, implementing OTP Verification,
creating a URL Shortener, and developing a Chatbot, allowed for hands-on exploration of
different aspects of Python programming and its diverse capabilities.
Through building an Alarm Clock, I gained insights into GUI development using tkinter and
handling date and time functionalities using the datetime library.
The OTP Verification project provided a deeper understanding of user authentication
processes and email handling in Python applications, crucial for ensuring secure interactions
in software systems.
Creating a URL Shortener with Python exposed me to working with external APIs and
manipulating strings efficiently, demonstrating the power of Python in web development
tasks.
Finally, developing a Chatbot involved a comprehensive process, from understanding user
needs to designing a chatbot with a distinct personality and optimizing its performance,
providing valuable insights into natural language processing and user-centric design
principles.
Overall, the internship not only reinforced fundamental Python concepts but also fostered
creativity and problem-solving skills essential for success in software development. The
projects undertaken serve as a testament to the versatility and practicality of Python in
addressing real-world challenges, and I look forward to applying the skills and knowledge
gained to future endeavors in the field.

You might also like