Python Assignment
Python Assignment
Python Assignment
nums = set([1,1,2,3,3,3,4,4])
print(len(nums))
a) 7
b) Error, invalid syntax for formation of set
c) 4
d) 8
a={1,2,3}
b=a
b.remove(3)
print(a)
a) {1,2,3}
b) Error, copying of sets isn’t allowed
c) {1,2}
d) Error, invalid syntax for remove
a={3,4,{7,5}}
print(a[2][0])
a) Yes, 7 is printed
b) Error, elements of a set can’t be printed
c) Error, subsets aren’t allowed
d) Yes, {7,5} is printed
a={4,5,6}
b={2,8,6}
print(a+b)
a) {4,5,6,2,8}
b) {4,5,6,2,8,6}
c) Error as unsupported operand type for sets
d) Error as the duplicate item 6 is present in both sets
10]What is the output?
d ={"john":40, "peter":45}
print(d["john"])
a) 40
b) 45
c) “john”
d) “peter”
a) snow
b) snow world
c) Error
d) snos world
a) 2
b) 0
c) 1
d) none of the mentioned
print("abcdef".find("cd"))
a) True
b) 2
c) 3
d) None of the mentioned