Python Programming Flashcards
What is an algorithm?
An algorithm is a step-by-step procedure, which defines a set of instructions to be executed in a certain order to get the desired output
What is the purpose of a python algorithm?
Python algorithms provide a detailed set of instructions by which you can process data for a specific purpose.
What are variables and what are some types?
They are containers for storing values. Some types include text and number variables.
What are integers?
Whole numbers.
What is ‘float’ in Python?
A number that isn’t whole (eg - 2.3).
What are the rules of text variables?
Must begin with a letter
Contain only letters and numbers or underscores but no other symbols
Must not be commands, e.g. PRINT is not a valid variable
Must not have any spaces
Cannot start with a number
What does the ‘print’ command do?
Prints a specified message onto your screen.
How do you add things together in Python?
Use +.
Example: 786 + 110
How do you subtract in Python?
Use -.
Example: 14 - 12
How do you multiply things together in Python?
Use *.
Example: 5 * 124000
How do you divide in Python?
Use /.
Example: 786 / 110
How do you write powers?
Use the command pow(number, number)
Example: pow(5, 622)
How do you use square root and pi and Python?
First, you must write the code import math. Then you can write math.sqrt or math.pi
Example: math.sqrt(100)
What is the greater than sign in Python?
>
What is the less than sign in Python?
<
What is the greater than or equal to sign in Python?
> =
What is the less than or equal to sign in Python?
<=
What is the equal to sign in Python?
==
What is the not equal to sign in Python?
!=
What does the if statement mean in Python?
If a condition if true, then do this.
What does the elif statement do?
The elif keyword is Python’s way of saying “if the previous conditions were not true, then try this condition”
What does the else statement do?
The else keyword catches anything not caught by the previous conditions.