Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

check if number is prime

def check_if_prime():
    number = int(input("Enter number: "))
    
    prime_lists = [1,2,3]
    
    divisible_by = []
    if number in prime_lists:
        return divisible_by
    
    if number==0:
        return None
    
    for i in range(2,number):
        
        if number%i==0:
            divisible_by.append(i)
            
    return divisible_by
        
    
check_if_prime()
Comment

identify if a number is prime

def prime():
  prime=True
  while True:
   for i in range(2,x-1):
      y=x%i
      if (y==0):
        prime=False
   break
  if (x==0) or (x==1):
    print(x , "is not a prime number")
  elif (prime==True):
    print(x , "is a prime number")
  else:
    print(x , "is not a prime number")
x=int(input("Enter a number:"))
prime()
Comment

PREVIOUS NEXT
Code Example
Python :: how to get runtime of a function in python 
Python :: diccionario python 
Python :: how to clear combobox tkinter 
Python :: comment multiple lines python 
Python :: camp cretaceous.com 
Python :: coding 
Python :: print something python 
Python :: 1024x768 
Python :: python suppress print output from function 
Python :: how to remove text in pygame 
Python :: how to make a operating system in python 
Python :: combine for and if python 
Python :: tkinter bind function with arguments 
Python :: propositional logic python 
Python :: Mixed Fractions in python 
Python :: show only lower diagonal in sns pairplot 
Python :: how to use visualize_runtimes 
Python :: multiclasshead 
Python :: Convert the below Series to pandas datetime : DoB = pd.Series(["07Sep59","01Jan55","15Dec47","11Jul42"]) 
Python :: check stl file for errors in pyvista 
Python :: rapids - convert nerworkx to cugraph 
Shell :: FirewallD is not running 
Shell :: npm install upgrade react version react-scripts 
Shell :: update google chrome command ubuntu 
Shell :: check gnome version 
Shell :: date linux format yyyymmdd 
Shell :: install nvm with brew 
Shell :: dns flush 
Shell :: sudo: aptitude: command not found 
Shell :: git reset all submodules 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =