Skip to main content

Posts

Showing posts with the label Python Test Answers Upwork 2019

Python Test Answers Upwork 2019

1. Which of the following will disable output buffering in Python? Answers: a. Using the -u command line switch a. class Unbuffered: def __init__(self, stream): self.stream = stream def write(self, data): self.stream.write(data) self.stream.flush() def __getattr__(self, attr): return getattr(self.stream, attr) import sys sys.stdout=Unbuffered(sys.stdout)  a. Setting the PYTHONUNBUFFERED environment variable a. sys.stdout = os.fdopen(sys.stdout.fileno(), ‘w’, 0) 2. Which of the following members of the object class compare two parameters? Answers: a. object.__eq__(self, other)  a. object.__ne__(self, other)  a. object.__compare__(self, other) a. object.__equals__(self, other) a. object.__co__(self, other) a. None of these 3. Object is the base class of new-style datatypes. Which of the following functions is not a member of the object class? Answers: a. object.__eq__(self, other) a. object.__ne__(self, other) a. object.__nz__(self)  a. object.__repr__(self) a. None ...