Python Inbyggda Funktioner Flashcards

1
Q

print()

A

Skriver ut det inom parantesen i kommandofönstret

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

Tilldelningsoperator (för en variabel tex)

A

=

(Tilldelning går från höger till vänster)

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

Skivning / Slicing

A

Plockar ut en del av en lista

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

x= [’a’, ’b’, ’c’, ’k’]
print(x[2:4])

A

’b’, ’c’

Printar index 2 till 4-1 (dvs 3)

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

x=[]
x.append(2, 3)

A

X=[2, 3]

Listor är förändringsbara (mutable)
Append är en list-funktion

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

[]+[]

A

konkatenerar två listor

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

[1] * 3

A

[1, 1 , 1]
Mångfaldigar listor

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

str(14)

A

’14’
byter datatyp

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

float(’12’)

A

12.0
byter datatyp

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

int(13.5)

A

13
Byter datatyp - avrundar nedåt till heltal

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

if

A

en typ av villkorssats

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