Chapter 1: Python Primer Flashcards

1
Q

Python is an interpreted language, true or false?

A

true

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

interpreted language

A

a high-level language run by an interpreter, a program that directly executes instructions written in the programming or scripting language without first compiling it into machine code

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

machine code (x2)

A

1) any low-level programming language, which consists of machine language instructions that are used to control a computer’s CPU (central processing unit)
2) a numerical language designed to run as fast as possible

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

high-level programming language (x3)

A

1) any programming language with strong abstraction from the computer
2) closer to human languages (easier to read) and further from machine languages
3) focuses more on logic than underlying hardware components (eg. memory management)

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

examples of high-level programming languages (x10)

A

1) Python
2) PHP
3) Perl
4) Java
5) JavaScript
6) C#
7) C++
8) Ruby
9) Rust
10) GO

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

What does IDE stand for?

A

integrated development interface

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

IDE (integrated development environment)

A

a software application for building applications that combines developer tools into a single GUI (graphical user interface)

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

delimiter

A

a unique character or series of characters that indicates the beginning or end of a specific statement, string or function body set

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

examples of delimiters (x4)

A

1) Round brackets or parentheses: ( )
2) Curly brackets: { }
3) Double or single quotes for string literals: ‘ ‘ “ “
4) Escape sequence for comments: /*

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

Python is an object-oriented language, true or false?

A

true

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

object-oriented language

A

a language that uses classes and objects to create models

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

temperature = 98.6 is an example of an _____ statement

A

assignment

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

temperature = 98.6

in this example, temperature is an _____ (also known as name)

A

identifier

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

temperature = 98.6

in this example, 98.6 is an _____

A

object

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

temperature = 98.6

in this example, the identifier (also known as name) _____ references an instance of the _____ class having value _____

A

temperature
float
98.6

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

identifiers are case-sensitive in Python, true or false?

A

true

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

an identifier is implicitly associated with the _____ _____ of the object to which it refers

A

memory address

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

Python is a dynamically typed language, true or false?

A

true

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

dynamically typed language (x2)

A

any language that does not require declaring the data type of a variable

the variable type of checked during runtime

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

alias

A

a second identifier (also known as name) to an existing object

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

in this example, original is an _____

A

alias

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

in this example, identifiers temperature and original reference the same object 98.6, true or false?

A

true

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

in this example, either identifier temperature or original can be used to access the 98.6 object, true or false?

A

true

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

if an object supports behaviors that affect its state, changes through an alias will be apparent when using the other identifier, true or false?

why is this so?

A

true

both identifiers refer to the same object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
``` temperature = 98.6 original = temperature temperature = temperature + 50 ``` the temperature identifier has been assigned to a new value, while original continues to refer to the previously existing value, true or false?
true
26
``` temperature = 98.6 original = temperature temperature = temperature + 50 ``` what is the value of the floating-point object original references? what is the value of the floating-point object temperature references in the last line?
98. 6 | 103. 6
27
instantiation
creating a new instance of a class
28
the syntax for instantiating an object to invoke the _____ of a class
constructor
29
syntax of a constructor of a class
the class name followed by parentheses
30
constructor of a class (x3)
a special member function of a class that is executed when a new object of that class is created (also known as instantiated) it has the same name as the class it does not have any return type, not even void
31
w = Widget() in this example, the constructor does not require parameters, true or false?
true
32
w = Widget(a, b , c) in this example, the constructor requires parameters, true or false?
true
33
Many of Python's built-in classes support a literal form for designating new instances of a class (also known as objects), true or false?
true
34
temperature = 98.6 in this example, the value _____ is a literal
98.6
35
literal
a value that is recognized as syntax for creating an object (also known as instance of a class)
36
A way to indirectly create an instance of a class (also known as an object) is to call a function that creates and returns such an instance, true or false?
true
37
Python supports traditional functions that are invoked with syntax such as sorted(data) in this example, what is the function name? what is the argument sent to the function?
sorted data
38
Python's classes may define one or more methods (also known as member functions), true or false?
true
39
Member functions (methods) are invoked on a specific object (also known as instance of a class) using _____ notation
dot
40
data.sort() is an example of a method invoked using _____ notation
dot
41
sorted(data) and data.sort() are the same, true or false?
true
42
in dot notation, the expression to the _____ of the dot identifies the object upon which the method is invoked
left
43
data.sort() in this example, _____ is the identifier (also known as name)
data
44
in dot notation, the expression to the left of the dot can be an identifier (also known as name), true or false?
true
45
the dot operator can be used to invoke a method upon the immediate result of another operation, true or false?
true
46
response.lower().startswith('y') explain the order of what is evaluated in these method calls (x2)
1) response.lower() is evaluated, which returns a new string instance (also known as object) 2) startswith('y') is called on the new string instance (also known as object)
47
accessor methods (also known as get methods or getters)
methods that return information about an object's state, but do not change its state
48
mutator methods (also known as update methods, set methods or setters)
methods that do change an object's state
49
data.sort() is this example an accessor method or a mutator method? why?
mutator method the sort() methods changes the values of the identifier so they are sorted
50
immutable class
a class in which once an object of that class is instantiated (also known as created), its value cannot subsequently be changed
51
bool mutable or immutable?
immutable
52
int mutable or immutable?
immutable
53
float mutable or immutable?
immutable
54
list mutable or immutable?
mutable
55
tuple mutable or immutable?
immutable
56
what is a list (array in other languages)?
a mutable sequence of objects
57
str (String in Swift) mutable or immutable?
immutable
58
set mutable or immutable?
mutable
59
what is a set? mutable or immutable?
an mutable unordered set of distinct objects
60
what is a frozenset?
the immutable form of the set class
61
frozenset mutable or immutable?
immutable
62
dict (also known as associative mapping or a dictionary) mutable or immutable?
mutable
63
in Python, a Boolean value can be created from a nonboolean type using the syntax bool(foo) for value foo, true or false?
true
64
what is the syntax for creating a Boolean value from a nonboolean type?
bool(foo)
65
when a Boolean value is created from a nonboolean type, numbers will evaluate to _____ if zero and _____ if nonzero
false true
66
when a Boolean value is created from a nonboolean type, sequences and other container types like strings and lists evaluate to _____ if empty and _____ if nonempty
false true
67
a nonboolean value can be used as a condition in a control structure, true or false?
true
68
it is not mandatory to pass a value to bool(), true or false?
true
69
if a value is not passed to bool(), _____ is returned
false
70
control structure
a block of programming that analyzes variables and chooses directions in which to go based on given parameters or conditions
71
list (array in other languages), tuple, and str classes are _____ types in Python, a collection of values in which the order is significant
sequence
72
for sequence types in Python, the order of the collection of values is significant, true or false?
true
73
a list (array in other languages) instance stores a sequence of objects, true or false?
true
74
a list (array in other languages) is a _____ structure, as it stores a sequence of _____ to its elements
referential reference
75
['red', 'green', 'blue'] in this example, the list contains three _____ instances (also known as objects)
string
76
set
a collection of elements without duplicates and without an inherent order to those elements
77
a set is a collection of elements without _____ and an _____
duplicates order
78
an advantage of a set over a list (array in other languages) is that it has an optimized _____ for checking whether a specific _____ element is contained in the set
method element
79
a set uses a hash table as its underlying data structure, true or false?
true
80
a set uses a _____ _____ as its underlying data structure
hash table
81
short-circuit
the compiler skips the execution or evaluation of a sub-expression in a logical expression (also known as a boolean expression)