Activity — Pseudocode

Purpose: (1) Practice problem solving and write pseudocode, (2) get started with PyCharm

For this activity, you may work alone or with 1-2 of your neighbors. Come up with an algorithm (pseudocode) to solve at least one of the following problems. Then, every team member will use PyCharm to record the pseudocode in a Python file. Note: You are not implementing anything, simply type you pseudocode.

Reminder: Always check your pseudocode.


To get started with PyCharm:

Why do we use Python and PyCharm for this activity? Can't we simply record our pseudocode using some text editors?
In reality, yes. For this activity, no.
In addition to helping you practice writing pseudocode, this activity is to help you verify if your installation is successful and everything is functioning; so you will be ready for the next class meeting (and start programming).


Problem #1

Imagine that the user specifies the width of a grid, as well as a tile. You will return either "True" or "False" depending on whether or not the tile is along the diagonal of the square grid. For example, on a 7x7 grid, assuming the tile numbers (starting at the top-left corner) are 1, 2, 3, ..., 49

1 2 3 4 5 6 7
8
15
22 23 24 25 26 27 28
29 30
36
43

all yellow tiles are on the diagonal.

You may use the following formulas in your algorithm as needed:

row = (tile - 1) // width
col = (tile - 1) % width


Problem #2

Imagine that the user specifies the width and height of a grid, as well as a tile. You will return either "True" or "False" depending on whether or not the tile is along the edge of grid. For example, on a 7x8 grid, assuming the tile numbers (starting at the top-left corner) are 1, 2, 3, ..., 56

1 2 3 4 5 6 7
8
15
22 23 24 25 26 27 28
29 30
36
43
50

all yellow tiles are on the edge.

You may use the following formulas in your algorithm as needed:

row = (tile - 1) // width
col = (tile - 1) % width


Problem #3

Imagine that the user specifies the width and height of a grid, as well as a tile. You will return either "True" or "False" depending on whether or not the tile is in the middle row of the grid. For example, on a 7x8 grid, assuming the tile numbers (starting at the top-left corner) are 1, 2, 3, ..., 56

1 2 3 4 5 6 7
8
15
22 23 24 25 26 27 28
29 30
36
43
50

all yellow tiles are in the middle row, as a grid with an even height has two middle rows. If the grid has an odd height, there is only one middle row.

You may use the following formulas in your algorithm as needed:

row = (tile - 1) // width
col = (tile - 1) % width


Problem #4

Imagine that the user specifies with width and height of a grid. You will return a string that represents all ordered tiles that make up the corners of the grid, with three tiles to a corner. You will return a string where each tile has a space after it (this will simplify your algorithm). For example, on a 7x10 grid, assuming the tile numbers (starting at the top-left corner) are 1, 2, 3, ..., 70

1 2 3 4 5 6 7
8 14
15
22 23 24 25 26 27 28
29
36
43
50
57 63
64 65 66 67 68 69 70

you would return the string "1 2 6 7 8 14 57 63 64 65 69 70 ". If the board doesn't have a width or height of at least four, you should return the tiles of all the edges. Under such cases, you want to avoid putting duplicate tiles in your strings.

You may use the following formulas in your algorithm as needed:

row = (tile - 1) // width
col = (tile - 1) % width


Problem #5

Imagine you are writing a program that allows a customer to have a name added to a plaque. When a customer enters a name and click the Show cost button, your program will compute the cost, each letter costs $5, and then show how much it will cost to the customer. If the customer clicks the Show cost button without entering anything, display a message telling the customer to enter a name.

    

Optional: you may consider and handle any special cases


Problem #6

Imagine you are writing a program that accepts a paragraph from a user. Your program then checks for repeated words and reports pairs of line numbers and repeated words.

For example, if a user enters
Welcome! In this course, we have two main goals - to teach teach you
the skill of programming and and and the art of computer science.
Having the ability to write to write and understand simple programs has
has become increasingly more important. The concepts and principles you
pick up in this class will give you give the ability to take an algorithm
or problem in your chosen field and write a program that will help you do
your job quicker, quicker, easier, and more reliably.
The program will report
Option 1: (1, teach), (2, and), (7, quicker)
Option 2: (1, teach), (2, and), (3, has), (7, quicker)


Problem #7

Imagine you are writing a program that accepts six project scores from the user. All scores are out of 100 points, except the first (which is out of 30) and the fifth (which is out of 50). The program allows a user to specify whether the lowest project score will be dropped. The program then computes and displays the highest average score for the projects.

For example, if a user enters
Score for project 1 = 15
Score for project 2 = 55
Score for project 3 = 55
Score for project 4 = 55
Score for project 5 = 25
Score for project 6 = 55


With the lowest project score being dropped, the highest average score will be 54
Without the lowest project score being dropped, the highest average score will be 53.33