Milan vashisth web development and ADAS
Milan vashisth web development and ADAS
Assignment:- 2 Lab
Q1- Develop a simple HTML5 page that embeds a YouTube video and
an audio file. Use CSS3 to style the media elements with custom
controls, backgrounds, and borders.
Answer:- Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>You Tube </title>
<style>
Body
{
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.media-container
{
background-color: #f4f1f8;
border: 2px solid #060101; border-radius: 10px;
padding: 20px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
text-align: center;
}
.media-container h1
{
margin-bottom: 20px;
color: #333333;
}
.video-wrapper,
.audio-wrapper {
margin-bottom: 20px;
}
.video-wrapper iframe
{
border: 3px solid #007BFF;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}
.audio-wrapper audio
{
width: 100%;
border: 2px solid #28a745;
border-radius: 8px;
background-color: #f8f9fa;
}
.footer
{
font-size: 0.9em;
color: #666666;
}
</style>
</head>
<body>
<div class="media-container">
<h1>You Tube</h1>
<!-- Embedded YouTube Video -->
<div class="video-wrapper"> <iframe
width="560"
height="315"
src="https://www.youtube.com/embed/dQw4w9WgXcQ"
title="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media;
gyroscope; picture-in
picture"
allowfullscreen>
</iframe>
</div>
<!-- Embedded Audio File -->
<div class="audio-wrapper">
<audio controls>
<source src="Bapu.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</div>
<div class="footer">Designed with HTML5 and CSS3</div>
</div>
</body>
</html>
Q2 - Write a JavaScript program that uses recursion to calculate the
factorial of a given number. Compare the recursive approach with an
iterative approach and explain the differences.
// Recursive Approach
function factorialRecursive(n)
{
if (n < 0)
{
return "Invalid input"; // Factorial is not defined for negative numbers
}
if (n === 0 || n === 1)
{
return 1; // Base case
}
return n * factorialRecursive(n - 1); // Recursive call
}
// Iterative Approach
function factorialIterative(n)
{
if (n < 0)
{
return "Invalid input"; // Factorial is not defined for negative numbers
}
let result = 1;
for (let i = 2; i <= n; i++)
{
result *= i; // Multiplying the result by each number up to n
}
return result;
}
const number = 5;
console.log(`Factorial of ${number} using recursion: $
{factorialRecursive(number)}`);
console.log(`Factorial of ${number} using iteration: $
{factorialIterative(number)}`);
Certainly! Below is a JavaScript program that calculates the factorial of a
given number using both a recursive approach and an iterative approach.
Along with that, I will explain the differences between these two methods.
```javascript
// Recursive Approach
function factorialRecursive(n)
{
if (n < 0)
{
return "Invalid input"; // Factorial is not defined for negative numbers
}
if (n === 0 || n === 1)
{
return 1; // Base case
}
return n * factorialRecursive(n - 1); // Recursive call
}
// Iterative Approach
function factorialIterative(n)
{
if (n < 0)
{
return "Invalid input"; // Factorial is not defined for negative numbers
}
let result = 1;
for (let i = 2; i <= n; i++)
{
result *= i; // Multiplying the result by each number up to n
}
return result;
}
const number = 5;
console.log(`Factorial of ${number} using recursion: $
{factorialRecursive(number)}`);
console.log(`Factorial of ${number} using iteration: $
{factorialIterative(number)}`);
2. Recursive Call: For any number greater than 1, it multiplies `n` by the
factorial of `n-1`. This breaks the problem down into smaller sub problems.
3. Stack Depth: Each function call adds to the call stack, so for large values
of `n`, there could be a risk of a stack overflow due to too many frames in
the call stack.
Iterative Approach
1. Looping: The iterative solution uses a loop which continues until it has
multiplied all integers from 2 to `n`.
Differences:-
Characteristics:-
Purpose:-
Data Integrity
Payments.
Inventory updates.
data visualization.
business intelligence .
Answer:- In this answer we will have to create a library database with four
main tables: Books, Authors, Members, and Loans. Each table has a unique
primary key and foreign key referencing other tables as needed.
Code:-
USE LibraryDatabase;
UPDATE Books SET Title = 'The Great Gatsby (Updated)' WHERE BookID
= 1;
1) Books
2) Authors
3) Members
4) Loans.
The Books table has columns for BookID, Title, Publisher, ISBN, and
Genre.
The Authors table has columns for AuthorID and FirstName and LastName.
The Members table has columns for MemberID, FirstName, LastName, and
Email.
The Loans table has columns for LoanID, MemberID (foreign key
referencing MemberID in Members), BookID (foreign key referencing
BookID in Books), LoanDate, and ReturnDate.
Data Types:-
The data types used are: INT for whole numbers (e.g., BookID, MemberID,
AuthorID, LoanID) VARCHAR for variable-length strings (e.g.Title,
Publisher, ISBN, Genre, FirstName, LastName, Email) DATE for dates
(e.g., LoanDate, ReturnDate).
Benefits:-