content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
class BoundingBox:
x: int
y: int
x2: int
y2: int
cx: int
cy: int
width: int
height: int
def __init__(self, x: int, y: int, width: int, height: int):
self.x = x
self.y = y
self.width = width
self.height = height
self.x2 = x + width - 1
... | class Boundingbox:
x: int
y: int
x2: int
y2: int
cx: int
cy: int
width: int
height: int
def __init__(self, x: int, y: int, width: int, height: int):
self.x = x
self.y = y
self.width = width
self.height = height
self.x2 = x + width - 1
... |
#!/usr/bin/env python3
def convert_to_celsius(fahrenheit: float) -> float:
return (fahrenheit - 32.0) * 5.0 / 9.0
def above_freezing(celsius: float) -> bool:
return celsius > 0
fahrenheit = float(input('Enter the temperature in degrees Fahrenheit: '))
celsius = convert_to_celsius(fahrenheit)
print(celsius)... | def convert_to_celsius(fahrenheit: float) -> float:
return (fahrenheit - 32.0) * 5.0 / 9.0
def above_freezing(celsius: float) -> bool:
return celsius > 0
fahrenheit = float(input('Enter the temperature in degrees Fahrenheit: '))
celsius = convert_to_celsius(fahrenheit)
print(celsius)
if above_freezing(celsius)... |
numero = str(input('digite um numero'))
print('unidade: {}'.format(numero[1]))
print('dezena: {}'.format(numero[2]))
print('centena: {} '.format(numero[3]))
print('unidade de milhar: {}'.format(numero[4]))
| numero = str(input('digite um numero'))
print('unidade: {}'.format(numero[1]))
print('dezena: {}'.format(numero[2]))
print('centena: {} '.format(numero[3]))
print('unidade de milhar: {}'.format(numero[4])) |
def f():
'''f'''
pass
def f1(): pass
f2 = f
if True:
def g(): pass
else:
def h(): pass
class C:
def i(self): pass
def j(self):
def j2(self):
pass
class C2:
def k(self): pass
| def f():
"""f"""
pass
def f1():
pass
f2 = f
if True:
def g():
pass
else:
def h():
pass
class C:
def i(self):
pass
def j(self):
def j2(self):
pass
class C2:
def k(self):
pass |
IPlist = ['209.85.238.4','216.239.51.98','64.233.173.198','64.3.17.208','64.233.173.238']
# for address in range(len(IPlist)):
# IPlist[address] = '%3s.%3s.%3s.%3s' % tuple(IPlist[address].split('.'))
# IPlist.sort(reverse=False)
# for address in range(len(IPlist)):
# IPlist[address] = IPlist[address].re... | i_plist = ['209.85.238.4', '216.239.51.98', '64.233.173.198', '64.3.17.208', '64.233.173.238']
IPlist.sort(key=lambda address: list(map(str, address.split('.'))))
print(IPlist) |
class Base1:
def FuncA(self):
print("Base1::FuncA")
class Base2:
def FuncA(self):
print("Base2::FuncA")
class Child(Base1, Base2):
pass
def main():
obj=Child()
obj.FuncA()
if __name__ == "__main__":
main()
| class Base1:
def func_a(self):
print('Base1::FuncA')
class Base2:
def func_a(self):
print('Base2::FuncA')
class Child(Base1, Base2):
pass
def main():
obj = child()
obj.FuncA()
if __name__ == '__main__':
main() |
KIND_RETRIEVE_DATA = {
"_embedded": {
"naam": {
"_embedded": {
"inOnderzoek": {
"_embedded": {
"datumIngangOnderzoek": {
"dag": None,
"datum": None,
"ja... | kind_retrieve_data = {'_embedded': {'naam': {'_embedded': {'inOnderzoek': {'_embedded': {'datumIngangOnderzoek': {'dag': None, 'datum': None, 'jaar': None, 'maand': None}}, 'geslachtsnaam': False, 'voornamen': False, 'voorvoegsel': False}}, 'geslachtsnaam': 'Maykin Kind', 'voorletters': 'K', 'voornamen': 'Media Kind', ... |
# -*- coding: utf-8 -*-
#from pkg_resources import resource_filename
class dlib_model:
def pose_predictor_model_location():
return "./models/dlib/shape_predictor_68_face_landmarks.dat"
def pose_predictor_five_point_model_location():
return "./models/dlib/shape_predictor_5_face_landmarks.dat"
def face_... | class Dlib_Model:
def pose_predictor_model_location():
return './models/dlib/shape_predictor_68_face_landmarks.dat'
def pose_predictor_five_point_model_location():
return './models/dlib/shape_predictor_5_face_landmarks.dat'
def face_recognition_model_location():
return './models/d... |
# %% [705. Design HashSet](https://leetcode.com/problems/design-hashset/)
class MyHashSet(set):
remove = set.discard
contains = set.__contains__
| class Myhashset(set):
remove = set.discard
contains = set.__contains__ |
words_count = int(input())
words_dict = {}
def add_word(word,definition):
words_dict[word] = definition
def translate_sentence(words_list):
sentence = ""
for word in words_list:
if word in words_dict:
sentence += words_dict[word] + " "
else:
sentence += word + " "... | words_count = int(input())
words_dict = {}
def add_word(word, definition):
words_dict[word] = definition
def translate_sentence(words_list):
sentence = ''
for word in words_list:
if word in words_dict:
sentence += words_dict[word] + ' '
else:
sentence += word + ' '
... |
''' Control Structures
A statement used to control the flow of execution in a program is called a control structure.
Types of control structures
1. Sequence ******************************************************
In a sequential structure the statements are executed in the same order in which they a... | """ Control Structures
A statement used to control the flow of execution in a program is called a control structure.
Types of control structures
1. Sequence ******************************************************
In a sequential structure the statements are executed in the same order in which they a... |
#33
# Time: O(logn)
# Space: O(1)
# Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
# (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).
#
# You are given a target value to search. If found in the array return its index, otherwise return -1.
#
# You may assume no dupli... | class Binarysearchsol:
def search_in_rotated_array_i(self, nums, target):
(left, right) = (0, len(nums) - 1)
while left <= right:
mid = (left + right) // 2
if nums[mid] == target:
return mid
elif nums[mid] > nums[left] and nums[left] <= target < n... |
class Task:
def __init__(self,name,due_date):
self.name = name
self.due_date = due_date
self.comments=[]
self.completed=False
def change_name(self,new_name:str):
if self.name==new_name:
return f"Name cannot be the same."
self.name=new_name
ret... | class Task:
def __init__(self, name, due_date):
self.name = name
self.due_date = due_date
self.comments = []
self.completed = False
def change_name(self, new_name: str):
if self.name == new_name:
return f'Name cannot be the same.'
self.name = new_nam... |
class ManuscriptSubjectAreaService:
def __init__(self, df):
self._df = df
self._subject_areas_by_id_map = df.groupby(
'version_id')['subject_area'].apply(sorted).to_dict()
@staticmethod
def from_database(db, valid_version_ids=None):
df = db.manuscript_subject_area.read_f... | class Manuscriptsubjectareaservice:
def __init__(self, df):
self._df = df
self._subject_areas_by_id_map = df.groupby('version_id')['subject_area'].apply(sorted).to_dict()
@staticmethod
def from_database(db, valid_version_ids=None):
df = db.manuscript_subject_area.read_frame()
... |
def _cc_stamp_header(ctx):
out = ctx.outputs.out
args = ctx.actions.args()
args.add("--stable_status", ctx.info_file)
args.add("--volatile_status", ctx.version_file)
args.add("--output_header", out)
ctx.actions.run(
outputs = [out],
inputs = [ctx.info_file, ctx.version_file],
... | def _cc_stamp_header(ctx):
out = ctx.outputs.out
args = ctx.actions.args()
args.add('--stable_status', ctx.info_file)
args.add('--volatile_status', ctx.version_file)
args.add('--output_header', out)
ctx.actions.run(outputs=[out], inputs=[ctx.info_file, ctx.version_file], arguments=[args], execut... |
print('Challenge 14: WAF to check if a number is present in a list or not.')
test_list = [ 1, 6, 3, 5, 3, 4 ]
print("Checking if 6 exists in list: ")
# Checking if 6 exists in list
# using loop
for i in test_list:
if(i == 6) :
print ("Element Exists") | print('Challenge 14: WAF to check if a number is present in a list or not.')
test_list = [1, 6, 3, 5, 3, 4]
print('Checking if 6 exists in list: ')
for i in test_list:
if i == 6:
print('Element Exists') |
# dictionaries
friends = ["john", "andre", "mark", "robert"]
ages = [23, 43, 54, 12]
biodatas_dict = dict(zip(friends, ages))
print(biodatas_dict)
# list
biodatas_list = list(zip(friends, ages))
print(biodatas_list)
# tuple
biodatas_tuple = tuple(zip(friends, ages))
print(biodatas_tuple)
| friends = ['john', 'andre', 'mark', 'robert']
ages = [23, 43, 54, 12]
biodatas_dict = dict(zip(friends, ages))
print(biodatas_dict)
biodatas_list = list(zip(friends, ages))
print(biodatas_list)
biodatas_tuple = tuple(zip(friends, ages))
print(biodatas_tuple) |
#!/usr/bin/env python
def count_fish(lanternfish: list, repro_day: int) -> int:
return len([x for x in lanternfish if x == repro_day])
def pass_one_day(fish_age_hash: dict, day: int, lanternfish: list=None):
if day == 0:
if not lanternfish:
raise AttributeError("Error: lanternfish list mus... | def count_fish(lanternfish: list, repro_day: int) -> int:
return len([x for x in lanternfish if x == repro_day])
def pass_one_day(fish_age_hash: dict, day: int, lanternfish: list=None):
if day == 0:
if not lanternfish:
raise attribute_error('Error: lanternfish list must be passed as arg')
... |
class MyClass:
def __call__(self): print('__call__')
c = MyClass()
c()
c.__call__()
print()
c.__call__ = lambda: print('overriding call')
c()
c.__call__()
| class Myclass:
def __call__(self):
print('__call__')
c = my_class()
c()
c.__call__()
print()
c.__call__ = lambda : print('overriding call')
c()
c.__call__() |
token = 'Ndhhfghfgh'
firebase = {
"apiKey": "AIzaSyBYHMxJYFVWP6xH55gAY1TJpVECq4KRjKM",
"authDomain": "test24-13912.firebaseapp.com",
"databaseURL": "https://test24-13912-default-rtdb.firebaseio.com",
"projectId": "test24-13912",
"storageBucket": "test24-13912.appspot.com",
"messagingSenderId": "939334214645",
"... | token = 'Ndhhfghfgh'
firebase = {'apiKey': 'AIzaSyBYHMxJYFVWP6xH55gAY1TJpVECq4KRjKM', 'authDomain': 'test24-13912.firebaseapp.com', 'databaseURL': 'https://test24-13912-default-rtdb.firebaseio.com', 'projectId': 'test24-13912', 'storageBucket': 'test24-13912.appspot.com', 'messagingSenderId': '939334214645', 'appId': '... |
class InstagramQueryId:
USER_MEDIAS = '17880160963012870'
USER_STORIES = '17890626976041463'
STORIES = '17873473675158481'
| class Instagramqueryid:
user_medias = '17880160963012870'
user_stories = '17890626976041463'
stories = '17873473675158481' |
class person:
def __init__(self, first_name, last_name, age):
self.first_name = first_name
self.last_name = last_name
self.age = age
def get_full_name(self):
return f"{self.first_name} {self.last_name}"
def introduce(self):
return f"Hi. I'm {self.first_name}. {se... | class Person:
def __init__(self, first_name, last_name, age):
self.first_name = first_name
self.last_name = last_name
self.age = age
def get_full_name(self):
return f'{self.first_name} {self.last_name}'
def introduce(self):
return f"Hi. I'm {self.first_name}. {self... |
#
# PySNMP MIB module HPN-ICF-FLASH-MAN-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-FLASH-MAN-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:26:48 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (def... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_union, value_range_constraint, single_value_constraint, constraints_intersection) ... |
#
# PySNMP MIB module BENU-IP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/BENU-IP-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:37:23 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, 0... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_size_constraint, value_range_constraint, constraints_intersection, single_value_constraint) ... |
class Item:
def __init__(self, name, price, rarity, typ):
self.__name = name
self.__price = price
self.__rarity = rarity
self.__typ = typ
def getName(self):
return self.__name
def setName(self, name):
self.__name = name
def getPrice(self):
r... | class Item:
def __init__(self, name, price, rarity, typ):
self.__name = name
self.__price = price
self.__rarity = rarity
self.__typ = typ
def get_name(self):
return self.__name
def set_name(self, name):
self.__name = name
def get_price(self):
r... |
class Quantity(object):
def __get__(self, instance, owner):
return getattr(instance, self.target_name)
def __set__(self, instance, value):
if not hasattr(self, 'target_name'):
self.set_target_names(instance)
if value > 0:
setattr(instance, self.target_name, valu... | class Quantity(object):
def __get__(self, instance, owner):
return getattr(instance, self.target_name)
def __set__(self, instance, value):
if not hasattr(self, 'target_name'):
self.set_target_names(instance)
if value > 0:
setattr(instance, self.target_name, valu... |
def sort_012(inputList):
next0 = 0
next2 = len(inputList) - 1
frontIndex = 0
while frontIndex <= next2:
if inputList[frontIndex] is 0:
inputList[frontIndex] = inputList[next0]
inputList[next0] = 0
next0 += 1
frontIndex += 1
elif inputList[frontIndex] == 2: ... | def sort_012(inputList):
next0 = 0
next2 = len(inputList) - 1
front_index = 0
while frontIndex <= next2:
if inputList[frontIndex] is 0:
inputList[frontIndex] = inputList[next0]
inputList[next0] = 0
next0 += 1
front_index += 1
elif inputList... |
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def __repr__(self):
if type(self.data) != 'str':
return str(self.data)
return self.data
def inorder(root, is_last_node=False):
if root:
inorder(root.left)... | class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def __repr__(self):
if type(self.data) != 'str':
return str(self.data)
return self.data
def inorder(root, is_last_node=False):
if root:
inorder(root.left)
... |
sum=0
for i in range(5):
a=int(input())
if a<40:
a=40
sum+=a
print(sum//5) | sum = 0
for i in range(5):
a = int(input())
if a < 40:
a = 40
sum += a
print(sum // 5) |
# Some constants to work for https://github.com/Di-Ny/LoRaPacketForwarderDomoticzConfigurator
#
# Author: DiNy
###########
## Global
GW_UNIT_ID=10
###########
## LORA
DR_2_SFBW_EU868 = {
"0":["12","125.0","5"],
"1":["11","125.0","5"],
"2":["10","125.0","5"],
"3":["9","125.0","5"],
"4":["8","125.0","5"],
"5":["7"... | gw_unit_id = 10
dr_2_sfbw_eu868 = {'0': ['12', '125.0', '5'], '1': ['11', '125.0', '5'], '2': ['10', '125.0', '5'], '3': ['9', '125.0', '5'], '4': ['8', '125.0', '5'], '5': ['7', '125.0', '5'], '6': ['7', '250.0', '5'], '7': ['12', '125.0', '7'], '8': ['12', '62.5', '5'], '9': ['12', '62.5', '7'], '10': ['12', '31.25',... |
# Login information for the 6.034 Automated Tester
USERNAME="lcchiang_MIT_EDU"
PASSWORD="yu7Q4nPJNRALMY3AJ6ze"
XMLRPC_URL="https://ai6034.mit.edu/labs/xmlrpc/"
| username = 'lcchiang_MIT_EDU'
password = 'yu7Q4nPJNRALMY3AJ6ze'
xmlrpc_url = 'https://ai6034.mit.edu/labs/xmlrpc/' |
ENDPOINT = "https://en.wikipedia.org/w/api.php"
def make_url(id, is_expanded=False, is_html=False):
# TODO: isdigit is not robust enough, title could be number instead of string
return make_id_url(id, is_expanded, is_html) if str(id).isdigit() else make_title_url(id, is_expanded, is_html)
def make_title_ur... | endpoint = 'https://en.wikipedia.org/w/api.php'
def make_url(id, is_expanded=False, is_html=False):
return make_id_url(id, is_expanded, is_html) if str(id).isdigit() else make_title_url(id, is_expanded, is_html)
def make_title_url(id, is_expanded=False, is_html=False):
url = ENDPOINT + '?action=query&titles='... |
#!/usr/bin/python3
def main():
buffersize = 50000
infile = open('obama.png', 'rb')
outfile = open('obama-copy.png', 'wb')
buffer = infile.read(buffersize)
while len(buffer):
outfile.write(buffer)
print('.', end = '')
buffer = infile.read(buffersize)
print()
print('D... | def main():
buffersize = 50000
infile = open('obama.png', 'rb')
outfile = open('obama-copy.png', 'wb')
buffer = infile.read(buffersize)
while len(buffer):
outfile.write(buffer)
print('.', end='')
buffer = infile.read(buffersize)
print()
print('Done.')
if __name__ == '... |
a, b, c = sorted(list(map(float, input().split())))
if(((a+b) > c)and((c-a) < b)):
print('It is a triangle.')
if(((a**2)+(b**2)) == (c**2)):
print('-> also a Right triangle.')
if(not(a-b)):
print('-> Wow it\'s a Isosceles right triangle!')
else:
print('not a triangle.') | (a, b, c) = sorted(list(map(float, input().split())))
if a + b > c and c - a < b:
print('It is a triangle.')
if a ** 2 + b ** 2 == c ** 2:
print('-> also a Right triangle.')
if not a - b:
print("-> Wow it's a Isosceles right triangle!")
else:
print('not a triangle.') |
def alternating(list_of_ints):
pass
print(alternating([1, 2, 3, 4]))
print(alternating([10, 11, 1, 12]))
print(alternating([10, 21, 22, -5, 100, 101, 2]))
| def alternating(list_of_ints):
pass
print(alternating([1, 2, 3, 4]))
print(alternating([10, 11, 1, 12]))
print(alternating([10, 21, 22, -5, 100, 101, 2])) |
DEVICE_NAME = '00002a00-0000-1000-8000-00805f9b34fb'
MODEL_NUMBER = '00002a24-0000-1000-8000-00805f9b34fb'
SERIAL_NUMBER = '00002a25-0000-1000-8000-00805f9b34fb'
FIRMWARE_VERSION = '00002a26-0000-1000-8000-00805f9b34fb'
HARDWARE_VERSION = '00002a27-0000-1000-8000-00805f9b34fb'
MANUFACTURER_NAME = '00002a29-0000-1000-80... | device_name = '00002a00-0000-1000-8000-00805f9b34fb'
model_number = '00002a24-0000-1000-8000-00805f9b34fb'
serial_number = '00002a25-0000-1000-8000-00805f9b34fb'
firmware_version = '00002a26-0000-1000-8000-00805f9b34fb'
hardware_version = '00002a27-0000-1000-8000-00805f9b34fb'
manufacturer_name = '00002a29-0000-1000-80... |
pkgname = "libusbmuxd"
pkgver = "2.0.2"
pkgrel = 0
build_style = "gnu_configure"
hostmakedepends = ["pkgconf", "automake", "libtool"]
makedepends = ["libusb-devel", "libplist-devel"]
pkgdesc = "Client library to multiplex connections to/from iOS devices"
maintainer = "q66 <q66@chimera-linux.org>"
license = "LGPL-2.1-on... | pkgname = 'libusbmuxd'
pkgver = '2.0.2'
pkgrel = 0
build_style = 'gnu_configure'
hostmakedepends = ['pkgconf', 'automake', 'libtool']
makedepends = ['libusb-devel', 'libplist-devel']
pkgdesc = 'Client library to multiplex connections to/from iOS devices'
maintainer = 'q66 <q66@chimera-linux.org>'
license = 'LGPL-2.1-on... |
def main():
return 'THIS_IS_MAIN_MAIN'
def func():
return 'THIS_IS_MAIN_FUNC'
| def main():
return 'THIS_IS_MAIN_MAIN'
def func():
return 'THIS_IS_MAIN_FUNC' |
def get_msg_with_punctuations(old, new):
new_org_text = new
for i in range(len(old)):
if not str.isalpha(old[i]):
new_org_text = new_org_text[0:i] + old[i] + new_org_text[i:]
for i in range(len(old)):
if str.isupper(old[i]):
new_org_text = new_org_text[0:i] + str.uppe... | def get_msg_with_punctuations(old, new):
new_org_text = new
for i in range(len(old)):
if not str.isalpha(old[i]):
new_org_text = new_org_text[0:i] + old[i] + new_org_text[i:]
for i in range(len(old)):
if str.isupper(old[i]):
new_org_text = new_org_text[0:i] + str.uppe... |
class Solution:
def lowestCommonAncestor(self, root, p, q):
if root is None or p == root or q == root:
return root
l = self.lowestCommonAncestor(root.left, p, q)
r = self.lowestCommonAncestor(root.right, p, q)
if l is None:
return r
if r is None:
... | class Solution:
def lowest_common_ancestor(self, root, p, q):
if root is None or p == root or q == root:
return root
l = self.lowestCommonAncestor(root.left, p, q)
r = self.lowestCommonAncestor(root.right, p, q)
if l is None:
return r
if r is None:
... |
### This program subtracts ###
def minus(a, b):
sub = a - b
print(sub)
print("Welcome to subtracting your life version 1.0.0.0.0.0.0.1!")
x,y = input("Please input the digits of your life that you wish to subtract: ").split()
x = int(x)
y = int(y)
minus(x,y)
| def minus(a, b):
sub = a - b
print(sub)
print('Welcome to subtracting your life version 1.0.0.0.0.0.0.1!')
(x, y) = input('Please input the digits of your life that you wish to subtract: ').split()
x = int(x)
y = int(y)
minus(x, y) |
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def reverseList(self, head: ListNode) -> ListNode:
if head == None or head.next == None:
return head
next_node = head.next
head.next = None
while next_node:
... | class Listnode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def reverse_list(self, head: ListNode) -> ListNode:
if head == None or head.next == None:
return head
next_node = head.next
head.next = None
while next_node:
... |
def Cel():
celsius = float(input("Enter the temperature in Celsius ")) # It will take user input
fahrenheit :float = (celsius * 9 / 5) + 32 # calculation part
print("Value in Fahrenheit ", fahrenheit)
def Far():
fahrenheit = float(input("Enter the temperature in Fahrenheit ")) # It will take user i... | def cel():
celsius = float(input('Enter the temperature in Celsius '))
fahrenheit: float = celsius * 9 / 5 + 32
print('Value in Fahrenheit ', fahrenheit)
def far():
fahrenheit = float(input('Enter the temperature in Fahrenheit '))
celsius: float = (fahrenheit - 32) * 5 / 9
print(' Value in Ce... |
#CP2
#Thomas Franceschi
#Kyle Williams
#import sys
class baseParser:
def __init__(self, expression, length, counter):
self.expression = expression #String being parsed
self.length = length #Max range for token
self.counter = counter #Token
self.M = '' #Output
def parseRegexp(self):
... | class Baseparser:
def __init__(self, expression, length, counter):
self.expression = expression
self.length = length
self.counter = counter
self.M = ''
def parse_regexp(self):
self.M = self.parseUnion()
if self.counter == self.length:
return self.M
... |
__all__ = [
'PrimaryStatus',
'InputStatus',
'OutputStatus',
'StopReason'
]
class PrimaryStatus:
QUEUING_CHECKS = "QUEUING_CHECKS"
# one of checks tasks has been started
CHECKING = "CHECKING"
# when all first level tasks has been finished
CHECKS_FINISHED = "CHECKS_FINISHED"
... | __all__ = ['PrimaryStatus', 'InputStatus', 'OutputStatus', 'StopReason']
class Primarystatus:
queuing_checks = 'QUEUING_CHECKS'
checking = 'CHECKING'
checks_finished = 'CHECKS_FINISHED'
queuing_inputs_downloading = 'QUEUING_INPUTS_DOWNLOADING'
inputs_downloading = 'INPUTS_DOWNLOADING'
all_input... |
# __getattr__ is not implemented by default
# __getattribute__ run for every attribute access (w/o looking at attributes on object)
# __getattr__ only run when attribute not found in normal ways
class Foo(object):
def __getattribute__(self, item):
print('Foo called __getattribute__ on {0}'.format(item))
... | class Foo(object):
def __getattribute__(self, item):
print('Foo called __getattribute__ on {0}'.format(item))
return super().__getattribute__(item)
def __getattr__(self, item):
print('Foo called __getattr__ on {0}'.format(item))
return super().__getattr__(item)
class Bar(Foo):... |
# palindrome_check.py
# recursion in strings
def isPalindrome(s):
# check if string is a palindrome
def toChars(s):
# convert string to characters
s = s.lower()
ans = ''
for c in s:
if c in 'abcdefghijklmnopqrstuvwxy':
ans = ans + c
retur... | def is_palindrome(s):
def to_chars(s):
s = s.lower()
ans = ''
for c in s:
if c in 'abcdefghijklmnopqrstuvwxy':
ans = ans + c
return ans
def is_pal(s):
if len(s) <= 1:
return True
else:
return s[0] == s[-1] and ... |
f = open('./deu.txt','r')
fwde = open('./deu.de','w')
fwen = open('./deu.en','w')
lines = [line for line in f.read().split('\n') if line]
for line in lines:
items = line.split('\t')
assert len(items)==3
fwen.write(items[0] + '\n')
fwde.write(items[1] + '\n')
fwde.close()
fwen.close()
| f = open('./deu.txt', 'r')
fwde = open('./deu.de', 'w')
fwen = open('./deu.en', 'w')
lines = [line for line in f.read().split('\n') if line]
for line in lines:
items = line.split('\t')
assert len(items) == 3
fwen.write(items[0] + '\n')
fwde.write(items[1] + '\n')
fwde.close()
fwen.close() |
height_map = [int(e.strip()) for e in input().strip().split(',')]
count = 0
negative = False
for i in height_map:
if i < 0:
negative = True
else:
if negative:
count += 1
negative = False
print(count) | height_map = [int(e.strip()) for e in input().strip().split(',')]
count = 0
negative = False
for i in height_map:
if i < 0:
negative = True
else:
if negative:
count += 1
negative = False
print(count) |
# Find value that occurs in odd number of elements.
# Find the number in an non-empty array that does not have pair
# Array [9,3,9,3,9,7,9] pairs
# A[0] = 9 and A[2] = 9
# A[1] = 3 and A[3] = 3
# A[4] = 9 and A[6] = 9
# A[5] = 7 no pair
# the function should return 7, as explained in the example above.... | def solution(A):
a = sorted(A)
current = A[0]
count = 0
for i in A:
if current == i:
count += 1
else:
if count % 2 != 0:
return current
count = 1
current = i
return current
print(solution([9, 3, 9, 3, 9, 7, 9])) |
Data_File = open("Day2_Data.txt")
Data = Data_File.read()
Data = Data.split(',')
for i in range(len(Data)):
Data[i]=int(Data[i])
Data_Backup = Data.copy()
for noun in range (100):
for verb in range(100):
Data = Data_Backup.copy()
Data[1] = noun
Data[2] = verb
Ind... | data__file = open('Day2_Data.txt')
data = Data_File.read()
data = Data.split(',')
for i in range(len(Data)):
Data[i] = int(Data[i])
data__backup = Data.copy()
for noun in range(100):
for verb in range(100):
data = Data_Backup.copy()
Data[1] = noun
Data[2] = verb
index__number = 0... |
# https://www.facebook.com/roshan.philipines/posts/2769055946717382
# Subscribed by Roshaen
#Implementation of ISBN number
def isbn(n):
lst=[]
j=0
for i in range(len(n)):
lst.insert(j,n[i])
j+=1
i=0
sum=0
for i in range(len(lst)):
sum=sum+int(lst[i])*(10-i)
if(sum%1... | def isbn(n):
lst = []
j = 0
for i in range(len(n)):
lst.insert(j, n[i])
j += 1
i = 0
sum = 0
for i in range(len(lst)):
sum = sum + int(lst[i]) * (10 - i)
if sum % 11 == 0:
print('Valid ISBN number')
else:
print('Not a valid ISBN number')
inp = inpu... |
def get_defaults():
return {
"acceptable_size": 100,
"acceptable_time": 3,
"get_pages": True,
"get_assets": True,
"get_images": True,
"get_scripts": True,
"get_stylesheets": True,
"give_second_chance": True,
"logfile_location": "gyroscope.log",... | def get_defaults():
return {'acceptable_size': 100, 'acceptable_time': 3, 'get_pages': True, 'get_assets': True, 'get_images': True, 'get_scripts': True, 'get_stylesheets': True, 'give_second_chance': True, 'logfile_location': 'gyroscope.log', 'logfile_mode': 'w', 'log_level': 30, 'log_too_big': True, 'log_too_slow... |
#PROBLEM LINK:- https://leetcode.com/problems/shuffle-the-array/
class Solution:
def shuffle(self, nums, n):
v = []
for i in range(n):
v.append(nums[i])
v.append(nums[i+n])
return v
| class Solution:
def shuffle(self, nums, n):
v = []
for i in range(n):
v.append(nums[i])
v.append(nums[i + n])
return v |
# coding: utf-8
##############################################################################
# Copyright (C) 2018 Microchip Technology Inc. and its subsidiaries.
#
# Subject to your compliance with these terms, you may use Microchip software
# and any derivatives exclusively with Microchip products. It is your
# resp... | def instantiate_component(comp):
gfx_intf_smc_h = comp.createFileSymbol('GFX_INTF_SMC_H', None)
GFX_INTF_SMC_H.setDestPath('gfx/interface/')
GFX_INTF_SMC_H.setSourcePath('../drv_gfx_disp_intf.h')
GFX_INTF_SMC_H.setOutputName('drv_gfx_disp_intf.h')
GFX_INTF_SMC_H.setProjectPath('config/' + Variables.... |
input_numbers = input('Enter numbers separated by a space : ').split()
max = int(input_numbers[0])
min = int(input_numbers[0])
avg = 0
sum = 0
for i in range(0, len(input_numbers)):
input_numbers[i] = int(input_numbers[i])
sum = sum + input_numbers[i]
if input_numbers[i] > max:
max = input_nu... | input_numbers = input('Enter numbers separated by a space : ').split()
max = int(input_numbers[0])
min = int(input_numbers[0])
avg = 0
sum = 0
for i in range(0, len(input_numbers)):
input_numbers[i] = int(input_numbers[i])
sum = sum + input_numbers[i]
if input_numbers[i] > max:
max = input_numbers[i... |
'''3. Write a Python program to print the square and cube symbol in the
area of a rectangle and volume of a cylinder.
Sample output:
The area of the rectangle is 1256.66cm2
The volume of the cylinder is 1254.725cm3'''
area = 1256.66
volume = 1254.725
print(f"The area of the rectangle is {round(area, 2)}cm2")
print(f... | """3. Write a Python program to print the square and cube symbol in the
area of a rectangle and volume of a cylinder.
Sample output:
The area of the rectangle is 1256.66cm2
The volume of the cylinder is 1254.725cm3"""
area = 1256.66
volume = 1254.725
print(f'The area of the rectangle is {round(area, 2)}cm2')
print(f'... |
#!/usr/bin/env python3
def clear_screen(lines=128):
if not isinstance(lines, int) or lines < 64:
lines = 64
print( '\n' * lines, end='' )
class Player:
def __init__(self, n):
self.score = 0
self.name = n
self.attack1 = ''
self.attack2 = ''
self.guard = ''
... | def clear_screen(lines=128):
if not isinstance(lines, int) or lines < 64:
lines = 64
print('\n' * lines, end='')
class Player:
def __init__(self, n):
self.score = 0
self.name = n
self.attack1 = ''
self.attack2 = ''
self.guard = ''
def step(self):
... |
class Assert(object):
@staticmethod
def is_instance(instance, instances_class):
assert isinstance(instance, instances_class), '{0} should be an instance of class {1}'.format(
instance.__name__, instances_class.__name__
)
| class Assert(object):
@staticmethod
def is_instance(instance, instances_class):
assert isinstance(instance, instances_class), '{0} should be an instance of class {1}'.format(instance.__name__, instances_class.__name__) |
#Prime Number Checker
#Parker Dinkins
'''
This program asks for a number between 0 and 5000
If the number isn't in that range it asks for it again
When a proper number is entered it checks if it is prime
If the numbr is prime it prints the two factors
If the number is not prime it prints all the factors
Finally it ask... | """
This program asks for a number between 0 and 5000
If the number isn't in that range it asks for it again
When a proper number is entered it checks if it is prime
If the numbr is prime it prints the two factors
If the number is not prime it prints all the factors
Finally it asks if you want run the checker again or ... |
#!/usr/bin/env python3
# Write a program that computes the GC fraction of a DNA sequence in a window
# Window size is 11 nt
# Output with 4 significant figures using whichever method you prefer
# Use no nested loops. Instead, count only the first window
# Then 'move' the window by adding 1 letter on one side
# And subt... | seq = 'ACGACGCAGGAGGAGAGTTTCAGAGATCACGAATACATCCATATTACCCAGAGAGAG'
w = 11
window = ''
count = 0
for i in range(w):
window += seq[i]
if seq[i] == 'G' or seq[i] == 'C':
count += 1
print(f'{0} {window} {count / w: .4f}')
for i in range(1, len(seq) - w + 1):
if window[0] == 'G' or window[0] == 'C':
... |
#!/usr/local/bin/python3
class Duet():
def __init__(self, instruction_list):
self.instruction_list = [ instruction.split() for instruction in instruction_list ]
self.program_counter = 0
self.registers = {}
self.played = None
self.nonZeroPlayed = False
self.__instr_se... | class Duet:
def __init__(self, instruction_list):
self.instruction_list = [instruction.split() for instruction in instruction_list]
self.program_counter = 0
self.registers = {}
self.played = None
self.nonZeroPlayed = False
self.__instr_set = {'set': self.__set, 'add'... |
NUM_ALLELES = 3
ALLELE_PRIOR = 1.0 / NUM_ALLELES
ALPHA = 1.5
MINUS_INFINITE = -1000000000
mBound = 6
jA = 10.0
jB = 0.5
pA = 0.1
pD = 0.1
pC = 1.0 - pD
pI = 0.1
if __name__ == '__main__':
print('This is a configuration file!')
| num_alleles = 3
allele_prior = 1.0 / NUM_ALLELES
alpha = 1.5
minus_infinite = -1000000000
m_bound = 6
j_a = 10.0
j_b = 0.5
p_a = 0.1
p_d = 0.1
p_c = 1.0 - pD
p_i = 0.1
if __name__ == '__main__':
print('This is a configuration file!') |
class A:
def feature1(self):
print("Feature 1 working")
def feature2(self):
print("Feature 2 working")
a1 = A()
a1.feature1()
class B(A):
def feature3(self):
print("feature 3 working")
def feature4(self):
print("feature 4 working")
b1 = B()
b1.feature2()
| class A:
def feature1(self):
print('Feature 1 working')
def feature2(self):
print('Feature 2 working')
a1 = a()
a1.feature1()
class B(A):
def feature3(self):
print('feature 3 working')
def feature4(self):
print('feature 4 working')
b1 = b()
b1.feature2() |
# Application Install Directory (Relative to Inside Container)
SNODAS_APP = '/app/cumulus/snodas/core'
# Archive of UNMASKED files downloaded from NSIDC
SNODAS_RAW_UNMASKED = '/app/data/snodas/raw_unmasked'
# Archive of MASKED files downloaded from NSIDC
SNODAS_RAW_MASKED = '/app/data/snodas/raw_masked'
| snodas_app = '/app/cumulus/snodas/core'
snodas_raw_unmasked = '/app/data/snodas/raw_unmasked'
snodas_raw_masked = '/app/data/snodas/raw_masked' |
expected_output = {
'vrf': {
'VRF501': {
'address_family': {
'ipv4': {
'routes': {
'192.168.111.1/32': {
'route': '192.168.111.1/32',
'active': True... | expected_output = {'vrf': {'VRF501': {'address_family': {'ipv4': {'routes': {'192.168.111.1/32': {'route': '192.168.111.1/32', 'active': True, 'source_protocol_codes': 'L', 'source_protocol': 'local', 'next_hop': {'outgoing_interface': {'Loopback501': {'outgoing_interface': 'Loopback501', 'updated': '1d22h'}}}}, '192.1... |
class Node:
def __init__(self, name=None, terminal=False):
self._name = name
self._children = []
self._level = None
self._terminal = terminal
# ====================
# GETTERS E SETTERS
@property
def name(self):
return self._name
@name.setter
def name... | class Node:
def __init__(self, name=None, terminal=False):
self._name = name
self._children = []
self._level = None
self._terminal = terminal
@property
def name(self):
return self._name
@name.setter
def name(self, value):
self._name = value
@pr... |
def get_all_includes(comp_args, dst_includes):
i = 0
while i < len(comp_args):
curr_arg = comp_args[i].strip()
if curr_arg == "-isystem":
curr_arg1 = "-I" + comp_args[i+1].strip()
if curr_arg1 not in dst_includes:
dst_includes.append(curr_arg1)
if ... | def get_all_includes(comp_args, dst_includes):
i = 0
while i < len(comp_args):
curr_arg = comp_args[i].strip()
if curr_arg == '-isystem':
curr_arg1 = '-I' + comp_args[i + 1].strip()
if curr_arg1 not in dst_includes:
dst_includes.append(curr_arg1)
i... |
def push(data_json):
# A user pushes 1 or more commits to a repository.
repository = data_json['repository']
# repository_scm = repository['scm']
repository_name = repository['name']
repository_link = repository['links']['html']['href']
actor = data_json['actor']
actor_name = actor['display... | def push(data_json):
repository = data_json['repository']
repository_name = repository['name']
repository_link = repository['links']['html']['href']
actor = data_json['actor']
actor_name = actor['display_name']
actor_profile = actor['links']['html']['href']
pushh = data_json['push']['changes... |
class LifeCycle:
def __init__(self, id, label, composed_of):
self.id = id
self.label = label
self.composed_of = composed_of
| class Lifecycle:
def __init__(self, id, label, composed_of):
self.id = id
self.label = label
self.composed_of = composed_of |
a = []
maximum = 0
for _ in range(6):
tmp = [int(x) for x in str(input()).split(" ")]
a.append(tmp)
for i in range(6):
for j in range(6):
if (j + 2 < 6) and (i + 2 < 6):
result = a[i][j] + a[i][j+1] + a[i][j+2] + a[i+1][j+1] + a[i+2][j] + a[i+2][j+1] + a[i+2][j+2]
if(result > maximum):
maximum = result... | a = []
maximum = 0
for _ in range(6):
tmp = [int(x) for x in str(input()).split(' ')]
a.append(tmp)
for i in range(6):
for j in range(6):
if j + 2 < 6 and i + 2 < 6:
result = a[i][j] + a[i][j + 1] + a[i][j + 2] + a[i + 1][j + 1] + a[i + 2][j] + a[i + 2][j + 1] + a[i + 2][j + 2]
... |
def NumpyInList(array,l1):
for i in l1:
if i[0] == array[0] and i[1] == array[1]:
return True
return False
| def numpy_in_list(array, l1):
for i in l1:
if i[0] == array[0] and i[1] == array[1]:
return True
return False |
def create_matrix(size):
matrix = []
for _ in range(size):
matrix.append([int(x) for x in input().split()])
return matrix
def is_valid_cell(position, size):
row = position[0]
col = position[1]
return 0 <= row < size and 0 <= col < size
def print_matrix(matrix):
for row in matrix:... | def create_matrix(size):
matrix = []
for _ in range(size):
matrix.append([int(x) for x in input().split()])
return matrix
def is_valid_cell(position, size):
row = position[0]
col = position[1]
return 0 <= row < size and 0 <= col < size
def print_matrix(matrix):
for row in matrix:
... |
(rows_count, columns_count) = map(int, input().split())
matrix = []
new_matrix = []
player_position = []
player_wins = False
for i in range(rows_count):
row = [x for x in input()]
if "P" in row:
player_position = [i, row.index("P")]
row[row.index("P")] = "."
row2 = row.copy()
matrix.app... | (rows_count, columns_count) = map(int, input().split())
matrix = []
new_matrix = []
player_position = []
player_wins = False
for i in range(rows_count):
row = [x for x in input()]
if 'P' in row:
player_position = [i, row.index('P')]
row[row.index('P')] = '.'
row2 = row.copy()
matrix.appe... |
coordinates_FFFFCC = ((149, 117),
(149, 118), (149, 119), (149, 120), (149, 121), (149, 122), (149, 123), (149, 124), (149, 125), (149, 126), (149, 127), (149, 128), (149, 129), (149, 130), (150, 111), (150, 112), (150, 113), (150, 114), (150, 115), (150, 116), (150, 131), (150, 133), (151, 107), (151, 108), (151, 10... | coordinates_ffffcc = ((149, 117), (149, 118), (149, 119), (149, 120), (149, 121), (149, 122), (149, 123), (149, 124), (149, 125), (149, 126), (149, 127), (149, 128), (149, 129), (149, 130), (150, 111), (150, 112), (150, 113), (150, 114), (150, 115), (150, 116), (150, 131), (150, 133), (151, 107), (151, 108), (151, 109)... |
class EmailAddress:
def __init__(self, email):
self.email = email
self._email_tpl = tuple(self._email.split('@'))
def __str__(self):
return self.email
def __repr__(self):
return f"{EmailAddress.__name__}('{self.email}')"
@property
def email(self):
return s... | class Emailaddress:
def __init__(self, email):
self.email = email
self._email_tpl = tuple(self._email.split('@'))
def __str__(self):
return self.email
def __repr__(self):
return f"{EmailAddress.__name__}('{self.email}')"
@property
def email(self):
return s... |
x = int(input())
y = int(input())
ans = 0
if x > 0:
if y > 0:
ans = 1
else: ans = 4
else:
if y > 0:
ans = 2
else: ans = 3
print(ans) | x = int(input())
y = int(input())
ans = 0
if x > 0:
if y > 0:
ans = 1
else:
ans = 4
elif y > 0:
ans = 2
else:
ans = 3
print(ans) |
# filename : csc_checks.py
# description : check definitions (security best practices and CVEs)
# create date : 2018-05-07 14:07:33.569768
csc1_1 = {'check_name': 'csc1_1',
'check_type': 'check_in_simple',
'match1': 'banner motd',
'match2': 'n/a',
'required': 'yes',
'result_ok': 'Test successful.... | csc1_1 = {'check_name': 'csc1_1', 'check_type': 'check_in_simple', 'match1': 'banner motd', 'match2': 'n/a', 'required': 'yes', 'result_ok': 'Test successful.', 'result_failed': 'Test failed.', 'info': 'A banner shoud be set', 'url': 'n/a', 'fix': 'Command to fix'}
csc1_2 = {'check_name': 'csc1_2', 'check_type': 'check... |
print("What is yas?")
word = input()
def isYas(word):
Yasses = True
state=0
for i in range(len(word)):
if word[i].isalpha():
if state == 0:
if word[i] in ["Y","y"]:
state=1
else:
Yasses = False
elif state == 1:
if word[i] in ["Y","y"]:
state=1
elif word[i] in ["A","a"]:
st... | print('What is yas?')
word = input()
def is_yas(word):
yasses = True
state = 0
for i in range(len(word)):
if word[i].isalpha():
if state == 0:
if word[i] in ['Y', 'y']:
state = 1
else:
yasses = False
eli... |
class NGram:
# @param {int} n a integer
# @param {str} string a string
def mapper(self, _, n, string):
# Write your code here
# Please use 'yield key, value' here
for i in range(len(string) - n + 1):
yield string[i:i + n], 1
# @param key is from mapper
# @param... | class Ngram:
def mapper(self, _, n, string):
for i in range(len(string) - n + 1):
yield (string[i:i + n], 1)
def reducer(self, key, values):
yield (key, sum(values)) |
class Vector:
def __init__(self,x,y):
self.x=x
self.y=y
def __repr__(self):
return str(self.x) +"i, "+ str(self.y)+"j"
def dotProduct(v1,v2):
return v1.x*v2.x + v1.y*v2.y | class Vector:
def __init__(self, x, y):
self.x = x
self.y = y
def __repr__(self):
return str(self.x) + 'i, ' + str(self.y) + 'j'
def dot_product(v1, v2):
return v1.x * v2.x + v1.y * v2.y |
#poly_limit=10
def poly_check(seq,poly_limit):
if 'A'*poly_limit not in seq and 'T'*poly_limit not in seq and 'G'*poly_limit not in seq and 'C'*poly_limit not in seq:
return True
else:
return False
def var_check(change_from, change_to, seq,var_limit):
ALL=['A','T','C','G']
tmp=[]
for one in ALL:
if on... | def poly_check(seq, poly_limit):
if 'A' * poly_limit not in seq and 'T' * poly_limit not in seq and ('G' * poly_limit not in seq) and ('C' * poly_limit not in seq):
return True
else:
return False
def var_check(change_from, change_to, seq, var_limit):
all = ['A', 'T', 'C', 'G']
tmp = []
... |
x = input()
if x == ".helpf":
print(".help : to show help menu")
| x = input()
if x == '.helpf':
print('.help : to show help menu') |
class Config(object):
SQLALCHEMY_DATABASE_URI = 'sqlite:///app.db'
SQLALCHEMY_TRACK_MODIFICATIONS = False
SECRET_KEY = '1234567890'
SQLALCHEMY_ECHO = False
FLASK_ADMIN_SWATCH = 'united'
if __name__ == '__main__':
for key in Config.__dict__:
print(key, Config.__dict__[key]) | class Config(object):
sqlalchemy_database_uri = 'sqlite:///app.db'
sqlalchemy_track_modifications = False
secret_key = '1234567890'
sqlalchemy_echo = False
flask_admin_swatch = 'united'
if __name__ == '__main__':
for key in Config.__dict__:
print(key, Config.__dict__[key]) |
# https://leetcode.com/problems/generate-a-string-with-characters-that-have-odd-counts
def generate_the_string(n):
if n % 2 == 0:
return 'a' * (n - 1) + 'b'
return 'a' * n | def generate_the_string(n):
if n % 2 == 0:
return 'a' * (n - 1) + 'b'
return 'a' * n |
class Queue2Stacks:
def __init__(self):
self.stack1 = []
self.stack2 = []
def size(self):
return len(self.stack1)
def isEmpty(self):
return self.stack1 == []
def enqueue(self,item):
self.stack1.append(item)
def d... | class Queue2Stacks:
def __init__(self):
self.stack1 = []
self.stack2 = []
def size(self):
return len(self.stack1)
def is_empty(self):
return self.stack1 == []
def enqueue(self, item):
self.stack1.append(item)
def dequeue(self):
if self.stack2 != [... |
def gen_counter(cnt=None):
res = 0
while True:
yield res
res += 1 if cnt is None else cnt
if __name__=='__main__':
cnt = gen_counter()
print(next(cnt))
print(next(cnt))
print(next(cnt))
print(next(cnt))
print(next(cnt))
cnt = gen_counter(5)
print(next(cnt))
... | def gen_counter(cnt=None):
res = 0
while True:
yield res
res += 1 if cnt is None else cnt
if __name__ == '__main__':
cnt = gen_counter()
print(next(cnt))
print(next(cnt))
print(next(cnt))
print(next(cnt))
print(next(cnt))
cnt = gen_counter(5)
print(next(cnt))
... |
#
# PySNMP MIB module NBS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NBS-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:07:17 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:15)... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_range_constraint, value_size_constraint, constraints_union, constraints_intersection) ... |
def test_calculator_add_returns_correct_result():
result = calc_add(2,2)
assert result == 4
# def calc_add(x,y):
# pass
# return x+y
# if isinstance(x, number_types) and isinstance(y, number_types):
# return x + y
# else:
# raise ValueError("Non-numeric inpu... | def test_calculator_add_returns_correct_result():
result = calc_add(2, 2)
assert result == 4 |
def getGroupCount(line):
#print("Line "+line)
curSet = set(())
for curChar in line:
curSet.add(curChar)
#print("Set: "+str(curSet))
return len(curSet)
filename = "inputs\\2020\\input-day6.txt"
with open(filename) as f:
lines = f.readlines()
group = ""
sum = 0
for line in lines:
if ... | def get_group_count(line):
cur_set = set(())
for cur_char in line:
curSet.add(curChar)
return len(curSet)
filename = 'inputs\\2020\\input-day6.txt'
with open(filename) as f:
lines = f.readlines()
group = ''
sum = 0
for line in lines:
if len(line.strip()) == 0:
sum += get_group_count(... |
def up_array(arr):
if not arr:
return None
else:
string = ''
for item in arr:
if not str(item).isdigit() or item > 9:
return None
else:
string += str(item)
total = []
for char in str(int(string)+1):
... | def up_array(arr):
if not arr:
return None
else:
string = ''
for item in arr:
if not str(item).isdigit() or item > 9:
return None
else:
string += str(item)
total = []
for char in str(int(string) + 1):
tot... |
def findDecision(obj): #obj[0]: Passanger, obj[1]: Weather, obj[2]: Time, obj[3]: Coupon, obj[4]: Coupon_validity, obj[5]: Gender, obj[6]: Age, obj[7]: Maritalstatus, obj[8]: Children, obj[9]: Education, obj[10]: Occupation, obj[11]: Income, obj[12]: Bar, obj[13]: Coffeehouse, obj[14]: Restaurant20to50, obj[15]: Direct... | def find_decision(obj):
if obj[10] <= 19:
if obj[9] <= 2:
if obj[14] <= 2.0:
if obj[7] > 0:
if obj[6] <= 4:
if obj[2] <= 3:
if obj[12] > 0.0:
if obj[3] > 0:
... |
###Database
#database typy Option:(mongodb, mysql, redis)
DB_TYPE = 'mongdb'
#database ip
DB_HOST = 'localhost'
#database port
DB_PORT = '1'
#username
#USERNAME = None
#passward
#PASSWARD = None
#database name
DB_DBNAME = 'quickspy'
###
| db_type = 'mongdb'
db_host = 'localhost'
db_port = '1'
db_dbname = 'quickspy' |
x = 1
while True:
x = input("Number:\n> ")
if int(x) == 0:
break
| x = 1
while True:
x = input('Number:\n> ')
if int(x) == 0:
break |
#!/usr/bin/env python
# coding: utf-8
# # *section 4: Strings*
#
# ### writer : Faranak Alikhah 1954128
# ### 12.Check Subset:
#
#
# In[ ]:
num_testCase=int(input())
for i in range(num_testCase):
num_testCase1=int(input())
a=set(input().split())
num_testCase2=int(input())
b=set(input().split())
... | num_test_case = int(input())
for i in range(num_testCase):
num_test_case1 = int(input())
a = set(input().split())
num_test_case2 = int(input())
b = set(input().split())
print(a.issubset(b)) |
# Exercise 105 - Parsing and Generating Dictionaries
'''Write a program that has a grades() function that can receive multiple grades
from students and will return a dictionary with the following information:
- Number of notes
- The highest grade
- The lowest grade
- The class average
- The situation (optional)
Als... | """Write a program that has a grades() function that can receive multiple grades
from students and will return a dictionary with the following information:
- Number of notes
- The highest grade
- The lowest grade
- The class average
- The situation (optional)
Also add the docstrings of this function for query by the... |
# Test case for PR#183; print of a recursive PyStringMap causes a JVM stack
# overflow.
g = globals()
print(g)
| g = globals()
print(g) |
###########################################################################
#
# Copyright 2019 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/... | custom_dimension_schema = [{'name': 'accountName', 'type': 'STRING'}, {'name': 'accountId', 'type': 'STRING'}, {'name': 'propertyName', 'type': 'STRING'}, {'name': 'propertyId', 'type': 'STRING'}, {'name': 'id', 'type': 'STRING'}, {'name': 'name', 'type': 'STRING'}, {'name': 'index', 'type': 'STRING'}, {'name': 'scope'... |
def score_hand(player_one: list, player_two: list):
if len(player_one) != 7 or len(player_two) != 7:
raise RuntimeError('invalid hands')
# pairs
player_one_pairs = player_one[1]
player_two_pairs = player_two[1]
player_one_has_pairs = len(player_one_pairs)
player_two_has_pairs = len(pla... | def score_hand(player_one: list, player_two: list):
if len(player_one) != 7 or len(player_two) != 7:
raise runtime_error('invalid hands')
player_one_pairs = player_one[1]
player_two_pairs = player_two[1]
player_one_has_pairs = len(player_one_pairs)
player_two_has_pairs = len(player_two_pairs... |
'''
Title : Zipped!
Subdomain : Built-Ins
Domain : Python
Author : codeperfectplus
Created : 17 January 2020
'''
# Enter your code here. Read input from STDIN. Print output to STDOUT
n, x = map(int, input().split())
sheet = []
for _ in range(x):
sheet.append(map(float, input().split()) )
for i in zi... | """
Title : Zipped!
Subdomain : Built-Ins
Domain : Python
Author : codeperfectplus
Created : 17 January 2020
"""
(n, x) = map(int, input().split())
sheet = []
for _ in range(x):
sheet.append(map(float, input().split()))
for i in zip(*sheet):
print(sum(i) / len(i)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.