Calculator Problem

C

Charlie Winn

Hey Guys i Need Help , When i run this program i get the 'None' Under the program, see what i mean by just running it , can someone help me fix this

def Addition():
print('Addition: What are two your numbers?')
1 = float(input('First Number:'))
2 = float(input('Second Number:'))
print('Your Final Result is:', 1 + 2)


def Subtraction():
print('Subtraction: What are two your numbers?')
3 = float(input('First Number:'))
4 = float(input('Second Number:'))
print('Your Final Result is:', 3 - 4)


def Multiplication():
print('Multiplication: What are two your numbers?')
5 = float(input('First Number:'))
6 = float(input('Second Number:'))
print('Your Final Result is:', 5 * 6)


def Division():
print('Division: What are your two numbers?')
7 = float(input('First Number:'))
8 = float(input('Second Number:'))
print('Your Final Result is:', 7 / 8)



print('What type of calculation would you like to do?')
Question = input('(Add, Subtract, Divide or Multiply)')
if Question.lower().startswith('a'):
print(Addition())
elif Question.lower().startswith('s'):
print(Subtraction())
elif Question.lower().startswith('d'):
print(Division())
elif Question.lower().startswith('m'):
print(Multiplication())
else:
print('Please Enter The First Letter Of The Type Of Calculation You Would Like To Use')

while Question == 'test':
Question()
 
G

Gary Herron

Hey Guys i Need Help , When i run this program i get the 'None' Under the program, see what i mean by just running it , can someone help me fix this

def Addition():
print('Addition: What are two your numbers?')
1 = float(input('First Number:'))
2 = float(input('Second Number:'))
print('Your Final Result is:', 1 + 2)


def Subtraction():
print('Subtraction: What are two your numbers?')
3 = float(input('First Number:'))
4 = float(input('Second Number:'))
print('Your Final Result is:', 3 - 4)


def Multiplication():
print('Multiplication: What are two your numbers?')
5 = float(input('First Number:'))
6 = float(input('Second Number:'))
print('Your Final Result is:', 5 * 6)


def Division():
print('Division: What are your two numbers?')
7 = float(input('First Number:'))
8 = float(input('Second Number:'))
print('Your Final Result is:', 7 / 8)



print('What type of calculation would you like to do?')
Question = input('(Add, Subtract, Divide or Multiply)')
if Question.lower().startswith('a'):
print(Addition())
elif Question.lower().startswith('s'):
print(Subtraction())
elif Question.lower().startswith('d'):
print(Division())
elif Question.lower().startswith('m'):
print(Multiplication())
else:
print('Please Enter The First Letter Of The Type Of Calculation You Would Like To Use')

while Question == 'test':
Question()

Sorry, but in fact you did *not* run this program as you claim. It's
full of syntax errors. Any attempt to run it will display syntax errors
immediately, and never actually run. So please tell us what really
happened.

But even without an accurate description of what you did, I can say this:

Lines like
1 = float(...)
don't make sense. It's as if you are trying to change the value of the
number one, but that's nonsense.

And lines like
print('Your Final Result is:', 5 * 6)
had better print out 30 (since that is what 5 times 6 is) but that's
clearly not what you intended.

Gary Herron
 
D

Denis McMahon

Sorry, but in fact you did *not* run this program as you claim.

+1

I can also see a call to a function named Question, but I can't see where
that function is defined.

That might not be a major issue, because I don't think the while
condition that leads to the function call is ever fulfilled anyway.
 
C

Charlie Winn

Sorry, but in fact you did *not* run this program as you claim. It's

full of syntax errors. Any attempt to run it will display syntax errors

immediately, and never actually run. So please tell us what really

happened.



But even without an accurate description of what you did, I can say this:



Lines like

1 = float(...)

don't make sense. It's as if you are trying to change the value of the

number one, but that's nonsense.



And lines like

print('Your Final Result is:', 5 * 6)

had better print out 30 (since that is what 5 times 6 is) but that's

clearly not what you intended.



Gary Herron

excuse me but don't be so ******* rude , i did run this program and it did run correctly and if you want me to prove it with screenshots so be it , sodon't make accusations ** Gary ** i only came here for some help not to beaccused of not even running my program

Charlie :D
 
J

Joel Goldstick

the program, see what i mean by just running it , can someone help me fix
this
You can't name a variable a number
You should a result, then print it after the function.
excuse me but don't be so ******* rude , i did run this program and it
did run correctly and if you want me to prove it with screenshots so be it
, so don't make accusations ** Gary ** i only came here for some help not
to be accused of not even running my program

If you can run this, cut and paste the results
 
C

Charlie Winn

You can't name a variable a number


You should a result, then print it after the function.



If you can run this, cut and paste the results

Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:19:30) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.What type of calculation would you like to do?
(Add, Subtract, Divide or Multiply)a
Addition: What are two your numbers?
First Number:5
Second Number:96
Your Final Result is: 101.0
None
 
R

Roy Smith

Charlie Winn said:
excuse me but don't be so ******* rude , i did run this program and it did
run correctly and if you want me to prove it with screenshots so be it , so
don't make accusations ** Gary ** i only came here for some help not to be
accused of not even running my program

Hi Charlie,

I don't think anybody doubts that you ran your program. More likely,
the code that you ran simply isn't the code that you posted. When
posting code, it's best to copy-paste the exact code you ran.

You posted this:

That code could not have been what you ran, because it's not runnable.
It's a syntax error (in both Python 2 and 3).
 
S

Steven D'Aprano

excuse me but don't be so ******* rude , i did run this program and it
did run correctly

Charlie, you may have run *some* program, but it wasn't the program you
posted here. And if it ran correctly, why are you asking for help?

The code you ran and the code you posted here are not the same, because
the code you posted will not run due to multiple syntax errors. If you
had tried to run *that* program you would have received multiple syntax
errors:

py> 1 = float(input('First Number:'))
File "<stdin>", line 1
SyntaxError: can't assign to literal


So you must have run a different program. Please show us the program you
*actually* used, and then we can help you.
 
G

Gary Herron

excuse me but don't be so ******* rude , i did run this program and it did run correctly and if you want me to prove it with screenshots so be it , so don't make accusations ** Gary ** i only came here for some help not to be accused of not even running my program

Charlie :D


Sorry, it wasn't rude, it was a statement of fact pointing out an error
on your part. You may *think* you ran the code you posted, but in fact
you could not have done so. The code you posted will not run. Not in
any version of Python, past, present or future. Assigning to a literal
1 = ...
makes no sense and produces a syntax error. That's the only result you
could have gotten. If you think that's what you've done, then by all
means post a screen-shot showing is how you came to that conclusion, and
we'll correct you again. But I'll guarantee with absolute certainty,
that your posted Python program did not *run* "correctly" or incorrectly.

People on the group are willing to help with nearly anything, but it's
all a volunteer effort. You waste our time (either carelessly or
maliciously) if you don't accurately post your code and the results of
running that code.

So please try again. You *will* get help. There are a number of other
errors in your program also. We can get to those once we know what code
you are really running, and are sure that you know what it means to
*run* it, and that you can correctly identify the results -- error or not.

Gary Herron
 
I

Ian Kelly

On Feb 3, 2014 3:26 PM, "Steven D'Aprano" <
Charlie, you may have run *some* program, but it wasn't the program you
posted here. And if it ran correctly, why are you asking for help?

He said previously that he doesn't want it printing the None after the
result. I think that was already answered though: Assuming that the code
being run is structurally similar to what was posted, it prints None
because the calculator functions print their result instead of returning
it, and then the main function also prints the return value from the
calculator functions, which is None. The print should be in one place or
the other, not both.
 
D

Denis McMahon

Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:19:30) [MSC v.1600 64
bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for
more information.What type of calculation would you like to do?
(Add, Subtract, Divide or Multiply)a Addition: What are two your
numbers?
First Number:5 Second Number:96 Your Final Result is: 101.0 None

That wasn't obtained from running the code you posted.

Your code *as you posted it* gives:

$ python charlie.py
File "charlie.py", line 4
1 = float(input('First Number:'))
SyntaxError: can't assign to literal
$
 
D

David Hutto

Hey Guys i Need Help , When i run this program i get the 'None' Under the program, see what i mean by just running it , can someone help me fix this



def Addition():

print('Addition: What are two your numbers?')

1 = float(input('First Number:'))

2 = float(input('Second Number:'))

print('Your Final Result is:', 1 + 2)





def Subtraction():

print('Subtraction: What are two your numbers?')

3 = float(input('First Number:'))

4 = float(input('Second Number:'))

print('Your Final Result is:', 3 - 4)





def Multiplication():

print('Multiplication: What are two your numbers?')

5 = float(input('First Number:'))

6 = float(input('Second Number:'))

print('Your Final Result is:', 5 * 6)





def Division():

print('Division: What are your two numbers?')

7 = float(input('First Number:'))

8 = float(input('Second Number:'))

print('Your Final Result is:', 7 / 8)







print('What type of calculation would you like to do?')

Question = input('(Add, Subtract, Divide or Multiply)')

if Question.lower().startswith('a'):

print(Addition())

elif Question.lower().startswith('s'):

print(Subtraction())

elif Question.lower().startswith('d'):

print(Division())

elif Question.lower().startswith('m'):

print(Multiplication())

else:

print('Please Enter The First Letter Of The Type Of Calculation You Would Like To Use')



while Question == 'test':

Question()

Can anyone point out how using an int as a var is possible, unless it's something I miss that changed in 3.3 from 3.2:

david@david:~$ python3.2
Python 3.2.3 (default, Sep 25 2013, 18:25:56)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
david@david:~$ python
Python 2.7.3 (default, Sep 26 2013, 20:08:41)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 
M

Mario R. Osorio

Hey Guys i Need Help , When i run this program i get the 'None' Under the program, see what i mean by just running it , can someone help me fix this



def Addition():

print('Addition: What are two your numbers?')

1 = float(input('First Number:'))

2 = float(input('Second Number:'))

print('Your Final Result is:', 1 + 2)





def Subtraction():

print('Subtraction: What are two your numbers?')

3 = float(input('First Number:'))

4 = float(input('Second Number:'))

print('Your Final Result is:', 3 - 4)





def Multiplication():

print('Multiplication: What are two your numbers?')

5 = float(input('First Number:'))

6 = float(input('Second Number:'))

print('Your Final Result is:', 5 * 6)





def Division():

print('Division: What are your two numbers?')

7 = float(input('First Number:'))

8 = float(input('Second Number:'))

print('Your Final Result is:', 7 / 8)







print('What type of calculation would you like to do?')

Question = input('(Add, Subtract, Divide or Multiply)')

if Question.lower().startswith('a'):

print(Addition())

elif Question.lower().startswith('s'):

print(Subtraction())

elif Question.lower().startswith('d'):

print(Division())

elif Question.lower().startswith('m'):

print(Multiplication())

else:

print('Please Enter The First Letter Of The Type Of Calculation You Would Like To Use')



while Question == 'test':

Question()

I don't know why people bother trying to help you, when it is YOU that has a ******* rude attitude.

You are asking the wrong question to begin with because the posted code could have NEVER given you the stated output.

Most of us here are noobs and those that are not, were noobs once; so we all can deal with noobs, but none should have to deal with a*******holes.
 
C

Chris Angelico

one = 42

(ducking and running)

In theory, there might be a Unicode character that's valid as an
identifier, but gets converted into U+0031 for ASCIIfication prior to
being sent by email. However, I can't find one :)

And of course, that assumes that the OP's mail client mangles its
input in that way. ASCIIfication shouldn't be necessary.

ChrisA
 
8

88888 Dihedral

Hey Guys i Need Help , When i run this program i get the 'None' Under the program, see what i mean by just running it , can someone help me fix this



def Addition():

print('Addition: What are two your numbers?')

1 = float(input('First Number:'))

2 = float(input('Second Number:'))

print('Your Final Result is:', 1 + 2)





def Subtraction():

print('Subtraction: What are two your numbers?')

3 = float(input('First Number:'))

4 = float(input('Second Number:'))

print('Your Final Result is:', 3 - 4)





def Multiplication():

print('Multiplication: What are two your numbers?')

5 = float(input('First Number:'))

6 = float(input('Second Number:'))

print('Your Final Result is:', 5 * 6)





def Division():

print('Division: What are your two numbers?')

7 = float(input('First Number:'))

8 = float(input('Second Number:'))

print('Your Final Result is:', 7 / 8)







print('What type of calculation would you like to do?')

Question = input('(Add, Subtract, Divide or Multiply)')

if Question.lower().startswith('a'):

print(Addition())

elif Question.lower().startswith('s'):

print(Subtraction())

elif Question.lower().startswith('d'):

print(Division())

elif Question.lower().startswith('m'):

print(Multiplication())

else:

print('Please Enter The First Letter Of The Type Of Calculation You Would Like To Use')



while Question == 'test':

Question()

I suggest just get an input string
of the valid python expression type
first. Then just use exec and _ or
eval to get the result.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top