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.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section7.5: Case Studies
Problem 3E
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
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr