You are on page 1of 12

View Question Bank

1 Correct Ans : D Added By : FC18084 September 30, 2021, 1:12 pm Edit


Which of the following is correct with respect to above Python code?

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.

2 Correct Ans : B Added By : FC18084 September 30, 2021, 1:12 pm Edit


Which one of the following is correct?

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.

3 Correct Ans : D Added By : FC18084 September 30, 2021, 1:13 pm Edit


What will be the output of above Python code?

d1={"abc":5,"def":6,"ghi":7}

print(d1[0])

A. abc
B. 5
C. {"abc":5}
D. Error

4 Correct Ans : C Added By : FC18084 October 1, 2021, 8:25 pm Edit


What will the above Python code do?

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

5 Correct Ans : A Added By : FC18084 October 1, 2021, 8:26 pm Edit


What will be the result of above Python code?

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

6 Correct Ans : C Added By : FC18084 September 30, 2021, 1:15 pm Edit


Which of the following is False regarding dictionary in Python?

A. Values of a dictionary can be string,integers or combination of both.


B. Keys of a dictionary can be string,integers or combination of both
C. The value of a dictionary can be accessed with the help of indices.
D. None of the above

7 Correct Ans : A Added By : FC18084 September 30, 2021, 1:15 pm Edit


Which of the following will delete key_value pair for key="tiger" in dictionary?

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"])

8 Correct Ans : D Added By : FC18084 September 30, 2021, 1:16 pm Edit


Which of the following will give error?

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.

9 Correct Ans : B Added By : FC18084 September 30, 2021, 1:16 pm Edit


Which of the following Python codes will give same output if
(i) dict.pop("book")
(ii) del dict["book"]
(iii) dict.update({"diary":1,"novel":5})

dict={"diary":1,"book":3,"novel":5}
A. i, ii, iii
B. i, ii
C. i, iii
D. ii, iii

10 Correct Ans : C Added By : FC18084 September 30, 2021, 1:17 pm Edit


What will be the following Python code?

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

11 Correct Ans : D Added By : FC18084 September 30, 2021, 1:18 pm Edit


What will be the output of the following Python code?

>>> a={i: i*i for i in range(6)}


>>> a
a) Dictionary comprehension doesn�t exist
b) {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6:36}
c) {0: 0, 1: 1, 4: 4, 9: 9, 16: 16, 25: 25}
d) {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25}

12 Correct Ans : C Added By : FC18084 September 30, 2021, 1:20 pm Edit


What will be the output of the following Python code?

>>> b={}
>>> all(b)
a) { }
b) False
c) True
d) An exception is thrown

13 Correct Ans : D Added By : FC18084 September 30, 2021, 1:21 pm Edit


What will be the output of the following Python code?

>>> 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'}

14 Correct Ans : A Added By : FC18084 September 30, 2021, 1:21 pm Edit


What will be the output?
a = {}
a[1] = 1
a['1'] = 2
a[1]= a[1]+1
count = 0
for i in a:
count += a[i]
print(count)
a)4
b)2
c)1
d)Error

15 Correct Ans : A Added By : FC18084 September 30, 2021, 1:22 pm Edit


What will be the output?
test = {1:'A', 2:'B', 3:'C'}
del test[1]
test[1] = 'D'
del test[2]
print(len(test))
a)2
b)1
c)0
d)Error

16 Correct Ans : B Added By : FC18084 September 30, 2021, 1:23 pm Edit


What will be the output?
a ={}
a['a']= 1
a['b']=[2, 3, 4]
print(a)
a){�b�: [2], �a�: 1}
b){�b�: [2, 3, 4], �a�: 1}
c){�b�: [2], �a�: [3]}
d)Error

17 Correct Ans : C Added By : FC18084 September 30, 2021, 1:30 pm Edit


What is the output of the following program?
D = dict()
for x in enumerate(range(2)):
D[x[0]] = x[1]
D[x[1]+7] = x[0]
print(D)
a) KeyError
b) {0: 1, 7: 0, 1: 1, 8: 0}
c) {0: 0, 7: 0, 1: 1, 8: 1}
d) {1: 1, 7: 2, 0: 1, 8: 1}

18 Correct Ans : D Added By : FC18084 September 30, 2021, 1:31 pm Edit


What is the output of the following program?
D = {1 : {'A' : {1 : "A"}, 2 : "B"}, 3 :"C", 'B' : "D", "D": 'E'}
print(D[D[D[1][2]]], end = " ")
print(D[D[1]["A"][2]])
a) D C
b) E B
c) D B
d) E KeyError

19 Correct Ans : B Added By : FC18084 September 30, 2021, 1:32 pm Edit


What is the output of the following program?
D = dict()
for i in range (3):
for j in range(2):
D[i] = j
print(D)
a) {0: 0, 1: 0, 2: 0}
b) {0: 1, 1: 1, 2: 1}
c) {0: 0, 1: 0, 2: 0, 0: 1, 1: 1, 2: 1}
d) TypeError: Immutable object

20 Correct Ans : D Added By : FC18084 September 30, 2021, 1:32 pm Edit


Which of the options below could possibly be the output of the following program?
D = {1 : [1, 2, 3], 2: (4, 6, 8)}
D[1].append(4)
print(D[1], end = " ")
L = list(D[2])
L.append(10)
D[2] = tuple(L)
print(D[2])
a) [1, 2, 3, 4] [4, 6, 8, 10]
b) [1, 2, 3] (4, 6, 8)
c) �[1, 2, 3, 4] TypeError: tuples are immutable
d) [1, 2, 3, 4] (4, 6, 8, 10)

21 Correct Ans : C Added By : FC18084 September 30, 2021, 1:41 pm Edit


What will be the output of the following Python code?
count={}
count[(1,2,4)] = 5
count[(4,2,1)] = 7
count[(1,2)] = 6
count[(4,2,1)] = 2
tot = 0

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

22 Correct Ans : B Added By : FC18084 September 30, 2021, 1:42 pm Edit


What is the output of the following code?

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

23 Correct Ans : D Added By : FC18084 September 30, 2021, 1:42 pm Edit


What will be the output of the following Python code?
a={i: i*i for i in range(6)}
print (a)

a) Dictionary comprehension doesn�t exist


b) {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6:36}
c) {0: 0, 1: 1, 4: 4, 9: 9, 16: 16, 25: 25}
d) {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25}

24 Correct Ans : C Added By : FC18084 September 30, 2021, 1:45 pm Edit


Which of the statements about dictionary values if false?

a) More than one key can have the same value


b) The values of the dictionary can be accessed as dict[key]
c) Values of a dictionary must be unique
d) Values of a dictionary can be a mixture of letters and numbers

25 Correct Ans : D Added By : FC18084 September 30, 2021, 1:46 pm Edit


What will be the output of the following Python code snippet?
numbers = {}
letters = {}
comb = {}
numbers[1] = 56
numbers[3] = 7
letters[4] = 'B'
comb['Numbers'] = numbers
comb['Letters'] = letters
print(comb)

a) Error, dictionary in a dictionary can�t exist


b) �Numbers�: {1: 56, 3: 7}
c) {�Numbers�: {1: 56}, �Letters�: {4: �B�}}
d) {�Numbers�: {1: 56, 3: 7}, �Letters�: {4: �B�}}

26 Correct Ans : C Added By : FC18084 October 1, 2021, 8:01 pm Edit


Which of the following is used for variable length storage with maximum
length of 4,000 characters?
a)NCHAR
b)NTEXT
c)NVARCHAR
d)NBARCHAR(MAX)

27 Correct Ans : A Added By : FC18084 October 1, 2021, 8:01 pm Edit


Which sequence of commands is used to replace the records of employee
who was getting highest salary with an employee who was getting second highest
salary when the first one quits the job?
a)SELECT,DELETE,UPDATE
b)DELETE,SELECT,INSERT
c)INSERT,DELETE,UPDATE
d)UPDATE,SELECT,DELETE

28 Correct Ans : D Added By : FC18084 October 1, 2021, 8:02 pm Edit


What we cannot do with an alter command statement?
a)Rename a field
b)Modify a field
c)Add a field
d)Modify a field value

29 Correct Ans : C Added By : FC18084 October 1, 2021, 8:03 pm Edit


Which of the following is not a valid SQL type?

a)FLOAT
b)NUMERIC
c)DECIMAL
d)CHARACTER

30 Correct Ans : B Added By : FC18084 October 1, 2021, 8:03 pm Edit


What is the full form of SQL?

a)Structured Query List


b)Structure Query Language
c)Sample Query Language
d)None of these.

31 Correct Ans : D Added By : FC18084 October 1, 2021, 8:04 pm Edit


Which of the following is not a DDL command?
a)TRUNCATE
b)ALTER
c)CREATE
d)UPDATE

32 Correct Ans : A Added By : FC18084 October 1, 2021, 8:05 pm Edit


Which of the following are TCL commands?

a)COMMIT and ROLLBACK


b)UPDATE and TRUNCATE
c)SELECT and INSERT
d)GRANT and REVOKE

33 Correct Ans : A Added By : FC18084 October 1, 2021, 8:05 pm Edit


How many Primary keys can have in a table?

a)Only 1
b)Only 2
c)Depends on no of Columns
d)Depends on DBA

34 Correct Ans : D Added By : FC18084 October 1, 2021, 8:06 pm Edit


Which operator is used to compare a value to a specified list of values?

a)ANY
b)BETWEEN
c)ALL
d)IN

35 Correct Ans : B Added By : FC18084 October 1, 2021, 8:07 pm Edit


______ is a constraint that can be defined only at the column level?

a)UNIQUE
b)NOT NULL
c)CHECK
d)PRIMARY KEY

36 Correct Ans : B Added By : FC18084 October 1, 2021, 8:07 pm Edit


_________ command makes the updates performed by the transaction permanent in the
database?

a)ROLLBACK
b)COMMIT
c)TRUNCATE
d)DELETE

37 Correct Ans : A Added By : FC18084 October 1, 2021, 8:08 pm Edit


Which of the following SQL clauses is used to DELETE tuples from a database table?
a) DELETE
b) REMOVE
c) DROP
d) CLEAR

38 Correct Ans : D Added By : FC18084 October 1, 2021, 8:08 pm Edit


___________removes all rows from a table without logging the individual row
deletions.
a) DELETE
b) REMOVE
c) DROP
d) TRUNCATE

39 Correct Ans : B Added By : FC18084 October 1, 2021, 8:09 pm Edit


________________ is not a category of SQL command.
a) TCL
b) SCL
c) DCL
d) DDL

40 Correct Ans : A Added By : FC18084 October 1, 2021, 8:10 pm Edit


Which of the following statement is true?
a) DELETE does not free the space containing the table and TRUNCATE free the space
containing the table
b) Both DELETE and TRUNCATE free the space containing the table
c) Both DELETE and TRUNCATE does not free the space containing the table
d) DELETE free the space containing the table and TRUNCATE does not free the space
containing the table

41 Correct Ans : D Added By : FC18084 October 1, 2021, 8:12 pm Edit


What does DML stand for?
a) Different Mode Level
b) Data Model Language
c) Data Mode Lane
d) Data Manipulation language

42 Correct Ans : D Added By : FC18084 October 1, 2021, 8:12 pm Edit


The command to remove rows from a table �CUSTOMER� is __________________
a) DROP FROM CUSTOMER
b) UPDATE FROM CUSTOMER
c) REMOVE FROM CUSTOMER
d) DELETE FROM CUSTOMER WHERE
43 Correct Ans : B Added By : FC18084 October 1, 2021, 8:13 pm Edit
Point out the wrong statement.
a) You cannot drop a database currently being used
b) A database cannot be dropped regardless of its state
c) Any database snapshots on a database must be dropped before the database can be
dropped
d) None of the mentioned

44 Correct Ans : A Added By : FC18084 October 1, 2021, 8:14 pm Edit


Features provided by ALTER DATABASE statement do not include ____________
a) Deletes database
b) Modifies file
c) Changes the attributes of a database
d) Changes the database collation

45 Correct Ans : B Added By : FC18084 October 1, 2021, 8:14 pm Edit


Which of the following data types does the SQL standard not support?
a) char(n)
b) String(n)
c) varchar(n)
d) float(n)

46 Correct Ans : A Added By : FC18084 October 1, 2021, 8:15 pm Edit


Which of the following commands do we use to delete a relation (R) from a database?
a) drop table R
b) drop relation R
c) delete table R
d) delete from R

47 Correct Ans : C Added By : FC18084 October 1, 2021, 8:15 pm Edit


Which of the following commands do we use to delete all the tuples from a relation
(R)?
a) delete table R
b) drop table R
c) delete from R
d) drop from R

48 Correct Ans : C Added By : FC18084 October 1, 2021, 8:16 pm Edit


create table apartment(ownerID varchar (5), ownername varchar(25), floor
numeric(4,0), primary key (ownerID));
Choose the correct option regarding the above statement
a) The statement is syntactically wrong
b) It creates a relation with three attributes ownerID, ownername, floor in which
floor cannot be null.
c) It creates a relation with three attributes ownerID, ownername, floor in which
ownerID cannot be null.
d) It creates a relation with three attributes ownerID, ownername, floor in which
ownername must consist of at least 25 characters.
49 Correct Ans : C Added By : FC18084 October 1, 2021, 8:16 pm Edit
What does the not null integrity constraint do?
a) It ensures that at least one tuple is present in the relation
b) It ensures that at least one foreign key is present in the relation
c) It ensures that all tuples have a finite value on a specified attribute
d) It ensures that all tuples have finite attributes on all the relations

50 Correct Ans : A Added By : FC18084 October 1, 2021, 8:17 pm Edit


What is a timestamp?
a) A combination of date and time with date first
b) A combination of date and time with time first
c) A combination of time and place with time first
d) A combination of time and place with place first

51 Correct Ans : B Added By : FC18084 October 5, 2021, 2:08 pm Edit


The attribute value that is currently unknown is:
A)0
B)NULL
C)''
D)-1

52 Correct Ans : A Added By : FC18084 October 5, 2021, 2:11 pm Edit


Which one are not the integrity constraints?
A) identical
B) not null
C) unique
D) none of these

53 Correct Ans : B Added By : FC18084 October 5, 2021, 2:11 pm Edit


Which of the following _____is preferred method for enforcing data integrity?
A) stored procedure
B) constraints
C) cursor
D) none of these

54 Correct Ans : B Added By : FC18084 October 5, 2021, 2:12 pm Edit


The data which is processed and organized and can be used for decision making
purposes is called:
a)data
b)knowldedge
c) information
d)result

55 Correct Ans : A Added By : FC18084 October 5, 2021, 2:13 pm Edit


The feature that enables multiple users to use a same application at a same time is
called as:
a)concurrency
b)availability
c)integrity
d)accuracy
56 Correct Ans : C Added By : FC18084 October 5, 2021, 2:14 pm Edit
What is the output of the following program?
L1 = list()
L1.append([1, [2, 3], 4])
L1.extend([7, 8, 9])
print(L1[0][1][1] + L1[2])

a) Type Error: can only concatenate list (not �int�) to list


b) 12
c) 11
d) 38

57 Correct Ans : D Added By : FC18084 October 5, 2021, 2:16 pm Edit


What is the output of the following program?
L1 = [1, 1.33, 'GFG', 0, 'NO', None, 'G', True]
val1, val2 = 0, ''
for x in L1:
if(type(x) == int or type(x) == float):
val1 += x
elif(type(x) == str):
val2 += x
else:
break
print(val1, val2)

a) 2 GFGNO
b) 2.33 GFGNOG
c) 2.33 GFGNONoneGTrue
d) 2.33 GFGNO

58 Correct Ans : A Added By : FC18084 October 5, 2021, 2:17 pm Edit


What is the output of the following program?

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

59 Correct Ans : D Added By : FC18084 October 5, 2021, 2:18 pm Edit


What is the value of L at the end of execution of the following program?
L = [2e-04, 'a', False, 87]
T = (6.22, 'boy', True, 554)
for i in range(len(L)):
if L[i]:
L[i] = L[i] + T[i]
else:
T[i] = L[i] + T[i]
break
a) [6.222e-04, �aboy�, True, 641]
b) [6.2202, �aboy�, 1, 641]
c) [6.2202, �aboy�, True, 87]
d) [6.2202, �aboy�, False, 87]

60 Correct Ans : B Added By : FC18084 October 5, 2021, 2:18 pm Edit


Suppose t = (1, 2, 4, 3), which of the following is incorrect?
a) print(t[3])
b) t[3] = 45
c) print(max(t))
d) print(len(t))

You might also like