In this article, we will learn how to convert time from 12 to 24 hours format. Let’s say we have the following input date in 12-hour format − 10:25:30 PM The following is the output in 24-hour format − 22:25:30 Convert current time from 12 hour to 24 hour format To convert time from 12 hour to 24 hour format, here’s the code − Example import datetime def timeconvert(str1): if str1[-2:] == "AM" and str1[:2] == "12": return "00" + str1[2:-2] elif str1[-2:] == "AM": return str1[:-2] elif str1[-2:] == "PM" and str1[:2] == "12": return str1[:-2] ... Read More
The difflib module is used in Python to compute deltas. It is used to compare files, and can produce information about file differences in various formats, including HTML and context and unified diffs. We need to first import the difflib module before using it − import difflib Class (difflib.SequenceMatcher) This class is used to compare two sequences of any type. It has different methods. Some of the methods − set_seqs(a, b) − Set the sequence files which will be compared. It computes and caches detailed information about the second file. So for matching multiple files, we should set ... Read More
The Numeric Types in Python are the integer datatypes. It includes integers, floatimg point, complex, etc. The complex includes real and imag parts. Also, includes Hexadecimal and Octal types. Python int datatype The Numeric Types include the int datatypes − a = 5 print("Integer = ", a) print("Type = ", type(a)) Output Integer = 5 Type = Python float datatype The Numeric Types include the float datatypes − Example a = 7E2 print("Float = ", a) print("Type = ", type(a)) Output Float = 700.0 Type = Python complex datatype The Numeric Types include the ... Read More
Suppose you are building a web app that manages the data of daily tasks, the user inserts the task and a list of tasks gets formed. But at some point in time, the user wants to remove all the tasks from the list and wants to make the list empty. So, as a developer, you should know how to remove all the child elements from the DOM node. To remove all the elements from the DOM node we have the following approaches. By iterating the DOM nodes and using the removeChild method. By Erasing the innerHTML value to a ... Read More
We will count the number of vowels using set in a given string. Let’s say we have the following input − jackofalltrades The output should be the following, counting the number of vowels − 65 Count the number of vowels using set in a given string We will count the number of vowels using set in a give string − Example def vowelFunc(str): c = 0 # Create a set of vowels s="aeiouAEIOU" v = set(s) # Loop to traverse the alphabet in the given string for alpha in str: # If alphabet is present # in ... Read More
To check if two lists have at least one common element, we will loop through list1 and list2 and check for atleast one common element in both the lists. The list is the most versatile datatype available in Python, which can be written as a list of comma-separated values (items) between square brackets. Important thing about a list is that the items in a list need not be of the same type. Let’s say we have the following inputs i.e. 2 lists − [15, 45, 67, 30, 98] [10, 8, 45, 48, 30] The output should be the following ... Read More
Spoofing is an identity theft where a person tries to use the identity of a legitimate user. Phishing, on the other hand, is a phenomenon where an attacker employs social engineering methods to steal sensitive and confidential information from a user. Spoofing and phishing are both forms of cyber-attacks aimed at tricking you into disclosing your personal information. Both methods will be used by a criminal to gain your user names, passwords, and maybe more. Despite the fact that their final aim is the same, their techniques are not. Read through this article to find out more ... Read More
Both Routers and Modems are network connecting devices. Routers work at the network layer and are responsible to find the shortest path for a packet, whereas Modems connect a device like desktop, laptop to the Internet. Routers connect devices across multiple networks. Read through this article to find out more about Routers and Modems and how they are different from each other. What is a Modem? A modulator-demodulator, or a modem, is a piece of hardware that transforms data from a digital format designed for direct communication between devices using specific cabling into a format suitable for transmission via ... Read More
In this article, we will learn how to use map function to find row with maximum number of 1's. 2D array is given and the elements of the arrays are 0 and 1. All rows are sorted. We have to find row with maximum number of 1's. Here we use map (). The map function is the simplest one among Python built-ins used for functional programming. These tools apply functions to sequences and other iterables. Let’s say the input is the following array − [[0, 1, 1, 1, 1], [0, 0, 1, 1, 1], [1, 1, 1, 1, 1], [0, ... Read More
Both Routers and Gateways are network connecting devices. Routers work at the network layer and are responsible to find the shortest path for a packet. Routers connect devices across multiple networks. Gateways, in contrast, function as a node that serves as a gateway to a network's other nodes. Read through this article to find out more about Routers and Gateways and how they are different from each other. What is a Router? A router is basically a network connecting device that determines the quickest path for a packet to go to its destination. The primary objective of using a router ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP