class 9 science chapter 7

ch7 part9

<!DOCTYPE html>
<html lang="en">
<head>
<title>🧠 Science Quiz – Potential Energy and Conservation of Mechanical Energy</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 – Potential Energy and Conservation of Mechanical Energy</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. Example 7.7 mein cricket ball ka mass 200 g aur maximum height 10 m hai. Agar g = 10 m/s² ho, to maximum height par ball ki potential energy kitni hogi?",
    options: ["A. 2 J", "B. 10 J", "C. 20 J", "D. 200 J"],
    correct: 2,
    explanation: "Correct Answer: C. 20 J<br>200 g = 0.2 kg. Formula: U = mgh = 0.2 × 10 × 10 = <b>20 J</b>."
  },
  {
    question: "2. Agar koi object Earth ki surface ke paas horizontal direction mein constant velocity se move kare, to uski gravitational potential energy mein kya change hoga?",
    options: ["A. Increase hogi", "B. Decrease hogi", "C. Zero ho jayegi", "D. Change nahi hogi"],
    correct: 3,
    explanation: "Correct Answer: D. Change nahi hogi<br>Horizontal motion mein object ki height same rehti hai, isliye mgh ke according potential energy change nahi hoti."
  },
  {
    question: "3. Agar kisi object ko gradually vertical direction mein upar raise kiya jaye, to uski gravitational potential energy kya hogi?",
    options: ["A. Increase hogi", "B. Decrease hogi", "C. Constant rahegi", "D. Zero ho jayegi"],
    correct: 0,
    explanation: "Correct Answer: A. Increase hogi<br>Height increase hone par U = mgh ke according gravitational potential energy bhi increase hoti hai."
  },
  {
    question: "4. Work done against which force potential energy ke form mein energy store nahi karta?",
    options: ["A. Gravitational force", "B. Electric force", "C. Magnetic force", "D. Frictional force"],
    correct: 3,
    explanation: "Correct Answer: D. Frictional force<br>Gravitational, electric aur magnetic forces ke against work potential energy store kar sakta hai, lekin friction ke against work energy ko stored potential energy ke form mein nahi rakhta."
  },
  {
    question: "5. Kinetic energy aur potential energy ka sum kya kehlata hai?",
    options: ["A. Thermal energy", "B. Mechanical energy", "C. Chemical energy", "D. Electrical energy"],
    correct: 1,
    explanation: "Correct Answer: B. Mechanical energy<br>Mechanical Energy = Kinetic Energy + Potential Energy."
  },
  {
    question: "6. Ek object ko height h par point A se rest position se drop kiya gaya. Point A par uski kinetic energy kya hogi?",
    options: ["A. mgh", "B. ½mgh", "C. Zero", "D. 2mgh"],
    correct: 2,
    explanation: "Correct Answer: C. Zero<br>Object ko rest se drop kiya gaya hai, yani initial velocity u = 0. Isliye point A par kinetic energy zero hai."
  },
  {
    question: "7. Point A par height h par rest mein rakhe object ki mechanical energy kya hogi?",
    options: ["A. Zero", "B. ½mgh", "C. mgh", "D. 2mgh"],
    correct: 2,
    explanation: "Correct Answer: C. mgh<br>Point A par KE = 0 aur PE = mgh. Isliye mechanical energy = 0 + mgh = <b>mgh</b>."
  },
  {
    question: "8. Jab object freely fall karta hai, to uski potential energy aur kinetic energy mein kya change hota hai?",
    options: ["A. PE increase aur KE decrease", "B. PE decrease aur KE increase", "C. Dono decrease", "D. Dono constant"],
    correct: 1,
    explanation: "Correct Answer: B. PE decrease aur KE increase<br>Falling ke during height decrease hoti hai, isliye PE decrease hoti hai. Lost PE kinetic energy mein convert hoti hai, isliye KE increase hoti hai."
  },
  {
    question: "9. Free fall ke during agar koi other external force act nahi kar raha ho, to object ki mechanical energy kya hoti hai?",
    options: ["A. Continuously increase hoti hai", "B. Continuously decrease hoti hai", "C. Constant rehti hai", "D. Zero ho jati hai"],
    correct: 2,
    explanation: "Correct Answer: C. Constant rehti hai<br>Jab sirf gravitational force act karta hai, to potential energy ka loss kinetic energy ke gain ke equal hota hai. Isliye total mechanical energy conserved rehti hai."
  },
  {
    question: "10. Ek object height h se freely fall karta hai. Uski lost potential energy kis form mein convert hoti hai?",
    options: ["A. Chemical energy", "B. Electrical energy", "C. Kinetic energy", "D. Nuclear energy"],
    correct: 2,
    explanation: "Correct Answer: C. Kinetic energy<br>Falling ke time gravitational potential energy decrease hoti hai aur wahi energy object ki kinetic energy mein convert hoti hai. Isi principle ko conservation of mechanical energy kehte hain."
  }
];

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>

Leave a Comment