ch4 part13
<!DOCTYPE html>
<html lang="en">
<head>
<title>🧠 Science Quiz – Kinematic Equations</title>
<style>
body {
font-family: Arial, sans-serif;
background: linear-gradient(135deg, #a1c4fd, #c2e9fb);
display: flex;
justify-content: center;
align-items: flex-start;
padding: 30px;
min-height: 100vh;
}
.quiz-container {
background: #fff;
padding: 25px;
border-radius: 12px;
box-shadow: 0 4px 10px rgba(0,0,0,0.2);
width: 90%;
max-width: 800px;
}
h2 { text-align: center; color: #1e3c72; }
.question { font-weight: bold; margin: 10px 0; line-height: 1.6; }
.options label {
display: block;
margin: 8px 0;
padding: 10px;
border-radius: 6px;
border: 1px solid #ccc;
cursor: pointer;
transition: 0.3s;
}
.options label:hover { background: #f0f0f0; }
.correct { background-color: #c8f7c5 !important; border-color: #28a745 !important; }
.wrong { background-color: #f8d7da !important; border-color: #dc3545 !important; }
.explanation {
background: #e9ecef;
padding: 10px;
margin-top: 10px;
border-left: 5px solid #2a5298;
display: none;
line-height: 1.6;
}
.controls { text-align: center; margin-top: 15px; }
button {
background-color: #2a5298;
color: white;
border: none;
padding: 10px 20px;
border-radius: 6px;
cursor: pointer;
margin: 5px;
}
button:hover { background-color: #1e3c72; }
#scoreboard {
margin-top: 25px;
background: #eef3f7;
padding: 15px;
border-radius: 8px;
}
#scoreboard h3 { text-align: center; }
ol { padding-left: 20px; }
#userName {
padding: 10px;
width: 60%;
max-width: 300px;
border: 1px solid #ccc;
border-radius: 6px;
}
</style>
</head>
<body>
<div class="quiz-container">
<h2>🧠 Science Quiz – Kinematic Equations</h2>
<div id="nameSection">
<p><strong>Enter your name to start:</strong></p>
<input type="text" id="userName" placeholder="Your Name">
<button onclick="startQuiz()">Start Quiz</button>
</div>
<div id="quizSection" style="display:none;">
<div id="questionContainer"></div>
<div class="controls">
<button onclick="prevQuestion()" id="prevBtn">Previous</button>
<button onclick="nextQuestion()" id="nextBtn">Next</button>
<button onclick="submitQuiz()" id="submitBtn" style="display:none;">Submit</button>
</div>
<div id="result" style="text-align:center; margin-top:20px;"></div>
<div id="scoreboard">
<h3>🏆 Scoreboard</h3>
<ol id="scoreList"></ol>
</div>
</div>
</div>
<script>
const questions = [
{
question: "1. Kinematic equations ka use kis type ke motion ko analyse karne ke liye kiya jaata hai?",
options: [
"A. Circular motion with changing acceleration",
"B. Straight-line motion with constant acceleration",
"C. Random motion without acceleration",
"D. Circular motion with zero velocity"
],
correct: 1,
explanation: "Kinematic equations specifically <b>straight-line motion with constant acceleration</b> ko describe karti hain."
},
{
question: "2. Ek object ki initial velocity 5 m/s hai aur acceleration 2 m/s² hai. 4 s ke baad final velocity kya hogi?",
options: [
"A. 7 m/s",
"B. 10 m/s",
"C. 13 m/s",
"D. 15 m/s"
],
correct: 2,
explanation: "v = u + at = 5 + (2 × 4) = <b>13 m/s</b>."
},
{
question: "3. Equation v = u + at mein ‘u’ kya represent karta hai?",
options: [
"A. Final velocity",
"B. Initial velocity",
"C. Acceleration",
"D. Displacement"
],
correct: 1,
explanation: "Equation mein <b>u initial velocity</b>, v final velocity, a acceleration aur t time interval ko represent karta hai."
},
{
question: "4. Ek object rest se start karta hai. Uski acceleration 3 m/s² hai. 5 s mein woh kitna displacement cover karega?",
options: [
"A. 15 m",
"B. 30 m",
"C. 37.5 m",
"D. 45 m"
],
correct: 2,
explanation: "Rest se start hone par u = 0.<br>s = ut + ½at²<br>= 0 + ½ × 3 × 5²<br>= <b>37.5 m</b>."
},
{
question: "5. Equation s = ut + ½at² mein ‘s’ kis physical quantity ko represent karta hai?",
options: [
"A. Speed",
"B. Displacement",
"C. Final velocity",
"D. Time"
],
correct: 1,
explanation: "Is kinematic equation mein <b>s displacement</b> ko represent karta hai."
},
{
question: "6. Ek car ki initial velocity 10 m/s hai. Acceleration 2 m/s² hai aur car 5 s tak accelerate karti hai. Uska displacement kitna hoga?",
options: [
"A. 50 m",
"B. 60 m",
"C. 75 m",
"D. 100 m"
],
correct: 2,
explanation: "s = ut + ½at²<br>= (10 × 5) + ½ × 2 × 25<br>= 50 + 25 = <b>75 m</b>."
},
{
question: "7. Kinematic equation v² = u² + 2as mein kaunsi physical quantity directly present nahi hai?",
options: [
"A. Initial velocity",
"B. Final velocity",
"C. Time",
"D. Acceleration"
],
correct: 2,
explanation: "Is equation mein <b>u, v, a aur s</b> hain, lekin <b>time t directly present nahi hai</b>."
},
{
question: "8. Ek object 4 m/s ki initial velocity se move karta hai aur 3 m/s² ki constant acceleration ke saath 2 s tak move karta hai. Final velocity kya hogi?",
options: [
"A. 6 m/s",
"B. 8 m/s",
"C. 10 m/s",
"D. 12 m/s"
],
correct: 2,
explanation: "v = u + at = 4 + (3 × 2) = <b>10 m/s</b>."
},
{
question: "9. Ek object ki initial velocity 10 m/s, final velocity 20 m/s aur displacement 75 m hai. Acceleration kitni hogi?",
options: [
"A. 1 m/s²",
"B. 2 m/s²",
"C. 3 m/s²",
"D. 4 m/s²"
],
correct: 1,
explanation: "v² = u² + 2as<br>400 = 100 + 2 × a × 75<br>300 = 150a<br>a = <b>2 m/s²</b>."
},
{
question: "10. Kinematic equations ka main purpose kya hai?",
options: [
"A. Sirf object ka mass calculate karna",
"B. Motion ke future position ya velocity ko predict karna",
"C. Sirf force calculate karna",
"D. Sirf distance aur speed ko compare karna"
],
correct: 1,
explanation: "Kinematic equations motion ka mathematical description deti hain aur <b>future time par object ki position ya velocity predict</b> karne mein help karti hain."
}
];
let currentQuestion = 0;
let score = 0;
let userAnswers = [];
let userName = "";
let quizSubmitted = false;
function startQuiz() {
userName = document.getElementById("userName").value.trim();
if (!userName) {
alert("Please enter your name.");
return;
}
document.getElementById("nameSection").style.display = "none";
document.getElementById("quizSection").style.display = "block";
showQuestion();
loadScoreboard();
}
function showQuestion() {
const q = questions[currentQuestion];
const container = document.getElementById("questionContainer");
container.innerHTML = `
<div class="question">${q.question}</div>
<div class="options">
${q.options.map((opt, i) => `
<label>
<input type="radio" name="option" value="${i}"
${userAnswers[currentQuestion] == i ? "checked" : ""}>
${opt}
</label>
`).join("")}
</div>
<div class="explanation">${q.explanation}</div>
`;
document.getElementById("prevBtn").style.display =
currentQuestion === 0 ? "none" : "inline-block";
document.getElementById("nextBtn").style.display =
currentQuestion === questions.length - 1 ? "none" : "inline-block";
document.getElementById("submitBtn").style.display =
currentQuestion === questions.length - 1 ? "inline-block" : "none";
}
function saveAnswer() {
const selected = document.querySelector('input[name="option"]:checked');
userAnswers[currentQuestion] = selected ? parseInt(selected.value) : null;
}
function nextQuestion() {
saveAnswer();
if (currentQuestion < questions.length - 1) {
currentQuestion++;
showQuestion();
}
}
function prevQuestion() {
saveAnswer();
if (currentQuestion > 0) {
currentQuestion--;
showQuestion();
}
}
function submitQuiz() {
if (quizSubmitted) return;
saveAnswer();
score = 0;
questions.forEach((q, index) => {
if (userAnswers[index] === q.correct) {
score++;
}
});
quizSubmitted = true;
showResults();
saveScore(userName, score);
loadScoreboard();
}
function showResults() {
const container = document.getElementById("questionContainer");
container.innerHTML = "";
questions.forEach((q, index) => {
const selected = userAnswers[index];
const correct = q.correct;
let optsHTML = q.options.map((opt, i) => {
let cls = "";
if (i === correct) cls = "correct";
if (selected === i && selected !== correct) cls = "wrong";
return `<label class="${cls}">${opt}</label>`;
}).join("");
container.innerHTML += `
<div class="question">${q.question}</div>
<div class="options">${optsHTML}</div>
<div class="explanation" style="display:block;">
${q.explanation}
</div>
<hr>
`;
});
document.querySelector(".controls").style.display = "none";
document.getElementById("result").innerHTML =
`<h3>Your Score: ${score} / ${questions.length}</h3>`;
}
function saveScore(name, score) {
let scores = [];
try {
scores = JSON.parse(localStorage.getItem("quizScores")) || [];
} catch (error) {
scores = [];
}
scores.push({
name: name,
score: score,
date: new Date().toLocaleString()
});
localStorage.setItem("quizScores", JSON.stringify(scores));
}
function loadScoreboard() {
let scores = [];
try {
scores = JSON.parse(localStorage.getItem("quizScores")) || [];
} catch (error) {
scores = [];
}
scores.sort((a, b) => b.score - a.score);
document.getElementById("scoreList").innerHTML =
scores.map(s =>
`<li>${s.name} - ${s.score}/10 (${s.date})</li>`
).join("");
}
</script>
</body>
</html>