Just call the parent class attack method
The data for this imaginary midterm exam can be found (in part) in the file midterm.csv, a file of comma-separated values. By opening this file in a text editor (or more preferably, spreadsheet software such as Numbers or Excel), you will see the data in tabular format. See Figure 1 for an example of how it might look.
Each column in the file represents the midterm exam answers of an individual student (except the first column, which gives the row titles). In particular, the first row gives the student number, the second and third rows give the number of topics that student did not complete (due to lack of time, e.g.,), and the fourth column gives the ID of the individual who graded their exam.
Figure 2: Examples of how the plots should look.
get num questions in topic(data, topic): Takes the midterm data as list of lists and topic number, and returns the number of questions in that topic.
get num students(data): Takes the midterm data as list of lists, and returns the total number of students who sat for the midterm.
where data is a list of percentages, each percentage in the range [0.0, 1.0], corresponding to the per-centage of students that were given a topic relative to the total number of students, and categories is a list of labels (e.g., ‘Topic 1’, ‘Topic 2’, etc.), where each element at position i of categories refers to the percentage at position i of data.
Make sure to give your pie chart a title, and then show it to the screen.
Given a particular topic, calculate the average for each question in that topic, then calculate and return the average of all those question averages.
plot topic averages(data)
Given a particular column index (referring to an individual student), calculate their average for the exam.
Note that you will have to go through each topic, check if the student was given that topic, and if so, count the number of questions in that topic, and count how many of those questions they got correct. Do this for each topic, keeping count as you go, and when done, you can take the number of questions they got correct and divide it by the total number of questions they were given.
plot student averages(data)
Display the averages for all students in a histogram, and show it to the screen. Make sure to give your histogram a title. Make the x-axis range from 0.0 to 1.0 (you can again use the plt.xticks function, providing a list of values of increments of 0.1).
Additional functionality (5 points)
For the remaining 5 points of this question, you are encouraged to make a plot to display some other interesting characteristic of the data. The requirements to obtain the 5 points are as follows:
Question 2 [40 points]
I want to be the very best,
Like no one ever was.• After a Pokemon wins a battle, they gain experience points. When enough experience points have been gained, the Pokemon reaches a new level of strength.
• Certain types of Pokemon are strong against some types, and weak against others. For example, Pokemon of electric type are strong against ground type Pokemon, but weak against flying type Pokemon. Thus, in battle, their moves will be more and less effective, respectively.
Core classes (30 points)
Each of the following classes should be written in its own file, except classes that inherit from other classes (which should be written in the same file as their parent class). In all, there will be four files for you to write and submit: pokemon trainer.py, pokemon.py, item.py and move.py.
add pokemon(self, pkmn)
Parameter: a Pokemon object
Add the parameter into the list of Pokemon that the Pokemon trainer currently has. If there is no currently active Pokemon, then set it to the parameter.add item(self, item)
Parameter: an Item object
Add the parameter into the list of items that the Pokemon trainer currently has.
str (self)
Return a string containing the values of all the attributes of the self object in a readable format.
HealthPotion sub-class (inheriting from Item)
Initializer method
Parameters: a string name and an integer amount of hp to restore.Call the parent class’ initializer method on the self object with the name parameter, then assign the other parameter to the attribute of the same name.
|
3; defense: |
|
---|
gain exp(self, opponent level)
Parameter: a positive integer opponent level
Calculate the number of experience points the Pokemon has gained by taking a random number in the range [1, opponent level], add it to the Pokemon’s current experience points, and print a message saying how much experience was gained (e.g., Staryu gained 5 EXP!). If their experience points reach 10, set their experience back to 0 and increase their level by 1, and print a corresponding
Parameters: a string name and a list of Move objects moves.
Call the parent class’ initializer method on the self object with the given parameters, and ElementType.Electric for the move type parameter.
• If it is ElementType.ELECTRIC or ElementType.FLYING, then print the message It’s not very effective... and call the defend method on the opponent, giving as argument half the current Pokemon’s attack power multiplied by a random number in the range [1, move.damage].
• Otherwise, just call the parent class’ attack method, giving the parameters as arguments.
• Create a new Area class that has a list of Pokemon as attribute, then create a new visit(area) function that takes an Area object as argument, lets the player move around the area or visit another area, and each time the player moves around the area, let them have a chance to catch one of the particular Pokemon contained in the area. The Pokemon should then be added into the player’s list of Pokemon.
11
This question is intended to be an open-ended exploration of website data using techniques shown in class.
We will write our code in the file web.py. Note that there will be no codePost tests for this question; you must make sure it meets the following requirements before you submit it.
Then, analyze the data by plotting it using Matplotlib, with at least two graphs showing different parts of the data. Save these graphs to disk.
Note: Before starting to write your code, make sure you have the correct XPath/CSS selector string. Also, when testing your code, comment out the code dealing with the retrieval of the data so that you can test all other parts of your code first (use empty lists or fake data instead of retrieving the actual data). Only when you are sure that it all works, then un-comment that code block and test the entire code file. We strongly recommend you follow this testing strategy since repeated downloading of data from a website can cause you to be automatically blocked from further visiting that web page, at which point you would have to change the website you chose for this question to a different one.