Plutonic Rainbows

Copying Again

A simple script that just checks the file size and copies the file to a target destination that you specify. That’s done when you pass in script, file_from, file_to = argv at the very beginning.

from sys import argv

script, file_from, file_to = argv

file_in = open(file_from)
indata = file_in.read()


print "The file is %s in size.\n" % (indata)

file_out = open(file_to, 'w')
file_out.write(indata)

file_in.close()
file_out.close()

Functions in Math

I’ve been looking again at functions and how they work. They are great for simple math but can do a lot more besides. With that in mind, here is a simple way of multiplying numbers with user input. Remember to tell Python to use float when handling numbers.

def calc(value1, value2):
	return value1 * value2
	
print "\nLet's multiply two numbers.\n"	

value1 = (float(raw_input("Enter a number: ")))
value2 = (float(raw_input("Enter another number: ")))


answer = calc(value1, value2)

print "\nThe answer is {0:.2f}.\n".format (answer)

Another While Loop

As the title says, just another while loop for practice.

i = 0

numbers = []

while i < 7:
	print "The number at the top is now: %d" % i
	numbers.append(i)
	
	i = i + 1
	print "Numbers are now", numbers
	print "The number at the bottom is now: %d" % i
	
print "The numbers:"

for num in numbers:
	print num

Analyzing Cryptocurrency Markets using Python

Part of the Python Data Science Guide, this is a great introduction to Cryptocurrency. Recommended reading, if a little difficult to follow.

Patrick Triest:

The goal of this article is to provide an easy introduction to cryptocurrency analysis using Python. We will walk through a simple Python script to retrieve, analyze, and visualize data on different cryptocurrencies. In the process, we will uncover an interesting trend in how these volatile markets behave, and how they are evolving.

Manuscript decoded using Artificial Intelligence

Article in the Independent relating how text appears to be written in Hebrew with letters rearranged, according to algorithms employed by Canadian researchers.

Artificial intelligence has allowed scientists to make significant progress in cracking a mysterious ancient text, the meaning of which has eluded scholars for centuries.

Dated to the 15th century, the Voynich manuscript is a hand-written text in an unknown script, accompanied by pictures of plants, astronomical observations and nude figures.

Since its discovery in the 19th century, many historians and cryptographers have attempted to unravel its meaning - including code breakers during the Second World War - but none have been successful.

While some have written the Voynich manuscript off as a hoax, use of modern techniques has previously suggested the presence of “a genuine message” inside the book.

Math Functions 2

Some more math functions in Python. Make sure you use your # -*- coding: utf-8 -*- or the formatting will not work correctly.

# -*- coding: utf-8 -*-
def add(a, b, c):
	print "\nADDING %d + %d + %d" % (a, b, c)
	return a + b + c
 	
price = add(12, 12, 12);print "The price is £{0:.2f}\n".format (price)
 
def multiply(a, b):
	print "MULTIPLYING %d * %d" % (a, b)
	return a * b
 	
multiply_price = multiply(10, 10);print "The price is £{0:.2f}\n".format (multiply_price)
 
def subtracting(a, b):
	print "SUBTRACTING %d - %d" % (a, b)
	return a - b
 
subtract_price = subtracting(100, 50);print "The price is £{0:.2f}\n".format (subtract_price)

def division(a, b):
	print "DIVIDING %d / %d" % (a, b)
	return a / b

division_price = division(90, 2);print "The price is £{0:.2f}\n".format (division_price)

Books on A.I

Michele Baker gives a list of recommended books on Artificial Intelligence.

Sunday

Weather is very dark and gloomy with frequent rain. Not something that goes nicely with Easter. Still, there is plenty of chocolate. Been listening to the new music releases most of the weekend. There is a lot to get through. I’ll try and get back on the work & study program tomorrow.

Easter Weekend

It’s cold, wet and raining in my part of the world. So here’s some Python for converting Celsius to Fahrenheit.

# -*- coding: utf-8 -*-

x = float(raw_input("°C: "))

fahrenheit = x * 1.8 + 32

print "Fahrenheit: {0:.1f}°F".format (fahrenheit)

Staying indoors, I am listening to the new album Tahoe from Dedekind Cut - and also enjoying the previous one. There is also a new album from Chris Carter that sounds good. As well as a Flame 1 release which features Burial in a collaboration with The Bug.

Boomkat:

London’s dankest relay palpably paranoid pressures from the capital on The Bug’s newly minted Pressure label, hopefully the start of an ongoing collaboration between the pair.

Spying those hours of the dance when the smoke machines are puffing but there’s nobody there yet, Fog finds them melding charred bass hustle with billowing greyscale atmospheres in a time-honoured style shared by both artists.

On the flip, Shrine distills their meditative intensity to more suspenseful degrees with exceedingly brittle drums bearing the huge, brooding weight of a slowed down dread bass and glowering pads = minimal fuss for deadly, concentrated impact.