Convert Dictionary Values to Absolute Magnitude Using Python

Pranay Arora
Updated on 29-Aug-2023 12:56:53

309 Views

Dictionaries are data structures that can contain key and values of any data type. The values can be of integer type as well. In this article we are going to see How to Convert Dictionary values to Absolute Magnitude using Python which simply means if a value is in negative it will be converted to it’s absolute or positive value while positive values will remain as it is. I/O Example Input = {'a':1 , 'b' : -1} Output = {'a':1 , 'b' : 1} To do this conversion, there are lot of techniques however 1 function that ... Read More

Convert Dictionary to K-Sized Dictionaries Using Python

Pranay Arora
Updated on 29-Aug-2023 12:54:11

111 Views

Dictionaries are key-value data structures in python where in the keys are unique and values can be repeated or not. The keys and values can be of any data type. In this article we are going to see How to Convert dictionary to K sized dictionaries using Python which simply means we will divide a dictionary into k-smaller dictionaries where k is any positive number i.e. k>0. Example Let the input dictionary be d = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'x': 8, 'y': 9} The corresponding output should be {'a': 1, ... Read More

Round Down Float to 2 Decimals in Python

Vikram Chiluka
Updated on 29-Aug-2023 07:46:09

166K+ Views

In this article, we will show you how to round off a floating number upto 2 decimals in python. Below are the various methods to accomplish this task: Using round() function Using format() function Using Decimal Module Using ceil() function Using round() function The round() function gives a floating point number with a specified number of decimals which is the rounded version of the specified number. The function will return the nearest integer because the default value for the number of decimals is 0. Syntax round(number, digits) Parameters number(required)- a number that should be rounded digits(optional)- ... Read More

Semaphores in Operating System

David Meador
Updated on 29-Aug-2023 07:37:21

214K+ Views

Semaphores are integer variables that are used to solve the critical section problem by using two atomic operations, wait and signal that are used for process synchronization.The definitions of wait and signal are as follows −WaitThe wait operation decrements the value of its argument S, if it is positive. If S is negative or zero, then no operation is performed.wait(S) {    while (S

Set Font Color in HTML

Lokesh Badavath
Updated on 29-Aug-2023 07:35:05

161K+ Views

We use the style attribute to set the font color in HTML. The style attribute specifies an inline style for an element, with the CSS color property. The attribute is used with the HTML tag, with the CSS color property. HTML5 do not support the tag, so the CSS style is used to add font color. The tag deprecated in HTML5. Syntax text… Example In the example below, we set the font color of the text inside the tag. DOCTYPE html> HTML Font color ... Read More

Add Color to a Drop-Down List in Excel

Pradeep Kumar
Updated on 29-Aug-2023 07:28:40

406K+ Views

Color can be a powerful element in an Excel drop down list, and it's easier to incorporate than you may think. We can add conditional formatting rules to the cell containing the drop-down list. Learn how to provide visual clues by adding a new list and validation control, followed by conditional format rules. For example, I have created a drop-down list of city names; when I select "Hyderabad", I want the cell to be colored Yellow automatically, and when I select "Chicago", I want the cell to be colored Blue, as shown in the screenshot below. First, Create ... Read More

Set Environment Variables Using PowerShell

Chirag Nagrekar
Updated on 29-Aug-2023 07:24:55

277K+ Views

To set the environmental variable using PowerShell you need to use the assignment operator (=). If the variable already exists then you can use the += operator to append the value, otherwise, a new environment variable will be created.For example, there is no AZURE_RESOURCE_GROUP environment variable that exists in the system. We can create it as below.$env:AZURE_RESOURCE_GROUP = 'MyTestResourceGroup'Now when you check the environment variables in the system, you will get the above variable name.PS C:\Windows\system32> dir env: Name                            Value ----             ... Read More

Check Data Type in Pandas DataFrame

Gireesha Devara
Updated on 29-Aug-2023 07:20:28

213K+ Views

To check the data type in pandas DataFrame we can use the "dtype" attribute. The attribute returns a series with the data type of each column.And the column names of the DataFrame are represented as the index of the resultant series object and the corresponding data types are returned as values of the series object.If any column has mixed data types are stored then the data type of the entire column is indicated as object dtype.Example 1Apply the pandas dtype property and verify the data type of each in the DataFrame object.# importing pandas package import pandas as pd ... Read More

Set Background Color in HTML

Lokesh Badavath
Updated on 29-Aug-2023 07:08:04

244K+ Views

Setting the background color of a web page or an element on the web page, enable us to create unique layouts for the web page. To set the background color in HTML, use the style attribute, with the CSS property background-color inside the body tag of the HTML document. HTML5 do not support the tag bgcolor attribute, so the CSS style is used to add background color. The bgcolor attribute deprecated in HTML5. We can change the background color by overriding the property with the other property. Syntax Example Following is the example program to set background ... Read More

Use an Image as a Link in HTML

Lokesh Badavath
Updated on 29-Aug-2023 07:02:36

347K+ Views

We can add image as a link and other HTML elements as a link. A link is a connection from one Web page to another web page. We can add page links to a web page. HTML links are hyperlinks. The tag defines a hyperlink and used to link from one page to another. The href attribute is used with the tag, which indicates the link's destination. To make page links in an HTML page, use the and tags, with href attribute used to define the links. We should use the … tags inside … tags. Syntax ... Read More

Advertisements