17. The following function takes a parameter that is a list of integers; the list has at least one element. It is supposed to find the integer that is the largest and find the position of that integer in the list. The function has two incorrect lines of code that make the function compute the results incorrectly. Several lines are highlighted (bold, underlined) which COULD be incorrect. In the following questions, choose the correct line of code that should be in the function.

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
icon
Related questions
Question
17. The following function takes a parameter that is a list of integers; the list has at least one element. It is supposed to
find the integer that is the largest and find the position of that integer in the list. The function has two incorrect lines
of code that make the function compute the results incorrectly. Several lines are highlighted (bold, underlined) which
COULD be incorrect. In the following questions, choose the correct line of code that should be in the function.
1
def findlarge(intlist):
2
largest = 0
3
pos = 0
for i in range(1,len(intlist)):
if largest > intlist[i:
4
5
largest = intlist[i]
pos = i
return (largest, pos)
8
Select one of the following to correct a line of code in the function.
a. Line 2 should be: largest = -1
b. Line 2 should be: largest = intlist[0]
c. Line 4 should be: for i in range(0,len(intlist):
%3D
d. Line 4 should be: for i in range(1,len(intlist)-1):
e. Line 8 should be: return largest
18. Select one of the following to correct a line of code in the function.
a) Line 4 should be: for i in range(0,len(intlist):
b) Line 4 should be: for i in range(1,len(intlist)-1):
c) Line 5 should be: if intlist[i] > largest:
d) Line 5 should be: if largest >= intlist[i]:
e) Line 8 should be: return largest
67 00
Transcribed Image Text:17. The following function takes a parameter that is a list of integers; the list has at least one element. It is supposed to find the integer that is the largest and find the position of that integer in the list. The function has two incorrect lines of code that make the function compute the results incorrectly. Several lines are highlighted (bold, underlined) which COULD be incorrect. In the following questions, choose the correct line of code that should be in the function. 1 def findlarge(intlist): 2 largest = 0 3 pos = 0 for i in range(1,len(intlist)): if largest > intlist[i: 4 5 largest = intlist[i] pos = i return (largest, pos) 8 Select one of the following to correct a line of code in the function. a. Line 2 should be: largest = -1 b. Line 2 should be: largest = intlist[0] c. Line 4 should be: for i in range(0,len(intlist): %3D d. Line 4 should be: for i in range(1,len(intlist)-1): e. Line 8 should be: return largest 18. Select one of the following to correct a line of code in the function. a) Line 4 should be: for i in range(0,len(intlist): b) Line 4 should be: for i in range(1,len(intlist)-1): c) Line 5 should be: if intlist[i] > largest: d) Line 5 should be: if largest >= intlist[i]: e) Line 8 should be: return largest 67 00
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Linked List Representation
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education