• Logic expressions in python
    And operator “And” operator is binary, so it takes 2 arguments. The “and” operator has a lower priority than comparison operators. If both are true it will return true else it will return false: a = True b = False c = True d = False print( b and d ) # False print( a… Continue reading Logic expressions in python
  • The continue statement in Python
    The break statement allows you to exit a for loop, but what to do if you don’t want to exit the loop and all you want to do is to skip it? Python allows you to do this with statement keyword Let’s start with a basic loop, counting to 10 from 0. for i in… Continue reading The continue statement in Python
  • The break statement in Python
    So you learned how to work with for loops and while loops, but what to do when you want to exit a loop? Let’s start with this for loop code: for nr in range(11): print(nr) What to do if you want to exit the for loop when nr. is equal to 5 ? In python,… Continue reading The break statement in Python
  • Python For Loop
    Just like while loop, for loop in python is allow you to avoid having repetitive code. As you will see this will allow you to iterate through lists, dicts and objects. In this tutorial I’m not going to talk about lists, dicts and objects Let’s start from while loop example # define a variable that… Continue reading Python For Loop
  • Python While Loop
    In python you can use a while loop to auto generate code and avoid having repetitive code. Here is the default While Loop syntax: while condition is true: # do something # this is the body of the while loop else: # else block that will always be executed Keep in mind that while is… Continue reading Python While Loop
  • Python Comparison Operators
    Equality Comparison Operator: == The equality operator compares the argument from the left with the argument from the right. If the comparison is true it will return true else it will return false This is a binary operator – means that it takes 2 arguments “a == b” where “a” and “b” are arguments and… Continue reading Python Comparison Operators
  • If statement in Python
    The if condition will execute the body of the statement if the condition is true. Check out the operators and booleans to understand better this subject. If condition: # the body of the if statement Example: a = 3 b = 4 if b > a: print(“b > a”) Please note that :– after condition,… Continue reading If statement in Python
  • Add Python To Path In Windows
    In order to add python to path in windows follow the next steps: Right click on start menu Click System Click Advanced system settings from the right sidebar Click Environment Variables In System variables click path and click edit Click New and add the complete path to python.exe Python can now be used directly from… Continue reading Add Python To Path In Windows
  • Type casting in Python
    In python you can do operations usually with same types. If you try to add a string with a number you will get a type error nr1 = “2” nr2 = 2.3 print(nr1 + nr2) This will result in TypeError: can only concatenate str (not “float”) to str In order to solve this issue you… Continue reading Type casting in Python