Placeholder Image

Subtitles section Play video

  • Now let's tackle these, man.

  • The two DUIs are going to be as follows getting the key from the user from the command line, getting the plain text, prompting for that in ciphering that plain text and then finally printing the cipher text back to the user.

  • The key is going to be in the command line argument, and we can access it as follows.

  • Using the RV array and see we simply called R V Index one and in Python will have to add in a system dot RV for that.

  • Then you'll also want to check to make sure that your key is comprised of all letters, all alphabetic.

  • So use this is Alfa function here to check for that.

  • To get the plain text from the user, prompt them for it using wth e get string function found in the CS 50 module.

  • Now let's talk about in ciphering.

  • If I wanted to iterated over all of the letters in my name printing those, then I could store my name in a variable name and then I would execute the four loop as follows.

  • Four C in name print.

  • See notice here that the variable sea is just a placeholder, the generator for every character in my name.

  • Now, if I ran this, then the print method would include a new line after every character.

  • So make sure to check up on how print works and how to omit a new line coming automatically after every call to print.

  • All right, so now that we know at the most basic level how to iterated over a plain text, let's look at the formula for vision there where we have the ice letter of the plain text shifted by the Jace letter of the key.

  • And all of that is module owed by 26.

  • And that gives you the ice letter of our cipher text.

  • So here you'll notice that, as before, we have two indices that we're dealing with I and J.

  • But in the four Loop example, before, we only had the capability for one index or want it aerator, so you'll have to find a way to keep track of your second index.

  • Now we want advance that index in the key word on Lee.

  • If the character in plain text is letter, so go back to the is Alfa function and as before with our ciphers will want to preserve the case so you might want to use the is upper and his lower functions.

  • Finally, you'll want to implement alphabetical wrap around.

  • I'll give you a hint to check out these two functions and in combination with the formula from before, figure out how to go back and forth between asking values and alphabetical indices to make sure that you wrap around the alphabet correctly, print the cipher, text back to the user and you finish the problem.

  • My name is, um, Isla, and this was visionary.

Now let's tackle these, man.

Subtitles and vocabulary

Click the word to look it up Click the word to find further inforamtion about it