- Write Python code using any editor.
- Execute the program from the command line.
- Unit test the program.
- Upload on Canvas for submission
-
Setting Up Python Environment
- Verify Python Installation:
- Open your terminal (Command Prompt for Windows, Terminal for macOS/Linux).
- Type
python --versionand press Enter. - You should see the installed Python version displayed.
-
Configuring Visual Studio Code (VS Code)
- Install Python Extension:
- Open VS Code.
- Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or by pressing Ctrl+Shift+X.
- Search for
Pythonin the Extensions Marketplace. - Click “Install” on the Python extension by Microsoft.
-
Running Python in VS Code
- Create a New Python File:
- In VS Code, open a folder where you want to save your Python projects.
- Click on File > New File or press Ctrl+N to create a new file.
- Save the file with a .py extension (e.g.,
hello.py).
-
Write a Python program that performs as a Tuffy Titan Student/Faculty List which contains a list of students and a list of faculty.
-
Create a
peoplemodule to meet the following requirements:- Create a file named
people.py.- Define a class named
Person.- Define a member function named
__init__to meet the following requirements:- Take a self object as a positional parameter.
- Take a first name string as a positional parameter.
- Take a last name string as a positional parameter.
- Set a member variable
firstnameequal to the first name parameter. - Set a member variable
lastnameequal to the last name parameter.
- Define a member function named
- Define a class named
Facultythat inherits fromPerson- Define a member function named
__init__to meet the following requirements:- Take a self object as a positional parameter.
- Take a first name as a positional parameter.
- Take a last name as a positional parameter.
- Take a department as a positional parameter.
- Call the
Person__init__member function passing the first and last name. - Set a member variable
departmentequal to the department parameter.
- Define a member function named
- Define a class named
Studentthat inherits fromPerson- Define a member function named
__init__to meet the following requirements:- Take a self object as a positional parameter.
- Take a first name string as a positional parameter.
- Take a last name string as a positional parameter.
- Call the
Person__init__member function passing the first and last name.
- Define a member function named
set_classto meet the following requirements:- Take a self object as a positional parameter.
- Take a class year string as a positional parameter.
- Set a member variable
classyearequal to the class year parameter.
- Define a member function named
set_majorto meet the following requirements:- Take a self object as a positional parameter.
- Take a major string as a positional parameter.
- Set a member variable
majorequal to the major parameter.
- Define a member function named
set_advisorto meet the following requirements:- Take a self object as a positional parameter.
- Take a
Facultyobject as a positional parameter. - Set a member variable
advisorequal to the faculty parameter.
- Define a member function named
- Define a class named
- Create a file named
-
Create a
maindriver program to meet the following requirements:- Create a file named
main.py. - Import the
FacultyandStudentclasses from thepeoplemodule. - Declare a variable to hold a list of faculty.
- Declare a variable to hold a list of students.
- Implement a menu within a loop with following choices:
- Add faculty
- Print faculty
- Add student
- Print student
- Exit the program
- Prompt the user for the menu choice.
- The Add faculty function should prompt the user for the first name, last name, and department, then instantiate a
Facultyobject and append the object to the faculty list. - The Add student function should prompt the user for the first name, last name, class year, major, and the record number of the faculty advisor, then instantiate a
Studentobject and append the object to the student list.
- Create a file named
-
Run the program using the command below and repeat the steps above until you are satisfied your program output meets the above requirements.
python3 -m main -
Typical input and output for the program:
*** TUFFY TITAN STUDENT/FACULTY MAIN MENU 1. Add faculty 2. Print faculty 3. Add student 4. Print student 9. Exit the program Enter menu choice: 2 ======================= FACLUTY ======================= Record Name Department ====== ==================== ========================= 0 Susan Barua Computer Science 1 Hosssen Moini Mechanical Engineering 2 Huda Munjy Civil Engineering 3 Mostafa Shiva Electrical Engineering *** TUFFY TITAN STUDENT/FACULTY MAIN MENU 1. Add faculty 2. Print faculty 3. Add student 4. Print student 9. Exit the program Enter menu choice: 4 ===================================== STUDENTS ====================================== Name Class Major Advisor ==================== ======== ========================= ========================= Erica Perine Freshman Civil Engineering Huda Munjy Jonathan Rosso Senior Computer Science Susan Barua Samuel Carter Sophomore Environmental Engineering Huda Munjy Stephanie Dalaba Senior Electrical Engineering Mostafa Shiva Chuck Pirards Junior Mechanical Engineering Hosssen Moini *** TUFFY TITAN STUDENT/FACULTY MAIN MENU 1. Add faculty 2. Print faculty 3. Add student 4. Print student 9. Exit the program Enter menu choice: 1 Enter first name: George Enter last name: Kiran Enter department: Computer Engineering *** TUFFY TITAN STUDENT/FACULTY MAIN MENU 1. Add faculty 2. Print faculty 3. Add student 4. Print student 9. Exit the program Enter menu choice: 2 ======================= FACLUTY ======================= Record Name Department ====== ==================== ========================= 0 Susan Barua Computer Science 1 Hosssen Moini Mechanical Engineering 2 Huda Munjy Civil Engineering 3 Mostafa Shiva Electrical Engineering 4 George Kiran Computer Engineering *** TUFFY TITAN STUDENT/FACULTY MAIN MENU 1. Add faculty 2. Print faculty 3. Add student 4. Print student 9. Exit the program Enter menu choice: 3 Enter first name: Becky Enter last name: Hanna Enter class year: Senior Enter major: Computer Science Enter faculty advisor: 4 *** TUFFY TITAN STUDENT/FACULTY MAIN MENU 1. Add faculty 2. Print faculty 3. Add student 4. Print student 9. Exit the program Enter menu choice: 4 ===================================== STUDENTS ====================================== Name Class Major Advisor ==================== ========= ========================= ========================= Erica Perine Freshman Civil Engineering Huda Munjy Jonathan Rosso Senior Computer Science Susan Barua Samuel Carter Sophomore Environmental Engineering Huda Munjy Stephanie Dalaba Senior Electrical Engineering Mostafa Shiva Chuck Pirards Junior Mechanical Engineering Hosssen Moini Becky Hanna Senior Computer Science George Kiran *** TUFFY TITAN STUDENT/FACULTY MAIN MENU 1. Add faculty 2. Print faculty 3. Add student 4. Print student 9. Exit the program Enter menu choice: 9 -
Run the unit testing program to ensure that your program runs as expected.
For Linux and Mac users
./test.sh or source ./test.shFor windows users
./win_test.batThe unit testing will output the results of a series of tests using specific input and expected output. Any error will provide information on where the expected output is different from the actual output. You will need to edit your source code to fix the error and run
./test.shor./win_test.batrepeatedly until it passes all the test.
Submit a zip file containing all the code files on canvas
Naming Convention: _.zip
Your zipped folder should contain below files:
CWID_LASTNAME.zip -
| > test.py
| > test.sh
| > main.py
| > people.py
| > test.txt
| > win_test.bat
- All points add up to a total of 100 points possible as detailed below. Partial credit will be given where applicable.
| Points | Description |
|---|---|
| 50 | Environment setup and Lab Submission |
| 5 | main.py file submitted and meets the program requirements |
| 10 | people.py file submitted and meets the program requirements |
| 5 | unit test passes Test01_Person |
| 5 | unit test passes Test02_Faculty |
| 5 | unit test passes Test03_FacultyInheritsPerson |
| 5 | unit test passes Test04_FacultyInheritsStudent |
| 5 | unit test passes Test05_Student |
| 5 | unit test passes Test06_StudentInheritsPerson |
| 5 | unit test passes Test07_StudentInheritsFaculty |