Loading...
More Python Posts
# Python program for implementation of Selection# Sortimport sysA = [64, 25, 12, 22, 11]# Traverse through all array elementsfor i in range(len(A)):# Find the minimum element in remaining# unsorted arraymin_idx = ifor j in range(i+1, len(A)):if A[min_idx] > A[j]:min_idx = j# Swap the found minimum element with# the first elementA[i], A[min_idx] = A[min_idx], A[i]# Driver code to test aboveprint ("Sorted array")for i in range(len(A)):print("%d" %A[i]),
"""Take screenshots at x interval - make a movie of doings on a computer."""import timefrom datetime import datetimeimport ffmpegimport pyautoguiwhile 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())"""
# Python code to demonstrate# method to remove i'th character# Naive Method# Initializing Stringtest_str = "CodeCatch"# Printing original stringprint ("The original string is : " + test_str)# Removing char at pos 3# using loopnew_str = ""for i in range(len(test_str)):if i != 2:new_str = new_str + test_str[i]# Printing string after removalprint ("The string after removal of i'th character : " + new_str)
# function which return reverse of a stringdef isPalindrome(s):return s == s[::-1]# Driver codes = "malayalam"ans = isPalindrome(s)if ans:print("Yes")else:print("No")
class Rectangle:passclass Square(Rectangle):passrectangle = Rectangle()square = Square()print(isinstance(rectangle, Rectangle)) # Trueprint(isinstance(square, Rectangle)) # Trueprint(isinstance(square, Square)) # Trueprint(isinstance(rectangle, Square)) # False
# Python Program to calculate the square rootnum = float(input('Enter a number: '))num_sqrt = num ** 0.5print('The square root of %0.3f is %0.3f'%(num ,num_sqrt))