Midterm Information: Covered materials: Lectures 1 to 9; Assignments 1 and 3. Priority for study: Priority 1: Homework - if you missed any point, make sure you know how to do it Priority 2: Lecture slides/Your own assignment code Priority 3: Other information if you do not understand part of the slides Most questions in the midterm are related to coding: writing code segments to achieve certain tasks or predicting the output of a code segment. --- Format: Short answer questions (around 70 points) and longer answer questions (3 questions, around 30 points). Two of the longer answer questions are related to Assignments. Short answer question examples: 1) What is the output when the following code executes def incr(a): a[0] = a[0] + 1 lst = [1, 2, 3] incr(lst) print('lst = ', lst) 2) Let str be a string. Write the code to change the last character in str to be 'Z'. A longer answer question example: Write the isPrime(x) function that determines whether x is a prime number. ---- Content: Lecture 1 to Lecture 9 Lecture 1: Introduction to Python - Interpreted languages .vs. compiled languages - Strong typing and dynamic typing in Python - Numeric types - Sequence data types and operations (slicing and others) - Mutable and immutable objects - Parallel assignment - Control flow: if, while, for (the range function) - Control flow manipulate statements: break, continue, pass, else Lecture 2: Modules and functions - Command line arguments - Modules: * __name__ variable * semantics of import * Module search path - Functions: * positional argument, default argument, keyword argument * issues with default mutable argument * variable number of positional arguments and keyword arguments * parameter passing: pass by assignment * function as first-class object * function closure * decorator * generator - Names and Scopes * local scope, enclosing scope, global scope, and built-in scope * LEGB rule * changing default scope: global and nonlocal statements Lecture 3: Sequence data types and file IO - Strings (immutable) * modifying a string * slicing * built-in methods * string formatting: f-string - Lists * creation/accessing elements/slicing/insert/remove * Use as stacks and queues - Sets * creation/operations - Tuples * creation/operations - Dictionaries * creation/accessing/updating/other functions File operations: * open/close/read/write/tell/seek * managing file access using with Lecture 4: Functional programming and Object-oriented programming - Lambda function - Functional programming tools * filter/map/reduce - Object-oriented programming * class and derived class * constructor (__init__ function) * class variable and object variable * private variable/methods Lecture 5: Introduction to Parallel Computing - Parallel computer/parallel computing/parallel programming - Flynn's taxonomy - Dependency - Speedup and scalability (weak scaling and strong scaling) - Amdahl's law - Gustafson's law Lecture 6: Python threads - Processes .vs. threads/multiprocessing .vs. multithreading - Concurrent programming/parallel programming - Python threads: * write multi-thread Python code * thread synchronization: critical section and lock Lecture 7: Python multiprocessing - Write multi-proces Python code - Inter Process Communication using message queue - Write multi-process code using the master-worker design pattern Lecture 8: Introducting to Networking - Computer network and its elements * hosts, end systems/routers, switches, and middleboxes/links - Layered architecture * protocol and service interface - Types of services - ISO/OSI reference model * what does each layer specify? - TCP/IP reference model * what does each layer specify? - Network performance metrics * latency and bandwidth * What are the components in end-to-end latency? * how do we measure end-to-end bandwidth? Lecture 9: Socket Programming with Python - Socket interface: socket/bind/listen/connect/accept/read/write/close - Client-server paradigm - Sequential and concurrent server