Computer Science, asked by naveenavoora, 4 months ago

1 def find_max(nums):
max_num float("-int") # smaller than all other numbers
for num in nums:
if num > max_num:
# (Fill in the missing line here)
return max_num
Select the correct answer :​

Answers

Answered by gouravbansiwal86
8

Answer:

1

#include <bits/stdc++.h>

using namespace std;

4 class Test

5

6

public:

7

Test() { cout << "Constructor called" :)

8

9

10 int main()

11

12

Test *t = (Test *) malloc(sizeof (Test));

13

return 0;

)

15

Answered by poojan
21

max_num=num is the missing statement

Explanation:

def find_max(nums):

   max_num = float("-inf") # smaller than all other numbers

   for num in nums:

       if num > max_num:

           max_num = num

   return max_num

nums = (3,2,1)

print (find_max(nums))

At first, max_num is filled with the minimum number. Then, on iterating over the list of numbers in nums, each value of nums is stored in the iterable num in series one by one on each iteration till the list of elements gets complete.

On every iteration, the max_num value is compared with the current value in the iterable, and if num is greater than max_num, max_num is replaced with the big one, num.

In such a way, once the loop terminates, we will have the maximum number of the list in the variable max_num and it is returned to the function call and is printed.

max_num=num will help in replacing the value in the max_num with biggest number.

Learn more:

Write a Python function sumsquare(l) that takes a nonempty list of integers and returns a list [odd,even], where odd is the sum of squares all the odd numbers in l and even is the sum of squares of all the even numbers in l.

brainly.in/question/15473120

Python program to find absolute difference between the odd and even numbers in the inputted number.

brainly.in/question/11611140

Similar questions