ITECH5104 - Fundamentals of Python Programming

Download Solution Order New Solution

Assignment 1 Real-World Text Processing and Analysis

Overview

In this assignment, you will apply your Python programming skills to solve practical text processing problems inspired by real-world applications such as data security, bioinformatics, and pattern recognition. Here, you will develop robust programs that process and analyze text-based data.
This assignment incorporates problem-solving, conditionals, loops, string manipulation, functions, and file handling, ensuring that your work reflects real-world programming challenges.

Learning Outcomes Assessed

The following course learning outcomes are assessed by completing this assessment:

Knowledge:
• K1. Identify and use correct Python syntax.
• K2. Apply programming constructs to design and implement solutions.
• K4. Write well-structured, documented, and readable code.

Skills:
• S1. Use pseudocode/algorithms for structured problem-solving.
• S2. Implement solutions using fundamental programming constructs.
• S4. Explain program functionality by analyzing given code.

Application of Knowledge and Skills:
• A1. Adapt algorithms to various real-world contexts.
• A2. Design and implement program solutions using effective coding practices.

Assessment Details

Task 1: Encrypted Text Transformation

Scenario:
A cybersecurity firm wants to implement a simple text encryption algorithm. They request a Python function that applies a variation of the Thue-Morse sequence1 to obfuscate text.

1 The Thue-Morse sequence is a binary sequence that is generated iteratively using an inversion rule, which replaces 0 with
1 and 1 with 0 (Allouche & Shallit, 1999).

  • ????0 = "0" ????1 = ????0 + ????????????????????????????(????0) = "0"+ "1" = "01"
  • ????2 = ????1 + ????????????????????????????(????1) = "01" + "10" = "0110"
  • ????3 = ????2 + ????????????????????????????(????2) = "0110" + "1001" = "01101001"

Requirements: 

Implement a function encrypt_text(message: str, n: int) -> str that:

  • Takes a text message (message) as input.
  • Applies three iterations of a transformation:
    • Iteration 1: Shift every char forward by +3 in the alphabet.
    • Iteration 2: Position-Dependent Inversion (You have to ignore spaces): If index is
      even → shift backward by -2, If index is odd → shift forward by + 4
    • Iteration 3: Use the morse-based shift. Consider first 10 bits of Morse 0110100110
      and apply: if 0 → Shift by +1, if 1 → shift - 1
       
  • Returns the transformed text.

Note: Ensure that only characters are transformed while keeping punctuation and spaces unchanged. When you shift letters, they should wrap around within the alphabet. When you shift digits, they should wrap around within 0–9: '9' shifted +1 → '0'.

Note: For each iteration, you compute the Thue-Morse pattern up to the required length, and then apply rules based on whether the pattern at that index is 0 or 1.

Task 2: Text Decryption and Pattern Reversal Analysis

Scenario: Now that you have implemented an encryption method based on an extended Thue-Morse sequence, your next challenge is to reverse-engineer the process. In real-world cybersecurity, encryption systems must be designed with controlled reversibility, allowing the original message to be retrieved when necessary. Your task is to develop a decryption function and analyze whether the transformations applied in encryption can be effectively reversed.

Requirements: Implement a function decrypt_text(encrypted_message: str, n: int) -> str that:

  • Takes an encrypted text and the number of iterations (n) as input.
  • Reverses the extended Thue-Morse sequence transformation applied during encryption.
  • Returns the original plaintext message.
  • Describe the tests you ran to ensure your decryption function works correctly. Include at least two test cases:
    • One where the encrypted text is successfully restored to the original.
    • One where incorrect parameter is given, explaining the output.
  • List at least three Python features (e.g., conditional expressions) that you used in your implementation, and explain why you chose them.

Assessment Brief Summary

Assessment Type: Programming Assignment (Python)

Purpose:
To apply Python programming skills to solve real-world text processing problems using encryption, decryption, and analysis techniques.

Key Pointers to be Covered

  1. Task 1: Encrypted Text Transformation

    • Implement encrypt_text(message: str, n: int) -> str.
    • Apply three transformations:
      • Iteration 1: Shift characters by +3.
      • Iteration 2: Position-based shift (even → -2, odd → +4; ignore spaces).
      • Iteration 3: Apply Thue-Morse sequence rules:
        • 0 → shift +1
        • 1 → shift -1
    • Maintain wrapping for alphabet and digits.
    • Preserve punctuation and spaces.
  2. Task 2: Text Decryption and Pattern Reversal Analysis

    • Implement decrypt_text(encrypted_message: str, n: int) -> str.
    • Reverse transformations to retrieve the original text.
    • Demonstrate correctness with at least two test cases:
      • Successful decryption.
      • Incorrect parameters leading to different output.
    • Identify three Python features used (e.g., loops, conditionals, string handling) and justify their use.

Learning Outcomes Assessed:

  • Knowledge (K1, K2, K4): Python syntax, programming constructs, readable code.
  • Skills (S1, S2, S4): Structured problem-solving, implementation of constructs, code analysis.
  • Application (A1, A2): Adapting algorithms to contexts, designing effective solutions.

Assessment Approach Step-by-Step Mentor Guidance

  1. Understanding the Problem:

    • Mentor clarified encryption/decryption logic and why Thue-Morse is used in real-world cybersecurity.
    • Broke down each transformation into smaller logical steps.
  2. Breaking Tasks into Sub-Problems:

    • Guided the student to design pseudocode before coding.
    • Focused first on simple shifting logic (wrapping alphabets and digits).
    • Then extended to position-based rules and Thue-Morse pattern application.
  3. Implementing Task 1 (Encryption):

    • Mentor explained modular arithmetic for wraparound.
    • Ensured student separated concerns by writing helper functions (e.g., shift_char).
    • Checked correct handling of spaces, punctuation, and digits.
  4. Implementing Task 2 (Decryption):

    • Mentor guided student to carefully reverse each transformation in exact order.
    • Explained pitfalls of reversibility (must undo last step first).
    • Encouraged testing with known inputs to validate logic.
  5. Testing and Debugging:

    • Created multiple test cases to verify:
      • Correct restoration of original message.
      • Handling of edge cases (digits, punctuation, incorrect parameters).
    • Mentor emphasized debugging with print statements and stepwise verification.
  6. Explaining Python Features Used:

    • Mentor asked student to reflect on why conditionals, loops, and string slicing were chosen.
    • Reinforced the importance of documenting code for readability.
  7. Final Review:

    • Checked function readability, comments, and structure.
    • Ensured alignment with learning outcomes and assignment requirements.

Outcome Achieved

  • Student successfully implemented both encryption and decryption functions.
  • Demonstrated ability to use pseudocode, modular arithmetic, loops, and string operations.
  • Produced readable, well-documented Python code that met academic standards.
  • Validated solutions with test cases, showing understanding of both correctness and error handling.

Learning Objectives Covered

  1. Programming Knowledge: Applied Python syntax and constructs effectively.
  2. Problem-Solving Skills: Used pseudocode and algorithms to design structured solutions.
  3. Implementation: Developed encryption and decryption using loops, conditionals, and file/string handling.
  4. Analysis: Explained program functionality and tested different cases.
  5. Application: Adapted algorithmic thinking to real-world text processing and cybersecurity contexts.

Boost Your Grades with the Right Support

Looking for guidance on how to structure and present your assignment? Our sample solutions are available to help you understand formatting, research integration, and step-by-step problem-solving. These files are a great way to learn how to approach similar tasks confidently.

Important Note: The sample provided is strictly for reference and learning purposes only. Submitting it as your own work will be considered plagiarism and may lead to serious academic consequences.

If you need a unique, plagiarism-free assignment tailored to your topic, our team of expert academic writers is here to help. With a fresh solution, you get:

  • 100% original content written specifically for your requirements
  • Proper citations, formatting, and academic standards followed
  • Clear explanations to strengthen your subject knowledge
  • On-time delivery so you never miss a deadline

Get the best of both worlds learn from the sample or secure a custom-written solution to achieve your academic goals.

Download Sample Solution                           Order Fresh Assignment

Get It Done! Today

Country
Applicable Time Zone is AEST [Sydney, NSW] (GMT+11)
+

Every Assignment. Every Solution. Instantly. Deadline Ahead? Grab Your Sample Now.