Day Four - Randomisation and Python Lists Flashcards

1
Q

How to access the random library?

A

import random

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

Can you import your own module?

A

Yes, just create a file and them go to another (program) and type: ‘import + name of the file’.

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

How can you make a random float number?

A

Type: random.random()

and them multiply it by 5 (or any other number).

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

How can you make a random int number?

A

Type: random.randint()

Put the two numbers inside.

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

How to make a list?

A

You can set them by typing a = [smt, smt2]

two square brackets.

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

How to access a specific item inside of it?

A

print(a[1])

by using the brackets and the n° of the position inside of it.

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

How to add an element at the end of the list?

A

You can use .append.

ex - a.append(element).

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

How can you use the split to split after a specific parameter?

A

Put the parameter inside the parenthesis.

a.split(“, “) (the parameter is the comma).

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