content stringlengths 7 1.05M |
|---|
'''Defines the `checkstyle_aspect`.
'''
load("//java:providers/JavaCompilationInfo.bzl", "JavaCompilationInfo")
load(
"//java:common/extract/toolchain_info.bzl",
"extract_java_runtime_toolchain_class_path_separator",
"extract_checkstyle_toolchain_info",
)
_JAVA_RUNTIME_TOOLCHAIN_TYPE = "@dwtj_rules_java//... |
"""Common constants used across image quality modules."""
VALID_MASK_FORMAT = 'valid_mask_%s'
CERTAINTY_MASK_FORMAT = 'certainty_mask_%s'
PREDICTIONS_MASK_FORMAT = 'predictions_mask_%s'
ORIG_IMAGE_FORMAT = 'orig_name=%s'
PATCH_SIDE_LENGTH = 84
REMOTE_MODEL_CHECKPOINT_PATH = "https://storage.googleapis.com/microscope-... |
expected_output = {
"interface_name": "Gi1/0/1",
"if_id": "75",
"phy_registers": {
"0": {
"register_number": "0000",
"hex_bit_value": "1140",
"register_name": "Control Register",
"bits": "0001000101000000",
},
"1": {
"regist... |
class Solution:
def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
l = set(nums1)
ret = [i for i in nums2 if i in l]
return list(set(ret)) |
temp=int(input("Ingrese la temperatura"))
print("f° c°")
for temp in range(0,temp,2):
print(temp," ",int((temp-32)*5/9))
|
# Class attributes ...
#
# Use dot to assign values to a class instance
class Point:
""" a 2D point """
p = Point()
p.x = 1
p.y = 2
assert p.x == 1
assert p.y == 2 |
"""API endpoints."""
class Endpoint(object):
API_PREFIX = '/api/'
VEHICLES = API_PREFIX + 'vehicles/' # ?dealer=AAA?model=XXX?fuel=YYY?transmission=ZZZ
DEALERS_CLOSEST_LIST = API_PREFIX + 'dealers/' # ?dealer=AAA?model=XXX?fuel=YYY?transmission=ZZZ?latitude=LLL?longitude=OOO
DEALER_CLOSEST = API_PREF... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 6 20:34:16 2019
@author: sodatab
MITx: 6.00.1x
"""
"""
01.2-Finger While Exercise 02
----------------------------
2. Convert the following into code that uses a while loop.
prints Hello!
prints 10
prints 8
prints 6
prints 4
prints 2
"""
"""Answ... |
def solution(N):
b_rep = '{:b}'.format(N)
counter = 0
res = 0
prev_val = 0
count = False
for val in b_rep:
val = int(val)
if val - prev_val == -1:
count = True
counter += 1
if val - prev_val == 0 and count:
counter += 1
if val -... |
x = 30;
y = 3;
## addition
print("x + y : ",x + y);
## we can use + for concatenate string
print("Hello, " + "World!");
## Subtraction
print("x - y : ",x - y);
## Division
print("x / y : ",x / y);
## here division operator always return float type number
## Multiplication
print("x * y : ",x*y);
# we can use * oper... |
class YAMLEmptyError(Exception):
"""The yaml configs file is empty, nothing to read from there."""
class BadInputs(Exception):
"""Bad inputs"""
class PeaFailToStart(SystemError):
"""When pea is failed to started"""
class GRPCServerError(Exception):
"""Can not connect to the grpc gateway"""
class... |
# Os números primos possuem várias aplicações dentro da Computação, por exemplo na Criptografia. Um número primo é aquele que é divisível apenas por um e por ele mesmo. Faça um programa que peça um número inteiro e determine se ele é ou não um número primo.
numero = int(input("Digite um número: "))
div = []
count = 0
... |
#!/usr/bin/env python3
# Please make sure this file can be executed.
# chmod +x hello.py
print('Hello World!!')
|
def seta(n):
for i in range(n):
if i == n - 1:
print((2 * n) * '*', end='')
print((i + 1) * '*')
else:
print((2 * n) * ' ', end='')
print((i + 1) * '*')
for j in range(n - 1, 0, -1):
print((2 * n) * ' ',end='')
print(j * '*')
seta(1... |
'''input
atcoder beginner contest
ABC
'''
# -*- coding: utf-8 -*-
# AtCoder Beginner Contest
# Problem A
if __name__ == '__main__':
a, b, c = input().split()
result = a[0] + b[0] + c[0]
print(result.upper())
|
#Desenvolva um programa que leia as duas notas de um aluno. Calcule e mostre a sua média
n1 = int(input("Digite a nota de seu primeiro teste: "))
n2 = int(input("Digite a nota de seu segundo teste: "))
me = ((n1+n2)/2)
print ("A média aritmética de suas notas é:",me)
|
file = open("AAPL.txt", "r")
lines = file.readlines()
prices = []
for line in lines:
price = float(line)
prices.append(price)
print(price)
print(prices) |
'''
Problem Description:
--------------------
The program reads a file and counts
the number of blank spaces in a text file.
'''
print(__doc__)
print('-'*25)
fileName=input('Enter file name: ')
k=0
with open(fileName,'r')as f:
for line in f:
words=line.split()
for i in words:
for letter in i:
... |
n = int(input('Digite um número para calcular a tabuada '))
m = 1
print('{} x {:2} = {}'.format(n, 1, n*1))
print('{} x {:2} = {}'.format(n, 2, n*2))
print('{} x {:2} = {}'.format(n, 3, n*3))
print('{} x {:2} = {}'.format(n, 4, n*4))
print('{} x {:2} = {}'.format(n, 5, n*5))
print('{} x {:2} = {}'.format(n, 6, n*6))
p... |
functions = {
'Add': (2, lambda p: p[0] + p[1]),
'Minus': (2, lambda p: p[0] - p[1]),
'UnaryMinus': (1, lambda p: -p[0]),
'Divide': (2, lambda p: p[0] / p[1]),
'Multiply': (2, lambda p: p[0] * p[1]),
'Modulo': (2, lambda p: p[0] % p[1]),
'EqualTo': (2, lambda p: p[0] == p[1]),
'NotEqualT... |
class Features:
NOTEBOOKS = 'app.features.notebooks'
class Deployment:
SITE = 'app.deployment.site'
class Branding:
PRIVACY = 'app.configuration.privacy'
LICENSE = 'app.configuration.license'
HEADER_LOGO_ID = 'app.configuration.header.logo.file.id'
FOOTER_LOGO_ID = 'app.configuration.footer.lo... |
"""This problem was asked by Snapchat.
You are given an array of length N, where each element i represents the number of ways
we can produce i units of change. For example, [1, 0, 1, 1, 2] would indicate that
there is only one way to make 0, 2, or 3 units, and two ways of making 4 units.
Given such an array, determ... |
WIDTH = 512
HEIGHT = 336
FPS = 50
PIX_FOR_BRIX = 16
STEPS_FOR_CYCLE = 16
N_STEP_FOR_TEST = 5
BLACK = (0, 0, 0)
BKGR = (0, 0, 0)
|
# -*- coding: utf-8 -*-
"""
.. module:: pytfa
:platform: Unix, Windows
:synopsis: Thermodynamics-based Flux Analysis
.. moduleauthor:: pyTFA team
Pre-tuned configurations for faster solving
"""
def dg_relax_config(model):
"""
:param model:
:return:
"""
# grbtune output on a hard model :
... |
"""
PASSENGERS
"""
numPassengers = 3217
passenger_arriving = (
(6, 3, 5, 3, 2, 0, 6, 8, 4, 2, 4, 0), # 0
(5, 11, 6, 2, 1, 0, 7, 9, 7, 3, 1, 0), # 1
(3, 8, 6, 4, 3, 0, 5, 12, 3, 7, 1, 0), # 2
(6, 6, 6, 5, 3, 0, 3, 7, 5, 5, 3, 0), # 3
(1, 4, 7, 4, 4, 0, 7, 11, 9, 6, 3, 0), # 4
(5, 11, 5, 5, 0, 0, 5, 9, 4, 4... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
synthqc.errors
This module holds project defined errors
Author: Jacob Reinhold (jacob.reinhold@jhu.edu)
Created on: Nov 15, 2018
"""
class SynthQCError(Exception):
pass
|
__title__ = 'Sellsy'
__description__ = 'https://api.sellsy.fr/documentation/methodes'
__version__ = '0.0.4'
__author__ = 'Cantin L.'
print("API de ", __title__ ," lien de la documentation : ", __description__ ," c'est la version ", __version__ ," développer par ", __author__)
|
a = [1, 2, 3]
b = a
print(a == b)
# => True
print(a is b)
# => True
c = list(a)
# == evaluates to true if the objects referred by the variables are equal
print(a == c)
# => True
# is evaluates to true if both variables point to the same object
print(a is c)
# => false
|
# !/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Project : acs-project-krr
@File : model_v1.py
@Author : Billy Sheng
@Contact : shengdl999links@gmail.com
@Date : 2020/11/21 10:40 上午
@Version : 1.0.0
@License : Apache License 2.0
@Desc : None
"""
MODELS = [
{
"DOMAIN": {'5', '3', '6', '7', '2... |
# Best
# time O(log(n))
# space O(1)
def binarySearch(array, target):
low = 0
high = len(array)-1
while low<=high:
mid = (low+high)//2
if array[mid] == target:
return mid
if target > array[mid]:
low = mid + 1
else:
high = mid -... |
l = [1,2,3,4]
def printCombo(l):
for j in range(1, len(l)+1):
for i in range(len(l)-1):
l[i],l[i+1]=l[i+1],l[i]
print(l)
for i in range(len(l)):
printCombo(l[i:])
|
def read_u8(f):
"""Reads an unsigned byte from the file object f.
"""
temp = f.read(1)
if not temp:
raise EOFError("EOF")
return int.from_bytes(temp, byteorder='little', signed=False)
def read_u16(f):
"""Reads a two byte unsigned value from the file object f.
"""
temp = f.read... |
# 多继承引入
class Father(object):
def eat(self):
print("文雅的吃饭")
class Mom(object):
def run(self):
print("小碎步")
class Son(Father, Mom):
pass
def main():
son = Son()
son.eat()
son.run()
if __name__ == '__main__':
main()
|
"""
Author: David Oniani
Purpose: Homework (problem 8)
NOTE: I have not included the algorithm to check
that 6210001000 is indeed the only number that
meets the conditions. It needs a bit more explanation
for optimizations so I decided to take it out.
"""
def check(ten_digit_number):
"""
Function to check wh... |
s = """75
95 64
17 47 82
18 35 87 10
20 04 82 47 65
19 01 23 75 03 34
88 02 77 73 07 63 67
99 65 04 28 06 16 70 92
41 41 26 56 83 40 80 70 33
41 48 72 33 47 32 37 16 94 29
53 71 44 65 25 43 91 52 97 51 14
70 11 33 28 77 73 17 78 39 68 17 57
91 71 52 38 17 14 91 43 58 50 27 29 48
63 66 04 68 89 53 67 30 73 16 69 87 40 3... |
f=open('This.txt','r')
# this is Default read mode of file
f=open('This.txt') #open file
# data=f.read()
data=f.read(5) #Starting 5 characters from file
print(data)
f.close() |
# https://github.com/arrow-py/arrow
"""
>>> import arrow
>>> arrow.get('2013-05-11T21:23:58.970460+07:00')
<Arrow [2013-05-11T21:23:58.970460+07:00]>
>>> utc = arrow.utcnow()
>>> utc
<Arrow [2013-05-11T21:23:58.970460+00:00]>
>>> utc = utc.shift(hours=-1)
>>> utc
<Arrow [2013-05-11T20:23:58.970460+00:00]>
>>> local ... |
# Create cache for known results
factorial_memo = {}
def factorial(k):
if k < 2:
return 1
if not k in factorial_memo:
factorial_memo[k] = k * factorial(k-1)
return factorial_memo[k]
print(factorial_memo)
print(factorial(4))
print(factorial_memo)
print(factorial(5))
print(factorial_mem... |
#自行替换
BOTTOKEN="114514191:AAF1z0dfbE3QEx6lLq2f1UjI1145141919810"
BOTNAME="ranwengamebot"
#PROXY="socks5h://localhost:1080"
PROXY=""
DEBUG=True
PY=True#py钱
|
# author: Gonzalo Salazar
# assigment: Homework #2
# description: contains three functions
# First function:
# Input: temperature value in degrees Centigrade
# Output: temperature value in degrees Fahrenheit
# Second function:
# Input: temperature value in degrees Fahrenheit
# Output: temper... |
# -*- coding: utf-8 -*-
"""
Mobile Forms - Controllers
"""
module = request.controller
# -----------------------------------------------------------------------------
def forms():
"""
Controller to download a list of available forms
"""
if request.env.request_method == "GET":
if aut... |
# https://leetcode.com/problems/maximum-product-subarray/
class Solution:
def maxProduct(self, nums: List[int]) -> int:
res = nums[0]
maxNum, minNum = 1, 1
for num in nums:
tempMax = num * maxNum
tempMin = num... |
# Program to reverse an array
def reverseArray(arr : list) :
for i in range(len(arr) // 2) :
arr[i], arr[len(arr)-1-i] = arr[len(arr)-1-i], arr[i]
if __name__ == "__main__":
arr = [1,2,3,4,5,6,7]
reverseArray(arr)
print(arr)
|
#
# PySNMP MIB module Juniper-MPLS-CONF (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Juniper-MPLS-CONF
# Produced by pysmi-0.3.4 at Mon Apr 29 19:52:41 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... |
class Solution:
def searchInsert(self, nums: List[int], target: int) -> int:
s = 0
e = len(nums) - 1
while(s <= e):
m = (s + e) // 2
if (nums[m] < target):
s = m + 1
elif (nums[m] > target):
e = m - 1
else:
return m
return s |
'''
Conestoga Computer Science Club Programming Challenges
Instructions:
Finish each method and run the test.py file to test the methods.
'''
'''
Karaca Encrypt
--------------
Make a function that encrypts a given input with these steps:
Input: "apple"
Step 1: Reverse the input: "elppa"
Step 2: Replace all vowel... |
#%%
# dutch_w = 0.664
# turkish_w = 0.075
# moroccan_w = 0.13
# ghanaian_w = 0.021
# suriname_w = 0.11
# sample_n = 4000
# dutch_pop = sample_n * dutch_w
# suriname_pop = sample_n * suriname_w
# turkish_pop = sample_n * turkish_w
# moroccan_pop = sample_n * moroccan_w
# ghanaian_pop = sample_n * ghanaian_w
# ethn... |
entries = [
{
'env-title': 'atari-alien',
'env-variant': 'Human start',
'score': 570.20,
},
{
'env-title': 'atari-amidar',
'env-variant': 'Human start',
'score': 133.40,
},
{
'env-title': 'atari-assault',
'env-variant': 'Human start',
... |
'''
Cho một list chứa nhiều phần tử mang nhiều kiểu dữ liệu khác nhau,
trong đó có một phần tử kiểu tuple. Viết chương trình đếm số lượng
các phần tử trong một list đó, đến khi gặp một phần tử kiểu tuple.
'''
list = [1, 2, 'Vietnam', (99, 'hello', 2 + 3j)]
count = 0
print(type(list[3]))
for i in r... |
SECRET_KEY = 'secret'
ROOT_URLCONF = 'jsonrpc.tests.test_backend_django.urls'
ALLOWED_HOSTS = ['testserver']
DATABASE_ENGINE = 'django.db.backends.sqlite3'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
}
}
JSONRPC_MAP_VIEW_ENABLED = True
|
packages = {
'Greenspace': {
'description': '',
'foundations' : [
'neighborhood_development_18_027',
'neighborhood_development_18_021'
],
'default_foundation' : 'neighborhood_development_18_027',
'slides' : [
'neighborhood_development_18_003',
'neighborhood_de... |
# Solution 2
# def fib(num, l=[]):
# a=b=1
# while(True):
# a+=b
# if a % 2 == 0:
# l.append(a)
# a,b=b,a
# if a >= num:
# break
# return l
# print(sum(fib(4000000)))
# Solution 3
# import math
# def factors(num):
# factors_list = []
# for value in range(2, math.ceil(math... |
l = [4, 3, 5, 4, -3,10,2,33,98,4]
print(l)
min = l[0]
max = l[0]
n = len(l)
for i in range(1, n):
curr = l[i]
if curr < min:
min=curr
if curr>max:
max=curr
print("Min=",min,"Max=",max)
|
class MinMaxHeap:
# Checks if a binary tree is a min/max heap.
@staticmethod
def is_valid(values, index, level, min_value, max_value):
if index >= len(values):
return True
if (values[index] > min_value and values[index] < max_value) == False:
return False
... |
chars2get = set()
with open('biofic2take.tsv', encoding = 'utf-8') as f:
for line in f:
fields = line.strip().split('\t')
charid = fields[0]
chars2get.add(charid)
outlines = []
with open('../biofic50/biofic50_doctopics.txt', encoding = 'utf-8') as f:
for line in f:
fields = li... |
# Homework 01 - Game of life
#
# Your task is to implement part of the cell automata called
# Game of life. The automata is a 2D simulation where each cell
# on the grid is either dead or alive.
#
# State of each cell is updated in every iteration based state of neighbouring cells.
# Cell neighbours are cells that ar... |
class BoundingBox:
def __init__(self, top: float, right: float, bottom: float, left: float):
self.top = top
self.right = right
self.bottom = bottom
self.left = left
def to_flickr_bounding_box(self):
return '{self.left}, {self.bottom}, {self.right}, {self.top}'.format(sel... |
#!/usr/bin/python3.6
class Reaction:
# the sets of reactants, inhibitors and products of the reaction
name = None
reactants = set()
inhibitors = set()
products = set()
# the creation of a reaction is made through the called of a function in which all the controls are performed, so we can
... |
def create_empty_list():
phone_device_types = []
print(phone_device_types)
return
def access_list_item():
phone_device_types = ["IOS", "Android"]
print(phone_device_types) # ['IOS', 'Android']
print(phone_device_types[0])
print(phone_device_types[0].title())
# -1 = last item. 倒数第一个
... |
# adapted from https://raw.githubusercontent.com/lucien2k/wipy-urllib/master/urllib.py
def unquote(s):
"""Kindly rewritten by Damien from Micropython"""
"""No longer uses caching because of memory limitations"""
res = s.split('%')
for i in range(1, len(res)):
item = res[i]
try:
... |
# Description: Find H-bonds around a residue.
# Source: placeHolder
"""
cmd.do('remove element h; distance hbonds, all, all, 3.2, mode=2;')
"""
cmd.do('remove element h; distance hbonds, all, all, 3.2, mode=2;')
|
# Pattern that would startup the DUT, then do nothing else.
# Should still generate.
with Pattern() as pat:
...
|
# -*- coding: utf-8 -*-
"""001 = Deixando tudo pronto
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1GhfZy4Dql6Q-h1khGuR5Uji39RilKx9T
"""
msg = "Olá, Mundo"
print(msg) |
N = int(input())
total = 0
for i in range(1, N+1):
if (i % 3) != 0 and (i % 5) != 0:
total = total+i
print(total)
|
INSTRUCTIONS = {
"SUM": 0b00001,
"SUB": 0b00010,
"MULT": 0b00011,
"DIV": 0b00101,
}
def instrFor(instr):
return INSTRUCTIONS[instr] |
class Solution(object):
# def isPerfectSquare(self, num):
# """
# :type num: int
# :rtype: bool
# """
# i = 1
# while num > 0:
# num -= i
# i += 2
# return num == 0
def isPerfectSquare(self, num):
low, high = 1, num
... |
VAT_NUMBER_REGEXES = {
# EU VAT number regexes have a high certainty
'AT': r'^U\d{8}$',
'BE': r'^[01]\d{9}$',
'BG': r'^\d{9,10}$',
'CY': r'^\d{8}[A-Z]$',
'CZ': r'^\d{8,10}$',
'DE': r'^\d{9}$',
'DK': r'^\d{8}$',
'EE': r'^\d{9}$',
'EL': r'^\d{9}$',
'ES': r'^([A-Z]\d{7}[A-Z0-9]|... |
#
# This file contains the Python code from Program 6.7 of
# "Data Structures and Algorithms
# with Object-Oriented Design Patterns in Python"
# by Bruno R. Preiss.
#
# Copyright (c) 2003 by Bruno R. Preiss, P.Eng. All rights reserved.
#
# http://www.brpreiss.com/books/opus7/programs/pgm06_07.txt
#
class StackAsLinked... |
class Model():
def __init__(self, model):
pass
|
pound = int(input())
conv_to_dollar = pound * 1.31
print(f"{conv_to_dollar:.3f}")
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2020/4/30 13:40
# @Author : zengsm
# @File : config
#爬取公众号文章
PROXY_POOL_URL = 'http://127.0.0.1:5000/get'
KEYWORD ='计算机等级二级' # 输入关键词
MONGO_URI = 'localhost'
MONGO_DB = 'data'
MAX_COUNT = 5 |
"""
Codemonk link: https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/binary-movement/
You are given a bit array (0 and 1) of size n. Your task is to perform Q queries. In each query you have to toggle all
the bits from the index L to R (L and... |
# Desenvolva um programa que leia quatro valores
# pelo teclado e guarde-os em uma tupla.
# No final, mostre:
# A) Quantas vezes apareceu o valor 9.
# B) Em que posição foi digitado o primeiro valor 3.
# C) Quais foram os números pares.
num = (int(input('Digite um numero: ')),
int(input('Digite outro numero: ')... |
# Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray).
# Example 1:
# Input: [1,3,5,4,7]
# Output: 3
# Explanation: The longest continuous increasing subsequence is [1,3,5], its length is 3.
# Even though [1,3,5,7] is also an increasing subsequence, it's not a ... |
S, W = map(int, input().split())
if(W >= S):
print("unsafe")
else:
print("safe") |
#medicine = 'Coughussin'
#dosage = 5
#duration = 4.5
#instructions = '{} - Take {} ML by mouth every {} hours.'.format(medicine, dosage, duration)
#print(instructions)
#instructions = '{2} - Take {1} ML by mouth every {0} hours'.format(medicine, dosage, duration)
#print(instructions)
#instructions = '{medicine} - Take... |
# TWITTER PYTHON
# Copyright 2022 Billyfranklim
# See LICENSE for details.
__version__ = '0.1.0'
__author__ = 'Billyfranklim Pereira'
__license__ = 'MIT' |
"""
586. Sqrt(x) II
Implement double sqrt(double x) and x >= 0.
Compute and return the square root of x.
You do not care about the accuracy of the result, we will help you to output results.
binary search?
by result?
"""
class Solution:
"""
@param x: a double
@return: the square root of x
"""
de... |
"""Top-level package for Female Health Analysis."""
__author__ = """Daniel Schulz"""
__email__ = 'danielschulz2005@hotmail.com'
__version__ = '0.1.0'
|
# Time: O(n)
# Space: O(n)
# 1182 biweekly contest 8 9/7/2019
# You are given an array colors, in which there are three colors: 1, 2 and 3.
#
# You are also given some queries. Each query consists of two integers i and c, return the shortest distance
# between the given index i and the target color c. If there is no... |
# def print_hi(name):
# print(f'Hi, {name}')
# if __name__ == '__main__':
# print_hi('PyCharm')
print("Hello World Python xd")
# Para saber la direccion de memoria de cierta variable se usa el metodo id()
name = "Juan Diego Castellanos"
print(name)
print(id(name))
print("------")
print("tipo de dato")
print(ty... |
"""
Shared constant values.
"""
"""
## Handling Concurrency.
When appending events to a stream, you can supply a
*stream state* or *stream revision*. Your client can
use this to tell EventStoreDB what state or version
you expect the stream to be in when you append. If the
stream isn't in that state the an exception wi... |
"""
Django Rest Framework Auth provides very simple & quick way to adopt
authentication APIs' to your django project.
Rationale
---------
django-rest-framework's `Serializer` is nice idea for detaching
business logic from view functions. It's very similar to django's
``Form``, but serializer is not obligible for ren... |
'''
0. 用 while 语句实现与以下 for 语句相同的功能:
for each in range(5):
print(each)
'''
r = iter(range(5))
while 1:
try:
each = next(r)
except StopIteration:
break
print(each)
|
'''
Your plot of the ECDF and determination of the confidence interval make it pretty clear that the beaks of G. scandens on Daphne Major have gotten deeper. But is it possible that this effect is just due to random chance? In other words, what is the probability that we would get the observed difference in mean beak d... |
#!/usr/bin/env python3
def isBalanced(s: str) -> bool:
stack = []
pair = {'(': ')', '{': '}', '[': ']'}
for ch in s:
# For left brackets push right brackets
if (ch in pair.keys()):
stack.append(pair[ch])
else:
# Unmatch right char
if len(stack) =... |
#
# if type(input) == string:
# find if palindrome
# elif type(input) == number:
# find factorial
# find if palindrome
#
def pal(st):
l = len(st)
i = 0
flag = True
while i < l//2:
if st[i] == st[l-i-1]:
pass
else:
flag = False
i += 1
return flag
while True:
print("Menu\n1. for palindrome\n2... |
class TSDBClientException(Exception):
pass
class TSDBNotAlive(TSDBClientException):
pass
class TagsError(TSDBClientException):
pass
class ValidationError(TSDBClientException):
pass
class UnknownTSDBConnectProtocol(TSDBClientException):
def __init__(self, protocol):
self.protocol = ... |
# Author: Jocelino F.G
a, b = input().split(), input().split()
q1 = int(a[1])
v1 = float(a[2])
q2 = int(b[1])
v2 = float(b[2])
t1 = q1 * v1
t2 = q2 * v2
tt = t1 + t2
print('VALOR A PAGAR: R$ %.2f' %tt)
|
def merge_sort(unsorted_list):
if len(unsorted_list) <= 1:
return unsorted_list
# Finding the middle point and partitioning the array into two halves
middle = len(unsorted_list) // 2
left = unsorted_list[:middle]
right = unsorted_list[middle:]
left = merge_sort(left)
right = merge_s... |
x = 0
drone_chk = [112, 334, 4444, 4444, 445, 112, 27466, 445, 27466]
for i in drone_chk:
x ^= i
print("The missing drone order ID is:", x)
|
############################################################################
#
# Copyright (C) 2016 The Qt Company Ltd.
# Contact: https://www.qt.io/licensing/
#
# This file is part of Qt Creator.
#
# Commercial License Usage
# Licensees holding valid commercial Qt licenses may use this file in
# accordance with the co... |
"""
Code Challenge 1
Certificate Generator
Develop a Python code that can generate certificates in image format.
It must take names and other required information from the user and generates
certificate of participation in a Python Bootcamp conducted by Forsk.
Certificate should have Forsk Seal, Forsk Signature, ... |
#
# PySNMP MIB module F5-3DNS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/F5-3DNS-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:11:39 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 0... |
#Return the sum of all the multiples of 3 or 5 below the number passed in.
def solution(number):
lit = []
for i in range(0, number):
if i % 3 == 0 or i % 5 == 0:
lit.append(i)
return sum(lit)
#Alternate Solution
def solution(number):
return sum(x for x in range(number) if x % 3 == 0... |
print('Notas: menor que 5, REPROVADO / entre 5 e 6.9, RECUPERAÇÃO / maior ou igual a 7, APROVADO')
nota1 = float(input('Primeira nota: '))
nota2 = float(input('Segunda nota: '))
media = (nota1 + nota2) / 2
if media < 5:
print('Sua média é {} e você está REPROVADO!!'.format(media))
elif media >= 5 and media < 7:
... |
class Queue:
def __init__(self, initial_values):
self.queue = initial_values
def enqueue(self, val):
self.queue.insert(0, val)
def dequeue(self):
if self.is_empty():
return None
else:
return self.queue.pop()
def size(self):
return len(... |
# <auto-generated>
# This code was generated by the UnitCodeGenerator tool
#
# Changes to this file will be lost if the code is regenerated
# </auto-generated>
def to_millilitres(value):
return value * 14.786764781249998848
def to_litres(value):
return value * 0.014786764781249998848
def to_kilolitres(value):
re... |
# Configure schema: 'Column_name': ['List', 'of', 'synonyms']
columns_with_synonyms = {
'Name': ['Mitglied des Landtages'],
'Fraktion': ['Partei',
'Fraktion (ggf. Partei)',
],
'Wahlkreis': ['Landtagswahlkreis der Direktkandidaten',
'Landtagswahlkreis',
... |
# -*- coding: utf-8 -*-
"""
Editor de Spyder
Este es un archivo temporal.
"""
#import pdb
def biseccion(f, a=-100, b=100, epsilon=0.001, max_iter=100):
guess = (a + b) / 2
# Contador de iteraciones
num_guesses = 0
#pdb.set_trace()
while abs(f(guess)) >= epsilon and num_guesses < max_iter:... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.