Re: [Tutor] Modulus Operator ? SOLVED

2015-11-21 Thread Ken Hammer
Thanks, Danny Got it. Ken In , on 11/20/15 at 01:39 PM, Danny Yoo said: >>>On Thu, Nov 19, 2015 at 1:11 PM, Ken Hammer wrote: >> y = 49%13 print y 10 >> >>>Actually, let me pretend for a moment that I don't know what the modulus >>>operator is. Why do we get 10 here?

Re: [Tutor] Modulus Operator ?

2015-11-20 Thread Danny Yoo
>>On Thu, Nov 19, 2015 at 1:11 PM, Ken Hammer wrote: > >>> y = 49%13 >>> print y >>> 10 > >>Actually, let me pretend for a moment that I don't know what the modulus >>operator is. Why do we get 10 here? Can you verbalize the reason? > > 49 contains 13 3 times and leaves 10 to be divided. > > >>C

Re: [Tutor] Modulus Operator ?

2015-11-19 Thread Danny Yoo
On Thu, Nov 19, 2015 at 1:11 PM, Ken Hammer wrote: > y = 49%13 > print y > 10 Actually, let me pretend for a moment that I don't know what the modulus operator is. Why do we get 10 here? Can you verbalize the reason? Can you modify this example above to use the modulus operator with "10" on

Re: [Tutor] Modulus Operator ?

2015-11-19 Thread Alan Gauld
On 19/11/15 21:11, Ken Hammer wrote: ...The 2nd below mystifies me. How do I use "x % 10" and "x % 100" ... Also, you can extract the right-most digit or digits from a number. > For example, x % 10 yields the right-most digit of x (in base 10). I understand these: x = 49/13 print x 3 > >

[Tutor] Modulus Operator ?

2015-11-19 Thread Ken Hammer
A text for Python 2.7 includes these two paragraphs. The first I understand. The 2nd below mystifies me. How do I use "x % 10" and "x % 100" in the context of the examples I've created following the paragraphs? "The modulus operator turns out to be surprisingly useful. For example, you can

Re: [Tutor] modulus

2011-11-16 Thread Wayne Werner
On Wed, Nov 16, 2011 at 4:04 PM, Steven D'Aprano wrote: > Wayne Werner wrote: > >> It was explained to me once that in > > this case: >> >> "%s" % 42 >> >> That since python expects to see a single-element tuple it treats it as or >> converts 42 to a single element tuple. >> > > "Treats as" may

Re: [Tutor] modulus

2011-11-16 Thread Steven D'Aprano
Wayne Werner wrote: On Wed, Nov 16, 2011 at 10:09 AM, Steven D'Aprano wrote: Wayne Werner wrote: In old style formatting, you use a string with format specifiers (%s, %d, etc.) followed by a tuple of arguments. Here, the lengths have to match exactly - if you have one specifier then you must

Re: [Tutor] modulus

2011-11-16 Thread Wayne Werner
On Wed, Nov 16, 2011 at 10:09 AM, Steven D'Aprano wrote: > Wayne Werner wrote: > > >> In old style formatting, you use a string with format specifiers (%s, %d, >> etc.) followed by a tuple of arguments. Here, the lengths have to match >> exactly - if you have one specifier then you must have a 1-

Re: [Tutor] modulus

2011-11-16 Thread ADRIAN KELLY
really appreciate that answer thanks very much.. Adrian Kelly 1 Bramble Close Baylough Athlone County Westmeath 0879495663 From: waynejwer...@gmail.com Date: Wed, 16 Nov 2011 09:59:50 -0600 Subject: Re: [Tutor] modulus To: kellyadr...@hotmail.com CC: tutor@python.org On

Re: [Tutor] modulus

2011-11-16 Thread Steven D'Aprano
Wayne Werner wrote: In this case it's not actually modulus, it's just the syntax for string formatting. I'm not sure *what* the reasoning behind the % was, but that's the way it is. I believe the designers of the C programming language are to blame. [...] In old style formatting, you use a s

Re: [Tutor] modulus

2011-11-16 Thread Steven D'Aprano
ADRIAN KELLY wrote: Please can anyone tell me how i can print this without all the brackets and commas, i know i need the modulus symbol but i dont know how it works. any advice would be appreciated regards adrian def arguments(): name=raw_input ("Please enter your firstname: ") su

Re: [Tutor] modulus

2011-11-16 Thread Wayne Werner
On Wed, Nov 16, 2011 at 9:46 AM, ADRIAN KELLY wrote: > Please can anyone tell me how i can print this without all the brackets > and commas, i know i need the modulus symbol but i dont know how it works. > any advice would be appreciated > > regards > adrian > > def arguments(): > name=raw_in

[Tutor] modulus

2011-11-16 Thread ADRIAN KELLY
Please can anyone tell me how i can print this without all the brackets and commas, i know i need the modulus symbol but i dont know how it works. any advice would be appreciated regards adrian def arguments(): name=raw_input ("Please enter your firstname: ") surname=raw_input ("Ent