Programming

Important Exam Information

  • Content:

    • All lesson content included in the exam.

    • Log in to SNAP to check venue and seat number.

  • Preparation Advice:

    • Ensure laptop is in good working condition with adequate storage and memory space.

    • It is permitted to use Jupyter Notebook during the exam to test code.

    • Organize notes and have lesson summaries (especially Lesson 26) readily available.



Self-Assessment Paper Structure

  • Format:

    • Section A: Multiple Choice Questions

    • Section B: Fill in the blanks

    • Section C: Essay coding



Coding Questions Explanation

  • Python Basics:

    • Use correct string methods (e.g., len, find) from respective lessons.

Sample Coding Questions:
  1. Question on String Methods:

    • Determine the length of a string:

      • Answer: len() returns the length.

  2. Find method:

    • The find() method returns the lowest index of the first occurrence; returns -1 if not found.

  3. Use of break statement:

    • It stops the current loop immediately.


Data Handling: NumPy and Pandas

  • Pandas DataFrame Definition:

    • Use square brackets and the column name to select columns in a DataFrame.

  • Cleaning Data:

    • For missing values, remember to use dropna() and droppeduplicate() for duplicates.


Preparing for Open Book Exam

  • Suggested to have all Jupyter Notebook files and lesson notes ready during the exam for quick reference.


Python Programming Questions

Common Concepts Discussed:
  1. Loops and Conditional Statements:

    • Use for loops to iterate over elements.

    • Understand nested conditions and check inputs using the 'if-else' structure.

  2. Functions:

    • User-defined functions using the def keyword.

  3. Random Choices:

    • Using random.choice() for selecting items from a list or array.


Data Visualization with Matplotlib

  • Always import matplotlib.pyplot as plt for plotting.

  • To customize plots, use plt.title(), plt.xlabel(), and plt.ylabel().

  • For line plots, use plt.plot() and ensure to specify x and y axis data correctly.