Lab 12: Classes | CMSC 105 Elementary Programming - Fall 2024

Lab 12: Classes

Points Possible: 100

Due: Thursday, November 21st

In this lab, we will write programs using Python classes.

Submission:

  1. Submit a Python file for each of the programs.

Program 1: Triangle

Design a class named Triangle. The Triangle class contains:

Write test code that prompts the user to enter three sides of a triangle. The program should create a triangle object with these sides and display the triangle’s area and perimeter.

Formula:

\[s = (side1 + side2 + side3) / 2\] \[area=\sqrt{s(s-side1)(s-side2)(s-side3)}\]

Save the program as triangle.py and attach it to the Blackboard lab assignment.

Draw a UML diagram for the Triangle class and attach it to the Blackboard lab assignment. You can take a picture of the diagram, or use an online tool.

Grading Rubric for the program:
(Comments: 5 points, class and methods: 30 points, UML: 5 points, test program: 5 points, UML: 5 points)
Total: 50 points

Program 2: Practice

Create a class Practice that contains the following data fields:

Methods:

Write a test code that creates an instance of the Practice class and pass values for list and dictionary (you can use any arbitrary values). Print the minimum and maximum values in the list by calling the methods. Also, print the sum of values in dictionary by calling the findSumDict method.

Save the program as Practice.py and attach it to the Blackboard lab assignment.

Grading Rubric for the program:
(Comments: 5 points, class and functions: 40 points, test program: 5 points)
Total: 50 points