Week 2 - Quiz (Programming, Datastructures and Algorithms using Python) (NPTEL 2022 - CS26)
- Get link
- X
- Other Apps
One of the following 10 statements generates an error. Which one?
(Your answer should be a number between 1 and 10.)
x = [1,"abcd",2,"efgh",[3,4]] # Statement 1 y = x[0:6] # Statement 2 z = x # Statement 3 w = y # Statement 4 x[1] = x[1][0:3] + 'd' # Statement 5 y[2] = 4 # Statement 6 z[1][1:3] = 'yzw' # Statement 7 z[0] = 0 # Statement 8 w[4][0] = 1000 # Statement 9 a = (x[4][1] == 4) # Statement 10
Accepted Answers: 7
(Type: Numeric) 7
2.5 points
2.5 points
Consider the following lines of Python code.
x = [423,'b',37,'f'] u = x[1:] y = u w = x u = u[0:] u[1] = 53 x[2] = 47After these execute, which of the following is correct?
Accepted Answers: A
What is the value of second after executing the following lines?
first = "tarantula" second = "" for i in range(len(first)-1,-1,-1): second = first[i] + second
Accepted Answers: "tarantula"
(Type: Regex Match) \s*\"tarantula\"\s*
(Type: Regex Match) \s*\'tarantula\'\s*
2.5 points
What is the value of list1 after the following lines are executed?
def mystery(l): l = l[0:5] return() list1 = [44,71,12,8,23,17,16] mystery(list1)
Accepted Answers: [44,71,12,8,23,17,16]
(Type: Regex Match) \s*\[\s*44\s*,\s*71\s*,\s*12\s*,\s*8\s*,\s*23\s*,\s*17\s*,\s*16\s*\]\s*
- Get link
- X
- Other Apps
Comments
Post a Comment