If ``a = [1, 1, 2, 3, 3, 6,6,4]``. What is set(a)
Answers
I think the answer is:
a={1,2,3,4,6}
The output of the following códe will be {1, 2, 3, 4, 6}
The códe will be written like this
a = [1, 1, 2, 3, 3, 6, 6, 4]
print(set(a))
Explanation
In this códe
a = [1, 1, 2, 3, 3, 6, 6, 4]
print(set(a))
a is a list.
set() method is used to remove duplicate elements from a list.
Extra Information
A list contains python objects and objects inside are separated by comma (,) and enclosed within square brackets.
List can contain values of the types Integers, Floats, Lists, and Tuples.
Integer Values such as the whole numbers can be positive, negative and zero. Example => 5, 6, 7, -8, 0 etc.
Float values are those values that consist of decimal numbers. Example => 5.25, 9.187 etc.
Examples of print() statement
print("Hello World")
Output
Hello World
print(5/2)
Output
2.5
x = ("apple", "banana", "cherry")
print(x)
Output
('apple', 'banana', 'cherry')
Python is created by Guido van Rossum and came into existence in 1991. It is a high-level and general programming language. It is a very lucid programming language as it has a good language construct and object-oriented approach. It is dynamically typed and garbage-collected.