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

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!"?
Due to the reasons discussed here we will be moving to python-forum.io on October 1, 2016.

This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.

micseydel

Posts: 3000
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 helpprint ("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`
Due to the reasons discussed here we will be moving to python-forum.io/ on October 1 2016
This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.

Yoriz

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