├── .gitattributes ├── .github └── FUNDING.yml ├── .idea ├── .gitignore ├── .name ├── csv-plugin.xml ├── inspectionProfiles │ └── profiles_settings.xml ├── misc.xml ├── modules.xml ├── pythoncodecamp.iml └── vcs.xml ├── LICENSE ├── OOPs ├── Currency.py ├── Digit.py ├── Employee.py ├── ErrorHandling.py ├── ExceptionHandling.py ├── Form.py ├── MultiLevelInheritence.py ├── OperatorOverloadingCurrency.py ├── OperatorOverloadingTable.py ├── Person (2).py ├── Person.py ├── Person1.py ├── Shapes.py ├── SuperEmployee.py ├── __pycache__ │ ├── Person.cpython-310.pyc │ ├── Person.cpython-36 (2).pyc │ ├── Person.cpython-36.pyc │ ├── Person.cpython-37.pyc │ ├── Person1.cpython-37.pyc │ ├── book.cpython-310.pyc │ └── book.cpython-36.pyc ├── bankapplication │ ├── Currency.py │ ├── Person.py │ ├── __init__.py │ ├── __pycache__ │ │ ├── Currency.cpython-310.pyc │ │ ├── Currency.cpython-313.pyc │ │ ├── Person.cpython-310.pyc │ │ └── Person.cpython-313.pyc │ └── bank.py ├── book.py ├── generatortable.py ├── inheritance.py ├── minheritance.py ├── oops examples │ ├── ADT Stack.py │ ├── Linked List Stack.py │ ├── MultipleInheritance.py │ ├── SimpleInheritance.py │ ├── Static and Instance.py │ ├── constructor and destructor with data.py │ ├── constructor and destructor.py │ └── json to object and back.py ├── oops.py ├── oopsinpython.py ├── personemployeemanager.py ├── polymorphism.py ├── rectangle.py ├── scratch (2).py ├── scratch.py ├── scratch2.py └── superuse.py ├── README.md ├── __pycache__ └── imagelibrary.cpython-36.pyc ├── index.html ├── mailerwindow.spec ├── numpyuse ├── chat gpt use.py ├── emiequation.py ├── numpy 1.py ├── numpyarray.py ├── solving practice.py └── start numpy.py ├── pandasuse ├── data.csv ├── newdata.csv ├── pandasexcel.py ├── vns.csv └── weather.py ├── pattern ├── M-Pattern.py ├── Tower.py ├── arrow.py ├── basepatternsquare.py ├── fulldiamond.py ├── leadingdiagonal.py ├── leftlowertriangle.py ├── leftuppertriangle.py ├── lowertriangle.py ├── nonleadingdiagonal.py ├── outlinediamond.py ├── outlinesquare.py ├── patterns to make │ ├── 0.JPG │ ├── 1.JPG │ ├── 2.JPG │ ├── 3.JPG │ ├── 4.JPG │ ├── 5.JPG │ ├── 6.JPG │ ├── 7.JPG │ ├── 8.JPG │ └── 9.JPG ├── patterns │ ├── Full Diamond.py │ ├── Half Diamond.py │ ├── Hour Glass.py │ ├── Pascal Diamond.py │ ├── Pascal Hour Glass.py │ ├── Shifted Triangle.py │ ├── Simple Triangle.py │ ├── X.PNG │ ├── arrow.PNG │ ├── figures.PNG │ ├── fulldiagonal.PNG │ ├── leadingdiagonal.PNG │ ├── leftlowertriangle.PNG │ ├── leftuppertriaangle.PNG │ ├── lowertriangle.PNG │ ├── nonleadingdiagoonal.PNG │ ├── outlinediagonal.PNG │ ├── outlinesqure.PNG │ ├── rightlowertriangle.PNG │ ├── rightuppertraingle.PNG │ ├── square.PNG │ └── uppertriangle.PNG ├── rightlowertriangle.py ├── rightuppertriangle.py ├── uppertriangle.py └── x.py ├── pics └── champak │ └── me.jpg ├── printdemo.py ├── regressionproject ├── __init__.py ├── fullregression - Copy.py0 ├── myfullregression.py └── test.py └── swap.py /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [Varanasi-Software-Junction] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | MailThread.py -------------------------------------------------------------------------------- /.idea/csv-plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 29 | 30 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/pythoncodecamp.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 champaksworld 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /OOPs/Currency.py: -------------------------------------------------------------------------------- 1 | """ 2 | Starting a class that will be a complete example of Python OOPs 3 | We will implement operator overloading as well. 4 | 5 | The Currency class takes rupees and paise as input. Converts 6 | paise >=100 into rupees and proceeds 7 | 8 | """ 9 | ''' 10 | Operators that can be overloaded 11 | 12 | Operator. Required Method 13 | + __add__(self, other) 14 | – __sub__(self, other) 15 | * __mul__(self, other) 16 | / __truediv__(self, other) 17 | // __floordiv__(self, other) 18 | % __mod__(self, other) 19 | ** __pow__(self, other) 20 | >> __rshift__(self, other) 21 | << __lshift__(self, other) 22 | & __and__(self, other) 23 | | __or__(self, other) 24 | ^ __xor__(self, other) 25 | Comparison Operators : 26 | Operator Methods 27 | < __lt__(self, other) 28 | > __gt__(self, other) 29 | <= __le__(self, other) 30 | >= __ge__(self, other) 31 | == __eq__(self, other) 32 | != __ne__(self, other) 33 | Assignment Operators : 34 | Operator Method to be overloaded 35 | -= __isub__(self, other) 36 | += __iadd__(self, other) 37 | *= __imul__(self, other) 38 | /= __idiv__(self, other) 39 | //= __ifloordiv__(self, other) 40 | %= __imod__(self, other) 41 | **= __ipow__(self, other) 42 | >>= __irshift__(self, other) 43 | <<= __ilshift__(self, other) 44 | &= __iand__(self, other) 45 | |= __ior__(self, other) 46 | ^= __ixor__(self, other) 47 | Unary Operators : 48 | Operator Method to be overloaded 49 | – __neg__(self) 50 | + __pos__(self) 51 | ~ __invert__(self) 52 | Note: It is not possible to change the number of operands of an operator. For ex. you cannot overload a unary operator as a binary operator. The following code will throw a syntax error. 53 | 54 | 55 | 56 | 57 | ''' 58 | 59 | 60 | class Currency: # Starting a class declaration 61 | def __next__(self): # Returs rupees the first time and paise the nextchar time 62 | n = self.counter 63 | self.counter += 1 64 | if self.counter > 2: 65 | raise StopIteration 66 | 67 | if n == 0: 68 | return self.pad0(self.total // 100) 69 | return self.pad0(self.total % 100) 70 | 71 | def __iter__(self): 72 | self.counter = 0 73 | return self 74 | 75 | def pad0(self, n): # Add leading 0 to numbers less than 10 76 | if n < 10: 77 | return "0{0}".format(n) 78 | return "{0}".format(n) 79 | 80 | def __init__(self, rs, paise): # Constructor. Converts rs and paise to a total in paise and stores 81 | self.total = rs * 100 + paise 82 | 83 | def __str__(self): # str function converts total to rupee and paise 84 | r = self.total // 100 85 | p = self.total % 100 86 | r = self.pad0(r) 87 | p = self.pad0(p) 88 | return "₹ {0}.{1}".format(r, p) 89 | 90 | def __add__(self, other): # Implements the + operator 91 | return Currency(0, self.total + other.total) 92 | 93 | def __gt__(self, other): # Implements the > operator 94 | return self.total > other.total 95 | 96 | def __le__(self, other): 97 | return self.total <= other.total 98 | 99 | def __getitem__(self, item): 100 | if item == 0: 101 | return self.pad0(self.total // 100) 102 | if item == 1: 103 | return self.pad0(self.total % 100) 104 | raise IndexError("list index out of range") 105 | 106 | def __len__(self): # This is for a loop through sequence.We have two items rupees and paise 107 | return 2 108 | 109 | 110 | c1 = Currency(1, 12) 111 | print("C1 ", c1) 112 | for i in c1: 113 | print(i) 114 | c2 = Currency(2, -90) 115 | print("C2 ", c2) 116 | print("0", c2[0]) 117 | print("1", c2[1]) 118 | print(c1 <= c2) 119 | -------------------------------------------------------------------------------- /OOPs/Digit.py: -------------------------------------------------------------------------------- 1 | class Digit: 2 | def __init__(self,n): 3 | self.n = n 4 | 5 | 6 | self.count =0 7 | i=self.n 8 | while i!=0: 9 | i=i//10 10 | self.count +=1 11 | 12 | def __iter__(self): 13 | self.i = self.n 14 | self.icount =self.count 15 | return self 16 | def __next__(self): 17 | 18 | if self.i == 0: 19 | raise StopIteration 20 | res = self.i // (10**(self.icount-1)) 21 | self.i = self.i%(10**(self.icount-1)) 22 | self.icount -=1 23 | return res 24 | 25 | d=Digit(56474) 26 | for i in d: 27 | print(i) -------------------------------------------------------------------------------- /OOPs/Employee.py: -------------------------------------------------------------------------------- 1 | import Person as pp 2 | 3 | 4 | class Employee(pp.Person): 5 | def __init__(self, name, age, address, salary, post): 6 | super().__init__(self, name, age, address) 7 | self.salary = salary 8 | self.post = post 9 | # pp.Person.__init__(self,name,age,address) 10 | 11 | def __str__(self): 12 | return "{0}, Salary={1}, Post={2}".format(pp.Person, self.salary,self.post) 13 | 14 | 15 | e = Employee("pappu", 56, "Delhi", 1000, "VP") 16 | print(e) 17 | -------------------------------------------------------------------------------- /OOPs/ErrorHandling.py: -------------------------------------------------------------------------------- 1 | class AgeException(Exception): 2 | def __init__(self, message): 3 | Exception.__init__(self,message) 4 | 5 | try: # Write the code whose exceptions need handling 6 | d={1:"One"} 7 | print(d[1]) 8 | x=int("1") 9 | age=int(input("Age\n")) 10 | if age < 0: 11 | raise AgeException("Age is -ve")#Throw your own exception 12 | 13 | except KeyError as error_message:#Handle the key errors 14 | print("Key Error " + str(error_message)) 15 | except ValueError as v: 16 | print("Value Error " + str(v)) 17 | except ZeroDivisionError as manas: 18 | print(manas) 19 | except Exception as e:#All Remaining Exceptions 20 | print(e) 21 | else:#If no exception occured 22 | print("All correct") 23 | finally:#Runs everytime in the end 24 | print("Bye ") -------------------------------------------------------------------------------- /OOPs/ExceptionHandling.py: -------------------------------------------------------------------------------- 1 | class AgeError(Exception): 2 | def __init__(self, message): 3 | Exception.__init__(self, message) 4 | 5 | 6 | try: # Write the code whose exceptions need handling 7 | d = {1: "One"} 8 | print(d[1]) 9 | age = int(input("Enter Age: ")) 10 | if age < 0: 11 | raise AgeError('Age is Negative') # Throw your own exception 12 | f = 100 / 2 13 | 14 | except KeyError as e: # Handling Key Errors 15 | print("Key Error " + str(e)) 16 | except ValueError as v: # Handling Value Errors 17 | print('Value Error ' + str(v)) 18 | except AgeError as f: # Handling All remaining Excetions 19 | print("Age Error " + str(f)) 20 | except Exception as f: # Handling All remaining Excetions 21 | print("Unknown Error " + str(f)) 22 | else: # If no Exception occured 23 | print("No Exception Occurred") 24 | 25 | finally: # Runs Everytime in the end 26 | print("Bye") 27 | -------------------------------------------------------------------------------- /OOPs/Form.py: -------------------------------------------------------------------------------- 1 | class ageError(Exception):#Creating a new exception class 2 | def __init__(self,message): 3 | Exception.__init__(self,message) 4 | class nameError(Exception): 5 | def __init(self,message): 6 | Exception.__init__(self,message) 7 | class marksError(Exception): 8 | def __init__(self,message): 9 | Exception.__init__(self,message) 10 | 11 | try: 12 | 13 | name = input('Enter Full Name :') 14 | if len(name)<4: 15 | raise nameError('Name is too short') 16 | 17 | for i in name: 18 | if (ord(i) not in range(65,91)) and (ord(i) not in range(97,123) and ord(i) != 32): 19 | raise nameError('Name should not contain number or special character') 20 | 21 | age = int(input('Enter your age :')) 22 | if age < 0 or age >=60: 23 | raise ageError("Age is -ve or your age is greater than 60") 24 | 25 | pmarks = int(input('Enter your Physics Marks :')) 26 | if pmarks < 0 or pmarks > 100: 27 | raise marksError("Marks is not in between 0 and 100") 28 | cmarks = int(input('Enter your Chemsitry Marks :')) 29 | if cmarks < 0 or cmarks > 100: 30 | raise marksError("Marks is not in between 0 and 100") 31 | except Exception as e: 32 | print("!!!!!!Registration Failed!!!!!!") 33 | print("Error : "+str(e)) 34 | else: 35 | print("--:Registered Sucessfully:--") 36 | finally: 37 | print("Bye Bye") 38 | 39 | -------------------------------------------------------------------------------- /OOPs/MultiLevelInheritence.py: -------------------------------------------------------------------------------- 1 | class A: 2 | def f1(self): 3 | print('f1 in A') 4 | 5 | class B(A): 6 | def f1(self): 7 | print('f1 in B') 8 | 9 | def f1a(self): 10 | A().f1() 11 | class C(B): 12 | def f1(self): 13 | print('f1 in c') 14 | def f1b(self): 15 | B().f1() 16 | o = C() 17 | o.f1() 18 | o.f1a() 19 | o.f1b() -------------------------------------------------------------------------------- /OOPs/OperatorOverloadingCurrency.py: -------------------------------------------------------------------------------- 1 | class Currency: 2 | def manage(self,n): 3 | if n//10 ==0: 4 | return "0{0}".format(n) 5 | return "{0}".format(n) 6 | def __add__(self,other): 7 | return Currency(0,self.total + other.total) 8 | def __sub__(self,other): 9 | return Currency(0,self.total - other.total) 10 | def __mul__(self,a): 11 | return Currency(0,a*self.total) 12 | def __eq__(self, other): 13 | return self.total == other.total 14 | def __gt__(self,other): 15 | return self.total > other.total 16 | def __lt__(self,other): 17 | return self.total < other.total 18 | def __ge__(self,other): 19 | return not self < other 20 | 21 | def __init__(self, rupee , paise): 22 | self.total= rupee*100+paise 23 | 24 | 25 | def __str__(self): 26 | r = (self.total)//100 27 | p = (self.total)%100 28 | r = self.manage(r) 29 | p = self.manage(p) 30 | return "₹{0}.{1}".format(r,p) 31 | 32 | m = Currency(10,50) 33 | n=4 34 | m1 = Currency(11,50) 35 | print(m) 36 | print(m1) 37 | sum = m + m1 38 | 39 | print(sum) 40 | sub= m-m1 41 | print(sub) 42 | if m1>=m: 43 | print('yes') 44 | else: 45 | print('No') 46 | total = m*4 47 | print(total) 48 | -------------------------------------------------------------------------------- /OOPs/OperatorOverloadingTable.py: -------------------------------------------------------------------------------- 1 | class Table: 2 | def __init__(self, a ): 3 | self.n = a 4 | def __iter__(self): # Operator 5 | self.i = 0 #OVerloading 6 | return self #for 7 | def __next__(self): #Iteration 8 | self.i += 1 # 9 | if self.i > 10: # 10 | raise StopIteration 11 | value = self.n * self.i 12 | return value 13 | 14 | def __getitem__(self, i): 15 | return i * self.n 16 | 17 | t1 = Table(4) 18 | for i in t1: 19 | print(i) 20 | 21 | print(t1[1]) 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /OOPs/Person (2).py: -------------------------------------------------------------------------------- 1 | class Person: 2 | def __init__(self,name,age,address): 3 | self.name=name 4 | self.address=address 5 | self.age=age 6 | def __str__(self): 7 | return "Name={0}, Age = {1}, Address={2}".format(self.name,self.age,self.address) 8 | 9 | p=Person("Pappu",50,"Delhi") 10 | print(p) 11 | -------------------------------------------------------------------------------- /OOPs/Person.py: -------------------------------------------------------------------------------- 1 | import book as book 2 | 3 | ''' 4 | Using a class in another class. We have imported the Book class 5 | ''' 6 | 7 | 8 | class Person: 9 | def __init__(self, name, age, address, mybook): 10 | self.name = name 11 | self.address = address 12 | self.age = age 13 | self.book = mybook 14 | 15 | def __str__(self): 16 | return "Name={0}, Age = {1}, Address={2}, Book=({3})".format(self.name, self.age, self.address, self.book) 17 | 18 | 19 | b1 = book.Book("Basic C", 100, "C") 20 | p = Person("Raju", 50, "Delhi", b1) 21 | # print(p) 22 | -------------------------------------------------------------------------------- /OOPs/Person1.py: -------------------------------------------------------------------------------- 1 | class Person: 2 | def __init__(self,name,age,address): 3 | self.name = name 4 | self.address = address 5 | self.age = age 6 | def __str__(self): 7 | return "Name = {0} , Age = {1}, Address = {2}".format(self.name,self.age,self.address ) 8 | p1 = Person('Manjit',21, "UP") 9 | -------------------------------------------------------------------------------- /OOPs/Shapes.py: -------------------------------------------------------------------------------- 1 | class Rectangle: 2 | def __init__(self, l,b): # constructor 3 | self.b = b 4 | self.l = l 5 | def __str__(self): # called whenever object is printed 6 | return "Rectangle having length = {0} and breadth = {1}".format(self.l,self.b) 7 | def perimeter(self): 8 | return 2*(self.l+self.b) 9 | def area(self): 10 | return self.l*self.b 11 | 12 | 13 | r1 = Rectangle(4,5) 14 | print(r1) 15 | print("Area of rectanle =",r1.area()) 16 | print("Perimeter of rectangle = ", r1.perimeter()) -------------------------------------------------------------------------------- /OOPs/SuperEmployee.py: -------------------------------------------------------------------------------- 1 | import Person as pp 2 | class Employee(pp.Person): 3 | def __init__(self, name,age,address,salary,post): 4 | super().__init__(name,age,address) 5 | self.salary=salary 6 | self.post=post 7 | def __str__(self): 8 | return "{0}, Salary={1}, Post={2}".format(pp.Person,self.salary,self.post) 9 | e=Employee("pappu",56,"Delhi",1000,"VP") 10 | print(e) -------------------------------------------------------------------------------- /OOPs/__pycache__/Person.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/OOPs/__pycache__/Person.cpython-310.pyc -------------------------------------------------------------------------------- /OOPs/__pycache__/Person.cpython-36 (2).pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/OOPs/__pycache__/Person.cpython-36 (2).pyc -------------------------------------------------------------------------------- /OOPs/__pycache__/Person.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/OOPs/__pycache__/Person.cpython-36.pyc -------------------------------------------------------------------------------- /OOPs/__pycache__/Person.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/OOPs/__pycache__/Person.cpython-37.pyc -------------------------------------------------------------------------------- /OOPs/__pycache__/Person1.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/OOPs/__pycache__/Person1.cpython-37.pyc -------------------------------------------------------------------------------- /OOPs/__pycache__/book.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/OOPs/__pycache__/book.cpython-310.pyc -------------------------------------------------------------------------------- /OOPs/__pycache__/book.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/OOPs/__pycache__/book.cpython-36.pyc -------------------------------------------------------------------------------- /OOPs/bankapplication/Currency.py: -------------------------------------------------------------------------------- 1 | class Currency: 2 | def __init__(self, rs, p): 3 | self.total = 100* rs + p 4 | 5 | def __str__(self): 6 | 7 | return "{}".format(self.total) 8 | -------------------------------------------------------------------------------- /OOPs/bankapplication/Person.py: -------------------------------------------------------------------------------- 1 | class Person: 2 | def __init__(self, name=None, age=None, address=None): 3 | if name is not None: 4 | self.name = name 5 | else: 6 | self.name = input("Enter name\n") 7 | if address is not None: 8 | self.address = address 9 | else: 10 | self.address = input("Enter address\n") 11 | if age is not None: 12 | self.age = age 13 | else: 14 | self.age = int(input("Enter age\n")) 15 | 16 | def __str__(self) -> str: 17 | return "Name={0}, Age={1}, Address={2}".format(self.name, self.age, self.address) 18 | 19 | 20 | -------------------------------------------------------------------------------- /OOPs/bankapplication/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/OOPs/bankapplication/__init__.py -------------------------------------------------------------------------------- /OOPs/bankapplication/__pycache__/Currency.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/OOPs/bankapplication/__pycache__/Currency.cpython-310.pyc -------------------------------------------------------------------------------- /OOPs/bankapplication/__pycache__/Currency.cpython-313.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/OOPs/bankapplication/__pycache__/Currency.cpython-313.pyc -------------------------------------------------------------------------------- /OOPs/bankapplication/__pycache__/Person.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/OOPs/bankapplication/__pycache__/Person.cpython-310.pyc -------------------------------------------------------------------------------- /OOPs/bankapplication/__pycache__/Person.cpython-313.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/OOPs/bankapplication/__pycache__/Person.cpython-313.pyc -------------------------------------------------------------------------------- /OOPs/bankapplication/bank.py: -------------------------------------------------------------------------------- 1 | import Person as pp 2 | import Currency as cr 3 | 4 | # p = pp.Person(address="Popat") 5 | c = cr.Currency(100,5) 6 | # print(p) 7 | print(c) 8 | -------------------------------------------------------------------------------- /OOPs/book.py: -------------------------------------------------------------------------------- 1 | """ 2 | Starting OOPs in Python. 3 | The topics we will cover are. 4 | 1. Making Classes 5 | 2. Methods inside classes 6 | 3. Using classes inside classes 7 | 4. Inheritance 8 | 5. Multiple inheritance 9 | 6. Operator overloading 10 | 11 | """ 12 | 13 | 14 | class Book: # Definiton of class begins 15 | 16 | def __init__(self, bookName, price, subject): # Constructor 17 | # self is the equivalent of this in Java and CPP. We can use any name for self. 18 | # def __init__(xyz, bookName, price, subject): is also valid 19 | self.bookName = bookName # Copy bookName parameter to the class variable 20 | self.price = price 21 | self.subject = subject 22 | 23 | def __str__(self): # toString. WIll be used if class object is printed 24 | return "Bookname = {0}, Price = {1}, Subject = {2}".format(self.bookName, self.price, self.subject) 25 | 26 | 27 | b1 = Book("Basic C", 100, "Cb") 28 | b2 = Book("Adv C", 100, "C") 29 | # print(b1) 30 | # print(b2) 31 | # print("Book = {0}".format(b1)) 32 | -------------------------------------------------------------------------------- /OOPs/generatortable.py: -------------------------------------------------------------------------------- 1 | def table(n): 2 | i = 1 3 | while i <= 10: 4 | yield i * n 5 | i += 1 6 | 7 | 8 | tbl = table(5) 9 | for x in tbl: 10 | print(x) 11 | -------------------------------------------------------------------------------- /OOPs/inheritance.py: -------------------------------------------------------------------------------- 1 | class A: # Original class to be inherited 2 | def f1(self): 3 | print("F1 in A") 4 | 5 | 6 | class B: 7 | def f2(self): 8 | print("F2 in B") 9 | 10 | def f1(self): 11 | print("F1 in B") 12 | 13 | 14 | class C(A, B): 15 | def f(self): 16 | A().f1() 17 | B().f1() 18 | 19 | 20 | c = C() 21 | c.f1() 22 | c.f2() 23 | c.f() 24 | -------------------------------------------------------------------------------- /OOPs/minheritance.py: -------------------------------------------------------------------------------- 1 | class FirstClass(object): 2 | def __init__(self): 3 | super(FirstClass, self).__init__() 4 | print("First Class Constructor") 5 | 6 | 7 | class SecondClass(object): 8 | def __init__(self): 9 | super(SecondClass, self).__init__() 10 | print("Second Class") 11 | 12 | 13 | class ThirdClass(FirstClass, SecondClass): 14 | def __init__(self): 15 | super(ThirdClass, self).__init__() 16 | print("Third Class") 17 | 18 | 19 | obj = ThirdClass() 20 | print(obj) 21 | -------------------------------------------------------------------------------- /OOPs/oops examples/ADT Stack.py: -------------------------------------------------------------------------------- 1 | class Stack: 2 | def __init__(self): 3 | self.data = [] 4 | 5 | def push(self, value): 6 | self.data.append(value) 7 | 8 | def pop(self): 9 | if self.data: 10 | return self.data.pop() 11 | return None 12 | 13 | def empty(self): 14 | return not self.data 15 | 16 | 17 | st = Stack() 18 | for i in range(5): 19 | st.push(i) 20 | while not st.empty(): 21 | print(st.pop()) 22 | -------------------------------------------------------------------------------- /OOPs/oops examples/Linked List Stack.py: -------------------------------------------------------------------------------- 1 | class Node: 2 | def __init__(self, data=None): 3 | self.next = None 4 | self.data = data 5 | 6 | 7 | class Stack: 8 | def __init__(self): 9 | self.head = None 10 | 11 | def push(self, value): 12 | newnode = Node(value) 13 | newnode.next = self.head 14 | self.head = newnode 15 | 16 | def pop(self): 17 | if not self.head: 18 | return None 19 | value = self.head.data 20 | next = self.head.next 21 | del self.head 22 | self.head = next 23 | return value 24 | 25 | def empty(self): 26 | return not self.head 27 | 28 | 29 | st = Stack() 30 | for i in range(5): 31 | st.push(i) 32 | while not st.empty(): 33 | print(st.pop()) 34 | -------------------------------------------------------------------------------- /OOPs/oops examples/MultipleInheritance.py: -------------------------------------------------------------------------------- 1 | class A: 2 | def f1(self): 3 | print("f1 in A") 4 | 5 | 6 | class B: 7 | def f1(self): 8 | print("f1 in B") 9 | 10 | 11 | class C(A, B): 12 | pass 13 | 14 | 15 | c = C() 16 | c.f1() 17 | print(C.mro()) 18 | -------------------------------------------------------------------------------- /OOPs/oops examples/SimpleInheritance.py: -------------------------------------------------------------------------------- 1 | class A: 2 | def f1(self): 3 | print("F1 in A") 4 | 5 | def f2(self): 6 | print("F2 in A") 7 | 8 | 9 | class B(A): 10 | def f1(self): 11 | print("F1 in B") 12 | super().f1() 13 | 14 | 15 | b = B() 16 | b.f1() 17 | b.f2() 18 | -------------------------------------------------------------------------------- /OOPs/oops examples/Static and Instance.py: -------------------------------------------------------------------------------- 1 | class StaticAndInstanceDemo: 2 | 3 | @staticmethod 4 | def IamStaticMethod(): 5 | print("Static Method") 6 | 7 | def IamInstanceMethod(self): 8 | print("Instance Method") 9 | self.IamInstanceVariable = "Instance Variable" 10 | 11 | IamStaticVariable = "Static Value" 12 | 13 | 14 | StaticAndInstanceDemo.IamStaticMethod() 15 | print(StaticAndInstanceDemo.IamStaticVariable) 16 | a = StaticAndInstanceDemo() 17 | a.IamInstanceMethod() 18 | print(a.IamInstanceVariable) 19 | -------------------------------------------------------------------------------- /OOPs/oops examples/constructor and destructor with data.py: -------------------------------------------------------------------------------- 1 | # Constructor and Destructor 2 | class A: 3 | def __init__(self, data=None): 4 | self.data = data 5 | print("Constructor Called " + data) 6 | 7 | def __del__(self): 8 | print("Destructor Called " + self.data) 9 | 10 | 11 | a = A("One") 12 | b = A("Two") 13 | -------------------------------------------------------------------------------- /OOPs/oops examples/constructor and destructor.py: -------------------------------------------------------------------------------- 1 | # Constructor and Destructor 2 | class A: 3 | def __init__(self): 4 | print("Constructor Called") 5 | 6 | def __del__(self): 7 | print("Destructor Called") 8 | 9 | 10 | a = A() 11 | -------------------------------------------------------------------------------- /OOPs/oops examples/json to object and back.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | 4 | class Book: 5 | def __init__(self, bookname, subject, price): 6 | self.bookname = bookname 7 | self.subject = subject 8 | self.price = price 9 | 10 | def __str__(self): 11 | return 'Book Name={0},Subject={1}, Price={2}'.format(self.bookname, self.subject, self.price) 12 | 13 | 14 | b = Book("The Recursion Sutras", "Recursion", 299) 15 | print(b) 16 | jsonbookdata = json.dumps(b.__dict__) 17 | print(jsonbookdata) 18 | 19 | data = '{"bookname": "The Recursion Sutras", "subject": "Recursion","price":299}' 20 | 21 | jsonbook = json.loads(data, object_hook=lambda d: Book(**d)) 22 | print(jsonbook) 23 | jsonbook = json.loads(jsonbookdata, object_hook=lambda d: Book(**d)) 24 | print(jsonbook) 25 | -------------------------------------------------------------------------------- /OOPs/oops.py: -------------------------------------------------------------------------------- 1 | class A: 2 | def f(self): 3 | print("F in A") 4 | class B: 5 | def f(self): 6 | print("F in B") 7 | class C(B,A): 8 | pass 9 | 10 | c = C() 11 | c.f() 12 | -------------------------------------------------------------------------------- /OOPs/oopsinpython.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | """ 6 | Computer Programming started with what is called Procedural Programming 7 | Characteristics of Procedural Programming 8 | 1. A set of global variables that were accessible throughout the program. 9 | 2. different functions to do specific tasks. Functions could have their parameters and 10 | local variables. 11 | It was difficult to make programs that were complex and that went up to around 1000 lines 12 | Imagine a situation where a laptop is not divided into components like 13 | hard disk, mouse pad, screen etc but is simple circuit 14 | The problems 15 | 1. Too complex logic 16 | 2. Finding faults was difficult, isolating faults was difficult 17 | 3. No part evolution or replacement. If the screen goes bad you replace it. No part enhancement. 18 | You need higher capacity hard disk then simply replace the part 19 | 20 | Computer programmers decided that component based systems must come into software development. 21 | This is called Object Oriented Programming or OOPS 22 | 23 | Basic terminology 24 | Imagine a situation where your company decides to make a car. 25 | What are the steps that you follow? 26 | 1. Decide upon the final car. The design and facilities 27 | 2. Break the car into parts and decide their functionality. Things like wheels, horns, 28 | steering, brakes etc 29 | 3. Break the parts into smaller-simpler parts and carry on till you come to situation 30 | where things can be implemented 31 | 4. Make the parts and combine. 32 | This is top down design. We started with the final car and broke it into parts. 33 | 34 | For the nextchar car we will already have a stock of parts. We will try and use this to the 35 | maximum. Bottom-up design 36 | 37 | Terms 38 | Class - the design of an object. In the case of a Car a list of parts with functions 39 | Generally called blueprint 40 | Object- Instance of a class. The actual produced car. Once a class is made we can create 41 | unlimited objects. 42 | Encapsulation-- Putting multiple objects inside a new object and leaving only the interfaces out 43 | is called encapsulation. 44 | 45 | Interface -- Points where process communicate. Eg keyboard, mouse, screen in a laptop. 46 | steering, horn etc in a car 47 | 48 | Abstraction -- Abstraction is learning how to use an object without knowing its implementation 49 | details. The driver shouldn't need to learn how a car is made to actually drive. 50 | Implementation details must be hidden. This also promotes Device Independence. 51 | 52 | Polymorphism --- The same command meaning different things based on the context, the number 53 | of inputs and the types of inputs. For example if you are holding a bat and someone says hit 54 | hard you understand he is talking about hitting the ball. If you are holding a badminton racket it 55 | means something else 56 | The + command used with strings concatenates but used with numbers it adds numerically. 57 | "1" = "2" = "12" while 1 + 2 = 3 58 | 59 | Inheritance-- Developing a new version of a product maintaining backward compatibility. 60 | 61 | Class variables --- variables accessible throughout the object 62 | Constructor --- Adding the parts to the body. In Python its the __init__ function 63 | toString --- Gives a string output of the current object. 64 | 65 | 66 | 67 | 68 | """ 69 | 70 | 71 | class Car: # Starting the Car class 72 | def __init__(self, carmodel, carprice, carcompany): # Constructor. Self is a reference to the current object 73 | self.carmodel = carmodel # Transferring to the current object 74 | self.carprice = carprice 75 | self.carcompany = carcompany 76 | 77 | def __str__(self): # String representation of the class 78 | return "Model={0}, Company = {1}, Price = {2}".format(self.carmodel, self.carcompany, self.carprice) 79 | 80 | 81 | c1 = Car("800", 100000, "Maruti") 82 | print(c1) 83 | c2 = Car("Esteem", 1000000, "Maruti") 84 | print(c2) 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /OOPs/personemployeemanager.py: -------------------------------------------------------------------------------- 1 | """ 2 | Imagine the following scenario. 3 | 4 | 1. You developed a class called Person with the following data to be used in 5 | an address book application. We store name, address and mobile numbers in the Person class 6 | 7 | 2. The nextchar project we are asked to manage Employee details so we plan an Employee class 8 | The Employee class needs to store name, address, mobileno, post and salary. 9 | 10 | The first 3 members are common to both classes. More importantly every Employee is a Person. 11 | 12 | This is the exact situation in which inheritance is done. 13 | 14 | 15 | 16 | 17 | 18 | """ 19 | 20 | 21 | class Person: 22 | def __init__(self, name, address, mobile): 23 | self.name = name 24 | self.address = address 25 | self.mobile = mobile 26 | 27 | def __str__(self): 28 | return "Name={0}, Address={1}, Mobile={2}".format(self.name, self.address, self.mobile) 29 | 30 | 31 | class Employee(Person): # Extended from Person 32 | def __init__(self, name, address, mobile, post, salary): # Constructor 33 | super(Employee, self).__init__(name, address, mobile) # Super class constructor 34 | self.post = post 35 | self.salary = salary 36 | 37 | def __str__(self): 38 | return "{0}, Post = {1}, Salary={2}".format(super().__str__(), self.post, self.salary) 39 | 40 | 41 | p = Person("Sachin", "Mumbai", "9987887654") 42 | print(p) 43 | e = Employee("Sachin", "Mumbai", "9876543212", 'Batsman', 1000) 44 | print(e) 45 | -------------------------------------------------------------------------------- /OOPs/polymorphism.py: -------------------------------------------------------------------------------- 1 | class A: 2 | def f(self): 3 | print("F in A") 4 | class B(A): 5 | def f(self): 6 | print( "F in B") 7 | A.f(self) 8 | super().f() 9 | def add(a=0,b=0): 10 | print("A=",a,", B = ",b) 11 | return a + b 12 | print(add(1,2)) 13 | print(add(2)) 14 | print(add()) 15 | print(add(b=9,a=8)) 16 | print(add(b=9)) 17 | a=A() 18 | a.f() 19 | a=B() 20 | a.f() -------------------------------------------------------------------------------- /OOPs/rectangle.py: -------------------------------------------------------------------------------- 1 | class Rectangle: 2 | def __init__(self,length,breadth): 3 | self.length=length 4 | self.breadth=breadth 5 | def perimeter(self): 6 | return 2* self.length + 2* self.breadth 7 | def area(self): 8 | return self.length * self.breadth 9 | def __str__(self): 10 | return "Length = {0}, Breadth={1}, area = {2}".format(self.length,self.breadth,self.area()) 11 | class Square(Rectangle): 12 | def __init__(self,side): 13 | Rectangle.__init__(self,side,side) 14 | 15 | r1=Rectangle(4,3) 16 | print(r1.area()) 17 | print(r1) 18 | s1=Square(2) 19 | print(s1) 20 | print(s1.perimeter()) -------------------------------------------------------------------------------- /OOPs/scratch (2).py: -------------------------------------------------------------------------------- 1 | class NumberIter: 2 | def __init__(self,n): 3 | self.n=n 4 | self.i=0 5 | l=[] 6 | while n>0: 7 | rem=n % 10 8 | n=n//10 9 | l= [rem] + l 10 | self.l=l 11 | def __iter__(self): 12 | self.i=0 13 | return self 14 | def __next__(self): 15 | if self.i>=len(self.l): 16 | raise StopIteration 17 | self.i+=1 18 | return self.l[self.i-1] 19 | 20 | 21 | c=NumberIter(123) 22 | for x in c: 23 | print(x) 24 | for x in c: 25 | print(x) 26 | -------------------------------------------------------------------------------- /OOPs/scratch.py: -------------------------------------------------------------------------------- 1 | class A: 2 | def f(self): 3 | print("F in A") 4 | 5 | 6 | def addAll(*args): 7 | sum = 0 8 | type(args) 9 | for arg in args: 10 | sum += arg 11 | print(sum) 12 | 13 | 14 | def f(*args): 15 | print(type(args)) 16 | for arg in args: 17 | print(arg) 18 | 19 | 20 | def ff(**kargs): 21 | print(type(kargs)) 22 | for key, value in kargs.items(): 23 | print(key, value) 24 | 25 | 26 | f(1, 2, 3, 4) 27 | ff(name="pappu", age="10") 28 | 29 | 30 | def f1(): 31 | print("F1") 32 | 33 | 34 | def f2(): 35 | print("F2") 36 | 37 | 38 | def sub(a, b): 39 | print(a - b) 40 | 41 | 42 | def f(fn): 43 | fn() 44 | # print("F") 45 | 46 | 47 | def fs(fn): 48 | fn(1, 2) 49 | # print("F") 50 | 51 | 52 | a = A() 53 | fs(sub) 54 | f(a.f) 55 | addAll() 56 | -------------------------------------------------------------------------------- /OOPs/scratch2.py: -------------------------------------------------------------------------------- 1 | try: 2 | a = int(input("Enter price :")) 3 | if a < 0: 4 | raise ValueError('Price Negative me nahi ho sakta') 5 | except Exception as e: 6 | print("Error :" + str(e)) -------------------------------------------------------------------------------- /OOPs/superuse.py: -------------------------------------------------------------------------------- 1 | class A: 2 | def f(self): 3 | print("F in A") 4 | class B: 5 | def f(self): 6 | print("F in B") 7 | class C(B,A): 8 | def f(self): 9 | super(B,self).f() 10 | 11 | 12 | c = C() 13 | c.f() 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pythoncodecamp 2 | Python repository for learning the language from the beginning 3 | -------------------------------------------------------------------------------- /__pycache__/imagelibrary.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/__pycache__/imagelibrary.cpython-36.pyc -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Python Repository: Home 9 | 16 | 17 | 18 | 19 |
20 |
21 | Champak's Image 23 |
24 |
25 |

Python Repository: Home

26 |
27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /mailerwindow.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python ; coding: utf-8 -*- 2 | 3 | 4 | block_cipher = None 5 | 6 | 7 | a = Analysis(['mailerwindow.py'], 8 | pathex=[], 9 | binaries=[], 10 | datas=[], 11 | hiddenimports=[], 12 | hookspath=[], 13 | hooksconfig={}, 14 | runtime_hooks=[], 15 | excludes=[], 16 | win_no_prefer_redirects=False, 17 | win_private_assemblies=False, 18 | cipher=block_cipher, 19 | noarchive=False) 20 | pyz = PYZ(a.pure, a.zipped_data, 21 | cipher=block_cipher) 22 | 23 | exe = EXE(pyz, 24 | a.scripts, 25 | a.binaries, 26 | a.zipfiles, 27 | a.datas, 28 | [], 29 | name='mailerwindow', 30 | debug=False, 31 | bootloader_ignore_signals=False, 32 | strip=False, 33 | upx=True, 34 | upx_exclude=[], 35 | runtime_tmpdir=None, 36 | console=True, 37 | disable_windowed_traceback=False, 38 | target_arch=None, 39 | codesign_identity=None, 40 | entitlements_file=None ) 41 | -------------------------------------------------------------------------------- /numpyuse/chat gpt use.py: -------------------------------------------------------------------------------- 1 | api="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" 2 | -------------------------------------------------------------------------------- /numpyuse/emiequation.py: -------------------------------------------------------------------------------- 1 | from sympy import symbols, Eq, solve, N 2 | r = symbols('r', real=True) 3 | emi = -100 4 | p = 10 5 | n = 5 6 | 7 | 8 | eq = Eq(emi * ((1 + r) ** n - 1) - (p * r * (1 + r) ** n), 0) 9 | print("Equation") 10 | print(eq) 11 | results = solve(eq, r) 12 | for result in results: 13 | value = N(result) 14 | print(value) 15 | -------------------------------------------------------------------------------- /numpyuse/numpy 1.py: -------------------------------------------------------------------------------- 1 | # Introduction to Numpy 2 | import numpy as np 3 | 4 | print(np.__version__) 5 | a = np.array([1, 2, 3, 4, 5]) 6 | 7 | print("An array ", a) 8 | arr = np.zeros(10) # Create an array filled with 0s 9 | print("Array of zeroes ", arr) 10 | arr = np.ones(10) # create an array with 1s 11 | print("Array of ones ", arr) 12 | arr = np.random.randint(9, size=10) # Create an array of random numbers 13 | print("Array of random elements ", arr) 14 | arr = arr.reshape([2, 5]) 15 | print("Array reshaped 2X5\n", arr) 16 | arr = arr.reshape([-1]) 17 | print("Array reshaped to one dimension ", arr) 18 | a = np.array([[1, 2], [3, 41]]) 19 | print("Element at 0,0 ", a[0, 0]) 20 | print("Size of array ", a.size) 21 | print("Shape of array", a.shape) 22 | print("Dimensions of Array", a.ndim) 23 | a = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9]) 24 | result = np.where(a % 2 == 1) 25 | print("Searching in array ", result) 26 | print(result[0]) 27 | for pos in result: 28 | print("pos", pos, "value", a[pos]) 29 | print("Sort", np.sort(a)) 30 | print("Reverse", np.flip(np.sort(a))) 31 | -------------------------------------------------------------------------------- /numpyuse/numpyarray.py: -------------------------------------------------------------------------------- 1 | import numpy 2 | 3 | arr = numpy.zeros(10) 4 | print(arr) 5 | arr = numpy.ones(10) 6 | print(arr) 7 | arr = arr.reshape([2, 5, 1, 1]) 8 | print(arr) 9 | -------------------------------------------------------------------------------- /numpyuse/solving practice.py: -------------------------------------------------------------------------------- 1 | from sympy import symbols, Eq, solve,N 2 | 3 | x = symbols('x') 4 | eq = Eq((x ** -2 + 9), 1) 5 | print("Equation") 6 | print(eq) 7 | for result in solve(eq, x): 8 | print(N(result)) 9 | -------------------------------------------------------------------------------- /numpyuse/start numpy.py: -------------------------------------------------------------------------------- 1 | # pip install numpy 2 | import numpy 3 | arr = numpy.array([1, 2, 3, 4, 5]) 4 | 5 | print(arr) -------------------------------------------------------------------------------- /pandasuse/data.csv: -------------------------------------------------------------------------------- 1 | 2 | Player,Run,Wicket,Catch 3 | A,2,3,4 4 | B,6,7,8 5 | 6 | 7 | -------------------------------------------------------------------------------- /pandasuse/newdata.csv: -------------------------------------------------------------------------------- 1 | Player,Run,Wicket,Catch,newcol 2 | A,1001,7,9,1002001 3 | B,12,22,4,144 4 | -------------------------------------------------------------------------------- /pandasuse/pandasexcel.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | 3 | 4 | def find(data, name): 5 | query = data[(data["Player"] == name)] 6 | return query 7 | 8 | 9 | def updateName(data, oldname, newname): 10 | query = find(data, oldname) 11 | index = query.index[0] 12 | data.loc[index, ["Player"]] = newname 13 | return data 14 | 15 | 16 | data = pd.read_csv("data.csv") 17 | updateName(data, 'B', "Popat") 18 | print(data) 19 | 20 | # print(query) 21 | # print(query.index[0]) 22 | data = data.drop([0]) 23 | print(data) 24 | 25 | """ 26 | #print(data) 27 | #print(type(data)) 28 | player=data["Player"] 29 | print(player) 30 | print(type(player)) 31 | l=["Player","Run"] 32 | player=data[l] 33 | print(player) 34 | print(type(player)) 35 | data["newcol"]="New Data" 36 | print(data) 37 | data["newcol"]=data["Run"]**2 38 | data.to_csv("newdata.csv",index=False) 39 | print(data) 40 | del data["newcol"] 41 | data.append(["M",1,2,3]) 42 | print(data) 43 | #query=data[(data["Player"]=="A")] 44 | #print(query) 45 | #print(type(query)) 46 | #plt.plot(query["Run"],query["Run"]) 47 | #plt.show() 48 | """ 49 | -------------------------------------------------------------------------------- /pandasuse/vns.csv: -------------------------------------------------------------------------------- 1 | Month,Celsius,Fahrenheit 2 | 1,16,60.8 3 | 2,19.8,67.6 4 | 3,25.4,77.7 5 | 4,31.1,88.1 6 | 5,33.4,92.2 7 | 6,32.6,90.6 8 | 7,29,84.2 9 | 8,28.4,83.1 10 | 9,27.8,82 11 | 10,25.7,78.3 12 | 11,21.9,71.4 13 | 12,17.5,63.5 14 | 15 | 16 | -------------------------------------------------------------------------------- /pandasuse/weather.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import pandas as pd 3 | 4 | cum = [] 5 | data = pd.read_csv("vns.csv") 6 | print(data) 7 | x = data["Celsius"] 8 | x = data["Month"] 9 | y = data["Celsius"] 10 | prev = 0 11 | for item in y: 12 | cum = cum + [item + prev] 13 | prev = cum[len(cum) - 1] 14 | print(x) 15 | print(y) 16 | plt.grid() 17 | plt.title("Varanasi Temperature") 18 | plt.ylabel("Celsius") 19 | plt.xlabel("Month") 20 | plt.scatter(x, y, color="red", alpha=0.5) 21 | plt.plot(x, y) 22 | plt.plot(x, cum) 23 | plt.show() 24 | -------------------------------------------------------------------------------- /pattern/M-Pattern.py: -------------------------------------------------------------------------------- 1 | n = 7 2 | for row in range(1, n + 1): 3 | for col in range(1, n + 1): 4 | if col == 1 or col == n or row <= n // 2 + 1 and (row == col or row + col == n + 1): 5 | print("0", end="") 6 | else: 7 | print(" ", end="") 8 | print() 9 | -------------------------------------------------------------------------------- /pattern/Tower.py: -------------------------------------------------------------------------------- 1 | n = 6 2 | h = 2 * n - 1 3 | for row in range(n, 0, -1): 4 | for star in range(1, row + 1): 5 | print("0", end="") 6 | for space in range(1, h - 2 * row): 7 | print(" ", end="") 8 | for star in range(1, row + 1): 9 | print("0", end="") 10 | print() 11 | -------------------------------------------------------------------------------- /pattern/arrow.py: -------------------------------------------------------------------------------- 1 | print("helo \n" * 4) -------------------------------------------------------------------------------- /pattern/basepatternsquare.py: -------------------------------------------------------------------------------- 1 | #the figure to be drawn 2 | # https://github.com/Varanasi-Software-Junction/pythoncodecamp/blob/ba8654ec5f4118ca6d366c4dbc478886b4c1288e/pattern/patterns/square.PNG 3 | 4 | n = 7 #n=no of rows and no of columns as well 5 | for row in range(1, n + 1): # loop for rows 6 | for col in range(1, n + 1):# loop for columns 7 | print("0", end="") # print 0 end = "" is for avoiding the newline 8 | print() # print newline after col loop finishes 9 | 10 | -------------------------------------------------------------------------------- /pattern/fulldiamond.py: -------------------------------------------------------------------------------- 1 | #the figure to be drawn 2 | # https://github.com/Varanasi-Software-Junction/pythoncodecamp/blob/ba8654ec5f4118ca6d366c4dbc478886b4c1288e/pattern/patterns/fulldiagonal.PNG 3 | 4 | n = 7 #n=no of rows and no of columns as well 5 | mid = (n + 1)/2 6 | for row in range(1, n + 1): # loop for rows 7 | for col in range(1, n + 1):# loop for columns 8 | condition = row + col >= mid + 1 and row + col <= n + mid and col - row <= mid-1 and row - col <= mid -1 # Condition for drawing 0 9 | if condition: #Apply the condition 10 | print("0", end="") # print 0 end = "" is for avoiding the newline 11 | else: 12 | print(" ", end="") 13 | print() # print newline after col loop finishes 14 | 15 | -------------------------------------------------------------------------------- /pattern/leadingdiagonal.py: -------------------------------------------------------------------------------- 1 | #the figure to be drawn 2 | # https://github.com/Varanasi-Software-Junction/pythoncodecamp/blob/ba8654ec5f4118ca6d366c4dbc478886b4c1288e/pattern/patterns/leadingdiagonal.PNG 3 | 4 | n = 7 #n=no of rows and no of columns as well 5 | 6 | for row in range(1, n + 1): # loop for rows 7 | for col in range(1, n + 1):# loop for columns 8 | condition = row == col # Condition for drawing 0 9 | if condition: #Apply the condition 10 | print("0", end="") # print 0 end = "" is for avoiding the newline 11 | else: 12 | print(" ", end="") 13 | print() # print newline after col loop finishes 14 | 15 | -------------------------------------------------------------------------------- /pattern/leftlowertriangle.py: -------------------------------------------------------------------------------- 1 | #the figure to be drawn 2 | # https://github.com/Varanasi-Software-Junction/pythoncodecamp/blob/ba8654ec5f4118ca6d366c4dbc478886b4c1288e/pattern/patterns/leftlowertriangle.PNG 3 | 4 | n = 7 #n=no of rows and no of columns as well 5 | 6 | for row in range(1, n + 1): # loop for rows 7 | for col in range(1, n + 1):# loop for columns 8 | condition = row >= col # Condition for drawing 0 9 | if condition: #Apply the condition 10 | print("0", end="") # print 0 end = "" is for avoiding the newline 11 | else: 12 | print(" ", end="") 13 | print() # print newline after col loop finishes 14 | 15 | -------------------------------------------------------------------------------- /pattern/leftuppertriangle.py: -------------------------------------------------------------------------------- 1 | #the figure to be drawn 2 | # https://github.com/Varanasi-Software-Junction/pythoncodecamp/blob/ba8654ec5f4118ca6d366c4dbc478886b4c1288e/pattern/patterns/leftuppertriaangle.PNG 3 | 4 | n = 7 #n=no of rows and no of columns as well 5 | 6 | for row in range(1, n + 1): # loop for rows 7 | for col in range(1, n + 1):# loop for columns 8 | condition = row + col <= n + 1# Condition for drawing 0 9 | if condition: #Apply the condition 10 | print("0", end="") # print 0 end = "" is for avoiding the newline 11 | else: 12 | print(" ", end="") 13 | print() # print newline after col loop finishes 14 | 15 | -------------------------------------------------------------------------------- /pattern/lowertriangle.py: -------------------------------------------------------------------------------- 1 | #the figure to be drawn 2 | # https://github.com/Varanasi-Software-Junction/pythoncodecamp/blob/ba8654ec5f4118ca6d366c4dbc478886b4c1288e/pattern/patterns/lowertriangle.PNG 3 | 4 | n = 7 #n=no of rows and no of columns as well 5 | mid = (n + 1)/2 6 | for row in range(1, n + 1): # loop for rows 7 | for col in range(1, n + 1):# loop for columns 8 | condition = row + col >= mid + 1 and row + col <= n + mid and row - col <= mid - 1 and row >= mid # Condition for drawing 0 9 | if condition: #Apply the condition 10 | print("0", end="") # print 0 end = "" is for avoiding the newline 11 | else: 12 | print(" ", end="") 13 | print() # print newline after col loop finishes 14 | 15 | -------------------------------------------------------------------------------- /pattern/nonleadingdiagonal.py: -------------------------------------------------------------------------------- 1 | #the figure to be drawn 2 | # https://github.com/Varanasi-Software-Junction/pythoncodecamp/blob/ba8654ec5f4118ca6d366c4dbc478886b4c1288e/pattern/patterns/leadingdiagonal.PNG 3 | 4 | n = 7 #n=no of rows and no of columns as well 5 | 6 | for row in range(1, n + 1): # loop for rows 7 | for col in range(1, n + 1):# loop for columns 8 | condition = row + col == n + 1 # Condition for drawing 0 9 | if condition: #Apply the condition 10 | print("0", end="") # print 0 end = "" is for avoiding the newline 11 | else: 12 | print(" ", end="") 13 | print() # print newline after col loop finishes 14 | 15 | -------------------------------------------------------------------------------- /pattern/outlinediamond.py: -------------------------------------------------------------------------------- 1 | #the figure to be drawn 2 | # https://github.com/Varanasi-Software-Junction/pythoncodecamp/blob/ba8654ec5f4118ca6d366c4dbc478886b4c1288e/pattern/patterns/outlinediagonal.PNG 3 | 4 | n = 7 #n=no of rows and no of columns as well 5 | mid = (n + 1)/2 6 | for row in range(1, n + 1): # loop for rows 7 | for col in range(1, n + 1):# loop for columns 8 | condition = row + col == mid + 1 or row + col == n + mid or col - row == mid-1 or row - col == mid -1 # Condition for drawing 0 9 | if condition: #Apply the condition 10 | print("0", end="") # print 0 end = "" is for avoiding the newline 11 | else: 12 | print(" ", end="") 13 | print() # print newline after col loop finishes 14 | 15 | -------------------------------------------------------------------------------- /pattern/outlinesquare.py: -------------------------------------------------------------------------------- 1 | #the figure to be drawn 2 | # https://github.com/Varanasi-Software-Junction/pythoncodecamp/blob/ba8654ec5f4118ca6d366c4dbc478886b4c1288e/pattern/patterns/outlinesqure.PNG 3 | 4 | n = 7 #n=no of rows and no of columns as well 5 | 6 | for row in range(1, n + 1): # loop for rows 7 | for col in range(1, n + 1):# loop for columns 8 | condition = row == 1 or col == 1 or row == n or col == n# Condition for drawing 0 9 | if condition: #Apply the condition 10 | print("0", end="") # print 0 end = "" is for avoiding the newline 11 | else: 12 | print(" ", end="") 13 | print() # print newline after col loop finishes 14 | 15 | -------------------------------------------------------------------------------- /pattern/patterns to make/0.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns to make/0.JPG -------------------------------------------------------------------------------- /pattern/patterns to make/1.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns to make/1.JPG -------------------------------------------------------------------------------- /pattern/patterns to make/2.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns to make/2.JPG -------------------------------------------------------------------------------- /pattern/patterns to make/3.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns to make/3.JPG -------------------------------------------------------------------------------- /pattern/patterns to make/4.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns to make/4.JPG -------------------------------------------------------------------------------- /pattern/patterns to make/5.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns to make/5.JPG -------------------------------------------------------------------------------- /pattern/patterns to make/6.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns to make/6.JPG -------------------------------------------------------------------------------- /pattern/patterns to make/7.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns to make/7.JPG -------------------------------------------------------------------------------- /pattern/patterns to make/8.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns to make/8.JPG -------------------------------------------------------------------------------- /pattern/patterns to make/9.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns to make/9.JPG -------------------------------------------------------------------------------- /pattern/patterns/Full Diamond.py: -------------------------------------------------------------------------------- 1 | n = 5 2 | for row in range(1, n ): 3 | for space in range(1, n - row + 1): 4 | print(" ", end="") 5 | for star in range(1, 2*row ): 6 | print("0", end="") 7 | print() 8 | 9 | for row in range(n,0,-1): 10 | for space in range(1, n - row + 1): 11 | print(" ", end="") 12 | for star in range(1, 2*row ): 13 | print("0", end="") 14 | print() 15 | -------------------------------------------------------------------------------- /pattern/patterns/Half Diamond.py: -------------------------------------------------------------------------------- 1 | n = 5 2 | for row in range(1, n ): 3 | 4 | for star in range(1, row + 1): 5 | print("0", end="") 6 | for space in range(1,2*(n-row) + 1): 7 | print(" ", end="") 8 | for star in range(1, row + 1): 9 | print("0", end="") 10 | 11 | print() 12 | for row in range( n-2,-0,-1): 13 | 14 | for star in range(1, row + 1): 15 | print("0", end="") 16 | for space in range(1,2*(n-row) + 1): 17 | print(" ", end="") 18 | for star in range(1, row + 1): 19 | print("0", end="") 20 | 21 | print() 22 | -------------------------------------------------------------------------------- /pattern/patterns/Hour Glass.py: -------------------------------------------------------------------------------- 1 | n = 5 2 | 3 | for row in range(n,0,-1): 4 | for space in range(1, n - row + 1): 5 | print(" ", end="") 6 | for star in range(1, 2*row ): 7 | print("0", end="") 8 | print() 9 | 10 | for row in range(2, n +1): 11 | for space in range(1, n - row + 1): 12 | print(" ", end="") 13 | for star in range(1, 2*row ): 14 | print("0", end="") 15 | print() 16 | -------------------------------------------------------------------------------- /pattern/patterns/Pascal Diamond.py: -------------------------------------------------------------------------------- 1 | n = 5 2 | 3 | for row in range(1, n ): 4 | for space in range(1, n - row + 1): 5 | print(" ", end="") 6 | for star in range(1, row+1 ): 7 | print("0 ", end="") 8 | print() 9 | 10 | for row in range(n,0,-1): 11 | for space in range(1, n - row + 1): 12 | print(" ", end="") 13 | for star in range(1, row+1 ): 14 | print("0 ", end="") 15 | print() 16 | -------------------------------------------------------------------------------- /pattern/patterns/Pascal Hour Glass.py: -------------------------------------------------------------------------------- 1 | n = 5 2 | 3 | for row in range(n,0,-1): 4 | for space in range(1, n - row + 1): 5 | print(" ", end="") 6 | for star in range(1, row+1 ): 7 | print("0 ", end="") 8 | print() 9 | 10 | for row in range(2, n +1): 11 | for space in range(1, n - row + 1): 12 | print(" ", end="") 13 | for star in range(1, row+1 ): 14 | print("0 ", end="") 15 | print() 16 | -------------------------------------------------------------------------------- /pattern/patterns/Shifted Triangle.py: -------------------------------------------------------------------------------- 1 | n = 5 2 | for row in range(1, n + 1): 3 | for space in range(1, n - row + 1): 4 | print(" ", end="") 5 | for star in range(1, row + 1): 6 | print("0", end="") 7 | print() 8 | -------------------------------------------------------------------------------- /pattern/patterns/Simple Triangle.py: -------------------------------------------------------------------------------- 1 | n = 5 2 | for row in range(1, n + 1): 3 | for star in range(1, row + 1): 4 | print("0", end="") 5 | print() 6 | -------------------------------------------------------------------------------- /pattern/patterns/X.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns/X.PNG -------------------------------------------------------------------------------- /pattern/patterns/arrow.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns/arrow.PNG -------------------------------------------------------------------------------- /pattern/patterns/figures.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns/figures.PNG -------------------------------------------------------------------------------- /pattern/patterns/fulldiagonal.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns/fulldiagonal.PNG -------------------------------------------------------------------------------- /pattern/patterns/leadingdiagonal.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns/leadingdiagonal.PNG -------------------------------------------------------------------------------- /pattern/patterns/leftlowertriangle.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns/leftlowertriangle.PNG -------------------------------------------------------------------------------- /pattern/patterns/leftuppertriaangle.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns/leftuppertriaangle.PNG -------------------------------------------------------------------------------- /pattern/patterns/lowertriangle.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns/lowertriangle.PNG -------------------------------------------------------------------------------- /pattern/patterns/nonleadingdiagoonal.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns/nonleadingdiagoonal.PNG -------------------------------------------------------------------------------- /pattern/patterns/outlinediagonal.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns/outlinediagonal.PNG -------------------------------------------------------------------------------- /pattern/patterns/outlinesqure.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns/outlinesqure.PNG -------------------------------------------------------------------------------- /pattern/patterns/rightlowertriangle.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns/rightlowertriangle.PNG -------------------------------------------------------------------------------- /pattern/patterns/rightuppertraingle.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns/rightuppertraingle.PNG -------------------------------------------------------------------------------- /pattern/patterns/square.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns/square.PNG -------------------------------------------------------------------------------- /pattern/patterns/uppertriangle.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pattern/patterns/uppertriangle.PNG -------------------------------------------------------------------------------- /pattern/rightlowertriangle.py: -------------------------------------------------------------------------------- 1 | #the figure to be drawn 2 | # https://github.com/Varanasi-Software-Junction/pythoncodecamp/blob/ba8654ec5f4118ca6d366c4dbc478886b4c1288e/pattern/patterns/rightlowertriangle.PNG 3 | 4 | n = 7 #n=no of rows and no of columns as well 5 | 6 | for row in range(1, n + 1): # loop for rows 7 | for col in range(1, n + 1):# loop for columns 8 | condition = row + col >= n + 1# Condition for drawing 0 9 | if condition: #Apply the condition 10 | print("0", end="") # print 0 end = "" is for avoiding the newline 11 | else: 12 | print(" ", end="") 13 | print() # print newline after col loop finishes 14 | 15 | -------------------------------------------------------------------------------- /pattern/rightuppertriangle.py: -------------------------------------------------------------------------------- 1 | #the figure to be drawn 2 | # https://github.com/Varanasi-Software-Junction/pythoncodecamp/blob/ba8654ec5f4118ca6d366c4dbc478886b4c1288e/pattern/patterns/rightuppertraingle.PNG 3 | 4 | n = 7 #n=no of rows and no of columns as well 5 | 6 | for row in range(1, n + 1): # loop for rows 7 | for col in range(1, n + 1):# loop for columns 8 | condition = row <= col# Condition for drawing 0 9 | if condition: #Apply the condition 10 | print("0", end="") # print 0 end = "" is for avoiding the newline 11 | else: 12 | print(" ", end="") 13 | print() # print newline after col loop finishes 14 | 15 | -------------------------------------------------------------------------------- /pattern/uppertriangle.py: -------------------------------------------------------------------------------- 1 | #the figure to be drawn 2 | # https://github.com/Varanasi-Software-Junction/pythoncodecamp/blob/ba8654ec5f4118ca6d366c4dbc478886b4c1288e/pattern/patterns/uppertriangle.PNG 3 | 4 | n = 7 #n=no of rows and no of columns as well 5 | mid = (n + 1)/2 6 | for row in range(1, n + 1): # loop for rows 7 | for col in range(1, n + 1):# loop for columns 8 | condition = row + col >= mid + 1 and row + col <= n + mid and col - row <= mid-1 and row <= mid # Condition for drawing 0 9 | if condition: #Apply the condition 10 | print("0", end="") # print 0 end = "" is for avoiding the newline 11 | else: 12 | print(" ", end="") 13 | print() # print newline after col loop finishes 14 | 15 | -------------------------------------------------------------------------------- /pattern/x.py: -------------------------------------------------------------------------------- 1 | #the figure to be drawn 2 | # https://github.com/Varanasi-Software-Junction/pythoncodecamp/blob/ba8654ec5f4118ca6d366c4dbc478886b4c1288e/pattern/patterns/X.PNG 3 | 4 | n = 7 #n=no of rows and no of columns as well 5 | 6 | for row in range(1, n + 1): # loop for rows 7 | for col in range(1, n + 1):# loop for columns 8 | condition = row == col or row + col == n + 1# Condition for drawing 0 9 | if condition: #Apply the condition 10 | print("0", end="") # print 0 end = "" is for avoiding the newline 11 | else: 12 | print(" ", end="") 13 | print() # print newline after col loop finishes 14 | 15 | -------------------------------------------------------------------------------- /pics/champak/me.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/pics/champak/me.jpg -------------------------------------------------------------------------------- /printdemo.py: -------------------------------------------------------------------------------- 1 | print=90 2 | print(10) -------------------------------------------------------------------------------- /regressionproject/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varanasi-Software-Junction/pythoncodecamp/c3777526f31b6978dd3b8ec737b678174943f490/regressionproject/__init__.py -------------------------------------------------------------------------------- /regressionproject/fullregression - Copy.py0: -------------------------------------------------------------------------------- 1 | class RegressionPredict: 2 | def __init__(self, x, y,projecttitle, xlabel="X", ylabel="Y"): 3 | self.x = x 4 | self.y = y 5 | self.projecttitle=projecttitle 6 | self.n = len(x) 7 | self.sigmax = sum(x) 8 | self.sigmay = sum(y) 9 | self.x2 = [i*i for i in x] 10 | self.sigmax2 = sum([i*i for i in x]) 11 | self.sigmay2 = sum([i*i for i in y]) 12 | self.sigmaxy = sum([x[i]*y[i] for i in range(self.n)]) 13 | self.b = (self.n * self.sigmaxy - self.sigmax * self.sigmay) / \ 14 | (self.n * self.sigmax2 - self.sigmax2) 15 | self.a = (self.sigmay - self.b * self.sigmax) / self.n 16 | 17 | r = self.sigmaxy - (self.sigmax * self.sigmay / self.n) 18 | self.r = r / ((self.sigmax2 - (self.sigmax2 / self.n)) 19 | * (self.sigmay2 - (self.sigmay**2 / self.n)))**0.5 20 | 21 | def predict(self, x): 22 | return [self.a + self.b * xi for xi in x] 23 | 24 | def __str__(self): 25 | output = f"X = {self.x} \nY = {self.y}\nX2 = {self.x2} \nY2 = {self.sigmay2}\nXY = {self.sigmaxy}\n" 26 | return output 27 | 28 | def plot(self, digramtitle, plottitle, xlabel, ylabel): 29 | plt.xlabel(xlabel) 30 | plt.ylabel(ylabel) 31 | plt.title(self.projecttitle) 32 | plt.grid(True) 33 | regressiondata = self.predict(self.x) 34 | plt.plot(self.x, self.y, color='red', label=digramtitle) 35 | plt.plot(self.x, regressiondata, color='green', 36 | label="Line of Best Fit") 37 | 38 | predictruninput = [i for i in range(1, 9)] 39 | predictrunoutput = self.predict(predictruninput) 40 | regressiondata = self.predict(self.x) 41 | plt.plot(self.x, self.y, color='red', label=digramtitle) 42 | plt.plot(self.x, regressiondata, color='green', 43 | label="Line of Best Fit") 44 | plt.plot(predictruninput, predictrunoutput, 45 | color='yellow', label="Predicted Run") 46 | plt.legend() 47 | plt.tight_layout() 48 | plt.show() -------------------------------------------------------------------------------- /regressionproject/myfullregression.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | 3 | 4 | class RegressionPredict: 5 | def __init__(self, x, y, projecttitle, xlabel="X", ylabel="Y"): 6 | self.x = x 7 | self.y = y 8 | self.projecttitle = projecttitle 9 | self.xlabel = xlabel 10 | self.ylabel = ylabel 11 | self.x2= [i*i for i in x] 12 | 13 | def plotdata(self, x, y, xlabel, ylabel, plotlabel, projecttitle): 14 | plt.title(projecttitle) 15 | plt.xlabel(xlabel) 16 | plt.ylabel(ylabel) 17 | plt.grid(True) 18 | plt.plot(x, y, color="red", label=plotlabel) 19 | plt.scatter(x, y, color="blue", label=plotlabel) 20 | plt.legend() 21 | plt.show() 22 | 23 | def plotXY(self): 24 | self.plotdata(self.x, self.y, self.xlabel, self.ylabel, 25 | "Runs per innings", self.projecttitle) 26 | def plotXX2(self): 27 | self.plotdata(self.x, self.x2, self.xlabel, "Innings2", 28 | "Runs per innings", self.projecttitle + "\nInnings="+str(self.x) + "\nInnings2=" + str(self.x2)) 29 | 30 | 31 | rgp = RegressionPredict([1, 2, 3, 4, 5], [44, 32, 57, 90, 16], 32 | "Virat's Runs in IPL", "Innings", "Runs") 33 | rgp.plotXY() 34 | rgp.plotXX2() 35 | 0 -------------------------------------------------------------------------------- /regressionproject/test.py: -------------------------------------------------------------------------------- 1 | def prime_generator(n): 2 | 3 | primes = [2, 3, 5] 4 | # n = 100 5 | t = 2 6 | nextprimecandidate = 5 7 | nextprimecandidate += t 8 | while True: 9 | isprime = True 10 | sqrtlimit = int(nextprimecandidate) 11 | for p in primes: 12 | if p > sqrtlimit: 13 | isprime = True 14 | break 15 | if nextprimecandidate % p == 0: 16 | isprime = False 17 | break 18 | if isprime: 19 | primes.append(nextprimecandidate) 20 | t = 6-t 21 | nextprimecandidate += t 22 | if len(primes) >= n: 23 | # print(primes) 24 | return primes 25 | result=prime_generator(15) 26 | print(result) -------------------------------------------------------------------------------- /swap.py: -------------------------------------------------------------------------------- 1 | a,b=1,2 2 | print(a,b) 3 | t=a 4 | a=b 5 | b=t 6 | print(a,b) 7 | --------------------------------------------------------------------------------