Paste: Lex's First Python

Author: Lexie
Mode: python
Date: Thu, 7 Jul 2011 05:30:25
Plain Text |
fun with Python codez: cats = ("Leeloo", "Murlysha", "Satanic Cat") #list of cats
victims_per_day = {} #empty dictionary
victims_per_day ["Leeloo"] = 500
victims_per_day ["Murlysha"] = 3
victims_per_day ["Satanic Cat"] = 0.000001
total_victims = 0
for name_of_cat in cats: #cats is list name
number_of_days = 30
victims = number_of_days * victims_per_day [name_of_cat]
 
print "%s has %f victims." %(name_of_cat, victims)
total_victims = total_victims + victims
all_cats = ", ".join (cats) #cats is list name
print "%s have a grand kill total of %f" %(all_cats, total_victims)
This turns into:
Leeloo has 15000.000000 victims.
Murlysha has 90.000000 victims.
Satanic Cat has 0.000030 victims.
Leeloo, Murlysha, Satanic Cat have a grand kill total of 15090.000030
Moral of the story: Leeloo is a cold killer and Murlysha is soft.

New Annotation

Summary:
Author:
Mode:
Body: