A dummy variable is anything you want to use to replace the object. For python to recognize the for loop you will need to indent the statements within the for loop.
We need to have at least one condition to implement the loop and make sure we don't get an infinite (or endless) loop. Be sure to indent the statements to repeat in the loop.
Sometimes while loops are more necessary and sometimes for loops are more necessary. In general, for loops are used when you know exactly how many times you plan to run a loop; a while loop is used when the number of iterations is uncertain.
An if statement is a conditional statement that does something if the condition you set is met.
if Condition:
do thing here
elif Condition
do thing here
else
do thing here
An if/else statement can have many parts. If the first condition isn’t met Python moves on to the elif(else if) statement and if no statement works. Indents are still required to use if statements.
def functionName(parameter1, parameter2, ...):
do things here
return(output)
The parentheses contain what are called parameters. These are the variables that are input into the function that contribute to the final output. Parameters are not always required; depending on the function, they can include anything from integers and strings to other functions. Let us create a simple area calculating function to get used to the syntax.
501 E. High Street
Oxford, OH 45056
1601 University Blvd.
Hamilton, OH 45011
4200 N. University Blvd.
Middletown, OH 45042
7847 VOA Park Dr.
(Corner of VOA Park Dr. and Cox Rd.)
West Chester, OH 45069
Chateau de Differdange
1, Impasse du Chateau, L-4524 Differdange
Grand Duchy of Luxembourg
217-222 MacMillan Hall
501 E. Spring St.
Oxford, OH 45056, USA