Sep-05-2020, 09:37 AM
Sep-10-2020, 04:54 AM
At lest the following issues I could point out:
1) In the example starting with
2) You listed methods of the list class. However, method names are started with uppercased letter; if I'm learning python and don't know anything, I would try, e.g.
3) In the section "Python program to check if element exists in the list"; I would expect your code returns a boolean; However, there is
4) ...use an in-built function called copy()... It is method, not a function. You probably need to provide some details about this method. Discover: It returns shallow or deep copy of a list.
5) In section: "Python program to count occurrences of an element in a list"; You provide a code snippet, however, there is
6) 8. Python program to find the sum of elements in the list. What about
7) In section: "Python program to find the smallest number in a list". You sorted an array to find its minimal element. Sorting is quite heavy operation, its complexity O(N log N); It is better to traverse the list and find the smallest element with O(N) operations; what about
1) In the example starting with
Numbers = [23, 34, 43, 67]
..., your are talking about 5-th element in the list. It slightly confuses, because there is no fifth element in that list.2) You listed methods of the list class. However, method names are started with uppercased letter; if I'm learning python and don't know anything, I would try, e.g.
list.Append
and get the error. Since Python is case-sensitive, you listed wrong method names (there is no such method Append
, but append
exists).3) In the section "Python program to check if element exists in the list"; I would expect your code returns a boolean; However, there is
.index
method which do the same as your code snippet; and in
keyword to check if the elemnt is in the list.4) ...use an in-built function called copy()... It is method, not a function. You probably need to provide some details about this method. Discover: It returns shallow or deep copy of a list.
5) In section: "Python program to count occurrences of an element in a list"; You provide a code snippet, however, there is
.count
method which solves the problem.6) 8. Python program to find the sum of elements in the list. What about
sum
builtin function?7) In section: "Python program to find the smallest number in a list". You sorted an array to find its minimal element. Sorting is quite heavy operation, its complexity O(N log N); It is better to traverse the list and find the smallest element with O(N) operations; what about
min
builtin function;