| concept |
parameters |
algorithm |
python |
| New Variable |
name: what to call it |
create a variable called
name of type
type
with initial value initVal
|
name initVal |
| type: type of data |
| initVal: starting value |
| output |
message: text to write |
output the text message |
print(message) |
| input |
variable: where answer will be stored |
ask the user message and
store result in |
variable = input("message") |
| message: question being asked |
| Convert to integer |
oldVariable: in a non-integer format |
convert oldVariable to integer
and store in intVariable |
intVariable = int(oldVariable) |
| intVariable: integer to hold results |
| branch |
condition: true / false value |
if condition is true, execute
code |
if condition:
code |
| code: one or more lines of grouped code |
| for loop |
sentry - integer variable to control loop |
begin with sentry at start and
add change to sentry on each pass until
sentry is larger than or equal to finish |
for sentry in range(start, finish, change):
code to repeat
|
| start - integer starting value |
| finish - integer ending value |
| change - integer to add each pass |
| while loop |
sentry - variable to control loop |
initialize sentry with initialization code then continue
loop as long as condition is true. Inside loop,
change sentry with change code |
initialization code
while (condition):
code to repeat
change code
|
| initialization code - code to initialize sentry |
| condition - loop will repeat if condition is true |
| change code - code to change sentry so condition can become true |
| function |
functionName - the name of the function |
create a function called functionName passing the values
parameters that returns a value of return type |
def functionName():
code
return something |
| return type- type of data function returns. Could be nothing |
| parameters - one or more values to send to the function |