content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
__all__ = ["plural", "singular"] def plural(role, count=2): # FIXME: deprecated, use translation metadata if count == 1: return role bits = role.split() if bits[-1][-2:] == "'s": bits[-1] = plural(bits[-1][:-2], count) bits[-1] += "'" if bits[-1][-1] == "s" else "'s" else: ...
__all__ = ['plural', 'singular'] def plural(role, count=2): if count == 1: return role bits = role.split() if bits[-1][-2:] == "'s": bits[-1] = plural(bits[-1][:-2], count) bits[-1] += "'" if bits[-1][-1] == 's' else "'s" else: bits[-1] = {'person': 'people', 'wolf': 'wo...
# # Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target. # # The same repeated number may be chosen from candidates unlimited number of times. # # Note: # # All numbers (including target) w...
class Solution(object): def combination_sum(self, candidates, target): """ :type candidates: List[int] :type target: int :rtype: List[List[int]] """ res = [] self.combination(candidates, target, res, []) return res def combination(self, candidate...
# Copyright 2010 Orbitz WorldWide # # 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 writ...
class Commandargs: def __init__(self): self._existing_args = [] self._args = [] self._without_console_color = False self._tests_to_run = [] self._python_paths = [] self._console_width = '' self._output_directory = '' self._log_level = '' def with...
""" Each age group is 2 years To get from one age group down to the next, you have to minus 3 because an age group is 2 years inclusive """ def get_age_group(age): """Get age group Done by continuously reducing age and going to previous age group and counting how many times this is done Note that si...
""" Each age group is 2 years To get from one age group down to the next, you have to minus 3 because an age group is 2 years inclusive """ def get_age_group(age): """Get age group Done by continuously reducing age and going to previous age group and counting how many times this is done Note that sin...
def sol(): N = int(input()) for i in range(2 * N - 1): if i < N: print(' ' * (N - 1 - i) + '*' * (2 * i + 1)) else: print(' ' * (i - N + 1) + '*' * (4 * N - 3 - 2 * i)) if __name__ == "__main__": sol()
def sol(): n = int(input()) for i in range(2 * N - 1): if i < N: print(' ' * (N - 1 - i) + '*' * (2 * i + 1)) else: print(' ' * (i - N + 1) + '*' * (4 * N - 3 - 2 * i)) if __name__ == '__main__': sol()
# START PROBLEM SET 03 print('Problem Set 03') # Problem 01 print('\nProblem 1') # SETUP destroyed_houses1 = ("straw house",) destroyed_houses2 = ["straw house"] # END SETUP # Problem 02 print('\nProblem 2') # SETUP wolf_dialog_1 = "Little pigs! Little pigs! Let me in! Let me in!" # END SETUP # Problem 03 print(...
print('Problem Set 03') print('\nProblem 1') destroyed_houses1 = ('straw house',) destroyed_houses2 = ['straw house'] print('\nProblem 2') wolf_dialog_1 = 'Little pigs! Little pigs! Let me in! Let me in!' print('\nProblem 3') pigs_dialog_1 = 'No! No! No! Not by the hairs on our chinny chin chin!' print('\nProblem 4') w...
values = [] with open('2020118194823303242491FODDAG77873904000.csv', encoding='cp1252') as fo: ilines = fo.readlines() for line in ilines: elements = line.strip().split(';') if len(elements)!=3: continue if elements[2]=='': continue if elements[2]=='..': continue if elements[2][0]=='"': c...
values = [] with open('2020118194823303242491FODDAG77873904000.csv', encoding='cp1252') as fo: ilines = fo.readlines() for line in ilines: elements = line.strip().split(';') if len(elements) != 3: continue if elements[2] == '': continue if elements[2] == '..': continue if...
# Copyright (c) 2017 Dustin Doloff # Licensed under Apache License v2.0 load( "//labels:labels.bzl", "executable_label", ) load( ":internal.bzl", "generate_bin_file", "generate_gen_file", "zip_files_impl", "zip_runfiles_rule", ) def generate_file(name, contents, file, bin_file): if bin...
load('//labels:labels.bzl', 'executable_label') load(':internal.bzl', 'generate_bin_file', 'generate_gen_file', 'zip_files_impl', 'zip_runfiles_rule') def generate_file(name, contents, file, bin_file): if bin_file: generate_bin_file(name=name, contents=contents, file=file) else: generate_gen_fi...
#!/usr/bin/env python3 def good_score(S, N): score = 0 for i, ab in enumerate(zip(S, S[::-1])): a, b = ab if i == N // 2: break if a != b: score += 1 return score def ans(N, K, S): return abs(K - good_score(S, N)) for t in range(int(input())): N...
def good_score(S, N): score = 0 for (i, ab) in enumerate(zip(S, S[::-1])): (a, b) = ab if i == N // 2: break if a != b: score += 1 return score def ans(N, K, S): return abs(K - good_score(S, N)) for t in range(int(input())): (n, k) = input().split(' '...
class Solution: def isIsomorphic(self, s, t): """ :type s: str :type t: str :rtype: bool """ if not s: return True ch_dict = dict() values = set() i = 0 while i < len(s): if s[i] in ch_dict: if ...
class Solution: def is_isomorphic(self, s, t): """ :type s: str :type t: str :rtype: bool """ if not s: return True ch_dict = dict() values = set() i = 0 while i < len(s): if s[i] in ch_dict: if ...
# This problem was asked by Alibaba. # Given an even number (greater than 2), return two prime numbers whose sum will be equal to the given number. # A solution will always exist. See https://en.wikipedia.org/wiki/Goldbach%27s_conjecture. # Example: # Input: 4 # Output: 2 + 2 = 4 # If there are more than one solution p...
def primes(x): sieve = [True] * x sieve[0] = sieve[1] = False i = 2 while i * i < x: if sieve[i]: for cur in range(i * i, x, i): sieve[cur] = False i += 1 return [i for (i, x) in enumerate(sieve) if x] def goldbach_pair(x): p = primes(x) beg = 0 ...
#SOLUTION OF P21 '''P21 (*) Insert an element at a given position into a list. Example: * (insert-at 'alfa '(a b c d) 2) (A ALFA B C D)''' my_list = ['a','b','c','d','e'] #TAKE THE ELEMENT TO BE ADDED AND WHERE TO ADD AS INPUT elem = input("Enter the data to add = ") pos= int(input('Where to add = ')) def add_elem...
"""P21 (*) Insert an element at a given position into a list. Example: * (insert-at 'alfa '(a b c d) 2) (A ALFA B C D)""" my_list = ['a', 'b', 'c', 'd', 'e'] elem = input('Enter the data to add = ') pos = int(input('Where to add = ')) def add_element(your_list, element, position): length = len(your_list) out_...
class TokenError(Exception): """ Base exception for token errors. """ pass
class Tokenerror(Exception): """ Base exception for token errors. """ pass
# -*- coding: utf-8 -*- """ Created on Fri Jan 1 16:23:55 2021 @author: Abhishek Parashar """ class Solution: def canPartition(self, nums: List[int]) -> bool: def subsetsum(nums,n,w): t=[[False for i in range(w+1)]for i in range(n+1)] for i in range(n+1): ...
""" Created on Fri Jan 1 16:23:55 2021 @author: Abhishek Parashar """ class Solution: def can_partition(self, nums: List[int]) -> bool: def subsetsum(nums, n, w): t = [[False for i in range(w + 1)] for i in range(n + 1)] for i in range(n + 1): t[i][0] = True ...
# # PySNMP MIB module OMNI-gx2dualdrr2x-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/OMNI-gx2dualdrr2x-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:33:56 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (def...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, constraints_union, value_range_constraint, single_value_constraint, value_size_constraint) ...
nb_lists, nb_elements, max_attempts = map(int, input().split()) def get_answer(): answer = int(input()) if answer == -1: exit(0) return answer def print_array(number_array): print(' '.join(map(str, number_array))) for list_id in range(1, nb_lists + 1): print_array([1, 2, 3]) median...
(nb_lists, nb_elements, max_attempts) = map(int, input().split()) def get_answer(): answer = int(input()) if answer == -1: exit(0) return answer def print_array(number_array): print(' '.join(map(str, number_array))) for list_id in range(1, nb_lists + 1): print_array([1, 2, 3]) median_i...
filepath = 'GridLab-D_old.glm' outF = open("GridLab-D.glm", "w") with open(filepath) as fp: line = fp.readline() cnt = 0 index = 1 while line: #print("Line {}: {}".format(cnt, line.strip())) line = fp.readline() if line.strip() == 'object controller {': line = line + "\n \t n...
filepath = 'GridLab-D_old.glm' out_f = open('GridLab-D.glm', 'w') with open(filepath) as fp: line = fp.readline() cnt = 0 index = 1 while line: line = fp.readline() if line.strip() == 'object controller {': line = line + '\n \t name HOUSE_' + str(index) + ';\n' li...
[ "SentenceFeatureGenerator::1.1_counts_individual_int_individual_e_1_[0]", # 0 "SentenceFeatureGenerator::1.1_counts_individual_int_individual_e_3_[0]", # 1 "SentenceFeatureGenerator::3_order_[0]", # 2 "DependencyFeatureGenerator::19_LD_pos_N_gram_LD_1_<NOUN>_[0]", # 3 "DependencyFeatureGenerat...
['SentenceFeatureGenerator::1.1_counts_individual_int_individual_e_1_[0]', 'SentenceFeatureGenerator::1.1_counts_individual_int_individual_e_3_[0]', 'SentenceFeatureGenerator::3_order_[0]', 'DependencyFeatureGenerator::19_LD_pos_N_gram_LD_1_<NOUN>_[0]', 'DependencyFeatureGenerator::19_LD_pos_N_gram_LD_2_<[SOURCE ~~ PUN...
# # PySNMP MIB module ALCATEL-IND1-VRRP3-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ALCATEL-IND1-VRRP3-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:04:46 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (d...
(softent_ind1_vrrp,) = mibBuilder.importSymbols('ALCATEL-IND1-BASE', 'softentIND1Vrrp') (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, constr...
# -*- coding: utf-8 -*- class BaseAI(object): player = None table = None def __init__(self, table, player): self.player = player self.table = table def discard_tile(self): pass
class Baseai(object): player = None table = None def __init__(self, table, player): self.player = player self.table = table def discard_tile(self): pass
# Given numRows, generate the first numRows of Pascal's triangle. # # For example, given numRows = 5, # Return # # [ # [1], # [1,1], # [1,2,1], # [1,3,3,1], # [1,4,6,4,1] # ] # My solution here is not the most efficient (the use of a semi-coroutine here is not really justified) # However, it looks fancy...
class Solution(object): def generate(self, numRows): """ :type numRows: int :rtype: List[List[int]] """ def pascal(n): row = [1] yield row for i in range(1, n): for j in range(len(row) - 1): row[j] += r...
question = "What color are apples?\n(a) Red\n(b) Purple\n(c) Orange\n(d) Yellow" answer = "b" attempt = 3 while attempt <= 3: print(question) guess = input() if guess == answer: print("Correct!") break else: print("Incorrect!") print(f"You have only {attempt-1}/3") ...
question = 'What color are apples?\n(a) Red\n(b) Purple\n(c) Orange\n(d) Yellow' answer = 'b' attempt = 3 while attempt <= 3: print(question) guess = input() if guess == answer: print('Correct!') break else: print('Incorrect!') print(f'You have only {attempt - 1}/3') ...
def najdi_dolzino_cikla(n): dolzina_cikla = 0 list_preostankov = [] x = 1 while True: if x % n == 0: break elif x in list_preostankov: break list_preostankov.append(x) x = (x * 10) % n dolzina_cikla += 1 return dolzina_cikla de...
def najdi_dolzino_cikla(n): dolzina_cikla = 0 list_preostankov = [] x = 1 while True: if x % n == 0: break elif x in list_preostankov: break list_preostankov.append(x) x = x * 10 % n dolzina_cikla += 1 return dolzina_cikla def funkcija...
## Everything in python is considered as a object # Numbers [Integers, Floats] type(5) # => Int Class type(3.142) # => Float Class 5 + 5 # => 10 5 - 5 # => 0 5 * 5 # => 25 5 / 5 # => 1.0 [Float] 5 // 5 # => 1 [Int] 5 ** 5 # => 3125 [5^5] 10 % 3 # => 1 [Modulo] 5 + 5 * 3 # => BIDMAS [Brackets, Indices(Power), Divisio...
type(5) type(3.142) 5 + 5 5 - 5 5 * 5 5 / 5 5 // 5 5 ** 5 10 % 3 5 + 5 * 3 age = 5 age += 5 age -= 5 age /= 5 'hello' 'hello' "he's a mad man" "he's a mad man" greet = 'hello' greet[0] greet[-1] greet[0:3] greet[2:-1] dudes = 'dudes' greet + ' ' + dudes greet * 2 greet.upper() cheeses = 'brie, chedder, stilton' cheeses...
class Queue(): def __init__(self): self.front = 1 self.next = 1 self.data = [] def enqueue(self, newItem): self.data.insert(self.next - 1, newItem) self.next = self.next + 1 self.get() def dequeue(self): if self.front < self.next: self.front = self.front + 1 self.get() ...
class Queue: def __init__(self): self.front = 1 self.next = 1 self.data = [] def enqueue(self, newItem): self.data.insert(self.next - 1, newItem) self.next = self.next + 1 self.get() def dequeue(self): if self.front < self.next: self.fro...
class Solution: """ @param n: the number n @return: the times n convert to 1 """ def digitConvert(self, n): # Write your code here i = 0 while n != 1: if (n % 2) == 0: n = n / 2 else: n = n * 3 + 1 i += 1 ...
class Solution: """ @param n: the number n @return: the times n convert to 1 """ def digit_convert(self, n): i = 0 while n != 1: if n % 2 == 0: n = n / 2 else: n = n * 3 + 1 i += 1 return i
def solve(datafile="input.txt"): DELIMS = { ")": 3, "]": 57, "}": 1197, ">": 25137, "(": -3, "[": -57, "{": -1197, "<": -25137, } RDELIMS = {-3: 1, -57: 2, -1197: 3, -25137: 4} def check(line): stack = [] for _ in line: ...
def solve(datafile='input.txt'): delims = {')': 3, ']': 57, '}': 1197, '>': 25137, '(': -3, '[': -57, '{': -1197, '<': -25137} rdelims = {-3: 1, -57: 2, -1197: 3, -25137: 4} def check(line): stack = [] for _ in line: d = DELIMS[_] if d < 0: stack.inse...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Bellkor.Utils.Exceptions """ class ModelValidationException(Exception): """ Raised if the Model has not been initialised correctly """ def __init__(self, msg): """ Initialise the Input Validation Exception :param msg: message ...
""" Bellkor.Utils.Exceptions """ class Modelvalidationexception(Exception): """ Raised if the Model has not been initialised correctly """ def __init__(self, msg): """ Initialise the Input Validation Exception :param msg: message """ self.msg = msg super(Model...
# Write a program that asks for an employee's salary and calculates the amount of your increase. # For salaries in excess of US$ 1,250.00, calculate an increase of 10%. # For those less than or equal, the increase is 15%. s = float(input('Enter the employees salary: US$ ')) if s > 1250: new = s * 1.10 print('...
s = float(input('Enter the employees salary: US$ ')) if s > 1250: new = s * 1.1 print('The new salary, whit a increase of 10%, is: US${:.2f}'.format(new)) else: new = s * 1.15 print('The new salary, whit a increase of 15%, is: US${:.2f}'.format(new))
class HashTable: class LLNode: def __init__(self, key, next_ = None): self.key = key self.next = next_ def __init__(self, n): self.table = [None] * n self.n = n def __str__(self): line = "" for i in range(len(self.table)): ...
class Hashtable: class Llnode: def __init__(self, key, next_=None): self.key = key self.next = next_ def __init__(self, n): self.table = [None] * n self.n = n def __str__(self): line = '' for i in range(len(self.table)): line +=...
#!/usr/bin/env python3 class DNArecord(object): def __init__(self,DNA_sequence,gene_name,gene_organism): self.gene_name = gene_name self.DNA_sequence = DNA_sequence self.gene_organism = gene_organism def seq_length(self): seq_length = len(self.DNA_sequence) return seq_length def nucl_comp(self): lengt...
class Dnarecord(object): def __init__(self, DNA_sequence, gene_name, gene_organism): self.gene_name = gene_name self.DNA_sequence = DNA_sequence self.gene_organism = gene_organism def seq_length(self): seq_length = len(self.DNA_sequence) return seq_length def nucl_...
original_lstm = { 'hidden': 16, 'dropout': 0.5, 'linear': 64, 'norm': False, 'task': 'regression' } original_lstm_with_norm = { 'hidden': 16, 'dropout': 0.5, 'linear': 64, 'norm': True, 'task': 'regression' } larger_lstm = { 'hidden': 64, 'dropout': 0.5, 'linear': 6...
original_lstm = {'hidden': 16, 'dropout': 0.5, 'linear': 64, 'norm': False, 'task': 'regression'} original_lstm_with_norm = {'hidden': 16, 'dropout': 0.5, 'linear': 64, 'norm': True, 'task': 'regression'} larger_lstm = {'hidden': 64, 'dropout': 0.5, 'linear': 64, 'norm': True, 'task': 'regression'} larger_lstm_5bin = {...
def filter_even_only(*args): filtered_list = filter(lambda x: x % 2 == 0, args[0]) return filtered_list input_string = input() input_numbers = map(int, input_string.split(' ')) even_list = list(filter_even_only(input_numbers)) print(even_list)
def filter_even_only(*args): filtered_list = filter(lambda x: x % 2 == 0, args[0]) return filtered_list input_string = input() input_numbers = map(int, input_string.split(' ')) even_list = list(filter_even_only(input_numbers)) print(even_list)
SECRET_KEY = 'spam' DEBUG = True TEMPLATE_DEBUG = DEBUG ROOT_URLCONF = 'tests.urls' INSTALLED_APPS = ['tests'] DATABASES = {'default': {'NAME': 'db.sqlite', 'ENGINE': 'django.db.backends.sqlite3'}} # Django < 1.8 TEMPLATE_CONTEXT_PROCESSORS = [ 'django_settings_export.settings_export' ] # ...
secret_key = 'spam' debug = True template_debug = DEBUG root_urlconf = 'tests.urls' installed_apps = ['tests'] databases = {'default': {'NAME': 'db.sqlite', 'ENGINE': 'django.db.backends.sqlite3'}} template_context_processors = ['django_settings_export.settings_export'] templates = [{'BACKEND': 'django.template.backend...
#constructing a bst from given keys # A class to store a BST node class Node: def __init__(self, data, left=None, right=None): self.data = data self.left = left self.right = right # Function to perform inorder traversal on the tree def inorder(root): if root is None: ...
class Node: def __init__(self, data, left=None, right=None): self.data = data self.left = left self.right = right def inorder(root): if root is None: return inorder(root.left) print(root.data, end=' ') inorder(root.right) def construct(keys, low, high, root): i...
def test_it_can_run_a_remote_method_without_params(mcl): res = mcl.Apartment.query.one().function_without_params() assert res == 5 def test_it_can_run_a_remote_method_with_builtin_type_params(mcl): res = mcl.Apartment.query.one().function_with_params(5, 'test') assert res == '5: test' def test_it_ca...
def test_it_can_run_a_remote_method_without_params(mcl): res = mcl.Apartment.query.one().function_without_params() assert res == 5 def test_it_can_run_a_remote_method_with_builtin_type_params(mcl): res = mcl.Apartment.query.one().function_with_params(5, 'test') assert res == '5: test' def test_it_can_...
# https://atcoder.jp/contests/atc001/tasks/unionfind_a class UnionFind: def __init__(self, n: int): self.parents = [i for i in range(n + 1)] self.size = [1] * (n + 1) def root(self, x: int) -> int: if self.parents[x] == x: return x self.parents[x] = self.root(self....
class Unionfind: def __init__(self, n: int): self.parents = [i for i in range(n + 1)] self.size = [1] * (n + 1) def root(self, x: int) -> int: if self.parents[x] == x: return x self.parents[x] = self.root(self.parents[x]) return self.parents[x] def is_s...
class Solution: def maxArea(self, h, w, hs, vs): MOD = 10 ** 9 + 7 hs.append(h) vs.append(w) hs.sort() vs.sort() hmx = last = hs[0] for h in hs[1:]: if h - last > hmx: hmx = h - last last = h vmx = last = vs[0]...
class Solution: def max_area(self, h, w, hs, vs): mod = 10 ** 9 + 7 hs.append(h) vs.append(w) hs.sort() vs.sort() hmx = last = hs[0] for h in hs[1:]: if h - last > hmx: hmx = h - last last = h vmx = last = vs[0]...
class Tile: def __init__(self, blocked, block_sight=None): self.type_of_tile = 0 self.blocked = blocked if block_sight is None: block_sight = blocked self.block_sight = block_sight self.explored = False self.status_effects = [] self.placed_sp...
class Tile: def __init__(self, blocked, block_sight=None): self.type_of_tile = 0 self.blocked = blocked if block_sight is None: block_sight = blocked self.block_sight = block_sight self.explored = False self.status_effects = [] self.placed_spells ...
# -*- coding: utf8 -*- def teacher_go(): # todo: teacher_go action return { "result": "it is student_get action" } def student_go(): # todo: student_go action return { "result": "it is teacher_put action" } def student_come(): # todo: student_come action return { ...
def teacher_go(): return {'result': 'it is student_get action'} def student_go(): return {'result': 'it is teacher_put action'} def student_come(): return {'result': 'it is teacher_put action'} def main_handler(event, context): print(str(event)) if event['pathParameters']['user_type'] == 'teacher...
CHANNELS = ["tekken", "raamikysely", "tekken-frames", "live3d", "3d"] EXTRA_DATA = { 'prefix': '?', 'description': 'Tekken 7 Frame Bot customized by AtillaBosma', 'timeout_normal': 45, 'timeout_error': 15 }
channels = ['tekken', 'raamikysely', 'tekken-frames', 'live3d', '3d'] extra_data = {'prefix': '?', 'description': 'Tekken 7 Frame Bot customized by AtillaBosma', 'timeout_normal': 45, 'timeout_error': 15}
# Aran Introduction sm.killMobs() if sm.getFieldID() == 914000200: sm.spawnMob(9300379, 2099, 2, False, 10) sm.spawnMob(9300379, 1799, 2, False, 10) sm.spawnMob(9300379, 1515, 2, False, 10) elif sm.getFieldID() == 914000210: sm.spawnMob(9300380, 667, 2, False, 15) sm.spawnMob(9300380, 382, 2, Fals...
sm.killMobs() if sm.getFieldID() == 914000200: sm.spawnMob(9300379, 2099, 2, False, 10) sm.spawnMob(9300379, 1799, 2, False, 10) sm.spawnMob(9300379, 1515, 2, False, 10) elif sm.getFieldID() == 914000210: sm.spawnMob(9300380, 667, 2, False, 15) sm.spawnMob(9300380, 382, 2, False, 15) sm.spawnMob...
def count_odd_even(list_num): even_cnt = 0 odd_cnt = 0 for num in list_num: if num % 2 == 0: even_cnt += 1 else: odd_cnt += 1 return (even_cnt, odd_cnt)
def count_odd_even(list_num): even_cnt = 0 odd_cnt = 0 for num in list_num: if num % 2 == 0: even_cnt += 1 else: odd_cnt += 1 return (even_cnt, odd_cnt)
"""" You've built an inflight entertainment system with on-demand movie streaming. Users on longer flights like to start a second movie right when their first one ends, but they complain that the plane usually lands before they can see the ending. So you're building a feature for choosing two movies whose total runtim...
"""" You've built an inflight entertainment system with on-demand movie streaming. Users on longer flights like to start a second movie right when their first one ends, but they complain that the plane usually lands before they can see the ending. So you're building a feature for choosing two movies whose total runtim...
#Say you have an array for which the ith element is the price of a given stock on day i. #If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit. #Note that you cannot sell a stock before you buy one. # Example 1:...
class Solution(object): def max_profit(self, prices): n = len(prices) if n <= 0: return 0 m = prices[0] profit = 0 for i in range(1, n): if prices[i] > m: if prices[i] - m >= profit: profit = prices[i] - m ...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Dec 22 09:07:51 2017 @author: efrem """ def isIn(char, aStr): ''' char: a single character aStr: an alphabetized string returns: True if char is in aStr; False otherwise ''' index = len(aStr) // 2 if len(aStr) == 0: ...
""" Created on Fri Dec 22 09:07:51 2017 @author: efrem """ def is_in(char, aStr): """ char: a single character aStr: an alphabetized string returns: True if char is in aStr; False otherwise """ index = len(aStr) // 2 if len(aStr) == 0: return False elif char == aStr[index]...
# coding: utf8 # pre-defined validator notempty=IS_NOT_EMPTY(error_message=e_m['empty']) # definition of car makers db.define_table('brand', Field('name', unique=True, notnull=True), format='%(name)s') # definition of brand validators db.brand.name.requires=[notempty, IS_NOT_IN_DB(db,...
notempty = is_not_empty(error_message=e_m['empty']) db.define_table('brand', field('name', unique=True, notnull=True), format='%(name)s') db.brand.name.requires = [notempty, is_not_in_db(db, 'brand.name', error_message=e_m['in_db'])] db.define_table('car', field('brand', db.brand, notnull=True), field('model', notnull=...
# -*- coding: utf-8 -*- """ Created on Tue Apr 16 14:21:57 2019 @author: JeanineT """ x=5 y=10 print(x*y) z=20 a=3 b=7 print((a*y)-3*x+z) print(a*b)
""" Created on Tue Apr 16 14:21:57 2019 @author: JeanineT """ x = 5 y = 10 print(x * y) z = 20 a = 3 b = 7 print(a * y - 3 * x + z) print(a * b)
secret = 'BEEAKFYDJXUQYHYJIQRYHTYJIQFBQDUYJIIKFUHCQD' for K in range(26): plain = ''.join([chr((ord(c) - ord('A') + K) % 26 + ord('A')) for c in secret]) print(plain)
secret = 'BEEAKFYDJXUQYHYJIQRYHTYJIQFBQDUYJIIKFUHCQD' for k in range(26): plain = ''.join([chr((ord(c) - ord('A') + K) % 26 + ord('A')) for c in secret]) print(plain)
name = input("Siapa nama kamu?") umur = input("Berapa umur kamu?") jk = input("Apa jenis kelaminmu? (L/P)") print(""" Nama saya: {} Umur saya: {} Jenis kelamin saya: {} """.format(name, umur, jk))
name = input('Siapa nama kamu?') umur = input('Berapa umur kamu?') jk = input('Apa jenis kelaminmu? (L/P)') print('\n Nama saya: {}\n Umur saya: {}\n Jenis kelamin saya: {}\n '.format(name, umur, jk))
# Python is dynamically typed language. This means that variable does not have any information about its type when it is defined - its type can change # throughout code. When "type" function is called, it only returns the type of object that the variable is currently pointing at. a = "Hello." print(type(a)) a = 10 p...
a = 'Hello.' print(type(a)) a = 10 print(type(a)) a = lambda x: x ** 2 print(type(a)) a = 3 + 4j print(type(a))
lista = [] positivos = 0 for i in range(0, 6): lista.append(float(input())) if lista[i] > 0: positivos += 1 print(f"{positivos} valores positivos")
lista = [] positivos = 0 for i in range(0, 6): lista.append(float(input())) if lista[i] > 0: positivos += 1 print(f'{positivos} valores positivos')
class Calculator: def __init__(self, a: int, b: int) -> None: self.a = a self.b = b def suma(self) -> int: return self.a + self.b def resta(self) -> int: return self.a - self.b def Multiplicion(self)-> int: return self.a * self.b def Div...
class Calculator: def __init__(self, a: int, b: int) -> None: self.a = a self.b = b def suma(self) -> int: return self.a + self.b def resta(self) -> int: return self.a - self.b def multiplicion(self) -> int: return self.a * self.b def division(self) -> fl...
class Loader: def __init__(self, options): self.options = options self.error = False self.error_message = '' self.input_file = None self.output_file = None if options.input_filename == '' or options.input_filename == None: self.error = True self.error_message = 'Please provide an input file' retu...
class Loader: def __init__(self, options): self.options = options self.error = False self.error_message = '' self.input_file = None self.output_file = None if options.input_filename == '' or options.input_filename == None: self.error = True se...
def round_sum(a, b, c): round_a = round10(a) round_b = round10(b) round_c = round10(c) round_sum = round_a + round_b + round_c return round_sum def round10(num): if num % 10 >= 5: num = num + (10 - (num%10)) return num elif num % 10 < 5: num = num - (num%10) ...
def round_sum(a, b, c): round_a = round10(a) round_b = round10(b) round_c = round10(c) round_sum = round_a + round_b + round_c return round_sum def round10(num): if num % 10 >= 5: num = num + (10 - num % 10) return num elif num % 10 < 5: num = num - num % 10 ...
# When given two positive integers greater than 1 which are A and B, write a program that prints all the factors that they both share. # 10 and 24 shares: # 1 # 2 # input num1 = int(input('Enter a number: ')) num2 = int(input('Enter another number: ')) # processing & output divisor = 1 upper_limit = min(num1, num2) ...
num1 = int(input('Enter a number: ')) num2 = int(input('Enter another number: ')) divisor = 1 upper_limit = min(num1, num2) print(num1, 'and', num2, 'share these factors:') while divisor <= upper_limit: if num1 % divisor == 0 and num2 % divisor == 0: print(divisor) divisor += 1
class Port: def __init__(self, name, register, vhdl_name, bitwidth=32, data_type='int', internal=False, virtual=False): self.name=name self.register=register self.vhdl_name=vhdl_name self.bitwidth=bitwidth self.data_type=str(data_type) self.internal=internal s...
class Port: def __init__(self, name, register, vhdl_name, bitwidth=32, data_type='int', internal=False, virtual=False): self.name = name self.register = register self.vhdl_name = vhdl_name self.bitwidth = bitwidth self.data_type = str(data_type) self.internal = inter...
def recursiveAdd(result): number = int(input('add a number: ')) result += number print(result) if input('do you wish to add other number? y/n ') == 'y': result = recursiveAdd(result) return result if __name__ == "__main__": try: print('the final res...
def recursive_add(result): number = int(input('add a number: ')) result += number print(result) if input('do you wish to add other number? y/n ') == 'y': result = recursive_add(result) return result if __name__ == '__main__': try: print('the final result is : {}'.format(...
# # |-----------------------------------| # <module> | x ---> 1 | # | y ---> x + 1 | # |-----------------------------------| # # |-----------------------------------| # | x ---> 1 | # c ...
def b(z): prod = a(z, z) print(z, prod) return prod def a(x, y): x = x + 1 return x * y def c(x, y, z): total = x + y + z square = b(total) ** 2 return square x = 1 y = x + 1 print(c(x, y + 3, x + y))
# Time: O(n) # Space: O(n) # A frog is crossing a river. The river is divided into x units and # at each unit there may or may not exist a stone. # The frog can jump on a stone, but it must not jump into the water. # # Given a list of stones' positions (in units) in sorted ascending order, # determine if the frog is...
class Solution(object): def can_cross(self, stones): """ :type stones: List[int] :rtype: bool """ lookup = {} for (k, v) in enumerate(stones): lookup[v] = k dp = [False for _ in xrange(len(stones))] dp[0] = True for i in xrange(len...
# -*- coding:utf-8 -*- """ Constants """ # mode names TRN_PREP_MODE = 'trn_prep' TST_PREP_MODE = 'tst_prep' TRN_MODE = 'trn' TST_MODE = 'tst' # location of TFRecords RECORDS_DIR = 'records' TF_REC_EXT = '.tfrecords' # IMAGE PARAMS IMG_EXT = '.png' # image dimensions (H, W, C) IMG_SHAPE = (32, 32, 3) # TRAINING PARA...
""" Constants """ trn_prep_mode = 'trn_prep' tst_prep_mode = 'tst_prep' trn_mode = 'trn' tst_mode = 'tst' records_dir = 'records' tf_rec_ext = '.tfrecords' img_ext = '.png' img_shape = (32, 32, 3) batch_size = 32 lrn_rate = 0.05 num_epochs = 20 num_epoch_before_chkpt = 20 num_batch_before_print_loss = 100 tst_batch_siz...
""" Author: Isaac Riley Date: September 2020 Tests the dependency parsing and opinion mining functionalities of the WikiNet class. """
""" Author: Isaac Riley Date: September 2020 Tests the dependency parsing and opinion mining functionalities of the WikiNet class. """
def math(): long = int(input()) print('Feliz nat' + 'a' * long + 'l!') if __name__ == '__main__': math()
def math(): long = int(input()) print('Feliz nat' + 'a' * long + 'l!') if __name__ == '__main__': math()
''' BreezySLAM: Simple, efficient SLAM in Python sensors.py: SLAM sensors (currently just Laser) Copyright (C) 2014 Simon D. Levy This code is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version...
""" BreezySLAM: Simple, efficient SLAM in Python sensors.py: SLAM sensors (currently just Laser) Copyright (C) 2014 Simon D. Levy This code is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version...
# https://github.com/tensorflow/tensorflow/issues/2169 # ThomasWollmann's solution of max un pooling # I've adapted chahld's version to handle unknown input tensor shape. def unpool(pool, ind, ksize=[1, 2, 2, 1], scope='unpool'): """ Unpooling layer after max_pool_with_argmax. Args: pool:...
def unpool(pool, ind, ksize=[1, 2, 2, 1], scope='unpool'): """ Unpooling layer after max_pool_with_argmax. Args: pool: max pooled output tensor ind: argmax indices ksize: ksize is the same as for the pool Return: unpool: unpooling tensor...
#!/usr/bin/env python # Copyright (c) 2022 Oxford Robotics Institute (ORI), University of Oxford # # This work is licensed under the terms of the MIT license. # For a copy, see <https://opensource.org/licenses/MIT>. ACCELERATOR_PERCENT = "Accelerator Pedal" BRAKE_PERCENT = "Brake Pedal" DELTA_V_LATERAL = "Delta-V Lat...
accelerator_percent = 'Accelerator Pedal' brake_percent = 'Brake Pedal' delta_v_lateral = 'Delta-V Lateral' delta_v_longitudinal = 'Delta-V Longitudinal' engine_rpm = 'Engine RPM' gnss_altitude = 'Altitude' gnss_latitude = 'Latitude' gnss_longitude = 'Longitude' lateral_acceleration = 'Lateral Acceleration' lateral_vel...
""" A dummy module to test relative imports from scripts. """ test_string = "dummy_module"
""" A dummy module to test relative imports from scripts. """ test_string = 'dummy_module'
#! /usr/local/bin/env python3 # inventory.py - Fantasy Game Inventory stuff = {'rope': 1, 'torch': 6, 'gold coin': 42, 'dagger': 1, 'arrow': 12} def displayInventory(inventory): print('Inventory:') item_total = 0 for key, value in inventory.items(): # FILL IN THE CODE HERE item_total += ...
stuff = {'rope': 1, 'torch': 6, 'gold coin': 42, 'dagger': 1, 'arrow': 12} def display_inventory(inventory): print('Inventory:') item_total = 0 for (key, value) in inventory.items(): item_total += value print(f'{value} {key}') print('Total number of items: ' + str(item_total)) display_i...
class OrderBook: def __init__(self,gt_2_ob = None,ob_to_ts = None): self.list_asks = [] self.list_bids = [] self.gw_2_ob=gt_2_ob self.ob_to_ts = ob_to_ts self.current_bid = None self.current_ask = None def create_book_event(self,bid,offer): book_event = {...
class Orderbook: def __init__(self, gt_2_ob=None, ob_to_ts=None): self.list_asks = [] self.list_bids = [] self.gw_2_ob = gt_2_ob self.ob_to_ts = ob_to_ts self.current_bid = None self.current_ask = None def create_book_event(self, bid, offer): book_event ...
def count(txt, char): count = 0 for x in txt: if x == char: count = count + 1 return count text = input('Enter a text: ') character = input('Enter a character that you can search in "'+text+'": ') result = count(text, character) print('The character "'+character+'" appears '+str(result)+' times in "'+text+...
def count(txt, char): count = 0 for x in txt: if x == char: count = count + 1 return count text = input('Enter a text: ') character = input('Enter a character that you can search in "' + text + '": ') result = count(text, character) print('The character "' + character + '" appears ' + st...
#!/usr/local/bin/python # coding: utf-8 """ docstring here """ foo = 'bar'
""" docstring here """ foo = 'bar'
# 617. Merge Two Binary Trees # Runtime: 84 ms, faster than 79.23% of Python3 online submissions for Merge Two Binary Trees. # Memory Usage: 15.4 MB, less than 76.43% of Python3 online submissions for Merge Two Binary Trees. # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left...
class Solution: def merge_trees(self, root1: TreeNode, root2: TreeNode) -> TreeNode: if root1 is None: return root2 elif root2 is None: return root1 else: new_root = tree_node(root1.val + root2.val) new_root.right = self.mergeTrees(root1.right...
print("Input:") N = int(input()) print("\nOutput:") def set(N): if (N <= 2): print ("No") return value = (N * (N + 1)) // 2 if(value & 1): print ("No") return s1 = [] s2 = [] if (not (N & 1)): turn = 1 start = 1 last = N ...
print('Input:') n = int(input()) print('\nOutput:') def set(N): if N <= 2: print('No') return value = N * (N + 1) // 2 if value & 1: print('No') return s1 = [] s2 = [] if not N & 1: turn = 1 start = 1 last = N while start < last: ...
_bitfont_0 = [ True, True, True, True, False, True, True, False, True, True, False, True, True, True, True ] _bitfont_1 = [ False, False, True, False, True, True, False, False, True, False, False, True, False, False, True ] _bitfont_2 = [ True, True, Tru...
_bitfont_0 = [True, True, True, True, False, True, True, False, True, True, False, True, True, True, True] _bitfont_1 = [False, False, True, False, True, True, False, False, True, False, False, True, False, False, True] _bitfont_2 = [True, True, True, False, False, True, True, True, True, True, False, False, True, True...
""" exception.py ~~~~~~~~ Module containing Custom Exceptions """ class UdfUnavailable(Exception): """Raised when udf specified not available""" def __init__(self, e): raise e
""" exception.py ~~~~~~~~ Module containing Custom Exceptions """ class Udfunavailable(Exception): """Raised when udf specified not available""" def __init__(self, e): raise e
mystery = open('../c0rrupt/mystery','rb').read() def add_png_hdr1(): hdr1=list(map(lambda x: int(x,16), ['0x'+c for c in '89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52'.split(' ')])) hdr2=list(map(lambda x: int(x,16),['0x'+c for c in '00 00 06 a1 00 00 02 60 08 02 00 00 00 85 ad 5e'.split(' ')])) ...
mystery = open('../c0rrupt/mystery', 'rb').read() def add_png_hdr1(): hdr1 = list(map(lambda x: int(x, 16), ['0x' + c for c in '89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52'.split(' ')])) hdr2 = list(map(lambda x: int(x, 16), ['0x' + c for c in '00 00 06 a1 00 00 02 60 08 02 00 00 00 85 ad 5e'.split(' ')]))...
class Solution(object): def XXX(self, s): l=['IV','IX','XL','XC','CD','CM'] l0=['I','V','X','L','C','D','M'] map={'IV':4,'IX':9,'XL':40,'XC':90,'CD':400,'CM':900, 'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000} tot=0 for i in l: if i in s: ...
class Solution(object): def xxx(self, s): l = ['IV', 'IX', 'XL', 'XC', 'CD', 'CM'] l0 = ['I', 'V', 'X', 'L', 'C', 'D', 'M'] map = {'IV': 4, 'IX': 9, 'XL': 40, 'XC': 90, 'CD': 400, 'CM': 900, 'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000} tot = 0 for i in l:...
# OGC Catalogue Services 3.0 Specification - HTTP Protocol Binding identifier = "12-176r7" specURL = "http://docs.opengeospatial.org/is/12-176r7/12-176r7.html" fout = open("../mappings/"+identifier+".csv","w") # output file elementList = [] confClasses = ['Basic-Catalogue','OpenSearch','GetCapabilities-XML','GetRecordB...
identifier = '12-176r7' spec_url = 'http://docs.opengeospatial.org/is/12-176r7/12-176r7.html' fout = open('../mappings/' + identifier + '.csv', 'w') element_list = [] conf_classes = ['Basic-Catalogue', 'OpenSearch', 'GetCapabilities-XML', 'GetRecordById-XML', 'GetRecords-Basic-XML', 'GetRecords-Distributed-XML', 'GetRe...
PUBLIC_API_URL = 'https://max-api.maicoin.com/api' PRIVATE_API_URL = 'https://max-api.maicoin.com/api' PUBLIC_API_VERSION = 'v2' PRIVATE_API_VERSION = 'v2'
public_api_url = 'https://max-api.maicoin.com/api' private_api_url = 'https://max-api.maicoin.com/api' public_api_version = 'v2' private_api_version = 'v2'
yosoku = 13 jissai = 11 gosa = 2 if (yosoku - jissai < gosa) or (yosoku - jissai > -1*gosa): print(yosoku - jissai + gosa) else: print(yosoku - jissai - gosa)
yosoku = 13 jissai = 11 gosa = 2 if yosoku - jissai < gosa or yosoku - jissai > -1 * gosa: print(yosoku - jissai + gosa) else: print(yosoku - jissai - gosa)
def PadovanElement(n): forSwap = [1, 1, 1] num = 1 an = 1 while an < n: an = forSwap[0] + forSwap[1] forSwap = [forSwap[1], forSwap[2], an] num += 1 return num, forSwap[1] def pad(n): # 0th ,1st and 2nd number of the series are 1 pPrevPrev, pPrev, pCurr, pNext = 1, ...
def padovan_element(n): for_swap = [1, 1, 1] num = 1 an = 1 while an < n: an = forSwap[0] + forSwap[1] for_swap = [forSwap[1], forSwap[2], an] num += 1 return (num, forSwap[1]) def pad(n): (p_prev_prev, p_prev, p_curr, p_next) = (1, 1, 1, 1) for i in range(3, n + 1):...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ RLBook.Chapter8 - Python Implementation of the RL Book Exercises - Planning """ __version__ = "0.1.1" __developers__ = "Dan Dixey (2018)" # Default Node Initialisation with these parameters DEFAULT_NODE_PARAMS = dict(N_PLAYS=0, N_WINS=0, N_TIES=0, SCORE=0., PRIO...
""" RLBook.Chapter8 - Python Implementation of the RL Book Exercises - Planning """ __version__ = '0.1.1' __developers__ = 'Dan Dixey (2018)' default_node_params = dict(N_PLAYS=0, N_WINS=0, N_TIES=0, SCORE=0.0, PRIOR=1.0, C_PUCT=2, TAU=1.0, Q=0.0, U=0.0, ACTION=None, V=0)
#!/usr/bin/python3 motorcycles = ['honda', 'yamaha', 'suzuki'] print(motorcycles) motorcycles.append('ducati') print(motorcycles) motorcycles.insert(0, 'ducati') print(motorcycles) del motorcycles[0] print(motorcycles) del motorcycles[1] print(motorcycles) poped_motorcycle = motorcycles.pop() print(poped_motorcyc...
motorcycles = ['honda', 'yamaha', 'suzuki'] print(motorcycles) motorcycles.append('ducati') print(motorcycles) motorcycles.insert(0, 'ducati') print(motorcycles) del motorcycles[0] print(motorcycles) del motorcycles[1] print(motorcycles) poped_motorcycle = motorcycles.pop() print(poped_motorcycle) first_owned = motorcy...
def read_number(filename): number = [] with open(filename) as file: for line in file: for n in line[:-1]: number.append(int(n)) return number def find_greatest_adjacent_product(n): """ :param n: how many adjacent numbers :return: lst [index, sequence, product...
def read_number(filename): number = [] with open(filename) as file: for line in file: for n in line[:-1]: number.append(int(n)) return number def find_greatest_adjacent_product(n): """ :param n: how many adjacent numbers :return: lst [index, sequence, product...
# Names of columns that contains NaN [k for k,l in [(i,j) for i,j in zip(df,df.isnull().sum())] if l] # Columns that contains NaN df[[k for k,l in [(i,j) for i,j in zip(df,df.isnull().sum())] if l]]
[k for (k, l) in [(i, j) for (i, j) in zip(df, df.isnull().sum())] if l] df[[k for (k, l) in [(i, j) for (i, j) in zip(df, df.isnull().sum())] if l]]
class Settings: """A class to store all the settings.""" def __init__(self): """Initialize the game's static settings.""" self.correct_score = 10 self.incorrect_score = 0 self.screen_width = 1200 self.screen_height = 600 self.bg_color = (230, 230, 230) # light ...
class Settings: """A class to store all the settings.""" def __init__(self): """Initialize the game's static settings.""" self.correct_score = 10 self.incorrect_score = 0 self.screen_width = 1200 self.screen_height = 600 self.bg_color = (230, 230, 230) se...
"""An extension with the workspace dependency declarations.""" dependencies = [ { "name": "jq", "url": { "darwin": "https://github.com/stedolan/jq/releases/download/jq-{version}/jq-osx-amd64", "linux": "https://github.com/stedolan/jq/releases/download/jq-{version}/jq-linux64...
"""An extension with the workspace dependency declarations.""" dependencies = [{'name': 'jq', 'url': {'darwin': 'https://github.com/stedolan/jq/releases/download/jq-{version}/jq-osx-amd64', 'linux': 'https://github.com/stedolan/jq/releases/download/jq-{version}/jq-linux64', 'windows': 'https://github.com/stedolan/jq/re...
c = get_config() # Notebook config c.NotebookApp.certfile = u'/home/collaboratool/collaboratool-cert.pem' c.NotebookApp.ip = '*' c.NotebookApp.open_browser = False c.NotebookApp.password = u'sha1:72eecedd5231:9d66151455494288b82761447d2757836cc514b1'
c = get_config() c.NotebookApp.certfile = u'/home/collaboratool/collaboratool-cert.pem' c.NotebookApp.ip = '*' c.NotebookApp.open_browser = False c.NotebookApp.password = u'sha1:72eecedd5231:9d66151455494288b82761447d2757836cc514b1'
s=input() def check(string): for i in range(0,len(string)): if (i%2==0) and string[i].isupper(): return False elif (i%2==1) and string[i].islower(): return False return True if(check(s)): print('Yes') else: print('No')
s = input() def check(string): for i in range(0, len(string)): if i % 2 == 0 and string[i].isupper(): return False elif i % 2 == 1 and string[i].islower(): return False return True if check(s): print('Yes') else: print('No')
MAX_EDGE_PENWIDTH_GRAPHVIZ = 2.6 MIN_EDGE_PENWIDTH_GRAPHVIZ = 1.0 def human_readable_stat(c): """ Transform a timedelta expressed in seconds into a human readable string Parameters ---------- c Timedelta expressed in seconds Returns ---------- string Human readable str...
max_edge_penwidth_graphviz = 2.6 min_edge_penwidth_graphviz = 1.0 def human_readable_stat(c): """ Transform a timedelta expressed in seconds into a human readable string Parameters ---------- c Timedelta expressed in seconds Returns ---------- string Human readable str...
{ "targets": [ { "target_name": "stepfunction", "sources": ["stepfunction.cc"] } ] }
{'targets': [{'target_name': 'stepfunction', 'sources': ['stepfunction.cc']}]}
# UMAP umap_metrics = ["euclidean", # 0 "manhattan", # 1 "chebyshev", # 2 "minkowski", # 3 "canberra", # 4 "braycurtis", # 5 "mahalanobis", # 6 "wminkowski", # 7 "seuclidean", # 8 ...
umap_metrics = ['euclidean', 'manhattan', 'chebyshev', 'minkowski', 'canberra', 'braycurtis', 'mahalanobis', 'wminkowski', 'seuclidean', 'cosine', 'correlation', 'haversine', 'hamming', 'jaccard', 'dice', 'russelrao', 'kulsinski', 'rogerstanimoto', 'sokalmichener', 'sokalsneath', 'yule'] path_cifar10 = '' path_cifar100...
sigma_s = 1 N_d = 32 N_c = 8 K = 50 P_FA = 0.05 SNR = 100 SNR_LOW = -20 SNR_UP = 6 SNR_STEP = 2 SNR_NOISE = 1 NUM_STATISTICS = 1000 #NUM_STATISTICS = 100000
sigma_s = 1 n_d = 32 n_c = 8 k = 50 p_fa = 0.05 snr = 100 snr_low = -20 snr_up = 6 snr_step = 2 snr_noise = 1 num_statistics = 1000
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Feb 12 15:29:56 2020 @author: mlampert """ """ - PLOTTING THE SIZE AND OTHER PARAMETERS OF THE GAS CLOUD ONTO THE RESULTS AS SOME CONFIDENCE LEVEL - FORWARD AND BACKWARD FILTERING TO PREVENT THE PHASE CHANGE """
""" Created on Wed Feb 12 15:29:56 2020 @author: mlampert """ '\n- PLOTTING THE SIZE AND OTHER PARAMETERS OF THE GAS CLOUD ONTO THE RESULTS AS SOME CONFIDENCE LEVEL\n- FORWARD AND BACKWARD FILTERING TO PREVENT THE PHASE CHANGE\n'
class UnknownChannelType(Exception): pass class BaseError(Exception): http_status = 500 class QueueFull(BaseError): http_status = 503 class ChannelNotFound(BaseError): http_status = 404
class Unknownchanneltype(Exception): pass class Baseerror(Exception): http_status = 500 class Queuefull(BaseError): http_status = 503 class Channelnotfound(BaseError): http_status = 404
line = input('Line: ') biagrams = [] # take input while line: line = line.lower() data = line.split() # add biagrams to dictionary for word in data[:-1]: position = data.index(word) biagrams.append((data[position] + " " + data[position+1])) line = input('Line: ') # find unique uniq...
line = input('Line: ') biagrams = [] while line: line = line.lower() data = line.split() for word in data[:-1]: position = data.index(word) biagrams.append(data[position] + ' ' + data[position + 1]) line = input('Line: ') unique_biagrams = set(biagrams) for biagram in unique_biagrams: ...
class JSONResponse: def __init__(self, status_code, body): self.status_code = status_code self.body = body def json(self): return self.body
class Jsonresponse: def __init__(self, status_code, body): self.status_code = status_code self.body = body def json(self): return self.body
"""Module to define specific errors.""" class NotFoundError(ValueError): """Raised when some application object could not be found.""" class InvalidRecordError(ValueError): """Raised when some application object did not passed validation."""
"""Module to define specific errors.""" class Notfounderror(ValueError): """Raised when some application object could not be found.""" class Invalidrecorderror(ValueError): """Raised when some application object did not passed validation."""
my_list = [1, 2, 3] def add_list(my_list): for i in my_list: sum_list = my_list[i] + sum_list return sum_list def sumarize(add_list): print("sum of " + my_list + "is" + add_list()) add_list(my_list) sumarize()
my_list = [1, 2, 3] def add_list(my_list): for i in my_list: sum_list = my_list[i] + sum_list return sum_list def sumarize(add_list): print('sum of ' + my_list + 'is' + add_list()) add_list(my_list) sumarize()
# Vererbung (inheritance) mit super: # vererbt an die Kindklasse alle Variablen und Methoden class A: def __init__(self): print("Init A called!") self.a = 2 def hello(self): print('hi') class B(A): # erbt von A def __init__(self): super().__init__() # ruft von der Eltern...
class A: def __init__(self): print('Init A called!') self.a = 2 def hello(self): print('hi') class B(A): def __init__(self): super().__init__() print('Init B called!') self.b = self.a * 2 print(self.b) class C(A): def __init__(self): ...