Check If a Given String is Heterogram in Python

Rishi Raj
Updated on 23-Jun-2020 16:12:12

2K+ Views

Here one string is given then our task is to check weather a given string is Heterogram or not.The meaning of heterogram checking is that a word, phrase, or sentence in which no letter of the alphabet occurs more than once. A heterogram may be distinguished from a pangram which uses all of the letters of the alphabet.ExampleString is abc def ghiThis is Heterogram (no alphabet repeated)String is abc bcd dfhThis is not Heterogram. (b, c, d are repeated)AlgorithmStep 1: first we separate out list of all alphabets present in sentence. Step 2: Convert list of alphabets into set because ... Read More

Find Largest, Smallest, Second Largest and Second Smallest in a List

karthikeya Boyini
Updated on 23-Jun-2020 16:11:30

2K+ Views

Array is given, we have to find out maximum, minimum, secondlargest, second smallest number.AlgorithmStep 1: input list element Step 2: we take a number and compare it with all other number present in the list. Step 3: get maximum, minimum, secondlargest, second smallest number.Example code# To find largest, smallest, second largest and second smallest in a List    def maxmin(A):       maxi = A[0]       secondsmax = A[0]       mini = A[0]       secondmini = A[0]       for item in A:    if item > maxi:       maxi ... Read More

Select Elements with a Specified Attribute using CSS

Giri Raju
Updated on 23-Jun-2020 16:09:58

195 Views

To select elements with an attribute, use the CSS [attribute] selector.For example, alt attribute or a target attribute, etc.You can try to run the following code to implement the CSS[attribute] selector,ExampleLive Demo                    img[alt] {             border: 3px solid orange;          }                              

Print Common Characters of Two Strings in Alphabetical Order

karthikeya Boyini
Updated on 23-Jun-2020 16:09:56

1K+ Views

Two user input strings are given, our task is to print all the common characters in alphabetical order.ExampleInput: string1: python string2: program Output: opExplanationThe letters that are common between the two strings are o (1 times), p (1 time)AlgorithmStep 1: first we take two input string. Step 2: next we will do to convert these two strings into counter dictionary. Step 3: Now find common elements between two strings using intersection ( ) property. Step 4: Resultant will also be a counter dictionary having common elements as keys and their common frequencies as value. Step 5: Use elements () method ... Read More

CSS Perspective Origin Property

Jennifer Nicholas
Updated on 23-Jun-2020 16:09:26

81 Views

Use the perspective-origin property to specify the bottom position of 3D elements.You can try to run the following code to implement the perspective-origin property:ExampleLive Demo                   .demo1 {             position: relative;             width: 150px;             height: 150px;             background-color: yellow;             perspective: 80px;             margin: 50px;             perspective-origin: left;          }          .demo2 {             position: absolute;             padding: 20px;             background-color: orange;             transform-style: preserve-3d;             transform: rotateX(45deg);          }                     Rotation       Demo          Demo          

Move Spaces to Front of String in Single Traversal

Samual Sam
Updated on 23-Jun-2020 16:09:23

523 Views

Given a string that has set of words and spaces, our task is to move all spaces to front of string, by traversing the string only once. We will solve this problem quickly in Python using List Comprehension.ExampleInput: string = "python program" Output: string= “ pythonprogram"AlgorithmStep1: input a string with word and space. Step2: Traverse the input string and using list comprehension create a string without any space. Step 3: Then calculate a number of spaces. Step 4: Next create a final string with spaces. Step 5: Then concatenate string having no spaces. Step 6: Display string.Example Code# Function to ... Read More

String Slicing in Python to Rotate a String

karthikeya Boyini
Updated on 23-Jun-2020 16:09:07

5K+ Views

A string is given, our task is to slicing the string into two way. One is clockwise and another anticlockwise.1. Left (Or anticlockwise) rotate the given string by d elements (where d pythonprogram Left Rotation: thonprogrampy Right Rotation: ampythonprogr

Specify Perspective for 3D Elements in CSS

Chandu yadav
Updated on 23-Jun-2020 16:08:25

88 Views

Use the CSS perspective property to specify the perspective on how 3D elements are viewed.You can try to run the following code to achieve thisExampleLive Demo                    .demo1 {             position: relative;             width: 150px;             height: 150px;             background-color: yellow;             perspective: 80px;             margin: 50px;          }          .demo2 {             position: absolute;             padding: 20px;             background-color: orange;             transform-style: preserve-3d;             transform: rotateX(45deg);          }                       Rotation       Demo          Demo                    

Calculate n + n * m + n * m * m + ... + n * m ^ m Times

Samual Sam
Updated on 23-Jun-2020 16:03:14

566 Views

Here n is given value which is positive number m is the number of times till which the series run. Our task is to calculate this series.AlgorithmStep 1: Input n, m; Step 2: Converting the number to string. Step 3: Initializing result as number and string. Step 4: Adding remaining terms. Step 5: Concatenating the string making n, nn, nnn... Step 6: Before adding converting back to integer. Step 7: return sum.Example Code# Python program to sum the series def sumofseries(n, m):    str1 = str(n)    sum1 = n    sumofstr1 = str(n)    for i in range(1, m): ... Read More

Check if Both Halves of the String Have Same Set of Characters in Python

karthikeya Boyini
Updated on 23-Jun-2020 16:01:38

269 Views

Given a string, our task is to check if both halves of the string have the same set of characters or not. To solve this problem we first split the string from the middle, so we get two halves, now we check each halves having the same set of characters or not. If the length of the string is not even then ignore the middle element and check for the rest.AlgorithmStep 1: Given a string. Step 2: Break the input string into two parts. Step 3: Then convert both parts into a dictionary using Counter(iterator) method and each dictionary contains ... Read More

Advertisements