Lab 2 / Flowcharts to Python
This lab asks you to write Python code based on a provided flowchart that runs a binary search algorithm to find an item in an array.
Learning objectives
Interpret branching and looping logic in flowcharts
Use condition-controlled loops (WHILE) and exception handling
Flowchart

Instructions
Analyse the file
binary_search_flowchart.png
andDo a dry run of the algorithm and create trace tables for the following test cases:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
[G, H, I, J, K, L, M, N, O, P]
[blue, brown, green, orange, pink, purple, red, white, yellow]
Write a Python program that implements the logic described in the flowchart.
Test your program with the test cases provided above.
Last updated
Was this helpful?