Download WGU D335 INTRO TO PYTHON OA OBJECTIVE and more Exams Nursing in PDF only on Docsity!
WGU D335 Intro to Python | OA | Objective
Assessment | 100 Updated & Actual
Questions and 100% Correct Answers |
SECTION 1: Python Basics & Syntax (Q1โ25)
1. Which symbol is used for comments in Python? A. // B. /* */ C. # D. -- Answer: C Explanation: Python uses # for single-line comments. 2. Which function outputs text to the console? A. echo() B. print() C. output() D. write() Answer: B Explanation: print() displays output in Python. 3. Which of the following is a valid variable name?
A. 2value B. my-value C. my_value D. class Answer: C Explanation: Variable names cannot start with numbers or be keywords.
4. What is the output of the following code? print(type( 10 )) A. int B. integer C. D. number Answer: C Explanation: Python displays data types using class notation. 5. Which data type stores text? A. int B. float C. str D. bool **Answer: C
- What is the value of x after execution?** x = 5
D. float(x) Answer: B
10. Which keyword defines a function? A. func B. define C. def D. function **Answer: C SECTION 2: Conditionals (Q26โ50)
- Which keyword handles additional conditions?** A. else B. elif C. then D. when **Answer: B
- What is the output?** x = 10 if x > 5 : print("A") else: print("B")
A. A
B. B
C. Error D. Nothing Answer: A
28. Which comparison checks inequality? A. == B. >= C. != D. <= **Answer: C
- What does this print?** if False: print("Yes") else: print("No") A. Yes B. No C. Error D. Nothing **Answer: B
- Boolean values are:**
34. Which keyword ends a conditional block? A. end B. stop C. Indentation D. break **Answer: C
- Which statement executes if all conditions fail?** A. if B. elif C. else D. when **Answer: C SECTION 3: Loops (Q51โ80)
- Which loop repeats a known number of times?** A. while B. for C. do-while D. repeat **Answer: B
- What does this print?** for i in range( 3 ):
print(i) A. 1 2 3 B. 0 1 2 C. 0 1 2 3 D. Error Answer: B
53. Which keyword stops a loop immediately? A. stop B. end C. break D. exit **Answer: C
- Which keyword skips to the next iteration?** A. skip B. next C. continue D. pass **Answer: C
- What is the output?** x = 0 while x < 3 : print(x)
59. Which loop checks condition before execution? A. for B. while C. repeat D. do **Answer: B
- What does pass do?** A. Ends loop B. Skips iteration C. Does nothing D. Causes error **Answer: C SECTION 4: Functions (Q81โ105)
- What is a function?** A. Variable B. Loop C. Reusable block of code D. Condition **Answer: C
- What keyword returns a value?** A. send B. output
C. return D. give Answer: C
83. What is printed? def add(a, b): return a + b print(add( 2 , 3 )) A. 2 B. 3 C. 5 D. Error **Answer: C
- Parameters are:** A. Values returned B. Variables in function definition C. Function calls D. Data types **Answer: B
- Arguments are:** A. Variables B. Returned values
def f(x= 5 ): A. Error B. Required parameter C. Optional parameter D. Loop Answer: C
90. How many values can a function return? A. One B. Two C. Unlimited D. None **Answer: C SECTION 5: Data Structures (Q106โ130)
- Which structure stores ordered items?** A. Set B. Dictionary C. List D. Boolean **Answer: C
- Which structure is immutable?** A. List B. Tuple C. Dictionary
D. Set Answer: B
108. How do you access first list element? lst = [ 10 , 20 , 30 ] A. lst(0) B. lst[1] C. lst[0] D. lst.first() **Answer: C
- What does append() do?** A. Removes item B. Adds item to end C. Sorts list D. Clears list **Answer: B
- Dictionaries store data as:** A. Indexes B. Values only C. Key-value pairs D. Sets **Answer: C
- How do you access dictionary value?**
115. Indexing starts at: A. 1 B. - 1 C. 0 D. Any **Answer: C SECTION 6: Strings, Errors & Final Concepts (Q131โ150)
- Strings are:** A. Mutable B. Immutable C. Loops D. Integers **Answer: B
- What does upper() do?** A. Removes spaces B. Capitalizes string C. Converts to uppercase D. Reverses string **Answer: C
- What causes a syntax error?** A. Logic mistake B. Incorrect indentation
C. Misspelled keyword D. All of the above Answer: D
134. What is a runtime error? A. Compile issue B. Error during execution C. Syntax issue D. Comment issue **Answer: B
- What does try/except handle?** A. Loops B. Input C. Errors D. Output **Answer: C
- Which converts string to float?** A. float(x) B. str(x) C. int(x) D. bool(x) **Answer: A
- What does strip() do?**
141 โ 150: Final Exam Logic (Rapid Review)
- Python is case-sensitive โ True
- = assigns values โ True
- == compares values โ True
- Lists are mutable โ True
- Tuples are immutable โ True
- Dictionaries use keys โ True
- Indentation defines blocks โ True
- input() returns string โ True
- Functions improve reusability โ True
- D335 OA tests problem-solving โ True