CSC401 – Assignment 3 Solved

$ 20.99
Category:

Description

Jay Tang
Reading
Read Chapter 5.1 and 5.2 in Introduction to Computing using Python: An Application Development Focus, Second Edition by Ljubomir Perković.
Logistics
You need to do this assignment on a computer which has Python 3 installed on it. Python 3.8.5 download page can be found here.
A submission that includes code which does not run will not get any points for the part unless specifically documented reason of the error.

Assignment
1. Decisions (15pt)
If there is a vote at a meeting, there are several possible outcomes based on the number of yes and no votes (abstains are not counted). If all the votes are yes, then the proposal passes “unanimously”, if at least 2/3 of the votes are yes, then the proposal passes with “supermajority”, if more than 1/2 of the votes are yes, then the proposal passes by “simple majority”, and otherwise it fails. Write a program that asks the user for the number of yes and no votes (two separate prompts), and then prints the outcome of the vote (‘unanimous’, ‘supermajority’, ‘simple majority’, ‘fail’).
Hint: In a first step compute the total number of votes. Then if, elif, else.

2. Loop Patterns (85pt)
a. (20pt) Implement function myMin(lst) that takes a list of number as a parameter. Without using the built-in min() function, write your own implementation to find the minimum value of the list and return that value.

Hint: If you want a number larger than or others, you can use float(‘inf’). If you want a number smaller than or others, you can use float(‘-inf’).

b. (20pt) Implement function noNegative(lst) that takes a list of numbers as a
parameter. The function changes the list items so that all numbers in the list are positive or zero.

Hint: Make sure the list you pass to the function is changed after the function call.
c. (25pt) We have seen a multiplication chart like this in the last assignment.

This time implement a function multChart(row, col) that takes two parameters: row indicating how many rows to print and col deciding how many columns to print. First print the line number then followed by multiples.

The following screenshot shows an example of the results. You should also align your numbers so the chart can be easily readable.

d. (20pt) Write a function rect(n, m) which creates the boundary of an n by m rectangle, that is an n by m (empty) box with asterisks in the first and last columns and rows.

Submission
Submit the assignment using Assignment 3 folder. Submit only a single python file using your name as file name (e.g. Jay_Tang_Assign_3.py).

Reviews

There are no reviews yet.

Be the first to review “CSC401 – Assignment 3 Solved”

Your email address will not be published. Required fields are marked *