-
Notifications
You must be signed in to change notification settings - Fork 12.9k
NameError fix calculator.py #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
using the normal input() function was causing a NameError. changing it to raw_input() fixed this.
|
@ayush1999 this program is written in Python 3. |
|
@ayush1999 also I do have a NameError Exception in the program and it works. |
| print ("\nScientific Calculator\nEg: pi * sin(90) - sqrt(81)") | ||
|
|
||
| k = input("\nWhat is ") | ||
| k = raw_input("\nWhat is ") # Using input() function is causing NameError. Changing it to raw_input() fixes this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ayush1999 python3 input will give you a string no matter what you input.py2 is different so,raw_input =>string,and input may result in a number if you input like"1+2".if wrong,thanks for telling me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In python 2, raw_input will always return a string, however input will treat it as an expression.
In Python 3, input returns a string. Maybe this helps!
|
Thank you for you contribution to the repo and the community
…On 29 May 2017, at 19:36, Ayush Shridhar ***@***.***> wrote:
using the normal input() function was causing a NameError.
changing it to raw_input() fixed this.
You can view, comment on, or merge this pull request online at:
#172
Commit Summary
NameError fix calculator.py
File Changes
M calculator.py (2)
Patch Links:
https://github.com/geekcomputers/Python/pull/172.patch
https://github.com/geekcomputers/Python/pull/172.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
Can someone please tell me how *args and **kwargs work in Python? |
|
@ayush1999 def foo(first, *args, **kwargs):
print('Required argument: ', first)
for v in args:
print('Optional argument (*args): ', v)
for k, v in kwargs.items():
print('Optional argument %s (*kwargs): %s' % (k, v))
>>> foo(1, 2, 3, 4, k1=5, k2=6)Required argument: 1 |
using the normal input() function was causing a NameError.
changing it to raw_input() fixed this.