Loading...
More Python Posts
#You are given a two-digit integer n. Return the sum of its digits.#Example#For n = 29 the output should be solution (n) = 11def solution(n):return (n//10 + n%10)
print("hellur")
color2 = (60, 74, 172)color1 = (19, 28, 87)percent = 1.0for 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
def to_roman_numeral(num):lookup = [(1000, 'M'),(900, 'CM'),(500, 'D'),(400, 'CD'),(100, 'C'),(90, 'XC'),(50, 'L'),(40, 'XL'),(10, 'X'),(9, 'IX'),(5, 'V'),(4, 'IV'),(1, 'I'),]res = ''for (n, roman) in lookup:(d, num) = divmod(num, n)res += roman * dreturn resto_roman_numeral(3) # 'III'to_roman_numeral(11) # 'XI'to_roman_numeral(1998) # 'MCMXCVIII'
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
from colorama import init, Fore# Initialize coloramainit()print(Fore.RED + "This text is in red color.")print(Fore.GREEN + "This text is in green color.")print(Fore.BLUE + "This text is in blue color.")# Reset coloramaprint(Fore.RESET + "This text is back to the default color.")