Question

Mele!!! Question 24 2 pts What is the output of the following code: def XXX(array,y): X = for i in range (y): x += array[i] p

0 0
Add a comment Improve this question Transcribed image text
Answer #1
  • Correct option is 60 as output of the given code is 60.
  • The given code actually adds the element of the passed array passed as a parameter to the function xxx along with the one more parameter (number) which will be the range of the for loop.
  • The executed code with output is attached in the snapshot.

x = 0 main.py 1 def xxx(array, y): 2 3 for i in range (y): 4 += array[i] 5 print (x) 6 7 list = [10,20,30] 8 xxx(list, 3D x i

GOOD LUCK, PLEASE REVIEW AND UPVOTE!!!

Add a comment
Know the answer?
Add Answer to:
Mele!!! Question 24 2 pts What is the output of the following code: def XXX(array,y): X...
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
  • Question 4 2 pts What is the output of the following code? def count(word): d =...

    Question 4 2 pts What is the output of the following code? def count(word): d = {} for char in word: if char in d: d[char] += 1 else: d[char] = 1 return d dictionary = count("Morgan Bears") print(dictionary["a"] + dictionary["r"])

  • 1. What is the output of the following code segment? int array[] = { 8, 6,...

    1. What is the output of the following code segment? int array[] = { 8, 6, 9, 7, 6, 4, 4, 5, 8, 10 }; System.out.println( "Index Value" ); for ( int i = 0; i < array.length; i++ ) System.out.printf( "%d %d\n", i, array[ i ] ); 2. What is the output of the following code segment? char sentence[] = {'H', 'o', 'w', ' ', 'a', 'r', 'e', ' ', 'y', 'o', 'u' }; String output = "The sentence...

  • Consider the following small program. What will the output be? def foo(x): print(x) def bar(): return...

    Consider the following small program. What will the output be? def foo(x): print(x) def bar(): return 3 def baz(y, z): return y * z a = bar() + 2 b = baz(a, 2) foo(a + b) 10 3 2 25 none of these 15

  • Which of the following will result in an output of: 8 def pass_it(x, y): z =...

    Which of the following will result in an output of: 8 def pass_it(x, y): z = x**y return(z) num1 = 2 num2 = 3 answer = pass_it(numi, num2) print(answer) def pass_it(x, y): z = y*** return(z) num1 = 2 num2 = 3 answer = pass it(numl, num2) print(answer) def pass_it(x, y): 22*3 return(z) num1 = 2 num23 answer pass_it (numi, num2) print(answer) def pass_it(x, y): Z = xy return(2) num1 = 2 num23 answer = passit(numl, num2) print(answer) # Hint...

  • 12. What is the output of this program? Your answer: 1 def main(): 2 print('The numbers...

    12. What is the output of this program? Your answer: 1 def main(): 2 print('The numbers are:') 3 for i in range (2,25): 4 isone (i) 5 def isone (number): isOne = True i = 2 while i < number and is one: if number % i == 0: 10 isOne = False 11 i += 1 Lou if isOne == True: 13 print("\t', i) 14 main() 12 13. What is the output of this program? Your answer: for i...

  • need help on all parts please and thank you (e) What is the correct output of...

    need help on all parts please and thank you (e) What is the correct output of this code? (2 pts) >>> def func(x): >>> res = 0 >>> for i in range (len (x)): res i >>> return res >>> print (func(4)) ( 4 5 ) 6 ()7 ( What could be described as an immutable list? (2 pts) () a dimple ( ) a tuple ( ) a truffle () a dictionary (g) What is the result of the...

  • wrote the code in the discbribtion bar Question 26 CLOS Following code is supposed to ask...

    wrote the code in the discbribtion bar Question 26 CLOS Following code is supposed to ask a user to input a numbe then print the numbers from 0 1 4 0 16 (n-1)2 def my_print(inp) for i in range(inp printi"2) n= int(input(Enter a number: ) my_print(n) The code is not working due to incorect format select the comectly formatted code def my_print(inp): for i in range(inp) printi2) n= int(input(Enter a number ) my_print(n) O def my_print(inp): for i in range(inp)...

  • 20) What is the output of the following segment of C code: int avg(int n, int*...

    20) What is the output of the following segment of C code: int avg(int n, int* a); int main () {             int array[4]={1,0,6,9};             printf("%d", avg(4, array)+ 1);             system("pause");             return 0; } int avg(int n, int* a) { int i, sum=0; for (i=0;i<n;i++) { sum+=a[i]; } return sum/n; } a) 16 b) 5 c) 4 d) 8 21) What is the output of the following segment of C code: int x = 2; int y = 3;...

  • What would be the output of the following code? def get_letter_index(letter, string): returns the index of...

    What would be the output of the following code? def get_letter_index(letter, string): returns the index of letter in string, OR if letter is not found in string, prints that information instead. If the letter occurs multiple times, this returns only the first index where the letter is found. Index where the letter is found for i in range(len(string)): if string[i] == letter: return i #if execution reaches this point, we must not have found the letter print(letter, "not found in",...

  • Look at the following function definition: def my_function(x, y): return x[y] a. Write a statement that...

    Look at the following function definition: def my_function(x, y): return x[y] a. Write a statement that calls this function and uses keyword arguments to pass ‘testing’ into x and 2 into y. b. What will be printed when the function call executes? 6. Write a statement that generates a random number in the range I'm using python to solve this this is what i did def main():      result= my_function(x='testing', y=2)      print(result) def my_function(x,y):      return x[y] main()

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