content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
def parse_cls_ind(clsind_path):
with open(clsind_path) as cls_ind:
cls_dic = {}
for line in cls_ind:
label, cls_name = line.split(',')
cls_dic[cls_name.strip()] = int(label)
cls_dic[int(label)] = cls_name.strip()
return cls_dic | def parse_cls_ind(clsind_path):
with open(clsind_path) as cls_ind:
cls_dic = {}
for line in cls_ind:
(label, cls_name) = line.split(',')
cls_dic[cls_name.strip()] = int(label)
cls_dic[int(label)] = cls_name.strip()
return cls_dic |
def delKlinkers(woord):
'This returns a given word without vowels'
result = ''
for char in woord: # loop
if char not in 'aeiou':
result = result + char
return result # returns result to variable result
delKlinkers('Achraf')
| def del_klinkers(woord):
"""This returns a given word without vowels"""
result = ''
for char in woord:
if char not in 'aeiou':
result = result + char
return result
del_klinkers('Achraf') |
''' Problem Statemenr : Python program to segregate even and odd nodes in a Linked List
Complexity : O(n)'''
head = None # head of list
# Node class
class Node:
# Function to initialise the node object
def __init__(self, data):
self.data = data # Assign data
self.next =None
def segregateEvenOdd():
g... | """ Problem Statemenr : Python program to segregate even and odd nodes in a Linked List
Complexity : O(n)"""
head = None
class Node:
def __init__(self, data):
self.data = data
self.next = None
def segregate_even_odd():
global head
end = head
prev = None
curr = head
while end.n... |
ies = []
ies.append({ "ie_type" : "Node ID", "ie_value" : "Node ID", "presence" : "M", "instance" : "0", "comment" : "This IE shall contain the unique identifier of the sending Node."})
ies.append({ "ie_type" : "Node Report Type", "ie_value" : "Node Report Type", "presence" : "M", "instance" : "0", "comment" : "This IE... | ies = []
ies.append({'ie_type': 'Node ID', 'ie_value': 'Node ID', 'presence': 'M', 'instance': '0', 'comment': 'This IE shall contain the unique identifier of the sending Node.'})
ies.append({'ie_type': 'Node Report Type', 'ie_value': 'Node Report Type', 'presence': 'M', 'instance': '0', 'comment': 'This IE shall indic... |
def get_unique_username():
id = 0
base_string = "locust_username_"
while True:
id = id + 1
yield base_string + str(id)
def get_unique_email():
id = 0
base_string = "locust@email_"
while True:
id = id + 1
yield base_string + str(id)
def get_unique_password():
... | def get_unique_username():
id = 0
base_string = 'locust_username_'
while True:
id = id + 1
yield (base_string + str(id))
def get_unique_email():
id = 0
base_string = 'locust@email_'
while True:
id = id + 1
yield (base_string + str(id))
def get_unique_password():... |
def predict_boxes_connect(heatmap,T,threshold=0.9):
'''
This function takes heatmap and returns the bounding boxes and associated
confidence scores.
'''
'''
BEGIN YOUR CODE
'''
temp_h=int(T.shape[0]//2)
temp_w=int(T.shape[1]//2)
print(temp_h)
origin_map = np.copy(heatmap)
def explore(i,j,cnt):
if hea... | def predict_boxes_connect(heatmap, T, threshold=0.9):
"""
This function takes heatmap and returns the bounding boxes and associated
confidence scores.
"""
'\n\tBEGIN YOUR CODE\n\t'
temp_h = int(T.shape[0] // 2)
temp_w = int(T.shape[1] // 2)
print(temp_h)
origin_map = np.copy(heatmap)
def... |
def remainder(a,b):
if a==0 or b ==0:
if a > b:
if b ==0:
return None
else:
return a % b
elif b > a:
if a ==0:
return None
else:
return b % a
elif a > b:
return a%b
else:
... | def remainder(a, b):
if a == 0 or b == 0:
if a > b:
if b == 0:
return None
else:
return a % b
elif b > a:
if a == 0:
return None
else:
return b % a
elif a > b:
return a % b
... |
output_fname = raw_input("Enter the output filename: ")
search_text = raw_input("Enter the inclusion text: ")
f = open("features.tsv","r")
included_lines = []
for line in f.readlines():
if search_text in line:
included_lines.append(line)
print("found lines: %d" % len(included_lines))
outf = open(output_fname, "w... | output_fname = raw_input('Enter the output filename: ')
search_text = raw_input('Enter the inclusion text: ')
f = open('features.tsv', 'r')
included_lines = []
for line in f.readlines():
if search_text in line:
included_lines.append(line)
print('found lines: %d' % len(included_lines))
outf = open(output_fna... |
def parse (input):
decoded_input = input.decode()
decoded_input = decoded_input.split('\n')
destination = decoded_input[-1]
decoded_input = decoded_input[0:len(decoded_input)-1]
time_consider = decoded_input[0].split(',')[2]
visited_nodes = []
for i in decoded_input:
visited_nodes.ap... | def parse(input):
decoded_input = input.decode()
decoded_input = decoded_input.split('\n')
destination = decoded_input[-1]
decoded_input = decoded_input[0:len(decoded_input) - 1]
time_consider = decoded_input[0].split(',')[2]
visited_nodes = []
for i in decoded_input:
visited_nodes.a... |
# Attributes on the fly
class User:
pass
user_1 = User()
user_1.username = "Chandra"
user_2 = User()
user_2
# NOTE 1 : You can define "object" attributes on the fly
print(user_1.username)
# AttributeError: 'User' object has no attribute 'username'
# print(user_2.username)
# Class Attributes
class Person:
... | class User:
pass
user_1 = user()
user_1.username = 'Chandra'
user_2 = user()
user_2
print(user_1.username)
class Person:
count_male = 0
def __init__(self, is_male):
if is_male:
Person.count_male += 1
chandra = person(True)
sireesha = person(False)
print(Person.count_male)
mohan = perso... |
##parameters=
##title=Manage filter cookie
##
REQUEST=context.REQUEST
if REQUEST.get('clear_view_filter', 0):
context.clearCookie()
REQUEST.set('folderfilter', '')
REQUEST.set('close_filter_form', '1')
elif REQUEST.get('set_view_filter', 0):
filter=context.encodeFolderFilter(REQUEST)
REQUEST.RESPONS... | request = context.REQUEST
if REQUEST.get('clear_view_filter', 0):
context.clearCookie()
REQUEST.set('folderfilter', '')
REQUEST.set('close_filter_form', '1')
elif REQUEST.get('set_view_filter', 0):
filter = context.encodeFolderFilter(REQUEST)
REQUEST.RESPONSE.setCookie('folderfilter', filter, path='... |
class User:
def __init__(self,uid,name,surname,email,password,card_number,certificate):
self.uid=uid
self.name=name
self.surname=surname
self.email=email
self.certificate=certificate
self.password=password
self.card_number=card_number
| class User:
def __init__(self, uid, name, surname, email, password, card_number, certificate):
self.uid = uid
self.name = name
self.surname = surname
self.email = email
self.certificate = certificate
self.password = password
self.card_number = card_number |
class AverageDeviationAnomalyClass:
def __init__(self, conf, confa):
self.confObj = conf
self.confaObj = confa
# init global vars
# init global vars
self.sql = conf.sql
self.cur = conf.db.cursor()
self.gl = conf.Global
# define transactions data... | class Averagedeviationanomalyclass:
def __init__(self, conf, confa):
self.confObj = conf
self.confaObj = confa
self.sql = conf.sql
self.cur = conf.db.cursor()
self.gl = conf.Global
self.transactionsData = {}
self.transactionsDataSums = {}
self.transac... |
# -*- coding: utf-8 -*-
known_chains = {
"BTS": {
"chain_id": "4018d7844c78f6a6c41c6a552b898022310fc5dec06da467ee7905a8dad512c8",
"core_symbol": "BTS",
"prefix": "BTS",
},
"TEST": {
"chain_id": "39f5e2ede1f8bc1a3a54a7914414e3779e33193f1f5693510e73cb7a87617447",
"core_... | known_chains = {'BTS': {'chain_id': '4018d7844c78f6a6c41c6a552b898022310fc5dec06da467ee7905a8dad512c8', 'core_symbol': 'BTS', 'prefix': 'BTS'}, 'TEST': {'chain_id': '39f5e2ede1f8bc1a3a54a7914414e3779e33193f1f5693510e73cb7a87617447', 'core_symbol': 'TEST', 'prefix': 'TEST'}, 'DNATESTNET': {'chain_id': '93b266081a68bea38... |
city = input()
sales = float(input())
commision = 0
if city == 'Sofia':
if 0 <= sales <= 500:
commision = 0.05
elif 500 < sales <= 1000:
commision = 0.07
elif 1000 < sales <= 10000:
commision = 0.08
elif sales > 10000:
commision = 0.12
elif city == 'Varna':
if 0 <= s... | city = input()
sales = float(input())
commision = 0
if city == 'Sofia':
if 0 <= sales <= 500:
commision = 0.05
elif 500 < sales <= 1000:
commision = 0.07
elif 1000 < sales <= 10000:
commision = 0.08
elif sales > 10000:
commision = 0.12
elif city == 'Varna':
if 0 <= sa... |
__metaclass__ = type
class Filter_node:
def __init__(self, struc=None, config=None, save=None, debug=None):
self.myInfo = "Filter Node"
self.struc = str(struc)
self.save = str(save)
self.config = str(config)
self.debug = debug
self.nodeNum = -1
self.nodeList... | __metaclass__ = type
class Filter_Node:
def __init__(self, struc=None, config=None, save=None, debug=None):
self.myInfo = 'Filter Node'
self.struc = str(struc)
self.save = str(save)
self.config = str(config)
self.debug = debug
self.nodeNum = -1
self.nodeList... |
FF = 'ff'
ONGOING = 'normal'
FINISHED = 'finished'
CHEATED = 'cheated'
| ff = 'ff'
ongoing = 'normal'
finished = 'finished'
cheated = 'cheated' |
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
def printLinkedList(l: ListNode) -> None:
if l:
print(l.val, end=" ")
nextNode = l.next
while nextNode:
print(nextNode.val, end=" ")
nextNode = nextNode.next
... | class Listnode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
def print_linked_list(l: ListNode) -> None:
if l:
print(l.val, end=' ')
next_node = l.next
while nextNode:
print(nextNode.val, end=' ')
next_node = nextNode.nex... |
class Solution:
def rearrangeBarcodes(self, barcodes: List[int]) -> List[int]:
cnt = collections.Counter(barcodes).most_common()[::-1]
ref = [val for val, t in cnt for _ in range(t)]
for i in range(0, len(barcodes), 2):
barcodes[i] = ref.pop()
for i in range(1, len(barcod... | class Solution:
def rearrange_barcodes(self, barcodes: List[int]) -> List[int]:
cnt = collections.Counter(barcodes).most_common()[::-1]
ref = [val for (val, t) in cnt for _ in range(t)]
for i in range(0, len(barcodes), 2):
barcodes[i] = ref.pop()
for i in range(1, len(ba... |
'''
Elections are in progress!
Given an array of the numbers of votes given to each of the candidates so far, and an integer k equal to the number of voters who haven't cast their vote yet, find the number of candidates who still have a chance to win the election.
The winner of the election must secure strictly more ... | """
Elections are in progress!
Given an array of the numbers of votes given to each of the candidates so far, and an integer k equal to the number of voters who haven't cast their vote yet, find the number of candidates who still have a chance to win the election.
The winner of the election must secure strictly more ... |
class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def append(self, node):
if self.head == None:
self.head = node
else:
cur = self.head
# go till end
... | class Node:
def __init__(self, data):
self.data = data
self.next = None
class Linkedlist:
def __init__(self):
self.head = None
def append(self, node):
if self.head == None:
self.head = node
else:
cur = self.head
while cur.next !... |
# continue vs break vs pass
print('for continue function')
# continue is used for skipping outpot
for letter in range(5):
if letter == 3:
continue
print ('hi', letter)
print ('for pass function')
# pass is used to skip variable/print definition
for letter in range(5):
pass
print('for brea... | print('for continue function')
for letter in range(5):
if letter == 3:
continue
print('hi', letter)
print('for pass function')
for letter in range(5):
pass
print('for break function')
for letter in range(5):
if letter == 3:
break
print('hi', letter) |
WoqlSelect = {
"jsonObj": {
"@type": "woql:Select",
"woql:variable_list": [
{
"@type": "woql:VariableListElement",
"woql:variable_name": {"@value": "V1", "@type": "xsd:string"},
"woql:index": {"@type": "xsd:nonNegativeInteger", "@value": 0}... | woql_select = {'jsonObj': {'@type': 'woql:Select', 'woql:variable_list': [{'@type': 'woql:VariableListElement', 'woql:variable_name': {'@value': 'V1', '@type': 'xsd:string'}, 'woql:index': {'@type': 'xsd:nonNegativeInteger', '@value': 0}}], 'woql:query': {'@type': 'woql:Triple', 'woql:subject': {'@type': 'woql:Node', '... |
#author: <Samaiya Howard>
# date: <7/1/21>
# --------------- Section 1 --------------- #
# ---------- Integers and Floats ---------- #
# you may use floats or integers for these operations, it is at your discretion
# addition
# instructions
# 1 - create a print statement that prints the sum of two numbers
# ... | print(25 + 74)
print(43 + 82 + 1)
print(-2 + -73)
print()
print(15 - 23)
print(79 - 13 - 3)
print(-3 - -17)
print()
print(5 * 4)
print(100 / 5)
print(100 * 25 / 5)
print()
print(134 // 7)
print()
print(6 ** 7)
print()
print(97 % 5)
print()
print('Samaiya' + 'Howard')
print('dogs' + 'horses' + 'seals' + 'cats' + 'seals'... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
username = 'admin'
password = 'admin'
tenant_name = 'admin'
admin_auth_url = 'http://controller:35357/'
auth_url = 'http://controller:5000/' # discover api version
auth_url_v2 = 'http://controller:5000/v2.0/'
auth_url_v3 = 'http://controller:5000/v3/'
glance_url = 'http:/... | username = 'admin'
password = 'admin'
tenant_name = 'admin'
admin_auth_url = 'http://controller:35357/'
auth_url = 'http://controller:5000/'
auth_url_v2 = 'http://controller:5000/v2.0/'
auth_url_v3 = 'http://controller:5000/v3/'
glance_url = 'http://controller:9292/'
nova_url = 'http://controller:8774/'
nova_url_v2 = '... |
print('Hello, chap3, sec1.')
pub = dict()
pub['author'] = 'John F. Nash'
pub['title'] = 'Equilibrium points in n-person games'
pub['journal'] = 'PNAS'
pub['year'] = '1950' | print('Hello, chap3, sec1.')
pub = dict()
pub['author'] = 'John F. Nash'
pub['title'] = 'Equilibrium points in n-person games'
pub['journal'] = 'PNAS'
pub['year'] = '1950' |
def p(a,n):
a.sort()
s=0
for i in range(n):
s+=a[i]
a.append(s)
print(max(a))
t=int(input())
n,m,a=[],[],[]
for i in range(t):
n.append(list(map(int,(input()).strip().split(' '))))
a.append(list(map(int,(input()).strip().split(' ')))[:n[i][0]])
for i in range(t):
... | def p(a, n):
a.sort()
s = 0
for i in range(n):
s += a[i]
a.append(s)
print(max(a))
t = int(input())
(n, m, a) = ([], [], [])
for i in range(t):
n.append(list(map(int, input().strip().split(' '))))
a.append(list(map(int, input().strip().split(' ')))[:n[i][0]])
for i in range(t):
p... |
class Init:
def __init__(self):
return
def phone(self, phone: int) -> int:
try:
phstr = str(phone)
step = int(phstr[0])
for x in range(len(phstr)):
if not x + 1 == len(phstr):
step = (step ** int(phstr[x + 1]) // int(phstr... | class Init:
def __init__(self):
return
def phone(self, phone: int) -> int:
try:
phstr = str(phone)
step = int(phstr[0])
for x in range(len(phstr)):
if not x + 1 == len(phstr):
step = step ** int(phstr[x + 1]) // int(phstr[... |
def min_of_maxes(nums,k):
count = 0
highest = None
lowest = None
for i in nums:
count += 1
if highest == None:
highest = i
if i > highest:
highest = i
if count == k:
if lowest == None:
lowest = highest
if highest < lowest:
lowest = highest
high... | def min_of_maxes(nums, k):
count = 0
highest = None
lowest = None
for i in nums:
count += 1
if highest == None:
highest = i
if i > highest:
highest = i
if count == k:
if lowest == None:
lowest = highest
if hi... |
class AuthenticationError(Exception):
pass
class APICallError(Exception):
pass | class Authenticationerror(Exception):
pass
class Apicallerror(Exception):
pass |
# Definition for a binary tree node.
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
# Recursive
def isUnivalTree(root: TreeNode) -> bool:
def compare_value(cur_root: TreeNode, previous_root: int) -> bool:
if n... | class Treenode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
def is_unival_tree(root: TreeNode) -> bool:
def compare_value(cur_root: TreeNode, previous_root: int) -> bool:
if not cur_root:
return True
... |
## Colm Higgins
## This program will ask the user to input a string and prints
## every second letter in reverse order
# input sentence
x = input("Please type a sentence of your choice: ")
# print input removing every 2nd letter and reversed
# [::2] is every 2nd letter and putting a - before will reverse it.
# Shor... | x = input('Please type a sentence of your choice: ')
print('The sentence you typed removing every second letter and reversed is:\n {}'.format(x[::-2])) |
'''
Suppose a sorted array is rotated at some pivot unknown to you beforehand.
(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).
You are given a target value to search. If found in the array return its index, otherwise return -1.
You may assume no duplicate exists in the array.
'''
class Solution:
# @param A, a li... | """
Suppose a sorted array is rotated at some pivot unknown to you beforehand.
(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).
You are given a target value to search. If found in the array return its index, otherwise return -1.
You may assume no duplicate exists in the array.
"""
class Solution:
def search(self... |
# Title : Nato Phonetic Expansion
# Author : Kiran raj R.
# Date : 17:10:2020
persons = {'John': {'Age': '55', 'Gender': 'Male'},
'Toney': {'Age': '23', 'Gender': 'Male'},
'Karin': {'Age': '42', 'Gender': 'Female'},
'Cathie': {'Age': '29', 'Gender': 'Female'},
'Rosalba': ... | persons = {'John': {'Age': '55', 'Gender': 'Male'}, 'Toney': {'Age': '23', 'Gender': 'Male'}, 'Karin': {'Age': '42', 'Gender': 'Female'}, 'Cathie': {'Age': '29', 'Gender': 'Female'}, 'Rosalba': {'Age': '12', 'Gender': 'Female'}, 'Nina': {'Age': '50', 'Gender': 'Female'}, 'Burton': {'Age': '16', 'Gender': 'Male'}, 'Joey... |
class NoneType(object):
def __new__(self, *args):
return None
def __init__(self, *args):
pass
def __bool__(self):
return False
def __str__(self):
return "None"
___assign("%NoneType", NoneType)
| class Nonetype(object):
def __new__(self, *args):
return None
def __init__(self, *args):
pass
def __bool__(self):
return False
def __str__(self):
return 'None'
___assign('%NoneType', NoneType) |
# -*- coding: utf-8 -*-
DESC = "cloudaudit-2019-03-19"
INFO = {
"StartLogging": {
"params": [
{
"name": "AuditName",
"desc": "Tracking set name"
}
],
"desc": "This API is used to enable a tracking set."
},
"GetAttributeKey": {
"params": [
{
"name": "Websit... | desc = 'cloudaudit-2019-03-19'
info = {'StartLogging': {'params': [{'name': 'AuditName', 'desc': 'Tracking set name'}], 'desc': 'This API is used to enable a tracking set.'}, 'GetAttributeKey': {'params': [{'name': 'WebsiteType', 'desc': 'Website type. Value range: zh, en. Default value: zh'}], 'desc': 'This API is use... |
# test basic async for execution
# example taken from PEP0492
class AsyncIteratorWrapper:
def __init__(self, obj):
print('init')
self._it = iter(obj)
async def __aiter__(self):
print('aiter')
return self
async def __anext__(self):
print('anext')
try:
... | class Asynciteratorwrapper:
def __init__(self, obj):
print('init')
self._it = iter(obj)
async def __aiter__(self):
print('aiter')
return self
async def __anext__(self):
print('anext')
try:
value = next(self._it)
except StopIteration:
... |
INPUT_RANGE = [382345, 843167]
if __name__ == "__main__":
count = 0
for num in range(INPUT_RANGE[0], INPUT_RANGE[1]):
d1 = num // 100000
d2 = (num // 10000) % 10
d3 = (num // 1000) % 10
d4 = (num // 100) % 10
d5 = (num // 10) % 10
d6 = num % 10
... | input_range = [382345, 843167]
if __name__ == '__main__':
count = 0
for num in range(INPUT_RANGE[0], INPUT_RANGE[1]):
d1 = num // 100000
d2 = num // 10000 % 10
d3 = num // 1000 % 10
d4 = num // 100 % 10
d5 = num // 10 % 10
d6 = num % 10
if d1 <= d2 <= d3 <... |
#
# @lc app=leetcode.cn id=15 lang=python3
#
# [15] 3sum
#
None
# @lc code=end | None |
# -*- coding: utf-8 -*-
__version__ = '0.4.4.4'
request_post_identifier = 'current_aldryn_blog_entry'
app_title = 'News' | __version__ = '0.4.4.4'
request_post_identifier = 'current_aldryn_blog_entry'
app_title = 'News' |
# each user has his own credentials file. Do not share this with other users.
username = "synqs_test" # Put here your username
password = "Cm2TXfRmXennMQ5" # and the pwd
| username = 'synqs_test'
password = 'Cm2TXfRmXennMQ5' |
#
# PySNMP MIB module POLYCOM-VIDEO-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/POLYCOM-VIDEO-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:32:27 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, single_value_constraint, constraints_union, constraints_intersection, value_size_constraint) ... |
def netmiko_copy(device, source='', destination='', ckwargs={}, **kwargs):
# Example of a copy subtask
if source and destination:
command = f'copy {source} {destination}'
# For Cisco as long "file prompt" is either alert or noisy this should work
# if "file prompt" is quiet tr... | def netmiko_copy(device, source='', destination='', ckwargs={}, **kwargs):
if source and destination:
command = f'copy {source} {destination}'
output = device['nc'].send_command_timing(command)
if 'Address or name' or 'Source filename' in output:
output += '\n'
output... |
n = int(input("Enter the lowe limit : "))
m = int(input("Enter the upper limit : "))
print("The prime numbers between" , n , "and" , m, "are")
for i in range(n,m,1):
a = 0
for j in range (1,i+1,1):
if (i%j==0):
a = a+ 1
if (a==2):
print(j) | n = int(input('Enter the lowe limit : '))
m = int(input('Enter the upper limit : '))
print('The prime numbers between', n, 'and', m, 'are')
for i in range(n, m, 1):
a = 0
for j in range(1, i + 1, 1):
if i % j == 0:
a = a + 1
if a == 2:
print(j) |
rootDir = 'd:/projects/astronomy/gaia_dr2/'
fp = open(rootDir+'output/release/ranges.csv','r')
regions = set()
region_count = {}
line = fp.readline()
while len(line) != 0:
bits = line.strip().split(',')
if len(bits) > 1:
region,count = bits
regions.add(region)
line = fp.readline()
fp.clo... | root_dir = 'd:/projects/astronomy/gaia_dr2/'
fp = open(rootDir + 'output/release/ranges.csv', 'r')
regions = set()
region_count = {}
line = fp.readline()
while len(line) != 0:
bits = line.strip().split(',')
if len(bits) > 1:
(region, count) = bits
regions.add(region)
line = fp.readline()
fp.... |
#! python
# Problem # : 231A
# Created on : 2019-01-14 21:19:31
def Main():
n = int(input())
cnt = 0
for i in range(0, n):
if sum(list(map(int, input().split(' ')))) > 1:
cnt += 1
else:
print(cnt)
if __name__ == '__main__':
Main()
| def main():
n = int(input())
cnt = 0
for i in range(0, n):
if sum(list(map(int, input().split(' ')))) > 1:
cnt += 1
else:
print(cnt)
if __name__ == '__main__':
main() |
def longestCommonSubstr(self, S1, S2, n, m):
# code here
dp=[[0 for j in range(m+1)]for i in range(n+1)]
for i in range(1,n+1):
for j in range(1,m+1):
if S1[i-1]==S2[j-1]:
dp[i][j]=1+dp[i-1][j-1]
else:
dp[i][j]=0... | def longest_common_substr(self, S1, S2, n, m):
dp = [[0 for j in range(m + 1)] for i in range(n + 1)]
for i in range(1, n + 1):
for j in range(1, m + 1):
if S1[i - 1] == S2[j - 1]:
dp[i][j] = 1 + dp[i - 1][j - 1]
else:
dp[i][j] = 0
mx = 0
f... |
class NonGameScreen:
def __init__(self, screen):
self.screen = screen
def draw_text(self, text, font, color, cntr):
phrase = font.render(text, 0, color)
phrase_rect = phrase.get_rect(center=cntr)
self.screen.blit(phrase, phrase_rect)
| class Nongamescreen:
def __init__(self, screen):
self.screen = screen
def draw_text(self, text, font, color, cntr):
phrase = font.render(text, 0, color)
phrase_rect = phrase.get_rect(center=cntr)
self.screen.blit(phrase, phrase_rect) |
x = 50
y =2
dolar = 5.63
real = 1
tem_cafe = True
tem_pao = False
print(x + y)
print(x - y)
print(x * y)
print(x / y)
print(x ** y)
print(x // y)
print(x % y)
print(not tem_cafe)
print(tem_cafe or tem_pao)
print(tem_cafe and tem_pao)
print(dolar > real)
print(dolar < real)
print(dolar >= real)
print(dolar <= real)
prin... | x = 50
y = 2
dolar = 5.63
real = 1
tem_cafe = True
tem_pao = False
print(x + y)
print(x - y)
print(x * y)
print(x / y)
print(x ** y)
print(x // y)
print(x % y)
print(not tem_cafe)
print(tem_cafe or tem_pao)
print(tem_cafe and tem_pao)
print(dolar > real)
print(dolar < real)
print(dolar >= real)
print(dolar <= real)
pri... |
# -*- coding: utf-8 -*-
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License MIT (https://opensource.org/licenses/MIT).
def migrate(cr, version):
# Add temporary credit product column
cr.execute("ALTER TABLE product_template ADD temporary_credit_product int")
# S... | def migrate(cr, version):
cr.execute('ALTER TABLE product_template ADD temporary_credit_product int')
cr.execute('SELECT id FROM account_journal WHERE account_journal.debt is true')
journal_id = cr.fetchone()
if journal_id:
cr.execute('UPDATE product_template SET temporary_credit_product=%s WHER... |
HIGH = 0x1
LOW = 0x0
INPUT = 0x0
OUTPUT = 0x1
INPUT_PULLUP = 0x2
PI = 3.1415926535897932384626433832795
HALF_PI = 1.5707963267948966192313216916398
TWO_PI = 6.283185307179586476925286766559
DEG_TO_RAD = 0.017453292519943295769236907684886
RAD_TO_DEG = 57.295779513082320876798154814105
EULER = 2.7182818284590452353602... | high = 1
low = 0
input = 0
output = 1
input_pullup = 2
pi = 3.141592653589793
half_pi = 1.5707963267948966
two_pi = 6.283185307179586
deg_to_rad = 0.017453292519943295
rad_to_deg = 57.29577951308232
euler = 2.718281828459045
serial = 0
display = 1
lsbfirst = 0
msbfirst = 1
change = 1
falling = 2
rising = 3 |
def listUsers(actors, name='azmy', age=20):
raise NotImplementedError()
| def list_users(actors, name='azmy', age=20):
raise not_implemented_error() |
#
# script_globals = dict()
# script_locals = dict()
# exec(open("./npc1.py").read(), script_globals, script_locals)
#
# script_locals['touched']()
#
npc_sprite_path = "./assets/sprites/npc_male_1.png"
palette = (
(248, 112, 32), # primary - orange shirt
(0, 0, 0), # secondary - black hair
(94, 50, 18) ... | npc_sprite_path = './assets/sprites/npc_male_1.png'
palette = ((248, 112, 32), (0, 0, 0), (94, 50, 18))
name = 'Greg'
is_pushable = False
def on_create(self):
self.character.face_north()
def on_collided(self, collided_by, delta_x, delta_y):
print(f'{self.character.name}: Watch your step!')
def on_touched(sel... |
class BaseError(Exception):
pass
class BadRequestError(BaseError):
pass
class UnauthorizedError(BaseError):
pass
class NotFoundError(BaseError):
pass
class MethodNotAllowedError(BaseError):
pass
class ConflictError(BaseError):
pass
class ServerError(BaseError):
pass
class Servi... | class Baseerror(Exception):
pass
class Badrequesterror(BaseError):
pass
class Unauthorizederror(BaseError):
pass
class Notfounderror(BaseError):
pass
class Methodnotallowederror(BaseError):
pass
class Conflicterror(BaseError):
pass
class Servererror(BaseError):
pass
class Serviceunava... |
# We generate all the possible powers in the given range, put each value
# into a set, and let the set count the number of unique values present.
def compute():
seen = set(a**b for a in range(2, 101) for b in range(2, 101))
return str(len(seen))
if __name__ == "__main__":
print(compute())
| def compute():
seen = set((a ** b for a in range(2, 101) for b in range(2, 101)))
return str(len(seen))
if __name__ == '__main__':
print(compute()) |
kofy = [7,
286,
200,
176,
120,
165,
206,
75,
129,
109,
123,
111,
43,
52,
99,
128,
111,
110,
98,
135,
112,
78,
118,
64,
77,
227,
93,
88,
69,
60,
34,
30,
73,
54,
45,
83,
182,
88,
75,
85,
54,
53,
89,
59,
37,
35,
38,
29,
18,
4... | kofy = [7, 286, 200, 176, 120, 165, 206, 75, 129, 109, 123, 111, 43, 52, 99, 128, 111, 110, 98, 135, 112, 78, 118, 64, 77, 227, 93, 88, 69, 60, 34, 30, 73, 54, 45, 83, 182, 88, 75, 85, 54, 53, 89, 59, 37, 35, 38, 29, 18, 45, 60, 49, 62, 55, 78, 96, 29, 22, 24, 13, 14, 11, 11, 18, 12, 12, 30, 52, 52, 44, 28, 28, 20, 56,... |
def read_properties(path: str) -> dict:
dictionary = dict()
with open(path+".properties", "r") as arguments:
for line in arguments:
temp = line.strip().replace(" ", "").replace("%20", " ").split("=")
if len(temp) == 2:
if temp[1].isdigit():
tem... | def read_properties(path: str) -> dict:
dictionary = dict()
with open(path + '.properties', 'r') as arguments:
for line in arguments:
temp = line.strip().replace(' ', '').replace('%20', ' ').split('=')
if len(temp) == 2:
if temp[1].isdigit():
t... |
__author__ = 'raca'
'''
The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly
believe that 49/98 = 4/8, which is correct, is obtained by cancelling the 9s.
We shall consider fractions like, 30/50 = 3/5, to be trivial examples.
There are exactly four ... | __author__ = 'raca'
'\nThe fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly\nbelieve that 49/98 = 4/8, which is correct, is obtained by cancelling the 9s.\n\nWe shall consider fractions like, 30/50 = 3/5, to be trivial examples.\n\nThere are exactly fo... |
def apply_discound(price, discount):
return price * (100 - discount) / 100
# def discound_product(price):
# pass
basket = [5768.32, 4213.23, 12356, 12456]
basket_sum = sum(basket)
print(basket_sum)
basket_sum_discounted = 0
discount_1 = 7
for product in basket:
basket_sum_discounted += apply_discound(pr... | def apply_discound(price, discount):
return price * (100 - discount) / 100
basket = [5768.32, 4213.23, 12356, 12456]
basket_sum = sum(basket)
print(basket_sum)
basket_sum_discounted = 0
discount_1 = 7
for product in basket:
basket_sum_discounted += apply_discound(product, discount_1)
print(basket_sum_discounted... |
__author__ = 'roberto'
def AddNewPlane1Curve(parent, cat_constructor, curve):
pass | __author__ = 'roberto'
def add_new_plane1_curve(parent, cat_constructor, curve):
pass |
# -*- coding: utf-8 -*-
__all__ = ['get_currency', 'Currency']
_CURRENCIES = {}
def get_currency(currency_code):
"Retrieve currency by the ISO currency code."
return _CURRENCIES[currency_code]
class Currency:
"Class representing a currency, such as USD, or GBP"
__slots__ = ['code', 'name', 'symbol... | __all__ = ['get_currency', 'Currency']
_currencies = {}
def get_currency(currency_code):
"""Retrieve currency by the ISO currency code."""
return _CURRENCIES[currency_code]
class Currency:
"""Class representing a currency, such as USD, or GBP"""
__slots__ = ['code', 'name', 'symbol', 'precision']
... |
#3Sum closest
class Solution:
def threeSumClosest(self, nums: List[int], target: int) -> int:
nums.sort()
ans=0
diff=10000000
for i in range(0,len(nums)-2):
#print(i)
left=i+1
right=len(nums)-1
while(left<right):
#print(... | class Solution:
def three_sum_closest(self, nums: List[int], target: int) -> int:
nums.sort()
ans = 0
diff = 10000000
for i in range(0, len(nums) - 2):
left = i + 1
right = len(nums) - 1
while left < right:
if nums[left] + nums[rig... |
# 04. Atomic symbols
#Split the sentence "Hi He Lied Because Boron Could Not Oxidize Fluorine. New Nations Might Also Sign Peace Security Clause. Arthur King Can". into words, and extract the first letter from the 1st, 5th, 6th, 7th, 8th, 9th, 15th, 16th, 19th words and the first two letters from the other words. Crea... | s = 'Hi He Lied Because Boron Could Not Oxidize Fluorine. New Nations Might Also Sign Peace Security Clause. Arthur King Can'
s_list = s.split(' ')
new_list = {}
for i in range(1, len(sList) + 1):
if i in [1, 5, 6, 7, 8, 9, 15, 16, 19]:
newList[sList[i - 1][:1]] = i
else:
newList[sList[i - 1][:2... |
# This comes with no warranty, implied or otherwise
# This data structure was designed to support Proportional fonts
# on Arduinos. It can however handle any ttf font that has been converted
# using the conversion program. These could be fixed width or proportional
# fonts. Individual characters do not have to b... | tft__comic24 = [0, 25, 0, 0, 32, 21, 0, 0, 0, 7, 33, 2, 2, 20, 1, 6, 255, 255, 255, 252, 45, 34, 3, 6, 8, 2, 10, 207, 60, 243, 207, 60, 243, 35, 3, 20, 18, 1, 20, 1, 129, 128, 24, 24, 1, 129, 128, 48, 48, 3, 3, 7, 255, 255, 127, 255, 240, 96, 96, 6, 6, 0, 192, 192, 12, 12, 15, 255, 254, 255, 255, 225, 129, 128, 24, 24,... |
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def deleteDuplicates(self, head):
if head is None:
return None
if head.next is None:
return head
now = head
_dict = ... | class Listnode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def delete_duplicates(self, head):
if head is None:
return None
if head.next is None:
return head
now = head
_dict = {}
while now.next:
... |
tokenizer_special_cases = [
'xxbos',
'xxeos',
]
| tokenizer_special_cases = ['xxbos', 'xxeos'] |
# Space : O(n)
# Time : O(n)
class Solution:
def twoSum(self, numbers: List[int], target: int) -> List[int]:
n = len(numbers)
hashmap = {numbers[i]: (i+1) for i in range(n)}
for i in range(n):
if target - numbers[i] in hashmap:
return [i+1, hashmap[target - num... | class Solution:
def two_sum(self, numbers: List[int], target: int) -> List[int]:
n = len(numbers)
hashmap = {numbers[i]: i + 1 for i in range(n)}
for i in range(n):
if target - numbers[i] in hashmap:
return [i + 1, hashmap[target - numbers[i]]]
return [] |
GUEST_USER = {
"Properties": {
"highvalue": False,
"name": "GUEST@DOMAIN_NAME.DOMAIN_SUFFIX",
"domain": "DOMAIN_NAME.DOMAIN_SUFFIX",
"objectid": "DOMAIN_SID-501",
"distinguishedname": "CN=Guest,CN=Users,DC=DOMAIN_NAME,DC=DOMAIN_SUFFIX",
"description": "Built-in acco... | guest_user = {'Properties': {'highvalue': False, 'name': 'GUEST@DOMAIN_NAME.DOMAIN_SUFFIX', 'domain': 'DOMAIN_NAME.DOMAIN_SUFFIX', 'objectid': 'DOMAIN_SID-501', 'distinguishedname': 'CN=Guest,CN=Users,DC=DOMAIN_NAME,DC=DOMAIN_SUFFIX', 'description': 'Built-in account for guest access to the computer/domain', 'dontreqpr... |
expected_output = {
"location": {
"R0 R1": {
"auto_abort_timer": "inactive",
"pkg_state": {
1: {"filename_version": "10.106.1.0.277", "state": "I", "type": "IMG"},
2: {"filename_version": "10.106.1.0.277", "state": "C", "type": "IMG"},
},
... | expected_output = {'location': {'R0 R1': {'auto_abort_timer': 'inactive', 'pkg_state': {1: {'filename_version': '10.106.1.0.277', 'state': 'I', 'type': 'IMG'}, 2: {'filename_version': '10.106.1.0.277', 'state': 'C', 'type': 'IMG'}}}}} |
#!/usr/bin/env python
#
# Copyright (c) 2018 10X Genomics, Inc. All rights reserved.
#
# tsne
TSNE_N_COMPONENTS = 2
TSNE_DEFAULT_KEY = '2'
TSNE_DEFAULT_PERPLEXITY = 30
TSNE_THETA = 0.5
RANDOM_STATE = 0
TSNE_MAX_ITER = 1000
TSNE_STOP_LYING_ITER = 250
TSNE_MOM_SWITCH_ITER = 250
ANALYSIS_H5_TSNE_GROUP = 'tsne'
# cluster... | tsne_n_components = 2
tsne_default_key = '2'
tsne_default_perplexity = 30
tsne_theta = 0.5
random_state = 0
tsne_max_iter = 1000
tsne_stop_lying_iter = 250
tsne_mom_switch_iter = 250
analysis_h5_tsne_group = 'tsne'
analysis_h5_clustering_group = 'clustering'
analysis_h5_kmeans_group = 'kmeans'
analysis_h5_kmedoids_grou... |
if body== True:
force_vec = ass.loadasem(loads, IBC, neq) + aux.body_forces(elements, nodes, neq, DME , force_y=aux.force_y )
else:
force_vec = ass.loadasem(loads, IBC, neq) + aux.body_forces(elements, nodes, neq, DME )
UG = sol.static_sol(mat_rigidez, force_vec)
UC = pos.complete_disp(IBC, nodes, UG)
| if body == True:
force_vec = ass.loadasem(loads, IBC, neq) + aux.body_forces(elements, nodes, neq, DME, force_y=aux.force_y)
else:
force_vec = ass.loadasem(loads, IBC, neq) + aux.body_forces(elements, nodes, neq, DME)
ug = sol.static_sol(mat_rigidez, force_vec)
uc = pos.complete_disp(IBC, nodes, UG) |
#!/usr/bin/python
# Filename: print_tuple.py
age = 22
myempty = ()
print(len(myempty))
a1 = ('aa',)
print(len(a1))
a2 = ('abcd')
print(len(a2),a2[3])
name = ('Swaroop')
print ('%s is %d years old' % (name, age))
print ('Why is %s playing with that python?' % name)
| age = 22
myempty = ()
print(len(myempty))
a1 = ('aa',)
print(len(a1))
a2 = 'abcd'
print(len(a2), a2[3])
name = 'Swaroop'
print('%s is %d years old' % (name, age))
print('Why is %s playing with that python?' % name) |
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Date : 2018-01-02 11:33:15
# @Author : YeHarold (1174484433@qq.com)
# @Link : https://github.com/Yeharold
def add(a,b):
c = a + b
return c
| def add(a, b):
c = a + b
return c |
#
# PySNMP MIB module CISCO-WAN-MODULE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-WAN-MODULE-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:20:35 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (defau... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_size_constraint, single_value_constraint, value_range_constraint, constraints_union) ... |
entrada = input('Digite qualquer coisa: ')
print(type(entrada))
print(entrada.isnumeric())
print(entrada.isalnum())
print(entrada.isalpha())
| entrada = input('Digite qualquer coisa: ')
print(type(entrada))
print(entrada.isnumeric())
print(entrada.isalnum())
print(entrada.isalpha()) |
s = list(input())
s.pop()
sans = []
for i, char in enumerate(s):
if (i + 1) % 2:
sans.insert( len(sans) // 2,char)
else:
sans.insert( (len(sans) + 1) // 2,char)
print(''.join(sans)) | s = list(input())
s.pop()
sans = []
for (i, char) in enumerate(s):
if (i + 1) % 2:
sans.insert(len(sans) // 2, char)
else:
sans.insert((len(sans) + 1) // 2, char)
print(''.join(sans)) |
nums = input().split()
reverse = []
while nums:
reverse.append(nums.pop())
print(" ".join(reverse)) | nums = input().split()
reverse = []
while nums:
reverse.append(nums.pop())
print(' '.join(reverse)) |
article_body = "1. I thought of putting pen into book, turning dark ink\
into colorful, rainbow letters of love to express my feelings for you.\
But I figured I'd write the longest book in history. So, I thought\
to show off my love for you, then, I imagined, I'll have to bring\
the worl... | article_body = "1. I thought of putting pen into book, turning dark ink into colorful, rainbow letters of love to express my feelings for you. But I figured I'd write the longest book in history. So, I thought to show off my love for you, then, I imagined, I'll have to bring the world at you... |
while True:
highSchoolGrade=float(input("Please enter your highschool grade : "))
QudaratGrade= float(input("Please enter your Qudarat grade : "))
TahsiliGrade= float(input("Please enter your Tahsili grade : "))
if (highSchoolGrade > 100 or QudaratGrade > 100 or TahsiliGrade > 100):
... | while True:
high_school_grade = float(input('Please enter your highschool grade : '))
qudarat_grade = float(input('Please enter your Qudarat grade : '))
tahsili_grade = float(input('Please enter your Tahsili grade : '))
if highSchoolGrade > 100 or QudaratGrade > 100 or TahsiliGrade > 100:
print(... |
def bubble(arr):
for i in range(0, len(arr) - 1):
for j in range(0, len(arr)-i-1):
if arr[j] > arr[j+1]:
arr[j] , arr[j+1] = arr[j+1], arr[j]
print(arr)
if __name__ == '__main__':
bubble([32,43,54,54,45,3,2,4,1,56, 9]) | def bubble(arr):
for i in range(0, len(arr) - 1):
for j in range(0, len(arr) - i - 1):
if arr[j] > arr[j + 1]:
(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
print(arr)
if __name__ == '__main__':
bubble([32, 43, 54, 54, 45, 3, 2, 4, 1, 56, 9]) |
class Node():
def __init__(self, data):
self.data = data
self.next = None
class Add():
def __init__(self):
print('Add class initialized')
# Append a node
def append(self, data):
if data is None:
print('No data received')
return
node = Nod... | class Node:
def __init__(self, data):
self.data = data
self.next = None
class Add:
def __init__(self):
print('Add class initialized')
def append(self, data):
if data is None:
print('No data received')
return
node = node(data)
if sel... |
n = int(input())
okay = [int(x) for x in input().split()]
a = set()
a.add(0)
counter = n
for i in range(n):
k = okay[i]
if not k in a:
counter -= 1
a.add(k)
print(counter) | n = int(input())
okay = [int(x) for x in input().split()]
a = set()
a.add(0)
counter = n
for i in range(n):
k = okay[i]
if not k in a:
counter -= 1
a.add(k)
print(counter) |
h = int(input())
cnt = 0
while h > 1:
h //= 2
cnt += 1
print(2 ** (cnt + 1) - 1)
| h = int(input())
cnt = 0
while h > 1:
h //= 2
cnt += 1
print(2 ** (cnt + 1) - 1) |
'''
For your reference:
class TreeNode:
def __init__(self):
self.children = []
'''
# Perform a DFS but at each leaf perform max
# Pass along the level in recursive calls
def find_height(root):
def dfs_helper(node, level, hmax):
if not node.children:
if level >... | """
For your reference:
class TreeNode:
def __init__(self):
self.children = []
"""
def find_height(root):
def dfs_helper(node, level, hmax):
if not node.children:
if level > hmax[0]:
hmax[0] = level
return
for n in node.chil... |
def _openssl_dgst_sign_impl(ctx):
ctx.actions.expand_template(
template = ctx.file._template,
output = ctx.outputs.executable,
substitutions = {
"{{SRC}}": ctx.file.src.short_path,
},
is_executable = True,
)
return [DefaultInfo(
runfiles = ctx.run... | def _openssl_dgst_sign_impl(ctx):
ctx.actions.expand_template(template=ctx.file._template, output=ctx.outputs.executable, substitutions={'{{SRC}}': ctx.file.src.short_path}, is_executable=True)
return [default_info(runfiles=ctx.runfiles([ctx.file.src]))]
openssl_dgst_sign = rule(implementation=_openssl_dgst_sig... |
#!/bin/python
def getName(t, i):
if "location" in i:
t = t + "_"
t = t + i["location"]
if "name" in i:
t = t + "_"
t = t + i["name"]
if "unit" in i:
t = t + "_"
t = t + i["unit"]
return t
def parse(spacename,r):
lat = r["location"]["lat"]
lon... | def get_name(t, i):
if 'location' in i:
t = t + '_'
t = t + i['location']
if 'name' in i:
t = t + '_'
t = t + i['name']
if 'unit' in i:
t = t + '_'
t = t + i['unit']
return t
def parse(spacename, r):
lat = r['location']['lat']
lon = r['location'][... |
# Databricks notebook source
# MAGIC %md
# MAGIC ## Rubric for this module
# MAGIC - Using the silver delta table(s) that were setup by your ETL module train and validate your token recommendation engine. Split, Fit, Score, Save
# MAGIC - Log all experiments using mlflow
# MAGIC - capture model parameters, signature, t... | (wallet_address, start_date) = Utils.create_widgets()
print(wallet_address, start_date)
dbutils.notebook.exit(json.dumps({'exit_code': 'OK'})) |
class Bird:
def fly(self):
raise NotImplementedError
class Eagle(Bird):
def fly(self):
print("very fast")
if __name__ == "__main__":
eagle = Eagel()
eagle.fly()
| class Bird:
def fly(self):
raise NotImplementedError
class Eagle(Bird):
def fly(self):
print('very fast')
if __name__ == '__main__':
eagle = eagel()
eagle.fly() |
fib = [0, 1]
for x in range(60):
b = fib[-2] + fib[-1]
fib.append(b)
vzs = int(input())
i = [int(input()) for x in range(vzs)]
[print(f'Fib({x}) = {fib[x]}') for x in i] | fib = [0, 1]
for x in range(60):
b = fib[-2] + fib[-1]
fib.append(b)
vzs = int(input())
i = [int(input()) for x in range(vzs)]
[print(f'Fib({x}) = {fib[x]}') for x in i] |
# Author: James Tam
# Version: November 2016
# Exercise 1: modifying list elements
def start():
list = [1,2,3,4]
print(list)
index = int(input("Enter index of element to change: "))
while((index<0) or (index>3)):
index = int(input("Invalid index! Enter again: ")) #here we check if the in... | def start():
list = [1, 2, 3, 4]
print(list)
index = int(input('Enter index of element to change: '))
while index < 0 or index > 3:
index = int(input('Invalid index! Enter again: '))
new_value = int(input('Enter the new integer value for element: '))
while newValue < 0:
new_value... |
lst = ["A", "B", "C"]
item = {"key": "value"}
print(item["key"])
item2 = {"name": "Drew"}
print(item2["name"])
#dictionary can contain multiple pair of information
hero = {"name": "Iron Man", "nationality": "United States", "type": False}
item3 = {"bag": ["laptop", "usb", "food"], "pocket": [5.00, 1.00, 'gum'],
... | lst = ['A', 'B', 'C']
item = {'key': 'value'}
print(item['key'])
item2 = {'name': 'Drew'}
print(item2['name'])
hero = {'name': 'Iron Man', 'nationality': 'United States', 'type': False}
item3 = {'bag': ['laptop', 'usb', 'food'], 'pocket': [5.0, 1.0, 'gum'], 'reddit': {'key': [1, 2, 3, 4]}}
print(item3['bag'])
print(ite... |
# Calculate the score for each word
# 4 letter word = 1 pt
# For a word longer than 4 letters:
# 1 pt for each letter
# A 5 letter word receives 5 pts.
# Panagrams receive 7 extra pts.
def get_word_points(word, letters):
word_len = len(word)
if word_len == 4:
points = 1
else:
points ... | def get_word_points(word, letters):
word_len = len(word)
if word_len == 4:
points = 1
else:
points = word_len
if is_panagram(word, letters):
points += 7
return points
def is_panagram(word, letters):
for letter in letters:
if letter not in word:
return... |
def maxSubArraySum(a,size):
max_so_far = -1000000000000000000000
max_ending_here = 0
for i in range(0, size):
max_ending_here = max_ending_here + a[i]
if (max_so_far < max_ending_here):
max_so_far = max_ending_here
if max_ending_here < 0:
max_ending_h... | def max_sub_array_sum(a, size):
max_so_far = -1000000000000000000000
max_ending_here = 0
for i in range(0, size):
max_ending_here = max_ending_here + a[i]
if max_so_far < max_ending_here:
max_so_far = max_ending_here
if max_ending_here < 0:
max_ending_here = 0... |
WAVAX = "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7"
PNG = "0x60781c2586d68229fde47564546784ab3faca982"
WETH = "0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab" # WETH.e
DAI = "0xd586e7f844cea2f87f50152665bcbc2c279d8d70" # DAI.e
USDC = "0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664" # USDC.e
USDT = "0xc7198437980c041c805a1edcb... | wavax = '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7'
png = '0x60781c2586d68229fde47564546784ab3faca982'
weth = '0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab'
dai = '0xd586e7f844cea2f87f50152665bcbc2c279d8d70'
usdc = '0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664'
usdt = '0xc7198437980c041c805a1edcba50c1ce5db95118' |
class Hero:
#private class variabel
__jumlah = 0;
def __init__(self,name):
self.__name = name
Hero.__jumlah += 1
# method ini hanya berlaku untuk objek
def getJumlah(self):
return Hero.__jumlah
# method ini tidak berlaku untuk objek tapi berlaku untuk class
def getJumlah1():
return Hero.__jumlah
# ... | class Hero:
__jumlah = 0
def __init__(self, name):
self.__name = name
Hero.__jumlah += 1
def get_jumlah(self):
return Hero.__jumlah
def get_jumlah1():
return Hero.__jumlah
@staticmethod
def get_jumlah2():
return Hero.__jumlah
@classmethod
def ... |
l1 = [1,4,5,6]
l2 = l1[:]
l1.append('gern')
print(l1)
print(l2) | l1 = [1, 4, 5, 6]
l2 = l1[:]
l1.append('gern')
print(l1)
print(l2) |
PROJECT_TITLE = 'xmolpp2'
PLUGINS = [
]
INPUT_PAGES = ['index.rst']
OUTPUT = f'../_/site'
LINKS_NAVBAR1 = [
('C++ API', './api/c++', []),
('Python API', './api/python', []),
('Github', 'https://github.com/sizmailov/pyxmolpp2', [])
]
SEARCH_DISABLED = True | project_title = 'xmolpp2'
plugins = []
input_pages = ['index.rst']
output = f'../_/site'
links_navbar1 = [('C++ API', './api/c++', []), ('Python API', './api/python', []), ('Github', 'https://github.com/sizmailov/pyxmolpp2', [])]
search_disabled = True |
try:
arr= []
print(" Enter the integer inputs and type 'stop' when you are done\n" )
while True:
arr.append(int(input()))
except:# if the input is not-integer, just continue to the next step
unique=[]
repeat=[]
s=0
for i in arr:
if i not in unique:
unique.append... | try:
arr = []
print(" Enter the integer inputs and type 'stop' when you are done\n")
while True:
arr.append(int(input()))
except:
unique = []
repeat = []
s = 0
for i in arr:
if i not in unique:
unique.append(i)
s = s + i
elif i not in repeat:
... |
#!/usr/bin/env python3
def merge_data(dfl, dfr, col_name):
for column in dfr.columns.values:
col = col_name + str(column)
dfl[col] = dfr[column]
| def merge_data(dfl, dfr, col_name):
for column in dfr.columns.values:
col = col_name + str(column)
dfl[col] = dfr[column] |
##################
# General Errors #
##################
# No error occurred.
NO_ERROR = 0
# General error occurred.
FAILED = 1
# Operating system error occurred.
SYS_ERROR = 2
# Out of memory.
OUT_OF_MEMORY = 3
# Internal error occurred.
INTERNAL = 4
# Illegal number representation given.
ILLEGAL_NUMBER = 5
# N... | no_error = 0
failed = 1
sys_error = 2
out_of_memory = 3
internal = 4
illegal_number = 5
numeric_overflow = 6
illegal_option = 7
dead_pid = 8
not_implemented = 9
bad_parameter = 10
forbidden = 11
out_of_memory_mmap = 12
corrupted_csv = 13
file_not_found = 14
cannot_write_file = 15
cannot_overwrite_file = 16
type_error =... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.