Posted by: BlackRain
« on: March 09, 2012, 10:33:49 pm »There, better? xD

|
Posted by: BlackRain« on: March 09, 2012, 10:33:49 pm »There, better? xD
Posted by: CrazyHobo« on: March 09, 2012, 10:14:45 pm »yes, please.
That would make my life significantly easier. Posted by: BlackRain« on: March 09, 2012, 04:27:18 am »xD I realize this. I just figured you'd be able to separate the different programs by me saying,'And this month...' xD Shall I put some horizontal lines in the post to help you out, Brother? ;P
Posted by: CrazyHobo« on: March 08, 2012, 11:59:51 pm »I'm horrible with programming, ya know >_>
Posted by: BlackRain« on: March 08, 2012, 12:03:38 pm »xD No, Igor. It's three different programs, separated by when I say,'this month' or some such.
Thanks TR. ![]() Posted by: CrazyHobo« on: March 08, 2012, 08:53:16 am »I'm **** confused O_O
At first it looks like buying a Defiler, but then it turns into Dungeons and Dragons looting, only you're a chaos lord? O_o Posted by: TRHeadshot« on: March 08, 2012, 06:05:56 am »Sexxii code bro
![]() Posted by: BlackRain« on: March 08, 2012, 05:24:19 am »Heh. Glad to be able to make you laugh, mate.
... I can't wait until Igor sees this... >:D Posted by: Superchaos2585« on: March 08, 2012, 05:11:00 am » XD
Posted by: BlackRain« on: March 08, 2012, 05:09:00 am »So... I'm sitting in a computer programming class right now, and I decide to show you guys what the code I use looks like... xD
Python Code from two months ago: ---------------------------------------- #Fancy Credits by Rain 1/12/12 #Demonstrates escape sequences. print('\t\t\t Fancy Credits') print('\t\t\t \\ \\ \\ \\ \\ \\ \\') print('\t\t\t by') print('\t\t\t Black Rain') print('\t\t\t \\ \\ \\ \\ \\ \\ \\') print('\n\t\t\tSpecial thanks goes out to:') print('\t\t\tTHE BLOOD GOD KHORNE!') print('\t\t\tBLOOD FOR THE BLOOD GOD!') print('\t\t\tAND SKULLS FOR THE SKULL THRONE!') print('\n\n\n\t... I would like some milk for my Chaos Khorne Flakes') # sound the system bell. print('\n\n\n\a') input('\n\nPress the enter key to exit.') ---------------------------------------- Last month: ---------------------------------------- #Defiler Tank Requisition Cost A.I.(Car Salesman) #Black Rain, Harbinger of Khorne #Calculates the costs of buying, registering, and outfitting a defiler walker tank. print('\t\t\tDefiler Walker Requisition Costs\n\n') print('This A.I. program will tell you how much Requisition you need to have a Defiler tank delivered to the warfront.') #Variables being defined as the sections of the the Defiler tank costs base = input('The base prices of the two types of Defilers are 8000 and 12000. Choose one: ') base = int(base) warpTravel = int(base * .1) training = int(base * .05) blessing = int(400) energy = int(800) summoning = int(400) #Displays all the different costs of the sections of the walker tank print('Base Cost:................... ........', base,' Req.') print('Warp Travel:................... ......', warpTravel,' Req.') print('Pilot Training:................... ...', training,' Req.') print('Khorne\'s Blessing:..................', blessing,' Req.') print('Energy Cost:................... ......', energy,' Req.') print('Daemon Summoning and Binding:........', summoning,' Req.') #Adds them all together into the same variable to display as a string. total = int(base + warpTravel + training + blessing + energy + summoning) print('The total Requisition cost of a Defiler walker tank is ', total, '.') input('\nPress enter key to exit.') ---------------------------------------- And this month... ---------------------------------------- #Chaos Lord's Wargear Program 32 #Black Rain, Harbinger of Khorne #demonstrates tuple creation #create an empty tuple inventory = () #treat the tuple as a condition if not inventory: print('You are empty-handed.') #create tuple with some items inventory = ('power sword', 'artificer armor', 'Chaos banner', 'frag grenade') #Waits for user consent input('\nPress the enter key to continue.') #get the length of the tuple print('You have', len(inventory), 'wargear pieces in your possession.') #Waits for user consent input('\nPress the enter key to continue.') #test for membership with in if 'frag grenade' in inventory: print('You will live to fight another day.') #display one item through an index index = int(input('\nEnter the index number for an item in inventory: ')) print('At index', index, 'is', inventory[index]) #display a slice start = int(input('\nEnter the index number to begin a slice: ')) finish = int(input('Enter the index number to begin a slice: ')) print('inventory[', start, ':', finish, '] is', end=' ') print(inventory[start:finish]) #Waits for user consent input('\nPress the enter key to continue.') #concatenate two tuples #Prints various role playing information #Combines inventory and chest. chest = ('relic', 'ammunition') print('You find a supply crate. It contains: ') print(chest) print('You add the contents of the crate to your ruck.') inventory += chest print('Your inventory is now: ') print(inventory) #wait for user consent input('\nPress the enter key to continue.') #print the tuple print('\nYour items: ') for item in inventory: print(item) input('\n\nPress the enter key to exit.') ---------------------------------------- xD Yes, even in school, I use 'Black Rain' as my name. >:3 ---------------------------------------- #Ch. 10 Challenge 1 - 46 #Black Rain, Harbinger of Khorne #Create a story based on user input #import tkinter package from tkinter import * #initialize class to hold everything class Application(Frame): """ GUI application that creates a story based on user input. """ def __init__(self, master): """ Initialize Frame. """ super(Application, self).__init__(master) self.grid() self.create_widgets() def create_widgets(self): """ Create widgets to get story information and to display story. """ #create instruction label Label(self, text = "Enter information for a new story" ).grid(row = 0, column = 0, columnspan = 2, sticky = W) #create a label and text entry for the name of a person Label(self, text = "Person: " ).grid(row = 1, column = 0, sticky = W) self.person_ent = Entry(self) self.person_ent.gri d(row = 1, column = 1, sticky = W) #create a label and text entry for a plural noun Label(self, text = "Plural Noun:" ).grid(row = 2, column = 0, sticky = W) self.noun_ent = Entry(self) self.noun_ent.grid(row = 2, column = 1, sticky = W) #create a label and text entry for a plural noun Label(self, text = "Second Noun:" ).grid(row = 3, column = 0, sticky = W) self.verb_ent = Entry(self) self.verb_ent.grid(row = 3, column = 1, sticky = W) #create a label for adjectives check buttons Label(self, text = "Adjective(s):" ).grid(row = 4, column = 0, sticky = W) #create itchy check button self.is_fearfully = BooleanVar() Checkbutton(self, text = "fearfully", variable = self.is_fearfully ).grid(row = 4, column = 1, sticky = W) #create joyous check button self.is_disturbingl y = BooleanVar() Checkbutton(self, text = "disturbingly", variable = self.is_disturbingl y ).grid(row = 4, column = 2, sticky = W) #create electric check button self.is_frightening ly = BooleanVar() Checkbutton(self, text = "frighteningly", variable = self.is_frightening ly ).grid(row = 4, column = 3, sticky = W) #create a label for body parts radio buttons Label(self, text = "Body Part:" ).grid(row = 5, column = 0, sticky = W) # create variable for single, body part self.body_part = StringVar() self.body_part.set(None) #create body part radio buttons body_parts = ["second mouth", "eighth eye", "umbilical scar"] column = 1 for part in body_parts: Radiobutton(self, text = part, variable = self.body_part, value = part ).grid(row = 5, column = column, sticky = W) column += 1 #create a submit button Button(self, text = "Click for story", command = self.tell_story ).grid(row = 6, column = 0, sticky = W) self.story_txt = Text(self, width = 75, height = 10, wrap = WORD) self.story_txt.grid(row = 7, column = 0, columnspan = 4) def tell_story(self): """ Fill text box with new story based on user input. """ #get values from the GUI person = self.person_ent.get() noun = self.noun_ent.get() verb = self.verb_ent.get() adjectives = "" if self.is_fearfully.g et(): adjectives += "fearfully, " if self.is_disturbingl y.get(): adjectives += "disturbingly, " if self.is_frightening ly.get(): adjectives += "frighteningly, " body_part = self.body_part.get() #create the story story = "The famous explorer " story += person story += " had nearly given up a life-long quest to find The Lost City of " story += noun.title() story += " when one day, the " story += noun story += " found " story += person + ". " story += "A strong, " story += adjectives story += "peculiar feeling overwhelmed the Chaos Lord. " story += "After all this time, the search was finally over. A small smile came to " story += person + "'s " story += body_part + ". " story += "And then, the " story += noun story += " promptly devoured " story += person + ". " story += "The moral of the story? - " story += verb.upper() story += " FOR THE " story += verb.upper() story += " GOD!" #display the story self.story_txt.dele te(0.0, END) self.story_txt.inse rt(0.0, story) #curb stomp the main window into action root = Tk() root.title("Mad Lib") app = Application(root) root.mainloop() ---------------------------------------- What this code makes... ![]() ---------------------------------------- #Ch. 10 Challenge 3 - 48 #Black Rain, Harbinger of Khorne #Import tkinter package and random from tkinter import * #open a class to start everything up in class Application(Frame): """ GUI Application for food orders """ def __init__(self, master): super(Application, self).__init__(master) self.grid() self.create_widgets() def create_widgets(self): """ Create widgets for food choices. """ # create description label Label(self, text = "Choose your food orders." ).grid(row = 0, column = 0, sticky = W) # create instruction label Label(self, text = "Select all that apply:" ).grid(row = 1, column = 0, sticky = W) # create Virgin Soul check button self.ordersVirgin = BooleanVar() Checkbutton(self, text = "Virgin Soul - 20R", variable = self.ordersVirgin, command = self.update_text ).grid(row = 2, column = 0, sticky = W) # create Saint check button self.ordersSaint = BooleanVar() Checkbutton(self, text = "Aged Saint Soul - 25R", variable = self.ordersSaint, command = self.update_text ).grid(row = 3, column = 0, sticky = W) # create Bone Marrow check button self.ordersMarrow = BooleanVar() Checkbutton(self, text = "Bone Marrow - 15R", variable = self.ordersMarrow, command = self.update_text ).grid(row = 4, column = 0, sticky = W) # create Grey Matter check button self.ordersGrey = BooleanVar() Checkbutton(self, text = "Grey Matter - 30R", variable = self.ordersGrey, command = self.update_text ).grid(row = 5, column = 0, sticky = W) # create Entrails check button self.ordersEntrails = BooleanVar() Checkbutton(self, text = "Mortal Entrails - 20R", variable = self.ordersEntrails, command = self.update_text ).grid(row = 6, column = 0, sticky = W) # create Fresh check button self.ordersBlood = BooleanVar() Checkbutton(self, text = "Fresh Blood - 15R", variable = self.ordersBlood, command = self.update_text ).grid(row = 7, column = 0, sticky = W) #create text field to display results self.results_txt = Text(self, width = 40, height = 10, wrap = WORD) self.results_txt.gr id(row = 8, column = 0, columnspan = 3) def update_text(self): """ Update text widget and display user's food order. """ likes = "" cost = 0 if self.ordersVirgin.g et(): cost += 20 likes += "Item: Virgin Soul - 20R\n" if self.ordersSaint.ge t(): cost += 25 likes += "Item: Aged Saint Soul - 25R\n" if self.ordersMarrow.g et(): cost += 15 likes += "Item: Bone Marrow - 15R\n" if self.ordersGrey.get(): cost += 30 likes += "Item: Grey Matter - 30R\n" if self.ordersEntrails .get(): cost += 20 likes += "Item: Mortal Entrails - 20R\n" if self.ordersBlood.ge t(): cost += 15 likes += "Item: Fresh Blood - 15R\n" if cost > 0: likes += "Total: " + str(cost) + "R" self.results_txt.de lete(0.0, END) self.results_txt.in sert(0.0, likes) #curb stomp main window into action. root = Tk() root.title("Order Up!") app = Application(root) root.mainloop() ---------------------------------------- And what this code makes... ![]() ---------------------------------------- ![]() |
|