EXAM Flashcards

Midterm & Final

You may prefer our related Brainscape-certified flashcards:
1
Q

printing the contents of a file containing two lines read with “readlines()” results in what?

A

[‘Line01\n’, ‘Line02’]

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

printing the contents of a file containing two lines read in with “read()” results in what?

A

Line01\nLine02

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

Opening an existing text file with the option ‘w’ and then “write”ing some text to the file does what

A

Writes over the contents of the existing file.

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

If a file is opened with the option ‘a’ but the file doesn’t exist, what is returned?

A

File text_file.txt will be created if it does not exist

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

If a file is opened with the option ‘r’ but the file doesn’t exist, what is returned?

A

Error message.

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

“ATGCATGC” return the results when the “GC” is replaced with “U”

A

ATUATU

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

What is the “len” of a sequence when you split “ATGCATGC” at “A”

A

3, first A results in a space.

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

stringvariable.find(‘string’) method returns what?

A

The index of the first occurrence of the substring if found or -1 if not found

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

string = [“Python”, “is”, “fun”] print(““.join(string)) returns what?

A

Python is fun - string join() method returns a string by joining all the elements of an iterable (list, string, tuple)

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

string.split() does what to this object, string = “Good Morning to you”
[“Good”, “Morning”, “to”, “you”] text.split() -

A

splits string into a list of substrings at each space character, text.split(‘,’) splits at commas,

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

Class instantiation uses function notation that returns a new instance of the class. For example
tobject = Grades(1234, 5007) does what?

A

creates a new instance of the class and assigns this object to the local variable tobject.

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

How does class inheritance work?

A

Declare your class followed by parentheses and then list any classes that your class inherits from. In a function definition, parentheses after the function name represent arguments that the function accepts. In a class definition the parentheses after the class name instead represent the classes being inherited from. The second class has access to all the methods in the inherited class.

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

f1= Fraction(1,2)
f2= Fraction(2,3)
f3 = f1 + f2
print(f3.num)
returns 7, why?

A

The Fraction module is a built in class with a __add__ method which is = to the arithmetic function +
1/2 + 2/3 = 3/6+4/6=7/6
7 = num, 6 = den
f3.num calls the add function and the numerator is 7

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

If head = 0 in your Class and you instantiate the object with other variables, what does print(IList.head) return?

A

0 because the variable head = 0 in iList. Despite IList class being called in the previous line with a list of numbers which would set head to 4, that doesn’t persist because it isn’t saved when iList is called again. Rather than printing out a variable, the print command here calls the class with no input attributes so head is equal to the default value set in the class.

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

How do you call a method inside a class. ex. print(new_emp.getDept()) vs. call an attribute in a class by print(new_emp.dept)

A

We invoke a method by first typing in the name of the object we are referencing, followed by a dot (.), followed by the method with parenthesis.

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

What position does this command return in an XML file?
find(“.//country[1]”).attrib[“name”]

A

Returns the “name” attribute of the first country listed because parsing in XML starts at position 1 unlike JSON and CSV which starts at position 0.
- find(“.//country[2]”).attrib[“name”]
- finds the second country in an XML file.

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

When you open a csv file with csv.reader what is the first row read?

A

The first row read is the header row.

18
Q

When you open a csv file with csv.dictreader what is the first row read?

A

The first row read when opened with dictreader is the first row of data.

19
Q

print(xmlRoot.find(./country[@name=’Panama’]/rank”).text) does what?

A

Looks in country to find the attribute name which equals Panama and returns the rank text value.

20
Q

What does this do?
if neighbor.get(“direction”) == “E”:
cname = neighbor.get(“name”)
Print(cname)

A

Finds the neighbor tag where the direction attribute value is E and returned the name attribute as cname

21
Q

XML file positions start with which number?

A

[1] - yes it is true. XML unlike JSON start position with 1 not 0

22
Q

CSV file positions start with which number?

A

[0] - Most objects in python start position counting with [0, 1, 2, 3…]

23
Q

Learning by associating stimulus and response is called:

A

classical conditioning

24
Q

Computationally intractable problems are problems that are:

A

not solvable with existing computational tools

25
Q

All possible outcomes of a problem is called

A

problem space

26
Q

Conterfactual thinking is what?

A

Thinking about alternate outcome if an event in past had been different

27
Q

Explain Type 1 vs Type 2 reasoning.

A

use type 1 reasoning when:
You are very experienced
Have repeatedly seen the same pattern before.
Need quick results
When you are aware of possible biases and control for them.
When the risk of not acting quickly is worse or equal to making an error.

You should use type 2 reasoning when:
the problem involves a novel choice which you have never seen.
there is a strong confirmation bias, availability bias, or other human judgement error towards the situation.
the intuitive answer might lead you in the wrong direction.
the problem is very complex and needs to be broken down into sub-problems.
There is time to test hypothesis and eliminate possibilities.

28
Q

What makes a well defined problem?

A
  1. an initial/starting state
  2. a clear end or goal state
  3. a set of allowable moves or actions to change states

one where the entire problem space is mapped out, decision rules which link the conditions to actions are available. The desired results are very clear and specific outcomes.

29
Q

Define metadata with an example. Provide a healthcare use case where the metadata is used.

A

Metadata is data about data for example in healthcare, we often refer to demographics as a data grouping. Patient demographics refers to multiple data elements such as race, ethnicity, gender, age at diagnosis, income, married or not. The properties of these data elements, what each of these data elements mean, what values are allowed in the fields, whether they are binned, how the fields are defined is the metadata. The actual data would be the values for an individual patient such as white, Hispanic, 42, 50k-100k, single. In this way, the metadata defines the data that is being collected.

30
Q

Define secondary analysis of healthcare data

A

Raw data is the actual data collected on a patient while secondary analysis is data that can be derived from the primary raw data. For example if a patient is on a drug for hypertension then you know that they have hypertension, similarly for diabetes drugs, you can infer the diagnosis based on the drug prescribed. Secondary analysis is the process to derive additional data from the primary data such as the example just described using the primary data = drug prescribed to determine the secondary data = diagnosis.

31
Q

Data Acquisition is:

A

Extracting the data in a desired format

32
Q

Which of the following is not core to Data Science? Data Intelligence, Data Wrangling, Data Analysis, Data Quality

A

Data Intelligence is not core to Data Science.

33
Q

Compare two subsets of data to determine if any relationship exists, that is:

A

Data Analysis

34
Q

By decreasing the time spend in ICU, evaluate the effect in cost savings is an example of what type of analysis?

A

causative analysis

35
Q

Checking to see if there are missing value in the blood glucose monitoring would be an example of what data science action?

A

Data Manipulation is the answer provided - perhaps because it includes data quality.

36
Q

ATGCATGC
What is at position [-3] + [3] ?

A

TC ; counting backwards starts at -1, counting forward starts at 0

37
Q

When converting from a float to an integer what happens to a decimal like int(float(0.98))) ?

A

It becomes 0 because when converting from float to integer, the number gets truncated (decimal parts are removed). Since 0.99 losses everything to the right of the decimal all that is left is the 0

38
Q

For the following code to work without error, which of the following condition must be met?

fname = open(“/opt/data/text_file.txt”, “w”)

(a.)File text_file.txt may or may not exist in the directory
(b.)File text_file.txt must be a binary file
(c.)File text_file.txt must be empty
(d.)File text_file.txt must not exist, as it is newly created

A

a

39
Q

For the following code to work without error, which of the following condition must be met?

fname = open(“/opt/data/text_file.txt”, “a”)

(a.)File text_file.txt will be created it does not exist
(b.)File text_file.txt must be binary
(c.)File text_file.txt must not be empty
(d.)File text_file.txt will be replaced with new file.

A

a

40
Q

Consider the text_file.txt with following contents
Line01
Line02

Provide the exact output of the following python script

1
2 fname = open(“/opt/data/text_file.txt”, “a”)
3 ftext = fname.read()
4 fname.close()
5 print(ftext)
6

(a.)Line01\nLine02
(b.)Line01
(c.)Line01 Line02
(d.)Line01Line02

A

a

41
Q

For the following code to work without error, which of the following condition must be met?

fname = open(“/opt/data/text_file.txt”, “r”)

(a.)File text_file.txt must exist in the directory
(b.)File text_file.txt must be a binary file
(c.)File text_file.txt should not exist, and it will be created by the program
(d.)File text_file.txt should not be empty

A

a

42
Q

Consider that a file text_file.txt exists at /opt/data/text_file.txt and following python program

1
2 fname = open(“/opt/data/text_file.txt”, “w”)
3 ftext = fname.write(“Last Line”)
4 fname.close()
5

(a.)text_file.txt will be replaced with new contents
(b.)”Last Line” will be appended to the file
(c.)There will be an error
(d.)Nothing will be written to the file

A

a