- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What does .shape do in “for i in range(Y.shape)” using Matplotlib?
The shape property is usually used to get the current shape of an array, but it may also be used to reshape the array in-place by assigning a tuple of array dimensions to it.
Get an array Y using np.array method.
Y.shape would return a tuple (4, ).
Y.shape method would return 4, i.e., the first element of the tuple.
import numpy as np Y = np.array([1, 2, 3, 4]) print("Output of .show method would be: ", Y.shape, " for ", Y) print("Output of .show method would be: ", Y.shape, " for ", Y) print("Output for i in range(Y.shape): ", end=" ") for i in range(Y.shape): print(Y[i], end=" ")
Output of .show method would be: (4,) for [1 2 3 4] Output of .show method would be: 4 for [1 2 3 4] Output for i in range(Y.shape): 1 2 3 4
- What does a “set+0” in a MySQL statement do?
- What does the “yield” keyword do in Python?
- How do I index “or” in MongoDB for indexing multiple fields?
- How does “do something OR DIE()” work in Perl?
- What does axes.flat in Matplotlib do?
- How do I programmatically “restart” an Android app?
- How do I programmatically “restart” an iOS app?
- What does “?:” mean in a Python regular expression?
- How do I replace “+”(plus sign) with SPACE in MySQL?
- What does “dereferencing” a pointer mean in C/C++?
- How do I use the ternary operator ( ? : ) in PHP as a shorthand for “if / else”?
- How do I kill all the processes in MySQL “show processlist”?