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.
Select one:
True
False
Question 2
Not yet answered
Marked out of 1.00
Flag question
Question text
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.
This principle is known as:
Select one:
a. trichotomy
b. abstraction
c. the distributive property
d. the transitive property
Question 3
Not yet answered
Marked out of 1.00
Flag question
Question text
Given the following code what will the output be?
def find(strng, ch):
index = 0
while index < len(strng):
if strng[index] == ch:
return index
index += 1
return -1
print (find("the doctor is in", '*'))
Select one:
a. -1
b. 0
c. 12
d. 13
Question 4
Not yet answered
Marked out of 1.00
Flag question
Question text
Given the following code, what will the output be?
import string
index = "Ability is a poor man's wealth".find("w")
print(index)
Select one:
a. 24
b. 0
c. 23
d. -1
Question 5
Not yet answered
Marked out of 1.00
Flag question
Question text
: 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.
Select one:
True
False
Question 6
Not yet answered
Marked out of 1.00
Flag question
Question text
What output will the following code produce?
print ("%s %d %f" % (5, 5, 5))
Select one:
a. 5 5 5.000000
b. 5 5 5
c. 5 5.000000
d. 0 5 5.0
Question 7
Not yet answered
Marked out of 1.00
Flag question
Question text
: To create a new object that has the same value as an existing object is know as creating an alias.
Select one:
True
False
Question 8
Not yet answered
Marked out of 1.00
Flag question
Question text
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]
b += 1
a += 1
b = 0
print (total)
Select one:
a. 14
b. 23
c. 0
d. 13
Question 9
Not yet answered
Marked out of 1.00
Flag question
Question text
: The following code:
for fruit in ["banana", "apple", "quince"]:
print (fruit)
will produce the following output:
banana apple quince
Select one:
True
False
Question 10
Not yet answered
Marked out of 1.00
Flag question
Question text
Given the following code, what will the output be?
mylist = ["now", "four", "is", "score", "the", "and seven", "time", "years", "for"]
a=0
while a < 7:
print (mylist[a],)
a += 2
Select one:
a. now is the time
b. now is the time for
c. for score and seven years
d. now four is score the and seven time years for
Question 11
Not yet answered
Marked out of 1.00
Flag question
Question text
The output of the following code will be:
fruit = "banana"
letter = fruit[1]
print (letter)
Select one:
a. b
b. a
c. n
d. banana
Question 12
Not yet answered
Marked out of 1.00
Flag question
Question text
A variable that has a data type of "str" cannot be a compound data type.
Select one:
True
False
Question 13
Not yet answered
Marked out of 1.00
Flag question
Question text
Traversal can only be accomplished with the "while" loop.
Select one:
True
False
Question 14
Not yet answered
Marked out of 1.00
Flag question
Question text
Strings are easily changed with string slices.
Select one:
True
False
Question 15
Not yet answered
Marked out of 1.00
Flag question
Question text
The elements of a list are immutable.
Select one:
True
False
Select one:
True
False
Question 2
Not yet answered
Marked out of 1.00
Flag question
Question text
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.
This principle is known as:
Select one:
a. trichotomy
b. abstraction
c. the distributive property
d. the transitive property
Question 3
Not yet answered
Marked out of 1.00
Flag question
Question text
Given the following code what will the output be?
def find(strng, ch):
index = 0
while index < len(strng):
if strng[index] == ch:
return index
index += 1
return -1
print (find("the doctor is in", '*'))
Select one:
a. -1
b. 0
c. 12
d. 13
Question 4
Not yet answered
Marked out of 1.00
Flag question
Question text
Given the following code, what will the output be?
import string
index = "Ability is a poor man's wealth".find("w")
print(index)
Select one:
a. 24
b. 0
c. 23
d. -1
Question 5
Not yet answered
Marked out of 1.00
Flag question
Question text
: 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.
Select one:
True
False
Question 6
Not yet answered
Marked out of 1.00
Flag question
Question text
What output will the following code produce?
print ("%s %d %f" % (5, 5, 5))
Select one:
a. 5 5 5.000000
b. 5 5 5
c. 5 5.000000
d. 0 5 5.0
Question 7
Not yet answered
Marked out of 1.00
Flag question
Question text
: To create a new object that has the same value as an existing object is know as creating an alias.
Select one:
True
False
Question 8
Not yet answered
Marked out of 1.00
Flag question
Question text
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]
b += 1
a += 1
b = 0
print (total)
Select one:
a. 14
b. 23
c. 0
d. 13
Question 9
Not yet answered
Marked out of 1.00
Flag question
Question text
: The following code:
for fruit in ["banana", "apple", "quince"]:
print (fruit)
will produce the following output:
banana apple quince
Select one:
True
False
Question 10
Not yet answered
Marked out of 1.00
Flag question
Question text
Given the following code, what will the output be?
mylist = ["now", "four", "is", "score", "the", "and seven", "time", "years", "for"]
a=0
while a < 7:
print (mylist[a],)
a += 2
Select one:
a. now is the time
b. now is the time for
c. for score and seven years
d. now four is score the and seven time years for
Question 11
Not yet answered
Marked out of 1.00
Flag question
Question text
The output of the following code will be:
fruit = "banana"
letter = fruit[1]
print (letter)
Select one:
a. b
b. a
c. n
d. banana
Question 12
Not yet answered
Marked out of 1.00
Flag question
Question text
A variable that has a data type of "str" cannot be a compound data type.
Select one:
True
False
Question 13
Not yet answered
Marked out of 1.00
Flag question
Question text
Traversal can only be accomplished with the "while" loop.
Select one:
True
False
Question 14
Not yet answered
Marked out of 1.00
Flag question
Question text
Strings are easily changed with string slices.
Select one:
True
False
Question 15
Not yet answered
Marked out of 1.00
Flag question
Question text
The elements of a list are immutable.
Select one:
True
False
1. False
A data type in which the values are made up of components, or elements, that are themselves values is known as an Collection data type
2. a. Tricotomy
3. a. -1
The above code returns the index of the character that is passed as second parameter in string passed as first parameter if it is not found after looping through entire array it will return -1
4. a. 24
The above code returns the index of character passed to the function in the string.
5. a True
6. a. 5 5 5.000000
first string, integer and float
7. b. False
Multiple variables containing reference to same object is known as aliases where as to create a new object having same value as existing object is known as clone
8.a. 14
In the above program mylist is a 2-dimensional matrix
and a iterates through rows and b iterates through columns but b runs only till 1 since given b<2
so the total is the sum of first 2 elemnts of each row
total = mylist[0][0]+mylist[0][1]+mylist[1][0]+mylist[1][1]+mylist[2][0]+mylist[2][1] =2+4+1+2+2+3 = 14
9. b. False
The output is
10. a. now is the time
As in each loop the value of a is incremented by 2 the values of a will be 0,2,4,6
the strings at those positions are printed\
11. option - (b). a
The indexes start from 0 the value at index 1 is a so a is printed
12. a. True
The types which are comprised of smaller types are known as compound data types
13. a. True
14. a. True
15. b . False
Elements in the list are mutable they can be changed
A data type in which the values are made up of components, or elements, that are themselves values is known as an Collection data type
2. a. Tricotomy
3. a. -1
The above code returns the index of the character that is passed as second parameter in string passed as first parameter if it is not found after looping through entire array it will return -1
4. a. 24
The above code returns the index of character passed to the function in the string.
5. a True
6. a. 5 5 5.000000
first string, integer and float
7. b. False
Multiple variables containing reference to same object is known as aliases where as to create a new object having same value as existing object is known as clone
8.a. 14
In the above program mylist is a 2-dimensional matrix
and a iterates through rows and b iterates through columns but b runs only till 1 since given b<2
so the total is the sum of first 2 elemnts of each row
total = mylist[0][0]+mylist[0][1]+mylist[1][0]+mylist[1][1]+mylist[2][0]+mylist[2][1] =2+4+1+2+2+3 = 14
9. b. False
The output is
banana apple quinceeach element is printed on a new line
10. a. now is the time
As in each loop the value of a is incremented by 2 the values of a will be 0,2,4,6
the strings at those positions are printed\
11. option - (b). a
The indexes start from 0 the value at index 1 is a so a is printed
12. a. True
The types which are comprised of smaller types are known as compound data types
13. a. True
14. a. True
15. b . False
Elements in the list are mutable they can be changed
No comments:
Post a Comment