*All questions refer to Python* QUESTION 31 The function that can be used to gen
ID: 3582718 • Letter: #
Question
*All questions refer to Python*
QUESTION 31
The function that can be used to generate a list of index values, useful in controlling a for loop:
list()
range()
rand()
str()
2 points
QUESTION 32
The function used to import python code and objects from other python files.
build
add
import
2 points
QUESTION 33
An interpreter converts the entire source code into an executable.
True
False
2 points
QUESTION 34
Compilers and interpreters have the following in common:
Reads the source code into machine code, all at once.
Translates machine code into byte code.
Reads the course code one line at a time.
Translates source code into machine code.
2 points
QUESTION 35
The _______ block is used to perform normal operations, but allow an exception to be thrown, thus ending the _______ block.
Try
Except
Throw
Catch
2 points
QUESTION 36
def setPhone(self,
phone):
self.phone
= phone
The above code is an...
Mutator method
Accessor method
Global function
Except Function
2 points
QUESTION 37
What does this operator mean <=
Equal
Approximately
Greater than or equal to
Less than or equal to
2 points
QUESTION 38
Write a 4 element Python dictionary object that contains four colors as the names and their values as examples of something that is that color. Example: “red”: “apple”
2 points
QUESTION 39
Write a Python class definition for an Employee object that contains the following elements:
Attributes:
id
name
wage
department
Methods:
Initializer which sets ID, name, and wage
Set Name
Set Department
Get Id
Get Name
Get Wage
Get Department
2 points
QUESTION 40
In Python, all exceptions must be instances of a class that derives from BaseException.
True
False
list()
range()
rand()
str()
MashupsExplanation / Answer
Question 31:range()
It is used to generate list of index values useful in loops
Question 32:import
import keyword is used to import python code and objects from other python files.
QUESTION 33
An interpreter converts the entire source code into an executable.
True
QUESTION 34:Translates source code into machine code
Compilers and interpreters both Translates source code into machine code,compiler all at a time and interpreter one line at a time
QUESTION 35
The except block is used to perform normal operations, but allow an exception to be thrown, thus ending the try block.
QUESTION 36
def setPhone(self,
phone):
self.phone
= phone
The above code is a...Mutator method
Question 37.The operator<= means "Less than or equal to"
Question 38:
Question 39:
class Employee:
id
name
wage
department
def __init__(self, name, salary):
self.id=id
self.name = name
self.wage = salary
def GetId(self):
print "Employee id : ", self.id, "
def GetName(self):
print "Name : ", self.name, "
def GetName(self):
print "Wage : ", self.wage, "
def GetName(self):
print "Department : ", self.department, "
"This would create first object of Employee class"
emp1 = Employee("emp01","Zara", 2000,"QC")
QUESTION 40
In Python, all exceptions must be instances of a class that derives from BaseException.In a try statement with an except clause that mentions a particular class, that clause also handles any exception classes derived from that class
Answer is True
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.