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
Q

What issues does “< tolerance” fix

A

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
Q

When “or” is used, how many trues does there need to be for the output to be true ?

A

one or more

25
Q

How many falses in needed for a “and” output to be false

A

one or more - regardless of the amount of True statements

25
Q

if brackets are empty, is this considered “truthly” or “falsely” ?

ex: [ ]

A

falsely

26
Q

if something is in brackets regardless of what it is, (besides a space) is this “truthly” or “falsely”

A

truthly

27
Q

What function checks the truthliness of an object?

A

bool()

28
Q

is a 0 value true or false ?

A

false

29
Q

is a non-zero true or false?

A

true

30
Q

what does

a += 5

mean

A

a = a +5

31
Q

what does

a /= 10

mean

A

a = a / 10

32
Q

what does

a ^= 10

mean

A

a = a ^ b

33
Q

Is it possible to multiply strings? If yes, how is this done?

A

it can be done using *

s= ‘foo’

print(3 * s)

‘foofoofoo’

34
Q

What happens if you try to multiply strings with a negative number

A

you get a blank output (NOT AN ERROR!)

35
Q

What happens if you try to multiply strings with a float

A

will result in an error

36
Q

what does ord() do?

A

it is the opposite of chr() and outputs the number value when given a string

36
Q

what does the function chr() do?

A

checks what a number represents and outputs the corresponding string value

a = 97

chr(97)

a

37
Q

what is string indexing?

A

refers to assigning values to letters in a string :

f o o b a r
0 1 2 3 4 5

38
Q

What is the 0th letter?

A

the technical “first” letter

39
Q

what is ‘string slicing’ ?

A

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
Q

Is the second boundary ever included in string slicing?

ex: s[3:6]
-would the sixth value be included

A

no, the second boundary is never included

41
Q

is zero needed before the colon in string slicing?

ex: [:4]

A

no _:and 0: mean the same thing

42
Q

is an end value needed if the string slicing is wanted to be done to the end of the string?

ex s[2:]

A

no, they mean the same thing

43
Q

true or false: s[2:len(s)]

means to go the end of the string

A

true

44
Q

yes or no: does the first boundary in string slicing need to be lower than the second boundary?

A

yes

45
Q

how do negative values work in string slicing?

A

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
Q

what is a ‘stride’ in string slicing?

A

a command that count the term ever n number of terms

s[::5] - counts the term every 5 terms

47
Q

what effect does a negative number have on stride string slicing?

A

it reverses the order and starts at the last letter

racecar -> racecar

48
Q

What does immutable mean?

A

means you can change the value of a term/letter

49
Q

Are strings immutable?

A

yes, strings are immutable - their values cannot be changed

50
Q

Are lists immutable or mutable ?

A

mutable. Individual term values can be changed

51
Q

What are the first 3 facts about python lists?

A
  1. They are ordered
  2. They can contain arbitrary objects
  3. Elements can be accessed by the index
52
Q

What are the last three facts about python lists?

A
  1. Can be nested
  2. Are mutable
  3. They are dynamic
53
Q

All 6 facts about python lists?

A
  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