Chapter 2 - Types, variables and simple I/O Flashcards

1
Q

American Standard Code for Information exchange

A

ASCII

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

newline sequence

A

\n

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

tab sequence

A

\t

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

print a backslash

A

\

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

escape sequence (rings a bell if played by windows)

A

\a

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

concatenating strings

A

combination of strings using “+”
print(“me” + “plus” + “you”)
meplusyou

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

line continuation (entered at the end of a line); used for readibility
-used outside of a string
print(“Me” \
“ good”) -> Me good

A

\

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

peanut butter sandwich

peanut butter sandwich

A

print((“peanut” + “butter” + “sandwich”) * 2)

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

a whole number

A

integer

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

a number with a fractional point

A

floating-point number(float)

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

a sequence of values joined by operators

A

expression

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

integer division

19/5 = 3

A

\

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

Modulus - produces remainder of an integer

19/5 = 4

A

%

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

name = “Momchil”

A

assignment statement (creates a variable assigns value to variable) ! a variable gets a value, is not assigned one

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

Name 2 variable rules

A
  1. The variable name can only contain numbers, letters and underscores
  2. Can not start with a number
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Code, easily understood without comments

A

Self-documenting code

17
Q

print(variable.upper())

A

prints the variable in all uppercase letters

18
Q

print(variable.replace(“one”, “two”))

A

replaces the string “one” with “two”

19
Q

an ability a string has (e. g. quote.upper())

-needs to be called through a particular string (unlike a function)

A

string method

string.string_method()

20
Q

Returns a new string where the case of each letter is switched

A

swapcase()

21
Q

returns a string where all the white space at the beginning and end is striped

A

strip()

22
Q

when a program produces unintended results without crashing

A

logical error

23
Q

using the same operator with values of different types

A

operator overloading

24
Q

putting one function inside of another

A

nesting

25
Q

converts x to a floating-point value

A

float()

26
Q

converts x to an integer

A

int()

27
Q

converts x to a string

A

str()

28
Q

augments the value and assigns it back to the variable

A

augmented assignment operators

x *= 2 or x += 1