Codes for quilting

From XPUB & Lens-Based wiki
Revision as of 13:31, 22 October 2020 by Naaami (talk | contribs) (→‎Pattern making practice)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Basic

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)

Pattern making practice

#1

width = 100
height = 10
for y in range(height):
    print('-/' * 50)
    print('|' * width)
-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

#2

# Let's continue a bit with this "canvas-mode" of working, 
# and let's bring the random function to the table again.

# In order to slowly build a canvas of characters, 
# we will use a variable (called 'line' in this case) to temporary save our line ...

import random
characters = ['░','▒','▓','▉','▚','▞']
width = 50
height = 30
line = ''
for y in range(height):
    for x in range(width):
        line += random.choice(characters)
        #print(random.choice(characters))
    print(line)
    line = ''
▚▉░▞▉▞░░▓▞▓▓▞▚▓░▓▉▚▉░▚▞▚▒▞░░░▞▒▓░░▞▒▓▒▞░▓▚▉░▚▚▚▉▞▒
▚▚▓▚▞▒░▞▉▉▉▉░░▓▉░▓▉▚▒▞▚▞▞▞▒▒▚▞░▒▉▚▞▉░▓▒▓▉░▓▚▉░▚▚▓▉
░▞▒▒░▒░▒▚▒▓░▚▉▚▉▚▓░░▚▞▚░▓▒▞▉▓▒▒▒▓▞▓▓▉▓▒▚▓▉░▚▞▚░▚▓▚
▒▉░▉▞▒▞▒▞▚▞▒▉▚░▉▞▚▞░░░▓▉▚▞▞░▞▓░░▞▓▒▉▉▓░▞▚▒▒░▒▓▉▞▓▚
▒▉▚▉░▒▒▒▓▓▉░▓▉▞▓▉▚▒▉▚▉▚▒▞▉▚▉▉▞▚░▞▚▞▓▚▚▓▞▓░▒▒░▞▚▓░▉
▚░▓░░▞▒▞░▞▉░▞▉░▉▚▓▚▉░▚▚▒░▓░▉▞▒▓▒▞▚▚░▉▓▚▚▓▓▉▉▉▞▒▉▉▒
▉▚▚▞▞▓▒▉░▉▚▓▓░▓▉▚▚░▓▒░▉▒▒▚▒▚░░▒░░▓▓▉▞░▉▒▞░▒▓▓▉▒▓▚░
▉▓░░▉▓▞▞░▒▞░▉▉▞▓▓▚░▚▞░▞▉▉▉▞░▉▚▉▞▒░▚▒▚▒▞░▞▞▉▒▞░░░▞▚
▚▉▓▓▒▉▒▉▉▞▞▞▉▉▉▞▓▓▒▓▉▉▒▒▚▉▓▚▞▓▚▒▚▒▞▒▞▒▓▓░▓▉▓░░▉▉▒▚
▓▚░▉▓▉▓▒▞▞░▓▓░▓▞▓▉▒▞░▞▞▚▚▒▒▚▓▚▓▞░▓▓▚▓░▓▓░░▞▞▞░▉▉░▓
▞▒▉▓▓▉░▓▚▓▓▉▉▚░░▉▞▉▓░▓▒░▉▓░▉▒▞░▓▉▞▉▚▓▞▒▒▉▞▓▞▉▉▓░▉▚
▞▚▚░▉░▉▓▞░░░▒░▒▒▞▞▞▚▓▓░▞░▚▉▞▚▒▉░▉▒▉▚▒░▚▒▚▞▓▉▉▞▓▒▞▓
▓▒▓▚▞▓░▚▚▓▚▉▚▉▚▒▒▚▞▚▒▓░░░▚▉▚▚░▓▒▚▓▓▓▚▒▉▚▚░░▒▞▞▉▚░▞
▞▚▓▚░▞▒▓▉░░▒▒░▉▉▒▚▓▒▞▒░░▒▚▉▒▒▉░▒▒▞░▉▒▒░░▉▚▚▉▞▓▚▞▒▓
▒▒▒▓░▒▞▒▉░░▓▉▞▒▒▓▞▉▉▚▉▓▚░░▉▓▚▚▉▚░▉▉▞▉▚▉▚▚░▒▒▉▓▚░▒▞
▚▞▒▒▒▉▓▞▓▉░▓▒░▒░▚▒░▒▒▚▚▉▓▉▚░░░▞▚▉▒▚▒▓░▞░▞▞▒▚▞▚▞▓▓▓
▉▉░▓░▉▓▞▓▒▉▒▒▚░▉░▞▞▞░▚░▒▓▉▓▉▉░▚▒▉▚▞▓▉░▉▒▉▓▞▞▚░▓▞▉░
▓▞▓▓▉░▓▓▉▓▚░▓▓░▓▉▚▒▒▉▚▓▉░▞░░▓▓▉▒░▚▓▓▉▉░░▉▚▞░▓▚░▓▞▞
▞▒▚▒▉▓▞▞░▉▒░▚▞░▒░▞▞▉▉▒▒▚▉▚░▞░▉▓▓▓▒▒░▓▉▞▉▉▚░▒▚▒▓▓▒▞
▚▞▓▞▞▒▒▒▒▚░▞▓▞▞▒▚▚▓▓▚▓▒▚▉▚▚▒▚▚▞▒▓▞▒▞▒▓▉▚░▒▞░▉▓▓▓▓▒
▉▉▓▓▉▒▞▒▒▒░▞░▓▒▉▉▞▓▉▚▚▒▞▚▒▓▒▞▓▞▞▓▓░░▒▒▓▚▒▉▓░▉▞▚▒▒▒
▉░▓▒▓░▞▚░▞░▉▒▚▓▚▞▞▚▒░▞░▒▒░▉░▉▒▞▞▉▓▚▉▒▞▞▞▚▓▉▉▉▓▞▒▉▉
▉▉▓▉░▚▓▞▞░▞▒▞▉▓▚▞▚▒░▉▞▉▓▞▉▚▞▒▉▒▚▞▚▞▉▓▓▞▚▞▞▓░▓▒▒▉▉▒
▒▚▓▒▚▓▓▞▒▚▒▉▚░░▞▒▚░▉▚░░▞▒▚▒▚▞▞▓▓░▓▓▚░▒░▚▓▓░░▉▓▓▉▚▞
▚▉▚▉▚▓▒▉░▉▚▉▉▓▞▞░▒░▓▚▚▉▒▚▓▉░▒░░▒▉▞▒▒▉░▉░▞▓▉▞░▒▚▒▉▉
░▚▒▚▉▉▚▒▞░▞▞▒▒▉▉▓▓▚▉▉░▚▉▉▒▉▉▉░▒▚▒░▓▉▉░▉▓░▚░▒▒░▉▓▓▓
▞░░▓▓▒▚▞▚▒░▚▚░▉▚▚▒▉▉▚▓░▓▓░▞▒▓▚▉▉▞▞▒▉▒▒▞░▓▞▓▚▚▚▒░▞▞
░▒░▉▞▚▞▉▚░▉░▉▒▓▉▓▚▓▞▉▚▞▚▚▚▉▉▚▓░▞▞▞░▚░▞▒░▞▒░▚░▉░░▓▒
▚▓▞▒▓▚░▉▓▒░▉░▓▒▓▚▉░▓▚▚▉▓▞▞▉▉▞▉▚░▞░▓▓▉▞░▚▚▓▒▚░▚▉▒▒▓
▒▓▓▉▒▓▞░▉▒▉▓▒▒▉▓▓▉▚▚▒▉▓▉░▞▉▉▞▞▒▉▒░▒▉▚▒▒▚▒▚▞░▓▒▉░▉▚

#3

 
import random

moons = ['🖐','✋','🖖','🤟','🤘','✊','👊']
width = 50
height = 30
line = ''

for y in range(height):
    for x in range(width):
        line += random.choice(moons)
    print(line)
    line = ''
✊🤘🖖🤟🤟🖐✊✋👊✋✋🤘🤘🤟✋🤟✋✊✋👊🖐✊👊✋✊🖖🤘🤘🤟✋🤘🤘🤟🖐✋🖖👊👊🤘🤟🤘🖐👊✊👊🖐✋🖐✊🖐
👊✋🖐🤟✋🖐🤟🖖🖐🤘🤟🖐👊🤘🤟🖖👊✊🤟✊👊✊🖐✋🤟🖐👊🖖✋🖖✊✊🤘🤟👊🤘👊🖐🤟🖖🖖✊🤟✊🖐🖖🤟✊✋🤘
✊👊🖖🖖🤘🖐✋✋🤘🤟✊🖐🖐🤘🤘👊👊✊✊✊✋🖐🖖🖐🤘✊🖐👊✊🖐✋🖖✋✋🖐✋👊🤘🤘🤟🖐🤘✊🖐🖐🤘🤘🤟👊🖖
🖐👊🖖✋🤘✋✊🖐🖖🖖👊🖖🤟🤘🤘🤟🤘🖐👊🤟🖐🤟✋✋👊🖖👊🖖🖐🖖🤟👊👊✊✊🖐🤟🖖✊🖖🖐✋🖐✊🖐✊👊✋🤟✋
🤘🤘🤟🤟👊👊🤘🤟✋👊🤟🤘🖐👊🤟👊✊🖖🤟🖐🤘🤟✋🤟🖖🖖🖐🤟🖖✋🖐🤟✊🖐🖖✊🖐🤟✊🖐🤟✋🖐✋👊✋✋🖐🖖🖖
🤟🤟🖖🖐🖐✋🖖👊🤘🤘🖐🖖👊✋🤘🤘👊🤘✋✋🤘✊🖐👊🖖🖐🤘🤘🤘✊👊🖐👊🖐✋✊🤟✊✋🖖✊🤟🖖🖐🤘🤘✋🖖🖖👊
🖖🖐🖖🤟🖐🤟🖖✋✊✊🖐🤟🖖🖖🤟🖖👊🖐👊🤘🖐🤘🤘👊✋✋🖐✊🤟🖐🖖🤟✋🤘🤘✊✋👊✊🤟🤘✋🖖🖐🖖✊🖖🤘🤟🤘
🤟👊🖖✊🤘✋🤟🖐🤟🖐✊🖖🖐✊✊🖖🖖✊🤘🖖🤟🖐🖐👊🖐✋🤘✋✋🤟🤟🖐🤘🖐🤟🖖👊✊✊🖐🤘🖐🤟👊🖐🤘🤟🖖🖐👊
✋✋🤘✋🖐✊🤘✊🤟🖖✋🤟✋✊✊✊🤘🖖🖐🖐✊👊👊🖖🖖✊🖐🖐👊🤟🤟🤘✊✊🖐🤘🤟🤟✊🤟🤟✋🤟🖖🖐✊✊✊✋👊
👊🤘🖐✋✊🖖👊👊🤟🤘👊👊🖖✋👊🤘🤟🤟🖖🤟✊✋🤟👊🖖✋✊🖖🤘✊✊👊🤘🤘🤟🤘🤟🤟🖖👊🖖✋✊🖐🖐✊🖖🤘👊✋
🤟👊✊🖖👊🖖✋🖐👊🤘🖐🤘👊✋👊🖖👊👊🤟🖐🤟🤟🖖👊🤟🤟👊✋✊✋🤘🤘🤘👊🤘🤘🖐🖐🤘👊🤘👊🤘👊🖐✊✋🖖✋👊
🤘✋🤘✋✋🖐🖐🤘✋✊✋🤘🖐🤘🖐🤟🖐🖖✊🖖🤟✊🤟🤘🤟🖖🤟✊👊✋🖐🤘👊🤟🤟✋🤟🤘🖖🖖👊🖖🤟👊👊✋🖖🖐🖐🤟
🖖🖐🖐🖖🤘🤘🤟👊🖐🖐✋🖖✋👊🖖🖐🖖👊✊🤟🤘🖖🤘✊👊🖖✊✋🖖👊✋🖐✋✊🤟🖐🤟✋✋🖖🤘✋🖖✊✋✊🖖🖐🖐🤟
✊✋✊✋🖐✋✊🖐🖖🖐✊✋✊✊🖖✊🤟✊✋🤟👊🖐✊🖖🤘✋🖖🖖🤟👊👊🖖🖖🤟🖐🤟✊✋🖐🤟✊👊✋🤘🖖👊🤟✊✋🖖
👊✋🤘✊🤟🖐🤘🤘👊👊🖐✊🖖🖖✋🤘🤘✋✋🖐🤟🖐🖐✊✋✊✋✊🖖👊👊🖐🖐🖖✊👊👊✋✊🖐✋✊🤘👊🤘🖐👊👊✋🖐
🤘🖐✊🤘🤘🤘✊🖖🤘✊🖖🖖✊🤟✋🤟✋🤟🖖✊🖐✊🖖🖐🤟🖐👊🖖🤘✋🖖✊🖐👊✋✊👊🤘🖖🤟✋🤟🤟🖐🖖✋🖖✊✋🖖
✋✊👊👊🤘🖖🤟🤘👊🤟✋🖖🤘🖐👊🤘✊✋✊✊🖖🤘🖐🖐👊🖐👊✋👊🤟✋🤟🤟👊🖖🤘🖐✋🤟👊🖐🤟✋🖖✊🤘🖐👊✊✋
🤟👊🤟✊🖐✋🖐✋✋✋🖖🖖🖖✋🤘🤟✊🖐🤘✊✊🤟👊🖐🤘✊🤟🖖✋🖐🖐🤘🤘🤟🖐✊🤟🖖🤟✊🤘✋🖐🖖🤘✊🖖✊🤟🖖
✋🖐✋✋✋✊🖖🖖👊🖐🖖✋🤟🤘🤘🖖🖖🖖🤘🤘🖖🤘✋✊✊🖐🤟🤘✋🖐🤟🤘👊🖐🖖🖐🖖🖖🖖🖐✊✊✋✊🤘🤟🤘✊👊✋
🤘🖖🖖✊🤘🤟✊🤘✋🤟🖖🤘✊🖖🖐🖖🖖✊✋🖐✋👊🤘🖖👊🖖🖖✊🖖🤘🖐👊✋🤘🤘👊🖐🤟✋✊🤟👊🤟🤟🖖👊🖖🤟✊🖖
🖖✊✋✋🤟🖐🤟✋👊🤟🤟✋🤘✋🖖🤘🤘👊👊✋👊✋🖐✋🤘✊🖖🖐🖖✊👊👊🖐✋🤟🤟✊✊🖐✊🖖✋🖖✋✋🖐👊🤟🤘🤟
🖖🤟🤟🖖✋🤟🖐✊🖐👊🖐🖐🖖🤘🖖✋🖖🤟🤟🖐✋🤟🖖🤟✋🖖🖖✊✋👊✋🤟🖖👊🤘🤟🤟🖖🖖👊✊🖐🤟👊✊🖖🖐🖖👊🤘
🖐🤘🤘🖖🖖🖐🖐👊🖖✋🤘🖐👊🖖🖖🤟✋👊🖖🤘🖖🤘✋🤟✊🤘👊🖐🖖✊✊🖐👊🤟👊🤘🖐✊👊👊🤘👊🤟🤘🤟✊✊🤟🤘🤘
🖖✊🤟🤟👊👊🤘🖐🤘🤘✋🤟🖐✊✊🖖🤟🖖🖖✋🤘🖐🖖👊✊✊✋🤘🖖🖖🖖✋✊✊🖐🖖🖐🤘🤘👊👊✋🤟🖖✊🤘✋✊🖖🤟
🤟🤘🤟✊🤟🤘✋🤘🤘🖐✋✋✋✋👊🤟✋✊✋🤘🖖✋✋🖐✊🤟👊🤟✊✋✊👊🤘🤘🤟🤘🤟🖐🖖🖖🖐🤟🖖✊✊🤘🤟🤟🤟👊
🖐✊🤘🖐👊🤘🤘🤟🤟✋✋🖖🖐🖐🤘🤘🖐🖐🤘✋🤟🖐🤟✊🖖✊🖐✋👊🖖👊🖐✋🖐✊🖐✊✊✋🖖🤘🖐👊🤘🖐🤟✊👊🤘🤟
🖖✋👊🤘🤘✋🖖🤟🤘🤟👊🖐🖐✋🤘🖖🖐✋🤟✊✋🤟🤟🖖👊🤘🖐✊🤟🤟🤟🖖🖖✋✋🤟🖐🤟🖐🤘👊👊🖐🤟✋✋🖐🖐✋🖖
🤟🤟🖐🖐👊👊🤟✊👊✋👊✊🤘✊✋🖐✋🖖🤟👊✋✊✊🖐👊🖐🤘✊🤘👊👊🤘✋🖐✊✊✋✋👊🖐🤟✋✊👊🖖✋🤘🖐🤘👊
🖐🖖👊🤟✊🤘🤟🤘🤘✋🤟🖐🤟✋✋🤟🤘🖐👊👊🤟👊👊✊✊✊🤘🤘✊🤘✋✊🖖🖐🖐🖐🖖🖐🤘✊🤘🖐🤘✋👊🤟✋✊✋🤘
🤟🖖✋🤘🖖👊✊🖐👊✊👊🤟✋🖐🖖✋🤘🤟🤘👊🖐✊🤘🖖🤘🖖✋👊👊🤟✊🤟🤘✊🖖🖐🖖🤟🤘🖐🤘🖖👊🤟🖐👊🤟🤟🖖🖐