Robotics & Artificial Intelligence
In Python programming, it is an unordered collection data type that is iterable, mutable and has no duplicate elements. It is represented by { } where the values are enclosed in curly braces.
Read the above paragraph and answer the following questions:
(a) Name the data type that is used in Python.
(b) What will happen, if duplicate elements are present in this data types and executed?
Python Funda
3 Likes
Answer
(a) The data type used in Python is Set.
(b) If duplicate elements are present in a set and executed, the set will automatically remove the duplicates and retain only the unique values. This is because a set does not allow duplicate elements. For example, executing My_set = {"red", "blue", "green", "yellow", "blue", "green"} will result in {"red", "blue", "green", "yellow"} being stored, as the duplicate values "blue" and "green" are eliminated.
Answered By
3 Likes
Related Questions
Predict the output when executed:
Statement Output a = 24
m = float(a)
print(m)b = 32.86
n = int(b)
print(n)c = 3
p = complex(c)
print(p)Assertion (A): Variable is a named memory location which contains a value.
Reason (R): When you create a variable, it reserves some space in the memory.
Based on the above discussion, choose an appropriate statement from the options given below:
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true and R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
- Both A and R are false.
Write short notes on Indentation.
Write short notes on Assignment.