Having trouble making an unusually structured calculator.

This is the place for queries that don't fit in any of the other categories.

Having trouble making an unusually structured calculator.

Postby spamynator_1 » Sun Mar 03, 2013 12:57 am

Ive been trying to write a calculator program that processes its funcitons around an object.

Code: Select all
#!/usr/bin/env python
#DONT LOOK AT MY FUCKING SOURCE CODE!!!
print ("This is a calculator.")
print ("The possible functions are as follows:")
print ("1: add, 2: subtract, 3: multiply, 4: divide, 5: exponent")
#For all intentive purposes 'poop' is now an object which is the root of all mathmatical operations.
class poop:
    amount_of_corn = 0
    viscosity = 0
    yaw = 0
    shades_of_brown = 0
    quality_of_service = 0
    density = 0
    consistancy = 0
    boyancy = 0
    girth = 0
    stank = 0
    steam = 0
    def choice(self):
        turd= int(input("Enter what function you would like: "))
        if turd == (add):
            corn= int(input("Enter the first number")
            visc= int(input("Enter the second number")
            timmy.poop = amount_of_corn = corn
            dong.poop = viscosity = visc
            print (b + c)


As you can see this is not the standard way to program a calculator but i would like to ease my way into oop. Although after the inevidable wiseass comments i would appreciate if someone could offer input that would assist this to function. corn and visc are strings.
spamynator_1
 
Posts: 63
Joined: Sun Mar 03, 2013 12:45 am

Re: Having trouble making an unusually structured calculator

Postby micseydel » Sun Mar 03, 2013 1:40 am

spamynator_1 wrote:Ive been trying to write a calculator program that processes its funcitons around an object.

Code: Select all
#!/usr/bin/env python
#DONT LOOK AT MY FUCKING SOURCE CODE!!!
print ("This is a calculator.")
print ("The possible functions are as follows:")
print ("1: add, 2: subtract, 3: multiply, 4: divide, 5: exponent")
#For all intentive purposes 'poop' is now an object which is the root of all mathmatical operations.
class poop:
    amount_of_corn = 0
    viscosity = 0
    yaw = 0
    shades_of_brown = 0
    quality_of_service = 0
    density = 0
    consistancy = 0
    boyancy = 0
    girth = 0
    stank = 0
    steam = 0
    def choice(self):
        turd= int(input("Enter what function you would like: "))
        if turd == (add):
            corn= int(input("Enter the first number")
            visc= int(input("Enter the second number")
            timmy.poop = amount_of_corn = corn
            dong.poop = viscosity = visc
            print (b + c)


As you can see this is not the standard way to program a calculator but i would like to ease my way into oop. Although after the inevidable wiseass comments i would appreciate if someone could offer input that would assist this to function. corn and visc are strings.

Did you have a question, or did you just want to make sure your first post screamed "don't help me!"?
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1303
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: Having trouble making an unusually structured calculator

Postby Yoriz » Sun Mar 03, 2013 1:46 am

Ive added comments to the things i spotted that i think are not quite right.
Code: Select all
#!/usr/bin/env python
#DONT LOOK AT MY FUCKING SOURCE CODE!!! ############################# If we can't look at the source code how can we help
print ("This is a calculator.")
print ("The possible functions are as follows:")
print ("1: add, 2: subtract, 3: multiply, 4: divide, 5: exponent")
#For all intentive purposes 'poop' is now an object which is the root of all mathmatical operations.
class poop:  ############################# Class names should be Capitalized
    amount_of_corn = 0
    viscosity = 0
    yaw = 0
    shades_of_brown = 0
    quality_of_service = 0
    density = 0
    consistancy = 0
    boyancy = 0
    girth = 0
    stank = 0
    steam = 0
    def choice(self):
        turd= int(input("Enter what function you would like: "))
        if turd == (add):  #############################  variable named add not defined, brackets not necessary
            corn= int(input("Enter the first number") ############################# Close bracket missing
            visc= int(input("Enter the second number")  ############################# Close bracket missing
            timmy.poop = amount_of_corn = corn  ############################# timmy not defined
            dong.poop = viscosity = visc  ############################# dong not defined
            print (b + c)  ############################# b and c not defined

############################# The Poop class is never called
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 789
Joined: Fri Feb 08, 2013 1:35 am
Location: UK


Return to General Coding Help

Who is online

Users browsing this forum: 7stud, Baldyr, rjnicholson and 3 guests