Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python 3.0 help!!!! a4q1_initial_power_levels.txt : 12,139,206,250,177,1030,3500,900 5000,3500,1770,1830,1480,981,400,18000 10000,8000,6000,5000,8,4300,1000,39000 30000,18000,10000,19000,13000,8400,8000,7600 Purpose: To practice using arrays in python. This question is very easy with slicing and array

Python 3.0 help!!!!

a4q1_initial_power_levels.txt :

12,139,206,250,177,1030,3500,900 5000,3500,1770,1830,1480,981,400,18000 10000,8000,6000,5000,8,4300,1000,39000 30000,18000,10000,19000,13000,8400,8000,7600 

image text in transcribed

Purpose: To practice using arrays in python. This question is very easy with slicing and array indexing! Degree of Difficulty Easy Master Roshi has decided to start a martial arts academy to train young Z Warriors in preparation for the next inevitable alien invasion. Each student has a power number (integer), and the power levels of the students are stored in a4q1 initial power levels txt (available on moodle). Each row in the file represents a different year. The first row is the first-year students. The second row is the second-year students, etc Create a program to 1. Read a4q1 initial power levels.txt into a 2D numpy array. 2. Count and nicely print out how many total students have a power level 9000 in each year (how many are in each row 3. Set the value of all students that have a power level lower than 200 to 0 (they've been expelled). Print out how many have been expelled. (This can be done using relational operators on your array) 4. After a year of training, the remaining students have become more powerful. Multiply each year of students by the year they are about to be in (ex: f rst year students will get multiplied by 2, second year students will get multiplied 3. Then print out your newly modified array of power levels 5. GHOST NAPPA HAS INVADED EARTH! Scramble all remaining Z Warriors! Ghost Nappa's power level is 9,000,000,000 (9 billion). Sum the total power of the remaining student Z Warriors and print it out. If this summed value is over Ghost Nappa's power level, print out: The Z Warriors successfully defend Earth against Ghost Nappa If the summed value is less than Ghost Nappa's power level, then print out Ghost Nappa is too strong The Earth is doomed! DOOMED! Sample output Year 1 has 0 SUPER POWERFUL WARRIORS Year 2 has 1 SUPER POWERFUL WARRIORS! Year 3 has 2 SUPER POWERFUL WARRIORS Year 4 has 5 SUPER POWERFUL WARRIORS! students are weaksauce and were expelled After a year of training, the students have grown stronger 412 2060 7000 1800] 500 15000 10500 5310 5490 4440 2943 1200 540001 40000 32000 24000 20000 0 17200 4000 156000] [150000 90000 50000 95000 65000 42000 40000 380001 Total power level of all remaining z Warriors 973855 Ghost Nappa is too strong! The Earth is doomed DOOMED Hint: Remember you can perform comparisons on an entire array like so: some array 100. This will output an array of Booleans. You can count how many items this is with this: some array[some array 100 size Indexing an array by an array of Booleans returns new array of elements corresponding to the True entries in the Boolean array. Hint: The theme of this question is Dragon Ball Z. Purpose: To practice using arrays in python. This question is very easy with slicing and array indexing! Degree of Difficulty Easy Master Roshi has decided to start a martial arts academy to train young Z Warriors in preparation for the next inevitable alien invasion. Each student has a power number (integer), and the power levels of the students are stored in a4q1 initial power levels txt (available on moodle). Each row in the file represents a different year. The first row is the first-year students. The second row is the second-year students, etc Create a program to 1. Read a4q1 initial power levels.txt into a 2D numpy array. 2. Count and nicely print out how many total students have a power level 9000 in each year (how many are in each row 3. Set the value of all students that have a power level lower than 200 to 0 (they've been expelled). Print out how many have been expelled. (This can be done using relational operators on your array) 4. After a year of training, the remaining students have become more powerful. Multiply each year of students by the year they are about to be in (ex: f rst year students will get multiplied by 2, second year students will get multiplied 3. Then print out your newly modified array of power levels 5. GHOST NAPPA HAS INVADED EARTH! Scramble all remaining Z Warriors! Ghost Nappa's power level is 9,000,000,000 (9 billion). Sum the total power of the remaining student Z Warriors and print it out. If this summed value is over Ghost Nappa's power level, print out: The Z Warriors successfully defend Earth against Ghost Nappa If the summed value is less than Ghost Nappa's power level, then print out Ghost Nappa is too strong The Earth is doomed! DOOMED! Sample output Year 1 has 0 SUPER POWERFUL WARRIORS Year 2 has 1 SUPER POWERFUL WARRIORS! Year 3 has 2 SUPER POWERFUL WARRIORS Year 4 has 5 SUPER POWERFUL WARRIORS! students are weaksauce and were expelled After a year of training, the students have grown stronger 412 2060 7000 1800] 500 15000 10500 5310 5490 4440 2943 1200 540001 40000 32000 24000 20000 0 17200 4000 156000] [150000 90000 50000 95000 65000 42000 40000 380001 Total power level of all remaining z Warriors 973855 Ghost Nappa is too strong! The Earth is doomed DOOMED Hint: Remember you can perform comparisons on an entire array like so: some array 100. This will output an array of Booleans. You can count how many items this is with this: some array[some array 100 size Indexing an array by an array of Booleans returns new array of elements corresponding to the True entries in the Boolean array. Hint: The theme of this question is Dragon Ball Z

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

7. Senior management supports the career system.

Answered: 1 week ago