content stringlengths 7 1.05M |
|---|
PROJECT_TITLE = 'xmolpp2'
PLUGINS = [
]
INPUT_PAGES = ['index.rst']
OUTPUT = f'../_/site'
LINKS_NAVBAR1 = [
('C++ API', './api/c++', []),
('Python API', './api/python', []),
('Github', 'https://github.com/sizmailov/pyxmolpp2', [])
]
SEARCH_DISABLED = True |
try:
arr= []
print(" Enter the integer inputs and type 'stop' when you are done\n" )
while True:
arr.append(int(input()))
except:# if the input is not-integer, just continue to the next step
unique=[]
repeat=[]
s=0
for i in arr:
if i not in unique:
unique.append... |
# Elaborar um programa que leia duas matrizes A e B de uma dimensão do tipo vetor com dez elementos inteiros cada. Construir uma matriz C de mesmo tipo e dimensão que seja formada pelo quadrado da soma dos elementos correspondentes nas matrizes A e B. Apresentar os elementos da matriz C.
A = []
B = []
C = []
for ... |
#!/usr/bin/env python3
def merge_data(dfl, dfr, col_name):
for column in dfr.columns.values:
col = col_name + str(column)
dfl[col] = dfr[column]
|
n1 = int(input('Digite um valor: '))
n2 = int(input('Digite um valor: '))
s = n1 + n2
print('O tipo da classe de n1 e n2 é > ', type(n1))
print('A soma entre {} e {} vale {}'.format(n1, n2, s)) |
##################
# General Errors #
##################
# No error occurred.
NO_ERROR = 0
# General error occurred.
FAILED = 1
# Operating system error occurred.
SYS_ERROR = 2
# Out of memory.
OUT_OF_MEMORY = 3
# Internal error occurred.
INTERNAL = 4
# Illegal number representation given.
ILLEGAL_NUMBER = 5
# N... |
class BinaryTree(LogicalBase):
def _get(self, node, key):
while node is not None:
if key < node.key:
node = self._follow(node.left_ref)
elif node.key < key:
node = self._follow(node.right_ref)
else:
return self._follow(node.value_ref)
raise KeyError
def _insert(self, node, key, value_... |
class BagOfHolding:
'''Generic holder class; allows for .<anything> attribute usage
'''
pass
class FreqPair:
'''Container for an arbitrary object and an observed frequency count
'''
item = None
freq = 0
def __init__(self, item, freq=0):
self.item = item
self.freq = freq... |
def fav_city(name):
print(f"One of my favorite cities is {name}.")
fav_city("Santa Barbara, California!")
fav_city("Madrid, Spain")
fav_city("Moscow, Russia")
# Library: A grouping of variables and functions that someone else has written and verified for day to day usage.
# Tiobe-index is a great tracker to see w... |
#encoding:utf-8
subreddit = 'climbing'
t_channel = '@r_climbing'
def send_post(submission, r2t):
return r2t.send_simple(submission)
|
#
# PySNMP MIB module CISCO-GSLB-TC-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-GSLB-TC-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:59:23 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... |
pessoas = {'nome': 'Gustavo', 'sexo': 'M', 'idade': 22}
del pessoas['sexo'] # APAGA O ITEM (chave + valor) "SEXO"
for k, v in pessoas.items():
print(f'{k} = {v}')
print()
pessoas['nome'] = 'Leandro' # A CHAVE "NOME" PASSA A SER O VALOR "LEANDRO"
for k, v in pessoas.items():
print(f'{k} = {v}')
print()
... |
TICKET_PRICE = 10
tickets_remaining = 100
SERVICE_FEE = 5
def calculate_price(number_of_tickets):
return number_of_tickets * TICKET_PRICE + SERVICE_FEE
while tickets_remaining > 0:
print("There are {} tickets remaining.".format(tickets_remaining))
username = input("What is your name? ")
try:
... |
print("Tugas Pratikum 3. Latihan 3")
a=100000000
for s in range(1,9):
if(s>=1 and s<=2):
b=a*0
print("Laba bulan ke-",s,":",b)
if(s>=3 and s<=4):
c=a*0.1
print("Laba bulan ke-",s,":",c)
if(s>=5 and s<=7):
d=a*0.5
print("Laba bulan ke-",s,":",d)
if(s==8... |
'''
From projecteuler.net
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
'''
#list comprehension solution
def solution(n):
return sum(num for num in range(1,n,1) if num%3==0 ... |
size = [165, 167, 160, 173, 105, 135, 149, 122, 147, 145, 126, 99, 116, 164, 101, 175]
flag = ""
for s in size:
flag += chr(s - 50)
print(flag)
|
# In this program we iterate from 1 to m with iterator i, if which, it yeilds 0 as remainder, we add it to the factors of m in fm list.
# Similarly we do for n and store it in fn.
# we compare fm and fn for common factors, if we found any, we store it on another list called cf.
# We then return the last element of the ... |
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
def cre_linked_list(arr):
head = ListNode(arr[0])
res = head
for a in arr[1:]:
tmp = ListNode(a)
head.next, head = tmp, tmp
return res
head = cre_linked_list([1, 1, 2, 2, 3, 3, 4, 4])
class Sol... |
def compute_lcm(x, y):
if x > y:
greater = x
else:
greater = y
while(True):
if((greater % x == 0) and (greater % y == 0)):
lcm = greater
break
greater += 1
return lcm
def hcfnaive(a,b):
if(b==0):
return a
else:
return hcfnaive(b,a%b... |
"""Count the number of Duplicates
Write a function that will return the count of distinct case-insensitive
alphabetic characters and numeric digits that occur more than once in the input string.
The input string can be assumed to contain only alphabets (both uppercase and lowercase)
and numeric digits
Example:
"abcde"... |
'''
URL: https://leetcode.com/problems/groups-of-special-equivalent-strings/
Difficulty: Easy
Description: Groups of Special-Equivalent Strings
You are given an array A of strings.
A move onto S consists of swapping any two even indexed characters of S, or any two odd indexed characters of S.
Two strings S and T a... |
#
# This file contains definitions of text and functions useful for debugging
#
def hexdump(s):
print(":".join("{:02x}".format(c) for c in s))
# Textual messages for the bits in the status message response
status_summary_text = [
# byte 0
[
['Command not complete','Command complete'], # bit 0
... |
'''
Given an array of n distinct non-empty strings, you need to generate minimal possible abbreviations for every word following rules below.
Begin with the first character and then the number of characters abbreviated, which followed by the last character.
If there are any conflict, that is more than one words share ... |
n = int(input('Digite um valor inteiro e eu calcularei o fatorial desse número: '))
x = n
m = n
while n > 1:
m = m * (n-1)
n = n - 1
print('{}! = {}'.format(x,m))
|
def get_new_board(dimension):
"""
Return a multidimensional list that represents an empty board (i.e. empty string at every position).
:param: dimension: integer representing the nxn dimension of your board.
For example, if dimension is 3, you should return a 3x3 board
:return: For example i... |
FOL_TEST_WORLD = {
'domain': [1, 2, 3, 4],
'constants': {
'a': 1,
'b': 2,
'c': 3
},
'extensions': {
"P": [[1]],
"R": [[1], [2], [4]],
"Q": [[1], [2], [3], [4]],
"C": [[1, 2], [2, 3]],
"D": [[2, 3]]
}
}
# see readme for link to original... |
input = """
a(1).
a(2) :- true.
true.
"""
output = """
a(1).
a(2) :- true.
true.
"""
|
#
# PySNMP MIB module ZYXEL-VLAN-STACK-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ZYXEL-VLAN-STACK-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:46:11 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (defau... |
def callwith(f, *args, **kwargs):
def inner(*ignoreargs, **ignorekwargs):
return f(*args, **kwargs)
return inner
def eq(target):
def inner(index, item: dict):
return item == target
return inner
def veq(key, val):
def inner(index: int, item: dict):
return item[key] == val
... |
# We are given an unsorted array containing ‘n’ numbers taken from the range 1 to ‘n’.
# The array originally contained all the numbers from 1 to ‘n’, but due to a data error,
# one of the numbers got duplicated which also resulted in one number going missing. Find both these numbers.
# Example 1:
# Input: [3, 1, 2... |
html_data = '''
<div class="main-container container-sm">
<h3 class="text-center"> links for <a href=/abs/1987gady.book.....B/abstract><b>1987gady.book.....B</b></a></h3>
<div class="list-group">
<div class="list-group-item">
<a href="http://... |
def get_density(medium, temp_K):
if medium == "water":
A = 206.7
B = 7.01013
C = -0.0195311
D = 0.0000164685
elif medium == "glycol":
#From Internet (2016/04/08) Propylene Glycol
A = 1187.6
B = -0.3789
C = -0.0003
D = -0.0000007
else:
... |
class Sku:
def __init__(self, sku, price, storage, shipping_fee, style_color, style_size, image_url,
extra_image_list, weight=300):
self.sku = sku
self.price = price
self.storage = storage
self.shipping_fee = shipping_fee
self.style_color = style_color
... |
print('===== DESAFIO 042 =====')
l1 = float(input('Digite o primeiro lado: '))
l2 = float(input('Digite o segundo lado: '))
l3 = float(input('Digite o terceiro lado: '))
#! verificando a existencia do triangulo #
if (l1 < l2 + l3) and (l2 < l3 + l1) and (l3 < l1 + l2):
print('o triangulo existe')
else:
print(... |
"""
STATEMENT
Given a binary tree and a sum, determine if the tree has a root-to-leaf path
such that adding up all the values along the path equals the given sum.
CLARIFICATIONS
-
EXAMPLES
(needs to be drawn)
COMMENTS
- A recursive solution over the left and right subtree should work.
- The base cases are tricky, si... |
class A:
"""
Namespaces: The Whole Story::
1. qualified and unqualified names are treated differently, and that some
scopes serve to initialize object namespaces;
2. Unqualified names (e.g., X) deal with scopes;
3. Qualified attribute names (e.g., object.x) use object namespaces;
4. Some scopes initialize o... |
if 5<6:
print('Linija1')
print('Linija2')
print("Linija3")
print("Linija4")
if 5>6:
print("Linija1")
print("Linija2")
print("Linija3")
print("Linija4") |
#!/usr/bin/env python3
# coding:utf-8
class Solution:
def GetNumberOfK(self, data, k):
if data == [] or k > data[-1]:
return 0
left = 0
right = len(data) - 1
while left < right:
mid = left + (right - left) // 2
if data[mid] < k:
... |
class FeedFormatter(object):
def __init__(self):
pass
def format(self, contents):
# To be overwritten by derived classes
pass
class PPrintFormatter(FeedFormatter):
def __init__(self):
super(PPrintFormatter, self).__init__()
def format(self, contents):
result =... |
class MissingSignerError(Exception):
"""Raised when the ``signer`` attribute has not
been set on an :class:`~flask_pyjwt.manager.AuthManager` object.
"""
class MissingConfigError(Exception):
"""Raised when a config value is missing from an
:class:`~flask_pyjwt.manager.AuthManager` object.
Arg... |
class Root(object):
@property
def greetings(self):
return [
Greeting('mundo'),
Greeting('world')
]
class Greeting(object):
def __init__(self, person):
self.person = person
|
def _rec(origin, l1, target, l2):
if not l1:
return l2
elif not l2:
return l1
a1 = _rec(origin, l1-1, target, l2) + 1
a2 = _rec(origin, l1, target, l2-1) + 1
a3 = _rec(origin, l1-1, target, l2-1) + \
(origin[l1 - 1] != target[l2 - 1])
return min(a1, a2, a3)
... |
fichier = open("Rosetta/main/source/src/apps.src.settings","r")
commands = fichier.readlines()
fichier.close()
commands = commands[:-1] + [" 'cifparse',\n"] + [commands[-1]]
fichier = open("Rosetta/main/source/src/apps.src.settings","w")
fichier.writelines(commands)
fichier.close()
|
project = "Textstat"
master_doc = 'index'
extensions = ['releases']
releases_github_path = 'shivam5992/textstat'
releases_unstable_prehistory = True
html_theme = 'alabaster'
templates_path = [
'_templates',
]
html_sidebars = {
'**': [
'about.html',
'navigation.html',
'relations.htm... |
"""week 8 warmup exercises and videos
"""
iso = {1: 'Mon', 2: 'Tue', 3: 'Wed', 4: 'Thu',
5: 'Fri', 6: 'Sat', 7: 'Sun'}
counts = {}
for key in iso:
counts[iso[key]] = 0
print(counts)
def who_has_s(d, s):
for keys in d.keys():
for values in s.values():
if 's' in values:... |
#
# PySNMP MIB module ROHC-RTP-MIB (http://pysnmp.sf.net)
# ASN.1 source http://mibs.snmplabs.com:80/asn1/ROHC-RTP-MIB
# Produced by pysmi-0.0.7 at Sun Feb 14 00:27:06 2016
# On host bldfarm platform Linux version 4.1.13-100.fc21.x86_64 by user goose
# Using Python version 3.5.0 (default, Jan 5 2016, 17:11:52)
#
( Ob... |
class SingletonMeta(type):
def __call__(cls, *args, **kwargs):
raise RuntimeError('Classes Singleton têm o construtor privado.')
def get_instance(cls, *args, **kwargs):
if not cls.__dict__.get('_instance'):
cls._instance = type.__call__(cls, *args, **kwargs)
return cls._ins... |
name = 'help'
cmdhelp = 'Display help'
###
def init_parser(parser):
return
def main(cnsapp, args):
'''Stub that actually does nothing'''
pass |
config = {}
def process_adapter_message(message):
type = message.get("type", None)
if type == "initialize":
return __initialize__()
elif type == "set_state":
return __set_state__(message)
return {
"type": "exception.not_supported",
"origin_type": type
}
def __in... |
def exposify(cls):
# cls.__dict__ does not include inherited members, so we can't use that.
for key in dir(cls):
val = getattr(cls, key)
if callable(val) and not key.startswith("_"):
setattr(cls, "exposed_%s" % (key,), val)
return cls
class Singleton:
"""
A non-thread-safe helper class to ease implementi... |
"""
Space : O(1)
Time : O(n)
"""
class Solution:
def maxDepth(self, s: str) -> int:
n = len(s)
if n == 0:
return 0
max_dep, dep = 0, 0
for i in range(n):
if s[i] == '(':
dep += 1
max_dep = max(max_dep, dep)
... |
# Where You Came From [Kaiser] (25808)
recoveredMemory = 7081
sm.flipDialoguePlayerAsSpeaker()
sm.sendNext("Memories... Memories from when? When I became Kaiser?")
sm.sendSay("No, that's not good enough. Tear... Velderoth... "
"We were young and naive, but we believed. That was my beginning. "
"That was when I learne... |
# use functions to break down the code
def create_matrix(rows):
result = []
for _ in range(rows):
result.append(input().split())
return result
def in_range(indices, rows_range, columns_range):
is_in_range = True
r_1, c_1, r_2, c_2 = indices
if not r_1 in rows_range or not r_2 in rows_ra... |
#
# file: power_of_ten.py
#
# Report if the input is a power of ten and, if so, its exponent.
#
# Pipe the output of primes10.frac to this program to see the progression
# of 10**prime.
#
# RTK, 05-Apr-2021
# Last update: 05-Apr-2021
#
################################################################
def isPo... |
def binary_search(arr, val):
min = 0
max = len(arr) - 1
while True:
if max < min:
return -1
mid = (min + max) // 2
if arr[mid] < val:
min = mid + 1
elif arr[mid] > val:
max = mid - 1
else:
return mid |
# Copyright 2018 Minds.ai, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... |
MAX_SIZE = 71
MAX_NUMBER = 2**32
matrix = [[0 for _ in range(MAX_SIZE)] for _ in range(MAX_SIZE)]
for i in range(MAX_SIZE):
matrix[i][0] = 1
matrix[1][i] = 1
for i in range(2, MAX_SIZE):
for j in range(1, MAX_SIZE):
sum = matrix[i][j-1] + matrix[i-1][j]
matrix[i][j] = sum if sum < MAX_NUM... |
class Control(object):
def __init__(self, states, start_state):
states = {str(x): x for x in states}
self.done = False
self.states = states
self.state_name = start_state
self.state = self.states[self.state_name]
self.state.startup()
def update(self):
if s... |
def fatorial(numero, show=False):
""" Função Fatorial()
fatoria(numero, show = false)
numero : numero inteiro
show = True: mostrar contagem
False : não mostrar contagem
None : considera False
ex:
fatorial(5, True)
5x4x3x2x1 = 120
"""
... |
def sum_nums(a: int, b: int) -> int:
return a + b
def sub_nums(a, b):
return a - b
def mul_nums(a, b):
return a * b
def div_nums(a, b):
return a / b
def main():
num1 = int(input('Введите первое число: '))
num2 = int(input('Введите второе число: '))
operator = input('Введите операцию:... |
# Copyright (C) 2005 Michael Urman
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
class Metadata(object):
"""An abstract dict-like object.
Metadata is the base class ... |
class DLinkedList:
def __init__(self, def_value='B'):
self.default_val = def_value
self.curr = Node(val=self.default_val)
@property
def data(self):
return self.curr.value
@data.setter
def data(self, val):
self.curr.value = val
def get_to_left_end(self):
... |
class APIKeyMiddleware(object):
"""
A simple middleware to pull the users API key from the headers and
attach it to the request.
It should be compatible with both old and new style middleware.
"""
def __init__(self, get_response=None):
self.get_response = get_response
... |
def arquivoExiste(nome):
try:
a = open(nome, 'rt')
a.close()
except FileNotFoundError:
return False
else:
return True
def criarArquivo(nome):
try:
a = open(nome, 'wt+')
a.close()
except:
print('\033[31mHouve um erro na criação do arquivo!\033... |
# coding=utf-8
"""
ValueRef and LogicalBase classes
"""
class ValueRef(object):
"""
ValueRef abstract class
"""
def prepare_to_store(self, storage):
"""
Will be implemented
:param storage:
"""
pass
@staticmethod
def referent_to_string(referent):
... |
def heapify(array, current, heap_size):
left = 2 * current + 1
right = 2 * current + 2
if left <= heap_size and array[left] > array[current]:
largest = left
else:
largest = current
if right <= heap_size and array[right] > array[largest]:
largest = right
if largest != cu... |
global variables, localspace
if str(variables.get("DOCKER_ENABLED")).lower() == 'true':
# Be aware, that the prefix command is internally split by spaces. So paths with spaces won't work.
# Prepare Docker parameters
containerName = variables.get("DOCKER_IMAGE")
dockerRunCommand = 'docker run '
dock... |
"""
[2016-11-11] Challenge #291 [Hard] Spaghetti Wiring
https://www.reddit.com/r/dailyprogrammer/comments/5cetzo/20161111_challenge_291_hard_spaghetti_wiring/
> **Note:** As has been [pointed
out](https://www.reddit.com/r/dailyprogrammer/comments/5cetzo/20161111_challenge_291_hard_spaghetti_wiring/d9wd9h1/),
this pro... |
power = {'BUSES': {'Area': 1.33155,
'Bus/Area': 1.33155,
'Bus/Gate Leakage': 0.00662954,
'Bus/Peak Dynamic': 0.0,
'Bus/Runtime Dynamic': 0.0,
'Bus/Subthreshold Leakage': 0.0691322,
'Bus/Subthreshold Leakage with power gating': 0.0259246,
'Gate... |
class Cart:
turn_list = ["<", "|", ">"]
directions = {"left":"<", "right":">", "upp":"^", "down":"v"}
def __init__(self, x, y, direction):
self.x = x
self.y = y
self.direction = direction
self.cross_count = 0
self.crashed = False
def __lt__(self, other):
... |
try:
with open('input.txt', 'r') as myinputfile:
print('how about here?')
for line in myinputfile:
print(line)
except FileNotFoundError:
print('That file does not exist')
print('Execution never gets here') |
class SearchaniseException(Exception):
def __init__(self, message):
super(SearchaniseException, self).__init__(message)
class PSAWException(Exception):
def __init__(self, message):
super(PSAWException, self).__init__(message)
|
# Copyright (C) 2019 GreenWaves Technologies
# All rights reserved.
# This software may be modified and distributed under the terms
# of the BSD license. See the LICENSE file for details.
quote = lambda s: '"'+s+'"'
class CodeBlock():
def __init__(self, starting_indent=0, indent_char=" "):
self._inde... |
class Solution(object):
def computeArea(self, A, B, C, D, E, F, G, H):
"""
:type A: int
:type B: int
:type C: int
:type D: int
:type E: int
:type F: int
:type G: int
:type H: int
:rtype: int
"""
overlap = max(min(C, G) -... |
#
#
def minRemoveToMakeValid(s):
"""
:type s: str
:rtype: str
"""
opens, closes = [], []
for i in range(len(s)):
c = s[i]
if c == '(':
opens.append(i)
elif c == ')':
if len(opens) == 0:
closes.append(i)
else:
... |
def minSwaps(arr):
count = 0
for i in range(len(arr)):
val = arr[i]
if val == i + 1:
continue
for j in range(i + 1, len(arr)):
if arr[j] != i+1:
continue
arr[i] = arr[j]
arr[j] = val
count += 1
return count
|
def log(parser,logic,logging,args=0):
if args:
options = args.keys()
if "freq" in options:
try:
sec = int(args["freq"][0])
logging.freq = sec
except:
parser.print("-freq: "+str(args["freq"][0])+" could not cast to integer")
... |
'''
Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of them. If there are less than 2k but greater than or equal to k characters, then reverse the first k characters and left ... |
#!/usr/bin/env python
# -*- coding:utf-8 -*-
def binary_search(mylist, item):
low = 0
high = len(mylist) - 1
while low <= high:
mid = int((low + high) / 2)
guess = mylist[mid]
if guess == item:
return mid
if guess > item:
high = mid - 1
else... |
# -*- coding: utf-8 -*-
DESC = "monitor-2018-07-24"
INFO = {
"DescribeProductEventList": {
"params": [
{
"name": "Module",
"desc": "接口模块名,固定值\"monitor\""
},
{
"name": "ProductName",
"desc": "产品类型过滤,比如\"cvm\"表示云服务器"
},
{
"name": "EventName",
... |
'''
3. Faça um programa para receber um valor e escrever se é “positivo”
ou “negativo” (considere o valor zero como positivo).
'''
print('Digite um numero:')
numero = float(input())
if(numero>=0):
print('Valor é positivo')
else:
print('Valor é negativo')
|
#
# PySNMP MIB module HUAWEI-MUSA-MA5100-CONFMIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-MUSA-MA5100-CONFMIB
# Produced by pysmi-0.3.4 at Wed May 1 13:47:24 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version ... |
number = 1024
# using map() to separate each element and store it in a list
digit_list = list(map(int, str(number)))
print(digit_list)
# Using list comprehension
digit_list2 = [int(a) for a in str(number)]
print(digit_list2)
# Simplest approach
digit_list3 = list(str(number))
print(digit_list3) |
#quiz2
print("convercion de monedad")
"""
Dolar: 1USD
EUR: 1USD =0.8965 EUR
YEN: 1USD =101.5744 YEN
BP: 1USD = 0.7702 BP
MXN: 1USD = 19.7843
"""
print("Introduce la cantidad de monedas que deseas convertir ")
i= int(input("valor monetario en centavos:"))
Dolar= i/100
print(str(Dolar) + "dolares")
EUR= Dolar*0.8965
p... |
# -*- coding: utf-8 -*-
myName = input("Please enter your name: ")
myAge = input("What about your age: ")
print ("Hello World, my name is", myName, "and I am", myAge, "years old.")
print ('''Hello World.
My name is James and
I am 20 years old.''')
|
num = [2, 5, 9, 1]
num[2] = 3
#num[4] = 7 -> não posso aumentar o tamanho da lista, apenas trocar os elementos
num.append(7)
#num.sort() -> ordenar a lista
num.sort(reverse=True)
num.insert(2, 2)
if 5 in num:
num.remove(5)
else:
print('Não encontrei o número 4')
#num.pop(2) -> excluir elementos da lista
print... |
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 1 14:22:58 2021
@author: NOTEBOOK
"""
class BankAccount():
#The __init__ method accepts an arguement for the account's balance.
#It is assigned to the__balance attribute.
def __init__(self, bal):
self.__balance = bal
#The deposit ,m... |
# coding=utf-8
class Thumb(object):
_engine = None
def __init__(self, url='', key=None, fullpath=None):
self.url = url
self.key = key
self.fullpath = fullpath
def __nonzero__(self):
return bool(self.url)
def __bool__(self):
return bool(self.url)
def as_... |
"""This problem was asked by Google.
Implement a PrefixMapSum class with the following methods:
insert(key: str, value: int): Set a given key's value in the map. If the key already exists, overwrite the value.
sum(prefix: str): Return the sum of all values of keys that begin with a given prefix.
For example, you s... |
def lengthOfLongestSubstring(s: str) -> int:
left = length = 0
visited = dict()
for pos, char in enumerate(s):
if char in visited and visited[char] >= left:
left = visited[char] + 1
else:
length = max(length, pos - left + 1)
visited[char] = pos
retur... |
# 1. Greeting
print("Welcome to Jeon's blind auction program!")
print(
"&& Rule: In the blind auction, if there are identical bid with one item, the winner is the first person who input his/her bid!"
)
# 2. Ask name
bid_log_dictionary = {}
# 2-1. Creat function that checks if it is a valid name
def name_check(na... |
#
# PySNMP MIB module DIAL-CONTROL-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DIAL-CONTROL-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 16:52:54 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar ... |
# This file is responsible for validating if a action is valid
def how_may_of(dices):
# Find out how many values there are for a number
out = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0}
for dice in dices:
out[dice.value] += 1
return out
def check(dices, settings):
dices = sorted(dices, key=lamb... |
# Este es un módulo con funciones que saludan
def saludar():
print("Hola, te estoy saludando desde la función saludar() del módulo saludos")
class Saludo():
def __init__(self):
print("Hola, te estoy saludando desde el __init__ de la clase Saludo") |
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 18 08:52:57 2016
@author: Stella
"""
|
class User:
userList = []
def __init__(self, fname, lname, username, pwd):
"""
_init_ methods that help us define properties for our new user object
Args:
fname: New user first name
lname: New user last name
username: new Username
pwd: New user password
... |
# -*- coding: utf-8 -*-
def index():
redirect(URL(c='default', f='index'))
def show_products():
if request.vars.category:
product_list = db(db.product.default_category == request.vars.categor... |
def to_range(s):
a, b = s.split("-")
a, b = int(a), int(b)
return lambda x: x >= a and x <= b
def parse_rule(line):
key, values = line.split(":")
rules = list(map(to_range, values.split("or")))
return (
key.strip(),
lambda foo: any(map(lambda rule: rule(foo), rules)),
)
d... |
#!/usr/bin/env python3
print(50 + 50) # add
print (50 - 50) # subtract
print(50 * 50) # multiply
print( 50 / 50) #divide
print (50 + 50 - 50 * 50 / 50) # PEMDAS
print (50 ** 2) #raising to power. exponents
print (50 % 6) #modulo, get remainder
print( 50 // 6) # divides w/ no remainder
|
"""
Macros for defining toolchains.
See https://docs.bazel.build/versions/master/skylark/deploying.html#registering-toolchains
"""
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains")
load("@rules_java//java:repositories.bzl", "remote_jdk11_repos")
load("@rules_jvm_externa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.