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

ملء الشاشة (f)
exit full mode
سؤال
What is the string concatenation operator in Python?

A) :
B) +
C) ~
D) *
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
What is the repetition operator in Python?

A) :
B) +
C) ~
D) *
سؤال
What is the value of 'John'[0]?

A) J
B) 'J'
C) 0
D) Undefined
سؤال
What function returns the number of characters in a string?

A) range
B) length
C) leng
D) stringlen
سؤال
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?

A) 'R'
B) R
C) 'v'
D) G
سؤال
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?

A) 'R'
B) R
C) 'v'
D) G
سؤال
What is the [:] operator called?

A) Cut
B) Index
C) Slice
D) Substring
سؤال
What is the result of the following code?
'bc' in 'abc'

A) True
B) False
C) 'a'
D) 1
سؤال
What method can be used to surround a string with spaces in order to make it a certain length?

A) replace
B) count
C) upper
D) center
سؤال
What function converts a character to its Unicode equivalent?

A) str
B) chr
C) ord
D) num
سؤال
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. What is the name of the % operator used on line 6?

A) Division
B) Modulo
C) Cipher
D) Rail fence
سؤال
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. What type of cipher has been implemented?

A) Transposition
B) Accumulator
C) Substitution
D) Vignère
سؤال
Python uses the ____ function to ask the user for a single string.

A) string
B) get
C) input
D) prompt
سؤال
When implementing a substitution cipher in Python, use the ____ method to return the position of any letter in the alphabet.

A) range
B) len
C) position
D) index
سؤال
When implementing the Vigenère cipher, which step comes first?

A) Use the accumulator pattern to add the ciphertext letter to the ciphertext message.
B) Determine which letter of the key we should use.
C) Return the string as the ciphertext message.
D) Look up the ciphertext letter in the Vigenère square, using the key letter row and plaintext character column.
سؤال
The concatenation operator joins two strings and adds a space between them.
سؤال
Although the function call len('abc') returns 3, we would use 'abc'[2] to access the character 'c'.
سؤال
The find method finds the number of occurrences of one string within another.
سؤال
The letter 'a' corresponds to the number 0 in the Unicode system.
سؤال
The process of turning ciphertext into plaintext is called decryption.
سؤال
Match each line of code with a result below. Assume aString is initialized as below:
aString = "golden gopher football"
-aString.count('o')

A) 4
B) 18
C) 0
D) 1
سؤال
Match each line of code with a result below. Assume aString is initialized as below:
aString = "golden gopher football"
-aString.find('b')

A) 5
B) 19
C) 1
D) 2
سؤال
Match each line of code with a result below. Assume aString is initialized as below:
aString = "golden gopher football"
-aString.index('g')

A) 6
B) 20
C) 2
D) 3
سؤال
Match each line of code with a result below. Assume aString is initialized as below:
aString = "golden gopher football"
-aString.count('oo')

A) 7
B) 21
C) 3
D) 4
سؤال
What does the term "string" refer to in computer science language, and how is a string defined in Python?
سؤال
What is the operator represented by the * in the following code? Explain its use.
>>> 'go'*3
سؤال
Describe the functionality of the string index operator with an example.
سؤال
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.
سؤال
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.
سؤال
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.
سؤال
What is the advantage of a substitution cipher over a transposition cipher?
سؤال
How effective is a brute force approach to cracking a substitution cipher? Explain your answer.
سؤال
Provide a high-level summary of the actions needed to encrypt a message using a Vigenère square.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/33
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 3: Codes and Other Secrets: String Operators and Methods, the Len Built-In Function, Keyword Parameters, User Input
1
What is the string concatenation operator in Python?

A) :
B) +
C) ~
D) *
B
2
What is the repetition operator in Python?

A) :
B) +
C) ~
D) *
D
3
What is the value of 'John'[0]?

A) J
B) 'J'
C) 0
D) Undefined
B
4
What function returns the number of characters in a string?

A) range
B) length
C) leng
D) stringlen
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
5
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?

A) 'R'
B) R
C) 'v'
D) G
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
6
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?

A) 'R'
B) R
C) 'v'
D) G
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
7
What is the [:] operator called?

A) Cut
B) Index
C) Slice
D) Substring
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
8
What is the result of the following code?
'bc' in 'abc'

A) True
B) False
C) 'a'
D) 1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
9
What method can be used to surround a string with spaces in order to make it a certain length?

A) replace
B) count
C) upper
D) center
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
10
What function converts a character to its Unicode equivalent?

A) str
B) chr
C) ord
D) num
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
11
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. What is the name of the % operator used on line 6?

A) Division
B) Modulo
C) Cipher
D) Rail fence
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
12
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. What type of cipher has been implemented?

A) Transposition
B) Accumulator
C) Substitution
D) Vignère
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
13
Python uses the ____ function to ask the user for a single string.

A) string
B) get
C) input
D) prompt
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
14
When implementing a substitution cipher in Python, use the ____ method to return the position of any letter in the alphabet.

A) range
B) len
C) position
D) index
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
15
When implementing the Vigenère cipher, which step comes first?

A) Use the accumulator pattern to add the ciphertext letter to the ciphertext message.
B) Determine which letter of the key we should use.
C) Return the string as the ciphertext message.
D) Look up the ciphertext letter in the Vigenère square, using the key letter row and plaintext character column.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
16
The concatenation operator joins two strings and adds a space between them.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
17
Although the function call len('abc') returns 3, we would use 'abc'[2] to access the character 'c'.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
18
The find method finds the number of occurrences of one string within another.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
19
The letter 'a' corresponds to the number 0 in the Unicode system.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
20
The process of turning ciphertext into plaintext is called decryption.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
21
Match each line of code with a result below. Assume aString is initialized as below:
aString = "golden gopher football"
-aString.count('o')

A) 4
B) 18
C) 0
D) 1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
22
Match each line of code with a result below. Assume aString is initialized as below:
aString = "golden gopher football"
-aString.find('b')

A) 5
B) 19
C) 1
D) 2
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
23
Match each line of code with a result below. Assume aString is initialized as below:
aString = "golden gopher football"
-aString.index('g')

A) 6
B) 20
C) 2
D) 3
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
24
Match each line of code with a result below. Assume aString is initialized as below:
aString = "golden gopher football"
-aString.count('oo')

A) 7
B) 21
C) 3
D) 4
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
25
What does the term "string" refer to in computer science language, and how is a string defined in Python?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
26
What is the operator represented by the * in the following code? Explain its use.
>>> 'go'*3
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
27
Describe the functionality of the string index operator with an example.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
28
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
29
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
30
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
31
What is the advantage of a substitution cipher over a transposition cipher?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
32
How effective is a brute force approach to cracking a substitution cipher? Explain your answer.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
33
Provide a high-level summary of the actions needed to encrypt a message using a Vigenère square.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.