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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
52845800e0886e3483d7825fef50295bd37e3a4d | Python | yajie/python | /MyHtmlParser.py | UTF-8 | 539 | 2.859375 | 3 | [] | no_license | from sgmllib import SGMLParser
class URLParser(SGMLParser):
urlList=[]
def reset(self):
self.is_a = ""
self.name = []
SGMLParser.reset(self)
def start_a(self,attrs):
self.is_a = 1
href = [ v for k,v in attrs if k == 'href']
if href:
URLParser.urlList.extend(href)
def handle_data(self,data):
if ... | true |
3e3ca76b57d9ff804ba813dd3368caa0aa7126c9 | Python | jar398/psyche | /bhl/make_pdfs.py | UTF-8 | 2,061 | 2.703125 | 3 | [] | no_license | # Download a page images (jpeg): https://www.biodiversitylibrary.org/pageimage/11809641
# For lossless conversion to PDF, use img2pdf (needs python 3)
# This is lossy:
"""
gs \
-sDEVICE=pdfwrite \
-o foo.pdf \
/usr/local/share/ghostscript/8.71/lib/viewjpeg.ps \
-c \(my.jpg\) viewJPEG
Multipage:
gs \
-sDEVICE=... | true |
2aebc3bb917d951723794bfadec18f4053c83a84 | Python | sabarjp/ClonalCellSimulation | /population.py | UTF-8 | 3,457 | 3.390625 | 3 | [
"MIT"
] | permissive | from random import normalvariate
from copy import deepcopy
class Population:
"""
Represents a population of cells. The population can be iterated over to
perform the simulation.
"""
# The group of the cells.
cell_collection = []
current_tick = 1
def __init__(self, inital_cell):
... | true |
28a895e14c64ee520ef40d9af3737ce7fd3d8c69 | Python | amjayy/bug_fixing | /no.py | UTF-8 | 243 | 4.125 | 4 | [] | no_license | def convert_to_celsius(fahrenheit):
# (number) -> float
# Return the number of Celsius degrees equivalent to fahrenheit degrees.\
# >>> covert_to_celsius(75)
# 23.88888888888889
return (fahrenheit - 32.0 ) * 5.0 /9.0
| true |
651f5802a885840d1576e195f04cb119e3c645aa | Python | bharathnaveen123/1BM17CS020 | /admission_class.py | UTF-8 | 1,359 | 3.296875 | 3 | [] | no_license | class admission:
def __init__(self,i):
self.id=0
self.age=0
self.marks=0
def get_val(self):
self.id=int(input("ID:"))
self.age=int(input("age:"))
self.marks=int(input("marks:"))
l1=[]
l1.append(self.age)
l1.append(self.marks)
... | true |
f4b68da00adbb44570ce502d64905b0d3fc2c5f4 | Python | josenriagu/fluffy-fiesta | /_dcomp/leastFrequentNumber.py | UTF-8 | 430 | 3.421875 | 3 | [] | no_license | def leastFrequentNumber(arr):
values = set()
least = (0, 0)
for i in range(len(arr)):
freq = arr.count(arr[i])
if i == 0:
least = (arr[i], freq)
elif arr[i] not in values and freq < least[1]:
least = (arr[i], freq)
values.add(arr[i])
return least[0... | true |
ed0cc6c1a072dee9af6d6f76845d51731302a0fc | Python | f-fathurrahman/ffr-MetodeNumerik | /chapra_7th/ch14/optim_SD_linmin.py | UTF-8 | 841 | 2.96875 | 3 | [] | no_license | import numpy as np
def linmin_grad(grad_func, x, g, d, αt=1e-5):
xt = x + αt*d
gt = grad_func(xt)
denum = np.dot(g - gt, d)
if denum != 0.0:
α = abs( αt * np.dot(g, d)/denum )
else:
α = 0.0
return α
def optim_SD_linmin(func, grad_func, x0, NiterMax=1000):
x = np.copy(x0)
... | true |
6a0de0c5ebffc95aadd4799981023b66f0eb6701 | Python | ProjectOnePM/ProjectOneEjercicios | /Unidad 4 - Funciones/Funciones/UT4ejeI.py | UTF-8 | 238 | 3.484375 | 3 | [] | no_license | def funcionnumero(n):
sum=0
for i in range(1,(n/2)+1):
if n%i==0:
sum=sum+i
if n==sum:
return"Es un numero perfecto"
elif (n<sum):
return"Es un numero abundante"
elif (n>sum):
return"Es un numero deficiente"
| true |
a4a6f2197063c6ca8ca314f772d4cdf1dbac9258 | Python | tanakaxa/syslogsender | /ext-syslogsender.py | UTF-8 | 713 | 2.515625 | 3 | [] | no_license | import json
import sys
from syslogjson import syslogjson
from syslogjson import extsyslogjson
def main():
# log message import
logfile = open(sys.argv[1], 'r')
jsonfile = json.load(logfile)
for v in jsonfile.values():
try:
tcpflag = v["tcp"]
except KeyError:
tcp... | true |
e81be8e99c5632394ae7ad15b373afd697b4dc2d | Python | jakecraige/ctf | /cybersecurityrumble-2020/ezdsa/exploit.py | UTF-8 | 2,104 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env python3
from pwn import *
from binascii import hexlify, unhexlify
import hashlib
import ecdsa
N = ecdsa.SECP256k1.order
hashfunc = hashlib.sha1
def decode_sig(hex_sig):
assert len(hex_sig) == 64
r = int.from_bytes(hex_sig[:32], "big")
s = int.from_bytes(hex_sig[32:], "big")
return (r, s... | true |
97f2e635b7dc68e47a8da1d5a9b0b42ba10faac5 | Python | 280779378/fenbushi-demo | /自己写分布式爬虫.py | UTF-8 | 1,134 | 2.78125 | 3 | [] | no_license |
'''
目标:
使用分布式爬虫,去爬取所有页
http://www.btbtdy.net/btfl/dy30.html
'''
from redis import Redis
import requests
# 存储urls
REDIS_KEY = "btdy:urls"
# rds = Redis('10.8.151.21',6379)
rds = Redis('192.168.56.1',6379)
def fetch(url):
"""
下载页面,如果下载成功,返回response对象,否则返回None
:param url: ... | true |
73e99bc033a711ccef073d5a3b156c118ec47ed8 | Python | Newky/LinuxVoiceChallenges | /ch02/bars.py | UTF-8 | 2,803 | 3.203125 | 3 | [] | no_license | import csv, contextlib, math, random, sys, time, turtle
turtle.colormode(255)
@contextlib.contextmanager
def return_to_pos(tur):
heading = tur.heading()
pos = tur.pos()
yield
jump_to(tur, pos[0], pos[1])
tur.setheading(heading)
@contextlib.contextmanager
def set_random_color(tur):
current_c... | true |
b9111dd3afae37d42225202cf6781d1c9da65234 | Python | testNameGenerator/SublimeText-plugin | /TestNameGenerator.py | UTF-8 | 7,490 | 2.953125 | 3 | [
"MIT"
] | permissive | import sublime, sublime_plugin, re
class ConvertTestNameCommand(sublime_plugin.TextCommand):
def isAllowedSyntax(self, syntax):
return ((syntax == "PHP") | (syntax == "JavaScript"))
# keep only alphanum and ",", ".", "(", ")"
def getCleanLineContents(self, lineContents):
pattern = TextHelp... | true |
98d823f4e0c4e2e5610ee349358140e51aca46d2 | Python | angel-star/codewars | /Python/Find the next perfect square!.py | UTF-8 | 1,580 | 4.28125 | 4 | [] | no_license | You might know some pretty large perfect squares. But what about the NEXT one?
Complete the findNextSquare method that finds the next integral perfect square after the one passed as a parameter. Recall that an integral perfect square is an integer n such that sqrt(n) is also an integer.
If the parameter is itself not... | true |
9718e11a2146ade7df6ddde8a3ec6dec60cd569f | Python | biscuitsnake/advent-of-code | /2018/5.py | UTF-8 | 1,336 | 3.203125 | 3 | [] | no_license | import string
# part 1 = 9900
file = open('5.txt')
polymer = list(file.read())
polymer.pop()
reaction = True
totalDes = 0
while reaction:
destroyed = False
i = 0
r = True
while r:
f = polymer[i]
s = polymer[i + 1]
if (f.isupper() != s.isupper()) and (f.lower() == s.lower()):... | true |
ea713bcedf72b559089af86b26f1a320fe4e6feb | Python | alexj136/NeuralNet | /misc.py | UTF-8 | 1,716 | 3.265625 | 3 | [] | no_license | from instances import Instance
import math
xorData = \
[ Instance([-1, -1], [-1])
, Instance([-1, 1], [ 1])
, Instance([ 1, -1], [ 1])
, Instance([ 1, 1], [-1])
]
def euclideanDist(x, y):
'''Compute the euclidean distance between two vectors (lists) x and y'''
return ... | true |
12cc7425b7a88bcd04357aa991b737428f1e5706 | Python | SqueezeStudioAnimation/studiolibrary | /packages/studiolibrarydemo/demoplugin.py | UTF-8 | 8,027 | 2.59375 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | # Copyright 2016 by Kurt Rathjen. All Rights Reserved.
#
# Permission to use, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appear in all copies and that
# both that copyright notice and this permission notice a... | true |
f0792ae5ef1b96652ec895746dc5bc4bceee0e26 | Python | Danutelka/Coderslab-Python-progr-obiektowe | /1_Zadania/Dzien_1/1_Podstawowa_obiektowosc/zad_1.py | UTF-8 | 707 | 4.125 | 4 | [] | no_license | class Calculator:
def __init__(self):
self.operations =[]
def add(self, a, b):
operation = "added {} to {} got {}" .format(a, b, a + b)
self.operations.append(operation)
return a + b
def multiply(self, a, b):
operation = "multiplied {} with {} got {}" .format(a, b,... | true |
f8dace72865fcc798e40137600c31f1c06911a5c | Python | 3rawkz/Pentesting-with-Python | /PwP-main.py | UTF-8 | 604 | 2.640625 | 3 | [] | no_license | print """Pentesting with Pyton is a collection of simple pentesting tool written
in Python\n"""
print """ Currently following tools are available:\n"""
print '1. TCP proxy utility '
print '2. TCP server'
print '3. TCP full connection port scanner'
print '4. Netcat'
print '5. Keylogger'
print '6. Utility for extracting ... | true |
35f412ec850553096cc98697818f2ef38ac4d8fe | Python | JoannaDrx/protein-classification | /model.py | UTF-8 | 6,208 | 2.96875 | 3 | [] | no_license | """
Author: Joanna Dreux [joanna.dreux@gmail.com]
"""
from sklearn.feature_selection import RFE
from sklearn import model_selection
from sklearn.svm import LinearSVC, SVC
from sklearn.neighbors import KNeighborsClassifier
from sklearn.decomposition import PCA
from sklearn.linear_model import LogisticRegression
from sk... | true |
efa334cd89e3566e4b27f0abf8b673bedd06f72a | Python | gabriellaec/desoft-analise-exercicios | /backup/user_014/ch38_2020_04_21_19_51_05_568709.py | UTF-8 | 195 | 2.859375 | 3 | [] | no_license | def quantos_uns(numero_qualquer):
n = 0
contador = 0
while n < len(numero_qualquer):
if numero_qualquer[n] == '1':
contador += 1
n += 1
return contador | true |
1b9f6ed58f3af39d51b7f5189820d8aed945470f | Python | ArlexDu/Training_Management | /Management/forms.py | UTF-8 | 2,426 | 2.609375 | 3 | [] | no_license | #-*- coding: UTF-8 -*-
from django import forms
from models import *
class PersonForm(forms.Form):
name = forms.CharField(required=True, error_messages={'required':'请填写您的真实姓名'})
idcard = forms.CharField(required=True, error_messages={'required':'请填写您的身份证号码'})
province = forms.CharField(required=True, error... | true |
fac81d52dba6b26dbc58b472e33e51e60dd7765a | Python | 15823675454/- | /day04/myThread.py | UTF-8 | 938 | 3.140625 | 3 | [] | no_license | """
测试用例
"""
import time
from multiprocessing import Process
from threading import Thread
# 单进程时间: 5.944053411483765
# 10进程时间: 3.169448137283325
# 10线程时间: 5.8551366329193115
def count(x, y):
c = 0
while c < 7000000:
x += 1
y += 1
c += 1
# 单进程时间: 44.934661626815796
# 10进程时间: 18.6272537708... | true |
af645751bda110d25b7447d11104b8e029999fee | Python | BilalQadar/Toronto-Bike-Share | /bikes.py | UTF-8 | 12,845 | 3.4375 | 3 | [] | no_license | from typing import List, TextIO
# A type to represent cleaned (see clean_data()) for multiple stations
SystemData = List[List[object]]
# A type to represent cleaned data for one station
StationData = List[object]
# A type to represent a list of stations
StationList = List[int]
#Constants
# station information.
ID = ... | true |
210525310458b1fb275c95769224a4b51bafeb87 | Python | Parkyes90/algo | /leetcode/201~300/203. Remove Linked List Elements.py | UTF-8 | 847 | 3.765625 | 4 | [] | no_license | # Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def removeElements(self, head: ListNode, val: int) -> ListNode:
if not head:
return head
node = head
nodes = []
... | true |
58b6b24670fa68d7a69de3a1b0b674f529a94c03 | Python | sbabicki/cmput410lab5 | /todolist.py | UTF-8 | 2,734 | 2.59375 | 3 | [] | no_license | #
# Lots of the code in here is directly from
# http://flask.pocoo.org/docs/0.10/tutorial/setup/#tutorial-setup
# See README for more info
#
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash
import sqlite3
DATABASE = 'todo.db'
DEBUG = True
SECRET_KEY = 'blah blah blah'
US... | true |
f493d7b6541c0ab61704ea40bf26110471e94b13 | Python | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/matrix/b942d606261640af92280cc01cf9bc63.py | UTF-8 | 474 | 3.28125 | 3 | [] | no_license | __author__ = 'angelo'
class Matrix:
def __init__(self, nums):
self.rows = []
for r in nums.split('\n'):
row = []
for n in r.split():
row.append(int(n))
self.rows.append(row)
self.columns = []
for i in range(len(self.rows[0])):
... | true |
0f5d3c4103a4f4c06bef35c999b0084355d7ea28 | Python | mangpo/floem | /floem/test_ast.py | UTF-8 | 11,939 | 2.875 | 3 | [
"BSD-2-Clause"
] | permissive | import unittest
from standard_elements import *
from codegen import *
from join_handling import join_and_resource_annotation_pass
class TestAST(unittest.TestCase):
def find_roots(self, g):
return g.find_roots()
def find_subgraph(self, g, root):
return g.find_subgraph(root, set())
def ch... | true |
fc4404fcde3c012d2ef5ba8bbe83200fe2b1d517 | Python | bclwan/ironbot_remote | /src/motion_control_node.py | UTF-8 | 2,636 | 2.609375 | 3 | [] | no_license | #!/usr/bin/env python
import rospy
import tf
from std_msgs.msg import Int32
from sensor_msgs.msg import Imu
from ack_steer.srv import ack_steer
from ack_ctrl import AckermannCtrl
import numpy as np
class IronbotControl:
def __init__(self):
rospy.init_node('ironbot_ctrl')
rospy.wait_for_service('... | true |
af4104a194c3a611e41163c3f46b105fd0cac8c1 | Python | Thequickesthand/Wizualizacja-danych | /caa.py | UTF-8 | 107 | 3.296875 | 3 | [] | no_license | krotka = (int(10), int(5), int(6), 'a', 'b', 'c')
#krotka[2] = int(8)
print(krotka[3])
print(krotka[-5]) | true |
ecfe35910b11e14262005aeaf9850a8fd86a6402 | Python | miltonsarria/teaching | /basics/ex6.py | UTF-8 | 2,791 | 4.65625 | 5 | [
"MIT"
] | permissive | #existe otro tipo de variables
#en este programa se ilusta el uso de tuplas, listas y diccionarios
#son variables de multiple proposito que pueden almacenar numeros, caracteres, matrices....
#tuple: similar a un arreglo, pero una vez definida no se puede modificar
#Ejemplo
print('\n\n Tuple')
months = ('January','Febr... | true |
09e1e268588eff6177b6d1ffa0f650efd9e891cf | Python | HugoDeku/semaine | /The Last Gust/testPathFind.py | UTF-8 | 658 | 2.921875 | 3 | [] | no_license | import pygame
from pygame.locals import *
import path
from Boss import *
from Joueur import *
pygame.init()
fenetre = pygame.display.set_mode((500,500))
p1 = Boss()
joueur = Joueur(100,0)
fond = pygame.image.load(path.join(path.dirname(__file__),"assets/sprites/bg_temp.png"))
ite = 0
while 1:
fenetre.blit(fond... | true |
6c02dd57cf41d22672be58ff688e8cb6b4bea6e3 | Python | beckybai/Music-Classification | /CNN/process_result/300_compute.py | UTF-8 | 338 | 2.515625 | 3 | [] | no_license | import pandas as pd
import numpy as np
import matplotlib
testdata = pd.read_csv("./10000.log")
index = testdata['Num']
accuracy = testdata['accuracy']
loss = testdata['loss']
nn = -1
for i in range(1,3000,15):
print ("this is #",i)
ww =sum(accuracy[i:i+15]>0)
print float(sum(accuracy[i:i+15]>0))
if(ww>7):
nn ... | true |
7c911dbbb0858b89008fe399407fc36d0000ff04 | Python | liu666197/data1 | /8.10/12 字典练习.py | UTF-8 | 487 | 3.828125 | 4 | [] | no_license | a = []
for i in range(1,4):
print('请输入第%s个人的信息:'%(i))
name = input('姓名:')
sex = input('性别:')
age = input('年龄:')
jiguan = input('籍贯:')
dic = {
"姓名": name,
'性别': sex,
'年龄': age,
'籍贯': jiguan
}
a.append(dic)
# 遍历列表
for person in a:
print(person['姓名'],end... | true |
e4ffb17e2e8dd6629e408f93181bd779b9663478 | Python | katerynak/shopping_scraper | /crawling/spiders/ah_spider.py | UTF-8 | 2,775 | 2.640625 | 3 | [] | no_license | import logging
import scrapy
from items import Product
class AHSpider(scrapy.Spider):
name = "ahSpider"
search_term = None
shop_search_url = "https://www.ah.nl/zoeken"
shop_url = "https://www.ah.nl"
def __init__(self, search_term, redis_connection, output_queue):
self.search_term = sear... | true |
0b7f05d6f8621178cc56551fce0d6fcc95e3ba68 | Python | liu1073811240/Conv-cifar | /cifar_train.py | UTF-8 | 3,212 | 2.625 | 3 | [] | no_license | from torch.utils.data import DataLoader
from full_conv import Net
import matplotlib.pyplot as plt
import torch
from torch import nn
from torchvision import transforms, datasets
from PIL import Image
import numpy as np
if __name__ == '__main__':
batch_size = 100
save_params = "./net_params.pth"
save_net = "... | true |
08a68a149d8feadef9dcff2dbbe3e7aa68d2af6b | Python | Yogesh-Singh-Gadwal/YSG_Python | /Advance_Python/Day-25/57.py | UTF-8 | 578 | 3.9375 | 4 | [] | no_license | # class
from time import sleep
# global variable
c = 30
import time
class Myclass():
# class variable
a = 10
# cons-1
def __init__(self,name):
self.name = name
# cons-2
def __str__(self):
return self.name
# cons-3
def __del__(self):
print('Ob... | true |
44de6f09b1931a98c6df23cff2e62c27e3148976 | Python | kaamesh17/Assignment | /hello.py | UTF-8 | 76 | 2.546875 | 3 | [] | no_license | def printUniqueCharCount(w):
print(w)
printUniqueCharCount("hello"); | true |
e3905c797c7c306e49465e9f89e127558c44b1ad | Python | fnehmer/haw-dqn | /agent.py | UTF-8 | 7,673 | 3.34375 | 3 | [] | no_license | import random
import gym
import numpy as np
from collections import deque
from keras.models import Sequential
from keras.layers import Dense
from keras.optimizers import Adam
import matplotlib.pyplot as plt
import os # for creating directories
env = gym.make('CartPole-v0') # initialise environment
state_size = env.ob... | true |
972b1ac63d33334107376d26ce4137dd7b032acd | Python | GreatLaboratory/algorithm_python | /nadongbin/dfs-bfs/test02.py | UTF-8 | 1,295 | 3.703125 | 4 | [] | no_license | # 음료수 얼려 먹기
def solution(n, m, ice):
def dfs(x, y):
# 현재 방문하려는 노드가 범위에 벗어났다면 탈출
if x <= -1 or x >= n or y <= -1 or y >= m:
return False
# 구멍이 뚫려있다면(현재 방문한 노드가 0이면) 무조건 true를 반환함과 동시에
if ice[x][y] == 0:
# 해당 노드를 얼음인 1로 채우고
ice[x][y] = 1
... | true |
7ebc7b6f18d3beaca8ec58b486f78ac661f46ec0 | Python | Methuselah96/aoc-2019-python | /02_1/solve.py | UTF-8 | 778 | 3.359375 | 3 | [] | no_license | def add(state, index):
state[state[index + 3]] = state[state[index + 1]] + state[state[index + 2]]
def multiply(state, index):
state[state[index + 3]] = state[state[index + 1]] * state[state[index + 2]]
def solve(state):
index = 0
op_code = state[0]
while op_code != 99:
if op_code == 1:
... | true |
9b17ab64cb560330f30859714784978730a082fd | Python | Zzzcg/SimpleCVReproduction | /NAS/single-path-one-shot/src/cifar100/utils/scheduler.py | UTF-8 | 2,421 | 3.09375 | 3 | [
"Apache-2.0"
] | permissive | import itertools
import matplotlib.pyplot as plt
import torch
import torch.nn as nn
from torch.optim.lr_scheduler import (CosineAnnealingLR,
CosineAnnealingWarmRestarts, LambdaLR)
initial_lr = 0.1
total_epoch = 100
class StepLR:
def __init__(self, optimizer, learning_rate: ... | true |
50fb1d683962770a72d1e0ba91ca0bb943d1b142 | Python | MateuszKruk1303/DjangoSimpleApp | /news/views.py | UTF-8 | 2,731 | 2.59375 | 3 | [] | no_license | from django.shortcuts import render, redirect, get_object_or_404
# Create your views here.
from django.http import HttpResponse
from .models import News
from .forms import NewsForm, NewsEditForm
from django.utils import timezone
from django.contrib.auth.decorators import login_required
def view_news(request):
# G... | true |
e6783db1459b61cce1f42c755e9f830a666a5c0c | Python | midori-mate/ArrangementGameTry | /ArrangementGameTry.py | UTF-8 | 7,109 | 2.890625 | 3 | [] | no_license | # coding: utf-8
'''ArrangementGameTry
pygameお試し作品。
床と椅子を置ける。
'''
import pygame, sys
from pygame.locals import *
import os
import accept_mouse_click
_IMG_FOLDER = '01_img'
_MUSIC_FOLDER = '02_music'
pygame.init()
screen = pygame.display.set_mode((640, 480))
pygame.display.set_caption('Arrangement game')
# 画像ロード
de... | true |
d53733622d581d5bf000465fa8492e6d47ab2c46 | Python | simon816/Advent-of-Code-2020 | /21/part2.py | UTF-8 | 749 | 2.65625 | 3 | [] | no_license | from collections import defaultdict
import sys
allergens = {}
all_ingredients = defaultdict(lambda: 0)
for food in sys.stdin.readlines():
ing, al = food.strip()[:-1].split(' (contains ')
ing = set(ing.split(' '))
for i in ing:
all_ingredients[i] += 1
for al in al.split(', '):
if al no... | true |
f31c283030d8ca0ced70210402604c432871dc84 | Python | hdavidethan/catan-tp | /resources/gui/element.py | UTF-8 | 798 | 3.390625 | 3 | [] | no_license | #########################################################################
# Element File
# Contains the Element class (GUI Element) which are drawn on the screen.
# Written by David Hwang (dchwang) for 15-112 Fall 2019 Term Project
#########################################################################
class Element... | true |
edb7327b35b42a92cf32ebf86390584c82dbd3bd | Python | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/223/users/3858/codes/1594_1801.py | UTF-8 | 61 | 3.046875 | 3 | [] | no_license | n = input()
r = int(input())
s = " Abra " + n
print(s * r) | true |
20bceb82cb3232a82090494f1b942058a6555d8a | Python | HiimHotta/MAE0119 | /Classe06/Classe06.py | UTF-8 | 748 | 3.359375 | 3 | [] | no_license | import random
#create a random list
def urna ():
a = 8
b = 12
s = []
for i in range (0, 20):
x = random.randrange(1, 20)
if (x <= 8 & a > 0) | (b == 0):
s.append ("a")
a-=1
else:
s.append ("b")
b-=1
... | true |
ac162c2a370d79dc934db689208a2e89f7e9bea1 | Python | k-young-passionate/Baekjoon | /python_version/p17256.py | UTF-8 | 294 | 3.234375 | 3 | [] | no_license |
# b.x = c.x - a.z
# b.y = c.y / a.y
# b.z = c.z - a.x
def result():
a = input().split()
c = input().split()
a = list(map(int, a))
c = list(map(int, c))
b = [c[0] - a[2] , int(c[1] / a[1]), c[2] - a[0]]
r = ""
for i in b:
r += str(i) + " "
print(r) | true |
fd116d773e1dc8b406cb5b81f115d7f07db2f6cb | Python | kmgumienny/CS4341-Bomberman | /group26/scenario2/variant5.py | UTF-8 | 1,434 | 2.6875 | 3 | [] | no_license | # This is necessary to find the main code
import sys
sys.path.insert(0, '../../bomberman')
sys.path.insert(1, '..')
# Import necessary stuff
import random
from game import Game
from monsters.stupid_monster import StupidMonster
from monsters.selfpreserving_monster import SelfPreservingMonster
# TODO This is your code!... | true |
719625b0c3bd927a00347f87d81d3881d64a2c23 | Python | chaochaocodes/leetcode | /medium/maxVowels.py | UTF-8 | 1,776 | 4.28125 | 4 | [] | no_license | '''
Given a string s and an integer k.
Return the maximum number of vowel letters in any substring of s with length k.
Vowel letters in English are (a, e, i, o, u).
Input: s = "leetcode", k = 3
Output: 2
Explanation: "lee", "eet" and "ode" contain 2 vowels.
'''
s = "leetcode"
k = 3 # Output 2
# # Approach 1: Slidin... | true |
ed0a952aa5d0db3bcba7c63c11078ab9d97486ca | Python | bmoretz/Python-Playground | /src/Classes/MSDS400/PFinal/Q_02.py | UTF-8 | 974 | 3.015625 | 3 | [
"MIT"
] | permissive | # Northwest Molded molds plastic handles which cost $1.00 per handle to mold. The fixed cost to run the molding machine is $ 4,467 per week.
# If the company sells the handles for $4.00 each, how many handles must be molded weekly to break even?
from sympy import solve, lambdify, symbols, diff, pprint, pretty
imp... | true |
8d69b2d4f050dc01f0b6b9901d4b7ea39948c16e | Python | peterz5/TensorFlowPractice | /mnist_deep.py | UTF-8 | 3,233 | 2.546875 | 3 | [] | no_license | import argparse
import sys
import tempfile
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
FLAGS = None
def deepnn(x):
with tf.name_scope('reshape'):
x_image = tf.reshape(x, [-1, 28, 28, 1])
with tf.name_scope('conv1'):
W_conv1 = weight_variable([5,5,1,32])
b_conv1 = bias... | true |
6fed73c98f0dfefe234406f470cb19378f7e5173 | Python | dreipoe/Python | /LB1/1.2.py | UTF-8 | 162 | 3.125 | 3 | [] | no_license | import math
y = float(input('Введите y: '))
k = float(input('Введите k: '))
R = (math.sqrt(math.sin(y)**2+6.835))/(math.log1p(y+k)+3*y**2)
print(R)
| true |
e99b4baf279019c2e565772b2e102c7bd78c4cf1 | Python | Terfno/2018_report | /前期_python/python1/1_07.py | UTF-8 | 348 | 4.21875 | 4 | [] | no_license | # for 変数 in range(始まりの数値, 最後の数値, 増加する量):
#ループ処理
print('図1.12')
for i in range(5):
print(i)
print('図1.13')
for i in range(2,4):
print(i)
print('図1.14')
for i in range(5,1,-2):
print(i)
print('図1.15')
lst=list('python')
for c in lst:
print(c)
quit()
| true |
02119442ed7a621c063d4504224165edd16b4a0a | Python | codeAligned/LEETCodePractice | /Python/SortedListToBST.py | UTF-8 | 980 | 3.484375 | 3 | [
"MIT"
] | permissive | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class... | true |
c4eddc9024e713805761c3a072c032dcfca108b2 | Python | JStumpp/ai-lab-hska-rl | /notebooks/session_2/agent.py | UTF-8 | 1,668 | 3 | 3 | [] | no_license | """
Q-Learning implementation.
"""
import random
import math
import numpy as np
from typing import Tuple
from lib import AbstractAgent
class AdvancedQLearning(AbstractAgent):
def __init__(self, action_size: Tuple[int], buckets: Tuple[int, int, int, int],
gamma: float = None, epsilo... | true |
114695f8191ae537ebf64e61716dafbbe5b983fd | Python | xgalv00/docker-test-new | /stuff/server.py | UTF-8 | 644 | 2.671875 | 3 | [] | no_license | from flask import Flask, request
import threading
import time
import logging
app = Flask(__name__)
@app.before_first_request
def activate_job():
def run_job():
while True:
# logging.warning("Run recurring task")
time.sleep(0.25)
thread = threading.Thread(target=run_job)
t... | true |
84ce2ca2eddf0129c528dd6bfab63ca767344c50 | Python | cvdlab-alumni/416886 | /2013-05-10/python/exercise03.py | UTF-8 | 10,793 | 2.671875 | 3 | [] | no_license | from pyplasm import *
import scipy
from scipy import *
#---------------------------------------------------------
def VERTEXTRUDE((V,coords)):
"""
Utility function to generate the output model vertices in a
multiple extrusion of a LAR model.
V is a list of d-vertices (each given as a list ... | true |
1a8788d05a8609e6e706d5cdd7d4bab94cec36af | Python | evaportelance/cbl-lstm-learning | /code/Python/src/cbl_modified_baseline_model.py | UTF-8 | 15,333 | 3 | 3 | [] | no_license | ### DISCLAIMER : The following code is a slightly modified version of McCauley & Christiansen's (2019) openly available code for their Chunk-based Learner (CBL) (see https://github.com/StewartMcCauley/CBL). These modifications have been made in order to keep track of production scores by utterance length. A new flag, -... | true |
8f363ac1c78bbaefb71fd8ca714dfd70e3503912 | Python | ldecup/AdventOfCode2019 | /Day1/Day1.py | UTF-8 | 713 | 3.28125 | 3 | [] | no_license | #Status : Done
import math
input = "Day1\InputDay1.txt"
file = open(input, "r")
data = []
fuel = 0
fuelMod = 0
fuelTotal = 0
addFuel = 0
addFuelTotal = 0
line = file.readline().split('\n')[0]
while line:
data.append(int(line))
line = file.readline().split('\n')[0]
#For each module
for i in range(0, len(data)):
ad... | true |
91cc3410944c318124d4c68f606e182a1378f515 | Python | SamyMohamed1/cs236605-tutorials | /tutorial8/dann_train.py | UTF-8 | 6,143 | 2.796875 | 3 | [] | no_license | '''
This is a PyTorch implementation of 'Domain-Adversarial Training of
Neural Networks' by Yaroslav Ganin et al. (2016).
The DANN model uses the adversarial learning paradigm to force a
classifier to only learn features that exist in both domains. This
enables a classifier trained on the source domain to generalize... | true |
462a1c540a87c83ab615e13c71ae42645c52488d | Python | lidongze6/leetcode- | /1209. 删除字符串中的所有相邻重复项 II.py | UTF-8 | 530 | 3.453125 | 3 | [] | no_license | def removeDuplicates(s, k):
stack = []
for char in s:
if not stack:
stack.append([1, char])
elif stack[-1][1] == char:
if stack[-1][0] == k - 1:
n = k - 1
while n > 0:
stack.pop()
n -= 1
e... | true |
c382d0dd78311c19e0161a14fb374dc8b5542329 | Python | RomainCoquery/Webscrapping | /webscrapping_code/parse.py | UTF-8 | 245 | 2.90625 | 3 | [] | no_license | import requests
from bs4 import BeautifulSoup
def get_parsed(url):
"""Fonction pour appeler et analyser une page du site"""
response = requests.get(url)
if response.ok:
return BeautifulSoup(response.content, "html.parser")
| true |
aeef4e377cafb311b33dda3bd1d06e9944900d2c | Python | nastyachizhikova/Variation_in_SL_phonemes | /extract_holds.py | UTF-8 | 7,262 | 2.765625 | 3 | [] | no_license | # python 3.7.1
# Author: Anna Klezovich
# The script is based on Calle Börstell make_signs_still.py script for SSL and NGT
# https://github.com/borstell/make_sign_stills
# This script extracts holds for signs of RSL. 76.7% accuracy
import cv2, os
import numpy as np
import matplotlib.pyplot as plt
from scipy... | true |
af060e3406c6e077a9709db1cd543e6abb225863 | Python | ShlokKaushik23/HackWIE-Among-Us | /Self_organising_maps.py | UTF-8 | 934 | 2.640625 | 3 | [] | no_license | import numpy as np
import quandl
import matplotlib.pyplot as plt
import pandas as pd
import datetime
from sklearn.preprocessing import MinMaxScaler
df=pd.read_csv("Credit_Card_Applications.csv")
X=df.iloc[:,:-1].values
Y=df.iloc[:,-1].values
sc=MinMaxScaler(feature_range=(0,1))
X=sc.fit_transform(X)
from minisom impor... | true |
f7cc609712a62800e327e7f6938cc5b0edd40492 | Python | wfondrie/perc2ssl | /perc2ssl/perc2ssl.py | UTF-8 | 2,439 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | """
This is the main module of perc2ssl and the command line entry point.
"""
import os
import sys
import logging
import argparse
import time
import perc2ssl.parse as parse
DESC = """
Convert crux percolator results to .ssl format for BiblioSpec.
Given the log and tab-delimited files from a crux percolator run, this... | true |
4fcbe94657e045b82c6282a90833b6f63d94be7d | Python | alexander-albers/KIT-Modulhandbuch-Extractor | /extractor.py | UTF-8 | 2,400 | 2.546875 | 3 | [
"MIT"
] | permissive | import cas_parser
from constants import *
from time import sleep
import json
from tqdm import tqdm
import sys
degree = sys.argv[1] if len(sys.argv) > 1 else INDEX_URLS[0]
################################################################
# GET MODULES
################################################################
s... | true |
796e4218266dcbd8fa0ca512b90d725d504c4c3e | Python | Pratt-Institute/MicroPython4MicroBit | /radio-hello.py | UTF-8 | 698 | 3.171875 | 3 | [
"MIT"
] | permissive | # Simple radio example
# Adapted from https://microbit-micropython.readthedocs.io/en/latest/radio.html
import radio
from microbit import *
# The radio won't work unless it's switched on.
radio.on()
# pick a channel to transmit on:
# integer value from 0 to 83 (inclusive)
radio.config(channel=7)
# Event loo... | true |
50d165123d4145cad2c626783dc93a444a3a8061 | Python | kakshay21/PythonClassMOZILLA | /MyGraphV2.py | UTF-8 | 902 | 3.78125 | 4 | [] | no_license | #Graph ADT
#This ADT is for directed graph with no parallel edges
#For undirected graphs, during insertion and deletion, supply the values in both the directions
#The input is the weighted adjacent list
#Assume the weight as 1 for unweighted graph
class Graph:
def __init__(self):
self.graph = {}
... | true |
c142979f3ffda2cb51bbe880fa95e7c9fb52518d | Python | imtiaz-rahi/Py-CheckiO | /Home/Pawn Brotherhood/best-clear-3.py | UTF-8 | 300 | 2.984375 | 3 | [] | no_license | # https://py.checkio.org/mission/pawn-brotherhood/publications/Tarty/python-3/intersection
def safe_pawns(pawns):
safe = lambda s: {chr(ord(s[0]) - 1) + str(int(s[1]) - 1),
chr(ord(s[0]) + 1) + str(int(s[1]) - 1)}
return sum([bool(set(pawns).intersection(safe(p))) for p in pawns ])
| true |
3d09fec1e6ce7cf6720572437022f5400767fecf | Python | ouyangyike/Inference-Algorithm | /logistic regression/linear_vs_logistic/logistic_vs_linear_accuracy.py | UTF-8 | 1,152 | 2.65625 | 3 | [
"MIT"
] | permissive | import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
from logistic_adam import *
from linear import *
#learing rate = 0.1,batch_size = 500, epoch=20
logging_logistic = runLogistic(0.1,500,20)
logging_linear = runLinear(0.01,500,20)
#Loss on train set
plt.figure(1)
plt.plot(logging_logistic[:,3]... | true |
12399b7b3467437d103c7797235ad10bfce29e8f | Python | Su-Mo7743/SciProgCodeExamples | /ExampleCode/Loops/GuessGame.py | UTF-8 | 1,016 | 4.8125 | 5 | [] | no_license | """
Simple guess game select a random int between 1->9 and will ask you got
guesses in an infinite loop until you get it right.
Be very careful that you follow the indentation here,
"""
import random # Add the randon module
def main():
# Use randint to get number between 1 -> 9 (in... | true |
731b06a6d8b13c604e22117ca265a2ebb38789a0 | Python | pengyuhou/git_test1 | /leetcode/289. 生命游戏.py | UTF-8 | 1,273 | 3.171875 | 3 | [] | no_license | import copy
class Solution(object):
def gameOfLife(self, board):
"""
:type board: List[List[int]]
:rtype: None Do not return anything, modify board in-place instead.
"""
mark = copy.deepcopy(board)
res = copy.deepcopy(board)
m, n = len(board), len(board[0])
... | true |
d2b93e7f8b1883eede42bc3b13c3ee57b67ad319 | Python | SolDDAENG/py_pandas | /pack2/bs06weather.py | UTF-8 | 3,242 | 3.296875 | 3 | [] | no_license | import urllib.request
import urllib.parse
from bs4 import BeautifulSoup
import pandas as pd
url = "http://www.weather.go.kr/weather/forecast/mid-term-rss3.jsp"
data = urllib.request.urlopen(url).read() # read() : 바로 읽기
# print(data.decode('utf-8')) # 인코딩된 데이터를 디코드한다.
soup = BeautifulSoup(data, 'lxml')
# print(soup... | true |
0d63d7558d29a4fc4a9436b0e415611b5bdd9ec6 | Python | contranton/IIC2233 | /Actividades/AC07/metaclases.py | UTF-8 | 1,251 | 2.75 | 3 | [] | no_license | import funciones
class MetaAuto(type):
def __call__(cls, *args):
new_car = type.__call__(cls, *args)
if hasattr(cls, "cars"):
if len(getattr(cls, "cars")) >= 3:
return None
getattr(cls, "cars").append(new_car)
return new_car
cls.cars = [... | true |
143eb7417ab0d641943e907902ea400e1599f726 | Python | KunyiLiu/algorithm_problems | /kunyi/data_structure/merge_k_sorted_list.py | UTF-8 | 2,125 | 3.9375 | 4 | [] | no_license | """
Definition of ListNode
class ListNode(object):
def __init__(self, val, next=None):
self.val = val
self.next = next
"""
class Solution:
"""
@param lists: a list of ListNode
@return: The head of one sorted list.
"""
def mergeKLists(self, lists):
# method 1: from bottom... | true |
fed6b4cbd5bc2551e3355a6ec165dc2a586d8687 | Python | GVK289/aws_folders | /clean_code/clean_code_submissions/clean_code_assignment_004/fb_post/utils/fb_post_get_replies_for_comment.py | UTF-8 | 966 | 2.71875 | 3 | [] | no_license | from fb_post.constants import DatetimeFormat
from fb_post.models import Comment
from .fb_post_exception_methods import check_whether_comment_id_exists
from .user_info import dict_of_user_info
# Task 15
def get_replies_for_comment(comment_id):
check_whether_comment_id_exists(comment_id)
replies_list = list(Com... | true |
feb276c3e79c0e656db0ccb621eded1cb6b1b74b | Python | AndySchlosser/Scratch | /QuickSort.py | UTF-8 | 294 | 2.90625 | 3 | [] | no_license | def sort(list):
if len(list) <= 1:
return list
smallerList = []
largerList = []
pivot = list[0]
for c in range(1, len(list)):#en(list)):
if list[c] <= pivot:
smallerList.append(list[c])
else:
largerList.append(list[c])
return (sort(smallerList) + [pivot] + sort(largerList))
| true |
80f7f5e2953d7a6308c6c22e8530dfa58affdc76 | Python | dhamejanishivam/Python-Backup | /More on files.py | UTF-8 | 557 | 3 | 3 | [] | no_license | a = open("shivam.txt")
print(a.readline())
a.seek(16)
print(a.readline())
a.seek(32)
print(a.readline())
a.close()
# a = open("shivam.txt")
# print(a.tell())
# print(a.readline())
# print(a.tell())
# print(a.readline())
# print(a.tell())
# print(a.readline())
# print(a.tell())
# print(a.readline())
# print(a.tell())
# ... | true |
43903d3a9d25ca3ce105301ee2fd7174f85d1894 | Python | joannasoh/ProgrammingI | /ProgrammingISemester2/Term3/JSShapes/Box.py | UTF-8 | 313 | 3.109375 | 3 | [] | no_license | class Box():
def __init__(self,length,breadth,height):
self.length = length
self.breadth = breadth
self.height = height
def getVolume(self):
self.volume = (length * breadth * height)
return volume
def getSurfaceArea(self):
self.sArea = (2 * length * height) + (2 * length * breadth)
return sArea
| true |
98759483cac8586321144567a8e619acacd6cb22 | Python | pavlenstory/AByteOfPythonReadyLessons | /39_Ввод от пользователя(палиндром)/user_input.py | UTF-8 | 544 | 4.34375 | 4 | [] | no_license | #Указание отрицательного шага,
# т.е. -1 приведёт к выводу текста
#в обратном порядке(:-1) ЧИТАЕТ ТЕКСТ В ОБРАТНО ПОРЯДКЕ
def reverse(text):
return text[::-1]
def is_palindrome(text):
return text != reverse(text) # != это обозночает не равен
something = input('Введите текст: ')
if is_palindrome(something):
... | true |
fc206468a33cb8251344a2b89e266df08055a229 | Python | umian/testing99 | /file02.py | UTF-8 | 586 | 2.65625 | 3 | [] | no_license | import sys
# mydata = open("C:/Users/usman/Documents/myapp/testing99/test01/download.png", "rb").read(1024)
# for x in mydata:
# print(x, end="")
if len(sys.argv)== 1:
print("not arg given---",len(sys.argv))
sys.exit
print("not arg given---",len(sys.argv))
print(sys.argv[0],sys.argv[1])
print("___________... | true |
daff3f74fe1f457357b0af78f0214fd3d29f7d8c | Python | anderser/textract | /textract/parsers/docx_parser.py | UTF-8 | 324 | 2.71875 | 3 | [
"MIT"
] | permissive | import docx
from .utils import BaseParser
class Parser(BaseParser):
"""Extract text from docx file using python-docx.
"""
def extract(self, filename, **kwargs):
document = docx.Document(filename)
return '\n\n'.join([
paragraph.text for paragraph in document.paragraphs
... | true |
76371788f030ab74562712932bb75440bd16d4f5 | Python | wangyum/Anaconda | /lib/python2.7/site-packages/sympy/interactive/tests/test_ipython.py | UTF-8 | 2,472 | 3.015625 | 3 | [
"Python-2.0",
"Apache-2.0",
"BSD-3-Clause",
"LicenseRef-scancode-unknown"
] | permissive | """Tests of tools for setting up interactive IPython sessions. """
from sympy.interactive.session import (init_ipython_session,
enable_automatic_symbols, enable_automatic_int_sympification)
from sympy.core import Symbol, Rational, Integer
from sympy.external import import_module
# TODO: The code below could be m... | true |
5e1935fbbc0ac60cc9cdef89bfc9073606e28a36 | Python | PyeongGang-Kim/TIL | /algorithm/백준/17825.py | UTF-8 | 2,485 | 3.359375 | 3 | [] | no_license | # move 함수는 말이 처음 이동할 때
score_list = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 13, 16, 19, 25, 26, 27, 28, 22, 24, 30, 35]
move = [
[0, 1, 2, 3, 4, 5],
[0, 2, 3, 4, 5, 6],
[0, 3, 4, 5, 6, 7],
[0, 4, 5, 6, 7, 8],
[0, 5, 6, 7, 8, 9],
[0, 21, 22, 23, 24, 30],
... | true |
85a17047bc108250cf945819caff9c91c8ad3cf9 | Python | npkhanhh/codeforces | /python/1263A.py | UTF-8 | 170 | 3.3125 | 3 | [] | no_license |
n = int(input())
for _ in range(n):
a, b, c = sorted(list(map(int, input().split())))
if a + b >= c:
print(int((a+b+c)/2))
else:
print(a+b)
| true |
f7459ea4af76c01d24d9a3623871eff1f1ca4f9e | Python | colioportfolio/Best-Time-to-Buy-and-Sell-Stock | /main.py | UTF-8 | 154 | 2.6875 | 3 | [] | no_license | from solution import Solution
lst = []
lst = [int(item) for item in input("Enter the stock prices: ").split()]
prices = Solution()
prices.maxProfit(lst) | true |
9cfb39b61ed6b3abc802ba0ec976c34f104a4ca9 | Python | erisky/my_practices | /codeJam/2018_ks_4A/solve_B.py | UTF-8 | 1,181 | 2.96875 | 3 | [
"MIT"
] | permissive | # raw_input() reads a string with a line of input, stripping the '\n' (newline) at the end.
# This is all you need for most Google Code Jam problems.
T = int(raw_input()) # read a line with a single integer
for Ti in xrange(1, T + 1):
tmp = raw_input().split()
N = int(tmp[0])
K = int(tmp[1])
P = int(tm... | true |
ace593134069e0a10ca09cb6ac33542b1ed7a6b4 | Python | jnu/ncaa | /ncaalib/aux/terminal.py | UTF-8 | 5,881 | 3.078125 | 3 | [
"MIT"
] | permissive | # -*- coding:utf8 -*-
'''
$ python terminal.py
Module for basic terminal output manipulation.
Should work on on *nix, on most xterm-based consoles.
Largely untested, though.
Implements 'save' and 'unsave' (ESC+[s and ESC+[u)
which most terminals do not honor.
Copyright (c) 2013 Joseph Nudell
Freely distributable un... | true |
ae539c9a8f8e25269498941b31f6122381bc67df | Python | beigerice/Project-Euler | /problem 77.py | UTF-8 | 539 | 3.28125 | 3 | [] | no_license | import math
n = 3
i = 0
primelist = []
primelist.append(2)
while n < 100:
if primelist[i] <= math.sqrt(n):
if n%primelist[i] > 0:
i += 1
else:
n += 2
i = 0
else:
primelist.append(n)
n += 2
i = 0
for target in range(10,100):
x = []
for prime in primelist:
if prime... | true |
07db2252811439505acc9780cababedeeb156c75 | Python | abhilashnirala/DSAD_Project | /DSAD/common_utils.py | UTF-8 | 471 | 2.734375 | 3 | [] | no_license | import json
import datetime
from os import path, makedirs
def get_abs_path(*paths):
return path.abspath(path.join(*paths))
def get_data_dir(file_name):
return get_abs_path(__file__, "../"+file_name)
def get_output_dir():
return get_abs_path(__file__, "../")
def get_content_from_file(file_path):
wi... | true |
02302b7e510591e53b01534ed890e9a2f5211a1e | Python | possible1402/national-science-exports | /libs/nsp/nsp/core.py | UTF-8 | 11,517 | 3.09375 | 3 | [] | no_license | """ core utils for the project """
import os
from collections import Counter
from itertools import combinations
import matplotlib.pyplot as plt
import networkx as nx
import numpy as np
import pandas as pd
from mpl_toolkits.axes_grid1 import make_axes_locatable
""" Gini """
def gini_coef(alist):
""" Gini Coeffic... | true |
7760ef27a93874b23a030b6c392e312701b1a251 | Python | DobroSun/py_set | /test_upload/test_compare.py | UTF-8 | 1,395 | 3.265625 | 3 | [] | no_license | #!/usr/bin/env python3
from py_set import pyset
import time
import sys
import random
random_list = [random.randrange(-1000000, 2000000) for _ in range(1000000)]
pst = pyset()
st = set()
lst = list()
print()
print("*** Adding elements ***")
start = time.time()
for i in range(1000000):
lst.append(i)
end = time.ti... | true |
f0ea448f5eda443bc13e648b28c50031e101c9da | Python | kehl/python_intro | /integration.py | UTF-8 | 1,122 | 3.875 | 4 | [] | no_license | __author__ = 'lois'
import numpy as np
def simpson(f, a, b, n):
delta = (b - a)/n
x = np.linspace(a, b, n + 1)
s= 0
for i in range(0, n, 2):
s += f(x[i]) + 4*f(x[i + 1]) + f(x[i+2])
return (delta/3)*s
if __name__ == "__main__":
print("For Simpson, Integral of x^2-1 from -2 to 2 is: ",si... | true |
961836343b20805268179318beb4787549024e30 | Python | XingxinHE/PythonCrashCourse_PracticeFile | /Chapter 6 Dictionary/6-11.py | UTF-8 | 855 | 3.4375 | 3 | [] | no_license | cities={
'Tengchong':{
'country':'China',
'population':'65990',
'fact':'650 km west of Kunming.'
},
'Toronto':{
'country':'Canada',
'population':'2731571',
'fact':'a centre of busines... | true |
f722deabe56785c49404017be9c8b0109f30fedd | Python | kburova/MapReduce | /stopwords.py | UTF-8 | 427 | 3.203125 | 3 | [] | no_license | #!/usr/bin/env python
import sys
import operator
words_limit=100
stopwords = {}
for line in sys.stdin:
word, count = line.strip().split('\t', 1)
stopwords[word] = int(count)
sw_sorted = sorted(stopwords.items(), key=operator.itemgetter(1), reverse=True)
file = open("list.txt", "w")
for i in range(words_limit):
f... | true |
4f1866e7fd05a32aeea041755b69dcc9c9f5767e | Python | jbhoffman613/cs393r_hw2 | /lidar_vis.py | UTF-8 | 277 | 3.296875 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
f = open('temp.txt')
d = int(f.readline())
print(d)
x = []
y = []
for i in range(d):
line = f.readline().split()
x.append(float(line[2]))
y.append(float(line[3]))
print(x)
print(y)
plt.scatter(x, y)
plt.show() | true |
af90b741b885c42515524b293c65feb5679c1b7d | Python | ivanlyon/exercises | /kattis/k_gamerank.py | UTF-8 | 1,007 | 3.53125 | 4 | [
"MIT"
] | permissive | '''
Create a game rank from a win-loss record
Status: Accepted
'''
###############################################################################
def main():
"""Read input and print output"""
rank_stars = [5] * 11 + [4] * 5 + [3] * 5 + [2] * 5
rank, stars, last3 = 25, 0, ''
for game in input():
... | true |
7b9e61b901deebc2bd0da818fea4b1d0256ef144 | Python | Suffoquer-fang/tianshou | /examples/dqn.py | UTF-8 | 2,590 | 2.5625 | 3 | [
"MIT"
] | permissive | import tensorflow as tf
import gym
import numpy as np
import time
import tianshou as ts
if __name__ == '__main__':
env = gym.make('CartPole-v0')
observation_dim = env.observation_space.shape
action_dim = env.action_space.n
# hyper-parameters
batch_size = 32
seed = 123
np.random.seed(see... | true |