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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
60e1e3932d0be07220bec0e12a14ef868cd423b2 | Python | chaofan-zheng/python_leanring_code | /month01/面向对象/2048自己的版本.py | UTF-8 | 5,098 | 3.765625 | 4 | [
"Apache-2.0"
] | permissive | """
(选做)面向过程 2048游戏核心算法
list_merge = [2,0,0,2]
(1). 定义函数,零元素移动到末尾
[2,0,0,2] --> [2,2,0,0]
[2,0,2,0] --> [2,2,0,0]
[2,0,4,2] --> [2,4,2,0]
(2). 定义函数,相邻相同数字合并
[2,0,0,2]-调用函数1->[2,2,0,0]->[4,0,0,0]
[2,0,2,0]-调用函数1->[2,2,0,0]->[4,0,0,0]
[8,8,8,8] --> [16,16,0,0]
... | true |
ca16806905ed8e3d5fc424b341bd20335c475d04 | Python | PierreSavatte/tetris | /tests/component/test_cell.py | UTF-8 | 2,782 | 3.265625 | 3 | [
"MIT"
] | permissive | from unittest.mock import patch
import pytest
from tetris.components.board import Board
from tetris.components.cell import Cell, CanNotMove
from tetris.constants import RECT_SIZE
def test_cell_is_init_correctly():
c = Cell(position=(3, 4), color=(0, 0, 0))
assert c.position == (3, 4)
assert c.color == ... | true |
2585ec5b44ad5e3d58c1da8187766dad9f0b5103 | Python | emmerkhofer/sts_tfidf | /lab.py | UTF-8 | 2,621 | 3.265625 | 3 | [] | no_license | # coding: utf-8
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity
import numpy as np
from scipy.stats import pearsonr
from nltk.stem import PorterStemmer
from nltk.tokenize import word_tokenize
from nltk.corpus import stopwords
import string
def load_st... | true |
1a0d67f5a9c2e762fce3caec355bd5774a36e560 | Python | KirillGu/AnimalSong | /song.py | UTF-8 | 1,258 | 3.28125 | 3 | [] | no_license | class Album:
def __init__(self,name, group):
self.name = name
self.group = group
self.track = []
def add_track (self, track):
self.track.append(track)
def get_tracks (self):
for item in self.track:
print(f' Песня:{item.name} , идет: {item.time}минут')... | true |
4e7c0b6a71c51635ccaafc83a79ca80704bae252 | Python | varunswarup0/HackerRank_Solutions | /automation/scrape_info/webpage_info.py | UTF-8 | 4,400 | 2.96875 | 3 | [
"Apache-2.0"
] | permissive | """
Open firefox driver and scape WebPageInfo.
"""
##########
# Imports
##########
import time
from typing import Tuple
import constants
from logger.scrape_info import logging
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
##########
# Driver
##########... | true |
c063438a7ffb6c0ca719b6a8c2bd8fd619bc7558 | Python | shenjiazhuang/jrxy_portfolio_management | /Code/portfolio_ini.py | UTF-8 | 5,308 | 2.890625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 5 02:15:33 2020
@author: Ni He
"""
import data_process
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams['axes.unicode_minus']=False
def get_stock_data(start_date, end_date, num_assets):
return data_process.random_stocks_return... | true |
4a889d9bf09b9eaf3573dea7b44061baf5564158 | Python | ImTehCookie/Vinny | /take2.py | UTF-8 | 3,356 | 2.84375 | 3 | [] | no_license | #Left off here(watch it):
#https://www.youtube.com/watch?v=vQw8cFfZPx0
#Gets Bot Token
from os import environ
token = environ.get('vinny_token')
import discord
from discord.ext import commands
from discord.ext import tasks
from itertools import cycle
import random #for 8ball
intents = discord.Intents(messages = Tr... | true |
8793b255b14e4efbd0da4458e566e07c1b5bc9c8 | Python | codyshepherd/advent_of_code_2019 | /5.py | UTF-8 | 4,633 | 3.25 | 3 | [] | no_license | '''
Advent of Code 2019
Cody Shepherd
Day 5, Parts 1 & 2
Part 1 Solution:
Essentially we have a virtual machine which maniuplates state, using global
state and a global instruction pointer.
I found it easiest to use a class to provide an abstraction for the instruction
which lets us give names to its parts instead ... | true |
33fadd2461c5ea7209dec4ac6eb66a1163b5b634 | Python | hhldiniz/pooptbank | /views/Historico.py | UTF-8 | 992 | 2.875 | 3 | [] | no_license | from views.SubWindow import SubWindow
from Transacao import Transacao
class HistoricoView(SubWindow):
def __init__(self, app, title):
SubWindow.__init__(self, app, title)
SubWindow.set_size(self, "500x400")
SubWindow.add_label(self, "Historico de Transacoes")
# so vai aprecer se u... | true |
0e562fc6a749e5c83b373749e411ea4bdcfe805c | Python | sgammon/fatcatmap | /fatcatmap/models/geo.py | UTF-8 | 731 | 2.578125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
'''
fcm: geo models
'''
# graph models
from . import (Model,
describe)
@describe(descriptor=True)
class Geopoint(Model):
''' Describes a single point on the globe, identified by a longitude/
latitude pair and an optional altitude. '''
latitude = float, {'indexe... | true |
12f7f3ab17e1083454c11931e0c13ba326b94290 | Python | Igor31415/BitRepublicHardware | /Tools.py | UTF-8 | 3,197 | 3.171875 | 3 | [] | no_license | import requests #Allow to send requests to the server (.get/.post/...)
import hashlib #Allow to hash the password via sha256 method
import socket #Allow the script to get ... | true |
f697e844fb60fae66aaadb4c4806e5d83e4f34b0 | Python | KristerSJakobsson/japanese-data-extractor | /scripts/download_wikipedia_pages.py | UTF-8 | 2,460 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"BSL-1.0"
] | permissive | #!/usr/bin/python
import sys
from typing import List, Any, Tuple
from getopt import getopt, GetoptError
from src.utils.io_utils import create_directory_if_not_exists
def _parse_parameters_and_arguments(argv: List[str]) -> Tuple[List[str], str]:
try:
extracted_options, extracted_arguments = getopt(argv, ... | true |
0611e52b1d35e6094cb7ffb0cda4133f37944043 | Python | agree9999/Klang | /Klang/talib_api.py | UTF-8 | 1,230 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | #
# Ta-lib
#
import talib
import numpy as np
from .Kdatas import KdataBase
def MA(X,N):
ret = KdataBase()
ret._data = talib.MA(X.data,N)
return ret
def ABS(X):
ret = KdataBase()
if isinstance(X,KdataBase):
data = X.data
else:
data = X
ret._data = np.abs(data)
return re... | true |
dbb5a025db27db26f42eff878bd6dc77b12eb975 | Python | amireh/grind | /keepers/kyoto/keeper.py | UTF-8 | 892 | 2.890625 | 3 | [
"MIT"
] | permissive | from kyotocabinet import *
import sys
# create the database object
db = DB()
# open the database
if not db.open("casket.kch", DB.OWRITER | DB.OCREATE):
print("open error: " + str(db.error()), file=sys.stderr)
# # store records
# if not db.set("foo", "hop") or not db.set("bar", "step") or not db.s... | true |
685e109b74acbbc16f3b2af8e48ad202ee429900 | Python | SimonCK666/pythonBasic | /python_6hours/PythonGrammer/Dictionary.py | UTF-8 | 648 | 4.09375 | 4 | [] | no_license | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Dictionary is to storage the key/values
customer = {
"name": "John Smith",
"age ": 30,
"is_verified": True
}
print(customer["name"])
print(customer.get("birthday", "Jan 1 2000"))
print('-------------------------------')
# Face and Feeling
message = input('>... | true |
89e2c9235b5194ee6afbe88bbe5c22808c21abc6 | Python | L1nwatch/leetcode-python | /1051.高度检查器.py | UTF-8 | 392 | 2.71875 | 3 | [] | no_license | #
# @lc app=leetcode.cn id=1051 lang=python3
#
# [1051] 高度检查器
#
# @lc code=start
class Solution:
def heightChecker(self, heights: List[int]) -> int:
answer = 0
right_heights = sorted(heights)
for height,right_height in zip(heights,right_heights):
if height != right_height:
... | true |
58f1da2975387703ecae8844e8d03f7a94cdf748 | Python | ClinicalGenomicsGBG/PARCA | /parca/workflows/scripts/blast_processing/blast_preprocessing/create_sliceblast_input.py | UTF-8 | 2,334 | 3.03125 | 3 | [] | no_license | # Script for extracting reads with the same taxonomic id from a fasta file and write to files called after the taxonomic id the reads are classed to in chunks of a specified size, e.g. "taxid__chunk".
# Author: Pernilla Ericsson (pernilla.ericsson@gu.se)
# Date: 2020-05-06
"""
Input:
classed_path = File with read... | true |
313866a8888d704cb6ade531a40af63515d2197c | Python | isabellecarson/teambolt473 | /GenerateTrials/generate_trials.py | UTF-8 | 4,460 | 2.59375 | 3 | [] | no_license | #!python3
import paths
import generate_wolf
import generate_csv
import sys
import random
import csv
sphero0 = paths.generate_set([0,0], 750, 60, 60, 72)
sphero1 = paths.generate_set([0,0], 750, 60, 60, 72)
sphero2 = paths.generate_set([0,0], 750, 60, 60, 72)
sphero3 = paths.generate_set([0,0], 750, 60, 60, 72)
spher... | true |
783625f9f5c8bc48e627472a198762fc93e35650 | Python | Unstable-Robert/Tank-Rover | /PythonController/main.py | UTF-8 | 861 | 2.6875 | 3 | [] | no_license | # This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
from tkinter import *
from time import sleep
import socket
from ControllerThread import ControllerThread
# creating window
... | true |
65713a5c58a8473ebd95b193864d225969bcade5 | Python | uohzxela/fundamentals | /arrays/alternate_pos_neg.py | UTF-8 | 906 | 3.59375 | 4 | [] | no_license | def alternate(A):
negIndex = posIndex = 0
for i in xrange(len(A)):
if i % 2 == 0 and A[i] >= 0:
negIndex = findNegIndex(A, i+1)
if negIndex >= len(A): return A
neg = A[negIndex]
rotate(A, i, negIndex-1)
A[i] = neg
elif i%2 == 1 and A[i]... | true |
24542fb16f6f48d1af414b0734889f46042fd824 | Python | ab5424/Polypy | /polypy/tests/test_utils.py | UTF-8 | 1,804 | 2.8125 | 3 | [
"MIT"
] | permissive | import unittest
import numpy as np
from polypy import utils as ut
from numpy.testing import assert_almost_equal
class TestUtils(unittest.TestCase):
def test_pbc_1(self):
a, b = ut.pbc(0.5, 0.6)
c, d = ut.pbc(0.1, 0.9)
expected_a = False
expected_c = True
assert a == expect... | true |
417a9cc893e4b3acffec03b4840b51ea604811ba | Python | hanna-becker/CarND-Capstone | /ros/src/tl_detector/light_classification/sample_generator.py | UTF-8 | 2,912 | 3.234375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
import csv
import cv2
import numpy as np
from keras.preprocessing.image import ImageDataGenerator
from keras.utils.np_utils import to_categorical
from sklearn.model_selection import train_test_split
NUM_CLASSES = 4
def read_from_log_file(file_name):
samples = []
with open(file_name) a... | true |
1bb68d5cd236b3c0c981bae24b4137958b964aa1 | Python | f0rk/csv2html | /csv2html | UTF-8 | 1,298 | 2.8125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
import sys
import csv
import cgi
import argparse
# without this, we may encounter fields larger than can be read
csv.field_size_limit(sys.maxsize)
parser = argparse.ArgumentParser()
parser.add_argument("files", help="path to CSVs, default stdin", nargs="*")
args = parser.parse_args()
files =... | true |
8f976f8e8eab602c882e7d85f66b28071e28ec73 | Python | Potatology/coding | /array/maxCandies.py | UTF-8 | 329 | 2.8125 | 3 | [] | no_license | class Solution:
def kidsWithCandies(self, candies: List[int], extraCandies: int) -> List[bool]:
mc = 0
for c in candies:
mc = max(mc, c)
res = [False]*len(candies)
for i in range(0, len(candies)):
res[i] = mc <= candies[i] + extraCandies
return res
... | true |
a0605e04d6e4aacc1e23e8ee018b103f7d08fd5c | Python | noonhub/python_oauth_client | /oauth_client.py | UTF-8 | 2,626 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env python
from argparse import ArgumentParser
import json
from os import path
import time
import urllib
import webbrowser
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from threading import Thread
from urlparse import urlparse, parse_qs
import requests
config = None
provider = 'uber'
class... | true |
406feefbd506fff69d0abee59a283d1f90f2f42d | Python | vineet2508/My-Audiobook | /Audiobook.py | UTF-8 | 841 | 3.296875 | 3 | [] | no_license | #Importing the libraries
#You need to install both of these modules using pip command
import pyttsx3
import PyPDF2
#book=open('.....file_path\\Filename.pdf','rb')
book=open('Audiobook Sample.pdf','rb')
pdfReader=PyPDF2.PdfFileReader(book)
pages=pdfReader.numPages
print("Total no. of Pages inside PDF:"+ str(page... | true |
9885cd5ea0d8e5efae289fccd26c9146c1a4829b | Python | moon0walker/musicbox | /frame/banner.py | UTF-8 | 1,169 | 2.671875 | 3 | [] | no_license | import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GdkPixbuf
from os.path import exists
MG = (1024, 768)
class Banner(Gtk.Frame):
def __init__(self, mon_width, mon_height):
Gtk.Frame.__init__(self)
global MG
MG = (mon_width, mon_height)
self.set_vexpand(True)... | true |
75bde5577608e90c0177c2aa5ba7b1154529ba67 | Python | boazvdv/CCG-Thesis | /Environment/Env_ML.py | UTF-8 | 1,645 | 2.75 | 3 | [] | no_license | from .Env import Environment
import pandas as pd
import numpy as np
class Environment_ML(Environment):
def __init__(self, C, S, gamma_percent, inst_num=0, predictors={}, model=''):
Environment.__init__(self, C, S, gamma_percent, inst_num)
self.predictors = predictors
self.active_set = []
... | true |
9148ec4f03e1162f04a0b0dd6fb6532ff3ca7b06 | Python | Hunt092/financeStatementToCSV | /Main.py | UTF-8 | 2,281 | 3.109375 | 3 | [] | no_license | from tabula import read_pdf
from tabula import convert_into
import pandas as pd
import os
# Makes a list of files present in PDfs folder (give the name of folder
# you have your pdfs in)
try:
filenames = os.listdir('Pdfs')
except:
print("Give a Valid folder")
# The accuracy depends upon the API[tabula] to
... | true |
b5fbbd9448f19ed9a4c321c953b9d4c993463de1 | Python | esousa77/collective-intelligence-book | /workbook/chapter8/optimization.py | UTF-8 | 5,939 | 3.078125 | 3 | [] | no_license | import time
import random
import math
people = [('Seymour', 'BOS'),
('Franny', 'DAL'),
('Zooey', 'CAK'),
('Walt', 'MIA'),
('Buddy', 'ORD'),
('Les', 'OMA')]
destination = 'LGA'
def get_minutes(t):
x = time.strptime(t, '%H:%M')
return x[3] * 60 + x[4]
def print_schedule(r):
for d in range(0, le... | true |
b8c4bb80ad6932513cd8b31482327d6a7feb65b5 | Python | Eatzhy/long-term-tracking-benchmark | /python/oxuva/assess.py | UTF-8 | 20,966 | 3.03125 | 3 | [] | no_license | '''
Examples:
To evaluate the prediction of a tracker for one tracking task:
assessment = assess.assess_sequence(task.labels, prediction, iou_threshold=0.5)
The function assess_sequence() calls subset_using_previous_if_missing() internally.
This function may alternatively be called before assess_... | true |
d7437408ae6acb9ac3ea73653d41d57c52f40791 | Python | je55ek/wedding | /wedding/general/functional/tuple.py | UTF-8 | 166 | 2.875 | 3 | [] | no_license | from typing import Tuple, TypeVar
A = TypeVar('A')
B = TypeVar('B')
def fst(t: Tuple[A, B]) -> A:
return t[0]
def snd(t: Tuple[A, B]) -> B:
return t[1]
| true |
c65f0eed395a345a945602f37b5bea669323d373 | Python | umangbhatia786/PythonPractise | /GeeksForGeeks/List/get_even_numbers.py | UTF-8 | 269 | 4.03125 | 4 | [] | no_license | #To get all even numbers from a list
def get_even_numbers(int_list):
'''To return list of all even numbers inside a list'''
return [num for num in int_list if num %2 == 0]
my_list = [1,2,3,4,5,6,7,8,9,10]
for num in get_even_numbers(my_list):
print(num)
| true |
8c7d1471014d8fac9c7f67e40ec29d7b020c4110 | Python | namyangil/edu | /모두의 라즈베리파이/chap3/3.9/tk_PIL_01.py | UTF-8 | 536 | 3.234375 | 3 | [] | no_license | # coding: utf-8
# Tkinter 라이브러리 임포트
import tkinter as tk # Python3
#import Tkinter as tk # Python2
# PIL 임포트
from PIL import Image, ImageTk
# Tk 객체 인스턴스 작성
root = tk.Tk()
# 이미지 파일 열기
image = Image.open('photo.png')
# PhotoImage 호환 이미지 객체로 변환
im = ImageTk.PhotoImage(image)
# root에 표시할 라벨 정의
label = tk.Label(root, ... | true |
6058a965d71711c64c5c3e7f2384ef87e51286c4 | Python | egghurt/z7z8 | /python/books.py | UTF-8 | 1,591 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | # -*-coding:utf8-*-
import requests
import bs4
import os
import os.path
import sys
import urllib
import unicodedata
import pyprind
address = 'http://www.lidown.com/'
code = {u'\u2022':u'·', u'\xbd':u'1/2', u'\u30fb':u'·', u'\xf6':u'o', u'\xf1':u'n', u'\u0469':u'', u'\u02a8':u'雪狮'}
directory = 'D:\\books\\Kindle'
de... | true |
8bf089c5dfa170580bfdb913136dca3195ffc5eb | Python | valerioMolinari/Elite | /Valerio/Python/corso_python_bemporad/Sequenze/liste.py | UTF-8 | 565 | 4.1875 | 4 | [] | no_license | # Una lista è una sequenza di tipi mutabili, il tipo è type = list
myList = [] # lista vuota
myList = list() # lista vuota con costruttore
myLst = [10, 20, 30] # lista non vuota
myList[1] # 20
myList[-1] # 30
myList.insert(2, 50) # [10, 20, 50, 30]
myList.append(60) # [10, 20, 50, 30, 60]
del myList[1] # [10, 50, 30... | true |
e0cccc1334bc44464251dafc598eb39d57c9ca43 | Python | mrpeerat/SEFR_CUT | /sefr_cut/deepcut/utils.py | UTF-8 | 3,620 | 2.8125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# encoding: utf-8
import numpy as np
CHAR_TYPE = {
u'กขฃคฆงจชซญฎฏฐฑฒณดตถทธนบปพฟภมยรลวศษสฬอ': 'c',
u'ฅฉผฟฌหฮ': 'n',
u'ะาำิีืึุู': 'v', # า ะ ำ ิ ี ึ ื ั ู ุ
u'เแโใไ': 'w',
u'่้๊๋': 't', # วรรณยุกต์ ่ ้ ๊ ๋
u'์ๆฯ.': 's', # ์ ๆ ฯ .
u'0123456789๑๒๓๔๕๖๗๘๙': 'd',
u'"'... | true |
21ccbffec25d4636b32ebbdc9d3eca6b70f89bab | Python | antoniosarosi/algoritmia | /src/demos/greedy/prim1.py | UTF-8 | 677 | 2.84375 | 3 | [
"MIT"
] | permissive | #coding: latin1
#< full
from algoritmia.datastructures.digraphs import UndirectedGraph, WeightingFunction
from algoritmia.problems.spanningtrees import PrimsMinimumSpanningFinder
d = WeightingFunction({(0,1): 0, (0,2): 15, (0,3): 2, (1,3): 3, (1,4): 13, (2,3): 11,
(2,5): 4, (3,4): 5, (3,... | true |
fb27c9dcdd5dc6971ca64cb264fdfa770161ea24 | Python | simonrw/network-checker | /networkcheck/runs_ping.py | UTF-8 | 2,878 | 2.546875 | 3 | [] | no_license | import subprocess as sp
import re
from .types import PingSummary, PingResult, SummaryResult
from .logging import logger
DATA_TRANSMISSION_RE = re.compile(
r"""^(?P<nbytes>\d+)\s+ # number of bytes
bytes\s+from\s+
(?P<ip_addr>(\d{1,3}\.){3}\d{1,3}):\s+
i... | true |
53daa4a6f7bb6d46044ddee9a5312032a093cae5 | Python | TheRoyalTnetennba/coding_challenges | /project_euler/python/problem23.py | UTF-8 | 819 | 3.625 | 4 | [] | no_license | def is_abundant(n):
i = 2
upper = n
sum_divs = 1
while i < upper:
if n % i == 0:
upper = n / i
sum_divs += upper
if upper != i:
sum_divs += i
i += 1
return sum_divs > n
def non_abundant_sum():
abundant_nums = [i... | true |
fc1fb2ab729d3ae6644852b501cf29679ce6d17e | Python | JingkaiTang/github-play | /use_good_fact_into_able_thing/see_big_company_beneath_bad_time.py | UTF-8 | 254 | 2.703125 | 3 | [] | no_license |
#! /usr/bin/env python
def public_year_or_long_number(str_arg):
great_number(str_arg)
print('own_number_or_public_company')
def great_number(str_arg):
print(str_arg)
if __name__ == '__main__':
public_year_or_long_number('large_year')
| true |
359b4bc773686aa458e74aa14c3b157523f7ac0e | Python | jxiaof/360 | /360.py | UTF-8 | 3,735 | 2.640625 | 3 | [] | no_license | """
2020年9月26日 360 kafka 数据转换问题
思路: 设置和cpu相同数量进程池(4)并行,同时使用线程池(125)消费,转换数据,最大效率使用cpu.
"""
import concurrent.futures
import copy
import json
import multiprocessing
import time
CPU_NUM = multiprocessing.cpu_count()
PLATFORM_MAPPING = {
'': {
"os": "UNKNOWN",
"platfor... | true |
d23643833aefee175db40236b1b797be80402054 | Python | faturita/CheeatahBot | /NeoCortex/motor/MotorCortex.py | UTF-8 | 965 | 3.078125 | 3 | [] | no_license | import serial
class MotorCortex:
def __init__(self, *, connection, speed = 120):
# TODO: not used now. To be done
self.connection = connection
self.speed = speed
def stop(self):
self.connection.send(b'A3010')
self.connection.send(b'A3000')
self.connection.send(... | true |
508cc86e916483416b5692fbd34bce1fdabdfda6 | Python | blegloannec/CodeProblems | /CodeJam/20/20.1A.B.Pascal_Walk.py | UTF-8 | 1,022 | 3.3125 | 3 | [] | no_license | #!/usr/bin/env python3
def sqrt_walk(N):
assert N>0
N -= 1
W = [(1,1)]
k = 1
while N>=k: # second column
W.append((k+1,2))
N -= k
k += 1
while N>0: # first column
W.append((k,1))
N -= 1
k += 1
return W
def log_walk(N):
assert N>30
M... | true |
fa5f6acd720d0837dbc23713790d562bc10288c6 | Python | marble-git/python-laoqi | /docs/chap6/code/singleton.py | UTF-8 | 782 | 3.515625 | 4 | [
"MIT"
] | permissive | #coding:utf-8
'''
filename:singleton.py
singleton type by rewriting __new__
'''
class Singleton:
__instance = None
def __new__(cls,*args,**kwargs):
if not cls.__instance:
cls.__instance = super().__new__(cls)
print('create instance :',cls.__instance)
return cls... | true |
492b7c9514839fd3b293cbd27ab6d8deaf0531b7 | Python | q2806060/python-note | /day04/day04/code/while.py | UTF-8 | 226 | 4.15625 | 4 | [] | no_license | # while.py
# 打印 20 行 hello!
i = 1 # 此变量用来控制循环条件
while i <= 20:
print('hello!')
i += 1 # 增大循环变量,让它逼近终止点20
else:
print("else子句被执行!,此时i=", i)
| true |
572ad2396bde8e73fe7a0da1d958faef49ee1098 | Python | lucasgr7/GoTransa | /begin.py | UTF-8 | 2,436 | 2.640625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import sys
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
import time
from gochatbot import GoChatBot
reload(sys)
sys.setdefaultencoding('utf-8')
#reload(sys)
#sys.setdefaultencoding('u... | true |
d15b6103246d129560d7aa6a950d061b0e83875a | Python | HarshParmar346/MyCaptainPython | /CicleArea.py | UTF-8 | 104 | 3.875 | 4 | [] | no_license | import math
r = float(input("Enter Radius of Circle"))
area = math.pi * r
print("Area is ", area)
| true |
b4e828f41f982a2e6ac87ec0423476713bdee098 | Python | louis-bompart/snapshot-automated-deployment | /deploy.py | UTF-8 | 853 | 2.6875 | 3 | [] | no_license | import json
import requests
import sys
"""
This script expects the following command line parameters:
- Coveo organization ID
- API key
- GitHub repository name
"""
org_id = sys.argv[1]
api_key = sys.argv[2]
repo_name = sys.argv[3]
print(f"Running deployment script with org ID: {org_id} and repo name: {repo_nam... | true |
d8b064afd0cad389b669d65e83f994cb1ff49d39 | Python | shuoshuren/PythonDataStructure | /排序算法/02_select_sort.py | UTF-8 | 387 | 3.546875 | 4 | [] | no_license | #!/usr/bin/python
# coding:utf-8
def select_sort(alist):
'''选择排序'''
n = len(alist)
for j in range(0,n-1):
min_index = j
for i in range(j+1,n):
if alist[i] < alist[min_index]:
min_index = i
alist[j],alist[min_index] = alist[min_index],alist[j]
print(alist)
if __name__ == '__main__':
alist = [54... | true |
18ac453891dfe3ef0411d0f58689656ce784db27 | Python | omnrohr/capstone | /app_test.py | UTF-8 | 13,686 | 2.65625 | 3 | [] | no_license | #----------------------------------------------------------------------------#
# Imports
#----------------------------------------------------------------------------#
import os
import unittest
import json
from flask_sqlalchemy import SQLAlchemy
from app import create_app
from models import Movie, Actor, setup_db
#-... | true |
20c9ef139347d6260fcbfbe27c29e77e65441567 | Python | dgjung0220/opencv_python | /code/python_opencv_3.py | UTF-8 | 1,749 | 3.03125 | 3 | [] | no_license | import numpy as np
import cv2
def default() :
img = cv2.imread('../test_image/ET/et000.jpg')
px = img[340, 200] # 340, 200 픽셀값 반환
print(px) # [35 35 35]
img[340, 200] = [0, 0, 0] # 픽셀값을 (0,0,0) 검은... | true |
6daab0c258c59042e1e4be61f39d8524d2897cf9 | Python | MEA-Hack-Club/MEA-Platformer- | /helpers.py | UTF-8 | 1,868 | 3.1875 | 3 | [] | no_license | from pygame.locals import * # import pygame modules
def readFile(path):
f = open(path, "r")
arr = []
while(True):
tempLine = f.readline()
if tempLine == "":
break
temparr = []
for t in tempLine:
temparr.append(t)
arr.append(temparr)
f.close()
return arr;
def collision_... | true |
02b6ff8516f9e4a0d4652de7fa15548879fca63b | Python | bobotran/CTGAN | /tests/integration/test_ctgan.py | UTF-8 | 1,992 | 3.046875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Integration tests for ctgan.
These tests only ensure that the software does not crash and that
the API works as expected in terms of input and output data formats,
but correctness of the data values and the internal behavior of the
model are not checked.
"""
import nu... | true |
7487d55e8c001224e39a441a257509c5ab1ce725 | Python | lumig242/DuplicationDetectionStackOverflow | /deliverable/Utils/TopicModel.py | UTF-8 | 2,243 | 3.09375 | 3 | [] | no_license | import os
import itertools
from collections import Counter
try:
import cPickle as pickle
except ImportError:
import pickle
import numpy as np
import lda
DUMP_MODEL_PATH = 'lda_model.pkl'
class LDA(object):
def __init__(self, corpus, load=False, n_topic=3):
self.words = np.array([t[0] for t in C... | true |
afe533063c5f4efffe3581a3a08ab090cb78fb47 | Python | hinohi/LSBattle | /model/mqo/mqo_loader.py | UTF-8 | 12,611 | 2.671875 | 3 | [] | no_license | #coding: utf8
import operator
import re
class Face(object):
__slots__ = ("n", "indices", "material", "uv", "h")
def __init__(self, n=0, indices=None, material=None, uv=None, color=None):
self.n = int(n)
if self.n not in [3, 4]:
self.n = 0
return
self.indices = ... | true |
47622d658bd694d9d4eea40b649862971bc836f9 | Python | brentsondgeroth/bioinformatics | /matchingsequences/BGChapter2S1.py | UTF-8 | 5,496 | 3.609375 | 4 | [] | no_license | '''
Names:Matthew Kachlik and Brent Gaither
Description: This program takes information from the user to proecess the
two sequences of DNA then comapres the amino acid sequence looking for
differences then writes to an outputfile
Due Date: 1/15/15
'''
import sys
'''
transcription
takes in the a sequence the... | true |
184348bdc83f2ee27f542a7cdf7f5c88a2e49e33 | Python | shy2913/python-practice-5 | /if문표현식.py | UTF-8 | 168 | 3.375 | 3 | [] | no_license | # 뭔가 반복적으로 엄청 수행해야 한다!
# 반복문(while문)
score = 70
message = "success" if score >= 60 else "failure"
# 3항 연산자
print(message)
| true |
5989f2a6072bdce022249c71a4550a00aa3f01d5 | Python | gistable/gistable | /all-gists/8591914/snippet.py | UTF-8 | 1,935 | 2.609375 | 3 | [
"MIT"
] | permissive | #coding: utf-8
import console
import keychain
import pickle
login = keychain.get_password('pinboard.in','pythonista')
if login is not None:
user, pw = pickle.loads(login)
else:
user, pw = console.login_alert('Pinboard Login', '')
login = pickle.dumps((user, pw))
keychain.set_password('pinboard.in', 'pythonista', ... | true |
eddf35e934ac42bea1428d2fefee8d7024bf6dad | Python | guptarohit994/ECE143_group25_project | /statistical_analysis/ucop_yearwise_stud_prof.py | UTF-8 | 11,615 | 3.015625 | 3 | [
"CC0-1.0"
] | permissive | import pandas as pd
import csv
import re
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import os
def get_ucop_dataset_facts(path, title_to_text_dict=None, verbose=False):
'''
function to get student opportunities out of ucop dataset
:param path: path of the csv file
:type path: ... | true |
7204b066d9e79ee81353b56f208e524f4d1bd9cc | Python | adelhult/welcome-bot | /greet.py | UTF-8 | 713 | 3.28125 | 3 | [
"MIT"
] | permissive | from random import choice
from discord import File
def greet():
with open('words.txt', encoding='utf8') as file:
words = file.readlines()
word = choice(words)
word = word.strip()
word = word.capitalize()
if (word[-1] == 'd'):
word = word[:-1] + 't'
elif (not is_vo... | true |
32992a5c2337731374af0e066daf1c7eca756d1c | Python | lizcrooks/class-work | /random_walk.py | UTF-8 | 1,812 | 4.09375 | 4 | [] | no_license | from random import choice
class RandomWalk():
"""A class to generate random walks."""
def __init__(self, num_points=5000):
"""Initialize attributes of a walk."""
self.num_points = num_points
#All walks start at (0,0).
self.x_values = [0]
self.y_values = [0]... | true |
b587b82681a5160686b40ab4f2cffa25360fc232 | Python | jamesberger/python-projects | /python-challenge/writing-stats.py | UTF-8 | 4,953 | 4.15625 | 4 | [] | no_license | #!/usr/bin/env python27
import sys
import os
from collections import Counter
'''
A quick utility for gathering stats for writers from text input.
The utility will take text from the command line or from a file.
Once it has text to work with, it will give the following stats:
1. Word count
2. Top ten most common wor... | true |
5bcff64ff4d8511340313650de104e67b561b28c | Python | knutsvk/sandbox | /euler/p43.py | UTF-8 | 522 | 3.390625 | 3 | [] | no_license | from itertools import permutations
from p35 import prime_sieve
def tup_to_int(tup):
return int("".join([str(x) for x in tup]))
if __name__ == "__main__":
perms = permutations(range(0, 10))
primes = (2, 3, 5, 7, 11, 13, 17)
ans = 0
for perm in perms:
interesting = True
for i in r... | true |
1621cc31e35daea115caea561dd78dd6b5717504 | Python | yuzhiw/SklearnTextClassification | /script/classifier_test.py | UTF-8 | 7,551 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# author:WWF
# datetime:2019/5/22 11:31
"""
1. sklearn 中分类方法(Naive Bayes, Logistic Regression, XGboost, lightGBM, SVM, KNN, \
Random Forest, Decision Tree, GBDT)测试文本二分类效果,所用数据(neg.txt, pos.txt),各个分类器
的测试效果如下:
Naive Bayes Result: 0.9032786885245901
Logi... | true |
888ce366058712efb7cd0e29d9f7464fdeee877e | Python | tyelf22/pythonBookRecommendations | /bookrecs.py | UTF-8 | 3,789 | 3.484375 | 3 | [] | no_license | ''' Tyson Elfors
5/21/20
CS-1410
Project 2 - Book Reccomendations
'''
"""I declare that the following source code was written solely by me.
I understand that copying any source code, in whole or in part, constitues cheating,
and that I will receive a zero on this project if I am found in violation of this policy."""
... | true |
fc46f5c2776548cac73d14b2faa0fcb89bcca8be | Python | pavithra171/python_powershell_practice | /python/pythonmodule.py | UTF-8 | 218 | 2.625 | 3 | [] | no_license | '''import os
print(os.name)
print(os.path)
print(os.getcwd())'''
import sys
print(sys.path)
print(sys.maxsize)
print(sys.api_version)
print(sys.platform)
print(sys.byteorder)
print(sys.argv)
print(sys.stdin) | true |
d80905fdc907f0fa9b652895b7959266b9541db1 | Python | rossbutler2000/Research | /PythonScripts/getBinaries.py | UTF-8 | 2,359 | 2.78125 | 3 | [] | no_license | '''
For the compounds of interest, we will be looking at the compounds used to
form them.
The compound structures ABC4 and A3BC6 are formed by the compostions of
AC+BC3 and 3AC+BC3 respectively.
This script gathers all the compound's composition compounds to study their
formation energies to see if the structure i... | true |
f2216f871e3c5d267ba445f8b11634bfe69abeaa | Python | aauss/wow_activity_map | /format_for_visualization.py | UTF-8 | 6,812 | 2.8125 | 3 | [] | no_license | import pickle
import pandas as pd
import numpy as np
from datetime import datetime
from didyoumean.didyoumean import didYouMean
from copy import deepcopy
cleaned_server_activity = pickle.load(open('cleaned_server_activity.p', 'rb'))
time_shift = {'America/Chicago': -5,
'America/Denver': -7,
... | true |
6b520ba874aac2447d2e9b0825124a7bba757f82 | Python | L200170009/prak_ASD_A | /no1.py | UTF-8 | 1,305 | 3.4375 | 3 | [] | no_license | class Pesan(object):
"""Sebuah class bernama Pesan.
Untuk memahami konsep Class dan Object"""
def __init__(self, sebuahString):
self.teks = sebuahString
def cetakIni(self):
print(self.teks)
def cetakPakaiHurufKapital(self):
print(str.upper(self.teks))
def cetakPa... | true |
60924199649a188b48f6d5894fc34208437d0751 | Python | kitsunetohu/SeverOfUnityPythonNumberRecognition | /recog.py | UTF-8 | 2,275 | 2.65625 | 3 | [] | no_license | import json
import numpy as np
import cv2
import pickle
from keras import models
from keras import layers
from keras.utils import to_categorical
import matplotlib.pyplot as plt
network=None
def jsonToImage (str):
json_data = str
#对传进来的点缩放使其符合28*28
python_obj = json.loads(json_data)
x = python_obj["X"]
... | true |
8c3a3fabd4db179be404664abee18d8a6e7aaebb | Python | asdfmelody/Lecture_OpenCV | /chap11_2/01haar_face.py | UTF-8 | 1,637 | 2.78125 | 3 | [] | no_license | import cv2
from Common.haar_utils import *
face_cascade = cv2.CascadeClassifier("haarcascade/haarcascade_frontalface_alt2.xml") # 정면 검출기
if face_cascade.empty(): raise IOError('Unable to load the face cascade classifier xml file')
eye_cascade = cv2.CascadeClassifier("haarcascade/haarcascade_eye.xml") # 눈 검출기
if eye_... | true |
a8bf4e0c82b49fab498d5141df21bb69d19b7bda | Python | tushi43/SentimentalAnalysis | /test.py | UTF-8 | 4,846 | 2.65625 | 3 | [] | no_license | import random
import sklearn
import nltk
import pandas as pd
import re
from nltk.corpus import stopwords
from nltk.stem import PorterStemmer
from nltk.tokenize import word_tokenize
from nltk.classify.scikitlearn import SklearnClassifier
from sklearn.naive_bayes import MultinomialNB,BernoulliNB
from sklearn.li... | true |
838ebac968cea100413632708f40a6c386cd4f1a | Python | JayWu7/Code | /leetcode_236.py | UTF-8 | 1,687 | 3.625 | 4 | [] | no_license | class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
#Excellent code
class Solution(object):
def lowestCommonAncestor(self, root, p, q):
"""
:type root: TreeNode
:type p: TreeNode
:type q: TreeNode
... | true |
35d1c8d75838922037bfa9bd266e5a7c7d519ae8 | Python | bennphsmith/dndAppProject | /dndApp/Archive/test2.py | UTF-8 | 688 | 2.5625 | 3 | [] | no_license | import json
import pprint
import urllib.request
from cassandra.cluster import Cluster
cluster = Cluster(['127.0.0.1']) # Create new Cluster Instance and connect to Cassandra database
session = cluster.connect() # Create a new session
session.set_keyspace('main') # Use keyspace for session
data_skills = json.load(urll... | true |
e9c5c925ffa221c0ff71314e0373be634e25f226 | Python | YakNazim/telemetry | /gps.py | UTF-8 | 1,672 | 2.609375 | 3 | [] | no_license | import re
import os
import ephem
import datetime
import copy
DATA = False
TLE_FILE = os.path.join(os.path.dirname(__file__), 'data/gps.tle')
SITE = ephem.Observer()
SITE.lon, SITE.lat = '-122.631007', '45.51200'
prn = re.compile('\PRN [0-9]*')
def init_constellation():
sats = {}
try:
with open(TLE_F... | true |
544365745d0f4b487aee04ceb23cbe45f0b46a71 | Python | Gauravcg492/ProblemSolving | /HackerRank/Interview_Prep/Greedy_Algorithms/Greedy_Florist/solution.py | UTF-8 | 349 | 2.71875 | 3 | [] | no_license | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the getMinimumCost function below.
def getMinimumCost(k, c):
f = 0
friends = [0]*k
c = sorted(c, reverse=True)
total_cost = 0
for i in c:
total_cost += ((friends[f]+1)*i)
friends[f] += 1
f = ... | true |
5f7ff6afeeedb58141b41b441da44eb3bb846f91 | Python | siddhusalvi/python-data-structure | /dictionary/lists_in_dictionary.py | UTF-8 | 342 | 4.125 | 4 | [] | no_license | """
13. Write a Python program to count number of items in a dictionary value that is a list.
"""
def count_list(dict1):
count = 0
for i, j in dict1.items():
if isinstance(j, list):
count += 1
return count
d = {'A': [1, 2, 3, 4, 5, 6, 7, 8, 9], 'B': 34, 'C': 12, 'D': [7, 8, 9, 6, 4]}... | true |
64f6ade3b3f97508278d345831ac0ff8fa392403 | Python | jac002020/Deep-Learning-Projects | /models/perceptron/perceptron.py | UTF-8 | 3,852 | 2.78125 | 3 | [] | no_license | import torch
import torch.nn as nn
import matplotlib.pyplot as plt
from torch.utils.data import Dataset, DataLoader
from pytorch_datasets.fashion_mnist import FashionMnistDataset
import matplotlib
matplotlib.colors.Colormap('inferno')
BATCH_SIZE = 16
NUM_EPOCHS = 1000
LEARNING_RATE = 1e-4
train_fashion_mnist_datase... | true |
2ef799ea2fffc489fd488ae181b560bc9b312303 | Python | gladiopeace/blockchaincentralitymeasurement | /clone_detector/src/utils.py | UTF-8 | 1,316 | 2.53125 | 3 | [] | no_license | import shutil
import os
import json
import random
import string
def pprint(obj):
print(json.dumps(obj, indent=2))
def get_dir_name(first, second):
return "%s_%s" % (first, second)
def listdir(src, ignore_dir={".git"}, ignore_file={".gitignore", ".gitattributes"}):
file_list = list()
for root, dirs... | true |
72d9e0414e08c05370214d1b317a21c54b75d753 | Python | valdeco/alura-machine-learning-I | /classifica_buscas.py | UTF-8 | 2,627 | 3.375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
#pd = python data_analys
import pandas as pd
from collections import Counter
#df = data_frame
df = pd.read_csv('busca.csv')
X_df = df[['home', 'busca', 'logado']]
Y_df = df['comprou']
#as type garante que o valor vai ser do tipo inteiro
Xdummies_df = pd.get_dummies(X_df).astype(int)
#Y não pr... | true |
6571c6b18dff5b4f630d51d971ef145bf0c78d6a | Python | theodore/olympiads | /HOJ/1951/bf.py | UTF-8 | 238 | 3.109375 | 3 | [] | no_license | #!/usr/bin/env python
from math import *
n = int(raw_input())
g = int(raw_input())
p = 999911659
ans = 0
for i in range(1, n + 1):
if n % i == 0:
ans += factorial(n) / factorial(i) / factorial(n - i)
ans %= p - 1
print g ** ans % p
| true |
c4cf593dae30c415b5e12bb7f69e0171f0b9e28d | Python | HassanBahati/python-sandbox | /modules.py | UTF-8 | 635 | 3.234375 | 3 | [] | no_license | # a module is basically a file containing a set of functions to include in your application.
# there are core python modules, modules you can install using the pip package manager (including django) as well as custom modules
#core modules
import datetime
#to import date from datetime
from datetime import date
#today... | true |
ea831d4c08a189b7c937ac57ac1d7c3059a2034a | Python | MrHamdulay/csc3-capstone | /examples/data/Assignment_3/swnsha007/question2.py | UTF-8 | 226 | 3.796875 | 4 | [] | no_license | def triangle():
x=eval(input("Enter the height of the triangle:\n"))
space=x//1
for i in range(0,x+4,2):
print(' '*space,end='')
print("*"*(i+1))
space-=1
triangle()
| true |
16b10a8d996c4dfed9279d82558ade0e5be5e292 | Python | lawson0628/python200805 | /day3-5.py | UTF-8 | 790 | 4.03125 | 4 | [] | no_license | while True:
print('1.加法')
print('2.減法')
print('3.乘法')
print('4.除法')
print('5.離開')
sel=int(input('請輸入你要選的選項:'))
if sel==1:
a=int(input('請輸入一個數'))
b=int(input('請輸入一個數'))
print(a,'+',b,'=',a+b)
elif sel==2:
a=int(input('請輸入一個數'))
b=int(input(... | true |
67e94de012da4b0c6f8fb5a53424ddd7428a9884 | Python | JeeHyesoo/algorithm | /1978_소수찾기.py | UTF-8 | 299 | 2.9375 | 3 | [] | no_license | import sys
sys.stdin = open("input.txt")
N = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
count = 0
for tmp in arr:
if tmp ==1:
count+=1
if True in list(map(lambda x: True if tmp % x == 0 else False, range(2,tmp))):
count+=1
print(N-count) | true |
1e939917bbaddad3578cec620833efc09ed35749 | Python | wetosc/Student-Book-Creator--Python- | /test.py | UTF-8 | 2,167 | 2.71875 | 3 | [] | no_license | import os
from PIL import Image
from fpdf import FPDF
def editImage(imagename):
image = Image.open(imagename).convert("L")
size_x, size_y = image.size
if size_y > size_x:
image=image.rotate(90)
paper = 230
def x1coord(data, size):
size_x, size_y = size
k = []
for... | true |
17901273e5f9a7a24579c3ab4e1eec9aa5824887 | Python | whiteted-strats/GE_Wiki_Maps | /lib/seperate_tile_groups.py | UTF-8 | 1,747 | 2.96875 | 3 | [] | no_license |
def seperateGroups(tiles, startTileName, dividingTiles):
dividingTiles = set(dividingTiles)
groups = []
stack = []
currTile = dict((tile["name"], addr) for addr, tile in tiles.items())[startTileName]
currGroup = []
count = 0
groupGood = len(dividingTiles) == 0
##print("In... | true |
c7bf99a54d47598116a1506e1701b5f8406f2a3b | Python | ike104/pythonwork | /qttest3.py | UTF-8 | 563 | 2.578125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sun Jul 05 23:12:30 2015
@author: ikechan
"""
#!env python
import sys
from PyQt4 import QtGui, QtCore
class QuitButton(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.setGeometry(50, 50, 300, 300)
self.set... | true |
b5ffdc169840962be0700c87efdc4b58710e6e9a | Python | GameThemedGroup/HTL | /Procedural/HTLJythonAPI/Lab9.py | UTF-8 | 1,603 | 2.828125 | 3 | [] | no_license | '''
@author: Taran Christensen
'''
from HTLAPISupport import *
@build_Game
def buildGame(Game):
for currentNum in range(0, 20):
Game.addPathLeftRight(currentNum, 5);
Game.preparePathForWalkers(0,5,19,5);
Game.setCountdownFrom(3);
@update_Game
def updateGame(Game):
if Game.countdownFir... | true |
ab4cf713761082e93d48673daa831a09d404f14a | Python | varun-invent/feature-extractor | /link_mapping_to_atlas/find_common_links.py | UTF-8 | 13,432 | 2.953125 | 3 | [
"MIT"
] | permissive | import pandas as pd
import numpy as np
import os
import sys
def calc_prec_recall_f_score(a, b, d):
p = b/a
r = b/d
f = 1/((1/p) + (1/r))
return p, r, f
def find_common_links_ABIDE_review(in_file1, in_file2, out_file_path):
# print(in_file1)
# print(in_file2)
# print(out_file_path)
A... | true |
67eb89e512e9b2b5f8508865c19c7f499df02bdf | Python | harshavardhan-i/python | /variables/string.py | UTF-8 | 1,290 | 4.21875 | 4 | [] | no_license | # String are immutable in python
# Strings are ordered sequences
# Can be encased with single quote or double quotes
# No difference between single and double quotes in python
# Must start and end with the same type of quotes
# String concatenation - "+" operator concatenates two string literals
# input("Please... | true |
e895063de54f54a8e4efdeb4c11af231aa15b142 | Python | aq-eng/abcd | /handeval_cached.py | UTF-8 | 1,150 | 3.25 | 3 | [] | no_license |
import itertools
import math
from handeval_naive import handnumber_5card, handnumber_3card
# test via 4 out of 20
def comb_classic(k_choosen, n_total):
"""Classic mathematical combinatorial forumula
choose k out of a total n without order without replacement"""
assert(isinstance(k_choosen, int))
asse... | true |
8bf37ae91bd23d31011d7b11745f2acec5fa40a3 | Python | lenstronomy/lenstronomy | /lenstronomy/GalKin/light_profile.py | UTF-8 | 11,550 | 2.90625 | 3 | [
"BSD-3-Clause"
] | permissive | import numpy as np
import copy
from scipy.interpolate import interp1d
from lenstronomy.LightModel.light_model import LightModel
__all__ = ['LightProfile']
class LightProfile(object):
"""
class to deal with the light distribution for GalKin
In particular, this class allows for:
- (faster) interpolat... | true |
5ce257fb28394815dcba39bfb08cd486bfd5dd6e | Python | manparvesh/coursera-ds-algorithms | /4. String Algorithms/Programming-Assignment-3/kmp/kmp.py | UTF-8 | 483 | 3.578125 | 4 | [
"MIT"
] | permissive | # python3
import sys
def find_pattern(pattern, text):
"""
Find all the occurrences of the pattern in the text
and return a list of all positions in the text
where the pattern starts in the text.
"""
result = []
# Implement this function yourself
return result
if __name__ == '__main__'... | true |
85fa8ecb6b704d861e7fcc56041e70c4399897c1 | Python | SamChen1981/spider-1 | /internet/backends/twisted/__init__.py | UTF-8 | 134 | 2.515625 | 3 | [] | no_license | import requests
class HttpClient(object):
def request(self, url):
response = requests.get(url)
return response
| true |
4d0204b51b2a8b1461b007b5666a5ee36c1df4bd | Python | yiwen26/MH8811-G1901835C | /02/Program 1.py | UTF-8 | 92 | 3.09375 | 3 | [
"MIT"
] | permissive |
# coding: utf-8
# In[ ]:
username=input("Username: ")
print("Hello, " + username +"!")
| true |
e3c53c91db583f72d1fc70a6cdbf90b34213a2dc | Python | hercules1408/codeforce | /gcppluslcm.py | UTF-8 | 313 | 3.3125 | 3 | [] | no_license | import sys
t = int(sys.stdin.readline().rstrip())
numl=[]
while t > 0:
numl.append(int(sys.stdin.readline().rstrip()))
t = t - 1
for i in numl:
if i % 2 == 0:
var1 = i // 2
print(str(var1) + ' ' + str(var1))
else:
var1=i
print('1' + ' ' + str(var1-1)) | true |
eeffb0d5008ac9dcb18ff06149887695b51b3644 | Python | gxkeep/- | /AL课件及作业/python及线代/10.17/作业/4.py | UTF-8 | 230 | 2.6875 | 3 | [] | no_license | import numpy as np
A=np.random.randn(200,500)
B=np.random.randn(500,500)
def fun(l):
return np.dot(A,np.dot(B,1*np.eye(500)))
res1=A+A
res2=np.dot(A,A.T)
res3=np.dot(A.T,A)
res4=np.dot(A,B)
i=int(input("lambda:"))
res5=fun(l) | true |
e04077ecfd009a51dbf5f7577f43e71628b97929 | Python | tonysy/DRN-MXNet | /lib/layers/weightedlogistic.py | UTF-8 | 1,829 | 2.53125 | 3 | [] | no_license | #!/usr/bin/env python
# encoding: utf-8
"""
@author: ‘zyq‘
@license: Apache Licence
@file: weightedlogistic.py
@time: 2017/12/2 16:24
"""
import mxnet as mx
from utils.image import plot_border
class WeightedLogisticRegression(mx.operator.CustomOp):
def __init__(self, grad_scale, clip_grad):
... | true |