• Understand and use the Python types:
    • string
    • list
    • dict
    • int
    • float

Exercise 3.1 Monograms

The American Sweater Company of Iona, Idaho (ASCII) makes monogrammed sweaters. The management would like an easier way to determine a monogram from a customer's name. They have asked you to write a program, named monogram.py, that will do the work for them.

The program should accept the customer's first name, middle name, and last name and output the corresponding monogram. When getting the user's initials, the program should only use the first letter of the user's input.

The input and output should look like this, for example:

First name? Alfred
Middle name? Edward
Last name? Neuman

The customer Alfred Edward Neuman has ordered a sweater with the monogram AEN.

You should ignore any extra letters entered with the middle name.

To get credit for this exercise, your solution should use a single print statement.

Be careful! There is a blank line between the input and the output.

Exercise 3.2 Scores

The JMU basketball program needs help calculating player statistics. They would like you to write them a program, named scores.py, that:

  • stores a list of integers in a variable named score_list. Each entry in this list represents the total points scored by a particular player in a single game. These numbers can be whatever you want for the purposes of testing your program.
  • prints out:
    • the player's total points for the season
    • the player's average points per game (to one decimal place)
    • the number of times the player scored 0 points in a game
    • the number of points the player scored in the final game of the season

For instance, if the player had scores of 10, 0, 5, 5, and 15, the program would print:

Total points: 35
Average points: 7.0
Number of 0 point games: 1
Last game score: 15

Gradescope will change the contents of your list and observe your program’s output. The output should be correct for any list of integers of length at least 1. You should test your program with several different integer lists to make sure that it behaves correctly in each case.

Note: You must not use loops in your program. Programs that use loops will receive no credit.

Exercise 3.3 Lots of data

The JMU basketball program needs some more help. They'd like you to create a program for displaying the statistics of players on request.

You will create a program, named scoring.py, that will display the points scored by a player on request. Your program will allow the user to type in the last name of a player, and then display the points scored over a season by that player.

For your program you will use the stats from the 2020-2021 Women's Basketball Team:

Name Points Scored
Jefferson 388
Hazell 237
Tucker 216
McDaniel 195
Green 140

Your program will represent this data in a dictionary named stats, and use this dictionary to retrieve the data for output.

Your program should replicate the following output and input:

>>> %Run scoring.py Enter the player's last name: Tucker
Tucker scored 216 points.

Note: Your solution must use a dictionary. Solutions using if statements or loops will receive no credit.

Exercise 3.4

Your CS professor needs help calculating scores for his class The History of Keyboards. Students are graded on four exams throughout the semester, with the lowest score dropped from the average. You have taken a side job to write a program, named grades.py, to calculate the scores.

The program should replicate the following output and input:

>>> %Run grades.py
score 1: 97
score 2: 74
score 3: 65
score 4: 100
The final score for the course is 90.33%. Dropped lowest score 65.
The remaining scores are 97, 74, and 100.

In solving this problem, you should put the four grades in a list named scores and use list functions and methods to find the lowest score and the final score. When your program finishes, scores should hold the three highest scores. Note that lists do not have a method for finding an average.

Note: You must not use loops in your program. Programs that use loops will receive no credit.

Exercise 3.5 Bar Chart

A Bar Chart is used to display data that comes in categories, like this one:

bar chart

from https://www.statista.com/chart/21017/most-popular-programming-languages/

Reproduce the first five rows of the chart above in text like this:

---------------------------------------- Python : ============================= Java : =================== JavaScri : ======== C# : ======= PHP : ====== ---------------------------------------- min: 6.20 max: 29.90

Start your program, named bar_chart.py, like this:

labels = ['Python', 'Java', 'JavaScript', 'C#', 'PHP']
data = [29.9, 19.1, 8.2, 7.3, 6.2]

Gradescope will test your code by changing the labels and data and seeing if the chart still prints out neatly and correctly.


  1. The top and bottom borders ("------") of the chart should be just as long as the longest bar in the chart.
  2. The data are floating-point numbers, but the bars have to be an integer number of ‘=’ long. You should truncate/round down/floor when determining the number of ‘=’ symbols to display. (This is the default when you perform a type conversion from float to int.)
  3. The labels should be formatted to fit in 8 spaces, no matter how long they are.
  4. The min and max values must be displayed to two decimal places.
  5. Be careful with spacing!

Tip: You can format long_string to fit into a smaller space by using f'{long_string:.4s}' which truncates the string to 4 characters. You can also add extra spaces to short_string by using f'{short_string:25s}', which adds enough spaces to make the whole string at least 25 characters long. You can even put them together, like f'{long_string:10.5s}. Try it in Thonny! You’ll need this formatting to finish this problem correctly.

Note: You must not use loops in your program. Programs that use loops will receive no credit.

Back to Top