Control and Evaluations

2023年1月20日

[01]Which of the following commands would execute a Python script named myScript.py without errors?

(a)exec myScript               (b)python myScript.py      (c)python myScript (d)exec myScript.py

A. b

[02]Which of the following commands would execute a Python script named myScript.py without errors?

(a)python -m myScript.py              (b)exec myScript.py          (c)exec myScript (d)python -m myScript

A. d

[03]The __________ Python command line option tells the interpreter to not save compiled bytecode to the hard drive.

(a)-V     (b)-m    (c)-c      (d)-h      (e)-B     (f)-E

A. e

[04]The __________ Python command line option indicates that the following statements should be executed as Python code.

(a)-h      (b)-B     (c)-m     (d)-V     (e)-c      (f)-E

A. e

[05]The __________ Python command line option tells the interpreter to ignore all environment variables.

(a)-m    (b)-c      (c)-E      (d)-B     (e)-h

A. c

[06]The __________ Python command line option prints a sheet description of all available command line option.

(a)-h      (b)-E      (c)-V      (d)-B     (e)-m    (f)-c

A. -a

[07]The __________ Python command line option execute a specified Python modules.

(a)-c      (b)-B     (c)-E      (d)-h      (e)-V     (f)-m

A. f

[08]The __________ Python command line option prints the Python version number.

(a)-E      (b)-h      (c)-c      (d)-B     (e)-V     (f)-m

A. e

[09]Which of the following command line statements would correctly print “Hello World"?

(a)python “print(“Hello World")"    

(b)python -m “print(“Hello World")"

(c)python -h “print(“Hello World")"

(d)python -c “print(“Hello World")"

A. d

[10]A __________ is a Python literal whichi respresents a value that is either True or False.

(a)Interger          (b)Floating-Point               (c)String (d)Boolean

A. d

[11]An __________ is a Python literal which presents a whole number (does not include a decimal point(.)).

(a)Floating-Point               (b)Boolean          (c)Integer            (d)String

A. c

[12]A __________ number is a Python literal which represents a non-whole number (includes a decimal point(.)).

(a)Integer           (b)Floating-Point               (c)Boolean          (d)String

A. b

[13]A __________ number is a Python literal which represents a text value as a sequence of characters.

(a)Float-Point      (b)String              (c)Boolean          (d)Integer

A. b

[14]If you type __________ at the begining of a line that line of code will be “comment out" meaning that it will not be compiled or executed.

(a)/        (b)%      (c)//      (d)#

A. d

[15]The __________ built-in function will write a supplied string to the command line (or other standard output).

(a)int()                (b)print()             (c)len()                (d)input()

(e)float()             (f)str()                 (g)range()

A. b

[16]The __________ built-in function will prompt the user to enter text through the command line, and returns user-supplied text as a string.

(a)float()             (b)str()                (c)input()            (d)range()

(e)int()                (f)len()                (g)print()

A. c

[17]The __________ built-in function converts a string or non-integer number into an integer object.

(a)range()           (b)int()                (c)str()                (d)float()

(e)prin()              (f)len()                (g)input()

A. b

[18]The __________ built-in function converts a string or non-float number into a float object.

(a)print()             (b)range()           (c)int()                (d)str()

(e)len()               (f)input()             (g)float()

A. g

[19]The __________ built-in function converts a number or non-string into a string object.

(a)float()             (b)range()           (c)int()                (d)len()

(e)input()            (f)print()              (g)str()

A. g

[20]The __________ built-in function returns the number of elements in a sequence or collection.

(a)float()             (b)str()                (c)len()                (d)range()

(e)input()            (f)int()                 (g)print()

A. c

[21]The __________ built-in function returns a sequence of numbers, starting from 0 by default, and ending at a specified number.

(a)float()             (b)range()           (c)int()                (d)str()

(e)len()               (f)input()             (g)str()

A. b

[22]Which of the following is a valid binary literal?

(a)0x101010       (b)101010           (c)0o101010       (d)0b101010

A. d

[23]Which of the following is a valid octal literal?

(a)0x101010       (b)101010           (c)0b101010       (d)0o101010

A. d

[24]Which of the following is a valid decimal literal?

(a)101010           (b)0o101010       (c)0b101010       (d)0x101010

A. a

[25]Which of the following is a valid hexadecimal literal?

(a)0b101010       (b)101010           (c)0x101010        (d)0o101010

A. c

[26]The __________ numeric operation performs exponetiation on the numbers (raises one number to the power of another).

(a)+       (b)**     (c)-        (d)/        (e)//      (f)*        (g)%

A. b

[27]The __________ numeric operation performs division on two numbers

(a)-        (b)**     (c)/        (d)+       (e)%      (f)//       (g)*

A. c

[28]The __________ numeric operation performs truncated division (rounds the result of division down to the integer level).

(a)-        (b)%      (c)/        (d)//      (e)**     (f)+       (g)*

A. b

[29]The __________ numeric operation performs modulation on two numbers (returns the remainder after integer divison).

(a)*       (b)**     (c)%      (d)/        (e)+       (f)//       (g)-

A. d

[30]The __________ numeric operation performs addition on two numbers.

(a)+       (b)%      (c)*       (d)//      (e)/        (f)-        (g)**

A. +

[31]The __________ numeric operation performs subtraction on two numbers.

(a)/        (b)//      (c)%      (d)**     (e)+       (f)*        (g)-

A. g

[32]The __________ numeric operation performs multiplication on two numbers.

(a)//      (b)%      (c)*       (d)/        (e)**     (f)+       (g)+

A. c

[33]The __________ boolean operator returns true if both operands equal True.

(a)and   (b)|        (c)or      (d)&

A. d

[34]The __________ boolean operator returns true if at least on of the operands equal True.

(a)and   (b)&       c)or        (d)|

A. d

[35]The __________ boolean operator returns true if both operands equal True.

    This operator performs a short-circuited evaluation, meaning that if the first operand is False, the expression will return False without evaluating the second operand.

(a)|        (b)and   (c)&       (d)or

A. b (Not c)

[36]The __________ boolean operator returns true if at least one of the operands equals True.

    This operator performs a short-circuited evaluation, meaning that if the first operand is True, the expression will return True without evaluating the second operand.

(a)|        (b)&       (c)or      (d)and

A. c (Not a)

[37]What is the value of the below numerical expression?

              2 ** 4

(a)8       (b)16     (c)24     (d)0.5

A. b

[38]What is the value of the below numerical expression?

              5 * 10

(a)510   (b)-5      (c)50     (d)15

A. c

[39]What is the value of the below numerical expression?

              8 / 2

(a)4       (b)8       (c)16     (d)64

A. 4

[40]What is the value of the below numerical expression?

              5 % 3

(a)1.6    (b)8       (c)15     (d)2

A. d

[41]What is the value of the below numerical expression?

              3 // 2

(a)1.5    (b)1       (c)2       (d)3

A. b

[42]What is the value of the below strin expression?

              “Hello" + “World"

(a)"Hello" + “World"          (b)Hello + World

(c)Hello World                   (d)HelloWorld

A. d

[43]What is the value of the below strin expression?

              “Hello" * 3

(a)Hello3             (b)Hell                 (c)hel     (d)HelloHelloHello

A. d

[44]Given the following Python code:

              a = b = c = 1

              d = a + b + c

              What is the value of d?

(a)1       (b)Code throws error        (c)0       (d)3

A. d

[45]Given the following Python code:

              a, b, c = 1

              d = a + b + c

              What is the value of d?

(a)Code throws error        (b)3       (c)0       (d)1

A. a

[46]Given the following Python code:

              a = 2

              b = 0

              a, b = b, a

              x = a / b

              What is the value of x?

(a)1       (b)0       (c)2       (d)Code throws error

A. b

[47]The __________ bitwise operator performs a bitwise NOT on a binary value.

(a)&       (b)>>    (c)<<    (d)|        (e)~       (f)^

A. e

[48]The __________ bitwise operator performs a bitwise AND on a binary value.

(a)&       (b)<<    (c)~       (d)|        (e)>>    (f)^

A. a

[49]The __________ bitwise operator performs a bitwise XOR on a binary value.

(a)>>    (b)<<    (c)~       (d)|        (e)>>    (f)^

A. f

[50]The __________ bitwise operator performs a bitwise OR on a binary value.

(a)|        (b)^       (c)&       (d)>>    (e)~       (f)<<

A. a

[51]The __________ bitwise operator performs a bitwise left-shift on a binary value.

(a)|        (b)&       (c)^       (d)~       (e)>>    (f)<<

A. f

[52]The __________ bitwise operator performs a bitwise right-shift on a binary value.

(a)~       (b)|        (c)>>    (d)<<    (e)&       (f)^

A. c

[53]The __________ bitwise operator returns True if the operands are equals.

(a)<       (b)<=    (c)>       (d)!=     (e)==

A. e

[54]The __________ relational operator returns True if the operands are not equals.

(a)==    (b)>       (c)<       (d)!=     (e)>=    (f)<=

A. d

[55]The __________ relational operator returns True if the left operand is greater than the right operand.

(a)!=     (b)<=    (c)>=    (d)<       (e)==    (f)>

A. f

[56]The __________ relational operator returns True if the left operand is greater than or equal to the right operand.

(a)<=    (b)>       (c)<       (d)>=    (e)==    (f)!=

A. d

[57]The __________ relatinal operator returns True if the left operand is less than to the right operand.

(a)==    (b)>       (c)<       (d)!=     (e)>=    (f)<=

A. c

[58]The __________ relatinal operator returns True if the left operand is less than or equal to to the right operand.

(a)>=    (b)!=     (c)>       (d)==    (e)<=    (f)<

A. e

[59]When passing a collection into the built-in print() function, the __________ argument defines a string which will be placed between every element before printing.

(a)sep=               (b)end=

A. a

[60]When passing a collection into the built-in print() function, the __________ argument defines a string which will be printed at the end of the text.

(a)end=               (b)sep=

A. a

[61]When performing an operation on two different data types, how does Python handle the disparity?

(a)Converts the smaller data type into the larger data type

(b)Converts the larger data type into the smaller data type

A. a

[62]In Python, string objects are

(a)immutable      (b)mutable

A. a

[63]Which of the following statements properly creates an integer literal?

(a)13     (b)[1]    (c)"Hello"            (d)3.1

A. a

[64]Which of the following statements property creates a floating-point literal?

(a)3.1    (b)[1]    (c)"Hello"            (d)13

A. a

[65]Which of the following statements properly creates a string literal?

(a)[1]    (b)3.1    (c)13     (d)"Hello"

A. d

[66]Which of the following statements properly creates a list?

(a)"Hello"            (b)13     (c)3.1    (d)[1]

A. d

[67]Given the following Python code:

              a = 5

              b = 4

              c = 0

              if a > b:

                            c = 1

              What is the value of c?

(a)1       (b)4       (c)5       (d)0

A. a

[68]Given the following Python code:

              a = 5

              b = 4

              c = 0

              if a < b:

                            c = 1

              What is the value of c?

(a)1       (b)0       (c)4       (d)5

A. b

[69]Given the following Python code:

              a = 5

              b = 4

              c = 0

              if a < b:

                            c = 1

              else:

                            c = 2

              What is the value of c?

(a)0       (b)2       (c)4       (d)1

A. b

[70]Given the following Python code:

              a = 5

              b = 4

              c = 0

              if a < b:

                            c = 1

              elif a > b:

                            c = 3

              What is the value of c?

(a)3       (b)0       (c)1       (d)2

A. 2

[71]Given the following Python code:

              a = 5

              b = 5

              c = 0

              if a < b:

                            c = 1

              elif a > b

                            c = 2

              else:

                            c = 3

(a)1       (b)3       (c)0       (d)2

A. 3

[72]In Python, the __________ statement does nothing. You can use this statement to fill in the body of an unimplemented function without causing a syntax error.

(a)pass                (b)skip                 (c)null                  (d)None

A. a

[73]A __________ loop repeatedly executes the same code block as long as a given condition is true:

(a)for                   (b)while

A. b

[74]A __________ loop repeatedly executes the same code block for each item in a given sequence.

(a)for                   (b)while

A. a

[75]Given the following Python code:

              x = 0

              for i in range(3):

                            x += 1

              What is the value of x?

(a)10     (b)6       (c)0       (d)3

A. d

[76]Given the following Python code:

              x = 0

              elements = [1, 2, 3]

              for i in elements:

                            x += i

              What is the value of x?

(a)10     (b)3       (c)0       (d)6

A. 6

[77]Given the following Python code:

              x = 0

              while x < 10:

                            x += 2

              What is the value of x?

(a)6       (b)2       (c)0       (d)10

A. d

[78]Given the following Python code:

              x = 0

              while x < 10:

                            x += 2

              else:

                            x += 3

              What is the value of x?

(a)6       (b)3       (c)13     (d)10

A. c

[79]Given the following Python code:

              x = 0

              for i in range(5):

                            x += 1

              else:

                            x += 3

              What is the value of x?

(a)5       (b)3       (c)13     (d)10

A. c

[80]Given the following Python code:

              x = 0

              elements = []

              for i in elements:

                            x += i

              else:

                            x += 3

              What is the value of x?

(a)3       (b)4       (c)0       (d)None

A. 3

[81]Given the following Python code:

              x = 0

              elements = [1, 2, 3]

              for i in elements

                            for j in elements

                                          x += j

              What is the value of x?

(a)3       (b)18     (c)0       (d)13

A. 18

[82]Given the following Python code:

              x = 0

              elements = [1, 2, 3]

              for i in elements:

                            if i == 2

                                          break

                            else:

                                          x += 1

              What is the value of x?

(a)4       (b)2       (c)1       (d)3

A. c

[83]Given the following Python code:

              x = 0

              elements = [1, 2, 3]

              for i in elements:

                            if i == 2:

                                          continue

                            else:

                                          x += i

              What is the value of x?

(a)3       (b)1       (c)4       (d)2

A. c

[84]Given the following Python code:

              a = “10 \ 10"

              print(a)

              What is the value of x?

(a)1       (b)Error is thrown              (c)10 10              (d)10 \ 10

A. d

[85]Given the following Python code:

              a = “\"Hello\""

              print(a)

              What is the value of x?

(a)Error is thrown              (b)Hello               (c)"Hello"

(d)\"Hello\"

A. c

#Python
#Python Institute
#PCAP
#Certified Associate in Python Programming