content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
number = input('Enter a number: ')
number = int(number)
if number % 2 == 0:
print('The number is even')
else:
print('The number is odd') | number = input('Enter a number: ')
number = int(number)
if number % 2 == 0:
print('The number is even')
else:
print('The number is odd') |
print("input 5 decimals")
values = []
for i in range(5):
values.append(float(input("demical #"+str(i+1)+": ")))
cnt = 0
for i in values:
if i >= 10 and i <= 100:
cnt += 1
print(cnt)
| print('input 5 decimals')
values = []
for i in range(5):
values.append(float(input('demical #' + str(i + 1) + ': ')))
cnt = 0
for i in values:
if i >= 10 and i <= 100:
cnt += 1
print(cnt) |
# 3. n children have got m pieces of candy. They want to eat as much candy as they can, but each child must eat exactly the same amount of candy as any other child. Determine how many pieces of candy will be eaten by all the children together. Individual pieces of candy cannot be split.
# Example
# For n = 3 and m = ... | def candies(n, m):
result = m - m % n
return result
print(candies(4, 25)) |
'''error pattern'''
class A:
def __init__(self, text):
print('a')
print(text)
class B(A):
def __init__(self, text):
print('b')
super(B, self).__init__(text)
class C:
def __init__(self, **kwargs):
print('c')
super(C, self).__init__()
class D(C, B):
def __init__(self, text):
pr... | """error pattern"""
class A:
def __init__(self, text):
print('a')
print(text)
class B(A):
def __init__(self, text):
print('b')
super(B, self).__init__(text)
class C:
def __init__(self, **kwargs):
print('c')
super(C, self).__init__()
class D(C, B):
... |
def test_restart_opencart_mysql_service(restart_mysql):
assert "active (running)" in restart_mysql
print(restart_mysql)
def test_restart_opencart_apache_service(restart_apache):
assert "active (running)" in restart_apache
print(restart_apache)
def test_opencart_is_active(request_opencart):
print... | def test_restart_opencart_mysql_service(restart_mysql):
assert 'active (running)' in restart_mysql
print(restart_mysql)
def test_restart_opencart_apache_service(restart_apache):
assert 'active (running)' in restart_apache
print(restart_apache)
def test_opencart_is_active(request_opencart):
print(r... |
def fatorial(n):
nFatorial=n
for i in range(1,n):
nFatorial=nFatorial*(n-i)
return nFatorial
| def fatorial(n):
n_fatorial = n
for i in range(1, n):
n_fatorial = nFatorial * (n - i)
return nFatorial |
class Solution:
def dayOfTheWeek(self, day: int, month: int, year: int) -> str:
num2day = ['Thursday', 'Friday', 'Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday']
mon2num = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
count = 0
for i in range(1971, year):
i... | class Solution:
def day_of_the_week(self, day: int, month: int, year: int) -> str:
num2day = ['Thursday', 'Friday', 'Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday']
mon2num = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
count = 0
for i in range(1971, year):
... |
def preenchimento_de_vetor_iv():
n = 0
par = list()
impar = list()
while n < 15:
numero = int(input())
if numero % 2 == 0:
par.append(numero)
else:
impar.append(numero)
if len(par) == 5:
for i in range(5):
print(f'par[{i... | def preenchimento_de_vetor_iv():
n = 0
par = list()
impar = list()
while n < 15:
numero = int(input())
if numero % 2 == 0:
par.append(numero)
else:
impar.append(numero)
if len(par) == 5:
for i in range(5):
print(f'par[{i... |
# -*- coding: utf-8 -*-
# @Time : 2018/4/12 20:16
# @Author : ddvv
# @Site : http://ddvv.life
# @File : __init__.py.py
# @Software: PyCharm
def main():
pass
if __name__ == "__main__":
main() | def main():
pass
if __name__ == '__main__':
main() |
n= int(input())
alfabeto = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in range(n):
letras=input()
pulos=int(input())
novaPalavra=""
for j in range(len(letras)):
posicao=alfabeto.find(letras[j])
numeroPosicao=posicao-pulos
if numeroPosicao<0:
novaPosicao=len(alfabeto)+numer... | n = int(input())
alfabeto = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(n):
letras = input()
pulos = int(input())
nova_palavra = ''
for j in range(len(letras)):
posicao = alfabeto.find(letras[j])
numero_posicao = posicao - pulos
if numeroPosicao < 0:
nova_posicao = le... |
sec = { # Security
1102: {"Descr": "The audit log was cleared",
"Provider": "Microsoft-Windows-Eventlog",
"SubjectUserSid": "SID",
"SubjectUserName": "Username",
"SubjectDomainName": "Domain",
"SubjectLogonId": "LogonId"},
4616: {"Descr": "The system time... | sec = {1102: {'Descr': 'The audit log was cleared', 'Provider': 'Microsoft-Windows-Eventlog', 'SubjectUserSid': 'SID', 'SubjectUserName': 'Username', 'SubjectDomainName': 'Domain', 'SubjectLogonId': 'LogonId'}, 4616: {'Descr': 'The system time was changed', 'Provider': 'Microsoft-Windows-Security-Auditing', 'SubjectUse... |
class Solution:
def arrayRankTransform(self, arr2: List[int]) -> List[int]:
d = {}
if len(arr2)==0: return []
ct = 1
arr = sorted(arr2)
d[arr[0]] = 1
for i in range(1,len(arr)):
if arr[i]>arr[i-1]:
ct+=1
d[arr[i]] = ct
r... | class Solution:
def array_rank_transform(self, arr2: List[int]) -> List[int]:
d = {}
if len(arr2) == 0:
return []
ct = 1
arr = sorted(arr2)
d[arr[0]] = 1
for i in range(1, len(arr)):
if arr[i] > arr[i - 1]:
ct += 1
... |
# Our server roles:
config.rdbms = ['127.0.0.1']
config.httpd = ['localhost']
def production():
# this would set `rdbms` and `httpd` to prod. values.
# for now we just switch them around in order to observe the effect
config.rdbms, config.httpd = config.httpd, config.rdbms
def build():
local('echo Bu... | config.rdbms = ['127.0.0.1']
config.httpd = ['localhost']
def production():
(config.rdbms, config.httpd) = (config.httpd, config.rdbms)
def build():
local('echo Building project')
@roles('rdbms')
def prepare_db():
run('echo Preparing database for deployment')
@roles('httpd')
def prepare_web():
run('... |
# --------------
##File path for the file
file_path
#Code starts here
#Function to read file
def read_file(path):
#Opening of the file located in the path in 'read' mode
file = open(path, 'r')
#Reading of the first line of the file and storing it in a variable
sentence=file.rea... | file_path
def read_file(path):
file = open(path, 'r')
sentence = file.readline()
file.close()
return sentence
sample_message = read_file(file_path)
print(sample_message)
(file_path_1, file_path_2)
def read_file1(file1):
file1 = open(file_path_1, 'r')
sentence1 = file1.readline()
file1.clos... |
def decompose(n):
return helper(n, n**2)
def helper(n, sum, arr=[]):
if sum==0:
return arr[::-1]
for i in range(n-1, -1, -1):
if i**2<=sum:
return helper(i, sum-i**2, arr+[i]) or helper(i, sum, arr) | def decompose(n):
return helper(n, n ** 2)
def helper(n, sum, arr=[]):
if sum == 0:
return arr[::-1]
for i in range(n - 1, -1, -1):
if i ** 2 <= sum:
return helper(i, sum - i ** 2, arr + [i]) or helper(i, sum, arr) |
class person:
def __init__(self, first_name, last_name):
self.first_name = first_name
self.last_name = last_name
def fullname(self):
return f"{self.first_name} {self.last_name}"
def email(self):
return f"{self.first_name}{self.last_name}@gmail.com"
| class Person:
def __init__(self, first_name, last_name):
self.first_name = first_name
self.last_name = last_name
def fullname(self):
return f'{self.first_name} {self.last_name}'
def email(self):
return f'{self.first_name}{self.last_name}@gmail.com' |
'''
Set Matrix Zeros
Asked in: Oracle, Amazon
https://www.interviewbit.com/problems/set-matrix-zeros/
Given a matrix, A of size M x N of 0s and 1s. If an element is 0, set its entire row and column to 0.
Note: This will be evaluated on the extra memory used. Try to minimize the space and time complexity.
Input Fo... | """
Set Matrix Zeros
Asked in: Oracle, Amazon
https://www.interviewbit.com/problems/set-matrix-zeros/
Given a matrix, A of size M x N of 0s and 1s. If an element is 0, set its entire row and column to 0.
Note: This will be evaluated on the extra memory used. Try to minimize the space and time complexity.
Input Fo... |
# -*- coding: utf-8 -*-
# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html
class MoviePipeline(object):
def process_item(self, item, spider):
with open('out/my_meiju.txt', 'a', encoding='U... | class Moviepipeline(object):
def process_item(self, item, spider):
with open('out/my_meiju.txt', 'a', encoding='UTF-8') as fp:
fp.write(str(item['name'].strip()) + '\n') |
number = int(input())
synonyms_dict = dict()
for num in range (number):
word = input()
synonym = input()
if word not in synonyms_dict.keys():
synonyms_dict[word] = list()
synonyms_dict[word].append(synonym)
for word in synonyms_dict:
synonyms = ", ".join(synonyms_dict[word])
print(f"{... | number = int(input())
synonyms_dict = dict()
for num in range(number):
word = input()
synonym = input()
if word not in synonyms_dict.keys():
synonyms_dict[word] = list()
synonyms_dict[word].append(synonym)
for word in synonyms_dict:
synonyms = ', '.join(synonyms_dict[word])
print(f'{word... |
class Person:
# allocate space for only these attributes so we don't need to create a __dict__ property in the class and we save space when parsing large files
__slots__ = ["lastName", "firstName", "middleInitial",
"gender", "favoriteColor", "dateOfBirth"]
def __init__(self, lastName, fir... | class Person:
__slots__ = ['lastName', 'firstName', 'middleInitial', 'gender', 'favoriteColor', 'dateOfBirth']
def __init__(self, lastName, firstName, middleInitial, gender, favoriteColor, dateOfBirth):
self.lastName = lastName
self.firstName = firstName
self.middleInitial = middleIniti... |
expected_output = {
'10.1.1.2': {
'conn_capability': 'IPv4-IPv6-Subnet',
'conn_inst': 1,
'conn_status': 'On (Speaker) :: On (Listener)',
'conn_version': 5,
'duration': '0:00:00:57 (dd:hr:mm:sec) :: 0:00:00:55 (dd:hr:mm:sec)',
'local_mode': 'Both',
'peer_ip': '... | expected_output = {'10.1.1.2': {'conn_capability': 'IPv4-IPv6-Subnet', 'conn_inst': 1, 'conn_status': 'On (Speaker) :: On (Listener)', 'conn_version': 5, 'duration': '0:00:00:57 (dd:hr:mm:sec) :: 0:00:00:55 (dd:hr:mm:sec)', 'local_mode': 'Both', 'peer_ip': '10.1.1.2', 'source_ip': '10.1.1.1', 'tcp_conn_fd': '1(Speaker)... |
class Stack:
def __init__(self):
self.list = []
def push(self, element):
self.list.append(element)
def pop(self):
assert len(self.list) > 0, "Stack is empty"
return self.list.pop()
def isEmpty(self):
return len(self.list) == 0
| class Stack:
def __init__(self):
self.list = []
def push(self, element):
self.list.append(element)
def pop(self):
assert len(self.list) > 0, 'Stack is empty'
return self.list.pop()
def is_empty(self):
return len(self.list) == 0 |
#!/usr/bin/python
# Calculer la somme des valeurs du tableau
def somme_tab(tab):
somme = 0
for i in range(len(tab)):
somme += tab[i]
return somme
tab = [5, 18.5, 13.2, 8.75, 2, 15, 13.5, 6, 17]
print(somme_tab(tab))
| def somme_tab(tab):
somme = 0
for i in range(len(tab)):
somme += tab[i]
return somme
tab = [5, 18.5, 13.2, 8.75, 2, 15, 13.5, 6, 17]
print(somme_tab(tab)) |
# Creating a Dictionary
# with Integer Keys
Dict = {1: 'Geeks', 2: 'For', 3: 'Geeks'}
print("\nDictionary with the use of Integer Keys: ")
print(Dict)
# Creating a Dictionary
# with Mixed keys
Dict = {'Name': 'Geeks', 1: [1, 2, 3, 4]}
print("\nDictionary with the use of Mixed Keys: ")
print(Dict)
# Creating an empty ... | dict = {1: 'Geeks', 2: 'For', 3: 'Geeks'}
print('\nDictionary with the use of Integer Keys: ')
print(Dict)
dict = {'Name': 'Geeks', 1: [1, 2, 3, 4]}
print('\nDictionary with the use of Mixed Keys: ')
print(Dict)
dict = {}
print('Empty Dictionary: ')
print(Dict)
dict = dict({1: 'Geeks', 2: 'For', 3: 'Geeks'})
print('\nD... |
def threeSum(nums):
s = set()
nums.sort()
for i in range(len(nums)):
m = {}
for j in range(i+1, len(nums)):
x = -nums[i] - nums[j]
if x not in m:
m[nums[j]] = j
else:
s.add((x,nums[i],nums[j]))
return list(s) | def three_sum(nums):
s = set()
nums.sort()
for i in range(len(nums)):
m = {}
for j in range(i + 1, len(nums)):
x = -nums[i] - nums[j]
if x not in m:
m[nums[j]] = j
else:
s.add((x, nums[i], nums[j]))
return list(s) |
array = [54, 26, 93, 17, 77, 31, 44, 55, 20]
def bubble_sort(nums: list):
for i in range(len(nums)):
for j in range(len(nums) - 1, i, -1):
if nums[j - 1] > nums[j]:
nums[j - 1], nums[j] = nums[j], nums[j - 1]
print(array)
bubble_sort(array)
print(array)
| array = [54, 26, 93, 17, 77, 31, 44, 55, 20]
def bubble_sort(nums: list):
for i in range(len(nums)):
for j in range(len(nums) - 1, i, -1):
if nums[j - 1] > nums[j]:
(nums[j - 1], nums[j]) = (nums[j], nums[j - 1])
print(array)
bubble_sort(array)
print(array) |
BLKNUM_OFFSET = 1000000000
TXINDEX_OFFSET = 10000
def decode_utxo_id(utxo_id):
blknum = utxo_id // BLKNUM_OFFSET
txindex = (utxo_id % BLKNUM_OFFSET) // TXINDEX_OFFSET
oindex = utxo_id % TXINDEX_OFFSET
return blknum, txindex, oindex
def encode_utxo_id(blknum, txindex, oindex):
return (blknum * BL... | blknum_offset = 1000000000
txindex_offset = 10000
def decode_utxo_id(utxo_id):
blknum = utxo_id // BLKNUM_OFFSET
txindex = utxo_id % BLKNUM_OFFSET // TXINDEX_OFFSET
oindex = utxo_id % TXINDEX_OFFSET
return (blknum, txindex, oindex)
def encode_utxo_id(blknum, txindex, oindex):
return blknum * BLKNU... |
# OAuth app keys
DROPBOX_KEY = None
DROPBOX_SECRET = None
DROPBOX_AUTH_CSRF_TOKEN = 'dropbox-auth-csrf-token'
# Max file size permitted by frontend in megabytes
MAX_UPLOAD_SIZE = 150
| dropbox_key = None
dropbox_secret = None
dropbox_auth_csrf_token = 'dropbox-auth-csrf-token'
max_upload_size = 150 |
ALLOWED_HOSTS = ['localhost', '127.0.0.1', '[::1]', 'jobs.harenconstruction.com', 'www.harenconstruction.com', 'harenconstruction.com' '104.236.59.248']
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = '/home/applicant/' #os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
#... | allowed_hosts = ['localhost', '127.0.0.1', '[::1]', 'jobs.harenconstruction.com', 'www.harenconstruction.com', 'harenconstruction.com104.236.59.248']
base_dir = '/home/applicant/'
debug = False
databases = {'default': {'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'applicant', 'USER': 'applicant', 'PASSWO... |
#
# PySNMP MIB module ZhoneDsl-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ZhoneDsl-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:52:33 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019,... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_size_constraint, value_range_constraint, constraints_intersection, single_value_constraint) ... |
def is_on(S, j):
return (S & (1 << j)) >> j
def set_all(n):
return (1 << n) - 1
def low_bit(S):
return (S & (-S)).bit_length() - 1
def clear_bit(S, j):
return S & ~(1 << j)
| def is_on(S, j):
return (S & 1 << j) >> j
def set_all(n):
return (1 << n) - 1
def low_bit(S):
return (S & -S).bit_length() - 1
def clear_bit(S, j):
return S & ~(1 << j) |
class core50():
def __init__(self, paradigm, run):
self.batch_num = 5
self.rootdir = '/home/rushikesh/code/core50_dataloaders/dataloaders/task_filelists/'
self.train_data = []
self.train_labels = []
self.train_groups = [[],[],[],[],[]]
for b in range(self.batch_num):
with open( self.rootdir + paradig... | class Core50:
def __init__(self, paradigm, run):
self.batch_num = 5
self.rootdir = '/home/rushikesh/code/core50_dataloaders/dataloaders/task_filelists/'
self.train_data = []
self.train_labels = []
self.train_groups = [[], [], [], [], []]
for b in range(self.batch_num... |
User_name = input("What is your name? ")
User_age = input("How old are you? ")
User_liveplace = input("Where are you live? ")
print ( "This is", User_name)
print ( "It is" , User_age)
print ( "(S)he live in", User_liveplace) | user_name = input('What is your name? ')
user_age = input('How old are you? ')
user_liveplace = input('Where are you live? ')
print('This is', User_name)
print('It is', User_age)
print('(S)he live in', User_liveplace) |
def includes(doc, path, title=3, **args):
j = doc.docsite._j
spath = j.sal.fs.processPathForDoubleDots(j.sal.fs.joinPaths(j.sal.fs.getDirName(doc.path), path))
if not j.sal.fs.exists(spath, followlinks=True):
doc.raiseError("Cannot find path for macro includes:%s" % spath)
docNames = [j.sal.fs... | def includes(doc, path, title=3, **args):
j = doc.docsite._j
spath = j.sal.fs.processPathForDoubleDots(j.sal.fs.joinPaths(j.sal.fs.getDirName(doc.path), path))
if not j.sal.fs.exists(spath, followlinks=True):
doc.raiseError('Cannot find path for macro includes:%s' % spath)
doc_names = [j.sal.fs.... |
#!/usr/bin/env python
lista=[2,3,4,1]
lista2=lista[:] #Copia
lista.sort()
if lista == lista2:
print("Lista ordenada")
else:
print("Lista no ordenada") | lista = [2, 3, 4, 1]
lista2 = lista[:]
lista.sort()
if lista == lista2:
print('Lista ordenada')
else:
print('Lista no ordenada') |
__author__ = "Andre Merzky"
__copyright__ = "Copyright 2012-2013, The SAGA Project"
__license__ = "MIT"
# ------------------------------------------------------------------------------
# FIXME: OS enums, ARCH enums
# resource type enum
COMPUTE = 1 # resource accepting jobs
STORAGE = 2 ... | __author__ = 'Andre Merzky'
__copyright__ = 'Copyright 2012-2013, The SAGA Project'
__license__ = 'MIT'
compute = 1
storage = 2
network = 4
unknown = None
new = 1
pending = 2
active = 4
canceled = 8
expired = 16
done = EXPIRED
failed = 32
final = CANCELED | DONE | FAILED
id = 'Id'
rtype = 'Rtype'
state = 'State'
state_... |
def is_zigzag(numbers: list):
if len(numbers) != 3:
raise ValueError('must be 3 elements {}'.format(numbers))
return 1 if (numbers[0] < numbers[1] > numbers[2]) or (numbers[0] > numbers[1] < numbers[2]) else 0
if __name__ == "__main__":
#numbers = [1, 2, 1]
numbers = [1, 2, 1, 3, 4]
numb... | def is_zigzag(numbers: list):
if len(numbers) != 3:
raise value_error('must be 3 elements {}'.format(numbers))
return 1 if numbers[0] < numbers[1] > numbers[2] or numbers[0] > numbers[1] < numbers[2] else 0
if __name__ == '__main__':
numbers = [1, 2, 1, 3, 4]
numbers = [1, 3, 4, 5, 6, 14, 14]
... |
def ext_here(props):
props['ext_ui']['filedir2']=props['ext_ui']['filedir']
props['music'].clickSon()
#print(filedir2)
decomp(props)
def ext_to(props):
filedir=props['ext_ui']['filedir']
root=props['root']
filedialog=props['filedialog']
props['music'].clickSon()
root.filename... | def ext_here(props):
props['ext_ui']['filedir2'] = props['ext_ui']['filedir']
props['music'].clickSon()
decomp(props)
def ext_to(props):
filedir = props['ext_ui']['filedir']
root = props['root']
filedialog = props['filedialog']
props['music'].clickSon()
root.filename = filedialog.askdir... |
class UserDoesNotExist(Exception):
pass
class PasswordDoesNotMatch(Exception):
pass
class EmailAlreadyRegistered(Exception):
pass
| class Userdoesnotexist(Exception):
pass
class Passworddoesnotmatch(Exception):
pass
class Emailalreadyregistered(Exception):
pass |
class TestData():
BROWSER_PATH="C:/Python/Python37-32/chromedriver.exe"
BASE_URL = "https://www.amazon.com"
SEARCH_TERM = "adidas backpack men"
HOME_PAGE_TITLE = "Amazon.com"
NO_RESULTS_TEXT = "No results found." | class Testdata:
browser_path = 'C:/Python/Python37-32/chromedriver.exe'
base_url = 'https://www.amazon.com'
search_term = 'adidas backpack men'
home_page_title = 'Amazon.com'
no_results_text = 'No results found.' |
class Vec3():
def __init__(self, x=0, y=0, z=0):
self.x = x
self.y = y
self.z = z
def length(self):
return (self.x * self.x + self.y * self.y + self.z * self.z)**0.5
def __add__(self, other):
return Vec3(self.x + other.x, self.y + other.y, self.z + other.z)
def... | class Vec3:
def __init__(self, x=0, y=0, z=0):
self.x = x
self.y = y
self.z = z
def length(self):
return (self.x * self.x + self.y * self.y + self.z * self.z) ** 0.5
def __add__(self, other):
return vec3(self.x + other.x, self.y + other.y, self.z + other.z)
de... |
def dp(height, max_steps, memo):
if height == 0:
return 1
if memo[height] > 0:
return memo[height]
ways = 0
for i in range(max(height - max_steps, 0), height):
ways += dp(i, max_steps, memo)
memo[height] = ways
return ways
def staircaseTraversal(height, maxSteps):
... | def dp(height, max_steps, memo):
if height == 0:
return 1
if memo[height] > 0:
return memo[height]
ways = 0
for i in range(max(height - max_steps, 0), height):
ways += dp(i, max_steps, memo)
memo[height] = ways
return ways
def staircase_traversal(height, maxSteps):
m... |
#Question 1342:
#Given a non-negative integer num, return the number of steps to reduce it to zero.
# If the current number is even, you have to divide it by 2, otherwise, you have to subtract 1 from it.
#Example:
#Input: num = 14
#Output: 6
#Explanation:
#Step 1) 14 is even; divide by 2 and obtain 7.
#Step 2)... | def number_of_steps(num):
no_of_steps = 0
while num > 0:
if num & 1 == 0:
num -= 1
else:
num //= 2
no_of_steps += 1
return no_of_steps
num = int(input('Enter a number: '))
print('Number of steps required to reduce: {}'.format(number_of_steps(num))) |
class Variable(object):
BOOLEAN = 1
def __init__(self, name, type, value):
self.name = name
self.type = type
self.value = value
def __repr__(self):
return "Variable(%s, %s, %s)" % (self.name, self.type, self.value)
| class Variable(object):
boolean = 1
def __init__(self, name, type, value):
self.name = name
self.type = type
self.value = value
def __repr__(self):
return 'Variable(%s, %s, %s)' % (self.name, self.type, self.value) |
# Copyright 2016 The Bazel Authors. All rights reserved.
#
# 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 la... | load(':common.bzl', 'make_dart_context', 'package_spec_action')
load(':dart_vm_snapshot.bzl', 'dart_vm_snapshot_action')
def _dart_vm_binary_action(ctx, script_file, srcs, deps, data=[], snapshot=True, script_args=[], generated_srcs=[], vm_flags=[], pub_pkg_name=''):
dart_ctx = make_dart_context(ctx, srcs=srcs, ge... |
print("CONVERSOR DE DECIMALES A OTRA BASE")
number = input("Ingresa un numero de base decimal: ")
base = input("Ingresa la base: ")
numbers = []
def residuo(number, base, iteration = 0):
cociente = number // base
res = number % base
print(" " * iteration, res, cociente)
numbers.append(res)
if (c... | print('CONVERSOR DE DECIMALES A OTRA BASE')
number = input('Ingresa un numero de base decimal: ')
base = input('Ingresa la base: ')
numbers = []
def residuo(number, base, iteration=0):
cociente = number // base
res = number % base
print(' ' * iteration, res, cociente)
numbers.append(res)
if cocien... |
def draw(n):
for i in range(1, n+1):
for k in range(0,n-i):
print(" ", end=" ")
for j in range(0,i):
print("*", end=" ")
print("\n")
draw(4) | def draw(n):
for i in range(1, n + 1):
for k in range(0, n - i):
print(' ', end=' ')
for j in range(0, i):
print('*', end=' ')
print('\n')
draw(4) |
i = 0
while i < 10:
print(i)
i = i + 1
i = 1
while i <= 2 ** 32:
print(i)
i *= 2
done = False
while not done:
quit = input("Do you want to quit? ")
if quit == "y":
done = True
attack = input("Does your elf attack the dragon? ")
if attack == "y":
print("Bad choice,... | i = 0
while i < 10:
print(i)
i = i + 1
i = 1
while i <= 2 ** 32:
print(i)
i *= 2
done = False
while not done:
quit = input('Do you want to quit? ')
if quit == 'y':
done = True
attack = input('Does your elf attack the dragon? ')
if attack == 'y':
print('Bad choice, you die... |
class Solution:
def reformatDate(self, date: str) -> str:
clean = date.split()
month = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
... | class Solution:
def reformat_date(self, date: str) -> str:
clean = date.split()
month = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
(day, month, year) = (str(clean[0])[:-2], month.index(clean[1]) + 1, clean[2])
if len(day) == 1:
d... |
# Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# This is a mixture of the javadoc_library rule in
# https://github.com/google/bazel-common and the one in
# https://github.com/stackb/rules_proto.
# The main two factors for why we ... | def _javadoc_library(ctx):
transitive_deps = []
for dep in ctx.attr.deps:
if JavaInfo in dep:
transitive_deps.append(dep[JavaInfo].transitive_deps)
elif hasattr(dep, 'java'):
transitive_deps.append(dep.java.transitive_deps)
classpath = depset([], transitive=transitive... |
# Notation for direction will be as follows:
# 0
# 3 1
# 2
# Turning to the rights = (d+1)%4
# Turning to the left = (d-1)%4
def move(d, cX, cY):
if (d == 0):
cX = cX-1
if (d == 1):
cY = cY+1
if (d == 2):
cX = cX+1
if (d == 3):
cY = cY-1
return cX, cY
def ... | def move(d, cX, cY):
if d == 0:
c_x = cX - 1
if d == 1:
c_y = cY + 1
if d == 2:
c_x = cX + 1
if d == 3:
c_y = cY - 1
return (cX, cY)
def work(mp, d, x, y):
if mp[x][y] == '#':
d = (d + 1) % 4
mp[x][y] = '.'
else:
d = (d - 1) % 4
... |
class Constants:
# Common Constants
mail: str = "prodcube@prodcube.dev"
version: str = "1.0.0"
# Production Constants
productionDescription: str = "Handles the ProDCube Backend Server. Currently in Production. " \
"Please change to development mode while development... | class Constants:
mail: str = 'prodcube@prodcube.dev'
version: str = '1.0.0'
production_description: str = 'Handles the ProDCube Backend Server. Currently in Production. Please change to development mode while development.'
production_title: str = 'ProDCube Backend Server - Production'
development_de... |
def mergeSort(arr:[int]):
mid:int = 0
L:[int] = None
R:[int] = None
i:int = 0
j:int = 0
k:int = 0
if len(arr) > 1:
# Finding the mid of the array
mid = len(arr)//2
# Dividing the array elements
L=[]
while (i<mid):
L = L + [arr[i]]
... | def merge_sort(arr: [int]):
mid: int = 0
l: [int] = None
r: [int] = None
i: int = 0
j: int = 0
k: int = 0
if len(arr) > 1:
mid = len(arr) // 2
l = []
while i < mid:
l = L + [arr[i]]
i = i + 1
r = []
while i < len(arr):
... |
n=int(input())
arr=[]
c=0
for _ in range(n):
arr.append(list(map(int,input().split())))
for i in range(len(arr)):
co=0
for j in range(len(arr[i])):
if(arr[i][j]==1):
co+=1
if(co>=2):
c+=1
print(c) | n = int(input())
arr = []
c = 0
for _ in range(n):
arr.append(list(map(int, input().split())))
for i in range(len(arr)):
co = 0
for j in range(len(arr[i])):
if arr[i][j] == 1:
co += 1
if co >= 2:
c += 1
print(c) |
# 21302 - [Job Adv] (Lv.60) Aran
sm.setSpeakerID(1201002)
sm.sendNext("Oh, isn't that... Hey, did you remember how to make the Red Jade? You may be a dummy who has amnesia, but this is why I can't leave you. Now hurry, give me the gem!")
if sm.sendAskYesNo("Okay, now that I have the power of Red Jade, I'll restore mo... | sm.setSpeakerID(1201002)
sm.sendNext("Oh, isn't that... Hey, did you remember how to make the Red Jade? You may be a dummy who has amnesia, but this is why I can't leave you. Now hurry, give me the gem!")
if sm.sendAskYesNo("Okay, now that I have the power of Red Jade, I'll restore more of your abilities. Your level ha... |
class Prunner(object):
def __init__(self):
pass
def fit(self, ensemble, X, y):
return self
def get(self, p=0.1):
return self.ensemble[:int(p * len(self.ensemble))]
| class Prunner(object):
def __init__(self):
pass
def fit(self, ensemble, X, y):
return self
def get(self, p=0.1):
return self.ensemble[:int(p * len(self.ensemble))] |
# -*- coding: utf-8 -*-
'''
Author: Hannibal
Data:
Desc: local data config
NOTE: Don't modify this file, it's build by xml-to-python!!!
'''
simpleskillpassive_map = {};
simpleskillpassive_map[2001] = {"id":2001,"skilldata":[{"lv":1,"effect":"actor['atk']*=1.2","group":1,},{"lv":2,"effect":"actor['atk']*=1.3","group... | """
Author: Hannibal
Data:
Desc: local data config
NOTE: Don't modify this file, it's build by xml-to-python!!!
"""
simpleskillpassive_map = {}
simpleskillpassive_map[2001] = {'id': 2001, 'skilldata': [{'lv': 1, 'effect': "actor['atk']*=1.2", 'group': 1}, {'lv': 2, 'effect': "actor['atk']*=1.3", 'group': 1}, {'lv': 3,... |
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Mytree:
def maketree(self, arr: list):
root = TreeNode(arr[0])
mystack = []
mystack.append(root)
nl = []
i = 0
whil... | class Treenode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Mytree:
def maketree(self, arr: list):
root = tree_node(arr[0])
mystack = []
mystack.append(root)
nl = []
i = 0
wh... |
asdasdfgs = 1
def add(x, y):
return x + y
print(add(asdasdfgs, 2))
print(add(asdasdfgs, 3))
print(add(asdasdfgs, 5))
| asdasdfgs = 1
def add(x, y):
return x + y
print(add(asdasdfgs, 2))
print(add(asdasdfgs, 3))
print(add(asdasdfgs, 5)) |
#!/usr/bin/python
#coding=utf-8
class List(list):
def __getattr__(self, attr):
tmp = List()
for l in self:
tmp.append(l.__getattr__(attr))
return tmp
def equal(self, value, attr='class'):
tmp = List()
for l in self:
if hasattr(l, 'equal'):
... | class List(list):
def __getattr__(self, attr):
tmp = list()
for l in self:
tmp.append(l.__getattr__(attr))
return tmp
def equal(self, value, attr='class'):
tmp = list()
for l in self:
if hasattr(l, 'equal'):
flag = l.equal(value, ... |
def add(x, y):
total = x + y
return total
print(add(5, 10))
def add(x, y=3):
total = x + y
return total
print(add(5))
print(add(5, 7))
print(add(x=2))
print(add(x=8, y=4))
print(1, 2, 3, 4, 5)
print(1, 2, 3, 4, 5, sep=' - ')
# The default value is stored at the definition of the function
# as sho... | def add(x, y):
total = x + y
return total
print(add(5, 10))
def add(x, y=3):
total = x + y
return total
print(add(5))
print(add(5, 7))
print(add(x=2))
print(add(x=8, y=4))
print(1, 2, 3, 4, 5)
print(1, 2, 3, 4, 5, sep=' - ')
default_y = 3
def add(x, y=default_y):
total = x + y
print(total)
add... |
a=int(input("Enter the first term of the GP: "))
r=int(input("Enter the common ratio: "))
n=int(input("Enter the number of terms: "))
sum=0
product=1
for i in range(n):
term=a*pow(r,i)
sum=sum+term
product=product*term
print("Sum of",n,"terms=",sum)
print("Product of",n,"terms=",product)
| a = int(input('Enter the first term of the GP: '))
r = int(input('Enter the common ratio: '))
n = int(input('Enter the number of terms: '))
sum = 0
product = 1
for i in range(n):
term = a * pow(r, i)
sum = sum + term
product = product * term
print('Sum of', n, 'terms=', sum)
print('Product of', n, 'terms=',... |
def get_starting_params():
num_players = int(input("Enter Number of Players : ")) # it takes user input
deck_size = 48
if num_players == 2:
hand_size = 10
points_threshold = 5
number_starting_common_cards = 8
elif num_players == 3:
hand_size = 8
points_threshol... | def get_starting_params():
num_players = int(input('Enter Number of Players : '))
deck_size = 48
if num_players == 2:
hand_size = 10
points_threshold = 5
number_starting_common_cards = 8
elif num_players == 3:
hand_size = 8
points_threshold = 3
number_star... |
class Benchmark:
@classmethod
def get_train_tasks(cls, sample_all=False):
return cls(env_type='train', sample_all=sample_all)
@classmethod
def get_test_tasks(cls, sample_all=False):
return cls(env_type='test', sample_all=sample_all)
| class Benchmark:
@classmethod
def get_train_tasks(cls, sample_all=False):
return cls(env_type='train', sample_all=sample_all)
@classmethod
def get_test_tasks(cls, sample_all=False):
return cls(env_type='test', sample_all=sample_all) |
def includeme(config):
# settings = config.registry.settings
config.add_route('processes', '/processes')
config.add_route('processes_list', '/processes/list')
config.add_route('processes_execute', '/processes/execute')
config.include('phoenix.processes.views.actions')
| def includeme(config):
config.add_route('processes', '/processes')
config.add_route('processes_list', '/processes/list')
config.add_route('processes_execute', '/processes/execute')
config.include('phoenix.processes.views.actions') |
special_sum = 0
n_minus_1 = n_minus_2 = 1
fib_n = 0
while fib_n < 1000000:
fib_n, n_minus_1, n_minus_2 = n_minus_1, n_minus_2, n_minus_1 + n_minus_2
if fib_n % 2 == 0: special_sum += fib_n
print(special_sum)
| special_sum = 0
n_minus_1 = n_minus_2 = 1
fib_n = 0
while fib_n < 1000000:
(fib_n, n_minus_1, n_minus_2) = (n_minus_1, n_minus_2, n_minus_1 + n_minus_2)
if fib_n % 2 == 0:
special_sum += fib_n
print(special_sum) |
test = { 'name': 'q0_1',
'points': 1,
'suites': [ { 'cases': [ {'code': ">>> flavor_count.labels == ('Flavor', 'count')\nTrue", 'hidden': False, 'locked': False},
{'code': '>>> flavor_count.take(0).column("count").item(0) == 4\nTrue', 'hidden': False, 'locked': False},... | test = {'name': 'q0_1', 'points': 1, 'suites': [{'cases': [{'code': ">>> flavor_count.labels == ('Flavor', 'count')\nTrue", 'hidden': False, 'locked': False}, {'code': '>>> flavor_count.take(0).column("count").item(0) == 4\nTrue', 'hidden': False, 'locked': False}, {'code': '>>> flavor_count.take(1).column("count").ite... |
EXPECTED_TOKEN = "eyJhbGciOiJSUzI1NiIsImtpZCI6Ijk0OTRhZDc1LTNmNTQtNDE1NS04NGZhLWMxYTE3ZGEyMmIzNSIsInR5cCI6IkpXVCJ9.eyJhbGxvdyI6eyIqIjoiKiJ9LCJkZW55Ijp7fX0.nDqCxO2Q1iXpxzbH7syxuyqw7kCY0sDfi9RX-VSUMTRN5aWTLt1bcPw4oN_jx89-YHBzDwnwBc07RsMgpFuo4zz2LU9PF0ciYxMNX-atTNsaIn05NkXT08au2AYb0DRCDS76MZ4QNi-4mRpLrj1SD4mSCwGtc2WNw9f0J... | expected_token = 'eyJhbGciOiJSUzI1NiIsImtpZCI6Ijk0OTRhZDc1LTNmNTQtNDE1NS04NGZhLWMxYTE3ZGEyMmIzNSIsInR5cCI6IkpXVCJ9.eyJhbGxvdyI6eyIqIjoiKiJ9LCJkZW55Ijp7fX0.nDqCxO2Q1iXpxzbH7syxuyqw7kCY0sDfi9RX-VSUMTRN5aWTLt1bcPw4oN_jx89-YHBzDwnwBc07RsMgpFuo4zz2LU9PF0ciYxMNX-atTNsaIn05NkXT08au2AYb0DRCDS76MZ4QNi-4mRpLrj1SD4mSCwGtc2WNw9f0J... |
# Floyed Loop
# Double linked List definition
class DListNode(object):
def __init__(self):
# self.value = x
self.next = None
self.prev = None
class Floyed(object):
def __init__(self):
self.head = None
# super(Floyed, self).__init__()
self.slow = DListNode()
... | class Dlistnode(object):
def __init__(self):
self.next = None
self.prev = None
class Floyed(object):
def __init__(self):
self.head = None
self.slow = d_list_node()
self.fast = d_list_node()
self.slow = self.head
self.fast = self.head
def is_loop(se... |
def parse_app_id(app_id, method):
if app_id is not None and "/" in app_id:
# This is the normal case - narrative methods
app_id_parts = app_id.split("/")
app_type = "narrative"
elif method is not None:
# Here we use the method for non-narrative methods.
app_id_parts = met... | def parse_app_id(app_id, method):
if app_id is not None and '/' in app_id:
app_id_parts = app_id.split('/')
app_type = 'narrative'
elif method is not None:
app_id_parts = method.split('.')
app_type = 'other'
else:
return None
if len(app_id_parts) != 2:
if ... |
filename = 'test.txt'
filehandle = open('test.txt')
row = 1
filelist = list()
for item in filehandle:
print(item)
if item.startswith('4'):
item = item.strip()
item = int(item)
if item == row:
filelist.append(item)
row = row + 1
else:
... | filename = 'test.txt'
filehandle = open('test.txt')
row = 1
filelist = list()
for item in filehandle:
print(item)
if item.startswith('4'):
item = item.strip()
item = int(item)
if item == row:
filelist.append(item)
row = row + 1
else:
print(file... |
a = 0
b = 67 # 1
c = b # 2
d = 0
e = 0
f = 0
g = 0
h = 0
# count the number of mul
# smoke test for asm translation correctness
count = 0
# jumps > 0: if-else
# jumps < 0: do-while
if a != 0: # 2, 5
b *= 100 # 5
b += 100000 # 6
c = b # 7
c += 17000 # 8
while True: # 32
f = 1 # 9 - flag registe... | a = 0
b = 67
c = b
d = 0
e = 0
f = 0
g = 0
h = 0
count = 0
if a != 0:
b *= 100
b += 100000
c = b
c += 17000
while True:
f = 1
d = 2
outer_g = True
while outer_g:
e = 2
inner_g = True
while inner_g:
g = d
g *= e
count += 1
... |
#Create a histogram from a given list of integers
def histogram( items ):
for n in items:
output = ''
times = n
while( times > 0 ):
output += ' @ '
times = times - 1
print(output)
histogram([2, 3, 6, 5])
| def histogram(items):
for n in items:
output = ''
times = n
while times > 0:
output += ' @ '
times = times - 1
print(output)
histogram([2, 3, 6, 5]) |
# Write a short Python function, is even(k), that takes an integer value and
# returns True if k is even, and False otherwise. However, your function
# cannot use the multiplication, modulo, or division operators
def is_even(k):
even_nums = [0, 2, 4, 6, 8]
string_k = str(k)
string_list = [c for c in string... | def is_even(k):
even_nums = [0, 2, 4, 6, 8]
string_k = str(k)
string_list = [c for c in string_k]
last_number = string_list[-1] if len(string_list) > 1 else string_list[0]
print(k)
try:
even_nums.index(int(last_number))
return True
except ValueError:
return False
prin... |
# Sample Test passing with nose and pytest
def test_pass():
assert True, "Sample test"
| def test_pass():
assert True, 'Sample test' |
class Solution:
def pathSum(self, root: TreeNode, sum: int) -> List[List[int]]:
ans = []
def dfs(root: TreeNode, sum: int, path: List[int]) -> None:
if root is None:
return
if root.val == sum and root.left is None and root.right is None:
ans.append(path + [root.val])
retur... | class Solution:
def path_sum(self, root: TreeNode, sum: int) -> List[List[int]]:
ans = []
def dfs(root: TreeNode, sum: int, path: List[int]) -> None:
if root is None:
return
if root.val == sum and root.left is None and (root.right is None):
a... |
class Address:
def __init__(self, street, city, pincode) -> None:
self.street = street
self.city = city
self.pincode = pincode
class Student:
def __init__(self,name, email, street, city, pincode) -> None:
self.name = name
self.email = email
self.address = Address... | class Address:
def __init__(self, street, city, pincode) -> None:
self.street = street
self.city = city
self.pincode = pincode
class Student:
def __init__(self, name, email, street, city, pincode) -> None:
self.name = name
self.email = email
self.address = addr... |
h , m = map(int, input().split())
if m < 45 :
if h==0:
h = 23
else:
h-=1
m += 15
else:
m -= 45
print(h,m) | (h, m) = map(int, input().split())
if m < 45:
if h == 0:
h = 23
else:
h -= 1
m += 15
else:
m -= 45
print(h, m) |
# pyfc4
# version info
__version_info__ = ('0', '1')
__version__ = '.'.join(__version_info__)
| __version_info__ = ('0', '1')
__version__ = '.'.join(__version_info__) |
CONTRACT_RECEIVE_FUNCTION_SOURCE = '''
pragma solidity ^0.6.0;
contract Receive {
string text;
fallback() external payable {
text = 'fallback';
}
receive() external payable {
text = 'receive';
}
function getText() public view returns (string memory) {
return text;
... | contract_receive_function_source = "\npragma solidity ^0.6.0;\n\n\ncontract Receive {\n string text;\n\n fallback() external payable {\n text = 'fallback';\n }\n\n receive() external payable {\n text = 'receive';\n }\n\n function getText() public view returns (string memory) {\n r... |
# Define a function that takes in two non-negative integers a and b and returns the last decimal digit of a^b.
# Note that a and b may be very large!
# For example, the last decimal digit of 9^7 is 9, since 9^7=4782969.
# The last decimal digit of (2^200)^2300, which has over 10^92 decimal digits, is 6.
# Also, plea... | def last_digit(a, b):
return pow(a, b, 10) |
num = int(input("Input: "))
count = 0
squareLength = 3
while squareLength * squareLength < num:
squareLength += 2
squareLength -= 2
cornerValue = squareLength * squareLength
diff = num - cornerValue
midPoint = (squareLength + 1) / 2
# # Walk right one
# diff += 1
# # Walk north
# if squareLength > diff:
# dif... | num = int(input('Input: '))
count = 0
square_length = 3
while squareLength * squareLength < num:
square_length += 2
square_length -= 2
corner_value = squareLength * squareLength
diff = num - cornerValue
mid_point = (squareLength + 1) / 2
print(squareLength)
print(cornerValue)
print(diff)
print(midPoint) |
#Python program to Find ASCII value of character
def main():
x=input("Enter a character")
print("The ASCII value of",x,"is",ord(x))
if __name__=='__main__':
main()
| def main():
x = input('Enter a character')
print('The ASCII value of', x, 'is', ord(x))
if __name__ == '__main__':
main() |
{
"cells": [
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The max value = 5\n",
"The min value = -3\n",
"The max squared value = 25\n",
"The length of the list = 7\n",
"T... | {'cells': [{'cell_type': 'code', 'execution_count': 29, 'metadata': {}, 'outputs': [{'name': 'stdout', 'output_type': 'stream', 'text': ['The max value = 5\n', 'The min value = -3\n', 'The max squared value = 25\n', 'The length of the list = 7\n', 'The total of all positive numbers in the list = 15\n', 'The Negative nu... |
class TestClass(object):
def test_eken(self):
eken = 'diq'
assert eken == 'diq'
def test_gman(self):
gman_is_g = True
assert gman_is_g is True
def test_t(self):
tys_biceps_circumference = 5*1000
assert tys_biceps_circumference > 1000
| class Testclass(object):
def test_eken(self):
eken = 'diq'
assert eken == 'diq'
def test_gman(self):
gman_is_g = True
assert gman_is_g is True
def test_t(self):
tys_biceps_circumference = 5 * 1000
assert tys_biceps_circumference > 1000 |
load("//:plugin.bzl", "ProtoPluginInfo")
load(
"//internal:common.bzl",
"ProtoCompileInfo",
"copy_file",
"descriptor_proto_path",
"get_int_attr",
"get_output_filename",
"strip_path_prefix",
)
ProtoLibraryAspectNodeInfo = provider(
fields = {
"output_files": "The files generated ... | load('//:plugin.bzl', 'ProtoPluginInfo')
load('//internal:common.bzl', 'ProtoCompileInfo', 'copy_file', 'descriptor_proto_path', 'get_int_attr', 'get_output_filename', 'strip_path_prefix')
proto_library_aspect_node_info = provider(fields={'output_files': 'The files generated by this aspect and its transitive dependenci... |
# def foo (arg1, arg2, arg3):
# print (arg1,arg2,arg3)
# foo(
# arg2 = 'second',
# arg3 = 'third',
# arg1 = ['name1','name2']
# )
# string1 = ('{} part'.format('first'))
# string2 = 'second part'
# print (string1+string2)
def create_table(name,columns,datatype,key): #columns is a list containing col... | def create_table(name, columns, datatype, key):
dd = {'str': 'varchar(255)', 'float': 'FLOAT(63,4)'}
query = 'CREATE TABLE {} ( \n'.format(name)
query_seg = ''
for (i, col_name) in enumerate(columns):
query_seg = '{} {} NOT NULL,\n'.format(col_name, dd[datatype[i]])
query += query_seg
... |
chave_certa = 2002
while True:
senha = int(input())
if senha == chave_certa:
print("Acesso Permitido")
break
print("Senha Invalida") | chave_certa = 2002
while True:
senha = int(input())
if senha == chave_certa:
print('Acesso Permitido')
break
print('Senha Invalida') |
#!/usr/bin/python3
def max_integer(my_list=[]):
my_list.sort()
if my_list:
return my_list[len(my_list) - 1]
else:
return None
| def max_integer(my_list=[]):
my_list.sort()
if my_list:
return my_list[len(my_list) - 1]
else:
return None |
class Jogador():
def __init__(self):
self.cartas = []
self.soma = 0
self.turnos = 0 | class Jogador:
def __init__(self):
self.cartas = []
self.soma = 0
self.turnos = 0 |
feature_dict = {
'VMAF_feature': ['vif_scale0', 'vif_scale1', 'vif_scale2', 'vif_scale3', 'adm2', 'motion', ],
}
model_type = "LIBSVMNUSVR"
model_param_dict = {
# ==== preprocess: normalize each feature ==== #
# 'norm_type': 'none', # default: do nothing
'norm_type': 'clip_0to1', # rescale to within... | feature_dict = {'VMAF_feature': ['vif_scale0', 'vif_scale1', 'vif_scale2', 'vif_scale3', 'adm2', 'motion']}
model_type = 'LIBSVMNUSVR'
model_param_dict = {'norm_type': 'clip_0to1', 'score_clip': [0.0, 100.0], 'gamma': 0.05, 'C': 4.0, 'nu': 0.9} |
class Operation(dict):
def __init__(self, operationType=None, operationName=None, listOfInputMessages=None, listOfOutputMessages=None):
dict.__init__(self, operationType=operationType, operationName=operationName
, listOfInputMessages=listOfInputMessages, listOfOutputMessages=listOfOut... | class Operation(dict):
def __init__(self, operationType=None, operationName=None, listOfInputMessages=None, listOfOutputMessages=None):
dict.__init__(self, operationType=operationType, operationName=operationName, listOfInputMessages=listOfInputMessages, listOfOutputMessages=listOfOutputMessages) |
'''(Partitioning Arrays: Dutch Flag [M]): Dutch National Flag Problem:
Given an array of integers A and a pivot, rearrange A in the following order:
[Elements less than pivot, elements equal to pivot, elements greater than pivot]
For example, if A = [5,2,4,4,6,4,4,3] and pivot = 4 -> result = [3,2,4,4,4,4,6,5]'''... | """(Partitioning Arrays: Dutch Flag [M]): Dutch National Flag Problem:
Given an array of integers A and a pivot, rearrange A in the following order:
[Elements less than pivot, elements equal to pivot, elements greater than pivot]
For example, if A = [5,2,4,4,6,4,4,3] and pivot = 4 -> result = [3,2,4,4,4,4,6,5]"""
def... |
# copying a large dictionary
a = {i: 2 * i for i in range(1000)}
b = a.copy()
for i in range(1000):
print(i, b[i])
print(len(b))
| a = {i: 2 * i for i in range(1000)}
b = a.copy()
for i in range(1000):
print(i, b[i])
print(len(b)) |
class Parser():
def __init__(self, file):
content = [line.strip() for line in file.readlines()]
content = [line.split('//')[0].strip() for line in content if not line.startswith('//') and line is not '']
self.source_code: list = content
self.current_command: int = 0
def _comman... | class Parser:
def __init__(self, file):
content = [line.strip() for line in file.readlines()]
content = [line.split('//')[0].strip() for line in content if not line.startswith('//') and line is not '']
self.source_code: list = content
self.current_command: int = 0
def _command(... |
pkgname = "ninja"
pkgver = "1.10.2"
pkgrel = 0
hostmakedepends = ["python"]
pkgdesc = "Small build system with a focus on speed"
maintainer = "q66 <q66@chimera-linux.org>"
license = "Apache-2.0"
url = "https://ninja-build.org"
sources = [f"https://github.com/ninja-build/ninja/archive/v{pkgver}.tar.gz"]
sha256 = ["ce358... | pkgname = 'ninja'
pkgver = '1.10.2'
pkgrel = 0
hostmakedepends = ['python']
pkgdesc = 'Small build system with a focus on speed'
maintainer = 'q66 <q66@chimera-linux.org>'
license = 'Apache-2.0'
url = 'https://ninja-build.org'
sources = [f'https://github.com/ninja-build/ninja/archive/v{pkgver}.tar.gz']
sha256 = ['ce358... |
fonts = AllFonts()
for font in fonts:
min = 0
max = 0
for glyph in font:
if glyph.bounds != None:
if glyph.bounds[1] < min:
min = glyph.bounds[1]
if glyph.bounds[3] > max:
max = glyph.bounds[3]
print(min,max)
capSpace = m... | fonts = all_fonts()
for font in fonts:
min = 0
max = 0
for glyph in font:
if glyph.bounds != None:
if glyph.bounds[1] < min:
min = glyph.bounds[1]
if glyph.bounds[3] > max:
max = glyph.bounds[3]
print(min, max)
cap_space = max - font['H... |
def palindrome():
largest = 0
for a in range(999, 99, -1):
for b in range(999, 99, -1):
# use an awesome extended slice to reverse string
# https://docs.python.org/2/whatsnew/2.3.html#extended-slices
# print(a, b, a*b, str(a*b)[::-1])
if a*b == int(str(a*b... | def palindrome():
largest = 0
for a in range(999, 99, -1):
for b in range(999, 99, -1):
if a * b == int(str(a * b)[::-1]) and a * b > largest:
largest = a * b
return largest
print(palindrome()) |
class MaxHeap:
def __init__(self):
self.data = []
def root_node(self):
return self.data[0]
def last_node(self):
return self.data[-1]
def left_child_index(self, index):
return 2 * index + 1
def right_child_index(self, index):
return 2 * index + 2
def ... | class Maxheap:
def __init__(self):
self.data = []
def root_node(self):
return self.data[0]
def last_node(self):
return self.data[-1]
def left_child_index(self, index):
return 2 * index + 1
def right_child_index(self, index):
return 2 * index + 2
def ... |
wt9_2_10 = {'192.168.122.110': [5.7108, 8.5399, 6.3325, 4.9405, 4.3064, 5.4196, 4.7852, 4.852, 5.5112, 6.0472, 5.987, 5.9324, 5.9693, 5.9885, 5.9521, 5.9517, 5.9214, 5.8912, 6.1639, 6.1483, 6.1269, 6.1008, 6.0684, 6.0465, 6.0183, 5.9975, 6.094, 6.0673, 6.0838, 6.2445, 6.2204, 6.1954, 6.1722, 6.1532, 6.1334, 6.1211, 6.... | wt9_2_10 = {'192.168.122.110': [5.7108, 8.5399, 6.3325, 4.9405, 4.3064, 5.4196, 4.7852, 4.852, 5.5112, 6.0472, 5.987, 5.9324, 5.9693, 5.9885, 5.9521, 5.9517, 5.9214, 5.8912, 6.1639, 6.1483, 6.1269, 6.1008, 6.0684, 6.0465, 6.0183, 5.9975, 6.094, 6.0673, 6.0838, 6.2445, 6.2204, 6.1954, 6.1722, 6.1532, 6.1334, 6.1211, 6.1... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.