OA Exams

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

Question 41

What will be the output of print(‘hello’.upper())?

a) HELLO
b) hello
c) Hello
d) Error

Correct Answer: a) HELLO

Explanation: The upper() method converts all characters in a string to uppercase.

Question 42

What does the pass statement do in Python?

a) Stops the execution of a loop
b) Does nothing and continues to the next statement
c) Skips the current iteration of a loop
d) Terminates a function

Correct Answer: b) Does nothing and continues to the next statement

Explanation: The pass statement is used as a placeholder and does not perform any action.

Question 43

 What is the result of print(7 // 3)?

a) 2
b) 2.33
c) 1
d) 3

Correct Answer: a) 2

Explanation: The // operator performs floor division and returns the largest integer less than or equal to the result.

Question 44

Which method is used to reverse a list in Python?

a) reverse()
b) reversed()
c) flip()
d) sort(reverse=True)

Correct Answer: a) reverse()

Explanation: The reverse() method reverses the elements of a list in place.

Question 45

 How do you delete an element from a dictionary in Python?

a) del dict[key]
b) dict.delete(key)
c) dict.remove(key)
d) remove dict[key]

Correct Answer: a) del dict[key]

Explanation: The del statement removes the key-value pair from a dictionary.

Question 46

What will be the result of print(10 % 3)?

a) 3
b) 1
c) 10
d) 0

Correct Answer: b) 1

Explanation: The modulus operator % returns the remainder of a division, so 10 % 3 equals 1.

Question 47

Which operator is used to check if two values are not equal in Python?

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

Correct Answer: a) !=

Explanation: The != operator checks if two values are not equal.

Question 48

How do you create a multi-line comment in Python?

a) Using # for each line
b) Using “”” or ”’
c) Using /* */
d) Using //

Correct Answer: b) Using """ or '''

Explanation: Multi-line comments are created using triple quotes, either """ or '''.

Question 49

 What is the purpose of the break statement in a loop?

a) To skip the current iteration
b) To exit the loop immediately
c) To continue to the next iteration
d) To restart the loop

Correct Answer: b) To exit the loop immediately

Explanation: The break statement causes the loop to terminate immediately, regardless of its condition.

Question 50

What is the result of 5 + 3 * 2 in Python?

a) 16
b) 11
c) 10
d) 13

Correct Answer: b) 11

Explanation: According to operator precedence, multiplication is performed before addition, so 3 * 2 is evaluated first, followed by 5 + 6.

Complete the Captcha to view next question set.

Tags

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