Professional Documents
Culture Documents
d={"a":3,"b":7}
A. a dictionary d is created.
B. a and b are the keys of dictionary d.
C. 3 and 7 are the values of dictionary d
D. All of the above.
A. In python, a dictionary can have two same keys with different values.
B. In python, a dictionary can have two same values with different keys
C. In python, a dictionary can have two same keys or same values but cannot have
two same key-value pair
D. In python, a dictionary can neither have two same keys nor two same values.
d1={"abc":5,"def":6,"ghi":7}
print(d1[0])
A. abc
B. 5
C. {"abc":5}
D. Error
dict={"Phy":94,"Che":70,"Bio":82,"Eng":95}
dict.update({"Che":72,"Bio":80})
A. It will create new dictionary as dict={"Che":72,"Bio":80} and old dict will be
deleted.
B. It will throw an error as dictionary cannot be updated.
C. It will simply update the dictionary as
dict={"Phy":94,"Che":72,"Bio":80,"Eng":95}
D. It will not throw any error but it will not do any changes in dict
dict={"Joey":1,"Rachel":2}
dict.update({"Phoebe":2})
print(dict)
A. {"Joey":1,"Rachel":2,"Phoebe":2}
B. {"Joey":1,"Rachel":2}
C. {"Joey":1,"Phoebe":2}
D. Error
dic={"lion":"wild","tiger":"wild","cat":"domestic","dog":"domestic"}
A. del dic["tiger"]
B. dic["tiger"].delete()
C. delete(dic.["tiger"])
D. del(dic.["tiger"])
Suppose dict1={"a":1,"b":2,"c":3}
A. print(len(dict1))
B. print(dict1.get("b"))
C. dict1["a"]=5
D. None of these.
dict={"diary":1,"book":3,"novel":5}
A. i, ii, iii
B. i, ii
C. i, iii
D. ii, iii
dict1={"a":10,"b":2,"c":3}
str1=""
for i in dict1:
str1=str1+str(dict1[i])+" "
str2=str1[:-1]
print(str2[::-1])
A. 3, 2
B. 3, 2, 10
C. 3, 2, 01
D. Error
>>> b={}
>>> all(b)
a) { }
b) False
c) True
d) An exception is thrown
>>> a={"a":1,"b":2,"c":3}
>>> b=dict(zip(a.values(),a.keys()))
>>> b
a) {'a': 1, 'b': 2, 'c': 3}
b) An exception is thrown
c) {'a': 'b': 'c': }
d) {1: 'a', 2: 'b', 3: 'c'}
for i in count:
tot=tot+count[i]
print(len(count)+tot)
a) 25
b) 17
c) 16
d) Tuples can�t be made keys of a dictionary
a={}
a[2]=1
a[1]=[2,3,4]
print(a[1][1])
a) [2,3,4]
b) 3
c) 2
d) An exception is thrown
a)FLOAT
b)NUMERIC
c)DECIMAL
d)CHARACTER
a)Only 1
b)Only 2
c)Depends on no of Columns
d)Depends on DBA
a)ANY
b)BETWEEN
c)ALL
d)IN
a)UNIQUE
b)NOT NULL
c)CHECK
d)PRIMARY KEY
a)ROLLBACK
b)COMMIT
c)TRUNCATE
d)DELETE
a) 2 GFGNO
b) 2.33 GFGNOG
c) 2.33 GFGNONoneGTrue
d) 2.33 GFGNO
T = tuple('jeeps')
a, b, c, d, e = T
b = c = '*'
T = (a, b, c, d, e)
print(T)
a) (�j�, �*�, �*�, �p�, �s�)
b) (�j�, �e�, �e�, �p�, �s�)
c) (�jeeps�, �*�, �*�)
d) KeyError