IFT 10

( This file is the basis for the questions Q8 Q7 Q6 Q5 Q4 for a file upload question . The other 3 questions are in blackboard

Note: for the Python programs

***Code these questions in your Python editor, run them and paste the code and result into the space below each question.  You may need to edit the pasted in  text since spacing and line breaks could be lost. So, put in line breaks and restore the proper indents.( you don’t need exact indents but lined up indents are required. 

Remember, Python indices for arrays start at zero. An exception is the binary search question, where the indices start at ‘1’.

Q8 Python Program

Given an array of Fahrenheit temperatures below,

Write a Python program that will go through this array, print out each temperature and then at the end , print out the average temperature. Use a WHILE loop. Use the Python ‘len’ function to determine array size.

temperatures = [ 60, 65, 73, 54, 78, 75]

Q7: Manual Procedure – Binary Search

Given the sorted array below, search for the target value of ‘600’, using a manual binary search procedure. Fill out the supplied table and write down the pair of lower and upper bounds for each iteration as well as the mid index and value at that index.

Assume arrays indices start at “1”.

Part a) – fill out the table

binItems= [5, 12, 14, 18, 129, 200, 397, 408, 500. 550, 600]

Step lower bound upper bound mid index value at mid-index

11

Part b) How many iterations did you need? ---

Q6 Python Program – Loop/Iterations

Scenario: Given the binItems array in Q7 above, write the Python code to loop through the array and print the largest element. Use a FOR loop structure.

Hint: in your initialization section, initialize max = float(‘-inf’) since this is Python’s way to give less than the smallest possible integer and so is a way for you to start comparing incoming binItems values

Q5 Manual Procedure – Decision Table

Scenario:

Given a department store clerk deciding what to do about a purchase of an item presented by a customer. Management has constructed a decision table to assist the clerk in these decisions.

You can use T for true and F for false and you may place the a1, a2, or a3 under the truth stacks, rather than the ‘x’ style shown in the text. The intent of this question is to be sure you know how to construct a decision table, so the structure is important.

You only need to fill out four columns of a decision table, as required below, label your rows as in the text except the action rows can be combined into one row.

Here are the possibilities to be considered:

A: the item is < $500

B: This customer is in good credit standing

C: This customer is more than 30 days behind in credit card payments

Construct a decision table where the actions are as follows

A,B,C) TTF → a1= ok

(A,B,C)T,F,F → a2= reject

(A,B,C) F,F,F --> a3= refer to credit dept

Q4 Python Temperature conversion

Given the Fahrenheit temperatures

temperatures = [ 60, 65, 73, 54, 78, 75]

Write Python program to convert these to Centigrade (as done in class several times). Print out the fahrenheit and the converted centigrade temperature at each iteration with appropriate names, i.e. “fahrenheit, centigrade”.

now upload this completed file ( or your copy of this completed file) to Blackboard

put you initials as a file suffix...