Python Move File: A Complete Guide
The Python shutil.move() method moves a file to another location on your computer. This method is part of the shutil model, which you must import before using this method. Moving files is a common operation in Python programs. For instance,…
CSS focus: A How-To Guide
The CSS :focus psuedo-class selects an element in its focus state. This happens when you click on an element or select it with the tab button. :focus comes after the name of the element you want to select. You may…
CSS Hide Element: A Step-By-Step Guide
You can hide an element in CSS using the CSS properties display: none or visibility: hidden. display: none removes the entire element from the page and mat affect the layout of the page. visibility: hidden hides the element while keeping…
Python Shuffle List: A Step-By-Step Guide
The Python random.shuffle() method changes the order of the items in a list at random. Combined with indexing, this method is useful for selecting a random item from a list. The random.shuffle() method accepts one argument: the list you want…
How to Ask Someone to Be a Reference
A lot of stress goes into the job search process. Wondering about how to ask someone to be a reference can be one of them. During your job search, you may be asked to produce a list of referees who…
CSS Nth Child: The Complete Guide
The CSS :nth-child() selector applies a style to elements at a specific position in a group. Often, the :nth-child() selector is used to style particular list items, such as every second or third item. When you’re designing a website, you…
Python Power: A Step-By-Step Guide
The ** operator and the pow() function calculate the power of a number in Python. The ** operator raises the number on the left to the power of the number on the right. The pow() function raises the first parameter…
Python Ord: A Step-By-Step Guide
The Python ord() method converts a character into its Unicode code. The ord() method takes one argument: a string containing a single Unicode character. This method returns an integer that represents that character in Unicode. You may encounter a situation…
How to Write a Python Insertion Sort
The Python insertion sort works like sorting game cards. To use the insertion sort, you create two lists: a sorted and unsorted list. You compare each item in the unsorted list until you sort that item. The insertion sort is…
How to Use the Python Modulo Operator
The Python modulo operator calculates the remainder of dividing two values. This operator is represented by the percentage sign (%). The syntax for the modulo operator is: number1 % number2. The first number is divided by the second then the…
How to Copy a List in Python
You can copy a list in Python using the copy() method, slicing, the list() method, and a list comprehension. The copy() method is the most direct way of copying a Python list. When you’re working with a list in Python,…
Selection Sort Python: A Guide
A Python selection sort divides a list into two small lists. One list represents the sorted elements. The other list contains the unsorted elements. The selection sort finds the smallest or highest values in each iteration and moves those values…
Python Create Directory: A How-To Guide
The Python os.mkdir() method creates a blank directory on your file system. You cannot use this method to create a folder in a folder that does not exist. The os.mkdirs() method recursively creates a blank directory. Files let you store…
Linux cp Command: A Guide
The Linux cp command copies a file or a folder on a computer. You can move one or more files and folders at the same time. The syntax for cp is the name of the file to be copied followed…
Python Rename File: A Step-By-Step Guide
The Python os.rename() method changes the name of a file. os.rename() accepts two arguments: the path of the old file and the path of the new file. The new file path should end in a different file name. When you’re…
How to Use the Python not Keyword
The Python not keyword returns True if a value is equal to False and vice versa. This keyword inverts the value of a Boolean. The not keyword can be used with an if statement to check if a value is…
Python Flatten List: A How-To Guide
Flattening a list refers to the process of removing a dimension from a list. A dimension refers to an additional co-ordinate needed to locate an item in a list. You can flatten a Python list using a list comprehension, a…
JavaScript Array Contains: A Step-By-Step Guide
The JavaScript includes() method searches an array for an item. This method returns True if the element in the array exists. The filter() method lets you find an item in a list. Unlike includes(), the filter() method returns the item…
Git Clone Specific Branch: A How-To Guide
The git clone --single-branch --branch command clones a specific branch. This command lets you copy the contents of a repository without downloading all the branches on the repository. It is useful if a repository is large and you only want…
Git Undo Merge: A Guide
You can undo a Git merge using the git reset --merge command. This command changes all files that are different between your current repository and a particular commit. There is no "git undo merge" command but the git reset command…
Java Selection Sort: A How-To Guide
The Java selection sort finds the smallest item in a list and moves that value to the start of the list. This happens repeatedly until every element in the first list has been sorted. The selection sort returns the sorted…
Python Absolute Value: A Step-By-Step Guide
The Python abs() method returns the absolute value of a number. The absolute value of a number is the number’s distance from 0. This makes any negative number positive, while positive numbers are unaffected. For example, abs(-9) would return 9,…
CSS Font Color: A How-To Guide
The CSS background-color property applies color to a text element. You can specify a CSS built-in color keyword, a hexadecimal value, or another color value with the background-color property. The syntax for this property is: color: yourcolor;. How to Apply…
CSS Line Height: A How-To Guide
The CSS line-height property determines the line height of different HTML elements. It is commonly used to set the distance between lines of text. A line height can be set using keywords, percentages, or numerical values. The CSS line-height property…
Java break Statement: A How-To Guide
A Java break statement halts the execution of a loop. When a break statement is run, a program starts to run the code after a statement. If a break statement is used in a nested loop, only the innermost loop…
JavaScript Concatenate Strings: A Guide
The JavaScript concat() method merges the contents of two or more strings. You can also use the + concatenation operator to merge multiple strings. The concatenation operator is preferred in most cases as it is more concise. Concatenation is a…
Java Ternary Operator: A Step-By-Step Guide
The Java ternary operator lets you write an if statement on one line of code. A ternary operator can either evaluate to true or false. It returns a specified value depending on whether the statement evaluates to true or false.…
How to Use the JavaScript += Operator
The JavaScript += operator adds two values together and assigns the result to a variable. This operator is called the addition assignment operator. It is more convenient than the regular variable = X + Y syntax. A plus sign and…
Python Remove Character from String: A Guide
You can remove a character from a Python string using replace() or translate(). Both these methods replace a character or string with a given value. If an empty string is specified, the character or string you select is removed from…
JavaScript Trim: A Step-By-Step Guide
The JavaScript trim() method removes white space characters from the beginning and end of a string. The trimLeft() and trimStart() methods trim white space characters from the beginning of a string. trimRight() and trimEnd() trim white spaces from the end…