
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
![Task 2
Write a Python program that takes a list as an input from the user. Then creates a new list excluding the first and last two elements of the given list and prints
the new list. If there are not enough elements in the list to do the task, the print "Not possible".
Note: You may use list slicing.
Sample Input 1:
[10, 20, 24, 25, 26, 35, 70]
Sample Output 1:
[24, 25, 26]
============
Sample Input 2:
[10, 20, 24, 25, 26]
Sample Output 2:
[24]](https://content.bartleby.com/qna-images/question/667e086a-245f-406d-8e31-f91ea07f1ebc/e53ce6f3-a008-41ec-b2ed-55cd96dc73ea/caq0vy9_thumbnail.png)
Transcribed Image Text:Task 2
Write a Python program that takes a list as an input from the user. Then creates a new list excluding the first and last two elements of the given list and prints
the new list. If there are not enough elements in the list to do the task, the print "Not possible".
Note: You may use list slicing.
Sample Input 1:
[10, 20, 24, 25, 26, 35, 70]
Sample Output 1:
[24, 25, 26]
============
Sample Input 2:
[10, 20, 24, 25, 26]
Sample Output 2:
[24]
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- 121: Write a Python program that prompts the user to enter 3 numbers, store these numbers in a list, and then calculate the average of the numbers stored in the list. Your average calcualtion cose should work for any number of items in the list (Hint: use the len() method)arrow_forwardGiven the following list: numbers = [15, 27, 17, 23, 10, 2, 46] a) Provide a statement that stores the value of the fourth item in the list in variable a: b) Provide a statement that store the value of the last list item in the variable b: c) What is the value of a / b (provide answer in the same format Python would)?arrow_forwardThe chapter is nested lists Create code in python using for loops Thanks!arrow_forward
- Please help me, create your won code Create a function that takes a 2D list and an integer v, and returns the number of times the value v is in the list of lists. Add the Nsteps variable to count how many times the loops execute and display a message.• The main program must give a 2D list (no need to generate it, just create it manually), call the function, and display the result example it's the picturearrow_forwardGiven a list input_string_list, generate and print a new list that has the even numbers on the left and the odd numbers on the right. You should keep the ordering of the even and odd numbers the same as in the original list. Hint: Use the .split() function to read in the list and convert each element of the list to an integer using either a for loop or a list comprehension Sample Input 1 1,4,3,2,5,6,7 Sample Output 1 [4, 2, 6, 1, 3, 5, 7] Sample Input 2 98,97,100,101,102 Sample Output 2 [98, 100, 102, 97, 101]arrow_forwardDevelop a Python program. 1. Create an list to hold 5 elements. 2. Use for loop to collect 5 numbers from user input, save each number to the list 3. calculate the average number of these 5 numbers.arrow_forward
- Create a program that generates an eight-digit account number. The program should generate eight random numbers, each in the range of 0 to 9, and assign each number to a list element. Then write another loop that displays the entire contents of the list without the []. use pythonarrow_forwardpython LAB: Subtracting list elements from max When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. This can be done by normalizing to values between 0 and 1, or throwing away outliers. Write a program that adjusts a list of values by subtracting each value from the maximum value in the list. The input begins with an integer indicating the number of integers that follow.arrow_forwardWrite a program that uses 2 lists. Call the lists Items and Basket respectively. The first list will contain a list of at least 10 items (make up your own items) to select from. The second list will be used to add the selected items in the new list.(Basket) Your program should do the following in a Loop until the user exits the loop: Display the list (print out 1, 2, 3, 4, etc. before each item in the list (Hint: Use Index + 1) Prompt the user to select an item from the Items list. Add the selected item to the new list (Basket) (HINT: Use number entered - 1 for the Index) When the user selects 0, exit the loop and print out the new list of items (Basket) Use Microsoft Word to create your Outline and Logic sections. You can copy and paste your Python code at the end under the heading "Code:" Upload your work into the assignment when completedarrow_forward
- Largest Value. Create a program that uses a list to store input values, and outputs the largest value entered at its location in the list. The program shall accept input values until the user enters -1. And Next Movie Time. Create a program that shows the user when the next showing for a movie is. The program first reads the different showing times (only hours) in a 24-hour clock format (that is, 1PM is 13, 6PM is 18, etc.). The program then asks when a customer wants to go to the movies. The program replies with the time for the next showing. If the next showing matches the hour input by the customer, show the next showing after that. If the next showing is past the last one, the program shall output, “There are no more showings.”, Here is a sample execution: I am trying to use these programs as practice for practicing lists, strings and inputs. But am struggling a bit after laying down the foundation on each problem. I plan to put them into thonny to compare them with my own work.arrow_forwardPython code easy way plsarrow_forwardPython code Could you write the code in a different way but get the same result.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education