Deck 4: Strings and Text Files
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/50
العب
ملء الشاشة (f)
Deck 4: Strings and Text Files
1
Data can be output to a text file using a(n) output object.
False
2
All data output to or input from a text file must be strings.
True
3
When used with strings, the left operand of Python's in operator is a target substring and the right operand is the string to be searched.
True
4
The string method isalphabetic returns True if the string contains only letters or False otherwise.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
5
The absolute value of a digit is determined by raising the base of the system to the power specified by the position (baseposition).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
6
A difference between functions and methods is that methods cannot return values.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
7
The string is a mutable data structure.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
8
A binary number is sometimes referred to as a string of bits or a bit string.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
9
Many applications now use data mangling to protect information transmitted on networks.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
10
Using a text editor such as Notepad or TextEdit, you can create, view, and save data in a text file.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
11
The two digits in the base two number system are 0 and 1.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
12
A method is always called with a given data value called an object, which is placed before the method name in the call.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
13
The decimal number system is also called the base ten number system.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
14
When using the open function to open a file for output (i.e., using 'w' as the mode string), if the file does not exist, Python raises an error.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
15
The string method isnumeric returns True if the string contains only digits or False otherwise.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
16
Some applications extract portions of strings called characters.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
17
A data structure is a compound unit that consists of several smaller pieces of data.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
18
A module behaves like a function, but has a slightly different syntax.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
19
In Python, all data values are objects.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
20
A Caesar cipher uses a plaintext character to compute two or more encrypted characters, and each encrypted character is computed using two or more plaintext characters.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
21
The remove file system function is included in the os.path module.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
22
What file access method can be used to read a single line of input and return the line as a string, including the newline character?
A) getline
B) readline
C) fetch
D) read
A) getline
B) readline
C) fetch
D) read
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
23
The exists file system function is included in the os.path module.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
24
When using the open function to open a file for input (i.e., using 'r' as the mode string), if the file does not exist, Python raises an error.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
25
What does a block cipher utilize in order to change plaintext characters into two or more encrypted characters?
A) A mathematical structure known as an invertible matrix.
B) A random noise sampling from the computer's hardware.
C) A pseudorandom number generator defined by the encrypting language.
D) A hardware encryption chip designed to perform obfuscation.
A) A mathematical structure known as an invertible matrix.
B) A random noise sampling from the computer's hardware.
C) A pseudorandom number generator defined by the encrypting language.
D) A hardware encryption chip designed to perform obfuscation.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
26
What is the value of the binary number 10010110 in base-10?
A) 144
B) 150
C) 169
D) 232
A) 144
B) 150
C) 169
D) 232
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
27
What statement regarding the structure of strings is accurate?
A) A string is a sequence of zero or more characters.
B) A string's length as calculated by the len() function is always "1".
C) A string cannot be decomposed into more primitive parts.
D) A string is a mutable data structure.
A) A string is a sequence of zero or more characters.
B) A string's length as calculated by the len() function is always "1".
C) A string cannot be decomposed into more primitive parts.
D) A string is a mutable data structure.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
28
When a sender of information encrypts that information, what is the resulting text known as?
A) plain text
B) garbage text
C) cipher text
D) junk text
A) plain text
B) garbage text
C) cipher text
D) junk text
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
29
You are running a Python script that is supposed to write data to an open file, but discover that the file contents are not updating even after the script finishes. What is most likely the issue?
A) The file was opened using 'w' instead of 'b' as the mode string.
B) The file is not being updated because it doesn't exist.
C) The file is not being written to using the dump() method.
D) The file was not closed using the close() method.
A) The file was opened using 'w' instead of 'b' as the mode string.
B) The file is not being updated because it doesn't exist.
C) The file is not being written to using the dump() method.
D) The file was not closed using the close() method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
30
A legacy program is outputting values in octal format, and you need to translate the octal to hexadecimal. What is 173 in octal expressed as a hexadecimal value?
A) FA
B) 7B
C) 5D
D) 9C
A) FA
B) 7B
C) 5D
D) 9C
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
31
The file method write expects a single string as an argument.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
32
The encryption method that replaces a character in a text with another character some given distance away in the alphabet from the original is known as what type of cipher?
A) Alpha cipher
B) Caesar cipher
C) Jumble cipher
D) Alternate cipher
A) Alpha cipher
B) Caesar cipher
C) Jumble cipher
D) Alternate cipher
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
33
What string method can you use to locate the lowest index in a string named s where substring "findme" is found?
A) s.locate("findme")
B) s.find("findme")
C) s.grep('findme')
D) s.search("findme")
A) s.locate("findme")
B) s.find("findme")
C) s.grep('findme')
D) s.search("findme")
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
34
What happens if you attempt to access a string using an index equal to the string's length?
A) The entirety of the string will be accessed.
B) The name of the string will be accessed.
C) The string's location in memory will be returned.
D) An error will occur, indicating the index is out of range.
A) The entirety of the string will be accessed.
B) The name of the string will be accessed.
C) The string's location in memory will be returned.
D) An error will occur, indicating the index is out of range.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
35
You are parsing a comma separated value string with Python. What method can you use to separate the values in each line and place them in a list?
A) string.split(',')
B) string.delimit(',')
C) string.parsetolist(',')
D) string.strip(',')
A) string.split(',')
B) string.delimit(',')
C) string.parsetolist(',')
D) string.strip(',')
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
36
Your script is parsing filenames and is creating a count of how many files per file extension type exist within a directory. What slice could you use to extract the file extension substring, assuming the extensions are three letters only?
A) filename[-3:]
B) filename[-3]
C) filename[:-3]
D) filename[$-3]
A) filename[-3:]
B) filename[-3]
C) filename[:-3]
D) filename[$-3]
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
37
After input is finished, another call to read returns an empty string to indicate that the end of the file has been reached.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
38
What does a mode string of 'r' indicate when opening a file in Python?
A) The file will be opened for random access.
B) The file will be opened for read access.
C) The file will be opened for write access.
D) The file will be opened in binary mode.
A) The file will be opened for random access.
B) The file will be opened for read access.
C) The file will be opened for write access.
D) The file will be opened in binary mode.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
39
What is the decimal number 98 in binary?
A) 110010
B) 1100011
C) 1100010
D) 1110010
A) 110010
B) 1100011
C) 1100010
D) 1110010
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
40
The decimal number system, which utilizes the numbers 0-9, is also known as what number system?
A) The base-9 numbering system.
B) The base-10 numbering system.
C) The Octal numbering system.
D) The hexadecimal numbering system.
A) The base-9 numbering system.
B) The base-10 numbering system.
C) The Octal numbering system.
D) The hexadecimal numbering system.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
41
What os.path module function can you use to convert a path to a pathname appropriate for the current file system?
A) localize(path)
B) system(path)
C) convert(path)
D) normcase(path)
A) localize(path)
B) system(path)
C) convert(path)
D) normcase(path)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
42
What specific Python module can you use to determine the file size in bytes of a given file?
A) os.stat
B) io.file
C) os.path
D) file.ops
A) os.stat
B) io.file
C) os.path
D) file.ops
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
43
You are attempting to open a file containing a list of integer numbers, each on a separate line, and read them into Python as int types. What statement could you use to do this, assuming each line is represented by the line variable in a continuous loop?
A) num = int(line.strip())
B) num = line.strip()
C) num = line.strip(int(line))
D) num = line[:-1]
A) num = int(line.strip())
B) num = line.strip()
C) num = line.strip(int(line))
D) num = line[:-1]
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
44
Which of the following are examples of protocols that utilize encryption for data transfer? (Choose two.)
A) HTTP
B) HTTPS
C) FTPS
D) RCP
A) HTTP
B) HTTPS
C) FTPS
D) RCP
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
45
What does the os module function remove do when called?
A) It removes a given file or directory that is passed to it.
B) It removes a given directory that is passed to it.
C) It removes a given file that is passed to it.
D) It removes a given symbolic link file and it's associated inode.
A) It removes a given file or directory that is passed to it.
B) It removes a given directory that is passed to it.
C) It removes a given file that is passed to it.
D) It removes a given symbolic link file and it's associated inode.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
46
In the binary number system, each digit or bit has a positional value that is a power of what?
A) 1
B) 2
C) 8
D) 16
A) 1
B) 2
C) 8
D) 16
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
47
What os module function should you use to get the path of the current working directory?
A) getcwd()
B) cwd()
C) getpwd()
D) showcwd()
A) getcwd()
B) cwd()
C) getpwd()
D) showcwd()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
48
You are running a Python script that is supposed to write data to an open file, but discover that the file contents are being erased each time the script runs. What is most likely the issue?
A) The file was opened using a mode string other than 'a'.
B) The file is truncated by default with the write() method.
C) The file is erased when the script uses the close() method.
D) The file must be opened using a mode string of 'rw'.
A) The file was opened using a mode string other than 'a'.
B) The file is truncated by default with the write() method.
C) The file is erased when the script uses the close() method.
D) The file must be opened using a mode string of 'rw'.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
49
When you launch Python, what file system path does it start with?
A) The root directory of the file system.
B) The current working directory.
C) The same folder as the Python executable file.
D) The user's home folder.
A) The root directory of the file system.
B) The current working directory.
C) The same folder as the Python executable file.
D) The user's home folder.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
50
What two methods can be used to return a copy of a string named s converted to all lowercase and all uppercase respectively?
A) s.lower()
B) s.lowcase()
C) s.upper()
D) s.upcase()
A) s.lower()
B) s.lowcase()
C) s.upper()
D) s.upcase()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck