Re: [Tutor] Geometric sequence

2013-11-08 Thread Peter O'Doherty
To the people who kindly replied to my question: many thanks! On 10/31/2013 06:29 PM, Danny Yoo wrote: As an aside: It shouldn't be too bad to write a "generator" for the geometric series, so that we can pick out the terms on-demand. # >>> def geometric(base):

Re: [Tutor] sequence of elements problem

2013-11-08 Thread Danny Yoo
On Fri, Nov 8, 2013 at 4:54 AM, donsuni wrote: > Hi, I have a problem in python which is kind of tricky. > > if i give a sequence of numbers, i should get another sequence of numbers > such that the the elements exceeds previous element in the list. For eg > Have you written any other functions

Re: [Tutor] sequence of elements problem

2013-11-08 Thread Dave Angel
On Fri, 8 Nov 2013 04:54:53 -0800 (PST), donsuni wrote: Hi, I have a problem in python which is kind of tricky. Your wording is kind of tricky. and so on without using any inbuilt functions. But you use len() and range(). Has your class taught about generators or list comprehensions? Curre

Re: [Tutor] sequence of elements problem

2013-11-08 Thread Mark Lawrence
On 08/11/2013 12:54, donsuni wrote: Hi, I have a problem in python which is kind of tricky. if i give a sequence of numbers, i should get another sequence of numbers such that the the elements exceeds previous element in the list. For eg seq_num([3,2,5,7])=[3,5,7] since 5 is >3, and 7>5 seq_num

[Tutor] sequence of elements problem

2013-11-08 Thread donsuni
Hi, I have a problem in python which is kind of tricky. if i give a sequence of numbers, i should get another sequence of numbers such that the the elements exceeds previous element in the list. For eg seq_num([3,2,5,7])=[3,5,7] since 5 is >3, and 7>5 seq_num([1,2,3,4])=[1,2,3,4] since 2 is >1,

Re: [Tutor] Finding a nearest perfect cube

2013-11-08 Thread Alan Gauld
On 08/11/13 10:12, Joel Goldstick wrote: inbuilt function or a for loop. Only while and if loops are allowed. This is confusing. What is an 'if loop'? I'm not sure why but this is a common mistake by beginners. I get a lot of emails about my tutorial that refer to "if loops" even though I n

Re: [Tutor] Finding a nearest perfect cube

2013-11-08 Thread Mark Lawrence
On 08/11/2013 10:12, Joel Goldstick wrote: On Fri, Nov 8, 2013 at 4:36 AM, Mark Lawrence wrote: On 07/11/2013 22:25, donsuni wrote: Hi, I am new to python and i have to write a following code without using any inbuilt function or a for loop. Only while and if loops are allowed. This is conf

Re: [Tutor] Finding a nearest perfect cube

2013-11-08 Thread Joel Goldstick
On Fri, Nov 8, 2013 at 4:36 AM, Mark Lawrence wrote: > On 07/11/2013 22:25, donsuni wrote: >> >> Hi, I am new to python and i have to write a following code without using >> any >> inbuilt function or a for loop. Only while and if loops are allowed. This is confusing. What is an 'if loop'? Of c

Re: [Tutor] Finding a nearest perfect cube

2013-11-08 Thread Mark Lawrence
On 07/11/2013 22:25, donsuni wrote: Hi, I am new to python and i have to write a following code without using any inbuilt function or a for loop. Only while and if loops are allowed. If i input a number, i should get a perfect cube nearest to it. For eg: if input=4, output=8 input=8, output=27 a