CertGrid
Python Certification

Python Automation for IT Practice Exam

Vendor-neutral CertGrid practical track (not an official certification): job-focused Python automation for IT, cloud, security, and DevOps - scripting, files and data formats, OS and process automation, APIs, and CI/CD.

Practice 787 exam-style Python Automation for IT questions with full answer explanations, then take timed mock exams that score like the real thing.

787
Practice pool
50 qs
CertGrid track
90 min
Track time
70%
Passing score

Vendor-neutral CertGrid practical track, not an official certification exam.

Objective-mapped practice, aligned to current exam objectives · Reviewed Jul 2026 · Independent practice platform.

What the Python Automation for IT exam covers

Free Python Automation for IT sample questions

A sample of 10 questions with answers and explanations. Sign up free to practice all 787.

  1. Question 1Python Scripting Foundations for Automation

    What does the following script print? 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: A

    The 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.
  2. Question 2Python Scripting Foundations for Automation

    A Python virtual environment isolates a project's installed packages from the system-wide Python packages.

    • ATrueCorrect
    • BFalse
    ✓ Correct answer: A

    A virtual environment gives a project its own site-packages directory and interpreter link, so pip installs stay local to that project instead of touching system packages.

    Why the other options are wrong
    • BIsolation of dependencies per project is exactly the purpose of a virtual environment.
  3. Question 3Files, Data Formats, and Text Processing

    What does the following script print? line = ' ERROR: disk full ' print(line.strip().split(':')[0])

    • AERRORCorrect
    • B ERROR
    • CERROR: disk full
    • D disk full
    ✓ Correct answer: A

    strip removes the surrounding spaces, split(':') breaks the text at the colon, and [0] selects the first piece, 'ERROR'.

    Why the other options are wrong
    • Bstrip runs first and removes the leading spaces before the split, so no spaces remain.
    • CThe split on ':' plus index [0] returns only the part before the colon.
    • DIndex [0] selects the first piece before the colon, not the [1] part after it.
  4. Question 4Files, Data Formats, and Text Processing

    Which creates a temporary file that is deleted automatically when it is closed?

    • Atempfile.NamedTemporaryFile()Correct
    • Btempfile.mkstemp()
    • Copen("/tmp/x", "w")
    • Dtempfile.gettempdir()
    ✓ Correct answer: A

    By default NamedTemporaryFile removes the underlying file when the object is closed, which pairs well with a with block.

    Why the other options are wrong
    • Bmkstemp returns a descriptor and path but leaves cleanup to you.
    • CA plain open creates a persistent file that you must delete yourself.
    • Dgettempdir only returns the temp directory path and creates nothing.
  5. Question 5Files, Data Formats, and Text Processing

    What does the following script print? import re print(bool(re.match(r'^\d{3}$', '1234')))

    • AFalseCorrect
    • BTrue
    • CNone
    • D4
    ✓ Correct answer: A

    ^ and $ anchor the pattern to the whole string and \d{3} requires exactly three digits, so '1234' does not match, re.match returns None, and bool(None) is False.

    Why the other options are wrong
    • BThe anchors require exactly three digits end to end, and the string has four.
    • Cre.match returns None on no match, but bool() converts that to False before printing.
    • DThe code prints a boolean from bool(), not the length of the string.
  6. Question 6OS, Process, and Task Automation

    os.walk(top) yields a tuple of what for each directory it visits?

    • A(dirpath, dirnames, filenames)Correct
    • B(filename, size, mode)
    • C(path, is_dir, is_file)
    • D(root, extension, count)
    ✓ Correct answer: A

    For each directory, os.walk yields the current path plus the lists of subdirectory names and file names within it.

    Why the other options are wrong
    • Bos.walk describes directories, not per-file size and mode.
    • CIt yields name lists, not boolean type flags.
    • DThere is no extension or count element in the yielded tuple.
  7. Question 7OS, Process, and Task AutomationSelect all that apply

    Which TWO functions create or remove directories on the filesystem? (Select TWO.)

    • Aos.makedirs creates any missing parent directoriesCorrect
    • Bos.rmdir removes a single empty directoryCorrect
    • Cos.listdir deletes everything inside a directory
    • Dos.getcwd removes the current working directory
    ✓ Correct answer: A, B

    os.makedirs creates a directory along with any missing parents, and os.rmdir removes a directory that is already empty.

    Why the other options are wrong
    • Clistdir returns the names of the entries; it does not delete anything.
    • Dgetcwd returns the current directory path and removes nothing.
  8. Question 8APIs, Web, and Cloud Automation

    How do you send a bearer token with the requests library?

    • Aheaders={"Authorization": "Bearer TOKEN"}Correct
    • Bheaders={"Token": "TOKEN"}
    • Cparams={"auth": "TOKEN"}
    • Ddata={"bearer": "TOKEN"}
    ✓ Correct answer: A

    Bearer auth expects an Authorization header whose value is the word Bearer followed by the token.

    Why the other options are wrong
    • BA custom Token header is not the standard bearer scheme most APIs expect.
    • CPutting the token in the query string is insecure and not the bearer convention.
    • DThe token belongs in a header, not the request body.
  9. Question 9APIs, Web, and Cloud Automation

    If the endpoint returns HTTP 200, what does this print? import requests r = requests.get('https://api.example.com/health') print(r.status_code == 200)

    • ATrueCorrect
    • B200
    • COK
    • DFalse
    ✓ Correct answer: A

    r.status_code holds the integer 200, and comparing it to 200 yields True, which is what print shows.

    Why the other options are wrong
    • BThe code prints the boolean comparison, not the raw status code.
    • Cstatus_code is the number 200, and the comparison yields a boolean, not text.
    • DA 200 response makes the comparison true, not false.
  10. Question 10Network Automation, Testing, and CI/CD

    Which command stages and records changes as a new commit in a local repo?

    • Agit add . && git commit -m 'msg'Correct
    • Bgit clone <url>
    • Cgit status --short
    • Dgit log --oneline
    ✓ Correct answer: A

    git add stages the changed files and git commit records them as a new commit, so the two together capture a snapshot locally.

    Why the other options are wrong
    • Bclone copies an existing remote repo; it does not record your new changes.
    • Cstatus only reports what changed and stages nothing.
    • Dlog shows past commits and does not create a new one.

Related Python resources

Python Automation for IT practice exam FAQ

How many questions are in the Python Automation for IT practice exam on CertGrid?

CertGrid has 787 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 scores your practice attempts the same way so you know when you are ready.

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.

Can I practice Python Automation for IT for free?

Yes. You can start practicing Python Automation for IT for free with daily practice and sample questions. Paid plans unlock full timed exams, complete explanations, and 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 an independent practice platform and is not affiliated with or endorsed by Python. Questions are original practice items designed to mirror certification concepts and exam style. CertGrid does not provide official exam questions or braindumps.