• Jan 23, 2021 •asnark
0 likes • 1 view
""" Take screenshots at x interval - make a movie of doings on a computer. """ import time from datetime import datetime import ffmpeg import pyautogui while True: epoch_time = int(time.time()) today = datetime.now().strftime("%Y_%m_%d") filename = str(epoch_time) + ".png" print("taking screenshot: {0}".format(filename)) myScreenshot = pyautogui.screenshot() myScreenshot.save(today + "/" + filename) time.sleep(5) # # and then tie it together with: https://github.com/kkroening/ffmpeg-python/blob/master/examples/README.md#assemble-video-from-sequence-of-frames # """ import ffmpeg ( ffmpeg .input('./2021_01_22/*.png', pattern_type='glob', framerate=25) .filter('deflicker', mode='pm', size=10) .filter('scale', size='hd1080', force_original_aspect_ratio='increase') .output('movie.mp4', crf=20, preset='slower', movflags='faststart', pix_fmt='yuv420p') .run() ) """
• Nov 19, 2022 •CodeCatch
0 likes • 3 views
# Python program for implementation of Bubble Sort def bubbleSort(arr): n = len(arr) # Traverse through all array elements for i in range(n-1): # range(n) also work but outer loop will repeat one time more than needed. # Last i elements are already in place for j in range(0, n-i-1): # traverse the array from 0 to n-i-1 # Swap if the element found is greater # than the next element if arr[j] > arr[j+1] : arr[j], arr[j+1] = arr[j+1], arr[j] # Driver code to test above arr = [64, 34, 25, 12, 22, 11, 90] bubbleSort(arr) print ("Sorted array is:") for i in range(len(arr)): print ("%d" %arr[i]),
• Feb 26, 2023 •wabdelh
#You are given a two-digit integer n. Return the sum of its digits. #Example #For n = 29 the output should be solution (n) = 11 def solution(n): return (n//10 + n%10)
• Nov 18, 2022 •AustinLeath
0 likes • 4 views
primes=[] products=[] def prime(num): if num > 1: for i in range(2,num): if (num % i) == 0: return False else: primes.append(num) return True for n in range(30,1000): if len(primes) >= 20: break; else: prime(n) for previous, current in zip(primes[::2], primes[1::2]): products.append(previous * current) print (products)
# Python program for implementation of Radix Sort # A function to do counting sort of arr[] according to # the digit represented by exp. def countingSort(arr, exp1): n = len(arr) # The output array elements that will have sorted arr output = [0] * (n) # initialize count array as 0 count = [0] * (10) # Store count of occurrences in count[] for i in range(0, n): index = (arr[i]/exp1) count[int((index)%10)] += 1 # Change count[i] so that count[i] now contains actual # position of this digit in output array for i in range(1,10): count[i] += count[i-1] # Build the output array i = n-1 while i>=0: index = (arr[i]/exp1) output[ count[ int((index)%10) ] - 1] = arr[i] count[int((index)%10)] -= 1 i -= 1 # Copying the output array to arr[], # so that arr now contains sorted numbers i = 0 for i in range(0,len(arr)): arr[i] = output[i] # Method to do Radix Sort def radixSort(arr): # Find the maximum number to know number of digits max1 = max(arr) # Do counting sort for every digit. Note that instead # of passing digit number, exp is passed. exp is 10^i # where i is current digit number exp = 1 while max1/exp > 0: countingSort(arr,exp) exp *= 10 # Driver code to test above arr = [ 170, 45, 75, 90, 802, 24, 2, 66] radixSort(arr) for i in range(len(arr)): print(arr[i]),
• Mar 10, 2021 •Skrome
0 likes • 2 views
color2 = (60, 74, 172) color1 = (19, 28, 87) percent = 1.0 for i in range(101): resultRed = round(color1[0] + percent * (color2[0] - color1[0])) resultGreen = round(color1[1] + percent * (color2[1] - color1[1])) resultBlue = round(color1[2] + percent * (color2[2] - color1[2])) print((resultRed, resultGreen, resultBlue)) percent -= 0.01