GPYC Exam Questions
71 real GPYC exam questions with expert-verified answers and explanations. Page 1 of 2.
- Question #1
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]
- Question #2
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)
- Question #3
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',...
- Question #4
A user enters unexpected data into a program. Which functionality can the programmer use to present an understandable error message to the user?
- Question #5
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...
- Question #6
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)
- Question #7
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
- Question #8
What is the output of the following line of code typed into a Python interactive session? >>> print(bin(0b101010 ^ 0b111000))
- Question #9
Which of the following would produce this list? [65, 66, 67, 68]
- Question #10
What is the output of the ls(TCP) function?
- Question #11
What happens if a programmer fails to build exception handling into a program, and the program encounters an unexpected error condition?
- Question #12
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")
- Question #13
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
- Question #14
After calling a subprocess in a Python program, the program returns an error code of "0". What does this indicate?
- Question #15
What is the output of the following command typed in Python interactive mode? >>> print("and" in "And now for something completely different")
- Question #16
Which python regular expression method should be used to match any character in a-z, 0-
- Question #17
What is the output of the following commands typed in the Python Interactive shell? ``` >>> print("Try",end=' ') ... except: ... print("Except",end=' ') ... else: ... print("Else",...
- Question #18
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...
- Question #19
Which of the following import statements will add the ability to parse data with regular expressions to your script?
- Question #20
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) ```
- Question #21
What is the output the following commands are typed in Python interactive mode? ``` >>> a = 5 >>> b = 10 >>> d = "a" + "c" >>> print (d) ```
- Question #22
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:...
- Question #23
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?
- Question #24
Which command will search for python modules that will have the ability to parse pcap files?
- Question #25
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...
- Question #26
What does executing the following code in Python 3 result in? '\x0066'
- Question #27
A programmer includes the following line in his program. What does this enable him to do? from scapy. all import *
- Question #28
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
- Question #29
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")
- Question #30
A multi-byte character encoded with UTF-8 has the first byte 11861101. What will the next byte begin with?
- Question #31
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(...
- Question #32
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...
- Question #33
What is the output of the following line of code typed into a Python interactive session? >>> print (~100)
- Question #34
What is the output of the following line of code typed into a Python interactive session? >>> print (int ("1111", 2))
- Question #35
What does the "enumerate" function return when applied to a list?
- Question #36
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...
- Question #37
Review the following code. import struct a = "\x01\x00" struct.unpack("<H",a) What is the output?
- Question #38
When using the Python "sockets" module, which of the following calls is used to transmit data to a specific IP address?
- Question #39
How many bytes are used to store a 16 bit Unicode character?
- Question #40
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...
- Question #41
Review the following Python code: hr = set([('Smith', 'Johnson', 'Williams', 'Jones')]) it = set(['Johnson', 'Jones', 'Brown']) x = hr.intersection(it)
- Question #42
What will be printed below if the value of x is 7? >>> if(x): ... print(x)
- Question #43
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...
- Question #44
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...
- Question #45
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...
- Question #46
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?
- Question #47
What will the contents of the "__name__" variable be if the program "gpyc.py" is run as a standalone program?
- Question #48
When accessing the hard drive directly, how would the character 'B' be stored?
- Question #49
Third-party Python modules like Scapy and Beautiful Soup are used for what purpose?
- Question #50
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 ```