Skip to content

Commit a5d2d5f

Browse files
committed
script updated
1 parent 59285fc commit a5d2d5f

32 files changed

+353
-22
lines changed

__pycache__/test.cpython-311.pyc

161 Bytes
Binary file not shown.
1.35 KB
Binary file not shown.

book.xml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<library>
2+
<book id="1">
3+
<title>Python for Data Science</title>
4+
<author>
5+
<first_name>John</first_name>
6+
<last_name>Doe</last_name>
7+
</author>
8+
<genre>Data Science</genre>
9+
<price currency="USD">29.99</price>
10+
<publication_year>2020</publication_year>
11+
<publisher>Big Data Publishing</publisher>
12+
</book>
13+
<book id="2">
14+
<title>Machine Learning Basics</title>
15+
<author>
16+
<first_name>Jane</first_name>
17+
<last_name>Smith</last_name>
18+
</author>
19+
<genre>Machine Learning</genre>
20+
<price currency="USD">39.99</price>
21+
<publication_year>2019</publication_year>
22+
<publisher>AI Press</publisher>
23+
</book>
24+
</library>

clock.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Digital Clock with Turtle
2+
import turtle
3+
import time
4+
5+
# set up the screen
6+
wn = turtle.Screen()
7+
wn.bgcolor('black')
8+
wn.setup(width=800,height=600)
9+
10+
# create a turtle for drawing
11+
t = turtle.Turtle()
12+
t.hideturtle()
13+
t.penup()
14+
t.color('green')
15+
t.speed(0)
16+
t.pensize(5)
17+
18+
# function to draw the current time
19+
def draw_time(some_turtle,
20+
time_string):
21+
some_turtle.clear()
22+
some_turtle.write(
23+
time_string,
24+
align='center',
25+
font=('Arial',60,'normal')
26+
)
27+
# continuously update the clock
28+
while True:
29+
c_time = time.strftime(
30+
"%H:%M:%S"
31+
)
32+
draw_time(t, c_time)
33+
time.sleep(1)

coolmath.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from coolmath1 import add
2+
res = add(2, 3)
3+
print(res)

coolmath1/README.md

+13-8
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,20 @@ A simple Python library for basic mathematical operations.
77
You can install this library using pip:
88

99
```bash
10-
pip install coolmath
10+
pip install coolmath1
11+
```
12+
# Usage
1113

12-
python setup.py sdist bdist_wheel
13-
you can upload to the packing library index PyPI
14+
```bash
15+
from coolmath1 import add, subtract, multiply, divide
1416

15-
to upload it
16-
you need to install
17-
pip install twine
17+
result_add = add(5, 3)
18+
result_subtract = subtract(10, 4)
19+
result_multiply = multiply(6, 7)
20+
result_divide = divide(8, 2)
1821

19-
pip install coolmath
22+
print(f"Addition: {result_add}")
23+
print(f"Subtraction: {result_subtract}")
24+
print(f"Multiplication: {result_multiply}")
25+
print(f"Division: {result_divide}")
2026

21-
from coolmath
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Contents of coolmath/coolmath1/__init__.py:
2+
3+
from .math_operations import add, subtract, multiply, divide
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Contents of coolmath/coolmath/math_operations.py:
2+
3+
def add(a, b):
4+
return a + b
5+
6+
def subtract(a, b):
7+
return a - b
8+
9+
def multiply(a, b):
10+
return a * b
11+
12+
def divide(a, b):
13+
if b == 0:
14+
raise ValueError("Cannot divide by zero")
15+
return a / b
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Contents of coolmath/coolmath/__init__.py:
1+
# Contents of coolmath/coolmath1/__init__.py:
22

33
from .math_operations import add, subtract, multiply, divide

coolmath1/coolmath.egg-info/PKG-INFO

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Metadata-Version: 2.1
22
Name: coolmath
3-
Version: 0.1
3+
Version: 0.4
44
Summary: A simple math library
55
Home-page: https://github.com/epythonlab/coolmath
66
Author: Asibeh Tenager
7-
Author-email: epythonlab@epythonlab.com
7+
Author-email: asibeh.tenager@gmail.com
88
Classifier: Development Status :: 3 - Alpha
99
Classifier: Intended Audience :: Developers
1010
Classifier: License :: OSI Approved :: MIT License
@@ -25,3 +25,19 @@ You can install this library using pip:
2525

2626
```bash
2727
pip install coolmath
28+
```
29+
# Usage
30+
31+
```bash
32+
from coolmath import add, subtract, multiply, divide
33+
34+
result_add = add(5, 3)
35+
result_subtract = subtract(10, 4)
36+
result_multiply = multiply(6, 7)
37+
result_divide = divide(8, 2)
38+
39+
print(f"Addition: {result_add}")
40+
print(f"Subtraction: {result_subtract}")
41+
print(f"Multiplication: {result_multiply}")
42+
print(f"Division: {result_divide}")
43+

coolmath1/coolmath1.egg-info/PKG-INFO

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 2.1
22
Name: coolmath1
3-
Version: 0.1
3+
Version: 0.5
44
Summary: A simple math library
55
Home-page: https://github.com/epythonlab/coolmath
66
Author: Asibeh Tenager
@@ -24,15 +24,20 @@ A simple Python library for basic mathematical operations.
2424
You can install this library using pip:
2525

2626
```bash
27-
pip install coolmath
27+
pip install coolmath1
28+
```
29+
# Usage
2830

29-
python setup.py sdist bdist_wheel
30-
you can upload to the packing library index PyPI
31+
```bash
32+
from coolmath1 import add, subtract, multiply, divide
3133

32-
to upload it
33-
you need to install
34-
pip install twine
34+
result_add = add(5, 3)
35+
result_subtract = subtract(10, 4)
36+
result_multiply = multiply(6, 7)
37+
result_divide = divide(8, 2)
3538

36-
pip install coolmath
39+
print(f"Addition: {result_add}")
40+
print(f"Subtraction: {result_subtract}")
41+
print(f"Multiplication: {result_multiply}")
42+
print(f"Division: {result_divide}")
3743

38-
from coolmath

coolmath1/coolmath1/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Contents of coolmath/coolmath/__init__.py:
1+
# Contents of coolmath/coolmath1/__init__.py:
22

33
from .math_operations import add, subtract, multiply, divide
-1.87 KB
Binary file not shown.

coolmath1/dist/coolmath1-0.1.tar.gz

-1.52 KB
Binary file not shown.
2.44 KB
Binary file not shown.

coolmath1/dist/coolmath1-0.4.tar.gz

1.58 KB
Binary file not shown.
2.44 KB
Binary file not shown.

coolmath1/dist/coolmath1-0.5.tar.gz

1.58 KB
Binary file not shown.

coolmath1/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
setup(
66
name="coolmath1",
7-
version="0.1",
7+
version="0.5",
88
packages=find_packages(),
99
install_requires=[],
1010
author="Asibeh Tenager",

demo.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Importing Local Scripts
2+
# demo.py
3+
import test

enumerator.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# enumerate()
2+
nums = [1, 3, 4, 5]
3+
for index, i in enumerate(nums):
4+
print(f'{index}: {i}')

happy_newyear.py

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# @epthonlab on Telegram
2+
# Happy new year, 20024
3+
4+
import time
5+
import random
6+
import turtle
7+
8+
screen_width = 600
9+
screen_height = 400
10+
11+
def draw_star(x, y, size, color):
12+
t.penup()
13+
t.goto(x, y)
14+
t.dot(size, color)
15+
16+
def draw_digit(digit, x, y, size):
17+
t.penup()
18+
t.goto(x, y)
19+
t.pendown()
20+
t.color('white')
21+
t.write(digit, font=("rial", size, "normal"))
22+
23+
def draw_text(text, x, y, size):
24+
t.penup()
25+
t.goto(x, y)
26+
t.pendown()
27+
t.color("white")
28+
t.write(text, align="center",
29+
font=("Arial", size, "normal"))
30+
31+
screen = turtle.Screen()
32+
screen.setup(width=screen_width,
33+
height=screen_height)
34+
screen.bgcolor("midnightblue")
35+
36+
t = turtle.Turtle()
37+
t.speed(0)
38+
t.hideturtle()
39+
40+
for _ in range(100):
41+
draw_star(random.randint(-300,300),
42+
random.randint(-200, 200),
43+
random.randint(2, 6), 'white')
44+
45+
time.sleep(0.5)
46+
draw_digit("2", -50, 0, 36)
47+
time.sleep(0.5)
48+
draw_digit("0", 0, 0, 36)
49+
time.sleep(0.5)
50+
draw_digit("2", 50, 0, 36)
51+
time.sleep(0.5)
52+
draw_digit("4", 100, 0, 36)
53+
54+
time.sleep(0.5)
55+
56+
draw_text("HAPPY NEW YEAR!", 0, -50, 18)
57+
58+
screen.exitonclick()

list_comprehension.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# List Comprehension
2+
3+
squares = [x**2 for x in range(10)]
4+
print(squares)
5+
6+
# option 2
7+
nums = []
8+
for i in range(10):
9+
nums.append(i**2)
10+
print(nums)

max_subarray_sum.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Python challenge: Given an array of integers,
2+
# find the maximum possible sum of a subarray,
3+
# where the subarray must contain at least one element.
4+
# - This is a classic algorithmic problem that
5+
# can be solved with a dynamic programming approach.
6+
7+
8+
def max_subarray_sum(nums):
9+
if not nums:
10+
return 0 # empty array
11+
12+
max_sum = nums[0]
13+
current_sum = nums[0]
14+
15+
for num in nums[1:]:
16+
current_sum = max(num, current_sum + num)
17+
max_sum = max(max_sum, current_sum)
18+
return max_sum
19+
20+
# test this function
21+
nums = [-2, 1, -3, 4, -1, 2, 1, -5, 4]
22+
23+
result = max_subarray_sum(nums)
24+
print(f'max subarray sum is: {result}')

oc.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import cv2
2+
import pytesseract
3+
from PIL import Image
4+
5+
# Path to the Tesseract executable in Google Colab
6+
pytesseract.pytesseract.tesseract_cmd = '/usr/bin/tesseract'
7+
8+
# Load the image from the specified path
9+
image_path = 'math.jpg'
10+
image = cv2.imread(image_path)
11+
12+
# Convert the image to grayscale
13+
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
14+
15+
# Apply thresholding to preprocess the image
16+
_, thresh = cv2.threshold(gray, 150, 255, cv2.THRESH_BINARY)
17+
18+
# Perform OCR on the preprocessed image
19+
custom_config = r'--oem 3' # Customize configuration as needed
20+
text = pytesseract.image_to_string(thresh, config=custom_config)
21+
22+
# Print the extracted text
23+
print("Extracted text:", text)

parsexml.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Converting XML into Pandas DataFrame
2+
3+
# import the necessary libraries
4+
import pandas as pd
5+
import xml.etree.ElementTree as et
6+
7+
# parse the xml file
8+
tree = et.parse('book.xml')
9+
root = tree.getroot()
10+
#print(root)
11+
12+
# extract the data
13+
books_list = []
14+
for book_elem in root.findall('.//book'):
15+
book_dict = {}
16+
book_dict['id'] = book_elem.get('id')
17+
for child_elem in book_elem:
18+
book_dict[child_elem.tag] = child_elem.text
19+
books_list.append(book_dict)
20+
print(books_list)
21+
22+
# convert to the dataframe
23+
df = pd.DataFrame(books_list)
24+
print(df)

sens.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import os
2+
import sys
3+
from com.dtmilano.android.viewclient import ViewClient
4+
5+
device, serialno = ViewClient.connectToDeviceOrExit()
6+
7+
# Get the sensor data
8+
sensor_data, _ = device.shell('dumpsys sensorservice')
9+
10+
# Print the sensor data
11+
print(sensor_data)

solve_dervetive.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import pytesseract
2+
from PIL import Image
3+
import sympy as sp
4+
5+
# Load the image
6+
img = Image.open('math.jpg')
7+
8+
# Use pytesseract to do OCR on the image
9+
text = pytesseract.image_to_string(img)
10+
11+
# Print the extracted text
12+
print("Extracted Text:", text)
13+
14+
# Parse the extracted text into a format that can be understood by SymPy
15+
parsed_expression = sp.sympify(text)
16+
17+
# Compute the derivative using SymPy
18+
derivative = sp.diff(parsed_expression, 'x')
19+
20+
# Print the original expression and its derivative
21+
print("Original Expression:", parsed_expression)
22+
print("Derivative:", derivative)

0 commit comments

Comments
 (0)