JK Week9 HMK
JK Week9 HMK
JK Week9 HMK
Sample Run
How many child tickets do you want?
3
How many adult tickets do you want?
7
Your cost will be $91.
Sample Run
How many child tickets do you want?
3
How many adult tickets do you want?
7
Your cost will be $81.90.
Problem C (5 points): Fish Tank Glass (fishtank.py)
You work for a large aquarium and are helping them decide some parameters for a new fishtank
they are buying. In particular, you need to help them calculate the cost of a fishtank and the
amount of water (in cubic inches) that will fit in it.
A fishtank is made out of five panes of glass. (The top is left open, so no pane of glass is needed
for the top.) The cost of a pane of glass is based on the area of its main surface. In particular, one
square inch of glass costs 15 cents. (This is a high price, but the glass used for large fishtanks is
special glass that is very strong.) Thus, a 4" x 8" pane of glass would cost 4 x 8 x $.15 = $4.80.
The user will enter the length, width and height of the proposed fish tank in inches.
Sample Run
Enter the length, width and height of the fish tank in inches.
18 36 24
Your cost for building the tank will be $486.00.
The volume is 15552 cubic inches.
Problem D (10 points): Paper Folding (fold.py)
If you take a piece of paper and fold it in half, then fold it in half again, and again and so on, the
paper becomes thicker each time. Assuming you can continually fold the paper (it has been said
you can only fold a piece of paper in half 8 times, it is referred to as the “Folding Paper
Problem”) the thickness of it will exponentially grow. After 50 folds of a standard piece of paper
(0.1 mm thick) it would be nearly the distance from the Earth to the Sun (1.475 x 1011 meters).
Sample Run
How thick is your sheet of paper (in millimeters)?
.1
How many times would you like to fold the paper?
50
What increment would you like to use for the table?
10
Folds Thickness
0 0.000100
10 0.102400
20 104.857600
30 107374.182400
40 109951162.777600
50 112589990684.262405
Problem E (10 points): Difference of Sums (sumdiff.py)
The sum of squares of the first 3 natural numbers is
12 + 22 + 32 = 14
The difference between these two is 36 – 14 = 22. (Note that the latter is always greater than or
equal to the former.) Your task is to write a program that computes the difference between the
square of the sums and the sum of the squares for natural numbers in a given range.
Sample Run
Enter the minimum value of the range.
5
Enter the maximum value of the range.
15
The desired difference is 10890.
Sample Run
Enter the dimensions of the room, in feet.
9 6
Enter the length of the side of a tile, in feet.
2
You can place a maximum of 12 complete tiles.
Problem G (15 points): Flag Designs (flag.py)
The US flag has stars for each state on it. They are arranged such that the odd numbered rows
have 6 stars and the even numbered rows have 5 stars. Given the number of stars and a total
number of rows (which is always odd), one can determine whether or not a star pattern like the
US flag is possible. Your job is to determine this. If it's possible, print out the star design.
Otherwise, print out the star design, with a single space between each star on each row. For
example, the star design for the US flag (50 stars, 9 rows), should be printed as follows:
* * * * * *
* * * * *
* * * * * *
* * * * *
* * * * * *
* * * * *
* * * * * *
* * * * *
* * * * * *
Sample Run
Enter the number of stars for your design.
50
Enter the number of rows for your design.
13
Sorry, no star design fits your specification.
Sample Run
Enter the number of stars for your design.
29
Enter the number of rows for your design.
3
* * * * * * * * * *
* * * * * * * * *
* * * * * * * * * *
Problem H (15 points): Arup's Pseudoprimes (fakeprimes.py)
Many students think that if a number is not divisible by 2, 3, 5 or 7, that it is prime. However,
this isn’t always true. For example, 121 isn’t divisible by any of those four values, but 121 = 11
x 11, so it isn’t prime. Arup pseudoprimes are numbers that ARE NOT prime, but also are not
divisible by 2, 3, 5 or 7. Write a program, that, given a range of positive integers, prints out all
the integers within the range that are Arup pseudoprimes.
Sample Run
Enter the low bound for your search of Arup pseudoprimes.
50
Enter the high bound for your search of Arup pseudoprimes.
200
121
143
169
187