data = []
twice = []
# Calculation and result
for index in range (0, 10) :
data.append(index)
twice.append(2 * index)
print (data)
print (twice)
data = []
twice = []
# Calculation and result
for index in range (0, 20) :
data.append(index)
twice.append(2 * index)
print (data)
print (twice)
BIG_NUMBER = 10 * 10
index = 1
# Calculation and result
while (index < BIG_NUMBER) :
index = index * 8
print ('%d' % index)
FIRST_PART = 7
LAST_PART = 5
ALL_PARTS = FIRST_PART + LAST_PART
# Calculation and result
print ('The square of all the parts is %d' % (ALL_PARTS * ALL_PARTS))
for i in reversed (range(10)) :
print ('Hi there')
size = 10
fudge = size - 2
# Calculation and result
size = fudge
print ('Size is %d' % size)
import sys
value = 1
# Calculation and result
if (value < 0) :
sys.exit()
print ('We did not die')
def SQR (x) :
return x * x
for counter in range (0, 5) :
print ('x %d, x squared %d\n' % (counter + 1, SQR (counter + 1)))
counter = 0
# Function declaration, calculation and result
def SQR (x) :
return x * x
while (counter < 5) :
print ('x %d square %d\n' % (counter + 1, SQR (counter + 1)))
counter += 1
def reciprocal (number) :
return 1 / number
for counter in range (1, 10) :
print ('1/%f = %f\n' % (counter, reciprocal (counter)))