+- +-

+-User

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+-Stats

Members
Total Members: 29
Latest: The Joker1
New This Month: 0
New This Week: 0
New Today: 0
Stats
Total Posts: 11369
Total Topics: 427
Most Online Today: 16
Most Online Ever: 284
(May 14, 2022, 07:43:40 am)
Users Online
Members: 0
Guests: 60
Total: 60

Cleaning

 The forum will be undergoing maintenance as things progress forward. SMF2 is a little buggy on our forum, and I will be working to iron out some of those bugs, and to restore the forum to a similar and familiar home for us to the one that we used to have.


Modify message

Subject:
Message icon:

Verification:

shortcuts: hit alt+s to submit/post or alt+p to preview


Topic Summary

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...



----------------------------------------

;D

Shoutbox

January 09, 2015, 09:35:29 am Superchaos2585 says: SHOUTBOX IS BACK

View Shout History

+-Recent Topics

Xbox 360 Games by Twilightpersona
July 03, 2013, 05:33:23 am

Random Awesome Song by Twilightpersona
July 03, 2013, 05:31:42 am

Watchdogs Game by Twilightpersona
May 22, 2013, 04:52:08 am

This is by far the creepiest anything I've ever seen. by Mustang MKIII
May 05, 2013, 12:21:35 pm

For crazyhobo by Twilightpersona
April 22, 2013, 06:13:54 am

Lone Wanderer's Journal Discussion by Twilightpersona
March 27, 2013, 06:47:00 am

Stray Sheep by Mustang MKIII
March 17, 2013, 05:47:21 am

Lone Wanderer's Journal by Twilightpersona
March 04, 2013, 08:57:17 am

The Second Pulse Discussion by Twilightpersona
February 26, 2013, 07:05:35 am

The Second Pulse by Twilightpersona
February 19, 2013, 06:41:46 am