Skip to content

Commit 4ecbe50

Browse files
committed
third commit
0 parents  commit 4ecbe50

17 files changed

+1162
-0
lines changed

Calculator/calculator.pyw

+596
Large diffs are not rendered by default.

Calculator/entry test.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from tkinter import *
2+
3+
root = Tk()
4+
s = ""
5+
e = Entry(root)
6+
e.pack()
7+
8+
def cle():
9+
global s
10+
e.place(x=0, y=0)
11+
e.insert(0, "")
12+
s = ""
13+
14+
def callback():
15+
print(e.get())
16+
17+
b = Button(root, text="get", width=10, command=callback)
18+
b.pack()
19+
b = Button(root, text="cle", width=10, command=cle)
20+
b.pack()
21+
22+
mainloop()
23+

Calculator/proper gui.py

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
from tkinter import *
2+
3+
def p():
4+
print("UU")
5+
6+
7+
class Window(Frame):
8+
9+
# Define settings upon initialization. Here you can specify
10+
def __init__(self, master=None):
11+
12+
# parameters that you want to send through the Frame class.
13+
Frame.__init__(self, master)
14+
15+
#reference to the master widget, which is the tk window
16+
self.master = master
17+
18+
#with that, we want to then run init_window, which doesn't yet exist
19+
self.init_window()
20+
21+
#Creation of init_window
22+
def init_window(self):
23+
24+
# changing the title of our master widget
25+
self.master.title("GUI")
26+
27+
# allowing the widget to take the full space of the root window
28+
self.pack(fill=BOTH, expand=1)
29+
30+
# creating a menu instance
31+
menu = Menu(self.master)
32+
self.master.config(menu=menu)
33+
34+
# create the file object)
35+
file = Menu(menu)
36+
37+
# adds a command to the menu option, calling it exit, and the
38+
# command it runs on event is client_exit
39+
file.add_command(label="Exit", command=self.client_exit)
40+
41+
#added "file" to our menu
42+
menu.add_cascade(label="File", menu=file)
43+
44+
# create the file object)
45+
edit = Menu(menu)
46+
47+
# adds a command to the menu option, calling it exit, and the
48+
# command it runs on event is client_exit
49+
edit.add_command(label="Undo", command=p)
50+
edit.add_command(label="Redo")
51+
52+
#added "file" to our menu
53+
menu.add_cascade(label="Edit", menu=edit)
54+
55+
# creating a button instance
56+
quitButton = Button(self, text="Exit",command=self.client_exit)
57+
58+
# placing the button on my window
59+
quitButton.place(x=10, y=10)
60+
61+
def client_exit(self):
62+
exit()
63+
64+
65+
# root window created. Here, that would be the only window, but
66+
# you can later have windows within windows.
67+
root = Tk()
68+
69+
root.geometry("400x300")
70+
71+
#creation of an instance
72+
app = Window(root)
73+
74+
#mainloop
75+
root.mainloop()

HTML.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
time = 0
2+
output = ""
3+
number = int(input("number "))
4+
coulor = input("colour ")
5+
for time in range(number):
6+
line = '<h1 style= "color:' + coulor + '">' + str(time) + '</h1>'
7+
output += line
8+
9+
f = open("output.txt","w")
10+
f.write(output)
11+
f.close()
12+
13+
print("done")
14+
input("Press enter to exit...")
15+
16+
17+
18+

L or R.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from random import randint
2+
from sys import exit
3+
4+
5+
while True:
6+
score = 0
7+
count = 0
8+
9+
while count <= 10:
10+
count += 1
11+
rand = randint(0,1)
12+
if rand == 0:
13+
print("*")
14+
correct = "l"
15+
if rand == 1:
16+
print(" *")
17+
correct = "r"
18+
print("left or right")
19+
answer = input("l or r")
20+
if answer == correct:
21+
score += 1
22+
print("==============================================================================")
23+
24+
print(str(score) + "/10")
25+
if score == 10:
26+
print("winner")
27+
else:
28+
print("looser")
29+
30+
if input("Enter play to play agan.") == "":
31+
exit()
32+
print("==============================================================================")
33+
34+

Mathematical/Only adding.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
def sub(x, y):
2+
ans = x + int("-" + str(y))
3+
return(ans)
4+
5+
def mul(x, y):
6+
ans = 0
7+
for i in range(y):
8+
ans += x
9+
return(ans)
10+
11+
def div(x, y, places=2):
12+
ans = str(divmod_(x, y)[0]) + "."
13+
for i in range(places):
14+
x = int(str(divmod_(x, y)[1]) + "0")
15+
ans += str(divmod_(x, y)[0])
16+
return(ans)
17+
18+
def divmod_(x, y):
19+
count = 0
20+
while x >= y:
21+
x = sub(x, y)
22+
count += 1
23+
return(count, x)
24+
25+
def pow(x, y):
26+
ans = x
27+
for i in range(y-1):
28+
ans = mul(ans, x)
29+
return(ans)
30+
31+
print(div(7, 2))

Mathematical/Pythagoras.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import math
2+
3+
while True:
4+
long = float(input("long "))
5+
short = float(input("short "))
6+
7+
print(round(math.sqrt(long * long - short * short), 1))
8+
print("")
9+
10+

Mathematical/happy primes.py

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
n1 = 0
2+
n2 = 0
3+
n3 = 0
4+
n4 = 0
5+
n5 = 0
6+
n6 = 0
7+
8+
while True:
9+
print("+-*/=Happy Primes=/*-+")
10+
print("For help press enter.")
11+
number = input("Prime ")
12+
13+
if number == "":
14+
print("Enter a number to see if it is prime or enter a prime to see if it is a happy prime. If it is not a happy prime it wont do anything.")
15+
print("")
16+
17+
else:
18+
divide = 1
19+
prime = 1
20+
while prime == 1 and divide < 12:
21+
divide += 1
22+
if divide == int(number):
23+
divide += 1
24+
if int(number) % divide == 0 or number == "1":
25+
prime = 0
26+
print("Not Prime")
27+
28+
if prime == 1:
29+
print("Prime")
30+
while int(number) > 1:
31+
n1 = int(number[0])
32+
if len(number) >= 10:
33+
n2 = int(number[1])
34+
if len(number) >= 100:
35+
n3 = int(number[2])
36+
if len(number) >= 1000:
37+
n4 = int(number[3])
38+
if len(number) >= 10000:
39+
n5 = int(number[4])
40+
if len(number) >= 100000:
41+
n6 = int(number[5])
42+
43+
number = str(n1 * n1 + n2 * n2 + n3 * n3 + n4 * n4 + n5 * n5 + n6 * n6)
44+
45+
if int(number[0]) == 1:
46+
print("Happy Prime")
47+
print("")
48+

Random.py

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
from random import randint
2+
3+
while True:
4+
print("0===============0===========0===========0")
5+
print("¦ Random Number ¦ Roll Dice ¦ Flip Coin ¦")
6+
print("¦ (1) ¦ (2) ¦(3) ¦")
7+
print("0===============0===========0===========0")
8+
choice = input("Select an option ")
9+
10+
if choice == "1":
11+
fromv = int(input("From "))
12+
tov = int(input("To "))
13+
print(randint(fromv, tov))
14+
print("")
15+
16+
if choice == "2":
17+
side = randint(1, 6)
18+
print("")
19+
if side == 1:
20+
print(" ")
21+
print(" O ")
22+
print(" ")
23+
24+
if side == 2:
25+
print(" O ")
26+
print(" ")
27+
print(" O ")
28+
29+
if side == 3:
30+
print(" O ")
31+
print(" O ")
32+
print(" O ")
33+
34+
if side == 4:
35+
print(" O O ")
36+
print(" ")
37+
print(" O O ")
38+
39+
if side == 5:
40+
print(" O O ")
41+
print(" O ")
42+
print(" O O ")
43+
44+
if side == 6:
45+
print(" O O ")
46+
print(" O O ")
47+
print(" O O ")
48+
49+
print("")
50+
51+
if choice == "3":
52+
side = randint(1, 2)
53+
print("")
54+
if side == 1:
55+
print("Heads")
56+
else:
57+
print("Tails")
58+
print("")
59+
60+
61+
62+
63+

Text scroll/Text scroll.pyw

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from tkinter import *
2+
import time, random, threading, os
3+
def new():
4+
f = open("put text hear.txt","w")
5+
f.write("Test")
6+
f.close
7+
8+
def edit():
9+
os.startfile("put text hear.txt")
10+
11+
def start():
12+
f = open("put text hear.txt","r")
13+
text = f.read()
14+
f.close
15+
16+
for char in text:
17+
t.insert("end",char)
18+
time.sleep(random.randint(0,150)/1000.0)
19+
20+
def starting():
21+
tsss = threading.Thread(target=start)
22+
tsss.start()
23+
24+
root = Tk()
25+
root.winfo_toplevel().title("Scroll Text")
26+
t = Text(root)
27+
t.pack()
28+
Button(root,text="Start",command=starting).pack()
29+
Button(root,text="New",command=new).pack(side=LEFT)
30+
Button(root,text="Open",command=edit).pack(side=RIGHT)
31+
root.mainloop()

google it.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import webbrowser
2+
3+
question = input("Question? ")
4+
url = "https://www.google.com/search?q=" + question.replace(" ", "+")
5+
print(url)
6+
webbrowser.open(url)

lines of code.py

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import os
2+
3+
def search(path, indent=""):
4+
ret = ""
5+
tlines = 0
6+
tcomments = 0
7+
files = 0
8+
for i, n in enumerate(os.listdir(path)):
9+
if n[-3:] == ".py" or n[-4:] == ".pyw":
10+
files += 1
11+
with open(os.path.join(path, n), "r") as f:
12+
content = f.read().split("\n")
13+
14+
lines = 0
15+
comments = 0
16+
for i, l in enumerate(content):
17+
line = l.strip(" ")
18+
if len(line) > 1:
19+
if line[0] == "#":
20+
comments += 1
21+
else:
22+
lines += 1
23+
24+
tlines += lines
25+
lines = indent + "Lines: " + str(lines) + "\n"
26+
tcomments += comments
27+
comments = indent + "Comments: " + str(comments) + "\n"
28+
ret += indent + n + "\n" + lines + comments + "\n"
29+
30+
31+
elif os.path.isdir(os.path.join(path, n)):
32+
if n != "Modules":
33+
level = search(os.path.join(path, n), indent=indent + " ")
34+
if level[0] != "":
35+
ret += indent + n + os.sep + "\n\n"
36+
ret += level[0]
37+
tlines += level[1]
38+
tcomments += level[2]
39+
if tlines > 1 and files > 1:
40+
ret += indent + "Total lines: " + str(tlines) + "\n"
41+
ret += indent + "Total comments: " + str(tcomments) + "\n\n\n"
42+
return ret, tlines, tcomments
43+
44+
path = input("Path to search ")
45+
if path == "":
46+
path = "."
47+
print(search(path)[0])
48+
input("Press enter to exit. ")
49+

0 commit comments

Comments
 (0)