Due Date: The due date is Friday, April 3 at 6pm. The assignment is to be submitted online on eclass. Late submissions will not be accepted.
Collaboration Policy: This must be your own work. Do not share or look at Python
code of other people (whether they are inside or outside the class). Do not search for or
copy code from the Internet. You can talk to others that are in the class about solution
ideas (but not so detailed that you are actually verbally sharing or hearing about or seeing
code). You must cite who you talked to in the comments of your programs.
Submission: You need to submit 2 files: A2q1.py and A2q2.py on eclass. Use the program "stubs" of these names provided on eclass. Your submitted solutions must be in the correct .py format so that the TAs can run the programs. Keep the file names the same as listed above. Do not submit pdf or doc or other incorrectly formatted files. Remember to leave your programs on your lab account before the due date (in case something goes wrong with your submission).
Marking: The assignment is worth 9% of your final grade. Marks are allocated for each question as follows: − 10% Describe your program in a comment at the top of the solution − 20% Program syntax is correct (Python reports no errors), program file can be run by the TAs without error messages − 50% Program works − 20% Coding style (meaningful variable names, proper indentations, comments in code)
In this assignment, you must use the subset of Python that we have discussed in class. In particular, you are not allowed to use the following built-in functions of Python: count, replace, join, split, find, sort, strip, clear, remove, pop, del.
Question 1 [10 marks]: Write a function find_valuepos(Alist, base) that returns the position of the largest value in the list Alist and this largest value is smaller than base. The function will return -1 if there is no value smaller than base. Note, do not sort this list. You should also be able to solve this problem going through the list only once.
Use this function in a main program as follows. First your main program should assign
values to a list. For example,
Get Free Quote!
275 Experts Online