content stringlengths 7 1.05M |
|---|
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#---------------------------------------------------------------------------
#
# Author: lubo
# E-mail: 454331202@qq.com
# LastModified: 2014-05-23 11:18:31
# Filename: gl.py
# Desc:
#
#---------------------------... |
# @Fábio C NUnes
# Crie um programa que leia o nome de uma cidade e diga se ela começa ou não com o nome 'Santo'.
cidade = str(input('Escreva o nome da cidade: ')).lower().strip()
i = 'santo' in (cidade)
y = ' ' in (cidade[5])
z = i and y == True
print(z)
|
# AUTOGENERATED BY NBDEV! DO NOT EDIT!
__all__ = ["index", "modules", "custom_doc_links", "git_url"]
index = {"display": "00_core.ipynb",
"Markdown": "00_core.ipynb",
"Audio": "00_core.ipynb",
"first_run": "00_core.ipynb",
"beep": "00_core.ipynb",
"h1": "00_core.ipynb",
... |
#17/02/21
#What does this code do?
# This code takes an input "n" and counts out until that number is reached.
# This works similarly to the previous code, except with numbers.
n = int(input('Enter a number: '))
for i in range(n):
print(i + 1)
#What is happening here?
# In line 1, our code is taking an... |
# Enter your code here. Read input from STDIN. Print output to STDOUT
n=int(input())
strarr=[]
for x in range(n):
strin=input()
strarr.append(strin)
stradd=set(strarr)
print(len(stradd))
|
'''
580C. Kefa and Park
dfs and similar, graphs, trees, 1500
http://codeforces.com/problemset/problem/580/C
'''
n, m = map(int, input().split())
cat = 1
empty = 0
status = [-1] + list(map(int, input().split()))
tree = {}
for _ in range(n-1):
s, e = map(int, input().split())
if s not in tree:
tree[s] = ... |
""" Practice Binary Search """
def binary_search(array, target):
mid = len(array) // 2
high = len(array) - 1
print("high", high)
low = 0
while low <= high:
mid = int((low+high)) // 2
print("mid", mid)
print('mid element', array[mid])
if array[mid] == target:
... |
# https://adventofcode.com/2021/day/14
test = "2021-14_sample.txt"
run = "2021-14_input.txt"
def part1(fname):
template = None
inserts = {}
for i, line in enumerate(open(fname)):
if i == 0:
template = line.rstrip()
elif line[2:6] == ' -> ':
inserts[line[0:2]] = line... |
'''
Created on 11 Dec 2021
@author: laurentmichel
'''
class MappingException(Exception):
pass
class ParsingException(Exception):
pass
class NotImplementedException(Exception):
pass
|
_base_ = [
'../_base_/models/dla34up_lane.py',
'../_base_/datasets/bdd100k_lane.py',
'../_base_/schedules/bdd100k_lane_12e.py',
'../_base_/default_runtime.py'
]
|
class Solution(object):
def totalHammingDistance(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
total, l = 0, len(nums)
for i in range(0, 32):
bit_count = 0
for num in nums:
bit_count += (num >> i) & 1
total... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2021/1/3 14:32
# @Author : cendeavor
# @File : basic_mapper.py
# @Software: PyCharm
class BasicMapper:
@staticmethod
def stats_collection(db, cname, key=None):
"""集合统计函数
返回集合的一些基本统计数据,比如count之类
Args:
db: 目标... |
# -*- coding: utf-8 -*-
"""This code is a part of Hydra Toolkit
.. module:: hydratk.extensions.datagen.translation.cs.help
:platform: Unix
:synopsis: Czech language translation for Datagen extension help generator
.. moduleauthor:: Petr Rašek <bowman@hydratk.org>
"""
language = {
'name': 'Čeština',
'IS... |
class ColumnLayer(tf.keras.layers.Layer):
def __init__(
self,
upstream_dim,
num_column_instances,
position_dim,
context_fan_in,
context_num_samples,
context_initial_sharpness,
train_context,
noise_rate,
bypass_rate,
):
super... |
###################
# COLOR CONSTANTS
###################
HEADER = '\033[95m'
OK_BLUE = '\033[94m'
OK_GREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
###########################
# ERROR MESSAGES CONSTANTS
###########################
BASE_ERROR_MSG = '\... |
def copyFile():
with open('test.txt') as file:
content = file.read()
with open('anotherTest.txt', 'w') as file:
file.write(content)
copyFile() |
#!/usr/bin/env python3
# Day 10: Excel Sheet Column Number
#
# Given a column title as appear in an Excel sheet, return its corresponding
# column number.
# A = 1
# B = 2
# C = 3
# ...
# Z = 26
# AA = 27
# AB = 28
# ...
class Solution:
def titleToNumber(self, s: str) -> int:
# In other words, convert from... |
class MissingValueError(ValueError):
pass
class ValidationError(ValueError):
pass
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 21 20:59:18 2021
@author: anelmusic
"""
def train_model(model, train_ds, val_ds, epochs, batch_size, num_train_imgs, num_val_imgs, optimizer, metrics, loss):
model.compile(loss=loss, optimizer=optimizer, metrics=metrics)
steps_per_epoch =nu... |
def leiaInt(msg):
n = (input(msg))
while n.isalpha() or n == '':
print('\033[0;31mERRO! Digite um número inteiro válido.\033[m')
n = (input(msg)).lstrip()
return n
n = leiaInt('Digite um número: ')
print(f'Voce acabou de digitar o número {n}.')
|
class AImodel:
def __init__(self):
pass
def process(self,input):
return -1 |
# 一串字符串(string)是字符(characters)的序列(sqquence)。基本上,字符串就是一串词汇。
# 主要有单引号,双引号和三引号。引号的开始和结束必须是相同类型。
# ''
# ""
# """ or ''' 主要用来指定多行的字符串
# print ('test')
#
# print("test")
#
# abc = '''
# Today is Aug 16 2018. I's a bad day.
#
# I miss you.
#
# What are you doing now?
#
# '''
#
# print(abc)
# \ 续行符,一般用于句尾
# x = "Python i... |
#Factorial digit sum
#Recursive funtion to calculate
def factorial(num):
#For negative numbers 0 or 1 will return 1
if num <= 1:
return 1
else:
#If num is greater than 1 multiply num by num-1 recursively until it returns 1(lowest value)
return num * factorial(num-1)
#Ask user to inp... |
class Solution:
def minRefuelStops(self, target, startFuel, stations):
"""
:type target: int
:type startFuel: int
:type stations: List[List[int]]
:rtype: int
"""
# dp[i] means maximum distance with ith refuel
n = len(stations)
dp = [startFuel] ... |
class Solution:
def countGoodTriplets(self, arr: List[int], a: int, b: int, c: int) -> int:
n = len(arr)
cnt = 0
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
cnt += abs(arr[i] - arr[j]) <= a and abs(arr[j] - arr[k]) <=... |
"""
3, 6, 7, 11, H=8
4 4. 4. 4
1 2. 2. 3 sum()=8
34567
FTTTT
[30,11,23,4,20], H = 5
29,30,31
F. T. T
Input: piles = [3,6,7,11], H = 8
3,6,7,11
3
6
1 1
45678
FFTTT
30,11,23,4,20
30
1. 1. 1. 1. 1
5T
29
2. 1. 1 1. 1
6 F
"""
class Solution:
def minEatingSpeed(self, piles: List[int], H: int) -> int:
... |
"""*****************************************************************************
* Copyright (C) 2019 Microchip Technology Inc. and its subsidiaries.
*
* Subject to your compliance with these terms, you may use Microchip software
* and any derivatives exclusively with Microchip products. It is your
* responsibility to ... |
def intdiv(a, b):
return a // b
if __name__ == "__main__":
print("Hi, I can calculate the integer division of two numers")
a = int(input("a = "))
b = int(input("b = "))
print(f"a // b = {intdiv(a, b)}")
print("Bye!")
|
class Solution(object):
def combinationSum(self, candidates, target):
"""
:type candidates: List[int]
:type target: int
:rtype: List[List[int]]
"""
q = [(target, [])]
candidates = sorted(candidates)
result = []
while q:
num, history... |
def power_consumption():
pass
def deadlines():
pass
def idle_cranes():
pass
def idle_machines():
pass
def buffer_usage():
pass
def material_pickup():
pass
|
def get_package_data():
return {
_ASTROPY_PACKAGE_NAME_
+ ".tests": [
"coveragerc",
"data/*.h5",
"data/*.dat",
"data/*.npy",
"integration_tests/*/*.yml",
"integration_tests/*/*.dat",
]
}
|
# Funções
def tamanho(sequencia):
cont = 0
for _ in sequencia:
cont += 1
return cont
def contar(sequencia, valor):
cont = 0
for x in sequencia:
if x == valor:
cont += 1
return cont
def somar(sequencia):
soma = 0
for x in sequencia:
soma += x
ret... |
#
# Exercism.io
# Python track
# Problem #1 - Hello World
# github.com/marnovo/Exercism
#
name = input("Tell your name: ")
def hello(name=''):
if name == '':
message = "Hello, World!"
else:
message = "Hello, " + name + "!"
return message
print(hello(name))
|
# EXERCÍCIO 2
# Faça um programa que leia o nome de uma pessoa e mostra uma mensagem de boas vinda.
nome = input('Digite o seu nome: ')
# print('Modelo 1')
print('É um prazer te conhecer, {}!'.format(nome))
# print('Modelo 2')
# print('É um prazer te conhecer, '+ nome)
|
#Challenge042
v1 = float(input(' medida 1: '))
v2 = float(input(' medida 2: '))
v3 = float(input(' medida 3: '))
#if v1+v2+v3 == 180:
if v1 == v2 == v3:
print('Triangulo equilatero: com todos os lados iguais')
elif (v1 == v2 or v3) and (v2 == v1 or v3 ):
print('tringulo isoceles dois lados iguais')
elif (v1 != ... |
# -*- coding: UTF-8 -*-
##############################################################################
# #
# Copyright (c) 2007-2010 Bernd Kreuss <prof7bit@gmail.com> #
# ... |
# @Title: 最长湍流子数组 (Longest Turbulent Subarray)
# @Author: KivenC
# @Date: 2020-07-15 15:29:06
# @Runtime: 612 ms
# @Memory: 17.7 MB
class Solution:
def maxTurbulenceSize(self, A: List[int]) -> int:
n = len(A)
if n < 2:
return 1
up, down, res = 1, 1, 1
for i in range(1, ... |
# Copyright (c) 2018 PaddlePaddle 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 app... |
def isDigit(symbol):
'''
Determine if the given character is a digit or not.
'''
return symbol.isdigit()
|
ash_pokedex = ['Pikachu',
'Bulbasaur',
'Koffing',
'Spearow',
'Vulpix',
'Wigglytuff',
'Zubat',
'Rattata',
'Psyduck',
'Squirtle']
brock_pokedex = ['Onix',
'Geodude',
'Zubat',
'Golem',
'Vulpix',
'Tauros',
'Kabutops',
'Omastar',
'Machop',
'Dugtrio']
# Convert Brock's Pokédex to a set
brock_pokedex_set ... |
a = list(" " * 9)
step = 0
def printgame():
print('-' * 9)
for i in range(3):
print("| {} {} {} |".format(a[0 + 3 * i], a[1 + 3 * i], a[2 + 3 * i]))
print('-' * 9)
while " " in a:
playx, playy = input("Enter the coordinates:").split()
if (int(playx) or int(playy)) not in [0, 1, 2, 3, 4, 5,... |
#!/usr/bin/python3
def new_in_list(my_list, idx, element):
list1 = my_list.copy()
leng = len(my_list)
if idx < 0:
return list1
if idx >= leng:
return list1
list1[idx] = element
return list1
|
'''
Leap year is an year with 366 days. Leap Year should be divisible by 4.
Also it should be divisible by 400 and not divisible by 100.
'''
def checkLeapYear(year):
if year % 400 == 0:
return 1
if year % 100 == 0:
return 0
if year % 4 == 0:
return 1
return 0
year1 = int(inp... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def Eq(field, value):
return {'_field': field, '_value': value}
def Gt(field, value):
return {'_gt': {field: value}}
def Gte(field, value):
return {'_gte': {field: value}}
def Lt(field, value):
return {'_lt': {field: value}}
def Lte(field, value):
... |
class LinkNodeIter:
def __init__(self, link):
self._link = link
def __iter__(self):
return self
def __next__(self):
next_value = self._link
if next_value is not None:
self._link = next_value.next_link
else:
raise StopIteration
return... |
class Solution:
def minTimeToVisitAllPoints(self, points: List[List[int]]) -> int:
count = 0
for index in range(len(points)-1):
count += max(abs(points[index][0]-points[index+1][0]), abs(points[index][1]-points[index+1][1]))
return count
|
async def db_get(db, query, **parameters):
async with db.execute(query, parameters) as cursor:
async for row in cursor:
yield dict(row)
async def db_get_one(db, column, query, **parameters):
async for row in db_get(db, query, **parameters):
return row.get(column, None)
else:
... |
#!/usr/bin/env python3
while True:
n = int(input('Quer ver a tabuada de qual número ? <número negativo para parar>'))
print('-'*30)
if n < 0:
break
for c in range (1, 11):
print(f'{n} x {c} = {n*c}')
print('-'*30)
print('PROGRAMA TABUADA ENCERRADO ! Volte sempre !') |
def test_line_highlight_fragments(test_env):
slide = test_env.slide
img = test_env.data_path("testimage.svg")
slide.image(img)
b = slide.box(x="[90%]", y="[30%]", width="30%", height="30%", show="4+")
b.rect("black", bg_color="white")
b2 = b.box(width="fill")
b2.update_style("default", si... |
red = "#c91111"
orange = "#e09401"
pale_blue = "#13aed5"
dark_blue = "#1321d8"
purple = "#642197"
|
"""Wagtail Live Exceptions."""
class RequestVerificationError(Exception):
pass
class WebhookSetupError(Exception):
pass
|
# -*- coding: UTF-8 -*-
logger.info("Loading 8 objects to table lists_list...")
# fields: id, ref, designation, list_type, remarks
loader.save(create_lists_list(1,None,['Announcements', 'Ank\xfcndigungen', 'Announcements'],1,u''))
loader.save(create_lists_list(2,None,['Weekly newsletter', 'Weekly newsletter', 'Weekly n... |
if __name__ == '__main__':
N = int(input())
elements = []
posicion = ""
dato = ""
for i in range(N):
commands = input()
longitud = len(commands)
if commands[0:6] == "insert" :
if(commands[8] == " "):
posicion = commands[7]
dato = c... |
IMG_HEIGHT = 480
IMG_WIDTH = 640
CLASS_NUM = 3
ANCHORS_GROUP = {
32:[[730,145],[288,190],[216,540]],
16:[[365,73],[144,95],[108,270]],
8:[[180,37],[72,44],[54,135]]
}
ANCHORS_GROUP_AREA = {
32: [x * y for x, y in ANCHORS_GROUP[32]],
16: [x * y for x, y in ANCHORS_GROUP[16]],
8... |
def devedor(*args):
try:
telaDevedores = args[0]
telaErro = args[1]
cursor = args[2]
banco10 = args[3]
data = args[4]
id = telaDevedores.codigo.text()
sql = ("select id from gerenciarPedido where id = %s and dataa = %s")
values = (id, data)
cu... |
name1_0_0_0_1_1_0 = None
name1_0_0_0_1_1_1 = None
name1_0_0_0_1_1_2 = None
name1_0_0_0_1_1_3 = None
name1_0_0_0_1_1_4 = None |
LOCATIONemojis = {
"fastbackwards": "<:fast_forward_left:870781340692402226>",
"backwards": "<:left_arrow:870781340990197860>",
"close": "<:Cross:863313854069997578>",
"forwards": "<:right_arrow:870781340314898473>",
"fastforwards": "<:fast_forward_right:870781340839202837>",
}
COGemojis = {
"Je... |
#!/usr/local/bin/python
# Think Like a Programmer Chapter 2: Pure Puzzles exercises
def main():
test_pound_shapes = False
test_base_conversion = True
if test_pound_shapes:
poundV()
print()
poundDiamond()
if test_base_conversion:
tests = [
# [1, 1, 2, 1], ... |
class Table(object):
def __init__(self):
self.rows = []
def to_ascii_table(self):
if not self.rows:
return ""
lines = []
def print_row(row):
line = ""
for column, l in zip(row, lens):
if column is None:
s... |
class DeviceSelectCredential:
def __init__(self, number):
pass
def __call__(self, status):
pass
|
expected_output={
"rlist_id": {
"0xf0001ae8": {
"flags": "0x0",
"packets": 38793,
"pps": 0,
"remote_ifs": 0,
"state": 1,
"status": "OK"
},
"0xf0001ae9": {
"flags": "0x0",
"packets": 0,
"pps": 0,
"remote_ifs": 0,
"state": 1,
... |
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
v = self.gf(l1) + self.gf(l2)
ll = ListNode(str(v)[::-1][0])
t = ll
for i in str(v)[::-1][1:]:
t.nex... |
def get_fs(client):
"""Return the db containing file system metadata.
Parameters
----------
client --> pymongo.mongo_client.MongoClient class, MongoDB client
Returns
-------
metadatafs['fs'] --> pymongo.collection.Collection, reference to collection fs
"""
#get the MongoDb ... |
"""BLE/LSL interfacing parameters for specific devices.
TODO:
* Simple class (or specification/template) for device parameters
"""
|
file = open('rosalind_cons.txt', 'r')
target = file.read()
d_list = []
class DNAcon:
def __init__(self):
self.A = 0
self.C = 0
self.G = 0
self.T = 0
def add_A(self, value):
self.A += value
def add_C(self, value):
self.C += value
def add_G(self, value... |
x1, y1 = list(map(int, input().split()))
x2, y2 = list(map(int, input().split()))
x3, y3 = list(map(int, input().split()))
x4 = 0
y4 = 0
if x1 == x2:
x4 = x3
elif x2 == x3:
x4 = x1
else:
x4 = x2
if y1 == y2:
y4 = y3
elif y2 == y3:
y4 = y1
else:
y4 = y2
print("{0} {1}".format(x4, y4))
|
# -*- coding: utf-8 -*-
"""
longboxed.comics
~~~~~~~~~~~~~~~~
longboxed comics package
""" |
def non_repeating(data):
state = dict()
for i in data:
if i not in state:
state[i] = 1
else:
state[i] = state[i] + 1
for i in data:
if state[i] == 1:
return i
return None
if __name__ == "__main__":
print(non_repeating("aaabbcdde"))
... |
# Databricks notebook source
# MAGIC %md # CCU002_02-D01-event_counts
# MAGIC
# MAGIC **Description** This notebook calculates the number of primary events from HES and death records for events.
# MAGIC
# MAGIC **Author(s)** Venexia Walker, Tom Bolton
# COMMAND ----------
# MAGIC %md ## Define functions
# COMMAND ... |
"""
Q1 Program to find max from 5 numbers
"""
'''
#way1
max = 0
list = [100,20,15,500,5]
for i in range (0,5):
if max < list[i]:
max =list[i]
print('Max no out of list is',max)
'''
#while list[0] == list[-1]: # list[-1] helps you get the last element of the list
'''
#Way 2
max = 0
list = [100, 20, 15, 500, 5]
i... |
# 200090310
sm.warp(200000141, 0)
sm.dispose()
|
'''
1) Implement the Node class to create
a binary search tree. The constructor
should initialize values 'data', 'left',
and 'right'.
2) Implement the 'insert' method for the
Node class. Insert should accept an argument
'data', then create a new node at the appropriate
location in the tree.
3) Implement the 'contains... |
NO_SUCH_OPTION_ERROR_TEMPLATE = "Error: no such option: {}"
NO_SUCH_COMMAND_ERROR_TEMPLATE = "Error: No such command \"{}\""
MISSING_COMMAND_ERROR_TEMPLATE = "Error: Missing command."
|
matriz2 = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
spar = scol = 0
for l in range(0, 3):
for c in range(0, 3):
matriz2[l][c] = int(input(f'Digite um valor para a posição {l,c}: '))
print('='*50)
for l in range(0, 3):
for c in range(0, 3):
print(f'[{matriz2[l][c]:^5}]', end='')
if matriz2[l][c] ... |
property_value_alias_age_long_to_short = {
"Unassigned": "NA",
"V10_0": "10.0",
"V11_0": "11.0",
"V12_0": "12.0",
"V12_1": "12.1",
"V13_0": "13.0",
"V1_1": "1.1",
"V2_0": "2.0",
"V2_1": "2.1",
"V3_0": "3.0",
"V3_1": "3.1",
"V3_2": "3.2",
"V4_0": "4.0",
"V4_1": "4.... |
""" The BaseGem class is the framework for all gems and fusions.
Base Gem holds all the stats of a gem or fusion in a dict, this dict is
modified through helper funcitons, these functions also return the end value.
Eventually we might keep ability functions here as well. We are still
utilizing child classes.
"""
... |
def fib(num):
output = [1,1]
before_previous_num = 1
previous_num = 1
for i in range(1,num+1):
new_num = before_previous_num + previous_num
output.append(new_num)
before_previous_num = previous_num
previous_num = new_num
nth = output[num-1]
return nth
'''
P... |
class Score:
def __init__(self):
self.score = 0
def get_score_text(self):
score_text = f"Score: {self.score}"
return score_text
def add_score(self, points):
self.score += points
|
# -*- coding: utf-8 -*-
""" Default Constants Used for the Australian Senate Election Audit. """
# The modes in which to run the senate election audit.
SIMULATION_MODE = 'simulation'
QUICK_MODE = 'quick'
REAL_MODE = 'real'
# The Australian states with senate election data available to audit.
STATES = [
'ACT',
... |
data = (
'k', # 0x00
'kh', # 0x01
'g', # 0x02
'gh', # 0x03
'ng', # 0x04
'c', # 0x05
'ch', # 0x06
'j', # 0x07
'jh', # 0x08
'ny', # 0x09
'nny', # 0x0a
'tt', # 0x0b
'tth', # 0x0c
'dd', # 0x0d
'ddh', # 0x0e
'nn', # 0x0f
'tt', # 0x10
'th', # 0x11
'd', # 0x12
'dh', ... |
def user_url():
"""this fuction is used to take the username as input,
then generate the profile url
Returns:
[string] -- [profile url]
"""
username = input("enter the username - ")
url = "https://www.instagram.com/{}/".format(username)
return url |
class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
def helper(ans, res, nums):
if not nums:
ans.append(res[:])
else:
element = nums.pop()
helper(ans, res, nums)
res.append(element)
... |
#!/usr/bin/env python3
# imports go here
#
# Free Coding session for 2015-03-31
# Written by Matt Warren
#
def foo():
print("completely out of ideas")
if __name__ == "__main__":
foo()
|
"""Advent of Code Day 13 - Packet Scanners"""
def severity(layers, delay):
"""Calculate cost of getting caught when traversing a Firewall."""
layers_list = layers.strip().split('\n')
severity = 0
for layer in layers_list:
layer_parts = (str(layer).split(':'))
layer_num = int(layer_par... |
# see https://www.codewars.com/kata/5ba38ba180824a86850000f7/solutions/python
def solve(arr):
i = 0
while i < len(arr):
if arr.count(arr[i]) > 1:
arr.pop(i)
else:
i+= 1
return arr
print(solve([3,4,4,3,6,3]) == [4,6,3])
print(solve([1,2,1,2,1,2,3]) == [1,2,3])
print(solve([1,2,3,4]) == [1,2,3... |
"""Given two numbers and an arithmetic operator (the name of it, as a string),
return the result of the two numbers having that operator used on them.
a and b will both be positive integers, and a will always be the first number in the operation,
and b always the second.
The four operators are "add", "subtract", "div... |
class Solution(object):
def fractionToDecimal(self, numerator, denominator):
"""
:type numerator: int
:type denominator: int
:rtype: str
"""
ans = "-" if numerator * denominator < 0 else ""
numerator = abs(numerator)
denominator = abs(denominator)
... |
# __init__.py/Open GoPro, Version 2.0 (C) Copyright 2021 GoPro, Inc. (http://gopro.com/OpenGoPro).
# This copyright was auto-generated on Wed, Sep 1, 2021 5:05:46 PM
"""Demos to show how to use Open GoPro package"""
|
FPS = 60
SCREEN_WIDTH = 1300
SCREEN_HEIGHT = 800
ground_height = SCREEN_HEIGHT // 6
ground_rect = ((0, SCREEN_HEIGHT - ground_height),
(SCREEN_WIDTH, SCREEN_HEIGHT))
menu_font_size = min(SCREEN_WIDTH, SCREEN_HEIGHT) // 18
num_of_evil_clouds = 15
field_for_movement_height = 3 * SCREEN_HEIGHT // 5
radi... |
class Solution:
def addToArrayForm(self, num: List[int], k: int) -> List[int]:
for i in reversed(range(len(num))):
k, num[i] = divmod(num[i] + k, 10)
while k > 0:
num = [k % 10] + num
k //= 10
return num
|
"""
Aula 008
Desafio 17
Faça um programa que leia o comprimento do cateto oposto e do cateto adjacente de um triângulo retângulo, calcule e mostre o comprimento da hipotenusa.
"""
|
# Complete the printLinkedList function below.
#
# For your reference:
#
# SinglyLinkedListNode:
# int data
# SinglyLinkedListNode next
#
#
def printLinkedList(head):
if(head is not None):
print(head.data)
printLinkedList(head.next)
|
class BalanceUnderLimitError(Exception):
pass
class BalanceOverLimitError(Exception):
pass
|
"""
Global settings and constants
"""
TEMP_IMAGE_FILE="/home/pi/tmp/capture.jpg"
CAPTURE_SLEEP=0.5
MUSIC_ROOT="/home/pi/Music"
DEFAULT_VOLUME=40
|
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
class Child(Person):
def __init__(self, name, age):
super().__init__(name, age)
# """"Test Code"""
# child = Child('Boris', 18)
# print(child.__dict__) |
nbPaquets = int(input())
poidsPaquet = int(input())
poidsTotal = nbPaquets * poidsPaquet
if (poidsTotal > 105):
print("Surcharge !") |
def test_root_api(api_client):
status_code, body, _ = api_client.get('/')
assert 200 == status_code
assert 'API' in body
assert {{cookiecutter.project_short_description}} == body['API']
|
# 序列是一块用于存放多个值的连续内存空间,并按照一定顺序排列,每个元素都有一个索引
# python中常见的序列:列表、元组、集合、字典和字符串
# 索引,python中的序列索引从0开始(从左到右),从-1开始(从右到左)
words = ["AA", "BB", "CC", "DD", "EE"]
print(words[2])
print(words[-1])
# 切片,访问序列中一定范围的元素,可以通过切片生成新的序列
# 语法格式:sname[start:end:step],其中start如果不指定默认为0,end若不指定默认为序列的长度,step若不指定默认为1
print(words[1:3])
print(wo... |
PATH_MESHES = '../output'
PATH_DATASET = '../input'
PATH_UNIT_MESHES = '../unit_meshes'
STR_LEGO_2_4 = 'lego_2_4.stl'
STR_CUBE = 'cube.stl'
|
general = "ffmpeg -f gdigrab -framerate 20 -offset_x"
# Encoding method:
# amd: hevc_amf
# nvidia: hevc_nvenc
encoder = "hevc_nvenc" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.