State Compliance Practice Exam
Questions And Correct Answers
(Verified Answers) Plus Rationales
|2026 Q&A | Instant Download Pdf
1. Which of the following is the correct way to define a function in
Python?
A. function myFunction():
B. def myFunction():
C. define myFunction():
D. func myFunction():
B is correct because "def" is the keyword used to define a function in
Python.
2. What will the following code output: print(type([]))?
A. <class 'tuple'>
B. <class 'dict'>
C. <class 'list'>
D. <class 'set'>
,C is correct because square brackets denote a list in Python.
3. What is the result of bool("") in Python?
A. True
B. False
C. None
D. "False"
B is correct because an empty string evaluates to False in a boolean
context.
4. Which HTTP status code should a Python API return when access is
forbidden due to lack of permissions?
A. 200
B. 301
C. 403
D. 500
C is correct because 403 is the standard status code for "Forbidden" access.
5. In Python, which built-in function can be used to get the ASCII value of
a character?
A. ascii()
B. ord()
C. chr()
D. int()
B is correct because ord() returns the ASCII or Unicode code of a character.
, 6. What Python data structure is best suited to store unique, unordered
elements?
A. list
B. tuple
C. dict
D. set
D is correct because sets store unique items and do not guarantee order.
7. Which Python statement is used to handle exceptions?
A. catch
B. try
C. check
D. except
B is correct because Python uses try-except blocks for exception handling.
8. What does the expression 3 == '3' evaluate to in Python?
A. True
B. False
C. Error
D. None
B is correct because Python is strictly typed and does not coerce different
types in equality checks.
, 9. Which of the following file types must be used when submitting code
for a Texas state agency compliance audit?
A. .docx
B. .exe
C. .js
D. .py
D is correct because Python source code files must have a .py extension.
10. What is the output of print("Hello" + str(5))?
A. Hello5
B. Hello5
C. Error
D. Hello 5
B is correct because str(5) converts the integer to a string for
concatenation.
11. In Python, what does the with statement manage?
A. Memory leaks
B. HTTP sessions
C. Context managers
D. Thread safety
C is correct because the with statement is used with context managers to
manage resources.