University | Victoria University of Wellington (VUW) |
Subject | COMP132: Programming for the Natural and Social Sciences |
Define a function discipline() that returns a list of all disciplines that a given country participates in. For example, if “New Zealand” is the argument, the function should return [“Athletics”, “Judo”, “Rugby Sevens”, “Sailing”, “Swimming”, “Table Tennis”]
Show the output of discipline(’New Zealand’). (p) Define a functioning country() that returns a list of all participated countries for a given discipline. For example, if “Tennis” is the argument, the function should return [“Argentina”, “Australia”, “Austria”, “Belarus”, “Belgium” “United States
of America”, “Uzbekistan”]. Show the output of the country(’Tennis’).
1.2 Entries
(a) Find the top 10 disciplines with the highest number of female athletes.
(b) Print the disciplines with more female entries than male entries.
(c) Print the total number of female athletes and then the total number of male athletes.
1.3 Medals
(a) Add a Rank column in the medals data frame to show the rank of the total number of medals.
(b) Find out the top 10 countries with the highest number of gold, silver, and bronze medals respectively. Draw one figure with three bar sub-plots (gold, silver, bronze) to show the results. In each subplot, set the x-axis to be the country and y as the number of medals the country gets. Add labels and titles for each sub-plot and make sure they do not overlap.
1.4 Using more than one data file
(a) Find out the number of countries that did not get any medals in the 2021 Tokyo Olympics.
(b) Create a new data frame with four columns:
Discipline: discipline,
Signed Up: the number of signed up athletes under the discipline,
Entries: the number of entries under the discipline,
Diff: the difference between the number of signed-up athletes and entries. You may notice that there is inconsistency in the data.
Print the data frame.
Also, write code to save the data frame to a .csv file and give a proper file name.
(c) Find out how many athletes participated Olympics for each country, and then find out the ratio of getting medals. Print the top 10 countries with the highest ratio along with’Total’ and a ’Ratio’ columns.
Hint: The ratio is the number of metals the country gets divided by the number of participated athletes.
Stuck! Do not Know Assessment Answers?
Hire NZ Native Experts 24/7.
Get the Instant assignment help on COMP132: Programming for the Natural and Social Sciences assignment. We have hired master's and Ph.D. degree specialists from the topmost universities in New Zealand. Also, our experts assure you to provide original and unique solutions on programming assignments at an unbeatable price.
- FSC521 The Financial Services Industry Assessment 2: A Practical Exploration of Insurance, Lending, Investment, and Taxation in Aotearoa
- Ethics, Responsibility, and Sustainability Assignment : A Critical Analysis of Temu’s Business Practices in the Online Consumer-to-Manufacturer (C2M) Industry
- PSYCH211 Psychology for Society Assignment 3: A Qualitative Exploration of Personal Experiences through Semi-Structured Interviews
- DBC503 Business Management Assignment: Enhancing Communication and Building Sustainable Stakeholder Relationships for Effective Team Performance
- NURSING 742 Biological Science for Practice Portfolio Case Studies Assignment – Integrating Pathophysiology, Pharmacology, and Clinical Reasoning
- NURSING 742 Biological Science for Practice Assignment 3: Comprehensive Portfolio of Case Studies in Clinical Pathology and Immunology
- Conduct Geographic Research with Consultation Assignment: A Comprehensive Investigation into Spatial Patterns, Data Analysis, and the Human-Environment Relationship
- MGT616 Occupational Health and Safety Assignment 2: Evaluating Data and Strategic Approaches to Health, Safety, and Wellbeing – A Case Study of Koru Construction Ltd
- ENGE601 Engineering Mathematics 2 and MATH605 Algebra and Calculus 2 Assignment-1: Applications of Multivariable Calculus, Vector Fields, and Optimization Techniques
- Research Methods Assignment: A Comparative Critique of Methodologies in Soil Bacteria Studies Investigating Antimicrobial Potential