0 of 59 questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 59 questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
What value of x will produce the output:
Hi
Mike
x=
if(x!=1):
print(‘Hello’)
else:
print(‘Hi’)
print(‘Mike’)
x=“Go”
if(x==“Go”):
print(‘Go Mike’)
else:
print(‘Stop’)
print(‘Mike’)
{ “The Bodyguard”:”1992″, “Saturday Night Fever”:”1977″}
select the keys
The variable release_year_dict is a Python Dictionary, what is the result of applying the following method: release_year_dict.values()
How many identical keys can a dictionary have
What is the result of the following code segment:1/2
What is the value of x after the following lines of code:
x=1
x=x+1
What is the result of the following operation 3+2*2?
In Python 3, what is the type of the variable x after the following: x=2/2
Consider the function delta, when will the function return a value of 1
def delta(x):
if x==0:
y=1;
else:
y=0;
return(y)
given the function add shown below, what does the following return :
def add(x):
return(x+x)
add(1)
What is the correct way to sort list ‘B’ using a method, the result should not return a new list, just change the list ‘B’.
what is the output of the following lines of code:
a=1
def do(x):
return(x+a)
print(do(1))
Write a function name add that takes two parameter a and b, then return the output of a + b (Do not use any other variable! Do not need to run it. Only write the code about how you define it.)
This response will be awarded full points automatically, but it can be reviewed and adjusted after submission.
Consider the tuple tuple1=(“A”,”B”,”C” ), what is the result of the following operation tuple1[-1]?
Consider the tuple A=((11,12),[21,22]), that contains a tuple and list. What is the result of the following operation A[1]:
Consider the tuple A=((11,12),[21,22]), that contains a tuple and list. What is the result of the following operation A[0][1]:
What is the result of the following operation: ‘A,B,C,D’.split(‘,’)
The method append does the following:
What is an important difference between lists and tuples?
Consider the following list : A=[“hard rock”,10,1.2]
what will list A contain affter the following command is run: del(A[1])
If A is a list what does the following syntax do: B=A[:]
what is the result of the following: len((“disco”,10))
What is the output of the following few lines of code?
A=[‘1’,‘2’,‘3’]
for a in A:
print(2*a)
What is the output of the following few lines of code?
x=5
while(x!=2):
print(x)
x=x–1
What is the output of the following few lines of code?
for i,x in enumerate([‘A’,‘B’,‘C’]):
print(i,2*x)
what is the output of the following:
for i in range(1,5):
if (i==2):
print(i)
Consider the class Points, what are the data attributes:
class Point(object):
def __init__(self,x,y):
self.x=x
self.y=y
def print_point(self):
print(‘x=’,self.x,‘y=’,self.y)
What is the result of running the following lines of code ?
class Points(object):
def __init__(self,x,y):
self.x=x
self.y=y
def print_point(self):
print(‘x=’,self.x,‘ y=’,self.y)
p1=Points(“A”,“B”)
p1.print_point()
What is the result of running the following lines of code ?
class Points(object):
def __init__(self,x,y):
self.x=x
self.y=y
def print_point(self):
print(‘x=’,self.x,‘ y=’,self.y)
p2=Points(1,2)
p2.x=2
p2.print_point()
what is the result of the following lines of code:
a=np.array([0,1,0,1,0])
b=np.array([1,0,1,0,1])
a*b
what is the result of the following lines of code:
a=np.array([0,1])
b=np.array([1,0])
np.dot(a,b)
what is the result of the following lines of code:
a=np.array([1,1,1,1,1])
a+10
how would you select the columns with the headers: artist, length and genre from the dataframe df and assign them to the variable y
Consider the dataframe df how would you access the element in the 1st row 3rd column
What function would you use to load a csv file in Pandas
Consider the following text file: Example1.txt:
This is line 1
This is line 2
This is line 3
What is the output of the following lines of code:
with open(“Example1.txt”,“r”) as file1:
FileContent=file1.read()
print(FileContent)
Consider the file object: File1. How would you read the first line of text?
What do the following lines of code do?
with open(“Example1.txt”,“r”) as file1:
FileContent=file1.readlines()
print(FileContent)
Consider the list A, what will be the result of the following operation: set(A)
Consider the Set: V={‘A’,’B’}, what is the result of V.add(‘C’)?
What is the result of the following: ‘1’ in {‘1′,’2’}?
In Python, if you executed name = ‘Lizz’, what would be the output of print(name[0:2])?
Consider the string A=’1934567′, what is the result of the following operation A[1::2]
In Python, what is the result of the following operation: ‘1’+’2′
What is the result of the following: ‘hello’.upper()?
Consider the string Name=”Michael Jackson” , what is the result of the following operation Name.find(‘el’)
What is the result of the following : str(1+1)
What is the result of the following: “ABC”.replace(“AB”, “ab”)?
How do you perform matrix multiplication on the numpy arrays A and B
What values does the variable out take if the following lines of code are run:
X=np.array([[1,0,1],[2,2,2]])
out=X[0,1:3]
out
What is the value of Z after the following code is run:
X=np.array([[1,0],[0,1]])
Y=np.array([[2,1],[1,2]])
Z=np.dot(X,Y)
What is the type of the following “7.1”
what is the type of the following: 1.0
What is the result of the following code segment: int(12.3)
What is the result of the following code segment: int(False)
Consider the following line of code:
with open(“Example.txt”,“a”) as file1:
What mode is the file object in?
What do the following lines of code do?
with open(“Example.txt”,“a”) as writefile:
writefile.write(“This is line A\n“)
writefile.write(“This is line B\n“)
what task do the following lines of code perform:
with open(‘Example2.txt’,’r’) as readfile:
with open(‘Example3.txt’,’w’) as writefile:
for line in readfile:
writefile.write(line)
check the mode of the open function for each file object