What output will the following python command produce:
>>> percentage =
float ( 60 * 100) / 55
float ( 60 * 100) / 55
>>> print (percentage)
Select one:
a. percentage
b. 109
c.
109.0909090909091
109.0909090909091
d. 109.0
ANSWER: c. 109.0909090909091
What output will the following python commands produce:
>>> print ((1+1)**(5-2))
Select one:
a. 16
b. 8
c. 4
d. 2
ANSWER: b. 8
What will the output of the following code be?
def recursive( depth ):
depth+=1
while (depth <
5):
5):
ret =
recursive(depth)
recursive(depth)
return depth
ret = recursive( 0 )
print ("the recursive depth is ", ret)
Select one:
a. the recursive
depth is 5
depth is 5
b. the recursive
depth is 4
depth is 4
c. Error due to depth
of recursive calls
of recursive calls
d. None
ANSWER: d. None
Creating a python script file with a .py extension on the
filename and placing it in the appropriate directory is all that is required to
create a module?
filename and placing it in the appropriate directory is all that is required to
create a module?
Select one:
True
False
What output will the following python commands produce:
x = 5
if x % 2 == 0:
print (x)
else:
print (x, x%2)
Select one:
a. 5
b. 5 1
c. 2
d. 5 0
Memory that can maintain its state without power is know
as.
as.
Select one:
a. Non volatile
memory
memory
b. Flash drives
c. Random access
memory (RAM)
memory (RAM)
d. Disk drive
storage
storage
Given any real numbers a and b, exactly one of the
following relations holds: a < b, a > b, or a = b. Thus when you can
establish that two of the relations are false, you can assume the remaining one
is true.
following relations holds: a < b, a > b, or a = b. Thus when you can
establish that two of the relations are false, you can assume the remaining one
is true.
This principle is known as:
Select one:
a. trichotomy
b. abstraction
c. the
distributive property
distributive property
d. the transitive
property
property
One of the advantages of a function is that it allows the
programmer to alter the flow of execution in the program.
programmer to alter the flow of execution in the program.
Select one:
True
False
A parameter written in a function header with an
assignment to a default value which it will receive if no corresponding
argument is given for it in the function call is called an optional parameter.
assignment to a default value which it will receive if no corresponding
argument is given for it in the function call is called an optional parameter.
Select one:
True
False
What will the following code segment do?
infile.readlines()
Select one:
a. Read all
remaining lines in a file
remaining lines in a file
b. Read the next
consecutive line from a file
consecutive line from a file
c. Print the
contents of the file
contents of the file
d. Print the first
line in the file
line in the file
What output will the following code produce?
print ("%s %d %f" % (5, 5, 5))
Select one:
a. 5 5
5.000000
5.000000
b. 5 5 5
c. 5 5.000000
d. 0 5 5.0
What is the output of the following statements?
pi = float(3.14159)
print (pi)
Select one:
a. 3
b. 3.0
c. 3.14159
d. 0
The statements inside of a loop are known as the ____ of
the loop.
the loop.
Select one:
a. body
b. expression
c. counter
d. block
Given the following code, what will the output be?
import string
index = "Ability is a poor man's
wealth".find("w")
wealth".find("w")
print(index)
Select one:
a. 24
b. 0
c. 23
d. -1
A development approach that that is intended to avoid a
lot of debugging by only adding and testing small amounts of code at a time is
called.
lot of debugging by only adding and testing small amounts of code at a time is
called.
Select one:
a. structured
development
development
b. incremental
development
development
c. unit testing
d. Systems
development life cycle
development life cycle
A function that returns an integer value grater than 0 is
called a boolean function.
called a boolean function.
Select one:
True
False
The set of modules that are included in the default
installation of python are known as the:
installation of python are known as the:
Select one:
a. Standard
Library
Library
b. API
(Application Programming Interface)
(Application Programming Interface)
c. Module Library
d. Python Library
In the following Python statement, what do we call the
portion of the statement before the dot ('string.')?
portion of the statement before the dot ('string.')?
string.capitalize('maryland')
Select one:
a. Module
b. Method
c. Function name
d. Attribute
A data type in which the values are made up of components,
or elements, that are themselves values is known as an object data type.
or elements, that are themselves values is known as an object data type.
Select one:
True
False
Which of the following is NOT a valid mode that can be
used to open a file when using the 'open' statement?
used to open a file when using the 'open' statement?
Select one:
a. r (read)
b. w (write)
c. a (append)
d. x (eXecute)
Functions can only return Boolean expressions.
Select one:
True
False
True or False: The graphical representation of a stack of
functions, their variables, and the values to which they refer is called a
traceback?
functions, their variables, and the values to which they refer is called a
traceback?
Select one:
True
False
To create a new object that has the same value as an
existing object is know as creating an alias.
existing object is know as creating an alias.
Select one:
True
False
The dot operator (.) permits access to attributes and
functions of a module (or attributes and methods of a class or instance).
functions of a module (or attributes and methods of a class or instance).
Select one:
True
False
What output will the following code produce?
mylist = [ [2,4,1], [1,2,3], [2,3,5] ]
a=0
b=0
total = 0
while a <= 2:
while b < 2:
total +=
mylist[a][b]
mylist[a][b]
b += 1
a += 1
b = 0
print (total)
Select one:
a. 14
b. 23
c. 0
d. 13
What output will the following statements produce?
n = 2
n += 5
print(n)
Select one:
a. 7
b. 5
c. 0
d. None
What will the contents of mylist be after the following
code has been executed?
code has been executed?
>>> mylist = [1, 4, 2 3]
>>> mylist.append(5)
Select one:
a. [1, 4, 2, 3,
5]
5]
b. [5, 1, 4, 2, 3]
c. [null]
d. [1, 4, 2, 3]
Using keywords for variable names will result in a
________________
________________
Select one:
a. runtime error
b. compile error
c. syntax error
d. semantic error
ANSWER: c. syntax error
No comments:
Post a Comment