Loading...
More Python Posts
primes=[]products=[]def prime(num):if num > 1:for i in range(2,num):if (num % i) == 0:return Falseelse:primes.append(num)return Truefor 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)
def get_ldap_user(member_cn, user, passwrd):'''Get an LDAP user and return the SAMAccountName'''#---- Setting up the Connection#account used for binding - Avoid putting these in version controlbindDN = str(user) + "@unt.ad.unt.edu"bindPass = passwrd#set some tuneables for the LDAP library.ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_ALLOW)#ldap.set_option(ldap.OPT_X_TLS_CACERTFILE, CACERTFILE)conn = ldap.initialize('ldaps://unt.ad.unt.edu')conn.protocol_version = 3conn.set_option(ldap.OPT_REFERRALS, 0)#authenticate the connection so that you can make additional queriestry:result = conn.simple_bind_s(bindDN, bindPass)except ldap.INVALID_CREDENTIALS:result = "Invalid credentials for %s" % usersys.exit()#build query in the form of (uid=user)ldap_query = '(|(displayName=' + member_cn + ')(cn='+ member_cn + ')(name=' + member_cn + '))'ldap_info = conn.search_s('DC=unt,DC=ad,DC=unt,DC=edu', ldap.SCOPE_SUBTREE, filterstr=ldap_query)sAMAccountName = str(ldap_info[0][1]['sAMAccountName']).replace("[b'", "").replace("']","")return sAMAccountName
# Prompt user for base and heightbase = float(input("Enter the base of the triangle: "))height = float(input("Enter the height of the triangle: "))# Calculate the areaarea = (base * height) / 2# Display the resultprint("The area of the triangle is:", area)
print("hellur")
"""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())"""
""" Calculator----------------------------------------"""def addition ():print("Addition")n = float(input("Enter the number: "))t = 0 //Total number enterans = 0while n != 0:ans = ans + nt+=1n = float(input("Enter another number (0 to calculate): "))return [ans,t]def subtraction ():print("Subtraction");n = float(input("Enter the number: "))t = 0 //Total number entersum = 0while n != 0:ans = ans - nt+=1n = float(input("Enter another number (0 to calculate): "))return [ans,t]def multiplication ():print("Multiplication")n = float(input("Enter the number: "))t = 0 //Total number enterans = 1while n != 0:ans = ans * nt+=1n = float(input("Enter another number (0 to calculate): "))return [ans,t]def average():an = []an = addition()t = an[1]a = an[0]ans = a / treturn [ans,t]// main...while True:list = []print(" My first python program!")print(" Simple Calculator in python by Malik Umer Farooq")print(" Enter 'a' for addition")print(" Enter 's' for substraction")print(" Enter 'm' for multiplication")print(" Enter 'v' for average")print(" Enter 'q' for quit")c = input(" ")if c != 'q':if c == 'a':list = addition()print("Ans = ", list[0], " total inputs ",list[1])elif c == 's':list = subtraction()print("Ans = ", list[0], " total inputs ",list[1])elif c == 'm':list = multiplication()print("Ans = ", list[0], " total inputs ",list[1])elif c == 'v':list = average()print("Ans = ", list[0], " total inputs ",list[1])else:print ("Sorry, invilid character")else:break