content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
setup(
name='pyroll',
description='cli for simulating the rolling of dice',
author='Philip Z Nevill',
author_email='pznevill.dev@gmail.com',
version='0.1.0',
packages=find_packages(include=['pyroll', 'pyroll.*']),
)
| setup(name='pyroll', description='cli for simulating the rolling of dice', author='Philip Z Nevill', author_email='pznevill.dev@gmail.com', version='0.1.0', packages=find_packages(include=['pyroll', 'pyroll.*'])) |
def calculation(filepath,down,across):
with open(filepath) as file:
rows = [x.strip() for x in file.readlines()]
end = len(rows)
currentrow = 0
currentcolumn = 0
count = 0
while currentrow < (end-1):
currentrow = currentrow+down
currentcolumn = (currentcolumn+acr... | def calculation(filepath, down, across):
with open(filepath) as file:
rows = [x.strip() for x in file.readlines()]
end = len(rows)
currentrow = 0
currentcolumn = 0
count = 0
while currentrow < end - 1:
currentrow = currentrow + down
currentcolumn = (currentcolumn + across... |
class Student:
def __init__(self, firstname, lastname, major, gpa):
self.firstname = firstname
self.lastname = lastname
self.major = major
self.gpa = gpa
@property # property decorator # access this method as an attribute
def fullname(self):
return f'{self.firstname} {self.lastname}'
@fullname.setter # ... | class Student:
def __init__(self, firstname, lastname, major, gpa):
self.firstname = firstname
self.lastname = lastname
self.major = major
self.gpa = gpa
@property
def fullname(self):
return f'{self.firstname} {self.lastname}'
@fullname.setter
def fullname(... |
{
"targets": [
{
"target_name": "simpleTest",
"sources": [ "simpleTest.cc" ]
},
{
"target_name": "simpleTest2",
"sources": [ "simpleTest.cc" ]
},
{
"target_name": "simpleTest3",
"sources": [ "simpleTest.cc" ]
}
]
} | {'targets': [{'target_name': 'simpleTest', 'sources': ['simpleTest.cc']}, {'target_name': 'simpleTest2', 'sources': ['simpleTest.cc']}, {'target_name': 'simpleTest3', 'sources': ['simpleTest.cc']}]} |
# =============================================================================
# Author: Teerapat Jenrungrot - https://github.com/mjenrungrot/
# FileName: 12700.py
# Description: UVa Online Judge - 12700
# =============================================================================
def run():... | def run():
n = int(input())
line = input()
count_b = sum(map(lambda x: x == 'B', line))
count_w = sum(map(lambda x: x == 'W', line))
count_t = sum(map(lambda x: x == 'T', line))
if countT == 0 and countW == 0 and (countB == 0):
print('ABANDONED')
elif countT == 0 and countW == 0 and ... |
DEBUG = True
PORT = 5000
UPLOAD_FOLDER = 'sacapp/static/tmp'
MODEL_FOLDER = 'model/'
DRUG2ID_FILE = 'model/drug2id.txt'
GENE2ID_FILE = 'model/gene2idx.txt'
IC50_DRUGS_FILE = 'model/ic50_drugid.txt'
IC50_DRUG2ID_FILE = 'model/ic50_drug2idx.txt'
IC50_GENES_FILE = 'model/ic50_genes.txt'
PERT_DRUGS_FILE = 'model/pert_drugi... | debug = True
port = 5000
upload_folder = 'sacapp/static/tmp'
model_folder = 'model/'
drug2_id_file = 'model/drug2id.txt'
gene2_id_file = 'model/gene2idx.txt'
ic50_drugs_file = 'model/ic50_drugid.txt'
ic50_drug2_id_file = 'model/ic50_drug2idx.txt'
ic50_genes_file = 'model/ic50_genes.txt'
pert_drugs_file = 'model/pert_dr... |
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'Point of Sale',
'version': '1.0.1',
'category': 'Sales/Point of Sale',
'sequence': 40,
'summary': 'User-friendly PoS interface for shops and restaurants',
'description': "",
'depend... | {'name': 'Point of Sale', 'version': '1.0.1', 'category': 'Sales/Point of Sale', 'sequence': 40, 'summary': 'User-friendly PoS interface for shops and restaurants', 'description': '', 'depends': ['stock_account', 'barcodes', 'web_editor', 'digest'], 'data': ['security/point_of_sale_security.xml', 'security/ir.model.acc... |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = "Dexter Scott Belmont"
__credits__ = [ "Dexter Scott Belmont" ]
__tags__ = [ "Maya", "Virus", "Removal" ]
__license__ = "MIT"
__version__ = "0.1"
__maintainer__ = "Dexter Scott Belmont"
__email__ = "dexter@kerneloid.com"
__status__ = "alpha"
#jobs = cmds.sc... | __author__ = 'Dexter Scott Belmont'
__credits__ = ['Dexter Scott Belmont']
__tags__ = ['Maya', 'Virus', 'Removal']
__license__ = 'MIT'
__version__ = '0.1'
__maintainer__ = 'Dexter Scott Belmont'
__email__ = 'dexter@kerneloid.com'
__status__ = 'alpha'
found = False
for job in cmds.scriptJob(lj=True):
if 'leukocyte.a... |
__all__ = ['Mine']
class Mine(object):
'''A mine object.
Attributes:
x (int): the mine position in X.
y (int): the mine position in Y.
owner (int): the hero's id that owns this mine.
'''
def __init__(self, x, y):
'''Constructor.
Args:
x (in... | __all__ = ['Mine']
class Mine(object):
"""A mine object.
Attributes:
x (int): the mine position in X.
y (int): the mine position in Y.
owner (int): the hero's id that owns this mine.
"""
def __init__(self, x, y):
"""Constructor.
Args:
x (int): ... |
INVALID_EMAIL = "invalid_email"
INVALID_EMAIL_CHANGE = "invalid_email_change"
MISSING_EMAIL = "missing_email"
MISSING_NATIONALITY = "missing_nationality"
DUPLICATE_EMAIL = "unique"
REQUIRED = "required"
INVALID_SUBSCRIBE_TO_EMPTY_EMAIL = "invalid_subscribe_to_empty_email"
| invalid_email = 'invalid_email'
invalid_email_change = 'invalid_email_change'
missing_email = 'missing_email'
missing_nationality = 'missing_nationality'
duplicate_email = 'unique'
required = 'required'
invalid_subscribe_to_empty_email = 'invalid_subscribe_to_empty_email' |
min_temp = None
max_temp = None
# factor = 2.25
factor = 0
HUE_MAX = 240 / 360
HUE_MIN = 0
HUE_GOOD = 120 / 360
HUE_WARNING = 50/360
HUE_DANGER = 0
#comfort ranges
TEMP_LOW = 16
TEMP_HIGH = 24
HUMIDITY_LOW = 30
HUMIDITY_HIGHT = 60 | min_temp = None
max_temp = None
factor = 0
hue_max = 240 / 360
hue_min = 0
hue_good = 120 / 360
hue_warning = 50 / 360
hue_danger = 0
temp_low = 16
temp_high = 24
humidity_low = 30
humidity_hight = 60 |
MAX_PIXEL_VALUE = 255
LAPLAS_FACTOR = 0.5
LAPLAS_1 = [[0,1,0],[1,-4,1],[0,1,0]]
LAPLAS_2 = [[1,1,1],[1,-8,1],[1,1,1]]
LAPLAS_3 = [[0,-1,0],[-1,4,-1],[0,-1,0]]
LAPLAS_4 = [[-1,-1,-1],[-1,8,-1],[-1,-1,-1]]
LAPLAS_5 = [[0,-1,0],[-1,5,-1],[0,-1,0]]
LAPLAS_6 = [[-1,-1,-1],[-1,9,-1],[-1,-1,-1]]
LAPLAS_7 = [[0,-1,0],[-1,LAPL... | max_pixel_value = 255
laplas_factor = 0.5
laplas_1 = [[0, 1, 0], [1, -4, 1], [0, 1, 0]]
laplas_2 = [[1, 1, 1], [1, -8, 1], [1, 1, 1]]
laplas_3 = [[0, -1, 0], [-1, 4, -1], [0, -1, 0]]
laplas_4 = [[-1, -1, -1], [-1, 8, -1], [-1, -1, -1]]
laplas_5 = [[0, -1, 0], [-1, 5, -1], [0, -1, 0]]
laplas_6 = [[-1, -1, -1], [-1, 9, -... |
class ListExtension(object):
@staticmethod
def split_list_in_n_parts(my_list, number_chunks):
k, m = len(my_list) / number_chunks, len(my_list) % number_chunks
return list(my_list[i * k + min(i, m):(i + 1) * k + min(i + 1, m)] for i in xrange(number_chunks))
@staticmethod
def convert_l... | class Listextension(object):
@staticmethod
def split_list_in_n_parts(my_list, number_chunks):
(k, m) = (len(my_list) / number_chunks, len(my_list) % number_chunks)
return list((my_list[i * k + min(i, m):(i + 1) * k + min(i + 1, m)] for i in xrange(number_chunks)))
@staticmethod
def con... |
# Violet Cube Fragment
FRAGMENT = 2434125
REWARD1 = 5062009 # red cube
REWARD2 = 5062010 # black cube
q = sm.getQuantityOfItem(FRAGMENT)
if q >= 10:
if sm.canHold(REWARD2):
sm.giveItem(REWARD2)
sm.consumeItem(FRAGMENT, 10)
else:
sm.systemMessage("Make sure you have enough space in your inventory..")
elif q >... | fragment = 2434125
reward1 = 5062009
reward2 = 5062010
q = sm.getQuantityOfItem(FRAGMENT)
if q >= 10:
if sm.canHold(REWARD2):
sm.giveItem(REWARD2)
sm.consumeItem(FRAGMENT, 10)
else:
sm.systemMessage('Make sure you have enough space in your inventory..')
elif q >= 5:
if sm.canHold(REW... |
num = {}
for i in range(97,123):
num[chr(i)] = i-96
L = int(input())
data = list(input().rstrip())
res = 0
M = 1234567891
for idx,val in enumerate(data):
res += (31**idx)*num[val]
res %= M
print(res) | num = {}
for i in range(97, 123):
num[chr(i)] = i - 96
l = int(input())
data = list(input().rstrip())
res = 0
m = 1234567891
for (idx, val) in enumerate(data):
res += 31 ** idx * num[val]
res %= M
print(res) |
class f:
def __init__(self,s,i):
self.s=s;self.i=i
r=""
for _ in range(int(__import__('sys').stdin.readline())):
n=int(__import__('sys').stdin.readline())
a=__import__('sys').stdin.readline().split()
b=__import__('sys').stdin.readline().split()
o=[-1]*n
for i in range(n):
for j i... | class F:
def __init__(self, s, i):
self.s = s
self.i = i
r = ''
for _ in range(int(__import__('sys').stdin.readline())):
n = int(__import__('sys').stdin.readline())
a = __import__('sys').stdin.readline().split()
b = __import__('sys').stdin.readline().split()
o = [-1] * n
for i i... |
n = int(input())
even = 0
odd = 0
for i in range(1, n + 1):
number = int(input())
if i % 2 == 0:
even += number
else:
odd += number
if even == odd:
print(f"Yes\nSum = {even}")
else:
print(f"No\nDiff = {abs(even - odd)}")
| n = int(input())
even = 0
odd = 0
for i in range(1, n + 1):
number = int(input())
if i % 2 == 0:
even += number
else:
odd += number
if even == odd:
print(f'Yes\nSum = {even}')
else:
print(f'No\nDiff = {abs(even - odd)}') |
def diff():
print("Diff Diff")
def patch():
print("Patch")
| def diff():
print('Diff Diff')
def patch():
print('Patch') |
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
}
}
INSTALLED_APPS = [
'userprofile',
]
USER_PROFILE_MODULE = 'userprofile.Profile'
| databases = {'default': {'ENGINE': 'django.db.backends.sqlite3'}}
installed_apps = ['userprofile']
user_profile_module = 'userprofile.Profile' |
class Solution:
def equalSubstring(self, s: str, t: str, mx: int) -> int:
i = 0
for j in range(len(s)):
mx -= abs(ord(s[j]) - ord(t[j]))
if mx < 0:
mx += abs(ord(s[i]) - ord(t[i]))
i += 1
return j - i + 1 | class Solution:
def equal_substring(self, s: str, t: str, mx: int) -> int:
i = 0
for j in range(len(s)):
mx -= abs(ord(s[j]) - ord(t[j]))
if mx < 0:
mx += abs(ord(s[i]) - ord(t[i]))
i += 1
return j - i + 1 |
'''
Problem:
Given an array A of n integers, in sorted order, and an integer x,
design an O(n)-time complexity algorithm to determine whether there
are 2 integers in A whose sum is exactly x.
'''
def sum(target, x):
lookup = set()
# Build a lookup table.
for item in target:
lookup.add(x - item)
... | """
Problem:
Given an array A of n integers, in sorted order, and an integer x,
design an O(n)-time complexity algorithm to determine whether there
are 2 integers in A whose sum is exactly x.
"""
def sum(target, x):
lookup = set()
for item in target:
lookup.add(x - item)
for item in target:
... |
class Televisao():
def __init__(self, c):
self.ligada = False
self.canal = c
self.marca = 'SAMSUNG'
self.tamanho = '43'
def muda_canal_cima(self):
if self.canal < 50:
self.canal += 1
else:
self.canal = 1
def muda_canal_baixo(self):
... | class Televisao:
def __init__(self, c):
self.ligada = False
self.canal = c
self.marca = 'SAMSUNG'
self.tamanho = '43'
def muda_canal_cima(self):
if self.canal < 50:
self.canal += 1
else:
self.canal = 1
def muda_canal_baixo(self):
... |
def test_numbers():
assert 1234 == 1234
def test_hello_world():
assert "hello" + "world" == "helloworld"
def test_foobar():
assert True
| def test_numbers():
assert 1234 == 1234
def test_hello_world():
assert 'hello' + 'world' == 'helloworld'
def test_foobar():
assert True |
'''
SPDX-License-Identifier: Apache-2.0
Copyright 2021 Keylime Authors
'''
async def execute(revocation):
try:
value = revocation['hello']
print(value)
except Exception as e:
raise Exception(
"The provided dictionary does not contain the 'hello' key")
| """
SPDX-License-Identifier: Apache-2.0
Copyright 2021 Keylime Authors
"""
async def execute(revocation):
try:
value = revocation['hello']
print(value)
except Exception as e:
raise exception("The provided dictionary does not contain the 'hello' key") |
# local scope
def my_func():
x = 300
print(x)
def my_inner_func():
print(x)
my_inner_func()
my_func()
| def my_func():
x = 300
print(x)
def my_inner_func():
print(x)
my_inner_func()
my_func() |
# OpenWeatherMap API Key
weather_api_key = "8915eee544f1c9b3ef5fa102f5edeb66"
# Google API Key
g_key = "AIzaSyDgD7ZgpyA4MuuVfr3Ep8G2-uCEx37joSE"
| weather_api_key = '8915eee544f1c9b3ef5fa102f5edeb66'
g_key = 'AIzaSyDgD7ZgpyA4MuuVfr3Ep8G2-uCEx37joSE' |
def to_polar(x, y):
'Rectangular to polar conversion using ints scaled by 100000. Angle in degrees.'
theta = 0
for i, adj in enumerate((4500000, 2656505, 1403624, 712502, 357633, 178991, 89517, 44761)):
sign = 1 if y < 0 else -1
x, y, theta = x - sign*(y >> i) , y + sign*(x >> i), theta - si... | def to_polar(x, y):
"""Rectangular to polar conversion using ints scaled by 100000. Angle in degrees."""
theta = 0
for (i, adj) in enumerate((4500000, 2656505, 1403624, 712502, 357633, 178991, 89517, 44761)):
sign = 1 if y < 0 else -1
(x, y, theta) = (x - sign * (y >> i), y + sign * (x >> i)... |
# -*- coding: utf-8 -*-
description = 'common detector devices provided by QMesyDAQ'
group = 'lowlevel'
devices = dict(
timer = device('nicos.devices.generic.VirtualTimer',
description = 'QMesyDAQ timer',
lowlevel = True,
unit = 's',
fmtstr = '%.1f',
),
mon1 = device('nic... | description = 'common detector devices provided by QMesyDAQ'
group = 'lowlevel'
devices = dict(timer=device('nicos.devices.generic.VirtualTimer', description='QMesyDAQ timer', lowlevel=True, unit='s', fmtstr='%.1f'), mon1=device('nicos.devices.generic.VirtualCounter', description='QMesyDAQ monitor 1', type='monitor', l... |
def arrayMap(f):
def app(arr):
return tuple(f(e) for e in arr)
return app
| def array_map(f):
def app(arr):
return tuple((f(e) for e in arr))
return app |
n = int(input())
arr = [int(e) for e in input().split()]
for inicio in range(1, n):
i = inicio
while i >= 1 and arr[i] < arr[i-1]:
arr[i], arr[i-1] = arr[i-1], arr[i]
i -= 1
for i in range(8):
print(arr[i], end=" ")
print()
| n = int(input())
arr = [int(e) for e in input().split()]
for inicio in range(1, n):
i = inicio
while i >= 1 and arr[i] < arr[i - 1]:
(arr[i], arr[i - 1]) = (arr[i - 1], arr[i])
i -= 1
for i in range(8):
print(arr[i], end=' ')
print() |
def area_for_polygon(polygon):
result = 0
imax = len(polygon) - 1
for i in range(0, imax):
result += (polygon[i][1] * polygon[i + 1][0]) - (polygon[i + 1][1] * polygon[i][0])
result += (polygon[imax][1] * polygon[0][0]) - (polygon[0][1] * polygon[imax][0])
return result / 2.
def centroid_f... | def area_for_polygon(polygon):
result = 0
imax = len(polygon) - 1
for i in range(0, imax):
result += polygon[i][1] * polygon[i + 1][0] - polygon[i + 1][1] * polygon[i][0]
result += polygon[imax][1] * polygon[0][0] - polygon[0][1] * polygon[imax][0]
return result / 2.0
def centroid_for_polyg... |
def square(): # function header
new_value=4 ** 2 # function body
print(new_value)
square()
| def square():
new_value = 4 ** 2
print(new_value)
square() |
class MockDbQuery(object):
def __init__(self, responses):
self.responses = responses
def get(self, method, **kws):
resp = None
if method in self.responses:
resp = self.responses[method].pop(0)
if 'validate' in resp:
checks = resp['validate']['che... | class Mockdbquery(object):
def __init__(self, responses):
self.responses = responses
def get(self, method, **kws):
resp = None
if method in self.responses:
resp = self.responses[method].pop(0)
if 'validate' in resp:
checks = resp['validate']['che... |
'''
Globals that are used throughout CheckAPI
'''
# Whether to output debugging statements
debug = False
# The model's current working directory
workingdir = "/"
| """
Globals that are used throughout CheckAPI
"""
debug = False
workingdir = '/' |
class SuperPalmTree:
def __init__(self, a: int, b: int, c: float):
self.a = a
self.b = b
self.c = c
def __call__(self, x):
return (self.a + self.b) * x / self.c
def unpack(self):
yield self.a
yield self.b
yield self.c
def param_tuple(self):
... | class Superpalmtree:
def __init__(self, a: int, b: int, c: float):
self.a = a
self.b = b
self.c = c
def __call__(self, x):
return (self.a + self.b) * x / self.c
def unpack(self):
yield self.a
yield self.b
yield self.c
def param_tuple(self):
... |
# functions
def yes_or_no(): # Returns 'yes' or 'no' based on first letter of user input.
while True:
item = input()
if not item or item[0] not in ['y', 'n']:
print('(y)es or (n)o are valid answers')
continue
elif item[0].lower() == 'y':
return 'yes'
... | def yes_or_no():
while True:
item = input()
if not item or item[0] not in ['y', 'n']:
print('(y)es or (n)o are valid answers')
continue
elif item[0].lower() == 'y':
return 'yes'
elif item[0].lower() == 'n':
return 'no' |
# selection sorting is an in-place comparison sort
# O(N^2) time, inefficient for large datasets
# best when memory is limited
def selection_sort(lst):
''' Implementation of selection sort. Efficient with space but not time. Finds the smallest unsorted index (index 0 in the first run) and compares it to all other... | def selection_sort(lst):
""" Implementation of selection sort. Efficient with space but not time. Finds the smallest unsorted index (index 0 in the first run) and compares it to all other items in the list. if an item has a smaller numeric value than the smallest unsorted index, it swaps with the smallest of all th... |
def list_to_string(lst):
string = ''
for item in lst:
string = string + item
return string
def find_rc(rc):
rc = rc[:: -1]
replacements = {"A": "T",
"T": "A",
"G": "C",
"C": "G"}
rc = "".join([replacements.get(c, c) for c in r... | def list_to_string(lst):
string = ''
for item in lst:
string = string + item
return string
def find_rc(rc):
rc = rc[::-1]
replacements = {'A': 'T', 'T': 'A', 'G': 'C', 'C': 'G'}
rc = ''.join([replacements.get(c, c) for c in rc])
return rc
def find_palindromes(x):
sequence = lis... |
t = int(input())
for _ in range(t):
s = input()
c = 0
for i in range(len(s)-1):
if abs(ord(s[i]) - ord(s[i+1])) != 1:
c += 1
print (c)
| t = int(input())
for _ in range(t):
s = input()
c = 0
for i in range(len(s) - 1):
if abs(ord(s[i]) - ord(s[i + 1])) != 1:
c += 1
print(c) |
class CheckResult:
msg: str = ""
def __init__(self, msg) -> None:
self.msg = msg
class Ok(CheckResult):
pass
class Warn(CheckResult):
pass
class Err(CheckResult):
pass
class Unk(CheckResult):
pass
class Probe:
def __init__(self, **kwargs):
for k, v in kwargs.items(... | class Checkresult:
msg: str = ''
def __init__(self, msg) -> None:
self.msg = msg
class Ok(CheckResult):
pass
class Warn(CheckResult):
pass
class Err(CheckResult):
pass
class Unk(CheckResult):
pass
class Probe:
def __init__(self, **kwargs):
for (k, v) in kwargs.items():... |
load(":testing.bzl", "asserts", "test_suite")
load("//maven:sets.bzl", "sets")
def new_test(env):
set = sets.new()
asserts.equals(env, 0, len(set))
set = sets.new("a", "b", "c")
asserts.equals(env, 3, len(set))
asserts.equals(env, ["a", "b", "c"], list(set))
def equality_test(env):
a = sets.ne... | load(':testing.bzl', 'asserts', 'test_suite')
load('//maven:sets.bzl', 'sets')
def new_test(env):
set = sets.new()
asserts.equals(env, 0, len(set))
set = sets.new('a', 'b', 'c')
asserts.equals(env, 3, len(set))
asserts.equals(env, ['a', 'b', 'c'], list(set))
def equality_test(env):
a = sets.ne... |
#Write a function that accepts a filename as input argument and reads the file and saves each line of the file as an element
#in a list (without the new line ("\n")character) and returns the list. Each line of the file has comma separated values
# Type your code here
def list_from_file(file_name):
# Make a connec... | def list_from_file(file_name):
file_pointer = open(file_name, 'r')
data = file_pointer.readlines()
final_list = []
for x in data:
final_list.append(x.strip('\n'))
return final_list
file_pointer.close()
print(list_from_file('file_name.txt')) |
# Instruction opcodes
_CHAR = 0
_NEWLINE = 1
_FONT = 2
_COLOR = 3
_SHAKE = 4
_WAIT = 5
_CUSTOM = 6
class Graph:
def __init__(self, default_font):
self.instructions = []
self.default_font = default_font
def string(self, s):
'''Adds a string of characters to the passage.'''... | _char = 0
_newline = 1
_font = 2
_color = 3
_shake = 4
_wait = 5
_custom = 6
class Graph:
def __init__(self, default_font):
self.instructions = []
self.default_font = default_font
def string(self, s):
"""Adds a string of characters to the passage."""
for c in s:
se... |
class DummyField(object):
def __init__(self, value, **kwargs):
self.value = value
for k_, v_ in kwargs.items():
setattr(self, k_, v_)
| class Dummyfield(object):
def __init__(self, value, **kwargs):
self.value = value
for (k_, v_) in kwargs.items():
setattr(self, k_, v_) |
class TempProps:
def __init__(self, start_temperature, grad_temperature, temperature_coefficient):
self.start_temp = start_temperature
self.grad_temp = grad_temperature
self.temp_coeff = temperature_coefficient
def __str__(self):
out_str = ""
out_str += "start temp: " +... | class Tempprops:
def __init__(self, start_temperature, grad_temperature, temperature_coefficient):
self.start_temp = start_temperature
self.grad_temp = grad_temperature
self.temp_coeff = temperature_coefficient
def __str__(self):
out_str = ''
out_str += 'start temp: ' +... |
class SmallArray():
def __init__(self) -> None:
self.clusters = 0
self.cluster_size = 0 | class Smallarray:
def __init__(self) -> None:
self.clusters = 0
self.cluster_size = 0 |
class ValidationError(Exception):
pass
class empty(Exception):
pass
| class Validationerror(Exception):
pass
class Empty(Exception):
pass |
# 1 and 9
TERMINAL_INDICES = [0, 8, 9, 17, 18, 26]
# dragons and winds
EAST = 27
SOUTH = 28
WEST = 29
NORTH = 30
HAKU = 31
HATSU = 32
CHUN = 33
WINDS = [EAST, SOUTH, WEST, NORTH]
HONOR_INDICES = WINDS + [HAKU, HATSU, CHUN]
FIVE_RED_MAN = 16
FIVE_RED_PIN = 52
FIVE_RED_SOU = 88
AKA_DORA_LIST = [FIVE_RED_MAN, FIVE_RED... | terminal_indices = [0, 8, 9, 17, 18, 26]
east = 27
south = 28
west = 29
north = 30
haku = 31
hatsu = 32
chun = 33
winds = [EAST, SOUTH, WEST, NORTH]
honor_indices = WINDS + [HAKU, HATSU, CHUN]
five_red_man = 16
five_red_pin = 52
five_red_sou = 88
aka_dora_list = [FIVE_RED_MAN, FIVE_RED_PIN, FIVE_RED_SOU]
display_winds ... |
# #class
class user:
def __init__(self,first_name,last_name,birth,sex): # this is the main class's (attribute)function , self is the main v
self.first_name=first_name
self.last_name=last_name
self.birth=birth
self.sex=sex
def grit(self):
print (f"name: {self.first_name}... | class User:
def __init__(self, first_name, last_name, birth, sex):
self.first_name = first_name
self.last_name = last_name
self.birth = birth
self.sex = sex
def grit(self):
print(f'name: {self.first_name},{self.last_name}, year: {self.birth}')
def calc_age(self, c... |
DEBUG = True
TEMPLATE_DEBUG = DEBUG
STATIC_DEBUG = DEBUG
CRISPY_FAIL_SILENTLY = not DEBUG
ADMINS = (
('Dummy', 'dummy@example.org'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'NAME': 'sdemo.db',
'ENGINE': 'django.db.backends.sqlite3',
'USER': '',
'PASSWORD': ''
}
}
#... | debug = True
template_debug = DEBUG
static_debug = DEBUG
crispy_fail_silently = not DEBUG
admins = (('Dummy', 'dummy@example.org'),)
managers = ADMINS
databases = {'default': {'NAME': 'sdemo.db', 'ENGINE': 'django.db.backends.sqlite3', 'USER': '', 'PASSWORD': ''}}
media_root = ''
media_url = ''
static_root = ''
static_... |
def path(current, visited_small_caves, cmap):
if current == 'end':
return [[current]]
next_caves = cmap[current]
paths = []
for next_cave in next_caves:
if next_cave in visited_small_caves:
continue
if next_cave.islower():
next_visited_small_caves = visite... | def path(current, visited_small_caves, cmap):
if current == 'end':
return [[current]]
next_caves = cmap[current]
paths = []
for next_cave in next_caves:
if next_cave in visited_small_caves:
continue
if next_cave.islower():
next_visited_small_caves = visite... |
def func1(a):
a += 1
def funct2(b):
val = 1+b
return val
return funct2(a)
print(func1(5)) | def func1(a):
a += 1
def funct2(b):
val = 1 + b
return val
return funct2(a)
print(func1(5)) |
# You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the stones you have are also jewels.
# The letters in J are guaranteed distinct, and all characters in J and S are letters. ... | class Solution:
def num_jewels_in_stones(self, J, S):
count = 0
if J.isalpha() and S.isalpha() and (len(J) <= 50) and (len(S) <= 50):
for stones in S:
if stones in J:
count += 1
return count
if __name__ == '__main__':
j = 'aA'
s = ... |
#identify cycles in a linked list
def has_cycle(head):
taboo_list = list()
temp = head
while temp:
if temp not in taboo_list:
taboo_list.append(temp)
temp = temp.next
else:
return 1
return 0
| def has_cycle(head):
taboo_list = list()
temp = head
while temp:
if temp not in taboo_list:
taboo_list.append(temp)
temp = temp.next
else:
return 1
return 0 |
# CAN controls for MQB platform Volkswagen, Audi, Skoda and SEAT.
# PQ35/PQ46/NMS, and any future MLB, to come later.
def create_mqb_steering_control(packer, bus, apply_steer, idx, lkas_enabled):
values = {
"SET_ME_0X3": 0x3,
"Assist_Torque": abs(apply_steer),
"Assist_Requested": lkas_enabled,
"Assis... | def create_mqb_steering_control(packer, bus, apply_steer, idx, lkas_enabled):
values = {'SET_ME_0X3': 3, 'Assist_Torque': abs(apply_steer), 'Assist_Requested': lkas_enabled, 'Assist_VZ': 1 if apply_steer < 0 else 0, 'HCA_Available': 1, 'HCA_Standby': not lkas_enabled, 'HCA_Active': lkas_enabled, 'SET_ME_0XFE': 254,... |
#
# gambit
#
# Configuration file for gravity inversion for use by planeGravInv.py
# mesh has been made with mkGeoWithData2D.py
#
# Inversion constants:
#
# scale between misfit and regularization
mu = 1.e-14
#
# used to scale computed density. kg/m^3
rho_0 = 1.
#
# IPCG tolerance *|r| <= atol+rtol*|r0|*... | mu = 1e-14
rho_0 = 1.0
atol = 0.0
rtol = 0.001
pdetol = 1e-10
iter_max = 500
data_scale = 1e-06
mesh_name = 'G_201x338test.fly'
data_file = 'Gravity_201x338.nc'
output_name = 'G_test_201x338_rho0_{0:1.3e}_mu_{1:1.3e}'.format(rho_0, mu)
verbose_level = 'low' |
def countWaysToChangeDigit(value):
result = 0
for i in str(value):
result += 9 - int(i)
return result
| def count_ways_to_change_digit(value):
result = 0
for i in str(value):
result += 9 - int(i)
return result |
def product(x):
t = 1
for n in x:
t *= n
return t
| def product(x):
t = 1
for n in x:
t *= n
return t |
# Note: The schema is stored in a .py file in order to take advantage of the
# int() and float() type coercion functions. Otherwise it could easily stored as
# as JSON or another serialized format.
'''This schema has been changed compared to the Udacity schema,
due to missing values for attributes 'user' and 'uid'.
... | """This schema has been changed compared to the Udacity schema,
due to missing values for attributes 'user' and 'uid'.
It makes sense to keep them in the schema for use of other OSM data."""
schema = {'node': {'type': 'dict', 'schema': {'id': {'required': True, 'type': 'integer', 'coerce': int}, 'lat': {'required': T... |
class Port:
def __init__(self, mac_address, ip_address, mtu):
self.mac_address = mac_address
self.ip_address = ip_address
self.mtu = mtu
def __str__(self):
return '(%s - %s - %d)' % (self.mac_address, self.ip_address, self.mtu)
| class Port:
def __init__(self, mac_address, ip_address, mtu):
self.mac_address = mac_address
self.ip_address = ip_address
self.mtu = mtu
def __str__(self):
return '(%s - %s - %d)' % (self.mac_address, self.ip_address, self.mtu) |
class Context:
def __init__(self, **kwargs):
self.message = kwargs.get("message")
self.command = kwargs.get("command")
def print(self, content, *, indent=0, **kwargs):
if indent > 0:
lines = content.split("\n")
for line in lines:
prefix =... | class Context:
def __init__(self, **kwargs):
self.message = kwargs.get('message')
self.command = kwargs.get('command')
def print(self, content, *, indent=0, **kwargs):
if indent > 0:
lines = content.split('\n')
for line in lines:
prefix = '| ' * ... |
'''
Config! Change as needed.
NOTE: Please make sure that all information (except for authentication keys)
are passed in lower-case!
'''
# Your twitter access tokens. These are your accounts that you will enter giveaways from.
# Add as many users as you want, and please make sure to enter your username in lower case!... | """
Config! Change as needed.
NOTE: Please make sure that all information (except for authentication keys)
are passed in lower-case!
"""
access_tokens = {'user1': {'consumer_key': '', 'consumer_secret': '', 'access_token': '', 'access_token_secret': ''}, 'user2': {'consumer_key': '', 'consumer_secret': '', 'access_tok... |
n, m = [int(x) for x in input().split()]
edges = [[int(x) for x in input().split()] for _ in range(m)]
if m < n - 1:
print(0)
exit()
paths = []
start = 1
still_possible = True
while still_possible:
passed = [1]
current = start
for i in range(1, n):
for e in edges:
... | (n, m) = [int(x) for x in input().split()]
edges = [[int(x) for x in input().split()] for _ in range(m)]
if m < n - 1:
print(0)
exit()
paths = []
start = 1
still_possible = True
while still_possible:
passed = [1]
current = start
for i in range(1, n):
for e in edges:
if e[0] == cu... |
def is_unique_points(points=None):
if points is None:
points = {}
points_dict = {}
for key, values in points.items():
new_key = '%s:%s' % tuple(values)
is_exists = points_dict.get(new_key, None)
if is_exists:
return False
else:
points_dict[new... | def is_unique_points(points=None):
if points is None:
points = {}
points_dict = {}
for (key, values) in points.items():
new_key = '%s:%s' % tuple(values)
is_exists = points_dict.get(new_key, None)
if is_exists:
return False
else:
points_dict[ne... |
def containsDuplicate(nums):
sorted = sorted(nums)
for i in range(len(nums)-1):
if nums[i] == nums[i+1]:
return True
return False | def contains_duplicate(nums):
sorted = sorted(nums)
for i in range(len(nums) - 1):
if nums[i] == nums[i + 1]:
return True
return False |
def find_max(root):
if not root:
return 0
if not root.left and not root.right:
return root.val
m = [0]
helper(root, m)
return m[0]
def helper(n, m):
if n.val > m[0]:
m[0] = n.val
if n.left:
helper(n.left, m)
if n.right:
helper(n.right, m)
| def find_max(root):
if not root:
return 0
if not root.left and (not root.right):
return root.val
m = [0]
helper(root, m)
return m[0]
def helper(n, m):
if n.val > m[0]:
m[0] = n.val
if n.left:
helper(n.left, m)
if n.right:
helper(n.right, m) |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# ... | class Solution:
def sorted_list_to_bst(self, head: ListNode) -> TreeNode:
def get_median(left: ListNode, right: ListNode) -> ListNode:
fast = slow = left
while fast != right and fast.next != right:
fast = fast.next.next
slow = slow.next
r... |
#!/usr/bin/env python3
def chdir(path, folder):
return path+"/"+folder
def previous(path):
temp = ""
for i in path.split("/")[1:-1]:
temp += "/"+i
return temp
| def chdir(path, folder):
return path + '/' + folder
def previous(path):
temp = ''
for i in path.split('/')[1:-1]:
temp += '/' + i
return temp |
# Bradley Grose
data = ("John", "Doe", 53.44)
format_string = "Hello %s %s. Your current balance is $%s"
print(format_string % data) | data = ('John', 'Doe', 53.44)
format_string = 'Hello %s %s. Your current balance is $%s'
print(format_string % data) |
def winning_score():
while True:
try:
winning_score = int(input("\nHow many points should "
"declare the winner? "))
except ValueError:
print("\nInvalid input type. Enter a positive number.")
continue
else:
if winnin... | def winning_score():
while True:
try:
winning_score = int(input('\nHow many points should declare the winner? '))
except ValueError:
print('\nInvalid input type. Enter a positive number.')
continue
else:
if winning_score <= 0:
p... |
''' Else Statements
Code that executes if contitions checked evaluates to False.
''' | """ Else Statements
Code that executes if contitions checked evaluates to False.
""" |
class Solution:
def selfDividingNumbers(self, left: int, right: int) -> List[int]:
ret = []
for x in range(left, right + 1):
y = x
while y > 0:
z = y % 10
if z == 0 or x % z != 0:
break;
y //= 10
... | class Solution:
def self_dividing_numbers(self, left: int, right: int) -> List[int]:
ret = []
for x in range(left, right + 1):
y = x
while y > 0:
z = y % 10
if z == 0 or x % z != 0:
break
y //= 10
... |
# -*- coding: utf_8 -*-
__author__ = 'Yagg'
class ShipGroup:
def __init__(self, ownerName, count, shipType, driveTech, weaponTech, shieldTech, cargoTech, cargoType, cargoQuantity):
self.count = count
self.shipType = shipType
self.driveTech = driveTech
self.weaponTech = weaponTech
... | __author__ = 'Yagg'
class Shipgroup:
def __init__(self, ownerName, count, shipType, driveTech, weaponTech, shieldTech, cargoTech, cargoType, cargoQuantity):
self.count = count
self.shipType = shipType
self.driveTech = driveTech
self.weaponTech = weaponTech
self.shieldTech =... |
class MyHookExtension(object):
def post_create_hook(self, archive, product):
pass
def post_ingest_hook(self, archive, product):
pass
def post_pull_hook(self, archive, product):
pass
def post_remove_hook(self, archive, product):
pass
_hook_extensions = {
'myhooks'... | class Myhookextension(object):
def post_create_hook(self, archive, product):
pass
def post_ingest_hook(self, archive, product):
pass
def post_pull_hook(self, archive, product):
pass
def post_remove_hook(self, archive, product):
pass
_hook_extensions = {'myhooks': my_h... |
# return a go-to-goal heading vector in the robot's reference frame
def calculate_gtg_heading_vector( self ):
# get the inverse of the robot's pose
robot_inv_pos, robot_inv_theta = self.supervisor.estimated_pose().inverse().vector_unpack()
# calculate the goal vector in the robot's reference frame
goal = sel... | def calculate_gtg_heading_vector(self):
(robot_inv_pos, robot_inv_theta) = self.supervisor.estimated_pose().inverse().vector_unpack()
goal = self.supervisor.goal()
goal = linalg.rotate_and_translate_vector(goal, robot_inv_theta, robot_inv_pos)
return goal
v = self.supervisor.v_max() / (abs(omega) + 1) *... |
# pylint: disable=global-statement,missing-docstring,blacklisted-name
foo = "test"
def broken():
global foo
bar = len(foo)
foo = foo[bar]
| foo = 'test'
def broken():
global foo
bar = len(foo)
foo = foo[bar] |
def parse_input():
fin = open('input_day3.txt','r')
inputs = []
for line in fin:
inputs.append(line.strip('\n'))
return inputs
def plot_path(inputs, path, ref_path=None):
x=0
y=0
c = 0
hits = []
for i in inputs.split(','):
(d, v) = (i[0],int(i[1:]))
fn =... | def parse_input():
fin = open('input_day3.txt', 'r')
inputs = []
for line in fin:
inputs.append(line.strip('\n'))
return inputs
def plot_path(inputs, path, ref_path=None):
x = 0
y = 0
c = 0
hits = []
for i in inputs.split(','):
(d, v) = (i[0], int(i[1:]))
fn ... |
# This file is imported from __init__.py and exec'd from setup.py
__version__ = "1.0.0+dev"
VERSION = (1, 0, 0)
| __version__ = '1.0.0+dev'
version = (1, 0, 0) |
#returns list of groups. group is a list of strings, a string per person.
def getgroups():
with open('Day6.txt', 'r') as file:
groupList = []
currgroup = []
for line in file:
if line not in ['\n', '\n\n']:
currgroup.append(line.strip())
else:
... | def getgroups():
with open('Day6.txt', 'r') as file:
group_list = []
currgroup = []
for line in file:
if line not in ['\n', '\n\n']:
currgroup.append(line.strip())
else:
groupList.append(currgroup)
currgroup = []
... |
list1=['Apple','Mango',1999,2000]
print(list1)
del list1[2]
print("After deleting value at index 2:")
print(list1)
list2=['Apple','Mango',1999,2000,1111,2222,3333]
print(list2)
del list2[0:3]
print("After deleting value till index 2:")
print(list2)
| list1 = ['Apple', 'Mango', 1999, 2000]
print(list1)
del list1[2]
print('After deleting value at index 2:')
print(list1)
list2 = ['Apple', 'Mango', 1999, 2000, 1111, 2222, 3333]
print(list2)
del list2[0:3]
print('After deleting value till index 2:')
print(list2) |
base_vectors = [[0.001178571428571168, 1.9904285714285708, 0.0011071428571440833], [-0.013142857142857345, -0.0018571428571430015, 1.9921428571428583], [-0.0007499999999995843, 0.17799999999999994, -0.00024999999999630873], [-4.440892098500626e-16, -8.881784197001252e-16, 0.1769999999999996]]
n = [8, 8, 6, 6]
origin = ... | base_vectors = [[0.001178571428571168, 1.9904285714285708, 0.0011071428571440833], [-0.013142857142857345, -0.0018571428571430015, 1.9921428571428583], [-0.0007499999999995843, 0.17799999999999994, -0.00024999999999630873], [-4.440892098500626e-16, -8.881784197001252e-16, 0.1769999999999996]]
n = [8, 8, 6, 6]
origin = ... |
def solveProblem(inputPath):
floor = 0
indexFloorInfo = 0
with open(inputPath) as fileP:
valueLine = fileP.readline()
for floorInfo in valueLine:
indexFloorInfo += 1
if floorInfo == '(':
floor += 1
elif floorInfo == ')':
... | def solve_problem(inputPath):
floor = 0
index_floor_info = 0
with open(inputPath) as file_p:
value_line = fileP.readline()
for floor_info in valueLine:
index_floor_info += 1
if floorInfo == '(':
floor += 1
elif floorInfo == ')':
... |
try:
tests=int(input())
k=[]
for i in range(tests):
z=[]
count=0
find,length=[int(x) for x in input().split(" ")]
list1=list(map(int,input().rstrip().split()))
for i in range(len(list1)):
if list1[i]==find:
z.append(i+1)
... | try:
tests = int(input())
k = []
for i in range(tests):
z = []
count = 0
(find, length) = [int(x) for x in input().split(' ')]
list1 = list(map(int, input().rstrip().split()))
for i in range(len(list1)):
if list1[i] == find:
z.append(i + 1)... |
python = {'John':35,'Eric':36,'Michael':35,'Terry':38,'Graham':37,'TerryG':34}
holy_grail = {'Arthur':40,'Galahad':35,'Lancelot':39,'Knight of NI':40, 'Zoot':17}
life_of_brian = {'Brian':33,'Reg':35,'Stan/Loretta':32,'Biccus Diccus':45}
#membership test
print('Arthur' in holy_grail)
if 'Arthur' not in python:
prin... | python = {'John': 35, 'Eric': 36, 'Michael': 35, 'Terry': 38, 'Graham': 37, 'TerryG': 34}
holy_grail = {'Arthur': 40, 'Galahad': 35, 'Lancelot': 39, 'Knight of NI': 40, 'Zoot': 17}
life_of_brian = {'Brian': 33, 'Reg': 35, 'Stan/Loretta': 32, 'Biccus Diccus': 45}
print('Arthur' in holy_grail)
if 'Arthur' not in python:
... |
a, b, c = input().split(' ')
a = float(a)
b = float(b)
c = float(c)
areat = (a * c) / 2
areac = 3.14159 * c**2
areatp = (a + b) * c / 2
areaq = b * b
arear = b * a
print(f'TRIANGULO: {areat:.3f}')
print(f'CIRCULO: {areac:.3f}')
print(f'TRAPEZIO: {areatp:.3f}')
print(f'QUADRADO: {areaq:.3f}')
print(f'RETANGULO: {arear:.... | (a, b, c) = input().split(' ')
a = float(a)
b = float(b)
c = float(c)
areat = a * c / 2
areac = 3.14159 * c ** 2
areatp = (a + b) * c / 2
areaq = b * b
arear = b * a
print(f'TRIANGULO: {areat:.3f}')
print(f'CIRCULO: {areac:.3f}')
print(f'TRAPEZIO: {areatp:.3f}')
print(f'QUADRADO: {areaq:.3f}')
print(f'RETANGULO: {arear... |
#! python3
# aoc_05.py
# Advent of code:
# https://adventofcode.com/2021/day/5
# https://adventofcode.com/2021/day/5#part2
#
def hello_world():
return 'hello world'
class ventmap:
def __init__(self, xmax, ymax):
self.xmax = xmax
self.ymax = ymax
self.map = [[0 for i in range(xmax... | def hello_world():
return 'hello world'
class Ventmap:
def __init__(self, xmax, ymax):
self.xmax = xmax
self.ymax = ymax
self.map = [[0 for i in range(xmax)] for j in range(ymax)]
def check_line(x1, y1, x2, y2):
return x1 == x2 or y1 == y2
def find_vents(input, x, y):
mymap =... |
#
# PySNMP MIB module RAQMON-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RAQMON-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:52:12 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:... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_range_constraint, constraints_union, constraints_intersection, value_size_constraint) ... |
def findDecision(obj): #obj[0]: Passanger, obj[1]: Time, obj[2]: Coupon, obj[3]: Coupon_validity, obj[4]: Gender, obj[5]: Age, obj[6]: Children, obj[7]: Education, obj[8]: Occupation, obj[9]: Income, obj[10]: Bar, obj[11]: Coffeehouse, obj[12]: Restaurant20to50, obj[13]: Direction_same, obj[14]: Distance
# {"feature":... | def find_decision(obj):
if obj[0] <= 1:
if obj[10] <= 1.0:
if obj[2] > 0:
if obj[8] <= 14:
if obj[11] <= 2.0:
if obj[7] > 0:
if obj[1] > 0:
if obj[5] <= 4:
... |
def fib(x):
if x < 2:
return x
return fib(x - 1) + fib(x-2)
if __name__ == "__main__":
N = int(input())
while N > 0:
x = int(input())
print(fib(x))
N = N - 1
| def fib(x):
if x < 2:
return x
return fib(x - 1) + fib(x - 2)
if __name__ == '__main__':
n = int(input())
while N > 0:
x = int(input())
print(fib(x))
n = N - 1 |
T = int(input())
for _ in range(T):
for i in range(1, 1001):
print(i**2)
a = int(input())
if a==0:
continue
else:
break | t = int(input())
for _ in range(T):
for i in range(1, 1001):
print(i ** 2)
a = int(input())
if a == 0:
continue
else:
break |
class BaseException(object):
'''
The base exception class (equivalent to System.Exception)
'''
def __init__(self):
self.message = None
| class Baseexception(object):
"""
The base exception class (equivalent to System.Exception)
"""
def __init__(self):
self.message = None |
class Name(object):
def __init__(self,
normal: str,
folded: str):
self.normal = normal
self.folded = folded
| class Name(object):
def __init__(self, normal: str, folded: str):
self.normal = normal
self.folded = folded |
n = int(input())
x = list(map(int, input().split()))
m = 0
e = 0
c = 0
for n in x:
m += abs(n)
e += n ** 2
c = max(c, abs(n))
print(m)
print(e ** 0.5)
print(c) | n = int(input())
x = list(map(int, input().split()))
m = 0
e = 0
c = 0
for n in x:
m += abs(n)
e += n ** 2
c = max(c, abs(n))
print(m)
print(e ** 0.5)
print(c) |
#!/usr/bin/env python3
# String to be evaluated
s = "azcbobobegghakl"
# Initialize count
count = 0
# Vowels that will be evaluted inside s
vowels = "aeiou"
# For loop to count vowels in var s
for letter in s:
if letter in vowels:
count += 1
# Prints final count to terminal
print("Number of vowels in ... | s = 'azcbobobegghakl'
count = 0
vowels = 'aeiou'
for letter in s:
if letter in vowels:
count += 1
print('Number of vowels in ' + s + ': ' + str(count)) |
def diglet(i_buraco_origem, buracos):
if buracos[i_buraco_origem] == -99:
return 0
else:
i_buraco_destino = buracos[i_buraco_origem] - 1
buracos[i_buraco_origem] = -99
return 1 + diglet(i_buraco_destino, buracos)
def mdc_euclide(a, b):
if b == 0:
return a
else:
... | def diglet(i_buraco_origem, buracos):
if buracos[i_buraco_origem] == -99:
return 0
else:
i_buraco_destino = buracos[i_buraco_origem] - 1
buracos[i_buraco_origem] = -99
return 1 + diglet(i_buraco_destino, buracos)
def mdc_euclide(a, b):
if b == 0:
return a
else:
... |
x = ['happy','sad','cheerful']
print('{0},{1},{2}'.format(x[0],x[1].x[2]))
##-------------------------------------------##
a = "{x}, {y}".format(x=5, y=12)
print(a)
| x = ['happy', 'sad', 'cheerful']
print('{0},{1},{2}'.format(x[0], x[1].x[2]))
a = '{x}, {y}'.format(x=5, y=12)
print(a) |
class Book:
def __init__(self,title,author):
self.title = title
self.author = author
def __str__(self):
return '{} by {}'.format(self.title,self.author)
class Bookcase():
def __init__(self,books=None):
self.books = books
@classmethod
def create_bookcase(cls,book_list)... | class Book:
def __init__(self, title, author):
self.title = title
self.author = author
def __str__(self):
return '{} by {}'.format(self.title, self.author)
class Bookcase:
def __init__(self, books=None):
self.books = books
@classmethod
def create_bookcase(cls, bo... |
# # Copyright (c) 2017 - The MITRE Corporation
# For license information, see the LICENSE.txt file
__version__ = "1.3.0"
| __version__ = '1.3.0' |
class car():
def __init__(self, make, model, year ):
self.make = make
self.model = model
self.year = year
self.odometer = 0
def describe_car(self):
long_name = str(self.year)+' '+self.make+' '+self.model
return long_name.title()
def read_odometer(self):
... | class Car:
def __init__(self, make, model, year):
self.make = make
self.model = model
self.year = year
self.odometer = 0
def describe_car(self):
long_name = str(self.year) + ' ' + self.make + ' ' + self.model
return long_name.title()
def read_odometer(self)... |
expected_output = {
"route-information": {
"route-table": [
{
"active-route-count": "16",
"destination-count": "16",
"hidden-route-count": "0",
"holddown-route-count": "0",
"rt": [
{
... | expected_output = {'route-information': {'route-table': [{'active-route-count': '16', 'destination-count': '16', 'hidden-route-count': '0', 'holddown-route-count': '0', 'rt': [{'rt-announced-count': '1', 'rt-destination': '10.1.0.0', 'rt-entry': {'as-path': 'AS path: I', 'bgp-path-attributes': {'attr-as-path-effective'... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.