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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
013a97892737822d0f7cfff4a04938da82750368 | Python | duanbibo/test_demo | /case/httprun/debugtalk.py | UTF-8 | 381 | 3.265625 | 3 | [] | no_license | import random
def get_number(num):
list_nu=[]
zero=0
while zero<num:
list_nu.append(random.randint(1,999))
zero+=1
else:
return list_nu
#利用匿名函数和map 再进行过滤
# pf=map(lambda x:x*2 ,get_number(5))
# print(pf.__next__(),pf.__next__(),pf.__next__(),pf.__next__(... | true |
54d1ce4a22241943c1bf23f9efb8c3dac38cc515 | Python | Milstein-Corp/codecomp | /template/sample.py | UTF-8 | 1,270 | 2.78125 | 3 | [] | no_license | import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict
# available on Google, not available on Codeforces
# import numpy as np
# import scipy
def solve(): # fix inputs here
console("----- solving ------")
# return a string (i.e. not a list or matrix... | true |
060b3f1d05ae13ca899446fab03b2b43d5089d4d | Python | veb-101/Coding-Practice-Problems | /CodeSignal Challenges/challenge_22.py | UTF-8 | 1,311 | 4.1875 | 4 | [] | no_license | # https://app.codesignal.com/challenge/zA4ckXkvYQQ8Zitys
'''
You are given a positive integer x and you should perform n operations, where on the ith operation you increase x in such a way that its new value is divisible by i (operations are numbered from 1 to n).
Find the minimal value of x you can obtain by performi... | true |
20cda5c2999d9034c1ba000286ead671e51280e2 | Python | bokorn/voxlets | /src/common/mesh.py | UTF-8 | 9,714 | 2.703125 | 3 | [] | no_license | import numpy as np
#https://github.com/dranjan/python-plyfile
from skimage.measure import marching_cubes
class Camera(object):
pass
class Mesh(object):
'''
class for storing mesh data eg as read from a ply file
'''
def __init__(self):
self.vertices = []
self.faces = []
self... | true |
9a2aa71877888e4c6d734d4b3eb604a9ad1fafeb | Python | neelabh17/BadaNumPy | /Seive.py | UTF-8 | 262 | 3.453125 | 3 | [] | no_license | def sieve(n):
a=[i for i in range(n+1)]
# print(a)
i=2
while(i*i<=n):
j=2
#Deleting elements
while(i*j<=n):
a[i*j]=0
j=j+1
#Find next value for i
i=i+1
while(a[i]==0 and i<=n):
i+=1
print(a)
n=input()
sieve(int(n))
| true |
58e946be538bb8905dc44b2d4e660627617156e1 | Python | ryedunn/Sudoku_Solver | /Sudoku_Solver.py | UTF-8 | 3,363 | 4.21875 | 4 | [] | no_license | import time
iterations = 0
# Simple program in Python to solve a Sudoku puzzle using Recursion and backtracking
# Format and display the Sudoku puzzle familiar to the end user
def display(sudoku):
print("\n+-----------------------+")
for i in range(9):
if i % 3 == 0 and i != 0:
print("|-... | true |
aebe7687e047e939349d8e128b71a709dde3faca | Python | jacksonlo/sentrycloud | /main.py | UTF-8 | 1,376 | 2.546875 | 3 | [] | no_license | import argparse
import os
from config import cache_file_name, token, sentry_url
from data import get_data, create_word_cloud, count
from log import logger
import logging
def main():
if token is None:
logger.error('Missing env variable "sentrycloudtoken"')
return
if sentry_url is None:
... | true |
5688ce95ba486f32f1443032fd9a79ac25e45be6 | Python | bendevera/cs-module-project-iterative-sorting | /src/iterative_sorting/iterative_sorting.py | UTF-8 | 2,297 | 4.34375 | 4 | [] | no_license | # TO-DO: Complete the selection_sort() function below
def selection_sort(arr):
# loop through n-1 elements
for i in range(0, len(arr) - 1):
cur_index = i
smallest_index = cur_index
# find next smallest element
for j in range(i+1, len(arr)):
if arr[j] < arr[smallest_in... | true |
64b0d2898c50f56c3fb06e11295468a68a34692b | Python | VertikaD/HackerRank | /Practice/30 Days Of Code/Day11FinalAlgo.py | UTF-8 | 1,312 | 3.796875 | 4 | [] | no_license | #code by Vertika Dhingra.
matrix = [
[1, 2, 3, 4, 5, 6],
[9, 8, 7, 6, 5, 4],
[3, 4, 5, 4, 5, 6],
[9, 8, 7, 6, 5, 4],
[1, 2, 3, 4, 5, 6],
[9, 8, 7, 6, 5, 4],
]
# this function is optimises the code.
def all_hour_glasses(p, q):
# this function calculates sum of all 16 hourgl... | true |
72f91955946979edf334b7d4e077079d2eb00694 | Python | Bartor/python-uczelnia | /lista3/1.py | UTF-8 | 223 | 3.421875 | 3 | [] | no_license | def transposeFunnyMatrix(matrixArray):
return [" ".join(row.split(" ")[column] for row in matrixArray) for column in range(len(matrixArray))]
print(transposeFunnyMatrix(["1.1 2.2 3.3", "4.4 5.5 6.6", "7.7 8.8 9.9"]))
| true |
ed3f3f44c206b335dcfaf6f927d41cc1715870d0 | Python | silverbowen/COSC-1330-Intro-to-Programming-Python | /William_Bowen_lab5a.py | UTF-8 | 4,140 | 4.4375 | 4 | [] | no_license | ## define main
def main():
## user input begins here - miles first
miles = float(input('How many miles would you like to convert? '))
## set errorcount
errorcount = 0
## check for errors and repeat input if needed
## up to three times, then kaput
while miles < 0 and errorcount != 2:
... | true |
e32e6fafce2a8f30024c85739e18ca614062ccd4 | Python | tgz/51ape_artist_all_music_fetch | /51ape.py | UTF-8 | 1,575 | 2.921875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import sys
import requests
from bs4 import BeautifulSoup
page_encode = 'utf-8'
reload(sys)
sys.setdefaultencoding('utf-8')
def select_item_list(base_url, page_count, file_name):
file = open('{}.txt'.format(file_name),'w')
for index in range(1,page_count+1):
url = '{}/index_{}... | true |
cfe5cd973b5cfedc014f92dded0aadaf038ee31a | Python | MANOJPATRA1991/Cracking-the-coding-interview-solutions-in-Python | /Trees_and_Graphs/Problem-9/sol.py | UTF-8 | 2,130 | 3.875 | 4 | [] | no_license | # Algorithm to print all paths which sum to a given value
# Run time complexity = O(n*log(n))
# Space complexity = O(log n)
from Trees_and_Graphs.tree.main import BinaryTree
import sys
def depth(node):
"""
Helper function to find the depth of a tree
Args:
node(BinaryTree): The tree whose depth to... | true |
0d0d500ff143dfd1b580f62e48423dbfe8eb34cc | Python | bharatadhikari88/python | /market/py/extractorJob.py | UTF-8 | 667 | 2.953125 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
### Extract stock prices. every day, five day a week@ 4pm
import os
import schedule
import time
from Extractor import Extractor
def runExtractor():
Extractor().extract()
schedule.every().monday.at("16:00").do(runExtractor)
schedule.every().tuesday.at("16:00").do(... | true |
58048dc5d80bbbcb2657538b10b481864210f4a1 | Python | ronaldjuarez/bmen689_group2 | /ROC.py | UTF-8 | 3,194 | 2.6875 | 3 | [] | no_license | print(__doc__)
import numpy as np
from numpy import genfromtxt
from scipy import interp
import matplotlib.pyplot as plt
import os
from sklearn import svm, datasets, preprocessing
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import roc_curve, auc
from sklearn.model_selection import Stratifi... | true |
a1734da54d701288e5e3f937c4546e4db58bed33 | Python | f4b4nd/jo_scrapper | /journalofficiel/savefile.py | UTF-8 | 854 | 2.75 | 3 | [] | no_license | import os
from journalofficiel.alerts import Alert
class SaveFile:
def __init__(self, dirpath, filename, content):
self.dirpath = dirpath
self.filename = filename
self.content = content
self.filepath = dirpath / filename
@staticmethod
def create_dir(dirpath):
... | true |
862de8611d69f6dff0e86c7fbd7dfa6abaa03083 | Python | rohanchidrewar05/sudoku-solver-using-IP | /image_processor.py | UTF-8 | 5,347 | 2.984375 | 3 | [] | no_license | import matplotlib.pyplot as plt
import numpy as np
import math
import operator
import os
import cv2
import sys
def getcontourorder(contour):
# Used to map the contour to the correct position in the array
loc = cv2.boundingRect(contour)
return math.floor(loc[1]/20)*2000+loc[0]
def l2_dist(pt1,pt2):
# Calculates th... | true |
38582bca142960e852de0445e04d76afb018a1fb | Python | Jattwood90/DataStructures-Algorithms | /1. Arrays/4.continuous_sum.py | UTF-8 | 435 | 3.953125 | 4 | [] | no_license | # find the largest continuous sum in an array. If all numbers are positive, then simply return the sum.
def largest_sum(arr):
if len(arr) == 0:
return 0
max_sum = current = arr[0] # sets two variables as the first element of the list
for num in arr[1:]:
current = max(current+num, n... | true |
00c2cf8c612105be727372cd8c4376ad119d9180 | Python | shaswataddas/HackerRank | /Algorithms/Recursion/Recursive_Digit_Sum.py | UTF-8 | 431 | 2.921875 | 3 | [] | no_license |
import math
import os
import random
import re
import sys
def superDigit(n, k):
sd = sum(int(s) for s in n)
if sd*k < 10:
return sd*k
else:
return superDigit(str(sd*k), 1)
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
nk = input().split()
n = ... | true |
3788e854951913d5b68ae3701195b452ffcca239 | Python | ephraimschnaidman/55Coder | /KiloConverter.py | UTF-8 | 663 | 3.234375 | 3 | [] | no_license | from tkinter import *
window=Tk()
def kg_to_gram_lbs_oz():
gram=float(kg_value.get())*1000
t1.insert(END,gram)
lbs=float(kg_value.get())*2.20462
t2.insert(END,lbs)
oz=float(kg_value.get())*35.274
t3.insert(END,oz)
t0=Label(text='Enter Kg value:')
t0.grid(row=0,column=0)
kg_value=StringVar()
... | true |
8a681979de3f23a6ed52b344a17b7985eb5fec4c | Python | ceciliaAI/mmfashion | /mmfashion/models/losses/triplet_loss.py | UTF-8 | 1,686 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | import torch.nn as nn
import torch.nn.functional as F
from ..registry import LOSSES
@LOSSES.register_module
class TripletLoss(nn.Module):
def __init__(self,
method='cosine',
ratio=1,
margin=0.2,
use_sigmoid=False,
reduction='me... | true |
9d81640024fdd1c17407ebbefb5acbf9d3e3a3f7 | Python | Sharpiless/baby-voice-recognition | /data_all.py | UTF-8 | 2,694 | 2.625 | 3 | [] | no_license | import os
import wave
import librosa
import numpy as np
from tqdm import tqdm
import pickle as pkl
import librosa
from sklearn.preprocessing import normalize
import config as cfg
def pitch_shift_spectrogram(spectrogram):
""" Shift a spectrogram along the frequency axis in the spectral-domain at
random
"""
... | true |
e7083392f07e0eb63bd1f9f4c03bac3ab158cb69 | Python | SATABDA0207/College | /Sem_3/numerical_methods/NM_lab/all/graph.py | UTF-8 | 3,491 | 2.5625 | 3 | [] | no_license | import matplotlib.pyplot as plt
#bisection method---------------------------------------------
file = open("./data/bisection","rb")
data=file.read()
data=data.split()
for i in range(len(data)):
data[i]=data[i].split(',')
ite=[]
error=[]
for i in range(len(data)):
ite.append(data[i][0])
error.append((float)(d... | true |
f2b965c412c799135a4581c3088bfd9fd62db730 | Python | SantoGmz/Python | /condiciones.py | UTF-8 | 379 | 3.453125 | 3 | [] | no_license | # https://www.youtube.com/watch?v=iV-4F0jGWak&list=PLU8oAlHdN5BlvPxziopYZRd55pdqFwkeS&index=10
print("Programa de evaluacion de notas de alumnos")
nota_Alumno=input("Introduce la nota del alumno: ")
def evaluacion(nota):
valoracion="aprobado"
if nota<5 :
valoracion="Suspendido"
return valoracion... | true |
a433e1ce046dda304d7cb1a0324b189b9fb1b151 | Python | yudaikobayashi/MyAvatar | /createMyAvatar.py | UTF-8 | 2,101 | 2.953125 | 3 | [] | no_license | import sys
import numpy as np
import cv2
def main():
"""This program will create my avatar image."""
if len(sys.argv) != 3:
print("Usage: python3", sys.argv[0], "<output.png> <size>")
sys.exit(1)
if getExtension(sys.argv[1]) != "png":
print("Specify .png files.")
sys.exit(1)... | true |
8a4e76b557a2aa72428f88933e57ad7da6a058e6 | Python | charlesed/py-scripts | /Python2/update_dyndns_iptables.py | UTF-8 | 1,256 | 2.625 | 3 | [] | no_license | #!/usr/bin/env python2
import os
import socket
dyndns_host = ""
dyndns_log = "/tmp/dynip.log"
local_ip = ""
tcp_ports = ('22',)
udp_ports = ()
def updatelog(file, new_ip):
file.write(new_ip)
print "Log updated with new IP", new_ip
file.close()
def updateiptables(old_ip, new_ip):
print "Updating ipta... | true |
0b1abb7781602c410a5cb424f0790079ade00fef | Python | hagarwa3/self_driving_rc_car | /neural_nets/nonblocking_keypress.py | UTF-8 | 952 | 2.984375 | 3 | [] | no_license | import termios
import fcntl
import sys, os
def get_char_keyboard_nonblock():
"""
Example of a non-blocking keypress in python from
http://stackoverflow.com/questions/13207678/whats-the-simplest-way-of-detecting-keyboard-input-in-python-from-the-terminal
"""
fd = sys.stdin.fileno()
oldterm = t... | true |
9a03678e6b3ef5781175fd457e94d0e22bc59db9 | Python | tpt5cu/python-tutorial | /language/python_27/control_statements/if_statement.py | UTF-8 | 558 | 4.25 | 4 | [] | no_license | def compound_comparison(x):
'''Compound comparisons like this are not valid in other languages, but are valid in Python'''
if 1 < x < 5:
print(x)
else:
print(False)
def if_statement_variable():
'''There is no such thing as an if-statement variable. Check the surrounding context for the... | true |
cdf1b6166ee89b5ba3a820c1b1af7bfa2abc040f | Python | AdamMiltonBarker/Acute-Myeloid-Leukemia-Classifier-2021 | /modules/model.py | UTF-8 | 2,534 | 2.53125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
""" Class representing a AI Model.
Represents a AI Model. AI Models are used by AI Agents to process
incoming data.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without re... | true |
2394e09b50b44855797d5e5b63ea37203b031cf5 | Python | Aasthaengg/IBMdataset | /Python_codes/p02726/s751642668.py | UTF-8 | 239 | 3 | 3 | [] | no_license | import collections
N,x,y=map(int,input().split())
lit=[]
for i in range(1,N+1):
for j in range(i+1,N+1):
lit.append(min(abs(i-j),abs(x-j)+abs(y-i)+1,abs(y-j)+abs(x-i)+1))
a=collections.Counter(lit)
for i in range(1,N):
print(a[i]) | true |
ce2b2c339d1c5aa6105ebfcaab5069b2050b27d6 | Python | AisosaUtieyin/Contact-Book | /db.py | UTF-8 | 1,205 | 2.984375 | 3 | [] | no_license | import sqlite3
# connect to database
conn = sqlite3.connect('contactbook.db')
# create a cursor
c = conn.cursor()
# create table
c.execute(""" CREATE TABLE IF NOT EXISTS contacts_book (
number integer,
name text
... | true |
a588268bf3b100438bd3f3f65649add7eb5dd0be | Python | wimpywarlord/hacker_earth_and_hacker_rank_solutions | /Minimum Number.py | UTF-8 | 358 | 2.703125 | 3 | [] | no_license | t=int(input())
for i in range(0,t):
z=input()
n,k,q=z.split()
n=int(n)
k=int(k)
q=int(q)
ll=input()
l=ll.split()
for j in range(0,len(l)):
l[j]=int(l[j])
jump=n//k
p=[]
for j in range(0,len(l)):
p.append([])
for k in range(j,j+jump):
p[j].a... | true |
127649e2e2e6e5e516cf3d9d7b1abf1df61467ce | Python | CR7WO/TextClassification | /Sentibycharcnn/config.py | UTF-8 | 1,479 | 2.5625 | 3 | [] | no_license | import pandas as pd
config = {}
class TrainingConfig(object):
p = 0.9
base_rate = 1e-2
momentum = 0.9
decay_step = 15000
decay_rate = 0.95
epoches = 10
evaluate_every = 100
checkpoint_every = 100
class ModelConfig(object):
conv_layers = [[256, 7, 3],
[256, 7, 3]... | true |
559b93495691d9a9ed9857b6adab502c51b0a273 | Python | mrizvic/py-smsnexmo | /smsnexmo.py | UTF-8 | 3,632 | 2.578125 | 3 | [] | no_license | #!/usr/bin/python
import sys
import urllib
import urllib2
import json
import re
import argparse
def read_message(text):
if (text != 'NULL'):
return text
while True:
print "Type your message in one line:"
msg = sys.stdin.readline().strip()
msglen = len(msg)
if (msglen < 1):
print "message too short"
... | true |
2cffa90d44a03f3c488c0bd7cc93f7c28a122c89 | Python | istng/Algo3-TP1 | /tests/creador.py | UTF-8 | 1,378 | 3.4375 | 3 | [] | no_license | #!/usr/bin/python
import random
import math
def encuesta(cantidadAgentes, cantidadVotos):
votosPosibles = []
for i in range(1,cantidadAgentes+1):
for j in range(1,cantidadAgentes+1):
votosPosibles.append((i,j))
votosPosibles.append((i,-j))
print(str(cantidadAgentes) + " " + ... | true |
592ec779ed6e33016aec789dfd0c4bd93498ad2f | Python | NimrodCarmon/isofit | /isofit/test/test_common.py | UTF-8 | 286 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | import numpy as np
from isofit.core.common import eps, combos
def test_eps():
assert eps == 1e-5
def test_combos():
inds = np.array([[1, 2], [3, 4, 5]])
result = np.array([[1, 3], [2, 3], [1, 4], [2, 4], [1, 5], [2, 5]])
assert np.array_equal(combos(inds), result)
| true |
1c32798b5aa8e5365563141a0be50b088cbff6c4 | Python | BlackVS/Hackerrank | /WoC/34/Same Occurrence.py | UTF-8 | 1,977 | 2.75 | 3 | [
"MIT"
] | permissive | #!/bin/python3
import sys,copy
from collections import *
from itertools import *
from functools import lru_cache
from operator import sub
from heapq import *
from sys import stdin
input = stdin.readline
#sys.stdin = open('G:\hackerrank\WoC\\34\\3. Same Occurrence\\t1.txt', 'r')
N, Q = map(int, input().strip().split())... | true |
2a53f27f9bc5b78b0b59e5d30bb94cde71286e35 | Python | harshraj11584/EE2340_Information_Science | /MA17BTECH11003_Program.py | UTF-8 | 1,491 | 3.15625 | 3 | [] | no_license | import itertools
import numpy as np
import matplotlib.pyplot as plt
from math import *
from tkinter import *
from scipy.stats import bernoulli
epsilon=0.075; n=100; Pn_found = []
H=(0.25*log(1/0.25,2))+(0.75*log(1/0.75,2)) #this is the entropy H(X)
while n<=700:
non_epsilon_typical_vectors_found = ... | true |
103a50e02bd0473edb493376052cc9e11dbe94d9 | Python | OlavBerg/Text_based_python_game | /shield.py | UTF-8 | 405 | 3.015625 | 3 | [] | no_license | from item import Item
class Shield(Item):
def __init__(self, protection: int):
super().__init__()
self.protection = protection
def getProtection(self):
return self.protection
def upgrade(self):
self.protection += 1
def downgrade(self):
self.protection -= 1... | true |
d6bbc6ebd1a97fa27907fee67d621c15717ca8d5 | Python | BjornAPRtec/PiMakers | /MeasuringSessionUI.py | UTF-8 | 13,424 | 2.578125 | 3 | [] | no_license | from PyQt5 import QtWidgets, QtCore, QtGui
import configInterface
import configparser
import Communication
import inspect
class Channelsettings(QtWidgets.QWidget):
backPressed = QtCore.pyqtSignal()
okPressed = QtCore.pyqtSignal() # Custom pyqt signals
def __init__... | true |
285846ad9f2da0a9881902fa6a653c8bf7e19f36 | Python | rd37/KaleidoscopePubSub | /pubsub/utils/tools.py | UTF-8 | 1,827 | 2.8125 | 3 | [] | no_license | '''
Created on Feb 11, 2015
@author: ronaldjosephdesmarais
'''
from websockets.api.ws_api import PubSub_WS_API
#Subscriber queue for polling
import thread
class WSSubscriberMessageQueue(object):
def __init__(self,sub_ws_id):
self.sub_ws_id=sub_ws_id
#self.queue = []
def send(self,ms... | true |
a026c29705c399f4c947020c81c2d19204b097f6 | Python | ivuk/whensus | /whensus.py | UTF-8 | 9,441 | 3.0625 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python3
import argparse
from datetime import timedelta, datetime
from glob import glob
"""matplotlib gets imported when needed"""
from time import strptime, mktime
def OpenFile(InputFile):
"""Try to open the data file, raise an error if opening fails"""
try:
InputData = open(InputFile... | true |
70a56d5d5b470f676c061e4a2a96a1a2e7ad4fa0 | Python | cjuub/advent-of-code | /2019/16/aoc16.py | UTF-8 | 981 | 2.9375 | 3 | [] | no_license | #!/usr/bin/env python3
with open('input.txt') as fp:
lines = fp.readlines()
base_p = [0, 1, 0, -1]
inp = lines[0].strip()
for phase in range(100):
new_list = []
for k in range(len(inp)):
p = []
for i in range(len(inp)):
for j in range(len(new_list) + 1):
p.app... | true |
11ccdf610542ceaf39f543cb79d853ba234318a5 | Python | ErykKrupa/python-course | /list3/task5.py | UTF-8 | 432 | 3.171875 | 3 | [
"MIT"
] | permissive | def all_subsets(list_):
# functional syntax
# return [[]] if len(list_) == 0 else \
# list(map(lambda i: [list_[0]] + i, all_subsets(list_[1:]))) + all_subsets(list_[1:])
if len(list_) == 0:
return [[]]
head = [list_[0]]
subsets = all_subsets(list_[1:])
return list(map(lambda i: ... | true |
8b07ddb68b705c6304787d94532b8fddebbb8a23 | Python | evicy/semestral_project | /DrawErrors.py | UTF-8 | 1,983 | 2.828125 | 3 | [] | no_license | import scipy.stats as st
import Discretize as disc
import DistributionData as dist_data
import matplotlib.pyplot as plt
import DataForDrawing as DataForDrawing
import DistributionTuple as dTuple
def drawErrors(data_for_drawing):
# Funkcia, ktora vykresli pre kazdu distribuciu errory
# ako parameter dostane ob... | true |
e7058792a052ce1721d951dde194715abc777664 | Python | 0csong/baekjoon | /백준 2293.py | UTF-8 | 213 | 2.703125 | 3 | [] | no_license | n, k = map(int, input().split())
c=[int(input()) for i in range(n)]
dp=[0 for i in range(k+1)]
dp[0]=1
for i in c:
for j in range(i,k+1):
if j-1>=0:
dp[j]+=dp[j-i]
print(dp[k])
| true |
b332748e86911f18d969f4b2fcbe0e218233f6d8 | Python | SeanBrunson/mortgages | /mortgages/mbs.py | UTF-8 | 5,253 | 3.53125 | 4 | [
"MIT"
] | permissive | # Class to calculate stylized version of MBS value with prepayment:
import numpy as np
def calc_smm(coupon_rate, market_rates):
"""
Calculates the single monthly mortality rate (smm) given the
coupon rate and market rate. Uses the Richard and Roll (1989)
prepayment model.
Parameters
--------... | true |
2994790b91d35b4d17c02bca6fe5732d5b8262e0 | Python | pgtiegs/dmilo | /posertypes/posertypes_test.py | UTF-8 | 1,663 | 2.96875 | 3 | [] | no_license | import sys
import unittest
import posertypes
class TagParserTest(unittest.TestCase):
def testInit(self):
testTagParser = posertypes.TagParser()
self.assertFalse(testTagParser.dropSingletons)
self.assertTrue(len(testTagParser.ignoreWords) == 0)
del testTagParser
testTagParser = posertypes.TagParser(dropSin... | true |
94ca44a90485a78192472828bfc003829f6a2611 | Python | Aleottau/python | /def_3.py | UTF-8 | 947 | 4.5 | 4 | [] | no_license | #Actividad 2
#
#Escribamos una función numAleatorio() que retorne un número aleatorio entre 100 y 130,
#excepto los números 110, 115 y 120 .
#
#Adicionalmente, una función numeros que imprima diez números aleatorios
#(retornados por la función numAleatorio()) alternando par, impar, comenzando por par.
#numeros()
fro... | true |
5edf9101a7a2087faf27c0316fecc6993b7fe23c | Python | lidc54/GIS_UI | /UI/plotDem.py | UTF-8 | 1,461 | 2.5625 | 3 | [] | no_license | #coding:utf-8
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import LightSource
from matplotlib.pyplot import gca
class plotD:
def figureD(self,data):
if type(data[0]) is not np.ndarray:
return 0
Z = data[0].astype(np.int16)
Z[Z<0] =Z[Z>0].min()
... | true |
043b689348c93f37dea6ecfe4b149c524477ea1e | Python | arrowbounce/AdventofCode2019 | /Day19.py | UTF-8 | 1,071 | 2.765625 | 3 | [] | no_license | import intcode
f = open("Day19", "r")
cells = [int(i) for i in f.read().split(',')]
pull = 0
for i in range(50):
for j in range(50):
a =intcode.intcode(cells[:])
a.addinputs([i, j])
out = a.run()
if out[0][0] == 1:
print i,j
pull += 1
print pul... | true |
155d5e4d8282c524a1986123766b2a42acc3ea73 | Python | ohjho/st_super_res | /utils.py | UTF-8 | 1,888 | 3.03125 | 3 | [
"Apache-2.0"
] | permissive | import streamlit as st
import numpy as np
import imageio
from PIL import Image
def GetInputImage(st_asset = st, type = ['jpg', 'png', 'jpeg'], color = 'RGB'):
'''
Ask for user's input in the st_asset and return a NP array using imageio
'''
image_url = st_asset.text_input("Enter Image URL")
image_fh = st_asset.fil... | true |
2d0cda15b0c5514461e3ae67f6affbaaee27f934 | Python | tlsehd1230/pong-game | /server.py | UTF-8 | 2,977 | 2.9375 | 3 | [] | no_license | import socket
import threading
import pygame
from point import Point
import time
class Ball :
def __init__(self) :
self.ballposX = 400
self.ballposY = 300
self.speedX = 7
self.speedY = 7
self.nextdirection = -1
server_IP = "127.0.0.1"
server_PORT = 20000
sock = socket.socke... | true |
d3a984b52a7ca7ad386eba41feaf7d3741673ab5 | Python | seanzx/leetcode | /leetcode/_515FindLargestValueinEachTreeRow.py | UTF-8 | 302 | 3.234375 | 3 | [] | no_license | from TreeNode import TreeNode
def lasgestValue(root):
res = []
def dfs(root, depth):
if not root:
return 0
if len(res) < depth:
res.append(root.val)
elif res[depth - 1] < root.val:
res[depth-1] = root.val
dfs(root.left, depth+1)
dfs(root.right, depth+1)
dfs(root, 1)
return res | true |
c8c1005ab219f3a02213ee1f2ce8a955acb9c1f0 | Python | amarseg/chromosome_morphology | /functions_chromosomes.py | UTF-8 | 4,149 | 2.84375 | 3 | [] | no_license | import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import os
import pandas as pd
from scipy.spatial import ConvexHull
import seaborn as sns
import nestle
########################
#Functions
##########################
def plot_ellipsoid_3d(ell, ax):
"""Plot the 3-d Ellipsoid e... | true |
b6034f04067ced3545215b1480c99235f60f2b0f | Python | HarounH/nlp-col864 | /project/src/MemN2N-tensorflow-master/data_template.py | UTF-8 | 3,655 | 2.578125 | 3 | [
"MIT"
] | permissive | from __future__ import absolute_import
import os
import re
import numpy as np
import pdb
from collections import Counter
def read_dstc2_data_template(fname):
print('Reading ', fname)
data=[]
with open(fname) as f:
mem = []
query_results = {} # resto_name -> list of words(str)
for line in f.readlines():
if... | true |
bc0c3fe2fdc3ed4e403ae94c4fc883f89435d5d8 | Python | MiguelChichorro/PythonExercises | /World 3/Functions/ex097 - Special Print.py | UTF-8 | 396 | 3.46875 | 3 | [
"MIT"
] | permissive | colors = {"clean": "\033[m",
"red": "\033[31m",
"green": "\033[32m",
"yellow": "\033[33m",
"blue": "\033[34m",
"purple": "\033[35m",
"cian": "\033[36m"}
def write(txt):
tam = len(txt) + 3
print("=" * tam)
print(f"{colors['blue']} {txt}{colors['... | true |
085be4b6d7856ef72407e19c23cd857771e287d6 | Python | intelbras/dojos-intelbras | /2017-12-19/validador-cpf.py | UTF-8 | 2,172 | 3.8125 | 4 | [] | no_license | import unittest
# Validador de CPF
# Input (onze dígitos inteiros)
# Validar o número digitado - OK
# multiplicar a seq de 9 dígitos (10 - 2) OK
# pegar resto da divisão (*10 / 11) OK
# multiplicar a seq de 10 dígitos (11 - 2) OK
# comparar o validador obtido com o do usuário
# Output (True, False ou None)
def r... | true |
ab85ab7c3f8be6becf8da7c5acde32e32f2682ff | Python | bassaer/pypidev | /src/pypidev/core.py | UTF-8 | 166 | 3.046875 | 3 | [
"Apache-2.0"
] | permissive | """ Core pypidev """
class Hello(object):
def __init__(self, name):
self.name = name
def get(self):
return "Hello, {}!".format(self.name)
| true |
ffac93ae8f4b88afd86b19f1dcff9329b91c558e | Python | LSSTDESC/TXPipe | /txpipe/metadata.py | UTF-8 | 7,990 | 2.53125 | 3 | [
"BSD-3-Clause"
] | permissive | import numpy as np
import yaml
from .base_stage import PipelineStage
from .data_types import TomographyCatalog, MapsFile, HDFFile, YamlFile, ShearCatalog
from .utils.calibration_tools import read_shear_catalog_type
from .utils import choose_pixelization
def copy(tomo, in_section, out_section, name, meta_file, metadata... | true |
a613e8b339cbcacdfbbb4b42ba5d2204a7e443d7 | Python | smilechaser/mc-roboto | /splitbuffer.py | UTF-8 | 700 | 3.609375 | 4 | [
"Apache-2.0"
] | permissive | '''
'''
class SplitBuffer:
def __init__(self, split_size=None):
self.buffer = b''
self.size = 0
def deposit(self, data, data_length):
self.buffer += data[0:data_length]
self.size += data_length
def __getitem__(self, index):
if hasattr(index, 'start'):
... | true |
d3966b3efee24c5958c495578060a43f4c4db60d | Python | jjangsungwon/python-for-coding-test | /DP/효율적인화폐구성.py | UTF-8 | 559 | 2.890625 | 3 | [] | no_license | import sys
if __name__ == "__main__":
N, M = map(int, input().split())
coin = [int(input()) for _ in range(N)]
dp = [sys.maxsize] * (M + 1)
# coin에 들어있는 값은 1개로 가능
for i in range(N):
if coin[i] > M:
continue
else:
dp[coin[i]] = 1
# dp
for i in rang... | true |
aa3a62752b933b5a91a2cc9ef1203cd5a48ee0ab | Python | tahinpekmez/MyPython | /True_False | UTF-8 | 312 | 3.59375 | 4 | [] | no_license | #!/usr/bin/python
x = 5
t1 = 10 < x < 20
print(bool(t1))
y=6
t2 = x==y
print(bool(t2))
s1 = t1
if (s1 is t1):
print("True")
else:
print("False")
class A():
def __init__(self):
return None
a = A()
print(bool(a))
class B():
def __len__(self):
return 0
b = B()
print(bool(b))
| true |
1b5b430fd1ff78e231c1afe99a1a315cdd5249ee | Python | Fauer4Effect/adventofcode | /2017/day19.py | UTF-8 | 3,349 | 3.203125 | 3 | [] | no_license | """
Author: Kyle Fauerbach
Python solution to advent of code day 19
"""
def solve():
"""
part 1 answer should be BPDKCZWHGT
part 2 answer should be 17728
"""
with open("19_1_in.txt", "r") as my_input:
inside = map(lambda s: ['*']+s+['*'], map(list, my_input.read().split('\n')))
... | true |
5864d60b94385336f5065d59e686144fa8174d19 | Python | vj-09/DS_titanic | /predict_with_age_final.py | UTF-8 | 2,265 | 2.859375 | 3 | [] | no_license | import tensorflow as tf
import pandas as pd
from sklearn.utils import shuffle
import numpy as np
from sklearn.metrics import f1_score
data_frame = pd.read_csv("dataset/train.csv", usecols=["Survived", "Age", "Sex"])
new_df = data_frame.dropna()
def encode_sex(row):
if row["Sex"] == "male":
return 1
re... | true |
d27a4c843ea88908a4ff9dec5685cdab6fee32d6 | Python | CharisseU/CodingDojo_Assignments | /Python_Stack/flask/flask_foundations/Great_Number_Game/server.py | UTF-8 | 1,013 | 2.96875 | 3 | [] | no_license | from flask import Flask, render_template, request, redirect, session
import random # import the random module
app = Flask(__name__)
app.secret_key = 'key'
@app.route('/')
def index():
if "random_number" not in session:
session['random_number'] = random.randrange(0, 101)
session['display_guess'] =... | true |
e79c3953658bfb4d394f2f91e08e1655e36e3be7 | Python | okipriyadi/NewSamplePython | /SamplePython/samplePython/database/MongoDB/_06_find_and_query.py | UTF-8 | 6,878 | 3.5 | 4 | [] | no_license | """
You can use the find() method to issue a query to retrieve data from a collection in MongoDB. All queries in MongoDB have the scope of a single collection.
Queries can return all documents in a collection or only the documents that match a specified filter or criteria. You can specify the filter or criteria in a d... | true |
3944cbb0b40b50adee978143c3f349171805e55a | Python | kasztp/OITM-2021 | /pascal-triangle.py | UTF-8 | 211 | 2.953125 | 3 | [] | no_license | with open("output-onlinemathtools.txt", "r") as pascals:
numbers = pascals.read().split(" ")
numbers = numbers[1:-2]
print(numbers)
result = 0
for num in numbers:
result += int(num)
print(result)
| true |
368db5d801bbf8b857b028966d30e760c3855d4e | Python | Fuddlebob/CGAAPIMM | /transform/maxContrast.py | UTF-8 | 526 | 2.640625 | 3 | [] | no_license | from . import abstractTransform
import cv2
import numpy as np
import sys
class maxContrastTransform(abstractTransform.abstractTransformClass):
def name():
#short form name for the transform
return "Max Contrast"
def description():
#return a brief description of what the transform does
return "I... | true |
9dcbe189d674c22eba0da307864a2d2f64ad570b | Python | curiosity654/Tag-Tool | /src/ListBox.py | UTF-8 | 1,055 | 2.71875 | 3 | [] | no_license | from PyQt5 import QtCore, QtGui
from PyQt5.QtWidgets import *
from LabelItem import Label
import codecs
import os.path
class ListBox(QListWidget):
def Load_data1(self, rect_list, string_list, label_size, img_size):
self.clear()
label_list = []
for i in range(len(rect_list)):
la... | true |
198e395736162aa99a8a7256b3dcb92b4ef73fa3 | Python | isalin8281/sc-projects | /stanCode_Projeccts/boggle_game_solver/largest_digit.py | UTF-8 | 1,251 | 4.53125 | 5 | [
"MIT"
] | permissive | """
File: largest_digit.py
Name: Isabelle
----------------------------------
This file recursively prints the biggest digit in
5 different integers, 12345, 281, 6, -111, -9453
If your implementation is correct, you should see
5, 8, 6, 1, 9 on Console.
"""
def main():
print(find_largest_digit(12345)) # 5
print(... | true |
eab49dd65e2d86a671cafc26cd280d284d873756 | Python | yiwzhong/ELBSA4TSP | /tsp_result_verify.py | UTF-8 | 1,411 | 3.25 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu Jan 28 09:27:24 2016
@author: yiwzhong
"""
import numpy as np
import matplotlib.pyplot as plt
def plot_tour(solution, city_pos):
city_number = len(solution)
x = np.zeros(city_number+1)
y = np.zeros(city_number+1)
for i, city in enumerate(so... | true |
3d362201f361aebcb75313cb454a1dac6567c6d8 | Python | bibliodrone/Python_newer_files | /SudocTryout.py | UTF-8 | 355 | 2.53125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>
# <codecell>
from BeautifulSoup import BeautifulSoup
import urllib2
url="http://www.sudoc.fr/171178092.rdf"
page=urllib2.urlopen(url)
soup = BeautifulSoup(page.read())
isbns=soup.findAll('bibo:ISBN13')
for eachisbn in isbns:
print eachisbn['href']+","+eachisbn.str... | true |
a864fd240212ca3ccec49e7d332718c05c501e24 | Python | fuzikt/starpy | /particles_star_to_box.py | UTF-8 | 2,771 | 3.25 | 3 | [] | no_license | #!/usr/bin/env python3
import os
import sys
from metadata import MetaData
import argparse
class ParticlesToBox:
def define_parser(self):
self.parser = argparse.ArgumentParser(
description="Extracts coordinates from particles STAR file and saves as per micrograph box files.")
add = sel... | true |
8972c225c1eee0f31a2e6e3160fd4165a0c4ba70 | Python | AmuroPeng/DrowningSurveillance-InceptionV3 | /data_img_crop.py | UTF-8 | 915 | 2.859375 | 3 | [] | no_license | #!/usr/bin/ env python
# -*- coding:UTF-8 -*-
import os
from os.path import join as pjoin
from PIL import Image
data_dir = r".\material\Transformed" # data_dir是lfw数据集路径
img_dir = r".\material\Tailored" # 自己单独建的文件夹, 用于存放从lfw读取的图片
for folder_name in os.listdir(data_dir):
count = 0
person_dir = pjoin(data_dir... | true |
efdaf7f26c9a1b522c043bc71a4f134326c5f9dc | Python | huhuamian/autoWork | /02word/008_Word_docx_批量把文字写入Word/write_doc.py | UTF-8 | 2,199 | 2.796875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# @Time : 2020/8/20 18:10
# @公众号 :Python自动化办公社区
# @File : write_doc.py
# @Software: PyCharm
# @Description:
from docx import Document
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.shared import Pt
from docx.oxml.ns import qn
import time
price = input('请输入工资调整金额:')
# ... | true |
7b5e5cd95d2717369a0898a5c8e3cbfd1b686118 | Python | ucbrise/cs262a-fall2020 | /paper_rank.py | UTF-8 | 5,397 | 2.75 | 3 | [] | no_license | """
This script contains an implementation of the one-sided matching algorithm
described in [1]. Students rank their top 10 papers, and we assign each paper
to a student.
[1]: https://cs.stackexchange.com/a/80333
"""
from typing import Dict, List, NamedTuple, Optional
import argparse
import csv
import itertools
impor... | true |
40d782bf248ecb02716a557a760ba90526b3434f | Python | nirajchaughule/Python_prac | /height.py | UTF-8 | 86 | 2.796875 | 3 | [] | no_license | a=int(input("Height in cms:"))
if a<150:
print("bye")
else:
print("welcome")
| true |
28696ccfecf353765b2b8700c805c4b21bdb4137 | Python | vipzgy/DocumentSentimentSecond | /target/driver/MyIO.py | UTF-8 | 3,171 | 2.859375 | 3 | [] | no_license | # -*- encoding: utf-8 -*-
import re
import codecs
import _pickle
from collections import Counter
def read_word_line(sentence_path, config, is_train=False):
data = []
sentence_len = Counter()
word_dict = Counter()
label_dict = Counter()
with open(sentence_path, 'r', encoding='utf-8') as sentence_fi... | true |
d700fb4ab0eef980d79f14c95bd5150dc28d67a1 | Python | Celsuss/AdventOfCode2019 | /DayThree.py | UTF-8 | 6,740 | 3.390625 | 3 | [] | no_license | import numpy as np
import math
import sys
def getDirectionAndLength(move):
direction = [0,0]
if move[0] == 'R':
direction = [1,0]
elif move[0] == 'D':
direction = [0,-1]
elif move[0] == 'L':
direction = [-1,0]
elif move[0] == 'U':
direction = [0,1]
length = int(... | true |
874360969c22ce6d7a45ec4013692944f30cfdff | Python | Jeffyangchina/xingy | /enery search/etl.py | UTF-8 | 11,434 | 2.9375 | 3 | [] | no_license | #!/usr/bin/env python3.6
# -*- coding: utf-8 -*-
#@Author: Yang Xiaojun
import csv
import jieba
import re
import os
import logging
import time
logging.basicConfig(level = logging.DEBUG,format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
logger.setLevel(level = logging.D... | true |
8f45377e492dd9b3addcb773b5b68728de04d384 | Python | godisu524/BaekJunQuiz | /dynamic planing/11054_practice.py | UTF-8 | 1,320 | 3.140625 | 3 | [] | no_license | A= int (input())
A_list= list(map(int,input().split()))
result = [[] for _ in range(A)]
#순방향 돌려주기
for i in range(A):
if i == 0 :
result[i].append(A_list[i])
print("1 0"+ str(result))
else:
for j in range(0,i):
if result[j][-1] < A_list[i]:
if len(result[i]) ... | true |
da63054f8a04cd5f9cc8a25276ae8732eb2af61f | Python | Giamberardinosaur/EMF-Datalogger | /EMFDatalogger/TM192D.py | UTF-8 | 3,322 | 2.90625 | 3 | [] | no_license | import serial
import serial.tools.list_ports
import time
import struct
import numpy as np
import codecs
class TM192D():
def __init__(self):
self.baud = 38400
self.initialized = False
def begin(self):
try:
if not self.searchPorts(): # Return false if the device is not found... | true |
4e9e6edae5f136ec580664b8cf872dc8bf533c98 | Python | uykhokhar/photoshare | /main.py | UTF-8 | 10,686 | 2.53125 | 3 | [] | no_license | import cgi
import datetime
import urllib
import webapp2
import json
import logging
import uuid
from google.appengine.api import memcache
from google.appengine.ext import ndb
from google.appengine.api import images
from google.appengine.api import users
from models import *
######################################... | true |
3fe765c1efe573b21f2e016f46390383b9d64891 | Python | mascot6699/udacity-full-stack | /Full Stack Foundation/Google App Engine/handlers/rot13.py | UTF-8 | 366 | 2.65625 | 3 | [] | no_license | from .base import Handler
class Rot13Handler(Handler):
"""
Rotation by 13 ceaser cipher implemented
"""
def get(self):
self.render('rot13-form.html')
def post(self):
rot13 = ''
text = self.request.get('text')
if text:
rot13 = text.encode('rot13')
... | true |
e72269b1091b282703b7ed06469e52eabe1d2015 | Python | connected-ftarlan/tf-specialization | /C1/W2/Fashion_MNIST.py | UTF-8 | 2,601 | 3.21875 | 3 | [] | no_license | from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Flatten, Dense
from tensorflow.keras.datasets import fashion_mnist
from tensorflow.keras.callbacks import EarlyStopping
def load_fashion_mnist():
"""
Loads the fashion MNIST dataset into memory. It also normalizes the input
... | true |
208bb00b995f563fafe188a354025099ca601eb1 | Python | toologicbv/meta_learner | /models/layer_lstm.py | UTF-8 | 907 | 2.734375 | 3 | [] | no_license | import torch.nn as nn
import torch.nn.functional as F
class LayerLSTMCell(nn.Module):
def __init__(self, num_inputs, num_hidden, forget_gate_bias=0):
super(LayerLSTMCell, self).__init__()
self.forget_gate_bias = forget_gate_bias
self.num_hidden = num_hidden
self.fc_i2h = nn.Linea... | true |
900489483db0562f437ad1932c2855e1ebc761bb | Python | syurskyi/Python_Topics | /050_iterations_comprehension_generations/001_iterations_and_iteration_tool/examples/001_Iteration Contexts.py | UTF-8 | 1,606 | 3.3125 | 3 | [] | no_license | # Iteration Contexts
# Use file iterators
for line in open('script2.py'):
print(line.upper(), end='')
# Iteration Contexts
# Use List Comprehension
uppers = [line.upper() for line in open('script2.py')]
print(uppers)
# Iteration Contexts
# Use Map
print(map(str.upper, open('script1.py')))
# Iteration Contexts... | true |
3f0461ed62adb5adab5df46f47f3872ef8de88fb | Python | xia9999/test_one | /SeleniumTest/demo03.py | UTF-8 | 912 | 2.609375 | 3 | [] | no_license | from selenium import webdriver
import time
driver = webdriver.Chrome(executable_path='chromedriver.exe')
driver.maximize_window()
driver.get('http://132.232.44.158:8080/ljindex/')
driver.find_element_by_link_text('注册').click()
time.sleep(2)
driver.find_element_by_xpath('//*[@id="username"]').send_keys('xhq12... | true |
9e0589e6cf295d2205a5bd774b4969349a21b558 | Python | Sbastdia/Ejercicios-probables-examen | /RIT33PYT/Codigo_1/parte_4/contact/contact/scripts/gtk.py | UTF-8 | 3,840 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/python3
from gi.repository import Gtk
import argparse
from pyramid.paster import bootstrap
from sqlalchemy import engine_from_config
from contact.models import DBSession, Base, Contact, Subject
import transaction
class GtkContact:
def __init__(self, controller):
self.controller = controller... | true |
3f8bbc563749364694f6771a4c89ac8556b06359 | Python | HongyuanZhang/Numerical-Algorithms | /differentiation_integration/newton-cotes-integration.py | UTF-8 | 1,468 | 3.828125 | 4 | [] | no_license | '''
Numerical Integration using Newton-Cotes Formulas
'''
import numpy as np
# Integration by Composite Trapezoid Rule, a closed newton-cotes method
# f: integrand
# a: lower end of the integral
# b: upper end of the integral
# m: number of panels
def int_trapezoid(f, a, b, m):
h = (b-a)/m
panel_x_points = np... | true |
b41f620ca4169b6d9b597fdb4ba91da9335662c0 | Python | developeryuldashev/python-core | /python core/Lesson_8/funk_18.py | UTF-8 | 187 | 3.515625 | 4 | [] | no_license | def Fact(n):
p=1
i=1
while n>0:
p=p*i
i+=1
n-=1
return p
print(Fact(5))
k=6
while k>0:
x=int(input('x='))
p=Fact(x)
k-=1
print(p)
| true |
7c0f3b40537e140b3645484fb7e0af594ef47ca2 | Python | amcmorl/motorlab | /tuning/display/azel_plots.py | UTF-8 | 8,443 | 2.59375 | 3 | [] | no_license | import numpy as np
from amcmorl_py_tools.vecgeom import unitvec
from amcmorl_py_tools.vecgeom.rotations import rotate_by_angles
from amcmorl_py_tools.vecgeom.coords import pol2cart, cart2pol
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec, GridSpecFromSubplotSpec
from warnings... | true |
992d69e302af1cce1914413e4ebb789f4e0e11c8 | Python | gopan0511/Python | /Python/random1.py | UTF-8 | 127 | 3.625 | 4 | [] | no_license | a = input("Enter an array : ")
n = len(a)
i = 0
while i < n:
j = 0
while j < n-i-1:
print j,(j+1)
j = j+1
i = i + 1
| true |
335d1639e1394bb9cc13a265c157166a82d8d4a0 | Python | kongpeter/Pacman-Search | /pacman-contest/myTeam_Q.py | UTF-8 | 20,071 | 2.9375 | 3 | [] | no_license | from captureAgents import CaptureAgent
import distanceCalculator
import random, time, util, sys
from game import Directions,Actions
import game
from util import nearestPoint
import layout
'''
Team Creation:
(1) Offensive Agent
(2) Defensive Agent
'''
def createTeam(firstIndex, secondIndex, isRed,
firs... | true |
4ada094a752c9f032b070619cd3ac011aadc02d3 | Python | jaantollander/GameStore | /gamestore/tests/create_content.py | UTF-8 | 4,972 | 2.671875 | 3 | [
"MIT"
] | permissive | """Create fake content for testing the django application
Loading image to django model is adapted from:
http://www.revsys.com/blog/2014/dec/03/loading-django-files-from-code/
Attributes:
USERNAME_ALPHABET:
PASSWORD_ALPHABET:
"""
import logging
import os
import string
from functools import partial
from djan... | true |
7e93df2e6bcf6a6eb0606994afc605da460ba2f6 | Python | h0r5t/stratstuff | /stratstuff/python/src/engine/EngineData.py | UTF-8 | 8,895 | 2.8125 | 3 | [] | no_license | import numpy
from random import randint
import InfoReader
worldsDir = "../../resources/worlds"
dataDir = "../../resources/data"
class EngineData():
def __init__(self, world_name):
self.worldName = world_name
self.wp_array = None # will be initialized via numpy notation
self.m_objects = ... | true |
c4f61a632c43a7cd2cf72121de849ab79221022e | Python | YoungXueya/LeetcodeSolution | /src/739. Daily Temperatures.py | UTF-8 | 938 | 3.0625 | 3 | [] | no_license | class Solution:
# https://leetcode.com/problems/daily-temperatures/discuss/121787/C%2B%2B-Clean-code-with-explanation%3A-O(n)-time-and-O(1)-space-(beats-99.13)
# Logic is if T[i]<T[i+1], if result[i+1]>0 means that the following result[i+1] is smaller than T[i],
# Therefore, compare with elements at least r... | true |
4585fccfa82a87264173f46237a4e89fa05477f6 | Python | godarderik/projecteuler | /Solved/Problem51.py | UTF-8 | 1,876 | 3.609375 | 4 | [] | no_license | import math
def sieve(n):
arr = [True] * n
arr[0] = arr[1] = False
for (i, isPrime) in enumerate(arr):
if isPrime:
yield i
for x in range(i*i, n, i):
arr[x] = False
def isPrime(n):
if (n % 2 == 0) or (n % 3 == 0):
return False
div = 5
whi... | true |
759733b377bb79e464700c2a2e76f3e4931a53f0 | Python | rgonzagaoliveira/python-fundamentals | /HandsOn/Aula06/Exercicio.py | UTF-8 | 841 | 3.046875 | 3 | [] | no_license | # ---- CONEXAO COM O BANCO
import psycopg2
# abre a conexao
con = psycopg2.connect(
'host=%s dbname=%s user=%s password=%s' % (
'localhost', 'projeto', 'postgres', '123456'
)
)
print con
## INSERIR UM TITULO - QUE O USUARIO QUISER
# abre a secao
tit = raw_input('Insira o titulo: ')
cont = raw_input('Insira o... | true |