Docsity

WGU E010 OA EXAM /ACTUAL WGU E010 OBJECTIVE ASSESSMENT FINAL SECTION 1: PYTHON PROGRAM, Exams of Information and Communications Technology (ICT)

Toggle sidebar
bg1
WGU E010 OA EXAM /ACTUAL WGU E010
OBJECTIVE ASSESSMENT FINAL
SECTION 1: PYTHON PROGRAMMING & DATA TYPES (Questions 1-30)
Q1. What is the output of print(type(10 / 2))?
• A) ``
• B) ``
• C) ``
• D) ``
Correct Answer: B
Rationale: In Python, the / operator always returns a float, even when the two
numbers divide evenly. 10 / 2 evaluates to 5.0, which is a float .
Q2. Which of the following data types is immutable?
• A) list
• B) dict
• C) set
• D) tuple
Correct Answer: D
Rationale: Tuples cannot be changed after creation (immutable). Lists,
dictionaries, and sets are mutable and can be modified after creation .
Q3. What is the result of print(10 // 3)?
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27

Partial preview of the text

Download WGU E010 OA EXAM /ACTUAL WGU E010 OBJECTIVE ASSESSMENT FINAL SECTION 1: PYTHON PROGRAM and more Exams Information and Communications Technology (ICT) in PDF only on Docsity!

WGU E010 OA EXAM /ACTUAL WGU E

OBJECTIVE ASSESSMENT FINAL

SECTION 1: PYTHON PROGRAMMING & DATA TYPES (Questions 1-30) Q1. What is the output of print(type(10 / 2))?

  • A) ``
  • B) ``
  • C) ``
  • D) `` Correct Answer: B Rationale: In Python, the / operator always returns a float, even when the two numbers divide evenly. 10 / 2 evaluates to 5.0, which is a float. Q2. Which of the following data types is immutable?
  • A) list
  • B) dict
  • C) set
  • D) tuple Correct Answer: D Rationale: Tuples cannot be changed after creation (immutable). Lists, dictionaries, and sets are mutable and can be modified after creation. Q3. What is the result of print(10 // 3)?

• A) 3.333…

• B) 3

• C) 4

• D) 3.

Correct Answer: B Rationale: The // operator performs floor division (integer division). It returns the quotient without the remainder, so 10 // 3 evaluates to 3. Q4. What is the output of print(2 ** 3)?

  • A) 6
  • B) 8
  • C) 9
  • D) 5 Correct Answer: B Rationale: The ** operator is the exponentiation operator. 2 ** 3 means 2 raised to the power of 3, which is 2 * 2 * 2 = 8. Q5. What does the input() function return?
  • A) An integer
  • B) A float
  • C) A string
  • D) A boolean Correct Answer: C Rationale: The built-in input() function reads a line from standard input and returns it as a string. Q6. Which of the following variable names is invalid?
  • B) tho
  • C) yth
  • D) hon Correct Answer: B Rationale: Slicing [2:5] takes characters from index 2 up to (but not including) index 5. Indices: P0 y1 t2 h3 o4 n5 → slice "tho". Q10. What does print(x[-1]) output if x = [1, 2, 3]?
  • A) 1
  • B) 2
  • C) 3
  • D) Error Correct Answer: C Rationale: Negative indexing starts from the end of the sequence. - 1 refers to the last element, which is 3. Q11. What is the value of 10 % 3?
  • A) 1
  • B) 2
  • C) 3
  • D) 0 Correct Answer: A Rationale: The % operator is the modulo operator, which returns the remainder of division. 10 ÷ 3 = 3 with a remainder of 1. Q12. Which operator is used for exponentiation in Python?
  • A) ^

• B) **

• C) *

• D) //

Correct Answer: B Rationale: ** is the exponentiation operator (e.g., 2 ** 3 = 8). ^ is bitwise XOR, not exponentiation. Q13. What does the append() method do when called on a list?

  • A) Removes the last item
  • B) Adds an element to the end of the list
  • C) Inserts an element at a specific index
  • D) Sorts the list Correct Answer: B Rationale: append() adds a single element to the end of a list, increasing the list's length by one. Q14. Which of the following creates a list comprehension?
  • A) [x for x in range(5)]
  • B) (x for x in range(5))
  • C) {x for x in range(5)}
  • D) x for x in range(5) Correct Answer: A Rationale: List comprehensions are enclosed in square brackets []. Parentheses create a generator expression, curly braces create a set comprehension. Q15. What does the len() function return when called on a string?
  • A) The memory size of the string

• B) ==

• C) !=

• D) ===

Correct Answer: B Rationale: == is the equality comparison operator. = is assignment. != means not equal. === is not valid in Python. Q19. What is the output of print(5 + 3 * 2)?

  • A) 16
  • B) 11
  • C) 13
  • D) 10 Correct Answer: B Rationale: Multiplication has higher precedence than addition. 3 * 2 = 6, then 5 + 6 = 11. Q20. What does the break statement do in a loop?
  • A) Skips one iteration and continues
  • B) Exits the loop entirely
  • C) Restarts the loop from the beginning
  • D) Pauses the loop temporarily Correct Answer: B Rationale: break immediately terminates the nearest enclosing loop (for or while). Program execution resumes after the loop. Q21. Which loop is most appropriate when the number of iterations is not known beforehand?
  • A) for loop
  • B) while loop
  • C) nested loop
  • D) foreach loop Correct Answer: B Rationale: A while loop continues as long as a condition remains true. It is ideal when you do not know how many times the loop should run. Q22. Which keyword is used to define a function in Python?
  • A) function
  • B) def
  • C) define
  • D) func Correct Answer: B Rationale: Functions are defined using the def keyword, followed by the function name and parentheses containing parameters. Q23. Which keyword is used to handle exceptions in Python?
  • A) catch
  • B) try
  • C) error
  • D) exceptify Correct Answer: B Rationale: Python uses try/except blocks to handle exceptions. Code that may raise an exception is placed in a try block, and handling code goes in the corresponding except block.

Q27. What is the output of print("Hello" + "World")?

  • A) HelloWorld
  • B) Hello World
  • C) Hello+World
  • D) Error Correct Answer: A Rationale: The + operator concatenates strings. No space is added unless explicitly included. Q28. Which of the following statements about range(5, 10, 2) is correct?
  • A) It generates numbers 5, 6, 7, 8, 9
  • B) It generates numbers 5, 7, 9
  • C) It generates numbers 5, 7, 9, 11
  • D) It generates numbers 5, 10 Correct Answer: B Rationale: range(start, stop, step) generates numbers starting at 5 (inclusive), up to but not including 10 , incrementing by 2. This yields 5, 7, 9. Q29. What does the return statement do in a function?
  • A) Prints a value
  • B) Exits the function and optionally sends back a value
  • C) Restarts the function
  • D) Creates a loop Correct Answer: B Rationale: return ends function execution and passes a value back to the caller. Without return, the function returns None.

Q30. Which of the following is a valid way to create an empty list?

  • A) list()
  • B) []
  • C) Both A and B
  • D) None of the above Correct Answer: C Rationale: Both [] and list() create an empty list. [] is the preferred, more common syntax. SECTION 2: STRINGS, LISTS, AND OPERATIONS (Questions 31-60) Q31. What is the output of print(type("Hello" * 3))?
  • A) ``
  • B) ``
  • C) ``
  • D) `` Correct Answer: C Rationale: Multiplying a string by an integer repeats the string. The result is still a string, so type() returns , not (which doesn't exist). Q32. What does pop() do when called on a list without arguments?
  • A) Removes the first element
  • B) Removes and returns the last element
  • C) Removes a random element
  • D) Removes all elements

Correct Answer: B Rationale: The + operator concatenates strings. "Hello" + " " + "World" combines to produce "Hello World". Q36. Which statement about Python sets is TRUE?

  • A) Sets maintain insertion order
  • B) Sets automatically prevent duplicate values
  • C) Sets can contain mutable elements
  • D) Sets are indexed by position Correct Answer: B Rationale: Sets automatically prevent duplicate values. Sets are unordered (no index positions) and contain only immutable elements. Q37. What is the output of the following code? python sports = ["basketball", "baseball", "football", "soccer", "tennis"] last = sports[- 3 :] print(last)
  • A) ['football', 'soccer', 'tennis']
  • B) ['basketball', 'baseball', 'football']
  • C) ['soccer', 'tennis']
  • D) ['basketball', 'baseball'] Correct Answer: A Rationale: Slice notation [-3:] starts from the third element from the end and goes to the end of the list. Index - 3 is 'football', - 2 is 'soccer', - 1 is 'tennis'. Q38. Which method returns the index of the first occurrence of a value in a list?
  • A) find()
  • B) index()
  • C) search()
  • D) locate() Correct Answer: B Rationale: The index() method returns the index of the first occurrence of a specified value in a list. If the value is not found, it raises a ValueError. Q39. What is the result of float("3.14")?
  • A) 3
  • B) 3.
  • C) Error
  • D) "3.14" Correct Answer: B Rationale: float("3.14") converts the string "3.14" to a floating-point number 3.14. The string must contain a valid numeric literal. Q40. Which of the following conversions will raise an error?
  • A) float("5.0")
  • B) int("10")
  • C) int("3.14")
  • D) float("5") Correct Answer: C Rationale: The string must represent a valid integer literal. "3.14" contains a decimal point and cannot be converted directly to an integer. Q41. What is the output of print(2 + 3 * 4 - 1)?

Rationale: y = x makes y reference the same list object as x. Appending to y also changes x. This is a reference assignment, not a copy. Q44. Which of the following correctly creates a dictionary?

  • A) {1, 2, 3}
  • B) {"a": 1, "b": 2}
  • C) [("a",1), ("b",2)]
  • D) (("a",1), ("b",2)) Correct Answer: B Rationale: Curly braces with key-value pairs define a dictionary. Option A creates a set, option C creates a list of tuples, and option D creates a tuple of tuples. Q45. What is the output of the following code? python d = {"x": 10 , "y": 20 } print(d.get("z", 0 ))
  • A) None
  • B) KeyError
  • C) 0
  • D) "z" Correct Answer: C Rationale: The .get(key, default) method returns the default value if the key is not found. Here "z" is missing, so it returns 0. Q46. Which function is used to read input from the user?
  • A) scan()
  • B) input()
  • C) read()
  • D) get() Correct Answer: B Rationale: The built-in input() function reads a line from standard input and returns it as a string. Q47. What does the global keyword do?
  • A) Creates a new variable
  • B) Allows a function to modify a variable defined outside the function
  • C) Deletes a variable
  • D) Makes a variable local Correct Answer: B Rationale: global inside a function allows you to assign to a variable defined in the global scope. Without global, assigning to a variable creates a new local variable. Q48. What is the output of print("Python"[-1])?
  • A) "P"
  • B) "y"
  • C) "h"
  • D) "n" Correct Answer: D Rationale: Negative indices count from the end of a string. - 1 always returns the last character, which is "n". Q49. Which operator is used for floor division?
  • A) /
  • B) //

Correct Answer: B Rationale: .copy() creates a shallow copy of the list. Modifying b does not affect a. Q52. What is the result of bool("False")?

  • A) False
  • B) True
  • C) Error
  • D) None Correct Answer: B Rationale: Any non-empty string evaluates to True in a boolean context. The content of the string (even "False") does not matter; only that it is non-empty matters. Q53. Which of the following is a valid Boolean value in Python?
  • A) true
  • B) TRUE
  • C) True
  • D) 1 Correct Answer: C Rationale: Boolean literals are True and False (capital T and F). 1 is an integer, not a Boolean literal (though it can be used in boolean contexts). Q54. What is the output of the following code? python x = [ 1 , 2 , 3 ] x.insert( 1 , 99 ) print(x)

• A) [1, 99, 2, 3]

• B) [99, 1, 2, 3]

• C) [1, 2, 99, 3]

• D) [1, 2, 3, 99]

Correct Answer: A Rationale: insert(1, 99) inserts 99 at index 1 , shifting existing elements to the right. The list becomes [1, 99, 2, 3]. Q55. What is the result of 10 % 3?

  • A) 3
  • B) 1
  • C) 0
  • D) Error Correct Answer: B Rationale: The modulo operator % returns the remainder. 10 ÷ 3 = 3 remainder 1. Q56. Which function removes the last element from a list and returns it?
  • A) remove()
  • B) pop()
  • C) delete()
  • D) discard() Correct Answer: B Rationale: pop() with no argument removes and returns the last element of the list. Q57. What is the output of the following code? python