├── 84 First App in Django part 1.txt ├── 31 Why Numpy Installing Numpy in Pycharm.txt ├── 19 Working with PyCharm Run Debug Trace py file.txt ├── 28 Prime Number in Python.txt ├── 27 For Else in Python.txt ├── 75 Python Database Connection.txt ├── 44 Factorial using Recursion.txt ├── 42 Factorial.txt ├── 43 Recursion.txt ├── 45 Anonymous Function Lambda.txt ├── 13 Number System Conversion in Python ├── 17 Python BitWise Operators ├── 46 Filter Map Reduce.txt ├── 39 Global Keyword in Python Global vs Local Variable.txt ├── 32 Ways of Creating Arrays in Numpy.txt ├── 41 Fibonacci Sequence.txt ├── 55 Types of Variables.txt ├── 38 Keyworded Variable Length Arguments.txt ├── 53__init__method.txt ├── 73 Bubble Sort in python List Sort.txt ├── 20 User input in Python Command Line Input.txt ├── 25 Break vs Continue vs Pass in Python.txt ├── 40 Pass List to a Function in Python.txt ├── 71 Linear search using Python.txt ├── 37 Type of argu.txt ├── 8 Python Set Path in Windows and Help ├── 74 Selection Sort using Python.txt ├── Generators.txt ├── 66 Exception Handling.txt ├── 47 Decorators.txt ├── 23 For Loop in Python.txt ├── 36 Function Arguments in Python.txt ├── 61 Duck Typing.txt ├── 30 Array values from User in Python Search in Array.txt ├── 22 While Loop in Python.txt ├── 48 Modules.txt ├── 35 Functions in Python.txt ├── 67 MultiThreading.txt ├── 58 Inheritance.txt ├── 49 Special Vairable__name___.txt ├── 52 Class and Object.txt ├── 54 Constructor Self and Comparing Object.txt ├── 72 Binary search using Python.txt ├── 24 Break Continue Pass in Python.txt ├── 7 Tuple Set in Python ├── 10 More on Variables in Python ├── 21 If Elif Else Statement in Python.txt ├── 50 Special Vairable__name___part 2.txt ├── 29 Array in Python.txt ├── 57 Inner class.txt ├── 59 Constructor in Inheritance.txt ├── 56 Type of Methods.txt ├── 34 Working with Matrix in Python.txt ├── Iterator.txt ├── Method Overloading and Method Overriding.txt ├── 26 Printing Patterns in Python.txt ├── 68 File Handling.txt ├── 14 Swap 2 Variables in Python.txt ├── 62 Operator Overloading_Polymorphism.txt ├── 12 Operators in Python ├── 85 First App Django - part 2.txt ├── 4 Getting Started with Python ├── 33 Copying an Array in Python.txt ├── 18 Import Math Functions in Python ├── 11 Data Types in Python ├── 6 List in Python ├── 86 Django Template Language DTL.txt ├── 5 Variables in Python ├── 87 Django Template Language part 2.txt ├── 88 Addition of Two Numbers in Django.txt ├── 89 GET vs POST HTTP Methods.txt ├── 94 Passing Dynamic Data in Html part 2.txt ├── 95 If statement.txt ├── 91 Static File - 1.txt ├── 99 Re-Migration.txt └── 98 Models and Migration.txt /84 First App in Django part 1.txt: -------------------------------------------------------------------------------- 1 | Commands 2 | -------------------------------------------------------------------------------- 3 | 4 | >workon test 5 | >python manage.py startapp calc -------------------------------------------------------------------------------- /31 Why Numpy Installing Numpy in Pycharm.txt: -------------------------------------------------------------------------------- 1 | MyCode.py 2 | -------------------------------------------------------------------------------- 3 | 4 | 5 | from numpy import * 6 | 7 | arr = array([1,2,3,2,5,4],int) 8 | 9 | print(arr) -------------------------------------------------------------------------------- /19 Working with PyCharm Run Debug Trace py file.txt: -------------------------------------------------------------------------------- 1 | MyCode.py 2 | -------------------------------------------------------------------------------- 3 | 4 | x = 5 5 | y = 8 6 | z = x + y 7 | print(z) 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /28 Prime Number in Python.txt: -------------------------------------------------------------------------------- 1 | MyCode.py 2 | -------------------------------------------------------------------------------- 3 | 4 | 5 | num = 10 6 | 7 | for i in range(2,num): 8 | if num % i == 0: 9 | print("Not Prime") 10 | break 11 | else: 12 | print("Prime") -------------------------------------------------------------------------------- /27 For Else in Python.txt: -------------------------------------------------------------------------------- 1 | MyCode.py 2 | -------------------------------------------------------------------------------- 3 | 4 | 5 | nums = [10,16,18,21,26] 6 | 7 | for num in nums: 8 | 9 | if num % 5 == 0: 10 | print(num) 11 | break 12 | else: 13 | print("not found") -------------------------------------------------------------------------------- /75 Python Database Connection.txt: -------------------------------------------------------------------------------- 1 | 1.Install Mysql 2 | 3 | 2.Write query :- 4 | 5 | 6 | show databases; 7 | 8 | create database telusko; 9 | 10 | use telusko; 11 | create table student(name varchar(20), college varchar(20)); 12 | 13 | insert into student values ('navin','vsit'), ('Priya','bvit'); 14 | select * from student; -------------------------------------------------------------------------------- /44 Factorial using Recursion.txt: -------------------------------------------------------------------------------- 1 | demo.py 2 | -------------------------------------------------------------------------------- 3 | 4 | 5 | def fact(n): 6 | 7 | if(n==0): 8 | return 1 9 | 10 | return n * fact(n-1) 11 | 12 | 13 | 14 | result = fact(5) 15 | 16 | print(result) 17 | -------------------------------------------------------------------------------- /42 Factorial.txt: -------------------------------------------------------------------------------- 1 | demo.py 2 | -------------------------------------------------------------------------------- 3 | 4 | def fact(n): 5 | 6 | f = 1 7 | 8 | for i in range(1,n+1): 9 | f = f * i 10 | return f 11 | 12 | 13 | x = 4 14 | 15 | result = fact(x) 16 | 17 | 18 | print(result) -------------------------------------------------------------------------------- /43 Recursion.txt: -------------------------------------------------------------------------------- 1 | demo.py 2 | -------------------------------------------------------------------------------- 3 | 4 | import sys 5 | 6 | sys.setrecursionlimit(2000) 7 | print(sys.getrecursionlimit()) 8 | 9 | i = 0 10 | 11 | def greet(): 12 | global i 13 | i+=1 14 | print("Hello ",i) 15 | greet() 16 | 17 | greet() -------------------------------------------------------------------------------- /45 Anonymous Function Lambda.txt: -------------------------------------------------------------------------------- 1 | demo.py 2 | -------------------------------------------------------------------------------- 3 | 4 | # def square(a): 5 | # return a * a 6 | # 7 | # result = square(5) 8 | # 9 | # print(result) 10 | 11 | 12 | 13 | f = lambda a,b : a+b 14 | 15 | result = f(5,6) 16 | 17 | print(result) 18 | -------------------------------------------------------------------------------- /13 Number System Conversion in Python: -------------------------------------------------------------------------------- 1 | Code 2 | 3 | Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32 4 | Type "help", "copyright", "credits" or "license()" for more information. 5 | >>> bin(25) 6 | '0b11001' 7 | >>> 0b0101 8 | 5 9 | >>> oct(25) 10 | '0o31' 11 | >>> hex(25) 12 | '0x19' 13 | >>> hex(10) 14 | '0xa' 15 | >>> 0xf 16 | 15 17 | >>> 18 | -------------------------------------------------------------------------------- /17 Python BitWise Operators: -------------------------------------------------------------------------------- 1 | Code 2 | 3 | Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32 4 | Type "help", "copyright", "credits" or "license()" for more information. 5 | >>> ~12 6 | -13 7 | >>> 12 & 13 8 | 12 9 | >>> 12 | 13 10 | 13 11 | >>> 25 & 30 12 | 24 13 | >>> 12 ^ 1 14 | 13 15 | >>> 12 ^ 13 16 | 1 17 | >>> 25 ^ 30 18 | 7 19 | >>> 20 | -------------------------------------------------------------------------------- /46 Filter Map Reduce.txt: -------------------------------------------------------------------------------- 1 | demo.py 2 | -------------------------------------------------------------------------------- 3 | 4 | from functools import reduce 5 | 6 | nums = [3,2,6,8,4,6,2,9] 7 | 8 | evens = list(filter(lambda n : n%2==0,nums)) 9 | 10 | doubles = list(map(lambda n : n*2,evens)) 11 | print(doubles) 12 | 13 | sum = reduce(lambda a,b : a+b,doubles) 14 | 15 | print(sum) 16 | -------------------------------------------------------------------------------- /39 Global Keyword in Python Global vs Local Variable.txt: -------------------------------------------------------------------------------- 1 | MyCode.py 2 | -------------------------------------------------------------------------------- 3 | 4 | 5 | a = 10 6 | print(id(a)) 7 | 8 | def something(): 9 | a = 9 10 | 11 | x = globals()['a'] 12 | print(id(x)) 13 | print("in fun ",a) 14 | 15 | globals()['a'] = 15 16 | 17 | 18 | 19 | something() 20 | 21 | print("outside ",a) -------------------------------------------------------------------------------- /32 Ways of Creating Arrays in Numpy.txt: -------------------------------------------------------------------------------- 1 | MyCode.py 2 | -------------------------------------------------------------------------------- 3 | 4 | from numpy import * 5 | 6 | # arr = array([1,2,3,4,5],float) 7 | # 8 | # print(arr.dtype) 9 | # print(arr) 10 | 11 | # arr = linspace(0,15) 12 | # arr = arange(1,15,2) 13 | 14 | # arr = logspace(1,40,5) 15 | # print('%.2f' %arr[4]) 16 | 17 | arr = ones(5,int) 18 | print(arr) -------------------------------------------------------------------------------- /41 Fibonacci Sequence.txt: -------------------------------------------------------------------------------- 1 | fib.py 2 | -------------------------------------------------------------------------------- 3 | 4 | def fib(n): 5 | 6 | a = 0 7 | b = 1 8 | 9 | if n == 1: 10 | print(a) 11 | 12 | else: 13 | print(a) 14 | print(b) 15 | 16 | for i in range(2,n): 17 | c = a + b 18 | a = b 19 | b = c 20 | print(a+b) 21 | 22 | fib(100) 23 | -------------------------------------------------------------------------------- /55 Types of Variables.txt: -------------------------------------------------------------------------------- 1 | demo.py 2 | -------------------------------------------------------------------------------- 3 | 4 | 5 | class Car: 6 | 7 | wheels = 4 8 | 9 | def __init__(self): 10 | self.mil = 10 11 | self.com = "BMW" 12 | 13 | 14 | c1 = Car() 15 | c2 = Car() 16 | 17 | c1.mil = 8 18 | 19 | Car.wheels = 5 20 | 21 | print(c1.com , c1.mil , c1.wheels) 22 | print(c2.com , c2.mil , c2.wheels) -------------------------------------------------------------------------------- /38 Keyworded Variable Length Arguments.txt: -------------------------------------------------------------------------------- 1 | MyCode.py 2 | -------------------------------------------------------------------------------- 3 | 4 | # def person(name, **data): 5 | # print(name) 6 | # print(data) 7 | # person('navin',age=28,city='Mumbai',mob=9865432) 8 | 9 | 10 | def person(name, **data): 11 | print(name) 12 | for i,j in data.items(): 13 | print(i,j) 14 | person('navin',age=28,city='Mumbai',mob=9865432) -------------------------------------------------------------------------------- /53__init__method.txt: -------------------------------------------------------------------------------- 1 | demo.py 2 | -------------------------------------------------------------------------------- 3 | 4 | 5 | 6 | class Computer: 7 | 8 | def __init__(self,cpu,ram): 9 | self.cpu = cpu 10 | self.ram = ram 11 | 12 | def config(self): 13 | print("Config is ",self.cpu, self.ram) 14 | 15 | com1 = Computer('i5',16) 16 | com2 = Computer('Ryzen 3',8) 17 | 18 | 19 | com1.config() 20 | com2.config() -------------------------------------------------------------------------------- /73 Bubble Sort in python List Sort.txt: -------------------------------------------------------------------------------- 1 | demo.py 2 | -------------------------------------------------------------------------------- 3 | 4 | 5 | def sort(nums): 6 | 7 | for i in range(len(nums)-1,0,-1): 8 | for j in range(i): 9 | if nums[j]>nums[j+1]: 10 | temp = nums[j] 11 | nums[j] = nums[j+1] 12 | nums[j+1] = temp 13 | 14 | 15 | nums = [5, 3, 8, 6, 7, 2] 16 | sort(nums) 17 | 18 | print(nums) -------------------------------------------------------------------------------- /20 User input in Python Command Line Input.txt: -------------------------------------------------------------------------------- 1 | MyCode.py 2 | -------------------------------------------------------------------------------- 3 | 4 | # x = int(input("Enter 1st number")) 5 | # y = int(input("Enter 2nd number")) 6 | # z = x + y 7 | # print(z) 8 | 9 | # ch = input('enter a char') 10 | # print(ch[0]) 11 | 12 | # ch = input('enter a char')[0] 13 | # print(ch) 14 | 15 | result = eval(input('enter a expr')) 16 | print(result) 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /25 Break vs Continue vs Pass in Python.txt: -------------------------------------------------------------------------------- 1 | MyCode.py 2 | -------------------------------------------------------------------------------- 3 | 4 | 5 | # for i in range(5): 6 | # 7 | # if i==3: 8 | # continue 9 | # print("Hello ",i) 10 | 11 | for i in range(5): 12 | 13 | if i==3: 14 | break 15 | print("Hello ",i) 16 | 17 | if i==4: 18 | pass 19 | 20 | 21 | def fun(): 22 | pass 23 | 24 | a = 5 25 | 26 | class Human: 27 | pass -------------------------------------------------------------------------------- /40 Pass List to a Function in Python.txt: -------------------------------------------------------------------------------- 1 | MyCode.py 2 | -------------------------------------------------------------------------------- 3 | 4 | 5 | def count(lst): 6 | 7 | even = 0 8 | odd = 0 9 | 10 | for i in lst: 11 | if i%2==0: 12 | even+=1 13 | else: 14 | odd+=1 15 | 16 | return even,odd 17 | 18 | lst = [20,25,14,19,16,24,28,47,26] 19 | 20 | even , odd = count(lst) 21 | 22 | print("Even : {} and Odd : {}".format(even,odd)) 23 | -------------------------------------------------------------------------------- /71 Linear search using Python.txt: -------------------------------------------------------------------------------- 1 | demo.py 2 | -------------------------------------------------------------------------------- 3 | 4 | pos = -1 5 | 6 | def search(list, n): 7 | i = 0 8 | 9 | while i< len(list): 10 | if list[i] == n: 11 | globals()['pos'] = i 12 | return True 13 | i = i + 1; 14 | 15 | return False 16 | 17 | list = [5,8,4,6,9,2] 18 | n = 9 19 | 20 | if search(list, n): 21 | print("Found at ",pos+1) 22 | else: 23 | print("Not Found") -------------------------------------------------------------------------------- /37 Type of argu.txt: -------------------------------------------------------------------------------- 1 | MyCode.py 2 | -------------------------------------------------------------------------------- 3 | 4 | 5 | # 6 | # def person(name , age): 7 | # print(name) 8 | # print(age) 9 | # 10 | # person(age=28,name='navin') 11 | 12 | 13 | 14 | # def person(name , age=18): 15 | # print(name) 16 | # print(age) 17 | # 18 | # person('navin',28) 19 | 20 | def sum(*b): 21 | 22 | c = 0 23 | for i in b: 24 | c = c + i 25 | 26 | print(c) 27 | 28 | sum(5,6,34,78) 29 | -------------------------------------------------------------------------------- /8 Python Set Path in Windows and Help: -------------------------------------------------------------------------------- 1 | Code 2 | 3 | CMD :- 4 | Microsoft Windows [Version 10.0.17763.503] 5 | (c) 2018 Microsoft Corporation. All rights reserved. 6 | 7 | C:\Users\telusko>python 8 | Python 3.7.0 (v3.7.0:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32 9 | Type "help", "copyright", "credits" or "license" for more information. 10 | >>> 2 + 3 11 | 5 12 | >>> print("Hello World") 13 | Hello World 14 | >>> 15 | 16 | Python Shell :- 17 | >>> help() 18 | help> topics 19 | help> LISTS 20 | help> quit 21 | >>> help('LISTS') 22 | -------------------------------------------------------------------------------- /74 Selection Sort using Python.txt: -------------------------------------------------------------------------------- 1 | demo.py 2 | -------------------------------------------------------------------------------- 3 | 4 | 5 | 6 | def sort(nums): 7 | 8 | for i in range(5): 9 | minpos = i 10 | for j in range(i,6): 11 | if nums[j] < nums[minpos]: 12 | minpos = j 13 | 14 | 15 | temp = nums[i] 16 | nums[i] = nums[minpos] 17 | nums[minpos] = temp 18 | 19 | print(nums) 20 | 21 | 22 | nums = [5, 3, 8, 6, 7, 2] 23 | sort(nums) 24 | 25 | print(nums) -------------------------------------------------------------------------------- /Generators.txt: -------------------------------------------------------------------------------- 1 | dec.py 2 | -------------------------------------------------------------------------------- 3 | 4 | # def topten(): 5 | # 6 | # yield 1 7 | # yield 2 8 | # yield 3 9 | # yield 4 10 | # 11 | # 12 | # 13 | # values = topten() 14 | # 15 | # print(values.__next__()) 16 | # print(values.__next__()) 17 | 18 | 19 | def topten(): 20 | 21 | n = 1 22 | 23 | while n <= 10: 24 | sq = n*n 25 | yield sq 26 | n += 1 27 | 28 | 29 | values = topten() 30 | 31 | for i in values: 32 | print(i) -------------------------------------------------------------------------------- /66 Exception Handling.txt: -------------------------------------------------------------------------------- 1 | demo.py 2 | -------------------------------------------------------------------------------- 3 | 4 | a = 5 5 | b = 2 6 | 7 | try: 8 | print("resource Open") 9 | print(a/b) 10 | k = int(input("Enter a number")) 11 | print(k) 12 | 13 | except ZeroDivisionError as e: 14 | print("Hey, You cannot divide a Number by Zero" , e) 15 | 16 | except ValueError as e: 17 | print("Invalid Input") 18 | 19 | except Exception as e: 20 | print("Something went Wrong...") 21 | 22 | finally: 23 | print("resource Closed") -------------------------------------------------------------------------------- /47 Decorators.txt: -------------------------------------------------------------------------------- 1 | demo.py 2 | -------------------------------------------------------------------------------- 3 | 4 | # def div(a,b): 5 | # print(a/b) 6 | # 7 | # div(2,4) 8 | 9 | 10 | # def div(a,b): 11 | # if a=1: 14 | # print("Telusko") 15 | # i=i-1 16 | 17 | # i = 5 18 | # 19 | # while i>=1: 20 | # print("Telusko" , i) 21 | # i=i-1 22 | 23 | i = 1 24 | 25 | while i<=5: 26 | print("Telusko ",end="") 27 | j=1 28 | while j<=4: 29 | print("Rocks ",end="") 30 | j=j+1 31 | 32 | i=i+1 33 | print() 34 | -------------------------------------------------------------------------------- /48 Modules.txt: -------------------------------------------------------------------------------- 1 | demo.py 2 | -------------------------------------------------------------------------------- 3 | 4 | from Calc import * 5 | 6 | a = 9 7 | b = 7 8 | 9 | c = sub(a,b) 10 | 11 | print(c) 12 | 13 | 14 | -------------------------------------------------------------------------------- 15 | Calc.py 16 | -------------------------------------------------------------------------------- 17 | 18 | def add(a,b): 19 | return a+b 20 | 21 | def sub(a,b): 22 | return a-b 23 | 24 | def mul(a,b): 25 | return a*b 26 | 27 | def div(a,b): 28 | return a/b -------------------------------------------------------------------------------- /35 Functions in Python.txt: -------------------------------------------------------------------------------- 1 | MyCode.py 2 | -------------------------------------------------------------------------------- 3 | 4 | 5 | # def greet(): 6 | # print("Hello") 7 | # print("Good Morning") 8 | # 9 | # greet() 10 | 11 | 12 | # def greet(): 13 | # print("Hello") 14 | # print("Good Morning") 15 | # 16 | # def add(x,y): 17 | # c = x+y 18 | # return c 19 | # 20 | # greet() 21 | # result = add(5,4) 22 | # print(result) 23 | 24 | 25 | 26 | def add_sub(x,y): 27 | c = x+y 28 | d = x-y 29 | return c,d 30 | 31 | result1,result2 = add_sub(5,4) 32 | print(result1, result2) -------------------------------------------------------------------------------- /67 MultiThreading.txt: -------------------------------------------------------------------------------- 1 | demo.py 2 | -------------------------------------------------------------------------------- 3 | 4 | from time import sleep 5 | from threading import * 6 | 7 | class Hello(Thread): 8 | def run(self): 9 | for i in range(5): 10 | print("Hello") 11 | sleep(1) 12 | 13 | 14 | class Hi(Thread): 15 | def run(self): 16 | for i in range(5): 17 | print("Hi") 18 | sleep(1) 19 | 20 | 21 | t1 = Hello() 22 | t2 = Hi() 23 | 24 | t1.start() 25 | sleep(0.2) 26 | t2.start() 27 | 28 | t1.join() 29 | t2.join() 30 | 31 | print("Bye") -------------------------------------------------------------------------------- /58 Inheritance.txt: -------------------------------------------------------------------------------- 1 | demo.py 2 | -------------------------------------------------------------------------------- 3 | 4 | class A: 5 | def feature1(self): 6 | print("Feature 1 working") 7 | 8 | def feature2(self): 9 | print("Feature 2 working") 10 | 11 | class B: 12 | def feature3(self): 13 | print("Feature 3 working") 14 | 15 | def feature4(self): 16 | print("Feature 4 working") 17 | 18 | class C(A,B): 19 | def feature5(self): 20 | print("Feature 5 working") 21 | 22 | 23 | a1 = A() 24 | 25 | a1.feature1() 26 | a1.feature2() 27 | 28 | b1 = B() 29 | 30 | c1 = C() -------------------------------------------------------------------------------- /49 Special Vairable__name___.txt: -------------------------------------------------------------------------------- 1 | demo.py 2 | -------------------------------------------------------------------------------- 3 | 4 | # import Calc 5 | # print("Demo Says : " + __name__) 6 | 7 | def main(): 8 | 9 | print("Hello") 10 | print("Welcome User") 11 | 12 | if __name__ == "__main__": 13 | main() 14 | 15 | 16 | -------------------------------------------------------------------------------- 17 | Calc.py 18 | -------------------------------------------------------------------------------- 19 | 20 | # print("Hello " + __name__) 21 | 22 | import demo 23 | 24 | print("Its Time to Calculate") -------------------------------------------------------------------------------- /52 Class and Object.txt: -------------------------------------------------------------------------------- 1 | demo.py 2 | -------------------------------------------------------------------------------- 3 | 4 | 5 | # class Computer: 6 | # 7 | # def config(self): 8 | # print("i5, 16gb, 1TB") 9 | # 10 | # x = 9 11 | # print(type(x)) 12 | # 13 | # 14 | # a = '8' 15 | # print(type(a)) 16 | # com1 = Computer() 17 | # 18 | # print(type(com1)) 19 | 20 | 21 | class Computer: 22 | 23 | def config(self): 24 | print("i5, 16gb, 1TB") 25 | 26 | com1 = Computer() 27 | com2 = Computer() 28 | 29 | 30 | Computer.config(com1) 31 | Computer.config(com2) 32 | 33 | com1.config() 34 | com2.config() 35 | 36 | 37 | -------------------------------------------------------------------------------- /54 Constructor Self and Comparing Object.txt: -------------------------------------------------------------------------------- 1 | demo.py 2 | -------------------------------------------------------------------------------- 3 | 4 | 5 | class Computer: 6 | 7 | def __init__(self): 8 | self.name = "Navin" 9 | self.age = 28 10 | 11 | 12 | def compare(self,other): 13 | if self.age == other.age: 14 | return True 15 | else: 16 | return False 17 | 18 | 19 | c1 = Computer() 20 | c1.age = 30 21 | c2 = Computer() 22 | 23 | # c1.name = "Rashi" 24 | # c1.age = 12 25 | 26 | if c1.compare(c2): 27 | print("They are same") 28 | else: 29 | print("They are different") 30 | 31 | # c1.update() 32 | 33 | print(c1.name) 34 | print(c2.name) -------------------------------------------------------------------------------- /72 Binary search using Python.txt: -------------------------------------------------------------------------------- 1 | demo.py 2 | -------------------------------------------------------------------------------- 3 | 4 | pos = -1 5 | 6 | def search(list, n): 7 | 8 | l = 0 9 | u = len(list)-1 10 | 11 | while l <= u: 12 | mid = (l+u) // 2 13 | 14 | if list[mid] == n: 15 | globals()['pos'] = mid 16 | return True 17 | else: 18 | if list[mid] < n: 19 | l = mid+1; 20 | else: 21 | u = mid-1; 22 | 23 | return False 24 | 25 | 26 | list = [4,7,8,12,45,99,102,702,10987,56666] 27 | n = 10 28 | 29 | if search(list, n): 30 | print("Found at ",pos+1) 31 | else: 32 | print("Not Found") -------------------------------------------------------------------------------- /24 Break Continue Pass in Python.txt: -------------------------------------------------------------------------------- 1 | MyCode.py 2 | -------------------------------------------------------------------------------- 3 | 4 | 5 | # av = 5 6 | # 7 | # x = int(input("How many Candies you want?")) 8 | # 9 | # i = 1 10 | # while i <= x: 11 | # 12 | # if i>av: 13 | # print("Out of stock") 14 | # break 15 | # 16 | # 17 | # print("Candy") 18 | # i+=1 19 | # 20 | # print("Bye") 21 | 22 | 23 | # for i in range(1,101): 24 | # 25 | # if i%3==0 and i%5==0: 26 | # continue 27 | # 28 | # print(i) 29 | # 30 | # print("Bye") 31 | 32 | 33 | for i in range(1,101): 34 | 35 | if(i%2!=0): 36 | pass 37 | 38 | else: 39 | print(i) 40 | 41 | print("Bye") -------------------------------------------------------------------------------- /7 Tuple Set in Python: -------------------------------------------------------------------------------- 1 | Code 2 | 3 | Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32 4 | Type "help", "copyright", "credits" or "license()" for more information. 5 | >>> tup = (21,36,14,25) 6 | >>> tup 7 | (21, 36, 14, 25) 8 | >>> tup[1] 9 | 36 10 | >>> tup[1] = 33 11 | Traceback (most recent call last): 12 | File "", line 1, in 13 | tup[1] = 33 14 | TypeError: 'tuple' object does not support item assignment 15 | >>> s = {22,25,14,21,5} 16 | >>> s 17 | {5, 14, 21, 22, 25} 18 | >>> s = {25,14,98,63,75,98} 19 | >>> s 20 | {98, 75, 14, 25, 63} 21 | >>> s[2] 22 | Traceback (most recent call last): 23 | File "", line 1, in 24 | s[2] 25 | TypeError: 'set' object is not subscriptable 26 | >>> 27 | -------------------------------------------------------------------------------- /10 More on Variables in Python: -------------------------------------------------------------------------------- 1 | Code 2 | 3 | Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32 4 | Type "help", "copyright", "credits" or "license()" for more information. 5 | >>> num = 5 6 | >>> id(num) 7 | 140731200725776 8 | >>> name = 'navin' 9 | >>> id(name) 10 | 2243898937160 11 | >>> a = 10 12 | >>> b = a 13 | >>> a 14 | 10 15 | >>> b 16 | 10 17 | >>> id(a) 18 | 140731200725936 19 | >>> id(b) 20 | 140731200725936 21 | >>> id(10) 22 | 140731200725936 23 | >>> k = 10 24 | >>> id(k) 25 | 140731200725936 26 | >>> a = 9 27 | >>> id(a) 28 | 140731200725904 29 | >>> id(b) 30 | 140731200725936 31 | >>> k = a 32 | >>> id(k) 33 | 140731200725904 34 | >>> b = 8 35 | >>> PI = 3.14 36 | >>> PI 37 | 3.14 38 | >>> PI = 3.15 39 | >>> type(PI) 40 | 41 | >>> 42 | -------------------------------------------------------------------------------- /21 If Elif Else Statement in Python.txt: -------------------------------------------------------------------------------- 1 | MyCode.py 2 | -------------------------------------------------------------------------------- 3 | 4 | #if True: 5 | # print("Im right") 6 | 7 | # if False: 8 | # print("Im right") 9 | # print("Bye") 10 | 11 | 12 | # x = 4 13 | # r = x % 2 14 | # 15 | # if r==0: 16 | # print("Even") 17 | # if x>5: 18 | # print("Great") 19 | # else: 20 | # print("Not so great") 21 | # 22 | # else: 23 | # print("Odd") 24 | # 25 | # print("Bye") 26 | 27 | 28 | x = 5 29 | 30 | if x==1: 31 | print("one") 32 | 33 | elif(x==2): 34 | print("Two") 35 | 36 | elif(x==3): 37 | print("Three") 38 | 39 | elif(x==4): 40 | print("Four") 41 | 42 | else: 43 | print("Wrong Input") 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /50 Special Vairable__name___part 2.txt: -------------------------------------------------------------------------------- 1 | demo.py 2 | -------------------------------------------------------------------------------- 3 | 4 | from Calc import add 5 | 6 | def fun1(): 7 | add() 8 | print("from fun1") 9 | 10 | def fun2(): 11 | print("from fun2") 12 | 13 | def main(): 14 | fun1() 15 | fun2() 16 | 17 | 18 | main() 19 | 20 | 21 | -------------------------------------------------------------------------------- 22 | Calc.py 23 | -------------------------------------------------------------------------------- 24 | 25 | def add(): 26 | print("result 1 is ", __name__) 27 | 28 | 29 | def sub(): 30 | print("result 2 is ") 31 | 32 | 33 | def main(): 34 | print("in Calc main") 35 | add() 36 | sub() 37 | 38 | if __name__ == "__main__": 39 | main() -------------------------------------------------------------------------------- /29 Array in Python.txt: -------------------------------------------------------------------------------- 1 | MyCode.py 2 | -------------------------------------------------------------------------------- 3 | 4 | 5 | from array import * 6 | 7 | # vals = array('i',[5,9,-8,4,2]) 8 | # 9 | # print(vals.buffer_info()) 10 | # print(vals.typecode) 11 | # vals.reverse() 12 | # 13 | # for i in range(5): 14 | # for i in range(len(vals)): 15 | # for e in vals: 16 | # print(e) 17 | 18 | 19 | 20 | # vals = array('u',['a','e','i']) 21 | # 22 | # 23 | # for e in vals: 24 | # print(e) 25 | 26 | 27 | # vals = array('i',[5,9,8,4,2]) 28 | # newArr = array(vals.typecode, (a*a for a in vals)) 29 | # 30 | # for e in newArr: 31 | # print(e) 32 | 33 | 34 | vals = array('i',[5,9,8,4,2]) 35 | newArr = array(vals.typecode, (a*a for a in vals)) 36 | 37 | i = 0 38 | 39 | while i r2: 30 | return True 31 | else: 32 | return False 33 | 34 | def __str__(self): 35 | return '{} {}'.format( self.m1,self.m2) 36 | 37 | 38 | s1 = Student(58,69) 39 | s2 = Student(69,65) 40 | 41 | s3 = s1 + s2 42 | 43 | if s1 > s2: 44 | print("s1 wins") 45 | else: 46 | print("s2 wins") 47 | 48 | a = 9 49 | print(a.__str__()) 50 | 51 | print(s2) -------------------------------------------------------------------------------- /12 Operators in Python: -------------------------------------------------------------------------------- 1 | Code 2 | 3 | Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32 4 | Type "help", "copyright", "credits" or "license()" for more information. 5 | >>> x = 2 6 | >>> y = 3 7 | >>> x + y 8 | 5 9 | >>> x - y 10 | -1 11 | >>> x * y 12 | 6 13 | >>> x * y 14 | 6 15 | >>> x/y 16 | 0.6666666666666666 17 | >>> x = x + 2 18 | >>> x 19 | 4 20 | >>> x +=2 21 | >>> x 22 | 6 23 | >>> x *= 3 24 | >>> x 25 | 18 26 | >>> a,b = 5,6 27 | >>> a 28 | 5 29 | >>> b 30 | 6 31 | >>> n = 7 32 | >>> n 33 | 7 34 | >>> -n 35 | -7 36 | >>> n 37 | 7 38 | >>> n = -n 39 | >>> n 40 | -7 41 | >>> a < b 42 | True 43 | >>> a > b 44 | False 45 | >>> a == b 46 | False 47 | >>> a = 6 48 | >>> a == b 49 | True 50 | >>> a <= b 51 | True 52 | >>> a >= b 53 | True 54 | >>> a != b 55 | False 56 | >>> b = 7 57 | >>> a != b 58 | True 59 | >>> a = 5 60 | >>> b = 4 61 | >>> a < 8 and b < 5 62 | True 63 | >>> a < 8 and b < 2 64 | False 65 | >>> a < 8 or b < 2 66 | True 67 | >>> x = True 68 | >>> x 69 | True 70 | >>> not x 71 | False 72 | >>> x = not x 73 | >>> x 74 | False 75 | >>> 76 | -------------------------------------------------------------------------------- /85 First App Django - part 2.txt: -------------------------------------------------------------------------------- 1 | view.py 2 | -------------------------------------------------------------------------------- 3 | 4 | from django.shortcuts import render 5 | from django.http import HttpResponse 6 | 7 | # Create your views here. 8 | 9 | 10 | def home(request): 11 | return HttpResponse("Hello World") 12 | 13 | 14 | -------------------------------------------------------------------------------- 15 | urls.py ::calc 16 | -------------------------------------------------------------------------------- 17 | 18 | from django.urls import include, path 19 | from . import views 20 | from django.contrib import admin 21 | 22 | urlpatterns = [ 23 | path('', views.home, name='home'), 24 | 25 | ] 26 | -------------------------------------------------------------------------------- 27 | urls.py ::telusko 28 | -------------------------------------------------------------------------------- 29 | 30 | from django.contrib import admin 31 | from django.urls import path, include 32 | 33 | urlpatterns = [ 34 | path('', include('calc.urls')), 35 | path('admin/', admin.site.urls), 36 | ] -------------------------------------------------------------------------------- /4 Getting Started with Python: -------------------------------------------------------------------------------- 1 | Code 2 | 3 | Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32 4 | Type "help", "copyright", "credits" or "license()" for more information. 5 | >>> 2 + 3 6 | 5 7 | >>> 9 - 8 8 | 1 9 | >>> 4 * 6 10 | 24 11 | >>> 8 / 4 12 | 2.0 13 | >>> 5 / 2 14 | 2.5 15 | >>> 5 // 2 16 | 2 17 | >>> 8 + 9 - 10 18 | 7 19 | >>> 8 + 9 - 20 | SyntaxError: invalid syntax 21 | >>> 8 + 2 * 3 22 | 14 23 | >>> (8 + 2) * 3 24 | 30 25 | >>> 2 * 2 * 2 26 | 8 27 | >>> 2 ** 3 28 | 8 29 | >>> 10 // 3 30 | 3 31 | >>> 10 % 3 32 | 1 33 | >>> 'navin' 34 | 'navin' 35 | >>> print('navin') 36 | navin 37 | >>> print('navin's laptop') 38 | 39 | SyntaxError: invalid syntax 40 | >>> print("navin's laptop") 41 | navin's laptop 42 | >>> print('navin "laptop"') 43 | navin "laptop" 44 | >>> print('navin's "laptop"') 45 | 46 | SyntaxError: invalid syntax 47 | >>> print('navin\'s "laptop"') 48 | navin's "laptop" 49 | >>> 'navin' + 'navin' 50 | 'navinnavin' 51 | >>> 10 * 'navin' 52 | 'navinnavinnavinnavinnavinnavinnavinnavinnavinnavin' 53 | >>> print('c:\docs\navin') 54 | c:\docs 55 | avin 56 | >>> print(r'c:\docs\navin') 57 | c:\docs\navin 58 | 59 | -------------------------------------------------------------------------------- /33 Copying an Array in Python.txt: -------------------------------------------------------------------------------- 1 | MyCode.py 2 | -------------------------------------------------------------------------------- 3 | 4 | from numpy import * 5 | 6 | # arr1 = array([1,2,3,4,5]) 7 | # arr2 = array([6,1,9,3,2]) 8 | # 9 | # arr = arr1 + arr2 10 | # 11 | # print(arr) 12 | 13 | 14 | 15 | # arr1 = array([1,2,3,4,5]) 16 | # print(sin(arr1)) 17 | 18 | 19 | # arr1 = array([1,2,3,4,5]) 20 | # print(cos(arr1)) 21 | 22 | 23 | # arr1 = array([1,2,3,4,5]) 24 | # print(log(arr1)) 25 | 26 | 27 | # arr1 = array([1,2,3,4,5]) 28 | # print(sqrt(arr1)) 29 | 30 | 31 | # arr1 = array([1,2,3,4,5]) 32 | # print(sum(arr1)) 33 | 34 | 35 | # arr1 = array([1,2,3,4,5]) 36 | # print(min(arr1)) 37 | 38 | 39 | # arr1 = array([1,2,3,4,5]) 40 | # print(max(arr1)) 41 | 42 | 43 | # arr1 = array([1,2,3,4,5]) 44 | # arr2 = array([6,1,9,3,2]) 45 | # print(concatenate([arr1,arr2])) 46 | 47 | 48 | # arr1 = array([2,6,8,1,3]) 49 | # arr2 = arr1 50 | # 51 | # print(arr1) 52 | # print(arr2) 53 | # 54 | # print(id(arr1)) 55 | # print(id(arr2)) 56 | 57 | 58 | arr1 = array([2,6,8,1,3]) 59 | # arr2 = arr1.view() 60 | arr2 = arr1.copy() 61 | 62 | arr1[1] = 7 63 | 64 | print(arr1) 65 | print(arr2) 66 | 67 | print(id(arr1)) 68 | print(id(arr2)) -------------------------------------------------------------------------------- /18 Import Math Functions in Python: -------------------------------------------------------------------------------- 1 | Code 2 | 3 | Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32 4 | Type "help", "copyright", "credits" or "license()" for more information. 5 | >>> x = sqrt(25) 6 | Traceback (most recent call last): 7 | File "", line 1, in 8 | x = sqrt(25) 9 | NameError: name 'sqrt' is not defined 10 | >>> import math 11 | >>> x = math.sqrt(25) 12 | >>> x 13 | 5.0 14 | >>> x = math.sqrt(15) 15 | >>> x 16 | 3.872983346207417 17 | >>> print(math.floor(2.9)) 18 | 2 19 | >>> print(math.ceil(2.2)) 20 | 3 21 | >>> 3 ** 2 22 | 9 23 | >>> print(math.pow(3,2)) 24 | 9.0 25 | >>> print(math.pi) 26 | 3.141592653589793 27 | >>> print(math.e) 28 | 2.718281828459045 29 | >>> m.sqrt(25) 30 | Traceback (most recent call last): 31 | File "", line 1, in 32 | m.sqrt(25) 33 | NameError: name 'm' is not defined 34 | >>> import math as m 35 | >>> math.sqrt(25) 36 | 5.0 37 | >>> m.sqrt(25) 38 | 5.0 39 | >>> 40 | =============================== RESTART: Shell =============================== 41 | >>> math.sqrt(25) 42 | Traceback (most recent call last): 43 | File "", line 1, in 44 | math.sqrt(25) 45 | NameError: name 'math' is not defined 46 | >>> from math import sqrt, pow 47 | >>> pow(4,5) 48 | 1024.0 49 | >>> help('math') 50 | >>> 51 | -------------------------------------------------------------------------------- /11 Data Types in Python: -------------------------------------------------------------------------------- 1 | Code 2 | 3 | Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32 4 | Type "help", "copyright", "credits" or "license()" for more information. 5 | >>> num = 2.5 6 | >>> type(num) 7 | 8 | >>> num = 5 9 | >>> type(num) 10 | 11 | >>> num = 6+9j 12 | >>> type(num) 13 | 14 | >>> a = 5.6 15 | >>> b = int(a) 16 | >>> type(b) 17 | 18 | >>> b 19 | 5 20 | >>> k = float(b) 21 | >>> k 22 | 5.0 23 | >>> k = 6 24 | >>> c = complex(b,k) 25 | >>> c 26 | (5+6j) 27 | >>> b>> boll = b < k 30 | >>> bool 31 | 32 | >>> b > k 33 | False 34 | >>> int(True) 35 | 1 36 | >>> int(False) 37 | 0 38 | >>> 1st = [25,36,45,12] 39 | SyntaxError: invalid syntax 40 | >>> lst = [25,36,45,12] 41 | >>> type(lst) 42 | 43 | >>> s = {25,36,45,15,12,25} 44 | >>> s 45 | {36, 12, 45, 15, 25} 46 | >>> type(s) 47 | 48 | >>> t = (25,36,4,57,12) 49 | >>> type(t) 50 | 51 | >>> str = "navin" 52 | >>> st = 'a' 53 | >>> type(st) 54 | 55 | >>> range(10) 56 | range(0, 10) 57 | >>> list(range(10)) 58 | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 59 | >>> list(range(2,10,2)) 60 | [2, 4, 6, 8] 61 | >>> type(range(10)) 62 | 63 | >>> d = {'navin':'samsung','rahul':'Iphone','kiran':'Oneplus'} 64 | >>> d 65 | {'navin': 'samsung', 'rahul': 'Iphone', 'kiran': 'Oneplus'} 66 | >>> d.keys() 67 | dict_keys(['navin', 'rahul', 'kiran']) 68 | >>> d.values() 69 | dict_values(['samsung', 'Iphone', 'Oneplus']) 70 | >>> d['rahul'] 71 | 'Iphone' 72 | >>> d.get('kiran') 73 | 'Oneplus' 74 | >>> 75 | -------------------------------------------------------------------------------- /6 List in Python: -------------------------------------------------------------------------------- 1 | Code 2 | 3 | Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32 4 | Type "help", "copyright", "credits" or "license()" for more information. 5 | >>> nums = [25,12,36,95,14] 6 | >>> nums 7 | [25, 12, 36, 95, 14] 8 | >>> nums[0] 9 | 25 10 | >>> nums[54\] 11 | 12 | SyntaxError: unexpected character after line continuation character 13 | >>> nums[54] 14 | Traceback (most recent call last): 15 | File "", line 1, in 16 | nums[54] 17 | IndexError: list index out of range 18 | >>> nums[4] 19 | 14 20 | >>> nums[2:] 21 | [36, 95, 14] 22 | >>> nums[-1] 23 | 14 24 | >>> nums[-5] 25 | 25 26 | >>> names = ['navin','kiran','john'] 27 | >>> names 28 | ['navin', 'kiran', 'john'] 29 | >>> values = [9.5,'Navin',25] 30 | >>> mil = [nums, names] 31 | >>> mil 32 | [[25, 12, 36, 95, 14], ['navin', 'kiran', 'john']] 33 | >>> nums.append(45) 34 | >>> nums 35 | [25, 12, 36, 95, 14, 45] 36 | >>> nums.insert(2,77) 37 | >>> nums 38 | [25, 12, 77, 36, 95, 14, 45] 39 | >>> nums.remove(14) 40 | >>> nums 41 | [25, 12, 77, 36, 95, 45] 42 | >>> nums.pop(1) 43 | 12 44 | >>> nums 45 | [25, 77, 36, 95, 45] 46 | >>> nums.pop() 47 | 45 48 | >>> del nums[2:] 49 | >>> nums 50 | [25, 77] 51 | >>> nums.extend(29,12,14,36) 52 | Traceback (most recent call last): 53 | File "", line 1, in 54 | nums.extend(29,12,14,36) 55 | TypeError: extend() takes exactly one argument (4 given) 56 | >>> nums.extend([29,12,14,36]) 57 | >>> nums 58 | [25, 77, 29, 12, 14, 36] 59 | >>> min(nums) 60 | 12 61 | >>> max(nums) 62 | 77 63 | >>> sum(nums) 64 | 193 65 | >>> nums.sort() 66 | >>> nums 67 | [12, 14, 25, 29, 36, 77] 68 | >>> 69 | -------------------------------------------------------------------------------- /86 Django Template Language DTL.txt: -------------------------------------------------------------------------------- 1 | view.py 2 | -------------------------------------------------------------------------------- 3 | 4 | from django.shortcuts import render 5 | from django.http import HttpResponse 6 | 7 | # Create your views here. 8 | 9 | 10 | def home(request): 11 | return render(request, 'home.html', {'name': 'Kiran'}) 12 | 13 | 14 | -------------------------------------------------------------------------------- 15 | home.html 16 | -------------------------------------------------------------------------------- 17 | 18 |

Hello {{name}}!!!!!

19 | 20 | 21 | -------------------------------------------------------------------------------- 22 | urls.py ::calc 23 | -------------------------------------------------------------------------------- 24 | 25 | from django.urls import include, path 26 | from . import views 27 | from django.contrib import admin 28 | 29 | urlpatterns = [ 30 | path('', views.home, name='home'), 31 | 32 | ] 33 | -------------------------------------------------------------------------------- 34 | urls.py ::telusko 35 | -------------------------------------------------------------------------------- 36 | 37 | from django.contrib import admin 38 | from django.urls import path, include 39 | 40 | urlpatterns = [ 41 | path('', include('calc.urls')), 42 | path('admin/', admin.site.urls), 43 | ] 44 | 45 | -------------------------------------------------------------------------------- 46 | settings.py 47 | -------------------------------------------------------------------------------- 48 | 49 | 'DIRS': [os.path.join(BASE_DIR, 'templates')], 50 | -------------------------------------------------------------------------------- /5 Variables in Python: -------------------------------------------------------------------------------- 1 | Code 2 | 3 | Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32 4 | Type "help", "copyright", "credits" or "license()" for more information. 5 | >>> 2 + 3 6 | 5 7 | >>> x = 2 8 | >>> x + 3 9 | 5 10 | >>> y = 3 11 | >>> x + y 12 | 5 13 | >>> x = 9 14 | >>> x + y 15 | 12 16 | >>> x 17 | 9 18 | >>> abc 19 | Traceback (most recent call last): 20 | File "", line 1, in 21 | abc 22 | NameError: name 'abc' is not defined 23 | >>> x + 10 24 | 19 25 | >>> _ + y 26 | 22 27 | >>> name = 'youtube' 28 | >>> name 29 | 'youtube' 30 | >>> mane + ' rocks' 31 | Traceback (most recent call last): 32 | File "", line 1, in 33 | mane + ' rocks' 34 | NameError: name 'mane' is not defined 35 | >>> name + ' rocks' 36 | 'youtube rocks' 37 | >>> name ' rocks' 38 | SyntaxError: invalid syntax 39 | >>> name [0] 40 | 'y' 41 | >>> name [6] 42 | 'e' 43 | >>> name [8] 44 | Traceback (most recent call last): 45 | File "", line 1, in 46 | name [8] 47 | IndexError: string index out of range 48 | >>> name [-1] 49 | 'e' 50 | >>> name [-2] 51 | 'b' 52 | >>> name [-7] 53 | 'y' 54 | >>> name [0:2] 55 | 'yo' 56 | >>> name [1:4] 57 | 'out' 58 | >>> name [1:] 59 | 'outube' 60 | >>> name[:4] 61 | 'yout' 62 | >>> [3:10] 63 | SyntaxError: invalid syntax 64 | >>> name [3:10] 65 | 'tube' 66 | >>> name [0:3] = 'my' 67 | Traceback (most recent call last): 68 | File "", line 1, in 69 | name [0:3] = 'my' 70 | TypeError: 'str' object does not support item assignment 71 | >>> name[0] = 'R' 72 | Traceback (most recent call last): 73 | File "", line 1, in 74 | name[0] = 'R' 75 | TypeError: 'str' object does not support item assignment 76 | >>> 'my ' + name[3:] 77 | 'my tube' 78 | >>> myname = 'Navin Reddy' 79 | >>> len(myname) 80 | 11 81 | -------------------------------------------------------------------------------- /87 Django Template Language part 2.txt: -------------------------------------------------------------------------------- 1 | view.py 2 | -------------------------------------------------------------------------------- 3 | 4 | from django.shortcuts import render 5 | from django.http import HttpResponse 6 | 7 | # Create your views here. 8 | 9 | 10 | def home(request): 11 | return render(request, 'home.html', {'name': 'Kiran'}) 12 | 13 | 14 | -------------------------------------------------------------------------------- 15 | home.html 16 | -------------------------------------------------------------------------------- 17 | 18 | {% extends 'base.html' %} 19 | 20 | {% block content %} 21 |

Hello {{name}}!!!!!

22 | 23 | {% endblock%} 24 | 25 | 26 | -------------------------------------------------------------------------------- 27 | base.html 28 | -------------------------------------------------------------------------------- 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | Telusko 38 | 39 | 40 | 41 | 42 | {% block content %} 43 | 44 | {% endblock %} 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- 52 | urls.py ::calc 53 | -------------------------------------------------------------------------------- 54 | 55 | from django.urls import include, path 56 | from . import views 57 | from django.contrib import admin 58 | 59 | urlpatterns = [ 60 | path('', views.home, name='home'), 61 | 62 | ] 63 | -------------------------------------------------------------------------------- 64 | urls.py ::telusko 65 | -------------------------------------------------------------------------------- 66 | 67 | from django.contrib import admin 68 | from django.urls import path, include 69 | 70 | urlpatterns = [ 71 | path('', include('calc.urls')), 72 | path('admin/', admin.site.urls), 73 | ] 74 | -------------------------------------------------------------------------------- /88 Addition of Two Numbers in Django.txt: -------------------------------------------------------------------------------- 1 | view.py 2 | -------------------------------------------------------------------------------- 3 | 4 | from django.shortcuts import render 5 | from django.http import HttpResponse 6 | 7 | # Create your views here. 8 | 9 | 10 | def home(request): 11 | return render(request, 'home.html', {'name': 'Navin'}) 12 | 13 | 14 | def add(request): 15 | 16 | val1 = int(request.GET['num1']) 17 | val2 = int(request.GET['num2']) 18 | res = val1 + val2 19 | 20 | return render(request, "result.html", {'result': res}) 21 | 22 | 23 | -------------------------------------------------------------------------------- 24 | home.html 25 | -------------------------------------------------------------------------------- 26 | 27 | {% extends 'base.html' %} 28 | 29 | {% block content %} 30 |

Hello {{name}}!!!!!

31 | 32 |
33 | 34 | Enter 1st number :
35 | Enter 2st number :
36 | 37 | 38 |
39 | 40 | {% endblock%} 41 | 42 | 43 | -------------------------------------------------------------------------------- 44 | result.html 45 | -------------------------------------------------------------------------------- 46 | 47 | {% extends 'base.html' %} 48 | 49 | {% block content %} 50 | 51 | Result : {{result}} 52 | 53 | {% endblock%} 54 | 55 | -------------------------------------------------------------------------------- 56 | base.html 57 | -------------------------------------------------------------------------------- 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | Telusko 67 | 68 | 69 | 70 | 71 | {% block content %} 72 | 73 | {% endblock %} 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- 81 | urls.py ::calc 82 | -------------------------------------------------------------------------------- 83 | 84 | from django.urls import include, path 85 | from . import views 86 | from django.contrib import admin 87 | 88 | urlpatterns = [ 89 | path('', views.home, name='home'), 90 | path('add', views.add, name='add') 91 | 92 | ] 93 | 94 | -------------------------------------------------------------------------------- 95 | urls.py ::telusko 96 | -------------------------------------------------------------------------------- 97 | 98 | from django.contrib import admin 99 | from django.urls import path, include 100 | 101 | urlpatterns = [ 102 | path('', include('calc.urls')), 103 | path('admin/', admin.site.urls), 104 | ] 105 | -------------------------------------------------------------------------------- /89 GET vs POST HTTP Methods.txt: -------------------------------------------------------------------------------- 1 | view.py 2 | -------------------------------------------------------------------------------- 3 | 4 | from django.shortcuts import render 5 | from django.http import HttpResponse 6 | 7 | # Create your views here. 8 | 9 | 10 | def home(request): 11 | return render(request, 'home.html', {'name': 'Navin'}) 12 | 13 | 14 | def add(request): 15 | 16 | val1 = int(request.POST['num1']) 17 | val2 = int(request.POST['num2']) 18 | res = val1 + val2 19 | 20 | return render(request, "result.html", {'result': res}) 21 | 22 | 23 | -------------------------------------------------------------------------------- 24 | home.html 25 | -------------------------------------------------------------------------------- 26 | 27 | {% extends 'base.html' %} 28 | 29 | {% block content %} 30 |

Hello {{name}}!!!!!

31 | 32 |
33 | 34 | {% csrf_token %} 35 | 36 | Enter 1st number :
37 | Enter 2st number :
38 | 39 | 40 |
41 | 42 | {% endblock%} 43 | 44 | 45 | -------------------------------------------------------------------------------- 46 | result.html 47 | -------------------------------------------------------------------------------- 48 | 49 | {% extends 'base.html' %} 50 | 51 | {% block content %} 52 | 53 | Result : {{result}} 54 | 55 | {% endblock%} 56 | 57 | -------------------------------------------------------------------------------- 58 | base.html 59 | -------------------------------------------------------------------------------- 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | Telusko 69 | 70 | 71 | 72 | 73 | {% block content %} 74 | 75 | {% endblock %} 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- 83 | urls.py ::calc 84 | -------------------------------------------------------------------------------- 85 | 86 | from django.urls import include, path 87 | from . import views 88 | from django.contrib import admin 89 | 90 | urlpatterns = [ 91 | path('', views.home, name='home'), 92 | path('add', views.add, name='add') 93 | 94 | ] 95 | 96 | -------------------------------------------------------------------------------- 97 | urls.py ::telusko 98 | -------------------------------------------------------------------------------- 99 | 100 | from django.contrib import admin 101 | from django.urls import path, include 102 | 103 | urlpatterns = [ 104 | path('', include('calc.urls')), 105 | path('admin/', admin.site.urls), 106 | ] 107 | -------------------------------------------------------------------------------- /94 Passing Dynamic Data in Html part 2.txt: -------------------------------------------------------------------------------- 1 | index.html 2 | -------------------------------------------------------------------------------- 3 | 4 | {% load static %} 5 | {% static "images" as baseUrl %} 6 | 7 | 8 | 9 | 10 | Travello 11 | 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 | 46 |
Call us: 00-56 445 678 33
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 | 104 | 105 | 106 | 107 |
108 | 109 | 110 |
111 | 171 | 172 |
173 | 178 |
179 |
180 |
181 | 182 | 183 | 184 | 211 | 212 | 213 | 214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 | 222 | 223 |
224 |
225 |
226 |
227 |
Top Destinations
228 |
229 |

Nulla pretium tincidunt felis, nec.

230 |
231 |
232 |
233 |
234 | 235 | 236 |
237 |
238 |
239 |
240 |
241 |
The Best Prices
242 |
243 |

Sollicitudin mauris lobortis in.

244 |
245 |
246 |
247 |
248 | 249 | 250 |
251 |
252 |
253 |
254 |
255 |
Amazing Services
256 |
257 |

Nulla pretium tincidunt felis, nec.

258 |
259 |
260 |
261 |
262 | 263 |
264 |
265 |
266 |
267 |
268 |
269 | 270 | 271 | 272 |
273 |
274 |
275 |
276 |
simply amazing places
277 |
278 |

Popular Destinations

279 |
280 |
281 |
282 |
283 |
284 |
285 | 286 | {% for dest in dests %} 287 | 288 |
289 |
290 | 291 | 292 |
293 |
294 | 295 |
296 |

{{dest.desc}}

297 |
298 |
From ${{dest.price}}
299 |
300 |
301 | 302 | {% endfor %} 303 | 304 | 305 |
306 |
307 |
308 |
309 |
310 | 311 | 312 | 313 |
314 |
316 |
317 |
318 |
319 |
simply amazing places
320 |
321 |

Testimonials

322 |
323 |
324 |
325 |
326 |
327 | 328 | 329 |
330 | 375 |
376 |
377 |
378 |
379 | 386 |
387 | 388 | 389 | 390 |
391 |
392 |
393 |
394 |
395 | 396 | 397 |
399 |
400 |
401 | 405 |
Best tips to travel light
406 | 411 |
412 |

Pellentesque sit amet elementum ccumsan sit amet mattis eget, tristique at 413 | leo. Vivamus massa.Tempor massa et laoreet.

414 |
415 |
416 |
417 | 418 | 419 |
421 |
422 |
423 | 427 |
Best tips to travel light
428 | 433 |
434 |

Tempor massa et laoreet malesuada. Pellentesque sit amet elementum ccumsan 435 | sit amet mattis eget, tristique at leo.

436 |
437 |
438 |
439 | 440 | 441 |
443 |
444 |
445 | 449 |
Best tips to travel light
450 | 455 |
456 |

Vivamus massa.Tempor massa et laoreet malesuada. Aliquam nulla nisl, accumsan 457 | sit amet mattis.

458 |
459 |
460 |
461 | 462 |
463 |
464 | 465 | 466 |
467 |
468 |
470 |
471 |
472 |
473 |
474 |
475 |
476 | 484 |
485 |
486 |
487 |
488 |
489 | 490 | 491 | 492 |
493 |
495 |
496 |
497 |
498 | 524 |
525 |
526 | 580 |
581 |
582 | 583 | Copyright © 584 | All rights reserved | This template is made 585 | with by Colorlib 587 | 588 |
589 |
590 |
591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | -------------------------------------------------------------------------------- 607 | models.py 608 | -------------------------------------------------------------------------------- 609 | 610 | from django.db import models 611 | 612 | # Create your models here. 613 | 614 | 615 | class Destination: 616 | id: int 617 | name: str 618 | img: str 619 | desc: str 620 | price: int 621 | 622 | 623 | -------------------------------------------------------------------------------- 624 | views.py 625 | -------------------------------------------------------------------------------- 626 | 627 | 628 | from django.shortcuts import render 629 | from .models import Destination 630 | 631 | # Create your views here. 632 | 633 | 634 | def index(request): 635 | 636 | dest1 = Destination() 637 | dest1.name = 'Mumbai' 638 | dest1.desc = 'The City That Never Sleeps' 639 | dest1.img = 'destination_1.jpg' 640 | dest1.price = 700 641 | 642 | dest2 = Destination() 643 | dest2.name = 'Hyderabad' 644 | dest2.desc = 'First Biryani, Then Sherwani' 645 | dest2.img = 'destination_2.jpg' 646 | dest2.price = 650 647 | 648 | dest3 = Destination() 649 | dest3.name = 'Bengaluru' 650 | dest3.desc = 'Beautiful City' 651 | dest3.img = 'destination_3.jpg' 652 | dest3.price = 750 653 | 654 | dests = [dest1, dest2, dest3] 655 | 656 | return render(request, "index.html", {'dests': dests}) 657 | -------------------------------------------------------------------------------- /95 If statement.txt: -------------------------------------------------------------------------------- 1 | index.html 2 | -------------------------------------------------------------------------------- 3 | {% load static %} 4 | {% static "images" as baseUrl %} 5 | 6 | 7 | 8 | 9 | Travello 10 | 11 | 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 | 45 |
Call us: 00-56 445 678 33
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 | 103 | 104 | 105 | 106 |
107 | 108 | 109 |
110 | 170 | 171 |
172 | 177 |
178 |
179 |
180 | 181 | 182 | 183 | 210 | 211 | 212 | 213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 | 221 | 222 |
223 |
224 |
225 |
226 |
Top Destinations
227 |
228 |

Nulla pretium tincidunt felis, nec.

229 |
230 |
231 |
232 |
233 | 234 | 235 |
236 |
237 |
238 |
239 |
240 |
The Best Prices
241 |
242 |

Sollicitudin mauris lobortis in.

243 |
244 |
245 |
246 |
247 | 248 | 249 |
250 |
251 |
252 |
253 |
254 |
Amazing Services
255 |
256 |

Nulla pretium tincidunt felis, nec.

257 |
258 |
259 |
260 |
261 | 262 |
263 |
264 |
265 |
266 |
267 |
268 | 269 | 270 | 271 |
272 |
273 |
274 |
275 |
simply amazing places
276 |
277 |

Popular Destinations

278 |
279 |
280 |
281 |
282 |
283 |
284 | 285 | {% for dest in dests %} 286 | 287 |
288 |
289 | 290 | 291 | {% if dest.offer %} 292 | 293 | {% endif %} 294 |
295 |
296 | 297 |
298 |

{{dest.desc}}

299 |
300 |
From ${{dest.price}}
301 |
302 |
303 | 304 | {% endfor %} 305 | 306 | 307 |
308 |
309 |
310 |
311 |
312 | 313 | 314 | 315 |
316 |
318 |
319 |
320 |
321 |
simply amazing places
322 |
323 |

Testimonials

324 |
325 |
326 |
327 |
328 |
329 | 330 | 331 |
332 | 377 |
378 |
379 |
380 |
381 | 388 |
389 | 390 | 391 | 392 |
393 |
394 |
395 |
396 |
397 | 398 | 399 |
401 |
402 |
403 | 407 |
Best tips to travel light
408 | 413 |
414 |

Pellentesque sit amet elementum ccumsan sit amet mattis eget, tristique at 415 | leo. Vivamus massa.Tempor massa et laoreet.

416 |
417 |
418 |
419 | 420 | 421 |
423 |
424 |
425 | 429 |
Best tips to travel light
430 | 435 |
436 |

Tempor massa et laoreet malesuada. Pellentesque sit amet elementum ccumsan 437 | sit amet mattis eget, tristique at leo.

438 |
439 |
440 |
441 | 442 | 443 |
445 |
446 |
447 | 451 |
Best tips to travel light
452 | 457 |
458 |

Vivamus massa.Tempor massa et laoreet malesuada. Aliquam nulla nisl, accumsan 459 | sit amet mattis.

460 |
461 |
462 |
463 | 464 |
465 |
466 | 467 | 468 |
469 |
470 |
472 |
473 |
474 |
475 |
476 |
477 |
478 | 486 |
487 |
488 |
489 |
490 |
491 | 492 | 493 | 494 |
495 |
497 |
498 |
499 |
500 | 526 |
527 |
528 | 582 |
583 |
584 | 585 | Copyright © 586 | All rights reserved | This template is made 587 | with by Colorlib 589 | 590 |
591 |
592 |
593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | -------------------------------------------------------------------------------- 608 | models.py 609 | -------------------------------------------------------------------------------- 610 | 611 | from django.db import models 612 | 613 | # Create your models here. 614 | 615 | 616 | class Destination: 617 | id: int 618 | name: str 619 | img: str 620 | desc: str 621 | price: int 622 | offer : bool 623 | 624 | 625 | -------------------------------------------------------------------------------- 626 | views.py 627 | -------------------------------------------------------------------------------- 628 | 629 | 630 | from django.shortcuts import render 631 | from .models import Destination 632 | 633 | # Create your views here. 634 | 635 | 636 | def index(request): 637 | 638 | dest1 = Destination() 639 | dest1.name = 'Mumbai' 640 | dest1.desc = 'The City That Never Sleeps' 641 | dest1.img = 'destination_1.jpg' 642 | dest1.price = 700 643 | dest1.offer = False 644 | 645 | dest2 = Destination() 646 | dest2.name = 'Hyderabad' 647 | dest2.desc = 'First Biryani, Then Sherwani' 648 | dest2.img = 'destination_2.jpg' 649 | dest2.price = 650 650 | dest2.offer = True 651 | 652 | dest3 = Destination() 653 | dest3.name = 'Bengaluru' 654 | dest3.desc = 'Beautiful City' 655 | dest3.img = 'destination_3.jpg' 656 | dest3.price = 750 657 | dest3.offer = True 658 | 659 | dests = [dest1, dest2, dest3] 660 | 661 | return render(request, "index.html", {'dests': dests}) -------------------------------------------------------------------------------- /91 Static File - 1.txt: -------------------------------------------------------------------------------- 1 | index.html 2 | -------------------------------------------------------------------------------- 3 | 4 | 5 | 6 | 7 | Travello 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 |
27 |
28 |
29 |
30 |
31 |
32 | 33 | 42 |
Call us: 00-56 445 678 33
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 | 95 | 96 | 97 | 98 |
99 | 100 | 101 |
102 | 153 | 154 |
155 | 160 |
161 |
162 |
163 | 164 | 165 | 166 | 188 | 189 | 190 | 191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 | 199 | 200 |
201 |
202 |
203 |
204 |
Top Destinations
205 |

Nulla pretium tincidunt felis, nec.

206 |
207 |
208 |
209 | 210 | 211 |
212 |
213 |
214 |
215 |
The Best Prices
216 |

Sollicitudin mauris lobortis in.

217 |
218 |
219 |
220 | 221 | 222 |
223 |
224 |
225 |
226 |
Amazing Services
227 |

Nulla pretium tincidunt felis, nec.

228 |
229 |
230 |
231 | 232 |
233 |
234 |
235 |
236 |
237 |
238 | 239 | 240 | 241 |
242 |
243 |
244 |
245 |
simply amazing places
246 |

Popular Destinations

247 |
248 |
249 |
250 |
251 |
252 | 253 | 254 |
255 |
256 | 257 | 258 |
259 |
260 | 261 |

Nulla pretium tincidunt felis, nec.

262 |
From $679
263 |
264 |
265 | 266 | 267 |
268 |
269 | 270 |
271 |
272 | 273 |

Nulla pretium tincidunt felis, nec.

274 |
From $679
275 |
276 |
277 | 278 | 279 |
280 |
281 | 282 |
283 |
284 | 285 |

Nulla pretium tincidunt felis, nec.

286 |
From $679
287 |
288 |
289 | 290 | 291 |
292 |
293 | 294 |
295 |
296 | 297 |

Nulla pretium tincidunt felis, nec.

298 |
From $679
299 |
300 |
301 | 302 | 303 |
304 |
305 | 306 |
307 |
308 | 309 |

Nulla pretium tincidunt felis, nec.

310 |
From $679
311 |
312 |
313 | 314 | 315 |
316 |
317 | 318 |
319 |
320 | 321 |

Nulla pretium tincidunt felis, nec.

322 |
From $679
323 |
324 |
325 | 326 |
327 |
328 |
329 |
330 |
331 | 332 | 333 | 334 |
335 |
336 |
337 |
338 |
339 |
simply amazing places
340 |

Testimonials

341 |
342 |
343 |
344 |
345 | 346 | 347 |
348 | 384 |
385 |
386 |
387 |
388 | 395 |
396 | 397 | 398 | 399 |
400 |
401 |
402 |
403 |
404 | 405 | 406 |
407 |
408 |
409 | 413 |
Best tips to travel light
414 | 419 |
420 |

Pellentesque sit amet elementum ccumsan sit amet mattis eget, tristique at leo. Vivamus massa.Tempor massa et laoreet.

421 |
422 |
423 |
424 | 425 | 426 |
427 |
428 |
429 | 433 |
Best tips to travel light
434 | 439 |
440 |

Tempor massa et laoreet malesuada. Pellentesque sit amet elementum ccumsan sit amet mattis eget, tristique at leo.

441 |
442 |
443 |
444 | 445 | 446 |
447 |
448 |
449 | 453 |
Best tips to travel light
454 | 459 |
460 |

Vivamus massa.Tempor massa et laoreet malesuada. Aliquam nulla nisl, accumsan sit amet mattis.

461 |
462 |
463 |
464 | 465 |
466 |
467 | 468 | 469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 | 486 |
487 |
488 |
489 |
490 |
491 | 492 | 493 | 494 |
495 |
496 |
497 |
498 |
499 | 514 |
515 |
516 | 564 |
565 |
566 | Copyright © All rights reserved | This template is made with by Colorlib 567 |
568 |
569 |
570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | -------------------------------------------------------------------------------- 585 | urls.py :: travello 586 | -------------------------------------------------------------------------------- 587 | 588 | from django.urls import include, path 589 | from . import views 590 | from django.contrib import admin 591 | 592 | urlpatterns = [ 593 | path('', views.index, name='index') 594 | 595 | ] 596 | 597 | 598 | -------------------------------------------------------------------------------- 599 | views.py 600 | -------------------------------------------------------------------------------- 601 | 602 | 603 | from django.shortcuts import render 604 | 605 | # Create your views here. 606 | 607 | 608 | def index(request): 609 | return render(request, "index.html") 610 | 611 | 612 | -------------------------------------------------------------------------------- 613 | urls.py :: telusko 614 | -------------------------------------------------------------------------------- 615 | 616 | """telusko URL Configuration 617 | 618 | The `urlpatterns` list routes URLs to views. For more information please see: 619 | https://docs.djangoproject.com/en/2.2/topics/http/urls/ 620 | Examples: 621 | Function views 622 | 1. Add an import: from my_app import views 623 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 624 | Class-based views 625 | 1. Add an import: from other_app.views import Home 626 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 627 | Including another URLconf 628 | 1. Import the include() function: from django.urls import include, path 629 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 630 | """ 631 | from django.contrib import admin 632 | from django.urls import path, include 633 | 634 | urlpatterns = [ 635 | path('', include('travello.urls')), 636 | path('admin/', admin.site.urls), 637 | ] 638 | 639 | 640 | -------------------------------------------------------------------------------- /99 Re-Migration.txt: -------------------------------------------------------------------------------- 1 | index.html 2 | -------------------------------------------------------------------------------- 3 | {% load static %} 4 | {% static "images" as baseUrl %} 5 | 6 | 7 | 8 | 9 | Travello 10 | 11 | 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 | 45 |
Call us: 00-56 445 678 33
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 | 103 | 104 | 105 | 106 |
107 | 108 | 109 |
110 | 170 | 171 |
172 | 177 |
178 |
179 |
180 | 181 | 182 | 183 | 210 | 211 | 212 | 213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 | 221 | 222 |
223 |
224 |
225 |
226 |
Top Destinations
227 |
228 |

Nulla pretium tincidunt felis, nec.

229 |
230 |
231 |
232 |
233 | 234 | 235 |
236 |
237 |
238 |
239 |
240 |
The Best Prices
241 |
242 |

Sollicitudin mauris lobortis in.

243 |
244 |
245 |
246 |
247 | 248 | 249 |
250 |
251 |
252 |
253 |
254 |
Amazing Services
255 |
256 |

Nulla pretium tincidunt felis, nec.

257 |
258 |
259 |
260 |
261 | 262 |
263 |
264 |
265 |
266 |
267 |
268 | 269 | 270 | 271 |
272 |
273 |
274 |
275 |
simply amazing places
276 |
277 |

Popular Destinations

278 |
279 |
280 |
281 |
282 |
283 |
284 | 285 | {% for dest in dests %} 286 | 287 |
288 |
289 | 290 | 291 | {% if dest.offer %} 292 | 293 | {% endif %} 294 |
295 |
296 | 297 |
298 |

{{dest.desc}}

299 |
300 |
From ${{dest.price}}
301 |
302 |
303 | 304 | {% endfor %} 305 | 306 | 307 |
308 |
309 |
310 |
311 |
312 | 313 | 314 | 315 |
316 |
318 |
319 |
320 |
321 |
simply amazing places
322 |
323 |

Testimonials

324 |
325 |
326 |
327 |
328 |
329 | 330 | 331 |
332 | 377 |
378 |
379 |
380 |
381 | 388 |
389 | 390 | 391 | 392 |
393 |
394 |
395 |
396 |
397 | 398 | 399 |
401 |
402 |
403 | 407 |
Best tips to travel light
408 | 413 |
414 |

Pellentesque sit amet elementum ccumsan sit amet mattis eget, tristique at 415 | leo. Vivamus massa.Tempor massa et laoreet.

416 |
417 |
418 |
419 | 420 | 421 |
423 |
424 |
425 | 429 |
Best tips to travel light
430 | 435 |
436 |

Tempor massa et laoreet malesuada. Pellentesque sit amet elementum ccumsan 437 | sit amet mattis eget, tristique at leo.

438 |
439 |
440 |
441 | 442 | 443 |
445 |
446 |
447 | 451 |
Best tips to travel light
452 | 457 |
458 |

Vivamus massa.Tempor massa et laoreet malesuada. Aliquam nulla nisl, accumsan 459 | sit amet mattis.

460 |
461 |
462 |
463 | 464 |
465 |
466 | 467 | 468 |
469 |
470 |
472 |
473 |
474 |
475 |
476 |
477 |
478 | 486 |
487 |
488 |
489 |
490 |
491 | 492 | 493 | 494 |
495 |
497 |
498 |
499 |
500 | 526 |
527 |
528 | 582 |
583 |
584 | 585 | Copyright © 586 | All rights reserved | This template is made 587 | with by Colorlib 589 | 590 |
591 |
592 |
593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | -------------------------------------------------------------------------------- 608 | models.py 609 | -------------------------------------------------------------------------------- 610 | 611 | from django.db import models 612 | 613 | # Create your models here. 614 | 615 | 616 | class Destination(models.Model): 617 | 618 | name = models.CharField(max_length=100) 619 | img = models.ImageField(upload_to='pics') 620 | desc = models.TextField() 621 | price = models.IntegerField() 622 | offer = models.BooleanField(default=False) 623 | 624 | 625 | -------------------------------------------------------------------------------- 626 | views.py 627 | -------------------------------------------------------------------------------- 628 | 629 | 630 | from django.shortcuts import render 631 | from .models import Destination 632 | 633 | # Create your views here. 634 | 635 | 636 | def index(request): 637 | 638 | dest1 = Destination() 639 | dest1.name = 'Mumbai' 640 | dest1.desc = 'The City That Never Sleeps' 641 | dest1.img = 'destination_1.jpg' 642 | dest1.price = 700 643 | dest1.offer = False 644 | 645 | dest2 = Destination() 646 | dest2.name = 'Hyderabad' 647 | dest2.desc = 'First Biryani, Then Sherwani' 648 | dest2.img = 'destination_2.jpg' 649 | dest2.price = 650 650 | dest2.offer = True 651 | 652 | dest3 = Destination() 653 | dest3.name = 'Bengaluru' 654 | dest3.desc = 'Beautiful City' 655 | dest3.img = 'destination_3.jpg' 656 | dest3.price = 750 657 | dest3.offer = True 658 | 659 | dests = [dest1, dest2, dest3] 660 | 661 | return render(request, "index.html", {'dests': dests}) 662 | 663 | -------------------------------------------------------------------------------- 664 | settings.py 665 | -------------------------------------------------------------------------------- 666 | 667 | """ 668 | Django settings for telusko project. 669 | 670 | Generated by 'django-admin startproject' using Django 2.2.5. 671 | 672 | For more information on this file, see 673 | https://docs.djangoproject.com/en/2.2/topics/settings/ 674 | 675 | For the full list of settings and their values, see 676 | https://docs.djangoproject.com/en/2.2/ref/settings/ 677 | """ 678 | 679 | import os 680 | 681 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 682 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 683 | 684 | 685 | # Quick-start development settings - unsuitable for production 686 | # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ 687 | 688 | # SECURITY WARNING: keep the secret key used in production secret! 689 | SECRET_KEY = 'fdg3ouh6u6x2x@ziy!t8k30!qq^fw@wc882*k4y&djotjrn+1s' 690 | 691 | # SECURITY WARNING: don't run with debug turned on in production! 692 | DEBUG = True 693 | 694 | ALLOWED_HOSTS = [] 695 | 696 | 697 | # Application definition 698 | 699 | INSTALLED_APPS = [ 700 | 'travello.apps.TravelloConfig', 701 | 'django.contrib.admin', 702 | 'django.contrib.auth', 703 | 'django.contrib.contenttypes', 704 | 'django.contrib.sessions', 705 | 'django.contrib.messages', 706 | 'django.contrib.staticfiles', 707 | ] 708 | 709 | MIDDLEWARE = [ 710 | 'django.middleware.security.SecurityMiddleware', 711 | 'django.contrib.sessions.middleware.SessionMiddleware', 712 | 'django.middleware.common.CommonMiddleware', 713 | 'django.middleware.csrf.CsrfViewMiddleware', 714 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 715 | 'django.contrib.messages.middleware.MessageMiddleware', 716 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 717 | ] 718 | 719 | ROOT_URLCONF = 'telusko.urls' 720 | 721 | TEMPLATES = [ 722 | { 723 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 724 | 'DIRS': [os.path.join(BASE_DIR, 'templates')], 725 | 'APP_DIRS': True, 726 | 'OPTIONS': { 727 | 'context_processors': [ 728 | 'django.template.context_processors.debug', 729 | 'django.template.context_processors.request', 730 | 'django.contrib.auth.context_processors.auth', 731 | 'django.contrib.messages.context_processors.messages', 732 | ], 733 | }, 734 | }, 735 | ] 736 | 737 | WSGI_APPLICATION = 'telusko.wsgi.application' 738 | 739 | 740 | # Database 741 | # https://docs.djangoproject.com/en/2.2/ref/settings/#databases 742 | 743 | DATABASES = { 744 | 'default': { 745 | 'ENGINE': 'django.db.backends.postgresql', 746 | 'NAME': 'telusko', 747 | 'USER': 'postgres', 748 | 'PASSWORD': '1234', 749 | 'HOST': 'localhost' 750 | } 751 | } 752 | 753 | 754 | # Password validation 755 | # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators 756 | 757 | AUTH_PASSWORD_VALIDATORS = [ 758 | { 759 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 760 | }, 761 | { 762 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 763 | }, 764 | { 765 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 766 | }, 767 | { 768 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 769 | }, 770 | ] 771 | 772 | 773 | # Internationalization 774 | # https://docs.djangoproject.com/en/2.2/topics/i18n/ 775 | 776 | LANGUAGE_CODE = 'en-us' 777 | 778 | TIME_ZONE = 'UTC' 779 | 780 | USE_I18N = True 781 | 782 | USE_L10N = True 783 | 784 | USE_TZ = True 785 | 786 | 787 | # Static files (CSS, JavaScript, Images) 788 | # https://docs.djangoproject.com/en/2.2/howto/static-files/ 789 | 790 | STATIC_URL = '/static/' 791 | STATICFILES_DIRS = [ 792 | os.path.join(BASE_DIR, 'static') 793 | ] 794 | STATIC_ROOT = os.path.join(BASE_DIR, 'assets') 795 | 796 | 797 | 798 | -------------------------------------------------------------------------------- Re-Migration Steps 799 | -------------------------------------------------------------------------------- 800 | 801 | >python manage.py makemigrations 802 | Select an option: 1 803 | >>> 0 804 | 805 | >python manage.py migrate 806 | -------------------------------------------------------------------------------- /98 Models and Migration.txt: -------------------------------------------------------------------------------- 1 | index.html 2 | -------------------------------------------------------------------------------- 3 | {% load static %} 4 | {% static "images" as baseUrl %} 5 | 6 | 7 | 8 | 9 | Travello 10 | 11 | 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 | 45 |
Call us: 00-56 445 678 33
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 | 103 | 104 | 105 | 106 |
107 | 108 | 109 |
110 | 170 | 171 |
172 | 177 |
178 |
179 |
180 | 181 | 182 | 183 | 210 | 211 | 212 | 213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 | 221 | 222 |
223 |
224 |
225 |
226 |
Top Destinations
227 |
228 |

Nulla pretium tincidunt felis, nec.

229 |
230 |
231 |
232 |
233 | 234 | 235 |
236 |
237 |
238 |
239 |
240 |
The Best Prices
241 |
242 |

Sollicitudin mauris lobortis in.

243 |
244 |
245 |
246 |
247 | 248 | 249 |
250 |
251 |
252 |
253 |
254 |
Amazing Services
255 |
256 |

Nulla pretium tincidunt felis, nec.

257 |
258 |
259 |
260 |
261 | 262 |
263 |
264 |
265 |
266 |
267 |
268 | 269 | 270 | 271 |
272 |
273 |
274 |
275 |
simply amazing places
276 |
277 |

Popular Destinations

278 |
279 |
280 |
281 |
282 |
283 |
284 | 285 | {% for dest in dests %} 286 | 287 |
288 |
289 | 290 | 291 | {% if dest.offer %} 292 | 293 | {% endif %} 294 |
295 |
296 | 297 |
298 |

{{dest.desc}}

299 |
300 |
From ${{dest.price}}
301 |
302 |
303 | 304 | {% endfor %} 305 | 306 | 307 |
308 |
309 |
310 |
311 |
312 | 313 | 314 | 315 |
316 |
318 |
319 |
320 |
321 |
simply amazing places
322 |
323 |

Testimonials

324 |
325 |
326 |
327 |
328 |
329 | 330 | 331 |
332 | 377 |
378 |
379 |
380 |
381 | 388 |
389 | 390 | 391 | 392 |
393 |
394 |
395 |
396 |
397 | 398 | 399 |
401 |
402 |
403 | 407 |
Best tips to travel light
408 | 413 |
414 |

Pellentesque sit amet elementum ccumsan sit amet mattis eget, tristique at 415 | leo. Vivamus massa.Tempor massa et laoreet.

416 |
417 |
418 |
419 | 420 | 421 |
423 |
424 |
425 | 429 |
Best tips to travel light
430 | 435 |
436 |

Tempor massa et laoreet malesuada. Pellentesque sit amet elementum ccumsan 437 | sit amet mattis eget, tristique at leo.

438 |
439 |
440 |
441 | 442 | 443 |
445 |
446 |
447 | 451 |
Best tips to travel light
452 | 457 |
458 |

Vivamus massa.Tempor massa et laoreet malesuada. Aliquam nulla nisl, accumsan 459 | sit amet mattis.

460 |
461 |
462 |
463 | 464 |
465 |
466 | 467 | 468 |
469 |
470 |
472 |
473 |
474 |
475 |
476 |
477 |
478 | 486 |
487 |
488 |
489 |
490 |
491 | 492 | 493 | 494 |
495 |
497 |
498 |
499 |
500 | 526 |
527 |
528 | 582 |
583 |
584 | 585 | Copyright © 586 | All rights reserved | This template is made 587 | with by Colorlib 589 | 590 |
591 |
592 |
593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | -------------------------------------------------------------------------------- 608 | models.py 609 | -------------------------------------------------------------------------------- 610 | 611 | from django.db import models 612 | 613 | # Create your models here. 614 | 615 | 616 | class Destination(models.Model): 617 | 618 | name = models.CharField(max_length=100) 619 | img = models.ImageField(upload_to='pics') 620 | desc = models.TextField() 621 | price = models.IntegerField() 622 | offer = models.BooleanField(default=False) 623 | 624 | 625 | -------------------------------------------------------------------------------- 626 | views.py 627 | -------------------------------------------------------------------------------- 628 | 629 | 630 | from django.shortcuts import render 631 | from .models import Destination 632 | 633 | # Create your views here. 634 | 635 | 636 | def index(request): 637 | 638 | dest1 = Destination() 639 | dest1.name = 'Mumbai' 640 | dest1.desc = 'The City That Never Sleeps' 641 | dest1.img = 'destination_1.jpg' 642 | dest1.price = 700 643 | dest1.offer = False 644 | 645 | dest2 = Destination() 646 | dest2.name = 'Hyderabad' 647 | dest2.desc = 'First Biryani, Then Sherwani' 648 | dest2.img = 'destination_2.jpg' 649 | dest2.price = 650 650 | dest2.offer = True 651 | 652 | dest3 = Destination() 653 | dest3.name = 'Bengaluru' 654 | dest3.desc = 'Beautiful City' 655 | dest3.img = 'destination_3.jpg' 656 | dest3.price = 750 657 | dest3.offer = True 658 | 659 | dests = [dest1, dest2, dest3] 660 | 661 | return render(request, "index.html", {'dests': dests}) 662 | 663 | -------------------------------------------------------------------------------- 664 | settings.py 665 | -------------------------------------------------------------------------------- 666 | 667 | """ 668 | Django settings for telusko project. 669 | 670 | Generated by 'django-admin startproject' using Django 2.2.5. 671 | 672 | For more information on this file, see 673 | https://docs.djangoproject.com/en/2.2/topics/settings/ 674 | 675 | For the full list of settings and their values, see 676 | https://docs.djangoproject.com/en/2.2/ref/settings/ 677 | """ 678 | 679 | import os 680 | 681 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 682 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 683 | 684 | 685 | # Quick-start development settings - unsuitable for production 686 | # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ 687 | 688 | # SECURITY WARNING: keep the secret key used in production secret! 689 | SECRET_KEY = 'fdg3ouh6u6x2x@ziy!t8k30!qq^fw@wc882*k4y&djotjrn+1s' 690 | 691 | # SECURITY WARNING: don't run with debug turned on in production! 692 | DEBUG = True 693 | 694 | ALLOWED_HOSTS = [] 695 | 696 | 697 | # Application definition 698 | 699 | INSTALLED_APPS = [ 700 | 'travello.apps.TravelloConfig', 701 | 'django.contrib.admin', 702 | 'django.contrib.auth', 703 | 'django.contrib.contenttypes', 704 | 'django.contrib.sessions', 705 | 'django.contrib.messages', 706 | 'django.contrib.staticfiles', 707 | ] 708 | 709 | MIDDLEWARE = [ 710 | 'django.middleware.security.SecurityMiddleware', 711 | 'django.contrib.sessions.middleware.SessionMiddleware', 712 | 'django.middleware.common.CommonMiddleware', 713 | 'django.middleware.csrf.CsrfViewMiddleware', 714 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 715 | 'django.contrib.messages.middleware.MessageMiddleware', 716 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 717 | ] 718 | 719 | ROOT_URLCONF = 'telusko.urls' 720 | 721 | TEMPLATES = [ 722 | { 723 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 724 | 'DIRS': [os.path.join(BASE_DIR, 'templates')], 725 | 'APP_DIRS': True, 726 | 'OPTIONS': { 727 | 'context_processors': [ 728 | 'django.template.context_processors.debug', 729 | 'django.template.context_processors.request', 730 | 'django.contrib.auth.context_processors.auth', 731 | 'django.contrib.messages.context_processors.messages', 732 | ], 733 | }, 734 | }, 735 | ] 736 | 737 | WSGI_APPLICATION = 'telusko.wsgi.application' 738 | 739 | 740 | # Database 741 | # https://docs.djangoproject.com/en/2.2/ref/settings/#databases 742 | 743 | DATABASES = { 744 | 'default': { 745 | 'ENGINE': 'django.db.backends.postgresql', 746 | 'NAME': 'telusko', 747 | 'USER': 'postgres', 748 | 'PASSWORD': '1234', 749 | 'HOST': 'localhost' 750 | } 751 | } 752 | 753 | 754 | # Password validation 755 | # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators 756 | 757 | AUTH_PASSWORD_VALIDATORS = [ 758 | { 759 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 760 | }, 761 | { 762 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 763 | }, 764 | { 765 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 766 | }, 767 | { 768 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 769 | }, 770 | ] 771 | 772 | 773 | # Internationalization 774 | # https://docs.djangoproject.com/en/2.2/topics/i18n/ 775 | 776 | LANGUAGE_CODE = 'en-us' 777 | 778 | TIME_ZONE = 'UTC' 779 | 780 | USE_I18N = True 781 | 782 | USE_L10N = True 783 | 784 | USE_TZ = True 785 | 786 | 787 | # Static files (CSS, JavaScript, Images) 788 | # https://docs.djangoproject.com/en/2.2/howto/static-files/ 789 | 790 | STATIC_URL = '/static/' 791 | STATICFILES_DIRS = [ 792 | os.path.join(BASE_DIR, 'static') 793 | ] 794 | STATIC_ROOT = os.path.join(BASE_DIR, 'assets') 795 | 796 | 797 | 798 | -------------------------------------------------------------------------------- Migration Steps 799 | -------------------------------------------------------------------------------- 800 | 801 | >pip install psycopg2 802 | >pip install Pillow 803 | >python manage.py makemigrations 804 | >python manage.py sqlmigrate travello 0001 805 | >python manage.py migrate 806 | --------------------------------------------------------------------------------