Exam 3: Codes and Other Secrets: String Operators and Methods, the Len Built-In Function, Keyword Parameters, User Input

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

When implementing a substitution cipher in Python, use the ____ method to return the position of any letter in the alphabet.

Free
(Multiple Choice)
4.9/5
(41)
Correct Answer:
Verified

D

The find method finds the number of occurrences of one string within another.

Free
(True/False)
4.7/5
(42)
Correct Answer:
Verified

False

What function returns the number of characters in a string?

Free
(Multiple Choice)
4.9/5
(33)
Correct Answer:
Verified

C

When implementing the Vigenère cipher, which step comes first?

(Multiple Choice)
4.9/5
(38)

Case Study 2: 1. def scramble2Encrypt(plainText): 2. evenChars = "" 3. oddChars = "" 4. charCount = 0 5. for ch in plainText: 6. if charCount % 2 == 0: 7. evenChars = evenChars + ch 8. else: 9. oddChars = oddChars + ch 10. charCount = charCount + 1 11. cipherText = oddChars + evenChars 12. return cipherText -Refer to the code in the accompanying Case Study 2. Explain how you would reverse the process of scramble2Encrypt in order to decrypt the message.

(Essay)
4.8/5
(39)

Python uses the ____ function to ask the user for a single string.

(Multiple Choice)
4.9/5
(34)

Case Study 1: 1. >>> name = "Roy G Biv" 2. >>> first = name[0] 3. >>> first 4. >>> middleChar = name[4] 5. >>> middleChar 6. >>> name[-1] -Refer to the session in the accompanying case study 1. What is printed after line 6?

(Multiple Choice)
4.7/5
(34)

Match each line of code with a result below. Assume aString is initialized as below: aString = "golden gopher football" -aString.count('o')

(Multiple Choice)
5.0/5
(39)

One of the easiest ways to encrypt a message is to simply scramble the letters. For example, the word "mango" could be randomly transformed to "nogma." In fact, there are 120 different possible arrangements of the word "mango." Explain why this is not an effective encryption method.

(Essay)
4.9/5
(42)

The process of turning ciphertext into plaintext is called decryption.

(True/False)
4.8/5
(41)

Provide a high-level summary of the actions needed to encrypt a message using a Vigenère square.

(Essay)
4.8/5
(37)

The letter 'a' corresponds to the number 0 in the Unicode system.

(True/False)
4.8/5
(43)

The concatenation operator joins two strings and adds a space between them.

(True/False)
4.8/5
(33)

Although the function call len('abc') returns 3, we would use 'abc'[2] to access the character 'c'.

(True/False)
4.8/5
(40)

What is the result of the following code? 'bc' in 'abc'

(Multiple Choice)
4.9/5
(38)

Case Study 2: 1. def scramble2Encrypt(plainText): 2. evenChars = "" 3. oddChars = "" 4. charCount = 0 5. for ch in plainText: 6. if charCount % 2 == 0: 7. evenChars = evenChars + ch 8. else: 9. oddChars = oddChars + ch 10. charCount = charCount + 1 11. cipherText = oddChars + evenChars 12. return cipherText -Refer to the code in the accompanying Case Study 2. Provide a line-by-line description of what is happening on lines 5 through 10.

(Essay)
4.9/5
(43)

Case Study 1: 1. >>> name = "Roy G Biv" 2. >>> first = name[0] 3. >>> first 4. >>> middleChar = name[4] 5. >>> middleChar 6. >>> name[-1] -Refer to the session in the accompanying Case Study 1. What is printed after line 3?

(Multiple Choice)
4.8/5
(39)

What is the value of 'John'[0]?

(Multiple Choice)
4.9/5
(39)

Match each line of code with a result below. Assume aString is initialized as below: aString = "golden gopher football" -aString.index('g')

(Multiple Choice)
4.9/5
(35)

What is the repetition operator in Python?

(Multiple Choice)
4.9/5
(33)
Showing 1 - 20 of 33
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)