Python_Programming_FinalExam
1. 1. Write a Python program “FinalE” to complete the following: • Define a class Shape (to be used as a super class) with data attributes color, filled (you may define “filled” in whatever you prefer, such as 1—filled, 0—not filled; yes—filled, no—not filled, or using True/False, …). • Define a subclass, Triangle, that extends class Shape, with 3 data attributes: side1, sisde2, side3 (for the 3 sides). • Implement methods __init__ and __str__ in both of the classes • Implement methods, area() and perimeter() for class Triangle. • Implement regular set/get methods for the data attributes. • Define regular main() function in which proper inputs should be read from keyboard (you need to use try-except for validation of the inputs—see the following sample testing) for the creation of Triangle object and display the object properties, such as the color, whether filled or not, area, perimeter. o Need to check whether the input can form a triangle (if the sum of any two sides is less than the third side, all these 3 inputs for the sides cannot form a triangle.) • Test your program and take screenshots of running your program. 2. 2. Write a Python program (its name must be “FinalE”) that reads a string and check the string to see whether it is a valid “secure code” according to the following rules: • At least two uppercase letters. • At least one lowercase letter. • It includes at least two digits, and the sum of the digits must be an odd number. • It includes at least one vowel (Vowels are the letters a, e, i, o, u and their uppercase cousins). • It includes at least one special character (i.e., @, #, $, %, &). Have your code well designed and organized: in addition to defining a main function, you would need to define at least two other functions to be called in the main function. Hints: Python string has defined many functions/methods for you to use in this project; also you may find the following function, if called, will return a list of Characters (or single-letter-strings), for example, [“h”, “e”, “l”, “l”, “o”] for “hello” useful for this project:
Written for
- Institution
- Python Programming
- Course
- Python Programming
Document information
- Uploaded on
- July 22, 2023
- Number of pages
- 4
- Written in
- 2022/2023
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
pythonprogrammingfinalexam
Also available in package deal