Python (Actual) Exam with Complete Solutions
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"] - ANSWER-(4, 4, 4)
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) - ANSWER-When the input is 0 When the input is 0
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) - ANSWER-When the input is 0 When the input is 0 - correct
Given myvar = 'hello', how would you convert myvar into uppercase? - ANSWER-
myvar.upper()
How many duplicate elements can you have in a set? - ANSWER-0, you can only have
one unique element in a set
In Python, if you executed name = 'Lizz', what would be the output of print(name[0:2])? -
ANSWER-Li
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"] - ANSWER-(4, 4, 4)
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) - ANSWER-When the input is 0 When the input is 0
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) - ANSWER-When the input is 0 When the input is 0 - correct
Given myvar = 'hello', how would you convert myvar into uppercase? - ANSWER-
myvar.upper()
How many duplicate elements can you have in a set? - ANSWER-0, you can only have
one unique element in a set
In Python, if you executed name = 'Lizz', what would be the output of print(name[0:2])? -
ANSWER-Li