From 91f28a345f9a66e323016e3bbef03917df255b0e Mon Sep 17 00:00:00 2001 From: tunny17 Date: Fri, 20 Oct 2023 02:06:58 +0000 Subject: [PATCH] CLASSROOMIO-T-197: Python Template Exercises Co-authored-by: Tunji Adeyemi Merge-request: CLASSROOMIO-MR-110 Merged-by: Best Admin --- src/lib/mocks/index.ts | 3 + src/lib/mocks/python/001_python_syntax.ts | 127 +++++++++++++++++ src/lib/mocks/python/002_python_comments.ts | 127 +++++++++++++++++ src/lib/mocks/python/003_python_variables.ts | 128 ++++++++++++++++++ src/lib/mocks/python/004_python_dataTypes.ts | 128 ++++++++++++++++++ src/lib/mocks/python/005_python_numbers.ts | 128 ++++++++++++++++++ src/lib/mocks/python/006_python_casting.ts | 126 +++++++++++++++++ src/lib/mocks/python/007_python_strings.ts | 128 ++++++++++++++++++ src/lib/mocks/python/008_python_booleans.ts | 124 +++++++++++++++++ src/lib/mocks/python/009_python_operators.ts | 122 +++++++++++++++++ src/lib/mocks/python/010_python_lists.ts | 123 +++++++++++++++++ src/lib/mocks/python/011_python_tuples.ts | 122 +++++++++++++++++ src/lib/mocks/python/012_python_sets.ts | 122 +++++++++++++++++ .../mocks/python/013_python_dictionaries.ts | 122 +++++++++++++++++ .../mocks/python/014_python_conditionals.ts | 122 +++++++++++++++++ src/lib/mocks/python/015_python_whileLoops.ts | 122 +++++++++++++++++ src/lib/mocks/python/016_python_forLoops.ts | 122 +++++++++++++++++ src/lib/mocks/python/017_python_functions.ts | 122 +++++++++++++++++ src/lib/mocks/python/018_python_lambda.ts | 121 +++++++++++++++++ src/lib/mocks/python/019_python_arrays.ts | 122 +++++++++++++++++ src/lib/mocks/python/020_python_classes.ts | 122 +++++++++++++++++ src/lib/mocks/python/index.ts | 66 +++++++++ 22 files changed, 2549 insertions(+) create mode 100644 src/lib/mocks/python/001_python_syntax.ts create mode 100644 src/lib/mocks/python/002_python_comments.ts create mode 100644 src/lib/mocks/python/003_python_variables.ts create mode 100644 src/lib/mocks/python/004_python_dataTypes.ts create mode 100644 src/lib/mocks/python/005_python_numbers.ts create mode 100644 src/lib/mocks/python/006_python_casting.ts create mode 100644 src/lib/mocks/python/007_python_strings.ts create mode 100644 src/lib/mocks/python/008_python_booleans.ts create mode 100644 src/lib/mocks/python/009_python_operators.ts create mode 100644 src/lib/mocks/python/010_python_lists.ts create mode 100644 src/lib/mocks/python/011_python_tuples.ts create mode 100644 src/lib/mocks/python/012_python_sets.ts create mode 100644 src/lib/mocks/python/013_python_dictionaries.ts create mode 100644 src/lib/mocks/python/014_python_conditionals.ts create mode 100644 src/lib/mocks/python/015_python_whileLoops.ts create mode 100644 src/lib/mocks/python/016_python_forLoops.ts create mode 100644 src/lib/mocks/python/017_python_functions.ts create mode 100644 src/lib/mocks/python/018_python_lambda.ts create mode 100644 src/lib/mocks/python/019_python_arrays.ts create mode 100644 src/lib/mocks/python/020_python_classes.ts create mode 100644 src/lib/mocks/python/index.ts diff --git a/src/lib/mocks/index.ts b/src/lib/mocks/index.ts index bde22c84..fe13f4df 100644 --- a/src/lib/mocks/index.ts +++ b/src/lib/mocks/index.ts @@ -9,6 +9,7 @@ import { TS_IDS, TS_TEMPLATES } from './typescript'; import { PHP_IDS, PHP_TEMPLATES } from './php'; import { VUE_IDS, VUE_TEMPLATES } from './vue'; import { GIT_IDS, GIT_TEMPLATES } from './git'; +import { PYTHON_IDS, PYTHON_TEMPLATES } from './python'; export const TAGS = { HTML: 'HTML', @@ -18,6 +19,7 @@ export const TAGS = { ReactJS: 'ReactJS', VueJS: 'VueJS', NodeJS: 'NodeJS', + Python: 'Python', PHP: 'PHP', GIT: 'GIT' }; @@ -56,6 +58,7 @@ export const TEMPLATES = { [TAGS.ReactJS]: generateTemplateForTag(REACT_IDS, REACT_TEMPLATES), [TAGS.VueJS]: generateTemplateForTag(VUE_IDS, VUE_TEMPLATES), [TAGS.NodeJS]: generateTemplateForTag(NODE_IDS, NODE_TEMPLATES), + [TAGS.Python]: generateTemplateForTag(PYTHON_IDS, PYTHON_TEMPLATES), [TAGS.PHP]: generateTemplateForTag(PHP_IDS, PHP_TEMPLATES), [TAGS.GIT]: generateTemplateForTag(GIT_IDS, GIT_TEMPLATES) }; diff --git a/src/lib/mocks/python/001_python_syntax.ts b/src/lib/mocks/python/001_python_syntax.ts new file mode 100644 index 00000000..300a9dfe --- /dev/null +++ b/src/lib/mocks/python/001_python_syntax.ts @@ -0,0 +1,127 @@ +import { QuestionTypes } from '../utils'; + +import type { ExerciseTemplate } from '$lib/utils/types'; + +const template: ExerciseTemplate = { + title: 'Python Syntax Quiz', + description: 'Test your knowledge of Python syntax', + questionnaire: { + questions: [ + { + title: 'What is Python used for?', + name: 'question1', + points: 2, + order: 0, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Web development', is_correct: false }, + { label: 'Data analysis', is_correct: false }, + { label: 'All of the above', is_correct: true }, + ], + }, + { + title: 'What symbol is used for comments in Python?', + name: 'question2', + points: 2, + order: 1, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '#', is_correct: true }, + { label: '//', is_correct: false }, + { label: '--', is_correct: false }, + ], + }, + { + title: 'How do you declare a variable in Python?', + name: 'question3', + points: 2, + order: 2, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'var x;', is_correct: false }, + { label: 'let x;', is_correct: false }, + { label: 'x = 5', is_correct: true }, + ], + }, + { + title: 'What is the correct way to print "Hello, World!" in Python?', + name: 'question4', + points: 2, + order: 3, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: 'print("Hello, World!")', is_correct: true }, + { label: 'echo("Hello, World!")', is_correct: false }, + { label: 'console.log("Hello, World!")', is_correct: false }, + { label: 'System.out.println("Hello, World!")', is_correct: false }, + ], + }, + { + title: 'Explain the purpose of "if" statements in Python.', + name: 'question5', + points: 2, + order: 4, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'What is the correct way to define a function in Python?', + name: 'question6', + points: 2, + order: 5, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'function myFunction():', is_correct: false }, + { label: 'def myFunction():', is_correct: true }, + { label: 'method myFunction():', is_correct: false }, + ], + }, + { + title: 'Which operator is used for exponentiation in Python?', + name: 'question7', + points: 2, + order: 6, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '^', is_correct: false }, + { label: '**', is_correct: true }, + { label: '^^', is_correct: false }, + ], + }, + { + title: 'What is the correct way to create a list in Python?', + name: 'question8', + points: 2, + order: 7, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '[1, 2, 3]', is_correct: true }, + { label: '(1, 2, 3)', is_correct: false }, + { label: '{1, 2, 3}', is_correct: false }, + ], + }, + { + title: 'Explain the purpose of "for" loops in Python.', + name: 'question9', + points: 2, + order: 8, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'How do you check the length of a list in Python?', + name: 'question10', + points: 2, + order: 9, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: 'len(myList)', is_correct: true }, + { label: 'myList.length', is_correct: false }, + { label: 'size(myList)', is_correct: false }, + ], + }, + ], + }, +}; + +export default template; diff --git a/src/lib/mocks/python/002_python_comments.ts b/src/lib/mocks/python/002_python_comments.ts new file mode 100644 index 00000000..5d5c64b5 --- /dev/null +++ b/src/lib/mocks/python/002_python_comments.ts @@ -0,0 +1,127 @@ +import { QuestionTypes } from '../utils'; + +import type { ExerciseTemplate } from '$lib/utils/types'; + +const template: ExerciseTemplate = { + title: 'Python Comments Quiz', + description: 'Test your knowledge of Python comments', + questionnaire: { + questions: [ + { + title: 'What is the purpose of comments in Python?', + name: 'question1', + points: 2, + order: 0, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'To add color to your code', is_correct: false }, + { label: 'To explain the code and make it more readable', is_correct: true }, + { label: 'To hide code from others', is_correct: false }, + ], + }, + { + title: 'Which symbol is used to start a single-line comment in Python?', + name: 'question2', + points: 2, + order: 1, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '//', is_correct: false }, + { label: '/*', is_correct: false }, + { label: '#', is_correct: true }, + ], + }, + { + title: 'How do you write a multi-line comment in Python?', + name: 'question3', + points: 2, + order: 2, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '/* This is a comment */', is_correct: false }, + { label: '// This is a comment //', is_correct: false }, + { label: '""" This is a comment """', is_correct: true }, + ], + }, + { + title: 'What is the correct way to comment out a single line of code in Python?', + name: 'question4', + points: 2, + order: 3, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: 'Using a hash symbol (#)', is_correct: true }, + { label: 'Using double slashes (//)', is_correct: false }, + { label: 'Using triple quotes (\'\'\')', is_correct: false }, + ], + }, + { + title: 'Explain the purpose of docstrings in Python.', + name: 'question5', + points: 2, + order: 4, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'What is the main purpose of writing comments in your code?', + name: 'question6', + points: 2, + order: 5, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'To increase the size of your code', is_correct: false }, + { label: 'To make your code look more colorful', is_correct: false }, + { label: 'To make the code understandable for you and others', is_correct: true }, + ], + }, + { + title: 'How can you comment out multiple lines of code in Python?', + name: 'question7', + points: 2, + order: 6, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: 'Using a hash symbol (#)', is_correct: false }, + { label: 'Using triple quotes (\'\'\')', is_correct: true }, + { label: 'Using double slashes (//)', is_correct: false }, + ], + }, + { + title: 'What is the purpose of triple-quoted strings in Python?', + name: 'question8', + points: 2, + order: 7, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'To define a string that spans multiple lines', is_correct: true }, + { label: 'To make your code more colorful', is_correct: false }, + { label: 'To indicate the end of a Python program', is_correct: false }, + ], + }, + { + title: 'Explain the purpose of inline comments in Python.', + name: 'question9', + points: 2, + order: 8, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'Which type of comment is used for documenting functions, classes, and modules in Python?', + name: 'question10', + points: 2, + order: 9, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Single-line comments', is_correct: false }, + { label: 'Multi-line comments', is_correct: false }, + { label: 'Docstrings', is_correct: true }, + ], + }, + ], + }, +}; + + +export default template; diff --git a/src/lib/mocks/python/003_python_variables.ts b/src/lib/mocks/python/003_python_variables.ts new file mode 100644 index 00000000..a8df025a --- /dev/null +++ b/src/lib/mocks/python/003_python_variables.ts @@ -0,0 +1,128 @@ +import { QuestionTypes } from '../utils'; + +import type { ExerciseTemplate } from '$lib/utils/types'; + +const template: ExerciseTemplate = { + title: 'Python Variables Quiz', + description: 'Test your knowledge of Python variables', + questionnaire: { + questions: [ + { + title: 'What is a variable in Python?', + name: 'question1', + points: 2, + order: 0, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'A reserved keyword', is_correct: false }, + { label: 'A container for storing data', is_correct: true }, + { label: 'A function in Python', is_correct: false }, + ], + }, + { + title: 'How do you declare a variable in Python?', + name: 'question2', + points: 2, + order: 1, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'var x;', is_correct: false }, + { label: 'x = 5', is_correct: true }, + { label: 'let x;', is_correct: false }, + ], + }, + { + title: 'What is the correct way to comment a variable declaration in Python?', + name: 'question3', + points: 2, + order: 2, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '/* This is a comment */', is_correct: false }, + { label: '# This is a comment', is_correct: true }, + { label: '// This is a comment', is_correct: false }, + ], + }, + { + title: 'What is a valid variable name in Python?', + name: 'question4', + points: 2, + order: 3, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: '123variable', is_correct: false }, + { label: 'my_variable', is_correct: true }, + { label: 'variable@name', is_correct: false }, + { label: '_variable', is_correct: true }, + ], + }, + { + title: 'Explain the purpose of variable names in Python.', + name: 'question5', + points: 2, + order: 4, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'How do you assign a value to a variable in Python?', + name: 'question6', + points: 2, + order: 5, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'x = value', is_correct: true }, + { label: 'assign(x, value)', is_correct: false }, + { label: 'set x to value', is_correct: false }, + ], + }, + { + title: 'Which data types are supported by Python variables?', + name: 'question7', + points: 2, + order: 6, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: 'Number', is_correct: true }, + { label: 'Boolean', is_correct: true }, + { label: 'Array', is_correct: false }, + { label: 'Object', is_correct: false }, + ], + }, + { + title: 'What is the scope of a variable in Python?', + name: 'question8', + points: 2, + order: 7, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Local scope', is_correct: true }, + { label: 'Global scope', is_correct: true }, + { label: 'Function scope', is_correct: false }, + ], + }, + { + title: 'Explain the purpose of variable assignment in Python.', + name: 'question9', + points: 2, + order: 8, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'How do you check the data type of a variable in Python?', + name: 'question10', + points: 2, + order: 9, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: 'type()', is_correct: true }, + { label: 'typeof', is_correct: false }, + { label: 'isinstance()', is_correct: true }, + ], + }, + ], + }, +}; + +export default template; diff --git a/src/lib/mocks/python/004_python_dataTypes.ts b/src/lib/mocks/python/004_python_dataTypes.ts new file mode 100644 index 00000000..18f2d5f2 --- /dev/null +++ b/src/lib/mocks/python/004_python_dataTypes.ts @@ -0,0 +1,128 @@ +import { QuestionTypes } from '../utils'; + +import type { ExerciseTemplate } from '$lib/utils/types'; + +const template: ExerciseTemplate = { + title: 'Python Data Types Quiz', + description: 'Test your knowledge of Python data types', + questionnaire: { + questions: [ + { + title: 'What is a data type in Python?', + name: 'question1', + points: 2, + order: 0, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'A type of snake', is_correct: false }, + { label: 'A classification of data', is_correct: true }, + { label: 'A Python function', is_correct: false }, + ], + }, + { + title: 'How do you declare a variable with the "int" data type in Python?', + name: 'question2', + points: 2, + order: 1, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'var x: int', is_correct: false }, + { label: 'int x', is_correct: true }, + { label: 'x = int', is_correct: false }, + ], + }, + { + title: 'Which of the following is a valid variable name in Python?', + name: 'question3', + points: 2, + order: 2, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: '123variable', is_correct: false }, + { label: 'my_variable', is_correct: true }, + { label: 'variable@name', is_correct: false }, + { label: '_variable', is_correct: true }, + ], + }, + { + title: 'What is the purpose of the "str" data type in Python?', + name: 'question4', + points: 2, + order: 3, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'To store integers', is_correct: false }, + { label: 'To store strings', is_correct: true }, + { label: 'To store floating-point numbers', is_correct: false }, + ], + }, + { + title: 'Explain the purpose of data types in Python.', + name: 'question5', + points: 2, + order: 4, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'Which data type is used to store a sequence of items in Python?', + name: 'question6', + points: 2, + order: 5, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'int', is_correct: false }, + { label: 'str', is_correct: false }, + { label: 'list', is_correct: true }, + ], + }, + { + title: 'How do you check the data type of a variable in Python?', + name: 'question7', + points: 2, + order: 6, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'typeof()', is_correct: false }, + { label: 'type()', is_correct: true }, + { label: 'datatype()', is_correct: false }, + ], + }, + { + title: 'Which data type is used to store a single character in Python?', + name: 'question8', + points: 2, + order: 7, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'char', is_correct: false }, + { label: 'str', is_correct: false }, + { label: 'chr', is_correct: true }, + ], + }, + { + title: 'What is the "bool" data type used for in Python?', + name: 'question9', + points: 2, + order: 8, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'Which data type is used to store a collection of items in Python?', + name: 'question10', + points: 2, + order: 9, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: 'tuple', is_correct: true }, + { label: 'set', is_correct: true }, + { label: 'dict', is_correct: true }, + { label: 'str', is_correct: false }, + ], + }, + ], + }, +}; + +export default template; diff --git a/src/lib/mocks/python/005_python_numbers.ts b/src/lib/mocks/python/005_python_numbers.ts new file mode 100644 index 00000000..12594e0e --- /dev/null +++ b/src/lib/mocks/python/005_python_numbers.ts @@ -0,0 +1,128 @@ +import { QuestionTypes } from '../utils'; + +import type { ExerciseTemplate } from '$lib/utils/types'; + +const template: ExerciseTemplate = { + title: 'Python Numbers Quiz', + description: 'Test your knowledge of Python numbers', + questionnaire: { + questions: [ + { + title: 'What is the main purpose of numbers in Python?', + name: 'question1', + points: 2, + order: 0, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'To add color to your code', is_correct: false }, + { label: 'To perform mathematical operations', is_correct: true }, + { label: 'To create text strings', is_correct: false }, + ], + }, + { + title: 'Which of the following is not a valid numeric data type in Python?', + name: 'question2', + points: 2, + order: 1, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: 'int', is_correct: true }, + { label: 'float', is_correct: true }, + { label: 'str', is_correct: false }, + { label: 'char', is_correct: false }, + ], + }, + { + title: 'How do you declare a floating-point number in Python?', + name: 'question3', + points: 2, + order: 2, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'x = 5', is_correct: false }, + { label: 'float x', is_correct: false }, + { label: 'x = 5.0', is_correct: true }, + ], + }, + { + title: 'What is the result of 5 + 2 in Python?', + name: 'question4', + points: 2, + order: 3, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '7', is_correct: true }, + { label: '52', is_correct: false }, + { label: '25', is_correct: false }, + ], + }, + { + title: 'Explain the purpose of numeric data types in Python.', + name: 'question5', + points: 2, + order: 4, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'Which operator is used for exponentiation in Python?', + name: 'question6', + points: 2, + order: 5, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '^', is_correct: false }, + { label: '**', is_correct: true }, + { label: '^^', is_correct: false }, + ], + }, + { + title: 'What is the result of 10 / 3 in Python?', + name: 'question7', + points: 2, + order: 6, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '3.333', is_correct: false }, + { label: '3.0', is_correct: false }, + { label: '3', is_correct: true }, + ], + }, + { + title: 'What is the purpose of the "complex" data type in Python?', + name: 'question8', + points: 2, + order: 7, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'To store complex numbers', is_correct: true }, + { label: 'To represent text', is_correct: false }, + { label: 'To handle exceptions', is_correct: false }, + ], + }, + { + title: 'Explain the purpose of mathematical operators in Python.', + name: 'question9', + points: 2, + order: 8, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'Which operator is used to find the remainder of a division in Python?', + name: 'question10', + points: 2, + order: 9, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: '%', is_correct: true }, + { label: '/', is_correct: false }, + { label: '*', is_correct: false }, + { label: '//', is_correct: false }, + ], + }, + ], + }, +}; + +export default template; diff --git a/src/lib/mocks/python/006_python_casting.ts b/src/lib/mocks/python/006_python_casting.ts new file mode 100644 index 00000000..d41e66d4 --- /dev/null +++ b/src/lib/mocks/python/006_python_casting.ts @@ -0,0 +1,126 @@ +import { QuestionTypes } from '../utils'; + +import type { ExerciseTemplate } from '$lib/utils/types'; + +const template: ExerciseTemplate = { + title: 'Python Casting Quiz', + description: 'Test your knowledge of Python casting', + questionnaire: { + questions: [ + { + title: 'What is type casting in Python?', + name: 'question1', + points: 2, + order: 0, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Casting spells in Python', is_correct: false }, + { label: 'Changing the data type of a value', is_correct: true }, + { label: 'Type checking in Python', is_correct: false }, + ], + }, + { + title: 'How do you perform type casting in Python?', + name: 'question2', + points: 2, + order: 1, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Using the "cast" keyword', is_correct: false }, + { label: 'Using the "to" keyword', is_correct: false }, + { label: 'By specifying the target data type', is_correct: true }, + ], + }, + { + title: 'What is the result of casting "3.14" to an integer in Python?', + name: 'question3', + points: 2, + order: 2, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '3.14', is_correct: false }, + { label: '3', is_correct: true }, + { label: '14', is_correct: false }, + ], + }, + { + title: 'Explain the purpose of type casting in Python.', + name: 'question4', + points: 2, + order: 3, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'Which casting function is used to convert a value to a floating-point number?', + name: 'question5', + points: 2, + order: 4, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'float()', is_correct: true }, + { label: 'int()', is_correct: false }, + { label: 'str()', is_correct: false }, + ], + }, + { + title: 'What happens if you try to cast a string that is not a valid number to an integer?', + name: 'question6', + points: 2, + order: 5, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'It becomes a valid integer', is_correct: false }, + { label: 'An error occurs', is_correct: true }, + { label: 'It becomes a float', is_correct: false }, + ], + }, + { + title: 'Which casting function is used to convert a value to an integer in Python?', + name: 'question7', + points: 2, + order: 6, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'int()', is_correct: true }, + { label: 'float()', is_correct: false }, + { label: 'str()', is_correct: false }, + ], + }, + { + title: 'Explain the concept of implicit type casting in Python.', + name: 'question8', + points: 2, + order: 7, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'What happens if you try to cast a floating-point number to an integer using int()?', + name: 'question9', + points: 2, + order: 8, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'It becomes a string', is_correct: false }, + { label: 'It becomes a float', is_correct: false }, + { label: 'The decimal part is truncated', is_correct: true }, + ], + }, + { + title: 'Which casting function is used to convert a value to a string in Python?', + name: 'question10', + points: 2, + order: 9, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'str()', is_correct: true }, + { label: 'int()', is_correct: false }, + { label: 'float()', is_correct: false }, + ], + }, + ], + }, +}; + +export default template; diff --git a/src/lib/mocks/python/007_python_strings.ts b/src/lib/mocks/python/007_python_strings.ts new file mode 100644 index 00000000..65bbdf32 --- /dev/null +++ b/src/lib/mocks/python/007_python_strings.ts @@ -0,0 +1,128 @@ +import { QuestionTypes } from '../utils'; + +import type { ExerciseTemplate } from '$lib/utils/types'; + +const template: ExerciseTemplate = { + title: 'Python Strings Quiz', + description: 'Test your knowledge of Python strings', + questionnaire: { + questions: [ + { + title: 'What is a string in Python?', + name: 'question1', + points: 2, + order: 0, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'A sequence of numbers', is_correct: false }, + { label: 'A sequence of characters', is_correct: true }, + { label: 'A data type in Python', is_correct: false }, + ], + }, + { + title: 'How do you declare a string in Python?', + name: 'question2', + points: 2, + order: 1, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'str x', is_correct: false }, + { label: 'x = "Hello"', is_correct: true }, + { label: 'string x', is_correct: false }, + ], + }, + { + title: 'Which of the following is a valid string declaration in Python?', + name: 'question3', + points: 2, + order: 2, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: 'x = "Hello, World!"', is_correct: true }, + { label: 'x = 42', is_correct: false }, + { label: 'x = \'Python\'', is_correct: true }, + { label: 'x = True', is_correct: false }, + ], + }, + { + title: 'How do you access characters in a string in Python?', + name: 'question4', + points: 2, + order: 3, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Using parentheses', is_correct: false }, + { label: 'By index', is_correct: true }, + { label: 'Using curly braces', is_correct: false }, + ], + }, + { + title: 'Explain the concept of string concatenation in Python.', + name: 'question5', + points: 2, + order: 4, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'Which operator is used for string concatenation in Python?', + name: 'question6', + points: 2, + order: 5, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '+', is_correct: true }, + { label: '-', is_correct: false }, + { label: '*', is_correct: false }, + ], + }, + { + title: 'What is the result of "Hello" * 3 in Python?', + name: 'question7', + points: 2, + order: 6, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'HelloHelloHello', is_correct: true }, + { label: 'HelloHello', is_correct: false }, + { label: '333', is_correct: false }, + ], + }, + { + title: 'What is the purpose of string methods in Python?', + name: 'question8', + points: 2, + order: 7, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'How do you check the length of a string in Python?', + name: 'question9', + points: 2, + order: 8, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'len(string)', is_correct: true }, + { label: 'string.length', is_correct: false }, + { label: 'string.len()', is_correct: false }, + ], + }, + { + title: 'Which method is used to remove whitespace from the beginning and end of a string in Python?', + name: 'question10', + points: 2, + order: 9, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: 'strip()', is_correct: true }, + { label: 'trim()', is_correct: false }, + { label: 'clean()', is_correct: false }, + { label: 'clear()', is_correct: false }, + ], + }, + ], + }, +}; + +export default template; diff --git a/src/lib/mocks/python/008_python_booleans.ts b/src/lib/mocks/python/008_python_booleans.ts new file mode 100644 index 00000000..5a81081a --- /dev/null +++ b/src/lib/mocks/python/008_python_booleans.ts @@ -0,0 +1,124 @@ +import { QuestionTypes } from '../utils'; + +import type { ExerciseTemplate } from '$lib/utils/types'; + +const template: ExerciseTemplate = { + title: 'Python Booleans Quiz', + description: 'Test your knowledge of Python booleans', + questionnaire: { + questions: [ + { + title: 'What is a boolean in Python?', + name: 'question1', + points: 2, + order: 0, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'A data type for representing true and false values', is_correct: true }, + { label: 'A numeric data type', is_correct: false }, + { label: 'A string data type', is_correct: false }, + ], + }, + { + title: 'Which of the following values is a valid boolean value in Python?', + name: 'question2', + points: 2, + order: 1, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: '0', is_correct: false }, + { label: 'True', is_correct: true }, + { label: 'False', is_correct: true }, + { label: '1', is_correct: false }, + ], + }, + { + title: 'What is the result of the expression "10 > 5" in Python?', + name: 'question3', + points: 2, + order: 2, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'True', is_correct: true }, + { label: 'False', is_correct: false }, + ], + }, + { + title: 'Explain the concept of boolean operators in Python.', + name: 'question4', + points: 2, + order: 3, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'Which operator is used for logical AND in Python?', + name: 'question5', + points: 2, + order: 4, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '&&', is_correct: false }, + { label: 'and', is_correct: true }, + { label: '||', is_correct: false }, + ], + }, + { + title: 'What is the result of "True and False" in Python?', + name: 'question6', + points: 2, + order: 5, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'True', is_correct: false }, + { label: 'False', is_correct: true }, + ], + }, + { + title: 'Which operator is used for logical OR in Python?', + name: 'question7', + points: 2, + order: 6, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '||', is_correct: false }, + { label: 'or', is_correct: true }, + { label: '&&', is_correct: false }, + ], + }, + { + title: 'Explain the concept of truthy and falsy values in Python.', + name: 'question8', + points: 2, + order: 7, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'What is the result of "not True" in Python?', + name: 'question9', + points: 2, + order: 8, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'True', is_correct: false }, + { label: 'False', is_correct: true }, + ], + }, + { + title: 'Which operator is used for logical NOT in Python?', + name: 'question10', + points: 2, + order: 9, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'not', is_correct: true }, + { label: '!', is_correct: false }, + { label: 'and', is_correct: false }, + ], + }, + ], + }, +}; + +export default template; diff --git a/src/lib/mocks/python/009_python_operators.ts b/src/lib/mocks/python/009_python_operators.ts new file mode 100644 index 00000000..4827d403 --- /dev/null +++ b/src/lib/mocks/python/009_python_operators.ts @@ -0,0 +1,122 @@ +import { QuestionTypes } from '../utils'; + +import type { ExerciseTemplate } from '$lib/utils/types'; + +const template: ExerciseTemplate = { + title: 'Python Operators Quiz', + description: 'Test your knowledge of Python operators', + questionnaire: { + questions: [ + { + title: 'What is the result of 5 + 3 in Python?', + name: 'question1', + points: 2, + order: 0, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '8', is_correct: true }, + { label: '53', is_correct: false }, + { label: '35', is_correct: false }, + ], + }, + { + title: 'Which operator is used for exponentiation in Python?', + name: 'question2', + points: 2, + order: 1, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '**', is_correct: true }, + { label: '^', is_correct: false }, + { label: '^^', is_correct: false }, + ], + }, + { + title: 'What is the result of 10 / 2 in Python?', + name: 'question3', + points: 2, + order: 2, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '5.0', is_correct: true }, + { label: '5', is_correct: false }, + { label: '2.5', is_correct: false }, + ], + }, + { + title: 'Explain the concept of operator precedence in Python.', + name: 'question4', + points: 2, + order: 3, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'Which operator is used to calculate the remainder of a division in Python?', + name: 'question5', + points: 2, + order: 4, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '%', is_correct: true }, + { label: 'remainder', is_correct: false }, + { label: 'remainderOf', is_correct: false }, + ], + }, + { + title: 'What is the result of 2 * 3 in Python?', + name: 'question6', + points: 2, + order: 5, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '6', is_correct: true }, + { label: '23', is_correct: false }, + { label: '32', is_correct: false }, + ], + }, + { + title: 'Explain the concept of logical operators in Python.', + name: 'question7', + points: 2, + order: 6, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'What is the result of "Hello" + " " + "World" in Python?', + name: 'question8', + points: 2, + order: 7, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'HelloWorld', is_correct: false }, + { label: 'Hello World', is_correct: true }, + { label: '"Hello World"', is_correct: false }, + ], + }, + { + title: 'Which operator is used for string repetition in Python?', + name: 'question9', + points: 2, + order: 8, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '*', is_correct: true }, + { label: '+', is_correct: false }, + { label: '++', is_correct: false }, + ], + }, + { + title: 'Explain the concept of membership operators in Python.', + name: 'question10', + points: 2, + order: 9, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + ], + }, +}; + +export default template; diff --git a/src/lib/mocks/python/010_python_lists.ts b/src/lib/mocks/python/010_python_lists.ts new file mode 100644 index 00000000..929e24b5 --- /dev/null +++ b/src/lib/mocks/python/010_python_lists.ts @@ -0,0 +1,123 @@ +import { QuestionTypes } from '../utils'; + +import type { ExerciseTemplate } from '$lib/utils/types'; + +const template: ExerciseTemplate = { + title: 'Python Lists Quiz', + description: 'Test your knowledge of Python lists', + questionnaire: { + questions: [ + { + title: 'What is a Python list?', + name: 'question1', + points: 2, + order: 0, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'A data structure that stores elements of the same type', is_correct: false }, + { label: 'An ordered collection of elements, which can be of any type', is_correct: true }, + { label: 'A string with comma-separated values', is_correct: false }, + ], + }, + { + title: 'How do you declare an empty list in Python?', + name: 'question2', + points: 2, + order: 1, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'list x = []', is_correct: false }, + { label: 'x = list()', is_correct: true }, + { label: 'list x', is_correct: false }, + ], + }, + { + title: 'Which of the following is a valid list declaration in Python?', + name: 'question3', + points: 2, + order: 2, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: 'mylist = [1, 2, 3]', is_correct: true }, + { label: 'mylist = (1, 2, 3)', is_correct: false }, + { label: 'mylist = 1, 2, 3', is_correct: false }, + { label: 'mylist = [\'apple\', \'banana\', \'cherry\']', is_correct: true }, + ], + }, + { + title: 'Explain the concept of list indexing in Python.', + name: 'question4', + points: 2, + order: 3, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'How do you add an item to the end of a list in Python?', + name: 'question5', + points: 2, + order: 4, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'add()', is_correct: false }, + { label: 'append()', is_correct: true }, + { label: 'insert()', is_correct: false }, + ], + }, + { + title: 'What is the result of ["apple", "banana"] + ["cherry", "date"] in Python?', + name: 'question6', + points: 2, + order: 5, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: "['apple', 'banana', 'cherry', 'date']", is_correct: true }, + { label: "['apple', 'banana'] ['cherry', 'date']", is_correct: false }, + { label: "['apple', 'banana', ['cherry', 'date']]", is_correct: false }, + ], + }, + { + title: 'Explain the concept of list methods in Python.', + name: 'question7', + points: 2, + order: 6, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'What is the result of [1, 2, 3, 4, 5][1:4] in Python?', + name: 'question8', + points: 2, + order: 7, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '[2, 3, 4]', is_correct: true }, + { label: '[1, 2, 3]', is_correct: false }, + { label: '[1, 2, 3, 4, 5]', is_correct: false }, + ], + }, + { + title: 'How do you remove an item from a list in Python?', + name: 'question9', + points: 2, + order: 8, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'remove()', is_correct: false }, + { label: 'delete()', is_correct: false }, + { label: 'pop()', is_correct: true }, + ], + }, + { + title: 'Explain the concept of list comprehension in Python.', + name: 'question10', + points: 2, + order: 9, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + ], + }, +}; + +export default template; diff --git a/src/lib/mocks/python/011_python_tuples.ts b/src/lib/mocks/python/011_python_tuples.ts new file mode 100644 index 00000000..a1a2ebde --- /dev/null +++ b/src/lib/mocks/python/011_python_tuples.ts @@ -0,0 +1,122 @@ +import { QuestionTypes } from '../utils'; + +import type { ExerciseTemplate } from '$lib/utils/types'; + +const template: ExerciseTemplate = { + title: 'Python Tuples Quiz', + description: 'Test your knowledge of Python tuples', + questionnaire: { + questions: [ + { + title: 'What is a Python tuple?', + name: 'question1', + points: 2, + order: 0, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'An ordered collection of elements that can be modified', is_correct: false }, + { label: 'An ordered collection of elements that cannot be modified', is_correct: true }, + { label: 'A list with different syntax', is_correct: false }, + ], + }, + { + title: 'How do you declare a Python tuple?', + name: 'question2', + points: 2, + order: 1, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'tuple x = (1, 2, 3)', is_correct: false }, + { label: 'x = (1, 2, 3)', is_correct: true }, + { label: 'x = tuple(1, 2, 3)', is_correct: false }, + ], + }, + { + title: 'Which of the following is a valid tuple declaration in Python?', + name: 'question3', + points: 2, + order: 2, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: 'mytuple = (1, 2, 3)', is_correct: true }, + { label: 'mytuple = [1, 2, 3]', is_correct: false }, + { label: 'mytuple = (\'apple\', \'banana\', \'cherry\')', is_correct: true }, + ], + }, + { + title: 'Explain the concept of immutability of tuples in Python.', + name: 'question4', + points: 2, + order: 3, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'How do you access elements in a tuple in Python?', + name: 'question5', + points: 2, + order: 4, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'By index using square brackets', is_correct: true }, + { label: 'By using dot notation', is_correct: false }, + { label: 'By using curly braces', is_correct: false }, + ], + }, + { + title: 'What is the result of (1, 2, 3) + (4, 5, 6) in Python?', + name: 'question6', + points: 2, + order: 5, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '(1, 2, 3, 4, 5, 6)', is_correct: true }, + { label: '10', is_correct: false }, + { label: '(10, 15, 21)', is_correct: false }, + ], + }, + { + title: 'Explain the concept of tuple methods in Python.', + name: 'question7', + points: 2, + order: 6, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'How do you check if an item is present in a tuple in Python?', + name: 'question8', + points: 2, + order: 7, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'By using the `contains` keyword', is_correct: false }, + { label: 'Using the `in` keyword', is_correct: true }, + { label: 'By using a loop', is_correct: false }, + ], + }, + { + title: 'What is the result of (1, 2, 3).count(2) in Python?', + name: 'question9', + points: 2, + order: 8, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '2', is_correct: false }, + { label: '3', is_correct: false }, + { label: '1', is_correct: true }, + ], + }, + { + title: 'Explain the concept of tuple unpacking in Python.', + name: 'question10', + points: 2, + order: 9, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + ], + }, +}; + +export default template; diff --git a/src/lib/mocks/python/012_python_sets.ts b/src/lib/mocks/python/012_python_sets.ts new file mode 100644 index 00000000..5e100afc --- /dev/null +++ b/src/lib/mocks/python/012_python_sets.ts @@ -0,0 +1,122 @@ +import { QuestionTypes } from '../utils'; + +import type { ExerciseTemplate } from '$lib/utils/types'; + +const template: ExerciseTemplate = { + title: 'Python Sets Quiz', + description: 'Test your knowledge of Python sets', + questionnaire: { + questions: [ + { + title: 'What is a Python set?', + name: 'question1', + points: 2, + order: 0, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'An ordered collection of elements', is_correct: false }, + { label: 'An unordered collection of unique elements', is_correct: true }, + { label: 'A list with duplicate elements', is_correct: false }, + ], + }, + { + title: 'How do you declare a Python set?', + name: 'question2', + points: 2, + order: 1, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'set x = {1, 2, 3}', is_correct: false }, + { label: 'x = {1, 2, 3}', is_correct: true }, + { label: 'x = set(1, 2, 3)', is_correct: false }, + ], + }, + { + title: 'Which of the following is a valid set declaration in Python?', + name: 'question3', + points: 2, + order: 2, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: 'myset = {1, 2, 3}', is_correct: true }, + { label: 'myset = [1, 2, 3]', is_correct: false }, + { label: 'myset = (\'apple\', \'banana\', \'cherry\')', is_correct: false }, + ], + }, + { + title: 'Explain the concept of uniqueness in sets in Python.', + name: 'question4', + points: 2, + order: 3, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'How do you add an item to a set in Python?', + name: 'question5', + points: 2, + order: 4, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'add()', is_correct: true }, + { label: 'append()', is_correct: false }, + { label: 'insert()', is_correct: false }, + ], + }, + { + title: 'What is the result of {1, 2, 3} | {3, 4, 5} in Python?', + name: 'question6', + points: 2, + order: 5, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '{1, 2, 3, 4, 5}', is_correct: true }, + { label: '12, 345', is_correct: false }, + { label: '{3}', is_correct: false }, + ], + }, + { + title: 'Explain the concept of set methods in Python.', + name: 'question7', + points: 2, + order: 6, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'How do you remove an item from a set in Python?', + name: 'question8', + points: 2, + order: 7, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'remove()', is_correct: true }, + { label: 'delete()', is_correct: false }, + { label: 'pop()', is_correct: false }, + ], + }, + { + title: 'What is the result of {1, 2, 3, 4, 5}.difference({3, 4, 5}) in Python?', + name: 'question9', + points: 2, + order: 8, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '{1, 2}', is_correct: true }, + { label: '{3, 4, 5}', is_correct: false }, + { label: '{}', is_correct: false }, + ], + }, + { + title: 'Explain the concept of set comprehension in Python.', + name: 'question10', + points: 2, + order: 9, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + ], + }, +}; + +export default template; diff --git a/src/lib/mocks/python/013_python_dictionaries.ts b/src/lib/mocks/python/013_python_dictionaries.ts new file mode 100644 index 00000000..6f5d10d3 --- /dev/null +++ b/src/lib/mocks/python/013_python_dictionaries.ts @@ -0,0 +1,122 @@ +import { QuestionTypes } from '../utils'; + +import type { ExerciseTemplate } from '$lib/utils/types'; + +const template: ExerciseTemplate = { + title: 'Python Dictionaries Quiz', + description: 'Test your knowledge of Python dictionaries', + questionnaire: { + questions: [ + { + title: 'What is a Python dictionary?', + name: 'question1', + points: 2, + order: 0, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'An ordered collection of elements', is_correct: false }, + { label: 'An unordered collection of key-value pairs', is_correct: true }, + { label: 'A list with duplicate elements', is_correct: false }, + ], + }, + { + title: 'How do you declare a Python dictionary?', + name: 'question2', + points: 2, + order: 1, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'dict x = {\'name\': \'John\', \'age\': 30}', is_correct: false }, + { label: 'x = {\'name\': \'John\', \'age\': 30}', is_correct: true }, + { label: 'x = dictionary(\'name\'=\'John\', \'age\'=30)', is_correct: false }, + ], + }, + { + title: 'Which of the following is a valid dictionary declaration in Python?', + name: 'question3', + points: 2, + order: 2, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: 'mydict = {1: \'apple\', 2: \'banana\'}', is_correct: true }, + { label: 'mydict = [\'apple\', \'banana\']', is_correct: false }, + { label: 'mydict = {\'name\': [\'John\', \'Doe\'], \'age\': 30}', is_correct: true }, + ], + }, + { + title: 'Explain the concept of key-value pairs in dictionaries in Python.', + name: 'question4', + points: 2, + order: 3, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'How do you access a value in a dictionary in Python?', + name: 'question5', + points: 2, + order: 4, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'By index using square brackets', is_correct: false }, + { label: 'By using dot notation', is_correct: true }, + { label: 'By using curly braces', is_correct: false }, + ], + }, + { + title: 'What is the result of mydict.get(\'age\') in Python?', + name: 'question6', + points: 2, + order: 5, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Error', is_correct: false }, + { label: '30', is_correct: true }, + { label: 'None', is_correct: false }, + ], + }, + { + title: 'Explain the concept of dictionary methods in Python.', + name: 'question7', + points: 2, + order: 6, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'How do you add a key-value pair to a dictionary in Python?', + name: 'question8', + points: 2, + order: 7, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'add()', is_correct: false }, + { label: 'insert()', is_correct: false }, + { label: 'mydict[\'new_key\'] = \'new_value\'', is_correct: true }, + ], + }, + { + title: 'What is the result of mydict.pop(\'name\') in Python?', + name: 'question9', + points: 2, + order: 8, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Error', is_correct: false }, + { label: '30', is_correct: false }, + { label: '\'John\'', is_correct: true }, + ], + }, + { + title: 'Explain the concept of dictionary comprehension in Python.', + name: 'question10', + points: 2, + order: 9, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + ], + }, +}; + +export default template; diff --git a/src/lib/mocks/python/014_python_conditionals.ts b/src/lib/mocks/python/014_python_conditionals.ts new file mode 100644 index 00000000..4648a9ba --- /dev/null +++ b/src/lib/mocks/python/014_python_conditionals.ts @@ -0,0 +1,122 @@ +import { QuestionTypes } from '../utils'; + +import type { ExerciseTemplate } from '$lib/utils/types'; + +const template: ExerciseTemplate = { + title: 'Python Conditions Quiz', + description: 'Test your knowledge of Python conditions', + questionnaire: { + questions: [ + { + title: 'What is a Python if statement used for?', + name: 'question1', + points: 2, + order: 0, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Looping', is_correct: false }, + { label: 'Making decisions', is_correct: true }, + { label: 'Defining functions', is_correct: false }, + ], + }, + { + title: 'How do you write an if statement in Python?', + name: 'question2', + points: 2, + order: 1, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'if x > 5', is_correct: true }, + { label: 'if x < 5:', is_correct: false }, + { label: 'if (x > 5) {', is_correct: false }, + ], + }, + { + title: 'Which of the following is a valid Python if statement?', + name: 'question3', + points: 2, + order: 2, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: 'if x > 5:', is_correct: true }, + { label: 'if x < 10:', is_correct: true }, + { label: 'if x == 7', is_correct: false }, + ], + }, + { + title: 'Explain the concept of boolean expressions in Python conditions.', + name: 'question4', + points: 2, + order: 3, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'How do you use the "else" statement in Python?', + name: 'question5', + points: 2, + order: 4, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'As a replacement for "if"', is_correct: false }, + { label: 'To define a function', is_correct: false }, + { label: 'To execute code if the "if" statement is false', is_correct: true }, + ], + }, + { + title: 'What is the result of (5 > 3) and (10 > 7) in Python?', + name: 'question6', + points: 2, + order: 5, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'True', is_correct: true }, + { label: 'False', is_correct: false }, + { label: '1', is_correct: false }, + ], + }, + { + title: 'Explain the concept of "elif" in Python conditions.', + name: 'question7', + points: 2, + order: 6, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'How do you use the "or" operator in Python conditions?', + name: 'question8', + points: 2, + order: 7, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'To combine conditions that must both be true', is_correct: false }, + { label: 'To combine conditions where at least one must be true', is_correct: true }, + { label: 'To exclude conditions', is_correct: false }, + ], + }, + { + title: 'What is the result of not(True) in Python?', + name: 'question9', + points: 2, + order: 8, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'True', is_correct: false }, + { label: 'False', is_correct: true }, + { label: 'None', is_correct: false }, + ], + }, + { + title: 'Explain the concept of nested if statements in Python.', + name: 'question10', + points: 2, + order: 9, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + ], + }, +}; + +export default template; diff --git a/src/lib/mocks/python/015_python_whileLoops.ts b/src/lib/mocks/python/015_python_whileLoops.ts new file mode 100644 index 00000000..48fd674e --- /dev/null +++ b/src/lib/mocks/python/015_python_whileLoops.ts @@ -0,0 +1,122 @@ +import { QuestionTypes } from '../utils'; + +import type { ExerciseTemplate } from '$lib/utils/types'; + +const template: ExerciseTemplate = { + title: 'Python While Loops Quiz', + description: 'Test your knowledge of Python while loops', + questionnaire: { + questions: [ + { + title: 'What is the purpose of a while loop in Python?', + name: 'question1', + points: 2, + order: 0, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Iterating over a range of values', is_correct: false }, + { label: 'Repeating a block of code while a condition is true', is_correct: true }, + { label: 'Defining a function', is_correct: false }, + ], + }, + { + title: 'How do you write a simple while loop in Python?', + name: 'question2', + points: 2, + order: 1, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'while x > 5:', is_correct: false }, + { label: 'while (x < 10):', is_correct: false }, + { label: 'while condition:', is_correct: true }, + ], + }, + { + title: 'Which of the following statements is true about the "break" statement in a while loop?', + name: 'question3', + points: 2, + order: 2, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: 'It is used to exit the current loop', is_correct: true }, + { label: 'It is used to define a new variable', is_correct: false }, + { label: 'It is used to skip the next iteration of the loop', is_correct: false }, + ], + }, + { + title: 'Explain the concept of an infinite loop in Python while loops.', + name: 'question4', + points: 2, + order: 3, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'What is the result of using "continue" in a while loop in Python?', + name: 'question5', + points: 2, + order: 4, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Exit the loop', is_correct: false }, + { label: 'Skip the current iteration and continue with the next', is_correct: true }, + { label: 'Re-run the loop from the beginning', is_correct: false }, + ], + }, + { + title: 'What is the purpose of the "else" statement in a while loop?', + name: 'question6', + points: 2, + order: 5, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'As a replacement for "if"', is_correct: false }, + { label: 'To execute code if the loop completes without a "break"', is_correct: true }, + { label: 'To define a function', is_correct: false }, + ], + }, + { + title: 'Explain the concept of "nested while loops" in Python.', + name: 'question7', + points: 2, + order: 6, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'How do you use the "for" loop in Python?', + name: 'question8', + points: 2, + order: 7, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'To create an infinite loop', is_correct: false }, + { label: 'To iterate over a sequence of items', is_correct: true }, + { label: 'To execute code only once', is_correct: false }, + ], + }, + { + title: 'What is the result of "range(3)" in a for loop in Python?', + name: 'question9', + points: 2, + order: 8, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '0, 1, 2', is_correct: true }, + { label: '3, 6, 9', is_correct: false }, + { label: '1, 2, 3', is_correct: false }, + ], + }, + { + title: 'Explain the concept of "loop control statements" in Python.', + name: 'question10', + points: 2, + order: 9, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + ], + }, +}; + +export default template; diff --git a/src/lib/mocks/python/016_python_forLoops.ts b/src/lib/mocks/python/016_python_forLoops.ts new file mode 100644 index 00000000..32457024 --- /dev/null +++ b/src/lib/mocks/python/016_python_forLoops.ts @@ -0,0 +1,122 @@ +import { QuestionTypes } from '../utils'; + +import type { ExerciseTemplate } from '$lib/utils/types'; + +const template: ExerciseTemplate = { + title: 'Python For Loops Quiz', + description: 'Test your knowledge of Python for loops', + questionnaire: { + questions: [ + { + title: 'What is the purpose of a for loop in Python?', + name: 'question1', + points: 2, + order: 0, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Iterating over a range of values', is_correct: false }, + { label: 'Repeating a block of code a specific number of times', is_correct: true }, + { label: 'Defining a function', is_correct: false }, + ], + }, + { + title: 'How do you write a simple for loop in Python?', + name: 'question2', + points: 2, + order: 1, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'for (x < 10):', is_correct: false }, + { label: 'for condition:', is_correct: false }, + { label: 'for x in range(5):', is_correct: true }, + ], + }, + { + title: 'Which of the following statements is true about the "break" statement in a for loop?', + name: 'question3', + points: 2, + order: 2, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: 'It is used to exit the current loop', is_correct: true }, + { label: 'It is used to define a new variable', is_correct: false }, + { label: 'It is used to skip the next iteration of the loop', is_correct: false }, + ], + }, + { + title: 'Explain the concept of an infinite loop in Python for loops.', + name: 'question4', + points: 2, + order: 3, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'What is the result of using "continue" in a for loop in Python?', + name: 'question5', + points: 2, + order: 4, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Exit the loop', is_correct: false }, + { label: 'Skip the current iteration and continue with the next', is_correct: true }, + { label: 'Re-run the loop from the beginning', is_correct: false }, + ], + }, + { + title: 'What is the purpose of the "else" statement in a for loop?', + name: 'question6', + points: 2, + order: 5, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'As a replacement for "if"', is_correct: false }, + { label: 'To execute code if the loop completes without a "break"', is_correct: true }, + { label: 'To define a function', is_correct: false }, + ], + }, + { + title: 'Explain the concept of "nested for loops" in Python.', + name: 'question7', + points: 2, + order: 6, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'How do you use the "while" loop in Python?', + name: 'question8', + points: 2, + order: 7, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'To create an infinite loop', is_correct: false }, + { label: 'To iterate over a sequence of items', is_correct: false }, + { label: 'To execute code while a condition is true', is_correct: true }, + ], + }, + { + title: 'What is the result of "range(3)" in a while loop in Python?', + name: 'question9', + points: 2, + order: 8, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '0, 1, 2', is_correct: true }, + { label: '3, 6, 9', is_correct: false }, + { label: '1, 2, 3', is_correct: false }, + ], + }, + { + title: 'Explain the concept of "loop control statements" in Python.', + name: 'question10', + points: 2, + order: 9, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + ], + }, +}; + +export default template; diff --git a/src/lib/mocks/python/017_python_functions.ts b/src/lib/mocks/python/017_python_functions.ts new file mode 100644 index 00000000..31eef56a --- /dev/null +++ b/src/lib/mocks/python/017_python_functions.ts @@ -0,0 +1,122 @@ +import { QuestionTypes } from '../utils'; + +import type { ExerciseTemplate } from '$lib/utils/types'; + +const template: ExerciseTemplate = { + title: 'Python Functions Quiz', + description: 'Test your knowledge of Python functions', + questionnaire: { + questions: [ + { + title: 'What is the purpose of a function in Python?', + name: 'question1', + points: 2, + order: 0, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'To define a variable', is_correct: false }, + { label: 'To execute code repeatedly', is_correct: false }, + { label: 'To group and reuse code', is_correct: true }, + ], + }, + { + title: 'How do you define a function in Python?', + name: 'question2', + points: 2, + order: 1, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'function myFunction:', is_correct: false }, + { label: 'define myFunction:', is_correct: false }, + { label: 'def myFunction():', is_correct: true }, + ], + }, + { + title: 'Which keyword is used to call a function in Python?', + name: 'question3', + points: 2, + order: 2, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'call', is_correct: false }, + { label: 'invoke', is_correct: false }, + { label: 'return', is_correct: true }, + ], + }, + { + title: 'Explain the concept of function parameters in Python.', + name: 'question4', + points: 2, + order: 3, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'What is a "default parameter" in a Python function?', + name: 'question5', + points: 2, + order: 4, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'A parameter with a default value', is_correct: true }, + { label: 'A parameter that cannot be changed', is_correct: false }, + { label: 'A reserved keyword', is_correct: false }, + ], + }, + { + title: 'How do you return a value from a function in Python?', + name: 'question6', + points: 2, + order: 5, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'use return statement', is_correct: true }, + { label: 'use print statement', is_correct: false }, + { label: 'use break statement', is_correct: false }, + ], + }, + { + title: 'Explain the concept of "local variables" in Python functions.', + name: 'question7', + points: 2, + order: 6, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'How can you make a Python function accept an arbitrary number of arguments?', + name: 'question8', + points: 2, + order: 7, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Use a for loop', is_correct: false }, + { label: 'Use the *args parameter', is_correct: true }, + { label: 'Use the $args parameter', is_correct: false }, + ], + }, + { + title: 'What is a "lambda function" in Python?', + name: 'question9', + points: 2, + order: 8, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'A function defined with the lambda keyword', is_correct: true }, + { label: 'A built-in Python function', is_correct: false }, + { label: 'A function with a long name', is_correct: false }, + ], + }, + { + title: 'Explain the concept of "recursion" in Python functions.', + name: 'question10', + points: 2, + order: 9, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + ], + }, +}; + +export default template; diff --git a/src/lib/mocks/python/018_python_lambda.ts b/src/lib/mocks/python/018_python_lambda.ts new file mode 100644 index 00000000..a6e51c5f --- /dev/null +++ b/src/lib/mocks/python/018_python_lambda.ts @@ -0,0 +1,121 @@ +import { QuestionTypes } from '../utils'; + +import type { ExerciseTemplate } from '$lib/utils/types'; + +const template: ExerciseTemplate = { + title: 'Python Lambda Functions Quiz', + description: 'Test your knowledge of Python lambda functions', + questionnaire: { + questions: [ + { + title: 'What is a lambda function in Python?', + name: 'question1', + points: 2, + order: 0, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'A type of list', is_correct: false }, + { label: 'A small anonymous function', is_correct: true }, + { label: 'A Python keyword', is_correct: false }, + ], + }, + { + title: 'How do you define a lambda function in Python?', + name: 'question2', + points: 2, + order: 1, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'def my_lambda:', is_correct: false }, + { label: 'lambda my_lambda:', is_correct: true }, + { label: 'function my_lambda():', is_correct: false }, + ], + }, + { + title: 'What is the primary use of lambda functions in Python?', + name: 'question3', + points: 2, + order: 2, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'To create global variables', is_correct: false }, + { label: 'To define classes', is_correct: false }, + { label: 'To create small, anonymous functions', is_correct: true }, + ], + }, + { + title: 'Explain the concept of "anonymous functions" in Python.', + name: 'question4', + points: 2, + order: 3, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'How are lambda functions typically used in Python?', + name: 'question5', + points: 2, + order: 4, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'To define classes', is_correct: false }, + { label: 'To create global variables', is_correct: false }, + { label: 'As arguments for higher-order functions', is_correct: true }, + ], + }, + { + title: 'What is the syntax of a lambda function in Python?', + name: 'question6', + points: 2, + order: 5, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'lambda: expression', is_correct: false }, + { label: 'function: expression', is_correct: false }, + { label: 'lambda parameters: expression', is_correct: true }, + ], + }, + { + title: 'Explain the concept of "higher-order functions" in Python.', + name: 'question7', + points: 2, + order: 6, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'Can a lambda function have multiple expressions?', + name: 'question8', + points: 2, + order: 7, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Yes', is_correct: false }, + { label: 'No', is_correct: true }, + ], + }, + { + title: 'How do you call a lambda function in Python?', + name: 'question9', + points: 2, + order: 8, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Use the call() method', is_correct: false }, + { label: 'Use the lambda keyword', is_correct: false }, + { label: 'Use the function name followed by arguments', is_correct: true }, + ], + }, + { + title: 'Explain an example use case for lambda functions in Python.', + name: 'question10', + points: 2, + order: 9, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + ], + }, +}; + +export default template; diff --git a/src/lib/mocks/python/019_python_arrays.ts b/src/lib/mocks/python/019_python_arrays.ts new file mode 100644 index 00000000..2d11abe9 --- /dev/null +++ b/src/lib/mocks/python/019_python_arrays.ts @@ -0,0 +1,122 @@ +import { QuestionTypes } from '../utils'; + +import type { ExerciseTemplate } from '$lib/utils/types'; + +const template: ExerciseTemplate = { + title: 'Python Arrays Quiz', + description: 'Test your knowledge of Python arrays', + questionnaire: { + questions: [ + { + title: 'What is a Python list?', + name: 'question1', + points: 2, + order: 0, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'An ordered collection of items', is_correct: true }, + { label: 'A data type to store text', is_correct: false }, + { label: 'A way to define functions', is_correct: false }, + ], + }, + { + title: 'How do you create an empty list in Python?', + name: 'question2', + points: 2, + order: 1, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Using the `array()` function', is_correct: false }, + { label: 'Using the `list()` function', is_correct: true }, + { label: 'You cannot create an empty list', is_correct: false }, + ], + }, + { + title: 'What is the index of the first element in a Python list?', + name: 'question3', + points: 2, + order: 2, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: '0', is_correct: true }, + { label: '1', is_correct: false }, + { label: '-1', is_correct: false }, + ], + }, + { + title: 'Explain the concept of slicing in Python lists.', + name: 'question4', + points: 2, + order: 3, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'What is the difference between lists and tuples in Python?', + name: 'question5', + points: 2, + order: 4, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Lists are immutable, tuples are mutable', is_correct: false }, + { label: 'Lists are ordered and mutable, tuples are ordered and immutable', is_correct: true }, + { label: 'Lists are unordered, tuples are ordered', is_correct: false }, + ], + }, + { + title: 'How do you add an element to the end of a list in Python?', + name: 'question6', + points: 2, + order: 5, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Using the `insert()` method', is_correct: false }, + { label: 'Using the `append()` method', is_correct: true }, + { label: 'Using the `add()` function', is_correct: false }, + ], + }, + { + title: 'Explain the concept of list comprehension in Python.', + name: 'question7', + points: 2, + order: 6, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'How do you remove an element from a list by value in Python?', + name: 'question8', + points: 2, + order: 7, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Using the `delete()` method', is_correct: false }, + { label: 'Using the `remove()` method', is_correct: true }, + { label: 'Using the `pop()` function', is_correct: false }, + ], + }, + { + title: 'What is the result of the expression `len(my_list)` where `my_list` is a list?', + name: 'question9', + points: 2, + order: 8, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'The last element of the list', is_correct: false }, + { label: 'The length (number of elements) of the list', is_correct: true }, + { label: 'The sum of all elements in the list', is_correct: false }, + ], + }, + { + title: 'Explain an example use case for Python arrays in programming.', + name: 'question10', + points: 2, + order: 9, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + ], + }, +}; + +export default template; diff --git a/src/lib/mocks/python/020_python_classes.ts b/src/lib/mocks/python/020_python_classes.ts new file mode 100644 index 00000000..65ae4d53 --- /dev/null +++ b/src/lib/mocks/python/020_python_classes.ts @@ -0,0 +1,122 @@ +import { QuestionTypes } from '../utils'; + +import type { ExerciseTemplate } from '$lib/utils/types'; + +const template: ExerciseTemplate = { + title: 'Python Classes Quiz', + description: 'Test your knowledge of Python classes and object-oriented programming', + questionnaire: { + questions: [ + { + title: 'What is a class in Python?', + name: 'question1', + points: 2, + order: 0, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'A blueprint for creating objects', is_correct: true }, + { label: 'A built-in data type', is_correct: false }, + { label: 'A function that returns a value', is_correct: false }, + ], + }, + { + title: 'How do you define a class in Python?', + name: 'question2', + points: 2, + order: 1, + question_type: QuestionTypes[1], // CHECKBOX + options: [ + { label: 'Using the `define` keyword', is_correct: false }, + { label: 'Using the `class` keyword', is_correct: true }, + { label: 'Using the `new` keyword', is_correct: false }, + ], + }, + { + title: 'What is an object in object-oriented programming?', + name: 'question3', + points: 2, + order: 2, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'A function in a class', is_correct: false }, + { label: 'An instance of a class', is_correct: true }, + { label: 'A global variable', is_correct: false }, + ], + }, + { + title: 'Explain the concept of inheritance in Python classes.', + name: 'question4', + points: 2, + order: 3, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'What is a constructor method in a Python class?', + name: 'question5', + points: 2, + order: 4, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'A method that constructs objects', is_correct: false }, + { label: 'A special method that initializes objects', is_correct: true }, + { label: 'A method for destroying objects', is_correct: false }, + ], + }, + { + title: 'How do you create an instance of a class in Python?', + name: 'question6', + points: 2, + order: 5, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Using the `new` keyword', is_correct: false }, + { label: 'By calling the class name as a function', is_correct: true }, + { label: 'Using the `create` method', is_correct: false }, + ], + }, + { + title: 'Explain the concept of encapsulation in Python classes.', + name: 'question7', + points: 2, + order: 6, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + { + title: 'What is method overriding in Python classes?', + name: 'question8', + points: 2, + order: 7, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'Changing the class name', is_correct: false }, + { label: 'Creating a new class', is_correct: false }, + { label: 'Providing a new implementation for a parent class method in a child class', is_correct: true }, + ], + }, + { + title: 'What is the purpose of the `self` parameter in Python class methods?', + name: 'question9', + points: 2, + order: 8, + question_type: QuestionTypes[0], // RADIO + options: [ + { label: 'It is a reserved keyword and cannot be used as a parameter', is_correct: false }, + { label: 'It refers to the instance of the class and is used to access its attributes and methods', is_correct: true }, + { label: 'It is used to pass parameters to the class constructor', is_correct: false }, + ], + }, + { + title: 'Explain the concept of a class variable in Python.', + name: 'question10', + points: 2, + order: 9, + question_type: QuestionTypes[2], // TEXTAREA + options: [], + }, + ], + }, +}; + +export default template; diff --git a/src/lib/mocks/python/index.ts b/src/lib/mocks/python/index.ts new file mode 100644 index 00000000..808f86bb --- /dev/null +++ b/src/lib/mocks/python/index.ts @@ -0,0 +1,66 @@ +import pythonSyntax from './001_python_syntax'; +import pythonComments from './002_python_comments'; +import pythonVariables from './003_python_variables'; +import pythonDataTypes from './004_python_dataTypes'; +import pythonNumbers from './005_python_numbers'; +import pythonCasting from './006_python_casting'; +import pythonStrings from './007_python_strings'; +import pythonBooleans from './008_python_booleans'; +import pythonOperators from './009_python_operators'; +import pythonLists from './010_python_lists'; +import pythonTuples from './011_python_tuples'; +import pythonSets from './012_python_sets'; +import pythonDictionaries from './013_python_dictionaries'; +import pythonConditionals from './014_python_conditionals'; +import pythonWhileLoops from './015_python_whileLoops'; +import pythonForLoops from './016_python_forLoops'; +import pythonFunctions from './017_python_functions'; +import pythonLambda from './018_python_lambda'; +import pythonArrays from './019_python_arrays'; +import pythonClasses from './020_python_classes'; + +export const PYTHON_IDS: { [key: string]: string } = { + PYTHON_SYNTAX: 'PYTHON_SYNTAX', + PYTHON_COMMENTS: 'PYTHON_COMMENTS', + PYTHON_VARIABLES: 'PYTHON_VARIABLES', + PYTHON_DATATYPES: 'PYTHON_DATATYPES', + PYTHON_NUMBERS: 'PYTHON_NUMBERS', + PYTHON_CASTING: 'PYTHON_CASTING', + PYTHON_STRINGS: 'PYTHON_STRINGS', + PYTHON_BOOLEANS: 'PYTHON_BOOLEANS', + PYTHON_OPERATORS: 'PYTHON_OPERATORS', + PYTHON_LISTS: 'PYTHON_LISTS', + PYTHON_TUPLES: 'PYTHON_TUPLES', + PYTHON_SETS: 'PYTHON_SETS', + PYTHON_DICTIONARIES: 'PYTHON_DICTIONARIES', + PYTHON_CONDITIONALS: 'PYTHON_CONDITIONALS', + PYTHON_WHILELOOPS: 'PYTHON_WHILELOOPS', + PYTHON_FORLOOPS: 'PYTHON_FORLOOPS', + PYTHON_FUNCTIONS: 'PYTHON_FUNCTIONS', + PYTHON_LAMBDA: 'PYTHON_LAMBDA', + PYTHON_ARRAYS: 'PYTHON_ARRAYS', + PYTHON_CLASSES: 'PYTHON_CLASSES' +}; + +export const PYTHON_TEMPLATES = { + [PYTHON_IDS.PYTHON_SYNTAX]: pythonSyntax, + [PYTHON_IDS.PYTHON_COMMENTS]: pythonComments, + [PYTHON_IDS.PYTHON_VARIABLES]: pythonVariables, + [PYTHON_IDS.PYTHON_DATATYPES]: pythonDataTypes, + [PYTHON_IDS.PYTHON_NUMBERS]: pythonNumbers, + [PYTHON_IDS.PYTHON_CASTING]: pythonCasting, + [PYTHON_IDS.PYTHON_STRINGS]: pythonStrings, + [PYTHON_IDS.PYTHON_BOOLEANS]: pythonBooleans, + [PYTHON_IDS.PYTHON_OPERATORS]: pythonOperators, + [PYTHON_IDS.PYTHON_LISTS]: pythonLists, + [PYTHON_IDS.PYTHON_TUPLES]: pythonTuples, + [PYTHON_IDS.PYTHON_SETS]: pythonSets, + [PYTHON_IDS.PYTHON_DICTIONARIES]: pythonDictionaries, + [PYTHON_IDS.PYTHON_CONDITIONALS]: pythonConditionals, + [PYTHON_IDS.PYTHON_WHILELOOPS]: pythonWhileLoops, + [PYTHON_IDS.PYTHON_FORLOOPS]: pythonForLoops, + [PYTHON_IDS.PYTHON_FUNCTIONS]: pythonFunctions, + [PYTHON_IDS.PYTHON_LAMBDA]: pythonLambda, + [PYTHON_IDS.PYTHON_ARRAYS]: pythonArrays, + [PYTHON_IDS.PYTHON_CLASSES]: pythonClasses, +};