COSI 10a (Fall, 2024) Introduction to Problem Solving in Python


Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due


COSI 10a (Fall, 2024)

Introduction to Problem Solving in Python Programming Assignment #2

Program Description

For this assignment you will write a program for each of the following 3 problems and name each script Problem1.py, Problem2.py, etc.

You may talk to other students about the assignment and consult the slides and online resources for syntax, but all code you submit must be your own. Do not copy code directly from other students or from any online resources. The best way to not get caught plagiarizing is to not do it in the first place. The graders will be receiving a solution generated by ChatGPT to see how it will utilize style – so we highly recommend not getting your answer from ChatGPT. These assignments are training your ability to deconstruct problems and process solutions in code, not to see how quickly you can solve it!

Requirements

  1. All three programs must run without error and give the correct output.
  2. Your code must be commented and have docstrings, as well as descriptive function and variable names.
  3. There should be no code outside of a function except for a call to main().
  4. Your code should be well structured and split into appropriate functions.
  5. Include a comment at the top of each submitted file with your name, the assignment number, the program number, and a brief description of what the program does. For example:
#Full Name
#COSI 10a Fall 2024
#Programming Assignment 2
#Problem 1
#Description: …

You should limit your code to use only what we have learned through lecture 9, as well as topics covered in lectures 12 and 13. You should not use anything from lectures 10 and 11 (if statements, while loops).

Submission and Grading

Submit via Latte a zip file named yourfirstname_yourlastnamePA2.zip which contains your program files. To create a zip file on Mac, right click the document/folder and select the “Compress [document/folder name]” option. On Windows, right click the document/folder and select the “Send To..” and then “zip/compressed file” options. See Moodle for the due date and time.

There are 3 possible grades you may receive for this assignment: fail, pass, and pass+. Your program will be graded pass/fail on each of the requirements listed above. If your code does not meet requirement 1 (correctly named, produces the desired output without error) you will not receive an overall passing grade. Of the remaining requirements, you may fail no more than 1 to receive a passing grade. Submissions that meet all of the requirements will receive a grade of pass+.

There are 3 total problems in this assignment, please see them below.

Problems

Problem 1

The Fibonacci numbers are a sequence of integers in which the first two elements are 1 and each following element is the sum of the two preceding elements. The first 12 Fibonacci numbers are: 1 1 2 3 5 8 13 21 34 55 89 144. Write a program that prompts the user for a number and prints out that number of squares where the size of each square is the next number in the fibonacci sequence, starting with a square of size 3. For example, if the user asks for 3 squares, your program should print the following:

Problem 2

Write a program that prompts a user for a number n and then prints out a multiplication table where the top row is the numbers 1 to n left to right and the first column has 1 at the top and n on the bottom. Each cell in the body of the table should be the product of the row and column number. For example, if the user gives the program the number 5, the program should print the
following:
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25

Problem 3

The Bank of Brandeis, NA offers 0.65% interest on savings accounts (yes, a very generous bank!), compounded annually. Create a program that allows a user to enter the number of years they want to invest with a specific annual deposit. Your output should look exactly like the following:

Notes:
  • The input for both should work for any number above 1. We will be testing this logic on many different use-cases.
  • Exact spacing is negligible, but it should look very similar to the above output with exact logic.
  • To achieve the rounded numbers you can use the Python round function. Say we wanted to round 105.3434 to 2 decimal places, we would do: round(105.3434, 2), where the latter number specifies significant figures.
Our first year, technically year 0, is the confirmation for the initial account. The subsequent years add the interest from the previous year, then the new balance including new deposit. Keep in mind that 0.65% interest is 0.0065 of the amount.

发表评论

电子邮件地址不会被公开。 必填项已用*标注