content stringlengths 42 6.51k |
|---|
def _str_to_int(_str):
"""Convert the input str to an int if possible
:param _str: input string
:return: integer if text is a digit, else string
"""
return int(_str) if _str.isdigit() else _str |
def set_sampling_params(im_per_scene_per_camera=1, intensity_transfer=False,
target_aug_im_num=5000, excluded_camera_models=None,
excluded_datasets=None, save_as_16_bits=True,
remove_saturated_pixels=False, saturation_level=0.97,
... |
def calculate_rating(rating):
"""Calculates overall rating from rating array."""
#Uses a simple averaging formula. A refinement could be to replace this with
#a weighted formula. For instance giving greater weight for more popular options.
cumulative = 0
weight = 0
for i in range(1,6):
c... |
def invert(x):
"""
"Invert" a dictionary of dictionaries passed in i.e. swap inner & outer keys
e.g. {"a":{"x":1,"y":2},"b":{"x":3,"y":4}} becomes {"x":{"a":1,"b":3},"y":{"a":2,"b":4}}
"""
# dict for output
inv={}
# iterate over the keys of first dictionary from input
for k in list(list(... |
def get_clean_layer_name(name):
"""Remove any unwanted characters from the layer name.
Args:
name (string): the layer name.
Returns:
string: the filtered layer name.
"""
delimit_chars = ":_/"
for char in delimit_chars:
name = name.split(char)[0]
return name |
def do_full_save(experiment_result):
"""This is a simple check to see if the final OOF ROC-AUC score is above 0.75. If it is, we return True; otherwise, we return
False. As input, your do_full_save functions should expect an Experiment's result dictionary. This is actually the dictionary
that gets saved as ... |
def maybe_quote(s):
""" Enclose the string argument in single quotes if it looks like it needs it.
Spaces and quotes will trigger; single quotes in the argument are escaped.
This is only used to compose the --print output so need only satisfy shlex.
"""
NEED_QUOTE = u" \t\"\\'"
clean = T... |
def islower(char):
""" Indicates if the char is lower """
if len(char) == 1:
if ord(char) >= 0x61 and ord(char) < 0x7A:
return True
return False |
def is_slice(idx):
"""
Check if `idx` is slice.
"""
#return isinstance(idx,slice)
return type(idx)==slice |
def get_param(dict, key, default):
""" Return value from dictionary if key present, otherwise return default value"""
val = dict[key] if key in dict else default
return val |
def pos_in_interval(pos, intervalstart, intervalend):
"""Check if position is in interval. Return boolean"""
pos = int(pos)
intervalstart = int(intervalstart)
intervalend = int(intervalend)
return pos >= intervalstart and pos <= intervalend |
def undo(data):
"""Remove all `DotDict` instances from `data`.
This function will recursively replace all `DotDict` instances with their
plain Python equivalent.
"""
if not isinstance(data, (list, tuple, dict)):
return data
# Recursively convert all elements in lists and dicts.
if... |
def get_canonical_container_name(container):
"""Return the canonical container name, which should be
of the form dusty_<service_name>_1. Containers are returned
from the Python client with many names based on the containers
to which they are linked, but simply taking the shortest name
should be suff... |
def _concept_to_lf(concept):
"""
Parse concept. Since fixed recursion we don't have to worry about
precedence
"""
op = ""
if "or" in concept:
op = "or"
elif "and" in concept:
op = "and"
if op:
op_index = concept.index(op)
left = concept[:op_index]
... |
def replace_urls_from_entinies(html, urls):
"""
:return: the html with the corresponding links from the entities
"""
for url in urls:
link = '<a href="%s">%s</a>' % (url['url'], url['display_url'])
html = html.replace(url['url'], link)
return html |
def recursive_update(default, custom):
"""A recursive version of Python dict#update"""
if not isinstance(default, dict) or not isinstance(custom, dict):
raise TypeError('Params of recursive_update() must be a dictionnaries.')
for key in custom:
if isinstance(custom[key], dict) and isinstanc... |
def _collector_url_from_hostport(secure, host, port, use_thrift):
"""
Create an appropriate collector URL given the parameters.
`secure` should be a bool.
"""
if secure:
protocol = 'https://'
else:
protocol = 'http://'
if use_thrift:
return ''.join([protocol, host, '... |
def rgbToGray(r, g, b):
"""
Converts RGB to GrayScale using luminosity method
:param r: red value (from 0.0 to 1.0)
:param g: green value (from 0.0 to 1.0)
:param b: blue value (from 0.0 to 1.0)
:return GreyScale value (from 0.0 to 1.0)
"""
g = 0.21*r + 0.72*g + 0.07*b
return g |
def contain_filter(file, filters=None):
"""
Check if a file contains one or many of the substrings specified in filters
:param file:
:param filters:
:return bool:
"""
if filters is None:
return True
for filter in filters:
if len(file.split(filter)) >= 2:
retu... |
def rstrip(s):
"""rstrip(s) -> string
Return a copy of the string s with trailing whitespace
removed.
"""
return s.rstrip() |
def string_prepend(prefix: str, string: str):
"""Prepends each line in `string` with `prefix`."""
sub = "\n" + prefix
return prefix + string.replace("\n", sub) |
def shake_shake_eval(xa, xb):
"""Shake-shake regularization in testing mode.
Args:
xa: Input, branch A.
xb: Input, branch B.
Returns:
Mix of input branches.
"""
# Blend between inputs A and B 50%-50%.
return (xa + xb) * 0.5 |
def massage_decl(decl):
"""
Tart-up a C function declaration: remove storage qualifiers,
smush onto one line, escape asterisks.
"""
for storage in 'extern static inline'.split():
decl = decl.replace(storage + ' ', '')
fixed_lines = ' '.join(line.strip() for line in decl.splitlines()... |
def collections_from_dict(dic):
"""
construct a Jekyll yaml collection (a dictionary) from a menu dict
example input: {'ReadingNotes': ['Book_NeuralNetworksAndDeepLearning', 'test']}
example output: {'ReadingNotes_Book_NeuralNetworksAndDeepLearning': {'output': True,
'permalink': '/ReadingNotes/Bo... |
def gt_with_none(a, b):
"""Implementation of greater than return False if a or b are NoneType values"""
if a is None or b is None:
return False
else:
return a > b |
def CtoKtoC_Conversion(inputTemp, outputTempType, isReturn):
"""This method converts to Celsius if given a Kelvin and vice versa.
inputTemp = The input temperature value.
outputTempType = Type of output temperature required.
isReturn = Whether output is required in return."""
if outputTempT... |
def create_reverse_dns(*resource_name_parts) -> str:
"""
Returns a name for the resource following the reverse domain name notation
"""
# See https://en.wikipedia.org/wiki/Reverse_domain_name_notation
return "io.simcore.storage" + ".".join(map(str, resource_name_parts)) |
def convert_c_to_f(temperature_c):
"""Convert Celsius to Fahrenheit."""
temperature_f = temperature_c * (9/5) +32
return temperature_f |
def sumNumbers(root):
"""
:type root: TreeNode
:rtype: int
"""
if root is None: return 0
parent, leaves = {}, []
stack = [root]
while stack:
node = stack.pop()
if node.left is None and node.right is None:
leaves.append(node)
continue
if nod... |
def str_space_to_int_list(string):
""" Converts a spaced string in a list of integer.
The string consists of the succession of the elements of the list separated by spaces.
:param string: the string to convert.
:return: the corresponding list of integer.
"""
string_list = string.split(" ")
... |
def valueForKeyList(d, keys, default=None):
"""Returns the value at the end of the list of keys.
>>> d = {'a': 1, 'c': {'e': 5, 'd': 4}, 'b': 2, 'f': {'g': {'h': 8}}}
>>> valueForKeyList(d, ('q',), "foo")
'foo'
>>> valueForKeyList(d, (), "foo")
{'a': 1, 'c': {'e': 5, 'd': 4}, 'b': 2, 'f': {'g':... |
def check_hash(hash: bytes, leading_zeros: int)-> bool:
"""Check that the provided hash is prefixed with at least `leading_zeros` zero bits"""
if leading_zeros >= 32 * 8:
raise Exception(f"Requirement of {leading_zeros} leading zero bits is impossible; max is {32 * 8}")
# convert bits to bytes,... |
def format_context_as_squad(fiche_id, context):
"""
For fiches which have no question, add them without qas.
"""
res = {
"title": fiche_id,
"paragraphs": [
{
"context": context,
}
],
}
return res |
def _calculate_num_learner_steps(
num_observations: int,
min_observations: int,
observations_per_step: float,
) -> int:
"""Calculates the number of learner steps to do at step=num_observations."""
n = num_observations - min_observations
if n < 0:
# Do not do any learner steps until you h... |
def get_by_name(yaml, ifname):
"""Return the BondEthernet by name, if it exists. Return None,None otherwise."""
try:
if ifname in yaml["bondethernets"]:
return ifname, yaml["bondethernets"][ifname]
except KeyError:
pass
return None, None |
def serialize_ambito_publico(ambito_publico):
"""
# $ref: '#/components/schemas/ambitoPublico'
"""
if ambito_publico:
return ambito_publico.codigo if ambito_publico.codigo else "EJECUTIVO"
return "EJECUTIVO" |
def redraw_in_scale(shape, scale):
""" Takes a shape and redraws it in a different bigger scale.
The positions are offseted but the colors are preserved.
For simplicity the algorithm first rescales Ys then Xs.
Each rescale uses anchor to calculate the position of new/old cells.
The further away we ... |
def myshortcode(context, var):
"""
This is as example of a user-defined shortcode.
"""
return var.upper() |
def get_items_from_triggers(triggers):
"""Given a list of Item rule triggers, extract the names of the Items and
return them in a list.
Arguments:
- triggers: the list of rule trigger strings.
Returns:
A list of item_names.
"""
return [t.split(" ")[1] for t in triggers if t.sta... |
def task_accuracy_metrics(reward_list):
""" Accuracy as percentage of examples that received rewards """
accuracy = sum(reward_list)*100/float(len(reward_list))
print("Total Reward: %s, Accuracy: %s %%"%(sum(reward_list),accuracy))
return accuracy |
def flat_file_add_to_output_dict(output_dict, location_in_json, data_dict):
"""Add key value pairs to the output_dict"""
for key, value in data_dict.items():
add_command = location_in_json + "[\"" + key + "\"] = " + value
try:
exec(add_command)
except (NameError, SyntaxError... |
def is_iterable(x):
"""
Returns if given :math:`x` variable is iterable.
Parameters
----------
x : object
Variable to check the iterability.
Returns
-------
bool
:math:`x` variable iterability.
Examples
--------
>>> is_iterable([1, 2, 3])
True
>>> i... |
def stirling_second(n: int, k: int):
"""
Computes Stirling number of the second kind
Parameters
----------
n: int
Numeric. If non-integer passed in, will attempt to cast as integer
k: int
Numeric. If non-integer passed in, will attempt to cast as integer
Returns
------... |
def _lexographic_lt0(a1, a2):
"""
Compare two 1D numpy arrays lexographically
Parameters
----------
a1: ndarray
1D numpy array
a2: ndarray
1D numpy array
Returns
-------
comparison:
True if a1 < a2, False otherwise
"""
for e1, e2 in zip(a1, a2):
... |
def calculate_management_strategy(fef, mtbfa, mtbfgp):
"""
Function to calculate the minimum required management strategy for the
entire program or a test phase.
:param float fef: the average fix effectiveness factor over the period to
calculate the management strategy.
:param... |
def pk(y_true, y_pred, k):
"""
Function to calculate precision at k
:param y_true: list of values, actual classes
:param y_pred: list of values, predicted classes
:param k: the value for k
:return: precision at given value k
"""
# we are only interested in top-k predictions
y_pred = y_pre... |
def build_quarter_string(operational_year, operational_quarter):
"""
Helper function to build quarter name for JIRA.
:param String operational_year:
:param String operational_quarter:
:return: Formatted Quarter name
:rtype: String
"""
return 'Y%s-Q%s' % (operational_year, operational_qu... |
def filter_evidence_fn(
example, y_input):
# pylint: disable=unused-argument
"""Filter out claims/evidence that have zero length.
Args:
example: The encoded example
y_input: Unused, contains the label, included for API compat
Returns:
True to preserve example, False to filter it out
"""
# B... |
def _split_version_id(full_version_id):
"""Return server and version.
Args:
full_version_id: Value in the format that is set in the 'CURRENT_VERSION_ID'
environment var. I.e. 'server:server_version.minor_version'.
Returns:
(server, server_version) tuple, or (None, server_version) if this is the
... |
def is_good(res):
""" is_good
Check res is not None and res.attrib['stat'] == "ok" for XML object
"""
return False\
if res is None\
else (not res == "" and res.attrib['stat'] == "ok") |
def twos_comp(val, bits):
"""Compute the 2's complement of int value val."""
if (val & (1 << (bits - 1))) != 0: # if sign bit is set
val = val - (1 << bits) # compute negative value
return val # return positive value as is |
def sort_sons(items):
"""Sort sons from node.sons.items()"""
return sorted(items, key=lambda it: it[1].data['rank']) |
def intensity2color(scale):
"""Interpolate from pale grey to deep red-orange.
Boundaries:
min, 0.0: #cccccc = (204, 204, 204)
max, 1.0: #ff2000 = (255, 32, 0)
"""
assert 0.0 <= scale <= 1.0
baseline = 204
max_rgb = (255, 32, 0)
new_rbg = tuple(baseline + int(round(scale * (... |
def build_suggest_result(prefix, wd_search_results):
""" Build extend result set.
Parameters:
prefix (str): suggest prefix entery.
wd_search_results (obj): Search result from Wikidata.
Returns:
extend_results (obj): Result for the data extension request.
"""... |
def duns_screener(duns):
"""
Takes a duns number and returns a modified string to comply with DUNS+4 format
common DUNS errors:
* leading zero removed: len == 8 --> add leading zero back + '0000' trailing
* 9-digits --> duns + '0000'
* else: 'error'
"""
if len(duns) ==... |
def name_converter(name: str) -> str:
"""
Returns the correct dataset name for datasets begining with numbers.
:param name: The name of the dataset to convert
:return: The converted dataset name if required, else passed in name is returned.
"""
return {
"jid_editorial_images_2018": "201... |
def mutation_frequency(H, D):
"""
# ========================================================================
MUTATION FREQUENCY
PURPOSE
-------
Calculates the mutation frequency.
INPUT
-----
[INT] [H]
The number of haplotypes.
[2D ARRAY] [D]
A distance mat... |
def check(file_path: str) -> bool:
""" True if the given file path is a baseline file. """
return file_path.endswith('.baseline') |
def isWinner(data,c1,c2):
"""
This function takes the preference ranking data as an input parameter. It computes the
head to head winner for the two candidates that are passed into it as parameters.
If the first candidate passed as a paramter wins against the second candidate, then
the function will ... |
def fits(bounds_inside, bounds_around):
"""Returns True if bounds_inside fits entirely within bounds_around."""
x1_min, y1_min, x1_max, y1_max = bounds_inside
x2_min, y2_min, x2_max, y2_max = bounds_around
return (x1_min >= x2_min and x1_max <= x2_max
and y1_min >= y2_min and y1_max <= y2_ma... |
def is_hash160(s):
""" Returns True if the considered string is a valid RIPEMD160 hash. """
if not s or not isinstance(s, str):
return False
if not len(s) == 40:
return False
for c in s:
if (c < '0' or c > '9') and (c < 'A' or c > 'F') and (c < 'a' or c > 'f'):
return... |
def used_interfaces(list_of_address):
"""Returns a set of interfaces that the addresses are configured on"""
interfaces = set()
for address in list_of_address:
interfaces.update([address.get_interface()])
return interfaces |
def key_safe_data_access(data, key):
"""Safe key based data access.
Traditional bracket access in Python (foo['bar']) will throw a KeyError (or
IndexError if in a list) when encountering a non-existent key.
foo.get(key, None) is solves this problem for objects, but doesn't work with
lists. Thus this function... |
def drop_placeholders(peaks):
"""Removes all placeholder peaks from an iterable of peaks
Parameters
----------
peaks : Iterable of FittedPeak
Returns
-------
list
"""
return [peak for peak in peaks if peak.mz > 1 and peak.intensity > 1] |
def calc_matrix_size(ver):
"""\
Returns the matrix size according to the provided `version`.
Note: This function does not check if `version` is actually a valid
(Micro) QR Code version. Invalid versions like ``41`` may return a
size as well.
:param int ver: (Micro) QR Code version constant.
... |
def cli_parser_var(var: str):
"""Parse runflow `--var` value."""
key, value = var.split("=")
return key.strip(), value.strip() |
def starts_with(value: str, arg: str) -> bool:
"""
Simple filter for checking if a string value starts with another string.
Usage:
```django
{% if request.url | starts_with:"/events" %}
...
{% endif %}
```
"""
return value.startswith(arg) |
def arrayNetworkLength(networkLength, clusterNodesLength):
"""
Define how many cell switches (DCell) and PODs (FatTree) wil be created on each cluster node or worker
"""
arrayNetworkLength = [networkLength / clusterNodesLength] * clusterNodesLength
restNetworkLength = networkLength % clusterNode... |
def chunks(l, n):
"""Yield successive n-sized chunks from l."""
ll=[]
for i in range(0, len(l), n):
ll.append(l[i:i+n])
return ll |
def dump_flags(flag_bits, flags_dict):
"""Dump the bits in flag_bits using the flags_dict"""
flags = []
for name, mask in flags_dict:
if (flag_bits & mask) != 0:
flags.append(name)
if not flags:
flags = ["0"]
return "|".join(flags) |
def badge(value, bg_color=None, show_empty=False):
"""
Display the specified number as a badge.
Args:
value: The value to be displayed within the badge
bg_color: Background color CSS name
show_empty: If true, display the badge even if value is None or zero
"""
return {
... |
def _extract_pipeline_of_pvalueish(pvalueish):
"""Extracts the pipeline that the given pvalueish belongs to."""
if isinstance(pvalueish, tuple):
pvalue = pvalueish[0]
elif isinstance(pvalueish, dict):
pvalue = next(iter(pvalueish.values()))
else:
pvalue = pvalueish
if hasattr(pvalue, 'pipeline'):
... |
def str_or_null(res):
"""Return res as a string, unless res is None, in which case it returns
the empty string.
"""
if res is None:
return ''
return str(res) |
def center(width, n):
"""
Computes free space on the figure on both sides.
:param width:
:param n: number of algorithms
:return:
"""
max_unit = 1
free_space = width - n * max_unit
free_space = max(0, free_space / max_unit)
free_left = free_space / 2
free_right = free_space / ... |
def extract_tokens(ngrams):
"""Extract and count tokens from JSTOR ngram data"""
article_words = []
text = ngrams.rstrip()
text_list = text.split('\n')
for item in text_list:
word_count = item.split('\t')
if len(word_count[0]) < 3: # data cleanup: eliminate ocr noise and most roman ... |
def most_common(hist):
"""Makes a list of word-freq pairs in descending order of frequency.
hist: map from word to frequency
returns: list of (frequency, word) pairs
"""
t = []
for key, value in hist.items():
t.append((value, key))
t.sort()
t.reverse()
return t |
def de_unit_key(key: str) -> str:
"""Remove the unit from a key."""
if key.endswith("f"):
return key[:-1]
if key.endswith("in"):
return key[:-2]
if key.endswith("mph"):
return key[:-3]
return key |
def find(predicate, seq):
"""A helper to return the first element found in the sequence
that meets the predicate. For example: ::
comment = find(lambda comment: comment.author.name == 'SilverElf', mod.comments.flatten())
would find the first :class:`.Comment` whose author's name is 'SilverElf' and... |
def RGBtoHSL( rgb ):
""" return a triple tuple containing HSL values given
a triple tuple of rgb data ( blue, green, red ) format
"""
# R' = R/255 (G' = G/255, B' = B/255)
Rp = rgb[2]/255
Gp = rgb[1]/255
Bp = rgb[0]/255
Cmax = max(Rp,Gp,Bp)
Cmin = min(Rp,Gp,Bp)
Delta = Cmax -... |
def bulk_lookup(license_dict, pkg_list):
"""Lookup package licenses"""
pkg_licenses = {}
for pkg in pkg_list:
# Failsafe in case the bom file contains incorrect entries
if not pkg.get("name") or not pkg.get("version"):
continue
pkg_key = pkg["name"] + "@" + pkg["version"]... |
def lr_poly(base_lr, i_iter, max_iters, power):
""" Poly_LR scheduler
"""
return base_lr * ((1 - float(i_iter) / max_iters) ** power) |
def AP(target, results):
"""
Description:
Return AP(Average Precision) with target and results
Parameters:
target: list of K retrieved items (type: list, len: K)
[Example] [tag1, tag2, ..., tagK]
results: list of N retrieved items (type: list, shape: (N, ?))
... |
def list2str(lists):
"""
list to str
"""
return str(list(lists)).replace('\'', '').replace('\\n', '\n').replace(', ', '\n')[1:-1] |
def get_letterbox_image_embedding(img_h, img_w, target_letterbox_dim):
"""
----------
Author: Damon Gwinn (gwinndr)
----------
- Computes embedding information for a letterbox input format
- Information is the size of the embedded image and where the embedded image is in the letterbox
------... |
def count_periods(start, end, period_length):
"""
:param start: unix time, excluded
:param end: unix time, included
:param period_length: length of the period
:return:
"""
return (int(end)-int(start)) // period_length |
def serialize_int(x: int) -> bytes:
""" Efficiently convert a python integer to a serializable byte-string. """
byte_size = (int.bit_length(x) + 8) // 8
return int.to_bytes(x, length=byte_size, byteorder='big') |
def get_emails(data):
"""Extracts only emails from below structure and returns them as list
data = [
{
...: ...,
'Attributes': [
{
'Name': 'email'
'Value': '...'
},
...
],
... |
def decodeString(s: str) -> str:
"""Return decoded string, given encoded string 's'."""
def decodeScope(i: int = 0, repeat: int = 1):
"""Decode the encoding scope beginning at index 'i', given the
enclosing number of 'repeat's. Returns a tuple of the next index
to process along with... |
def parse_both_2(image_results):
""" parses the tags and repos from a image_results with the format:
{
'image': [{
'pluginImage': {
'ibmContainerRegistry': 'internalRepo/name'
'publicRegistry': 'repo/name'
},
'driverImage': {
... |
def find_parent(lst, i, dist):
"""Finds the parent node of the given node in a pre-order traversal list.
Args:
lst: a list that contains a pre-order traversal of a free-tree
i: the index of the actual node
dist: the distance of the actual node
Returns:
int: the index of the... |
def EVLAGetSessionCode( fileDict ):
"""
Get the project session code from a fileDict returned by
PipeUtil.ParseASDM.
* fileDict = dictionary returned by ParseASDM
"""
# Get session from archive file name
session = 'XX'
#VLBA pattern = re.compile(r'EVLA_[A-Za-z]+[0-9]+([A-Za-z]+)')
... |
def extract_datainput_name(stanza_name):
"""
stansa_name: string like aws_s3://my_s3_data_input
"""
sep = "://"
try:
idx = stanza_name.index(sep)
except ValueError:
return stanza_name
return stanza_name[idx + len(sep):] |
def parse_indices(in_: str) -> list:
"""Parse indices from comma-separated and ranged index string."""
comps = in_.split(',')
indices = set()
for comp in comps:
if '-' in comp:
low, high = comp.split('-')
indices.update(range(int(low), int(high) + 1))
else:
... |
def plot_landmarks(axis, landmarks, **kwargs):
"""Plot markers at ``landmark`` locations in ``axis``."""
color = kwargs.pop('color', 'k')
lbl = kwargs.pop('label', '')
marker = kwargs.pop('marker','^')
for x, y in landmarks:
axis.plot([x], [y], marker=marker, color=color, label=lbl, **kwargs... |
def lineStartingWith(string, lines):
""" Searches through the specified list of strings and returns the
first line starting with the specified search string, or None if not found
"""
for line in lines:
if line.startswith(string):
return line
else:
return None |
def reduce_value(value, default=''):
"""
:return: a single value from lists, tuples or sets with one item;
otherwise, the value itself if not empty or the default if it is.
"""
if hasattr(value, '__len__'):
vlen = len(value)
if vlen == 0:
return default
elif vle... |
def count_a_in_b_unique(a, b):
"""Count unique items.
Args:
a (List): list of lists.
b (List): list of lists.
Returns:
count (int): number of elements of a in b.
"""
count = 0
for el in a:
if el in b:
count += 1
return count |
def get_url(position, location):
"""Generate url from position and location"""
# remember to replace so it results q= {] and l={}
placeholder = 'https://nz.indeed.com/jobs?q={}&l={}'
# Format correctly to use url for multiple jobs.
url = placeholder.format(position, location)
return url |
def line_from_two_points(x1, y1, x2, y2):
"""
Helper function to return the equation of a line
passing through any two points.
:Parameters:
x1: float
X coordinate of first point
y1: float
Y coordinate of first point
x2: float
X coordinate of second point
y2... |
def factorial(num):
""" Calculatte the factorial of a positive integer num
Assumption : num is not less than or equal to 0"""
if num == 1:
return num
else:
return num * factorial(num - 1) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.