Question

3. use python Results/What Does it Do? cmp(list1, list2) len(list) max(list) min(list) list.append(obj) list.count(obj) list.extend(seq) list.index(obj)...

3. use python

Results/What Does it Do?

cmp(list1, list2)

len(list)

max(list)

min(list)

list.append(obj)

list.count(obj)

list.extend(seq)

list.index(obj)

list.insert(index, obj)

list.pop(obj=list[-1])

list.remove(obj)

list.reverse( )

list.sort([func])

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Explanation for each of the given:

1) cmp(list1, list2):

it is the inbuilt function in python. it takes two arguments

lets denote 1st argument as "n" and second argument as "m"

if "n<m" it will return "-1" as output

if "n==m" it will return "0" as output

if "n>m" it will return "1" as output

2) len(list)

len(list) will display the length of the list

3) max(list)

max(list) displays the maximum element or highest element in the list

4) min(list)

min(list) will display the minimum element or lowest element in the list

5 )list.append(obj)

list.append(obj) will add the element into the list

for example if we give "list.append(5)", The element "5" will be added into the list

6) list.count(obj)

list.count(obj) will count the number of occurences of the element in the list

7) list.extend(seq)

list.extend(seq) will take a list as an argument and it will combine the elements of the both lists i.e original list and list given as argument and displays the whole element in a list

8) list.index(obj)

list.index(obj) will display the index or position of the element in the list

indexes in the element starts from "0" position

9) list.insert(index, obj)

list.insert(index, obj) will add the element given in the argument in the index position given in the argument

for example if we give "list.insert(5,15)" it will add the element "15" in the "5th" position of the list

10) list.pop(obj=list[-1])

list.pop(obj=list[-1]) will delete the element in the "0 th" position of the list

11) list.remove(obj)

list.remove(obj) will remove or delete the argumented element from the list

for example "list.remove(5)" will delete the element "5" from the list

12 )list.reverse( )

list.reverse( ) will display the list in the reverse order

if the original list is "[5,6,7,8,9] ", the reversed list will be displayed as "[9,8,7,6,5]"

13) list.sort([func])

list.sort([func]) will sort the list in the ascending order

Proof for all the above given:

Add a comment
Know the answer?
Add Answer to:
3. use python Results/What Does it Do? cmp(list1, list2) len(list) max(list) min(list) list.append(obj) list.count(obj) list.extend(seq) list.index(obj)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In the python: Note 1: You may not use these python built-in functions: sorted(), min(), max(),...

    In the python: Note 1: You may not use these python built-in functions: sorted(), min(), max(), sum(), pow(), zip(), map(), append(), count() and counter(). For questions 1, 2 and 4: Ask the user to enter the size of a list. Fill the list with random numbers 0-9 and print the list. 1- (8 points) luckyNumbers.py: Find the sum of the numbers in a list, except the number 7 is considered unlucky, so we ignore it and do not include 7's...

  • Python Write a function index_last(elem, seq) that takes as inputs an element elem and a sequence...

    Python Write a function index_last(elem, seq) that takes as inputs an element elem and a sequence seq, and that uses recursion (i.e., that calls itself recursively) to find and return the index of the last occurrence of elem in seq. The sequence seq can be either a list or a string. If seq is a string, elem will be a single-character string; if seq is a list, elem can be any value. Don’t forget that the index of the first...

  • BlockPy: #33.8) Maximum Odd Use the Min/Max pattern to write a function maximum_odd that finds the...

    BlockPy: #33.8) Maximum Odd Use the Min/Max pattern to write a function maximum_odd that finds the highest odd value in the list (consumes a list of numbers and returns a number). Use the provided helper function is_odd (that consumes a single number and returns a boolean indicating whether it is true or false). Do not change the helper function is odd. Call your maximum_odd function on your favorite list of numbers Console Feedback: Instructor Feedback You cannot use the builtin...

  • Something is preventing this python code from running properly. Can you please go through it and...

    Something is preventing this python code from running properly. Can you please go through it and improve it so it can work. The specifications are below the code. Thanks list1=[] list2=[] def add_player(): d={} name=input("Enter name of the player:") d["name"]=name position=input ("Enter a position:") if position in Pos: d["position"]=position at_bats=int(input("Enter AB:")) d["at_bats"] = at_bats hits= int(input("Enter H:")) d["hits"] = hits d["AVG"]= hits/at_bats list1.append(d) def display(): if len(list1)==0: print("{:15} {:8} {:8} {:8} {:8}".format("Player", "Pos", "AB", "H", "AVG")) print("ORIGINAL TEAM") for x...

  • use python to solve this problem Problem 3- contains.py: Sub-list containment You will write a function...

    use python to solve this problem Problem 3- contains.py: Sub-list containment You will write a function to determine whether a given sub-list" s appears within another given list 1. The problem will guide you through the problem breakdown. Essentially, first you can solve the easier problem if the "sub-list" s appears within 1 at a specific position i. Then Practice goal: Guided practice with modular thinking and programming. Problem 3a Partial equality [5 points] Write a function contains_at that accepts...

  • Please do this in C++ Please do this in C++ Array List Operations For an array...

    Please do this in C++ Please do this in C++ Array List Operations For an array based list, (A) If the Length operation associated with an unsorted list returns 15, and we then call the Delete operation for the list, pass it a value that matches the 7th item in the list: 1). What is the index of the component that is deleted? 2). What is the index of the component that takes its place? 3). What does the Length...

  • 3. What does this code do? Write an explanation in English python n=1 while (n <1000):...

    3. What does this code do? Write an explanation in English python n=1 while (n <1000): print(n) n-n

  • python 2..fundamentals of python 1.Package Newton’s method for approximating square roots (Case Study 3.6) in a...

    python 2..fundamentals of python 1.Package Newton’s method for approximating square roots (Case Study 3.6) in a function named newton. This function expects the input number as an argument and returns the estimate of its square root. The script should also include a main function that allows the user to compute square roots of inputs until she presses the enter/return key. 2.Convert Newton’s method for approximating square roots in Project 1 to a recursive function named newton. (Hint: The estimate of...

  • Subject: Algorithm. solve only part 3 and 4 please. 2.2 Selection- 5 points each 1. Run the simultaneous min-and-max algorithm on the array A 4, 2, 12, 6, 13,9,15). (16, 7, 10, 1,5, 11,3,8, 14, 2....

    Subject: Algorithm. solve only part 3 and 4 please. 2.2 Selection- 5 points each 1. Run the simultaneous min-and-max algorithm on the array A 4, 2, 12, 6, 13,9,15). (16, 7, 10, 1,5, 11,3,8, 14, 2. Explain why the above algorithm is better than the naive algorithm for finding minimum and maximum separately. How many comparisons does the naive algorithm do? How many comparisons does the simultaneous min and max do? 3. Use the randomized select algorithm based on partition...

  • #Practical Quiz 3 #Add a comment above each line of code describing what it does. #Be...

    #Practical Quiz 3 #Add a comment above each line of code describing what it does. #Be specific. Use multiple comment lines if you need to #OR write code below the comments requesting code. #Make sure your file runs and generates the correct results. def main(): #define variable str1 with string "Hello" str1 = "Hello" #print out the 2nd letter print(str1[1]) #START QUIZ HERE print(str1[-2]) print(str1[:3]) print(str1[2:len(str1)-1]) str2 = "World" print(str1+str2) #write code below to iterate over the str1 and print...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT