This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')] | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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')], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
check if an element is present in the list | |
you can use 'in' operator to check if the element is present and 'not in' operator to check if the element is not present | |
''' | |
cart = ['ice cream', 'chocolates', 'bread', 'jam', 'butter'] | |
item = input("Enter the element you want to search: ") | |
if item in cart: | |
print("yes, the element is present") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
using for loop to print numbers 1 to 10 | |
range(a, b+1) starts from a and ends at b | |
''' | |
for i in range(1, 11): | |
print(i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
print a string | |
''' | |
print("hello!") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pgzrun | |
from random import randint | |
WIDTH = 800 | |
HEIGHT = 600 | |
BLACK = (0, 0, 0) | |
paddle = {"x": 20, "y": HEIGHT-50, "length": 200, "width":25} | |
ball = {"x": 0, "y": 0, "move_x": 5, "move_y": 5} | |
BALL_RADIUS = 25 |