Posts

Conditional Expression

  #Example 03_07_2019 a = 35 if ( a > 5 ):     print ( "the value of a is greater than 5 " ) elif ( a > 9 ) : print ( "the value of a is greater than 9 " ) elif ( a > 15 ) : print ( "the value of a is greater than 15 " ) elif ( a > 25 ) :     print ( "the value of a is greater than 25 " ) else :     print ( " The value is not grater than 5 and 9" ) # in this ladder only one statement will execute. a = 3                   # there is no semicolon in Python, so it takes space automatically , it makes different from other language if ( a > 5 ):                 ### here indent will be a "Tab" or "4 space _ _ _ _"     print ( "the value of a is greater than 5 " ) elif ( a > 9 ) :     print ( "the value of a is greater than 9 " ) elif ( a > 15 ) :       print ( "the value of a is greater than 15 " ) elif ( a > 25 ) :     print ( "the value of a is greater th

SETS & DICTIONARY

  # Sets in python Date 01_07_2019 b = {}   # it is an empty set but it is not empty set is an empty Dictionary print ( type (b))   #class  <'dict'> a = { 1 ,   2 ,   3 ,   4 ,   5 } print ( type (a))   # <Class 'set'> print (a)     a = { 1 ,   2 ,   3 ,   4 ,   5 , 1 } print (a)   # it ignore one 1 bc, set definition "Set is a collection of non repetitive elements" # if we want to write an empty set use {} ######################################### # Empty set a = {} print ( a ) print ( type ( a )) # it is a dictionary type not a set # an empty set can create using syntex c = set () print ( type ( c )) # to add some thing on set c we use .add function c . add ( 3 ), #c.add(9 ,5, 7) we cant add more then one element like this c . add ( 5 ), c . add ( 7 ), print ( c ) ############################################## # set methods c = set () print ( type ( c )) # to add something on set 'c' we use .add function c . add ( 3 ), #c.add

Game_01_Snake_Water_Gun_or_Rock_Paper_Scissor

  #snake water gun, or rock paper scissor import random def gameWin ( comp , you ):     if comp == you : # if two values are equal declear a tie         return None     #check for all possibilities when computer chose "s"     elif comp == 's' :         if you == 'w' :             return         elif you == 'g' :             return True     #check for all possibilities when computer chose "w"     elif comp == 'w' :         if you == 'g' :             return False         elif you == 's' :             return True     #check for all possibilities when computer chose "g"     elif comp == 'g' :         if you == 's' :             return False         elif you == 'w' :             return True Game_Snake_Water_Gun_or_Rock_Paper_Scissor # If you want to change "S" 'W' 'G' to 'R", P, S you can print ( "comp Turn: Snake(s) Water