Question

2) You are given the following lists. Write code that produce the following resulting list. (30 points) Exam2 [C 12.py-PyCharm Edu 3.0 Eile Edit Yiew Navigate Code Help a 2-Py × nanes # [ April, BL11,Cindy. Dave, Emily] testl [34,21,67,45,88 test2 [ 11, 67, 92, 35, 89] test3-[94,33,67,34,67 testi [27, 83, 43, 67, 93] tests 43,76,78,45,65 0 Project *÷ o-r 1.py × @3.py × 1.py nh External Libraries resultinglist 10 print (resultingList) Run2 ↑ [[Aprll, 34, 11, 94, 27, 43], [B111-21, 67, 33, 83, 76]. [*CLndy.. 67, 92, 67, 43, 78], [Ouve., 45, 35, 34, 67, 45], [En11y, ce, e9, 67, 93, 6511 Process finiahed with exit code 0 11骂 Python Console > 4: Run 4:1 CRLF: UTF-8: b

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Your Code .. 1 names April, Bil1, Cindy Dave Emily] 2 testi - [34, 21, 67, 45, 88] 3 test2 - [11, 67, 92, 35, 89] 4 test3 - [94, 33, 67, 34, 67] 5 test4 - [27, 83, 43, 67, 93] 6 test5 - [43, 76, 78, 45, 65] 8 resultingList - [] 1e for i in range(len (names)): 11 resultingList.append(]) 12 resultingList[i].append (names[i]) 13 resultingList[i].append(testi[i]) 14 resultingList[i].append(test2[i]) 15 resultingList[i].append(test3[i]) 16 resultingList[i].append(test4[i]) 17 resultingList[i].append(tests[i]) 18 19 print(resultinglist)l

names = ['April', 'Bill', 'Cindy', 'Dave', 'Emily']
test1 = [34, 21, 67, 45, 88]
test2 = [11, 67, 92, 35, 89]
test3 = [94, 33, 67, 34, 67]
test4 = [27, 83, 43, 67, 93]
test5 = [43, 76, 78, 45, 65]

resultingList = []

for i in range(len(names)):
resultingList.append([])
resultingList[i].append(names[i])
resultingList[i].append(test1[i])
resultingList[i].append(test2[i])
resultingList[i].append(test3[i])
resultingList[i].append(test4[i])
resultingList[i].append(test5[i])

print(resultingList)

# Output: [['April', 34, 11, 94, 27, 43], ['Bill', 21, 67, 33, 83, 76], ['Cindy', 67, 92, 67, 43, 78], ['Dave', 45, 35, 34, 67, 45], ['Emily', 88, 89, 67, 93, 65]]

Add a comment
Know the answer?
Add Answer to:
2) You are given the following lists. Write code that produce the following resulting list. (30...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Complete function long_list_printer.print_list(). When it's finished, it should be able to print this list, a =...

    Complete function long_list_printer.print_list(). When it's finished, it should be able to print this list, a = [ [93, 80, 99, 72, 86, 84, 85, 41, 69, 31], [15, 37, 58, 59, 98, 40, 63, 84, 87, 15], [48, 50, 43, 68, 69, 43, 46, 83, 11, 50], [52, 49, 87, 77, 39, 21, 84, 13, 27, 82], [64, 49, 12, 42, 24, 54, 43, 69, 62, 44], [54, 90, 67, 43, 72, 17, 22, 83, 28, 68], [18, 12, 10,...

  • Write a python nested for loop that prints out the following pattern 100 99 98 97...

    Write a python nested for loop that prints out the following pattern 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33...

  • python program do not use dictionary, list only Complete the program found in assignment4.py. You may...

    python program do not use dictionary, list only Complete the program found in assignment4.py. You may not change any provided code. You may only complete the sections labeled: #YOUR CODE HERE Write a program that does the following. Reads the contents of Text from the include file, input.txt Create a dictionary of key-value pairs called index.txt Key: This represents the individual word Value: This is a list of the line number from Text where Key appeared Example: If the word...

  • 1. Forecast demand for Year 4. a. Explain what technique you utilized to forecast your demand....

    1. Forecast demand for Year 4. a. Explain what technique you utilized to forecast your demand. b. Explain why you chose this technique over others. Year 3 Year 1 Year 2 Actual Actual Actual Forecast Forecast Forecast Demand Demand Demand Week 1 52 57 63 55 66 77 Week 2 49 58 68 69 75 65 Week 3 47 50 58 65 80 74 Week 4 60 53 58 55 78 67 57 Week 5 49 57 64 76 77...

  • Write the C program, to achieve as shown in the sample code execution, using the given...

    Write the C program, to achieve as shown in the sample code execution, using the given struct and using the comments in the given main program below: typedef struct{ char first[20]; char last[20]; float gpa; int score; } student; int main(void){ student *ptr; //first name //last name //student gpa //student score } //ask a user to enter the number of students, num //dynamically allocate memory for an array of students of the appropriate size (i.e. //num that the user just...

  • == Programming Assignment == For this assignment you will write a program that controls a set...

    == Programming Assignment == For this assignment you will write a program that controls a set of rovers and sends them commands to navigate on the Martian surface where they take samples. Each rover performs several missions and each mission follows the same sequence: deploy, perform one or more moves and scans, then return to base and report the results. While on a mission each rover needs to remember the scan results, in the same order as they were taken,...

  • Write a Python program (question2.py) that reads from a file called “input.txt” numbers in [1,39] separated...

    Write a Python program (question2.py) that reads from a file called “input.txt” numbers in [1,39] separated in by commas. The numbers are in [1-99]. The program will then convert each number to a possible Roman Numeral equivalent, and print it on the screen. Remember, I is 1, V is 5, X is 10 For example, if the input is: 23, 11 the output is: XXIII, XI. ROMAN NUMERALS CHART 1 TO 100 69 LXIX 11 2 11 3 III 4...

  • Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges...

    Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges two arrays of positive integers and removes any duplicate entries. Your program will first ask for a valid length which must be an integer which is 10 or greater. The program should continue to ask until a valid length is entered. The program will then create two arrays of the length entered, fill these with random integers between 1 and 100 inclusive, and print...

  • Use C++ (2D Array) Write a program which: 1. Assigns data given below into the 2D...

    Use C++ (2D Array) Write a program which: 1. Assigns data given below into the 2D array of integers which is 10x10. 2. Prints out the contents of the 2D array after assigning the data to make sure correct data was assigned. 3. Figures out and prints out the square root of the sum of ALL the elements in the 2D array. 4. Figures out and prints out the average of ALL THE ELEMENTS in the 2D array. 5. Figures...

  • The task involves writing a C++ program that determines the prime numbers between 1 and 100....

    The task involves writing a C++ program that determines the prime numbers between 1 and 100. The steps you should follow to identify the prime numbers are the following. 1. The number 1 is not a prime number, so it should be scratched. 2. Starting from the first prime number, which is 2, you scratch all the numbers that are the multiple of 2. You should not scratch out 2 itself. 3. The next number in the sequence after the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT