3. File construction¶
Lines that start with “#” are called comments
They are intended to be read by humans and Python ignores them
Python skips all text from the “#” to the end of the line
# File chaos.py
# A program that illustrates the Chaos Theory
x
is an example of a variableWe will assign a value to
x
that can be referred to laterThe message in quotes will be displayed and the response will be stored in
x
x = eval(input("Enter a number between 0 and 1:"))
There are loop or cycle commands such as the
for
commandA loop or cycle is used to repeat a block of code several times
In this example, the following block will be repeated 10 times
for i in range(10):
We call indentation to the spaces at the beginning of the line
In Python, indentation delimits the block that will be executed
The calculation
3.9 * x * (1-x)
will be performed on the CPU and assigned to the variablex
You have attempted of activities on this page