content
stringlengths
7
1.05M
class Question: def __init__(self, text, answer): self.text = text self.answer = answer
# this technique creates the copy of the list while reversing. It takes up more memory. lis = [1, 2, 3] reversed_list = lis[::-1] print(reversed_list)
#TAT = CT - AT => CT = AT + TAT #WT = TAT - BT => TAT = BT + WT #TAT = BT + WT => BT = TAT - WT #CT = ST + BT => CT = ST + TAT - WT #for creating a 2D Array n = 5 process = [] for i in range(5): l = [] for j in range(4): l.append(0) process.append(l) def findWaitingTime( waitingTime): cumulativ...
expected = 'Jana III Sobieskiego' a = ' Jana III Sobieskiego ' b = 'ul Jana III SobIESkiego' c = '\tul. Jana trzeciego Sobieskiego' d = 'ulicaJana III Sobieskiego' e = 'UL. JA\tNA 3 SOBIES\tKIEGO' f = 'UL. jana III SOBiesKIEGO' g = 'ULICA JANA III SOBIESKIEGO ' h = 'ULICA. JANA III SOBIeskieGO' i = ' Jana 3 Sobieski...
#Linear Threshold global to test: 0.261583162085 svm_linear = { "global_threshhold": 0.17234866241479857, "model_path": "models/signetf_lambda0.95.pkl", "c-minus": 1, "gamma": 'auto', } svm_rbf = { "global_threshhold": 0.26488806589512859, ...
""" Crie um Programa que leia uma Frase qualquer e diga se ela é um palíndromo, desconsiderando os espaços """ frase = str(input('Digite uma frase: ')).replace(" ", "").upper() if frase == frase[::-1]: print('A Frase Digitada ao contrário é idêntica à ela escrita normal, ela é Palíndromo!') else: print('A Fras...
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def findFrequentTreeSum(self, root): """ :type root: TreeNode :rtype: List[int] """ res = [...
def T(): for row in range(6): for col in range(5): if (row==0 or col==2): print("*",end=" ") else: print(end=" ") print()
class state (object): def __init__(self): self._dict = {} self._dict['dependencies'] = {} self._dict['build'] = {} self._clean = True def clean(self): return self._clean def __getattr__(self, key): try: return self._dict[key] except ...
DATASETS = { 'ctx': { 'ptype': 'edr', 'instr': 'ctx', 'host': 'mro' }, 'hirise': { 'ptype': 'rdrv11', 'instr': 'hirise', 'host': 'mex' } }
# Demo Python Scope - Global Keyword ''' Global Keyword If you need to create a global variable, but are stuck in the local scope, you can use the global keyword. The global keyword makes the variable global. Also, use the global keyword if you want to make a change to a global variable inside a function. ''' # To...
def lielaku_skaits(saraksts): """ Funkcija akceptē vienu argumentu - masīvu ar skaitļiem un atgriež cik no šiem skaitļiem ir strikti lielāki par skaitļu vidējo vērtību. Pārbaudiet funkcijas darbību ar dažādiem argumentiem. Argumenti: saraksts {list} -- skaitļu saraksts Atgriež: ...
VERSION = (0, 0, 2) def get_version(version = None): version = version or VERSION return ".".join(map(str, list(version))) __version__ = get_version(VERSION)
# -*- coding: utf-8 -*- # URL : https://leetcode.com/problems/two-sum/ """ 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。 你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素。 示例: 给定 nums = [2, 7, 11, 15], target = 9 因为 nums[0] + nums[1] = 2 + 7 = 9 所以返回 [0, 1] """ """ nums中每两个相加,如果等于target就返回,那需要遍历(n^2)。 作差值计算...
"""import os import string import random from datetime import datetime, timedelta from elasticsearch_dsl.connections import connections from search.doc_app import Article connections.create_connection(hosts=[os.getenv('ELASTIC7', 'localhost:9200')]) Article.init() idindex = 0 for i in range(0, 20): for j in rang...
""" pass """ def sayhi(): print('hello world!')
# https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/ # # algorithms # Medium (43.48%) # Total Accepted: 83,141 # Total Submissions: 191,230 # beats 100.0% of python submissions class Solution(object): def maxProfit(self, prices): """ :type prices: List[int] :rt...
def ffr(n): if n < 1 or type(n) != int: raise ValueError("n must be an int >= 1") try: return ffr.r[n] except IndexError: r, s = ffr.r, ffs.s ffr_n_1 = ffr(n-1) lastr = r[-1] # extend s up to, and one past, last r s += list(range(s[-1] + 1, lastr)) if ...
def fib(n): if n <= 1: return n return fib(n - 1) + fib(n - 2) if __name__ == "__main__": n = 40 print("{answer}\n".format(answer=fib(n)))
#ejemplo 1 num1 = 13 num2 = 32.34 num1 = num1 + num2 print ("num1 =",num1) #ejemplo 2 num1 = 141.42 num2 = 412 num1 = num1 + num2 print ("num1 =",round(num1)) #ejemplo 3 num1 = 42 num2 = 4.23 result = (num1 + num2) print("El resultado de la operacion es =", round(result)) print(int(6.324)) rl1 = str(64.523) pri...
#!/usr/bin/env python # -*- coding: utf-8 -*- class PodiumAccount(object): """ Object that represents a particular User. **Attributes:** **account_id** (str): Unique id for account **username** (string): The User's username. **email** (str): Account email address ...
class AbstractContext(object): def valueForVar(self, name): return def setValueForVar(self, name, ex): return def typeForVar(self, name): return
# # @lc app=leetcode id=204 lang=python3 # # [204] Count Primes # # @lc code=start class Solution: def countPrimes(self, n: int) -> int: # 埃氏筛法 if n <= 2: return 0 res = [True] * n res[0] = res[1] = False for i in range(2, n): if res[i] == True: f...
""" .. module:: test_viewer :synopsis: Unit tests for viewer module """
# -*- coding: utf-8 -*- class Settings: """ 获取字典 """ @classmethod def get_values(cls): d = dict(vars(cls)) private = [i for i in d.keys() if i.startswith('_')] for k in private: d.pop(k) return d class Sanic: name = "Sanic Tailor" SANIC_JWT_SE...
# coding=utf-8 class TestSpiderMiddleware1: '''实现爬虫中间件''' def process_request(self, request): ''' 处理请求 :param request:请求 :return: 请求 ''' # print("TestSpiderMiddleware1 -- process_request") return request def process_response(self, response): ...
class foo: x = 5 def __init__(self,x): self.x = x def bar(self): return self.x + 1 class foo2(foo): x = 7 # no init so jump/inherit from foo def bar(self): return self.x + 2 def bark(): print('woof') f = foo2(6) #calls foo init f.bark() #Error foo2.bark() #woof foo.bark() #Error f.bar() # 8 foo.bar(...
while True: try: file_name = input("Please enter the name of the file you would like to read") fh = open(file_name) break except: print("Couldn't open file. Please try again") while True: try: line_cnt = int(input("How many lines would you like to read?")) if(line_cnt <= 0): raise ValueError if(lin...
class Solution(object): def checkPossibility(self, nums): """ :type nums: List[int] :rtype: bool """ isIncrease = lambda nums: all(nums[i] <= nums[i + 1] for i in range(len(nums) - 1)) one, two = nums[:], nums[:] for i in range(0, len(nums) - 1): i...
""" Procuret Python Error Module author: hugh@blinkybeach.com """ class ProcuretError(Exception): pass
EC2_INSTANCE_TYPES = [ 't1.micro', 't2.nano', 't2.micro', 't2.small', 't2.medium', 't2.large', 't2.xlarge', 't2.2xlarge', 'm1.small', 'm1.medium', 'm1.large', 'm1.xlarge', 'm3.medium', 'm3.large', 'm3.xlarge', 'm3.2xlarge', 'm4.large', 'm4.xlarge',...
class Config: BOT_USE = False # True is private use BOT_TOKEN = '5298092373:AAF7zZJm02Gkv4DE8jVrbJSPcUoWMvXGX6k' # from @botfather APP_ID = 16655133 # from https://my.telegram.org/apps API_HASH = '6e6a925776a4525c7f0234119f629c99' ...
# Read in the two haplotypes to compare with open("h1.txt", "r") as infile: real = infile.readlines()[0] with open("h2.txt", "r") as infile: found = infile.readlines()[0] # Initialize counters for different kinds of errors switch = 0 flip = 0 # Save length of smaller haplotype (if they are different lengths?) size ...
def remove_duplicates(t): t_unique = [] for element in t: if not element in t_unique: t_unique.append(element) return t_unique print(remove_duplicates(['a', 'b', 1, 2, 'a', '2', 3, 1]))
## Autogenerated code from generate.py ## Note1: Please dont update this file manually ## Note2: For any new keys, add at the end of file smac_keys.list ## To update this file, update the keys in 'smac_keys.list' and rerun 'generate.py' smac_keys={ 'CMD_SET_PROPERTY' :'0',# '0' ...
class Solution: def search(self, nums: list, target: int) -> int: low =0 hi = len(nums) - 1 while low <= hi: mid = int((low + hi)/2) if nums[mid] == target: return mid elif nums[mid] > target: hi = mid - 1 else: ...
""" PROBLEM 43: Sub-string divisibility The number, 1406357289, is a 0 to 9 pandigital number because it is made up of each of the digits 0 to 9 in some order, but it also has a rather interesting sub-string divisibility property. Let d_1 be the 1st digit, d_2 be the 2nd digit, and so on. In this way, we note the fol...
''' Given a set of intervals, find out if any two intervals overlap. Example: Intervals: [[1,4], [2,5], [7,9]] Output: true Explanation: Intervals [1,4] and [2,5] overlap ''' class Interval: def __init__(self, start, end): self.start = start self.end = end def doesOverlap(intervals): interva...
""" Given an array of integers arr, and three integers a, b and c. You need to find the number of good triplets. A triplet (arr[i], arr[j], arr[k]) is good if the following conditions are true: 0 <= i < j < k < arr.length |arr[i] - arr[j]| <= a |arr[j] - arr[k]| <= b |arr[i] - arr[k]| <= c Where |x| denotes the...
# Time: O(n) # Space: O(1) # # The API: int read4(char *buf) reads 4 characters at a time from a file. # # The return value is the actual number of characters read. For example, it returns 3 if there is only 3 characters left in the file. # # By using the read4 API, implement the function int read(char *buf, int n) th...
#!/usr/bin/env python year = int(input("Año:")) if year % 4 == 0 and year % 100 != 0 or year % 400 == 0: print("Bisiesto") else: print("No bisiesto")
def check_line_containment(line_1, line_2): return (line_1[0] <= line_2[0] and line_1[1] >= line_2[1]) def containment(rec_1, rec_2): is__rec_1__in__rec_2 = check_line_containment(rec_1.get('x'), rec_2.get( 'x')) and check_line_containment(rec_1.get('y'), rec_2.get('y')) is__rec_2__in__rec_1 = chec...
# -*- coding: utf-8 -*- ''' mc_proxy / Dummy state generation ================================== ''' def hook(name, changes=None, **kw): ''' State that will always return ret, use that for orchestration purpose name name of dummy state ''' if not changes: changes = {} ret ...
#A* ------------------------------------------------------------------- #B* This file contains source code for the PyMOL computer program #C* copyright 1998-2000 by Warren Lyford Delano of DeLano Scientific. #D* ------------------------------------------------------------------- #E* It is unlawful to modify or remove ...
alphabet = [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' ] def is_number(s): """ Check if the number is a float """ try: float(s) return True except ValueError: return False except Type...
class Data(): pass class PersonalInfo(Data): def __init__(self): self.ID = "" self.age = "" self.gender = "U" # "M" for male, "F" for female or "U" as unknown self.language = "" # "French", "Chinese" def setParams(self, ID, age, gender, language): self.ID = ID ...
horario = input('que horas sao de 0-23') if horario.isdigit(): horario = int(horario) if horario < 0 or horario > 23: print('horario de ser de 0 a 23') else: if horario <= 11: print('bom dia') elif horario <= 17: print('boa tarde') else: p...
# Load our airplanes airplanes = spark.read.json("data/airplanes.json") airplanes.show() airplanes.write.format("org.elasticsearch.spark.sql")\ .option("es.resource","agile_data_science/airplane")\ .mode("overwrite")\ .save() # Format data for Elasticsearch, as a tuple with a dummy key in the first field # airp...
#Ver4.0, finally I did it! print("Grego -> Mingo Year Translator") grego = int(input("What's that year in Grego? ")) mingo = grego - 1911 if mingo >= 0: print ("So that year in Mingo year is:", mingo) else: print ("Sorry, in that year ROC was not exist.")
n = int (input ('DIGITE UM NUMERO PARA O CALCULO DO SEU FATORIAL: ')) c = n f = 1 while c > 0: print ('{} x '.format (c), end = '') f = f * c c = c - 1 print ('O FATORIAL DE {} É IGUAL A {}'.format (n, f))
""" MAX31855 Copyright 2015 - Alexander Hiam <alex@graycat.io> A library for PyBBIO to interface with Maxim's MAX31855 thermocouple amplifier. MAX31855 is released as part of PyBBIO under its MIT license. See PyBBIO/LICENSE.txt """ class MAX31855(object): SPI_CLOCK_MODE = 1 SPI_FREQUENCY = 4000000 SPI_N_...
with open("words.txt", "r") as f: words = f.readlines()[0].split() words_found = {x: 0 for x in words} with open("input.txt", 'r') as f: for num, line in enumerate(f, start=1): for word in words: if word in line: words_found[word] += 1 with open("output.txt", "w") as f: ...
_DEFAULT_BROWSER = "firefox" _COMMON_TAGS = [ "browser-test", "no-sandbox", "requires-network", ] _BROWSERS = { "chrome": { "deps": ["//java/client/src/org/openqa/selenium/chrome"], "jvm_flags": ["-Dselenium.browser=chrome"], "tags": _COMMON_TAGS + ["chrome"], }, "edge"...
class TagCloud: def __init__(self): self.tags = {} def add(self, tag): self.tags[tag.lower()] = self.tags.get(tag.lower(), 0) + 1 def __getitem__(self, tag): return self.tags.get(tag.lower(), 0) def __setitem__(self, tag, count): self.tags[tag.lower()] = count def __len__(self): re...
#!/usr/bin/env python3 # encoding: utf-8 # like itertools.zip_longest, but with no fillvalue # written for https://github.com/erikrose/more-itertools/pull/240#issuecomment-441513474 def zip(*iterables): iterators = list(map(iter, iterables)) while True: to_yield = _build_zipped_tuple(iterators) if not to_yield:...
# # PySNMP MIB module Nortel-Magellan-Passport-BgpMIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Nortel-Magellan-Passport-BgpMIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:17:03 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Pytho...
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def reverseList(self, head): """ :type head: ListNode :rtype: ListNode """ dummy = ListNode(-1) while head: ...
a = {1,2 , 3+4, 10*7} b = {7,14,21} print(a-b) # - will return the resulting set which has elements of the left-hand set with all elements from the right-hand set removed # difference function is used in newer version # a={1,2,7,70} # {1,2, 70} a = {1,2 , 3+4, 10*7} b = {7,14,21} print(a.difference(b)) ...
''' Problem Description Given a positive integer A, return its corresponding column title as appear in an Excel sheet. Problem Constraints 1 <= A <= 1000000000 Input Format First and only argument is integer A. Output Format Return a string, the answer to the problem. Approach: base conversion''' class Solution: ...
# Copyright 2013 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. { 'variables': { 'chromium_code': 1, }, 'includes': [ 'audio_sender/audio_sender.gypi', 'congestion_control/congestion_control.gypi', '...
""" This module implements a set of languages as collections of features that are language specific. feature collections +++++++++++++++++++ Languages implement a subset of feature collections (e.g. :class:`~revscoring.languages.features.Dictionary`, :class:`~revscoring.languages.features.Stopwords`, :class:`~revscori...
class BollingerBands: def __init__(self): self.BBW = [] self.BB_indicator = False self.buy_indicator = False self.sell_indicator = False def feed(self, last_SMA, last_standard_deviation, last_close): upper_band = last_SMA + 2 * last_standard_deviation lower_band ...
class Affine: def __init__(self, W, b): self.W = W self.b = b self.x = None self.dW = None self.db = None def forward(self, x): self.x = x out = np.dot(x, self.x) + self.b return out def backward(self, dout): dx = np.dot(dout, sel...
class Solution: def fourSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[List[int]] """ resultList = [] nums.sort() for a in range(len(nums)): b = a+1 if(a>0 and nums[a] == nums[a-1]...
class NineGates: name = "Nine Gates" points = 88 excluded = ("Full Flush", "Pung of Terminals or Honors") def __init__(self, handObj): self.hand = handObj def map_ranks(self, tiles): def get_ranks(tile): rank = int(tile.rank) return rank ranks = list(map(get_ranks, tiles)) ranks.sort() return r...
# -*- coding: utf-8 -*- """@package Methods.Machine.SlotW24.comp_angle_opening SlotW24 Computation of average opening angle method @date Created on Mon Jul 06 11:40:07 2015 @copyright (C) 2014-2015 EOMYS ENGINEERING. @author pierre_b """ def comp_angle_opening(self): """Compute the average opening angle of the Sl...
def height(root): l = 1 + height(root.left) if root.left else 0 r = 1 + height(root.right) if root.right else 0 return max(l, r)
#!/usr/bin/python # -*- coding: utf-8 -*- artistdict = {"Bohemian Rhapsody":"Queen", "Imagine":"John Lennon", "Angels":"Robbie Williams", "Hey Jude":"Beatles", "Smells Like Teen Spirit":"Nirvana", "Live Forever":"Oasis", "Wonderwall":"Oasis", "One":"U2", "Bitter Sweet Symphony":"Verve", "With Or Without You":"U2", "Pe...
def validate_register_fields(req): data = req.get_json(silent=True) fields = ['first_name', 'last_name', 'email', 'password'] for d in data.keys(): if d not in fields: return False return True
""" # Example One my_list1 = [1, 2, 3, 4, 5, 6] my_list2 = my_list1 # How would you verify that my_list1 and my_list2 have the same identity? print(my_list1 is my_list2) # True my_list1.append(7) # Check if my_list1 and my_list2 still have the same identity. # If they do, why is that? print(my_list1) # [1, 2, 3,...
""" Premium Question """ __author__ = 'Daniel' class Solution(object): def __init__(self): """ encode rules """ self.skip = [[None for _ in xrange(10)] for _ in xrange(10)] self.skip[1][3], self.skip[3][1] = 2, 2 self.skip[1][7], self.skip[7][1] = 4, 4 self....
# generated from genmsg/cmake/pkg-genmsg.context.in messages_str = "/root/catkin_ws/src/navigation_msgs/map_msgs/msg/OccupancyGridUpdate.msg;/root/catkin_ws/src/navigation_msgs/map_msgs/msg/PointCloud2Update.msg;/root/catkin_ws/src/navigation_msgs/map_msgs/msg/ProjectedMapInfo.msg;/root/catkin_ws/src/navigation_msgs/m...
df = pd.DataFrame(np.random.randn(10,3), columns=['Col1', 'Col2', 'Col3']) df['X'] = pd.Series(['A', 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'B']) df['Y'] = pd.Series(['A', 'B', 'A', 'B', 'A', 'B', 'A', 'B', 'A', 'B']) boxplot = df.boxplot(column=['Col1', 'Col...
__version__ = '0.1' __all__ = ["hamilton", "objects", "hamutilities", "structure", "utilities", "gui", "masterjobs", "workbench.py", "workbench_gui.py", "setup.py", "update.py"]
{ "targets": [ { "target_name": "xprofiler", "win_delay_load_hook": "false", "sources": [ "src/environment_data.cc", "src/xprofiler.cc", "src/configure.cc", "src/logger.cc", "src/library/json....
# --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- MLC_WORKSPACE_API_VERSION = '2020-02-02' MLC_COMPUTE_RESOURCE_ID_FMT = '/subscriptions/{}/resourceGroups/{}/providers/Microsoft.Machin...
if True: if True: if True: return _( "qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweas " + "qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqwegqweasdzxcqweasdzxc.", "qweasdzxcqweasdzxcq...
""" Write a function that finds the longest palindromic substring of a given string. Try to be as efficient as possible! If you find more than one substring you should return the one which is closer to the beginning. Input: A text as a string. Output: The longest palindromic substring. Precondition: 1 < |text| ≤ 20...
# The Twitter API keys needed to send tweets CONSUMER_KEY = "enter your consumer key here" CONSUMER_SECRET = "enter your secret consumer key here" ACCESS_TOKEN = "enter your access token here" ACCESS_TOKEN_SECRET = "enter your secret access token here"
""" Profile ../profile-datasets-py/standard54lev_allgas/006.py file automaticaly created by prof_gen.py script """ self["ID"] = "../profile-datasets-py/standard54lev_allgas/006.py" self["Q"] = numpy.array([ 1.42610400e+00, 2.25740200e+00, 3.03034000e+00, 3.69967200e+00, 4.31610400e+00, 4...
class Solution: def solveNQueens(self, n: int) -> List[List[str]]: ans = [] def string_representation(board): s = [] for col in board: s.append("." * (col) + "Q" + "." * (n - col - 1)) return s def solve(row, used_columns, used_di...
class Node: def __init__(self, data): self.data = data self.next = None class Circular_Linked_List: def __init__(self): self.head = None def Sorted_Insert(self, new_node): current = self.head if current is None: new_node.next = new_node ...
def p1(): lines = open('../stream/input03.txt').read().splitlines() period = 31 #in chars mat = [] for line in lines: mat_row = [1 if x == '#' else 0 for x in list(line)] mat.append(mat_row) count = 0 j_ = 0 for i in range(0, len(mat)): # print(mat[i]) ...
class Time: def __init__(self, hour=None, minute=None, second=None): self.hour = hour self.minute = minute self.second = second def sum(self, time): result = Time() result.second = self.second + time.second result.minute = self.minute + time.minute ...
# -*- coding: utf-8 -*- """ Contains a bunch of information about this package. """ __version__ = "0.1.5" __author__ = "Benjamin F. Maier" __copyright__ = "Copyright 2020-2021, " + __author__ __credits__ = [__author__] __license__ = "MIT" __maintainer__ = __author__ __email__ = "contact@benmaier.org" __status__ = "De...
with open("./input.txt") as f: arr = [ line.strip() for line in f.readlines()] annoying = arr[0].replace("=", "|").replace(".", "|").replace(",", "|").replace(" ", "|").split("|") nums = [int(thing) for thing in annoying if thing.replace("-", "").isnumeric()] def contained(loc): return nums[0] <= loc[0] <= n...
ech_genshis = 2 ou_genshis = 2 suu_bunshis = 12 zenn_genshis = suu_bunshis*(ech_genshis + ou_genshis) print(zenn_genshis)
def string_anagrams(s1,s2): if(sorted(s1)==sorted(s2)): print("The strings are anagrams.") else: print("The strings aren't anagrams.") s1=input("Enter first string:") s2=input("Enter second string:") string_anagrams(s1,s2)
#:copyright: Copyright 2009-2010 by the Vesper team, see AUTHORS. #:license: Dual licenced under the GPL or Apache2 licences, see LICENSE. @Action def testaction(kw, retval): query = "{comment where(label='%s')}" % kw._name #XXX qnames are broken result = kw.__server__.defaultStore.query(query) tem...
def artifactual_patterns(a: set, b: set): """ Measures the proportion of frequent itemsets minded from the sanitised database which did not occur in the original database. Given a transactional database D and an associated sanitised database D′ a is the set of frequent itemsets in D b is the se...
#!/usr/bin/env python ''' Copyright (C) 2019, WAFW00F Developers. See the LICENSE file for copying permission. ''' NAME = 'Instart DX (Instart Logic)' def is_waf(self): schema1 = [ self.matchHeader(('X-Instart-Request-ID', '.+')), self.matchHeader(('X-Instart-Cache', '.+')), self.matchHea...
class Codec: def __init__(self): self.counter = 0 self.dic = {} def encode(self, longUrl): """Encodes a URL to a shortened URL. :type longUrl: str :rtype: str """ self.dic[self.counter] = longUrl self.counter += 1 return self.cou...
# day 6 question 2 # more customs declarations groups = [] group = {} with open('input.txt', 'r') as file: num = 0 for line in file: line = line.strip() if not line: group['num'] = num num = 0 groups.append(group) group = {} e...
''' aula tratamento de erros ''' ''' n = int(input('Número: ')) print(f'Você digitou o Número {n}') # se digitar não-inteiro; typeError ''' try: a = int(input('Numerador: ')) b = int(input('Denominador: ')) r = a / b except Exception as erro: print(f'Problema Encontrado foi {erro.__class__}') exce...
__version__ = '0.1.3' dataPaths = {'reference': 'src/db/human_GRCh38_no_alt_analysis_set_chr22only_cyp2d7-masked.fasta', 'database' : 'src/db/CYP2D6.db', 'spacer' : 'src/db/spacer.fasta'} database = {'alleleTable' : 'pbAA_consensus', 'variantTable': 'SampleVariants', ...
class MyClass: """a multi-line docstring""" class InnerClass: """ a multi-line docstring""" class MyClass: """a multi-line docstring """ class InnerClass: """a multi-line docstring """ class MyClass: """ a docstring""" class ...
""" Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move either down or right at any point in time. Example: Input: [ [1,3,1], [1,5,1], [4,2,1] ] Output: 7 Explanation: Because the path 1→3→...
""" write your first program in python3 python3 helloworld.py """ print("HelloWorld in python!!")
class Solution: def maxSumRangeQuery(self, nums: List[int], requests: List[List[int]]) -> int: n = len(nums) count = [0] * (n + 1) for start, end in requests: count[start] += 1 count[end + 1] -= 1 for i in range(1, n + 1): count[i] += count[i - 1] ...
__all__ = [ 'DocParseMeta' ] class DocParseMeta(type): @staticmethod def __new__(meta, clsname, bases, clsdict): if '__doc__' in clsdict: lexer = meta.lexer() parser = meta.parser() lexer.cls_name = parser.cls_name = clsname lexer.cls_qualname = parser.cls...