The program creates two sets x and y with values {10, 20, 30, 40, 50} and {40, 50, 60, 70, 80} respectively. The union method is then used to find the union of the two sets, i.e., all the elements that are present in either of the sets. The result of the union method is stored in the set z. Finally, the value of z is printed which contains all the elements from both sets, i.e., {10, 20, 30, 40, 50, 60, 70, 80}.
x = {10, 20, 30, 40, 50} y = {40, 50, 60, 70,80} z = x.union(y) print(z)
{70, 40, 10, 80, 50, 20, 60, 30}
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions