Python challenges 12-14

This commit is contained in:
newt 2024-10-09 18:02:28 +01:00
parent 8d9ef15107
commit 05b41d6659
12 changed files with 36 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View file

@ -0,0 +1,3 @@
data = open("evil2.gfx", 'rb').read()
for i in range(5):
open('{0}.jpg'.format(i), 'wb').write(data[i::5])

View file

@ -0,0 +1,7 @@
import xmlrpc.client
connection = xmlrpc.client.ServerProxy('http://www.pythonchallenge.com/pc/phonebook.php')
print(connection.system.listMethods()) # methods
print(connection.system.methodHelp('phone')) # what does phone do?
print(connection.system.methodSignature('phone')) # takes a string, returns a string
print(connection.phone('Bert')) # italy!!!

View file

@ -0,0 +1,23 @@
from PIL import Image
img = Image.open('wire.png')
print(img.size) # the real size is actually 10000x1, not 100x100
out = Image.new('RGB', (100, 100))
delta = [(1, 0), (0, 1), (-1, 0), (0, -1)] # spiral!
x = -1
y = 0
p = 0
d = 200
while (d / 2) > 0:
for v in delta:
steps = d // 2
for s in range(steps):
x = x + v[0]
y = y + v[1]
out.putpixel((x, y), img.getpixel((p, 0)))
p += 1
d -= 1
out.save('level14.jpg')

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -29,3 +29,6 @@ Here you can find a bunch of random work from my GCSE Computer Science class dum
- [9 - Good](python/pythonchallenge.com/9%20-%20Good.py)
- [10 - Bull](python/pythonchallenge.com/10%20-%20Bull.py)
- [11 - 5808](python/pythonchallenge.com/11%20-%205808.py)
- [12 - Evil](python/pythonchallenge.com/12%20-%20Evil.py)
- [13 - Disproportional](python/pythonchallenge.com/13%20-%20Disproportional.py)
- [14 - Italy](python/pythonchallenge.com/14%20-%20Italy.py)