content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
#!/usr/bin/env python
DEF_TASKDB_CONF = {'timeout': 10.0, # seconds
'task_checkout_delay': 1.0, # seconds
'task_checkout_num_tries': 10}
class TASK_STATES(object):
QUEUED_NO_DEP = 'QUEUED_NO_DEP'
RUNNING = 'RUNNING'
FAILED = 'FAILED'
SUCCEEDED = 'SUCCEEDED'
... | def_taskdb_conf = {'timeout': 10.0, 'task_checkout_delay': 1.0, 'task_checkout_num_tries': 10}
class Task_States(object):
queued_no_dep = 'QUEUED_NO_DEP'
running = 'RUNNING'
failed = 'FAILED'
succeeded = 'SUCCEEDED'
checkpointed = 'CHECKPOINTED'
killed = 'KILLED'
deleted = 'DELETED'
list_of... |
#!/usr/bin/env python3
#######################################################################################
# #
# Program purpose: Finds the first appearance of the substring 'not' and 'poor' #
# from a... | def get_user_string(mess: str):
is_valid = False
data = ''
while is_valid is False:
try:
data = input(mess)
if len(data) == 0:
raise value_error('Please provide a string')
is_valid = True
except ValueError as ve:
print(f'[ERROR]... |
symbol1 = input()
symbol2 = input()
def return_characters(symbol1, symbol2):
symbol1 = ord(symbol1)
symbol2 = ord(symbol2)
result = []
for i in range(symbol1 + 1, symbol2):
char = chr(i)
result.append(char)
result = " ".join(result)
return result
print(return_characters(sy... | symbol1 = input()
symbol2 = input()
def return_characters(symbol1, symbol2):
symbol1 = ord(symbol1)
symbol2 = ord(symbol2)
result = []
for i in range(symbol1 + 1, symbol2):
char = chr(i)
result.append(char)
result = ' '.join(result)
return result
print(return_characters(symbol1,... |
class Messages:
help = "How can I help you?"
hello = "Hello!"
welcome = "Welcome {name}! I'm VK-Reminder-Bot."
done = "I have set the reminder!"
updated = "I have updated the reminder!"
missed = "I didn't get that!"
get_title = "Please enter Reminder Title:"
get_time = "When should I rem... | class Messages:
help = 'How can I help you?'
hello = 'Hello!'
welcome = "Welcome {name}! I'm VK-Reminder-Bot."
done = 'I have set the reminder!'
updated = 'I have updated the reminder!'
missed = "I didn't get that!"
get_title = 'Please enter Reminder Title:'
get_time = 'When should I rem... |
class Solution:
def kthPalindrome(self, queries: List[int], intLength: int) -> List[int]:
start = pow(10, (intLength + 1) // 2 - 1)
end = pow(10, (intLength + 1) // 2)
mul = pow(10, intLength // 2)
def reverse(num: int) -> int:
res = 0
while num:
res = res * 10 + num % 10
... | class Solution:
def kth_palindrome(self, queries: List[int], intLength: int) -> List[int]:
start = pow(10, (intLength + 1) // 2 - 1)
end = pow(10, (intLength + 1) // 2)
mul = pow(10, intLength // 2)
def reverse(num: int) -> int:
res = 0
while num:
... |
def checkMagazine(magazine, note):
if len(magazine) < len(note):
print("No")
# Program would not stop if not return
return None
note_dict = {}
for word in note:
if word not in note_dict:
note_dict[word] = 1
else:
note_dict[word] += ... | def check_magazine(magazine, note):
if len(magazine) < len(note):
print('No')
return None
note_dict = {}
for word in note:
if word not in note_dict:
note_dict[word] = 1
else:
note_dict[word] += 1
for word in magazine:
if word in note_dict:
... |
#!/usr/bin/env python
# definitions of packets that go from the App to Artoo or App to Solo and vice versa.
# All packets are of the form (in little endian)
# 32-bit type identifier
# 32-bit length
# n bytes value
# https://docs.google.com/a/3drobotics.com/document/d/1rA1zs3T7X1n9ip9YMGZEcLCW6Mx1RR1bNlh9gF0i8nM/edit#h... | solo_message_header_length = 8
solo_message_get_current_shot = 0
solo_message_set_current_shot = 1
solo_message_location = 2
solo_record_position = 3
solo_cable_cam_options = 4
solo_message_get_button_setting = 5
solo_message_set_button_setting = 6
solo_pause = 7
solo_follow_options = 19
solo_follow_options_v2 = 119
so... |
tempo_em_segundo = int(input())
horas = tempo_em_segundo//3600
tempo_em_segundo -= horas*3600
minutos = tempo_em_segundo//60
segundos = tempo_em_segundo - minutos*60
print(f"{horas}:{minutos}:{segundos}") | tempo_em_segundo = int(input())
horas = tempo_em_segundo // 3600
tempo_em_segundo -= horas * 3600
minutos = tempo_em_segundo // 60
segundos = tempo_em_segundo - minutos * 60
print(f'{horas}:{minutos}:{segundos}') |
#!/usr/bin/env python
def rev(stack):
return stack[::-1]
def cut(stack, n):
return stack[n:] + stack[:n]
def incr(stack, n):
size = len(stack)
new_stack = [-1] * size
i = 0
for a in range(size):
new_stack[i % size] = stack[a]
i += n
return new_stack
def solve(inp, siz... | def rev(stack):
return stack[::-1]
def cut(stack, n):
return stack[n:] + stack[:n]
def incr(stack, n):
size = len(stack)
new_stack = [-1] * size
i = 0
for a in range(size):
new_stack[i % size] = stack[a]
i += n
return new_stack
def solve(inp, size):
steps = [line.split... |
class ParseError(Exception):
pass
class UnsupportedFile(Exception):
pass
class MultipleParentsGFF(UnsupportedFile):
pass
| class Parseerror(Exception):
pass
class Unsupportedfile(Exception):
pass
class Multipleparentsgff(UnsupportedFile):
pass |
mariadb = dict(
ip_address = 'localhost',
port = 3307,
user = 'root',
password = 'password',
db = 'cego',
users_table = 'users'
)
test = dict(
query = 'SELECT id, firstName, lastName, email FROM users',
filename = 'Test.txt'
) | mariadb = dict(ip_address='localhost', port=3307, user='root', password='password', db='cego', users_table='users')
test = dict(query='SELECT id, firstName, lastName, email FROM users', filename='Test.txt') |
class Graph:
def __init__ (self, adj = None):
''' Creates new graph from adjacency list. '''
if adj is None:
adj = []
self.adj = adj
def GetEdges (self):
''' Returns list of the graph's edges. '''
edges = []
... | class Graph:
def __init__(self, adj=None):
""" Creates new graph from adjacency list. """
if adj is None:
adj = []
self.adj = adj
def get_edges(self):
""" Returns list of the graph's edges. """
edges = []
for vertex in self.adj:
for edge ... |
def philosophy(statement):
def thought():
return statement
return thought
question = philosophy('To B, or not to B. It depends where the bomb is.')
print(question())
| def philosophy(statement):
def thought():
return statement
return thought
question = philosophy('To B, or not to B. It depends where the bomb is.')
print(question()) |
pass
# import os
# from unittest.mock import MagicMock, patch
# import pytest
# from JumpscaleZrobot.test.utils import ZrobotBaseTest, mock_decorator
# from node_port_manager import NODE_CLIENT, NodePortManager
# from zerorobot.template.state import StateCheckError
# import itertools
# class TestNodePortManagerTemp... | pass |
test = { 'name': 'q41',
'points': 1,
'suites': [ { 'cases': [ { 'code': '>>> # Oops, your name is assigned to the wrong data type!;\n'
'>>> type(year_population_crossed_6_billion) == int or type(year_population_crossed_6_billion) == np.int32\n'
... | test = {'name': 'q41', 'points': 1, 'suites': [{'cases': [{'code': '>>> # Oops, your name is assigned to the wrong data type!;\n>>> type(year_population_crossed_6_billion) == int or type(year_population_crossed_6_billion) == np.int32\nTrue', 'hidden': False, 'locked': False}, {'code': '>>> year_population_crossed_6_bil... |
class UrlConstructor:
def __init__(self, key='', base_url='https://androzoo.uni.lu/api/download?apikey={0}&sha256={01}'):
self.base_url = base_url
self.key = key
def construct(self, apk):
return self.base_url.format(self.key, apk.sha256)
| class Urlconstructor:
def __init__(self, key='', base_url='https://androzoo.uni.lu/api/download?apikey={0}&sha256={01}'):
self.base_url = base_url
self.key = key
def construct(self, apk):
return self.base_url.format(self.key, apk.sha256) |
class Node:
def __init__(self,data=None,next=None,position = 0):
self.data = data
self.next = next
self.position = position
class LinkedList:
def __init__(self) -> None:
self.head = None # Initialising the head as None
def insetElement(self,data):
newNode = ... | class Node:
def __init__(self, data=None, next=None, position=0):
self.data = data
self.next = next
self.position = position
class Linkedlist:
def __init__(self) -> None:
self.head = None
def inset_element(self, data):
new_node = node(data)
if self.head:
... |
def solution(A):
count = []
len_a = len(A)
for i in range(len_a):
sub_count = 0
for j in range(len_a):
if i != j and A[i] % A[j] != 0:
sub_count += 1
count.append(sub_count)
return count
print(solution([3, 1, 2, 3, 6]))
| def solution(A):
count = []
len_a = len(A)
for i in range(len_a):
sub_count = 0
for j in range(len_a):
if i != j and A[i] % A[j] != 0:
sub_count += 1
count.append(sub_count)
return count
print(solution([3, 1, 2, 3, 6])) |
# def isPrime(number):
# counter = 2
# isPrime = True
#
# while counter < number:
# if number % counter == 0:
# isPrime = False
# break
#
# counter = counter + 1
#
# return isPrime
# function isPrime
def isPrime(number):
counter = 2
while counter < numb... | def is_prime(number):
counter = 2
while counter < number:
if number % counter == 0:
return False
counter = counter + 1
return True
print('Give me a number?')
input_num = int(input())
if is_prime(inputNum):
print("It's a prime")
else:
print("It's not a prime") |
i = 0
num = int(input("Enter your number:- "))
while i <= num:
if num > 0:
print("it is positive")
elif num < 0:
print("it is negative")
else :
print("zero")
i = i + 1
| i = 0
num = int(input('Enter your number:- '))
while i <= num:
if num > 0:
print('it is positive')
elif num < 0:
print('it is negative')
else:
print('zero')
i = i + 1 |
DATA = {
"B01003_001E": "Total Population",
"B01002_001E": "Median Age",
"B11005_001E": "Total Households Age",
"B11005_002E": "Total Households With Under 18",
# household income
"B19013_001E": "Median Household Income",
"B19001_001E": "Total Households Income",
"B19001_002E": "Hou... | data = {'B01003_001E': 'Total Population', 'B01002_001E': 'Median Age', 'B11005_001E': 'Total Households Age', 'B11005_002E': 'Total Households With Under 18', 'B19013_001E': 'Median Household Income', 'B19001_001E': 'Total Households Income', 'B19001_002E': 'Household Income $0 - $10,000', 'B19001_003E': 'Household In... |
'''Basic object to store the agents and auxiliary content in the agent system
graph. The object should be considered to be replaced with namedtuple at some
point, once the default field has matured
'''
class Node(object):
'''Basic object to store agent and auxiliary content in the agent system.
Parameters
... | """Basic object to store the agents and auxiliary content in the agent system
graph. The object should be considered to be replaced with namedtuple at some
point, once the default field has matured
"""
class Node(object):
"""Basic object to store agent and auxiliary content in the agent system.
Parameters
... |
masuk=int(input("Masukkan Jam Masuk = "))
keluar=int(input("Masukkan Jam Keluar ="))
lama=keluar-masuk
payment=12000
print("Lama Mengajar = ", lama, "jam")
if lama <=1:
satu_jam_pertama=payment
print("Biaya Mengajar= Rp", satu_jam_pertama)
elif lama <10:
biaya_selanjutnya = (lama+1)*3000+payment
print("... | masuk = int(input('Masukkan Jam Masuk = '))
keluar = int(input('Masukkan Jam Keluar ='))
lama = keluar - masuk
payment = 12000
print('Lama Mengajar = ', lama, 'jam')
if lama <= 1:
satu_jam_pertama = payment
print('Biaya Mengajar= Rp', satu_jam_pertama)
elif lama < 10:
biaya_selanjutnya = (lama + 1) * 3000 +... |
# dataset settings
dataset_type = 'PhoneDataset'
data_root = '/home/ubuntu/tienpv/datasets/PhoneDatasets/COCO2017/'
ann_files = '/home/ubuntu/tienpv/datasets/PhoneDatasets/COCO2017/annotations/instances_train2017_cell_phone_format_widerface.txt'
val_data_root = '/home/ubuntu/tienpv/datasets/PhoneDatasets/COCO2017/'
va... | dataset_type = 'PhoneDataset'
data_root = '/home/ubuntu/tienpv/datasets/PhoneDatasets/COCO2017/'
ann_files = '/home/ubuntu/tienpv/datasets/PhoneDatasets/COCO2017/annotations/instances_train2017_cell_phone_format_widerface.txt'
val_data_root = '/home/ubuntu/tienpv/datasets/PhoneDatasets/COCO2017/'
val_ann_files = '/home... |
def longestPeak(array):
max_size = 0
i = 1
while i < len(array) - 1:
peak = array[i - 1] < array[i] > array[i + 1]
if not peak:
i += 1
continue
left = i - 1
right = i + 1
while left >= 0 and array[left] < array[left + 1]:
left ... | def longest_peak(array):
max_size = 0
i = 1
while i < len(array) - 1:
peak = array[i - 1] < array[i] > array[i + 1]
if not peak:
i += 1
continue
left = i - 1
right = i + 1
while left >= 0 and array[left] < array[left + 1]:
left -= 1... |
# ========================
# Information
# ========================
# Direct Link: https://www.hackerrank.com/challenges/s10-standard-deviation
# Difficulty: Easy
# Max Score: 30
# Language: Python
# ========================
# Solution
# ========================
N = int(input())
X = list(map(int, input... | n = int(input())
x = list(map(int, input().strip().split(' ')))
mean = sum(X) / N
sum = 0
for i in range(N):
sum += (X[i] - MEAN) ** 2 / N
print(round(sum ** 0.5, 1)) |
class Entity(object):
def __init__(self, name, represented_class_name=None, parent_entity=None,
is_abstract=False, attributes=None, relationships=None):
self.name = name
self.represented_class_name = represented_class_name or name
self.parent_entity = parent_entity
self.i... | class Entity(object):
def __init__(self, name, represented_class_name=None, parent_entity=None, is_abstract=False, attributes=None, relationships=None):
self.name = name
self.represented_class_name = represented_class_name or name
self.parent_entity = parent_entity
self.is_abstract ... |
class Solution:
def answer(self, current, end, scalar):
if current == end:
return scalar
self.visited.add(current)
if current in self.graph:
for i in self.graph[current]:
if i[0] not in self.visited:
a = self.answer(i[0], end, scala... | class Solution:
def answer(self, current, end, scalar):
if current == end:
return scalar
self.visited.add(current)
if current in self.graph:
for i in self.graph[current]:
if i[0] not in self.visited:
a = self.answer(i[0], end, scal... |
def isIsosceles(x, y, z):
if x <= 0 or y <=0 or z <=0:
return False
if x == y:
return True
if y == z:
return True
if x == z:
return True
else:
return False
print(isIsosceles(-2, -2, 3))
print(isIsosceles(2, 3, 2))
def isIsosceles(x, y, z):
if x <= 0 or y <=... | def is_isosceles(x, y, z):
if x <= 0 or y <= 0 or z <= 0:
return False
if x == y:
return True
if y == z:
return True
if x == z:
return True
else:
return False
print(is_isosceles(-2, -2, 3))
print(is_isosceles(2, 3, 2))
def is_isosceles(x, y, z):
if x <= 0... |
class CmdResponse:
__status: bool
__type: str
__data: dict
__content: str
def __init__(self, status: bool, contentType: str):
self.__status = status
self.__type = contentType
self.__data = {'status': status}
self.__content = None
def setData(self, ... | class Cmdresponse:
__status: bool
__type: str
__data: dict
__content: str
def __init__(self, status: bool, contentType: str):
self.__status = status
self.__type = contentType
self.__data = {'status': status}
self.__content = None
def set_data(self, data: object)... |
with open("pytest_results.xml", "w") as f:
f.write("<?xml version='1.0' encoding='utf-8'?>")
f.write("<test>")
f.write("<!-- No tests executed -->")
f.write("</test>")
| with open('pytest_results.xml', 'w') as f:
f.write("<?xml version='1.0' encoding='utf-8'?>")
f.write('<test>')
f.write('<!-- No tests executed -->')
f.write('</test>') |
def exec(path: str, data: bytes) -> None:
fs = open(path, 'wb')
fs.write(data)
fs.close()
| def exec(path: str, data: bytes) -> None:
fs = open(path, 'wb')
fs.write(data)
fs.close() |
# model
batch = 1
in_chans = 1
out_chans = 1
in_rows = 4
in_cols = 4
out_rows = 8
out_cols = 8
ker_rows = 3
ker_cols = 3
stride = 2
# pad is 0 (left: 0 right: 1 top: 0 bottom: 1)
input_table = [x for x in range(batch * in_rows * in_cols * in_chans)]
kernel_table = [x for x in range(out_chans * ker_rows * ker_cols * in... | batch = 1
in_chans = 1
out_chans = 1
in_rows = 4
in_cols = 4
out_rows = 8
out_cols = 8
ker_rows = 3
ker_cols = 3
stride = 2
input_table = [x for x in range(batch * in_rows * in_cols * in_chans)]
kernel_table = [x for x in range(out_chans * ker_rows * ker_cols * in_chans)]
out_table = [0 for x in range(batch * out_rows ... |
def main():
# input
css = [[*map(int, input().split())] for _ in range(3)]
# compute
for i in range(3):
if css[i-1][i-1]+css[i][i] != css[i-1][i]+css[i][i-1]:
print('No')
exit()
# output
print('Yes')
if __name__ == '__main__':
main()
| def main():
css = [[*map(int, input().split())] for _ in range(3)]
for i in range(3):
if css[i - 1][i - 1] + css[i][i] != css[i - 1][i] + css[i][i - 1]:
print('No')
exit()
print('Yes')
if __name__ == '__main__':
main() |
'''
This is a math Module
Do Some thing
'''
def add(a=0, b=0):
return a + b;
def minus(a=0, b=0):
return a - b;
def multy(a=1, b=1):
return a * b;
| """
This is a math Module
Do Some thing
"""
def add(a=0, b=0):
return a + b
def minus(a=0, b=0):
return a - b
def multy(a=1, b=1):
return a * b |
class MyClass:
data = 3
a = MyClass()
b = MyClass()
a.data = 5
print(a.data)
print(b.data)
| class Myclass:
data = 3
a = my_class()
b = my_class()
a.data = 5
print(a.data)
print(b.data) |
class Solution:
def findLHS(self, nums) -> int:
nums.sort()
pre_num, pre_length = -1, 0
cur_num, cur_length = -1, 0
i = 0
max_length = 0
while i < len(nums):
if nums[i] == cur_num:
cur_length += 1
else:
if cur_nu... | class Solution:
def find_lhs(self, nums) -> int:
nums.sort()
(pre_num, pre_length) = (-1, 0)
(cur_num, cur_length) = (-1, 0)
i = 0
max_length = 0
while i < len(nums):
if nums[i] == cur_num:
cur_length += 1
else:
... |
def validate_count(d):
print(len([0 for e in d if((c:=e[2].count(e[1]))>e[0][0])and(c<e[0][1])]))
def validate_position(d):
print(len([0 for e in d if(e[2][e[0][0]-1]==e[1])^(e[2][e[0][1]-1]==e[1])]))
if __name__ == "__main__":
with open('2020/input/day02.txt') as f:
database = [[[*map(int, (e := ... | def validate_count(d):
print(len([0 for e in d if (c := e[2].count(e[1])) > e[0][0] and c < e[0][1]]))
def validate_position(d):
print(len([0 for e in d if (e[2][e[0][0] - 1] == e[1]) ^ (e[2][e[0][1] - 1] == e[1])]))
if __name__ == '__main__':
with open('2020/input/day02.txt') as f:
database = [[[*... |
# Copyright 2017 Brocade Communications Systems, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may also obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requir... | class Pyfos_Type:
type_na = 0
type_int = 1
type_wwn = 2
type_str = 3
type_bool = 4
type_ip_addr = 5
type_ipv6_addr = 6
type_zoning_name = 7
type_domain_port = 8
def __init__(self, pyfos_type):
self.pyfos_type = pyfos_type
def get_type(self):
return self.pyfo... |
{
"includes": [
"../common.gypi"
],
"targets": [
{
"configurations": {
"Release": {
"defines": [
"NDEBUG"
]
}
},
"include_dirs": [
... | {'includes': ['../common.gypi'], 'targets': [{'configurations': {'Release': {'defines': ['NDEBUG']}}, 'include_dirs': ['apr-iconv/include'], 'sources': ['dependencies/apr-iconv/lib/iconv.c', 'dependencies/apr-iconv/lib/iconv_ces.c', 'dependencies/apr-iconv/lib/iconv_ces_euc.c', 'dependencies/apr-iconv/lib/iconv_ces_iso... |
def flatten_forest(forest):
flat_forest = []
for row in forest:
flat_forest += row
return flat_forest
def deflatten_forest(forest_1d, rows):
cols = len(forest_1d) // rows
forest_2d = []
for i in range(cols):
forest_slice = forest_1d[i*cols: (i+1)*cols]
forest_2d.append(... | def flatten_forest(forest):
flat_forest = []
for row in forest:
flat_forest += row
return flat_forest
def deflatten_forest(forest_1d, rows):
cols = len(forest_1d) // rows
forest_2d = []
for i in range(cols):
forest_slice = forest_1d[i * cols:(i + 1) * cols]
forest_2d.app... |
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ /... | backup_perfdata_enabled = True
def performancedata_restore(pre_restore=True):
global backup_perfdata_enabled
site = config.default_site()
html.live.set_only_sites([site])
if pre_restore:
data = html.live.query('GET status\nColumns: process_performance_data')
if data:
backup_... |
def create_mine_field(n, m, mines):
mine_field = [
[0 for _ in range(m)
] for _ in range(n)
]
for mine in mines:
x, y = mine
mine_field[x-1][y-1] = '*'
return mine_field
def neighbours(i, j, m):
nearest = [m[x][y] for x in [i-1, i, i+1] for y in [j-1, j, j+1]
... | def create_mine_field(n, m, mines):
mine_field = [[0 for _ in range(m)] for _ in range(n)]
for mine in mines:
(x, y) = mine
mine_field[x - 1][y - 1] = '*'
return mine_field
def neighbours(i, j, m):
nearest = [m[x][y] for x in [i - 1, i, i + 1] for y in [j - 1, j, j + 1] if x in range(0,... |
line = '-'*39
blank = '|' + ' '*37 + '|'
print(line)
print(blank)
print(blank)
print(blank)
print(blank)
print(blank)
print(line)
| line = '-' * 39
blank = '|' + ' ' * 37 + '|'
print(line)
print(blank)
print(blank)
print(blank)
print(blank)
print(blank)
print(line) |
class Solution:
def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float:
if len(a:=nums1) > len(b:=nums2):
a, b = b, a
n = len(a)
m = len(b)
median, i, j = 0, 0, 0
min_index = 0
max_index = n
... | class Solution:
def find_median_sorted_arrays(self, nums1: List[int], nums2: List[int]) -> float:
if len((a := nums1)) > len((b := nums2)):
(a, b) = (b, a)
n = len(a)
m = len(b)
(median, i, j) = (0, 0, 0)
min_index = 0
max_index = n
while min_inde... |
'''
Python function to check whether a number is divisible by another number.
Accept two integers values form the user.
'''
def multiple(m, n):
return True if m % n == 0 else False
print(multiple(20, 5))
print(multiple(7, 2))
| """
Python function to check whether a number is divisible by another number.
Accept two integers values form the user.
"""
def multiple(m, n):
return True if m % n == 0 else False
print(multiple(20, 5))
print(multiple(7, 2)) |
#
# PySNMP MIB module MISSION-CRITICAL-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/MISSION-CRITICAL-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:12:55 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (defau... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_union, value_size_constraint, constraints_intersection, value_range_constraint) ... |
num = 111
num = 222
num = 333333
num = 333
num4 = 44444
| num = 111
num = 222
num = 333333
num = 333
num4 = 44444 |
__author__ = "hoongeun"
__version__ = "0.0.1"
__copyright__ = "Copyright (c) hoongeun"
__license__ = "Beer ware"
| __author__ = 'hoongeun'
__version__ = '0.0.1'
__copyright__ = 'Copyright (c) hoongeun'
__license__ = 'Beer ware' |
def test1():
inp="0 2 7 0"
inp="4 10 4 1 8 4 9 14 5 1 14 15 0 15 3 5"
nums = list(map(lambda x: int(x), inp.split()))
hist = [ nums ]
step = 1
current = nums[:]
while True:
#print('step', step, 'current', current)
#search max
m = max(current)
#max index
idx = current.index(m)
current[idx] = 0
... | def test1():
inp = '0 2 7 0'
inp = '4 10 4 1 8 4 9 14 5 1 14 15 0 15 3 5'
nums = list(map(lambda x: int(x), inp.split()))
hist = [nums]
step = 1
current = nums[:]
while True:
m = max(current)
idx = current.index(m)
current[idx] = 0
idx += 1
while m > 0... |
# test floor-division and modulo operators
@micropython.viper
def div(x:int, y:int) -> int:
return x // y
@micropython.viper
def mod(x:int, y:int) -> int:
return x % y
def dm(x, y):
print(div(x, y), mod(x, y))
for x in (-6, 6):
for y in range(-7, 8):
if y == 0:
continue
d... | @micropython.viper
def div(x: int, y: int) -> int:
return x // y
@micropython.viper
def mod(x: int, y: int) -> int:
return x % y
def dm(x, y):
print(div(x, y), mod(x, y))
for x in (-6, 6):
for y in range(-7, 8):
if y == 0:
continue
dm(x, y) |
# -*- coding: utf-8 -*-
def func(precess_data, x):
precess_data = list(range(0, 100, 3))
low = 0
high = 34
guess = int((low + high) / 2)
while precess_data[guess] != x:
if precess_data[guess] < x:
low = guess
elif precess_data[guess] > x:
high ... | def func(precess_data, x):
precess_data = list(range(0, 100, 3))
low = 0
high = 34
guess = int((low + high) / 2)
while precess_data[guess] != x:
if precess_data[guess] < x:
low = guess
elif precess_data[guess] > x:
high = guess
else:
break
... |
'''
Created on 08.06.2014
@author: ionitadaniel19
'''
map_selenium_objects={
"SUSER":"name=login",
"SPWD":"name=password",
"SREMEMBER":"id=remember_me",
"SSUBMIT":"name=commit",
"SKEYWORD":"id=q... | """
Created on 08.06.2014
@author: ionitadaniel19
"""
map_selenium_objects = {'SUSER': 'name=login', 'SPWD': 'name=password', 'SREMEMBER': 'id=remember_me', 'SSUBMIT': 'name=commit', 'SKEYWORD': 'id=q1c', 'SSHOWANSER': 'name=showanswer', 'SANSWER': 'css=#answer > p'} |
linesize = int(input())
table = [[0 for x in range(4)] for y in range(linesize)]
queue = []
for i in range(linesize):
entry = input().split(' ')
# print(entry, 'pushed')
country = (int(entry[1]),int(entry[2]),int(entry[3]),str(entry[0]))
queue.append(country)
out = sorted(queue, key = lambda x: x[3])
o... | linesize = int(input())
table = [[0 for x in range(4)] for y in range(linesize)]
queue = []
for i in range(linesize):
entry = input().split(' ')
country = (int(entry[1]), int(entry[2]), int(entry[3]), str(entry[0]))
queue.append(country)
out = sorted(queue, key=lambda x: x[3])
out = sorted(out, key=lambda x... |
name = input('Enter your Name: ')
sen = "Hello "+ name +" ,How r u today??"
print(sen)
para = ''' hey , this is a
multiline comment.Lets see how
it works.'''
print(para)
| name = input('Enter your Name: ')
sen = 'Hello ' + name + ' ,How r u today??'
print(sen)
para = ' hey , this is a\n multiline comment.Lets see how\n it works.'
print(para) |
x, y = map(float, input().split())
exp = 0.0001
count = 1
while y - x > exp:
x += x * 0.7
count += 1
print(count) | (x, y) = map(float, input().split())
exp = 0.0001
count = 1
while y - x > exp:
x += x * 0.7
count += 1
print(count) |
#!/usr/bin/python
class helloworld:
def __init__(self):
print("Hello World!")
helloworld()
| class Helloworld:
def __init__(self):
print('Hello World!')
helloworld() |
def init():
return {
"ingest": {
"outputKafkaTopic": "telemetry.ingest",
"inputPrefix": "ingest",
"dependentSinkSources": [
{
"type": "azure",
"prefix": "raw"
},
{
... | def init():
return {'ingest': {'outputKafkaTopic': 'telemetry.ingest', 'inputPrefix': 'ingest', 'dependentSinkSources': [{'type': 'azure', 'prefix': 'raw'}, {'type': 'azure', 'prefix': 'unique'}, {'type': 'azure', 'prefix': 'channel'}, {'type': 'azure', 'prefix': 'telemetry-denormalized/raw'}, {'type': 'druid', 'pr... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
RECOVER_ITEM = [
("n 't ", "n't ")
]
def recover_quotewords(text):
for before, after in RECOVER_ITEM:
text = text.replace(before, after)
return text
| recover_item = [("n 't ", "n't ")]
def recover_quotewords(text):
for (before, after) in RECOVER_ITEM:
text = text.replace(before, after)
return text |
names = [
'Christal',
'Ray',
'Ron'
]
print(names)
| names = ['Christal', 'Ray', 'Ron']
print(names) |
def solution(numBottles,numExchange):
finalsum = numBottles
emptyBottles = numBottles
numBottles = 0
while (emptyBottles >= numExchange):
numBottles = emptyBottles // numExchange
emptyBottles -= emptyBottles // numExchange * numExchange
finalsum += numBottles
empt... | def solution(numBottles, numExchange):
finalsum = numBottles
empty_bottles = numBottles
num_bottles = 0
while emptyBottles >= numExchange:
num_bottles = emptyBottles // numExchange
empty_bottles -= emptyBottles // numExchange * numExchange
finalsum += numBottles
empty_bot... |
def undistort_image(image, objectpoints, imagepoints):
# Get image size
img_size = (image.shape[1], image.shape[0])
# Calibrate camera based on objectpoints, imagepoints, and image size
ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objectpoints, imagepoints, img_size, None, None)
# Call cv2.u... | def undistort_image(image, objectpoints, imagepoints):
img_size = (image.shape[1], image.shape[0])
(ret, mtx, dist, rvecs, tvecs) = cv2.calibrateCamera(objectpoints, imagepoints, img_size, None, None)
dst = cv2.undistort(image, mtx, dist, None, mtx)
return dst
def get_shresholded_img(image, grad_thresh... |
largest=None
smallest=None
while True:
number=input("Enter a number:")
if number == "done":
break
try:
number=int(number)
if largest == None:
largest = number
elif largest < number:
largest = number
if ... | largest = None
smallest = None
while True:
number = input('Enter a number:')
if number == 'done':
break
try:
number = int(number)
if largest == None:
largest = number
elif largest < number:
largest = number
if smallest == None:
smal... |
class UsdValue(float):
def __init__(self, v) -> None:
super().__init__()
class UsdPrice(float):
def __init__(self, v) -> None:
super().__init__() | class Usdvalue(float):
def __init__(self, v) -> None:
super().__init__()
class Usdprice(float):
def __init__(self, v) -> None:
super().__init__() |
def filter(fname,data):
list=[]
for i in range(len(data)):
f=fname(data[i])
if f==True:
list.append(data[i])
return list
def map(fname,newdata):
list=[]
for i in range(len(newdata)):
f=fname(newdata[i])
list.append(f)
... | def filter(fname, data):
list = []
for i in range(len(data)):
f = fname(data[i])
if f == True:
list.append(data[i])
return list
def map(fname, newdata):
list = []
for i in range(len(newdata)):
f = fname(newdata[i])
list.append(f)
return list
def redu... |
#
numbers = [str(x) for x in range(32)]
letters = [chr(x) for x in range(97, 123)]
crate = '''
sandbox crate
map {boot: @init}
/*initialize utility vars and register vars*/
service init {
writer = 0
alpha = 0
beta = 0
status = 0'''
for letter in letters:
crate += '\n ' + letter + ' = 0'
crate +=... | numbers = [str(x) for x in range(32)]
letters = [chr(x) for x in range(97, 123)]
crate = '\nsandbox crate\n\nmap {boot: @init}\n/*initialize utility vars and register vars*/\nservice init {\n writer = 0\n alpha = 0\n beta = 0\n status = 0'
for letter in letters:
crate += '\n ' + letter + ' = 0'
crate... |
# coding: utf-8
# http://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-a-parser
DEFAULT_PARSER = 'lxml'
ALLOWED_CONTENT_TYPES = [
'text/html',
'image/',
]
FINDER_PIPELINE = (
'haul.finders.pipeline.html.img_src_finder',
'haul.finders.pipeline.html.a_href_finder',
'haul.finders.pipelin... | default_parser = 'lxml'
allowed_content_types = ['text/html', 'image/']
finder_pipeline = ('haul.finders.pipeline.html.img_src_finder', 'haul.finders.pipeline.html.a_href_finder', 'haul.finders.pipeline.css.background_image_finder')
extender_pipeline = ('haul.extenders.pipeline.google.blogspot_s1600_extender', 'haul.ex... |
# pythran export _brief_loop(float64[:,:], uint8[:,:],
# intp[:,:], int[:,:], int[:,:])
def _brief_loop(image, descriptors, keypoints, pos0, pos1):
for k in range(len(keypoints)):
kr, kc = keypoints[k]
for p in range(len(pos0)):
pr0, pc0 = pos0[p]
... | def _brief_loop(image, descriptors, keypoints, pos0, pos1):
for k in range(len(keypoints)):
(kr, kc) = keypoints[k]
for p in range(len(pos0)):
(pr0, pc0) = pos0[p]
(pr1, pc1) = pos1[p]
descriptors[k, p] = image[kr + pr0, kc + pc0] < image[kr + pr1, kc + pc1] |
factors = {
1:{
1:"I",5:"I",9:"I",13:"I",17:"I",21:"I",25:"I",29:"I",33:"I",37:"I",41:"I",45:"I",49:"I",53:"I",57:"I"
, 2:"S", 6:"S", 10:"S", 14:"S", 18:"S", 22:"S", 26:"S",30:"S" ,34:"S",38:"S",42:"S",46:"S",50:"S",54:"S",58:"S"
, 3:"T", 7:"T" , 11:"T", 15:"T", 19:"T",23:"T"... | factors = {1: {1: 'I', 5: 'I', 9: 'I', 13: 'I', 17: 'I', 21: 'I', 25: 'I', 29: 'I', 33: 'I', 37: 'I', 41: 'I', 45: 'I', 49: 'I', 53: 'I', 57: 'I', 2: 'S', 6: 'S', 10: 'S', 14: 'S', 18: 'S', 22: 'S', 26: 'S', 30: 'S', 34: 'S', 38: 'S', 42: 'S', 46: 'S', 50: 'S', 54: 'S', 58: 'S', 3: 'T', 7: 'T', 11: 'T', 15: 'T', 19: 'T... |
wkidInfo = {
'4326':{'type':'gcs', 'path':'World/WGS 1984.prj'},
'102100':{'type':'pcs', 'path':r'World/WGS 1984 Web Mercator (auxiliary sphere).prj'},
'3857' : {'type':'pcs', 'path':r'World/WGS 1984 Web Mercator (auxiliary sphere).prj'}
} | wkid_info = {'4326': {'type': 'gcs', 'path': 'World/WGS 1984.prj'}, '102100': {'type': 'pcs', 'path': 'World/WGS 1984 Web Mercator (auxiliary sphere).prj'}, '3857': {'type': 'pcs', 'path': 'World/WGS 1984 Web Mercator (auxiliary sphere).prj'}} |
#import ctypes
#import GdaImport
#import matplotlib.pyplot as plt
# getting example
# gjden
def GDA_MAIN(gda_obj):
per='the apk permission:\n'
# per+=gda_obj.GetAppString()
# per+=gda_obj.GetCert()
# per+=gda_obj.GetUrlString()
#
per+=gda_obj.GetPermission()
gda_... | def gda_main(gda_obj):
per = 'the apk permission:\n'
per += gda_obj.GetPermission()
gda_obj.log(per)
tofile = open('out.txt', 'w')
tofile.write(per)
tofile.close()
return 0 |
# Copyright 2016 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.
{
'targets': [
{
'target_name': 'control_bar',
'dependencies': [
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
... | {'targets': [{'target_name': 'control_bar', 'dependencies': ['<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior', 'profile_browser_proxy'], 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi']}, {'target_name': 'create_... |
# Part 1 of the Python Review lab.
def hello_world():
print("hello world")
pass
def greet_by_name(name):
print("please enter your name")
name = input
print
pass
def encode(x):
pass
def decode(coded_message):
pass | def hello_world():
print('hello world')
pass
def greet_by_name(name):
print('please enter your name')
name = input
print
pass
def encode(x):
pass
def decode(coded_message):
pass |
pizzas = ["triple carne", "extra queso", "suprema"]
friend_pizzas = ["triple carne", "extra queso", "suprema"]
pizzas.append("baggel")
friend_pizzas.append("hawaiana")
print("Mis pizzas favoritas son:")
for i in range(0,len(pizzas)):
print(pizzas[i])
print()
print("Las pizzas favoritas de mi amigo son:")
for i ... | pizzas = ['triple carne', 'extra queso', 'suprema']
friend_pizzas = ['triple carne', 'extra queso', 'suprema']
pizzas.append('baggel')
friend_pizzas.append('hawaiana')
print('Mis pizzas favoritas son:')
for i in range(0, len(pizzas)):
print(pizzas[i])
print()
print('Las pizzas favoritas de mi amigo son:')
for i in ... |
# -*- coding: utf-8 -*-
GITHUB_STRING = 'https://github.com/earaujoassis/watchman/archive/v{0}.zip'
NAME = "agents"
VERSION = "0.2.4"
| github_string = 'https://github.com/earaujoassis/watchman/archive/v{0}.zip'
name = 'agents'
version = '0.2.4' |
def first(arr, low , high):
if high >= low:
mid = low + (high - low)//2
if (mid ==0 or arr[mid-1] == 0) and arr[mid] == 1:
return mid
elif arr[mid] == 0:
return first(arr, mid+1, high)
else:
return first(arr, low, mid-1)
return -1
def row_with... | def first(arr, low, high):
if high >= low:
mid = low + (high - low) // 2
if (mid == 0 or arr[mid - 1] == 0) and arr[mid] == 1:
return mid
elif arr[mid] == 0:
return first(arr, mid + 1, high)
else:
return first(arr, low, mid - 1)
return -1
def ... |
def get_path_components(path):
path = path.strip("/").split("/")
path = [c for c in path if c]
normalized = []
for comp in path:
if comp == ".":
continue
elif comp == "..":
if normalized:
normalized.pop()
else:
raise Va... | def get_path_components(path):
path = path.strip('/').split('/')
path = [c for c in path if c]
normalized = []
for comp in path:
if comp == '.':
continue
elif comp == '..':
if normalized:
normalized.pop()
else:
raise val... |
#Belajar String Method
#https://docs.python.org/3/library/stdtypes.html#string-methods
nama = "muhammad aris septanugroho"
print(nama)
print(nama.upper()) #Huruf besar semua
print(nama.capitalize()) #Huruf besar kata pertama
print(nama.title()) #Huruf besar tiap kata
print(nama.split(" ")) #Memisah data me... | nama = 'muhammad aris septanugroho'
print(nama)
print(nama.upper())
print(nama.capitalize())
print(nama.title())
print(nama.split(' ')) |
def product_left_recursive(alist, result=None):
if alist == []:
return result
g = result[-1] * alist[0]
result.append(g)
return product_left_recursive(alist[1:], result)
def product_left(alist):
new_list = [1]
for index in range(1, len(alist)):
value = new_list[-1] * alist[inde... | def product_left_recursive(alist, result=None):
if alist == []:
return result
g = result[-1] * alist[0]
result.append(g)
return product_left_recursive(alist[1:], result)
def product_left(alist):
new_list = [1]
for index in range(1, len(alist)):
value = new_list[-1] * alist[index... |
fileName = ["nohup_2", "nohup_1", "nohup_4", "nohup"]
Fo = open("new nohup", "w")
for fil in fileName:
lineNum = 0
with open(fil) as F:
for line in F:
if lineNum % 10 == 0:
Fo.write(",\t".join(line.split()))
Fo.write("\n")
lineNum += 1
Fo.w... | file_name = ['nohup_2', 'nohup_1', 'nohup_4', 'nohup']
fo = open('new nohup', 'w')
for fil in fileName:
line_num = 0
with open(fil) as f:
for line in F:
if lineNum % 10 == 0:
Fo.write(',\t'.join(line.split()))
Fo.write('\n')
line_num += 1
F... |
# Python - 3.6.0
test.assert_equals(last([1, 2, 3, 4, 5]), 5)
test.assert_equals(last('abcde'), 'e')
test.assert_equals(last(1, 'b', 3, 'd', 5), 5)
| test.assert_equals(last([1, 2, 3, 4, 5]), 5)
test.assert_equals(last('abcde'), 'e')
test.assert_equals(last(1, 'b', 3, 'd', 5), 5) |
class Student:
def __init__(self,m1,m2):
self.m1 = m1
self.m2 = m2
def sum(self, a = None, b = None, c = None):
addition = 0
if a!=None and b!=None and c!=None:
addition = a + b + c
elif a!=None and b!= None:
addition = a + b
... | class Student:
def __init__(self, m1, m2):
self.m1 = m1
self.m2 = m2
def sum(self, a=None, b=None, c=None):
addition = 0
if a != None and b != None and (c != None):
addition = a + b + c
elif a != None and b != None:
addition = a + b
else:... |
a = int(input("Enter number of elements in set A "))
A = set(map(int,input("# Spaced Separated list of elements of A ").split())) # Spaced Separated list of elements of A
n = int(input("Number of sets ")) # Number of sets
for i in range(n):
p = input("Enter the operation and number of elements in set"+i).split()
... | a = int(input('Enter number of elements in set A '))
a = set(map(int, input('# Spaced Separated list of elements of A ').split()))
n = int(input('Number of sets '))
for i in range(n):
p = input('Enter the operation and number of elements in set' + i).split()
s2 = set(map(int, input('Enter space separated list o... |
class Solution:
def sqrt(self, x):
low = 0
high = 65536
best = 0
while high > low:
mid = (high + low) / 2
sqr = mid ** 2
if sqr > x:
high = mid
elif sqr == x:
return mid
else... | class Solution:
def sqrt(self, x):
low = 0
high = 65536
best = 0
while high > low:
mid = (high + low) / 2
sqr = mid ** 2
if sqr > x:
high = mid
elif sqr == x:
return mid
else:
... |
def palindrome(word, ind):
if word == word[::-1]:
return f"{word} is a palindrome"
if word[ind] != word[len(word) - 1 - ind]:
return f"{word} is not a palindrome"
return palindrome(word, ind + 1)
print(palindrome("abcba", 0))
print(palindrome("peter", 0))
| def palindrome(word, ind):
if word == word[::-1]:
return f'{word} is a palindrome'
if word[ind] != word[len(word) - 1 - ind]:
return f'{word} is not a palindrome'
return palindrome(word, ind + 1)
print(palindrome('abcba', 0))
print(palindrome('peter', 0)) |
#NETWORK
LOCALHOST = "127.0.0.1"
PI_ADDRESS = "192.168.0.1"
PORT = 5000
#STATE
MOVEMENT_MARGIN = 2
KICK_TIMEOUT = 1
LAST_POSITION = -1
PLAYER_LENGTH = 2
NOISE_THRESHOLD = 3
MIN_VELOCITY_THRESHOLD = 300
OPEN_PREP_RANGE = -30
BLOCK_PREP_RANGE = 100
OPEN_KICK_RANGE = -20
BLOCK_KICK_RANGE = 60
KICK_ANGLE = 55
PREP_ANGL... | localhost = '127.0.0.1'
pi_address = '192.168.0.1'
port = 5000
movement_margin = 2
kick_timeout = 1
last_position = -1
player_length = 2
noise_threshold = 3
min_velocity_threshold = 300
open_prep_range = -30
block_prep_range = 100
open_kick_range = -20
block_kick_range = 60
kick_angle = 55
prep_angle = -30
block_angle ... |
#! /usr/bin/env python3.6
#a = 'str'
a = '32'
print(f'float(a) = {float(a)}')
print(f'int(a) = {int(a)}')
if(isinstance(a, str)):
print("Yes, it is string.")
else:
print("No, it is not string.")
| a = '32'
print(f'float(a) = {float(a)}')
print(f'int(a) = {int(a)}')
if isinstance(a, str):
print('Yes, it is string.')
else:
print('No, it is not string.') |
class TreeNode:
def __init__(self, val):
self.left = None
self.right = None
self.val = val
def is_valid_BST(node, min, max):
if node == None:
return True
if (min is not None and node.val <= min) or (max is not None and max <= node.val):
return False
return is_va... | class Treenode:
def __init__(self, val):
self.left = None
self.right = None
self.val = val
def is_valid_bst(node, min, max):
if node == None:
return True
if min is not None and node.val <= min or (max is not None and max <= node.val):
return False
return is_vali... |
class lagrange(object):
def __init__(self, eval_x = 0):
self._eval_x = eval_x
self._extrapolations = []
def add_point(self, x, y):
new_extraps = [(y, x)]
for past_extrap, x_old in self._extrapolations:
new_val = ((self._eval_x - x) * past_extrap \
+ (... | class Lagrange(object):
def __init__(self, eval_x=0):
self._eval_x = eval_x
self._extrapolations = []
def add_point(self, x, y):
new_extraps = [(y, x)]
for (past_extrap, x_old) in self._extrapolations:
new_val = ((self._eval_x - x) * past_extrap + (x_old - self._eva... |
# -*- coding: utf-8 -*-
__version__ = '1.0.0'
default_app_config = 'webmap.apps.WebmapConfig'
| __version__ = '1.0.0'
default_app_config = 'webmap.apps.WebmapConfig' |
#Get a string which is n (non-negative integer) copies of a given string
#
#function to display the string
def dispfunc(iteration):
output=str("")
for i in range(iteration):
output=output+entry
print(output)
#
entry=str(input("\nenter a string : "))
displaynumber=int(input("how many times must it be... | def dispfunc(iteration):
output = str('')
for i in range(iteration):
output = output + entry
print(output)
entry = str(input('\nenter a string : '))
displaynumber = int(input('how many times must it be displayed? : '))
dispfunc(displaynumber)
feedback = str(input('\nwould you try it for the stringle... |
spaces = int(input())
steps =0
while(spaces > 0):
if(spaces >= 5):
spaces -= 5
steps += 1
elif(spaces >= 4):
spaces -= 4
steps += 1
elif(spaces >= 3):
spaces -= 3
steps += 1
elif(spaces >= 2):
spaces -= 2
steps += 1
elif(spaces >= 1):
... | spaces = int(input())
steps = 0
while spaces > 0:
if spaces >= 5:
spaces -= 5
steps += 1
elif spaces >= 4:
spaces -= 4
steps += 1
elif spaces >= 3:
spaces -= 3
steps += 1
elif spaces >= 2:
spaces -= 2
steps += 1
elif spaces >= 1:
... |
# Straightforward implementation of the Singleton Pattern
class Logger(object):
_instance = None
def __new__(cls):
if cls._instance is None:
print('Creating the object')
cls._instance = super(Logger, cls).__new__(cls)
# Put any initialization here.
return cl... | class Logger(object):
_instance = None
def __new__(cls):
if cls._instance is None:
print('Creating the object')
cls._instance = super(Logger, cls).__new__(cls)
return cls._instance
log1 = logger()
print(log1)
log2 = logger()
print(log2)
print('Are they the same object?',... |
load("@rules_pkg//:providers.bzl", "PackageFilesInfo", "PackageSymlinkInfo", "PackageFilegroupInfo")
def _runfile_path(ctx, file, runfiles_dir):
path = file.short_path
if path.startswith(".."):
return path.replace("..", runfiles_dir)
if not file.owner.workspace_name:
return "/".join([runfil... | load('@rules_pkg//:providers.bzl', 'PackageFilesInfo', 'PackageSymlinkInfo', 'PackageFilegroupInfo')
def _runfile_path(ctx, file, runfiles_dir):
path = file.short_path
if path.startswith('..'):
return path.replace('..', runfiles_dir)
if not file.owner.workspace_name:
return '/'.join([runfil... |
# You can also nest for loops with
# while loops. Check it out!
for i in range(4):
print("For loop: " + str(i))
x = i
while x >= 0:
print(" While loop: " + str(x))
x = x - 1
| for i in range(4):
print('For loop: ' + str(i))
x = i
while x >= 0:
print(' While loop: ' + str(x))
x = x - 1 |
##list of integers
student_score= [99, 88, 60]
##printing out that list
print(student_score)
##printing all the integers in a range
print(list(range(1,10)))
##printing out all the integers in a range skipping one every time
print(list(range(1,10,2)))
## manipulating a string and printting all the modifications
x =... | student_score = [99, 88, 60]
print(student_score)
print(list(range(1, 10)))
print(list(range(1, 10, 2)))
x = 'hello'
y = x.upper()
z = x.title()
print(x, y, z) |
def harmonic(a, b):
return (2*a*b)/(a + b);
a, b = map(int, input().split())
print(harmonic(a, b))
| def harmonic(a, b):
return 2 * a * b / (a + b)
(a, b) = map(int, input().split())
print(harmonic(a, b)) |
# from recipes.decor.tests import test_cases as tcx
# pylint: disable-all
def test_expose_decor():
@expose.show
def foo(a, b=1, *args, c=2, **kws):
pass
foo(88, 12, 11, c=4, y=1)
def test_expose_decor():
@expose.args
def foo(a, b=1, *args, c=2, **kws):
pass
foo(88, 12, 11,... | def test_expose_decor():
@expose.show
def foo(a, b=1, *args, c=2, **kws):
pass
foo(88, 12, 11, c=4, y=1)
def test_expose_decor():
@expose.args
def foo(a, b=1, *args, c=2, **kws):
pass
foo(88, 12, 11, c=4, y=1) |
def fill_bin_num(dataframe, feature, bin_feature, bin_size, stat_measure, min_bin=None, max_bin=None, default_val='No'):
if min_bin is None:
min_bin = dataframe[bin_feature].min()
if max_bin is None:
max_bin = dataframe[bin_feature].max()
new_dataframe = dataframe.copy()
df_meancat = pd.... | def fill_bin_num(dataframe, feature, bin_feature, bin_size, stat_measure, min_bin=None, max_bin=None, default_val='No'):
if min_bin is None:
min_bin = dataframe[bin_feature].min()
if max_bin is None:
max_bin = dataframe[bin_feature].max()
new_dataframe = dataframe.copy()
df_meancat = pd.... |
def main():
num = int(input("introduce un numero:"))
for x in range (1,num):
print(x, end=",")
else:
print(num, end="") | def main():
num = int(input('introduce un numero:'))
for x in range(1, num):
print(x, end=',')
else:
print(num, end='') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.