Computer Science, asked by srishtigupta26, 2 months ago

. What will be the output of below Python code? list1=[1,3,5,2,4,6,2] list1.remove(2) print(sum(list1))
A. 18
B. 19
C. 21
D. 22​

Answers

Answered by jai696
6

21

Explanation:

list.remove(2) removed the first occurrence of 2 from the list.

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Answered by BrainlyYoda
4

The output of the given Python code is 21

Explanation

list1 is a list and it contains integers.

list1.remove(2) removes the first matching element 2 from the list so, the list is left with elements which are [1, 3, 5, 4, 6, 2]

sum(list1) adds up the values left in list1 that is [1, 3, 5, 4, 6, 2]

print(sum(list1)) prints the sum of values present in list.

Extra Information

A list contains python objects and objects inside are separated by a comma (,) and enclosed within square brackets.

List can contain values of the types Integers, Floats, Lists, and Tuples.

Integer values such as the whole numbers can be positive, negative, and zero. Example => 5, 6, 7, -8, 0 etc.

Float values are those values that consist of decimal numbers. Example => 5.25, 9.187 etc.

Python was created by Guido van Rossum and came into existence in 1991. It is a high-level and general programming language. It is a very lucid programming language as it has a good language construct and object-oriented approach. It is dynamically typed and garbage-collected.

Similar questions