DBA Midterm Quiz

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/143

encourage image

There's no tags or description

Looks like no tags are added yet.

144 Terms

1
New cards

What is Data Science?

isn’t well defined, but incorporates elements of: exploratory data analysis, visualization, machine learning, statistics, and high-performance computing.

2
New cards

Hacking Skills + Math/Stats Knowledge =

Machine Learning

3
New cards

Math/Stats Knowledge + Substantive Expertise =

Traditional Research

4
New cards

Hacking Skills + Substantive Expertise

Danger Zone

5
New cards

Intersection of all three =

Data Science

6
New cards

Scientist worldview:

Scientists study the messy/complicated natural world (nothing is completely true or false)

7
New cards

Computer Scientist Worldview:

Computer scientists build clean, organized virtual worlds (everything is binary: true or false)

8
New cards

Scientist approach:

data-driven and discover

9
New cards

Computer Scientist approach:

algorithm-driven and invent.

10
New cards

Are Scientist comfortable with errors:

True

11
New cards

Are Computer Scientist comfortable with errors:

False

12
New cards

Computer Scientist often view data as simply stuff to run through a program:

True

13
New cards

Which of the following statements best reflects the difference between real scientists and computer scientists?

Scientists are data-driven, while computer scientists are algorithm-driven.

14
New cards

Genius shows in finding the right answer:

True

15
New cards

Wisdom shows in avoiding the wrong answer:

True

16
New cards

Sources of wisdom:

Experience, general knowledge, listening to others, and humility (learning from mistakes).

17
New cards

According to the lecture, while genius shows in finding the right answer, wisdom shows in:

Avoiding wrong answers

18
New cards

A good data scientist develops a curiosity about the domain/application they are working in:

True

19
New cards

What computer scientists do is create clever ways to encode and process information to solve problems.

True

20
New cards

Using binary representation on the 5 fingers of one hand, what is the highest number you can count to?

31

21
New cards

What is a programming language?

a set of vocabulary and rules that allow a human to communicate with a computer. Programs are written and executed sequentially.

22
New cards

Syntax:

The strict, predictable format/rules required for code to be translated.

23
New cards

Semantics:

The actual meaning, intent, or purpose of the code (which computers do not understand).

24
New cards

Compiled:

Translates source code into machine code prior to running.

25
New cards

Interpreted (e.g., Python):

Translates line-by-line during runtime; syntax/runtime errors are only caught when an incorrect line is executed.

26
New cards

In programming languages, what term refers to the actual purpose or meaning of the code, which the computer does not inherently understand?

Semantics

27
New cards

Why are errors in interpreted languages like Python typically caught only when the offending line is reached?

Translation to machine code occurs during runtime.

28
New cards

Variable:

A user-named reference to a specific memory address (place in memory).

29
New cards

Literal:

A fixed, definitive value directly assigned to a variable (e.g., 3, "hello").

30
New cards

Naming Multi-Word Variables:

Convention calls for camelCase or snake_case.

31
New cards

In computer programming, what is a variable?

A user-named reference pointing to a specific address in memory

32
New cards

Statically-Typed Languages:

Require the programmer to explicitly declare the data type in the source code ahead of time.

33
New cards

Data types provide ___ to the computer program

context

34
New cards

Python is classified as a dynamically-typed language because:

It infers the data type of a variable during execution rather than requiring explicit declaration.

35
New cards

How can variables have their data type changed manually?

type casting or “Casting”

36
New cards

Role of Data Types:

They provide context to the program, dictating which operations are valid on that piece of data.

37
New cards

Primitive types: Numeric

int (integers), float (decimal numbers), complex.

38
New cards

Primitive types: Sequence Types:

str (ordered collection of characters), list, tuple.

39
New cards

Other Primitives:

Boolean, Dictionary, Set.

40
New cards

Type Casting:

Manually converting a variable from one data type to another to enable operations specific to the new type (e.g., int(), float(), str()).

41
New cards

Type Errors:

Attempting an operation on an incompatible data type (e.g., concatenating a string with a raw integer) raises a TypeError.

42
New cards

Why are data types essential in a programming language?

They define the context of the data and specify which operations are permitted on it.

43
New cards

What error occurs if you try to perform an operation between two incompatible data types without type casting (e.g., concatenating a string with an integer)?

TypeError

44
New cards

type():

Returns the data type of the passed variable.

45
New cards

print():

Sends output to the console.

46
New cards

input():

Receives input entered by the user at the console

47
New cards

The value returned by input() is always a string (str), even if the user enters numeric characters.

True

48
New cards

What is the default data type of any value returned by the input() function in Python?

str

49
New cards

String:

An ordered sequence of characters, enclosed in single or double quotes.

50
New cards

Indexing Rules:

Positive indexing counts from the left, starting at 0.
Negative indexing counts from the right, starting with -1 for the last character.
Slicing uses [start : end]

51
New cards

In Python sequence indexing, which index value refers to the very last character of a string?

-1

52
New cards

Comments:

Text intended exclusively for human readers that is ignored by the Python interpreter.

53
New cards

How are single-line comments denoted:

Denoted by the hash symbol (#).

54
New cards

How are Multi-line comments denoted:

Enclosed using triple quotes (""" or ''').

55
New cards

What happens to commented lines of code when a Python script is executed?

They are completely ignored by the Python interpreter.

56
New cards

Boolean Literals:

The bool data type has only two values: True and False. They often act as "flags" indicating binary state changes.

57
New cards

Comparison Operators:

Compare two values and reduce to a boolean (==, !=, >, <, >=, <=).

58
New cards

Logical Operators: and:

Evaluates to True only if all inputs are True.

59
New cards

Logical Operators: or:

Evaluates to True if any input is True.

60
New cards

Logical Operators: not:

Reverses the boolean value (unary operator)

61
New cards

Which logical operator evaluates to True if at least one of its operand conditions is True?

or

62
New cards

if Statement:

Control structure that executes a block of code only if the specified condition is True.

63
New cards

else Statement:

Provides an alternative block of code that executes when the preceding condition evaluates to False

64
New cards

elif Statement:

Short for "else if". It is only evaluated if the preceding if or elif condition evaluated to False, creating a priority hierarchy.

65
New cards

In a Python if-elif-else construct, when is an elif condition evaluated?

Only if all preceding conditions in the chain evaluated to False

66
New cards

Four Primitive Collections:

List (list()), Tuple (tuple()), Set (set()), and Dictionary (dict()).

67
New cards

List Properties:

Ordered, changeable (mutable), and allows duplicate values.

Declared with square brackets ([]).

Can store elements of any data type.

Zero-indexed; attempting to access an index outside the valid range raises an IndexError.

Lists are considered the default "go-to" collection unless another specific collection behavior is needed.

68
New cards

What type of error is raised if a program attempts to retrieve an item at an index position that does not exist in a list?

IndexError

69
New cards

Which statement accurately describes a Python list?

Ordered, changeable (mutable), allows duplicates

70
New cards

Syntax Difference:

Methods use dot notation (listName.method()), while general functions wrap the collection (function(listName)).

71
New cards

Key List Methods append():

Adds an element to the end.

72
New cards

Key List Methods insert():

Adds an element at a specified position.

73
New cards

Key List Methods pop():

Removes an element at a specified position.

74
New cards

Key List Methods remove():

Removes the first item with the specified value.

75
New cards

Key List Methods clear():

Removes all elements from the list.

76
New cards

len():

Returns element count.

77
New cards

max(), min(), sum():

Aggregate operations on list elements.

78
New cards

in / not in:

Membership operators that return a boolean indicating whether an item exists in the collection.

79
New cards

What is the difference between the .remove() and .pop() list methods?

.remove() deletes an item by matching value, whereas .pop() deletes an item at a specified index.

80
New cards

Tuple Properties:

Ordered, unchangeable (immutable), and allows duplicate values.

Declared with parentheses (()).

Zero-indexed using square brackets ([]) for retrieval.

Values cannot be reset or modified after creation.

81
New cards

What are tuples used for:

Durability, data integrity, and security—used when values represent a constant sequence that must never be altered during program execution

82
New cards

What is the primary conceptual reason to use a tuple instead of a list in Python?

Tuples provide immutability, ensuring constant data cannot be modified accidentally.

83
New cards

Structure:

Organized into <key, value> pairs and declared with curly braces {key: value}.

84
New cards

Mutability & Ordering:

Dictionaries are ordered and changeable (mutable).

85
New cards

Key Uniqueness:

Duplicate keys are not allowed; each key maps to a single value.

86
New cards

Indexing & Errors:

Indexed by key using bracket notation (dict[key]). Trying to access a key that does not exist raises a KeyError.

87
New cards

Use Case:

Ideal as lookup tables to quickly fetch data associated with a unique key.

88
New cards

What error is raised when you attempt to retrieve a value from a Python dictionary using a key that does not exist?

KeyError

89
New cards

Which of the following statements about Python dictionaries is correct?

They are changeable, ordered collections of key-value pairs with unique keys.

90
New cards

Dictionary Methods: .keys():

Returns a view/list containing the dictionary's keys.

91
New cards

Dictionary Methods: .values():

Returns a view/list containing all the values.

92
New cards

Dictionary Methods: .items():

Returns a view/list containing a tuple for each key-value pair.

93
New cards

Dictionary Methods: .get():

Returns the value of a specified key.

94
New cards

Dictionary Methods: .pop(key)

removes the element with the specified key.

95
New cards

Dictionary Methods: .popitem()

removes the last inserted key-value pair.

96
New cards

Dictionary Methods: .setdefault():

Returns the value of the key; if the key does not exist, it inserts the key with the specified default value.

97
New cards

Dictionary Methods: .update():

Updates the dictionary with specified key-value pairs.

98
New cards

Dictionary Methods: .clear():

Removes all elements from the dictionary.

99
New cards

Which dictionary method returns key-value pairs as a list of tuples?

.items()

100
New cards

What is the behavior of the .popitem() method on a Python dictionary?

It removes the last inserted key-value pair.