Saturday, 6 January 2018

Python Membership Operators

#!/usr/bin/python3
a = int(input("Enter value of a"))
b = int(input("Enter value of b"))
list = [1, 2, 3, 4, 5 ]
if ( a in list ):
  print ("Line 1 - a is available in the given list")
else:
  print ("Line 1 - a is not available in the given list")
if ( b not in list ):
  print ("Line 2 - b is not available in the given list")
else:
  print ("Line 2 - b is available in the given list")
c=b/a
if ( c in list ):
  print ("Line 3 - a is available in the given list")
else:
  print ("Line 3 - a is not available in the given list")


No comments:

Post a Comment

Lists

Python  Lists Python Collections (Arrays) There are four collection data types in the Python programming language: List  is a ...