# USING PYTHON GENERATE PRIME NUMBERS AND SET OPERATIONS!!!

|ODD PRIME NUMBERS||SET OPERATIONS|

In this program, we going to generate a set of prime numbers and another set of odd numbers and displaying the result of set operations.

- First, we are using the variable
If we use a set bracket the answer will be displayed in a set bracket({}).*”odd”.* - And inside that set bracket, we have given list terms
this is the logic this means that we going to generate odd numbers; And we have given*”x*2+1”,*which means it takes a value from*”for x in range(0,5)”,*the odd numbers will be generated.*“0 to 4”*

The logic of “x*2+1” →if value of x=1

→1*2+1

→3 ,so here we get “odd numbers”

~like that the odd numbers will be generated.

- Next, we are going to create an empty set to store prime numbers
; And then we are generating a for a loop.*” primes =set()”*which means it takes value from*” for i in range(2,10):”*because we are generating values up to*“2 to 9”*.*“10”* - Now we are going to see the prime number concept, we are going to take two variables i and j and we have to check
if we get remainder*“i/j “*it is not a prime number;*“0”*given inside the loop will act as*“f=0”**“flag”.*

# FLAG:

A **flag in Python** acts as a signal to the program to determine whether or not the program as a whole or a specific section of the program should run. In other words, you can set the **flag** to True and the program will run continuously until any type of event makes it False.

Next,

→to check prime number“while j≤i/2:”Then

→selection statement“if i%j==0:”

So, we give the value of i=2 and j=2:

→2/2=0

~Remainder is ** “0”**; likewise we can check for all the numbers.

- Then,
is not a prime number.*“f=1”*

→

”j+=1”→”if f ==0:”

→”primes.add(i)”

- Here, if f value is
it will not go inside*“1”*”; If f value is*“if statement*it checks with*“0”*, then it will add prime number*“if statement”**“primes.add(i)”.*

~Like this it will repeat the process till ”9”

- Then, we going to print odd numbers, prime numbers, union, intersection, difference, symmetric difference.