OA Exams

  • web.groovymark@gmail.com
  • November 29, 2024

Question 41

What is the output of print(type({}))?

a) set
b) dict
c) list
d) None

Correct Answer: b) dict

Explanation: An empty pair of curly braces {} creates an empty dictionary in Python.

Question 42

What is the function of the ord() method?

a) Returns the Unicode point for a character
b) Converts a string to lowercase
c) Reverses a string
d) Finds the length of a string

Correct Answer: a) Returns the Unicode point for a character

Explanation: The ord() method returns the Unicode code point of a single character.

Question 43

Which of the following is not a Python built-in function?

a) print()
b) input()
c) map()
d) clear()

Correct Answer: d) clear()

Explanation: clear() is a method for certain data types like dictionaries and sets, but not a built-in function.

Question 44

How do you convert an integer to a string in Python?

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

Correct Answer: a) str()

Explanation: The str() function converts any data type to a string.

Question 45

What is the result of print(4 / 2)?

a) 2
b) 2.0
c) 4
d) Error

Correct Answer: b) 2.0

Explanation: Division / in Python always returns a float, even if the result is a whole number.

Question 46

Which of the following functions can be used to create a new tuple?

a) list()
b) set()
c) tuple()
d) dict()

Correct Answer: c) tuple()

Explanation: The tuple() function is used to create a new tuple in Python.

Question 47

What is the default value of the start parameter in the range() function?

a) 1
b) 0
c) -1
d) None

Correct Answer: b) 0

Explanation: The start parameter in range() defaults to 0, meaning the sequence starts at 0 unless otherwise specified.

Question 48

Which of the following is true about Python lists?

a) Lists are immutable
b) Lists are ordered collections
c) Lists cannot contain duplicates
d) Lists must only contain integers

Correct Answer: b) Lists are ordered collections

Explanation: Lists in Python are ordered, meaning the elements are indexed and maintain the order in which they were added.

Question 49

How do you access the last element of a list in Python?

a) list[-1]
b) list[0]
c) list[1]
d) list[len(list)]

Correct Answer: a) list[-1]

Explanation: The index -1 refers to the last element in a list in Python.

Question 50

Which of the following is not a valid Python loop control structure?

a) for
b) while
c) do-while
d) break

Correct Answer: c) do-while

Explanation: Python does not have a do-while loop; it only supports for and while loops.

Complete the Captcha to view next question set.

Prev Post
WGU D335 Practice Exam Questions – Set 4 – Part 2
Next Post
WGU D335 Practice Exam Questions – Set 5 – Part 1