Python Flashcards

1
Q

Find an index number

A

my_list.index(200)

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

Assign a value to an existing index

A

my_list[4]=100

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

Allow user to input a value

A

my_list[9]=input()

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

Print the length of list

A

print(len(my_list))

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

Add another value to the end of an existing list

A

my_list.append(200)

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

Remove an indexed value

A

my_list.pop(5)

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

Make whole string uppercase

A

.upper()

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

Make whole string lowercase

A

.lower()

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

Make only first letter of every word uppercase.

A

.title()

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

Count the number of a certain character in a variable.

A

.count(x)

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

Print an indexed value

A

print(variable[number])

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

Loop while condition is true

A

while x==x:

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

Repeat a certain number of times

A

for i in range(number):

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

Range

A

range([starting number], [up to but not including], [steps])

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

Check if is upper

A

.isupper()

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

Check if is lower

A

.islower()

17
Q

Check if variable contains any numbers

A

.isnumeric()

18
Q

Import random

A

import random

19
Q

Random number

A

.randint([starting point], [end point])

20
Q

Random integer

A

.randrange([start], [stop], [step])

21
Q

Random floating point

(For up to a number multiply by desired maximum number)

A

.random()