Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'value,': 0.03; 'elements.': 0.05; 'assign': 0.07; 'subject:two': 0.07; 'python': 0.09; 'any.': 0.09; 'calculates': 0.09; 'successive': 0.09; 'cc:addr:python-list': 0.10; 'itself.': 0.11; 'useful,': 0.13; 'advance.': 0.15; 'value.': 0.15; '24,': 0.16; 'iterable,': 0.16; 'mine.': 0.16; 'progression': 0.16; 'subject:Problems': 0.16; 'subject:questions': 0.16; 'subject:these': 0.16; 'thread.': 0.16; 'wrote:': 0.17; 'integer': 0.17; '(or': 0.18; 'variable': 0.20; 'help.': 0.22; 'cc:2**0': 0.23; 'elements': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'arithmetic': 0.29; 'factor': 0.29; 'function': 0.30; 'function.': 0.33; 'problem': 0.33; 'version': 0.34; 'thanks': 0.34; 'built-in': 0.35; 'problem,': 0.35; 'same.': 0.35; 'sequence': 0.35; 'pm,': 0.35; 'but': 0.36; '12,': 0.36; 'problems': 0.36; 'two': 0.37; 'subject:: ': 0.38; 'positive': 0.38; 'advice': 0.39; 'takes': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'end': 0.40; "you've": 0.61; 'distance': 0.62; 'between': 0.63; 'show': 0.63; 'sum': 0.66; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'sounds': 0.71; 'reply-to:no real name:2**0': 0.72; '2.an': 0.84; 'attempt,': 0.84; 'good,': 0.91; 'factors': 0.95 Date: Sun, 18 Nov 2012 21:18:19 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 MIME-Version: 1.0 To: su29090 <129km09@gmail.com> Subject: Re: Problems on these two questions References: <400c615f-4d93-4b8b-85ec-1bb4c47e30fe@googlegroups.com> In-Reply-To: <400c615f-4d93-4b8b-85ec-1bb4c47e30fe@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:7xDKvXouGaQ2jjzOhNIAdGZxC6iWI4OqQMvhr08sPn9 /shoioXKDdDdHnkLJ/cmBU6SBItvD0ispl3fBZX8WTLB17iIJg sDCx2GHGGJpgaZALF6FvCCQNLf6s/41T2Sbwip9RpDSu28r9b1 EIWfhfha6ct0ccceM5NC0Fv0KTMhmTrYiIg6Xs+S+KwT9SrllO U42tzHEtrh4zUSwendLktcDwrdjJ91HnvpdnQEcrhjBmA6INha JMLCMr0KMeFzeua8aghTrSubu2f+rdRI7YKT67Irj/kCMg5Jj/ kEu1Snmh1HiYEwn9gzl+6ruSRB3JfybZjcBSd1RzqPKjXih0Q= = Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: d@davea.name List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1353291523 news.xs4all.nl 6870 [2001:888:2000:d::a6]:40072 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33525 On 11/18/2012 08:52 PM, su29090 wrote: > I all of the other problems but I have issues with these: > > 1.Given a positive integer n , assign True to is_prime if n has no factors other than 1 and itself. (Remember, m is a factor of n if m divides n evenly.) if is_a_prime(n): is_prime = True Now all you have to do is write is_a_prime(). if you get stuck, please show us what you've got, and what the problem is with it. And as usual, tell us what version of Python you're writing in, if any. > 2.An arithmetic progression is a sequence of numbers in which the distance (or difference) between any two successive numbers if the same. This in the sequence 1, 3, 5, 7, ... , the distance is 2 while in the sequence 6, 12, 18, 24, ... , the distance is 6. > > Given the positive integer distance and the positive integer n , associate the variable sum with the sum of the elements of the arithmetic progression from 1 to n with distance distance . For example, if distance is 2 and n is 10 , then sum would be associated with 26 because 1+3+5+7+9 = 25 . Don't call it 'sum' since that's a built-in function. Coincidentally, it's a function that takes an iterable, and calculates the sum of its elements. Sounds useful, no? The other thing you might want is xrange, which takes a start value, and end value, and a distance value. > > Thanks in advance. You never responded to any of the messages in the other thread. But Chris's advice was good, and better worded than mine. Pick a problem, make an attempt, then ask for help. -- DaveA