program7.py This assignment requires the main function and a custom value-returning function. The value-returning function takes a list of random integers as its only argument and returns a smaller list of only the elements that end with 7. This value-returning function must use a list comprehension to create this smaller list. In the main function, code these steps in this sequence: Set random seed to 42 import random random.seed(42) create an empty list that will the hold random integers. use a loop to add 50 random integers to the list. All integers should be between 200 and 250, inclusive. Duplicates are okay. sort the list in ascending order and then use another loop to display all 50 sorted integers on one line separated by spaces. print a slice showing list elements indexed 5 through 10, inclusive. print a second slice showing the final 5 elements in the sorted list. execute the custom function with the entire original list as its sole argument. report the number of elements in the new "sevens" list returned by the custom function. if 207 is not in the "sevens" list, add it to the start of "sevens" and report that this happened. Otherwise, report that nothing was added. if 247 is in the "sevens" list, report the index of its first occurrence. Otherwise, append 247 to the end of the list. use another loop to display all elements in "sevens" on one line separated by spaces. Finally, report the total of the "sevens" list. See attatched image for what the output needs to be I need pseudocode and an explanation of each step so I can learn
program7.py This assignment requires the main function and a custom value-returning function. The value-returning function takes a list of random integers as its only argument and returns a smaller list of only the elements that end with 7. This value-returning function must use a list comprehension to create this smaller list. In the main function, code these steps in this sequence: Set random seed to 42 import random random.seed(42) create an empty list that will the hold random integers. use a loop to add 50 random integers to the list. All integers should be between 200 and 250, inclusive. Duplicates are okay. sort the list in ascending order and then use another loop to display all 50 sorted integers on one line separated by spaces. print a slice showing list elements indexed 5 through 10, inclusive. print a second slice showing the final 5 elements in the sorted list. execute the custom function with the entire original list as its sole argument. report the number of elements in the new "sevens" list returned by the custom function. if 207 is not in the "sevens" list, add it to the start of "sevens" and report that this happened. Otherwise, report that nothing was added. if 247 is in the "sevens" list, report the index of its first occurrence. Otherwise, append 247 to the end of the list. use another loop to display all elements in "sevens" on one line separated by spaces. Finally, report the total of the "sevens" list. See attatched image for what the output needs to be I need pseudocode and an explanation of each step so I can learn
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
program7.py
This assignment requires the main function and a custom value-returning function. The value-returning function takes a list of random integers as its only argument and returns a smaller list of only the elements that end with 7. This value-returning function must use a list comprehension to create this smaller list.
In the main function, code these steps in this sequence:
- Set random seed to 42 import random
random.seed(42) - create an empty list that will the hold random integers.
- use a loop to add 50 random integers to the list. All integers should be between 200 and 250, inclusive. Duplicates are okay.
- sort the list in ascending order and then use another loop to display all 50 sorted integers on one line separated by spaces.
- print a slice showing list elements indexed 5 through 10, inclusive.
- print a second slice showing the final 5 elements in the sorted list.
- execute the custom function with the entire original list as its sole argument.
- report the number of elements in the new "sevens" list returned by the custom function.
- if 207 is not in the "sevens" list, add it to the start of "sevens" and report that this happened. Otherwise, report that nothing was added.
- if 247 is in the "sevens" list, report the index of its first occurrence. Otherwise, append 247 to the end of the list.
- use another loop to display all elements in "sevens" on one line separated by spaces.
- Finally, report the total of the "sevens" list.
See attatched image for what the output needs to be
I need pseudocode and an explanation of each step so I can learn
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 now
This is a popular solution!
Step by step
Solved in 3 steps with 1 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.Recommended textbooks for you
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
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