Language Selection

English French German Italian Portuguese Spanish

Python Programming

Filed under
Development
  • Transpose a Matrix – Linux Hint

    In Python, a matrix has rows and columns. We can create the matrix in different ways, but the easy method is using the list as shown:
    matrix = [ [1, 2, 4], [31, 17, 15] ]

    The list inside the list above is a row, and every element inside the list is called a column. So, in the above example, we have two rows and three columns [2 X 3].

    And also, indexing of the Python starts from zero.

    The transpose of a matrix means where we change the rows to columns or columns to rows.

    Let’s discuss different kinds of methods to do matrix transpose.

  • How to sort with lambda in Python – Linux Hint

    The sort operation is applied to a list of data in any programming language. Tuple, list, and dictionary are used in Python to store multiple data. The values of the tuple and list are accessed by numeric index, and the keys access the values of the dictionary. Many built-in functions exist in Python to sort the list of data in ascending or descending order. The lambda function is one of them. The coder can define the sorting order based on the requirement by using this function. The uses of the lambda function for sorting the list and dictionary objects in different ways have been explained in this tutorial.

  • How to sort dictionary in Python – Linux Hint

    Multiple data are stored in Python by using a tuple, list, and dictionary. When the data are stored in Python by key-value pair that works like an associative array of other programming language is called the dictionary. The value of the dictionary is mutable. The dictionary can be stored based on the value of the key or value or both key and value. The dictionary can be sorted by using a simple for loop, built-in functions, and module. Different ways to sort dictionary data have been explained in this tutorial.

  • How to sort JSON objects in Python – Linux Hint

    The JSON file is a very popular medium to exchange data between different types of programming languages. It is a language-independent text-based file format that stores data by using an array and object. It can store numbers, strings, Boolean, and another array or object as the content. The JSON object can be sorted by using built-in python functions, modules, and user-defined functions. Different ways to sort the JSON object in Python have been explained in this tutorial.

  • How to read excel (xlsx) file in python – Linux Hint

    The .xlsx is the extension of the excel document that can store a large amount of data in tabular form, and many types of arithmetic and logical calculation can be done easily in an excel spreadsheet. Sometimes it is required to read the data from the excel document using Python script for programming purposes. Many modules exist in Python to read the excel document. Some of the useful modules are xlrd, openpyxl, and pandas. The ways to use these modules to read the excel file in Python have been shown in this tutorial.

  • How to get and set environment variables in Python – Linux Hint

    Environment variables are used to change the system configuration. The output of the many Python applications depends on the values of the particular environment variables. When those environment variables change, the python script requires changing to get the appropriate output, which is not desirable. This problem can be solved by reading and setting the value of the environment variable in the Python script based on the requirement. It eliminates the task of changing the environment variable manually and makes the code more secure by hiding the sensitive data required to assign the environment variable, such as API token. The ways to set and get the environment variable in Python have shown in this tutorial.

  • How to check a file is opened or closed in Python – Linux Hint

    The file is used to store data permanently. Working with a file is a very common task of any programming language. Many built-in functions exist in Python to create, open, read, write and close the file. Two types of files can be created to store data. These are text files and binary files. Any file is required to open before reading or write. The open() function is used in Python to open a file. Using the open() function is one way to check a particular file is opened or closed. If the open() function opens a previously opened file, then an IOError will be generated. Another way to check a file is opened or closed is to check the values of the closed property of the file handler object. Using rename() function is another way to check the file is opened or closed. Different ways to check any file is opened or closed in Python have been shown in this tutorial.

More in Tux Machines

LibreOffice 8.0 New tabbed interface layout available

Muttakin Rizal ( Rizal Muttaqin ), one of the designers LibreOffice office suite, has published in his blog, the user interface possible development plan LibreOffice 8.0. The most notable innovation is the built-in support for tabs, through which you can quickly switch between different documents, similar to how switching between sites is carried out in modern browsers. If necessary, each tab can be unpinned in the form of a separate window, or vice versa, convert the window into a tab. It is also possible to collapse all tabs into a drop-down list accessible by pressing the “^” button. The header also shows a LibreOffice button to launch the initial interface, which was previously shown when starting or closing all documents, to open a file, visually evaluate recently opened documents, or create a new document based on a template. Read more

today's howtos

  • How to install Deltarune Chapter 2 on a Chromebook

    Today we are looking at how to install Deltarune Chapter 2 on a Chromebook. Please follow the video/audio guide as a tutorial where we explain the process step by step and use the commands below.

  • How to Install Spotify on Ubuntu 20.04 Linux

    Spotify is an on-demand music company that gives us access to listen to millions of songs and podcasts for a monthly fee. It has been a revolution in music consumption on the Internet. The right music or podcast is always at your fingertip You can access it on your phone, your computer, your tablet, and more. Some of the most prominent features of Spotify are Equalizer, Listening history, Spotify Connect, Search, Listen offline and you can also listen offline. You can visit the official site to learn more about the features. Spotify is available for Android, iOS, and Windows. A great sign that Linux is also being taken into account. There is a Spotify client for the Linux family and mainly for Ubuntu 20.04 which is perhaps one of the most popular distributions.

  • How to Completely Uninstall Google Chrome From Ubuntu

    So, you managed to install Google Chrome on Ubuntu. It is the most popular web browser in the world, after all. But perhaps you dislike Google products for the heavy tracking and data mining they employ on its users. You decided to opt for other web browsers on Ubuntu, perhaps a non-Chromium browser. Now that you are no longer using it, it would be wise to remove Google Chrome from Ubuntu.

  • How to uninstall applications in GNU / Linux - itsfoss.net

    Either because the latest program we installed does not convince us, or because we are determined to ‘lighten up’ our equipment, it is important to know how we can uninstall software (or rather, using the correct terminology, ‘packages’) from our Linux system . However, one thing we should know about Linux is that there is not just one way to uninstall (or install, since we are) packages , but multiple. In the first place, it will differ according to the distribution we are using, and secondly according to how we prefer to carry out this task using graphical tools or the command line terminal.

  • How To Install Apache Airflow on Ubuntu 20.04 - idroot

    In this tutorial, we will show you how to install Apache Airflow on Ubuntu 20.04 LTS. For those of you who didn’t know, Airflow is one of the most popular workflow management solutions, it authors, schedules, and monitors workflows. Airflow is written in Python, and workflows are created via Python scripts. Airflow is designed under the principle of “configuration as code”. This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Apache Airflow workflows management tool on Ubuntu 20.04 (Focal Fossa). You can follow the same instructions for Ubuntu 18.04, 16.04, and any other Debian-based distribution like Linux Mint.

  • How to Install Cockpit on AlmaLinux 8 or Rocky Linux 8

    The Cockpit is an open-source web-based server management tool that allows administrators to manage and monitor their Linux server systems remotely. It provides a nice Dashboard to administer your Linux servers from a web browser. With Cockpit, you can check the system performance, the load, start/stop services, disk space, CPU & memory usage, running process, and more. One notable feature of Cockpit is that you can access the terminal from the dashboard and install various packages over the remote server.

  • Perfect Server Automated ISPConfig 3 Installation on Debian 10 and Ubuntu 20.04

    This tutorial will take you through installing your own ISPConfig 3 single server setup using the ISPConfig auto-installer. This installer follows the old Perfect Server guides but is more modular and easy to follow. If you want to set up a multiserver setup with dedicated servers for each service instead, see the Perfect Multiserver guide. This guide works for both Debian 10 and Ubuntu 20.04. We will use the hostname server1.example.com. Replace it where necessary.

  • Auto Logout Inactive Users After A Period Of Time In Linux - OSTechNix

    This brief tutorial explains three different ways to auto logout inactive users after a particular period of time in Linux and Unix-like systems. Picture this scenario. You are managing a shared server that is regularly being accessed by many users from all systems in the network. There are chances that some user may forget to logout his session and left the session open. Leaving an user session open is dangerous and some users may misuse it intentionally.

  • 13 Top Command In Linux (Monitor Linux Server Processes) | LinuxTeck

    In this article, we will learn how to monitor running processes on Linux. The Linux OS offers several commands that can be used to monitor a running process, but for checking dynamic real-time processes, we can use a command called 'TOP. This tool enables System Administrators to determine how fully real-time processes are utilized by their current system. With every Linux distribution, the 'top' utility comes pre-installed. We can utilize the interactive command to see the summary of the current system stats, and also customize the list of processes, threads, and many other features. This guide shows you how to use the top with various options to view all the current system activities. System administrators will be able to manage system resources as well as optimize their hardware utilization by analyzing uptime, CPU usage, memory utilization, swap space usage, load average, and all the other processes that are running on their system to ascertain how much real-time processing is being used.

Kernel: Intel Being Intel and Linux Plumbers Conference

  • Intel Alder Lake has a special treat for Windows 11 users, but Linux may be left in the lurch [Ed: Intel continues to prop up Microsoft's monopoly while ruining things for Linux (all the time, e.g. [1, 2])]
  • Linux Plumbers Conference: Get ready for LPC 2021!

    The LPC 2021 conference is just around the corner. We wanted to share the logistics on how to participate and watch the virtual conference. For those that are not registered for the conference, we will have live streaming of the sessions on YouTube, like last year. This is free of charge. We will provide the URLs where to watch each day, on this page. The only limitation is that you cannot participate and ask questions live with audio. However this year we will have the chat in each Big Blue Button room also available externally via the Matrix open communication network. Anyone is invited to join with their personal Matrix account.

Today's Leftovers and Programming Leftovers

  • LHS Episode #429: The Weekender LXXVIII

    It's time once again for The Weekender. This is our bi-weekly departure into the world of amateur radio contests, open source conventions, special events, listener challenges, hedonism and just plain fun. Thanks for listening and, if you happen to get a chance, feel free to call us or e-mail and send us some feedback. Tell us how we're doing. We'd love to hear from you.

  • New Alpha Release: Tor 0.4.7.1-alpha
  • Mozilla is testing setting Bing as the default Firefox search engine - MSPoweruser
  • What is open-source software? Understanding the non-proprietary software that allows you to modify its code [Ed: Lots of disinformation here]
  • It’s Time for Vendor Security 2.0

    1. Questionnaires are largely Security Theater because it’s nearly impossible to assess a company’s security risk from the outside.

    2. If the business needs a given tool, they’ll likely force the company to use it despite the risk.

    3. Given these truths, the most realistic path for protecting ourselves from vendors is heavy investment in Risk Visibility, Risk Reduction, and Risk Communication/Acceptance.

  • Napkin Problem 16: When To Write a Simulator

    I hope you see the value in simulations for getting a handle on these types of problems. I think you’ll also find that writing simulators is some of the most fun programming there is. Enjoy!

  • Use virtual environments to install third-party Python programs from PyPI

    The problem is that Pip's "user" mode involves pretending that Pip is basically a Unix distribution's package manager that just happens to be operating on your $HOME/.local. This is an attractive illusion and it sort of works, but in practice you run into issues over time when you upgrade things, especially if you have more than one program installed. You'll experience some of these issues with virtual environments as well, but with single purpose virtual environments (one venv per program) and keeping track of what you installed, the ultimate brute force solution is to delete and recreate the particular virtual environment. The dependency versions are getting tangled? Delete and recreate. You've moved to a new distribution version of Python (perhaps you've upgraded from one Ubuntu LTS to another)? It sounds like a good time to delete and recreate, rather than dealing with version issues.