Suppose d = {“john”:40, “peter”:45}. To obtain the number of entries in dictionary  which command do we use?
a) d.size()
b) len(d)
c) size(d)
d) d.len()

1 Answer

Answer :

b) len(d)

Related questions

Description : Suppose d = {“john”:40, “peter”:45}, to delete the entry for “john” what command do we use a) d.delete(“john”:40) b) d.delete(“john”) c) del d[“john”]. d) del d(“john”:40)

Last Answer : c) del d[“john”].

Description : Suppose d = { john :40, peter :45}, what happens when we try to retrieve a value using the expression d[ susan ]? a) Since susan is not a value in the set, Python raises a KeyError ... Python raises a KeyError exception d) Since susan is not a key in the set, Python raises a syntax error

Last Answer : c) Since “susan” is not a key in the set, Python raises a KeyError exception

Description : Which of the following statements create a dictionary? a) d = {} b) d = {“john”:40, “peter”:45} c) d = {40:”john”, 45:”peter”} d) All of the mentioned

Last Answer : d) All of the mentioned

Description : 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))

Last Answer : b) t[3] = 45

Description : Which of the following statements create a dictionary? a) d = {} b) d = {“john”:40, “peter”:45} c) d = {40:”john”, 45:”peter”} d) All of the mentioned

Last Answer : A

Description : What will be the output? d = {"john":40, "peter":45} print(list(d.keys())) a) [“john”, “peter”]. b) [“john”:40, “peter”:45]. c) (“john”, “peter”) d) (“john”:40, “peter”:45)

Last Answer : a) [“john”, “peter”].

Description : What is the output? d = {"john":40, "peter":45} d["john"] a) 40 b) 45 c) “john” d) “peter”

Last Answer : a) 40

Description : What will be the output? d1 = {"john":40, "peter":45} d2 = {"john":466, "peter":45} d1 > d2 a) True b) False c) Error d) None

Last Answer : c) Error

Description : What will be the output? d1 = {"john":40, "peter":45} Page No 40 d2 = {"john":466, "peter":45} d1 == d2 a) True b) False c) None d) Error

Last Answer : b) False

Description : What will be the output? d = {"john":40, "peter":45} "john" in d a) True b) False c) None d) Error

Last Answer : a) True

Description : Read the code shown below carefully and pick out the keys? d = {"john":40, "peter":45} a) “john”, 40, 45, and “peter” b) “john” and “peter” c) 40 and 45 d) d = (40:”john”, 45:”peter”)

Last Answer : b) “john” and “peter”

Description : What will be the output? d = {"john":40, "peter":45} d["john"] a) 40 b) 45 c) “john” d) “peter”

Last Answer : a) 40

Description : Suppose list Example is [‘h’,’e’,’l’,’l’,’o’], what is len(list Example)? a) 5 b) 4 c) None d) Error

Last Answer : a) 5

Description : 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))

Last Answer : d) print(len(t)) is incorrect. In python, len(t) is a built-in function that returns the number of items in the tuple t. Since t contains 4 items, len(t) would correctly return 4. a) print(t[ ... of tuple. c) print(max(t)) is correct, it will return the maximum element of tuple which is 4.

Description : What will be the output of the following Python code? d = {"john":40, "peter":45} d["john"] a) 40 b) 45 c) “john” d) “peter”

Last Answer : Answer: a Explanation: Execute in the shell to verify.

Description : What will be the output of the following Python code snippet? d1 = {"john":40, "peter":45} d2 = {"john":466, "peter":45} d1 > d2 a) True b) False c) Error d) None

Last Answer : Answer: c Explanation: Arithmetic > operator cannot be used with dictionaries.

Description : What will be the output of the following Python code snippet? d1 = {"john":40, "peter":45} d2 = {"john":466, "peter":45} d1 == d2 a) True b) False c) None d) Error

Last Answer : Answer: b Explanation: If d2 was initialized as d2 = d1 the answer would be true.

Description : What will be the output of the following Python code snippet? d = {"john":40, "peter":45} "john" in d a) True b) False c) None d) Error

Last Answer : Answer: a Explanation: In can be used to check if the key is int dictionary.

Description : What will be the output of the following Python code snippet? d = {"john":40, "peter":45} a) “john”, 40, 45, and “peter” b) “john” and “peter” c) 40 and 45 d) d = (40:”john”, 45:”peter”)

Last Answer : Answer: b Explanation: Dictionaries appear in the form of keys and values.

Description : The age of Discontinuity‘ (1969) has been authored by A. John Drydon B. Cyril Debydeen C. Peter F. Drucker D. None of these

Last Answer : C. Peter F. Drucker

Description : Suppose that the number of instructions executed between page faults is directly proportional to the number of page frames allocated to a program. If the available memory is doubled, the mean interval between page faults is also ... memory were available? (A) 60 sec (B) 30 sec (C) 45 sec (D) 10 sec

Last Answer : Answer: C Explanation: T = Ninstr x 1µs + 15,000 x 2,000 µs = 60s Ninstr x 1µs = 60,000,000 µs - 30,000,000 µs = 30,000,000 µs Ninstr = 30,000,000 The number of instruction ... doesn't mean that the program runs twice as fast as on the first system. Here, the performance increase is of 25%.

Description : What will be the output? numberGames = {} numberGames[(1,2,4)] = 8 numberGames[(4,2,1)] = 10 numberGames[(1,2)] = 12 sum = 0 for k in numberGames: sum += numberGames[k] print len(numberGames) + sum Page No 36 a) 30 b) 24 c) 33 d) 12

Last Answer : a) 30

Description : What will be the output? >>>my_tuple = (1, 2, 3, 4) >>>my_tuple.append( (5, 6, 7) ) >>>print len(my_tuple) a) 1 b) 2 c) 5 d) Error

Last Answer : c) 5

Description : What will be the output? >>>t = (1, 2, 4, 3, 8, 9) >>>[t[i] for i in range(0, len(t), 2)] a) [2, 3, 9]. b) [1, 2, 4, 3, 8, 9]. c) [1, 4, 8]. d) (1, 4, 8)

Last Answer : c) [1, 4, 8].

Description : What is the output of the following? x = 'abcd' for i in range(len(x)): print(x) x = 'a' a) a b) abcd abcd abcd abcd c) a a a a d) none of the mentioned

Last Answer : d) none of the mentioned

Description : What is the output of the following? x = 'abcd' for i in range(len(x)): x = 'a' print(x) Page No 17 a) a b) abcd abcd abcd c) a a a a d) none of the mentioned

Last Answer : c) a a a a

Description : What is the output of the following? x = 'abcd' for i in range(len(x)): i.upper() print (x) a) a b c d b) 0 1 2 3 c) error d) none of the mentioned

Last Answer : c) error

Description : A UNIX file system has 1 KB block size and 4-byte disk addresses. What is the maximum file size if the inode contains ten direct block entries, one single indirect block entry, one double indirect block entry and one triple indirect block entry? (A) 30 GB (B) 64 GB (C) 16 GB (D) 1 GB

Last Answer : (C) 16 GB

Description : The virtual address generated by a CPU is 32 bits. The Translation Lookaside Buffer (TLB) can hold total 64 page table entries and a 4-way set associative (i.e. with 4- cache lines in the set). The page size is 4 KB. The minimum size of TLB tag is (A) 12 bits (B) 15 bits (C) 16 bits (D) 20 bits

Last Answer : (C) 16 bits Explanation: VirtualAddress = 32 bits PageSize = 4KB = 12 bits therefore : VPNTag = 20 bits, OffsetTag = 12 bits TLBEntryLength = VPNTag = 20 bits TotalTLBEntries = 64, 4-way implies ... therefore : TLBIndex = 4 bits TLBTag = TLBEntryLength - TLBIndex = 20 - 4 = 16 bits

Description : A unix file system has 1-KB blocks and 4-byte disk addresses. What is the maximum file size if i-nodes contain 10 direct entries and one single, double and triple indirect entry each? (A) 32 GB (B) 64 GB (C) 16 GB (D) 1 GB

Last Answer : (C) 16 GB

Description : A virtual memory has a page size of 1K words. There are eight pages and four blocks. The associative memory page table contains the following entries:  Which of the following list of virtual addresses (in ... 1234, 4012, 5000, 6200 (C) 1020, 3012, 6120, 8100 (D) 2021, 4050, 5112, 7100

Last Answer : Answer: C Explanation: The pages which are not in main memory are: 1020 will not cause page fault (1024-2047) 3012 will not cause page fault (3072-4095) 6120 will not cause page fault (4096-5119) 8100 will not cause page fault (6144-7167)

Description : The order of a leaf node in a B+ tree is the maximum number of children it can have. Suppose that block size is 1 kilobytes, the child pointer takes 7 bytes long and search field value takes 14 bytes long. The order of the leaf node is ............ (1) 16 (2) 63 (3) 64 (4) 65

Last Answer : Answer: All

Description : Which language has the most words (according to dictionary entries)? -General Knowledge

Last Answer : English, 200,000 words

Description : If a={5,6,7,8}, which of the following statements is false? a) print(len(a)) b) print(min(a)) c) a.remove(5) d) a[2]=45

Last Answer : Answer: d Explanation: The members of a set can be accessed by their index values since the elements of the set are unordered.

Description : Consider a subnet with 720 routers. If a three-level hierarchy is choosen with eight clusters, each containing 9 regions of 10 routers, then total number of entries in the routing table is ................... (A) 25 (B) 27 (C) 53 (D) 72

Last Answer : Answer: A  Explanation: Each router needs 10 entries for local routers, 8 entries for routing to other regions within its own cluster, and 7 entries for distant clusters, for a total of 25 entries.

Description : Consider the following statements: (a) Revised simplex method requires lesser computations than the simplex method. (b) Revised simplex method automatically generates the inverse of the current basis matrix. (c) Less number of entries are needed ... c) only (C) (b) and (c) only (D) (a), (b) and (c)

Last Answer : (D) (a), (b) and (c)

Description : For the implementation of a paging scheme, suppose the average process size be x bytes, the page size be y bytes, and each page entry requires z bytes. The optimum page size that minimizes the total overhead due to the page ... fragmentation loss is given by (A) x/2 (B) xz/2 (C) √2xz (D) (√xz)/2

Last Answer : (C) √2xz 

Description : In a fully-connected mesh network with 10 computers, total .............. number of cables are required and ................ number of ports are required for each device. (A) 40, 9 (B) 45, 10 (C) 45, 9 (D) 50, 10

Last Answer : (C) 45, 9

Description : The directory can be viewed as .................... that translates filenames into their directory entries. (A) Symbol table (B) Partition (C) Swap space (D) Cache

Last Answer : (A) Symbol table

Description : Suppose that we have numbers between 1 and 1000 in a binary search tree and want to search for the number 364. Which of the following sequences could not be the sequence of nodes examined? (A) 925, 221, 912, 245, 899, ... 926, 203, 912, 241, 913, 246, 364 (D) 3, 253, 402, 399, 331, 345, 398, 364 

Last Answer : (C) 926, 203, 912, 241, 913, 246, 364

Description : DDS stands for ………………… A) Data Data Systems B) Data Digital System C) Data Dictionary Systems D) Digital Data Service

Last Answer : C) Data Dictionary Systems

Description : What is the output of the following code? a={1:"A",2:"B",3:"C"} print(a.setdefault(3)) a) {1: ‘A’, 2: ‘B’, 3: ‘C’} b) C c) {1: 3, 2: 3, 3: 3} d) No method called setdefault() exists for dictionary

Last Answer : b) C

Description : Which of the following is not a declaration of the dictionary? a) {1: ‘A’, 2: ‘B’} b) dict([[1,”A”],[2,”B”]]) c) {1,”A”,2”B”} d) { }

Last Answer : c) {1,”A”,2”B”}

Description : Data Integrity control uses ................ (A) Upper and lower limits on numeric data. (B) Passwords to prohibit unauthorised access to files. (C) Data dictionary to keep the data (D) Data dictionary to find last access of data

Last Answer : (B) Passwords to prohibit unauthorised access to files.

Description : Data which improves the performance and accessibility of the database are called: (A) Indexes (B) User Data (C) Application Metadata (D) Data Dictionary

Last Answer : (A) Indexes

Description : A software program that infers and manipulates existing knowledge in order to generate new knowledge is known as: (A) Data Dictionary (B) Reference Mechanism (C) Inference Engine (D) Control Strategy

Last Answer : (C) Inference Engine

Description : From the given data below: a b b a a b b a a b which one of the following is not a word in the dictionary created by LZ-coding (the initial words are a, b)? (1) a b (2) b b (3) b a (4) b a a b 

Last Answer : (4) b a a b 

Description : To remove string “hello” from list1, we use which command ? a) list1.remove(“hello”) b) list1.remove(hello) c) list1.removeAll(“hello”) d) list1.removeOne(“hello”)

Last Answer : d) list1.removeOne(“hello”)

Description : To insert 5 to the third position in list1, we use which command ? a) list1.insert(3, 5) b) list1.insert(2, 5) c) list1.add(3, 5) d) list1.append(3, 5)

Last Answer : a) list1.insert(3, 5)

Description : To add a new element to a list we use which command ? a) list1.add(5) b) list1.append(5) c) list1.addLast(5) d) list1.addEnd(5)

Last Answer : a) list1.add(5)