MSCDSA01 - Foundation Flashcards

Foundational Data Science - Inc lots of Python

1
Q

What is Tkinter and what is it used for?

A

A python module, for building a graphical interface

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

What is SQLite and what is it used for?

A

(an alternative to writing to a text file)

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

What is ‘pdb’ and what is it used for?

A

which can be used to find elusive logic errors

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

What are the string type identifiers in Python?

A

you can use single or double quotes, either is fine - ‘ or “

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

what does the ‘' character inside a string do?

A
The \ tells python to expect a number or character afterwards which will indicate printing a special character 
\ = newline
\\ = \
\' = '
\" = "
\a = ASCII Bell(BEL)
\b = ASCII Backspace (BS)
\f = ASCII Formfeed (FF)
\n = ASCII Linefeed (LF)(newline)
..etc
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you ‘print’ to the console in python?

A

print ( )
eg:
print (‘Hello World’)
——

or
print ("Hello World")
but NOT
Print ('Hello
    World') 
= capital Would not be recognised (case sensitive) and whitespace means something and is not ignored)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is ‘Spyder’ and what is it used for?

A

Spyder is an open source integrated development environment (IDE) for scientific programming in the Python language

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

What does ‘Syntax’ mean in programming?

A
the rules (like grammar in written language) define combinations of symbols to make a correctly structured expression. 
--------

Applies both for programming languages, (source code), and for markup languages, where the document represents data.

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

What is a ‘markup language’?

A

from the “marking up” of paper manuscripts; replaced digitally by tags, indicating what the elements of text ARE, rather than how they might be shown on a display

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

Is python a ‘compiled’ or an ‘interpreted’ language, and what is the difference?

A

It has elements of a ‘compiled’ language, having compilers available

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

What are the two modes of entering and running programs in Python?

A

Interactive mode = type instructions and python responds immediately

Script mode = type in and SAVE

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

In ‘Jupyter’ what is the key combination to run a python program?

A
alt+enter
or
ctrl+enter
or
cmd+enter
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

In language theory and programming what is the term for joining character strings end-to-end?

A

For example, the concatenation of “snow” and “ball” is “snowball”

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

How would you put single or double quotes inside a string in python?

A

eg if you want a “ inside the string, then encapsulate (define) the string using the ‘ (single quote) character

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

What symbol is used to concatenate strings in Python

A

+

so “A” + “B” would produce AB

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

What are the the numeric data types in python?

A
int = integer (a whole number)
float = floating point  (a number with a decimal point)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

what are the standard arithmetic operators in python?

A
\+, -, * (multiply) and / (divide)
** for exponentiation (eg 2 ** 3 = 8 = 2^3)
% (mod) returns the remainder when an integer is divided by another (11 % 5 = 1)
// (div) performs integer division (11 // 5 = 2)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

In python when does numerical division result in a floating point number?

A

use ‘//’ to get an integer without remainder or decimal

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

In python which is the divide symbol ‘ \ ‘ or ‘ / ‘

A

remember your Christmas tree, it was the right hand slope ‘ \ ‘ that gave the problem because its an escape sequence and you needed ‘\' to get \

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

In Python why does 1.62+0.53 = 2.1500000000000004 how to avoid it?

A

To be certain of out put use the round() function:
round(1.62+0.53,2)

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

What is the TRUE/FALSE data type called?

A

Boolean

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q
What are the true false answers to the following:
9  ==  3*3
9 != 3*3
9 == 4*4
9 != 4*4
(5 > 1) and (7 > 1)
(1 > 5) and (7 > 1)
(1 > 5) or (7 > 1)
A
TRUE
FALSE
FALSE
TRUE
TRUE
FALSE
TRUE
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

In Python what would the following evaluate to:

9 != 4*4

A

TRUE

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

In Python what would the following evaluate to:

1 > 5) and (7 > 1

A

FALSE

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

In Python what are the 3 standard convention for naming variables?

A

1) make the names meaningful.
2) start with a lower case letter
3) use “camel caps” to separate parts of a name
eg. highScore

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

In Python what is the standard convention for naming constants?

A

1) make the name meaningful.
2) use ALLCAPS
eg. VATRATE

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

What is an assignment operator in Python?

A

It is how you assign a value to an object, e.g .

This is done using the ‘=’ operator.

length = 4 means the variable name (left) has the value (right) assigned to it

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

In python what is an ‘augmented assignment operator’

A

A way to update a variable e.g.

score +=1

is equivalent to

You can NOT use one if the variable has not yet been defined

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

what do the following ‘augmented assignment operators’ do?
A) +=

B) -=

C) *=

D) /=

E) %=

F) //=

A

variableA ‘+=’ rhValue

A) add the right hand value or variable to variableA

B) subtract the right hand value or variable from variableA

C) multiply variableA by the right hand value or variable and replace variableA with the answer

D) divide variableA by the right hand value or variable and replace variableA with the answer

E) mod (divide) variableA by the right hand value or variable and replace variableA with the REMAINDER

F) div (integer divide) variableA by the right hand value or variable and replace variableA with the answer (which discards the remainder)

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

In Python’s print statement, how do you combine strings and variables into a single print line?

A

print (“price is £”, totalPrice, “ exactly”

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

in Python IDEs is the £ sign always handled correctly?

A

In some IDE’s it is and in some it is not recognised in a string and will cause the program to crash

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

In Python print command, can you use a ‘ + ‘ to join strings or variables?

A

so you first have to convert any real numbers to strings using the str(n) function

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

in python, when separating strings using ‘ , ‘ how can you eliminate the extra space that appears between a string and a number e.g when you get “.. £ 15.00” but you want “.. £15.00”?

A

Use the ‘ + ‘ and convert the number to a string using the str(n) function

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

In Python what function converts a number to a string?

A

str(n)

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

What is the name for the method(s) that allow you to put special characters into strings?

A

Escape sequences

e.g \n skips to a new line

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

How do insert a ‘tab’ into a string (to form columns for instance)

A

use the escape sequence ‘ \t ‘

37
Q

In Python, what operator allows two print statements on different lines to be printed on the same line?

A

add ‘ , end = “ “ ‘ to the end of the print function (inside the brackets. e,g:
print (“this all prints “, end = “ “)
print (“on one line”)

38
Q

In Python, what does triple quote (single or double quotes) do? - ‘’’ or “””

A
retains the formatting of the string e.g. over several lines eg:
print ("""
John Smith
23 Elm Street
Andover
""")
would retain the 3 lines as distinct 3 lines
John Smith
23 Elm Street
Andover
39
Q

In Python describe a way to take a value from the program user and assign it to a variable in the program

A

It can contain the on screen prompt or that can be provided by a print statement. e.g:

firstName = input(“Please enter your first name: “)
print(“Please enter your surname: “)
surname = input()
print (“Your full name is”, firstName, surname)

40
Q

In Python, what is the file extension for a standard python script source file (as used in script mode)

A

.py

41
Q

When commenting a program at the top, what are the 5 elements it is good practice to add, and what symbol is used to note a comment?

A

1) Program Name
2) Program Purpose
3) Programmers Name
4) Date the program was written
5) The folder / location the source code is saved in.
- ————

Comments are marked by prefixing with a # (alt 3 on the mac keyboard)

42
Q

In Python, how would you keep the console open (for debugging etc) when the program has completed, when the program has been launched by double-clicking the file in finder/explorer

A

If you add an input right at the end of the program it will wait for user input before exiting. e.g:

input(“\nPress Enter to exit: “)

43
Q

In Python, what is an Object?

A

Python is an object oriented programming language.

44
Q

In Python, what is a class?

A

A Class is like an object constructor, or a “blueprint” for creating objects.

45
Q

in Python what string methods would perform the following:
A) convert a string to UPPER case

B) convert a string to lower case

C) find the first occurrence of a sub string inside a string or an ERROR if not found

D) find the first occurrence of a sub string inside a string or a ‘ -1 ‘ if not found

E) replace all occurrences of a sub string with another, within a string

A

A) myString.upper()

B) myString.lower()

C) myString.index(‘a..’)

D) myString.find(‘a..’)

E) myString.replace(‘a..’, ‘z..’)

46
Q

In Python, when using the variable = input() assignment function, if the user enters 1.00 what data type is this stored as?

A

A string. The input function only deals in strings. You need to use float(x) or int(x) to convert the string into a number.

47
Q

In Python, how can you use input() to assign the value as a float or int?

A

encapsulate the input() function within the float() or int() function e.g:
variable1 = float(input(“give me a number”))

48
Q

In Python, what is the difference calling / using a method vs a function?

A

A method is written using ‘ . ‘ ‘dot’ notation, with the name of the object followed by a dot and then the method name e.g:

postionOfA = myVariable.find(“A”)

A function has the function name first, followed by the name of the object in parentheses. e.g. the ‘len’ function:

lengthOfString = len(myVariable)

49
Q

What are the three basic programming constructs for controlling the order in which programming statements are carried out?

A

Sequential (B follows A etc)

Selective (If A then X if B then Y)

Iteration

50
Q

In Python, what clause is used when there are multiple routes through the program flow

A

’ elif ‘ in place of the else, except the final else.

51
Q

In Python are all elifs tested?

A

If an If or elif is true then all subsequent tests are skipped

52
Q

What is a way of testing multiple conditions? (in if / else)

A
By using nested if statements
if a = true:
    if b = true:
    "true"
    else:
    "false"
else "try again"
53
Q

three boolean expressions are..?

A

AND (true if both conditions are true)

OR (true if either or both conditions are true)

NOT (true expression becomes false and vice versa)

54
Q

In Python, how do you use a function contained in a standard library module?

A

load the module by using the ‘ import ‘ function to import/load the module

55
Q

In Python, how do you obtain a random integer?

A

1) import random
2) use the random method random.randint
3) allocate upper and lower ranges for the integer: myRandom = random.randint(n,n1)

56
Q

Define the difference between data and information?

A

Data is NOT information

’ Name John ‘ is Data
‘ His Name is John ‘ is Information

57
Q

Provide a definition for information theory?

A

The reduction of uncertainty

58
Q

What do we use, in order to understand data and create information?

A

Applying analysis produces value from the data

Data can be large and small

59
Q

What are the 4 v’s of Big Data?

A

1) Volume
2) Variety
3) Velocity

4a) Value
4b) Veracity
- ——

Volume refers to the amount of data, variety refers to the number of types of data and velocity refers to the speed of data processing

60
Q

What are the 3 types of business Analytics?

A

1) Descriptive Analytics= ‘What Happened?’
2) Predictive Analytics = ‘What is LIKELY to happen?’

3) Prescriptive Analytics = ‘The best possible decision is..?
- ———–

1) Descriptive = usually data visualisation and descriptive stats

2) Predictive Analytics =
a. Data Mining
b. Text / Web mining
c. Forecasting (i.e. Time series)

3) Prescriptive Analytics =
a. Optimisation - global maxima or minima
b. Simulation
c. Multi-Criteria Decision Modelling
d. Heuristic Programming

61
Q

What is the definition of a ‘ system ‘?

A

Input&raquo_space; Processing&raquo_space; Output&raquo_space;

^^«&laquo_space;Feedback ««

62
Q

What is a definition for Data Science

A

Science that creates data products, using:

1) computer science,
2) statistics,
3) machine learning,
4) visualisation
5) human-computer interaction (HCI)
- ———

1) collects data,
2) cleans data,
3) integrates data,
4) analyses data,
5) visualises data,
6) interacts (HCI) with data

63
Q

What is Business Intelligence?

What are tree aspects of Business Intelligence?

A

1) Data - lots of data and sources. get it all together to analyse
2) Analyse - track benchmarks to measure performance. Effective visualisation is key
3) Insight - trends, correlations and comparisons.

64
Q

1) Data Science
2) Big Data
3) Data Analytics.

Characterise key purpose of each

A

1) Data Science = Mining structured and unstructured data
2) Big Data = Humongous volumes of data.

3) Data Analytics = Analysis to draw conclusions and solve problems
- —–

Data Science = Mining to identify patterns. Includes programming, Statistical, Machine Learning and algorithms

Big Data = Capture, store, share and query data

Data Analytics = Process and perform statistical analysis on data. Discover how data can be used to draw conclusions and solve problems

65
Q

What does a Data Scientist do?

3 Core things:

A

1) Predicts the future based on past patterns
2) Explores data from multiple disconnected sources
3) Develop new analytical methods and ML models

66
Q

What does a Big Data Professional do?

3 Core things:

A

1) Builds large scale data processing systems
2) Designs scalable distributed systems
3) Analyses system Bottlenecks

67
Q

What does a Data Analyst do?

3 Core things:

A

1) Gets, processes and summarises data
2) Packages the data for insight
3) Design and create data reports

68
Q

What does ANOVA mean?, and what is it used for?

A

Analysis of Variance (ANOVA)

Looks for statistically significant differences between the means of three or more independent (unrelated) groups.

In its simplest form, ANOVA provides a statistical test of whether two or more population means are equal, and therefore generalizes the t-test beyond two means.

69
Q

In “The Unreasonable Effectiveness of Data” Peter Norvig showed what?

A

That simple models with LOTS of data outperformed complex models

70
Q

How is value discovered from data?

A

By applying Analytics

71
Q

What is a Tuple?

A

Tuples cannot be changed (unlike lists) and tuples use parentheses, whereas lists use square brackets.

Creating a tuple is as simple as putting different comma-separated values. Optionally you can put these comma-separated values between parentheses also

A tuple lets us “chunk” together related information and use it as a single thing.

There is no description of what each field means, but we can guess.

Like other indexed items (lists, vectors, arrays all of which hold one type of information) but tuples hold multi-type)

72
Q

In Python how do you access time functions?

A

load the module ‘ time ‘ by using:

import time

access time by using dot notation:

myCurrentTimeVariable = time.time() # which would produce seconds since January 1st 1970

73
Q

In Python how do you produce a nicely formatted date and time output

A

By using the ctime method of the time function

niceFormatTimeVar = time.ctime(myCurrentTimeVariable)

74
Q

In Python how can you print a float to a certain number of decimal spaces?

A

using in the string the escape sequence:

“… %.2f” % myFloatVariable)

e.g. print(“rounded to 2 %.2f” % myFloatVariable)

75
Q

In Programming name two types of loops

A

for loops: (definite iteration)

while loops: (indefinite iteration)

76
Q

In a Python ‘ for ‘ loop you set a start and finish range; how many numbers would the following iterate? (1,6)

A

1, 2, 3, 4, 5

the range will start with the first number and iterate up to BUT NOT INCLUDING the second number

77
Q

In a Python ‘ for ‘ loop how can you increment the counter by any integer value? e.g (1,16)

A

by adding a third value into the function e.g. (1, 16, 3) would count in 3’s

1 4 7 10 13 16

(10, 0, -2) would count down from 10 in -2’s

78
Q

In Python how can you pause a program for 1 second?

A

using the sleep method of the time function from the time module:
import time
time.sleep(1)

79
Q

How is a while loop controlled?

A

it will loop whilst a boolean condition is TRUE

If the condition is FALSE the loop will be skipped

80
Q

In Python, what would be difference in creation of:

myVariable = [1,2,3,4]
or
mVariable = (1,2,3,4)

A

square brackets tell python you are creating a LIST

round brackets tell python you are creating a TUPLE

81
Q

In Python, what collection type do the following braces represent:

( parentheses )

[ square brackets ]

{ curly braces }

A

( p ) is a tuple:

[ sq ] is a list:

{ crl } is a dict

( p ) is a tuple: An immutable collection of values, usually (but not necessarily) of different types.

[ sq ] is a list: A mutable collection of values, usually (but not necessarily) of the same type.

{ crl } is a dict: Use a dictionary for key value pairs.

82
Q

What measurement is used to calculate the degree to which points cluster along a straight line linear regression?

A

Pearson Correlation Coefficient - R

83
Q

if the correlation of N zx and zy scores is perfect, what will the sum of N zx*zy be..?

A

If the correlation is perfect then zx * zy is = to zx squared (or zy squared) and the sum of those products will equal N. becasue the correlation is perfect.. Hence the product / N shows the strength of the correlation (1 = perfect, 0 = none, >.5 is strong positive correlation but not perfect) .

This is the Pearson Correlation coefficient r

84
Q

what is the ‘end’ function for? will the following code produce:

print(‘one’, end=’ ‘)
print(‘two’, end=’ * ‘)
print(‘three’)

A

one two * three

end will join the print statements and the * will be displayed

85
Q

what is the ‘sep’ function for? What will the following code produce:

print(‘one’,’two’,’three’, sep=’*’)

A

onetwothree

sep will separate the strings using whatever is in the sep quotes

86
Q

what would the following produce:

myVar = 1234.12345
format(myVar, ‘.2f’)

A

1234.12

87
Q

what would the following produce:

myVar = 1234.12345
format(myVar, ‘.3e’)

A

1.234e+03

88
Q

when opening a file in python, what are the single character options for ‘x’ and what do they do?

myFile = open(“filename.txt” , “x” )

A

Open the file different ‘modes’

“r” for Read
“w” for Write
“a” for Append

89
Q

How variables can be compared by human visualisation abilities ?

A

Tops out at 3 according to field caddy