Chapter 3 Flashcards

1
Q

Comment

A

A line of code written in English preceded by #

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

Print

A

print(“”) or print(‘’)

Prints whatever character input between the parenthesis

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

Line

A

Programs are made up of lines of code.

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

Keywords

A

Words with special meaning.

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

Data Types

A

Python groups data into different categories.

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

Object

A

Each data value. ie. 2 or “Hello, world!”

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

3 Properties of an Object

A
  1. Identity
  2. Data Type
  3. Value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Object’s Identity

A

Location in your computer’s memory, which never changes.

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

Object’s Data Type

A

Category of data the object belongs to, which determines the properties of the object, which never changes.

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

Object’s Value

A

The data it represents ie. the number 2. Value of 2.

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

“Hello, world!” Object Properties

A
  1. Data Type: str == string
  2. Value: “Hello, world!”
    aka a string
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

string

A

A sequence of one or more characters surrounded by quotes.

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

character

A

A single symbol. ie. ‘a’ or ‘1’.

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

Integer

A

int;

represents whole numbers

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

int Properties

A

Able to multiply(*), divide(/), add(+), subtract(-).

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

float

A

float;

represents decimal numbers

17
Q

booleans

A

bool;

True or False statements.

18
Q

NoneType

A

value None;

Used to represent the absence of value.

19
Q

Constant

A

Value that never changes.

eg. 2 will always represent the value 2

20
Q

Variable

A

Value that can change.

eg. b = 100; b = 200

21
Q

Assignment Operator

A

(=);

Assign the variables name a value.

22
Q

Increment Value of a Variable

A

Increases the value of a variable.

eg. x = x + 1 or x = x += 1

23
Q

Decrement Value of a Variable

A

Decreases the value of a variable.

eg. x = x - 1 or x -= 1

24
Q

4 Rules for Naming a Variable

A
  1. Variables cannot have spaces.
  2. Letters, numbers, and underscore.
  3. Cannot start name with a number.
  4. Cannot use keywords as names.
25
Q

Syntax

A

Set of rules, principles, and processes that govern the structure of sentences in a given language, specifically word order.

26
Q

Syntax Error

A

Errors that are fatal and program will not run.

27
Q

Exception

A

Any error that is not a syntax error. Not necessarily fatal.

28
Q

Arithmetic Operators

A

Symbols that perform arithmetic.

29
Q

Arithmetic Operators: Symbols

A
  1. ’+’ addition
  2. ’-‘ subtraction
  3. ‘*’ multiplication
  4. ’/’ division
  5. ‘**’ exponent
  6. ’%’ remainder
  7. ’//’ integer division/floored quotient
30
Q

Operand

A

Value on either side of an operator.

eg. print(4/2) # ‘4’ & ‘2’ are the operands

31
Q

Expression

A

An operator surrounded by two operands.

eg. print(4/2) #”4/2” is the expression

32
Q

Order of Operations

A
Parenthesis
Exponent
Multiplication
Division
Addition
Subtraction
33
Q

Comparision Operator

A

Category of operators used in an expression that evaluate either true or false.

34
Q

Comparison Operators: Symbols

A
  1. ’>’ greater than
  2. ’=’ greater than or equal to
  3. ’<=” less than or equal to
  4. ’==’ equal
  5. ’!=’ not equal
35
Q

Logical Operators

A

Evaluate two expressions and return either True or False.

36
Q

List the Logical Operators

A
  1. and: Returns true if both statements are true.
  2. or: Returns true if one of the statements are true.
  3. not: Returns the opposite of the result.
37
Q

Conditional Statements

A

Code that can execute additional code conditionally.

38
Q

List the Conditional Statements

A
  1. if: Firstly, define a condition for the code to meet and execute.
  2. elif: Combines the two statements as an if-else statement.
  3. else: Secondly, False “if-statement”, define another condtion which the code will execute.