From 3856c49dada04cdf6f6599b769c40a735e2cee31 Mon Sep 17 00:00:00 2001 From: SalehOmar-Y Date: Sun, 8 Jun 2025 12:37:29 +0100 Subject: [PATCH 1/8] new file: prep/Variables new file: prep/example.js --- prep/Variables | 31 +++++++++++++++++++++++++++++++ prep/example.js | 1 + 2 files changed, 32 insertions(+) create mode 100644 prep/Variables create mode 100644 prep/example.js diff --git a/prep/Variables b/prep/Variables new file mode 100644 index 000000000..963af6a21 --- /dev/null +++ b/prep/Variables @@ -0,0 +1,31 @@ +# variables_practice.py + +# Integer variable +age = 25 + +# Float variable +height = 1.75 + +# String variable +name = "Alice" + +# Boolean variable +is_student = True + +# Print variables +print("Name:", name) +print("Age:", age) +print("Height:", height) +print("Is student:", is_student) + +# Update variables +age = age + 1 +height = height + 0.05 +name = name + " Smith" +is_student = False + +print("\nUpdated values:") +print("Name:", name) +print("Age:", age) +print("Height:", height) +print("Is student:", is_student) \ No newline at end of file diff --git a/prep/example.js b/prep/example.js new file mode 100644 index 000000000..a171c2f64 --- /dev/null +++ b/prep/example.js @@ -0,0 +1 @@ +satisfies; \ No newline at end of file From 6e565c21434c77b7b4273852dae7ae1347befc42 Mon Sep 17 00:00:00 2001 From: SalehOmar-Y Date: Sun, 8 Jun 2025 15:13:21 +0100 Subject: [PATCH 2/8] new file --- prep/Variables | 66 +++++++++++++++++++++++++++++++++++++++++++++- prep/age.js | 7 +++++ prep/arithmetic.js | 4 +++ prep/example.js | 14 +++++++++- 4 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 prep/age.js create mode 100644 prep/arithmetic.js diff --git a/prep/Variables b/prep/Variables index 963af6a21..fb9c45765 100644 --- a/prep/Variables +++ b/prep/Variables @@ -28,4 +28,68 @@ print("\nUpdated values:") print("Name:", name) print("Age:", age) print("Height:", height) -print("Is student:", is_student) \ No newline at end of file +print("Is student:", is_student) + +# Create a list variable +hobbies = ["reading", "cycling", "hiking"] +# Print list variable +print("\nHobbies:", hobbies) +# Add a new hobby +hobbies.append("painting") +# Print updated list variable +print("Updated Hobbies:", hobbies) +# Create a dictionary variable +profile = { + "name": name, + "age": age, + "height": height, + "is_student": is_student, + "hobbies": hobbies +} +# Print dictionary variable +print("\nProfile:", profile) +# Update dictionary variable +profile["age"] = profile["age"] + 1 +# write a summary of the declaration and statement of variables +## Summary of Variable Declaration and Statement +# In Python, variables are declared by assigning a value to a name. +# The type of the variable is determined by the value assigned. +# Variables can be of different types such as integers, floats, strings, and booleans. +# Variables can also be updated by reassigning a new value to them. + + let versionNumber = "2.0.0"; // declaration +versionNumber = "2.0.1"; // statement + +# The let keyword allows us to create new variables like the const keyword. + +#Math.round(10.3) is a call expression; read this as: + +#apply the set of instructions for Math.round to the number 10.3.” + +#If we type Math.round(10.3) then we get the result 10. So we say that Math.round(10.3) returns 10." + +# Example of using Functions in JavaScript; +Math.round(4.7); // 5 + +// Example of using declarations in JavaScript; + + + +#> versionNumber = "2.0.1"; +'2.0.1' +> Math.round +[Function: round] +> Math.round(0.3) +0 +> const roundValue = Math.round(10.3); +undefined +> +> roundValue +10 +> const roundValueInString = `10.3 round to ${Math.round +(10.3)}`; +undefined +> roundValueInString +'10.3 round to 10' +> roundValueInString +'10.3 round to 10' \ No newline at end of file diff --git a/prep/age.js b/prep/age.js new file mode 100644 index 000000000..e4eb5cc88 --- /dev/null +++ b/prep/age.js @@ -0,0 +1,7 @@ +const yearOfBirth = 1960; // declaration +let currentYear = 2025; // declaration + +console.log(`I am ${currentYear - yearOfBirth} years old`); + // statement +// This statement will print the age in the terminal +// The output will be "I am 65 years old" if the current year is 2025 diff --git a/prep/arithmetic.js b/prep/arithmetic.js new file mode 100644 index 000000000..d063f3727 --- /dev/null +++ b/prep/arithmetic.js @@ -0,0 +1,4 @@ +const result = Math.round(10.3); +const result2 = Math.round(10.7); +console.log(result); // Output: 10 +console.log(result2); // Output: 11 \ No newline at end of file diff --git a/prep/example.js b/prep/example.js index a171c2f64..01308ccd0 100644 --- a/prep/example.js +++ b/prep/example.js @@ -1 +1,13 @@ -satisfies; \ No newline at end of file + // this statement will print "Hello, World!" in the terminal +// This is a comment explaining the code below +console.log("Hello, World!"); + +// invalid or unexpected token // This is a comment explaining the code below +const firstName = "Kim"; +const age = "33"; +const nationality = "Korean"; + +const volunteer = "Said"; +//if we want to print the value of the variable volunteer, we can use console.log +console.log(volunteer); + From 658b6115d59032bf38fde5a1978075b25945e6c8 Mon Sep 17 00:00:00 2001 From: SalehOmar-Y Date: Thu, 19 Jun 2025 16:58:46 +0100 Subject: [PATCH 3/8] handling and improve function implementations in key error examples --- Project-CLI-Treasure-Hunt | 1 + Sprint-2/1-key-errors/0.js | 13 +++++++++++-- Sprint-2/1-key-errors/1.js | 15 +++++++++++---- Sprint-2/1-key-errors/2.js | 10 ++++++---- Sprint-2/2-mandatory-debug/0.js | 9 +++++++-- Sprint-2/2-mandatory-debug/1.js | 10 ++++++++-- Sprint-2/2-mandatory-debug/2.js | 22 ++++++++++++++++++---- Sprint-2/3-mandatory-implement/1-bmi.js | 7 +++++-- my-new-folder/CYF-Workshops | 1 + 9 files changed, 68 insertions(+), 20 deletions(-) create mode 160000 Project-CLI-Treasure-Hunt create mode 160000 my-new-folder/CYF-Workshops diff --git a/Project-CLI-Treasure-Hunt b/Project-CLI-Treasure-Hunt new file mode 160000 index 000000000..2f622599e --- /dev/null +++ b/Project-CLI-Treasure-Hunt @@ -0,0 +1 @@ +Subproject commit 2f622599e09fc28147949f59bcb6892ff6721548 diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 653d6f5a0..074cbc4f8 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -1,13 +1,22 @@ // Predict and explain first... -// =============> write your prediction here +// =============> write your prediction here it will captilase the first and second letter of the string because the is calling for 0 , 1 slice. // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring function capitalise(str) { - let str = `${str[0].toUpperCase()}${str.slice(1)}`; + str = `${str[0].toUpperCase()}${str.slice(1)}`; return str; } +console.log(capitalise("summer")); +// why will an error occur when this program runs? +// because the variable str is being declared twice, once as a parameter and then again inside the function. // =============> write your explanation here // =============> write your new code here +function capitalise(str) { + str = `${str[0].toUpperCase()}${str.slice(1)}`; + return str; +} + +console.log(capitalise("summer")); \ No newline at end of file diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index f2d56151f..07838484b 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -1,20 +1,27 @@ // Predict and explain first... // Why will an error occur when this program runs? -// =============> write your prediction here +// =============> write your prediction here - it won't work because the variable decimalNumber is being declared twice, once as a parameter and then again inside the function. + // Try playing computer with the example to work out what is going on function convertToPercentage(decimalNumber) { - const decimalNumber = 0.5; const percentage = `${decimalNumber * 100}%`; return percentage; } -console.log(decimalNumber); +console.log(convertToPercentage(0.8)); // =============> write your explanation here - +// previously the code was not working because the variable decimalNumber was being declared twice, once as a parameter and then again inside the function. This caused a conflict and resulted in an error. // Finally, correct the code to fix the problem // =============> write your new code here +function convertToPercentage(decimalNumber) { + const percentage = `${decimalNumber * 100}%`; + + return percentage; +} + +console.log(convertToPercentage(0.8)); \ No newline at end of file diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index aad57f7cf..0290d722c 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -4,17 +4,19 @@ // this function should square any number but instead we're going to get an error // =============> write your prediction of the error here - +// We will get in error beacuse teh variable num is not defined. function square(3) { return num * num; } -// =============> write the error message here +// =============> write the error message here - SyntaxError: Unexpected number -// =============> explain this error message here +// =============> explain this error message here - the number should not be there, it should be a variable name. // Finally, correct the code to fix the problem // =============> write your new code here - +function square(num) { + return num * num; +} diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index b27511b41..34824a486 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -1,9 +1,9 @@ // Predict and explain first... -// =============> write your prediction here +// =============> write your prediction here - the multiply will not return anything because the function does not have a return statement. function multiply(a, b) { - console.log(a * b); + console.log(a * b); } console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); @@ -12,3 +12,8 @@ console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); // Finally, correct the code to fix the problem // =============> write your new code here +function multiply(a, b) { + return result = a * b; +} + +console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); \ No newline at end of file diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 37cedfbcf..89f4132b1 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -1,5 +1,5 @@ // Predict and explain first... -// =============> write your prediction here +// =============> write your prediction here - the function will not work because we don't have a return statement in the function. function sum(a, b) { return; @@ -8,6 +8,12 @@ function sum(a, b) { console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); -// =============> write your explanation here +// =============> write your explanation here = I'vee added a return statement to the function to ensure it returns the sum of the two numbers. // Finally, correct the code to fix the problem // =============> write your new code here +function sum(a, b) { + return result = + a + b; +} + +console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); \ No newline at end of file diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 57d3f5dc3..6ae2f6440 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -1,6 +1,6 @@ -// Predict and explain first... +// Predict and explain first... - const num = 103; is declared outside the function, so it will not be used in the getLastDigit function. -// Predict the output of the following code: +// Predict the output of the following code: - error. // =============> Write your prediction here const num = 103; @@ -14,11 +14,25 @@ console.log(`The last digit of 105 is ${getLastDigit(105)}`); console.log(`The last digit of 806 is ${getLastDigit(806)}`); // Now run the code and compare the output to your prediction -// =============> write the output here +// =============> write the output here - +// The last digit of 42 is 3 +//The last digit of 105 is 3 +//The last digit of 806 is 3 + // Explain why the output is the way it is -// =============> write your explanation here +// =============> write your explanation here - because const cant be used with other numbers, it is only used with the first number declared. and the function is not taking any parameters, so it will always return the last digit of the first number declared. // Finally, correct the code to fix the problem // =============> write your new code here // This program should tell the user the last digit of each number. // Explain why getLastDigit is not working properly - correct the problem +// our function getLastDigit does not accept any parameters, so it always uses the global variable num (which is 103). +const num = 103; + +function getLastDigit(number) { + return number.toString().slice(-1); +} + +console.log(`The last digit of 42 is ${getLastDigit(42)}`); +console.log(`The last digit of 105 is ${getLastDigit(105)}`); +console.log(`The last digit of 806 is ${getLastDigit(806)}`); diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js index 17b1cbde1..dea5a03e6 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -15,5 +15,8 @@ // It should return their Body Mass Index to 1 decimal place function calculateBMI(weight, height) { - // return the BMI of someone based off their weight and height -} \ No newline at end of file + const bmi = weight / (height * height); + return parseFloat(bmi.toFixed(1)); + // return the BMI of someone based off their weight and height +} +console.log(calculateBMI(84, 1.81)); \ No newline at end of file diff --git a/my-new-folder/CYF-Workshops b/my-new-folder/CYF-Workshops new file mode 160000 index 000000000..e2a1884aa --- /dev/null +++ b/my-new-folder/CYF-Workshops @@ -0,0 +1 @@ +Subproject commit e2a1884aa028a328627b321f08d6bf1d54035821 From 16b87c7a8dfd4afd0f434761e515ab6691667704 Mon Sep 17 00:00:00 2001 From: SalehOmar-Y Date: Fri, 20 Jun 2025 19:22:12 +0100 Subject: [PATCH 4/8] Update BMI calculation example, add toUpperCaseSnake function, implement toPounds function, and enhance formatAs12HourClock function with tests --- Project-CLI-Treasure-Hunt | 2 +- Sprint-2/3-mandatory-implement/1-bmi.js | 2 +- Sprint-2/3-mandatory-implement/2-cases.js | 6 +++ Sprint-2/3-mandatory-implement/3-to-pounds.js | 15 ++++++++ Sprint-2/4-mandatory-interpret/time-format.js | 12 +++--- Sprint-2/5-stretch-extend/format-time.js | 38 ++++++++++--------- 6 files changed, 51 insertions(+), 24 deletions(-) diff --git a/Project-CLI-Treasure-Hunt b/Project-CLI-Treasure-Hunt index 2f622599e..7cc7f5a96 160000 --- a/Project-CLI-Treasure-Hunt +++ b/Project-CLI-Treasure-Hunt @@ -1 +1 @@ -Subproject commit 2f622599e09fc28147949f59bcb6892ff6721548 +Subproject commit 7cc7f5a96677e8187c1b64abf73231ac1a1820eb diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js index dea5a03e6..5ed3a15d3 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -19,4 +19,4 @@ function calculateBMI(weight, height) { return parseFloat(bmi.toFixed(1)); // return the BMI of someone based off their weight and height } -console.log(calculateBMI(84, 1.81)); \ No newline at end of file +console.log(calculateBMI(80, 1.81)); \ No newline at end of file diff --git a/Sprint-2/3-mandatory-implement/2-cases.js b/Sprint-2/3-mandatory-implement/2-cases.js index 5b0ef77ad..b147f2949 100644 --- a/Sprint-2/3-mandatory-implement/2-cases.js +++ b/Sprint-2/3-mandatory-implement/2-cases.js @@ -14,3 +14,9 @@ // You will need to come up with an appropriate name for the function // Use the MDN string documentation to help you find a solution // This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase + +function toUpperCaseSnake(sentence){ +sentence = sentence.split(' ').join('_').toUpperCase(); +return sentence; +} +console.log(toUpperCaseSnake("Do what you can, with what you have, where you are.")); diff --git a/Sprint-2/3-mandatory-implement/3-to-pounds.js b/Sprint-2/3-mandatory-implement/3-to-pounds.js index 6265a1a70..c634acc5c 100644 --- a/Sprint-2/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-2/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,18 @@ // You will need to declare a function called toPounds with an appropriately named parameter. // You should call this function a number of times to check it works for different inputs +function toPounds(penceString) { + const penceStringWithoutTrailingP = penceString.slice(0, -1); + const paddedPence = penceStringWithoutTrailingP.padStart(3, "0"); + + const pounds = paddedPence.slice(0, -2); + const pence = paddedPence.slice(-2).padEnd(2, "0"); + + return `£${pounds}.${pence}`; +} + + + +console.log(toPounds("399p")); +console.log(toPounds("99p")); + diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index 7c98eb0e8..d78f2e274 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -17,18 +17,20 @@ function formatTimeDisplay(seconds) { // Questions // a) When formatTimeDisplay is called how many times will pad be called? -// =============> write your answer here +// =============> write your answer here - 3 times, once for each of totalHours, remainingMinutes, and remainingSeconds. // Call formatTimeDisplay with an input of 61, now answer the following: // b) What is the value assigned to num when pad is called for the first time? -// =============> write your answer here +// =============> write your answer here - the value assigned to pad is 0 // c) What is the return value of pad is called for the first time? -// =============> write your answer here +// =============> write your answer here - "00" — because pad(0) => "0".padStart(2, "0") => "00" + // d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer -// =============> write your answer here +// =============> write your answer here - 1 — because the last call to pad is for remainingSeconds, which is 1. + // e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer -// =============> write your answer here +// =============> write your answer here. - "01" — because pad(1) => "1".padStart(2, "0") => "01". diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js index 32a32e66b..2183b5bb0 100644 --- a/Sprint-2/5-stretch-extend/format-time.js +++ b/Sprint-2/5-stretch-extend/format-time.js @@ -2,24 +2,28 @@ // Make sure to do the prep before you do the coursework // Your task is to write tests for as many different groups of input data or edge cases as you can, and fix any bugs you find. + function formatAs12HourClock(time) { - const hours = Number(time.slice(0, 2)); - if (hours > 12) { - return `${hours - 12}:00 pm`; + const [hh, mm] = time.split(":"); + let hours = Number(hh); + const minutes = mm; + let suffix = "am"; + + if (hours === 0) { + hours = 12; + } else if (hours === 12) { + suffix = "pm"; + } else if (hours > 12) { + hours -= 12; + suffix = "pm"; } - return `${time} am`; -} -const currentOutput = formatAs12HourClock("08:00"); -const targetOutput = "08:00 am"; -console.assert( - currentOutput === targetOutput, - `current output: ${currentOutput}, target output: ${targetOutput}` -); + const paddedHours = hours.toString().padStart(2, "0"); + return `${paddedHours}:${minutes} ${suffix}`; +} -const currentOutput2 = formatAs12HourClock("23:00"); -const targetOutput2 = "11:00 pm"; -console.assert( - currentOutput2 === targetOutput2, - `current output: ${currentOutput2}, target output: ${targetOutput2}` -); +console.assert(formatAs12HourClock("00:00") === "12:00 am", "Midnight"); +console.assert(formatAs12HourClock("01:30") === "01:30 am", "1:30 AM"); +console.assert(formatAs12HourClock("13:15") === "01:15 pm", "1:15 PM"); +console.assert(formatAs12HourClock("23:59") === "11:59 pm", "11:59 PM"); +console.assert(formatAs12HourClock("09:05") === "09:05 am", "9:05 AM"); From 11fc7bfddab856c6499e06c5acb52024eefbd660 Mon Sep 17 00:00:00 2001 From: SalehOmar-Y Date: Sun, 22 Jun 2025 19:12:59 +0100 Subject: [PATCH 5/8] No code changes detected; skipping commit. --- my-new-folder/CYF-Workshops | 1 - 1 file changed, 1 deletion(-) delete mode 160000 my-new-folder/CYF-Workshops diff --git a/my-new-folder/CYF-Workshops b/my-new-folder/CYF-Workshops deleted file mode 160000 index e2a1884aa..000000000 --- a/my-new-folder/CYF-Workshops +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e2a1884aa028a328627b321f08d6bf1d54035821 From 972a41c6e709bc5414ff385e10120141de3aa94c Mon Sep 17 00:00:00 2001 From: Saleh Yousef Date: Sun, 6 Jul 2025 14:20:39 +0100 Subject: [PATCH 6/8] Update 1.js --- Sprint-2/2-mandatory-debug/1.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 89f4132b1..ab78b4b90 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -12,8 +12,7 @@ console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); // Finally, correct the code to fix the problem // =============> write your new code here function sum(a, b) { - return result = - a + b; + return a + b; } -console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); \ No newline at end of file +console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); From 746515f9c940875d7e7e0dd36940f043e5217976 Mon Sep 17 00:00:00 2001 From: SalehOmar-Y Date: Sat, 12 Jul 2025 14:39:05 +0100 Subject: [PATCH 7/8] Updated 0.js --- Sprint-2/2-mandatory-debug/0.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index 34824a486..12270017b 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -13,7 +13,7 @@ console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); // Finally, correct the code to fix the problem // =============> write your new code here function multiply(a, b) { - return result = a * b; + return a * b; } console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); \ No newline at end of file From 017c77fe59231a24112fff9cabdff03d18ede537 Mon Sep 17 00:00:00 2001 From: SalehOmar-Y Date: Sat, 12 Jul 2025 15:20:18 +0100 Subject: [PATCH 8/8] prep deleted --- prep/Variables | 95 ---------------------------------------------- prep/age.js | 7 ---- prep/arithmetic.js | 4 -- prep/example.js | 13 ------- 4 files changed, 119 deletions(-) delete mode 100644 prep/Variables delete mode 100644 prep/age.js delete mode 100644 prep/arithmetic.js delete mode 100644 prep/example.js diff --git a/prep/Variables b/prep/Variables deleted file mode 100644 index fb9c45765..000000000 --- a/prep/Variables +++ /dev/null @@ -1,95 +0,0 @@ -# variables_practice.py - -# Integer variable -age = 25 - -# Float variable -height = 1.75 - -# String variable -name = "Alice" - -# Boolean variable -is_student = True - -# Print variables -print("Name:", name) -print("Age:", age) -print("Height:", height) -print("Is student:", is_student) - -# Update variables -age = age + 1 -height = height + 0.05 -name = name + " Smith" -is_student = False - -print("\nUpdated values:") -print("Name:", name) -print("Age:", age) -print("Height:", height) -print("Is student:", is_student) - -# Create a list variable -hobbies = ["reading", "cycling", "hiking"] -# Print list variable -print("\nHobbies:", hobbies) -# Add a new hobby -hobbies.append("painting") -# Print updated list variable -print("Updated Hobbies:", hobbies) -# Create a dictionary variable -profile = { - "name": name, - "age": age, - "height": height, - "is_student": is_student, - "hobbies": hobbies -} -# Print dictionary variable -print("\nProfile:", profile) -# Update dictionary variable -profile["age"] = profile["age"] + 1 -# write a summary of the declaration and statement of variables -## Summary of Variable Declaration and Statement -# In Python, variables are declared by assigning a value to a name. -# The type of the variable is determined by the value assigned. -# Variables can be of different types such as integers, floats, strings, and booleans. -# Variables can also be updated by reassigning a new value to them. - - let versionNumber = "2.0.0"; // declaration -versionNumber = "2.0.1"; // statement - -# The let keyword allows us to create new variables like the const keyword. - -#Math.round(10.3) is a call expression; read this as: - -#apply the set of instructions for Math.round to the number 10.3.” - -#If we type Math.round(10.3) then we get the result 10. So we say that Math.round(10.3) returns 10." - -# Example of using Functions in JavaScript; -Math.round(4.7); // 5 - -// Example of using declarations in JavaScript; - - - -#> versionNumber = "2.0.1"; -'2.0.1' -> Math.round -[Function: round] -> Math.round(0.3) -0 -> const roundValue = Math.round(10.3); -undefined -> -> roundValue -10 -> const roundValueInString = `10.3 round to ${Math.round -(10.3)}`; -undefined -> roundValueInString -'10.3 round to 10' -> roundValueInString -'10.3 round to 10' \ No newline at end of file diff --git a/prep/age.js b/prep/age.js deleted file mode 100644 index e4eb5cc88..000000000 --- a/prep/age.js +++ /dev/null @@ -1,7 +0,0 @@ -const yearOfBirth = 1960; // declaration -let currentYear = 2025; // declaration - -console.log(`I am ${currentYear - yearOfBirth} years old`); - // statement -// This statement will print the age in the terminal -// The output will be "I am 65 years old" if the current year is 2025 diff --git a/prep/arithmetic.js b/prep/arithmetic.js deleted file mode 100644 index d063f3727..000000000 --- a/prep/arithmetic.js +++ /dev/null @@ -1,4 +0,0 @@ -const result = Math.round(10.3); -const result2 = Math.round(10.7); -console.log(result); // Output: 10 -console.log(result2); // Output: 11 \ No newline at end of file diff --git a/prep/example.js b/prep/example.js deleted file mode 100644 index 01308ccd0..000000000 --- a/prep/example.js +++ /dev/null @@ -1,13 +0,0 @@ - // this statement will print "Hello, World!" in the terminal -// This is a comment explaining the code below -console.log("Hello, World!"); - -// invalid or unexpected token // This is a comment explaining the code below -const firstName = "Kim"; -const age = "33"; -const nationality = "Korean"; - -const volunteer = "Said"; -//if we want to print the value of the variable volunteer, we can use console.log -console.log(volunteer); -