On 2/7/2012 1:57 PM, Sarma Tangirala wrote:
Anyway, I was wondering about this, if internally pow() actually uses
**. :P
>>> from dis import dis
>>> dis(lambda a,b:a**b)
1 0 LOAD_FAST0 (a)
3 LOAD_FAST1 (b)
6 BINARY_POWE
On 02/07/2012 01:57 PM, Sarma Tangirala wrote:
On 8 February 2012 00:01, Steven D'Aprano wrote:
Sarma Tangirala wrote:
Is is better to use pow() against **?
Advantages of **
- it is shorter to type x**y vs pow(x, y)
- being an operator, it is slightly faster than calling a function
- you
On 8 February 2012 00:01, Steven D'Aprano wrote:
> Sarma Tangirala wrote:
>
> Is is better to use pow() against **?
>>
>
>
> Advantages of **
>
> - it is shorter to type x**y vs pow(x, y)
> - being an operator, it is slightly faster than calling a function
> - you can't monkey-patch it
>
> Disad
Sarma Tangirala wrote:
Is is better to use pow() against **?
Advantages of **
- it is shorter to type x**y vs pow(x, y)
- being an operator, it is slightly faster than calling a function
- you can't monkey-patch it
Disadvantages of **
- being an operator, you can't directly use it as a fun
On 07/02/12 16:54, Sarma Tangirala wrote:
Is is better to use pow() against **?
I suspect ** will be faster since it doesn't have the function
call overhead.
But I haven't tried timing it. Feel free to do some tests and find out.
Let us know how you get on!
--
Alan G
Author of the Learn to
On 7 February 2012 13:49, Alan Gauld wrote:
> On 07/02/12 01:01, Nate Lastname wrote:
>
>> Exponents ... are **(or ^)
>>
>
> Not quite the ^ operator is a bitwise XOR...
>
> >>> 2^2
> 0
> >>> 2^1
> 3
>
> pow() is the other way to do exponents.
>
>
Is is better to use pow() against **?
> --
> Al
On 07/02/12 01:01, Nate Lastname wrote:
Exponents ... are **(or ^)
Not quite the ^ operator is a bitwise XOR...
>>> 2^2
0
>>> 2^1
3
pow() is the other way to do exponents.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
On Mon, Feb 06, 2012 at 04:54:57PM -0800, William Stewart wrote:
> Hello everyone, I am making a calculator and I need to know how to make it do
> exponents and remainders
> How can I input this info in python?
> Any help would be appreciated
You can do exponents either with the ** operator or th
Exponents and remainder (modulus) are **(or ^) and % respectively. I.E.;
d = a ** b (exponent)
c = a % b (modulus)
There you are!
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listi
Hello everyone, I am making a calculator and I need to know how to make it do
exponents and remainders
How can I input this info in python?
Any help would be appreciated
Thanks
--- On Mon, 2/6/12, Steven D'Aprano wrote:
From: Steven D'Aprano
Subject: Re: [Tutor] Sandbox Game
To: "tutor"
Date
10 matches
Mail list logo