Posts

Showing posts from January, 2022

IFELSE IN PYTHON

Image
   ALL ABOUT IF-ELSE IN PYTHON THIS IS CODE OF IF-ELSE IN PYTHON YOU CAN COPY PASTE THIS CODE AND RUN  AND SEE THE OUTPUT IN THIS CODE I HAVE COVER ALMOST WORK RELATED   TO IF-ELSE. ''' Equal : a==b not equal: a!=b less than: a<b greater than :b>a greater than or equal to :a>=b less than equal to: a<=b ''' # if statement a = 33 b = 200 if b > a : print ( "b is geater than a" ) # # elif a = 33 b = 33 if b > a : print ( "b is greater than a" ) elif a == b : print ( "a and b are equal" ) # # ELSE a = 200 b = 33 if b > a : print ( "b is greater than a" ) elif a == b : print ( "a is greater than b" ) else : print ( "a is greater than b" ) # # SHORT HAND IF a = 300 b = 30 if a > b : print ( "a is greater than b " ) # # SHORT HAND IF ELSE a = 2 b = 330 print ( "A" ) if a > b else print ( "B" )

DICTIONARY IN PYTHON

Image
   ALL ABOUT DICTIONARY IN PYTHON THIS IS CODE OF DICTIONARY IN PYTHON YOU CAN COPY PASTE THIS CODE AND RUN  AND SEE THE OUTPUT IN THIS CODE I HAVE COVER ALMOST WORK RELATED   TO DICTIONARY. # Dictionaries are used to store data values in key:value pairs. # A dictionary is a collection which is ordered*, # changeable and does not allow duplicates. # Example of dictionary thisdict = { "brand" : "Ford" , "model" : "Mustang" , "year" : 1964 } print ( thisdict ) # Dictionary Items thisdict = { "brand" : "bmw" , "model" : "Mustang" , "year" : 1964 } print ( thisdict [ "brand" ]) # Duplicates Not Allowed thisdict = { "brand" : "Ford" , "model" : "Mustang" , "year" : 1964 , "year" : 2020 } print ( thisdict ) # Dictionary Length print ( len ( thisdict )) # Dictionary Items - Data Types t