Foundations of independent audit of AI Systems
What is a "Len" function?
"len" determines the length of a set
What is a "sum" function?
"sum" takes the total value of a set of numbers or from a tuple
In Python, what is the result of the following operation '1'+'2'
'12'
>>>>Consider the following Python Dictionary: Dict={"A":1,"B":"2","C":[3,3,3],"D":(4,4,4),'E':5,'F':6} , what is the result of the following operation: Dict["D"]
(4, 4, 4)
How many duplicate elements can you have in a set?
0, you can only have one unique element in a set
In Python, if you executed var = '01234567', what would be the result of print(var[::2])?
0246
What is the result of the following line of code: "0123456".find('1')
1
what is the output of the following lines of code: x=3 y=1 while(y!= x): print(y) y=y+1
1,2
What is the value of c after the following block of code is run ? a=1 def add(b): return a+b c=add(10)
11
what is the output of the following lines of code: A=[3,4,5] for a in A: print(a)
3,4,5
i!=6
i is not equal to six
What is the type of the following int(1.0)?
int
What is the intersection of set S and U S={'A','B','C'} U={'A','Z','C'}
{'A', 'C'}
What is the value of c after the following block of code is run ? def f(*x): return sum(c)
return the total of a variable amount of parameters
What is the difference between a "sorted" function and a "sort" function?
Sort function sorts the existing list, and a sorted function creates a new sorted list from the existing data.
In Python, if you executed name = 'Lizz', what would be the output of print(name[0:2])?
Li
What is an important difference between lists and tuples?
Lists are mutable tuples are not
Consider the following string: Numbers="0123456" how would you obtain the even elements ?
Numbers[::2]
What is the syntax to obtain the first element of the tuple: A=('a','b','c')
A[0]
how do you access the last element of the tuple: A=(0,1,2,3) :
A[3] A[-1]
what is the output of executing the following statement: # print('Hello World!')
there is no output as it is a comment correct
Consider the following dictionary: D={'a':0,'b':1,'c':2} What is the output of the following D['b'] :
1
What is the result of the following operation in Python: 3 + 2 * 2
7
Using the Practice Lab find the result of executing print("Hello\nWorld!") statement
Hello World!'
After applying the following method,L.append(['a','b']), the following list will only be one element longer.
True
>>Consider the list B=["a","b","c"] what is the result of the following B[1:]
['b', 'c']
Branching
allows for run different statements for a different input.
Enter the code to convert the number 1 to a Boolean ?
bool(1)
Consider the following dictionary: D={'a':0,'b':1,'c':2} What is the result of the following: D.values()
dict_values([0, 1, 2])
What is the function "mult"?
it multiplies two intigers
Given myvar = 'hello', how would you convert myvar into uppercase?
myvar.upper()
What is the result of the following lines of code: S={'A','B','C'} U={'A','Z','C'} U.union(S)
{'A', 'B', 'C', 'Z'}