├── Python.Py ├── Ch-1.py │ ├── 1.py │ ├── 2.py │ └── 3.py ├── Ch-10(OOPS).PY │ ├── 1.py │ ├── 2.py │ ├── 3.py │ └── 4.py ├── Ch-11(inheritance).py │ ├── 1.py │ └── 2.py ├── Ch-2.py │ ├── 1.py │ ├── 2.py │ ├── 3.py │ ├── 4.py │ └── 5.py ├── Ch-3(String).py │ ├── 1.py │ ├── 2.py │ ├── 3.py │ ├── 4.py │ ├── 5.py │ ├── 6.py │ └── 7.PY ├── Ch-4(List & Tuples).py │ ├── 1.py │ ├── 2.py │ ├── 3(tupples).py │ ├── 4.py │ ├── 5.py │ └── 6.py ├── Ch-5(Dictionary & sets).py │ ├── 1(Dictonary).py │ └── 2(Sets).py ├── Ch-6(condional operators).py │ ├── 1.py │ ├── 2.py │ ├── 3.py │ └── 4.py ├── Ch-7(loops) │ ├── 1(while loop).py │ ├── 10.py │ ├── 11.py │ ├── 12.py │ ├── 2(for loop).py │ ├── 3(Range_function).py │ ├── 4(for with else).py │ ├── 5(pass Statement).py │ ├── 6.py │ ├── 7.py │ ├── 8.py │ └── 9.py ├── Ch-8(Function).py │ ├── 1.py │ └── 2(Recursion).py ├── Ch-9(file).py │ ├── 1.py │ └── 2.py ├── PROJECT(1).py │ └── GAME.py ├── PROJECT(2).py │ └── GAME.py └── samp.txt └── README.md /Python.Py/Ch-1.py/1.py: -------------------------------------------------------------------------------- 1 | print("Hello World") 2 | '''Made By Ashish Madhup''' 3 | # Great Work 4 | ' Love For Python ' -------------------------------------------------------------------------------- /Python.Py/Ch-1.py/2.py: -------------------------------------------------------------------------------- 1 | #pip install playsound 2 | #This will install our playsound module 3 | from playsound import playsound 4 | playsound("C:\\Users\\HP\\Downloads\\Hanuman Chalisa_320(PagalWorld.com.se).mp3") 5 | -------------------------------------------------------------------------------- /Python.Py/Ch-1.py/3.py: -------------------------------------------------------------------------------- 1 | 'use of os Module' 2 | import os 3 | print(os.listdir()) 4 | #listdir() is used to print the content os the directory -------------------------------------------------------------------------------- /Python.Py/Ch-10(OOPS).PY/1.py: -------------------------------------------------------------------------------- 1 | class Remote(): 2 | pass 3 | 4 | class Player: 5 | def moveRight(self): 6 | pass 7 | 8 | def moveLeft(self): 9 | pass 10 | 11 | def moveTop(self): 12 | pass 13 | 14 | remote1 = Remote() 15 | player1 = Player() 16 | 17 | if(remote1.isLeftPressed()): 18 | player1.moveLeft() 19 | -------------------------------------------------------------------------------- /Python.Py/Ch-10(OOPS).PY/2.py: -------------------------------------------------------------------------------- 1 | class Employee : 2 | company="Google" 3 | salary=880000000 4 | 5 | Ashish=Employee() 6 | seju=Employee() 7 | print(Ashish.company) 8 | Ashish.salary=900000000 9 | print(seju.company) 10 | seju.salary=890000000 11 | Employee.company="Microsoft" 12 | print(Ashish.company) 13 | print(seju.company) 14 | print(Ashish.salary) 15 | print(seju.salary) -------------------------------------------------------------------------------- /Python.Py/Ch-10(OOPS).PY/3.py: -------------------------------------------------------------------------------- 1 | class Employee: 2 | company="Goggle" 3 | def getSalary(self): 4 | print("Salary is 900k") 5 | 6 | 7 | 8 | 9 | Ashish=Employee() 10 | Ashish.getSalary() 11 | Employee.getSalary(Ashish) -------------------------------------------------------------------------------- /Python.Py/Ch-10(OOPS).PY/4.py: -------------------------------------------------------------------------------- 1 | class Employee: 2 | company="Goggle" 3 | def getSalary(self): 4 | print(f"Salary is {self.Salary}") 5 | 6 | @staticmethod 7 | def greet():#This doesn't required self 8 | print("Good Morning Sir") 9 | 10 | Ashish=Employee 11 | Ashish.greet() 12 | Ashish.Salary=90000000 13 | Ashish.getSalary() -------------------------------------------------------------------------------- /Python.Py/Ch-11(inheritance).py/1.py: -------------------------------------------------------------------------------- 1 | class Employee : 2 | company="Google" 3 | 4 | def ShowDetails(self): 5 | print("This is an Employee") 6 | 7 | @classmethod 8 | def Change_Company(cls,comp): 9 | cls.company=comp 10 | 11 | class Programmer(Employee): 12 | language="Python" 13 | def getLanguage(self): 14 | print(f"The Language is {self.Language}") 15 | 16 | def ShowDetails(self): 17 | print("This is an programmer") 18 | 19 | e=Employee() 20 | e.ShowDetails() 21 | p=Programmer() 22 | p.ShowDetails() 23 | print(p.company) 24 | e.Change_Company("Microsoft") 25 | print(e.Change_Compapny) -------------------------------------------------------------------------------- /Python.Py/Ch-11(inheritance).py/2.py: -------------------------------------------------------------------------------- 1 | class Employee: 2 | company="Google" 3 | salary=5600 4 | salarybonus=500 5 | #totalSalary=6100 6 | 7 | @property #use of property(setter method) 8 | def totalSalary(self): 9 | return self.salary + self.salarybonus 10 | 11 | @totalSalary.setter# setter method 12 | def totalSalary(self,val): 13 | self.salarybonus = val - self.salary 14 | 15 | e = Employee() 16 | print(e.totalSalary) 17 | e.tatalSalary = 9999 18 | print(e.salary) 19 | print(e.salarybonus) -------------------------------------------------------------------------------- /Python.Py/Ch-2.py/1.py: -------------------------------------------------------------------------------- 1 | a="Ashish Madhup" 2 | 3 | a1='''Ashish 4 | is 5 | Great''' 6 | 7 | a2='Ashish' 8 | b=97 9 | c=99.9 10 | d=True 11 | 12 | #printing the variables 13 | print(a) 14 | print(b) 15 | print(c) 16 | print(a1) 17 | print(a2) 18 | 19 | #printing the type of variable 20 | print(type(a)) 21 | print(type(b)) 22 | print(type(c)) 23 | print(type(d)) 24 | print(type(a1)) 25 | print(type(a2)) -------------------------------------------------------------------------------- /Python.Py/Ch-2.py/2.py: -------------------------------------------------------------------------------- 1 | #operators in pythons 2 | ''' There are 4 Types of Operators 3 | 1. Arithmatic Operators 4 | 2. 5 | 3. 6 | 4.''' 7 | 8 | #Arithmatic Operators 9 | x=3 10 | y=4 11 | 12 | print("The Value of 3+4 is ", 3+4) 13 | print("The Value of 3-4 is ",3-4) 14 | print("The Value of 3*4 is",3*4) 15 | print("The Value of 3/4 is ",3/4) 16 | print("The Value of 3%4 is ", 3%4) 17 | 18 | print("The Value of 96+2 is ",96+2) 19 | 20 | #Assignment Operators 21 | a=334 22 | print(a) 23 | a+=12 24 | print(a) 25 | a-=9 26 | print(a) 27 | a/=2 28 | print(a) 29 | 30 | #Comparison Operators 31 | b=(1>7) 32 | print(b) 33 | b1=(14>7) 34 | print(b1) 35 | b2=(14!=7) 36 | print(b2) 37 | b3=(7==7) 38 | print(b3) 39 | 40 | #Logical Operators 41 | bool1 = True 42 | bool2 = False 43 | 44 | print("The value of bool1 and bool2 is",(bool1 and bool2)) 45 | print("The value of bool1 or bool2 is",(bool1 or bool2)) 46 | print("The value not bool1 is",(not bool1)) 47 | print("The Value of not bool2 is",(not bool2)) -------------------------------------------------------------------------------- /Python.Py/Ch-2.py/3.py: -------------------------------------------------------------------------------- 1 | #Type Casting 2 | 3 | a="3534" 4 | print(type(a)) 5 | a=int(a) 6 | print(type(a)) 7 | print(a) 8 | print(a+5) 9 | 10 | 'str(a)->convert into string' 11 | "int(a)->convert into integer" -------------------------------------------------------------------------------- /Python.Py/Ch-2.py/4.py: -------------------------------------------------------------------------------- 1 | a=input("Enter Your Name ") 2 | print(type(a)) 3 | print(a) -------------------------------------------------------------------------------- /Python.Py/Ch-2.py/5.py: -------------------------------------------------------------------------------- 1 | #Program to find Average given by User 2 | 3 | a = input("Enter a : ") 4 | b = input("Enter b : ") 5 | 6 | print(type(a)) 7 | print(type(b)) 8 | 9 | a=int(a) 10 | b=int(b) 11 | 12 | print(type(a)) 13 | print(type(b)) 14 | 15 | avg=(a+b)/2 16 | 17 | print("The Average of a and b is : ",avg) -------------------------------------------------------------------------------- /Python.Py/Ch-3(String).py/1.py: -------------------------------------------------------------------------------- 1 | greet="Good Morning " 2 | a=input("Enter Your Number : ") 3 | 4 | print(greet + a ) -------------------------------------------------------------------------------- /Python.Py/Ch-3(String).py/2.py: -------------------------------------------------------------------------------- 1 | name = "Ashish" 2 | 3 | print(name[0]) 4 | print(name[1:6]) 5 | print(name[:6]) #This is same as name[0:6] 6 | print(name[1:]) #This is same as name[1:6] 7 | print(name[-6:-1]) #This is same as name[1:6] 8 | 9 | -------------------------------------------------------------------------------- /Python.Py/Ch-3(String).py/3.py: -------------------------------------------------------------------------------- 1 | name = "AshishisGreatPerson." 2 | 3 | d = name[0::3] 4 | 5 | print(d) -------------------------------------------------------------------------------- /Python.Py/Ch-3(String).py/4.py: -------------------------------------------------------------------------------- 1 | blog = "I am Ashish Madhup and I love codeing and do my practices on Leetcode" 2 | 3 | #string Function 4 | print(len(blog)) 5 | print(blog.endswith("Leetcode")) 6 | print(blog.count("A")) 7 | print(blog.capitalize()) 8 | print(blog.find("Ashish")) 9 | 10 | print(blog.replace("practice","professionaly work on the")) 11 | 12 | story = "Ashish Loves Coding.\n My\tFav Language is C++. Ashish i\\s Best" 13 | print(story) 14 | -------------------------------------------------------------------------------- /Python.Py/Ch-3(String).py/5.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madhupashish/Python-Project/c71ef871e977233709d34fd6fe135edf6c61b695/Python.Py/Ch-3(String).py/5.py -------------------------------------------------------------------------------- /Python.Py/Ch-3(String).py/6.py: -------------------------------------------------------------------------------- 1 | letter= '''Dear <|Name|> , 2 | Your are selected ! 3 | 4 | Date: <|Date|> 5 | 6 | Greet from Hackeraashu Team''' 7 | 8 | name = input("Entre Your Name\n") 9 | date = input("Enter Date\n") 10 | letter = letter.replace("<|Name|>", name) 11 | letter = letter.replace("<|Date|>", date) 12 | 13 | print(letter) -------------------------------------------------------------------------------- /Python.Py/Ch-3(String).py/7.PY: -------------------------------------------------------------------------------- 1 | s="This is a string with double space and we need to place it with single space" 2 | 3 | doublespace=s.find(" ") 4 | print(doublespace) 5 | 6 | s=s.replace(" "," ") 7 | print(s) -------------------------------------------------------------------------------- /Python.Py/Ch-4(List & Tuples).py/1.py: -------------------------------------------------------------------------------- 1 | #creat a list using [] 2 | a=[91 , 98 , 97 ,96 ] 3 | 4 | #print the list using print() function 5 | print(a) 6 | 7 | #Access the value of list 8 | print(a[0]) 9 | 10 | #change the value of list 11 | a[0]=99 12 | print(a) 13 | 14 | #list slicing 15 | friends=["sejal" , "seju" , "deol" , "sejon" ] 16 | print(friends[0:3]) 17 | print(friends[-4:-1]) -------------------------------------------------------------------------------- /Python.Py/Ch-4(List & Tuples).py/2.py: -------------------------------------------------------------------------------- 1 | l1=[ 88 , 87 , 90 , 95 , 99 , 94 , 99] 2 | print(l1) 3 | 4 | l1.sort() 5 | print(l1) 6 | 7 | l1.reverse() 8 | print(l1) 9 | 10 | l1.append(99) #add at the end of the list 11 | print(l1) 12 | 13 | l1.insert(0,99)#insert 99 at index 0 14 | print(l1) 15 | 16 | l1.pop(2) #will delete element at index 2 17 | print(l1) 18 | 19 | l1.remove(87)#remove 87 from the list 20 | print(l1) 21 | 22 | 23 | -------------------------------------------------------------------------------- /Python.Py/Ch-4(List & Tuples).py/3(tupples).py: -------------------------------------------------------------------------------- 1 | #Tuple 2 | t=(12,13,14,15) 3 | print(t) 4 | 5 | #Tuple with single element 6 | t1=(1,) 7 | print(t1) 8 | 9 | # NOTES: can't change the values of Tuples 10 | 11 | #Libraries 12 | a=(86,87,88,89,90,91,92,93,94,95,96,97,98,99) 13 | print(a) 14 | print(a.count(99)) 15 | print(a.index(99)) 16 | -------------------------------------------------------------------------------- /Python.Py/Ch-4(List & Tuples).py/4.py: -------------------------------------------------------------------------------- 1 | f1=input("Enter Name1") 2 | f2=input("Enter Name2") 3 | f3=input("Enter Name3") 4 | f4=input("Enter Name4") 5 | 6 | f_list=[f1,f2,f3,f4] 7 | print(f_list) -------------------------------------------------------------------------------- /Python.Py/Ch-4(List & Tuples).py/5.py: -------------------------------------------------------------------------------- 1 | '''As we have created the list 2 | we know it is default is in string 3 | so we have converted it in integer''' 4 | 5 | m1=int(input("Enter marks1")) 6 | m2=int(input("Enter marks2")) 7 | m3=int(input("Enter marks3")) 8 | m4=int(input("Enter marks4")) 9 | 10 | marks_list=[m1,m2,m3,m4] 11 | marks_list.sort() 12 | print(marks_list) 13 | -------------------------------------------------------------------------------- /Python.Py/Ch-4(List & Tuples).py/6.py: -------------------------------------------------------------------------------- 1 | a=[10,20,30,50,98] 2 | 3 | print(a[0]+a[1]+a[2]+a[3]+a[4]) 4 | print(sum) -------------------------------------------------------------------------------- /Python.Py/Ch-5(Dictionary & sets).py/1(Dictonary).py: -------------------------------------------------------------------------------- 1 | #Dictionary Syntax 2 | 3 | my_Dict= { 4 | "Ashish": "Brilliant name", 5 | "Ashish Madhup": "Brilliant Human" , 6 | "marks": [99,98,99] , 7 | "another_Dict": {"ashish": "Ashish"}, 8 | 1:2 9 | } 10 | 11 | print(my_Dict['Ashish']) 12 | print(my_Dict['Ashish Madhup']) 13 | print(my_Dict["marks"]) 14 | print(my_Dict["another_Dict"]) 15 | print(my_Dict['another_Dict']['ashish']) 16 | 17 | print(my_Dict.keys()) 18 | print(list(my_Dict.keys())) 19 | print(my_Dict.values()) 20 | print(my_Dict.items()) 21 | 22 | print(my_Dict) 23 | updateDict={ 24 | "Seju":"Friend", 25 | "Ashish": "Brilliant Person" 26 | } 27 | my_Dict.update(updateDict) 28 | print(my_Dict) 29 | 30 | print(my_Dict.get("Ashish")) 31 | print(my_Dict["Ashish"]) -------------------------------------------------------------------------------- /Python.Py/Ch-5(Dictionary & sets).py/2(Sets).py: -------------------------------------------------------------------------------- 1 | #Sets 2 | a={1,2,3,4,5,5,4,6} 3 | print(type(a)) 4 | print(a) #sets don't print repitative value 5 | 6 | b={} # this will creat empty dictonary 7 | c=set() # this will creat empty sets 8 | 9 | print(type(b)) 10 | print(type(c)) 11 | 12 | c.add(5,7,8,9) 13 | c.add(4)#can't add list & dictonary in set but can add tupple 14 | print(c) 15 | 16 | print(len(c)) 17 | 18 | c.remove(5) 19 | print(c) 20 | 21 | print(c.pop()) 22 | print(c) -------------------------------------------------------------------------------- /Python.Py/Ch-6(condional operators).py/1.py: -------------------------------------------------------------------------------- 1 | a=99 2 | if(a>98): 3 | print("Value is greater than 95") 4 | elif(a>97): 5 | print("Value is greater than 96") 6 | else: 7 | print("value is samaller than 97 & 98") 8 | -------------------------------------------------------------------------------- /Python.Py/Ch-6(condional operators).py/2.py: -------------------------------------------------------------------------------- 1 | #Write a program to find the greatest of four numbers entered by the user. 2 | 3 | num1 = int(input("Enter Your Number : ")) 4 | num2 = int(input("Enter Your Number : ")) 5 | num3 = int(input("Enter Your Number : ")) 6 | num4 = int(input("Enter Your Number : ")) 7 | 8 | if(num1>num4): 9 | f1=num1 10 | else: 11 | f1=num4 12 | 13 | if(num2>num3): 14 | f2=num2 15 | else: 16 | f2=num3 17 | 18 | if(f1>f2): 19 | print(str(f1) + " is gratest") 20 | else: 21 | print(str(f2) + " is greatest") 22 | 23 | -------------------------------------------------------------------------------- /Python.Py/Ch-6(condional operators).py/3.py: -------------------------------------------------------------------------------- 1 | # A spam comment is defined as a text containing the following keywords: 2 | # “make a lot of money”, “buy now”. 3 | # Write a program to detect these spams. 4 | 5 | text=input("Enter Your Text") 6 | 7 | if("make a lot of money" in text): 8 | spam=True 9 | elif("buy now" in text): 10 | spam=True 11 | else: 12 | spam=False 13 | 14 | if(spam): 15 | print("THis text is spam") 16 | else: 17 | print("This text is not spam") 18 | 19 | -------------------------------------------------------------------------------- /Python.Py/Ch-6(condional operators).py/4.py: -------------------------------------------------------------------------------- 1 | username=[ "ash", "aash", "disha"] 2 | name=input("Enter Your Name") 3 | 4 | if name in username: 5 | print("Name is There") 6 | else: 7 | print("Name is not in There") -------------------------------------------------------------------------------- /Python.Py/Ch-7(loops)/1(while loop).py: -------------------------------------------------------------------------------- 1 | i=0 2 | while i<10 : 3 | print("yes" + str(i)) 4 | i=i+1 5 | 6 | print("done") -------------------------------------------------------------------------------- /Python.Py/Ch-7(loops)/10.py: -------------------------------------------------------------------------------- 1 | # Write a program to print the following star pattern. 2 | 3 | num=int(input("Enter Your Number : ")) 4 | 5 | for i in range (4): 6 | print("*" * (i+1)) 7 | num=num+1 8 | -------------------------------------------------------------------------------- /Python.Py/Ch-7(loops)/11.py: -------------------------------------------------------------------------------- 1 | # Write a program to print the following star pattern. 2 | 3 | n=3 4 | 5 | for i in range(3): 6 | print(" " * (n-i-1), end="") 7 | print("*" * (2*i+1), end="") 8 | print(" " * (n-i-1)) -------------------------------------------------------------------------------- /Python.Py/Ch-7(loops)/12.py: -------------------------------------------------------------------------------- 1 | # Write a program to print the multiplication table of n using for loop in reversed order. 2 | 3 | num=int(input("Enter Your Numberm : ")) 4 | 5 | for i in range (10,0,-1): 6 | #print(str(num) + " X " + str(i) + "=" + str(i*num)) 7 | 8 | print(f"{num} X {i} = {num*i}") # fstrings -------------------------------------------------------------------------------- /Python.Py/Ch-7(loops)/2(for loop).py: -------------------------------------------------------------------------------- 1 | fruits = ["Mango", "Banana","Grapes","Papaya"] 2 | 3 | for item in fruits: 4 | print(item) -------------------------------------------------------------------------------- /Python.Py/Ch-7(loops)/3(Range_function).py: -------------------------------------------------------------------------------- 1 | # Range Function 2 | for i in range(8): 3 | print(i) 4 | 5 | print() 6 | 7 | for i in range(1,8): 8 | print(i) 9 | 10 | print() 11 | 12 | for i in range(1,8,2): 13 | print(i) -------------------------------------------------------------------------------- /Python.Py/Ch-7(loops)/4(for with else).py: -------------------------------------------------------------------------------- 1 | for i in range(10): 2 | print(i) 3 | 4 | else: 5 | print("Thank you") -------------------------------------------------------------------------------- /Python.Py/Ch-7(loops)/5(pass Statement).py: -------------------------------------------------------------------------------- 1 | # pass 2 | # pass is a null statement 3 | 4 | i=4 5 | if i > 0 : 6 | pass 7 | while i > 6 : 8 | pass 9 | 10 | print("Ashish Madhup") -------------------------------------------------------------------------------- /Python.Py/Ch-7(loops)/6.py: -------------------------------------------------------------------------------- 1 | # Write a program to print the multiplication table of a given number using for loop. 2 | 3 | num=int(input("Enter Your Numberm : ")) 4 | 5 | for i in range (1,11): 6 | #print(str(num) + " X " + str(i) + "=" + str(i*num)) 7 | 8 | print(f"{num} X {i} = {num*i}") # fstrings -------------------------------------------------------------------------------- /Python.Py/Ch-7(loops)/7.py: -------------------------------------------------------------------------------- 1 | l1= ["Ashish","Aashhu","Abhi","Seju"] 2 | 3 | for name in l1 : 4 | if name.startswith("A"): 5 | print("Hello"+ name) -------------------------------------------------------------------------------- /Python.Py/Ch-7(loops)/8.py: -------------------------------------------------------------------------------- 1 | # Write a program to find whether a given number is prime or not. 2 | 3 | num=int(input("Enter Your Number")) 4 | 5 | prime=True 6 | for i in range(2,num): 7 | if(num%i==0): 8 | prime =False 9 | break 10 | 11 | if (prime): 12 | print("Number is Prime") 13 | else: 14 | print("Number is not prime") -------------------------------------------------------------------------------- /Python.Py/Ch-7(loops)/9.py: -------------------------------------------------------------------------------- 1 | # rite a program to calculate the factorial of a given number using for loop 2 | num=int(input("Enter Your Number : ")) 3 | factorial = 1 4 | 5 | for i in range(1,num+1): 6 | factorial=factorial*i 7 | 8 | print(f"The factorial of {num} is {factorial}") 9 | -------------------------------------------------------------------------------- /Python.Py/Ch-8(Function).py/1.py: -------------------------------------------------------------------------------- 1 | def percent (marks): 2 | p=(sum(marks)/400)*100 3 | return p 4 | 5 | marks1=[98,98,97,99] 6 | percentage1=percent(marks1) 7 | 8 | marks2=[99,99,98,99] 9 | percentage2=percent(marks2) 10 | 11 | print(percentage1,percentage2) -------------------------------------------------------------------------------- /Python.Py/Ch-8(Function).py/2(Recursion).py: -------------------------------------------------------------------------------- 1 | # Recursion 2 | 3 | def factorial_recursive(n): 4 | if n==1 or n==0: 5 | return 1 6 | return n * factorial_recursive(n-1) 7 | 8 | def factorial_iter(n): 9 | fact=1 10 | for i in range(1,n+1): 11 | fact=fact*i 12 | return fact 13 | 14 | A1= factorial_iter(5) 15 | A2=factorial_recursive(5) 16 | print(A1) 17 | print(A2) -------------------------------------------------------------------------------- /Python.Py/Ch-9(file).py/1.py: -------------------------------------------------------------------------------- 1 | a=open('samp.txt','r')# by default mode is in read 2 | game_code=a.read() 3 | print(game_code) 4 | a.close() 5 | 6 | '''game_code=a.read(5)#read 5 character 7 | print(game_code) 8 | game_code=a.readline()#read 1 line 9 | print(game_code)''' 10 | 11 | if 'writing' in game_code : 12 | print("It is Present") 13 | else: 14 | print("It is not Present") 15 | 16 | -------------------------------------------------------------------------------- /Python.Py/Ch-9(file).py/2.py: -------------------------------------------------------------------------------- 1 | f=open('samp.txt','a')#appending mode 2 | f.write("i am appending") 3 | f.close() 4 | 5 | f=open('samp.txt','w')#writing mode 6 | f.write("i am writing") 7 | f.close() 8 | #This will create a new file if file is not created 9 | #f.write with w will remove everything from file -------------------------------------------------------------------------------- /Python.Py/PROJECT(1).py/GAME.py: -------------------------------------------------------------------------------- 1 | # Project 1 2 | # Snake, Water, Gun Game We all have played snake, water gun game in our childhood. 3 | # If you haven’t, google the rules of this game and 4 | # write a Python program capable of playing this game with the user. 5 | 6 | import random 7 | def game(comp,you): 8 | if comp==you: 9 | return None 10 | 11 | elif comp==1: 12 | if you==2: 13 | return False 14 | else: 15 | return True 16 | 17 | elif comp==2: 18 | if you==3: 19 | return False 20 | else: 21 | return True 22 | 23 | elif comp==3: 24 | if you==1: 25 | return False 26 | else: 27 | return True 28 | 29 | 30 | print("computer's Turn : sanke(1) , water(2) , gun(3)") 31 | comp=random.randint(1,3) 32 | 33 | you=int(input("Enter snake(1) , water(2) , gun(3)")) 34 | a=game(comp,you) 35 | 36 | print(f"Computer's choice : {comp}") 37 | print(f"your's choice :{you}") 38 | 39 | if a==None: 40 | print("Game is Tie") 41 | elif a: 42 | print("Congratulation You Won !") 43 | else: 44 | print("Computer won this time") 45 | -------------------------------------------------------------------------------- /Python.Py/PROJECT(2).py/GAME.py: -------------------------------------------------------------------------------- 1 | ''' Project 2: The Perfect Guess 2 | We are going to write a program that generates a random number and asks the user to guess it. 3 | If the player’s guess is higher than the actual number, the program displays “Lower number please”. Similarly, 4 | if the user’s guess is too low, the program prints “higher number please”.When the user guesses the correct number, 5 | the program displays the number of guesses the player used to arrive at the number. 6 | Hint: Use the random module''' 7 | import random 8 | randNumber = random.randint(1,100) 9 | userGuess=None 10 | guesses=0 11 | while(userGuess!= randNumber): 12 | userGuess = int(input("Enter Your Guess : ")) 13 | guesses +=1 14 | if(userGuess==randNumber): 15 | print("You guessed it right!") 16 | else: 17 | if(userGuess>randNumber): 18 | print("You guesed it wrong! Enter a samller number") 19 | else: 20 | print("You guessed it wrong! Enter a larger number") 21 | 22 | print(f"You guessed the number in {guesses} guesses") -------------------------------------------------------------------------------- /Python.Py/samp.txt: -------------------------------------------------------------------------------- 1 | i am writing -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python-Project 2 | 3 | This is my project repo of python 4 | --------------------------------------------------------------------------------