
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

Transcribed Image Text:**Educational Task: Python Programming Exercise**
**Objective:**
Develop a Python program that performs the following tasks:
1. **List Declaration:**
- Create a list named `my_list` containing the integers: 6, 5, 1, -3, 10, 0, 4.
2. **List Modification:**
- Modify the elements of `my_list` based on these criteria:
- If an element is an integer less than three, increase its value by 2.
- If an element is an integer greater than or equal to three, decrease its value by 3.
3. **Output Requirement:**
- After modification, display only those items of the list that exist at even indices, arranged in reverse order.
**Instructions:**
- Ensure the program is saved as a Python file and attached as required.
Note: There are no graphs or diagrams included in this task.
Expert Solution

arrow_forward
Step 1
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
- Need pseudocode for thisarrow_forwardPYTHON ONLY AND PLEASE COMMENT CODE 1. A) write a For loop that iterates through a list of products (any number of products) that are sold in a store and prints them. [examples: fan, fridge, freezer, washer, etc.]. b) copy the code from a) and use the same loop to add more products(any)to the list. You must use list methods to add. c) Copy the code from c), and search for a specific product (any), if the product is found the loop is terminated. Make sure to use else in the for loop. d) Create an empty dictionary, then add 4 entries (the key is a word, the value is word’s frequency in a book). [example: {‘street’: 23}]. e) Create a for loop to access the entries from d) and print the keys and values. f) Copy the code from e) and search for a specific key in the dictionary and prints its value. The program prints a message “ the {key} is not found”, if the key does not exist.arrow_forwardQ1.Customers often ask for movies by actor. Write a query that lists the actors in the movies in the FLIX inventory. Your results should include the actor’s name (first and last) and the movie title. To help FLIX employees answer the customers’ questions quickly, sort the results by the actors’ last name and first name.Q2.FLIX would like to create a section of their inventory called “Classics.” To do this, they need to identify movies with a release date of at least 25 years ago. Of course, this 25-year age will change each year so be sure your query accounts for this.Write a query that identifies these movies. Your results should include the release date and the movie title. Sort your results by release date.Q3.FLIX managers want a report that lists All actors (whether they have been in one of the movies in the database or not.All movies (whether they have an actor associated with them or not.Sort results by the actor’s stage name.arrow_forward
- #include <iostream>// ask user how long is the list// modify code to ask user what is the starting value of the list// ask user how much to add to each list elementusing namespace std; int main(){int n[10]; // list of length 10n[0]=23;for (int i=1; i<=9; i++)n[i]=n[i-1] + 5;for (int j=0; j<=9; j++)cout<<n[j]<<" "; system("PAUSE");return 0;}arrow_forward-Write a statement that assigns the list of seasons of the year to the variable seasons in the following order in Python: Winter Spring Summer Fall -Write one statement that uses the in operator to test if the element 'surfing' is present in list listActivities and print the results. -Using the del keyword and/or the slicing operator:, delete the 3rd through the 5th element from the list listTemps. You've been provided a list named myLst, of six integers. Set the fourth element's value to 7.arrow_forwardAssume my_list is a list of integer values. Write a list comprehension statement in Python that creates a second list named plus_one. The plus_one list should contain the values of my_list with 1 added to each value. For example, if my_list contains the following values: [10, 20, 30, 40, 50] The plus_one list should contain these values: [11, 21, 31, 41, 51]arrow_forward
- Assume the following statement appears in a program: names = I"'Ms. Sri"' Write statements to demonstrate how to add your name to the end of the list in three ways: using the insert() method, using the append() method, and using list concatenation. IN PYTHONarrow_forward2.Assume list1 is a list of integers. Write a statement that uses a list comprehension to create a second list containing the elements of list1 that are greater than 100.arrow_forwardWhat occurs when using the ref or out keyword with an array parameter?arrow_forward
- python help, please show all steps and include comments Write a function largerLst() that takes a list of numbers (i.e., int or float values) as a parameter and returns a new list constructed out of it. The list returned has all the values in the parameter list that are larger than the element immediately to their right, that is, larger than their right neighbor. If the parameter list is empty or there are no values larger than their right neighbor, then the function returns an empty list. Note that the last element in the list will never be included in the list returned since it does not have a right neighbor. The function should not change the parameter list in any way. Note that a correct solution to this problem must use an indexed loop That is, one that makes a call to the range() function to generate indices into the list which are used to solve the problem (Review lecture notes 8-1). A solution that does not use an indexed loop will not be accepted. Note in particular that you…arrow_forwardAssume that the variable data refers to the list [5, 3, 7]. Write the expressions that perform the following tasks: a. Replace the value at position o in data with that value's negation. b. Add the value 10 to the end of data. c. Insert the value 22 at position 2 in data. d. Remove the value at position 1 in data. e. Add the values in the list newData to the end of data. f. Locate the index of the value 7 in data, safely. g. Sort the values in data.arrow_forwardIn DrRacket, which of the following is the signature of primitive append? A) List List -> ListOfList B) List List -> List C) ListOfList -> ListOfList D) List List ... List -> ListOfList E) List List ... List -> Listarrow_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