Posts

LIST FILES AND FOLDERS WITH THEIR RESPECTIVE SIZES

Here is a python script which prints list of files and folders with their respective sizes. This script is particularly useful on Windows systems. Create a file with .py extension and paste the below code in the file. Copy the file to any directory or drive and run it on command prompt.   #to list files and directories with size in the current path import  os  #importing the module os from  columnar  import  columnar  #to create a table on output, install it with: pip install columnar filepath =  '.'   #setting the path for which files and directories are to be seen file_list = os.listdir(filepath)  #getting the list of files and directories data = []  #in this list/array, we shall add each file/folder name with their respective sizes(in KB/MB/GB) sizes = []  #in this list/array, add all the sizes for  x  in  file_list:     file_size = os.path.getsize(filepath+ "/" +x)  #calculating size of each file item     file_size = file_size /  1024     file_size =  round (fil

HOW TO CREATE A PYTHON SCRIPT

 To create and run a python script, please make sure you have already installed python language and in most computers it is already there.A python script can be run on different OS platforms and can be used to perform a wide variety of system and user functions. Let me show you how to create a simple python script.Use some good editor to start typing python code.You may use powerful tools like Visual Studio Code and PyCharm to start python coding.Open a blank page and start the code with lines like: #!/usr/bin/python #help text: this is my first script The first line is shebang line and usually used in unix-like systems like Linux.It tells the location of python interpreter.The second line is a simple comment.We shall add more code to create a simple script which will ask user to input two numbers which can be added together. #help text: simple script to input numbers to get the sum number1 = input('Please enter first number: ') number2 = input('Please enter second number:

HOW TO INSTALL PYTHON

Image
Python is an interpreted, high-level and general-purpose programming language.It can be used to create simple and complex system scripts to carry out different kinds of operating system-level tasks. Python is also used to create very powerful web and desktop applications.It is also being used to create powerful backend APIs for mobile apps. In this article, I can tell you how to install python if it is not already installed on your computer.To check whether python is already installed: On Windows, search for cmd.exe or open command prompt.Run the following command to know the version of python already installed: python --version  On linux/Mac, open a terminal window and run the above command. If the command shows the version of the python, it is good to know it is installed.On linux, you can also try to run the following commands: python2 --version python3 --version The python version can be 2 or 3. On windows, many times, it is required to install the python language. 1. Visit the web