content stringlengths 7 1.05M |
|---|
#!/usr/bin/env python3
"""
.. automodule:: test_phile.test_PySide2
.. automodule:: test_phile.test_asyncio
.. automodule:: test_phile.test_builtins
.. automodule:: test_phile.test_cmd
.. automodule:: test_phile.test_configuration
.. automodule:: test_phile.test_data
.. automodule:: test_phile.test_datetime
.. automodul... |
def limpar(tela):
telaPrincipal = tela
lista = [telaPrincipal.telefone, telaPrincipal.nome,
telaPrincipal.cep,
telaPrincipal.end,
telaPrincipal.numero,
telaPrincipal.bairro,
telaPrincipal.ref,
telaPrincipal.complemento, telaPrincipal... |
#Embedded file name: ACEStream\version.pyo
VERSION = '2.0.8.7'
VERSION_REV = '2191'
VERSION_DATE = '2013/03/28 18:36:41'
|
credentials = {
'ldap': {
'user': '',
'pass': ''
},
'rocket': {
'user': '',
'pass': ''
}
} |
# https://edabit.com/challenge/KWoj7kWiHRqJtG6S2
# There is a single operator in Python
# capable of providing the remainder of a division operation.
# Two numbers are passed as parameters.
# The first parameter divided by the second parameter will have a remainder, possibly zero.
# Return that value.
def... |
ano=int(input('que ano quer analisar'))
if ano%4==0 and ano % 100 !=0 or ano %400==0:
print('o ano é bissexto'.format (ano))
else:
print('o ano nao é bissesto')
|
#! /usr/bin/python
##
# @file
# This file is part of SeisSol.
#
# @author Sebastian Rettenberger (sebastian.rettenberger AT tum.de, http://www5.in.tum.de/wiki/index.php/Sebastian_Rettenberger)
#
# @section LICENSE
# Copyright (c) 2016, SeisSol Group
# All rights reserved.
#
# Redistribution and use in source and binar... |
# -----------------------------------------------------.
# ポリゴンメッシュの不要な頂点/稜線を削除.
# 選択されたポリゴンメッシュの面を構成しない頂点や稜線を削除.
#
# @title \en Remove unnecessary vertices/edges of polygon mesh \enden
# @title \ja ポリゴンメッシュの不要な頂点/稜線を削除 \endja
# -----------------------------------------------------.
scene = xshade.scene()
# ポリゴンメ... |
# Script Name : data.py
# Author : Howard Zhang
# Created : 14th June 2018
# Last Modified : 14th June 2018
# Version : 1.0
# Modifications :
# Description : The struct of data to sort and display.
class Data:
# Total of data to sort
data_count = 32
def __init__(self,... |
class Plugin:
def __init__(self):
pass
def execute(self):
print("HELLO WORLD 2. :D")
|
class NotAuthenticatedError(Exception):
pass
class AuthenticationFailedError(Exception):
pass
|
OPERATION_TYPES = [
'ADD',
'REMOVE',
'CHANGE_DATA',
'PATCH_METADATA'
]
USER_CHANGEABLE_RELEASE_STATUSES = {
'MUTABLE': [
'DRAFT',
'PENDING_RELEASE',
'PENDING_DELETE'
],
'IMMUTABLE': [
'RELEASED',
'DELETED'
]
}
RELEASE_STATUS_ALLOWED_TRANSITIONS =... |
total_taxis = 100
size = 4
expected_customers = 120
size_without_driver = size - 1
number_of_cars_required = expected_customers/size_without_driver
print(f"number of cars required {number_of_cars_required}")
|
lst = ["Peace", "of", "the", "mind", 2, 4, 7]
for i in lst:
place = "".join(map(str, lst))
print(place)
|
class DebuggerStepperBoundaryAttribute(Attribute,_Attribute):
"""
Indicates the code following the attribute is to be executed in run,not step,mode.
DebuggerStepperBoundaryAttribute()
"""
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...... |
choice = ''
def add(num1, num2):
return num1 + num2
def subs(num1, num2):
return num1 - num2
def mult(num1, num2):
return num1 * num2
def div(num1, num2):
return num1 / num2
def mod(num1, num2):
return num1 % num2
def power(num1, num2):
result = 1
for i in range(num2):
result *=... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# */AIPND/intropylab-classifying-images/print_functions_for_lab_checks.py
#
# PROGRAMMER: Jennifer S.
# DATE CREATED: 05/14/2018 ... |
#!/usr/bin/env python
'''\
Given two strings, remove all characters contained in the latter from
the former. Note that order is preserved. For example:
"ab", "b" -> "a"
"abcdabcd", "acec" -> "bdbd"
What is the run-time of your algorithm? How much memory does it use? Is it
optimal?
linear search... |
ACACA_AcCoA = 34
ACACA_HCO3 = 2100
ACAT2_AcCoA = 29
ACLY_Citrate = 78
ACLY_CoA = 14
ACO2_Citrate = 480
ACO2_Isocitrate = 120
ACOT12_AcCoA = 47
ACOT13_AcCoA = 47
ACSS1_Acetate = 73
ACSS1_CoA = 11
ACSS2_Acetate = 73
ACSS2_CoA = 11
CS_AcCoA = 5
CS_OXa = 5.9
EP300_AcCoA = 0.28
FASN_AcCoA = 7
FASN_HCO3 = 21... |
# Set the following variables and rename to credentials.py
USER = RPC_USERNAME
PASSWORD = RPC_PASSWORD
SITE_SECRET_KEY = BYTE_STRING
|
# 카카오 압축
# 투 포인터 알고리즘 사용
"""
1. 길이가 1인 모든 단어를 포함하도록 딕셔너리 초기화
2. 만약 어떤 글자가 사전에 존재한다면, 오른쪽 범위를 1 증가시켜 탐색
3. 범위를 증가시켰을 때 존재하지 않는다면, 단어를 사전에 등록 후 right를 -1 감소시킨 값을 출력함
"""
def solution(msg):
hs = set()
words = {}
ans = []
left, right = 0, 1
# 딕셔너리 및 해시 초기화
idx = 27
for i in range(26):
... |
def GetXSection(fileName): #[pb]
#Cross Section derived from sample name using https://cms-gen-dev.cern.ch/xsdb/
#TODO UL QCD files have PSWeights in their name, but xsdb does not include it in its name
fileName = fileName.replace("PSWeights_", "")
#TODO: UL Single Top xSection only defined for filename without inc... |
"""
--- Day 1: Report Repair ---
After saving Christmas five years in a row, you've decided to take a vacation at a nice resort on a tropical island. Surely, Christmas will go on without you.
The tropical island has its own currency and is entirely cash-only. The gold coins used there have a little picture of a starfi... |
# Given an array of non-negative integers,
# you are initially positioned at the first index of the array.
# Each element in the array represents your maximum jump length at that position.
# Determine if you are able to reach the last index.
# Example 1:
# Input: [2,3,1,1,4]
# Output: true
# Explanation: Jump 1 step ... |
"""
给定一个二叉树,检查它是否是镜像对称的。
例如,二叉树 [1,2,2,3,4,4,3] 是对称的。
1
/ \
2 2
/ \ / \
3 4 4 3
但是下面这个 [1,2,2,null,3,null,3] 则不是镜像对称的:
1
/ \
2 2
\ \
3 3
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/symmetric-tree
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
"""
# Definition for a binary tre... |
def mdc(m, n):
while m%n != 0:
oldm = m
oldn = n
m = oldn
n = oldm%oldn
return n
def mesmaFracao(f1, f2):
return (f1.getNum() == f2.getNum()) and (f1.getDen() == f2.getDen())
class Fracao:
def __init__(self, num, den):
self.__num = num
... |
class WeatherAnalyzer:
def __init__(self, weathers):
weathers.sort(key=lambda x: x.temp)
self.weathers = weathers
def coldest(self):
print("Najzimniejsza temperatura panuje w mieście {}. Temperatura wynosi {}".
format(self.weathers[0].city_name, self.weathers[0].temp))
... |
# -*- coding: utf-8 -*-
"""
To-Do application
"""
def add(todos):
"""
Add a task
"""
task = input('New task: ')
todos.append({
'task': task,
'done': False
})
def delete(todos, index=None):
"""
Delete one or all tasks
"""
if index is not None:
del todos... |
# Copyright 2019 The Bazel Authors. 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 required by applicable la... |
class Solution:
"""
@param numbers: Give an array numbers of n integer
@param target: An integer
@return: return the sum of the three integers, the sum closest target.
"""
def threeSumClosest(self, numbers, target):
numbers.sort()
ans = None
for i in range(len(numbers)):... |
# polymorphism
# fonksiyonlarda polymorphism
# var1 = "metin"
# var2 = [1,2,3,4]
# print(len(var1))
# print(len(var2))
# def add(x,y,z=0):
# return x+y+z
# print(add(2,3))
# print(add(2,3,4))
# Class Method polymorphism
# class Azerbaycan():
# def baskent(self):
# print("Bakü Azerbaycan Başkentidir... |
variant = ["_clear", "_scratched", "_crystal", "_dim", "_dark", "_bright", "_ghostly", "_ethereal", "_foreboding", "_strong"]
colors = ["white", "orange", "magenta", "light_blue", "yellow", "lime", "pink", "gray", "silver", "cyan", "purple", "blue", "brown", "green", "red", "black"]
for prefix in variant:
with open... |
[
{
'date': '2011-01-01',
'description': 'Nieuwjaarsdag',
'locale': 'nl-NL',
'notes': '',
'region': '',
'type': 'NF'
},
{
'date': '2011-04-22',
'description': 'Goede Vrijdag',
'locale': 'nl-NL',
'notes': '',
'region': ''... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
__author__ = 'liying'
class Latest(object):
def __init__(self):
self.package = None
self.latest_version = None
|
ES_HOST = 'localhost:9200'
ES_INDEX = 'pending-dgidb'
ES_DOC_TYPE = 'association'
API_PREFIX = 'dgidb'
API_VERSION = ''
|
class CSVUpperTriangularPlugin:
def input(self, filename):
infile = open(filename, 'r')
self.colnames = infile.readline().strip().split(',') # Assume rownames=colnames
self.ADJ = []
for line in infile:
self.ADJ.append(line.strip().split(',')[1:])
def run(self):
pas... |
"""
Python program to remove an empty element from a list.
"""
list_in = ['Hello', 34, 45, '', 40]
# result = ['Hello', 34, 45, 40]
for item in list_in:
if not item:
list_in.remove(item)
print(list_in) |
class GithubError(Exception):
pass
class GithubAPIError(GithubError):
pass
|
"""
if the number of petals is greater than the length of the list, reduce the number of petals by the length
loop though list, checking if the number of petals is greater than the length of the list
reduce the number of petals by the length of the list after every iteration until the number is less than or equal to
l... |
# Write a function to find the longest common prefix string amongst an array of strings.
class Solution(object):
def longestCommonPrefix(self, strs):
if len(strs) == 0:
return ""
standard = strs[0]
longest_length = len(standard)
for string in strs[1:]:
index ... |
# Copyright Notice:
# Copyright 2016-2019 DMTF. All rights reserved.
# License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/Redfish-Interface-Emulator/blob/master/LICENSE.md
# Redfish template
REDFISH_TEMPLATE = {
"@odata.context": "{rest_base}$metadata#Systems/cs_puid",
"@odata.id... |
class Solution:
def findMaxConsecutiveOnes(self, nums: List[int]) -> int:
consecutive = 0
ret = 0
for i in range(len(nums) + 1):
if i == len(nums) or nums[i] == 0:
ret = max(ret, consecutive)
consecutive = 0
else:
consec... |
""" Router memory information """
class Mem(object):
""" Router memory information """
def __init__(self, usage, total, hz, type):
self._usage = usage
self._total = total
self._hz = hz
self._type = type
def get_usage(self):
return self._usage
def get_total(se... |
def get_max_increasing_sub_sequence(arr):
i = 1
n = len(arr)
j = 0
dp = arr[:]
while i < n:
while j < i:
if dp[j] < dp[i] < dp[i] + dp[j]:
dp[i] = dp[j] + dp[i]
j += 1
i += 1
return max(dp)
if __name__ == '__main__':
# arr = [1, 101, ... |
# Author : BIZZOZZERO Nicolas
# Completed on Sun, 24 Jan 2016, 22:38
#
# This program find the solution of the problem 1 of the Project Euler.
# The problem is the following :
#
# If we list all the natural numbers below 10 that are multiples of 3 or
# 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
... |
# -*- coding: utf-8 -*-
########################################
# Created on Sun Feb 11 13:35:07 2018
#
# @author: guenther.wasser
########################################
#
# Problem 7:
# ----------
#
# Implement a function that meets the specifications below.
#
# def applyF_filterG(L, f, g):
# """
# Assum... |
# this file defines available actions
# reference: https://github.com/TeamFightingICE/FightingICE/blob/master/python/Feature%20Extractor%20in%20Python/action.py
class Actions:
def __init__(self):
# map digits to actions
self.actions = [
"NEUTRAL",
"STAND",
"FORWA... |
#!/usr/bin/python3
"""
implement strongly connected components algorithm using 'SCC.txt' adjusency
list.
Problem answer (first 5): [434821, 968, 459, 313, 211]
"""
|
'''
Created on 16-10-2012
@author: Jacek Przemieniecki
'''
class Mixture(object):
def _calc_groups(self):
self._groups = {}
groups = self._groups
tot_grps = 0
for mol in self.moles:
m_groups = self.moles[mol].get_groups()
for m_grp in m_groups:... |
extractable_regions = ["TextRegion",
"ImageRegion",
"LineDrawingRegion",
"GraphicRegion",
"TableRegion",
"ChartRegion",
"MapRegion",
"SeparatorRegion",
... |
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
""" Score handler
Score operation handler"""
class Score(object):
def __init__(self, kind):
""" init about importer
This module assume about import module.
Argument of 'kind' indicates the way of judging.
In __init__, dicide what ... |
"""Repository rule for ROCm autoconfiguration.
`rocm_configure` depends on the following environment variables:
* `TF_NEED_ROCM`: Whether to enable building with ROCm.
* `GCC_HOST_COMPILER_PATH`: The GCC host compiler path
* `ROCM_TOOLKIT_PATH`: The path to the ROCm toolkit. Default is
`/opt/rocm`.
* `TF_... |
# Copyright 2016 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... |
class Graph:
"""
The purpose of the class is to provide a clean way to define a graph for
a searching algorithm:
"""
def __init__(self):
self.edges = {} # dictionary of edges NODE: NEIGHBOURS
self.weights = {} # dictionary of NODES and their COSTS
self.herist={}
... |
#
# PySNMP MIB module RADLAN-DHCP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RADLAN-DHCP-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:01:12 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27... |
'''
+-------------------------+
¦ 34 ¦ 21 ¦ 32 ¦ 41 ¦ 25 ¦
+----+----+----+----+-----¦
¦ 14 ¦ 42 ¦ 43 ¦ 14 ¦ 31 ¦
+----+----+----+----+-----¦
¦ 54 ¦ 45 ¦ 52 ¦ 42 ¦ 23 ¦
+----+----+----+----+... |
# Crie um programa que leia um número inteiro e mostre na tela se ele é PAR ou ÍMPAR.
numero = int(input('Digite um número: '))
if numero % 2 == 0:
print('O número {} é \033[1;34mPar\033[m.'.format(numero))
else:
print('O número {} é \033[1;34mÍmpar\033[m.'.format(numero)) |
def lerp(a, b, amount):
return (amount * a) + ((1 - amount) * b)
def smoothstep(edge0, edge1, amount):
x = clamp((amount - edge0) / (edge1 - edge0), 0.0, 1.0)
return x * x * (3 - 2 * x)
def smootherstep(edge0, edge1, amount):
x = clamp((amount - edge0) / (edge1 - edge0), 0.0, 1.0)
return x ... |
# Time: O(n); Space: O(n)
def next_greater_element(nums1, nums2):
stack = []
d = {}
i = len(nums2) - 1
while i >= 0:
num = nums2[i]
if not stack:
d[num] = -1
stack.append(num)
i -= 1
elif stack[-1] > num:
d[num] = stack[-1]
... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
DEFAULT_HOST = '127.0.01'
DEFAULT_PORT = 3306
DEFAULT_USER_NAME = 'root'
DEFAULT_USER_PASS = 'root123'
DEFAULT_USER_LIST = 'accounts/user.list'
DEFAULT_WORD_LIST = 'accounts/word.list'
# text color in console |
# mock resource classes from peeringdb-py client
class Organization:
pass
class Facility:
pass
class Network:
pass
class InternetExchange:
pass
class InternetExchangeFacility:
pass
class InternetExchangeLan:
pass
class InternetExchangeLanPrefix:
pass
class NetworkFacility:
... |
class Player():
def __init__(self, name, start=False, ai_switch=False):
self.ai = ai_switch
self.values = {0:.5}
self.name = name
self.turn = start
self.epsilon = 1
|
CONFIG_FILE_PATH = 'TypeRacerStats/src/config.json'
ACCOUNTS_FILE_PATH = 'TypeRacerStats/src/accounts.json'
ALIASES_FILE_PATH = 'TypeRacerStats/src/commands.json'
PREFIXES_FILE_PATH = 'TypeRacerStats/src/prefixes.json'
SUPPORTERS_FILE_PATH = 'TypeRacerStats/src/supporter_colors.json'
UNIVERSES_FILE_PATH = 'TypeRacerSta... |
#
# PySNMP MIB module HP-ICF-VRRP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HP-ICF-VRRP-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:23:26 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27... |
def pytest_addoption(parser):
parser.addoption('--integration_tests', action='store_true', dest="integration_tests",
default=False, help="enable integration tests")
def pytest_configure(config):
if not config.option.integration_tests:
setattr(config.option, 'markexpr', 'not integration... |
class CountdownCancelAll:
def __init__(self):
self.symbol = ""
self.countdownTime = 0
@staticmethod
def json_parse(json_data):
result = CountdownCancelAll()
result.symbol = json_data.get_string("symbol")
result.countdownTime = json_data.get_int("countdownT... |
"""Contains all variable for custom scripts"""
ENVS = {
"staging": {
"app": "sparte-staging",
"region": "osc-fr1",
},
"prod": {
"app": "sparte",
"region": "osc-secnum-fr1",
},
}
|
def fn1(a,b):
print("Subtraction=",a-b)
def fn2(c):
print(c) |
#taking values through keyboard
a,b=[int(i) for i in input('enter two numbers:').split(',')]
if(a>b):
print(a,'is big')
elif(a<b):
print(b,'is big')
else:
print('both are equal')
#taking values directly
a=5
b=3
if(a>b):
print(a,'is big')
elif(b>a):
print(b,'is big')
else:
print('both are equa... |
# -*- coding: utf-8 -*-
# 这个文件是配置文件
# 手动搜索Appfilter并保存到本地(会覆盖下面的设置,若开启,下面全部内容失效,未开工)
mannualAppfilterMode = False
# 是否输入Iconpack.xml所需内容
needIconpackXml = True
# 是是否生成Drawable.xml所需内容
needDrawableXml = True
# 是否联网获取Appfilter.xml
needAppfilterXml = True
# 设置搜索结果上限(<=128)
# 对 index.py 和 getAppfilter.py 同时使用(LoopMode... |
"""This file holds the payload yaml validator/definition template."""
VALIDATOR = {
"specification": {
"type": dict,
"required": True,
"childs": {
"payload": {
"type": str,
"required": True,
"allowed": "^(cmd)$",
"c... |
# Define a python class to execute sequencial action during a SOT execution.
#
# Examples would be:
# attime(1800,lambda: sigset(sot.damping,0.9))
# attime(1920,lambda: sigset(sot.damping,0.1))
# attime(1920,lambda: pop(tw))
# attime(850,lambda: sigset(taskSupportSmall.controlGain,0.01))
# @attime(400)
# def action400(... |
def flatten(lst):
if lst:
car,*cdr=lst
if isinstance(car,(list,tuple)):
if cdr: return flatten(car) + flatten(cdr)
return flatten(car)
if cdr: return [car] + flatten(cdr)
return [car]
|
class Solution:
def threeSum(self, nums: List[int]) -> List[List[int]]:
res = []
nums.sort()
n = len(nums)
for i in range(n-2):
if i > 0 and nums[i] == nums[i-1]:
continue
j, k = i + 1, n - 1
while j < k:
_sum = nums... |
def min_rooms_required(intervals):
'''Returns the minimum amount of rooms necessary.
Input consists of a list of time-intervals (start, stop):
>>> min_rooms_required([(10, 20), (15, 25)])
2
>>> min_rooms_required([(10, 20), (20, 30)])
1
'''
# transform intervals
# [(10, 20), (15, 25... |
class Solution:
def removeCoveredIntervals(self, intervals: List[List[int]]) -> int:
intervals.sort(reverse=True,key=lambda x:(x[1],-x[0]))
# print(intervals)
slen = len(intervals)
count = slen
for i in range(slen-1):
# print(intervals[i],intervals[i+1])
... |
# 312. Burst Balloons
# Runtime: 8448 ms, faster than 44.62% of Python3 online submissions for Burst Balloons.
# Memory Usage: 19.9 MB, less than 38.33% of Python3 online submissions for Burst Balloons.
class Solution:
def maxCoins(self, nums: list[int]) -> int:
n = len(nums)
# Edge case
... |
## Implementation of a recursive fibonacci series. Extremely inefficient though.
## Author: AJ
class fibonacci:
def __init__(self):
self.number = 0
self.series = []
def fib_series(self, num):
if num <=2:
if 1 not in self.series:
self.series.append(1)
... |
my_list = [('apple', 'orange', 'banana', 'grape'), (1, 2, 3)]
for item in my_list:
for child in item:
print(child, end=' ')
else:
print('遍历结束') |
#inherits , extend , override
class Employee:
def __init__(self , name , age , salary):
self.name = name
self.age = age
self.salary = salary
def work(self):
print( f"{self.name} is working..." )
class SoftwareEngineer(Employee):
def __init__(self , name , age , salary , le... |
MODULE_CONTEXT = {'metadata':{'module':'ANUVAAD-NMT-MODELS'}}
def init():
global app_context
app_context = {
'application_context' : None
} |
class TestStackiBoxInfo:
def test_no_name(self, run_ansible_module):
result = run_ansible_module("stacki_box_info")
assert result.status == "SUCCESS"
assert result.data["changed"] == False
assert len(result.data["boxes"]) == 2
def test_with_name(self, run_ansible_module):
result = run_ansible_module("sta... |
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'Indian - Purchase Report(GST)',
'version': '1.0',
'description': """GST Purchase Report""",
'category': 'Accounting',
'depends': [
'l10n_in',
'purchase',
],
'data': ... |
# Dictionaries
# https://www.freecodecamp.org/learn/scientific-computing-with-python/python-for-everybody/python-dictionaries
# A collection of values each with their own key identifiers - like a java hashmap
ddd = dict()
ddd['age'] = 21
ddd['course'] = 182
print(ddd)
ddd['age'] = 27
print(ddd)
# Literals
jjj = {'nam... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2017, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# this is a windows documentation stub, actual code lives in the .ps1
# file of the same name
ANSIBLE_METADATA = {'metadata_version': '1.1',
... |
file = 'fer2018surprise.csv'
file_path = '../data/original/'+file
new_file_path = '../data/converted/'+file
num = 0
with open(file_path, 'r') as fp:
with open(new_file_path, 'w') as fp2:
num = num + 1
line = fp.readline()
while line:
lineWithCommas = line.replace(' ', ',')
... |
__author__ = 'BeyondSky'
class Solution:
def climbStairs_dp(self, n):
if n < 2:
return 1
steps = []
steps.append(1)
steps.append(2)
for i in range(2,n):
steps.append(steps[i-1] + steps[i-2])
return steps[n-1]
def main():
outer = Soluti... |
# Maximum Erasure Value
'''
You are given an array of positive integers nums and want to erase a subarray containing unique elements. The score you get by erasing the subarray is equal to the sum of its elements.
Return the maximum score you can get by erasing exactly one subarray.
An array b is called to be a suba... |
# class Queue(object):
# def __init__(self):
# """
# initialize your data structure here.
# """
# self.stack1 = []
# self.stack2 = []
#
#
# def push(self, x):
# """
# :type x: int
# :rtype: nothing
# """
# while len(self.stack1) > 0... |
# --------------------------------------------------------------
class ModelSimilarity:
'''
Uses a model (e.g. Word2Vec model) to calculate the similarity between two terms.
'''
def __init__( self, model ):
self.model = model
def similarity( self, ranking_i, ranking_j ):
sim = 0.0
pairs = 0
for term_i ... |
xs1 = ys[42:
5:
-1]
xs2 = ys[:
2:
3]
xs3 = ys[::
3]
|
# 1 - Faça um Programa que peça dois números e imprima o
# maior deles.
num1 = input("Digite um número: ")
num2 = input("Digite outro número: ")
if(num1 > num2):
print(f"O maior é {num1}")
else:
print(f"O maior é {num2}")
|
class Stack:
topNode = None
class Node:
def __init__(self, value):
self.value = value
self.nextNode = None
def __repr__(self):
return "[{}]".format(self.value)
def __init__(self, iterable):
if len(iterable) != 0:
for k... |
# Multicollinearity solution using VIF 26/6/19
def calculate_vif_(X, thresh=5.0):
"""
Linear variational inflation factor for multi-colinearity solutions
Removes colinear features with messages
X is patients by features DataFrame
Good idea to inspect the VIFs for all data and consider threshold c... |
'''
'''
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License");... |
class take_skip:
def __init__(self, step, count):
self.step = step
self.count = count
self.start = 0
self.end = step * count
def __iter__(self):
return self
def __next__(self):
index = self.start
if index >= self.end:
raise StopIteration
... |
class Solution:
def longestCommonPrefix(self, strs: List[str]) -> str:
if len(strs) == 0:
return ''
def getCommonPrefix(s1, s2):
result = []
for i in range(min(len(s1), len(s2))):
if s1[i] == s2[i]:
result.append(s1[i])
... |
n = int(input())
a = list(map(int, input().split()))
xor = a[0]
for x in a[1:]:
xor ^= x
ans = print(*[xor ^ x for x in a]) |
class DictTrafo(object):
def __init__(self, trafo_dict=None, prefix=None):
if trafo_dict is None:
trafo_dict = {}
self.trafo_dict = trafo_dict
if type(prefix) is str:
self.prefix = (prefix,)
elif type(prefix) is tuple:
self.prefix = prefix
... |
# Copyright 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Python port of legacy_unit_info.html. This is a mapping of various units
# reported by gtest perf tests to histogram units, including improvement
# directi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.