Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***Please help compute the python code with correct indentation and show the output*** Write a small program that can compare numbers in two lists with

***Please help compute the python code with correct indentation and show the output***

image text in transcribed

Write a small program that can compare numbers in two lists with the same length. For example: Sample data list 1: [2, 5, 3, -9, 7.5, 100] list 2: [3, -2.5, 1, 0, 8, 100] Part a) Save the comparison result in a new list called compare , such that: When the number in list 1 is bigger than the corresponding number in list 2, assign a comparison result of 1 in the new list; When the number in list 1 is smaller than the corresponding number in list 2, assign a comparison result of 1 in the new list; 0 in When the number in list 1 is equal to the corresponding number in list 2, assign a comparison result of the new list. Sample output: [-1, 1, 1, -1, -1, 0] In [ ] : 1s1 = [2, 5, 3, -9, 7.5, 100] 1s2 = [3, -2.5, 1, 0, 8, 100] # Start your code below # Part a Part b) Find out which list "wins", in the sense that it has more larger numbers than smaller numbers as compared to the numbers in the other list. For example, in the sample data given above, list 1 "wins" list 2 on two occassions (5 vs -2.5 and 3 vs 1); list 1 "loses" to list 2 on three occassions (2 vs 3, -9 vs 0, and 7.5 vs 8); and they "tie" on one occassion (100 vs 100). So list 2 is the winner given the sample data. Print the name of the winning list as in the sample output below (or print "They tie!" instead of the name of the winning list if the two lists have equal wins and losses). Sample output: List 2 wins ! Noted that your program should still be applicable when numbers in the two lists change, but still all numeric and with the same length. In [ ]: # Start your code below # Part b

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

Step: 3

blur-text-image

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

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions