├── speech2text ├── readme.md ├── speak.py └── webtext.py ├── space invaders ├── readme.md ├── enemy.gif ├── space.gif ├── explode.WAV ├── player.gif ├── laser_gun.wav └── spaceinvaders.py ├── car-game ├── readme.txt ├── README.md ├── car.jpg ├── cargamed.txt ├── car1.jpg ├── car2.jpg ├── car4.jpg ├── car5.jpg ├── car6.jpg ├── car7.jpg ├── strip.jpg ├── background.jpg ├── background2.jpg ├── yellow strip.jpg └── car.py ├── tictactoe ├── readme.md ├── o_img.png ├── x_img.jpg ├── cover_img.jpg └── tic_tac.py ├── shutdown.py ├── syteminfo.py ├── screenshot.py ├── copyfile.py ├── emojiuse.py ├── movefiles.py ├── openwebsites.py ├── youtubedownload.py ├── macaddress.py ├── beepsound.py ├── numpyiterate.py ├── spellcorrect.py ├── playmusic.py ├── progressbar.py ├── pranking.py ├── hangman ├── hung.txt ├── hang.py └── words.py ├── imdb.py ├── imgsize.py ├── calender.py ├── instadowload.py ├── googleit.py ├── timers.py ├── itertoolsperm.py ├── tryexcept.py ├── instabio.py ├── texttranslate.py ├── restart.py ├── whatsappmsg.py ├── cropimg.py ├── qr.py ├── resize.py ├── text2speech.py ├── pytoexe.txt ├── speech2text.py ├── sun.py ├── secondLargest.py ├── dataframe.py ├── email.py ├── temperature.py ├── dm counter ├── counter,py └── readme.txt ├── README.md ├── portscanner.py ├── percentageFinder.py ├── extract_img.py ├── chatbot.py ├── nestedlist.py ├── fibmemo.py ├── translator.py ├── pageviews.ipynb ├── calculator.py ├── passwordgenerate.ipynb ├── vowelsquare.py ├── iplscore.py ├── clock.ipynb ├── turtle.ipynb ├── covidtrack.ipynb ├── chatter.ipynb ├── hostip.ipynb ├── chromedino.ipynb ├── personalassistant.ipynb ├── rps.py ├── motiondetect.ipynb ├── snake.py ├── dinochrome.py ├── snapfilter.py ├── words.py ├── webscaper.ipynb └── LICENSE /speech2text/readme.md: -------------------------------------------------------------------------------- 1 | Using google API 2 | -------------------------------------------------------------------------------- /space invaders/readme.md: -------------------------------------------------------------------------------- 1 | A simple python game 2 | -------------------------------------------------------------------------------- /car-game/readme.txt: -------------------------------------------------------------------------------- 1 | A simple car game using pygame. 2 | -------------------------------------------------------------------------------- /tictactoe/readme.md: -------------------------------------------------------------------------------- 1 | Simple tictactoe game using pygame 2 | -------------------------------------------------------------------------------- /shutdown.py: -------------------------------------------------------------------------------- 1 | import os 2 | os.system("shutdown /s /t 1") 3 | -------------------------------------------------------------------------------- /syteminfo.py: -------------------------------------------------------------------------------- 1 | import os 2 | os.system('cmd /k "systemindo"') 3 | -------------------------------------------------------------------------------- /car-game/README.md: -------------------------------------------------------------------------------- 1 | # car-game 2 | A simple car game using pygame. 3 | -------------------------------------------------------------------------------- /screenshot.py: -------------------------------------------------------------------------------- 1 | import pyautogui as ptg 2 | ptg.screenshot('abc.jpg') 3 | -------------------------------------------------------------------------------- /copyfile.py: -------------------------------------------------------------------------------- 1 | import shutil 2 | shutil.copy(r"work.txt",r"C:\New Folder") 3 | -------------------------------------------------------------------------------- /emojiuse.py: -------------------------------------------------------------------------------- 1 | from emoji import emojise 2 | print(emojise(":thumbs_up:")) 3 | -------------------------------------------------------------------------------- /movefiles.py: -------------------------------------------------------------------------------- 1 | import shutil 2 | shutil.move(r"work.txt",r"C:\New folder") 3 | -------------------------------------------------------------------------------- /openwebsites.py: -------------------------------------------------------------------------------- 1 | import webbrowser 2 | 3 | url = "link" 4 | 5 | webbrowser.open(url) 6 | -------------------------------------------------------------------------------- /youtubedownload.py: -------------------------------------------------------------------------------- 1 | from pytube import YouTube 2 | YouTube("Link").streams.first().download() 3 | -------------------------------------------------------------------------------- /car-game/car.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandran-jr/Python-library-explore/HEAD/car-game/car.jpg -------------------------------------------------------------------------------- /car-game/cargamed.txt: -------------------------------------------------------------------------------- 1 | All files should be downloaded and saved in the same file as the program 2 | -------------------------------------------------------------------------------- /car-game/car1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandran-jr/Python-library-explore/HEAD/car-game/car1.jpg -------------------------------------------------------------------------------- /car-game/car2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandran-jr/Python-library-explore/HEAD/car-game/car2.jpg -------------------------------------------------------------------------------- /car-game/car4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandran-jr/Python-library-explore/HEAD/car-game/car4.jpg -------------------------------------------------------------------------------- /car-game/car5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandran-jr/Python-library-explore/HEAD/car-game/car5.jpg -------------------------------------------------------------------------------- /car-game/car6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandran-jr/Python-library-explore/HEAD/car-game/car6.jpg -------------------------------------------------------------------------------- /car-game/car7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandran-jr/Python-library-explore/HEAD/car-game/car7.jpg -------------------------------------------------------------------------------- /car-game/strip.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandran-jr/Python-library-explore/HEAD/car-game/strip.jpg -------------------------------------------------------------------------------- /macaddress.py: -------------------------------------------------------------------------------- 1 | from getmac import get_mac_address 2 | 3 | macadd = get_mac_address() 4 | print(macadd) 5 | -------------------------------------------------------------------------------- /tictactoe/o_img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandran-jr/Python-library-explore/HEAD/tictactoe/o_img.png -------------------------------------------------------------------------------- /tictactoe/x_img.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandran-jr/Python-library-explore/HEAD/tictactoe/x_img.jpg -------------------------------------------------------------------------------- /beepsound.py: -------------------------------------------------------------------------------- 1 | import winsound 2 | frequency = 2500 3 | duration = 2000 4 | winsound.beep(frequency,duration) 5 | -------------------------------------------------------------------------------- /numpyiterate.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | arr= np.array([1,2,3]) 4 | 5 | for x in arr: 6 | print(x) 7 | -------------------------------------------------------------------------------- /spellcorrect.py: -------------------------------------------------------------------------------- 1 | from textblob import TextBlob 2 | 3 | a = "Rpsitry" 4 | b = TextBlob(a) 5 | 6 | print(b) 7 | -------------------------------------------------------------------------------- /car-game/background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandran-jr/Python-library-explore/HEAD/car-game/background.jpg -------------------------------------------------------------------------------- /car-game/background2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandran-jr/Python-library-explore/HEAD/car-game/background2.jpg -------------------------------------------------------------------------------- /playmusic.py: -------------------------------------------------------------------------------- 1 | import playsound 2 | 3 | music = 'your music filename here.mp3' 4 | playsound.playsound(filename) 5 | -------------------------------------------------------------------------------- /space invaders/enemy.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandran-jr/Python-library-explore/HEAD/space invaders/enemy.gif -------------------------------------------------------------------------------- /space invaders/space.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandran-jr/Python-library-explore/HEAD/space invaders/space.gif -------------------------------------------------------------------------------- /tictactoe/cover_img.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandran-jr/Python-library-explore/HEAD/tictactoe/cover_img.jpg -------------------------------------------------------------------------------- /car-game/yellow strip.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandran-jr/Python-library-explore/HEAD/car-game/yellow strip.jpg -------------------------------------------------------------------------------- /progressbar.py: -------------------------------------------------------------------------------- 1 | from tdqm import tdqm 2 | from time import sleep 3 | 4 | for i in tdqm(range(12)): 5 | sleep(0.2) 6 | -------------------------------------------------------------------------------- /space invaders/explode.WAV: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandran-jr/Python-library-explore/HEAD/space invaders/explode.WAV -------------------------------------------------------------------------------- /space invaders/player.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandran-jr/Python-library-explore/HEAD/space invaders/player.gif -------------------------------------------------------------------------------- /space invaders/laser_gun.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandran-jr/Python-library-explore/HEAD/space invaders/laser_gun.wav -------------------------------------------------------------------------------- /pranking.py: -------------------------------------------------------------------------------- 1 | import webbrowser 2 | import time 3 | 4 | while True: 5 | webbrowser.open("Enter URL") 6 | time.sleep(2000) 7 | -------------------------------------------------------------------------------- /hangman/hung.txt: -------------------------------------------------------------------------------- 1 | This is a simple game and no GUI libraries were used 2 | 3 | Words.py should be run first as a different program 4 | -------------------------------------------------------------------------------- /imdb.py: -------------------------------------------------------------------------------- 1 | import imdb 2 | 3 | ia= imdb.IMDB() 4 | search = ia.get_top_250_movies() 5 | for i in range(10): 6 | print(search[i]) 7 | -------------------------------------------------------------------------------- /imgsize.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | 3 | image = Image.open("hulk.png") 4 | width,height = image.size 5 | 6 | print(width,height) 7 | -------------------------------------------------------------------------------- /calender.py: -------------------------------------------------------------------------------- 1 | import calender 2 | y = int(input("Enter the year: ")) 3 | m = int(input("Enter the month: ")) 4 | print(calender.month(y,m)) 5 | -------------------------------------------------------------------------------- /instadowload.py: -------------------------------------------------------------------------------- 1 | import webbrowser 2 | url = input("Enter the post url:") 3 | download = "savefrom.net/"+url 4 | webbrowser.open(download) 5 | -------------------------------------------------------------------------------- /googleit.py: -------------------------------------------------------------------------------- 1 | from googlesearch import search 2 | 3 | query="rohit sharma" 4 | 5 | for i in search(query, num=5,stop=5,pause=2): 6 | print(i) 7 | -------------------------------------------------------------------------------- /timers.py: -------------------------------------------------------------------------------- 1 | import threading 2 | 3 | def myFun(): 4 | print("Alarm ringing") 5 | 6 | timer = threading.Timer(5.0,myFun) 7 | timer.start() 8 | -------------------------------------------------------------------------------- /itertoolsperm.py: -------------------------------------------------------------------------------- 1 | import itertools 2 | 3 | data = ['a','b','c'] 4 | 5 | result = itertools.permutation(data) 6 | for res in result: 7 | print(res) 8 | -------------------------------------------------------------------------------- /tryexcept.py: -------------------------------------------------------------------------------- 1 | try: 2 | a= int(input("Enter a:")) 3 | b= int(input("Enter b:")) 4 | c=a/b 5 | 6 | except: 7 | print("Cant divide by zero") 8 | -------------------------------------------------------------------------------- /instabio.py: -------------------------------------------------------------------------------- 1 | import instaloader 2 | L= instaloader.Instaloader() 3 | profile = instaloader.Profile.from_username(L.context,'username') 4 | print(profile.biography) 5 | -------------------------------------------------------------------------------- /texttranslate.py: -------------------------------------------------------------------------------- 1 | from translate import Translator 2 | translator = Translator(to_lang="German") 3 | translation = translator.translate("I am Govind") 4 | print(translation) 5 | -------------------------------------------------------------------------------- /restart.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | choice = input("Restart your computer? y/n") 4 | 5 | if choice == 'y': 6 | os.system("shutdown /r") 7 | else: 8 | print("Operation cancelled") 9 | -------------------------------------------------------------------------------- /whatsappmsg.py: -------------------------------------------------------------------------------- 1 | import pywhatkit 2 | 3 | pywhatkit.send_file("the number u wanna send", "path of the file in your system", 15,00) 4 | 5 | #whatsapp web must be logged in before running 6 | -------------------------------------------------------------------------------- /cropimg.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | image=Image.new('RGBA',(1200,1200),'blue') 3 | image.save('blue.png') 4 | croppedImage=image.crop((300,300,500,500)) 5 | croppedImage.save('cropped.png') 6 | -------------------------------------------------------------------------------- /qr.py: -------------------------------------------------------------------------------- 1 | import qrcode 2 | 3 | qr= qrcode.make('Hello this is Govind B Chandran and heres a qr code i have made using this very simple code and the qrcode module.Happy coding :)') 4 | qr.save('myQR.png') 5 | -------------------------------------------------------------------------------- /resize.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | image=Image.open('pic.png') 3 | image = Image.open('pic.png') 4 | width,height= image.size 5 | image = image.resize(100,100) 6 | image.save(" Required Folder path") 7 | -------------------------------------------------------------------------------- /text2speech.py: -------------------------------------------------------------------------------- 1 | import speech_recognition as sr 2 | 3 | r = sr.Recognizer() 4 | with sr.Microphone() as source: 5 | print("Speak now: ") 6 | audio = r.listen(source) 7 | 8 | print(r.recognize_google(audio)) 9 | -------------------------------------------------------------------------------- /pytoexe.txt: -------------------------------------------------------------------------------- 1 | first install pyinstaller 2 | go to cmd 3 | type "pip install pyinstaller" 4 | pyinstaller filename.py 5 | go to filename.py location 6 | go to build at same location 7 | go to filename 8 | click on filename.exe 9 | -------------------------------------------------------------------------------- /speech2text.py: -------------------------------------------------------------------------------- 1 | import speech_recognition as sr 2 | 3 | r = sr.Recognizer() 4 | with sr.Microphone() as source: 5 | print("Speak now:") 6 | audio = r.listen(source) 7 | 8 | print(r.recognize_google(audio)) 9 | -------------------------------------------------------------------------------- /sun.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | turtle.color("red","yellow") 3 | turtle.begin_fill() 4 | turtle.speed(10) 5 | for i in range(50): 6 | turtle.forward(300) 7 | turtle.left(170) 8 | turtle.end_fill() 9 | turtle.done() 10 | -------------------------------------------------------------------------------- /secondLargest.py: -------------------------------------------------------------------------------- 1 | #program to find the second largest item in a list 2 | 3 | if __name__ == '__main__': 4 | n = int(input()) 5 | arr = map(int, input().split()) 6 | arr=list(set(arr)) 7 | arr.sort() 8 | print(arr[-2]) -------------------------------------------------------------------------------- /dataframe.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | 3 | data={'Name':['Ben','Govind','Mannu'], 4 | 'Age':['22','24','36'], 5 | 'Job':['Developer','Scientist','Designer'], 6 | 'Place':['Tvm','Canada','Uganda']} 7 | 8 | df = pd.DataFrame(data) 9 | print(df) 10 | -------------------------------------------------------------------------------- /email.py: -------------------------------------------------------------------------------- 1 | import smtplib 2 | 3 | email = smtplib.SMTB('smtp.gmail.com', 587) 4 | 5 | email.starttls() 6 | 7 | email.login("sender_email_id","sender_password") 8 | 9 | message = "the message" 10 | 11 | email.sendmail("sender_email_id", "reciever_email_id",message) 12 | 13 | email.quit() 14 | -------------------------------------------------------------------------------- /temperature.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from bs4 import BeautifulSoup 3 | 4 | search = "weather in India" 5 | 6 | url = f"https://www.google.com/search?&q={search}" 7 | 8 | r = requests.get(url) 9 | 10 | s = BeautifulSoup(r.text, "html.parser") 11 | 12 | update = s.find("div", class_ = "BNeawe").text 13 | 14 | print(update) 15 | -------------------------------------------------------------------------------- /dm counter/counter,py: -------------------------------------------------------------------------------- 1 | from google.colab import files 2 | files.upload() 3 | 4 | 5 | username = input() 6 | import json 7 | 8 | ndata = [] 9 | c=0 10 | with open('messages.json', encoding='utf-8') as mes: 11 | data = json.load(mes) 12 | for a in data: 13 | mes = a['conversation'] 14 | for x in mes: 15 | if (x['sender']==username) and ('text' in x): 16 | c=c+1 17 | 18 | print(c) 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python-mini-projects 2 | Some interesting python programs(not the basics). 3 | 4 | 5 | Import required libraries. 6 | 7 | Useful short programs. 8 | 9 | Implementable on programs. 10 | 11 | All required libraries must be installed before running the program 12 | 13 | Usually pip install libraryname works but its better to search the web. 14 | 15 | Some of them might be pre-installed if you're using anaconda 16 | 17 | -------------------------------------------------------------------------------- /portscanner.py: -------------------------------------------------------------------------------- 1 | importsocket 2 | 3 | def portscan: 4 | try: 5 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 6 | sock.connect((target,port)) 7 | return True 8 | except: 9 | return False 10 | 11 | 12 | for port in range(1,1024): 13 | result=portscan(port) 14 | if(result): 15 | print("Port {} is open!" .format(port)) 16 | else: 17 | print("Port {} is closed" .format(port)) 18 | -------------------------------------------------------------------------------- /speech2text/speak.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Apr 17 11:56:32 2020 4 | 5 | @author: govin 6 | """ 7 | 8 | from gtts import gTTS 9 | import pyglet 10 | import time, os 11 | 12 | def tts(text, lang): 13 | file = gTTS(text = text, lang = lang) 14 | filename = '/tmp/temp.mp3' 15 | file.save(filename) 16 | 17 | music = pyglet.media.load(filename, streaming = False) 18 | music.play() 19 | 20 | time.sleep(music.duration) 21 | os.remove(filename) 22 | -------------------------------------------------------------------------------- /percentageFinder.py: -------------------------------------------------------------------------------- 1 | """ . The user enters some integer followed by the names and marks for students. 2 | You are required to save the record in a dictionary data type. The user then enters a student's name. 3 | Output the average percentage marks obtained by that student, correct to two decimal places.""" 4 | 5 | N = int(input()) 6 | stud_dict = dict() 7 | 8 | for i in range(N): 9 | tmp = input().split(' ') 10 | name = tmp[0] 11 | stud_dict[name] = (float(tmp[1]), float(tmp[2]), float(tmp[3])) 12 | 13 | name = input() 14 | print('%.2f' % (sum(stud_dict[name]) / 3.0)) -------------------------------------------------------------------------------- /dm counter/readme.txt: -------------------------------------------------------------------------------- 1 | To view how many messages a user has DM'd you. 2 | 3 | Steps you need to do. 4 | 5 | Go to your instagram,settings,privacy,and request for a download of your account data. (Ps: This usually takes around 30 mins-2 hrs). 6 | 7 | An email will appear which will allow you to download your data, do it. 8 | 9 | Upload the "messages.json" file into your colab environment. 10 | 11 | Run the first cell of the program and upload the "messages.json" file. 12 | 13 | Run the second cell and enter the username of the person whose number of DM's you want. 14 | 15 | Run the third cell. 16 | 17 | Happy analyzing 😉. 18 | -------------------------------------------------------------------------------- /extract_img.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import os 3 | 4 | cam = cv2.VideoCapture("Video Path") 5 | try: 6 | if not os.path.exists('data'): 7 | os.makedirs('data') 8 | 9 | except OSError: 10 | print("Error: Creating directory data") 11 | 12 | currentframe = 0 13 | 14 | while True: 15 | ret,frame = cam.read() 16 | 17 | if ret: 18 | name = './data/frame' + str(currentframe) + '.jpg' 19 | print("Creating" + name) 20 | 21 | cv2.imwrite(name,frame) 22 | 23 | currentframe +=1 24 | 25 | else: 26 | break 27 | 28 | cam.release() 29 | cv2.destroyAllWindows() 30 | 31 | -------------------------------------------------------------------------------- /chatbot.py: -------------------------------------------------------------------------------- 1 | import speech_recognition as sr 2 | import pyttsx3 3 | import wikipedia 4 | 5 | def speak(string): 6 | eng = pyttsx3.init() 7 | eng.say(string) 8 | eng.runAndWait() 9 | 10 | def userInput(): 11 | r = sr.Recognizer() 12 | with sr.Microphone() as source: 13 | print("Listening...") 14 | audio = r.listen(source) 15 | query = r.recognize_google(audio) 16 | return query 17 | 18 | def out(): 19 | query = userInput().lower() 20 | result = wikipedia.summary(query, sentences=3) 21 | print(result) 22 | speak("According to wikipediaa") 23 | speak(result) 24 | 25 | speak("Hey there nitro here ask me anything") 26 | out() 27 | -------------------------------------------------------------------------------- /nestedlist.py: -------------------------------------------------------------------------------- 1 | """Given the names and grades for each student in a Physics class of students, store them in a nested list 2 | and print the name(s) of any student(s) having the second lowest grade.""" 3 | 4 | if __name__ == '__main__': 5 | score_list = {} 6 | for _ in range(int(input())): 7 | name = input() 8 | score = float(input()) 9 | if score in score_list: 10 | score_list[score].append(name) 11 | else: 12 | score_list[score] = [name] 13 | new_list = [] 14 | for i in score_list: 15 | new_list.append([i, score_list[i]]) 16 | new_list.sort() 17 | result = new_list[1][1] 18 | result.sort() 19 | for i in result: 20 | print (i) 21 | 22 | -------------------------------------------------------------------------------- /speech2text/webtext.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Apr 17 11:55:12 2020 4 | 5 | @author: govin 6 | """ 7 | 8 | import speech_recognition as sr 9 | import webbrowser as wb 10 | import speak 11 | 12 | chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s' 13 | 14 | r = sr.Recognizer() 15 | 16 | with sr.Microphone() as source: 17 | print ('Say Something!') 18 | audio = r.listen(source) 19 | print ('Done!') 20 | 21 | try: 22 | text = r.recognize_google(audio) 23 | print('Google thinks you said:\n' + text) 24 | lang = 'en' 25 | 26 | speak.tts(text, lang) 27 | 28 | f_text = 'https://www.google.co.in/search?q=' + text 29 | wb.get(chrome_path).open(f_text) 30 | 31 | except Exception as e: 32 | print (e) 33 | -------------------------------------------------------------------------------- /fibmemo.py: -------------------------------------------------------------------------------- 1 | fib_store = {} 2 | 3 | def fib(n): 4 | if n == 1: 5 | fib_store[n] = 0 6 | return 0 7 | 8 | elif n == 2: 9 | fib_store[n] = 1 10 | return 1 11 | 12 | else: 13 | fibl = 0 14 | fibr = 0 15 | 16 | if n-2 in fib_store.keys(): 17 | fibl = fib_store[n-2] 18 | 19 | else: 20 | fibl = fib(n-2) 21 | fib_store[n-2] = fibl 22 | 23 | if n-1 in fib_store.keys(): 24 | fibr = fib_store[n-1] 25 | 26 | else: 27 | fibr = fib(n-1) 28 | fib_store[n-1] = fibr 29 | return fibl + fibr 30 | 31 | 32 | n= input("Input n for the nth term required ") 33 | n= int(n) 34 | k= fib(n) 35 | print(k) 36 | -------------------------------------------------------------------------------- /translator.py: -------------------------------------------------------------------------------- 1 | from googletrans import Translator 2 | 3 | # taking some text from our website in french language 4 | text = '''Python est un langage de programmation interprété et de haut 5 | niveau qui a été créé à la fin des années 1980, mais il a été implémenté 6 | en décembre 1989 par Guido Van Rossum . Le mot Python vient du serpent. 7 | Selon la récente enquête de StackOverflow , Python a dépassé la popularité de Java''' 8 | 9 | # Creating an instance of Translator to use 10 | # Google Translate ajax API 11 | translator = Translator() 12 | 13 | # detect- auto detects language of the input text 14 | dt = translator.detect(text) 15 | print(dt) 16 | 17 | # translate()-translates the text from source language to destination language 18 | # translate(self, text, dest='en', src='auto', **kwargs) 19 | # if we don't specify the dest(destination language) then 20 | # it translates to english 21 | translated = translator.translate(text) 22 | 23 | print(translated.text 24 | -------------------------------------------------------------------------------- /pageviews.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "from selenium import webdriver\n", 10 | "import time\n", 11 | "\n", 12 | "driver - webdriver.Chrome(executable_path = \"C:\\Program Files (x86)\\Google\\Chrome\\chromedriver.exe\")\n", 13 | "\n", 14 | "driver.get(\"https://www.google.com/\")\n", 15 | "\n", 16 | "refreshrate = int(10)\n", 17 | "\n", 18 | "while True:\n", 19 | " time.sleep(refreshrate)\n", 20 | " driver.refresh()" 21 | ] 22 | } 23 | ], 24 | "metadata": { 25 | "kernelspec": { 26 | "display_name": "Python 3", 27 | "language": "python", 28 | "name": "python3" 29 | }, 30 | "language_info": { 31 | "codemirror_mode": { 32 | "name": "ipython", 33 | "version": 3 34 | }, 35 | "file_extension": ".py", 36 | "mimetype": "text/x-python", 37 | "name": "python", 38 | "nbconvert_exporter": "python", 39 | "pygments_lexer": "ipython3", 40 | "version": "3.7.3" 41 | } 42 | }, 43 | "nbformat": 4, 44 | "nbformat_minor": 2 45 | } 46 | -------------------------------------------------------------------------------- /calculator.py: -------------------------------------------------------------------------------- 1 | # Program to make a simple calculator 2 | 3 | # This function adds two numbers 4 | def add(x, y): 5 | return x + y 6 | 7 | # This function subtracts two numbers 8 | def subtract(x, y): 9 | return x - y 10 | 11 | # This function multiplies two numbers 12 | def multiply(x, y): 13 | return x * y 14 | 15 | # This function divides two numbers 16 | def divide(x, y): 17 | return x / y 18 | 19 | 20 | print("Select operation.") 21 | print("1.Add") 22 | print("2.Subtract") 23 | print("3.Multiply") 24 | print("4.Divide") 25 | 26 | while True: 27 | # Take input from the user 28 | choice = input("Enter choice(1/2/3/4): ") 29 | 30 | # Check if choice is one of the four options 31 | if choice in ('1', '2', '3', '4'): 32 | num1 = float(input("Enter first number: ")) 33 | num2 = float(input("Enter second number: ")) 34 | 35 | if choice == '1': 36 | print(num1, "+", num2, "=", add(num1, num2)) 37 | 38 | elif choice == '2': 39 | print(num1, "-", num2, "=", subtract(num1, num2)) 40 | 41 | elif choice == '3': 42 | print(num1, "*", num2, "=", multiply(num1, num2)) 43 | 44 | elif choice == '4': 45 | print(num1, "/", num2, "=", divide(num1, num2)) 46 | break 47 | else: 48 | print("Invalid Input") 49 | -------------------------------------------------------------------------------- /passwordgenerate.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 3, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import random" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 6, 15 | "metadata": {}, 16 | "outputs": [ 17 | { 18 | "name": "stdout", 19 | "output_type": "stream", 20 | "text": [ 21 | "v4KOED{Wsg2p\n" 22 | ] 23 | } 24 | ], 25 | "source": [ 26 | "lower = \"abcdefghijklmnopqrstuvwxyz\"\n", 27 | "upper = \"ABCDEFGHIJKLMOPQRSTUVWXYZ\"\n", 28 | "numbers = \"0123456789\"\n", 29 | "symbols = \"@[]{}*/,\"\n", 30 | "\n", 31 | "all = symbols + numbers + upper + lower\n", 32 | "\n", 33 | "length = 12\n", 34 | "\n", 35 | "password = \"\".join(random.sample(all,length))\n", 36 | "print(password)" 37 | ] 38 | } 39 | ], 40 | "metadata": { 41 | "kernelspec": { 42 | "display_name": "Python 3", 43 | "language": "python", 44 | "name": "python3" 45 | }, 46 | "language_info": { 47 | "codemirror_mode": { 48 | "name": "ipython", 49 | "version": 3 50 | }, 51 | "file_extension": ".py", 52 | "mimetype": "text/x-python", 53 | "name": "python", 54 | "nbconvert_exporter": "python", 55 | "pygments_lexer": "ipython3", 56 | "version": "3.7.3" 57 | } 58 | }, 59 | "nbformat": 4, 60 | "nbformat_minor": 2 61 | } 62 | -------------------------------------------------------------------------------- /vowelsquare.py: -------------------------------------------------------------------------------- 1 | def fn(l): 2 | for i in range(len(l)-1): 3 | for j in range(len(l[i])-1): 4 | k=[l[i][j],l[i][j+1],l[i+1][j],l[i+1][j+1]] 5 | if(set(k).issubset(v)): 6 | return i,j 7 | break 8 | return 'No' 9 | 10 | l=["aqrst", "ukaei", "ffooo"] 11 | v=['a','e','i','o','u'] 12 | v=set(v) 13 | 14 | print(fn(l)) 15 | 16 | 17 | ''' 18 | Vowel Square 19 | Have the function VowelSquare(strArr) 20 | take the strArr parameter being passed which will be a 2D matrix of some arbitrary size filled with letters from the alphabet, 21 | and determine if a 2x2 square composed entirely of vowels exists in the matrix. 22 | For example: strArr is ["abcd", "eikr", "oufj"] then this matrix looks like the following: 23 | a b c d 24 | e i k r 25 | o u f j 26 | Within this matrix there is a 2x2 square of vowels starting in the second row and first column, namely, ei, ou. 27 | If a 2x2 square of vowels is found your program should return the top-left position (row-column) of the square, 28 | so for this example your program should return 1-0. If no 2x2 square of vowels exists, then return the string not found. 29 | If there are multiple squares of vowels, return the one that is at the most top-left position in the whole matrix. 30 | The input matrix will at least be of size 2x2. 31 | Examples 32 | Input: ["aqrst", "ukaei", "ffooo"] 33 | Output: 1-2 34 | Input: ["gg", "ff"] 35 | Output: not found 36 | ''' 37 | -------------------------------------------------------------------------------- /iplscore.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | import requests 3 | from bs4 import BeautifulSoup 4 | 5 | root = Tk() 6 | root.title('IPL SCORE VIEWER') 7 | url = "https:www.cricbuzz.com" 8 | 9 | 10 | def getdata(data): 11 | team1,team2,team1_score,team2_score=data 12 | page = requests.gt(url) 13 | soup = BeautifulSoup(page.text, 'html.parser') 14 | team_1 = soup.find_all(class_ = "cb-ovr-flo cb-hmscg-tm-nm")[0].get_text() 15 | team_2 = soup.find_all(class_ = "cb-ovr-flo cb-hmscg-tm-nm")[1].get_text() 16 | 17 | team_1_score = soup.find_all(class_ = "cb-ovr-flo")[8].get_text() 18 | team_2_score = soup.find_all(class_ = "cb-ovr-flo")[10].get_text() 19 | team1.config(text = team_1) 20 | team2.config(text = team_2) 21 | team1_score.config(text=team_1_score) 22 | team2_score.config(text=team_2_score) 23 | 24 | a = Label(root,text='IPL Viewer', font=("",40)) 25 | a.grid(row=0,columnspan=2) 26 | team1 = Label(root,text="Team 1",font=("",20)) 27 | team1.grid(row=1,column=0) 28 | team2 = Label(root,text="Team 2",font=("",20)) 29 | team2.grid(row=1,column=1) 30 | 31 | team1_score = Label(root,text="hit refresh",font = ("", 20)) 32 | team1_score.grid(row=2,column=0) 33 | team2_score=Label(root,text="hit refresh", font=("", 20)) 34 | team2_score.grid(row=2,column=1) 35 | data = [team1,team2,team1_score,team2_score] 36 | refresh = Button(root,text = "Refresh",command = lambda:getdata(data), 37 | height=2,width=10,font=("",20)) 38 | refresh.grid(row=3,columnspan=2) 39 | root.mainloop() 40 | -------------------------------------------------------------------------------- /clock.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "#Creating a digital clock using tkinter" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 1, 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import sys\n", 19 | "from tkinter import *\n", 20 | "import time \n", 21 | "\n", 22 | "def times():\n", 23 | "\tcurrent_time=time.strftime(\"%H:%M:%S\") \n", 24 | "\tclock.config(text=current_time)\n", 25 | "\tclock.after(200,times)\n", 26 | "\n", 27 | "\n", 28 | "root=Tk()\n", 29 | "root.geometry(\"500x250\")\n", 30 | "clock=Label(root,font=(\"times\",50,\"bold\"),bg=\"white\")\n", 31 | "clock.grid(row=2,column=2,pady=25,padx=100)\n", 32 | "times()\n", 33 | "\n", 34 | "digi=Label(root,text=\"Digital clock\",font=\"times 24 bold\")\n", 35 | "digi.grid(row=0,column=2)\n", 36 | "\n", 37 | "nota=Label(root,text=\"hours minutes seconds \",font=\"times 15 bold\")\n", 38 | "nota.grid(row=3,column=2)\n", 39 | "\n", 40 | "root.mainloop()" 41 | ] 42 | } 43 | ], 44 | "metadata": { 45 | "kernelspec": { 46 | "display_name": "Python 3", 47 | "language": "python", 48 | "name": "python3" 49 | }, 50 | "language_info": { 51 | "codemirror_mode": { 52 | "name": "ipython", 53 | "version": 3 54 | }, 55 | "file_extension": ".py", 56 | "mimetype": "text/x-python", 57 | "name": "python", 58 | "nbconvert_exporter": "python", 59 | "pygments_lexer": "ipython3", 60 | "version": "3.7.3" 61 | } 62 | }, 63 | "nbformat": 4, 64 | "nbformat_minor": 2 65 | } 66 | -------------------------------------------------------------------------------- /turtle.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import turtle\n", 10 | "\n", 11 | "root= turtle.Turtle()\n", 12 | "\n", 13 | "root.up()\n", 14 | "root.goto(0, -100)\n", 15 | "root.down()\n", 16 | "\n", 17 | "\n", 18 | "root.begin_fill()\n", 19 | "\n", 20 | "root.fillcolor(\"yellow\")\n", 21 | "\n", 22 | "root.circle(100)\n", 23 | "\n", 24 | "root.end_fill()\n", 25 | "\n", 26 | "root.up()\n", 27 | "root.goto(-67, -40)\n", 28 | "root.setheading(-60)\n", 29 | "root.width(5)\n", 30 | "root.down()\n", 31 | "root.circle(80, 120)\n", 32 | "root.goto(-67, -40)\n", 33 | "root.fillcolor(\"black\")\n", 34 | "\n", 35 | "for i in range(-35,105,70):\n", 36 | " root.up()\n", 37 | " root.goto(i,35)\n", 38 | " root.setheading(0)\n", 39 | " root.down()\n", 40 | " root.begin_fill()\n", 41 | " root.circle(20)\n", 42 | " root.end_fill()\n", 43 | " \n", 44 | "turtle.mainloop()\n" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": null, 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [] 53 | } 54 | ], 55 | "metadata": { 56 | "kernelspec": { 57 | "display_name": "Python 3", 58 | "language": "python", 59 | "name": "python3" 60 | }, 61 | "language_info": { 62 | "codemirror_mode": { 63 | "name": "ipython", 64 | "version": 3 65 | }, 66 | "file_extension": ".py", 67 | "mimetype": "text/x-python", 68 | "name": "python", 69 | "nbconvert_exporter": "python", 70 | "pygments_lexer": "ipython3", 71 | "version": "3.7.3" 72 | } 73 | }, 74 | "nbformat": 4, 75 | "nbformat_minor": 2 76 | } 77 | -------------------------------------------------------------------------------- /covidtrack.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "#Live Covid Activity Tracker in each country" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": null, 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "from covid import Covid" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 2, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "covid = Covid()" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": 3, 33 | "metadata": {}, 34 | "outputs": [], 35 | "source": [ 36 | "country = covid.get_status_by_country_name(\"india\")\n", 37 | "data = {\n", 38 | " key : country[key]\n", 39 | " for key in country.keys() and {\n", 40 | " 'confirmed','active','deaths','recovered'\n", 41 | " }\n", 42 | "}\n", 43 | "\n" 44 | ] 45 | }, 46 | { 47 | "cell_type": "code", 48 | "execution_count": 4, 49 | "metadata": {}, 50 | "outputs": [ 51 | { 52 | "name": "stdout", 53 | "output_type": "stream", 54 | "text": [ 55 | "{'active': 58864, 'recovered': 39233, 'confirmed': 101261, 'deaths': 3164}\n" 56 | ] 57 | } 58 | ], 59 | "source": [ 60 | "print(data)" 61 | ] 62 | } 63 | ], 64 | "metadata": { 65 | "kernelspec": { 66 | "display_name": "Python 3", 67 | "language": "python", 68 | "name": "python3" 69 | }, 70 | "language_info": { 71 | "codemirror_mode": { 72 | "name": "ipython", 73 | "version": 3 74 | }, 75 | "file_extension": ".py", 76 | "mimetype": "text/x-python", 77 | "name": "python", 78 | "nbconvert_exporter": "python", 79 | "pygments_lexer": "ipython3", 80 | "version": "3.7.3" 81 | } 82 | }, 83 | "nbformat": 4, 84 | "nbformat_minor": 2 85 | } 86 | -------------------------------------------------------------------------------- /chatter.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "chatter.ipynb", 7 | "provenance": [] 8 | }, 9 | "kernelspec": { 10 | "name": "python3", 11 | "display_name": "Python 3" 12 | } 13 | }, 14 | "cells": [ 15 | { 16 | "cell_type": "code", 17 | "metadata": { 18 | "id": "-zCwqgCf56iN", 19 | "colab_type": "code", 20 | "colab": {} 21 | }, 22 | "source": [ 23 | "from nltk.chat.util import Chat, reflections" 24 | ], 25 | "execution_count": 1, 26 | "outputs": [] 27 | }, 28 | { 29 | "cell_type": "code", 30 | "metadata": { 31 | "id": "cvMKrhoq6Ony", 32 | "colab_type": "code", 33 | "colab": {} 34 | }, 35 | "source": [ 36 | "pairs = [\n", 37 | " ['my name is (.*)', ['hi %1']],\n", 38 | " ['(hi|hello|hey|hola)',['hey there','hi there','hiya']],\n", 39 | " ['(.*) is amazing',['%1 is pretty amazing']],\n", 40 | "]\n" 41 | ], 42 | "execution_count": null, 43 | "outputs": [] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "metadata": { 48 | "id": "bstofPnK7UIt", 49 | "colab_type": "code", 50 | "colab": { 51 | "base_uri": "https://localhost:8080/", 52 | "height": 137 53 | }, 54 | "outputId": "6acf656f-0d7d-4d46-c11c-49f691fb7f03" 55 | }, 56 | "source": [ 57 | "chat = Chat(pairs, reflections)\n", 58 | "chat.converse()" 59 | ], 60 | "execution_count": null, 61 | "outputs": [ 62 | { 63 | "output_type": "stream", 64 | "text": [ 65 | ">hey\n", 66 | "hiya\n", 67 | ">hola\n", 68 | "hey there\n", 69 | ">my name is govind\n", 70 | "hi govind\n" 71 | ], 72 | "name": "stdout" 73 | } 74 | ] 75 | } 76 | ] 77 | } -------------------------------------------------------------------------------- /hostip.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "#Finding hostname and IP Adress\n", 10 | "import socket" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "metadata": {}, 17 | "outputs": [], 18 | "source": [ 19 | "hostname = socket.gethostname()" 20 | ] 21 | }, 22 | { 23 | "cell_type": "code", 24 | "execution_count": 3, 25 | "metadata": {}, 26 | "outputs": [], 27 | "source": [ 28 | "ip = socket.gethostbyname(hostname)" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": 10, 34 | "metadata": {}, 35 | "outputs": [ 36 | { 37 | "name": "stdout", 38 | "output_type": "stream", 39 | "text": [ 40 | "Host name is\n", 41 | "chandranjr235\n" 42 | ] 43 | } 44 | ], 45 | "source": [ 46 | "print(\"Host name is\" )\n", 47 | "print(hostname)" 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": 11, 53 | "metadata": {}, 54 | "outputs": [ 55 | { 56 | "name": "stdout", 57 | "output_type": "stream", 58 | "text": [ 59 | "IP Adress is\n", 60 | "192.168.56.1\n" 61 | ] 62 | } 63 | ], 64 | "source": [ 65 | "print(\"IP Adress is\")\n", 66 | "print(ip)" 67 | ] 68 | }, 69 | { 70 | "cell_type": "code", 71 | "execution_count": null, 72 | "metadata": {}, 73 | "outputs": [], 74 | "source": [] 75 | } 76 | ], 77 | "metadata": { 78 | "kernelspec": { 79 | "display_name": "Python 3", 80 | "language": "python", 81 | "name": "python3" 82 | }, 83 | "language_info": { 84 | "codemirror_mode": { 85 | "name": "ipython", 86 | "version": 3 87 | }, 88 | "file_extension": ".py", 89 | "mimetype": "text/x-python", 90 | "name": "python", 91 | "nbconvert_exporter": "python", 92 | "pygments_lexer": "ipython3", 93 | "version": "3.7.3" 94 | } 95 | }, 96 | "nbformat": 4, 97 | "nbformat_minor": 2 98 | } 99 | -------------------------------------------------------------------------------- /chromedino.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import pyautogui" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": null, 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "from PIL import Image,ImageGrab" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": null, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "import time" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": null, 33 | "metadata": {}, 34 | "outputs": [], 35 | "source": [ 36 | "def screenshot():\n", 37 | " img= ImageGrab.grab().convert('L')\n", 38 | " return img\n", 39 | "\n", 40 | "def press(key):\n", 41 | " pyautogui.keyDown(key)\n", 42 | " return\n", 43 | "\n", 44 | "def detect(data):\n", 45 | " for i in range(485,525):\n", 46 | " for j in range(220,260):\n", 47 | " if data[i,j]<100:\n", 48 | " press('up')\n", 49 | " return \n", 50 | " \n", 51 | " \n", 52 | "press('up')\n", 53 | "time.sleep(2)\n", 54 | "while True:\n", 55 | " img=screenshot()\n", 56 | " data=img.load()\n", 57 | " detect(data)" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": null, 63 | "metadata": {}, 64 | "outputs": [], 65 | "source": [] 66 | } 67 | ], 68 | "metadata": { 69 | "kernelspec": { 70 | "display_name": "Python 3", 71 | "language": "python", 72 | "name": "python3" 73 | }, 74 | "language_info": { 75 | "codemirror_mode": { 76 | "name": "ipython", 77 | "version": 3 78 | }, 79 | "file_extension": ".py", 80 | "mimetype": "text/x-python", 81 | "name": "python", 82 | "nbconvert_exporter": "python", 83 | "pygments_lexer": "ipython3", 84 | "version": "3.7.3" 85 | } 86 | }, 87 | "nbformat": 4, 88 | "nbformat_minor": 2 89 | } 90 | -------------------------------------------------------------------------------- /personalassistant.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 2, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import speech_recognition as sr\n", 10 | "import pyttsx3\n", 11 | "import wikipedia" 12 | ] 13 | }, 14 | { 15 | "cell_type": "code", 16 | "execution_count": 12, 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "name": "stdout", 21 | "output_type": "stream", 22 | "text": [ 23 | "Listening...\n", 24 | "Virat Kohli (pronunciation ; born 5 November 1988) is an Indian cricketer who currently captains the India national team. A right-handed top-order batsman, Kohli is regarded as one of the best batsmen in the world. He plays for Royal Challengers Bangalore in the Indian Premier League (IPL), and has been the team's captain since 2013.\n" 25 | ] 26 | } 27 | ], 28 | "source": [ 29 | "def speak(string):\n", 30 | " eng = pyttsx3.init()\n", 31 | " eng.say(string)\n", 32 | " eng.runAndWait()\n", 33 | " \n", 34 | "def userInput():\n", 35 | " r = sr.Recognizer()\n", 36 | " with sr.Microphone() as source:\n", 37 | " print(\"Listening...\")\n", 38 | " audio = r.listen(source)\n", 39 | " query = r.recognize_google(audio)\n", 40 | " return query\n", 41 | "\n", 42 | "def out():\n", 43 | " query = userInput().lower()\n", 44 | " result = wikipedia.summary(query, sentences=3)\n", 45 | " print(result)\n", 46 | " speak(\"According to wikipediaa\")\n", 47 | " speak(result)\n", 48 | " \n", 49 | "speak(\"Hey there nitro here ask me anything\")\n", 50 | "out()" 51 | ] 52 | } 53 | ], 54 | "metadata": { 55 | "kernelspec": { 56 | "display_name": "Python 3", 57 | "language": "python", 58 | "name": "python3" 59 | }, 60 | "language_info": { 61 | "codemirror_mode": { 62 | "name": "ipython", 63 | "version": 3 64 | }, 65 | "file_extension": ".py", 66 | "mimetype": "text/x-python", 67 | "name": "python", 68 | "nbconvert_exporter": "python", 69 | "pygments_lexer": "ipython3", 70 | "version": "3.7.3" 71 | } 72 | }, 73 | "nbformat": 4, 74 | "nbformat_minor": 2 75 | } 76 | -------------------------------------------------------------------------------- /rps.py: -------------------------------------------------------------------------------- 1 | import random 2 | computer_score=0 3 | user_score=0 4 | 5 | while True: 6 | option=['stone','paper','scissors'] 7 | a=random.choice(option) 8 | user_input=input("Enter your choice 1.Stone 2.Paper 3.Scissors Press q to exit \n") 9 | 10 | if user_input.isdigit()==True: 11 | user_input=int(user_input) 12 | if option[user_input-1]==a: 13 | print("draw game") 14 | computer_score,user_score=computer_score,user_score 15 | print("Computer score:",computer_score, " User score:", user_score ) 16 | elif option[user_input-1]=='stone': 17 | if a=='paper': 18 | computer_score=computer_score+1 19 | print("Computer wins") 20 | print("Computer score:",computer_score, " User score:", user_score ) 21 | print(" ") 22 | elif a=='scissors': 23 | user_score=user_score+1 24 | print("User wins") 25 | print("Computer score:",computer_score, " User score:", user_score ) 26 | print(" ") 27 | elif option[user_input-1]=='paper': 28 | if a=='scissors': 29 | computer_score=computer_score+1 30 | print("Computer wins") 31 | print("Computer score:",computer_score, " User score:", user_score ) 32 | print(" ") 33 | elif a=='stone': 34 | user_score=user_score+1 35 | print("User wins") 36 | print("Computer score:",computer_score, " User score:", user_score ) 37 | print(" ") 38 | elif option[user_input-1]=='scissors': 39 | if a=='stone': 40 | computer_score=computer_score+1 41 | print("Computer wins") 42 | print("Computer score:",computer_score, " User score:", user_score ) 43 | print(" ") 44 | elif a=='paper': 45 | user_score=user_score+1 46 | print("User wins") 47 | print("Computer score:",computer_score, " User score:", user_score ) 48 | print(" ") 49 | elif user_input.isdigit()==False: 50 | if str(user_input=='q'): 51 | print("final score") 52 | print(" ") 53 | print("Computer score:",computer_score, " User score:", user_score ) 54 | 1 quit() 55 | else: 56 | print("Invalid input sorry") 57 | -------------------------------------------------------------------------------- /motiondetect.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 2, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import cv2" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 3, 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import time" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": null, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "firstfr= None\n", 28 | "\n", 29 | "video=cv2.VideoCapture(0)\n", 30 | "\n", 31 | "while True:\n", 32 | " check,frame=video.read()\n", 33 | " \n", 34 | " gray=cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)\n", 35 | " gray=cv2.GaussianBlur(gray,(21,21),0)\n", 36 | " \n", 37 | " if firstfr is None:\n", 38 | " firstfr=gray\n", 39 | " continue\n", 40 | " delta_frame = cv2.absdiff(firstfr,gray)\n", 41 | " thresh_delta = cv2.threshold(delta_frame,30,255,cv2.THRESH_BINARY)[1]\n", 42 | " thresh_delta = cv2.dilate(thresh_delta,None,iterations=0)\n", 43 | " (_,cnts,_) = cv2.findContours(thresh_delta.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)\n", 44 | " \n", 45 | " for contour in thresh_delta:\n", 46 | " if cv.contourArea(contour) < 1000:\n", 47 | " continue\n", 48 | " \n", 49 | " (x,y,w,h) = cv2.boundingRect(contour)\n", 50 | " cv2.rectangle(frame,(x,y),(x+w,y+h),(0,255,0),3)\n", 51 | " \n", 52 | " cv2.imshow('frame',frame)\n", 53 | " cv2.imshow('Capturing',gray)\n", 54 | " cv2.imshow('delta',delta_frame)\n", 55 | " cv2.imshow('thresh',thresh_delta)\n", 56 | " \n", 57 | " key = cv2.waitKey(1)\n", 58 | " \n", 59 | " if key == ord('q'):\n", 60 | " break\n", 61 | " \n", 62 | " video.release()\n", 63 | " \n", 64 | " cv2.destroyAllWindows()" 65 | ] 66 | } 67 | ], 68 | "metadata": { 69 | "kernelspec": { 70 | "display_name": "Python 3", 71 | "language": "python", 72 | "name": "python3" 73 | }, 74 | "language_info": { 75 | "codemirror_mode": { 76 | "name": "ipython", 77 | "version": 3 78 | }, 79 | "file_extension": ".py", 80 | "mimetype": "text/x-python", 81 | "name": "python", 82 | "nbconvert_exporter": "python", 83 | "pygments_lexer": "ipython3", 84 | "version": "3.7.3" 85 | } 86 | }, 87 | "nbformat": 4, 88 | "nbformat_minor": 2 89 | } 90 | -------------------------------------------------------------------------------- /snake.py: -------------------------------------------------------------------------------- 1 | import pygame 2 | import sys 3 | import random 4 | 5 | class Snake(object): 6 | def __init__(self): 7 | self.length = 1 8 | self.positions = [((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2))] 9 | self.direction = random.choice([UP, DOWN, LEFT, RIGHT]) 10 | self.color = (17, 24, 47) 11 | 12 | def get_head_position(self): 13 | return self.positions[0] 14 | 15 | def turn(self, point): 16 | if self.length > 1 and (point[0] * -1, point[1] * -1) == self.direction: 17 | return 18 | else: 19 | self.direction = point 20 | 21 | def move(self): 22 | cur = self.get_head_position() 23 | x, y = self.direction 24 | new = (((cur[0] + (x*GRIDSIZE)) % SCREEN_WIDTH), (cur[1] + (y*GRIDSIZE)) % SCREEN_HEIGHT) 25 | if len(self.positions) > 2 and new in self.positions[2:]: 26 | self.reset() 27 | else: 28 | self.positions.insert(0, new) 29 | if len(self.positions) > self.length: 30 | self.positions.pop() 31 | 32 | def reset(self): 33 | self.length = 1 34 | self.positions = [((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2))] 35 | self.direction = random.choice([UP, DOWN, LEFT, RIGHT]) 36 | 37 | def draw(self, surface): 38 | for p in self.positions: 39 | r = pygame.Rect((p[0], p[1]), (GRIDSIZE, GRIDSIZE)) 40 | pygame.draw.rect(surface, self.color, r) 41 | pygame.draw.rect(surface, (93, 216, 228), r, 1) 42 | 43 | def handle_keys(self): 44 | for event in pygame.event.get(): 45 | if event.type == pygame.QUIT: 46 | pygame.quit() 47 | sys.exit() 48 | elif event.type == pygame.KEYDOWN: 49 | if event.key == pygame.K_UP: 50 | self.turn(UP) 51 | elif event.key == pygame.K_DOWN: 52 | self.turn(DOWN) 53 | elif event.key == pygame.K_LEFT: 54 | self.turn(LEFT) 55 | elif event.key == pygame.K_RIGHT: 56 | self.turn(RIGHT) 57 | 58 | class Food(object): 59 | def __init__(self): 60 | self.position = (0, 0) 61 | self.color = (233, 163, 49) 62 | self.randomize_position() 63 | 64 | def randomize_position(self): 65 | self.position = (random.randint(0, GRID_WIDTH-1) * GRIDSIZE, random.randint(0, GRID_HEIGHT-1) * GRIDSIZE) 66 | 67 | def draw(self, surface): 68 | r = pygame.Rect((self.position[0], self.position[1]), (GRIDSIZE, GRIDSIZE)) 69 | pygame.draw.rect(surface, self.color, r) 70 | pygame.draw.rect(surface, (93, 216, 228), r, 1) 71 | 72 | def drawGrid(surface): 73 | for y in range(0, int(GRID_HEIGHT)): 74 | for x in range(0, int(GRID_WIDTH)): 75 | if (x + y) % 2 == 0: 76 | r = pygame.Rect((x*GRIDSIZE, y*GRIDSIZE), (GRIDSIZE, GRIDSIZE)) 77 | pygame.draw.rect(surface, (93, 216, 228), r) 78 | else: 79 | rr = pygame.Rect((x*GRIDSIZE, y*GRIDSIZE), (GRIDSIZE, GRIDSIZE)) 80 | pygame.draw.rect(surface, (84, 194, 205), rr) 81 | 82 | SCREEN_WIDTH = 480 83 | SCREEN_HEIGHT = 480 84 | 85 | GRIDSIZE = 20 86 | GRID_WIDTH = SCREEN_WIDTH / GRIDSIZE 87 | GRID_HEIGHT = SCREEN_HEIGHT / GRIDSIZE 88 | 89 | UP = (0, -1) 90 | DOWN = (0, 1) 91 | LEFT = (-1, 0) 92 | RIGHT = (1, 0) 93 | 94 | def main(): 95 | pygame.init() 96 | 97 | clock = pygame.time.Clock() 98 | screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT), 0, 32) 99 | 100 | surface = pygame.Surface(screen.get_size()) 101 | surface = surface.convert() 102 | drawGrid(surface) 103 | 104 | snake = Snake() 105 | food = Food() 106 | 107 | while True: 108 | clock.tick(10) 109 | snake.handle_keys() 110 | drawGrid(surface) 111 | snake.move() 112 | if snake.get_head_position() == food.position: 113 | snake.length += 1 114 | food.randomize_position() 115 | snake.draw(surface) 116 | food.draw(surface) 117 | screen.blit(surface, (0,0)) 118 | pygame.display.update() 119 | 120 | main() 121 | -------------------------------------------------------------------------------- /dinochrome.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import cv2 3 | 4 | import math 5 | import pyautogui 6 | 7 | 8 | # Open Camera 9 | capture = cv2.VideoCapture(0) 10 | 11 | while capture.isOpened(): 12 | 13 | # Capture frames from the camera 14 | ret, frame = capture.read() 15 | 16 | # Get hand data from the rectangle sub window 17 | cv2.rectangle(frame, (100, 100), (300, 300), (0, 255, 0), 0) 18 | crop_image = frame[100:300, 100:300] 19 | 20 | # Apply Gaussian blur 21 | blur = cv2.GaussianBlur(crop_image, (3, 3), 0) 22 | 23 | # Change color-space from BGR -> HSV 24 | hsv = cv2.cvtColor(blur, cv2.COLOR_BGR2HSV) 25 | 26 | # Create a binary image with where white will be skin colors and rest is black 27 | mask2 = cv2.inRange(hsv, np.array([2, 0, 0]), np.array([20, 255, 255])) 28 | 29 | # Kernel for morphological transformation 30 | kernel = np.ones((5, 5)) 31 | 32 | # Apply morphological transformations to filter out the background noise 33 | dilation = cv2.dilate(mask2, kernel, iterations=1) 34 | erosion = cv2.erode(dilation, kernel, iterations=1) 35 | 36 | # Apply Gaussian Blur and Threshold 37 | filtered = cv2.GaussianBlur(erosion, (3, 3), 0) 38 | ret, thresh = cv2.threshold(filtered, 127, 255, 0) 39 | ##### 40 | # Find contours 41 | #image, contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) 42 | contours, hierachy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) 43 | 44 | try: 45 | # Find contour with maximum area 46 | contour = max(contours, key=lambda x: cv2.contourArea(x)) 47 | 48 | # Create bounding rectangle around the contour 49 | x, y, w, h = cv2.boundingRect(contour) 50 | cv2.rectangle(crop_image, (x, y), (x + w, y + h), (0, 0, 255), 0) 51 | 52 | # Find convex hull 53 | hull = cv2.convexHull(contour) 54 | 55 | # Draw contour 56 | drawing = np.zeros(crop_image.shape, np.uint8) 57 | cv2.drawContours(drawing, [contour], -1, (0, 255, 0), 0) 58 | cv2.drawContours(drawing, [hull], -1, (0, 0, 255), 0) 59 | 60 | # Fi convexity defects 61 | hull = cv2.convexHull(contour, returnPoints=False) 62 | defects = cv2.convexityDefects(contour, hull) 63 | 64 | # Use cosine rule to find angle of the far point from the start and end point i.e. the convex points (the finger 65 | # tips) for all defects 66 | count_defects = 0 67 | 68 | for i in range(defects.shape[0]): 69 | s, e, f, d = defects[i, 0] 70 | start = tuple(contour[s][0]) 71 | end = tuple(contour[e][0]) 72 | far = tuple(contour[f][0]) 73 | 74 | a = math.sqrt((end[0] - start[0]) ** 2 + (end[1] - start[1]) ** 2) 75 | b = math.sqrt((far[0] - start[0]) ** 2 + (far[1] - start[1]) ** 2) 76 | c = math.sqrt((end[0] - far[0]) ** 2 + (end[1] - far[1]) ** 2) 77 | angle = (math.acos((b ** 2 + c ** 2 - a ** 2) / (2 * b * c)) * 180) / 3.14 78 | 79 | # if angle >= 90 draw a circle at the far point 80 | if angle <= 90: 81 | count_defects += 1 82 | cv2.circle(crop_image, far, 1, [0, 0, 255], -1) 83 | 84 | cv2.line(crop_image, start, end, [0, 255, 0], 2) 85 | 86 | # Press SPACE if condition is match 87 | 88 | if count_defects >= 4: 89 | pyautogui.press('space') 90 | cv2.putText(frame, "JUMP", (115, 80), cv2.FONT_HERSHEY_SIMPLEX, 2, 2, 2) 91 | 92 | #PLAY RACING GAMES (WASD) 93 | """ 94 | if count_defects == 1: 95 | pyautogui.press('w') 96 | cv2.putText(frame, "W", (115, 80), cv2.FONT_HERSHEY_SIMPLEX, 2, 2, 2) 97 | if count_defects == 2: 98 | pyautogui.press('s') 99 | cv2.putText(frame, "S", (115, 80), cv2.FONT_HERSHEY_SIMPLEX, 2, 2, 2) 100 | if count_defects == 3: 101 | pyautogui.press('aw') 102 | cv2.putText(frame, "aw", (115, 80), cv2.FONT_HERSHEY_SIMPLEX, 2, 2, 2) 103 | if count_defects == 4: 104 | pyautogui.press('dw') 105 | cv2.putText(frame, "dw", (115, 80), cv2.FONT_HERSHEY_SIMPLEX, 2, 2, 2) 106 | if count_defects == 5: 107 | pyautogui.press('s') 108 | cv2.putText(frame, "s", (115, 80), cv2.FONT_HERSHEY_SIMPLEX, 2, 2, 2) 109 | """ 110 | 111 | except: 112 | pass 113 | 114 | # Show required images 115 | cv2.imshow("Gesture", frame) 116 | 117 | # Close the camera if 'q' is pressed 118 | if cv2.waitKey(1) == ord('q'): 119 | break 120 | 121 | capture.release() 122 | cv2.destroyAllWindows() 123 | -------------------------------------------------------------------------------- /hangman/hang.py: -------------------------------------------------------------------------------- 1 | import random 2 | from words import word_list 3 | 4 | 5 | def get_word(): 6 | word = random.choice(word_list) 7 | return word.upper() 8 | 9 | 10 | def play(word): 11 | word_completion = "_" * len(word) 12 | guessed = False 13 | guessed_letters = [] 14 | guessed_words = [] 15 | tries = 6 16 | print("Let's play Hangman!") 17 | print(display_hangman(tries)) 18 | print(word_completion) 19 | print("\n") 20 | while not guessed and tries > 0: 21 | guess = input("Please guess a letter or word: ").upper() 22 | if len(guess) == 1 and guess.isalpha(): 23 | if guess in guessed_letters: 24 | print("You already guessed the letter", guess) 25 | elif guess not in word: 26 | print(guess, "is not in the word.") 27 | tries -= 1 28 | guessed_letters.append(guess) 29 | else: 30 | print("Good job,", guess, "is in the word!") 31 | guessed_letters.append(guess) 32 | word_as_list = list(word_completion) 33 | indices = [i for i, letter in enumerate(word) if letter == guess] 34 | for index in indices: 35 | word_as_list[index] = guess 36 | word_completion = "".join(word_as_list) 37 | if "_" not in word_completion: 38 | guessed = True 39 | elif len(guess) == len(word) and guess.isalpha(): 40 | if guess in guessed_words: 41 | print("You already guessed the word", guess) 42 | elif guess != word: 43 | print(guess, "is not the word.") 44 | tries -= 1 45 | guessed_words.append(guess) 46 | else: 47 | guessed = True 48 | word_completion = word 49 | else: 50 | print("Not a valid guess.") 51 | print(display_hangman(tries)) 52 | print(word_completion) 53 | print("\n") 54 | if guessed: 55 | print("Congrats, you guessed the word! You win!") 56 | else: 57 | print("Sorry, you ran out of tries. The word was " + word + ". Maybe next time!") 58 | 59 | 60 | def display_hangman(tries): 61 | stages = [ # final state: head, torso, both arms, and both legs 62 | """ 63 | -------- 64 | | | 65 | | O 66 | | \\|/ 67 | | | 68 | | / \\ 69 | - 70 | """, 71 | # head, torso, both arms, and one leg 72 | """ 73 | -------- 74 | | | 75 | | O 76 | | \\|/ 77 | | | 78 | | / 79 | - 80 | """, 81 | # head, torso, and both arms 82 | """ 83 | -------- 84 | | | 85 | | O 86 | | \\|/ 87 | | | 88 | | 89 | - 90 | """, 91 | # head, torso, and one arm 92 | """ 93 | -------- 94 | | | 95 | | O 96 | | \\| 97 | | | 98 | | 99 | - 100 | """, 101 | # head and torso 102 | """ 103 | -------- 104 | | | 105 | | O 106 | | | 107 | | | 108 | | 109 | - 110 | """, 111 | # head 112 | """ 113 | -------- 114 | | | 115 | | O 116 | | 117 | | 118 | | 119 | - 120 | """, 121 | # initial empty state 122 | """ 123 | -------- 124 | | | 125 | | 126 | | 127 | | 128 | | 129 | - 130 | """ 131 | ] 132 | return stages[tries] 133 | 134 | 135 | def main(): 136 | word = get_word() 137 | play(word) 138 | while input("Play Again? (Y/N) ").upper() == "Y": 139 | word = get_word() 140 | play(word) 141 | 142 | 143 | if __name__ == "__main__": 144 | main() 145 | -------------------------------------------------------------------------------- /snapfilter.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | 3 | import cv2 4 | from imutils.video import VideoStream 5 | from imutils import face_utils, translate, resize 6 | 7 | import time 8 | import dlib 9 | 10 | import numpy as np 11 | 12 | parser = argparse.ArgumentParser() 13 | parser.add_argument("-predictor", required=True, help="path to predictor") 14 | args = parser.parse_args() 15 | 16 | print("starting program.") 17 | print("'s' starts drawing eyes.") 18 | print("'r' to toggle recording image, and 'q' to quit") 19 | 20 | vs = VideoStream().start() 21 | time.sleep(1.5) 22 | 23 | # this detects our face 24 | detector = dlib.get_frontal_face_detector() 25 | # and this predicts our face's orientation 26 | predictor = dlib.shape_predictor(args.predictor) 27 | 28 | recording = False 29 | counter = 0 30 | 31 | class EyeList(object): 32 | def __init__(self, length): 33 | self.length = length 34 | self.eyes = [] 35 | 36 | def push(self, newcoords): 37 | if len(self.eyes) < self.length: 38 | self.eyes.append(newcoords) 39 | else: 40 | self.eyes.pop(0) 41 | self.eyes.append(newcoords) 42 | 43 | def clear(self): 44 | self.eyes = [] 45 | 46 | # start with 10 previous eye positions 47 | eyelist = EyeList(10) 48 | eyeSnake = False 49 | 50 | # get our first frame outside of loop, so we can see how our 51 | # webcame resized itself, and it's resolution w/ np.shape 52 | frame = vs.read() 53 | frame = resize(frame, width=800) 54 | 55 | eyelayer = np.zeros(frame.shape, dtype='uint8') 56 | eyemask = eyelayer.copy() 57 | eyemask = cv2.cvtColor(eyemask, cv2.COLOR_BGR2GRAY) 58 | translated = np.zeros(frame.shape, dtype='uint8') 59 | translated_mask = eyemask.copy() 60 | 61 | while True: 62 | # read a frame from webcam, resize to be smaller 63 | frame = vs.read() 64 | frame = resize(frame, width=800) 65 | 66 | # fill our masks and frames with 0 (black) on every draw loop 67 | eyelayer.fill(0) 68 | eyemask.fill(0) 69 | translated.fill(0) 70 | translated_mask.fill(0) 71 | 72 | # the detector and predictor expect a grayscale image 73 | gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) 74 | rects = detector(gray, 0) 75 | 76 | # if we're running the eyesnake loop (press 's' while running to enable) 77 | if eyeSnake: 78 | for rect in rects: 79 | # the predictor is our 68 point model we loaded 80 | shape = predictor(gray, rect) 81 | shape = face_utils.shape_to_np(shape) 82 | 83 | # our dlib model returns 68 points that make up a face. 84 | # the left eye is the 36th point through the 42nd. the right 85 | # eye is the 42nd point through the 48th. 86 | leftEye = shape[36:42] 87 | rightEye = shape[42:48] 88 | 89 | # fill our mask in the shape of our eyes 90 | cv2.fillPoly(eyemask, [leftEye], 255) 91 | cv2.fillPoly(eyemask, [rightEye], 255) 92 | 93 | # copy the image from the frame onto the eyelayer using that mask 94 | eyelayer = cv2.bitwise_and(frame, frame, mask=eyemask) 95 | 96 | # we use this to get an x and y coordinate for the pasting of eyes 97 | x, y, w, h = cv2.boundingRect(eyemask) 98 | 99 | # push this onto our list 100 | eyelist.push([x, y]) 101 | 102 | # finally, draw our eyes, in reverse order 103 | for i in reversed(eyelist.eyes): 104 | # first, translate the eyelayer with just the eyes 105 | translated1 = translate(eyelayer, i[0] - x, i[1] - y) 106 | # next, translate its mask 107 | translated1_mask = translate(eyemask, i[0] - x, i[1] - y) 108 | # add it to the existing translated eyes mask (not actual add because of 109 | # risk of overflow) 110 | translated_mask = np.maximum(translated_mask, translated1_mask) 111 | # cut out the new translated mask 112 | translated = cv2.bitwise_and(translated, translated, mask=255 - translated1_mask) 113 | # paste in the newly translated eye position 114 | translated += translated1 115 | # again, cut out the translated mask 116 | frame = cv2.bitwise_and(frame, frame, mask=255 - translated_mask) 117 | # and paste in the translated eye image 118 | frame += translated 119 | 120 | # display the current frame, and check to see if user pressed a key 121 | cv2.imshow("eye glitch", frame) 122 | key = cv2.waitKey(1) & 0xFF 123 | 124 | if recording: 125 | # create a directory called "image_seq", and we'll be able to create gifs in ffmpeg 126 | # from image sequences 127 | cv2.imwrite("image_seq/%05d.png" % counter, frame) 128 | counter += 1 129 | 130 | if key == ord("q"): 131 | break 132 | 133 | if key == ord("s"): 134 | eyeSnake = not eyeSnake 135 | eyelist.clear() 136 | 137 | if key == ord("r"): 138 | recording = not recording 139 | 140 | cv2.destroyAllWindows() 141 | vs.stop() 142 | -------------------------------------------------------------------------------- /tictactoe/tic_tac.py: -------------------------------------------------------------------------------- 1 | #importing required Libraries 2 | import pygame as pg 3 | import sys 4 | import time 5 | from pygame.locals import * 6 | 7 | #declaring global variables 8 | 9 | XO='x' #stores x or o 10 | win=None 11 | draw=None 12 | width=400 13 | height=400 14 | white=(255,255,255) 15 | line_color=(0,0,0) #black 16 | 17 | #sets up a 3*3 board on Canvas 18 | board=[[None]*3,[None]*3,[None]*3] 19 | 20 | #game display 21 | pg.init() 22 | fps=30 #frames per second 23 | clock=pg.time.Clock() 24 | 25 | screen=pg.display.set_mode((width,height+100),0,32) 26 | #height+100 is to provide extra 100pc space to display game status 27 | 28 | #name tag 29 | pg.display.set_caption("Tic Tac Toe") 30 | 31 | #load images 32 | init_window=pg.image.load("images/cover_img.jpg") 33 | x_img=pg.image.load("images/x_img.jpg") 34 | o_img=pg.image.load("images/o_img.png") 35 | 36 | #resizing images to required width and height 37 | init_window=pg.transform.scale(init_window,(width,height+100)) 38 | x_img=pg.transform.scale(x_img,(80,80)) 39 | y_img=pg.transform.scale(o_img,(80,80)) 40 | 41 | def game_init_window(): 42 | screen.blit(init_window,(0,0)) 43 | pg.display.update() 44 | time.sleep(3) 45 | screen.fill(white) 46 | 47 | #drawing 2 vertical lines that splits the canvas in three equal halves 48 | pg.draw.line(screen,line_color,(width/3,0),(width/3,height),7) 49 | pg.draw.line(screen,line_color,(width/3*2,0),(width/3*2,height),7) 50 | 51 | #drawing 2 horizontal lines that splits the canvas in three equal halves 52 | pg.draw.line(screen,line_color,(0,height/3),(width,height/3),7) 53 | pg.draw.line(screen,line_color,(0,height/3*2),(width,height/3*2),7) 54 | draw_status() 55 | 56 | def draw_status(): 57 | 58 | global drawing 59 | if win is None: 60 | msg=XO.upper()+"'s turn" 61 | else: 62 | msg=XO.upper()+" Won!" 63 | if draw: 64 | msg="Game Draw!" 65 | 66 | font=pg.font.Font(None,30) 67 | text=font.render(msg,1,white) 68 | 69 | #creating a small block at the bottom of the display 70 | screen.fill(line_color,(0,400,500,100)) 71 | text_rect=text.get_rect(center=(width/2,450)) 72 | screen.blit(text,text_rect) 73 | pg.display.update() 74 | 75 | #main algorithm 76 | def check_win(): 77 | global board,win,draw 78 | 79 | #checking for wins in rows 80 | for row in range(3): 81 | if(board[row][0]==board[row][1]==board[row][2] and (board[row][0] is not None)): 82 | win=board[row][0] 83 | pg.draw.line(screen,(0,0,255),(0,(row+1)*height/3-height/6),(width,(row+1)*height/3-height/6),7) 84 | break 85 | 86 | #checking for wins in columns 87 | for column in range(3): 88 | if(board[0][column]==board[1][column]==board[2][column] and (board[0][column] is not None)): 89 | win=board[0][column] 90 | pg.draw.line(screen,(0,0,255),((col + 1)* width / 3 - width / 6, 0),((col + 1)* width / 3 - width / 6, height),7) 91 | break 92 | 93 | #checking for wins diagonally 94 | if (board[0][0]==board[1][1]==board[2][2] and (board[0][0] is not None)): 95 | #winning left to right 96 | win=board[0][0] 97 | pg.draw.line(screen,(0,0,255),(50,50),(350,350),4) 98 | elif(board[0][2]==board[1][1]==board[2][0] and (board[0][2] is not None)): 99 | #winning right to left 100 | win=board[0][2] 101 | pg.draw.line(screen,(0,0,255),(350,50),(50,350),4) 102 | 103 | if (all([all(row) for row in board]) and win is None): 104 | draw=True 105 | 106 | draw_status() 107 | 108 | #displaying user input 109 | def drawXO(row,col): 110 | global board,XO 111 | if row==1: 112 | posx=30 113 | elif row==2: 114 | posx=width/3+30 115 | elif row==3: 116 | posx=width/3*2+30 117 | 118 | if col==1: 119 | posy=30 120 | elif col==2: 121 | posy=height/3+30 122 | elif col==3: 123 | posy=height/3*2+30 124 | 125 | board[row-1][col-1]=XO 126 | #display the image 127 | if XO=='x': 128 | screen.blit(x_img,(posx,posy)) 129 | XO='o' 130 | else: 131 | screen.blit(y_img,(posx,posy)) 132 | XO='x' 133 | 134 | pg.display.update() 135 | 136 | #getting user input 137 | def user_click(): 138 | 139 | #get coordinates of mouse user_click 140 | x,y=pg.mouse.get_pos() 141 | 142 | #finding column based on user_click 143 | if x < width/3: 144 | col=1 145 | elif x < width/3*2 : 146 | col=2 147 | elif x < width: 148 | col=3 149 | else: 150 | col=None 151 | 152 | #finding row based on user_click 153 | if y < height/3: 154 | row=1 155 | elif y < height/3*2: 156 | row=2 157 | elif y < height: 158 | row=3 159 | else: 160 | row=None 161 | 162 | if( row and col and board[row-1][col-1] is None): 163 | global XO 164 | drawXO(row,col) 165 | check_win() 166 | 167 | 168 | def reset_game(): 169 | global board, winner, XO, draw 170 | time.sleep(3) 171 | XO = 'x' 172 | draw = False 173 | game_init_window() 174 | winner = None 175 | board = [[None]*3, [None]*3, [None]*3] 176 | 177 | game_init_window() 178 | 179 | while(True): 180 | for event in pg.event.get(): 181 | 182 | if event.type == QUIT: 183 | pg.quit() 184 | sys.exit() 185 | 186 | elif event.type is MOUSEBUTTONDOWN: 187 | user_click() 188 | 189 | if(win or draw): 190 | reset_game() 191 | 192 | pg.display.update() 193 | clock.tick(fps) 194 | -------------------------------------------------------------------------------- /space invaders/spaceinvaders.py: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | ###################### ---------------- ####################### 3 | ###################### |SPACE INVADERS| ####################### 4 | ###################### ---------------- ####################### 5 | ############################################################################### 6 | 7 | # Modules Used 8 | import turtle 9 | import os 10 | import math 11 | import random 12 | import winsound 13 | import threading 14 | 15 | # Set up the screen 16 | wn = turtle.Screen() 17 | wn.bgcolor("black") 18 | wn.title("Space Invaders") 19 | wn.bgpic("E:/python/space.gif") 20 | 21 | # Register the sounds 22 | laser_gun = "E:/python/laser_gun.wav" 23 | explode = "E:/python/explode.wav" 24 | 25 | # Register the shapes 26 | turtle.register_shape("E:/python/player.gif") 27 | turtle.register_shape("E:/python/enemy.gif") 28 | # Create the borders 29 | border_pen = turtle.Turtle() 30 | border_pen.speed(0) 31 | border_pen.color("white") 32 | border_pen.penup() 33 | border_pen.setposition(-300, -300) 34 | border_pen.pendown() 35 | border_pen.pensize(3) 36 | for side in range(0, 4): 37 | border_pen.fd(600) 38 | border_pen.lt(90) 39 | border_pen.hideturtle() 40 | 41 | # Set score to zero 42 | score = 0 43 | 44 | # Draw score 45 | score_pen = turtle.Turtle() 46 | score_pen.speed(0) 47 | score_pen.color("white") 48 | score_pen.penup() 49 | score_pen.setposition(-290, 280) 50 | scorestring = "Score : %s" % score 51 | score_pen.write(scorestring, False, align="left", font=("Arial", 14, "normal")) 52 | score_pen.hideturtle() 53 | 54 | # Player 55 | player = turtle.Turtle() 56 | player.color("blue") 57 | player.shape("E:/python/player.gif") 58 | player.penup() 59 | player.speed(0) 60 | player.setposition(0, -250) 61 | player.setheading(90) 62 | playerspeed = 15 63 | 64 | # Choose no.of enemies 65 | num_of_enemies = 5 66 | 67 | # Create an empty list of enemies 68 | enemies = [] 69 | 70 | # Add enemies to the list 71 | for i in range(num_of_enemies): 72 | # Create enemy 73 | enemies.append(turtle.Turtle()) 74 | 75 | for enemy in enemies: 76 | enemy.color("red") 77 | enemy.shape("E:/python/enemy.gif") 78 | enemy.penup() 79 | enemy.speed(0) 80 | x = random.randint(-200, 200) 81 | y = random.randint(100, 250) 82 | enemy.setposition(x, y) 83 | 84 | # Set enemy speed 85 | enemyspeed = 2 86 | 87 | 88 | # Create player weapon 89 | bullet = turtle.Turtle() 90 | bullet.color("yellow") 91 | bullet.shape("triangle") 92 | bullet.penup() 93 | bullet.speed(0) 94 | bullet.setheading(90) 95 | bullet.shapesize(0.5, 0.5) 96 | bullet.hideturtle() 97 | bulletspeed = 20 98 | 99 | # Define bullet state 100 | # ready - ready to fire 101 | # fire - bullet is firing 102 | bulletstate = "ready" 103 | 104 | # move player left and right 105 | 106 | 107 | def move_left(): 108 | x = player.xcor() 109 | x -= playerspeed 110 | if(x < -280): 111 | x = -280 112 | player.setx(x) 113 | 114 | 115 | def move_right(): 116 | x = player.xcor() 117 | x += playerspeed 118 | if(x > 280): 119 | x = 280 120 | player.setx(x) 121 | 122 | 123 | def fire_bullet(): 124 | # declare bulletstate as a global if it needs changed 125 | global bulletstate 126 | if bulletstate == "ready": 127 | bulletstate = "fire" 128 | # move the bullet to the just above of player 129 | winsound.PlaySound(laser_gun, winsound.SND_FILENAME) 130 | x = player.xcor() 131 | y = player.ycor() + 10 132 | bullet.setposition(x, y) 133 | bullet.showturtle() 134 | 135 | # Check if there is a collision 136 | 137 | 138 | def isCollision(t1, t2): 139 | distance = math.sqrt(math.pow(t1.xcor() - t2.xcor(), 2) + math.pow(t1.ycor() - t2.ycor(), 2)) 140 | if distance < 15: 141 | return True 142 | else: 143 | return False 144 | 145 | 146 | # Create keyboard bindings 147 | wn.onkey(move_left, "Left") 148 | wn.onkey(move_right, "Right") 149 | wn.onkey(fire_bullet, "space") 150 | wn.listen() 151 | # wn.mainloop() 152 | 153 | # Main game loop 154 | while True: 155 | for enemy in enemies: 156 | # move enemy 157 | x = enemy.xcor() 158 | x += enemyspeed 159 | enemy.setx(x) 160 | # move enemy back and down 161 | if enemy.xcor() > 275: 162 | # move all enemies down 163 | for e in enemies: 164 | y = e.ycor() 165 | y -= 40 166 | e.sety(y) 167 | if enemy.ycor() < -275: 168 | enemy.sety(-275) 169 | # change enemy direction 170 | enemyspeed *= -1 171 | 172 | if enemy.xcor() < -275: 173 | # move all enemies down 174 | for e in enemies: 175 | y = e.ycor() 176 | y -= 40 177 | e.sety(y) 178 | if enemy.ycor() < -275: 179 | enemy.sety(-275) 180 | # change enemy direction 181 | enemyspeed *= -1 182 | 183 | # check for a collision between enemy and bullet 184 | if isCollision(bullet, enemy): 185 | # reset the bullet 186 | winsound.PlaySound(explode, winsound.SND_FILENAME) 187 | bullet.hideturtle() 188 | bulletstate = "ready" 189 | bullet.setposition(0, -400) 190 | # reset the enemy 191 | x = random.randint(-200, 200) 192 | y = random.randint(100, 250) 193 | enemy.setposition(x, y) 194 | # Update score 195 | score += 10 196 | scorestring = "Score : %s" % score 197 | score_pen.clear() 198 | score_pen.write(scorestring, False, align="left", font=("Arial", 14, "normal")) 199 | # Not nessasary Code 200 | # if __name__ == '__main__': 201 | # creating thread 202 | # th1=threading.Thread(target=ifCollision) 203 | # th2=threading.Thread(target=explode) 204 | # th1.start() 205 | # th2.start() 206 | 207 | if isCollision(player, enemy): 208 | player.hideturtle() 209 | bullet.hideturtle() 210 | for ey in enemies: 211 | ey.hideturtle() 212 | game_over = turtle.Turtle() 213 | game_over.speed(0) 214 | game_over.color("red") 215 | game_over.penup() 216 | gamestring = "Game Over!! \n\nScore:%s" % score 217 | game_over.write(gamestring, False, align="left", font=("Arial", 20, "normal")) 218 | game_over.hideturtle() 219 | breaker = 10 220 | break 221 | # move bullet 222 | if bulletstate == "fire": 223 | y = bullet.ycor() 224 | y += bulletspeed 225 | bullet.sety(y) 226 | # check if bullet has gone top 227 | if bullet.ycor() > 275: 228 | bullet.hideturtle() 229 | bulletstate = "ready" 230 | if(breaker == 10): 231 | print(quit) 232 | else: 233 | wn.mainloop() 234 | delay = input("Press enter") 235 | -------------------------------------------------------------------------------- /hangman/words.py: -------------------------------------------------------------------------------- 1 | word_list = [ 2 | 'wares', 3 | 'soup', 4 | 'mount', 5 | 'extend', 6 | 'brown', 7 | 'expert', 8 | 'tired', 9 | 'humidity', 10 | 'backpack', 11 | 'crust', 12 | 'dent', 13 | 'market', 14 | 'knock', 15 | 'smite', 16 | 'windy', 17 | 'coin', 18 | 'throw', 19 | 'silence', 20 | 'bluff', 21 | 'downfall', 22 | 'climb', 23 | 'lying', 24 | 'weaver', 25 | 'snob', 26 | 'kickoff', 27 | 'match', 28 | 'quaker', 29 | 'foreman', 30 | 'excite', 31 | 'thinking', 32 | 'mend', 33 | 'allergen', 34 | 'pruning', 35 | 'coat', 36 | 'emerald', 37 | 'coherent', 38 | 'manic', 39 | 'multiple', 40 | 'square', 41 | 'funded', 42 | 'funnel', 43 | 'sailing', 44 | 'dream', 45 | 'mutation', 46 | 'strict', 47 | 'mystic', 48 | 'film', 49 | 'guide', 50 | 'strain', 51 | 'bishop', 52 | 'settle', 53 | 'plateau', 54 | 'emigrate', 55 | 'marching', 56 | 'optimal', 57 | 'medley', 58 | 'endanger', 59 | 'wick', 60 | 'condone', 61 | 'schema', 62 | 'rage', 63 | 'figure', 64 | 'plague', 65 | 'aloof', 66 | 'there', 67 | 'reusable', 68 | 'refinery', 69 | 'suffer', 70 | 'affirm', 71 | 'captive', 72 | 'flipping', 73 | 'prolong', 74 | 'main', 75 | 'coral', 76 | 'dinner', 77 | 'rabbit', 78 | 'chill', 79 | 'seed', 80 | 'born', 81 | 'shampoo', 82 | 'italian', 83 | 'giggle', 84 | 'roost', 85 | 'palm', 86 | 'globe', 87 | 'wise', 88 | 'grandson', 89 | 'running', 90 | 'sunlight', 91 | 'spending', 92 | 'crunch', 93 | 'tangle', 94 | 'forego', 95 | 'tailor', 96 | 'divinity', 97 | 'probe', 98 | 'bearded', 99 | 'premium', 100 | 'featured', 101 | 'serve', 102 | 'borrower', 103 | 'examine', 104 | 'legal', 105 | 'outlive', 106 | 'unnamed', 107 | 'unending', 108 | 'snow', 109 | 'whisper', 110 | 'bundle', 111 | 'bracket', 112 | 'deny', 113 | 'blurred', 114 | 'pentagon', 115 | 'reformed', 116 | 'polarity', 117 | 'jumping', 118 | 'gain', 119 | 'laundry', 120 | 'hobble', 121 | 'culture', 122 | 'whittle', 123 | 'docket', 124 | 'mayhem', 125 | 'build', 126 | 'peel', 127 | 'board', 128 | 'keen', 129 | 'glorious', 130 | 'singular', 131 | 'cavalry', 132 | 'present', 133 | 'cold', 134 | 'hook', 135 | 'salted', 136 | 'just', 137 | 'dumpling', 138 | 'glimmer', 139 | 'drowning', 140 | 'admiral', 141 | 'sketch', 142 | 'subject', 143 | 'upright', 144 | 'sunshine', 145 | 'slide', 146 | 'calamity', 147 | 'gurney', 148 | 'adult', 149 | 'adore', 150 | 'weld', 151 | 'masking', 152 | 'print', 153 | 'wishful', 154 | 'foyer', 155 | 'tofu', 156 | 'machete', 157 | 'diced', 158 | 'behemoth', 159 | 'rout', 160 | 'midwife', 161 | 'neglect', 162 | 'mass', 163 | 'game', 164 | 'stocking', 165 | 'folly', 166 | 'action', 167 | 'bubbling', 168 | 'scented', 169 | 'sprinter', 170 | 'bingo', 171 | 'egyptian', 172 | 'comedy', 173 | 'rung', 174 | 'outdated', 175 | 'radical', 176 | 'escalate', 177 | 'mutter', 178 | 'desert', 179 | 'memento', 180 | 'kayak', 181 | 'talon', 182 | 'portion', 183 | 'affirm', 184 | 'dashing', 185 | 'fare', 186 | 'battle', 187 | 'pupil', 188 | 'rite', 189 | 'smash', 190 | 'true', 191 | 'entrance', 192 | 'counting', 193 | 'peruse', 194 | 'dioxide', 195 | 'hermit', 196 | 'carving', 197 | 'backyard', 198 | 'homeless', 199 | 'medley', 200 | 'packet', 201 | 'tickle', 202 | 'coming', 203 | 'leave', 204 | 'swing', 205 | 'thicket', 206 | 'reserve', 207 | 'murder', 208 | 'costly', 209 | 'corduroy', 210 | 'bump', 211 | 'oncology', 212 | 'swatch', 213 | 'rundown', 214 | 'steal', 215 | 'teller', 216 | 'cable', 217 | 'oily', 218 | 'official', 219 | 'abyss', 220 | 'schism', 221 | 'failing', 222 | 'guru', 223 | 'trim', 224 | 'alfalfa', 225 | 'doubt', 226 | 'booming', 227 | 'bruised', 228 | 'playful', 229 | 'kicker', 230 | 'jockey', 231 | 'handmade', 232 | 'landfall', 233 | 'rhythm', 234 | 'keep', 235 | 'reassure', 236 | 'garland', 237 | 'sauna', 238 | 'idiom', 239 | 'fluent', 240 | 'lope', 241 | 'gland', 242 | 'amend', 243 | 'fashion', 244 | 'treaty', 245 | 'standing', 246 | 'current', 247 | 'sharpen', 248 | 'cinder', 249 | 'idealist', 250 | 'festive', 251 | 'frame', 252 | 'molten', 253 | 'sill', 254 | 'glisten', 255 | 'fearful', 256 | 'basement', 257 | 'minutia', 258 | 'coin', 259 | 'stick', 260 | 'featured', 261 | 'soot', 262 | 'static', 263 | 'crazed', 264 | 'upset', 265 | 'robotics', 266 | 'dwarf', 267 | 'shield', 268 | 'butler', 269 | 'stitch', 270 | 'stub', 271 | 'sabotage', 272 | 'parlor', 273 | 'prompt', 274 | 'heady', 275 | 'horn', 276 | 'bygone', 277 | 'rework', 278 | 'painful', 279 | 'composer', 280 | 'glance', 281 | 'acquit', 282 | 'eagle', 283 | 'solvent', 284 | 'backbone', 285 | 'smart', 286 | 'atlas', 287 | 'leap', 288 | 'danger', 289 | 'bruise', 290 | 'seminar', 291 | 'tinge', 292 | 'trip', 293 | 'narrow', 294 | 'while', 295 | 'jaguar', 296 | 'seminary', 297 | 'command', 298 | 'cassette', 299 | 'draw', 300 | 'anchovy', 301 | 'scream', 302 | 'blush', 303 | 'organic', 304 | 'applause', 305 | 'parallel', 306 | 'trolley', 307 | 'pathos', 308 | 'origin', 309 | 'hang', 310 | 'pungent', 311 | 'angular', 312 | 'stubble', 313 | 'painted', 314 | 'forward', 315 | 'saddle', 316 | 'muddy', 317 | 'orchid', 318 | 'prudence', 319 | 'disprove', 320 | 'yiddish', 321 | 'lobbying', 322 | 'neuron', 323 | 'tumor', 324 | 'haitian', 325 | 'swift', 326 | 'mantel', 327 | 'wardrobe', 328 | 'consist', 329 | 'storied', 330 | 'extreme', 331 | 'payback', 332 | 'control', 333 | 'dummy', 334 | 'influx', 335 | 'realtor', 336 | 'detach', 337 | 'flake', 338 | 'consign', 339 | 'adjunct', 340 | 'stylized', 341 | 'weep', 342 | 'prepare', 343 | 'pioneer', 344 | 'tail', 345 | 'platoon', 346 | 'exercise', 347 | 'dummy', 348 | 'clap', 349 | 'actor', 350 | 'spark', 351 | 'dope', 352 | 'phrase', 353 | 'welsh', 354 | 'wall', 355 | 'whine', 356 | 'fickle', 357 | 'wrong', 358 | 'stamina', 359 | 'dazed', 360 | 'cramp', 361 | 'filet', 362 | 'foresee', 363 | 'seller', 364 | 'award', 365 | 'mare', 366 | 'uncover', 367 | 'drowning', 368 | 'ease', 369 | 'buttery', 370 | 'luxury', 371 | 'bigotry', 372 | 'muddy', 373 | 'photon', 374 | 'snow', 375 | 'oppress', 376 | 'blessed', 377 | 'call', 378 | 'stain', 379 | 'amber', 380 | 'rental', 381 | 'nominee', 382 | 'township', 383 | 'adhesive', 384 | 'lengthy', 385 | 'swarm', 386 | 'court', 387 | 'baguette', 388 | 'leper', 389 | 'vital', 390 | 'push', 391 | 'digger', 392 | 'setback', 393 | 'accused', 394 | 'taker', 395 | 'genie', 396 | 'reverse', 397 | 'fake', 398 | 'widowed', 399 | 'renewed', 400 | 'goodness', 401 | 'featured', 402 | 'curse', 403 | 'shocked', 404 | 'shove', 405 | 'marked', 406 | 'interact', 407 | 'mane', 408 | 'hawk', 409 | 'kidnap', 410 | 'noble', 411 | 'proton', 412 | 'effort', 413 | 'patriot', 414 | 'showcase', 415 | 'parish', 416 | 'mosaic', 417 | 'coil', 418 | 'aide', 419 | 'breeder', 420 | 'concoct', 421 | 'pathway', 422 | 'hearing', 423 | 'bayou', 424 | 'regimen', 425 | 'drain', 426 | 'bereft', 427 | 'matte', 428 | 'bill', 429 | 'medal', 430 | 'prickly', 431 | 'sarcasm', 432 | 'stuffy', 433 | 'allege', 434 | 'monopoly', 435 | 'lighter', 436 | 'repair', 437 | 'worship', 438 | 'vent', 439 | 'hybrid', 440 | 'buffet', 441 | 'lively'] 442 | -------------------------------------------------------------------------------- /words.py: -------------------------------------------------------------------------------- 1 | word_list = [ 2 | 'wares', 3 | 'soup', 4 | 'mount', 5 | 'extend', 6 | 'brown', 7 | 'expert', 8 | 'tired', 9 | 'humidity', 10 | 'backpack', 11 | 'crust', 12 | 'dent', 13 | 'market', 14 | 'knock', 15 | 'smite', 16 | 'windy', 17 | 'coin', 18 | 'throw', 19 | 'silence', 20 | 'bluff', 21 | 'downfall', 22 | 'climb', 23 | 'lying', 24 | 'weaver', 25 | 'snob', 26 | 'kickoff', 27 | 'match', 28 | 'quaker', 29 | 'foreman', 30 | 'excite', 31 | 'thinking', 32 | 'mend', 33 | 'allergen', 34 | 'pruning', 35 | 'coat', 36 | 'emerald', 37 | 'coherent', 38 | 'manic', 39 | 'multiple', 40 | 'square', 41 | 'funded', 42 | 'funnel', 43 | 'sailing', 44 | 'dream', 45 | 'mutation', 46 | 'strict', 47 | 'mystic', 48 | 'film', 49 | 'guide', 50 | 'strain', 51 | 'bishop', 52 | 'settle', 53 | 'plateau', 54 | 'emigrate', 55 | 'marching', 56 | 'optimal', 57 | 'medley', 58 | 'endanger', 59 | 'wick', 60 | 'condone', 61 | 'schema', 62 | 'rage', 63 | 'figure', 64 | 'plague', 65 | 'aloof', 66 | 'there', 67 | 'reusable', 68 | 'refinery', 69 | 'suffer', 70 | 'affirm', 71 | 'captive', 72 | 'flipping', 73 | 'prolong', 74 | 'main', 75 | 'coral', 76 | 'dinner', 77 | 'rabbit', 78 | 'chill', 79 | 'seed', 80 | 'born', 81 | 'shampoo', 82 | 'italian', 83 | 'giggle', 84 | 'roost', 85 | 'palm', 86 | 'globe', 87 | 'wise', 88 | 'grandson', 89 | 'running', 90 | 'sunlight', 91 | 'spending', 92 | 'crunch', 93 | 'tangle', 94 | 'forego', 95 | 'tailor', 96 | 'divinity', 97 | 'probe', 98 | 'bearded', 99 | 'premium', 100 | 'featured', 101 | 'serve', 102 | 'borrower', 103 | 'examine', 104 | 'legal', 105 | 'outlive', 106 | 'unnamed', 107 | 'unending', 108 | 'snow', 109 | 'whisper', 110 | 'bundle', 111 | 'bracket', 112 | 'deny', 113 | 'blurred', 114 | 'pentagon', 115 | 'reformed', 116 | 'polarity', 117 | 'jumping', 118 | 'gain', 119 | 'laundry', 120 | 'hobble', 121 | 'culture', 122 | 'whittle', 123 | 'docket', 124 | 'mayhem', 125 | 'build', 126 | 'peel', 127 | 'board', 128 | 'keen', 129 | 'glorious', 130 | 'singular', 131 | 'cavalry', 132 | 'present', 133 | 'cold', 134 | 'hook', 135 | 'salted', 136 | 'just', 137 | 'dumpling', 138 | 'glimmer', 139 | 'drowning', 140 | 'admiral', 141 | 'sketch', 142 | 'subject', 143 | 'upright', 144 | 'sunshine', 145 | 'slide', 146 | 'calamity', 147 | 'gurney', 148 | 'adult', 149 | 'adore', 150 | 'weld', 151 | 'masking', 152 | 'print', 153 | 'wishful', 154 | 'foyer', 155 | 'tofu', 156 | 'machete', 157 | 'diced', 158 | 'behemoth', 159 | 'rout', 160 | 'midwife', 161 | 'neglect', 162 | 'mass', 163 | 'game', 164 | 'stocking', 165 | 'folly', 166 | 'action', 167 | 'bubbling', 168 | 'scented', 169 | 'sprinter', 170 | 'bingo', 171 | 'egyptian', 172 | 'comedy', 173 | 'rung', 174 | 'outdated', 175 | 'radical', 176 | 'escalate', 177 | 'mutter', 178 | 'desert', 179 | 'memento', 180 | 'kayak', 181 | 'talon', 182 | 'portion', 183 | 'affirm', 184 | 'dashing', 185 | 'fare', 186 | 'battle', 187 | 'pupil', 188 | 'rite', 189 | 'smash', 190 | 'true', 191 | 'entrance', 192 | 'counting', 193 | 'peruse', 194 | 'dioxide', 195 | 'hermit', 196 | 'carving', 197 | 'backyard', 198 | 'homeless', 199 | 'medley', 200 | 'packet', 201 | 'tickle', 202 | 'coming', 203 | 'leave', 204 | 'swing', 205 | 'thicket', 206 | 'reserve', 207 | 'murder', 208 | 'costly', 209 | 'corduroy', 210 | 'bump', 211 | 'oncology', 212 | 'swatch', 213 | 'rundown', 214 | 'steal', 215 | 'teller', 216 | 'cable', 217 | 'oily', 218 | 'official', 219 | 'abyss', 220 | 'schism', 221 | 'failing', 222 | 'guru', 223 | 'trim', 224 | 'alfalfa', 225 | 'doubt', 226 | 'booming', 227 | 'bruised', 228 | 'playful', 229 | 'kicker', 230 | 'jockey', 231 | 'handmade', 232 | 'landfall', 233 | 'rhythm', 234 | 'keep', 235 | 'reassure', 236 | 'garland', 237 | 'sauna', 238 | 'idiom', 239 | 'fluent', 240 | 'lope', 241 | 'gland', 242 | 'amend', 243 | 'fashion', 244 | 'treaty', 245 | 'standing', 246 | 'current', 247 | 'sharpen', 248 | 'cinder', 249 | 'idealist', 250 | 'festive', 251 | 'frame', 252 | 'molten', 253 | 'sill', 254 | 'glisten', 255 | 'fearful', 256 | 'basement', 257 | 'minutia', 258 | 'coin', 259 | 'stick', 260 | 'featured', 261 | 'soot', 262 | 'static', 263 | 'crazed', 264 | 'upset', 265 | 'robotics', 266 | 'dwarf', 267 | 'shield', 268 | 'butler', 269 | 'stitch', 270 | 'stub', 271 | 'sabotage', 272 | 'parlor', 273 | 'prompt', 274 | 'heady', 275 | 'horn', 276 | 'bygone', 277 | 'rework', 278 | 'painful', 279 | 'composer', 280 | 'glance', 281 | 'acquit', 282 | 'eagle', 283 | 'solvent', 284 | 'backbone', 285 | 'smart', 286 | 'atlas', 287 | 'leap', 288 | 'danger', 289 | 'bruise', 290 | 'seminar', 291 | 'tinge', 292 | 'trip', 293 | 'narrow', 294 | 'while', 295 | 'jaguar', 296 | 'seminary', 297 | 'command', 298 | 'cassette', 299 | 'draw', 300 | 'anchovy', 301 | 'scream', 302 | 'blush', 303 | 'organic', 304 | 'applause', 305 | 'parallel', 306 | 'trolley', 307 | 'pathos', 308 | 'origin', 309 | 'hang', 310 | 'pungent', 311 | 'angular', 312 | 'stubble', 313 | 'painted', 314 | 'forward', 315 | 'saddle', 316 | 'muddy', 317 | 'orchid', 318 | 'prudence', 319 | 'disprove', 320 | 'yiddish', 321 | 'lobbying', 322 | 'neuron', 323 | 'tumor', 324 | 'haitian', 325 | 'swift', 326 | 'mantel', 327 | 'wardrobe', 328 | 'consist', 329 | 'storied', 330 | 'extreme', 331 | 'payback', 332 | 'control', 333 | 'dummy', 334 | 'influx', 335 | 'realtor', 336 | 'detach', 337 | 'flake', 338 | 'consign', 339 | 'adjunct', 340 | 'stylized', 341 | 'weep', 342 | 'prepare', 343 | 'pioneer', 344 | 'tail', 345 | 'platoon', 346 | 'exercise', 347 | 'dummy', 348 | 'clap', 349 | 'actor', 350 | 'spark', 351 | 'dope', 352 | 'phrase', 353 | 'welsh', 354 | 'wall', 355 | 'whine', 356 | 'fickle', 357 | 'wrong', 358 | 'stamina', 359 | 'dazed', 360 | 'cramp', 361 | 'filet', 362 | 'foresee', 363 | 'seller', 364 | 'award', 365 | 'mare', 366 | 'uncover', 367 | 'drowning', 368 | 'ease', 369 | 'buttery', 370 | 'luxury', 371 | 'bigotry', 372 | 'muddy', 373 | 'photon', 374 | 'snow', 375 | 'oppress', 376 | 'blessed', 377 | 'call', 378 | 'stain', 379 | 'amber', 380 | 'rental', 381 | 'nominee', 382 | 'township', 383 | 'adhesive', 384 | 'lengthy', 385 | 'swarm', 386 | 'court', 387 | 'baguette', 388 | 'leper', 389 | 'vital', 390 | 'push', 391 | 'digger', 392 | 'setback', 393 | 'accused', 394 | 'taker', 395 | 'genie', 396 | 'reverse', 397 | 'fake', 398 | 'widowed', 399 | 'renewed', 400 | 'goodness', 401 | 'featured', 402 | 'curse', 403 | 'shocked', 404 | 'shove', 405 | 'marked', 406 | 'interact', 407 | 'mane', 408 | 'hawk', 409 | 'kidnap', 410 | 'noble', 411 | 'proton', 412 | 'effort', 413 | 'patriot', 414 | 'showcase', 415 | 'parish', 416 | 'mosaic', 417 | 'coil', 418 | 'aide', 419 | 'breeder', 420 | 'concoct', 421 | 'pathway', 422 | 'hearing', 423 | 'bayou', 424 | 'regimen', 425 | 'drain', 426 | 'bereft', 427 | 'matte', 428 | 'bill', 429 | 'medal', 430 | 'prickly', 431 | 'sarcasm', 432 | 'stuffy', 433 | 'allege', 434 | 'monopoly', 435 | 'lighter', 436 | 'repair', 437 | 'worship', 438 | 'vent', 439 | 'hybrid', 440 | 'buffet', 441 | 'lively', 442 | 'aglet'] ] 443 | -------------------------------------------------------------------------------- /car-game/car.py: -------------------------------------------------------------------------------- 1 | import pygame 2 | import sys 3 | pygame.init() 4 | gray=(119,118,110) 5 | black=(0,0,0) 6 | red=(255,0,0) 7 | green=(0,200,0) 8 | blue=(0,0,200) 9 | bright_red=(255,0,0) 10 | bright_green=(0,255,0) 11 | bright_blue=(0,0,255) 12 | display_width=800 13 | display_height=600 14 | import time 15 | import random 16 | 17 | 18 | gamedisplays=pygame.display.set_mode((display_width,display_height)) 19 | pygame.display.set_caption("car game") 20 | clock=pygame.time.Clock() 21 | carimg=pygame.image.load('car1.jpg') 22 | backgroundpic=pygame.image.load("download12.jpg") 23 | yellow_strip=pygame.image.load("yellow strip.jpg") 24 | strip=pygame.image.load("strip.jpg") 25 | intro_background=pygame.image.load("background.jpg") 26 | instruction_background=pygame.image.load("background2.jpg") 27 | car_width=56 28 | pause=False 29 | 30 | def intro_loop(): 31 | intro=True 32 | while intro: 33 | for event in pygame.event.get(): 34 | if event.type==pygame.QUIT: 35 | pygame.quit() 36 | quit() 37 | sys.exit() 38 | gamedisplays.blit(intro_background,(0,0)) 39 | largetext=pygame.font.Font('freesansbold.ttf',115) 40 | TextSurf,TextRect=text_objects("CAR GAME",largetext) 41 | TextRect.center=(400,100) 42 | gamedisplays.blit(TextSurf,TextRect) 43 | button("START",150,520,100,50,green,bright_green,"play") 44 | button("QUIT",550,520,100,50,red,bright_red,"quit") 45 | button("INSTRUCTION",300,520,200,50,blue,bright_blue,"intro") 46 | pygame.display.update() 47 | clock.tick(50) 48 | 49 | 50 | def button(msg,x,y,w,h,ic,ac,action=None): 51 | mouse=pygame.mouse.get_pos() 52 | click=pygame.mouse.get_pressed() 53 | if x+w>mouse[0]>x and y+h>mouse[1]>y: 54 | pygame.draw.rect(gamedisplays,ac,(x,y,w,h)) 55 | if click[0]==1 and action!=None: 56 | if action=="play": 57 | countdown() 58 | elif action=="quit": 59 | pygame.quit() 60 | quit() 61 | sys.exit() 62 | elif action=="intro": 63 | introduction() 64 | elif action=="menu": 65 | intro_loop() 66 | elif action=="pause": 67 | paused() 68 | elif action=="unpause": 69 | unpaused() 70 | 71 | 72 | else: 73 | pygame.draw.rect(gamedisplays,ic,(x,y,w,h)) 74 | smalltext=pygame.font.Font("freesansbold.ttf",20) 75 | textsurf,textrect=text_objects(msg,smalltext) 76 | textrect.center=((x+(w/2)),(y+(h/2))) 77 | gamedisplays.blit(textsurf,textrect) 78 | 79 | 80 | def introduction(): 81 | introduction=True 82 | while introduction: 83 | for event in pygame.event.get(): 84 | if event.type==pygame.QUIT: 85 | pygame.quit() 86 | quit() 87 | sys.exit() 88 | gamedisplays.blit(instruction_background,(0,0)) 89 | largetext=pygame.font.Font('freesansbold.ttf',80) 90 | smalltext=pygame.font.Font('freesansbold.ttf',20) 91 | mediumtext=pygame.font.Font('freesansbold.ttf',40) 92 | textSurf,textRect=text_objects("This is an car game in which you need dodge the coming cars",smalltext) 93 | textRect.center=((350),(200)) 94 | TextSurf,TextRect=text_objects("INSTRUCTION",largetext) 95 | TextRect.center=((400),(100)) 96 | gamedisplays.blit(TextSurf,TextRect) 97 | gamedisplays.blit(textSurf,textRect) 98 | stextSurf,stextRect=text_objects("ARROW LEFT : LEFT TURN",smalltext) 99 | stextRect.center=((150),(400)) 100 | hTextSurf,hTextRect=text_objects("ARROW RIGHT : RIGHT TURN" ,smalltext) 101 | hTextRect.center=((150),(450)) 102 | atextSurf,atextRect=text_objects("A : ACCELERATOR",smalltext) 103 | atextRect.center=((150),(500)) 104 | rtextSurf,rtextRect=text_objects("B : BRAKE ",smalltext) 105 | rtextRect.center=((150),(550)) 106 | ptextSurf,ptextRect=text_objects("P : PAUSE ",smalltext) 107 | ptextRect.center=((150),(350)) 108 | sTextSurf,sTextRect=text_objects("CONTROLS",mediumtext) 109 | sTextRect.center=((350),(300)) 110 | gamedisplays.blit(sTextSurf,sTextRect) 111 | gamedisplays.blit(stextSurf,stextRect) 112 | gamedisplays.blit(hTextSurf,hTextRect) 113 | gamedisplays.blit(atextSurf,atextRect) 114 | gamedisplays.blit(rtextSurf,rtextRect) 115 | gamedisplays.blit(ptextSurf,ptextRect) 116 | button("BACK",600,450,100,50,blue,bright_blue,"menu") 117 | pygame.display.update() 118 | clock.tick(30) 119 | 120 | def paused(): 121 | global pause 122 | 123 | while pause: 124 | for event in pygame.event.get(): 125 | if event.type==pygame.QUIT: 126 | pygame.quit() 127 | quit() 128 | sys.exit() 129 | gamedisplays.blit(instruction_background,(0,0)) 130 | largetext=pygame.font.Font('freesansbold.ttf',115) 131 | TextSurf,TextRect=text_objects("PAUSED",largetext) 132 | TextRect.center=((display_width/2),(display_height/2)) 133 | gamedisplays.blit(TextSurf,TextRect) 134 | button("CONTINUE",150,450,150,50,green,bright_green,"unpause") 135 | button("RESTART",350,450,150,50,blue,bright_blue,"play") 136 | button("MAIN MENU",550,450,200,50,red,bright_red,"menu") 137 | pygame.display.update() 138 | clock.tick(30) 139 | 140 | def unpaused(): 141 | global pause 142 | pause=False 143 | 144 | 145 | def countdown_background(): 146 | font=pygame.font.SysFont(None,25) 147 | x=(display_width*0.45) 148 | y=(display_height*0.8) 149 | gamedisplays.blit(backgroundpic,(0,0)) 150 | gamedisplays.blit(backgroundpic,(0,200)) 151 | gamedisplays.blit(backgroundpic,(0,400)) 152 | gamedisplays.blit(backgroundpic,(700,0)) 153 | gamedisplays.blit(backgroundpic,(700,200)) 154 | gamedisplays.blit(backgroundpic,(700,400)) 155 | gamedisplays.blit(yellow_strip,(400,100)) 156 | gamedisplays.blit(yellow_strip,(400,200)) 157 | gamedisplays.blit(yellow_strip,(400,300)) 158 | gamedisplays.blit(yellow_strip,(400,400)) 159 | gamedisplays.blit(yellow_strip,(400,100)) 160 | gamedisplays.blit(yellow_strip,(400,500)) 161 | gamedisplays.blit(yellow_strip,(400,0)) 162 | gamedisplays.blit(yellow_strip,(400,600)) 163 | gamedisplays.blit(strip,(120,200)) 164 | gamedisplays.blit(strip,(120,0)) 165 | gamedisplays.blit(strip,(120,100)) 166 | gamedisplays.blit(strip,(680,100)) 167 | gamedisplays.blit(strip,(680,0)) 168 | gamedisplays.blit(strip,(680,200)) 169 | gamedisplays.blit(carimg,(x,y)) 170 | text=font.render("DODGED: 0",True, black) 171 | score=font.render("SCORE: 0",True,red) 172 | gamedisplays.blit(text,(0,50)) 173 | gamedisplays.blit(score,(0,30)) 174 | button("PAUSE",650,0,150,50,blue,bright_blue,"pause") 175 | 176 | def countdown(): 177 | countdown=True 178 | 179 | while countdown: 180 | for event in pygame.event.get(): 181 | if event.type==pygame.QUIT: 182 | pygame.quit() 183 | quit() 184 | sys.exit() 185 | gamedisplays.fill(gray) 186 | countdown_background() 187 | largetext=pygame.font.Font('freesansbold.ttf',115) 188 | TextSurf,TextRect=text_objects("3",largetext) 189 | TextRect.center=((display_width/2),(display_height/2)) 190 | gamedisplays.blit(TextSurf,TextRect) 191 | pygame.display.update() 192 | clock.tick(1) 193 | gamedisplays.fill(gray) 194 | countdown_background() 195 | largetext=pygame.font.Font('freesansbold.ttf',115) 196 | TextSurf,TextRect=text_objects("2",largetext) 197 | TextRect.center=((display_width/2),(display_height/2)) 198 | gamedisplays.blit(TextSurf,TextRect) 199 | pygame.display.update() 200 | clock.tick(1) 201 | gamedisplays.fill(gray) 202 | countdown_background() 203 | largetext=pygame.font.Font('freesansbold.ttf',115) 204 | TextSurf,TextRect=text_objects("1",largetext) 205 | TextRect.center=((display_width/2),(display_height/2)) 206 | gamedisplays.blit(TextSurf,TextRect) 207 | pygame.display.update() 208 | clock.tick(1) 209 | gamedisplays.fill(gray) 210 | countdown_background() 211 | largetext=pygame.font.Font('freesansbold.ttf',115) 212 | TextSurf,TextRect=text_objects("GO!!!",largetext) 213 | TextRect.center=((display_width/2),(display_height/2)) 214 | gamedisplays.blit(TextSurf,TextRect) 215 | pygame.display.update() 216 | clock.tick(1) 217 | game_loop() 218 | 219 | def obstacle(obs_startx,obs_starty,obs): 220 | if obs==0: 221 | obs_pic=pygame.image.load("car.jpg") 222 | elif obs==1: 223 | obs_pic=pygame.image.load("car1.jpg") 224 | elif obs==2: 225 | obs_pic=pygame.image.load("car2.jpg") 226 | elif obs==3: 227 | obs_pic=pygame.image.load("car4.jpg") 228 | elif obs==4: 229 | obs_pic=pygame.image.load("car5.jpg") 230 | elif obs==5: 231 | obs_pic=pygame.image.load("car6.jpg") 232 | elif obs==6: 233 | obs_pic=pygame.image.load("car7.jpg") 234 | gamedisplays.blit(obs_pic,(obs_startx,obs_starty)) 235 | 236 | def score_system(passed,score): 237 | font=pygame.font.SysFont(None,25) 238 | text=font.render("Passed"+str(passed),True,black) 239 | score=font.render("Score"+str(score),True,red) 240 | gamedisplays.blit(text,(0,50)) 241 | gamedisplays.blit(score,(0,30)) 242 | 243 | 244 | def text_objects(text,font): 245 | textsurface=font.render(text,True,black) 246 | return textsurface,textsurface.get_rect() 247 | 248 | def message_display(text): 249 | largetext=pygame.font.Font("freesansbold.ttf",80) 250 | textsurf,textrect=text_objects(text,largetext) 251 | textrect.center=((display_width/2),(display_height/2)) 252 | gamedisplays.blit(textsurf,textrect) 253 | pygame.display.update() 254 | time.sleep(3) 255 | game_loop() 256 | 257 | 258 | def crash(): 259 | message_display("YOU CRASHED") 260 | 261 | 262 | def background(): 263 | gamedisplays.blit(backgroundpic,(0,0)) 264 | gamedisplays.blit(backgroundpic,(0,200)) 265 | gamedisplays.blit(backgroundpic,(0,400)) 266 | gamedisplays.blit(backgroundpic,(700,0)) 267 | gamedisplays.blit(backgroundpic,(700,200)) 268 | gamedisplays.blit(backgroundpic,(700,400)) 269 | gamedisplays.blit(yellow_strip,(400,0)) 270 | gamedisplays.blit(yellow_strip,(400,100)) 271 | gamedisplays.blit(yellow_strip,(400,200)) 272 | gamedisplays.blit(yellow_strip,(400,300)) 273 | gamedisplays.blit(yellow_strip,(400,400)) 274 | gamedisplays.blit(yellow_strip,(400,500)) 275 | gamedisplays.blit(strip,(120,0)) 276 | gamedisplays.blit(strip,(120,100)) 277 | gamedisplays.blit(strip,(120,200)) 278 | gamedisplays.blit(strip,(680,0)) 279 | gamedisplays.blit(strip,(680,100)) 280 | gamedisplays.blit(strip,(680,200)) 281 | 282 | def car(x,y): 283 | gamedisplays.blit(carimg,(x,y)) 284 | 285 | def game_loop(): 286 | global pause 287 | x=(display_width*0.45) 288 | y=(display_height*0.8) 289 | x_change=0 290 | obstacle_speed=9 291 | obs=0 292 | y_change=0 293 | obs_startx=random.randrange(200,(display_width-200)) 294 | obs_starty=-750 295 | obs_width=56 296 | obs_height=125 297 | passed=0 298 | level=0 299 | score=0 300 | y2=7 301 | fps=120 302 | 303 | bumped=False 304 | while not bumped: 305 | for event in pygame.event.get(): 306 | if event.type==pygame.QUIT: 307 | pygame.quit() 308 | quit() 309 | 310 | if event.type==pygame.KEYDOWN: 311 | if event.key==pygame.K_LEFT: 312 | x_change=-5 313 | if event.key==pygame.K_RIGHT: 314 | x_change=5 315 | if event.key==pygame.K_a: 316 | obstacle_speed+=2 317 | if event.key==pygame.K_b: 318 | obstacle_speed-=2 319 | if event.type==pygame.KEYUP: 320 | if event.key==pygame.K_LEFT or event.key==pygame.K_RIGHT: 321 | x_change=0 322 | 323 | x+=x_change 324 | pause=True 325 | gamedisplays.fill(gray) 326 | 327 | rel_y=y2%backgroundpic.get_rect().width 328 | gamedisplays.blit(backgroundpic,(0,rel_y-backgroundpic.get_rect().width)) 329 | gamedisplays.blit(backgroundpic,(700,rel_y-backgroundpic.get_rect().width)) 330 | if rel_y<800: 331 | gamedisplays.blit(backgroundpic,(0,rel_y)) 332 | gamedisplays.blit(backgroundpic,(700,rel_y)) 333 | gamedisplays.blit(yellow_strip,(400,rel_y)) 334 | gamedisplays.blit(yellow_strip,(400,rel_y+100)) 335 | gamedisplays.blit(yellow_strip,(400,rel_y+200)) 336 | gamedisplays.blit(yellow_strip,(400,rel_y+300)) 337 | gamedisplays.blit(yellow_strip,(400,rel_y+400)) 338 | gamedisplays.blit(yellow_strip,(400,rel_y+500)) 339 | gamedisplays.blit(yellow_strip,(400,rel_y-100)) 340 | gamedisplays.blit(strip,(120,rel_y-200)) 341 | gamedisplays.blit(strip,(120,rel_y+20)) 342 | gamedisplays.blit(strip,(120,rel_y+30)) 343 | gamedisplays.blit(strip,(680,rel_y-100)) 344 | gamedisplays.blit(strip,(680,rel_y+20)) 345 | gamedisplays.blit(strip,(680,rel_y+30)) 346 | 347 | y2+=obstacle_speed 348 | 349 | 350 | 351 | 352 | obs_starty-=(obstacle_speed/4) 353 | obstacle(obs_startx,obs_starty,obs) 354 | obs_starty+=obstacle_speed 355 | car(x,y) 356 | score_system(passed,score) 357 | if x>690-car_width or x<110: 358 | crash() 359 | if x>display_width-(car_width+110) or x<110: 360 | crash() 361 | if obs_starty>display_height: 362 | obs_starty=0-obs_height 363 | obs_startx=random.randrange(170,(display_width-170)) 364 | obs=random.randrange(0,7) 365 | passed=passed+1 366 | score=passed*10 367 | if int(passed)%10==0: 368 | level=level+1 369 | obstacle_speed+2 370 | largetext=pygame.font.Font("freesansbold.ttf",80) 371 | textsurf,textrect=text_objects("LEVEL"+str(level),largetext) 372 | textrect.center=((display_width/2),(display_height/2)) 373 | gamedisplays.blit(textsurf,textrect) 374 | pygame.display.update() 375 | time.sleep(3) 376 | 377 | 378 | if y obs_startx and x < obs_startx + obs_width or x+car_width > obs_startx and x+car_width < obs_startx+obs_width: 380 | crash() 381 | button("Pause",650,0,150,50,blue,bright_blue,"pause") 382 | pygame.display.update() 383 | clock.tick(60) 384 | intro_loop() 385 | game_loop() 386 | pygame.quit() 387 | quit() 388 | -------------------------------------------------------------------------------- /webscaper.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import requests" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 2, 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "from bs4 import BeautifulSoup" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 5, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "url = 'https://google.com'\n", 28 | "page = requests.get(url)" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": 6, 34 | "metadata": {}, 35 | "outputs": [ 36 | { 37 | "name": "stdout", 38 | "output_type": "stream", 39 | "text": [ 40 | "\n", 41 | "\n", 42 | " \n", 43 | " \n", 44 | " \n", 45 | " \n", 46 | " Google\n", 47 | " \n", 48 | " \n", 53 | " \n", 56 | " \n", 59 | " \n", 61 | " \n", 62 | " \n", 63 | " \n", 69 | "
\n", 70 | " \n", 104 | "
\n", 105 | " \n", 106 | " \n", 107 | " \n", 108 | " \n", 109 | " \n", 110 | " \n", 111 | " \n", 112 | " \n", 113 | " Web History\n", 114 | " \n", 115 | " |\n", 116 | " \n", 117 | " Settings\n", 118 | " \n", 119 | " |\n", 120 | " \n", 121 | " Sign in\n", 122 | " \n", 123 | " \n", 124 | "
\n", 125 | "
\n", 126 | "
\n", 127 | "
\n", 128 | "
\n", 129 | "
\n", 130 | "
\n", 131 | "
\n", 132 | "
\n", 133 | " \"Google\"\n", 134 | "
\n", 135 | "
\n", 136 | "
\n", 137 | "
\n", 138 | " \n", 139 | " \n", 140 | " \n", 142 | " \n", 168 | " \n", 173 | " \n", 174 | "
\n", 141 | " \n", 143 | " \n", 144 | " \n", 145 | " \n", 146 | " \n", 147 | " \n", 148 | "
\n", 149 | " \n", 150 | "
\n", 151 | "
\n", 152 | " \n", 153 | " \n", 154 | " \n", 155 | " \n", 156 | " \n", 157 | " \n", 158 | " \n", 159 | " \n", 160 | " \n", 164 | " \n", 165 | " \n", 166 | " \n", 167 | "
\n", 169 | " \n", 170 | " Advanced search\n", 171 | " \n", 172 | "
\n", 175 | " \n", 176 | " \n", 179 | "
\n", 180 | "
\n", 181 | "
\n", 182 | "
\n", 183 | "
\n", 184 | "
\n", 185 | " \n", 188 | " \n", 218 | "
\n", 219 | "
\n", 220 | " \n", 221 | "
\n", 222 | " \n", 236 | "
\n", 237 | "

\n", 238 | " © 2020 -\n", 239 | " \n", 240 | " Privacy\n", 241 | " \n", 242 | " -\n", 243 | " \n", 244 | " Terms\n", 245 | " \n", 246 | "

\n", 247 | "
\n", 248 | "
\n", 249 | " \n", 255 | " \n", 256 | "\n" 257 | ] 258 | } 259 | ], 260 | "source": [ 261 | "soup = BeautifulSoup(page.content, 'html.parser')\n", 262 | "print(soup.prettify())" 263 | ] 264 | } 265 | ], 266 | "metadata": { 267 | "kernelspec": { 268 | "display_name": "Python 3", 269 | "language": "python", 270 | "name": "python3" 271 | }, 272 | "language_info": { 273 | "codemirror_mode": { 274 | "name": "ipython", 275 | "version": 3 276 | }, 277 | "file_extension": ".py", 278 | "mimetype": "text/x-python", 279 | "name": "python", 280 | "nbconvert_exporter": "python", 281 | "pygments_lexer": "ipython3", 282 | "version": "3.7.3" 283 | } 284 | }, 285 | "nbformat": 4, 286 | "nbformat_minor": 2 287 | } 288 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------