Updated CiC_ Economics Practice Final

.pdf

School

Florida International University *

*We aren’t endorsed by this school

Course

6675

Subject

Computer Science

Date

Jan 9, 2024

Type

pdf

Pages

13

Uploaded by nduque

Report
Disclaimer: This is the first semester in which Professor Cannon has ever held a final exam for 1002, the result of which is that I and no one other than him has any idea what the content of the final will be like. As a result I cannot say with certainty that the questions you see on this document are going to be like those on the final, what I can guarantee is that I wrote these questions after a deep dive into the lectures from the context, meaning the content presented is stuff you should be aware of whether it is programming related or purely mathematical. I also plan to make this a full length practice exam so there will be 25 multiple choice questions, you will have the class time (technically slightly less) in order to complete the exam so please simulate the actual testing environment when you complete this practice. As always, Good luck! COMS 1002 Computing in Context Practice Final Exam Name: _________________ Please Use CAPITAL LETTERS to fill in the boxes: A B C D E 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25.
1. Consider the popular data science module ‘Pandas’. How can we enable the use of pandas in our python programs? a. import module pandas b. from pandas import pd c. import numpy as np d. import pandas_data e. import pandas 2. Consider the head of the dataframe df below, how can we change the index to be the second column from the left? name email address 0 Donald donald@magic.kingdom NaN 1 Goofy goofy@magic.kingdom NaN 2 Ariel ariel@magic.kingdom NaN 3 Minnie minnie@magic.kingdom NaN 4 Mickey mickey@magic.kingdom NaN 5 Ursula ursula@magic.kingdom NaN 6 Captain Hook NaN The seven seas a. df.set_index(“email”) b. df.index(“email”) c. df.set_index(email.toString()) d. df = df.index(“email”) e. df = df.set_index(“email”) 3. We have two methods meant for locating information within a dataframe: what are they and what is the primary difference between them? a. .locate() and .ilocate() the former uses labels to find the information and the latter uses integer based indexing b. .loc() and .iloc() the former uses labels to find the information and the latter uses integer based indexing c. .loc[] and .iloc[] the former uses labels to find the information and the latter uses integer based indexing d. There is only one way to locate values in a Pandas dataframe e. None of the above are correct
4. Consider the following code fragment, what is the output when the code is run in a proper development environment? import numpy as np a = np.array([1,2,3]) b = np.array([[4,5,6],[7,8,9]]) c = a*b c = c.reshape(3,2) print(c) a. [[4 10 18] [7 16 27]] b. [4 10 18] [7 16 27] c. This code will result in an error d. [ 4 10] [18 7] [16 27] e. [[ 4 10] [18 7] [16 27]] 5. Recall that we can define functions to help us determine the probability of certain events. In particular we can consider the fact that a standard coin flip can be modeled with a Bernoulli with a probability of success of 0.5. Now consider a biased coin where the probability of getting heads is 0.25, what is the probability that I flip 10 heads in a row? a. (0.5)^10 b. (0.75)^10 c. (0.25)^10 d. (0.25)^10 / 2^10 e. (0.75)^10 / 2^10
6. Recall your discussion on argument and parameter types in Python. Using that knowledge consider the following code segment and determine what the output is: def foo(a, b, c, *args, d = 0, e = 100): sum = 0 for value in args: sum += (value * d) sum -= e sum *= b sum /= a return sum foo(2, 5, 8, 9, 2, 150) a. -250.0 b. 430.0 c. -375.0 d. 555.0 e. The code produces an error
7. Recall from a previous economics lab that we wrote some functions in order to calculate the stock price S after T days using the following formula: S = S 0 Y 1 Y 2 Y T Specifically recall that you may have used np.product to compute the product of a list of values, which of the following is a proper alternative for that specific part of the code. a. prod = 1 for val in some_list: prod += val b. prod = 1 for val in some_list: prod *= val c. prod = 1 for val in some_list: prod **= val d. prod = np.sum(some_list) e. None of the above are algorithmic substitutes 8. When discussing types in python there are certain things we can do that have default types assigned to them prior to doing operations. Consider the following: x = {} What is the type of x directly following this assignment? a. List b. Set c. Dictionary d. OrderedDictionary e. Numpy Array
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help