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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
6ae125fd0a23a92b1961199d22cbffd2de5c4a8b | Python | jakelar/Python | /python RPG/hero.py | UTF-8 | 3,083 | 3.484375 | 3 | [] | no_license | #hero class
class Hero:
def __init__(self,name,race,heroClass):
self.name = name
self.race = race
self.heroClass = heroClass
self.level = 1
self.hp = 0
self.atk = 0
self.alive = True
self.mana = 0
self.maxMana = 0
self.xp = 0
self.xpMax=25
self.locationi=9
self.l... | true |
5610c833ef77570bff4e259bcdc007ea236a7166 | Python | gubenkoved/daily-coding-problem | /python/dcp_378_json_dump.py | UTF-8 | 1,083 | 3.875 | 4 | [] | no_license | # This problem was asked by Coinbase.
#
# Write a function that takes in a number, string, list, or dictionary and returns
# its JSON encoding. It should also handle nulls.
#
# For example, given the following input:
#
# [None, 123, ["a", "b"], {"c":"d"}]
# You should return the following, as a string:
#
# '[null, 123,... | true |
838829c9e477c219f8b3caf67f71d7d69978e752 | Python | ilpadre/ProjectEuler | /Python/Euler-Problem1.py | UTF-8 | 131 | 3.515625 | 4 | [] | no_license | # Problem 1
totalSum = 0
for x in range(1, 1000):
if x % 3 == 0 or x % 5 == 0:
totalSum = totalSum + x
print(totalSum)
| true |
06c34fa810a181927f2fdbf1a3ddb1d7b2499fe5 | Python | Lance-Easley/Casino | /Casino.py | UTF-8 | 4,632 | 3.1875 | 3 | [
"MIT"
] | permissive | import Blackjack
import Roulette
import Slot_Machine
from os import system, name
#used to clear screen
def clear():
if name == 'nt':
_ = system('cls')
chips = 10000
while chips > 0:
chips = int(chips)
print('')
print(f"You have {chips} chips left")
print('We have Blackjack, Roulette, and... | true |
69ed5d917e5f4eaa1a8d2fb8feeb055c1e542a92 | Python | randim05/test2 | /cards.py | UTF-8 | 332 | 3.03125 | 3 | [] | no_license | cards = {"2":2, "3":3, "4":4, "5":5, "6":6, "7":7, "8":8, "9":9, "10":10,
"Jack":11, "Queen":12, "King":13, "Ace":14}
sum = 0
ch = 1
u_i = []
while len(u_i) < 6:
u_i.append(input())
# u_i = input().split('/n')
for i in u_i:
i.strip()
if i in cards:
sum += cards[i]
# ch += 1
print(s... | true |
e1c7899f33fe6b4fcbd02e5c795470268e4147fa | Python | phcreery/spotify-downloader | /tests/utils/test_formatter.py | UTF-8 | 3,616 | 2.84375 | 3 | [
"MIT"
] | permissive | from pathlib import Path
from spotdl.types.song import Song, SongList
from spotdl.utils.formatter import (
create_file_name,
create_song_title,
parse_duration,
sanitize_string,
)
def test_create_song_title():
"""
Test create song title function
"""
assert (
create_song_title(... | true |
e2d029b2e47579e8507b3fe68233c83047bf95e7 | Python | jennysu/PUBPOL590 | /1_data_clean.py | UTF-8 | 758 | 3.265625 | 3 | [] | no_license | from pandas import Series, DataFrame
import pandas as pd
import numpy as np
import os
main_dir = "/Users/jennysu/Documents/Duke Spring 2015/PubPol590/data/"
git_dir = "/Users/jennysu/GitHub/Pubpol590/"
csv_file = "sample_data_unclean.csv"
df = pd.read_csv(os.path.join(main_dir,csv_file))
# converting lists to series... | true |
54b10414d0208236dadd09456e24abbc91528f72 | Python | RobsonLsMello/agendatelefonica | /Lib/EnviarEmail.py | UTF-8 | 1,383 | 2.625 | 3 | [] | no_license | # import necessary packages
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from Model.DTO.UsuarioDTO import UsuarioDTO
import smtplib
#python.agenda@gmail.com
#SucoDeUva#1
class EnviarEmail:
def __init__(self):
self.msg = MIMEMultipart()
self.mensagem = ""
... | true |
864e449996796702daa2f591fcdd0f5182028111 | Python | istommao/adcat | /adcat/bintree.py | UTF-8 | 2,054 | 3.859375 | 4 | [
"MIT"
] | permissive | """bintree."""
class TreeNode(object):
def __init__(self, val, left=None, right=None):
self.val = val
self.left = left
self.right = right
def __str__(self):
return str(self.val)
def __repr__(self):
return '<TreeNode {}>'.format(str(self.val))
class StackTravers... | true |
5324f611ae24f0f726680123494627c0ea026db7 | Python | raperez81/Curso-basico-de-Python-practicas | /listas.py | UTF-8 | 1,224 | 4.4375 | 4 | [] | no_license | """ objetos = ['Hola', 3,5,7,True]
print(objetos)
# Notacion de slice
print(objetos[1:])
# El parámetro de la funcion append será el elemento que queremos agregar
objetos.append(90)
print(objetos)
# El parámetro de la función será el índice del elemento que queremos borrar, la función pop retorna el elemento borra... | true |
512e43f0bac61c809f5651b407098b0141fc9fbb | Python | pheelcool/EnsembleSystemDevelopment | /src/System/Forecast.py | UTF-8 | 4,302 | 2.859375 | 3 | [] | no_license | '''
Created on 20 Dec 2014
@author: Mark
'''
import pandas as pd
from numpy import NaN, mean, std, empty, isinf
from copy import deepcopy
from pandas.core.panel import Panel
from System.Strategy import StrategyContainerElement, ModelElement
from pandas.stats.moments import rolling_mean, rolling_std
clas... | true |
df8e81a9122c340b2ac448721e478dcea2f44377 | Python | narahc321/SEM-6-DataMining-Lab-codes | /heirarchial/heirachial_clustering.py | UTF-8 | 1,892 | 2.9375 | 3 | [] | no_license | import pandas as pd
import numpy as np
from math import *
from copy import deepcopy
def single(data):
dt = deepcopy(data)
maxi = ceil(np.max(dt)) + 1
for i in range(dt.shape[0]):
dt[i][i] = maxi
steps = []
for step in range(dt.shape[0]-1):
index = np.argmin(dt)
x,y = index//dt.shape[0], index%dt.shape[0]
... | true |
2e6ba62f1e4d55bc42b77015b8a2fab9a6ea45d1 | Python | lulalachen/GodzillaAlert | /src/extract/DB.py | UTF-8 | 1,127 | 2.75 | 3 | [] | no_license | # -*- coding: utf-8 -*-
#處理掉unicode 和 str 在ascii上的問題
import sys
import psycopg2
reload(sys)
sys.setdefaultencoding('utf8')
class DB:
database=""
user=""
password=""
host=""
port=""
conn = None
cur = None
def __init__(self,filepath,beta):
f = open(filepath,'r')
self.database = f.readline... | true |
31f6cb66ec0e0bb3b6d0b126bb553785bf0b954e | Python | cpon00/python-projects | /gradebook.py | UTF-8 | 1,407 | 4.15625 | 4 | [] | no_license | def grade_book():
print("This is a grade book analyzer.")
students = int(input("How many students are in the class?"))
student_grades = dict()
for x in range(0, students):
add_student(student_grades)
for x in student_grades:
print(len(student_grades))
while input("Would you... | true |
743a2dde76721a3d4aacf486060405b9db58fb5d | Python | dskym/Algorithm | /LeetCode/648/Solution.py | UTF-8 | 810 | 3.1875 | 3 | [] | no_license | class Solution:
def replaceWords(self, dict, sentence):
"""
:type dict: List[str]
:type sentence: str
:rtype: str
"""
words = sentence.split(' ')
result = []
for word in words:
temp = word
l = len(word)
... | true |
4f39aea5a199305ef009f96aaf80baab042aaf5e | Python | pjns-lb/polaris-gslb | /polaris_health/state/globalname.py | UTF-8 | 2,646 | 2.921875 | 3 | [
"BSD-3-Clause"
] | permissive | # -*- coding: utf-8 -*-
import logging
from polaris_health import Error
__all__ = [ 'GlobalName' ]
LOG = logging.getLogger(__name__)
LOG.addHandler(logging.NullHandler())
MAX_NAME_LEN = 256
MAX_POOL_NAME_LEN = 256
MIN_TTL = 1
class GlobalName:
"""Load-balnced DNS name"""
def __init__(self, name, pool_na... | true |
df32f2066defd8f201f6dbf6c236c7888f95cde1 | Python | alexahn917/Semesterly_Search | /phase_1/vectorize_json.py | UTF-8 | 5,900 | 2.71875 | 3 | [] | no_license | import numpy as np
import json
import re
from collections import defaultdict
from PorterStemmer import PorterStemmer
from pprint import pprint
import math
def main():
courses = open("../json_files/preprocessed_courses.json").read()
courses = json_loads_byteified(courses)
# set up global variables (read_on... | true |
ee5d17963933791752e6905ac9aa3c74808efada | Python | AndyK184/AmazonPriceWebScraper | /Webscraping/scraper.py | UTF-8 | 853 | 2.859375 | 3 | [] | no_license | import requests
import subprocess
import time
from bs4 import BeautifulSoup
headers = {
"User-Agent": 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Safari/605.1.15'}
URLs = ["Your_first_amazon_link_here",
"Your_second_amazon_link_here"]
def findPr... | true |
5b386ec56586d745acaf09942bc20f70b9f57d89 | Python | EMENDEZ93/englishpy | /englishpy/english_py/practise/types.py | UTF-8 | 850 | 2.6875 | 3 | [] | no_license |
class VerbTypes():
IRREGULAR = 'Irregular'
REGULAR = 'Regular'
PHRASAL_VERB = 'Phrasal_verb'
TYPES = (
(IRREGULAR, IRREGULAR),
(REGULAR, REGULAR),
(PHRASAL_VERB, PHRASAL_VERB)
)
class TimesTypes():
PAST = 'Past'
PAST_PARTICIPLE = 'Past Participle'
TYPES = (
... | true |
daf956ba91e6083e0ad4a8b74fb2b345307f8ccc | Python | Fatalys/PythonIA | /OpenAIgym/TestPendule.py | UTF-8 | 1,234 | 2.796875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu Apr 15 15:26:43 2021
@author: Administrator
"""
import gym
import numpy as np
#Crée l'environnement
env = gym.make('Acrobot-v1')
Amplitude = env.observation_space.high - env.observation_space.low
#Amplitude[4], Amplitude[5] = 15, 20
#Discrétise les états
... | true |
c1c46822ba186f1d22583f2e2ac39f1fbaa3c530 | Python | rishirajsinghjhelumi/Coding-Templates | /SPOJ_BACKUP/COEF-7072168-src.py | UTF-8 | 214 | 3.140625 | 3 | [] | no_license | def fact(n):
if n==0:
return 1
return n*fact(n-1)
while 1:
try:
x=raw_input().split()
n=int(x[0])
k=int(x[1])
y=1
for i in raw_input().split():
y=y*fact(int(i))
print fact(n)/y
except:
break
| true |
548608791f9ed5e0c80d7ab7aebacb5c03ee72c3 | Python | lmmx/wikitransp | /src/wikitransp/scraper/decompress_utils.py | UTF-8 | 1,334 | 3.28125 | 3 | [
"MIT"
] | permissive | from __future__ import annotations
import gzip
import shutil
from pathlib import Path
from tqdm import tqdm
__all__ = ["decompress_gz_file"]
def decompress_gz_file(gz_path: Path) -> Path:
"""
Decompress a gzip-compressed file to disk, naming it by just removing the ".gz"
suffix. If the output path alre... | true |
963c63c3e2a559a77d9309a289c4eba40418cba1 | Python | jlomibao/BIMM185-Lab2 | /getSeq.py | UTF-8 | 1,969 | 3.109375 | 3 | [] | no_license | #File Name: getSeq.py
#Author: John Francis Lomibao
#PID: A11591509
#packages imported
import os.path
import sys
import textwrap
#arg1 is the genomic file, arg2 is the table file
genFile = sys.argv[1]
tableFile = sys.argv[2]
#string to hold DNA seq as continuous string with no spaces
seq = ''
#Take ... | true |
87cc26e4f6c72bad5b66d2f3b5468969d01b01ed | Python | ruiyang123/giao.netflix.github.io | /scripts/data_types.py | UTF-8 | 2,391 | 2.984375 | 3 | [] | no_license | import csv
import operator
import json
def load_data(json_file_name):
with open(json_file_name + ".json") as json_data:
data = json.load(json_data)
total = 0
var = 0.5
for i in range(0, len(data)):
total += data[i]["value"]
print(total)
new_element = {
"name" : "others",
"value"... | true |
aae7d402d39b1487e65314e5f0535d2b482a42e7 | Python | htingwang/HandsOnAlgoDS | /LeetCode/1535.Find-The-Winner-Of-An-Array-Game/Find-The-Winner-Of-An-Array-Game.py | UTF-8 | 588 | 2.921875 | 3 | [] | no_license | class Solution(object):
def getWinner(self, arr, k):
"""
:type arr: List[int]
:type k: int
:rtype: int
"""
if k == 1: return max(arr[0 : 2])
mx = max(arr)
cnt = 1
queue = collections.deque(arr)
pre = -1
while cnt < k:
... | true |
81420bbc6f474e9dc3175b85996aea9d59b84fc3 | Python | Seung-Joon/JCET_dataManagement | /CASE1/Case1_Shell_Excuter.py | UTF-8 | 1,703 | 2.671875 | 3 | [] | no_license |
import os
import sys
import json
from datetime import datetime
timeFlag = datetime.now()
systemInterpreterPath = "/usr/local/bin/python3.7"
workingAreaPath = os.path.dirname(os.path.abspath(__file__))
generatorFile = workingAreaPath + "/Case1_Error_Report.py"
outputFilePath = workingAreaPath + '/output/ERROR_DATA_RE... | true |
fedff7f5ada87f25d3fded17fc5c4477da2e0790 | Python | Ateeq72/attendance_tracking_usig_rfid | /mysql.py | UTF-8 | 3,653 | 2.734375 | 3 | [] | no_license | #-------------------------------------------------------------------------------
# Name: MySQL reader/writer
# Purpose:
#
# Author: Jakub 'Yim' Dvorak
#
# Created: 26.10.2013
# Copyright: (c) Jakub Dvorak 2013
# Licence:
# ----------------------------------------------------------------------------
... | true |
3d5400d431be6ad226db26cac876f0b759387615 | Python | tanucdi/dailycodingproblem | /CP/Arithmetic Problem/Choclate_puzzle.py | UTF-8 | 187 | 2.9375 | 3 | [] | no_license | #TIME COMPLEXITY
# inp=5 | 2,4,8,16,32 = 62
# we can do it usinng loop but tc will be O(n)
# but here using GP tc is O(1)
n=int(input())
r=a=2
s=0
s=(a*(r**n - 1))
r=r-1
s=s//r
print(s) | true |
e6298f99ec573b972bcd847356c05ec4fc895a82 | Python | egreenius/ai.algorithms_python | /lesson_2/les_2_hw_1.py | UTF-8 | 2,069 | 3.921875 | 4 | [] | no_license | '''1. Написать программу, которая будет складывать, вычитать, умножать или делить два числа. Числа и знак операции
вводятся пользователем. После выполнения вычисления программа не завершается, а запрашивает новые данные для
вычислений. Завершение программы должно выполняться при вводе символа '0' в качестве знака опера... | true |
cc3ffeb3f11840544b83a4205cb93905a7368062 | Python | msqming/boboML | /01-Numpy/4-FancyIndexing.py | UTF-8 | 680 | 3.328125 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
x = np.arange(16)
print(x)
ind = [3, 5, 8] # 索引列表
print(x[ind])
ind1 = np.array([[0, 2],
[1, 3]]) # 二维索引
print(x[ind1])
print(x <= 3)
print(np.sum(x <= 3)) # 求向量x小于等于3的所有元素个数的和
print(np.sum((x > 3) & (x < 6))) # 大于3并且小于6 多种条件
print... | true |
a4b54e71a50e4dd4d1625ff86f9a4f704756beb4 | Python | FengWangCN/imtoolkit | /imtoolkit/SemiUnitaryDifferentialMLDSimulator.py | UTF-8 | 7,383 | 2.8125 | 3 | [
"MIT"
] | permissive | # Copyright (c) IMToolkit Development Team
# This toolkit is released under the MIT License, see LICENSE.txt
import os
from tqdm import tqdm, trange
if os.getenv("USECUPY") == "1":
from cupy import *
else:
from numpy import *
from .Simulator import Simulator
from .Util import getXORtoErrorBitsArray, inv_dB, ... | true |
bdfe4bd4ff61999c654183599d1c1ae1517beb05 | Python | rjNemo/graphql_python_template | /app/models/todo.py | UTF-8 | 316 | 3.34375 | 3 | [
"MIT"
] | permissive | from uuid import uuid4
class Todo:
def __init__(self, title: str, todo_id: str = None, is_done: bool = False):
self.todo_id = todo_id or str(uuid4())
self.title = title
self.is_done = is_done
def __repr__(self):
return f"Todo: {self.todo_id}, {self.title}, {self.is_done}"
| true |
85a95c5b623539eaff840ced8a1272c9f54e8426 | Python | tairen99/Boggle-Game | /recursiveMethods.py | UTF-8 | 5,825 | 3.53125 | 4 | [] | no_license | # using two recursive functions to do the word Boggle game
# Given words vector, check if word in words can be found on board.
# Rules: The letters must be adjoining in a 'chain'.
# (Letter cubes in the chain may be adjacent horizontally,
# vertically, or diagonally.) Each letter can only be
# used one time in the wor... | true |
bc9cffa392e4f7326bd2871ab4b0b8201b56129b | Python | GeHaha/AboutPython | /PythonDaily/罗伟富设计模式/E23/share2.py | UTF-8 | 1,698 | 3.15625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sun Oct 7 19:51:01 2018
@author: Gehaha
"""
class PowerBank:
"移动电源"
def __init__(self, serialNum, electricQuantity):
self.__serialNum = serialNum
self.__electricQuantity = electricQuantity
self.__user = ""
def getSerialNum(self):
re... | true |
77270abe9ec5f82b222ddd9c824a1a9e3d96c9ec | Python | afsana1210/python-learning | /exception.py | UTF-8 | 128 | 2.515625 | 3 | [] | no_license | try:
f=open('Line',r)
f.write('write a test line')
except:
print'All other exception!'
finally:
print 'i always run'
| true |
2d35a386b2443aedfe6e2d858bb5a423973a2f8b | Python | Drewleks/learn-python-the-hard-way | /ex16/ex16.py | UTF-8 | 907 | 3.609375 | 4 | [] | no_license | from sys import argv
script, filename = argv
print(f"Я собираюсь стереть файл {filename}.")
print("Если вы не хотите стирать его, нажмите сочетание клавиш CTRL+C (^C).")
print("Если хотите стереть файл, нажмите клавишу Enter.")
input("?")
print("Открытие файла...")
target = open(filename, 'w')
print("Очистка файла... | true |
c5ac5a3f0cac724967a168c6ca94a4d8e7bb1e24 | Python | lokidess/spalah_shop | /core/models.py | UTF-8 | 1,719 | 2.5625 | 3 | [] | no_license | from django.db import models
# python manage.py makemigrations
class TradeMark(models.Model):
name = models.CharField(max_length=255)
class Meta:
verbose_name = 'Торговая Марка'
verbose_name_plural = 'Торговые Марки'
def __str__(self):
return self.name
class Tag(models.Model)... | true |
8ff145fbed9213659cd67b25e070020e753db229 | Python | ppablocruzcobas/Simulated-Annealing | /heuristic/quadric.py | UTF-8 | 5,294 | 3.171875 | 3 | [] | no_license |
__authors__ = ["Melissa", "Ronaldo", "Pedro Pablo"]
from heuristic.anneal import Annealer
import random as r
import numpy as np
class QuadricRealProblem(Annealer):
"""
Class to solve the quadric problem
min xTQx + pTx s.t. a <= x <= b; a, b \in R^{n}:
`Q`: a square matrix
`p`: a vector
`l_li... | true |
4cd073eef78f5ad141d8fef16b84b41067f7a825 | Python | Orecchia-Research-Group/manifold_learning | /manifold_sampling/mala/MA_metropolis_hastings.py | UTF-8 | 8,688 | 2.8125 | 3 | [] | no_license |
import sys
import numpy as np
import numpy.linalg as linalg
import matplotlib.pyplot as plt
import scipy.linalg
import mala.metropolis_hastings as mh
import mala.icosehedron as ico
# MANIFOLD-ADJUSTED METROPOLIS-HASTINGS ----------------------------------------
# meta-algorithm for markov-chain monte-carlo, moving in... | true |
24bd13b6a3d447a9fff7405e314a9838e0203392 | Python | wandora58/RL | /test.py | UTF-8 | 6,792 | 2.71875 | 3 | [] | no_license | """
overview:
Predict solutions to traveling salesman problem using trained model
args:
Following elements are specified in this code
- log_dir: output of following elements
- model_path: trained model file
- n_episodes: number of predicted episodes
output:
Following elements to th... | true |
2e4b100af027472100249a23b8b49fd6d6f5e8df | Python | chenders/deadonfilm | /bin/fill_db.py | UTF-8 | 2,444 | 2.515625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
import requests
from tqdm import tqdm
import zlib
import csv
import os.path
import psycopg2.extras
from urllib.parse import urlparse
DOWNLOAD_URL = "https://datasets.imdbws.com/name.basics.tsv.gz"
OUTPUT_FILENAME = "name.basics.tsv"
DB_URL = urlparse(os.environ.get("IMDB_DB", "postgresql://local... | true |
0f91e3aa78cb1fda7e0d5f62470d2fd4af676a09 | Python | nilsso/challenge-solutions | /exercism/python/book-store/book_store.py | UTF-8 | 1,586 | 3.21875 | 3 | [] | no_license | price = 800
discount = [1, 1-0.05, 1-0.10, 1-0.20, 1-0.25]
def group_price(group):
n = len(group)
return int(n * price * (1 - discount[n-1]))
class CountReducer:
def __init__(self, data):
self.data = [n for n in data if n[1] > 0]
self.i = 0
def __iter__(self):
return self
... | true |
b15b7d15430ab6c5485d9a48d038254a9e0f311c | Python | kirmartuk/ShareCodeWin | /Utils.py | UTF-8 | 349 | 2.703125 | 3 | [] | no_license | import time
from uuid import getnode as get_mac
def getUrl():
str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
tiny = ''
id = int(round(time.time() * 1000))
while (id > 0):
tiny += str[int(id % 62)]
id = int(id / 62)
return tiny
def getMacAddress():
mac = ge... | true |
5179390e32a064acd87eba081311f6d525ee2f10 | Python | prthshrma/Cryptography | /Assignment6/decryptPassword.py | UTF-8 | 250 | 2.859375 | 3 | [] | no_license |
#hardcoded root which is calculated in smallExpRSA.py
root=4773930458381642785
bin_root = "0" + bin(root)[2:]
password=""
for i in range( 0, len(bin_root), 8):
password += chr( int( bin_root[i:i+8] , 2) )
print("Final Password is ",password)
| true |
866194e904185ccd4518d607b17c8821ea17cd93 | Python | Znmangosteen/FuzzyGBML | /draw_graph/draw_3d_point.py | UTF-8 | 1,302 | 2.765625 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# data = np.random.randint(0, 255, size=[40, 40, 40])
# x, y, z = data[0], data[1], data[2]
ax = plt.subplot(111, projection='3d') # 创建一个三维的绘图工程
data = np.loadtxt('../3_OBJ/运行结果/a1_va3/figure/20 c 1 g 800 s 264 e 0.txt')
# dat... | true |
04d1731c77151a7253b9d33a67a944adb65a7444 | Python | caoxiang104/-offer | /35.py | UTF-8 | 2,292 | 3.65625 | 4 | [] | no_license | # -*- coding:utf-8 -*-
"""
链接:https://www.nowcoder.com/questionTerminal/96bd6684e04a44eb80e6a68efc0ec6c5
来源:牛客网
在数组中的两个数字,如果前面一个数字大于后面的数字,则这两个数字组成一个逆序对。
输入一个数组,求出这个数组中的逆序对的总数P。并将P对1000000007取模的结果输出。
即输出P%1000000007
"""
class Solution:
def __init__(self):
self.count = 0
def InversePairs(self, data):
... | true |
ad8a2fe52c43a2e80aafddf98bd7acdd86be5647 | Python | US-ATLAS-HFSF/HFSF2015 | /macros/utils.py | UTF-8 | 718 | 2.984375 | 3 | [] | no_license | '''
A standard set of utilities that help ease the pain of doing work
'''
import re
dsid_regex = re.compile('\.?(?:00)?(\d{6,8})\.?')
def get_dsid(sample_name):
'''
Given a sample name of a standard format, try and extract
the DSID from it
sample_name: the filename as a string for a given sample such ... | true |
225507ae0367f1ee872db69e76bfec751dec3417 | Python | paiv/aoc2015 | /code/22-1-wizard/solve.py | UTF-8 | 4,318 | 3.21875 | 3 | [] | no_license | #!/usr/bin/env python3
import heapq
import itertools
import math
import re
class PriorityQueue:
def __init__(self):
self.pq = [] # list of entries arranged in a heap
self.counter = itertools.count() # unique sequence count
def __len__(self):
return len(self... | true |
eaba3aca1259cf871aa74d3f9760b6c059c3036a | Python | steve98654/bokeh-demos | /bokeh_risk_dashboard/risk_app.py | UTF-8 | 15,063 | 2.546875 | 3 | [] | no_license | # TODO
# put the selection option back in!
# remove bokeh symbol and the link-to-this link?
# Compare multiple portfolios? Dropdown select
## Questions:
# how to control spacing between vtable and htable boxes?
### ADD A PERCENTAGE OF UP DAYS INTO THE DF
# Done:
# sourced with custom stock data
# rearrange... | true |
b46eaa672c2e95db3b4c92318f0d10335902a5a8 | Python | mstazherova/IM-CycleGAN | /tensorflow/utils.py | UTF-8 | 2,563 | 2.578125 | 3 | [] | no_license | import os
import numpy as np
from skimage import transform
import time
import glob
from scipy import misc
import imageio
import cv2
import tensorflow as tf
SAMPLE_DIR = '/tmp/stazherova/samples/{}'.format(time.strftime('%Y%m%d-%H%M%S'))
CHECKPOINT_DIR = '/tmp/stazherova/checkpoint/'
CHECKPOINT_FILE = 'cyclegan.ckpt'... | true |
736746ab8984ea01c74d5e1439afefd40af6616d | Python | dlaststark/machine-learning-projects | /Programming Language Detection/Experiment-2/Dataset/Train/Python/iterated-digits-squaring-4.py | UTF-8 | 555 | 2.8125 | 3 | [] | no_license | >>> from functools import lru_cache
>>> @lru_cache(maxsize=1024)
def _ids(nt):
if nt in {('1',), ('8', '9')}: return nt
else: return _ids(tuple(sorted(str(sum(int(d) ** 2 for d in nt)))))
>>> def ids(n):
return int(''.join(_ids(tuple(sorted(str(n))))))
>>> ids(1), ids(15)
(1, 89)
>>> [ids(x) for x in range(1, 21... | true |
f8f88c6d91dec6ab41add7eed05361a42f5cf093 | Python | Nikhil483/ADA-lab | /merge.py | UTF-8 | 525 | 3.25 | 3 | [] | no_license |
def merge_sort (A) :
if len(A)>1 :
mid=len(A)//2
left=A[:mid]
right=A[mid:]
merge_sort(left)
merge_sort(right)
i=j=k=0
while i<len(left) and j <len(right) :
if left[i]<right[j] :
A[k]=left[i]
i+=1
else :
A[k]=right[j]
j+=1
k+=1
while i<len(left) :
A[k]=left[i]
i+=1... | true |
fe3b143a5b674ad53297a30a12fed2d9dcb793f1 | Python | orokusaki/adgeletti | /adgeletti/templatetags/adgeletti_tags.py | UTF-8 | 5,223 | 2.765625 | 3 | [] | no_license | import re
import json
import cStringIO
from django import template
from django.contrib.sites.models import Site
from django.utils.html import escape
from adgeletti.models import AdPosition
register = template.Library()
ADS = '_adgeletti_ads'
FIRED = '_adgeletti_fired'
BREAKPOINTS = '_adgeletti_breakpoints'
def e... | true |
2ba09252b11c03a958e965348d1ac010624620f6 | Python | JonnyBanana/awesome-cryptokitties | /genes/mixGenes.py | UTF-8 | 4,893 | 2.5625 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | ##################################
# CryptoKitties GeneScience algorithm by Alex Hegyi, Dec 23
# see https://medium.com/@alexhegyi/cryptokitties-genescience-1f5b41963b0d
#
# > My winter holiday thus far has consisted of staring at disassembled bytecode
# > until I had everything figured out:
#
# Source:
# https://g... | true |
94fb64f8353364cdc08cfdec81cee577f04d4b52 | Python | KyungwonJIN/korean_handwriting_verification | /handwriting_verification/predict_for_user.py | UTF-8 | 2,890 | 2.96875 | 3 | [] | no_license |
# hdf5파일 잘 되었는지 확인
import h5py
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.backends.backend_tkagg
## 없김다이 4글자 한번에 test 하기위해서 4번 돌림
for j in range(4):
hdf5_path = 'E:\handwriting_kw\필적_trainingdata_nfolded/class'+ str(j+1) +'_1.hdf5'
# E:\필적_trainingdata_nfolded
# open t... | true |
0ca733b12193d50f991fabdbe34c491111a21fb6 | Python | laurentperrinet/bcpnn-mt | /measure_tuning_curve_abstract.py | UTF-8 | 6,690 | 2.6875 | 3 | [] | no_license | """
This script assumes that you've run abstract_training.py before (the actual training is not necessary,
it's enough to have create_stimuli)
Two different tuning curves can be measured:
1) stimulus orientation vs output rate
2) stimulus distance vs output rate
"""
import os
import pylab
import time
impor... | true |
63190c0ce2e9f63b6005ef527e4ca1f136012fcd | Python | hidetomo-watanabe/nlp_knock | /41.py | UTF-8 | 1,956 | 2.59375 | 3 | [] | no_license | import my_cabocha
if __name__ == '__main__':
with open('neko.txt.cabocha', 'r') as f:
sentence_num = 0
morphs = []
chunk_obj = None
srcs_dict = {}
for line in f.readlines():
# 文節内容の行
if '\t' in line:
# 文節内容取得
surface, tm... | true |
bb946562b2a5735afbbaf8475e294d8cede3cece | Python | hoshizorahikari/PythonExercise | /LintCode/LintCode-74:第一个错误的代码版本.py | UTF-8 | 2,650 | 4.21875 | 4 | [] | no_license | """
74. 第一个错误的代码版本
代码库的版本号是从 1 到 n 的整数。某一天,有人提交了错误版本的代码,因此造成自身及之后版本的代码在单元测试中均出错。请找出第一个错误的版本号。
你可以通过 isBadVersion 的接口来判断版本号 version 是否在单元测试中出错,具体接口详情和调用方法请见代码的注释部分。
注意:请阅读上述代码,对于不同的语言获取正确的调用 isBadVersion 的方法,比如java的调用方式是SVNRepo.isBadVersion(v)
样例:给出 n=5
调用isBadVersion(3),得到false
调用isBadVersion(5),得到true
调用isBadVersion(... | true |
50c3beeed53e0def9a60bdaa47f82e07944033a1 | Python | waengg/vizdoom_torch | /src/test_main.py | UTF-8 | 1,179 | 2.640625 | 3 | [] | no_license | import torch
from methods.dqn import DQN
from methods.nets.cnn import CNN
import vizdoom as vzd
from collections import deque
import numpy as np
def build_action(a):
return [1 if a == i else 0 for i in range(3)]
def main():
net = CNN(None, 3)
net.load_state_dict(torch.load('/home/gabrielwh/dev/vizdoom_tor... | true |
f4bfa65e474fe592b41a9a57f81562d3382ab3ff | Python | soumasish/leetcodely | /python/reverse_integer.py | UTF-8 | 494 | 3.40625 | 3 | [
"MIT"
] | permissive | """Given a 32-bit signed integer, reverse digits of an integer."""
class Solution(object):
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
if str(x)[0] == '-':
res = -int(str(x)[1:][::-1])
else:
res = int(str(x)[::-1])
if (-1... | true |
23ab08693090ea11f9078f0ef77c3f80c6b6223f | Python | ANTRIKSH-GANJOO/-HACKTOBERFEST2K20 | /Python/selection_sort.py | UTF-8 | 569 | 4.03125 | 4 | [
"Apache-2.0"
] | permissive | def selecsort(lst):
''' It takes a list as input from the user and returns it's sorted version. '''
for i in range(len(lst)):
minpos=i
for j in range(i,len(lst)):
if lst[j]<lst[minpos]:
minpos=j
(lst[i],lst[minpos])=(lst[minpos],lst[i])
return ls... | true |
c74cf81fa9df28bf04f0a9c1fa14fe5c769d282a | Python | chenjinming580/PycharmProjects | /untitled/appium1/songqinapk.py | UTF-8 | 1,757 | 2.5625 | 3 | [] | no_license |
# author:JinMing time:2020-04-15
#导包
from appium import webdriver
#准备自动化配置信息
desired_caps={
#移动设备平台
'platformName':'Android',
#平台OS版本号,写整数位即可
'plathformVersion':'6',
#设备的名称--值可以随便写
'deviceName':'test0106',
#提供被测app的信息-包名,入口信息
# adb shell dumpsys activity recents | findstr intent
... | true |
851d3bc9a28685124a11638fa3cf4c435c4b048c | Python | Dennisjcj/RRT_Dennis | /RRT.py | UTF-8 | 13,961 | 3.09375 | 3 | [] | no_license | '''
Created on Mar 3, 2014
@author: Dennis
'''
#!/usr/bin/env python
# rrt.py
# This program generates a simple rapidly
# exploring random tree (RRT) in a rectangular region.
#
# Written by Steve LaValle
# May 2011
import sys, random, math, pygame
from pygame.locals import *
from math import sqrt,cos,sin,atan2
impor... | true |
4990c15704936a4b78285773cf6b1329fcabeb8a | Python | jareddrayton/ASECP | /plotting/plotter.py | UTF-8 | 6,643 | 2.96875 | 3 | [] | no_license | import csv, math
import matplotlib.pyplot as plt
from matplotlib import animation
def read_all_csv(metric, ff, vowel, color):
scale = 60
for i in range(1,6):
directory = ("vowel-%s-mono.wav Gen 20 Pop 75 Mut 0.15 SD 0.15 %s %s 0%d" % (vowel, ff, metric, i))
with open('%s\\... | true |
0fdb64cc3e1dc5ff5fa2576648e32fc167cc912d | Python | lv0817/mofan_numpy | /fenge.py | UTF-8 | 95 | 2.703125 | 3 | [] | no_license | import numpy as np
A = np.arange(12).reshape(3,4)
print(A)
print(np.split(A,[1,1,2],axis=1)) | true |
92d4db622c6312301cc3c3bc521ea58bd988d699 | Python | nadeldrucker/MLCharGestures | /ml/learning/kaggle_dataset/model.py | UTF-8 | 532 | 2.734375 | 3 | [] | no_license | import pandas
from learning.models import v1
df = pandas.read_csv('../../../datasets/kaggle/dataset.csv').astype('float32')
df = df.sample(frac=1).reset_index(drop=True)
X = df.drop(df.columns[0], axis=1)
y = df['0']
data = X.to_numpy().reshape((len(X)), 28, 28) / 255.
validation_split = 0.75
validation_index = int... | true |
b93e0f6be1debd2a1291a9cc8b7ed754c1558b19 | Python | BellPeppers/Tracking-the-Flu-EOH2016- | /BasicTweetPull.py | UTF-8 | 3,482 | 3.015625 | 3 | [] | no_license | #Import the necessary methods from tweepy library
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
import json, datetime, time
import tweepy
def print_tweets(api, filter, start_date, end_date, region, count):
page = 1
ct = 0
deadend = False
while ... | true |
e2e3f48c22450e8b2fc3897cec449a952901e37d | Python | easulimov/py3_learn | /ex13.py | UTF-8 | 435 | 3.359375 | 3 | [] | no_license | from sys import argv
script, first, second, third= argv
print("Этот сценарий называется: ", script)
print("Моя первая переменная назывется ", first)
print("Моя первая переменная назывется ", second)
print("Моя первая переменная назывется ", third)
new_str=input("Напишите еще что нибудь =) :")
print(new_str) | true |
374b6072cb7b2e0f7ba35017c2d4c700a06af4fb | Python | xpansong/learn-python | /字符串/5. 字符串的判断.py | UTF-8 | 885 | 4.15625 | 4 | [] | no_license | print('----------判断是否为合法标识符--------')
print('hello'.isidentifier())
print('123'.isidentifier())
print('张三'.isidentifier())
print('张三_123'.isidentifier())
print('-----------判断是否全部由空白字符组成(回车、空格、水平制表符)---------')
print('\t'.isspace())
print('-----------判断是否全部由字母组成------------')
print('abc'.isalpha())
print('张三'.isalpha())... | true |
0e1f5b606035eebad64c11cee650c060288746d7 | Python | jamesregis/ibmcloud-python-sdk | /ibmcloud_python_sdk/power/task.py | UTF-8 | 1,610 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | from ibmcloud_python_sdk.config import params
from ibmcloud_python_sdk.utils.common import query_wrapper as qw
from ibmcloud_python_sdk.utils.common import resource_deleted
from ibmcloud_python_sdk.power import get_power_headers as headers
class Task():
def __init__(self):
self.cfg = params()
def ge... | true |
f41f4c5a308e1fa8ba962b80373b580a9f00e6b7 | Python | t-T-s/DBSCAN-apriori-trade-anomaly-detection | /Tests and Attempts/DBSCAN_OutlierDetection.py | UTF-8 | 1,671 | 2.9375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon Sep 16 09:47:01 2019
@author: Thulitha
"""
import numpy as np
import pandas as pd
from pylab import rcParams
import seaborn as sb
import matplotlib.pyplot as plt
import sklearn
from sklearn.cluster import DBSCAN
from collections import Counter
#Setting sta... | true |
78e5ff45a18bcd7dfcafd5424fe834c3f4c83343 | Python | 5l1v3r1/Job-application-bot | /Main/job_bot.py | UTF-8 | 3,339 | 2.6875 | 3 | [] | no_license | from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
impor... | true |
7dcb231fa4a459aa9533de03d17ecc996c8410c9 | Python | ryankavanaugh/SeleniumScripts | /WikiLinks.py | UTF-8 | 2,270 | 3.171875 | 3 | [] | no_license | # Add the link to the list
# Go Through the entire list
# Is it KB? If so, then we are done
# Else
# Call open page func
# This function will open the item on the list in question
# it will then get all the links on that page
# then add those links to the list
# End (repeat... | true |
33d92ffb74204d0358e99449ac40c441caf92d68 | Python | AmalyaSargsyan/HTI-1-Practical-Group-1-Amalya-Sargsyan | /Homework_2/stools.py | UTF-8 | 866 | 3.390625 | 3 | [] | no_license | # Ստեղծել ծրագիր, որի միջոցով օգտագործողը կմուտքագրի իրարից բացատով առանձնացված թվեր,
# որոնք դասարանում աշակերտների հասակներն են։ Աշակերտները, բացի ամենաբարձրահասակներից,
# պետք է կանգնեն տարբեր բարձրության աթոռների վրա այնպես, որ արդյունքում բոլորը լինեն նույն հասակի։
# Ծրագիրը պետք է տպի աթոռների բարձրությունների գո... | true |
6f06f3cbb6bd118f98c0eebe586ca648c5972410 | Python | jeyoon12/django1 | /django1/src/blog/views.py | UTF-8 | 3,839 | 2.640625 | 3 | [] | no_license | from django.shortcuts import render
# 제네릭뷰: 장고에서 제공하는 여러가지 뷰 기능을 구현한 클래스
# ListView: 특정 모델 클래스의 객체 목록을 다루는 기능이 구현된 뷰
# -> 내가 설정한 최대 한 페이지에 보이는 객체 수를 넘어가면 다음 페이지로 넘어감
# DetailView: 특정 모델 클래스의 객체 1개를 다루는 기능이 구현
# FormView: 특정 폼클래스를 다루는 기능이 구현
from django.views.generic.detail import DetailView
from django.view... | true |
e4c1cfd9e4df0cd43d747782c14fef315604db68 | Python | yamarba/algorithmsngames | /mostFrequent.py | UTF-8 | 357 | 3.5 | 4 | [] | no_license |
def most_frequent(list):
count = ()
max_items = None
for i in list:
if i is not in count:
count[i] = 1
else:
count[i] += 1
if count[i] > max_count:
max_count = count[i]
max_item = i
return max_item
print (most_frequent([-1, 3,... | true |
a07ed0a5723675859800e20fa9116f50431b6562 | Python | dand91/personal_http_server | /sql/sql_main.py | UTF-8 | 5,663 | 2.71875 | 3 | [] | no_license | import mysql.connector
import sys
from log import log_main
log = log_main.Log(100, "log/database_log.txt")
class Database(object):
"""
This class serves as a database template
"""
__password = ""
__username = ""
__database = ""
def __init__(self):
self.set_password()
... | true |
4a78e4e8933ae7e7e30cca2edd95374d57befbb9 | Python | frclasso/turma1_Python_Modulo2_2019 | /Cap05_Tkinter/04_checkButton.py | UTF-8 | 379 | 2.75 | 3 | [] | no_license |
from tkinter import *
root = Tk()
root.title("Check Button")
CheckVar1 = IntVar()
CheckVar2 = IntVar()
C1 = Checkbutton(root, text='Music', variable=CheckVar1, onvalue=1,
offvalue=0, height=5,width=20)
C2 = Checkbutton(root, text='Video', variable=CheckVar2, onvalue=1,
offvalue=0... | true |
49bb91e7fdc6669ea9b02c622af83377796b9f04 | Python | YunjinJo/PythonProject1 | /Day4/list0102_1.py | UTF-8 | 612 | 3.71875 | 4 | [] | no_license | import tkinter
import datetime #컴퓨터 시간을 사용하기 위한 모듈 임포트
def time_now():
d = datetime.datetime.now() #컴퓨터의 현재 시간을 가져온다.
t = '{0}:{1}:{2}'.format(d.hour, d.minute, d.second) #중괄호 0이 d.hour와 연결, 중괄호 1이 d.minute과 연결 중괄호 2가 d.second와 연결
label['text'] = t
root.after(1000, time_now) #1000ms 후에 time_now 함수를... | true |
d8deb8d1d65893b23e1b9fff9861e88b179e50c5 | Python | nkyriako/clustering | /practice/ml_practice_2.py | UTF-8 | 803 | 3.4375 | 3 | [] | no_license | import numpy as np
from sklearn.datasets import load_iris
from sklearn import tree
iris = load_iris()
#features are sepal and petal measurements
print(iris.feature_names)
#targets are what we want classified, setosa, versicolor, virginica
print(iris.target_names)
test_idx = [0, 50, 100]
#Training data
train_target = ... | true |
a2f3d0151f968f3e8047a93a0f969c7c10b2965a | Python | yoyoraso/Python_3 | /problem3_lab3.py | UTF-8 | 220 | 3.28125 | 3 | [] | no_license | def check(element,tup):
if element in tup:
print(True)
else:
print(False)
return (element,tup)
tupler = ("w", 3, "r", "e", "s", "o", "u", "r", "c", "e")
z = check('w',tupler)
print(z) | true |
a90994bde7ff0f67a1a39480aa6556c054a6e29f | Python | shiraWeiss/NYC-MLProject | /Data/Crime/Crimes.py | UTF-8 | 1,681 | 3.09375 | 3 | [] | no_license | # use 'pip install uszipcode' to install library
from uszipcode import ZipcodeSearchEngine as zipcode
import pandas as pd
from Data.ExtractionUtils import colToInt, TEST_LINES, selectCols, DATASETS_PATH
class Crimes:
X_COORD = 'Latitude'
Y_COORD = 'Longitude'
def __init__(self):
try:
... | true |
b499636ac68ce6c5d369b3572a8053c9dc5f7301 | Python | DenisScar/URI-BEECROWD-PYTHON | /URI_1004.py | UTF-8 | 112 | 2.8125 | 3 | [] | no_license | #!/usr/bin/python3
#-*-coding:UTF-8-*-
A=int(input())
B=int(input())
PROD=(A*B)
print('PROD = {}'.format(PROD))
| true |
d7722909d33665d0020d6d3b9ec2cb6995dd3e3c | Python | DavidCorrea/UNQ-SO-2014 | /scheduling/Scheduler.py | UTF-8 | 2,341 | 3.03125 | 3 | [] | no_license | from Queue import PriorityQueue
class Scheduler:
def __init__(self):
self._policy = None
self._quantum = None
def set_as_fifo(self):
self._policy = FifoScheduler()
self._quantum = -1
def set_as_pq(self):
self._policy = PriorityScheduler()
self._quantum = ... | true |
5b3c05eed2618957c80de89c74b88d574bef7fd8 | Python | yuna1880/Python | /code03-04.py | UTF-8 | 501 | 4.4375 | 4 | [] | no_license | print(2 ** 3)
print(pow(2,3))
print(100 ** 100)
print(9 // 2) # 몫 구하기
print(9 % 2) # 나머지 구하기
print(3.14E5)
# 16/8/2 진수를 10진수로 변환!
print(0xFF, 0o77, 0b1111)
print(hex(255), oct(63), bin(15)) # 10진수를 다른 진수로 변환
print()
a = (100 == 100)
print(a)
b = "파이썬\n만세"
print(b)
# 곁따옴표 """는 화면에 보이는 그대로 출력해준다.
b... | true |
aaf8d656464daeda175f99355f52021ff0870d95 | Python | otherness/6.00.1x | /pset1/[p1]-counting-vowels.py | UTF-8 | 169 | 3.484375 | 3 | [] | no_license | s = "aabbcciddee"
vowels = ("a","e","i","o","u")
vowels_cntr = 0
for i in s:
if i in vowels:
vowels_cntr+=1
print ("Number of vowels: " + str(vowels_cntr)) | true |
35d4f08d1fda57fb7a893ff69ce9b57624f93159 | Python | Slimmerd/COMP1811-Python-CW | /administrator_features/tools/window_size.py | UTF-8 | 325 | 3.28125 | 3 | [] | no_license | def center_window_on_screen(width, height, screenwidth, screenheight, chosen_window):
# Centres windows and makes appropriate windows size
x_cord = int((screenwidth / 2) - (width / 2))
y_cord = int((screenheight / 2) - (height / 2))
chosen_window.geometry("{}x{}+{}+{}".format(width, height, x_cord, y_co... | true |
6233b6693ede705423444d09fa4cc3890ed04f30 | Python | RecluseXU/learning_spider | /example/0_Basic_usage_of_the_library/python_pyenchant/2_user_dictionary.py | UTF-8 | 1,316 | 3.296875 | 3 | [
"MIT"
] | permissive | # -*- encoding: utf-8 -*-
'''
@Time : 2022-09-01
@Author : EvilRecluse
@Contact : https://github.com/RecluseXU
@Desc : 自定义字典
add(): store an unrecognised word in the user’s personal dictionary so that it is recognised as correct in the future.
remove(): store a recognised word in the user’s personal exc... | true |
ba29cc49cfd5e97480c9dbecb9135af595786695 | Python | dujiaojingyu/Personal-programming-exercises | /编程/4月/4.13/name_function.py | UTF-8 | 435 | 2.9375 | 3 | [] | no_license | __author__ = "Narwhale"
# def get_formatted_name(first,last):
# '''合并姓名'''
# full_name = first + ' ' + last
# return full_name.title()
#
#------------------------------------------------------
def get_formatted_name(first,last,moddle=''):
'''合并姓名'''
if moddle:
full_name = first + ' ' ... | true |
79a57437b10f162cccbafd2a8c2eb787ebdf1654 | Python | coffee-coded/quick_sort | /main.py | UTF-8 | 2,090 | 3.828125 | 4 | [] | no_license |
def quick_sort(array_unsorted):
if len(array_unsorted) == 1 or len(array_unsorted) == 0:
return array_unsorted
pivot: object = array_unsorted[0]
left = array_unsorted[1]
l_k = 1
right = array_unsorted[-1]
r_k = len(array_unsorted) - 1
while l_k != r_k:
if not right < pivot:
... | true |
c40494f3cc46d3abd9e92ee1b6014dc73c271b38 | Python | HanbumKo/AmazingAmase | /amase/TCPClient.py | UTF-8 | 3,291 | 2.59375 | 3 | [] | no_license | import socket
from lmcp import LMCPFactory
## ===============================================================================
## Authors: Abe Stoker
## University of Dayton Research Institute Applied Sensing Division
##
## Copyright (c) 2018 Government of the United State of America, as represented by
## the Secretary... | true |
8a2224cba2ffc3c1c9b008f9d1b05cb82e640968 | Python | Jadro007/EventParser | /src/finder/PriceFinder.py | UTF-8 | 1,830 | 3.078125 | 3 | [] | no_license | import re
from typing import Optional
from bs4 import BeautifulSoup
from src.dto.PriceRange import PriceRange
from src.dto.Price import Price
from src.utils.Utils import Utils
class PriceFinder:
regex_for_price = None
@staticmethod
def find(soup) -> Optional[PriceRange]:
if PriceFinder.regex_... | true |
496731927ac6929fa87e1c91254ed6f398b56b9b | Python | MahalakshmiAnandan/python-basics | /hill pattern.py | UTF-8 | 143 | 3.15625 | 3 | [] | no_license | n=int(input())
for r in range(1,n+1):
for i in range(1,r+1):
print('*',end='')
for spc in range(r+1,n+1):
print(" ",end='')
print()
| true |
4b860d4d6907efb665ce1ed3bf2c5e19bb33c2e6 | Python | frankyangkun/Test0402 | /case/test_database.py | UTF-8 | 730 | 2.984375 | 3 | [] | no_license | # -*- coding:utf8 -*-
"""
目标:自动化测试中操作项目数据库
案例:判断用户id1是否收藏了id为2的文章 1-为收藏 0-收藏
"""
#导包 pymysql需要安装
import pymysql
#获取连接对象
conn = pymysql.connect("127.0.0.1","root","123456","hmtt",charset="utf8")
#获取游标对象 所有的操作都在游标对象里
cursor = conn.cursor()
#执行方法sql
sql = "select is_deleted from news_collection where user_id=1 and article... | true |
b34d8e8e0f9cf46cd69d038a37cbe310ff58f068 | Python | ShayHa/CodingInterviewSolution | /python/7_Find_Median.py | UTF-8 | 314 | 3.484375 | 3 | [
"MIT"
] | permissive | """
Find the median of a given list with integers
"""
# If we can't use imports
def find_median(ls):
ls = sorted(ls)
l = len(ls)
if l % 2 ==0:
return (ls[l//2-1]+ls[l//2])/2
return ls[l//2]
# If we can import
def find_median_v2(ls):
import statistics
return statistics.median(ls)
| true |
7c356174bfe9e1f33779f09b81f3fa4653b20fc1 | Python | LorisMarini/synology | /code/execute.py | UTF-8 | 2,956 | 2.703125 | 3 | [] | no_license | from imports import *
from helpers import *
# Get the directory of this file
here = pathlib.Path(__file__).parent.absolute()
# FInd plans directory
plans_dir = here.parent / "_plans"
def execute(*, df:pd.DataFrame, mode:str, replace:str):
print(f"\nExecuting...")
# Create destination directories if they do... | true |
353f395247d1eb2e1f1a246dda53ca57bf39329d | Python | Index197511/AtCoder_with_Python | /AGC15_A.py | UTF-8 | 107 | 2.96875 | 3 | [] | no_license | n,a,b=map(int,input().split())
if ((b-a)*(n-2)+1)>0:
print(int((b-a)*(n-2)+1))
else:
print(0)
| true |
ca0e900903c5f3564c78ff27178000a265ce9be2 | Python | bhargavaurala/LMDBWrapper | /LMDBWrapper.py | UTF-8 | 1,695 | 2.625 | 3 | [] | no_license | import lmdb
class LMDBWrapperBase(object):
def __init__(self, lmdb_name, init_sample_estimate = 1000, sample_size = 64):
self.lmdb_name = lmdb_name
self.init_sample_estimate = init_sample_estimate
self.sample_size = sample_size
self.env = lmdb.open(lmdb_name, map_size = init_sample_estimate * sample_size)... | true |
570a3c107bb530d5376679b6dbe7d071d7475652 | Python | susami-jpg/atcoder_solved_probrem | /Staircase_Sequences.py | UTF-8 | 668 | 3.65625 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sat May 29 17:03:22 2021
@author: kazuk
"""
n = int(input())
def make_divisors(n):
lower_divisors , upper_divisors = [], []
i = 1
while i*i <= n:
if n % i == 0:
lower_divisors.append(i)
if i != n // i:
... | true |
2b5828463122b09b08abbfbcbf81e1895f5491db | Python | jwaldroup/gracefo_gw_search | /match_filter/waveform_non_pycbc_test.py | UTF-8 | 2,374 | 2.6875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu Oct 15 15:04:17 2020
version 10/22/20 5:54pm
@author: john
"""
import numpy as np
import matplotlib.pyplot as plt
#import q_c_orbit_waveform_gen_functions as q_c_apx
import q_c_orbit_waveform_py2 as q_c_py2
import zero_finder
#binary system parameters
m1 = 100.0 #solar mass... | true |