content
stringlengths 7
1.05M
|
---|
nome = input('Digite seu nome: ')
name = input('Type your name: ')
print('É um prazer te conhecer, {}{}{}!'.format('\033[1;36m', nome, '\033[m'))
print('It is nice to meet you, {}{}{}!'.format('\033[4;30m', name, '\033[m'))
|
class ATMOS(object):
'''
class ATMOS
- attributes:
- self defined
- methods:
- None
'''
def __init__(self,info):
self.info = info
for key in info.keys():
setattr(self, key, info[key])
def __repr__(self):
return 'Instance of class ATMOS' |
t=int(input())
if not (1 <= t <= 100000): exit(-1)
dp=[0]*100001
dp[3]=3
for i in range(4,100001):
if i%3==0 or i%7==0: dp[i]=i
dp[i]+=dp[i-1]
query=[*map(int,input().split())]
if len(query)!=t: exit(-1)
for i in query:
if not (10 <= int(i) <= 80000): exit(-1)
print(dp[int(i)])
succ=False
try: input()
except: succ=True
if not succ: exit(-1) |
"""
Define the environment paths
"""
#Path variables
TEMPLATE_PATH = "/home/scom/documents/opu_surveillance_system/monitoring/master/"
STATIC_PATH = "/home/scom/documents/opu_surveillance_system/monitoring/static/"
|
N = int(input())
A = list(map(int, input().split()))
ans = 0
for a in A:
if a > 10:
ans += a - 10
print(ans) |
#!/usr/bin/env python
# encoding: utf-8
def run(whatweb, pluginname):
whatweb.recog_from_content(pluginname, "espcms")
whatweb.recog_from_file(pluginname, "templates/wap/cn/public/footer.html", "espcms")
|
vetor = []
entradaUsuario = int(input())
repetir = 1000
indice = 0
adicionar = 0
while(repetir > 0):
vetor.append(adicionar)
adicionar += 1
if(adicionar == entradaUsuario):
adicionar = 0
repetir -= 1
repetir = 1000
while(repetir>0):
repetir -= 1
print("N[{}] = {}".format(indice, vetor[indice]))
indice += 1
|
# -*- coding: utf-8 -*-
"""
eve-app settings
"""
# Use the MongoHQ sandbox as our backend.
MONGO_HOST = 'localhost'
MONGO_PORT = 27017
MONGO_USERNAME = ''
MONGO_PASSWORD = ''
MONGO_DBNAME = 'notifications'
# also, correctly set the API entry point
# SERVER_NAME = 'localhost'
# Enable reads (GET), inserts (POST) and DELETE for resources/collections
# (if you omit this line, the API will default to ['GET'] and provide
# read-only access to the endpoint).
RESOURCE_METHODS = ['GET', 'POST', 'DELETE']
# Enable reads (GET), edits (PATCH) and deletes of individual items
# (defaults to read-only item access).
ITEM_METHODS = ['GET', 'PATCH', 'DELETE']
# We enable standard client cache directives for all resources exposed by the
# API. We can always override these global settings later.
CACHE_CONTROL = 'max-age=20'
CACHE_EXPIRES = 20
X_DOMAINS = '*'
X_HEADERS = ['Authorization','If-Match','Access-Control-Expose-Headers','Content-Type','Pragma','Cache-Control']
X_EXPOSE_HEADERS = ['Origin', 'X-Requested-With', 'Content-Type', 'Accept']
units = ['ATG', 'ATC Mobile', 'Dealer Site', 'ATC', 'RealDeal', 'KBB', 'Tradein', 'vAuto', 'Fastlane', 'ATC SYC', 'VinSolution', 'HomeNet', 'ATX', 'CRM']
incident = {
# if 'item_title' is not provided API will just strip the final
# 's' from resource name, and use it as the item_title.
# 'item_title': 'incident',
'schema': {
'title': {
'type': 'string',
'minlength': 1,
'maxlength': 128,
},
'status': {
'type': 'string',
'allowed': ['red', 'yellow', 'green'],
'required': True,
},
'unit': {
'type': 'string',
'allowed': units,
'required': True,
},
'summary': {
'type': 'string',
'minlength': 1,
'maxlength': 512,
},
'created_by': {
'type': 'string',
'maxlength': 32,
},
}
}
update = {
# We choose to override global cache-control directives for this resource.
'cache_control': 'max-age=10,must-revalidate',
'cache_expires': 10,
'schema': {
'created_by': {
'type': 'string',
'maxlength': 32,
},
'description': {
'type': 'string',
'minlength': 1,
'maxlength': 512,
'required': True,
},
'incident': {
'type': 'objectid',
'required': True,
# referential integrity constraint: value must exist in the
# 'incidents' collection. Since we aren't declaring a 'field' key,
# will default to `incidents._id` (or, more precisely, to whatever
# ID_FIELD value is).
'data_relation': {
'resource': 'incidents',
# make the owner embeddable with ?embedded={"incident":1}
'embeddable': True
},
},
}
}
# The DOMAIN dict explains which resources will be available and how they will
# be accessible to the API consumer.
DOMAIN = {
'incidents': incident,
'updates': update,
}
|
# AUTHOR = PAUL KEARNEY
# DATE = 2018-02-05
# STUDENT ID = G00364787
# EXERCISE 03
#
# filename= gmit--exercise03--collatz--20180205d.py
#
# the Collatz conjecture
print("The COLLATZ CONJECTURE")
# define the variables
num = ""
x = 0
# obtain user input
num = input("A start nummber: ")
x = int(num)
print("--Start of sequence.")
print (x)
# calculate the sequence/conjecture
while x != 1:
if x % 2 == 0:
x = x / 2
else:
x = (x * 3) + 1
print(int(x))
print("--End of sequence")
#
#
#
#
#
#
#
# WEEK 03
#
# filename= gmit--week03--collatz--20180205d.py
#
# STUDENT ID= g00364787
#
# the Collatz conjecture
#
#
#
#The COLLATZ CONJECTURE
#
#A start nummber: 12
#--Start of sequence.
#12
#6
#3
#10
#5
#16
#8
#4
#2
#1
#--End of sequence
#
## end ##
|
#Faça um programa que calcule a soma entre todos os números ímpares que são múltiplos de 3 e que se encontram
# no intervalo de 1 até 500.
soma = 0
cont = 0
for c in range(1,501,2):
if c % 3 == 0:
cont = cont + 1
soma = soma + c
print('A soma dos números solicitados {} são {}'.format(cont, soma))
|
"""django-livereload"""
__version__ = '1.7'
__license__ = 'BSD License'
__author__ = 'Fantomas42'
__email__ = 'fantomas42@gmail.com'
__url__ = 'https://github.com/Fantomas42/django-livereload'
|
DEFAULT_TEXT_TYPE = "mrkdwn"
class BaseBlock:
def generate(self):
raise NotImplemented("Subclass missing generate implementation")
class TextBlock(BaseBlock):
def __init__(self, text, _type=DEFAULT_TEXT_TYPE):
self._text = text
self._type = _type
def __repr__(self):
return f"TextBlock({self._text}, _type={self._type})"
def generate(self):
return {"type": "section", "text": {"type": self._type, "text": self._text}}
|
"""
CPF = 079.004.419-64
----------------------
0 * 10 = 0 # 0 * 11 = 0
7 * 9 = 63 # 7 * 10 = 70
9 * 8 = 72 # 9 * 9 = 81
0 * 7 = 0 # 0 * 8 = 0
0 * 6 = 0 # 0 * 7 = 0
4 * 5 = 20 # 4 * 6 = 24
4 * 4 = 16 # 4 * 5 = 20
1 * 3 = 3 # 1 * 4 = 4
9 * 2 = 18 # 9 * 3 = 27
# digito 1 * 2 = 12
soma = 192 # soma = 238
11 - (192 % 11) = 6 # 11 - (238 % 11) = 4
se soma > 9 == 0 # se soma > 9 == 0
se soma <= 9 == soma # se soma <= 9 == soma
Digito 1 = 6 # Digito 1 = 4
"""
# Input de dados e verificação dos numeros
print()
print('*'*50)
titulo = ' Validador de CPF '
print(f'{titulo:*^50}')
print('*'*50)
print()
while True:
cpf = input('Digite o seu CPF: ')
if not cpf.isnumeric():
print('Digite apenas os números do seu CPF sem ponto e hífen')
continue
elif not len(cpf) == 11:
print('Opa seu CPF está não está com 11 números')
continue
else:
print(cpf)
break
soma_1 = 0
i = 0
for n in range(10,1,-1):
soma_1 += int(cpf[i])*n
i += 1
calc_digito_1 = str (11 - (soma_1 % 11))
soma_2 = 0
j = 0
for n in range(11,1,-1):
soma_2 += int(cpf[j])*n
j += 1
calc_digito_2 = str (11 - (soma_2 % 11))
if calc_digito_1 == cpf[9] and calc_digito_2 == cpf[10]:
print('Seu CPF é válido no território nacional')
else:
print('Você está com um CPF não válido')
|
#Script to calc. area of circle.
print("enter the radius")
r= float(input())
area= 3.14*r**2
print("area of circle is",area)
|
#doc4
#1.
print([1, 'Hello', 1.0])
#2
print([1, 1, [1,2]][2][1])
#3. out: 'b', 'c'
print(['a','b', 'c'][1:])
#4.
weekDict= {'Sunday':0,'Monday':1,'Tuesday':2,'Wednesday':3,'Thursday':4,'Friday':5,'Saturday':6, }
#5. out: 2 if you replace D[k1][1] with D['k1][1]
D={'k1':[1,2,3]}
print(D['k1'][1])
#6.
tup = ( 'a', [1,[2,3]] )
print(tup)
#7.
x= set('Missipi')
print(x)
#8
x.add('X')
print(x)
#9 out: [1, 2, ,3]
print(set([1,1,2,3]))
#10
for i in range(2000,3001):
if (i%7==0) and (i%5!=0):
print(i) |
description = 'Resi instrument setup'
group = 'basic'
includes = ['base']
|
def quick_sort(array):
'''
Prototypical quick sort algorithm using Python
Time and Space Complexity:
* Best: O(n * log(n)) time | O(log(n)) space
* Avg: O(n * log(n)) time | O(log(n)) space
* Worst: O(n^2) time | O(log(n)) space
'''
return _quick_sort(array, 0, len(array)-1)
def _quick_sort(array, start, end):
# We don't need to sort an array of size 1 (already sorted), or less
if start >= end:
return
pivot = partition(array, start, end)
_quick_sort(array, start, pivot-1)
_quick_sort(array, pivot+1, end)
def partition(array, start, end):
pivot, pivotVal = start, array[start]
left, right = start+1, end
while left <= right:
if array[left] > pivotVal and array[right] < pivotVal:
swap(array, left, right)
if array[left] <= pivotVal:
left += 1
if pivotVal <= array[right]:
right -= 1
swap(array, pivot, right)
return right
def swap(array, i, j):
'''
Swaps the value at the i-th index with the value at the j-th index in place.
'''
if i < 0 or i > len(array)-1:
raise IndexError(f'Index <i> of {i} is not a valid index of <array>')
elif j < 0 or j > len(array)-1:
raise IndexError(f'Index <j> of {j} is not a valid index of <array>')
elif i == j:
return
array[i], array[j] = array[j], array[i]
test_cases = [
[],
[3,2],
[2,3,1],
[1,2,3],
[33, 33, 33, 33, 33],
[33, 33, 33, 33, 44],
[16, 1, 53, 99, 16, 9, 100, 300, 12],
]
for test_case in test_cases:
result = test_case.copy()
quick_sort(result)
assert result == sorted(test_case) |
def loops():
# String Array
names = ["Apple", "Orange", "Pear"]
# \n is a newline in a string
print('\n---------------')
print(' For Each Loop')
print('---------------\n')
# For Each Loop
for i in names:
print(i)
print('\n---------------')
print(' For Loop')
print('---------------\n')
# For Loop
# the range() function can take a min, max, and interval
# value, max is non-inclusive i.e. 101 stops at 100
# example: range(0, 101, 2)
for i in range(5):
if i == 1:
print('1, continue')
# continue will move to the next iteration in the loop
continue
elif i == 3:
print('3, break')
# the break statement will end the loop
break
# if the number doesn't fit the conditions above
# it will be printed to the console
print(i)
print('\n---------------')
print(' While Loop')
print('---------------\n')
# Boolean variables hold True or False, 0 or 1
loop = True
# Integer variables hold whole numbers
iterations = 0
max_iterations = 10
print('0 -', max_iterations, '\n')
# The while loop will run as long as the given
# condition or variable is true
# Parentheses are optional
while loop:
# the += operator adds the given value to
# the current value of a variable
iterations += 1
print(iterations)
if iterations == max_iterations:
# break will end a loops execution
break
if __name__ == '__main__':
loops()
|
def solution(participant, completion):
answer = ''
# sort하면 시간절약이 가능
participant.sort() # [a, a, b]
completion.sort() # [a, b]
print(participant)
print(completion)
for i in range(len(completion)):
if participant[i] != completion[i]:
answer = participant[i]
break
else:
answer = participant[len(participant) - 1]
return answer
part = ['marina', 'josipa', 'nikola', 'vinko', 'filipa']
comp = ['josipa', 'filipa', 'marina', 'nikola']
print(solution(part, comp)) |
class Node:
def __init__(self, value, next_p=None):
self.next = next_p
self.value = value
def __str__(self):
return f'{self.value}'
class InvalidOperationError(Exception):
pass
class Stack:
def __init__(self):
self.top = None
def push(self, value):
current = self.top
if self.top == None:
self.top = Node(value)
else:
node_n = Node(value)
node_n.next = self.top
self.top = node_n
def pop(self):
if not self.top:
raise InvalidOperationError('Method not allowed on empty collection')
if self.top:
top_value = self.top
self.top = self.top.next
return top_value.value
def peek(self):
if not self.top:
raise InvalidOperationError("Method not allowed on empty collection")
return self.top.value
def is_empty(self):
return not self.top
class Queue:
def __init__(self):
self.f = None
self.r = None
def enqueue(self, value):
node = Node(value)
if self.r:
node = self.r.next
node = self.r
def dequeue(self):
if not self.f:
raise InvalidOperationError('Method not allowed on empty collection')
leave = self.f
if self.f == self.r:
self.r = None
self.f = self.f.next
return leave.value
def peek(self):
if not self.f:
raise InvalidOperationError('Method not allowed on empty collection')
return self.f.value
def is_empty(self):
return not self.f and not self.r
|
def main():
number = int(input("Enter number (Only positive integer is allowed)"))
print(f'{number} square is {number ** 2}')
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
main()
|
number_of_computers = int(input())
number_of_sales = 0
real_sales = 0
made_sales = 0
counter_sales = 0
total_ratings = 0
for i in range (number_of_computers):
rating = int(input())
rating_scale = rating % 10
possible_sales = rating // 10
total_ratings += rating_scale
if rating_scale == 2:
real_sales = possible_sales * 0 / 100
counter_sales += real_sales
elif rating_scale == 3:
real_sales = possible_sales * 50 / 100
counter_sales += real_sales
elif rating_scale == 4:
real_sales = possible_sales * 70 / 100
counter_sales += real_sales
elif rating_scale == 5:
real_sales = possible_sales * 85 / 100
counter_sales += real_sales
elif rating_scale == 6:
real_sales = possible_sales * 100 / 100
counter_sales += real_sales
average_rating = total_ratings / number_of_computers
print (f'{counter_sales:.2f}')
print (f'{average_rating:.2f}')
|
"""
Created: 2001/08/05
Purpose: Turn PythonCard into a package
__version__ = "$Revision: 1.1.1.1 $"
__date__ = "$Date: 2001/08/06 19:53:11 $"
"""
|
def main():
valid_passwords_by_range_policy = 0
valid_passwords_by_position_policy = 0
with open('input') as f:
for line in f:
policy_string, password = parse_line(line.strip())
policy = Policy.parse(policy_string)
if policy.is_valid_by_range_policy(password):
valid_passwords_by_range_policy += 1
if policy.is_valid_by_position_policy(password):
valid_passwords_by_position_policy += 1
print(f'There are {valid_passwords_by_range_policy} valid passwords by "range" policy.')
print(f'There are {valid_passwords_by_position_policy} valid passwords by "position" policy.')
def parse_line(line):
tokens = line.split(':', 1)
policy_string = tokens[0]
password = tokens[1].strip()
return policy_string, password
class Policy:
def __init__(self, first_number, second_number, letter):
self._first_number = first_number
self._second_number = second_number
self._letter = letter
def is_valid_by_range_policy(self, password):
count = password.count(self._letter)
return count >= self._first_number and count <= self._second_number
def is_valid_by_position_policy(self, password):
index1 = self._first_number - 1
index2 = self._second_number - 1
return (password[index1] == self._letter) != (password[index2] == self._letter)
@classmethod
def parse (cls, string):
tokens = string.split(' ')
first_number_string, second_number_string = tokens[0].split('-')
letter = tokens[1]
return cls(int(first_number_string), int(second_number_string), letter)
if __name__ == '__main__':
main()
|
# LTE using two pointers O(n**3)
class Solution(object):
def fourSumCount(self, A, B, C, D):
# corner case:
if len(A) == 0:
return 0
A.sort()
B.sort()
C.sort()
D.sort()
count = 0
for i in range(len(A)):
for j in range(len(B)):
k = 0
t = len(D) - 1
while 0 <= k < len(C) and 0 <= t < len(D):
if A[i] + B[j] + C[k] + D[t] > 0:
t -= 1
elif A[i] + B[j] + C[k] + D[t] < 0:
k += 1
else:
tmp1 = 1
tmp2 = 1
while 0 <= k < len(C) - 1 and C[k + 1] == C[k]:
k += 1
tmp1 += 1
while 1 <= t < len(D) and D[t - 1] == D[t]:
t -= 1
tmp2 += 1
count += tmp1 * tmp2
k += 1
t -= 1
return count
# hashmap Solution AC O(n**2)
class Solution(object):
def fourSumCount(self, A, B, C, D):
"""
:type A: List[int]
:type B: List[int]
:type C: List[int]
:type D: List[int]
:rtype: int
"""
hashtable = {}
count = 0
for a in A:
for b in B:
if a+b in hashtable:
hashtable[a+b] += 1
else:
hashtable[a+b] = 1
for c in C:
for d in D:
if -c-d in hashtable:
count += hashtable[-c-d]
return count |
def tree_16b(features):
if features[12] <= 0.0026689696301218646:
if features[2] <= 0.00825153129312639:
if features[19] <= 0.005966400067336508:
if features[19] <= 0.0029812112336458085:
if features[17] <= 0.001915214421615019:
return 0
else: # if features[17] > 0.001915214421615019
return 0
else: # if features[19] > 0.0029812112336458085
if features[2] <= 0.0018615168210089905:
return 0
else: # if features[2] > 0.0018615168210089905
return 0
else: # if features[19] > 0.005966400067336508
if features[19] <= 0.00793332328953511:
if features[18] <= 0.005491076861972033:
return 1
else: # if features[18] > 0.005491076861972033
return 0
else: # if features[19] > 0.00793332328953511
if features[6] <= 0.001075940812143017:
return 1
else: # if features[6] > 0.001075940812143017
return 1
else: # if features[2] > 0.00825153129312639
if features[2] <= 0.011165123326009052:
if features[19] <= 0.0012947088146120223:
if features[9] <= 0.002559585628887362:
return 1
else: # if features[9] > 0.002559585628887362
return 0
else: # if features[19] > 0.0012947088146120223
if features[10] <= 0.0028857488325684244:
return 1
else: # if features[10] > 0.0028857488325684244
return 0
else: # if features[2] > 0.011165123326009052
if features[1] <= 0.012951065746165114:
if features[6] <= 0.009407024106167228:
return 1
else: # if features[6] > 0.009407024106167228
return 0
else: # if features[1] > 0.012951065746165114
return 1
else: # if features[12] > 0.0026689696301218646
if features[19] <= 0.017378134596128803:
if features[2] <= 0.01920186421671133:
if features[0] <= 0.0018734496211436635:
if features[10] <= 0.0055686400628474075:
return 0
else: # if features[10] > 0.0055686400628474075
return 1
else: # if features[0] > 0.0018734496211436635
if features[3] <= 0.02158046904355615:
return 0
else: # if features[3] > 0.02158046904355615
return 1
else: # if features[2] > 0.01920186421671133
if features[3] <= 0.06516701033547179:
if features[15] <= 0.00476715365380187:
return 1
else: # if features[15] > 0.00476715365380187
return 1
else: # if features[3] > 0.06516701033547179
if features[0] <= 0.034261057986668675:
return 1
else: # if features[0] > 0.034261057986668675
return 0
else: # if features[19] > 0.017378134596128803
if features[0] <= 0.0035281312398183218:
if features[2] <= 0.0026570368299871916:
if features[14] <= 0.008929712100780307:
return 1
else: # if features[14] > 0.008929712100780307
return 0
else: # if features[2] > 0.0026570368299871916
if features[19] <= 0.03522761479757719:
return 1
else: # if features[19] > 0.03522761479757719
return 0
else: # if features[0] > 0.0035281312398183218
if features[8] <= 0.0518500053851767:
if features[13] <= 0.010222432115369884:
return 1
else: # if features[13] > 0.010222432115369884
return 0
else: # if features[8] > 0.0518500053851767
if features[0] <= 0.03477615719248206:
return 1
else: # if features[0] > 0.03477615719248206
return 0
##################################################
def tree_15b(features):
if features[12] <= 0.0026689696301218646:
if features[2] <= 0.008249542493103945:
if features[19] <= 0.005966400067336508:
if features[19] <= 0.002979222433623363:
if features[17] <= 0.0019132256215925736:
return 0
else: # if features[17] > 0.0019132256215925736
return 0
else: # if features[19] > 0.002979222433623363
if features[2] <= 0.0018615168210089905:
return 0
else: # if features[2] > 0.0018615168210089905
return 0
else: # if features[19] > 0.005966400067336508
if features[19] <= 0.007935312089557556:
if features[18] <= 0.005493065661994478:
return 1
else: # if features[18] > 0.005493065661994478
return 0
else: # if features[19] > 0.007935312089557556
if features[6] <= 0.0010739520121205715:
return 1
else: # if features[6] > 0.0010739520121205715
return 1
else: # if features[2] > 0.008249542493103945
if features[2] <= 0.011165123326009052:
if features[19] <= 0.0012927200145895767:
if features[9] <= 0.0025575968288649165:
return 1
else: # if features[9] > 0.0025575968288649165
return 0
else: # if features[19] > 0.0012927200145895767
if features[10] <= 0.00288773763259087:
return 1
else: # if features[10] > 0.00288773763259087
return 0
else: # if features[2] > 0.011165123326009052
if features[1] <= 0.012951065746165114:
if features[6] <= 0.009407024106167228:
return 1
else: # if features[6] > 0.009407024106167228
return 0
else: # if features[1] > 0.012951065746165114
return 1
else: # if features[12] > 0.0026689696301218646
if features[19] <= 0.017378134596128803:
if features[2] <= 0.019199875416688883:
if features[0] <= 0.0018734496211436635:
if features[10] <= 0.0055686400628474075:
return 0
else: # if features[10] > 0.0055686400628474075
return 1
else: # if features[0] > 0.0018734496211436635
if features[3] <= 0.021582457843578595:
return 0
else: # if features[3] > 0.021582457843578595
return 1
else: # if features[2] > 0.019199875416688883
if features[3] <= 0.06516502153544934:
if features[15] <= 0.0047651648537794244:
return 1
else: # if features[15] > 0.0047651648537794244
return 1
else: # if features[3] > 0.06516502153544934
if features[0] <= 0.03426304678669112:
return 1
else: # if features[0] > 0.03426304678669112
return 0
else: # if features[19] > 0.017378134596128803
if features[0] <= 0.0035281312398183218:
if features[2] <= 0.0026570368299871916:
if features[14] <= 0.008929712100780307:
return 1
else: # if features[14] > 0.008929712100780307
return 0
else: # if features[2] > 0.0026570368299871916
if features[19] <= 0.035225625997554744:
return 1
else: # if features[19] > 0.035225625997554744
return 0
else: # if features[0] > 0.0035281312398183218
if features[8] <= 0.051848016585154255:
if features[13] <= 0.010222432115369884:
return 1
else: # if features[13] > 0.010222432115369884
return 0
else: # if features[8] > 0.051848016585154255
if features[0] <= 0.03477615719248206:
return 1
else: # if features[0] > 0.03477615719248206
return 0
##################################################
def tree_14b(features):
if features[12] <= 0.0026729472301667556:
if features[2] <= 0.008249542493103945:
if features[19] <= 0.005966400067336508:
if features[19] <= 0.002983200033668254:
if features[17] <= 0.0019172032216374646:
return 0
else: # if features[17] > 0.0019172032216374646
return 0
else: # if features[19] > 0.002983200033668254
if features[2] <= 0.0018615168210089905:
return 0
else: # if features[2] > 0.0018615168210089905
return 0
else: # if features[19] > 0.005966400067336508
if features[19] <= 0.007931334489512665:
if features[18] <= 0.005489088061949587:
return 1
else: # if features[18] > 0.005489088061949587
return 0
else: # if features[19] > 0.007931334489512665
if features[6] <= 0.0010739520121205715:
return 1
else: # if features[6] > 0.0010739520121205715
return 1
else: # if features[2] > 0.008249542493103945
if features[2] <= 0.011161145725964161:
if features[19] <= 0.0012966976146344678:
if features[9] <= 0.0025615744289098075:
return 1
else: # if features[9] > 0.0025615744289098075
return 0
else: # if features[19] > 0.0012966976146344678
if features[10] <= 0.00288773763259087:
return 1
else: # if features[10] > 0.00288773763259087
return 0
else: # if features[2] > 0.011161145725964161
if features[1] <= 0.012951065746165114:
if features[6] <= 0.009411001706212119:
return 1
else: # if features[6] > 0.009411001706212119
return 0
else: # if features[1] > 0.012951065746165114
return 1
else: # if features[12] > 0.0026729472301667556
if features[19] <= 0.01737415699608391:
if features[2] <= 0.019203853016733774:
if features[0] <= 0.0018774272211885545:
if features[10] <= 0.0055686400628474075:
return 0
else: # if features[10] > 0.0055686400628474075
return 1
else: # if features[0] > 0.0018774272211885545
if features[3] <= 0.021582457843578595:
return 0
else: # if features[3] > 0.021582457843578595
return 1
else: # if features[2] > 0.019203853016733774
if features[3] <= 0.06516104393540445:
if features[15] <= 0.0047651648537794244:
return 1
else: # if features[15] > 0.0047651648537794244
return 1
else: # if features[3] > 0.06516104393540445
if features[0] <= 0.03426304678669112:
return 1
else: # if features[0] > 0.03426304678669112
return 0
else: # if features[19] > 0.01737415699608391
if features[0] <= 0.0035321088398632128:
if features[2] <= 0.0026570368299871916:
if features[14] <= 0.008925734500735416:
return 1
else: # if features[14] > 0.008925734500735416
return 0
else: # if features[2] > 0.0026570368299871916
if features[19] <= 0.035225625997554744:
return 1
else: # if features[19] > 0.035225625997554744
return 0
else: # if features[0] > 0.0035321088398632128
if features[8] <= 0.051851994185199146:
if features[13] <= 0.010222432115369884:
return 1
else: # if features[13] > 0.010222432115369884
return 0
else: # if features[8] > 0.051851994185199146
if features[0] <= 0.03477217959243717:
return 1
else: # if features[0] > 0.03477217959243717
return 0
##################################################
def tree_13b(features):
if features[12] <= 0.0026729472301667556:
if features[2] <= 0.008257497693193727:
if features[19] <= 0.005966400067336508:
if features[19] <= 0.002975244833578472:
if features[17] <= 0.0019092480215476826:
return 0
else: # if features[17] > 0.0019092480215476826
return 0
else: # if features[19] > 0.002975244833578472
if features[2] <= 0.0018615168210089905:
return 0
else: # if features[2] > 0.0018615168210089905
return 0
else: # if features[19] > 0.005966400067336508
if features[19] <= 0.007939289689602447:
if features[18] <= 0.005489088061949587:
return 1
else: # if features[18] > 0.005489088061949587
return 0
else: # if features[19] > 0.007939289689602447
if features[6] <= 0.0010819072122103535:
return 1
else: # if features[6] > 0.0010819072122103535
return 1
else: # if features[2] > 0.008257497693193727
if features[2] <= 0.011169100926053943:
if features[19] <= 0.0012887424145446857:
if features[9] <= 0.0025615744289098075:
return 1
else: # if features[9] > 0.0025615744289098075
return 0
else: # if features[19] > 0.0012887424145446857
if features[10] <= 0.002879782432501088:
return 1
else: # if features[10] > 0.002879782432501088
return 0
else: # if features[2] > 0.011169100926053943
if features[1] <= 0.012951065746165114:
if features[6] <= 0.009403046506122337:
return 1
else: # if features[6] > 0.009403046506122337
return 0
else: # if features[1] > 0.012951065746165114
return 1
else: # if features[12] > 0.0026729472301667556
if features[19] <= 0.01737415699608391:
if features[2] <= 0.019203853016733774:
if features[0] <= 0.0018774272211885545:
if features[10] <= 0.0055686400628474075:
return 0
else: # if features[10] > 0.0055686400628474075
return 1
else: # if features[0] > 0.0018774272211885545
if features[3] <= 0.021574502643488813:
return 0
else: # if features[3] > 0.021574502643488813
return 1
else: # if features[2] > 0.019203853016733774
if features[3] <= 0.06515308873531467:
if features[15] <= 0.0047731200538692065:
return 1
else: # if features[15] > 0.0047731200538692065
return 1
else: # if features[3] > 0.06515308873531467
if features[0] <= 0.03425509158660134:
return 1
else: # if features[0] > 0.03425509158660134
return 0
else: # if features[19] > 0.01737415699608391
if features[0] <= 0.0035321088398632128:
if features[2] <= 0.0026570368299871916:
if features[14] <= 0.008925734500735416:
return 1
else: # if features[14] > 0.008925734500735416
return 0
else: # if features[2] > 0.0026570368299871916
if features[19] <= 0.035225625997554744:
return 1
else: # if features[19] > 0.035225625997554744
return 0
else: # if features[0] > 0.0035321088398632128
if features[8] <= 0.051851994185199146:
if features[13] <= 0.010214476915280102:
return 1
else: # if features[13] > 0.010214476915280102
return 0
else: # if features[8] > 0.051851994185199146
if features[0] <= 0.03478013479252695:
return 1
else: # if features[0] > 0.03478013479252695
return 0
##################################################
def tree_12b(features):
if features[12] <= 0.0026729472301667556:
if features[2] <= 0.008241587293014163:
if features[19] <= 0.005950489667156944:
if features[19] <= 0.002991155233758036:
if features[17] <= 0.0019092480215476826:
return 0
else: # if features[17] > 0.0019092480215476826
return 0
else: # if features[19] > 0.002991155233758036
if features[2] <= 0.0018456064208294265:
return 0
else: # if features[2] > 0.0018456064208294265
return 0
else: # if features[19] > 0.005950489667156944
if features[19] <= 0.007923379289422883:
if features[18] <= 0.0055049984621291514:
return 1
else: # if features[18] > 0.0055049984621291514
return 0
else: # if features[19] > 0.007923379289422883
if features[6] <= 0.0010819072122103535:
return 1
else: # if features[6] > 0.0010819072122103535
return 1
else: # if features[2] > 0.008241587293014163
if features[2] <= 0.011169100926053943:
if features[19] <= 0.0013046528147242498:
if features[9] <= 0.0025456640287302434:
return 1
else: # if features[9] > 0.0025456640287302434
return 0
else: # if features[19] > 0.0013046528147242498
if features[10] <= 0.002895692832680652:
return 1
else: # if features[10] > 0.002895692832680652
return 0
else: # if features[2] > 0.011169100926053943
if features[1] <= 0.012951065746165114:
if features[6] <= 0.0094189569063019:
return 1
else: # if features[6] > 0.0094189569063019
return 0
else: # if features[1] > 0.012951065746165114
return 1
else: # if features[12] > 0.0026729472301667556
if features[19] <= 0.01737415699608391:
if features[2] <= 0.01918794261655421:
if features[0] <= 0.0018774272211885545:
if features[10] <= 0.0055686400628474075:
return 0
else: # if features[10] > 0.0055686400628474075
return 1
else: # if features[0] > 0.0018774272211885545
if features[3] <= 0.021574502643488813:
return 0
else: # if features[3] > 0.021574502643488813
return 1
else: # if features[2] > 0.01918794261655421
if features[3] <= 0.0651371783351351:
if features[15] <= 0.0047731200538692065:
return 1
else: # if features[15] > 0.0047731200538692065
return 1
else: # if features[3] > 0.0651371783351351
if features[0] <= 0.0342710019867809:
return 1
else: # if features[0] > 0.0342710019867809
return 0
else: # if features[19] > 0.01737415699608391
if features[0] <= 0.0035321088398632128:
if features[2] <= 0.0026411264298076276:
if features[14] <= 0.00894164490091498:
return 1
else: # if features[14] > 0.00894164490091498
return 0
else: # if features[2] > 0.0026411264298076276
if features[19] <= 0.035225625997554744:
return 1
else: # if features[19] > 0.035225625997554744
return 0
else: # if features[0] > 0.0035321088398632128
if features[8] <= 0.05183608378501958:
if features[13] <= 0.010214476915280102:
return 1
else: # if features[13] > 0.010214476915280102
return 0
else: # if features[8] > 0.05183608378501958
if features[0] <= 0.03478013479252695:
return 1
else: # if features[0] > 0.03478013479252695
return 0
##################################################
def tree_11b(features):
if features[12] <= 0.0026729472301667556:
if features[2] <= 0.008273408093373291:
if features[19] <= 0.005982310467516072:
if features[19] <= 0.002991155233758036:
if features[17] <= 0.0019092480215476826:
return 0
else: # if features[17] > 0.0019092480215476826
return 0
else: # if features[19] > 0.002991155233758036
if features[2] <= 0.0018456064208294265:
return 0
else: # if features[2] > 0.0018456064208294265
return 0
else: # if features[19] > 0.005982310467516072
if features[19] <= 0.00795520008978201:
if features[18] <= 0.005473177661770023:
return 1
else: # if features[18] > 0.005473177661770023
return 0
else: # if features[19] > 0.00795520008978201
if features[6] <= 0.0010819072122103535:
return 1
else: # if features[6] > 0.0010819072122103535
return 1
else: # if features[2] > 0.008273408093373291
if features[2] <= 0.011137280125694815:
if features[19] <= 0.0012728320143651217:
if features[9] <= 0.0025456640287302434:
return 1
else: # if features[9] > 0.0025456640287302434
return 0
else: # if features[19] > 0.0012728320143651217
if features[10] <= 0.002863872032321524:
return 1
else: # if features[10] > 0.002863872032321524
return 0
else: # if features[2] > 0.011137280125694815
if features[1] <= 0.012919244945805985:
if features[6] <= 0.0094189569063019:
return 1
else: # if features[6] > 0.0094189569063019
return 0
else: # if features[1] > 0.012919244945805985
return 1
else: # if features[12] > 0.0026729472301667556
if features[19] <= 0.01737415699608391:
if features[2] <= 0.019219763416913338:
if features[0] <= 0.0018456064208294265:
if features[10] <= 0.0055368192624882795:
return 0
else: # if features[10] > 0.0055368192624882795
return 1
else: # if features[0] > 0.0018456064208294265
if features[3] <= 0.021574502643488813:
return 0
else: # if features[3] > 0.021574502643488813
return 1
else: # if features[2] > 0.019219763416913338
if features[3] <= 0.06510535753477598:
if features[15] <= 0.0047731200538692065:
return 1
else: # if features[15] > 0.0047731200538692065
return 1
else: # if features[3] > 0.06510535753477598
if features[0] <= 0.034239181186421774:
return 1
else: # if features[0] > 0.034239181186421774
return 0
else: # if features[19] > 0.01737415699608391
if features[0] <= 0.0035002880395040847:
if features[2] <= 0.0026729472301667556:
if features[14] <= 0.008909824100555852:
return 1
else: # if features[14] > 0.008909824100555852
return 0
else: # if features[2] > 0.0026729472301667556
if features[19] <= 0.03525744679791387:
return 1
else: # if features[19] > 0.03525744679791387
return 0
else: # if features[0] > 0.0035002880395040847
if features[8] <= 0.05186790458537871:
if features[13] <= 0.01024629771563923:
return 1
else: # if features[13] > 0.01024629771563923
return 0
else: # if features[8] > 0.05186790458537871
if features[0] <= 0.03474831399216782:
return 1
else: # if features[0] > 0.03474831399216782
return 0
##################################################
def tree_10b(features):
if features[12] <= 0.0026729472301667556:
if features[2] <= 0.008273408093373291:
if features[19] <= 0.005982310467516072:
if features[19] <= 0.00292751363303978:
if features[17] <= 0.0019092480215476826:
return 0
else: # if features[17] > 0.0019092480215476826
return 0
else: # if features[19] > 0.00292751363303978
if features[2] <= 0.0019092480215476826:
return 0
else: # if features[2] > 0.0019092480215476826
return 0
else: # if features[19] > 0.005982310467516072
if features[19] <= 0.007891558489063755:
if features[18] <= 0.005473177661770023:
return 1
else: # if features[18] > 0.005473177661770023
return 0
else: # if features[19] > 0.007891558489063755
if features[6] <= 0.0010182656114920974:
return 1
else: # if features[6] > 0.0010182656114920974
return 1
else: # if features[2] > 0.008273408093373291
if features[2] <= 0.011200921726413071:
if features[19] <= 0.0012728320143651217:
if features[9] <= 0.0025456640287302434:
return 1
else: # if features[9] > 0.0025456640287302434
return 0
else: # if features[19] > 0.0012728320143651217
if features[10] <= 0.00292751363303978:
return 1
else: # if features[10] > 0.00292751363303978
return 0
else: # if features[2] > 0.011200921726413071
if features[1] <= 0.012982886546524242:
if features[6] <= 0.0094189569063019:
return 1
else: # if features[6] > 0.0094189569063019
return 0
else: # if features[1] > 0.012982886546524242
return 1
else: # if features[12] > 0.0026729472301667556
if features[19] <= 0.017437798596802168:
if features[2] <= 0.019219763416913338:
if features[0] <= 0.0019092480215476826:
if features[10] <= 0.005600460863206536:
return 0
else: # if features[10] > 0.005600460863206536
return 1
else: # if features[0] > 0.0019092480215476826
if features[3] <= 0.02163814424420707:
return 0
else: # if features[3] > 0.02163814424420707
return 1
else: # if features[2] > 0.019219763416913338
if features[3] <= 0.06504171593405772:
if features[15] <= 0.00470947845315095:
return 1
else: # if features[15] > 0.00470947845315095
return 1
else: # if features[3] > 0.06504171593405772
if features[0] <= 0.034239181186421774:
return 1
else: # if features[0] > 0.034239181186421774
return 0
else: # if features[19] > 0.017437798596802168
if features[0] <= 0.003563929640222341:
if features[2] <= 0.0026729472301667556:
if features[14] <= 0.008909824100555852:
return 1
else: # if features[14] > 0.008909824100555852
return 0
else: # if features[2] > 0.0026729472301667556
if features[19] <= 0.03525744679791387:
return 1
else: # if features[19] > 0.03525744679791387
return 0
else: # if features[0] > 0.003563929640222341
if features[8] <= 0.051804262984660454:
if features[13] <= 0.010182656114920974:
return 1
else: # if features[13] > 0.010182656114920974
return 0
else: # if features[8] > 0.051804262984660454
if features[0] <= 0.03474831399216782:
return 1
else: # if features[0] > 0.03474831399216782
return 0
##################################################
def tree_9b(features):
if features[12] <= 0.0025456640287302434:
if features[2] <= 0.008146124891936779:
if features[19] <= 0.00585502726607956:
if features[19] <= 0.003054796834476292:
if features[17] <= 0.0020365312229841948:
return 0
else: # if features[17] > 0.0020365312229841948
return 0
else: # if features[19] > 0.003054796834476292
if features[2] <= 0.0017819648201111704:
return 0
else: # if features[2] > 0.0017819648201111704
return 0
else: # if features[19] > 0.00585502726607956
if features[19] <= 0.007891558489063755:
if features[18] <= 0.005600460863206536:
return 1
else: # if features[18] > 0.005600460863206536
return 0
else: # if features[19] > 0.007891558489063755
if features[6] <= 0.0010182656114920974:
return 1
else: # if features[6] > 0.0010182656114920974
return 1
else: # if features[2] > 0.008146124891936779
if features[2] <= 0.011200921726413071:
if features[19] <= 0.0012728320143651217:
if features[9] <= 0.0025456640287302434:
return 1
else: # if features[9] > 0.0025456640287302434
return 0
else: # if features[19] > 0.0012728320143651217
if features[10] <= 0.002800230431603268:
return 1
else: # if features[10] > 0.002800230431603268
return 0
else: # if features[2] > 0.011200921726413071
if features[1] <= 0.012982886546524242:
if features[6] <= 0.0094189569063019:
return 1
else: # if features[6] > 0.0094189569063019
return 0
else: # if features[1] > 0.012982886546524242
return 1
else: # if features[12] > 0.0025456640287302434
if features[19] <= 0.017310515395365655:
if features[2] <= 0.019092480215476826:
if features[0] <= 0.0017819648201111704:
if features[10] <= 0.005600460863206536:
return 0
else: # if features[10] > 0.005600460863206536
return 1
else: # if features[0] > 0.0017819648201111704
if features[3] <= 0.02163814424420707:
return 0
else: # if features[3] > 0.02163814424420707
return 1
else: # if features[2] > 0.019092480215476826
if features[3] <= 0.06491443273262121:
if features[15] <= 0.0048367616545874625:
return 1
else: # if features[15] > 0.0048367616545874625
return 1
else: # if features[3] > 0.06491443273262121
if features[0] <= 0.034366464387858286:
return 1
else: # if features[0] > 0.034366464387858286
return 0
else: # if features[19] > 0.017310515395365655
if features[0] <= 0.003563929640222341:
if features[2] <= 0.0025456640287302434:
if features[14] <= 0.008909824100555852:
return 1
else: # if features[14] > 0.008909824100555852
return 0
else: # if features[2] > 0.0025456640287302434
if features[19] <= 0.03513016359647736:
return 1
else: # if features[19] > 0.03513016359647736
return 0
else: # if features[0] > 0.003563929640222341
if features[8] <= 0.051931546186096966:
if features[13] <= 0.010182656114920974:
return 1
else: # if features[13] > 0.010182656114920974
return 0
else: # if features[8] > 0.051931546186096966
if features[0] <= 0.034875597193604335:
return 1
else: # if features[0] > 0.034875597193604335
return 0
##################################################
def tree_8b(features):
if features[12] <= 0.0025456640287302434:
if features[2] <= 0.008146124891936779:
if features[19] <= 0.006109593668952584:
if features[19] <= 0.003054796834476292:
if features[17] <= 0.0020365312229841948:
return 0
else: # if features[17] > 0.0020365312229841948
return 0
else: # if features[19] > 0.003054796834476292
if features[2] <= 0.0020365312229841948:
return 0
else: # if features[2] > 0.0020365312229841948
return 0
else: # if features[19] > 0.006109593668952584
if features[19] <= 0.008146124891936779:
if features[18] <= 0.005600460863206536:
return 1
else: # if features[18] > 0.005600460863206536
return 0
else: # if features[19] > 0.008146124891936779
if features[6] <= 0.0010182656114920974:
return 1
else: # if features[6] > 0.0010182656114920974
return 1
else: # if features[2] > 0.008146124891936779
if features[2] <= 0.011200921726413071:
if features[19] <= 0.001527398417238146:
if features[9] <= 0.0025456640287302434:
return 1
else: # if features[9] > 0.0025456640287302434
return 0
else: # if features[19] > 0.001527398417238146
if features[10] <= 0.003054796834476292:
return 1
else: # if features[10] > 0.003054796834476292
return 0
else: # if features[2] > 0.011200921726413071
if features[1] <= 0.012728320143651217:
if features[6] <= 0.009164390503428876:
return 1
else: # if features[6] > 0.009164390503428876
return 0
else: # if features[1] > 0.012728320143651217
return 1
else: # if features[12] > 0.0025456640287302434
if features[19] <= 0.017310515395365655:
if features[2] <= 0.01934704661834985:
if features[0] <= 0.0020365312229841948:
if features[10] <= 0.005600460863206536:
return 0
else: # if features[10] > 0.005600460863206536
return 1
else: # if features[0] > 0.0020365312229841948
if features[3] <= 0.021383577841334045:
return 0
else: # if features[3] > 0.021383577841334045
return 1
else: # if features[2] > 0.01934704661834985
if features[3] <= 0.06465986632974818:
if features[15] <= 0.004582195251714438:
return 1
else: # if features[15] > 0.004582195251714438
return 1
else: # if features[3] > 0.06465986632974818
if features[0] <= 0.03411189798498526:
return 1
else: # if features[0] > 0.03411189798498526
return 0
else: # if features[19] > 0.017310515395365655
if features[0] <= 0.003563929640222341:
if features[2] <= 0.0025456640287302434:
if features[14] <= 0.009164390503428876:
return 1
else: # if features[14] > 0.009164390503428876
return 0
else: # if features[2] > 0.0025456640287302434
if features[19] <= 0.03513016359647736:
return 1
else: # if features[19] > 0.03513016359647736
return 0
else: # if features[0] > 0.003563929640222341
if features[8] <= 0.051931546186096966:
if features[13] <= 0.010182656114920974:
return 1
else: # if features[13] > 0.010182656114920974
return 0
else: # if features[8] > 0.051931546186096966
if features[0] <= 0.03462103079073131:
return 1
else: # if features[0] > 0.03462103079073131
return 0
##################################################
def tree_7b(features):
if features[12] <= 0.003054796834476292:
if features[2] <= 0.008146124891936779:
if features[19] <= 0.006109593668952584:
if features[19] <= 0.003054796834476292:
if features[17] <= 0.0020365312229841948:
return 0
else: # if features[17] > 0.0020365312229841948
return 0
else: # if features[19] > 0.003054796834476292
if features[2] <= 0.0020365312229841948:
return 0
else: # if features[2] > 0.0020365312229841948
return 0
else: # if features[19] > 0.006109593668952584
if features[19] <= 0.008146124891936779:
if features[18] <= 0.005091328057460487:
return 1
else: # if features[18] > 0.005091328057460487
return 0
else: # if features[19] > 0.008146124891936779
if features[6] <= 0.0010182656114920974:
return 1
else: # if features[6] > 0.0010182656114920974
return 1
else: # if features[2] > 0.008146124891936779
if features[2] <= 0.011200921726413071:
if features[19] <= 0.0010182656114920974:
if features[9] <= 0.003054796834476292:
return 1
else: # if features[9] > 0.003054796834476292
return 0
else: # if features[19] > 0.0010182656114920974
if features[10] <= 0.003054796834476292:
return 1
else: # if features[10] > 0.003054796834476292
return 0
else: # if features[2] > 0.011200921726413071
if features[1] <= 0.013237452949397266:
if features[6] <= 0.009164390503428876:
return 1
else: # if features[6] > 0.009164390503428876
return 0
else: # if features[1] > 0.013237452949397266
return 1
else: # if features[12] > 0.003054796834476292
if features[19] <= 0.017310515395365655:
if features[2] <= 0.01934704661834985:
if features[0] <= 0.0020365312229841948:
if features[10] <= 0.005091328057460487:
return 0
else: # if features[10] > 0.005091328057460487
return 1
else: # if features[0] > 0.0020365312229841948
if features[3] <= 0.021383577841334045:
return 0
else: # if features[3] > 0.021383577841334045
return 1
else: # if features[2] > 0.01934704661834985
if features[3] <= 0.06415073352400213:
if features[15] <= 0.005091328057460487:
return 1
else: # if features[15] > 0.005091328057460487
return 1
else: # if features[3] > 0.06415073352400213
if features[0] <= 0.03462103079073131:
return 1
else: # if features[0] > 0.03462103079073131
return 0
else: # if features[19] > 0.017310515395365655
if features[0] <= 0.003054796834476292:
if features[2] <= 0.003054796834476292:
if features[14] <= 0.009164390503428876:
return 1
else: # if features[14] > 0.009164390503428876
return 0
else: # if features[2] > 0.003054796834476292
if features[19] <= 0.03563929640222341:
return 1
else: # if features[19] > 0.03563929640222341
return 0
else: # if features[0] > 0.003054796834476292
if features[8] <= 0.051931546186096966:
if features[13] <= 0.010182656114920974:
return 1
else: # if features[13] > 0.010182656114920974
return 0
else: # if features[8] > 0.051931546186096966
if features[0] <= 0.03462103079073131:
return 1
else: # if features[0] > 0.03462103079073131
return 0
##################################################
def tree_6b(features):
if features[12] <= 0.0020365312229841948:
if features[2] <= 0.008146124891936779:
if features[19] <= 0.006109593668952584:
if features[19] <= 0.0020365312229841948:
if features[17] <= 0.0020365312229841948:
return 0
else: # if features[17] > 0.0020365312229841948
return 0
else: # if features[19] > 0.0020365312229841948
if features[2] <= 0.0020365312229841948:
return 0
else: # if features[2] > 0.0020365312229841948
return 0
else: # if features[19] > 0.006109593668952584
if features[19] <= 0.008146124891936779:
if features[18] <= 0.006109593668952584:
return 1
else: # if features[18] > 0.006109593668952584
return 0
else: # if features[19] > 0.008146124891936779
if features[6] <= 0.0020365312229841948:
return 1
else: # if features[6] > 0.0020365312229841948
return 1
else: # if features[2] > 0.008146124891936779
if features[2] <= 0.010182656114920974:
if features[19] <= 0.0020365312229841948:
if features[9] <= 0.0020365312229841948:
return 1
else: # if features[9] > 0.0020365312229841948
return 0
else: # if features[19] > 0.0020365312229841948
if features[10] <= 0.0020365312229841948:
return 1
else: # if features[10] > 0.0020365312229841948
return 0
else: # if features[2] > 0.010182656114920974
if features[1] <= 0.012219187337905169:
if features[6] <= 0.010182656114920974:
return 1
else: # if features[6] > 0.010182656114920974
return 0
else: # if features[1] > 0.012219187337905169
return 1
else: # if features[12] > 0.0020365312229841948
if features[19] <= 0.018328781006857753:
if features[2] <= 0.018328781006857753:
if features[0] <= 0.0020365312229841948:
if features[10] <= 0.006109593668952584:
return 0
else: # if features[10] > 0.006109593668952584
return 1
else: # if features[0] > 0.0020365312229841948
if features[3] <= 0.022401843452826142:
return 0
else: # if features[3] > 0.022401843452826142
return 1
else: # if features[2] > 0.018328781006857753
if features[3] <= 0.06313246791251004:
if features[15] <= 0.0040730624459683895:
return 1
else: # if features[15] > 0.0040730624459683895
return 1
else: # if features[3] > 0.06313246791251004
if features[0] <= 0.03462103079073131:
return 1
else: # if features[0] > 0.03462103079073131
return 0
else: # if features[19] > 0.018328781006857753
if features[0] <= 0.0040730624459683895:
if features[2] <= 0.0020365312229841948:
if features[14] <= 0.008146124891936779:
return 1
else: # if features[14] > 0.008146124891936779
return 0
else: # if features[2] > 0.0020365312229841948
if features[19] <= 0.03462103079073131:
return 1
else: # if features[19] > 0.03462103079073131
return 0
else: # if features[0] > 0.0040730624459683895
if features[8] <= 0.05091328057460487:
if features[13] <= 0.010182656114920974:
return 1
else: # if features[13] > 0.010182656114920974
return 0
else: # if features[8] > 0.05091328057460487
if features[0] <= 0.03462103079073131:
return 1
else: # if features[0] > 0.03462103079073131
return 0
##################################################
def tree_5b(features):
if features[12] <= 0.0040730624459683895:
if features[2] <= 0.008146124891936779:
if features[19] <= 0.0040730624459683895:
if features[19] <= 0.0040730624459683895:
if features[17] <= 0.0:
return 0
else: # if features[17] > 0.0
return 0
else: # if features[19] > 0.0040730624459683895
if features[2] <= 0.0:
return 0
else: # if features[2] > 0.0
return 0
else: # if features[19] > 0.0040730624459683895
if features[19] <= 0.008146124891936779:
if features[18] <= 0.0040730624459683895:
return 1
else: # if features[18] > 0.0040730624459683895
return 0
else: # if features[19] > 0.008146124891936779
if features[6] <= 0.0:
return 1
else: # if features[6] > 0.0
return 1
else: # if features[2] > 0.008146124891936779
if features[2] <= 0.012219187337905169:
if features[19] <= 0.0:
if features[9] <= 0.0040730624459683895:
return 1
else: # if features[9] > 0.0040730624459683895
return 0
else: # if features[19] > 0.0
if features[10] <= 0.0040730624459683895:
return 1
else: # if features[10] > 0.0040730624459683895
return 0
else: # if features[2] > 0.012219187337905169
if features[1] <= 0.012219187337905169:
if features[6] <= 0.008146124891936779:
return 1
else: # if features[6] > 0.008146124891936779
return 0
else: # if features[1] > 0.012219187337905169
return 1
else: # if features[12] > 0.0040730624459683895
if features[19] <= 0.016292249783873558:
if features[2] <= 0.020365312229841948:
if features[0] <= 0.0:
if features[10] <= 0.0040730624459683895:
return 0
else: # if features[10] > 0.0040730624459683895
return 1
else: # if features[0] > 0.0
if features[3] <= 0.020365312229841948:
return 0
else: # if features[3] > 0.020365312229841948
return 1
else: # if features[2] > 0.020365312229841948
if features[3] <= 0.06109593668952584:
if features[15] <= 0.0040730624459683895:
return 1
else: # if features[15] > 0.0040730624459683895
return 1
else: # if features[3] > 0.06109593668952584
if features[0] <= 0.032584499567747116:
return 1
else: # if features[0] > 0.032584499567747116
return 0
else: # if features[19] > 0.016292249783873558
if features[0] <= 0.0040730624459683895:
if features[2] <= 0.0040730624459683895:
if features[14] <= 0.008146124891936779:
return 1
else: # if features[14] > 0.008146124891936779
return 0
else: # if features[2] > 0.0040730624459683895
if features[19] <= 0.036657562013715506:
return 1
else: # if features[19] > 0.036657562013715506
return 0
else: # if features[0] > 0.0040730624459683895
if features[8] <= 0.052949811797589064:
if features[13] <= 0.012219187337905169:
return 1
else: # if features[13] > 0.012219187337905169
return 0
else: # if features[8] > 0.052949811797589064
if features[0] <= 0.036657562013715506:
return 1
else: # if features[0] > 0.036657562013715506
return 0
##################################################
def tree_4b(features):
if features[12] <= 0.0:
if features[2] <= 0.008146124891936779:
if features[19] <= 0.008146124891936779:
if features[19] <= 0.0:
if features[17] <= 0.0:
return 0
else: # if features[17] > 0.0
return 0
else: # if features[19] > 0.0
if features[2] <= 0.0:
return 0
else: # if features[2] > 0.0
return 0
else: # if features[19] > 0.008146124891936779
if features[19] <= 0.008146124891936779:
if features[18] <= 0.008146124891936779:
return 1
else: # if features[18] > 0.008146124891936779
return 0
else: # if features[19] > 0.008146124891936779
if features[6] <= 0.0:
return 1
else: # if features[6] > 0.0
return 1
else: # if features[2] > 0.008146124891936779
if features[2] <= 0.008146124891936779:
if features[19] <= 0.0:
if features[9] <= 0.0:
return 1
else: # if features[9] > 0.0
return 0
else: # if features[19] > 0.0
if features[10] <= 0.0:
return 1
else: # if features[10] > 0.0
return 0
else: # if features[2] > 0.008146124891936779
if features[1] <= 0.016292249783873558:
if features[6] <= 0.008146124891936779:
return 1
else: # if features[6] > 0.008146124891936779
return 0
else: # if features[1] > 0.016292249783873558
return 1
else: # if features[12] > 0.0
if features[19] <= 0.016292249783873558:
if features[2] <= 0.016292249783873558:
if features[0] <= 0.0:
if features[10] <= 0.008146124891936779:
return 0
else: # if features[10] > 0.008146124891936779
return 1
else: # if features[0] > 0.0
if features[3] <= 0.024438374675810337:
return 0
else: # if features[3] > 0.024438374675810337
return 1
else: # if features[2] > 0.016292249783873558
if features[3] <= 0.05702287424355745:
if features[15] <= 0.008146124891936779:
return 1
else: # if features[15] > 0.008146124891936779
return 1
else: # if features[3] > 0.05702287424355745
if features[0] <= 0.032584499567747116:
return 1
else: # if features[0] > 0.032584499567747116
return 0
else: # if features[19] > 0.016292249783873558
if features[0] <= 0.0:
if features[2] <= 0.0:
if features[14] <= 0.008146124891936779:
return 1
else: # if features[14] > 0.008146124891936779
return 0
else: # if features[2] > 0.0
if features[19] <= 0.032584499567747116:
return 1
else: # if features[19] > 0.032584499567747116
return 0
else: # if features[0] > 0.0
if features[8] <= 0.048876749351620674:
if features[13] <= 0.008146124891936779:
return 1
else: # if features[13] > 0.008146124891936779
return 0
else: # if features[8] > 0.048876749351620674
if features[0] <= 0.032584499567747116:
return 1
else: # if features[0] > 0.032584499567747116
return 0
##################################################
def tree_3b(features):
if features[12] <= 0.0:
if features[2] <= 0.016292249783873558:
if features[19] <= 0.0:
if features[19] <= 0.0:
if features[17] <= 0.0:
return 0
else: # if features[17] > 0.0
return 0
else: # if features[19] > 0.0
if features[2] <= 0.0:
return 0
else: # if features[2] > 0.0
return 0
else: # if features[19] > 0.0
if features[19] <= 0.0:
if features[18] <= 0.0:
return 1
else: # if features[18] > 0.0
return 0
else: # if features[19] > 0.0
if features[6] <= 0.0:
return 1
else: # if features[6] > 0.0
return 1
else: # if features[2] > 0.016292249783873558
if features[2] <= 0.016292249783873558:
if features[19] <= 0.0:
if features[9] <= 0.0:
return 1
else: # if features[9] > 0.0
return 0
else: # if features[19] > 0.0
if features[10] <= 0.0:
return 1
else: # if features[10] > 0.0
return 0
else: # if features[2] > 0.016292249783873558
if features[1] <= 0.016292249783873558:
if features[6] <= 0.016292249783873558:
return 1
else: # if features[6] > 0.016292249783873558
return 0
else: # if features[1] > 0.016292249783873558
return 1
else: # if features[12] > 0.0
if features[19] <= 0.016292249783873558:
if features[2] <= 0.016292249783873558:
if features[0] <= 0.0:
if features[10] <= 0.0:
return 0
else: # if features[10] > 0.0
return 1
else: # if features[0] > 0.0
if features[3] <= 0.016292249783873558:
return 0
else: # if features[3] > 0.016292249783873558
return 1
else: # if features[2] > 0.016292249783873558
if features[3] <= 0.048876749351620674:
if features[15] <= 0.0:
return 1
else: # if features[15] > 0.0
return 1
else: # if features[3] > 0.048876749351620674
if features[0] <= 0.032584499567747116:
return 1
else: # if features[0] > 0.032584499567747116
return 0
else: # if features[19] > 0.016292249783873558
if features[0] <= 0.0:
if features[2] <= 0.0:
if features[14] <= 0.016292249783873558:
return 1
else: # if features[14] > 0.016292249783873558
return 0
else: # if features[2] > 0.0
if features[19] <= 0.032584499567747116:
return 1
else: # if features[19] > 0.032584499567747116
return 0
else: # if features[0] > 0.0
if features[8] <= 0.048876749351620674:
if features[13] <= 0.016292249783873558:
return 1
else: # if features[13] > 0.016292249783873558
return 0
else: # if features[8] > 0.048876749351620674
if features[0] <= 0.032584499567747116:
return 1
else: # if features[0] > 0.032584499567747116
return 0
##################################################
def tree_2b(features):
if features[12] <= 0.0:
if features[2] <= 0.0:
if features[19] <= 0.0:
if features[19] <= 0.0:
if features[17] <= 0.0:
return 0
else: # if features[17] > 0.0
return 0
else: # if features[19] > 0.0
if features[2] <= 0.0:
return 0
else: # if features[2] > 0.0
return 0
else: # if features[19] > 0.0
if features[19] <= 0.0:
if features[18] <= 0.0:
return 1
else: # if features[18] > 0.0
return 0
else: # if features[19] > 0.0
if features[6] <= 0.0:
return 1
else: # if features[6] > 0.0
return 1
else: # if features[2] > 0.0
if features[2] <= 0.0:
if features[19] <= 0.0:
if features[9] <= 0.0:
return 1
else: # if features[9] > 0.0
return 0
else: # if features[19] > 0.0
if features[10] <= 0.0:
return 1
else: # if features[10] > 0.0
return 0
else: # if features[2] > 0.0
if features[1] <= 0.0:
if features[6] <= 0.0:
return 1
else: # if features[6] > 0.0
return 0
else: # if features[1] > 0.0
return 1
else: # if features[12] > 0.0
if features[19] <= 0.032584499567747116:
if features[2] <= 0.032584499567747116:
if features[0] <= 0.0:
if features[10] <= 0.0:
return 0
else: # if features[10] > 0.0
return 1
else: # if features[0] > 0.0
if features[3] <= 0.032584499567747116:
return 0
else: # if features[3] > 0.032584499567747116
return 1
else: # if features[2] > 0.032584499567747116
if features[3] <= 0.032584499567747116:
if features[15] <= 0.0:
return 1
else: # if features[15] > 0.0
return 1
else: # if features[3] > 0.032584499567747116
if features[0] <= 0.032584499567747116:
return 1
else: # if features[0] > 0.032584499567747116
return 0
else: # if features[19] > 0.032584499567747116
if features[0] <= 0.0:
if features[2] <= 0.0:
if features[14] <= 0.0:
return 1
else: # if features[14] > 0.0
return 0
else: # if features[2] > 0.0
if features[19] <= 0.032584499567747116:
return 1
else: # if features[19] > 0.032584499567747116
return 0
else: # if features[0] > 0.0
if features[8] <= 0.032584499567747116:
if features[13] <= 0.0:
return 1
else: # if features[13] > 0.0
return 0
else: # if features[8] > 0.032584499567747116
if features[0] <= 0.032584499567747116:
return 1
else: # if features[0] > 0.032584499567747116
return 0
##################################################
|
class Employee:
def __init__(self, name, emp_id, email_id):
self.__name=name
self.__emp_id=emp_id
self.__email_id=email_id
def get_name(self):
return self.__name
def get_emp_id(self):
return self.__emp_id
def get_email_id(self):
return self.__email_id
class OrganizationDirectory:
def __init__(self,emp_list):
self.__emp_list=emp_list
def lookup(self,key_name):
result_list=[]
for emp in self.__emp_list:
if(key_name in emp.get_name()):
result_list.append(emp)
self.display(result_list)
return result_list
def display(self,result_list):
print("Search results:")
for emp in result_list:
print(emp.get_name()," ", emp.get_emp_id()," ",emp.get_email_id())
emp1=Employee("Kevin",24089, "Kevin_xyz@organization.com")
emp2=Employee("Jack",56789,"Jack_xyz@organization.com")
emp3=Employee("Jackson",67895,"Jackson_xyz@organization.com")
emp4=Employee("Henry Jack",23456,"Jacky_xyz@organization.com")
emp_list=[emp1,emp2,emp3,emp4]
org_dir=OrganizationDirectory(emp_list)
#Search for an employee
org_dir.lookup("KEVIN") |
class tablecloumninfo:
col_name=""
data_type=""
comment=""
def __init__(self,col_name,data_type,comment):
self.col_name=col_name
self.data_type=data_type
self.comment=comment
|
class GraphLearner:
"""Base class for causal discovery methods.
Subclasses implement different discovery methods. All discovery methods are in the package "dowhy.causal_discoverers"
"""
def __init__(self, data, library_class, *args, **kwargs):
self._data = data
self._labels = list(self._data.columns)
self._adjacency_matrix = None
self._graph_dot = None
def learn_graph(self):
'''
Discover causal graph and the graph in DOT format.
'''
raise NotImplementedError
|
"""
aiida_crystal_dft
AiiDA plugin for running the CRYSTAL code
"""
__version__ = "0.8"
|
class attributes_de:
def __init__(self,threshold_list,range_for_r):
self.country_name = 'Germany'
self.population = 83190556
self.url = 'https://opendata.arcgis.com/datasets/dd4580c810204019a7b8eb3e0b329dd6_0.geojson'
self.contains_tests=False
self.csv=False # if the resources have csv format
self.CasesPer100k_thresholds=threshold_list
self.Range_for_R=range_for_r
self.color_sizes = dict(
colorEvenRows = '#FFE6D9',
colorOddRows = 'white',
colorHeaderBG= '#FFCE00',
sizeHeaderFont = 14,
colorHeaderFont='black',
colorCellFont = 'black',
sizeCellFont = 12,
colorTitle = 'black',
sizeTitleFont = 27,
colorPivotColumnText='#DD0000'
)
# https://www.data.gouv.fr/fr/datasets/synthese-des-indicateurs-de-suivi-de-lepidemie-covid-19/
class attributes_fr:
def __init__(self,threshold_list,range_for_r):
self.country_name = 'France'
self.population = 67406000
self.url = "https://www.data.gouv.fr/fr/datasets/r/f335f9ea-86e3-4ffa-9684-93c009d5e617"
self.contains_tests=True
self.csv_encoding='latin'
self.csv_separator=','
self.csv=True # if the resources have csv format
self.CasesPer100k_thresholds=threshold_list
self.Range_for_R=range_for_r
self.color_sizes=dict(
colorEvenRows = '#FFE6D9', #'#FFE3F1'#'#FFAFAE'
colorOddRows = 'white',
colorHeaderBG='#001489',
sizeHeaderFont = 14,
colorHeaderFont='white',
colorCellFont = 'black',
sizeCellFont = 12,
colorTitle = '#001489',
sizeTitleFont = 27,
colorPivotColumnText='#001489'
)
class attributes_at:
def __init__(self,threshold_list,range_for_r):
self.country_name = 'Austria'
self.population = 8901064
self.url="https://covid19-dashboard.ages.at/data/CovidFaelle_Timeline.csv"
self.contains_tests=False
self.csv_encoding='utf-8'
self.csv_separator=';'
self.csv=True # if the resources have csv format
self.CasesPer100k_thresholds=threshold_list
self.Range_for_R=range_for_r
self.color_sizes=dict(
colorEvenRows = '#F3EED9', #'#FFE3F1'#'#FFAFAE'
colorOddRows = 'white',
colorHeaderBG='#ED2939',
sizeHeaderFont = 14,
colorHeaderFont='white',
colorCellFont = 'black',
sizeCellFont = 12,
colorTitle = '#ED2939',
sizeTitleFont = 27,
colorPivotColumnText='#ED2939'
)
# Austria: What the fuck?! The way data is published I would guess this country is a banana republic
class attributes_be:
def __init__(self,threshold_list,range_for_r):
self.country_name = 'Belgium'
self.population = 11492641
self.url = 'https://epistat.sciensano.be/Data/COVID19BE_tests.json'
self.contains_tests=True
self.csv=False # if the resources have csv format
self.CasesPer100k_thresholds=threshold_list
self.Range_for_R=range_for_r
self.color_sizes = dict(
colorEvenRows = '#FFE6D9',
colorOddRows = 'white',
colorHeaderBG= '#FDDA24',
sizeHeaderFont = 14,
colorHeaderFont='black',
colorCellFont = 'black',
sizeCellFont = 12,
colorTitle = 'black',
sizeTitleFont = 27,
colorPivotColumnText='#EF3340'
)
class attributes_lv:
def __init__(self,threshold_list,range_for_r):
self.country_name = 'Latvia'
self.population = 1907675
self.url = 'https://data.gov.lv/dati/eng/api/3/action/datastore_search_sql?sql=SELECT%20*%20from%20%22d499d2f0-b1ea-4ba2-9600-2c701b03bd4a%22'
self.contains_tests=True
self.csv=False # if the resources have csv format
self.CasesPer100k_thresholds=threshold_list
self.Range_for_R=range_for_r
self.color_sizes=dict(
colorEvenRows = '#F3EED9', #'#FFE3F1'#'#FFAFAE'
colorOddRows = 'white',
colorHeaderBG='#9E3039',
sizeHeaderFont = 14,
colorHeaderFont='white',
colorCellFont = 'black',
sizeCellFont = 12,
colorTitle = '#9E3039',
sizeTitleFont = 27,
colorPivotColumnText='#9E3039'
)
def get_attributes(country,threshold_list=[10,20,50,100,200,400,600,800,1000],range_for_r=[0.8,0.85,0.9,0.95,1.05,1.1,1.15,1.2]):
"""
Gets the country specific attributes like Name, population, url etc.
Parameters
----------
country : str
A two letter color code for a country e.g. 'de' for Germany
thresholds_list : list
optional: A list of integers representing the threshold which R has to go above or below
range_for_r : list
optional: A list of floats representing the range of R
Returns
-------
class
Class with the country specific attributes. Also contains a color scheme class for this country
"""
try:
if country=='de':
attributes=attributes_de(threshold_list,range_for_r)
elif country=='fr':
attributes=attributes_fr(threshold_list,range_for_r)
elif country=='at':
attributes=attributes_at(threshold_list,range_for_r)
elif country=='be':
attributes=attributes_be(threshold_list,range_for_r)
elif country=='lv':
attributes=attributes_lv(threshold_list,range_for_r)
else:
print("Error no such country attribute defined")
return attributes
except Exception as e:
print(e)
# de -> Germany attributes
# lv -> Latvia attributes
# de |
"""
Common bazel version requirements for tests
"""
CURRENT_BAZEL_VERSION = "5.0.0"
OTHER_BAZEL_VERSIONS = [
"4.2.2",
]
SUPPORTED_BAZEL_VERSIONS = [
CURRENT_BAZEL_VERSION,
] + OTHER_BAZEL_VERSIONS
|
# See also examples/example_track/track_meta.py for a longer, commented example
track = dict(
author_username='dansbecker',
course_name='Machine Learning',
course_url='https://www.kaggle.com/learn/intro-to-machine-learning'
)
lessons = [
dict(
topic='Your First BiqQuery ML Model',
),
]
notebooks = [
dict(
filename='tut1.ipynb',
lesson_idx=0,
type='tutorial',
scriptid=4076893,
),
dict(
filename='ex1.ipynb',
lesson_idx=0,
type='exercise',
scriptid=4077160,
),
]
|
class Solution:
def canThreePartsEqualSum(self, A: List[int]) -> bool:
# Since all the three parts are equal, if we sum all element of arrary it should be a multiplication of 3
# so the sum of each part must be equal to sum of all element divided by 3
quotient, remainder = divmod(sum(A), 3)
if remainder != 0:
return False
subarray = 0
partitions = 0
for num in A:
subarray += num
if subarray == quotient:
partitions += 1
subarray = 0
# Check if it consist at least 3 partitions
return partitions >= 3 |
STATE_CITY = "fluids_state_city"
OBS_QLIDAR = "fluids_obs_qlidar"
OBS_GRID = "fluids_obs_grid"
OBS_BIRDSEYE = "fluids_obs_birdseye"
OBS_NONE = "fluids_obs_none"
BACKGROUND_CSP = "fluids_background_csp"
BACKGROUND_NULL = "fluids_background_null"
REWARD_PATH = "fluids_reward_path"
REWARD_NONE = "fluids_reward_none"
RIGHT = "RIGHT"
LEFT = "LEFT"
STRAIGHT = "STRAIGHT"
RED = (0xf6, 0x11, 0x46)
YELLOW = (0xfc, 0xef, 0x5e),
GREEN = (0, 0xc6, 0x44)
|
class Solution:
def generate(self, num_rows):
if num_rows == 0:
return []
ans = [1]
result = [ans]
for _ in range(num_rows - 1):
ans = [1] + [ans[i] + ans[i + 1] for i in range(len(ans[:-1]))] + [1]
result.append(ans)
return result
|
for testcase in range(int(input())):
n = int(input())
dict = {}
comb = 1
m = (10**9)+7
for x in input().split():
no = int(x)
try:
dict[no] = dict[no] + 1
except:
dict[no] = 1
dict = list(dict.items())
dict.sort(key=lambda x: x[0], reverse=True)
dict = [x[1] for x in dict]
for ind in range(len(dict)):
if dict[ind]==0:
continue
if (dict[ind]%2==0):
for j in range(dict[ind]-1,2,-2):
comb = (comb*j) % m
else:
for j in range(dict[ind],2,-2):
comb = (comb*j) % m
comb = (comb*dict[ind+1]) % m
dict[ind+1] -= 1
print(comb)
|
class Timer:
def __init__(self, duration, ticks):
self.duration = duration
self.ticks = ticks
self.thread = None
def start(self):
pass
# start Thread here
|
#MAIN PROGRAM STARTS HERE:
num = int(input('Enter the number of rows and columns for the square: '))
for x in range(1, num + 1):
for y in range(1, num - 2 + 1):
print ('{} {} '.format(x, y), end='')
print() |
class PrivilegeNotHeldException(UnauthorizedAccessException):
"""
The exception that is thrown when a method in the System.Security.AccessControl namespace attempts to enable a privilege that it does not have.
PrivilegeNotHeldException()
PrivilegeNotHeldException(privilege: str)
PrivilegeNotHeldException(privilege: str,inner: Exception)
"""
def ZZZ(self):
"""hardcoded/mock instance of the class"""
return PrivilegeNotHeldException()
instance=ZZZ()
"""hardcoded/returns an instance of the class"""
def GetObjectData(self,info,context):
"""
GetObjectData(self: PrivilegeNotHeldException,info: SerializationInfo,context: StreamingContext)
Sets the info parameter with information about the exception.
info: The System.Runtime.Serialization.SerializationInfo that holds the serialized object data about the exception being thrown.
context: The System.Runtime.Serialization.StreamingContext that contains contextual information about the source or destination.
"""
pass
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
@staticmethod
def __new__(self,privilege=None,inner=None):
"""
__new__(cls: type)
__new__(cls: type,privilege: str)
__new__(cls: type,privilege: str,inner: Exception)
"""
pass
def __reduce_ex__(self,*args):
pass
def __str__(self,*args):
pass
PrivilegeName=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets the name of the privilege that is not enabled.
Get: PrivilegeName(self: PrivilegeNotHeldException) -> str
"""
SerializeObjectState=None
|
def segmented_sieve(n):
# Create an boolean array with all values True
primes = [True]*n
for p in range(2,n):
#If prime[p] is True,it is a prime and its multiples are not prime
if primes[p]:
for i in range(2*p,n,p):
# Mark every multiple of a prime as not prime
primes[i]=False
#If value is true it is prime and print value
for l in range(2,n):
if primes[l]:
print(f"{l} ")
#Test
while True:
try:
input_value = int(input("Please a number: "))
segmented_sieve(input_value)
break
except ValueError:
print("No valid integer! Please try again ...") |
# Fonte: https://leetcode.com/problems/string-to-integer-atoi/
# Autor: Bruno Harlis
# Data: 03/08/2021
"""
Implemente a função myAtoi(string s), que converte uma string em um
inteiro assinado de 32 bits (semelhante à função C / C ++ atoi).
O algoritmo para myAtoi(string s) é o seguinte:
Leia e ignore qualquer espaço em branco à esquerda.
Verifique se o próximo caractere (se ainda não estiver no final da string)
é '-' ou '+'. Leia este caractere se for algum. Isso determina se o resultado
final é negativo ou positivo, respectivamente. Suponha que o resultado seja
positivo se nenhum estiver presente.
Leia a seguir os caracteres até que o próximo caractere não digitado ou o
final da entrada seja alcançado. O resto da string é ignorado.
Converta esses dígitos em um número inteiro (ou seja "123" -> 123, "0032" -> 32).
Se nenhum dígito foi lido, o número inteiro é 0. Altere o sinal conforme
necessário (da etapa 2).
Se o inteiro estiver fora do intervalo de inteiros com sinal de 32 bits, fixe
o inteiro para que ele permaneça no intervalo. Especificamente, números inteiros
menores do que deveriam ser fixados e inteiros maiores do que deveriam ser fixados.
[-231, 231 - 1]-231-231231 - 1231 - 1
Retorne o inteiro como o resultado final.
Observação:
Apenas o caractere de espaço ' ' é considerado um caractere de espaço em branco.
Não ignore nenhum caractere além do espaço em branco inicial ou o resto da string após os dígitos.
Tempo de execução : 36 ms, mais rápido que 60,05 % dos envios.
Uso da memória : 14,5 MB, menos de 26,10 % dos envios.
"""
def myAtoi(s):
s = s.strip()
negativo = False
i = 0
r = 0
if len(s) == 0:
return 0
if s[i] == '-':
negativo = True
i += 1
elif s[i] == '+':
i += 1
while i < len(s):
if s[i].isnumeric():
temp = int(s[i:i+1])
r = r * 10 + temp
if negativo:
if r * -1 < -2**31:
return -2**31
elif r > 2**31 - 1:
return 2**31 - 1
i += 1
else:
break
return r * -1 if negativo else r
|
def test_test():
"""A generic test
:return:
"""
assert True
|
class AuxPowMixin(object):
AUXPOW_START_HEIGHT = 0
AUXPOW_CHAIN_ID = 0x0001
BLOCK_VERSION_AUXPOW_BIT = 0
@classmethod
def is_auxpow_active(cls, header) -> bool:
height_allows_auxpow = header['block_height'] >= cls.AUXPOW_START_HEIGHT
version_allows_auxpow = header['version'] & cls.BLOCK_VERSION_AUXPOW_BIT
return height_allows_auxpow and version_allows_auxpow |
#!/usr/bin/env python3
#filter sensitive words in user's input
def replace_sensitive_words(input_word):
s_words = []
with open('filtered_words','r') as f:
line = f.readline()
while line != '':
s_words.append(line.strip())
line = f.readline()
for word in s_words:
if word in input_word:
input_word = input_word.replace(word, "**")
print(input_word)
if __name__ == '__main__':
while True:
input_word = input('--> ')
replace_sensitive_words(input_word)
|
#Faça um algoritimo que leia o preço de um produto e mostre o seu novo preço com 5% de desconto.
price = float(input("Digite o preço do produto: "))
sale = price - (price * 0.05)
print("O valor bruto do produto é: {:.2f}R$.".format(price))
print("Com o desconto de 5%: {:.2f}R$".format(sale)) |
#Calcular el salario neto de un tnrabajador en fucion del numero de horas trabajadas, el precio de la hora
#y el descuento fijo al sueldo base por concepto de impuestos del 20%
horas = float(input("Ingrese el numero de horas trabajadas: "))
precio_hora = float(input("Ingrese el precio por hora trabajada: "))
sueldo_base = float(input("Ingrese el valor del sueldo base: "))
pago_hora = horas * precio_hora
impuesto = 0.2
salario_neto = pago_hora + (sueldo_base * 0.8)
print(f"Si el trabajador tiene un sueldo base de {sueldo_base}$ (al cual se le descuenta un 20% por impuestos), trabaja {horas} horas, y la hora se le paga a {precio_hora}$.")
print(f"El salario neto del trabajador es de {salario_neto}$") |
# Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Actions to manipulate debug symbol outputs."""
load("@build_bazel_rules_apple//apple/bundling:file_actions.bzl", "file_actions")
def _collect_linkmaps(ctx, debug_outputs, bundle_name):
"""Collects the available linkmaps from the binary.
Args:
ctx: The current context.
debug_outputs: dSYM bundle binary provider.
bundle_name: Anticipated name of the dSYM bundle.
Returns:
A list of linkmap files, one per linked architecture.
"""
outputs = []
actions = ctx.actions
# TODO(b/36174487): Iterate over .items() once the Map/dict problem is fixed.
for arch in debug_outputs.outputs_map:
arch_outputs = debug_outputs.outputs_map[arch]
linkmap = arch_outputs["linkmap"]
out_linkmap = actions.declare_file("%s_%s.linkmap" % (bundle_name, arch))
outputs.append(out_linkmap)
file_actions.symlink(ctx, linkmap, out_linkmap)
return outputs
def _create_symbol_bundle(ctx, debug_outputs, bundle_name, bundle_extension = ""):
"""Creates the .dSYM bundle next to the output archive.
The generated bundle will have the same name as the bundle being built
(including its extension), but with the ".dSYM" extension appended to it.
If the target being built does not have a binary or if the build it not
generating debug symbols (`--apple_generate_dsym` is not provided), then this
function is a no-op that returns an empty list.
This function assumes that the target has a user-provided binary in the
`binary` attribute. It is the responsibility of the caller to check this.
Args:
ctx: The Skylark context.
debug_outputs: dSYM bundle binary provider.
bundle_name: Anticipated name of the dSYM bundle.
bundle_extension: Anticipated extension of the dSYM bundle, empty string if
it does not have one.
Returns:
A list of files that comprise the .dSYM bundle, which should be returned as
additional outputs from the rule.
"""
dsym_bundle_name = bundle_name + bundle_extension + ".dSYM"
outputs = []
actions = ctx.actions
# TODO(b/36174487): Iterate over .items() once the Map/dict problem is fixed.
for arch in debug_outputs.outputs_map:
arch_outputs = debug_outputs.outputs_map[arch]
dsym_binary = arch_outputs["dsym_binary"]
out_symbols = actions.declare_file("%s/Contents/Resources/DWARF/%s_%s" % (
dsym_bundle_name,
bundle_name,
arch,
))
outputs.append(out_symbols)
file_actions.symlink(ctx, dsym_binary, out_symbols)
# If we found any outputs, create the Info.plist for the bundle as well;
# otherwise, we just return the empty list. The plist generated by dsymutil
# only varies based on the bundle name, so we regenerate it here rather than
# propagate the other one from the apple_binary. (See
# https://github.com/llvm-mirror/llvm/blob/master/tools/dsymutil/dsymutil.cpp)
if outputs:
out_plist = actions.declare_file("%s/Contents/Info.plist" %
dsym_bundle_name)
outputs.append(out_plist)
actions.expand_template(
template = ctx.file._dsym_info_plist_template,
output = out_plist,
substitutions = {
"%bundle_name_with_extension%": bundle_name + bundle_extension,
},
)
return outputs
# Define the loadable module that lists the exported symbols in this file.
debug_symbol_actions = struct(
collect_linkmaps = _collect_linkmaps,
create_symbol_bundle = _create_symbol_bundle,
)
|
class Runtime:
@staticmethod
def v3(major: str, feature: str, ml_type: str = None, scala_version: str = "2.12"):
if ml_type and ml_type.lower() not in ["cpu", "gpu"]:
raise ValueError('"ml_type" can only be "cpu" or "gpu"!')
return "".join(
[
f"{major}.",
f"{feature}.x",
"" if not ml_type else f"-{ml_type}-ml",
f"-scala{scala_version}",
]
)
@staticmethod
def v2(
major: str,
feature: str,
maintenance: str,
runtime_version: str,
scala_version: str = "2.11",
):
raise ValueError("This version of runtime is no longer supported!")
@staticmethod
def light(major: str, feature: str, scala_version: str = "2.11"):
return f"apache-spark.{major}.{feature}.x-scala{scala_version}"
|
s = 'abc'; print(s.isupper(), s)
s = 'Abc'; print(s.isupper(), s)
s = 'aBc'; print(s.isupper(), s)
s = 'abC'; print(s.isupper(), s)
s = 'abc'; print(s.isupper(), s)
s = 'ABC'; print(s.isupper(), s)
s = 'abc'; print(s.capitalize().isupper(), s.capitalize())
|
#!/usr/bin/env python
'''
Global Variables convention:
* start with UpperCase
* have no _ character
* may have mid UpperCase words
'''
Debug = True
Silent = True
Verbose = False
CustomerName = 'customer_name'
AuthHeader = {'Content-Type': 'application/json'}
BaseURL = "https://firewall-api.d-zone.ca"
AuthURL = 'https://firewall-auth.d-zone.ca/auth/realms/D-ZoneFireWall/protocol/openid-connect/token'
|
"""Base observer class for weighmail operations.
"""
class BaseObserver(object):
"""Base observer class; does nothing."""
def searching(self, label):
"""Called when the search process has started for a label"""
pass
def labeling(self, label, count):
"""Called when the labelling process has started for a given label
label - the label we are working on
count - number of messages to label
"""
pass
def done_labeling(self, label, count):
"""Called when finished labelling for a given label
label - the label we were working on
count - number of messages that were labelled
"""
pass
def done(self):
"""Called when completely finished"""
pass
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2021/12/4 22:00
# @Author : weihuchao
def insert_sort(data):
"""
从前往后遍历, 假定前面部分已经有序, 查看当前元素应该在前面部分的哪个位置
"""
for idx in range(1, len(data)):
tmp = data[idx]
j = idx - 1
while j >= 0 and tmp < data[j]:
data[j + 1] = data[j]
j = j - 1
data[j + 1] = tmp
|
#
# PySNMP MIB module FUNI-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/FUNI-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:03:03 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)
#
ObjectIdentifier, OctetString, Integer = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "OctetString", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsUnion, SingleValueConstraint, ValueRangeConstraint, ConstraintsIntersection, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ValueRangeConstraint", "ConstraintsIntersection", "ValueSizeConstraint")
ifIndex, = mibBuilder.importSymbols("IF-MIB", "ifIndex")
NotificationGroup, ModuleCompliance, ObjectGroup = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup")
TimeTicks, enterprises, MibIdentifier, Counter32, MibScalar, MibTable, MibTableRow, MibTableColumn, iso, Gauge32, ObjectIdentity, NotificationType, ModuleIdentity, Bits, Integer32, Unsigned32, Counter64, IpAddress = mibBuilder.importSymbols("SNMPv2-SMI", "TimeTicks", "enterprises", "MibIdentifier", "Counter32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "iso", "Gauge32", "ObjectIdentity", "NotificationType", "ModuleIdentity", "Bits", "Integer32", "Unsigned32", "Counter64", "IpAddress")
TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString")
atmfFuniMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 353, 5, 6, 1))
if mibBuilder.loadTexts: atmfFuniMIB.setLastUpdated('9705080000Z')
if mibBuilder.loadTexts: atmfFuniMIB.setOrganization('The ATM Forum')
atmForum = MibIdentifier((1, 3, 6, 1, 4, 1, 353))
atmForumNetworkManagement = MibIdentifier((1, 3, 6, 1, 4, 1, 353, 5))
atmfFuni = MibIdentifier((1, 3, 6, 1, 4, 1, 353, 5, 6))
funiMIBObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1))
class FuniValidVpi(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ValueRangeConstraint(0, 255)
class FuniValidVci(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ValueRangeConstraint(0, 65535)
funiIfConfTable = MibTable((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 1), )
if mibBuilder.loadTexts: funiIfConfTable.setStatus('current')
funiIfConfEntry = MibTableRow((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 1, 1), ).setIndexNames((0, "IF-MIB", "ifIndex"))
if mibBuilder.loadTexts: funiIfConfEntry.setStatus('current')
funiIfConfMode = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("mode1a", 1), ("mode1b", 2), ("mode3", 3), ("mode4", 4))).clone('mode1a')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: funiIfConfMode.setStatus('current')
funiIfConfFcsBits = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("fcsBits16", 1), ("fcsBits32", 2))).clone('fcsBits16')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: funiIfConfFcsBits.setStatus('current')
funiIfConfSigSupport = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2))).clone('disabled')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: funiIfConfSigSupport.setStatus('current')
funiIfConfSigVpi = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 1, 1, 4), FuniValidVpi()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: funiIfConfSigVpi.setStatus('current')
funiIfConfSigVci = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 1, 1, 5), FuniValidVci().clone(5)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: funiIfConfSigVci.setStatus('current')
funiIfConfIlmiSupport = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 1, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2))).clone('disabled')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: funiIfConfIlmiSupport.setStatus('current')
funiIfConfIlmiVpi = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 1, 1, 7), FuniValidVpi()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: funiIfConfIlmiVpi.setStatus('current')
funiIfConfIlmiVci = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 1, 1, 8), FuniValidVci().clone(16)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: funiIfConfIlmiVci.setStatus('current')
funiIfConfOamSupport = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 1, 1, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2))).clone('disabled')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: funiIfConfOamSupport.setStatus('current')
funiIfStatsTable = MibTable((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 2), )
if mibBuilder.loadTexts: funiIfStatsTable.setStatus('current')
funiIfStatsEntry = MibTableRow((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 2, 1), ).setIndexNames((0, "IF-MIB", "ifIndex"))
if mibBuilder.loadTexts: funiIfStatsEntry.setStatus('current')
funiIfEstablishedPvccs = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 2, 1, 1), Gauge32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiIfEstablishedPvccs.setStatus('current')
funiIfEstablishedSvccs = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 2, 1, 2), Gauge32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiIfEstablishedSvccs.setStatus('current')
funiIfRxAbortedFrames = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 2, 1, 3), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiIfRxAbortedFrames.setStatus('current')
funiIfRxTooShortFrames = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 2, 1, 4), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiIfRxTooShortFrames.setStatus('current')
funiIfRxTooLongFrames = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 2, 1, 5), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiIfRxTooLongFrames.setStatus('current')
funiIfRxFcsErrFrames = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 2, 1, 6), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiIfRxFcsErrFrames.setStatus('current')
funiIfRxUnknownFaFrames = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 2, 1, 7), Counter32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: funiIfRxUnknownFaFrames.setStatus('current')
funiIfRxDiscardedFrames = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 2, 1, 8), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiIfRxDiscardedFrames.setStatus('current')
funiIfTxTooLongFrames = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 2, 1, 9), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiIfTxTooLongFrames.setStatus('current')
funiIfTxLenErrFrames = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 2, 1, 10), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiIfTxLenErrFrames.setStatus('current')
funiIfTxCrcErrFrames = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 2, 1, 11), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiIfTxCrcErrFrames.setStatus('current')
funiIfTxPartialFrames = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 2, 1, 12), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiIfTxPartialFrames.setStatus('current')
funiIfTxTimeOutFrames = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 2, 1, 13), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiIfTxTimeOutFrames.setStatus('current')
funiIfTxDiscardedFrames = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 2, 1, 14), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiIfTxDiscardedFrames.setStatus('current')
funiVclStatsTable = MibTable((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 3), )
if mibBuilder.loadTexts: funiVclStatsTable.setStatus('current')
funiVclStatsEntry = MibTableRow((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 3, 1), ).setIndexNames((0, "IF-MIB", "ifIndex"), (0, "FUNI-MIB", "funiVclFaVpi"), (0, "FUNI-MIB", "funiVclFaVci"))
if mibBuilder.loadTexts: funiVclStatsEntry.setStatus('current')
funiVclFaVpi = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 3, 1, 1), FuniValidVpi())
if mibBuilder.loadTexts: funiVclFaVpi.setStatus('current')
funiVclFaVci = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 3, 1, 2), FuniValidVci())
if mibBuilder.loadTexts: funiVclFaVci.setStatus('current')
funiVclRxClp0Frames = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 3, 1, 3), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiVclRxClp0Frames.setStatus('current')
funiVclRxTotalFrames = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 3, 1, 4), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiVclRxTotalFrames.setStatus('current')
funiVclTxClp0Frames = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 3, 1, 5), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiVclTxClp0Frames.setStatus('current')
funiVclTxTotalFrames = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 3, 1, 6), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiVclTxTotalFrames.setStatus('current')
funiVclRxClp0Octets = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 3, 1, 7), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiVclRxClp0Octets.setStatus('current')
funiVclRxTotalOctets = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 3, 1, 8), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiVclRxTotalOctets.setStatus('current')
funiVclTxClp0Octets = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 3, 1, 9), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiVclTxClp0Octets.setStatus('current')
funiVclTxTotalOctets = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 3, 1, 10), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiVclTxTotalOctets.setStatus('current')
funiVclRxErrors = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 3, 1, 11), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiVclRxErrors.setStatus('current')
funiVclTxErrors = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 3, 1, 12), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiVclTxErrors.setStatus('current')
funiVclRxOamFrames = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 3, 1, 13), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiVclRxOamFrames.setStatus('current')
funiVclTxOamFrames = MibTableColumn((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 1, 3, 1, 14), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: funiVclTxOamFrames.setStatus('current')
funiMIBConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 2))
funiMIBCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 2, 1))
funiMIBGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 2, 2))
funiMIBCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 2, 1, 1)).setObjects(("FUNI-MIB", "funiIfConfMinGroup"), ("FUNI-MIB", "funiIfStatsMinGroup"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
funiMIBCompliance = funiMIBCompliance.setStatus('current')
funiIfConfMinGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 2, 2, 1)).setObjects(("FUNI-MIB", "funiIfConfMode"), ("FUNI-MIB", "funiIfConfFcsBits"), ("FUNI-MIB", "funiIfConfSigSupport"), ("FUNI-MIB", "funiIfConfSigVpi"), ("FUNI-MIB", "funiIfConfSigVci"), ("FUNI-MIB", "funiIfConfIlmiSupport"), ("FUNI-MIB", "funiIfConfIlmiVpi"), ("FUNI-MIB", "funiIfConfIlmiVci"), ("FUNI-MIB", "funiIfConfOamSupport"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
funiIfConfMinGroup = funiIfConfMinGroup.setStatus('current')
funiIfStatsMinGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 2, 2, 2)).setObjects(("FUNI-MIB", "funiIfEstablishedPvccs"), ("FUNI-MIB", "funiIfEstablishedSvccs"), ("FUNI-MIB", "funiIfRxAbortedFrames"), ("FUNI-MIB", "funiIfRxTooShortFrames"), ("FUNI-MIB", "funiIfRxTooLongFrames"), ("FUNI-MIB", "funiIfRxFcsErrFrames"), ("FUNI-MIB", "funiIfRxUnknownFaFrames"), ("FUNI-MIB", "funiIfRxDiscardedFrames"), ("FUNI-MIB", "funiIfTxTooLongFrames"), ("FUNI-MIB", "funiIfTxLenErrFrames"), ("FUNI-MIB", "funiIfTxCrcErrFrames"), ("FUNI-MIB", "funiIfTxPartialFrames"), ("FUNI-MIB", "funiIfTxTimeOutFrames"), ("FUNI-MIB", "funiIfTxDiscardedFrames"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
funiIfStatsMinGroup = funiIfStatsMinGroup.setStatus('current')
funiVclStatsOptionalGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 353, 5, 6, 1, 2, 2, 3)).setObjects(("FUNI-MIB", "funiVclRxClp0Frames"), ("FUNI-MIB", "funiVclRxTotalFrames"), ("FUNI-MIB", "funiVclTxClp0Frames"), ("FUNI-MIB", "funiVclTxTotalFrames"), ("FUNI-MIB", "funiVclRxClp0Octets"), ("FUNI-MIB", "funiVclRxTotalOctets"), ("FUNI-MIB", "funiVclTxClp0Octets"), ("FUNI-MIB", "funiVclTxTotalOctets"), ("FUNI-MIB", "funiVclRxErrors"), ("FUNI-MIB", "funiVclTxErrors"), ("FUNI-MIB", "funiVclRxOamFrames"), ("FUNI-MIB", "funiVclTxOamFrames"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
funiVclStatsOptionalGroup = funiVclStatsOptionalGroup.setStatus('current')
mibBuilder.exportSymbols("FUNI-MIB", funiVclRxErrors=funiVclRxErrors, funiVclTxClp0Octets=funiVclTxClp0Octets, funiVclTxClp0Frames=funiVclTxClp0Frames, funiIfConfIlmiSupport=funiIfConfIlmiSupport, funiIfConfMode=funiIfConfMode, FuniValidVpi=FuniValidVpi, funiIfEstablishedPvccs=funiIfEstablishedPvccs, funiIfTxCrcErrFrames=funiIfTxCrcErrFrames, funiIfTxTimeOutFrames=funiIfTxTimeOutFrames, funiIfTxTooLongFrames=funiIfTxTooLongFrames, funiVclRxTotalOctets=funiVclRxTotalOctets, funiIfStatsMinGroup=funiIfStatsMinGroup, funiIfConfTable=funiIfConfTable, funiIfStatsEntry=funiIfStatsEntry, funiVclFaVpi=funiVclFaVpi, funiIfConfSigVpi=funiIfConfSigVpi, funiIfConfFcsBits=funiIfConfFcsBits, funiIfRxTooLongFrames=funiIfRxTooLongFrames, funiIfRxDiscardedFrames=funiIfRxDiscardedFrames, atmfFuniMIB=atmfFuniMIB, funiVclTxErrors=funiVclTxErrors, atmfFuni=atmfFuni, funiIfRxUnknownFaFrames=funiIfRxUnknownFaFrames, funiIfTxPartialFrames=funiIfTxPartialFrames, funiIfConfIlmiVci=funiIfConfIlmiVci, funiIfTxLenErrFrames=funiIfTxLenErrFrames, funiVclRxTotalFrames=funiVclRxTotalFrames, funiIfConfMinGroup=funiIfConfMinGroup, funiVclStatsTable=funiVclStatsTable, FuniValidVci=FuniValidVci, funiVclRxOamFrames=funiVclRxOamFrames, funiIfConfIlmiVpi=funiIfConfIlmiVpi, funiVclStatsEntry=funiVclStatsEntry, funiIfConfSigSupport=funiIfConfSigSupport, funiIfRxFcsErrFrames=funiIfRxFcsErrFrames, funiVclTxTotalOctets=funiVclTxTotalOctets, funiIfStatsTable=funiIfStatsTable, funiVclStatsOptionalGroup=funiVclStatsOptionalGroup, funiVclRxClp0Frames=funiVclRxClp0Frames, funiVclTxOamFrames=funiVclTxOamFrames, funiMIBGroups=funiMIBGroups, atmForum=atmForum, funiMIBCompliance=funiMIBCompliance, funiIfConfSigVci=funiIfConfSigVci, PYSNMP_MODULE_ID=atmfFuniMIB, funiIfConfEntry=funiIfConfEntry, funiIfRxTooShortFrames=funiIfRxTooShortFrames, funiIfEstablishedSvccs=funiIfEstablishedSvccs, funiMIBCompliances=funiMIBCompliances, atmForumNetworkManagement=atmForumNetworkManagement, funiVclTxTotalFrames=funiVclTxTotalFrames, funiIfTxDiscardedFrames=funiIfTxDiscardedFrames, funiVclFaVci=funiVclFaVci, funiMIBConformance=funiMIBConformance, funiIfConfOamSupport=funiIfConfOamSupport, funiVclRxClp0Octets=funiVclRxClp0Octets, funiIfRxAbortedFrames=funiIfRxAbortedFrames, funiMIBObjects=funiMIBObjects)
|
x = 5
x |= 3
print(x)
|
## CUDA blocks are initialized here!
## Created by: Aditya Atluri
## Date: Mar 03 2014
def bx(blocks_dec, kernel):
if blocks_dec == False:
string = "int bx = blockIdx.x;\n"
kernel = kernel + string
blocks_dec = True
return kernel, blocks_dec
def by(blocks_dec, kernel):
if blocks_dec == False:
string = "int by = blockIdx.y;\n"
kernel = kernel + string
blocks_dec = True
return kernel, blocks_dec
def bz(blocks_dec, kernel):
if blocks_dec == False:
string = "int bz = blockIdx.z;\n"
kernel = kernel + string
blocks_dec = True
return kernel, blocks_dec
def blocks_decl(stmt, var_nam, var_val, blocks, type_vars):
equ = stmt.index('=')
kernel = ""
if var_nam.count('Bx') < 1 and stmt.count('Bx') > 0:
pos = stmt.index('Bx')
var_nam.append(stmt[pos])
kernel += "int Bx = gridDim.x;\n"
type_vars.append("int")
if var_nam.count('By') < 1 and stmt.count('By') > 0:
pos = stmt.index('By')
var_nam.append(stmt[pos])
kernel += "int By = gridDim.y;\n"
type_vars.append("int")
if var_nam.count('Bz') < 1 and stmt.count('Bz') > 0:
pos = stmt.index('Bz')
var_nam.append(stmt[pos])
kernel += "int Bz = gridDim.z;\n"
type_vars.append("int")
return var_nam, var_val, blocks, kernel, type_vars
|
# test unicode in identifiers
# comment
# αβγδϵφζ
# global identifiers
α = 1
αβγ = 2
bβ = 3
βb = 4
print(α, αβγ, bβ, βb)
# function, argument, local identifiers
def α(β, γ):
δ = β + γ
print(β, γ, δ)
α(1, 2)
# class, method identifiers
class φ:
def __init__(self):
pass
def δ(self, ϵ):
print(ϵ)
zζzζz = φ()
if hasattr(zζzζz, "δ"):
zζzζz.δ(ϵ=123)
|
def sample(name, custom_package):
native.android_binary(
name = name,
deps = [":sdk"],
srcs = native.glob(["samples/" + name + "/src/**/*.java"]),
custom_package = custom_package,
manifest = "samples/" + name + "/AndroidManifest.xml",
resource_files = native.glob(["samples/" + name + "/res/**/*"]),
)
|
# -*- coding: utf-8 -*-
# Copyright 2021 Cohesity Inc.
class TenantProxy(object):
"""Implementation of the 'TenantProxy' model.
Specifies the data for tenant proxy which has been deployed in tenant's
enviroment.
Attributes:
constituent_id (long|int): Specifies the constituent id of the proxy.
ip_address (string): Specifies the ip address of the proxy.
tenant_id (string): Specifies the unique id of the tenant.
version (string): Specifies the version of the proxy.
"""
# Create a mapping from Model property names to API property names
_names = {
"constituent_id":'constituentId',
"ip_address":'ipAddress',
"tenant_id":'tenantId',
"version":'version'
}
def __init__(self,
constituent_id=None,
ip_address=None,
tenant_id=None,
version=None):
"""Constructor for the TenantProxy class"""
# Initialize members of the class
self.constituent_id = constituent_id
self.ip_address = ip_address
self.tenant_id = tenant_id
self.version = version
@classmethod
def from_dictionary(cls,
dictionary):
"""Creates an instance of this model from a dictionary
Args:
dictionary (dictionary): A dictionary representation of the object as
obtained from the deserialization of the server's response. The keys
MUST match property names in the API description.
Returns:
object: An instance of this structure class.
"""
if dictionary is None:
return None
# Extract variables from the dictionary
constituent_id = dictionary.get('constituentId')
ip_address = dictionary.get('ipAddress')
tenant_id = dictionary.get('tenantId')
version = dictionary.get('version')
# Return an object of this model
return cls(constituent_id,
ip_address,
tenant_id,
version)
|
# generated from catkin/cmake/template/order_packages.context.py.in
source_root_dir = '/home/sim2real/ep_ws/src'
whitelisted_packages = ''.split(';') if '' != '' else []
blacklisted_packages = ''.split(';') if '' != '' else []
underlay_workspaces = '/home/sim2real/carto_ws/devel_isolated/cartographer_rviz;/home/sim2real/carto_ws/install_isolated;/home/sim2real/ep_ws/devel;/opt/ros/noetic'.split(';') if '/home/sim2real/carto_ws/devel_isolated/cartographer_rviz;/home/sim2real/carto_ws/install_isolated;/home/sim2real/ep_ws/devel;/opt/ros/noetic' != '' else []
|
#
# PySNMP MIB module CISCOSB-RMON (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCOSB-RMON
# Produced by pysmi-0.3.4 at Wed May 1 12:23:18 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)
#
Integer, OctetString, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "Integer", "OctetString", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsIntersection, ConstraintsUnion, SingleValueConstraint, ValueSizeConstraint, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ConstraintsUnion", "SingleValueConstraint", "ValueSizeConstraint", "ValueRangeConstraint")
switch001, = mibBuilder.importSymbols("CISCOSB-MIB", "switch001")
EntryStatus, OwnerString = mibBuilder.importSymbols("RMON-MIB", "EntryStatus", "OwnerString")
ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup")
ObjectIdentity, iso, Gauge32, TimeTicks, Counter64, Counter32, Bits, NotificationType, Integer32, MibIdentifier, MibScalar, MibTable, MibTableRow, MibTableColumn, ModuleIdentity, Unsigned32, IpAddress = mibBuilder.importSymbols("SNMPv2-SMI", "ObjectIdentity", "iso", "Gauge32", "TimeTicks", "Counter64", "Counter32", "Bits", "NotificationType", "Integer32", "MibIdentifier", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "ModuleIdentity", "Unsigned32", "IpAddress")
TruthValue, TextualConvention, RowStatus, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TruthValue", "TextualConvention", "RowStatus", "DisplayString")
rlRmonControl = ModuleIdentity((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49))
rlRmonControl.setRevisions(('2004-06-01 00:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts: rlRmonControl.setRevisionsDescriptions(('Initial version of this MIB.',))
if mibBuilder.loadTexts: rlRmonControl.setLastUpdated('200406010000Z')
if mibBuilder.loadTexts: rlRmonControl.setOrganization('Cisco Small Business')
if mibBuilder.loadTexts: rlRmonControl.setContactInfo('Postal: 170 West Tasman Drive San Jose , CA 95134-1706 USA Website: Cisco Small Business Home http://www.cisco.com/smb>;, Cisco Small Business Support Community <http://www.cisco.com/go/smallbizsupport>')
if mibBuilder.loadTexts: rlRmonControl.setDescription('The private MIB module definition for switch001 RMON MIB.')
rlRmonControlMibVersion = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlRmonControlMibVersion.setStatus('current')
if mibBuilder.loadTexts: rlRmonControlMibVersion.setDescription("The MIB's version. The current version is 1")
rlRmonControlHistoryControlQuotaBucket = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535)).clone(8)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlRmonControlHistoryControlQuotaBucket.setStatus('current')
if mibBuilder.loadTexts: rlRmonControlHistoryControlQuotaBucket.setDescription('Maximum number of buckets to be used by each History Control group entry. changed to read only, value is derived from rsMaxRmonEtherHistoryEntrie')
rlRmonControlHistoryControlMaxGlobalBuckets = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535)).clone(300)).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlRmonControlHistoryControlMaxGlobalBuckets.setStatus('current')
if mibBuilder.loadTexts: rlRmonControlHistoryControlMaxGlobalBuckets.setDescription('Maximum number of buckets to be used by all History Control group entries together.')
rlHistoryControlTable = MibTable((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49, 4), )
if mibBuilder.loadTexts: rlHistoryControlTable.setStatus('current')
if mibBuilder.loadTexts: rlHistoryControlTable.setDescription('A list of rlHistory control entries. This table is exactly like the corresponding RMON I History control group table, but is used to sample statistics of counters not specified by the RMON I statistics group.')
rlHistoryControlEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49, 4, 1), ).setIndexNames((0, "CISCOSB-RMON", "rlHistoryControlIndex"))
if mibBuilder.loadTexts: rlHistoryControlEntry.setStatus('current')
if mibBuilder.loadTexts: rlHistoryControlEntry.setDescription('A list of parameters that set up a periodic sampling of statistics. As an example, an instance of the rlHistoryControlInterval object might be named rlHistoryControlInterval.2')
rlHistoryControlIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49, 4, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlHistoryControlIndex.setStatus('current')
if mibBuilder.loadTexts: rlHistoryControlIndex.setDescription('An index that uniquely identifies an entry in the rlHistoryControl table. Each such entry defines a set of samples at a particular interval for a sampled counter.')
rlHistoryControlDataSource = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49, 4, 1, 2), ObjectIdentifier()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlHistoryControlDataSource.setStatus('current')
if mibBuilder.loadTexts: rlHistoryControlDataSource.setDescription('This object identifies the source of the data for which historical data was collected and placed in the rlHistory table. This object may not be modified if the associated rlHistoryControlStatus object is equal to valid(1).')
rlHistoryControlBucketsRequested = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49, 4, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535)).clone(50)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlHistoryControlBucketsRequested.setStatus('current')
if mibBuilder.loadTexts: rlHistoryControlBucketsRequested.setDescription('The requested number of discrete time intervals over which data is to be saved in the part of the rlHistory table associated with this rlHistoryControlEntry. When this object is created or modified, the probe should set rlHistoryControlBucketsGranted as closely to this object as is possible for the particular probe implementation and available resources.')
rlHistoryControlBucketsGranted = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49, 4, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlHistoryControlBucketsGranted.setStatus('current')
if mibBuilder.loadTexts: rlHistoryControlBucketsGranted.setDescription('The number of discrete sampling intervals over which data shall be saved in the part of the rlHistory table associated with this rlHistoryControlEntry. When the associated rlHistoryControlBucketsRequested object is created or modified, the probe should set this object as closely to the requested value as is possible for the particular probe implementation and available resources. The probe must not lower this value except as a result of a modification to the associated rlHistoryControlBucketsRequested object. There will be times when the actual number of buckets associated with this entry is less than the value of this object. In this case, at the end of each sampling interval, a new bucket will be added to the rlHistory table. When the number of buckets reaches the value of this object and a new bucket is to be added to the media-specific table, the oldest bucket associated with this rlHistoryControlEntry shall be deleted by the agent so that the new bucket can be added. When the value of this object changes to a value less than the current value, entries are deleted from the rlHistory table. Enough of the oldest of these entries shall be deleted by the agent so that their number remains less than or equal to the new value of this object. When the value of this object changes to a value greater than the current value, the number of associated rlHistory table entries may be allowed to grow.')
rlHistoryControlInterval = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49, 4, 1, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 3600)).clone(1800)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlHistoryControlInterval.setStatus('current')
if mibBuilder.loadTexts: rlHistoryControlInterval.setDescription('The interval in seconds over which the data is sampled for each bucket in the part of the rlHistory table associated with this rlHistoryControlEntry. This interval can be set to any number of seconds between 1 and 3600 (1 hour). Because the counters in a bucket may overflow at their maximum value with no indication, a prudent manager will take into account the possibility of overflow in any of the associated counters. It is important to consider the minimum time in which any counter could overflow and set the rlHistoryControlInterval object to a value This object may not be modified if the associated rlHistoryControlStatus object is equal to valid(1).')
rlHistoryControlOwner = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49, 4, 1, 6), OwnerString()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlHistoryControlOwner.setStatus('current')
if mibBuilder.loadTexts: rlHistoryControlOwner.setDescription('The entity that configured this entry and is therefore using the resources assigned to it.')
rlHistoryControlStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49, 4, 1, 7), EntryStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlHistoryControlStatus.setStatus('current')
if mibBuilder.loadTexts: rlHistoryControlStatus.setDescription('The status of this rlHistoryControl entry. Each instance of the rlHistory table associated with this rlHistoryControlEntry will be deleted by the agent if this rlHistoryControlEntry is not equal to valid(1).')
rlHistoryTable = MibTable((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49, 5), )
if mibBuilder.loadTexts: rlHistoryTable.setStatus('current')
if mibBuilder.loadTexts: rlHistoryTable.setDescription('A list of history entries.')
rlHistoryEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49, 5, 1), ).setIndexNames((0, "CISCOSB-RMON", "rlHistoryIndex"), (0, "CISCOSB-RMON", "rlHistorySampleIndex"))
if mibBuilder.loadTexts: rlHistoryEntry.setStatus('current')
if mibBuilder.loadTexts: rlHistoryEntry.setDescription('An historical statistics sample of a counter specified by the corresponding history control entry. This sample is associated with the rlHistoryControlEntry which set up the parameters for a regular collection of these samples. As an example, an instance of the rlHistoryPkts object might be named rlHistoryPkts.2.89')
rlHistoryIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49, 5, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlHistoryIndex.setStatus('current')
if mibBuilder.loadTexts: rlHistoryIndex.setDescription('The history of which this entry is a part. The history identified by a particular value of this index is the same history as identified by the same value of rlHistoryControlIndex.')
rlHistorySampleIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49, 5, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlHistorySampleIndex.setStatus('current')
if mibBuilder.loadTexts: rlHistorySampleIndex.setDescription('An index that uniquely identifies the particular sample this entry represents among all samples associated with the same rlHistoryControlEntry. This index starts at 1 and increases by one as each new sample is taken.')
rlHistoryIntervalStart = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49, 5, 1, 3), TimeTicks()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlHistoryIntervalStart.setStatus('current')
if mibBuilder.loadTexts: rlHistoryIntervalStart.setDescription('The value of sysUpTime at the start of the interval over which this sample was measured. If the probe keeps track of the time of day, it should start the first sample of the history at a time such that when the next hour of the day begins, a sample is started at that instant. Note that following this rule may require the probe to delay collecting the first sample of the history, as each sample must be of the same interval. Also note that the sample which is currently being collected is not accessible in this table until the end of its interval.')
rlHistoryValue = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49, 5, 1, 4), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlHistoryValue.setStatus('current')
if mibBuilder.loadTexts: rlHistoryValue.setDescription('The value of the sampled counter at the time of this sampling.')
rlControlHistoryControlQuotaBucket = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535)).clone(8)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlControlHistoryControlQuotaBucket.setStatus('current')
if mibBuilder.loadTexts: rlControlHistoryControlQuotaBucket.setDescription('Maximum number of buckets to be used by each rlHistoryControlTable entry.')
rlControlHistoryControlMaxGlobalBuckets = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49, 7), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535)).clone(300)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlControlHistoryControlMaxGlobalBuckets.setStatus('current')
if mibBuilder.loadTexts: rlControlHistoryControlMaxGlobalBuckets.setDescription('Maximum number of buckets to be used by all rlHistoryControlTable entries together.')
rlControlHistoryMaxEntries = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 49, 8), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535)).clone(300)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlControlHistoryMaxEntries.setStatus('current')
if mibBuilder.loadTexts: rlControlHistoryMaxEntries.setDescription('Maximum number of rlHistoryTable entries.')
mibBuilder.exportSymbols("CISCOSB-RMON", rlHistoryControlIndex=rlHistoryControlIndex, rlHistoryTable=rlHistoryTable, rlHistoryControlOwner=rlHistoryControlOwner, rlControlHistoryMaxEntries=rlControlHistoryMaxEntries, rlRmonControl=rlRmonControl, rlHistoryControlBucketsRequested=rlHistoryControlBucketsRequested, rlHistoryValue=rlHistoryValue, rlHistoryControlDataSource=rlHistoryControlDataSource, PYSNMP_MODULE_ID=rlRmonControl, rlControlHistoryControlQuotaBucket=rlControlHistoryControlQuotaBucket, rlHistoryControlEntry=rlHistoryControlEntry, rlRmonControlHistoryControlQuotaBucket=rlRmonControlHistoryControlQuotaBucket, rlHistoryIntervalStart=rlHistoryIntervalStart, rlHistoryEntry=rlHistoryEntry, rlHistoryIndex=rlHistoryIndex, rlHistorySampleIndex=rlHistorySampleIndex, rlHistoryControlBucketsGranted=rlHistoryControlBucketsGranted, rlHistoryControlTable=rlHistoryControlTable, rlControlHistoryControlMaxGlobalBuckets=rlControlHistoryControlMaxGlobalBuckets, rlRmonControlHistoryControlMaxGlobalBuckets=rlRmonControlHistoryControlMaxGlobalBuckets, rlRmonControlMibVersion=rlRmonControlMibVersion, rlHistoryControlStatus=rlHistoryControlStatus, rlHistoryControlInterval=rlHistoryControlInterval)
|
#!/usr/bin/env/ python3
"""SoloLearn > Code Coach > Hovercraft"""
sales = int(input('How many did you sell? ')) * 3
expense = 21
if sales > expense:
print('Profit')
elif sales < expense:
print('Loss')
else:
print('Broke Even')
|
class SearchResult(object):
"""Class representing a return object for a search query.
Attributes:
path: An array representing the path from a start node to the end node, empty if there is no path.
path_len: The length of the path represented by path, 0 if path is empty.
ele_gain: The cumulative elevation gain through the path, 0 if path is empty.
"""
def __init__(self, path=[], path_len=0, ele_gain=0):
self.path = path
self.path_len = path_len
self.ele_gain = ele_gain
|
class Stats:
writes: int
reads: int
accesses: int
def __init__(self) -> None:
self.reset()
def reset(self) -> None:
self.writes = 0
self.reads = 0
self.accesses = 0
def add_reads(self, count: int = 1) -> None:
self.reads += count
self.accesses += count
def add_writes(self, count: int = 1) -> None:
self.writes += count
self.accesses += count
|
colors = ['black', 'white']
sizes = ['S', 'M', 'L']
tshirts = [
(color, size)
for color in colors
for size in sizes
]
print(f"Cartesian products from {colors} and {sizes}: {tshirts}")
|
class Eventseverity(basestring):
"""
EMERGENCY|ALERT|CRITICAL|ERROR|WARNING|NOTICE|INFORMATIONAL|DEBUG
Possible values:
<ul>
<li> "emergency" - System is unusable,
<li> "alert" - Action must be taken immediately,
<li> "critical" - Critical condition,
<li> "error" - Error condition,
<li> "warning" - Warning condition,
<li> "notice" - Normal but significant condition,
<li> "informational" - Information message,
<li> "debug" - A debugging message
</ul>
"""
@staticmethod
def get_api_name():
return "eventseverity"
|
MAX_SENTENCE = 30
MAX_ALL = 50
MAX_SENT_LENGTH=MAX_SENTENCE
MAX_SENTS=MAX_ALL
max_entity_num = 10
num = 100
num1 = 200
num2 = 100
npratio=4
|
#Faça um programa que calcule e escreva o valor de S
# S=1/1+3/2+5/3+7/4...99/50
u=1
valores=[]
for c in range(1,100):
if(c%2==1):
valores.append(round(c/u,2))
u+=1
print(valores)
print(f"S = {sum(valores)}")
|
"""
File defining the classes Normalize and Standardize used respectively to normalize and standardize the data set.
"""
class Normalize(object):
"""
Data pre-processing class to normalize data so the values are in the range [new_min, new_max].
"""
def __init__(self, min_, max_, new_min=0, new_max=1):
"""
Initializer.
:param min_: Min of the un-normalized data.
:param max_: Max of the un-normalized data.
:param new_min: Min of the new data.
:param new_max: Max of the new data.
"""
self.min = min_
self.max = max_
self.new_min = new_min
self.new_max = new_max
def __call__(self, data):
"""
Normalize a given data point.
:param data: Data point to normalize.
:return: Normalized data.
"""
data = (self.new_max - self.new_min)*(data - self.min)/(self.max - self.min) + self.new_min
return data
class Standardize(object):
"""
Data pre-processing class to standardize data so the values have a fixed mean and standard deviation.
"""
def __init__(self, mean, std):
"""
Initializer.
:param mean: Mean of the un-standardized data.
:param std: Std of the un-standardized data.
"""
self.mean = mean
self.std = std
def __call__(self, data):
"""
Standardize a given data point.
:param data: Data point to standardize.
:return: Standardized data.
"""
data = (data - self.mean)/self.std
return data
|
n=1
def f(x):
print(n)
f(0) |
# creates a list and prints it
days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
# traversing without an index
for day in days:
print(day)
# traversing with an index
for i in range(len(days)):
print(f"Day {i} is {days[i]}")
days[1] = "Lunes"
print("Day[1] is now ",days[1])
for day in days:
print(day) |
# -*- coding: utf-8 -*-
# Memory addresses
ADDRESS_R15 = 0x400f
ADDRESS_ADC_POWER = 0x4062
ADDRESS_ADC_BATTERY = 0x4063
ADDRESS_LEVELA = 0x4064
ADDRESS_LEVELB = 0x4065
ADDRESS_PUSH_BUTTON = 0x4068
ADDRESS_COMMAND_1 = 0x4070
ADDRESS_COMMAND_2 = 0x4071
ADDRESS_MA_MIN_VALUE = 0x4086
ADDRESS_MA_MAX_VALUE = 0x4087
ADDRESS_CURRENT_MODE = 0x407b
ADDRESS_LCD_WRITE_PARAMETER_1 = 0x4180
ADDRESS_LCD_WRITE_PARAMETER_2 = 0x4181
ADDRESS_POWER_LEVEL = 0x41f4
ADDRESS_BATTERY_LEVEL = 0x4203
ADDRESS_LEVELMA = 0x420D
ADDRESS_KEY = 0x4213
# EEPROM addresses
EEPROM_ADDRESS_POWER_LEVEL = 0x8009
EEPROM_ADDRESS_FAVORITE_MODE = 0x800C
# Commands
COMMAND_START_FAVORITE_MODULE = 0x00
COMMAND_EXIT_MENU = 0x04
COMMAND_SHOW_MAIN_MENU = 0x0a
COMMAND_NEW_MODE = 0x12
COMMAND_WRITE_STRING_TO_LCD = 0x15
COMMAND_NO_COMMAND = 0xff
# Modes
MODE_POWERON = 0x00
MODE_UNKNOWN = 0x01
MODE_WAVES = 0x76
MODE_STROKE = 0x77
MODE_CLIMB = 0x78
MODE_COMBO = 0x79
MODE_INTENSE = 0x7a
MODE_RYTHM = 0x7b
MODE_AUDIO1 = 0x7c
MODE_AUDIO2 = 0x7d
MODE_AUDIO3 = 0x7e
MODE_SPLIT = 0x7f
MODE_RANDOM1 = 0x80
MODE_RANDOM2 = 0x81
MODE_TOGGLE = 0x82
MODE_ORGASM = 0x83
MODE_TORMENT = 0x84
MODE_PHASE1 = 0x85
MODE_PHASE2 = 0x86
MODE_PHASE3 = 0x87
MODE_USER1 = 0x88
MODE_USER2 = 0x89
MODE_USER3 = 0x8a
MODE_USER4 = 0x8b
MODE_USER5 = 0x8c
MODE_USER6 = 0x8d
MODE_USER7 = 0x8e
# Power Level
POWERLEVEL_LOW = 0x01
POWERLEVEL_NORMAL = 0x02
POWERLEVEL_HIGH = 0x03
# Register 15 Bits
REGISTER_15_ADCDISABLE = 0
# Buttons
BUTTON_MENU = 0x80
BUTTON_OK = 0x20
BUTTON_RIGHT = 0x40
BUTTON_LEFT = 0x10
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 13 11:34:33 2019
@author: manninan
""" |
r"""
.. include::../README.md
:start-line: 1
"""
|
# http://www.codewars.com/kata/55f73f66d160f1f1db000059/
def combine_names(first_name, last_name):
return "{0} {1}".format(first_name, last_name)
|
class DefaultPreferences(type):
"""The type for Default Preferences that cannot be modified"""
def __setattr__(cls, key, value):
if key == "defaults":
raise AttributeError("Cannot override defaults")
else:
return type.__setattr__(cls, key, value)
def __delattr__(cls, item):
if item == "defaults":
raise AttributeError("Cannot delete defaults")
else:
return type.__delattr__(cls, item)
class Preferences(object):
"""The base Preferences class"""
__metaclass__ = DefaultPreferences
def list(self):
print(self.__dict__)
return self.__dict__
def defaults(self):
return tuple(self.__dict__.values())
class GraphPreferences(object):
"""Handles graphing preferences."""
class Plot(object):
boxplot = True
histogram = True
cdf = False
oneway = True
probplot = True
scatter = True
tukey = False
histogram_borders = False
boxplot_borders = False
defaults = (boxplot, histogram, cdf, oneway, probplot, scatter, tukey, histogram_borders, boxplot_borders)
distribution = {'counts': False,
'violin': False,
'boxplot': True,
'fit': False,
'fit_style': 'r--',
'fit_width': '2',
'cdf_style': 'k-',
'distribution': 'norm',
'bins': 20,
'color': 'green'
}
bivariate = {'points': True,
'point_style': 'k.',
'contours': False,
'contour_width': 1.25,
'fit': True,
'fit_style': 'r-',
'fit_width': 1,
'boxplot': True,
'violin': True,
'bins': 20,
'color': 'green'
}
oneway = {'boxplot': True,
'violin': False,
'point_style': '^',
'line_style': '-'
}
|
# ------------------------------------------
#
# Program created by Maksim Kumundzhiev
#
#
# email: kumundzhievmaxim@gmail.com
# github: https://github.com/KumundzhievMaxim
# -------------------------------------------
BATCH_SIZE = 10
IMG_SIZE = (160, 160)
MODEL_PATH = 'checkpoints/model'
|
#1
num = int(input("Enter a number : "))
largest_divisor = 0
#2
for i in range(2, num):
#3
if num % i == 0:
#4
largest_divisor = i
#5
print("Largest divisor of {} is {}".format(num,largest_divisor))
|
# Description
# 中文
# English
# Given a string(Given in the way of char array) and an offset, rotate the string by offset in place. (rotate from left to right)
# offset >= 0
# the length of str >= 0
# Have you met this question in a real interview?
# Example
# Example 1:
# Input: str="abcdefg", offset = 3
# Output: str = "efgabcd"
# Explanation: Note that it is rotated in place, that is, after str is rotated, it becomes "efgabcd".
# Example 2:
# Input: str="abcdefg", offset = 0
# Output: str = "abcdefg"
# Explanation: Note that it is rotated in place, that is, after str is rotated, it becomes "abcdefg".
# Example 3:
# Input: str="abcdefg", offset = 1
# Output: str = "gabcdef"
# Explanation: Note that it is rotated in place, that is, after str is rotated, it becomes "gabcdef".
# Example 4:
# Input: str="abcdefg", offset =2
# Output: str = "fgabcde"
# Explanation: Note that it is rotated in place, that is, after str is rotated, it becomes "fgabcde".
# Example 5:
# Input: str="abcdefg", offset = 10
# Output: str = "efgabcd"
# Explanation: Note that it is rotated in place, that is, after str is rotated, it becomes "efgabcd".
class Solution:
"""
@param str: An array of char
@param offset: An integer
@return: nothing
"""
def rotateString(self, s, offset):
# write your code here
if len(s) > 0:
offset = offset % len(s)
temp = (s + s)[len(s) - offset : 2 * len(s) - offset]
for i in range(len(temp)):
s[i] = temp[i] |
class ObjectProperties:
def __init__(self, object_id, extra_data=None, ticket_type=None, quantity=None):
if extra_data:
self.extraData = extra_data
self.objectId = object_id
if ticket_type:
self.ticketType = ticket_type
if quantity:
self.quantity = quantity
|
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
if len(s) == 0:
return 0
m = 1
for _ in range(len(s)):
i = 0
S = set()
for x in range(_, len(s)):
if s[x] not in S:
S.add(s[x])
i += 1
else:
break
m = max(i, m)
return m |
lookup = [
(10, "x"),
(9, "ix"),
(5, "v"),
(4, "iv"),
(1, "i"),
]
def to_roman(integer):
#
"""
"""
for decimal, roman in lookup:
if decimal <= integer:
return roman + to_roman(integer - decimal)
return ""
def main():
print(to_roman(1))
print(to_roman(2))
print(to_roman(4))
print(to_roman(5))
print(to_roman(6))
print(to_roman(9))
print(to_roman(10))
print(to_roman(11))
print(to_roman(36))
if __name__ == "__main__":
main()
|
class Stack:
def __init__(self):
self.items = []
def is_empty(self): # test to see whether the stack is empty.
return self.items == []
def push(self, item): # adds a new item to the top of the stack.
self.items.append(item)
def pop(self): # removes the top item from the stack.
return self.items.pop()
def peek(self): # return the top item from the stack.
return self.items[len(self.items) - 1]
def size(self): # returns the number of items on the stack.
return len(self.items)
def base_converter(dec_number, base):
digits = "0123456789ABCDEF"
rem_stack = Stack()
while dec_number > 0:
rem = dec_number % base
rem_stack.push(rem)
dec_number = dec_number // base
new_string = ""
while not rem_stack.is_empty():
new_string = new_string + digits[rem_stack.pop()]
return new_string
print(base_converter(196, 2))
print(base_converter(25, 8))
print(base_converter(26, 16)) |
class Book:
def __init__(self, title, author, location):
self.title = title
self.author = author
self.location = location
self.page = 0
def turn_page(self, page):
self.page = page
|
class Entity(object):
'''
An entity has:
- energy
- position(x,y)
- size(length, width)
An entity may have a parent entity
An entity may have child entities
'''
def __init__(
self,
p,
parent=None,
children=None):
self.p = p
self.energy = p.getfloat("ENTITY", "energy")
self.x_pos = p.getfloat("ENTITY", "x_pos")
self.y_pos = p.getfloat("ENTITY", "y_pos")
self.length = p.getint("ENTITY", "length")
self.width = p.getint("ENTITY", "width")
self.parent = parent
if children is None:
self.children = []
else:
self.children = children
def add_child(self, entity):
self.children.append(entity)
def remove_child(self, entity):
self.children.remove(entity)
def remove_self(self):
if self.parent is not None:
self.parent.children.remove(self)
def number_children(self):
if self.children:
return len(self.children)
else:
return 0
def total_energy(self):
'''
returns the sum of all energy
'''
total_energy = self.energy
for child in self.children:
total_energy += child.energy
return total_energy
def set_bounds(self, x, y):
'''
Ensure that x, y are within the bounds of this entity.
Reset x,y so that a torus is formed
'''
if x < 0.0:
x = self.length
if x > self.length:
x = 0.0
if y < 0.0:
y = self.width
if y > self.width:
y = 0.0
return x, y
|
"""
https://leetcode.com/problems/longest-substring-without-repeating-characters/
Given a string, find the length of the longest substring without repeating characters.
"""
class Solution:
def lengthOfLongestSubstring(self, s):
longest = 0
longest_substr = ""
for ch in s:
if ch not in longest_substr:
longest_substr += ch
else:
if len(longest_substr) > longest:
longest = len(longest_substr)
longest_substr = longest_substr[(longest_substr.find(ch)+1):] + ch
return max(longest, len(longest_substr))
s=Solution()
print(s.lengthOfLongestSubstring("umvejcuuk"))
|
N = int(input())
A = list(map(int, input().split()))
d = {}
for i in range(N - 1):
if A[i] in d:
d[A[i]].append(i + 2)
else:
d[A[i]] = [i + 2]
for i in range(1, N + 1):
if i in d:
print(len(d[i]))
else:
print(0)
|
GENERIC = [
'Half of US adults have had family jailed',
'Judge stopped me winning election',
'Stock markets stabilise after earlier sell-off'
]
NON_GENERIC = [
'Leicester helicopter rotor controls failed',
'Pizza Express founder Peter Boizot dies aged 89',
'Senior Tory suggests vote could be delayed'
] |
class Solution:
def uniqueLetterString(self, S: str) -> int:
idxes = {ch : (-1, -1) for ch in string.ascii_uppercase}
ans = 0
for idx, ch in enumerate(S):
i, j = idxes[ch]
ans += (j - i) * (idx - j)
idxes[ch] = j, idx
for i, j in idxes.values():
ans += (j - i) * (len(S) - j)
return ans % (int(1e9) + 7)
|
#!/usr/bin/python
#coding=utf-8
'''
@author: sheng
@license:
'''
SPELL=u'yìfēng'
CN=u'翳风'
NAME=u'yifeng41'
CHANNEL='sanjiao'
CHANNEL_FULLNAME='SanjiaoChannelofHand-Shaoyang'
SEQ='SJ17'
if __name__ == '__main__':
pass
|
class Image_Anotation:
def __init__(self, id, image, path_image):
self.id = id
self.FOV = [0.30,0.60]
self.image = image
self.list_roi=[]
self.list_compose_ROI=[]
self.id_roi=0
self.path_image = path_image
def set_image(self, image):
self.image = image
def get_image(self):
return self.image
def get_id(self):
return self.id
def get_path(self):
return self.path_image
def get_list_roi(self):
return self.list_roi
def add_ROI(self, roi):
self.id_roi += 1
roi.set_id(self.id_roi)
self.list_roi.append(roi)
#return roi to get the id
return roi
def delet_ROI(self, id):
for element in self.list_roi:
if element.get_id() == id:
self.list_roi.remove(element)
self.id_roi -= 1
break
for element in self.list_roi:
if element.get_id() > id:
new_id = element.get_id() - 1
element.set_id(new_id)
def edit_roi(self, roi):
self.list_roi[(roi.get_id()-1)] = roi
def delet_list_roi(self):
self.list_roi.clear()
def add_compose_ROI(self, compose_ROI):
self.list_compose_ROI.append(compose_ROI)
def get_list_compose_ROI(self):
return self.list_compose_ROI
def get_compose_ROI(self, id):
for roi in self.list_compose_ROI:
if roi.get_id() == id:
return roi
return None
def delete_compose_ROI(self, id):
for element in self.list_compose_ROI:
if element.get_id() == id:
self.list_compose_ROI.remove(element)
break
for element in self.list_compose_ROI:
if element.get_id() > id:
new_id = element.get_id() - 1
element.set_id(new_id)
def modify_compose_ROI(self, id, compose_ROI):
self.list_compose_ROI[id]= compose_ROI
|
# Hashcode 2021
# Team Depresso
# Problem - Traffic Signaling
## Data Containers
class Street:
def __init__(self,start,end,name,L):
self.start = start
self.end = end
self.name = name
self.time = L
def show(self):
print(self.start,self.end,self.name,self.time)
class Car:
def __init__(self,P, path):
self.P = P # the number of streets that the car wants to travel
self.path = path # names of the streets
# the car starts at the end of first street
def show(self):
print(self.P, self.path)
#Just getting data
with open('c.txt') as f:
D, I, S, V, F = list(map(int, f.readline()[:-1].split(" ")))
'''
l1 = f.readline()[:-1].split(' ')
D = int(l1[0]) # Duration of simulation 1 <D<10^4
I = int(l1[1]) # The number of intersections 2 ≤ I ≤ 10^5
S = int(l1[2]) # The number of streets 2 ≤ S ≤ 10 5
V = int(l1[3]) # The number of cars 1 ≤ V ≤ 10 3
F = int(l1[4]) # The bonus points for each car that reaches
# its destination before time D1 ≤ F ≤ 10 3
'''
# B, E, streets_descriptions = [], [], []
streets = [0]*S
for i in range(S):
line = f.readline()[:-1].split(' ')
street = Street(int(line[0]), int(line[1]), line[2], int(line[3]))
streets[i] = street
#street.show()
cars = [0]*V
for i in range(V):
line = f.readline()[:-1].split(' ')
car = Car(int(line[0]), line[1:])
cars[i] = car
#car.show()
o= open("c-output-try-stupid-v2.txt","w+")
o.write(str(I)+'\n')
for i in range(I):
o.write(str(i)+'\n')
num_roads_ending = 0
str_ending = []
for j in range(S):
if streets[j].end == i:
num_roads_ending += 1
str_ending.append(streets[j].name)
o.write(str(num_roads_ending)+'\n')
for k in range(num_roads_ending):
o.write(str_ending[k]+" "+ str(1)+'\n') |
NEO_HOST = "seed3.neo.org"
MAINNET_HTTP_RPC_PORT = 10332
MAINNET_HTTPS_RPC_PORT = 10331
TESTNET_HTTP_RPC_PORT = 20332
TESTNET_HTTPS_RPC_PORT = 20331
|
# first.n.squares.manual.method.py
def get_squares_gen(n):
for x in range(n):
yield x ** 2
squares = get_squares_gen(3)
print(squares.__next__()) # prints: 0
print(squares.__next__()) # prints: 1
print(squares.__next__()) # prints: 4
# the following raises StopIteration, the generator is exhausted,
# any further call to next will keep raising StopIteration
print(squares.__next__())
|
class binary_tree:
def __init__(self):
pass
class Node(binary_tree):
__field_0 : int
__field_1 : binary_tree
__field_2 : binary_tree
def __init__(self, arg_0 : int , arg_1 : binary_tree , arg_2 : binary_tree ):
self.__field_0 = arg_0
self.__field_1 = arg_1
self.__field_2 = arg_2
def __iter__(self):
yield self.__field_0
yield self.__field_1
yield self.__field_2
class Leaf(binary_tree):
__field_0 : int
def __init__(self, arg_0 : int ):
self.__field_0 = arg_0
def __iter__(self):
yield self.__field_0
|
class WindowInteropHelper(object):
"""
Assists interoperation between Windows Presentation Foundation (WPF) and Win32 code.
WindowInteropHelper(window: Window)
"""
def EnsureHandle(self):
"""
EnsureHandle(self: WindowInteropHelper) -> IntPtr
Creates the HWND of the window if the HWND has not been created yet.
Returns: An System.IntPtr that represents the HWND.
"""
pass
@staticmethod
def __new__(self,window):
""" __new__(cls: type,window: Window) """
pass
Handle=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets the window handle for a Windows Presentation Foundation (WPF) window�that is used to create this System.Windows.Interop.WindowInteropHelper.
Get: Handle(self: WindowInteropHelper) -> IntPtr
"""
Owner=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets or sets the handle of the Windows Presentation Foundation (WPF)�owner window.
Get: Owner(self: WindowInteropHelper) -> IntPtr
Set: Owner(self: WindowInteropHelper)=value
"""
|
def main():
_ = input()
string = input()
if _ == 0 or _ == 1:
return 0
if _ == 2:
if string[0] == string[1]:
return 1
return 0
last = string[0]
cnt = 0
for i in range(1, len(string)):
if string[i] == last:
cnt += 1
last = string[i]
return cnt
print(main())
|
num = int(input("Enter a number: "))
sum = 0; size = 0; temp = num; temp2 = num
while(temp2!=0):
size += 1
temp2 = int(temp2/10)
while(temp!=0):
remainder = temp%10
sum += remainder**size
temp = int(temp/10)
if(sum == num):
print("It's an armstrong number")
else:
print("It's not an armstrong number")
|
#!/usr/bin/env python3
"""This is a simple python3 calculator for demonstration purposes
some to-do's but we'll get to that"""
__author__ = "Sebastian Meier zu Biesen"
__copyright__ = "2000-2019 by MzB Solutions"
__email__ = "smzb@mitos-kalandiel.me"
class Calculator(object):
@property
def isDebug(self):
return self._isDebug
@isDebug.setter
def isDebug(self, bDebug):
self._isDebug = bDebug
@isDebug.deleter
def isDebug(self):
del self._isDebug
@property
def isInteractive(self):
return self._isInteractive
@isInteractive.setter
def isInteractive(self, bInteractive):
self._isInteractive = bInteractive
@isInteractive.deleter
def isInteractive(self):
del self._isInteractive
@property
def Operation(self):
return self._Operation
@Operation.setter
def Operation(self, iOperation):
self._Operation = iOperation
@Operation.deleter
def Operation(self):
del self._Operation
@property
def Num1(self):
return self._Num1
@Num1.setter
def Num1(self, iNum):
if not isinstance(iNum, int):
raise TypeError
self._Num1 = iNum
@Num1.deleter
def Num1(self):
del self._Num1
@property
def Num2(self):
return self._Num2
@Num2.setter
def Num2(self, iNum):
if not isinstance(iNum, int):
raise TypeError
self._Num2 = iNum
@Num2.deleter
def Num2(self):
del self._Num2
def __init__(self):
self._isDebug = False
self._isInteractive = False
self._Operation = None
self._Num1 = None
self._Num2 = None
def add(self):
"""This functions adds two numbers"""
return self._Num1 + self._Num2
def subtract(self):
"""This is a simple subtraction function"""
return self._Num1 - self._Num2
def multiply(self):
"""Again a simple multiplication"""
return self._Num1 * self._Num2
def divide(self):
"""division function
todo: (smzb/js) make division by 0 impossible"""
return self._Num1 / self._Num2
def ask_op(self):
"""Lets ask what the user wants to do"""
print("Please select operation -\n"
"1. Add\n"
"2. Subtract\n"
"3. Multiply\n"
"4. Divide\n")
# Take input from the user
result = input("Select operations from 1, 2, 3, 4 :")
return int(result)
def ask_number(self):
"""Get a number from the user"""
num = int(input("Enter an operand: "))
return num
def eval_operation(self):
"""Now evaluate what operation the user wants,
and run the consecutive function"""
if self._Operation == 1:
print(self._Num1, "+", self._Num2, "=",
Calculator.add(self))
elif self._Operation == 2:
print(self._Num1, "-", self._Num2, "=",
Calculator.subtract(self))
elif self._Operation == 3:
print(self._Num1, "*", self._Num2, "=",
Calculator.multiply(self))
elif self._Operation == 4:
print(self._Num1, "/", self._Num2, "=",
Calculator.divide(self))
elif self._Operation == 0:
return
else:
print("Invalid operation")
|
'''
Напишите программу, которая объявляет переменную: "name" и присваивает ей значение "Python".
Программа должна напечатать в одну строку, разделяя пробелами:
Строку "name"
Значение переменной "name"
Число 3
Число 8.5
Sample Input:
Sample Output:
name Python 3 8.5
'''
name = 'Python'
print('name', name, 3, 8.5)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.