Write a Python program to Check if a specific value exists in a set


The code creates a set named "s" and assigns it the values 10, 20, 30, 40, and 50. Then, it uses the "in" operator to check if the value 60 is an element of the set "s". The "in" operator returns a Boolean value, indicating whether the specified value is present in the set or not. In this case, the value 60 is not present in the set "s", so the expression "60 in s" returns False. Next, the code checks if the value 30 is an element of the set "s". The value 30 is present in the set, so the expression "30 in s" returns True. Finally, the print statements display the results of the expressions "60 in s" and "30 in s".

Source Code

s = {10,20,30,40,50}
print(60 in s)
print(30 in s)

Output

False
True