
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 26504 Articles for Server Side Programming

2K+ Views
Python does not support a character type; these are treated as strings of length one, thus also considered a substring.ExampleTo access substrings, use the square brackets for slicing along with the index or indices to obtain your substring. For example − Live Demo#!/usr/bin/python var1 = 'Hello World!' var2 = "Python Programming" print "var1[0]: ", var1[0] print "var2[1:5]: ", var2[1:5]OutputWhen the above code is executed, it produces the following result −var1[0]: H var2[1:5]: ytho

1K+ Views
In this article, we will go through Python's mathematical constants and how to use them. Some of the defined constants that can be utilized in a variety of mathematical operations are included in the math module. These mathematical constants return values that are equivalent to their standard defined values. The following math module constants are available in the Python programming language: Python math.e constant Python math.pi constant Python math.tau constant Python math.inf constant Python math.nan constant Python math.e constant The Euler's number, 2.71828182846, is returned by the math.e constant. Syntax math.e Return Value − It returns the ... Read More

532 Views
Random numbers are used for games, simulations, testing, security, and privacy applications. Python includes following functions that are commonly used.Sr.NoFunction & Description1choice(seq)A random item from a list, tuple, or string.2randrange ([start, ] stop [, step])A randomly selected element from range(start, stop, step)3random()A random float r, such that 0 is less than or equal to r and r is less than 14seed([x])Sets the integer starting value used in generating random numbers. Call this function before calling any other random module function. Returns None.5shuffle(lst)Randomizes the items of a list in place. Returns None.6uniform(x, y)A random float r, such that x is less ... Read More

782 Views
Suppose we have a string s that is formed by digits ('0' - '9') and '#'. We have to map s to one English lowercase characters as follows −Characters ('a' to 'i') are represented by ('1' to '9') respectively.Characters ('j' to 'z') are represented by ('10#' to '26#') respectively.We have to find the string formed after mapping. We are taking one assumption that a unique mapping will always exist. So if the input is like “10#11#12”, then it will be “jkab”. As 10# is j, 11# is k, 1 is a and 2 is b.To solve this, we will follow ... Read More

816 Views
Suppose we have one ‘head’ which is a reference node to a singly-linked list. The value of each node present in the linked list is either 0 or 1. This linked list stores the binary representation of a number. We have to return the decimal value of the number present in the linked list. So if the list is like [1, 0, 1, 1, 0, 1]To solve this, we will follow these steps −x := convert the list elements into an arraythen reverse the list xans := 0, and temp := 1for i in range i := 0, to size ... Read More

615 Views
Suppose we have one 2D grid of size m x n. We have another variable k. We have to shift the grid k times. The shift operation will be as followsElement at grid G[i, j] moves to G[i, j + 1]Element at grid G[i, n – 1] moves to G[i + 1, 0]Element at grid G[m - 1, n – 1] moves to G[0, 0]So if the grid is like −123456789The output will be −912345678To solve this, we will follow these steps −The shift operation will take the matrix as inputn = number of rows, m := number of columns, ... Read More

406 Views
Suppose there are some chips, the i-th chip is at present at position chips[i]. We can perform any of the two following types of operations any many numbers of times as we want (possibly zero) on any chip −Move the i-th chip by 2 units to the left side or to the right side with a cost of 0.Move the i-th chip by 1 unit to the left side or to the right side with a cost of 1.Initially, there can be two or more chips. We have to return the minimum cost needed to move all the chips to ... Read More

359 Views
Suppose we have an array A of integers, we have to modify the array in the following way −We can choose an i and replace the A[i] with -A[i], and we will repeat this process K times. We have to return the largest possible sum of the array after changing it in this way.So, if the array A = [4, 2, 3], and K = 1, then the output will be 5. So choose indices 1, the array will become [4, -2, 3]To solve this, we will follow these steps −Sort the array Afor i in range 0 to length ... Read More

1K+ Views
Suppose we have an array with n integers, our task is to check whether it could become nondecreasing by modifying at most one element. We can define an array is non-decreasing if it satisfies this rule: array[i] 0if arr[i - 1] > arr[i + 1], then arr[i + 1] := arr[i]return trueExample (Python)Let us see the following implementation to get a better understanding − Live Democlass Solution(object): def checkPossibility(self, nums): if len(nums) nums[i+1]: if ans: return False ... Read More

745 Views
Suppose we have two binary trees and consider that when we put one of them to cover the other, some nodes of the two trees are overlapped while the others are overlapping. We have to merge them into a new binary tree. The merge rule is like that if two nodes are overlapping, then sum node values up as the new value of the merged node. Otherwise, the non-empty node will be used as the node of the new tree.So if the trees are −Then the output will be −To solve this, we will follow these steps −The method is ... Read More