class 10 science chapter 2

ch2 part 1

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Acids, Bases and Salts – Chemistry Quiz</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>πŸ§ͺ Acids, Bases and Salts – Chemistry Quiz</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. Agar kisi person ko overeating ke baad acidity ho rahi hai, to inmein se kaunsa remedy suggest kiya ja sakta hai?",
    options: [
      "A. Lemon juice",
      "B. Vinegar",
      "C. Baking soda solution",
      "D. Sugar solution"
    ],
    correct: 2,
    explanation: "Acidity mein stomach mein excess acid hota hai. Baking soda basic nature ka hota hai, isliye acid ke effect ko neutralise karne mein help karta hai. Acid aur base ek-doosre ke effect ko nullify kar sakte hain."
  },
  {
    question: "2. Acids blue litmus paper ke colour ko kis colour mein change kar dete hain?",
    options: [
      "A. Blue",
      "B. Green",
      "C. Red",
      "D. Yellow"
    ],
    correct: 2,
    explanation: "Acids blue litmus ko red kar dete hain. Ye acid ko identify karne ka ek common test hai. Bases iska opposite effect dikhate hain aur red litmus ko blue kar dete hain."
  },
  {
    question: "3. Bases red litmus paper ke colour ko kis colour mein change karte hain?",
    options: [
      "A. Blue",
      "B. Red",
      "C. Yellow",
      "D. Orange"
    ],
    correct: 0,
    explanation: "Bases red litmus ko blue kar dete hain. Isliye litmus ek natural indicator hai jo acidic aur basic substances ko identify karne mein help karta hai."
  },
  {
    question: "4. Inmein se kaunsa olfactory indicator ka example hai?",
    options: [
      "A. Litmus",
      "B. Methyl orange",
      "C. Onion",
      "D. Phenolphthalein"
    ],
    correct: 2,
    explanation: "Aise substances jinki odour acidic ya basic medium mein change ho jati hai, unhe olfactory indicators kehte hain. Onion, vanilla aur clove is type ke indicators ke examples hain."
  },
  {
    question: "5. Acid aur metal ki reaction mein generally kya products bante hain?",
    options: [
      "A. Salt + Water",
      "B. Salt + Hydrogen gas",
      "C. Base + Oxygen",
      "D. Carbon dioxide + Water"
    ],
    correct: 1,
    explanation: "Acid metals ke saath react karke generally salt aur hydrogen gas banata hai.<br><strong>Acid + Metal β†’ Salt + Hydrogen gas</strong>"
  },
  {
    question: "6. Zinc ko sodium hydroxide solution ke saath warm karne par kaunsi gas release hoti hai?",
    options: [
      "A. Oxygen",
      "B. Carbon dioxide",
      "C. Hydrogen",
      "D. Nitrogen"
    ],
    correct: 2,
    explanation: "Zinc sodium hydroxide ke saath react karke sodium zincate aur hydrogen gas banata hai:<br><strong>2NaOH + Zn β†’ Naβ‚‚ZnOβ‚‚ + Hβ‚‚</strong><br>Is reaction se pata chalta hai ki kuch metals bases ke saath bhi react kar sakte hain."
  },
  {
    question: "7. Metal carbonates aur metal hydrogencarbonates acids ke saath react karke kya produce karte hain?",
    options: [
      "A. Salt + Carbon dioxide + Water",
      "B. Salt + Hydrogen",
      "C. Base + Oxygen",
      "D. Only water"
    ],
    correct: 0,
    explanation: "Metal carbonate ya hydrogencarbonate acid ke saath react karta hai aur salt, carbon dioxide aur water banata hai.<br><strong>Metal carbonate/Metal hydrogencarbonate + Acid β†’ Salt + COβ‚‚ + Water</strong>"
  },
  {
    question: "8. Carbon dioxide gas ko lime water mein pass karne par kya observation hoti hai?",
    options: [
      "A. Lime water blue ho jata hai",
      "B. White precipitate form hota hai",
      "C. Hydrogen gas release hoti hai",
      "D. Lime water red ho jata hai"
    ],
    correct: 1,
    explanation: "COβ‚‚ ko lime water Ca(OH)β‚‚ mein pass karne par calcium carbonate (CaCO₃) ka insoluble white precipitate banta hai.<br><strong>Ca(OH)β‚‚ + COβ‚‚ β†’ CaCO₃ + Hβ‚‚O</strong>"
  },
  {
    question: "9. Acid aur base ki reaction jisme salt aur water bante hain, use kya kaha jata hai?",
    options: [
      "A. Displacement reaction",
      "B. Decomposition reaction",
      "C. Neutralisation reaction",
      "D. Combination reaction"
    ],
    correct: 2,
    explanation: "Acid aur base ek-doosre ke effect ko neutralise karke salt aur water banate hain. Example:<br><strong>NaOH + HCl β†’ NaCl + Hβ‚‚O</strong><br>General form: <strong>Base + Acid β†’ Salt + Water</strong>"
  },
  {
    question: "10. Metal oxide aur acid ki general reaction kya hoti hai?",
    options: [
      "A. Metal oxide + Acid β†’ Salt + Water",
      "B. Metal oxide + Acid β†’ Hydrogen + Salt",
      "C. Metal oxide + Acid β†’ Carbon dioxide + Water",
      "D. Metal oxide + Acid β†’ Only water"
    ],
    correct: 0,
    explanation: "Metallic oxides acids ke saath react karke salt aur water banate hain. Isi similar behaviour ke karan metallic oxides ko basic oxides kaha jata hai. Example: copper oxide aur hydrochloric acid ki reaction mein copper(II) chloride aur water bante 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