content stringlengths 7 1.05M |
|---|
class BouncingBall(object):
def __init__(self, x, y, dia, col):
self.location = PVector(x, y)
self.velocity = PVector(0, 0)
self.d = dia
self.col = col
self.gravity = 0.1
self.dx = 2
def move(self):
# self.location.x += self.dx
s... |
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
@content : ๅ
จๅฑๅ้้
็ฝฎๆจกๅ db.py, getter.py, tester.py, scheduler.py
@Author : ๅๅฅ็ฅๅ
@File : setting.py
@Software: PyCharm
"""
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโๅไธฝๅๅฒ็บฟโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# db.pyๆจกๅๅ
จๅฑๅ้ REDIS_HOST, REDI... |
# Copyright 2020 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 errors():
# ***********************************************************************
#
# SpcErr.h = (c) Spectrum GmbH, 2006
#
# ***********************************************************************
#
# error codes of the Spectrum drivers. Until may 2004 this file was
# errors.h. N... |
def get_data_odor_num_val():
# get data
odor = ''
data = []
with open('mushrooms_data.txt') as f:
lines = f.readlines()
for line in lines:
odor = line[10]
if odor == 'a': # almond
data.append(1)
elif odor == 'l': # anise
data.append(2)
... |
# This problem can be solved analytically, but we can just as well use
# a for loop. For a given shell of side n, the value at the top right
# vertex is given by the area, n^2. Moving anticlockwise, the values at
# the other vertex is always (n - 1) less than the previous vertex.
n_max = 1001
ans = 1 + sum(4*n... |
#Create a converter that changes binary numbers to decimals and vice versa
def b_to_d(number):
var = str(number)[::-1]
counter = 0
decimal = 0
while counter < len(var):
if int(var[counter]) == 1:
decimal += 2**counter
counter += 1
return decimal
def d_to_b(number):
binary = ''
while num... |
#file operations
with open('test.txt', 'r') as f:
#print('file contents using f.read()', f.read())
#print('file contencts using f.readlines()', f.readlines())
#print('file read 1 line using f.readline', f.readline())
print('read line by line, so that there is no memeory issue')
for line in f:
print(line, end = ... |
class Solution(object):
def combinationSum2(self, candidates, target):
"""
:type candidates: List[int]
:type target: int
:rtype: List[List[int]]
"""
candidates.sort()
return self.adding(candidates, 0, target, [])
def adding(self, candidates, startIndex, ... |
"""
This program asks the user for
1) the name of a text file
2) a line number
and prints the text from that line of the file.
"""
def main():
try:
# Get a filename from the user.
filename = input("Enter the name of text file: ")
# Read the text file specified by the user into a list.
... |
_base_ = [
'../../../_base_/datasets/fine_tune_based/few_shot_voc.py',
'../../../_base_/schedules/schedule.py', '../../tfa_r101_fpn.py',
'../../../_base_/default_runtime.py'
]
# classes splits are predefined in FewShotVOCDataset
# FewShotVOCDefaultDataset predefine ann_cfg for model reproducibility.
data = ... |
class LibraryException(Exception):
pass
class BookException(Exception):
pass
|
a,b=map(int,input().split())
if b==0 and a>0:
print("Gold")
elif a==0 and b>0:
print("Silver")
elif a>0 and b>0:
print("Alloy")
|
n = int(input())
h = int(input())
w = int(input())
print((n-h+1) * (n-w+1)) |
class custom_range:
def __init__(self, start: int, end: int) -> None:
self.start = start
self.end = end
def __iter__(self) -> iter:
return self
def __next__(self) -> int:
if self.start <= self.end:
i = self.start
self.start += 1
... |
ADD_USER_CONTEXT = {
"CyberArkPAS.Users(val.id == obj.id)": {
"authenticationMethod": [
"AuthTypePass"
],
"businessAddress": {
"workCity": "",
"workCountry": "",
"workState": "",
"workStreet": "",
"workZip": ""
},
"changePassOnNextLogon": True,
"componentUse... |
# Common training-related configs that are designed for "tools/lazyconfig_train_net.py"
# You can use your own instead, together with your own train_net.py
train = dict(
output_dir="./output",
init_checkpoint="detectron2://ImageNetPretrained/MSRA/R-50.pkl",
max_iter=90000,
amp=dict(enabled=False), # op... |
#------------------------------------------------------------------------------
# Copyright (c) 2013, Nucleic Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
#-----------------------------------------------------... |
"""
Base class for a projectile
"""
class CageProjectile(object):
"""
Simple projectile base class
"""
def __init__(self, world, projectileid):
self.world = world
self.projectileid = projectileid
def next(self):
"""
Progress the game state to the next tick.
"... |
s1 = "fairy tales"
s2 = "rail safety"
s1 = s1.replace(" ", "").lower()
s2 = s2.replace(" ", "").lower()
# Requires n log n time (since any comparison
# based sorting algorithm requires at least
# nlogn time to sort).
print(sorted(s1) == sorted(s2))
# The Preferred Solution
# This solution is of linear time complexi... |
model = Model()
i1 = Input("input", "TENSOR_QUANT8_ASYMM", "{4, 3, 2}, 0.8, 5")
axis = Parameter("axis", "TENSOR_INT32", "{4}", [1, 0, -3, -3])
keepDims = False
output = Output("output", "TENSOR_QUANT8_ASYMM", "{2}, 0.8, 5")
model = model.Operation("REDUCE_MAX", i1, axis, keepDims).To(output)
# Example 1. Input in op... |
def build_dataset(train_text):
words = list()
with open(train_text, 'r') as f:
lines = f.readlines()
for line in lines:
# line -> line.split('\t')[1]
sentence = line.split('\t')[1]
if sentence:
words.append(sentence)
with open('./total_na... |
#Your secret information. Make sure you don't tell anyone
secret_key = ''
public_key = ''
url='https://api.paystack.co/transaction'
|
print("ๆ่ฝไธญ100ไธ")
print("ๆ่ฝไธญ100ไธ")
print("ๆ่ฝไธญ100ไธ")
print("ๆ่ฝไธญ100ไธ")
print("ๆ่ฝไธญ100ไธ")
print("ๆ่ฝไธญ100ไธ")
print('ๅฏไปฅ๏ผๅๅๅๅ') |
class Solution:
def find132pattern(self, nums: List[int]) -> bool:
if len(nums) < 3:
return False
second_num = -math.inf
stck = []
# Try to find nums[i] < second_num < stck[-1]
for i in range(len(nums) - 1, -1, -1):
if nums[i] < second_num:
... |
class Logger:
# Logger channel.
channel: str
def __init__(self, channel: str):
self.channel = channel
def log(self, message):
print(f'\033[92m[{self.channel}] {message}\033[0m')
def info(self, message):
print(f'\033[94m[{self.channel}] {message}\033[0m')
def warning(s... |
#!/usr/bin/env python3
# ็จๆฐๅญ1 2 2 3 4 5 ่ฟๅ
ญไธชๆฐๅญ๏ผๅไธไธชmainๅฝๆฐ๏ผๆๅฐๅบๆๆไธๅ็ๆๅ๏ผ ไพๅฆ512234, 412345.
# ่ฆๆฑ4ไธ่ฝๅจ็ฌฌไธไฝ๏ผไธ3่ท5ไธ่ฝ็ธ้ป
# num_lis = [1, 2, 2, 3, 4, 5]
# res_set = []
# for i1 in num_lis:
# for i2 in [i for i in num_lis if i != i1]:
# for i3 in [i for i in num_lis if i not in [i1, i2]]:
# for i4 in [i ... |
r=' '
lista=list()
while True:
n=(int(input('digite um numero')))
if n in lista:
print('numero duplicado nao adicionado...')
r = str(input('quer continuar'))
else:
lista.append(n)
print('numero adicionado com sucesso.')
r=str(input('quer continuar'))
if r == 'n... |
# Almost any value is evaluated to True if it has some sort of content.
#
# Any string is True, except empty strings.
#
# Any number is True, except 0.
#
# Any list, tuple, set, and dictionary are True, except empty ones.
bool("abc")
bool(123)
bool(["apple", "cherry", "banana"])
|
# Distributed under the MIT software license, see the accompanying
# file LICENSE or https://www.opensource.org/licenses/MIT.
# List of words which are recognized in commands. The display_name method
# also recognizes strings between these words as own words so not all words
# appearing in command names have to be lis... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Python APRS Module Tests."""
__author__ = 'Greg Albrecht W2GMD <oss@undef.net>' # NOQA pylint: disable=R0801
__copyright__ = 'Copyright 2017 Greg Albrecht and Contributors' # NOQA pylint: disable=R0801
__license__ = 'Apache License, Version 2.0' # NOQA pylint: disab... |
data = {
"red": ((0.0, 0.0, 0.0), (1.0, 0.2, 0.2)),
"green": ((0.0, 0.0, 0.0), (1.0, 0.2, 0.2)),
"blue": ((0.0, 0.0, 0.0), (1.0, 1.0, 1.0)),
}
|
# create template
class DtlTemplateCreateModel:
def __init__(self, name, subject, html_body): # required fields
self.name = name
self.subject = subject
self.html_body = html_body
self.template_setting_id = None
self.unsubscribe_option = None
def get_json_object... |
ABSOLUTE_URL_OVERRIDES = {}
ADMINS = ()
ADMIN_FOR = ()
ADMIN_MEDIA_PREFIX = '/static/admin/'
ALLOWED_INCLUDE_ROOTS = ()
APPEND_SLASH = True
AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend',)
BANNED_IPS = ()
CACHES = {}
CACHE_MIDDLEWARE_ALIAS = 'default'
CACHE_MIDDLEWARE_KEY_PREFIX = ''
CACHE_MIDDL... |
"""
104.ไบๅๆ ็ๆๅคงๆทฑๅบฆ
ๆถ้ดๅคๆๅบฆ๏ผO(logn)
็ฉบ้ดๅคๆๅบฆ๏ผO(1)
"""
class TreeNode:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
def createTreeNode(node_list):
if not node_list[0]:
return None
root = TreeNode(node_list)
Nodes = [root]
j = 1
for node in... |
def load(h):
return ({'abbr': 0, 'code': 0, 'title': 'Visibility', 'units': 'm'},
{'abbr': 1, 'code': 1, 'title': 'Albedo', 'units': '%'},
{'abbr': 2, 'code': 2, 'title': 'Thunderstorm probability', 'units': '%'},
{'abbr': 3, 'code': 3, 'title': 'Mixed layer depth', 'units': 'm'}... |
IMAGE_PATH = "H:\Asu\mwdb\project-phase-0\CSE 515 Fall19 - Smaller Dataset\Phase-1\CSE 515 Fall19 - Smaller Dataset\Hand_0008110.jpg"
IMAGE_FOLDER = "H:\Asu\mwdb\project-phase-0\CSE 515 Fall19 - Smaller Dataset\images"
DATABASE_FOLDER = "H:\Asu\mwdb\project-phase-0\CSE 515 Fall19 - Smaller Dataset\Database\\"
METADA... |
def remove_duplicates(some_list):
return list(set(some_list))
def run():
random_list = [1,1,2,2,4]
print(remove_duplicates(random_list))
if __name__ == '__main__':
run() |
# -*- coding: utf-8 -*-
# Copyright (c) 2016, 2017, 2018, 2019 Sqreen. All rights reserved.
# Please refer to our terms for more information:
#
# https://www.sqreen.io/terms.html
#
__author__ = "Sqreen"
__copyright__ = "Copyright 2016, 2017, 2018, 2019, Sqreen"
__email__ = "contact@sqreen.io"
__license__ = "propri... |
class Word():
def __init__(self, text):
self.__text = text
def __eq__(self, word2):
return self.__text.lower() == word2.__text.lower()
def __str__(self):
'''
call once print(object of Word)
'''
return self.__text
def __repr__(self):
'''
... |
# Copyright 2017 Michael Blondin, Alain Finkel, Christoph Haase, Serge Haddad
# 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 requir... |
class Report(object):
def __init__(self):
self._packets_in_buffer = []
self._packet_wait_time = []
self._server_load = []
def update_state(self, packets_in_buffer, packet_wait_time, server_load):
self._packets_in_buffer.append(packets_in_buffer)
self._packet_wait_time.ap... |
# coding=utf-8
if __name__ == "__main__":
print("developing...") |
ITALY_CITIES = ['Roma', 'Milano']
GERMAN_CITIES = ['Berlin', 'Frankfurt']
US_CITIES = ['Boston', 'Los Angeles']
# Our restaurant is named differently in different
# in different parts of the world
def get_restaurant_name(city: str) -> str:
if city in ITALY_CITIES:
return "Trattoria Viafore"
if city i... |
"""easyNeuron is the simplest way to design, build and test machine learnng models.
Submodules
----------
easyneuron.math - The math tools needed for the module
easyneuron.neighbours - KNearest and other neighbourb based ML models
easyneuron.types - The custom types for the module
""" |
km = int(input('Quantos KM dura a viagem '))
if km < 200:
km_atualizado = km * 0.50
print("O valor da viagem รฉ R${:.2f} reais".format(km_atualizado))
else:
km_atualizado_maior = km * 0.45
print('O valor da viagem รฉ R${:.2f} reais'.format(km_atualizado_maior))
print("BOA VIAGEM") |
# Description: Imports needed for most uses of pymol in Jupyter. Combination of importPyMOL and importPythonDisplay.
# Source: placeHolder
"""
cmd.do('from pymol import cmd')
cmd.do('from IPython.display import Image')
cmd.do('from IPython.core.display import HTML')
cmd.do('PATH = "/Users/blaine/"')
"""
cmd.do('fro... |
training_data_hparams = {
'shuffle': False,
'num_epochs': 1,
'batch_size': 5,
'allow_smaller_final_batch': False,
'source_dataset': {
"files": ['data/iwslt14/train.de'],
'vocab_file': 'data/iwslt14/vocab.de',
'max_seq_length': 50
},
'target_dataset': {
'files'... |
def foo(x):
return x**2
def decorator(func):
def wrapper(*args, **kwargs):
print(func, args, kwargs)
return func(*args, **kwargs)
return wrapper
_decorated_funcs = defaultdict(lambda: [])
_applied_decorators = defaultdict(lambda: [])
def apply_decorator(func, decorator):
_decorated_fu... |
# Created by MechAviv
# ID :: [910150001]
# Frozen Fairy Forest : Elluel
sm.showEffect("Effect/Direction5.img/effect/mercedesInIce/merBalloon/8", 2000, 0, -100, 0, -2, False, 0)
sm.sendDelay(2000)
sm.setTemporarySkillSet(0)
sm.setInGameDirectionMode(False, True, False, False)
sm.progressMessageFont(3, 20, 20, 0, "Pr... |
print('Jรก atingiu a maior idade?')
x = 0
s = 0
for c in range(1, 8):
ano = int(input('Em que ano nasceu a {}ยช pessoa: '.format(c)))
if ano < 2003:
s = s + 1
print('Pessoas MAIORES de idade {} \nPessoas MENORES de idade {}'.format(s, 7 - s))
|
"""Constants for testing the Coinbase integration."""
GOOD_CURRENCY = "BTC"
GOOD_CURRENCY_2 = "USD"
GOOD_CURRENCY_3 = "EUR"
GOOD_EXCHNAGE_RATE = "BTC"
GOOD_EXCHNAGE_RATE_2 = "ATOM"
BAD_CURRENCY = "ETH"
BAD_EXCHANGE_RATE = "ETH"
MOCK_ACCOUNTS_RESPONSE = [
{
"balance": {"amount": "13.38", "currency": GOOD_C... |
#!/usr/bin/env python3
input = int(input())
def scores_after_n_receipes(n):
scores = [3, 7]
elfs_positions = [0, 1]
target_scores = n + 10
while len(scores) < target_scores:
new_receipe_score = 0
for i, pos in enumerate(elfs_positions):
new_receipe_score += scores[pos]
... |
# try:
# total = 1/0
# # this will not execute
# except Exception:
# total = 0
# print(total) # 0
# try:
# total = 1/0
# print("This will not show up.")
# except Exception:
# print("Exception was caught") # Exception was caught
# total = 0
# print(total) # 0
# num = input("What is a... |
# python 3
# -*- Coding:utf-8 -*-
class Fibo(object):
def __init__(self):
self.fibo_0 = 0
self.fibo_1 = 1
def fibo_top(self, n):
'''
่ทๅๅnไธชๆๆณข้ฃๅฅๆฐ
'''
fibo = [self.fibo_0, self.fibo_1]
for i in range(2, n):
# print(i)
fibo.append(fi... |
class ErroresLexicos():
'''
Parametros:
- Descripcion:str
Descripcion
- linea y columna:numeric
linea y columna
- clase origen:str
Sirve para decir en que clase del patron interprete trono
'''
def __init__(self, des... |
#
# PySNMP MIB module CISCO-PORT-CHANNEL-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-PORT-CHANNEL-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:09:40 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (d... |
if __name__ == '__main__':
na = int(input())
a = list(map(int,input().split()))
nb = int(input())
b = list(map(int, input().split()))
if len(a) == na and len(b) == nb:
set_a = set(a)
set_b = set(b)
symmetric_diff = list(set_a.symmetric_difference(set_b))
symmetric_d... |
"""Configurations for the RC car"""
PICAMERA_RESOLUTION_WIDTH = 640
PICAMERA_RESOLUTION_HEIGHT = 480
PICAMERA_RESOLUTION = (PICAMERA_RESOLUTION_WIDTH, PICAMERA_RESOLUTION_HEIGHT)
PICAMERA_FRAMERATE = 60
PICAMERA_WARM_UP_TIME = 2
BACK_MOTOR_DATA_ONE = 17
BACK_MOTOR_DATA_TWO = 27
BACK_MOTOR_ENABLE_PIN = 22
FRONT_MOTOR_... |
def tune(scale, acc_rate):
"""
tune: bool
Flag for tuning. Defaults to True.
tune_interval: int
The frequency of tuning. Defaults to 100 iterations.
Module from pymc3
Tunes the scaling parameter for the proposal distribution
according to the acceptance rate over the last tune_i... |
__author__ = "Dylan Hamel"
__version__ = "0.1"
__email__ = "dylan.hamel@protonmail.com"
__status__ = "Prototype"
|
budget = float(input())
season = input()
budget_spent = 0
destination = ""
place = ""
if budget <= 100:
if season == "summer":
budget_spent = budget * 0.30
destination = "Bulgaria"
place = "Camp"
else:
budget_spent = budget * 0.70
destination = "Bulgaria"
place ... |
"""ๆๅญๅๅบ็ค
ๆฐๅคๆๅญ้ข้ฃใฎๅคๅฎใกใฝใใ
ๆฐๅคๆๅญใงใใใใๅคๅฎใใ isnumeric
[่ชฌๆใใผใธ]
https://tech.nkhn37.net/python-isxxxxx/#_isnumeric
"""
print('=== isnumeric ===')
print('ไธไธไบๅ'.isnumeric())
print('0b0101'.isnumeric())
|
def ma_methode(x = 0, y = 0):
print(x,y)
a = 1
b = 2
ma_methode()
ma_methode(a)
ma_methode(a,b)
y = 10;
ma_methode(y)
ma_methode(y = 10) |
class TestSettings(object):
ETCD_PREFIX = '/config/etcd_settings'
ETCD_ENV = 'test'
ETCD_HOST = 'etcd'
ETCD_PORT = 2379
ETCD_USERNAME = 'test'
ETCD_PASSWORD = 'test'
ETCD_DETAILS = dict(
host='etcd',
port=2379,
prefix='/config/etcd_settings',
username='test',... |
def length_of_longest_substring(s):
l, r, max_len = 0, 0, 0
while r < len(s):
substring = s[l:r + 1]
max_len = max(max_len, len(substring))
if r + 1 < len(s) and s[r + 1] in substring:
l += 1
else:
r += 1
return max_len
def length_of_longest_subst... |
# ------------------------------
# 340. Longest Substring with At Most K Distinct Characters
#
# Description:
# Given a string, find the length of the longest substring T that contains at most k distinct characters.
# For example, Given s = โecebaโ and k = 2,
# T is "ece" which its length is 3.
#
# Version: 1.0
# 11/... |
def aoc(data):
total = 0
min, max = data.split("-")
for x in [str(x) for x in range(int(min), int(max))]:
inc = True
double = False
for i, d in enumerate(x[1:]):
if d < x[i]:
inc = False
break
for i, d in enumerate(x):
... |
def swap_case(s):
a=""
for i in range(len(s)):
if s[i].islower():
a=a+s[i].upper()
else:
a=a+s[i].lower()
return a
|
"""lista = []
for i in range(5):
valor = int(input('Digite um valor: '))
if i == 0 or valor > lista[-1]:
lista.append(valor)
print('Valor adicionado no final da lista...')
else:
posicao = 0
while posicao < len(lista):
if valor <= lista[posicao]:
li... |
expected_output = {
"backbone_fast": False,
"bpdu_filter": False,
"bpdu_guard": False,
"bridge_assurance": True,
"configured_pathcost": {"method": "short"},
"etherchannel_misconfig_guard": True,
"extended_system_id": True,
"loop_guard": False,
"mode": {
"rapid_pvst": {
... |
# -*- coding: utf-8 -*-
#
# michael a.g. aรฏvรกzis
# orthologue
# (c) 1998-2021 all rights reserved
#
class MixedComments:
"""
The mixed commenting strategy: both a block marker pair and an individual line marker
"""
# implemented interface
def commentBlock(self, lines):
"""
Create... |
class ComboBoxData(RibbonItemData):
"""
This class contains information necessary to construct a combo box in the Ribbon.
ComboBoxData(name: str)
"""
@staticmethod
def __new__(self, name):
""" __new__(cls: type,name: str) """
pass
Image = property(lambda self: obje... |
#
# @lc app=leetcode.cn id=669 lang=python3
#
# [669] ไฟฎๅชไบๅๆ็ดขๆ
#
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
# ้ๅฝ่ฐ็จ
# ๅๆ
ๅต่ฎจ่ฎบๆ น่็นๅผไธๅบ้ด[L,R]็ๅ
ณ็ณป
def trimBST(self, root: TreeNode, L: int, R: int) -> TreeNode:
try:
... |
f = open('pierwsze.txt', 'w')
for item in range(2,100+1):
for number in range(2,item):
if item % number == 0:
break
else:
f.write(str(item))
f.write(" ")
f.close() |
def maximo (a, b, c):
if a>b and a>c:
return a
elif b>a and b>c:
return b
elif c>b and c>a:
return c
else:
return a
x = int(input("primeiro numero"))
y= int( input("Segundo numero"))
z = int( input("terceiro numero"))
w=maximo(x,y,z)
print(w) |
#Grace Kelly 07/03/2018
#Exercise 5
#Read iris data set
#Print out four numerical values
#Decimal places aligned
#Space between columns
with open("data/iris.csv") as f:
for line in f:
print(line.split(',') [:4])
|
#
# PySNMP MIB module CISCOSB-rlIP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCOSB-rlIP-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:24:17 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar ... |
def run():
inicial = int(input('ยฟCuรกntas porciones de pizza ordenarรกs? '))
print('El repartidor de pizza llegรณ. Te trajรณ {} porciones de pizza.'.format(inicial))
consumidas = int(input('ยฟCuรกntas porciones de pizza han comido? '))
return print("Aรบn quedan {} porciones de pizza.".format(inicial - consumid... |
class Solution:
def isPalindrome(self, x: int) -> bool:
if x < 0:
return False
digits = []
while x:
digits.append(x % 10)
x = int(x / 10)
return digits == list(reversed(digits))
|
a = float(input())
b = float(input())
c = float(input())
d = float(input())
e = float(input())
f = float(input())
if a == 0 and b == 0 and c == 0 and d == 0 and e == 0 and f == 0:
print(5)
elif a * d == b * c and a * f != c * e:
print(0)
elif a == 0 and b == 0 and e != 0:
print(0)
elif c == 0 and d == 0 an... |
"""
Copyright (c) 2021 Anshul Patel
This code is licensed under MIT license (see LICENSE.MD for details)
@author: cheapBuy
"""
|
class Solution:
def sumOfDistancesInTree(self, n: int, edges: List[List[int]]) -> List[int]:
graph = collections.defaultdict(set)
for u, v in edges:
graph[u].add(v)
graph[v].add(u)
count = [1 for _ in range(n)]
ans = [0 for _ in range(n)]
def... |
#
# PySNMP MIB module RFC1215-MIB (http://pysnmp.sf.net)
#
( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString")
( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
( ConstraintsUnion, SingleValueConstraint, ConstraintsInt... |
# Deleting tuples
my_tuple = ('p', 'r', 'o', 'g', 'r', 'a', 'm', 'i', 'z')
# can't delete items
# TypeError: 'tuple' object doesn't support item deletion
# del my_tuple[3]
# Must delete an entire tuple
del my_tuple
# NameError: name 'my_tuple' is not defined
print(my_tuple)
|
class Solution:
def largestSumAfterKNegations(self, A: List[int], K: int) -> int:
heapq.heapify(A)
for _ in range(K):
val = heapq.heappop(A)
heapq.heappush(A, -val)
return sum(A) |
# Category description for the widget registry
NAME = "SRW ESRF Extension"
DESCRIPTION = "Widgets for SRW"
BACKGROUND = "#969fde"
ICON = "icons/esrf2.png"
PRIORITY = 204
|
price = 1000000
has_good_credit = True
if has_good_credit:
down_payment = 0.1 * price
else:
down_paymet = 0.2 * price
print(f"Down Payment: ยฃ{down_payment}") |
San_Francisco_polygon = [[37.837174338616975,-122.48725891113281],[37.83364941345965,-122.48485565185547],[37.83093781796035,-122.4814224243164],[37.82415839321614,-122.48004913330078],[37.8203616433087,-122.47970581054688],[37.81059767530207,-122.47798919677734],[37.806122091729485,-122.47627258300781],[37.79215110146... |
class EmptyQueueError(Exception):
pass
class DualStructureError(Exception):
pass
class ConservativeVolumeError(Exception):
pass
class PmsFluxFacesError(Exception):
pass
|
# -*- coding: utf-8 -*-
#
# michael a.g. aรฏvรกzis
# orthologue
# (c) 1998-2021 all rights reserved
#
class Leaf:
"""
Mix-in class that provides an implementation of the subset of the interface of {Node} that
requires traversals of the expression graph rooted at leaf nodes.
"""
# interface
@pr... |
dias = int(input('Digite os dias: ')) * 60 * 60 * 24
horas = int(input('Digite as horas: ')) * 60 * 60
minutos = int(input('Digite os minutos: ')) * 60
segundos = int(input('Digite os segundos: '))
print ('O total dias em segundos: %d' % dias)
print ('O total de horas em segundos: %d' % horas)
print ('O total d... |
def apply_formatting_options(func):
def wrapper(self, *args, **kwargs):
type_config_dict = getattr(self, 'type_config_dict')
supplied_key = args[0]
supplied_value = args[1]
anonymized_value = func(self, supplied_key, supplied_value)
if type_config_dict.get('upper'):
... |
# nlantau, 2021-02-01
a1 = [-1,5,10,20,28,3]
a2 = [26,134,135,15,17]
sample_output = [28,26]
def smallestDifference_passed7outof10(a, b):
a.sort()
b.sort()
res = list()
for i in a:
t = max(a) + max(b)
for j in b:
if abs(j-i) < t:
t = abs(j-i)
... |
# coding: utf-8
"""
av-website
~~~~~~~~
App deployable on GAE, configured and customised with Bootstrap, Flask.
Copyright (c) 2015 by Tiberiu CORBU.
License MIT, see LICENSE for more details.
"""
__version__ = '3.3.4'
|
if __name__ == "__main__":
result = 1
for i in range(100):
result *= i + 1
result = str(result)
res = 0
for i in result:
res += int(i)
print("100! = ", res, "\n")
|
name = 'therm_PRF.dat'
fin = open(name,'r')
fout = open(name+'_upper','w')
for line in fin:
fout.write(line.upper())
|
mozilla = [
'Mozilla/5.0 (Windows; U; Windows NT 6.1; rv:2.2) Gecko/20110201',
'Mozilla/5.0 (Windows; U; Windows NT 6.1; it; rv:2.0b4) Gecko/20100818',
'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a3pre) Gecko/20070330',
'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9.2a1pre) Gecko',
'Mozi... |
n1 = int(input("Digite um nรบmero: "))
print("{} x {} = {}" .format(n1,1,n1*1))
print("{} x {} = {}" .format(n1,2,n1*2))
print("{} x {} = {}" .format(n1,3,n1*3))
print("{} x {} = {}" .format(n1,4,n1*4))
print("{} x {} = {}" .format(n1,5,n1*5))
print("{} x {} = {}" .format(n1,6,n1*6))
print("{} x {} = {}" .format(... |
class TicTacToe:
def __init__(self, n: int):
"""
Initialize your data structure here.
"""
self.col = [0] * n
self.row = [0] * n
self.n = n
self.diag, self.anti = 0, 0
def move(self, row: int, col: int, player: int) -> int:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.