14,599,947 members

# Welcome to the Lounge

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 Re: Any Data Analytics expert here? MehreenTahir20-Mar-20 4:37 MehreenTahir 20-Mar-20 4:37
 The cloud-based, alexa-compatible wrong-forum AI is on good form, today Mark_Wallace19-Mar-20 21:47 Mark_Wallace 19-Mar-20 21:47
 Commit strip OTD: Stay At Home! OriginalGriff19-Mar-20 21:16 OriginalGriff 19-Mar-20 21:16
 Re: Commit strip OTD: Stay At Home! Mark_Wallace19-Mar-20 21:49 Mark_Wallace 19-Mar-20 21:49
 Re: Commit strip OTD: Stay At Home! CodeWraith19-Mar-20 22:45 CodeWraith 19-Mar-20 22:45
 Re: Commit strip OTD: Stay At Home! Ravi Bhavnani19-Mar-20 22:46 Ravi Bhavnani 19-Mar-20 22:46
 Phantom Planet - "Quarantine 20/20" abmv19-Mar-20 21:10 abmv 19-Mar-20 21:10
 Need help interpretting this Python prime number code ryfoa619-Mar-20 20:09 ryfoa6 19-Mar-20 20:09
 The assignment is to write a function that returns the number of prime numbers that exist up to and including a given number. The solution is below but I'm having trouble interpreting it. The part I don't understand is the 'for y in range(3,x,2)' loop. The first time it runs, x = 3 so I see it as 'range(3,3,2) but this doesn't make sense because the middle number represents up to but not including. So a range of 3-2 doesn't make sense. Also why is 'else:' not lined up with 'if'? ```def count_primes2(num): primes = [2] x = 3 if num < 2: return 0 while x <= num: for y in primes: # use the primes list! if x%y == 0: x += 2 break else: primes.append(x) x += 2 print(primes) return len(primes)```
 Re: Need help interpretting this Python prime number code OriginalGriff19-Mar-20 20:45 OriginalGriff 19-Mar-20 20:45
 Re: Need help interpretting this Python prime number code CPallini19-Mar-20 21:36 CPallini 19-Mar-20 21:36
 Re: Need help interpretting this Python prime number code   Forogar  20-Mar-20 3:18 Forogar 20-Mar-20 3:18
 A Topical Song Rick York19-Mar-20 14:09 Rick York 19-Mar-20 14:09
 Re: A Topical Song phil.o19-Mar-20 14:40 phil.o 19-Mar-20 14:40
 Re: A Topical Song Rick York19-Mar-20 18:01 Rick York 19-Mar-20 18:01
 Re: A Topical Song GenJerDan19-Mar-20 22:39 GenJerDan 19-Mar-20 22:39
 Re: A Topical Song dandy7220-Mar-20 6:57 dandy72 20-Mar-20 6:57
 Re: A Topical Song phil.o20-Mar-20 7:29 phil.o 20-Mar-20 7:29
 Re: A Topical Song OriginalGriff19-Mar-20 20:52 OriginalGriff 19-Mar-20 20:52
 Re: A Topical Song Graeme Henderson19-Mar-20 22:03 Graeme Henderson 19-Mar-20 22:03
 Re: A Topical Song 5teveH19-Mar-20 22:42 5teveH 19-Mar-20 22:42
 Re: A Topical Song jsc4220-Mar-20 1:04 jsc42 20-Mar-20 1:04
 Re: A Topical Song Mike Hankey20-Mar-20 4:22 Mike Hankey 20-Mar-20 4:22
 Re: A Topical Song jeron120-Mar-20 10:37 jeron1 20-Mar-20 10:37
 Re: A Topical Song Richard Deeming23-Mar-20 0:57 Richard Deeming 23-Mar-20 0:57
 Re: A Topical Song Rick York23-Mar-20 4:43 Rick York 23-Mar-20 4:43
 Last Visit: 4-Aug-20 5:07     Last Update: 4-Aug-20 5:07 Refresh ᐊ Prev1...663664665666667668669670671672 Next ᐅ