How to Make a Beep Sound in Python? [Linux/macOS/Win]

Windows: How to Make Beep in Python To make a beep sound in Python on your Windows machine: Import the library using: import winsound Call windsound.Beep(frequency, duration) for your desired frequency (in Hertz) and duration (in milliseconds). For example, winsound.Beep(2000, 1500) would make a sound with 2000 Hz for 1.5 seconds. Here’s the relevant code … Read more

PowerShell Operators

Windows PowerShell uses variables to store values, and we have a large set of operators we can use to modify or compare those variables. PowerShell Assignment Operators Assignment Operators allow us to simply create variables and populate them with values in one command: When we call those variables, we can see the values they contain: … Read more

PowerShell Loops – A Simple Guide with Video

PowerShell foreach Loop Syntax: The keyword ‘foreach‘ is used in Windows PowerShell to iterate through a series or list of items, usually with the intent of performing operations using each item.  Example: In the following example, we use PowerShell to read the contents of a text file (C:\Temp\ServerList.txt) filled with server names, storing the values … Read more

How Do I List All Files of a Directory in Python?

Problem: Given a directory. How to list all the files in the directory using Python? Video Solution  What is a directory?A directory is a unit organizational structure used to store a collection of programs and subdirectories. Sometimes as a coder you have to deal with the countless number files within different directories. Hence, it becomes … Read more

What’s the Difference Between ‘py’ and ‘python’ in the Terminal?

Problem If you run Python in your terminal or shell, you may have realized that there are two ways to do so: using the “python” command and using the “py” command. What’s the difference? Example Say, you want to check your Python version. You can run both commands and the output is different! Here’s using … Read more

How to Get a Windows Screenshot in Python?

Problem Formulation Say, you run a Python program on your Windows machine and you want it to take a screenshot. How to accomplish this programmatically? Method 1: Multiple Screen Shots Module To programmatically record one or more screenshots in your Python program, run the sct.shot() function from the mss module. Install the Multiple Screen Shots … Read more

How to Open Outlook in Python?

Problem Formulation Given a Windows operating system on which you have the Microsoft Outlook email program installed. How to open Microsoft Outlook using only a function call in your Python script? Solution: os.startfile(‘outlook’) The easiest way to open Outlook on Windows using only a short and concise Python One-Liner is to use the os.startfile(‘outlook’) function … Read more