codescracker


python

Python Program to Find Different Set of Mathematical Operations



« Previous Program Next Program »


Find Different Set of Mathematical Operations in Python

To find different set of mathematical operations in python such as union, intersection, difference, symmetric difference, you have to choose two set of numbers and perform the desired operations as shown in the program given here.

Python Programming Code to Add Two Numbers

Following python program choose two set of numbers and then find the different set of mathematical operations:

# Python Program - Find Different Set of Mathematical Operations
		
A = {0, 2, 4, 6, 8}
B = {1, 2, 3, 4, 5}
while True:
	print("Union of A and B =", A | B)
	print("Intersection of A and B =", A & B)
	print("Difference of A and B =", A - B)
	print("Symmetric difference of A and B =", A ^ B)
	print("\nWant to to watch again ? (y/n): ")
	check = input()
	if check == 'n':
		break

Here is the sample run of the above Python program:

python find difference set of mathematical operations

« Previous Program Next Program »




Tools
Calculator

Quick Links
Signup - Login - Give Online Test