mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 10:22:16 +00:00
fix(curriculum): remove introductory examples from caesar cipher workshop (#67102)
This commit is contained in:
+2
-6
@@ -7,13 +7,9 @@ dashedName: step-1
|
||||
|
||||
# --description--
|
||||
|
||||
As you may recall from previous lessons, in Python, you declare a variable by writing the variable name on the left side of the assignment operator (`=`) and the value to assign on the right side:
|
||||
In this workshop, you will create a program called caesar cipher which is an encryption method that shifts letters in the alphabet to encode messages.
|
||||
|
||||
```py
|
||||
variable_name = value
|
||||
```
|
||||
|
||||
Create a variable called `shift` and assign the value `5` to your new variable.
|
||||
Start by creating a variable called `shift` and assign the value `5` to your new variable.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
-7
@@ -7,13 +7,6 @@ dashedName: step-2
|
||||
|
||||
# --description--
|
||||
|
||||
In previous lessons, you learned about different data types you can store in a variable. You just assigned an integer value. Now you need to assign a string, which is a sequence of characters enclosed by either single or double quotes:
|
||||
|
||||
```py
|
||||
string_1 = 'I am a string'
|
||||
string_2 = "I am also a string"
|
||||
```
|
||||
|
||||
Declare another variable called `alphabet` and assign the string `abcdefghijklmnopqrstuvwxyz` to this variable.
|
||||
|
||||
# --hints--
|
||||
|
||||
+1
-9
@@ -7,15 +7,7 @@ dashedName: step-4
|
||||
|
||||
# --description--
|
||||
|
||||
As you can see from the output, the shifted alphabet starts at the letter `f` because `shift` has the value `5`. But now the first five letters of the alphabet – `a`, `b`, `c`, `d` and `e` – are missing from the shifted alphabet, so you'll need to add them at the end of the shifted alphabet.
|
||||
|
||||
The `+` operator is used to combine two or more strings together in a process called concatenation like this:
|
||||
|
||||
```py
|
||||
greeting = 'Hello' + ' ' + 'World'
|
||||
print(greeting) # Hello World
|
||||
|
||||
```
|
||||
As you can see from the output, the shifted alphabet starts at the letter `f` because `shift` has the value `5`. But now the first five letters of the alphabet – `a`, `b`, `c`, `d` and `e` – are missing from the shifted alphabet, so you'll need to add them at the end of the shifted alphabet. You can use the `+` operator to concatenate the missing portion of the alphabet.
|
||||
|
||||
Modify the existing assignment of the `shifted_alphabet` variable: use the slicing syntax to extract the missing first portion of `alphabet` and concatenate it to `alphabet[shift:]`.
|
||||
|
||||
|
||||
+1
-6
@@ -7,12 +7,7 @@ dashedName: step-16
|
||||
|
||||
# --description--
|
||||
|
||||
Now that you've implemented the basic functionalities of the cipher, it's time to add some validation. For that, you'll need an `if` statement. Here's a reminder of the syntax for an `if` statement:
|
||||
|
||||
```py
|
||||
if condition:
|
||||
# code to run when condition is true
|
||||
```
|
||||
Now that you've implemented the basic functionalities of the cipher, it's time to add some validation. For that, you'll need an `if` statement.
|
||||
|
||||
At the beginning of your function body, create an `if` statement. For now, use `True` as the condition, and within the `if` statement body return the string `Shift must be an integer value.`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user