Python basics
Networks
Recursion/Iteration
Testing/Ducktype
Exception/Namespace/Pathlib
100

True or false, Python executes code line by line.

True

100

What is TCP and UDP?

TCP - Two way connection that only  performs one cycle of network connection

UDP - One way connection that only perfroms one cycle of network connection.

100

What is recursion?

recusion is the idea of calling the function itself inside the function

100

What is duck typing?

Dynamic typing!

If something quacks like a duck, walk like a duck, then it must be a duck.


100
What is the difference between assert and try except?

Assert are test cases that make sure you are receiving the correct input or that your functions are working properly. Throws an error if the expected data is incorrect.

    Try excepts are error handling so that your code never runs into an unhandled error. 

200

what does if __name__ == "__main__" do?

Stuff inside this conditional only runs when the file is being directly executed.
200

What is an API?

An application programming interface is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how to build or use such a connection or interface is called an API specification.

200

What is the difference between recursion and iteration?

recursion uses function to loop through code.

iteration uses for or while to loop through code.

200

What are three types of testing?

Black white and grey.

200

What are the four namespaces and what happen after the four namespace.

Local, non-local(enclosing),global,built-in.


NameError wil be thrown
300

What is class in python? Name some characteristics of class and their purpose.

Class is a blueprint that creates objects in python. Abstraction and encapsulation are some characteristics of class.

300

What is sockets?

A network socket is a software structure within a network node of a computer network that serves as an endpoint for sending and receiving data across the network. The structure and properties of a socket are defined by an application programming interface for the networking architecture.

300
Name one function you know that you can implement in both recursion and iteration?

Fibonacci sequence.

300

What are the differences between unittest and integral test? When do you use these?

Unittest is to test independent function.

Integral test is to test multiple functions where one input depends on the output.



300
Why do we need the pathlib module? Think about the issue with mac vs windows
Mac(Unix) and Window(DOS) uses different schemes when identifying paths. Mac uses / whereas Windows uses \. Using pathlib we can disregawrd this issue and treat everything just as a regular path.
400

Name some external libraries/modules that we use for ICS 32.

requests, socket, pathlib

400
What is a HTTP request. Is it considered an API? TCP? UDP?

HTTP is a two way connection that works extremely similar to API. You give an url and expects a html webpage to be returned.

400

What does the following do:

def fib(a):

    if a<=1:

        return a

    else:

        return fib(a-1) + fib(a-2)

This is fibonacci sequence

400
How do you run a unittest by using the unittest module?

use unittest.run() in main


400
What will the following code prints?


x =5 

def a():

   global x

   x = 3


def b():

   x=2

print(x)

a(x)

b(x)

print(x)




5

3


500
Will python always pass by value or pass by reference?

Pass by reference

500
How do you implement an API call? What is the required elemenets that an API call needs?


Bonus 100p:

What are the two types of API? What are the differences between them?


you can use the requests module. API always requires an API key.


bonus 100p answer:

two types of API are get and post. Get usually doesn't require a parameter within the request, Post usuall require a parameter within the request.

 For example, you would request a class schedule for winter 2023 using a get request. 

But you would want to use post to request an enrollment into a class. 



500

What happens if you search "Recursion" on google.

Recursion
500

What is edge/boundary case?

The extreme test case that usually you don't expect happening.
500
How do you find all files that has a ".png" extention in the current directory and all the sub-directory?

    from pathlib import Path

     p = Path().glob(“**/*.png”)