Question: 4.1 Stay under 80 characters on all code and comment lines Ask for input() with descriptive prompts telling users what is expected o Especially remember

4.1 Stay under 80 characters on all code and comment lines Ask for input() with descriptive prompts telling users what is expected o Especially remember to tell user what delimiter youre expecting when using split() Make sure to validate user input for data type, value range and other problem requirements Print output that clearly explains what is being printed (where necessary) o In other words, dont just print a 5 unless its clear what that 5 represents. Import statements should be immediately after the program docstring Make sure to include # line comments (just a few in each program, dont go crazy) Use snake_case (lower case plus underscores) for variables CONSTANT variables must be all upper case and immediately following any import statements Do NOT create user defined functions for this assignment. Only base python functions and methods can be used, along with those in the modules listed below. Modules Allowed You may only import the following modules into your programs and use their methods and attributes, unless first receiving special (and unlikely) permission from your facilitator: math operator os re string sys

Q\ Write a python program to solve the following: a. Create a constant list with the integers from 55 to 5, but only every 10th number (see example). Set this up using the python range function b. Generate a new list with same number of elements as the original list such that each integer in the new list is the sum of its nearest neighbors and itself from the original list. The integers at the beginning and end of the list only have one nearest neighbor c. Print both lists with descriptions. Your code should be able to work with an integer list of any size. Example of Output: Input List: [55, 45, 35, ] Result List: [100, 135, ]

I got answer from you which is

) """ import operator

# Constants INPUT_LIST = list(range(55, 0, -10))

# Helper function to generate result list def generate_result_list(input_list): result_list = [] for i in range(len(input_list)): if i == 0: result_list.append(sum([input_list[i], input_list[i+1]])) elif i == len(input_list) - 1: result_list.append(sum([input_list[i], input_list[i-1]])) else: result_list.append(sum([input_list[i-1], input_list[i], input_list[i+1]])) return result_list

# Main program result_list = generate_result_list(INPUT_LIST) print("Input List:", INPUT_LIST) print("Result List:", result_list)

*** I mentioned above that Do NOT create user-defined functions for this assignment. Only base python functions and methods can be used, along with those in the modules listed. so need you to modify that code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!