Quiz 2

By entering in your initials:

  1. You agree not to use outside resources including notes, LLMs, the internet, etc.
  2. You agree to remain in full screen while you complete the exam.





Time Remaining: 30:00

Question 1

What is the main difference between the library sympy and the library numpy?

Question 2

Given an n-element list contlist= = [1, 2, 3, ..., n-1, n] and a function rewrite() defined as:


    def rewrite(inputlist):
        rewrittenlist = []
        for i in inputlist:
            for j in inputlist:
                rewrittenlist.append( (i,j) )
        return rewrittenlist

  1. What is the maximum number of operations that could occur when running rewrite(contlist)?
  2. What is the time complexity of the rewrite function?

Question 3

How is a numpy array different from a python list?

Question 4

Consider the following lines of code:


    contlist = [1, 2, 3, 4]
    contarray = numpy.array(contlist)

    print(2 * contlist)
    print(2 * contarray)
    

How will the output of the two print statements differ? Explain why.

Question 5

Consider the sympy, numpy, and math libraries. Pick at least 3 functions from these libraries (3 total from any of them). Write a problem that uses these functions and write out the solution to the problem using these functions.