Answers for "not equal in python 3"

3

comparison python 3

#!/usr/bin/python3

a = 21
b = 10

if ( a == b ):
   print ("Line 1 - a is equal to b")
else:
   print ("Line 1 - a is not equal to b")

if ( a != b ):
   print ("Line 2 - a is not equal to b")
else:
   print ("Line 2 - a is equal to b")

if ( a < b ):
   print ("Line 3 - a is less than b" )
else:
   print ("Line 3 - a is not less than b")

if ( a > b ):
   print ("Line 4 - a is greater than b")
else:
   print ("Line 4 - a is not greater than b")

a,b = b,a #values of a and b swapped. a becomes 10, b becomes 21

if ( a <= b ):
   print ("Line 5 - a is either less than or equal to  b")
else:
   print ("Line 5 - a is neither less than nor equal to  b")

if ( b >= a ):
   print ("Line 6 - b is either greater than  or equal to b")
else:
   print ("Line 6 - b is neither greater than  nor equal to b")
Posted by: Guest on March-05-2020
0

bracket balanced or not in python

def isBalanced(final_str):
    type_brackets = ['()', '{}', '[]']
    while any(x in final_str for x in type_brackets):
        for br in type_brackets:
            final_str = final_str.replace(br, '')
    return not final_str


string = "{[]{()}}"
print(string, "-", "Balanced"
      if isBalanced(string) else "Unbalanced")
Posted by: Guest on April-30-2020
3

python not equal to

1 != 2  # The 'not equal to' symbol is !=
Posted by: Guest on March-08-2020
0

pyton not equal

(a != b) #testing for not equel
Posted by: Guest on November-09-2020

Python Answers by Framework

Browse Popular Code Answers by Language