Python
0.0.0.0 is used for
All ip addresses on requested port
with open("MyFile.txt", "w") as file: file.write("Hello World")
"Hello World" is written inside "MyFile.txt".
What happens when a variable is created in the global scope (main scope)?
A name is declared as global, and means when the function wants to create a new variable within its scope, it will use global variable
Boolean AND
Both conditions must be true
Which programming is hard to learn, works in any environments, has few libraries, and many frameworks?
Java
AND True & False
False
How does sockets send & receive?
In Bytes (b)
Boolean OR
Only one of the operations needs to be true
NOT True
False
Which of the following is NOT a Python data type?
Switch
While performing the Echo Communication home project, the command socket.accept() crashed the script. What could be the problem?
The accept() command was not assigned 2 variables
What is the purpose of the None keyword in Python?
Define a null variable or object
Boolean XOR
Exclusive OR. True if the result of the operation aren't similar
What is Python?
High-level programming language, easy to deploy & learn. It's design emphasizes code readability
How does a socket enable communication?
In logical, local, and physical external networks. It enables usage of the internet via a browser, which involves a client connecting with a site server and the server transferring information back to the client.
num_list = [1, 2, 3, 4] for num in num_list: num_list.append(num) print(num) What is the output of this code?
Infinite loop
How can python sockets be used by attackers ?
It can be used to create malicious code that acts as a reverse shell from client to the attacker (listener)
What is a socket?
It is an endpoint of communication between client & server. Messages are sent via TCP or UDP
When sending text via socket library to a server, why should the text be encoded?
It must be passed as a byte object
What are Python data type?
List, Dictionary, Tuple
Programs
Lists of instructions the computer performs in sequential order. They typically include mathematical operations
What happens with File Access Mode: a
Opens a file for appending OR creates file if it does not exsist
What happens with File Access Mode: r ?
Opens a file for read only
Of the following, which is NOT an advantage of an interpreter compared to a compiler?
Speed
When accepting data in client-server communication, what is the meaning of: recv(2048)
The limit for the amount of bytes to accept
Which command would you use to gracefully exit in case of an error?
Try and Except
How would you assign a tuple to variable myTuple?
myTuple = (1, 2, 'name', 'time')
dictionary = {"list" : [1, 2, 3]} dictionary["list"].append([4, 5, 6]) for value in dictionary: print(value) What is the output of this code?
"list"
Boolean NOT
Reverse the result of the operation
Compiler / compilation
-Takes more time, but the code execution is faster -code is compiled for a specific operating system -the source code is typically unavailable and the compiled data can be read -once the binary is compiled the source code is no longer needed
mysocket.connect(("10.0.0.5", 5000)) is an example of
A client connection
source code
A program written in a high level programming language
mysocket.bind(('0.0.0.0',5000)) is an example of what?
A server connection
What does programming language include?
A set of instructions that yield various types of results
Which programming only works in specific environments, .NET libraries & framework, and syntax is difficult to learn?
C#
Python Interpretation
Default language for python, Reads top to bottom & left to right, performs instruction validation, results returned per instruction in sequential order
What do Python, C#, and Java have in common?
Large community
What happens with File Access Mode: w
Opens a file for writing
What happens with File Access Mode: b ?
Opens a file in binary
Which programming works in any environment is easy to learn, has many libraries and has many frameworks?
Python
You installed PyCharm and started writing a little script that prints out "I love hacking with Python". However, PyCharm won't allow running the script. What can be the solution to the problem?
Setting an interpreter
How should a Main scope in code be defined?
So that it will be executed, and not any other main function from an external source
OR true & false
True
XOR True & False
True