FSD LAB MANUAL
FSD LAB MANUAL
MANUAL
(R22A0513)
B.TECH
Vision
To be a premier centre for academic excellence and research through innovative
interdisciplinary collaborations and making significant contributions to the
community, organizations, and society as a whole.
Mission
To impart cutting-edge Artificial Intelligence technology in accordance with
industry norms.
To instill in students a desire to conduct research in order to tackle challenging
technical problems for industry.
To develop effective graduates who are responsible for their professional
growth, leadership qualities and are committed to lifelong learning.
Quality Policy
1. Students are advised to come to the laboratory at least 5 minutes before (to starting time), those
who come after 5 minutes will not be allowed into the lab.
2. Plan your task properly much before to the commencement, come prepared to the lab with
the synopsis / program / experiment details.
3. Student shouldenter into the laboratory with:
a. Laboratory observation notes with all the details (Problem statement, Aim, Algorithm, Procedure,
Program, Expected Output, etc.,) filled in for the lab session.
b. Laboratory Record updated up to the last session experiments and other utensils (if any) needed in
the lab.
c. Proper Dress code and Identity card.
4. Sign in the laboratory login register, write the TIME-IN, and occupy the computer system allotted
to you by the faculty.
5. Execute your task in the laboratory, and record the results / output in the lab observation
notebook, and get certified by the concerned faculty.
6. All the students should be polite and cooperative with the laboratory staff, must maintain the
discipline and decency in the laboratory.
7. Computer labs are established with sophisticated and high-end branded systems, which should
be utilized properly.
8. Students / Faculty must keep their mobile phones in SWITCHED OFF mode during the lab sessions.
Misuse of the equipment, misbehaviors with the staff and systems etc., will attract severe punishment.
9. Students must take the permission of the faculty in case of any urgency to go out; if anybody found
loitering outside the lab / class without permission during working hours will be treated seriously and
punished appropriately.
10. Students should LOG OFF/ SHUT DOWN the computer system before he/she leaves the lab after
completing the task (experiment) in all aspects. He/she must ensure the system / seat is kept properly.
LAB OBJECTIVES:
LAB OUTCOMES:
Regularity 3Marks
Program written 3Marks
Execution & Result 3Marks
Viva-Voce 3Marks
Dress Code 3Marks
Allocation of Marks for Lab Internal
Total marks for lab internal are 40 Marks as per Autonomous (JNTUH.)
These 40 Marks are distributed as:
Average of Continuous Evaluation marks:15
Marks Lab exam:15 Marks
VIVA:10 Marks
Viva-Voce 10 Marks
Record 10 Marks
CODE:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Online Bookstore</title>
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
line-height: 1.6;
}
header {
background-color: #333;
color: white;
padding: 10px 0;
text-align: center;
}
header .logo h1 {
margin: 0;
}
nav ul {
list-style-type: none;
padding: 0;
}
nav ul li {
display: inline;
margin: 0 15px;
}
nav ul li a {
color: white;
text-decoration: none;
font-size: 1.1em;
}
nav ul li a:hover {
color: #f0a500;
}
section.hero {
background-color: #f4f4f4;
padding: 20px;
text-align: center;
}
section.catalog {
display: flex;
justify-content: space-around;
flex-wrap: wrap;
padding: 20px;
}
section.catalog .book {
width: 30%;
margin-bottom: 20px;
text-align: center;
}
section.catalog .book h3 {
font-size: 1.2em;
margin: 10px 0;
}
section.catalog .book p {
font-size: 1em;
color: #555;
}
section.catalog .book a {
background-color: #333;
color: white;
padding: 10px;
text-decoration: none;
display: inline-block;
margin-top: 10px;
}
section.contact {
padding: 20px;
}
section.contact form {
max-width: 600px;
margin: 0 auto;
}
footer {
background-color: #333;
color: white;
text-align: center;
padding: 10px;
margin-top: 20px;
}
</style>
</head>
<body>
<header>
<div class="logo">
<h1>Online Bookstore</h1>
</div>
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#catalog">Catalog</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</header>
<!-- Hero Section -->
<section id="home" class="hero">
<h2>Welcome to the Best Bookstore!</h2>
<p>Browse and shop from a wide variety of books across all genres.</p>
</section>
<footer>
<p>© 2024 Online Bookstore. All rights reserved.</p>
</footer>
OUTPUT:
EXERCISE PROGRAM:
Week-2. Designing a webpage using CSS Which includes different styles
CODE:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Stylish Webpage</title>
<style>
/* Reset some default styles */
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Arial', sans-serif;
line-height: 1.6;
background-color: #f4f4f9;
color: #333;
}
/* Header styles */
header {
background-color: #333;
color: #fff;
padding: 20px;
text-align: center;
}
header h1 {
font-size: 2.5em;
margin: 0;
font-weight: bold;
}
header nav {
margin-top: 10px;
}
header nav ul {
list-style-type: none;
}
header nav ul li {
display: inline-block;
margin: 0 15px;
}
header nav ul li a {
text-decoration: none;
color: #fff;
font-size: 1.2em;
}
.content-box {
background-color: #fff;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
border-radius: 10px;
padding: 20px;
width: 30%;
text-align: center;
transition: transform 0.3s ease;
}
.content-box:hover {
transform: scale(1.05);
}
.content-box h2 {
color: #333;
font-size: 1.8em;
margin-bottom: 20px;
}
.content-box p {
font-size: 1.1em;
color: #555;
}
.content-box button {
background-color: #333;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
font-size: 1.1em;
margin-top: 20px;
}
.content-box button:hover {
background-color: #f0a500;
}
/* Footer styles */
footer {
background-color: #333;
color: #fff;
text-align: center;
padding: 20px;
margin-top: 40px;
}
footer p {
font-size: 1em;
}
/* Responsive Styles */
@media (max-width: 768px) {
.main-content {
flex-direction: column;
align-items: center;
}
.content-box {
width: 80%;
margin-bottom: 20px;
}
header h1 {
font-size: 2em;
}
header nav ul li {
margin: 0 10px;
}
header nav ul li a {
font-size: 1em;
}
}
/* Button Styles */
.btn-primary {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
font-size: 1.2em;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.btn-primary:hover {
background-color: #45a049;
}
.btn-secondary {
background-color: #f44336;
color: white;
padding: 10px 20px;
font-size: 1.2em;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.btn-secondary:hover {
background-color: #e53935;
}
</style>
</head>
<body>
<header>
<h1>My Stylish Webpage</h1>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</header>
</body>
</html>
OUTPUT:
EXERCISE PROGRAM:
Week-3. Write a JavaScript to implement the following various events.
CODE:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript Events Example</title>
<style>
body {
font-family: Arial, sans-serif;
line-height: 1.6;
background-color: #f4f4f9;
color: #333;
text-align: center;
padding: 20px;
}
button {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
font-size: 1.2em;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #45a049;
}
.input-box {
margin: 10px 0;
padding: 10px;
font-size: 1em;
width: 300px;
border-radius: 5px;
border: 1px solid #ccc;
}
.message {
margin-top: 20px;
font-size: 1.5em;
color: #f44336;
}
</style>
</head>
<body>
<!-- Input box that triggers focus and blur events -->
<input type="text" id="focusInput" class="input-box" placeholder="Focus and blur events" />
<script>
// Click event on button
document.getElementById("clickButton").addEventListener("click", function() {
document.getElementById("eventMessage").textContent = "Button Clicked!";
});
</body>
</html>
OUTPUT:
EXERCISE PROGRAM:
Week-4. Write a program to create and Build a Password Strength Check using JQuery.
CODE:
To create a Password Strength Checker using jQuery, we will build a program that evaluates the strength of a
password based on different criteria such as:
Here's a step-by-step guide and code implementation for a Password Strength Checker using jQuery:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Password Strength Checker</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
background-color: #f4f4f9;
}
h2 {
text-align: center;
}
.password-container {
width: 300px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
.password-container input {
width: 100%;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
}
.password-strength {
height: 10px;
border-radius: 5px;
transition: width 0.4s ease;
}
.strength-weak {
background-color: red;
}
.strength-medium {
background-color: orange;
}
.strength-strong {
background-color: green;
}
.strength-message {
font-size: 14px;
text-align: center;
margin-top: 5px;
}
.strength-message span {
font-weight: bold;
}
</style>
</head>
<body>
<div class="password-container">
<input type="password" id="password" placeholder="Enter your password" />
<div id="passwordStrength" class="password-strength"></div>
<div id="strengthMessage" class="strength-message"></div>
</div>
<script>
$(document).ready(function() {
$('#password').on('input', function() {
var password = $(this).val();
var strength = 0;
var strengthMessage = '';
</body>
</html>
OUTPUT:
EXERCISE PROGRAM:
Week-5. Write a program to create and Build a star rating system using JQuery
CODE:
Steps:
.rating {
font-size: 40px;
direction: rtl; /* Makes it easier to handle clicks from right to left */
display: inline-block;
}
.rating span {
cursor: pointer;
color: #ccc; /* Empty stars color */
transition: color 0.3s ease;
}
.rating span.filled {
color: gold; /* Filled stars color */
}
.rating span:hover,
.rating span:hover ~ span {
color: gold; /* Hover effect */
}
.rating-result {
font-size: 18px;
margin-top: 20px;
font-weight: bold;
color: #333;
}
</style>
</head>
<body>
<div class="rating-result">
Rating: <span id="ratingValue">0</span> / 5
</div>
<script>
$(document).ready(function() {
let currentRating = 0;
</body>
</html>
OUTPUT:
EXERCISE PROGRAM:
Week-6. Write a program for sending request to a server by using AJAX.
To send a request to a server using AJAX, we can use JavaScript (along with the jQuery library) to send HTTP
requests like GET, POST, or other methods. AJAX allows us to send data to a server and receive a response
reloading the webpage.
Below is a simple example of sending a request to the server using AJAX with jQuery:
In this example, we'll send a GET request to a server, fetch some data, and display the result on the page.
h2 {
text-align: center;
}
#response {
font-size: 18px;
margin-top: 20px;
padding: 10px;
border: 1px solid #ddd;
background-color: #f9f9f9;
}
.loading {
color: #888;
}
</style>
</head>
<body>
<script>
$(document).ready(function() {
// Handle the button click to send the GET request
$('#getRequestButton').on('click', function() {
// Change the response area to indicate loading
$('#response').text('Loading...');
</body>
</html>
OUTPUT:
EXERCISE PROGRAM:
Week-7. Develop an Angular JS application that displays a list of shopping items. Allow users
to add and remove items from the list using directives and controllers. Note: The default
values of items may be included in the program
To develop an AngularJS application that displays a list of shopping items and allows users to add and remove
items, we'll need to create a simple AngularJS app with the following features:
Steps:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shopping List App</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
background-color: #f9f9f9;
}
h2 {
text-align: center;
color: #4CAF50;
}
.shopping-list {
max-width: 500px;
margin: 0 auto;
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.shopping-list input[type="text"] {
width: 80%;
padding: 8px;
font-size: 16px;
border-radius: 4px;
border: 1px solid #ccc;
margin-right: 10px;
}
.shopping-list button {
padding: 8px 16px;
font-size: 16px;
border: none;
border-radius: 4px;
background-color: #4CAF50;
color: white;
cursor: pointer;
}
.shopping-list button:hover {
background-color: #45a049;
}
.item {
display: flex;
justify-content: space-between;
align-items: center;
margin: 10px 0;
}
.item button {
background-color: #f44336;
border: none;
color: white;
font-size: 16px;
cursor: pointer;
}
.item button:hover {
background-color: #e53935;
}
</style>
</head>
<body ng-app="shoppingApp" ng-controller="shoppingCtrl">
<h2>Shopping List</h2>
<div class="shopping-list">
<input type="text" ng-model="newItem" placeholder="Enter item" />
<button ng-click="addItem()">Add Item</button>
<div ng-if="shoppingList.length > 0">
<h3>Items:</h3>
<ul>
<li ng-repeat="item in shoppingList">
<div class="item">
<span>{{ item }}</span>
<button ng-click="removeItem($index)">Remove</button>
</div>
</li>
</ul>
</div>
<script>
// AngularJS Application
var app = angular.module("shoppingApp", []);
</body>
</html>
OUTPUT:
EXERCISE PROGRAM:
Week-8. Write a program to create a simple calculator Application using React JS
Creating a simple calculator application using React JS involves using React components, managing state, and
handling events like button clicks. Below is a step-by-step guide to creating a calculator app in React.
Steps:
1. Set up React environment (You can use tools like Create React App to set up a React project).
2. Create components: We'll use one component for the entire calculator.
3. Manage state: We need to keep track of the current input, the operation to perform, and the result.
4. Handle events: Handle button clicks for numbers and operations.
If you haven't already created a React app, you can do so by running the following command:
function App() {
// State to store the current value, operation, and previous value
const [currentInput, setCurrentInput] = useState('');
const [previousInput, setPreviousInput] = useState('');
const [operation, setOperation] = useState('');
// Set the result to the current input and clear operation and previous input
setCurrentInput(result.toString());
setPreviousInput('');
setOperation('');
}
};
You can add some basic styles for your calculator to make it look neat:
.calculator {
width: 260px;
margin: 100px auto;
background-color: #f4f4f4;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.display {
text-align: right;
margin-bottom: 20px;
}
.previous-input {
font-size: 16px;
color: #888;
}
.current-input {
font-size: 32px;
font-weight: bold;
}
.buttons button {
width: 50px;
height: 50px;
margin: 5px;
font-size: 18px;
border: 1px solid #ccc;
background-color: #fff;
cursor: pointer;
border-radius: 5px;
}
.buttons button:hover {
background-color: #f0f0f0;
}
.buttons button:active {
background-color: #ddd;
}
How to Run the Application:
OUTPUT:
EXERCISE PROGRAM:
Week-9. Write a program to create a voting application using React JS.
Creating a voting application using React JS involves several key steps: setting up the project, creating the
components, managing state, and displaying the results. Here's how you can build a simple voting application:
To get started, you'll need to create a React app. If you don’t have create-react-app installed, you can install it and
set up your project:
2. Create Components
3. App.js
Here we will manage the state of the voting options and the number of votes for each option. We will also handle
the logic for voting and displaying results.
function App() {
const [votes, setVotes] = useState({
option1: 0,
option2: 0,
option3: 0,
});
4. VoteOptions.js
This component will display the voting options and allow the user to vote.
5. Result.js
return (
<div>
<h2>Results</h2>
<p>Option 1: {votes.option1} votes ({percentage(votes.option1)}%)</p>
<p>Option 2: {votes.option2} votes ({percentage(votes.option2)}%)</p>
<p>Option 3: {votes.option3} votes ({percentage(votes.option3)}%)</p>
<p>Total Votes: {totalVotes}</p>
</div>
);
}
6. Styling (optional)
To make the app look better, you can add some simple styles in App.css.
.App {
text-align: center;
padding: 20px;
}
button {
margin: 5px;
padding: 10px;
font-size: 16px;
}
h1 {
color: #333;
}
h2 {
color: #444;
}
Once you have set up the components and styles, you can run the app using:
npm start
The application will display three voting options and allow users to vote. After a vote is cast, the results will be
displayed with the percentage of votes for each option.
OUTPUT:
EXERCISE PROGRAM:
Week-10. Write a server side program for Accessing MongoDB from Node.js.
To access MongoDB from Node.js, you will need to set up a Node.js application that communicates with a
MongoDB database using the mongoose package, which provides a higher-level API to interact with MongoDB.
Below are the steps to set up a server-side Node.js program to access MongoDB:
mkdir node-mongo-app
cd node-mongo-app
npm init -y
2. Install Dependencies
You will need to install express (to create the server) and mongoose (to interact with MongoDB).
If you don't have MongoDB running locally, you can either install MongoDB or use a cloud-based solution like
MongoDB Atlas. If using MongoDB Atlas, you'll need a connection string (e.g.,
mongodb+srv://<username>:<password>@cluster0.mongodb.net/myDatabase).
Let's create a basic Node.js server that interacts with MongoDB using the Mongoose library.
// MongoDB connection string (update with your own connection string if using MongoDB Atlas)
const mongoURI = 'mongodb://localhost:27017/votingApp';
try {
let vote = await Vote.findOne({ option });
if (!vote) {
// If the option doesn't exist, create a new vote option
vote = new Vote({ option, votes: 1 });
await vote.save();
} else {
// Increment the votes for the existing option
vote.votes += 1;
await vote.save();
}
res.status(200).json(vote);
} catch (err) {
res.status(500).json({ message: 'Error casting vote', error: err });
}
});
In the code above, we define a Mongoose schema to structure the vote options. Each vote option will have:
This schema is used to create the Vote model that interacts with the MongoDB database.
mongod
7. Test the API
{
"option": "Option 1"
}
8. Optional Improvements
You can further improve this application with features such as:
node index.js
The server will now be running on http://localhost:3000 and you can interact with it using Postman or any HTTP
client.
OUTPUT:
EXERCISE PROGRAM:
Week-11. Write a server side program for Manipulating MongoDB from Node.js
To manipulate MongoDB from Node.js, we can use the mongoose library, which is an Object Data Modeling
(ODM) library that provides a higher-level API for interacting with MongoDB.
Here’s a complete guide and example server-side program that demonstrates basic MongoDB manipulations, such
as creating, reading, updating, and deleting data (CRUD operations).
Steps:
1. Set Up Project
mkdir node-mongo-crud
cd node-mongo-crud
npm init -y
npm install express mongoose
Create a file called index.js for the server-side logic. This will handle the database connection and the routes for
CRUD operations.
// MongoDB connection URI (replace with your connection string if using MongoDB Atlas)
const mongoURI = 'mongodb://localhost:27017/myDatabase';
// Connect to MongoDB
mongoose.connect(mongoURI, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => console.log('Connected to MongoDB'))
.catch((err) => console.error('Error connecting to MongoDB:', err));
// Define a Schema (Model) for MongoDB
const itemSchema = new mongoose.Schema({
name: String,
description: String,
price: Number,
});
{
"name": "Item 1",
"description": "A sample item",
"price": 100
}
1. Make sure you have MongoDB running locally (mongod) or connect to a cloud database like MongoDB
Atlas.
2. To run the Node.js server, use the following command in the terminal:
node index.js
3. The server should now be running at http://localhost:3000. You can use tools like Postman or cURL to test
the API routes.
node-mongo-crud/
│
├── node_modules/ # Dependencies
├── package.json # Project metadata and dependencies
├── index.js # Server code handling CRUD operations
└── package-lock.json # Locked dependencies version
OUTPUT:
EXERCISE PROGRAM: