This assignment invites you to enhance, run, and observe three Python programs called
create-dog-with-list. Instead of using the Poetry tool for managing dependencies and packaging these programs, which the technical skills advise as a best practice, these programs are a script, without any dependencies on other Python packages, that you can run with the Python interpreter. As you continue to practice a different way to run a Python program, this project invites you to explore how to use three different approaches to representing an object in the Python programming language. After completing this source code survey, you should understand how to express relationships between variables in three different ways and be able to articulate the trade-offs associated with each approach.
If you are a student enrolled in a Computer Science class at Allegheny College, you can access this assignment by clicking the link provided to you in Discord. Once you click this link it will create a GitHub repository that you can clone to your computer by following the general-purpose instructions in the description of the technical skills. Specifically, you will need to use the
git clone command to download the project from GitHub to your computer. Now you are ready to add source code and documentation to the project!
If you change into the
source directory of your GitHub repository, you will see two Python programs called
create-dog-with-list.py. Importantly, both of these Python programs should produce the same output! Your goal for this project is to add the source code required by the
TODO markers so that the program produces the output that is given below this paragraph. When you are finished adding the required source code, both of the aforementioned programs should produce the following output. With that said, the first line produced by
create-dog-with-dictionary should be
Creating dog objects using a dictionary-based approach! and the first line produced by
create-dog-with-list.py should be
Creating dog objects using a list-based approach!. As you implement both of these approaches to representing objects, please take time to reflect on the relative strengths and weaknesses of both ways to store details about a
Dog in the computer's memory.
The dog's name is: Bosco The dog's age is: 6 The dog's breed is: Havanese The dog's name is: Faith The dog's age is: 14 The dog's breed is: Havanese
You will notice that the
source directory also contains a Python program, called
create-dog-with-class.py, that uses the object-oriented programming paradigm to represent the state and behavior associated with a
Dog object. As for the two other programs, you should add all of the Python source code required by the
TODO markers, ensuring that the program produces the following output. Two of the methods that you will need to implement in the
Dog class include
def __init__(self, name, age, breed): and
def __str__(self):. The first of these methods is the constructor, or the method responsible for creating a new instance of the
Dog class. The second of these methods is responsible for creating a textual representation of a
Dog object that you can display in a terminal window or a graphical user interface. As you implement the Python source code for this project, you should note the ways in which the object-oriented approach to representing an object supports the combination of both state and behaviors.
Creating dog objects using a object-oriented approach! Bosco is a 6 years old Havanese The dog's name is: Bosco The dog's age is: 6 The dog's breed is: Havanese Bosco is a 6 years old Havanese Hey, Bosco roll over! Faith is a 14 years old Havanese The dog's name is: Faith The dog's age is: 14 The dog's breed is: Havanese Faith is a 14 years old Havanese Hey, Faith waive bye-bye!
Since this project does not use Poetry to manage project dependencies and virtual environments, it does not support the use of commands like
poetry run task test. However, you can leverage the relevant instructions in the technical skills to enter into a Docker container and run the command
gradle grade to check your work. If
gradle grade shows that all checks pass, you will know that you made progress towards correctly implementing and writing about this project's program. You are also encouraged to ensure that
create-dog-with-list both produce the same output, excepting the fact that they both output a starting line that is specific to the kind of representation that they use for the
Dog object. Finally, you should confirm that the
create-dog-with-class program produces similar output to the two aforementioned programs while also further demonstrating the features that are unique to this approach.
Once you have finished all of the previous technical tasks, you can use a text editor to answer all of the questions in the
writing/reflection.md file. Since this is a source code survey, you should provide output from running each of the provided Python programs on your own laptop and then explain how the program's source code produced that output. A specific goal for this project is for you to ensure that you can implement and understand multiple approaches to representing objects in the Python programming language.
Since this project is source code survey, it is aligned with the remembering and understanding levels of Bloom's taxonomy. You can learn more about how a proactive programming expert will assess your work by examining the assessment strategy. From the start to the end of this project you may make an unlimited number of reattempts at submitting source code and technical writing that meet the project's specification.
Emerging proactive programmers who have questions about this project are invited to ask them in either the GitHub discussions forum or the Proactive Programmers Discord server. Before you ask your question, please read the advice concerning how to best participate in the Proactive Programmers community. If you find a mistake in this project, please describe it and propose a solution by creating an issue in the GitHub Issue Tracker.