content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
def isPalindrome(string): if len(string) <= 1: return True else: return string[0] == string[-1] and isPalindrome(string[1:-1]) userInput = input("Please enter a sequence to check if it is an palindrome: ") answer = isPalindrome(userInput) print("Is '" + userInput + "' an palindrome? " + str(a...
def is_palindrome(string): if len(string) <= 1: return True else: return string[0] == string[-1] and is_palindrome(string[1:-1]) user_input = input('Please enter a sequence to check if it is an palindrome: ') answer = is_palindrome(userInput) print("Is '" + userInput + "' an palindrome? " + str(...
N = int(input()) A = [int(n) for n in input().split()] Aset = set(A) m = (10**9+7) o = {} ans = [] for a in A: o.setdefault(a, 0) o[a] += 1 for i in range(len(Aset)-1): for j in range(i+1, len(Aset)): ans.append((A[i]^A[j])*o[A[i]]*o[A[j]]) print(sum(ans)/m)
n = int(input()) a = [int(n) for n in input().split()] aset = set(A) m = 10 ** 9 + 7 o = {} ans = [] for a in A: o.setdefault(a, 0) o[a] += 1 for i in range(len(Aset) - 1): for j in range(i + 1, len(Aset)): ans.append((A[i] ^ A[j]) * o[A[i]] * o[A[j]]) print(sum(ans) / m)
# DOWNLOADER_MIDDLEWARES = {} # DOWNLOADER_MIDDLEWARES.update({ # 'scrapy.downloadermiddlewares.httpcache.HttpCacheMiddleware': None, # 'scrapy_httpcache.downloadermiddlewares.httpcache.AsyncHttpCacheMiddleware': 900, # }) HTTPCACHE_STORAGE = 'scrapy_httpcache.extensions.httpcache_storage.MongoDBCacheStorage' ...
httpcache_storage = 'scrapy_httpcache.extensions.httpcache_storage.MongoDBCacheStorage' httpcache_mongodb_host = '127.0.0.1' httpcache_mongodb_port = 27017 httpcache_mongodb_username = None httpcache_mongodb_password = None httpcache_mongodb_auth_db = None httpcache_mongodb_db = 'cache_storage' httpcache_mongodb_coll =...
def flatten(aList): myList = [] for el in aList: if isinstance(el, list) or isinstance(el, tuple): myList.extend(flatten(el)) else: myList.append(el) return myList
def flatten(aList): my_list = [] for el in aList: if isinstance(el, list) or isinstance(el, tuple): myList.extend(flatten(el)) else: myList.append(el) return myList
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def zlib(): if "zlib" not in native.existing_rules(): http_archive( name = "zlib", build_file = "//third_party/zlib:zlib.BUILD", sha256 = "91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d...
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') def zlib(): if 'zlib' not in native.existing_rules(): http_archive(name='zlib', build_file='//third_party/zlib:zlib.BUILD', sha256='91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d9', strip_prefix='zlib-1.2.12', url='https:...
class Sampler(object): def __init__(self): self._params = None self._dim = None self._iteration = 0 def setParameters(self, params): self._params = params self._dim = params.getStochasticDim() def nextSamples(self, *args, **kws): raise NotImplementedError()...
class Sampler(object): def __init__(self): self._params = None self._dim = None self._iteration = 0 def set_parameters(self, params): self._params = params self._dim = params.getStochasticDim() def next_samples(self, *args, **kws): raise not_implemented_err...
# def calcula_investimento(inv, mes, tipo): # seleciona tipo de investimento # CDB if tipo == 'CDB': for i in range(1, mes + 1): inv = inv * 1.013 if i % 6 == 0: inv = inv * 1.012 # LCI elif tipo == 'LCI': inv = inv*1.016**(...
def calcula_investimento(inv, mes, tipo): if tipo == 'CDB': for i in range(1, mes + 1): inv = inv * 1.013 if i % 6 == 0: inv = inv * 1.012 elif tipo == 'LCI': inv = inv * 1.016 ** mes 'for i in range(1, mes + 1):\n inv = inv * 1.016' ...
#!/usr/bin/env python3 def collatz(x): if x <= 0: raise ValueError("Collatz has become 0") if (x % 2) == 0: return x/2 else: return 3*x+1 if __name__ == "__main__": number = 10 print("Ausgangszahl: ", number) iteration = 0 while True: number = collatz(numbe...
def collatz(x): if x <= 0: raise value_error('Collatz has become 0') if x % 2 == 0: return x / 2 else: return 3 * x + 1 if __name__ == '__main__': number = 10 print('Ausgangszahl: ', number) iteration = 0 while True: number = collatz(number) iteration ...
''' 256 definitions cause LOAD_NAME and LOAD_CONST to both require EXTENDED_ARGS. Generated with: `for i in range(0, 0xff, 0x10): print(*[f'x{j:02x}=0x{j:02x}' for j in range(i, i+0x10)], sep='; ')` ''' x00=0x00; x01=0x01; x02=0x02; x03=0x03; x04=0x04; x05=0x05; x06=0x06; x07=0x07; x08=0x08; x09=0x09; x0a=0x0a; x0b=0x...
""" 256 definitions cause LOAD_NAME and LOAD_CONST to both require EXTENDED_ARGS. Generated with: `for i in range(0, 0xff, 0x10): print(*[f'x{j:02x}=0x{j:02x}' for j in range(i, i+0x10)], sep='; ')` """ x00 = 0 x01 = 1 x02 = 2 x03 = 3 x04 = 4 x05 = 5 x06 = 6 x07 = 7 x08 = 8 x09 = 9 x0a = 10 x0b = 11 x0c = 12 x0d = 13 x...
# This function tells a user whether or not a number is prime def isPrime(number): # this will tell us if the number is prime, set to True automatically # We will set to False if the number is divisible by any number less than it number_is_prime = True # loop over all numbers less than the input numb...
def is_prime(number): number_is_prime = True for i in range(2, number): remainder = number % i if remainder == 0: number_is_prime = False return number_is_prime
class Solution: def longestCommonSubstring(self, a, b): matrix = [[0 for _ in range(len(b))] for _ in range((len(a)))] z = 0 ret = [] for i in range(len(a)): for j in range(len(b)): if a[i] == b[j]: if i == 0 or j == 0: ...
class Solution: def longest_common_substring(self, a, b): matrix = [[0 for _ in range(len(b))] for _ in range(len(a))] z = 0 ret = [] for i in range(len(a)): for j in range(len(b)): if a[i] == b[j]: if i == 0 or j == 0: ...
# Copyright (c) 2020 The Khronos Group 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 ...
def _split_counter_from_name(str): if len(str) > 0 and (not str[-1].isdigit()): return (str, None) i = len(str) while i > 0: if not str[i - 1].isdigit(): return (str[:i], int(str[i:])) i -= 1 return (None, int(str)) def generate_tensor_names_from_op_type(graph, keep_...
sigla = input('Digite uma das siglas: SP / RJ / MG: ') if sigla == 'RJ' or sigla == 'rj': print('Carioca') elif sigla == 'SP' or sigla == 'sp': print('Paulista') elif sigla == 'MG' or sigla == 'mg': print('Mineiro') else: print('Outro estado')
sigla = input('Digite uma das siglas: SP / RJ / MG: ') if sigla == 'RJ' or sigla == 'rj': print('Carioca') elif sigla == 'SP' or sigla == 'sp': print('Paulista') elif sigla == 'MG' or sigla == 'mg': print('Mineiro') else: print('Outro estado')
# Copyright (c) 2019 Ezybaas by Bhavik Shah. # CTO @ Susthitsoft Technologies Private Limited. # All rights reserved. # Please see the LICENSE.txt included as part of this package. # EZYBAAS RELEASE CONFIG EZYBAAS_RELEASE_NAME = 'EzyBaaS' EZYBAAS_RELEASE_AUTHOR = 'Bhavik Shah CTO @ SusthitSoft Technologies' EZYBAAS_RE...
ezybaas_release_name = 'EzyBaaS' ezybaas_release_author = 'Bhavik Shah CTO @ SusthitSoft Technologies' ezybaas_release_version = '0.1.4' ezybaas_release_date = '2019-07-20' ezybaas_release_notes = 'https://github.com/bhavik1st/ezybaas' ezybaas_release_standalone = True ezybaas_release_license = 'https://github.com/bhav...
#Oskar Svedlund #TEINF-20 #2021-09-20 #For i For loop for i in range(1,10): for j in range(1,10): print(i*j, end="\t") print()
for i in range(1, 10): for j in range(1, 10): print(i * j, end='\t') print()
#!/usr/bin/env python ''' Copyright (C) 2019, WAFW00F Developers. See the LICENSE file for copying permission. ''' NAME = 'StackPath (StackPath)' def is_waf(self): schemes = [ self.matchContent(r"This website is using a security service to protect itself"), self.matchContent(r'You performed an ac...
""" Copyright (C) 2019, WAFW00F Developers. See the LICENSE file for copying permission. """ name = 'StackPath (StackPath)' def is_waf(self): schemes = [self.matchContent('This website is using a security service to protect itself'), self.matchContent('You performed an action that triggered the service and blocked...
content = ''' <script> function createimagemodal(path,cap) { var html = '<div id="modalWindow1" class="modal" data-keyboard="false" data-backdrop="static">\ <span class="close1" onclick=deletemodal("modalWindow1") data-dismiss="modal">&times;</span>\ ...
content = '\n <script>\n function createimagemodal(path,cap) {\n var html = \'<div id="modalWindow1" class="modal" data-keyboard="false" data-backdrop="static"> <span class="close1" onclick=deletemodal("modalWindow1") data-dismiss="modal">&times;</span> ...
a = int(input('Digite o primeiro segmento ')) b = int(input('Digite o segundo segmento: ')) c = int(input('Digite o terceiro segmento ')) if (b - c) < a < (b + c) and (a - c) < b < (a + c) and (a - b) < c < (a + b): print('Formam um triangulo') else: print('Nao formam um triangulo')
a = int(input('Digite o primeiro segmento ')) b = int(input('Digite o segundo segmento: ')) c = int(input('Digite o terceiro segmento ')) if b - c < a < b + c and a - c < b < a + c and (a - b < c < a + b): print('Formam um triangulo') else: print('Nao formam um triangulo')
SECTION_OFFSET_START = 0x0 SECTION_ADDRESS_START = 0x48 SECTION_SIZE_START = 0x90 BSS_START = 0xD8 BSS_SIZE = 0xDC TEXT_SECTION_COUNT = 7 DATA_SECTION_COUNT = 11 SECTION_COUNT = TEXT_SECTION_COUNT + DATA_SECTION_COUNT PATCH_SECTION = 3 ORIGINAL_DOL_END = 0x804DEC00 def word(data, offset): retur...
section_offset_start = 0 section_address_start = 72 section_size_start = 144 bss_start = 216 bss_size = 220 text_section_count = 7 data_section_count = 11 section_count = TEXT_SECTION_COUNT + DATA_SECTION_COUNT patch_section = 3 original_dol_end = 2152590336 def word(data, offset): return sum((data[offset + i] << ...
class MetaSingleton(type): instance = {} def __init__(cls, name, bases, attrs, **kwargs): cls.__copy__ = lambda self: self cls.__deepcopy__ = lambda self, memo: self def __call__(cls, *args, **kwargs): key = cls.__qualname__ if key not in cls.instance: instance ...
class Metasingleton(type): instance = {} def __init__(cls, name, bases, attrs, **kwargs): cls.__copy__ = lambda self: self cls.__deepcopy__ = lambda self, memo: self def __call__(cls, *args, **kwargs): key = cls.__qualname__ if key not in cls.instance: instance ...
# # This file contains the Python code from Program 15.10 of # "Data Structures and Algorithms # with Object-Oriented Design Patterns in Python" # by Bruno R. Preiss. # # Copyright (c) 2003 by Bruno R. Preiss, P.Eng. All rights reserved. # # http://www.brpreiss.com/books/opus7/programs/pgm15_10.txt # class HeapSorter(...
class Heapsorter(Sorter): def __init__(self): super(HeapSorter, self).__init__() def percolate_down(self, i, length): while 2 * i <= length: j = 2 * i if j < length and self._array[j + 1] > self._array[j]: j = j + 1 if self._array[i] >= self....
''' @name -> insertTopStreams @param (dbConnection) -> db connection object @param (cursor) -> db cursor object @param (time) -> a list of 5 integers that means [year, month, day, hour, minute] @param (topStreams) -> list of 20 dictionary objects ''' def insertTopStreams(dbConnection, cursor, time, topStreams): # m...
""" @name -> insertTopStreams @param (dbConnection) -> db connection object @param (cursor) -> db cursor object @param (time) -> a list of 5 integers that means [year, month, day, hour, minute] @param (topStreams) -> list of 20 dictionary objects """ def insert_top_streams(dbConnection, cursor, time, topStreams): ...
class BinaryIndexedTree: def __init__(self, n): self.sums = [0] * (n + 1) def update(self, i, delta): while i < len(self.sums): self.sums[i] += delta # add low bit i += (i & -i) def prefix_sum(self, i): ret = 0 while i: ...
class Binaryindexedtree: def __init__(self, n): self.sums = [0] * (n + 1) def update(self, i, delta): while i < len(self.sums): self.sums[i] += delta i += i & -i def prefix_sum(self, i): ret = 0 while i: ret += self.sums[i] i...
#stack is a linear data structure that stores items in a Last-In/First-Out (LIFO) or First-In/Last-Out (FILO) manner. #In stack, a new element is added at one end and an element is removed from that end only. stack = [] # append() function to push # element in the stack stack.append('a') stack.append('b') stack.app...
stack = [] stack.append('a') stack.append('b') stack.append('c') stack.append('d') stack.append('e') print('Initial stack') print(stack) print('\nElements popped from stack:') print(stack.pop()) print(stack.pop()) print(stack.pop()) print('\nStack after elements are popped:') print(stack)
student = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] a = [1, 2, 6, 7, 13, 15, 11] b = [3, 4, 6, 8, 12, 13] c = [6, 7, 8, 9, 14, 15] t1 = [] t2 = [] t3 = [] t4 = [] for i in range(len(student)): if student[i] in a and student[i] in b: t1.append(student[i]) if student[i] in a and student[i] not...
student = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] a = [1, 2, 6, 7, 13, 15, 11] b = [3, 4, 6, 8, 12, 13] c = [6, 7, 8, 9, 14, 15] t1 = [] t2 = [] t3 = [] t4 = [] for i in range(len(student)): if student[i] in a and student[i] in b: t1.append(student[i]) if student[i] in a and student[i] not i...
async def setupAddSelfrole(plugin, ctx, name, role, roles): role_id = role.id name = name.lower() if role_id in [roles[x] for x in roles] or name in roles: return await ctx.send(plugin.t(ctx.guild, "already_selfrole", _emote="WARN")) if role.position >= ctx.guild.me.top_role.position: ...
async def setupAddSelfrole(plugin, ctx, name, role, roles): role_id = role.id name = name.lower() if role_id in [roles[x] for x in roles] or name in roles: return await ctx.send(plugin.t(ctx.guild, 'already_selfrole', _emote='WARN')) if role.position >= ctx.guild.me.top_role.position: re...
''' LANGUAGE: Python AUTHOR: Weiyi GITHUB: https://github.com/weiyi-m ''' print("Hello World!")
""" LANGUAGE: Python AUTHOR: Weiyi GITHUB: https://github.com/weiyi-m """ print('Hello World!')
hours = 40 pay_rate = 400 no_weeks = 4 monthly_pay = hours * pay_rate *no_weeks print(monthly_pay)
hours = 40 pay_rate = 400 no_weeks = 4 monthly_pay = hours * pay_rate * no_weeks print(monthly_pay)
def is_leap(year): leap = False # Write your logic here # thought process #if year%4==0: # return True #elif year%100==0: # return False #elif year%400==0: # return True # Optimized, Python 3 return ((year%4==0)and(year%100!=0)or(year%400==0))
def is_leap(year): leap = False return year % 4 == 0 and year % 100 != 0 or year % 400 == 0
''' 1. Write a Python program to find three numbers from an array such that the sum of three numbers equal to a given number Input : [1, 0, -1, 0, -2, 2], 0) Output : [[-2, -1, 1, 2], [-2, 0, 0, 2], [-1, 0, 0, 1]] 2. Write a Python program to compute and return the square root of a given 'integer'. Input : 16 Output :...
""" 1. Write a Python program to find three numbers from an array such that the sum of three numbers equal to a given number Input : [1, 0, -1, 0, -2, 2], 0) Output : [[-2, -1, 1, 2], [-2, 0, 0, 2], [-1, 0, 0, 1]] 2. Write a Python program to compute and return the square root of a given 'integer'. Input : 16 Output :...
def main(): for i in range(10): print(f"The square of {i} is {square(i)}") return def square(n): return n**2 if __name__ == '__main__': main()
def main(): for i in range(10): print(f'The square of {i} is {square(i)}') return def square(n): return n ** 2 if __name__ == '__main__': main()
''' Created on 11 aug. 2011 .. codeauthor:: wauping <w.auping (at) student (dot) tudelft (dot) nl> jhkwakkel <j.h.kwakkel (at) tudelft (dot) nl> To be able to debug the Vensim model, a few steps are needed: 1. The case that gave a bug, needs to be saved in a text file. The entire case ...
""" Created on 11 aug. 2011 .. codeauthor:: wauping <w.auping (at) student (dot) tudelft (dot) nl> jhkwakkel <j.h.kwakkel (at) tudelft (dot) nl> To be able to debug the Vensim model, a few steps are needed: 1. The case that gave a bug, needs to be saved in a text file. The entire case ...
game = { 'leds': ( # GPIO05 - Pin 29 5, # GPIO12 - Pin 32 12, # GPIO17 - Pin 11 17, # GPIO22 - Pin 15 22, # GPIO25 - Pin 22 25 ), 'switches': ( # GPIO06 - Pin 31 6, # GPIO13 - Pin 33 13, #...
game = {'leds': (5, 12, 17, 22, 25), 'switches': (6, 13, 19, 23, 24), 'countdown': 5, 'game_time': 60, 'score_increment': 1}
# Databricks notebook source # MAGIC %run ./_utility-methods $lesson="3.1" # COMMAND ---------- DA.cleanup() DA.init(create_db=False) install_dtavod_datasets(reinstall=False) print() copy_source_dataset(f"{DA.working_dir_prefix}/source/dtavod/flights/departuredelays.csv", f"{DA.paths.working_dir}/flights/departuredel...
DA.cleanup() DA.init(create_db=False) install_dtavod_datasets(reinstall=False) print() copy_source_dataset(f'{DA.working_dir_prefix}/source/dtavod/flights/departuredelays.csv', f'{DA.paths.working_dir}/flights/departuredelays.csv', 'csv', 'flights') DA.conclude_setup()
class CNConfig: interp_factor = 0.075 sigma = 0.2 lambda_= 0.01 output_sigma_factor=1./16 padding=1 cn_type = 'pyECO'
class Cnconfig: interp_factor = 0.075 sigma = 0.2 lambda_ = 0.01 output_sigma_factor = 1.0 / 16 padding = 1 cn_type = 'pyECO'
sortname = { 'bubblesort': f'Bubble Sort O(n\N{SUPERSCRIPT TWO})', 'insertionsort': f'Insertion Sort O(n\N{SUPERSCRIPT TWO})', 'selectionsort': f'Selection Sort O(n\N{SUPERSCRIPT TWO})', 'mergesort': 'Merge Sort O(n log n)', 'quicksort': 'Quick Sort O(n log n)', 'heapsort': 'Heap Sort O(n log n)' }
sortname = {'bubblesort': f'Bubble Sort O(n²)', 'insertionsort': f'Insertion Sort O(n²)', 'selectionsort': f'Selection Sort O(n²)', 'mergesort': 'Merge Sort O(n log n)', 'quicksort': 'Quick Sort O(n log n)', 'heapsort': 'Heap Sort O(n log n)'}
class Cons(): def __init__(self, data, nxt): self.data = data self.nxt = nxt Nil = None def new(*elems): if len(elems) == 0: return Nil else: return Cons(elems[0], new(*elems[1:])) def printls(xs): i = xs while i != Nil: print(i.data) i = i.nxt
class Cons: def __init__(self, data, nxt): self.data = data self.nxt = nxt nil = None def new(*elems): if len(elems) == 0: return Nil else: return cons(elems[0], new(*elems[1:])) def printls(xs): i = xs while i != Nil: print(i.data) i = i.nxt
names = ['John', 'Bob', 'Mosh', 'Sarah', 'Mary'] print(names[2]) print(names[-1]) print(names[2:]) # prints from third to end print(names[2:4]) # prints third to fourth, does not include last one names[0] = 'Jon' # Find largest number in list numbers = [1, 34, 34, 12312, 123, 23, 903, 341093, 34] max_numb...
names = ['John', 'Bob', 'Mosh', 'Sarah', 'Mary'] print(names[2]) print(names[-1]) print(names[2:]) print(names[2:4]) names[0] = 'Jon' numbers = [1, 34, 34, 12312, 123, 23, 903, 341093, 34] max_number = numbers[0] for item in numbers: if item > max_number: max_number = item print(f'The largest number is {max...
n = int(input("n: ")) a = int(input("a: ")) b = int(input("b: ")) c = int(input("c: ")) while (n <= 0 or n >= 100000) or (a <= 0 or a >= 100000) or (b <= 0 or b >= 100000) or (c <= 0 or c >= 100000): print("All numbers should be positive between 0 and 100 000!") n = int(input("n: ")) a = int(input("a: ")) ...
n = int(input('n: ')) a = int(input('a: ')) b = int(input('b: ')) c = int(input('c: ')) while (n <= 0 or n >= 100000) or (a <= 0 or a >= 100000) or (b <= 0 or b >= 100000) or (c <= 0 or c >= 100000): print('All numbers should be positive between 0 and 100 000!') n = int(input('n: ')) a = int(input('a: ')) ...
def write_empty_line(handle): handle.write('\n') def write_title(handle, title, marker = ''): if marker == '': line = '{0}\n'.format(title) else: line = '{0} {1}\n'.format(marker, title) handle.write(line) def write_notes(handle, task): def is_task_with_notes(task): re...
def write_empty_line(handle): handle.write('\n') def write_title(handle, title, marker=''): if marker == '': line = '{0}\n'.format(title) else: line = '{0} {1}\n'.format(marker, title) handle.write(line) def write_notes(handle, task): def is_task_with_notes(task): result =...
def goodSegement1(badList,l,r): sortedBadList = sorted(badList) current =sortedBadList[0] maxVal = 0 for i in range(len(sortedBadList)): current = sortedBadList[i] maxIndex = i+1 # first value if i == 0 and l<=current<=r: val = current - l prev...
def good_segement1(badList, l, r): sorted_bad_list = sorted(badList) current = sortedBadList[0] max_val = 0 for i in range(len(sortedBadList)): current = sortedBadList[i] max_index = i + 1 if i == 0 and l <= current <= r: val = current - l prev = l ...
l, r = map(int, input().split()) mod = 10 ** 9 + 7 def f(x): if x == 0: return 0 res = 1 cnt = 2 f = 1 b_s = 2 e_s = 4 b_f = 3 e_f = 9 x -= 1 while x > 0: if f: res += cnt * (b_s + e_s) // 2 b_s = e_s + 2 e_s = e_s + 2 * (4 * ...
(l, r) = map(int, input().split()) mod = 10 ** 9 + 7 def f(x): if x == 0: return 0 res = 1 cnt = 2 f = 1 b_s = 2 e_s = 4 b_f = 3 e_f = 9 x -= 1 while x > 0: if f: res += cnt * (b_s + e_s) // 2 b_s = e_s + 2 e_s = e_s + 2 * (4 *...
def sum_doubles(): numbers = open('1.txt').readline() numbers = numbers + numbers[0] total = 0 for i in range(len(numbers) - 1): a = int(numbers[i]) b = int(numbers[i+1]) if a == b: total += a return total # print(sum_doubles()) # 1341 def sum_halfway(numbers): ...
def sum_doubles(): numbers = open('1.txt').readline() numbers = numbers + numbers[0] total = 0 for i in range(len(numbers) - 1): a = int(numbers[i]) b = int(numbers[i + 1]) if a == b: total += a return total def sum_halfway(numbers): total = 0 delta = int...
def reader(): ...
def reader(): ...
def C(x=None, ls=('$', 'A', 'C', 'G', 'T')): x = "ATATATTAG" if not x else x x += "$" dictir = {i: sum([x.count(j) for j in ls[:ls.index(i)]]) for i in ls} return dictir def BWT(x, suffix): x = "ATATATTAG" if not x else x x += "$" return ''.join([x[i - 2] for i in suffix]) def suffix_ar...
def c(x=None, ls=('$', 'A', 'C', 'G', 'T')): x = 'ATATATTAG' if not x else x x += '$' dictir = {i: sum([x.count(j) for j in ls[:ls.index(i)]]) for i in ls} return dictir def bwt(x, suffix): x = 'ATATATTAG' if not x else x x += '$' return ''.join([x[i - 2] for i in suffix]) def suffix_arr(x...
CONTEXT = {'cell_line': 'Cell Line', 'cellline': 'Cell Line', 'cell_type': 'Cell Type', 'celltype': 'Cell Type', 'tissue': 'Tissue', 'interactome': 'Interactome' } HIDDEN_FOLDER = '.contnext' ZENODO_URL = 'https://zenodo.org/record/5831786/files/data.zip?download=1'
context = {'cell_line': 'Cell Line', 'cellline': 'Cell Line', 'cell_type': 'Cell Type', 'celltype': 'Cell Type', 'tissue': 'Tissue', 'interactome': 'Interactome'} hidden_folder = '.contnext' zenodo_url = 'https://zenodo.org/record/5831786/files/data.zip?download=1'
def diag_diff(matriza): first_diag = second_diag = 0 razmer = len(matriza) for i in range(razmer): first_diag += matriza[i][i] second_diag += matriza[i][razmer - i - 1] return first_diag - second_diag
def diag_diff(matriza): first_diag = second_diag = 0 razmer = len(matriza) for i in range(razmer): first_diag += matriza[i][i] second_diag += matriza[i][razmer - i - 1] return first_diag - second_diag
description = 'STRESS-SPEC setup with Eulerian cradle' group = 'basic' includes = [ 'standard', 'sampletable', ] sysconfig = dict( datasinks = ['caresssink'], ) devices = dict( chis = device('nicos.devices.generic.Axis', description = 'Simulated CHIS axis', motor = device('nicos.devi...
description = 'STRESS-SPEC setup with Eulerian cradle' group = 'basic' includes = ['standard', 'sampletable'] sysconfig = dict(datasinks=['caresssink']) devices = dict(chis=device('nicos.devices.generic.Axis', description='Simulated CHIS axis', motor=device('nicos.devices.generic.VirtualMotor', fmtstr='%.2f', unit='deg...
# Copyright (C) 2017 Ming-Shing Chen def gf2_mul( a , b ): return a&b # gf4 := gf2[x]/x^2+x+1 # 4 and , 3 xor def gf4_mul( a , b ): a0 = a&1 a1 = (a>>1)&1 b0 = b&1 b1 = (b>>1)&1 ab0 = a0&b0 ab1 = (a1&b0)^(a0&b1) ab2 = a1&b1 ab0 ^= ab2 ab1 ^= ab2 ab0 ^= (ab1<<1) return ab0 # gf16 := gf4[y]/y^...
def gf2_mul(a, b): return a & b def gf4_mul(a, b): a0 = a & 1 a1 = a >> 1 & 1 b0 = b & 1 b1 = b >> 1 & 1 ab0 = a0 & b0 ab1 = a1 & b0 ^ a0 & b1 ab2 = a1 & b1 ab0 ^= ab2 ab1 ^= ab2 ab0 ^= ab1 << 1 return ab0 def gf16_mul(a, b): a0 = a & 3 a1 = a >> 2 & 3 b0 = ...
#Dictionary and Class usage and examples #cleaning up the input values def sanitize(time_string): if '-' in time_string: splitter = '-' elif ':' in time_string: splitter = ':' else: return time_string (mins, secs) = time_string.split(splitter) return(mins + '.' + secs) ...
def sanitize(time_string): if '-' in time_string: splitter = '-' elif ':' in time_string: splitter = ':' else: return time_string (mins, secs) = time_string.split(splitter) return mins + '.' + secs def get_coach_data(filename): try: with open(filename) as f: ...
a1 = 1 a2 = 2 an = a1 + a2 sum_ = a2 print(a1, ',', a2, end=", ") for n in range(100): an = a1 + a2 if an > 4000000: print('\n=== DONE ===') break if an % 2 == 0: sum_ += an print(an, end=", ") a1 = a2 a2 = an print("Even term sum =", sum_)
a1 = 1 a2 = 2 an = a1 + a2 sum_ = a2 print(a1, ',', a2, end=', ') for n in range(100): an = a1 + a2 if an > 4000000: print('\n=== DONE ===') break if an % 2 == 0: sum_ += an print(an, end=', ') a1 = a2 a2 = an print('Even term sum =', sum_)
# Difficulty Level: Easy # Question: Filter the dictionary by removing all items with a value of greater # than 1. # d = {"a": 1, "b": 2, "c": 3} # Expected output: # {'a': 1} # Hint 1: Use dictionary comprehension. # Hint 2: Inside the dictionary comprehension access dictionary items with # d.items() if you are on...
d = {'a': 1, 'b': 2, 'c': 3} print({i: j for (i, j) in d.items() if j <= 1}) d = {'a': 1, 'b': 2, 'c': 3} d = dict(((key, value) for (key, value) in d.items() if value <= 1)) print(d)
def factorial(n): if n == 0: return 1 elif n == 1: return 1 else: return factorial(n-1) * n example = int(input()) print(factorial(example))
def factorial(n): if n == 0: return 1 elif n == 1: return 1 else: return factorial(n - 1) * n example = int(input()) print(factorial(example))
''' Created on Mar 9, 2019 @author: hzhang0418 '''
""" Created on Mar 9, 2019 @author: hzhang0418 """
r=open('all.protein.faa','r') w=open('context.processed.all.protein.faa','w') start = True mem = "" for line in r: if '>' in line and not start: list_char = list(mem.replace('\n','')) list_context = [] list_context_length_before = 1 list_context_length_after = 1 for i in range(len(list_char)): tmp="" ...
r = open('all.protein.faa', 'r') w = open('context.processed.all.protein.faa', 'w') start = True mem = '' for line in r: if '>' in line and (not start): list_char = list(mem.replace('\n', '')) list_context = [] list_context_length_before = 1 list_context_length_after = 1 for ...
number = int(input()) dots = ((3 * number) - 1) // 2 print('.' * dots + 'x' + '.' * dots) print('.' * (dots - 1) + '/' + 'x' + '\\' + '.' * (dots - 1)) print('.' * (dots - 1) + 'x' + '|' + 'x' + '.' * (dots - 1)) ex = number dots = ((3 * number) - ((ex * 2) + 1)) // 2 for i in range(1, (number // 2) + 2): print('...
number = int(input()) dots = (3 * number - 1) // 2 print('.' * dots + 'x' + '.' * dots) print('.' * (dots - 1) + '/' + 'x' + '\\' + '.' * (dots - 1)) print('.' * (dots - 1) + 'x' + '|' + 'x' + '.' * (dots - 1)) ex = number dots = (3 * number - (ex * 2 + 1)) // 2 for i in range(1, number // 2 + 2): print('.' * dots ...
# -*- coding: utf-8 -*- def main(): a, b = map(int, input().split()) pins = ['x' for _ in range(10)] p = list(map(int, input().split())) for pi in p: pins[pi - 1] = '.' if b > 0: q = list(map(int, input().split())) for qi in q: pins[qi - 1] = 'o' print(...
def main(): (a, b) = map(int, input().split()) pins = ['x' for _ in range(10)] p = list(map(int, input().split())) for pi in p: pins[pi - 1] = '.' if b > 0: q = list(map(int, input().split())) for qi in q: pins[qi - 1] = 'o' print(' '.join(map(str, pins[6:])))...
''' Macros Calculator MIT License Copyright (c) 2018 Casey Chad Salvador Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to...
""" Macros Calculator MIT License Copyright (c) 2018 Casey Chad Salvador Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy...
JETBRAINS_IDES = { 'androidstudio': 'Android Studio', 'appcode': 'AppCode', 'datagrip': 'DataGrip', 'goland': 'GoLand', 'intellij': 'IntelliJ IDEA', 'pycharm': 'PyCharm', 'rubymine': 'RubyMine', 'webstorm': 'WebStorm' } JETBRAINS_IDE_NAMES = list(JETBRAINS_IDES.values())
jetbrains_ides = {'androidstudio': 'Android Studio', 'appcode': 'AppCode', 'datagrip': 'DataGrip', 'goland': 'GoLand', 'intellij': 'IntelliJ IDEA', 'pycharm': 'PyCharm', 'rubymine': 'RubyMine', 'webstorm': 'WebStorm'} jetbrains_ide_names = list(JETBRAINS_IDES.values())
mystr="Python is a multipurpose and simply learning langauge" for i in mystr: print(i,end=" ") print() print(mystr.find("simply")) print(mystr[0:11]+ " programming")
mystr = 'Python is a multipurpose and simply learning langauge' for i in mystr: print(i, end=' ') print() print(mystr.find('simply')) print(mystr[0:11] + ' programming')
T1, T2 = map(int, input().split()) n = 1000001 sieve = [True] * n m = int(n ** 0.5) for i in range(2, m + 1): if sieve[i] == True: for j in range(i + i, n, i): sieve[j] = False for i in range(T1, T2 + 1): if i == 1: continue if sieve[i]: print(i)
(t1, t2) = map(int, input().split()) n = 1000001 sieve = [True] * n m = int(n ** 0.5) for i in range(2, m + 1): if sieve[i] == True: for j in range(i + i, n, i): sieve[j] = False for i in range(T1, T2 + 1): if i == 1: continue if sieve[i]: print(i)
# # Copyright 2012 Sonya Huang # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing...
use_table_margins = ['margins', 'rail_margin', 'truck_margin', 'water_margin', 'air_margin', 'pipe_margin', 'gaspipe_margin', 'wholesale_margin', 'retail_margin'] final_demand = 'f' value_added = 'v' intermediate_output = 'i' fd_sectors = {1972: {'pce': '910000', 'imports': '950000', 'exports': '940000'}, 1977: {'pce':...
config_object = { "org_id": "", "client_id": "", "tech_id": "", "pathToKey": "", "secret": "", "date_limit": 0, "token": "", "tokenEndpoint": "https://ims-na1.adobelogin.com/ims/exchange/jwt" } header = {"Accept": "application/json", "Content-Type": "application/json", ...
config_object = {'org_id': '', 'client_id': '', 'tech_id': '', 'pathToKey': '', 'secret': '', 'date_limit': 0, 'token': '', 'tokenEndpoint': 'https://ims-na1.adobelogin.com/ims/exchange/jwt'} header = {'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': 'Bearer ', 'x-api-key': ''} endpoin...
INITIAL_HPS = { 'image_classifier': [{ 'image_block_1/block_type': 'vanilla', 'image_block_1/normalize': True, 'image_block_1/augment': False, 'image_block_1_vanilla/kernel_size': 3, 'image_block_1_vanilla/num_blocks': 1, 'image_block_1_vanilla/separable': False, ...
initial_hps = {'image_classifier': [{'image_block_1/block_type': 'vanilla', 'image_block_1/normalize': True, 'image_block_1/augment': False, 'image_block_1_vanilla/kernel_size': 3, 'image_block_1_vanilla/num_blocks': 1, 'image_block_1_vanilla/separable': False, 'image_block_1_vanilla/dropout_rate': 0.25, 'image_block_1...
file = open('names.txt', 'w') file.write('amirreza\n') file.write('setayesh\n') file.write('artin\n') file.write('iliya\n') file.write('mohammadjavad\n') file.close()
file = open('names.txt', 'w') file.write('amirreza\n') file.write('setayesh\n') file.write('artin\n') file.write('iliya\n') file.write('mohammadjavad\n') file.close()
CAPACITY = 10 class Heap: def __init__(self): self.heap_size = 0 self.heap = [0]*CAPACITY def insert(self, item): # when heap is full if self.heap_size == CAPACITY: return self.heap[self.heap_size] = item self.heap_size += 1 ...
capacity = 10 class Heap: def __init__(self): self.heap_size = 0 self.heap = [0] * CAPACITY def insert(self, item): if self.heap_size == CAPACITY: return self.heap[self.heap_size] = item self.heap_size += 1 self.fix_heap(self.heap_size - 1) def...
src = Split(''' ota_service.c ota_util.c ota_update_manifest.c ota_version.c ''') component = aos_component('fota', src) dependencis = Split(''' framework/fota/platform framework/fota/download utility/digest_algorithm utility/cjson ''') for i in dependencis: component.add_comp_d...
src = split('\n ota_service.c\n ota_util.c\n ota_update_manifest.c\n ota_version.c\n') component = aos_component('fota', src) dependencis = split('\n framework/fota/platform\n framework/fota/download \n utility/digest_algorithm \n utility/cjson \n') for i in dependencis: component.add_comp_...
# Works only with a good seed # You need the Emperor's gloves to cast "Chain Lightning" hero.cast("chain-lightning", hero.findNearestEnemy())
hero.cast('chain-lightning', hero.findNearestEnemy())
def main(): rst = bf_cal() print(f"{rst[0]}^5 + {rst[1]}^5 + {rst[2]}^5 + {rst[3]}^5 = {rst[4]}^5") def bf_cal(): max_n = 250 pwr_pool = [n ** 5 for n in range(max_n)] y_pwr_pool = {n ** 5: n for n in range(max_n)} for x0 in range(1, max_n): print(f"processing {x0} in (0..250)") ...
def main(): rst = bf_cal() print(f'{rst[0]}^5 + {rst[1]}^5 + {rst[2]}^5 + {rst[3]}^5 = {rst[4]}^5') def bf_cal(): max_n = 250 pwr_pool = [n ** 5 for n in range(max_n)] y_pwr_pool = {n ** 5: n for n in range(max_n)} for x0 in range(1, max_n): print(f'processing {x0} in (0..250)') ...
sq_sum, sum = 0, 0 for i in range(1, 101): sq_sum = sq_sum + (i * i) sum = sum + i print((sum * sum) - sq_sum)
(sq_sum, sum) = (0, 0) for i in range(1, 101): sq_sum = sq_sum + i * i sum = sum + i print(sum * sum - sq_sum)
class NotFoundException(Exception): pass class BadRequestException(Exception): pass class JobExistsException(Exception): pass class NoSuchImportableDataset(Exception): pass
class Notfoundexception(Exception): pass class Badrequestexception(Exception): pass class Jobexistsexception(Exception): pass class Nosuchimportabledataset(Exception): pass
n = int(input('Enter A Number: ')) def findFactors(num): arr = [] for x in range(1, n + 1 ,1): if num % x == 0: arr.append(x) return arr if len(findFactors(n)) == 2: # Array will have 1 and the number itself print(f"{n} Is Prime.") else : print(f"{n} Is Composite")
n = int(input('Enter A Number: ')) def find_factors(num): arr = [] for x in range(1, n + 1, 1): if num % x == 0: arr.append(x) return arr if len(find_factors(n)) == 2: print(f'{n} Is Prime.') else: print(f'{n} Is Composite')
''' Created on 1.12.2016 @author: Darren ''' ''' Given a binary search tree and a node in it, find the in-order successor of that node in the BST. Note: If the given node has no in-order successor in the tree, return null. '''
""" Created on 1.12.2016 @author: Darren """ '\nGiven a binary search tree and a node in it, find the in-order successor of that node in the BST.\n\nNote: If the given node has no in-order successor in the tree, return null.\n'
def printCommands(): print("Congratulations! You're running Ryan's Task list program.") print("What would you like to do next?") print("1. List all tasks.") print("2. Add a task to the list.") print("3. Delete a task.") print("q. To quit the program") printCommands() aTaskListArray = ["bob", "...
def print_commands(): print("Congratulations! You're running Ryan's Task list program.") print('What would you like to do next?') print('1. List all tasks.') print('2. Add a task to the list.') print('3. Delete a task.') print('q. To quit the program') print_commands() a_task_list_array = ['bob'...
data = open("input.txt", "r") data = data.read().split(",") check = True index = 0 while check is True: section = data[index] firstNum = int(data[int(data[index + 1])]) secondNum = int(data[int(data[index + 2])]) if section == "1": total = firstNum + secondNum if section == "2": ...
data = open('input.txt', 'r') data = data.read().split(',') check = True index = 0 while check is True: section = data[index] first_num = int(data[int(data[index + 1])]) second_num = int(data[int(data[index + 2])]) if section == '1': total = firstNum + secondNum if section == '2': to...
mod = 10**9 + 7 n = int(input()) a = list(map(int, input().split())) answer = 0 sumation = sum(a) for i in range(n-1): sumation -= a[i] answer += a[i]*sumation answer %= mod print(answer)
mod = 10 ** 9 + 7 n = int(input()) a = list(map(int, input().split())) answer = 0 sumation = sum(a) for i in range(n - 1): sumation -= a[i] answer += a[i] * sumation answer %= mod print(answer)
{ "targets": [ { "target_name": "sharedMemory", "include_dirs": [ "<!(node -e \"require('napi-macros')\")" ], "sources": [ "./src/sharedMemory.cpp" ], "libraries": [], }, { "target_name": "messaging", "include_dirs": [ "<!(node -e \"require('na...
{'targets': [{'target_name': 'sharedMemory', 'include_dirs': ['<!(node -e "require(\'napi-macros\')")'], 'sources': ['./src/sharedMemory.cpp'], 'libraries': []}, {'target_name': 'messaging', 'include_dirs': ['<!(node -e "require(\'napi-macros\')")'], 'sources': ['./src/messaging.cpp'], 'libraries': []}]}
def protected(func): def wrapper(password): if password=='platzi': return func() else: print('Contrasena invalida') return wrapper @protected def protected_func(): print('To contrasena es correcta') if __name__ == "__main__": password=str(raw_input('Ingresa tu ...
def protected(func): def wrapper(password): if password == 'platzi': return func() else: print('Contrasena invalida') return wrapper @protected def protected_func(): print('To contrasena es correcta') if __name__ == '__main__': password = str(raw_input('Ingresa ...
s=input() if s[-1] in '24579': print('hon') elif s[-1] in '0168': print('pon') else: print('bon')
s = input() if s[-1] in '24579': print('hon') elif s[-1] in '0168': print('pon') else: print('bon')
# Text Type: str # Numeric Types: int, float, complex # Sequence Types: list, tuple, range # Mapping Type: dict # Set Types: set, frozenset # Boolean Type: bool # Binary Types: bytes, bytearray, memoryview x = float(1) # x will be 1.0 y = float(2.8) # y will be 2.8 z = float("3") # z will be 3.0 w = float("4.2...
x = float(1) y = float(2.8) z = float('3') w = float('4.2') print('--------------------------------------------------------') num = 6 print(num) print(str(num) + ' is my num') print('--------------------------------------------------------')
TRAIN_DATA_PATH = "data/processed/train_folds.csv" TEST_DATA_PATH = "data/processed/test.csv" MODEL_PATH = "models/" NUM_FOLDS = 5 SEED = 23 VERBOSE = 0 FEATURE_COLS = [ "Pclass", "Sex", "Age", "SibSp", "Parch", "Ticket", "Fare", "Cabin", "Embarked", "Title", "Surname", "...
train_data_path = 'data/processed/train_folds.csv' test_data_path = 'data/processed/test.csv' model_path = 'models/' num_folds = 5 seed = 23 verbose = 0 feature_cols = ['Pclass', 'Sex', 'Age', 'SibSp', 'Parch', 'Ticket', 'Fare', 'Cabin', 'Embarked', 'Title', 'Surname', 'Family_Size'] target_col = 'Survived'
def parse_ninja(): f = open('out/peerconnection_client.ninja', 'r') for line in f.readlines(): lines = line.split(" ") for l in lines: print(l) f.close() def create_list_of_libs(): f = open('out/client_libs.txt', 'r') for line in f.readlines(): segments = line.st...
def parse_ninja(): f = open('out/peerconnection_client.ninja', 'r') for line in f.readlines(): lines = line.split(' ') for l in lines: print(l) f.close() def create_list_of_libs(): f = open('out/client_libs.txt', 'r') for line in f.readlines(): segments = line.st...
#(n-1)%M = x - 1 #(n-1)%N = y - 1 gcd = lambda a,b: gcd(b,a%b) if b else a def finder(M,N,x,y): for i in range(N//gcd(M,N)): if (x-1+i*M)%N==y-1: return x+i*M return -1 for _ in range(int(input())): M,N,x,y = map(int,input().split()) print(finder(M,N,x,y))
gcd = lambda a, b: gcd(b, a % b) if b else a def finder(M, N, x, y): for i in range(N // gcd(M, N)): if (x - 1 + i * M) % N == y - 1: return x + i * M return -1 for _ in range(int(input())): (m, n, x, y) = map(int, input().split()) print(finder(M, N, x, y))
norm_cfg = dict(type='GN', num_groups=32, requires_grad=True) model = dict( type='PoseDetDetector', pretrained='pretrained/dla34-ba72cf86.pth', # pretrained='open-mmlab://msra/hrnetv2_w32', backbone=dict( type='DLA', return_levels=True, levels=[1, 1, 1, 2, 2, 1], channel...
norm_cfg = dict(type='GN', num_groups=32, requires_grad=True) model = dict(type='PoseDetDetector', pretrained='pretrained/dla34-ba72cf86.pth', backbone=dict(type='DLA', return_levels=True, levels=[1, 1, 1, 2, 2, 1], channels=[16, 32, 64, 128, 256, 512], ouput_indice=[3, 4, 5, 6]), neck=dict(type='FPN', in_channels=[64,...
# Exceptions class SequenceFieldException(Exception): pass
class Sequencefieldexception(Exception): pass
try: x = int(input("X: ")) except ValueError: print("That is not an int!") exit() try: y = int(input("Y: ")) except ValueError: print("That is not an int!") exit() print (x + y)
try: x = int(input('X: ')) except ValueError: print('That is not an int!') exit() try: y = int(input('Y: ')) except ValueError: print('That is not an int!') exit() print(x + y)
# Design Linked List class ListNode: def __init__(self, x): self.value = x self.next = None class LinkedList: def __init__(self): self.size = 0 self.head = ListNode(0) # Sentinel Node as psuedo-head # add at head def addAtHead(self, val): self.addAtHead(0, val...
class Listnode: def __init__(self, x): self.value = x self.next = None class Linkedlist: def __init__(self): self.size = 0 self.head = list_node(0) def add_at_head(self, val): self.addAtHead(0, val) def add_at_tail(self, val): self.addAtTail(self.size...
# -*- coding:utf-8 -*- pizza = { 'crust': 'thick', 'toppings': ['mushrooms', 'extra cheese'], }
pizza = {'crust': 'thick', 'toppings': ['mushrooms', 'extra cheese']}
# You may remember by now that while loops use the condition to check when # to exit. The body of the while loop needs to make sure that the condition begin # checked will change. If it doesn't change, the loop may never finish and we get # what's called an infinite loop, a loop that keeps executing and never stops. # ...
def print_range(start, end): n = start while n <= end: print(n) n += 1 print_range(1, 5)
DOMAIN = "audiconnect" CONF_VIN = "vin" CONF_CARNAME = "carname" CONF_ACTION = "action" MIN_UPDATE_INTERVAL = 5 DEFAULT_UPDATE_INTERVAL = 10 CONF_SPIN = "spin" CONF_REGION = "region" CONF_SERVICE_URL = "service_url" CONF_MUTABLE = "mutable" SIGNAL_STATE_UPDATED = "{}.updated".format(DOMAIN) TRACKER_UPDATE = f"{DOMA...
domain = 'audiconnect' conf_vin = 'vin' conf_carname = 'carname' conf_action = 'action' min_update_interval = 5 default_update_interval = 10 conf_spin = 'spin' conf_region = 'region' conf_service_url = 'service_url' conf_mutable = 'mutable' signal_state_updated = '{}.updated'.format(DOMAIN) tracker_update = f'{DOMAIN}_...
class Mouse: __slots__=( '_system_cursor', 'has_mouse' ) def __init__(self): self._system_cursor = ez.window.panda_winprops.get_cursor_filename() self.has_mouse = ez.panda_showbase.mouseWatcherNode.has_mouse def hide(self): ez.window.panda_winprops.set_curso...
class Mouse: __slots__ = ('_system_cursor', 'has_mouse') def __init__(self): self._system_cursor = ez.window.panda_winprops.get_cursor_filename() self.has_mouse = ez.panda_showbase.mouseWatcherNode.has_mouse def hide(self): ez.window.panda_winprops.set_cursor_hidden(True) e...
n = int(input()) s = set(map(int, input().split())) for i in range(int(input())): f = input().split() if (f[0] == "pop"): s.pop() elif (f[0] == "remove"): s.remove(int(f[-1])) else: s.discard(int(f[-1])) print(sum(s))
n = int(input()) s = set(map(int, input().split())) for i in range(int(input())): f = input().split() if f[0] == 'pop': s.pop() elif f[0] == 'remove': s.remove(int(f[-1])) else: s.discard(int(f[-1])) print(sum(s))
# ------------------------------------------------------------------------------------ # Tutorial: Learn how to use Dictionaries in Python # ------------------------------------------------------------------------------------ # Dictionaries are a collection of key-value pairs. # Keys can only appear once in a dictiona...
my_dict = {'my_key': 'my value', 'your_key': 42, 5: 10, 'speed': 20.0} my_dict['their_key'] = 3.142 retrieved = my_dict['my_key'] print("Value of 'my_key': " + str(retrieved)) retrieved = my_dict.get('your_key') print("Value of 'your_key': " + str(retrieved)) retrieved = my_dict.get('non_existent_key', 'Not here.') pri...
def setup(): noLoop() size(500, 500) noStroke() smooth() def draw(): background(50) fill(94, 206, 40, 100) ellipse(250, 100, 160, 160) fill(94, 206, 40, 150) ellipse(250, 200, 160, 160) fill(94, 206, 40, 200) ellipse(250, 300, 160, 160) fill(94, 206, 4...
def setup(): no_loop() size(500, 500) no_stroke() smooth() def draw(): background(50) fill(94, 206, 40, 100) ellipse(250, 100, 160, 160) fill(94, 206, 40, 150) ellipse(250, 200, 160, 160) fill(94, 206, 40, 200) ellipse(250, 300, 160, 160) fill(94, 206, 40, 250) ellip...
def test_get_condition_new(): scraper = Scraper('Apple', 3000, 'new') result = scraper.condition_code assert result == 1000 def test_get_condition_used(): scraper = Scraper('Apple', 3000, 'used') result = scraper.condition_code assert result == 3000 def test_get_condition_error(): scraper = Scraper('A...
def test_get_condition_new(): scraper = scraper('Apple', 3000, 'new') result = scraper.condition_code assert result == 1000 def test_get_condition_used(): scraper = scraper('Apple', 3000, 'used') result = scraper.condition_code assert result == 3000 def test_get_condition_error(): scraper ...
def get_median( arr ): size = len(arr) mid_pos = size // 2 if size % 2 == 0: # size is even median = ( arr[mid_pos-1] + arr[mid_pos] ) / 2 else: # size is odd median = arr[mid_pos] return (median) def collect_Q1_Q2_Q3( arr ): # Preprocessing # in-pl...
def get_median(arr): size = len(arr) mid_pos = size // 2 if size % 2 == 0: median = (arr[mid_pos - 1] + arr[mid_pos]) / 2 else: median = arr[mid_pos] return median def collect_q1_q2_q3(arr): arr.sort() q2 = get_median(arr) size = len(arr) mid = size // 2 if size ...
def vowelCount(str): count = 0 for i in str: if i == "a" or i == "e" or i == "u" or i == "i" or i == "o": count += 1 print(count) exString = "Count the vowels in me!" vowelCount(exString)
def vowel_count(str): count = 0 for i in str: if i == 'a' or i == 'e' or i == 'u' or (i == 'i') or (i == 'o'): count += 1 print(count) ex_string = 'Count the vowels in me!' vowel_count(exString)
def test_add_two_params(): expected = 5 actual = add(2, 3) assert expected == actual def test_add_three_params(): expected = 9 actual = add(2, 3, 4) assert expected == actual def add(a, b, c=None): if c is None: return a + b else: return a + b + c
def test_add_two_params(): expected = 5 actual = add(2, 3) assert expected == actual def test_add_three_params(): expected = 9 actual = add(2, 3, 4) assert expected == actual def add(a, b, c=None): if c is None: return a + b else: return a + b + c
l = [58, 60, 67, 72, 76, 74, 79] s = '[' for ll in l: s += ' %i' % (ll + 9) s += ' ]' print(s)
l = [58, 60, 67, 72, 76, 74, 79] s = '[' for ll in l: s += ' %i' % (ll + 9) s += ' ]' print(s)
{ "variables": { "GTK_Root%": "c:\\gtk", "conditions": [ [ "OS == 'mac'", { "pkg_env": "PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig" }, { "pkg_env": "" }] ] }, "targets": [ { "target_name": "rsvg", "sources": [ "src/Rsvg.cc", "src/Enums.cc", "src/Autocrop.cc" ], "include_d...
{'variables': {'GTK_Root%': 'c:\\gtk', 'conditions': [["OS == 'mac'", {'pkg_env': 'PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig'}, {'pkg_env': ''}]]}, 'targets': [{'target_name': 'rsvg', 'sources': ['src/Rsvg.cc', 'src/Enums.cc', 'src/Autocrop.cc'], 'include_dirs': ['<!(node -e "require(\'nan\')")'], 'variables': {'packages'...