content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# model initial conditions
x = -1
y = 0
z = 0.5
t = 0
# model constants
_alpha = 0.3
gamma = 0.01
# gradients
palette_relaxing_red = [color(180, 15, 48), color(255, 251, 213)]
palette_shahabi = [color(104, 250, 0), color(166, 1, 116)]
palette_flare = [color(245, 174, 25), color(241, 40, 16)]
palette_rose_colored_lens... | x = -1
y = 0
z = 0.5
t = 0
_alpha = 0.3
gamma = 0.01
palette_relaxing_red = [color(180, 15, 48), color(255, 251, 213)]
palette_shahabi = [color(104, 250, 0), color(166, 1, 116)]
palette_flare = [color(245, 174, 25), color(241, 40, 16)]
palette_rose_colored_lenses = [color(100, 112, 163), color(232, 203, 191)]
palette_m... |
def get_bid(exchange, symbol, n=1):
return 0
def get_bid(exchange, symbol, n=1):
return 0
| def get_bid(exchange, symbol, n=1):
return 0
def get_bid(exchange, symbol, n=1):
return 0 |
def build_tuple_type(*columns):
class Tuple(object):
__slots__ = columns
def __init__(self, d=None, **kw):
if d is None:
d = kw
for k in self.__slots__:
setattr(self, k, d.get(k))
def __getitem__(self, k):
if k in s... | def build_tuple_type(*columns):
class Tuple(object):
__slots__ = columns
def __init__(self, d=None, **kw):
if d is None:
d = kw
for k in self.__slots__:
setattr(self, k, d.get(k))
def __getitem__(self, k):
if k in self.__... |
# ------------------------------------------------------------------------------
# Site Configuration File
# ------------------------------------------------------------------------------
theme = "carbon"
title = "Holly Demo"
tagline = "A blog-engine plugin for Ivy."
extensions = ["holly"]
holly = {
"homepage": ... | theme = 'carbon'
title = 'Holly Demo'
tagline = 'A blog-engine plugin for Ivy.'
extensions = ['holly']
holly = {'homepage': {'root_urls': ['@root/blog//', '@root/animalia//']}, 'roots': [{'root_url': '@root/blog//'}, {'root_url': '@root/animalia//'}]} |
def Prime_number(n):
a = []
for i in range(2,n+1):
e1 = n % i
if e1 == 0:
b.append(e1)
if len(a) > 1:
print('FALSE')
print('This is not a prime number!')
elif len(a) == 1:
print('TRUE')
print('This is a Prime number!')
Prime_number(int(input('Please give your number: '))) | def prime_number(n):
a = []
for i in range(2, n + 1):
e1 = n % i
if e1 == 0:
b.append(e1)
if len(a) > 1:
print('FALSE')
print('This is not a prime number!')
elif len(a) == 1:
print('TRUE')
print('This is a Prime number!')
prime_number(int(input... |
class Platform:
def __init__(self, designer, debug):
self.designer = designer
self.debug = debug
def generate_wrappers(self):
raise Exception("Method not implemented")
def create_mem(self, mem_type, name, data_type, size, init):
raise Exception("Method not implemented")
... | class Platform:
def __init__(self, designer, debug):
self.designer = designer
self.debug = debug
def generate_wrappers(self):
raise exception('Method not implemented')
def create_mem(self, mem_type, name, data_type, size, init):
raise exception('Method not implemented')
... |
# Here I've implemented a method of finding square root of imperfect square
# Steps (Pseudocode): visit http://burningmath.blogspot.in/2013/12/finding-square-roots-of-numbers-that.html
# Read the steps carefully or you'll not understand the program!
# To check is number is a perfect square or not
def is_perfect_square... | def is_perfect_square(n):
if isinstance(n, float):
return (False, None)
for i in range(n + 1):
if i * i == n:
return (True, i)
return (False, None)
def average(*args):
hold = list(args)
return sum(hold) / len(hold)
def sqrt_of_imperfect_square(a, certainty=6):
is_sq... |
usuario = input("Informe o nome de usuario: ")
senha = input("Informe a senha: ")
while usuario == senha:
print("Usuario deve ser diferente da senha!\n")
senha = input("Informe uma nova senha: ")
else:
print("Dados confirmados") | usuario = input('Informe o nome de usuario: ')
senha = input('Informe a senha: ')
while usuario == senha:
print('Usuario deve ser diferente da senha!\n')
senha = input('Informe uma nova senha: ')
else:
print('Dados confirmados') |
# Dependency Inversion Principle (SOLID)
# https://www.geeksforgeeks.org/dependecy-inversion-principle-solid/
# SGVP391900 | 12:03 7Mar19
# Mootto - Any higher classes should always depend upon the abstraction of the class
# rather than the detail.
class Employee(object):
def Work():
pass
class Manager... | class Employee(object):
def work():
pass
class Manager:
def __init__(self):
self.employees = []
def add_employee(self, a):
self.employees.append(a)
class Developer(Employee):
def __init__(self):
print('developer added')
def work():
print('truning coffee... |
[b'z' if foldnuls and not word else
b'y' if foldspaces and word == 0x20202020 else
(chars2[word // 614125] +
chars2[word // 85 % 7225] +
chars[word % 85])
]
| [b'z' if foldnuls and (not word) else b'y' if foldspaces and word == 538976288 else chars2[word // 614125] + chars2[word // 85 % 7225] + chars[word % 85]] |
inputs = {"sentence": "a very well-made, funny and entertaining picture."}
archive = (
"https://storage.googleapis.com/allennlp-public-models/"
"basic_stanford_sentiment_treebank-2020.06.09.tar.gz"
)
predictor = Predictor.from_path(archive)
interpreter = SimpleGradient(predictor)
interpretation = interpreter.sa... | inputs = {'sentence': 'a very well-made, funny and entertaining picture.'}
archive = 'https://storage.googleapis.com/allennlp-public-models/basic_stanford_sentiment_treebank-2020.06.09.tar.gz'
predictor = Predictor.from_path(archive)
interpreter = simple_gradient(predictor)
interpretation = interpreter.saliency_interpr... |
# File: adldap_view.py
#
# Copyright (c) 2021-2022 Splunk 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 applic... | def get_ctx_result(result):
ctx_result = {}
param = result.get_param()
summary = result.get_summary()
data = result.get_data()
ctx_result['param'] = param
if data:
ctx_result['data'] = data[0]
if summary:
ctx_result['summary'] = summary
return ctx_result
def display_attr... |
while True:
try:
p = input()
d = 0
for i in range(len(p)):
if(p[i]=='('):
d += 1
elif(p[i]==')'):
d -= 1
if(d < 0):
break
if(d != 0):
print('incorrect')
else:
print('co... | while True:
try:
p = input()
d = 0
for i in range(len(p)):
if p[i] == '(':
d += 1
elif p[i] == ')':
d -= 1
if d < 0:
break
if d != 0:
print('incorrect')
else:
print('co... |
f = open('69_sample.txt')
# read 1st line
data = f.readline()
print (data)
# read second line
data = f.readline()
print (data)
f.close()
| f = open('69_sample.txt')
data = f.readline()
print(data)
data = f.readline()
print(data)
f.close() |
bot = {'owner': '',
'client_id': '',
'version': '',
'prefix': '|',
'pstart': 'python3 ./main.py',
'game': '',
'token': '',
'invite_url': '',
'update_name': '',
'release_details': './data/misc/releaseplaceholder.txt',
'checkin_details': './data/misc/c... | bot = {'owner': '', 'client_id': '', 'version': '', 'prefix': '|', 'pstart': 'python3 ./main.py', 'game': '', 'token': '', 'invite_url': '', 'update_name': '', 'release_details': './data/misc/releaseplaceholder.txt', 'checkin_details': './data/misc/checkin.txt', 'checkin_channel': '', 'update_details': './data/misc/upd... |
N = int(input())
for i in range(N):
line = input()
print("I am Toorg!") | n = int(input())
for i in range(N):
line = input()
print('I am Toorg!') |
def divide(n1, n2):#dessa forma levantamos o erro sem parar o cod
if n2 == 0:#se n2 for igual a zero
raise ValueError("n2 nao pode ser 0 ")
return n1 / n2
try:
print(divide(n1=2,n2=1))
except ValueError as error:
print('Voce esta tentando dividir por zero')
print('log:', error) | def divide(n1, n2):
if n2 == 0:
raise value_error('n2 nao pode ser 0 ')
return n1 / n2
try:
print(divide(n1=2, n2=1))
except ValueError as error:
print('Voce esta tentando dividir por zero')
print('log:', error) |
# 566. Reshape the Matrix
# Runtime: 109 ms, faster than 30.83% of Python3 online submissions for Reshape the Matrix.
# Memory Usage: 14.7 MB, less than 87.88% of Python3 online submissions for Reshape the Matrix.
class Solution:
# Using Queue
def matrixReshape(self, mat: list[list[int]], r: int, c: int) ->... | class Solution:
def matrix_reshape(self, mat: list[list[int]], r: int, c: int) -> list[list[int]]:
if len(mat) == 0 or r * c != len(mat) * len(mat[0]):
return mat
nums = []
for i in range(len(mat)):
for j in range(len(mat[0])):
nums.append(mat[i][j])
... |
def n_primos (x):
numero =2
quantidadeDePrimos=0
while numero<=x:
divisor = 2
divisores=0
while divisor<numero:
if numero%divisor==0:
divisores+=1
divisor+=1
if divisores==0:
quantidadeDePrimos+=1
numero+=1
return... | def n_primos(x):
numero = 2
quantidade_de_primos = 0
while numero <= x:
divisor = 2
divisores = 0
while divisor < numero:
if numero % divisor == 0:
divisores += 1
divisor += 1
if divisores == 0:
quantidade_de_primos += 1
... |
#Now let's make things a little more challenging.
#
#Last exercise, you wrote a function called word_count that
#counted the number of words in a string essentially by
#counting the spaces. However, if there were multiple spaces
#in a row, it would incorrectly add additional words. For
#example, it would have counted t... | def word_count(my_string):
word_count = 1
try:
string_len = len(my_string)
i = 0
while string_len > 0:
try:
if my_string[i] == ' ' and (not my_string[i + 1] == ' '):
word_count += 1
i += 1
string_len -= 1
... |
def sortByHeight(a):
trees = []
peoples = []
for i in range(len(a)):
if (a[i] != -1):
peoples.append(a[i])
else:
trees.append(i)
peoples = sorted(peoples)
for i in range(len(trees)):
peoples.insert(trees[i], -1)
return peoples | def sort_by_height(a):
trees = []
peoples = []
for i in range(len(a)):
if a[i] != -1:
peoples.append(a[i])
else:
trees.append(i)
peoples = sorted(peoples)
for i in range(len(trees)):
peoples.insert(trees[i], -1)
return peoples |
nome = str(input('qual o seu nome '))
print('Prazer em te conhecer {:-^20}! \n'.format(nome))
n = int(input(' Bem vindo a Tabuada, digite um numero para ver o resultado: '))
multiplicando = 0
cont = 0
while cont <= 10:
print(n * multiplicando)
multiplicando = multiplicando + 1
cont = cont + 1
| nome = str(input('qual o seu nome '))
print('Prazer em te conhecer {:-^20}! \n'.format(nome))
n = int(input(' Bem vindo a Tabuada, digite um numero para ver o resultado: '))
multiplicando = 0
cont = 0
while cont <= 10:
print(n * multiplicando)
multiplicando = multiplicando + 1
cont = cont + 1 |
__all__ = ["RefMixin"]
class RefMixin:
def __init__(self, loop, ref=True):
self.loop = loop
self.ref = ref
self._ref_increased = False
def _increase_ref(self):
if self.ref:
self._ref_increased = True
self.loop.increase_ref()
def _decrease_ref(self)... | __all__ = ['RefMixin']
class Refmixin:
def __init__(self, loop, ref=True):
self.loop = loop
self.ref = ref
self._ref_increased = False
def _increase_ref(self):
if self.ref:
self._ref_increased = True
self.loop.increase_ref()
def _decrease_ref(self)... |
#!/usr/bin/env python3
max_seat = 0
with open('input.txt') as infile:
for line in infile:
row = 0
col = 0
for c in line:
if c == 'B':
row = 2*row + 1
if c == 'F':
row *= 2
if c == 'R':
col = 2*col + 1
... | max_seat = 0
with open('input.txt') as infile:
for line in infile:
row = 0
col = 0
for c in line:
if c == 'B':
row = 2 * row + 1
if c == 'F':
row *= 2
if c == 'R':
col = 2 * col + 1
if c == 'L':
... |
class Solution:
def closedIsland(self, grid: List[List[int]]) -> int:
m = len(grid)
n = len(grid[0])
vis = [[0]*n for i in range(m)]
res = 0
def bfs(i,j):
vis[i][j] = 1
q = [(i,j)]
valid = 1
while len(q)> 0... | class Solution:
def closed_island(self, grid: List[List[int]]) -> int:
m = len(grid)
n = len(grid[0])
vis = [[0] * n for i in range(m)]
res = 0
def bfs(i, j):
vis[i][j] = 1
q = [(i, j)]
valid = 1
while len(q) > 0:
... |
UK = "curb accessorise accessorised accessorises accessorising acclimatisation acclimatise acclimatised acclimatises acclimatising accoutrements aeon aeons aerogramme aerogrammes aeroplane aeroplanes aesthete aesthetes aesthetic aesthetically aesthetics aetiology ageing aggrandisement agonise agonised agonises agonisin... | uk = 'curb accessorise accessorised accessorises accessorising acclimatisation acclimatise acclimatised acclimatises acclimatising accoutrements aeon aeons aerogramme aerogrammes aeroplane aeroplanes aesthete aesthetes aesthetic aesthetically aesthetics aetiology ageing aggrandisement agonise agonised agonises agonisin... |
s = [[int(i) for i in input().split(' ')] for j in range(3)]
n = [s[i][j] for i in range(3) for j in range(3)]
all_n = [[8,1,6,3,5,7,4,9,2],[6,1,8,7,5,3,2,9,4],[4,9,2,3,5,7,8,1,6],[2,9,4,7,5,3,6,1,8],[8,3,4,1,5,9,6,7,2],[4,3,8,9,5,1,2,7,6],[6,7,2,1,5,9,8,3,4],[2,7,6,9,5,1,4,3,8]]
allsum=[]
for l in all_n:
summ=... | s = [[int(i) for i in input().split(' ')] for j in range(3)]
n = [s[i][j] for i in range(3) for j in range(3)]
all_n = [[8, 1, 6, 3, 5, 7, 4, 9, 2], [6, 1, 8, 7, 5, 3, 2, 9, 4], [4, 9, 2, 3, 5, 7, 8, 1, 6], [2, 9, 4, 7, 5, 3, 6, 1, 8], [8, 3, 4, 1, 5, 9, 6, 7, 2], [4, 3, 8, 9, 5, 1, 2, 7, 6], [6, 7, 2, 1, 5, 9, 8, 3, 4... |
BUILTIN_ENGINES = {"spark": "feaflow.engine.spark.SparkEngine"}
BUILTIN_SOURCES = {
"query": "feaflow.source.query.QuerySource",
"pandas": "feaflow.source.pandas.PandasDataFrameSource",
}
BUILTIN_COMPUTES = {"sql": "feaflow.compute.sql.SqlCompute"}
BUILTIN_SINKS = {
"table": "feaflow.sink.table.TableSink... | builtin_engines = {'spark': 'feaflow.engine.spark.SparkEngine'}
builtin_sources = {'query': 'feaflow.source.query.QuerySource', 'pandas': 'feaflow.source.pandas.PandasDataFrameSource'}
builtin_computes = {'sql': 'feaflow.compute.sql.SqlCompute'}
builtin_sinks = {'table': 'feaflow.sink.table.TableSink', 'redis': 'feaflo... |
APP_ID = '390093838084850'
DOMAIN = 'https://ef1ac6ba.ngrok.io'
COMMENTS_CALLBACK = DOMAIN + \
'/webhook_handler/'
MESSENGER_CALLBACK = DOMAIN + \
'/webhook_handler/'
VERIFY_TOKEN = '19990402'
APP_SECRET = 'e3d24fecd0c82e3c558d9cca9c6edad7'
| app_id = '390093838084850'
domain = 'https://ef1ac6ba.ngrok.io'
comments_callback = DOMAIN + '/webhook_handler/'
messenger_callback = DOMAIN + '/webhook_handler/'
verify_token = '19990402'
app_secret = 'e3d24fecd0c82e3c558d9cca9c6edad7' |
bind = '0.0.0.0:5000'
workers = 1
backlog = 2048
worker_class = "sync"
debug = True
proc_name = 'gunicorn.proc'
pidfile = '/tmp/gunicorn.pid'
logfile = '/var/log/gunicorn/debug.log'
loglevel = 'error' | bind = '0.0.0.0:5000'
workers = 1
backlog = 2048
worker_class = 'sync'
debug = True
proc_name = 'gunicorn.proc'
pidfile = '/tmp/gunicorn.pid'
logfile = '/var/log/gunicorn/debug.log'
loglevel = 'error' |
def fizzbuzz(i):
''' int -> str
If i is divisible by 3, return "Fizz".
If i is divisible by 5, return "Buzz".
If i is divisible by 3 and 5, return "FizzBuzz".'''
if i % 3 == 0 and i % 5 == 0:
return ("FizzBuzz")
elif i % 3 == 0:
return ("Fizz")
elif i % 5 == 0:
retur... | def fizzbuzz(i):
""" int -> str
If i is divisible by 3, return "Fizz".
If i is divisible by 5, return "Buzz".
If i is divisible by 3 and 5, return "FizzBuzz"."""
if i % 3 == 0 and i % 5 == 0:
return 'FizzBuzz'
elif i % 3 == 0:
return 'Fizz'
elif i % 5 == 0:
return 'Bu... |
# Configuration file for the Sphinx documentation builder.
# -- Project information
project = 'ChemW'
copyright = '2022, Andrew Philip Freiburger'
author = 'Andrew Philip Freiburger'
release = '1'
version = '0.3.1' | project = 'ChemW'
copyright = '2022, Andrew Philip Freiburger'
author = 'Andrew Philip Freiburger'
release = '1'
version = '0.3.1' |
#URL: https://www.hackerrank.com/challenges/two-characters/problem
def alternate(l, s):
chars = list(set(s))
n = len(chars)
maxlen = 0
#print(chars)
for i in range(n):
for j in range(i+1,n):
ch1 = chars[i]
ch2 = chars[j]
tempans = ""
ansl = 0
... | def alternate(l, s):
chars = list(set(s))
n = len(chars)
maxlen = 0
for i in range(n):
for j in range(i + 1, n):
ch1 = chars[i]
ch2 = chars[j]
tempans = ''
ansl = 0
f = True
for ch in s:
if ch == ch1:
... |
def arithmetic_arranger(problems, answer=False):
# check to see if the list is too long
num_problems = len(problems)
answers_list = []
top_operand = []
operator = []
bottom_operand = []
# calculate answers, create a list of answers
# check to see if there are too many problems... | def arithmetic_arranger(problems, answer=False):
num_problems = len(problems)
answers_list = []
top_operand = []
operator = []
bottom_operand = []
if num_problems > 5:
return 'Error: Too many problems.'
for problem in problems:
problem_list = problem.split()
if len(pr... |
#
# PySNMP MIB module OUTBOUNDTELNET-PRIVATE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/OUTBOUNDTELNET-PRIVATE-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:35:45 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version ... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, single_value_constraint, constraints_intersection, value_size_constraint, constraints_union) ... |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: FBOutput
class PassMask(object):
_img = 1
_id = 2
_category = 4
_mask = 8
_depth = 16
_normals = 32
_flow = 64
| class Passmask(object):
_img = 1
_id = 2
_category = 4
_mask = 8
_depth = 16
_normals = 32
_flow = 64 |
class Config():
def __init__(self):
self.api_token = None
self.module_name = None
self.port = None
self.enable_2fa = None
self.creds = None
self.seen = set()
self.verbose = False
| class Config:
def __init__(self):
self.api_token = None
self.module_name = None
self.port = None
self.enable_2fa = None
self.creds = None
self.seen = set()
self.verbose = False |
board=[" "]*9
def draw_board(board):
print("|----|----|----|")
print("| | | |")
print("| "+board[0]+"| "+board[1]+" | "+board[2]+" |")
print("| | | |")
print("|----|----|----|")
print("| | | |")
print("| "+board[3]+"| "+board[4]+" | "+board[5]+" |")
pr... | board = [' '] * 9
def draw_board(board):
print('|----|----|----|')
print('| | | |')
print('| ' + board[0] + '| ' + board[1] + ' | ' + board[2] + ' |')
print('| | | |')
print('|----|----|----|')
print('| | | |')
print('| ' + board[3] + '| ' + board[4] + ' | ... |
__example_payload__ = "AND 1=1"
__type__ = "putting the payload in-between a comment with obfuscation in it"
def tamper(payload, **kwargs):
return "/*!00000{}*/".format(payload)
| __example_payload__ = 'AND 1=1'
__type__ = 'putting the payload in-between a comment with obfuscation in it'
def tamper(payload, **kwargs):
return '/*!00000{}*/'.format(payload) |
class Employee:
raise_amount = 1.04
employee_Amount = 0
def __init__(self, first, last, pay):
self.first = first
self.last = last
self.pay = pay
self.email = first + '.' + last + '@companyemail'
Employee.employee_Amount += 1
def fullname(self):
... | class Employee:
raise_amount = 1.04
employee__amount = 0
def __init__(self, first, last, pay):
self.first = first
self.last = last
self.pay = pay
self.email = first + '.' + last + '@companyemail'
Employee.employee_Amount += 1
def fullname(self):
return '... |
class Editor(object):
def __init__(self):
self.color = '0 143 192'
self.visgroupshown = 1
self.visgroupautoshown = 1
def __str__(self):
out_str = 'editor\n\t\t{\n'
out_str += f'\t\t\t\"color\" \"{self.color}\"\n'
out_str += f'\t\t\t\"visgroupshown\" \"{self.visgr... | class Editor(object):
def __init__(self):
self.color = '0 143 192'
self.visgroupshown = 1
self.visgroupautoshown = 1
def __str__(self):
out_str = 'editor\n\t\t{\n'
out_str += f'\t\t\t"color" "{self.color}"\n'
out_str += f'\t\t\t"visgroupshown" "{self.visgroupsho... |
class SharpSpringException(Exception):
pass
| class Sharpspringexception(Exception):
pass |
t = int(input())
for _ in range(t):
n = int(input())
s = input()
dic = {}
for i in s:
if i not in dic:
dic[i] = 1
else:
dic[i] += 1
is_yes = True
for key in dic:
if(dic[key] % 2 == 1):
is_yes = False
break
if(i... | t = int(input())
for _ in range(t):
n = int(input())
s = input()
dic = {}
for i in s:
if i not in dic:
dic[i] = 1
else:
dic[i] += 1
is_yes = True
for key in dic:
if dic[key] % 2 == 1:
is_yes = False
break
if is_yes:
... |
# Space: O(l)
# Time: O(m * n * l)
class Solution:
def exist(self, board, word) -> bool:
column_length = len(board)
row_length = len(board[0])
word_length = len(word)
def dfs(x, y, index):
if index >= word_length: return True
if (not 0 <= x < row_length) o... | class Solution:
def exist(self, board, word) -> bool:
column_length = len(board)
row_length = len(board[0])
word_length = len(word)
def dfs(x, y, index):
if index >= word_length:
return True
if not 0 <= x < row_length or not 0 <= y < column_l... |
class User:
def __init__(self, login, password):
self._login = login
self._password = password
@property
def login(self):
return self._login
@property
def password(self):
return self._password
class Operation:
def __init__(self, a, func, b):
self._a = ... | class User:
def __init__(self, login, password):
self._login = login
self._password = password
@property
def login(self):
return self._login
@property
def password(self):
return self._password
class Operation:
def __init__(self, a, func, b):
self._a =... |
internCache = {} # XXX: upper bound on size somehow
def intern(klass, vm, method, frame):
string = frame.get_local(0)
value = string._values['value']
if value in internCache:
return internCache[value]
internCache[value] = string
return string
| intern_cache = {}
def intern(klass, vm, method, frame):
string = frame.get_local(0)
value = string._values['value']
if value in internCache:
return internCache[value]
internCache[value] = string
return string |
for _ in range(int(input())):
s = input().split()
for i in range(2, len(s)):
print(s[i], end=' ')
print(s[0]+' '+s[1])
| for _ in range(int(input())):
s = input().split()
for i in range(2, len(s)):
print(s[i], end=' ')
print(s[0] + ' ' + s[1]) |
# https://stepik.org/lesson/5047/step/5?unit=1086
# Sample Input 1:
# 8
# 2
# 14
# Sample Output 1:
# 14
# 2
# 8
# Sample Input 2:
# 23
# 23
# 21
# Sample Output 2:
# 23
# 21
# 23
max, min, other = a, b, c = int(input()), int(input()), int(input())
if b > max: max, min = b, a
if c > max: max, min, other = c, a, b
if ... | (max, min, other) = (a, b, c) = (int(input()), int(input()), int(input()))
if b > max:
(max, min) = (b, a)
if c > max:
(max, min, other) = (c, a, b)
if min > other:
(min, other) = (other, min)
print(max, min, other, sep='\n') |
p=int(input("Enter the size of list : "))
l=p
x=[]
while(l):
x.append(input("Enter elements : "))
l=l-1
print(x)
while(True) :
option= int(input("Do you want to :\n1.Pop\n2Remove\n3.Exit\n4.Insert\n5.Append\n6.Search\n7.Sort\n8.Reverse\n9.DecSort ?\n"))
if(option == 1):
#POP
n=int(in... | p = int(input('Enter the size of list : '))
l = p
x = []
while l:
x.append(input('Enter elements : '))
l = l - 1
print(x)
while True:
option = int(input('Do you want to :\n1.Pop\n2Remove\n3.Exit\n4.Insert\n5.Append\n6.Search\n7.Sort\n8.Reverse\n9.DecSort ?\n'))
if option == 1:
n = int(input('Ent... |
'''
Python Code Snippets - stevepython.wordpress.com
149-Convert KMH to MPH
Source:
https://www.pythonforbeginners.com/code-snippets-source-code/
python-code-convert-kmh-to-mph/
'''
kmh = int(input("Enter km/h: "))
mph = 0.6214 * kmh
print ("Speed:", kmh, "KM/H = ", mph, "MPH")
| """
Python Code Snippets - stevepython.wordpress.com
149-Convert KMH to MPH
Source:
https://www.pythonforbeginners.com/code-snippets-source-code/
python-code-convert-kmh-to-mph/
"""
kmh = int(input('Enter km/h: '))
mph = 0.6214 * kmh
print('Speed:', kmh, 'KM/H = ', mph, 'MPH') |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
opticalIsomers = 2
energy = {
'CBS-QB3': GaussianLog('TS07.log'),
'CCSD(T)-F12/cc-pVTZ-F12': MolproLog('TS07_f12.out'),
#'CCSD(T)-F12/cc-pVTZ-F12': -382.96546696009017
}
frequencies = GaussianLog('TS07freq.log')
rotors = [HinderedRotor(scanLog=Sca... | optical_isomers = 2
energy = {'CBS-QB3': gaussian_log('TS07.log'), 'CCSD(T)-F12/cc-pVTZ-F12': molpro_log('TS07_f12.out')}
frequencies = gaussian_log('TS07freq.log')
rotors = [hindered_rotor(scanLog=scan_log('scan_0.log'), pivots=[2, 4], top=[4, 5, 6, 7], symmetry=3), hindered_rotor(scanLog=scan_log('scan_1.log'), pivot... |
def read_list(t): return [t(x) for x in input().split()]
def read_line(t): return t(input())
def read_lines(t, N): return [t(input()) for _ in range(N)]
for i in range(read_line(int)):
N = read_line(int)
print(min(read_list(int)) * (N-1))
| def read_list(t):
return [t(x) for x in input().split()]
def read_line(t):
return t(input())
def read_lines(t, N):
return [t(input()) for _ in range(N)]
for i in range(read_line(int)):
n = read_line(int)
print(min(read_list(int)) * (N - 1)) |
#assert True == True
def mean(num_list):
try:
mean = sum(num_list)/float(len(num_list))
if isinstance(mean, complex):
return NotImplemented
return mean
except ZeroDivisionError as detail:
msg = "\nCannot compute the mean value of an empty list."
raise ZeroDiv... | def mean(num_list):
try:
mean = sum(num_list) / float(len(num_list))
if isinstance(mean, complex):
return NotImplemented
return mean
except ZeroDivisionError as detail:
msg = '\nCannot compute the mean value of an empty list.'
raise zero_division_error(detail.... |
def solution(clothes):
style = dict()
for i in clothes:
if i[1] not in style:
style[i[1]]=1
else :
style[i[1]]+=1
print(style)
answer =1
for i in style.values():
answer*=(i+1)
return answer-1 | def solution(clothes):
style = dict()
for i in clothes:
if i[1] not in style:
style[i[1]] = 1
else:
style[i[1]] += 1
print(style)
answer = 1
for i in style.values():
answer *= i + 1
return answer - 1 |
# tunnels at level = 0
#https://www.openstreetmap.org/way/167952621
assert_has_feature(
18, 41903, 101298, "roads",
{"kind": "highway", "highway": "motorway", "id": 167952621,
"name": "Presidio Pkwy.", "is_tunnel": True, "sort_key": 331})
# http://www.openstreetmap.org/way/89912879
assert_has_feature(
... | assert_has_feature(18, 41903, 101298, 'roads', {'kind': 'highway', 'highway': 'motorway', 'id': 167952621, 'name': 'Presidio Pkwy.', 'is_tunnel': True, 'sort_key': 331})
assert_has_feature(16, 19829, 24234, 'roads', {'kind': 'major_road', 'highway': 'trunk', 'id': 89912879, 'name': 'Sullivan Square Underpass', 'is_tunn... |
'''
Kattis - rijeci
from fibo(0) = 0, fibo(1) = 1, output the x-1th and xth fibo numbers, x <= 45
Simply use a for loop.
Time: O(x), Space: O(1)
'''
x = int(input())
a = 1
b = 0
for i in range(x):
a, b = b, a+b
print(a, b) | """
Kattis - rijeci
from fibo(0) = 0, fibo(1) = 1, output the x-1th and xth fibo numbers, x <= 45
Simply use a for loop.
Time: O(x), Space: O(1)
"""
x = int(input())
a = 1
b = 0
for i in range(x):
(a, b) = (b, a + b)
print(a, b) |
# 1st solution
# O(1) time | O(1) space
class Solution:
def bitwiseComplement(self, n: int) -> int:
k = 1
while k < n:
k = (k << 1) | 1
return k - n | class Solution:
def bitwise_complement(self, n: int) -> int:
k = 1
while k < n:
k = k << 1 | 1
return k - n |
months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November',
'December']
for n in range(1, 12, 1):
n = int(input())
print(months[n - 1])
break | months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
for n in range(1, 12, 1):
n = int(input())
print(months[n - 1])
break |
# Utility class used for string processing
def HasText(line, values):
retval = False
found = 0
for data in values:
if data in line:
found += 1
if found == len(values):
retval = True
return retval
def TextAfter(line, values):
retval = ""
if HasText... | def has_text(line, values):
retval = False
found = 0
for data in values:
if data in line:
found += 1
if found == len(values):
retval = True
return retval
def text_after(line, values):
retval = ''
if has_text(line, values):
loc = 0
for data in valu... |
# razbi n, ki je 5000 mestno stevilo na 100 50 mestnih stevilk in najdi prvih 10 stevk vsote teh 100-tih stevil
sez = [37107287533902102798797998220837590246510135740250,46376937677490009712648124896970078050417018260538,74324986199524741059474233309513058123726617309629,91942213363574161572522430563301811072406154908... | sez = [37107287533902102798797998220837590246510135740250, 46376937677490009712648124896970078050417018260538, 74324986199524741059474233309513058123726617309629, 91942213363574161572522430563301811072406154908250, 23067588207539346171171980310421047513778063246676, 89261670696623633820136378418383684178734361726757, 2... |
async def run(plugin, ctx, channel):
plugin.db.configs.update(ctx.guild.id, "message_logging", True)
plugin.db.configs.update(ctx.guild.id, "message_log_channel", f"{channel.id}")
await ctx.send(plugin.t(ctx.guild, "enabled_module_channel", _emote="YES", module="Message Logging", channel=channel.mention)... | async def run(plugin, ctx, channel):
plugin.db.configs.update(ctx.guild.id, 'message_logging', True)
plugin.db.configs.update(ctx.guild.id, 'message_log_channel', f'{channel.id}')
await ctx.send(plugin.t(ctx.guild, 'enabled_module_channel', _emote='YES', module='Message Logging', channel=channel.mention)) |
### --- ### --- ### --- ###
#! While structure:
#` 1. The while statement starts with the while keyword, followed bu a test condition, and ends with a colon (:).
#` 2. The loop body contains the code that gets repeated at each step of the loop. Each line is indented four spaces.
#$ Example:
n = 10
while n < 20:
... | n = 10
while n < 20:
print(n)
n = n + 1
while n <= 10:
print(n) |
class EndpointSolver(object):
def __init__(self, env, charms):
self.env = env
self.charms = charms
# Relation endpoint match logic
def solve(self, ep_a, ep_b):
service_a, charm_a, endpoints_a = self._parse_endpoints(ep_a)
service_b, charm_b, endpoints_b = self._parse_endpo... | class Endpointsolver(object):
def __init__(self, env, charms):
self.env = env
self.charms = charms
def solve(self, ep_a, ep_b):
(service_a, charm_a, endpoints_a) = self._parse_endpoints(ep_a)
(service_b, charm_b, endpoints_b) = self._parse_endpoints(ep_b)
pairs = self._... |
# -*- encoding: utf-8 -*-
def _single_action_str(self):
return '/'.join(list(iter(self)))
def _multi_action_str(_):
cmd_actions = [
str(arg) for arg in [
RUN_OPT_NAME,
STOP_OPT_NAME,
ENABLE_OPTS_NAME,
ENABLE_OPTS_NAME,
]
]
return ', '.j... | def _single_action_str(self):
return '/'.join(list(iter(self)))
def _multi_action_str(_):
cmd_actions = [str(arg) for arg in [RUN_OPT_NAME, STOP_OPT_NAME, ENABLE_OPTS_NAME, ENABLE_OPTS_NAME]]
return ', '.join(cmd_actions)
frozenset_single_action_opts = type('frozenset_argv_action_opts', (frozenset,), {'__s... |
rosha = bet_log[-1]
bet_log = []
| rosha = bet_log[-1]
bet_log = [] |
#
# PySNMP MIB module CISCO-LWAPP-REAP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-LWAPP-REAP-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:49:14 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (defau... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_union, value_size_constraint, single_value_constraint, constraints_intersection) ... |
number = 15
while True:
number += 1
last_digit = str(number)[-1:]
if last_digit != '6':
continue
small = int(number / 10)
large = int('6' + str(small))
if large % number == 0:
print('--')
print(str(number) + ' || ' + str(small) + ' : ' + str(large))
print... | number = 15
while True:
number += 1
last_digit = str(number)[-1:]
if last_digit != '6':
continue
small = int(number / 10)
large = int('6' + str(small))
if large % number == 0:
print('--')
print(str(number) + ' || ' + str(small) + ' : ' + str(large))
print('Divisio... |
fake_users_db = {
"typo11": {
"username": "typo11",
"full_name": "Tammy Cacablanka",
"email": "tammy@localhost.com",
"disabled": False,
"hashed_password": "$2b$12$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW"
},
"typo12": {
"username": "typo12",
... | fake_users_db = {'typo11': {'username': 'typo11', 'full_name': 'Tammy Cacablanka', 'email': 'tammy@localhost.com', 'disabled': False, 'hashed_password': '$2b$12$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW'}, 'typo12': {'username': 'typo12', 'full_name': 'Sammy Cacablanka', 'email': 'master@localhost.com', 'di... |
# Aidan Conlon - 27 March 2019
# This is the solution to Problem 6
# Write a program that takes a user input string and outputs every second word.
UserInput = input("Please enter a string of text:") # Print to screen the comment and take a value entered by the user.
for i, word in enumerate(UserInput.split()): ... | user_input = input('Please enter a string of text:')
for (i, word) in enumerate(UserInput.split()):
if i % 2 == 0:
print('%s' % word, sep=' ', end=' ')
quit() |
# THIS IS STATIC
WEEKDAYS = {
0: "Monday",
1: "Tuesday",
2: "Wednesday",
3: "Thursday",
4: "Friday",
5: "Saturday",
6: "Sunday"
}
CLASS_MAP = {
1: "Art",
2: "Geography",
3: "Science"
}
ENTRIES = {
"Monday": {
1: {
"class_name": CLASS_MAP[1],
... | weekdays = {0: 'Monday', 1: 'Tuesday', 2: 'Wednesday', 3: 'Thursday', 4: 'Friday', 5: 'Saturday', 6: 'Sunday'}
class_map = {1: 'Art', 2: 'Geography', 3: 'Science'}
entries = {'Monday': {1: {'class_name': CLASS_MAP[1], 'meeting_time': [9, 10], 'meeting_link': 'zoommtg://port-ac-uk.zoom.us/join?action=join&confno=5453452... |
# -*- coding: utf-8 -*-
def test_search_all(slack_time):
assert slack_time.search.all
def test_search_files(slack_time):
assert slack_time.search.files
def test_search_messages(slack_time):
assert slack_time.search.messages
| def test_search_all(slack_time):
assert slack_time.search.all
def test_search_files(slack_time):
assert slack_time.search.files
def test_search_messages(slack_time):
assert slack_time.search.messages |
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Pre-caching steps used internally by the IDL compiler
#
# Design doc: http://www.chromium.org/developers/design-documents/idl-build
{
'includes': [
... | {'includes': ['scripts.gypi', '../bindings.gypi', '../templates/templates.gypi'], 'targets': [{'target_name': 'cached_lex_yacc_tables', 'type': 'none', 'actions': [{'action_name': 'cache_lex_yacc_tables', 'inputs': ['<@(idl_lexer_parser_files)'], 'outputs': ['<(bindings_scripts_output_dir)/lextab.py', '<(bindings_scrip... |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: enums
class DateGenerationRule(object):
Backward = 0
CDS = 1
Forward = 2
OldCDS = 3
ThirdWednesday = 4
Twentieth = 5
TwentiethIMM = 6
Zero = 7
| class Dategenerationrule(object):
backward = 0
cds = 1
forward = 2
old_cds = 3
third_wednesday = 4
twentieth = 5
twentieth_imm = 6
zero = 7 |
n=int(input("Enter a number:"))
print("The number is",n)
sum=0
while(n>0 or sum>9):
if(n==0):
n=sum
sum=0
sum=sum+n%10
n=n//10
print(f"sum of the digits is:", sum)
if(sum==1):
print("it is a magic number")
else:
print("It is not a magic number")
| n = int(input('Enter a number:'))
print('The number is', n)
sum = 0
while n > 0 or sum > 9:
if n == 0:
n = sum
sum = 0
sum = sum + n % 10
n = n // 10
print(f'sum of the digits is:', sum)
if sum == 1:
print('it is a magic number')
else:
print('It is not a magic number') |
# https://docs.python.org/3/library/exceptions.html
class person:
def __init__(self, age, name):
if type(age)!=int:
raise Exception("Invaild Age: {}".format(age))
if age<0:
raise Exception("Invaild Age: {}".format(age))
if type(name)!=str:
raise Exception... | class Person:
def __init__(self, age, name):
if type(age) != int:
raise exception('Invaild Age: {}'.format(age))
if age < 0:
raise exception('Invaild Age: {}'.format(age))
if type(name) != str:
raise exception('Name not string: {}'.format(name))
s... |
#Exercise!
#Display the image below to the right hand side where the 0 is going to be ' ',
# and the 1 is going to be '*'. This will reveal an image!
picture = [
[0,0,0,1,0,0,0],
[0,0,1,1,1,0,0],
[0,1,1,1,1,1,0],
[1,1,1,1,1,1,1],
[0,0,0,1,0,0,0],
[0,0,0,1,0,0,0]
]
#version 1
# for y_list in picture:
# ... | picture = [[0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0]]
fill = '*'
space = ' '
empty = ''
for row in picture:
for pixel in row:
if pixel:
print(fill, end=empty)
else:
print(space, end... |
f = open('rucsac.txt', 'r')
n = int(f.readline())
v = []
for i in range(n):
linie = f.readline().split()
v.append((i+1, int(linie[0]), int(linie[1])))
G = int(f.readline())
cmax = [[0 for i in range(G+1)] for j in range(n+1)]
for i in range(1, n+1):
for j in range(1, G+1):
if v[i-1][1] > j... | f = open('rucsac.txt', 'r')
n = int(f.readline())
v = []
for i in range(n):
linie = f.readline().split()
v.append((i + 1, int(linie[0]), int(linie[1])))
g = int(f.readline())
cmax = [[0 for i in range(G + 1)] for j in range(n + 1)]
for i in range(1, n + 1):
for j in range(1, G + 1):
if v[i - 1][1] >... |
for _ in range(int(input())):
a,b = map(str,input().split())
l1 = len(a)
l2 = len(b)
flag = True
k = ""
while l1>0 and l2>0:
if a[-1]<=b[-1]:
l1-=1
l2-=1
a1 = a[-1]
b1 = b[-1]
a = a[:-1]
b = b[:-1]
a1 = i... | for _ in range(int(input())):
(a, b) = map(str, input().split())
l1 = len(a)
l2 = len(b)
flag = True
k = ''
while l1 > 0 and l2 > 0:
if a[-1] <= b[-1]:
l1 -= 1
l2 -= 1
a1 = a[-1]
b1 = b[-1]
a = a[:-1]
b = b[:-1]
... |
BILL_TYPES = {
'hconres': 'House Concurrent Resolution',
'hjres': 'House Joint Resolution',
'hr': 'House Bill',
'hres': 'House Resolution',
'sconres': 'Senate Concurrent Resolution',
'sjres': 'Senate Joint Resolution',
's': 'Senate Bill',
'sres': 'Senate Resolution',
}
| bill_types = {'hconres': 'House Concurrent Resolution', 'hjres': 'House Joint Resolution', 'hr': 'House Bill', 'hres': 'House Resolution', 'sconres': 'Senate Concurrent Resolution', 'sjres': 'Senate Joint Resolution', 's': 'Senate Bill', 'sres': 'Senate Resolution'} |
def is_file_h5(item):
output = False
if type(item)==str:
if item.endswith('.h5') or item.endswith('.hdf5'):
output = True
return output
| def is_file_h5(item):
output = False
if type(item) == str:
if item.endswith('.h5') or item.endswith('.hdf5'):
output = True
return output |
class World:
def __init__(self):
self.children = []
def addChild(self, child):
child.world = self
self.children.append(child)
def getChildByName(self, name):
for child in self.children:
if child.name == name:
return name
return None
... | class World:
def __init__(self):
self.children = []
def add_child(self, child):
child.world = self
self.children.append(child)
def get_child_by_name(self, name):
for child in self.children:
if child.name == name:
return name
return None
... |
# Taken from https://engineering.semantics3.com/a-simplified-guide-to-grpc-in-python-6c4e25f0c506
def message_to_send(x):
if x=="hi":
return 'hello, how can i help you'
elif x=="good afternoon":
return "good afternoon, how you doing"
elif x== 'Do you think you can really help me?':
return 'Yes, O... | def message_to_send(x):
if x == 'hi':
return 'hello, how can i help you'
elif x == 'good afternoon':
return 'good afternoon, how you doing'
elif x == 'Do you think you can really help me?':
return 'Yes, Of Course I can!'
elif x == 'How can I contact You?':
return 'You can... |
# Python program to implement graph deletion operation | delete node | using dictionary
nodes = []
graph = {}
# delete a node undirected and unweighted
def delete_node(val):
if val not in graph:
print(val, "is not present in the graph")
else:
graph.pop(val) # pop the key with all valu... | nodes = []
graph = {}
def delete_node(val):
if val not in graph:
print(val, 'is not present in the graph')
else:
graph.pop(val)
for i in graph:
list1 = graph[i]
if val in list1:
return list1.remove(val)
def delete_node(val):
if val not in gra... |
with open('day14/input.txt') as f:
lines = f.readlines()
dic = {}
for line in lines:
a, b = line.strip().split(" -> ")
dic[a] = b
def grow(poly: str) -> str:
result = ""
for i in range(len(poly) - 1):
q = poly[i:i+2]
result += poly[i] +dic[q]
result += poly[-1]
return resul... | with open('day14/input.txt') as f:
lines = f.readlines()
dic = {}
for line in lines:
(a, b) = line.strip().split(' -> ')
dic[a] = b
def grow(poly: str) -> str:
result = ''
for i in range(len(poly) - 1):
q = poly[i:i + 2]
result += poly[i] + dic[q]
result += poly[-1]
return r... |
n, m = map(int, input().split())
notes = [list(map(int, input().split())) for _ in range(m)]
if m == 1:
d, h = notes[0]
print(max(h+(d-1), h+(n-d)))
exit(0)
d0, h0 = notes[0]
ans = h0+(d0-1)
for i in range(m-1):
d1, h1 = notes[i]
d2, h2 = notes[i+1]
if d2-d1 < abs(h1-h2):
ans = -1
... | (n, m) = map(int, input().split())
notes = [list(map(int, input().split())) for _ in range(m)]
if m == 1:
(d, h) = notes[0]
print(max(h + (d - 1), h + (n - d)))
exit(0)
(d0, h0) = notes[0]
ans = h0 + (d0 - 1)
for i in range(m - 1):
(d1, h1) = notes[i]
(d2, h2) = notes[i + 1]
if d2 - d1 < abs(h1 ... |
t = int(input())
outs = []
for _ in range(t):
n = input()
a = list(map(int, input().split()))
if a[0] != a[1]:
correct = a[2]
else:
correct = a[0]
for i in range(len(a)):
if a[i] != correct:
outs.append(i+1)
break
for out in outs:
print(out) | t = int(input())
outs = []
for _ in range(t):
n = input()
a = list(map(int, input().split()))
if a[0] != a[1]:
correct = a[2]
else:
correct = a[0]
for i in range(len(a)):
if a[i] != correct:
outs.append(i + 1)
break
for out in outs:
print(out) |
d={
"Aligarh":"It is the city in UP ",
"bharatpur":"it is the city in Rajasthan",
"delhi ":"it is the capital of India",
"Mumbai":"it is the city in Maharashtra"
}
print("enter the name which you want to search ")
n1=input()
print(d[n1])
| d = {'Aligarh': 'It is the city in UP ', 'bharatpur': 'it is the city in Rajasthan', 'delhi ': 'it is the capital of India', 'Mumbai': 'it is the city in Maharashtra'}
print('enter the name which you want to search ')
n1 = input()
print(d[n1]) |
class Persona:
def __init__(self,nombre,apellidoPaterno,apellidoMaterno,sexo,edad,domicilio,telefono):
self.nombre = nombre
self.apellidoPaterno = apellidoPaterno
self.apellidoMaterno = apellidoMaterno
self.sexo = sexo
self.edad = edad
self.domicilio = domicilio
... | class Persona:
def __init__(self, nombre, apellidoPaterno, apellidoMaterno, sexo, edad, domicilio, telefono):
self.nombre = nombre
self.apellidoPaterno = apellidoPaterno
self.apellidoMaterno = apellidoMaterno
self.sexo = sexo
self.edad = edad
self.domicilio = domicil... |
# 1. Write a Python class named Rectangle constructed by a length and width and a method which will
# compute the area of a rectangle.
class rectangle():
def __init__(self, width, length):
self.width = width
self.length = length
def area(self):
return self.width * self.length
a = int... | class Rectangle:
def __init__(self, width, length):
self.width = width
self.length = length
def area(self):
return self.width * self.length
a = int(input('Enter length of rectangle: '))
b = int(input('Enter width of rectangle: '))
obj = rectangle(a, b)
print('Area of rectangle:', obj.a... |
CONNECTION_TAB_DEFAULT_TITLE = "Untitled"
CONNECTION_STRING_SUPPORTED_DB_NAMES = ["SQLite"]
CONNECTION_STRING_PLACEHOLDER = "Enter..."
CONNECTION_STRING_DEFAULT = "demo.db"
QUERY_EDITOR_DEFAULT_TEXT = "SELECT name FROM sqlite_master WHERE type='table'"
QUERY_CONTROL_CONNECT_BUTTON_TEXT = "Connect"
QUERY_CONTROL_EXECUTE... | connection_tab_default_title = 'Untitled'
connection_string_supported_db_names = ['SQLite']
connection_string_placeholder = 'Enter...'
connection_string_default = 'demo.db'
query_editor_default_text = "SELECT name FROM sqlite_master WHERE type='table'"
query_control_connect_button_text = 'Connect'
query_control_execute... |
# -*- coding: utf-8 -*-
# Copyright 2015 Pietro Brunetti <pietro.brunetti@itb.cnr.it>
#
# 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
# Unle... | __authors__ = 'Pietro Brunetti'
__all__ = ['peptidome', 'raw', 'by_targets', 'ChangeTargetPeptides', 'DialogCommons', 'EPPI_dataEPPI', 'flatnotebook', 'html_generator', 'Join', 'ManageVars', 'pages', 'project', 'ReportProtein,ReportSequence', 'Resume', 'Search', 'SelPepts', 'Targets'] |
#!/usr/bin/python
# This script simply generates a table of the voltage to expect
# if I combine my photoresistors with some of my resitors from stock..
# As there is no strong sunlight at the moment here, I will have to
# postpone the real life testing..
voltage=5.
resistor=[59,180,220,453,750,1000,10000,20000]
me... | voltage = 5.0
resistor = [59, 180, 220, 453, 750, 1000, 10000, 20000]
measurement = [2000000, 1000000, 600000, 200000, 100000, 80000, 40000, 20000, 10000, 8000, 6000, 4000, 2000, 1000, 800, 600, 400, 200, 100, 80, 60, 40, 20, 8, 2]
def measure(r, p):
return round(voltage - voltage / (r + p) * r, 4)
print('')
print... |
# Calculates total acres based on square feet input
# Declare variables
sqftInOneAcre = 43560
# Prompt user for total square feet of parcel of land
totalSqft = float(input('\nEnter total square feet of parcel of land: '))
# Calculate and display total acres
totalAcres = totalSqft / sqftInOneAcre
print('Total acres: ... | sqft_in_one_acre = 43560
total_sqft = float(input('\nEnter total square feet of parcel of land: '))
total_acres = totalSqft / sqftInOneAcre
print('Total acres: ', format(totalAcres, ',.1f'), '\n') |
class ReportEntry:
def __init__(self):
self.medium = 'Book'
self.title = None
self.url = None
self.classification = None
self.length = None
self.start_date = None
self.stop_date = None
self.distribution_percent = None
| class Reportentry:
def __init__(self):
self.medium = 'Book'
self.title = None
self.url = None
self.classification = None
self.length = None
self.start_date = None
self.stop_date = None
self.distribution_percent = None |
def rank_cal(rank_list, target_index):
rank = 0.
target_score = rank_list[target_index]
for score in rank_list:
if score >= target_score:
rank += 1.
return rank
def reciprocal_rank(rank):
return 1./rank
def accuracy_at_k(rank, k):
if rank <= k:
return... | def rank_cal(rank_list, target_index):
rank = 0.0
target_score = rank_list[target_index]
for score in rank_list:
if score >= target_score:
rank += 1.0
return rank
def reciprocal_rank(rank):
return 1.0 / rank
def accuracy_at_k(rank, k):
if rank <= k:
return 1.0
e... |
pos = 0
for k in range(6):
if float(input()) > 2: pos += 1
print(pos, "valores positivos")
| pos = 0
for k in range(6):
if float(input()) > 2:
pos += 1
print(pos, 'valores positivos') |
class NumMatrix:
def __init__(self, matrix: List[List[int]]):
if not any(matrix):
return
m, n = len(matrix), len(matrix[0])
self.tree = [[0] * (n + 1) for _ in range(m + 1)]
self.R = m + 1
self.C = n + 1
for i in range(m):
for j in range(n):
... | class Nummatrix:
def __init__(self, matrix: List[List[int]]):
if not any(matrix):
return
(m, n) = (len(matrix), len(matrix[0]))
self.tree = [[0] * (n + 1) for _ in range(m + 1)]
self.R = m + 1
self.C = n + 1
for i in range(m):
for j in range(n... |
width = 800
height = 700
fps = 60
font_n = 'arial'
sheetload = "spritesheet_jumper.png"
mob_fq = 5000
player_acc = 0.5
player_friction = -0.12
player_gra = 0.8
player_jump = 21
platform_list = [(0,height-50),(width/2-50,height*3/4),
(235,height-350),(350,200),(175,100)]
white = (255,255,... | width = 800
height = 700
fps = 60
font_n = 'arial'
sheetload = 'spritesheet_jumper.png'
mob_fq = 5000
player_acc = 0.5
player_friction = -0.12
player_gra = 0.8
player_jump = 21
platform_list = [(0, height - 50), (width / 2 - 50, height * 3 / 4), (235, height - 350), (350, 200), (175, 100)]
white = (255, 255, 255)
black... |
n = int(input())
ans = 0
number = 0
for i in range(n):
a, b = map(int, input().split())
A = int(str(a)[::-1]) # reverse
B = int(str(b)[::-1]) # reverse
ans = A + B
number = int(str(ans)[::-1]) # reverse
print(number)
| n = int(input())
ans = 0
number = 0
for i in range(n):
(a, b) = map(int, input().split())
a = int(str(a)[::-1])
b = int(str(b)[::-1])
ans = A + B
number = int(str(ans)[::-1])
print(number) |
#***Library implementing the sorting algorithms***
def quick_sort(seq,less_than):
if len(seq) < 1:
return seq
else:
pivot=seq[0]
left = quick_sort([x for x in seq[1:] if less_than(x,pivot)],less_than)
right = quick_sort([x for x in seq[1:] if not less_than(x,pivot)],less_than)
return left + [pivot] + right... | def quick_sort(seq, less_than):
if len(seq) < 1:
return seq
else:
pivot = seq[0]
left = quick_sort([x for x in seq[1:] if less_than(x, pivot)], less_than)
right = quick_sort([x for x in seq[1:] if not less_than(x, pivot)], less_than)
return left + [pivot] + right |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.