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

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
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: "))
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

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
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: "))
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 for off-topic chat!

Please prefer not to PM members. The point of the forum is so that anyone can benefit. We don't want to help you over PMs/emails/Skype chats that others can't benefit from

micseydel

Posts: 2027
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

### Re: Having trouble making an unusually structured calculator

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
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
Join the #python-forum IRC channel on irc.freenode.net!

Yoriz

Posts: 1443
Joined: Fri Feb 08, 2013 1:35 am
Location: UK