Python key terms Flashcards
memorise and learn the key terms of programing in Python
What is a ‘statement’?
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.
What is a ‘string’?
A string is a data type collection of characters, e.g. a word.
How are strings represented in Python?
Sequences of characters inside single or double quotation marks.
What is a ‘float’ or floating point number?
A number with a decimal.
What is a “variable”?
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.
What is an “operator”?
A symbol or keyword that tells the computer to perform a specific action on one or more pieces of data.
What is an argument?
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”)
What is a “conditional statement”?
A block of code that is only executed if some condition is met. An ‘if’ statement for example.
What is a “block”?
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.
What is an ‘Expression’?
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”.
What is “syntax”?
Syntax is how the code should be written. If the syntax is wrong, the program wont run correctly if at all.
What is ‘debugging’?
When a program doesn’t run as anticipated, debugging is checking for errors in syntax or the code.
What symbol is used for commenting in Python?
The pound / has symbol #
What are the rules for naming variables in Python?
Begin with a letter or underscore, contain only letters, numbers, and underscores. Case-sensitive
What is a ‘function’?
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 does Python recognise a block of code?
By consistent indentation (usually a tab or spaces).
What is a data type?
The category or kind of value an object has, like integer, string, or list.
What does the + operator do with strings?
It joins them together / concatenates them
How do you check the data type of an expression?
use the type() function
What’s the difference between a statement and an expression?
Statements perform actions, expressions produce values.