Numpy, Panda, Vis. Flashcards
(49 cards)
What is the primary purpose of the Pandas library in Python? (A) Web development (B) Data manipulation and analysis (C) Game development (D) Machine learning algorithms
B
Which of the following is NOT a valid way to create a list in Python? (A) list = [1, 2, 3, 4] (B) list = list((1, 2, 3, 4)) (C) list = {1, 2, 3, 4} (D) list = list(range(1, 5))
C
Which pandas method would you use to handle missing values in a DataFrame? (A) dropna() (B) fillna() (C) replacena() (D) removena()
B
What type of error does this code contain? result = 10 / 0 (A) SyntaxError (B) ZeroDivisionError (C) ValueError (D) TypeError
B
What does the following code return? list1 = [1, 2, 3]; list2 = list1; list2.append(4); print(list1) (A) [1, 2, 3] (B) [1, 2, 3, 4] (C) [4] (D) Error
B
Which pandas function would you use to read a CSV file? (A) pd.read_file() (B) pd.read_csv() (C) pd.open_csv() (D) pd.import_csv()
B
What error type would this code produce? my_dict = {‘a’: 1, ‘b’: 2}; print(my_dict[‘c’]) (A) SyntaxError (B) KeyError (C) IndexError (D) ValueError
B
What is the output of the following code? x = [1, 2, 3]; y = x; y = [4, 5, 6]; print(x) (A) [1, 2, 3] (B) [4, 5, 6] (C) [1, 2, 3, 4, 5, 6] (D) Error
A
Which pandas method creates a cross-tabulation table? (A) pd.tabulate() (B) pd.crosstab() (C) pd.cross() (D) pd.pivot()
B
What type of error does this code contain? def calculate_average(numbers): return sum(numbers)/len(numbers); print(calculate_average([])) (A) SyntaxError (B) ZeroDivisionError (C) ValueError (D) TypeError
B
What is the output of this code? a = 5; def func(): a = 10; print(a); func(); print(a) (A) 5, 5 (B) 10, 10 (C) 10, 5 (D) 5, 10
C
Which pandas function would you use to merge two DataFrames? (A) pd.merge() (B) pd.combine() (C) pd.join() (D) pd.concat()
A
What type of error does this code contain? import pndas as pd (A) SyntaxError (B) ImportError/ModuleNotFoundError (C) NameError (D) AttributeError
B
What is the output of the following code? print(list(range(0, 10, 2))) (A) [0, 2, 4, 6, 8, 10] (B) [0, 2, 4, 6, 8] (C) [2, 4, 6, 8] (D) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
B
Which pandas method would you use to group data by a specific column? (A) cluster() (B) groupby() (C) categorize() (D) segment()
B
What type of error does this code contain? x = 5; x.append(10) (A) SyntaxError (B) AttributeError (C) TypeError (D) ValueError
B
What is the output of this code? print(“Hello”*3) (A) HelloHelloHello (B) Hello Hello Hello (C) Hello3 (D) Error
A
Which pandas function would you use to get descriptive statistics of a DataFrame? (A) stats() (B) summary() (C) describe() (D) info()
C
What error would this code produce? def func(x, y=10, z): return x + y + z (A) No error (B) IndentationError (C) SyntaxError (D) TypeError
C
What is the output of this code? print([i for i in range(10) if i % 2 == 0]) (A) [0, 2, 4, 6, 8, 10] (B) [0, 2, 4, 6, 8] (C) [2, 4, 6, 8] (D) [1, 3, 5, 7, 9]
B
Which pandas method would you use to drop rows with missing values? (A) remove() (B) dropna() (C) clean() (D) filter()
B
What type of error does this code contain? num = int(“hello”) (A) SyntaxError (B) ValueError (C) TypeError (D) NameError
B
What is the output of this code? print(set([1, 2, 2, 3, 3, 3])) (A) [1, 2, 3] (B) {1, 2, 3} (C) {1, 2, 2, 3, 3, 3} (D) Error
B
Which pandas function would you use to select rows based on a condition? (A) select() (B) filter() (C) query() (D) where()
C