content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
m = 5
n = 0.000001
# rule-id: use-float-numbers
assert(1.0000 == 1.000000)
# rule-id: use-float-numbers
assert(1.0000 == m)
# rule-id: use-float-numbers
assert(m == 1.0000)
# rule-id: use-float-numbers
assert(m == n)
| m = 5
n = 1e-06
assert 1.0 == 1.0
assert 1.0 == m
assert m == 1.0
assert m == n |
while True:
password = input("Password")
print(password)
if password == "stop":
break
print("the while loop has stopped") | while True:
password = input('Password')
print(password)
if password == 'stop':
break
print('the while loop has stopped') |
# wczytanie slow i szyfrow
with open('../dane/sz.txt') as f:
cyphers = []
for word in f.readlines():
cyphers.append(word[:-1])
with open('../dane/klucze2.txt') as f:
keys = []
for word in f.readlines():
keys.append(word[:-1])
# zbior odszyfrowanych slow
words = []
# przejscie po slowac... | with open('../dane/sz.txt') as f:
cyphers = []
for word in f.readlines():
cyphers.append(word[:-1])
with open('../dane/klucze2.txt') as f:
keys = []
for word in f.readlines():
keys.append(word[:-1])
words = []
for (cypher, key) in zip(cyphers, keys):
word = ''
for (i, char) in en... |
def graph_pred_vs_actual(actual,pred,data_type):
plt.scatter(actual,pred,alpha=.3)
plt.plot(np.linspace(int(min(pred)),int(max(pred)),int(max(pred))),
np.linspace(int(min(pred)),int(max(pred)),int(max(pred))))
plt.title('Actual vs Pred ({} Data)'.format(data_type))
plt.xlabel('Actual')
... | def graph_pred_vs_actual(actual, pred, data_type):
plt.scatter(actual, pred, alpha=0.3)
plt.plot(np.linspace(int(min(pred)), int(max(pred)), int(max(pred))), np.linspace(int(min(pred)), int(max(pred)), int(max(pred))))
plt.title('Actual vs Pred ({} Data)'.format(data_type))
plt.xlabel('Actual')
plt.... |
#
# PySNMP MIB module DC-OPT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DC-OPT-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:21:45 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, 09:... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_size_constraint, value_range_constraint, constraints_union, constraints_intersection) ... |
#
# PySNMP MIB module DGS-6600-STP-EXT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DGS-6600-STP-EXT-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:45: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, value_size_constraint, single_value_constraint, constraints_intersection, constraints_union) ... |
def arithmetic_arranger(problems,calc = False):
if 5 < len(problems):
return "Error: Too many problems."
sOperand1 = sOperand2 = sDashes = sResults = ""
separator = " "
for i in range(len(problems)):
words = problems[i].split()
if(not (words[1] == "+" or words[1] =="-")):
return "E... | def arithmetic_arranger(problems, calc=False):
if 5 < len(problems):
return 'Error: Too many problems.'
s_operand1 = s_operand2 = s_dashes = s_results = ''
separator = ' '
for i in range(len(problems)):
words = problems[i].split()
if not (words[1] == '+' or words[1] == '-'):
... |
#
# PySNMP MIB module MITEL-ERN (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/MITEL-ERN
# Produced by pysmi-0.3.4 at Wed May 1 14:13:10 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, 09:23... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, value_range_constraint, constraints_intersection, single_value_constraint, constraints_union) ... |
def oneaway(x,y):
# INSERT
x = list(x)
y = list(y)
if (len(x)+1) == len(y):
for k in x:
if k in y:
continue
else:
return "1 FUCK"
# REMOVAL
if (len(x)-1) == len(y):
for k in y:
if k in x:
continu... | def oneaway(x, y):
x = list(x)
y = list(y)
if len(x) + 1 == len(y):
for k in x:
if k in y:
continue
else:
return '1 FUCK'
if len(x) - 1 == len(y):
for k in y:
if k in x:
continue
else:
... |
# Python - 3.6.0
test.describe('Example Tests')
tests = (
('John', 'Hello, John!'),
('aLIce', 'Hello, Alice!'),
('', 'Hello, World!')
)
for inp, exp in tests:
test.assert_equals(hello(inp), exp)
test.assert_equals(hello(), 'Hello, World!')
| test.describe('Example Tests')
tests = (('John', 'Hello, John!'), ('aLIce', 'Hello, Alice!'), ('', 'Hello, World!'))
for (inp, exp) in tests:
test.assert_equals(hello(inp), exp)
test.assert_equals(hello(), 'Hello, World!') |
'''PROGRAM TO, FOR A GIVEN LIST OF TUPLES, WHERE EACH TUPLE TAKES PATTERN (NAME,MARKS) OF A STUDENT, DISPLAY ONLY NAMES.'''
#Given list
scores = [("akash", 85), ("arind", 80), ("asha",95), ('bhavana',90), ('bhavik',87)]
#Seperaing names and marks
sep = list(zip(*scores))
names = sep[0]
#Displaying names
print('\nN... | """PROGRAM TO, FOR A GIVEN LIST OF TUPLES, WHERE EACH TUPLE TAKES PATTERN (NAME,MARKS) OF A STUDENT, DISPLAY ONLY NAMES."""
scores = [('akash', 85), ('arind', 80), ('asha', 95), ('bhavana', 90), ('bhavik', 87)]
sep = list(zip(*scores))
names = sep[0]
print('\nNames of students:')
for x in names:
print(x.title())
pr... |
# https://binarysearch.com/problems/Largest-Anagram-Group
class Solution:
def solve(self, words):
anagrams = {}
for i in range(len(words)):
words[i] = "".join(sorted(list(words[i])))
if words[i] in anagrams:
anagrams[words[i]]+=1
else:
... | class Solution:
def solve(self, words):
anagrams = {}
for i in range(len(words)):
words[i] = ''.join(sorted(list(words[i])))
if words[i] in anagrams:
anagrams[words[i]] += 1
else:
anagrams[words[i]] = 1
return max(anagrams.... |
class Solution:
def mostCommonWord(self, paragraph: str, banned: List[str]) -> str:
paraList = re.split('\W', paragraph.lower())
paraListAlpha = []
for item in paraList:
item = ''.join([i for i in item if i.isalpha()])
paraListAlpha.append(item)
countParaList ... | class Solution:
def most_common_word(self, paragraph: str, banned: List[str]) -> str:
para_list = re.split('\\W', paragraph.lower())
para_list_alpha = []
for item in paraList:
item = ''.join([i for i in item if i.isalpha()])
paraListAlpha.append(item)
count_p... |
with open("a.txt",'r') as ifile:
with open("b.txt","w") as ofile:
char = ifile.read(1)
while char:
if char==".":
ofile.write(char)
ofile.write("\n")
char = ifile.read(1)
else:
ofile.write(char)
ch... | with open('a.txt', 'r') as ifile:
with open('b.txt', 'w') as ofile:
char = ifile.read(1)
while char:
if char == '.':
ofile.write(char)
ofile.write('\n')
char = ifile.read(1)
else:
ofile.write(char)
... |
L, R = map(int, input().split())
ll = list(map(int, input().split()))
rl = list(map(int, input().split()))
lsize = [0]*41
rsize = [0]*41
for l in ll:
lsize[l] += 1
for r in rl:
rsize[r] += 1
ans = 0
for i in range(10, 41):
ans += min(lsize[i], rsize[i])
print(ans)
| (l, r) = map(int, input().split())
ll = list(map(int, input().split()))
rl = list(map(int, input().split()))
lsize = [0] * 41
rsize = [0] * 41
for l in ll:
lsize[l] += 1
for r in rl:
rsize[r] += 1
ans = 0
for i in range(10, 41):
ans += min(lsize[i], rsize[i])
print(ans) |
SIZE = 32
class Tile():
def __init__(self, collision=False, image=None, action_index=None):
self.collision = collision
self.image = image
self.action_index = action_index | size = 32
class Tile:
def __init__(self, collision=False, image=None, action_index=None):
self.collision = collision
self.image = image
self.action_index = action_index |
A = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
B = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
C = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
intercalada = []
contador = 0
for i in range(10):
intercalada.append(A[contador])
intercalada.append(B[contador])
intercalada.append(C[contador])
contador += 1
print(in... | a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
b = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
c = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
intercalada = []
contador = 0
for i in range(10):
intercalada.append(A[contador])
intercalada.append(B[contador])
intercalada.append(C[contador])
contador += 1
print(intercalada) |
# Python program to demonstrate working of
# Set in Python
# Creating two sets
set1 = set()
set2 = set()
# Adding elements to set1
for i in range(1, 6):
set1.add(i)
# Adding elements to set2
for i in range(3, 8):
set2.add(i)
set1.add(1)
print("Set1 = ", set1)
print("Set2 = ", set2)
print("\n")
#... | set1 = set()
set2 = set()
for i in range(1, 6):
set1.add(i)
for i in range(3, 8):
set2.add(i)
set1.add(1)
print('Set1 = ', set1)
print('Set2 = ', set2)
print('\n')
my_set = {1, 3, 4, 5, 6}
print(my_set)
my_set.discard(4)
print(my_set)
my_set.remove(6)
print(my_set)
my_set.discard(2)
print(my_set)
my_set = set('... |
'''
Copyright 2011 Acknack Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
dis... | """
Copyright 2011 Acknack Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
dis... |
# This is your Application's Configuration File.
# Make sure not to upload this file!
# Flask App Secret. Used for "session".
flaskSecret = "<generateKey>"
# Register your V1 app at https://portal.azure.com.
# Sign-On URL as <domain>/customer/login/authorized i.e. http://localhost:5000/customer/login/authorized
# Mak... | flask_secret = '<generateKey>'
client_id = '<GUID>'
client_secret = '<SECRET>'
aad_endpoint = 'https://login.microsoftonline.com/'
resource_arm = 'https://management.azure.com/'
resource_graph = 'https://graph.windows.net/'
api_version_graph = '1.6' |
def min4(*args):
min_ = args[0]
for item in args:
if item < min_:
min_ = item
return min_
a, b, c, d = int(input()), int(input()), int(input()), int(input())
print(min4(a, b, c, d))
| def min4(*args):
min_ = args[0]
for item in args:
if item < min_:
min_ = item
return min_
(a, b, c, d) = (int(input()), int(input()), int(input()), int(input()))
print(min4(a, b, c, d)) |
class Contender:
def __init__(self, names, values):
self.names = names
self.values = values
def __repr__(self):
strings = tuple(str(v.id()) for v in self.values)
return str(strings) + " contender"
def __lt__(self, other):
return self.values < other.values
def ... | class Contender:
def __init__(self, names, values):
self.names = names
self.values = values
def __repr__(self):
strings = tuple((str(v.id()) for v in self.values))
return str(strings) + ' contender'
def __lt__(self, other):
return self.values < other.values
de... |
def non_repeat(line):
ls = [line[i:j] for i in range(len(line))
for j in range(i+1, len(line)+1)
if len(set(line[i:j])) == j - i]
return max(ls, key=len, default='') | def non_repeat(line):
ls = [line[i:j] for i in range(len(line)) for j in range(i + 1, len(line) + 1) if len(set(line[i:j])) == j - i]
return max(ls, key=len, default='') |
first_number = int(input("Enter the first number(divisor): "))
second_number = int(input("Enter the second number(boundary): "))
for number in range(second_number, 0, -1):
if number % first_number == 0:
print(number)
break
| first_number = int(input('Enter the first number(divisor): '))
second_number = int(input('Enter the second number(boundary): '))
for number in range(second_number, 0, -1):
if number % first_number == 0:
print(number)
break |
n = int(input())
last = 1
lastlast = 0
print('0 1 ', end="")
for i in range(n-2):
now = last+lastlast
if i == n-3:
print('{}'.format(now))
else:
print('{} '.format(now), end="")
lastlast = last
last = now | n = int(input())
last = 1
lastlast = 0
print('0 1 ', end='')
for i in range(n - 2):
now = last + lastlast
if i == n - 3:
print('{}'.format(now))
else:
print('{} '.format(now), end='')
lastlast = last
last = now |
# -*- coding: utf-8 -*-
def main():
n = int(input())
dishes = list()
ans = 0
# See:
# https://poporix.hatenablog.com/entry/2019/01/28/222905
# https://misteer.hatenablog.com/entry/NIKKEI2019qual?_ga=2.121425408.962332021.1548821392-1201012407.1527836447
for i in range(n):
... | def main():
n = int(input())
dishes = list()
ans = 0
for i in range(n):
(ai, bi) = map(int, input().split())
dishes.append((ai, bi))
for (index, dish) in enumerate(sorted(dishes, key=lambda x: x[0] + x[1], reverse=True)):
if index % 2 == 0:
ans += dish[0]
... |
class Cell:
def __init__(self, x, y, entity = None, agent = None, dirty = False):
self.x = x
self.y = y
self.entity = entity
self.agent = agent
self.dirty = dirty
def set_entity(self, entity):
self.entity = entity
self.entity.x = self.x
self.entit... | class Cell:
def __init__(self, x, y, entity=None, agent=None, dirty=False):
self.x = x
self.y = y
self.entity = entity
self.agent = agent
self.dirty = dirty
def set_entity(self, entity):
self.entity = entity
self.entity.x = self.x
self.entity.y =... |
# Ann watched a TV program about health and learned that it is
# recommended to sleep at least A hours per day, but
# oversleeping is also not healthy, and you should not sleep more
# than B hours. Now Ann sleeps H hours per day. If Ann's sleep
# schedule complies with the requirements of that TV program -
# print "Nor... | (a, b, h) = (int(input()), int(input()), int(input()))
if h < a:
print('Deficiency')
elif h > b:
print('Excess')
else:
print('Normal') |
def menu():
simulation_name = "listWithOptionsOptimized"
use_existing = True
save_results = False
print("This project is made to train agents to fight each other\nThere is three types of agents\n-dummy : don't do anything\n-runner : just moving\n-killer : move and shoot\nWe are only using dummies and runners ... | def menu():
simulation_name = 'listWithOptionsOptimized'
use_existing = True
save_results = False
print("This project is made to train agents to fight each other\nThere is three types of agents\n-dummy : don't do anything\n-runner : just moving\n-killer : move and shoot\nWe are only using dummies and ru... |
my_set = {4, 2, 8, 5, 10, 11, 10} # seturile sunt neordonate
my_set2 = {9, 5, 77, 22, 98, 11, 10}
print(my_set)
# print(my_set[0:]) #nu se poate
lst = (11, 12, 12, 14, 15, 13, 14)
print(set(lst)) #eliminam duplicatele din lista prin transformarea in set
print(my_set.difference(my_set2))
print(my_set.intersection(my_... | my_set = {4, 2, 8, 5, 10, 11, 10}
my_set2 = {9, 5, 77, 22, 98, 11, 10}
print(my_set)
lst = (11, 12, 12, 14, 15, 13, 14)
print(set(lst))
print(my_set.difference(my_set2))
print(my_set.intersection(my_set2)) |
def make_weights_for_balanced_classes(images, nclasses):
count = [0] * nclasses
for item in images:
count[item[1]] += 1 ... | def make_weights_for_balanced_classes(images, nclasses):
count = [0] * nclasses
for item in images:
count[item[1]] += 1
weight_per_class = [0.0] * nclasses
n = float(sum(count))
for i in range(nclasses):
weight_per_class[i] = N / float(count[i])
weight = [0] * len(images)
for... |
'''
You own a Goal Parser that can interpret a string command.
The command consists of an alphabet of "G", "()" and/or
"(al)" in some order. The Goal Parser will interpret "G"
as the string "G", "()" as the string "o", and "(al)" as
the string "al". The interpreted strings are then
concaten... | """
You own a Goal Parser that can interpret a string command.
The command consists of an alphabet of "G", "()" and/or
"(al)" in some order. The Goal Parser will interpret "G"
as the string "G", "()" as the string "o", and "(al)" as
the string "al". The interpreted strings are then
concaten... |
def sequencia():
i = 0
j = 1
while i <= 2:
for aux in range(3):
if int(i) == i:
print(f'I={int(i)} J={int(j)}')
else:
print(f'I={i:.1f} J={j:.1f}')
j += 1
j = round(j - 3 + 0.2, 1)
i = round(i + 0.2, 1)
sequencia()... | def sequencia():
i = 0
j = 1
while i <= 2:
for aux in range(3):
if int(i) == i:
print(f'I={int(i)} J={int(j)}')
else:
print(f'I={i:.1f} J={j:.1f}')
j += 1
j = round(j - 3 + 0.2, 1)
i = round(i + 0.2, 1)
sequencia() |
def twoSum( nums, target: int):
#Vaule = {}.fromkeys
for i in range(len(nums)):
a = target - nums[i]
for j in range(i+1,len(nums),1):
if a == nums[j]:
return [i,j]
findSum = twoSum(nums = [1,2,3,4,5,6,8],target=14)
print(findSum)
| def two_sum(nums, target: int):
for i in range(len(nums)):
a = target - nums[i]
for j in range(i + 1, len(nums), 1):
if a == nums[j]:
return [i, j]
find_sum = two_sum(nums=[1, 2, 3, 4, 5, 6, 8], target=14)
print(findSum) |
# Tot's reward lv 50
sm.completeQuest(5522)
# Lv. 50 Equipment box
sm.giveItem(2430450, 1)
sm.dispose()
| sm.completeQuest(5522)
sm.giveItem(2430450, 1)
sm.dispose() |
class Board:
def __init__(self):
self.board = [0] * 9
def __getitem__(self, n):
return self.board[n]
def __setitem__(self, n, value):
self.board[n] = value
def __str__(self):
return "\n".join([
"".join([[" ", "o", "x"][j] for j in self.board[3*i:3*i+3]])
... | class Board:
def __init__(self):
self.board = [0] * 9
def __getitem__(self, n):
return self.board[n]
def __setitem__(self, n, value):
self.board[n] = value
def __str__(self):
return '\n'.join([''.join([[' ', 'o', 'x'][j] for j in self.board[3 * i:3 * i + 3]]) for i in... |
line = input()
words = line.split()
for word in words:
line = line.replace(word, word.capitalize())
print(line)
| line = input()
words = line.split()
for word in words:
line = line.replace(word, word.capitalize())
print(line) |
expected_output = {
'jid': {1: {'index': {1: {'data': 344,
'dynamic': 0,
'jid': 1,
'process': 'init',
'stack': 136,
'text': 296}}},
51: {'index': {1: {'data': 1027776,
'd... | expected_output = {'jid': {1: {'index': {1: {'data': 344, 'dynamic': 0, 'jid': 1, 'process': 'init', 'stack': 136, 'text': 296}}}, 51: {'index': {1: {'data': 1027776, 'dynamic': 5668, 'jid': 51, 'process': 'processmgr', 'stack': 136, 'text': 1372}}}, 53: {'index': {1: {'data': 342500, 'dynamic': 7095, 'jid': 53, 'proce... |
def primefactor(n):
for i in range(2,n+1):
if n%i==0:
isprime=1
for j in range(2,int(i/2+1)):
if i%j==0:
isprime=0
break
if isprime:
print(i)
n=315
primefactor(n)
... | def primefactor(n):
for i in range(2, n + 1):
if n % i == 0:
isprime = 1
for j in range(2, int(i / 2 + 1)):
if i % j == 0:
isprime = 0
break
if isprime:
print(i)
n = 315
primefactor(n) |
# Copyright (c) 2011 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.
{
'includes': [
'../../../build/common.gypi',
],
'variables': {
'common_sources': [
],
},
'targets' : [
{
'target_name':... | {'includes': ['../../../build/common.gypi'], 'variables': {'common_sources': []}, 'targets': [{'target_name': 'nosys_lib', 'type': 'none', 'variables': {'nlib_target': 'libnosys.a', 'build_glibc': 0, 'build_newlib': 1, 'build_pnacl_newlib': 1}, 'sources': ['access.c', 'chmod.c', 'chown.c', 'endpwent.c', 'environ.c', 'e... |
def is_leap(year):
if ( year >= 1900 and year <=100000):
leap = False
if ( (year % 4 == 0) and (year % 400 == 0 or year % 100 != 0) ):
leap = True
return leap
year = int(input())
print(is_leap(year))
| def is_leap(year):
if year >= 1900 and year <= 100000:
leap = False
if year % 4 == 0 and (year % 400 == 0 or year % 100 != 0):
leap = True
return leap
year = int(input())
print(is_leap(year)) |
# -*- coding: utf-8 -*-
def count_days(y, m, d):
return (365 * y + (y // 4) - (y // 100) + (y // 400) + ((306 * (m + 1)) // 10) + d - 429)
def main():
y = int(input())
m = int(input())
d = int(input())
if m == 1 or m == 2:
m += 12
y -= 1
print(count_days(201... | def count_days(y, m, d):
return 365 * y + y // 4 - y // 100 + y // 400 + 306 * (m + 1) // 10 + d - 429
def main():
y = int(input())
m = int(input())
d = int(input())
if m == 1 or m == 2:
m += 12
y -= 1
print(count_days(2014, 5, 17) - count_days(y, m, d))
if __name__ == '__main__... |
class CausalFactor:
def __init__(self, id_: int, name: str, description: str):
self.id_ = id_
self.name = name
self.description = description
class VehicleCausalFactor:
def __init__(self):
self.cf_driver = []
self.cf_fellow_passenger = []
self.cf_vehicle = []
... | class Causalfactor:
def __init__(self, id_: int, name: str, description: str):
self.id_ = id_
self.name = name
self.description = description
class Vehiclecausalfactor:
def __init__(self):
self.cf_driver = []
self.cf_fellow_passenger = []
self.cf_vehicle = []
... |
class Solution:
def numJewelsInStones(self, J: str, S: str) -> int:
result = 0
for i in set(J):
result += S.count(i)
return result | class Solution:
def num_jewels_in_stones(self, J: str, S: str) -> int:
result = 0
for i in set(J):
result += S.count(i)
return result |
class Indent:
def __init__(self, left: int = None, top: int = None, right: int = None, bottom: int = None):
self.left = left
self.top = top
self.right = right
self.bottom = bottom
| class Indent:
def __init__(self, left: int=None, top: int=None, right: int=None, bottom: int=None):
self.left = left
self.top = top
self.right = right
self.bottom = bottom |
drink = input()
sugar = input()
drinks_count = int(input())
if drink == "Espresso":
if sugar == "Without":
price = 0.90
elif sugar == "Normal":
price = 1
elif sugar == "Extra":
price = 1.20
elif drink == "Cappuccino":
if sugar == "Without":
price = 1
elif sugar == "N... | drink = input()
sugar = input()
drinks_count = int(input())
if drink == 'Espresso':
if sugar == 'Without':
price = 0.9
elif sugar == 'Normal':
price = 1
elif sugar == 'Extra':
price = 1.2
elif drink == 'Cappuccino':
if sugar == 'Without':
price = 1
elif sugar == 'Norm... |
n = int(input())
arr = [int(e) for e in input().split()]
ans = 0
for i in arr:
if i % 2 == 0:
ans += i / 4
else:
ans += i * 3
print("{:.1f}".format(ans))
| n = int(input())
arr = [int(e) for e in input().split()]
ans = 0
for i in arr:
if i % 2 == 0:
ans += i / 4
else:
ans += i * 3
print('{:.1f}'.format(ans)) |
# This exercise should be done in the interpreter
# Create a variable and assign it the string value of your first name,
# assign your age to another variable (you are free to lie!), print out a message saying how old you are
name = "John"
age = 21
print("my name is", name, "and I am", age, "years old.")
# Use the ... | name = 'John'
age = 21
print('my name is', name, 'and I am', age, 'years old.')
age += 10
print(name, 'will be', age, 'in 10 years.') |
def divide(num1, num2):
try:
num1 / num2
except Exception as e:
print(e)
divide(1, 0)
| def divide(num1, num2):
try:
num1 / num2
except Exception as e:
print(e)
divide(1, 0) |
class Automation(object):
def __init__(self, productivity, cost,numberOfAutomations, lifeSpan):
# self.annualHours = annualHours
self.productivity = float(productivity)
self.cost = float(cost)
self.lifeSpan = float(lifeSpan)
self.numberOfAutomations = float(numberOfAutomation... | class Automation(object):
def __init__(self, productivity, cost, numberOfAutomations, lifeSpan):
self.productivity = float(productivity)
self.cost = float(cost)
self.lifeSpan = float(lifeSpan)
self.numberOfAutomations = float(numberOfAutomations)
def production(self):
r... |
# coding=utf-8
DBcsvName = 'houseinfo_readable_withXY'
with open(DBcsvName + '.csv', 'r', encoding='UTF-8') as f:
lines = f.readlines()
print(lines[0])
with open(DBcsvName + '_correct.csv', 'w', encoding='UTF-8') as fw:
fw.write(
"houseID" + "," + "title" + "," + "link" + "," + "community" + "," ... | d_bcsv_name = 'houseinfo_readable_withXY'
with open(DBcsvName + '.csv', 'r', encoding='UTF-8') as f:
lines = f.readlines()
print(lines[0])
with open(DBcsvName + '_correct.csv', 'w', encoding='UTF-8') as fw:
fw.write('houseID' + ',' + 'title' + ',' + 'link' + ',' + 'community' + ',' + 'years' + ',' + 'houset... |
class Node():
def __init__(self, val, left, right):
self.val = val
self.left = left
self.right = right
def collect(node, data, depth = 0):
if not node:
return None
if depth not in data:
data[depth] = []
data[depth].append(node.val)
collect(node.left, data, depth + 1)
collect(node.rig... | class Node:
def __init__(self, val, left, right):
self.val = val
self.left = left
self.right = right
def collect(node, data, depth=0):
if not node:
return None
if depth not in data:
data[depth] = []
data[depth].append(node.val)
collect(node.left, data, depth... |
ques=input('Do you wish to find the Volume of Cube by 2D Method or via Side Method? Please enter either 2D or Side')
if ques=='2D':
print ('OK.')
ba=int(input('Enter the Base Area of the Cube'))
Height=int(input('Enter a Height measure'))
v=ba*Height
print ('Volume of the Cube is', v)
elif qu... | ques = input('Do you wish to find the Volume of Cube by 2D Method or via Side Method? Please enter either 2D or Side')
if ques == '2D':
print('OK.')
ba = int(input('Enter the Base Area of the Cube'))
height = int(input('Enter a Height measure'))
v = ba * Height
print('Volume of the Cube is', v)
elif... |
#!/usr/bin/env python3
class Solution:
def fizzBuzz(self, n: int):
res = []
for i in range(1, n+1):
if i % 15 == 0:
res.append('FizzBuzz')
elif i % 3 == 0:
res.append('Fizz')
elif i % 5 == 0:
res.append('Buzz')
... | class Solution:
def fizz_buzz(self, n: int):
res = []
for i in range(1, n + 1):
if i % 15 == 0:
res.append('FizzBuzz')
elif i % 3 == 0:
res.append('Fizz')
elif i % 5 == 0:
res.append('Buzz')
else:
... |
#!/usr/bin/python3
accesses = {}
with open('download.log') as f:
for line in f:
splitted_line = line.split(',')
if len(splitted_line) != 2:
continue
[file_path, ip_addr] = splitted_line
if file_path not in accesses:
accesses[file_path] = []
... | accesses = {}
with open('download.log') as f:
for line in f:
splitted_line = line.split(',')
if len(splitted_line) != 2:
continue
[file_path, ip_addr] = splitted_line
if file_path not in accesses:
accesses[file_path] = []
if ip_addr not in accesses[fil... |
'''
This module contains all the configurations needed by
the modules in the etl package
'''
# import os
# from definitions import ROOT_DIR
TRANSFORMED_DATA_DB_CONFIG = {
'user': 'root',
'password': 'xxxxxxxxxxxx',
'host': '35.244.x.xxx',
'port': 3306,
'database': 'transformed_data'
#... | """
This module contains all the configurations needed by
the modules in the etl package
"""
transformed_data_db_config = {'user': 'root', 'password': 'xxxxxxxxxxxx', 'host': '35.244.x.xxx', 'port': 3306, 'database': 'transformed_data'} |
file_name = input('Enter file name: ')
fn = open(file_name)
count = 0
for line in fn:
words = line.strip().split()
try:
if words[0] == 'From':
print(words[1])
count += 1
except IndexError:
pass
print(f'There were {count} lines in the file with From as the first word')... | file_name = input('Enter file name: ')
fn = open(file_name)
count = 0
for line in fn:
words = line.strip().split()
try:
if words[0] == 'From':
print(words[1])
count += 1
except IndexError:
pass
print(f'There were {count} lines in the file with From as the first word') |
# -*- coding: utf-8 -*-
class GeneratorRegister(object):
def __init__(self):
self.generators = []
def register(self, obj):
self.generators.append(obj)
def generate(self, command=None):
for generator in self.generators:
if command is not None and command.verbosity > 1:
command.stdout.write('\nGeneratin... | class Generatorregister(object):
def __init__(self):
self.generators = []
def register(self, obj):
self.generators.append(obj)
def generate(self, command=None):
for generator in self.generators:
if command is not None and command.verbosity > 1:
command.... |
class CoOccurrence:
def __init__(self, entity: str, score: float, entity_type: str = None):
self.entity = entity
self.score = score
self.entity_type = entity_type
def __repr__(self):
return f'{self.entity} - {self.entity_type} ({self.score})'
def as_dict(self):
d = ... | class Cooccurrence:
def __init__(self, entity: str, score: float, entity_type: str=None):
self.entity = entity
self.score = score
self.entity_type = entity_type
def __repr__(self):
return f'{self.entity} - {self.entity_type} ({self.score})'
def as_dict(self):
d = d... |
year = int(input())
if year % 4 == 0 and not (year % 100 == 0):
print("Leap")
else:
if year % 400 == 0:
print("Leap")
else:
print("Ordinary")
| year = int(input())
if year % 4 == 0 and (not year % 100 == 0):
print('Leap')
elif year % 400 == 0:
print('Leap')
else:
print('Ordinary') |
class ChatRoom:
def __init__(self):
self.people = []
def broadcast(self, source, message):
for p in self.people:
if p.name != source:
p.receive(source, message)
def join(self, person):
join_msg = f'{person.name} joins the chat'
self.broadcast('ro... | class Chatroom:
def __init__(self):
self.people = []
def broadcast(self, source, message):
for p in self.people:
if p.name != source:
p.receive(source, message)
def join(self, person):
join_msg = f'{person.name} joins the chat'
self.broadcast('r... |
class LinkedList:
def __init__(self):
self.head = None
def insert(self, value):
self.head = Node(value, self.head)
def append(self, value):
new_node = Node(value)
current = self.head
if current == None:
self.head = new_node
elif current... | class Linkedlist:
def __init__(self):
self.head = None
def insert(self, value):
self.head = node(value, self.head)
def append(self, value):
new_node = node(value)
current = self.head
if current == None:
self.head = new_node
elif current.next == ... |
#
# Explore
# - The Adventure Interpreter
#
# Copyright (C) 2006 Joe Peterson
#
class ItemContainer:
def __init__(self):
self.items = []
self.item_limit = None
def has_no_items(self):
return len(self.items) == 0
def has_item(self, item):
return item in self... | class Itemcontainer:
def __init__(self):
self.items = []
self.item_limit = None
def has_no_items(self):
return len(self.items) == 0
def has_item(self, item):
return item in self.items
def is_full(self):
if self.item_limit == None or len(self.items) < self.item... |
#!/usr/bin/python3
a = sum(range(100))
print(a)
| a = sum(range(100))
print(a) |
WINDOW_TITLE = "ElectriPy"
HEIGHT = 750
WIDTH = 750
RESIZABLE = True
FPS = 40
DEFAULT_FORCE_VECTOR_SCALE_FACTOR = 22e32
DEFAULT_EF_VECTOR_SCALE_FACTOR = 2e14
DEFAULT_EF_BRIGHTNESS = 105
DEFAULT_SPACE_BETWEEN_EF_VECTORS = 20
MINIMUM_FORCE_VECTOR_NORM = 10
MINIMUM_ELECTRIC_FIELD_VECTOR_NORM = 15
KEYS = {
"clear_scre... | window_title = 'ElectriPy'
height = 750
width = 750
resizable = True
fps = 40
default_force_vector_scale_factor = 2.2e+33
default_ef_vector_scale_factor = 200000000000000.0
default_ef_brightness = 105
default_space_between_ef_vectors = 20
minimum_force_vector_norm = 10
minimum_electric_field_vector_norm = 15
keys = {'c... |
# Multiples of 3 and 5
# Problem 1
# If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.
# The sum of these multiples is 23.
# Find the sum of all the multiples of 3 or 5 below 1000
def solution(limit):
s = 0
for x in range(1, limit):
if x % 3 == 0:
... | def solution(limit):
s = 0
for x in range(1, limit):
if x % 3 == 0:
s = s + x
elif x % 5 == 0:
s = s + x
return s
def main():
limit = 1000
ans = solution(limit)
print(ans)
if __name__ == '__main__':
main() |
class Index:
def set_index(self, index_name):
self.index = index_name
def mapping(self):
return {
self.doc_type:{
"properties":self.properties()
}
}
def analysis(self):
return {
'filter':{
'spanish_stop'... | class Index:
def set_index(self, index_name):
self.index = index_name
def mapping(self):
return {self.doc_type: {'properties': self.properties()}}
def analysis(self):
return {'filter': {'spanish_stop': {'type': 'stop', 'stopwords': '_spanish_'}, 'spanish_stemmer': {'type': 'stemme... |
'''
Encontrar el valor repetido de
'''
lista =[1,2,2,3,1,5,6,1]
for number in lista:
if lista.count(number) > 1:
i = lista.index(number)
print(i)
lista_dos = ["a", "b", "a", "c", "c"]
mylist = list(dict.fromkeys(lista_dos))
print(mylist)
print("*"*10)
| """
Encontrar el valor repetido de
"""
lista = [1, 2, 2, 3, 1, 5, 6, 1]
for number in lista:
if lista.count(number) > 1:
i = lista.index(number)
print(i)
lista_dos = ['a', 'b', 'a', 'c', 'c']
mylist = list(dict.fromkeys(lista_dos))
print(mylist)
print('*' * 10) |
# 969. Pancake Sorting
class Solution:
def pancakeSort2(self, A):
ans, n = [], len(A)
B = sorted(range(1, n+1), key=lambda i: -A[i-1])
for i in B:
for f in ans:
if i <= f:
i = f + 1 - i
ans.extend([i, n])
n -= 1... | class Solution:
def pancake_sort2(self, A):
(ans, n) = ([], len(A))
b = sorted(range(1, n + 1), key=lambda i: -A[i - 1])
for i in B:
for f in ans:
if i <= f:
i = f + 1 - i
ans.extend([i, n])
n -= 1
return ans
... |
## Logging
logging_config = {
'console_log_enabled': True,
'console_log_level': 25, # SPECIAL
'console_fmt': '[%(asctime)s] %(message)s',
'console_datefmt': '%y-%m-%d %H:%M:%S',
##
'file_log_enabled': True,
'file_log_level': 15, # VERBOSE
'file_fmt': '%(asctime)s %(levelname)-8s %(nam... | logging_config = {'console_log_enabled': True, 'console_log_level': 25, 'console_fmt': '[%(asctime)s] %(message)s', 'console_datefmt': '%y-%m-%d %H:%M:%S', 'file_log_enabled': True, 'file_log_level': 15, 'file_fmt': '%(asctime)s %(levelname)-8s %(name)s: %(message)s', 'file_datefmt': '%y-%m-%d %H:%M:%S', 'log_dir': 'lo... |
# coding:utf-8
'''
@Copyright:LintCode
@Author: taoleetju
@Problem: http://www.lintcode.com/problem/find-minimum-in-rotated-sorted-array
@Language: Python
@Datetime: 15-12-14 03:26
'''
class Solution:
# @param num: a rotated sorted array
# @return: the minimum number in the array
def findMin(self, nu... | """
@Copyright:LintCode
@Author: taoleetju
@Problem: http://www.lintcode.com/problem/find-minimum-in-rotated-sorted-array
@Language: Python
@Datetime: 15-12-14 03:26
"""
class Solution:
def find_min(self, num):
p1 = 0
p2 = len(num) - 1
pm = p1
while num[p1] >= num[p2]:
... |
# These constants are all possible fields in a message.
ADDRESS_FAMILY = 'address_family'
ADDRESS_FAMILY_IPv4 = 'ipv4'
ADDRESS_FAMILY_IPv6 = 'ipv6'
CITY = 'city'
COUNTRY = 'country'
RESPONSE_FORMAT = 'format'
FORMAT_HTML = 'html'
FORMAT_JSON = 'json'
FORMAT_MAP = 'map'
FORMAT_REDIRECT = 'redirect'
FORMAT_BT = 'bt'
VA... | address_family = 'address_family'
address_family_i_pv4 = 'ipv4'
address_family_i_pv6 = 'ipv6'
city = 'city'
country = 'country'
response_format = 'format'
format_html = 'html'
format_json = 'json'
format_map = 'map'
format_redirect = 'redirect'
format_bt = 'bt'
valid_formats = [FORMAT_HTML, FORMAT_JSON, FORMAT_MAP, FOR... |
def f():
x = 5
def g(y):
print (x + y)
g(1)
x = 6
g(1)
x = 7
g(1)
f()
| def f():
x = 5
def g(y):
print(x + y)
g(1)
x = 6
g(1)
x = 7
g(1)
f() |
# Python program to insert, delete and search in binary search tree using linked lists
# A Binary Tree Node
class Node:
# Constructor to create a new node
def __init__(self, key):
self.key = key
self.left = None
self.right = None
# A utility function to do inorder traversal of BST
... | class Node:
def __init__(self, key):
self.key = key
self.left = None
self.right = None
def inorder(root):
if root is not None:
inorder(root.left)
print(root.key, end=', ')
inorder(root.right)
def insert(node, key):
if node is None:
return node(key)
... |
def keyword_argument_example(your_age, **kwargs):
return your_age, kwargs
### Write your code below this line ###
about_me = "Replace this string with the correct function call."
### Write your code above this line ###
print(about_me)
| def keyword_argument_example(your_age, **kwargs):
return (your_age, kwargs)
about_me = 'Replace this string with the correct function call.'
print(about_me) |
#MAP
# def fahrenheit(T):
# return (9/5) * T + 32
temp = [9,22,40,90,120]
# for t in temp:
# print(fahrenheit(t))
# print(list(map(fahrenheit, temp)))
# print(list(map(lambda t:(9/5)*t+32,temp)))
#FILTER
pares = [1,2,3,4,8,10,11,15,16,28,24,20]
# print(list(filter(lambda x: x%2 == 0, pares)))
#ZIP
x = ... | temp = [9, 22, 40, 90, 120]
pares = [1, 2, 3, 4, 8, 10, 11, 15, 16, 28, 24, 20]
x = [1, 2, 3, 4, 87, 65, 84, 87, 96, 258]
y = [4, 5, 6, 256, 245, 635, 85, 96, 256, 485]
a = [1, 2, 3, 5, 5, 2]
b = [2, 3, 25, 2]
c = [2, 4, 2, 5]
lista = ['a', 'b', 'c', 'd']
teste = 'How long are the words in this phrase'
def word_length... |
#
# PySNMP MIB module RSVP-MIB (http://pysnmp.sf.net)
# ASN.1 source http://mibs.snmplabs.com:80/asn1/RSVP-MIB
# Produced by pysmi-0.0.7 at Sun Feb 14 00:27:32 2016
# On host bldfarm platform Linux version 4.1.13-100.fc21.x86_64 by user goose
# Using Python version 3.5.0 (default, Jan 5 2016, 17:11:52)
#
( ObjectIden... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, value_size_constraint, single_value_constraint, constraints_intersection, constraints_union) ... |
# Implemente uma nova classe que simule uma pilha usando apenas duas filas.
class Node:
def __init__(self, data, next=None):
self.data = data
self.next = next
class MyQueue:
def __init__(self):
self.head = None
self.tail = self.head
def enqueue(self, value):
if (se... | class Node:
def __init__(self, data, next=None):
self.data = data
self.next = next
class Myqueue:
def __init__(self):
self.head = None
self.tail = self.head
def enqueue(self, value):
if self.head:
new_node = node(value)
self.tail.next = new... |
'''
199. Binary Tree Right Side View Medium
Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.
Example 1:
Input: root = [1,2,3,null,5,null,4]
Output: [1,3,4]
Example 2:
Input: root = [1,null,3]
Output: [1,3]
E... | """
199. Binary Tree Right Side View Medium
Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.
Example 1:
Input: root = [1,2,3,null,5,null,4]
Output: [1,3,4]
Example 2:
Input: root = [1,null,3]
Output: [1,3]
E... |
class Content():
def __init__(self):
self.content_type = "video"
self.title = "sample title"
self.author = {"url": "", "name": "James"}
self.time_estimate = "(15 min)"
self.url = "http://mim-rec-engine.heroku.com"
self.thumbnail_url = "static/imgs/document.png"
... | class Content:
def __init__(self):
self.content_type = 'video'
self.title = 'sample title'
self.author = {'url': '', 'name': 'James'}
self.time_estimate = '(15 min)'
self.url = 'http://mim-rec-engine.heroku.com'
self.thumbnail_url = 'static/imgs/document.png'
... |
__author__ = 'hs634'
class Solution():
def __init__(self):
pass
def three_sum_zero(self, arr):
arr, solution, i = sorted(arr), [], 0
while i < len(arr) - 2:
j, k = i + 1, len(arr) - 1
while j < k:
three_sum = arr[i] + arr[j] + arr[k]
... | __author__ = 'hs634'
class Solution:
def __init__(self):
pass
def three_sum_zero(self, arr):
(arr, solution, i) = (sorted(arr), [], 0)
while i < len(arr) - 2:
(j, k) = (i + 1, len(arr) - 1)
while j < k:
three_sum = arr[i] + arr[j] + arr[k]
... |
class Solution:
def merge(self, A, m, B, n):
sm, sn, i = m - 1, n - 1, m + n - 1
while sm >= 0 and sn >= 0:
if A[sm] > B[sn]:
A[i] = A[sm]
sm -= 1
else:
A[i] = B[sn]
sn -= 1
i -= 1
while sn >... | class Solution:
def merge(self, A, m, B, n):
(sm, sn, i) = (m - 1, n - 1, m + n - 1)
while sm >= 0 and sn >= 0:
if A[sm] > B[sn]:
A[i] = A[sm]
sm -= 1
else:
A[i] = B[sn]
sn -= 1
i -= 1
while ... |
class TasksService:
def __init__(self, site):
self.__site = site
self.__is_loaded = False
def load(self):
self.__is_loaded = True
| class Tasksservice:
def __init__(self, site):
self.__site = site
self.__is_loaded = False
def load(self):
self.__is_loaded = True |
class Recipe(object):
def __init__(self):
self.ingredients = [] # need to store lots of qty & unit & ingred per recipe. will be ordered triple
self.directions = "" # how to make this food
self.notes = "" # personal annotations re: this recipe
self.recipe_name = "" # what's in a ... | class Recipe(object):
def __init__(self):
self.ingredients = []
self.directions = ''
self.notes = ''
self.recipe_name = ''
self.synopsis = ''
self.uses = 0
self.source = ''
self.labels = []
def add_ingredient(self, qty, unit, name):
self.... |
class GetTableInteractor(object):
def __init__(self, repo):
self.repo = repo
def set_params(self, user, year, month, before, after):
self.user = user
self.year = year
self.month = month
self.before = before
self.after = after
return self
def exec... | class Gettableinteractor(object):
def __init__(self, repo):
self.repo = repo
def set_params(self, user, year, month, before, after):
self.user = user
self.year = year
self.month = month
self.before = before
self.after = after
return self
def execute... |
# AUTOGENERATED! DO NOT EDIT! File to edit: 13_dataproc.ipynb (unless otherwise specified).
__all__ = ['dataproc_test']
# Cell
def dataproc_test(test_msg):
"Function dataproc"
return test_msg | __all__ = ['dataproc_test']
def dataproc_test(test_msg):
"""Function dataproc"""
return test_msg |
todos = [
{
'id': 1,
'title': 'Workout tomorrow',
'body': 'I intend to go through some rigorous exercise targetting my abs and my lower stomach',
'completed': False,
'date': '08/12/2019'
},
{
'id': 2,
'title': 'Chefs Quaters',
'body': 'I intend... | todos = [{'id': 1, 'title': 'Workout tomorrow', 'body': 'I intend to go through some rigorous exercise targetting my abs and my lower stomach', 'completed': False, 'date': '08/12/2019'}, {'id': 2, 'title': 'Chefs Quaters', 'body': 'I intend to cook Rice with vegetables and also garnish it with some fried chicken', 'com... |
class Solution:
def combine(self, n: int, k: int) -> List[List[int]]:
ans = []
def dfs(n: int, k: int, s: int, path: List[int]) -> None:
if k == 0:
ans.append(path.copy())
return
for i in range(s, n + 1):
path.append(i)
dfs(n, k - 1, i + 1, path)
path.pop(... | class Solution:
def combine(self, n: int, k: int) -> List[List[int]]:
ans = []
def dfs(n: int, k: int, s: int, path: List[int]) -> None:
if k == 0:
ans.append(path.copy())
return
for i in range(s, n + 1):
path.append(i)
... |
# -----------
# User Instructions:
#
# Modify the the search function so that it returns
# a shortest path as follows:
#
# [['>', 'v', ' ', ' ', ' ', ' '],
# [' ', '>', '>', '>', '>', 'v'],
# [' ', ' ', ' ', ' ', ' ', 'v'],
# [' ', ' ', ' ', ' ', ' ', 'v'],
# [' ', ' ', ' ', ' ', ' ', '*']]
#
# Where '>', '<', '^',... | grid = [[0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0]]
init = [0, 0]
goal = [len(grid) - 1, len(grid[0]) - 1]
cost = 1
delta = [[-1, 0], [0, -1], [1, 0], [0, 1]]
delta_name = ['^', '<', 'v', '>']
def search(grid, init, goal, cost):
closed = [[-1 for row in range... |
def add_numbers(start,end):
c = 0
for number in range(start,end+1):
print(number)
c = c + number
return(c)
answer = add_numbers(333,777)
#print(answer)
#print(add_numbers())
#add_numbers()
| def add_numbers(start, end):
c = 0
for number in range(start, end + 1):
print(number)
c = c + number
return c
answer = add_numbers(333, 777) |
# CELERY
CELERY_BROKER_URL = 'redis://10.16.78.86:6380'
CELERY_RESULT_BACKEND = 'redis://10.16.78.86:6380'
# NGINX STATIC HOME
DOC_HOME = '/opt/data'
# Flask-Log Settings
LOG_LEVEL = 'debug'
LOG_FILENAME = "/var/archives/error.log"
LOG_ENABLE_CONSOLE = False
# REDIS Settings
REDIS_HOST = '10.16.78.86'... | celery_broker_url = 'redis://10.16.78.86:6380'
celery_result_backend = 'redis://10.16.78.86:6380'
doc_home = '/opt/data'
log_level = 'debug'
log_filename = '/var/archives/error.log'
log_enable_console = False
redis_host = '10.16.78.86'
redis_port = 6383 |
X = [[12,7,3],
[4,5,6],
[7,8,9]]
Y = [[5,8,1],
[6,7,3],
[4,5,9]]
result = [[0,0,0],
[0,0,0],
[0,0,0]]
print(len(X),len(Y))
# iterate through rows
for i in range(0,3):
# iterate through columns
for j in range(0,3):
result[i][j] = X[i][j] + Y[i][j]
for r in result:
pr... | x = [[12, 7, 3], [4, 5, 6], [7, 8, 9]]
y = [[5, 8, 1], [6, 7, 3], [4, 5, 9]]
result = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
print(len(X), len(Y))
for i in range(0, 3):
for j in range(0, 3):
result[i][j] = X[i][j] + Y[i][j]
for r in result:
print(r) |
#!/bin/python3
annee_naissance = input('t ne ou ')
annee = 2025 - int(annee_naissance)
print(annee)
print(f'voila : {str(annee)} pewepw')
| annee_naissance = input('t ne ou ')
annee = 2025 - int(annee_naissance)
print(annee)
print(f'voila : {str(annee)} pewepw') |
# Python program to demonstrate in-built poly-
# morphic functions
# len() being used for a string
print(len("geeks"))
# len() being used for a list
print(len([10, 20, 30])) | print(len('geeks'))
print(len([10, 20, 30])) |
class Solution:
def isOneBitCharacter(self, bits):
if len(bits) == 1:
return True
idx = 0
while True:
if idx == len(bits) - 3 or idx == len(bits) - 2:
break
if bits[idx] == 1:
idx += 2
else:
idx +... | class Solution:
def is_one_bit_character(self, bits):
if len(bits) == 1:
return True
idx = 0
while True:
if idx == len(bits) - 3 or idx == len(bits) - 2:
break
if bits[idx] == 1:
idx += 2
else:
i... |
# S E
# array = [8, 5, 2, 8, 5, 6, 3]
# P L R
# if s >= e : r
# assigning p, l, r -variables
# while r >= e
# if l >= p & r <= p
# swap
# l <= p - l+
# r >= p - r-
# leftsubarrayissmaller = r - 1 - s < e - (r + 1)
# (p , s, r - 1)
# (p, r + 1, e)
# Worst : time - O(n^2),Space- O(log(n)) # in inp... | def quick_sort(array):
quick_sort_helper(array, 0, len(array) - 1)
return array
def quick_sort_helper(array, startIdx, endIdx):
if startIdx >= endIdx:
return
pivot_idx = startIdx
left_idx = startIdx + 1
right_idx = endIdx
while rightIdx >= leftIdx:
if array[leftIdx] > array[... |
def palindrome(n):
a0=n
s=0
while a0>0:
d=a0%10
s=s*10+d
a0=a0//10
if s==n:
return 1
else:
return 0
n=int(input("Enter a number "))
if palindrome(n)==1:
print("palindrome ...")
else:
print("Not palindrome..") | def palindrome(n):
a0 = n
s = 0
while a0 > 0:
d = a0 % 10
s = s * 10 + d
a0 = a0 // 10
if s == n:
return 1
else:
return 0
n = int(input('Enter a number '))
if palindrome(n) == 1:
print('palindrome ...')
else:
print('Not palindrome..') |
class Bicycle:
def __init__(self, name, wheel_numbers, brake_type, gear_number):
self.name = name
self.wheel_numbers = wheel_numbers
self.brake_type = brake_type
self.gear_number = gear_number
bicycle = Bicycle('single speed', '2', 'rim brake', 'free wheel')
print(bicycle.n... | class Bicycle:
def __init__(self, name, wheel_numbers, brake_type, gear_number):
self.name = name
self.wheel_numbers = wheel_numbers
self.brake_type = brake_type
self.gear_number = gear_number
bicycle = bicycle('single speed', '2', 'rim brake', 'free wheel')
print(bicycle.name)
prin... |
CELERY_IMPORTS=("app", )
CELERY_BROKER_URL="amqp://saket:fedora13@localhost//"
CELERY_RESULT_BACKEND="amqp://saket:fedora13@localhost//"
SQLALCHEMY_DATABASE_URI="mysql://saket:fedora13@localhost/moca"
CELERYD_MAX_TASKS_PER_CHILD=10
| celery_imports = ('app',)
celery_broker_url = 'amqp://saket:fedora13@localhost//'
celery_result_backend = 'amqp://saket:fedora13@localhost//'
sqlalchemy_database_uri = 'mysql://saket:fedora13@localhost/moca'
celeryd_max_tasks_per_child = 10 |
class Restaurant:
def __init__(self):
self.restaurant = []
def update_location(self):
pass
def add(self, restaurant):
self.restaurant.append(restaurant)
| class Restaurant:
def __init__(self):
self.restaurant = []
def update_location(self):
pass
def add(self, restaurant):
self.restaurant.append(restaurant) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.