[
  {
    "path": "\"if\" statements/main.py",
    "content": "##\r\n# \"If\" Statements Lecture\r\n##\r\n\r\n# -*- coding: utf-8 -*-\r\n\r\n'''\r\nSyntax:\r\nif condition:\r\n    Action\r\n'''\r\nclick = False                 #set variable click to False\r\nLike = 0                      #initialize Like equal to 0\r\n\r\nif click == True:             #Check if click is True\r\n    Like = Like + 1           #Increment Like by 1\r\n    click = False             #set click to False\r\n\r\nprint(Like)                  #print the value\r\nTemperature = 20             #set a variable Temperature to 20\r\nThermo = 15                  #set a variable Thermo to 15\r\nif Temperature < 15:         #Check if Temperature is less than 15\r\n    Thermo = Thermo + 5      #if yes increment variable Thermo by 5\r\n\r\nprint(Thermo)               #print the value Thermo\r\n\r\nTemperature = 14             #set variable Temperature to 14\r\nThermo = 15                  #set variable Thermo to 15\r\nif Temperature < 15:         #Check if Temperature is less than 15\r\n    Thermo = Thermo + 5      #if True increment Thermo by 5\r\n\r\nprint(Thermo)               #print the value of Thermo\r\n\r\nTemperature = 15            #set variable Temperature to 15\r\nThermo = 15                 #set variable Thermo to 15\r\nif Temperature <= 15:       #Check if Temperature is less than or equal to 15\r\n    Thermo = Thermo + 5     #if True increment Thermo by 5\r\n\r\nprint(Thermo)               #print the value of Thermo\r\n\r\nif Temperature > 20:        #Check if Temperature is greater than 20\r\n    Thermo = Thermo - 3     #if True decrement Thermo by 3\r\n\r\nprint(Thermo)               #print the value of Thermo\r\nTemperature = 20           #set the value of Temperature to 20\r\nThermo = 15                #set Thermo equals to 15\r\nif Temperature <= 15:      #Check if Temperature is less than or equal to 15\r\n    Thermo = Thermo + 5    #if True increment Thermo by 5\r\n\r\nprint(Thermo)              #print value of Thermo\r\n\r\nif Temperature >= 20:       #Check if Temperature is greater than or equal to 20\r\n    Thermo = Thermo - 3     #if True decrement Thermo by 3\r\n\r\nprint(Thermo)              #print value of Thermo\r\n\r\n\r\nTime = \"Day\"               #set variable Time to Day\r\nSleepy = False             #set Sleepy equals to False\r\nPajamas = \"Off\"            #initialize Pajamas equal to Off\r\n'''\r\nIf Time equals to Night and Sleep is True then set Pajamas equal to On\r\n'''\r\nif Time == \"Night\" and Sleepy == True:   #Check two condition and are ANDed\r\n    Pajamas = \"On\"                       #if both condition are True then set Pajamas = On\r\nprint(Pajamas)                            #print the value of Pajamas\r\n\r\nPajamas = \"Off\"             #initialize Pajamas equal to Off\r\nif Time == \"Night\" or Sleepy == True:    #Check two condition and are ORed\r\n    Pajamas = \"On\"                       #if anyone of the condition is True set Pajamas equal to On\r\nprint(Pajamas)                           #print the value of Pajamas\r\n\r\nTime = 'Night'                #set variable Time to Night\r\nSleepy = 'True'               #set variable Sleep equals to True\r\nPajamas = \"Off\"               #initialize Pajamas equal to Off\r\nif Time == \"Night\" or Sleepy == False: #Check two condition and are ORed\r\n    Pajamas = \"On\"              #if anyone of the condition is True set Pajamas equal to On\r\nprint(Pajamas)                #print the value of Pajamas\r\n\r\n'''\r\nintialize Time equals to Day, Sleepy equals to False, Pajamas to off and InBed equals to True\r\nCheck if Time equals to Night, set Pajamas equals to On, else if Time equals to Morning is True\r\nset Pajamas equals to On and then print its value\r\n'''\r\nTime = 'Day'\r\nSleepy = 'False'\r\nPajamas = \"off\"\r\nInBed = True\r\nif Time == \"Night\":\r\n    Pajamas = \"On\"\r\nelif Time == \"Morning\":\r\n    Pajamas = \"On\"\r\nprint(Pajamas)\r\n\r\nTime = 'Morning'              #set Time equals to Morning\r\nSleepy = 'False'              #Set Sleepy to False\r\nPajamas = \"Unknown\"           #set Pajamas to Unknown\r\nInBed = True                  #set InBed variable to True\r\nprint(Pajamas)                #print value of Pajamas\r\nif Time == \"Night\":           #if Time is equal to Night\r\n    Pajamas = \"On\"            #set pajamas to On\r\nelif Time == \"Morning\":       #else if Time equal to Morning\r\n    Pajamas = \"On\"            #set pajamas to On\r\nelse:                          #otherwise if any of the above two statement are not true\r\n    Pajamas = \"Off\"           #set Pajamas Off\r\nprint(Pajamas)                #print the value of Pajamas\r\n"
  },
  {
    "path": ".gitignore",
    "content": "# OS generated files\n.DS_Store\n.DS_Store?\n._*\n.Spotlight-V100\n.Trashes\nIcon?\nehthumbs.db\nThumbs.db\n"
  },
  {
    "path": "README.md",
    "content": "# Python is Easy\n\n> Code snippets for the \"Python is Easy\" course, available at Pirple.com/python\n\n\n## About this Repository\n\nThese code snippets are for following along with the lectures, and running the code yourself.\n\nEverything is organized by section. Click on a section to find the lecture code you're looking for.\n\n\n## Never used Git or Github before?\n\nNo worries. You can learn how to use it in just a few minutes. Start by watching these videos:\n\n\n#### Git\n[https://git-scm.com/videos](https://git-scm.com/videos)\n\n#### Github\n[https://www.youtube.com/playlist?list=PLg7s6cbtAD15G8lNyoaYDuKZSKyJrgwB-](https://www.youtube.com/playlist?list=PLg7s6cbtAD15G8lNyoaYDuKZSKyJrgwB-)\n\nAfter that, you'll know enough to grab this code yourself and \"clone\" it down to your machine.\n"
  },
  {
    "path": "classes/Class-Inheritance.py",
    "content": "##\r\n# Class Inheritance Lecture\r\n##\r\n\r\n# -*- coding: utf-8 -*-\r\n\r\nclass Team:        \r\n    #constructor passes two variables Name and Origin. The\r\n    #default value of variable Name is \"Name\" and that of variable Origin is \"Origin\".\r\n    #If no values are passed through a constructor its default values are Name and Origin.\r\n    def __init__(self, Name = \"Name\", Origin = \"Origin\"):             #constructor\r\n        self.TeamName = Name                                          #member assignment\r\n        self.TeamOrigin = Origin                                      #member assignment\r\n\r\n    def DefineTeamName(self, Name):                                  #class method\r\n        self.TeamName = Name\r\n\r\n    def DefineTeamOrigin(self, Origin):                              #class method\r\n        self.TeamOrigin = Origin\r\n\r\n#class InheritanceClassName(ParentClass):\r\n#    def __init__(self, Input1, Input2):\r\n#        ParentClass.__init__(self)\r\n#        self.Attribute1 = Input1\r\n#        self.Attribute2 = Input2\r\n#        self.Attribute3 = 0\r\n#\r\n#    def AnotherMethod(self):\r\n#        Action(s)\r\n\r\n'''\r\nClass Player is derived from the base class or parent  class Team\r\n'''\r\nclass Player(Team):\r\n    def __init__(self):             #constructor\r\n        Team.__init__(self)\r\n        '''\r\n        The __init__ method of our Team class explicitly invokes the __init__method of the Player class.\r\n        '''\r\n        self.PlayerName = \"None\"    #member variable assigned to None\r\n        self.PlayerPoints = 0       #member variable assigned to 0\r\n\r\n    '''\r\n    Methods: ScoredPoints and setName\r\n    ScoredPoints increments the PlayerPoints by 1.\r\n    setName sets the name of Player\r\n    '''\r\n    def ScoredPoint(self):\r\n        self.PlayerPoints += 1          #increments Playerpoints by 1\r\n\r\n    def setName(self, name):\r\n        self.PlayerName = name         #assigned name to Player\r\n\r\n\r\nPlayer1 = Player()                    #create an instance of a class Player\r\nprint(Player1.PlayerName)             #print the value of member variable PlayerName\r\nprint(Player1.PlayerPoints)           #print the value of member variable PlayerPoints\r\nPlayer1.DefineTeamName(\"Sharks\")      #call methods DefineTeamName\r\nprint(Player1.TeamName)               #print the value of base class from derived class\r\nprint(Player1.TeamOrigin)             #print the value of member TeamOrigin of base class from derived class\r\n\r\n\r\nclass Player(Team):\r\n    '''\r\n    4 variables are passed into Contructor\r\n    '''\r\n    def __init__(self, PlayerName, PPoints, TeamName, TeamOrigin):\r\n        Team.__init__(self, TeamName, TeamOrigin)\r\n        self.PlayerName = PlayerName\r\n        self.PlayerPoints = PPoints\r\n\r\n    '''\r\n    Methods: ScoredPoints and setName\r\n    ScoredPoints increments the PlayerPoints by 1.\r\n    setName sets the name of Player\r\n    '''\r\n    def ScoredPoint(self):\r\n        self.PlayerPoints += 1\r\n\r\n    def setName(self, name):\r\n        self.PlayerName = name\r\n\r\n    '''\r\n    Override to print a readable string presentation of your object\r\n    '''\r\n    def __str__(self):\r\n        return self.PlayerName + \" has scored: \" + str(self.PlayerPoints) + \" Points\"\r\n\r\nPlayer1 = Player(\"Sid\", 0, \"Sharks\", \"Chicago\")      #create an instance of a class Player\r\nprint(Player1.PlayerName)             #print the value of member variable PlayerName\r\nprint(Player1.PlayerPoints)           #print the value of member variable PlayerPoints\r\n#Player1.DefineTeamName(\"Sharks\")\r\nprint(Player1.TeamName)               #print the value of base class from derived class\r\nprint(Player1.TeamOrigin)             #print the value of member TeamOrigin of base class from derived class\r\nPlayer1.ScoredPoint()                 #call method ScoredPoint\r\nprint(Player1.PlayerPoints)           #access member PlayerPoints from outside the class and print it\r\nPlayer1.setName(\"Lee\")                #call method setName\r\nprint(Player1.PlayerName)             #print the value of member variable PlayerName\r\nprint(Player1)                        #print the string message.\r\n"
  },
  {
    "path": "classes/Introduction-to-Classes.py",
    "content": "##\r\n# Introduction to Classes Lecture\r\n##\r\n\r\n# -*- coding: utf-8 -*-\r\n\r\n\r\n\"\"\"\r\nclass is defined by a keyword class\r\n\r\nClassname Team in defined\r\n\"\"\"\r\n\r\nclass Team:\r\n    def __init__(self):                          #constructor with no arguments\r\n        self.TeamName = 'Name'                   #self represents the instance of the class and the variables of a class can be accessed using self\r\n        self.TeamOrigin = 'Origin'               #set an attribute 'TeamOrigin to \"Origin\"\r\n\r\n    '''\r\n    DefinieTeamName and DefineTeamOrigin represents the methods of a class. Each method takes one\r\n    arguments\r\n    '''\r\n    def DefineTeamName(self, Name):\r\n        self.TeamName = Name\r\n\r\n    def DefineTeamOrigin(self, Origin):\r\n        self.TeamOrigin = Origin\r\n\r\nTeam1 = Team()                                  #create an object of a class Team\r\n'''\r\nMethods and Member of a class can be accessed using a dot operator.\r\nobject.membername or object.methodname\r\n'''\r\nprint(Team1.TeamName)                           #Access the member of a class using dot operator and print the value of a member\r\nTeam1.DefineTeamName(\"Tigers\")                  #call methods of a class using a dot operator\r\nprint(Team1.TeamName)                           #print the value of a member TeamName\r\nprint(Team1.TeamOrigin)                         #print the value of a member TeamOrigin\r\nTeam1.DefineTeamOrigin(\"Chicago\")               #call method DefineTeamOrigin of a class Team\r\nprint(Team1.TeamOrigin)                         #print value of a member TeamOrigin\r\n\r\n'''\r\nAgain Define a class Team\r\n'''\r\nclass Team:\r\n    #constructor passes two variables Name and Origin. The\r\n    #default value of variable Name is \"Name\" and that of variable Origin is \"Origin\".\r\n    #If no values are passed through a constructor its default values are Name and Origin.\r\n    def __init__(self, Name = \"Name\", Origin = \"Origin\"):             #constructor\r\n        self.TeamName = Name                                          #member assignment\r\n        self.TeamOrigin = Origin                                      #member assignment\r\n\r\n    def DefineTeamName(self, Name):                                  #class method\r\n        self.TeamName = Name\r\n\r\n    def DefineTeamOrigin(self, Origin):                              #class method\r\n        self.TeamOrigin = Origin\r\n\r\nTeam1 = Team(\"Tigers\", \"Chicago\")                                   #creating an object of a class Team.\r\nTeam2 = Team(\"Hawks\", \"Newyork\")                                    #creating an instance of a class Team and passing two values.\r\nTeam3 = Team()                                                      #creating an object of a class with no values passed.\r\nprint(Team1.TeamName)                                               #member can be accessed from outside the class using dot operator\r\nTeam1.DefineTeamName(\"Tigers\")                                      #call methods from outside the class\r\nprint(Team1.TeamName)                                               #print the value of member TeamName\r\nprint(Team1.TeamOrigin)                                             #print the value of member TeamOrigin\r\nTeam1.DefineTeamOrigin(\"Chicago\")                                  #call method DefineTeamOrigin\r\nprint(Team1.TeamOrigin)                                             #print the value of member\r\nprint(Team2.TeamName)                                              #print the value of member TeamName of object Team2\r\nprint(Team2.TeamOrigin)                                           #print the value of member TeamOrigin of object Team2\r\nprint(Team3.TeamName)                                               #print the value of member TeamName of object Team3\r\nprint(Team3.TeamOrigin)                                           #print the value of member TeamOrigin of object Team3\r\n"
  },
  {
    "path": "classes/Pets-Part-A.py",
    "content": "##\n# Pets, Part A Lecture\n##\n\n# -*- coding: utf-8 -*-\n\n# Define a class\nclass Pet:\n\n  # Define a function which refers to the class in order to initiliaze the attributes of the class\n  def __init__(self,n,a,h,p):\n    # Define an attribute and assign the value of the n argument\n    self.name = n\n    # Define an attribute and assign the value of the a argument\n    self.age = a\n    # Define an attribute and assign the value of the h argument\n    self.hunger = h\n    # Define an attribute and assign the value of the p argument\n    self.playful = p\n\n# Define a class\nclass Pet:\n\n  # Define a function which refers to the class in order to initiliaze the attributes of the class\n  def __init__(self,name,a,h,p):\n    # Define an attribute and assign the value of the name argument\n    self.name = name\n    # Define an attribute and assign the value of the a argument\n    self.age = a\n    # Define an attribute and assign the value of the h argument\n    self.hunger = h\n    # Define an attribute and assign the value of the p argument\n    self.playful = p\n\n  # getters\n  # Define a function to return an attribute of the class\n  def getName(self):\n    # The function will return the name attribute\n    return self.name\n\n  # setters\n  # Define a function which assigns a value to an attribute of the class\n  def setName(self,name):\n    self.name = name\n\n# Define a class\nclass Pet:\n\n  # Define a function which refers to the class in order to initiliaze the attributes of the class\n  def __init__(self,name,a,h,p):\n    # Define an attribute and assign the value of the name argument\n    self.name = name\n    # Define an attribute and assign the value of the a argument\n    self.age = a\n    # Define an attribute and assign the value of the h argument\n    self.hunger = h\n    # Define an attribute and assign the value of the p argument\n    self.playful = p\n\n  # getters\n  # Define a function to return an attribute of the class\n  def getName(self):\n    # The function will return the name attribute\n    return self.name\n\n  # setters\n  # Define a function which assigns a value to an attribute of the class\n  def setName(self,x):\n    self.name = x\n\n\n# Define a class\nclass Pet:\n\n  # Define a function which refers to the class in order to initiliaze the attributes of the class\n  def __init__(self,name,a,h,p):\n    # Define an attribute and assign the value of the name argument\n    self.name = name\n    # Define an attribute and assign the value of the a argument\n    self.age = a\n    # Define an attribute and assign the value of the h argument\n    self.hunger = h\n    # Define an attribute and assign the value of the p argument\n    self.playful = p\n\n  # getters\n  # Define a function to return an attribute of the class\n  def getName(self):\n    # The function will return the name attribute\n    return self.name\n\n  # Define a function to return an attribute of the class\n  def getAge(self):\n    # The function will return the age attribute\n    return self.age\n\n  # Define a function to return an attribute of the class\n  def getHunger(self):\n    # The function will return the hunger attribute\n    return self.hunger\n\n  # Define a function to return an attribute of the class\n  def getPlayful(self):\n    # The function will return the playful attribute\n    return self.playful\n\n  # setters\n  # Define a function which assigns a value to an attribute of the class\n  def setName(self,xname):\n    self.name = xname\n\n  # Define a function which assigns a value to an attribute of the class\n  def setAge(self,Age):\n    self.age = Age\n\n  # Define a function which assigns a value to an attribute of the class\n  def setHunger(self,hunger):\n    self.hunger = hunger\n\n  # Define a function which assigns a value to an attribute of the class\n  def setPlayful(self,play):\n    self.playful = play\n\n# Create an instance of the Pet class and assign values to the attributes\nPet1 = Pet(\"Jim\",3,False,True)\n\n# Print the value returned by the getName() function of the Pet1 instance\n# This will print \"Jim\"\nprint(Pet1.getName())\n#Print the value returned by the getPlayful() function of the Pet1 instance\n# This will print True\nprint(Pet1.getPlayful())\n\n# Call the setName(xname) function of the Pet1 instance\n# This will assign a new value to the name attribute of the Pet1 instance\nPet1.setName(\"Snowball\")\n# Print the value returned by the getName() function of the Pet1 instance\n# This will print \"Snowball\"\nprint(Pet1.getName())\n\n# Access and print the name attribute of the Pet1 instance\n# This will print \"Snowball\"\nprint(Pet1.name)\n\n# Assign the value \"Jim\" to the name attribute of the Pet1 instance\nPet1.name = \"Jim\"\n# Access and print the name attribute of the Pet1 instance\n# This will print \"Jim\"\nprint(Pet1.name)\n"
  },
  {
    "path": "classes/Pets-Part-B.py",
    "content": "##\n# Pets, Part B Lecture\n##\n\n# -*- coding: utf-8 -*-\n\n\n# Define a class\nclass Pet:\n\n  # Define a function which refers to the class in order to initiliaze the attributes of the class\n  def __init__(self,name,a,h,p):\n    # Define an attribute and assign the value of the name argument\n    self.name = name\n    # Define an attribute and assign the value of the a argument\n    self.age = a\n    # Define an attribute and assign the value of the h argument\n    self.hunger = h\n    # Define an attribute and assign the value of the p argument\n    self.playful = p\n\n  # getters\n  # Define a function to return an attribute of the class\n  def getName(self):\n    # The function will return the name attribute\n    return self.name\n\n  # Define a function to return an attribute of the class\n  def getAge(self):\n    # The function will return the age attribute\n    return self.age\n\n  # Define a function to return an attribute of the class\n  def getHunger(self):\n    # The function will return the hunger attribute\n    return self.hunger\n\n  # Define a function to return an attribute of the class\n  def getPlayful(self):\n    # The function will return the playful attribute\n    return self.playful\n\n  # setters\n  # Define a function which assigns a value to an attribute of the class\n  def setName(self,xname):\n    self.name = xname\n\n  # Define a function which assigns a value to an attribute of the class\n  def setAge(self,Age):\n    self.age = Age\n\n  # Define a function which assigns a value to an attribute of the class\n  def setHunger(self,hunger):\n    self.hunger = hunger\n\n  # Define a function which assigns a value to an attribute of the class\n  def setPlayful(self,play):\n    self.playful = play\n\n\n# The class is commented becuse two errors exist. One is in line 65 where the self argument is missing\n# and the second error is in line 81 where the code should be self.FavoriteToy\n# Define a class which inherits the Pet class\n#class Dog(Pet):\n#\n#  # Define a function which refers to the class in order to initiliaze the attributes of the class\n#  def __init__(self,name,age,hunger,playful,breed,FavoriteToy):\n#    # Call the initializer of the parent class with the proper parameters\n#    # Error - the self argument is missing\n#    Pet.__init__(name,age,hunger,playful)\n#\n#    # The following line will return an error if uncommented\n#    #self.__init__(name,age,hunger,playful)\n#\n#    # Define an attribute and assign the value \"None\"\n#   self.breed = breed\n#    self.FavoriteToy = FavoriteToy\n#\n#  # Define unction which refers to the class\n#  def wantsToPlay(self):\n#\n#    # IF condition is True\n#    if self.playful == True:\n#      # Define the string which the function returns\n#      # Error - It should be self.FavoriteToy\n#      return(\"Dog wants to play with \" + FavoriteToy)\n#\n#    # ELSE condition\n#    else:\n#      # Define the string which the function returns\n#      return(\"Dog doesn't want to play\")\n#\n# Create an instance of the Dog class and assign values to the attributes\n#huskyDog = Dog(\"Snowball\",5,False,True,\"Husky\",\"Stick\")\n#\n# Assign to a variable the result returned by the wantsToPlay() function of the huskyDog instance\n#Play = huskyDog.wantsToPlay()\n#\n# Print the value of the Play variable\n# This will print \"Dog wants to play with Stick\"\n#print(Play)\n\n\n\n# Define a class which inherits the Pet class\nclass Dog(Pet):\n\n  # Define a function which refers to the class in order to initiliaze the attributes of the class\n  def __init__(self,name,age,hunger,playful,breed,FavoriteToy):\n    # Call the initializer of the parent class with the proper parameters\n    Pet.__init__(self,name,age,hunger,playful)\n\n    # The following line will return an error if uncommented\n    #self.__init__(name,age,hunger,playful)\n\n    # Define an attribute and assign the value \"None\"\n    self.breed = breed\n    self.FavoriteToy = FavoriteToy\n\n  # Define unction which refers to the class\n  def wantsToPlay(self):\n\n    # IF condition is True\n    if self.playful == True:\n      # Define the string which the function returns\n      return(\"Dog wants to play with \" + self.FavoriteToy)\n\n    # ELSE condition\n    else:\n      # Define the string which the function returns\n      return(\"Dog doesn't want to play\")\n\n# Create an instance of the Dog class and assign values to the attributes\nhuskyDog = Dog(\"Snowball\",5,False,True,\"Husky\",\"Stick\")\n\n# Assign to a variable the result returned by the wantsToPlay() function of the huskyDog instance\nPlay = huskyDog.wantsToPlay()\n\n# Print the value of the Play variable\n# This will print \"Dog wants to play with Stick\"\nprint(Play)\n\n# Assign the value False to the playful attribute of the huskyDog instance\nhuskyDog.playful = False\n\n# Assign to a variable the result returned by the wantsToPlay() function of the huskyDog instance\nPlay = huskyDog.wantsToPlay()\n\n# Print the value of the Play variable\n# This will print \"Dog doesn't want to play\"\nprint(Play)\n"
  },
  {
    "path": "classes/Pets-Part-C.py",
    "content": "##\n# Pets, Part C Lecture\n##\n\n# -*- coding: utf-8 -*-\n\n\n# Define a class\nclass Pet:\n\n  # Define a function which refers to the class in order to initiliaze the attributes of the class\n  def __init__(self,name,a,h,p):\n    # Define an attribute and assign the value of the name argument\n    self.name = name\n    # Define an attribute and assign the value of the a argument\n    self.age = a\n    # Define an attribute and assign the value of the h argument\n    self.hunger = h\n    # Define an attribute and assign the value of the p argument\n    self.playful = p\n\n  # getters\n  # Define a function to return an attribute of the class\n  def getName(self):\n    # The function will return the name attribute\n    return self.name\n\n  # Define a function to return an attribute of the class\n  def getAge(self):\n    # The function will return the age attribute\n    return self.age\n\n  # Define a function to return an attribute of the class\n  def getHunger(self):\n    # The function will return the hunger attribute\n    return self.hunger\n\n  # Define a function to return an attribute of the class\n  def getPlayful(self):\n    # The function will return the playful attribute\n    return self.playful\n\n  # setters\n  # Define a function which assigns a value to an attribute of the class\n  def setName(self,xname):\n    self.name = xname\n\n  # Define a function which assigns a value to an attribute of the class\n  def setAge(self,Age):\n    self.age = Age\n\n  # Define a function which assigns a value to an attribute of the class\n  def setHunger(self,hunger):\n    self.hunger = hunger\n\n  # Define a function which assigns a value to an attribute of the class\n  def setPlayful(self,play):\n    self.playful = play\n\n  # Define a function which refers to the class and returns a string\n  def __str__(self):\n     # Define the string which the function returns\n    return (self.name + \" is \" +str(self.age) + \" years old\")\n\n\n# The class is commented becuse two errors exist. One is in line 65 where the self argument is missing\n# and the second error is in line 81 where the code should be self.FavoriteToy\n# Define a class which inherits the Pet class\n#class Dog(Pet):\n#\n#  # Define a function which refers to the class in order to initiliaze the attributes of the class\n#  def __init__(self,name,age,hunger,playful,breed,FavoriteToy):\n#    # Call the initializer of the parent class with the proper parameters\n#    # Error - the self argument is missing\n#    Pet.__init__(name,age,hunger,playful)\n#\n#    # The following line will return an error if uncommented\n#    #self.__init__(name,age,hunger,playful)\n#\n#    # Define an attribute and assign the value \"None\"\n#   self.breed = breed\n#    self.FavoriteToy = FavoriteToy\n#\n#  # Define unction which refers to the class\n#  def wantsToPlay(self):\n#\n#    # IF condition is True\n#    if self.playful == True:\n#      # Define the string which the function returns\n#      # Error - It should be self.FavoriteToy\n#      return(\"Dog wants to play with \" + FavoriteToy)\n#\n#    # ELSE condition\n#    else:\n#      # Define the string which the function returns\n#      return(\"Dog doesn't want to play\")\n#\n# Create an instance of the Dog class and assign values to the attributes\n#huskyDog = Dog(\"Snowball\",5,False,True,\"Husky\",\"Stick\")\n#\n# Assign to a variable the result returned by the wantsToPlay() function of the huskyDog instance\n#Play = huskyDog.wantsToPlay()\n#\n# Print the value of the Play variable\n# This will print \"Dog wants to play with Stick\"\n#print(Play)\n\n\n\n# Define a class which inherits the Pet class\nclass Dog(Pet):\n\n  # Define a function which refers to the class in order to initiliaze the attributes of the class\n  def __init__(self,name,age,hunger,playful,breed,FavoriteToy):\n    # Call the initializer of the parent class with the proper parameters\n    Pet.__init__(self,name,age,hunger,playful)\n\n    # The following line will return an error if uncommented\n    #self.__init__(name,age,hunger,playful)\n\n    # Define an attribute and assign the value of the breed argument\n    self.breed = breed\n    # Define an attribute and assign the value of the FavoriteToy argument\n    self.FavoriteToy = FavoriteToy\n\n  # Define unction which refers to the class\n  def wantsToPlay(self):\n    # IF condition is True\n    if self.playful == True:\n      # Define the string which the function returns\n      return(\"Dog wants to play with \" + self.FavoriteToy)\n    # ELSE condition\n    else:\n      # Define the string which the function returns\n      return(\"Dog doesn't want to play\")\n\n\n# Define a class which inherits the Pet class\nclass Cat(Pet):\n\n  # Define a function which refers to the class in order to initiliaze the attributes of the class\n  def __init__(self,name,age,hunger,playful,place):\n\n    # Call the initializer of the parent class with the proper parameters\n    Pet.__init__(self,name,age,hunger,playful)\n\n    # Define an attribute and assign the value of the place argument\n    self.FavoritePlaceToSit = place\n\n  # Define unction which refers to the class\n  def wantsToSit(self):\n    # IF condition is True\n    if self.playful == False:\n      # Define the string which the function returns\n      # The following line will produce an error if uncommented due to the self.place part of the code\n      #print(\"The cat wants to sit in\" ,self.place)\n      print(\"The cat wants to sit in\" ,self.FavoritePlaceToSit)\n    # ELSE condition\n    else:\n      # Define the string which the function returns\n      print(\"The cat wants to play\")\n\n  # Define a function which refers to the class and returns a string\n  def __str__(self):\n    # Define the string which the function returns\n    return (self.name + \" likes to sit in \" + self.FavoritePlaceToSit)\n\n\n# Create an instance of the Dog class and assign values to the attributes\nhuskyDog = Dog(\"Snowball\",5,False,True,\"Husky\",\"Stick\")\n\n# Assign to a variable the result returned by the wantsToPlay() function of the huskyDog instance\nPlay = huskyDog.wantsToPlay()\n\n# Print the value of the Play variable\n# This will print \"Dog wants to play with Stick\"\nprint(Play)\n\n# Assign the value False to the playful attribute of the huskyDog instance\nhuskyDog.playful = False\n\n# Assign to a variable the result returned by the wantsToPlay() function of the huskyDog instance\nPlay = huskyDog.wantsToPlay()\n\n# Print the value of the Play variable\n# This will print \"Dog doesn't want to play\"\nprint(Play)\n\n# Create an instance of the Cat class and assign values to the attributes\ntypicalCat = Cat(\"Fluffy\",3,False,False,\"the sun ray\")\n\n# Call the wantsToSit() function of the typicalCat instance\n# This will print \"The cat wants to sit in the sun ray\"\ntypicalCat.wantsToSit()\n\n# This will print the returned string from the __str__ function of the typicalCat instance\n# This will print \"Fluffy likes to sit in the sun ray\"\nprint(typicalCat)\n# The __str__ function is not defined in the Dog function so it will return general inforamtion on the class\n# This will print <class '__main__.Dog'>\nprint(Dog)\n"
  },
  {
    "path": "classes/Pets-Part-D.py",
    "content": "##\n# Pets, Part D Lecture\n##\n\n# -*- coding: utf-8 -*-\n\n\n# Define a class\nclass Pet:\n\n  # Define a function which refers to the class in order to initiliaze the attributes of the class\n  def __init__(self,name,a,h,p):\n    # Define an attribute and assign the value of the name argument\n    self.name = name\n    # Define an attribute and assign the value of the a argument\n    self.age = a\n    # Define an attribute and assign the value of the h argument\n    self.hunger = h\n    # Define an attribute and assign the value of the p argument\n    self.playful = p\n\n  # getters\n  # Define a function to return an attribute of the class\n  def getName(self):\n    # The function will return the name attribute\n    return self.name\n\n  # Define a function to return an attribute of the class\n  def getAge(self):\n    # The function will return the age attribute\n    return self.age\n\n  # Define a function to return an attribute of the class\n  def getHunger(self):\n    # The function will return the hunger attribute\n    return self.hunger\n\n  # Define a function to return an attribute of the class\n  def getPlayful(self):\n    # The function will return the playful attribute\n    return self.playful\n\n  # setters\n  # Define a function which assigns a value to an attribute of the class\n  def setName(self,xname):\n    self.name = xname\n\n  # Define a function which assigns a value to an attribute of the class\n  def setAge(self,Age):\n    self.age = Age\n\n  # Define a function which assigns a value to an attribute of the class\n  def setHunger(self,hunger):\n    self.hunger = hunger\n\n  # Define a function which assigns a value to an attribute of the class\n  def setPlayful(self,play):\n    self.playful = play\n\n  # Define a function which refers to the class and returns a string\n  def __str__(self):\n     # Define the string which the function returns\n    return (self.name + \" is \" +str(self.age) + \" years old\")\n\n\n# The class is commented becuse two errors exist. One is in line 65 where the self argument is missing\n# and the second error is in line 81 where the code should be self.FavoriteToy\n# Define a class which inherits the Pet class\n#class Dog(Pet):\n#\n#  # Define a function which refers to the class in order to initiliaze the attributes of the class\n#  def __init__(self,name,age,hunger,playful,breed,FavoriteToy):\n#    # Call the initializer of the parent class with the proper parameters\n#    # Error - the self argument is missing\n#    Pet.__init__(name,age,hunger,playful)\n#\n#    # The following line will return an error if uncommented\n#    #self.__init__(name,age,hunger,playful)\n#\n#    # Define an attribute and assign the value \"None\"\n#   self.breed = breed\n#    self.FavoriteToy = FavoriteToy\n#\n#  # Define unction which refers to the class\n#  def wantsToPlay(self):\n#\n#    # IF condition is True\n#    if self.playful == True:\n#      # Define the string which the function returns\n#      # Error - It should be self.FavoriteToy\n#      return(\"Dog wants to play with \" + FavoriteToy)\n#\n#    # ELSE condition\n#    else:\n#      # Define the string which the function returns\n#      return(\"Dog doesn't want to play\")\n#\n# Create an instance of the Dog class and assign values to the attributes\n#huskyDog = Dog(\"Snowball\",5,False,True,\"Husky\",\"Stick\")\n#\n# Assign to a variable the result returned by the wantsToPlay() function of the huskyDog instance\n#Play = huskyDog.wantsToPlay()\n#\n# Print the value of the Play variable\n# This will print \"Dog wants to play with Stick\"\n#print(Play)\n\n\n\n# Define a class which inherits the Pet class\nclass Dog(Pet):\n\n  # Define a function which refers to the class in order to initiliaze the attributes of the class\n  def __init__(self,name,age,hunger,playful,breed,FavoriteToy):\n    # Call the initializer of the parent class with the proper parameters\n    Pet.__init__(self,name,age,hunger,playful)\n\n    # The following line will return an error if uncommented\n    #self.__init__(name,age,hunger,playful)\n\n    # Define an attribute and assign the value of the breed argument\n    self.breed = breed\n    # Define an attribute and assign the value of the FavoriteToy argument\n    self.FavoriteToy = FavoriteToy\n\n  # Define unction which refers to the class\n  def wantsToPlay(self):\n    # IF condition is True\n    if self.playful == True:\n      # Define the string which the function returns\n      return(\"Dog wants to play with \" + self.FavoriteToy)\n    # ELSE condition\n    else:\n      # Define the string which the function returns\n      return(\"Dog doesn't want to play\")\n\n\n# Define a class which inherits the Pet class\nclass Cat(Pet):\n\n  # Define a function which refers to the class in order to initiliaze the attributes of the class\n  def __init__(self,name,age,hunger,playful,place):\n\n    # Call the initializer of the parent class with the proper parameters\n    Pet.__init__(self,name,age,hunger,playful)\n\n    # Define an attribute and assign the value of the place argument\n    self.FavoritePlaceToSit = place\n\n  # Define unction which refers to the class\n  def wantsToSit(self):\n    # IF condition is True\n    if self.playful == False:\n      # Define the string which the function prints\n      # The following line will produce an error if uncommented due to the self.place part of the code\n      #print(\"The cat wants to sit in\" ,self.place)\n      print(\"The cat wants to sit in\" ,self.FavoritePlaceToSit)\n    # ELSE condition\n    else:\n      # Define the string which the function prints\n      print(\"The cat wants to play\")\n\n  # Define a function which refers to the class and returns a string\n  def __str__(self):\n    # Define the string which the function returns\n    return (self.name + \" likes to sit in \" + self.FavoritePlaceToSit)\n\n# Define a class\nclass Human:\n  # Define a function which refers to the class in order to initiliaze the attributes of the class\n  def __init__(self,name,Pets):\n    # Define an attribute and assign the value of the name argument\n    self.name = name\n    # Define an attribute and assign the value of the Pets argument\n    self.Pets = Pets\n\n  def hasPets(self):\n    # IF condition is True\n    # If the Human has Pets\n    if len(self.Pets) != 0:\n      # Define the string which the function returns\n      return \"yes\"\n    # ELSE condition\n    else:\n      # Define the string which the function returns\n      return \"no\"\n\n\n\n\n\n# Create an instance of the Dog class and assign values to the attributes\nhuskyDog = Dog(\"Snowball\",5,False,True,\"Husky\",\"Stick\")\n\n# Assign to a variable the result returned by the wantsToPlay() function of the huskyDog instance\nPlay = huskyDog.wantsToPlay()\n\n# Print the value of the Play variable\n# This will print \"Dog wants to play with Stick\"\nprint(Play)\n\n# Assign the value False to the playful attribute of the huskyDog instance\nhuskyDog.playful = False\n\n# Assign to a variable the result returned by the wantsToPlay() function of the huskyDog instance\nPlay = huskyDog.wantsToPlay()\n\n# Print the value of the Play variable\n# This will print \"Dog doesn't want to play\"\nprint(Play)\n\n# Create an instance of the Cat class and assign values to the attributes\ntypicalCat = Cat(\"Fluffy\",3,False,False,\"the sun ray\")\n\n# Call the wantsToSit() function of the typicalCat instance\n# This will print \"The cat wants to sit in the sun ray\"\ntypicalCat.wantsToSit()\n\n# This will print the returned string from the __str__ function of the typicalCat instance\n# This will print \"Fluffy likes to sit in the sun ray\"\nprint(typicalCat)\n# The __str__ function is not defined in the Dog function so it will return general inforamtion on the class\n# This will print <class '__main__.Dog'>\nprint(Dog)\n# This will print the returned string from the __str__ function of the huskyDog instance which is inherited by the Pet class\n# This will print \"Snowball is 5 years old\"\nprint(huskyDog)\n\n# Create an instance of the Human class and assign values to the attributes\nyourAverageHuman = Human(\"Alice\",[huskyDog,typicalCat])\n\n# Assign to a variable the result returned by the hasPets() function of the yourAverageHuman instance\nhasPet = yourAverageHuman.hasPets()\n\n# Print the value of the hasPet variable\n# This will print \"yes\"\nprint(hasPet)\n\n# Print the first element in the Pets list attribute of the yourAverageHuman instance\n# The huskyDog instance is the first element in the Pets list attribute of the yourAverageHuman instance\n# This will print the returned string from the __str__ function of the huskyDog instance which is inherited by the Pet class\n# This will print \"Snowball is 5 years old\"\nprint(yourAverageHuman.Pets[0])\n\n# Print the second element in the Pets list attribute of the yourAverageHuman instance\n# The typicalCat instance is the second element in the Pets list attribute of the yourAverageHuman instance\n# This will print the returned string from the __str__ function of the typicalCat instance\n# This will print \"Fluffy likes to sit in the sun ray\"\nprint(yourAverageHuman.Pets[1])\n\n# Print the name attribute of the second element in the Pets list attribute of the yourAverageHuman instance\n# The typicalCat instance is the second element in the Pets list attribute of the yourAverageHuman instance\n# This will print \"Fluffy\"\nprint(yourAverageHuman.Pets[1].name)\n\n# Print the name attribute of the first element in the Pets list attribute of the yourAverageHuman instance\n# The huskyDog instance is the first element in the Pets list attribute of the yourAverageHuman instance\n# This will print \"Snowball\"\nprint(yourAverageHuman.Pets[0].name)\n"
  },
  {
    "path": "dictionaries and sets/Dictionaries-and-Sets.py",
    "content": "##\r\n# Dictionaries and Sets Lecture\r\n##\r\n\r\n# -*- coding: utf-8 -*-\r\n\r\n\r\n\"\"\"\r\nA set is a data structure in python like a list to store a variety of hetrogenous unique elements.\r\nHetrogenous means a set can contain primitive types  integer , string , float in it.\r\nUnique means that each element can occur only once in a set\r\n\"\"\"\r\n\r\n# Declaring a set 'Sets' with different string values in it\r\nSets={\"Element1\",\"Element2\",\"Element1\",\"Element4\"}\r\n# Printing variable 'Sets' using the 'print' function\r\nprint(Sets)\r\n# Output\r\n\"\"\"\r\n{'Element1', 'Element4', 'Element2'}\r\n\"\"\"\r\n# Notice how the output is different from the input in two ways\r\n# 1) Only unique elements are printed\r\n# 2) Elements are not printed in the same order as they were stored because in sets order doesnt matter\r\n\r\n\r\n# Here 'if' condition is used along with 'in' keyword to check whether the value \"Element1\" is present in set 'Sets'\r\nif \"Element1\" in Sets:\r\n    # If the value \"Element1\" is found print \"Yes\" to console\r\n    print(\"Yes\")\r\n# Output\r\n\"\"\"\r\nYes\r\n\"\"\"\r\n\r\n\r\n# Declaring a list variable 'CountryList' and assigning empty list to it by using '[]'\r\nCountryList = []\r\n\r\n# For loop is used with 'range(5)' indicating the loop will run 5 times from 0-4\r\nfor i in range(5):\r\n    # Taking input from user and assigning it to variable named 'Country' using 'input(range_value)' function\r\n    Country = input(\"Please Enter Your Country: \")\r\n    # 'append(variable_name)' function is used here which adds a new element into the list 'CountryList'\r\n    CountryList.append(Country)\r\n\r\n# A new set 'CountrySet' is created using the 'set(variable_name)' function by passing the variable 'CountryList' which will convert the 'CountryList' to a set\r\nCountrySet = set(CountryList)\r\n\r\n# Printing list 'CountryList'\r\nprint(CountryList)\r\n# Printing set 'CountrySet'\r\nprint(CountrySet)\r\n# Output\r\n\"\"\"\r\nPlease Enter Your Country: US\r\nPlease Enter Your Country: France\r\nPlease Enter Your Country: India\r\nPlease Enter Your Country: Brazil\r\nPlease Enter Your Country: France\r\n['US', 'France', 'India', 'Brazil', 'France']\r\n{'France', 'India', 'Brazil', 'US'}\r\n\"\"\"\r\n# First the program asks to entry country names 5 times and then the list and set is printed\r\n# Notice how the set has changed order and only prints unique elements which is the property of set\r\n\r\n# Here 'if' condition is used along with 'in' keyword to check whether the value \"Brazil\" is present in set 'CountrySet'\r\nif \"Brazil\" in CountrySet:\r\n    # If the value \"Brazil\" is found print \"attended\" to console\r\n    print(\"attended\")\r\n# Output\r\n\"\"\"\r\nattended\r\n\"\"\"\r\n\r\n\"\"\"\r\nA dictionary is another data structure in python that also supports hetrogenous data to be stored inside it.\r\nRather than using index like used in list , a dictionary supports key-value structure where the key is used like an index and value is stored besides it like how values are stored in a variable\r\nA dictionary should also contain unique keys and can contain even lists inside of it.\r\n\"\"\"\r\n\r\n# Declaring a dictonary variable named 'Dictonary' and assigning keys and values to it\r\n# \"Key\" , \"Key1\", \"Key2\" are the keys\r\n# \"Value\" , \"Value1\" , \"Value2\" are the corresponding values\r\nDictionary={\"Key\":\"Value\",\"Key1\":\"Value1\",\"Key2\":\"Value2\"}\r\n# Printing the dictonary variable 'Dictionary'\r\nprint(Dictionary)\r\n# Output\r\n\"\"\"\r\n{'Key': 'Value', 'Key1': 'Value1', 'Key2': 'Value2'}\r\n\"\"\"\r\n\r\n\r\n# Declaring a list variable 'CountryList' and assigning empty list to it by using '[]'\r\nCountryList = []\r\n\r\n# For loop is used with 'range(5)' indicating the loop will run 5 times from 0-4\r\nfor i in range(5):\r\n    # Taking input from user and assigning it to variable named 'Country' using 'input(range_value)' function\r\n    Country = input(\"Please Enter Your Country: \")\r\n    # 'append(variable_name)' function is used here which adds a new element into the list 'CountryList'\r\n    CountryList.append(Country)\r\n\r\n\r\n# Declaring a dictionary variable 'CountryDictionary' and assigning empty dictionary to it by using '{}'\r\nCountryDictionary={}\r\n\r\n# A for loop is used using 'for in syntax' to access the elements of list 'CountryList' and stored it in local variable named 'Country'\r\nfor Country in CountryList:\r\n    # If statement is used in order to check if the country name is present as a key in dictionary 'CountryDictionary'\r\n    if Country in CountryDictionary:\r\n        # upon finding the key the value is accessed using 'DictionaryName[key_name]' synatx and incremented one to it\r\n        CountryDictionary[Country] +=1\r\n    else:\r\n        # if the key is not found then creating a new key with country name and assigning one to it\r\n        # Notice how no error will be produced which was occuring in list when tried to access an element whcih didnt existed\r\n        CountryDictionary[Country] = 1\r\n\r\n# Printing the dictionary variable 'CountryDictionary'\r\nprint(CountryDictionary)\r\n# Output\r\n\"\"\"\r\nPlease Enter Your Country: US\r\nPlease Enter Your Country: France\r\nPlease Enter Your Country: India\r\nPlease Enter Your Country: Brazil\r\nPlease Enter Your Country: France\r\n{'France': 2, 'India': 1, 'Brazil': 1,'US': 1}\r\n\"\"\"\r\n# No order is mainatined in dictionary as well\r\n"
  },
  {
    "path": "dictionaries and sets/Examples-of-Dictionaries-and-Sets.py",
    "content": "##\r\n# Examples of Dictionaries and Sets - Lecture\r\n##\r\n\r\n\r\n# Declaring a dictonary variable named 'BlackShoes' and assigning keys and values to it\r\n# 42 , 41, 40 , 39 , 38 are the keys\r\n# 2 , 3 , 4 , 1 , 0 are the corresponding values\r\nBlackShoes={42:2,41:3,40:4,39:1,38:0}\r\n\r\n# Printing the dictionary variable 'BlackShoes'\r\nprint(BlackShoes)\r\n\r\n# Using a while loop which will run endlesly until a given condition is met\r\nwhile (True): # True==True\r\n    # Taking input from user and assigning it to variable named 'purchaseSize' using 'input()' function\r\n    # notice \\n in the code which is used to bring new line\r\n    # int(variable_name) converts the the variable to type integer\r\n    purchaseSize = int(input(\"Which shoe size would you like to buy?\\n\"))\r\n    # Accessing the value of key 'purchaseSize' and decreasing it by 1\r\n    BlackShoes[purchaseSize] -= 1 # BlackShoes[purchaseSize]=BlackShoes[purchaseSize]-1 both are same\r\n    # Printing the dictionary variable 'BlackShoes'\r\n    print(BlackShoes)\r\n# Output\r\n\"\"\"\r\n{42: 2, 41: 3, 40: 4, 39: 1, 38: 0}\r\nWhich shoe size would you like to buy?\r\n42\r\n{42: 1, 41: 3, 40: 4, 39: 1, 38: 0}\r\nWhich shoe size would you like to buy?\r\n39\r\n{42: 1, 41: 3, 40: 4, 39: 0, 38: 0}\r\nWhich shoe size would you like to buy?\r\n38\r\n{42: 1, 41: 3, 40: 4, 39: 0, 38: -1}\r\n\"\"\"\r\n# Notice the issue in the code where the value of shoe size goes to negative and this needs to be fixed\r\n\r\n\r\n\r\n# Declaring a dictonary variable named 'BlackShoes' and assigning keys and values to it\r\n# 42 , 41, 40 , 39 , 38 are the keys\r\n# 2 , 3 , 4 , 1 , 0 are the corresponding values\r\nBlackShoes={42:2,41:3,40:4,39:1,38:0}\r\n\r\n# Printing the dictionary variable 'BlackShoes'\r\nprint(BlackShoes)\r\n\r\n# Using a while loop which will run endlesly until a given condition is met\r\nwhile (True): # True==True\r\n    # Taking input from user and assigning it to variable named 'purchaseSize' using 'input()' function\r\n    # notice \\n in the code which is used to bring new line\r\n    # int(variable_name) converts the the variable to type integer\r\n    purchaseSize = int(input(\"Which shoe size would you like to buy?\\n\"))\r\n    # If statement is used in order to check if the value of shoe size is greater than zero\r\n    if BlackShoes[purchaseSize] > 0:\r\n        # Accessing the value of key 'purchaseSize' and decreasing it by 1\r\n        BlackShoes[purchaseSize] -= 1 # BlackShoes[purchaseSize]=BlackShoes[purchaseSize]-1 both are same\r\n    # If size is not greater than zero then we print message using 'print()' function to user\r\n    else:\r\n        # Printing message\r\n        print(\"Shoes are no longer in stock\")\r\n    # Printing the dictionary variable 'BlackShoes'\r\n    print(BlackShoes)\r\n# Output\r\n\"\"\"\r\n{42: 2, 41: 3, 40: 4, 39: 1, 38: 0}\r\nWhich shoe size would you like to buy?\r\n42\r\n{42: 1, 41: 3, 40: 4, 39: 1, 38: 0}\r\nWhich shoe size would you like to buy?\r\n38\r\nShoes are no longer in stock\r\n{42: 1, 41: 3, 40: 4, 39: 1, 38: 0}\r\nWhich shoe size would you like to buy?\r\n\r\n\"\"\"\r\n# Notice that the negative number problem is fixed but the loop is never ending and this needs to be fixed as well\r\n\r\n\r\n\r\n\r\n# Declaring a dictonary variable named 'BlackShoes' and assigning keys and values to it\r\n# 42 , 41, 40 , 39 , 38 are the keys\r\n# 2 , 3 , 4 , 1 , 0 are the corresponding values\r\nBlackShoes={42:2,41:3,40:4,39:1,38:0}\r\n\r\n# Printing the dictionary variable 'BlackShoes'\r\nprint(BlackShoes)\r\n\r\n# Using a while loop which will run endlesly until a given condition is met\r\nwhile (True): # True==True\r\n    # Taking input from user and assigning it to variable named 'purchaseSize' using 'input()' function\r\n    # notice \\n in the code which is used to bring new line\r\n    # int(variable_name) converts the the variable to type integer\r\n    purchaseSize = int(input(\"Which shoe size would you like to buy?\\n\"))\r\n    # If statement is used to check if the entered amount is less than 0\r\n    if purchaseSize < 0:\r\n        # if it is then 'break' keyword is used to terminate the loop\r\n        break\r\n    # If statement is used in order to check if the value of shoe size is greater than zero\r\n    if BlackShoes[purchaseSize] > 0:\r\n        # Accessing the value of key 'purchaseSize' and decreasing it by 1\r\n        BlackShoes[purchaseSize] -= 1 # BlackShoes[purchaseSize]=BlackShoes[purchaseSize]-1 both are same\r\n    # If size is not greater than zero then we print message using 'print()' function to user\r\n    else:\r\n        # Printing message\r\n        print(\"Shoes are no longer in stock\")\r\n    # Printing the dictionary variable 'BlackShoes'\r\n    print(BlackShoes)\r\n# Output\r\n\"\"\"\r\n{42: 2, 41: 3, 40: 4, 39: 1, 38: 0}\r\nWhich shoe size would you like to buy?\r\n38\r\nShoes are no longer in stock\r\n{42: 2, 41: 3, 40: 4, 39: 1, 38: 0}\r\nWhich shoe size would you like to buy?\r\n40\r\n{42: 2, 41: 3, 40: 3, 39: 1, 38: 0}\r\nWhich shoe size would you like to buy?\r\n-1\r\n\"\"\"\r\n"
  },
  {
    "path": "error handling/main.py",
    "content": "##\r\n# Error Handling Lecture\r\n##\r\n\r\n\r\n# float(\"123.4\") - > 123.4\r\n# float(\"N/A\") - > error\r\n\r\n\"\"\"\r\n'try' 'except' is a way of handling errors in phyton\r\nIts similiar to if else block the difference being that if any errors occur in the 'try' block , the 'expect' block will be called automatically\r\n\"\"\"\r\n\r\n\r\ntry:\r\n    # Printing 'Hello' using the 'print()' function\r\n    print(\"Hello\")\r\nexcept:\r\n    # Printing 'Enterted Exception' only if any errors occur in the try block using the 'print()' function\r\n    print(\"Entered exception\")\r\n\r\n# Output\r\n\"\"\"\r\nHello\r\n\"\"\"\r\n# Hello is printed since no error occured in the try block\r\n\r\n\r\ntry:\r\n    # Printing 'Hello' using the 'print()' function\r\n    print(int(\"Hello\"))\r\nexcept:\r\n    # Printing 'Enterted Exception' only if any errors occur in the try block using the 'print()' function\r\n    print(\"Entered exception\")\r\n\r\n# Output\r\n\"\"\"\r\nEntered exception\r\n\"\"\"\r\n# Entered exception is printed since error occured in the try block\r\n\r\n\r\n\r\ntry:\r\n    # Printing 'Hello' using the 'print()' function\r\n    print(int(\"Hello\"))\r\nexcept:\r\n    # Printing 'Enterted Exception' only if any errors occur in the try block using the 'print()' function\r\n    print(\"Entered exception\")\r\n\r\n# Printing 'Past exception' using the 'print()' function\r\nprint(\"Past exception\")\r\n# Output\r\n\"\"\"\r\nEntered exception\r\nPast exception\r\n\"\"\"\r\n# Both the Entered exception and passed exception has been printed , this shows that the program doesnt stops if an error has occured\r\n\r\n# Declared a variable 'keyword' with a value of \"123\"\r\nkeyword=\"123\"\r\ntry:\r\n    # Printing variable 'keyword' using the 'print()' function\r\n    print(int(keyword))\r\nexcept:\r\n    # Printing 'Enterted Exception' only if any errors occur in the try block using the 'print()' function\r\n    print(\"Entered exception\")\r\n\r\n# Printing 'Past exception' using the 'print()' function\r\nprint(\"Past exception\")\r\n# Output\r\n\"\"\"\r\n123\r\nPast exception\r\n\"\"\"\r\n\r\n\r\n\r\n# Declared a variable 'keyword' with a value of \"Hello\"\r\nkeyword=\"Hello\"\r\ntry:\r\n    # Printing variable 'keyword' using the 'print()' function\r\n    print(int(keyword))\r\nexcept:\r\n    # Printing 'Enterted Exception' only if any errors occur in the try block using the 'print()' function\r\n    print(\"Entered exception\")\r\n\r\n# Printing 'Past exception' using the 'print()' function\r\nprint(\"Past exception\")\r\n# Output\r\n\"\"\"\r\nEntered exception\r\nPast exception\r\n\"\"\"\r\n\r\n\r\n# Declared a variable 'keyword' with a value of \"Hello\"\r\nkeyword=\"Hello\"\r\ntry:\r\n    # Printing variable 'keyword' using the 'print()' function\r\n    print(int(keyword))\r\nexcept:\r\n    # The pass keyword is used to indicate when no operation needs to be done in the block , this is also used to move the execution forward\r\n    pass\r\n\r\n# Printing 'Past exception' using the 'print()' function\r\nprint(\"Past exception\")\r\n# Output\r\n\"\"\"\r\nPast exception\r\n\"\"\"\r\n\r\n\r\n# Declared a variable 'keyword' with a value of \"Hello\"\r\nkeyword=\"Hello\"\r\ntry:\r\n    # Printing variable 'keyword' using the 'print()' function\r\n    print(int(keyword))\r\nexcept:\r\n    # The pass keyword is used to indicate when no operation needs to be done in the block , this is also used to move the execution forward\r\n    pass\r\n    # Printing 'Enterted Exception' only if any errors occur in the try block using the 'print()' function\r\n    print(\"Entered exception\")\r\n\r\n# Printing 'Past exception' using the 'print()' function\r\nprint(\"Past exception\")\r\n# Output\r\n\"\"\"\r\nEntered exception\r\nPast exception\r\n\"\"\"\r\n# Both the Entered exception and Past exception has been printed , because 'pass' keyword is doesnt work like 'break'\r\n\r\n\r\n\r\n\r\n# Declared a variable 'keyword' with a value of \"Hello\"\r\nkeyword=\"Hello\"\r\ntry:\r\n    # Printing variable 'keyword' using the 'print()' function\r\n    print(int(keyword))\r\nexcept Exception as e:\r\n    # Printing the string version of the catched exception , The exception that has occured can be caught and stored in a variable\r\n    print(str(e))\r\n\r\n# Printing 'Past exception' using the 'print()' function\r\nprint(\"Past exception\")\r\n# Output\r\n\"\"\"\r\ninvalid literal for int() with base 10: 'Hello'\r\nPast exception\r\n\"\"\"\r\n\r\n\r\n# Declared a variable 'keyword' with a value of \"Hello\"\r\nkeyword=\"Hello\"\r\ntry:\r\n    # Printing variable 'keyword' using the 'print()' function\r\n    print(int(keyword))\r\n# If known a specific error can be caught using the 'except' keyword\r\nexcept ValueError:\r\n    # Pinting \"got a ValueError\" using 'print()' function\r\n    print(\"got a ValueError\")\r\n\r\n# Printing 'Past exception' using the 'print()' function\r\nprint(\"Past exception\")\r\n# Output\r\n\"\"\"\r\ngot a ValueError\r\nPast exception\r\n\"\"\"\r\n\r\n\r\n# Declared a variable 'keyword' with a value of \"Hello\"\r\nkeyword=\"Hello\"\r\ntry:\r\n    # Printing variable 'keyword' using the 'print()' function\r\n    print(int(keyword))\r\n# If known a specific error can be caught using the 'except' keyword\r\nexcept ValueError:\r\n    # Printing \"got a ValueError\" using 'print()' function\r\n    print(\"got a ValueError\")\r\n# except can be chained together like if elif statements\r\nexcept:\r\n    # Printing \"Other types of exception\" using 'print()' function\r\n    print(\"Other tpyes of exception\")\r\n\r\n# Printing 'Past exception' using the 'print()' function\r\nprint(\"Past exception\")\r\n# Output\r\n\"\"\"\r\ngot a ValueError\r\nPast exception\r\n\"\"\"\r\n# Since ValueError has occured only the 'except' block with 'ValueError' has been executed\r\n\r\n\r\n# Declared a variable 'keyword' with a value of \"Hello\"\r\nkeyword=\"Hello\"\r\ntry:\r\n    # Printing variable 'keyword' using the 'print()' function\r\n    print(int(keyword))\r\n# If known a specific error can be caught using the 'except' keyword\r\nexcept ValueError:\r\n    # Printing \"got a ValueError\" using 'print()' function\r\n    print(\"got a ValueError\")\r\n# except can be chained together like if elif statements\r\nexcept:\r\n    # Printing \"Other types of exception\" using 'print()' function\r\n    print(\"Other tpyes of exception\")\r\n# The 'finally' block is a block always executed , no matter what happens in the 'try' 'except' block\r\nfinally:\r\n    # Printing \"finally\" using 'print()' function\r\n    print(\"finally\")\r\n\r\n# Printing 'Past exception' using the 'print()' function\r\nprint(\"Past exception\")\r\n# Output\r\n\"\"\"\r\ngot a ValueError\r\nfinally\r\nPast exception\r\n\"\"\"\r\n# finally has also printed because it always executed\r\n\r\n\r\n\r\ntry:\r\n    # We can 'raise' call an error using the raise keyword even though the error doesnt occur in the program\r\n    raise ValueError\r\n# If known a specific error can be caught using the 'except' keyword\r\nexcept ValueError:\r\n    # Printing \"got a ValueError\" using 'print()' function\r\n    print(\"got a ValueError\")\r\n# except can be chained together like if elif statements\r\nexcept:\r\n    # Printing \"Other types of exception\" using 'print()' function\r\n    print(\"Other tpyes of exception\")\r\n# The 'finally' block is a block always executed , no matter what happens in the 'try' 'except' block\r\nfinally:\r\n    # Printing \"finally\" using 'print()' function\r\n    print(\"finally\")\r\n\r\n# Printing 'Past exception' using the 'print()' function\r\nprint(\"Past exception\")\r\n# Output\r\n\"\"\"\r\ngot a ValueError\r\nfinally\r\nPast exception\r\n\"\"\"\r\n# got a ValueError is printed because we rasied that error ourselves\r\n\r\n\r\n\r\ntry:\r\n    # We can 'raise' call an error using the raise keyword even though the error doesnt occur in the program\r\n    raise NameError\r\n# If known a specific error can be caught using the 'except' keyword\r\nexcept ValueError:\r\n    # Printing \"got a ValueError\" using 'print()' function\r\n    print(\"got a ValueError\")\r\n# except can be chained together like if elif statements\r\nexcept:\r\n    # Printing \"Other types of exception\" using 'print()' function\r\n    print(\"Other tpyes of exception\")\r\n# The 'finally' block is a block always executed , no matter what happens in the 'try' 'except' block\r\nfinally:\r\n    # Printing \"finally\" using 'print()' function\r\n    print(\"finally\")\r\n\r\n# Printing 'Past exception' using the 'print()' function\r\nprint(\"Past exception\")\r\n# Output\r\n\"\"\"\r\nOther types of exception\r\nfinally\r\nPast exception\r\n\"\"\"\r\n# Notice how \"Other types of exception\" is printed because we have not caught the 'NameError' in any 'except' block\r\n\r\n\r\n\r\n\r\n\r\ntry:\r\n    # We can 'raise' call an error using the raise keyword even though the error doesnt occur in the program\r\n    raise NameError\r\n# If known a specific error can be caught using the 'except' keyword\r\nexcept ValueError:\r\n    # Printing \"got a ValueError\" using 'print()' function\r\n    print(\"got a ValueError\")\r\n# except can be chained together like if elif statements\r\nexcept:\r\n    # Printing \"Other types of exception\" using 'print()' function\r\n    print(\"Other tpyes of exception\")\r\n    # We can raise the same error again to manually crash the program\r\n    raise\r\n# The 'finally' block is a block always executed , no matter what happens in the 'try' 'except' block\r\nfinally:\r\n    # Printing \"finally\" using 'print()' function\r\n    print(\"finally\")\r\n\r\n# Printing 'Past exception' using the 'print()' function\r\nprint(\"Past exception\")\r\n# Output\r\n\"\"\"\r\nraise NameError\r\nNameError\r\n\"\"\"\r\n\r\n\r\n\r\ntry:\r\n    # We can 'raise' call an error using the raise keyword even though the error doesnt occur in the program\r\n    # A message of \"Error\" has been passed when we 'raise' the error\r\n    raise NameError(\"Error\")\r\n# If known a specific error can be caught using the 'except' keyword\r\nexcept ValueError:\r\n    # Printing \"got a ValueError\" using 'print()' function\r\n    print(\"got a ValueError\")\r\n# except can be chained together like if elif statements\r\n# The error has been catched here and renamed it to 'e'\r\nexcept Exception as e:\r\n    # Printing \"Other types of exception\" using 'print()' function\r\n    print(\"Other tpyes of exception\")\r\n    # Printing the String version of error 'e' using 'print()' function\r\n    print(str(e))\r\n# The 'finally' block is a block always executed , no matter what happens in the 'try' 'except' block\r\nfinally:\r\n    # Printing \"finally\" using 'print()' function\r\n    print(\"finally\")\r\n\r\n# Printing 'Past exception' using the 'print()' function\r\nprint(\"Past exception\")\r\n# Output\r\n\"\"\"\r\nOther tpyes of exception\r\nError\r\nfinally\r\nPast exception\r\n\"\"\"\r\n# Notice the message \"Error\" has also been printed\r\n\r\n\r\n# Declared a variable 'keyword' with a value of \"Hello\"\r\nkeyword=\"Hello\"\r\ntry:\r\n    # Printing variable 'keyword' using the 'print()' function\r\n    print(int(keyword))\r\n    # We can 'raise' call an error using the raise keyword even though the error doesnt occur in the program\r\n    # A message of \"Error\" has been passed when we 'raise' the error\r\n    raise NameError(\"Error\")\r\n# The error has been catched here and renamed it to 'e'\r\nexcept Exception as e:\r\n    # Printing \"Other types of exception\" using 'print()' function\r\n    print(\"Other tpyes of exception\")\r\n    # Printing the String version of error 'e' using 'print()' function\r\n    print(str(e))\r\n# The 'finally' block is a block always executed , no matter what happens in the 'try' 'except' block\r\nfinally:\r\n    # Printing \"finally\" using 'print()' function\r\n    print(\"finally\")\r\n\r\n# Printing 'Past exception' using the 'print()' function\r\nprint(\"Past exception\")\r\n# Output\r\n\"\"\"\r\nOther tpyes of exception\r\ninvalid literal for int() with base 10: 'Hello'\r\nfinally\r\nPast exception\r\n\"\"\"\r\n# Notice the message \"Error\" has also been printed\r\n"
  },
  {
    "path": "final project/Blackjack-Part-A.py",
    "content": "##\r\n# Blackjack, Part A Lecture\r\n##\r\n\r\n# _*_ coding: utf-8 _*_\r\n\r\n#Import shuffle function from random library\r\nfrom random import shuffle\r\n\r\n# Create a functions\r\ndef createDeck():\r\n    Deck = []\r\n    #Set a variable for faceValues\r\n    faceValues = ['A', 'J', 'Q', 'K']\r\n    for i in range(4): #There are 4 different suites\r\n        for card in range(2,11): #Adding numbers 2-10\r\n            Deck.append(str(card))\r\n\r\n        for card in faceValues:\r\n            Deck.append(card)\r\n    return Deck #Return products\r\n\r\n#Set a variable to createDock function, and then print it\r\ncardDeck = createDeck()\r\n\r\nshuffle(cardDeck) #Mixing results with shuffle\r\n\r\nprint(cardDeck)\r\n"
  },
  {
    "path": "final project/Blackjack-Part-B.py",
    "content": "##\r\n# Blackjack, Part B Lecture\r\n##\r\n\r\n# _*_ coding: utf-8 _*_\r\n\r\n#Import shuffle function from random library\r\nfrom random import shuffle\r\n\r\n# Create a functions\r\ndef createDeck():\r\n    Deck = []\r\n    #Set a variable for faceValues\r\n    faceValues = ['A', 'J', 'Q', 'K']\r\n    for i in range(4): #There are 4 different suites\r\n        for card in range(2,11): #Adding numbers 2-10\r\n            Deck.append(str(card))\r\n\r\n        for card in faceValues:\r\n            Deck.append(card)\r\n    shuffle(Deck) #Mixing results with shuffle\r\n    return Deck #Return products\r\n\r\n#Set a variable to createDock function, and then print it\r\ncardDeck = createDeck()\r\nprint(cardDeck)\r\n\r\n# Set a player class\r\nclass Player:\r\n    def __init__(self,hand = [],money = 100): #__init__ is the constructor for a class\r\n      self.hand = hand\r\n      self.score = self.setScore()\r\n      print(self.score)\r\n      self.money = money\r\n\r\n    def __str__(self): #__str__ will return a human readable string\r\n      currentHand = \" \" #slef.hand = [\"A\",\"10\"]\r\n      for card in self.hand:\r\n          currentHand  += str(card) + \" \"\r\n\r\n      #Set a variable for finalStatus, and then return it\r\n      finalStatus = currentHand + \"score \" + str(self.score)\r\n      return finalStatus\r\n\r\n    #Set a setScore function, and then return it\r\n    def setScore(self) :\r\n        self.score = 0\r\n        print(self.score)\r\n        #Set a Dictionary for faceCards\r\n        faceCardsDict = {\"A\":11,\"J\":10,\"Q\":10,\"K\":10,\r\n                        \"2\":2,\"3\":3,\"4\":4,\"5\":5,\"6\":6,\r\n                        \"7\":7,\"8\":8,\"9\":9,\"10\":10}\r\n        #Set a variable for aceCounter\r\n        aceCounter = 0\r\n        #Convert card into score\r\n        for card in self.hand:\r\n            self.score += faceCardsDict[card]\r\n            if card == \"A\":\r\n                aceCounter +=1\r\n            if self.score > 21 and aceCounter !=0:\r\n                self.score -= 10\r\n                aceCounter -= 1\r\n        return self.score\r\n\r\n#Set a variable for player1, and then print it\r\nplayer1 = Player([\"3\",\"7\",\"5\"])\r\nprint(player1)\r\n"
  },
  {
    "path": "final project/Blackjack-Part-C.py",
    "content": "##\r\n# Blackjack, Part C Lecture\r\n##\r\n\r\n# _*_ coding: utf-8 _*_\r\n\r\n\r\n#Import shuffle function from random library\r\nfrom random import shuffle\r\n\r\n# Create a functions\r\ndef createDeck():\r\n    Deck = []\r\n    #Set a variable for faceValues\r\n    faceValues = ['A', 'J', 'Q', 'K']\r\n    for i in range(4): #There are 4 different suites\r\n        for card in range(2,11): #Adding numbers 2-10\r\n            Deck.append(str(card))\r\n\r\n        for card in faceValues:\r\n            Deck.append(card)\r\n    shuffle(Deck) #Mixing results with shuffle\r\n    return Deck #Return products\r\n\r\n#Set a variable to createDock function, and then print it\r\ncardDeck = createDeck()\r\nprint(cardDeck)\r\n\r\n# Set a player class\r\nclass Player:\r\n    def __init__(self,hand = [],money = 100): #__init__ is the constructor for a class\r\n      self.hand = hand\r\n      self.score = self.setScore()\r\n      self.money = money\r\n\r\n    def __str__(self): #__str__ will return a human readable string\r\n      currentHand = \" \" #slef.hand = [\"A\",\"10\"]\r\n\r\n      for card in self.hand:\r\n          currentHand  += str(card) + \" \"\r\n\r\n      #Set a variable for finalStatus, and then return it\r\n      finalStatus = currentHand + \"score \" + str(self.score)\r\n      return finalStatus\r\n\r\n    #Set a setScore function to count score, and then return it\r\n    def setScore(self) :\r\n        self.score = 0\r\n        #Set a Dictionary for faceCards\r\n        faceCardsDict = {\"A\":11,\"J\":10,\"Q\":10,\"K\":10,\r\n                        \"2\":2,\"3\":3,\"4\":4,\"5\":5,\"6\":6,\r\n                        \"7\":7,\"8\":8,\"9\":9,\"10\":10}\r\n        #Set a variable for aceCounter\r\n        aceCounter = 0\r\n        #Convert card into score\r\n        for card in self.hand:\r\n            self.score += faceCardsDict[card]\r\n            if card == \"A\":\r\n                aceCounter +=1\r\n            if self.score > 21 and aceCounter != 0:\r\n                self.score -= 10\r\n                aceCounter -= 1\r\n\r\n        return self.score\r\n\r\n    #Set a hit function to select a card, and then return it\r\n    def hit(self,card):\r\n        self.hand.append(card)\r\n        self.score = self.setScore()\r\n\r\n    #Set a function to add new player\r\n    def play(self,newHnad):\r\n        self.hand = newHnad\r\n        self.score = self.setScore()\r\n\r\n    #Set a function to put out money\r\n    def pay(self,amount):\r\n        self.money -= amount #decrease money from balance\r\n\r\n    #Set a function for winner\r\n    def win(self,amount):\r\n        self.money += amount # double amount for winner\r\n\r\n\r\n#Set a variable for player1, and then print it\r\nPlayer1 = Player([\"3\",\"7\",\"5\"])\r\nprint(Player1)\r\nPlayer1.hit(\"A\")\r\nPlayer1.hit(\"A\")\r\nprint(Player1) #Score after selecting a card\r\nPlayer1.pay(20)\r\nprint(Player1.money) #Balance after puting money\r\nPlayer1.win(40)\r\nprint(Player1.money) #Balance after winning\r\nPlayer1.play([\"A\",\"K\"])\r\nprint(Player1) #Score for new player\r\nprint(Player1.money) #After restarting the game\r\n"
  },
  {
    "path": "final project/Blackjack-Part-D.py",
    "content": "##\r\n# Blackjack, Part D Lecture\r\n##\r\n\r\n# _*_ coding: utf-8 _*_\r\n\r\n\r\n#Import shuffle function from random library\r\nfrom random import shuffle\r\n\r\n# Create a functions\r\ndef createDeck():\r\n    Deck = []\r\n    #Set a variable for faceValues\r\n    faceValues = ['A', 'J', 'Q', 'K']\r\n    for i in range(4): #There are 4 different suites\r\n        for card in range(2,11): #Adding numbers 2-10\r\n            Deck.append(str(card))\r\n\r\n        for card in faceValues:\r\n            Deck.append(card)\r\n    shuffle(Deck) #Mixing results with shuffle\r\n    return Deck #Return products\r\n\r\n#Set a variable to createDock function, and then print it\r\ncardDeck = createDeck()\r\nprint(cardDeck)\r\n\r\n# Set a player class\r\nclass Player:\r\n    def __init__(self,hand = [],money = 100): #__init__ is the constructor for a class\r\n      self.hand = hand\r\n      self.score = self.setScore()\r\n      self.money = money\r\n      self.bet = 0\r\n\r\n    def __str__(self): #__str__ will return a human readable string\r\n      currentHand = \" \" #slef.hand = [\"A\",\"10\"]\r\n\r\n      for card in self.hand:\r\n          currentHand  += str(card) + \" \"\r\n\r\n      #Set a variable for finalStatus, and then return it\r\n      finalStatus = currentHand + \"score \" + str(self.score)\r\n      return finalStatus\r\n\r\n    #Set a setScore function to count score, and then return it\r\n    def setScore(self) :\r\n        self.score = 0\r\n        #Set a Dictionary for faceCards\r\n        faceCardsDict = {\"A\":11,\"J\":10,\"Q\":10,\"K\":10,\r\n                        \"2\":2,\"3\":3,\"4\":4,\"5\":5,\"6\":6,\r\n                        \"7\":7,\"8\":8,\"9\":9,\"10\":10}\r\n        #Set a variable for aceCounter\r\n        aceCounter = 0\r\n        #Convert card into score\r\n        for card in self.hand:\r\n            self.score += faceCardsDict[card]\r\n            if card == \"A\":\r\n                aceCounter +=1\r\n            if self.score > 21 and aceCounter != 0:\r\n                self.score -= 10\r\n                aceCounter -= 1\r\n\r\n        return self.score\r\n\r\n    #Set a hit function to select a card, and then return it\r\n    def hit(self,card):\r\n        self.hand.append(card)\r\n        self.score = self.setScore()\r\n\r\n    #Set a function to add new player\r\n    def play(self,newHnad):\r\n        self.hand = newHnad\r\n        self.score = self.setScore()\r\n\r\n    #Set a function to put out money\r\n    def betMoney(self,amount):\r\n        self.money -= amount #decrease money from balance\r\n        self.bet += amount #\r\n\r\n    #Set a function for winner\r\n    def win(self,result):\r\n        if result == True:\r\n            if self.score == 21 and len(self.hand) == 2: # Set required score for winning blackjack\r\n                self.money += 2.5*self.bet # if player win with a blackjack\r\n            else:\r\n                self.money += 2*self.bet # if player win without a blackjack\r\n\r\n            self.bet = 0 # Reset the bet\r\n        else:\r\n            self.bet = 0 # If player loose a bet\r\n\r\n#Set a variable for player1, and then print it\r\nPlayer1 = Player([\"3\",\"7\",\"5\"])\r\nprint(Player1)\r\nPlayer1.hit(\"A\")\r\nPlayer1.hit(\"A\")\r\nprint(Player1) #Score after selecting a card\r\nPlayer1.betMoney(20)\r\nprint(Player1.money,Player1.bet) #Balance after puting money and bet amount\r\nPlayer1.win(True)\r\nprint(Player1.money,Player1.bet) #Balance after winning without a blackjack\r\nPlayer1.play([\"A\",\"K\"])\r\nprint(Player1) #Score for new player\r\nPlayer1.betMoney(20)\r\nPlayer1.win(True)\r\nprint(Player1.money,Player1.bet) #Balance after winning with a blackjack\r\n"
  },
  {
    "path": "final project/Blackjack-Part-E.py",
    "content": "##\r\n# Blackjack, Part E Lecture\r\n##\r\n\r\n# _*_ coding: utf-8 _*_\r\n\r\n#! /usr/bin/env python3\r\n# -*- coding: utf-8 -*-\r\n\r\nfrom random import shuffle              #import shuffle function from random module\r\n\r\ndef createDeck():                       #define a function to Create the Deck\r\n    Deck = []                           #create Deck as a List\r\n\r\n    faceValues = [\"A\", \"J\", \"Q\", \"K\" ]  #define faceValues with a list\r\n    for i in range(4):                  #add values 4 times via a for loop so there are 4 different suits\r\n\r\n        for card in range(2,11):        #loop through values between 2 to 10 not including 11. tese numbers represent cards\r\n            Deck.append(str(card))      #add cards to Deck. converting Integers to Strins for more convinience\r\n        for card in faceValues:         #loop through faceValues list\r\n            Deck.append(card)           #add faceValues to Deck\r\n\r\n    shuffle(Deck)                       #suffle the Deck\r\n    return Deck                         #return the Deck\r\n\r\nclass Player:                              #here we will be creating Player class\r\n    def __init__(self,hand = [],money = 100):        #__init__ function used to initialize a object. it is usually used to assign values for attributes of the object created by class\r\n       self.hand =   hand              #define hand attribute for the class player\r\n       self.score =  self.setScore()   #define score attribute for the Player and call to setScore function. return value from setScore will be assigned to score attribute\r\n       self.money =  money             #define money attribute for the class player\r\n       self.bet = 0                     #add a new attribute to Player called bet.\r\n\r\n    def __str__(self):                 #overriding the __str__ function. it is used to print hand and score of the player\r\n        CurrentHand = \"\"               #define a temporary variable to hold the current cards of the player\r\n        for card in self.hand:         #loop through the player 'hand' and add each card to CurrentHand\r\n            CurrentHand += str(card) + \" \"  #it is more convinient to add cards as strings to CurrentHand. so use str(card)\r\n\r\n        finalStaus = CurrentHand + \"score: \" + str(self.score) #finalStaus will be in the format  \"A 10 score:21\"  \"A 10 2 score:23\"\r\n        return finalStaus               #return finalStatus. which is printed by this function.\r\n\r\n    def setScore(self):                 #define setScore method for player class\r\n        self.score = 0                  #it is good practice to initialize the variable.\r\n        faceCardsDict = {\"A\":11, \"J\":10, \"Q\":10, \"K\":10,            #create a Dictionary and map each card a value\r\n                         \"2\":2, \"3\":3, \"4\":4, \"5\":5, \"6\":6,\r\n                         \"7\":7, \"8\":8, \"9\":9, \"10\":10}\r\n        aceCounter = 0                              #You need to count the number of Aces. here counter is initialized.\r\n        for card in self.hand:                      #loop throught the hand of the player and add value of each card to players score\r\n            self.score += faceCardsDict[card]\r\n            if card == \"A\":                         #if the card is a Ace,\r\n                aceCounter +=1                      #then increment the aceCounter\r\n            if self.score > 21 and aceCounter != 0:  #if the acore is above 21 and player has a Ace\r\n                self.score -= 10                     #new Ace value will be 1. hence score will be reduced by 10\r\n                aceCounter -= 1                      #as one Ace is consumed, reduce 1 from aceCounter\r\n\r\n        return self.score                            #return the score of the player\r\n\r\n    def hit(self, card):                        #hit function is used to ada a card to hand\r\n        self.hand.append(card)                  #new card will be append to the Player's hand\r\n        self.score = self.setScore()            #player score will be recalculated\r\n\r\n    def play(self, newHand):                    #play function will be used to restart the game or resest the hand. it will take a 'hand' as an argument\r\n        self.hand = newHand                     #new hand will be assigned to Player's hand\r\n        self.score = self.setScore()            #recalculate the Player's score\r\n\r\n    def betMoney(self,amount):                  #change pay function to betMoney\r\n        self.money -= amount                    #reduce bet amount from player's money\r\n        self.bet += amount                      #add bet amount to Player's bet amount\r\n\r\n    def win(self, result):                      #change win function. now it takes boolean argument.\r\n        if result == True:                      #if win funtion recieve true\r\n            if self.score == 21 and len(self.hand) == 2:   #if Blackjack is earned\r\n                self.money += 2.5 * self.bet                #2.5 times of bet amount will be added to Player's money.\r\n            else:                                   #if win but not a Blackjack\r\n                self.money += 2 * self.bet          #two times of bet amount will be added to Players money\r\n            self.bet = 0                        #we should erase bet amount after that\r\n        else:\r\n            self.bet = 0                        #if player is lost we only have to do erase bet amount. so it won't effect future play\r\n\r\ndef printHouse(House):                          #this method will print all cards of House except first card\r\n    for card in range(len(House.hand)):         #loop through the hand of House\r\n        if card == 0:                           #if it is the first card\r\n            print(\"X\", end=\" \")                 #just print 'X'. continue printing in same line with space gap\r\n        elif card == len(House.hand) - 1:       #if the card is the last one in the hand\r\n            print(House.hand[card])             #just print it. no need of space\r\n        else:                                   #else\r\n            print(House.hand[card], end=\" \")    #just print the card and keep a gap of space\r\n\r\ncardDeck = createDeck()                             #what is returned from the createDeck() function will be assigned to 'cardDeck'\r\nprint(cardDeck)                                     #print the cardDeck\r\nfirstHand = [cardDeck.pop(),cardDeck.pop()]         #add last two cards to firstHand,\r\nsecondHand = [cardDeck.pop(),cardDeck.pop()]        #add next last two cards to secondHand\r\nPlayer1 = Player(firstHand)                         #Player1 recieve firstHand\r\nHouse = Player(secondHand)                          #House recieve secondHand\r\nprint(Player1)                                      #Print hand and score of Player1\r\nprintHouse(House)                                   #Print hand and score of House\r\n\r\nwhile(Player1.score < 21):                          #this loop will continue as long as Player1 score is less than 21\r\n    action = input(\"Do you want another card?(y/n)\") #ask from user whether he needs another card. recieve user input\r\n    if action == \"y\":                               #if he press 'y'\r\n        Player1.hit(cardDeck.pop())                 #Player1 recieve a new card\r\n        print(Player1)                              #Print hand and score of Player1\r\n        printHouse(House)                           #Print hand and score of House\r\n    else:\r\n        break                                       #if user press 'n', exit the loop\r\n"
  },
  {
    "path": "final project/Blackjack-Part-F.py",
    "content": "##\r\n# Blackjack, Part F Lecture\r\n##\r\n\r\n# _*_ coding: utf-8 _*_\r\n\r\n\r\nfrom __future__ import print_function\r\n#Import shuffle function from random library\r\nfrom random import shuffle\r\n\r\n# Set a createDeck function\r\ndef createDeck():\r\n    Deck = []\r\n\r\n    #Set a variable for faceValues\r\n    faceValues = ['A', 'J', 'Q', 'K']\r\n    for i in range(4): # There are 4 different suites\r\n        for card in range(2,11): # Adding numbers 2-10\r\n            Deck.append(str(card))\r\n\r\n        for card in faceValues:\r\n            Deck.append(card)\r\n\r\n    shuffle(Deck) # Mixing results with shuffle\r\n    return Deck # Return products\r\n\r\n# Set a player class\r\nclass Player:\r\n    def __init__(self,hand = [],money = 100):     #__init__ is the constructor for a class\r\n      self.hand = hand\r\n      self.score = self.setScore()\r\n      self.money = money\r\n      self.bet = 0\r\n\r\n    def __str__(self):       #__str__ will return a human readable string\r\n      currentHand = \" \"\r\n\r\n      for card in self.hand:\r\n          currentHand  += str(card) + \" \"\r\n\r\n      #Set a variable for finalStatus, and then return it\r\n      finalStatus = currentHand + \"score \" + str(self.score)\r\n      return finalStatus\r\n\r\n    #Set a setScore function to count score, and then return it\r\n    def setScore(self) :\r\n        self.score = 0\r\n        #Set a Dictionary for faceCards\r\n        faceCardsDict = {\"A\":11,\"J\":10,\"Q\":10,\"K\":10,\r\n                        \"2\":2,\"3\":3,\"4\":4,\"5\":5,\"6\":6,\r\n                        \"7\":7,\"8\":8,\"9\":9,\"10\":10}\r\n        #Set a variable for aceCounter\r\n        aceCounter = 0\r\n        #Convert card into score\r\n        for card in self.hand:\r\n            self.score += faceCardsDict[card]\r\n            if card == \"A\":\r\n                aceCounter +=1\r\n            if self.score > 21 and aceCounter != 0:\r\n                self.score -= 10\r\n                aceCounter -= 1\r\n\r\n        return self.score\r\n\r\n    #Set a hit function to select a card, and then return it\r\n    def hit(self,card):\r\n        self.hand.append(card)\r\n        self.score = self.setScore()\r\n\r\n    #Set a function to add new player\r\n    def play(self,newHand):\r\n        self.hand = newHand\r\n        self.score = self.setScore()\r\n\r\n    #Set a function to put out money\r\n    def betMoney(self,amount):\r\n        self.money -= amount          # Decrease money from balance\r\n        self.bet += amount\r\n\r\n    #Set a function for winner\r\n    def win(self,result):\r\n        if result == True:\r\n            if self.score == 21 and len(self.hand) == 2: # Set required score for winning blackjack\r\n                self.money += 2.5*self.bet               # if player win with a blackjack\r\n            else:\r\n                self.money += 2*self.bet                 # if player win without a blackjack\r\n\r\n            self.bet = 0                                 # Reset the bet\r\n        else:\r\n            self.bet = 0                                 # If player loose a bet\r\n\r\n    #Set a function to check the result win or draw\r\n    def draw(self):\r\n\t\tself.money += self.bet\r\n\t\tself.bet = 0\r\n\r\n    #Set a function to check blackjack\r\n    def hasBlackjack(self):\r\n        if self.score == 21 and len(self.hand) == 2:\r\n            return True\r\n        else:\r\n\t\t\treturn False\r\n\r\n\r\n# Set a printHouse function to print the house and score\r\ndef printHouse(House):\r\n    for card in range(len(House.hand)):\r\n        if card == 0:\r\n            print(\"X\",end = \" \")\r\n        elif card == len(House.hand) -1:\r\n\t\t\tprint(House.hand[card])\r\n        else:\r\n            print(House.hand[card], end = \" \")\r\n\r\n#Set a variable to createDock function, and then print it\r\ncardDeck = createDeck()\r\n\r\n# Pop function select the last shuffle number\r\n\r\n# Set a variable for First players last shuffle number\r\nfirstHand =[cardDeck.pop(),cardDeck.pop()]\r\n\r\n# Set a variable for Second players last shuffle number\r\nsecondHand = [cardDeck.pop(),cardDeck.pop()]\r\n\r\n# Set a variable to First player score, and then print it\r\nPlayer1 = Player(firstHand)\r\n\r\n# Set a variable to Second player score, and then print it\r\nHouse = Player(secondHand)\r\n\r\ncardDeck = createDeck()\r\n\r\nwhile(True):\r\n    if len(cardDeck) <20:\r\n        cardDeck = createDeck()\r\n    firstHand = [cardDeck.pop(),cardDeck.pop()]\r\n    secondHand = [cardDeck.pop(),cardDeck.pop()]\r\n    Player1.play(firstHand)\r\n    House.play(secondHand)\r\n\r\n    # Set a variable to ask player for bet amount\r\n    Bet = int(input(\"Please enter your bet: \"))\r\n\r\n    print(cardDeck)\r\n    Player1.betMoney(Bet)\r\n    printHouse(House)\r\n    print(Player1)\r\n\r\n    #Define results on Blackjack win\r\n    if Player1.hasBlackjack():\r\n        if House.hasBlackjack():\r\n            Player1.draw()\r\n        else:\r\n            Player1.win(True)\r\n    else:\r\n        # if players score is below 21, ask him to add more card\r\n        while(Player1.score < 21):# While (true==true)\r\n            action = input(\"Do you want another card?(y/n): \")\r\n            if action == \"y\":\r\n                Player1.hit(cardDeck.pop())\r\n                print(Player1)\r\n                printHouse(House)\r\n            else:\r\n                break\r\n        # Define how long player can add card\r\n        while(House.score < 16):\r\n            print(House)\r\n            House.hit(cardDeck.pop())\r\n\r\n        if Player1.score > 21:\r\n            if House.score > 21:\r\n                Player1.draw()\r\n            else:\r\n                Player1.win(False)\r\n\r\n        elif Player1.score > House.score:\r\n            Player1.win(True)\r\n\r\n        elif Player1.score == House.score:\r\n            Player1.draw()\r\n\r\n        else:\r\n            if House.score > 21:\r\n                Player1.win(True)\r\n            else:\r\n                Player1.win(False)\r\n\r\n    print(Player1.money)\r\n    print(House)\r\n"
  },
  {
    "path": "functions/main.py",
    "content": "##\n# Functions Lecture\n##\n\n# -*- coding: utf-8 -*-\n\n# Assignment on Functions\n'''\nSyntax for a function:\n\ndef FunctionName(Input):\n    Action\n    return Output\n'''\n# define a function using a keyword def\n'''\nfunction name: addOne\ninput: Number\noutput: Output\n'''\n#The function addOne takes a Number as input and then adds 1 and then returns it\ndef addOne(Number):\n    Output = Number + 1                      #add 1 to a Number\n    return Output                            #return output\n\nVar = 0                                     #intialize to 0\nprint(Var)                                  #print value\n'''\nan argument is passed through a function.\n'''\nVar2 = addOne(Var)                          #calling a function addOne and is assigned to a variable\nVar3 = addOne(Var2)                         #calling a function addOne and is assigned to a variable\nVar4 = addOne(2)                            #a value is directly passed through a function and the output is\n                                            #assigned to a variable\n#print Var2, Var3 and Var4\nprint(Var2)\nprint(Var3)\nprint(Var4)\n\nVar4 = addOne(2.1)                         #float value is passed into a function\nprint(Var4)                                #print the value\nVar4 = addOne(2.1+3.4)                     #two float numbers are added and passed into a function\nprint(Var4)                                #print the value\n\n'''\nfunction addOneAddTwo takes two variable as an input and then returns a variable.\n'''\ndef addOneAddTwo(NumberOne, NumberTwo):\n    Output = NumberOne + 1                #add 1 to a variable NumberOne\n#    Output = Output + NumberTwo + 2\n    Output += NumberTwo + 2               #add 2, NumberTwo variable and Output\n    return Output                         #return Output variable\n\nSum = addOneAddTwo(1, 2)                 #call the function addOneTwo and pass two arguments directly\nprint(Sum)                               #print output\nSum = addOneAddTwo(Var2, Var3)           #call the function addOneTwo and pass two variable arguments\nprint(Sum)                               #print output\n"
  },
  {
    "path": "importing/Alternative-Import-Methods.py",
    "content": "##\n# Alternative Import Methods Lecture\n##\n\n# _*_ coding: utf-8 _*_\n\n# Importing the library 'random' as 'r' where 'r' is its nickname\n## from random import *\nimport random as r\n\n# import the function from the library\n## from random import randInt\n\n# Assign a random integer value to the variable 'randInt'\n## random.seed(1)\nrandInt = r.randint(0,10) #start<=N<=end\nprint(randInt)\n\n# Assign a random float value to the variable 'randFloat' between 0 and 1 only\nrandFloat = r.random() #0.0<=N<1.0\nprint(randFloat)\n\n# Assign a random float value to the variable 'randFloat' between any specified range\nrandUniform = r.uniform(1,1100) #start<=N<=end\nprint(randUniform)\n\n# Create a list 'simpleList' and print a random integer from that list\nsimpleList = [1,3,5,7,11]\npickElement = r.choice(simpleList)\nprint(pickElement)\nprint(simpleList)\n\n# shuffle the list using 'shuffle' function of 'random' library\nr.shuffle(simpleList)\nprint(simpleList)\n"
  },
  {
    "path": "importing/Guessing-Game-Part-A.py",
    "content": "##\n# Guessing Game, Part A Lecture\n##\n\n# _*_ coding: utf-8 _*_\n\n# import the fuction 'randint' from library random\nfrom random import randint\n\n## randint(a,b) -> a<=N<=b\n\n# set the variable 'randVal' with a random value between 0 to 100\nrandVal = randint(0,100)\n\n\nwhile(True):\n    guess = int(input('Please enter your guess:'))\n    # check if 'guess' and 'randVal' are equal\n    if guess == randVal:\n        # get out of the loop if they are equal\n        break\n    # check if 'guess' is less than 'randVal'\n    elif guess < randVal:\n        print('Your guess was too low')\n    # check if 'guess' is more than 'randVal'\n    else:\n        print('Too high')\n\n# print the correct answer\nprint('You guessed correctly with:',guess)\n"
  },
  {
    "path": "importing/Guessing-Game-Part-B.py",
    "content": "##\n# Guessing Game, Part B Lecture\n##\n\n# _*_ coding: utf-8 _*_\n\n# import 'random' fuction of 'random' library\nfrom random import random\n\n# import 'clock' function of 'time' library\nfrom time import clock\n\n# Set the value of variable 'randVal' as a random number\nrandVal = random() # 0.0 <=N <1.0\n## print(randVal)\n## time.clock() -> timevalue\n## time.clock() -> timevalue2\n\n# Set the values of upper and lower as 1.0 and 0.0 respectively\nupper = 1.0\nlower = 0.0\n## guess = 0.5 -> Too Low -> lower = 0.5\n## guess = 0.9 -> Too High -> upper = 0.9\n## guess = 0.5\n\n# Set the variable 'startTime' as the currect processor time\nstartTime = clock()\nwhile(True):\n    # set the variable 'guess' as the avarage of 'upper' and 'lower'\n    guess = (upper+lower)/2\n    # check if 'guess' and 'randVal' are equal\n    if guess == randVal:\n        # get out of the loop if they are equal\n        break\n    # check if 'guess' is less than 'randVal'\n    elif guess<randVal:\n        lower = guess\n    # check if 'guess' is more than 'randVal'\n    else :\n        upper = guess\n\n# Set the variable 'endTime' as the currect processor time\nendTime = clock()\n\n# print the 'guess'\nprint(guess)\n\n# print the time it took to run the loop\nprint('It took us:', endTime-startTime,'seconds')\n"
  },
  {
    "path": "importing/Introduction-to-Importing.py",
    "content": "##\n# Introduction to Importing Lecture\n##\n\n# _*_ coding: utf-8 _*_\n\n# Importing the library 'random' as 'r' where 'r' is its nickname\nimport random as r\n\n# Assign a random integer value to the variable 'randInt'\n# random.seed(1)\nrandInt = r.randint(0,10) #start<=N<=end\nprint(randInt)\n\n# Assign a random float value to the variable 'randFloat' between 0 and 1 only\nrandFloat = r.random() #0.0<=N<1.0\nprint(randFloat)\n\n# Assign a random float value to the variable 'randFloat' between any specified range\nrandUniform = r.uniform(1,11) #start<=N<=end\nprint(randUniform)\n"
  },
  {
    "path": "importing/Math-Library.py",
    "content": "##\n# Math Library Lecture\n##\n\n# _*_ coding: utf-8 _*_\n\n# import the library 'math'\nimport math\n\n# square root of the variable 'Val' using 'sqrt' function\nVal = 3.14\nsqrtVal = math.sqrt(Val)\nprint(sqrtVal) # sqrtVal**(2) = sqrtVal^2\n\n# exponential value of the variable 'Val' using 'exp' function\nexpVal = math.exp(Val) #e^(Val)\nprint(expVal)\n\n# factorial of the variable 'Val' using 'factorial' function and print it\nfactVal = math.factorial(math.floor(Val)) #5! = 5*4*3*2*1\nprint(factVal)\n\n# sine value of the variable 'Val' using sin function and print it\nsinVal = math.sin(Val)\nprint(sinVal)\n\n# the nearest integer which is less than the value of 'Val' and print it\nfloorVal = math.floor(Val)\nprint(floorVal)\n\n# the nearest integer which is greater than the value of 'Val' and print it\nceilingVal = math.ceil(Val)\nprint(ceilingVal)\n"
  },
  {
    "path": "importing/Time-Library.py",
    "content": "##\n# The Time Library Lecture\n##\n\n# _*_ coding: utf-8 _*_\n\n# import the 'time' library and print the time, processor takes to print the \"Hello World\"\nimport time\n\ncurrentTime = time.clock()\nprint(\"Hello\")\nprint(\"World\")\npastTime = time.clock()\nprint(pastTime - currentTime)\n\n# sleep the processor for 3 seconds using 'sleep' function\nprint(\"1\")\ntime.sleep(3)\nprint(\"2\")\n\n# print the integers from 1 to 10 in the interval break of 1 second\nfor i in range(1,11):\n    print(i)\n    time.sleep(1)\n"
  },
  {
    "path": "input and output/File-IO.py",
    "content": "##\r\n# File Input and Output Lecture\r\n##\r\n\r\n# _*_ coding: utf-8 _*_\r\n\r\n\r\n# Genral form to open a file with an option (\"r\":read, \"w\": write, \"a\": append, \"r+\": read and write)\r\n# File = open(\"Filename\",\"r\") # \"r\", \"w\", \"a\", \"r+\"\r\n# Once done with the file we can close it\r\n# File.close()\r\n\r\n# Create a list: sperate elements by a comma\r\nCountries = [\"London\", \"Paris\", \"New York\", \"Utah\", \"IceLand\"]\r\n# Let's call our list a VacationSpots\r\nVacationSpots = [\"London\", \"Paris\", \"New York\", \"Utah\", \"IceLand\"]\r\n\r\n# Creat a file\r\n# The option \"w\" will create the file if it doesn't exist but will override it if it exists already\r\n# This will create the file at the same folder of your python file code\r\nVacationFile = open(\"VacationPlaces\",\"w\")\r\n\r\n# We loop over our list to take each element and put it inside our file\r\nfor Spots in VacationSpots:\r\n    VacationFile.write(Spots) # Spots in this case has to be a string\r\n    # Or convert it to string if it is not\r\n    # VacationFile.write(str(Spots))\r\n\r\n# close the file\r\nVacationFile.close()\r\nprint(\"done\")\r\n\r\n# Open the file again: it is not mandatory to use the same variable\r\nVacationFile = open(\"VacationPlaces\",\"r\")\r\n\r\n# The following instruction will read all the content of our file and assign it to TheWholeFile\r\n# Note: this is usefull for small files but we will see other methods for bigger files\r\nTheWholeFile = VacationFile.read()\r\nprint(TheWholeFile)\r\n# Always close the file once done using it\r\nVacationFile.close()\r\n\r\n# We notice that the ouptut doesn't look very well\r\n# The pointer will just write any new element directly after the previous one\r\n# LondonParisNew YorkUtahIceLand\r\n\r\n# To solve this: we can add a space after each write operation\r\nVacationFile = open(\"VacationPlaces\",\"w\")\r\nfor Spots in VacationSpots:\r\n    # VacationFile.write(Spots+ \" \")\r\n    # Or to separate them by \",\"\r\n    # VacationFile.write(Spots+ \", \")\r\n    # We can also put elements in a new line\r\n    VacationFile.write(Spots+ \"\\n\")\r\nVacationFile.close()\r\n\r\n# We can read the file one by one\r\n# Line will have all the data for one line\r\nVacationFile = open(\"VacationPlaces\",\"r\")\r\n\r\n# We can read each line into a variable\r\n# We have a pointer that will read the file from the beginning\r\nFirstLine = VacationFile.readline()\r\nprint(FirstLine)\r\n# If we read the line again, the pointer will move to the next element\r\nSecondLine = VacationFile.readline()\r\nprint(SecondLine)\r\n\r\n# In this case we will start by the third line\r\nfor line in VacationFile:\r\n    print(line)  # We will a blank line separator since we have put \\n between our elements\r\n    # To specify how the end of line should be\r\n    print(line, end = \"\")  # take away the newLine\r\nVacationFile.close()\r\n\r\n# Append a new spot\r\nFinalSpot = \"Thailand\\n\"\r\n# Remember to not use \"w\" option, otherwise all the content of the file will be deleted\r\nVacationFile = open(\"VacationPlaces\", \"a\") # use the append option\r\n# Write to the end of the file\r\nVacationFile.write(FinalSpot)\r\nVacationFile.close()\r\n\r\nVacationFile = open(\"VacationPlaces\",\"r\") # Open file as reading\r\n# Loop over the file, line by line\r\nfor line in VacationFile:\r\n    print(line, end = \"\")\r\nVacationFile.close()\r\n\r\n# Another method to open a file without having to close it at the end\r\n# The file will be saved inside the variable VacationFile\r\nwith open(\"VacationPlaces\",\"r\") as VacationFile:\r\n    for line in VacationFile:\r\n        print(line)\r\n# The file is closed automatically\r\n\r\n# So the below instruction is no more valid since file is already closed\r\n# VacationFile.read()\r\n\r\n\"\"\"\r\n# We can do the above operation for multiple files\r\n# Example : read the content from 5 files (VacationPlaces1 ... VacationPlaces4)\r\nfor i in range(5):\r\n    with open(\"VacationPlaces\"+str(i),\"r\") as VacationFile:\r\n        for line in VacationFile:\r\n            print(line)\r\n\"\"\"\r\n"
  },
  {
    "path": "input and output/Introduction-to-IO.py",
    "content": "##\r\n# Introduction to Input and Output Lecture\r\n##\r\n\r\n# _*_ coding: utf-8 _*_\r\n\r\n\r\n# Display a message to the user to write an input that will be saved into the Var variable\r\nVar = input(\"Message to the user\")\r\n\r\nName = input(\"Please to enter your name: \")\r\n# Read back the name\r\nprint(Name)\r\n\r\n# All inputs are going to be imported as strings\r\nAge = input(\"Please enter your age: \")\r\n# Print out the Age\r\nprint(Age)\r\n\r\n# However, we cannot print the Age + 1 for example since Age is a string (ie: \"21\"+1)\r\n#print(Age+1)\r\n# For example: this will work\r\nprint(\"21\"+\"1\") # Gives 211\r\n# Or in case both of them are integers\r\nprint(21+1)\r\n\r\n# So we need to convert our input to an integer\r\n# But note that you can not put caracters like \"twenty one\"\r\nAge = int(input(\"Please enter your age: \")) # Age here will be an integer\r\n# The following instruction becames valid for now\r\nprint(Age+1)\r\n# Again, this is not valid because we are trying to add an integer(Age) to a string(\"1\")\r\n#print(Age+\"1\")\r\n# We can for now convert both of the inputs to strings\r\nprint(str(Age)+\"1\") # str(Age) = str(21) -> \"21\"\r\n# Age = 21\r\n\r\n# Another method is to convert the Age later\r\nAge = input(\"Please enter your age: \") # Age here will be an integer\r\n# The following instruction becames valid for now\r\nprint(int(Age)+1) # This will temporary convert Age string to integer\r\n\r\n\r\n# Create an empty list\r\nScores = []\r\n# Ask the user for 5 different scores using a loop\r\nfor i in range(5):   # Create a range , variable i will start by value 0 to 4 at the end of the loop ([0,4[)\r\n    # currentScore = int(input(\"Please enter the score: \"))\r\n    # Or we can also print which score to put: but accept only integers\r\n    # currentScore = int(input(\"Please enter the score \" + str(i+1) + \": \")) # Add 1 because i will start by 0\r\n    # We can also convert it to float so also decimals could be taken into account\r\n    currentScore = float(input(\"Please enter the score \" + str(i+1) + \": \"))\r\n    # Append the score to our list (at the end) using the predefined function : append\r\n    Scores.append(currentScore)\r\n    # Print the score entered by the user, we use comma to format our variable to string automatically\r\n    # print(\"The score you entered was: \",currentScore)\r\n    # We can put something else afterwards\r\n    # print(\"The score you entered was: \",currentScore, \"nice\")\r\n    # We can use \"\\n\" to put our score in a new line: \"\\\" is used to mention a special caracter\r\n    # print(\"The score you entered was:\\n\",currentScore)\r\n    # To convert our score to an integer\r\n    print(\"The score you entered was: \\n\"+str(currentScore))\r\n\r\n# print is actually a function that takes those inputs separated by \",\" and prints them\r\n# def FunctionName(input1,input2):\r\n#       Action\r\n\r\n\r\n# What happens inside our loop ? (Below an example for integers)\r\n#   Scores = []\r\n#   Scores = [70]                   # First loop i = 0\r\n#   Scores = [70, 12]               # First loop i = 1\r\n#   Scores = [70, 12, 45]           # First loop i = 2\r\n#   Scores = [70, 12, 45, 56]       # First loop i = 3\r\n#   Scores = [70, 12, 45, 56, 99]   # First loop i = 4\r\n\r\n# Print the list Scores\r\nprint(Scores)\r\n"
  },
  {
    "path": "input and output/Participant-Data-Part-A.py",
    "content": "##\r\n# Participant Data, Part A Lecture\r\n##\r\n\r\n# _*_ coding: utf-8 _*_\r\n\r\n\r\n# Create the number of participants that are allowed to register\r\nParticipantNumber = 2\r\nParticipantData = []  # For now an empty list to store Participant Data\r\n\r\n# Create a counter for the registered participants\r\nregisteredParticipants = 0\r\n\r\n# This is the file where we are going to write our data\r\noutputFile = open(\"PaticipantData.txt\",\"w\")\r\n\r\n# Loop over the participants\r\nwhile(registeredParticipants < ParticipantNumber):\r\n    # Add a temporary data holder as a list\r\n    tempPartData = [] # name, country of origin, age\r\n    # Ask for user input to add his name\r\n    name = input(\"Please enter your name: \")\r\n    # Append the name to the temporary data\r\n    tempPartData.append(name)\r\n    country = input(\"Please enter your country of origin: \")\r\n    # Append the country to the temporary data\r\n    tempPartData.append(country)\r\n    # Ask for user input to add his age\r\n    age = int(input(\"Please enter your age: \"))  # Convert the input to integer\r\n    # Append the age to the temporary data\r\n    tempPartData.append(age)\r\n    # Print the tempData\r\n    print (tempPartData)\r\n    # Save our temporary data to the ParticipantData\r\n    ParticipantData.append(tempPartData)  # [tempPartData] = [[name,country,age]]\r\n    print(ParticipantData)\r\n    # Increase the registeredParticipants number\r\n    registeredParticipants +=1 # = registeredParticipants + 1\r\n\r\n# Write everything to a file\r\n# Each participant is represented by a list\r\nfor participant in ParticipantData:\r\n    # loop over particpant data\r\n    for data in participant:\r\n        outputFile.write(str(data))  # Convert data to string and write it to the file\r\n        # We need to add extra formatting otherwise we will have it similar to MaxU.s.21\r\n        outputFile.write(\" \")  # MaxU.s.21\r\n    # Add each participant data in a new line\r\n    outputFile.write(\"\\n\")\r\n\r\n\r\noutputFile.close()\r\n"
  },
  {
    "path": "input and output/Participant-Data-Part-B.py",
    "content": "##\r\n# Participant Data, Part B Lecture\r\n##\r\n\r\n# _*_ coding: utf-8 _*_\r\n\r\n\r\n# Create the number of participants that are allowed to register\r\nParticipantNumber = 5\r\nParticipantData = []  # For now an empty list to store Participant Data\r\n\r\n# Create a counter for the registered participants\r\nregisteredParticipants = 0\r\n\r\n# This is the file where we are going to write our data\r\noutputFile = open(\"PaticipantData.txt\",\"w\")\r\n\r\n# Loop over the participants\r\nwhile(registeredParticipants < ParticipantNumber):\r\n    # Add a temporary data holder as a list\r\n    tempPartData = [] # name, country of origin, age\r\n    # Ask for user input to add his name\r\n    name = input(\"Please enter your name: \")\r\n    # Append the name to the temporary data\r\n    tempPartData.append(name)\r\n    country = input(\"Please enter your country of origin: \")\r\n    # Append the country to the temporary data\r\n    tempPartData.append(country)\r\n    # Ask for user input to add his age\r\n    age = int(input(\"Please enter your age: \"))  # Convert the input to integer\r\n    # Append the age to the temporary data\r\n    tempPartData.append(age)\r\n    # Print the tempData\r\n    print (tempPartData)\r\n    # Save our temporary data to the ParticipantData\r\n    ParticipantData.append(tempPartData)  # [tempPartData] = [[name,country,age]]\r\n    print(ParticipantData)\r\n    # Increase the registeredParticipants number\r\n    registeredParticipants +=1 # = registeredParticipants + 1\r\n\r\n# Write everything to a file\r\n# Each participant is represented by a list\r\nfor participant in ParticipantData:\r\n    # loop over particpant data\r\n    for data in participant:\r\n        outputFile.write(str(data))  # Convert data to string and write it to the file\r\n        # We need to add extra formatting otherwise we will have it similar to MaxU.s.21\r\n        outputFile.write(\" \")  # MaxU.s.21\r\n    # Add each participant data in a new line\r\n    outputFile.write(\"\\n\")\r\n\r\n# Always remember to close your file\r\noutputFile.close()\r\n\r\n# Reading all this data from the file\r\ninputFile = open(\"PaticipantData.txt\",\"r\")\r\n# Store all the file data into an inputList\r\ninputList = []\r\n# Read through the file line by line using a for loop\r\nfor line in inputFile:\r\n    # We need to read back from the file all participant data\r\n    tempParticipant = line.strip(\"\\n\").split()\r\n    # This is equivalent to the following\r\n    # \"Max U.S. 21 \\n\".strip(\"\\n\") -> \"Max U.S. 21 \"  // Takes out the \\n\r\n    # \"Max U.S. 21 \".split() -> [\"Max\",\"U.S.\",\"21\"]  // Split the string and puts it's part into a list\r\n    print(tempParticipant)\r\n    # Let's append the data to the inputList\r\n    inputList.append(tempParticipant)\r\n    print(inputList)\r\n\r\n# let's save the data into a dictionnary\r\nAge = {}\r\n# loop over the list to get each participant's age\r\nfor part in inputList:\r\n    # Use a temporary variable\r\n    tempAge = int(part[-1])  # ie: int('21') -> 21\r\n    # We can access the last element using this method\r\n    # Only add the Age to the dictionnary if it doesn't exist already\r\n    if tempAge in Age:\r\n        Age[tempAge] += 1 # means there is one more person with the same age\r\n    else:\r\n        Age[tempAge] = 1 # Otherwise, put it inside the dictionnary and give it value 1\r\n\r\nprint(Age)  # ie: {25: 2, 22: 1, 21: 1, 26: 1}\r\n\r\n# Always remember to close your file\r\noutputFile.close()\r\n"
  },
  {
    "path": "input and output/Participant-Data-Part-C.py",
    "content": "##\r\n# Participant Data, Part C Lecture\r\n##\r\n\r\n# _*_ coding: utf-8 _*_\r\n\r\n\r\n# Create the number of participants that are allowed to register\r\nParticipantNumber = 5\r\nParticipantData = []  # For now an empty list to store Participant Data\r\n\r\n# Create a counter for the registered participants\r\nregisteredParticipants = 0\r\n\r\n# This is the file where we are going to write our data\r\noutputFile = open(\"PaticipantData.txt\",\"w\")\r\n\r\n# Loop over the participants\r\nwhile(registeredParticipants < ParticipantNumber):\r\n    # Add a temporary data holder as a list\r\n    tempPartData = [] # name, country of origin, age\r\n    # Ask for user input to add his name\r\n    name = input(\"Please enter your name: \")\r\n    # Append the name to the temporary data\r\n    tempPartData.append(name)\r\n    country = input(\"Please enter your country of origin: \")\r\n    # Append the country to the temporary data\r\n    tempPartData.append(country)\r\n    # Ask for user input to add his age\r\n    age = int(input(\"Please enter your age: \"))  # Convert the input to integer\r\n    # Append the age to the temporary data\r\n    tempPartData.append(age)\r\n    # Print the tempData\r\n    print (tempPartData)\r\n    # Save our temporary data to the ParticipantData\r\n    ParticipantData.append(tempPartData)  # [tempPartData] = [[name,country,age]]\r\n    print(ParticipantData)\r\n    # Increase the registeredParticipants number\r\n    registeredParticipants +=1 # = registeredParticipants + 1\r\n\r\n# Write everything to a file\r\n# Each participant is represented by a list\r\nfor participant in ParticipantData:\r\n    # loop over particpant data\r\n    for data in participant:\r\n        outputFile.write(str(data))  # Convert data to string and write it to the file\r\n        # We need to add extra formatting otherwise we will have it similar to MaxU.s.21\r\n        outputFile.write(\" \")  # MaxU.s.21\r\n    # Add each participant data in a new line\r\n    outputFile.write(\"\\n\")\r\n\r\n# Always remember to close your file\r\noutputFile.close()\r\n\r\n# Reading all this data from the file\r\ninputFile = open(\"PaticipantData.txt\",\"r\")\r\n# Store all the file data into an inputList\r\ninputList = []\r\n# Read through the file line by line using a for loop\r\nfor line in inputFile:\r\n    # We need to read back from the file all participant data\r\n    tempParticipant = line.strip(\"\\n\").split()\r\n    # This is equivalent to the following\r\n    # \"Max U.S. 21 \\n\".strip(\"\\n\") -> \"Max U.S. 21 \"  // Takes out the \\n\r\n    # \"Max U.S. 21 \".split() -> [\"Max\",\"U.S.\",\"21\"]  // Split the string and puts it's part into a list\r\n    print(tempParticipant)\r\n    # Let's append the data to the inputList\r\n    inputList.append(tempParticipant)\r\n    print(inputList)\r\n\r\n# let's save the data into a dictionnary\r\nAge = {}\r\n# loop over the list to get each participant's age\r\nfor part in inputList:\r\n    # Use a temporary variable\r\n    tempAge = int(part[-1])  # ie: int('21') -> 21\r\n    # We can access the last element using this method\r\n    # Only add the Age to the dictionnary if it doesn't exist already\r\n    if tempAge in Age:\r\n        Age[tempAge] += 1 # means there is one more person with the same age\r\n    else:\r\n        Age[tempAge] = 1 # Otherwise, put it inside the dictionnary and give it value 1\r\n\r\nprint(Age)  # ie: {25: 2, 22: 1, 21: 1, 26: 1}\r\n\r\n\r\n# We can also get other participant's data like country int(part[1]) or name int(part[0])\r\nCountries = {}\r\n# loop over the list to get each participant's country\r\nfor part in inputList:\r\n    # Use a temporary variable\r\n    tempCountry = part[1] # No need to convert : it's already a string\r\n    # We can access the last element using this method\r\n    # Only add the Age to the dictionnary if it doesn't exist already\r\n    if tempCountry in Countries:\r\n        Countries[tempCountry] += 1 # means there is one more person with the same age\r\n    else:\r\n        Countries[tempCountry] = 1 # Otherwise, put it inside the dictionnary and give it value 1\r\n\r\nprint(\"Countries that attended:\",Countries)\r\n\r\n# Find the oldest age\r\nOldest = 0              # Let's assume this is the minimum value our age can have\r\nYoungest = 100          # Let's assume this is the maximum value our age can have\r\nmostOccuringAge = 0     # To save the most occurant age\r\ncounter = 0\r\n\r\n# Loop over the Age dictionnary\r\nfor tempAge in Age:\r\n    # In the first time Oldest = first tempAge since the previous value was 0\r\n    # In each loop: if we have found a new bigger value, we will assign it to variable Oldest\r\n    if tempAge > Oldest:\r\n        Oldest = tempAge\r\n    # Otherwise, Oldest will not change and we'll assign it to the Youngest\r\n    if tempAge < Youngest:\r\n        Youngest = tempAge\r\n    # Access the value of each key in dictionary, counter will get the value for most occuring age\r\n    if Age[tempAge] >= counter:\r\n       counter = Age[tempAge]\r\n       # Get the dictionnary key equivalent to mostOccurongAge\r\n       mostOccuringAge = tempAge\r\n\r\n# Print the Oldest Age\r\nprint(Oldest)\r\nprint(Youngest)\r\nprint(\"Most occuring age is:\",mostOccuringAge,\"with\",counter,\"participants\")\r\n\r\n# Always remember to close your file\r\ninputFile.close()\r\n"
  },
  {
    "path": "input and output/Participant-Data-Part-D.py",
    "content": "##\r\n# Participant Data, Part D Lecture\r\n##\r\n\r\n# _*_ coding: utf-8 _*_\r\n\r\n\r\n# Create the number of participants that are allowed to register\r\nParticipantNumber = 5\r\nParticipantData = []  # For now an empty list to store Participant Data\r\n\r\n# Create a counter for the registered participants\r\nregisteredParticipants = 0\r\n\r\n\"\"\"\r\n# This is the file where we are going to write our data\r\noutputFile = open(\"PaticipantData.txt\",\"w\")\r\n\r\n# Loop over the participants\r\nwhile(registeredParticipants < ParticipantNumber):\r\n    # Add a temporary data holder as a list\r\n    tempPartData = [] # name, country of origin, age\r\n    # Ask for user input to add his name\r\n    name = input(\"Please enter your name: \")\r\n    # Append the name to the temporary data\r\n    tempPartData.append(name)\r\n    country = input(\"Please enter your country of origin: \")\r\n    # Append the country to the temporary data\r\n    tempPartData.append(country)\r\n    # Ask for user input to add his age\r\n    age = int(input(\"Please enter your age: \"))  # Convert the input to integer\r\n    # Append the age to the temporary data\r\n    tempPartData.append(age)\r\n    # Print the tempData\r\n    print (tempPartData)\r\n    # Save our temporary data to the ParticipantData\r\n    ParticipantData.append(tempPartData)  # [tempPartData] = [[name,country,age]]\r\n    print(ParticipantData)\r\n    # Increase the registeredParticipants number\r\n    registeredParticipants +=1 # = registeredParticipants + 1\r\n\r\n# Write everything to a file\r\n# Each participant is represented by a list\r\nfor participant in ParticipantData:\r\n    # loop over particpant data\r\n    for data in participant:\r\n        outputFile.write(str(data))  # Convert data to string and write it to the file\r\n        # We need to add extra formatting otherwise we will have it similar to MaxU.s.21\r\n        outputFile.write(\" \")  # MaxU.s.21\r\n    # Add each participant data in a new line\r\n    outputFile.write(\"\\n\")\r\n\r\n# Always remember to close your file\r\noutputFile.close()\r\n\"\"\"\r\n\r\n\r\n# Reading all this data from the file\r\ninputFile = open(\"PaticipantData.txt\",\"r\")\r\n# Store all the file data into an inputList\r\ninputList = []\r\n# Read through the file line by line using a for loop\r\nfor line in inputFile:\r\n    # We need to read back from the file all participant data\r\n    tempParticipant = line.strip(\"\\n\").split()\r\n    # This is equivalent to the following\r\n    # \"Max U.S. 21 \\n\".strip(\"\\n\") -> \"Max U.S. 21 \"  // Takes out the \\n\r\n    # \"Max U.S. 21 \".split() -> [\"Max\",\"U.S.\",\"21\"]  // Split the string and puts it's part into a list\r\n    print(tempParticipant)\r\n    # Let's append the data to the inputList\r\n    inputList.append(tempParticipant)\r\n    print(inputList)\r\n\r\n# let's save the data into a dictionnary\r\nAge = {}\r\n# loop over the list to get each participant's age\r\nfor part in inputList:\r\n    # Use a temporary variable\r\n    tempAge = int(part[-1])  # ie: int('21') -> 21\r\n    # We can access the last element using this method\r\n    # Only add the Age to the dictionnary if it doesn't exist already\r\n    if tempAge in Age:\r\n        Age[tempAge] += 1 # means there is one more person with the same age\r\n    else:\r\n        Age[tempAge] = 1 # Otherwise, put it inside the dictionnary and give it value 1\r\n\r\nprint(Age)  # ie: {25: 2, 22: 1, 21: 1, 26: 1}\r\n# Find the oldest age\r\nOldest = 0  # Let's assume this is the minimum value our age can have\r\n# Loop over the Age dictionnary\r\nfor tempAge in Age:\r\n    # In the first time Oldest = first tempAge since the previous value was 0\r\n    # In each loop: if we have found a new bigger value, we will assign it to variable Oldest\r\n    if tempAge > Oldest:\r\n        Oldest = tempAge\r\n    # Otherwise, Oldest will not change\r\n\r\n# Print the Oldest Age\r\n\r\n# Always remember to close your file\r\ninputFile.close()\r\n"
  },
  {
    "path": "input and output/Tic-Tac-Toe-Part-A.py",
    "content": "##\r\n# Tic Tac Toe, Part A Lecture\r\n##\r\n\r\n# _*_ coding: utf-8 _*_\r\n\r\n\"\"\"\r\n# The game should be similar to\r\n# | |  0\r\n#----- 1\r\n# | |  2\r\n#----- 3\r\n# | |  4\r\n\"\"\"\r\n\r\n#!python3\r\n\r\n# Define a function\r\ndef drawField():\r\n    for row in range(5):  #0,1,2,3,4\r\n        # if row is even row write \" | |  \"\r\n        if row%2 == 0:\r\n            # print writing lines\r\n            for column in range(5):  # will take values 0,1,2,3,4\r\n                # if column is even, we will print a space\r\n                if column%2 == 0:\r\n                    if column != 4:\r\n                        print(\" \",end=\"\") # Continue in the same line\r\n                    else:\r\n                        print(\" \") # Jump to the next line\r\n                else:\r\n                    print(\"|\",end=\"\")\r\n        else:\r\n            print(\"-----\")\r\n\r\n\"\"\"\r\n# We need to do the following\r\n1. Apply and Save the move\r\n2. Check which player turn is \"X\" or \"O\"\r\n\"\"\"\r\n\r\n# Create a variable for the Players\r\nPlayer = 1\r\n# Create a list with each element corresponds to a column\r\n# currentField = [element1, element2, element3]\r\n# Let's simulate our playing field\r\n# In the first time, each list that correpond to a column will contains 3 empty spaces for the rows\r\ncurrentField = [[\" \", \" \", \" \"], [\" \", \" \", \" \"], [\" \", \" \", \" \"]] # A list that contains 3 lists\r\n\r\n\r\n# Create an infinite loop for the gamez\r\nwhile(True): # True == True / is always true (We can also use while(1))\r\n    # Display the player's turn\r\n    print(\"Players turn: \",Player)\r\n    # Ask user for input: to specify the desired row and column\r\n    MoveRow = int(input(\"Please enter the row\\n\"))       # Convert the row to integer\r\n    MoveColumn = int(input(\"Please enter the column\\n\")) # Convert the column to integer\r\n    if Player == 1:\r\n        # Make move for player 1\r\n        # Access our current field\r\n        currentField[MoveColumn][MoveRow] = \"X\"\r\n        # Once Player 1 make his move we change the Player to 2\r\n        Player = 2\r\n    else:\r\n        # Make move for player 2\r\n        currentField[MoveColumn][MoveRow] = \"O\"\r\n        Player = 1\r\n    # At the end, print the current field\r\n    print(currentField)\r\n"
  },
  {
    "path": "input and output/Tic-Tac-Toe-Part-B.py",
    "content": "##\r\n# Tic Tac Toe, Part B Lecture\r\n##\r\n\r\n# _*_ coding: utf-8 _*_\r\n\r\n\r\n\"\"\"\r\n# The game should be similar to\r\n# | |  0\r\n#----- 1\r\n# | |  2\r\n#----- 3\r\n# | |  4\r\n\"\"\"\r\n\r\n#!python3\r\n\r\n# Define the function drawField that will print the game field\r\n# We will try to put our current field into the draw field\r\n\r\ndef drawField(field):\r\n    for row in range(5):  #0,1,2,3,4\r\n                          #0,.,1,.,2\r\n        # if row is even row write \" | |  \"\r\n        if row%2 == 0:\r\n            practicalRow = int(row/2)\r\n            # print writing lines\r\n            # In this case , we have to adapt our field (3*3) to the actual drawing (5*5)\r\n            # We can divde by 2 to get the correct maping\r\n            for column in range(5):  # will take values 0 (in drawing) -> 0 (in actual field), 1->., 2->1, 3->., 4->2\r\n                # if column is even, we will print a space\r\n                # The even columns gives us the move of each player\r\n                if column%2 == 0: # Values 0,2,4\r\n                    # The actual column that should be used in our field\r\n                    # Make sure our values are integers\r\n                    practicalColumn = int(column/2)  # Values 0,1,2\r\n                    if column != 4:\r\n                        # Print the specific field\r\n                        print(field[practicalColumn][practicalRow],end=\"\") # Continue in the same line\r\n                    else:\r\n                        print(field[practicalColumn][practicalRow]) # Jump to the next line\r\n                else:\r\n                    # The odd value just give us vertical lines\r\n                    print(\"|\",end=\"\")\r\n        else:\r\n            print(\"-----\")\r\n\r\n\"\"\"\r\n# We need to do the following\r\n1. Apply and Save the move\r\n2. Check which player turn is \"X\" or \"O\"\r\n\"\"\"\r\n\r\n# Create a variable for the Players\r\nPlayer = 1\r\n# Create a list with each element corresponds to a column\r\n# currentField = [element1, element2, element3]\r\n# Let's simulate our playing field\r\n# In the first time, each list that correpond to a column will contains 3 empty spaces for the rows\r\ncurrentField = [[\" \", \" \", \" \"], [\" \", \" \", \" \"], [\" \", \" \", \" \"]] # A list that contains 3 lists\r\n\r\n# We will draw the current field\r\ndrawField(currentField)\r\n\r\n# Create an infinite loop for the gamez\r\nwhile(True): # True == True / is always true (We can also use while(1))\r\n    # Display the player's turn\r\n    print(\"Players turn: \",Player)\r\n    # Ask user for input: to specify the desired row and column\r\n    MoveRow = int(input(\"Please enter the row\\n\"))       # Convert the row to integer\r\n    MoveColumn = int(input(\"Please enter the column\\n\")) # Convert the column to integer\r\n    if Player == 1:\r\n        # Make move for player 1\r\n        # Access our current field\r\n        # We only want to make one move when that specific field is empty\r\n        if currentField[MoveColumn][MoveRow] == \" \":\r\n            currentField[MoveColumn][MoveRow] = \"X\"\r\n            # Once Player 1 make his move we change the Player to 2\r\n            Player = 2\r\n    else:\r\n        # Make move for player 2\r\n        if currentField[MoveColumn][MoveRow] == \" \":\r\n            currentField[MoveColumn][MoveRow] = \"O\"\r\n            Player = 1\r\n\r\n    # At the end, draw the current field representation\r\n    drawField(currentField)\r\n"
  },
  {
    "path": "lists/main.py",
    "content": "##\n# Lists Lecture\n##\n\n# -*- coding: utf-8 -*-\n\n\nTestList = [\"element1\", \"element2\", \"element3\"]             #TestList is a list with three elements\n#Scores is a list with different data types\nScores = [70, 85, 67.5, 90, 80]\nprint(Scores)                                                #print Scores list\n'''\nelements of a list can be accessed with a index inside a square bracket\nAccessing list elements. The first element of a list starts from 0\n'''\nprint(Scores[0])                               #prints 1st element of a list\nprint(Scores[1])                               #prints 2nd element of a list\nprint(Scores[2])                               #prints 3rd element of a list\nprint(Scores[3])                               #prints 4th element of a list\nprint(Scores[4])                               #prints 5th element of a list\n'''\nAccessing list in a reverse order\n'''\nprint(Scores[-1])                              #prints last element of a list\nprint(Scores[-2])                              #prints 2nd last element of a list\nprint(Scores[-3])                              #prints 3rd last element of a list\nprint(Scores[-4])                              #prints 4th last element of a list\nprint(Scores[-5])                              #prints 5th last element of a list\n'''\nAccessing multiple elements from a list.\nIt can be done using List[first : last]\n'''\nprint(Scores[0:2])                             #access elements from index 0 to index 1\nprint(Scores[0:3])                             #access elements from index 0 to index 2\nprint(Scores[1:3])                             #access elements from index 1 to index 2\nprint(Scores[2:])                              #access all elements from index 2 to end\nprint(Scores[1:])                              #access all elements from index 1 to end\n\n'''\nValues of a list can be changed\n'''\nScores = [70, 85, 67.5, 90, 80]                #initialize list with values\nprint(Scores)                                  #print a list named Scores\nScores[0] = 75                                 #assign a value of 75 to the first element of a list Scores\nprint(Scores)                                  #print the Scores\nScores = [70, 85, 67.5, 90, 80]                #initialize list with values\nScores[0] = 6.0                                #assign a float value 6.0 to the first element of a list\nprint(Scores)                                  #print Scores\nScores = [70, 85, 67.5, 90, 80]                #initialize list with values\nprint(Scores)                                  #print Scores\nScores[0] = \"Hello\"                            #assign a string 'Hello' to the first element of a list\nprint(Scores)                                  #print Scores\nScores = [70, 85, 67.5, 90, 80]                #initialize list with values\nprint(Scores)                                 #print Scores\nScores[1:3] = []                               #remove elements 2nd to 3rd from the list\nprint(Scores)                                 #print Scores\nScores = [70, 85, 67.5, 90, 80]               #initialize list with values\nprint(Scores)                                 #print Scores\nScores[2:3] = []                              #remove 3rd element from the list.\nprint(Scores)                                 #print Scores list\nScores = [70, 85, 67.5, 90, 80]               #initialize list with values\nprint(Scores)                                 #print Scores list\nScores[2] = []                                #assign an empty list to element 3rd (index 2nd)\nprint(Scores)                                 #print Scores\nScores = [70, 85, 67.5, 90, 80]               #initialize list with values\nprint(Scores)                                 #print Scores\nScores[2] = [\"Hello\", \"World\"]                #assign a list to 3rd element (index 2nd)\nprint(Scores)                                 #print Scores\nprint(Scores[2])                              #accessing the 3rd element\n'''\nAccessing list within a list\n'''\nprint(Scores[2][0])                           #access the list within a list\nprint(Scores[2][1])\nScores = [70, 85, 67.5, 90, 80]              #initialize list with values\nprint(Scores)                                #print Scores\nScores.append(82)                            #appending value at the end of list\nprint(Scores)                                #print Scores\n"
  },
  {
    "path": "loops/Breaking-and-Continuing-in-Loops.py",
    "content": "##\r\n# Breaking and Continuing in Loops Lecture\r\n##\r\n\r\n# -*- coding: utf-8 -*-\r\n\r\n\r\nParticipants = [\"Jen\", \"Alex\", \"Tina\", \"Joe\", \"Ben\"]              #create a list of 5 elements.\r\n\r\nposition = 0                                                      #set position is equal to 0\r\nfor name in Participants:                                         #loop over each element of list\r\n    if name == \"Tina\":                                            #check if the element of list matches to \"Tina\"\r\n        break                                                     #come outside of loop if the condition is met\r\n    position = position + 1                                       #increment variable position by 1\r\n\r\nprint(position)                                                   #print the value of position\r\n\r\nposition = 0                                                   #set position is equal to 0\r\nfor name in Participants:                                      #loop over each element of list\r\n    if name == \"Tina\":                                          #check if the element of list matches to \"Tina\"\r\n        print(\"About to break\")                               #print message\r\n        break                                                   #come outside of loop if the condition is met\r\n    print(\"About to increment\")                                #print message\r\n    position = position + 1                                   #increment variable position by 1\r\n\r\nprint(position)                                               #print the value of position\r\n\r\n'''\r\nfinds the index of matched string from the list\r\n'''\r\nIndex = 0                                           #set Index to 0\r\nfor currentIndex in range(len(Participants)):       #loop over all elements in list\r\n    print(currentIndex)                             #print value of currentIndex\r\n    if Participants[currentIndex] == \"Joe\":         #check if list element is equal to Joe\r\n        print(\"Have Breaked\")                       #print message\r\n        break                                      #come out of the loop\r\n    print(\"Not Breaked\")                           #print message\r\nprint(currentIndex+1)                              #print currentIndex of matched element\r\n\r\nfor number in range(10):                           #loop from range of 0 to 10\r\n    if number%3 == 0:                              #check remainder is 0 if divided by 3\r\n        print(number)                              #print value of a number\r\n        print(\"Divisible by 3\")                    #print message\r\n        continue                                    #continue\r\n    print(number)                                  #print value of number\r\n    print(\"Not Divisible by 3\")                    #print message\r\n"
  },
  {
    "path": "loops/Introduction-to-Loops.py",
    "content": "##\r\n# Introduction to Loops Lecture\r\n##\r\n\r\n# -*- coding: utf-8 -*-\r\n\r\n\r\n\r\nWord = \"Hello\"                       #initialize a variable Word with string \"Hello\"\r\nLetters = []                         #create an empty list\r\n'''\r\nloop through each character of a string, print each character. Check if the character\r\nin a string matches e, print a string and then append it into List\r\n'''\r\nfor w in Word:                       #loop over each character\r\n    print(w)                         #print a character\r\n    if w == \"e\":                     #check if a character matches 'e'\r\n        print(\"What a funny letter\")\r\n    Letters.append(w)                #Append each character into List.\r\nprint(Letters)                       #print the list\r\n'''\r\nLoop through each character stored in list Letters and then print each character\r\n'''\r\nfor l in Letters:                    #Print each character in the list named Letters\r\n    print(l)\r\n\r\n'''\r\nCreate a list of 5 elements. Loop through each element in the list and print it.\r\n'''\r\nNumbers = [1, 2, 3, 4, 5]          #creating a list named Numbers with 5 integer elements\r\nfor l in Numbers:                  #loop over each element in list using for loop\r\n    print(l)                       #print each element\r\n\r\n'''\r\nprint all the numbers which has a remainder of zero when divisible by 2.\r\n'''\r\nfor l in Numbers:                   #loop over all elements in the list\r\n    if l%2 == 0:                    #check if remainder is 0 when divided by 2\r\n        print(l)                    #print the number\r\n'''\r\nprint all the numbers which has a remainder of one when divisible by 2.\r\n'''\r\nfor l in Numbers:                   #loop over all elements in the list\r\n    if l%2 == 1:                    #check if remainder is 1 when divided by 2\r\n        print(l)                    #print the number\r\n\r\nNumbers = []                        #create an empty list\r\nfor num in range(10):               #loop over elements from 0 to 9\r\n    Numbers.append(num)             #append each number to List\r\n    print(num)                      #print each number\r\nprint(Numbers)                     #print the list.\r\n\r\n'''\r\nAbove process is repeated with value changed to 100. It prints all numbers from 0 to 99 and are appended\r\nin list Numbers.\r\n'''\r\nNumbers = []                      #create an empty list\r\nfor num in range(100):            #loop over elements from 0 to 9\r\n    Numbers.append(num)           #append each number to List\r\n    print(num)                    #print each number\r\nprint(Numbers)                    #print the list\r\n\r\n'''\r\nrange is a function which takes an integer as an input.\r\nrange(1, 10, 2): 1 is the start, 10 is end and 2 is the step size\r\n'''\r\nNumbers = []                      #create an empty list\r\nfor num in range(1, 10, 2):       #loop over an elements from 1 to 10 with difference of 2\r\n    Numbers.append(num)           #append each number to List\r\n    print(num)                    #print each number\r\nprint(Numbers)                    #print the list\r\n\r\nNumbers = []                      #create an empty list\r\nfor num in range(-1, -12, -2):    #loop over an elements from -1 to -12 with difference of -2\r\n    Numbers.append(num)           #append each number to List\r\n    print(num)                    #print each number\r\nprint(Numbers)                    #print list\r\n\r\n'''\r\nAbove example is repeated with a range now changed  from -1 to -13 at a difference of 3.\r\n'''\r\nNumbers = []\r\nfor num in range(-1, -13, 3):\r\n    Numbers.append(num)\r\n    print(num)\r\nprint(Numbers)\r\n"
  },
  {
    "path": "loops/Making-Shapes-With-Loops.py",
    "content": "##\r\n# Making Shapes With Loops Lecture\r\n##\r\n\r\n# -*- coding: utf-8 -*-\r\n\r\nLength = 10                  #set a variable name Length = 10\r\n'''\r\nOn each loop character c is printed n number of times which is defined by pos.\r\n\"c\"*2 means character c is repeated twice\r\n'''\r\nfor pos in range(1, 10):     #loop from 1 to 9\r\n    print(\"c\"*pos)           #print character c\r\n\r\nLength = 10                   #set a variable name Length = 10\r\nToPrint = \"a\"                 #a variable name ToPrint is assigned a character \"a\"\r\nfor pos in range(1, Length + 1): #loop from 1 to value of Length + 1\r\n    print(ToPrint*pos)         #print character n number of times\r\n\r\n'''\r\nLoop in a decreasing order from 10 to 0 and print a character n times on each decreasing loop\r\n'''\r\nfor pos in range(Length, 0, -1):\r\n    print(ToPrint*pos)\r\n'''\r\nLoop in a increasing order from 1 to 12 and print a character n times on each increasing loop\r\n'''\r\nLength = 12\r\nToPrint = \"1\"                  #a variable name ToPrint is assigned a character \"1\"\r\nfor pos in range(1, Length + 1):\r\n    print(ToPrint*pos)\r\n'''\r\nLoop in a decreasing order from 12 to 0 and print a character \"1\" n times on each decreasing loop\r\n'''\r\nfor pos in range(Length, 0, -1):\r\n    print(ToPrint*pos)\r\n"
  },
  {
    "path": "loops/Nested-Loops.py",
    "content": "##\r\n# Nested Loops Lecture\r\n##\r\n\r\n# -*- coding: utf-8 -*-\r\n\r\n\r\n# | |\r\n#-----\r\n# | |\r\n#-----\r\n# | |\r\n'''\r\nfor loop\r\n'''\r\nfor row in range(5):               #loop 5 times\r\n    if row%2 == 0:                 #if remainder is equal to zero when divided by 2\r\n        print(\" | | \")             #print message\r\n    else:                          #if above condition is false\r\n        print(\"-----\")             #print message\r\n\r\n'''\r\n | |\r\n-----\r\n | |\r\n-----\r\n | |\r\nprinting the above shapes\r\n'''\r\nfor row in range(5):              #loop 5 times\r\n    if row%2 == 0:                #if remainder is equal to zero when divided by 2\r\n        for column in range(1, 6): #created a nested loop of range from 1 to 6\r\n            if column%2 == 1:      #check if remainder is 1 when divided by 2\r\n                if column != 5:    #if variable column not equal to 5\r\n                    print(\" \", end = \"\")   #print space and in the same line\r\n                else:\r\n                    print(\" \")     #print in next line\r\n            else:\r\n                print(\"|\", end = \"\") #print a pipe in  same line\r\n\r\n    else:\r\n        print(\"-----\")               #print dash\r\n"
  },
  {
    "path": "loops/While-Loops.py",
    "content": "##\r\n# While Loops Lecture\r\n##\r\n\r\n# -*- coding: utf-8 -*-\r\n\r\n'''\r\nWhile Loops\r\nSyntax:\r\n    while condition:\r\n        Action1\r\n        Action2\r\n        ACtion3\r\n'''\r\ncounter = 1                         #set counter variable equal to 1\r\n'''\r\nThe while loop runs until the condition is True, updates the counter, prints the counter.\r\nIt comes out of the loop if the condition fails.\r\n'''\r\nwhile (counter <= 10):             #checks condition\r\n    print(counter)                 #print value of counter\r\n    counter = counter + 1          #increments counter by 1\r\n\r\ncounter = 1                       #sets counter variable equal to 1\r\nSum = 0                           #initialize sum to 0\r\nwhile (counter <= 10):            #checks condition\r\n    print(counter)                #print value of counter\r\n    Sum = Sum + counter           #add sum and counter value\r\n    counter = counter + 1          #increments counter by 1\r\nprint(Sum)                       #print the value of sum\r\n\r\n'''\r\nprint the sum of values from 1 to 100\r\n'''\r\ncounter = 1                     #set counter equal to 1\r\nSum = 0                         #intialize sum to 0\r\nwhile (counter <= 100):         #check the value of counter until it is less than or equal to 100\r\n    print(counter)              #print the value of counter\r\n    Sum = Sum + counter         #add the sum and counter\r\n    counter = counter + 1       #increment counter by 1\r\nprint(Sum)                      #print Sum\r\n\r\nKeepTrack = 1\r\nSum = 0\r\nwhile (KeepTrack <= 100):\r\n    print(KeepTrack)\r\n    Sum = Sum + KeepTrack\r\n    KeepTrack = KeepTrack + 1\r\nprint(Sum)\r\n\r\nLetters = [\"a\", \"b\", \"c\", \"d\", \"e\"]             #initialize a list with 5 character elements\r\nIndex = 0                                       #set index equal to 0\r\nwhile (Index < len(Letters)):                 #Compare variable Index with length of list\r\n    print(Index)                               #print value of Index\r\n    print(Letters[Index])                     #print each element in a List\r\n    Index = Index + 1                        #Increment value of Index by 1.\r\n\r\n'''\r\nStarts from Index 4. Since the length of list is equal to 5. the loop runs only once\r\nand prints the last element only.\r\n'''\r\nIndex = 4                      #set index equal to 4\r\nwhile (Index < len(Letters)):   #Compare variable Index with length of list\r\n    print(Index)                #print value of Index\r\n    print(Letters[Index])       #print each element in a List\r\n    Index = Index + 1           #Increment value of Index by 1.\r\n\r\n\r\n'''\r\nThe code below does not print anything since the loop starts from 5 and condition does not meet.\r\n'''\r\nIndex = 5\r\nwhile (Index < len(Letters)):\r\n    print(Index)\r\n    print(Letters[Index])\r\n    Index = Index + 1\r\n\r\nheight = 5000                   #set variable height equal to 5000.\r\nvelocity = 50                   #set variable velocity equal to 50\r\ntime = 0                        #set variable time equal to 0\r\nwhile (height > 0):             #check if variable height > 0\r\n    height = height - velocity  #decrement height with velocity and assign the value to height.\r\n    time = time + 1            #increment time by value 1\r\n\r\nprint(height)                   #print value of height\r\nprint(time)                     #print value of time\r\n"
  },
  {
    "path": "variables/main.py",
    "content": "##\r\n# Variables Lecture\r\n##\r\n\r\n# -*- coding: utf-8 -*-\r\n\r\n\r\n# 'one' is the name of the variable\r\n# '=' is called the assignment operator we use to store values in a variable\r\n# '1' is the actual value stored inside the variable 'one'\r\none = 1\r\n\r\n# 'two' is the name of the variable\r\n# '=' is called the assignment operator we use to store values in a variable\r\n# '2' is the actual value stored inside the variable 'two'\r\ntwo = 2\r\n\r\n# 'three' is the name of the variable\r\n# '=' is called the assignment operator we use to store values in a variable\r\n# '3' is the actual value stored inside the variable 'three'\r\nthree = 3\r\n\r\n# 'print()' is a function we use in python to print some value or content on the screen\r\n# name of the variable can be passed inside the print function to display its value on screen\r\nprint(one)\r\nprint(two)\r\nprint(three)\r\nprint(two)\r\nprint(one)\r\n# The above code will print the following\r\n# Notice how the same variable is being used again for printing\r\n\"\"\"\r\n1\r\n2\r\n3\r\n2\r\n1\r\n\"\"\"\r\n\r\n\r\n\r\nprint(one)\r\nprint(two)\r\nprint(three)\r\n# the value of a variable can be overwritten again by using the assignment operator '=' to store a new unique value\r\ntwo = 4\r\nprint(two)\r\nprint(one)\r\n# The above code will print the following\r\n# Notice the value of variable 'two' is reassigned to '4' in the output\r\n\"\"\"\r\n1\r\n2\r\n3\r\n4\r\n1\r\n\"\"\"\r\n\r\n# apart from storing integer values , decimal values can also be stored inside a variable\r\n# notice how the decimal value '1.1' is stored inside a variable called 'decimal'\r\ndecimal = 1.1\r\n# The above code will print the following\r\n\"\"\"\r\n1.1\r\n\"\"\"\r\n\r\n\r\n# text values also called strings can be stored inside a variable\r\n# notice how the value 'Hello' is stored inside a variable 'StringVar'\r\nStringVar = \"Hello\"\r\n# The above code will print the following\r\n\"\"\"\r\nHello\r\n\"\"\"\r\n\r\n# will produce and error with the following message\r\n\"\"\"\r\nStringVar = \"Hello\" + 1\r\nTypeError: must be str, not int\r\n\"\"\"\r\n# uncomment this code execute the script to see error\r\n#StringVar = \"Hello\" + 1\r\n# this happens because variables cant be of two types of 'int' denotes to integer and 'str' denotes to string\r\n\r\n\r\nStringVar = \"Hello\" + \"1\"\r\n# The above code will print the following\r\n# The above code works beause now both 1 and hello are strings\r\n\"\"\"\r\nHello1\r\n\"\"\"\r\n\r\n# The def keyword is used to begin fuction declaration and then the name of function is wriiten\r\ndef FunctionName():\r\n    # Declaring local variable\r\n    newVar=\"World\"\r\n    # Printing local variable\r\n    print(newVar)\r\n    # Used to indicate global variable is used\r\n    global one\r\n    # Printing global one variable\r\n    print(one)\r\n    # Returing a value , also used for ending a function\r\n    return\r\n\r\n# The function being called by using its name along with ()\r\nFunctionName()\r\n# Printing a local variable\r\nprint(newVar)\r\n# The following error is produced with due to the fact that 'newVar is a local variable'\r\n\"\"\"\r\nNameError: name 'newVar' is not defined\r\n\"\"\"\r\n\r\n# Shorthand way of declaration variables\r\none , two , three = 1,2,3\r\nprint(one)\r\nprint(two)\r\nprint(three)\r\n# The above code will print the following\r\n\"\"\"\r\n1\r\n2\r\n3\r\n\"\"\"\r\n\r\n# Declaraing a variable and storing the value 5 into it\r\nFive = 3+2\r\nprint(Five)\r\n# The above code will print the following\r\n\"\"\"\r\n5\r\n\"\"\"\r\n\r\n# Will produce error because we cant add two variables with one value on the right of assignment operator\r\nFive + Six = 3+2\r\n\r\n# This will produce an error as well\r\n# left = what you're giving the value to\r\n# right = what the value is\r\n5 = Five\r\n# Trying to print the value of variable 'Five'\r\nprint(Five)\r\n\r\n# Declared a variable 'count' and stored the value 0 to it\r\ncount = 0\r\n# Printing count value\r\nprint(count)\r\n# Output\r\n\"\"\"\r\n0\r\n\"\"\"\r\n\r\n# Reassign the value of count to 1\r\ncount = 1\r\n# Printing count value\r\nprint(count)\r\n# Output\r\n\"\"\"\r\n1\r\n\"\"\"\r\n\r\n\r\n# This will also increase the count value by adding 1 to the previous value of count\r\ncount = count + 1\r\n# Printing count value\r\nprint(count)\r\n# Output\r\n\"\"\"\r\n2\r\n\"\"\"\r\n# This will also increase the count value by adding 1 to the previous value of count\r\ncount = count + 1\r\n# Printing count value\r\nprint(count)\r\n# Output\r\n\"\"\"\r\n3\r\n\"\"\"\r\n\r\n# This will also increase the count value by adding 1 to the previous value of count\r\n# Short hand notation of the same line as 'count=count+1'\r\ncount+=1\r\n# Printing count value\r\nprint(count)\r\n# Output\r\n\"\"\"\r\n4\r\n\"\"\"\r\n\r\n# Assign 0 value to variable count\r\ncount = 0\r\n# Print the value\r\nprint(count)\r\n# Incrementing count value\r\ncount = count + 1\r\n# Print the value\r\nprint(count)\r\n# Multiply the value of count by 3\r\ncount*=3\r\n# Print the value\r\nprint(count)\r\n# Output\r\n\"\"\"\r\n0\r\n1\r\n3\r\n\"\"\"\r\n\r\n# Assign 0 value to variable count\r\ncount = 0\r\n# Print the value\r\nprint(count)\r\n# Incrementing count value\r\ncount = count + 1\r\n# Print the value\r\nprint(count)\r\n# Multiply the value of count by 3\r\ncount/=3\r\n# Print the value\r\nprint(count)\r\n# Output\r\n\"\"\"\r\n0\r\n1\r\n0.333333333333\r\n\"\"\"\r\n"
  }
]