Plutonic Rainbows

Making Decisions in Python

This is a short script that shows how to use if as well as elif and else so that Python can make decisions based on the input it is given.

people = 100
cars = 30
buses = 15

if cars > people:
    print "We should take the cars."
elif cars < people:
    print "We should not take the cars."
else:
    print "We can't decide."


if buses > cars:
    print "That's too many buses."
elif buses < cars:
    print "Maybe we could take the buses."
else:
    print "We still can't decide"


if people > buses:
    print "Alright, let's just take the buses."
else:
    print "Fine. Let's stay home then."

How Rice crippled the Japanese Navy

There is a great article this month in Atlas Obscura detailing how fine, polished white rice helped destroy the Japanese navy and upset most of the residents of Tokyo.

Gleaming white rice was a status symbol—it was expensive and laborious to husk, hull, polish, and wash. In Japan, the poor ate brown rice, or other carbohydrates such as sweet potatoes or barley. The rich ate polished white rice, often to the exclusion of other foods.

In his book Beriberi in Modern Japan: The Making of a National Disease, Alexander R. Bay describes the efforts of Edo-era doctors to figure out the disease. A common suspect was dampness and damp ground. One doctor administered herbal medicines and a fasting regimen to a samurai, who died within months. Other doctors burned dried mugwort on patients’ bodies to stimulate qi and blood flow.

Memorizing Logic

Today, I will start trying to memorise the Truth Terms. Basically if something is true or false. These symbols forms combinations to tell Python what to do in a given situation. Now it's just a case of making them stick in my mind. Most of them seem fairly self-explanatory.

and

or

not

!= (not equal)

== (equal)

>= (greater than equal)

<= (less than equal)

True

False

Adding

I wrote a simple script for adding that uses a function to hold two variables and then add them together. You create a function by using def and then giving it a name.

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

def add(value_1, value_2):
    print "Adding %d and %d together." % (value_1, value_2)
    return value_1 + value_2

cost = add(2345,1234)

print "The cost is: £{0:.2f}".format (cost)

Be sure to use the utf-8 value at the top or else Python will not understand the currency character.

Dedekind Cut - Tahoe

Great new album from Lee Bannon. Tahoe has huge, cinematic sweeps often accompanied by feelings of sadness or unresolved strife. A really excellent addition, if you're into atmospheric ambient works.