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

Give 3 examples 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
Q

Keywords are __ words that have __ meaning in Python.

A

reserved, special

26
Q

Keywords can be used as identifiers.

A

False. They can’t be used as identifiers because keywords are reserved words.

27
Q

Types of keywords can be…

A

flow control, data types, classes and objects, and modules and packages.

28
Q

Examples of keywords.

A

if, else, for, while, def, class, import, try, except.

29
Q

Identifiers are names…

A

given to variables, functions, classes, and modules.

30
Q

__ starts with a letter or an _ and can contain letters, __, or __.

A

Identifiers, underscores, numbers, underscores

31
Q

Identifiers must begin with…

A
  1. A letter of the English language
  2. A non-English letter (a or π)
  3. Underscore
  4. Dollar sign
32
Q

Identifiers can begin with a digit.

A

False.

33
Q

What casing convention does Python follow?

A

snake_case.

34
Q

Describe snake_case.

A

It is where all words are lowercase and separated by an underscore.

35
Q

snake_case is used for…

A

variables, function, and modules.

36
Q

What casing convention do class names use?

A

PascalCase/UpperCamelCase.

37
Q

Describe PascalCase.

A

It is where several words are joined together, and the first letter of every word is capitalized.

38
Q

Describe PascalCase.

A

It is where several words are joined together, and the first letter of every word is capitalized.

39
Q

Literals represents…

A

constant values.

40
Q

Literals can only be strings.

A

False. Literals can be different data types (i.e., numbers, strings, etc.)

41
Q

Literals cannot be “none”.

A

False.

42
Q

“None” represents…

A

the absence of values.

43
Q

They are symbols used to perform operations on values.

A

Operators.

44
Q

Delimiters are characters used to…

A

separate different parts of a Python program (e.g., “()”, “{}”, etc.).

45
Q

These start with a “#” for single lines, or “ “’ “ for multiple lines.

A

Comments.

46
Q

Comments are texts…

A

ignored by the Python interpreter.

47
Q

It is a token used to explain code or provide documentation.

A

Comments.

48
Q

This defines how a class can be accessed.

A

Access specifier.

49
Q

It is a crucial aspect of the language’s syntax and is used to define code blocks and control the flow of execution.

A

Indentation.