in Technology by

What will be the output of the following Python code?

  1. >>>list1 = [1, 3]
  2. >>>list2 = list1
  3. >>>list1[0] = 4
  4. >>>print(list2)

a) [1, 4]
b) [1, 3, 4]
c) [4, 3]
d) [1, 3]

1 Answer

0 votes
by

Answer: c
Explanation: Lists should be copied by executing [:] operation.

Related questions

0 votes
    What will be the output of the following Python code snippet? for i in [1, 2, 3, 4][::-1]: print (i) a) 4 3 2 1 b) error c) 1 2 3 4 d) none of the mentioned...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python program? def foo(x): x[0] = ['def'] x[1] = ['abc'] return id(x) q = ['abc ... (id(q) == foo(q)) a) Error b) None c) False d) True...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python code? print('*', "abcde".center(6), '*', sep='') a) * abcde * b) *abcde * c) * abcde* d) * abcde *...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python code? print("abc. DEF".capitalize()) a) Abc. def b) abc. def c) Abc. Def d) ABC. DEF...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python code? class tester: def __init__(self, id): self.id = str(id) id="224" >>>temp ... >>>print(temp.id) a) 12 b) 224 c) None d) Error...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python code? print("abc. DEF".capitalize()) a) Abc. def b) abc. def c) Abc. Def d) ABC. DEF...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python code? l=[1, 0, 2, 0, 'hello', '', []] list(filter(bool, l)) a) [1 ... ;] d) [1, 0, 2, 0, ‘hello’, ”, []]...
asked Dec 31, 2022 in Technology by JackTerrance
0 votes
    What is the output of print list1 + list2, if list1 = [ 'abcd', 786 , 2.23, 'john', 70.2 ] and ist2 = [123, 'john']?...
asked Nov 23, 2020 in Technology by JackTerrance
0 votes
    What will be the output of the following Python program? z=set('abc') z.add('san') z.update(set(['p', 'q'] ... ;, ‘c’, [‘p’, ‘q’], ‘san}...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python statement? >>>"a"+"bc" a) bc b) abc c) a d) bca...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the value of ‘result’ in following Python program? list1 = [1,2,3,4] list2 = [2,4,5,6] list3 = [2,6,7,8] result ... ) [1, 7, 8] c) [1, 2, 4, 7, 8] d) error...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python program? def foo(x): x[0] = ['def'] x[1] = ['abc'] return id(x) q = ['abc ... (id(q) == foo(q)) a) Error b) None c) False d) True...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    Consider a list2 with values 70,60,50. What will be the output statements considering that the above object has ... print(list2*3) Select the correct answer from above options...
asked Dec 29, 2021 in Education by JackTerrance
0 votes
    What will be the output of the following Python code? class tester: def __init__(self, id): self.id = str(id) id="224" >>>temp ... >>>print(temp.id) a) 12 b) 224 c) None d) Error...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python code? x = 'abcd' for i in x: print(i.upper()) a)a B C D b) a b c d c) error d)A B C D...
asked Jan 2, 2023 in Technology by JackTerrance
...