content stringlengths 7 1.05M |
|---|
project = 'Daydream'
label = project + ' Documentation'
copyright = '2020, Remo'
author = 'Remo'
# The short X.Y version
version = '0.1'
# The full version, including alpha/beta/rc tags
release = '0.1 alpha'
# -- General configuration ---------------------------------------------------
extensions = []
templates_pat... |
pn = float(input('Qual preço do produto: '))
print('''INFORMAÇÕES SOBRE O PAGAMENTO!!!
[ 1 ] á vista dinheiro/cheque
[ 2 ] á vista cartão
[ 3 ] em até 2x no cartão
[ 4 ] em até 3x ou mais no cartão''')
opção = int(input('Qual a opção? '))
if opção == 1:
total = pn - (pn * 10 / 100)
elif opção == 2:
total = pn -... |
# Do not edit this file directly.
# It was auto-generated by: code/programs/reflexivity/reflexive_refresh
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
def gflags():
http_archive(
name="gflags" ,
sha256="ed82ef64389409e378fc6ae55b8b60f11a0b4bbb7e004d5ef9e791f40af19a6e" ,
... |
#
# PySNMP MIB module Fore-Redundancy-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Fore-Redundancy-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:17:22 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default... |
x=[10,20,30,40,50,60,70,80,90,100]
num=0
p=0
sum=0
print('Enter positions to add no.s')
p= int(input())
p= p+1
while num<p:
sum=x[num]+sum
num=num+1
print(sum) |
class ModelConfig:
"""
ModelConfig is a utility class that stores important configuration option about our model
"""
def __init__(self, model, name, input_img_dimensions, conv_layers_config, fc_output_dims, output_classes, dropout_keep_pct):
self.model = model
self.name = name
s... |
#!/usr/bin/env python3
# display a welcome message
print("The Miles Per Gallon application")
print()
another_trip = "y"
while another_trip == "y":
# get input from the user
miles_driven = float(input("Enter miles driven: "))
gallons_used = float(input("Enter gallons of gas used: "))
cost_pe... |
"""Mocks
"""
def decode_token(self, token):
"""Decode a token emitted by Kisee"""
return {
"iss": "example.com",
"sub": "toto",
"exp": 1534173723,
"jti": "j2CMReXSUwcnvPfhqq7cSg",
}
def decode_token__new_user(self, token):
"""Decode a token emitted by Kisee
with a... |
# Aidan O'Connor - G00364756 - 22/02/2018
# Exercise 4, Topic 4: euler5.py
# Each new term in the Fibonacci sequence is generated,
# by adding the previous two terms.
# By starting with 1 and 2, the first 10 terms will be:
# 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
# By considering the terms in the Fibonacci sequen... |
# Class based on employee - separating to check decorators
class Player:
def __init__(self, first, last):
self.first = first
self.last = last
def email(self):
return '{}.{}@email.com'.format(self.first, self.last)
@property
def fullname(self):
return '{} {}'.format(se... |
n = int(input().strip())
a = list(map(int, input().strip().split(' ')))
swaps = 0
for i in range(n):
for j in range(n - 1):
if(a[j] > a[j + 1]):
a[j], a[j + 1] = a[j + 1], a[j]
swaps += 1
print('Array is sorted in {} swaps.'.format(swaps))
print('First Element: {}'.format(a.pop(0))... |
problems = input().split(";")
count = 0
for problem in problems:
if "-" in problem:
split_problem = problem.split("-")
count += int(split_problem[1]) - int(split_problem[0]) + 1
else:
count += 1
print(count)
|
class Solution:
def widthOfBinaryTree(self, root):
"""
:type root: TreeNode
:rtype: int
"""
if not root:
return 0
queue = [(root, 1)]
left, right, size, max_width = 0, 0, 1, 1
while len(queue) > 0:
node = queue[0]
qu... |
def isFib(x):
a=0
b=1
if x==a:
return True
if x==b:
return True
n=2
while(b<x):
t=a+b
a=b
b=t
#print(b)
n += 1
if x == b:
return True
return False
for i in range(0,20):
print(i,isFib(i)) |
# -*- coding: utf-8 -*-
"""Base utils for all Bandicoot related utilities."""
fields = {
"interaction": 0,
"direction": 1,
"country_code": 2,
"correspondent_id": 3,
"datetime": 4,
"call_duration": 5,
"antenna_id": 6,
"longitude": 7,
"latitude": 8,
"location_level_1": 9,
"loc... |
#
# PySNMP MIB module DNOS-METRO-DOT1AG-PRIVATE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DNOS-METRO-DOT1AG-PRIVATE-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:51:46 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python ve... |
class Person:
def __init__(self, name: str):
self.name = name
self.partner = None
def __str__(self):
return self.name
def marry(self, spouce): #: Person):
self.partner = spouce
spouce.partner = self
class Student(Person):
def __init__(self, name, ID: int):
self.name = name
self.ID = ID
|
"""
This file is part of WSQL-SDK
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS F... |
tour_stops = input()
original_stops = tour_stops
command = input()
while command != 'Travel':
current_action = command.split(':')
action = current_action[0]
if action == 'Add Stop':
index = int(current_action[1])
new_stop = current_action[2]
if 0 <= index <= len(tour_stops):
... |
Y = []
filepath = 'newdatay.csv'
with open(filepath) as fp:
line = fp.readline()
cnt = 1
while line:
print("Line {}: {}".format(cnt, line.strip()))
Y.append(float(line.strip()))
line = fp.readline()
cnt += 1
print (Y)
|
# lextab.py. This file automatically created by PLY (version 3.11). Don't edit!
_tabversion = '3.10'
_lextokens = set(('AFTER', 'AND', 'ATTRIBUTE', 'BBOX', 'BEFORE', 'BETWEEN', 'BEYOND', 'COMMA', 'CONTAINS', 'CROSSES', 'DISJOINT', 'DIVIDE', 'DURATION', 'DURING', 'DWITHIN', 'ENVELOPE', 'EQ', 'EQUALS', 'FLOAT', 'GE'... |
# AUTOGENERATED! DO NOT EDIT! File to edit: 00_core.ipynb (unless otherwise specified).
__all__ = ['kir']
# Cell
def kir(x):
" this is practice session"
return x/2 |
## Non-idiomatic file reading statement
# No.1
def n13():
f = open('file.txt')
a = f.read()
f.close()
# No.2
def n14():
f = open(path, "rb")
result = do_something_with(f)
f.close()
# No.3
def n15():
f = open('file.ext')
try:
contents = f.read()
finally:
f.close()
# ... |
''' Refaça o desafio 35 dos triângulos, acrescentando o recurso de mostrar
qual tipo de triângulo será formado:
- equilátero: todos os lados iguais
- isósceles: dois lados iguais
- escaleno: todos os lados diferentes'''
print('-=-' * 20)
print('Analisador de Triângulos')
print('-=-' * 20)
t1 = float(input('Informe o t... |
def centuryFromYear(year):
""" Given a year, return the century it is in. -> int """
iter = year//100 + 1
sec = 0
for i in list(range(iter)):
if (sec+100 >= year):
return i+1
else:
sec += 100
|
END = "\033[0m"
BOLD = "\033[1m"
RED = "\033[91m"
GREEN = "\033[92m"
YELLOW = "\033[93m"
BLUE = "\033[94m" |
junk_drawer = [3, 4]
# Using the list provided, add a pen, a scrap paper, a 7.3 and a True element
junk_drawer.append('pen')
junk_drawer.append('scrap paper')
junk_drawer.append(7.3)
junk_drawer.append(True)
# What's the length of the list now?
# Save it in an object named drawer_length
drawer_length = len(junk_d... |
#!python3
# https://www.hackerrank.com/challenges/make-it-anagram/
s1 = input()
s2 = input()
letters_s1 = {}
for c in s1:
if c not in letters_s1:
letters_s1[c] = 0
letters_s1[c] += 1
dels = 0
for c in s2:
if c not in letters_s1:
dels += 1
else:
letters_s1[c] -= 1
if l... |
def aumentar(preço, taxa):
resultado = (preço*taxa/100) + preço
return resultado
def diminuir(preço, taxa):
resultado = preço - (preço*taxa/100)#Essa taxa é diferença, pois está em um scopo local
return resultado
def dobro(preço):
resultado = preço*2
return resultado
def metade(preço):
... |
# 67. Add Binary
class Solution:
# Bit Manipulation
def addBinary(self, a: str, b: str) -> str:
x, y = int(a, 2), int(b, 2)
while y:
ans = x ^ y
carry = (x & y) << 1
x, y = ans, carry
|
"""Kata url: https://www.codewars.com/kata/5467e4d82edf8bbf40000155."""
def descending_order(num: int) -> int:
return int(''.join(sorted(str(num), reverse=True)))
|
###################### Code By - ORASHAR #########################
###################### Age check fro child, teen or adult #########################
try:
n = int(input("Enter the number: "))
if n < 10:
print("child")
elif n <= 18:
print("teenager")
else:
prin... |
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def zigzagLevelOrder(self, root):
cur_st = []
next_st = []
data = []
left2right = 0
... |
#
# PySNMP MIB module Dell-rldot1q-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Dell-rldot1q-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:43:09 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar ... |
#!/usr/bin/env python3
class Dir:
"""
kwargs:
parent parent node DirEnt ref
url node list api url
"""
def __init__(self, **kwargs):
self._parent = kwargs.get('parent', False)
self._url = kwargs.get('url', False)
@staticmethod
def printlist(filelist):
... |
CSI = '\x1b['
OSC = '\x1b]'
BEL = '\a'
def sequence(letter, fields=1, default=[]):
def _sequence(*values):
output = list(values)
if fields >= 0 and len(output) > fields:
raise ValueError('Invalid number of fields, got %d expected %d' %
(len(output), fields))
wh... |
""" Sort Array with three types of elements: You are given three types of elements in the array and you have to
sort them accordingly"""
"""Solution"""
def segregate_elements_three(arr) -> list:
i = 0
j = len(arr)-1
mid = 0
while mid <= j:
if arr[mid] == 0:
arr[i], arr[mid] =... |
n = int(input())
c = 0
for i in range (1, n):
temp = input().split()
temp[0] = int(temp[0])
temp[1] = int(temp[1])
if temp[0] == temp[1] - 1:
c += 1
print (c) |
def getPaginatedParamValues(request):
pagesizemax = 500
offset = request.args.get('offset')
if offset is None:
offset = 0
else:
offset = int(offset)
pagesize = request.args.get('pagesize')
if pagesize is None:
pagesize = 100
else:
pagesize = int(pagesize)
if pagesize > pagesizemax:
... |
class Solution:
def isIsomorphic(self, s, t):
if len(s) != len(t): # isomorphic strings must be same length
return False
d = {}
h = {}
for i in range(0, len(s)):
x = s[i]
y = t[i]
if x not in d and y not in h: # Both chars have NOT been seen before (NOT in hash table)
d[x] = [i] # store... |
x=int(input("enter the starting of range"))
y=int(input("enter the end of range"))
for num in range(x,y):
if num>=0:
print(num, end=" ")
|
# !/usr/bin/python
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------- # {{{
# Name: __NAME__
# Purpose: In README.md
#
# Author: Kilo11
#
# Created: __DATE__
# Last Change: 2021/03/11 17:21:03.
# Copyright: (c) SkyDog __YEAR__
# Licence: SDS1****
... |
class PointVariables:
def __init__(self):
self.LE = "9999999.0"
self.CE = "9999999.0"
self.HAE = "9999999.0"
self.LON = "0"
self.LAT = "0" |
"""
Packages custom Andon exceptions.
"""
class AndonAppException(Exception):
"""
Generic catch-all exception when a request to Andon fails.
"""
pass
class AndonBadRequestException(AndonAppException):
"""
Generic exception when a request to Andon fails because there's something
wrong with ... |
class MyDecorator:
def __init__(self, function):
self.function = function
def __call__(self):
print("before the function is called.")
self.function()
print("after the function is called.")
@MyDecorator
def function():
print("Howtoautomate.in.th")
... |
def binSearch( arr, left, right, x):
if right >= left:
mid = left + ( right-left ) / 2
# If the element is present at the middle itself
if arr[mid] == x:
return mid
# If the element is smaller than mid,then it can only be present in the le... |
vc = float(input('Qual o valor da casa? '))
vs = float(input('Qual o seu salário? '))
a = int(input('Em quantos anos você vai pagar? '))
vp = vc / (a * 12)
mínimo = vs * 30 / 100
if vp <= mínimo:
print('A prestação mensal será de R${}!'.format(vp))
else:
print('Seu empréstimo foi negado por ultrapassar 30% do s... |
"""
Make plotting nice and consistent
"""
# mpl.rcParams.update({
# 'axes.spines.left': True,
# 'axes.spines.bottom': True,
# 'axes.spines.top': False,
# 'axes.spines.right': False,
# 'legend.frameon': False,
# 'figure.subplot.wspace': .01,
# 'figure.subplot.hspace': .01,
# 'figure.figsi... |
n,k=[int(x) for x in input().split(" ")]
arr=list(map(int,input().rstrip().split()))
z=[]
arr=sorted(arr)
arr=arr[::-1]
for i in range(len(arr)//k+1):
if len(arr)>=k:
z.append(arr[0:k])
a=arr[0:k]
for j in a:
arr.remove(j)
else:
z.append(arr)
if len(z[-1]... |
def solution(A, B):
answer = 0
A.sort()
B.sort(reverse=True)
for i, j in zip(A, B):
answer += i*j
return answer
|
guide_data_doc = """
▪ *help*
👉Access this guide
▪ *helprex*
👉To know about how you can get involved and contribute to this project
▪ *echo <Anything>*
👉I will respond with <Anything>
▪ *tt*
👉Sends Timetable
▪ *gcc*
👉Sends All available Google Classrooms
▪ *ml*
👉Sends All available Meetings
▪ *about*
👉A li... |
# In python numbers (int, float) are the same
print(5)
print(6.58)
# Calculation is the same how other languages
print(5.8 + 6)
print((8 + 1) * 10)
|
class LCCS:
def __init__(self, Ls=[8, 16, 32, 64, 128, 256, 512], step=1):
self.Ls = Ls
self.step = step
self.name = 'lccs'
def for_param(self, distance):
for l in self.Ls:
yield '-L %d --step 1'%l
class LCCS_MP:
def __init__(self, Ls=[8, 16, 32, 64, 128, 256,... |
# Crie um script em Python que pede uma frase (string) ao usuário e em seguida um caractere. Em seguida, seu script deve dizer quantas vezes aquele caractere apareceu na frase digitar. Use função com parâmetros.
def conta_caractere(texto,char):
count = 0
for letra in texto:
if letra == char:
... |
a,b,c,d,e=map(int,input().split(" "))
bl=False
x=a
while(a>0):
# print(b,d)
# print(bl)
if(b==d):
bl=True
break
b+=1
d-=1
if(b==d):
bl=True
break
if(b>x):
b=1
if(d<1):
d=x
if(b==d):
bl=True
break
a-=1
if(bl==Fals... |
"""Constants for the ELV USB-WDE1 integration."""
DOMAIN = "elv_usb_wde"
DEFAULT_DEVICE = "/dev/ttyUSB0"
DEFAULT_SPEED = 9600
|
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Script: solution.py
# @Author: Pradip Patil
# @Contact: @pradip__patil
# @Created: 2018-02-10 20:47:08
# @Last Modified By: Pradip Patil
# @Last Modified: 2018-02-10 20:48:49
# @Description: https://www.hackerrank.com/challenges/py-hello-world/problem
if __name__ == '... |
# зодиак + Выигрышные номера тиража + предыдущий тираж к примеру 2000
def test_zodiac_winning_draw_numbers_for_previous_draw(app):
app.ResultAndPrizes.open_page_results_and_prizes()
app.ResultAndPrizes.click_game_zodiac()
app.ResultAndPrizes.click_winning_draw_numbers()
app.ResultAndPrizes.select_dra... |
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Blazars at low frequencies"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* The bulk velocity is $ v $.\n",
"* The bulk Lorentz factor is $$ \\gamma = \\frac{1}{\\sqrt{1 - \\beta^{2}}} $$ where ... |
#
# PySNMP MIB module DSLAM-UPC-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DSLAM-UPC-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:54: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 201... |
# -*- coding: utf-8 -*-
"""
bluebuttonuser
FILE: __init__.py
Created: 11/24/15 12:12 AM
"""
__author__ = 'Mark Scrimshire:@ekivemark'
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 5 12:29:53 2019
@author: sodatab
MITx: 6.00.1x
"""
"""
02-02 Paying Debt off in a Year - Fixed Rate
---------------------------------------------
Now write a program that calculates the minimum fixed monthly payment needed in order pay off a cred... |
# Copyright 2015-2016 NEC Corporation. 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 requ... |
m=input("enter the string:\t")
if m.isdigit():
print("the given string is numeric")
else:
print("the given string is not numeric")
|
class Solution:
def isScramble(self, s1, s2):
l1, l2 = len(s1), len(s2)
if l1 != l2:
return False
dp = [[[False] * (l1 + 1) for _ in range(l1)] for _ in range(l1)]
for l in range(1, l1 + 1):
for i in range(l1 - l + 1):
for j in range(l1 - l + 1... |
#!/usr/local/bin/python3
ORDERS = {
'N': lambda s, w, a: (s, (w[0] + a, w[1])),
'S': lambda s, w, a: (s, (w[0] - a, w[1])),
'E': lambda s, w, a: (s, (w[0], w[1] + a)),
'W': lambda s, w, a: (s, (w[0], w[1] - a)),
'F': lambda s, w, a: ((s[0] + a * w[0], s[1] + a * w[1]), w),
'L': lambda s, w, a: ... |
class Environment:
def evaluate(self, phenotype):
assert False, "'evaluate' must be implemented"
if __name__ == '__main__':
# a test for evaluate
flag = False
try:
Environment().evaluate('phenotype')
except AssertionError:
flag = True
assert flag, "NG in 'envi... |
class Tires:
def __init__(self, size: int):
self.size = size
self.pressure = 0
def get_pressure(self) -> int:
return self.pressure
def pump(self, psi: int):
self.pressure = psi
class Engine:
def __init__(self, fuel_type: str):
self.fuel_type = fuel_type
... |
#! python
'''
a program that displays a list of lists in a well formatted tabular structure
'''
tableData = [
['apples', 'oranges', 'cherries', 'banana'],
['Alice', 'Bob', 'Carol', 'David'],
['dogs', 'cats', 'moose', 'goose']
]
def printTable(entries: list) -> None:
colWidths = [0] * len(entries)
# loop ... |
with open("hightemp.txt") as f:
pre, city = [], []
for line in f.read().split('\n')[:-1]:
pre_i, city_i, _, _ = line.split()
pre.append(pre_i)
city.append(city_i)
with open("col1.txt", 'w') as f1:
f1.write('\n'.join(pre))
with open("col2.txt", 'w') as f2:
f2.write... |
class DetachFromCentralOption(Enum,IComparable,IFormattable,IConvertible):
"""
Options for workset detachment behavior.
enum DetachFromCentralOption,values: ClearTransmittedSaveAsNewCentral (3),DetachAndDiscardWorksets (2),DetachAndPreserveWorksets (1),DoNotDetach (0)
"""
def __eq__(self,*args):
""" x... |
#
# PySNMP MIB module CIENA-CES-RADIUS-CLIENT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CIENA-CES-RADIUS-CLIENT-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:31:56 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python versio... |
with open('/dev/stdin/') as f:
f.readline()
for l in f:
print(l, end='')
|
# coding: utf8
# Author: Wing Yung Chan (~wy)
# Date: 2017
# Distinct Powers
# Find the size of the set S
# For all a^b fo 2<=a<=100 and 2<=b<=100
# S = {s = a^b | a,b in 2..100}
def problem29():
powers = set()
for a in range(2,101):
for b in range(2,101):
powers.add(pow(a,b))
re... |
# ----------------------------------------------------------------------------
# CLASSES: nightly
#
# Test Case: reflect.py
#
# Tests: mesh - 3D curvilinear, single domain,
# 3D rectilinear, single domain.
# 3D unstructured, single domain.
# p... |
# Let's refactor star.py into an almost-Thompson algorithm. The idea:
# represent a regex with tree nodes augmented with a 'chain' link that
# can be cyclic. The nodes plus the chains form the Thompson NFA
# graph, but a node can be labeled with 'star' (as well as Thompson's
# 'literal' and 'either' nodes), and we deri... |
coordinates_E0E1E1 = ((126, 75),
(127, 71), (127, 72), (127, 73), (127, 74), (127, 76), (128, 67), (128, 69), (128, 70), (128, 77), (128, 86), (128, 103), (128, 104), (129, 67), (129, 71), (129, 72), (129, 73), (129, 74), (129, 75), (129, 77), (129, 86), (130, 67), (130, 69), (130, 70), (130, 71), (130, 72), (130, 73... |
#!/usr/bin/env python3
# https://codeforces.com/problemset/problem/1180/A
# 关键: 每次加几个?
n = int(input())
print(n**2+(n-1)**2)
|
# These functions return the probablity of 'value' in the given distribution
def gaussian(value, μ, 𝜎):
# Calculate variance
𝜎2 = 𝜎 * 𝜎
# Calculate exponentiated term
exp = np.power(np.e, -(np.power(value - μ, 2) / (2 * 𝜎2)))
# Calculate denominator term
den = np.power((np.sqrt(2 * np.pi... |
{
'targets': [
{
'target_name': 'cpu_features',
'type': 'static_library',
'cflags': [ '-O3' ],
'include_dirs': [
'include',
'include/internal',
],
'sources': [
'include/cpu_features_cache_info.h',
'include/cpu_features_macros.h',
# uti... |
'''
Desenvolva um programa que leia seis números inteiros e mostre a soma apenas daqueles que forem pares. Se o valor digitado for ímpar, desconsidere-o.
# - Pontos a serem estudados
'''
soma = 0 #
cont = 0 #
for c in range(1, 7 ):
num = int(input('Digite um número: '))
if num % 2 == 0:
soma += num #
... |
n = int(input())
r = 0
l = n - 1
right_diagonal = 0
left_diagonal = 0
for x in range(n):
line = input()
numbers = list(
map(
int,
line.split()
)
)
right_diagonal += numbers[r]
left_diagonal += numbers[l]
r += 1
l -= 1
print(
abs(
rig... |
class Animal:
@staticmethod
def eat():
return "eating..."
class Dog(Animal): # Single Inheritance
@staticmethod
def bark():
return "barking..."
a = Animal()
print(a.eat())
dog = Dog()
print(dog.eat())
print(dog.bark())
|
#!/usr/bin/env python
#
# ----------------------------------------------------------------------
#
# Brad T. Aagaard, U.S. Geological Survey
# Charles A. Williams, GNS Science
# Matthew G. Knepley, University of Chicago
#
# This code was developed as part of the Computational Infrastructure
# for Geodynamics (http://ge... |
class SlackException(Exception):
pass
class SlackConnectionError(SlackException):
pass
class SlackReadError(SlackException):
pass
|
# Summing numbers
def summer(nums):
total = 0
numbers = nums.split(" ")
for num in numbers:
total += int(num)
return total
print(summer(input("Enter nums: ")))
|
"""Some examples of how to add comments to Python code."""
# This is a comment
# and also like this
"""You can add comments like this to your code"""
"""You can do
this for multi-line comments
as well"""
"""
or like this style if you prefer
"""
def print_function(my_string):
'''You can use triple quoted ones... |
def check_data_continuity(df, main_column, precision):
"""
Check data continuity and return a dataframe with the filtered values
Keyword arguments:
df -- a pandas.DataFrame object that stores the data
main_column -- the column index by which the data will be filtered (unique
values, us... |
def getcard():
print('please enter card number')
card=str(input()).split(' ')
return card
def luhn(card):
reverse=''
temp=''
for z in card:
reverse=z+reverse
total=0
for x in range(0, len(reverse)):
if x==0 or x%2==0:
temp=temp+reverse[x]
... |
HTBClass = """\
tc class add dev {interface} parent {parent} classid {handle} \
htb rate {rate}{units} ceil {ceil}{units}\
"""
|
# -*- coding: utf-8 -*-
__author__ = 'Jordan Woerndle'
__email__ = 'jordan52@gmail.com'
__version__ = '0.1.0'
|
def loadDataSet():
dataMat = []
labelMat = []
fr = open('testSet.txt')
for line in fr.readLines():
lineArr = line.strip().split()
dataMat.append([1, 0, ]) |
print('\n')
print(f'The __name__ of main_test.py is: {__name__}')
print('\n')
def print_function():
print('\n')
print(f'FROM FUNCTION: The __name__ of main_test.py is: {__name__}')
print('\n')
def some_function():
print('I AM SOME FUNCTION')
if __name__ == '__main__':
print_function() |
n = input()
def mul(n):
if len(n)==1:
return n[0]
return mul(n[1:])*n[0]
def fac(n):
if n==1:
return 1
return fac(n-1)*n
def ap(h,n):
if len(n)==0:
print(h)
for k in sorted(set(n)):
t = list(n)
t.remove(k)
ap(h+k,t)
print(fac(len(n))//mul([fac(n... |
"""
******************************************
init file - to tell python that this folder
is a package.
Left blank for now.
******************************************
""" |
points = []
distances = []
number_of_cases = int(input())
for x in range(number_of_cases):
number_of_points = int(input())
for y in range(number_of_points):
point = list(input().split())
points.append(point)
distances.append((int(point[1]) ** 2 + int(point[2]) ** 2) ** (1/2))
distanc... |
pairs = {
"(": ")",
"[": "]",
"{": "}",
"<": ">",
}
scores = {
")": 3,
"]": 57,
"}": 1197,
">": 25137,
}
with open('./input', encoding='utf8') as file:
lines = [line.strip() for line in file.readlines()]
score = 0
for line in lines:
next_char = []
for char in line:
... |
"""
.. image:: PyPI_logo.svg
:target: https://pypi.org/project/loanpy/
.. image:: zenodo-gradient-200.png
:target: https://zenodo.org/record/4127115#.YHCQwej7SLQ
loanpy is a toolkit for historical linguists. \
It extracts sound changes from an etymological \
dictionary. It reconstructs hypothetical roots of \
mo... |
n = 0
i = 0
while True:
try:
e = input()
n += int(input())
i += 1
except EOFError:
print('{:.1f}'.format(float(n / i)))
break
|
routes = {
'/':
{
"controller": "home.index",
"accepted_method": "GET,POST"
},
'/user':
{
"controller": "user.index",
"accepted_method": "GET"
},
'/user/create':
{
"controller": "user.create",
"ac... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.