Basics of Python and Tokens Flashcards

1
Q

What are the 6 basics of Python?

A
  1. Variables and data types
  2. Operators
  3. Control flow
  4. Functions
  5. Modules
  6. OOP
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the 7 data types?

A
  1. Numbers/numerics
  2. Strings
  3. Lists
  4. Tuples
  5. Dictionaries
  6. Sets
  7. Booleans
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the ordered data types?

A
  1. Numerics
  2. Strings
  3. Lists
  4. Tuples
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the unordered data types?

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

It is a scalar/primitive data type.

A

Booleans.

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

Lists are an ordered collection as well as a __ collection.

A

sequence

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

Tuples are __ collections and are __.

A

ordered, immutable

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

Dictionaries are __ collections of __-__ pairs.

A

unordered, key value

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

Give an example of a key-value pair.

A

“Name: “ “Alice”

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

Sets are __ collections of __ elements.

A

unordered, unique

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

What values are in a boolean?

A

True or false.

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

The 3 operators.

A
  1. Arithmetic
  2. Comparison
  3. Logic
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

3 examples of arithmetic operators.

A
  1. //
  2. %
  3. **
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does the arithmetic operator // do?

A

It takes the greatest integer of a quotient.

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

What does the arithmetic operator % do?

A

It takes the remainder of a quotient.

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

What does the arithmetic operator ** do?

A

It indicates an exponent.

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

== is a __ operator used in __ operations.

A

comparison, conditional

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

Give 3 examples of logic operators.

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

Give 4 examples of control flow functions.

A
  1. if-else statements
  2. for loops
  3. while loops
  4. break and continue
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

3 processes of functions

A
  1. Defining
  2. Calling
  3. Returning values
21
Q

2 uses of modules.

A
  1. Organising code
  2. Importing modules
22
Q

4 characteristics of OOP.

A
  1. Classes
  2. Objects
  3. Inheritance
  4. Polymorphism
23
Q

Tokens in Python are the smallest…

A

unit of a program that has a specific meaning.

24
Q

What are the 6 categories of tokens?

A
  1. Keywords
  2. Identifiers
  3. Literals
  4. Operators
  5. Delimiters
  6. Comments
25
Keywords are __ words that have __ meaning in Python.
reserved, special
26
Keywords can be used as identifiers.
False. They can't be used as identifiers because keywords are reserved words.
27
Types of keywords can be...
flow control, data types, classes and objects, and modules and packages.
28
Examples of keywords.
if, else, for, while, def, class, import, try, except.
29
Identifiers are names...
given to variables, functions, classes, and modules.
30
__ starts with a letter or an _ and can contain letters, __, or __.
Identifiers, underscores, numbers, underscores
31
Identifiers must begin with...
1. A letter of the English language 2. A non-English letter (a or π) 3. Underscore 4. Dollar sign
32
Identifiers can begin with a digit.
False.
33
What casing convention does Python follow?
snake_case.
34
Describe snake_case.
It is where all words are lowercase and separated by an underscore.
35
snake_case is used for...
variables, function, and modules.
36
What casing convention do class names use?
PascalCase/UpperCamelCase.
37
Describe PascalCase.
It is where several words are joined together, and the first letter of every word is capitalized.
38
Describe PascalCase.
It is where several words are joined together, and the first letter of every word is capitalized.
39
Literals represents...
constant values.
40
Literals can only be strings.
False. Literals can be different data types (i.e., numbers, strings, etc.)
41
Literals cannot be "none".
False.
42
"None" represents...
the absence of values.
43
They are symbols used to perform operations on values.
Operators.
44
Delimiters are characters used to...
separate different parts of a Python program (e.g., “()”, “{}”, etc.).
45
These start with a "#" for single lines, or " "' " for multiple lines.
Comments.
46
Comments are texts...
ignored by the Python interpreter.
47
It is a token used to explain code or provide documentation.
Comments.
48
This defines how a class can be accessed.
Access specifier.
49
It is a crucial aspect of the language's syntax and is used to define code blocks and control the flow of execution.
Indentation.