x=0(adsbygoogle = window.adsbygoogle || []).push({});

y = raw_input("""Up to what number would you like to locate primes?: """)

for i in range(int(y)):

x = x + 1

if x%2 and x%3 and x%5 and x%7:

print x, '--> PRIME'

elif x==2 or x==3 or x==5 or x==7:

print x, '--> PRIME'

elif x==1:

print x

else:

print x

I've been on break for the last week and a half and I thought I would spend my time learning Python. I wrote this little script earlier tonight that simply prints out a list of integers within a user specified range and identifies which of them are prime. What I want to do but can't seem to find any documentation on is to have the script count the occurrences of the primes and echo a "There were (blank) number of primes within your specified interval." I have no idea where to look for that sort of thing. I don't want an answer but I would like someone to point me in the direction I need to be going in.

As always,

Thanks.

P.S. This does work, I just want to make it 'better'.

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Trying to teach myself Python

Loading...

Similar Threads - Trying teach myself | Date |
---|---|

Has anyone tried to train a neural network to learn physics? | Jan 12, 2018 |

Where should I try for learning programming? | Dec 22, 2017 |

Which programming language would you want to teach to a very young person (5-7 y/o) | Nov 14, 2017 |

C/++/# Trying to compile a source code in C | Feb 14, 2017 |

Trying to download AUTO | Feb 13, 2017 |

**Physics Forums - The Fusion of Science and Community**