ch8 part 2
<!DOCTYPE html>
<html lang="en">
<head>
<title>🧠 Air and Its Composition 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>🧠 Air and Its Composition 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. Air kis type ka mixture hai?",
options: [
"A. Non-uniform mixture",
"B. Uniform mixture",
"C. Pure substance",
"D. Compound"
],
correct: 1,
explanation: "Air ek uniform mixture hai kyunki ismein nitrogen, oxygen, argon, carbon dioxide aur water vapour jaise gases evenly distributed hoti hain.<br><br><b>Example:</b> Air mein oxygen aur nitrogen alag-alag dikhai nahi deti, kyunki ye uniformly mixed hoti hain."
},
{
question: "2. Air mein sabse zyada kaunsi gas hoti hai?",
options: [
"A. Oxygen",
"B. Carbon dioxide",
"C. Nitrogen",
"D. Argon"
],
correct: 2,
explanation: "Air ka lagbhag 78% hissa nitrogen gas hoti hai. Nitrogen normal conditions mein combustion ko support nahi karti.<br><br><b>Example:</b> Agar kisi jalti hui candle ko aise environment mein rakha jaye jahan oxygen available na ho, toh candle jalti nahi rahegi."
},
{
question: "3. Most living beings ko alive rehne ke liye kaunsi gas chahiye?",
options: [
"A. Nitrogen",
"B. Oxygen",
"C. Argon",
"D. Carbon dioxide"
],
correct: 1,
explanation: "Most living beings ko respiration ke liye oxygen ki zaroorat hoti hai. Is process se body ko energy milti hai.<br><br><b>Example:</b> Humans saans lete waqt air se oxygen apne lungs mein lete hain."
},
{
question: "4. Combustion ko support karne wali gas kaunsi hai?",
options: [
"A. Nitrogen",
"B. Oxygen",
"C. Argon",
"D. Water vapour"
],
correct: 1,
explanation: "Combustion ka matlab burning ya jalne ki process hai. Oxygen burning ko support karti hai.<br><br><b>Example:</b> Burning candle ko glass se cover karne par kuch samay baad flame bujh jaati hai, kyunki available oxygen limited ho jaati hai."
},
{
question: "5. Air mein nitrogen lagbhag kitne percent hoti hai?",
options: [
"A. 21%",
"B. 50%",
"C. 78%",
"D. 100%"
],
correct: 2,
explanation: "Air mein approximately 78% nitrogen aur 21% oxygen hoti hai. Baaki lagbhag 1% mein argon, carbon dioxide aur other gases hoti hain.<br><br><b>Example:</b> Agar 100 litres air ka sample ho, toh usmein approximately 78 litres nitrogen hogi."
},
{
question: "6. Warm air jab cool surface ke contact mein aati hai, toh kya ho sakta hai?",
options: [
"A. Water vapour liquid droplets mein change ho sakti hai",
"B. Nitrogen solid ban jaati hai",
"C. Oxygen disappear ho jaati hai",
"D. Air pure water ban jaati hai"
],
correct: 0,
explanation: "Jab water vapour cool hoti hai, toh condensation hota hai. Is process mein water vapour liquid water ki tiny droplets mein change ho jaati hai.<br><br><b>Example:</b> Thandi water bottle ke outer surface par water droplets ban jaate hain."
},
{
question: "7. Lime water ko milky kaunsi gas banati hai?",
options: [
"A. Oxygen",
"B. Nitrogen",
"C. Carbon dioxide",
"D. Argon"
],
correct: 2,
explanation: "Carbon dioxide, calcium hydroxide ke saath react karke insoluble calcium carbonate banati hai. Calcium carbonate ke tiny white particles solution ko milky bana dete hain.<br><br><b>Example:</b> Jab exhaled air ko lime water se pass kiya jaata hai, toh carbon dioxide ki presence ke kaaran lime water milky ho sakta hai."
},
{
question: "8. Lime water ka chemical name kya hai?",
options: [
"A. Calcium carbonate solution",
"B. Calcium hydroxide solution",
"C. Calcium oxide solution",
"D. Sodium hydroxide solution"
],
correct: 1,
explanation: "Calcium oxide (quick lime) ko water ke saath react karane par calcium hydroxide banta hai. Iski solution ko lime water kehte hain.<br><br><b>Example:</b><br>Calcium oxide + Water → Calcium hydroxide + Heat."
},
{
question: "9. Lime water milky kyun ho jaata hai jab carbon dioxide usse react karti hai?",
options: [
"A. Oxygen ke bubbles banne ke kaaran",
"B. Nitrogen dissolve hone ke kaaran",
"C. Insoluble calcium carbonate banne ke kaaran",
"D. Water evaporate hone ke kaaran"
],
correct: 2,
explanation: "Carbon dioxide calcium hydroxide ke saath react karke calcium carbonate aur water banati hai. Calcium carbonate water mein insoluble hota hai, isliye tiny white particles milky appearance dete hain.<br><br><b>Example:</b><br>Calcium hydroxide + Carbon dioxide → Calcium carbonate + Water."
},
{
question: "10. Dark room mein sunlight ki beam ke andar tiny shining particles kyun dikhai dete hain?",
options: [
"A. Air mein suspended dust particles ke kaaran",
"B. Sirf oxygen ke kaaran",
"C. Sirf nitrogen ke kaaran",
"D. Sunlight mein water banne ke kaaran"
],
correct: 0,
explanation: "Air mein gases ke alawa dust aur other tiny particles bhi suspended ho sakte hain. Sunlight in particles par fall karti hai, jisse woh visible ho jaate hain.<br><br><b>Example:</b> Jab sunlight window ke chhote opening se dark room mein aati hai, toh uski beam mein dust particles move karte hue dikh sakte 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>