content
stringlengths
7
1.05M
n1 = float(input('Redação:')) n2 = float(input('Ciências da Natureza e suas Tecnologias:')) n3 = float(input('Ciências Humanas e suas Tecnologias:')) n4 = float(input('Linguagens, Códigos e suas Tecnologias:')) n5 = float(input('Matemática e suas Tecnologias:')) x = (n1 + n2 + n3 + n4 + n5) / 5 print('Sua média no Enem é: {}'.format(x))
def factorial(n): if n == 0: return 1 return factorial(n-1) * n
def getalpha(schedule, step): alpha = 0.0 for (point, alpha_) in schedule: if step >= point: alpha = alpha_ else: break return alpha step_stage_0 = 0 step_stage_1 = 5e4 step_stage_2 = 7e4 step_stage_3 = 1e5 step_stage_4 = 2.5e5 step_stages = [step_stage_0, step_stage_1, step_stage_2, step_stage_3, step_stage_4] schedule = [[1., 0., 0., 0., 0.], [0., 1., 1., 0., 0.], [0., 0.1, 0.5, 1.0, 0.9]] schedule_new = [] for ls in schedule: ls_new = [] for i, a in enumerate(ls): ls_new.append((step_stages[i], a)) schedule_new.append(ls_new) step_0 = 2e4 step_1 = 6e4 step_2 = 9e4 step_3 = 2e5 step_4 = 3e5 steps_test = [step_0, step_1, step_2, step_3, step_4] for i in steps_test: print("="*10, " ", i, " ", "="*10) result = [] for index in range(3): result.append(getalpha(schedule_new[index], i)) print(result)
def nome_no_formulario(): nome = input() tamanho_de_caracteres = len(nome) if tamanho_de_caracteres > 80: print('NO') else: print('YES') nome_no_formulario()
class Fib: def __init__(self,nn): print("inicjujemy") self.__n=nn self.__i=0 self.__p1=self.__p2=1 def __iter__(self): print('iter') return self def __next__(self): print('next') self.__i+=1 if self.__i>self.__n: raise StopIteration if self.__i in[1,2]: return 1 ret = self.__p1 + self.__p2 self.__p1,self.__p2 = self.__p2,ret return ret for i in Fib(10): print(i)
# (C) Datadog, Inc. 2018 # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) CORE_GAUGES = { 'system.disk.total': 5, 'system.disk.used': 4, 'system.disk.free': 1, 'system.disk.in_use': .80, } CORE_RATES = { 'system.disk.write_time_pct': 9.0, 'system.disk.read_time_pct': 5.0, } UNIX_GAUGES = { 'system.fs.inodes.total': 10, 'system.fs.inodes.used': 1, 'system.fs.inodes.free': 9, 'system.fs.inodes.in_use': .10 } UNIX_GAUGES.update(CORE_GAUGES)
# by Kami Bigdely # Replace magic numbers with named constanst def calculation(charge1, charge2, distance): constant = 8.9875517923*1e9 return constant * charge1 * charge2 / (distance**2) # First Section # Given two point charges, calcualte the electric force exerted on them. q1 = int(input('Enter a value of charge q1: ')) q2 = int(input('Enter a value of charge q2: ')) distance = int(input("Enter the distance be10tween two charges: ")) print("Electric Force between q1 and q2 is: ",calculation(q1, q2, distance), "Newton") # Second Section num = int(input('Enter an integer number: ')) if num % 2 == 0: print(num, "is an even number.") else: print(num, "is an odd number.")
class IDataset(object): def __init__(self): pass def train(self): raise RuntimeError("No implementation found!") def val(self): raise RuntimeError("No implementation found!") def test(self): raise RuntimeError("No implementation found!")
class A: def z(self): return self def y(self, t): return len(t) #Funcion que abriremos desde el archivo main.py def main_puzzle(): a = A y = a.z print(y(a)) #Muestra por pantalla <class '__main__.A'> ya que la funcion z devuelve self aa = a() print(aa is a()) #Imprime False ya que esta condicion no es cierta z = aa.y print(z(())) #Devuelve 0 ya que no hemos introducido valores dentro de len ---> len() print(a().y((a,))) #Devuelve len(a,), es decir, 1 print(A.y(aa, (a,z))) #Devuelve len(a,z), que es igual a 2 ya que (a,z) tiene 2 elementos print(aa.y((z,1,'z'))) #Devuelve len(z,1,'z'), que es 3 ya que tiene 3 elementos
#define MAX(x,y) (((x) > (y)) ? (x) : (y)) #define MIN(x,y) (((x) < (y)) ? (x) : (y)) class solution: def maxProfit(prices:list[int])->int: pricesSize = len(prices) dp_sell_out = [] dp_sell_with = [] dp_buy = [] #current action is not selling, next step could be buying dp_sell_out.append(0) # current action is selling, next step must be cooldown dp_sell_with.append(0) # make sure last action is buying dp_buy.append(-prices[0]) for i in range(1,pricesSize): dp_sell_out.append(max(dp_sell_out[i-1],dp_sell_with[i-1])) dp_sell_with.append(dp_buy[i-1]+prices[i]) dp_buy.append(max(dp_buy[i-1],dp_sell_out[i-1]-prices[i])) return max(dp_sell_out[pricesSize-1],dp_sell_with[pricesSize-1])
# Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def partition(self, head: ListNode, x: int) -> ListNode: curr_node = head curr_new = new_head = ListNode(0) prev = None while curr_node: if curr_node.val >= x: if prev: prev.next = curr_node.next curr_new.next = curr_node curr_node = curr_node.next curr_new = curr_new.next curr_new.next = None else: curr_new.next = temp = curr_node head = curr_node = curr_node.next temp.next = None curr_new = curr_new.next elif curr_node.val < x: prev = curr_node curr_node = curr_node.next if prev: prev.next = new_head.next else: return new_head.next return head
# This program subtracts one number from another # Author: Isabella Doyle first = int(input("Enter the first number:")) # requests input of integer from user second = int(input("Enter the second number:")) # requests input of integer from user # prints sum below print(first - second)
#b. Un alumno desea saber cuál será su calificación final en la materia de Lógica Computacional. # Dicha calificación se compone de tres exámenes parciales cuya ponderación es de 30%, 30% y 40%. print("¡Calculo de calificacion Final de un alumno!") examen01=float(input("Ingrese nota de examen N° 1 = ")) examen02=float(input("Ingrese nota de examen N° 2 = ")) examen03=float(input("Ingrese nota de examen N° 3 = ")) Peso01=examen01 * 0.3 Peso02=examen02 * 0.3 Peso03=examen03 * 0.4 calificacion=Peso01+Peso02+Peso03 print("Tu Nota de Calificacion es = ", calificacion)
def test_get_uptimez(client): response = client.get("/uptimez/") assert response.status_code == 200 def test_get_healthz(client): response = client.get("/healthz/") assert response.status_code == 200
print("Hello world") print("Adios") def suma(a,b): return a+b print(suma(2,3)) print("Esto es una feature")
t = int(input()) for _ in range(t) : n, k = map(int, input().split()) arr = list(map(int, input().split())) arr.sort() if(k > arr[0]) : print(abs(k-arr[0])) else : print(0)
''' Você deve fazer um programa que apresente a sequencia conforme o exemplo abaixo. Entrada Não há nenhuma entrada neste problema. Saída Imprima a sequencia conforme exemplo abaixo. ''' I = [1,1,1,3,3,3,5,5,5,7,7,7,9,9,9] J = [7,6,5,9,8,7,11,10,9,13,12,11,15,14,13] for i,j in zip(I,J): print('I={} J={}'.format(i,j))
# -*- coding: utf-8 -*- """ stocks_correlation.providers.quandl This module define the normalized columns of the DataFrame the providers return """ DATAFRAME_COLUMNS = ['date', 'open', 'high', 'low', 'close'] CORREL_COMPUTE_COLUMNS = DATAFRAME_COLUMNS[1:] def filter_dates(df, start_date, end_date): """Filters the DataFrame so that all ticks are between start_date and end_date""" return df[(df['date'] >= start_date) & (df['date'] <= end_date)]
a = int(input("Enter the First Number: "))# Inputing the first number b = int(input("Enter the seconf Number: "))#inputing the second number if(a>=b):#cheking if the first print(a, "is greater") else: print(b, "is greater")
__name__ = "pairwisedist" __author__ = """Guy Teichman""" __email__ = "guyteichman@gmail.com" __version__ = "1.1.0" __license__ = "Apache"
""" Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well. For example, the input [3, 4, -1, 1] should give 2. The input [1, 2, 0] should give 3. """ def solution(integers): """Sorting the sequence in place and search the minimal positive integer required.""" integers.sort() min = integers[0] for integer in integers: if min > 0 and integer > min + 1: return min + 1 else: min = integer return min + 1
#! python3 # __author__ = "YangJiaHao" # date: 2018/3/2 class Solution: def searchMatrix(self, matrix, target): """ :type matrix: List[List[int]] :type target: int :rtype: bool 时间复杂度 O(m + n) """ if not matrix: return False row = 0 col = len(matrix[0]) - 1 while row < len(matrix) and col >= 0: if matrix[row][col] == target: return True elif matrix[row][col] < target: row += 1 else: col -= 1 return False if __name__ == '__main__': so = Solution() res = so.searchMatrix([[-10,-8,-6,-4,-3],[0,2,3,4,5],[8,9,10,10,12]], 0) print(res)
MAJOR = 1 MINOR = 11 RELEASE = 10 VERSION = '%d.%d.%d' % (MAJOR, MINOR, RELEASE) def num(versionstring=VERSION): """Convert the version string of the form 'X.Y.Z' to an integer 100000*X + 100*Y + Z for version comparison""" (major, minor, release) = versionstring.split('.') return 100*100*int(major) + 100*int(minor) + int(release) def split(versionstring): """Split the version string 'X.Y.Z' and return tuple (int(X), int(Y), int(Z))""" assert versionstring.count('.') == 2, "Version string must be of the form str('X.Y.Z')" return tuple([int(x) for x in versionstring.split('.')]) def major(versionstring=VERSION): """Return the major version number int(X) for versionstring 'X.Y.Z'""" return split(versionstring)[0] def minor(versionstring=VERSION): """Return the minor version number int(Y) for versionstring 'X.Y.Z'""" return split(versionstring)[1] def release(versionstring=VERSION): """Return the release version number int(Z) for versionstring 'X.Y.Z'""" return split(versionstring)[2] def at_least_version(versionstring): """Is versionstring='X.Y.Z' at least the current version?""" return num(VERSION) >= num(versionstring) def is_at_least(versionstring): """Synonym for at_least_version""" return num(VERSION) >= num(versionstring) def is_exactly(versionstring): """Is the versionstring = 'X,Y.Z' exactly equal to vipy.__version__""" return versionstring == VERSION def at_least_major_version(major): """is the major version (e.g. X, for version X.Y.Z) greater than or equal to the major version integer supplied?""" return MAJOR >= int(major)
""" Standardize Mobile Number Using Decorators https://www.hackerrank.com/challenges/standardize-mobile-number-using-decorators/problem """ def wrapper(f): def fun(l): # complete the function for i, n in enumerate(l): if len(n) == 10: n= "+91" + n elif len(n) == 11 and n.startswith("0"): n = "+91" + n[1:] elif len(n) == 12 and n.startswith("91"): n = "+" + n elif len(n) == 13 and n.startswith("+91"): pass else: continue n = n[0:3] + " " + n[3:8] + " " + n[8:] l[i] = n return f(l) return fun @wrapper def sort_phone(l): print(*sorted(l), sep='\n') if __name__ == '__main__': l = [input() for _ in range(int(input()))] sort_phone(l)
# -*- coding: utf-8 -*- # Author : Jin Kim # e-mail : jinkim@seculayer.com # Powered by Seculayer © 2021 Service Model Team, R&D Center. class StringUtil(object): @staticmethod def get_int(data) -> int: try: return int(data) except ValueError: return -1 @staticmethod def get_boolean(data) -> bool: val = str(data).lower() if val == "y" or val == "true": return True else: return False
file = open('list_de_note.csv', mode = "r", encoding = "utf-8-sig") file_new = open('list_de_note_new.csv', mode = "w", encoding = "utf-8-sig") header = file.readline() ##lire la premiere ligne #file_new.write(header) file_new.write(header.strip() + ", Điểm trung bình,Học lực\n") row = file.readline() ##lire la deuxieme ligne while row != "" : row_list = row.split(",") math = float(row_list[2]) litt = float(row_list[3]) ave = (math + litt)/2 ave = round(ave,1) rank = "" if ave >= 8 : rank = "Giỏi" elif ave < 8 and ave >= 6.5 : rank = "Tiên tiến" else : rank = "Trung bình" row_new = row.strip() + "," + str(ave) + "," + rank + "\n" print(row_new) file_new.write(row_new) row = file.readline()
#returns the set of reachable vertices assuming G is represented via adjacency lists. # Assumes that the graph is a dictionary and each adjacency list is a set. def reachable(G,v): rset = set() def dfs(w): rset.add(w) for ngh in G[w]: if not (ngh in rset): dfs(ngh) return dfs(v) return(rset) G = {} G[0] = {1,2,3} G[1] = {0,3} G[2] = {} G[3] = {1,4,2} G[4] = {5,6} G[5] = {4} G[7] = {5,6} G[6] = {5,7} print(reachable(G,0)) print(reachable(G,1)) print(reachable(G,2)) print(reachable(G,3)) print(reachable(G,4)) print(reachable(G,5)) print(reachable(G,6)) print(reachable(G,7))
class Script(object): START_MSG = """<b>Hy {}, I'm an advanced filter bot with many capabilities! There is no practical limits for my filtering capacity :) See <i>/help</i> for commands and more details.</b> """ HELP_MSG = """ <b><i>Add me as admin in your group and start filtering :)</i></b> <b>Filter Commands;</b> <b>/add name reply</b> - Add filter for name <b>/del name</b> - Delete filter <b>/delall</b> - Delete entire filters (Group Owner Only!) <b>/viewfilters</b> - List all filters in chat <b>Connection Commands;</b> <b>/connect groupid</b> - Connect your Group to my PM. You can also simply use, <b>/connect</b> in Groups. <b>/connections</b> - Manage your connections. <b>Extras;</b> /status - Shows current status of your bot (Auth User Only) /id - Shows ID information <b>© @Urs_BOND</b> """ ABOUT_MSG = """⭕️<b>My Name : HD Filter Bot</b> ⭕️<b>🧑🏻‍💻Creater : @Urs_Bond</b> ⭕️<b>Language :</b> <code>Python3</code> ⭕️<b>Library :</b> <a href='https://docs.pyrogram.org/'>Pyrogram 1.0.7</a> """
# # PySNMP MIB module ADSL-LINE-EXT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ADSL-LINE-EXT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 16:58:27 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # adslAtucPerfDataEntry, adslAturIntervalEntry, adslAtucIntervalEntry, adslLineAlarmConfProfileEntry, adslLineEntry, adslLineConfProfileEntry, adslAturPerfDataEntry, adslMIB = mibBuilder.importSymbols("ADSL-LINE-MIB", "adslAtucPerfDataEntry", "adslAturIntervalEntry", "adslAtucIntervalEntry", "adslLineAlarmConfProfileEntry", "adslLineEntry", "adslLineConfProfileEntry", "adslAturPerfDataEntry", "adslMIB") AdslPerfPrevDayCount, AdslPerfCurrDayCount = mibBuilder.importSymbols("ADSL-TC-MIB", "AdslPerfPrevDayCount", "AdslPerfCurrDayCount") OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ValueSizeConstraint, ValueRangeConstraint, ConstraintsUnion, ConstraintsIntersection, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueSizeConstraint", "ValueRangeConstraint", "ConstraintsUnion", "ConstraintsIntersection", "SingleValueConstraint") PerfCurrentCount, PerfIntervalCount = mibBuilder.importSymbols("PerfHist-TC-MIB", "PerfCurrentCount", "PerfIntervalCount") SnmpAdminString, = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString") NotificationGroup, ObjectGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ObjectGroup", "ModuleCompliance") Gauge32, Integer32, IpAddress, Bits, Counter32, ObjectIdentity, NotificationType, MibScalar, MibTable, MibTableRow, MibTableColumn, Unsigned32, TimeTicks, ModuleIdentity, MibIdentifier, Counter64, iso = mibBuilder.importSymbols("SNMPv2-SMI", "Gauge32", "Integer32", "IpAddress", "Bits", "Counter32", "ObjectIdentity", "NotificationType", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Unsigned32", "TimeTicks", "ModuleIdentity", "MibIdentifier", "Counter64", "iso") DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention") adslExtMIB = ModuleIdentity((1, 3, 6, 1, 2, 1, 10, 94, 3)) adslExtMIB.setRevisions(('2002-12-10 00:00',)) if mibBuilder.loadTexts: adslExtMIB.setLastUpdated('200212100000Z') if mibBuilder.loadTexts: adslExtMIB.setOrganization('IETF ADSL MIB Working Group') adslExtMibObjects = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 94, 3, 1)) class AdslTransmissionModeType(TextualConvention, Bits): status = 'current' namedValues = NamedValues(("ansit1413", 0), ("etsi", 1), ("q9921PotsNonOverlapped", 2), ("q9921PotsOverlapped", 3), ("q9921IsdnNonOverlapped", 4), ("q9921isdnOverlapped", 5), ("q9921tcmIsdnNonOverlapped", 6), ("q9921tcmIsdnOverlapped", 7), ("q9922potsNonOverlapeed", 8), ("q9922potsOverlapped", 9), ("q9922tcmIsdnNonOverlapped", 10), ("q9922tcmIsdnOverlapped", 11), ("q9921tcmIsdnSymmetric", 12)) adslLineExtTable = MibTable((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 17), ) if mibBuilder.loadTexts: adslLineExtTable.setStatus('current') adslLineExtEntry = MibTableRow((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 17, 1), ) adslLineEntry.registerAugmentions(("ADSL-LINE-EXT-MIB", "adslLineExtEntry")) adslLineExtEntry.setIndexNames(*adslLineEntry.getIndexNames()) if mibBuilder.loadTexts: adslLineExtEntry.setStatus('current') adslLineTransAtucCap = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 17, 1, 1), AdslTransmissionModeType()).setMaxAccess("readonly") if mibBuilder.loadTexts: adslLineTransAtucCap.setStatus('current') adslLineTransAtucConfig = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 17, 1, 2), AdslTransmissionModeType()).setMaxAccess("readwrite") if mibBuilder.loadTexts: adslLineTransAtucConfig.setStatus('current') adslLineTransAtucActual = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 17, 1, 3), AdslTransmissionModeType()).setMaxAccess("readonly") if mibBuilder.loadTexts: adslLineTransAtucActual.setStatus('current') adslLineGlitePowerState = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 17, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("none", 1), ("l0", 2), ("l1", 3), ("l3", 4)))).setMaxAccess("readonly") if mibBuilder.loadTexts: adslLineGlitePowerState.setStatus('current') adslLineConfProfileDualLite = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 17, 1, 5), SnmpAdminString()).setMaxAccess("readwrite") if mibBuilder.loadTexts: adslLineConfProfileDualLite.setStatus('current') adslAtucPerfDataExtTable = MibTable((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18), ) if mibBuilder.loadTexts: adslAtucPerfDataExtTable.setStatus('current') adslAtucPerfDataExtEntry = MibTableRow((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1), ) adslAtucPerfDataEntry.registerAugmentions(("ADSL-LINE-EXT-MIB", "adslAtucPerfDataExtEntry")) adslAtucPerfDataExtEntry.setIndexNames(*adslAtucPerfDataEntry.getIndexNames()) if mibBuilder.loadTexts: adslAtucPerfDataExtEntry.setStatus('current') adslAtucPerfStatFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 1), Counter32()).setUnits('line retrains').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAtucPerfStatFastR.setStatus('current') adslAtucPerfStatFailedFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 2), Counter32()).setUnits('line retrains').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAtucPerfStatFailedFastR.setStatus('current') adslAtucPerfStatSesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 3), Counter32()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAtucPerfStatSesL.setStatus('current') adslAtucPerfStatUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 4), Counter32()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAtucPerfStatUasL.setStatus('current') adslAtucPerfCurr15MinFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 5), PerfCurrentCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAtucPerfCurr15MinFastR.setStatus('current') adslAtucPerfCurr15MinFailedFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 6), PerfCurrentCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAtucPerfCurr15MinFailedFastR.setStatus('current') adslAtucPerfCurr15MinSesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 7), PerfCurrentCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAtucPerfCurr15MinSesL.setStatus('current') adslAtucPerfCurr15MinUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 8), PerfCurrentCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAtucPerfCurr15MinUasL.setStatus('current') adslAtucPerfCurr1DayFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 9), AdslPerfCurrDayCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAtucPerfCurr1DayFastR.setStatus('current') adslAtucPerfCurr1DayFailedFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 10), AdslPerfCurrDayCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAtucPerfCurr1DayFailedFastR.setStatus('current') adslAtucPerfCurr1DaySesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 11), AdslPerfCurrDayCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAtucPerfCurr1DaySesL.setStatus('current') adslAtucPerfCurr1DayUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 12), AdslPerfCurrDayCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAtucPerfCurr1DayUasL.setStatus('current') adslAtucPerfPrev1DayFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 13), AdslPerfPrevDayCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAtucPerfPrev1DayFastR.setStatus('current') adslAtucPerfPrev1DayFailedFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 14), AdslPerfPrevDayCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAtucPerfPrev1DayFailedFastR.setStatus('current') adslAtucPerfPrev1DaySesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 15), AdslPerfPrevDayCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAtucPerfPrev1DaySesL.setStatus('current') adslAtucPerfPrev1DayUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 18, 1, 16), AdslPerfPrevDayCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAtucPerfPrev1DayUasL.setStatus('current') adslAtucIntervalExtTable = MibTable((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 19), ) if mibBuilder.loadTexts: adslAtucIntervalExtTable.setStatus('current') adslAtucIntervalExtEntry = MibTableRow((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 19, 1), ) adslAtucIntervalEntry.registerAugmentions(("ADSL-LINE-EXT-MIB", "adslAtucIntervalExtEntry")) adslAtucIntervalExtEntry.setIndexNames(*adslAtucIntervalEntry.getIndexNames()) if mibBuilder.loadTexts: adslAtucIntervalExtEntry.setStatus('current') adslAtucIntervalFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 19, 1, 1), PerfIntervalCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAtucIntervalFastR.setStatus('current') adslAtucIntervalFailedFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 19, 1, 2), PerfIntervalCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAtucIntervalFailedFastR.setStatus('current') adslAtucIntervalSesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 19, 1, 3), PerfIntervalCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAtucIntervalSesL.setStatus('current') adslAtucIntervalUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 19, 1, 4), PerfIntervalCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAtucIntervalUasL.setStatus('current') adslAturPerfDataExtTable = MibTable((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 20), ) if mibBuilder.loadTexts: adslAturPerfDataExtTable.setStatus('current') adslAturPerfDataExtEntry = MibTableRow((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 20, 1), ) adslAturPerfDataEntry.registerAugmentions(("ADSL-LINE-EXT-MIB", "adslAturPerfDataExtEntry")) adslAturPerfDataExtEntry.setIndexNames(*adslAturPerfDataEntry.getIndexNames()) if mibBuilder.loadTexts: adslAturPerfDataExtEntry.setStatus('current') adslAturPerfStatSesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 20, 1, 1), Counter32()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAturPerfStatSesL.setStatus('current') adslAturPerfStatUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 20, 1, 2), Counter32()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAturPerfStatUasL.setStatus('current') adslAturPerfCurr15MinSesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 20, 1, 3), PerfCurrentCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAturPerfCurr15MinSesL.setStatus('current') adslAturPerfCurr15MinUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 20, 1, 4), PerfCurrentCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAturPerfCurr15MinUasL.setStatus('current') adslAturPerfCurr1DaySesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 20, 1, 5), AdslPerfCurrDayCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAturPerfCurr1DaySesL.setStatus('current') adslAturPerfCurr1DayUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 20, 1, 6), AdslPerfCurrDayCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAturPerfCurr1DayUasL.setStatus('current') adslAturPerfPrev1DaySesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 20, 1, 7), AdslPerfPrevDayCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAturPerfPrev1DaySesL.setStatus('current') adslAturPerfPrev1DayUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 20, 1, 8), AdslPerfPrevDayCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAturPerfPrev1DayUasL.setStatus('current') adslAturIntervalExtTable = MibTable((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 21), ) if mibBuilder.loadTexts: adslAturIntervalExtTable.setStatus('current') adslAturIntervalExtEntry = MibTableRow((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 21, 1), ) adslAturIntervalEntry.registerAugmentions(("ADSL-LINE-EXT-MIB", "adslAturIntervalExtEntry")) adslAturIntervalExtEntry.setIndexNames(*adslAturIntervalEntry.getIndexNames()) if mibBuilder.loadTexts: adslAturIntervalExtEntry.setStatus('current') adslAturIntervalSesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 21, 1, 1), PerfIntervalCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAturIntervalSesL.setStatus('current') adslAturIntervalUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 21, 1, 2), PerfIntervalCount()).setUnits('seconds').setMaxAccess("readonly") if mibBuilder.loadTexts: adslAturIntervalUasL.setStatus('current') adslConfProfileExtTable = MibTable((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 22), ) if mibBuilder.loadTexts: adslConfProfileExtTable.setStatus('current') adslConfProfileExtEntry = MibTableRow((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 22, 1), ) adslLineConfProfileEntry.registerAugmentions(("ADSL-LINE-EXT-MIB", "adslConfProfileExtEntry")) adslConfProfileExtEntry.setIndexNames(*adslLineConfProfileEntry.getIndexNames()) if mibBuilder.loadTexts: adslConfProfileExtEntry.setStatus('current') adslConfProfileLineType = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 22, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("noChannel", 1), ("fastOnly", 2), ("interleavedOnly", 3), ("fastOrInterleaved", 4), ("fastAndInterleaved", 5))).clone('fastOnly')).setMaxAccess("readcreate") if mibBuilder.loadTexts: adslConfProfileLineType.setStatus('current') adslAlarmConfProfileExtTable = MibTable((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 23), ) if mibBuilder.loadTexts: adslAlarmConfProfileExtTable.setStatus('current') adslAlarmConfProfileExtEntry = MibTableRow((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 23, 1), ) adslLineAlarmConfProfileEntry.registerAugmentions(("ADSL-LINE-EXT-MIB", "adslAlarmConfProfileExtEntry")) adslAlarmConfProfileExtEntry.setIndexNames(*adslLineAlarmConfProfileEntry.getIndexNames()) if mibBuilder.loadTexts: adslAlarmConfProfileExtEntry.setStatus('current') adslAtucThreshold15MinFailedFastR = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 23, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 900))).setUnits('seconds').setMaxAccess("readcreate") if mibBuilder.loadTexts: adslAtucThreshold15MinFailedFastR.setStatus('current') adslAtucThreshold15MinSesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 23, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 900))).setUnits('seconds').setMaxAccess("readcreate") if mibBuilder.loadTexts: adslAtucThreshold15MinSesL.setStatus('current') adslAtucThreshold15MinUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 23, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 900))).setUnits('seconds').setMaxAccess("readcreate") if mibBuilder.loadTexts: adslAtucThreshold15MinUasL.setStatus('current') adslAturThreshold15MinSesL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 23, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 900))).setUnits('seconds').setMaxAccess("readcreate") if mibBuilder.loadTexts: adslAturThreshold15MinSesL.setStatus('current') adslAturThreshold15MinUasL = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 23, 1, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 900))).setUnits('seconds').setMaxAccess("readcreate") if mibBuilder.loadTexts: adslAturThreshold15MinUasL.setStatus('current') adslExtTraps = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 24)) adslExtAtucTraps = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 24, 1)) adslExtAtucTrapsPrefix = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 24, 1, 0)) adslAtucFailedFastRThreshTrap = NotificationType((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 24, 1, 0, 1)).setObjects(("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr15MinFailedFastR")) if mibBuilder.loadTexts: adslAtucFailedFastRThreshTrap.setStatus('current') adslAtucSesLThreshTrap = NotificationType((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 24, 1, 0, 2)).setObjects(("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr15MinSesL")) if mibBuilder.loadTexts: adslAtucSesLThreshTrap.setStatus('current') adslAtucUasLThreshTrap = NotificationType((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 24, 1, 0, 3)).setObjects(("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr15MinUasL")) if mibBuilder.loadTexts: adslAtucUasLThreshTrap.setStatus('current') adslExtAturTraps = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 24, 2)) adslExtAturTrapsPrefix = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 24, 2, 0)) adslAturSesLThreshTrap = NotificationType((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 24, 2, 0, 1)).setObjects(("ADSL-LINE-EXT-MIB", "adslAturPerfCurr15MinSesL")) if mibBuilder.loadTexts: adslAturSesLThreshTrap.setStatus('current') adslAturUasLThreshTrap = NotificationType((1, 3, 6, 1, 2, 1, 10, 94, 3, 1, 24, 2, 0, 2)).setObjects(("ADSL-LINE-EXT-MIB", "adslAturPerfCurr15MinUasL")) if mibBuilder.loadTexts: adslAturUasLThreshTrap.setStatus('current') adslExtConformance = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 94, 3, 2)) adslExtGroups = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 94, 3, 2, 1)) adslExtCompliances = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 94, 3, 2, 2)) adslExtLineMibAtucCompliance = ModuleCompliance((1, 3, 6, 1, 2, 1, 10, 94, 3, 2, 2, 1)).setObjects(("ADSL-LINE-EXT-MIB", "adslExtLineGroup"), ("ADSL-LINE-EXT-MIB", "adslExtLineConfProfileControlGroup"), ("ADSL-LINE-EXT-MIB", "adslExtLineAlarmConfProfileGroup"), ("ADSL-LINE-EXT-MIB", "adslExtAtucPhysPerfCounterGroup"), ("ADSL-LINE-EXT-MIB", "adslExtAturPhysPerfCounterGroup"), ("ADSL-LINE-EXT-MIB", "adslExtNotificationsGroup")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): adslExtLineMibAtucCompliance = adslExtLineMibAtucCompliance.setStatus('current') adslExtLineGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 10, 94, 3, 2, 1, 1)).setObjects(("ADSL-LINE-EXT-MIB", "adslLineConfProfileDualLite"), ("ADSL-LINE-EXT-MIB", "adslLineTransAtucCap"), ("ADSL-LINE-EXT-MIB", "adslLineTransAtucConfig"), ("ADSL-LINE-EXT-MIB", "adslLineTransAtucActual"), ("ADSL-LINE-EXT-MIB", "adslLineGlitePowerState")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): adslExtLineGroup = adslExtLineGroup.setStatus('current') adslExtAtucPhysPerfCounterGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 10, 94, 3, 2, 1, 2)).setObjects(("ADSL-LINE-EXT-MIB", "adslAtucPerfStatFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfStatFailedFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr15MinFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr15MinFailedFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr1DayFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr1DayFailedFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfPrev1DayFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfPrev1DayFailedFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfStatSesL"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfStatUasL"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr15MinSesL"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr15MinUasL"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr1DaySesL"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfCurr1DayUasL"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfPrev1DaySesL"), ("ADSL-LINE-EXT-MIB", "adslAtucPerfPrev1DayUasL"), ("ADSL-LINE-EXT-MIB", "adslAtucIntervalFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucIntervalFailedFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucIntervalSesL"), ("ADSL-LINE-EXT-MIB", "adslAtucIntervalUasL")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): adslExtAtucPhysPerfCounterGroup = adslExtAtucPhysPerfCounterGroup.setStatus('current') adslExtAturPhysPerfCounterGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 10, 94, 3, 2, 1, 3)).setObjects(("ADSL-LINE-EXT-MIB", "adslAturPerfStatSesL"), ("ADSL-LINE-EXT-MIB", "adslAturPerfStatUasL"), ("ADSL-LINE-EXT-MIB", "adslAturPerfCurr15MinSesL"), ("ADSL-LINE-EXT-MIB", "adslAturPerfCurr15MinUasL"), ("ADSL-LINE-EXT-MIB", "adslAturPerfCurr1DaySesL"), ("ADSL-LINE-EXT-MIB", "adslAturPerfCurr1DayUasL"), ("ADSL-LINE-EXT-MIB", "adslAturPerfPrev1DaySesL"), ("ADSL-LINE-EXT-MIB", "adslAturPerfPrev1DayUasL"), ("ADSL-LINE-EXT-MIB", "adslAturIntervalSesL"), ("ADSL-LINE-EXT-MIB", "adslAturIntervalUasL")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): adslExtAturPhysPerfCounterGroup = adslExtAturPhysPerfCounterGroup.setStatus('current') adslExtLineConfProfileControlGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 10, 94, 3, 2, 1, 4)).setObjects(("ADSL-LINE-EXT-MIB", "adslConfProfileLineType")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): adslExtLineConfProfileControlGroup = adslExtLineConfProfileControlGroup.setStatus('current') adslExtLineAlarmConfProfileGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 10, 94, 3, 2, 1, 5)).setObjects(("ADSL-LINE-EXT-MIB", "adslAtucThreshold15MinFailedFastR"), ("ADSL-LINE-EXT-MIB", "adslAtucThreshold15MinSesL"), ("ADSL-LINE-EXT-MIB", "adslAtucThreshold15MinUasL"), ("ADSL-LINE-EXT-MIB", "adslAturThreshold15MinSesL"), ("ADSL-LINE-EXT-MIB", "adslAturThreshold15MinUasL")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): adslExtLineAlarmConfProfileGroup = adslExtLineAlarmConfProfileGroup.setStatus('current') adslExtNotificationsGroup = NotificationGroup((1, 3, 6, 1, 2, 1, 10, 94, 3, 2, 1, 6)).setObjects(("ADSL-LINE-EXT-MIB", "adslAtucFailedFastRThreshTrap"), ("ADSL-LINE-EXT-MIB", "adslAtucSesLThreshTrap"), ("ADSL-LINE-EXT-MIB", "adslAtucUasLThreshTrap"), ("ADSL-LINE-EXT-MIB", "adslAturSesLThreshTrap"), ("ADSL-LINE-EXT-MIB", "adslAturUasLThreshTrap")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): adslExtNotificationsGroup = adslExtNotificationsGroup.setStatus('current') mibBuilder.exportSymbols("ADSL-LINE-EXT-MIB", adslAtucPerfPrev1DayFastR=adslAtucPerfPrev1DayFastR, adslAturPerfDataExtEntry=adslAturPerfDataExtEntry, adslConfProfileExtTable=adslConfProfileExtTable, adslExtAturTrapsPrefix=adslExtAturTrapsPrefix, adslAturPerfDataExtTable=adslAturPerfDataExtTable, adslAlarmConfProfileExtTable=adslAlarmConfProfileExtTable, adslExtAtucTraps=adslExtAtucTraps, adslAturIntervalUasL=adslAturIntervalUasL, adslExtAturTraps=adslExtAturTraps, adslAtucPerfCurr15MinFastR=adslAtucPerfCurr15MinFastR, adslAtucIntervalFastR=adslAtucIntervalFastR, adslAturPerfStatUasL=adslAturPerfStatUasL, adslAturPerfPrev1DaySesL=adslAturPerfPrev1DaySesL, adslExtLineConfProfileControlGroup=adslExtLineConfProfileControlGroup, adslAturIntervalSesL=adslAturIntervalSesL, adslAtucPerfCurr15MinFailedFastR=adslAtucPerfCurr15MinFailedFastR, adslAturUasLThreshTrap=adslAturUasLThreshTrap, adslAtucIntervalExtTable=adslAtucIntervalExtTable, adslAtucSesLThreshTrap=adslAtucSesLThreshTrap, adslExtAturPhysPerfCounterGroup=adslExtAturPhysPerfCounterGroup, PYSNMP_MODULE_ID=adslExtMIB, AdslTransmissionModeType=AdslTransmissionModeType, adslExtGroups=adslExtGroups, adslAtucPerfCurr1DayFastR=adslAtucPerfCurr1DayFastR, adslAtucIntervalFailedFastR=adslAtucIntervalFailedFastR, adslAtucPerfDataExtEntry=adslAtucPerfDataExtEntry, adslAtucIntervalSesL=adslAtucIntervalSesL, adslAtucThreshold15MinFailedFastR=adslAtucThreshold15MinFailedFastR, adslAtucPerfCurr15MinUasL=adslAtucPerfCurr15MinUasL, adslLineTransAtucConfig=adslLineTransAtucConfig, adslAtucPerfCurr1DaySesL=adslAtucPerfCurr1DaySesL, adslAturIntervalExtEntry=adslAturIntervalExtEntry, adslAturPerfCurr1DayUasL=adslAturPerfCurr1DayUasL, adslAtucPerfStatFastR=adslAtucPerfStatFastR, adslAtucPerfPrev1DayUasL=adslAtucPerfPrev1DayUasL, adslAtucUasLThreshTrap=adslAtucUasLThreshTrap, adslConfProfileExtEntry=adslConfProfileExtEntry, adslAtucPerfCurr15MinSesL=adslAtucPerfCurr15MinSesL, adslAturPerfStatSesL=adslAturPerfStatSesL, adslExtMIB=adslExtMIB, adslAlarmConfProfileExtEntry=adslAlarmConfProfileExtEntry, adslAturPerfCurr15MinSesL=adslAturPerfCurr15MinSesL, adslLineGlitePowerState=adslLineGlitePowerState, adslAtucPerfPrev1DaySesL=adslAtucPerfPrev1DaySesL, adslAtucIntervalExtEntry=adslAtucIntervalExtEntry, adslAtucPerfDataExtTable=adslAtucPerfDataExtTable, adslAtucPerfCurr1DayUasL=adslAtucPerfCurr1DayUasL, adslAturThreshold15MinUasL=adslAturThreshold15MinUasL, adslAturPerfCurr1DaySesL=adslAturPerfCurr1DaySesL, adslExtAtucPhysPerfCounterGroup=adslExtAtucPhysPerfCounterGroup, adslAturThreshold15MinSesL=adslAturThreshold15MinSesL, adslExtConformance=adslExtConformance, adslExtAtucTrapsPrefix=adslExtAtucTrapsPrefix, adslAtucIntervalUasL=adslAtucIntervalUasL, adslAtucFailedFastRThreshTrap=adslAtucFailedFastRThreshTrap, adslAtucThreshold15MinUasL=adslAtucThreshold15MinUasL, adslAtucPerfPrev1DayFailedFastR=adslAtucPerfPrev1DayFailedFastR, adslExtTraps=adslExtTraps, adslConfProfileLineType=adslConfProfileLineType, adslExtMibObjects=adslExtMibObjects, adslAtucThreshold15MinSesL=adslAtucThreshold15MinSesL, adslLineConfProfileDualLite=adslLineConfProfileDualLite, adslExtCompliances=adslExtCompliances, adslExtLineAlarmConfProfileGroup=adslExtLineAlarmConfProfileGroup, adslLineTransAtucActual=adslLineTransAtucActual, adslLineExtEntry=adslLineExtEntry, adslExtNotificationsGroup=adslExtNotificationsGroup, adslAtucPerfStatUasL=adslAtucPerfStatUasL, adslAtucPerfCurr1DayFailedFastR=adslAtucPerfCurr1DayFailedFastR, adslAturPerfPrev1DayUasL=adslAturPerfPrev1DayUasL, adslLineTransAtucCap=adslLineTransAtucCap, adslAtucPerfStatFailedFastR=adslAtucPerfStatFailedFastR, adslAturIntervalExtTable=adslAturIntervalExtTable, adslAturSesLThreshTrap=adslAturSesLThreshTrap, adslAturPerfCurr15MinUasL=adslAturPerfCurr15MinUasL, adslExtLineGroup=adslExtLineGroup, adslLineExtTable=adslLineExtTable, adslAtucPerfStatSesL=adslAtucPerfStatSesL, adslExtLineMibAtucCompliance=adslExtLineMibAtucCompliance)
def fahrenheit_to_celsius(F): C = 0 # Your code goes here: calculate the temperature in Celsius, # store in a variable (we called it C), and return it. return C
''' https://www.hackerrank.com/challenges/30-class-vs-instance/problem Crear una clase persona con una variable de instancia de age. El constructor debe asignar initialAge a la age despues de corfimar el argumento pasado como initailAge no es negativo, Sies negativo initialAge el constructor deberá mostrar age=0 e imprimir "Age is not valid, setting age to 0." Escribir los método de instancia: 1. yearPasses() Incrementa la edad de la instancia en 1. 2. amIOLD() hace los siguientes condicionales. * if age<13 imprimir --- "You are young" * if age>=13 and age <18 "You are teenager" else: "You are old" ''' class Person(): def __init__(self, initialAge): if initialAge < 0: print ("Age is not valid, setting age to 0.") self.initialAge = 0 else: self.initialAge = int(initialAge) def yearPasses(self): self.initialAge +=1 def amIOLD(self): if self.initialAge <13: print("You are young") elif self.initialAge >=13 and self.initialAge <18: print("You are a teenager") else: print("You are old") persona = Person(10) print(persona.initialAge) print(persona.amIOLD()) print(persona.yearPasses()) print(persona.initialAge)
base_datapath = '/Work19/2020/lijunjie/LRS3/AV_model_database/' with open(base_datapath+'pretrain_dataset.txt', 'r') as tr: lines = tr.readlines() for line in lines: info = line.strip().split('.') num1 = info[0].strip().split('-')[1] num2 = info[0].strip().split('-')[2] new_line = line.strip() + ' ' + num1 + '_faceemb.npy' + ' ' + num2 + '_faceemb.npy\n' with open(base_datapath+'AVdataset_pretrain.txt', 'a') as f: f.write(new_line) with open(base_datapath+'trainval_dataset.txt', 'r') as val: lines = val.readlines() for line in lines: info = line.strip().split('.') num1 = info[0].strip().split('-')[1] num2 = info[0].strip().split('-')[2] new_line = line.strip() + ' ' + num1 + '_faceemb.npy' + ' ' + num2 + '_faceemb.npy\n' with open(base_datapath+'AVdataset_trainval.txt','a') as f: f.write(new_line) with open(base_datapath+'test_dataset.txt', 'r') as val: lines = val.readlines() for line in lines: info = line.strip().split('.') num1 = info[0].strip().split('-')[1] num2 = info[0].strip().split('-')[2] new_line = line.strip() + ' ' + num1 + '_faceemb.npy' + ' ' + num2 + '_faceemb.npy\n' with open(base_datapath+'AVdataset_test.txt','a') as f: f.write(new_line)
"""Our first program in Python""" #print is the function to show to the user all we want print('Welcome to Python') #input is the functions that we use to recive data from the user name = input('Give me your name') #We can print the data we recive print('Hello ', name)
# Copyright (c) 2021 by Don Deel. All rights reserved. """ Shared data for fishem and its modules. All Redfish and Swordfish objects are shared as JSON objects in a dictionary named "fish". Redfish resource path names are used as keys to access objects in this dictionary, and these objects can contain nested elements. Examples are shown here: Key (path) Value (object) -------------------------------- -------------------------------- /redfish Protocol version object /redfish/v1 ServiceRoot /redfish/v1/<R> Resource Collection /redfish/v1/<R>/<Id1> Resource Singleton Id1 /redfish/v1/<R>/<Id1>/<SR> SubResource Collection /redfish/v1/<R>/<Id1>/<SR>/<Id2> SubResource Singleton Id2 /redfish/v1/odata OData Service Document /redfish/v1/$metadata Metadata Document <R> = Resource <SR> = SubResource <Id1> = Identifier <Id2> = Identifier Note: The keys for objects in this dictionary, including the ServiceRoot key, do NOT have trailing slashes. fishem configuration setup information is shared in a dictionary named "fishem_config". """ # fish data dictionary fish = {} # fishem configuration dictionary (set by fishem.py) fishem_config = {}
def entry(**kwargs): return '\n'.join([ "Welcome to SAMi", "What would you like? REPLY", "1 = Resources", "2 = Talk to a friend", "3 = Charge your phone", ]) def resources_1(**kwargs): return '\n'.join([ "Welcome to resources: TEXT", "1 = Food", "2 = Shelters", "3 = Bathroom/Showers", ]) def resources_shelters_1(**kwargs): return '\n'.join([ "Here are some shelters near you:", "" "Angels Flight (Youth)", "357 S Westlake Ave", "Los Angeles, California 90057", "0.17 miles / 0.27 kilometers", "(800) 833-2499", "5600 Rickenbacker Road", "" "Bell, California 90201", "(323) 263-1206", "0.11 miles / 0.17 kilometers", ]) def resources_bathrooms_1(**kwargs): return '\n'.join([ "Here are some public restrooms near you:", "The Box La", "805 Traction Avenue, The Box Gallery, Los Angeles, California", "0.0 miles / 0.0 kilometers", "", "Staples Center", "1111 S Figueroa St, Los Angeles, CA Los Angeles, CA", "0.11 miles / 0.17 kilometers", "", "Snowya", "123 Astronaut E S Onizuka St, Los Angeles, California", "0.17 miles / 0.27 kilometers", ])
def aumentar(preco=0, taxa=0, formatado=False): res = preco + (preco * taxa / 100) return res if formatado is False else moeda(res) def diminuir(preco=0, taxa=0, formatado=False): res = preco - (preco * taxa / 100) return res if formatado is False else moeda(res) def dobro(preco=0, formatado=False): res = preco * 2 return res if formatado is False else moeda(res) def metade(preco=0, formatado=False): res = preco / 2 return res if formatado is False else moeda(res) def moeda(preco=0, moeda="MTs"): return f"{preco:.2f}{moeda}".replace(".", ",") def resumo(p=0, taxaa=10, taxar=5): print("-" * 30) print("RESUMO DO VALOR".center(30)) print("-" * 30) print("Preco analisado: \t\t{}".format(moeda(p))) print("Dobro do preco: \t\t{}".format(dobro(p, True))) print("Metade do preco: \t\t{}".format(metade(p, True))) print("Com {}% de aumento: \t{}".format(taxaa, aumentar(p, taxaa, True))) print("Com {}% de reducao: \t{}".format(taxar, diminuir(p, taxar, True))) print("-" * 30)
class Queue: def __init__(self, initial_size = 10): self.arr = [0 for _ in range(initial_size)] self.next_index = 0; self.front_index = -1; self.queue_size = 0; def enqueue(self, value): if(self.queue_size) == len(self.arr): self.handle_queue_capacity_full(); self.arr[self.next_index] = value; self.queue_size += 1; self.next_index = (self.next_index + 1) % len(self.arr); if self.front_index == -1: self.front_index = 0; def dequeue(self): if self.is_empty(): self.front_index = -1; self.next_index = 0; return None; value = self.arr[self.front_index]; self.front_index = self.front_index + 1 % len(self.arr) self.queue_size -= 1; return value; def handle_queue_capacity_full(self): old_arr = self.arr; self.arr = [0 for _ in range(2 * len(old_arr))]; index = 0; for i in range(self.front_index, len(old_arr)): self.arr[index] = old_arr[i] index += 1; for i in range(0, self.front_index): self.arr[index] = old_arr[i]; index += 1; self.front_index = 0; self.next_index = index; def size(self): return self.queue_size; def is_empty(self): return self.size() == 0 def front(self): if self.front_index is -1: return None; else: return self.front_index; q = Queue() # print(q.arr) print("Pass" if q.arr == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] else "Fail"); print(q.arr) q.enqueue(10) q.enqueue(20) q.enqueue(30) q.enqueue(10) q.enqueue(20) q.enqueue(30) q.enqueue(10) q.enqueue(20) q.enqueue(30) q.enqueue(10) q.enqueue(20) q.enqueue(30) q.enqueue(10) q.enqueue(20) q.enqueue(30) q.enqueue(10) q.enqueue(20) q.enqueue(30) q.enqueue(20) q.enqueue(30) q.enqueue(20) q.enqueue(30) print(q.arr); val = q.dequeue(); print(val) print(q.size()) # print(print(q.size())) # print(print(q.is_empty())) # print(print(q.front()))
# clean city and sector columns ar & eng def cities(df): df['English_City'] = df["City"].copy() df['English_City'][df.English_City.str.contains('TABOUK')] = 'TABOUK' df['English_City'][df.English_City.str.contains('HAIL')] = 'HAIL' df['English_City'][df.English_City.str.contains('ABHA')] = 'ABHA' df['English_City'][df.English_City.str.contains('MAKKAH')] = 'MAKKAH' df['English_City'][df.English_City.str.contains('BURAIDAH')] = 'BURAIDAH' df['English_City'][df.English_City.str.contains('KHOBAR')] = 'KHOBAR' df['English_City'][df.English_City.str.contains('MADINA')] = 'MADINA' df['English_City'][df.English_City.str.contains('DAMMAM')] = 'DAMMAM' df['English_City'][df.English_City.str.contains('JEDDAH')] = 'JEDDAH' df['English_City'][df.English_City.str.contains('RIYADH')] = 'RIYADH' df['English_City'][df.English_City.str.contains('OTHER')] = 'OTHER' df['Arabic_City'] = df["City"].copy() df['Arabic_City'][df.Arabic_City.str.contains('TABOUK')] = 'تبوك' df['Arabic_City'][df.Arabic_City.str.contains('HAIL')] = 'حائل' df['Arabic_City'][df.Arabic_City.str.contains('ABHA')] = 'أبها' df['Arabic_City'][df.Arabic_City.str.contains('MAKKAH')] = 'مكة المكرمة' df['Arabic_City'][df.Arabic_City.str.contains('BURAIDAH')] = 'بريدة' df['Arabic_City'][df.Arabic_City.str.contains('KHOBAR')] = 'الخبر' df['Arabic_City'][df.Arabic_City.str.contains('MADINA')] = 'المنورة' df['Arabic_City'][df.Arabic_City.str.contains('DAMMAM')] = 'الدمام' df['Arabic_City'][df.Arabic_City.str.contains('JEDDAH')] = 'جدة' df['Arabic_City'][df.Arabic_City.str.contains('RIYADH')] = 'الرياض' df['Arabic_City'][df.Arabic_City.str.contains('OTHER')] = 'المدن الأخرى' del df["City"] def sectors(df): df['English_Sector'] = df["Sector"].copy() df['English_Sector'][df.English_Sector.str.contains('Clothing')] = 'Clothing and Footwear' df['English_Sector'][df.English_Sector.str.contains('Construction')] = 'Construction & Building Materials' df['English_Sector'][df.English_Sector.str.contains('Education')] = 'Education' df['English_Sector'][df.English_Sector.str.contains('Electronic')] = 'Electronic & Electric Devices' df['English_Sector'][df.English_Sector.str.contains('Gas')] = 'Gas' df['English_Sector'][df.English_Sector.str.contains('Health')] = 'Health' df['English_Sector'][df.English_Sector.str.contains('Furniture')] = 'Furniture' df['English_Sector'][df.English_Sector.str.contains('Hotels')] = 'Hotels' df['English_Sector'][df.English_Sector.str.contains('Public')] = 'Public Utilities' df['English_Sector'][df.English_Sector.str.contains('Jewelry')] = 'Jewelry' df['English_Sector'][df.English_Sector.str.contains('Miscellaneous')] = 'Miscellaneous Goods and Services' df['English_Sector'][df.English_Sector.str.contains('Recreation')] = 'Recreation and Culture' df['English_Sector'][df.English_Sector.str.contains('Culture')] = 'Recreation and Culture' df['English_Sector'][df.English_Sector.str.contains('Restaurants')] = 'Restaurants & Café' df['English_Sector'][df.English_Sector.str.contains('Beverage')] = 'Beverage and Food' df['English_Sector'][df.English_Sector.str.contains('Telecommunication')] = 'Telecommunication' df['English_Sector'][df.English_Sector.str.contains('Transportation')] = 'Transportation' df['English_Sector'][df.English_Sector.str.contains('Other')] = 'Other' df['English_Sector'][df.English_Sector.str.contains('Total')] = 'Total' df['Arabic_Sector'] = df["Sector"].copy() df['Arabic_Sector'][df.Arabic_Sector.str.contains('Clothing')] = 'الملابس والأحذية' df['Arabic_Sector'][df.Arabic_Sector.str.contains('Construction')] = 'مواد التشييد والبناء' df['Arabic_Sector'][df.Arabic_Sector.str.contains('Education')] = 'التعليم' df['Arabic_Sector'][df.Arabic_Sector.str.contains('Electronic')] = 'الأجهزة الإلكترونية والكهربائية' df['Arabic_Sector'][df.Arabic_Sector.str.contains('Gas')] = 'محطات الوقود' df['Arabic_Sector'][df.Arabic_Sector.str.contains('Health')] = 'الصحة' df['Arabic_Sector'][df.Arabic_Sector.str.contains('Furniture')] = 'الأثاث' df['Arabic_Sector'][df.Arabic_Sector.str.contains('Hotels')] = 'الفنادق' df['Arabic_Sector'][df.Arabic_Sector.str.contains('Public')] = 'المنافع العامة' df['Arabic_Sector'][df.Arabic_Sector.str.contains('Jewelry')] = 'المجوهرات' df['Arabic_Sector'][df.Arabic_Sector.str.contains('Miscellaneous')] = 'سلع وخدمات متنوعة' df['Arabic_Sector'][df.Arabic_Sector.str.contains('Recreation')] = 'الترفية والثقافة' df['Arabic_Sector'][df.Arabic_Sector.str.contains('Culture')] = 'الترفية والثقافة' df['Arabic_Sector'][df.Arabic_Sector.str.contains('Restaurants')] = 'المطاعم والمقاهي' df['Arabic_Sector'][df.Arabic_Sector.str.contains('Beverage')] = 'الأطعمة والمشروبات' df['Arabic_Sector'][df.Arabic_Sector.str.contains('Telecommunication')] = 'الاتصالات' df['Arabic_Sector'][df.Arabic_Sector.str.contains('Transportation')] = 'المواصلات' df['Arabic_Sector'][df.Arabic_Sector.str.contains('Other')] = 'أخرى' df['Arabic_Sector'][df.Arabic_Sector.str.contains('Total')] = 'الإجمالي' del df["Sector"] # to intger def to_int(df,x): df[x] = df[x].replace(',','', regex=True) df[x] = df[x].astype(int) def to_float(df,x): df[x] = df[x].replace(',','', regex=True) df[x] = df[x].astype(float) # pars date def fix_date(df): df["Start Date"]= df['Date'].str.split("-", n = 1, expand = True)[0] df['Start Date'] = [pd.to_datetime(x) for x in df['Start Date']] df["End Date"]= df['Date'].str.split("-", n = 1, expand = True)[1] df['End Date'] = [pd.to_datetime(x) for x in df['End Date']] df['Week Number'] = df['Start Date'].dt.week del df["Date"] def df_filter(message,df): slider_1, slider_2 = st.slider('%s' % (message),0,len(df)-1,[0,len(df)-1],1) while len(str(df.iloc[slider_1][1]).replace('.0','')) < 4: df.iloc[slider_1,1] = '0' + str(df.iloc[slider_1][1]).replace('.0','') while len(str(df.iloc[slider_2][1]).replace('.0','')) < 4: df.iloc[slider_2,1] = '0' + str(df.iloc[slider_1][1]).replace('.0','') start_date = datetime.datetime.strptime(str(df.iloc[slider_1][0]).replace('.0','') + str(df.iloc[slider_1][1]).replace('.0',''),'%Y%m%d%H%M%S') start_date = start_date.strftime('%d %b %Y, %I:%M%p') end_date = datetime.datetime.strptime(str(df.iloc[slider_2][0]).replace('.0','') + str(df.iloc[slider_2][1]).replace('.0',''),'%Y%m%d%H%M%S') end_date = end_date.strftime('%d %b %Y, %I:%M%p') st.info('Start: **%s** End: **%s**' % (start_date,end_date)) filtered_df = df.iloc[slider_1:slider_2+1][:].reset_index(drop=True) return filtered_df def filter_rows_by_values(df, col, values): return df[~df[col].isin(values)]
class ListNode(object): def __init__(self, x): self.val = x self.next = None def __repr__(self): node = self output = "" while node != None: output += str(node.val) output += " " node = node.next return output
#Unicode characters and strings #1960s/1970s ---> we assumed one byte is one character and went it with # a byte and character were assumed to be the same thing #ASCII goes up to 127 print(ord('H')) print(ord('e')) print(ord('\n')) print(ord('G')) #UTF-16 - fixed length, two byes #UTF-32 - fixed length, four byes #UTF-8 - 1-4 bytes # upwards compat with ASCII # auto detection between ASCII & UTF-8 # UTF-8 rec best pracetice for encoding/data exchange between systems # in python3, all strings are unicode # data in from external resource # must be decoded based on its character set so it's properly represented in py3 as a string # when talking to external network resource that sends bytes, # you need to encode the py3 strings into a given char encoding
a = ("Ты можеш входить один на вечеринку.") b = ("На вечеринку входи с мамой.") c = ("Тебе нельзя входить на вечеринку.") d = ("Сколько тебе лет?") age = int(input(d)) if (age>=25) : print (a) elif (age>18) and (age<25) : print (b) elif (age>много) : print ('Ну так вали отсюда со своим много') else: print (c)
""" Various constants used Unit abreviations are appended to the name, but powers are not specified. For instance, the gravitational constant has units "Mpc^3 msun^-1 s^-2", but is called "G_const_Mpc_Msun_s". Most of these numbers are from google calculator. SHOULD MOVE TO ASTROPY.UNITS AT SOME POINTS!!!!! """ # If you add a constant, make sure to add a description too. # Physical contants # Planck constant (in J.s) H_planck = 6.6262e-34 # speed of ight in vacuum (in m/s) c_light_m_s = 2.9979e8 # Boltzman constant in (J/K) K_boltzman = 1.3807e-23 # charge of the electron (in C) e_elec = 1.60217646e-19 # mass of a proton (in kg) m_p = 1.67262158e-27 # mass of an electron (in kg) m_e = 9.11e-31 # mass of the sun (in kg) m_sun = 1.98892e30 # h*c h_c = H_planck * c_light_m_s # Zero Celcius (K) zero_celsius = 273.15 # Black body constants BBT = H_planck / K_boltzman BBO = 2. * H_planck / c_light_m_s**2. # Zero point magnitude # Jy mag=0 m0Jy_band_U = 1810 m0Jy_band_B = 4260 m0Jy_band_V = 3640 m0Jy_band_R = 3080 m0Jy_band_I = 2550 m0Jy_band_J = 1600 m0Jy_band_H = 1080 m0Jy_band_K = 670 # --- extinction laws EXTINCTION_LAW_MW = 1 EXTINCTION_LAW_LMC = 2 EXTINCTION_LAW_SMC = 3 EXTINCTION_LAW_LINEAR = 4 EXTINCTION_LAW_CALZETTI = 5 EXTINCTION_LAW_GRB1 = 6 EXTINCTION_LAW_GRB2 = 7 # Others # Parsec in cm pc_cm = 3.085677e18 # Megaparsec in cm Mpc_cm = pc_cm * 1e6 # Megaparsec in km Mpc_km = Mpc_cm * 1e-5 # Angstrom in cm angstrom_cm = 1e-8 # a year in s yr_s = 365. * 24. * 60. * 60. # Megayear in s Myr_s = 1.e6 * yr_s # Gigayear in s Gyr_s = 1.e9 * yr_s # atomic mass unit in g amu_g = 1.66053886e-24 # mass of a proton in g m_p_g = m_p * 1e-6 # mass of a hydrogen atom in g m_H_g = 1.00794 * amu_g # mass of a helium atom in g m_He_g = 4.002602 * amu_g # Solar mass in grams M_sun_g = 1.98892e33 # Speed of light in m/s c_light_km_s = c_light_m_s * 1e-3 # Speed of light in cm/s c_light_cm_s = c_light_m_s * 1e2 # Speed of light in Mpc/s c_light_Mpc_s = c_light_cm_s / Mpc_cm # Speed of light in Mpc/Gyr c_light_Mpc_Gyr = Gyr_s * c_light_cm_s / Mpc_cm # km/s/Mpc H100_km_s_Mpc = 100. # 100 km s^-1 Mpc^-1 in s^-1 H100_s = 100. / Mpc_km # Gravitational constant in Mpc^3 msun^-1 s^-2 G_const_Mpc_Msun_s = M_sun_g * (6.673e-8) / Mpc_cm**3. # Central wavelength of H Lyman-alpha in Angstroms lambda_Lya_0 = 1215.67 # Central wavelength of an NV doublet in Angstroms lambda_NV_0 = 1240.81 # hydrogen recombination coefficient at T=10^4 K alpha_B_cm_s_1e4 = 2.59e-13 # Thomson cross section in cm^2 sigma_T_cm = 6.6524586e-25 # Thomson cross section in Mpc^2 sigma_T_Mpc = sigma_T_cm / (Mpc_cm ** 2.)
description = 'MIRA2 monochromator' group = 'lowlevel' includes = ['base', 'mslit2', 'sample', 'alias_mono'] tango_base = 'tango://miractrl.mira.frm2:10000/mira/' devices = dict( co_m2tt = device('nicos.devices.entangle.Sensor', visibility = (), tangodevice = tango_base + 'mono2/m2tt_enc', unit = 'deg', ), mo_m2tt = device('nicos.devices.entangle.Motor', visibility = (), tangodevice = tango_base + 'mono2/m2tt_mot', unit = 'deg', precision = 1, # due to backlash ), m2tt = device('nicos_mlz.mira.devices.axis.HoveringAxis', description = 'monochromator two-theta angle', precision = 0.04, backlash = 1, motor = 'mo_m2tt', coder = 'co_m2tt', startdelay = 1, stopdelay = 4, speed = 0.25, switch = 'air_mono', switchvalues = (0, 1), fmtstr = '%.3f', ), co_m2th = device('nicos.devices.entangle.Sensor', visibility = (), tangodevice = tango_base + 'mono2/m2th_enc', unit = 'deg', ), mo_m2th = device('nicos.devices.entangle.Motor', visibility = (), tangodevice = tango_base + 'mono2/m2th_mot', unit = 'deg', precision = 0.002, ), m2th = device('nicos.devices.generic.Axis', description = 'monochromator theta angle', motor = 'mo_m2th', coder = 'co_m2th', fmtstr = '%.3f', precision = 0.002, ), mono = device('nicos.devices.tas.Monochromator', description = 'monochromator unit to move incoming wavevector', unit = 'A-1', theta = 'm2th', twotheta = 'm2tt', focush = None, focusv = 'm2fv', abslimits = (0.1, 10), # calibration 1/2013, valid from 1.2 to 1.4 ki vfocuspars = [220.528, -40.485, 2.789], scatteringsense = -1, crystalside = -1, dvalue = 3.355, ), co_m2tx = device('nicos.devices.entangle.Sensor', visibility = (), tangodevice = tango_base + 'mono2/m2tx_enc', unit = 'mm', ), mo_m2tx = device('nicos.devices.entangle.Motor', visibility = (), tangodevice = tango_base + 'mono2/m2tx_mot', unit = 'mm', precision = 0.1, ), m2tx = device('nicos.devices.generic.Axis', description = 'monochromator translation parallel to the blades', motor = 'mo_m2tx', coder = 'co_m2tx', fmtstr = '%.2f', precision = 0.1, ), co_m2ty = device('nicos.devices.entangle.Sensor', visibility = (), tangodevice = tango_base + 'mono2/m2ty_enc', unit = 'mm', ), mo_m2ty = device('nicos.devices.entangle.Motor', visibility = (), tangodevice = tango_base + 'mono2/m2ty_mot', unit = 'mm', precision = 0.1, ), m2ty = device('nicos.devices.generic.Axis', description = 'monochromator translation perpendicular to the blades', motor = 'mo_m2ty', coder = 'co_m2ty', fmtstr = '%.2f', precision = 0.1, ), co_m2gx = device('nicos.devices.entangle.Sensor', visibility = (), tangodevice = tango_base + 'mono2/m2gx_enc', unit = 'deg', ), mo_m2gx = device('nicos.devices.entangle.Motor', visibility = (), tangodevice = tango_base + 'mono2/m2gx_mot', unit = 'deg', precision = 0.05, ), m2gx = device('nicos.devices.generic.Axis', description = 'monochromator tilt', motor = 'mo_m2gx', coder = 'co_m2gx', fmtstr = '%.2f', precision = 0.05, ), m2fv = device('nicos.devices.entangle.Motor', description = 'monochromator vertical focus', tangodevice = tango_base + 'mono2/m2fv_mot', unit = 'deg', precision = 0.5, fmtstr = '%.1f', ), PBe = device('nicos_mlz.mira.devices.center.CrappySensor', description = 'Be filter pressure', tangodevice = tango_base + 'leybold/sensor2', warnlimits = (1e-8, 0.00051), fmtstr = '%.2g', ), Pccr = device('nicos_mlz.mira.devices.center.CrappySensor', description = 'CCR isolation vacuum pressure', tangodevice = tango_base + 'leybold/sensor1', warnlimits = (1e-9, 1e-5), fmtstr = '%.2g', ), TBe = device('nicos.devices.entangle.Sensor', description = 'LakeShore sensor: Be filter temperature', tangodevice = tango_base + 'ls/t_be', warnlimits = (0, 65), pollinterval = 3, maxage = 5, fmtstr = '%.1f', ), ) startupcode = ''' mth.alias = m2th mtt.alias = m2tt mtx.alias = m2tx mty.alias = m2ty mgx.alias = m2gx mfv.alias = m2fv '''
# Divided OF two number while True: a = int(input("Enter The Dividend Number : ")) b = int(input("Enter The Divisor Number : ")) if a > b: quotient = int(a / b) print("Quotirnt Number Of :", quotient) else: Quotient = int(b / a) print("Quotirnt Number Of : 0.", Quotient)
IMPAR = [] PAR = [] for i in range(15): X = int(input()) if X % 2 == 0: PAR.append(X) elif X % 2 != 0: IMPAR.append(X) if len(PAR) == 5: Y = 0 for j in PAR: print('par[{}] = {}'.format(Y,j)) Y += 1 PAR = [] if len(IMPAR) == 5: Y = 0 for j in IMPAR: print('impar[{}] = {}'.format(Y,j)) Y += 1 IMPAR = [] if len(IMPAR) > 0: Y = 0 for j in IMPAR: print('impar[{}] = {}'.format(Y,j)) Y += 1 if len(PAR) > 0: Y = 0 for j in PAR: print('par[{}] = {}'.format(Y,j)) Y += 1
# The MIT License # Copyright (c) 2015 Tom Pollard # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. def compute_oasis(pd_dataframe): """ Takes Pandas DataFrame as an argument and computes Oxford Acute Severity of Illness Score (OASIS) (http://oasisicu.com/) The DataFrame should include only measurements taken over the first 24h from admission. pd_dataframe should contain the following columns: 'prelos' => Pre-ICU length of stay, hours 'age' => Age of patient, years 'GCS_total' => Total Glasgow Coma Scale for patient 'hrate' => All heart rate measurements 'MAP' => All mean arterial blood pressure measurements 'resp_rate' => All respiratory rate measurements 'temp_c' => All temperature measurements, C 'urine' => Total urine output over 24 h (note, not consecutive measurements) 'ventilated' => Is patient ventilated? (y,n) 'admission_type' => Type of admission (elective, urgent, emergency) Reference: Johnson AE, Kramer AA, Clifford GD. A new severity of illness scale using a subset of Acute Physiology And Chronic Health Evaluation data elements shows comparable predictive accuracy. Crit Care Med. 2013 Jul;41(7):1711-8. doi: 10.1097/CCM.0b013e31828a24fe http://www.ncbi.nlm.nih.gov/pubmed/23660729 """ # 10 variables oasis_score, oasis_prelos, oasis_age, oasis_gcs, oasis_hr, oasis_map, oasis_resp, \ oasis_temp, oasis_urine, oasis_vent, oasis_surg = 0,0,0,0,0,0,0,0,0,0,0 # Pre-ICU length of stay, hours for val in pd_dataframe['prelos']: if val >= 4.95 and val <= 24.0: oasis_prelos = np.nanmax([0,oasis_prelos]) elif val > 311.8: oasis_prelos = np.nanmax([1,oasis_prelos]) elif val > 24.0 and val <= 311.8: oasis_prelos = np.nanmax([2,oasis_prelos]) elif val >= 0.17 and val < 4.95: oasis_prelos = np.nanmax([3,oasis_prelos]) elif val < 0.17: oasis_prelos = np.nanmax([5,oasis_prelos]) else: oasis_prelos = np.nanmax([np.nan,oasis_prelos]) if pd_dataframe['prelos'].isnull().all(): oasis_prelos = np.nan # Age, years for val in pd_dataframe['age']: if val < 24: oasis_age = np.nanmax([0,oasis_age]) elif val >= 24 and val <= 53: oasis_age = np.nanmax([3,oasis_age]) elif val > 53 and val <= 77: oasis_age = np.nanmax([6,oasis_age]) elif val > 77 and val <= 89: oasis_age = np.nanmax([9,oasis_age]) elif val > 89: oasis_age = np.nanmax([7,oasis_age]) else: oasis_age = np.nanmax([np.nan,oasis_age]) if pd_dataframe['age'].isnull().all(): oasis_age = np.nan # Glasgow Coma Scale for val in pd_dataframe['GCS_total']: if val == 15: oasis_gcs = np.nanmax([0,oasis_gcs]) elif val == 14: oasis_gcs = np.nanmax([3,oasis_gcs]) elif val >= 8 and val <= 13: oasis_gcs = np.nanmax([4,oasis_gcs]) elif val >= 3 and val <= 7: oasis_gcs = np.nanmax([10,oasis_gcs]) else: oasis_gcs = np.nanmax([np.nan,oasis_gcs]) if pd_dataframe['GCS_total'].isnull().all(): oasis_gcs = np.nan # Heart rate for val in pd_dataframe['hrate']: if val >= 33 and val <= 88: oasis_hr = np.nanmax([0,oasis_hr]) elif val > 88 and val <= 106: oasis_hr = np.nanmax([1,oasis_hr]) elif val > 106 and val <= 125: oasis_hr = np.nanmax([3,oasis_hr]) elif val < 33: oasis_hr = np.nanmax([4,oasis_hr]) elif val > 125: oasis_hr = np.nanmax([6,oasis_hr]) else: oasis_hr = np.nanmax([np.nan,oasis_hr]) if pd_dataframe['hrate'].isnull().all(): oasis_hr = np.nan # Mean arterial pressure for val in pd_dataframe['MAP']: if val >=61.33 and val <= 143.44: oasis_map = np.nanmax([0,oasis_map]) elif val >= 51.0 and val < 61.33: oasis_map = np.nanmax([2,oasis_map]) elif (val >= 20.65 and val < 51.0) or (val > 143.44): oasis_map = np.nanmax([3,oasis_map]) elif val < 20.65: oasis_map = np.nanmax([4,oasis_map]) else: oasis_map = np.nanmax([np.nan,oasis_map]) if pd_dataframe['MAP'].isnull().all(): oasis_map = np.nan # Respiratory Rate for val in pd_dataframe['resp_rate']: if val >=13 and val <= 22: oasis_resp = np.nanmax([0,oasis_resp]) elif (val >= 6 and val <= 12) or (val >= 23 and val <= 30): oasis_resp = np.nanmax([1,oasis_resp]) elif val > 30 and val <= 44: oasis_resp = np.nanmax([6,oasis_resp]) elif val > 44: oasis_resp = np.nanmax([9,oasis_resp]) elif val < 6: oasis_resp = np.nanmax([10,oasis_resp]) else: oasis_resp = np.nanmax([np.nan,oasis_resp]) if pd_dataframe['resp_rate'].isnull().all(): oasis_resp = np.nan # Temperature, C for val in pd_dataframe['temp_c']: if val >= 36.40 and val <= 36.88: oasis_temp = np.nanmax([0,oasis_temp]) elif (val >= 35.94 and val < 36.40) or (val > 36.88 and val <= 39.88): oasis_temp = np.nanmax([2,oasis_temp]) elif val < 33.22: oasis_temp = np.nanmax([3,oasis_temp]) elif val >= 33.22 and val < 35.94: oasis_temp = np.nanmax([4,oasis_temp]) elif val > 39.88: oasis_temp = np.nanmax([6,oasis_temp]) else: oasis_temp = np.nanmax([np.nan,oasis_temp]) if pd_dataframe['temp_c'].isnull().all(): oasis_temp = np.nan # Urine output, cc/day (total over 24h) val = np.max(pd_dataframe['urine']) if val >=2544.0 and val <= 6896.0: oasis_urine = np.nanmax([0,oasis_urine]) elif val >= 1427.0 and val < 2544.0: oasis_urine = np.nanmax([1,oasis_urine]) elif val >= 671.0 and val < 1427.0: oasis_urine = np.nanmax([5,oasis_urine]) elif val > 6896.0: oasis_urine = np.nanmax([8,oasis_urine]) elif val < 671: oasis_urine = np.nanmax([10,oasis_urine]) else: oasis_urine = np.nanmax([np.nan,oasis_urine]) if pd_dataframe['urine'].isnull().all(): oasis_urine = np.nan # Ventilated y/n for val in pd_dataframe['ventilated']: if val == 'n': oasis_vent = np.nanmax([0,oasis_vent]) elif val == 'y': oasis_vent = np.nanmax([9,oasis_vent]) else: oasis_vent = np.nanmax([np.nan,oasis_vent]) if pd_dataframe['ventilated'].isnull().all(): oasis_vent = np.nan # Elective surgery y/n for val in pd_dataframe['admission_type']: if val == 'elective': oasis_surg = np.nanmax([0,oasis_surg]) elif val in ['urgent','emergency']: oasis_surg = np.nanmax([6,oasis_surg]) else: oasis_surg = np.nanmax([np.nan,oasis_surg]) if pd_dataframe['admission_type'].isnull().all(): oasis_surg = np.nan # Return sum oasis_score = sum([oasis_prelos, oasis_age, oasis_gcs, oasis_hr, oasis_map, oasis_resp, \ oasis_temp, oasis_urine, oasis_vent, oasis_surg]) return oasis_score
class UserRepositoryDependencyMarker: # pragma: no cover pass class ProductRepositoryDependencyMarker: # pragma: no cover pass
#!/usr/bin/env python3 # -*- coding: utf-8 -*- class Option: def __init__(self, name, number, y): self.name=name self.number=number self.y=y
# $Id: module_index.py 2790 2008-02-29 08:33:14Z cpbotha $ class emp_test: kits = ['vtk_kit'] cats = ['Tests'] keywords = ['test', 'tests', 'testing'] help = \ """Module to test DeVIDE extra-module-paths functionality. """
a = input('Digite algo ') print(' O tipo primitivo desse valor é:',type(a)) print('Só tem espaços?',a.isspace()) print('É um número?', a.isnumeric()) print('É alfabético?',a.isalpha()) print('é alfanumérico?',a.isalnum()) print('Está em maiúscula?',a.isupper()) print('Está em minúsculo?',a.islower()) print('Está captalizada?',a.istitle())
''' N = int(input()) notas100 = N//100 notas50 = (N-(notas100*100))//50 notas20 = (N-(notas100*100+notas50*50))//20 notas10 = (N-(notas100*100+notas50*50+notas20*20))//10 notas5 = (N-(notas100*100+notas50*50+notas20*20+notas10*10))//5 notas2 = (N-(notas100*100+notas50*50+notas20*20+notas10*10+notas5*5))//2 notas1 = (N-(notas100*100+notas50*50+notas20*20+notas10*10+notas5*5+notas2*2)) print(notas100, ' nota(s) de R$ 100,00') print(notas50, ' nota(s) de R$ 50,00') print(notas20, ' nota(s) de R$ 20,00') print(notas10, ' nota(s) de R$ 10,00') print(notas5, ' nota(s) de R$ 5,00') print(notas2, ' nota(s) de R$ 2,00') print(notas1, ' nota(s) de R$ 1,00') ''' N = int(input()) n100 = N//100 N = N - n100*100 n50 = N//50 N = N - n50*50 n20 = N//20 N = N - n20*20 n10 = N//10 N = N - n10*10 n5 = N//5 N = N - n5*5 n2 = N//2 N = N - n2*2 n1 = N print(n100, ' nota(s) de R$ 100,00') print(n50, ' nota(s) de R$ 50,00') print(n20, ' nota(s) de R$ 20,00') print(n10, ' nota(s) de R$ 10,00') print(n5, ' nota(s) de R$ 5,00') print(n2, ' nota(s) de R$ 2,00') print(n1, ' nota(s) de R$ 1,00')
n1 = float(input('Primeira reta: ')) n2 = float(input('Segunda reta: ')) n3 = float(input('Terceira reta: ')) if n1 < n2 + n3 and n2 < n1 + n3 and n3 < n1 + n2: print('Essas retas forrmam um triângulo ', end='') if n1 == n2 == n3: print('EQUILÁTERO!') elif n1 != n2 != n3: print('ESCALENO!') else: print('ISÓSCELES!') else: print('Com essas três retas não é possivel fazer um triângulo!')
# https://binarysearch.com/problems/Longest-Anagram-Subsequence class Solution: def solve(self, a, b): letters = set(list(a)).intersection(set(list(b))) length = 0 for i in letters: length += min(a.count(i),b.count(i)) return length
""" Formatando valores: :s -> Texto (string) :d -> Inteiro (int) :f -> Números de ponto flutuante (float) :.(NUMERO)f -> Quantidade de casas decimais (float) :(CARACTERE)(> ou < ou ^)(QUANTIDADE)(TIPO - s, d ou f) > -> Esquerda < -> Direita ^ -> Centro """ num_1 = 10 num_2 = 3 divisao = num_1 / num_2 print(f'{divisao:.2f}') # Formatação a esquerda com zeros num_1 = 1 print(f'{num_1:0>10}') num_2 = 1150 print(f'{num_2:0>10}') # Formatação a direita com zeros print(f'{num_1:0<10}') print(f'{num_2:0<10}') # Formatação com o valor centralizado print(f'{num_1:0^10}') print(f'{num_2:0^10}') # Funcionam com qualquer caractere, nao somente com numeros nome = 'John' print('{nome:@>15}'.format(nome=nome))
t = int(input()) while t > 0: t -= 1 n,m,s = map(int, input().strip().split(' ')) k = (s+m-1)%n if(k==0): print (n) else: print (k)
''' Description : Input In Function By .format Method Function Date : 14 Feb 2021 Function Author : Prasad Dangare Input : Int Output : Int ''' # defination of function, use of .format method def Addition(no1, no2): ans = no1 + no2 return ans def main(): print("enter first number") value1 = int(input()) print("enter second number") value2 = int(input()) ret = Addition(value1, value2) print("Addition of {} and {} is {} ".format(value1, value2, ret)) if __name__ == "__main__": main()
#cameraCoords syntax: [x1 (oben links),y1,x2 (unten rechts),y2,zoomLevel] def moveCamera(cameraCoords, move,worldSize): if cameraCoords[0]+move[0] <= 1 and move[0] < 0: cameraCoords[0] -= cameraCoords[0]%1 cameraCoords[2] -= cameraCoords[2]%1 while cameraCoords[0] > 1: cameraCoords[0] -= 1 #Wenn Kamera x-Koordinaten unter 0 gesetzt werden, werden die Koordinaten proportional angeglichen cameraCoords[2] -= 1 elif cameraCoords[2]+move[0]+1 >= worldSize[0]: return cameraCoords else: cameraCoords[0] += move[0] cameraCoords[2] += move[0]#Bewegen (x) if cameraCoords[1]+move[1] <= 1 and move[1] < 0: cameraCoords[1] -= cameraCoords[1]%1 cameraCoords[3] -= cameraCoords[3]%1 while cameraCoords[1] > 1: cameraCoords[1] -= 1#Wenn Kamera y-Koordinaten unter 0 gesetzt werden, werden die Koordinaten proportional angeglichen cameraCoords[3] -= 1 elif cameraCoords[3]+move[1]+1 >= worldSize[1]: return cameraCoords else: cameraCoords[1] += move[1] cameraCoords[3] += move[1]#Bewegen (y) return cameraCoords
def display_board( state ): print("-------------") print("| %i | %i | %i |" % (state[0], state[1], state[2])) print("-------------") print("| %i | %i | %i |" % (state[3], state[4], state[5])) print("-------------") print("| %i | %i | %i |" % (state[6], state[7], state[8])) print("-------------") def move_up(state): new_state = state[:] idx = new_state.index(0) if idx not in [0, 1, 2]: new_state[idx - 3], new_state[idx] = new_state[idx], new_state[idx - 3] return new_state else: return None def move_down(state): new_state = state[:] idx = new_state.index(0) if idx not in [6, 7, 8]: new_state[idx + 3], new_state[idx] = new_state[idx], new_state[idx + 3] return new_state else: return None def move_left(state): new_state = state[:] idx = new_state.index(0) if idx not in [0, 3, 6]: new_state[idx - 1], new_state[idx] = new_state[idx], new_state[idx - 1] return new_state else: return None def move_right(state): new_state = state[:] idx = new_state.index(0) if idx not in [2, 5, 8]: new_state[idx + 1], new_state[idx] = new_state[idx], new_state[idx + 1] return new_state else: return None def expand_children_nodes(node, known_states): expanded_nodes = [] expanded_nodes.append(Node(move_down(node.state), node, "d", node.depth + 1)) expanded_nodes.append(Node(move_up(node.state), node, "u", node.depth + 1)) expanded_nodes.append(Node(move_right(node.state), node, "r", node.depth + 1)) expanded_nodes.append(Node(move_left(node.state), node, "l", node.depth + 1)) expanded_nodes = [node for node in expanded_nodes if node.state != None and node.state not in [list(state) for state in known_states]] return expanded_nodes """Performs a breadth first search from the start state to the goal""" def bfs(start_state, goal_state): nodes = [] known_states = set() iterations = 0 nodes.append(Node(start_state, None, None, 0)) while True: if len( nodes ) == 0: return None iterations += 1 node = nodes.pop(0) known_states.add(tuple(node.state)) if node.state == goal_state: moves = [] temp = node print('\nFINISHED') display_board(node.state) while True: moves.insert(0, temp.operator) if temp.depth == 1: break temp = temp.parent display_board(temp.state) print('Initial state') display_board(temp.parent.state) print('Iterations: '+str(iterations)) return moves nodes.extend(expand_children_nodes(node, known_states)) """Performs a depth first search from the start state to the goal""" def dfs(start_state, goal_state, depth=5): depth_limit = depth nodes = [] known_states = set() iterations = 0 nodes.append(Node(start_state, None, None, 0)) while True: if len(nodes) == 0: return None node = nodes.pop(0) known_states.add(tuple(node.state)) iterations += 1 if node.state == goal_state: moves = [] temp = node display_board(node.state) while True: moves.insert(0, temp.operator) if temp.depth <= 1: break temp = temp.parent display_board(temp.state) print('Initial state') display_board(temp.parent.state) print('Iterations: '+str(iterations)) return moves if node.depth < depth_limit: expanded_nodes = expand_children_nodes(node, known_states) expanded_nodes.extend(nodes) print([i.depth for i in expanded_nodes]) nodes = expanded_nodes '''Node data structure''' class Node: def __init__(self, state, parent, operator, depth): self.state = state self.parent = parent self.operator = operator self.depth = depth '''Main method''' def main(): goal_state = [1, 2, 3, 4, 5, 6, 7, 8, 0] '''Input Unit Test''' # start_state = [1, 2, 3, 4, 5, 6, 7, 0, 8] # start_state = [1, 2, 3, 0, 4, 5, 7, 8, 6] start_state = [0, 2, 3, 1, 4, 5, 7, 8, 6] # start_state = [0, 8, 7, 6, 5, 4, 3, 2, 1] # UNSOLVABLE (24 steps) result = bfs(start_state, goal_state) if result == None: print("No solution found") elif result == [None]: print("Start node was the goal!") else: print(result) print(len(result), " moves") if __name__ == "__main__": main()
a = input ("Digite algo") print(a.isalpha()) print(a.isalnum()) print(a.isascii()) print(a.isdecimal()) print(a.isdigit()) print(a.isidentifier()) print(a.islower())
class Node: def __init__(self, val=0): self.value = val self.next = None class LinkList: c = 10 def __init__(self, *args): self.val = (*args,) self.head = self.__constructLinklist() #self.printLinklist(self.head) # self.pre = self.revserlinklist() # self.printLinklist(self.pre) def printLinklist(self, head): while head is not None: print(head.val) head = head.next def __constructLinklist(self): dummyNode = Node() head = Node(self.val[0]) dummyNode.next = head for i in range(1, len(self.val)): next = Node(self.val[i]) head.next = next head = next return dummyNode.next def revserlinklist(self): pre = None while self.head is not None: next = self.head.next self.head.next = pre pre = self.head self.head = next return pre def revserFromM2N(self, m, n): #if m<0 or n<0 or n>self.linklength():return None head2=self.head head3=self.head head2.next.next.next=None self.printLinklist(self.head) def linklength(self): length = 0 while self.head is not None: self.head = self.head.next length += 1 return length a = LinkList(1, 2, 3, 4, 5) a.revserFromM2N(2,3)
""" Question 59 : Print a unicode string "hello world". Hints : Use u'string format to define unicode string """ # Solution : unicode_string = u"hello world!" print(unicode_string) """ Output : hello world """
""" PASSENGERS """ numPassengers = 4084 passenger_arriving = ( (4, 8, 15, 6, 6, 0, 9, 7, 7, 4, 1, 0), # 0 (4, 11, 5, 5, 2, 0, 7, 10, 6, 8, 2, 0), # 1 (11, 10, 4, 1, 1, 0, 5, 9, 13, 5, 1, 0), # 2 (5, 5, 9, 5, 1, 0, 6, 8, 7, 3, 2, 0), # 3 (5, 10, 8, 7, 1, 0, 8, 16, 10, 3, 3, 0), # 4 (6, 12, 7, 1, 4, 0, 10, 6, 6, 5, 4, 0), # 5 (9, 12, 6, 2, 5, 0, 13, 17, 5, 3, 1, 0), # 6 (5, 5, 8, 2, 2, 0, 11, 17, 7, 8, 5, 0), # 7 (7, 9, 5, 4, 3, 0, 9, 15, 6, 6, 1, 0), # 8 (1, 8, 9, 6, 4, 0, 6, 14, 4, 5, 2, 0), # 9 (5, 2, 13, 10, 4, 0, 15, 9, 3, 9, 2, 0), # 10 (6, 16, 7, 6, 2, 0, 12, 12, 8, 7, 1, 0), # 11 (5, 12, 7, 4, 3, 0, 13, 11, 7, 3, 3, 0), # 12 (4, 17, 13, 6, 4, 0, 10, 8, 8, 5, 3, 0), # 13 (1, 15, 9, 5, 0, 0, 5, 9, 7, 6, 1, 0), # 14 (5, 11, 6, 3, 1, 0, 5, 10, 5, 5, 3, 0), # 15 (2, 5, 12, 7, 4, 0, 9, 17, 10, 10, 0, 0), # 16 (6, 5, 7, 7, 0, 0, 11, 9, 5, 5, 2, 0), # 17 (6, 11, 11, 5, 2, 0, 13, 8, 7, 5, 7, 0), # 18 (6, 12, 10, 7, 4, 0, 11, 12, 6, 3, 2, 0), # 19 (4, 12, 11, 3, 5, 0, 8, 15, 14, 10, 5, 0), # 20 (3, 4, 13, 4, 3, 0, 6, 7, 8, 7, 7, 0), # 21 (11, 13, 11, 5, 2, 0, 5, 14, 8, 2, 7, 0), # 22 (8, 10, 11, 6, 3, 0, 4, 7, 5, 7, 1, 0), # 23 (6, 12, 9, 3, 3, 0, 7, 12, 13, 5, 2, 0), # 24 (4, 10, 9, 5, 0, 0, 12, 11, 9, 6, 2, 0), # 25 (5, 9, 12, 0, 5, 0, 13, 14, 4, 8, 5, 0), # 26 (8, 8, 11, 0, 6, 0, 6, 9, 5, 6, 2, 0), # 27 (5, 15, 6, 3, 3, 0, 9, 2, 11, 3, 4, 0), # 28 (5, 14, 9, 5, 4, 0, 6, 10, 7, 1, 2, 0), # 29 (5, 14, 7, 2, 6, 0, 13, 6, 6, 7, 1, 0), # 30 (4, 10, 10, 2, 0, 0, 8, 12, 6, 3, 3, 0), # 31 (3, 12, 12, 4, 5, 0, 9, 16, 2, 9, 2, 0), # 32 (7, 13, 9, 3, 4, 0, 3, 11, 8, 5, 2, 0), # 33 (7, 10, 10, 5, 3, 0, 5, 13, 11, 7, 5, 0), # 34 (10, 18, 7, 7, 7, 0, 6, 9, 4, 3, 2, 0), # 35 (7, 7, 3, 6, 6, 0, 12, 13, 8, 3, 4, 0), # 36 (7, 19, 12, 3, 2, 0, 8, 8, 4, 4, 3, 0), # 37 (7, 13, 8, 1, 2, 0, 13, 11, 5, 4, 3, 0), # 38 (7, 11, 10, 7, 1, 0, 11, 10, 4, 9, 2, 0), # 39 (6, 14, 8, 4, 4, 0, 7, 16, 7, 7, 3, 0), # 40 (2, 24, 12, 4, 5, 0, 9, 17, 6, 8, 2, 0), # 41 (6, 11, 2, 3, 1, 0, 3, 11, 8, 6, 3, 0), # 42 (9, 10, 11, 4, 3, 0, 6, 11, 6, 6, 2, 0), # 43 (6, 14, 16, 3, 2, 0, 7, 5, 6, 3, 2, 0), # 44 (5, 11, 9, 7, 1, 0, 12, 16, 11, 9, 4, 0), # 45 (6, 11, 12, 6, 3, 0, 6, 21, 4, 10, 4, 0), # 46 (5, 10, 10, 6, 0, 0, 10, 12, 6, 8, 2, 0), # 47 (4, 11, 10, 3, 4, 0, 13, 9, 4, 7, 4, 0), # 48 (6, 16, 10, 5, 4, 0, 8, 7, 12, 3, 6, 0), # 49 (4, 10, 4, 7, 5, 0, 5, 14, 3, 3, 7, 0), # 50 (6, 14, 12, 1, 4, 0, 5, 13, 8, 3, 6, 0), # 51 (6, 18, 12, 5, 2, 0, 8, 11, 7, 8, 1, 0), # 52 (8, 9, 7, 5, 5, 0, 4, 11, 10, 6, 2, 0), # 53 (10, 12, 7, 3, 1, 0, 10, 14, 6, 9, 4, 0), # 54 (3, 16, 13, 7, 4, 0, 6, 11, 7, 6, 4, 0), # 55 (8, 18, 5, 3, 3, 0, 5, 13, 6, 4, 1, 0), # 56 (8, 10, 8, 3, 3, 0, 5, 18, 11, 9, 2, 0), # 57 (3, 16, 7, 7, 1, 0, 4, 14, 5, 8, 5, 0), # 58 (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # 59 ) station_arriving_intensity = ( (4.769372805092186, 12.233629261363635, 14.389624839331619, 11.405298913043477, 12.857451923076923, 8.562228260869567), # 0 (4.81413961808604, 12.369674877683082, 14.46734796754499, 11.46881589673913, 12.953819711538461, 8.559309850543478), # 1 (4.8583952589991215, 12.503702525252525, 14.54322622107969, 11.530934782608696, 13.048153846153847, 8.556302173913043), # 2 (4.902102161984196, 12.635567578125, 14.617204169344474, 11.591602581521737, 13.14036778846154, 8.553205638586958), # 3 (4.94522276119403, 12.765125410353535, 14.689226381748071, 11.650766304347826, 13.230375, 8.550020652173911), # 4 (4.987719490781387, 12.892231395991162, 14.759237427699228, 11.708372961956522, 13.318088942307691, 8.546747622282608), # 5 (5.029554784899035, 13.01674090909091, 14.827181876606687, 11.764369565217393, 13.403423076923078, 8.54338695652174), # 6 (5.0706910776997365, 13.138509323705808, 14.893004297879177, 11.818703125, 13.486290865384618, 8.5399390625), # 7 (5.1110908033362605, 13.257392013888888, 14.956649260925452, 11.871320652173912, 13.56660576923077, 8.536404347826087), # 8 (5.1507163959613695, 13.373244353693181, 15.018061335154243, 11.922169157608696, 13.644281249999999, 8.532783220108696), # 9 (5.1895302897278315, 13.485921717171717, 15.077185089974291, 11.971195652173915, 13.719230769230771, 8.529076086956522), # 10 (5.227494918788412, 13.595279478377526, 15.133965094794343, 12.018347146739131, 13.791367788461539, 8.525283355978262), # 11 (5.2645727172958745, 13.701173011363636, 15.188345919023137, 12.063570652173912, 13.860605769230768, 8.521405434782608), # 12 (5.3007261194029835, 13.803457690183082, 15.240272132069407, 12.106813179347826, 13.926858173076925, 8.51744273097826), # 13 (5.335917559262511, 13.90198888888889, 15.289688303341899, 12.148021739130433, 13.99003846153846, 8.513395652173912), # 14 (5.370109471027217, 13.996621981534089, 15.336539002249355, 12.187143342391304, 14.050060096153846, 8.509264605978261), # 15 (5.403264288849868, 14.087212342171718, 15.380768798200515, 12.224124999999999, 14.10683653846154, 8.50505), # 16 (5.4353444468832315, 14.173615344854797, 15.422322260604112, 12.258913722826087, 14.16028125, 8.500752241847827), # 17 (5.46631237928007, 14.255686363636363, 15.461143958868895, 12.291456521739132, 14.210307692307696, 8.496371739130435), # 18 (5.496130520193152, 14.333280772569443, 15.4971784624036, 12.321700407608695, 14.256829326923079, 8.491908899456522), # 19 (5.524761303775241, 14.40625394570707, 15.530370340616965, 12.349592391304348, 14.299759615384616, 8.487364130434782), # 20 (5.552167164179106, 14.47446125710227, 15.56066416291774, 12.375079483695652, 14.339012019230768, 8.482737839673913), # 21 (5.578310535557506, 14.537758080808082, 15.588004498714653, 12.398108695652175, 14.374499999999998, 8.47803043478261), # 22 (5.603153852063214, 14.595999790877526, 15.612335917416454, 12.418627038043478, 14.40613701923077, 8.473242323369567), # 23 (5.62665954784899, 14.649041761363636, 15.633602988431875, 12.43658152173913, 14.433836538461538, 8.468373913043479), # 24 (5.648790057067603, 14.696739366319445, 15.651750281169667, 12.451919157608696, 14.457512019230768, 8.463425611413044), # 25 (5.669507813871817, 14.738947979797977, 15.66672236503856, 12.464586956521739, 14.477076923076922, 8.458397826086957), # 26 (5.688775252414398, 14.77552297585227, 15.6784638094473, 12.474531929347828, 14.492444711538463, 8.453290964673915), # 27 (5.7065548068481124, 14.806319728535353, 15.68691918380463, 12.481701086956523, 14.503528846153845, 8.448105434782608), # 28 (5.722808911325724, 14.831193611900254, 15.69203305751928, 12.486041440217392, 14.510242788461538, 8.44284164402174), # 29 (5.7375, 14.85, 15.69375, 12.4875, 14.512500000000001, 8.4375), # 30 (5.751246651214834, 14.865621839488634, 15.692462907608693, 12.487236580882353, 14.511678590425532, 8.430077267616193), # 31 (5.7646965153452685, 14.881037215909092, 15.68863804347826, 12.486451470588234, 14.509231914893617, 8.418644565217393), # 32 (5.777855634590792, 14.896244211647728, 15.682330027173915, 12.485152389705883, 14.50518630319149, 8.403313830584706), # 33 (5.790730051150895, 14.91124090909091, 15.67359347826087, 12.483347058823531, 14.499568085106382, 8.38419700149925), # 34 (5.803325807225064, 14.926025390624996, 15.662483016304348, 12.481043198529411, 14.492403590425532, 8.361406015742128), # 35 (5.815648945012788, 14.940595738636366, 15.649053260869564, 12.478248529411767, 14.48371914893617, 8.335052811094453), # 36 (5.8277055067135555, 14.954950035511365, 15.63335883152174, 12.474970772058823, 14.47354109042553, 8.305249325337332), # 37 (5.839501534526853, 14.969086363636364, 15.615454347826088, 12.471217647058824, 14.461895744680852, 8.272107496251873), # 38 (5.851043070652174, 14.983002805397728, 15.595394429347825, 12.466996875000001, 14.44880944148936, 8.23573926161919), # 39 (5.862336157289003, 14.99669744318182, 15.573233695652176, 12.462316176470589, 14.434308510638296, 8.196256559220389), # 40 (5.873386836636828, 15.010168359374997, 15.549026766304348, 12.457183272058824, 14.418419281914893, 8.153771326836583), # 41 (5.88420115089514, 15.023413636363639, 15.522828260869566, 12.451605882352942, 14.401168085106384, 8.108395502248875), # 42 (5.894785142263428, 15.03643135653409, 15.494692798913043, 12.445591727941178, 14.38258125, 8.060241023238381), # 43 (5.905144852941176, 15.049219602272727, 15.464675, 12.439148529411764, 14.36268510638298, 8.009419827586207), # 44 (5.915286325127877, 15.061776455965909, 15.432829483695656, 12.43228400735294, 14.341505984042554, 7.956043853073464), # 45 (5.925215601023019, 15.074100000000003, 15.39921086956522, 12.425005882352941, 14.319070212765958, 7.90022503748126), # 46 (5.934938722826087, 15.086188316761364, 15.363873777173913, 12.417321874999999, 14.295404122340427, 7.842075318590705), # 47 (5.944461732736574, 15.098039488636365, 15.326872826086957, 12.409239705882353, 14.27053404255319, 7.7817066341829095), # 48 (5.953790672953963, 15.10965159801136, 15.288262635869566, 12.400767095588236, 14.24448630319149, 7.71923092203898), # 49 (5.96293158567775, 15.121022727272724, 15.248097826086958, 12.391911764705883, 14.217287234042553, 7.65476011994003), # 50 (5.971890513107417, 15.132150958806818, 15.206433016304347, 12.38268143382353, 14.188963164893616, 7.588406165667167), # 51 (5.980673497442456, 15.143034375, 15.163322826086954, 12.373083823529411, 14.159540425531915, 7.5202809970015), # 52 (5.989286580882353, 15.153671058238638, 15.118821875, 12.363126654411765, 14.129045345744682, 7.450496551724138), # 53 (5.9977358056266, 15.164059090909088, 15.072984782608694, 12.352817647058824, 14.09750425531915, 7.379164767616192), # 54 (6.00602721387468, 15.174196555397728, 15.02586616847826, 12.342164522058825, 14.064943484042553, 7.306397582458771), # 55 (6.014166847826087, 15.184081534090907, 14.977520652173913, 12.331175, 14.031389361702129, 7.232306934032984), # 56 (6.022160749680308, 15.193712109375003, 14.92800285326087, 12.319856801470587, 13.996868218085105, 7.15700476011994), # 57 (6.030014961636829, 15.203086363636363, 14.877367391304347, 12.308217647058825, 13.961406382978723, 7.0806029985007495), # 58 (0.0, 0.0, 0.0, 0.0, 0.0, 0.0), # 59 ) passenger_arriving_acc = ( (4, 8, 15, 6, 6, 0, 9, 7, 7, 4, 1, 0), # 0 (8, 19, 20, 11, 8, 0, 16, 17, 13, 12, 3, 0), # 1 (19, 29, 24, 12, 9, 0, 21, 26, 26, 17, 4, 0), # 2 (24, 34, 33, 17, 10, 0, 27, 34, 33, 20, 6, 0), # 3 (29, 44, 41, 24, 11, 0, 35, 50, 43, 23, 9, 0), # 4 (35, 56, 48, 25, 15, 0, 45, 56, 49, 28, 13, 0), # 5 (44, 68, 54, 27, 20, 0, 58, 73, 54, 31, 14, 0), # 6 (49, 73, 62, 29, 22, 0, 69, 90, 61, 39, 19, 0), # 7 (56, 82, 67, 33, 25, 0, 78, 105, 67, 45, 20, 0), # 8 (57, 90, 76, 39, 29, 0, 84, 119, 71, 50, 22, 0), # 9 (62, 92, 89, 49, 33, 0, 99, 128, 74, 59, 24, 0), # 10 (68, 108, 96, 55, 35, 0, 111, 140, 82, 66, 25, 0), # 11 (73, 120, 103, 59, 38, 0, 124, 151, 89, 69, 28, 0), # 12 (77, 137, 116, 65, 42, 0, 134, 159, 97, 74, 31, 0), # 13 (78, 152, 125, 70, 42, 0, 139, 168, 104, 80, 32, 0), # 14 (83, 163, 131, 73, 43, 0, 144, 178, 109, 85, 35, 0), # 15 (85, 168, 143, 80, 47, 0, 153, 195, 119, 95, 35, 0), # 16 (91, 173, 150, 87, 47, 0, 164, 204, 124, 100, 37, 0), # 17 (97, 184, 161, 92, 49, 0, 177, 212, 131, 105, 44, 0), # 18 (103, 196, 171, 99, 53, 0, 188, 224, 137, 108, 46, 0), # 19 (107, 208, 182, 102, 58, 0, 196, 239, 151, 118, 51, 0), # 20 (110, 212, 195, 106, 61, 0, 202, 246, 159, 125, 58, 0), # 21 (121, 225, 206, 111, 63, 0, 207, 260, 167, 127, 65, 0), # 22 (129, 235, 217, 117, 66, 0, 211, 267, 172, 134, 66, 0), # 23 (135, 247, 226, 120, 69, 0, 218, 279, 185, 139, 68, 0), # 24 (139, 257, 235, 125, 69, 0, 230, 290, 194, 145, 70, 0), # 25 (144, 266, 247, 125, 74, 0, 243, 304, 198, 153, 75, 0), # 26 (152, 274, 258, 125, 80, 0, 249, 313, 203, 159, 77, 0), # 27 (157, 289, 264, 128, 83, 0, 258, 315, 214, 162, 81, 0), # 28 (162, 303, 273, 133, 87, 0, 264, 325, 221, 163, 83, 0), # 29 (167, 317, 280, 135, 93, 0, 277, 331, 227, 170, 84, 0), # 30 (171, 327, 290, 137, 93, 0, 285, 343, 233, 173, 87, 0), # 31 (174, 339, 302, 141, 98, 0, 294, 359, 235, 182, 89, 0), # 32 (181, 352, 311, 144, 102, 0, 297, 370, 243, 187, 91, 0), # 33 (188, 362, 321, 149, 105, 0, 302, 383, 254, 194, 96, 0), # 34 (198, 380, 328, 156, 112, 0, 308, 392, 258, 197, 98, 0), # 35 (205, 387, 331, 162, 118, 0, 320, 405, 266, 200, 102, 0), # 36 (212, 406, 343, 165, 120, 0, 328, 413, 270, 204, 105, 0), # 37 (219, 419, 351, 166, 122, 0, 341, 424, 275, 208, 108, 0), # 38 (226, 430, 361, 173, 123, 0, 352, 434, 279, 217, 110, 0), # 39 (232, 444, 369, 177, 127, 0, 359, 450, 286, 224, 113, 0), # 40 (234, 468, 381, 181, 132, 0, 368, 467, 292, 232, 115, 0), # 41 (240, 479, 383, 184, 133, 0, 371, 478, 300, 238, 118, 0), # 42 (249, 489, 394, 188, 136, 0, 377, 489, 306, 244, 120, 0), # 43 (255, 503, 410, 191, 138, 0, 384, 494, 312, 247, 122, 0), # 44 (260, 514, 419, 198, 139, 0, 396, 510, 323, 256, 126, 0), # 45 (266, 525, 431, 204, 142, 0, 402, 531, 327, 266, 130, 0), # 46 (271, 535, 441, 210, 142, 0, 412, 543, 333, 274, 132, 0), # 47 (275, 546, 451, 213, 146, 0, 425, 552, 337, 281, 136, 0), # 48 (281, 562, 461, 218, 150, 0, 433, 559, 349, 284, 142, 0), # 49 (285, 572, 465, 225, 155, 0, 438, 573, 352, 287, 149, 0), # 50 (291, 586, 477, 226, 159, 0, 443, 586, 360, 290, 155, 0), # 51 (297, 604, 489, 231, 161, 0, 451, 597, 367, 298, 156, 0), # 52 (305, 613, 496, 236, 166, 0, 455, 608, 377, 304, 158, 0), # 53 (315, 625, 503, 239, 167, 0, 465, 622, 383, 313, 162, 0), # 54 (318, 641, 516, 246, 171, 0, 471, 633, 390, 319, 166, 0), # 55 (326, 659, 521, 249, 174, 0, 476, 646, 396, 323, 167, 0), # 56 (334, 669, 529, 252, 177, 0, 481, 664, 407, 332, 169, 0), # 57 (337, 685, 536, 259, 178, 0, 485, 678, 412, 340, 174, 0), # 58 (337, 685, 536, 259, 178, 0, 485, 678, 412, 340, 174, 0), # 59 ) passenger_arriving_rate = ( (4.769372805092186, 9.786903409090908, 8.63377490359897, 4.56211956521739, 2.5714903846153843, 0.0, 8.562228260869567, 10.285961538461537, 6.843179347826086, 5.755849935732647, 2.446725852272727, 0.0), # 0 (4.81413961808604, 9.895739902146465, 8.680408780526994, 4.587526358695651, 2.5907639423076922, 0.0, 8.559309850543478, 10.363055769230769, 6.881289538043478, 5.786939187017995, 2.4739349755366162, 0.0), # 1 (4.8583952589991215, 10.00296202020202, 8.725935732647814, 4.612373913043478, 2.609630769230769, 0.0, 8.556302173913043, 10.438523076923076, 6.918560869565217, 5.817290488431875, 2.500740505050505, 0.0), # 2 (4.902102161984196, 10.1084540625, 8.770322501606683, 4.636641032608694, 2.628073557692308, 0.0, 8.553205638586958, 10.512294230769232, 6.954961548913042, 5.846881667737789, 2.527113515625, 0.0), # 3 (4.94522276119403, 10.212100328282828, 8.813535829048842, 4.66030652173913, 2.6460749999999997, 0.0, 8.550020652173911, 10.584299999999999, 6.990459782608696, 5.875690552699228, 2.553025082070707, 0.0), # 4 (4.987719490781387, 10.313785116792928, 8.855542456619537, 4.6833491847826085, 2.663617788461538, 0.0, 8.546747622282608, 10.654471153846153, 7.025023777173913, 5.90369497107969, 2.578446279198232, 0.0), # 5 (5.029554784899035, 10.413392727272727, 8.896309125964011, 4.705747826086957, 2.680684615384615, 0.0, 8.54338695652174, 10.72273846153846, 7.058621739130436, 5.930872750642674, 2.603348181818182, 0.0), # 6 (5.0706910776997365, 10.510807458964646, 8.935802578727506, 4.72748125, 2.697258173076923, 0.0, 8.5399390625, 10.789032692307693, 7.0912218750000005, 5.95720171915167, 2.6277018647411614, 0.0), # 7 (5.1110908033362605, 10.60591361111111, 8.97398955655527, 4.7485282608695645, 2.7133211538461537, 0.0, 8.536404347826087, 10.853284615384615, 7.122792391304347, 5.982659704370181, 2.6514784027777774, 0.0), # 8 (5.1507163959613695, 10.698595482954543, 9.010836801092546, 4.768867663043478, 2.7288562499999993, 0.0, 8.532783220108696, 10.915424999999997, 7.153301494565217, 6.007224534061697, 2.6746488707386358, 0.0), # 9 (5.1895302897278315, 10.788737373737373, 9.046311053984574, 4.7884782608695655, 2.743846153846154, 0.0, 8.529076086956522, 10.975384615384616, 7.182717391304348, 6.030874035989716, 2.697184343434343, 0.0), # 10 (5.227494918788412, 10.87622358270202, 9.080379056876605, 4.807338858695652, 2.7582735576923074, 0.0, 8.525283355978262, 11.03309423076923, 7.2110082880434785, 6.053586037917737, 2.719055895675505, 0.0), # 11 (5.2645727172958745, 10.960938409090907, 9.113007551413881, 4.825428260869565, 2.7721211538461534, 0.0, 8.521405434782608, 11.088484615384614, 7.238142391304347, 6.0753383676092545, 2.740234602272727, 0.0), # 12 (5.3007261194029835, 11.042766152146465, 9.144163279241644, 4.8427252717391305, 2.7853716346153847, 0.0, 8.51744273097826, 11.141486538461539, 7.264087907608696, 6.096108852827762, 2.760691538036616, 0.0), # 13 (5.335917559262511, 11.121591111111112, 9.173812982005138, 4.859208695652173, 2.7980076923076918, 0.0, 8.513395652173912, 11.192030769230767, 7.288813043478259, 6.115875321336759, 2.780397777777778, 0.0), # 14 (5.370109471027217, 11.19729758522727, 9.201923401349612, 4.874857336956521, 2.810012019230769, 0.0, 8.509264605978261, 11.240048076923076, 7.312286005434782, 6.134615600899742, 2.7993243963068175, 0.0), # 15 (5.403264288849868, 11.269769873737372, 9.228461278920308, 4.88965, 2.8213673076923076, 0.0, 8.50505, 11.28546923076923, 7.334474999999999, 6.152307519280206, 2.817442468434343, 0.0), # 16 (5.4353444468832315, 11.338892275883836, 9.253393356362468, 4.903565489130434, 2.83205625, 0.0, 8.500752241847827, 11.328225, 7.3553482336956515, 6.168928904241644, 2.834723068970959, 0.0), # 17 (5.46631237928007, 11.40454909090909, 9.276686375321336, 4.916582608695652, 2.842061538461539, 0.0, 8.496371739130435, 11.368246153846156, 7.374873913043479, 6.184457583547558, 2.8511372727272724, 0.0), # 18 (5.496130520193152, 11.466624618055553, 9.298307077442159, 4.928680163043477, 2.8513658653846155, 0.0, 8.491908899456522, 11.405463461538462, 7.393020244565217, 6.198871384961439, 2.866656154513888, 0.0), # 19 (5.524761303775241, 11.525003156565655, 9.318222204370178, 4.939836956521739, 2.859951923076923, 0.0, 8.487364130434782, 11.439807692307692, 7.409755434782609, 6.212148136246785, 2.8812507891414136, 0.0), # 20 (5.552167164179106, 11.579569005681815, 9.336398497750643, 4.95003179347826, 2.8678024038461536, 0.0, 8.482737839673913, 11.471209615384614, 7.425047690217391, 6.224265665167096, 2.894892251420454, 0.0), # 21 (5.578310535557506, 11.630206464646465, 9.352802699228791, 4.95924347826087, 2.8748999999999993, 0.0, 8.47803043478261, 11.499599999999997, 7.438865217391305, 6.235201799485861, 2.907551616161616, 0.0), # 22 (5.603153852063214, 11.67679983270202, 9.367401550449872, 4.967450815217391, 2.8812274038461534, 0.0, 8.473242323369567, 11.524909615384614, 7.451176222826087, 6.244934366966581, 2.919199958175505, 0.0), # 23 (5.62665954784899, 11.719233409090908, 9.380161793059125, 4.974632608695652, 2.8867673076923075, 0.0, 8.468373913043479, 11.54706923076923, 7.461948913043478, 6.25344119537275, 2.929808352272727, 0.0), # 24 (5.648790057067603, 11.757391493055556, 9.391050168701799, 4.980767663043478, 2.8915024038461534, 0.0, 8.463425611413044, 11.566009615384614, 7.471151494565217, 6.260700112467866, 2.939347873263889, 0.0), # 25 (5.669507813871817, 11.79115838383838, 9.400033419023135, 4.985834782608695, 2.8954153846153843, 0.0, 8.458397826086957, 11.581661538461537, 7.478752173913043, 6.266688946015424, 2.947789595959595, 0.0), # 26 (5.688775252414398, 11.820418380681815, 9.40707828566838, 4.989812771739131, 2.8984889423076923, 0.0, 8.453290964673915, 11.593955769230769, 7.484719157608696, 6.271385523778919, 2.9551045951704538, 0.0), # 27 (5.7065548068481124, 11.84505578282828, 9.412151510282778, 4.992680434782609, 2.9007057692307687, 0.0, 8.448105434782608, 11.602823076923075, 7.489020652173913, 6.274767673521851, 2.96126394570707, 0.0), # 28 (5.722808911325724, 11.864954889520202, 9.415219834511568, 4.994416576086956, 2.902048557692307, 0.0, 8.44284164402174, 11.608194230769229, 7.491624864130435, 6.276813223007712, 2.9662387223800506, 0.0), # 29 (5.7375, 11.879999999999999, 9.41625, 4.995, 2.9025, 0.0, 8.4375, 11.61, 7.4925, 6.277499999999999, 2.9699999999999998, 0.0), # 30 (5.751246651214834, 11.892497471590906, 9.415477744565216, 4.994894632352941, 2.9023357180851064, 0.0, 8.430077267616193, 11.609342872340426, 7.492341948529411, 6.276985163043476, 2.9731243678977264, 0.0), # 31 (5.7646965153452685, 11.904829772727274, 9.413182826086956, 4.994580588235293, 2.901846382978723, 0.0, 8.418644565217393, 11.607385531914892, 7.49187088235294, 6.275455217391303, 2.9762074431818184, 0.0), # 32 (5.777855634590792, 11.916995369318181, 9.40939801630435, 4.994060955882353, 2.9010372606382977, 0.0, 8.403313830584706, 11.60414904255319, 7.491091433823529, 6.272932010869566, 2.9792488423295453, 0.0), # 33 (5.790730051150895, 11.928992727272727, 9.40415608695652, 4.993338823529412, 2.899913617021276, 0.0, 8.38419700149925, 11.599654468085104, 7.490008235294118, 6.269437391304347, 2.9822481818181816, 0.0), # 34 (5.803325807225064, 11.940820312499996, 9.39748980978261, 4.9924172794117645, 2.898480718085106, 0.0, 8.361406015742128, 11.593922872340425, 7.488625919117647, 6.264993206521739, 2.985205078124999, 0.0), # 35 (5.815648945012788, 11.952476590909091, 9.389431956521738, 4.9912994117647065, 2.896743829787234, 0.0, 8.335052811094453, 11.586975319148936, 7.486949117647059, 6.259621304347825, 2.988119147727273, 0.0), # 36 (5.8277055067135555, 11.96396002840909, 9.380015298913044, 4.989988308823529, 2.8947082180851056, 0.0, 8.305249325337332, 11.578832872340422, 7.484982463235293, 6.253343532608695, 2.9909900071022726, 0.0), # 37 (5.839501534526853, 11.97526909090909, 9.369272608695653, 4.988487058823529, 2.89237914893617, 0.0, 8.272107496251873, 11.56951659574468, 7.4827305882352935, 6.246181739130434, 2.9938172727272727, 0.0), # 38 (5.851043070652174, 11.986402244318182, 9.357236657608695, 4.98679875, 2.8897618882978717, 0.0, 8.23573926161919, 11.559047553191487, 7.480198125, 6.23815777173913, 2.9966005610795454, 0.0), # 39 (5.862336157289003, 11.997357954545455, 9.343940217391305, 4.984926470588235, 2.886861702127659, 0.0, 8.196256559220389, 11.547446808510635, 7.477389705882353, 6.22929347826087, 2.999339488636364, 0.0), # 40 (5.873386836636828, 12.008134687499997, 9.329416059782607, 4.982873308823529, 2.8836838563829783, 0.0, 8.153771326836583, 11.534735425531913, 7.474309963235294, 6.219610706521738, 3.002033671874999, 0.0), # 41 (5.88420115089514, 12.01873090909091, 9.31369695652174, 4.980642352941176, 2.880233617021277, 0.0, 8.108395502248875, 11.520934468085107, 7.4709635294117644, 6.209131304347826, 3.0046827272727277, 0.0), # 42 (5.894785142263428, 12.02914508522727, 9.296815679347825, 4.978236691176471, 2.8765162499999994, 0.0, 8.060241023238381, 11.506064999999998, 7.467355036764706, 6.1978771195652165, 3.0072862713068176, 0.0), # 43 (5.905144852941176, 12.03937568181818, 9.278805, 4.975659411764705, 2.8725370212765955, 0.0, 8.009419827586207, 11.490148085106382, 7.4634891176470575, 6.1858699999999995, 3.009843920454545, 0.0), # 44 (5.915286325127877, 12.049421164772726, 9.259697690217394, 4.972913602941176, 2.8683011968085106, 0.0, 7.956043853073464, 11.473204787234042, 7.459370404411764, 6.1731317934782615, 3.0123552911931815, 0.0), # 45 (5.925215601023019, 12.059280000000001, 9.239526521739132, 4.970002352941176, 2.8638140425531913, 0.0, 7.90022503748126, 11.455256170212765, 7.455003529411765, 6.159684347826087, 3.0148200000000003, 0.0), # 46 (5.934938722826087, 12.06895065340909, 9.218324266304347, 4.966928749999999, 2.859080824468085, 0.0, 7.842075318590705, 11.43632329787234, 7.450393124999999, 6.145549510869564, 3.0172376633522724, 0.0), # 47 (5.944461732736574, 12.07843159090909, 9.196123695652174, 4.9636958823529405, 2.854106808510638, 0.0, 7.7817066341829095, 11.416427234042551, 7.445543823529412, 6.130749130434782, 3.0196078977272727, 0.0), # 48 (5.953790672953963, 12.087721278409088, 9.17295758152174, 4.960306838235294, 2.8488972606382976, 0.0, 7.71923092203898, 11.39558904255319, 7.4404602573529415, 6.115305054347826, 3.021930319602272, 0.0), # 49 (5.96293158567775, 12.096818181818177, 9.148858695652175, 4.956764705882353, 2.8434574468085105, 0.0, 7.65476011994003, 11.373829787234042, 7.43514705882353, 6.099239130434783, 3.0242045454545443, 0.0), # 50 (5.971890513107417, 12.105720767045453, 9.123859809782608, 4.953072573529411, 2.837792632978723, 0.0, 7.588406165667167, 11.351170531914892, 7.429608860294118, 6.082573206521738, 3.026430191761363, 0.0), # 51 (5.980673497442456, 12.114427499999998, 9.097993695652173, 4.949233529411764, 2.8319080851063827, 0.0, 7.5202809970015, 11.32763234042553, 7.4238502941176465, 6.065329130434781, 3.0286068749999995, 0.0), # 52 (5.989286580882353, 12.122936846590909, 9.071293125, 4.945250661764706, 2.8258090691489364, 0.0, 7.450496551724138, 11.303236276595745, 7.417875992647058, 6.04752875, 3.030734211647727, 0.0), # 53 (5.9977358056266, 12.13124727272727, 9.043790869565216, 4.941127058823529, 2.8195008510638297, 0.0, 7.379164767616192, 11.278003404255319, 7.411690588235294, 6.0291939130434775, 3.0328118181818176, 0.0), # 54 (6.00602721387468, 12.139357244318182, 9.015519701086955, 4.93686580882353, 2.8129886968085103, 0.0, 7.306397582458771, 11.251954787234041, 7.405298713235295, 6.010346467391304, 3.0348393110795455, 0.0), # 55 (6.014166847826087, 12.147265227272724, 8.986512391304348, 4.9324699999999995, 2.8062778723404254, 0.0, 7.232306934032984, 11.225111489361701, 7.398705, 5.991008260869565, 3.036816306818181, 0.0), # 56 (6.022160749680308, 12.154969687500001, 8.95680171195652, 4.927942720588234, 2.7993736436170207, 0.0, 7.15700476011994, 11.197494574468083, 7.391914080882352, 5.9712011413043475, 3.0387424218750003, 0.0), # 57 (6.030014961636829, 12.16246909090909, 8.926420434782608, 4.923287058823529, 2.792281276595744, 0.0, 7.0806029985007495, 11.169125106382976, 7.384930588235295, 5.950946956521738, 3.0406172727272724, 0.0), # 58 (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), # 59 ) passenger_allighting_rate = ( (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 0 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 1 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 2 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 3 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 4 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 5 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 6 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 7 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 8 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 9 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 10 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 11 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 12 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 13 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 14 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 15 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 16 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 17 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 18 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 19 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 20 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 21 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 22 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 23 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 24 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 25 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 26 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 27 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 28 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 29 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 30 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 31 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 32 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 33 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 34 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 35 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 36 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 37 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 38 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 39 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 40 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 41 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 42 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 43 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 44 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 45 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 46 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 47 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 48 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 49 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 50 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 51 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 52 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 53 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 54 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 55 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 56 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 57 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 58 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 59 ) """ parameters for reproducibiliy. More information: https://numpy.org/doc/stable/reference/random/parallel.html """ #initial entropy entropy = 258194110137029475889902652135037600173 #index for seed sequence child child_seed_index = ( 1, # 0 77, # 1 )
''' __program__: Taking user input from the user __author__: Abhinav Anil __submittedTo__: dataSciTech __email__: dataascii@gmail.com __instagram__: @data.sci_ ''' #Taking the user name, PAN card number to validate the information for the user details. while(1): name = input("\n Enter your name : ") if name.isalpha() == False: print("Invalid Name, Sorry you cannot proceed.") break else: pan_card_no = input("\n Enter your PAN card number : ") if pan_card_no.isalnum == False: print("Invalid PAN card number, Sorry you cannot proceed.") break print("Please check "+name, "your PAN card number is: "+pan_card_no) break
peoples = { 'first_name': 'le', 'last_name': 'xiaoyuan', 'age': 21, 'city': 'dawu' } print(peoples['first_name']) print(peoples['last_name']) print(peoples['age']) print(peoples['city']) for people in peoples.values(): print(people) lucky_number = { 'lexiaoyuan': 6, 'benjamin': 66, 'lexiaoyuanbeta': 666, 'yege': 6666, 'ruanwei': 66666 } print('lexiaoyuan'.title() + "'s lucky number is " + str(lucky_number['lexiaoyuan'])) print('benjamin'.title() + "'s lucky number is " + str(lucky_number['benjamin'])) print('lexiaoyuanbeta'.title() + "'s lucky number is " + str(lucky_number['lexiaoyuanbeta'])) print('yege'.title() + "'s lucky number is " + str(lucky_number['yege'])) print('ruanwei'.title() + "'s lucky number is " + str(lucky_number['ruanwei'])) for name, number in lucky_number.items(): print(name.title() + "'s lucky number is " + str(number)) dictionary = { 'if': 'if', 'for': 'for', 'list': 'list', 'title': 'title', 'upper': 'upper' } print("if: " + dictionary['if']) print("for: " + dictionary['for']) print("list: " + dictionary['list']) print("title: " + dictionary['title']) print("upper: " + dictionary['upper']) for dic in dictionary.keys(): print(dic) people_1 = { 'first_name': 'le', 'last_name': 'xiaoyuan', 'age': 21, 'city': 'dawu' } people_2 = { 'first_name': 'le', 'last_name': 'xiaoyuanbeta', 'age': 21, 'city': 'dawu' } people_3 = { 'first_name': 'ben', 'last_name': 'jamin', 'age': 21, 'city': 'dawu' } people = [people_1, people_2, people_3] for p in people: print(p) lucky_numbers = { 'lexiaoyuan': [6, 66], 'benjamin': [66, 666], 'lexiaoyuanbeta': [666, 6666], 'yege': [6666, 66666], 'ruanwei': [66666, 666666], } for name, numbers in lucky_numbers.items(): print(name.title() + "'s favorite number are:") for number in numbers: print("\t" + str(number))
# Problem! you teach children about how to calculate the area and perimeter of the square # and you will solve 20 questions about the way to find area and perimeter. to teach them. # but that will consume the time, so you want to write a program to reduce the time # when calculating all 20 quests. # Now try to solve it. # Hint: perimeter = (x * 4), area = (x ** 2) # The first method def calc(x): sideLength = x print(f"area = {sideLength ** 2}") print(f"perimeter = {sideLength * 4}") calc(int(input())) # The second method calcs = lambda x : (x**2, x*4) c1, c2 = calcs(int(input())) print(f'area = {c1}\nperimeter = {c2}') # The 3rd method def calc2(x): return (x**2, x*4) a, b = calcs(int(input())) print(str(a) + ' is area', str(b) + ' is perimeter')
class PullRequest: """ This class models a pull-request. """ @staticmethod def __initialize_files(files_string): return files_string.split("|") def __init__(self, data): self.pr_id = data[0] self.pull_number = data[1] self.requester_login = data[2] self.title = data[3] self.description = data[4] self.created_date = data[5] self.merged_date = data[6] self.integrator_login = data[7] self.files = self.__initialize_files(data[8]) @property def pr_id(self): return self.__pr_id @property def pull_number(self): return self.__pull_number @property def requester_login(self): return self.__requester_login @property def title(self): return self.__title @property def description(self): return self.__description @property def created_date(self): return self.__created_date @property def merged_date(self): return self.__merged_date @property def integrator_login(self): return self.__integrator_login @property def files(self): return self.__files @pr_id.setter def pr_id(self, val): self.__pr_id = val @pull_number.setter def pull_number(self, val): self.__pull_number = val @requester_login.setter def requester_login(self, val): self.__requester_login = val @title.setter def title(self, val): self.__title = val @description.setter def description(self, val): self.__description = val @created_date.setter def created_date(self, val): self.__created_date = val @merged_date.setter def merged_date(self, val): self.__merged_date = val @integrator_login.setter def integrator_login(self, val): self.__integrator_login = val @files.setter def files(self, val): self.__files = val
# *** these filters do NOT see ping messages, nor do routers see them *** # *** global imports are NOT accessible, do imports in __init__ and bind them to an attribute *** class Filters(Base): def __init__(self, logger): # init parent class super().__init__(logger) # some imports needed later self.random = __import__("random") self.base64 = __import__("base64") self._thread = __import__("_thread") self.time = __import__("time") # some vars #self.master_killed = False self.started = 0 self.data_received = {} self.overlay_constructed = False self.mutation_logged = False def gui_command_incoming(self, command): global task pass def gui_command_completed(self, command, error): global task if command["_command"] == "start": if not error: pass #self.logger.info("*********** STARTED") else: pass #self.logger.info("*********** ERROR STARTING ROUTER: %s" % str(error)) def gui_event_outgoing(self, event): global task pass def router_command_incoming(self, command, router): global task if command["_command"] == "subscribe": self.started = self.time.time() if command["_command"] == "remove_connection" and task["name"] in ["test", "all_reconnects_on_packetloss"]: self.logger.error("*********** CODE_EVENT(remove_connection): reconnects += 1") def subscribed_datamsg_incoming(self, msg, router): global task pass def covert_msg_incoming(self, msg, con): global task if msg.get_type() == "Flooding_advertise" and not msg["reflood"] and task["name"] in ["flooding_suboptimal_paths"]: channel = msg["channel"] nonce = self.base64.b64decode(bytes(msg["nonce"], "ascii")) # decode nonce peer_id = con.get_peer_id() chain = (self.router._find_nonce(nonce, self.router.advertisement_routing_table[channel]) if channel in self.router.advertisement_routing_table else None) if chain: # new advertisements (chain == None) aren't relevant here sorting = self.router._compare_nonces(nonce, self.router.advertisement_routing_table[channel][chain].peekitem(0)[0]) if sorting != -1: return # received advertisement is longer than already known one publisher = self.router._canonize_active_path_identifier(channel, msg['nonce']) for subscriber in self.router._ActivePathsMixin__reverse_edges[channel]: if publisher in self.router._ActivePathsMixin__reverse_edges[channel][subscriber]: active_peer = self.router._ActivePathsMixin__reverse_edges[channel][subscriber][publisher]["peer"] if sorting == -1 and active_peer != peer_id: if self.router.node_id == subscriber: self.logger.error("*********** CODE_EVENT(shorter_nonce): shorter_subscribers += 1") else: self.logger.error("*********** CODE_EVENT(shorter_nonce): shorter_intermediates += 1") self.logger.info("*********** DEBUG_DATA: node_id=%s, subscriber=%s, msg=%s" % (self.router.node_id, subscriber, str(msg))) def covert_msg_outgoing(self, msg, con): global task # only check first advertisements if msg.get_type() == "Flooding_advertise" and not msg["reflood"] and task["name"] in ["flooding_master_count"]: channel = msg["channel"] nonce = self.base64.b64decode(bytes(msg["nonce"], "ascii")) # decode nonce peer_id = con.get_peer_id() chain = (self.router._find_nonce(nonce, self.router.advertisement_routing_table[channel]) if channel in self.router.advertisement_routing_table else None) shortest_nonce = self.router.advertisement_routing_table[channel][chain].peekitem(0)[0] if None in self.router.advertisement_routing_table[channel][chain][shortest_nonce] and not self.mutation_logged: self.logger.error("*********** CODE_EVENT(become_master): master_publishers += 1") self.logger.info("*********** DEBUG_DATA: node_id=%s" % self.router.node_id) self.mutation_logged = True def msg_incoming(self, msg, con): global task if task["name"] in [ "test", "flooding_overlay_construction", "aco_overlay_construction", "aco_overlay_construction_bandwidth", "flooding_overlay_construction_packetloss", "aco_overlay_construction_packetloss", "simple_overlay_construction", "simple_overlay_construction_packetloss", ]: if msg["channel"] in self.router.subscriptions and msg["id"] not in self.router.seen_data_ids: # only check subscriber perspective if msg["data"] not in self.data_received: self.data_received[msg["data"]] = 0 self.data_received[msg["data"]] += 1 self.logger.info("*********** DEBUG_DATA: data_received[%s] --> %s" % (str(msg["data"]), str(self.data_received[msg["data"]]))) if self.data_received[msg["data"]] == task["publishers"] and not self.overlay_constructed: self.logger.error("*********** CODE_EVENT(overlay_constructed): overlay_construction.append(%.3f)" % (self.time.time() - self.started)) self.logger.info("*********** DEBUG_DATA: node_id = %s" % self.router.node_id) #TODO: this should be used by the evaluator to stop evaluation earlier if possible self.logger.info("*********** MEASUREMENT_COMPLETED: %s" % self.router.node_id) self.overlay_constructed = True def msg_outgoing(self, msg, con): global task #if msg.get_type() == "Flooding_data": #if self.time.time() - self.started > 60 and "test" in self.router.master and self.router.master["test"] and not self.master_killed: #self.logger.info("*********** KILLING MASTER NODE: node_id=%s" % self.router.node_id) #self.master_killed = True #self._thread.interrupt_main() pass
# functions for creating model and selection of hyperparameters def objective_lgb(space, X, Y, cat_feats, NFALG_PRINT_HIST, NUM_FOLDS): #global iteration, best_auc_so_far, best_ntrees global iteration, best_auc_val_so_far, best_auc_val_std_so_far, best_ntrees, best_auc_train_so_far, best_auc_train_std_so_far iteration += 1 ### if NFALG_PRINT_HIST==False: print('Num step: {}'.format(iteration), end="\r") params = {'num_leaves': int(space['num_leaves']), 'min_data_in_leaf': int(space['min_data_in_leaf']), 'max_depth': int(space['max_depth']), 'bagging_freq': int(space['bagging_freq']), 'max_bin': int(space['max_bin']), 'learning_rate': space['learning_rate'], 'feature_fraction': space['feature_fraction'], 'bagging_fraction': space['bagging_fraction'], 'n_jobs': space['n_jobs'], 'objective': space['objective'], 'random_state': space['random_state'] } ds = lgb.Dataset(X, Y, categorical_feature=cat_feats) cv_res = lgb.cv(params, ds, metrics='auc', num_boost_round=1000, early_stopping_rounds=50, nfold=len(time_folds) if time_folds else NUM_FOLDS, folds=time_folds if time_folds else None, categorical_feature=cat_feats) auc_val = cv_res['auc-val-mean'][-1] #AUC for the last boosting of Validation sample auc_val_std = cv_res['auc-val-stdv'][-1] #AUC STD for the last boosting of Validation sample auc_train = cv_res['auc-train-mean'][-1] #AUC for the last boosting of Training Sample auc_train_std = cv_res['auc-train-stdv'][-1] #AUC STD for the last boosting of Training Sample # choosing best parameters based on a comparison between a new calculated and the last best if (((auc_val-2*auc_val_std)-0.5*abs((auc_train)-(auc_val))) > ((best_auc_val_so_far-best_auc_val_std_so_far)- 0.5*abs((best_auc_train_so_far)-(best_auc_val_so_far)))): best_auc_val_so_far = auc_val best_auc_val_std_so_far = auc_val_std best_ntrees = len(cv_res['auc-val-mean']) best_auc_train_so_far = auc_train best_auc_train_std_so_far = auc_train_std if NFALG_PRINT_HIST: print('iteration {}'.format(iteration)) print("---AUC SCORE (val):\t{} (std: {}) ({} (std: {}) best so far)".format(round(auc_val,6), round(auc_val_std,6), round(best_auc_val_so_far,6), round(best_auc_val_std_so_far,6))) print("---AUC SCORE (train):\t{} (std: {}) ({} (std: {}) best so far)".format(round(auc_train,6), round(auc_train_std,6), round(best_auc_train_so_far,6), round(best_auc_train_std_so_far,6))) print("---ntrees:\t{} ({} best so far)\n".format(len(cv_res['auc-val-mean']), best_ntrees)) return{'loss':1-((auc_val-auc_val_std)-0.5*abs((auc_train+auc_train_std)-(auc_val-auc_val_std))), 'status': STATUS_OK} def run_hyperopt_lgb(x_train, y_train, x_test, y_test, cat_feats, evals=10, NFALG_PRINT_HIST=True, NUM_FOLDS = 3): iteration = 0 params_space = {'num_leaves':[4, 12, 50, 100, 150, 200], 'min_data_in_leaf':[20, 50, 100, 250], 'max_depth':[2, 4, 6], # [2, 4, 6, 8, 10, 12, 14, 25] 'bagging_freq':[1, 2, 3, 5, 10], 'max_bin':[100, 255, 500], #'learning_rate':[0.01, 0.02, 0.03, 0.05, 0.1, 0.3, 0.5, 0.8, 1], 'learning_rate':[.01, .05, .1, .3, .5, .8], 'feature_fraction':[.25, .3, .5, .7], 'bagging_fraction':[.3, .5, .7], 'n_jobs': [8], 'objective': ['binary'], 'random_state': [123]} # Variable for a final choice of the parameters (inputs) of the algorithm LightGBM space = {'num_leaves' : hp.choice('num_leaves', params_space['num_leaves']), 'min_data_in_leaf' : hp.choice('min_data_in_leaf', params_space['min_data_in_leaf']), 'max_depth' : hp.choice('max_depth', params_space['max_depth']), 'bagging_freq' : hp.choice('bagging_freq', params_space['bagging_freq']), 'max_bin' : hp.choice('max_bin', params_space['max_bin']), 'learning_rate' : hp.choice('learning_rate', params_space['learning_rate']), 'feature_fraction' : hp.choice('feature_fraction', params_space['feature_fraction']), 'bagging_fraction' : hp.choice('bagging_fraction', params_space['bagging_fraction']), 'n_jobs' : hp.choice('n_jobs', params_space['n_jobs']), 'objective' : hp.choice('objective', params_space['objective']), 'random_state' : hp.choice('random_state', params_space['random_state'])} trials = Trials() # hyperOpt variable for choosing algorithm for best parameters finding # Running optimization for finding best parameters best_params = fmin(fn=partial(objective_lgb, X=x_train, Y=y_train, cat_feats=cat_feats, NFALG_PRINT_HIST=NFALG_PRINT_HIST, NUM_FOLDS=NUM_FOLDS),#objective space=space, algo=tpe.suggest, # Algorithm of finding optimal parameters. Please check how it works max_evals=evals, # number of iterations trials=trials) # object for Hyper Optimization print("--Best params metrics AUC SCORE:{} (std: {}) ntrees: {}".format(round(best_auc_val_so_far,6), round(best_auc_val_std_so_far,6), best_ntrees)) for k in params_space.keys(): # востанавливает лучшие значения по их индексам best_params[k] = params_space[k][best_params[k]] # best params in a different format train = lgb.Dataset(x_train, y_train, categorical_feature=cat_feats) # categorical_feature test = lgb.Dataset(x_test, y_test, categorical_feature=cat_feats) booster = lgb.train(best_params, # calling the algorithm itself train_set=train, valid_sets=[train, test], num_boost_round=best_ntrees, categorical_feature=cat_feats, verbose_eval=True) return booster, best_params # the first model cat_feat = get_cat_feats(X_train, ids=True) iteration=0 best_auc_val_so_far=0 best_auc_val_std_so_far=0 best_auc_train_so_far=0 best_auc_train_std_so_far=0 time_folds=False booster,best_params=run_hyperopt_lgb(X_train, Y_train, X_val, Y_val, cat_feat, evals=5)
class HwndSourceParameters(object): """ Contains the parameters that are used to create an System.Windows.Interop.HwndSource object using the System.Windows.Interop.HwndSource.#ctor(System.Windows.Interop.HwndSourceParameters) constructor. HwndSourceParameters(name: str) HwndSourceParameters(name: str,width: int,height: int) """ def Equals(self,obj): """ Equals(self: HwndSourceParameters,obj: HwndSourceParameters) -> bool Determines whether this structure is equal to a specified System.Windows.Interop.HwndSourceParameters structure. obj: The structure to be tested for equality. Returns: true if the structures are equal; otherwise,false. Equals(self: HwndSourceParameters,obj: object) -> bool Determines whether this structure is equal to a specified object. obj: The objects to be tested for equality. Returns: true if the comparison is equal; otherwise,false. """ pass def GetHashCode(self): """ GetHashCode(self: HwndSourceParameters) -> int Returns the hash code for this System.Windows.Interop.HwndSourceParameters instance. Returns: A 32-bit signed integer hash code. """ pass def SetPosition(self,x,y): """ SetPosition(self: HwndSourceParameters,x: int,y: int) Sets the values that are used for the screen position of the window for the System.Windows.Interop.HwndSource. x: The position of the left edge of the window. y: The position of the upper edge of the window. """ pass def SetSize(self,width,height): """ SetSize(self: HwndSourceParameters,width: int,height: int) Sets the values that are used for the window size of the System.Windows.Interop.HwndSource. width: The width of the window,in device pixels. height: The height of the window,in device pixels. """ pass def __eq__(self,*args): """ x.__eq__(y) <==> x==y """ pass @staticmethod def __new__(self,name,width=None,height=None): """ __new__[HwndSourceParameters]() -> HwndSourceParameters __new__(cls: type,name: str) __new__(cls: type,name: str,width: int,height: int) """ pass def __ne__(self,*args): pass AcquireHwndFocusInMenuMode=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets or sets the value that determines whether to acquire Win32 focus for the WPF containing window when an System.Windows.Interop.HwndSource is created. Get: AcquireHwndFocusInMenuMode(self: HwndSourceParameters) -> bool Set: AcquireHwndFocusInMenuMode(self: HwndSourceParameters)=value """ AdjustSizingForNonClientArea=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets or sets a value that indicates whether to include the nonclient area for sizing. Get: AdjustSizingForNonClientArea(self: HwndSourceParameters) -> bool Set: AdjustSizingForNonClientArea(self: HwndSourceParameters)=value """ ExtendedWindowStyle=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets or sets the extended Microsoft Windows styles for the window. Get: ExtendedWindowStyle(self: HwndSourceParameters) -> int Set: ExtendedWindowStyle(self: HwndSourceParameters)=value """ HasAssignedSize=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets a value that indicates whether a size was assigned. Get: HasAssignedSize(self: HwndSourceParameters) -> bool """ Height=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets or sets a value that indicates the height of the window. Get: Height(self: HwndSourceParameters) -> int Set: Height(self: HwndSourceParameters)=value """ HwndSourceHook=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets or sets the message hook for the window. Get: HwndSourceHook(self: HwndSourceParameters) -> HwndSourceHook Set: HwndSourceHook(self: HwndSourceParameters)=value """ ParentWindow=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets or sets the window handle (HWND) of the parent for the created window. Get: ParentWindow(self: HwndSourceParameters) -> IntPtr Set: ParentWindow(self: HwndSourceParameters)=value """ PositionX=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets or sets the left-edge position of the window. Get: PositionX(self: HwndSourceParameters) -> int Set: PositionX(self: HwndSourceParameters)=value """ PositionY=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets or sets the upper-edge position of the window. Get: PositionY(self: HwndSourceParameters) -> int Set: PositionY(self: HwndSourceParameters)=value """ RestoreFocusMode=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets or sets how WPF handles restoring focus to the window. Get: RestoreFocusMode(self: HwndSourceParameters) -> RestoreFocusMode Set: RestoreFocusMode(self: HwndSourceParameters)=value """ TreatAncestorsAsNonClientArea=property(lambda self: object(),lambda self,v: None,lambda self: None) """Get: TreatAncestorsAsNonClientArea(self: HwndSourceParameters) -> bool Set: TreatAncestorsAsNonClientArea(self: HwndSourceParameters)=value """ TreatAsInputRoot=property(lambda self: object(),lambda self,v: None,lambda self: None) """Get: TreatAsInputRoot(self: HwndSourceParameters) -> bool Set: TreatAsInputRoot(self: HwndSourceParameters)=value """ UsesPerPixelOpacity=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets a value that declares whether the per-pixel opacity of the source window content is respected. Get: UsesPerPixelOpacity(self: HwndSourceParameters) -> bool Set: UsesPerPixelOpacity(self: HwndSourceParameters)=value """ UsesPerPixelTransparency=property(lambda self: object(),lambda self,v: None,lambda self: None) """Get: UsesPerPixelTransparency(self: HwndSourceParameters) -> bool Set: UsesPerPixelTransparency(self: HwndSourceParameters)=value """ Width=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets or sets a value that indicates the width of the window. Get: Width(self: HwndSourceParameters) -> int Set: Width(self: HwndSourceParameters)=value """ WindowClassStyle=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets or sets the Microsoft Windows class style for the window. Get: WindowClassStyle(self: HwndSourceParameters) -> int Set: WindowClassStyle(self: HwndSourceParameters)=value """ WindowName=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets or sets the name of the window. Get: WindowName(self: HwndSourceParameters) -> str Set: WindowName(self: HwndSourceParameters)=value """ WindowStyle=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets or sets the style for the window. Get: WindowStyle(self: HwndSourceParameters) -> int Set: WindowStyle(self: HwndSourceParameters)=value """
#----------------------------------------------------------------------------- # Copyright (c) 2013, PyInstaller Development Team. # # Distributed under the terms of the GNU General Public License with exception # for distributing bootloader. # # The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- """ Python module 'pydoc' causes the inclusion of Tcl/Tk library even in case of simple hello_world script. Most of the we do not want this behavior. This hook just removes this implicit dependency on Tcl/Tk. """ def hook(mod): # Ignore 'Tkinter' to prevent inclusion of Tcl/Tk library. for i, m in enumerate(mod.pyinstaller_imports): if m[0] == 'Tkinter': del mod.pyinstaller_imports[i] break return mod
number = input("Enter a series of number, using separator you like: ") separator = "" for char in number: if not char.isnumeric(): separator = separator + char print(separator) str = 0; sum = 0 for char in number: if char not in separator: str = str * 10 + int(char) if char == number[len(number)-1]: sum = sum + int(char) elif char in separator: sum = sum + str str = 0 print(sum)
{ "includes": [ "../common.gypi" ], "targets": [ { "target_name": "libgdal_ogr_pgdump_frmt", "type": "static_library", "sources": [ "../gdal/ogr/ogrsf_frmts/pgdump/ogrpgdumplayer.cpp", "../gdal/ogr/ogrsf_frmts/pgdump/ogrpgdumpdatasource.cpp", "../gdal/ogr/ogrsf_frmts/pgdump/ogrpgdumpdriver.cpp" ], "include_dirs": [ "../gdal/ogr/ogrsf_frmts/pgdump" ] } ] }
class Human(object): def __init__(self, mark, io): self.mark = mark self.io = io def sanitize_user_input(self, user_input): try: sanitized_input = int(user_input) except TypeError: sanitized_input = 0 except ValueError: sanitized_input = 0 return sanitized_input def get_sanitized_input(self): user_input = self.io.get_input() return self.sanitize_user_input(user_input) def is_move_valid(self, move, board): return isinstance(move, int) and board.is_spot_available(move) def get_move(self, presenter, board): while 1: presenter.move_prompt(self.mark) presenter.available_moves_message(board.available_spots()) chosen_move = self.get_sanitized_input() if self.is_move_valid(chosen_move, board): return chosen_move presenter.invalid_move_message()
def razbi_stevilo(n, st): s = [] st = str(st) while len(st) > n: stevilo = st[:n] s.append(stevilo) st = st[1:] return s #seznam 13 mestnih steil podanih v nizu def razbi_stevke(n): sez_stevk = [] for stevka in n: sez_stevk.append(int(stevka)) sez_stevk.sort() return sez_stevk def max_zmnozek(n, st): s = razbi_stevilo(n, st) sez_stevil = [] for ste in s: sez_stevil.append(razbi_stevke(ste)) maxi = max(sez_stevil) zmnozek = 1 for stevka in maxi: zmnozek *= stevka return zmnozek st = 7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450
class Solution: def longestMountain(self, A: List[int]) -> int: ''' T: O(n) and S: O(1) ''' if len(A) < 3: return 0 maxLen = 0 for i in range(1, len(A)-1): left, right = i - 1, i + 1 if (A[left] < A[i]) and (A[i] > A[right]): while left > 0 and A[left-1] < A[left]: left -= 1 while right < len(A)-1 and A[right] > A[right+1]: right += 1 maxLen = max(maxLen, right - left + 1) return maxLen
# Loan repayment calculation service # This is the program calculating the loan repayment amount for clients. # # Input parameters: # principal(p) : Only integers equal or greater than one million are allowed # years(y) : Only integers equal or greater than one are allowed # annual interest rate(r) : Only floating point numbers from 0.0 to 100.0 are allowed # Output parameters: # annual repayment amount(d), monthly repayment amount(d / 12), total repayment amount(d * y) # # Developers : Hacktree # Development date : 2021/06/16 (Version 1.0) # Input and check input value print("Welcome to loan repayment calculation service") p = int(input("How much is the principal? (We only count over one million won.) ")) y = int(input("How many years is the repayment period? ")) r = float(input("What percent is the interest rate? ")) # Calcualte repayment amount d = ((1 + (r / 100)) ** y * p * (r / 100)) // ((1 + (r / 100)) ** y - 1) d = int(d) # Print Output print("We will inform you about the loan repayment details.") print("If you repay once a year, you have to pay {} won for each year.".format(d)) print("If you repay once a month, you have to pay {} won for each month.".format(d // 12)) print("The total repayment amount until the repayment is completed is {} won.".format(d * y)) print("Thank you for using our service.") print("I hope you to see again.")
# -*- coding: utf-8 -*- # .-. .-. .-. . . .-. .-. .-. .-. # |( |- |.| | | |- `-. | `-. # ' ' `-' `-`.`-' `-' `-' ' `-' __title__ = 'requests2' __description__ = 'Python HTTP for Humans.' __url__ = 'http://python-requests.org' __version__ = '2.16.0' __build__ = 0x021600 __author__ = 'Kenneth Reitz' __author_email__ = 'me@kennethreitz.org' __license__ = 'Apache 2.0' __copyright__ = 'Copyright 2017 Kenneth Reitz' __cake__ = u'✨ 🍰 ✨'
# -*- coding: utf-8 -*- """ Created on Wed Aug 26 12:58:44 2020 @author: SELICLO1 """ def HammingDistance(a,b): mm = 0 for i,s in enumerate(a): if s != b[i]: mm+= 1 return mm a = 'GTCTGGGCCGTGCGGACTTGTTGCGGATGATACAAGGGCTTCACTACGTCGAAGTAAGTTACCAATTATACAAGCTACCGGTGTAGAATGGTGAGTAGGTCCGCTTATAGCCCGCGCGGTGTACCTCGAGATAGATTGGGGTCAACCCAGTCCGACCCCACGCTACATGGTCATCCTATGTTGGACTGTTACCCCGACCAGTCCACACATCTACGTACTAACGAGCGACGTCGTCTAAGAGCTCATTTTAGACCTTTTGAGATGAAAGATACAAGTCAAACCGTGCGTTAGGCTGGCCCAACGCAAGTTTACAGATAGCGTTCTGGGGCACGTTTAATCGCTATGATTTAGTAGCACATAAGGAGCTGAAACGTTTATCGGCATTGGGGAGAGTAATCCGGAAGGGCTCATTCTCCCACGTTGTCCAATTACACACTGCTGTTCGATACTTGGCGCTCGGACTCACCGATAGCGCTGGCCCTGGTCGCCCCTAACACGTAACGGTTCTGGAGAATTGATCCGAACAACAGATAAGAAAGCTGATGAAGAAGTAACGGACGTAAACAGGACTGGTCGAGCAACACCCCTAGCTAGGGAAAGAGATAAAACGGGAATGCAGTTTTAATTTTCAGAATTATCTGGAATGCGCAAGCATTTTTTCGTTGGGGCCATGCGAGGCGAAGCAAATGTGTGAGAAAATTGCGGAGGTACGATACCATGGGAGTCTTGTGTTTTAGTCCGATGTCGCCCCTCACCCGCAAGAACGAGCACGGAACACTCTATCCCGAGGACTACTATGGCGAGAGCTCAATAACAGCACTGCTCTCCACAACGGCGCCTAGTGATCGTGAATCCCCCATTTCTGCCAATAGTAATATTCACCAGGGTATCCAATGCAACGTCTCATTAATGAAATATTTAGTGCGGTTGGCAAAAATCCCCGCTGAAAAGAGGTTTTACGTTGTAGAACTAGAATGTTCGTGGTTCGTTGCGACTTTTAACCTAAGCTGGTCGGTGGGCTTGAGACTAGCATGTTGCCCTCCTCGGGGCAGGGCGCGACAAACCATTGGTGTGAGGACACCAGCCAGACACGACAAATCGTCACGGCGCGCAT' b = 'TTTGTGGATCCCCCTTAATGCAGCCACAAAGCAGCACCCACGAGTATGCAGTGCTTAAGGGGTTTCGATCTTACGATCCCTGCCTAACACACGGTAGCTTGTTATGGCCGGGCTGTACTTAAACGTTACACTCCGAACCCCAATGGGGTTAAGCGTCGAACAGGAGTACAGTGTATCATATTCGACTATGTCCACGTGAGATCGTAACCGTCCGAAAACCGGCAGTAGAAGGGCAGCTAACAGGTATCTTGCACCAGCTTACCTATCTTTTAGTGGCGGGCCATCAGGAGGCCAGTCCCGCGTCCCTACACGCCCGGAGTGTAGAGTAGGGTACGGGCTCGTCTGGTGCGAAAAAGACCGCAGCCTACATAAGCTCGCACAACATAGTCGATGCCTCAAAGCAAGGGCGTCACGAACCTACCCTCTGCTATATTACGGACCTGGTACAATCTAGCAGATTTATAAAGACTACCAAGCTAAACTCACCGTTTACCGCTGTCCCACTGAATTCGGAGTCTCTATGTGCAACCGCAGGTCATGTACACACATTGTACACCTTAGCGGAAGCCTGGAGTTGCTTATCAAGGGCATCCAGGGATAAAGGACGCAAGCTACAAAAAACAATTTTCTCCCAGTACCCTCTTCACAAATTGCAACTGTTCCTGTCAAACTCCCTCTGCAACGGCCGGGCTTTACCTTTAGACTAAACAACTACGAGTGTTGGTATCCTAGGGGTGTGCTAACAACTACACCATAGTAGGGGCCTAATATATTCGATGCGCTAGCGTTGGTGCACATTCGTTGCAGTGCGTTTAAGCCGTGTCACCATTGATATCCGCCACTGGTGTCCCGGATGGCGCCGCTCGTCGGATAACACGGTTGGCGGAGCATGCTATGGATAGGAGAGTCACTGATGACGGGGTTGATCCAAGACGCATCTGGGGCATCCAAGACTGGCTCAGTTAACAGAACCCAGTTTTGCATTTCGAGGGCATAGGGGGGGTGTTTAAGTGTTCAAATCCGGTCCTAACCTGCCCGGCGACGCCCGCGGTTACGTTTAGATACTGGGCTAAGGTGTAGGCACTTGGCGGGAATCGTTCGCTTTGGATAATGC' hd = HammingDistance(a,b) print(hd)
a = int(input("Enter the first no : ")) b = int(input("Enter the second no : ")) c = a+b print("sum of",a,'+',b,'=',c) print("The first no is: %d and second number is: %d and the sum is: %d"%(a,b,c)) print("%d + %d = %d"%(a,b,c)) print("%-10d + %-10d = %-10d"%(a,b,c)) print("%-10f + %-10f = %-10f"%(a,b,c)) print("%s + %s = %s"%("tony","george","tonygeorge"))
class Node(object): def __init__(self, data, next=None): self.data = data self.next = next def kth_to_last(k, linked_list): pointer1, pointer2 = linked_list, linked_list for _ in range(k): if not pointer1: return None pointer1 = pointer1.next while pointer1: pointer1, pointer2 = pointer1.next, pointer2.next return pointer2 def kth_to_last2(k, linked_list): ll_length = 0 head = linked_list while head: ll_length += 1 head = head.next final_head = linked_list while final_head.next and k != ll_length: final_head = final_head.next ll_length -= 1 return final_head ll = Node(1, Node(2, Node(3, Node(4, None)))) k = 3 newll = kth_to_last2(k, ll) print(newll.data) print(newll.next.data) print(newll.next.next.data)
print("-- Strings -- ") print() mystring = "hello" myfloat = 10.0 myint = 20 if mystring == "hello": print("String: %s" % mystring) if isinstance(myfloat, float) and myfloat == 10.0: print("Float: %f" % myfloat) if isinstance(myint, int) and myint == 20: print("Integer: %d" % myint) print() nome = 'Teste' idade = 18 print('Nome: {a}, Idade: {b}'.format(a=nome, b=idade)) def print_full_name(a, b): print('Hello {a} {b}! You just delved into python.'.format(a=a, b=b)) print_full_name('Ross', 'Taylor') a = "this is a string" a = a.split(" ") # a is converted to a list of strings. print(a) string = '' for item in a: if len(string) > 0: string = string +"-"+ item else: string = string + item print(string)
def General(project): feature_vectors = get_featrures(projects) h_clusters = BIRCH(projects,feature_vectors) for level in h_clusters.levels: if level.depth == h_clusters.max_depth: for cluster in level.clusters: level.cluster.bell = bellwether(cluster.projects) else: for cluster in h_clusters.level.clusters: bell_projects = cluster.child.get_bellwethers() level.cluster.bell = bellwether(bell_projects) return h_clusters
""" LC89. Gray Code The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0. Example 1: Input: 2 Output: [0,1,3,2] Explanation: 00 - 0 01 - 1 11 - 3 10 - 2 For a given n, a gray code sequence may not be uniquely defined. For example, [0,2,3,1] is also a valid gray code sequence. 00 - 0 10 - 2 11 - 3 01 - 1 Example 2: Input: 0 Output: [0] Explanation: We define the gray code sequence to begin with 0. A gray code sequence of n has size = 2n, which for n = 0 the size is 20 = 1. Therefore, for n = 0 the gray code sequence is [0]. """ # Runtime: 40 ms, faster than 22.57% of Python3 online submissions for Gray Code. # Memory Usage: 14.7 MB, less than 5.26% of Python3 online submissions for Gray Code. class Solution: def grayCode(self, n: int) -> List[int]: if n == 0: return [0] res = {} curr = "0" * n self.dfs(res, curr, n, 0) return [int(key, 2) for key,_ in sorted(res.items(), key=lambda x:x[1])] def dfs(self, res, curr, n, index): res[curr] = index for i in range(n): if curr[i] == "0": tmp = curr[:i] + "1" + curr[i+1:] else: tmp = curr[:i] + "0" + curr[i+1:] if tmp in res: continue self.dfs(res, tmp, n, index+1) break
# Sudoku Solver: https://leetcode.com/problems/sudoku-solver/ # Write a program to solve a Sudoku puzzle by filling the empty cells. # A sudoku solution must satisfy all of the following rules: # Each of the digits 1-9 must occur exactly once in each row. # Each of the digits 1-9 must occur exactly once in each column. # Each of the digits 1-9 must occur exactly once in each of the 9 3x3 sub-boxes of the grid. # The '.' character indicates empty cells. # This boils down from a really hard problem into a simple backtracking dfs solution # basically what we need to do is create a set for rows, cols and the grid boxes # once we have all those sets we move across from 0,0 -> 8,8 and if there is an empty box # try and fill it with a value that is not in any of the three sets class Solution: def solveSudoku(self, board) -> None: """ Do not return anything, modify board in-place instead. """ # For checking we need to check if value is not in r, c or sqr def canAddVal(value, r, c): return value not in row[r] and value not in col[c] and value not in sqr[sqrIndex(r, c)] # So for adding we need to add the number to the set # and then to the board def addToBoard(value, r, c): board[r][c] = str(value) row[r].add(value) col[c].add(value) sqr[sqrIndex(r, c)].add(value) # Remove is the same as above but the opposite def remFromBoard(value, r, c): board[r][c] = '.' row[r].remove(value) col[c].remove(value) sqr[sqrIndex(r, c)].remove(value) def nextLocation(r, c): # Check if we are at the final location because if we are we simply need to return if r == N - 1 and c == N - 1: self.isSolved = True return else: # If we are here we need to move across col unless we are at edge if c == N - 1: backtrack(r+1) else: backtrack(r, c + 1) def backtrack(r=0, c=0): # For this solution we need try adding a number recursing down until it fails # then removing the number if it gets back if board[r][c] != '.': # This r,c already has a number so we skip over it nextLocation(r, c) else: # Otherwise try all possible numbers for val in range(1, 10): if canAddVal(val, r, c): addToBoard(val, r, c) nextLocation(r, c) # If we get to the end we just need to return if self.isSolved: return # Otherwise backtrack by removing the added num remFromBoard(val, r, c) # Set up the basic stuff we now n = 3 N = n * n # Create sets for row col and the sqr (aka grid box) row = [set() for _ in range(N)] col = [set() for _ in range(N)] sqr = [set() for _ in range(N)] # Create a lambda to convert the r,c pair into a index of sqr for our set def sqrIndex(r, c): return (r // n * n) + (c // n) # Create a way to trigger the end if we are at the last spot self.isSolved = False # Loop through the whole entire grid and add numbers to our sets for r in range(N): for c in range(N): if board[r][c] != '.': addToBoard(int(board[r][c]), r, c) backtrack() return board # The above works out and runs in a horrible O(9!) which reduces to o(1) and uses o(!) space as well # Score Card # Did I need hints? N # Did you finish within 30 min? 25 # Was the solution optimal? This is optimal # Were there any bugs? No # 5 5 5 5 = 5
abi = """[ { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "_hashSender", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "_hashId", "type": "uint256" }, { "indexed": false, "internalType": "string", "name": "_hashContent", "type": "string" }, { "indexed": false, "internalType": "uint256", "name": "timestamp", "type": "uint256" } ], "name": "NewHashStored", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "_previousOwner", "type": "address" }, { "indexed": true, "internalType": "address", "name": "_newOwner", "type": "address" } ], "name": "OwnershipTransferred", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "_hashSender", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } ], "name": "Withdrawn", "type": "event" }, { "inputs": [ { "internalType": "uint256", "name": "_price", "type": "uint256" } ], "name": "StoreHash", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "_hashId", "type": "uint256" } ], "name": "find", "outputs": [ { "internalType": "address", "name": "hashSender", "type": "address" }, { "internalType": "string", "name": "hashContent", "type": "string" }, { "internalType": "string", "name": "_lastHashContent", "type": "string" }, { "internalType": "uint256", "name": "hashTimestamp", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "name": "hashes", "outputs": [ { "internalType": "address", "name": "sender", "type": "address" }, { "internalType": "string", "name": "content", "type": "string" }, { "internalType": "uint256", "name": "timestamp", "type": "uint256" }, { "internalType": "string", "name": "old", "type": "string" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "lastHashId", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "owner", "outputs": [ { "internalType": "address", "name": "", "type": "address" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "price", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "string", "name": "_hashContent", "type": "string" }, { "internalType": "string", "name": "_lastHashContent", "type": "string" } ], "name": "save", "outputs": [], "stateMutability": "payable", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "_newOwner", "type": "address" } ], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" } ]"""
# import contact: click on chart to draw a contact that gets pinged by sonar colors = {'GRN':color(51, 255, 0), 'RED':color(193, 49, 36), 'BLK':color(10)} def setup(): size(480, 480) background(colors['BLK']) fill(colors['RED']) ellipse(240, 240, 430, 430) fill(10) ellipse(240, 240, 420, 420) def draw(): stroke(colors['GRN']) if mousePressed: fill(colors['GRN']) ellipse(mouseX, mouseY, 10, 10)
def debug_policy_plot(): qq_right = [] x_vec = np.arange(vagent.max_q[0]) for xx in x_vec: vagent.q[0] = xx vsensor.update(vscene,vagent) vobservation = local_observer(vsensor,vagent) #todo: generalize qq_right.append(RL.compute_q_eval(vobservation.reshape([1,-1]))) qq_right = (np.reshape(qq_right,[-1,2])) vax[0].clear() vax[0].plot(qq_right, 'x-') vax[1].clear() vax[1].plot(qq_right[:,1]-qq_right[:,0], 'x-')
class Solution: def stringShift(self, s: str, shift: List[List[int]]) -> str: sum = 0 for i in shift: if i[0] == 0: sum += i[1] else: sum -= i[1] sum = sum % len(s) return s[sum:]+s[:sum]
# Copyright © 2014 Bart Massey # [This program is licensed under the "MIT License"] # Please see the file COPYING in the source # distribution of this software for license terms. # The += operator on lists appends the a copy of the # right-hand operand to the left-hand operand. This # makes z += y different from z = z + y. # First, note that the append operator makes a (shallow) # copy of both lists. x = [[1]] y = [[2]] z = x + y print(z) # Prints [[1], [2]] x[0][0] = 3 y[0][0] = 4 print(z) # Prints [[3], [4]] x[0] = 3 y[0] = 4 print(z) # Prints [[3], [4]] print() # Now, note that append assignment operator makes a copy of # just the right list. x = [1] z = x y = [2] z += y print(z) # Prints [1, 2] x[0] = 3 print(z) # Prints [3, 2] y[0] = 3 print(z) # Prints [3, 2] print() # The identity z = z + y === z += y does not hold. x = [1] z = x y = [2] z = z + y print(z) # Prints [1, 2] x[0] = 3 print(z) # Prints [1, 2] y[0] = 3 print(z) # Prints [1, 2]
""" netparse.table This module provides the necessary abstraction to take a TABLE pattern output and generate an accurate datastructure based off it. For further reading, please check out this article: https://pyability.com/the-curse-of-the-cli/ """ class ParseTable: def __init__(self, unstructured_data, pattern): self.unstructured_data = unstructured_data self.pattern = pattern self.data_range = self._populate_data_range() self.row_data = self._populate_row_data() def _populate_data_range(self): """ parsetable._populate_data_range Initializes the data range attribute which determines the size of each column in the TABLE """ # Define the range of each data attribute data_range = {} # Populate the first level in the structured datastructure for header, header_data in self.pattern.value_set.items(): header_location = header_data['header_location'] data_range[header] = { 'start': header_location, 'stop': header_location + len(header) - 1, } return data_range def _populate_row_data(self): """ parsetable._populate_row_data Initializes the row data variable with row header information. Also, this finishes up the full data range population as this method analyzes all the values in the unstructured dataset """ # Define row data row_data = {} # Define the first header at which all rows will begin pivot_header = '' pivot_location = 100000 # Start iteration of the unstuctured dataset for line_num, line in enumerate(self.unstructured_data): # Analyze each word in the unstructured dataset for word in line.split(): # Start iteration of the value set from the TABLE PATTERN for header, header_data in self.pattern.value_set.items(): # Initialize header location and alignment parameters header_location = header_data['header_location'] header_alignment = header_data['header_alignment'] # Check alignment as right aligned if header_alignment == 'right_align': # The following sets the value of the word's end location # as the same as the end location for the header as # it is right aligned value_length = line.find(word) + len(word) - 1 header_length = header_location + len(header) - 1 # If they do match, then the word is indeed under # the correct right aligned column set if value_length == header_length: start = line.find(word) # Adjust the right aligned column's start position # as necessary in case the word's length is longer # than the previous values if start < self.data_range[header]['start']: self.data_range[header]['start'] = start # Check alignment as left aligned elif header_alignment == 'left_align': # The following sets the value of the word's start location # as the same as the start location for the header as # it is left aligned value_length = line.find(word) header_length = header_location # If they do match, then the word is indeed under # the correct left aligned column set if value_length == header_length: stop = value_length + len(word) - 1 # Adjust the left aligned column's stop position # as necessary in case the word's length is longer # than the previous values if stop > self.data_range[header]['stop']: self.data_range[header]['stop'] = stop # Sets up the pivot header which is the first header # in the dataset with the lowest character location # as this will determine the row values if header_location < pivot_location: pivot_header = header pivot_location = header_location # If the word is equivalent to the pivot location, # then it is fair to set that up as the second level # for the structured dataset with... # COLUMN = HEADERS, ROWS = FIRST COLUMN DATA if line.find(word) == pivot_location: # Skip entry if it matches header if word == pivot_header: continue # Otherwise, add the row header data to the dictionary if (line_num+1) not in row_data: row_data[line_num+1] = word return row_data def generate_structure(self): """ parsetable.generate_structure Based on the information gleaned from the pattern tuple, generate structured data! """ # Define final datastructure structured_data = [] # Define pattern length pattern_length = sum(1 for _ in iter(self.pattern.value_set.items())) - 1 # Iterate through the unstructured data for line_num, line in enumerate(self.unstructured_data): # Temporary structure json_structure = {} # Skip any headers that do not have a row header if (line_num+1) not in self.row_data: continue # Define row header row_header = self.row_data[line_num+1] # Start iteration of the value set from the TABLE PATTERN for i, (c_header, c_header_data) in enumerate(self.pattern.value_set.items()): # Initialize the previous and future header datasets p_header, p_header_data, f_header, f_header_data = '', '', '', '' # Initialize the start and stop parameters start, stop = '', '' # Fill in previous header data if applicable if i != 0: p_header, p_header_data = list(self.pattern.value_set.items())[i-1] # Fill in future header data if applicable if i != pattern_length: f_header, f_header_data = list(self.pattern.value_set.items())[i+1] # Initialize current header data c_header_alignment = c_header_data['header_alignment'] # Initialize the data range values for each header start = self.data_range[c_header] stop = self.data_range[c_header] # Define the correct start and stop conditions if c_header_alignment == 'left_align': start = self.data_range[c_header]['start'] if f_header: stop = self.data_range[f_header]['start'] - 1 else: stop = len(line) # Define the correct start and stop conditions elif c_header_alignment == 'right_align': stop = self.data_range[c_header]['stop'] + 1 if p_header: start = self.data_range[p_header]['stop'] + 1 else: start = 0 json_structure[c_header] = line[start:stop].strip() structured_data.append(json_structure) return structured_data
# Based on MicroPython config option, comparison of str and bytes # or vice versa may issue a runtime warning. On CPython, if run as # "python3 -b", only comparison of str to bytes issues a warning, # not the other way around (while exactly comparison of bytes to # str would be the most common error, as in sock.recv(3) == "GET"). # Update: the issue above with CPython apparently happens in REPL, # when run as a script, both lines issue a warning. if ("123" == b"123" or b"123" == "123"): print("FAIL") raise SystemExit print("PASS")
class Solution: def toGoatLatin(self, S: str) -> str: words = S.split() res = [] for i, w in enumerate(words): if w[0].lower() not in "aeiou": w = w[1:] + w[0] w += "ma" + ("a" * (i + 1)) res.append(w) return ' '.join(res) if __name__ == '__main__': S = input("Input: ") print(f"Output: {Solution().toGoatLatin(S)}")
# the interface # class, or the interface # data type # interface data types # are inspired from # the typescript language # example # f = Interface(types) # f.create(data) class InterfaceObject(): def __init__(self, object_info): # the passed in values # to create a new object self.values = object_info # get the interface # property def get_item(self, property_): if property_ in self.values: return self.values[property_] else: raise KeyError(f"Cannot find {property_}") # set the interface # property # Note : cannot change types after assignment def set_item(self, property_, value): # check if property_ is in self.values # if yes, pass # else throw a KeyError if property_ in self.values: # check whether the current type # of the key and the new type is same # if yes , change the value # else , raise a KeyError typeof = isinstance(value, type(self.values[property_])) if typeof: self.values[property_] = value else: raise TypeError("Cannot change types after assignment") else: raise KeyError(f"Cannot find {property_}") def __repr__(self): return "" class Interface(object): def __init__(self, data_params): # the main # key names and the # type of the value self.params = self.__get_params(data_params) # verifying the entered # parameters and return # them def __get_params(self, data): # check whether the data # passed in is a dict # else throw an Error data_is_dict = isinstance(data, dict) # loop through each dict # value and check whether # each value is # a list # the list of types it can be # return the passed-in parameter if data_is_dict: for data_key in data: if not isinstance(data[data_key], list): raise TypeError("Expected to be a list") return data else: raise TypeError("Expected a dict") # create a new interface # object def create(self, *args): # self.match = self.__match_param_types(data) # print(args) if len(args) == len(self.params): match = self.__match_param_types(args) return InterfaceObject(match) else: raise Exception( f"Expected {len(self.params)} arguments but got {len(args)}") # check whether # the new create interface # parameter type match # with self.params def __match_param_types(self, data): # check if the passed in # parameter is a # tuple, else throw # a TYpeError if isinstance(data, tuple): # the new interface interface = {} # loop through each element # and index in the dictionary # (self.params) for index, key in enumerate(self.params): # the current character # of the argument current_character = data[index] # the number of types # matches(a list of # True and False(booleans)) types_matches = [] for allowed_type in self.params[key]: # if the allowed types # is (?) or 'any', append true # as it resembles (any) type # else, if the type of # the param is in # the list of types # allowed if allowed_type == "?" or allowed_type == "any": types_matches.append(True) else: types_matches.append(allowed_type == type(data[index])) # if the list is full of False # or if no types match raise # a type error # else, add it to the # interface dict if True not in types_matches: raise TypeError("Types don't match") else: interface[key] = data[index] # return the interface dict return interface else: raise TypeError("Expected a dict")
""" Standard disk mounted on a CIM_ComputerSystem. """ def EntityOntology(): return (["Name"],)
def rotflip(): yield "rot1" yield "rot2" yield "rot3" yield "rot4" yield "flip" yield "rot1" yield "rot2" yield "rot3" yield "rot4" raise ValueError("aaaaa") i = 0 #for i,a in enumerate(rotflip()): a_gen = rotflip() while True: a = a_gen.__next__() print(a) i += 1 if i == 6: break
marks = {} for _ in range(int(input())): line = input().split() marks[line[0]] = sum(map(float, line[1:])) / 3 print('%.2f' % marks[input()])
""" Count the number of ways to tile the floor of size n x m using 1 x m size tiles Given a floor of size n x m and tiles of size 1 x m. The problem is to count the number of ways to tile the given floor using 1 x m tiles. A tile can either be placed horizontally or vertically. Both n and m are positive integers and 2 < = m. Examples: Input : n = 2, m = 3 Output : 1 Only one combination to place two tiles of size 1 x 3 horizontally on the floor of size 2 x 3. Input : n = 4, m = 4 Output : 2 1st combination: All tiles are placed horizontally 2nd combination: All tiles are placed vertically. """ """ This problem is mainly a more generalized approach to the Tiling Problem. Approach: For a given value of n and m, the number of ways to tile the floor can be obtained from the following relation. | 1, 1 < = n < m count(n) = | 2, n = m | count(n-1) + count(n-m), m < n """ def tiling(n,m): count=[] for i in range(n+2): count.append(0) count[0]=0 for i in range(1,n+1): # recurssive cases if i > m: count[i]=count[i-1]+count[i-m] #base cases elif i <m: count[i]=1 # i == m else: count[i]=2 return count[n] # print(tiling(7,4)) """ Count number of ways to fill a “n x 4” grid using “1 x 4” tiles Given a number n, count number of ways to fill a n x 4 grid using 1 x 4 tiles Examples: Input : n = 1 Output : 1 Input : n = 2 Output : 1 We can only place both tiles horizontally Input : n = 3 Output : 1 We can only place all tiles horizontally. Input : n = 4 Output : 2 The two ways are : 1) Place all tiles horizontally 2) Place all tiles vertically. Input : n = 5 Output : 3 We can fill a 5 x 4 grid in following ways : 1) Place all 5 tiles horizontally 2) Place first 4 vertically and 1 horizontally. 3) Place first 1 horizontally and 4 horizontally. Let “count(n)” be the count of ways to place tiles on a “n x 4” grid, following two cases arise when we place the first tile. Place the first tile horizontally : If we place first tile horizontally, the problem reduces to “count(n-1)” Place the first tile vertically : If we place first tile vertically, then we must place 3 more tiles vertically. So the problem reduces to “count(n-4)” Therefore, count(n) can be written as below. count(n) = 1 if n = 1 or n = 2 or n = 3 count(n) = 2 if n = 4 count(n) = count(n-1) + count(n-4) """ def titling(n): count=[0 for i in range(n+1)] for i in range(1,n+1): if i<=3: count[i]=1 elif i==4: count[i]==2 else: count[i]=count[i-1]+count[i-4] return count[n]
# A script to recursively find the greatest common divisor of two numbers def greatest_divisor(first, second): assert first == int(first) and second == int(second) and first != 0 and second != 0, 'Numbers provided must be nonzero integers' if first < 0: first = -first if second < 0: second = -second if (first >= second): return gcd_ordered(first, second) elif (first < second): return gcd_ordered(second, first) def gcd_ordered(higher, lower): if higher % lower == 0: return lower return gcd_ordered(lower, higher % lower) # Test the function print(greatest_divisor(18,48)) print(greatest_divisor(12,8)) print(greatest_divisor(49,21)) print(greatest_divisor(4,9)) print(greatest_divisor(9,9))
def main(): card_number = input("Enter credit card number: ") print_card_value(card_number) def print_card_value(card_number): if check_for_sum(card_number) == False: print("INVALID") elif check_for_amex(card_number) == True: print("AMEX") elif check_for_master(card_number) == True: print("MASTERCARD") elif check_for_visa(card_number) == True: print("VISA") else: print("INVALID") def check_for_amex(card_number): if len(card_number) == 15 and card_number[:2] in ["34", "37"]: return True else: return False def check_for_master(card_number): if len(card_number) == 16 and card_number[:2] in ["51", "52", "53", "54", "55"]: return True else: return False def check_for_visa(card_number): if len(card_number) in [13, 16] and card_number[0] == "4": return True else: return False def check_for_sum(card_number): product_of_two_sequence = 0 not_product_of_two_sequence = 0 product_of_two_digit_array = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9] for i in range(len(card_number)): new_number = int(card_number[len(card_number) - 1 - i]) if i % 2 == 0: not_product_of_two_sequence = not_product_of_two_sequence + new_number else: product_of_two_sequence = product_of_two_digit_array[new_number] sum_of_total = not_product_of_two_sequence + product_of_two_sequence return ((sum_of_total % 10) == 0) main()
# Write a program to create a stack called Product to perform # the basic operations on stack using list. The list contains # two data fields: ProductId and ProductName. Write the following functions: # InsertProd() – To push the data values into the list Docinfo # DeleteProd() – To remove the data value from the list Docinfo # ShowProd(): - To display data value for all Docinfo. # stack product = [] def InsertProd(): n = int(input('Enter who many products you want to insert: ')) for _ in range(0, n): pro_id = int(input('Enter product ID: ')) pro_name = input('Enter product: ') Docinfo = (pro_id, pro_name) product.append(Docinfo) def DeleteProd(): product.pop() print('Done') def ShowProd(): print(product) k = True while k == True: print(''' 1. Push Docinfo 2. Delete Docinfo 3. See Product 4. Exit ''') option = int(input('Enter your option(1/4): ')) if option == 1: InsertProd() elif option == 2: DeleteProd() elif option == 3: ShowProd() elif option == 4: k = False else: print("Invalid Option!") continue