Skip to content

Instantly share code, notes, and snippets.

@shinysu
shinysu / bot.py
Created April 8, 2021 12:45
Web page Analyser
import PySimpleGUI as sg
layout = [
[sg.Text("Enter the URL: ", font=('Arial, 16')),
sg.Input("", font=('Arial, 16'), size=(40, 1), key='url'),
sg.Button('Get Data', font=('Arial, 16'), key='get', bind_return_key=True)],
[sg.Multiline('', font=('Arial', 16), size=(70,15), key='output', disabled=True)]
]
@shinysu
shinysu / play_00.py
Created December 19, 2020 15:37
Space shooter
import pgzrun
HEIGHT = 800
WIDTH = 1000
BLACK = (0, 0, 0)
ship = Actor("playership")
ship.x = WIDTH // 2
ship.bottom = HEIGHT
@shinysu
shinysu / pong_1.py
Created December 5, 2020 15:15
Pong game using pgzero
"""
draw the ball
"""
import pgzrun
WIDTH = 1000
HEIGHT = 700
COLOUR = (0, 0, 250)
ball = Actor("ball")
@shinysu
shinysu / create_db.py
Last active December 5, 2020 11:42
Todolist_SQLite
'''
create_db.py - creates the table.
Note: This program should be run first to create the database and tables
'''
import sqlite3
def create_table():
sql_query = """
CREATE TABLE tasks(
@shinysu
shinysu / create_db.py
Created December 4, 2020 09:22
Todolist using SQLite database
'''
create_db.py - creates the table.
Note: This program should be run first to create the database and tables
'''
import sqlite3
def create_table():
sql_query = """
CREATE TABLE tasks(
@shinysu
shinysu / bot.py
Last active November 29, 2020 04:53
Web Page Analyzer
"""
bot.py : Given an url, analyses the webpage and gives the following information about the page
1. Number of sentences in the webpage
2. Number of words in the page
3. Number of unique words in the page
4. 5 most frequent words in the page
"""
import PySimpleGUI as sg
from webutils import get_content_from_url, parse_html_by_tags
@shinysu
shinysu / bot.py
Created November 21, 2020 14:03
Web Page Analyser
import PySimpleGUI as sg
from webutils import get_html_content, parse_html_using_tag
from utils import get_statistics
layout = [
[sg.Text("Web Page Analyzer", font=("Arial", 18))],
[sg.Text("Enter URL", font=("Arial", 14)), sg.InputText("", font=("Arial", 14), key='url'),
sg.Button("Get Data", font=("Arial", 14), key='get')],
[sg.Multiline("", font=("Arial", 14), size=(60, 15), key='output')]
]
@shinysu
shinysu / bot.py
Created November 7, 2020 11:00
Wordbot using wordnet
"""
bot.py : Given a word, gets the meaning, synonyms and antonyms for the word
"""
import PySimpleGUI as sg
from utils import get_meaning
greeting = "Hi, I am a word bot. I can help you with words\n"
layout = [
[sg.Multiline(greeting, font=("Arial", 14), size=(70, 15), key='output')],
@shinysu
shinysu / file_ops.py
Last active November 7, 2020 07:28
ToDolist using PySimpleGUI and files
def file_write(fname, tasks):
with open(fname, "w") as fp:
for x in tasks:
fp.write("%s\n" % x)
def file_read(fname):
tasks = []
try:
with open(fname, "r") as fp:
@shinysu
shinysu / 0_Session6.py
Last active November 3, 2020 08:52
Programs using files
'''
program to read from a file using read() and write to another file using write()
'''
with open("input.txt","r") as reader:
lines = reader.read()
with open("output.txt","w") as writer:
writer.write(lines)