Loading...
More Python Posts
#Loop back to this point once code finishesloop = 1while (loop < 10):#All the questions that the program asks the usernoun = input("Choose a noun: ")p_noun = input("Choose a plural noun: ")noun2 = input("Choose a noun: ")place = input("Name a place: ")adjective = input("Choose an adjective (Describing word): ")noun3 = input("Choose a noun: ")#Displays the story based on the users inputprint ("------------------------------------------")print ("Be kind to your",noun,"- footed", p_noun)print ("For a duck may be somebody's", noun2,",")print ("Be kind to your",p_noun,"in",place)print ("Where the weather is always",adjective,".")print ()print ("You may think that is this the",noun3,",")print ("Well it is.")print ("------------------------------------------")#Loop back to "loop = 1"loop = loop + 1
# Listlst = [1, 2, 3, 'Alice', 'Alice']# One-Linerindices = [i for i in range(len(lst)) if lst[i]=='Alice']# Resultprint(indices)# [3, 4]
# question3.pyfrom itertools import productV='∀'E='∃'def tt(f,n) :xss=product((0,1),repeat=n)print('function:',f.__name__)for xs in xss : print(*xs,':',int(f(*xs)))print('')# this is the logic for part A (p\/q\/r) /\ (p\/q\/~r) /\ (p\/~q\/r) /\ (p\/~q\/~r) /\ (~p\/q\/r) /\ (~p\/q\/~r) /\ (~p\/~q\/r) /\ (~p\/~q\/~r)def parta(p,q,r) :a=(p or q or r) and (p or q or not r) and (p or not q or r)and (p or not q or not r)b=(not p or q or r ) and (not p or q or not r) and (not p or not q or r) and (not p or not q or not r)c= a and breturn cdef partb(p,q,r) :a=(p or q and r) and (p or not q or not r) and (p or not q or not r)and (p or q or not r)b=(not p or q or r ) and (not p or q or not r) and (not p or not q or r) and (not p or not q or not r)c= a and breturn cprint("part A:")tt(parta,3)print("part B:")tt(partb,3)
# Python program for Bitonic Sort. Note that this program# works only when size of input is a power of 2.# The parameter dir indicates the sorting direction, ASCENDING# or DESCENDING; if (a[i] > a[j]) agrees with the direction,# then a[i] and a[j] are interchanged.*/def compAndSwap(a, i, j, dire):if (dire==1 and a[i] > a[j]) or (dire==0 and a[i] > a[j]):a[i],a[j] = a[j],a[i]# It recursively sorts a bitonic sequence in ascending order,# if dir = 1, and in descending order otherwise (means dir=0).# The sequence to be sorted starts at index position low,# the parameter cnt is the number of elements to be sorted.def bitonicMerge(a, low, cnt, dire):if cnt > 1:k = cnt/2for i in range(low , low+k):compAndSwap(a, i, i+k, dire)bitonicMerge(a, low, k, dire)bitonicMerge(a, low+k, k, dire)# This funcion first produces a bitonic sequence by recursively# sorting its two halves in opposite sorting orders, and then# calls bitonicMerge to make them in the same orderdef bitonicSort(a, low, cnt,dire):if cnt > 1:k = cnt/2bitonicSort(a, low, k, 1)bitonicSort(a, low+k, k, 0)bitonicMerge(a, low, cnt, dire)# Caller of bitonicSort for sorting the entire array of length N# in ASCENDING orderdef sort(a,N, up):bitonicSort(a,0, N, up)# Driver code to test abovea = [3, 7, 4, 8, 6, 2, 1, 5]n = len(a)up = 1sort(a, n, up)print ("\n\nSorted array is")for i in range(n):print("%d" %a[i]),
print(“Hello World”)
import osimport sysimport argparseimport jsonimport csvimport getpassimport stringimport randomimport refrom datetime import datetimeimport ldapimport requestsfrom requests.packages.urllib3.exceptions import InsecureRequestWarningrequests.packages.urllib3.disable_warnings(InsecureRequestWarning)from requests.auth import HTTPBasicAuthimport validatorsdef create_guac_connection(BASE_URL, auth_token, ldap_group, computer, guac_group_id):'''creates a guac connection'''json_header = {'Accept': 'application/json'}query_parm_payload = { 'token': auth_token }payload_data = {"parentIdentifier":guac_group_id,"name":computer,"protocol":"vnc","parameters":{"port":"5900","read-only":"","swap-red-blue":"","cursor":"","color-depth":"","clipboard-encoding":"","disable-copy":"","disable-paste":"","dest-port":"","recording-exclude-output":"","recording-exclude-mouse":"","recording-include-keys":"","create-recording-path":"","enable-sftp":"true","sftp-port":"","sftp-server-alive-interval":"","enable-audio":"","audio-servername":"","sftp-directory":"","sftp-root-directory":"","sftp-passphrase":"","sftp-private-key":"","sftp-username":"","sftp-password":"","sftp-host-key":"","sftp-hostname":"","recording-name":"","recording-path":"","dest-host":"","password":"asdasd","username":"asdasd","hostname":"nt72310.cvad.unt.edu"},"attributes":{"max-connections":"","max-connections-per-user":"1","weight":"","failover-only":"","guacd-port":"","guacd-encryption":"","guacd-hostname":""}}CREATE_CONNECTION_URL = BASE_URL + "/api/session/data/mysql/connections"create_connection_request = requests.post(CREATE_CONNECTION_URL, headers=json_header, params=query_parm_payload, data=payload_data, verify=False)create_connection_result = create_connection_request.status_codeif create_connection_result == "200":print("Successfully created computer: " + computer)else:print(create_connection_request.json())return create_connection_result