random Flashcards

1
Q

Python: When scraping a list from a site

A

remember that you need to loop each list item into a new list, and not use the soup_page to save into pandas.

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

Pandas: To reference a df column by its index rather than its name, type

A

df.columns[0]

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

Pandas: To filter a column by partial string, type

A

mask = df[“Column name”].str.contains(“string”)

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

Selenium: To scroll to the bottom of a page, type

A

my_browser.execute_script(“window.scrollTo(0, document.body.scrollHeight);”)

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

To import SelectPercentile, type

A

from sklearn.feature_selection import SelectPercentile

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

To set the SelectPercentile percentile, type

A

SelectPercentile(percentile=20)

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

sklearn: To create a transformer that turns a column from an integer to a float

A

from sklearn.base import TransformerMixin

class MyTransformer(TransformerMixin):

    def transform(self, X, **transform_params):
        X["Numeric"] = X["Numeric"].apply(lambda x: x.astype(float))
        return X
    def fit(self, X, y=None, **fit_params):
        return self
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

sklearn: To import gradient boosting, type

A

from sklearn.ensemble import GradientBoostingClassifier

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

Pandas: To set the columns on read_csv and on a new DataFrame use

A

read_csv: names=[]
DataFrame: columns=[]

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

pyautogui: To click somewhere based on a screentshot’s center, type

A

pixel_x, pixel_y = pyautogui.locateCenterOnScreen(“screenshot.png”)
pyautogui.click(pixel_x, pixel_y)

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

pyautogui: To have a dialogue box pop up and confirm that you want to continue, type

A

pyautogui.confirm(“Proceed?”)

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

pyautogui: To find the pixel coordinates of the current mouse position, and then click them, type

A

current_x, current_y = pyautogui.position()

pyautogui.click(current_x, current_y)

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

pyautogui: To move the mouse, type

A

pyautogui.moveTo(100, 150)

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

pyautogui: To type characters, type

A

pyautogui.typewrite(“My String”, interval=0.25)

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

pyautogui: To take a screenshot and then save it, type

A

screenshot = pyautogui.screenshot()

screenshot.save(“path/screenshot.png”)

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

smtplib: To send a gmail email with an image attachment, type

A

import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.image import MIMEImage
from email.mime.text import MIMEText

my_msg = MIMEMultipart()
my_msg[“Subject”] = “My subject”
my_msg.attach(MIMEText(“My body message text”, “plain”))

fp = open(“file/path.png”, ‘rb’)
file = MIMEImage(fp.read())
fp.close()
my_msg.attach(file)

server = smtplib.SMTP(“smtp.gmail.com:587”)

server. ehlo()
server. starttls()
server. login(“me@gmail.com”, “password”)
server. sendmail(“from@gmail.com”, [“to@gmail.com”], my_msg.as_string())
server. quit()

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

smtplib: To send a gmail email with a csv attachment, type

A
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email.mime.text import MIMETe
xt
from email import encoders

my_msg = MIMEMultipart()
my_msg[“Subject”] = “My subject”
my_msg.attach(MIMEText(“My body message text”, “plain”))

fp = open(“/path/filename.csv”, “rb”)
file = MIMEBase(“application”, “octet-stream”)
file.set_payload(fp.read())
fp.close()
encoders.encode_base64(file)
file.add_header(“Content-Disposition”, “file”, filename=”filename.csv”)
my_msg.attach(file)

server = smtplib.SMTP(“smtp.gmail.com:587”)

server. starttls()
server. login(“me@gmail.com”,”password”)
server. sendmail(“from@gmail.com”, [“to@gmail.com”], my_msg.as_string())
server. quit()

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

Math: ROI is

A

revenue divided by cost

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

Python: To create a special method that returns a string when print is called on a class instance, type

A
class Myclass(Parentclass):
    def \_\_str\_\_(self):
        return "This string is returned when print(my_instance) is called"
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Python: To create an __init__ method that prompts an input upon instantiation, type

A
class Myclass:
    def \_\_init\_\_(self, **args):
        self.my_attribute = input("Prompt string")
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Python: To create an __init__ method that prompts a method that then prompts two inputs, type

A
class Myclass:
    def \_\_init\_\_(self, **args):
        self.my_attribute = self.input_method()
    def input_meth(self):
        my_attribute = input("Prompt string")
            return my_attribute
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Python: To combine two columns together so their rows are both available in every iteration of a for loop, type

A

for item1, item2 in tuple(zip(df[“column”].tolist(), df[“column”].tolist())):
print(item1, item2)

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

Python: A generator expression is

A

the same as a list comprehension but can be passed into a function without turning it into a list.

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

Python: To write a generator expression, type

A

(item for item in my_list if item >5)

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

Python: To iteratively replace a list of characters with spaces, type

A

for item in [”.”, “?”, “!”]:

text = text.replace(item, “ “)

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

Python: To remove most of the html, style and scripts from a pages source, type

A

soup_page = BeautifulSoup(page, “html.parser”)

for script in soup_page.find_all([“script”, “style”]):
script.extract()

text = soup.get_text()

for item in [”.”, “?”, “!”, “,”, “ “]:
text = text.replace(item, “ “)

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

Pandas: To append a row of data to an existing df that is empty while also setting its column labels, type

A

df = df.append({“column1”:”value”, “column2”:”value”, “column3”:”value”}, ignore_index=True)

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

sklearn: A confusion matrix is a

A

2x2 matrix with the y index of actual class and x index of predicted class, that counts how many values of each class were correctly or incorrectly predicted. It is a measure of how many false positives and false negatives there are.

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

sklearn: Generally it seems for text it is best to

A

Not use select percentile
use a stemmer
remove irrelevant symbols and characters
use Tfidf instead of CountVect

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

sklearn: When choosing the training data it is pivotal to

A

not have mislabeled data

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

sklearn: When choosing the features, use

A

the all features you think have high information gain, and do whatever is necessary to get them into the dataset.

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

sklearn: It is very unlikely for NearestNeighbors

A

to outperform other models, and if it does it may be because the data has duplicates

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

Python: To open a file on windows in its default application, type

A

os.system(“start /file/path.csv”)

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

sklearn: The default settings for GridSearchCV should be

A

if using DataFrameMapper

sklearn_pandas.GridSearchCV(pipeline, param_grid=param_grid, verbose=3, scoring=”accuracy”, cv=10)

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

sklearn: When data is missing, it can be useful to

A

impute the data based on hints in the other columns. eg Mr. is associated with older age.

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

sklearn: To GridSearchCV the parameters of a model nested in a pipeline, type

A

import sklearn_pandas
param_grid = {“setname__parameter”:[10, 20, 30]}

grid_model = sklearn_pandas.GridSearchCV(pipeline, param_grid=param_grid, verbose=3, scoring=”accuracy”, cv=10)

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

sklearn: To use sklearn_pandas.GridSearchCV, you cannot

A

have any custom transformer (I think)

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

adwords: In upgraded URLs, curly brackets with an underscore in the tracking template means,

A

That it is a variable name that must be assigned in one of the custom parameters.

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

adwords: Always export reports as

A

a nomal CSV, not the Excel type

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

Pandas: To make the last column the first, type

A

df = df.reindex_axis([“Conversions”] + [item for item in df.columns if item !=”Conversions”], axis=1)

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

Python: To inherit from two parent classes, type

A

class Myclass(Parentclass1, Parentclass2):

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

GridSearchCV: To print all of the grid scores as GridSearchCV is working, type

A

verbose=3

sklearn_pandas.GridSearchCV(pipe, param_grid, verbose=3)

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

GridSearchCV: To choose the number of folds GridSearchCV creates, type

A

cv =10

sklearn_pandas.GridSearchCV(pipe, param_grid, verbose=3, scoring=”accuracy”, cv=10)

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

Python: To make a class that prompts for an input upon init and if it is not part of a list, it asks for the input again, type

A

class Myclass:
def __init__(self, **args):
def get_attribute(self):
my_attribute = input(“Attribute query?”)
if my_attribute != “chosen attribute”:
return get_attribute()
else:
get_attribute()
self.my_attribute = self.get_attribute()

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

Python: To perform addition on just one index of a list, type

A

my_list[2] += 1

or

my_list[2] = my_list[2] +1

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

Python: DRY means

A

grouping common operations into functions and common functionality in classes.

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

Python: To borrow classes from another python file in the same directory, type

A

from otherclassfile import Myotherclass

class Myclass(Myotherclass):

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

Python: To extend two classes, type

A

class Myclass(Otherclass, Otherclass2)

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

Python: To override a function that is inherited from a class just

A

create a new function in the current class with the same name

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

Python: Before inheriting a class make sure to

A

import it.

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

Python: In order to set attributes of a class they must be

A

in def __init__(self, **args):

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

Python: All classes implicitly extend from

A

the Object class

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

Python: The format for a set is

A

{1,2,3}

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

Python: A set automatically

A

removes any non unique values and order the rest in ascending order.

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

Python: Can a set use a comprehension?

A

yes

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

Python: When a tuple is a paramater into a class it requires

A

it’s own brackets

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

Pandas: To set the maximum rows and columns to display, type

A

pandas. set_option(“display.max_rows”, 1000)

pandas. set_option(“display.max_columns”, 1000)

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

Python: A dependency is

A

an external file that must be imported into the file you are running.

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

Python: To sum a list, type

A

sum(my_list)

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

sklearn: for RandomForestClassifer, the parameters you should GridSearchCV are

A

n_estimators, max_features, max_depth, min_samples_leaf

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

sklearn: If the desired output consists of one or more continuous variables

A

the task is called regression.

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

sklearn: In a confusion matrix it is ideal for the

A

main top left to bottom right has the highest numbers because that signifies correct classifications.

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

sklearn: Recall is

A
the rate of how often the algorithm misclassifies a sample that is in fact a certain class as another one.
"This class only gets classified correctly x percent of the time."
When a sample is in fact a certain class, how often is it classified correctly.

“in fact”

Measure of false negatives for a class.

true positives/(false negatives + true positives)

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

sklearn: Precision is

A

the rate of how often when a classification is made, how often it is correct.
“When a classification is finally made for this sample we are x sure that is was made correctly”
How often do samples of other classes get mistaken for this class.

“when classification is made”

Measure of true positives for a class.

true positives/(false positives + true positives)

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

sklearn: When using an unbalanced dataset with many samples of one class and few of another, it is better to use the the evaluation metrics of

A

precision, recall, or f1 score (which is both) on a class by class basis.

66
Q

sklearn: f1 score is a combination of

A

precision score and recall score

67
Q

GridSearchCV: To use GridSearchCV with the goal metric as f1 type

A

scoring=”f1”

68
Q

udacity: To predict the time of arrival for at&t techs, udacity

A

binned the times into sections of the day and used a NearestNeighbors classifier to predict based on locality.

69
Q

ML: A spurious attribute is an attribute that

A

should not have any bearing on the label so any features with an information gain lower than the spurious attribute can be ignored.

70
Q

ML: A plot where the prediction line is very wiggly suggests

A

overfitting

71
Q

ML: The definition of p-value is

A

idk

72
Q

Stats: Stratified sampling is when

A

The population is grouped by a characteristic, and then a number of samples is pulled from each group to represent it.

73
Q

Stats: Cluster sampling is when

A

you group samples based on a characteristic but then only pull samples from one of the groups.

74
Q

Stats: Simple random sampling is when

A

All of the samples are grouped together and chosen chosen at random and then returned back into the pool at each draw.

75
Q

Console: Vim is a… and the command is

A

A text editor and the command is: vi my_file.py

76
Q

Python: To sort a list in place, type

A

my_list.sort()

77
Q

Python: To reverse the elements of a list in place, type

A

my_list.reverse()

78
Q

Python: To return a count the occurrences of a value in a list, type

A

my_list.count(“value”)

79
Q

Python: To apply a lambda function to all of a lists items instead of using a list comprehension, type

A

list(map(lambda x: x*2, my_list))

80
Q

Python: The map function returns

A

an object, not a list.

81
Q

Python: To return a list of all of the

A

os.listdir(“/users/student/desktop”)

82
Q

Python: When I see myself looping and appending, I should question whether

A

a list comprehension assigned to a variable would do.

83
Q

sklearn: In order to optimize GridSeachCV towards f1, recall or precison, you must

A

make the labels binary (1 and 0) only.

84
Q

sklearn: To make GridSearchCV run faster, add

A

n_jobs=-1 to the parameters

85
Q

sklearn: To save the best GridSearchCV params to a variable, type

A

best_parameters = grid_search.best_estimator_.get_params()

86
Q

Python: If you edit a class, make sure to

A

re-instantiate the instance afterwards so it can take on the new attributes.

87
Q

Pandas: df[“column”].str.contains(“string”) is

A

case sensitive

88
Q

sklearn: To reattach the predictions to the samples, type

A

df[“Prediction”] = pandas.Series(model_grid.predict(my_transformer(df_features)))

89
Q

Selenium: to return the current url, type

A

my_browser.current_url

90
Q

sklearn: for small datasets a classifier that can work well is

A

LinearSVC

91
Q

sklearn: To return the best params and best score from a grid search, type

A

model_grid.get_params_

model_grid.best_score_

92
Q

sklearn: To return the best params from a grid search, type

A

model_grid.get_params_

93
Q

numpy: To transpose a numpy array, type

A

my_array = np.array([1,2], [3,4])
my_array.T
array([ [1, 3],
[2, 4] ])

94
Q

numpy: To merge to sets of columns, type

A

numpy.concatenate((a, b), axis=1)

95
Q

marketing: A burst is

A

usually incentivized traffic for a short time.

96
Q

marketing: Incentivized traffic is usually,

A

a sign up or download in exchange for a bribe like in game currency.

97
Q

HTTP stands for

A

HyperText Transfer Protocol

98
Q

HyperText is

A

text with links in it

99
Q

Transfer protocol is

A

rules for getting data from one place to another

100
Q

REST API stands for

A

Representational State Transfer

101
Q

A stateless API means that

A

all information necessary to respond to a request is available in each individual request; no data, or state, is held by the server from request to request

102
Q

axis=1 means

A

columns

103
Q

numpy: to check the type of object an arroy is, type

A

my_numpy_array.dtype

104
Q

mysql: To delete a table, type

A

DROP TABLES tablename;

105
Q

mysql: To delete multiple tables , type

A

DROP TABLES tablename1, tablename2;

106
Q

mysql: To insert multiple rows into a table together, type

A

INSERT INTO tablename VALUES (“String 1”, “String 2”), (“String 1”, “String 2”);

107
Q

mysql: Strings that you are inserting into a table must be

A

surrounded by quotes

108
Q

re: To test if a regex matches a string in the python interpreter, type

A

import re

re.match(r’^org/?P\w+/$’, ‘org/companyA’)

109
Q

re: To create the variable that will be parseable by re from a txt file, type

A

import re

file = open(“my_file.txt”, encoding=”utf-8”)
data = file.read()
file.close()

110
Q

python: To chain multiple ands and ors into an if statement, type

A

if (True and True) and (False or True) or (False and False):

111
Q

python: This returns
if True and False:
print(“Hi”)

A

nothing

112
Q

python: This returns
if True or False:
print(“Hi”)

A

“Hi”

113
Q

python: To turn [“A”] into [“A”, “A”, “A”, “A”], type

A

[“A”] * 4

114
Q

pandas: For plots to display in the notebook, type

A

%pylab inline

115
Q

Pandas: changes columns name uses the command

A

rename, not replace

116
Q

Excel: When doing vlookup, set approx match to

A

0

117
Q

Pandas: to remove the index when sending df to string, type

A

df.to_string(index=False)

118
Q

flask: In order to use a file from the templates directory in a view function, type

A

import render_template

@app.route("/")
def my_view_function():
    return render_template("file.html")
119
Q

flask: To open spots in the html template that are variable from the view, you need to

A
put {{ var_name }} in the template 
pass the variable into render_template like
return render_template("file.html", var_name=var_name)
120
Q

flask: when creating views remember to

A

set defaults for the variable that are supposed to be passed in.

121
Q

flask: {{ var_name }} is used in

A

templates to pull a variable into it from the view.

122
Q

flask: all html files must go in

A

the template directory

123
Q

flask: the symbols for variable and blocks are

A

variable: {{ var_name }}
block: {%block my_block %}{% endblock %}

124
Q

flask: the file html you are extending must

A

have quotes around it

125
Q

flask: html pages with after extending from layout.html and removing repeated html look like

A

{% extends “layout.html” %}

{% block title %}{{ super() }} My Title Tag{% endblock %}

{% block body_content %}

<h1>This is the content of my body</h1>

{% endblock %}

126
Q

flask: To have a views route redirect you to another view function, type

A

from flask import redirect
from flask import url_for

@app.rout("/save")
def save():
    return redirect(url_for("view_function"))
127
Q

flask: to make a view function only allow post methods to access it, type

A

@app.route(“/save”, methods=[“POST”])

128
Q

flask: to access the form data POSTed into a view, type

A

request.form

129
Q

flask: To set a cookie by instantiating a make_response object, type

A

import json
import make_response
import redirect
import url_for

@app.route(“/save”, methods=[“POST”])
def save_view():
response = make_response(redirect(url_for(“index.html”)))
response.set_cookie(“cookie_name”, json.dumps(dict(request.form.items())))
return response

130
Q

flask: to create a form thats action is to send a POST request to a view. (which is later made to set a cookie)

A

{% block my_body %}

  • form action=”{{ url_for(“save”) }}” method=”POST”>
    • label>Form title-/label>
    • input type=”text” name=”name” value=”” autofocus>
    • input type=”submit” value=”default!”>
  • /form>

{% endblock%}

131
Q

flask: To be able to accept a form POST request, you must first

A

import request in the app file

from flask import request

132
Q

flask: In flask the cookie is set upon

A

the response to the browser

133
Q

flask: When setting a cookie with a POST request from a form, the value of the cookie becomes

A

a dict with the key as the name from the name parameter in the form, and the value as the value inputted into the form.

134
Q

flask: Cookies set on a browser have both

A

a name (which you give) and a value which is a dict with the name and value from the form field.

135
Q

flask: To create a view meant for setting a cookie, type

A
def get_cookies():
    try:
        cookie = json.loads(request.cookies.get("cookie1"))
    except:
        cookie = {}
    return data

@app.route(“/save”, methods=[“POST”])
def save():
response = make_response(redirect(url_for(“index”)))
cookie = get_cookies()
cookie.update(dict(request.form.items()))
response.set_cookie(“cookie1”, json.dumps(cookie))
return response

136
Q

flask: To make the default value of a form the value from a cookie, type

A
create the function that returns the cookie in dict format.
def get_saved_data():
    try:
        data = json.loads(request.cookies.get("cookie name"))
    except:
        data = {}
    return data
Pass the cookie dict into the template.
@app.route("/")
def index():
    data = get_saved_data()
    return render_template("index.html", data=data)

Set the value in the form.

137
Q

flask: In the view that just received a POST request, to get all the form keys and values, type

A

request.form.items()

138
Q

flask: To use a for loop in flask, type

A

{% for item in my_list %}
-li>-h2>item-/h2>-/li>
{% endfor %}

139
Q

python: When you are inheriting from two parent classes, the order should be

A

most import parent class last.

140
Q

flask: The three main files that go in the directory are

A

app.py, templates, static

141
Q

flask: In a flask app the css file will be in

A

-link rel=”stylesheet” href=”../static/styles.css”>

142
Q

flask: To create a form meant to file uploads, type

A
  • form action=”” method=”” enctype=multipart/form-data>
    - input type=”file” value=”value” name=”name”>
  • /form>
143
Q

flask: When I reference images from within an html view, it assumes

A

I am already in my static directory, so I can reference the files directly without changing levels.

144
Q

flask: I must keep all static files without exception in

A

static/

145
Q

flask: To upload a file, type

A

ALLOWED_EXTENSIONS = set([‘txt’, ‘pdf’, ‘png’, ‘jpg’, ‘jpeg’, ‘gif’])

app = Flask(\_\_name\_\_)
app.config['UPLOAD_FOLDER'] = '/home/alpalalpal/mysite/static'

@app.route(‘/4’, methods=[‘GET’, ‘POST’])
def upload_file():
if request.method == ‘POST’:
file = request.files[‘file’]
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
file.save(os.path.join(app.config[‘UPLOAD_FOLDER’], filename))
return redirect(url_for(‘uploaded_file’,
filename=filename))
return ‘’’

Upload new File
<h1>Upload new File</h1>

  <p>

</p>
'''
146
Q

flask: Loops inside flask blocks do not require

A

a colon

147
Q

pyautogui: To scroll down, type

A

pyautogui.scroll(-10)

148
Q

python: list(range(1,2)) has

A

1 item

149
Q

Outbrain: The number of characters allowed in ads it

A

150

150
Q

Hadoop is

A

an open-source software framework written in Java for distributed storage and distributed processing of huge data sets.

151
Q

Statically typed programming languages

A

do type checking, which is verifying and enforcing the constraints of types at compile-time as opposed to run-time.

152
Q

MapReduce is

A

an algorithm that allows you to query data in parallel on a distributed cluster of computers.

153
Q

Big Data refers to at least

A

a terabyte of data

154
Q

The four V’s of IBM’s definition of big data is

A

volume, variety, veracity and velocity

155
Q

Apache Mahout is

A

library of scalable machine-learning algorithms, implemented on Apache Hadoop

156
Q

Hadoop: HDFS stands for

A

Hadoop Distributed File System

157
Q

Hadoop: A cluster usually has

A

one heavy duty computers and then 10-15 commodity computers

158
Q

A node is a

A

single point in a network or single computer in a cluster.

159
Q

os: To change your current working directory from within python, type

A

import os

os.chdir(“C:\folder”)

160
Q

ipython: Sometimes when there is an unusual error it can be ameliorated by

A

restarting he kernel

161
Q

cookies: For security purposes, cookies can only be accessed by

A

the site that placed them.

162
Q

python: To create a decorator with no arguments, type

A
def log(func):
    def inner():
        print("string")
        return func()
    return inner
@log
def say_hello():
    return "Hello there!"

say_hello()