Numpy, Panda, Vis. Flashcards

1
Q

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

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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))

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which pandas method would you use to handle missing values in a DataFrame? (A) dropna() (B) fillna() (C) replacena() (D) removena()

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What type of error does this code contain? result = 10 / 0 (A) SyntaxError (B) ZeroDivisionError (C) ValueError (D) TypeError

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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()

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which pandas method creates a cross-tabulation table? (A) pd.tabulate() (B) pd.crosstab() (C) pd.cross() (D) pd.pivot()

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which pandas function would you use to merge two DataFrames? (A) pd.merge() (B) pd.combine() (C) pd.join() (D) pd.concat()

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What type of error does this code contain? import pndas as pd (A) SyntaxError (B) ImportError/ModuleNotFoundError (C) NameError (D) AttributeError

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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]

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which pandas method would you use to group data by a specific column? (A) cluster() (B) groupby() (C) categorize() (D) segment()

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What type of error does this code contain? x = 5; x.append(10) (A) SyntaxError (B) AttributeError (C) TypeError (D) ValueError

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is the output of this code? print(“Hello”*3) (A) HelloHelloHello (B) Hello Hello Hello (C) Hello3 (D) Error

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Which pandas function would you use to get descriptive statistics of a DataFrame? (A) stats() (B) summary() (C) describe() (D) info()

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

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

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

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]

21
Q

Which pandas method would you use to drop rows with missing values? (A) remove() (B) dropna() (C) clean() (D) filter()

22
Q

What type of error does this code contain? num = int(“hello”) (A) SyntaxError (B) ValueError (C) TypeError (D) NameError

23
Q

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

24
Q

Which pandas function would you use to select rows based on a condition? (A) select() (B) filter() (C) query() (D) where()

25
Q

What error would this code produce? a = [1, 2, 3]; print(a[3]) (A) SyntaxError (B) IndexError (C) ValueError (D) KeyError

26
Q

What is the output of this code? print(232) (A) 64 (B) 512 (C) 36 (D) 18

27
Q

Which pandas method would you use to find duplicate values in a DataFrame? (A) duplicated() (B) find_duplicates() (C) get_duplicates() (D) dup()

28
Q

What type of error does this code contain? with open(‘nonexistent_file.txt’, ‘r’) as f: data = f.read() (A) IOError (B) FileNotFoundError (C) OSError (D) ReadError

29
Q

What is the output of this code? print(‘{0}, {1}, {0}’.format(‘hello’, ‘world’)) (A) 0, 1, 0 (B) hello, world, hello (C) hello, world, world (D) {0}, {1}, {0}

30
Q

Which pandas method would you use to pivot a DataFrame? (A) rotate() (B) transform() (C) pivot() (D) transpose()

31
Q

What error would this code produce? x = 1; print(x + “2”) (A) SyntaxError (B) TypeError (C) ValueError (D) No error, it prints “12”

32
Q

What is the output of this code? print(bool([]), bool([0]), bool(0)) (A) True, True, False (B) False, True, False (C) False, False, False (D) True, False, False

33
Q

Which pandas method would you use to rename columns in a DataFrame? (A) rename() (B) change_names() (C) alter() (D) modify()

34
Q

What type of error does this code contain? def func(): return x; print(func()) (A) SyntaxError (B) NameError (C) ReferenceError (D) IndexError

35
Q

What is the output of this code? print(“Python”[1:4]) (A) Pyt (B) yth (C) ytho (D) ython

36
Q

In Python, indentation is optional and used only for code readability. (A) True (B) False

37
Q

The break statement exits only the innermost loop in nested loops. (A) True (B) False

38
Q

Python dictionaries preserve the order of items as they were added (in Python 3.7+). (A) True (B) False

39
Q

In Python, a variable can change its type during program execution. (A) True (B) False

40
Q

The is operator in Python checks if two objects have the same value. (A) True (B) False

41
Q

The append() method in Python modifies the original list and returns None. (A) True (B) False

42
Q

In Python, a tuple is mutable. (A) True (B) False

43
Q

The sort() method in Python returns a new sorted list. (A) True (B) False

44
Q

In Python, all functions return a value, even if not explicitly specified. (A) True (B) False

45
Q

In Python, strings are immutable. (A) True (B) False

46
Q

The global keyword in Python allows modifying a global variable from within a function. (A) True (B) False

47
Q

The \_\_init\_\_ method in a Python class is called every time an instance of the class is created. (A) True (B) False

48
Q

Lists and tuples can be used as dictionary keys in Python. (A) True (B) False

49
Q

In Python, a function can be passed as an argument to another function. (A) True (B) False