Your last recorded submission was on 2022-08-09, 21:54 IST
All questions carry equal weightage. All Python code is assumed to be executed using Python3. You may submit as many times as you like within the deadline. Your final submission will be graded.
Note:
If the question asks about a value of type string, remember to enclose your answer in single or double quotes.
If the question asks about a value of type list, remember to enclose your answer in square brackets and use commas to separate list items.
One of the following 10 statements generates an error. Which one? (Your answer should be a number between 1 and 10.)
x = [[3,5],"mimsy",2,"borogove",1] # Statement 1
y = x[0:50] # Statement 2
z = y # Statement 3
w = x # Statement 4
x[1] = x[1][:5] + 'ery' # Statement 5
y[1] = 4 # Statement 6
w[1][:3] = 'fea' # Statement 7
z[4] = 42 # Statement 8
x[0][0] = 5555 # Statement 9
a = (x[3][1] == 1) # Statement 10
Ans: 7
2.5 points
2.5 points
Consider the following lines of Python code.
b = [43,99,65,105,4]
a = b[2:]
d = b[1:]
c = b
d[1] = 95
b[2] = 47
c[3] = 73
Which of the following holds at the end of this code?
What is the value of endmsg after executing the following lines?
startmsg = "anaconda"
endmsg = ""
for i in range(1,1+len(startmsg)):
endmsg = endmsg + startmsg[-i]
Ans: "anaconda"
2.5 points
What is the value of mylist after the following lines are executed?
def mystery(l):
l = l[2:]
return(l)
mylist = [7,11,13,17,19,21]
mystery(mylist)
Ans: [7,11,13,17,19,21]
2.5 points
You may submit any number of times before the due date. The final submission will be considered for grading.
No comments