├── .gitattributes ├── AreaEstimation.py ├── AreaUsingRGB.py ├── AudioTranscripter.py ├── BinarySearch.py ├── BirthdayParadox.py ├── CrowdComputing.py ├── DataCompression.py ├── DobbleGame.py ├── FaceBookSentimentAnalysis.py ├── GPSTrackRoute.py ├── GuessTheMovieName.py ├── ImageLibrary.py ├── InstaAutomation.py ├── JumbledWords.py ├── MagicSquare.py ├── MonteHall.py ├── Networkx.py ├── PlagrisimChecker.py ├── RecursionPrograms.py ├── RockPaperScissors.py ├── SpeedTest.py ├── SpiralTraversing.py ├── SubstitutionCipher ├── SubstitutionCipher.py ├── input.txt └── output.txt ├── TheoryOfRevolution.py ├── TicTacToe.py ├── Tuples.py ├── __pycache__ └── SpeedTest.cpython-311.pyc ├── chess game.py ├── config ├── blacklist.txt ├── comments.txt ├── followed.txt ├── friends.txt ├── log │ ├── instabot_4297249872.log │ ├── instabot_4339815440.log │ ├── instabot_4365194256.log │ └── instabot_4370863184.log ├── skipped.txt ├── unfollowed.txt └── whitelist.txt ├── dnaTest.txt ├── fibonacci turtle.py ├── heart game.py ├── jumbled.py ├── mymap.html ├── route.csv └── test.png /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /AreaEstimation.py: -------------------------------------------------------------------------------- 1 | import scipy.misc 2 | from PIL import Image 3 | import random 4 | 5 | img = scipy.misc.read('img_name') 6 | countPunjab = 0 7 | countIndia = 0 8 | count = 0 9 | 10 | while(count<=100000): 11 | x=random.randint(0,2735) #width of india map 12 | y=random.randint(0,2480) #height of india map 13 | z=0 14 | if(img[x][y][z]==60): 15 | countIndia = countIndia + 1 16 | count = count + 1 17 | else: 18 | if(img[x][y][z]==80): 19 | countPunjab = countPunjab + 1 20 | count = count + 1 21 | 22 | areaEstimated = (countPunjab/countIndia) * 328763 #area of india 23 | print(areaEstimated," km") -------------------------------------------------------------------------------- /AreaUsingRGB.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import random 3 | 4 | im = Image.open('img_name') 5 | rgb = im.convert('RGB') 6 | countPunjab = 0 7 | countIndia = 0 8 | count = 0 9 | while(count<=100000): 10 | x = random.randint(0,2375) 11 | y = random.randint(0,2480) 12 | z = 0 13 | r,g,b = rgb.getpixel((x,y)) 14 | if(r==60): 15 | countIndia = countIndia + 1 16 | count = count + 1 17 | else: 18 | if(r==80): 19 | countPunjab = countPunjab + 1 20 | count = count + 1 21 | 22 | estimatedArea = (countPunjab/countIndia) * 3287263 23 | print(estimatedArea,' km') -------------------------------------------------------------------------------- /AudioTranscripter.py: -------------------------------------------------------------------------------- 1 | import speech_recognition as sr 2 | audioFile = ("sample.wav") # only converts audio present in .wav extention 3 | r = sr.Recognizer() 4 | 5 | with sr.AudioFile(audioFile) as source: 6 | audioFile = r.record(source) 7 | 8 | try: 9 | print(r.recognize_google(audioFile)) 10 | except sr.UnknownValueError: 11 | print("Google couldn't recognize audio") # except is a type of error 12 | except sr.RequestError: 13 | print("Check audio file once") 14 | 15 | -------------------------------------------------------------------------------- /BinarySearch.py: -------------------------------------------------------------------------------- 1 | def binarySearch(list,num,start,end): 2 | if start == end: 3 | if(list[start]== num): 4 | return start 5 | else: 6 | return -1 7 | 8 | else: 9 | start = 0 10 | end = len(list) - 1 11 | mid = int((start + end)/2) 12 | if(list[mid] == num): 13 | return mid 14 | elif(num < list[mid]): 15 | return binarySearch(list,num,start,mid-1) 16 | else: 17 | return binarySearch(list,num,mid+1,end) 18 | 19 | 20 | l = [10,20,30,40,60] 21 | n = int(input('Enter the number: ')) 22 | 23 | index = binarySearch(l, n, 0, len(l) - 1) 24 | if index == -1: 25 | print(x, 'not found') 26 | else: 27 | print(x, ' is found in', index+1) -------------------------------------------------------------------------------- /BirthdayParadox.py: -------------------------------------------------------------------------------- 1 | import random 2 | birthday = [] 3 | i = 0 4 | while(i<50): 5 | year = random.randint(1900,2023) 6 | if(year%4==0 and year%100!=0 or year%400==0): 7 | leap=1 8 | else: 9 | leap=0 10 | month = random.randint(1,12) 11 | if(month==2 and leap==1): 12 | day=random.randint(1,29) 13 | elif(month==2 and leap==0): 14 | day=random.randint(1,28) 15 | elif(month==7 or month==8): 16 | day=random.randint(1,31) 17 | elif(month%2!=0 and month<7): 18 | day=random.randint(1,31) 19 | elif(month%2==0 and month>7 and month<12): 20 | day=random.randint(1,31) 21 | -------------------------------------------------------------------------------- /CrowdComputing.py: -------------------------------------------------------------------------------- 1 | import statistics 2 | import matplotlib.pyplot as plt 3 | estimates = [10,550,666,234,233,567,433,678,433,900,0] 4 | y = [] 5 | estimates.sort() 6 | tv = int(0.1*(len(estimates))) # trimming first and last 10% valies 7 | estimates = estimates[tv:] 8 | estimates = estimates[:len(estimates)-tv] 9 | for i in range (len(estimates)): 10 | y.append(5) 11 | plt.plot(estimates, y,'r--') 12 | plt.plot([345],[5],'g^') 13 | plt.plot([statistics.mean(estimates)],[5],'ro') 14 | plt.plot([statistics.median(estimates)],[5],'bs') 15 | plt.show() 16 | 17 | plt.ylabel('some values') 18 | plt.plot([1,2,3,4],[5,6,7,8],'r--') 19 | plt.show() 20 | -------------------------------------------------------------------------------- /DataCompression.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from PIL import Image 3 | 4 | img = Image.open('img_name') 5 | pixelMap = img.load() 6 | 7 | I = np.asanyarray(Image.open('img_name')) 8 | imgNew = Image.new(img.mode,img.size) 9 | pixelNew = imgNew.load() 10 | 11 | for i in range(img.size[0]): 12 | for j in range(img.size[1]): 13 | 14 | if(pixelMap[i,j]>=0 and pixelMap[i,j]<=31): 15 | pixelMap[i,j] = 0 16 | 17 | elif(pixelMap[i,j]>=32 and pixelMap[i,j]<=63): 18 | pixelMap[i,j] = 1 19 | 20 | elif(pixelMap[i,j]>=64 and pixelMap[i,j]<=95): 21 | pixelMap[i,j] = 2 22 | 23 | elif(pixelMap[i,j]>=96 and pixelMap[i,j]<=127): 24 | pixelMap[i,j] = 2 25 | 26 | img2 = pixelMap.load() 27 | img.save('new_image_name') 28 | 29 | -------------------------------------------------------------------------------- /DobbleGame.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nishant-Tiwari24/python-foundation-projects/95bb8c7e952772caf364bfe1e9cba53a35a8a0b6/DobbleGame.py -------------------------------------------------------------------------------- /FaceBookSentimentAnalysis.py: -------------------------------------------------------------------------------- 1 | #VADER = Valence aware dictionary and sentiment reasoner and accounts the intensity of sentiment 2 | #nltk = to analyse the sentiments of human data 3 | 4 | import pandas as pd 5 | import nltk 6 | from nltk.sentiment.vader import SentimentIntensityAnalyzer 7 | nltk.downloader.download('vader_lexicon') 8 | 9 | file = 'filename in excel format' 10 | xl = pd.ExcelFile(file) 11 | dataFrames = xl.parse(xl.sheet_names[0]) #parsing data 12 | dataFrames = xl.list(dataFrames['Timeline']) #removes blank rows 13 | sid = SentimentIntensityAnalyzer() 14 | str1 = 'UTC+05:30' #removing not-required data 15 | for data in sid: 16 | a = data.find(str1) 17 | if(a == -1): 18 | ss=sid.polarity_scores(data) #sentiment analyser 19 | for k in ss: 20 | print(k,ss[k]) 21 | -------------------------------------------------------------------------------- /GPSTrackRoute.py: -------------------------------------------------------------------------------- 1 | from gmplot import gmplot 2 | import csv 3 | gmap = gmplot.GoogleMapPlotter(28.689519,77.324495,17) 4 | gmap.coloricon = "https://googlemapsmakers.com/v1/%s/" 5 | 6 | with open('route.csv','r') as f: 7 | reader = csv.reader(f) 8 | 9 | for row in reader: 10 | lat = float(row[0]) 11 | long = float(row[1]) 12 | gmap.marker(lat,long,'red') 13 | 14 | gmap.draw('mymap.html') 15 | 16 | -------------------------------------------------------------------------------- /GuessTheMovieName.py: -------------------------------------------------------------------------------- 1 | import random as random 2 | movies=['drishyam','nayakan','avengers','pink','golmaal','vikram vedha','black friday','dangal','manichithratazu','taare zameen par'] 3 | 4 | def createQues(movie): 5 | n = len(movie) 6 | letters = list(movie) 7 | temp = [] 8 | for i in range (n): 9 | if letters[i]==' ': 10 | temp.append(' ') 11 | else: 12 | temp.append('-') 13 | separator = '' 14 | qn = separator.join(temp) #converts back to string 15 | return qn 16 | 17 | def isPresent(letter,movie): 18 | return letter in movie 19 | 20 | def unlock(question, movie, letter): 21 | question = list(question) 22 | for i in range(len(movie)): 23 | if movie[i] == letter: 24 | question[i] = letter 25 | return ''.join(question) 26 | 27 | def play(): 28 | p1name = input('Player 1 enter your name: ') 29 | p2name = input('Player 2 enter your name: ') 30 | pointsP1=0 31 | pointsP2=0 32 | turn=0 33 | willing=True 34 | 35 | while(willing is True): 36 | if turn%2==0: 37 | print(p1name," Your Turn") 38 | pickedMovie = random.choice(movies) 39 | question = createQues(pickedMovie) 40 | print(question) 41 | 42 | notSaid = True 43 | while(notSaid): 44 | letter = str(input("Your letter: ")) 45 | if(isPresent(letter,pickedMovie)): 46 | modifiedQues = unlock(modifiedQues,pickedMovie,letter) 47 | print(modifiedQues) 48 | d = int(input('Press 1 to guess the movie name or 2 to nlock another letter')) 49 | if d==1: 50 | ans = input('Your answer: ') 51 | if ans == pickedMovie: 52 | pointsP1 = pointsP1+1 53 | print('Correct') 54 | notSaid = False 55 | print(p1name,'Your score : ', pointsP1) 56 | else: 57 | print('Try again') 58 | 59 | else: 60 | print(letter," is not found") 61 | 62 | c = int(input("Press 1 to continue or 0 to exit")) 63 | if c==0: 64 | print(p1name,'Your score is ',pointsP1) 65 | print(p2name,'Your score is ',pointsP2) 66 | print('Thanks for playing') 67 | willing = False 68 | 69 | else: 70 | print(p2name," Your Turn") 71 | pickedMovie = random.choice(movies) 72 | question = createQues(pickedMovie) 73 | print(question) 74 | 75 | notSaid = True 76 | while(notSaid): 77 | letter = input("Your letter") 78 | if(isPresent(letter,pickedMovie)): 79 | modifiedQues = unlock(modifiedQues,pickedMovie,letter) 80 | print(modifiedQues) 81 | d = input('Press 1 to guess the movie name or 2 to nlock another letter') 82 | if d==1: 83 | ans = input('Your answer: ') 84 | if ans==pickedMovie: 85 | pointsP2=pointsP2+1 86 | print('Correct') 87 | notSaid=False 88 | print(p2name,'Your score : ',pointsP2) 89 | else: 90 | print('Try again') 91 | 92 | else: 93 | print(letter," is not found") 94 | 95 | c = input("Press 1 to continue or 0 to exit") 96 | if c==0: 97 | print(p1name,'Your score is ',pointsP1) 98 | print(p2name,'Your score is ',pointsP2) 99 | print('Thanks for playing') 100 | willing = False 101 | 102 | turn=turn+1 103 | 104 | play() 105 | -------------------------------------------------------------------------------- /ImageLibrary.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from PIL import Image 3 | width = 5 4 | height = 4 5 | array = np.zeros([width,height,3],dtype=np.uint8) 6 | img = Image.fromarray(array) 7 | img.save('test.png') 8 | array1 = np.zeros([100,200,3],dtype=np.uint8) 9 | array1[:,:100] = [255,128,0] 10 | img = Image.fromarray(array1) 11 | img.save('test1.png') 12 | 13 | #to get rgb values of a image 14 | image1 = Image.open('test1.png') 15 | rgb = image1.convert('RGB') 16 | r,g,b = rgb.getpixel(1,1) 17 | print(r,g,b) 18 | -------------------------------------------------------------------------------- /InstaAutomation.py: -------------------------------------------------------------------------------- 1 | from instabot import Bot 2 | automationBot = Bot() 3 | 4 | automationBot.login(username="its.nishaant",password="********") 5 | automationBot.follow("niv_srir") 6 | automationBot.upload_photo("/Users/nishanttiwari/projects/netflix_clone") 7 | automationBot.unfollow("nivedha_sriram") 8 | automationBot.send_message("Hey there its Nishant",['yeemessymfs,nivedha_sriram']) 9 | followers = automationBot.get_user_followers("its.nishaant") 10 | for i in followers: 11 | print(automationBot.get_user_info) 12 | -------------------------------------------------------------------------------- /JumbledWords.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | def choose(): 4 | words = ["apple", "banana", "cherry", "date", "grape", "kiwi", "lemon", "mango", "orange", "pear"] 5 | pick = random.choice(words) 6 | return pick 7 | 8 | 9 | 10 | def jumble(word): 11 | jumbled = "".join(random.sample(word,len(word))) 12 | return jumbled 13 | 14 | def thank(player1,player2,pp1,pp2): 15 | print(player1," score is ",pp1) 16 | print(player2," score is ",pp2) 17 | print('Thanks for playing') 18 | 19 | def play(): 20 | player1 = input('Enter the name of first player: ') 21 | player2 = input('Enter the name of second player: ') 22 | pp1 = 0 23 | pp2 = 0 24 | turn = 0 25 | 26 | pickedWord = choose() 27 | qn = jumble(pickedWord) 28 | print(qn) 29 | 30 | while(1): 31 | if turn%2 == 0: 32 | print(player1," your chance") 33 | ans = input('What is in your mind?\n') 34 | if ans == pickedWord: 35 | pp1 = pp1 + 1 36 | print('Your score is ',pp1) 37 | else: 38 | print('Better luck next time') 39 | c = int(input('Choose 1 to continue and 0 to quit ')) 40 | if c==0: 41 | thank(player1,player2,pp1,pp2) 42 | break 43 | 44 | else: 45 | print(player1," your chance") 46 | ans = input('What is in your mind?') 47 | if(ans == pickedWord): 48 | pp1 = pp1 + 1 49 | print('Your score is ',pp1) 50 | else: 51 | print('Better luck next time',pickedWord) 52 | c = int(input('Choose 1 to continue and 0 to quit')) 53 | if c==0: 54 | thank(player1,player2,pp1,pp2) 55 | break 56 | turn=turn+1 57 | 58 | play() 59 | -------------------------------------------------------------------------------- /MagicSquare.py: -------------------------------------------------------------------------------- 1 | def magic_Square(n): 2 | magicSquare=[] 3 | for i in range(n): 4 | l = [] 5 | for j in range(n): 6 | l.append(0) 7 | magicSquare.append(l) 8 | 9 | for i in range(n): 10 | for j in range(n): 11 | print(magicSquare[i][j], end=" ") 12 | print() 13 | -------------------------------------------------------------------------------- /MonteHall.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | doors = [0]*3 4 | goatDoor = [0]*2 5 | swapWins = 0 6 | noSwapWins = 0 7 | 8 | price = random.randint(0,2) 9 | doors[price] = 'price' 10 | 11 | for i in range(0,2): 12 | if(i==price): 13 | continue 14 | else: 15 | doors[i] = 'Goat' 16 | goatDoor.append(i) 17 | c = int(input("Enter your choice")) 18 | doorOpen = random.choice(goatDoor) 19 | while(doorOpen==c): 20 | doorOpen = random.choice(goatDoor) 21 | ch = input("Do you want to swap? y/n") 22 | if(ch=='y'): 23 | if(doors[c]=='Goat'): 24 | print('Player wins') 25 | swapWins = swapWins + 1 26 | else: 27 | print('Player lost') 28 | else: 29 | if(doors[c]=='Goat'): 30 | print('Player lost') 31 | else: 32 | print('player wins') 33 | noSwapWins = noSwapWins + 1 -------------------------------------------------------------------------------- /Networkx.py: -------------------------------------------------------------------------------- 1 | import networkx as nx 2 | import matplotlib.pyplot as plt 3 | 4 | G = nx.complete_graph(100) 5 | graph = nx.gnp_random_graph(20,0.5) 6 | 7 | 8 | print(G.nodes(),G.edges()) 9 | nx.draw(G) 10 | plt.show() 11 | 12 | -------------------------------------------------------------------------------- /PlagrisimChecker.py: -------------------------------------------------------------------------------- 1 | import nltk 2 | from nltk.corpus import wordnet 3 | from nltk.tokenize import word_tokenize 4 | from nltk.corpus import stopwords 5 | import random 6 | 7 | stop_words = stopwords.words("english") 8 | 9 | def plagiarism_remover(i): 10 | word = i 11 | synonyms = [] 12 | if word in stop_words: 13 | return word 14 | if wordnet.synsets(word)==[]: 15 | return word 16 | for syn in wordnet.synsets(word): 17 | for lemma in syn.lemmas(): 18 | synonyms.append(lemma.name()) 19 | pos_tag_word = nltk.pos_tag([word]) 20 | pos = [] 21 | for i in synonyms: 22 | pos.append(nltk.pos_tag([i])) 23 | final_synonyms = [] 24 | for i in pos: 25 | if pos_tag_word[0][1] == i[0][1]: 26 | final_synonyms.append(i[0][0]) 27 | final_synonyms = list(set(final_synonyms)) 28 | if final_synonyms == []: 29 | return word 30 | if word.istitle(): 31 | return random.choice(final_synonyms).title() 32 | else: 33 | return random.choice(final_synonyms) 34 | 35 | def plagiarism_removal(para): 36 | para_split = word_tokenize(para) 37 | final_text = [] 38 | for i in para_split: 39 | final_text.append(plagiarism_remover(i)) 40 | final_text = " ".join(final_text) 41 | return final_text 42 | 43 | import tkinter as tk 44 | from functools import partial 45 | def call_result(label_result, n): 46 | text = n.get() 47 | result = plagiarism_removal(text) 48 | label_result.config(text="Text after plagiarism removal is:\n %s" % result,wraplength=500) 49 | return 50 | root = tk.Tk() 51 | root.geometry('1000x1000') 52 | root.title('Plagiarism Removal') 53 | number1 = tk.StringVar() 54 | labelNum1 = tk.Label(root, text="Enter text to remove plagiarism") 55 | labelNum1.grid(row=1, column=0) 56 | labelResult = tk.Label(root) 57 | labelResult.grid(row=7, column=2) 58 | entryNum1 = tk.Entry(root, textvariable=number1) 59 | entryNum1.grid(row=1, column=2) 60 | call_result = partial(call_result, labelResult, number1) 61 | buttonCal = tk.Button(root, text="Remove Plagiarism", command=call_result) 62 | buttonCal.grid(row=3, column=0) 63 | root.mainloop() -------------------------------------------------------------------------------- /RecursionPrograms.py: -------------------------------------------------------------------------------- 1 | def factorial(n): 2 | if(n==1): 3 | return 1 4 | else: 5 | return n*factorial(n-1) 6 | 7 | n = int(input('Enter the number: ')) 8 | ans = factorial(n) 9 | print(ans) -------------------------------------------------------------------------------- /RockPaperScissors.py: -------------------------------------------------------------------------------- 1 | import random 2 | yourChoice = int(input("Enter your number: type 0 for Rock, type 1 for Paper and type 2 for scissors: ")) 3 | if(yourChoice >= 3 or yourChoice <0): 4 | print("Invalid number seclected") 5 | computerChoice = random.randint(0,2) 6 | print("Computer's choice is",computerChoice) 7 | 8 | if(yourChoice == computerChoice): 9 | print("Its a draw") 10 | elif(yourChoice == 0 and computerChoice == 2): 11 | print('You lose') 12 | elif(yourChoice == 2 and computerChoice == 1): 13 | print('You Win') 14 | elif(yourChoice > computerChoice): 15 | print('You Win') 16 | elif(yourChoice < computerChoice): 17 | print('You lose') 18 | 19 | -------------------------------------------------------------------------------- /SpeedTest.py: -------------------------------------------------------------------------------- 1 | import speedtest 2 | internetSpeed = speedtest.Speedtest() 3 | 4 | def bytesToMb(bytes): 5 | KB =1024 6 | MB = KB*1024 7 | return (bytes/MB) 8 | 9 | downloadSpeed = bytesToMb(internetSpeed.download()) 10 | uploadSpeed = bytesToMb(internetSpeed.upload()) 11 | 12 | print("Download speed: ",downloadSpeed,"MB") 13 | print("Upload speed: ",uploadSpeed,"MB") -------------------------------------------------------------------------------- /SpiralTraversing.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | 3 | tur = turtle.Turtle() 4 | for i in range(5): 5 | tur.forward(500) 6 | tur.right(144) 7 | 8 | 9 | turtle.done() -------------------------------------------------------------------------------- /SubstitutionCipher/SubstitutionCipher.py: -------------------------------------------------------------------------------- 1 | import string 2 | dict={} 3 | file = open('output.txt','w') 4 | 5 | for i in range(len(string.ascii_letters)): 6 | dict[string.ascii_letters[i]] = string.ascii_letters[i-1] 7 | print(dict) 8 | with open('input.txt') as f: 9 | while True: 10 | c = f.read(1) 11 | if not c: 12 | print("End of file") 13 | break 14 | if c in dict: 15 | data = dict[c] 16 | else: 17 | data = c 18 | file.write(data) 19 | print(data) 20 | file.close() -------------------------------------------------------------------------------- /SubstitutionCipher/input.txt: -------------------------------------------------------------------------------- 1 | hey there its nishant -------------------------------------------------------------------------------- /SubstitutionCipher/output.txt: -------------------------------------------------------------------------------- 1 | with open('') -------------------------------------------------------------------------------- /TheoryOfRevolution.py: -------------------------------------------------------------------------------- 1 | with open('file1.txt','w') as myfile: 2 | myfile.write('Hey I am a nice child') 3 | print(myfile) 4 | myfile.close() -------------------------------------------------------------------------------- /TicTacToe.py: -------------------------------------------------------------------------------- 1 | import numpy 2 | board = numpy.array([['-','-','-'],['-','-','-'],['-','-','-']]) 3 | p1s='X' 4 | p2s='O' 5 | 6 | def checkRows(symbol): 7 | for i in range(3): 8 | count = 0 9 | for j in range(3): 10 | board[i][j] == symbol 11 | count = count+1 12 | if count == 3: 13 | print(symbol,' won') 14 | return True 15 | return False 16 | 17 | def checkColumns(symbol): 18 | for i in range(3): 19 | count = 0 20 | for j in range(3): 21 | board[j][i] == symbol 22 | count = count+1 23 | if count == 3: 24 | print(symbol,' won') 25 | return True 26 | return False 27 | 28 | def checkDiagonals(symbol): 29 | count = 0 30 | for i in range(3): 31 | for j in range(3): 32 | if i == j: 33 | board[i][j] == symbol 34 | count = count+1 35 | else: 36 | return False 37 | if count == 3: 38 | print(symbol,' won') 39 | return True 40 | return False 41 | 42 | def won(symbol): 43 | return checkRows(symbol) or checkColumns(symbol) or checkDiagonals(symbol) 44 | 45 | def place(symbol): 46 | print(board) 47 | while(1): 48 | row = int(input('Enter the row 1 or 2 or 3: ')) 49 | column = int(input('Enter the column 1 or 2 or 3: ')) 50 | if row>0 and row<4 and column>0 and column<4 and board[row-1][column-1]=='-': 51 | break 52 | else: 53 | print('Invalid entry') 54 | board[row-1][column-1] = symbol 55 | 56 | 57 | def play(): 58 | for turn in range(9): 59 | if turn%2==0: 60 | print('X turn') 61 | place(p1s) 62 | if won(p1s): 63 | break 64 | 65 | else: 66 | print('O turn') 67 | place(p2s) 68 | if won(p2s): 69 | break 70 | 71 | if not (won(p1s)) and (won(p2s)): 72 | print('Its a draw') 73 | 74 | play() 75 | -------------------------------------------------------------------------------- /Tuples.py: -------------------------------------------------------------------------------- 1 | iceCream = ('vanilla','strawberry') 2 | for i in iceCream: 3 | print() -------------------------------------------------------------------------------- /__pycache__/SpeedTest.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nishant-Tiwari24/python-foundation-projects/95bb8c7e952772caf364bfe1e9cba53a35a8a0b6/__pycache__/SpeedTest.cpython-311.pyc -------------------------------------------------------------------------------- /chess game.py: -------------------------------------------------------------------------------- 1 | class ChessGame: 2 | def __init__(self): 3 | self.board = self.initialize_board() 4 | self.current_player = "white" 5 | 6 | def initialize_board(self): 7 | # Initialize an 8x8 board with pieces in their starting positions 8 | board = [] 9 | for i in range(8): 10 | row = [] 11 | for j in range(8): 12 | if i == 0: 13 | if j == 0 or j == 7: 14 | row.append("rook_black") 15 | elif j == 1 or j == 6: 16 | row.append("knight_black") 17 | elif j == 2 or j == 5: 18 | row.append("bishop_black") 19 | elif j == 3: 20 | row.append("queen_black") 21 | elif j == 4: 22 | row.append("king_black") 23 | elif i == 1: 24 | row.append("pawn_black") 25 | elif i == 6: 26 | row.append("pawn_white") 27 | elif i == 7: 28 | if j == 0 or j == 7: 29 | row.append("rook_white") 30 | elif j == 1 or j == 6: 31 | row.append("knight_white") 32 | elif j == 2 or j == 5: 33 | row.append("bishop_white") 34 | elif j == 3: 35 | row.append("queen_white") 36 | elif j == 4: 37 | row.append("king_white") 38 | else: 39 | row.append("empty") 40 | board.append(row) 41 | return board 42 | 43 | def print_board(self): 44 | print(" a b c d e f g h") 45 | for i, row in enumerate(self.board): 46 | print(i+1, end=" ") 47 | for piece in row: 48 | if piece == "empty": 49 | print("-", end=" ") 50 | else: 51 | print(piece[0].upper(), end=" ") 52 | print() 53 | 54 | def is_valid_move(self, start, end): 55 | # Check if the move is valid (e.g. piece can move to that square) 56 | # This is a very basic implementation, you would need to add more rules 57 | start_x, start_y = start 58 | end_x, end_y = end 59 | piece = self.board[start_x-1][start_y-1] 60 | if piece == "empty": 61 | return False 62 | if piece.endswith(self.current_player): 63 | if piece.startswith("pawn"): 64 | # Pawns can move forward one square, but capture diagonally 65 | if start_x == end_x and abs(start_y - end_y) == 1: 66 | return True 67 | elif start_y == end_y and abs(start_x - end_x) == 1: 68 | return True 69 | elif piece.startswith("knight"): 70 | # Knights move in an L-shape 71 | if abs(start_x - end_x) == 2 and abs(start_y - end_y) == 1: 72 | return True 73 | elif abs(start_x - end_x) == 1 and abs(start_y - end_y) == 2: 74 | return True 75 | # Add more rules for other pieces 76 | return False 77 | 78 | def make_move(self, start, end): 79 | if self.is_valid_move(start, end): 80 | start_x, start_y = start 81 | end_x, end_y = end 82 | piece = self.board[start_x-1][start_y-1] 83 | self.board[end_x-1][end_y-1] = piece 84 | self.board[start_x-1][start_y-1] = "empty" 85 | self.current_player = "black" if self.current_player == "white" else "white" 86 | else: 87 | print("Invalid move!") 88 | 89 | def play_game(self): 90 | while True: 91 | self.print_board() 92 | start = input("Enter start position (e.g. 1a): ") 93 | end = input("Enter end position (e.g. 2b): ") 94 | start_x = int(start[0]) 95 | start_y = ord(start[1]) - 96 96 | end_x = int(end[0]) 97 | end_y = ord(end[1]) - 96 98 | self.make_move((start_x, start_y), (end_x, end_y)) 99 | 100 | game = ChessGame() 101 | game.play_game() -------------------------------------------------------------------------------- /config/blacklist.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nishant-Tiwari24/python-foundation-projects/95bb8c7e952772caf364bfe1e9cba53a35a8a0b6/config/blacklist.txt -------------------------------------------------------------------------------- /config/comments.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nishant-Tiwari24/python-foundation-projects/95bb8c7e952772caf364bfe1e9cba53a35a8a0b6/config/comments.txt -------------------------------------------------------------------------------- /config/followed.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nishant-Tiwari24/python-foundation-projects/95bb8c7e952772caf364bfe1e9cba53a35a8a0b6/config/followed.txt -------------------------------------------------------------------------------- /config/friends.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nishant-Tiwari24/python-foundation-projects/95bb8c7e952772caf364bfe1e9cba53a35a8a0b6/config/friends.txt -------------------------------------------------------------------------------- /config/log/instabot_4297249872.log: -------------------------------------------------------------------------------- 1 | 2023-10-20 00:32:37,725 - instabot version: 0.117.0 (bot) - INFO - Instabot version: 0.117.0 Started 2 | 2023-10-20 00:32:37,725 - instabot version: 0.117.0 (bot) - DEBUG - Bot imported from /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/instabot/bot/bot.py 3 | 2023-10-20 00:32:37,725 - instabot version: 0.117.0 (api_login) - INFO - Not yet logged in starting: PRE-LOGIN FLOW! 4 | 2023-10-20 00:32:38,166 - instabot version: 0.117.0 (api) - DEBUG - POST to endpoint: accounts/get_prefill_candidates/ returned response: 5 | 2023-10-20 00:32:38,736 - instabot version: 0.117.0 (api) - DEBUG - POST to endpoint: qe/sync/ returned response: 6 | 2023-10-20 00:32:39,147 - instabot version: 0.117.0 (api) - DEBUG - POST to endpoint: launcher/sync/ returned response: 7 | 2023-10-20 00:32:39,570 - instabot version: 0.117.0 (api) - DEBUG - POST to endpoint: accounts/contact_point_prefill/ returned response: 8 | 2023-10-20 00:32:40,362 - instabot version: 0.117.0 (api) - DEBUG - POST to endpoint: accounts/login/ returned response: 9 | 2023-10-20 00:32:40,362 - instabot version: 0.117.0 (api) - DEBUG - Responsecode indicates error; response content: b'{"message":"The username you entered doesn\'t appear to belong to an account. Please check your username and try again.","status":"fail","error_title":"Incorrect username","buttons":[{"title":"Try Again","action":"dismiss"}],"invalid_credentials":true,"exception_name":"UserInvalidCredentials","error_type":"invalid_user"}' 10 | 2023-10-20 00:32:40,362 - instabot version: 0.117.0 (api) - ERROR - Request returns 400 error! 11 | 2023-10-20 00:32:40,362 - instabot version: 0.117.0 (api) - INFO - Instagram's error message: The username you entered doesn't appear to belong to an account. Please check your username and try again. 12 | 2023-10-20 00:32:40,363 - instabot version: 0.117.0 (api) - INFO - Error type: invalid_user 13 | 2023-10-20 00:32:40,363 - instabot version: 0.117.0 (api) - ERROR - Failed to login go to instagram and change your password 14 | 2023-10-20 00:32:40,363 - instabot version: 0.117.0 (api) - INFO - Username or password is incorrect. 15 | -------------------------------------------------------------------------------- /config/log/instabot_4339815440.log: -------------------------------------------------------------------------------- 1 | 2023-10-20 00:33:14,193 - instabot version: 0.117.0 (bot) - INFO - Instabot version: 0.117.0 Started 2 | 2023-10-20 00:33:14,193 - instabot version: 0.117.0 (bot) - DEBUG - Bot imported from /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/instabot/bot/bot.py 3 | 2023-10-20 00:33:14,193 - instabot version: 0.117.0 (api_login) - INFO - Not yet logged in starting: PRE-LOGIN FLOW! 4 | 2023-10-20 00:33:14,600 - instabot version: 0.117.0 (api) - DEBUG - POST to endpoint: accounts/get_prefill_candidates/ returned response: 5 | 2023-10-20 00:33:15,388 - instabot version: 0.117.0 (api) - DEBUG - POST to endpoint: qe/sync/ returned response: 6 | 2023-10-20 00:33:15,806 - instabot version: 0.117.0 (api) - DEBUG - POST to endpoint: launcher/sync/ returned response: 7 | 2023-10-20 00:33:16,225 - instabot version: 0.117.0 (api) - DEBUG - POST to endpoint: accounts/contact_point_prefill/ returned response: 8 | 2023-10-20 00:33:17,011 - instabot version: 0.117.0 (api) - DEBUG - POST to endpoint: accounts/login/ returned response: 9 | 2023-10-20 00:33:17,011 - instabot version: 0.117.0 (api) - DEBUG - Responsecode indicates error; response content: b'{"message":"The username you entered doesn\'t appear to belong to an account. Please check your username and try again.","status":"fail","error_title":"Incorrect username","buttons":[{"title":"Try Again","action":"dismiss"}],"invalid_credentials":true,"exception_name":"UserInvalidCredentials","error_type":"invalid_user"}' 10 | 2023-10-20 00:33:17,012 - instabot version: 0.117.0 (api) - ERROR - Request returns 400 error! 11 | 2023-10-20 00:33:17,012 - instabot version: 0.117.0 (api) - INFO - Instagram's error message: The username you entered doesn't appear to belong to an account. Please check your username and try again. 12 | 2023-10-20 00:33:17,012 - instabot version: 0.117.0 (api) - INFO - Error type: invalid_user 13 | 2023-10-20 00:33:17,012 - instabot version: 0.117.0 (api) - ERROR - Failed to login go to instagram and change your password 14 | 2023-10-20 00:33:17,012 - instabot version: 0.117.0 (api) - INFO - Username or password is incorrect. 15 | -------------------------------------------------------------------------------- /config/log/instabot_4365194256.log: -------------------------------------------------------------------------------- 1 | 2023-10-20 00:33:04,885 - instabot version: 0.117.0 (bot) - INFO - Instabot version: 0.117.0 Started 2 | 2023-10-20 00:33:04,885 - instabot version: 0.117.0 (bot) - DEBUG - Bot imported from /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/instabot/bot/bot.py 3 | 2023-10-20 00:33:04,885 - instabot version: 0.117.0 (api_login) - INFO - Not yet logged in starting: PRE-LOGIN FLOW! 4 | 2023-10-20 00:33:05,316 - instabot version: 0.117.0 (api) - DEBUG - POST to endpoint: accounts/get_prefill_candidates/ returned response: 5 | 2023-10-20 00:33:05,902 - instabot version: 0.117.0 (api) - DEBUG - POST to endpoint: qe/sync/ returned response: 6 | 2023-10-20 00:33:06,316 - instabot version: 0.117.0 (api) - DEBUG - POST to endpoint: launcher/sync/ returned response: 7 | 2023-10-20 00:33:06,772 - instabot version: 0.117.0 (api) - DEBUG - POST to endpoint: accounts/contact_point_prefill/ returned response: 8 | 2023-10-20 00:33:07,442 - instabot version: 0.117.0 (api) - DEBUG - POST to endpoint: accounts/login/ returned response: 9 | 2023-10-20 00:33:07,442 - instabot version: 0.117.0 (api) - DEBUG - Responsecode indicates error; response content: b'{"message":"The username you entered doesn\'t appear to belong to an account. Please check your username and try again.","status":"fail","error_title":"Incorrect username","buttons":[{"title":"Try Again","action":"dismiss"}],"invalid_credentials":true,"exception_name":"UserInvalidCredentials","error_type":"invalid_user"}' 10 | 2023-10-20 00:33:07,442 - instabot version: 0.117.0 (api) - ERROR - Request returns 400 error! 11 | 2023-10-20 00:33:07,442 - instabot version: 0.117.0 (api) - INFO - Instagram's error message: The username you entered doesn't appear to belong to an account. Please check your username and try again. 12 | 2023-10-20 00:33:07,442 - instabot version: 0.117.0 (api) - INFO - Error type: invalid_user 13 | 2023-10-20 00:33:07,442 - instabot version: 0.117.0 (api) - ERROR - Failed to login go to instagram and change your password 14 | 2023-10-20 00:33:07,442 - instabot version: 0.117.0 (api) - INFO - Username or password is incorrect. 15 | -------------------------------------------------------------------------------- /config/log/instabot_4370863184.log: -------------------------------------------------------------------------------- 1 | 2023-10-20 00:32:22,279 - instabot version: 0.117.0 (bot) - INFO - Instabot version: 0.117.0 Started 2 | 2023-10-20 00:32:22,279 - instabot version: 0.117.0 (bot) - DEBUG - Bot imported from /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/instabot/bot/bot.py 3 | 2023-10-20 00:32:22,280 - instabot version: 0.117.0 (api_login) - INFO - Not yet logged in starting: PRE-LOGIN FLOW! 4 | 2023-10-20 00:32:22,730 - instabot version: 0.117.0 (api) - DEBUG - POST to endpoint: accounts/get_prefill_candidates/ returned response: 5 | 2023-10-20 00:32:23,196 - instabot version: 0.117.0 (api) - DEBUG - POST to endpoint: qe/sync/ returned response: 6 | 2023-10-20 00:32:23,598 - instabot version: 0.117.0 (api) - DEBUG - POST to endpoint: launcher/sync/ returned response: 7 | 2023-10-20 00:32:24,004 - instabot version: 0.117.0 (api) - DEBUG - POST to endpoint: accounts/contact_point_prefill/ returned response: 8 | 2023-10-20 00:32:24,767 - instabot version: 0.117.0 (api) - DEBUG - POST to endpoint: accounts/login/ returned response: 9 | 2023-10-20 00:32:24,768 - instabot version: 0.117.0 (api) - DEBUG - Responsecode indicates error; response content: b'{"message":"The username you entered doesn\'t appear to belong to an account. Please check your username and try again.","status":"fail","error_title":"Incorrect username","buttons":[{"title":"Try Again","action":"dismiss"}],"invalid_credentials":true,"exception_name":"UserInvalidCredentials","error_type":"invalid_user"}' 10 | 2023-10-20 00:32:24,768 - instabot version: 0.117.0 (api) - ERROR - Request returns 400 error! 11 | 2023-10-20 00:32:24,768 - instabot version: 0.117.0 (api) - INFO - Instagram's error message: The username you entered doesn't appear to belong to an account. Please check your username and try again. 12 | 2023-10-20 00:32:24,768 - instabot version: 0.117.0 (api) - INFO - Error type: invalid_user 13 | 2023-10-20 00:32:24,768 - instabot version: 0.117.0 (api) - ERROR - Failed to login go to instagram and change your password 14 | 2023-10-20 00:32:24,768 - instabot version: 0.117.0 (api) - INFO - Username or password is incorrect. 15 | -------------------------------------------------------------------------------- /config/skipped.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nishant-Tiwari24/python-foundation-projects/95bb8c7e952772caf364bfe1e9cba53a35a8a0b6/config/skipped.txt -------------------------------------------------------------------------------- /config/unfollowed.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nishant-Tiwari24/python-foundation-projects/95bb8c7e952772caf364bfe1e9cba53a35a8a0b6/config/unfollowed.txt -------------------------------------------------------------------------------- /config/whitelist.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nishant-Tiwari24/python-foundation-projects/95bb8c7e952772caf364bfe1e9cba53a35a8a0b6/config/whitelist.txt -------------------------------------------------------------------------------- /dnaTest.txt: -------------------------------------------------------------------------------- 1 | 10001010101011001101010100101011011111011101111111000000100100011110101101101011001010001010101011001011010110101010011101010101001010111000000111101100011010110111101010101010101010101010101110000011100100101010101011 -------------------------------------------------------------------------------- /fibonacci turtle.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | t = turtle.Turtle() 3 | turtle.bgcolor("black") 4 | t.speed(0) 5 | colors = ["red", "yellow", "blue", "green", "purple", "orange"] 6 | for i in range(300): 7 | t.pencolor(colors[i%6]) 8 | t.forward(i*2) 9 | t.right(61) 10 | turtle.done() 11 | 12 | -------------------------------------------------------------------------------- /heart game.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | 3 | s = turtle.Screen() 4 | s.bgcolor('black') 5 | pen = turtle.Turtle() 6 | pen.speed(1) 7 | pen.color('red') 8 | pen.begin_fill() 9 | pen.fillcolor('red') 10 | pen.left(140) 11 | pen.forward(180) 12 | pen.circle(-90, 200) 13 | pen.setheading(60) 14 | pen.circle(-90, 200) 15 | pen.forward(180) 16 | pen.end_fill() 17 | pen.hideturtle() 18 | s.mainloop() -------------------------------------------------------------------------------- /jumbled.py: -------------------------------------------------------------------------------- 1 | import random 2 | name = input("What is your name? ") 3 | print("Good Luck ! ", name) 4 | print ("Guess the word") 5 | 6 | 7 | words = ['accept', 'acting', 'advice', 'beauty', 'python', 'before', 'player', 'beyond', 'artist', 'branch', 'boards', 'branch'] 8 | astrick = words.replace(words,"*" * len(words)) 9 | 10 | 11 | word = random.choice(words) 12 | 13 | 14 | print("Guess the characters") 15 | 16 | guesses = '' 17 | 18 | 19 | turns = 9000 20 | 21 | while turns > 0: 22 | 23 | 24 | failed = 0 25 | 26 | 27 | for char in word: 28 | 29 | 30 | if char in guesses: 31 | print(char) 32 | 33 | else: 34 | print("_") 35 | 36 | 37 | failed += 1 38 | 39 | 40 | if failed == 0: 41 | 42 | print("You Win") 43 | 44 | print("The word is: ", word) 45 | break 46 | 47 | guess = input("guess a character:") 48 | 49 | 50 | guesses += guess 51 | 52 | if guess not in word: 53 | 54 | turns -= 1 55 | 56 | 57 | print("Wrong") 58 | 59 | 60 | print("You have", + turns, 'more guesses') 61 | 62 | 63 | if turns == 0: 64 | print("You Loose") 65 | 66 | input ("press enter to continue") -------------------------------------------------------------------------------- /mymap.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Google Maps - gmplot 6 | 7 | 27 | 28 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /route.csv: -------------------------------------------------------------------------------- 1 | 28.689519,77.324495 -------------------------------------------------------------------------------- /test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nishant-Tiwari24/python-foundation-projects/95bb8c7e952772caf364bfe1e9cba53a35a8a0b6/test.png --------------------------------------------------------------------------------