Python crash course Flashcards

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

How to perform float division python

A

from __future__ import this

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

What is mutable? Give a definition alternative

A

Mutable: once you set it , cant modify it . Lists vs Sets

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

functions to present intrinsic elements of dictionaries

A

dict. values()
dict. keys()
dict. items #return the dict elements as a tuple

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

What is counter from collections?

A

For a data structure, it counts how many times an element appears.

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

Why to use sets?

A

Fast operations and checking membership

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

Difference between sorted(list_) and list_.sort()

A

The second is in place sorting

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

How to create function factories?

A

from functool import partial

new_func=partial(func,value=value_)

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

What map function performs?

A

maps(func,iterable) is the signature of the function.

According to func, it transforms the iterable which may be anything.

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

What does filter does

A

filter(func,iterable)

if func, which acts to the subsequent elements of an iterable, returns a true value then the element is kept.

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

Which is the functionality of zip(list1,list2)?

A

Merges two lists

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

What is ‘reduce’ function in python and how it is called?

A

The reduce() function accepts a function and a sequence and returns a single value calculated as follows:

Initially, the function is called with the first two items from the sequence and the result is returned.
The function is then called again with the result obtained in step 1 and the next value in the sequence. This process keeps repeating until there are items in the sequence.

reduce(func, iterable)

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

Find minimum and maximum value of a list

A

min(list) max(list)

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

What is dispersion? Define a simple measure in python

A
Dispersion is a metric how spread are our data. A simle metric for a list of data is range
def range(list_):
return max(list_) -min(list_)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Describe a more complicated version of dispresion

A

A more complicated method of dispersion is variance

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

If you want to generate random events in python, you can use random module. Define two use cases

A

import random

random. randint(x,y) #produce a random int between x and y
random. choice(iterable) #produce a random element from the iterable

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

What is Jupyter Notebook?

A

The Jupyter Notebook is an interactive environment for running code in the browser.

17
Q

In scikit-learn, What is the fundamental data structure?

A

The NumPy array