content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# -*- coding: utf-8 -*-
def test_task_run():
print("test task run module")
assert 1 == 1
| def test_task_run():
print('test task run module')
assert 1 == 1 |
# A program to calculate frequency of array elements
class ArrayBasic:
def __init__(self, arr, n):
self.arr = arr
self.n = n
def calculate_frequency_hash_map(self):
"""
[A program to calculate counting frequency of array elements]
Time complexity: O(n)
Auxiliary... | class Arraybasic:
def __init__(self, arr, n):
self.arr = arr
self.n = n
def calculate_frequency_hash_map(self):
"""
[A program to calculate counting frequency of array elements]
Time complexity: O(n)
Auxiliary space: O(n)
Returns:
[dict]: [A ... |
n=int(input("Enter the Decimal Number:"))
def covbin(n):
if(n==0):
return 0
else:
return (n%2)+(10*covbin(n//2))
print("Binary is=",covbin(n))
| n = int(input('Enter the Decimal Number:'))
def covbin(n):
if n == 0:
return 0
else:
return n % 2 + 10 * covbin(n // 2)
print('Binary is=', covbin(n)) |
"""
ssml:sheetViews = ssml:CT_SheetViews
Sequence [1..1]
ssml:sheetView [1..*] Worksheet View
ssml:extLst [0..1] Future Feature Storage Area
ssml:sheetView = ssml:CT_SheetView
Sequence [1..1]
ssml:pane [0..1] View Pane
ssml:selection [0..4] Selection
ssml:pivotSelection [0..4] PivotT... | """
ssml:sheetViews = ssml:CT_SheetViews
Sequence [1..1]
ssml:sheetView [1..*] Worksheet View
ssml:extLst [0..1] Future Feature Storage Area
ssml:sheetView = ssml:CT_SheetView
Sequence [1..1]
ssml:pane [0..1] View Pane
ssml:selection [0..4] Selection
ssml:pivotSelection [0..4] PivotT... |
__all__ = ['descriptor',
'es_transport',
'flushing_buffer',
'line_buffer',
'sqs_transport',
'transport_exceptions',
'transport_result',
'transport_utils'] | __all__ = ['descriptor', 'es_transport', 'flushing_buffer', 'line_buffer', 'sqs_transport', 'transport_exceptions', 'transport_result', 'transport_utils'] |
# GPLv3 License
#
# Copyright (C) 2020 Ubisoft
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is dis... | """
This package defines how we send Blender updates to the server, and how we interpret updates we receive to update
Blender's data.
These functionalities are implemented in the BlenderClient class and in submodules of the package.
Submodules with a well defined entity name (camera, collection, light, ...) handle up... |
def total_centro_custo(D_e):
D_return = {}
# Pecorre dados de cada pessoa
for v in D_e.values():
if v['centro de custo'] not in D_return:
D_return[v['centro de custo']] = 0
D_return[v['centro de custo']] += v['valor']
return D_return | def total_centro_custo(D_e):
d_return = {}
for v in D_e.values():
if v['centro de custo'] not in D_return:
D_return[v['centro de custo']] = 0
D_return[v['centro de custo']] += v['valor']
return D_return |
"""
jupylet/lru.py
Copyright (c) 2020, Nir Aides - nir@winpdb.org
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
... | """
jupylet/lru.py
Copyright (c) 2020, Nir Aides - nir@winpdb.org
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
... |
"""MicroESP Errors
"""
__author__ = 'Oleksandr Shepetko'
__email__ = 'a@shepetko.com'
__license__ = 'MIT'
class ESP8266Error(Exception):
pass
class DeviceNotConnectedError(ESP8266Error):
pass
class DeviceCodeExecutionError(ESP8266Error):
pass
| """MicroESP Errors
"""
__author__ = 'Oleksandr Shepetko'
__email__ = 'a@shepetko.com'
__license__ = 'MIT'
class Esp8266Error(Exception):
pass
class Devicenotconnectederror(ESP8266Error):
pass
class Devicecodeexecutionerror(ESP8266Error):
pass |
def print_n(s, n):
while n >= 0:
print(s)
n -= 1
| def print_n(s, n):
while n >= 0:
print(s)
n -= 1 |
# Copyright 2019 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "licens... | package_xml_element_order = ['name', 'version', 'description', 'author', 'maintainer', 'license', 'url', 'buildtool_depend', 'build_depend', 'build_export_depend', 'depend', 'exec_depend', 'test_depend', 'member_of_group', 'doc_depend', 'conflict', 'replace', 'export']
cmake_lists_renamed_variables = {'${CATKIN_DEVEL_P... |
class CommandModule:
def __init__(self, name, bus, conn, chan, conf):
self.name = name
self.conf = conf
self.chan = chan
self.conn = conn
self.bus = bus
def send(self, msg):
self.conn.privmsg(self.chan, msg)... | class Commandmodule:
def __init__(self, name, bus, conn, chan, conf):
self.name = name
self.conf = conf
self.chan = chan
self.conn = conn
self.bus = bus
def send(self, msg):
self.conn.privmsg(self.chan, msg)
def error(self, msg):
self.status('error:... |
text = input('Enter a text: ')
character = input('Enter a character that you can search in "'+text+'": ')
result = text.count(character)
print('The character "'+character+'" appears '+str(result)+' times in "'+text+'".') | text = input('Enter a text: ')
character = input('Enter a character that you can search in "' + text + '": ')
result = text.count(character)
print('The character "' + character + '" appears ' + str(result) + ' times in "' + text + '".') |
class BME280:
'''Class to mock temp sensor'''
def __init__(self):
'''Constructor for mock'''
def get_temperature(self):
'''Temp'''
return 20.0 | class Bme280:
"""Class to mock temp sensor"""
def __init__(self):
"""Constructor for mock"""
def get_temperature(self):
"""Temp"""
return 20.0 |
def test_movie_tech_sections(ia):
movie = ia.get_movie('0133093', info=['technical'])
tech = movie.get('tech', [])
assert set(tech.keys()) == set(['sound mix', 'color', 'aspect ratio', 'camera',
'laboratory', 'cinematographic process', 'printed film format',
... | def test_movie_tech_sections(ia):
movie = ia.get_movie('0133093', info=['technical'])
tech = movie.get('tech', [])
assert set(tech.keys()) == set(['sound mix', 'color', 'aspect ratio', 'camera', 'laboratory', 'cinematographic process', 'printed film format', 'negative format', 'runtime', 'film length']) |
#!/usr/bin/env python3
#Swimming in the pool excercise
def getValue():
try:
valueInput = int(input())
except ValueError:
print("Wrong type")
quit()
else:
return valueInput
def calcResidue(length, coordinate):
halfOfLength = length / 2
residue = length - coordinate
if residue < halfOfLength:
return res... | def get_value():
try:
value_input = int(input())
except ValueError:
print('Wrong type')
quit()
else:
return valueInput
def calc_residue(length, coordinate):
half_of_length = length / 2
residue = length - coordinate
if residue < halfOfLength:
return residu... |
class Robot:
def greet(self):
print('Hello Viraj')
class RobotChild(Robot):
def greet(self):
print('Hello Scott')
# Instantiate RobotChild Class
child = RobotChild()
# Invoke Greet method from RobotChild class
child.greet()
| class Robot:
def greet(self):
print('Hello Viraj')
class Robotchild(Robot):
def greet(self):
print('Hello Scott')
child = robot_child()
child.greet() |
#!/usr/bin/env python3
def welcome():
print("Welcome")
def hi(name):
print("Hi " + name + "!")
welcome()
username = input("Who are there? ")
hi(name=username)
hi(username)
| def welcome():
print('Welcome')
def hi(name):
print('Hi ' + name + '!')
welcome()
username = input('Who are there? ')
hi(name=username)
hi(username) |
class Solution(object):
def reverseBits(self, n):
"""
:type n: int
:rtype: int
"""
for i in xrange(16):
a = (n >> i) & 1
b = (n >> (31-i)) & 1
if a:
n |= 1 << (31-i)
else:
n &= ~(1 << (31-i))
... | class Solution(object):
def reverse_bits(self, n):
"""
:type n: int
:rtype: int
"""
for i in xrange(16):
a = n >> i & 1
b = n >> 31 - i & 1
if a:
n |= 1 << 31 - i
else:
n &= ~(1 << 31 - i)
... |
# preorder: root -> left -> right
# inorder: left -> root -> right
# we can first pick up root from preorder, then get the left and right subtrees from inorder
# Recursion
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val... | class Solution:
def build_tree(self, preorder: List[int], inorder: List[int]) -> TreeNode:
if not inorder:
return
ind = inorder.index(preorder.pop(0))
root = tree_node(inorder[ind])
root.left = self.buildTree(preorder, inorder[0:ind])
root.right = self.buildTree(... |
classes_names = [
'book',
'bottle',
'cabinet',
'ceiling',
'chair',
'cone',
'counter',
'dishwasher',
'faucet',
'fire extinguisher',
'floor',
'garbage bin',
'microwave',
'paper towel dispenser',
'paper',
'pot',
'refridgerator',
'stove burner',
'table',
'unknown',
'wall',
'bowl',
'magnet',
'sink',
'air vent',
'box',
'door... | classes_names = ['book', 'bottle', 'cabinet', 'ceiling', 'chair', 'cone', 'counter', 'dishwasher', 'faucet', 'fire extinguisher', 'floor', 'garbage bin', 'microwave', 'paper towel dispenser', 'paper', 'pot', 'refridgerator', 'stove burner', 'table', 'unknown', 'wall', 'bowl', 'magnet', 'sink', 'air vent', 'box', 'door ... |
'''
Return the nth Fibonacci number
F0 = 0 F1 = 1
Fn = Fn-1 + Fn-2
'''
def Fibonacci(n):
''' return nth fibonacci number
to reduce O(n), we invoke recursion only once during one call (Fn-1, Fn-2)
'''
if n <= 1:
return (n,0)
else:
(a,b) = Fibonacci(n-1)
return (a+b,a)
#p... | """
Return the nth Fibonacci number
F0 = 0 F1 = 1
Fn = Fn-1 + Fn-2
"""
def fibonacci(n):
""" return nth fibonacci number
to reduce O(n), we invoke recursion only once during one call (Fn-1, Fn-2)
"""
if n <= 1:
return (n, 0)
else:
(a, b) = fibonacci(n - 1)
return (a + b,... |
thisdict = {
"brand":"Ford",
"model":"Mustang",
"year":1964
}
for x in thisdict.values():
print(x)
| thisdict = {'brand': 'Ford', 'model': 'Mustang', 'year': 1964}
for x in thisdict.values():
print(x) |
name = "ada lovelace"
print(name.title())
print(name.upper())
print(name.lower())
| name = 'ada lovelace'
print(name.title())
print(name.upper())
print(name.lower()) |
#!/usr/bin/env python
"""
Class definition to store attributes of micro architectural events
This module provides definitions for the following events
1. generic core - events programmable in general purpose pmu registers
2. fixed core - events colleted by fixed pmu registers
3. offcore - counters for off... | """
Class definition to store attributes of micro architectural events
This module provides definitions for the following events
1. generic core - events programmable in general purpose pmu registers
2. fixed core - events colleted by fixed pmu registers
3. offcore - counters for offcore requests and resp... |
"""
Functions for working with, checking and converting numbers.
All numbers are stored within the computer as the positive equivalent.
They may be interpreted as negative.
"""
def number_to_bitstring(number, bit_width=8):
"""
Convert a number to an equivalent bitstring of the given width.
Raises:
... | """
Functions for working with, checking and converting numbers.
All numbers are stored within the computer as the positive equivalent.
They may be interpreted as negative.
"""
def number_to_bitstring(number, bit_width=8):
"""
Convert a number to an equivalent bitstring of the given width.
Raises:
... |
def has_style(tag):
return tag.has_attr('style')
def has_class(tag):
return tag.has_attr('class')
def clean(soup):
if soup.name == 'br' or soup.name == 'img' or soup.name == 'p' or soup.name == 'div':
return
try:
ll = 0
for j in soup.strings:
ll += len(j.replace('\n', ''))
if ll == 0:
soup.decompose... | def has_style(tag):
return tag.has_attr('style')
def has_class(tag):
return tag.has_attr('class')
def clean(soup):
if soup.name == 'br' or soup.name == 'img' or soup.name == 'p' or (soup.name == 'div'):
return
try:
ll = 0
for j in soup.strings:
ll += len(j.replace('... |
#
# PySNMP MIB module HIRSCHMANN-PIM-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HIRSCHMANN-PIM-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:31:12 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, ... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, single_value_constraint, constraints_intersection, value_size_constraint, constraints_union) ... |
"""
[Question.py]
@description: a set of functions which helps with asking console questions.
"""
def ask(question):
print(question)
answer = input("Response: ")
return answer
def ask_bool_positive_safe(question):
answer = input(question + " ")
return (answer.lower() == "true") or \
(... | """
[Question.py]
@description: a set of functions which helps with asking console questions.
"""
def ask(question):
print(question)
answer = input('Response: ')
return answer
def ask_bool_positive_safe(question):
answer = input(question + ' ')
return answer.lower() == 'true' or answer.lower() == ... |
load(
"@d2l_rules_csharp//csharp:defs.bzl",
"csharp_register_toolchains",
"csharp_repositories",
"import_nuget_package",
)
def selenium_register_dotnet():
csharp_register_toolchains()
csharp_repositories()
native.register_toolchains("//third_party/dotnet/ilmerge:all")
import_nuget_pac... | load('@d2l_rules_csharp//csharp:defs.bzl', 'csharp_register_toolchains', 'csharp_repositories', 'import_nuget_package')
def selenium_register_dotnet():
csharp_register_toolchains()
csharp_repositories()
native.register_toolchains('//third_party/dotnet/ilmerge:all')
import_nuget_package(name='json.net',... |
wifi_ssid = ""
wifi_password = ""
mqtt_username = ""
mqtt_password = ""
mqtt_address = ""
mqtt_port = 8883
| wifi_ssid = ''
wifi_password = ''
mqtt_username = ''
mqtt_password = ''
mqtt_address = ''
mqtt_port = 8883 |
# NOTE: \a is the delimiter for chat pages
# Quest ids can be found in Quests.py
SCRIPT = '''
ID reward_100
SHOW laffMeter
LERP_POS laffMeter 0 0 0 1
LERP_SCALE laffMeter 0.2 0.2 0.2 1
WAIT 1.5
ADD_LAFFMETER 1
WAIT 1
LERP_POS laffMeter -1.18 0 -0.87 1
LERP_SCALE laffMeter 0.075 0.075 0.075 1
WAIT 1
FINISH_QUEST_MOVIE
... | script = '\nID reward_100\nSHOW laffMeter\nLERP_POS laffMeter 0 0 0 1\nLERP_SCALE laffMeter 0.2 0.2 0.2 1\nWAIT 1.5\nADD_LAFFMETER 1\nWAIT 1\nLERP_POS laffMeter -1.18 0 -0.87 1\nLERP_SCALE laffMeter 0.075 0.075 0.075 1\nWAIT 1\nFINISH_QUEST_MOVIE\n\n# TUTORIAL\n\nID tutorial_mickey\nLOAD_SFX soundRun "phase_3.5/audio/s... |
# https://leetcode.com/submissions/detail/109225225/
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def reverseList(self, head):
"""
:type head: ListNode
:rtype: ListNode
... | class Solution(object):
def reverse_list(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
if head is None:
return
stack = []
while head:
stack.append(head)
head = head.next
head = stack.pop()
head.... |
class Word():
"""docstring for Word"""
def __init__(self, text: str, start_time: float, end_time: float):
assert isinstance(text, str), "text should be string."
assert isinstance(start_time, float) and isinstance(end_time, float), "Start time and end time should be float values."
self.text = text
... | class Word:
"""docstring for Word"""
def __init__(self, text: str, start_time: float, end_time: float):
assert isinstance(text, str), 'text should be string.'
assert isinstance(start_time, float) and isinstance(end_time, float), 'Start time and end time should be float values.'
self.tex... |
while True:
valores = input().split()
n = int(valores[0])
d = a = int(valores[1])
e = b = int(valores[2])
if n == 0 and a == 0 and b == 0:
break
while e != 0:
d, e = e, d % e
c = (a * b) // d
a_l = len(range(a, n + 1, a))
b_l = len(range(b, n + 1, b))
c_... | while True:
valores = input().split()
n = int(valores[0])
d = a = int(valores[1])
e = b = int(valores[2])
if n == 0 and a == 0 and (b == 0):
break
while e != 0:
(d, e) = (e, d % e)
c = a * b // d
a_l = len(range(a, n + 1, a))
b_l = len(range(b, n + 1, b))
c_l = le... |
def convert_to_string(idx_list, form_manager):
w_list = []
for i in range(len(idx_list)):
w_list.append(form_manager.get_idx_symbol(int(idx_list[i])))
return " ".join(w_list)
def is_all_same(c1, c2, form_manager):
all_same = False
if len(c1) == len(c2):
all_same = True
for ... | def convert_to_string(idx_list, form_manager):
w_list = []
for i in range(len(idx_list)):
w_list.append(form_manager.get_idx_symbol(int(idx_list[i])))
return ' '.join(w_list)
def is_all_same(c1, c2, form_manager):
all_same = False
if len(c1) == len(c2):
all_same = True
for j... |
def test_geoadd(judge_command):
judge_command(
'GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania"',
{
"command": "GEOADD",
"key": "Sicily",
"longitude": "15.087269",
"latitude": "37.502669",
"member": '"Catania"',
... | def test_geoadd(judge_command):
judge_command('GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania"', {'command': 'GEOADD', 'key': 'Sicily', 'longitude': '15.087269', 'latitude': '37.502669', 'member': '"Catania"'})
def test_georadiusbymember(judge_command):
judge_command('GEORADIUSBYMEMBE... |
"""
Common utilities/lib for use by multiple services
"""
subscription_types = ['policy_eval', 'tag_update', 'vuln_update', 'repo_update', 'analysis_update']
resource_types = ['registries', 'users', 'images', 'policies', 'evaluations', 'subscriptions', 'archive']
bucket_types = ["analysis_data", "policy_bundles", "pol... | """
Common utilities/lib for use by multiple services
"""
subscription_types = ['policy_eval', 'tag_update', 'vuln_update', 'repo_update', 'analysis_update']
resource_types = ['registries', 'users', 'images', 'policies', 'evaluations', 'subscriptions', 'archive']
bucket_types = ['analysis_data', 'policy_bundles', 'poli... |
"""
Dexter Legaspi
Class: CS 521 - Summer 2
Date: 08/03/2021
Homework Problem # 5.6.3
Description of Problem: A program that highlights the use of proper exception
handling.
"""
EXPECTED_INPUTS = 4
# validate input and the result loop
while True:
user_input = input('Please enter {} numbers delimited by space: '
... | """
Dexter Legaspi
Class: CS 521 - Summer 2
Date: 08/03/2021
Homework Problem # 5.6.3
Description of Problem: A program that highlights the use of proper exception
handling.
"""
expected_inputs = 4
while True:
user_input = input('Please enter {} numbers delimited by space: '.format(EXPECTED_INPUTS)).split()
if ... |
# Copyright 2019 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.
PYTHON_VERSION_COMPATIBILITY = 'PY2+3'
DEPS = [
'recipe_engine/cipd',
'recipe_engine/commit_position',
'recipe_engine/context',
'recipe_engine/file'... | python_version_compatibility = 'PY2+3'
deps = ['recipe_engine/cipd', 'recipe_engine/commit_position', 'recipe_engine/context', 'recipe_engine/file', 'recipe_engine/golang', 'recipe_engine/json', 'recipe_engine/nodejs', 'recipe_engine/path', 'recipe_engine/raw_io', 'recipe_engine/step', 'depot_tools/depot_tools', 'depot... |
class Cup(object):
def __init__(self, name):
self.name = name
self.price = 0
class MyClass:
pass
def myfunc():
pass
if __name__ == '__main__':
cup1 = Cup('aaa')
cup2 = Cup('bbb')
# get attribute of object
print(getattr(cup1, 'name'))
print(getattr(cup2, 'name'))
... | class Cup(object):
def __init__(self, name):
self.name = name
self.price = 0
class Myclass:
pass
def myfunc():
pass
if __name__ == '__main__':
cup1 = cup('aaa')
cup2 = cup('bbb')
print(getattr(cup1, 'name'))
print(getattr(cup2, 'name'))
try:
name = getattr(cup1... |
# set, himpunan:
super_hero = {'superman','ironman','hulk','flash'}
print(super_hero)
print('1=====================')
super_hero.add('gundala')
super_hero.add('121')
print(super_hero)
print('2=====================')
super_hero.add('hulk')
print(super_hero)
print(sorted(super_hero))
print('3========... | super_hero = {'superman', 'ironman', 'hulk', 'flash'}
print(super_hero)
print('1=====================')
super_hero.add('gundala')
super_hero.add('121')
print(super_hero)
print('2=====================')
super_hero.add('hulk')
print(super_hero)
print(sorted(super_hero))
print('3=====================')
ganjil = {1, 3, 5, ... |
# Python carefully avoids evaluating bools more than once in a variety of situations.
# Eg:
# In the statement
# if a or b:
# it doesn't simply compute (a or b) and then evaluate the result to decide whether to
# jump. If a is true it jumps directly to the body of the if statement.
# We can confirm that this behaviour... | class Explodingbool:
def __init__(self, value):
self.value = value
self.booled = False
def __bool__(self):
assert not self.booled
self.booled = True
return self.value
y = exploding_bool(False) and False and True and False
print(y)
if exploding_bool(True) or False or Tru... |
def firstZero(arr, low, high):
if (high >= low):
# Check if mid element is first 0
mid = low + int((high - low) / 2)
if (( mid == 0 or arr[mid-1] == 1)
and arr[mid] == 0):
return mid
# If mid element is not 0
if (... | def first_zero(arr, low, high):
if high >= low:
mid = low + int((high - low) / 2)
if (mid == 0 or arr[mid - 1] == 1) and arr[mid] == 0:
return mid
if arr[mid] == 1:
return first_zero(arr, mid + 1, high)
else:
return first_zero(arr, low, mid - 1)
... |
# coding: utf-8
#
# Copyright 2022 :Barry-Thomas-Paul: Moss
#
# Licensed under the Apache License, Version 2.0 (the "License")
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http: // www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | class Commonfilepickerelementids(object):
"""
Const Class
These constants are used to specify common controls of a FilePicker dialog.
**since**
OOo 1.1.2
See Also:
`API CommonFilePickerElementIds <https://api.libreoffice.org/docs/idl/ref/namespacecom_1_1sun_1_1star_1_1ui_... |
"""Package pyang.transforms: transform plugins for YANG.
Modules:
* edit: YANG edit transform plugin
"""
| """Package pyang.transforms: transform plugins for YANG.
Modules:
* edit: YANG edit transform plugin
""" |
# augmented vertex
class Vertex:
def __init__(self, element, location):
self.element = element
self.location = location
def getElement(self):
return self.element
def setElement(self, element):
self.element = element
def getLocation(self):
return self.location
... | class Vertex:
def __init__(self, element, location):
self.element = element
self.location = location
def get_element(self):
return self.element
def set_element(self, element):
self.element = element
def get_location(self):
return self.location
def set_loc... |
def get_node_info(file):
nodes = set()
df = [line.strip().split() for line
in open('input/%s.txt' % file).readlines()
if line.startswith('/dev')]
for nodeinfo in df:
# Filesystem Size Used Avail Use%
# /dev/grid/node-x0-y0 92T 68T ... | def get_node_info(file):
nodes = set()
df = [line.strip().split() for line in open('input/%s.txt' % file).readlines() if line.startswith('/dev')]
for nodeinfo in df:
(_, x, y) = nodeinfo[0].split('-')
size = int(nodeinfo[1][:-1])
used = int(nodeinfo[2][:-1])
node = (int(x[1:]... |
class Problem:
initial_state = [None, None, None, None, None, None, None, None]
row = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
col = [0,1,2,3,4,5,6,7]
def check_if_attacked(self, state): # returns True if attacked
try:
index = state.index(None) - 1
except ValueEr... | class Problem:
initial_state = [None, None, None, None, None, None, None, None]
row = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
col = [0, 1, 2, 3, 4, 5, 6, 7]
def check_if_attacked(self, state):
try:
index = state.index(None) - 1
except ValueError:
index = 7
... |
# Easy
# https://leetcode.com/problems/climbing-stairs/
class Solution:
# Time complexity : O(n)
# Space complexity: O(1)
# Fibonacci sequence
def climbStairs(self, n: int) -> int:
a, b = 1, 2
for _ in range(1, n):
a, b = b, a + b
return a
| class Solution:
def climb_stairs(self, n: int) -> int:
(a, b) = (1, 2)
for _ in range(1, n):
(a, b) = (b, a + b)
return a |
"""
Author: Clinton Wang, E-mail: `clintonjwang@gmail.com`, Github: `https://github.com/clintonjwang/lipiodol`
"""
class Config:
def __init__(self):
self.proj_dims = [64,64,32]
self.world_dims = [32,64,64]
#self.aug_factor = 100
self.npy_dir = r"D:\CBCT\Train\NPYs"
self.nii_dir = r"D:\CBCT\Train\NIFTIs"
... | """
Author: Clinton Wang, E-mail: `clintonjwang@gmail.com`, Github: `https://github.com/clintonjwang/lipiodol`
"""
class Config:
def __init__(self):
self.proj_dims = [64, 64, 32]
self.world_dims = [32, 64, 64]
self.npy_dir = 'D:\\CBCT\\Train\\NPYs'
self.nii_dir = 'D:\\CBCT\\Train\\... |
file = {'amy':5,
'bob':8,
'candy':6,
'doby':9,
'john':0}
print("Amy's number is:" +'\n\t' + str(file['amy']) +'.')
print("\nBob's number is:" +'\n\t' + str(file['bob']) +'.') | file = {'amy': 5, 'bob': 8, 'candy': 6, 'doby': 9, 'john': 0}
print("Amy's number is:" + '\n\t' + str(file['amy']) + '.')
print("\nBob's number is:" + '\n\t' + str(file['bob']) + '.') |
class Solution:
def myAtoi(self, str):
if len(str) == 0:
return 0
res = 0
max_int = 2147483647
min_int = -2147483648
for i in range(0, len(str)):
c = str[i]
if c != ' ':
break
s = str[i:]
pos = False
... | class Solution:
def my_atoi(self, str):
if len(str) == 0:
return 0
res = 0
max_int = 2147483647
min_int = -2147483648
for i in range(0, len(str)):
c = str[i]
if c != ' ':
break
s = str[i:]
pos = False
... |
class Config:
def __init__(self):
self.basename = 'delta_video'
self.directory = '/home/eleanor/Documents/gcamp_analysis_files_temp/171019-06-bottom-experiment/data'
self.topics = ['/multi_tracker/1/delta_video',]
self.record_length_hours = 1 | class Config:
def __init__(self):
self.basename = 'delta_video'
self.directory = '/home/eleanor/Documents/gcamp_analysis_files_temp/171019-06-bottom-experiment/data'
self.topics = ['/multi_tracker/1/delta_video']
self.record_length_hours = 1 |
## -*- coding: utf-8 -*- ##
## Sage Doctest File ##
#**************************************#
#* Generated from PreTeXt source *#
#* on 2017-08-24T11:43:34-07:00 *#
#* *#
#* http://mathbook.pugetsound.edu *#
#* ... | """
Please contact Rob Beezer (beezer@ups.edu) with
any test failures here that need to be changed
as a result of changes accepted into Sage. You
may edit/change this file in any sensible way, so
that development work may procede. Your changes
may later be replaced by the authors of "Abstract
Algebra: Theory and Appl... |
class Memory:
def __init__(self, size):
self.mem = bytearray(size)
self.bin_size = 0
def read8(self, addr):
val = self.mem[addr]
#if addr > self.bin_size:
# print(f'Read {val:02x} at {addr}')
return val
def write8(self, addr, val):
self.mem[addr]... | class Memory:
def __init__(self, size):
self.mem = bytearray(size)
self.bin_size = 0
def read8(self, addr):
val = self.mem[addr]
return val
def write8(self, addr, val):
self.mem[addr] = val
def write_bin(self, addr, data):
self.mem[addr:addr + len(data... |
__author__ = 'Jeffrey Seifried'
__description__ = 'A library for forecasting sun positions'
__email__ = 'jeffrey.seifried@gmail.com'
__program__ = 'analemma'
__url__ = 'http://github.com/jeffseif/{}'.format(__program__)
__version__ = '1.0.0'
__year__ = '2020'
| __author__ = 'Jeffrey Seifried'
__description__ = 'A library for forecasting sun positions'
__email__ = 'jeffrey.seifried@gmail.com'
__program__ = 'analemma'
__url__ = 'http://github.com/jeffseif/{}'.format(__program__)
__version__ = '1.0.0'
__year__ = '2020' |
"""
MIT License
Copyright (c) 2021 FelipeSavazi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, ... | """
MIT License
Copyright (c) 2021 FelipeSavazi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, ... |
'''
Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings.
You need to help them find out their common interest with the least list index sum. If there is a choice tie between answers, output all of them with no order requirement. You co... | """
Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings.
You need to help them find out their common interest with the least list index sum. If there is a choice tie between answers, output all of them with no order requirement. You co... |
# -*- coding: utf-8 -*-
"""
Procurement
A module to handle Procurement
Currently handles
Suppliers
Planned Procurements
Purchase Orders (POs)
@ToDo: Extend to
Purchase Requests (PRs)
"""
if not settings.has_module(c):
raise HTTP(404, body="Module disabled: %s" % ... | """
Procurement
A module to handle Procurement
Currently handles
Suppliers
Planned Procurements
Purchase Orders (POs)
@ToDo: Extend to
Purchase Requests (PRs)
"""
if not settings.has_module(c):
raise http(404, body='Module disabled: %s' % c)
def index():
""" M... |
# flake8: noqa
# https://github.com/trezor/python-mnemonic/blob/master/vectors.json
trezor_vectors = {
"english": [
{
"id": 0,
"entropy": "00000000000000000000000000000000",
"mnemonic": "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about",
"salt"... | trezor_vectors = {'english': [{'id': 0, 'entropy': '00000000000000000000000000000000', 'mnemonic': 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about', 'salt': 'TREZOR', 'binary': '00000000000 00000000000 00000000000 00000000000 00000000000 00000000000 00000000000 00000000000... |
# -*- coding: utf-8 -*-
# Copyright 2011 Fanficdownloader team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | pass |
class Mapper(object):
""" A base clap from which to ineherit in order to create a keyboard mapper. """
def __init__(self):
self.base_map = None
self.alt_map = None
self.map = None
def create_map(self):
self.map = dict(zip(self.base_map, self.alt_map))
def map_key(self, ... | class Mapper(object):
""" A base clap from which to ineherit in order to create a keyboard mapper. """
def __init__(self):
self.base_map = None
self.alt_map = None
self.map = None
def create_map(self):
self.map = dict(zip(self.base_map, self.alt_map))
def map_key(self,... |
"""
A package with everything you need to build a simple neural network
"""
# todo - add unit tests
| """
A package with everything you need to build a simple neural network
""" |
# Copyright (c) Microsoft Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in wri... | async def test_check_the_box(page):
await page.setContent('<input id="checkbox" type="checkbox"></input>')
await page.check('input')
assert await page.evaluate('checkbox.checked')
async def test_not_check_the_checked_box(page):
await page.setContent('<input id="checkbox" type="checkbox" checked></input... |
# https://leetcode.com/problems/single-number-iii/
class Solution:
def singleNumber(self, nums: List[int]) -> List[int]:
d = {}
for num in nums:
if num in d:
d[num] += 1
else:
d[num] = 1
result = []
for key, v... | class Solution:
def single_number(self, nums: List[int]) -> List[int]:
d = {}
for num in nums:
if num in d:
d[num] += 1
else:
d[num] = 1
result = []
for (key, value) in d.items():
if value == 1:
resu... |
# https://stackoverflow.com/questions/1883980/find-the-nth-occurrence-of-substring-in-a-string
def find_nth(haystack, needle, n):
start = haystack.find(needle)
while start >= 0 and n > 1:
start = haystack.find(needle, start+len(needle))
n -= 1
return start
file_to_be_read = input("Which fil... | def find_nth(haystack, needle, n):
start = haystack.find(needle)
while start >= 0 and n > 1:
start = haystack.find(needle, start + len(needle))
n -= 1
return start
file_to_be_read = input('Which file do you want to open? (Please specify the full filename.)\n')
rtz_file = open(file_to_be_read... |
a=int(input("Enter a number"))
if a%2==0:
print(a,"is an Even Number")
else:
print(a,"is an Odd Number")
| a = int(input('Enter a number'))
if a % 2 == 0:
print(a, 'is an Even Number')
else:
print(a, 'is an Odd Number') |
# wczytanie wszystkich trzech plikow
with open('../dane/dane5-1.txt') as f:
data1 = []
for line in f.readlines():
data1.append(int(line[:-1]))
with open('../dane/dane5-2.txt') as f:
data2 = []
for line in f.readlines():
data2.append(int(line[:-1]))
with open('../dane/dane5-3.txt') as f:
... | with open('../dane/dane5-1.txt') as f:
data1 = []
for line in f.readlines():
data1.append(int(line[:-1]))
with open('../dane/dane5-2.txt') as f:
data2 = []
for line in f.readlines():
data2.append(int(line[:-1]))
with open('../dane/dane5-3.txt') as f:
data3 = []
for line in f.read... |
numbers = list(range(0, 110, 10))
numbers = (0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100)
second = []
x = 0
while x < len(numbers):
t = numbers[x] *2.5
if t % 2 == 0:
second.append(int(t))
x += 1
print(second)
print(x) | numbers = list(range(0, 110, 10))
numbers = (0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100)
second = []
x = 0
while x < len(numbers):
t = numbers[x] * 2.5
if t % 2 == 0:
second.append(int(t))
x += 1
print(second)
print(x) |
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "workspace_and_buildfile")
load(
"@bazel_tools//tools/cpp:lib_cc_configure.bzl",
"auto_configure_fail",
"auto_configure_warning",
"escape_string",
"get_env_var",
"get_starlark_list",
"resolve_labels",
"split_escaped",
"which",
)
l... | load('@bazel_tools//tools/build_defs/repo:utils.bzl', 'workspace_and_buildfile')
load('@bazel_tools//tools/cpp:lib_cc_configure.bzl', 'auto_configure_fail', 'auto_configure_warning', 'escape_string', 'get_env_var', 'get_starlark_list', 'resolve_labels', 'split_escaped', 'which')
load('//AvrToolchain:cc_toolchain/cc_too... |
class initial(object):
pass
INITIAL = initial()
another = INITIAL
print(another is INITIAL) | class Initial(object):
pass
initial = initial()
another = INITIAL
print(another is INITIAL) |
# Copyright (c) Facebook, Inc. and its affiliates. (http://www.facebook.com)
{*[1,2,3], *[4,5,6]}
# EXPECTED:
[
...,
BUILD_SET_UNPACK(2),
...
]
| {*[1, 2, 3], *[4, 5, 6]}
[..., build_set_unpack(2), ...] |
def capital_indexes(string: str) -> list:
return [index for index, char in enumerate(string) if char.isupper()]
# return [letter for letter in range(len(indexes)) if indexes[letter].isupper()]
def tests() -> None:
print(capital_indexes("mYtESt")) # [1, 3, 4]
print(capital_indexes("owO"))
if __name_... | def capital_indexes(string: str) -> list:
return [index for (index, char) in enumerate(string) if char.isupper()]
def tests() -> None:
print(capital_indexes('mYtESt'))
print(capital_indexes('owO'))
if __name__ == '__main__':
tests() |
# dataset settings
dataset_type = 'ImageNet'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='RandomResizedCrop', size=224, backend='pillow'),
dict(type='RandomFlip', flip_prob=0.5, direction='hor... | dataset_type = 'ImageNet'
img_norm_cfg = dict(mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
train_pipeline = [dict(type='LoadImageFromFile'), dict(type='RandomResizedCrop', size=224, backend='pillow'), dict(type='RandomFlip', flip_prob=0.5, direction='horizontal'), dict(type='Normalize', **i... |
"""Scorer of model predictions. Adaped from OneIE. """
def safe_div(num, denom):
if denom > 0:
if num / denom <= 1:
return num / denom
else:
return 1
else:
return 0
def compute_f1(predicted, gold, matched):
precision = safe_div(matched, predicted)
recall = safe_div(matched, gold)
f1 = safe_div(2 * ... | """Scorer of model predictions. Adaped from OneIE. """
def safe_div(num, denom):
if denom > 0:
if num / denom <= 1:
return num / denom
else:
return 1
else:
return 0
def compute_f1(predicted, gold, matched):
precision = safe_div(matched, predicted)
recall... |
class StakeHolder:
def __init__(self, staker, amount_pending_for_approval, amount_approved, block_no_created):
self._staker = staker
self._amount_pending_for_approval = amount_pending_for_approval
self._amount_approved = amount_approved
self._block_no_created = block_no_created
... | class Stakeholder:
def __init__(self, staker, amount_pending_for_approval, amount_approved, block_no_created):
self._staker = staker
self._amount_pending_for_approval = amount_pending_for_approval
self._amount_approved = amount_approved
self._block_no_created = block_no_created
... |
sender = ''
password = ''
smtp_name = 'smtp.gmail.com'
smtp_port = 587
body = """
<html>
<body>
<p>Hi User,<br>
How are you?<br>
</p>
</body>
</html>
"""
receiver = ''
signature_img_name = 'awesome_attachment.png'
signature_img_path = 'C:/Users/user/Desktop/'
attachment_name = signa... | sender = ''
password = ''
smtp_name = 'smtp.gmail.com'
smtp_port = 587
body = '\n<html>\n <body>\n <p>Hi User,<br>\n How are you?<br>\n </p>\n </body>\n</html>\n'
receiver = ''
signature_img_name = 'awesome_attachment.png'
signature_img_path = 'C:/Users/user/Desktop/'
attachment_name = signature_img_name
... |
"""
1120. Maximum Average Subtree
Medium
Given the root of a binary tree, find the maximum average value of any subtree of that tree.
(A subtree of a tree is any node of that tree plus all its descendants. The average value of a tree is the sum of its values, divided by the number of nodes.)
Example 1:
Input: ... | """
1120. Maximum Average Subtree
Medium
Given the root of a binary tree, find the maximum average value of any subtree of that tree.
(A subtree of a tree is any node of that tree plus all its descendants. The average value of a tree is the sum of its values, divided by the number of nodes.)
Example 1:
Input: ... |
# -*- coding: utf-8 -*-
template_model_creation = """import pandas as pd
from sklearn.model_selection import train_test_split
{model_import} as ChosenMLAlgorithm
from sklearn.metrics import accuracy_score, confusion_matrix
import pickle
csv_file = "{csv_file}"
model_file = "{model_file}"
predictors = {predictors}
t... | template_model_creation = 'import pandas as pd\nfrom sklearn.model_selection import train_test_split\n\n{model_import} as ChosenMLAlgorithm\n\nfrom sklearn.metrics import accuracy_score, confusion_matrix\nimport pickle\n\ncsv_file = "{csv_file}"\nmodel_file = "{model_file}"\npredictors = {predictors}\ntargets = {target... |
my_variabel = "hai darmawan"
for variabel_baru in my_variabel:
print("for string: ",variabel_baru)
my_list =["aku", "kamu", "dia"]
my_tuple=(1,5,6,7)
for variabel_baru3 in my_tuple:
print("for list or tuple", variabel_baru3)
| my_variabel = 'hai darmawan'
for variabel_baru in my_variabel:
print('for string: ', variabel_baru)
my_list = ['aku', 'kamu', 'dia']
my_tuple = (1, 5, 6, 7)
for variabel_baru3 in my_tuple:
print('for list or tuple', variabel_baru3) |
def main():
x=11
y=2
print("Addition X+Y=",x+y)
print("Subtraction X-Y=",x-y)
print("Multiplication X*Y=",x*y)
print("Division X/Y=",x/y)
print("Modulus X%Y=",x%y)
print("Exponent X**Y=",x**y)
print("Floor Division X//Y=",x//y)
if __name__ == '__main__':
main()
| def main():
x = 11
y = 2
print('Addition X+Y=', x + y)
print('Subtraction X-Y=', x - y)
print('Multiplication X*Y=', x * y)
print('Division X/Y=', x / y)
print('Modulus X%Y=', x % y)
print('Exponent X**Y=', x ** y)
print('Floor Division X//Y=', x // y)
if __name__ == '__main__':
... |
def test_screen_two():
for num in range(0, 100):
col = int(num * 0.01 * 2.0)
y = (num * 0.01 - float(col) / 2.0) * 2.0
newY = y / 960.0 * 480.0 + 1.0 / 4.0
print('col:' + str(col) + ' num: ' + str(num) + ' y: ' + str(y) + ' newY: ' + str(newY))
# print(str(newY))
def test_sc... | def test_screen_two():
for num in range(0, 100):
col = int(num * 0.01 * 2.0)
y = (num * 0.01 - float(col) / 2.0) * 2.0
new_y = y / 960.0 * 480.0 + 1.0 / 4.0
print('col:' + str(col) + ' num: ' + str(num) + ' y: ' + str(y) + ' newY: ' + str(newY))
def test_scale():
for num in rang... |
__project__ = "o3seespy"
__author__ = "Maxim Millen & Minjie Zhu"
__version__ = "3.1.0.18"
__license__ = "MIT with OpenSees License"
| __project__ = 'o3seespy'
__author__ = 'Maxim Millen & Minjie Zhu'
__version__ = '3.1.0.18'
__license__ = 'MIT with OpenSees License' |
# By Kami Bigdely
# Decompose conditional: You have a complicated conditional(if-then-else) statement. Extract
# methods from the condition, then part, and else part(s).
def make_alert_sound():
print('made alert sound.')
def make_accept_sound():
print('made acceptance sound')
def check_if_toxin(ingredients):... | def make_alert_sound():
print('made alert sound.')
def make_accept_sound():
print('made acceptance sound')
def check_if_toxin(ingredients):
"""Checks if any of the ingredients are in the list of toxic ingrediets"""
toxic_indredients = ['sodium nitrate', 'sodium benzoate', 'sodium oxide']
return an... |
class MyClass:
def __init__(self):
self.var = 'var'
def method(self):
print('method')
x = MyClass()
x.method()
m = x.method
m()
| class Myclass:
def __init__(self):
self.var = 'var'
def method(self):
print('method')
x = my_class()
x.method()
m = x.method
m() |
'''
@author: l4zyc0d3r
People who are happy makes other happy. I am gonna finish it slowly but definitely.cdt
'''
class Solution:
def kthFactor(self, n: int, k: int) -> int:
for i in range(1, n+1):
if n % i == 0:
k-=1
if k == 0: return i
return -1
| """
@author: l4zyc0d3r
People who are happy makes other happy. I am gonna finish it slowly but definitely.cdt
"""
class Solution:
def kth_factor(self, n: int, k: int) -> int:
for i in range(1, n + 1):
if n % i == 0:
k -= 1
if k == 0:
return i
... |
"""This is the calculation class / abstraction class"""
class Calculation:
"""Creates the Calculation parent class for the arithmetic subclasses"""
# pylint: disable=bad-option-value, too-few-public-methods
def __init__(self, values: tuple):
"""Constructor Method"""
self.values = Calculati... | """This is the calculation class / abstraction class"""
class Calculation:
"""Creates the Calculation parent class for the arithmetic subclasses"""
def __init__(self, values: tuple):
"""Constructor Method"""
self.values = Calculation.convert_to_float(values)
@classmethod
def create(cl... |
_base_ = [
'../_base_/datasets/nus-mono3d.py', '../_base_/models/fcos3d.py',
'../_base_/schedules/mmdet_schedule_1x.py', '../_base_/default_runtime.py'
]
# model settings
model = dict(
backbone=dict(
type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
# ... | _base_ = ['../_base_/datasets/nus-mono3d.py', '../_base_/models/fcos3d.py', '../_base_/schedules/mmdet_schedule_1x.py', '../_base_/default_runtime.py']
model = dict(backbone=dict(type='ResNet', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=1, norm_cfg=dict(type='SyncBN', requires_grad=True), norm_eval... |
#! /usr/bin/env python3
def main():
languages = {
"Python": "Guido van Rossum",
"Ruby": "Yukihiro Matsumoto",
"PHP": "Rasmus Lerdorf"
}
for each in languages:
print(each + " was created by " + languages[each])
if __name__ == "__main__":
main() | def main():
languages = {'Python': 'Guido van Rossum', 'Ruby': 'Yukihiro Matsumoto', 'PHP': 'Rasmus Lerdorf'}
for each in languages:
print(each + ' was created by ' + languages[each])
if __name__ == '__main__':
main() |
ziehungen = input().split(",")
ziehungen = [int(x) for x in ziehungen]
boards = []
while True:
leer = input()
zeile = [input().split(" ")]
zeile[0] = [int(x) for x in zeile[0] if x != '']
if zeile[0] != []:
for i in range(1,5):
zeile.append(input().split(" "))
zeile[i] ... | ziehungen = input().split(',')
ziehungen = [int(x) for x in ziehungen]
boards = []
while True:
leer = input()
zeile = [input().split(' ')]
zeile[0] = [int(x) for x in zeile[0] if x != '']
if zeile[0] != []:
for i in range(1, 5):
zeile.append(input().split(' '))
zeile[i] =... |
def insertion_sort(arr):
for i in range(1, len(arr)):
key = arr[i]
j = i - 1
while(j>=0 and arr[j]>key):
arr[j+1]=arr[j]
j = j - 1
arr[j+1] = key
return arr
def main():
arr = [6, 5, 8, 9, 3, 1, 4, 7, 2]
sorted_arr = insertion_sort(arr)
... | def insertion_sort(arr):
for i in range(1, len(arr)):
key = arr[i]
j = i - 1
while j >= 0 and arr[j] > key:
arr[j + 1] = arr[j]
j = j - 1
arr[j + 1] = key
return arr
def main():
arr = [6, 5, 8, 9, 3, 1, 4, 7, 2]
sorted_arr = insertion_sort(arr)
... |
"""
This module contains all the submodules for the handybeam software package.
"""
name = "handybeam"
__all__ = [
'bugcatcher',
'cl_system',
'evaluators',
'misc',
'solver',
'translator',
'tx_array',
'tx_array_library',
'visiualize',
'world',
'cl',
'cl_py_ref_code',
... | """
This module contains all the submodules for the handybeam software package.
"""
name = 'handybeam'
__all__ = ['bugcatcher', 'cl_system', 'evaluators', 'misc', 'solver', 'translator', 'tx_array', 'tx_array_library', 'visiualize', 'world', 'cl', 'cl_py_ref_code', 'opencl_wrappers', 'propagator_mixins', 'samplers', ... |
#
# PySNMP MIB module DNS-SERVER-MIB (http://pysnmp.sf.net)
# ASN.1 source http://mibs.snmplabs.com:80/asn1/DNS-SERVER-MIB
# Produced by pysmi-0.0.7 at Sun Feb 14 00:08:40 2016
# On host bldfarm platform Linux version 4.1.13-100.fc21.x86_64 by user goose
# Using Python version 3.5.0 (default, Jan 5 2016, 17:11:52)
#
... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, value_size_constraint, single_value_constraint, constraints_union, constraints_intersection) ... |
# _*_ coding: utf-8 _*_
"""
inst_save.py by xianhu
"""
class Saver(object):
"""
class of Saver, must include function working()
"""
def working(self, priority: int, url: str, keys: dict, deep: int, item: object) -> (int, object):
"""
working function, must "try-except" and don't chan... | """
inst_save.py by xianhu
"""
class Saver(object):
"""
class of Saver, must include function working()
"""
def working(self, priority: int, url: str, keys: dict, deep: int, item: object) -> (int, object):
"""
working function, must "try-except" and don't change the parameters and retu... |
"""
Get content from tag.
>>> from GDLC.GDLC import *
>>> dml = '''\
... <idx:entry scriptable="yes">
... <idx:orth value="ABC">
... <idx:infl>
... <idx:iform name="" value="ABC"/>
... </idx:infl>
... </idx:orth>
... <div>
... <span>
... <b>ABC</b>
... </span>
... </div>... | """
Get content from tag.
>>> from GDLC.GDLC import *
>>> dml = '''... <idx:entry scriptable="yes">
... <idx:orth value="ABC">
... <idx:infl>
... <idx:iform name="" value="ABC"/>
... </idx:infl>
... </idx:orth>
... <div>
... <span>
... <b>ABC</b>
... </span>
... </div>
.... |
#MAIN PROGRAM STARTS HERE:
num = int(input('Enter the number of rows and columns for the square: '))
k = 1
for x in range(0, num ):
for y in range(0, num):
print ('%d ' % (k), end='')
k += 2
print() | num = int(input('Enter the number of rows and columns for the square: '))
k = 1
for x in range(0, num):
for y in range(0, num):
print('%d ' % k, end='')
k += 2
print() |
class Point(object):
def __init__(self, x, y):
self.x, self.y = x, y
class PointHash(object):
def __init__(self, x, y):
self.x, self.y = x, y
def __hash__(self):
return hash((self.x, self.y))
def __eq__(self, other):
return self.x == other.x and self.y == other.y
if... | class Point(object):
def __init__(self, x, y):
(self.x, self.y) = (x, y)
class Pointhash(object):
def __init__(self, x, y):
(self.x, self.y) = (x, y)
def __hash__(self):
return hash((self.x, self.y))
def __eq__(self, other):
return self.x == other.x and self.y == oth... |
"""
This is pure python implementation of interpolation search algorithm
"""
"""Pure implementation of interpolation search algorithm in Python
Be careful collection must be ascending sorted, otherwise result will be
unpredictable
"""
def interpolation_search(sorted_collection, item):
left = 0
right = len(sor... | """
This is pure python implementation of interpolation search algorithm
"""
'Pure implementation of interpolation search algorithm in Python\nBe careful collection must be ascending sorted, otherwise result will be\nunpredictable\n'
def interpolation_search(sorted_collection, item):
left = 0
right = len(sorte... |
# -*- coding: utf-8 -*-
# 18/1/30
# create by: snower
version = "0.1.1"
version_info = (0,1.1) | version = '0.1.1'
version_info = (0, 1.1) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.