Skip to content

Instantly share code, notes, and snippets.

View jestoy0514's full-sized avatar
๐Ÿ˜‚
Happy

Jesus Vedasto A. Olazo jestoy0514

๐Ÿ˜‚
Happy
View GitHub Profile
@jestoy0514
jestoy0514 / wordsearch.py
Last active March 29, 2022 17:41
Word Search Generator
import random
import string
class WordSearch:
def __init__(self, words=[], max_row=10, max_col=10):
""" Initiallize other arguments and empty dictionary container """
self.max_row = max_row
self.max_col = max_col
@jestoy0514
jestoy0514 / extract_text.py
Created March 22, 2022 10:24
Extract text from pdf file
import fitz # This is pymupdf
from PIL import Image
import pytesseract
import tempfile
import os
def read_pdf(filename):
""" This function tries to extracts text from pdfs and store data in dictionary. """
result = {} # Define an empty dictionary for data storage.
with fitz.open(filename) as doc:
@jestoy0514
jestoy0514 / jvparser
Last active August 29, 2015 14:15
String Manipulation
#!/usr/bin/python
# Description: An alternate module for eval function.
#
# Author: Jesus Vedasto Olazo
def math_parser(math_expression):
"""
This module is created in hoping that it will be a alternative
replacement of eval function to be able to use in basic mathematical
@jestoy0514
jestoy0514 / listcomprehensions
Created February 21, 2015 10:23
List Comprehensions
#!/usr/bin/python3
#
# Author: Jesus Vedasto Olazo
# E-mail: jestoy.olazo@gmail.com
# Given list.
number_list = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
# New generated list with only a line of code.
new_list = [number for number in number_list if number%2 == 0]
@jestoy0514
jestoy0514 / stringlist
Created February 21, 2015 09:54
String Lists
#!/usr/bin/python3
#
# Author: Jesus Vedasto Olazo
# E-mail: jestoy.olazo@gmail.com
# Get user string input.
user_input = input("Please enter a strings: ")
# Define a function which will test the string if palindrome or not.
def palindrome(user_string):
@jestoy0514
jestoy0514 / listoverlap
Created February 21, 2015 09:00
List Overlap
#!/usr/bin/python3
#
# Author: Jesus Vedasto Olazo
# E-mail: jestoy.olazo@gmail.com
# Creating the first list.
first_list = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
# Create the second list.
second_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
# Create a blank list for the elements which is common to both list.
@jestoy0514
jestoy0514 / Divisors
Created February 21, 2015 07:16
Divisors
#!/usr/bin/python3
#
# Author: Jesus Vedasto Olazo
# E-mail: jestoy.olazo@gmail.com
result_list = []
try:
# Enter an input and convert the string input to integer.
your_number = int(input("Please enter a number: "))
@jestoy0514
jestoy0514 / listlessthanfive.py
Created January 28, 2015 09:23
Print elements in the list which are less than five and create a new list for elements which are less than five.
#!/usr/bin/env python3
# A python list.
mylist = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
# Create an empty list.
anot_list = []
# Print the number in the list which is less than 5
for number in mylist:
@jestoy0514
jestoy0514 / oddoreven.py
Created January 28, 2015 09:07
Check wether a given number is odd or even number.
#!/usr/bin/env python3
# Ask for input.
number = input('Enter a whole number: ')
number = int(number)
# Check if it is even or odd number and print the result.
if number % 2 == 0:
print(str(number) + ' is even number.')
else:
@jestoy0514
jestoy0514 / character input
Created January 28, 2015 08:01
Character input
#!/usr/bin/env python3
from datetime import date
# Enter your name.
name = input('Please enter your name: ')
# Enter your age.
age = input('Please enter your age: ')
age = int(age)