human
What is a code to numbers with exactly 3 divisors and the other steps required given the following:
Numbers with exactly 3 divisors | Generates all primes upto n and prints their squares.
If prime [ p ] is not changed , then it is a prime.
Update all multiples of p.
print squares of primes upto n ..
Driver program"
How can the above be solved in Python?
assistant
#Here is code to numbers with exactly 3 divisors and the other steps required.
 def numbersWith3Divisors ( n ) :
	prime = [ True ] * ( n + 1 ) ;
	prime [ 0 ] = prime [ 1 ] = False ;
	p = 2 ;
	while ( p * p <= n ) :
		if ( prime [ p ] == True ) :
			for i in range ( p * 2 , n + 1 , p ) :
				prime [ i ] = False ;
		p += 1 ;
	print ( " Numbers ▁ with ▁ 3 ▁ divisors ▁ : " ) ;
	i = 0 ;
	while ( i * i <= n ) :
		if ( prime [ i ] ) :
			print ( i * i , end = " ▁ " ) ;
		i += 1 ;
n = 96 ;
numbersWith3Divisors ( n ) ;