Which of the following are not used in expressions
For loop scenario question
#A simple program illustrating chaotic behavior where there are two numbers input and results displayed #in a column format
# Dr. Tonya Pierce
def main(): #This is the function definition. Every program you write will have a main function definition. #The purpose of this function is to start the program and provide the flow of the overall function. We will #discuss this further at a later date. For now, make sure you include a main function definition in every #program.
print("This program illustrates chaotic behavior")# This is an output statement. The items in quotes #are literal values. This means the program will print literally what is in the quotes.
x = eval(input("Enter a number between 0 and 1: "))#These are input statements. Again, what is in #quotes will be literally displayed to the user. Here you are providing instructions to the user to tell them #what they are to input. The input outside the parentheses tells you that you are asking for input. The #eval is used to tell Python that you are expecting a numeric value. All input is treated as alphanumeric. #The eval tells it to convert it to numeric. The eval is only used if you are expecting numeric values that #you expect to perform calculations on.
y = eval(input("Enter a number between 0 and 1: "))
for i in range(10): #This is your for loop. Notice that everything that is part of the for loop is indented #under the for loop.
x = 3.9 * x * (1-x)#These are your calculations
y = 3.9 * y * (1-y)
print(x," ",y)#This is your output. Notice the spacing between x and y. Simply adding #spaces will not work, as Python will ignore the spaces, unless you put those spaces in quotation #marks, and then it will become a literal. Also notice that this is not indented under the for loop but is #indented under the def main() function. This is because the output is part of the main definition but #not part of the loop.
main()#This is the call to function statement. This is saying to now implement the main definition that #was previously defined. Notice that it is left-aligned under the main definition. This is because it is not #part of the main definition. Notice that everything that is part of the main definition is indented under #the main definition.
- A counted loop is designed to iterate a specific number of times.