Vote count: 0
I created a program that works out primes. It was just a test but I thought it would be interesting to then plot this on a graph.
import matplotlib.pyplot as plt
max = int(input("What is your max no?: "))
primeList = []
for x in range(2, max + 1):
isPrime = True
for y in range (2 , int(x ** 0.5) + 1):
if x % y == 0:
isPrime = False
break
if isPrime:
primeList.append(x)
print(primeList)
How can I then plot primeList, can I do it all at once outside of the for loop?
asked 1 min ago
How do I plot a list all at once with matplotlib.pyplot?
Aucun commentaire:
Enregistrer un commentaire