Print pyramid pattern

0 likes • Nov 19, 2022 • 0 views
Python

More Python Posts

Display Calendar

0 likes • May 31, 2023 • 0 views
Python
```import calendar
# Prompt user for year and monthyear = int(input("Enter the year: "))month = int(input("Enter the month: "))
# Create a calendar objectcal = calendar.monthcalendar(year, month)
# Display the calendarprint(calendar.month_name[month], year)print("Mon  Tue  Wed  Thu  Fri  Sat  Sun")
for week in cal:    for day in week:        if day == 0:            print("     ", end="")        else:            print(str(day).rjust(2), "  ", end="")    print()```

0 likes • Nov 19, 2022 • 1 view
Python
```# Python program for implementation of Radix Sort	# A function to do counting sort of arr[] according to# the digit represented by exp.def countingSort(arr, exp1):		n = len(arr)		# The output array elements that will have sorted arr	output = [0] * (n)		# initialize count array as 0	count = [0] * (10)		# Store count of occurrences in count[]	for i in range(0, n):		index = (arr[i]/exp1)		count[int((index)%10)] += 1		# Change count[i] so that count[i] now contains actual	# position of this digit in output array	for i in range(1,10):		count[i] += count[i-1]		# Build the output array	i = n-1	while i>=0:		index = (arr[i]/exp1)		output[ count[ int((index)%10) ] - 1] = arr[i]		count[int((index)%10)] -= 1		i -= 1		# Copying the output array to arr[],	# so that arr now contains sorted numbers	i = 0	for i in range(0,len(arr)):		arr[i] = output[i]
# Find the maximum number to know number of digits	max1 = max(arr)
# Do counting sort for every digit. Note that instead	# of passing digit number, exp is passed. exp is 10^i	# where i is current digit number	exp = 1	while max1/exp > 0:		countingSort(arr,exp)		exp *= 10
# Driver code to test abovearr = [ 170, 45, 75, 90, 802, 24, 2, 66]radixSort(arr)
for i in range(len(arr)):	print(arr[i]),```

0 likes • Nov 19, 2022 • 0 views
Python
```from math import pi

guacamole LDAP creation

0 likes • Nov 18, 2022 • 0 views
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```

Delete all even numbers

0 likes • Nov 19, 2022 • 0 views
Python
`# Deleting all even numbers from a lista = [1,2,3,4,5]del a[1::2]print(a)`

Plotting Fibonacci

0 likes • Nov 19, 2022 • 0 views
Python
`# Python program for Plotting Fibonacci # spiral fractal using Turtle import turtle import math   def fiboPlot(n):     a = 0    b = 1    square_a = a     square_b = b       # Setting the colour of the plotting pen to blue     x.pencolor("blue")       # Drawing the first square     x.forward(b * factor)     x.left(90)     x.forward(b * factor)     x.left(90)     x.forward(b * factor)     x.left(90)     x.forward(b * factor)       # Proceeding in the Fibonacci Series     temp = square_b     square_b = square_b + square_a     square_a = temp           # Drawing the rest of the squares     for i in range(1, n):         x.backward(square_a * factor)         x.right(90)         x.forward(square_b * factor)         x.left(90)         x.forward(square_b * factor)         x.left(90)         x.forward(square_b * factor)           # Proceeding in the Fibonacci Series         temp = square_b         square_b = square_b + square_a         square_a = temp       # Bringing the pen to starting point of the spiral plot     x.penup()     x.setposition(factor, 0)     x.seth(0)     x.pendown()       # Setting the colour of the plotting pen to red     x.pencolor("red")       # Fibonacci Spiral Plot     x.left(90)     for i in range(n):         print(b)         fdwd = math.pi * b * factor / 2        fdwd /= 90        for j in range(90):             x.forward(fdwd)             x.left(1)         temp = a         a = b         b = temp + b     # Here 'factor' signifies the multiplicative  # factor which expands or shrinks the scale # of the plot by a certain factor. factor = 1  # Taking Input for the number of  # Iterations our Algorithm will run n = int(input('Enter the number of iterations (must be > 1): '))   # Plotting the Fibonacci Spiral Fractal  # and printing the corresponding Fibonacci Number if n > 0:     print("Fibonacci series for", n, "elements :")     x = turtle.Turtle()     x.speed(100)     fiboPlot(n)     turtle.done() else:     print("Number of iterations must be > 0")`