chore(curriculum): add quotes around strings in cypher project (#53418)

This commit is contained in:
Ilenia
2024-02-02 21:24:15 +01:00
committed by GitHub
parent b1de0dd45a
commit 5d1fa66e08
20 changed files with 30 additions and 30 deletions

View File

@@ -15,7 +15,7 @@ string_2 = 'I am also a string'
string_3 = 'This is not valid"
```
Delete your `number` variable and its value. Then, declare another variable called `text` and assign the string `Hello World` to this variable.
Delete your `number` variable and its value. Then, declare another variable called `text` and assign the string `'Hello World'` to this variable.
# --hints--
@@ -32,7 +32,7 @@ You should declare a variable called `text`. Pay attention to place the variable
assert.match(code, /^text\s*=/m)
```
You should assign the string `Hello World` to your `text` variable. Remember to use either single or double quotes to enclose the string and pay attention to the letter case.
You should assign the string `'Hello World'` to your `text` variable. Remember to use either single or double quotes to enclose the string and pay attention to the letter case.
```js
assert.match(code, /^text\s*=\s*("|')Hello World\1\s*(#.*)?$/m)

View File

@@ -14,7 +14,7 @@ greet = 'Hello!'
print(greet)
```
The code in the example above would print the string `Hello!`, which is the value of the variable `greet` passed to `print()` as the argument.
The code in the example above would print the string `'Hello!'`, which is the value of the variable `greet` passed to `print()` as the argument.
Print your `text` variable to the screen by passing the `text` variable as the argument to the `print()` function.

View File

@@ -7,7 +7,7 @@ dashedName: step-5
# --description--
Each string character can be referenced by a numerical index. The index count starts at zero. So the first character of a string has an index of `0`. For example, in the string `Hello World`, `H` is at index `0`, `e` is at index `1`, and so on.
Each string character can be referenced by a numerical index. The index count starts at zero. So the first character of a string has an index of `0`. For example, in the string `'Hello World'`, `'H'` is at index `0`, `'e'` is at index `1`, and so on.
Each character of a string can be accessed by using bracket notation. You need to write the variable name followed by square brackets and add the index of the character between the brackets:

View File

@@ -7,7 +7,7 @@ dashedName: step-8
# --description--
You can see `11` printed on the terminal because `Hello World` contains 11 characters.
You can see `11` printed on the terminal because `'Hello World'` contains 11 characters.
Another useful built-in function is `type()`, which returns the data type of a variable. Modify your `print()` call to print the data type of `text`.

View File

@@ -14,7 +14,7 @@ Key aspects of variable naming in Python are:
- Variable names are case sensitive, i.e. `my_var` is different from `my_Var` and `MY_VAR`.
- Finally, it is a common convention to write variable names using `snake_case`, where each space is replaced by an underscore character and the words are written in lowercase letters.
Remove both calls to `print()` and declare another variable called `alphabet`. Assign the string `abcdefghijklmnopqrstuvwxyz` to this variable.
Remove both calls to `print()` and declare another variable called `alphabet`. Assign the string `'abcdefghijklmnopqrstuvwxyz'` to this variable.
# --hints--
@@ -38,7 +38,7 @@ You should declare a variable called `alphabet`. Pay attention to place the vari
assert.match(code, /^alphabet\s*=/m)
```
You should assign the string `abcdefghijklmnopqrstuvwxyz` to your `alphabet` variable. Remember to use either single or double quotes to enclose the string.
You should assign the string `'abcdefghijklmnopqrstuvwxyz'` to your `alphabet` variable. Remember to use either single or double quotes to enclose the string.
```js
assert.match(code, /^alphabet\s*=\s*("|')abcdefghijklmnopqrstuvwxyz\1\s*(#.*)?$/m)

View File

@@ -15,7 +15,7 @@ Start by finding the position of the first letter in the string. One way is to c
text.find('W')
```
Above, uppercase `W` is the character you want to locate inside the string stored in the `text` variable. The method will return `6`, which is the index of the `W` character inside the string stored in the `text` variable.
Above, uppercase `'W'` is the character you want to locate inside the string stored in the `text` variable. The method will return `6`, which is the index of the `'W'` character inside the string stored in the `text` variable.
At the end of your code, call `.find()` on your `alphabet` string and pass `text[0]` to the method. Note that a method is just a function that belongs to an object (you will learn more about that in another project).

View File

@@ -7,7 +7,7 @@ dashedName: step-16
# --description--
`.find()` returns the index of the matching character inside the string. If the character is not found, it returns `-1`. As you can see, the first character in `text`, uppercase `H`, is not found, since `alphabet` contains only lowercase letters.
`.find()` returns the index of the matching character inside the string. If the character is not found, it returns `-1`. As you can see, the first character in `text`, uppercase `'H'`, is not found, since `alphabet` contains only lowercase letters.
You can transform a string into its lowercase equivalent with the `.lower()` method. Add another `print()` call to print `text.lower()` and see the output.

View File

@@ -7,7 +7,7 @@ dashedName: step-20
# --description--
As you can see from the output, `h` is at index `7` in the `alphabet` string. Now you need to find the letter at index `7` plus the value of `shift`. For that, you can use the addition operator, `+`, in the same way you would use it for a mathematical addition.
As you can see from the output, `'h'` is at index `7` in the `alphabet` string. Now you need to find the letter at index `7` plus the value of `shift`. For that, you can use the addition operator, `+`, in the same way you would use it for a mathematical addition.
Modify your `shifted` variable so that it stores the value of `alphabet` at index `index + shift`.

View File

@@ -7,7 +7,7 @@ dashedName: step-42
# --description--
Currently, spaces get encrypted as `c`. To maintain the original spacing in the plain message, you'll require a conditional `if` statement. This is composed of the `if` keyword, a condition, and a colon `:`.
Currently, spaces get encrypted as `'c'`. To maintain the original spacing in the plain message, you'll require a conditional `if` statement. This is composed of the `if` keyword, a condition, and a colon `:`.
```py
if x != 0:
@@ -16,7 +16,7 @@ if x != 0:
In the example above, the condition of the `if` statement is `x != 0`. The code `print(x)`, inside the `if` statement body, runs only when the condition evaluates to `True` (in this example, meaning that `x` is different from zero).
At the top of your for loop, replace `print(char == ' ')` with an `if` statement. The condition of this `if` statement should evaluate to `True` if `char` is an empty space and `False` otherwise. Inside the `if` body, print the string `space!`. Remember to indent this line.
At the top of your for loop, replace `print(char == ' ')` with an `if` statement. The condition of this `if` statement should evaluate to `True` if `char` is an empty space and `False` otherwise. Inside the `if` body, print the string `'space!'`. Remember to indent this line.
# --hints--
@@ -36,7 +36,7 @@ const {block_body} = __helpers.python.getBlock(commentless_code, /for\s+char\s+i
assert(block_body.match(/if\s+char\s*==\s*("|')\s\1\s*:/));
```
You should print the string `space!` inside your new `if` statement.
You should print the string `'space!'` inside your new `if` statement.
```js
const commentless_code = __helpers.python.removeComments(code);

View File

@@ -7,7 +7,7 @@ dashedName: step-43
# --description--
Now, instead of printing `space!`, use the addition assignment operator to add the space (currently stored in `char`) to the current value of `encrypted_text`.
Now, instead of printing `'space!'`, use the addition assignment operator to add the space (currently stored in `char`) to the current value of `encrypted_text`.
# --hints--

View File

@@ -7,7 +7,7 @@ dashedName: step-45
# --description--
Try to assign the string `Hello Zaira` to your `text` variable and see what happens in the console.
Try to assign the string `'Hello Zaira'` to your `text` variable and see what happens in the console.
# --hints--
@@ -17,7 +17,7 @@ You should have a `text` variable.
assert.match(code, /^text\s*=/m)
```
You should assign the string `Hello Zaira` to your `text` variable.
You should assign the string `'Hello Zaira'` to your `text` variable.
```js
assert.match(code, /^text\s*=\s*("|')Hello\sZaira\1/m)

View File

@@ -7,7 +7,7 @@ dashedName: step-58
# --description--
Delete your `shift` variable. Then, declare a new variable called `custom_key` and assign the value of the string `python` to this variable.
Delete your `shift` variable. Then, declare a new variable called `custom_key` and assign the value of the string `'python'` to this variable.
# --hints--
@@ -23,7 +23,7 @@ You should declare a variable called `custom_key`.
({ test: () => assert(__userGlobals.has("custom_key")) })
```
You should assign the string `python` to your `custom_key` variable.
You should assign the string `'python'` to your `custom_key` variable.
```js
({ test: () => assert.equal(__userGlobals.get("custom_key"), "python") })

View File

@@ -19,7 +19,7 @@ You should have a `text` variable.
({ test: () => assert(__userGlobals.has("text")) })
```
Your `text` variable should be equal to the string `Hello Zaira!`.
Your `text` variable should be equal to the string `'Hello Zaira!'`.
```js
({ test: () => assert.equal(__userGlobals.get("text"), "Hello Zaira!") })

View File

@@ -9,7 +9,7 @@ dashedName: step-86
It works! Now, you are going to start with an encrypted message to be decrypted.
Change the value of `text` to the string `mrttaqrhknsw ih puggrur`.
Change the value of `text` to the string `'mrttaqrhknsw ih puggrur'`.
# --hints--
@@ -19,7 +19,7 @@ You should still have a `text` variable.
({ test: () => assert(__userGlobals.has("text")) })
```
Your `text` variable should have the value of `mrttaqrhknsw ih puggrur`.
Your `text` variable should have the value of `'mrttaqrhknsw ih puggrur'`.
```js
({ test: () => assert.equal(__userGlobals.get("text"), "mrttaqrhknsw ih puggrur") })

View File

@@ -9,7 +9,7 @@ dashedName: step-88
Two or more strings can be concatenated by using the `+` operator. For example: `'Hello' + ' there!'` results in `'Hello there!`.
Call the `print()` function and use the `+` operator to concatenate the `text` variable to the string `Encrypted text: `. Pay attention to the spacing.
Call the `print()` function and use the `+` operator to concatenate the `text` variable to the string `'Encrypted text: '`. Pay attention to the spacing.
# --hints--

View File

@@ -7,11 +7,11 @@ dashedName: step-89
# --description--
Below the `print()` call you just added, add another `print()` call to print `Key: python` by concatenating the string `Key: ` and the value of the `custom_key` variable.
Below the `print()` call you just added, add another `print()` call to print `Key: python` by concatenating the string `'Key: '` and the value of the `custom_key` variable.
# --hints--
You should have a `print()` call that prints `Key: python` by concatenating the string `Key: ` and the value of the `custom_key` variable.
You should have a `print()` call that prints `Key: python` by concatenating the string `'Key: '` and the value of the `custom_key` variable.
```js
const commentless_code = __helpers.python.removeComments(code);

View File

@@ -7,7 +7,7 @@ dashedName: step-95
# --description--
Wait a minute! You cannot decrypt anything with the wrong key. Try with `happycoding`.
Wait a minute! You cannot decrypt anything with the wrong key. Try with `'happycoding'`.
With that, your cipher project is complete.
@@ -19,7 +19,7 @@ You should still have a `custom_key` variable.
({ test: () => assert(__userGlobals.has("custom_key")) })
```
You should modify the `custom_key` value into `happycoding`.
You should modify the `custom_key` value into `'happycoding'`.
```js
({ test: () => assert.equal(__userGlobals.get("custom_key"), "happycoding") })

View File

@@ -7,7 +7,7 @@ dashedName: step-31
# --description--
Strings are immutable, which means they cannot be changed once created. For example, you might think that the following code changes the value of `my_string` into the string `train`, but this is not valid:
Strings are immutable, which means they cannot be changed once created. For example, you might think that the following code changes the value of `my_string` into the string `'train'`, but this is not valid:
```py
my_string = 'brain'

View File

@@ -14,7 +14,7 @@ message = 'Hello World'
message = 'Hello there!'
```
Delete the `text[0]` line and reassign `text` the string `Albatross`.
Delete the `text[0]` line and reassign `text` the string `'Albatross'`.
# --hints--
@@ -25,7 +25,7 @@ const commentless_code = __helpers.python.removeComments(code);
assert.isFalse( /text\s*\[\s*0\s*\]\s*\=\s*("|')\w\1/.test(commentless_code));
```
You should reassign `text` the string `Albatross`. Do not modify `text = 'Hello World'`.
You should reassign `text` the string `'Albatross'`. Do not modify `text = 'Hello World'`.
```js
({test: () => {

View File

@@ -20,7 +20,7 @@ const commentless_code = __helpers.python.removeComments(code);
assert.isFalse( /text\s*=\s*("|')Albatross\1/.test(commentless_code))
```
You should still have a `text` variable with the value `Hello World`.
You should still have a `text` variable with the value `'Hello World'`.
```js
({test: () => {