SSL Certificate
  • Assume that the customer file references a file object, and the file was opened using the


Assume that the customer file references a file object, and the file was opened using the ‘w’ mode specifier. How would you write the string ‘Mary Smith’ to the file?
 
A. customer.write(‘w’,‘Mary Smith’)
 
B. customer_file.write(‘Mary Smith’)
 
C. customer.write(‘Mary Smith’)
 
D. customer.input(‘Mary Smith’)






Which method is automatically executed when an instance of the class is created in memory?
 
A. __str__
 
B. __init__
 
C. __obj__
 
D. __state__


Which of the following does not apply to sets?
 
A. The elements are unordered.
 
B. All the elements must be unique – no two elements can have the same value.
 
C. The stored elements can be of different data types.
 
D. The elements are pairs.


Which of the following statements are true?
 
A. When you open a file for reading, if the file does not exist, an error occurs.
 
B. When you open a file for writing, if the file does not exist, a new file is created.
 
C. When you open a file reading, if the file does not exist, the program will open an empty file.
 
D. When you open a file for writing, if the file exists, the existing file is overwritten with the new file.
 
E. When you open a file for writing, if the file does not exist, an error occurs.




Which of the following statements produces {'a', 'b', 'c'}?
 
A. tuple("abac")
 
B. set("abac")
 
C. list("abac")
 
D. None
Suppose s1 = {1, 2, 4, 3} and s2 = {0, 1, 5, 3, 4, 2, 13}, ________ is true.
 
A. s2.issubset(s1)
 
B. s1.issuperset(s2)
 
C. s2.issuperset(s1)
 
D. s1.issubset(s2)


Suppose d = {"john":40, "peter":45}, to delete the entry for "john":40, use ________.
 
A.  del d["john"]
 
B.  d.delete("john":40)
 
C. del d("john":40)
 
D. d.delete("john")


In slicing, if the end index specifies a position beyond the end of the string, Python will use the length of the string instead.
  True
  False
Indexing of a string starts at 1, so the index of the first character is 1, the index of the second character is 2, and so forth.
  True
  False






Write a review

Please login or register to review

Assume that the customer file references a file object, and the file was opened using the

  • $9.99


*All your data are SECURED & ENCRYPTED using a valid, trusted server certificate (Comodo SSL) and we don't store credit card information on our servers and all Payments are SECURED & handled by Paypal.
SSL CertificatePaypal

Tags: Multiple choice question, MCQ, python, object oriented programming, oop