The document outlines 3 programming problems:
1) Design a Triangle class that extends the GeometricObject class with fields and methods to calculate area and perimeter of a triangle based on user input of three sides, color, and filled property.
2) Write a program to read scores separated by blanks from a text file, calculate total and average, and display results after prompting user for file name.
3) Write a short program using the calendar module to demonstrate some of its features like displaying dates.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
44 views1 page
Python Programs
The document outlines 3 programming problems:
1) Design a Triangle class that extends the GeometricObject class with fields and methods to calculate area and perimeter of a triangle based on user input of three sides, color, and filled property.
2) Write a program to read scores separated by blanks from a text file, calculate total and average, and display results after prompting user for file name.
3) Write a short program using the calendar module to demonstrate some of its features like displaying dates.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 1
Program 1.) Design a class named Triangle that extends the GeometricObject class.
The Triangle class
contains: -Three float data fields named side1, side2, and side3 to donate the three sides of the triangle. -A constructor that creates a triangle with the specified side1, side2, and side3 with default values 1.0. -The accessor methods for all three data fields. -A method named getArea() that returns the area of this triangle. -A method named getPerimeter() that returns the perimeter of this triangle. -A method named __str__() that returns a string description for the triangle. Write a test program that prompts the user to enter the three sides of the triangle, a color, and 1 or 0 to indicate whether the triangle is filled. The program should create a Triangle object with these sides and set the color and filled properties using the input. The program should display the triangle's area, perimeter, color, and True or False to indicate whether the triangle is filled or not. Program 2.) Suppose that a text file contains an unspecified number of scores. Write a program that reads the scores from the file and displays their total and average. Scores are separated by blanks. Program should prompt user to enter a file name. Sample: Enter a file name: scores.txt There are 70 scores The total is 800 The average is 33.33 Program 3.) Write a program that uses the calendar module. The program should display some of the features that the calendar function can do. The program does not need to be very long, maybe 15-30 lines or so.