Unit Two (it's not wraps...yet) Flashcards

1
Q

Command to switch a number to an integer?

A

int()

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

What is a “float”

A

a number that has a decimal (can be .0)

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

What is the float command in Python? What do you type in do get the float command in python?

A

float()

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

What are strings and what is the command for strings?

A

They are sequences of character data. the command is str()

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

What are two ways to have a quote inside a quotation?

A

Either using:
Double quotes: “ “” “
or
A backslash: “John/’s meal”

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

What does the backslash do in Python?

A
  • can break up lines
  • negates anything after it in a string
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How is tab expressed in Python?

A

\t

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

What does \t do in python

A

tab

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

What is a raw string and how is it denoted?

A

a raw string disregards any escape sequences (ei “") that may come after it

it is formatted as such: print(r’john//’)

john//

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

What do triple-quoted strings do?

A

They can be used interchangeably with the backslash

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

What is boolean ?

A

True and False

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

absolute value function

A

abs()

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

What command is used to convert to a boolean value?

A

bool()

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

What function checks the type of a value?

A

type()

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

What function checks the length of a function?

A

len()

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

What function creates a list?

A

list()

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

What function sends a message to the user and receives a message?

A

input()

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

What does the != function mean?

A

not equal to

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

What needs to go in the square brackets?

print( {[ ]”Hello {name}’)

A

f

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

if
n = 300
and
m = n

does m = 300?

A

no because the identity codes will be different

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

can the first letter of a variable be a number ?

ex: 32goober

A

no

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

what are the three types of cases for variables and what do they mean?

A

camel case - has capitalized words not first word though (camel - capitalized)

pascal case - has the first letter capitalized

snake case - words are separated by underscores

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

what does a modulo look like and do?

A

%

finds the remainder of two values

24
Q

What is floor division and how is it expressed?

A

//

divides two numbers and rounds down

24
What issues does "< tolerance" fix
it fixes the issues when two floats are combined (in some way) it negates pythons habit of reading 1.1 as 1.1000000001 therefore saying "close enough"
25
When "or" is used, how many trues does there need to be for the output to be true ?
one or more
25
How many falses in needed for a "and" output to be false
one or more - regardless of the amount of True statements
25
if brackets are empty, is this considered "truthly" or "falsely" ? ex: [ ]
falsely
26
if something is in brackets regardless of what it is, (besides a space) is this "truthly" or "falsely"
truthly
27
What function checks the truthliness of an object?
bool()
28
is a 0 value true or false ?
false
29
is a non-zero true or false?
true
30
what does a += 5 mean
a = a +5
31
what does a /= 10 mean
a = a / 10
32
what does a ^= 10 mean
a = a ^ b
33
Is it possible to multiply strings? If yes, how is this done?
it can be done using * s= 'foo' print(3 * s) 'foofoofoo'
34
What happens if you try to multiply strings with a negative number
you get a blank output (NOT AN ERROR!)
35
What happens if you try to multiply strings with a float
will result in an error
36
what does ord() do?
it is the opposite of chr() and outputs the number value when given a string
36
what does the function chr() do?
checks what a number represents and outputs the corresponding string value a = 97 chr(97) a
37
what is string indexing?
refers to assigning values to letters in a string : f o o b a r 0 1 2 3 4 5
38
What is the 0th letter?
the technical "first" letter
39
what is 'string slicing' ?
breaking down the index of the string by using a colon to denote which values of the string something is referencing s = 'foobar' f o o b a r 0 1 2 3 4 5 s[2:5] 'oba'
40
Is the second boundary ever included in string slicing? ex: s[3:6] -would the sixth value be included
no, the second boundary is never included
41
is zero needed before the colon in string slicing? ex: [:4]
no _:and 0: mean the same thing
42
is an end value needed if the string slicing is wanted to be done to the end of the string? ex s[2:]
no, they mean the same thing
43
true or false: s[2:len(s)] means to go the end of the string
true
44
yes or no: does the first boundary in string slicing need to be lower than the second boundary?
yes
45
how do negative values work in string slicing?
same as postive integers just reverse - see example below -6 -5-4 -3 -2 -1 f o o b a r 0 1 2 3 4 5
46
what is a 'stride' in string slicing?
a command that count the term ever n number of terms s[::5] - counts the term every 5 terms
47
what effect does a negative number have on stride string slicing?
it reverses the order and starts at the last letter racecar -> racecar
48
What does immutable mean?
means you can change the value of a term/letter
49
Are strings immutable?
yes, strings are immutable - their values cannot be changed
50
Are lists immutable or mutable ?
mutable. Individual term values can be changed
51
What are the first 3 facts about python lists?
1. They are ordered 2. They can contain arbitrary objects 3. Elements can be accessed by the index
52
What are the last three facts about python lists?
4. Can be nested 5. Are mutable 6. They are dynamic
53
All 6 facts about python lists?
1. They are ordered 2. They can contain arbitrary objects 3. Elements can be accessed by the index 4. Can be nested 5. Are mutable 6. They are dynamic