<b>loops</b><br/>
for x in range(10):
print ("hello python")
print (x)
x = 1
while x<10:
print (f"x is {x}")
x = x + 1
<b>.random</b><br/>
words.sort()
words = ['weaving', 'with', 'words', 'and', 'code']
# First a simple loop through the list
for word in words:
print(word)
# Then, a loop in which we start to play with random again
import random
for word in words:
print(random.choice(words), random.choice(words), random.choice(words), random.choice(words), random.choice(words))
# How to work with more iterations of the loop?
# For example 100?
# You can use "range"
range?
# Make a loop that starts at 0 and ends at 99 (100 iterations)
import random
for number in range(100):
print(random.choice(words), random.choice(words), random.choice(words), random.choice(words), random.choice(words))
# You can use range also differently, for example to loop in between two numbers ...
for number in range(50, 60):
print(number, 'x'* number)
# ... or with bigger steps:
for number in range(0,100,10):
print(number, '*'* number)
# Now... write a loop in a loop
for x in range(1,6):
for y in range(1,6):
print('x'* x, 'y'* y)