content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
class Strip(object): def plotSurf(self): for cyc in self.cut_cycs: self.df = None print("file to analyse: ",self.file) myResults = RTQuICData_feat(self.file, numCycles =cyc) self.df = myResults.getData() self.addSurflabels() for param i...
class Strip(object): def plot_surf(self): for cyc in self.cut_cycs: self.df = None print('file to analyse: ', self.file) my_results = rt_qu_ic_data_feat(self.file, numCycles=cyc) self.df = myResults.getData() self.addSurflabels() for p...
class Demo: def __init__(self): pass def runDemo(self): print("Hi , This is demo !")
class Demo: def __init__(self): pass def run_demo(self): print('Hi , This is demo !')
# 40 ms ; faster than 97.67 % """ # Definition for a Node. class Node: def __init__(self, val: int = 0, left: 'Node' = None, right: 'Node' = None, next: 'Node' = None): self.val = val self.left = left self.right = right self.next = next """ class Solution: def connect(self, roo...
""" # Definition for a Node. class Node: def __init__(self, val: int = 0, left: 'Node' = None, right: 'Node' = None, next: 'Node' = None): self.val = val self.left = left self.right = right self.next = next """ class Solution: def connect(self, root: 'Node') -> 'Node': ...
def median(l): tmp = l tmp.sort() n = len(tmp) m = n // 2 if n % 2: return tmp[m] else: return (tmp[m] + tmp[m-1]) // 2 n = int(input()) x_ = [] y_ = [] for i in range(n): x, y = [int(j) for j in input().split()] x_.append(x) y_.append(y...
def median(l): tmp = l tmp.sort() n = len(tmp) m = n // 2 if n % 2: return tmp[m] else: return (tmp[m] + tmp[m - 1]) // 2 n = int(input()) x_ = [] y_ = [] for i in range(n): (x, y) = [int(j) for j in input().split()] x_.append(x) y_.append(y) y_cable = median(y_) cabl...
class libro(): def __init__(self,prestamo,devolucion,dame_info): self.prestamo = prestamo self.devolucion = devolucion self.dame_info = dame_info def get_prestamo(self): return def get_devolucion(self): return def get_dame_info(self): return
class Libro: def __init__(self, prestamo, devolucion, dame_info): self.prestamo = prestamo self.devolucion = devolucion self.dame_info = dame_info def get_prestamo(self): return def get_devolucion(self): return def get_dame_info(self): return
class Solution: def findClosestNumber(self, nums: List[int]) -> int: nums.sort(key=lambda x: (abs(x), -x)) return nums[0]
class Solution: def find_closest_number(self, nums: List[int]) -> int: nums.sort(key=lambda x: (abs(x), -x)) return nums[0]
# Create a program that has a tuple fully populated with a count in full, from zero to twenty. # Your program should read a number on the keyboard (between 0 and 20) and show it in full. full = ('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirtee...
full = ('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty') while True: number = int(input('Enter a number between 0 and 20: ')) if 0 <= number <= 20: print...
class Node: def __init__(self, data): self.val = data self.next = None def __str__(self): return str(self.val) class LinkedList: def __init__(self): self.head = None self._size = 0 def append(self, el): if self.head: pointer = self.head ...
class Node: def __init__(self, data): self.val = data self.next = None def __str__(self): return str(self.val) class Linkedlist: def __init__(self): self.head = None self._size = 0 def append(self, el): if self.head: pointer = self.head ...
version = '0.6.4' version_cmd = 'consul -v' depends = ['unzip'] download_url = 'https://releases.hashicorp.com/consul/VERSION/consul_VERSION_linux_amd64.zip' install_script = """ unzip -o consul_VERSION_linux_amd64.zip mv -f consul /usr/local/bin/consul """
version = '0.6.4' version_cmd = 'consul -v' depends = ['unzip'] download_url = 'https://releases.hashicorp.com/consul/VERSION/consul_VERSION_linux_amd64.zip' install_script = '\nunzip -o consul_VERSION_linux_amd64.zip\nmv -f consul /usr/local/bin/consul\n'
'''input 2000 ''' inp = int(input('')) print(int((inp-1)*inp*(inp+1)/6+inp))
"""input 2000 """ inp = int(input('')) print(int((inp - 1) * inp * (inp + 1) / 6 + inp))
""" def find_next_wildcard(s, n): for i in range(n, len(s)): if s[i] == '?': index = i break else: index = i+1 return index def wildcard_main(s): #print(len(s), [n for n in range(3,2)]) wildcard(s, find_next_wildcard(s, 0)) def wildcard(s, n): if...
""" def find_next_wildcard(s, n): for i in range(n, len(s)): if s[i] == '?': index = i break else: index = i+1 return index def wildcard_main(s): #print(len(s), [n for n in range(3,2)]) wildcard(s, find_next_wildcard(s, 0)) def wildcard(s, n): if...
""" ========= Associate ========= Widgets for association rules. """ # Category description for the widget registry NAME = "WISE 2 Tools" DESCRIPTION = "Widgets for WISE 2" BACKGROUND = "#FD8D8D" ICON = "icons/tools.png" PRIORITY = 303
""" ========= Associate ========= Widgets for association rules. """ name = 'WISE 2 Tools' description = 'Widgets for WISE 2' background = '#FD8D8D' icon = 'icons/tools.png' priority = 303
#File name: SUDOKU.py #Finding unsige cell def FindUnsignedLocation(Board, l): for row in range(0,9): for col in range(0,9): if (Board[row][col] == 0): l[0] = row l[1] = col return True return False def InRow(Board, row, num): ...
def find_unsigned_location(Board, l): for row in range(0, 9): for col in range(0, 9): if Board[row][col] == 0: l[0] = row l[1] = col return True return False def in_row(Board, row, num): for i in range(0, 9): if Board[row][i] == nu...
[ [0.02175933, 0.03332428, 0.04187784, 0.03716728, 0.0308031, 0.01415677], [0.02346025, 0.03427124, 0.04290557, 0.0354381, 0.02346025, 0.01953654], ]
[[0.02175933, 0.03332428, 0.04187784, 0.03716728, 0.0308031, 0.01415677], [0.02346025, 0.03427124, 0.04290557, 0.0354381, 0.02346025, 0.01953654]]
def limits(signed, bit_size): signed_limit = 2 ** (bit_size - 1) return (-signed_limit, signed_limit - 1) if signed else (0, 2 * signed_limit - 1) def str_int(signed, bit_size): s = "u" if not signed else "" s += "int" s += "%s" % bit_size return s def assert_int_in_range(value, signed, bit_...
def limits(signed, bit_size): signed_limit = 2 ** (bit_size - 1) return (-signed_limit, signed_limit - 1) if signed else (0, 2 * signed_limit - 1) def str_int(signed, bit_size): s = 'u' if not signed else '' s += 'int' s += '%s' % bit_size return s def assert_int_in_range(value, signed, bit_si...
def alternatingCharacters(s): deleted = 0 for i in range(0,len(s)): while True: if i+1 < len(s): if s[i] == s[i+1]: s.pop(i+1) deleted += 1 else: break else: return del...
def alternating_characters(s): deleted = 0 for i in range(0, len(s)): while True: if i + 1 < len(s): if s[i] == s[i + 1]: s.pop(i + 1) deleted += 1 else: break else: return...
class Solution: # @param {integer[]} nums # @return {integer[]} def singleNumber(self, nums): xor = reduce(operator.xor, nums) res = reduce(operator.xor, (x for x in nums if x & xor & -xor)) return [res, res ^ xor]
class Solution: def single_number(self, nums): xor = reduce(operator.xor, nums) res = reduce(operator.xor, (x for x in nums if x & xor & -xor)) return [res, res ^ xor]
class Solution: def num_decodings(self, s: str) -> int: self.memoize = {} return self.find(s) def find(self, s): if s in self.memoize: return self.memoize[s] elif s == '': return 1 else: qty = 0 if int(s[:1]) > 0: ...
class Solution: def num_decodings(self, s: str) -> int: self.memoize = {} return self.find(s) def find(self, s): if s in self.memoize: return self.memoize[s] elif s == '': return 1 else: qty = 0 if int(s[:1]) > 0: ...
""" FUNCTIONS: 1. Write a Python function to find the Max of three numbers. 2. Write a Python program to reverse a string. Sample String : "1234abcd" Expected Output : "dcba4321" 3. Write a Python function to sum all the numbers in a list. Sample List : (8, 2, 3, 0, 7) Expected Output : 20 4. Write a Python functi...
""" FUNCTIONS: 1. Write a Python function to find the Max of three numbers. 2. Write a Python program to reverse a string. Sample String : "1234abcd" Expected Output : "dcba4321" 3. Write a Python function to sum all the numbers in a list. Sample List : (8, 2, 3, 0, 7) Expected Output : 20 4. Write a Python functi...
side = 1080 frames = 48 def shape(thickness): fill(0) stroke(1) strokeWidth(1) with savedState(): rotate(startAngle + f * (endAngle - startAngle), (thickness*0.1, thickness*0.1)) rect(0 - (thickness/2), 0 - (thickness/2), thickness, thickness) for i in range(frames): phase = 2 * pi...
side = 1080 frames = 48 def shape(thickness): fill(0) stroke(1) stroke_width(1) with saved_state(): rotate(startAngle + f * (endAngle - startAngle), (thickness * 0.1, thickness * 0.1)) rect(0 - thickness / 2, 0 - thickness / 2, thickness, thickness) for i in range(frames): phase = 2...
#define a dictionary data structure #dictionaries have a key : value pair for elements example_dict = { "class":"Astr 119", "prof":"Brant", "awesomeness":10 } print(type(example_dict)) #get a value using a key course = example_dict["class"] print(course) #change a value using a key example_dict["awesomeness"]+=1...
example_dict = {'class': 'Astr 119', 'prof': 'Brant', 'awesomeness': 10} print(type(example_dict)) course = example_dict['class'] print(course) example_dict['awesomeness'] += 1 print(example_dict) for x in example_dict.keys(): print(x, example_dict[x])
""" Solution for Leet Code 657. """ class Solution: def judgeCircle(moves): i = j = 0 for move in moves: if move is 'U': i += 1 elif move is 'D': i -= 1 elif move is 'L': j += 1 else: j ...
""" Solution for Leet Code 657. """ class Solution: def judge_circle(moves): i = j = 0 for move in moves: if move is 'U': i += 1 elif move is 'D': i -= 1 elif move is 'L': j += 1 else: j...
class Solution: def rob(self, nums): """ :type nums: List[int] :rtype: int """ if len(nums) == 0: return 0 if len(nums) == 1: return nums[0] m = [0] * len(nums) m[0] = nums[0] m[1] = m[0] if m[0] > nums[1] else nums[1]...
class Solution: def rob(self, nums): """ :type nums: List[int] :rtype: int """ if len(nums) == 0: return 0 if len(nums) == 1: return nums[0] m = [0] * len(nums) m[0] = nums[0] m[1] = m[0] if m[0] > nums[1] else nums[1] ...
# Python 3 Program to find # sum of Fibonacci numbers # Computes value of first # fibonacci numbers def calculateSum(n) : if (n <= 0) : return 0 fibo =[0] * (n+1) fibo[1] = 1 # Initialize result sm = fibo[0] + fibo[1] # Add remaining terms for i in range(2,n+1) : fibo[i] = fibo[i-1] + fibo[i-2] sm = s...
def calculate_sum(n): if n <= 0: return 0 fibo = [0] * (n + 1) fibo[1] = 1 sm = fibo[0] + fibo[1] for i in range(2, n + 1): fibo[i] = fibo[i - 1] + fibo[i - 2] sm = sm + fibo[i] return sm n = int(input()) print('Sum of Fibonacci numbers is : ', calculate_sum(n))
# Calculando descontos produto = float(input('Qual o valor do produto ? R$ ')) novo = produto - (produto * 5 / 100) print('O produto com 5% de desconto ficara : R$ {:.2f} '.format(novo))
produto = float(input('Qual o valor do produto ? R$ ')) novo = produto - produto * 5 / 100 print('O produto com 5% de desconto ficara : R$ {:.2f} '.format(novo))
def can_build(env, platform): return platform=="android" or platform=="iphone" def configure(env): if (env['platform'] == 'android'): env.android_add_dependency("implementation \"com.android.support:support-v4:28.0.0\"") env.android_add_dependency("implementation \"com.google.android.gms:play-services-location:1...
def can_build(env, platform): return platform == 'android' or platform == 'iphone' def configure(env): if env['platform'] == 'android': env.android_add_dependency('implementation "com.android.support:support-v4:28.0.0"') env.android_add_dependency('implementation "com.google.android.gms:play-se...
class Node(object): TRUE = 't' FALSE = 'f' QUERY = '?' NOTHING = '-' def __init__(self, name): self.name = name self.status = self.NOTHING self.cpt = [] self.index = None self.__children = [] self.__parents = [] return def __str__(self):...
class Node(object): true = 't' false = 'f' query = '?' nothing = '-' def __init__(self, name): self.name = name self.status = self.NOTHING self.cpt = [] self.index = None self.__children = [] self.__parents = [] return def __str__(self): ...
# -*- coding: utf-8 -*- ''' File name: code\su_doku\sol_96.py Author: Vaidic Joshi Date created: Oct 20, 2018 Python Version: 3.x ''' # Solution to Project Euler Problem #96 :: Su Doku # # For more information see: # https://projecteuler.net/problem=96 # Problem Statement ''' Su Doku (Japanese mean...
""" File name: code\\su_doku\\sol_96.py Author: Vaidic Joshi Date created: Oct 20, 2018 Python Version: 3.x """ '\nSu Doku (Japanese meaning number place) is the name given to a popular puzzle concept. Its origin is unclear, but credit must be attributed to Leonhard Euler who invented a similar, and muc...
array = [list(map(int, input().split())) for i in range(5)] check = [list(map(int, input().split())) for i in range(5)] def checkBingo(arr): bingoNum = 0 rightSlide = 0 leftSlide = 0 for i in range(5): colZeroNum = 0 verZeroNum = 0 for j in range(5): if...
array = [list(map(int, input().split())) for i in range(5)] check = [list(map(int, input().split())) for i in range(5)] def check_bingo(arr): bingo_num = 0 right_slide = 0 left_slide = 0 for i in range(5): col_zero_num = 0 ver_zero_num = 0 for j in range(5): if arr[i...
def seq_search(lst, element): pos = 0 found = False while pos < len(lst) and not found: if lst[pos] == element: found = True else: pos += 1 return found arr = [1,2,3,4,5,56] print(seq_search(arr,3)) print(seq_search(arr,56)) print(seq_search(arr,1)) print(se...
def seq_search(lst, element): pos = 0 found = False while pos < len(lst) and (not found): if lst[pos] == element: found = True else: pos += 1 return found arr = [1, 2, 3, 4, 5, 56] print(seq_search(arr, 3)) print(seq_search(arr, 56)) print(seq_search(arr, 1)) prin...
#!/usr/bin/env python3 # https://abc061.contest.atcoder.jp/tasks/abc061_b n, m = map(int, input().split()) a = [0] * n for _ in range(m): u, v = map(int, input().split()) a[u - 1] += 1 a[v - 1] += 1 for x in a: print(x)
(n, m) = map(int, input().split()) a = [0] * n for _ in range(m): (u, v) = map(int, input().split()) a[u - 1] += 1 a[v - 1] += 1 for x in a: print(x)
languages = [ { 'language' : 'lang_cpp', 'display_name' : 'C++', 'build_configurations' : [ { 'compiler': 'msvc', 'builder': 'build_cpp_sources_with_msvc', }, { 'compiler': 'gcc', 'bui...
languages = [{'language': 'lang_cpp', 'display_name': 'C++', 'build_configurations': [{'compiler': 'msvc', 'builder': 'build_cpp_sources_with_msvc'}, {'compiler': 'gcc', 'builder': 'build_cpp_sources_with_gcc'}, {'compiler': 'clang', 'builder': 'build_cpp_sources_with_clang'}]}, {'language': 'lang_d', 'display_name': '...
""" This module contains the various utilities that may be useful in lab anaylysis and operating on the waveforms. """
""" This module contains the various utilities that may be useful in lab anaylysis and operating on the waveforms. """
# Python Comments # Single line comment print("End of line comment, which will ignore anything after # and treat is as comment \n\n") # End of line comments # This # is # Multi line comments print("Multi line comment is nothing but using the # to be prefixed at start of the line.\n\n") """ Well this is also a...
print('End of line comment, which will ignore anything after # and treat is as comment \n\n') print('Multi line comment is nothing but using the # to be prefixed at start of the line.\n\n') "\nWell this\nis also another way to write\nmulti line comments.\nThis is actually a string value in multi line\nsince this is not...
# %% # Ensure the target is unchanged # assert all(y_tr.sort_index() == original_y_train.sort_index()) # Ensure the target is unchanged (unshuffled!) # assert all(y_tr == original_y_train) # %% Predict on X_tr for comparison y_tr_predicted = clf_grid_BEST.predict(X_tr) # original_y_train.value_counts() # y_tr.cat.cod...
y_tr_predicted = clf_grid_BEST.predict(X_tr) train_kappa = kappa(y_tr, y_tr_predicted) logging.info('Metric on training set: {:0.3f}'.format(train_kappa)) sk.metrics.confusion_matrix(y_tr, y_tr_predicted) if CV_FRACTION > 0: y_cv_predicted = clf_grid_BEST.predict(X_cv) train_kappa_cv = kappa(y_cv, y_cv_predicte...
def fun(a,b,c,d,e,f): if(a>=d and b>=e and c>=f) and (a>d or b>e or c>f): return 1 elif(a<=d and b<=e and c<=f) and (a<d or b<e or c<f): return 1 return 0 for i in range(int(input())): a = [int(j) for j in input().split()] b = [int(j) for j in input().split()] c = [int(j) for j ...
def fun(a, b, c, d, e, f): if (a >= d and b >= e and (c >= f)) and (a > d or b > e or c > f): return 1 elif (a <= d and b <= e and (c <= f)) and (a < d or b < e or c < f): return 1 return 0 for i in range(int(input())): a = [int(j) for j in input().split()] b = [int(j) for j in input...
""" Demos on some detailed use cases for Dragonfly. We use domains and configurations from an electrolyte design task, but use synthetic functions instead. -- kirthevasank """
""" Demos on some detailed use cases for Dragonfly. We use domains and configurations from an electrolyte design task, but use synthetic functions instead. -- kirthevasank """
class TwoSum: def __init__(self, arr , target: int) : self.arr = arr self.target = target def get_to_sum(self): i = 0 while i<len(arr): val = target - arr[i] if val in arr[i+1:]: return [i, arr.index(val, i+1)] else: ...
class Twosum: def __init__(self, arr, target: int): self.arr = arr self.target = target def get_to_sum(self): i = 0 while i < len(arr): val = target - arr[i] if val in arr[i + 1:]: return [i, arr.index(val, i + 1)] else: ...
def all_are_none(*args) -> bool: """ Return True if all args are None. """ return all([arg is None for arg in args]) def none_are_none(*args) -> bool: """ Return True if no args are None. """ return not any([arg is None for arg in args]) def any_are_not_none(*args) -> bool: """ ...
def all_are_none(*args) -> bool: """ Return True if all args are None. """ return all([arg is None for arg in args]) def none_are_none(*args) -> bool: """ Return True if no args are None. """ return not any([arg is None for arg in args]) def any_are_not_none(*args) -> bool: """ ...
mod = pow(10, 9)+7 match = dict() for i in range(26): match[chr(i+97)] = i+1 def rabin_karp(text, pattern): n, m = len(text), len(pattern) if n < m: return False hash_pattern = 0 i = 0 for p in pattern[::-1]: hash_pattern = (hash_pattern + pow(26, i, mod) * match[p]) % mod ...
mod = pow(10, 9) + 7 match = dict() for i in range(26): match[chr(i + 97)] = i + 1 def rabin_karp(text, pattern): (n, m) = (len(text), len(pattern)) if n < m: return False hash_pattern = 0 i = 0 for p in pattern[::-1]: hash_pattern = (hash_pattern + pow(26, i, mod) * match[p]) %...
class GenericRetriesHandler: def __init__(self, *args, **kwargs): self.count = 0 def is_eligible(self, response): raise NotImplementedError def increment(self): self.count += 1
class Genericretrieshandler: def __init__(self, *args, **kwargs): self.count = 0 def is_eligible(self, response): raise NotImplementedError def increment(self): self.count += 1
class Solution(object): def rotateString(self, A, B): """ :type A: str :type B: str :rtype: bool """ if not all([A, B]): return A == B if len(A) != len(B): return False pos = B.rfind(A[0]) while pos != -1: if...
class Solution(object): def rotate_string(self, A, B): """ :type A: str :type B: str :rtype: bool """ if not all([A, B]): return A == B if len(A) != len(B): return False pos = B.rfind(A[0]) while pos != -1: ...
def get_answer(lines): # print(lines) lowwater = 0 highwater = len(lines) - 1 j = highwater # print(f"highwater= {highwater}, lowwater= {lowwater}") while lowwater < j: sum = lines[lowwater] + lines[j] if sum == 2020: return(lines[lowwater] * lines[j]) elif ...
def get_answer(lines): lowwater = 0 highwater = len(lines) - 1 j = highwater while lowwater < j: sum = lines[lowwater] + lines[j] if sum == 2020: return lines[lowwater] * lines[j] elif lowwater == j - 1 or sum < 2020: lowwater += 1 j = highwate...
#=========================================================================== # This library is free software; you can redistribute it and/or # modify it under the terms of version 2.1 of the GNU Lesser General Public # License as published by the Free Software Foundation. # # This library is distributed in the hope tha...
def is_char_convertible(c): """Assert that the given value is convertible to a character using the %c conversion. This implies that c is either an integer, or a character (i.e. a string of length 1). """ assert isinstance(c, int) or (isinstance(c, str) and len(c) == 1), '%s is not convertible to a ...
defaults = { "Wiki homepage": "Contents", "Default tab on page load": ("History", "Articles", "Tabs"), "Save pasted images as": ("JPEG", "PNG"), } DB_SCHEMA = 0 PRODUCT_NAME = "Folio" PRODUCT_VERSION = "0.0.7a" PRODUCT = f"{PRODUCT_NAME} ver {PRODUCT_VERSION}"
defaults = {'Wiki homepage': 'Contents', 'Default tab on page load': ('History', 'Articles', 'Tabs'), 'Save pasted images as': ('JPEG', 'PNG')} db_schema = 0 product_name = 'Folio' product_version = '0.0.7a' product = f'{PRODUCT_NAME} ver {PRODUCT_VERSION}'
qtd=(int(input("Enter with the quantity: "))) if(qtd<1): while True: print("Error! The quantity needs to be positive") qtd=(int(input("Enter with the quantity: "))) if not(qtd<1): break def converter(number): return number*-1 number=[] for i in range(qtd): ...
qtd = int(input('Enter with the quantity: ')) if qtd < 1: while True: print('Error! The quantity needs to be positive') qtd = int(input('Enter with the quantity: ')) if not qtd < 1: break def converter(number): return number * -1 number = [] for i in range(qtd): number.a...
class Bar: def __init__( self, ticker: str, ts: int, open: float, high: float, low: float, close: float, adj_close: float, volume: int, _id: int = None ) -> None: self.id = _id self.ticker = ticker self.date ...
class Bar: def __init__(self, ticker: str, ts: int, open: float, high: float, low: float, close: float, adj_close: float, volume: int, _id: int=None) -> None: self.id = _id self.ticker = ticker self.date = ts self.open = open self.high = high self.low = low s...
"""Hello World https://exercism.org/tracks/python/exercises/hello-world """ def hello() -> str: """Hello. Returns: str: Hello world response. """ return "Hello, World!"
"""Hello World https://exercism.org/tracks/python/exercises/hello-world """ def hello() -> str: """Hello. Returns: str: Hello world response. """ return 'Hello, World!'
#quick Sorting def quick_sort(list): if len(list)<2: return list else: pivot=int(list.pop()) right_items,left_items=[],[] for item in list: if int(item)>pivot: right_items.append(int(item)) else: left_items.append(int(item))...
def quick_sort(list): if len(list) < 2: return list else: pivot = int(list.pop()) (right_items, left_items) = ([], []) for item in list: if int(item) > pivot: right_items.append(int(item)) else: left_items.append(int(item)) ...
TABLE_CLOTH_DELTA = 0.6 TABLE_CLOTH_TEXTILE_PRICE = 7 CARRE_TEXTILE_PRICE = 9 USD_TO_BGN = 1.85 number_of_tables = int(input('Rectangular tables')) table_length = float(input('Tables length')) table_width = float(input('Table width')) area_table_cloth = (table_length + TABLE_CLOTH_DELTA) * (table_width + TAB...
table_cloth_delta = 0.6 table_cloth_textile_price = 7 carre_textile_price = 9 usd_to_bgn = 1.85 number_of_tables = int(input('Rectangular tables')) table_length = float(input('Tables length')) table_width = float(input('Table width')) area_table_cloth = (table_length + TABLE_CLOTH_DELTA) * (table_width + TABLE_CLOTH_DE...
# Copyright 2009-2017 Ram Rachum. # This program is distributed under the MIT license. data = '''James John Robert Michael William David Richard Charles Joseph Thomas Christopher Daniel Paul Mark Donald George Kenneth Steven Edward Brian Ronald Anthony Kevin Jason Matthew Gary Timothy Jose Larry Jeffrey Frank Scott Er...
data = 'James\nJohn\nRobert\nMichael\nWilliam\nDavid\nRichard\nCharles\nJoseph\nThomas\nChristopher\nDaniel\nPaul\nMark\nDonald\nGeorge\nKenneth\nSteven\nEdward\nBrian\nRonald\nAnthony\nKevin\nJason\nMatthew\nGary\nTimothy\nJose\nLarry\nJeffrey\nFrank\nScott\nEric\nStephen\nAndrew\nRaymond\nGregory\nJoshua\nJerry\nDenn...
n = int(input()) grid = [] for i in range(n): grid.append([int(x) for x in input().split(' ')]) def valid(g): for y in range(n): for x in range(n): if (x+1 < n): if not (g[y][x] < g[y][x+1]): return False if (y+1 < n): if not ...
n = int(input()) grid = [] for i in range(n): grid.append([int(x) for x in input().split(' ')]) def valid(g): for y in range(n): for x in range(n): if x + 1 < n: if not g[y][x] < g[y][x + 1]: return False if y + 1 < n: if not g...
# https://atcoder.jp/contests/math-and-algorithm/tasks/typical90_n n = int(input()) aa = list(sorted(map(int, input().split()))) bb = list(sorted(map(int, input().split()))) print(sum([abs(aa[i] - bb[i]) for i in range(n)]))
n = int(input()) aa = list(sorted(map(int, input().split()))) bb = list(sorted(map(int, input().split()))) print(sum([abs(aa[i] - bb[i]) for i in range(n)]))
class RegistObject(object): def __init__(self,object_name,scope=None,params=None): self.object_name=object_name self.scope=scope self.params=params class RegistObjectName(object): def __init__(self,object_name,scope=None): self.object_name=object_name self.scope=scope c...
class Registobject(object): def __init__(self, object_name, scope=None, params=None): self.object_name = object_name self.scope = scope self.params = params class Registobjectname(object): def __init__(self, object_name, scope=None): self.object_name = object_name self...
# LEER panchofile = open('panchofile.txt', 'w') print(panchofile) # r = panchofile.readlines() # panchofile.write("\nVerso 1") panchofile.close()
panchofile = open('panchofile.txt', 'w') print(panchofile) panchofile.close()
"""Constants for readme.""" # Base component constants DOMAIN = "readme" DOMAIN_DATA = f"{DOMAIN}_data" VERSION = "0.2.1" REQUIRED_FILES = [ "translations/en.json", "const.py", "config_flow.py", "default.j2", "manifest.json", "services.yaml", ] ISSUE_URL = "https://github.com/custom-components/r...
"""Constants for readme.""" domain = 'readme' domain_data = f'{DOMAIN}_data' version = '0.2.1' required_files = ['translations/en.json', 'const.py', 'config_flow.py', 'default.j2', 'manifest.json', 'services.yaml'] issue_url = 'https://github.com/custom-components/readme/issues'
class Foo: @staticmethod def bar(x): """bar() can be called without instantiating from Foo""" print(x, "on class") def nbar(self, x): """nbar() can be used on an instance of Foo""" print(x, "on", self) Foo.bar("class bar") # Foo.nbar("class nbar") # Foo.nbar(Foo, "class nb...
class Foo: @staticmethod def bar(x): """bar() can be called without instantiating from Foo""" print(x, 'on class') def nbar(self, x): """nbar() can be used on an instance of Foo""" print(x, 'on', self) Foo.bar('class bar') foo = foo() foo.bar('instance bar') foo.nbar('insta...
"""Double linked list class defined.""" class DoublylinkedList: def __init__(self): self.head = None self.tail = None def set_head_to(self, node): if self.head == node: return elif self.head is None: self.head = node self.tail = node ...
"""Double linked list class defined.""" class Doublylinkedlist: def __init__(self): self.head = None self.tail = None def set_head_to(self, node): if self.head == node: return elif self.head is None: self.head = node self.tail = node ...
#!/usr/bin/env python # -*- encoding: utf-8 -*- """ @author: jayzhen @license: Apache Licence @version: v1.0 @contact: jayzhen_testing@163.com @site: http://blog.csdn.net/u013948858 @file: __init__.py.py @time: 2017/10/27 22:50 """
""" @author: jayzhen @license: Apache Licence @version: v1.0 @contact: jayzhen_testing@163.com @site: http://blog.csdn.net/u013948858 @file: __init__.py.py @time: 2017/10/27 22:50 """
class State: def __init__(self, words_following_dict, name, type_dict): self.words_following_dict = words_following_dict # Dictionary of words which lead to new states self.name = name # name of the state self.type_dict = type_dict #dict of type "State_name" : State to avoid circular problem...
class State: def __init__(self, words_following_dict, name, type_dict): self.words_following_dict = words_following_dict self.name = name self.type_dict = type_dict def __str__(self): return '[State: ' + self.name + ']' def __eq__(self, other): return str(self) == ...
#################################################################################### # Larabot Discord Bot # MIT License # Copyright (c) 2017 Devitgg # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the So...
def token(): token = 'insert here' return token def google_key(): this = 'insert here' return this def mod_authority(message): approved_roles = ['insert here'] for role in message.server.roles: for approved in approvedRoles: if approved == role.name: return ...
class Solution(object): def longestValidParentheses(self, s): """ :type s: str :rtype: int """ k = [0] c = 0 ans = 0 for i in range(len(s)): if s[i] == '(': c += 1 else: c -= 1 k.appen...
class Solution(object): def longest_valid_parentheses(self, s): """ :type s: str :rtype: int """ k = [0] c = 0 ans = 0 for i in range(len(s)): if s[i] == '(': c += 1 else: c -= 1 k.ap...
employee_one = int(input()) employee_two = int(input()) employee_three = int(input()) people_count = int(input()) all_employees = employee_one + employee_two + employee_three # this many per hour people_answered = 0 hours_needed =0 while people_answered < people_count: hours_needed += 1 if hours_needed % 4 =...
employee_one = int(input()) employee_two = int(input()) employee_three = int(input()) people_count = int(input()) all_employees = employee_one + employee_two + employee_three people_answered = 0 hours_needed = 0 while people_answered < people_count: hours_needed += 1 if hours_needed % 4 == 0: people_ans...
def loadyaml(path): ''' Read the config file with yaml :param path: the config file path :return: bidict ''' doc = [] if os.path.exists(path): with codecs.open(path, 'r') as yf: doc = yaml.safe_load(yf) return doc
def loadyaml(path): """ Read the config file with yaml :param path: the config file path :return: bidict """ doc = [] if os.path.exists(path): with codecs.open(path, 'r') as yf: doc = yaml.safe_load(yf) return doc
n = 0 for i in range(1,6): n = n + 1 print(n) print('\n') n = 0 for i in range(1,11): n = n + 1 print(n) print('\n') n = 0 for i in range(0,6): n = n+i**2 print(n) print('\n') n = 0 for i in range(0,6): n = n+i**3 print(n) print('\n') n = 0 for i in range(0,6): n = n + (i - 1)**2 print(n) print('\n')...
n = 0 for i in range(1, 6): n = n + 1 print(n) print('\n') n = 0 for i in range(1, 11): n = n + 1 print(n) print('\n') n = 0 for i in range(0, 6): n = n + i ** 2 print(n) print('\n') n = 0 for i in range(0, 6): n = n + i ** 3 print(n) print('\n') n = 0 for i in range(0, 6): n = n + (...
# # PySNMP MIB module MY-TC (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/MY-TC # Produced by pysmi-0.3.4 at Wed May 1 14:16:14 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) # ...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, value_range_constraint, value_size_constraint, constraints_intersection, single_value_constraint) ...
class Organism: alive = True class Animal(Organism): def eat(self): print("This animal is eating!") class Dog(Animal): def bark(self): print("This dog is barking!") dog = Dog() print(dog.alive) dog.eat() dog.bark()
class Organism: alive = True class Animal(Organism): def eat(self): print('This animal is eating!') class Dog(Animal): def bark(self): print('This dog is barking!') dog = dog() print(dog.alive) dog.eat() dog.bark()
def test_firstname_lastname_address(app): contact_from_home_page = app.contact.get_contact_list()[0] contact_from_edit_page = app.contact.get_contact_info_from_edit_page(0) assert contact_from_home_page.firstname == contact_from_edit_page.firstname assert contact_from_home_page.lastname == contact_from_...
def test_firstname_lastname_address(app): contact_from_home_page = app.contact.get_contact_list()[0] contact_from_edit_page = app.contact.get_contact_info_from_edit_page(0) assert contact_from_home_page.firstname == contact_from_edit_page.firstname assert contact_from_home_page.lastname == contact_from_...
def multiples (): y = list (range(1,21)) for x in y: if x % 2 == 0: print(x) multiples()
def multiples(): y = list(range(1, 21)) for x in y: if x % 2 == 0: print(x) multiples()
n=str(input("Enter the string")) le=len(n) count=0 for i in range(le-1): for j in range(le): if n[j]==n[i]: count=count+1 else: continue print("%s count is :%d"%(n[i],count)) count=0
n = str(input('Enter the string')) le = len(n) count = 0 for i in range(le - 1): for j in range(le): if n[j] == n[i]: count = count + 1 else: continue print('%s count is :%d' % (n[i], count)) count = 0
statusT = """ VAULT: {} KEY: {} PROJECT: {} ENV: {} AWS/profile? {} AWS/key? {} AWS/secret? {}""" helpT = """ 1. Run setup 2. Check that AWS environment variables for profile OR key+secret are set """
status_t = '\nVAULT: {}\nKEY: {}\nPROJECT: {} \nENV: {}\nAWS/profile? {}\nAWS/key? {}\nAWS/secret? {}' help_t = '\n1. Run setup\n2. Check that AWS environment variables for profile OR key+secret are set\n'
# Databricks notebook source # MAGIC %md # MAGIC References:<br> # MAGIC https://docs.azuredatabricks.net/user-guide/secrets/secrets.html<br> # MAGIC https://docs.azuredatabricks.net/spark/latest/data-sources/azure/azure-storage.html<br> # MAGIC https://docs.azuredatabricks.net/user-guide/dbfs-databricks-file-system.ht...
storage_acct_name = 'pxbrixsa' container_name = 'hack' secret_scope_name = 'pzbrixscope' secret_name = 'pzbrixsakey' mount_point = '/mnt/' + containerName dbutils.fs.mount(source='wasbs://hack@sa.blob.core.windows.net', mount_point=mountPoint, extra_configs={'fs.azure.account.key.pzbrixsa.blob.core.windows.net': dbutil...
#!/usr/bin/env python3 """module: syllable_filter author: R Steiner license: MIT, copyright (c) 2016 R Steiner Contains class SyllableFilter. """ class SyllableFilter: """This script takes a list of words and returns only those with the specified number of syllables. Syllables will be counted heuristically,...
"""module: syllable_filter author: R Steiner license: MIT, copyright (c) 2016 R Steiner Contains class SyllableFilter. """ class Syllablefilter: """This script takes a list of words and returns only those with the specified number of syllables. Syllables will be counted heuristically, as the number of vow...
# -*- coding: utf-8 -*- class ConnectorException(Exception): pass class UnsupportedDriver(ConnectorException): def __init__(self, driver): message = 'Driver "%s" is not supported' % driver super(UnsupportedDriver, self).__init__(message)
class Connectorexception(Exception): pass class Unsupporteddriver(ConnectorException): def __init__(self, driver): message = 'Driver "%s" is not supported' % driver super(UnsupportedDriver, self).__init__(message)
""" Useful annotators """ def auto_str(cls): """ Add implementation of __str__ and __repr__ functions to a class """ def __str__(self): return type(self).__name__ + '{' + ','.join(f'{k}={str(v)}' for k, v, in vars(self).items()) + '}' def __repr__(self): return type(self).__qualn...
""" Useful annotators """ def auto_str(cls): """ Add implementation of __str__ and __repr__ functions to a class """ def __str__(self): return type(self).__name__ + '{' + ','.join((f'{k}={str(v)}' for (k, v) in vars(self).items())) + '}' def __repr__(self): return type(self).__qua...
# added but not implemented. Not convinced its needed yet, """ from fabric.api import local myapp = "DictionaryOfNewZealandEnglish" def prepare_deployment(branch_name): local('python manage.py test ' + myapp) local('git add -p && git commit') local('git checkout master && git merge ' + branch_name) fro...
""" from fabric.api import local myapp = "DictionaryOfNewZealandEnglish" def prepare_deployment(branch_name): local('python manage.py test ' + myapp) local('git add -p && git commit') local('git checkout master && git merge ' + branch_name) from fabric.api import lcd def deploy(): with lcd('/path/to...
class TransactCounterSingleton(object): def __new__(cls): if not hasattr(cls, 'instance'): cls.instance = super(TransactCounterSingleton, cls).__new__(cls) cls.instance.count = 0 return cls.instance @staticmethod def get_id(): result = TransactCounterSingleto...
class Transactcountersingleton(object): def __new__(cls): if not hasattr(cls, 'instance'): cls.instance = super(TransactCounterSingleton, cls).__new__(cls) cls.instance.count = 0 return cls.instance @staticmethod def get_id(): result = transact_counter_singl...
"""Constants for the Integration - Riemann sum integral integration.""" DOMAIN = "integration" CONF_ROUND_DIGITS = "round" CONF_SOURCE_SENSOR = "source" CONF_UNIT_OF_MEASUREMENT = "unit" CONF_UNIT_PREFIX = "unit_prefix" CONF_UNIT_TIME = "unit_time" METHOD_TRAPEZOIDAL = "trapezoidal" METHOD_LEFT = "left" METHOD_RIGHT...
"""Constants for the Integration - Riemann sum integral integration.""" domain = 'integration' conf_round_digits = 'round' conf_source_sensor = 'source' conf_unit_of_measurement = 'unit' conf_unit_prefix = 'unit_prefix' conf_unit_time = 'unit_time' method_trapezoidal = 'trapezoidal' method_left = 'left' method_right = ...
BOT_NAME = 'GroeneScrapy' SPIDER_MODULES = ['GroeneScrapy.spiders'] NEWSPIDER_MODULE = 'GroeneScrapy.spiders' LOG_LEVEL = 'ERROR' GROENE_USERNAME = 'Enter your e-mail address here' GROENE_PASSWORD = 'Enter your password here' GROENE_PDF_PATH = 'GroenePDF'
bot_name = 'GroeneScrapy' spider_modules = ['GroeneScrapy.spiders'] newspider_module = 'GroeneScrapy.spiders' log_level = 'ERROR' groene_username = 'Enter your e-mail address here' groene_password = 'Enter your password here' groene_pdf_path = 'GroenePDF'
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Show that a list comprehension is just a 'for loop,' where you save the output to a variable. """ # A 'for loop' for x in range(0, 13): print(x) # The same loop, as a 'list comprehension' [x for x in range(0, 13)] # To save the output of the loop, we would do thi...
"""Show that a list comprehension is just a 'for loop,' where you save the output to a variable. """ for x in range(0, 13): print(x) [x for x in range(0, 13)] example_list_from_for_loop = [] for x in range(0, 13): example_list_from_for_loop.append(x) example_list_from_list_comprehension_loop = [x for x in range...
#!/usr/bin/env python3 def blocks(height, time): offset = 2 * height - 2 return time * height if time % offset == 0 else 0 if __name__ == '__main__': lines = [line.split(': ') for line in open('input').read().split('\n')] heights = {int(pos): int(height) for pos, height in lines} print(sum(map(l...
def blocks(height, time): offset = 2 * height - 2 return time * height if time % offset == 0 else 0 if __name__ == '__main__': lines = [line.split(': ') for line in open('input').read().split('\n')] heights = {int(pos): int(height) for (pos, height) in lines} print(sum(map(lambda col: blocks(heights...
class Event: circle_event = False @property def x(self): return 0 @property def y(self): return 0 def __lt__(self, other): if self.y == other.y and self.x == other.x: return self.circle_event and not other.circle_event if self.y == other.y: ...
class Event: circle_event = False @property def x(self): return 0 @property def y(self): return 0 def __lt__(self, other): if self.y == other.y and self.x == other.x: return self.circle_event and (not other.circle_event) if self.y == other.y: ...
####DEFINE COLOR SWITCH def code_to_class_string(argument): switcher = { 'n02691156': "airplane", 'n02419796': "antelope", 'n02131653': "bear", 'n02834778': "bicycle", 'n01503061': "bird", 'n0292...
def code_to_class_string(argument): switcher = {'n02691156': 'airplane', 'n02419796': 'antelope', 'n02131653': 'bear', 'n02834778': 'bicycle', 'n01503061': 'bird', 'n02924116': 'bus', 'n02958343': 'car', 'n02402425': 'cattle', 'n02084071': 'dog', 'n02121808': 'domestic_cat', 'n02503517': 'elephant', 'n02118333': 'f...
class Grid: def __init__(self, matrix=None): if (matrix): self.matrix = matrix else: self.matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] def __str__(self): return str(str(self.matrix[0][0]) + str(self.matrix[1][0]) + str(self.matrix[2][0]) + "\n" + ...
class Grid: def __init__(self, matrix=None): if matrix: self.matrix = matrix else: self.matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] def __str__(self): return str(str(self.matrix[0][0]) + str(self.matrix[1][0]) + str(self.matrix[2][0]) + '\n' + str(self.matrix[0][...
class HttpCodes(dict): http_100 = (100, 'Continue') http_101 = (101, 'Switching Protocols') http_102 = (102, 'Processing (WebDAV)') http_200 = (200, 'OK') http_201 = (201, 'Created') http_202 = (202, 'Accepted') http_203 = (203, 'Non-Authoritative Information') http_204 = (204, 'No Conte...
class Httpcodes(dict): http_100 = (100, 'Continue') http_101 = (101, 'Switching Protocols') http_102 = (102, 'Processing (WebDAV)') http_200 = (200, 'OK') http_201 = (201, 'Created') http_202 = (202, 'Accepted') http_203 = (203, 'Non-Authoritative Information') http_204 = (204, 'No Conte...
#!/usr/bin/env python # -*-coding: utf-8 -*- #config.py #Dave Landay #LAST UPDATED: 01-01-2020 DEBUG = True SQLALCHEMY_DATABASE_URI = '<PATH_TO_DATABASE.DB>' SECRET_KEY = '<SOME_SECRET_KEY>'
debug = True sqlalchemy_database_uri = '<PATH_TO_DATABASE.DB>' secret_key = '<SOME_SECRET_KEY>'
# AUTOGENERATED BY NBDEV! DO NOT EDIT! __all__ = ["index", "modules", "custom_doc_links", "git_url"] index = {"ShuffleBlock": "00_core.ipynb", "OprtType": "00_core.ipynb", "conv_unit": "00_core.ipynb", "conv": "00_core.ipynb", "relu_conv_bn": "00_core.ipynb", "conv_bn_relu...
__all__ = ['index', 'modules', 'custom_doc_links', 'git_url'] index = {'ShuffleBlock': '00_core.ipynb', 'OprtType': '00_core.ipynb', 'conv_unit': '00_core.ipynb', 'conv': '00_core.ipynb', 'relu_conv_bn': '00_core.ipynb', 'conv_bn_relu': '00_core.ipynb', 'bn_relu_conv': '00_core.ipynb', 'relu_conv': '00_core.ipynb', 'co...
# Open input, and split each line into list of 0 or 1 integers with open('./input', encoding='utf8') as file: vent_lines = [[[int(val) for val in endpoint.split(',')] for endpoint in line.split(' -> ')] for line in file] dims = [0, 0] for line in vent_lines: for val in line: dims[0] ...
with open('./input', encoding='utf8') as file: vent_lines = [[[int(val) for val in endpoint.split(',')] for endpoint in line.split(' -> ')] for line in file] dims = [0, 0] for line in vent_lines: for val in line: dims[0] = max(dims[0], val[0] + 1) dims[1] = max(dims[1], val[1] + 1) points = [[0]...
""" https://docs.opencv.org/master/d4/d86/group__imgproc__filter.html#ga67493776e3ad1a3df63883829375201f void cv::morphologyEx ( InputArray src, OutputArray dst, int op, InputArray kernel, Point anchor = Point(-1,-1), int iterations = 1, int borderType = BORDER_CONSTANT, const Scalar & ...
""" https://docs.opencv.org/master/d4/d86/group__imgproc__filter.html#ga67493776e3ad1a3df63883829375201f void cv::morphologyEx ( InputArray src, OutputArray dst, int op, InputArray kernel, Point anchor = Point(-1,-1), int iterations = 1, int borderType = BORDER_CONSTANT, const Scalar & ...
'''https://leetcode.com/problems/plus-one/''' class Solution: def plusOne(self, digits: List[int]) -> List[int]: digits.reverse() ans = [] c = 1 for d in digits: t = d+c if t>9: t = t-10 c=1 else: c=...
"""https://leetcode.com/problems/plus-one/""" class Solution: def plus_one(self, digits: List[int]) -> List[int]: digits.reverse() ans = [] c = 1 for d in digits: t = d + c if t > 9: t = t - 10 c = 1 else: ...
""" Pattern: Enter the number of rows: 5 EEEEE DDDD CCC BB A """ print('Alphabet Pattern: ') number_rows=int(input('Enter number of rows: ')) for row in range(1,number_rows+1): print(' '*(row-1),str(chr(65+(number_rows-row))+'')*(number_rows+1-row))
""" Pattern: Enter the number of rows: 5 EEEEE DDDD CCC BB A """ print('Alphabet Pattern: ') number_rows = int(input('Enter number of rows: ')) for row in range(1, number_rows + 1): print(' ' * (row - 1), str(chr(65 + (number_rows - row)) + '') * (number_rows + 1 - row))
class Action(): """ ``Action`` own the code intended for modify synergies objects. """ _listen = None """The ``Event`` class to listen.""" _depend = [] """List of ``Action`` who need to be executed before this.""" @classmethod def get_listened_class(cls): """ :retu...
class Action: """ ``Action`` own the code intended for modify synergies objects. """ _listen = None 'The ``Event`` class to listen.' _depend = [] 'List of ``Action`` who need to be executed before this.' @classmethod def get_listened_class(cls): """ :return: The lis...
x = 5 print(5) print(x) print('x') message = 'Hello World!' print(message) message = 'Goodbye cruel world...' print(message)
x = 5 print(5) print(x) print('x') message = 'Hello World!' print(message) message = 'Goodbye cruel world...' print(message)
''' dummy recommender ''' def recommend_random(movies, k=10): """ Dummy recommender that recommends a list of random movies. Ignores the actual query. """ return movies['title'].sample(k).to_list()
""" dummy recommender """ def recommend_random(movies, k=10): """ Dummy recommender that recommends a list of random movies. Ignores the actual query. """ return movies['title'].sample(k).to_list()
class Dobradura: def get_dobrar(self, numero_dobradura): self.numero_dobradura = 1 if type(numero_dobradura) == int and numero_dobradura > 0: for i in range(0,numero_dobradura): self.numero_dobradura = 2**numero_dobradura return self.numero_dobradura el...
class Dobradura: def get_dobrar(self, numero_dobradura): self.numero_dobradura = 1 if type(numero_dobradura) == int and numero_dobradura > 0: for i in range(0, numero_dobradura): self.numero_dobradura = 2 ** numero_dobradura return self.numero_dobradura ...
""" Wrapper """ class Trainer(object): def __init__(self, cfg, model, dataloader_dict, logger): self.cfg = cfg self.modes = self.cfg.MODES self.model = model self.dataloader_dict = dataloader_dict self.logger = logger self.current_epoch = cfg.RESUME_EPOCH_ID if cfg....
""" Wrapper """ class Trainer(object): def __init__(self, cfg, model, dataloader_dict, logger): self.cfg = cfg self.modes = self.cfg.MODES self.model = model self.dataloader_dict = dataloader_dict self.logger = logger self.current_epoch = cfg.RESUME_EPOCH_ID if cfg....
def normal_old_school_method(a,b,tmp): tmp = a a = b b = tmp return a,b def pythonic_swap(a,b): a,b = b,a return a,b if __name__ == '__main__': a,b = 10,25 tmp = 0 print('Original [Before Swap Values]:\t',a,b) print('Old School Method:',normal_old_school_method(a,b,tmp)) p...
def normal_old_school_method(a, b, tmp): tmp = a a = b b = tmp return (a, b) def pythonic_swap(a, b): (a, b) = (b, a) return (a, b) if __name__ == '__main__': (a, b) = (10, 25) tmp = 0 print('Original [Before Swap Values]:\t', a, b) print('Old School Method:', normal_old_school_...
class Vehicle: def __init__(self, max_speed, mileage): self.max_speed = max_speed self.mileage = mileage modelS = Vehicle(200,20) print(modelS.max_speed, modelS.mileage)
class Vehicle: def __init__(self, max_speed, mileage): self.max_speed = max_speed self.mileage = mileage model_s = vehicle(200, 20) print(modelS.max_speed, modelS.mileage)
class Solution(object): def calPoints(self, ops): """ :type ops: List[str] :rtype: int """ listvalue = [] last1 = 0 last2 = 0 sum = 0 for i in range(len(ops)): if (ops[i] == '+'): sum = listvalue[len(listvalue)-1] + ...
class Solution(object): def cal_points(self, ops): """ :type ops: List[str] :rtype: int """ listvalue = [] last1 = 0 last2 = 0 sum = 0 for i in range(len(ops)): if ops[i] == '+': sum = listvalue[len(listvalue) - 1] ...
""" A Python CLI for Atlas-Checks tools """ __version__ = '1.0'
""" A Python CLI for Atlas-Checks tools """ __version__ = '1.0'