What the Python Automation for IT exam covers
- Python Scripting Foundations for Automation96 questions
- Files, Data Formats, and Text Processing111 questions
- OS, Process, and Task Automation116 questions
- APIs, Web, and Cloud Automation78 questions
- Network Automation, Testing, and CI/CD70 questions
Free Python Automation for IT practice test questions
A sample of 10 questions with answers and explanations. A free account includes a fixed set of 20 practice questions for this exam, retryable anytime. Paid access unlocks the full 471-question bank.
-
What does the following script print? ```python nums = [1, 2, 3, 4] print([n * n for n in nums if n % 2 == 0]) ```
- A[4, 16]Correct
- B[1, 4, 9, 16]
- C[2, 4]
- D[1, 9]
✓ Correct answer: AThe comprehension keeps only even values (2 and 4) because of the if filter, then squares each survivor, giving 4 and 16.
Why the other options are wrong- BThat squares every element and ignores the if filter that keeps only even numbers.
- CThat keeps the even numbers but forgets to square them in the expression part.
- DThat squares the odd numbers, which is the opposite of the n % 2 == 0 filter.
-
Select TWO statements that are true about *args and **kwargs in a function signature.
- A*args collects extra positional arguments into a tupleCorrect
- B**kwargs collects extra keyword arguments into a dictCorrect
- C*args collects keyword arguments into a list
- D**kwargs must be written before *args in the signature
✓ Correct answer: A, BExtra positional arguments gather into the *args tuple and extra keyword arguments gather into the **kwargs dict.
Why the other options are wrong- C*args gathers positional arguments into a tuple, not keyword arguments into a list.
- D*args must appear before **kwargs, not the other way around.
-
Opening a file with mode 'w' keeps the existing contents and appends new lines at the end.
- ATrue
- BFalseCorrect
✓ Correct answer: BOpening in 'w' truncates any existing content to zero length; appending while preserving contents requires mode 'a'.
Why the other options are wrong- AChoosing True is incorrect: 'w' erases the file on open rather than preserving it.
-
True or False: yaml.safe_load is preferred over yaml.load because it will not construct arbitrary Python objects from the input.
- ATrueCorrect
- BFalse
✓ Correct answer: Asafe_load only builds simple Python types such as dicts, lists, strings, and numbers, so untrusted YAML cannot instantiate arbitrary classes the way the unrestricted loader could.
Why the other options are wrong- Bsafe_load is indeed the safer choice for untrusted input precisely because it blocks arbitrary object construction.
-
What happens on the second call? ```python import os os.makedirs('/tmp/app/cache') os.makedirs('/tmp/app/cache') ```
- AThe second call raises FileExistsErrorCorrect
- BBoth calls succeed silently
- CThe second call raises PermissionError
- DThe second call returns False
✓ Correct answer: Amakedirs raises FileExistsError if the leaf directory already exists; pass exist_ok=True to make it idempotent.
Why the other options are wrong- BWithout exist_ok=True, recreating the directory raises rather than succeeding.
- CThe directory already exists; it is not a permission problem.
- Dmakedirs raises on conflict instead of returning False.
-
Which call makes run.sh readable, writable, and executable for the owner using an octal mode?
- Aos.chmod('run.sh', 0o755)Correct
- Bos.chmod('run.sh', 755)
- Cos.access('run.sh', 0o755)
- Dos.stat('run.sh', 0o755)
✓ Correct answer: Achmod sets the permission bits, and the 0o prefix makes 755 an octal literal, giving rwx for the owner and rx for group and others.
Why the other options are wrong- BThe plain 755 is a decimal number, so it sets a different, unintended set of permission bits.
- Cos.access only tests whether a path is accessible; it does not change permissions.
- Dos.stat reads a file's metadata and does not accept or apply a mode.
-
Which requests call sends {'q': 'python'} as URL query parameters on a GET request?
- Arequests.get(url, params={'q': 'python'})Correct
- Brequests.get(url, json={'q': 'python'})
- Crequests.get(url, data={'q': 'python'})
- Drequests.get(url, headers={'q': 'python'})
✓ Correct answer: AThe params argument encodes the mapping into the URL query string, so the request goes to url?q=python, which is the correct place for GET filters.
Why the other options are wrong- Bjson serializes the mapping into the request body, not the URL query string.
- Cdata places form-encoded content in the body rather than the query string.
- Dheaders sets request headers, which are not the URL query parameters.
-
What does unittest.mock.patch('module.requests.get') do inside a test?
- AReplaces requests.get with a mock so no real HTTP call is madeCorrect
- BSends a real GET request and records how long it takes
- CVerifies that the remote endpoint returns a 200 status
- DInstalls the requests library if it is not present
✓ Correct answer: Apatch temporarily replaces requests.get as referenced in that module with a Mock, so the test controls the return value and no real network call happens, then restores the original afterward.
Why the other options are wrong- BThe point of patching is to avoid the real request, not to send one.
- CIt does not contact a real endpoint; it substitutes a controllable mock.
- Dpatch does not install packages; it replaces an attribute at test time.
-
Which is the recommended way to give a boto3 automation script its AWS credentials?
- ASupply credentials via environment variables or an IAM roleCorrect
- BPass the keys to boto3.client() as arguments read from a config.py file in the repository
- CStore the keys base64-encoded in the script so they are not stored as plain text
- DPass the secret key as a plaintext command line argument
✓ Correct answer: Aboto3 resolves credentials from the environment, shared config, or an instance/role profile, keeping keys out of source and rotating cleanly.
Why the other options are wrong- BThe keys still live in the repository and its history; boto3 finds credentials on its own without them being passed in.
- CBase64 is an encoding anyone can reverse, so the keys are effectively stored in the source.
- DCommand line arguments are visible in process lists and shell history.
-
You must extract the IP address from a log line. What does this print? ```python import re line = 'user login from 10.0.2.15 ok' m = re.search(r'(\d+\.\d+\.\d+\.\d+)', line) print(m.group(1)) ```
- A10.0.2.15Correct
- B10
- CNone
- D['10.0.2.15']
✓ Correct answer: AThe pattern captures four dot-separated digit runs, and group(1) returns that captured substring, the IP address.
Why the other options are wrong- BThe whole capture group matches all four octets, not just the first number.
- Csearch finds a match, so group(1) is a string rather than None.
- DA list is what re.findall returns; group(1) returns the captured text as a plain string.
Who this Python Automation for IT practice exam is for
This practice set is for anyone preparing for the Python Automation for IT exam - from first-time candidates building a foundation to experienced Python practitioners doing a final review before test day. If you learn best by working through realistic questions and reading why each answer is right or wrong, it is built for you.
How to use this Python Automation for IT practice exam
- Start with the free sample questions above to gauge your current baseline.
- Read the full explanation on every question, including why each wrong option is wrong.
- Track your weak domains and focus your study where you are losing the most marks.
- Once you are scoring consistently well, take a timed, full-length mock exam.
- Use your readiness score to decide when you are ready to book the real Python Automation for IT exam.
Related Python resources
- Python Automation for IT study guideKey concepts
- Python practice examsAll Python
- Certification pathWhere this fits
- Certification exam guides & tipsBlog
- Plans & pricingFree & paid
- Hands-on python-automation labsLearn
- Python automation cheat sheetCheat sheet
- How these questions are written and reviewedMethodology
- Report a problem with a questionCorrections
- PCAP practice examRelated
- PCEP practice examRelated
Python Automation for IT practice exam FAQ
How many questions are in the Python Automation for IT practice exam on CertGrid?
CertGrid has 471 practice questions for Python Automation for IT, covering 5 exam domains. This is a vendor-neutral CertGrid practical track, not an official vendor exam.
What is the passing score for Python Automation for IT?
This is a vendor-neutral CertGrid practical track, not an official certification exam. CertGrid scores your practice against a 70% readiness threshold on a 50-question mock, so you know when you are ready for real Python automation work.. You have about 90 min to complete it. CertGrid tracks your readiness against the exam objectives so you know where to focus.
Are these official Python Automation for IT exam questions?
No. CertGrid is an independent practice platform. We do not provide real or leaked exam questions. Our questions are original and designed to help you practice the concepts, scenarios, and difficulty style of the Python Automation for IT exam.
Is there a free Python Automation for IT practice test?
Yes. You can take a free Python Automation for IT practice test straight away: a fixed set of 20 practice questions for this exam, retryable as often as you like, with no credit card required. You get readiness scoring and a weak-domain breakdown on those questions. Paid plans unlock the full 471-question bank, timed mock exams and full-bank domain analytics.
What CertGrid is (and is not)
CertGrid is an independent IT certification practice platform for Azure, AWS, Google, Cisco, Security, Linux, Kubernetes, Terraform, and other certification tracks. It provides objective-mapped practice questions, readiness scoring, weak-domain drills, and explanations to help learners understand what to study next.
Independent & original. CertGrid is not affiliated with or endorsed by Microsoft, AWS, Google, Cisco, CompTIA, the Linux Foundation, HashiCorp, or other certification vendors. Questions are original practice items designed to mirror certification concepts and exam style. CertGrid does not provide official exam questions or braindumps.