• Sep 9, 2023 •AustinLeath
0 likes • 24 views
print("test")
• Nov 19, 2022 •CodeCatch
0 likes • 0 views
# Python program for implementation of Selection # Sort import sys A = [64, 25, 12, 22, 11] # Traverse through all array elements for i in range(len(A)): # Find the minimum element in remaining # unsorted array min_idx = i for j in range(i+1, len(A)): if A[min_idx] > A[j]: min_idx = j # Swap the found minimum element with # the first element A[i], A[min_idx] = A[min_idx], A[i] # Driver code to test above print ("Sorted array") for i in range(len(A)): print("%d" %A[i]),
• Mar 12, 2021 •mo_ak
0 likes • 2 views
prime_lists=[] # a list to store the prime numbers def prime(n): # define prime numbers if n <= 1: return False # divide n by 2... up to n-1 for i in range(2, n): if n % i == 0: # the remainder should'nt be a 0 return False else: prime_lists.append(n) return True for n in range(30,1000): # calling function and passing starting point =30 coz we need primes >30 prime(n) check=0 # a var to limit the output to 10 only for n in prime_lists: for x in prime_lists: val= n *x if (val > 1000 ): check=check +1 if (check <10) : print("the num is:", val , "=",n , "* ", x ) break
0 likes • 1 view
import math def factorial(n): print(math.factorial(n)) return (math.factorial(n)) factorial(5) factorial(10) factorial(15)
• Nov 18, 2022 •AustinLeath
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 control bindDN = 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 = 3 conn.set_option(ldap.OPT_REFERRALS, 0) #authenticate the connection so that you can make additional queries try: result = conn.simple_bind_s(bindDN, bindPass) except ldap.INVALID_CREDENTIALS: result = "Invalid credentials for %s" % user sys.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
• 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)