diff --git a/ananya_20233049/cquiz.html b/ananya_20233049/cquiz.html new file mode 100644 index 0000000..7747484 --- /dev/null +++ b/ananya_20233049/cquiz.html @@ -0,0 +1,33 @@ + + + + + + Quiz + + + + + + + +
+

Quiz!

+
+

Your Question is:

+
+ + + + +
+ + + +
+ + + + + + \ No newline at end of file diff --git a/ananya_20233049/dsa.html b/ananya_20233049/dsa.html new file mode 100644 index 0000000..3e83f05 --- /dev/null +++ b/ananya_20233049/dsa.html @@ -0,0 +1,32 @@ + + + + + + Quiz + + + + + + + +
+

Quiz!

+
+

Your Question is:

+
+ + + + +
+ + +
+ + + + + + \ No newline at end of file diff --git a/ananya_20233049/dsasc.js b/ananya_20233049/dsasc.js new file mode 100644 index 0000000..d27d8f0 --- /dev/null +++ b/ananya_20233049/dsasc.js @@ -0,0 +1,136 @@ +const questions=[ + { + question:"What is a data structure?", + answers:[ + {text:'A programming language',correct:false}, + {text:'A collection of algorithms',correct:false}, + {text:'A way to store and organize data',correct:true}, + {text:'A type of computer hardware',correct:false}, + ] + }, + { + question:" Which data structure is used for implementing recursion?", + answers:[ + {text:'queue',correct:false}, + {text:'stack',correct:true}, + {text:'vector',correct:false}, + {text:'array',correct:false}, + ] + }, + { + question:"The data structure required to check whether an expression contains a balanced parenthesis is?", + answers:[ + {text:'stack',correct:true}, + {text:'queue',correct:false}, + {text:'tree',correct:false}, + {text:'array',correct:false}, + ] + }, + { + question:"What is the value of the postfix expression 6 3 2 4 + – *?", + answers:[ + {text:'74',correct:false}, + {text:'-18',correct:true}, + {text:'-22',correct:false}, + {text:'40',correct:false}, + ] + }, + { + question:"The data structure required for Breadth First Traversal on a graph is?", + answers:[ + {text:'Tree',correct:false}, + {text:'Stack',correct:false}, + {text:'Queue',correct:true}, + {text:'Array',correct:false}, + ] + }, + { + question:"Which of the following is not the type of queue?", + answers:[ + {text:'priority queue',correct:false}, + {text:'circular queue',correct:false}, + {text:'single ended queue',correct:true}, + {text:'ordinary queue',correct:false}, + ] + }, +]; + + +const questionElement=document.getElementById("question"); +const answerButton=document.getElementById("answer-buttons"); +const nextButton=document.getElementById("next-btn"); +let curruentQuestionIndex=0; +let score=0; +function Gotohome(){ + window.location="index.html"; +} +function startQuiz(){ + curruentQuestionIndex=0; + score=0; + nextButton.innerHTML="Next"; + showQuestion(); +} + +function showQuestion(){ + resetState(); + let currentques=questions[curruentQuestionIndex]; + let questionno=curruentQuestionIndex+1; + questionElement.innerHTML=questionno +'.'+currentques.question; + currentques.answers.forEach(answer=>{ + const button=document.createElement("button"); + button.innerHTML=answer.text; + button.classList.add("btn"); + answerButton.appendChild(button); + if(answer.correct){ + button.dataset.correct=answer.correct; + } + button.addEventListener("click",selectAnswer); + }); +} +function resetState(){ + nextButton.style.display="none"; + while(answerButton.firstChild){ + answerButton.removeChild(answerButton.firstChild); + } +} +function selectAnswer(e){ + const selectedBtn=e.target; + const isCorrect=selectedBtn.dataset.correct==="true"; + if(isCorrect){ + selectedBtn.classList.add("correct"); + score++; + } + else{ + selectedBtn.classList.add("incorrect"); + } + Array.from(answerButton.children).forEach(button=>{ + if(button.dataset.correct==="true"){ + button.classList.add("correct"); + } + button.disabled=true; + }); + nextButton.style.display="inline"; +} +function showScore(){ + resetState(); + questionElement.innerHTML=`You scored ${score} out of ${questions.length}!`; + nextButton.innerHTML="Play Again"; + nextButton.style.display="inline"; +} +function handleNextButton(){ + curruentQuestionIndex++; + if(curruentQuestionIndex{ + if(curruentQuestionIndex + + + + + Quizzer + + + + + + + +
+

Welcome to the Quiz!

+ + + + + + \ No newline at end of file diff --git a/ananya_20233049/python.html b/ananya_20233049/python.html new file mode 100644 index 0000000..6983196 --- /dev/null +++ b/ananya_20233049/python.html @@ -0,0 +1,32 @@ + + + + + + Quiz + + + + + + + +
+

Quiz!

+
+

Your Question is:

+
+ + + + +
+ + +
+ + + + + + \ No newline at end of file diff --git a/ananya_20233049/pythonsc.js b/ananya_20233049/pythonsc.js new file mode 100644 index 0000000..3aca2a7 --- /dev/null +++ b/ananya_20233049/pythonsc.js @@ -0,0 +1,137 @@ +const questions=[ + { + question:" Which type of Programming does Python support?", + answers:[ + {text:'object-oriented programming',correct:false}, + {text:'structured programming',correct:false}, + {text:'functional programming',correct:false}, + {text:'All of the above',correct:true}, + ] + }, + { + question:"Is Python case sensitive when dealing with identifiers?", + answers:[ + {text:'No',correct:false}, + {text:'Yes',correct:true}, + {text:'Machine Dependent',correct:false}, + {text:'None',correct:false}, + ] + }, + { + question:"Is Python code compiled or interpreted?", + answers:[ + {text:'Python code is both compiled and interpreted',correct:true}, + {text:'Python code is neither compiled nor interpreted',correct:false}, + {text:'Python code is only compiled',correct:false}, + {text:'Python code is only interpreted',correct:false}, + ] + }, + { + question:"All keywords in Python are?", + answers:[ + {text:'Capitalized',correct:false}, + {text:'lower case',correct:false}, + {text:'UPPER case',correct:false}, + {text:'None',correct:true}, + ] + }, + { + question:"What does pip stand for python?", + answers:[ + {text:'Pip Installs Python',correct:false}, + {text:'Pip Installs Packages',correct:false}, + {text:'Preferred Installer Program',correct:true}, + {text:'All',correct:false}, + ] + }, + { + question:" Which of the following is the truncation division operator in Python?", + answers:[ + {text:'|',correct:false}, + {text:'*',correct:false}, + {text:'\\\\',correct:true}, + {text:'%',correct:false}, + ] + }, +]; + +const questionElement=document.getElementById("question"); +const answerButton=document.getElementById("answer-buttons"); +const nextButton=document.getElementById("next-btn"); +let curruentQuestionIndex=0; +let score=0; + +function Gotohome(){ + window.location="index.html"; +} + +function startQuiz(){ + curruentQuestionIndex=0; + score=0; + nextButton.innerHTML="Next"; + showQuestion(); +} + +function showQuestion(){ + resetState(); + let currentques=questions[curruentQuestionIndex]; + let questionno=curruentQuestionIndex+1; + questionElement.innerHTML=questionno +'.'+currentques.question; + currentques.answers.forEach(answer=>{ + const button=document.createElement("button"); + button.innerHTML=answer.text; + button.classList.add("btn"); + answerButton.appendChild(button); + if(answer.correct){ + button.dataset.correct=answer.correct; + } + button.addEventListener("click",selectAnswer); + }); +} +function resetState(){ + nextButton.style.display="none"; + while(answerButton.firstChild){ + answerButton.removeChild(answerButton.firstChild); + } +} +function selectAnswer(e){ + const selectedBtn=e.target; + const isCorrect=selectedBtn.dataset.correct==="true"; + if(isCorrect){ + selectedBtn.classList.add("correct"); + score++; + } + else{ + selectedBtn.classList.add("incorrect"); + } + Array.from(answerButton.children).forEach(button=>{ + if(button.dataset.correct==="true"){ + button.classList.add("correct"); + } + button.disabled=true; + }); + nextButton.style.display="inline"; +} +function showScore(){ + resetState(); + questionElement.innerHTML=`You scored ${score} out of ${questions.length}!`; + nextButton.innerHTML="Play Again"; + nextButton.style.display="inline"; +} +function handleNextButton(){ + curruentQuestionIndex++; + if(curruentQuestionIndex{ + if(curruentQuestionIndex{ + const button=document.createElement("button"); + button.innerHTML=answer.text; + button.classList.add("btn"); + answerButton.appendChild(button); + if(answer.correct){ + button.dataset.correct=answer.correct; + } + button.addEventListener("click",selectAnswer); + }); +} +function resetState(){ + nextButton.style.display="none"; + while(answerButton.firstChild){ + answerButton.removeChild(answerButton.firstChild); + } +} +function selectAnswer(e){ + const selectedBtn=e.target; + const isCorrect=selectedBtn.dataset.correct==="true"; + if(isCorrect){ + selectedBtn.classList.add("correct"); + score++; + } + else{ + selectedBtn.classList.add("incorrect"); + } + Array.from(answerButton.children).forEach(button=>{ + if(button.dataset.correct==="true"){ + button.classList.add("correct"); + } + button.disabled=true; + }); + nextButton.style.display="inline"; +} +function showScore(){ + resetState(); + questionElement.innerHTML=`You scored ${score} out of ${questions.length}!`; + nextButton.innerHTML="Play Again"; + nextButton.style.display="inline"; +} +function handleNextButton(){ + curruentQuestionIndex++; + if(curruentQuestionIndex{ + if(curruentQuestionIndex