sweigart chapter 1 Flashcards

1
Q

interactive shell/Read-Evaluate-Print Loop (REPL)

A

lets you run (or execute) Python instructions one at a time and instantly shows you the results.

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

expressions

A

consist of values (eg. 2) and operators (eg. +) and can always evaluate (reduce) down to a single value. a single value is also considered an expression but it evaluates only to itself. you can use expressions anywhere in Python code where you could also use a value.

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

precedence

A

the order of operations. python math operators are similar to mathematics. parentheses can be used.

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

data type

A

a category for values, where every value belongs to one data type.

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

strings

A

text values surrounded by single quote (‘) characters, also known as strs.

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

integer

A

eg. 1

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

floating-point number (floats)

A

incorporates a decimal point, eg. 1.0

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

empty/blank structure

A

a string with no characters in it (“).

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

string concatenation operator

A

when + is used on 2 string values it joins the strings.

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

string replication operator

A

when * is used on one string value and one integer value. it evaluates the expression down to a single string value that repeats the original string a number of times equal to the integer value.

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

variable

A

a box in the computer’s memory where you can store a single value. if you want to use the result of an evaluated expression later in your program.

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

assignment statement

A

used to store values in variables. it consists of a variable name, an equal sign (assignment operator), and the value to be stored.

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

initialised

A

when the variable is created the first time a value is stored in it. after that, you can use it in expressions with other variables and values.

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

overwriting a variable

A

when a variable is assigned a new value and the old value is forgotten.

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

camelcase

A

using capitalised letter for every new word instead of underscores. eg. current_balance becomes currentBalance.

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

file editor

A

used to write entire programs. in the file editor, instructions will not be run when you press enter. instead, you can save a file with many instructions and then run the program. it also does not have the&raquo_space;> prompt. you can start the program in the file editor so that it will start running in the interactive shell.

16
Q

terminates

A

when there are no more lines of code to execute, the Python program stops running.

17
Q

commenting out

A

every line following a hash mark (#) is called a comment and will be ignored by Python. it can be used as a note to yourself or to temporarily remove a line of code while testing a program.

18
Q

print() function

A

indicates that Python has to print out the text in a string.

19
Q

calling

A

executing a line with a function

20
Q

passed

A

when a line is executed and a function is called, the string value is passed to the function.

21
Q

argument

A

a value that is passed to a function call.

22
Q

len() function

A

evaluates to the integer value of the number of characters in a string value.

23
Q

input() function

A

waits for the user to send some text. this function evaluates to a string equal to the user’s text.

24
Q

int() function

A

can be helpful if you have a number as a string value that you want to use in mathematics. floating-point numbers will always be evaluated downwards.