content stringlengths 7 1.05M |
|---|
#
# PySNMP MIB module OMNI-gx2EDFA-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/OMNI-gx2EDFA-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:24:00 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar ... |
class CQueue:
def __init__(self):
self.q = []
def appendTail(self, value: int) -> None:
self.q.append(value)
def deleteHead(self) -> int:
return self.q.pop(0) if self.q else -1
# Your CQueue object will be instantiated and called as such:
# obj = CQueue()
# obj.appendTail(value)... |
# -*- coding: utf-8 -*-
__author__ = "venkat"
__author_email__ = "venkatram0273@gmail.com"
def block_indentation():
if 10 > 10:
print("if statement indented")
elif 10 > 5:
print("elif statement indented")
else:
print("else default statement indented")
for i in range(10):
... |
# read numbers
numbers = []
with open("nums.txt", "r") as f:
lines = f.readlines()
numbers = [int(i) for i in lines]
print(numbers)
# part 1 soln
for x,el in enumerate(numbers):
for i in range(x+1, len(numbers)):
if el + numbers[i] == 2020:
print("YAY: {} {}".format(el, num... |
# -*- coding: UTF-8 -*-
def read_file(filepath):
with open(filepath,'rb') as file:
# yield (file.readlines())
for i in file:
yield i
a = read_file(r'D:\pythontest/test\python_100/2/base.txt')
print(next(a))
|
class Solution:
def destCity(self, paths: List[List[str]]) -> str:
start = (list(map(lambda x: x[0], paths)))
for path in paths:
if path[1] not in start: return path[1]
# dic = {}
# for i in range(len(paths)):
# dic[paths[i][0]] = paths[i][1]... |
# Copyright 2020 Software Improvement Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed ... |
# Crie um programa que tenha uma tupla com várias palavras. (Não usar acentos).
# Depois disso, você deve mostrar, para cada palavra, quais são suas vogais.
palavras = ('aprender', 'programar', 'linguagem', 'python', 'curso', 'gratis',
'estudar', 'praticar', 'trabalhar', 'mercado', 'programador', 'futuro')
... |
class Solution:
def rotatedDigits(self, n: int) -> int:
goodnums = set([2,5,6,9])
badnums = set([3,4,7])
ans = 0
for i in range(1,n+1):
good = False
num = i
while num:
remains = num % 10
if remains in good... |
# TODO: Chain class
"""
The Chain class will support chaining multiple Digests together.
The Chain feature should have support to be placed ANYWHERE within the ApiForm and chain together DigestFeatures
A single Digest Feature should run within the same thread/process and be relatively simple.
A series of Digest Feat... |
def d(n):
return n + sum(list(map(int, list(str(n)))))
nums = [x for x in range(1, 10001)]
for i in range(1, 10001):
if d(i) in nums:
nums.remove(d(i))
for num in nums:
print(num) |
class Node:
def __init__(self, data) -> None:
self.data = data
self.next = None
self.traversed = False
class LinkedList:
def __init__(self) -> None:
self.head = self.rear = None
def check_loop(node):
temp = node.head
if temp == None:
print("Empty!!")
... |
def is_horiz_or_vert(line):
return line[0]["x"] == line[1]["x"] or line[0]["y"] == line[1]["y"]
def parse(input_line):
return [
{"x": int(x), "y": int(y)}
for x, y in [s.strip().split(",") for s in input_line.split("->")]
]
def do_it(input_lines, diagonals=False):
lines = [
l... |
windowWight=650
windowHeight=650
ellipseSize=200
def setup():
size(windowWight,windowHeight)
smooth()
background(255)
fill(50,80)
stroke(100)
strokeWeight(3)
noLoop()
def draw():
ellipse(windowWight/2, windowHeight/2 - ellipseSize/2, ellipseSize, ellipseSize)
ellipse(wi... |
# list(map(int, input().split()))
# int(input())
def main(N, A):
ans = 0
for n in range(1, N+1, 2):
if A[n-1] % 2 == 1:
ans += 1
print(ans)
if __name__ == '__main__':
N = int(input())
A = list(map(int, input().split()))
main(N, A)
|
budget = 150.0
pi_string = '03.14159260'
age_string = '21'
# convert string to number
pi_float = float(pi_string)
age_int = int(age_string)
# convert and print to string
print('The budget is: $' + str(budget))
print('pi_string: ' + pi_string)
print('pi_float: ' + str(pi_float))
print('age_int: ' + str(age_int)) |
ficha=list()
while True:
nome=str(input('Nome: '))
nota1=float(input('Nota 1: '))
nota2=float(input('Nota 2: '))
media= (nota1+nota2)/2
ficha.append([nome, [nota1,nota2],media])
resp=str(input('Quer continuar? [S/N]: ')).strip().upper()
if resp in 'N':
break
print('-='*30)
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Copyright 2020, Yutong Xie, UIUC.
Convert sorted array to binary search tree using recursion.
'''
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.le... |
#exercice 1
#calories calculator. create 2 functions main, calories.
#It should calculate the amount of calories from
#the grams of carbs, fat and protein.
#calories from fat = fat gram x 9
#calories from carbs = carbs gram x 4
#calories from protein = protein gram x 4
#example:
#if item has 1 gram of fat, 2 grams o... |
# 7-3. Multiples of Ten: Ask the user for a number, and then report whether the number is a multiple of 10 or not.
number = input("Tell me a number man :v : ")
number = int(number)
if number % 10 == 0:
print(str(number) + " is a multiple of 10.")
else:
print(str(number) + " is not a multiple of 10.") |
"""
https://www.codewars.com/kata/5168bb5dfe9a00b126000018/train/python
Given a string, return its reverse
"""
def solution(string):
return ''.join(reversed([char for char in string]))
def solution2(string):
return string[::-1]
print(solution2('world'))
|
# pylint: skip-file
# pylint: disable=too-many-instance-attributes
class GcloudConfig(GcloudCLI):
''' Class to wrap the gcloud config command'''
# pylint allows 5
# pylint: disable=too-many-arguments
def __init__(self,
project=None,
region=None):
''' Construct... |
"""
This file holds default settings value and it is used like template for creation userdef.py file.
If you want to change any variable listed below do that in generated userdef.py file.
"""
#args.gn template path
webRTCGnArgsTemplatePath='./webrtc/windows/templates/gns/args.gn'
#Path where nuget package and all... |
class TouchData:
x_distance = None
y_distance = None
x_offset = None
y_offset = None
relative_distance = None
is_external = None
in_range = None
def __init__(self, joystick, touch):
self.joystick = joystick
self.touch = touch
self._calculate()
def _calculate... |
STYLE = {
'fore':
{ # 前景色
'black': 30, # 黑色
'red': 31, # 红色
'green': 32, # 绿色
'yellow': 33, # 黄色
'blue': 34, # 蓝色
'purple': 35, # 紫红色
'cyan': 36, # 青蓝色
'white': 37, # 白色
},
'back':
{... |
def testing_system(right_answer, Iras_answer):
if right_answer == Iras_answer:
print("YES")
else:
print("NO")
testing_system(int(input()), int(input())) |
#!/usr/bin/env python3
'''
lib/subl
sublime-ycmd sublime utility module.
'''
|
class StyleGenerator:
def __init__(self):
self.sidebar_style = {}
self.content_style = {}
def getSidebarStyle(self):
return self.sidebar_style
def getContentStyle(self):
return self.content_style
def setSidebarStyle(self, position="fixed", top=0, left=0, bottom=0, width="0rem", padding="0rem 0rem", back... |
# implementation of linked list using python 3
# Node class
class Node:
#function to initialize the node object
def __init__(self, data):
self.data = data #assign data
self.next = None #initialize next as null
#Linked list class
class LinkedList:
#function to initialize the linked
#... |
def test_content_id_2():
content_id_head = pd.DataFrame({'Content_Rating': ['Everyone', 'Everyone', 'Everyone', 'Teen', 'Everyone']},
index=[101, 101, 101, 102, 101])
assert content_id_df.head().equals(content_id_head) |
#Mostrar a tabuada de qualquer número solicitado e repita até o usuário digitar um número negativo
n = cont = 0;
while True:
print('*=' * 25);
n = int(input(f'De qual número você deseja ver a tabuada? '));
print('*=' * 25);
if n < 0:
break;
while cont <= 10:
mult = n * c... |
"""
PASSENGERS
"""
numPassengers = 2713
passenger_arriving = (
(0, 6, 4, 4, 1, 0, 4, 5, 3, 6, 1, 0), # 0
(4, 10, 2, 0, 1, 0, 5, 8, 5, 5, 3, 0), # 1
(1, 6, 3, 2, 5, 0, 4, 4, 5, 5, 1, 0), # 2
(3, 10, 6, 3, 3, 0, 5, 5, 4, 2, 0, 0), # 3
(2, 6, 4, 1, 0, 0, 7, 8, 6, 6, 1, 0), # 4
(4, 9, 8, 3, 3, 0, 4, 7, 6, 7, ... |
#!/usr/bin/python
__all__ = [
'__title__', '__summary__', '__uri__', '__version__', '__author__',
'__email__', '__license__', '__copyright__',
]
__title__ = 'django-simple-datatable'
__summary__ = 'Simple datatable'
__uri__ = 'https://github.com/2375452377/django-simple-datatable.git'
__version__ = '0.1.1'
_... |
'''
def square(num):
return num*num
a = square(10)
print(a)
'''
# Lamda function --> Function creating using an expression using lamda keyword
square = lambda num: num*num # creating a square lamda function which takes num as input and multiply num*num and return to square
num = 10
a=square(num)
print(a)
... |
HTTP_METHOD_DELETE = "DELETE"
HTTP_METHOD_GET = "GET"
HTTP_METHOD_POST = "POST"
HTTP_METHOD_PUT = "PUT"
|
GYRO_FSR_250DPS = 0
GYRO_FSR_500DPS = 1
GYRO_FSR_1000DPS = 2
GYRO_FSR_2000DPS = 3
|
# Hash Table; Two pointers; string
# Given a string, find the length of the longest substring without repeating characters.
#
# Example 1:
#
# Input: "abcabcbb"
# Output: 3
# Explanation: The answer is "abc", with the length of 3.
# Example 2:
#
# Input: "bbbbb"
# Output: 1
# Explanation: The answer is "b", with the l... |
ACTIONS_MAP = {
"attack": "do_combat",
"area": "do_combat",
"block": "do_combat",
"disrupt": "do_combat",
"dodge": "do_combat",
"change character": "change_class",
"change class": "change_class",
}
|
#!/usr/bin/env python3
count = 0
while count < 5:
print(count)
count += 1
|
# A sample config file
emailInformation = dict(
fromEmail = 'senderAccount',
toEmail = 'toAccount',
username = 'sender username',
password = 'sender password'
)
dropboxInfo = dict(
token = 'dropbox token'
) |
# -*- coding: utf-8 -*-
# Copyright 2019 Cohesity Inc.
class SchedulingPolicyProtoMonthlySchedule(object):
"""Implementation of the 'SchedulingPolicyProto_MonthlySchedule' model.
TODO: type model description here.
Attributes:
count (int): Count of the day on which to perform the backup (look
... |
# -*- mode: python -*-
# vi: set ft=python :
"""
Downloads a precompiled version of buildifier and makes it available to the
WORKSPACE.
Example:
WORKSPACE:
load("@drake//tools/workspace:mirrors.bzl", "DEFAULT_MIRRORS")
load("@drake//tools/workspace/buildifier:repository.bzl", "buildifier_repositor... |
def largest_palindrome_product(digit_num):
pals = list()
for i in range(1,10**digit_num):
for j in range(1,10**digit_num):
n = (10**digit_num-i)*(10**digit_num-j)
p = ""
for i in range(1,len(str(n))+1):
p = p + str(n)[-i]
if p... |
def LEFT(i):
return 2*i + 1
def RIGHT(i):
return 2*i + 2
def swap(A, i, j):
temp = A[i]
A[i] = A[j]
A[j] = temp
def heapify(A, i, size):
left = LEFT(i)
right = RIGHT(i)
largest = i
if left < size and A[left] > A[i]:
largest = left
if right < size and A[right] > A[la... |
print('Normalmente, quantos litros de sangue uma pessoa tem? Em média, quantos são retirados numa doação de sangue? \n a) Tem entre 2 a 4 litros. São retirados 450 mililitros. \n b) Tem entre 4 a 6 litros. São retirados 450 mililitros. \n c) Tem 10 litros. São retirados 2 litros. \n d) Tem 7 litros. São retirados 1,5 l... |
# точка в правоъгълник
# Проверка дали точка {x, y} се намира вътре в правоъгълника {x1, y1} – {x2, y2}. Входните данни се четат от конзолата и се състоят от 6 реда:
# десетичните числа x1, y1, x2, y2, x и y (като се гарантира, че x1 < x2 и y1 < y2).
x1 = float(input())
y1 = float(input())
x2 = float(input())
y2 = flo... |
class APIException(Exception):
"""
Encapsulates HTTP errors thrown by the microcosm API.
"""
def __init__(self, error_message, status_code=None, detail=None):
self.status_code = status_code
self.detail = detail
super(APIException, self).__init__(error_message)
def __str__(s... |
# -*- coding:utf-8 -*-
__author__ = 'lee'
"""
数据库自定义异常
"""
class ExistError(Exception):
def __init__(self, exist, message):
self.exist = exist
self.message = message
def __str__(self):
return repr(self.message)
class NotExistError(Exception):
def __init__(self, notexist, message)... |
# -*- coding: utf-8 -*-
"""
@author: mwahdan
"""
class NluDataset:
def __init__(self, text, tags, intents):
self.text = text
self.tags = tags
self.intents = intents |
""" Model for Player """
class Player:
""" Player class """
def __init__(self, player_name):
self.name = player_name
def say_hello(self):
""" Function used by player to introduce him/her self """
print("Hello, I'm ", self.name)
def score_runs(self, runs):
... |
values = {
frozenset(("id=72", "vaultUserPermissions%5B2%5D=readOnly")): {
"status_code": "200",
"text": {
"responseData": {},
"responseHeader": {
"now": 1492630700324,
"requestId": "WPe8rAoQgF4AADVcyb0AAAAv",
"status": "ok",
... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def get_inputs():
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
# I N P U T S #
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
# Atmosphere options
... |
IX86_UNCONDITIONAL_JMP_CALLS = ["JMP", "JMP_SHORT", "JMP_FAR", "CALL"]
IX86_CONDITIONAL_JMP_CALLS = [
"JA",
"JA_SHORT",
"JNBE",
"JNBE_SHORT",
"JAE",
"JAE_SHORT",
"JNB",
"JNB_SHORT",
"JB",
"JB_SHORT",
"JBAE",
"JBAE_SHORT",
"JC",
"JC_SHORT",
"JBE",
"JBE_SHO... |
# Programowanie I R
# Zadania - seria 4.
# Zadanie 2.
#***********************************************************************************
# Klasa Stack
#***********************************************************************************
class Stack:
def __init__(self):
self._items = []
def... |
#!/usr/bin/env python
#Lists
categoryList = []
factList = []
caseList = []
saList = []
ruleList = []
erList = []
foList = []
evalList = []
#Operations
AND = " AND "
OR = " OR "
NEG = " NEG "
IMPLY = " IMPLY "
EQUALS = " EQUALS "
LESSER = " LESSER "
GREATER = " GREATER "
#Classes
class Cat... |
def median3():
numbers1 = input("What numbers are we finding the median of?: ")
numbers1 = numbers1.split(",")
num = []
for i in numbers1:
i = float(i)
n = num.append(i)
n1 = num.sort()
z = len(num)
if z % 2 == 0:
median1 = num[z//2]
median2 = num[z//2-1]
... |
POSTGRES_USER=test
POSTGRES_PASSWORD=password
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=example |
"""
Given a string s formed by digits ('0' - '9') and '#' . We want to map s to
English lowercase characters as follows:
- Characters ('a' to 'i') are represented by ('1' to '9') respectively.
- Characters ('j' to 'z') are represented by ('10#' to '26#')
respectively.
Return the... |
# Reverse Cipher
# https://www.nostarch.com/crackingcodes/ (BSD Licensed)
# message = 'Three can keep a secret, if two of them are dead.'
# message = '.daed era meht fo owt fi ,terces a peek nac eerhT'
message = input('Enter message: ')
translated = ''
i = len(message) - 1
while i >= 0:
translated = translated + ... |
# Input: nums = [0,1,2,2,3,0,4,2], val = 2
# Output: 5, nums = [0,1,4,0,3]
def removeElement(arr, element):
dictonary = {}
output = 0
for iter in arr:
if iter in dictonary:
dictonary[iter] += 1
else:
dictonary[iter] = 1
# {0: 2, 1: 1, 3: 1, 4: 1}
delete = in... |
# Define a coverage report
#
# Arguments:
# name : prefix of generated targets
# tests : list of test targets run for the report
# srcpath_include : (optional) list of path prefixes used to restrict data from matching sourcefiles
# srcpath_exclude : (optional) list of path prefixes used to exclude data from mat... |
nota1 = float(input('\033[36mQual sua primeira nota? '))
nota2 = float(input('Qual a sua segunda nota? '))
med = (nota1 + nota2) / 2
print('\033[35mSua média é {:.1f}'.format(med))
if med < 5.0:
print('Seu Resultado: \033[31mREPROVADO')
elif 7 > med >= 5:
print('Seu Resultado: \033[33mRECUPERAÇÃO')
else:
pr... |
# arrays
bonus = [0.005, 0.12, 0.345, 0.68, 1.125, 1.68, 2.345, 3.12, 4.005, 5 , 6.105, 7.32 ]
loss = [0]
probability = [0.359, 0.330, 0.3 , 0.27 , 0.24, 0.21 , 0.18, 0.15 , 0.12, 0.09 , 0.06, 0.03 ]
time = []
cookies_lost = []
# constants
cps = 11.696 #quadrillion
# counters
total_time = 0
... |
#
# PySNMP MIB module RADLAN-CDB-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RADLAN-CDB-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:45:42 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2... |
# atom
# : OPEN_PAREN (yield_expr | testlist_comp)? CLOSE_PAREN
# | OPEN_BRACKET testlist_comp? CLOSE_BRACKET
# | OPEN_BRACE dictorsetmaker? CLOSE_BRACE
# | REVERSE_QUOTE testlist COMMA? REVERSE_QUOTE
# | dotted_name
# | ELLIPSIS
# | name
# | PRINT
# | EXEC
# | MINUS? number
# ... |
name = "Maciek"
age = 22
print("imie:", name, "\nwiek:", age)
fovoruite_language = "Python"
print(age + 4)
fact_or_fiction = 3 < 5
print(fact_or_fiction)
|
#encoding: utf8
"""
(C) 2012 by Maho (?ukasz Mach)
License: GPL
Poor man's i18n support for Pyjamas.
_("identifier") returns you translated version of "identifier". If you want
original (English) version, just do nothing. If you want other language
(eg. PL), please import tra... |
# def test_one():
# assert sum([1, 12], 2) == 15
#
#
# test_one()
def my_unit_test(func):
def wrapper(a):
print(f'my unit test started for {a}')
func(a)
print('my unit test ended')
return wrapper
# @my_unit_test
# def test_one(a):
# assert sum([1, 12], a) == 15
# test_one(1)... |
'''
this util is made to validate the subdomains getting added into the hosts
if they're like the main subdomain the program is scanning. then it should pass
otherwise it shouldn't return anything
'''
def vSubdomains(sList, huntingTarget):
mainSubdomains = []
for singleSubdomain in sList:
if singleSub... |
n = int(input('Enter number: '))
flag = False
if n > 1:
for i in range(2, int(n**0.5)+1): # we only need to check up to square root
if n % i == 0:
print(f"{n} divides by {i}")
flag = True
break
if flag:
print(n, 'is not a prime number')
else:
print(n, 'is a prime ... |
# https://github.com/carpedm20/emoji
# http://www.unicode.org/emoji/charts/full-emoji-list.html
class Button:
Camera = u'\U0001F4F7'
FileFolder = u'\U0001F4C1'
FileFolderOpen = u'\U0001F4C2'
RightArrowUp = u'\U00002934'
RightArrowDown = u'\U00002935'
CrossMarkRed = u'\U0000274C'
CheckMark ... |
def parse_password_data(string):
# This function the password data into the 4 usable components: e.g. "1-9 x: xwjgxtmrzxzmkx"
minbound, maxbound, letter, passwords = [], [], [], []
for line in string:
firstpart = line.split(sep = '-')
secondpart = firstpart[-1].split(sep = ' ', ma... |
def indenter():
return " " * 4
def indent(n, lines, start, stop):
i = n * indenter()
for j in range(start, stop):
lines[j] = i + lines[j]
return lines
def check_shape(shape, typename):
if len(shape) == 1 and typename == "Polyvertex":
return True
if len(shape) != 2:
r... |
__all__ = [
'CommandHelpers',
'CommandManager',
'CommandRegistry',
'CommandManagerCallback'
]
|
"""
Given an integer, n, and n space-separated integers as input, create a tuple, t, of those n integers. Then compute and print the result of
hash(t).
Note: hash() is one of the functions in the __builtins__ module, so it need not be imported.
"""
if __name__ == '__main__':
n = int(input("Enter the length\n"))
... |
# ------------------------------------------------------------------------
# File: model_info.py
# ------------------------------------------------------------------------
# Licensed Materials - Property of IBM
# 5725-A06 5725-A29 5724-Y48 5724-Y49 5724-Y54 5724-Y55 5655-Y21
# Copyright IBM Corporation 2008, 2020. All ... |
def test_checkboxes(env, similar, template, expected):
template = env.from_string(template)
assert similar(template.render(), expected)
def test_checkboxes_with_id_and_name(env, similar, template, expected):
template = env.from_string(template)
assert similar(template.render(), expected)
def test_ch... |
# coding: utf-8
# Aluno: Misael Augusto
# Matrícula: 117110525
# Problema: Filtrando ELementos e Alterando uma Lista
def filtra_altera_lista(num, lista):
for i in range(len(lista) -1, -1, -1):
if i % num > 0:
lista.pop(i)
|
with open('assets/day08.txt', 'r') as file:
lines = [line for line in file.read().splitlines()]
collection = []
for line in lines:
inputs, outputs = tuple(line.split('|'))
collection.append({
'input': [digit for digit in inputs.strip().split(' ')],
'output': [digit for digit in outputs.str... |
"""" Ayuda en operaciones con ficheros de forma eficiente
"""
def count_of_matches_in_a_file(file_path, matches):
"""Cuenta el numero de coincidencias en un archivo dada la ruta del fichero y la función de coincidencia
:param file_path: La ruta del fichero de texto a analizar
:param matches: La función d... |
'''
try:
f = open('file1.txt', 'r')
except IOError:
print('Problem with Input Output...\n')
else:
print('No Problem with Input Output...')
'''
try:
f = open('file1.txt', 'w')
except IOError:
print('Problem with Input Output...\n')
else:
print('No Problem with Input Output...')
|
lines_colors = [
"Red",
"DodgerBlue",
"LimeGreen",
"Gold",
"MediumSlateBlue",
"Brown",
"Olive",
"Orange",
"DarkGoldenRod",
"Salmon",
"Fuchsia",
"Aqua",
"LightSlateGray",
"MediumBlue",
"GreenYellow",
"DarkRed",
"DarkMagenta",
"Khaki",
"MediumSp... |
#main class
class Characters:
def __init__(self,
name="none",
lastname="none",
age="none",
hp="50",
title="none",
language="none",
race="human or unknown",
weakness="none"
... |
#!/usr/bin/python3
# -*- coding: utf-8 -*-
class SimParameters(object):
def __init__(self):
self.run_time = 0
self.name = "default"
def debug(self):
print('SimParameters instance :')
print('---------------------------------------------------')
|
class Digit(object):
def __init__(self, representation):
self._digit_representation = representation
def scale(self, scale_factor=1):
if scale_factor == 1:
return self
scaled_lines = []
for line in self._digit_representation:
scaled_lines.append(line[0] +... |
class Stemmer:
'''
Stemmer object, this is a simplified Porter stemmer,
our stemmer is rule based, most of its functions replace suffix of a word to a new
suffix base on several rules to change the word to its stem
'''
def __init__(self):
self.buffer = "" # buffer for word ... |
"""
CONHECENDO ALGUMAS FUNÇÕES BOOLEAN
"""
e = (input('Digite algo: '))
print('O tipo primtivo desse valor é {}'.format(type(e)))
print('Só tem espaço?',e.isspace())
print('É um número? ',e.isnumeric())
print('É alfabético? ',e.isalpha())
print('É alfanumérico? ',e.isalnum())
print('Está em maiúsculo? ',e.isupper()... |
def mult(m,n):
ans = 0
while n>0:
ans+=m
n-=1
return ans |
loci = 20000000 #!!!
sample = 26
mu = 2e-6
rr = 1.05e-6
Na = 1000
Bt = 67
|
#
# PySNMP MIB module ELTEX-MES-SMON-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ELTEX-MES-SMON-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:01:55 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, ... |
try:
number=float(input("Enter a number between 0.0 and 1.0: "))
if number < 0 or number > 1:
print("Bad score!")
elif number >= 0.9:
print("A")
elif number >= 0.8:
print("B")
elif number >= 0.7:
print("C")
elif number >= 0.6:
print("D")
else:
print("F")
except:
print("Bad score!") |
"""
class BinaryTreeNode(object):
def __init__(self, value):
self.value = value
self.left = None
self.right = None
def insert_left(self, value):
self.left = BinaryTreeNode(value)
return self.left
def insert_right(self, value):
self.right = BinaryTreeNode(v... |
# Any or All
# Problem Link: https://www.hackerrank.com/challenges/any-or-all/problem
_ = int(input())
l = input().split()
print(all([int(i) > 0 for i in l]) and any([j == j[::-1] for j in l]))
|
print(2 not in [1,2,3])
print(2 not in [4,5])
print(1 not in [1] not in [[1]])
print(3 not in [1] not in [[1]])
|
"""
№283. К.Ю. Поляков.
На числовой прямой даны отрезки A = [80; 90], B = [30; 50] и C = [10; N] и функция
F(x) = (¬(x ∈ A) -> (x ∈ B)) && (¬(x ∈ C) -> (x ∈ A))
При каком наименьшем числе N функция F(x) истинна более чем для 25 целых чисел x?
"""
a = {i for i in range(80, 91)}
b = {i for i in range(30, 51)... |
def sum_of_numbers_in_an_integer(num):
answer = 0
while num > 0:
last_num = num % 10
num = num // 10
answer += last_num
print(answer)
def main():
num = int(input("Enter a number: " ))
sum_of_numbers_in_an_integer(num)
main() |
'''
Created on 2017. 4. 12.
@author: Byoungho Kang
'''
class Calculator:
def __init__(self, first, second):
self.first = first
self.second = second
def plus(self):
return self.first + self.second
def minus(self):
return self.first - self.s... |
#Questao 9
fila = []
print("Fila: ", fila)
fila.append("Tarefa E")
print("Inserindo um elemento no final da fila: ", fila)
fila.append("Tarefa I")
print("Inserindo outro elemento no final da fila: ", fila)
fila.append("Tarefa C")
print("Inserindo outro elemento no final da fila: ", fila)
fila.append("Tarefa F")
pri... |
def hello(verb, path, query):
return "Server received your " + verb + " request" + str(query) + "\r\n"
def register(urlMapper):
urlMapper["/hello"] = hello
|
###############################################
# list comprehension
x = [1, 2, 3, 4, 5, 6]
y = []
# metodo tradicional
for k in x:
y.append(k ** 2)
print(y)
# método list comprehension
y = [i**2 for i in x]
print(y)
# list comprehension condicional
y = [i**2 for i in x if i % 2 == 0]
print(y)
###############... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.