Recursive Functions in Python
18 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the purpose of the(lst.remove(val)) line in the Q14 function?

  • To remove the minimum value from the list (correct)
  • To find the maximum value in the list
  • To find the median of the list
  • To sort the list in ascending order
  • What is the output of the Q14 function when given the input [-1, 1, -2, 2, 3.14, -3.14, -6, 6.1]?

  • [-1, 1, -2, 2, 3.14, -3.14, -6, 6.1]
  • [6.1, 3.14, 2, 1, -1, -2, -3.14, -6]
  • [-6, -3.14, -2, -1, 1, 2, 3.14, 6.1] (correct)
  • None of the above
  • What does the Q12 function do?

  • Finds the minimum value in the list
  • Sorts the list in descending order
  • Finds the maximum value in the list and removes it (correct)
  • Reverses the list
  • What is the purpose of the beta variable in the Q13 function?

    <p>To find the largest value in the tuple</p> Signup and view all the answers

    What is the return value of the Q13 function?

    <p>The largest value in the tuple</p> Signup and view all the answers

    What is the main difference between the map and filter functions in Python?

    <p>The map function applies a function to every element, while the filter function applies a condition to every element</p> Signup and view all the answers

    What is the purpose of the lambda function in the f1q10 function?

    <p>To find the maximum of corresponding elements</p> Signup and view all the answers

    What is the output of the list comprehension [x for x in lst if x % 2 == 0]?

    <p>[2, 4]</p> Signup and view all the answers

    What does the map function do in the f1q10 function?

    <p>It finds the maximum of corresponding elements</p> Signup and view all the answers

    What is the purpose of the f1q8 function?

    <p>To recursively call itself until the list is empty</p> Signup and view all the answers

    How do you insert 'x' between '4' and '6' in the list lst?

    <p>lst.insert(5, 'x')</p> Signup and view all the answers

    What is the value of len(matrix) for a 4*6 list?

    <p>4</p> Signup and view all the answers

    What is the output of the function f1q1 when called with arguments 'abcdef' and 'xyz'?

    <p>axbycz</p> Signup and view all the answers

    What does the function f1q2 do?

    <p>It converts the binary representation of the input number to an integer</p> Signup and view all the answers

    What is the output of the function f1q4 when called with the input [14, 46, 43, 27, 57, 41]?

    <p>[14, 27, 41, 43, 46, 57]</p> Signup and view all the answers

    What is the purpose of the function f1q5?

    <p>To sort an array using the divide-and-conquer approach</p> Signup and view all the answers

    What is the time complexity of the function f1q4?

    <p>O(n^2)</p> Signup and view all the answers

    What is the space complexity of the function f1q5?

    <p>O(n)</p> Signup and view all the answers

    More Like This

    Python Functions and Arguments
    40 questions
    Python Functions and Recursion Quiz
    28 questions
    Introduction to Python Recursion
    47 questions
    Python Functions and Modules Overview
    21 questions
    Use Quizgecko on...
    Browser
    Browser