Limited-Time Offer: Enjoy 50% Savings! - Ends In 0d 00h 00m 00s Coupon code: 50OFF
Welcome to QA4Exam

Free practice questions with explanations

GIAC GPYC Dumps 2026 with Free Practice Questions and Answers

Practise for the GIAC Python Coder exam with 13 original questions, each with an answer and explanation.

Topics: Data Analysis With Python, Control Structures And Iteration, Creation Of Executables, Data Structures and 8 more.

Includes single answer, dropdown, multiple answers, drag and drop and order list. A new question is added every 15 days.

GPYC Practice Set Details

Vendor
GIAC
Exam Code
GPYC
Questions On This Page
13
Exam Topics Covered
12 of 12
Question Types
5
Newest Question
New Question
Every 15 days
Full Question Set
75
Certification
GIAC Penetration Testing
13 questions

GIAC GPYC Exam Questions and Answers by Topic

Control Structures and Iteration

1 practice question on this topicWhat this topic covers

Question 1

Added

Single Answer

A penetration-testing team processes a large newline-delimited file of observed hostnames. Blank lines and comment lines beginning with # must be ignored, while valid lines are normalized to lowercase and counted. The file is too large to load into memory, and malformed input should not stop processing later lines. Which loop design best meets the requirements while keeping the per-line handling clear?

Correct answer: D

Iterating over the file object reads it incrementally, avoiding memory growth proportional to the entire file. Using continue skips only the current blank or comment line, and a per-line exception handler lets later records proceed after malformed input. readlines() retains the full file in memory, so it conflicts with the stated scale constraint. A single read() in the while loop consumes all input rather than one line per iteration. break stops processing at the first ignored line instead of skipping it.

Creation of Executables

1 practice question on this topicWhat this topic covers

Question 2

Added

Single Answer

A red team must deliver a Windows assessment utility to an authorized client whose workstation has Python installed, but whose endpoint controls block unsigned executables and flag common PyInstaller bundles. The client permits signed scripts from the team's approved code-signing identity, requires source review, and prohibits techniques intended to conceal execution from antivirus. The utility should be easy to update during the engagement. Which delivery approach best satisfies these constraints?

Correct answer: C

The client already has Python, accepts signed scripts, and requires source review, so a reviewed script signed by the approved identity is the direct and maintainable delivery method. PyInstaller would create the very bundle type the controls flag and would not satisfy source review as cleanly. Renaming an executable does not change its contents or make it acceptable. Obfuscation and an in-memory decrypting launcher conflict with the explicit prohibition on concealing execution and are likely to trigger endpoint controls.

Data Analysis with Python

2 practice questions on this topicWhat this topic covers

Question 3

Added

Dropdown

An incident-response team receives a binary telemetry record containing a four-byte unsigned big-endian event identifier followed by a two-byte little-endian status value. Records are exactly six bytes, and the analyst must reject truncated input rather than silently unpacking a partial record. The team uses Python's standard struct module and needs a format string suitable for struct.unpack after validating the buffer length. Complete the format string for these fields.

Choose the correct value for each blank.

fmt = +
Correct answer:

fmt = '>I' + '

The identifier is four bytes and big-endian, so the format component is >I. The status is two bytes and little-endian, so its component is

Question 4

Added

Multiple Answers

An analyst compares how often source addresses appear in a packet capture. The dataset is too large for manually maintained nested conditionals, and the report must provide the number of distinct sources, the most frequent source, and a long-tail cutoff that includes sources whose frequency is at least a specified threshold. The analyst wants standard Python data structures and must avoid counting the same source repeatedly in a separate deduplication pass. Which two approaches directly support the requested analysis? (Choose two.)

Correct answer: A, D

A set provides the number of distinct source addresses, while Counter accumulates each source's occurrence count in one pass over the observations. Counter.most_common() orders entries by frequency, and filtering by the required threshold yields the requested long-tail subset. A set discards duplicate occurrences, so its size cannot represent per-source frequency. Assigning 1 in a dictionary comprehension also loses repeated counts. The mean is a summary of numeric values and cannot identify the most frequent categorical source.

Data Structures

1 practice question on this topicWhat this topic covers

Question 5

Added

Multiple Answers

A scanner receives protocol payloads as bytes. One field is defined as UTF-8 text, while another field is a single byte whose value must be preserved even when it is not valid UTF-8. The scanner also needs a mutable copy of the payload for in-place edits, and it must retain the original bytes unchanged for evidence. Which two implementation choices meet these requirements? (Choose two.)

Correct answer: A, D

UTF-8 decoding is appropriate for the field specified as UTF-8, and explicitly handling UnicodeDecodeError avoids silently inventing replacement characters when invalid text matters. A bytearray provides mutable byte-level editing, while retaining the original bytes preserves an immutable evidence copy. Replacing invalid byte values loses their exact identity. Latin-1 maps byte values to characters but does not make a string the authoritative binary representation. str(bytes) produces a representation such as b'...' rather than decoding the payload, and strings are immutable.

Database Interaction

1 practice question on this topicWhat this topic covers

Question 6

Added

Single Answer

An internal assessment tool stores discovered service records in SQLite. A hostname is supplied by an operator and may contain apostrophes or SQL metacharacters; the tool must search for an exact hostname match and must not construct SQL by concatenating input. The result should include all columns for matching rows. Which approach is best?

Correct answer: A

SQLite parameter binding keeps the hostname as data rather than SQL syntax, safely handles apostrophes and metacharacters, and the equality predicate implements an exact match. Manual escaping is easy to get wrong and still relies on string construction. LIKE with an added percent sign changes the requirement to pattern matching and can return non-exact matches. Interpolating repr() is not a substitute for database parameter binding and does not provide the required safe query construction.

Exception Handling

1 practice question on this topicWhat this topic covers

Question 7

Added

Order List

A log summarizer reads one record at a time and converts a field to an integer. A malformed field should produce a warning and allow later records to be processed, but failure to open the input file must be reported as a fatal error. Arrange the implementation steps in the order they should be performed.

Drag the steps into the correct order, or use the arrows.

  1. On conversion failure, warn and continue to the next record
  2. Convert the current record's field inside an inner try block
  3. Open the input file inside an outer try block
  4. Iterate over records from the open file
Correct answer:
  1. Open the input file inside an outer try block
  2. Iterate over records from the open file
  3. Convert the current record's field inside an inner try block
  4. On conversion failure, warn and continue to the next record

Opening inside the outer try block lets the program catch and report file-access failures separately. Iteration then provides one record at a time. Conversion belongs in a narrower inner try block so a ValueError for one field does not become a fatal file-level error. Handling that conversion failure with a warning and continue preserves processing of subsequent records. Reversing the scopes can either prevent iteration or cause a recoverable bad record to terminate the whole run.

Functions, Classes, and Objects

1 practice question on this topicWhat this topic covers

Question 8

Added

Single Answer

A team models network endpoints with a class. Each endpoint needs its own address and port, and instances should provide a method that returns an address-and-port tuple. A junior developer places a mutable list of endpoint observations on the class body, expecting each instance to have independent observations. Which change correctly preserves per-instance state while keeping the tuple-producing behavior?

Correct answer: C

Creating the observations list in __init__ gives every endpoint instance a distinct mutable list, preventing one instance's updates from appearing in another. Initializing address and port on self also makes them instance-specific, and an instance method can return (self.address, self.port). A class-level list is shared by all instances. Class methods operate on the class rather than naturally representing each endpoint's fields. Module-level variables and a static method likewise fail to maintain independent instance state.

Network Interfaces

1 practice question on this topicWhat this topic covers

Question 9

Added

Single Answer

A monitoring utility sends a small UDP status datagram to a configured collector. The collector address and port are known, delivery is best-effort, and the utility must not wait for an application-level response. A test run currently uses TCP and blocks while waiting for a connection to be accepted. Which socket design best fits the specified behavior?

Correct answer: C

UDP datagrams use SOCK_DGRAM, and sendto supplies the destination for an individual datagram without establishing a connection or awaiting an application response. A TCP stream requires connection setup and has the blocking behavior described in the failed implementation. UDP sockets do not use listen() and accept(), which are stream-server operations. The final design combines a stream socket with a datagram-style send pattern and therefore does not implement the required UDP communication.

Packet Analysis with Python

1 practice question on this topicWhat this topic covers

Question 10

Added

Drag And Drop

A network analyst uses Scapy to inspect a capture and build a focused summary. The analyst must distinguish packets by protocol layer, read the source address from an IPv4 header, and retrieve the TCP destination port without assuming that every packet contains TCP. Match each analysis need to the Scapy expression that performs it.

Drag each item onto its matching target. On a phone: tap an item, then tap a target.

Check whether a packet contains an IPv4 layer
Read the IPv4 source address
Read the TCP destination port
packet[TCP].dport
IP in packet
packet[IP].src
Correct answer:
  • Check whether a packet contains an IPv4 layer → IP in packet
  • Read the IPv4 source address → packet[IP].src
  • Read the TCP destination port → packet[TCP].dport

Scapy layer membership checks such as IP in packet allow code to determine whether a layer is present before indexing it. Once IPv4 is present, packet[IP].src accesses the source address field. The TCP destination port is available as packet[TCP].dport, but code should first verify TCP membership when captures can include other protocols. Using an IP field expression for the TCP port, or treating a layer object itself as a field value, would not retrieve the requested data.

Python Basics

1 practice question on this topicWhat this topic covers

Question 11

Added

Single Answer

A utility reads a text configuration file containing one target per line. Operators may leave blank lines or add surrounding whitespace, and the tool must preserve the original line numbering in error messages. The file may be large, so loading every line at once is undesirable. Which implementation best satisfies these requirements?

Correct answer: D

File iteration processes the input incrementally, while enumerate assigns the physical line number before blank lines are skipped. Stripping surrounding whitespace and testing for an empty result handles both blank lines and whitespace-only lines. readlines() loads all records and removing blanks before enumeration changes the reported line numbers. Splitting the whole file loses line boundaries and token indices are not line numbers. A counter incremented only for nonblank lines also reports logical record numbers rather than original file positions.

Regular Expressions

1 practice question on this topicWhat this topic covers

Question 12

Added

Single Answer

An audit script extracts IPv4-looking tokens from command output. A match must occupy a complete whitespace-delimited token, so an address embedded in a longer digit sequence must not be accepted. The script separately validates each octet numerically, so the pattern need not enforce the 0-255 range. Which regular-expression approach is most appropriate for extracting the token without consuming surrounding whitespace?

Correct answer: B

The negative lookbehind (?

Website Interaction

1 practice question on this topicWhat this topic covers

Question 13

Added

Dropdown

An authorized web-monitoring script must fetch a URL and retain a session cookie returned by the server so that a later request to the same host can use it. The team is using Python's standard urllib.request interface and does not need a browser engine or JavaScript execution. Complete the setup and request flow using the standard cookie handler and opener APIs.

Choose the correct value for each blank.

jar = http.cookiejar.CookieJar()\nhandler = urllib.request.(jar)\nopener = urllib.request.build_opener(handler)\nresponse = opener.(url)
Correct answer:

jar = http.cookiejar.CookieJar()\nhandler = urllib.request.HTTPCookieProcessor(jar)\nopener = urllib.request.build_opener(handler)\nresponse = opener.open(url)

HTTPCookieProcessor connects the CookieJar to urllib's request handling, allowing received cookies to be stored and sent on later requests made through the same opener. Calling opener.open(url) performs the request using the configured handler chain. HTTPHandler does not manage cookies, ProxyHandler configures proxy behavior, and HTTPBasicAuthHandler addresses authentication rather than cookie persistence. urlopen is a module-level convenience function rather than the opener method used here; Request constructs a request object, and install_opener installs an opener globally rather than issuing the request.

More GIAC Practice Questions

Get the Full GIAC GPYC Dumps as PDF and Practice Test

13 questions are free on this page and the full set has 75. It comes as a PDF and an online practice test, with 90 days of free updates.