A downloadable tool

A program that can check if a number is prime. Can be run on anything that can run Python files. Figure it out yourself.

Prime - Checks if one number is prime.

Primes for multiple - Checks if multiple numbers are prime.

Download

Download
Prime 1 kB
Download
Primes for multiple 1 kB

Install instructions

Python file, can be run on anything capable of running python files.

Development log

Comments

Log in with itch.io to leave a comment.

(1 edit)

cool, can be written simpler in 2 lines as:
number = int(input("enter number here: ")
print(len([x for x in list(range(1, number)) if number%x==0]) == 0)
and you can look into making it an exexutable using pyinstaller so it can run on any machine even those which dont have python

Thanks, I don’t know enough about python to understand what I just read there but thanks! So how are you removing all the indentations? And since when were brackets used?

here's an explanation for that code, int() is used to turn the string that you get from the input into string, len() is a function o get the length of an iterable object in this case a list, [] brackets to make a list but in this case its a list made from a generator (the text inside the brackets "x for x in" is to make the generator, generators are somewhat advanced but u need to look into them cuz they are helpful) list() to turn the get a list from the range() function which takes numbers from 0 to the number you specified which in our case is the variable "number" inputed, then an if statement for the generator which add numbers to this list if number%x==0 meaning if dividing the number variable by x for every x smaller than the number, if dividing that number by x has to left over we add it to that list, and in the end the len() function to see if that list is empty meaning no number smaller than "number" can divide it with no left over meaning its a prime number, i know u still dont understand it but if u look into the keywords i mentioned here u may start to understand some of it and gain more experience on python cuz the tools i used here are very useful to python

How are you doing “x for x in list”? Isn’t the way a for statement is setup like this? “for x in list”. I don’t understand what the x variable before the for statement is doing. Also thx for explaining

it is a way of setting up a generator class, but for your case we dont need the generator class really we just need to get a list out of it, so to set a generator we say (x for x in [*some list or any iterable object*]) and it would return a generator class but we need the list from it so we put it inside list() function, but i generally use the generator to shorten code as ill give u an example, we can write this bit of code as this:

names_list = [*some names*] 
result_list = []
for name in names_list:
        if name.startswith("t"): #to check if  a name starts with the letter t
                result_list.append(name)
print(result_list)

we can instead write all of this code as one line of code:

print( list( (name for name in [*some names*] if name.startswith("t") ) ) )

which may look abit complicated but again u would wrap ur head better around it if you look into how generators in python work, and from this i see you need to look into a lot of basic concepts in python as they really make coding in python much faster and easier (even if a bit harder to read) plus dont forget to also look into pyinstaller to transform ur code from a .py to an .exe that can run on any machine even those which dont have python like all of the projects on my profile, all of then are .exe that can run on all machines even tho every project i made is made on python.

(+1)

Thanks a ton! I’ll make sure to look into these “generator” things, as for pyinstaller, I code on a Chromebook. Which can’t run .exe files unfortunately.