Check If a String Contains All Unique Characters in Python

Pavitra
Updated on 26-Sep-2019 12:14:14

708 Views

In this article, we will learn about the solution and approach to solve the given problem statement.Problem statementGiven a sring input, we need to find whether a string contains all unique characters or not.ApproachWe will create an array of boolean values, where the variable flag at the index i indicates that whether character i in the alphabet is contained in the string or not.The second time we encounter this character we can immediately return false as string characters is no longer unique.We can also return false if the string length exceeds the value of number of unique characters presnt in ... Read More

Check Armstrong Number in Python

Pavitra
Updated on 26-Sep-2019 12:11:58

2K+ Views

In this article, we will learn about the solution and approach to solve the given problem statement.Problem statementGiven an integer n , we need to check that the given integer is an armstrong number.A positive integer is called an Armstrong number of order n ifabcd... = a^n + b^n + c^n + d^n + …Here we will be discussing the brute-force approach for an armstrong number of 3 digits and hence of order three.To check the armstrong number of order n we need to replace 3 by the corresponding order value in line number 7.Now let’s see the implementation −Example Live ... Read More

Sum of Squares of First N Natural Numbers in Python

Pavitra
Updated on 26-Sep-2019 12:04:49

887 Views

In this article, we will learn about the solution and approach to solve the given problem statement.Problem statementGiven a positive integer N as input . We need to compute the value of 12 + 22 + 32 + ….. + N2.Problem statement:This can be solved by two methodsMultiplication addition arithmeticUsing mathematical formulaApproach 1: Multiplication & Addition ArithmeticHere we run a loop from 1 to n and for each i, 1

HTML KeyboardEvent which Property

AmitDiwan
Updated on 26-Sep-2019 12:00:14

86 Views

The HTML KeyboardEvent which property returns the Unicode character code of the key that fires the onkeypress event, onkeydown event or onkeyup event in an HTML document.SyntaxFollowing is the syntax −event.whichLet us see an example of HTML KeyboardEvent which property −Example Live Demo    body {       color: #000;       height: 100vh;       background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) no-repeat;       text-align: center;    }    input {       border: 2px solid #fff;       padding: 8px;       background: transparent;       width: 310px;   ... Read More

Smallest K-Digit Number Divisible by X in Python

Pavitra
Updated on 26-Sep-2019 12:00:10

444 Views

In this article, we will learn about the solution and approach to solve the given problem statement.Problem statementIntegers n and d are given. We need to find the smallest n-digit number divisible by d.Approach1. FirstNow let's we compute MIN : smallest n-digit number (1000...n-times)2. Now, If MIN % X is 0, ans = MIN3. else, ans = (MIN + X) - ((MIN + X) % X))This is because there will be a number in range [MIN...MIN+X] which is divisible by d.Now let’s see the implementation −Example Live Demodef answer(n, d):    # Computing MAX    Min = pow(10, d-1)    if(Min%n ... Read More

HTML Navigator JavaEnabled Method

AmitDiwan
Updated on 26-Sep-2019 11:57:07

145 Views

The HTML navigator javaEnabled() method returns a boolean value that defines whether the browser has java enable or not.SyntaxFollowing is the syntax −navigator.javaEnabled()Let us see an example of HTML navigator userAgent property −Example Live Demo    body {       color: #000;       height: 100vh;       background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) no-repeat;       text-align: center;    }    .btn {       background: #db133a;       border: none;       height: 2rem;       border-radius: 20px;       width: 330px;       display: block;   ... Read More

Simple Interest in Python Program

Pavitra
Updated on 26-Sep-2019 11:56:50

282 Views

In this article, we will learn about the calculation of simple interest in Python 3.x. Or earlier.Simple interestis calculated by multiplying the daily interest rate by the principal amount by the number of days that elapse between the payments.Mathematically, Simple Interest = (P x T x R)/100Where, P is the principal amountT is the time andR is the rateFor Example, If P = 1000, R = 1, T = 2Then SI=20.0Now let’s see how we can implement a simple interest calculator in Python.Example Live DemoP = 1000 R = 1 T = 2 # simple interest SI = (P * R ... Read More

HTML Navigator UserAgent Property

AmitDiwan
Updated on 26-Sep-2019 11:52:57

222 Views

The HTML navigator userAgent property returns the value of the user-agent header sent by the browser to the server.SyntaxFollowing is the syntax −navigator.userAgentLet us see an example of HTML navigator userAgent property −Example Live Demo    body {       color: #000;       height: 100vh;       background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) no-repeat;       text-align: center;    }    .btn {       background: #db133a;       border: none;       height: 2rem;       border-radius: 20px;       width: 330px;       display: block;   ... Read More

HTML Navigator Product Property

AmitDiwan
Updated on 26-Sep-2019 11:49:14

115 Views

The HTML navigator product property returns the browser’s engine name.SyntaxFollowing is the syntax −navigator.productLet us see an example of HTML navigator product property −Example Live Demo    body {       color: #000;       height: 100vh;       background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) no-repeat;       text-align: center;    }    .btn {       background: #db133a;       border: none;       height: 2rem;       border-radius: 20px;       width: 330px;       display: block;       color: #fff;       outline: none; ... Read More

Selection Sort in Python Program

Pavitra
Updated on 26-Sep-2019 11:49:07

383 Views

In this article, we will learn about the Selection sort and its implementation in Python 3.x. Or earlier.In selection sort algorithm, an array is sorted by recursively finding the minimum element from the unsorted part and inserting it at the beginning. Two subarrays are formed during the execution of Selection sort on a given array.The subarray , which is already sorted.The subarray , which is unsorted.During every iteration of selection sort, the minimum element from the unsorted subarray is popped and inserted into the sorted subarray.Let’s see the visual representation of the algorithm −Now let’s see the implementation of the ... Read More

Advertisements