def python_sort(a_list): var1 = ct() a_list.sort() var2 = ct() var = var2 - var1 return var
def shell_sort(a_list): var1 = ct() sublist_count = len(a_list) // 2 while sublist_count > 0: for start_position in range(sublist_count): gap_insertion_sort(a_list, start_position, sublist_count) sublist_count //= 2 var2 = ct() var = var2 - var1 return var
def sequential_search(a_list, item): var1 = ct() pos = 0 found = False while pos < len(a_list) and not found: if a_list[pos] == item: found = True else: pos = pos + 1 var2 = ct() var = var2 - var1 return found, var
def insertion_sort(a_list): var1 = ct() for index in range(1, len(a_list)): current_value = a_list[index] position = index while position > 0 and a_list[position - 1] > current_value: a_list[position] = a_list[position - 1] position = position - 1 a_list[position] = current_value var2 = ct() var = var2 - var1 return var
def binary_search_iterative(a_list, item): var1 = ct() first = 0 last = len(a_list) - 1 found = False while first <= last and not found: midpoint = (first + last) // 2 if a_list[midpoint] == item: found = True else: if item < a_list[midpoint]: last = midpoint - 1 else: first = midpoint + 1 var2 = ct() var = var2 - var1 return found, var
def binary_search_recursive(a_list, item): var1 = ct() def _binary_search_recursive(a_list, item): if len(a_list) == 0: return False else: midpoint = len(a_list) // 2 if a_list[midpoint] == item: return True else: if item < a_list[midpoint]: return _binary_search_recursive(a_list[:midpoint], item) else: return _binary_search_recursive(a_list[midpoint + 1:], item) found = _binary_search_recursive(a_list, item) var2 = ct() var = var2 - var1 return found, var
import os from time import ctime as ct print("Current Dir : ", os.getcwd()) files = os.listdir() print("Dir list : ", files) print(len(files)) print(type(files)) # print only .py file for file in files: if file.endswith('.py'): print(file) print("Dir list[C:] : ", os.listdir("C:/")) print(ct())
# In[8]: del ctime #메모리에 있는 ctime함수를 unload # In[9]: # import 모듈명 as 별칭 import time as t t.ctime() # In[12]: #4. from 모듈명 import 함수명 as 별칭 # from 패키지명 import 모듈명 as 별칭 from time import ctime as ct ct() #ctime()으로 하면 에러 발생 # In[13]: del ct # In[14]: import time #numpay, pandas 등 자주 사용(필요할 때만 로드해서 사용) # In[15]: dir(time) #time안에 있는 변수, 함수, 클래스 등을 list로 출력 # In[17]:
def update_status(self, stuff): self.Status = stuff self.statuslb.insert(END, str(ct()) + ":" + self.Status) self.statuslb.see(END) self.top.update() return
def noOp(self): self.print_line("-------- Action not implemented. ----------") self.print_line("The time is now [%s]" % str(ct()))
# This file aims at scrapping a youtube channel in order to get data as: # the number of subscribers, the number of views and the starting date of this # particular channel. channelName="Mister Geopolitix" channelUrl="https://www.youtube.com/channel/UCX9lsdsTKfTi1eqoyL-RS-Q/about" #Opening connection, grabbing the page uClient = uReq(channelUrl) pageHtml = uClient.read() uClient.close() # Using beautifulsoup module we parse the source code of the webpage pageSoup = soup(pageHtml, "html.parser") # We are seeking the 'about-stat' span section: stats = pageSoup.findAll("span", {"class", "about-stat"}) # Values Extraction nbSubs = stats[0].find("b").text.replace('\xa0', ' ') nbViews = stats[1].find("b").text.replace('\xa0', ' ') startDate = stats[2].text.replace('\xa0', ' ') # Save data in a file with the current date record = open("log.txt", "a") date = ct() #current time record.write(channelName+","+nbSubs+","+nbViews+","+date+"\n") print( channelName + "\t" + nbSubs + " abonnés \t" + nbViews + " vues")