Python Coding Flashcards
What type of language is python?
High-level programming language. Easy for humans to read, write and maintain but code is slower to run.
What is a statement?
Complete computer command.
What does an expression do?
Evaluates to the new value. e.g. 2*2
What does the function print() do?
Outputs and displays text in terminal.
What do variables do?
Stores values (not expressions) using assignment operator =. Variable names should describe stored data.
What are the different data types variables can store?
Int (whole no.), floats (decimal no.), strings (text)
What is the symbol and advantage of using multi-line strings?
”””
Anything between the “triple quotes” is part of the string including quotes, new lines and tab.
“””
What is a string concatenation?
Combing string values using the + symbol (joins w/o spaces).
What is the function of input()?
Assign user value as a variable. Prompt message printed beforehand.
What type of data is user input and what are some problems that may arise?
User input is entered as strings, therefore, calculations cannot be made. Must be converted to int.
What is the control flow and what does it allow us to do?
The sequence in which a program’s code is executed is regulated by conditional statements, functions and loops. Allows alternative courses of action to be taken depending on the occurrence of an event.
What is a Boolean expression?
A statement that is true or false (whether or not it’s a fact).
What is an if statement used for?
Simple decisions.
What is an if-else statement used for?
Two-way decisions that describe what we want to happen if condition(s) are not met.
What is an if-elif-else statement used for?
Multi-way decisions that check for another condition after the statement.