text
stringlengths
38
1.54M
# YOUR CODE HERE length = len(message) index = 0 encoded = '' while index < length: letter = ord(message[index]) encLetter = letter + key newLetter = chr(encLetter) encoded = encoded + newLetter index = index + 1
# Generated by Django 2.0.4 on 2018-04-28 19:33 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('page', '0012_merge_20180427_1450'), ] operations = [ migrations.AddField( model_name='club', name='photo', ...
import math # raw_input() reads a string with a line of input, stripping the '\n' (newline) at the end. # This is all you need for most Google Code Jam problems. total = int(raw_input()) # read a line with a single integer for numcases in xrange(1, total + 1): S = list(raw_input()) alldict = {} for x in S:...
# https://leetcode.com/problems/verifying-an-alien-dictionary/ # 2020/10 # 32 ms class Solution: def compare(self, w1, w2, order): for i in range(0, min(len(w1), len(w2))): diff = order.find(w1[i]) - order.find(w2[i]) if diff != 0: return diff return len(w1) ...
#! /usr/bin/env python3 ##@namespace run_hafs # @brief A wrapper around the Rocoto workflow system that knows how to run HAFS in Rocoto # # @anchor run_hafs_main # This is a Python program, run_hafs.py, that users run to launch and maintain an # HAFS workflow # # @code{.sh} # run_hafs.py [options] [ensids and cycles] ...
from keras.models import model_from_json import pandas as pd # load json and create model json_file = open('cnn_model.json', 'r') loaded_model_json = json_file.read() json_file.close() loaded_model = model_from_json(loaded_model_json) # load weights into new model loaded_model.load_weights("cnn_model.h5") print("Loade...
#!/usr/bin/python # coding: UTF-8 # # Author: Dawid Laszuk # Contact: laszukdawid@gmail.com # # Edited: 11/05/2017 # # Feel free to contact for any information. from __future__ import division, print_function import logging import numpy as np import os from scipy.interpolate import interp1d fro...
#!/usr/bin/env python # split_fa.py """ Split a directory full of fasta files into files with equal numbers of sequences per file """ import argparse import os from Bio import SeqIO import glob def split_fasta(infile, outdir, files_wanted, total_sequences, file_counter): """ Split fasta file into x number o...
# Generated by Django 2.2.5 on 2019-09-09 09:22 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='Finding', fields=[ ...
import time import pytest from test.helper import ( execute_add, wait_for_process, wait_for_processes, command_factory, ) @pytest.mark.parametrize('signal', ['sigint', 'SIGINT', 'int', 'INT', '2', 'sigterm', 'SIGTERM', 'term', 'TERM', '15', ...
# ๆœฌ็จ‹ๅผ็”จๆ–ผ็ˆฌๆ–ผ็ฌฌไธ€ๆฌกๆœๅฐ‹ๆ™‚๏ผŒไธๆ…ŽๆŠ“้Œฏ็š„้ค้คจ from selenium import webdriver from selenium.webdriver.common.keys import Keys import time import urllib.request from bs4 import BeautifulSoup import urllib.parse from selenium.webdriver.chrome.options import Options list_shop = [] dict_data = dict() ffile = input() ffile = open(ffile...
import smtplib def sendemail(toaddr,fromaddr,fromname,subject,msg): message = """\nFrom: {} {} \nTo: {} \nSubject: {} \n{} """ messagetosend = message.format( fromaddr, fromname, toaddr, ...
# 3.1.1 list # 1. datalist = [1452, 11.23, 1+ 2j, True, 'w3source', (0, -1), [5, 12], {"class": 'v', "section": 'a'}] for i in datalist: print(i, ":", type(i)) # 3.1.2 Numberlist # 2a lst = [1, -1, 2, 0, 5, 8, -13, 21, -34, 55, 87, 0] def haib(list): for i in list: if i < ...
from django.db import models import os class ComplexityPost(models.Model): post = models.CharField(max_length=25) guess = models.CharField(max_length=25) date = models.DateTimeField(auto_now_add=True) class MastersPost(models.Model): post_a = models.CharField(max_length=5) post_b = models.CharFi...
class QuickSort: def quick_sort(self, arr): """ :param arr:list{int] :return: list[int] """ if not arr or len(arr) <= 1: return arr def qs(arr, left, right): if left >= right: return i, j = left, right k...
def prime_num(): try: n=0 l=int(input()) r=int(input()) for num in range(l,r+ 1): if num > 1: for i in range(2,num): if (num % i) == 0: break else: n=n+1 print(n) ...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Adventure object """ from object import AdventureGameObject class AdventureGameObjectAltar(AdventureGameObject): "Adventure Game Object" def getName(self): "Get the name of the object" return "Altar" def check(self): "Print...
import FWCore.ParameterSet.Config as cms def customise_trackMon_IterativeTracking_2012(process): ## DEBUGGING # if hasattr(process,"trackMonIterativeTracking2012"): # print "trackMonIterativeTracking2012 DEFINED !!!" # else : # print "trackMonIterativeTracking2012 NOT DEFINED !!!" # print "Iter...
''' An example of training a reinforcement learning agent on the PettingZoo environments that wrap RLCard ''' import os import argparse import torch from pettingzoo.classic import ( leduc_holdem_v4, texas_holdem_v4, texas_holdem_no_limit_v6, gin_rummy_v4, ) from rlcard.agents.pettingzoo_agents import...
# for row in range(0,13): # if row == 0: # th = "x " # for x in range(1,13): # th+=str(x) +" " # print th # continue # string = "" + str(row) + " " # for colum in range(1,13): # string += str(row*colum) + " " # print string
#!/usr/bin/env python3 import os import sys import warnings import argparse import numpy as np import shutil import json import grid2op from grid2op.Runner import Runner from grid2op.Chronics import ChangeNothing from grid2op.Agent import BaseAgent from grid2op.Reward import BaseReward, RedispReward, L2RPNSandBoxSco...
#!/usr/bin/python3 # import random import string def getRndStr(length): letters = string.ascii_lowercase result = ''.join(random.choice(letters) for i in range(length)) return result print(getRndStr(5)) print(getRndStr(5))
# The analysis file that is created by the get_probs_at_frame file stores information for the files. This reads # that information and allows for creating more concise meaningful stats. import ast import numpy as np with open("analysis-dec-16-ss90-96-98.txt", "r") as f: frame_start_attempts = [] frame_attempts_l...
# Copyright 2020 The TensorFlow Authors. 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 applica...
#! /usr/bin/python3 from sys import argv w = int( argv[1] ) if len( argv ) == 2 else 16 h = ( ' +', '--+' ) v = ( ' ', ' |', 'OO ', 'OO|' ) print( '+' + '--+' * w ) while True: try: line=input() except EOFError: break print( '|', *[ v[int( c ) >> 1 & 3] for c in line ], sep='' ) p...
import os import re from django.conf import settings def validation_error(parameter, value=None, field=None): msg = 'Invalid "%s" value' % (parameter,) if value is not None: msg += '("%s")' % (value,) return {'error': msg, 'error_code': 406, 'field': parameter} def validate_regexp(key, value): ...
# 455. Assign Cookies # https://leetcode.com/problems/assign-cookies/description/ class Solution: def findContentChildren(self, g, s): """ :type g: List[int] :type s: List[int] :rtype: int """ g.sort() s.sort() i = 0 for size in s: ...
from django import forms from rbmo.models import AllotmentReleases from django.contrib.auth.models import User class AllotmentReleaseForm(forms.Form): MONTHS = ((1, 'January'), (2, 'February'), (3, 'March'), (4, 'April'), (5, 'May'), (6, 'June'), (7, 'July'), (8, 'August'), (9, 'September'), ...
# Generated by Django 3.1.5 on 2021-01-27 23:11 import core.models from django.db import migrations, models import stdimage.models class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='Projects', fields...
import numpy as np import gym import math import os import pickle import neat from neat.reporting import * import time import torch.multiprocessing as mp from utils import * from config import * class GenomeEvaluator: def __init__(self, config, neat_config, state_normalizer): self.config = config s...
import socket, os, time, threading, sys from queue import Queue # ะฅะฐะบะตั€ intThreads = 2 arrJobs = [1,2] queue = Queue() arrAddresses = [] arrConnections = [] strHost = '192.168.1.150' #ip ั…ะฐะบะตั€ะฐ intPort = 4444 intBuff = 1024 decode_utf = lambda data: data.decode("utf-8") remove_quotes = lambda stri...
# O(v+e) time | o(v) space class Node: def __init__(self, name): self.children = [] self.name = name self.visited = set() def addChild(self, name): self.children.append(Node(name)) return self def breadthFirstSearch(self, array): queue = [self] whi...
#็จ‹ๅบๅผ‚ๅธธ #ๅธธ่ง็š„ๅผ‚ๅธธ """ NameError ๏ผšๅฐ่ฏ•่ฎฟ้—ฎไธ€ไธชๆฒกๆœ‰ๅฃฐๆ˜Ž็š„ๅ˜้‡ๅผ•ๅ‘็š„้”™่ฏฏ IndexError ๏ผš็ดขๅผ•่ถ…ๅ‡บๅบๅˆ—่Œƒๅ›ดๅผ•ๅ‘็š„้”™่ฏฏ IndentationError ๏ผš็ผฉ่ฟ›้”™่ฏฏ ValueError ๏ผšไผ ๅ…ฅ็š„ๅ€ผ้”™่ฏฏ KeyError ๏ผš่ฏทๆฑ‚ไธ€ไธชไธๅญ˜ๅœจ็š„ๅญ—ๅ…ธๅ…ณ้”ฎๅญ—ๅผ•ๅ‘้”™่ฏฏ IOError ๏ผš่พ“ๅ…ฅ่พ“ๅ‡บ้”™่ฏฏ๏ผˆๅฆ‚ๆžœ่ฏปๅ–ๆ–‡ไปถไธๅญ˜ๅœจ๏ผ‰ ImportError ๏ผšๅฝ“import่ฏญๅฅๆ— ๆณ•ๆ‰พๅˆฐๆจกๅ—ๆˆ–fromๆ— ๆณ•ๅœจๆจกๅ—ไธญๆ‰พๅˆฐ็›ธๅบ”็š„ๅ็งฐๆ˜ฏๅผ•ๅ‘็š„้”™่ฏฏ AttributeError ๏ผšๅฐ่ฏ•่ฎฟ้—ฎๆœช็Ÿฅ็š„ๅฏน่ฑกๅฑžๆ€งๅผ•ๅ‘็š„้”™่ฏฏ TypeError ๏ผš็ฑปๅž‹ไธๅˆ้€‚ๅผ•ๅ‘็š„้”™่ฏฏ MemoryError ๏ผšๅ†…ๅญ˜ไธ่ถณ ZeroDivisionError ๏ผš้™คๆ•ฐไธบ0ๅผ•...
# tuples # paranthesis are not required.. but preferred zoo = ('python','elephant','penguin') print 'Number of animals in the zoo : ',len(zoo) new_zoo = 'monkey', 'camel', zoo print 'Number of animals in new zoo : ',len(new_zoo) print 'Animals in zoo: ', zoo print 'Animals in new zoo: ', new_zoo # zoo print new_z...
from celery import Celery from time import sleep app = Celery('tasks',broker='pyamqp://guest@localhost//', backend='amqp') @app.task def reverse(text): sleep(5) return text[::-1]
import pandas as pd import re,sys def format_data (x): if isinstance(x,int): return str(x) if isinstance(x,float): return str(round(x,4)) if isinstance(x,str): return re.sub("_","\\_",x) raise RuntimeException("Unsupported Type to be formatted") def print_table(dfinput,idcolumnIndex, longtable, landscape,se...
import os import numpy as np import pandas as pd import experiments.benchmarks.benchmark as benchmark class ActivityBenchmark(benchmark.Benchmark): def __init__(self): super().__init__('activity', (('--sequence_length', 64, int), ('--max_samples', 40_00...
# coding: utf-8 # In[1]: import matplotlib.pyplot as plt # In[15]: year = [1950, 1951, 1952,] pop = [2.538, 2.57, 2.62] # In[16]: plt.plot(year, pop) plt.xlabel('Year') plt.ylabel('Population') plt.title('World Population Projections') plt.yticks([0, 2, 4, 6, 8, 10], ['0', '2B', '4B', '6B', '8B', '10...
from django.db.models import Q from rest_framework.filters import ( SearchFilter, OrderingFilter, ) from rest_framework.generics import ( ListAPIView, CreateAPIView, RetrieveAPIView, ) from rest_framework.mixins import ( DestroyModelMixin, UpdateModelMixin, ) from rest_framework.permissions ...
N = int(input()) output = '' for i in range(N): output += '*' print(output) for i in range(N-1): output = output[:-1:] print(output~)
from random import choice lot = [1, 2, 3, 4, 5, 6, 7, 8, 9, 15, "a","z","b","y", "c"] winner = [] while len(winner) < 4: numero_w = choice(lot) if numero_w not in winner: print(f"We pulled: {numero_w}") winner.append(numero_w) print(f"The winner is {winner}")
import sys sys.path.append('..') from bhbot.models import Command class AliveCommand(Command): @property def triggers(self): return ['alive'] def __call__(self, context: dict) -> str: return 'Yes, I am alive.' def get_command(): return AliveCommand
# Generated by Django 3.0.5 on 2020-04-03 08:32 from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('fvh_courier', '0025_auto...
# coding: utf-8 """ Cyclos 4.11.5 API The REST API for Cyclos 4.11.5 # noqa: E501 OpenAPI spec version: 4.11.5 Generated by: https://github.com/swagger-api/swagger-codegen.git """ import pprint import re # noqa: F401 import six from swagger_client.configuration import Configuration class...
""" Created on Jan 25, 2018 @author: Siyuan Qi Description of the file. """ from . import grammarutils from .generalizedearley import GeneralizedEarley __all__ = ('grammarutils', 'GeneralizedEarley')
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys, os from TouchStyle import * import MFRC522 import ftrobopy # the output ports GREEN = 0 RED = 2 MOTOR = 4 # This is the default key for authentication KEY = [0xFF,0xFF,0xFF,0xFF,0xFF,0xFF] def dummy_reader(): # Scan for cards (status,Ta...
from helper import * import plot_defaults from matplotlib.ticker import MaxNLocator from pylab import figure import os, re, string parser = argparse.ArgumentParser() parser.add_argument('--dir', '-d', help="Directory where data exist", required = True) args = parser.parse_arg...
"""Return fizzbuzz list until the number from input.""" from __future__ import print_function def fizz_buzz(number): """Return a list containing fizzbuzz list.""" lists = [] for i in range(1, number + 1): if i % 3 == 0 and i % 5 == 0: lists.append("FizzBuzz") elif i % 3 == 0: ...
import paramiko import time ssh = parmiko.SSHClient() ssh.load_system_host_keys() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect('ipaddress', username='username',password='password') chan = ssh.invoke_shell() chan.send('show version\r') while not chan.recv_ready(): time.sleep(5) out = chan.rec...
def frequencySort(self, s: str) -> str: c_cnts = collections.Counter(s).most_common() return ''.join(c*cnt for c, cnt in c_cnts)
from django.db.models import * from django.contrib.auth.models import User priority = [ ('Normal', 'Normal'), ('High', 'High'), ('Urgent', 'Urgent'), ('Immediate', 'Immediate'), ] payment_status = [ ('Waiting For Payment', 'Waiting For Payment'), ('Paid', 'Paid'), ('Payment Ca...
from math import sqrt q=int(input("ENTER NUMBER OF INPUTS")) list=[] for i in range(q): q1=int(input()) list.append(q1) C=50 H=30 for i in list: D=sqrt(((2 * C * i)/H)) print(round(D))
directory = dict() first = 'chris' last = 'gidden' number = 2 directory[last, first] = number print(number) for last, first in directory: print(first, last, directory[last,first])
from station import StationList from zoopla import Zoopla from zoopla.exceptions import ZooplaAPIException import os zoopla = Zoopla(api_key=os.environ['ZOOPLA_KEY'], verbose=True) for station in StationList().stations: name = '{} Station'.format(station.name) latitude, longitude = station.parse_location() ...
# Generated by Django 2.2.7 on 2019-12-01 10:04 from django.db import migrations, models import django.utils.timezone class Migration(migrations.Migration): dependencies = [ ('polls', '0006_auto_20191201_1749'), ] operations = [ migrations.AddField( model_name='question', ...
#!/usr/bin/env python import numpy as np ############################################################### Periodic boundary utility #periodic boundary for relative position vector def wrap( vector, box ): return vector - np.floor( vector / box + 0.5 ) * box
""" Contains all the tools necessary to map GO ontology and Pathway classification from the database to an Adjacency and Laplacian graph. """ import hashlib import json import pickle import random import string import math import datetime from collections import defaultdict from copy import copy from random import shuf...
#!/usr/bin/env python2 import time import thread import json import gst class Player(object): def __init__(self, on_end = None): self.current = None self.progress = 0 self.length = 0 self.playing = False self.on_end = on_end self.playbin = gst.element_factory_make("playbin2", "player") thread.start_ne...
import numpy as np import tensorflow as tf import pandas as pd import os import time Rootdir = os.path.abspath(os.path.dirname(os.getcwd())) Modeldir = Rootdir + r"\Models\LSTM\LSTM.model" Datadir = "E:\PyCharmProjects\MasonicDLv0.1\Database\ๆ— ่ฏไน‹็ฝช_partI.csv" Data_Sheet = "Sheet1" train_step = 8000 # learning_rate = 0...
# Copyright 2020-2023 OpenDR European Project # # 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 agree...
from django.conf.urls import patterns, include, url # Uncomment the next two lines to enable the admin: # from django.contrib import admin # admin.autodiscover() urlpatterns = patterns('', (r'^$', 'info.views.index'), (r'^about/$', 'info.views.about'), (r'^instructions/$', 'info.views.instructions'),...
def list_users(user_filter): list_users_response = cognito_client.list_users(UserPoolId=COGNITO_USER_POOL_ID, Filter=user_filter) users = list_users_response['Users'] while 'PaginationToken' in list_users_response: list_users_response = cognito_client.list_users(UserPoolId=COGNITO_USER_POOL_ID, Fil...
from selenium import webdriver import time from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC ''' def get_web_driver(the_url): browser = webdriv...
# -*- coding:utf-8 -*- import pandas as pd import numpy as np import xgboost as xgb path = '/Users/chenhong/' na_values = ['', 'NULL', 'null', 'NA', 'na', 'NaN', 'nan', '\\N'] ## load data feature_import='xgb_model/feature_importance_with_sort_feature_.txt' train_pre_file='xgb_model/train_pred_with_sort_feature.txt...
#!/usr/bin/env python # | Copyright 2015-2016 Karlsruhe Institute of Technology # | # | 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 ...
import os import pandas as pd from sklearn.model_selection import train_test_split from tensorflow import keras import numpy as np os.chdir("C:/Users/Kyeongjun/Desktop/LG๊ฐ€์ „๋ฐ์ดํ„ฐ") """------------------------------------------------------------------------------------------------------ ### 1. calculating expect...
#!/usr/bin/env python # # System tray notifier for sboui updates. Source code adapted from # salix-update-notifier by George Vlahavas (gapan). import gtk import sys def accept(data=None): sys.exit(0) def dismiss(data=None): sys.exit(1) def quit(data=None): sys.exit(2) def make_menu(event_button, event_...
count = 0 while count < 5: count = count+1 if count is 4: break print("count") # With continue statement count = 0 while count < 5: count = count+1 if count is 4: continue print("count")
"""Add ix_test_start_time_status_lower Revision ID: 9c00de5646cd Revises: d5e936a5835e Create Date: 2017-08-01 14:25:16.846453 """ # revision identifiers, used by Alembic. revision = '9c00de5646cd' down_revision = 'd5e936a5835e' from alembic import op import sqlalchemy as sa def upgrade(): # ### commands auto...
# For the exercise, look up the methods and functions that are available for use # with Python lists. x = [1, 2, 3] y = [8, 9, 10] # For the following, DO NOT USE AN ASSIGNMENT (=). # Change x so that it is [1, 2, 3, 4] # YOUR CODE HERE print(x.append(4)) # Using y, change x so that it is [1, 2, 3, 4, 8, 9, 10] # ...
import argparse parser = argparse.ArgumentParser() parser.add_argument('--fasta', type=str) parser.add_argument('--start', type=int) parser.add_argument('--end', type=int) args = parser.parse_args() # finds Chi-sites coordinates for + and - strands for a given interval with open(args.fasta, 'r', encoding='utf-8') as...
# -*- coding: utf-8 -*- import pandas as pd import pytest from kartothek.core.cube.constants import KTK_CUBE_UUID_SEPERATOR from kartothek.core.cube.cube import Cube from kartothek.io.eager_cube import build_cube, copy_cube __all__ = ( "test_additional_files", "test_delete_by_correct_uuid", "test_fail_blo...
def print19(start,end): for i in range(start, end+1): print(i,end=" ") print("") s=int(input("์‹œ์ž‘:")) e=int(input("๋:")) if s<e: print19(s,e)
#!/usr/bin/env python # -*- coding: utf-8 -*- import json import urllib.request import bs4 import re from sqlConnector import mySql_Connector as sql class webPageSpider: # ๅˆๅง‹ๅŒ–ๅ‡ฝๆ•ฐ def __init__(self): pass # ๅญ—็ฌฆไธฒ่ฟ‡ๆปคๅ‡ฝๆ•ฐ def checkStr(self, String): try: # python...
# ๋‹คํŠธ ๊ฒŒ์ž„์€ ์ด 3๋ฒˆ์˜ ๊ธฐํšŒ๋กœ ๊ตฌ์„ฑ๋œ๋‹ค. # ๊ฐ ๊ธฐํšŒ๋งˆ๋‹ค ์–ป์„ ์ˆ˜ ์žˆ๋Š” ์ ์ˆ˜๋Š” 0์ ์—์„œ 10์ ๊นŒ์ง€์ด๋‹ค. # ์ ์ˆ˜์™€ ํ•จ๊ป˜ Single(S), Double(D), Triple(T) ์˜์—ญ์ด ์กด์žฌํ•˜๊ณ  ๊ฐ ์˜์—ญ ๋‹น์ฒจ ์‹œ ์ ์ˆ˜์—์„œ 1์ œ๊ณฑ, 2์ œ๊ณฑ, 3์ œ๊ณฑ (์ ์ˆ˜1 , ์ ์ˆ˜2 , ์ ์ˆ˜3 )์œผ๋กœ ๊ณ„์‚ฐ๋œ๋‹ค. # ์˜ต์…˜์œผ๋กœ ์Šคํƒ€์ƒ(*) , ์•„์ฐจ์ƒ(#)์ด ์กด์žฌํ•˜๋ฉฐ ์Šคํƒ€์ƒ(*) ๋‹น์ฒจ ์‹œ ํ•ด๋‹น ์ ์ˆ˜์™€ ๋ฐ”๋กœ ์ „์— ์–ป์€ ์ ์ˆ˜๋ฅผ ๊ฐ 2๋ฐฐ๋กœ ๋งŒ๋“ ๋‹ค. # ์•„์ฐจ์ƒ(#) ๋‹น์ฒจ ์‹œ ํ•ด๋‹น ์ ์ˆ˜๋Š” ๋งˆ์ด๋„ˆ์Šค๋œ๋‹ค. # ์Šคํƒ€์ƒ(*)์€ ์ฒซ ๋ฒˆ์งธ ๊ธฐํšŒ์—์„œ๋„ ๋‚˜์˜ฌ ์ˆ˜ ์žˆ๋‹ค. ์ด ๊ฒฝ์šฐ ์ฒซ ๋ฒˆ์งธ ์Šคํƒ€์ƒ(*)์˜ ์ ์ˆ˜๋งŒ ...
import re pat = r'^\d+$' x = input() if bool(re.match(pat, n)): x = int(x) flag = True ar = list(input().split()) for i in ar: if not bool(re.match(pat, i)): print("Invalid") flag = False break if flag: ans = [] for i in range(n): ...
from django.contrib import admin from accounts.models import Contact_Information, Days class ContactInline(admin.TabularInline): model = Days extra = 3 class ContactAdmin(admin.ModelAdmin): list_display = ('phone', 'office', 'email', 'github', 'bitbucket') inlines = (ContactInline,) admin.site.reg...
import functools import utils.minidom_fix as dom class XML_builder: def __init__(self, schema): self.schema = schema def ram_to_xml(self): if self.schema is None: raise ValueError("Schema is empty") xml = dom.Document() element = xml.createElement("dbd_schema") ...
n1 = int(input()) n2 = int(input()) n3 = int(input()) if (n1+n2 == n3) or (n1+n3 == n2) or (n2+n3 == n1): print ('soma') else: if (n1*n2 == n3) or (n1*n3 == n2) or (n2*n3 == n1): print ('multi') else: if ((n1+n2+n3)%2 == 0): print ('par') else: p...
import subprocess import threading import time class ShellRunnerTimeout(Exception): def __init__(self, cmd): self.cmd = ' '.join(cmd) class ShellRunnerFailed(Exception): def __init__(self, cmd, retval): self.cmd = ' '.join(cmd) self.retval = retval class ShellRunner(object): def _...
from django import template from django.core.urlresolvers import reverse from ..models import Appointment register = template.Library() class ContinuationAppointmentAnchor(template.Node): """return a reverse url for a continjuation appointment if the appointment does not already exist""" def __init__(self, ...
import json data = None ROWLATITUDE = 7 # Column number that latitude value is located in ROWLARVAE = 16 debug_bool = True # # Algorithm: # TODO: Put in algorithm steps # TODO: Create adjacency matrix for weightd edges on the graph # def debug(s): if(debug_bool): print(s) class Animal: def __...
#I got this code working shortly after starting the project #So it was developed for visible light photos with no filter #Then I started fooling around with double thresholding for the mask #Bandpass filter will severely affect thresholding #Background subtraction might have to be substituted instead from plantcv impo...
import os import sys import json sys.path.append(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'langeval')) from eval import LanguageEval class LangEvaluator(): def __init__(self, dataset): self.uid2ref = {} self.langeval = LanguageEval() for datum in dataset.da...
import numpy as np import os def estimateProjectionMatrix(x, y, P, num) : Q = np.array([]) for i in range(num) : Pk = P[:, i] zeroMat = np.zeros(4) xk = x[i] yk = y[i] Qk = np.array([ np.hstack((Pk.T, zeroMat, (-xk) * (Pk.T))), ...
from django.utils.deprecation import MiddlewareMixin class MyMiddleWare(MiddlewareMixin): def process_request(self,request): print(request.path)
import os import sys from xcoin_api_client import * from binance.client import Client import pprint import json import urllib.request from urllib.request import Request, urlopen import threading import datetime import time from PyQt5.QtGui import * from PyQt5.QtCore import * from PyQt5.QtWidgets import * from PyQt5 ...
class Graph: def __init__(self): self.data = [] self.x_labels = [] self.y_min = 0 self.y_max = 20 self.y_steps = 5 self.title_text = '' self.title_size = 30 self.pie = 0 self.x_tick_size = -1 # GRID styles: self.x_axis_colour =...
import datetime import pytz from dateutil import relativedelta UTC_TZ = pytz.timezone('UTC') EASTERN_TZ = pytz.timezone('US/Eastern') # Timezones are way harder than one would imagine. # from betterself.utils import date_utils def get_datetime_in_eastern_timezone(year, month, day, hour, minute, second=0): """ ...
# coding: utf-8 """ Main functions to preprocess Sentinel-2 Datasets for Change Detection purpose @Author: Tony Di Pilato Created on Wed Feb 19, 2020 """ import os import numpy as np from osgeo import osr from osgeo import gdal import random def build_raster(folder, channels): filenames = {3:['B02','B03','B04...
#-*- coding: utf-8 -*- #!/usr/bin/env python ''' Created on Jan 05, 2011 @author: Wander Jardim ''' import os import sys def prepara_path(): """Carrega o diretรณrio fonte no sys.path. Isso sรณ serรก necessรกrio quando estiver executando uma distribuiรงรฃo fonte. Distribuiรงรตes binรกria jรก garantem que o caminh...
class Rectangle: def __init__(self, x, y, width, height): self.x = x self.y = y self.width = width self.height = height def get_figure(self): return f'Rectangle({self.x}, {self.y}, {self.width}, {self.height}).' class Circle: def __init__(self, x, y, r): se...
class A: def __init__(self): print("A") class B(A): # def __init__(self): # print("B") pass class C(A): # def __init__(self): # print("C") pass class D(B,C): pass D()
#!/usr/bin/env python3 from aws_cdk import core from test_cdk.test_cdk_stack import TestCdkStack app = core.App() TestCdkStack(app, "test-cdk") app.synth()
#%% # -*- coding: utf-8 -*- # Section 1 COM = r'COM27'#r'COM21' motor = 'theta' def degreesToSteps(degrees): return int(9140000*(degrees/360)) from motor_driver_interface import MotorDriver MD = MotorDriver(COM) #MD.alignMotor(motor) #%% # Section 2 MD.turnMotor(motor, degreesToSteps(1), 'cw') #%% # Sectio...
import random import numpy as np from pandas import DataFrame from sklearn.preprocessing import normalize from math import acos, pi, isnan from scipy.stats import entropy np.random.seed(13) NUM_EMOTIONS = 6 NDIMS = 300 def read_emo_lemma(aline): """ Splits a line into lemma l, emotion e, and l(e). l(e) ...
calendar_events_mapping = { 'action': '/char/UpcomingCalendarEvents.xml.aspx', 'fields': ['eventID', 'ownerName', 'eventDate', 'eventTitle', 'duration', 'eventText'] } contracts_mapping = { 'action': '/char/Contracts.xml.aspx', 'fields': ['contractID', 'startStationID', 'status', 'price'...
from django.db import models from django.contrib.auth.models import User from PIL import Image DEPARTMENTS = ( ("CE", "Chemical Engineering"), ("BioTech", "Biotechnology"), ("Civil", "Civil Engineering"), ("CSE", "Computer Science and Engineering"), ("ECE", "Electronics and Communication Engineering...
# -*- coding: utf-8 -*- # USAGE # Start the server: # python app.py # Submit a request via cURL: # curl --data input_word="good" http://localhost:5000/predict # curl --data input_word="am" http://localhost:5000/predict # curl --data input_word="bad" http://localhost:5000/predict # import the necessary package...
#! /usr/bin/env python # -*- coding: utf-8 -*- """aubio command line tool This file was written by Paul Brossier <piem@aubio.org> and is released under the GNU/GPL v3. Note: this script is mostly about parsing command line arguments. For more readable code examples, check out the `python/demos` folder.""" import sy...