Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. You will write a Python program that defines two one-dimensional lists, each with 20 real elements. Use the list constructor bracket to initialize the

image text in transcribed
2. You will write a Python program that defines two one-dimensional lists, each with 20 real elements. Use the list constructor bracket to initialize the values of the first list to the following values (you may cut and paste these to save some typing): 0.2802 . 1103 0.2584 -0.096 0.4036 -0.368 0.4420 0.4561 0.0752 .4403 -0.2653 -0.14690.32 0.48460.4570 0.1491 0.2317 0.1477 -0.0491 -0.3311 Make sure that no line in your program is longer than 80 characters. Remember that the ampersand character \allows you to continue a line, but you will not need one to continue a line with an open bracket. Initialize the second list to be empty. Then, use a loop to fill the second list with the sum of all of the values in the first list up to that point. That is, the value in the first element of the second list will be 0.2802, the value of the second element of the second list will be 0.2802+-0.1103 0.1699, and so on. (Hint: The last value in the second list will be-1.3077.) Note that a conditional (an if statement) may be required here. Print out the list elements, one per line using a floating point format that shows 4 digits to the right of the decimal point. 3. Print out the second list from problem 2 above. This time, assume that the list could be any length (your solution should work if the list had other than 20 elements) and figure out how to print 5 elements per ine, using the same floating point format shown in the problem above. Using slice notation with a variable as the starting and ending element number will be helpful ME021 Engineering Computing-Spring 2019 4. Write a Python program that does what we did in problem 2 of last week's assignment, but do not use a cascadedif statement to determine which string to assign to the class name. Instead, set up the class names and numbers in a dictionary, with numbers as the keys and strings as the values. Then use the user's input to grab the class names from dictionary

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building The Data Lakehouse

Authors: Bill Inmon ,Mary Levins ,Ranjeet Srivastava

1st Edition

1634629663, 978-1634629669

More Books

Students also viewed these Databases questions

Question

8. Do the organizations fringe benefits reflect diversity?

Answered: 1 week ago

Question

7. Do the organizations social activities reflect diversity?

Answered: 1 week ago