ch4 part5
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>🧠 Science Quiz – Speed and Velocity</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; }
</style>
</head>
<body>
<div class="quiz-container">
<h2>🧠 Science Quiz – Speed and Velocity</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. Do postmen ek-doosre ki taraf 210 yojanas ki distance se walk karna start karte hain. Pehla postman 9 yojanas/day aur doosra 5 yojanas/day chalta hai. Dono ek din mein milkar kitni distance cover karenge?",
options: [
"A. 4 yojanas",
"B. 9 yojanas",
"C. 14 yojanas",
"D. 45 yojanas"
],
correct: 2,
explanation: "Dono ek-doosre ki taraf aa rahe hain, isliye combined distance per day = 9 + 5 = <b>14 yojanas/day</b>."
},
{
question: "2. Do postmen 210 yojanas apart hain aur unki speeds 9 yojanas/day aur 5 yojanas/day hain. Woh kitne din mein milenge?",
options: [
"A. 10 days",
"B. 12 days",
"C. 15 days",
"D. 20 days"
],
correct: 2,
explanation: "Combined speed = 9 + 5 = 14 yojanas/day.<br>Time = Distance ÷ Speed = 210 ÷ 14 = <b>15 days</b>."
},
{
question: "3. 15 days mein 9 yojanas/day ki speed se chalne wala postman kitni distance cover karega?",
options: [
"A. 75 yojanas",
"B. 105 yojanas",
"C. 135 yojanas",
"D. 150 yojanas"
],
correct: 2,
explanation: "Distance = Speed × Time = 9 × 15 = <b>135 yojanas</b>."
},
{
question: "4. Speed aur velocity mein main difference kya hai?",
options: [
"A. Speed direction batati hai, velocity nahi",
"B. Speed sirf magnitude batati hai, velocity magnitude ke saath direction bhi batati hai",
"C. Dono hamesha same physical quantity hain",
"D. Velocity mein time ka koi role nahi hota"
],
correct: 1,
explanation: "Speed batati hai object <b>kitni fast</b> move kar raha hai. Velocity speed ke saath <b>direction of motion</b> bhi batati hai."
},
{
question: "5. Average velocity ko calculate karne ke liye kaunsi quantity use ki jaati hai?",
options: [
"A. Total distance ÷ time interval",
"B. Displacement ÷ time interval",
"C. Time interval ÷ displacement",
"D. Distance × time interval"
],
correct: 1,
explanation: "Average velocity = <b>Displacement ÷ Time interval</b>. Ismein displacement ki direction bhi consider hoti hai."
},
{
question: "6. Ek student 20 m east direction mein 5 seconds mein move karta hai. Uski average velocity kya hogi?",
options: [
"A. 4 m/s east",
"B. 4 m/s west",
"C. 25 m/s east",
"D. 100 m/s east"
],
correct: 0,
explanation: "Average velocity = Displacement ÷ Time = 20 ÷ 5 = <b>4 m/s east</b>. Direction displacement ke same hoti hai."
},
{
question: "7. Straight-line motion mein velocity ki direction ko mathematically kaise indicate kiya ja sakta hai?",
options: [
"A. Sirf unit se",
"B. Sirf time se",
"C. + ya − sign se",
"D. Sirf mass se"
],
correct: 2,
explanation: "Straight-line motion mein ek direction ko <b>positive (+)</b> aur opposite direction ko <b>negative (−)</b> sign se represent kiya ja sakta hai."
},
{
question: "8. Average speed aur average velocity ki SI unit kya hai?",
options: [
"A. km/h only",
"B. metre (m)",
"C. metre per second (m/s)",
"D. second per metre (s/m)"
],
correct: 2,
explanation: "Average speed aur average velocity dono ki SI unit <b>m/s</b> ya <b>m s⁻¹</b> hai. Inhe commonly km/h mein bhi express kiya ja sakta hai."
},
{
question: "9. “Average velocity is the average rate of change of position with respect to time.” Is statement ka correct meaning kya hai?",
options: [
"A. Position mein change ko time interval se divide karna",
"B. Time ko position se divide karna",
"C. Distance ko mass se divide karna",
"D. Position aur time ko multiply karna"
],
correct: 0,
explanation: "Average velocity = <b>Change in position (displacement) ÷ Corresponding time interval</b>. Isliye yeh position ke change ki rate batati hai."
},
{
question: "10. Ek car 100 m east direction mein 10 s mein move karti hai. Agar east ko positive direction maana jaye, toh car ki average velocity kya hogi?",
options: [
"A. −10 m/s",
"B. +10 m/s",
"C. +100 m/s",
"D. −100 m/s"
],
correct: 1,
explanation: "Average velocity = 100 ÷ 10 = <b>10 m/s</b>. East ko positive maana gaya hai, isliye velocity <b>+10 m/s</b> hogi."
}
];
let currentQuestion = 0;
let score = 0;
let userAnswers = [];
let userName = "";
function startQuiz() {
userName = document.getElementById("userName").value.trim();
if (!userName) {
return alert("Please enter your name.");
}
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" id="explain${currentQuestion}">
${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 nextQuestion() {
saveAnswer();
if (currentQuestion < questions.length - 1) {
currentQuestion++;
showQuestion();
}
}
function prevQuestion() {
saveAnswer();
if (currentQuestion > 0) {
currentQuestion--;
showQuestion();
}
}
function saveAnswer() {
const selected = document.querySelector('input[name="option"]:checked');
userAnswers[currentQuestion] = selected ? parseInt(selected.value) : null;
}
function submitQuiz() {
saveAnswer();
score = 0;
questions.forEach((q, index) => {
if (userAnswers[index] === q.correct) {
score++;
}
});
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 = JSON.parse(localStorage.getItem("quizScores")) || [];
scores.push({
name,
score,
date: new Date().toLocaleString()
});
localStorage.setItem("quizScores", JSON.stringify(scores));
}
function loadScoreboard() {
let scores = JSON.parse(localStorage.getItem("quizScores")) || [];
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>