Skip to content

Commit

Permalink
Merge pull request #3 from Vinit710/enhances_learning
Browse files Browse the repository at this point in the history
 Fixes: #2 adds comments to hello world and variables learning
  • Loading branch information
codingkatty authored Oct 11, 2024
2 parents 01dd063 + 7545e24 commit 24c93cd
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,48 @@ function showEditor(lesson) {
editor.setTheme("ace/theme/twilight");
editor.session.setMode("ace/mode/python");
editor.setOptions({
fontSize: "18px" // Increased from 16px
fontSize: "18px"
});
}
editor.setValue(`# ${lesson} lesson\n# Start coding here`);

// Update the editor content based on the lesson chosen
if (lesson === 'Hello World') {
editor.setValue(`
# I'll walk the user through the print statement and explain its purpose and usage.
# Lesson: Hello World in Python
# The print() function is used to display output to the user.
# In Python, we use print() to send text, numbers, or other data types to the terminal or console.
# Example:
print("Hello, World!")
# Explanation:
# The print statement above will display the text "Hello, World!" in the console.
# Whatever is inside the quotes ("") will be printed exactly as it is.
# print() can also display numbers or variables. For example:
number = 5
print(number) # This will print the number 5.
# Try changing the text inside the print() function and run the code!`);
} else if (lesson === 'Variables') {
editor.setValue(`# Lesson: Variables in Python
# Variables are containers for storing data values. In Python, a variable is created the moment you assign a value to it.
# Example:
x = 5
y = "Hello"
print(x)
print(y)
# Explanation:
# In this example, x is a variable with a value of 5, and y is a variable with a value of "Hello".
# Python is dynamically typed, meaning you don't need to declare the variable type (e.g., int, string) explicitly.
# You can assign any value to a variable, and the print() function will output the value.`);
} else {
editor.setValue(`# ${lesson} lesson\n# Start coding here`);
}
}

async function runCode() {
Expand Down Expand Up @@ -70,6 +108,7 @@ function clearTerminal() {
terminal.innerHTML = ''; // Clear the terminal output
}


function viewChallenge(challengeName) {
const description = document.getElementById('challenge-description');

Expand Down

0 comments on commit 24c93cd

Please sign in to comment.