Data Aggregates

2023年1月20日

[01]Given the following Python code:

              a = “hello"

              b = a[2]

              What is the value of b?

(a)hello                (b)None               (c)e       (d)l

A. d

[02]Given the following Python code:

              a = “world"

              b = a[0]

              What is the value of b?

(a)world                            (b)w      (c)Error is thrown              (d)None

A. b

[03]Given the following Python code:

              a = “world"

              b = a[5]

              What is the value of b?

(a)None               (b)world                            (c)w       (d)Error is thrown

A. d

[04]Given the following Python code:

              a = “world"

              b = a[-1]

              What is the value of b?

(a)w      (b)d       (c)Error is thrown              (d)None

A. b

[05]Given the following Python code:

              a = list(“hello")

              b = len(a)

              What is the value of b?

(a)0       (b)Error is thrown              (c)5       (d)4

A. c

[06]Given the following Python code:

              a = [1, 2, 3]

              b = a[2]

              What is the value of b?

(a)Error is thrown              (b)3       (c)2       (d)1

A. b

[07]Given the following Python code:

              a = [1, 2, 3, 4, 5, 6]

              b = a[2, 5]

              What is the value of b?

(a)[3, 4, 5]          (b)[2, 5]              (c)[2, 3, 4, 5]

(d)[3, 4, 5, 6]

A. a

[08]Given the following Python code:

              a = [1, 2, 3, 4, 5, 6]

              b = a[ : : -1]

              What is the value of b?

(a)[1, 2, 3, 4, 5, 6]           (b)[6]    (c)[6, 5, 4, 3, 2, 1]           (d)[1]

A. c

[09]Given the following Python code:

              a = [1, 2, 3, 4, 5, 6]

              b = a[ : : 2]

              What is the value of b?

(a)[1, 3, 5]          (b)[1, 2]              (c)[2]    (d)[2, 3, 4, 5, 6]

A. a

[10]Given the following Python code:

              a = [1, 2, 3, 4, 5, 6]

              b = slice(2, 3)

              What is the value of b?

(a)[2]                  (b)[2, 3]              (c)[3]                  (d)[2, 5, 6]

A. c

[11]Given the following Python code:

              a = [1, 2, 3]

              b = [-1]

              What is the value of b?

(a)[3]                  (b)[3, 2, 1]          (c)3       (d)-1

A. 3

[12]The __________ method of the List object add a new element to the end of a list.

(a)sorted()          (b)copy()             (c)index()            (d)append()

(e)insert()

A. d

[13]The __________ method of the List object add a new element to the list at a specified position.

(a)insert()           (b)index()            (c)copy()             (d)sorted()

(e)append()

A. a

[14]The __________ method of the List object returns the index of first occurene of an element in the list.

(a)index()            (b)sorted()          (c)append()        (d)instert()

(e)copy()

A. a

[15]The __________ method of the List object orders its elemens ascending and returns them in a new List object.

(a)instert()          (b)append()        (c)index()            (d)copy()

(e)sorted()

A. e

[16]The __________ method of the List object returns a new List with the same elements and order as the calling object.

(a)copy()             (b)append()        (c)sorted()          (d)index()

(e)insert()

A. a

[17]The __________ instruction is used to delete an element of a List at a given index.

(a)not                  (b)del                  (c)in

A. b

[18]The __________ operator returns True if a give element exists inside of a List.

(a)del                  (b)in                    (c)not

A. b

[19]The __________ operator returns True if a given element does not exist inside of a List.

(a)in                    (b)not                  (c)del

A. b

[20]A __________ is a Python collection type which represents an immutable, ordered collection of elements.

(a)Frozen Set      (b)List                  (c)Dictionary       (d)Tuple

A. d

[21]A __________ is a Python collection type which represents a mutable, ordered collection of elements.

(a)Frozen Set      (b)List                  (c)Set                  (d)Tuple

(e)Dictionary

A. b

[22]A __________ is a Python collection type which represents an map of key-value pairs.

(a)Frozen Set      (b)Dictionary       (c)List                  (d)Tuple

(e)Set

A. b

[23]A __________ is a Python collection type which represents a mutable non-ordered collection of unique elements.

(a)Frozen Set      (b)Tuple               (c)Set                  (d)List

(e)Dictionary

A. c

[24]]A __________ is a Python collection type which represents a mutable non-ordered collection of unique elements.

(a)List                  (b)Dictionary       (c)Set                  (d)Tuple

(e)Frozen Set

A. e

[25]Which of the following statements properly creates a Tuple object?

(a)[1, 2, 3]          (b){1, 2, 3}         (c)(1, 2, 3)          (d){“x":0, “y":1}

A. c

[26]Which of the following statements properly creates a List object?

(a){“x":0, “y":1}                            (b){1, 2, 3}         (c)(1, 2, 3)         

(d)[1, 2, 3]

A. d

[27]Which of the following statements properly creates a Dictionary object?

(a){1, 2, 3}         (b)(1, 2, 3)          (c)[1, 2, 3]          (d){“x":0, “y":1}

A. d

[28]Which of the following statements properly creates a Set object?

              (Choose 2.)

(a)(1, 2, 3)          (b){“x":0, “y":1}                            (c){1, 2, 3}        

(d)[1, 2, 3]

A. a, c

[29]Given the following Pythoon code:

              a = [1, 2, 3]

              b = [x + 1 for x in a]

              What is the value of b?

(a)[2, 3, 4]          (b)[1, 2, 3]          (c)[]      (d)[6]

A. a

[30]Given the following Pythoon code:

              a = [[1, 2, 3], [4, 5, 6]]

              b = a[1]

              What is the value of b?

(a)1       (b)[1, 2, 3]          (c)[4, 5, 6]          (d)[4]

A. c

[31]Given the following Pythoon code:

              a = [[1, 2, 3], [4, 5, 6]]

              b = a[0][1]

              What is the value of b?

(a)2       (b)[4]    (c)4       (d)[4, 5, 6]

A. a

[32]The __________ method of a Directory object returns the value associated a given key.

(a)key()               (b)update()         (c)items()           (d)fromkeys()

(e)values()          (f)get()

A. f

[33]The __________ method of a Dictionary object adds new key-value pairs to the dictionary, or overwrites existing key-value pairs with new values.

(a)keys()             (b)fromkeys()     (c)gets()             (d)update()

(e)values()          (f)items()

A. d

[34]The __________ method of a Dictionary object accepts a collection of keys and a single value and construct a new Dictionary which maps each key to the given value.

(a)keys()             (b)values()          (c)get()               (d)fromkeys()

(e)update()         (f)items()

A. d

[35]The __________ method of a Dictionary object returns a list containing a tuple for each key-value pair.

(a)get()               (b)fromkeys()     (c)update()         (d)items()

(e)keys()             (f)values()

A. d

[36]The __________ method of a Dictionary object returns a list containing all of the keys in the dictionary.

(a)items()           (b)values()          (c)fromkeys()      (d)update()

(e)keys()             (f)get()

A. e

[37]The __________ method of a Dictionary object returns a list containing all of the value in the dictionary.

(a)fromkeys()     (b)values()          (c)get()               (d)update()

(e)keys()             (f)items()

A. b

[38]Given the following Python code:

              a = [“jeff":0, “george":1]

              b = a[“jeff"]

              What is the value of b?

(a)jeff                  (b)None               (c)0       (d)1

A. c

[39]Given the following Python code:

              a = [“jeff":0, “george":1]

              b = a[0]

              What is the value of b?

(a)jeff                  (b)1                     (c)Error is thrown              (d)0

A. c

[40]Given the following Python code:

              a = [“jeff":0, “george":1, “john":2]

              b = 0

              for x in a:

                            b = b + x

              What is the value of b?

(a)0       (b)Error is thrown              (c)jeffgeorgejohn              (d)3

A. b

[41]Given the following Python code:

              a = [“jeff":0, “george":1, “john":2]

              b = 0

              for x in a values():

                            b = b + x

              What is the value of b?

(a)jeffgeorgejohn              (d)0       (c)3       (d)Error is thrown

A. c

[42]The __________ method of a String object sets the first character to upper case.

(a)startwith()      (b)capitalize()     (c)replace()         (d)title()

(e)find()

A. b

[43]The __________ method of a String object sets the first character of each word to upper case.

(a)find()                            (b)capitalize()     (c)title()                            (d)replace()

(e)startwith()

A. c

[44]The __________ method of a String object returns the index of the first occurent of a given substring.

(a)find()                            (b)replace()        (c)startwith()

(d)capitalize()     (e)title()

A. a

[45]The __________ method of a String object finds all occurrence of a given substring, and replaces them with a new string.

(a)title()                            (b)capitalize()     (c)find()               (d)replace()

(e)startwith()

A. d

[46]The __________ method of a String object returns true if the first charactor(s) of the string are a specified value.

(a)capitalize()     (b)title()              (c)find()               (d)replace()

(e)startwith()

A. e

[47]Given the following Python code:

              a = “hello hellow"

              b = a.replace(“hello", “goodbye")

              What is value of b?

(a)goodbye hello               (b)hello hello                     (c)hello goodbye

(d)goodbye goodbye

A. d

[48]Which of the following statements would create a multiline string?

(a)x = (“hello hello")         (b)x = “hello hello"

(c)x = “""hello hello"""      (d)x = 'hello hello’

A. c

[49]The __________ built-in string method converts a string to upper case.

(a)isdecimal()     (b)isalpha()         (c)chr()               (d)isalnum()

(e)lower()           (f)upper()

A. f

[50]The __________ built-in string method converts a string method converts a string to lower case.

(a)isalnum()        (b)lower()           (c)upper()           (d)isdecimal()

(e)chr()               (f)isalpha()

A. b

[51]The __________ built-in string method returns true if all characters are alphanumeric.

(a)isalnum()        (b)isalpha()         (c)isdecimal()     (d)lower()

A. a

[52]The __________ built-in string method returns true if all characters are alphabetic.

(a)isalpha()         (b)lower()           (c)isalnum()        (d)upper()

(e)chr()               (e)decimal()

A. a

[53]The __________ built-in string method returns true if all characters are numbers between 0-9.

(a)upper()           (b)isalnum()        (c)isalpha()         (d)isdecimal()

(e)lower()           (f)chr()

A. d

[54]The __________ built-in string method converts a number into a unicode character.

(a)upper()           (b)isalnum()        (c)chr()               (d)isdecimal()

(e)isalpha()         (f)lower()

A. c

[55]The __________ built-in string method returns true if all characters are number between 0-9 or is a unicode exponent.

(a)isidentifier()                  (b)isspace()        (c)isdigit()

(d)isspace()                      (e)islower()

A. c

[56]The __________ built-in string method returns true if the string contains alphanumeric letters(a-z) an (0-9), or underscores(_), and does not start with a number.

(a)islower()         (b)isidentifier()                  (c)isspace()

(d)isdigit()           (e)isnumeric()

A. b

[57]The __________ built-in string method returns true if all characters are lowercase.

(a)isspace()        (b)islower()         (c)isidentifier()     (d)isdigit()

(e)isnumeric()

A. b

[58]The __________ built-in string method returns true if all characters are numbers between 0-9 or is a unicode exponent, fraction or other numerical value.

(a)isspace()        (b)isdigit()           (c)islower()         (d)isidentifier()

(e)isnumeric()

A. e

[59]The __________ built-in string method returns true if all characters are white space.

(a)isspace()        (b)isdigit()           (c)islower()         (d)isidentifier()

(e)isnumeric()

A. e

[60]The __________ built-in string method returns true if every word in the string starts with an uppercase letter, and otherwise has lowercase letters.

(a)isupper()        (b)join()                            (c)split()              (d)ord()

(e)istitle()            (f)len()

A. e

[61]The __________ built-in string method returns true if all characters ar upper case.

(a)ord()               (b)isupper()        (c)split()              (d)join()

(e)len()               (f)istitle()

A. b

[62]The __________ built-in string method separates a string into parts and returns a list of those parts.

(a)isupper()        (b)len()               (c)join()               (d)istitle()

(e)split()

A. e

[63]The __________ built-in string method combines an iterable collection of strings into one string.

(a)istitle()            (b)ord()               (c)join()               (d)isupper()

(e)len()               (f)split()

A. c

[64]The __________ built-in string method returns the number of characters in the string.

(a)ord()               (b)isupper()        (c)istitle()            (d)len()

(e)join()                            (f)split()

A. d

[65]The __________ built-in string method converts a character into the unicode member associate with it.

(a)split()              (b)istitle()            (c)ord()               (d)len()

(e)isupper()        (f)join()

A. c

[66]The __________ escape character represents backslash.

(a)\"      (b)\b     (c)\\     (d)\’

A. c

[67]The __________ escape character represents a single quote.

(a)\’      (b)\"      (c)\\     (d)\b

A. a

[68]The __________ escape character represents a double quote.

(a)\’      (b)\b     (c)\"      (d)\\

A. c

[69]The __________ escape character represents an ASCII backspace.

(a)\\     (b)\’      (c)\"      (d)\b

A. d

[70]The __________ escape character represents a newline.

(a)\xhh               (b)\t                    (c)\n                   (d)\ooo

A. c

[71]The __________ escape character represents a horizonal tab.

(a)\xhh               (b)\t                    (c)\ooo               (d)\n

A. b

[72]The __________ escape character represents an octal value of “ooo".

(a)\xhh               (b)\t                    (c)\ooo               (d)\n

A. c

[73]The __________ escape character represents a character with the hexadecimal value of “hh".

(a)\xhh               (b)\t                    (c)\n                   (d)\ooo

A. a