1. Data Structure (and method) and Basic operation Flashcards

1
Q

8 basic datatypes

A

int, float, bool, str

list, tuple, set, dict

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

list

A

[a,b,c]

ordered sequence of objects

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

tuple

A

(a,b,c)

ordered immutable sequence of objects

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

set

A

{a,b,c}
unordered unique objects

set cannot be retrieved by index
either cast it to a list or tuple unpacking

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

dictionary

A

{“k1”: a , “k2” : b}
unordered key:value pairs
key can be number

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

index: power of 2

A

2**2

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

Remainder: 7 mod 4

A

7%4

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

not equal

A

!=

and == means equal

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

integer division / floor division

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

line continuation

A

‘this is a \

line continuation’

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

block comment

A

’’’
abc
‘’’
may only work in Jupyer

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

user input

A

myvar = input()

always returns string

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

create variable dynamically

A

for i in range(9):

exec(f”g{i} = Grid({i})”)

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

In place function

A

Act direct and does not return anything

List.sort() -> original list is sorted

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

cast to different data types

A
int(string)
list(string)
str(int)
str(list) -> this is stupid
set(list)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

check type

A

type

17
Q

check reference

A

id()

18
Q

import module

A

import datetime

import pandas as pd

19
Q

import method from module

A

from datetime import datetime and timedelta

from random import shuffle