On Monday, October 14, 2013 10:32:36 AM UTC+5:30, Steven D'Aprano wrote:
> On Sun, 13 Oct 2013 20:13:32 -0700, Tim Roberts wrote:
>
> > def add(c1, c2):
> > % Decode
> > c1 = ord(c1) - 65
> > c2 = ord(c2) - 65
> > % Process
> > i1 = (c1 + c2) % 26
> > % Encode
> >
Steven D'Aprano wrote:
>On Sun, 13 Oct 2013 20:13:32 -0700, Tim Roberts wrote:
>
>> def add(c1, c2):
>> % Decode
>>...
>Python uses # for comments, not %, as I'm sure you know. What language
>were you thinking off when you wrote the above?
Psssht, I know better than that.
I've been readin
On Oct 16, 2013 11:54 PM, "MRAB" wrote:
>
> On 16/10/2013 23:39, Rotwang wrote:
>>
>> On 14/10/2013 06:02, Steven D'Aprano wrote:
>>>
>>> On Sun, 13 Oct 2013 20:13:32 -0700, Tim Roberts wrote:
>>>
def add(c1, c2):
% Decode
c1 = ord(c1) - 65
c2 = ord(c2) - 65
>
On 16/10/2013 23:39, Rotwang wrote:
On 14/10/2013 06:02, Steven D'Aprano wrote:
On Sun, 13 Oct 2013 20:13:32 -0700, Tim Roberts wrote:
def add(c1, c2):
% Decode
c1 = ord(c1) - 65
c2 = ord(c2) - 65
% Process
i1 = (c1 + c2) % 26
% Encode
return chr(i1+65
On 14/10/2013 06:02, Steven D'Aprano wrote:
On Sun, 13 Oct 2013 20:13:32 -0700, Tim Roberts wrote:
def add(c1, c2):
% Decode
c1 = ord(c1) - 65
c2 = ord(c2) - 65
% Process
i1 = (c1 + c2) % 26
% Encode
return chr(i1+65)
Python uses # for comments, not %
Charles Hixson writes:
> On 10/13/2013 10:02 PM, Steven D'Aprano wrote:
>> On Sun, 13 Oct 2013 20:13:32 -0700, Tim Roberts wrote:
>>
>>> def add(c1, c2):
>>> % Decode
>>> c1 = ord(c1) - 65
>>> c2 = ord(c2) - 65
>>> % Process
>>> i1 = (c1 + c2) % 26
>>> % Encode
On 10/13/2013 10:02 PM, Steven D'Aprano wrote:
On Sun, 13 Oct 2013 20:13:32 -0700, Tim Roberts wrote:
def add(c1, c2):
% Decode
c1 = ord(c1) - 65
c2 = ord(c2) - 65
% Process
i1 = (c1 + c2) % 26
% Encode
return chr(i1+65)
Python uses # for comments, not
On Sun, 13 Oct 2013 20:13:32 -0700, Tim Roberts wrote:
> def add(c1, c2):
> % Decode
> c1 = ord(c1) - 65
> c2 = ord(c2) - 65
> % Process
> i1 = (c1 + c2) % 26
> % Encode
> return chr(i1+65)
Python uses # for comments, not %, as I'm sure you know. What language
kjaku...@gmail.com wrote:
>
>Transfer it to an uppercase letter if it's a letter, if it's not then an error.
>This isn't right, I know, just testing around
>
>def add(c1, c2):
>ans = ''
>for i in c1 + c2:
>ans += chrord(i)-65))%26) + 65)
>return ans
It's close. I think you
On 8/10/2013 10:28, kjaku...@gmail.com wrote:
> I have to define a function add(c1, c2), where c1 and c2 are capital letters;
> the return value should be the sum (obtained by converting the letters to
> numbers, adding mod 26, then converting back to a capital letter).
>
> All I have so far is
On 08/10/2013 15:28, kjaku...@gmail.com wrote:
I have to define a function add(c1, c2), where c1 and c2 are capital letters;
the return value should be the sum (obtained by converting the letters to
numbers, adding mod 26, then converting back to a capital letter).
I'd say the requirement is
On Tue, Oct 8, 2013, at 11:44, kjaku...@gmail.com wrote:
> def add(c1, c2):
> ans = ''
This only makes sense if your answer is going to be multiple characters.
> for i in c1 + c2:
This line concatenates the strings together.
> ans += chrord(i)-65))%26) + 65)
The way you are
On Tuesday, October 8, 2013 11:36:51 AM UTC-4, rand...@fastmail.us wrote:
>
>
>
> Your description says capital letters, but 'a' is a lowercase letter.
>
>
>
> Does "mod 26" means A is 1, or is it 0? i.e., is A+A = B or is it A?
>
>
>
> What should your function do if the letter isn't a ca
On Tue, Oct 8, 2013, at 10:28, kjaku...@gmail.com wrote:
> I have to define a function add(c1, c2), where c1 and c2 are capital
> letters; the return value should be the sum (obtained by converting the
> letters to numbers, adding mod 26, then converting back to a capital
> letter).
>
> All I hav
You wrote this:
def add(c1, c2):
ord(c1) - ord('a') + 1
ord(c2) - ord('a') + 1
First of all, this looks like homework. People will help you with
concepts here, but most frown on just providing answers. With that in
mind look at this:
>>> ord('A')
65
>>> ord('a')
97
>>>
In your assignm
On Tuesday, October 8, 2013 10:47:39 AM UTC-4, Robert Day wrote:
> On 08/10/13 15:28, kjaku...@gmail.com wrote:
>
> Can you give some expected outputs? For example, add('A', 'B') should
>
> presumably return 'C', and add('M', 'B') should presumably return 'O',
>
> but what about add('A', 'A')
On 08/10/13 15:28, kjaku...@gmail.com wrote:
I have to define a function add(c1, c2), where c1 and c2 are capital letters;
the return value should be the sum (obtained by converting the letters to
numbers, adding mod 26, then converting back to a capital letter).
Can you give some expected out
I have to define a function add(c1, c2), where c1 and c2 are capital letters;
the return value should be the sum (obtained by converting the letters to
numbers, adding mod 26, then converting back to a capital letter).
All I have so far is:
def add(c1, c2):
ord(c1) - ord('a') + 1
ord(c
18 matches
Mail list logo