2. Please using python code to complete the following operations using "NumPy" (a) Create a 1D array (name it as "arr_1") of numbers from 0 to 9 (desired output: [0 1 2 3 4 5 6 7 8 9]), and print it out. (b) Extract all odd numbers from "arr_1", and print it out. (c) Replace all odd numbers in "arr_1" with -1, and print it out. (d) Print out the elements in "arr_1" that indexed from 2 to 5 (desired output: [2 3 4 5]). (e) Print out the data type of "arr_1"
Added by Paul B.
Close
Step 1
```python import numpy as np arr_1 = np.arange(10) print(arr_1) ``` Output: ``` [0 1 2 3 4 5 6 7 8 9] ``` Show more…
Show all steps
Your feedback will help us improve your experience
Paul Gabriel and 91 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Write a function that partitions the array into two subarrays: one with all even integers and the other with all odd integers. Return your result in the following format: [[evens], [odds]] Example: even_odd_partition([2, 4, 8, 9]) → [[2, 4, 8], [9]]
Liam H.
'Q2. Write a program to calculate sum of those array elements that are at even position. Read the number of elements and elements from standard input. Also print that sum is Even of Odd. Ex INPUT 2 43 5 6 OUTPUT 9 Even'
Florencia C.
Write a program in Python to calculate and display the sum of all odd numbers in the list
Shelayah R.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Watch the video solution with this free unlock.
EMAIL
PASSWORD