Question

In: Computer Science

Please solve everything using Python 3 1. What does list contain after the following code is...

Please solve everything using Python 3

1. What does list contain after the following code is executed?

list = [82, 27, 66, 18, 40, 93, 85, 29]

list.append(50)

list.insert(3, 99)

list.pop()

a. [82, 27, 66, 99, 18, 40, 93, 85, 29]

b. [50, 82, 27, 99, 66, 18, 40, 93, 85]

c. [27, 66, 99, 18, 40, 93, 85, 29, 50]

d. [82, 27, 99, 66, 18, 40, 93, 85, 29]

2. What does list contain after the following code is executed?

list = [77, 41, 92, 30, 38, 12, 63]

list.sort()

list.insert(2, 88)

list.pop(5)

a. [12, 30, 88, 38, 63, 77, 92]

b. [92, 77, 88, 63, 41, 30, 12]

c. [12, 88, 30, 38, 63, 77, 92]

d. [12, 30, 88, 38, 41, 77, 92]

3. What does the list states contain after the following code is executed?

states = ['NJ', 'TN', 'WI', 'UT']

states.extend(['PA', 'KY', 'NY'])

states.remove('UT')

states.sort(reverse=True)

a. ['WI', 'UT', 'TN', 'PA', 'NY', 'NJ', 'KY']

b. ['WI', 'PA', 'TN', 'NJ', 'NY', 'KY']

c. ['WI', 'TN', 'PA', 'NY', 'NJ', 'KY']

d.['NJ', 'TN', 'WI', 'PA', 'KY', 'NY']

Solutions

Expert Solution

1)Solution is (a) methods are explained below one by one as comments.

2)Solution is (d) methods are explained below one by one as comments.

3)Solution is (c) methods are explained below one by one as comments.


Related Solutions

1. Please program the following in Python 3 code. 2. Please share your code. 3. Please...
1. Please program the following in Python 3 code. 2. Please share your code. 3. Please show all outputs. Instructions: Run Python code  List as Stack  and verify the following calculations; submit screen shots in a single file. Postfix Expression                Result 4 5 7 2 + - * = -16 3 4 + 2  * 7 / = 2 5 7 + 6 2 -  * = 48 4 2 3 5 1 - + * + = 18   List as Stack Code: """...
Please solve the following using if statements in python 3. User specifies the number of books...
Please solve the following using if statements in python 3. User specifies the number of books ordered, and if the order is online, or not. You can collect the second input by asking the user to enter 1 for online, and 0 for offline. You can assume that the user will enter 1 or 0 as directed. Unit price for a book is 15$. Online orders get shipping cost added: per book 25 cents upto 10 books, after that, flat...
Please provide Python code that does the following: 3) Write a program that takes a string...
Please provide Python code that does the following: 3) Write a program that takes a string as input, checks to see if it is comprised entirely of letters, and if all those letters are lower case. The output should be one of three possible messages: Your string is comprised entirely of lower case letters. Your string is comprised entirely of letters but some or all are upper case. Your string is not comprised entirely of letters. Your program may NOT:...
Please write a python code for the following. Use dictionaries and list comprehensions to implement the...
Please write a python code for the following. Use dictionaries and list comprehensions to implement the functions defined below. You are expected to re-use these functions in implementing other functions in the file. Include a triple-quoted string at the bottom displaying your output. Here is the starter outline for the homework: a. def count_character(text, char): """ Count the number of times a character occurs in some text. Do not use the count() method. """ return 0 b. def count_sentences(text): """...
Please write a python code for the following. Use dictionaries and list comprehensions to implement the...
Please write a python code for the following. Use dictionaries and list comprehensions to implement the functions defined below. You are expected to re-use these functions in implementing other functions in the file. Include a triple-quoted string at the bottom displaying your output. Here is the starter outline for the homework: g. def big_words(text, min_length=10): """ Return a list of big words whose length is at least min_length """ return [] h. def common_words(text, min_frequency=10): """ Return words occurring at...
Please solve using simple python programming language and make it easy to understand explain your code...
Please solve using simple python programming language and make it easy to understand explain your code as I am a beginner, use appropriate variable names which make the code easy to understand and edit if needed. A subsystem responsible for delivering priority numbers to an automated irrigation system has stopped working and you need to deliver a quick fix that will work until the actual subsystem is fixed by senior developer. As you are the newest addition to the development...
Solve with Python: The following is the color code of the jackets of employees for a...
Solve with Python: The following is the color code of the jackets of employees for a companies annual conference. The Color is determined by the Employee category and the state in which they work. Employee Category Executive (1) Director(2) Manager(3) Worker(4) State Jacket Color State Jacket Color State Jacket Color State Jacket Color NY, NJ, PA Blue NY, NJ, PA Purple NY, NJ, PA Red NY, NJ, PA Black TX, LA, FL White TX, LA, FL Green TX, LA, FL...
Python 3 can you explain what every single line of code does in simple terms please...
Python 3 can you explain what every single line of code does in simple terms please so basically # every single line with an explanation thanks def longest(string): start = 0;end = 1;i = 0; while i<len(string): j = i+1 while j<len(string) and string[j]>string[j-1]: j+=1 if end-start<j-i: end = j start = i i = j; avg = 0 for i in string[start:end]: avg+=int(i) print('The longest string in ascending order is',string[start:end]) print('The average is',avg/(end-start)) s = input('Enter a string ')...
Please use C++ and linked list to solve this problem Linked list 1 -> 3 ->...
Please use C++ and linked list to solve this problem Linked list 1 -> 3 -> 4 -> 5-> 6 ->7 replaceNode( 5 , 6) // Replace 5 with 6     result 1 -> 3 -> 4 -> 6 -> 6 ->7 Base code #include <iostream> using namespace std; class Node { public:     int data;     Node *next;     Node(int da = 0, Node *p = NULL) {         this->data = da;         this->next = p;     } };...
Solve following using Program R studio. Please show code and results. Thank you. 3. Assume that...
Solve following using Program R studio. Please show code and results. Thank you. 3. Assume that ? is a random variable represents lifetime of a certain type of battery which is exponentially distributed with mean 60 hours.   a. Simulate 500 pseudorandom numbers (using set.seed(10)) and assign them to a vector called expran. b. Calculate average of simulated data and compare it with corresponding theoretical value. c. Calculate probability that lifetime is less than 50 hours using cumulative probability function. d....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT