Python key terms Flashcards

memorise and learn the key terms of programing in Python

1
Q

What is a ‘statement’?

A

A single line of code that tells the Python interpreter to do something.
A program is composed of one or more statements executed in a specific order.

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

What is a ‘string’?

A

A string is a data type collection of characters, e.g. a word.

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

How are strings represented in Python?

A

Sequences of characters inside single or double quotation marks.

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

What is a ‘float’ or floating point number?

A

A number with a decimal.

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

What is a “variable”?

A

A ‘variable’ is a name used for a container or location for storing data for use later. It’s defined with an ‘=’, for example ‘variable = “This”’. It can contain a string, float or int.

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

What is an “operator”?

A

A symbol or keyword that tells the computer to perform a specific action on one or more pieces of data.

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

What is an argument?

A

An argument is the input data passed into a function when it is called / used, allowing the function to operate on that data. e.g. print (“this is an argument”)

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

What is a “conditional statement”?

A

A block of code that is only executed if some condition is met. An ‘if’ statement for example.

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

What is a “block”?

A

A section of code that is all run as one, indented to the same level. For example following an ‘if’ statement that evaluates to true, then run the rest of this code, otherwise, go on to the next part.

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

What is an ‘Expression’?

A

An expression is a combination of values, variables, operators, and function calls (i.e. code) that ‘evaluates’ to a single value. e.g. x+5 or “hey” + “you”.

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

What is “syntax”?

A

Syntax is how the code should be written. If the syntax is wrong, the program wont run correctly if at all.

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

What is ‘debugging’?

A

When a program doesn’t run as anticipated, debugging is checking for errors in syntax or the code.

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

What symbol is used for commenting in Python?

A

The pound / has symbol #

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

What are the rules for naming variables in Python?

A

Begin with a letter or underscore, contain only letters, numbers, and underscores. Case-sensitive

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

What is a ‘function’?

A

A named, reusable unit of code that performs a specific task and can optionally return a value. e.g. len(), or print(). A sequence of statements

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

How does Python recognise a block of code?

A

By consistent indentation (usually a tab or spaces).

17
Q

What is a data type?

A

The category or kind of value an object has, like integer, string, or list.

18
Q

What does the + operator do with strings?

A

It joins them together / concatenates them

19
Q

How do you check the data type of an expression?

A

use the type() function

20
Q

What’s the difference between a statement and an expression?

A

Statements perform actions, expressions produce values.