Python Program to check if the given array is Monotonic

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

997 Views

In this article, we will learn about the solution and approach to solve the given problem statement.Problem statementGiven an array input Arr containing n integers. We need to check whether the input array is Monotonic in nature or not.An array is said to be monotonic in nature if it is either continuously increasing or continuously decreasing.Mathematically,An array A is continuously increasing if for all i

Python program to check if a string contains all unique characters

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

425 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

Python Program to Check Armstrong Number

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

1K+ 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

Python Program for Sum of squares of first n natural numbers

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

595 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

37 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

Python Program for Smallest K digit number divisible by X

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

269 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

81 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

169 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

131 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

58 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

Advertisements