content stringlengths 7 1.05M |
|---|
price_list = { 1 : 4.0, 2 : 4.5, 3 : 5.0, 4 : 2.0, 5 : 1.5}
values = input()
product_code, price_product = [int(value) for value in values.split(' ')]
print('Total: R$ {:.2f}'.format(price_list[product_code] * price_product))
|
# try out the Python stack functions
# TODO: create a new empty stack
stack = []
# TODO: push items onto the stack
stack.append(1)
stack.append(2)
stack.append(3)
stack.append(4)
# TODO: print the stack contents
print(stack)
#TODO: pop an item off the stack
x = stack.pop()
print(x)
print(stack)
|
class Sword():
def __init__(self, name, damage):
self.damage = damage
self.name = name
@staticmethod
def showAbilities():
print("Swords can only attack orcs and elves, and do zero damage agains magic armour.")
Sword.showAbilities()
|
# 피보나치 구하는 함수
def fiboonacci(num):
output = 1
before1 = before2 = 1
if num == 0:
output = 0
elif num == 1 or num == 2:
output = 1
else:
for i in range(num - 2):
before1 = before2 # 1 1 2
before2 = output # 1 2 3
output = before1 + before... |
class EdsError(Exception):
"""EDS base exception."""
class DuplicateIncludeError(Exception):
"""Raised when a duplicate include occurs."""
class PluginNameNotFoundError(EdsError):
"""Raised when a specific plugin is not found."""
class PluginNameMismatchError(EdsError):
"""Raised when a plugin na... |
''' instantiating a class
The process of creating a an object from a class.
''' |
#
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
#
# SPDX-License-Identifier: Apache-2.0
#
SOC_IRAM_LOW = 0x4037c000
SOC_IRAM_HIGH = 0x403e0000
SOC_DRAM_LOW = 0x3fc80000
SOC_DRAM_HIGH = 0x3fce0000
SOC_RTC_DRAM_LOW = 0x50000000
SOC_RTC_DRAM_HIGH = 0x50002000
SOC_RTC_DATA_LOW = 0x50000000
SOC_RTC_DAT... |
# greaseweazle/image/hfe.py
#
# Written & released by Keir Fraser <keir.xen@gmail.com>
#
# This is free and unencumbered software released into the public domain.
# See the file COPYING for more details, or visit <http://unlicense.org>.
class HFE:
def __init__(self, start_cyl, nr_sides):
self.start_cyl = ... |
# ------------------------------------------------------------------------------
# Access to the CodeHawk Binary Analyzer Analysis Results
# Author: Henny Sipma
# ------------------------------------------------------------------------------
# The MIT License (MIT)
#
# Copyright (c) 2016-2020 Kestrel Technology LLC
#
#... |
# @desc By Anay '24
def check_age(age):
if age < 21:
return age
return age + 5
def main():
print(check_age(5))
print(check_age(29))
print(check_age(42))
print(check_age(15))
print(check_age(0.38))
print(check_age(21))
if __name__ == '__main__':
main()
|
# https://projecteuler.net/problem=91
# Fast enough
"""
Note that:
OP^2 = X_P^2 + Y_P^2
OQ^2 = X_Q^2 + Y_Q^2
PQ^2 = (X_P - X_Q)^2 + (Y_P - Y_Q)^2
There are 3 cases:
1. OP^2 + OQ^2 = PQ^2
-> X_P * X_Q + Y_P * Y_Q = 0
2. OP^2 + PQ^2 = OQ^2
-> X_P^2 + Y_P^2 - X_P * X_Q - Y_P * Y_Q = 0... |
#test
print('==================================')
print(' this is just a test ')
print('==================================')
num = int(input('insert a number: '))
print((num * 5) % 3)
|
def is_isogram(word):
word_dict = dict()
for c in word:
c = c.lower()
if ord('a') <= ord(c) <= ord('z'):
word_dict[c] = word_dict.get(c, 0) + 1
if word_dict[c] >= 2:
return False
return True
|
class Vector3f(object,IEquatable[Vector3f],IComparable[Vector3f],IComparable,IEpsilonFComparable[Vector3f]):
""" Vector3f(x: Single,y: Single,z: Single) """
@staticmethod
def Add(point,vector):
""" Add(point: Point3f,vector: Vector3f) -> Point3f """
pass
def CompareTo(self,other):
""" CompareTo(self: V... |
def reverse(x):
num = [] # 存储符号位每一位的数字
if x >= 0:
num.append(1) # 非负数
else:
num.append(-1)
x = abs(x)
# 获取每一位的数字
while x >= 10:
num.append(x % 10)
x = int(x / 10)
num.append(x)
# 反转数字
res = 0
length = len(num) - 1
for i in rang... |
option = None
def pytest_addoption(parser):
parser.addoption('--nproc', help='run tests on n processes', type=int, default=1)
parser.addoption('--lsf', help='run tests on with lsf clusters', action="store_true")
parser.addoption('--specs', help='test specs')
parser.addoption('--cases', help='test case ... |
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
def merge_list(head1, head2):
if head1 is None:
return head2
if head2 is None:
return head1
if head2.val < head1.val:
head1, head2 = head2, head1
head1.next = merge_list(head1.next, head2)
... |
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def nextLargerNodes(self, head):
"""
:type head: ListNode
:rtype: List[int]
"""
array = []
stack = []... |
# 公众号:MarkerJava
# 开发时间:2020/10/5 17:25
# scores = {'kobe': 100, 'lebron': 99, 'AD': 88}
# 第一种方式使用[]
# print(scores['kobe'])
# 第二种方式使用get()方法
# print(scores.get('lebron'))
# print(scores.get('ab'))
scores1 = {'kobe': 100, 'lebron': 99, 'AD': 88}
print('kobe' in scores1)
print('kobe' not in scores1)
# 删除指定的key-value... |
first_number = int(input())
second_number = int(input())
large_number = max(first_number, second_number)
small_number = min(first_number, second_number)
remaining_number = 0
gcd = 0
while True:
times = large_number // small_number
remain = large_number - ( small_number * times )
if 0 == remain:
... |
#
# PySNMP MIB module HM2-TRAFFICMGMT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HM2-TRAFFICMGMT-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:19:47 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default... |
# Faça um algoritimo em Python que receba o nome e três notas de um aluno. Este deverá exibir o nome e a média do mesmo
#saidas: nome, media
#entradas: nome, 3 notas
#processamento: calcular a média
nome = input("Digite o nome do aluno: ")
nota1 = input("Digite a nota 1: ")
nota2 = input("Digite a nota 2: ")
nota3 ... |
def find(s):
if s > 0 :
for i in range(9):
if s + i == 10:
return i
else :
return 0
s = 0
t = int(input())
for _ in range(int(t)):
n = int(input())
f = n
while(n>0):
d = n%10
s += d
n = n//10
x = find(s)
print(str(f)+str(x))
d = 0
s = 0 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@File : extractor.py
@Time : 2020/4/19 14:55
@Author : Empty Chan
@Contact : chen19941018@gmail.com
@Description: 解析器,解析爬虫模板的内容,并做处理
@License : (C) Copyright 2016-2020, iFuture Corporation Limited.
""" |
REQUEST_BODY_JSON = """
{
"customer_ids": [
"string"
]
}
"""
RESPONSE_200_JSON = """
{
"customers_balance": [
{
"balance": 1.1,
"customer_id": "string"
}
]
}
"""
|
def get_hello(name: str) -> tuple: # noqa: E501
"""
# noqa: E501
:param name:
:type name: str
:rtype: None
"""
return {"response": f" ola {name}. bem vindo ao clube"}, 200
# import aiohttp
# from connexion.lifecycle import ConnexionResponse
# async def get_hello(name: str) -> tuple... |
x=int(input())
if x < 0:
print(-x)
else:
print(x)
|
students = int(input())
students_dict = {}
top_students = {}
for _ in range(students):
name = input()
grade = float(input())
if name in students_dict:
students_dict[name].append(grade)
else:
students_dict[name] = [grade]
# for key, item in students_dict.items():
# if sum(item) / le... |
TASKS = {
"binary_classification": 1,
"multi_class_classification": 2,
"entity_extraction": 4,
"extractive_question_answering": 5,
"summarization": 8,
"single_column_regression": 10,
"speech_recognition": 11,
}
DATASETS_TASKS = ["text-classification", "question-answering-extractive"]
|
# enable: C0103
class FooClass:
"""
Attribute names should be in mixed case,
with the first letter lower case,
each word separated by having its first letter capitalized
just like method names.
And all private names should begin with an underscore.
"""
def __init__(self):
"""
... |
class GuiAbstractObject:
def is_clicked(self, mouse):
area = (self.position[0] * self.screen.engine.settings.graphic['screen']['resolution_scale'][0],
self.position[1] * self.screen.engine.settings.graphic['screen']['resolution_scale'][1],
(self.position[0] + self.position[2... |
#questão 07
print('='*50)
print(" " * 5, "Encontre o resultado de um n° fatorial")
print('='*50)
num = int(input("Digite o valor do numero: "))
fat = 1
x = 2
while x <= num:
fat = fat * x
x = x +1
print(f"O resultado do valor de [{num}!] é: {fat}") |
class NagiosException(Exception):
pass
class NagiosUnexpectedResultError(Exception):
pass
|
#!/usr/bin/env python
log_dir = os.environ['LOG_DIR']
admin_server_listen_address = os.environ['ADMIN_SERVER_LISTEN_ADDRESS']
admin_server_listen_port = os.environ['ADMIN_SERVER_LISTEN_PORT']
admin_username = os.environ['ADMIN_USERNAME']
admin_password = os.environ['ADMIN_PASSWORD']
managed_server_name = os.environ[... |
print("Choose from below options:")
print("1.Celsius to Fahrenheit.")
print("2.Fahrenheit to Celsius.")
o=int(input("option(1/2):"))
if(o==1):
c=float(input("Temperature in Celsius:"))
f=1.8*(c)+32.0
f=round(f,1) #temperature in fahrenheit precise to 1 decimal place
print("Temperature in Fahrenheit:",f)... |
#!/usr/bin/env python
# $Revision: 1.1.1.12 $ $Date: 2007/01/08 14:40:09 $ kgm
"""Monitor 1.8 This dummy module is only provided for backward compatibility.
It does nothing. class Monitor is now part of Simulation
and SimulationXXX."""
__version__ ='1.8 $Revision: 1.1.1.12 $ $Date: 2007/01/08 14:40:09 $'
pass
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# */AIPND-revision/intropyproject-classify-pet-images/adjust_results4_isadog.py
#
# PROGRAMMER: Sotirios Zikas
# DATE CREATED: April 16, 2019
def adjust_results4_... |
sub = {
"а" : {
"freq": 10.234,
"count": 3243,
"sub" : "б"
},
"б" : {
"freq": 8.324,
"count": 123,
"sub" : "д"
}
}
print(sub['а']['freq'], sub['б']['sub']) |
# This is a single line comment in Python
print("Hello World!") # This is a single comment
""" For multi-line
comments use three
double quotes
...
"""
|
"""
A rnd component generator.
"""
class RandomComponent:
def __init__(self, gen, str, var, par):
"""
Create a new RandomComponent.
:param gen: the random generator.
:param str: (dict) streams configuration.
:param var: (dict) variates configuration.
:param par: (di... |
__author__ = 'Nils Schmidt'
def memoize_pos_args(fun):
""" Memoize the functions positional arguments and return the same result for it """
# arguments, result
memo = {}
def wrapper(*args, **kwargs):
if args in memo:
return memo[args]
else:
memoize = True
... |
class Symbol:
def __init__(self,S,sign=1):
if type(S) != str:
raise TypeError("Symbols must be strings")
if S not in "abcdefghijklmnopqrstuvwxyz":
raise ValueError("Symbols must be lowercase letters")
self.S = S
self.sign = sign
def __str__(self):
... |
# Enter your code here. Read input from STDIN. Print output to STDOUT
n=int(input())
roll_n=set(map(int,input().split()))
m=int(input())
roll_m=set(map(int,input().split()))
s=roll_n|roll_m
print(len(s))
|
logLevel = 0
def log(msg):
if logLevel > 0:
print(msg)
else:
pass
def setLogLevel(value):
global logLevel
logLevel = value |
def solution(moves):
moves = list(moves)
programs = [chr(s) for s in range(ord("a"), ord("a") + 16)]
hashmap = {program: position for position, program in enumerate(programs)}
movemap = {"s": spin, "x": exchange, "p": partner}
seen = []
s = "".join(programs)
while s not in seen:
see... |
# The Nexus software is licensed under the BSD 2-Clause license.
#
# You should have recieved a copy of this license with the software.
# If you did not, you can find one at the following link.
#
# http://opensource.org/licenses/bsd-license.php
if len(parts) < 5:
self.client.sendServerMessage("For Make-a-Mob plea... |
del_items(0x80122D48)
SetType(0x80122D48, "struct THEME_LOC themeLoc[50]")
del_items(0x80123490)
SetType(0x80123490, "int OldBlock[4]")
del_items(0x801234A0)
SetType(0x801234A0, "unsigned char L5dungeon[80][80]")
del_items(0x80123130)
SetType(0x80123130, "struct ShadowStruct SPATS[37]")
del_items(0x80123234)
SetType(0x... |
'''
some other implementations:
recursive:
def binary_search(array, key, start, end):
if end < start:
return -1
else:
midpoint = start + (end - start) // 2
if key < array[midpoint]:
return binary_search(array, key, start, midpoint - 1... |
bil = -4
if (bil > 0):
print("Bilangan positif")
else:
print("Bilangan negatif atau nol") |
# -*- coding: utf-8 -*-
def codigobasico():
valor1 = 800
valor2 = 100
soma = valor1+valor2
print("O valor 1 é: " + str(valor1) + ", O valor 2 é: " + str(valor2) + ", Aqui está o retorno da soma: " + str(soma))
codigobasico()
|
input_name: str = input()
if input_name == 'Johnny':
print('Hello, my love!')
else:
print(f'Hello, {input_name}!')
|
def binary_search(array, target):
first = 0
last = len(array) - 1
while first <= last:
midpoint = (first + last) // 2
if array[midpoint] == target:
return midpoint
elif array[midpoint] < target:
first = midpoint + 1
elif array[midpoint] > target:
... |
def next_bigger(n):
"""Finds the next bigger number with the same digits."""
# Convert n to a string and a list in reverse for ease.
n_string = str(n)[::-1]
n_list = [int(x) for x in n_string]
# Go through each digit and identify when there is a lower digit.
number_previous = n_list[0]
... |
class Solution:
def heightChecker(self, heights: List[int]) -> int:
expected = sorted(heights)
indices=0
for i in range(len(heights)):
if(heights[i] != expected[i]):
indices += 1
return indices |
# -*- coding: utf-8 -*-
'''
File name: code\jumping_frog\sol_490.py
Author: Vaidic Joshi
Date created: Oct 20, 2018
Python Version: 3.x
'''
# Solution to Project Euler Problem #490 :: Jumping frog
#
# For more information see:
# https://projecteuler.net/problem=490
# Problem Statement
'''
There are... |
"""Top-level package for Nearest Neigbor Similarity."""
__author__ = """Shivam Ralli"""
__email__ = 'shivamralli167@gmail.com'
__version__ = '0.1.0'
|
s = float(input("Введите корень, который хотите извлечь: "))
x = 1
while abs(x * x - s) > 0.00001:
x = (x * x + s) / 2 / x
print(x) |
def Plus(a,b):
return a + b
def Minus(a,b):
return a - b
def Times(a,b):
return a*b
def Divide(a,b):
return a/b
|
# -*- encoding: utf-8 -*-
"""
@File : test_basemodel.py
@Time : 2020/4/3 0:08
@Author : chise
@Email : chise123@live.com
@Software: PyCharm
@info :测试basemodel的继承
"""
|
def filesFunctionField2list(files, func, field):
theList = []
for file in files:
record = {
"name": file,
field: func(file)
}
theList.append(record)
return theList
def filesClassFunctionField2list(files, Class, functionString, field):
theList = []
for file in files:
myClass = Class(file)
method =... |
"""PostgreSQL helpers."""
# Use pgcrypto, instead of uuid-ossp
# Also create a function uuid_generate_v4 for backward compatibility
UUID_SUPPORT_STMT = """CREATE EXTENSION IF NOT EXISTS "pgcrypto";
CREATE OR REPLACE FUNCTION uuid_generate_v4()
RETURNS uuid
AS '
BEGIN
RETURN gen_random_uuid();
END'
LANGUAGE 'plpgsql';
... |
def print_hi(name):
"""
:param name: the to say hi
:return: None
"""
# Use a breakpoint in the code line below to debug your script.
return f"Hi, {name}" # Press ⌘F8 to toggle the breakpoint.
class Hi:
def __init__(self):
self.hi = "hi there!"
def say(self):
print(se... |
s = 0
for c in range(1, 7):
n = int(input(f'Digite o {c}º número inteiro: '))
if n % 2 == 0:
s += n
print(f'A soma dos números pares é {s}')
|
cancerlist = ["ACC", "BLCA", "BRCA", "CESC", "CHOL", "COAD", "DLBC", "ESCA", "GBM", "HNSC", "KICH", "KIRC", "KIRP", "LGG", "LIHC", "LUAD", "LUSC", "MESO", "OV", "PAAD", "PCPG", "PRAD", "READ", "SARC", "SKCM", "STAD", "TGCT", "THCA", "THYM", "UCEC", "UCS", "UVM"]
input_data_path = "/ngs/data3/public_data/TCGA_FireBrows... |
N, L = map(int, input().split())
ans = 0
margin = float("inf")
for i in range(1, N + 1):
tar = 0
for j in range(1, N + 1):
tar += L + j - 1
res = 0
for j in range(1, N + 1):
if j == i:
continue
else:
res += L + j - 1
if abs(tar - res) < margin:
... |
#!/usr/bin/python3
def max_integer(my_list=[]):
if (len(my_list) == 0):
return (None)
a = my_list[0]
for i in range(0, len(my_list)):
if (my_list[i] > a):
a = my_list[i]
return (a)
|
"""Global constants module."""
GDRIVE_URL = 'https://drive.google.com'
DATASET_URL = '{0}/uc?id=1xABlWE790uWmT0mMxbDjn9KZlNUB6Y57'.format(GDRIVE_URL)
# dataset
LABEL_COLS = ('Jp', 'Becca', 'Katy')
# ignore resize
NO_RESIZE = (0, 0)
|
# Enter your code here
def triple(num):
num = num*3
print(num)
triple(6)
triple(99)
|
""" Some exception classes for the ondevice client """
class _Exception(Exception):
def __init__(self, *args, **kwargs):
Exception.__init__(self, *args)
self.msg = args[0]
for k,v in kwargs.items():
setattr(self, k, v)
class ConfigurationError(_Exception):
""" Indicates a m... |
EMBED_SIZE = 200
NUM_LAYERS = 2
LR = 0.0001
MAX_GRAD_NORM = 5.0
PAD_ID = 0
UNK_ID = 1
START_ID = 2
EOS_ID = 3
CONV_SIZE = 3
# sanity
# BUCKETS = [(55, 50)]
# BATCH_SIZE = 10
# NUM_EPOCHS = 50
# NUM_SAMPLES = 498
# HIDDEN_SIZE = 400
# test
BUCKETS = [(30, 30), (55, 50)]
BATCH_SIZE = 20
NUM_EPOCHS = 3
NUM_SAMPLES = ... |
# a = 42
# print(type(a))
# a = str(a)
# print(type(a))
a = 42.3
print(type(a))
a = str(a)
print(type(a))
|
#
# PySNMP MIB module ENTERASYS-IEEE802DOT11EXT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ENTERASYS-IEEE802DOT11EXT-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:49:11 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python ve... |
class Solution:
def longestCommonSub(self, a, n, b, m):
dp = [[0]*(m+1) for i in range(n+1)]
for i in range(1, n+1):
for j in range(1, m+1):
if a[i-1] == b[j-1]:
dp[i][j] = dp[i-1][j-1] + 1
else:
dp[i][j] = max(dp[i... |
"""
Code for training prototype segmentation model on Cityscapes dataset
https://www.cityscapes-dataset.com/
"""
|
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
load("//antlir/bzl:shape.bzl", "shape")
load("//antlir/bzl:target_tagger.shape.bzl", "target_tagged_image_source_t")
tarball_t = shape.shap... |
# -*- coding: utf-8 -*-
if __name__ == '__main__':
a = u'\u5f53\u524d\u4e91\u533a\u57df\u6ca1\u6709\u53ef\u7528\u7684'
# PROXY\uff0c\u8bf7\u5148\u68c0\u67e5\u5e76\u5b89\u88c5', u'\u76f4\u8fde\u533a\u57df\uff0c\u4e0d\u80fd\u5b89\u88c5PROXY\u548cPAGENT'
print(a) |
if condition:
...
else:
...
|
r"""Two example systems.
The :py:mod:`~example_systems.beryllium` module contains a calculation of the
process matrices for a :math:`^9\text{Be}^+` ion
addressed by a laser resonant with the :math:`^2S_{1/2}, F=2, m_F=2
\leftrightarrow ^2P_{3/2}, m_J=3/2` level, with perfect :math:`\sigma^+`
polarization.
The :py:mod... |
#
# PySNMP MIB module Juniper-DNS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Juniper-DNS-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:51: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... |
# I have no idea if this is actually functioning.
def line_intersection(l1, l2):
xdiff = (l1[0][0] - l1[1][0], l2[0][0] - l2[1][0])
ydiff = (l1[0][1] - l1[1][1], l2[0][1] - l2[1][1])
def det(a, b):
return a[0] * b[1] - a[1] * b[0]
div = det(xdiff, ydiff)
if div == 0:
return False
... |
fr = input('Frase: ')
for i in range(len(fr) -1,-1,-1):
print(fr[i], end='')
|
"""
Fundamental Template for LinkedList
"""
# General Definition of a node
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class LinkedList:
def __init__(self):
self.head = None
self.tail = None
return
def push_elements(self... |
def solve(arr, k):
cur=float("-inf")
ans=tuple()
total=sum(arr)
for i in range(len(arr), k-1, -1):
temp=compute(arr, total, i)
if temp[0]>cur:
cur=temp[0]
ans=(temp[1], i)
total-=arr[i-1]
return ans
def compute(arr, total, k):
cur=total
index=0... |
# Move all xeroes to right
N = int(input(''))
array = list(map(int, input().split(' ')[:N]))
flag = 0
# BRING/REPLACE ALL NON-ZEROES TO LEFT
for index in range(0, len(array)):
if(array[index] != 0):
array[flag] = array[index]
flag = flag+1
# NOW ADD ALL ZEROS TOWARDS RIGHT
for index in range(flag... |
# Space : O(n)
# Time : O(n)
class Solution:
def reverseWords(self, s: str) -> str:
l = s.split(" ")
for i in range(len(l)):
l[i] = l[i][::-1]
return " ".join(l)
|
inputTemplates = {
"M3": {
"QCD": [
[
0.0,
0.0004418671450315185,
0.01605229202018541,
0.05825334528354453,
0.08815209477081883,
0.1030093733105401,
0.10513254530282935,
... |
def expand_as_one_hot(input, C, ignore_index=None):
"""
Converts NxDxHxW label image to NxCxDxHxW, where each label gets converted to its corresponding one-hot vector
:param input: 4D input image (NxDxHxW)
:param C: number of channels/labels
:param ignore_index: ignore index to be kept during the ex... |
class HtmlWriter():
def __init__(self, filename):
self.filename = filename
self.html_file = open(self.filename, 'w')
self.html_file.write(
"""<!DOCTYPE html>\n""" + \
"""<html>\n<body>\n<table border="1" style="width:100%"> \n""")
def add_element(self, co... |
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
'''
Author: Luiz Yao (luizyao@163.com)
Created Date: 2019-09-26 16:22:12
-----
Last Modified: 2019-09-26 16:33:29
Modified By: Luiz Yao (luizyao@163.com)
-----
THIS PROGRAM IS FREE SOFTWARE, IS LICENSED UNDER MIT.
A short and simple permissive license with conditions
only ... |
# AT Commands
MAKE = 'at+cgmi'
MODEL = 'at+cgmm'
STATUS = 'at!gstatus?'
BANDMASK = 'at!gband?'
SIGNALQ = 'at+csq'
PWRMODE = { 'reboot': 'at!reset',
'lowpower': 'at+cfun=4',
'fullpower': 'at+cfun=1'}
|
x=int(input("Enter a value for x: "))
y=int(input("Enter a value for y: "))
z=int(input("Enter a value for z: "))
if x<y<z:
print("branch 1", end =' ')
elif x>y>z:
print("branch 2", end =' ')
else:
print("branch 3", end =' ')
print("is the branch") |
"""Pyvista specific errors."""
class MissingDataError(ValueError):
"""Exception when data is missing, e.g. no active scalars can be set."""
class AmbiguousDataError(ValueError):
"""Exception when data is ambiguous, e.g. multiple active scalars can be set."""
|
PORT=5050
HEADER=128
FORMAT='utf-8'
HEADER=64
DISCONNECT_MESSAGE='bye_0x8x0_eyb'
PING_MSG='I____NAME____I'
CHANGE_BIT='I_____I'
|
"""
@author: Andrea Domenico Giuliano
@contact: andreadomenico.giuliano@studenti.unipd.it
@organization: University of Padua
"""
#File contenente la funzione che ritorna quante volte compare un item tra le impression di una settimana
# e la funzione che ritorna la lista degli items di un impressions
def c_i(... |
def comp_surface_opening(self, Ndisc=200):
"""Compute the Slot opening surface (by numerical computation).
Caution, the bottom of the Slot is an Arc
Parameters
----------
self : Slot
A Slot object
Ndisc : int
Number of point to discretize the lines
Returns
-------
S... |
#!/usr/bin/env python3
syscall_table = [
"ni_syscall",
"console_putc",
"console_puts",
"process_create",
"process_exit",
"thread_create",
"thread_exit",
"vmo_create",
"vmo_write",
"vmo_read",
"vmo_map",
"register_server",
"register_named_server",
"register_client... |
def mensagem(texto):
print('-' * 30)
print('{:^30}'.format(texto))
print('-' * 30)
mensagem('CURSO EM VIDEO')
def mostrar_nome(nome):
print(f'Meu nome é {nome}')
mostrar_nome('Lucas')
def contador(*num):
print(num)
contador(1, 2, 4, 7, 9)
def dobra(lista):
pos = 0
while pos < len... |
class CaesarEncryption:
def __init__(self,input_message,shift):
self.input_message = input_message
self.shift=shift
def get_shifted_message(self):
alphabet_list_sequence = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
e... |
class InvalidRequest(Exception):
def __init__(self, message='', status_code=403):
super(InvalidRequest, self).__init__()
self.message = message
self.status_code = status_code
@property
def as_dict(self):
return {
'error': 'Invalid Request',
'message'... |
#!/usr/bin/env python
# coding: utf-8
# # BATCH 7 DAY 3 ASSIGNMENT
# Question 1
# In[ ]:
for altitude in range(1000,10000):
altitude=int(input('enter altitude'))
if altitude ==1000:
print('plane is safe to land')
elif altitude > 1000 and altitude < 5000:
print('bring the plane down to 1... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.