GPYC Exam Questions
71 real GPYC exam questions with expert-verified answers and explanations. Page 1 of 2.
- Question #1Python Fundamentals & Command Line Tools
Which of the following will be the value of the variable y? >>> x = {'a': [1, 2, [3,4]], 'b': [[5, 6], 7]} >>> y = x['b'][0][1]
nested data structuresdictionary indexinglist indexingsubscript notation - Question #2Python Fundamentals & Command Line Tools
What are the contents of the variable x when the following is executed in a Python interactive session? x = "So you want a GIAC Certification?" x.split()[0][1] print(x)
string immutabilitystring methodssplitprint - Question #3Python Fundamentals & Command Line Tools
Which of the following commands would correct the error in the screenshot? >>> tcp_flags_as_str(flag): ... def tcp_flags_as_str(flag): ... tcp_flags = ['CWR', 'ECE', 'URG', 'ACK',...
import statementsmodulesNameErroritertools - Question #4Python Fundamentals & Command Line Tools
A user enters unexpected data into a program. Which functionality can the programmer use to present an understandable error message to the user?
exception handlingerror messagesuser input - Question #5Python Fundamentals & Command Line Tools
A programmer attempts to run the Python program hello.py as follows, but an error occurs. What is the cause of this error? student@573:~ cat hello.py print "hello" student@573:~ ch...
shebang linescript executionfile permissionscommand line - Question #6Python Fundamentals & Command Line Tools
Review the following code, written in Python. What are the contents of variable a? a = set(['cat', 'dog', 'bird']) b = set(['violet', 'rose', 'dandelion']) a.update(b)
setsset.update()set operationscollections - Question #7Python Fundamentals & Command Line Tools
When the following program "question.py" is executed with Python what is the output? $ cat question.py def i(i): i=i+1 return i print(i) $ python question.py
function referencefunction objectsfirst-class functionsprint - Question #8Python Fundamentals & Command Line Tools
What is the output of the following line of code typed into a Python interactive session? >>> print(bin(0b101010 ^ 0b111000))
bitwise XORbinary arithmeticbit manipulationoperators - Question #9Python Fundamentals & Command Line Tools
Which of the following would produce this list? [65, 66, 67, 68]
map functionordASCII valuesbuilt-in functions - Question #10Network & Web Programming
What is the output of the ls(TCP) function?
ScapyTCP layerpacket fieldsnetwork analysis - Question #11Python Fundamentals & Command Line Tools
What happens if a programmer fails to build exception handling into a program, and the program encounters an unexpected error condition?
exception handlingprogram terminationerror conditions - Question #12Python Fundamentals & Command Line Tools
Review the following Python 3 code. while True: try: n = input("Enter a number: ") n = int(n) break except ValueError: print("Not an integer") print("Thank you")
try/exceptinput validationtype conversionwhile loop - Question #13Python Fundamentals & Command Line Tools
What is the output of the following program when executed with the Python Interpreter? student@573:~ cat program.py a = 10 a = a + 5 a += 5 print(a) student@573:~ python program.py
arithmetic operatorsaugmented assignmentvariable assignment - Question #14Advanced Python for Security Automation
After calling a subprocess in a Python program, the program returns an error code of "0". What does this indicate?
subprocessreturn codesprocess exit status - Question #15Python Fundamentals & Command Line Tools
What is the output of the following command typed in Python interactive mode? >>> print("and" in "And now for something completely different")
string membershipcase sensitivityin operatorsubstring search - Question #16Advanced Python for Security Automation
Which python regular expression method should be used to match any character in a-z, 0-
regular expressionscharacter classes\w metacharacterpattern matching - Question #17Python Fundamentals & Command Line Tools
What is the output of the following commands typed in the Python Interactive shell? ``` >>> print("Try",end=' ') ... except: ... print("Except",end=' ') ... else: ... print("Else",...
try/except/else/finallyexception flowcontrol flowerror handling - Question #18Web Scraping & Forensics with Python
What would be the result of the following code in Python? ```python registry_key = reg_handle.open("Microsoft\Windows NT\CurrentVersion") map(lambda x: x.path(), registry_key.subke...
Windows registrydigital forensicsmap/lambdaregistry subkeys - Question #19Python Fundamentals & Command Line Tools
Which of the following import statements will add the ability to parse data with regular expressions to your script?
import statementre moduleregular expressions - Question #20Python Fundamentals & Command Line Tools
What willt the code in the screen capture print when executed? ```python >>> x=4 >>> y=0 >>> if(y): ... x=x+2 ... print(x) ... else: ... x=x-2 ... print(x) ```
boolean truthinessfalsy valuesconditional statementsif/else - Question #21Python Fundamentals & Command Line Tools
What is the output the following commands are typed in Python interactive mode? ``` >>> a = 5 >>> b = 10 >>> d = "a" + "c" >>> print (d) ```
string concatenationdata typesPython operatorsinteractive mode - Question #22File System & Data Management
A log file is stored in variable "a". The file has the following format for each log entry, in order, stored in big endian: Field 1: 2-byte integer Field 2: 2-byte integer Field 3:...
struct modulebinary unpackingendiannessformat strings - Question #23Advanced Python for Security Automation
If the variable "example" contains a handle to a subprocess object, which of the following would show all of the possible results of running the subprocess?
subprocess modulestdoutstderrprocess output - Question #24Python Fundamentals & Command Line Tools
Which command will search for python modules that will have the ability to parse pcap files?
pippackage managementmodule searchcommand line - Question #25Python Fundamentals & Command Line Tools
Review the following code. Which of the following would give the results of variable "total"? ```python def addTogether(number1,number2,number3): total=number1+number2+number3 retu...
functionsparametersreturn valuesfunction calls - Question #26Python Fundamentals & Command Line Tools
What does executing the following code in Python 3 result in? '\x0066'
hex escape sequencesstring literalscharacter encodingPython syntax - Question #27Network & Web Programming
A programmer includes the following line in his program. What does this enable him to do? from scapy. all import *
scapypacket manipulationlibrary importsnetwork packets - Question #28Python Fundamentals & Command Line Tools
Which of the following is the final output when program.py is executed with a Python Interpreter? student$573:~ cat program.py a = 10 a = 5 print(a) student$573:~ python program.py
variable assignmentPython executionreassignmentprint function - Question #29Web Scraping & Forensics with Python
What is the output when the following commands are typed in Python interactive mode? >>> import re >>> re.findall(r"tag.*tag", "i want tag to go tag to sans tag")
regular expressionsre modulegreedy matchingfindall - Question #30Python Fundamentals & Command Line Tools
A multi-byte character encoded with UTF-8 has the first byte 11861101. What will the next byte begin with?
UTF-8multi-byte encodingcontinuation bytesbinary encoding - Question #31Interacting with APIs & Databases
Review the lines of code below. Which of the following actions will they perform? ctrack=cookielib.CookieJar() cproc=urllib2.HTTPCookieProcessor(ctrack) bconn=urllib2.build_opener(...
urllib2HTTP cookiescookielibweb sessions - Question #32Python Fundamentals & Command Line Tools
Review the following code: a = "123" b = "456" if ("1" in a) ^ ("4" in b): print("red") elif ("2" in a): print("blue") elif ("7" in b): print("yellow") What is the output of this c...
XOR operatorboolean logicconditional statementsstring membership - Question #33Python Fundamentals & Command Line Tools
What is the output of the following line of code typed into a Python interactive session? >>> print (~100)
bitwise NOTtwo's complementbitwise operatorsinteger operations - Question #34Python Fundamentals & Command Line Tools
What is the output of the following line of code typed into a Python interactive session? >>> print (int ("1111", 2))
int() functionbinary conversionnumber basesstring to int - Question #35Python Fundamentals & Command Line Tools
What does the "enumerate" function return when applied to a list?
enumerateiterablestuplesbuilt-in functions - Question #36Network & Web Programming
A connection between a python raw socket server and a netcat client is being made over port 1100 on the same computer. The last command in the Python terminal is: >>> connection.re...
raw socketsport bindingsocket acceptnetwork server - Question #37File System & Data Management
Review the following code. import struct a = "\x01\x00" struct.unpack("<H",a) What is the output?
struct modulelittle endianbinary unpackingunsigned short - Question #38Network & Web Programming
When using the Python "sockets" module, which of the following calls is used to transmit data to a specific IP address?
socketssendtoUDP transmissionsocket methods - Question #39Python Fundamentals & Command Line Tools
How many bytes are used to store a 16 bit Unicode character?
UnicodeUTF-16character encodingbyte size - Question #40Python Fundamentals & Command Line Tools
What is the output of the following line of code typed into a Python interactive session? student@573:$ cat question.py b = some_func() a = b + 10 print(a) def some_func(): return...
function definition orderNameErrorPython executionmodule scope - Question #41Python Fundamentals & Command Line Tools
Review the following Python code: hr = set([('Smith', 'Johnson', 'Williams', 'Jones')]) it = set(['Johnson', 'Jones', 'Brown']) x = hr.intersection(it)
setsintersectiontuple vs listcollections - Question #42Python Fundamentals & Command Line Tools
What will be printed below if the value of x is 7? >>> if(x): ... print(x)
truthinessconditionalsif statementboolean evaluation - Question #43Web Scraping & Forensics with Python
Which regular expression will match all date-time stamps for log files of the format shown in the screen capture? Mon May 9 23:13:37.379 <kernel> AWDL Sync Enabled 0 Mon May 9 23:1...
regexlog parsingre.findalltimestamp pattern - Question #44Python Fundamentals & Command Line Tools
What is the output of the following when executed in a Python shell? >>> listoflists = [[1,2],[3,4]] >>> copyoflists = list(listoflists) >>> copyoflists.append([5,6]) >>> copyoflis...
shallow copylist of listsmutable objectsmemory model - Question #45Python Fundamentals & Command Line Tools
What is the cause of the error shown below? >>> x=re.match("th", "this is the test") Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 're' is...
importNameErrorre modulemodules - Question #46Python Fundamentals & Command Line Tools
Given that mylist = [1,3,2,1,4,5,3] how do you remove all occurrences of the number 1 from the list in Python?
list comprehensionfilteringremove elementslist manipulation - Question #47Python Fundamentals & Command Line Tools
What will the contents of the "__name__" variable be if the program "gpyc.py" is run as a standalone program?
__name____main__module executionPython scripts - Question #48File System & Data Management
When accessing the hard drive directly, how would the character 'B' be stored?
binary encodingASCIIcharacter storagebit representation - Question #49Advanced Python for Security Automation
Third-party Python modules like Scapy and Beautiful Soup are used for what purpose?
ScapyBeautiful Soupthird-party modulesnetwork traffic - Question #50Python Fundamentals & Command Line Tools
Which of the following is in the output when program1.py shown below is executed? ``` $ cat program1.py a = 5 b = 10 d = a + c print(d) $ python program1.py ```
NameErrorundefined variablePython errorsscript execution