Python Programming
-
How to Convert a Float Array to an Integer Array in Python with NumPy
In this short NumPy tutorial, we are going to learn how to convert a float array to an integer array in Python. Specifically, here we are going to learn by example how to carry out this rather simple conversion task. First, we are going to change the data type from float to integer in a 1-dimensional array. Second, we are going to convert float to integer in a 2-dimensional array.
Now, sometimes we may want to round the numbers before we change the data type. Thus, we are going through a couple of examples, as well, in which we 1) round the numbers with the round() method, 2) round the numbers to the nearest largest in with the ceil() method, 3) round the float numbers to the nearest smallest numbers with floor() method. Note, all code can be found in a Jupyter Notebook. -
How to Find the Length of a List in Python
Lists are one of the most commonly used data types in Python and are used to store collections of items of the same type.
-
Python Import Command
The import command in Python is used to get access to other modules. Modules are the same as a code library in Java, C, C++, or C#. A module typically involves a set of functions and variables. When we need to include or use these functions of modules in our code, we can simply import the module by using the import command and we can easily invoke the module functions and variables. The import command is the simplest and common way of including modules into your code.
Python comes up with many built-in modules that we can include in our code easily. We can also create our module by just saving the Python code file with the .py extension.
In this article, we will learn that how we can import our own and built-in modules in Python. Spyder3 editor is used to creating and running the Python scripts.
-
Python List Index
In this post, we will learn about how to index lists in Python.
The index() method returns the index of an item in Python list.
-
Weekly Python StackOverflow Report: (ccxliii) stackoverflow python report
- Login or register to post comments
- Printer-friendly version
- 3231 reads
- PDF version
More in Tux Machines
- Highlights
- Front Page
- Latest Headlines
- Archive
- Recent comments
- All-Time Popular Stories
- Hot Topics
- New Members
digiKam 7.7.0 is releasedAfter three months of active maintenance and another bug triage, the digiKam team is proud to present version 7.7.0 of its open source digital photo manager. See below the list of most important features coming with this release. |
Dilution and Misuse of the "Linux" Brand
|
Samsung, Red Hat to Work on Linux Drivers for Future TechThe metaverse is expected to uproot system design as we know it, and Samsung is one of many hardware vendors re-imagining data center infrastructure in preparation for a parallel 3D world. Samsung is working on new memory technologies that provide faster bandwidth inside hardware for data to travel between CPUs, storage and other computing resources. The company also announced it was partnering with Red Hat to ensure these technologies have Linux compatibility. |
today's howtos
|
Recent comments
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago