Services
Discover
Homeschooling
Ask a Question
Log in
Sign up
Filters
Done
Question type:
Essay
Multiple Choice
Short Answer
True False
Matching
Topic
Computing
Study Set
Computer Science Using Python
Quiz 8: Text Files
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Question 21
Short Answer
To open a file for writing, the built-in _________ method is used, called with a required second parameter of ____.
Question 22
Short Answer
When opening a file for reading, an error that may occur is ______________________________.
Question 23
Short Answer
When reading a line from a text file, the ________________ method is used.
Question 24
Short Answer
24. When reading a line from a text file, all the characters up to and including the ___________ character are read and returned.
Question 25
Short Answer
The ___________ method is used to write to a text file.
Question 26
Short Answer
When writing to or reading from to a file, data is placed in an area of memory called a __________, which make the reading and writing of files more efficient.
Question 27
Short Answer
Provide Python code that opens a file named names.txt, in which each line of the file contains a friends name in the form firstname lastname, and displays each of the names on the screen, one per screen line.
Question 28
Short Answer
Provide Python code that prompts the user for the file name of the form filename.txt of a text file, opens the file, and displays each of the names on the screen, one per screen line.
Question 29
Short Answer
Provide Python code that prompts the user for the file name of the form filename.txt of a text file, opens the file, and writes the contents of the file to a new file name filename-2.txt.
Question 30
True/False
Any of the sequence methods of Python may be applied to strings.
Question 31
True/False
Strings are immutable in Python, and therefore cannot be altered.
Question 32
True/False
Any string method involving the modification of a string returns a new string containing the modification, with the original string the method is called on unchanged.
Question 33
Short Answer
Collectively, the operations performed on strings is called _______________________.
Question 34
Short Answer
The ________ string method in Python can be used to determine if a string contains only letters, whereas the __________ method can be used determine is a string contains only digits.
Question 35
Short Answer
The ________ and __________ string methods in Python can be used to determine if a string contains only lowercase or uppercase characters, whereas the __________ and ___________ methods can be used to convert a string to all lowercase or all uppercase characters.
Question 36
Essay
Give Python code that displays the longer of two names, name1 and name2.
Question 37
Essay
Give Python code that display "Valid SSN" if the string assigned to variable SSN is a valid social security number, and displays "Invalid SSN" otherwise. A social security number is valid if it contains exactly nine digits, and no other characters.