class 9 science chapter 4

ch4 part8

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>🧠 Science Quiz – Acceleration</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;
  }

  .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;
  }

  .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 – Acceleration</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. Ek bus 36 km/h ki velocity se move kar rahi hai. Driver accelerator press karta hai aur 10 s mein velocity 54 km/h ho jaati hai. Bus ki average acceleration kya hogi?",
    options: [
      "A. 0.5 m/s²",
      "B. 1.5 m/s²",
      "C. 5 m/s²",
      "D. 18 m/s²"
    ],
    correct: 0,
    explanation: "36 km/h = 10 m/s aur 54 km/h = 15 m/s. Average acceleration = (15 − 10) ÷ 10 = <b>0.5 m/s²</b>."
  },

  {
    question: "2. Usi bus ki velocity accelerator press karne ke baad 10 m/s se 15 m/s ho jaati hai. Is case mein acceleration ki direction kya hogi?",
    options: [
      "A. Velocity ke opposite",
      "B. Velocity ke same direction",
      "C. Hamesha perpendicular",
      "D. Zero direction"
    ],
    correct: 1,
    explanation: "Bus ki velocity ka magnitude increase ho raha hai, isliye acceleration <b>velocity ki direction</b> mein hogi."
  },

  {
    question: "3. Bus 54 km/h ki velocity se chal rahi hai aur brakes lagane par 5 s mein completely stop ho jaati hai. Bus ki average acceleration kya hogi?",
    options: [
      "A. +3 m/s²",
      "B. −3 m/s²",
      "C. +15 m/s²",
      "D. −15 m/s²"
    ],
    correct: 1,
    explanation: "54 km/h = 15 m/s. Average acceleration = (0 − 15) ÷ 5 = <b>−3 m/s²</b>. Negative sign batata hai ki acceleration velocity ke opposite direction mein hai."
  },

  {
    question: "4. Bus jab 54 km/h ki velocity se chal rahi ho aur brakes lagne par 5 s mein stop ho jaaye, toh negative acceleration ka kya meaning hai?",
    options: [
      "A. Bus backward move kar rahi hai",
      "B. Bus ki mass decrease ho rahi hai",
      "C. Acceleration velocity ke opposite direction mein hai",
      "D. Bus ki distance zero ho gayi hai"
    ],
    correct: 2,
    explanation: "Negative sign chosen positive direction ke opposite acceleration ko show karta hai. Yahan bus <b>slow down</b> kar rahi hai."
  },

  {
    question: "5. Ek bus straight highway par 80 km/h ki constant velocity se move kar rahi hai. Bus ki acceleration kya hogi?",
    options: [
      "A. 80 m/s²",
      "B. 8 m/s²",
      "C. 1 m/s²",
      "D. 0 m/s²"
    ],
    correct: 3,
    explanation: "Acceleration velocity ke change par depend karti hai. <b>Constant velocity</b> mein velocity change nahi hoti, isliye acceleration <b>zero</b> hoti hai."
  },

  {
    question: "6. Kaunsa statement acceleration ke baare mein correct hai?",
    options: [
      "A. Fast-moving object ki acceleration hamesha high hoti hai",
      "B. Slow-moving object ki acceleration hamesha zero hoti hai",
      "C. Acceleration velocity ke change hone ki rate par depend karti hai",
      "D. Acceleration sirf object ke mass par depend karti hai"
    ],
    correct: 2,
    explanation: "Object kitni fast move kar raha hai, yeh alone acceleration decide nahi karta. Acceleration batati hai ki <b>velocity kitni quickly change ho rahi hai</b>."
  },

  {
    question: "7. Ek object ko height se drop kiya jaata hai. Har successive 1 second mein uski velocity 9.8 m/s se increase hoti hai. Is object ki average acceleration kya hogi?",
    options: [
      "A. 4.9 m/s²",
      "B. 9.8 m/s²",
      "C. 19.6 m/s²",
      "D. 98 m/s²"
    ],
    correct: 1,
    explanation: "Har 1 second mein velocity 9.8 m/s se increase ho rahi hai. Isliye average acceleration = <b>9.8 m/s²</b>."
  },

  {
    question: "8. Dropped object ke liye 0–1 s, 1–2 s, 2–3 s aur 3–4 s ke intervals mein average acceleration respectively −9.8 m/s², −9.8 m/s², −9.8 m/s² aur −9.8 m/s² milti hai. Isse kya conclude hota hai?",
    options: [
      "A. Acceleration changing hai",
      "B. Acceleration constant hai",
      "C. Object rest mein hai",
      "D. Velocity constant hai"
    ],
    correct: 1,
    explanation: "Har successive 1-second interval mein acceleration ka same value <b>−9.8 m/s²</b> hai, isliye acceleration constant hai."
  },

  {
    question: "9. Ek object ko Earth ke gravitational force ke kaaran downward drop kiya jaata hai aur downward direction ko positive maana gaya hai. Agar velocity downward direction mein increase ho rahi hai, toh acceleration ki direction kya hogi?",
    options: [
      "A. Upward",
      "B. Downward",
      "C. Horizontal",
      "D. Zero"
    ],
    correct: 1,
    explanation: "Velocity ka magnitude downward direction mein increase ho raha hai, isliye acceleration bhi <b>downward direction</b> mein hogi. Is acceleration ko gravitational acceleration, <b>g</b>, kehte hain."
  },

  {
    question: "10. Motion problem solve karte waqt agar origin aur positive direction choose kar li gayi hai, toh us choice ke baare mein kya rule follow karna chahiye?",
    options: [
      "A. Har calculation ke baad direction change kar sakte hain",
      "B. Sirf positive direction change karni chahiye",
      "C. Chosen origin aur positive direction ko problem solve karte waqt change nahi karna chahiye",
      "D. Origin ki zaroorat hi nahi hoti"
    ],
    correct: 2,
    explanation: "Origin aur positive direction <b>convenience ke according choose</b> kar sakte hain, lekin choose karne ke baad complete problem mein <b>same convention maintain</b> karna chahiye."
  }

];

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>${userName}, 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>

Leave a Comment