diff --git a/sum_of_digits_of_a_number.py b/sum_of_digits_of_a_number.py index 64d62b281b7..f17fd6bcf41 100644 --- a/sum_of_digits_of_a_number.py +++ b/sum_of_digits_of_a_number.py @@ -13,6 +13,8 @@ 0 >>> sum_of_digits(999) 27 + >>> sum_of_digits(-123) + 6 """ import sys @@ -49,8 +51,8 @@ def sum_of_digits(n: int) -> int: Compute the sum of the digits of an integer. Args: - n:Non-negative integer - If the integer is negative , it is converted to postive interger and assigned to same number + n: Non-negative integer. + If the integer is negative, it is converted to positive before computing the sum. Returns: Sum of digits of the number. @@ -60,8 +62,10 @@ def sum_of_digits(n: int) -> int: 6 >>> sum_of_digits(405) 9 + >>> sum_of_digits(-789) + 24 """ - n=abs(n) + n = abs(n) # FIX: handle negative numbers total = 0 while n > 0: # Add last digit and remove it from n diff --git a/youtubedownloader.py b/youtubedownloader.py index 80362a737f3..b4b813e7b5e 100644 --- a/youtubedownloader.py +++ b/youtubedownloader.py @@ -1,10 +1,15 @@ -from tkinter import Button, Entry, Label, Tk, filedialog, messagebox -from threading import Thread -from pytube import YouTube +# modules for Using of app +from tkinter import Button, Entry, Label, Tk, filedialog, messagebox # Gui Modules +from threading import Thread # modules for multi threding +from pytube import YouTube # Module for Youtube service + +# this function for mulple code runes at a time def threading(): # Call work function t1 = Thread(target=download) t1.start() + +# this function for Download Youtube video def download(): try: url = YouTube(str(url_box.get())) @@ -18,7 +23,7 @@ def download(): else: messagebox.showwarning("", "Download cancelled!") except Exception: - messagebox.showerror("Error", "An error occurred while downloading the video.") + messagebox.showerror("Error", "Some Thing Went Wrong!!!\nplease try again") # This code runes on only this file @@ -40,13 +45,15 @@ def download(): ) introlable.place(x=35, y=20) - Label(root, text="Enter YouTube Link", font=("sans-serif", 16), bg="olivedrab1").place( + Label(root, text="Enter YouTube Link", font=("sans-serif", 16), bg="olivedrab1", fg='Black').place( x=40, y=150 ) + # entry box in UI url_box = Entry(root, font=("arial", 30), width=30) url_box.place(x=40, y=180) + # download button in UI btn = Button(root, text="DOWNLOAD", font=("sans-serif", 25), command=threading) btn.place(x=270, y=240) root.mainloop()