Python Programming

Compare Variables

Python programming example for conditional statement and comparison of two variables

7/19/2021
0 views
compare-variable.pyPython
#!/usr/bin/evn python

# Assign values in two variables
a, b = 5, 2

# If codition
if a > b:
    # {} use to print value
	print("A {} is greater than B {}".format(a,b))

# Else codition
else:
    # {} use to print value
	print("A {} is less than B {}".format(a,b))


# Conditional statement
print("A" if a < b else "B")


#***** Output *****
# A 5 is less than B 2
# B
PythonPython codingcompare variablesIf else statement

Related Examples