content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# # CLASS MEHTODS
# class Employee:
# company ="camel"
# salary = 100
# location = "mumbai"
# def ChangeSalary(self, sal):
# self.__class__.salary = sal
# # THE EASY METHOD FOR THE ABOVE STATEMENT AND FOR THE CLASS ATTRIBUTE IS
# @classmethod
# def ChangeSalary(cls, sal):
# ... | class Employee:
company = 'Bharat Gas'
salary = 4500
salary_bonus = 500
@property
def total_salary(self):
return self.salary + self.salaryBonus
@totalSalary.setter
def total_salary(self, val):
self.salaryBonus = val - self.salary
e = employee()
print(e.totalSalary)
e.totalS... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def bubble_sort(arr):
for n in range(len(arr)-1, 0, -1):
for k in range(n):
if r[k] > r[k+1]:
tmp = r[k]
r[k] = r[k+1]
r[k+1] = tmp
if __name__ == '__main__':
r = [5, 4, 2, 3, 1]
bubble_sor... | def bubble_sort(arr):
for n in range(len(arr) - 1, 0, -1):
for k in range(n):
if r[k] > r[k + 1]:
tmp = r[k]
r[k] = r[k + 1]
r[k + 1] = tmp
if __name__ == '__main__':
r = [5, 4, 2, 3, 1]
bubble_sort(r)
print(r) |
# Let's say you have a dictionary matchinhg your friends' names
# with their favorite flowers:
fav_flowers = {'Alex': 'field flowers', 'Kate': 'daffodil',
'Eva': 'artichoke flower', 'Daniel': 'tulip'}
# Your new friend Alice likes orchid the most: add this info to the
# fav_flowers dict and print the di... | fav_flowers = {'Alex': 'field flowers', 'Kate': 'daffodil', 'Eva': 'artichoke flower', 'Daniel': 'tulip'}
fav_flowers['Alice'] = 'orchid'
print(fav_flowers) |
num1 = float(input("Enter 1st number: "))
op = input("Enter operator: ")
num2 = float(input("Enter 2nd number: "))
if op == "+":
val = num1 + num2
elif op == "-":
val = num1 - num2
elif op == "*" or op == "x":
val = num1 * num2
elif op == "/":
val = num1 / num2
print(val)
| num1 = float(input('Enter 1st number: '))
op = input('Enter operator: ')
num2 = float(input('Enter 2nd number: '))
if op == '+':
val = num1 + num2
elif op == '-':
val = num1 - num2
elif op == '*' or op == 'x':
val = num1 * num2
elif op == '/':
val = num1 / num2
print(val) |
def count_substring(string, sub_string):
times = 0
length = len(sub_string)
for letter in range(0, len(string)):
if string[letter:letter+length] == sub_string:
times += 1
return times
| def count_substring(string, sub_string):
times = 0
length = len(sub_string)
for letter in range(0, len(string)):
if string[letter:letter + length] == sub_string:
times += 1
return times |
#!/usr/bin/pthon3
# Time complexity: O(N)
def solution(A):
count = {}
size_A = len(A)
leader = None
for i, a in enumerate(A):
count[a] = count.get(a, 0) + 1
if count[a] > size_A // 2:
leader = a
equi_leader = 0
before = 0
for i in range(size_A)... | def solution(A):
count = {}
size_a = len(A)
leader = None
for (i, a) in enumerate(A):
count[a] = count.get(a, 0) + 1
if count[a] > size_A // 2:
leader = a
equi_leader = 0
before = 0
for i in range(size_A):
if A[i] == leader:
before += 1
... |
n1 = int(input('digite um valor >>'))
n2 = int(input('digite outro vaor >>'))
n3 = int(input('digite outro valor >>'))
#menor
menor = n1
if n2 < n1 and n2 < n3:
menor = n2
if n3 < n1 and n3 < n2:
menor = n3
#maior
maior = n1
if n2 > n1 and n2 > n3:
maior = n2
if n3 > n1 and n3 > n2:
maior = n3
print('o ... | n1 = int(input('digite um valor >>'))
n2 = int(input('digite outro vaor >>'))
n3 = int(input('digite outro valor >>'))
menor = n1
if n2 < n1 and n2 < n3:
menor = n2
if n3 < n1 and n3 < n2:
menor = n3
maior = n1
if n2 > n1 and n2 > n3:
maior = n2
if n3 > n1 and n3 > n2:
maior = n3
print('o maior numero e... |
class TypeFactory(object):
def __init__(self, client):
self.client = client
def create(self, transport_type, *args, **kwargs):
klass = self.classes[transport_type]
cls = klass(*args, **kwargs)
cls._client = self.client
return cls
| class Typefactory(object):
def __init__(self, client):
self.client = client
def create(self, transport_type, *args, **kwargs):
klass = self.classes[transport_type]
cls = klass(*args, **kwargs)
cls._client = self.client
return cls |
length = float(input("Enter the length of a side of the cube: "))
total_surface_area = 6 * length ** 2
volume = 3 * length ** 2
print("The surface area of the cube is", total_surface_area)
print("The volume of the cube is", volume)
close = input("Press X to exit")
# The above code keeps the program op... | length = float(input('Enter the length of a side of the cube: '))
total_surface_area = 6 * length ** 2
volume = 3 * length ** 2
print('The surface area of the cube is', total_surface_area)
print('The volume of the cube is', volume)
close = input('Press X to exit') |
def generate():
class Spam:
count = 1
def method(self):
print(count)
return Spam()
generate().method()
| def generate():
class Spam:
count = 1
def method(self):
print(count)
return spam()
generate().method() |
# Title : Generators in python
# Author : Kiran raj R.
# Date : 31:10:2020
def printNum():
num = 0
while True:
yield num
num += 1
result = printNum()
print(next(result))
print(next(result))
print(next(result))
result = (num for num in range(10000))
print(result)
print(next(result))
print(... | def print_num():
num = 0
while True:
yield num
num += 1
result = print_num()
print(next(result))
print(next(result))
print(next(result))
result = (num for num in range(10000))
print(result)
print(next(result))
print(next(result))
print(next(result)) |
def funcion(nums,n):
print(nums)
res = []
for i in range(len(nums)):
suma = 0
aux = []
suma += nums[i]
for j in range(i+1,len(nums)):
print(i,j)
if suma + nums[j] == n:
aux.append(nums[i])
aux.append(nums[j])
... | def funcion(nums, n):
print(nums)
res = []
for i in range(len(nums)):
suma = 0
aux = []
suma += nums[i]
for j in range(i + 1, len(nums)):
print(i, j)
if suma + nums[j] == n:
aux.append(nums[i])
aux.append(nums[j])
... |
class TestHLD:
# edges = [
# (0, 1),
# (0, 6),
# (0, 10),
# (1, 2),
# (1, 5),
# (2, 3),
# (2, 4),
# (6, 7),
# (7, 8),
# (7, 9),
# (10, 11),
# ]
# root = 0
# get_lca = lca_hld(edges, root)
# print(get_lca(3, 5))... | class Testhld:
... |
#
# PySNMP MIB module OVERLAND-NEXTGEN (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/OVERLAND-NEXTGEN
# Produced by pysmi-0.3.4 at Wed May 1 14:35:46 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar ... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_union, value_range_constraint, value_size_constraint, constraints_intersection) ... |
class Solution:
def diStringMatch(self, S: str):
l = 0
r = len(S)
ret = []
for i in S:
if i == "I":
ret.append(l)
l += 1
else:
ret.append(r)
r -= 1
ret.append(r)
return ret
slu =... | class Solution:
def di_string_match(self, S: str):
l = 0
r = len(S)
ret = []
for i in S:
if i == 'I':
ret.append(l)
l += 1
else:
ret.append(r)
r -= 1
ret.append(r)
return ret
slu ... |
#CONSIDER: composable authorizations
class Authorization(object):
'''
Base authorization class, defaults to full authorization
'''
#CONSIDER: how is this notified about filtering, ids, etc
def __init__(self, identity, endpoint):
self.identity = identity
self.endpoint = endpoint
... | class Authorization(object):
"""
Base authorization class, defaults to full authorization
"""
def __init__(self, identity, endpoint):
self.identity = identity
self.endpoint = endpoint
def process_queryset(self, queryset):
return queryset
def is_authorized(self):
... |
# Len of signature in write signed packet
SIGNATURE_LEN = 12
# Attribute Protocol Opcodes
OP_ERROR = 0x01
OP_MTU_REQ = 0x02
OP_MTU_RESP = 0x03
OP_FIND_INFO_REQ = 0x04
OP_FIND_INFO_RESP = 0x05
OP_FIND_BY_TYPE_REQ = 0x06
OP_FIND_BY_TYPE_RESP= 0x07
OP_READ_BY_TYPE_REQ = 0x08
OP_READ_BY_TYPE_RESP = 0x09
OP_READ_REQ = 0x0... | signature_len = 12
op_error = 1
op_mtu_req = 2
op_mtu_resp = 3
op_find_info_req = 4
op_find_info_resp = 5
op_find_by_type_req = 6
op_find_by_type_resp = 7
op_read_by_type_req = 8
op_read_by_type_resp = 9
op_read_req = 10
op_read_resp = 11
op_read_blob_req = 12
op_read_blob_resp = 13
op_read_multi_req = 14
op_read_multi... |
'''
Description:
------------
When objects are instantiated, the object itself
is passed into the self parameter. The Object is
passed into the self parameter so that the object
can keep hold of its own data.
'''
print(__doc__)
print('-'*25)
class State(object):
def __init__(self):
global x... | """
Description:
------------
When objects are instantiated, the object itself
is passed into the self parameter. The Object is
passed into the self parameter so that the object
can keep hold of its own data.
"""
print(__doc__)
print('-' * 25)
class State(object):
def __init__(self):
global x
... |
#
# @lc app=leetcode id=611 lang=python3
#
# [611] Valid Triangle Number
#
# https://leetcode.com/problems/valid-triangle-number/description/
#
# algorithms
# Medium (49.73%)
# Likes: 1857
# Dislikes: 129
# Total Accepted: 109.5K
# Total Submissions: 222.7K
# Testcase Example: '[2,2,3,4]'
#
# Given an integer ar... | class Solution:
def triangle_number(self, nums: List[int]) -> int:
if not nums or len(nums) <= 2:
return 0
nums.sort()
count = 0
for i in range(len(nums) - 1, 1, -1):
delta = self.two_sum_greater(nums, 0, i - 1, nums[i])
count += delta
ret... |
# Computers are fast, so we can implement a brute-force search to directly solve the problem.
def compute():
PERIMETER = 1000
for a in range(1, PERIMETER + 1):
for b in range(a + 1, PERIMETER + 1):
c = PERIMETER - a - b
if a * a + b * b == c * c:
# It is now implied that b < c, because we have a > 0
r... | def compute():
perimeter = 1000
for a in range(1, PERIMETER + 1):
for b in range(a + 1, PERIMETER + 1):
c = PERIMETER - a - b
if a * a + b * b == c * c:
return str(a * b * c)
if __name__ == '__main__':
print(compute()) |
{
"targets": [
{
"target_name": "yolo",
"sources": [ "src/yolo.cc" ]
}
]
}
| {'targets': [{'target_name': 'yolo', 'sources': ['src/yolo.cc']}]} |
class Docs(object):
def __init__(self, conn):
self.client = conn.client
def size(self):
r = self.client.get('/docs/size')
return int(r.text)
def add(self, name, content):
self.client.post('/docs', files={'upload': (name, content)})
def clear(self):
self.client.... | class Docs(object):
def __init__(self, conn):
self.client = conn.client
def size(self):
r = self.client.get('/docs/size')
return int(r.text)
def add(self, name, content):
self.client.post('/docs', files={'upload': (name, content)})
def clear(self):
self.client... |
#!/bin/env python3
option = input("[E]ncryption, [D]ecryption, or [Q]uit -- ")
def key_generation(a, b, a1, b1):
M = a * b - 1
e = a1 * M + a
d = b1 * M + b
n = (e * d - 1) / M
return int(e), int(d), int(n)
def encryption(a, b, a1, b1):
e, d, n = key_generation(a, b, a1, b1)
print("You ma... | option = input('[E]ncryption, [D]ecryption, or [Q]uit -- ')
def key_generation(a, b, a1, b1):
m = a * b - 1
e = a1 * M + a
d = b1 * M + b
n = (e * d - 1) / M
return (int(e), int(d), int(n))
def encryption(a, b, a1, b1):
(e, d, n) = key_generation(a, b, a1, b1)
print('You may publish your p... |
#!/usr/bin/env python
# coding: utf-8
# # Seldon Kafka Integration Example with CIFAR10 Model
#
# In this example we will run SeldonDeployments for a CIFAR10 Tensorflow model which take their inputs from a Kafka topic and push their outputs to a Kafka topic. We will experiment with both REST and gRPC Seldon graphs. F... | get_ipython().system('pip install -r requirements.txt')
get_ipython().system('helm repo add strimzi https://strimzi.io/charts/')
get_ipython().system('helm install my-release strimzi/strimzi-kafka-operator')
cluster_type = 'kind'
if clusterType == 'kind':
get_ipython().system('kubectl apply -f cluster-kind.yaml')
e... |
# Creates the file nonsilence_phones.txt which contains
# all the phonemes except sil.
source = open("slp_lab2_data/lexicon.txt", 'r')
phones = []
# Get all the separate phonemes from lexicon.txt.
for line in source:
line_phones = line.split(' ')[1:]
for phone in line_phones:
phone = phone.strip(' ')
... | source = open('slp_lab2_data/lexicon.txt', 'r')
phones = []
for line in source:
line_phones = line.split(' ')[1:]
for phone in line_phones:
phone = phone.strip(' ')
phone = phone.strip('\n')
if phone not in phones and phone != 'sil':
phones.append(phone)
source.close()
phones... |
class Computer():
def __init__(self, model, memory):
self.mo = model
self.me = memory
c = Computer('Dell', '500gb')
print(c.mo,c.me) | class Computer:
def __init__(self, model, memory):
self.mo = model
self.me = memory
c = computer('Dell', '500gb')
print(c.mo, c.me) |
#!/usr/bin/env python
files = [ "dpx_nuke_10bits_rgb.dpx", "dpx_nuke_16bits_rgba.dpx" ]
for f in files:
command += rw_command (OIIO_TESTSUITE_IMAGEDIR, f)
# Additionally, test for regressions for endian issues with 16 bit DPX output
# (related to issue #354)
command += oiio_app("oiiotool") + " src/input_rgb_matt... | files = ['dpx_nuke_10bits_rgb.dpx', 'dpx_nuke_16bits_rgba.dpx']
for f in files:
command += rw_command(OIIO_TESTSUITE_IMAGEDIR, f)
command += oiio_app('oiiotool') + ' src/input_rgb_mattes.tif -o output_rgb_mattes.dpx >> out.txt;'
command += oiio_app('idiff') + ' src/input_rgb_mattes.tif output_rgb_mattes.dpx >> out.... |
# https://leetcode.com/problems/remove-nth-node-from-end-of-list/
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
# @param {ListNode} head
# @param {integer} n
# @return {ListNode}
def removeNthFromEn... | class Solution:
def remove_nth_from_end(self, head, n):
def remove_nth_from_end_rec(head, n):
if not head:
return 0
my_pos = remove_nth_from_end_rec(head.next, n) + 1
if my_pos - 1 == n:
head.next = head.next.next
return my_po... |
def get_url():
return None
result = get_url().text
print(result)
| def get_url():
return None
result = get_url().text
print(result) |
myStr = input("Enter a String: ")
count = 0
for letter in myStr:
count += 1
print (count)
| my_str = input('Enter a String: ')
count = 0
for letter in myStr:
count += 1
print(count) |
a = 1
b = 2
c = 3
def foo():
a = 1
b = 2
c = 3
foo()
print('TEST SUCEEDED')
| a = 1
b = 2
c = 3
def foo():
a = 1
b = 2
c = 3
foo()
print('TEST SUCEEDED') |
train = [[1,2],[2,3],[1,1],[2,2],[3,3],[4,2],[2,5],[5,5],[4,1],[4,4]]
weights = [1,1,1]
def perceptron_predict(inputs, weights):
activation = weights[0]
for i in range(len(inputs)-1):
activation += weights[i+1] * inputs[i]
return 1.0 if activation >= 0.0 else 0.0
for inputs in train:
print(p... | train = [[1, 2], [2, 3], [1, 1], [2, 2], [3, 3], [4, 2], [2, 5], [5, 5], [4, 1], [4, 4]]
weights = [1, 1, 1]
def perceptron_predict(inputs, weights):
activation = weights[0]
for i in range(len(inputs) - 1):
activation += weights[i + 1] * inputs[i]
return 1.0 if activation >= 0.0 else 0.0
for in... |
def msg_retry(self, buf):
print("retry")
return buf[1:]
MESSAGES = {1: msg_retry}
| def msg_retry(self, buf):
print('retry')
return buf[1:]
messages = {1: msg_retry} |
print("WELCOME!\nTHIS IS A NUMBER GUESSING QUIZ ")
num = 30
num_of_guesses = 1
guess = input("ARE YOU A KID?\n")
while(guess != num):
guess = int(input("ENTER THE NUMBER TO GUESS\n"))
if guess > num:
print("NOT CORRECT")
print("LOWER NUMBER PLEASE!")
num_of_guesses += 1
elif guess... | print('WELCOME!\nTHIS IS A NUMBER GUESSING QUIZ ')
num = 30
num_of_guesses = 1
guess = input('ARE YOU A KID?\n')
while guess != num:
guess = int(input('ENTER THE NUMBER TO GUESS\n'))
if guess > num:
print('NOT CORRECT')
print('LOWER NUMBER PLEASE!')
num_of_guesses += 1
elif guess < n... |
MAX_FOOD_ON_BOARD = 25 # Max food on board
EAT_RATIO = 0.50 # Ammount of snake length absorbed
FOOD_SPAWN_RATE = 3 # Number of turns per food spawn
HUNGER_THRESHOLD = 100 # Turns of inactivity before snake starvation
SNAKE_STARTING_LENGTH = 3 # Snake starting size
TURNS_PER_GOLD = 20 # Turns between the spawn of ... | max_food_on_board = 25
eat_ratio = 0.5
food_spawn_rate = 3
hunger_threshold = 100
snake_starting_length = 3
turns_per_gold = 20
gold_victory = 5
turns_per_wall = 5
wall_start_turn = 50
health_decay_rate = 1
food_value = 30 |
# https://codeforces.com/problemset/problem/1399/A
t = int(input())
for _ in range(t):
length_a = int(input())
list_a = [int(x) for x in input().split()]
list_a.sort()
while True:
if len(list_a) == 1:
print('YES')
break
elif abs(list_a[0] - list_a[1]) <= 1:
... | t = int(input())
for _ in range(t):
length_a = int(input())
list_a = [int(x) for x in input().split()]
list_a.sort()
while True:
if len(list_a) == 1:
print('YES')
break
elif abs(list_a[0] - list_a[1]) <= 1:
list_a.pop(0)
else:
print... |
sentence = input().split()
latin = ""
for word in sentence:
latin += word[1:] + word[0]+"ay "
print(latin,end="")
| sentence = input().split()
latin = ''
for word in sentence:
latin += word[1:] + word[0] + 'ay '
print(latin, end='') |
modulename = "Help"
creator = "YtnomSnrub"
sd_structure = {}
| modulename = 'Help'
creator = 'YtnomSnrub'
sd_structure = {} |
class DeBracketifyMiddleware(object):
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
cleaned = request.GET.copy()
for key in cleaned:
if key.endswith('[]'):
val = cleaned.pop(key)
cleaned_key = ... | class Debracketifymiddleware(object):
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
cleaned = request.GET.copy()
for key in cleaned:
if key.endswith('[]'):
val = cleaned.pop(key)
cleaned_key =... |
def trace_wire(wire_dirs):
last_pos = [0, 0]
grid_dict = {}
length = 0
for direction in wire_dirs:
way = direction[0]
amount = int(direction[1:])
if way == 'R':
for x in range(1,amount+1):
grid_pos = '{}_{}'.format(last_pos[0]+x, last_pos[1])
... | def trace_wire(wire_dirs):
last_pos = [0, 0]
grid_dict = {}
length = 0
for direction in wire_dirs:
way = direction[0]
amount = int(direction[1:])
if way == 'R':
for x in range(1, amount + 1):
grid_pos = '{}_{}'.format(last_pos[0] + x, last_pos[1])
... |
#Linear Seach Algorithm
def linearSearch(data, number):
found = False
for index in range(0, len(data)):
if (data[index] == number):
found = True
break
if found:
print("Element is present in the array", index)
else:
print("Element is not present in the ar... | def linear_search(data, number):
found = False
for index in range(0, len(data)):
if data[index] == number:
found = True
break
if found:
print('Element is present in the array', index)
else:
print('Element is not present in the array.') |
i = 1 # valor inicial de I
j = aux = 7 # valor inicial de J
while i < 10: # equanto for menor que 10:
for x in range(3): # loop: mostra as linhas consecutivas
print('I={} J={}' .forma... | i = 1
j = aux = 7
while i < 10:
for x in range(3):
print('I={} J={}'.format(i, j))
j -= 1
i += 2
aux += 2
j = aux |
IOSXE_TEST = {
"host": "172.18.0.11",
"username": "vrnetlab",
"password": "VR-netlab9",
"device_type": "cisco_xe",
"test_commands": ["show run", "show version"],
}
NXOS_TEST = {
"host": "172.18.0.12",
"username": "vrnetlab",
"password": "VR-netlab9",
"device_type": "cisco_nxos",
... | iosxe_test = {'host': '172.18.0.11', 'username': 'vrnetlab', 'password': 'VR-netlab9', 'device_type': 'cisco_xe', 'test_commands': ['show run', 'show version']}
nxos_test = {'host': '172.18.0.12', 'username': 'vrnetlab', 'password': 'VR-netlab9', 'device_type': 'cisco_nxos', 'test_commands': ['show run', 'show version'... |
def rotate_left(list_f, step):
for _ in range(step):
list_f.append(list_f.pop(0))
list_s = list_f[:]
return list_s
| def rotate_left(list_f, step):
for _ in range(step):
list_f.append(list_f.pop(0))
list_s = list_f[:]
return list_s |
times = [{'writing_data': 6.627535581588745, 'ndvi_pc10': 27.36231303215027, 'loading_data': 109.62806057929993, 'ndvi_pc90': 21.421257734298706, 'ndvi_pc50': 27.33169937133789},
{'writing_data': 6.443411588668823, 'ndvi_pc10': 39.16243243217468, 'loading_data': 123.19368815422058, 'ndvi_pc90': 38.72961163520813, 'ndvi... | times = [{'writing_data': 6.627535581588745, 'ndvi_pc10': 27.36231303215027, 'loading_data': 109.62806057929993, 'ndvi_pc90': 21.421257734298706, 'ndvi_pc50': 27.33169937133789}, {'writing_data': 6.443411588668823, 'ndvi_pc10': 39.16243243217468, 'loading_data': 123.19368815422058, 'ndvi_pc90': 38.72961163520813, 'ndvi... |
fname = input("Enter file name: ")
fh = open(fname)
total = 0.0
count = 0.0
for line in fh:
if line.startswith("X-DSPAM-Confidence:"):
total += float(line[line.find(":") + 1:])
count += 1
lf = total/count
else:
continue
print('Average spam confidence: ',"{0:.12f}".format(round(l... | fname = input('Enter file name: ')
fh = open(fname)
total = 0.0
count = 0.0
for line in fh:
if line.startswith('X-DSPAM-Confidence:'):
total += float(line[line.find(':') + 1:])
count += 1
lf = total / count
else:
continue
print('Average spam confidence: ', '{0:.12f}'.format(round... |
def selectmenuitem(window,object):
#log("{} :not implemented yet".format(sys._getframe().f_code.co_name))
object = object.split(";")
if len(object) == 2:
objectHandle = getobjecthandle(window,object[0])['handle']
mousemove(window,object[0],handle=objectHandle)
ldtp_extend_mouse_click... | def selectmenuitem(window, object):
object = object.split(';')
if len(object) == 2:
object_handle = getobjecthandle(window, object[0])['handle']
mousemove(window, object[0], handle=objectHandle)
ldtp_extend_mouse_click_here()
time.sleep(1)
object_handle = getobjecthandle(... |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
def kAltReverse(head, k) :
current = head
next = None
prev = None
count = 0
#1) reverse first k nodes of the linked list
while (current != None ... | def k_alt_reverse(head, k):
current = head
next = None
prev = None
count = 0
while current != None and count < k:
next = current.next
current.next = prev
prev = current
current = next
count = count + 1
if head != None:
head.next = current
count... |
_base_ = "./FlowNet512_1.5AugCosyAAEGray_AggressiveV2_Flat_Pbr_01_ape.py"
OUTPUT_DIR = "output/deepim/lmPbrSO/FlowNet512_1.5AugCosyAAEGray_AggressiveV2_Flat_lmPbr_SO/cat"
DATASETS = dict(TRAIN=("lm_pbr_cat_train",), TEST=("lm_real_cat_test",))
# bbnc5
# objects cat Avg(1)
# ad_2 19.26 19.26
# ad_5 62.48... | _base_ = './FlowNet512_1.5AugCosyAAEGray_AggressiveV2_Flat_Pbr_01_ape.py'
output_dir = 'output/deepim/lmPbrSO/FlowNet512_1.5AugCosyAAEGray_AggressiveV2_Flat_lmPbr_SO/cat'
datasets = dict(TRAIN=('lm_pbr_cat_train',), TEST=('lm_real_cat_test',)) |
def main():
with open('input.txt') as f:
inputs = [line.split() for line in f.readlines()]
pos = (0, 0) # horiz, depth
for cmd, amount in inputs:
amount = int(amount)
match cmd:
case 'forward':
pos = (pos[0] + amount, pos[1])
case 'down':
... | def main():
with open('input.txt') as f:
inputs = [line.split() for line in f.readlines()]
pos = (0, 0)
for (cmd, amount) in inputs:
amount = int(amount)
match cmd:
case 'forward':
pos = (pos[0] + amount, pos[1])
case 'down':
po... |
# Python Lists
# @IdiotInside_
print ("Creating List:")
colors = ['red', 'blue', 'green']
print (colors[0]) ## red
print (colors[1]) ## blue
print (colors[2]) ## green
print (len(colors)) ## 3
print ("Append to the List")
colors.append("orange")
print (colors[3]) ##orange
print ("Insert to the List")
colors.... | print('Creating List:')
colors = ['red', 'blue', 'green']
print(colors[0])
print(colors[1])
print(colors[2])
print(len(colors))
print('Append to the List')
colors.append('orange')
print(colors[3])
print('Insert to the List')
colors.insert(3, 'yellow')
print(colors[3])
print(colors[4])
print('Remove from the List')
prin... |
class Solution:
def find_averages(self, k, arr):
result = []
window_sum = 0
window_start = 0
for window_end in range(len(arr)):
window_sum += arr[window_end]
if window_end >= k - 1:
result.append(window_sum / k)
window_sum -= ar... | class Solution:
def find_averages(self, k, arr):
result = []
window_sum = 0
window_start = 0
for window_end in range(len(arr)):
window_sum += arr[window_end]
if window_end >= k - 1:
result.append(window_sum / k)
window_sum -= a... |
# calculting factorial using recursion
def Fact(n):
return (n * Fact(n-1) if (n > 1) else 1.0)
#main
num = int(input("n = "))
print(Fact(num)) | def fact(n):
return n * fact(n - 1) if n > 1 else 1.0
num = int(input('n = '))
print(fact(num)) |
# https://www.hackerrank.com/challenges/ctci-lonely-integer
def lonely_integer(a):
bitArray = 0b0
for ele in a:
bitArray = bitArray ^ ele
# print(ele, bin(bitArray))
return int(bitArray) | def lonely_integer(a):
bit_array = 0
for ele in a:
bit_array = bitArray ^ ele
return int(bitArray) |
andmed = []
nimekiri = open("nimekiri.txt", encoding="UTF-8")
for rida in nimekiri:
f = open(rida.strip() + ".txt", encoding="UTF-8")
kirje = {}
for attr in f:
osad = attr.strip().split(": ")
kirje[osad[0]] = osad[1]
f.close()
andmed.append(kirje)
nimekiri.close()
uus... | andmed = []
nimekiri = open('nimekiri.txt', encoding='UTF-8')
for rida in nimekiri:
f = open(rida.strip() + '.txt', encoding='UTF-8')
kirje = {}
for attr in f:
osad = attr.strip().split(': ')
kirje[osad[0]] = osad[1]
f.close()
andmed.append(kirje)
nimekiri.close()
uus_failinimi = inp... |
# window's attributes
TITLE = 'Arkanoid.py'
WIDTH = 640
HEIGHT = 400
ICON = 'images/ball.png'
| title = 'Arkanoid.py'
width = 640
height = 400
icon = 'images/ball.png' |
elemDictInv = {
100:'TrivialElement',
101:'PolyElement',
102:'NullElement',
110:'DirichletNode',
111:'DirichletNodeLag',
112:'zeroVariable',
120:'NodalForce',
121:'NodalForceLine',
130:'setMaterialParam',
131:'setDamageParam',
132:'IncrementVariables',
133:'insertDeformation',
134:'insertDeformationGeneral',
140:'p... | elem_dict_inv = {100: 'TrivialElement', 101: 'PolyElement', 102: 'NullElement', 110: 'DirichletNode', 111: 'DirichletNodeLag', 112: 'zeroVariable', 120: 'NodalForce', 121: 'NodalForceLine', 130: 'setMaterialParam', 131: 'setDamageParam', 132: 'IncrementVariables', 133: 'insertDeformation', 134: 'insertDeformationGenera... |
tupla = ('python', 'estudar', 'linguagem', 'curso', 'viajar',
'cinema', 'pipoca', 'futuro', 'programador', 'mercado')
for c in tupla:
print(f'\nNa palavra {c} temos as vogais:', end=' ')
for vogais in c:
if vogais.lower() in 'aeiou':
print(vogais, end=' ')
| tupla = ('python', 'estudar', 'linguagem', 'curso', 'viajar', 'cinema', 'pipoca', 'futuro', 'programador', 'mercado')
for c in tupla:
print(f'\nNa palavra {c} temos as vogais:', end=' ')
for vogais in c:
if vogais.lower() in 'aeiou':
print(vogais, end=' ') |
# Funcion de evaluacion de calidad de codigo. Devuelve un entero con un numero que representa la calidad. Cuanto mas cercano a 0 esten los valores, mayor sera la calidad.
def evaluateCode(listOfRefactors):
# Good code -> Close to 0
# Bad code -> Far from 0
codeQuality = 0
for refactor in listOfRe... | def evaluate_code(listOfRefactors):
code_quality = 0
for refactor in listOfRefactors:
code_quality = refactor['nPriority'] + codeQuality
return codeQuality |
DIRECTIONS = {
"U": (0, 1),
"D": (0, -1),
"L": (-1, 0),
"R": (1, 0)
}
def wire_to_point_set(wire):
s = set()
d = dict()
x, y, steps = 0, 0, 0
for w in wire:
dx, dy = DIRECTIONS[w[0]]
dist = int(w[1:])
for _ in range(dist):
x += dx
y += d... | directions = {'U': (0, 1), 'D': (0, -1), 'L': (-1, 0), 'R': (1, 0)}
def wire_to_point_set(wire):
s = set()
d = dict()
(x, y, steps) = (0, 0, 0)
for w in wire:
(dx, dy) = DIRECTIONS[w[0]]
dist = int(w[1:])
for _ in range(dist):
x += dx
y += dy
... |
def main():
print("Welcome To play Ground")
# Invocation
if __name__ == "__main__":
main()
myInt = 5
myFloat = 13.2
myString = "Hello"
myBool = True
myList = [0, 1, "Two", 3.4, 78, 89, 45, 67]
myTuple = (0, 1, 2)
myDict = {"one": 1, "Two": 2}
# Random print Statements
print(myDict)
print(myTuple)
print(myIn... | def main():
print('Welcome To play Ground')
if __name__ == '__main__':
main()
my_int = 5
my_float = 13.2
my_string = 'Hello'
my_bool = True
my_list = [0, 1, 'Two', 3.4, 78, 89, 45, 67]
my_tuple = (0, 1, 2)
my_dict = {'one': 1, 'Two': 2}
print(myDict)
print(myTuple)
print(myInt)
print(myList)
print(myFloat)
prin... |
expected_output = {
"version": 3,
"interfaces": {
"GigabitEthernet1/0/9": {
"interface": "GigabitEthernet1/0/9",
"max_start": 3,
"pae": "supplicant",
"credentials": "switch4",
"supplicant": {"eap": {"profile": "EAP-METH"}},
"timeout... | expected_output = {'version': 3, 'interfaces': {'GigabitEthernet1/0/9': {'interface': 'GigabitEthernet1/0/9', 'max_start': 3, 'pae': 'supplicant', 'credentials': 'switch4', 'supplicant': {'eap': {'profile': 'EAP-METH'}}, 'timeout': {'held_period': 60, 'start_period': 30, 'auth_period': 30}}}, 'system_auth_control': Tru... |
def isintersect(a,b):
for i in a:
for j in b:
if i==j:
return True
return False
class RopChain(object):
def __init__(self):
self.chains = []
self.dump_str = None
self.payload = b""
self.base_addr = 0
self.next_call = None
s... | def isintersect(a, b):
for i in a:
for j in b:
if i == j:
return True
return False
class Ropchain(object):
def __init__(self):
self.chains = []
self.dump_str = None
self.payload = b''
self.base_addr = 0
self.next_call = None
... |
def triplets_with_sum(number):
triplets = []
for a in range(1, number // 3):
l = a + 1
r = (number - a - 1) // 2
while l <= r:
b = (l + r) // 2
c = number - a - b
if a * a + b * b < c * c:
l = b + 1
elif a * a + b * b > c... | def triplets_with_sum(number):
triplets = []
for a in range(1, number // 3):
l = a + 1
r = (number - a - 1) // 2
while l <= r:
b = (l + r) // 2
c = number - a - b
if a * a + b * b < c * c:
l = b + 1
elif a * a + b * b > c * ... |
class ChangeTextState:
def __init__(self):
self.prev_tail = ''
self.context = None
_change_text_state = None
def init():
global _change_text_state
_change_text_state = ChangeTextState()
init()
def get_state() -> ChangeTextState:
global _change_text_state
if _change_text_state... | class Changetextstate:
def __init__(self):
self.prev_tail = ''
self.context = None
_change_text_state = None
def init():
global _change_text_state
_change_text_state = change_text_state()
init()
def get_state() -> ChangeTextState:
global _change_text_state
if _change_text_state is... |
Size = (512, 748)
ScaleFactor = 0.33
ZoomLevel = 1.0
Orientation = -90
Mirror = True
NominalPixelSize = 0.002325
filename = ''
ImageWindow.Center = (680, 512)
ImageWindow.ViewportCenter = (1.1904, 1.5774772727272726)
ImageWindow.crosshair_color = (255, 0, 255)
ImageWindow.boxsize = (0.1, 0.06)
ImageWindow.box_color = (... | size = (512, 748)
scale_factor = 0.33
zoom_level = 1.0
orientation = -90
mirror = True
nominal_pixel_size = 0.002325
filename = ''
ImageWindow.Center = (680, 512)
ImageWindow.ViewportCenter = (1.1904, 1.5774772727272726)
ImageWindow.crosshair_color = (255, 0, 255)
ImageWindow.boxsize = (0.1, 0.06)
ImageWindow.box_color... |
#! /usr/bin/env python3
def analyse_pattern(ls) :
corresponds = {2:1,7:8,4:4,3:7}
dct = {corresponds[len(i)]:i for i in ls if len(i) in [2, 3, 4, 7]}
for i in range(10) :
s = len(ls[i])
if s == 6 : #0 6 9
if sum(ls[i][j] in dct[4] for j in range(s)) == 3 :
if sum... | def analyse_pattern(ls):
corresponds = {2: 1, 7: 8, 4: 4, 3: 7}
dct = {corresponds[len(i)]: i for i in ls if len(i) in [2, 3, 4, 7]}
for i in range(10):
s = len(ls[i])
if s == 6:
if sum((ls[i][j] in dct[4] for j in range(s))) == 3:
if sum((ls[i][j] in dct[1] for j... |
class Solution:
def buildTree(self, inorder: List[int], postorder: List[int]) -> TreeNode:
if not postorder:
return
root = TreeNode(postorder[-1])
rootpos = inorder.index(postorder[-1])
root.left = self.buildTree(inorder[:rootpos], postorder[:rootpos])
root.right ... | class Solution:
def build_tree(self, inorder: List[int], postorder: List[int]) -> TreeNode:
if not postorder:
return
root = tree_node(postorder[-1])
rootpos = inorder.index(postorder[-1])
root.left = self.buildTree(inorder[:rootpos], postorder[:rootpos])
root.rig... |
class Node:
def __init__(self, data=None, next=None):
self.__data = data
self.__next = next
@property
def data(self):
return self.__data
@data.setter
def data(self, data):
self.__data = data
@property
def next(self):
return self.__next
@next.se... | class Node:
def __init__(self, data=None, next=None):
self.__data = data
self.__next = next
@property
def data(self):
return self.__data
@data.setter
def data(self, data):
self.__data = data
@property
def next(self):
return self.__next
@next.s... |
def y():
raise TypeError
def x():
y()
try:
x()
except TypeError:
print("x")
| def y():
raise TypeError
def x():
y()
try:
x()
except TypeError:
print('x') |
# nominal reactor positions
data = dict([
('YJ1', [52.5]),
('YJ2', [52.5]),
('YJ3', [52.5]),
('YJ4', [52.5]),
('YJ5', [52.5]),
('YJ6', [52.5]),
('TS1', [52.5]),
('TS2', [52.5]),
('TS3', [52.5]),
('TS4', [52.5]),
('DYB', [215.0]),
('HZ', [265.0]),
])
| data = dict([('YJ1', [52.5]), ('YJ2', [52.5]), ('YJ3', [52.5]), ('YJ4', [52.5]), ('YJ5', [52.5]), ('YJ6', [52.5]), ('TS1', [52.5]), ('TS2', [52.5]), ('TS3', [52.5]), ('TS4', [52.5]), ('DYB', [215.0]), ('HZ', [265.0])]) |
class Summary:
def __init__(self, total_income, net_income, income_tax, employees_ni,
employers_ni):
self._total_income = total_income
self._net_income = net_income
self._income_tax = income_tax
self._employees_ni = employees_ni
self._employers_ni = employers... | class Summary:
def __init__(self, total_income, net_income, income_tax, employees_ni, employers_ni):
self._total_income = total_income
self._net_income = net_income
self._income_tax = income_tax
self._employees_ni = employees_ni
self._employers_ni = employers_ni
@proper... |
class Solution:
def reverseOnlyLetters(self, s: str) -> str:
def isChar(c):
return True if ord('z')>=ord(c)>=ord('a') or ord('Z')>=ord(c)>=ord('A') else False
right = len(s)-1
left = 0
charArray = [c for c in s]
while left<righ... | class Solution:
def reverse_only_letters(self, s: str) -> str:
def is_char(c):
return True if ord('z') >= ord(c) >= ord('a') or ord('Z') >= ord(c) >= ord('A') else False
right = len(s) - 1
left = 0
char_array = [c for c in s]
while left < right:
prin... |
def fp(i,n) :
i /= 100
return (1+i)**n
def pf(i,n) :
i /= 100
return 1/((1+i)**n)
def fa(i,n) :
i /= 100
return (((1+i)**n)-1)/i
def af(i,n) :
i /= 100
return i/(((1+i)**n)-1)
def pa(i,n) :
i /= 100
return (((1+i)**n)-1)/(i*((1+i)**n))
def ap(i,n) :
i /= 100
return (i*((1+i)**n))/(((1+i)**n... | def fp(i, n):
i /= 100
return (1 + i) ** n
def pf(i, n):
i /= 100
return 1 / (1 + i) ** n
def fa(i, n):
i /= 100
return ((1 + i) ** n - 1) / i
def af(i, n):
i /= 100
return i / ((1 + i) ** n - 1)
def pa(i, n):
i /= 100
return ((1 + i) ** n - 1) / (i * (1 + i) ** n)
def ap(i,... |
# Copyright (c) 2018 Turysaz <turysaz@posteo.org>
class IoCContainer():
def __init__(self):
self.__constructors = {} # {"service_key" : service_ctor}
self.__dependencies = {} # {"service_key" : ["dep_key_1", "dep_key_2", ..]} constructor parameters
self.__quantity = {} # {"service_... | class Ioccontainer:
def __init__(self):
self.__constructors = {}
self.__dependencies = {}
self.__quantity = {}
self.__singletons = {}
def register_on_demand(self, service_name_string, service, *dependencies):
self.__register_internal(service_name_string, service, 'multi... |
# def isIPv4Address(inputString):
# return len([num for num in inputString.split(".") if num != "" and 0 <= int(num) < 255]) == 4
# def isIPv4Address(inputString):
# return len([int(num) for num in inputString.split(".") if num != "" and not num.islower() and 0 <= int(num) <= 255]) == 4
# def isIPv4Addr... | def is_i_pv4_address(inputString):
if inputString.count('.') != 3:
return False
return len([int(num) for num in inputString.split('.') if num != '' and (not num.islower()) and (0 <= int(num) <= 255) and (len(num) == len(str(int(num))))]) == 4
print(is_i_pv4_address('0..1.0.0')) |
def validTime(time):
tokens = time.split(":")
hours, mins = tokens[0], tokens[1]
if int(hours) < 0 or int(hours) > 23:
return False
if int(mins) < 0 or int(mins) > 59:
return False
return True
| def valid_time(time):
tokens = time.split(':')
(hours, mins) = (tokens[0], tokens[1])
if int(hours) < 0 or int(hours) > 23:
return False
if int(mins) < 0 or int(mins) > 59:
return False
return True |
#
# PySNMP MIB module AT-IGMP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/AT-IGMP-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:30:12 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 0... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_size_constraint, value_range_constraint, constraints_union, single_value_constraint) ... |
#!/usr/bin/env python
#
# Copyright (c) 2018 10X Genomics, Inc. All rights reserved.
#
MULTI_REFS_PREFIX = 'multi'
# Constants for metasamples
GENE_EXPRESSION_LIBRARY_TYPE = 'Gene Expression'
VDJ_LIBRARY_TYPE = 'VDJ'
ATACSEQ_LIBRARY_TYPE = 'Peaks'
ATACSEQ_LIBRARY_DERIVED_TYPE = 'Motifs'
DEFAULT_LIBRARY_TYPE = GENE_EX... | multi_refs_prefix = 'multi'
gene_expression_library_type = 'Gene Expression'
vdj_library_type = 'VDJ'
atacseq_library_type = 'Peaks'
atacseq_library_derived_type = 'Motifs'
default_library_type = GENE_EXPRESSION_LIBRARY_TYPE |
def noOfwords(strs):
l = strs.split(' ')
return len(l)
string = input()
count = noOfwords(string)
print(count)
| def no_ofwords(strs):
l = strs.split(' ')
return len(l)
string = input()
count = no_ofwords(string)
print(count) |
def modular_exp(b, e, mod):
if e == 0:
return 1
res = modular_exp(b, e//2, mod)
res = (res * res ) % mod
if e%2 == 1:
res = (res * b) % mod
return res
| def modular_exp(b, e, mod):
if e == 0:
return 1
res = modular_exp(b, e // 2, mod)
res = res * res % mod
if e % 2 == 1:
res = res * b % mod
return res |
#!C:\Python27\python.exe
# EASY-INSTALL-SCRIPT: 'docutils==0.12','rst2odt_prepstyles.py'
__requires__ = 'docutils==0.12'
__import__('pkg_resources').run_script('docutils==0.12', 'rst2odt_prepstyles.py')
| __requires__ = 'docutils==0.12'
__import__('pkg_resources').run_script('docutils==0.12', 'rst2odt_prepstyles.py') |
#!/usr/bin/env python3
def raw_limit_ranges(callback_values):
data = {
'__meta': {
'chart': 'cisco-sso/raw',
'version': '0.1.0'
},
'resources': [{
'apiVersion': 'v1',
'kind': 'LimitRange',
'metadata': {
'name': 'l... | def raw_limit_ranges(callback_values):
data = {'__meta': {'chart': 'cisco-sso/raw', 'version': '0.1.0'}, 'resources': [{'apiVersion': 'v1', 'kind': 'LimitRange', 'metadata': {'name': 'limits'}, 'spec': {'limits': [{'default': {'cpu': '100m', 'memory': '256Mi'}, 'defaultRequest': {'cpu': '100m', 'memory': '256Mi'}, ... |
#definir variables y otros
print("Ejemplo 01-Area de un triangulo")
#Datos de entrada - Ingresados mediante dispositivos de entrada
b=int(input("Ingrese Base:"))
h=int(input("Ingrese altura"))
#proceso de calculo de Area
area=(b*h)/2
#Datos de salida
print("El area del triangulo es:", area) | print('Ejemplo 01-Area de un triangulo')
b = int(input('Ingrese Base:'))
h = int(input('Ingrese altura'))
area = b * h / 2
print('El area del triangulo es:', area) |
def handle_request(response):
if response.error:
print("Error:", response.error)
else:
print('called')
print(response.body)
| def handle_request(response):
if response.error:
print('Error:', response.error)
else:
print('called')
print(response.body) |
# CPP Program of Prim's algorithm for MST
inf = 65000
# To add an edge
def addEdge(adj, u, v, wt):
adj[u].append([v, wt])
adj[v].append([u, wt])
def primMST(adj, V):
# Create a priority queue to store vertices that
# are being preinMST.
pq = []
src = 0 # Taking vertex 0 as source
#... | inf = 65000
def add_edge(adj, u, v, wt):
adj[u].append([v, wt])
adj[v].append([u, wt])
def prim_mst(adj, V):
pq = []
src = 0
key = [inf for i in range(V)]
parent = [-1 for i in range(V)]
in_mst = [False for i in range(V)]
pq.append([0, src])
key[src] = 0
while len(pq) != 0:
... |
n,m,k = map(int,input().split())
d = list(map(int,input().split()))
m = list(map(int,input().split()))
ans = []
check = 10**18
for i in range(len(d)):
frog=d[i]
c=0
for j in range(len(m)):
if m[j]%frog==0:
c+=1
if c<check:
ans.clear()
ans.append(i+1)
check=c
... | (n, m, k) = map(int, input().split())
d = list(map(int, input().split()))
m = list(map(int, input().split()))
ans = []
check = 10 ** 18
for i in range(len(d)):
frog = d[i]
c = 0
for j in range(len(m)):
if m[j] % frog == 0:
c += 1
if c < check:
ans.clear()
ans.append(i... |
# Variables
age = 20 # declaring int variable
temperature = 89.8 # declaring float variable
name = 'John' # declaring str variable, Note: we use single quotes to store the text.
model = "SD902" # declaring str variable
print(model)
model = 8890 # n... | age = 20
temperature = 89.8
name = 'John'
model = 'SD902'
print(model)
model = 8890
print(model)
msg = str('Big Brother is in town')
msg = str('Case sensitive variable')
print(f'msg = {msg}')
print(f'Msg = {Msg}') |
# -*- coding: utf-8 -*-
'''
Copyright (c) 2014
@author: Marat Khayrullin <xmm.dev@gmail.com>
'''
API_VERSION_V0 = 0
API_VERSION = API_VERSION_V0
bp_name = 'api_v0'
api_v0_prefix = '{prefix}/v{version}'.format(
prefix='/api', # current_app.config['URL_PREFIX'],
version=API_VERSION_V0
)
| """
Copyright (c) 2014
@author: Marat Khayrullin <xmm.dev@gmail.com>
"""
api_version_v0 = 0
api_version = API_VERSION_V0
bp_name = 'api_v0'
api_v0_prefix = '{prefix}/v{version}'.format(prefix='/api', version=API_VERSION_V0) |
hex2bin = dict('{:x} {:04b}'.format(x,x).split() for x in range(16))
def float_dec2bin(n):
neg = False
if n < 0:
n = -n
neg = True
hx = float(n).hex()
p = hx.index('p')
bn = ''.join(hex2bin.get(char, char) for char in hx[2:p])
return (('1' if neg else '0') + bn.strip('0') + hx[p... | hex2bin = dict(('{:x} {:04b}'.format(x, x).split() for x in range(16)))
def float_dec2bin(n):
neg = False
if n < 0:
n = -n
neg = True
hx = float(n).hex()
p = hx.index('p')
bn = ''.join((hex2bin.get(char, char) for char in hx[2:p]))
return ('1' if neg else '0') + bn.strip('0') + ... |
# basicpackage/foo.py
a = 10
class Foo(object):
pass
print("inside 'basicpackage/foo.py' with a variable in it")
| a = 10
class Foo(object):
pass
print("inside 'basicpackage/foo.py' with a variable in it") |
famous_people = []
with open("/Users/coco/Documents/GitHub/python-side-projects/wikipedia-crawler/year1902-2020.txt",'r') as foo:
for line in foo.readlines():
if '``' in line:
famous_people.append(line)
with open("famous_people.txt", "a") as f:
for person in famous_people:
f.wr... | famous_people = []
with open('/Users/coco/Documents/GitHub/python-side-projects/wikipedia-crawler/year1902-2020.txt', 'r') as foo:
for line in foo.readlines():
if '``' in line:
famous_people.append(line)
with open('famous_people.txt', 'a') as f:
for person in famous_people:
f.write(p... |
class no_deps(object):
pass
class one_dep(object):
def __init__(self, dependency):
self.dependency = dependency
class two_deps(object):
def __init__(self, first_dep, second_dep):
self.first_dep = first_dep
self.second_dep = second_dep
| class No_Deps(object):
pass
class One_Dep(object):
def __init__(self, dependency):
self.dependency = dependency
class Two_Deps(object):
def __init__(self, first_dep, second_dep):
self.first_dep = first_dep
self.second_dep = second_dep |
#
# PySNMP MIB module HP-ICF-ARP-PROTECT (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HP-ICF-ARP-PROTECT
# Produced by pysmi-0.3.4 at Mon Apr 29 19:20:43 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, constraints_union, value_size_constraint) ... |
pkgname = "libuninameslist"
pkgver = "20211114"
pkgrel = 0
build_style = "gnu_configure"
hostmakedepends = ["pkgconf", "automake", "libtool"]
pkgdesc = "Library of Unicode names and annotation data"
maintainer = "q66 <q66@chimera-linux.org>"
license = "BSD-3-Clause"
url = "https://github.com/fontforge/libuninameslist"
... | pkgname = 'libuninameslist'
pkgver = '20211114'
pkgrel = 0
build_style = 'gnu_configure'
hostmakedepends = ['pkgconf', 'automake', 'libtool']
pkgdesc = 'Library of Unicode names and annotation data'
maintainer = 'q66 <q66@chimera-linux.org>'
license = 'BSD-3-Clause'
url = 'https://github.com/fontforge/libuninameslist'
... |
POSTGRESQL = 'PostgreSQL'
MYSQL = 'MySQL'
DEV = 'Development'
STAGE = 'Staging'
TEST = 'Testing'
PROD = 'Production' | postgresql = 'PostgreSQL'
mysql = 'MySQL'
dev = 'Development'
stage = 'Staging'
test = 'Testing'
prod = 'Production' |
# 10001st prime
# The nth prime number
def isPrime(n):
for i in range(2, int(math.sqrt(n))+1):
if n%i == 0:
return False
return True
def nthPrime(n):
num = 2
nums = []
while len(nums) < n:
if isPrime(num) == True:
nums.append(num)
num += 1
return nums[-1]
| def is_prime(n):
for i in range(2, int(math.sqrt(n)) + 1):
if n % i == 0:
return False
return True
def nth_prime(n):
num = 2
nums = []
while len(nums) < n:
if is_prime(num) == True:
nums.append(num)
num += 1
return nums[-1] |
class IntervalNum:
def __init__(self,a,b):
if a > b:
a,b = b,a
self.a = a
self.b = b
def __str__(self):
return f"[{self.a};{self.b}]"
def __add__(self,other):
return IntervalNum(self.a+other.a, self.b+other.b)
def __sub__(self,other):
re... | class Intervalnum:
def __init__(self, a, b):
if a > b:
(a, b) = (b, a)
self.a = a
self.b = b
def __str__(self):
return f'[{self.a};{self.b}]'
def __add__(self, other):
return interval_num(self.a + other.a, self.b + other.b)
def __sub__(self, other)... |
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'cv.sqlite', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOS... | databases = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'cv.sqlite', 'USER': '', 'PASSWORD': '', 'HOST': '', 'PORT': ''}}
middleware_classes = ('django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.auth.middleware.AuthenticationM... |
vehicles = {
'dream': 'Honda 250T',
'er5': 'Kawasaki ER5',
'can-am': 'Bombardier Can-Am 250',
'virago': 'Yamaha XV250',
'tenere': 'Yamaha XT650',
'jimny': 'Suzuki Jimny 1.5',
'fiesta': 'Ford Fiesta Ghia 1.4',
'roadster': 'Triumph Street Triple'
}
vehicles["starfighter"] = "Lockhead F-10... | vehicles = {'dream': 'Honda 250T', 'er5': 'Kawasaki ER5', 'can-am': 'Bombardier Can-Am 250', 'virago': 'Yamaha XV250', 'tenere': 'Yamaha XT650', 'jimny': 'Suzuki Jimny 1.5', 'fiesta': 'Ford Fiesta Ghia 1.4', 'roadster': 'Triumph Street Triple'}
vehicles['starfighter'] = 'Lockhead F-104'
vehicles['learjet'] = 'Bombardie... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.