return maximum

0 likes • Nov 19, 2022
Python

More Python Posts

lambda example

CodeCatch
0 likes • Nov 19, 2022
Python
```list_1 = [1,2,3,4,5,6,7,8,9]cubed = map(lambda x: pow(x,3), list_1)print(list(cubed))
#Results#[1, 8, 27, 64, 125, 216, 343, 512, 729]```

CSCE 2100 Question 3

AustinLeath
0 likes • Nov 18, 2022
Python
```# 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 b  return c
def 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 b  return c
print("part A:")tt(parta,3)
print("part B:")tt(partb,3)```

Hello, python

Ntindle
0 likes • Jan 20, 2021
Python
`print(“Hello World”)`

guacamole LDAP creation

AustinLeath
0 likes • Nov 18, 2022
Python
```import osimport sysimport argparseimport jsonimport csvimport getpassimport stringimport randomimport re
from datetime import datetimeimport ldapimport requestsfrom requests.packages.urllib3.exceptions import InsecureRequestWarningrequests.packages.urllib3.disable_warnings(InsecureRequestWarning)from requests.auth import HTTPBasicAuthimport validators

def 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"

if create_connection_result == "200":        print("Successfully created computer: " + computer)    else:         print(create_connection_request.json())
return create_connection_result```

Remove i'th character

CodeCatch
0 likes • Nov 19, 2022
Python
```# 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)```

Size of tuple

CodeCatch
0 likes • Nov 19, 2022
Python
```import sys
# sample TuplesTuple1 = ("A", 1, "B", 2, "C", 3)Tuple2 = ("Geek1", "Raju", "Geek2", "Nikhil", "Geek3", "Deepanshu")Tuple3 = ((1, "Lion"), ( 2, "Tiger"), (3, "Fox"), (4, "Wolf"))
# print the sizes of sample Tuplesprint("Size of Tuple1: " + str(sys.getsizeof(Tuple1)) + "bytes")print("Size of Tuple2: " + str(sys.getsizeof(Tuple2)) + "bytes")print("Size of Tuple3: " + str(sys.getsizeof(Tuple3)) + "bytes")```