content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# Network parameters NUM_DIGITS = 10 TRAIN_BEGIN = 101 TRAIN_END = 1001 CATEGORIES = 4 NUM_HIDDEN_1 = 512 NUM_HIDDEN_2 = 512 # Parameters LEARNING_RATE = 0.005 TRAINING_EPOCHS = 50 BATCH_SIZE = 32 DECAY = 1e-6 MOMENTUM = 0.9
num_digits = 10 train_begin = 101 train_end = 1001 categories = 4 num_hidden_1 = 512 num_hidden_2 = 512 learning_rate = 0.005 training_epochs = 50 batch_size = 32 decay = 1e-06 momentum = 0.9
class PFFlaskSwaggerConfig(object): # General Config enable_pf_api_convention: bool = False default_tag_name: str = "Common" # Auth Config enable_jwt_auth_global: bool = False # UI Config enable_swagger_view_page: bool = True enable_swagger_page_auth: bool = False swagger_page_auth...
class Pfflaskswaggerconfig(object): enable_pf_api_convention: bool = False default_tag_name: str = 'Common' enable_jwt_auth_global: bool = False enable_swagger_view_page: bool = True enable_swagger_page_auth: bool = False swagger_page_auth_user: str = 'pfadmin' swagger_page_auth_password: st...
def remove_duplicates(arr): arr[:] = list({i:0 for i in arr}) # test remove_duplicates numbers = [1,66,32,34,2,33,11,32,87,3,4,16,55,23,66] arr = [i for i in numbers] remove_duplicates(arr) print("Numbers: ", numbers) print("Duplicates Removed: ", arr)
def remove_duplicates(arr): arr[:] = list({i: 0 for i in arr}) numbers = [1, 66, 32, 34, 2, 33, 11, 32, 87, 3, 4, 16, 55, 23, 66] arr = [i for i in numbers] remove_duplicates(arr) print('Numbers: ', numbers) print('Duplicates Removed: ', arr)
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def pathSum(self, root: TreeNode, sum: int) -> List[List[int]]: if not root: return [] res = [] def ...
class Solution: def path_sum(self, root: TreeNode, sum: int) -> List[List[int]]: if not root: return [] res = [] def dfs(node, tmp, cur_sum): cur_sum += node.val if not node.left and (not node.right): if cur_sum == sum: ...
a = int(input()) if ((a%4 == 0) and (a%100 != 0 or a%400 == 0)): print('1') else: print('0')
a = int(input()) if a % 4 == 0 and (a % 100 != 0 or a % 400 == 0): print('1') else: print('0')
class Plot: def __init__(self, x=None, y=None, layers=None, fig=None, ax=None): self.x = x self.y = y self.layers = layers self.fig = fig self.ax = ax
class Plot: def __init__(self, x=None, y=None, layers=None, fig=None, ax=None): self.x = x self.y = y self.layers = layers self.fig = fig self.ax = ax
#!/usr/bin/python """ Module by Butum Daniel - Group 911 """ def filter(iterable, filter_function): """ Filter an iterable object(e.g a list) by a user supplied function Example: numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] def filter_function(x): return x % 2 == 0 # all e...
""" Module by Butum Daniel - Group 911 """ def filter(iterable, filter_function): """ Filter an iterable object(e.g a list) by a user supplied function Example: numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] def filter_function(x): return x % 2 == 0 # all even numbers ...
__name__ = "jade" __version__ = "0.0.1" __author__ = "Aaron Halfaker" __author_email__ = "ahalfaker@wikimedia.org" __description__ = "Judgment and Dialog Engine" __url__ = "https://github.com/wiki-ai/jade" __license__ = "MIT"
__name__ = 'jade' __version__ = '0.0.1' __author__ = 'Aaron Halfaker' __author_email__ = 'ahalfaker@wikimedia.org' __description__ = 'Judgment and Dialog Engine' __url__ = 'https://github.com/wiki-ai/jade' __license__ = 'MIT'
# -*- coding: utf-8 -*- """ Created on Thu Jun 18 20:08:30 2020 @author: luol2 """ def combine_overlap(mention_list): entity_list=[] if len(mention_list)>2: first_entity=mention_list[0] nest_list=[first_entity] max_eid=int(first_entity[1]) for i in r...
""" Created on Thu Jun 18 20:08:30 2020 @author: luol2 """ def combine_overlap(mention_list): entity_list = [] if len(mention_list) > 2: first_entity = mention_list[0] nest_list = [first_entity] max_eid = int(first_entity[1]) for i in range(1, len(mention_list)): se...
#! /usr/bin/env python class arm_main: def __init__(self): list = [] self.planning_group = "arm_group" list.append(self.planning_group) object_f = arm_main() object_f.planning_group = "test" print(object_f.planning_group)
class Arm_Main: def __init__(self): list = [] self.planning_group = 'arm_group' list.append(self.planning_group) object_f = arm_main() object_f.planning_group = 'test' print(object_f.planning_group)
#Program to find perfect numbers within a given range l,m (inclusive) in python #This code is made for the issue #184(Print all the perfect numbers in a given range.) l = int(input()) m = int(input()) perfect_numbers = [] if l > m: l, m = m, l for j in range(l,m+1): divisor = [] for i in range(1,...
l = int(input()) m = int(input()) perfect_numbers = [] if l > m: (l, m) = (m, l) for j in range(l, m + 1): divisor = [] for i in range(1, j): if j % i == 0: divisor.append(i) if sum(divisor) == j: perfect_numbers.append(j) print('Found a perfect Number: ' + str(j)) pr...
# Tuplas # sao imutaveis depois de iniciado o programa ( comando de atribuir (=) nao funcionara) print('-' * 30) print('Exemplo 1 print') mochila = ('Machado', 'Camisa', 'Bacon', 'Abacate') print(mochila) print('-' * 30) print('Exemplo 2 fatiando') # podemos manipular e fatir a tupla igual strings print(mochila[0]) #...
print('-' * 30) print('Exemplo 1 print') mochila = ('Machado', 'Camisa', 'Bacon', 'Abacate') print(mochila) print('-' * 30) print('Exemplo 2 fatiando') print(mochila[0]) print(mochila[2]) print(mochila[0:2]) print(mochila[2:]) print(mochila[-1]) print('-' * 30) print('Exemplo 3 sem range') for item in mochila: prin...
class Solution: def findCircleNum(self, M): """ :type M: List[List[int]] :rtype: int """ count = 0 circle = {} m = len(M) n = len(M[0]) for i in range(m): for j in range(n): if M[i][j] == 1 and (i, j) not in circ...
class Solution: def find_circle_num(self, M): """ :type M: List[List[int]] :rtype: int """ count = 0 circle = {} m = len(M) n = len(M[0]) for i in range(m): for j in range(n): if M[i][j] == 1 and (i, j) not in circl...
# Copyright 2015-2016 by Raytheon BBN Technologies Corp. All Rights Reserved. """ Old loop unroller Functionality is now done within eval """ class Unroller(ast.NodeTransformer): """ A more general form of the ConcurUnroller, which knows how to "unroll" FOR loops and IF statements in more general contex...
""" Old loop unroller Functionality is now done within eval """ class Unroller(ast.NodeTransformer): """ A more general form of the ConcurUnroller, which knows how to "unroll" FOR loops and IF statements in more general contexts. TODO: document the subset of all possible cases that this code actu...
# pylint: disable=missing-docstring, line-too-long FINAL = b"""\ First line Line two. Line 3 Four? Five! 7 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et d...
final = b'First line\nLine two.\nLine 3\nFour?\nFive!\n7\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae au...
#: Warn if a field that implements storage is missing it's reset value MISSING_RESET = 1<<0 #: Warn if a field's bit offset is not explicitly specified IMPLICIT_FIELD_POS = 1<<1 #: Warn if a component's address offset is not explicitly assigned IMPLICIT_ADDR = 1<<2 #: Warn if an instance array's address stride is n...
missing_reset = 1 << 0 implicit_field_pos = 1 << 1 implicit_addr = 1 << 2 stride_not_pow2 = 1 << 3 strict_self_align = 1 << 4 all = MISSING_RESET | IMPLICIT_FIELD_POS | IMPLICIT_ADDR | STRIDE_NOT_POW2 | STRICT_SELF_ALIGN
# 1470. Shuffle the Array # Author- @lashewi class Solution: def shuffle(self, nums: List[int], n: int) -> List[int]: out = [] for i in range(n): out.append(nums[i]) out.append(nums[i+n]) return out
class Solution: def shuffle(self, nums: List[int], n: int) -> List[int]: out = [] for i in range(n): out.append(nums[i]) out.append(nums[i + n]) return out
line = input() result = "." for word in line: if word != result[-1]: result += word print(result.replace(".", ""))
line = input() result = '.' for word in line: if word != result[-1]: result += word print(result.replace('.', ''))
class Solution: def isPalindrome(self, s: str) -> bool: left=0 right=len(s)-1 while left<right: while left<right and not s[left].isalpha() and not s[left].isdigit(): left+=1 while left<right and not s[right].isalpha() and not s[right].isdigit(...
class Solution: def is_palindrome(self, s: str) -> bool: left = 0 right = len(s) - 1 while left < right: while left < right and (not s[left].isalpha()) and (not s[left].isdigit()): left += 1 while left < right and (not s[right].isalpha()) and (not s[r...
#!usr/bin/env python3 def main(): name = input("Enter ur Name to Start Quiz: ") ans = input("TRUE or FALSE: Python was released in 1991:\n") if ans == "TRUE": print('Correct') elif ans == "FALSE": print('Wrong') elif ans != ("TRUE" or "FALSE"): print('Please answer TRUE o...
def main(): name = input('Enter ur Name to Start Quiz: ') ans = input('TRUE or FALSE: Python was released in 1991:\n') if ans == 'TRUE': print('Correct') elif ans == 'FALSE': print('Wrong') elif ans != ('TRUE' or 'FALSE'): print('Please answer TRUE or FALSE') print('B...
maior = '' while True: a = input() if a == '0': print('\nThe biggest word: {}'.format(maior)) break a = a.split() for y, x in enumerate(a): if len(x) >= len(maior): maior = x if y+1 == len(a): print(len(x)) else: print(len(x), e...
maior = '' while True: a = input() if a == '0': print('\nThe biggest word: {}'.format(maior)) break a = a.split() for (y, x) in enumerate(a): if len(x) >= len(maior): maior = x if y + 1 == len(a): print(len(x)) else: print(len(x...
A, B, C, K = map(int, input().split()) ans = min(A, K) K -= min(A, K) K = max(0, K - B) ans += -1 * min(K, C) print(ans)
(a, b, c, k) = map(int, input().split()) ans = min(A, K) k -= min(A, K) k = max(0, K - B) ans += -1 * min(K, C) print(ans)
#18560 Mateusz Boczarski def testy(): #Zadanie 1 #Zdefiniuj klase Student(), ktora zawiera pola (niestatyczne): imie, nazwisko, nr_indeksu, #kierunek. Klasa ma posiadac __init__(), w ktorym podczas tworzenia instancji (obiektu) przypisywane #beda wartosci do wskazanych pol. Pole nr_indeksu powinno by...
def testy(): print('Zadanie 1') s1 = student('Jan', 'Kowalski', 1885, 'IE') print(s1.imie) print(s1.nazwisko) print(s1.kierunek) print(s1) print('\nZadanie 2') s2 = student('Kamil', 'Nowak', 1825, 'IP') print(s1.__lt__(s2)) print(s1.__eq__(s2)) print('\nZadanie 3') s3 = s...
def heapify(customList, n, i): smallest = i l = 2 * i + 1 r = 2 * i + 2 if l < n and customList[l] < customList[smallest]: smallest = l if r < n and customList[r] < customList[smallest]: smallest = r if smallest != i: customList[i], customList[smallest] = customList[sma...
def heapify(customList, n, i): smallest = i l = 2 * i + 1 r = 2 * i + 2 if l < n and customList[l] < customList[smallest]: smallest = l if r < n and customList[r] < customList[smallest]: smallest = r if smallest != i: (customList[i], customList[smallest]) = (customList[sm...
# This program creates a JPEG File Name from a Basic String word = "dog_image" print("Filename: " + word) word = word + ".jpeg" print("Image filename: " + word) # This section swaps the suffix '.jpeg' to '.jpg' i = len(word)-5 # Check if there's a suffix '.jpeg' if word[i:] == ".jpeg": #Remove the suffix ...
word = 'dog_image' print('Filename: ' + word) word = word + '.jpeg' print('Image filename: ' + word) i = len(word) - 5 if word[i:] == '.jpeg': word = word[0:i] word = word + '.jpg' print('New image filename: ' + word)
n= input() def ismagicnumber(number): if n[0] != '1': return False for i in range(len(n)): if n[i] != '1' and n[i] != '4': return False for i in range(1, len(n)-1): if n[i] == '4' and n[i-1] == '4' and n[i+1] == '4': return False return True flag =...
n = input() def ismagicnumber(number): if n[0] != '1': return False for i in range(len(n)): if n[i] != '1' and n[i] != '4': return False for i in range(1, len(n) - 1): if n[i] == '4' and n[i - 1] == '4' and (n[i + 1] == '4'): return False return True flag...
class TrackingSettings(object): """Settings to track how recipients interact with your email.""" def __init__(self): """Create an empty TrackingSettings.""" self._click_tracking = None self._open_tracking = None self._subscription_tracking = None self._ganalytics = None ...
class Trackingsettings(object): """Settings to track how recipients interact with your email.""" def __init__(self): """Create an empty TrackingSettings.""" self._click_tracking = None self._open_tracking = None self._subscription_tracking = None self._ganalytics = None ...
square = lambda x : x*x l = [1,2,3,4,5] #map return the finale value of the list. print("This is the map list.",list(map(square,l))) #filter return the original value of an list. print("This is the filter list.",list(filter(square,l)))
square = lambda x: x * x l = [1, 2, 3, 4, 5] print('This is the map list.', list(map(square, l))) print('This is the filter list.', list(filter(square, l)))
# Copyright (c) 2013 Mirantis Inc. # # 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 writi...
default_data = {'users': [{'launchpad_id': 'john_doe', 'user_name': 'John Doe', 'emails': ['johndoe@gmail.com', 'jdoe@nec.com'], 'companies': [{'company_name': '*independent', 'end_date': '2013-May-01'}, {'company_name': 'NEC', 'end_date': None}]}, {'launchpad_id': 'ivan_ivanov', 'user_name': 'Ivan Ivanov', 'emails': [...
rows = 6 cols = 50 grid = [] for _ in range(rows): grid.append([False] * cols) for line in open('input.txt', 'r'): if line.startswith('rect'): (a, b) = line[4:].strip().split('x') for i in range(int(b)): for j in range(int(a)): grid[i][j] = True elif line.starts...
rows = 6 cols = 50 grid = [] for _ in range(rows): grid.append([False] * cols) for line in open('input.txt', 'r'): if line.startswith('rect'): (a, b) = line[4:].strip().split('x') for i in range(int(b)): for j in range(int(a)): grid[i][j] = True elif line.startswi...
""" Created on Jun 18 16:54 2019 @author: nishit """ #gitkeep
""" Created on Jun 18 16:54 2019 @author: nishit """
def question(ab): exa, exb = map(int, ab.split()) return "Odd" if exa * exb % 2 == 1 else "Even"
def question(ab): (exa, exb) = map(int, ab.split()) return 'Odd' if exa * exb % 2 == 1 else 'Even'
# general driver elements ELEMENTS = [ { "name": "sendButton", "classes": ["g-btn.m-rounded"], "text": [], "id": [] }, { "name": "enterText", "classes": [], "text": [], "id": ["new_post_text_input"] }, { "name": "enterMe...
elements = [{'name': 'sendButton', 'classes': ['g-btn.m-rounded'], 'text': [], 'id': []}, {'name': 'enterText', 'classes': [], 'text': [], 'id': ['new_post_text_input']}, {'name': 'enterMessage', 'classes': ['b-chat__message__text'], 'text': [], 'id': []}, {'name': 'discountUserPromotion', 'classes': ['g-btn.m-rounded....
""" Misc utils that reproduce iterating tool for coroutine """ async def async_enumerate(aiteror, start=0): """ Simple enumerate """ i = start async for value in aiteror: yield i, value i += 1
""" Misc utils that reproduce iterating tool for coroutine """ async def async_enumerate(aiteror, start=0): """ Simple enumerate """ i = start async for value in aiteror: yield (i, value) i += 1
def buildUploadPypi(): info = 'pip install build twine\n' \ 'pip install --upgrade build twine\n' \ 'python -m build\n' \ 'twine upload --skip-existing --repository pypi dist/*' print(info) return info
def build_upload_pypi(): info = 'pip install build twine\npip install --upgrade build twine\npython -m build\ntwine upload --skip-existing --repository pypi dist/*' print(info) return info
""" The result_actions package holds objects deriving from ResultAction. A ResultAction represents an action that an be applied to a result. """
""" The result_actions package holds objects deriving from ResultAction. A ResultAction represents an action that an be applied to a result. """
i = lambda x: x k = lambda x: lambda f: x
i = lambda x: x k = lambda x: lambda f: x
#1^3-3^3-5^3.... n=int(input("Enter number of digits: ")) sum=0 temp=1 for x in range(1,n+1): temp=temp*pow(-1,x+1) if x%2==1: sum=sum+x*x*x*temp print(x*x*x,end='-') print('=',sum)
n = int(input('Enter number of digits: ')) sum = 0 temp = 1 for x in range(1, n + 1): temp = temp * pow(-1, x + 1) if x % 2 == 1: sum = sum + x * x * x * temp print(x * x * x, end='-') print('=', sum)
input = """ % This originally tested the old checker (command-line -OMb-) which does not % exist any longer. strategic(4) v strategic(16). strategic(3) v strategic(15). strategic(15) v strategic(6). strategic(15) v strategic(2). strategic(12) v strategic(16). strategic(8) v strategic(2). strategic(8) v strategic(15). s...
input = '\n% This originally tested the old checker (command-line -OMb-) which does not\n% exist any longer.\nstrategic(4) v strategic(16).\nstrategic(3) v strategic(15).\nstrategic(15) v strategic(6).\nstrategic(15) v strategic(2).\nstrategic(12) v strategic(16).\nstrategic(8) v strategic(2).\nstrategic(8) v strategic...
__author__ = 'Kalyan' notes = ''' For this assignment, you have to define a few basic classes to get an idea of defining your own types. ''' # For this problem, define a iterator class called Repeater which can be used to generate an infinite # sequence of this form: 1, 2, -2, 3, -3, 3, etc. (for each numbe...
__author__ = 'Kalyan' notes = '\nFor this assignment, you have to define a few basic classes to get an idea of defining your own types.\n' def gen_num(n): result = 0 j = 1 count = 0 flag = True while flag: sign = 0 for i in range(j): count += 1 sign += 1 ...
def maxab(a, b): if (a>=b): return a; else: return b; print(maxab(3,6)) print(maxab(8,4)) print(maxab(5,5))
def maxab(a, b): if a >= b: return a else: return b print(maxab(3, 6)) print(maxab(8, 4)) print(maxab(5, 5))
def modulus(num, div): if (type(num) != int) or (type(div) != int): raise TypeError return num % div print(modulus(True, 1))
def modulus(num, div): if type(num) != int or type(div) != int: raise TypeError return num % div print(modulus(True, 1))
# # PySNMP MIB module RADLAN-SNMP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RADLAN-SNMP-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:49:16 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, value_range_constraint, constraints_intersection, single_value_constraint, value_size_constraint) ...
media = validas = 0 while True: nota = float(input()) if nota > 10 or nota < 0: print("nota invalida") else: media += nota validas += 1 if validas == 2: media /= 2 print(f"media = {media:.2f}") validas = 0 media = 0 while True: ...
media = validas = 0 while True: nota = float(input()) if nota > 10 or nota < 0: print('nota invalida') else: media += nota validas += 1 if validas == 2: media /= 2 print(f'media = {media:.2f}') validas = 0 media = 0 while True: ...
#!/bin/python3 n = int(input("Input problem ID:")) n -= 101 user = n // 4 rnk = n % 4 tab = [ ['UC','DG','RB',''], ['HC','IB','FJ',''], ['GK','UH','QH',''], ['EE','DJ','IH',''], ['HL','MI','EJ',''], ['MB','UI','ED',''], ['AA','BG','ML',''], ['CF','TE','QG',''], ['PH','UJ','BB',''], ['CI','SD','NG',''], ['DK','LD','IJ...
n = int(input('Input problem ID:')) n -= 101 user = n // 4 rnk = n % 4 tab = [['UC', 'DG', 'RB', ''], ['HC', 'IB', 'FJ', ''], ['GK', 'UH', 'QH', ''], ['EE', 'DJ', 'IH', ''], ['HL', 'MI', 'EJ', ''], ['MB', 'UI', 'ED', ''], ['AA', 'BG', 'ML', ''], ['CF', 'TE', 'QG', ''], ['PH', 'UJ', 'BB', ''], ['CI', 'SD', 'NG', ''], ['...
id = "IAD" location = "dulles Intl Airport" max_temp = 32 min_temp = 13 precipitation = 0.4 #'(IAD) : (Dulles Intl Airport) : (32) / (13) / (0.4)' print("First Method") print ('{id:3s} : {location:19s} : {max_temp:3d} / {min_temp:3d} / {precipitation:5.2f}'.format( id=id, location=location, max_temp=max_temp, ...
id = 'IAD' location = 'dulles Intl Airport' max_temp = 32 min_temp = 13 precipitation = 0.4 print('First Method') print('{id:3s} : {location:19s} : {max_temp:3d} / {min_temp:3d} / {precipitation:5.2f}'.format(id=id, location=location, max_temp=max_temp, min_temp=min_temp, precipitation=precipitation)) print('') print('...
# def max_num(a, b, c): # if a >= b and a >= c: # return a # elif b >= a and b >= c: # return b # else: # return c # print(max_num(6,3,4)) def max_num(): num1 = int(input("Please enter first number: ")) num2 = int(input("Please enter second nu...
def max_num(): num1 = int(input('Please enter first number: ')) num2 = int(input('Please enter second number: ')) num3 = int(input('Please enter third number: ')) if num1 >= num2 and num1 >= num3: return 'Max is ' + str(num1) elif num2 >= num1 and num2 >= num3: return 'Max is ' + str...
# Copyright 2018 Ocean Protocol Foundation # SPDX-License-Identifier: Apache-2.0 class ConfigProvider: """Provides the Config instance.""" _config = None @staticmethod def get_config(): """ Get a Config instance.""" assert ConfigProvider._config, 'set_config first.' return Co...
class Configprovider: """Provides the Config instance.""" _config = None @staticmethod def get_config(): """ Get a Config instance.""" assert ConfigProvider._config, 'set_config first.' return ConfigProvider._config @staticmethod def set_config(config): """ ...
# -*- coding: utf-8 -*- def cartesius_to_image_coord(x, y, bounds): assert bounds.is_set() assert bounds.image_width assert bounds.image_height assert x != None assert y != None x = float(x) y = float(y) x_ratio = (x - bounds.left) / (bounds.right - bounds.left) y_ratio = (y - bou...
def cartesius_to_image_coord(x, y, bounds): assert bounds.is_set() assert bounds.image_width assert bounds.image_height assert x != None assert y != None x = float(x) y = float(y) x_ratio = (x - bounds.left) / (bounds.right - bounds.left) y_ratio = (y - bounds.bottom) / (bounds.top -...
# LIST OPERATION EDABIT SOLUTION: def list_operation(x, y, n): # creating a list to append the elements that are divisible by 'n'. l = [] # creating a for-loop to iterate from the x to y (both inclusive). for i in range(x, y + 1): # creating a nested if-statement to check for the element's divis...
def list_operation(x, y, n): l = [] for i in range(x, y + 1): if i % n == 0: l.append(i) return l
def run_server(model=None): print("Starting server.") if __name__ == "__main__": run_server()
def run_server(model=None): print('Starting server.') if __name__ == '__main__': run_server()
# A recursive solution for subset sum # problem # Returns true if there is a subset # of set[] with sun equal to given sum def isSubsetSum(set, n, sum): # Base Cases if (sum == 0): return True if (n == 0): return False # If last element is greater than # sum, then ignore it if (set[n - 1] > sum): retur...
def is_subset_sum(set, n, sum): if sum == 0: return True if n == 0: return False if set[n - 1] > sum: return is_subset_sum(set, n - 1, sum) return is_subset_sum(set, n - 1, sum) or is_subset_sum(set, n - 1, sum - set[n - 1]) set = [3, 34, 4, 12, 5, 2] sum = 9 n = len(set) if is_s...
class Packet(object): def __init__(self, ip_origin, ip_destination, data): self.ip_origin = ip_origin self.ip_destination = ip_destination self.data = data def __str__(self): return '{0}{1}{2}'.format(self.ip_origin, self.ip_destination, self.data)
class Packet(object): def __init__(self, ip_origin, ip_destination, data): self.ip_origin = ip_origin self.ip_destination = ip_destination self.data = data def __str__(self): return '{0}{1}{2}'.format(self.ip_origin, self.ip_destination, self.data)
# -*- coding: UTF-8 -*- ''' for num in range(5): for num in range(1,5): for num in range(1,5,2): ''' num_start = 1 num_end = 1000000000 num_input = input('Type a end number:') num_end = int(num_input) sum = 0 for num in range(num_start, num_end + 1): sum += num_end print(sum)
""" for num in range(5): for num in range(1,5): for num in range(1,5,2): """ num_start = 1 num_end = 1000000000 num_input = input('Type a end number:') num_end = int(num_input) sum = 0 for num in range(num_start, num_end + 1): sum += num_end print(sum)
n=30 n1=[10, 11, 12, 13, 14, 17, 18, 19] s1=[] i=0 c=0 l=len(n1) while i<l: j=0 while j<l: if n1[j]+n1[i]==n and n1[i]<n1[j]: s1.append([n1[i],n1[j]]) j+=1 i+=1 print(s1)
n = 30 n1 = [10, 11, 12, 13, 14, 17, 18, 19] s1 = [] i = 0 c = 0 l = len(n1) while i < l: j = 0 while j < l: if n1[j] + n1[i] == n and n1[i] < n1[j]: s1.append([n1[i], n1[j]]) j += 1 i += 1 print(s1)
#Functions #Taking input in lowercase name = input("Enter Name?").lower() #Defining Two Functions def advaith(): print("Hello, Advaith"); def rohan(): print("Hello, rohan"); #Checking the person's data if name == "advaith": advaith() elif name == "rohan": rohan() else: print("Unknown person");
name = input('Enter Name?').lower() def advaith(): print('Hello, Advaith') def rohan(): print('Hello, rohan') if name == 'advaith': advaith() elif name == 'rohan': rohan() else: print('Unknown person')
''' Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. Note: Recursive solution is trivial, could you do it iteratively? ''' # Definition for a binary tree node. class TreeNode(object): d...
""" Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 2 / 3 return [1,2,3]. Note: Recursive solution is trivial, could you do it iteratively? """ class Treenode(object): def __init__(self, x): self.val = x self...
PRO = 'PRO' WEB = 'WEB' VENTAS = 'VENTAS' BACKEND = 'BACKEND' MODULE_CHOICES = ( (PRO, 'Profesional'), (WEB, 'Web informativa'), (VENTAS, 'Ventas'), (BACKEND, 'Backend Manager'), ) ACT = 'PRO' INACT = 'WEB' OTRO = 'VENTAS' ESTADO_CHOICES = ( (ACT, 'Activo'), (INACT, 'Baja'), (OTRO, 'Otro...
pro = 'PRO' web = 'WEB' ventas = 'VENTAS' backend = 'BACKEND' module_choices = ((PRO, 'Profesional'), (WEB, 'Web informativa'), (VENTAS, 'Ventas'), (BACKEND, 'Backend Manager')) act = 'PRO' inact = 'WEB' otro = 'VENTAS' estado_choices = ((ACT, 'Activo'), (INACT, 'Baja'), (OTRO, 'Otro'))
#!/usr/bin/env python3 with open("input.txt") as f: inp = f.read() layer_len = 150 num_layers = len(inp) / 150 BLACK = str(0) WHITE = str(1) TRANSPARENT = str(2) top_pixels = [None] * layer_len for i in range(num_layers): layer = inp[i * layer_len : (i + 1) * layer_len] for i, l in enumerate(layer): ...
with open('input.txt') as f: inp = f.read() layer_len = 150 num_layers = len(inp) / 150 black = str(0) white = str(1) transparent = str(2) top_pixels = [None] * layer_len for i in range(num_layers): layer = inp[i * layer_len:(i + 1) * layer_len] for (i, l) in enumerate(layer): if top_pixels[i] is no...
""" @no 230 @name Kth Smallest Element in a BST """ class Solution: def count(self, root): if not root: return 0 return self.count(root.left) + self.count(root.right) + 1 def kthSmallest(self, root, k): """ :type root: TreeNode :type k: int :rtype: int ""...
""" @no 230 @name Kth Smallest Element in a BST """ class Solution: def count(self, root): if not root: return 0 return self.count(root.left) + self.count(root.right) + 1 def kth_smallest(self, root, k): """ :type root: TreeNode :type k: int :rtype:...
# -*- coding: utf-8 -*- """Top-level package for battlecl0ud.""" __author__ = """battlecloud""" __email__ = 'battlecloud@khast3x.club' __version__ = '0.1.0'
"""Top-level package for battlecl0ud.""" __author__ = 'battlecloud' __email__ = 'battlecloud@khast3x.club' __version__ = '0.1.0'
""" TicTacToe supporting functions ------------------------------ """ def winners(): """ Returns a list of sets with winning combinations for tic tac toe. """ return [{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {1, 4, 7}, {2, 5, 8}, {3, 6, 9}, {1, 5, 9}, {3, 5, 7}] def check_win(player_st...
""" TicTacToe supporting functions ------------------------------ """ def winners(): """ Returns a list of sets with winning combinations for tic tac toe. """ return [{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {1, 4, 7}, {2, 5, 8}, {3, 6, 9}, {1, 5, 9}, {3, 5, 7}] def check_win(player_state): ""...
#!/usr/bin/env python NAME = 'Art of Defence HyperGuard' def is_waf(self): # credit goes to W3AF return self.match_cookie('^WODSESSION=')
name = 'Art of Defence HyperGuard' def is_waf(self): return self.match_cookie('^WODSESSION=')
__author__ = 'arobres' #REQUEST PARAMETERS CONTENT_TYPE = u'content-type' CONTENT_TYPE_JSON = u'application/json' CONTENT_TYPE_XML = u'application/xml' ACCEPT_HEADER = u'Accept' ACCEPT_HEADER_XML = u'application/xml' ACCEPT_HEADER_JSON = u'application/json' AUTH_TOKEN_HEADER = u'X-Auth-Token' TENANT_ID_HEADER = u'Te...
__author__ = 'arobres' content_type = u'content-type' content_type_json = u'application/json' content_type_xml = u'application/xml' accept_header = u'Accept' accept_header_xml = u'application/xml' accept_header_json = u'application/json' auth_token_header = u'X-Auth-Token' tenant_id_header = u'Tenant-Id' headers = {'co...
""" Module to contain 'process state' object (pstate) related functionality """ __author__ = 'sergey kharnam' class Pstate(object): """ Class to represent process state (pstate) object data store pstate contains: - hostname (str) -- hostname of execution machine - rc (int) -- return code (default...
""" Module to contain 'process state' object (pstate) related functionality """ __author__ = 'sergey kharnam' class Pstate(object): """ Class to represent process state (pstate) object data store pstate contains: - hostname (str) -- hostname of execution machine - rc (int) -- return code (default: ...
''' from flask import Flask, current_app from config import Config from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate from flask_login import LoginManager from flask_mail import Mail from flask_babel import Babel, lazy_gettext as _l from flask_bootstrap import Bootstrap app = Flask(__name__) ap...
""" from flask import Flask, current_app from config import Config from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate from flask_login import LoginManager from flask_mail import Mail from flask_babel import Babel, lazy_gettext as _l from flask_bootstrap import Bootstrap app = Flask(__name__) ap...
def describe_city(name, country='Norway'): """Display information regarding a city's name and which country it is in.""" print(name + " is in " + country + ".") describe_city(name='Oslo') describe_city(name='Bergen') describe_city(name='Cordoba', country='Argentina')
def describe_city(name, country='Norway'): """Display information regarding a city's name and which country it is in.""" print(name + ' is in ' + country + '.') describe_city(name='Oslo') describe_city(name='Bergen') describe_city(name='Cordoba', country='Argentina')
# # PySNMP MIB module TRAPEZE-NETWORKS-ROOT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TRAPEZE-NETWORKS-ROOT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 21:19:43 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3....
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_union, single_value_constraint, constraints_intersection, value_size_constraint) ...
class Solution(object): def threeSumClosest(self, nums, target): result, min_diff = 0, float("inf") nums.sort() for i in reversed(range(2, len(nums))): if i+1 < len(nums) and nums[i] == nums[i+1]: continue left, right = 0, i-1 while left < ...
class Solution(object): def three_sum_closest(self, nums, target): (result, min_diff) = (0, float('inf')) nums.sort() for i in reversed(range(2, len(nums))): if i + 1 < len(nums) and nums[i] == nums[i + 1]: continue (left, right) = (0, i - 1) ...
# # PySNMP MIB module ZHONE-COM-VOICE-SIG-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ZHONE-COM-VOICE-SIG-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:47:22 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 ...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, constraints_union, value_range_constraint, single_value_constraint, constraints_intersection) ...
# TSP set for Uruguay from http://www.math.uwaterloo.ca/tsp/world/countries.html#UY OPTIMAL_SOLUTION = 79114 POINTS = [ (30133.3333, 57633.3333), (30166.6667, 57100.0000), (30233.3333, 57583.3333), (30250.0000, 56850.0000), (30250.0000, 56950.0000), (30250.0000, 57583.3333), (30300.0000, 569...
optimal_solution = 79114 points = [(30133.3333, 57633.3333), (30166.6667, 57100.0), (30233.3333, 57583.3333), (30250.0, 56850.0), (30250.0, 56950.0), (30250.0, 57583.3333), (30300.0, 56966.6667), (30316.6667, 56816.6667), (30400.0, 56466.6667), (30400.0, 56783.3333), (30433.3333, 57433.3333), (30466.6667, 56550.0), (30...
class Events: INITIALIZE = "INITIALIZE" # To initialize constants in the callback. TRAIN_BEGIN = "TRAIN_BEGIN" # At the beginning of each epoch. EPOCH_BEGIN = "EPOCH_BEGIN" # Set HP before the output and loss are computed. BATCH_BEGIN = "BATCH_BEGIN" # Called after forward but before lo...
class Events: initialize = 'INITIALIZE' train_begin = 'TRAIN_BEGIN' epoch_begin = 'EPOCH_BEGIN' batch_begin = 'BATCH_BEGIN' loss_begin = 'LOSS_BEGIN' backward_begin = 'BACKWARD_BEGIN' backward_end = 'BACKWARD_END' step_begin = 'STEP_BEGIN' step_end = 'STEP_END' batch_end = 'BATCH...
h, w = map(int, input().split()) ans = (h * w + 1) // 2 if h == 1 or w == 1: ans = 1 print(ans)
(h, w) = map(int, input().split()) ans = (h * w + 1) // 2 if h == 1 or w == 1: ans = 1 print(ans)
class MaxStepsExceeded(Exception): pass class MaxTimeExceeded(Exception): pass class StepControlFailure(Exception): pass class ConditionExit(Exception): pass class InvalidBrackets(Exception): pass class TransformationNotDefined(Exception): pass
class Maxstepsexceeded(Exception): pass class Maxtimeexceeded(Exception): pass class Stepcontrolfailure(Exception): pass class Conditionexit(Exception): pass class Invalidbrackets(Exception): pass class Transformationnotdefined(Exception): pass
""" @author: Gabriele Girelli @contact: gigi.ga90@gmail.com """ CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
""" @author: Gabriele Girelli @contact: gigi.ga90@gmail.com """ context_settings = dict(help_option_names=['-h', '--help'])
# https://leetcode.com/problems/add-two-numbers/ ''' Runtime: 88 ms, faster than 38.84% of Python3 online submissions for Add Two Numbers. Memory Usage: 13.9 MB, less than 33.63% of Python3 online submissions for Add Two Numbers. ''' # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0...
""" Runtime: 88 ms, faster than 38.84% of Python3 online submissions for Add Two Numbers. Memory Usage: 13.9 MB, less than 33.63% of Python3 online submissions for Add Two Numbers. """ class Solution: def add_two_numbers(self, l1: ListNode, l2: ListNode) -> ListNode: c = 0 k = 0 while l1: ...
x = """0 0 1.0 1 0 1.0 2 0 1.0 0 1 1.0 0 2 1.0 1 1 1.0 1 2 1.0 2 1 1.0 2 2 1.0 3 0 1.0 4 0 1.0 5 0 1.0 6 0 1.0 0 3 1.0 0 4 1.0 0 5 1.0 0 6 1.0 3 1 1.0 1 3 1.0 4 1 1.0 1 4 1.0 5 1 1.0 1 5 1.0 6 1 1.0 1 6 1.0 3 2 1.0 2 3 1.0 4 2 1.0 2 4 1.0 5 2 1.0 2 5 1.0 6 2 1.0 2 6 1.0 3 3 1.0 4 3 1.0 5 3 1.0 6 3 1.0 3 4 1.0 4 4 1.0 5...
x = '0 0 1.0\n1 0 1.0\n2 0 1.0\n0 1 1.0\n0 2 1.0\n1 1 1.0\n1 2 1.0\n2 1 1.0\n2 2 1.0\n3 0 1.0\n4 0 1.0\n5 0 1.0\n6 0 1.0\n0 3 1.0\n0 4 1.0\n0 5 1.0\n0 6 1.0\n3 1 1.0\n1 3 1.0\n4 1 1.0\n1 4 1.0\n5 1 1.0\n1 5 1.0\n6 1 1.0\n1 6 1.0\n3 2 1.0\n2 3 1.0\n4 2 1.0\n2 4 1.0\n5 2 1.0\n2 5 1.0\n6 2 1.0\n2 6 1.0\n3 3 1.0\n4 3 1.0\n...
def application(env, start_response): ip = env['REMOTE_ADDR'].encode() start_response('200', [('Content-Length', str(len(ip)))]) return ip
def application(env, start_response): ip = env['REMOTE_ADDR'].encode() start_response('200', [('Content-Length', str(len(ip)))]) return ip
def sign_in_database_create_farmer(request,cursor,con): cursor.execute(""" SELECT `PhoneNumber` FROM `farmers` """) phone_numbers = cursor.fetchall() IsUnique = 1 #print(phone_numbers) [('8610342197',), ('9176580040',)] #check if phone number matches for i in phone...
def sign_in_database_create_farmer(request, cursor, con): cursor.execute(' SELECT `PhoneNumber` FROM `farmers` ') phone_numbers = cursor.fetchall() is_unique = 1 for i in phone_numbers: if i[0] == request.form['phone']: is_unique = 2 if IsUnique == 1: cursor.execute(" INS...
cont = 1 print('-' * 34) while True: tabuada = int(input('Quer ver a tabuada de qual valor? ')) print('-' * 34) if tabuada < 0: break for c in range(1, 11): print(f'{tabuada} x {cont} = {tabuada*cont}') cont += 1 print('-' * 34) print('Programa de tabuada ENCERRADO! Volte Sem...
cont = 1 print('-' * 34) while True: tabuada = int(input('Quer ver a tabuada de qual valor? ')) print('-' * 34) if tabuada < 0: break for c in range(1, 11): print(f'{tabuada} x {cont} = {tabuada * cont}') cont += 1 print('-' * 34) print('Programa de tabuada ENCERRADO! Volte S...
# Writing Basic Python Programs # Drawing in Python print(" /|") print(" / |") print(" / |") print("/___|") # Click Play or Run Button in top right to run program # After clicking run the program will appear in the consule # Order of instructions matters!
print(' /|') print(' / |') print(' / |') print('/___|')
miles = float(input("Enter a distance in miles: ")) # x km = x miles * 1.609344 distance = miles*1.609344 print(f"Distance in km is: {distance}")
miles = float(input('Enter a distance in miles: ')) distance = miles * 1.609344 print(f'Distance in km is: {distance}')
toolname = 'bspline' thisDir = Dir('.').abspath upDir = Dir('./../').abspath # Define tool. This must match the value of toolname. def bspline(env): env.Append(LIBS = [toolname]) env.AppendUnique(CPPPATH = [upDir]) env.AppendUnique(CPPPATH = [thisDir]) env.AppendUnique(LIBPATH = [thisDir]) env.R...
toolname = 'bspline' this_dir = dir('.').abspath up_dir = dir('./../').abspath def bspline(env): env.Append(LIBS=[toolname]) env.AppendUnique(CPPPATH=[upDir]) env.AppendUnique(CPPPATH=[thisDir]) env.AppendUnique(LIBPATH=[thisDir]) env.Require(['prefixoptions']) export(toolname) sources = split('\nB...
class PluginDistributionRepositoryProvider: def __init__(self, plugin, repository_url_provider): self.plugin = plugin self.repository_url_provider = repository_url_provider def get_download_url(self, host): distribution_repository = self.plugin.variables["distribution"]["repository"] ...
class Plugindistributionrepositoryprovider: def __init__(self, plugin, repository_url_provider): self.plugin = plugin self.repository_url_provider = repository_url_provider def get_download_url(self, host): distribution_repository = self.plugin.variables['distribution']['repository'] ...
def get_version(): with open("tdmgr.py", "r") as tdmgr: version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", tdmgr.read(), re.M) return version_match.group(1) setup( name="map-proxy", version=get_version(), description="Translate non OSM map...
def get_version(): with open('tdmgr.py', 'r') as tdmgr: version_match = re.search('^__version__ = [\'\\"]([^\'\\"]*)[\'\\"]', tdmgr.read(), re.M) return version_match.group(1) setup(name='map-proxy', version=get_version(), description='Translate non OSM map tile server to OSM style', long_descriptio...
def transcribe(DNA): RNA = [] DNA = list(DNA) for i in DNA: if i == 'A': RNA.append(i) if i == 'C': RNA.append(i) if i == 'G': RNA.append(i) if i == 'T': RNA.append('U') RNA_string = ''.join(RNA) return RNA_strin...
def transcribe(DNA): rna = [] dna = list(DNA) for i in DNA: if i == 'A': RNA.append(i) if i == 'C': RNA.append(i) if i == 'G': RNA.append(i) if i == 'T': RNA.append('U') rna_string = ''.join(RNA) return RNA_string if __n...
# Linear algebra (numpy.linalg) # https://docs.scipy.org/doc/numpy/reference/routines.linalg.html unit = v / np.linalg.norm(v) z = np.cross(x, y) z = z / np.linalg.norm(z) # 0 # /S\ # 1---2 def triangle_area(p0, p1, p2): v1 = p1 - p0 v2 = p2 - p0 return np.linalg.norm(np.cross(v1, v2))
unit = v / np.linalg.norm(v) z = np.cross(x, y) z = z / np.linalg.norm(z) def triangle_area(p0, p1, p2): v1 = p1 - p0 v2 = p2 - p0 return np.linalg.norm(np.cross(v1, v2))
# David Markham 2019-02-24 # Solution to number 3 # Write a program that prints all numbers 1000 and 10,000, # That are divisible by 6 but not 12. # Here I set the range for the sum divisible by using the range function. # And the formula, if the range is divisible by 6 but not 12. for i in range (1000, 10000): # And...
for i in range(1000, 10000): i print(i) print('All the numbers divisible by 6 but not by 12 in the range 1000, 10000') print('Have a nice day!')
def get_primary_key(model): return model._meta.primary_key.name def parse_like_term(term): if term.startswith("^"): stmt = "%s%%" % term[1:] elif term.startswith("="): stmt = term[1:] else: stmt = "%%%s%%" % term return stmt def get_meta_fields(model): if hasattr(mod...
def get_primary_key(model): return model._meta.primary_key.name def parse_like_term(term): if term.startswith('^'): stmt = '%s%%' % term[1:] elif term.startswith('='): stmt = term[1:] else: stmt = '%%%s%%' % term return stmt def get_meta_fields(model): if hasattr(model....
BOT_PREFIX = "" TOKEN = "" APPLICATION_ID = "" OWNERS = [] #feel free to change to remove the brackets[] if only one owner BLACKLIST = [] STARTUP_COGS = [ "cogs.general", "cogs.jishaku", "cogs.help", "cogs.moderation", "cogs.owner", "cogs.errrorhandler", ]
bot_prefix = '' token = '' application_id = '' owners = [] blacklist = [] startup_cogs = ['cogs.general', 'cogs.jishaku', 'cogs.help', 'cogs.moderation', 'cogs.owner', 'cogs.errrorhandler']
description = 'CAMEA basic devices: motors, counters and such' pvmcu1 = 'SQ:CAMEA:mcu1:' pvmcu2 = 'SQ:CAMEA:mcu2:' pvmcu3 = 'SQ:CAMEA:mcu3:' pvmcu4 = 'SQ:CAMEA:mcu4:' devices = dict( s2t = device('nicos_ess.devices.epics.motor.EpicsMotor', epicstimeout = 3.0, description = 'Sample two theta', ...
description = 'CAMEA basic devices: motors, counters and such' pvmcu1 = 'SQ:CAMEA:mcu1:' pvmcu2 = 'SQ:CAMEA:mcu2:' pvmcu3 = 'SQ:CAMEA:mcu3:' pvmcu4 = 'SQ:CAMEA:mcu4:' devices = dict(s2t=device('nicos_ess.devices.epics.motor.EpicsMotor', epicstimeout=3.0, description='Sample two theta', motorpv=pvmcu1 + '2t', errormsgpv...
class LongitudeQueryResponse: def __init__(self, rows=None, fields=None, meta=None): self.rows = rows or [] self.fields = fields or {} self.meta = meta or {} self._from_cache = False @property def from_cache(self): return self._from_cache def mark_as_cached(self...
class Longitudequeryresponse: def __init__(self, rows=None, fields=None, meta=None): self.rows = rows or [] self.fields = fields or {} self.meta = meta or {} self._from_cache = False @property def from_cache(self): return self._from_cache def mark_as_cached(sel...
mylist = [1,2,3,4,5,6] a = mylist[::2] print(a) b = [i*i for i in mylist] print(mylist) print(b) list_org=["banana","cherry","apple"] list_cpy=list_org list_cpy.append("lemmon") list_cpy2 = list_org.copy() ## list_copy = list_org [:] list_cpy2.append ("grape") print(list_org) print(list_cpy) print(list_cpy2)
mylist = [1, 2, 3, 4, 5, 6] a = mylist[::2] print(a) b = [i * i for i in mylist] print(mylist) print(b) list_org = ['banana', 'cherry', 'apple'] list_cpy = list_org list_cpy.append('lemmon') list_cpy2 = list_org.copy() list_cpy2.append('grape') print(list_org) print(list_cpy) print(list_cpy2)
""" Template project and example that demonstrates how to use the pygame_cards framework. Files description: * mygame.py, settings.json - skeleton project with templates of elements necessary to create a game powered by pygame_cards framework and their description. Can be used as a template project, ...
""" Template project and example that demonstrates how to use the pygame_cards framework. Files description: * mygame.py, settings.json - skeleton project with templates of elements necessary to create a game powered by pygame_cards framework and their description. Can be used as a template project, ...
def greet(name): return f"Hey {name}!" def concatenate(word_one, word_two): return word_one + word_two def age_in_dog_years(age): result = age * 7 return result print(greet('Mattan')) print(greet('Chris')) print(concatenate('Mattan', 'Griffel')) print(age_in_dog_years(28)) print(concatenate(word_t...
def greet(name): return f'Hey {name}!' def concatenate(word_one, word_two): return word_one + word_two def age_in_dog_years(age): result = age * 7 return result print(greet('Mattan')) print(greet('Chris')) print(concatenate('Mattan', 'Griffel')) print(age_in_dog_years(28)) print(concatenate(word_two='...
#!/bin/python3 # Complete the repeatedString function below. def repeatedString(s, n): occurence_of_a_in_s = 0 for char in s: if char == 'a': occurence_of_a_in_s += 1 # Find how many times 's' can be completely repeated then multiple that by the occurence of a character # in 's' st...
def repeated_string(s, n): occurence_of_a_in_s = 0 for char in s: if char == 'a': occurence_of_a_in_s += 1 occurence_of_a_in_s *= int(n / len(s)) end_part = s[:n % len(s)] for char in end_part: if char == 'a': occurence_of_a_in_s += 1 return occurence_of_a...
# enumerate() example # enumerate() is used to loop through a list, and for each item in that list, to also give the index where that item can be found days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] # This is how we're used to looping -- for each item in this list, print this i...
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] for day in days: print(day) for (index, day) in enumerate(days): print('days[{0}] contains {1}'.format(index, day)) print('day contains {0}'.format(day)) for (index, day) in enumerate(days): print('{0} is day # {1}'.fo...
""" Title: 0030 - Substring with Concatenation of All Words Tags: Binary Search Time: O(logn) = O(1) Space: O(1) Source: https://leetcode.com/problems/divide-two-integers/ Difficulty: Medium """ # Issue with finding the duplicate class Solution: def findSubstring(self, s: str, words: List[str]) -> List[int]: ...
""" Title: 0030 - Substring with Concatenation of All Words Tags: Binary Search Time: O(logn) = O(1) Space: O(1) Source: https://leetcode.com/problems/divide-two-integers/ Difficulty: Medium """ class Solution: def find_substring(self, s: str, words: List[str]) -> List[int]: (word_len, arr_len) = (len(wor...
# return the path/sample name def output(path,sample): if len(path)<1: return sample else: if path[-1]=='/': return path+sample else: return path+'/'+sample # obtain the tn barcode for each passed file def exp_bc(file): bc_in=str(file).split('_')[-2] return bc_in
def output(path, sample): if len(path) < 1: return sample elif path[-1] == '/': return path + sample else: return path + '/' + sample def exp_bc(file): bc_in = str(file).split('_')[-2] return bc_in
class DataGridRowEditEndingEventArgs(EventArgs): """ Provides data for the System.Windows.Controls.DataGrid.RowEditEnding event. DataGridRowEditEndingEventArgs(row: DataGridRow,editAction: DataGridEditAction) """ @staticmethod def __new__(self,row,editAction): """ __new__(cls: type,row: DataGridRow,...
class Datagridroweditendingeventargs(EventArgs): """ Provides data for the System.Windows.Controls.DataGrid.RowEditEnding event. DataGridRowEditEndingEventArgs(row: DataGridRow,editAction: DataGridEditAction) """ @staticmethod def __new__(self, row, editAction): """ __new__(cls: type,row: Da...