commands and what they do Flashcards

1
Q

int

A

integers; they are whole numbers | Ex: 14, 7, 241

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

float

A

floating point #s: they are numbers with a decimal point | Ex: 2.8, 7.6, 100.8

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

str

A

strings; these are an ordered sequence of characters or numbers within quotes | Ex: “hola”, “yellow”, “example”

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

list

A

lists; an ordered, changeable sequence of objects | Ex: [“hola”,7,2.8]

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

dict

A

dictionaries; unordered Key:Value pairs | Ex: {“key”:”value”,”name”:”Jose”}

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

tup

A

tuples; ordered unchangeable sequence of objects | (7.6,”yellow”,241)

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

set

A

sets; unordered collections of unique objects | {2.5,”example”,(2,3,5)}

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

bool

A

booleans; logical value that indicates True or False

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

\n

A

Puts the following string on a new line when printed

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

\t

A

Inserts a tab

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

len()

A

Returns the length of the string entered in the parentheses

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

str.upper()

A

Outputs everything in the string as uppercase

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

str.lower()

A

Outputs everything in the string as lowercase letters

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

str.split()

A

Outputs the string in a list as specified by the splitting condition typed into the parentheses | by default it splits by any white spaces in the string

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

%s

A

Inputs a specified string into the spot the function was placed: will convert whatever is specified into a string

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

%r

A

Converts whatever is specified into a string representation using the repr() function

17
Q

%d

A

Converts whatever number was specified into an integer

18
Q

//

A

Floor division operator. It will truncate the decimal numbers off and output the integer

19
Q

%5.2f

A

The 5 is the minimum number of integers the number will contain… If it’s less then a space will fill the spot. The .2f is the number of decimal places you’d like the

20
Q

.format()

A

Will input into a print function what is entered into the parentheses. To put the placeholders in the print function, use {}

21
Q

Formatted string literals | f-strings

A

Place f into print function right before the double quoted sentence. Insert the variable name into {}

Use !r right before typing variable name to get the string representation

22
Q

elif statement

A

After declaring an if statement, you can write as many elif statements to state other conditions

23
Q

else statement

A

After declaring if and all elif statements, you finish up with an else statement that’s a catch all for any condition not declared in the if/elif statements

24
Q

break

A

Breaks out of the current enclosing loop

25
Q

continue

A

Goes to the top of the closest enclosing loop

26
Q

pass

A

Does nothing at all