class 9 science chapter 7

ch7 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 – Forms of 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;
  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 – Forms of Energy and Kinetic 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. Energy ke baare mein basic scientific definition kya hai?",
options: [
"A. Energy is the speed of an object",
"B. Energy is the capacity to do work",
"C. Energy is the force acting on an object",
"D. Energy is the displacement of an object"
],
correct: 1,
explanation: "✅ Correct Answer: B. Energy is the capacity to do work.<br>Science mein energy ko work karne ki capacity ke roop mein define kiya jaata hai."
},

{
question: "2. Electric bulb mein electrical energy mainly kis form ki energy mein convert hoti hai?",
options: [
"A. Sound energy",
"B. Chemical energy",
"C. Light energy",
"D. Nuclear energy"
],
correct: 2,
explanation: "✅ Correct Answer: C. Light energy.<br>Electric bulb mein electrical energy → light energy mein convert hoti hai. Saath mein kuch energy thermal energy mein bhi convert hoti hai."
},

{
question: "3. Electric water heater mein electrical energy mainly water ko kis form ki energy provide karti hai?",
options: [
"A. Thermal energy",
"B. Sound energy",
"C. Nuclear energy",
"D. Chemical energy"
],
correct: 0,
explanation: "✅ Correct Answer: A. Thermal energy.<br>Heater electrical energy ko mainly thermal energy mein convert karta hai, jisse water heat hota hai."
},

{
question: "4. Hum jo food khate hain usmein stored chemical energy body mein mainly kis form ki energy provide karti hai?",
options: [
"A. Mechanical energy",
"B. Nuclear energy",
"C. Light energy",
"D. Sound energy"
],
correct: 0,
explanation: "✅ Correct Answer: A. Mechanical energy.<br>Food ki chemical energy muscles ko power deti hai aur body movements ke liye mechanical energy mein convert hoti hai."
},

{
question: "5. Ek ringing bell mein mechanical energy kis form ki energy mein convert hoti hai?",
options: [
"A. Chemical energy",
"B. Sound energy",
"C. Nuclear energy",
"D. Electrical energy"
],
correct: 1,
explanation: "✅ Correct Answer: B. Sound energy.<br>Bell vibrate karti hai, aur uski mechanical energy sound energy mein convert hoti hai."
},

{
question: "6. Mechanical energy kisi object ke paas kis wajah se hoti hai?",
options: [
"A. Sirf uske temperature ki wajah se",
"B. Uski motion ya position ki wajah se",
"C. Sirf uske colour ki wajah se",
"D. Sirf uske volume ki wajah se"
],
correct: 1,
explanation: "✅ Correct Answer: B. Uski motion ya position ki wajah se.<br>Mechanical energy object ki motion ya position se related hoti hai. Ismein kinetic aur potential energy dono include hoti hain."
},

{
question: "7. Kisi moving bicycle ke paas kaunsi energy hoti hai jo uski motion ke reason se hoti hai?",
options: [
"A. Kinetic energy",
"B. Chemical energy",
"C. Nuclear energy",
"D. Thermal energy"
],
correct: 0,
explanation: "✅ Correct Answer: A. Kinetic energy.<br>Object ki motion ke karan possessed energy ko kinetic energy kehte hain. Moving bicycle aur rolling ball iske examples hain."
},

{
question: "8. Ek object initially rest mein hai aur constant force ke under move karke velocity v achieve karta hai. Uski final kinetic energy ka expression kya hoga?",
options: [
"A. K = mv",
"B. K = ½mv",
"C. K = ½mv²",
"D. K = mv²"
],
correct: 2,
explanation: "✅ Correct Answer: C. K = ½mv².<br>Mass m aur velocity v se moving object ki kinetic energy K = ½mv² hoti hai."
},

{
question: "9. Do objects ki mass same hai, lekin ek object ki speed doosre se double hai. Unki kinetic energies mein kya relation hoga?",
options: [
"A. Double",
"B. Same",
"C. Four times",
"D. Half"
],
correct: 2,
explanation: "✅ Correct Answer: C. Four times.<br>Kinetic energy K = ½mv². Mass same hone par K ∝ v². Speed double hone par kinetic energy 2² = 4 times ho jaati hai."
},

{
question: "10. 2 kg mass ka ek object 3 m/s ki speed se move kar raha hai. Uski kinetic energy kitni hogi?",
options: [
"A. 3 J",
"B. 6 J",
"C. 9 J",
"D. 18 J"
],
correct: 2,
explanation: "✅ Correct Answer: C. 9 J.<br>K = ½mv² = ½ × 2 × 3² = 1 × 9 = 9 J."
}

];

let currentQuestion = 0;
let score = 0;
let userAnswers = [];
let userName = "";

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" 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