blob_id
large_string
repo_name
large_string
path
large_string
src_encoding
large_string
length_bytes
int64
score
float64
int_score
int64
detected_licenses
large list
license_type
large_string
text
string
download_success
bool
63d867803dd566779a8bea147ed148255c80156a
mwartell/gdi-ct
/fake_data.py
UTF-8
679
3.296875
3
[ "MIT" ]
permissive
#!/usr/bin/python3 import csv import random import sys def id_numbers(start=1011, step=100): """Returns a series of increasing integers starting at start. The next number will be at most step above the last. """ while True: yield start start += random.randint(1, step) def fake_dat...
true
668c0c49f98efe5e619f4d9c6b9c65ffdc78a9d7
xueranyihua/tensorflow
/untitled/main.py
UTF-8
571
3.109375
3
[]
no_license
class Solution(object): def maxArea(self, height): max = 0 front = 0 behind = len(height) - 1 while True: if front == behind: break elif height[front] >= height[behind]: area = height[behind]*(behind - front) beh...
true
9e7e82f5c23c3f08530d9c8fdf11f23bf9f84d03
jacobfelknor/practice_interview_questions
/AlgorithmReview/knapsack.py
UTF-8
1,925
4.03125
4
[]
no_license
# knapsack niave recursive import random def knapSackRecursive(W, weights, values): if W == 0 or len(weights) < 1: return 0 if weights[0] > W: # if current weight exceeds available weight return knapSackRecursive(W, weights[1:], values[1:]) else: # return max of taking i...
true
ab34811fe38158ad31fe1102d039635420cac388
Wizmann/ACM-ICPC
/Exemplars/Data Generator/Graph/undirected_graph.py
UTF-8
873
2.9375
3
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
import sys import random if __name__ == '__main__': if len(sys.argv) == 2: n = int(sys.argv[1]) m = random.randint(n - 1, n * n) elif len(sys.argv) == 3: n = int(sys.argv[1]) m = int(sys.argv[2]) else: n = random.randint(1, 100) m = random.randint(n - 1, n * ...
true
c1f20cc0defada997623025005132e3fdec54af1
ishida722/atcoder-study
/ABC190/a.py
UTF-8
410
3.109375
3
[]
no_license
A, B, C = map(int, input().split()) if C: # aoki while True: if not B: print('Takahashi') exit() B -= 1 if not A: print('Aoki') exit() A -= 1 else: while True: if not A: print('Aoki') exit() A...
true
bb28225aa35b03ec17023a887c5a8662b5de74bc
migueldsw/DTN-HD
/dataset/utils.py
UTF-8
1,618
2.546875
3
[]
no_license
""" General project utils """ import os.path import os import shutil import numpy as np DATASET_ROOT_PATH = '' IMAGE_LIST_FILE = '' COMPLETE_TAGS_FILE = '' IMAGES_PATH = '' TEXT_DATA_FILE = '' TAG_LIST_FILE = '' with open(os.path.dirname(__file__) + '/../config.info') as f: content = f.readlines() lines = [x.str...
true
d3546f8af3b1830235328be0d188c445f5354e49
Rillatile/PyDiploma
/test.py
UTF-8
7,760
2.640625
3
[]
no_license
import unittest import parser import executor def parse_uncorrect_module_with_wrong_constant(*args, **kwargs): source = ('Variables {\n' + 'a: "Тестовое описание." = 1;\n' + '!b;\n' + '}\n' + 'Constants {\n' + 'PI: "Число Пи.";\n' + ...
true
173903c303fc5351eaefa7004e73864a39bdfa99
thizago/letscode
/#Lista - While/3.py
UTF-8
189
3.75
4
[ "MIT" ]
permissive
numero_maximo = int(input('Digite até que número deseja o fatorial: ')) i = 1 fatorial = 1 while i <= numero_maximo: fatorial *= i i += 1 print (numero_maximo,'n!:', fatorial)
true
005e29c0f8a94e1aa0e3f5f1c9da9be6b750930c
davek44/utility
/plot.py
UTF-8
1,456
2.984375
3
[]
no_license
#!/usr/bin/env python from optparse import OptionParser import matplotlib.pyplot as plt ################################################################################ # plot.py # # matplotlib helper methods ################################################################################ ###########################...
true
17288289ac8f22dc36d95dc15e4b279b97547a74
anirbandey303/xmeme
/backend/main/app/views.py
UTF-8
2,202
2.5625
3
[]
no_license
from datetime import datetime from app import app from app import database from flask import redirect from flask import request from flask import jsonify from flask import url_for from pymongo import MongoClient from app import ma import os import json class MemeDB(database.Model): id = database.Column(database.Inte...
true
86b31017d6b217100fdce5b10642c0caa0c06ad4
jennimm/PlanYourOpenSpaces
/main.py
UTF-8
8,724
2.53125
3
[]
no_license
filename = 'a_solar' data = open(filename+'.txt','r') W,H = data.readline().split() W = int(W) H = int(H) plan = [] companies = [] companyDevelopers = [] managersBonus = [] for i in range(H): plan.append([]) for i in range(H): line = data.readline() for j in range(W): plan[i].append(line[j]) numDe...
true
411aa5ebcb677b7f7317f5f6fa630067a1658f9c
michaeljoseph/remarkable
/tests/__init__.py
UTF-8
1,255
2.671875
3
[ "Apache-2.0" ]
permissive
import os from unittest2 import TestCase MARKDOWN = """ name: inverse layout: true class: center, middle, inverse --- # Application To Platform .footnote[ [How we used Python to scale Yola] (https://github.com/michaeljoseph/application-to-platform) ] --- layout: false background-image: url(https://raw.github....
true
af6a607012acfd0ac337814e5cf2900dc11d8237
moontree/leetcode
/version1/1295_Find_Numbers_with_Even_Number_of_Digits.py
UTF-8
1,545
3.953125
4
[]
no_license
""" Given an array nums of integers, return how many of them contain an even number of digits. Example 1: Input: nums = [12,345,2,6,7896] Output: 2 Explanation: 12 contains 2 digits (even number of digits). 345 contains 3 digits (odd number of digits). 2 contains 1 digit (odd number of digits). ...
true
f0216bdf6b8aadcb0f17889ae5f92949336bbd29
Sandesh373/GAAssignments
/2.6.py
UTF-8
404
2.578125
3
[]
no_license
import yaml my_dict = yaml.load(open('C:\\Users\\dyava\\Desktop\\ipl_match.yaml')) rt=my_dict["innings"][1]["2nd innings"]["deliveries"] run=0 for x in rt: for k,v in x.items(): for p,q in v.items(): if p =="wicket": for u,v in q.items(): if u=="kind" and v==...
true
2564587bf27659ba72d63126e371f61c6975fa3e
onionzhou/Note
/OLD_BAK/data_structure/sort/quicksort.py
UTF-8
2,396
3.8125
4
[]
no_license
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # @Time : 19/3/4 下午8:33 # @Author : onion # @Site : # @File : quicksort.py # @Software: PyCharm ''' 实现1: def quickSort(list): if len(list) < 2 : return list else: base = list[0] #基准条件 base_left = [i for i in list[1:] if i<=bas...
true
633d8d799ef549a6fdeeea351c7aa4d63ae6cf44
realpython/materials
/creating-and-modifying-pdfs/source_code/05-encrypting-and-decrypting-pdfs.py
UTF-8
950
2.90625
3
[ "MIT" ]
permissive
# --------------- # Encrypting PDFs # --------------- from pathlib import Path from pypdf import PdfReader, PdfWriter pdf_path = ( Path.home() / "creating-and-modifying-pdfs" / "practice_files" / "newsletter.pdf" ) pdf_reader = PdfReader(pdf_path) pdf_writer = PdfWriter() pdf_writer.append_pages_fr...
true
54767d14dea7da1d11e29b9cae4e2f8f30b953ae
MirasK/PythonPractice
/game.py
UTF-8
54
3.0625
3
[]
no_license
a = int(input()) n = 9 - a print(a * 100 + 90 + n)
true
5f03a74b3ba7d060785ee6e329a428f52ed7188e
neung20402/Python
/week3/test2.py
UTF-8
311
3.203125
3
[]
no_license
loop = int(input("กรุณากรอกจำนวนครั้งการรับค่า\n")) total = 0 for x in range(0,loop): num = int(input("กรอกตัวเลข : ")) total = total + num print("ผลรวมค่าที่รับมาทั้งหมด = ",total)
true
67b51171d37a92d447df0aa751b5b89e616809d7
smadala/IIIT-PG11
/sce/slides/python/pra/common.py
UTF-8
158
3.09375
3
[]
no_license
def common(l1,l2): cm=[] for i in range( len(l1) ): if l1[i] in l2: cm.append(l1[i]) print cm li1=[1,3,5,7,8] li2=[2,3,5,4,6,8] common(li1,li2)
true
720260fac1e77ac9f733e8459a533edb073beec1
zc1001/leetcode
/Number theory/228/228.py
UTF-8
1,808
3.046875
3
[]
no_license
import math import copy import operator # 执行用时 :24 ms, 在所有 python 提交中击败了40.21% 的用户 # 内存消耗 :11.7 MB, 在所有 python 提交中击败了32.43%的用户 class Solution(object): def summaryRanges(self, nums): """ :type nums: List[int] :rtype: List[str] """ if(len(nums) == 0): ...
true
3b15e7389ca9a752ec8281c7318c650a5d1e07da
GBoshnakov/SoftUni-Fund
/Classes and Objects basics/Email.py
UTF-8
730
3.53125
4
[]
no_license
class Email: def __init__(self, sender, receiver, content): self.sender = sender self.receiver = receiver self.content = content self.is_sent = False def send(self): self.is_sent = True def get_info(self): return (f"{self.sender} says to {self.receiver}: {se...
true
3fe20462a6542e36d65229e348e3268930fc64a9
tbleicher/clean-architecture-python
/src/tests/unit/domain/auth/test_auth_service.py
UTF-8
3,969
2.515625
3
[ "MIT" ]
permissive
import pytest from unittest.mock import AsyncMock from jose import jwt from app.domain.users.entities import AuthUser, User from app.domain.auth.entities import LoginInputDTO from app.domain.auth.errors import AuthError from app.domain.auth.service import AuthService user_data = { "id": "user-id", "first_nam...
true
b36893666857b555264d5583b089c67eaae37fed
sondongmin0419/study
/python/b_2292.py
UTF-8
141
3.296875
3
[]
no_license
n = int(input()) i = 0 cnt = 0 while True: n = n - i*6 if n <= 1: break else: i += 1 continue print(i+1)
true
a5e04b76c137292bc33d2f2ba8082d268df1ad90
914DU/hi
/hi.py
UTF-8
60
3.171875
3
[]
no_license
age = input('請問幾歲:') print ('wow,', age, '歲!')
true
445b1d759109bcba914e0e6db00d8daafe483b70
NamburiSrinath/Artificial-Intelligence
/perceptron/perceptron.py
UTF-8
3,895
3.328125
3
[]
no_license
import numpy as np #from perceptron import Perceptron class Perceptron(object): def __init__(self, no_of_inputs, threshold=100, learning_rate=0.01): self.threshold = threshold self.learning_rate = learning_rate self.weights = np.zeros(no_of_inputs + 1) def predict(self, inp...
true
3387f1d5c918ec39a6db5d4e24872970b5aede27
Ritwik411/ML_Projects
/SVM and Naive Bayes/iris_data.py
UTF-8
1,354
3.65625
4
[]
no_license
# -*- coding: utf-8 -*- """ Created on Sat Jun 1 11:47:28 2019 @author: Ritwik Gupta """ """ Q2. This famous classification dataset first time used in Fisher’s classic 1936 paper, The Use of Multiple Measurements in Taxonomic Problems. Iris dataset is having 4 features of iris flower and one target class. T...
true
693ff57ce2dc96e6a8e997562eb7e116d7760090
stebubu/emf
/emf/subcalc/__init__.py
UTF-8
2,263
2.5625
3
[ "MIT" ]
permissive
""" emf.subcalc is currently similar to the original versions of emf.fields because it supplements another modeling program without fully replacing it yet. In this case, the other modeling program is SUBCALC (developed by Enertech, sponsored by EPRI). SUBCALC predicts EMF over a fixed-height 2 dimensional grid and can ...
true
e3ff74f05701538ff770eae1df09008ea26b7097
Hansimov/Hansimov.github.io
/backup_scripts/file-processing/sync_bookmarks.py
UTF-8
3,421
2.828125
3
[]
no_license
import os import time t0 = time.time() mark_str_body = "BookmarkBegin\nBookmarkTitle: {}\nBookmarkLevel: {}\nBookmarkPageNumber: {}\n"# new_book_fname =" 镜头的语法. pdf"# txt_fname ="bk-camera-i.txt"# mark_fname ="bk-camera.txt" # page_offset = 11 # new_book_fname = "剪辑的语法. pdf" # txt_fname = "bk-cut-i.txt" # mark_fname...
true
6f88932f05217a03b8a745d54893683eb31f317a
iFengZhao/Algorithms-1
/剑指Offer/32-1-不分行从上到下打印二叉树.py
UTF-8
462
3.65625
4
[ "Apache-2.0" ]
permissive
''' 题目:从上到下打印出二叉树的每个节点,同一层的节点按照从左到右的顺序打印。 ''' class Solution: def print_from_top_to_bottom(self, root): if not root: return queue = [root] while queue: node = queue.pop(0) print(node.val) if root.left: queue.append(node.left) ...
true
6021be3cfee4df053ac08fb3cc2e1b1a1cfe74c1
anderscui/nlpy3
/resumes/resumes.py
UTF-8
569
2.5625
3
[ "MIT" ]
permissive
# coding=utf-8 import json resumes = json.load(open('resumes.json')) columns = ['resume_birth', 'resume_sex', 'resume_location', 'resume_self_evaluation', 'resume_language', 'resume_skill', 'resume_project_experience', 'resume_education_experience', 'resume_work_experience'] new_resumes = [] for r in resumes: if ...
true
a549d547bc81ddf695fa684aa825a237c87e5ec0
vtt-info/Micropython-8
/libs/gy21/gy21_test.py
UTF-8
367
2.859375
3
[]
no_license
import machine import gy21 import time # Write your PINS here scl_pin = 17 sda_pin = 16 i2c = machine.I2C(0,scl=machine.Pin(scl_pin), sda=machine.Pin(sda_pin),freq = 10000) gy = gy21.GY21(i2c) while True: temp = gy.temperature hum = gy.humidity print() print('Temperature: ', temp) print('...
true
169cc68338494efed3a40f226f84ac630698b8fa
pytorch/pytorch
/torch/distributed/_composable_state.py
UTF-8
949
2.859375
3
[ "BSD-3-Clause", "BSD-2-Clause", "LicenseRef-scancode-secret-labs-2011", "LicenseRef-scancode-generic-cla", "BSL-1.0", "Apache-2.0" ]
permissive
from typing import cast, Dict, Optional import torch.nn as nn class _State: pass _module_state_mapping: Dict[nn.Module, _State] = {} def _insert_module_state(module: nn.Module, state: _State) -> None: global _module_state_mapping assert module not in _module_state_mapping, f"Inserting {module} more t...
true
3ffdbcea7b39b37246c02f661d0d993ebc233ae7
valch85/study-python-hackerrank
/loops.py
UTF-8
51
3.484375
3
[ "MIT" ]
permissive
n = int(5) for i in range(0,n): print(i*i)
true
fb8a349f8214185cfddf0b2c77bd718a9e0dcdba
AdiSai/Driving-in-the-Rain
/image_training/testing_v2.py
UTF-8
2,983
2.671875
3
[]
no_license
#!/usr/bin/env python2 # -*- coding: utf-8 -*- # This is a re-implementation of testing code of this paper: # X. Fu, J. Huang, D. Zeng, Y. Huang, X. Ding and J. Paisley. �Removing Rain from Single Images via a Deep Detail Network�, CVPR, 2017. # author: Xueyang Fu (fxy@stu.xmu.edu.cn) import os import s...
true
3179111f844fd7e904b307f75a666872b15d148f
my0614/dataScience
/bloodtransfusion/bloodtransfusion.py
UTF-8
821
2.59375
3
[]
no_license
import pandas as pd import csv import matplotlib.pyplot as plt f = open('C:/Users/MY/Desktop/BloodTransfusionServiceCenter.csv') import matplotlib.font_manager as fm from matplotlib import rc #원그래프 만들 때 한글 사용 fontprop = fm.FontProperties(fname=r"C:\Users\MY\workspace\datascience\NanumFontSetup_TTF_ALL(1)/NanumGothicC...
true
7030b489f8d913fc800d14591194d0525485d7ea
onthejeep/MixtureModel
/Trap/Tensorflow/N_1_MixtureModel.py
UTF-8
3,068
2.828125
3
[]
no_license
import numpy as np; import sklearn.cluster as cl; import scipy.stats as sas; def Loglikelihood(data, numComponent, mu, sigma, weight): Loglikelihood = 0; for k in range(numComponent - 1): Temp = weight[k] * NormalPdf(data, mu[k], sigma[k]); Temp[Temp < 1e-20] = 1e-20; Logli...
true
1aca659df5ca6ee331489ffe3c2a9607c90763a6
sugus86/python_study_2018
/Python_高级知识/学习实例/python中 __cmp__.py
UTF-8
3,294
3.859375
4
[]
no_license
class Point(object): def __init__(self, x, y): self.x = x self.y = y def dispc(self): return ('(' + str(self.x) + ',' + str(self.y) + ')') ... def __lt__(self, other): return ((self.x < other.x) and (self.y < other.y)) def __eq__(self,other): ...
true
65786a6a0cd3d94eab561553d0eda483408afd1c
daria-brb/twitter-sentiment
/classifier/classifier.py
UTF-8
3,956
3.140625
3
[]
no_license
import numpy as np import os import csv class Trainer(): def __init__(self, wordSize = 20): super(Trainer, self).__init__() self.wordSize = wordSize self.w = 0 self.b = 0 self.punct = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~" def readDocument(self, filename, voc): ""...
true
177018e811dfedce5125a6b4ee53185aa11d4b94
iansebastian/iansebastian.github.io
/hackerrank/coolstring4.py
UTF-8
767
2.875
3
[]
no_license
def print_rangoli(size): # your code goes here key = 96 + size row = 2*size - 1 comp1 = '-' comp2 = chr(key) len1 = ((4*size - 3) - len(comp2)) // 2 for i in range(1, 2*size): print(comp1*len1 + comp2 + comp1*len1) if i == size: comp2 = comp2[0:((len(comp2)//2) - ...
true
2adc154876b070b77fa45a470800b56374fb6055
oijmark7/python_
/Cos Pro/문제만들기/문제7.py
UTF-8
1,231
3.828125
4
[]
no_license
#문제7 : 위험지역의 개수 찾기 #위험지역: 해당수의 동서남북 인접한 수 가 모두 더클경우 해당수는 위험지역 #2차원 리스트 = [ [리스트],[리스트],[리스트]] # 행1 행2 행3 def solution(지형): dx=[-1,1,0,0] #dx[서쪽,동쪽,0,0] dy=[0,0,-1,1] #요[0,0,남쪽,북쪽] 위험지역 = 0 for 가로 in range(4): for 세로 in range(4): ...
true
995d45245cf76bda8a0d01de6da203a54779d572
navasardyan/HomeWork
/Game_3.py
UTF-8
2,403
4.09375
4
[]
no_license
from random import randint X = "X" O = "O" EMPTY = " " def add_board(): """ Создание игральной доски :return: доска для игры """ board = [] for i in range(COUNT): board.append(EMPTY) return board def write_board(board): print("\n\t", "|",board[6], "|", bo...
true
3cba6de95d6a0bb36572abd584536c1fb3cdad45
drewsoske/sports-pools-django-app
/sportspools/models.py
UTF-8
2,949
2.609375
3
[ "Unlicense" ]
permissive
from django.db import models # Create your models here. SPORT_IDS = ( (1, 'NHL'), (2, 'NBA'), (3, 'MLB'), ) # Member Model class Member(models.Model): global SPORT_IDS sport_id = models.PositiveSmallIntegerField( max_length=2, choices=SPORT_IDS, default=1 ...
true
c4bba85d86546ac19caa0215f1826c71a2e0222e
enextus/python_learnstuff
/dictionary_verschachtelt.py
UTF-8
1,138
4.03125
4
[]
no_license
# input language = ['D', 'F', 'E', 'd', 'f', 'e'] while True: a = input('Wähle das Herkunftsprache aus: In dem Du die Buchstabe D, F, E: ') if a in language: break else: print("bitte nur D,F,E,I: ") while True: z = input('Wähle das Zielsprache aus: In dem Du die Buchstabe D, F, E: ') ...
true
15f71ef4e7cb421c28aa0939545df958ded939a7
davidnjakai/bootcamp-8-nbo
/tdd/fizzbuzz.py
UTF-8
261
3.65625
4
[]
no_license
def fizz_buzz(number): """return fizz when divisible by 3 return buzz when divisible by 5 return fizzbuzz when divisible by 15 """ if number % 15 == 0: return 'fizzbuzz' elif number % 5 == 0: return 'buzz' elif number % 3 == 0: return 'fizz'
true
0c471c3ff297319686293694b58aa5d72cb9009d
tallen95/NumberGame
/test1.py
UTF-8
733
4.09375
4
[]
no_license
import random print("Guess the Number!") cont= True while cont == True : user_Range = int(input("Choose a number you would like to pick between: ")) init_Num = random.randint(1,user_Range) user_Num = int(input('Think of a number between 1 and ' + str(user_Range) +': ')) if ini...
true
b5a09cd28459f01040b1b4869bbf7da9805e5e22
davidhuser/dhis2-pk
/src/fake_data.py
UTF-8
13,823
2.75
3
[ "MIT" ]
permissive
#!/usr/bin/env python # -*- coding: utf-8 -*- import datetime import json import os import random import sys import time import uuid from dhis2 import Api, setup_logger, logger, is_valid_uid, RequestException, generate_uid try: from common.utils import create_api, file_timestamp, write_csv from common.excepti...
true
cac6e3b0fdd9ba0376240093ab8e23bf8a6f4428
skimbrel/makerbot
/menger.py
UTF-8
2,483
3.5625
4
[]
no_license
"""menger.py - generate OpenSCAD-compatible descriptions of Menger sponges Takes a single argument n, an integer number of iterations to run. Prints OpenSCAD code to stdout. My first attempt at this was to try constructing the sponge exactly the way the mathematical definition works, i.e. to take the largest cube and ...
true
b30d1293bef3a0ee328b6fa02267680f0ca78957
adam-worley/com404
/2-GUI/1-classes-and-objects/superbot.py
UTF-8
554
3.265625
3
[]
no_license
from bot_Q2 import Bot class SuperBot(Bot): def __init__(self, name, age, energy, shield, super_power_level): super().__init__(name, age, energy, shield) self.super_power_level = super_power_level def display_summary_super(self): full_energy = 10 full_shield = 10 print("Name:",self.name) p...
true
b9d7bf99d8791e5040d1731a884871f07b5fa5f4
josephkirk/PymaxRigTool
/sample/demoPython/demoUniCodeIO.py
UTF-8
3,675
3.4375
3
[]
no_license
# Import our modules import MaxPlus import tempfile import os import codecs import shutil # Set our variables # # Strings for the file content textStr = 'Text String: Hello!\n' uniTextStr = u'Unicode String: 女時代' # # Get the current working folder currentDir = os.getcwd() # # Create Unicode directory name uniDir = u'時...
true
cb43a8d2a7d80bf9608af082d7675adc60512cb8
sandrejev/tensorflow_exercise
/lesson3_iris.py
UTF-8
1,623
3.03125
3
[]
no_license
import tensorflow as tf import numpy as np classes = {0: "Iris setosa", 1: "Iris versicolor", 2: "Iris virginica"} # Load data training_set = tf.contrib.learn.datasets.base.load_csv_with_header( filename="IRIS_data/iris_training.csv", target_dtype=np.int, features_dtype=np.float32) test_set = tf.contrib.l...
true
41da89e7700b53506d191a3dccb0673c40388b94
ram2010mechatronics/PythonLearning1
/venv/Practise/Training3.py
UTF-8
312
4.09375
4
[]
no_license
#With a given integral number n, write a program to generate a dictionary that contains #(i, i*i) such that is an integral number between 1 and n (both included). and then the program should print the dictionary. x = input ("entre the number: ") n= int(x) d=dict() for i in range(1,n+1): d[i]=i*i print (d)
true
f8416a76c5a97b2fd74e17fb6b61433099319e11
KrystalJoyD/fall_distance.py
/fall_distance.py
UTF-8
411
3.984375
4
[]
no_license
# Author: Krystal Palacios # Date : April 22. 2020 # Description : Determine the distance an object falls due to the gravity in a specific time period. def fall_distance(fallingTime): """ fall_distance used to calculate the distance an objects falls due to gravity with the equation: d = (1/2)*gt(squared) a...
true
e7b63eb11e4c84e278ac60aa3f8ace5692f54ecd
nirimag/airBnb-Sentiment-analysis
/3. classificationv1.py
UTF-8
10,484
2.671875
3
[]
no_license
# -*- coding: utf-8 -*- """ Created on Sat Apr 1 11:48:03 2017 @author: nirimag """ """ Classification """ # PREPROCESSING WITH STEMMING & STOPWORDS REMOVAL FROM CUSTOMISED LIST # console 6: listing # console 5: host 400k label import numpy as np import pandas as pd from time import time rawdata = pd.read_csv('la...
true
773c5df223308569ec94640501dfa4078119f38e
StoKatze/Temperature-Controlled-USB-Fan
/Python/sensor.py
UTF-8
2,237
2.765625
3
[ "BSD-2-Clause" ]
permissive
import time import smbus2 import bme280 import requests import RPi.GPIO as GPIO # Constants SENSOR_PORT = 1 SENSOR_ADDRESS = 0x77 # Check your address before running this script URL = 'http://localhost:8086/write' # InfluxDB write URL READING_DATA_PERIOD_MS = 5000.0 SENDING_PERIOD = 2 MAX_LINES_HISTORY =...
true
afa3f34e387e00bc339b3fb29f7f4b08edf311c5
zuzhiang/Reinforcement-learning
/Policy_Gradients_maze/PG.py
UTF-8
3,470
2.890625
3
[]
no_license
import numpy as np import pandas as pd import tensorflow as tf np.random.seed(1) tf.set_random_seed(1) class PolicyGradient(): def __init__(self, n_actions, n_features, learning_rate=0.01, reward_decay=0.95, output_graph=False, ...
true
f4bc8aff58f087289a76c4ac2394b45010138259
JeDeveloper/SimulationThingy
/sim_setups/random_mating.py
UTF-8
222
2.625
3
[]
no_license
from random import uniform def choose_mates(e, options): """ :param e: :param options: :return: """ options.sort(key=lambda x: uniform(0, 1)) return options[:min(e.num_mates(), len(options))]
true
3446d1b961460b4a38f1dae461914454d4375ec0
jyuly12/AirBnB_clone
/models/place.py
UTF-8
728
2.890625
3
[]
no_license
#!/usr/bin/python3 """Defines Place class """ from models.base_model import BaseModel class Place(BaseModel): """Place class saves the attributes of an place: - city_id (string) - user_id string) - name (string) - description (string) - number_rooms (integer) - num...
true
215222c0335e829349b79c2804e923c27dc6fd8a
Lesuz/Python-Application-Course
/Practice/Week 11-12 Topic - Exception.py
UTF-8
573
3.8125
4
[]
no_license
# Week 11-12 Topic - Exception #class ZeroYearImpossible(Exception): # pass class TryException: #def __init__(self): try: x = int(input("Enter a year: ")) print ("Year : " + str(x)) #if self.x == 0: # raise ZeroYearImpossible except ValueError: print ("You...
true
1b1f91f97486bee97152e88837e45f6496ef480f
foggyspace/kiwifruit
/scanner_engine/lib/core/data.py
UTF-8
1,573
2.59375
3
[]
no_license
import re from collections import namedtuple GET, POST = "GET", "POST" DEFAULT_METHOD = "GET" PARAMS_PATTERN = re.compile(r"(?P<key>[^&=]+)(?:=(?P<value>[^&=]*))?") TITLE_PATTERN = re.compile(r"<title>(?P<title>[^<]+)</title>", re.I) SITETYPES = {'PHP':'.php', 'JSP':'.jsp', 'ASP.NET':'.asp', 'ASP':'.asp'} IPAD...
true
ffdf31ee28cf506e3dd5cdf9498fb1b65ae87a94
davidthewatson/postgrest_python_requests_client
/client.py
UTF-8
1,338
2.78125
3
[ "MIT" ]
permissive
import json import requests import requests_jwt try: from config import credentials, urls except ImportError: print('Config.py not found. Copy config.in to config.py and edit to suit.') exit() def login(email, password): r = requests.post(urls.login, json={"email": email, ...
true
10e797958b7f34a5426cabb0aa9bc101c3e36287
FawneLu/leetcode
/774/Solution.py
UTF-8
455
2.953125
3
[]
no_license
```python class Solution: def minmaxGasDist(self, stations: List[int], K: int) -> float: low=0 high=stations[len(stations)-1]-stations[0] while low+1e-6<=high: count=0 mid=low+(high-low)/2 for i in range(len(stations)-1): count+=(stations[i...
true
f47ce5eaccd373a9579e8ac6611b72e16804fe6c
cubsoon/intervalarithmetic
/intervalarithmetic/__init__.py
UTF-8
8,538
2.59375
3
[ "MIT" ]
permissive
# Setting float rounding mode. # ---------------------------- # Based on: # https://rafaelbarreto.wordpress.com/2009/03/30/controlling-fpu-rounding-modes-with-python/ set_rounding = None get_rounding = None TO_ZERO = None TOWARD_MINUS_INF = None TOWARD_PLUS_INF = None TO_NEAREST = None def _init_libm(): """ ...
true
3777f91abf32720ef647b3594f9fb7c4392fe42e
JavaRod/SP_Python220B_2019
/students/gregdevore/lesson01/assignment/test_unit.py
UTF-8
6,577
3
3
[]
no_license
from unittest import TestCase from unittest.mock import MagicMock from unittest.mock import patch import io from inventory_management.electric_appliances_class import ElectricAppliances from inventory_management.furniture_class import Furniture from inventory_management.inventory_class import Inventory from inventory_...
true
95394b10a4f8b8da3d2d591c04b8c10bdae0c085
VijayEluri/DTDojo
/src/kata10/nwiggins/countlines.py
UTF-8
795
3
3
[]
no_license
''' Created on Dec 12, 2010 @author: nwiggins ''' import re class CountLines(object): def strippedMultiLineComments(self,javaCode): javaCode = re.sub('\/\*.*?\*\/', '', javaCode) return re.sub('/\*([^*]|\*[^/])*\*/', '\n', javaCode,re.MULTILINE) def stripOutLineComments(self,javaCode): ...
true
46ded8e205a6abcabdafb2b2cd6cf6523b7b163b
plasroom46/DesignPattern.Sample
/Python/Samples/Flyweight/CacheFlyweights.py
UTF-8
533
2.625
3
[ "MIT" ]
permissive
from Flyweight_models import Content from ContentFactory import ContentFactory class CacheFlyweights: def __init__(self): self.store = {} self.store["Team"] = ContentFactory.CreateTeam() self.store["Crews"] = ContentFactory.CreateCrews() def add(self, key, value): s...
true
00519ec03815777559003184126cc3ebc5f8266a
JaeZheng/learn_python
/5/5-9.py
UTF-8
188
2.640625
3
[]
no_license
users = ["admin", "Jae", "Kobe", "Alan", "Fri"] if users: print("We need to find some users.") del users[:] if users: print("We need to find some users.") else: print("Blank.")
true
8dfb619ef72727a8d1d79d20e6f52a5702ef3454
mheden/adventofcode2019
/intcode.py
UTF-8
12,090
2.84375
3
[ "MIT" ]
permissive
class Task(): def __init__(self, name, program, inputs=[], ramsize=None, verbose=False): self.name = name self.inputs = [] self.outputs = [] self.verbose = verbose self.regs = {'ip': 0, 'bp': 0} if ramsize is None: self.mem = program.copy() else: ...
true
b5f01bdfbc7e57577dab3a093ebd6a376eb4db7d
erokt/python_scripts
/gui_project.py
UTF-8
2,486
3.0625
3
[]
no_license
#!/usr/bin/python2 #Source of this information comes from the following site. #https://www.tutorialspoint.com/python/python_gui_programming.htm import Tkinter import tkMessageBox import os import sys top = Tkinter.Tk() top.title("PyKeys") #Creating my message box data string. data = """ Hello Everyone\n\nWelcome to...
true
c93269fe0592b6f65760c8db493d9ca02d3923a5
Kristof95/Week-7B-SQL-Task
/7B SQL TASK/SQL_manager.py
UTF-8
3,175
2.78125
3
[]
no_license
import mysql.connector connect_to_db = mysql.connector.connect(user='root', password='root', host='127.0.0.1', database='meetup_db') def list_meetups_for_a_particular_user(): prepare_database = "" try: prepare_database = connect_to_db.cursor(...
true
aaa607feae24176a8947685a65d182bfaaddb4f2
portfoliome/pgawedge
/tests/test_connections.py
UTF-8
742
2.703125
3
[ "MIT" ]
permissive
import unittest from psycopg2.extensions import connection as pg_connection from pgawedge.connections import format_alchemy_url, get_raw_connection from pgawedge.fixtures import AlchemySQLFixture class TestSqlalchemyConnections(AlchemySQLFixture, unittest.TestCase): def test_format_alchemy_url(self): h...
true
8aaba5f6ed2a2731c4d380e784d1036bae076ebb
alex2rive3/practicaPython
/multiplicacionDeEcuaciones.py
UTF-8
144
3.078125
3
[]
no_license
from sympy import * x = symbols('x') y = symbols('y') p1 = poly (4 * x - 7 * x * y) p2 = poly (2 * y + 3 * x) producto = p1 * p2 print(producto)
true
f0907323d3ea73ea54b9e95b13170a19568c3fff
ggppwx/heuristic-problem-solving-
/src/mint.py
UTF-8
6,377
2.875
3
[]
no_license
import time import sys costMap = {} costMap[0] = 0 costMap[100] = 0 final = {} combination = {0:[0,0,0,0,0], 100:[0,0,0,0,0]} def cost(d1, d2, d3, d4, d5): # d1 - d5: the denomination costMap[1] = 1 combination[1] = [1,0,0,0,0] for price in range(2,100+d5): minCost = 100 ...
true
a2d8980bd1861111f8ec84edd4ea634c6de6ae00
Garima16/visual-genome-visualisation
/position_in_1region.py
UTF-8
890
3.109375
3
[]
no_license
import json # preps in which 1st object has greater z value than 2nd deeper_preps = [' behind ', ' against ', ' inside ', ' back '] # 1st has lower z value shallower_preps = [' outside ', ' front ', ' in front of '] with open('subset_data\\region_graphs.json') as region_graph: data = json.load(region_gr...
true
e46330c7a71f0f10da207b1f8bead7ad794ebd12
lonewarrior556/Project_Euler
/euler69.py
UTF-8
1,230
3.125
3
[]
no_license
import pickle f=open('primes.txt') primes=pickle.loads(f.read()) def filter(ls): ls2=[] for x in ls: if x<1000001: ls2.append(x) else: return ls2 primes=filter(primes) primeset=set(primes) f.close() def factorout(n,x): if n%x!=0: return n else: return fact...
true
54385c5da458e7fa2957f6199c56f8af7c0f5d85
lzkmylz/learnCUDA
/mandelbrot_set.py
UTF-8
1,389
3.1875
3
[]
no_license
# -*- coding: UTF-8 -*- import numpy as np from time import time import matplotlib matplotlib.use('Agg') from matplotlib import pyplot as plt def simple_mandelbrot(width, height, real_low, real_high, imag_low, imag_high, max_iters, upper_bound): # np.linspace返回给定区间内按一定间隔分布的数 real_vals = np.linspace(real_low, ...
true
c330a4a7826c721b6615f7533306061cda5f9216
jagolinux-com/segitiga
/modularisasi.py
UTF-8
867
3.921875
4
[]
no_license
""" Menghitung luas segitiga Alas x Tinggi / 2 """ print ("Menghitung luas segitiga 1") alas = 10 tinggi = 6 luas_segitiga = alas * tinggi / 2 print(f'segitiga dengan alas = {alas} dan tinggi ={tinggi} memiliki luas {luas_segitiga}\n') print("Menghitung luas segitiga dengan copas dari segitiga 1") alas = 50 tinggi = ...
true
653f4e636219c1cd809eed9765127b4169cc05ef
jvalen92/Analisis-Numerico
/tarea1/epsilon.py
UTF-8
183
2.828125
3
[]
no_license
import math #Siguiendo el algortimo planteado en el libro podemos encontrar el epsilon de la maquina D=0.5 while 1 != 1+D: #mientras 1 sea diferente de 1+D print(D) D=D/2
true
8433d5889703eab14662bd5cb6d463fc8526f97c
MohamedNagyMostafa/ComputerVision_IntroProjects
/main.py
UTF-8
2,281
2.859375
3
[]
no_license
import cv2 import numpy as np import matplotlib.pyplot as plt #cv2.IMREAD_UNCHANGED #cv2.IMREAD_COLOR #cv2.IMREAD_GRAYSCALE src= 'images/me.jfif' title = 'my image' def intensity(img1, img2, alpha): return alpha * img1 + (1- alpha) * img2 def intensity_sub(img1, img2, alpha): return np.abs(alpha * img1 - (1- alpha...
true
1c3dea59fed06f5dd5d016ba8686d00741410709
simplewebby/Python_dictionary
/fall_2015.py
UTF-8
2,014
3.625
4
[]
no_license
#1 var = 0 num = 1 for i in range(3): if i%2 == 0: num *= -1 var += num print(var, end = ' ') #2 scary = 'boo! boo!' place = 0 while place <= len(scary): current = scary[place] print(current, end='') place += scary.count(current) #3 eap = 'rapping, rapping' print(eap[:4] + eap[-4:]...
true
fbc3cd8a5e1aecb10cacb875a625ef09b5275b44
nava45/problems
/python/binary_search.py
UTF-8
1,066
3.859375
4
[]
no_license
def binary_search(slist, item): first = 0 last = len(slist) found = False while first < last and not found: middle = (first+last) // 2 if slist[middle] == item: found = True else: if slist[middle] < item: first = middle else:...
true
46b24ce73a45406be9b83a811f79d8e225527ec7
antoine-lombardo/pybdinfo
/test.py
UTF-8
2,330
2.625
3
[]
no_license
from pybdinfo import BDInfo, Report from tqdm import tqdm import os, platform, sys, progressbar pbar = None data_dir = None if platform.system() == 'Windows': data_dir = 'D:\\' elif platform.system() == 'Linux': data_dir = '/media/ferb/Data/' if not data_dir: sys.exit() iso_file = os.path.join(data_dir, '...
true
e92fbd16b058319e74c3de1ee7b5f1ea51814904
jkmiao/leetcodex
/python/332_reconstruct_ltinerary.py
UTF-8
2,311
3.890625
4
[]
no_license
#!/usr/bin/env python # coding=utf-8 """ Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK. Thus, the itinerary must begin with JFK. Note: If there are multiple valid itine...
true
6eed09569556b9a54494ba324e25232636c6c0d0
Santidnp/Taller4_imagenes
/Clases.py
UTF-8
6,885
3.0625
3
[]
no_license
""" Autores: Laura Juliana Ramos Maldonado, Santiago Nicolás García Herrera """ # Cargar librerias import cv2 import numpy as np import random import math import sys from enum import Enum from hough import Hough from gradient_map import gradient_map class Methods(Enum): # Creación clase metodos Standard = ...
true
60e7eca7e42b691bd9dad1c1db95f213fba7f1f5
nixoldb86/packlink
/commons/selenium_utils.py
UTF-8
2,845
3.28125
3
[]
no_license
# -*- coding: utf-8 -*- from selenium import webdriver from selenium.common.exceptions import TimeoutException, NoSuchElementException import selenium.webdriver.support.ui as ui __author__ = 'nixoldb86' class SeleniumUtils(object): """ Class with some basic utilities for getting started with the selenium el...
true
e8f779b19f3335c3075e4f4f22dd2c573ebcf9ab
krsrv/word2vec
/src/model.py
UTF-8
1,516
3.078125
3
[]
no_license
# # # Codebase copied from https://towardsdatascience.com/learn-word2vec-by-implementing-it-in-tensorflow-45641adaf2ac # # import tensorflow as tf class model: def __init__(self, vocab_size, embed_dim): self.x = tf.placeholder(tf.float32, shape=(None, vocab_size)) self.y_label = tf.placeholder(tf....
true
2af756e0730dc68d0c655d5d45ec2a7b77fdc518
datakortet/dkfileutils
/dkfileutils/path.py
UTF-8
11,360
2.890625
3
[ "MIT" ]
permissive
# -*- coding: utf-8 -*- """Poor man's pathlib. (Path instances are subclasses of str, so interoperability with existing os.path code is greater than with Python 3's pathlib.) """ # pylint:disable=C0111,R0904 # R0904: too many public methods in Path from __future__ import print_function import os import re from c...
true
ffe1c1733988c48a36e862aa0dc1905ae45cc7eb
AbhinavUtkarsh/Code-Chef
/Cleaning Up/Cleaning Up.py
UTF-8
528
3
3
[]
no_license
#https://www.codechef.com/problems/CLEANUP for i in range(int(input())): #n not completed n,m=map(int,input().split()) jobs_done=list(map(int,input().split())) chef=[] assis=[] flag=0 for i in range(1,n+1): if i not in jobs_done and flag==0: chef.append(i) fla...
true
ad2df1c4cb4d4cb086e3f79f6482e7e8f388ab7f
Ralfe15/FPRO-2020
/REs/4: Functions/perfect.py
UTF-8
197
3.40625
3
[]
no_license
def is_perfect(n): res = 0 if n <= 0: return False for i in range(1,n): if n%i==0: res += i if n==res: return True else: return False
true
ae161f9e6cf3b9c4023c7219de30581d8160c405
thatthyguy/catalog
/main.py
UTF-8
283
2.984375
3
[]
no_license
import os, sys def full_file_listing(directory): for f in os.listdir(directory): if ".pdf" in f: print os.path.join(directory, f) if __name__ == '__main__': directory = str(sys.argv[1]) print "Listing files now..." full_file_listing(directory)
true
cdd0042a23c038745ef64355a35c0e3c8aadbf72
laurynasas/logistic-classifier-for-TMA-analysis
/logistic_regression.py
UTF-8
5,350
3.140625
3
[]
no_license
import csv import math import time import numpy as np import itertools ''' Sigmoid function in order to map values into range of [0,1] ''' def sigmoid_function(w, X): unbounded_prob_function = np.dot(X, w) return float(1) / (1 + math.e ** (-(unbounded_prob_function))) ''' Gradient calculation ''' def ...
true
30bca278f2d8c013478aa4860d0ce873d2fccfa5
21lucasmessias/CursoEmVideo-Python
/ex074.py
UTF-8
478
4.09375
4
[]
no_license
from random import randint, sample numeros = (randint(0, 10), randint(0, 10), randint(0, 10), randint(0, 10), randint(0, 10)) print('Os valores sorteados foram: ', end='') for numero in numeros: print(f'{numero}', end=' ') print(f'\nO maior valor sorteado foi: {max(numeros)}') print(f'O menor valo...
true
b30c503189f462298e445fee8d40b7bf059ef4bb
alessandro308/FogDirMime
/app_manager.py
UTF-8
10,183
2.953125
3
[ "Apache-2.0" ]
permissive
import random as rnd import numpy as np import json from infrastructure import * class Deployment(): def __init__(self, app_id, app_description): self.app_id = app_id self.app_description = app_description self.deployment = {} self.things_binding = {} class AppManager(): def...
true
e9e5b6c67c04d67f04554c2fbf28d2bba74a158c
shimizukawa/pycon2015-autodoc-sample
/deep_thought/api.py
UTF-8
1,045
3
3
[]
no_license
"APIs" class Request(object): """ .. seqdiag:: { code [label="Your Code"]; lib [label="Library"]; site [label="Web Site"]; code -> lib [label="Request(url)"]; code <-- lib [label="req"]; code -> lib [label="req....
true
dfbfd2de7e3f2a5f50fa2460304d740453eaee72
VakinduPhilliam/Python_SQLite_API
/Python_SQLite_API_Connection.py
MacCentralEurope
931
3.25
3
[]
no_license
# Python SQLite API # sqlite3 DB-API 2.0 interface for SQLite databases # SQLite is a C library that provides a lightweight disk-based database that doesnt require a separate server process and allows # accessing the database using a nonstandard variant of the SQL query language. # Some applications can use SQLite...
true
2f07e350ee0b76494b97eef8243ac33c87ea2902
tristan-jl/enigma_simulator
/enigma_simulator/enigma.py
UTF-8
4,011
2.53125
3
[ "MIT" ]
permissive
from __future__ import annotations import numpy as np from enigma_simulator.components import get_reflector from enigma_simulator.components import get_rotor from enigma_simulator.components import Plugboard from enigma_simulator.key import EnigmaKey from enigma_simulator.utils import char_to_int from enigma_simulato...
true
a2662797617e5ebc988d6db28cb4bb3b37c91594
nnamon/sortstuff
/bubblesort/bubblesort.py
UTF-8
2,513
3.71875
4
[]
no_license
#!/usr/bin/python def bubblesort(data): profile = {'outer': 0, 'compare': 0} work = list(data) for i in range(1, len(work)): profile['outer'] += 1 for j in range(len(work)-i): profile['compare'] += 1 if work[j] > work[j+1]: work[j], work[j+1] = work[j...
true
e712bf49a1f81142c4a71d3f3da87783692d98e3
liusu169/SPA
/mungebb.py
UTF-8
578
2.90625
3
[]
no_license
import csv import re def fix(s): while '<' in s: s=s[:s.index('<')]+s[s.index('>')+1:] s=re.sub('[^0-9]','',s) s=s[:4] return s fileid = open('prefs-fixed.csv', mode='rb') reader = csv.reader(fileid) for row in reader: if len(re.sub('[^0-9]','',row[0]))==8: c=list() t=0 for...
true
1f2b39ab3543f6189ca77da487b432516ec3230a
kiranpdas/calc
/tests/test_calc.py
UTF-8
569
2.984375
3
[]
no_license
import unittest from src.calc import add, sub, mult, div class TestCalc(unittest.TestCase): def setUp(self): self.__x, self.__y = 3, 2 def test_add(self): self.assertEqual(add(self.__x, self.__y), 5) def test_sub(self): self.assertEqual(sub(self.__x, self.__y), 1) self.a...
true
37fb54523928ee6e356d95614ed52e4409f6d08e
cassio12/primeiros-passos-no-Python
/desafio19.py
UTF-8
282
3.078125
3
[]
no_license
''' 1-escreva um programa q armazene uma lista com o titulo dos conteudos q já aprendemos. ''' lista = ['for', 'função', 'imput', 'print', 'srt', 'int', 'float', 'if', 'else', 'elif', 'and', 'or', 'def', 'min', 'max', 'sorted', 'while', 'random', 'break', 'renge'] print(lista)
true
2cfb8e3b73902c682db0ba4b979ca526341b0cbc
Necctares/MC920
/Trabalho 4/compHist.py
UTF-8
1,160
2.765625
3
[]
no_license
import sys import cv2 import numpy as np from skimage import feature def compareHistChiSqr(image1, image2): lbp = feature.local_binary_pattern(image1, 8, 1) lbp = np.float32(lbp) lbp_hist = cv2.calcHist([lbp],[0],None,[256],(0,256)) lbp_hist /= lbp_hist.sum() + 1e-9 lbp2 = feature.local_binary_pattern(image...
true