Respuesta :
Study the for statement carefully!
```
#!/usr/local/bin/python3
import sys, math
def is_prime( number ):
if( number % 2 == 0 ):
return False
else:
for i in range( 3, int( math.sqrt( number ) ) + 1, 2 ):
if( number % i == 0 ):
return False
return True
if( __name__ == "__main__" ):
if( len( sys.argv ) != 2 ):
sys.stderr.write( "\nusage: " + sys.argv[ 0 ] + " <integer>\n\n" )
exit( 127 )
print( is_prime( int( sys.argv[ 1 ] ) ) )
```
```
#!/usr/local/bin/python3
import sys, math
def is_prime( number ):
if( number % 2 == 0 ):
return False
else:
for i in range( 3, int( math.sqrt( number ) ) + 1, 2 ):
if( number % i == 0 ):
return False
return True
if( __name__ == "__main__" ):
if( len( sys.argv ) != 2 ):
sys.stderr.write( "\nusage: " + sys.argv[ 0 ] + " <integer>\n\n" )
exit( 127 )
print( is_prime( int( sys.argv[ 1 ] ) ) )
```
The program is an illustration of loops.
Loops are used to carry out repetition operations; examples are the for-loop and the while-loop.
The program in Python, where comments are used to explain each line is as follows:
#This defines the function
def is_prime(num):
#This iterates from 2 to the number
for i in range(2,num):
#If the number has a factor
if( num % i == 0 ):
#This returns False
return False
#And the loop is exited
break
#If there are no factors
else:
#This returns True
return True
The above program is implemented using a for loop
Read more about similar programs at:
https://brainly.com/question/15263759