blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 133 | path stringlengths 2 333 | src_encoding stringclasses 30
values | length_bytes int64 18 5.47M | score float64 2.52 5.81 | int_score int64 3 5 | detected_licenses listlengths 0 67 | license_type stringclasses 2
values | text stringlengths 12 5.47M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
de0feafe5b0a43558219baa63f21d4c1cb1ad2c9 | Python | Julinus-LI/pythonNote | /python进阶/02-python高级-2/02-装饰器/04-多个装饰器.py | UTF-8 | 486 | 3.546875 | 4 | [] | no_license | #!/usr/bin/env python
# coding=utf-8
#定义函数: 完成包裹数据
def makeBold(fn):
def wrapped():
print("-------1--------")
return "<b>" + fn() + "</b>"
return wrapped
#定义函数: 完成包裹数据
def makeItalic(fn):
def wrapped():
print("-------2--------")
return "<i>" + fn() + "</i>"
return wrappe... | true |
0b4e3fbf79948a464f114446860a160170420a7d | Python | sofcha23/novel-blood-vessel-segmentation-for-retinal-fundus-image | /accuracy.py | UTF-8 | 5,424 | 2.53125 | 3 | [] | no_license | import cv2
import os
import numpy as np
from matplotlib import pyplot as plt
def deviation_from_mean(image):
clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))
clahe_output = clahe.apply(image)
print(clahe_output)
result = clahe_output.copy()
result = result.astype('int')
i = 0
j = 0
while... | true |
7664308ea89219b327df2cfd90fc9c59a3e3f725 | Python | redoctopus/Sentiment-Analysis-Book-Reviews-2014 | /ReadFromFileTest.py | UTF-8 | 3,212 | 3.609375 | 4 | [] | no_license | ## Jocelyn Huang
## Sentiment Analysis Project
## 02.06.2014
## Read from text file
import string
import sys
def removePunctuation(s):
s = s.replace("-", " ")
s = s.replace(".", " ")
s = s.replace("/", " ")
removal = {ord(char): None for char in string.punctuation}
s = s.translate(removal).lower()
re... | true |
6285261686fb2d4f24a9814c8a25a52f37b163ac | Python | Juancho1007/practicas | /division paso a paso.py | UTF-8 | 1,217 | 3.828125 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Jan 20 10:17:47 2021
@author: Juan David
"""
"""
Spyder Editor
This is a temporary script file.
"""
a=(input("Introduce el dividendo: ") )
b=(input("Introduce el divisor: ") )
A=int(a)
B=int(b)
if A<B : #si el dividendo es menor que el divisor
c=A//B... | true |
417f6eaa490dcdc0cb443a66d60b548a6449d08f | Python | xuzhuo77/WorkSpace-FrameWork | /zhak_projects/agame/map/connected_domain.py | UTF-8 | 2,436 | 2.796875 | 3 | [] | no_license | class ConnectedDomainMap():
def __init__(self, width, height):
self.width = width
self.height = height
self.map = [[0 for x in range(self.width)] for y in range(self.height)]
def showMap(self):
for row in self.map:
s = ''
for entry in row:
... | true |
f9c243c6875e9c57b1e63cdf9c354a4720edb515 | Python | YEONGGEON/practice_python | /boj/15657.py | UTF-8 | 424 | 2.71875 | 3 | [] | no_license | import sys
N, M = map(int, sys.stdin.readline().split())
llist = list(map(int, sys.stdin.readline().split()))
llist.sort()
select = []
def DFS(a, count):
if count == M:
for i in select:
print(i, end=' ')
print('')
return
for i in range(a,N):
select.append(llist[i])... | true |
a62e7452c500bdc7f1edb903e46042b32a08cd87 | Python | AryakRoy/stock-sensei | /prediction.py | UTF-8 | 5,034 | 2.59375 | 3 | [] | no_license | import math
import pandas as pd
import numpy as np
from sklearn.preprocessing import MinMaxScaler
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, LSTM
from tensorflow.keras.models import model_from_json
import os
class Predictor:
def __init__(self,traverser):
self.... | true |
db0d0e8cd65879f9fa02269b9bd32e1e8bd7e01c | Python | EdikCarlos/Exercicios_Python_intermediario | /ex_Lista_ordenada_sem_repetições.py | UTF-8 | 516 | 3.890625 | 4 | [] | no_license | lista = []
for c in range(0,5):
v = int(input('Digite um número: '))
if c == 0:
lista.append(v)
print('Número adicionado à posição 1')
elif v > lista[-1]:
lista.append(v)
print('Número adicionado ao final da lista.')
else:
pos = 0
while pos < len(lista):
... | true |
95618dd6d0b151d8ad70560b7767d9b1b11e4f8b | Python | ailiasi/Drafter | /data_processing.py | UTF-8 | 4,032 | 2.703125 | 3 | [] | no_license | import numpy as np
import pandas as pd
# TODO: Use the Enum class to encode heroes, maps and modes
HEROES = {'Abathur': 0, 'Alarak': 1, 'Alexstrasza': 2, 'Ana': 3, "Anub'arak": 4,
'Artanis': 5, 'Arthas': 6, 'Auriel': 7, 'Azmodan': 8, 'Blaze': 9,
'Brightwing': 10, 'Cassia': 11, 'Chen': 12, 'Cho': 1... | true |
844b0b5e7c31dec1c3d480fc921f4b83c744614b | Python | vynhart/skripsi | /GUI/myfirstgui.py | UTF-8 | 235 | 2.859375 | 3 | [] | no_license | from tkinter import *
top = Tk()
def helloCallBack():
tkMessageBox.showinfo( "Hello Python", "Hello World")
# Code to add widgets will go here...
B = Button(top, text ="Hello", command=helloCallBack)
B.pack()
top.mainloop()
| true |
86133d1a07999fac284e30deb7b8c10f9cd63405 | Python | jfulghum/practice_thy_algos | /binary_trees/prune_binary_trees.py | UTF-8 | 1,884 | 3.890625 | 4 | [] | no_license |
class TreeNode:
def __init__(self, value = 0, left = None, right = None):
self.value = value
self.left = left
self.right = right
def arrayifyTree(root):
if root is None:
return []
queue = []
array = []
queue.append(root)
while (len(queue) != 0):
no... | true |
eabb873c51c052cf495317867fe6faa0543419dd | Python | leohentschker/Project-Euler | /Python/euler_p67/euler_p67.py | UTF-8 | 1,623 | 3.609375 | 4 | [] | no_license | class Triangle():
def __init__(self, value):
self.value = value
self.left_child = None
self.right_child = None
self.path_sum = -1
def set_children(self, left_child, right_child):
self.left_child = left_child
self.right_child = right_child
def max_path_sum(self):
# if we have already calculated the ma... | true |
ad78ca9d2dd3ddb1d720ca974e3c551ce63617b9 | Python | gistable/gistable | /dockerized-gists/805139/snippet.py | UTF-8 | 3,963 | 3.046875 | 3 | [
"MIT"
] | permissive | # -*- coding: utf8 -*-
import os, simplejson, re
class OrganizerException(Exception):
def __init__(self, message):
self.message = message
def __str__(self):
return self.message
class Organizer(object):
def __init__(self, configFile):
self.__preserveConfig(configFile)
... | true |
a390378a8f3311d282bf9226a265e4cf06d7a268 | Python | prem1806/python-practice-files | /selection_sort/selection_sort.py | UTF-8 | 271 | 3.515625 | 4 | [] | no_license | def ssort(lst):
for i in range(len(lst)-1,0,-1):
p=0
for l in range(1,i+1):
if lst[l]>lst[p]:
p = l
temp = lst[i]
lst[i] = lst[p]
lst[p] = temp
lst = [4,36,11,19,32,54,23,5,2]
ssort(lst)
print(lst)
| true |
f85ad27cdb10fc48c38c07f132aa5faa1bbd08b8 | Python | divyams1/LeetCode | /graphs/maze_end.py | UTF-8 | 316 | 2.96875 | 3 | [] | no_license | class Solution:
def findPath(self, start, end):
startCol = start[0]
startRow = start[1]
path = []
coordStart = Coordinate()
class Coordinate:
def __init__(self, row, col, color):
self.row = row
self.col = col
self.color = color
| true |
0a254fe26a23f7fa1d8d9c1acc77b3f957bffd65 | Python | tp-yan/PythonScript | /python编程从入门到实践/json_test.py | UTF-8 | 2,074 | 3.859375 | 4 | [] | no_license | #python借助json模块来存储数据到本地或从本地读取到内存
import json
numbers = [1,2,3,4,5,6,7]
#.json:按照json格式存储
file_name = 'numbers.json'
with open(file_name,'w') as f_obj:
#dump:倾倒,丢下,倾销,卸下,摆脱
json.dump(numbers,f_obj)
#从本地读取出来
with open(file_name) as f_obj:
_numbers = json.load(f_obj)
print(_numbers)
'''
#记录用户姓名到本地
file_username = '... | true |
12b10122a8107c233879466124ba251d43d1ca9d | Python | uwsampl/relay-bench | /experiments/char_rnn/language_data.py | UTF-8 | 1,746 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | import glob
import os
import requests
import string
import unicodedata
import zipfile
__DATA__ = None
DATA_URL = 'https://download.pytorch.org/tutorial/data.zip'
DATA_PATH = 'data'
ALL_LETTERS = string.ascii_letters + " .,;'"
N_LETTERS = len(ALL_LETTERS) + 1
N_CATEGORIES = None
ALL_CATEGORIES = []
MAX_LENGTH = 20
# ... | true |
b3a4d35804cd4fd7e252e10e79cb08c0c02af3b3 | Python | Chuban/xraylarch | /plugins/io/columnfile.py | UTF-8 | 11,776 | 2.953125 | 3 | [
"BSD-2-Clause"
] | permissive | #!/usr/bin/env python
"""
Larch column file reader: read_ascii
"""
import os
import time
from dateutil.parser import parse as dateparse
import numpy as np
from larch import ValidateLarchPlugin, Group
from larch.utils import fixName
from larch.symboltable import isgroup
MODNAME = '_io'
TINY = 1.e-7
MAX_FILESIZE = 1... | true |
ee56a1330837786e88585847e615f0d84184beba | Python | sshish/NF | /NF.py | UTF-8 | 12,272 | 3.3125 | 3 | [] | no_license | #######################################
#Basic interface of normalizing flows.#
#######################################
import torch
class Basic(torch.nn.Module):
"""Abstract module for normalizing flows.
Methods:
forward(x, c): Performs reversible transformation conditioned on
context c. Input x and o... | true |
f404477d60d834b5006cbb295d3b2328bf8c20d8 | Python | rlllzk/pydasar | /askses file txt.py | UTF-8 | 303 | 3.125 | 3 | [] | no_license | def main():
#mengakses file
f=open("sample.txt") #mengembalikan objek file
line = f.readline() #membaca baris pertama
while line:
print(line, end='')
line=f.readline() #membaca baris berikutnya
#menutup gile
f.close
if __name__=="__main__":
main() | true |
b12631a0b2f7f101caf6a2551785c1ee7d02da01 | Python | Zoujoko/Maths_Epitech_Tek3 | /308reedpipes/algo.py | UTF-8 | 1,661 | 3.140625 | 3 | [] | no_license | ##
## EPITECH PROJECT, 2021
## B-MAT-500-REN-5-1-308reedpipes-eliott.palueau
## File description:
## algo
##
def systemResolution(ordinate, abscissa):
A = 6 * (ordinate[2] - 2 * ordinate[1] + ordinate[0]) / 50
B = 6 * (ordinate[3] - 2 * ordinate[2] + ordinate[1]) / 50
C = 6 * (ordinate[4] - 2 * ordinate[3]... | true |
67342ef32213f52da0785888649ef533e5be1007 | Python | Carreau/python-opentree | /examples/synth_subtree.py | UTF-8 | 1,919 | 2.859375 | 3 | [
"BSD-2-Clause"
] | permissive | #!/usr/bin/env python3
import sys
from opentree import OTCommandLineTool, process_ott_or_node_id_arg
cli = OTCommandLineTool(usage='Gets a subtree of the synthetic tree rooted at the node requested',
common_args=("ott-id", "node-id"))
cli.parser.add_argument('--format', default='newick',
... | true |
3269e2d7c0c4fe5f1a756ee43795871fb5cdba66 | Python | asappresearch/emergent-comms-negotiation | /sampling.py | UTF-8 | 3,162 | 3.15625 | 3 | [
"MIT"
] | permissive | import torch
import numpy as np
def sample_items(batch_size, num_values=6, seq_len=3, random_state=np.random):
"""
num_values 6 will give possible values: 0,1,2,3,4,5
"""
pool = torch.from_numpy(random_state.choice(num_values, (batch_size, seq_len), replace=True))
return pool
def sample_utility(... | true |
0097f3b722d1cc2af76ce1eca576cd64634f1431 | Python | CSP-ArkCityHS-gregbuckbee/iterative-prisoners-dilemma-2019 | /team3.py | UTF-8 | 460 | 3.34375 | 3 | [] | no_license | team_name = 'Team 3333'
strategy_name = 'Betray 2'
strategy_description = 'If my history is c, and their history is c, I will betray.'
team_name = 'The name the team gives to itself' # Only 10 chars displayed.
strategy_name = 'The name the team gives to this strategy'
strategy_description = 'How does this strategy dec... | true |
f2cca278098e26c6a22c9e485cd4633972e84ff1 | Python | snirappi/facebookRanker | /analysis.py | UTF-8 | 905 | 3.125 | 3 | [] | no_license | import pandas as pd
import glob
def negative(x):
if x is not None and x != 0:
return x * -1
else:
return None
def change(frame):
frame = frame.diff(axis=1)
for column in frame.columns:
frame[column] = frame[column].apply(negative)
frame = frame.sort_values(frame.columns[len(frame.columns) - 1], ascending ... | true |
95a0a776a466695aa6992c65323dde4838ad146e | Python | nischalshrestha/automatic_wat_discovery | /Notebooks/py/ricemath25/first-titanic-solution-with-hyper-tuned-rfc/first-titanic-solution-with-hyper-tuned-rfc.py | UTF-8 | 4,828 | 2.859375 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# # Titanic Solution
# In[ ]:
import numpy as np
import os
import pandas as pd
import sklearn.ensemble
import sklearn.model_selection
# ## Load Data
# In[ ]:
train_df = pd.read_csv('../input/train.csv')
train_df.info()
train_df.head()
# In[ ]:
test_df = pd.read_csv('..... | true |
fc8aa8de0e1b8a449f9f4665a52ea386ab2962cf | Python | WatanabeYuto/multi_turtle | /multi_navigation/src/set_initpos.py | UTF-8 | 1,537 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import rospy
import tf
import math
from geometry_msgs.msg import PoseWithCovarianceStamped
if __name__ == '__main__':
try:
rospy.init_node('set_initpos', anonymous=True)
robot_list = rospy.get_param('robot_list')
print("follow are the names of robot which i... | true |
ced6f5f690f0bd0440679940f99a23dcd6412577 | Python | krishnodey/Python-Tutoral | /calculate_sum_avg_of_list_elements.py | UTF-8 | 264 | 3.8125 | 4 | [] | no_license | n = int(input("enter the list size: "))
l = []
for i in range(0,n):
e = int(input("enter the element: "))
l.append(e)
sum = 0
for i in range(0,n):
sum += l[i]
print("Sum = ",sum,"\n","Avg = ",sum/n)
#thanks for watching keep coding | true |
625dd68d26a0bf70698093ab8f23144a342d304f | Python | YashSolanki2007/Notes-App | /main.py | UTF-8 | 813 | 2.8125 | 3 | [] | no_license | from flask import Flask, render_template, request, url_for
# Creating the app
app = Flask(__name__)
# Global Variables
notes_list = []
temp_notes_list = []
notes_list_title = []
temp_notes_list_title = []
final_list = []
# Creating the main page
@app.route("/", methods=['GET', 'POST'])
def main():
global notes... | true |
9a996f54f928c1536bc33422fb57e8fd811da7f7 | Python | halucinor/QC_Tool_Ex | /correlation.py | UTF-8 | 351 | 2.59375 | 3 | [] | no_license | import init
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.ticker import PercentFormatter
import matplotlib.font_manager as fm
init.initilize()
data = pd.read_csv('correlation.csv')
df = pd.DataFrame(data)
corr = df.corr(method = 'pearson').sort_values('채수량', ascending=False)
... | true |
a81113f02125c0e2e38e82806f66f034b7616130 | Python | nod/site33 | /views/about.py | UTF-8 | 1,311 | 2.9375 | 3 | [] | no_license |
from markdown import Markdown
from .viewlib import BaseHandler
from . import route
about_text = """
### 33ad actually comes from a year
Thirty Three A.D. The common belief is that
Christ was 33 years old when he was crucified, and since we count years from
his (aproximated) birth, then 33AD would have been the year... | true |
9abdb9fcaf617b997a76f160a0eda89b85c757e5 | Python | notWhaleB/LamportMutex | /RPC/serialize.py | UTF-8 | 241 | 2.890625 | 3 | [] | no_license | DELIM = "\t"
END = "\n"
def serialize(cmd, *args):
return DELIM.join(map(str, [cmd] + list(args))) + END
def unserialize(data):
components = data.split(DELIM)
cmd = components[0]
args = components[1:]
return cmd, args | true |
a639904256778ce038d21d1003c7438be7f53aec | Python | jsvine/pdfplumber | /pdfplumber/convert.py | UTF-8 | 3,501 | 2.640625 | 3 | [
"MIT"
] | permissive | import base64
from typing import Any, Callable, Dict, List, Optional, Tuple
from pdfminer.psparser import PSLiteral
from .utils import decode_text
ENCODINGS_TO_TRY = [
"utf-8",
"latin-1",
"utf-16",
"utf-16le",
]
CSV_COLS_REQUIRED = [
"object_type",
]
CSV_COLS_TO_PREPEND = [
"page_number",
... | true |
449afdcac28fd477cc00585efb81d75f20264e47 | Python | ruckserve/JuniorDevs | /algorithms/binary_search/test.py | UTF-8 | 590 | 3.640625 | 4 | [] | no_license | #!/usr/bin/env python
from time import time, sleep
def factorial(n) :
if n <= 1 :
return long(1)
return n * factorial(n-1)
def iter_factorial(n) :
_factorial = long(1)
while n >= 1 :
_factorial *= n
n -= 1
return _factorial
def timer(method, args, iterations=100000) :
... | true |
ddd49a2374d26de4cb83f43161ea3006d4eb3121 | Python | pkerpedjiev/train-travel-times-europe | /scripts/parse_sections.py | UTF-8 | 6,839 | 2.828125 | 3 | [] | no_license | #!/usr/bin/python
import collections as col
import dateutil.parser as dp
import gzip
import itertools as it
import json
import os
import os.path as op
import sys
from optparse import OptionParser
from math import radians, cos, sin, asin, sqrt
cities_to_trains = {}
stretches_to_times = {}
def haversine(lon1, lat1, lo... | true |
61c8417d84a3075e2ff6151a01c9960dd36080b8 | Python | Seliaste/Wow-guild-online-checker | /checkbot.py | UTF-8 | 2,765 | 2.703125 | 3 | [] | no_license | import discord
import requests
import json
from requests.auth import HTTPBasicAuth
from requests.exceptions import HTTPError
from time import time
import threading
threadreturnlist = []
file = open("info.json", "r")
info = json.load(file)
realm = info[0]
guild = info[1]
discordToken = info[2]
bnetToken=[info[3],info[... | true |
75004887a63846ec8be086a074a9440f9c0dda1e | Python | mlejva/deeplearning | /uppercase_letters/du_8_uppercase_letters.py | UTF-8 | 11,365 | 2.625 | 3 | [] | no_license | #!/usr/bin/env python
from __future__ import division
from __future__ import print_function
import datetime
import numpy as np
import tensorflow as tf
import tensorflow.contrib.losses as tf_losses
import tensorflow.contrib.layers as tf_layers
import tensorflow.contrib.metrics as tf_metrics
class Dataset:
def __i... | true |
978cfe62306ab9d332d33c70f1c6f03c48700930 | Python | l5d1l5/EPAquaticSurvey | /04_nutrientsChlaLake.py | UTF-8 | 10,308 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# ## Import modules and set path
# In[1]:
import os
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from IPython.display import display
pd.options.display.max_columns = 50
pd.options.display.max_rows = 20
from scipy import stats
import matplotlib as mpl
w... | true |
4d38d84185094b4eca8eb9ffd5670d4ac0ef01de | Python | Amaguk2023/Pyspark_Spotify_ETL | /Airflow/Modules/data_request.py | UTF-8 | 862 | 2.515625 | 3 | [] | no_license | import requests
import json
from datetime import datetime
import datetime
from Spotify_ETL_Modules import extraction
def spotify_data_request(ACCESS_TOKEN):
#API CREDENTIALS FOR DATA REQUEST
headers = {
"Accept" : "application/json",
"Content-Type" : "application/json",
"Authorization" : "Bearer {token}".form... | true |
88b55d69950b3b62f78df9597dcf6ab061c29c18 | Python | ThorsteinnAdal/webcrawls_in_singapore_shippinglane | /db_to_file_helpers/test_jsonDicts_to_file.py | UTF-8 | 4,530 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | __author__ = 'thorsteinn'
import unittest
import os
import json
from jsonDicts_to_file import db_to_file, file_to_db, check_if_db_is_in_file, groom_file_db
class MyTestCase(unittest.TestCase):
def setUp(self):
'''
make a reasonable looking dictionary
'''
first = {'header001': {'typ... | true |
3ad86f3a18606fca80255b910730a84786cea1c9 | Python | yukokokoo/Randomized-optimization | /problem distribution.py | UTF-8 | 1,521 | 3.28125 | 3 | [] | no_license | import mlrose_hiive
import numpy as np
import matplotlib.pyplot as plt
from itertools import permutations
fitness = np.empty(256)
for i in range(256):
state = np.zeros(8)
num = [int(x) for x in list('{0:0b}'.format(i))]
for j in range(8 - len(num), 8):
state[j] = num[j - (8 - len(num))]
... | true |
bdc9c6a7d1067ba96b2f30ed0c33f79c5818204f | Python | Yohager/Leetcode | /python版本/5839-MinStoneSum.py | UTF-8 | 415 | 3.171875 | 3 | [] | no_license | class Solution:
def minStoneSum(self, piles: List[int], k: int) -> int:
tmp = [(-1)*i for i in piles]
import heapq
#import math
heapq.heapify(tmp)
while k > 0:
#弹出当前的最小值
cur = heapq.heappop(tmp)
cur = cur // 2
heapq.heappush(tmp... | true |
e0d3ed27dd48792145a724db61e2ecb9ab9c66a6 | Python | euggrie/w3resources_python_exercises | /Basic/exercise12.py | UTF-8 | 794 | 4.1875 | 4 | [] | no_license | ###############################
# #
# Exercise 12 #
# www.w3resource.com #
###############################
... | true |
5ce01a0dbcc9050e6664d0ddd419d5f8c0bcd54c | Python | pafreema/grs1915 | /COcubemasking.py | UTF-8 | 1,158 | 2.59375 | 3 | [] | no_license | from spectral_cube import SpectralCube
import astropy.io.fits as pyfits
import astropy.units as u
twelve=SpectralCube.read('12CO_combinewithtp.fits')
twelve_1=twelve.with_spectral_unit(u.km/u.s, velocity_convention='radio')
thirteen=SpectralCube.read('13CO_combinewithtp.fits')
thirteen_1=thirteen.with_spectral_unit(u.... | true |
6b6ca3858bcbc1f1d4ba398c44742396db106577 | Python | adrianmfi/deep-tictactoe | /src/board_to_img.py | UTF-8 | 2,130 | 2.96875 | 3 | [] | no_license | import os
from PIL import Image
WIDTH = 512
HEIGHT = 512
def to_image(board_arr, img_name):
img = Image.new("RGB", (WIDTH, HEIGHT))
shapes_path = 'shapes'
rel_dir = os.path.dirname(__file__)
circ = Image.open(os.path.join(rel_dir, shapes_path, 'circle.png')).resize((WIDTH //
... | true |
981e678719d62dbf6c80572005b0731db364d1fc | Python | cms-kr/hep-tools | /haddsplit | UTF-8 | 1,165 | 2.703125 | 3 | [] | no_license | #!/usr/bin/env python
import sys, os
def haddsplit(destDir, inputFiles):
## estimate total size and merge not to exceed 1Gbytes
totalSize = sum([os.stat(f).st_size for f in inputFiles])
fSize = 4*1024.*1024*1024 # 4GB
nOutput = int(totalSize/fSize)+1
nTotalFiles = len(inputFiles)
nFiles = nTo... | true |
4cf1b3e9d87d367bbbc95def8e446642e31385df | Python | mstatt/DocNovus | /text_extraction_doc.py | UTF-8 | 1,817 | 2.65625 | 3 | [] | no_license | def extract_Text_doc(x):
# -*- coding: utf-8 -*-
import os
import glob
import docx
from docx import Document
import shutil
#Imported Modules
from error_log_writer import error_msg
print("Starting Text Extraction for word doc's......")
error_msg(x,"Starting Text Extraction for w... | true |
6db96cc20f311953ea69574c17472c8ba2fcf8ca | Python | supratikbose/Multi-modal-learning | /dltk/core/modules/base.py | UTF-8 | 6,811 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | #from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
import tensorflow as tf
import re
import os
class AbstractModule(object):
"""Superclass for DLTK core modules - strongly inspired by Sonnet: https://github.com/deepmind/sonnet
This class wraps imple... | true |
ee305ab066792f362ecabc1d62c2feaf6e662403 | Python | cacev000/hw5 | /kmean.py | UTF-8 | 5,188 | 3.015625 | 3 | [] | no_license | import math
from numpy import dot
from numpy.linalg import norm
import random
import time
from tkinter import *
def euclidean(instance1, instance2):
if instance1 == None or instance2 == None:
return float("inf")
dist = 0
for i in range(1, len(instance1)):
dist += (instance1[i] - instance2[... | true |
229864c210ce54be0555366732501b6c7f4a160a | Python | JairMendoza/Python | /curso 2/ej2.py | UTF-8 | 223 | 4.0625 | 4 | [] | no_license | print ("Hola, buen dia.\n Vamos a calcular el perimetro de un triangulo")
altura = int(input("Ingrese la altura:" ))
base = int (input( "Ahora ingresemos la base: "))
area = base*altura/2
print (f"El Area es: {area}")
| true |
e9ef3fbae649c3e97d0c243c313ec39d97251dd1 | Python | Chriscaracach/python | /python.py | UTF-8 | 1,143 | 4.25 | 4 | [] | no_license | # #Funcion para generar letras random
# import random
# def textoRandom(texto):
# resultado = ""
# for letra in texto:
# if(letra == " "):
# resultado = resultado + " "
# else:
# resultado = resultado + random.choice("abcdefghijklmnopqrstuvwxyz")
# return resultado
... | true |
deeb59288b301491297985c07fe192f161ab2497 | Python | Rich43/rog | /albums/3/challenge296_easy/code.py | UTF-8 | 897 | 3.90625 | 4 | [] | no_license | '''
Print out the lyrics of The Twelve Days of Christmas
'''
import re
num_to_text = {
'and 1': 'and one',
'1': 'one',
'2': 'two',
'3': 'three',
'4': 'four',
'5': 'five',
'6': 'six',
'7': 'seven',
'8': 'eight',
... | true |
9075070deb70d73eb06fe50fedcb0e24a3117845 | Python | duanmao/leetcode | /98. Validate Binary Search Tree.py | UTF-8 | 1,090 | 3.5625 | 4 | [] | no_license | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def isValidBST(self, root: TreeNode) -> bool:
s = []
prev, node = None, root
while node or s:
while n... | true |
3515192fd7bcea33261eaae9cff15631b0d1e9e0 | Python | MooooonaLuo/mona-hello-world-homework | /hello_world_w2.py | UTF-8 | 1,873 | 3.9375 | 4 | [] | no_license | # Name: Jiayu Luo
# Assignment 1
myMac = {
"model": "MacBook Pro",
"size": 15,
"year": 2015,
"system": "macOS Big Sur",
"systemVersion": "11.5.2",
"memory": 16
}
# size in inch, memory in GB
myMug = {
"color": "red",
"brand": "Starbucks",
"volume": 355
}
# volume in ml
myVitamin =... | true |
b6a40f52b4d37ce33019ac00f0d829546d54124e | Python | Aasthaengg/IBMdataset | /Python_codes/p03737/s721567692.py | UTF-8 | 173 | 2.875 | 3 | [] | no_license | # A - Three-letter acronym
# https://atcoder.jp/contests/abc059/tasks/abc059_a
s1, s2, s3 = map(str, input().split())
print(s1[0].upper() + s2[0].upper() + s3[0].upper())
| true |
2e78bdec1ca9193e51580d5b9fd967a0efe5800b | Python | cornell-cup/cs-minibot | /minibot/botstate.py | UTF-8 | 733 | 3.671875 | 4 | [
"Apache-2.0"
] | permissive | """
BotState object.
"""
class BotState():
"""
BotState class.
Keeps track of the current state of the minibot.
"""
x = 0
y = 0
angle = 0
radius = 0
def __init__(self, x=0, y=0, angle=0, radius=0):
"""
Constructor for BotState. Assumes bot begins at origin with no o... | true |
13ffeee0a606e6088aa1298174028066528db5b2 | Python | boun7yhunt3r/Pythoncodes | /pyimagesearch/11_CV_case_studies/measuring_distance/pyimagesearch/markers/distancefinder.py | UTF-8 | 1,971 | 3.25 | 3 | [] | no_license | import cv2
class DistanceFinder:
def __init__(self, knownWidth, knownDistance):
self.knownWidth = knownWidth
self.knownDistance = knownDistance
#initialize the focal length
self.focalLength = 0
def calibrate(self, width):
self.focalLength = (width * self.knownDistance)... | true |
f445212a16e85a8786fe6837e17f6bd16047b192 | Python | chbrown/topic-sentiment-authorship | /tsa/science/summarization.py | UTF-8 | 4,708 | 2.515625 | 3 | [
"MIT"
] | permissive | from viz import gloss, geom
import numpy as np
from sklearn import metrics, cross_validation
from tsa.science import numpy_ext as npx
from tsa import logging
logger = logging.getLogger(__name__)
def metrics_summary(y_true, y_pred, labels=None, pos_label=1, average=None):
return ', '.join([
'accuracy: {a... | true |
c0bffb9e2b519f6fa78aeb069d481d9a6e14c026 | Python | ZL-Zealous/ZL-study | /py_study_code/函数/function_car.py | UTF-8 | 250 | 2.953125 | 3 | [] | no_license | def make_car(maker,size,**infos):
car_info={}
car_info['maker']=maker
car_info['size']=size
for k,v in infos.items():
car_info[k]=v
return car_info
car=make_car('subaru','outback',color="blue",tow_package=True)
print(car) | true |
b25d93eecd4446e3011686f9b1365897bde0d469 | Python | chuncaohenli/leetcode | /Python/lc227. Basic Calculator II.py | UTF-8 | 1,523 | 3.28125 | 3 | [] | no_license | # def calculate(s):
# if not s:
# return "0"
# stack, num, sign = [], 0, "+"
# for i in range(len(s)):
# if s[i].isdigit():
# num = num*10+ord(s[i])-ord("0")
# if (not s[i].isdigit() and not s[i].isspace()) or i == len(s)-1:
# if sign == "-":
# ... | true |
411ca135ab868facac4deb0913d1de45a743d4ed | Python | XuYi-fei/HUST-EIC-MathematicalModeling | /final/Preprocessed.py | UTF-8 | 1,029 | 2.75 | 3 | [
"MIT"
] | permissive | import pandas as pd
import os
import csv
data = pd.read_csv(r"D:\GitRepos\EIC\MathmaticalModeling\HUST-EIC-MathematicalModeling\final\time_series_covid_19_confirmed.csv")
columns = dict(zip(range(len(data.columns)), data.columns))
columnIndex = list(data.columns)[1:]
countries = {}
for index, row in data.iterrows():
... | true |
7a4c13f9fb21f5ada870d4625433677980db8e85 | Python | sharankonety/algorithms-and-data-structures | /linked_lists/linear_linked_lists/Insertion/insert_at_index.py | UTF-8 | 1,874 | 4.21875 | 4 | [] | no_license | # Insert a node at specified index position
class Node:
def __init__(self,data=None):
self.data = data
self.next = None
class Linked_list:
def __init__(self):
self.head = None
def list_print(self):
print_val = self.head
while print_val:
print(print_val.dat... | true |
395bade3019e6804a7f55a582899ba424a2e4d20 | Python | danebista/LeetCode-Algorithms | /Algorithms-LeetCode/11-20/15. 3 Sums Problem.py | UTF-8 | 801 | 2.828125 | 3 | [] | no_license | class Solution:
def threeSum(self, nums: List[int]) -> List[List[int]]:
ans=[]
nums.sort()
for i,a in enumerate(nums):
if i>0 and a==nums[i-1]:
continue
l=i+1
r=len(nums)-1
while(l<r):
sums= nums[l]+nums[r]+ a
... | true |
dae27393581ab5f5efa5185ea17df5c1bd7b4916 | Python | parkermac/ptools | /obs_ecy/station_map.py | UTF-8 | 1,429 | 2.6875 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Plot locations of Ecology Stations.
"""
# imports
import pandas as pd
import matplotlib.pyplot as plt
# SSMSP import
import os
import sys
pth = os.path.abspath('../ssmsp')
if pth not in sys.path:
sys.path.append(pth)
import sfun
import pfun
dir0 = '../../ptools... | true |
bc6d80b38bbd8c4e779b0352de2a9f3bee789140 | Python | mallika2011/Spotify-Recommender-System | /approach_A/preprocessing/for_artists/create_new_features.py | UTF-8 | 2,064 | 2.8125 | 3 | [] | no_license | import os
import pandas as pd
from itertools import chain
import ast
def load_artists(ids, emb):
f1 = open(ids, 'r')
line1 = f1.readline().strip('\n')
f2= open(emb, 'r')
line2 = f2.readline().strip('\n')
dict_ret = {}
while(line1):
dict_ret[line1] = line2.split()
... | true |
3a153aafa1bef5787c193cd1083ea6e3be9e82d8 | Python | OneJane/OneJane.github.io | /2021/11/11/SO逆向之最右sign分析/md5.py | UTF-8 | 6,821 | 3.53125 | 4 | [] | no_license | # codeing=utf-8
# 引入math模块,因为要用到sin函数
import math
# 定义常量,用于初始化128位变量,注意字节顺序,文中的A=0x01234567,这里低值存放低字节,即01 23 45 67,所以运算时A=0x67452301,其他类似。
# 这里用字符串的形势,是为了和hex函数的输出统一,hex(10)输出为'0xA',注意结果为字符串。
A = '0x67552301' # '0x67452301'
B = '0xEDCDAB89' # '0xefcdab89'
C = '0x98BADEFE' # '0x98badcfe'
D = '0x16325476' # '0x10325476'... | true |
4fc9ef846dbfdffe1fdba062a04c9682290b65f8 | Python | Krzyzaku21/Git_Folder | /_python_learning/Nauka Metod/met_list.py | UTF-8 | 3,831 | 4.625 | 5 | [] | no_license | # my_list = []
# 1. Zbiór wartości, 2. indeks od 0
# 3. Łatwe : dodawanie, odczytywanie, usówanie wartości, 4. Lista posiada swój indeks
# 5. Comprehension [expression for item in list] -
def list_comprehension():
point1 = "lista liter ze słowa human"
point2 = "lista z mapowaniem funkcji lambda i lista2 z filt... | true |
8eae838da7124b775432c4fa1eb6ea40a3601fac | Python | Akenne/CheckiO | /Home/How to find friends.py | UTF-8 | 2,205 | 3.65625 | 4 | [] | no_license | """
Sophia's drones are not soulless and stupid drones; they can make and have friends.
In fact, they are already are working for the their own social network just for drones!
Sophia has received the data about the connections between drones and she wants to know more about relations between them.
We have an array of... | true |
7af74ef640faf9383a817e4dcc9f306b1cc3778e | Python | OScott19/TheMulQuaBio | /archived/silbiocomp/Practicals/Code/re1.py | UTF-8 | 642 | 3.671875 | 4 | [
"CC-BY-3.0",
"MIT"
] | permissive | import re
my_string = "a given string"
# find a space in the string
match = re.search(r'\s', my_string)
print match
# this should print something like
# <_sre.SRE_Match object at 0x93ecdd30>
# now we can see what has matched
match.group()
match = re.search(r's\w*', my_string)
# this should return "string"
match.gr... | true |
4cfa669563e70feca81598dd1bca1dbe0a953602 | Python | kksuresh25/mutator | /loop_builder.py | UTF-8 | 25,887 | 2.796875 | 3 | [] | no_license | #!/usr/bin/env
from modeller import *
from modeller.optimizers import molecular_dynamics, conjugate_gradients
from modeller.automodel import *
from modeller.scripts import complete_pdb
from Bio import PDB as pdb
import re
import csv
import os, glob
import gromacs
"""
loop_builder.py
This program fills in missing res... | true |
ef6490b9000f00cef1d58fbc41d9cfc0a365ee93 | Python | RuoBingCoder/Python-Machine-Learning-Algorithm | /KNN/knn_plt.py | UTF-8 | 824 | 3 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
' a test module '
__author__ = 'clawpo'
from sklearn import datasets
import matplotlib.pyplot as plt
if __name__ == '__main__':
# 加载Iris数据集
iris = datasets.load_iris()
# 类别已经转成了数字,0 = Iris - Setosa, 1 = Iris - Versicolor, 2 = Iris - Virginica.
y = iris.... | true |
12822a083dd79ca8ce3e16c8467743f2972ac815 | Python | bwaheed22/imessages | /Scripts/sentiment_scores.py | UTF-8 | 1,128 | 3.015625 | 3 | [] | no_license | # Sentiment Analysis
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
import nltk
nltk.download('punkt')
nltk.download('stopwords')
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
# Instantiate analyzer:
analyzer = SentimentIntensityAnalyzer()
# Load Group Chat DataFrame... | true |
db918b4af752c86d5d4dfca411da49e928aa2b48 | Python | ComputerVisionCourse/CV-UI | /Class3/src/video_dilation.py | UTF-8 | 548 | 2.75 | 3 | [] | no_license | import cv2
import numpy as np
if __name__ == '__main__':
cap = cv2.VideoCapture(0)
while(1):
# get frame from camera
ret, frame = cap.read()
img = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# dilate image
kernel = np.ones((10, 10), np.uint8)
dilation = cv2.dilate(i... | true |
7c152477ce5e066eb2d897f8be9301684e446aac | Python | Luolingwei/LeetCode | /String/Q777_Swap Adjacent in LR String.py | UTF-8 | 875 | 3.453125 | 3 | [] | no_license |
# 思路: 因为XL只能让L往左替换, RX只能让R往右替换, 所以对应的start的L要在target的右边, 对应的start的R要在target的左边
# 同时RL不能相互跨越, 所以start和end的RL的个数和位置要对应
class Solution:
def canTransform(self, start: str, end: str) -> bool:
start_pairs = [(i,c) for i,c in enumerate(start) if c in ('L','R')]
end_pairs = [(i,c) for i,c in enumerate(end... | true |
2a9bdfe234da206b963f596f75e64454f11cc1ce | Python | ytyaru/Python.Hatena.Authentication.20211014095441 | /src/oauth1_get_token.py | UTF-8 | 3,618 | 2.75 | 3 | [
"CC0-1.0"
] | permissive | #!/usr/bin/env python3
#encoding:utf-8
# http://developer.hatena.ne.jp/ja/documents/auth/apis/oauth/consumer
# https://qiita.com/kosystem/items/7728e57c70fa2fbfe47c
#Temporary Credential Request URL https://www.hatena.com/oauth/initiate
#Resource Owner Authorization URL (PC) https://www.hatena.ne.jp/oauth/authorize
#... | true |
c2f5f9b47b6820a97a5b439de1fdbf57979ae467 | Python | parth-jr/ML-AndrewNG-Data | /plot/plotData.py | UTF-8 | 521 | 3.046875 | 3 | [] | no_license | import numpy as np
from matplotlib import pyplot as plt
data = np.loadtxt("ex2data1.txt", delimiter = ',', dtype = 'float')
X = data[:, 0:2]
y = data[:, 2]
m = len(y)
X = X.reshape((m,2))
y = y.reshape((m,1))
for i in range(m):
if(y[i] == 0):
plt.plot(X[i,0],X[i,1], "o", color = '#FFDD3C', mark... | true |
59e653746c5d1c8cd033d6612d0d4f0c466c4112 | Python | chrisglencross/advent-of-code | /aoc2021/day17/day17.py | UTF-8 | 1,044 | 3.46875 | 3 | [] | no_license | #!/usr/bin/python3
# Advent of code 2021 day 17
# See https://adventofcode.com/2021/day/17
import re
with open("input.txt") as f:
bounds = [int(value) for value in re.match("^target area: x=([-0-9]+)..([-0-9]+), y=([-0-9]+)..([-0-9]+)$", f.readline().strip()).groups()]
def hit_target(fire_dx, fire_dy, bounds):
... | true |
e66a1eb263074fd8f0f80957505b87a2497c91a9 | Python | sagar11010/PythonforEthicalHacking | /PyautoGuiTest.py | UTF-8 | 543 | 2.65625 | 3 | [] | no_license | import pyautogui
import time
pyautogui.FAILSAFE = False
def completeAction():
time.sleep(2)
# Index Setup
# pyautogui.hotkey('alt','tab')
# time.sleep(1)
# pyautogui.click() # Click on the program
# time.sleep(1)
i = 0
process = 10
time.sleep(3)
for i in range(10):
time.sleep(1)
pyautogui.hotkey('alt','... | true |
9f5b02bc2f617deae9254d67b9040795081bd41c | Python | Vanojx1/AdventOfCode2018 | /D8/part1.py | UTF-8 | 944 | 3.0625 | 3 | [
"MIT"
] | permissive | import re
puzzleInput = open('input.txt', 'r').read()
rawTree = map(lambda n: int(n), re.findall(r'\d+', puzzleInput))
class Tree():
cursor = -1
metaSum = 0
class Node():
def __init__(self, id=0):
self.id = id
self.tree = Tree
self.startIndex = self.tree.next()
self.metaIndex = sel... | true |
58cdf60cb7019d9eee16332576d5dfb6801c66f8 | Python | robbertvdzon/robotaansturing | /python/test4.py | UTF-8 | 1,736 | 3.0625 | 3 | [] | no_license | import time
from smbus import SMBus
from PCA9685 import PWM
fPWM = 50
i2c_address = 0x40 # (standard) adapt to your module
channel = 0 # adapt to your wiring
a = 8.5 # adapt to your servo
b = 2 # adapt to your servo
current0 =6.393
current1 =5.908
current2 =5.985
current3 =2.514
def setup():
global pwm
bus ... | true |
f9c5e2ea3408c333d07bea031eb17584634ff546 | Python | metinsenturk/ds620-motiondetection | /face-detect.py | UTF-8 | 1,882 | 3 | 3 | [] | no_license | import cv2 as cv
def detectAndDisplay(frame):
frame_gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
frame_gray = cv.equalizeHist(frame_gray)
# -- Detect faces
faces = face_cascade.detectMultiScale(
frame_gray,
scaleFactor=1.1,
minNeighbors=5,
minSize=(30, 30)
)
for... | true |
eedf261cb71d214d77f81aff31325c7722481ef3 | Python | alexander92993/ATU_coordenadas | /ATU_puntos.py | UTF-8 | 1,196 | 2.5625 | 3 | [] | no_license | import requests
import pandas as pd
writer = pd.ExcelWriter('BD_final.xlsx', engine='openpyxl')
url = "https://sistemas.atu.gob.pe/paraderosCOVID/Home/traer_datos"
headers2 = {
"user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/71.0.3578.80 Chrome/71.0.357... | true |
9176c1c0feb97b4fab2a95ed9a8b1b1a9525f93b | Python | codiez/mobile.sniffer | /mobile/sniffer/chain.py | UTF-8 | 1,601 | 2.671875 | 3 | [] | no_license | """
Chained user agent detection.
Use several sources to sniff UAs for better accuracy.
"""
__author__ = "Mikko Ohtamaa <mikko.ohtamaa@twinapex.fi>"
__copyright__ = "2009 Twinapex Research"
__license__ = "GPL"
__docformat__ = "epytext"
import base
class ChainedSniffer(base.Sniffer):
""" Chained sn... | true |
a5368a3190c24e85f10ac57aeb503ede59a2263c | Python | dirkakrid/importceptor | /tests/test_importceptor.py | UTF-8 | 4,357 | 2.84375 | 3 | [
"MIT"
] | permissive | # coding: utf-8
"""
Tests for `importceptor` module.
"""
from __future__ import unicode_literals
import unittest
import sys
from types import ModuleType
from importceptor import importceptor as ic
class TestImportceptor(unittest.TestCase):
marker = object()
def setUp(self):
# Note: this is most... | true |
0091fbde37860f6ffd34ece1934b44475cdcd5c3 | Python | InSeong-So/Algorithm | /python/problem/prgrms/week00-pretest/01_완주하지못한선수.py | UTF-8 | 1,168 | 3.640625 | 4 | [] | no_license | # 원소의 수를 세어 주는 라이브러리
from collections import Counter # O(n)
# 단순 반복으로 풀기 : 효율성 테스트 통과 X
def solution(participant, completion):
# O(n^2)
for i in completion: # O(n)
participant.remove(i) # O(n)
return str(participant[0])
# 정렬을 사용하여 풀기 : 효율성 테스트 통과 O
def solution(participant, completion):
part... | true |
d29c2a5c7a0692f18d3aa52f9329725211fcee2e | Python | sandeepkumar11/Face-Mask-Detection-Recognition | /Face mask project.py | UTF-8 | 2,820 | 3.125 | 3 | [] | no_license | # Convolutional Neural Network
# Importing the libraries
import tensorflow as tf
from keras.models import Sequential
from keras.layers import Convolution2D
from keras.layers import MaxPooling2D
from keras.layers import Flatten
from keras.layers import Dense
from keras.callbacks import TensorBoard, ModelCheckp... | true |
4d05c6f1968155cffbfdd102ffecf4690fd98f58 | Python | Nirol/LeetCodeTests | /Algorithms_questions/ez/count_primes.py | UTF-8 | 609 | 3.5625 | 4 | [] | no_license | import math
class Solution:
def countPrimes(self, n: int) -> int:
ans=0
for i in range (n):
if Solution.is_prime(i):
ans=ans+1
return ans
def is_prime(n):
if n == 2:
return True
if n % 2 == 0 or n <= 1:
... | true |
e6a7ad3b4c557568332758b56c25e18ca6f08620 | Python | mphuc/linux_c | /python/tt.py | UTF-8 | 84 | 2.65625 | 3 | [] | no_license |
aaa = {}
aaa["123"] = 1
aaa["234"] = 2
for keystr in aaa.keys():
print keystr
| true |
be13642c7fb0d4dc2ef10db4fd2fd9a6f56b0882 | Python | elpablo/Design-Pattern-Book | /Python/3-Behavioural/Iterator/DemoIterator.py | UTF-8 | 420 | 3.65625 | 4 | [] | no_license | #!/usr/bin/env python3
from Container import Container
def main():
stack = Container()
for i in range(1, 5):
stack.push(i)
container_iterator = stack.create_iterator()
while container_iterator.has_next():
print("Item: %d" % container_iterator.current_item())
container_iterato... | true |
23aef07083cf0498e02af4ea523a704325ceffcb | Python | harry595/BaekJoon | /Programmers/42577.py | UTF-8 | 224 | 2.78125 | 3 | [] | no_license | def solution(phone_book):
phone_book.sort()
for i in range(1,len(phone_book)):
before_len=len(phone_book[i-1])
if(phone_book[i][:before_len]==phone_book[i-1]):
return False
return True | true |
5d29206c954fb6955104e24834a770bafd93e4bf | Python | soberoy1112/Lintcode | /official_answer/test.py | UTF-8 | 724 | 3.40625 | 3 | [] | no_license | class Solution(object):
# @param nestedList a list, each element in the list
# can be a list or integer, for example [1,2,[1,2]]
# @return {int[]} a list of integer
def flatten(self, nestedList):
# Write your code here
if isinstance(nestedList, int):
return nestedList
... | true |
985b4e3d3fbc930e2f7772643fa818d751616470 | Python | BenjaminTMilnes/UOWFourthYearProjectOriginal | /Code Archive/Analysis_116_2013-03-07/ProgressMeter.py | UTF-8 | 690 | 3.46875 | 3 | [] | no_license | # Progress Meter
#
# Modified 2013.01.16 22:50
# Last Modified 2013.01.16 23:16
#
import math
class ProgressMeter:
def __init__(self, EndCount):
self.Count = 0
self.EndCount = EndCount
def Update(self, Count):
self.Count = Count
NewCount = False
if (self.Count < self.EndCount):
Progres... | true |
5703ae0e68909e912a658fa7e64fb43cff545d12 | Python | Guessan/python01 | /Assignments/Answer_8.4.py | UTF-8 | 654 | 4.40625 | 4 | [] | no_license | #8.4
#Open the file romeo.txt and read it line by line. For each line, split the line into a list of words using the split() method.
#The program should build a list of words.
#For each word on each line check to see if the word is already in the list and if not append it to the list.
#When the program completes, so... | true |
013a604258057e07a3ff4c96f35e011f6bb5d73d | Python | k201zzang/ComputationalPhysics | /F5.4.py | UTF-8 | 547 | 2.578125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu Aug 8 12:01:32 2013
@author: akels
"""
from __future__ import division, print_function
from os import sys
sys.path.append('cpresources')
#from pylab import *
from cmath import exp
from math import factorial,pi
f = lambda x: exp(2*x)
def derivative(fp,m,z0=0):
f = lambd... | true |
e442e9a5c088aaf0378d022abd6fc0fc588f9d6e | Python | Dimantarian/cryptoTradingBot | /interface/autocomplete_widget.py | UTF-8 | 3,620 | 3.453125 | 3 | [
"MIT"
] | permissive | import tkinter as tk
import typing
class Autocomplete(tk.Entry):
def __init__(self, symbols: typing.List[str], *args, **kwargs):
super().__init__(*args, **kwargs)
self._symbols = symbols
self._lb: tk.Listbox
self._lb_open = False # Used to know whether the Listbox is already ope... | true |
9d490c47de55fd614fde4380308e5f99a40cb7d9 | Python | zhuyunning/zhuyunning | /Programming for Analytics/Assignment 3.py | UTF-8 | 14,261 | 2.828125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sun Oct 9 13:51:08 2016
@author: nico
Programming Assignment 03: Web Scraping
Group 5
Yunning Zhu G39659638
Daniel Chen G25195689
Xinyi Wang G44230350
Tingting Ju
Abhinav Chandel G33895000
"""
#Question 1
#Mexican Restaurant
from bs4 import BeautifulSoup as bs
import urllib.re... | true |
8312415e2d37049fd6db124c63c5ece7499f62fe | Python | apeden/brownieSorter | /camp.py | UTF-8 | 16,171 | 3.71875 | 4 | [] | no_license | """
Author: Alex Peden
email: apeden23@gmail.com
July 2019
A programme for sorting brownies* into groups (tents)
of equal size according to friendships. Brownies and
friendship choices are imported from a text file.
An algorithm is run to find the optimal (or near best)
groupings of brownies. The best camp can be prin... | true |
da9f1be533944ae53e30bd8bfa1440d012780a0c | Python | ZXiaoheng/SHVC-bitrate-estimation | /SHVC_project/VIF/testvif.py | UTF-8 | 823 | 2.828125 | 3 | [] | no_license | import pandas as pd
import numpy as np
from statsmodels.stats.outliers_influence import variance_inflation_factor
# 宽表
data = pd.DataFrame([[15.9, 16.4, 19, 19.1, 18.8, 20.4, 22.7, 26.5, 28.1, 27.6, 26.3]
, [149.3, 161.2, 171.5, 175.5, 180.8, 190.7, 202.1, 212.1, 226.1, 231.9, 239]
... | true |
8b665e68dfd9d05fca0b2b43ffda42398e7d53c7 | Python | gotsulyakk/Learn-OpenCV | /warp_perspective.py | UTF-8 | 412 | 2.5625 | 3 | [] | no_license | import numpy as np
import cv2
img = cv2.imread('images/**ANY_IMAGE**')
width, height = 250, 350
pts1 = np.float32([[505, 157], [583, 261], [340, 225], [411, 342]])
pts2 = np.float32([[0, 0], [width, 0], [0, height], [width, height]])
matrix = cv2.getPerspectiveTransform(pts1, pts2)
output = cv2.warpPerspective(img, ma... | true |
14809848c0de951998b816b8a781efe4b5cc7150 | Python | avontd2868/6.00.1x | /examples/break-test.py | UTF-8 | 169 | 3.75 | 4 | [] | no_license | for n in range(2, 10):
for x in range(2, n):
if n % x == 0:
print str(n) + ' equals ' + str(x) + ' * ' + str(n/x)
break
else:
print str(n) + ' is a prime'
| true |