Comp 110 Final Exam– Complete Questions with
100% Correct Answers | Verified
when will you commonly use bool values in your programs? - ✔✔when making
logical decisions
What is true of expressions? - ✔✔Every expression evaluates to a value, Every
expression evaluates to a specific type, ANywhere you can write an expression that
evaluates to one type, you could write another expression it its place as long as it
evaluates to the same type and still have a validly types program.
What operator would be evaluated first using standard order of operations? 1+2/4*5-6 -
✔✔/
which operator is used to raise one number to the power of another - ✔✔**
which operator is used to find the remainder of an integer division calculation and
results in an int types value? - ✔✔%
which of the following boolean expressions results in a value of False? - ✔✔1>1, 1>2,
1>=2
comparing two string values using relational operators always works the way you would
expect it to in the English Language - ✔✔False
Which relational operator tests whether two values are equal to one another? -
✔✔==
,The random package has many functions for generating random numbers. There's a
random function defined in the random package, you can import and call using a
function call expression like so:
>>> from random import random >>> random()
Try calling the random function many times. What type does a call to the random
function evaluate to? - ✔✔<class 'float'>
The random package also has many functions for random selections. There's a choice
function defined in the random package, you can import and call using a function call
expression with a sequence as an argument, like so:
>>> from random import choice >>> choice("wxyz")
Try calling the choice function many times and with different str values as input
arguments. What type does a call to the choice function evaluate to in these examples?
- ✔✔<class 'str'>
The str class defines a method named isalpha for testing whether a string is made
entirely of alphabetical characters. It also has a method named isdigit
Given the three following expressions, what is the order of their evaluations?
>>> "comp110".isalpha() >>> "110".isdigit() >>> "comp110"[0].isalpha() - ✔✔False,
True, True
Functions are used for: - ✔✔- Process abstraction
- Breaking larger programs into smaller sub-programs
T/F: Function calls are expressions that evaluate to a specific data type. - ✔✔True
T/F: Defining a function is the same as calling it - ✔✔False
, T/F: A function definition can be thought of as a specification of the instructions which
will be carried out when the function is called - ✔✔True
Function definitions are found in: - ✔✔Built in functions automatically available,
Imported from libraries, defined in the same python file/ module
Which of the following will appear in a valid function call expression? - ✔✔The name
of the function, an argument list
Which of the following will appear in a valid function definition signature? - ✔✔the
def keyword, the name of the function, a parameter list, a return type preceded by ->
ends with a :
which of the following will appear in a valid function definition? - ✔✔the def
keyword, the name of the function, an argument list, a function body, a return type
preceded by ->, (a signature)
T/F: Each argument is an expression - ✔✔True
The signature line tells anyone who wants to use a function what it needs in order to be
called and what you can expect returned back as a result - ✔✔True
Parameters are found in a function definitions. Arguments are found in function calls. -
✔✔True
function names are stored in the - ✔✔stack
function definitions are stored in the - ✔✔heap
100% Correct Answers | Verified
when will you commonly use bool values in your programs? - ✔✔when making
logical decisions
What is true of expressions? - ✔✔Every expression evaluates to a value, Every
expression evaluates to a specific type, ANywhere you can write an expression that
evaluates to one type, you could write another expression it its place as long as it
evaluates to the same type and still have a validly types program.
What operator would be evaluated first using standard order of operations? 1+2/4*5-6 -
✔✔/
which operator is used to raise one number to the power of another - ✔✔**
which operator is used to find the remainder of an integer division calculation and
results in an int types value? - ✔✔%
which of the following boolean expressions results in a value of False? - ✔✔1>1, 1>2,
1>=2
comparing two string values using relational operators always works the way you would
expect it to in the English Language - ✔✔False
Which relational operator tests whether two values are equal to one another? -
✔✔==
,The random package has many functions for generating random numbers. There's a
random function defined in the random package, you can import and call using a
function call expression like so:
>>> from random import random >>> random()
Try calling the random function many times. What type does a call to the random
function evaluate to? - ✔✔<class 'float'>
The random package also has many functions for random selections. There's a choice
function defined in the random package, you can import and call using a function call
expression with a sequence as an argument, like so:
>>> from random import choice >>> choice("wxyz")
Try calling the choice function many times and with different str values as input
arguments. What type does a call to the choice function evaluate to in these examples?
- ✔✔<class 'str'>
The str class defines a method named isalpha for testing whether a string is made
entirely of alphabetical characters. It also has a method named isdigit
Given the three following expressions, what is the order of their evaluations?
>>> "comp110".isalpha() >>> "110".isdigit() >>> "comp110"[0].isalpha() - ✔✔False,
True, True
Functions are used for: - ✔✔- Process abstraction
- Breaking larger programs into smaller sub-programs
T/F: Function calls are expressions that evaluate to a specific data type. - ✔✔True
T/F: Defining a function is the same as calling it - ✔✔False
, T/F: A function definition can be thought of as a specification of the instructions which
will be carried out when the function is called - ✔✔True
Function definitions are found in: - ✔✔Built in functions automatically available,
Imported from libraries, defined in the same python file/ module
Which of the following will appear in a valid function call expression? - ✔✔The name
of the function, an argument list
Which of the following will appear in a valid function definition signature? - ✔✔the
def keyword, the name of the function, a parameter list, a return type preceded by ->
ends with a :
which of the following will appear in a valid function definition? - ✔✔the def
keyword, the name of the function, an argument list, a function body, a return type
preceded by ->, (a signature)
T/F: Each argument is an expression - ✔✔True
The signature line tells anyone who wants to use a function what it needs in order to be
called and what you can expect returned back as a result - ✔✔True
Parameters are found in a function definitions. Arguments are found in function calls. -
✔✔True
function names are stored in the - ✔✔stack
function definitions are stored in the - ✔✔heap