Question

Python

Which line changes the length of list L? L = [] L.append(4) L[0] = len(L) L = [5] OL = [5] OL= ] L.append(4) OL[0] = len(L)

I think the answer is L=[5]. Please explain

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

Answer:

L = []  # initializes an empty list
L.append(4)  # changes L to [4]. so, length of list changed here
L[0] = len(L)  # change L to [1]. but still length of list is 1(unchanged)
L = [5]  # change L to [5]. but still length of list is 1(unchanged)

so, only L.append(4) changes the length of list.
Answer: c)  L.append(4)
Add a comment
Know the answer?
Add Answer to:
Python I think the answer is L=[5]. Please explain Which line changes the length of list...
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
  • PYTHON I need help with this Python problem, please follow all the rules! Please help! THANK...

    PYTHON I need help with this Python problem, please follow all the rules! Please help! THANK YOU! Bonus Question Implement an efficient algorithm (Python code) for finding the 11th largest element in a list of size n. Assume that n will be greater than 11. det find 11th largest numberlissy Given, lissy, a list of n integers, the above function will return the 11th largest integer from lissy You can assume that length of lissy will be greater than 11....

  • PYTHON Im stuck, this is one line of code but I just cant remember it... Please...

    PYTHON Im stuck, this is one line of code but I just cant remember it... Please Help! Thank YOU! LIST COMPREHENSION Create a python list, that stores exactly [0,'hi', 2, thi', 4, thi', 6, 'hi', 8, thi') using python list comprehension. You can write one line of python code directly below (in the text box) or you can upload a python file having only one line of code. Write your solution (one line of python code) here. Enter your answer...

  • Python recursive function: Given an ordered list L. A permutation of L is a rearrangement of...

    Python recursive function: Given an ordered list L. A permutation of L is a rearrangement of its elements in some order. For example (1,3, 2) and (3, 2, 1) are two different permutations of L=(1,2,3). Implement the following function: def permutations (lst, low, high) The function is given a list 1st of integers, and two indices: low and high (lows high), which indicate the range of indices that need to be considered The function should return a list containing all...

  • In python, PART A: I am trying to get a dictionary with size(4, 5, 6) as...

    In python, PART A: I am trying to get a dictionary with size(4, 5, 6) as keys and an array for key containing a list of values (words from file of respective size) associated with those keys I am reading from a file of strings, where I am only interested with words of length 4, 5, and 6 to compute my program reading the text file line by line: At first, I have an empty dictionary then to that I...

  • python nts) Given L = [4, 5, 6, 81, write instructions for the following: Example: Print...

    python nts) Given L = [4, 5, 6, 81, write instructions for the following: Example: Print first number in the list Print the last number in the list Change L to (4,5, 6,8,20] by appending the integer 20 to L Reverse the elements in the list L Change L to ['new', 4, 5, 6, 8] print(L[O]) priet (l ) Ω4.20 points) Given L-4, [5, 6], 7], what is the result of the following: a) LII I1 b) LI-21 c) L.pop...

  • Please explain how to derive this and provide the answer. A bar of length L and...

    Please explain how to derive this and provide the answer. A bar of length L and uniform density is held horizontally against a wall by a pivot at one end and a rope of tension T which pulls up and to the left making an angle θ with the vertical wall. The rope is attached to the bar at a distance l L from the wall. A mass M is resting at the end of the bar. If the bar...

  • Python 2.7 Write a function cumsum() that takes a list l as argument and returns the...

    Python 2.7 Write a function cumsum() that takes a list l as argument and returns the cumulative sum (also known as the prefix sum) of l, which is a list, say cs of the same length as l such that each element cs[i] is equal to the sum of the first i + 1 elements of l, i.e., cs[i] == l[0] + l[1] + l[2] + ... + l[i] You should not modify the argument list l in any way....

  • *PYTHON EXPERTS ONLY PLEASE* Please provide the answer coded in Python using comments to explain code...

    *PYTHON EXPERTS ONLY PLEASE* Please provide the answer coded in Python using comments to explain code function. Good answers will be rated with thumbs up! Please answer both parts. Thank you for your time. Question 3 - Suppose you have a file named numbers.csv which contains a bunch of integers, five per line of text, separated by commas. Write code below that will open the _le, read the numbers from it, and print the sum of all the even numbers...

  • Please answer all questions I. Give an example of 2. List operators for arithmetic expressions in...

    Please answer all questions I. Give an example of 2. List operators for arithmetic expressions in python. 3 Give an eample on expression in python 4. List operators for rational/boolean expression in python. 5. Is there any type conversion in the following expression, and why? 9/3.0

  • B. List the impact of changes in divorce and child custody laws. c. Explain the ways in which mat...

    *sociology please answer in 3-5 sentences for each b. List the impact of changes in divorce and child custody laws. c. Explain the ways in which mate selection is not random d. Explain the various rules governing marriage. e. Discuss the various alternative family arrangements in contemporary American society. b. List the impact of changes in divorce and child custody laws. c. Explain the ways in which mate selection is not random d. Explain the various rules governing marriage. e....

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
ADVERTISEMENT