Skip to content

Commit 3eb85c9

Browse files
Add files via upload
1 parent 7614c86 commit 3eb85c9

26 files changed

+435
-0
lines changed

average.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
no_list = [10, 20, 30, 40]
2+
3+
def average(x):
4+
sum = 0
5+
for num in x:
6+
sum += num
7+
return sum / len(x)
8+
9+
print(average(no_list))

breakify.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def breakify(strings):
2+
return "<br>".join(strings)
3+
4+
lines = ["Haiku frogs in snow",
5+
"A limerick came from Nantucket",
6+
"Tetrametric drum-beats thrumming, Hiawathianic rhythm."]
7+
print(breakify(lines))

concatenation.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
def adverbly(s):
2+
return s + 'ly'
3+
4+
print(adverbly("quick"))

count_chrSub.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
def count_character(string, target):
2+
index = 0
3+
total = 0
4+
while index < len(string):
5+
if string[index] == target:
6+
total += 1
7+
index += 1
8+
print(total)
9+
count_character("papa pony and the parcel post problem", "p")
10+
11+
def count_substring(string, sub):
12+
total = 0
13+
index = 0
14+
while index < len(string):
15+
if string[index : index + len(sub)] == sub:
16+
total += 1
17+
index += len(sub)
18+
else:
19+
index += 1
20+
print(total)
21+
22+
count_substring('love, love, love, all you need is love', 'love')
23+
count_substring('AAAA', 'AA')

countdown.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import time
2+
n = 10
3+
while n > 0:
4+
print(n)
5+
n -= 1
6+
time.sleep(1)
7+
8+
print("Blastoff!")

demo.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
n1 = input("Enter a First number: ")
2+
n2 = input("Enter a Second number: ")
3+
n3 = input("Enter a Third number: ")
4+
sum = int(n1) + int(n2) + int(n3)
5+
print(f"{n1} + {n2} + {n3} = {sum}")
6+
dif = int(n1) - int(n2) - int(n3)
7+
print(n1 + ' - ' + n2 + ' - ' + n3 + ' = ' + str(dif))

downTube.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import tkinter as tk
2+
from tkinter import *
3+
from pytube import *
4+
from tkinter import messagebox
5+
6+
# from pytube import YouTube
7+
# from pytube import streams
8+
# from pytube.streams import Stream
9+
10+
root = tk.Tk()
11+
root.title('Youtube Downloader')
12+
root.geometry('500x200')
13+
14+
link_var = StringVar()
15+
link = link_var.get()
16+
17+
ytb = YouTube
18+
19+
# video = ytb(link)
20+
21+
22+
def url():
23+
link = link_var.get()
24+
yt = ytb(link)
25+
# filter(progressive=True, res=" 1080p", subtype='mp4')
26+
stream = yt.streams.get_highest_resolution()
27+
stream.download('C:/Users/abdel/Videos/Youtube')
28+
link_var.set("")
29+
messagebox.showinfo(title='Download', message='Done')
30+
31+
32+
def info():
33+
video = ytb(link)
34+
35+
print(f"Title: \n {video.title} \n ")
36+
print(f"Description: \n {video.description} \n")
37+
print(f"Views: \n {video.views} watchers \n ")
38+
print(f"Rating: \n {video.rating} / 5 \n ")
39+
print(f"Duration \n{video.length/60} minutes \n ")
40+
41+
42+
title = Label(root, text='Youtube Downloader',
43+
font=('Helvatical bold', 30, 'bold')).pack()
44+
45+
ent = Entry(root, width="50", textvariable=link_var).pack()
46+
47+
info = Button(root, text='Get Info', command=info).pack()
48+
49+
down = Button(root, text='Download', command=url).pack()
50+
51+
l = Label(root, text='By ABDELILAH').pack(side=BOTTOM)
52+
53+
root.mainloop()
54+
55+
56+
def finish():
57+
print("Download Done")
58+
59+
60+
video.register_on_complete_callback(finish())

find_num.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def find_512(x, y):
2+
for x in range(100):
3+
for y in range(100):
4+
if x * y == 512:
5+
return f"{x} * {y} == 512"
6+
print(f"{x} * {y} == 512")
7+
8+
x = 0
9+
y = 0
10+
find_512(x, y)

helloWorld.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import tkinter
2+
from tkinter import *
3+
4+
tk = Tk()
5+
tk.title('First App')
6+
tk.geometry('250x100')
7+
8+
9+
frame = Frame(tk, relief=SUNKEN, borderwidth=2, bd=2, bg="white",
10+
highlightbackground="blue", highlightthickness=2)
11+
frame.pack(fill=BOTH, expand=1)
12+
13+
var = StringVar()
14+
var.set("Hello World")
15+
16+
label = Label(frame, textvariable=var, fg="red",
17+
bg="yellow", cursor="dot", relief=RAISED, underline=5, wraplength=50)
18+
label.pack(expand=1)
19+
20+
button = Button(frame, text="Exit", command=tk.destroy,
21+
padx=10, pady=3, bg="skyblue", activebackground="blue")
22+
button.pack(side=BOTTOM)
23+
24+
tk.mainloop()

locate_first.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
def locate_first(string, sub):
2+
index = 0
3+
while index < len(string):
4+
if string[index : index + len(sub)] == sub:
5+
return index
6+
else:
7+
index += 1
8+
return -1
9+
10+
print(locate_first('cookbook', 'ook'))
11+
print(locate_first('all your bass are belong to us', 'base'))
12+
13+
def locate_all(string, sub):
14+
matches = []
15+
index = 0
16+
while index < len(string):
17+
if string[index : index + len(sub)] == sub:
18+
matches.append(index)
19+
index += len(sub)
20+
else:
21+
index += 1
22+
print(matches)
23+
locate_all('cookbook', 'ook')

0 commit comments

Comments
 (0)