Skip to main content

Not equal to in python using != operator

To check if two operands are not equal python provides operator !=.

Let’s see an example of not equal to an operator on an integer variable.

#Use of operator not equal to
a= "3"
b= "4"
c = "4"
#If a is not equal to b then conditon will print true
print("a=",a,"b=",b,"\nResult of Not Equal to Operator is ",a!=b)
print("\n")
#if c equal to b then condition will print false as we are using not equal to operator
print(" b=",b,"c=",c,"\nResult of Not Equal to Operator is  ",b!=c)
print("\n")
a= 3 b= 4 
Result of Not Equal to Operator is  True


 b= 4 c= 4 
Result of Not Equal to Operator is   False

Similarly, we can apply not equal to an operator on a variable that contains string values.

!= Operator return value as True when the value of operands are different. If both operands are the same then Not Equal to the operator will return False.

#Let's See with String value
str1= "ethosspace.com"
str2= "google.com"
str3 = "google.com"
#If str1 is not equal to str2 then conditon will print true
print("str1=",str1,"str2=",str2,"\nResult of Not Equal to Operator is ",str1!=str2)
print("\n")
#if str3 equal to str2 then condition will print false as we are using not equal to operator
print(" str2=",str2,"str3=",str3,"\nResult of Not Equal to Operator is  ",str2!=str3)
str1= ethosspace.com str2= google.com 
Result of Not Equal to Operator is  True


 str2= google.com str3= google.com 
Result of Not Equal to Operator is   False

Which property is useful to hide the element but should not take space

There are 2 different properties to hide element from User Interface. One is visibility Property and other is display property.

For example if we want to hide one element like button. Then using code “visibility:hidden” html page will hide the button from UI. But space occupied or size of the button will get consumed on front page. So tag is getting rendered but not data. So tag size is visible on page but not its content.

If user want to hide the complete tag and associated data from page then html/css provide property like “display:none”. By using display none property user can hide not only data but associated tag as well. This will have no impact on page layout.

Below are example which will give difference between visibility:hidden and display:none

Step 1) Displaying two buttons

<button type="button" >Button One</button>
<button type="button" >Button Two</button>

Step 2) Now using visibility:hidden for first button.

<button type="button" style="visibility:hidden">Button One</button>
<button type="button" >Button Two</button>

If you observe in above code button one is hidden but size is occupied on page layout.

Let’s use display:none property and see the effect.

<button type="button" style="display:none">Button One</button>
<button type="button" >Button Two</button>

So in above example if you observe due to display:none property button one is completed hide and associated tag is not rendered on page. That’s why button two is completely left aligned.

Run time user can change property to hide the element by using below code in java script.

document.getElementById("button1").style.visibility = "visible"; 

Compare Result with Different Search Engine using batch file

To see what results in different search engines provide for a specific query then copy the below code in notepad. Save that file as “abc.bat” and double-click on it.
By using an alternative search engine we can see different results for the same query.

@start www.google.com/search?q=ethosspace+Software+Testing+Services
@start https://www.bing.com/search?q=ethosspace+Software+Testing+Services
@start https://duckduckgo.com/?q=ethosspace+software+testing+services
@start https://search.yahoo.com/search?q=ethosspace+Software+Testing+Services
@start https://www.ecosia.org/search?q=ethosspace+software+testing+services
@start https://yandex.com/search/?text=ethosspace+software+testing+services
@start https://duckduckgo.com/?q=ethosspace+software+testing+services
@start https://www.lukol.com/s.php?q=ethosspace+software+testing+services
@start https://metager.org/meta/meta.ger3?eingabe=ethosspace+software+testing+services

Most of the search engines use parameters as search?q with the search string. Some search engines use parameter as ?q with search string.

For example, here we have used the search string as “ethosspace+Software+Testing+Services” so the same can be used differently for different search engines. The format is mentioned above code.

Simple code to Generate QR Code using Python

To generate QR Code like Below

It is important to install pyqrcode and pypng. To install this you can use the command prompt and use the below command.

pip install pyqrcode
pip install pypng

Below simple 5 line code will generate QR code for URL in python

#QR Code Generator
import pyqrcode
from pyqrcode import QRCode
urlDest = 'https://www.ethosspace.com/'
varQR = QRCode(urlDest, error='H', version=None, mode=None, encoding='iso-8859-1')
varQR.png('generatedQR.png', scale=8)
varQR.show()

Here in dest variable, we have used hyperlink ethosspace.com. Which can be replaced with url to generate QR Code.

How to remove duplicate keys from dictionary in python

This python code will remove all duplicate keys and associate items from the dictionary. To remove we are using one temp array and using it for loop iterating each value.

thisdict = {
  "1": "C language",
  "2": "Java Language",
  "4": "Python Language",
  "3": "C++",
  "4": "Python Language",
  "3": "C++",
  "5": "C++",
}
#declare temp array
tempA = []  
uniqueDict = dict()
for key, val in thisdict.items():
    if val not in tempA:
        tempA.append(val)
        uniqueDict[key] = val

print(uniqueDict)
{'1': 'C language', '2': 'Java Language', '4': 'Python Language', '3': 'C++'}

How to count occurrences of words, characters, sentences using Regular Expression

Here is a Regular Expression regex to count words, to count blank spaces, to count sentences, to count paragraphs in Java script.

Regular Expression to count words in Text.

text.match(/(\w+)/g).length;

Regular Expression to count paragraphs in text.

text.replace(/\n$/gm, '').split(/\n/).length;

Regular Expression to count Sentences in Text.

text.split(/[\.!\?]+\s/g).filter(Boolean).length;

Regular Expression to count spaces in Text.

text.split(" ").length - 1;

Use this Word Character Counter Online Tool. Another Tool is used to capitalize the first character of every word.

How to generate the series 1, 3, 6, 11, 18, 29, 42? up to N number in C Program

To generate series 1, 3, 6, 11, 18, 29, 42? in C Language it is important to understand the logic behind it. If we observe the difference between each number is like 2,3,7,11. So these are prime numbers. To generate such a series it is important that the difference between numbers should be an incremental prime number. So below program will generate a series up to user input by having prime number difference.

// Online C Program to generate Series up to Number
// 1, 3, 6, 11, 18, 29, 42?
#include <stdio.h>
int main() {
    //variable declaration
    int i,j,num,primeFlag,seriesNum,Scount;
    printf("\n how many numbers you need in this Series 1, 3, 6, 11, 18, 29, 42? to Print\n");
    scanf("%d",&num);
    //for loop to print numbers
    seriesNum =1; //This variable to store number from series.
    Scount=1; //variable to check count of numbers in series.
    printf("\t%d",seriesNum);
    do
    {
        primeFlag=0; //flag to check if number is prime or not.
        i= i+1;
        //loop to find prime number and add it to previous
        for(j=1;j<=i;j++)
        {
            if((i%j)==0)
            {
                primeFlag++;
            }
            else
            {
               //continue
            }
        }
        if (primeFlag == 2)
        {
//here if number is divisible by 1 and self number then only primeFlag will become 2
            seriesNum = seriesNum + i;
            printf(" %d,",seriesNum);
            Scount = Scount + 1;
        }
    }while (Scount < num);
    return 0;
}
how many numbers you need in this Series 1, 3, 6, 11, 18, 29, 42? to Print
22
1 3, 6, 11, 18, 29, 42, 59, 78, 101, 130, 161, 198, 239, 282, 329, 382, 441, 502, 569, 640, 713,

Simple C program to get square root of any number

Square Root is a factor of a number that, when multiplied by itself, gives the original number. This C Program will find squareroot of any number. C language provides math.h library file to perform various mathematical operations like square, power.

For example, if we take an example of 25 then the square root is 5.
5*5 = 25

// Program for math operations like power, square root.
#include <stdio.h>
#include <math.h>
int main() {
    // declaring variable in double
    double num,sr;
    printf("\nEnter number to find square root\t");
    scanf("%lf",&num);
    sr = sqrt(num);
    printf("\n\nSquare root of number %lf is %lf",num,sr);
    return 0;
}

Output

Enter number to find square root	625
Square root of number 625.000000 is 25.000000

HTML Marquee Tag simple Example for texts

To show scrollable texts or images within a web page we use marquee tag in html. Marquee tag has around ten attributes. Marquee can be implemented by using CSS. Below are examples of marquee tag with different attributes and their code.

Width Attribute: By providing width in percent we design marquee.

<marquee width="60%" >
This is a example of width attribute in marquee tag.
</marquee>
This is a example of width attribute in marquee tag.

Height Attribute: provides the height of a marquee

<marquee width="80%" height="80%">
This is a example of width attribute in marquee tag.
</marquee>
This is a example of width attribute in marquee tag.

Direction: Direction attribute provides the direction to scroll. values which can be used are left, right, up or down.

<marquee  direction="up" >Text going Up</marquee>
<marquee  direction="right">Text going Right</marquee>
<marquee direction="left" >Text going left</marquee>
<marquee  direction="right">Text going Down</marquee>
Text going Up Text going Right Text going left Text going Down

Scrolldelay: The Marquee scrolldelay attribute in HTML is used to set the interval between each scroll movement in milliseconds.

<marquee direction="up" scrolldelay=500>Text going Up</marquee>
<marquee direction="right" scrolldelay=200>Scroll Delay for 200</marquee>
<marquee direction="down" scrolldelay=1500>Scroll delay around 1500</marquee>
Text going Up Scroll Delay for 200 Scroll delay around 1500

scrollamount: Marquee speed can be changed using the “scrollmount” attribute. By Setting value 1 it scrolls slow and to increase the speed we can specify value more than 1

<marquee behavior="scroll" direction="right" scrollamount="1">Slow Scrolling</marquee>
<marquee behavior="scroll" direction="right" scrollamount="10">Little Fast Scrolling</marquee>
<marquee behavior="scroll" direction="right" scrollamount="25">Fast Scrolling</marquee>
<marquee behavior="scroll" direction="right" scrollamount="45">Very Fast Scrolling</marquee>
Slow Scrolling Little Fast Scrolling Fast Scrolling Very Fast Scrolling

Behavior: Three different values we can pass in behavior tag. Sliding, scrolling or alternate.

<marquee behavior="Slide" direction="right" scrollamount="10">Sliding Behavior</marquee>
<marquee behavior="scroll" direction="right" scrollamount="10">Scrolling Behavior</marquee>
<marquee behavior="alternate" direction="right" scrollamount="10">Alternate Behavior</marquee>
Sliding Behavior Scrolling Behavior Alternate Behavior

Loop: This category will decide number of times marquee is repeated. Valid values are number and “infinite”. Infinite is default value which means it runs endlessly.

<marquee scrollamount="5" loop="infinite">Infinite example for marquee</marquee>
<marquee scrollamount="5" loop="1">Loop through 1 time only for marquee</marquee>
Infinite example for marquee Loop through 1 time only for marquee

Alternative for marquee tag in html 5

There is no such alternative for marquee tag. But similar type effect we can achieve by using CSS, JavaScript.

Refer this for alternate of marquee in CSS.

For more information refer

C Program to print Math tables up to n numbers

This c program prints math tables up to n number. The program accepts user input. Using for loop we are printing the math table vertically.
To achieve math table output check the below c output and code.

Output

Up to which number you need to print table      10

        1       2       3       4       5       6       7       8       9       10
        2       4       6       8       10      12      14      16      18      20
        3       6       9       12      15      18      21      24      27      30
        4       8       12      16      20      24      28      32      36      40
        5       10      15      20      25      30      35      40      45      50
        6       12      18      24      30      36      42      48      54      60
        7       14      21      28      35      42      49      56      63      70
        8       16      24      32      40      48      56      64      72      80
        9       18      27      36      45      54      63      72      81      90
        10      20      30      40      50      60      70      80      90      100
//Program to display math table up to n number vertically
#include <stdio.h>
int main () {
  int tNo,i,j;
  printf("\n\tUp to which number you need to print table\t");
  scanf("%d",&tNo);
  for(i=1;i<=10;i++)
  {
      printf("\n");
      for (j=1;j<=tNo;j++)
      printf("\t%d",j*i);
    }
   return 0;
}