├── 10Sep2017 ├── filereadwrite │ ├── .idea │ │ ├── filereadwrite.iml │ │ ├── misc.xml │ │ ├── modules.xml │ │ └── workspace.xml │ ├── demo.txt │ ├── demo1.txt │ ├── file1.py │ ├── file2.py │ ├── file3.py │ ├── file4.py │ ├── file5.py │ ├── file6.py │ ├── file7.py │ └── file8.py └── objectoriented │ ├── .idea │ ├── misc.xml │ ├── modules.xml │ ├── objectoriented.iml │ └── workspace.xml │ ├── car.py │ ├── electricalcar.py │ ├── object1.py │ ├── object2.py │ ├── object3.py │ ├── object4.py │ ├── object5.py │ ├── object6.py │ ├── object7.py │ └── object8.py ├── 13Aug2017 ├── DemoInput │ ├── .idea │ │ ├── DemoInput.iml │ │ ├── inspectionProfiles │ │ │ └── profiles_settings.xml │ │ ├── misc.xml │ │ ├── modules.xml │ │ └── workspace.xml │ ├── Input1.py │ ├── Input2.py │ ├── Input3.py │ ├── Input4.py │ ├── While1.py │ ├── While2.py │ ├── While3.py │ └── While4.py ├── Practice │ ├── .idea │ │ ├── Practice.iml │ │ ├── inspectionProfiles │ │ │ └── profiles_settings.xml │ │ ├── misc.xml │ │ ├── modules.xml │ │ └── workspace.xml │ ├── DuplicateRandomNumbers.py │ ├── GuessNumber.py │ └── PrimeNumber.py └── RandomNumbers │ ├── .idea │ ├── RandomNumbers.iml │ ├── inspectionProfiles │ │ └── profiles_settings.xml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml │ ├── Demo.py │ ├── random1.py │ └── random2.py ├── 15Oct2017 ├── datascience_chap2 │ ├── .idea │ │ ├── datascience_chap2.iml │ │ ├── misc.xml │ │ ├── modules.xml │ │ └── workspace.xml │ ├── demo1.py │ ├── demo10.py │ ├── demo11.py │ ├── demo12.py │ ├── demo13.py │ ├── demo14.py │ ├── demo15.py │ ├── demo16.py │ ├── demo17.py │ ├── demo18.py │ ├── demo19.py │ ├── demo2.py │ ├── demo20.py │ ├── demo21.py │ ├── demo22.py │ ├── demo23.py │ ├── demo24.py │ ├── demo25.py │ ├── demo26.py │ ├── demo27.py │ ├── demo3.py │ ├── demo4.py │ ├── demo5.py │ ├── demo6.py │ ├── demo7.py │ ├── demo8.py │ └── demo9.py └── untitled │ ├── .idea │ ├── misc.xml │ ├── modules.xml │ ├── untitled.iml │ └── workspace.xml │ └── demo1.py ├── 17Sep2017 ├── exceptions │ ├── .idea │ │ ├── exceptions.iml │ │ ├── misc.xml │ │ ├── modules.xml │ │ └── workspace.xml │ ├── exception12.py │ ├── exceptions1.py │ ├── exceptions10.py │ ├── exceptions11.py │ ├── exceptions12.py │ ├── exceptions13.py │ ├── exceptions14.py │ ├── exceptions15.py │ ├── exceptions16.py │ ├── exceptions2.py │ ├── exceptions3.py │ ├── exceptions4.py │ ├── exceptions5.py │ ├── exceptions6.py │ ├── exceptions7.py │ ├── exceptions8.py │ └── exceptions9.py └── storingdata │ ├── .idea │ ├── misc.xml │ ├── modules.xml │ ├── storingdata.iml │ └── workspace.xml │ ├── numbers.json │ ├── numbers2.json │ ├── numbers3.json │ ├── numbers4.json │ ├── q10.py │ ├── sotring2.py │ ├── storing1.py │ ├── storing3.py │ ├── storing4.py │ ├── storing5.py │ ├── storing6.py │ ├── storing7.py │ └── storing8.py ├── 20Aug2017 ├── DemoDictionaries │ ├── .idea │ │ ├── DemoDictionaries.iml │ │ ├── inspectionProfiles │ │ │ └── profiles_settings.xml │ │ ├── misc.xml │ │ ├── modules.xml │ │ └── workspace.xml │ ├── Dictioanry13.py │ ├── Dictionary1.py │ ├── Dictionary10.py │ ├── Dictionary11.py │ ├── Dictionary12.py │ ├── Dictionary13.py │ ├── Dictionary14.py │ ├── Dictionary2.py │ ├── Dictionary5.py │ ├── Dictionary6.py │ ├── Dictionary7.py │ ├── Dictionary8.py │ ├── Dictionary9.py │ ├── Distionary3.py │ └── Distionary4.py └── Functions │ ├── .idea │ ├── Functions.iml │ ├── inspectionProfiles │ │ └── profiles_settings.xml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml │ ├── Func1.py │ ├── Func10.py │ ├── Func11.py │ ├── Func12.py │ ├── Func13.py │ ├── Func2.py │ ├── Func3.py │ ├── Func4.py │ ├── Func5.py │ ├── Func6.py │ ├── Func7.py │ ├── Func8.py │ └── Func9.py ├── 22Oct2017 └── datascience_chap1 │ ├── .idea │ ├── datascience_chap1.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml │ ├── demo1.py │ ├── demo2.py │ ├── demo3.py │ ├── demo4.py │ ├── demo5.py │ ├── demo6.py │ └── demo7.py ├── 23July2017 └── hello │ ├── .idea │ ├── hello.iml │ ├── inspectionProfiles │ │ └── profiles_settings.xml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml │ ├── eight.py │ ├── fifth.py │ ├── first.py │ ├── forth.py │ ├── second.py │ ├── seventh.py │ ├── sixth.py │ └── third.py ├── 24Sep2017 └── datascience_chap2 │ ├── .idea │ ├── datascience_chap2.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml │ ├── abc.ipynb │ ├── demo1.py │ ├── demo10.py │ ├── demo2.py │ ├── demo3.py │ ├── demo4.py │ ├── demo5.py │ ├── demo6.py │ ├── demo7.py │ ├── demo8.py │ └── demo9.py ├── 27Aug2017 └── Objects │ ├── .idea │ ├── Objects.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml │ ├── object3.py │ ├── objects1.py │ ├── objects10.py │ ├── objects11.py │ ├── objects12.py │ ├── objects13.py │ ├── objects14.py │ ├── objects2.py │ ├── objects4.py │ ├── objects5.py │ ├── objects6.py │ ├── objects7.py │ ├── objects8.py │ └── objects9.py ├── 29Oct2017 └── 29Oct2017 │ ├── datascience_chap1 │ ├── .idea │ │ ├── datascience_chap1.iml │ │ ├── misc.xml │ │ ├── modules.xml │ │ └── workspace.xml │ ├── demo1.py │ ├── demo2.py │ ├── demo3.py │ ├── demo4.py │ ├── demo5.py │ ├── demo6.py │ ├── demo7.py │ └── demo8.py │ └── demoObjects │ ├── .idea │ ├── demoObjects.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml │ └── obj1.py ├── 30July2017 ├── DemoList │ ├── .idea │ │ ├── DemoList.iml │ │ ├── inspectionProfiles │ │ │ └── profiles_settings.xml │ │ ├── misc.xml │ │ ├── modules.xml │ │ └── workspace.xml │ ├── List1.py │ ├── List10.py │ ├── List2.py │ ├── List3.py │ ├── List4.py │ ├── List5.py │ ├── List6.py │ ├── List7.py │ ├── List8.py │ └── List9.py └── DemoListChap4 │ ├── .idea │ ├── DemoListChap4.iml │ ├── inspectionProfiles │ │ └── profiles_settings.xml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml │ ├── List1.py │ ├── List2.py │ ├── List3.py │ ├── List4.py │ ├── List5.py │ ├── List6.py │ └── List7.py ├── 6Aug2017 ├── DemoIfElse │ ├── .idea │ │ ├── DemoIfElse.iml │ │ ├── inspectionProfiles │ │ │ └── profiles_settings.xml │ │ ├── misc.xml │ │ ├── modules.xml │ │ └── workspace.xml │ ├── IfElse1.py │ ├── IfElse2.py │ ├── IfElse3.py │ ├── IfElse4.py │ ├── IfElse5.py │ └── InOperator.py ├── DemoList │ ├── .idea │ │ ├── DemoList.iml │ │ ├── inspectionProfiles │ │ │ └── profiles_settings.xml │ │ ├── misc.xml │ │ ├── modules.xml │ │ └── workspace.xml │ ├── List1.py │ ├── List10.py │ ├── List11.py │ ├── List12.py │ ├── List13.py │ ├── List14.py │ ├── List15.py │ ├── List16.py │ ├── List17.py │ ├── List18.py │ ├── List2.py │ ├── List3.py │ ├── List4.py │ ├── List5.py │ ├── List6.py │ ├── List7.py │ ├── List8.py │ └── List9.py └── DemoTuple │ ├── .idea │ ├── DemoTuple.iml │ ├── inspectionProfiles │ │ └── profiles_settings.xml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml │ ├── tuple1.py │ ├── tuple2.py │ ├── tuple3.py │ ├── tuple4.py │ ├── tuple5.py │ └── tuple6.py ├── 8Oct2017 └── datascience_chap2 │ ├── .idea │ ├── datascience_chap2.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml │ ├── demo1.py │ ├── demo10.py │ ├── demo11.py │ ├── demo12.py │ ├── demo13.py │ ├── demo14.py │ ├── demo15.py │ ├── demo16.py │ ├── demo17.py │ ├── demo2.py │ ├── demo3.py │ ├── demo4.py │ ├── demo5.py │ ├── demo6.py │ ├── demo7.py │ ├── demo8.py │ └── demo9.py └── README.md /10Sep2017/filereadwrite/.idea/filereadwrite.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /10Sep2017/filereadwrite/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /10Sep2017/filereadwrite/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /10Sep2017/filereadwrite/demo.txt: -------------------------------------------------------------------------------- 1 | Hello World 1 2 | Hello World 2 3 | Hello World 3 4 | Hello World 4 5 | Hello World 5 -------------------------------------------------------------------------------- /10Sep2017/filereadwrite/demo1.txt: -------------------------------------------------------------------------------- 1 | I love programming! 2 | -------------------------------------------------------------------------------- /10Sep2017/filereadwrite/file1.py: -------------------------------------------------------------------------------- 1 | with open('demo.txt') as fileObj: 2 | content = fileObj.read() 3 | print(content) -------------------------------------------------------------------------------- /10Sep2017/filereadwrite/file2.py: -------------------------------------------------------------------------------- 1 | with open('demo.txt') as fileObj: 2 | for line in fileObj: 3 | print(line) -------------------------------------------------------------------------------- /10Sep2017/filereadwrite/file3.py: -------------------------------------------------------------------------------- 1 | with open('demo.txt') as fileObj: 2 | lines = fileObj.readlines() 3 | print(lines) -------------------------------------------------------------------------------- /10Sep2017/filereadwrite/file4.py: -------------------------------------------------------------------------------- 1 | mylist = ["hello","test"] 2 | with open('demo.txt') as fileObj: 3 | lines = fileObj.readlines() 4 | mylist = mylist + lines 5 | print(mylist) -------------------------------------------------------------------------------- /10Sep2017/filereadwrite/file5.py: -------------------------------------------------------------------------------- 1 | 2 | with open('demo1.txt','w') as fileObj: 3 | fileObj.write("I love programming!") -------------------------------------------------------------------------------- /10Sep2017/filereadwrite/file6.py: -------------------------------------------------------------------------------- 1 | 2 | with open('demo1.txt','a') as fileObj: 3 | fileObj.write("I love programming!\n") 4 | #content = fileObj.read() 5 | #print(content) -------------------------------------------------------------------------------- /10Sep2017/filereadwrite/file7.py: -------------------------------------------------------------------------------- 1 | 2 | with open('demo1.txt','r+') as fileObj: 3 | fileObj.write("I love programming!\n") 4 | 5 | fileObj.seek(0) 6 | content = fileObj.readlines() 7 | print(content) 8 | 9 | -------------------------------------------------------------------------------- /10Sep2017/filereadwrite/file8.py: -------------------------------------------------------------------------------- 1 | import os; 2 | 3 | p = os.path.isfile("demo.txt") 4 | p1 = os.path.isdir("C:\\Windows") 5 | dirList = os.listdir("C:\\Windows") 6 | print(p) 7 | print(p1) 8 | print(dirList) -------------------------------------------------------------------------------- /10Sep2017/objectoriented/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /10Sep2017/objectoriented/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /10Sep2017/objectoriented/.idea/objectoriented.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /10Sep2017/objectoriented/car.py: -------------------------------------------------------------------------------- 1 | class Car(): 2 | 3 | def __init__(self,make,model,year): 4 | self.make = make 5 | self.model = model 6 | self.year = year 7 | self.__odometer_reading = 5 8 | 9 | 10 | def get_descriptive_name(self): 11 | print("In Car") 12 | long_name = str(self.year)+ ' '+self.make + ' ' + self.model + ' '+ str(self.__odometer_reading) 13 | return long_name 14 | 15 | def update_odometer(self, val): 16 | self.__odometer_reading = val 17 | 18 | def get_odometer(self): 19 | return self.__odometer_reading 20 | 21 | -------------------------------------------------------------------------------- /10Sep2017/objectoriented/electricalcar.py: -------------------------------------------------------------------------------- 1 | from car import Car 2 | class ElectricCar(Car): 3 | '''ElectricCar''' 4 | def __init__(self,make,model,year): 5 | super().__init__(make,model,year) 6 | self.name = "Test 1 car" 7 | 8 | def charge(self): 9 | print("Electric Car is charging") 10 | 11 | def get_descriptive_name(self): 12 | print("In ElectricCar") 13 | long_name = str(self.year)+ ' '+self.make + ' ' + self.model 14 | return long_name 15 | 16 | -------------------------------------------------------------------------------- /10Sep2017/objectoriented/object1.py: -------------------------------------------------------------------------------- 1 | class Car(): 2 | 3 | def __init__(self,make,model,year): 4 | self.make = make 5 | self.model = model 6 | self.year = year 7 | self.__odometer_reading = 5 8 | 9 | 10 | def get_descriptive_name(self): 11 | long_name = str(self.year)+ ' '+self.make + ' ' + self.model + ' '+ str(self.__odometer_reading) 12 | return long_name 13 | 14 | def update_odometer(self, val): 15 | self.__odometer_reading = val 16 | 17 | def get_odometer(self): 18 | return self.__odometer_reading 19 | 20 | def __start(self): 21 | print("Car started") 22 | 23 | class ElectricCar(Car): 24 | '''ElectricCar''' 25 | def __init__(self,make,model,year): 26 | super().__init__(make,model,year) 27 | #self.make = make 28 | #self.model = model 29 | #self.year = year 30 | 31 | 32 | 33 | c = Car('audi', 'a4', 2016) 34 | ec = ElectricCar('Tesla', 's4', 2016) 35 | print(ec.get_descriptive_name()) 36 | #ec.__start() 37 | 38 | 39 | -------------------------------------------------------------------------------- /10Sep2017/objectoriented/object2.py: -------------------------------------------------------------------------------- 1 | class Car(): 2 | 3 | def __init__(self,make,model,year): 4 | self.make = make 5 | self.model = model 6 | self.year = year 7 | self.__odometer_reading = 5 8 | 9 | 10 | def get_descriptive_name(self): 11 | long_name = str(self.year)+ ' '+self.make + ' ' + self.model + ' '+ str(self.__odometer_reading) 12 | return long_name 13 | 14 | def update_odometer(self, val): 15 | self.__odometer_reading = val 16 | 17 | def get_odometer(self): 18 | return self.__odometer_reading 19 | 20 | 21 | class ElectricCar(Car): 22 | '''ElectricCar''' 23 | def __init__(self,make,model,year): 24 | super().__init__(make,model,year) 25 | self.name = "Test 1 car" 26 | 27 | def charge(self): 28 | print("Electric Car is charging") 29 | 30 | 31 | c = Car('audi', 'a4', 2016) 32 | ec = ElectricCar('Tesla', 's4', 2016) 33 | print(ec.get_descriptive_name()) 34 | ec.charge() 35 | #c.charge() 36 | print(ec.name) 37 | 38 | #ec = c; 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /10Sep2017/objectoriented/object3.py: -------------------------------------------------------------------------------- 1 | class Car(): 2 | 3 | def __init__(self,make,model,year): 4 | self.make = make 5 | self.model = model 6 | self.year = year 7 | self.__odometer_reading = 5 8 | 9 | 10 | def get_descriptive_name(self): 11 | print("In Car") 12 | long_name = str(self.year)+ ' '+self.make + ' ' + self.model + ' '+ str(self.__odometer_reading) 13 | return long_name 14 | 15 | def update_odometer(self, val): 16 | self.__odometer_reading = val 17 | 18 | def get_odometer(self): 19 | return self.__odometer_reading 20 | 21 | 22 | class ElectricCar(Car): 23 | '''ElectricCar''' 24 | def __init__(self,make,model,year): 25 | super().__init__(make,model,year) 26 | self.name = "Test 1 car" 27 | 28 | def charge(self): 29 | print("Electric Car is charging") 30 | 31 | def get_descriptive_name(self): 32 | print("In ElectricCar") 33 | long_name = str(self.year)+ ' '+self.make + ' ' + self.model 34 | return long_name 35 | 36 | 37 | c = Car('audi', 'a4', 2016) 38 | ec = ElectricCar('Tesla', 's4', 2016) 39 | print(ec.get_descriptive_name()) 40 | ec.charge() 41 | #c.charge() 42 | print(ec.name) 43 | 44 | #ec = c; 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /10Sep2017/objectoriented/object4.py: -------------------------------------------------------------------------------- 1 | class Car(): 2 | 3 | def __init__(self,make,model,year): 4 | self.make = make 5 | self.model = model 6 | self.year = year 7 | self.__odometer_reading = 5 8 | 9 | def doSomething(self): 10 | print("in car do something") 11 | return self.get_descriptive_name() 12 | 13 | def get_descriptive_name(self): 14 | print("In Car") 15 | long_name = str(self.year)+ ' '+self.make + ' ' + self.model + ' '+ str(self.__odometer_reading) 16 | return long_name 17 | 18 | class ElectricCar(Car): 19 | '''ElectricCar''' 20 | def __init__(self,make,model,year): 21 | super().__init__(make,model,year) 22 | self.name = "Test 1 car" 23 | 24 | def charge(self): 25 | print("Electric Car is charging") 26 | 27 | def get_descriptive_name(self): 28 | print("In ElectricCar") 29 | long_name = str(self.year)+ ' '+self.make + ' ' + self.model 30 | return long_name 31 | 32 | 33 | c = Car('audi', 'a4', 2016) 34 | ec = ElectricCar('Tesla', 's4', 2016) 35 | print(ec.doSomething()) 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /10Sep2017/objectoriented/object5.py: -------------------------------------------------------------------------------- 1 | class Car(): 2 | 3 | def __init__(self,make,model,year,battery): 4 | self.make = make 5 | self.model = model 6 | self.year = year 7 | self.battery = battery 8 | self.__odometer_reading = 5 9 | 10 | 11 | 12 | def get_descriptive_name(self): 13 | print("In Car") 14 | long_name = str(self.year)+ ' '+self.make + ' ' + self.model + ' '+ str(self.__odometer_reading) 15 | return long_name 16 | 17 | 18 | class Battery(): 19 | """A simple attempt to model a battery for an electric car.""" 20 | def __init__(self, battery_size=70): 21 | """Initialize the battery's attributes.""" 22 | self.battery_size = battery_size 23 | 24 | def describe_battery(self): 25 | """Print a statement describing the battery size.""" 26 | print("This car has a " + str(self.battery_size) + "-kWh battery.") 27 | 28 | b = Battery() 29 | c = Car('audi', 'a4', 2016, b) 30 | c.battery.describe_battery() 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /10Sep2017/objectoriented/object6.py: -------------------------------------------------------------------------------- 1 | from car import Car 2 | from electricalcar import ElectricCar 3 | 4 | c = Car('audi', 'a4', 2016, b) -------------------------------------------------------------------------------- /10Sep2017/objectoriented/object7.py: -------------------------------------------------------------------------------- 1 | from car import Car as c 2 | 3 | import electricalcar as ect 4 | 5 | abc = c('audi', 'a4', 2016) 6 | e = ect.ElectricCar() 7 | -------------------------------------------------------------------------------- /10Sep2017/objectoriented/object8.py: -------------------------------------------------------------------------------- 1 | class Car(): 2 | def dosomething(self): 3 | print("car dosomething") 4 | 5 | class AutomaticCar(): 6 | def dosomething(self): 7 | print("AutomaticCar dosomething") 8 | def testAuto(self): 9 | print("AutomaticCar auto") 10 | 11 | class ElectricalCar(AutomaticCar,Car): 12 | def workig(self): 13 | print("working") 14 | 15 | 16 | a = Car() 17 | b = AutomaticCar() 18 | c = ElectricalCar() 19 | c.dosomething() 20 | c.testAuto() 21 | -------------------------------------------------------------------------------- /13Aug2017/DemoInput/.idea/DemoInput.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /13Aug2017/DemoInput/.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /13Aug2017/DemoInput/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /13Aug2017/DemoInput/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /13Aug2017/DemoInput/Input1.py: -------------------------------------------------------------------------------- 1 | message = input("Enter your name ") 2 | print("Hello "+message+"!") -------------------------------------------------------------------------------- /13Aug2017/DemoInput/Input2.py: -------------------------------------------------------------------------------- 1 | age = input("How old are you? ") 2 | age = int(age) 3 | print(age) 4 | if age>18: 5 | print("Here is yor CNIC") 6 | else : 7 | print("Grow up") -------------------------------------------------------------------------------- /13Aug2017/DemoInput/Input3.py: -------------------------------------------------------------------------------- 1 | age = int(input("How old are you? ")) 2 | print(age) 3 | if age>18: 4 | print("Here is yor CNIC") 5 | else : 6 | print("Grow up") -------------------------------------------------------------------------------- /13Aug2017/DemoInput/Input4.py: -------------------------------------------------------------------------------- 1 | num = int(input("Enter your number")) 2 | if num % 2 == 0: 3 | print("The number "+str(num)+" even") 4 | else: 5 | print("The number " + str(num) + " odd") -------------------------------------------------------------------------------- /13Aug2017/DemoInput/While1.py: -------------------------------------------------------------------------------- 1 | current_number = 1 2 | 3 | while current_number <= 5: 4 | #print(current_number) 5 | current_number += 1 6 | 7 | print(current_number) 8 | -------------------------------------------------------------------------------- /13Aug2017/DemoInput/While2.py: -------------------------------------------------------------------------------- 1 | current_number = int(input("Enter number ")) 2 | num = 0 3 | 4 | while num < current_number: 5 | print(num) 6 | num += 1 7 | 8 | print("Final",num) 9 | -------------------------------------------------------------------------------- /13Aug2017/DemoInput/While3.py: -------------------------------------------------------------------------------- 1 | current_number = int(input("Enter number ")) 2 | num = 0 3 | 4 | while num < current_number: 5 | num += 1 6 | if num == 3: 7 | break 8 | print(num) 9 | 10 | 11 | print("Final",num) 12 | -------------------------------------------------------------------------------- /13Aug2017/DemoInput/While4.py: -------------------------------------------------------------------------------- 1 | current_number = int(input("Enter number ")) 2 | num = 0 3 | 4 | while num < current_number: 5 | num += 1 6 | if num == 3: 7 | continue 8 | print(num) 9 | 10 | 11 | print("Final",num) 12 | -------------------------------------------------------------------------------- /13Aug2017/Practice/.idea/Practice.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /13Aug2017/Practice/.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /13Aug2017/Practice/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /13Aug2017/Practice/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /13Aug2017/Practice/DuplicateRandomNumbers.py: -------------------------------------------------------------------------------- 1 | from random import randint 2 | max = int(input("Enter max number")) 3 | count = max+1 4 | mylist = [] 5 | 6 | while len(mylist) != count: 7 | num = randint(0, max) 8 | if( num not in mylist): 9 | mylist.append(num) 10 | 11 | print (mylist) -------------------------------------------------------------------------------- /13Aug2017/Practice/GuessNumber.py: -------------------------------------------------------------------------------- 1 | # 1) generate random number 2 | # 2) user guess number with input 3 | # 3) if number match you win 4 | # else you lose 5 | # 4) if user input is incorrect 6 | # give him 3 chance 7 | 8 | # 5) after win or lose ask user 9 | # do you want to continue 10 | # if user say yes Generate 11 | # New Random number 12 | # start from Point 1 again -------------------------------------------------------------------------------- /13Aug2017/Practice/PrimeNumber.py: -------------------------------------------------------------------------------- 1 | value = int(input("Enter value? ")) 2 | check = True 3 | num = 2 4 | while num<=value/2: 5 | if(value % num ==0): 6 | check = False 7 | break 8 | num +=1 9 | if check: 10 | print("This is Prime Number.") 11 | else: 12 | 13 | print("This isn't Prime Number.") -------------------------------------------------------------------------------- /13Aug2017/RandomNumbers/.idea/RandomNumbers.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /13Aug2017/RandomNumbers/.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /13Aug2017/RandomNumbers/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /13Aug2017/RandomNumbers/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /13Aug2017/RandomNumbers/Demo.py: -------------------------------------------------------------------------------- 1 | play = "yes" 2 | 3 | print(play is "yes") -------------------------------------------------------------------------------- /13Aug2017/RandomNumbers/random1.py: -------------------------------------------------------------------------------- 1 | from random import randint 2 | 3 | 4 | num = randint(1,15) 5 | print(num) -------------------------------------------------------------------------------- /13Aug2017/RandomNumbers/random2.py: -------------------------------------------------------------------------------- 1 | from random import randint 2 | num = 0 3 | mylist = [] 4 | for val in range(0,10): 5 | num = randint(1,15) 6 | mylist.append(num) 7 | print(num) 8 | 9 | print(mylist) 10 | 11 | val = 6; 12 | val in mylist -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/.idea/datascience_chap2.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo1.py: -------------------------------------------------------------------------------- 1 | def exp(base, power): 2 | return base ** power 3 | 4 | def two_to_the(power): 5 | return exp(2, power) 6 | 7 | print(exp(2,4)) 8 | print(exp(2,5)) 9 | print(exp(2,6)) 10 | 11 | print(two_to_the(8)) -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo10.py: -------------------------------------------------------------------------------- 1 | from functools import partial 2 | def double(x): 3 | return 2 * x 4 | 5 | xs = [1, 2, 3, 4] 6 | list_doubler = partial(map, double) 7 | 8 | print(list(list_doubler(xs))) 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo11.py: -------------------------------------------------------------------------------- 1 | from functools import partial 2 | 3 | def is_even(x): 4 | """True if x is even, False if x is odd""" 5 | return x % 2 == 0 6 | #return True 7 | 8 | xs = [1, 2, 3, 4] 9 | 10 | x_evens = filter(is_even, xs) # same as above 11 | print(list(x_evens)) 12 | #list_evener = partial(filter, is_even) # *function* that filters a list 13 | #x_evens = list_evener(xs) -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo12.py: -------------------------------------------------------------------------------- 1 | def multiply(x, y): 2 | return x * y 3 | 4 | a = multiply(1,2) 5 | print(a) 6 | b = multiply(a,3) 7 | print(b) 8 | c = multiply(b,4) 9 | print(c) -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo13.py: -------------------------------------------------------------------------------- 1 | from functools import reduce 2 | def multiply(x, y): 3 | return x * y 4 | xs = [1, 2, 3, 4] 5 | x_product = reduce(multiply, xs) 6 | 7 | print(x_product) -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo14.py: -------------------------------------------------------------------------------- 1 | documents = ["hello","world","new","that","working"] 2 | 3 | for i, document in enumerate(documents): 4 | print("I = "+str(i)+" doc = "+document) -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo15.py: -------------------------------------------------------------------------------- 1 | list1 = ['a', 'b','d', 'c',] 2 | list2 = [1, 2, 3,4,5,6] 3 | print(list(zip(list1, list2))) -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo16.py: -------------------------------------------------------------------------------- 1 | docs = [(1,"a"),(2,"b","rer"),(3,"c"),(4,"d")] 2 | 3 | a,b = zip(*docs) 4 | 5 | print(a) 6 | print(b) -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo17.py: -------------------------------------------------------------------------------- 1 | def add(a, b): 2 | return a + b 3 | 4 | print(add(2,4)) 5 | print(add(*[2,4])) -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo18.py: -------------------------------------------------------------------------------- 1 | def myfunction(x): 2 | return x * 3 3 | 4 | def doubler(f): 5 | return 4 + f(6) 6 | 7 | print(doubler(myfunction)) 8 | -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo19.py: -------------------------------------------------------------------------------- 1 | def myfunction(x): 2 | return x * 3 3 | def doubler(f): 4 | def g(z): 5 | return z + f(6) 6 | return g 7 | myfunc = doubler(myfunction) 8 | print(myfunc) 9 | print(myfunc(2)) 10 | 11 | -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo2.py: -------------------------------------------------------------------------------- 1 | from functools import partial 2 | 3 | def exp(base, power): 4 | return base ** power 5 | 6 | two_to_the = partial(exp, 2) 7 | 8 | print(two_to_the(3)) 9 | print(two_to_the(6)) 10 | print(two_to_the(9)) 11 | -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo20.py: -------------------------------------------------------------------------------- 1 | def acceptArray(*a): 2 | print(a) 3 | print(a[0]) 4 | print(a[4]) 5 | 6 | acceptArray(3,5,7,8,9) -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo21.py: -------------------------------------------------------------------------------- 1 | def acceptArray(*a,b): 2 | print(a) 3 | print(a[0]) 4 | print(a[4]) 5 | 6 | acceptArray(3,5,7,8,9,7,b=34) -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo22.py: -------------------------------------------------------------------------------- 1 | def acceptArray(b,*a): 2 | print(a) 3 | print(a[0]) 4 | print(a[4]) 5 | 6 | acceptArray(3,5,7,8,9,7) -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo23.py: -------------------------------------------------------------------------------- 1 | #Not allowed 2 | #def acceptArray(**b,a): 3 | def acceptArray(**b): 4 | print(b) 5 | 6 | acceptArray(hello="work",new="test") -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo24.py: -------------------------------------------------------------------------------- 1 | def acceptArray(a,**b): 2 | print(a) 3 | print(b) 4 | 5 | acceptArray(34,hello="work",new="test") 6 | acceptArray(hello="work",new="test",a=23) 7 | #acceptArray(hello="work",new="test",23) -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo25.py: -------------------------------------------------------------------------------- 1 | def other_way_magic(x, y, z): 2 | return x + y + z 3 | 4 | x_y_list = [1, 2] 5 | z_dict = { "z" : 3 } 6 | print(other_way_magic(*x_y_list, **z_dict)) # 6 -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo26.py: -------------------------------------------------------------------------------- 1 | def acceptArray(**b): 2 | print(b) 3 | 4 | acceptArray() -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo27.py: -------------------------------------------------------------------------------- 1 | def f2(x, y): 2 | return x + y 3 | 4 | def f3(x, y,z): 5 | return x + y +z 6 | 7 | def doubler_correct(f): 8 | """works no matter what kind of inputs f expects""" 9 | def g(*args, **kwargs): 10 | """whatever arguments g is supplied, pass them through to f""" 11 | return 2 * f(*args, **kwargs) 12 | return g 13 | 14 | g = doubler_correct(f2) 15 | #print(g(1, 2,3)) # 6 16 | print(g(1, 2)) # 6 17 | print("=======") 18 | 19 | g1 = doubler_correct(f3) 20 | print(g1(1, 2,3)) # 6 -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo3.py: -------------------------------------------------------------------------------- 1 | from functools import partial 2 | 3 | def exp(base, power): 4 | return base ** power 5 | 6 | two_to_the = partial(exp, 2,3) 7 | 8 | print(two_to_the()) 9 | -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo4.py: -------------------------------------------------------------------------------- 1 | from functools import partial 2 | 3 | def exp(base, power): 4 | return base ** power 5 | 6 | two_to_the = partial(exp,power=3) 7 | 8 | print(two_to_the(5)) 9 | -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo5.py: -------------------------------------------------------------------------------- 1 | def double(x): 2 | return 2 * x 3 | 4 | #print(double(4)) 5 | xs = [1, 2, 3, 4] 6 | xs2 = [] 7 | for x3 in xs: 8 | print(x3*2) 9 | #xs2.append(double(x3)) 10 | 11 | 12 | -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo6.py: -------------------------------------------------------------------------------- 1 | def double(x): 2 | return 2 * x 3 | 4 | #print(double(4)) 5 | xs = [1, 2, 3, 4] 6 | xs2 = [] 7 | for x3 in xs: 8 | print(double(x3)) 9 | #xs2.append(double(x3)) 10 | 11 | 12 | -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo7.py: -------------------------------------------------------------------------------- 1 | import functools 2 | def double(x): 3 | return 2 * x 4 | 5 | #print(double(4)) 6 | xs = [1, 2, 3, 4] 7 | xs2 = [] 8 | for x3 in xs: 9 | #print(double(x3)) 10 | xs2.append(double(x3)) 11 | 12 | print(xs2) 13 | 14 | 15 | -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo8.py: -------------------------------------------------------------------------------- 1 | def double(x): 2 | return 2 * x 3 | 4 | #print(double(4)) 5 | xs = [1, 2, 3, 4] 6 | xs2 = [double(x3) for x3 in xs] 7 | 8 | print(xs2) 9 | 10 | 11 | -------------------------------------------------------------------------------- /15Oct2017/datascience_chap2/demo9.py: -------------------------------------------------------------------------------- 1 | def double(x): 2 | return 2 * x 3 | 4 | 5 | xs = [1, 2, 3, 4] 6 | xs2 = map(double,xs) 7 | 8 | #print(list(xs2)) 9 | 10 | for a in xs2: 11 | print(a) 12 | 13 | print("test") 14 | for a in xs2: 15 | print(a) 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /15Oct2017/untitled/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /15Oct2017/untitled/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /15Oct2017/untitled/.idea/untitled.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /15Oct2017/untitled/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 32 | 33 | 34 | 39 | 40 | 41 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 138 | 139 | 140 | 141 | 142 | 143 | 153 | 154 | 155 | 156 | 172 | 173 | 189 | 190 | 206 | 207 | 223 | 224 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 260 | 261 | 262 | 263 | 1508665014924 264 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | -------------------------------------------------------------------------------- /22Oct2017/datascience_chap1/demo1.py: -------------------------------------------------------------------------------- 1 | users = [ 2 | { "id": 0, "name": "Hero" }, 3 | { "id": 1, "name": "Dunn" }, 4 | { "id": 2, "name": "Sue" }, 5 | { "id": 3, "name": "Chi" }, 6 | { "id": 4, "name": "Thor" }, 7 | { "id": 5, "name": "Clive" }, 8 | { "id": 6, "name": "Hicks" }, 9 | { "id": 7, "name": "Devin" }, 10 | { "id": 8, "name": "Kate" }, 11 | { "id": 9, "name": "Klein" } 12 | ] 13 | 14 | friendships = [(0, 1), (0, 2), (1, 2), (1, 3), (2, 3), (3, 4), 15 | (4, 5), (5, 6), (5, 7), (6, 8), (7, 8), (8, 9)] 16 | 17 | for user in users: 18 | user["friends"] = [] 19 | 20 | for i, j in friendships: 21 | # this works because users[i] is the user whose id is i 22 | users[i]["friends"].append(users[j]) # add i as a friend of j 23 | users[j]["friends"].append(users[i]) # add j as a friend of i 24 | def number_of_friends(user): 25 | """how many friends does _user_ have?""" 26 | return len(user["friends"]) 27 | 28 | data=[number_of_friends(user) 29 | for user in users] 30 | 31 | 32 | print(sum(data)) -------------------------------------------------------------------------------- /22Oct2017/datascience_chap1/demo2.py: -------------------------------------------------------------------------------- 1 | users = [ 2 | { "id": 0, "name": "Hero" }, 3 | { "id": 1, "name": "Dunn" }, 4 | { "id": 2, "name": "Sue" }, 5 | { "id": 3, "name": "Chi" }, 6 | { "id": 4, "name": "Thor" }, 7 | { "id": 5, "name": "Clive" }, 8 | { "id": 6, "name": "Hicks" }, 9 | { "id": 7, "name": "Devin" }, 10 | { "id": 8, "name": "Kate" }, 11 | { "id": 9, "name": "Klein" } 12 | ] 13 | 14 | friendships = [(0, 1), (0, 2), (1, 2), (1, 3), (2, 3), (3, 4), 15 | (4, 5), (5, 6), (5, 7), (6, 8), (7, 8), (8, 9)] 16 | 17 | for user in users: 18 | user["friends"] = [] 19 | 20 | for i, j in friendships: 21 | # this works because users[i] is the user whose id is i 22 | users[i]["friends"].append(users[j]) # add i as a friend of j 23 | users[j]["friends"].append(users[i]) # add j as a friend of i 24 | def number_of_friends(user): 25 | """how many friends does _user_ have?""" 26 | return len(user["friends"]) 27 | 28 | total_connections = sum(number_of_friends(user) 29 | for user in users) 30 | 31 | num_users = len(users) # length of the users list 32 | avg_connections = total_connections / num_users 33 | 34 | print(num_users) 35 | print(avg_connections) -------------------------------------------------------------------------------- /22Oct2017/datascience_chap1/demo3.py: -------------------------------------------------------------------------------- 1 | users = [ 2 | { "id": 0, "name": "Hero" }, 3 | { "id": 1, "name": "Dunn" }, 4 | { "id": 2, "name": "Sue" }, 5 | { "id": 3, "name": "Chi" }, 6 | { "id": 4, "name": "Thor" }, 7 | { "id": 5, "name": "Clive" }, 8 | { "id": 6, "name": "Hicks" }, 9 | { "id": 7, "name": "Devin" }, 10 | { "id": 8, "name": "Kate" }, 11 | { "id": 9, "name": "Klein" } 12 | ] 13 | 14 | friendships = [(0, 1), (0, 2), (1, 2), (1, 3), (2, 3), (3, 4), 15 | (4, 5), (5, 6), (5, 7), (6, 8), (7, 8), (8, 9)] 16 | 17 | for user in users: 18 | user["friends"] = [] 19 | 20 | for i, j in friendships: 21 | # this works because users[i] is the user whose id is i 22 | users[i]["friends"].append(users[j]) # add i as a friend of j 23 | users[j]["friends"].append(users[i]) # add j as a friend of i 24 | def number_of_friends(user): 25 | """how many friends does _user_ have?""" 26 | return len(user["friends"]) 27 | 28 | total_connections = sum(number_of_friends(user) 29 | for user in users) 30 | 31 | num_users = len(users) # length of the users list 32 | avg_connections = total_connections / num_users 33 | 34 | # create a list (user_id, number_of_friends) 35 | num_friends_by_id = [(user["id"], number_of_friends(user)) 36 | for user in users] 37 | print(sorted(num_friends_by_id, key= lambda data: data[1], reverse=True)) 38 | 39 | # print(sorted(num_friends_by_id, reverse=True)) -------------------------------------------------------------------------------- /22Oct2017/datascience_chap1/demo4.py: -------------------------------------------------------------------------------- 1 | users = [ 2 | { "id": 0, "name": "Hero" }, 3 | { "id": 1, "name": "Dunn" }, 4 | { "id": 2, "name": "Sue" }, 5 | { "id": 3, "name": "Chi" }, 6 | { "id": 4, "name": "Thor" }, 7 | { "id": 5, "name": "Clive" }, 8 | { "id": 6, "name": "Hicks" }, 9 | { "id": 7, "name": "Devin" }, 10 | { "id": 8, "name": "Kate" }, 11 | { "id": 9, "name": "Klein" } 12 | ] 13 | 14 | friendships = [(0, 1), (0, 2), (1, 2), (1, 3), (2, 3), (3, 4), 15 | (4, 5), (5, 6), (5, 7), (6, 8), (7, 8), (8, 9)] 16 | 17 | for user in users: 18 | user["friends"] = [] 19 | 20 | for i, j in friendships: 21 | # this works because users[i] is the user whose id is i 22 | users[i]["friends"].append(users[j]) # add i as a friend of j 23 | users[j]["friends"].append(users[i]) # add j as a friend of i 24 | 25 | 26 | def friends_of_friend_ids_bad(user): 27 | # "foaf" is short for "friend of a friend" 28 | return [foaf["id"] 29 | for friend in user["friends"] # for each of user's friends 30 | for foaf in friend["friends"]] # 31 | 32 | print(friends_of_friend_ids_bad(users[0])) 33 | foafList = [friends_of_friend_ids_bad(user) for user in users] 34 | print(foafList) 35 | -------------------------------------------------------------------------------- /22Oct2017/datascience_chap1/demo5.py: -------------------------------------------------------------------------------- 1 | users = [ 2 | { "id": 0, "name": "Hero" }, 3 | { "id": 1, "name": "Dunn" }, 4 | { "id": 2, "name": "Sue" }, 5 | { "id": 3, "name": "Chi" }, 6 | { "id": 4, "name": "Thor" }, 7 | { "id": 5, "name": "Clive" }, 8 | { "id": 6, "name": "Hicks" }, 9 | { "id": 7, "name": "Devin" }, 10 | { "id": 8, "name": "Kate" }, 11 | { "id": 9, "name": "Klein" } 12 | ] 13 | 14 | friendships = [(0, 1), (0, 2), (1, 2), (1, 3), (2, 3), (3, 4), 15 | (4, 5), (5, 6), (5, 7), (6, 8), (7, 8), (8, 9)] 16 | 17 | for user in users: 18 | user["friends"] = [] 19 | 20 | for i, j in friendships: 21 | # this works because users[i] is the user whose id is i 22 | users[i]["friends"].append(users[j]) # add i as a friend of j 23 | users[j]["friends"].append(users[i]) # add j as a friend of i 24 | 25 | 26 | def friends_of_friend_ids_bad(user): 27 | # "foaf" is short for "friend of a friend" 28 | return [foaf["id"] 29 | for friend in user["friends"] # for each of user's friends 30 | for foaf in friend["friends"]] # 31 | 32 | def not_the_same(user, other_user): 33 | """two users are not the same if they have different ids""" 34 | return user["id"] != other_user["id"] 35 | 36 | print(not_the_same(users[0],users[1])) 37 | -------------------------------------------------------------------------------- /22Oct2017/datascience_chap1/demo6.py: -------------------------------------------------------------------------------- 1 | users = [ 2 | { "id": 0, "name": "Hero" }, 3 | { "id": 1, "name": "Dunn" }, 4 | { "id": 2, "name": "Sue" }, 5 | { "id": 3, "name": "Chi" }, 6 | { "id": 4, "name": "Thor" }, 7 | { "id": 5, "name": "Clive" }, 8 | { "id": 6, "name": "Hicks" }, 9 | { "id": 7, "name": "Devin" }, 10 | { "id": 8, "name": "Kate" }, 11 | { "id": 9, "name": "Klein" } 12 | ] 13 | 14 | friendships = [(0, 1), (0, 2), (1, 2), (1, 3), (2, 3), (3, 4), 15 | (4, 5), (5, 6), (5, 7), (6, 8), (7, 8), (8, 9)] 16 | 17 | for user in users: 18 | user["friends"] = [] 19 | 20 | for i, j in friendships: 21 | # this works because users[i] is the user whose id is i 22 | users[i]["friends"].append(users[j]) # add i as a friend of j 23 | users[j]["friends"].append(users[i]) # add j as a friend of i 24 | 25 | 26 | def friends_of_friend_ids_bad(user): 27 | # "foaf" is short for "friend of a friend" 28 | return [foaf["id"] 29 | for friend in user["friends"] # for each of user's friends 30 | for foaf in friend["friends"]] # 31 | 32 | def not_the_same(user, other_user): 33 | """two users are not the same if they have different ids""" 34 | return user["id"] != other_user["id"] 35 | 36 | 37 | def not_friends(user, other_user): 38 | """other_user is not a friend if he's not in user["friends"]; 39 | that is, if he's not_the_same as all the people in user["friends"]""" 40 | return all(not_the_same(friend, other_user) 41 | for friend in user["friends"]) 42 | 43 | print(not_friends(users[0],users[3])) 44 | -------------------------------------------------------------------------------- /22Oct2017/datascience_chap1/demo7.py: -------------------------------------------------------------------------------- 1 | users = [ 2 | { "id": 0, "name": "Hero" }, 3 | { "id": 1, "name": "Dunn" }, 4 | { "id": 2, "name": "Sue" }, 5 | { "id": 3, "name": "Chi" }, 6 | { "id": 4, "name": "Thor" }, 7 | { "id": 5, "name": "Clive" }, 8 | { "id": 6, "name": "Hicks" }, 9 | { "id": 7, "name": "Devin" }, 10 | { "id": 8, "name": "Kate" }, 11 | { "id": 9, "name": "Klein" } 12 | ] 13 | 14 | friendships = [(0, 1), (0, 2), (1, 2), (1, 3), (2, 3), (3, 4), 15 | (4, 5), (5, 6), (5, 7), (6, 8), (7, 8), (8, 9)] 16 | 17 | for user in users: 18 | user["friends"] = [] 19 | 20 | for i, j in friendships: 21 | # this works because users[i] is the user whose id is i 22 | users[i]["friends"].append(users[j]) # add i as a friend of j 23 | users[j]["friends"].append(users[i]) # add j as a friend of i 24 | 25 | 26 | def friends_of_friend_ids_bad(user): 27 | # "foaf" is short for "friend of a friend" 28 | return [foaf["id"] 29 | for friend in user["friends"] # for each of user's friends 30 | for foaf in friend["friends"]] # 31 | 32 | def not_the_same(user, other_user): 33 | """two users are not the same if they have different ids""" 34 | return user["id"] != other_user["id"] 35 | 36 | 37 | def not_friends(user, other_user): 38 | """other_user is not a friend if he's not in user["friends"]; 39 | that is, if he's not_the_same as all the people in user["friends"]""" 40 | return all(not_the_same(friend, other_user) 41 | for friend in user["friends"]) 42 | 43 | from collections import Counter 44 | 45 | def friends_of_friend_ids(user): 46 | return Counter(foaf["id"] 47 | for friend in user["friends"] 48 | for foaf in friend["friends"] 49 | if not_the_same(user, foaf) 50 | and not_friends(user, foaf)) # and aren't my friends 51 | 52 | print(friends_of_friend_ids(users[0])) -------------------------------------------------------------------------------- /23July2017/hello/.idea/hello.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /23July2017/hello/.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /23July2017/hello/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /23July2017/hello/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /23July2017/hello/eight.py: -------------------------------------------------------------------------------- 1 | num1 = 0.1 2 | num2 = 0.2 3 | print(num1 + num2) 4 | print(num1 - num2) 5 | print(num1 * num2) 6 | num3 = 5 7 | #print(num3) 8 | -------------------------------------------------------------------------------- /23July2017/hello/fifth.py: -------------------------------------------------------------------------------- 1 | name = " hello world " 2 | name = name.strip() 3 | name = name.title() 4 | 5 | name1 = name.strip() 6 | name2 = name1.title() 7 | print(name2) 8 | 9 | -------------------------------------------------------------------------------- /23July2017/hello/first.py: -------------------------------------------------------------------------------- 1 | print("Hello New world") 2 | 3 | name = "Mughal" 4 | name = 'Mughal' 5 | age = 45 6 | email = "zeeshanhanif@gmail.com" 7 | print(name) 8 | name = 67 9 | print(name) 10 | 11 | name1 = "My father\"s name is M. Aslam" 12 | print(name1) 13 | 14 | 15 | -------------------------------------------------------------------------------- /23July2017/hello/forth.py: -------------------------------------------------------------------------------- 1 | languages = "Languages:\n\tPython\n\tC\n\tJavaScript" 2 | print(languages) 3 | 4 | name = " Hello World " 5 | print(name) 6 | print(name.rstrip()) 7 | print(name.lstrip()) 8 | print(name.strip()) 9 | print(name) -------------------------------------------------------------------------------- /23July2017/hello/second.py: -------------------------------------------------------------------------------- 1 | name = "qasim" 2 | name1 = name.title() 3 | print(name) 4 | print(name1) 5 | print(name.title()) 6 | print(name.upper()) 7 | print(name.lower()) 8 | print(name) -------------------------------------------------------------------------------- /23July2017/hello/seventh.py: -------------------------------------------------------------------------------- 1 | num1 = 81 2 | num2 = 3 3 | 4 | print(num1 + num2) 5 | print(num1 - num2) 6 | print(num1 / num2) 7 | print(num1 * num2) 8 | print(num1 % num2) 9 | print(num1 ** num2) 10 | print(num1 // num2) 11 | 12 | 13 | num3 = 5 - 3 * 2 + 2 / 2 14 | print(num3) -------------------------------------------------------------------------------- /23July2017/hello/sixth.py: -------------------------------------------------------------------------------- 1 | name = " hello world " 2 | print(name.strip().title()) -------------------------------------------------------------------------------- /23July2017/hello/third.py: -------------------------------------------------------------------------------- 1 | firstName = "Qasim" 2 | lastName = "M. Aslam" 3 | age = 45 4 | 5 | fullName = firstName +" "+ lastName 6 | print(firstName) 7 | print(lastName) 8 | print(fullName) 9 | print(firstName,lastName) 10 | 11 | fullName1 = firstName + " " + lastName +" " +str(age) 12 | print(fullName1) 13 | 14 | -------------------------------------------------------------------------------- /24Sep2017/datascience_chap2/.idea/datascience_chap2.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /24Sep2017/datascience_chap2/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /24Sep2017/datascience_chap2/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /24Sep2017/datascience_chap2/abc.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "collapsed": true 8 | }, 9 | "outputs": [], 10 | "source": [ 11 | "for i in [1, 2, 3, 4, 5]:\n", 12 | "\n", 13 | " # notice the blank line\n", 14 | " print (i)" 15 | ] 16 | } 17 | ], 18 | "metadata": { 19 | "kernelspec": { 20 | "display_name": "Python 2", 21 | "language": "python", 22 | "name": "python2" 23 | }, 24 | "language_info": { 25 | "codemirror_mode": { 26 | "name": "ipython", 27 | "version": 2 28 | }, 29 | "file_extension": ".py", 30 | "mimetype": "text/x-python", 31 | "name": "python", 32 | "nbconvert_exporter": "python", 33 | "pygments_lexer": "ipython2", 34 | "version": "2.7.6" 35 | } 36 | }, 37 | "nbformat": 4, 38 | "nbformat_minor": 0 39 | } 40 | -------------------------------------------------------------------------------- /24Sep2017/datascience_chap2/demo1.py: -------------------------------------------------------------------------------- 1 | two_plus_three = 2 + \ 2 | 3 3 | print(two_plus_three) 4 | 5 | name =" Muhammad " \ 6 | "Qasim" 7 | print(name) 8 | 9 | details ="""" Q 10 | Muhammd Qasim 11 | Muhammd Aslam 12 | """ 13 | 14 | print(details) -------------------------------------------------------------------------------- /24Sep2017/datascience_chap2/demo10.py: -------------------------------------------------------------------------------- 1 | word_count = { 2 | "hello":4, 3 | "world":6, 4 | "bye":1, 5 | "working":3 6 | } 7 | x = sorted(word_count.items()) 8 | y = sorted(word_count.values()) 9 | 10 | z = sorted(word_count.items(), key= [lambda a,b:b]) 11 | print(x) 12 | print(y) 13 | print(z) 14 | -------------------------------------------------------------------------------- /24Sep2017/datascience_chap2/demo2.py: -------------------------------------------------------------------------------- 1 | for i in [1, 2, 3, 4, 5]: 2 | 3 | # notice the blank line 4 | print (i) -------------------------------------------------------------------------------- /24Sep2017/datascience_chap2/demo3.py: -------------------------------------------------------------------------------- 1 | mylist = (2,94,14) 2 | 3 | a, b, c = mylist 4 | 5 | print(mylist) 6 | print(a) 7 | print(b) 8 | print(c) -------------------------------------------------------------------------------- /24Sep2017/datascience_chap2/demo4.py: -------------------------------------------------------------------------------- 1 | def sum_and_product(x, y): 2 | return (x + y),(x * y), (x*y) 3 | 4 | sp = sum_and_product(2, 3) # equals (5, 6) 5 | s, p,t = sum_and_product(5, 10) # s is 15, p is 50 6 | 7 | print(sp) 8 | print(s) 9 | print(p) 10 | print(t) -------------------------------------------------------------------------------- /24Sep2017/datascience_chap2/demo5.py: -------------------------------------------------------------------------------- 1 | from collections import Counter 2 | c = Counter([0, 1, 2, 0]) 3 | print(c) 4 | mostCommon = c.most_common(1) 5 | print(mostCommon) 6 | 7 | a,b = mostCommon[0] 8 | print(a) 9 | print(b) 10 | -------------------------------------------------------------------------------- /24Sep2017/datascience_chap2/demo6.py: -------------------------------------------------------------------------------- 1 | x = 11 2 | y = 21 3 | parity = "even" if x % 2 == 0 else "odd" 4 | print(parity) 5 | 6 | parity2 = "even" if x % 2 == 0 else "y even" if y % 2 == 0 else "y odd" 7 | print(parity2) -------------------------------------------------------------------------------- /24Sep2017/datascience_chap2/demo7.py: -------------------------------------------------------------------------------- 1 | v = [45,47] 2 | 3 | if v: 4 | print("its true") 5 | else: 6 | print("its false") -------------------------------------------------------------------------------- /24Sep2017/datascience_chap2/demo8.py: -------------------------------------------------------------------------------- 1 | print(all(["",True, 1, { 3 }])) 2 | 3 | -------------------------------------------------------------------------------- /24Sep2017/datascience_chap2/demo9.py: -------------------------------------------------------------------------------- 1 | x = sorted([-4,1,-2,3], key=abs, reverse=True) 2 | print(x) -------------------------------------------------------------------------------- /27Aug2017/Objects/.idea/Objects.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /27Aug2017/Objects/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /27Aug2017/Objects/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /27Aug2017/Objects/object3.py: -------------------------------------------------------------------------------- 1 | class Dog(): 2 | """A simple attempt to model a dog.""" 3 | 4 | def __init__(self,name,age): 5 | print("Dog init") 6 | print("Name ",name) 7 | print("Age ", age) 8 | self.name = name 9 | self.age = age 10 | 11 | def bark(self): 12 | print(self.name +" is barking") 13 | 14 | e = Dog("willie",6) 15 | e.bark() -------------------------------------------------------------------------------- /27Aug2017/Objects/objects1.py: -------------------------------------------------------------------------------- 1 | class Dog(): 2 | """A simple attempt to model a dog.""" 3 | 4 | def __init__(self,name,age): 5 | print("Dog init") 6 | print("Name ",name) 7 | print("Age ", age) 8 | 9 | #def __init__(self,name): 10 | # print("Dog init") 11 | # print("Name ",name) 12 | 13 | def bark(self): 14 | print("Dog is barking") 15 | 16 | e = Dog("willie",6) 17 | #g = Dog("willie") 18 | #print(d) 19 | #d.bark() 20 | -------------------------------------------------------------------------------- /27Aug2017/Objects/objects10.py: -------------------------------------------------------------------------------- 1 | class Car(): 2 | 3 | def __init__(self,make,model,year): 4 | self.make = make 5 | self.model = model 6 | self.year = year 7 | self.__odometer_reading = 5 8 | 9 | 10 | def get_descriptive_name(self): 11 | long_name = str(self.year)+ ' '+self.make + ' ' + self.model + ' '+ str(self.__odometer_reading) 12 | return long_name 13 | 14 | def update_odometer(self, val): 15 | self.__odometer_reading = val 16 | 17 | def get_odometer(self): 18 | return self.__odometer_reading 19 | 20 | 21 | c = Car('audi', 'a4', 2016) 22 | 23 | print(c.get_odometer()) 24 | c.update_odometer(400000) 25 | print(c.get_odometer()) 26 | 27 | 28 | -------------------------------------------------------------------------------- /27Aug2017/Objects/objects11.py: -------------------------------------------------------------------------------- 1 | class Car(): 2 | 3 | def __init__(self,make,model,year): 4 | self.make = make 5 | self.model = model 6 | self.year = year 7 | self.__odometer_reading = 5 8 | 9 | 10 | def get_descriptive_name(self): 11 | long_name = str(self.year)+ ' '+self.make + ' ' + self.model + ' '+ str(self.__odometer_reading) 12 | return long_name 13 | 14 | def update_odometer(self, val): 15 | self.__odometer_reading = val 16 | 17 | def get_odometer(self): 18 | return self.__odometer_reading 19 | 20 | def __start(self): 21 | print("Car started") 22 | 23 | 24 | c = Car('audi', 'a4', 2016) 25 | 26 | c.__start() 27 | -------------------------------------------------------------------------------- /27Aug2017/Objects/objects12.py: -------------------------------------------------------------------------------- 1 | class Car(): 2 | 3 | def __init__(self,make,model,year): 4 | self.make = make 5 | self.model = model 6 | self.year = year 7 | 8 | 9 | def get_descriptive_name(self): 10 | long_name = str(self.year)+ ' '+self.make + ' ' + self.model 11 | return long_name 12 | 13 | def __str__(self): 14 | return "Make = "+self.make + ", Model = " + self.model + ", Year = "+ str(self.year) 15 | 16 | c = Car('audi', 'a4', 2016) 17 | 18 | print(c) 19 | -------------------------------------------------------------------------------- /27Aug2017/Objects/objects13.py: -------------------------------------------------------------------------------- 1 | class Car(): 2 | 3 | def __init__(self,make,model,year): 4 | self.make = make 5 | self.model = model 6 | self.year = year 7 | self.__odometer_reading = 5 8 | 9 | 10 | def get_descriptive_name(self): 11 | long_name = str(self.year)+ ' '+self.make + ' ' + self.model + ' '+ str(self.__odometer_reading) 12 | return long_name 13 | 14 | def update_odometer(self, val): 15 | self.__odometer_reading = val 16 | 17 | def get_odometer(self): 18 | return self.__odometer_reading 19 | 20 | def __start(self): 21 | print("Car started") 22 | 23 | class ElectricCar(Car): 24 | '''ElectricCar''' 25 | def __init__(self,make,model,year): 26 | super().__init__(make,model,year) 27 | #self.make = make 28 | #self.model = model 29 | #self.year = year 30 | 31 | 32 | c = Car('audi', 'a4', 2016) 33 | ec = ElectricCar('Tesla', 's4', 2016) 34 | print(ec.get_descriptive_name()) 35 | print(ec.year) -------------------------------------------------------------------------------- /27Aug2017/Objects/objects14.py: -------------------------------------------------------------------------------- 1 | class Car(): 2 | 3 | def __init__(self,make,model,year): 4 | self.make = make 5 | self.model = model 6 | self.year = year 7 | self.__odometer_reading = 5 8 | 9 | 10 | def get_descriptive_name(self): 11 | #long_name = str(self.year)+ ' '+self.make + ' ' + self.model + ' '+ str(self.__odometer_reading) 12 | long_name = str(self.year) + ' ' + self.make + ' ' + self.model 13 | return long_name 14 | 15 | def update_odometer(self, val): 16 | self.__odometer_reading = val 17 | 18 | def get_odometer(self): 19 | return self.__odometer_reading 20 | 21 | def __start(self): 22 | print("Car started") 23 | 24 | class ElectricCar(Car): 25 | '''ElectricCar''' 26 | def __init__(self,make,model,year): 27 | #super().__init__(make,model,year) 28 | self.make = make 29 | self.model = model 30 | self.year = year 31 | 32 | 33 | c = Car('audi', 'a4', 2016) 34 | ec = ElectricCar('Tesla', 's4', 2016) 35 | print(ec.get_descriptive_name()) 36 | -------------------------------------------------------------------------------- /27Aug2017/Objects/objects2.py: -------------------------------------------------------------------------------- 1 | class Dog(): 2 | """A simple attempt to model a dog.""" 3 | 4 | def __init__(self,name,age): 5 | print("Dog init") 6 | print("Name ",name) 7 | print("Age ", age) 8 | self.name = name 9 | self.age = age 10 | 11 | def bark(self): 12 | print("Dog is barking") 13 | 14 | e = Dog("willie",6) 15 | 16 | print(e.name) 17 | print(e.age) 18 | e.age = 10 19 | print(e.age) 20 | -------------------------------------------------------------------------------- /27Aug2017/Objects/objects4.py: -------------------------------------------------------------------------------- 1 | class Dog(): 2 | """A simple attempt to model a dog.""" 3 | 4 | def __init__(self,name,age): 5 | print("Dog init") 6 | print("Name ",name) 7 | print("Age ", age) 8 | self.name = name 9 | self.age = age 10 | 11 | def bark(self): 12 | print(self.name +" is barking") 13 | 14 | myDog = Dog("willie",6) 15 | yourDog = Dog("lucy",3) 16 | 17 | myDog.bark() 18 | yourDog.bark() 19 | -------------------------------------------------------------------------------- /27Aug2017/Objects/objects5.py: -------------------------------------------------------------------------------- 1 | class Dog(): 2 | """A simple attempt to model a dog.""" 3 | total = 0 4 | def __init__(self,name,age): 5 | print("Dog init") 6 | print("Name ",name) 7 | print("Age ", age) 8 | self.name = name 9 | self.age = age 10 | Dog.total = Dog.total+1 11 | 12 | def bark(self): 13 | print(self.name +" is barking") 14 | 15 | myDog = Dog("willie",6) 16 | yourDog = Dog("lucy",3) 17 | 18 | myDog.bark() 19 | yourDog.bark() 20 | print(Dog.total) 21 | 22 | 23 | -------------------------------------------------------------------------------- /27Aug2017/Objects/objects6.py: -------------------------------------------------------------------------------- 1 | class Dog(): 2 | """A simple attempt to model a dog.""" 3 | total = 0 4 | def __init__(a,name,age): 5 | print("Dog init") 6 | print("Name ",name) 7 | print("Age ", age) 8 | a.name = name 9 | a.age = age 10 | Dog.total = Dog.total+1 11 | 12 | def bark(b): 13 | print(b.name +" is barking") 14 | 15 | myDog = Dog("willie",6) 16 | yourDog = Dog("lucy",3) 17 | 18 | myDog.bark() 19 | yourDog.bark() 20 | print(Dog.total) 21 | 22 | 23 | -------------------------------------------------------------------------------- /27Aug2017/Objects/objects7.py: -------------------------------------------------------------------------------- 1 | class Dog(): 2 | """A simple attempt to model a dog.""" 3 | total = 0 4 | def __init__(a,name,age): 5 | print("Dog init") 6 | print("Name ",name) 7 | print("Age ", age) 8 | a.name = name 9 | a.age = age 10 | Dog.total = Dog.total+1 11 | 12 | def bark(b): 13 | print(b.name +" is barking") 14 | 15 | myDog = Dog("willie",6) 16 | yourDog = Dog("lucy",3) 17 | 18 | myDog.bark() 19 | yourDog.bark() 20 | print(Dog.total) 21 | 22 | 23 | -------------------------------------------------------------------------------- /27Aug2017/Objects/objects8.py: -------------------------------------------------------------------------------- 1 | class Car(): 2 | 3 | def __init__(self,make,model,year): 4 | self.make = make 5 | self.model = model 6 | self.year = year 7 | 8 | def get_descriptive_name(self): 9 | long_name = str(self.year)+ ' '+self.make + ' ' + self.model 10 | return long_name 11 | 12 | 13 | c = Car('audi', 'a4', 2016) 14 | name = c.get_descriptive_name() 15 | print(name) 16 | 17 | 18 | -------------------------------------------------------------------------------- /27Aug2017/Objects/objects9.py: -------------------------------------------------------------------------------- 1 | class Car(): 2 | 3 | def __init__(self,make,model,year): 4 | self.make = make 5 | self.model = model 6 | self.year = year 7 | self.odometer_reading = 0 8 | 9 | 10 | def get_descriptive_name(self): 11 | long_name = str(self.year)+ ' '+self.make + ' ' + self.model 12 | return long_name 13 | 14 | 15 | c = Car('audi', 'a4', 2016) 16 | name = c.get_descriptive_name() 17 | print(name) 18 | -------------------------------------------------------------------------------- /29Oct2017/29Oct2017/datascience_chap1/.idea/datascience_chap1.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /29Oct2017/29Oct2017/datascience_chap1/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /29Oct2017/29Oct2017/datascience_chap1/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /29Oct2017/29Oct2017/datascience_chap1/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 102 | 103 | 104 | 116 | 117 | 118 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 87 | 88 | 89 | 91 | 92 | 93 | 94 | 1509275691937 95 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /29Oct2017/29Oct2017/demoObjects/obj1.py: -------------------------------------------------------------------------------- 1 | hmgjgjghjh 2 | -------------------------------------------------------------------------------- /30July2017/DemoList/.idea/DemoList.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /30July2017/DemoList/.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /30July2017/DemoList/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /30July2017/DemoList/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /30July2017/DemoList/List1.py: -------------------------------------------------------------------------------- 1 | bicycles = ['trek', 'cannondale', 2 | 'redline', 'specialized'] 3 | print(bicycles) 4 | print(bicycles[0]) 5 | singleBicycle = bicycles[2] 6 | print(singleBicycle.upper()) 7 | print(bicycles) 8 | print(bicycles[-3]) -------------------------------------------------------------------------------- /30July2017/DemoList/List10.py: -------------------------------------------------------------------------------- 1 | cars = ['bmw', 'audi', 'toyota', 'subaru',"abc"] 2 | print(cars) 3 | 4 | count = len(cars) 5 | print(count) 6 | print(cars[-1]) 7 | print(cars[-10]) -------------------------------------------------------------------------------- /30July2017/DemoList/List2.py: -------------------------------------------------------------------------------- 1 | motorcycles = ['honda', 'yamaha', 'suzuki'] 2 | print(motorcycles) 3 | 4 | #motorcycles[0] = 'ducati' 5 | motorcycles.append('ducati') 6 | print(motorcycles) 7 | 8 | motorcycles.insert(1,"hero") 9 | print(motorcycles) 10 | 11 | #motorcycles[5] = "Hello world" 12 | motorcycles.insert(5,"Hello World") 13 | print(motorcycles) 14 | 15 | del motorcycles[1]; 16 | print(motorcycles) 17 | 18 | -------------------------------------------------------------------------------- /30July2017/DemoList/List3.py: -------------------------------------------------------------------------------- 1 | motorcycles = ['honda', 'yamaha', 'suzuki'] 2 | removedMotorCycles = [] 3 | print(motorcycles) 4 | 5 | a1 = motorcycles.pop() 6 | removedMotorCycles.append(a1) 7 | print(motorcycles) 8 | print(a1) 9 | 10 | a2 = motorcycles.pop() 11 | removedMotorCycles.append(a2) 12 | print(motorcycles) 13 | print(a2) -------------------------------------------------------------------------------- /30July2017/DemoList/List4.py: -------------------------------------------------------------------------------- 1 | motorcycles = ['honda', 'yamaha', 'suzuki'] 2 | removedMotorCycles = [] 3 | print(motorcycles) 4 | 5 | removedMotorCycles.append(motorcycles.pop()) 6 | 7 | print(motorcycles) 8 | print(removedMotorCycles) 9 | 10 | removedMotorCycles.append(motorcycles.pop()) 11 | print(motorcycles) 12 | print(removedMotorCycles) 13 | -------------------------------------------------------------------------------- /30July2017/DemoList/List5.py: -------------------------------------------------------------------------------- 1 | motorcycles = ['honda', 'yamaha', 'suzuki'] 2 | removedMotorCycles = [] 3 | print(motorcycles) 4 | 5 | a1 = motorcycles.remove("yamaha") 6 | print(motorcycles) 7 | print(a1) -------------------------------------------------------------------------------- /30July2017/DemoList/List6.py: -------------------------------------------------------------------------------- 1 | cars = ['bmw', 'audi', 'toyota', 'subaru'] 2 | print(cars) 3 | cars.sort() 4 | print(cars) -------------------------------------------------------------------------------- /30July2017/DemoList/List7.py: -------------------------------------------------------------------------------- 1 | cars = ['bmw', 'audi', 'toyota', 'subaru'] 2 | print(cars) 3 | cars.sort(reverse=True) 4 | print(cars) -------------------------------------------------------------------------------- /30July2017/DemoList/List8.py: -------------------------------------------------------------------------------- 1 | cars = ['bmw', 'audi', 'toyota', 'subaru'] 2 | print(cars) 3 | #sortedList = sorted(cars) 4 | sortedList = cars.sort() 5 | print(cars) 6 | print(sortedList) 7 | -------------------------------------------------------------------------------- /30July2017/DemoList/List9.py: -------------------------------------------------------------------------------- 1 | cars = ['bmw', 'audi', 'toyota', 'subaru'] 2 | twoCars = cars[0] + " " +cars[1] 3 | print(twoCars) 4 | 5 | print(cars) 6 | cars.reverse() 7 | print(cars) -------------------------------------------------------------------------------- /30July2017/DemoListChap4/.idea/DemoListChap4.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /30July2017/DemoListChap4/.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /30July2017/DemoListChap4/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /30July2017/DemoListChap4/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /30July2017/DemoListChap4/List1.py: -------------------------------------------------------------------------------- 1 | magicians = ['alice', 'david', 'carolina'] 2 | 3 | for magician in magicians: 4 | print("Hello Mr. ",magician) 5 | print(magician) 6 | print("Hello ") -------------------------------------------------------------------------------- /30July2017/DemoListChap4/List2.py: -------------------------------------------------------------------------------- 1 | names = ["Wajid","Ali","Qasim","Zeeshan"] 2 | 3 | for a in names: 4 | print("Hello world",a) 5 | print("New line testing") 6 | 7 | print("Working") -------------------------------------------------------------------------------- /30July2017/DemoListChap4/List3.py: -------------------------------------------------------------------------------- 1 | for value in range(1,15): 2 | print(value) 3 | 4 | for value in range(1,10,2): 5 | print(value) 6 | print("---") 7 | for value in range(100,0,-5): 8 | 9 | print(value) -------------------------------------------------------------------------------- /30July2017/DemoListChap4/List4.py: -------------------------------------------------------------------------------- 1 | names = ["Wajid","Ali","Qasim","Zeeshan"] 2 | for value in range(0,len(names)): 3 | print(value) 4 | print(names[value]) -------------------------------------------------------------------------------- /30July2017/DemoListChap4/List5.py: -------------------------------------------------------------------------------- 1 | names = ["Wajid","Ali","Qasim","Zeeshan"] 2 | for value in range(len(names)-1,-1,-1): 3 | print(value) 4 | print(names[value]) -------------------------------------------------------------------------------- /30July2017/DemoListChap4/List6.py: -------------------------------------------------------------------------------- 1 | for value in range(1,10): 2 | abc = 34 3 | print("Hello", value) 4 | 5 | print("New", value) 6 | print("New2", abc) -------------------------------------------------------------------------------- /30July2017/DemoListChap4/List7.py: -------------------------------------------------------------------------------- 1 | 2 | mylist = range(1,10) 3 | print(mylist) 4 | mylist2 = list(range(1,5)); 5 | print(mylist2) 6 | 7 | mylist3 = list(range(1,20,3)); 8 | print(mylist3) -------------------------------------------------------------------------------- /6Aug2017/DemoIfElse/.idea/DemoIfElse.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /6Aug2017/DemoIfElse/.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /6Aug2017/DemoIfElse/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /6Aug2017/DemoIfElse/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /6Aug2017/DemoIfElse/IfElse1.py: -------------------------------------------------------------------------------- 1 | cars = ['audi', 'bmw', 'subaru', 'toyota'] 2 | for car in cars: 3 | if car == 'bmw': 4 | print(car.upper()) 5 | else: 6 | print(car.title()) -------------------------------------------------------------------------------- /6Aug2017/DemoIfElse/IfElse2.py: -------------------------------------------------------------------------------- 1 | marks = 95 2 | 3 | if marks > 80: 4 | print("A+") 5 | elif marks >70: 6 | print("A") 7 | elif marks >60: 8 | print("B") 9 | elif marks > 50: 10 | print("C") 11 | elif marks > 40: 12 | print("D") 13 | else: 14 | print("Failed") 15 | 16 | -------------------------------------------------------------------------------- /6Aug2017/DemoIfElse/IfElse3.py: -------------------------------------------------------------------------------- 1 | marks = 95 2 | 3 | if marks > 40: 4 | print("D") 5 | elif marks > 50: 6 | print("C") 7 | elif marks > 60: 8 | print("B") 9 | elif marks >70: 10 | print("A") 11 | elif marks > 80: 12 | print("A+") 13 | else: 14 | print("Failed") 15 | 16 | -------------------------------------------------------------------------------- /6Aug2017/DemoIfElse/IfElse4.py: -------------------------------------------------------------------------------- 1 | marks = 70 2 | 3 | if marks > 40 and marks < 50: 4 | print("D") 5 | elif marks > 50 and marks <60: 6 | print("C") 7 | elif marks > 60 and marks <70: 8 | print("B") 9 | elif marks >70 and marks < 80: 10 | print("A") 11 | elif marks > 80: 12 | print("A+") 13 | else: 14 | print("Failed") 15 | 16 | -------------------------------------------------------------------------------- /6Aug2017/DemoIfElse/IfElse5.py: -------------------------------------------------------------------------------- 1 | marks = 39 2 | 3 | if marks >= 40 and marks < 50: 4 | print("D") 5 | elif marks >= 50 and marks <60: 6 | print("C") 7 | elif marks >= 60 and marks <70: 8 | print("B") 9 | elif marks >= 70 and marks < 80: 10 | print("A") 11 | elif marks >= 80: 12 | print("A+") 13 | else: 14 | print("Failed") 15 | 16 | -------------------------------------------------------------------------------- /6Aug2017/DemoIfElse/InOperator.py: -------------------------------------------------------------------------------- 1 | requested_toppings = ['mushrooms', 'onions', 'pineapple'] 2 | 3 | print('moshrooms' in requested_toppings) 4 | 5 | if 'mushrooms' in requested_toppings: 6 | print("Ok Sir") 7 | else : 8 | print("Sorry, not available Sir ") 9 | -------------------------------------------------------------------------------- /6Aug2017/DemoList/.idea/DemoList.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /6Aug2017/DemoList/.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /6Aug2017/DemoList/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /6Aug2017/DemoList/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /6Aug2017/DemoList/List1.py: -------------------------------------------------------------------------------- 1 | squares = [] 2 | 3 | for value in range(1,11): 4 | square = value**2 5 | square = square+2 6 | squares.append(square) 7 | 8 | 9 | print(squares) 10 | -------------------------------------------------------------------------------- /6Aug2017/DemoList/List10.py: -------------------------------------------------------------------------------- 1 | players = ['charles', 'martina', 'michael', 2 | 'florence', 'eli',"asdf", 3 | "asdfa","asdfadf","astest"] 4 | fewPlayers = players[:] 5 | print(fewPlayers) 6 | print(players) -------------------------------------------------------------------------------- /6Aug2017/DemoList/List11.py: -------------------------------------------------------------------------------- 1 | players = ['charles', 'martina', 'michael', 2 | 'florence', 'eli',"1", 3 | "2","3","4"] 4 | fewPlayers = players[1:6:2] 5 | print(fewPlayers) 6 | print(players) -------------------------------------------------------------------------------- /6Aug2017/DemoList/List12.py: -------------------------------------------------------------------------------- 1 | players = ['charles', 'martina', 'michael', 2 | 'florence', 'eli',"1", 3 | "2","3","4"] 4 | fewPlayers = players[::2] 5 | print(fewPlayers) 6 | print(players) -------------------------------------------------------------------------------- /6Aug2017/DemoList/List13.py: -------------------------------------------------------------------------------- 1 | players = ['charles', 'martina', 'michael', 2 | 'florence', 'eli',"1", 3 | "2","3","4"] 4 | print(players) 5 | for p in players[::2]: 6 | print(p.title()) 7 | 8 | -------------------------------------------------------------------------------- /6Aug2017/DemoList/List14.py: -------------------------------------------------------------------------------- 1 | players = ['charles', 'martina', 'michael', 2 | 'florence', 'eli',"1", 3 | "2","3","4"] 4 | print(players) 5 | print(players[-3]) 6 | fewPlayers = players[-3:] 7 | print(fewPlayers) 8 | 9 | -------------------------------------------------------------------------------- /6Aug2017/DemoList/List15.py: -------------------------------------------------------------------------------- 1 | players = ['charles', 'martina', 'michael', 2 | 'florence', 'eli',"1", 3 | "2","3","4"] 4 | print(players) 5 | print(players[-3]) 6 | fewPlayers = players[-5:-3] 7 | print(fewPlayers) 8 | 9 | -------------------------------------------------------------------------------- /6Aug2017/DemoList/List16.py: -------------------------------------------------------------------------------- 1 | players = ['charles', 'martina', 'michael', 2 | 'florence', 'eli',"1", 3 | "2","3","4"] 4 | print(players) 5 | print(players[-3]) 6 | fewPlayers = players[-3:-7:-1] 7 | print(fewPlayers) 8 | 9 | -------------------------------------------------------------------------------- /6Aug2017/DemoList/List17.py: -------------------------------------------------------------------------------- 1 | players = ['charles', 'martina', 'michael', 2 | 'florence', 'eli',"1", 3 | "2","3","4"] 4 | print(players) 5 | print(players[-3]) 6 | fewPlayers = players[::-1] 7 | print(fewPlayers) 8 | 9 | -------------------------------------------------------------------------------- /6Aug2017/DemoList/List18.py: -------------------------------------------------------------------------------- 1 | my_foods = ['pizza', 'falafel', 'carrot cake'] 2 | friend_foods = my_foods[:] 3 | my_foods.append('cannoli') 4 | friend_foods.append('ice cream') 5 | print("My favorite foods are:") 6 | print(my_foods) 7 | print(friend_foods) -------------------------------------------------------------------------------- /6Aug2017/DemoList/List2.py: -------------------------------------------------------------------------------- 1 | squares = [] 2 | 3 | for value in range(1,11): 4 | squares.append(value**2) 5 | 6 | 7 | print(squares) 8 | -------------------------------------------------------------------------------- /6Aug2017/DemoList/List3.py: -------------------------------------------------------------------------------- 1 | squares = [] 2 | 3 | for value in range(1,11): 4 | squares.append(value**2) 5 | 6 | 7 | print(squares) 8 | 9 | minVal = min(squares) 10 | maxVal = max(squares) 11 | sumVal = sum(squares) 12 | countVal = len(squares) 13 | 14 | print("Min",minVal) 15 | print("Max",maxVal) 16 | print("Sum",sumVal) 17 | print("Count",countVal) 18 | print("Average",sumVal/countVal) 19 | 20 | 21 | -------------------------------------------------------------------------------- /6Aug2017/DemoList/List4.py: -------------------------------------------------------------------------------- 1 | values = [val for val in range(1,11)] 2 | values2 = [val for val in range(1,11,2)] 3 | squares = [value**2+2 for value in range(1,11)] 4 | print(squares) 5 | -------------------------------------------------------------------------------- /6Aug2017/DemoList/List5.py: -------------------------------------------------------------------------------- 1 | print([val for val in range(1,11)]) -------------------------------------------------------------------------------- /6Aug2017/DemoList/List6.py: -------------------------------------------------------------------------------- 1 | players = ['charles', 'martina', 'michael', 'florence', 'eli'] 2 | fewPlayers = players[1:3] 3 | print(fewPlayers) 4 | fewPlayers[0] = "Hello" 5 | print(fewPlayers) 6 | print(players) -------------------------------------------------------------------------------- /6Aug2017/DemoList/List7.py: -------------------------------------------------------------------------------- 1 | players = ['charles', 'martina', 'michael', 2 | 'florence', 'eli',"asdf", 3 | "asdfa","asdfadf","astest"] 4 | fewPlayers = players[4:7] 5 | print(fewPlayers) 6 | print(players) -------------------------------------------------------------------------------- /6Aug2017/DemoList/List8.py: -------------------------------------------------------------------------------- 1 | players = ['charles', 'martina', 'michael', 2 | 'florence', 'eli',"asdf", 3 | "asdfa","asdfadf","astest"] 4 | fewPlayers = players[:4] 5 | print(fewPlayers) 6 | print(players) -------------------------------------------------------------------------------- /6Aug2017/DemoList/List9.py: -------------------------------------------------------------------------------- 1 | players = ['charles', 'martina', 'michael', 2 | 'florence', 'eli',"asdf", 3 | "asdfa","asdfadf","astest"] 4 | fewPlayers = players[4:] 5 | print(fewPlayers) 6 | print(players) -------------------------------------------------------------------------------- /6Aug2017/DemoTuple/.idea/DemoTuple.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /6Aug2017/DemoTuple/.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /6Aug2017/DemoTuple/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /6Aug2017/DemoTuple/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /6Aug2017/DemoTuple/tuple1.py: -------------------------------------------------------------------------------- 1 | dimensions = (200, 50) 2 | print(dimensions) 3 | print(dimensions[0]) 4 | print(dimensions[1]) 5 | 6 | 7 | -------------------------------------------------------------------------------- /6Aug2017/DemoTuple/tuple2.py: -------------------------------------------------------------------------------- 1 | dimensions = (200, 50) 2 | print(dimensions) 3 | #dimensions.append(34) 4 | print(dimensions) 5 | 6 | 7 | -------------------------------------------------------------------------------- /6Aug2017/DemoTuple/tuple3.py: -------------------------------------------------------------------------------- 1 | dimensions = (200, 50) 2 | print(dimensions) 3 | dimensions[1] = 45 4 | print(dimensions) 5 | 6 | 7 | -------------------------------------------------------------------------------- /6Aug2017/DemoTuple/tuple4.py: -------------------------------------------------------------------------------- 1 | dimensions = tuple(range(1,11)) 2 | print(dimensions) 3 | for d in dimensions: 4 | print(d) 5 | 6 | 7 | -------------------------------------------------------------------------------- /6Aug2017/DemoTuple/tuple5.py: -------------------------------------------------------------------------------- 1 | dimensions = (200,500) 2 | print(dimensions) 3 | dimensions = (300,500) 4 | print(dimensions) 5 | 6 | -------------------------------------------------------------------------------- /6Aug2017/DemoTuple/tuple6.py: -------------------------------------------------------------------------------- 1 | dimensions = tuple(val**2 for val in range(1,11)) 2 | print(dimensions) 3 | 4 | -------------------------------------------------------------------------------- /8Oct2017/datascience_chap2/.idea/datascience_chap2.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /8Oct2017/datascience_chap2/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /8Oct2017/datascience_chap2/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /8Oct2017/datascience_chap2/demo1.py: -------------------------------------------------------------------------------- 1 | document = "That the quick brown fox jumps over the lazy dog" 2 | 3 | word_counts = {} 4 | for word in document.split(): 5 | if word in word_counts: 6 | word_counts[word] += 1 7 | else: 8 | word_counts[word] = 1 9 | 10 | print(word_counts) -------------------------------------------------------------------------------- /8Oct2017/datascience_chap2/demo10.py: -------------------------------------------------------------------------------- 1 | document = "That the quick brown fox jumps quick over fox the lazy dog fox Jumps" 2 | 3 | word_counts = {} 4 | for word in document.split(): 5 | if word in word_counts: 6 | word_counts[word] += 1 7 | else: 8 | word_counts[word] = 1 9 | 10 | print(word_counts) 11 | print(word_counts.items()) 12 | 13 | wc = sorted(word_counts.items()) 14 | print(wc) -------------------------------------------------------------------------------- /8Oct2017/datascience_chap2/demo11.py: -------------------------------------------------------------------------------- 1 | document = "That the quick brown fox jumps quick over fox the lazy dog fox Jumps" 2 | 3 | word_counts = {} 4 | for word in document.split(): 5 | if word in word_counts: 6 | word_counts[word] += 1 7 | else: 8 | word_counts[word] = 1 9 | 10 | print(word_counts) 11 | print(word_counts.items()) 12 | 13 | wc = sorted(word_counts.items(),key=lambda i: i[1],reverse=True) 14 | print(wc) -------------------------------------------------------------------------------- /8Oct2017/datascience_chap2/demo12.py: -------------------------------------------------------------------------------- 1 | even_numbers = [x for x in range(5) if x%2 == 0] 2 | print(even_numbers) 3 | 4 | zeroes = [0 for _ in even_numbers] 5 | print(zeroes) 6 | 7 | ab = [4,6,8,25,14] 8 | def abc (a): 9 | print(a) 10 | 11 | even_numbers1 = [x for x in range(15) if abc(x)] 12 | print(even_numbers1) 13 | 14 | -------------------------------------------------------------------------------- /8Oct2017/datascience_chap2/demo13.py: -------------------------------------------------------------------------------- 1 | x = range(10) 2 | y = list(x) 3 | print(x) 4 | print(y) 5 | for z in x: 6 | print(z) 7 | -------------------------------------------------------------------------------- /8Oct2017/datascience_chap2/demo14.py: -------------------------------------------------------------------------------- 1 | def myFunction(count): 2 | print("count",count) 3 | for x in range(count): 4 | yield x 5 | 6 | myval = myFunction(10) 7 | print(myval) 8 | print(next(myval)) 9 | print(next(myval)) 10 | print(next(myval)) 11 | 12 | #for z in myval: 13 | # print(z) -------------------------------------------------------------------------------- /8Oct2017/datascience_chap2/demo15.py: -------------------------------------------------------------------------------- 1 | def myFunction(count): 2 | print("count",count) 3 | for x in range(count): 4 | yield x 5 | 6 | myval = myFunction(10) 7 | print(myval) 8 | 9 | 10 | for z in myval: 11 | print(z) -------------------------------------------------------------------------------- /8Oct2017/datascience_chap2/demo16.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | a = random.choice(range(10)) 4 | print(a) 5 | 6 | 7 | four_with_replacement = [ 8 | x 9 | for x in range(4)] 10 | 11 | print(four_with_replacement) 12 | 13 | 14 | four_with_replacement1 = [ 15 | random.choice(range(10)) 16 | for _ in range(4)] 17 | 18 | print(four_with_replacement1) -------------------------------------------------------------------------------- /8Oct2017/datascience_chap2/demo17.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | myVal = "Hello World!" 4 | a = re.search("[a-z]", myVal) 5 | print(a.group()) 6 | -------------------------------------------------------------------------------- /8Oct2017/datascience_chap2/demo2.py: -------------------------------------------------------------------------------- 1 | from collections import defaultdict 2 | document = "That the quick brown fox jumps over the lazy dog" 3 | 4 | word_counts = defaultdict(int) 5 | for word in document.split(): 6 | word_counts[word] += 1 7 | 8 | print(word_counts) -------------------------------------------------------------------------------- /8Oct2017/datascience_chap2/demo3.py: -------------------------------------------------------------------------------- 1 | from collections import Counter 2 | document = "That the quick brown fox jumps quick over fox the lazy dog fox" 3 | 4 | c = Counter(document.split()) 5 | print(c) 6 | 7 | if "a": 8 | print("Hello") 9 | else: 10 | print("else") -------------------------------------------------------------------------------- /8Oct2017/datascience_chap2/demo4.py: -------------------------------------------------------------------------------- 1 | myList = [True, 1, { 3 },"a"] 2 | 3 | result = all(myList) 4 | 5 | print(result) -------------------------------------------------------------------------------- /8Oct2017/datascience_chap2/demo5.py: -------------------------------------------------------------------------------- 1 | myList = [True, 0, { 3 },""] 2 | 3 | result = any(myList) 4 | 5 | print(result) -------------------------------------------------------------------------------- /8Oct2017/datascience_chap2/demo6.py: -------------------------------------------------------------------------------- 1 | x = [4,1,2,3] 2 | #y = sorted(x) # is [1,2,3,4], x is unchanged 3 | x.sort() 4 | print(x) 5 | #print(y) -------------------------------------------------------------------------------- /8Oct2017/datascience_chap2/demo7.py: -------------------------------------------------------------------------------- 1 | x = [-4,1,-2,3] 2 | y = sorted(x,key=abs) 3 | 4 | print(x) 5 | print(y) -------------------------------------------------------------------------------- /8Oct2017/datascience_chap2/demo8.py: -------------------------------------------------------------------------------- 1 | 2 | a = lambda b:b*2 +4*b 3 | 4 | print(a) 5 | print(a(2)) 6 | -------------------------------------------------------------------------------- /8Oct2017/datascience_chap2/demo9.py: -------------------------------------------------------------------------------- 1 | x = [-4,1,-2,3] 2 | 3 | #a = lambda (a) 4 | 5 | y = sorted(x,key=lambda c:c*2) 6 | print(x) 7 | print(y) 8 | 9 | 10 | d = lambda c:c*2 11 | print(d(-4)) 12 | print(d(1)) 13 | print(d(-2)) 14 | print(d(3)) 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # python-code 2 | Python Code for AI class 3 | --------------------------------------------------------------------------------