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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
8b5a14f144b619b9fb39d9cf6784723eeddf81ff | Python | dongyingdepingguo/PTA | /pta_practice/PTA1039.py | UTF-8 | 1,498 | 4.28125 | 4 | [] | no_license | # !/usr/bin/env python
# _*_ coding: utf-8 _*_
"""
1039 到底买不买 (20 分)
小红想买些珠子做一串自己喜欢的珠串。卖珠子的摊主有很多串五颜六色的珠串,但是不肯把任何一串拆散了卖。于是小红要你帮忙判断一下,
某串珠子里是否包含了全部自己想要的珠子?如果是,那么告诉她有多少多余的珠子;如果不是,那么告诉她缺了多少珠子。
为方便起见,我们用[0-9]、[a-z]、[A-Z]范围内的字符来表示颜色。例如在图1中,第3串是小红想做的珠串;那么第1串可以买,
因为包含了全部她想要的珠子,还多了8颗不需要的珠子;第2串不能买,因为没有黑色珠子,并且少了一颗红色的珠子。
输入格式:... | true |
367dfc1c962e76d9e30d9f31b3c79435323ba0b2 | Python | MartinDowell/Test1 | /Python Files/Monty Test 3.py | UTF-8 | 226 | 3.40625 | 3 | [] | no_license | #Monty Test 3
shop = {
'apples' : [2, 11],
'pears': 7,
'bananas' : 5,
'raspberries' : 8,
'strawberries' : 9}
gash = shop.keys()
print (gash)
foo=[]
for a,b in shop.items():
foo.append(b)
print (foo)
| true |
14168c07119d6147b9d7ebd8c1a3470370ac9fea | Python | TJmask/Space-Health-Predicting | /Codes/generate_data_500ms_nor.py | UTF-8 | 11,604 | 2.8125 | 3 | [
"MIT"
] | permissive | import os
import glob
import pandas as pd
import numpy as np
import scipy as sp
from scipy.interpolate import interp1d
from datetime import timedelta
from sklearn import preprocessing
from sklearn.preprocessing import MinMaxScaler
# import matplotlib.pyplot as plt
import warnings
from pandas.core.common im... | true |
7dc6ba8e6e9d5089072dde43a52816fd90f52175 | Python | Shamya/multiLingRep | /libraries/embeddings.py | UTF-8 | 5,078 | 2.921875 | 3 | [] | no_license | import os
import numpy as np
import nltk, re, pprint
import django
import codecs
from gensim import models
from django.utils.encoding import smart_str
from bs4 import BeautifulSoup
from nltk import tokenize
from random import shuffle
from libraries.acs import acs
import time
import pickle
from gensim.parsing import Po... | true |
34afd3ca93f4a3062cab4da99d67d20665603a85 | Python | ChangtongZhou/School_AI_Projects | /nario.py | UTF-8 | 7,838 | 3.71875 | 4 | [] | no_license | import sys
import argparse
import math
import heapq
class Graph:
def __init__(self):
self.states = []
# Turn the board matrix into an array that contains coordinates without obstacles
def makeCoordinates(self):
nario = Nario()
board = nario.board
rows, cols = len(board), len(b... | true |
092819012e2b9aea847aa6f04a1f09522d1747c0 | Python | renanfe/studybook | /python/example 2/aluno.py | UTF-8 | 387 | 3.625 | 4 | [] | no_license | class Aluno:
def __init__(self, nome, email="default@gmail.com"):
self.__nome=nome
self.__email=email
def getNome(self):
return self.__nome
def getEmail(self):
return self.__email
def setNome(self, nome):
self.__nome = nome
def setEmail(self, email):
self.__email = email
... | true |
f918f1673d8a0781afbd3a4d46d8af558e9ce88c | Python | ISPritchin/Olympiad | /900/Оформлено/Сеть компании Bmail.py | UTF-8 | 150 | 2.875 | 3 | [] | no_license | n = int(input())
a = [0, 0] + list(map(int, input().split()))
b = []
i = n
while a[i] != 0:
b.append(i)
i = a[i]
b.append(1)
print(*b[::-1])
| true |
be410fa2ef91e246c21161db1c0b0ca5714d9ba9 | Python | talepre/AIProg | /module3/board.py | UTF-8 | 3,801 | 3.0625 | 3 | [] | no_license | from itertools import combinations, izip_longest
from probleminstance import Probleminstance
class Board():
'''
Class responsible for parsing the board from a text file, and making the domain and constraint dictonaries.
'''
def __init__(self, file):
'''
Initializes with a file, and reads its data.
'''
fi... | true |
6954841512d34408609e3c4589b967ba684195d6 | Python | mlgmya/Python | /百度百科/a.py | UTF-8 | 357 | 2.578125 | 3 | [] | no_license | import requests
from bs4 import BeautifulSoup
headers={"User-Agent":"Mozilla/5.0(Windows;U;Windows NT 6.0 x64;en-US;rv:1.9pre)Gecko/2008072421 Minefield/3.0.2pre"}
r=requests.get("https://baike.baidu.com/",headers=headers)
html=r.text
bsObj=BeautifulSoup(html)
for link in bsObj.findAll("a"):
if 'href' in link.att... | true |
e05ab33ac53bee536ea169a7f3617560db6f22ae | Python | rabinwill/Python | /Python_Examples/Queues&Stacks.py | UTF-8 | 1,917 | 4.78125 | 5 | [] | no_license | '''
A palindrome is a word, phrase, number, or other sequence of characters which reads the same backwards and forwards. Can you determine if a given string, s, is a palindrome?
To solve this challenge, we must first take each character in s, enqueue it in a queue, and also push that same character onto a stack. Once ... | true |
7378988b55182fd5f1129391c3d6d49a4f87c959 | Python | casahome2000/wz_jira | /config.py | UTF-8 | 15,646 | 2.625 | 3 | [] | no_license | __author__ = 'casahome2000'
import dateHandler
def calcReleaseDate(prevRelease, currentDuration):
date = dateHandler.date_by_adding_business_days(dateHandler.datetime.datetime(dateHandler.dateTODAY.year,
dateHandler.dateTODAY.month,
dateHandler.dateTODAY.day),
... | true |
a51738a0c0abf17a87ec1f086e1c26e37f861ba0 | Python | dinh/Config-Management | /Vim/bin/vimw-diary-template.py | UTF-8 | 2,054 | 2.78125 | 3 | [] | no_license | #!/usr/bin/env python
# @(#) gen-vimw-diary-template.py
# Last-edited: Mon 2021.01.04.0745 -- Danny Quah (me@DannyQuah.com)
# ----------------------------------------------------------------
# Revision History:
# % Sat 2020.09.26.0659 -- Danny Quah (me@DannyQuah.com)
# First draft: Template for Vimwiki diary
# ... | true |
ae038e4753deb705a1959ae02ff1c39c92b9919c | Python | capJavert/renamer | /renamer.py | UTF-8 | 1,189 | 2.890625 | 3 | [] | no_license | import click
# encoding=utf8
import os
# !/usr/bin/python
# -*- coding: utf8 -*-
__author__ = '@capJavert'
@click.command()
@click.option('--path', '-P', default=".", help='Path to directory where files/directories you want '
'renamed are located. Defaults to current d... | true |
dbc56e0be47cda8b7bf851b3e49e7b8ca8b4d058 | Python | stroobandt/lua-filters | /minted/run_minted_tests.py | UTF-8 | 16,777 | 2.84375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env python
"""
Unit tests for the pandoc minted.lua filter.
"""
# Lint this file with: flake8 --max-line-length=80
import os
import string
import subprocess
import sys
import textwrap
code_block = textwrap.dedent('''
## A Code Block
```{.cpp}
auto mult = []<typename T, typename U>(T const & x... | true |
8dcdbfeeb99800eda85dfd3ca80b80a3c78c07a0 | Python | skyscience/Python | /爬虫学习/7/csv文件处理.py | UTF-8 | 1,058 | 3.390625 | 3 | [] | no_license | # csv:其实就是一种数据保存的格式,每个字段之间,以逗号分割,
# 有头部
import csv
list = [
{'name':'fxm','class':201,'age':20,'hight':175},
{'name':'zy','class':201,'age':22,'hight':180},
{'name':'zzh','class':201,'age':24,'hight':180},
{'name':'ltt','class':201,'age':21,'hight':160},
{'name':'xnsk','class':201,'age':22,'hight':... | true |
019e882f8ae78eb9c6073beeaf3bd634abec761d | Python | christus02/citrix-adc-metrics-exporter-serverless | /utils/metrics-template-creator/metrics-template-creator.py | UTF-8 | 2,126 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | import json
import copy
IN_JSON = "metrics.json"
OUT_JSON = "out.json"
#Read the input metrics json
with open(IN_JSON) as f:
metrics = json.load(f)
f.close()
UNIT_CONVERSION = [
{"key": "_mbits_rate", "value": "Megabits/Second"},
{"key": "_mbits", "value": "Megabytes"},
{"key": "_mb", "value": "Megaby... | true |
f3306127c76c865b1b63b70ab483a3af2cdb2f2e | Python | timnaire/case | /models/subpractice.py | UTF-8 | 1,408 | 2.6875 | 3 | [] | no_license | import logging
from google.appengine.ext import ndb
from models.lawyer import Lawyer
class Subpractice(ndb.Model):
practice = ndb.KeyProperty(kind=Practice)
subpractice = ndb.StringProperty()
created = ndb.DateTimeProperty(auto_now_add=True)
updated = ndb.DateTimeProperty(auto_now=True)
@classmeth... | true |
c9d447ca0d0bf7e2ed43ec94f0fd48f965c8ea6d | Python | stratosthirios/mmgroup | /src/mmgroup/generate_c/testcode.py | UTF-8 | 669 | 2.890625 | 3 | [
"MIT"
] | permissive | from generate_functions import UserDirective
from make_c_tables import TableGenerator
class TestGen:
def add_to(x, expr):
return "{x} = {x} + {expr};\n".format(x = x, expr = str(expr))
functions = {
"AddTo": UserDirective(add_to, "si"),
}
tables = {
"y" : [1,2,3],
... | true |
aad201b8b947dcbb5e7145b6904d29b359f09eeb | Python | wondper/2dgp-homework | /git main/2dgp_homework/2dgp week2-1/20200910_grid1.py | UTF-8 | 410 | 3.515625 | 4 | [] | no_license | import turtle as t
t.speed(0)
size = 30
count = 19
linelength = count * size
t.penup()
t.goto(-100, -200)
t.pendown()
def line(start, end):
t.penup()
t.goto(*start)
t.pendown()
t.goto(*end)
x1, y1 = t.pos()
x2, y2 = x1 + linelength, y1 + linelength
for i in range(count + 1):
n = i * siz... | true |
46477810b0fbf99848db811ea394f111be35b373 | Python | ymei/TMSPlane | /Hardware/PCB/KiCadScript/KiAuto/util.py | UTF-8 | 374 | 2.578125 | 3 | [
"BSD-3-Clause"
] | permissive | ## \file
# Utility routines.
#
from __future__ import print_function
import pcbnew
## 1nm is the smallest dimension in KiCAD
_SCALE = 1000000.0
## convert x in [mm] to native scale
def mm(x):
return int(_SCALE * x)
#return pcbnew.FromMM(x)
## convert x in [mil] to native scale
def mil(x):
return int(_SCA... | true |
b4b07a3045ad215e8f433b0aaa6d1c1990e89bdc | Python | compMathUPRH/wolffia | /lib/chemicalGraph/io/PSF.py | UTF-8 | 9,764 | 2.53125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Copyright 2011, 2012: José O. Sotero Esteva,
Computational Science Group, Department of Mathematics,
University of Puerto Rico at Humacao
<jse@math.uprh.edu>.
(On last names: Most hispanic people, Puerto Ricans included, use two surnames;
one from the father an... | true |
093c83ffcd736f6aa5cca146bb141cea265734f5 | Python | H0bbyist/hero-rpg | /characters/zombie.py | UTF-8 | 459 | 3.59375 | 4 | [
"MIT"
] | permissive | from characters.base import Character
class Zombie(Character):
def __init__(self):
self.name = "Zombie"
self.health = 5
self.power = 1
self.prize = 0
def alive(self):
return True
def receive_damage(self, points):
self.health -= points
print(... | true |
a7b7cead6ea4368d09423119b7e2c12d11571ac2 | Python | Shashank-Bhari/Handwritten-Words-Recognition | /wknn.py | UTF-8 | 992 | 2.515625 | 3 | [] | no_license | import numpy
from sklearn.neighbors import KNeighborsClassifier
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split
import skimage.io
from skimage.feature import hog
import os
path='words1/train/'
hog_list=[]
labels=[]
f=open('pre.txt','+w')
for i in range(1,211):
path1... | true |
3c35a9d48ef39c442b7bc7dd7386438c16c68547 | Python | pohily/checkio | /house-password.py | UTF-8 | 1,397 | 3.390625 | 3 | [] | no_license | def checkio(data: str) -> bool:
if len(data)<10:
return False
digit = False
lower = False
upper = False
for letter in data:
if letter.isdigit():
digit = True
elif letter.islower():
lower = True
elif letter.isupper():
upper = True
... | true |
055ac2a58ac87e9751a68db464990a33410fa9b1 | Python | ndz-v/grades | /src/presentation_service.py | UTF-8 | 5,106 | 3.21875 | 3 | [] | no_license | import click
import os
class PresentationService:
window_width = 0
small_ratio = 0
big_ratio = 0
def __init__(self):
self.window_width = os.get_terminal_size().columns
self.small_ratio = int(self.window_width*0.08)
self.big_ratio = int(self.window_width*0.3)
def print_sub... | true |
b3fa563891e5f6d207ea60a8481f6c36d3c571ad | Python | ProfessorSean/Kasutamaiza | /upcfcardsearch/c132.py | UTF-8 | 1,041 | 2.53125 | 3 | [
"MIT"
] | permissive | import discord
from discord.ext import commands
from discord.utils import get
class c132(commands.Cog, name="c132"):
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.command(name='Atamotona', aliases=['c132'])
async def example_embed(self, ctx):
embed = discord.Embed(title='... | true |
ca1622fa5a777c58a19a5e99f74d22e1cf51885f | Python | yeyintminthuhtut/hack_audio_captcha | /split_loud_voice.py | UTF-8 | 3,037 | 2.84375 | 3 | [] | no_license | '''
Quick and dirty way to generate separate wav files depending on the loud voice detected in audio captcha challenge.
Lots of room for improvement.
Author : Debasish Mandal
http://www.debasish.in/
'''
import wave
import sys
import struct
import os
import time
import httplib
from random import randint
ip = wave.op... | true |
da57628ad144b0b7254709d4cb960d7e3eff45fe | Python | Corovino/credito | /comh.py | UTF-8 | 209 | 2.75 | 3 | [
"MIT"
] | permissive | import os
tipo = raw_input("Ingrese el tipo: ")
msj = raw_input("Ingrese el mensaje: ")
os.system('git add .')
os.system("""git commit -am '{"responsable": "Hebert Romero","tipo": "%s", "msj": "%s"}' """ %(tipo,msj)) | true |
47488e32da43503ca9d14c0439cf0d2942b201b3 | Python | salgado/python_stuffs | /jsonassg.py | UTF-8 | 459 | 3.296875 | 3 | [] | no_license | # get json form url
import json
import urllib
url = raw_input('Enter url: ')
if len(url) < 1 : exit
print 'Retrieving', url
uh = urllib.urlopen(url)
data = uh.read()
print 'Retrieved',len(data),'characters'
try: info = json.loads(str(data))
except: info = None
#print json.dumps(info, indent=4)
sum = 0
num = 0
for i... | true |
c8b4870a29ae311b310bdc7bfb240cfb4cea36d4 | Python | thiaagodev/Curso_Python_Mundo_1 | /PythonExercicios/ex019.py | UTF-8 | 370 | 3.828125 | 4 | [] | no_license | import random
aluno1 = input('Digite o nome do aluno número 1: ')
aluno2 = input('Digite o nome do aluno número 2: ')
aluno3 = input('Digite o nome do aluno número 3: ')
aluno4 = input('Digite o nome do aluno número 4: ')
lista = [aluno1, aluno2, aluno3, aluno4]
aluno_escolhido = random.choice(lista)
print('O aluno... | true |
07a092c99f580b10e8a24d488ba29670b5a324f8 | Python | sakanack/AtCorder | /AtCoderBeginnerContest148/D.py | UTF-8 | 256 | 2.953125 | 3 | [] | no_license | N = int(input())
a = list(map(int, input().split()))
breakCount = 0
orderCount = 1
for i in range(N):
if(a[i] == orderCount):
orderCount += 1
continue
breakCount += 1
if(breakCount == N):
print(-1)
else:
print(breakCount) | true |
7e015433bb5021dfa77360c58ab81e948b200a56 | Python | swapnil8424/DSA-in-python | /lab1\/LinkedList.py | UTF-8 | 2,685 | 4.34375 | 4 | [] | no_license | class LinkedList:
"""Defines a Singly Linked List.
attributes: head"""
def __init__(self):
"""Create a new list with a Sentinel Node"""
self.head=ListNode()
def insert(self,x,p):
"""Insert element x in the position after p"""
temp=ListNode()
temp.value=x
... | true |
843a11c9ffd8879802ee75ff8c4d8a462b7a49b8 | Python | Dude036/BlackjackPy | /cards.py | UTF-8 | 2,184 | 3.765625 | 4 | [] | no_license | #!/usr/bin/python
import random
class Card(object):
rank = 1
suit = 'S'
"""docstring for Card"""
def __init__(self, newRank, newSuit):
self.rank = newRank
self.suit = newSuit
def __add__(self, other):
return self.rank + other.rank
def __radd__(self, other):
return self.rank + other
def __gt__(self, o... | true |
54332236a0b39758dfa4cd5023edad7c80b36a1e | Python | GuodongQi/LeetCode | /codes_1-50/11_Container_With_Most_Water.py | UTF-8 | 545 | 3.078125 | 3 | [] | no_license | class Solution:
def maxArea(self, height):
"""
:type height: List[int]
:rtype: int
"""
m = len(height)
start = 0
end = m - 1
cont_most = 0
while start < end:
if height[start] < height[end]:
h = height[start]
... | true |
ad6d0ec4d92a2b34e080d5b4fb164f5521db1e4f | Python | thibs911/SergeSlack | /serge.py | UTF-8 | 4,154 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from messaging import new_message
import database_connector
from random import randint
import requests
from params import params
import json
from quizz import Quizz
# randint is inclusive
def treat_message(message, ws):
if 'type' in message:
if message['type']... | true |
f880efb60a2ea9d04b036d918db20d418c77636a | Python | tanyastropheus/holbertonschool-higher_level_programming | /0x0B-python-input_output/12-student.py | UTF-8 | 542 | 3.5 | 4 | [] | no_license | #!/usr/bin/python3
"""contains class Student"""
class Student:
def __init__(self, first_name, last_name, age):
self.first_name = first_name
self.last_name = last_name
self.age = age
def to_json(self, attrs=None):
"""retrieves a dictionary representation of a class Student inst... | true |
3a1c3bb27dfa6954339ed404451e451ea83ada12 | Python | mk270/covid19-uk-growth | /scrape_cases | UTF-8 | 1,333 | 2.59375 | 3 | [] | no_license | #!/usr/bin/env python3
import argparse
import datetime
import database
import sys
import logging
import os
import api_client
iso_date_fmt = "%Y-%m-%d"
def today_iso(days_ago):
then = datetime.datetime.now() - datetime.timedelta(days_ago)
return then.strftime(iso_date_fmt)
def run():
parser = argparse.Ar... | true |
d2d9bb596d325bbdd1ff7b5b1fad0f6cbe1ca926 | Python | Kohdz/Algorithms | /LeetCode/medium/72_kokoEatingBananas.py | UTF-8 | 716 | 3.625 | 4 | [] | no_license | # https://leetcode.com/problems/koko-eating-bananas/
# https://www.youtube.com/watch?v=Sp2sRLcLND0
# https://leetcode.com/discuss/general-discussion/786126/python-powerful-ultimate-binary-search-template-solved-many-problems
import math
def minEatingSpeed(piles, H):
def feasible(speed):
... | true |
53384d0f8d64944004e4d8951cc0083e82a53c25 | Python | ksopyla/numbers_recognition | /data_helpers.py | UTF-8 | 2,861 | 3 | 3 | [] | no_license | import numpy as np
import os
from scipy.misc import imread
def load_dataset(digits_dir,img_size, digits_count, max_files=float('inf')):
'''
loads digit dataset, folder structure:
Digit_2/
Font_name1/
00_timestamp.png
...
99_timestamp.png
Font_name2/
... | true |
72dc187c4453acbd981e58210d8b1a594c606425 | Python | JDiegoS/Proyecto1-Software-Renderer | /lib.py | UTF-8 | 3,434 | 3.21875 | 3 | [] | no_license | import struct
from collections import namedtuple
#Extraido de (no es la respuesta aceptada) https://stackoverflow.com/questions/28253102/python-3-multiply-a-vector-by-a-matrix-without-numpy
def matrixMul(a, b):
c = []
for i in range(0,len(a)):
temp=[]
for j in range(0,len(b[0])):
s ... | true |
a69771756dd8b34fb327881783b49e161b78992d | Python | mgramli1/pyelixys | /pyelixys/utils/flashlpc.py | UTF-8 | 13,465 | 2.515625 | 3 | [
"BSD-3-Clause"
] | permissive | # UCLA EE202A - LPC1768 Programmer for Python
# November 27, 2010
#issues baudrate too slow --> missed messages
import sys
import time
from time import sleep
import serial
import getopt
import binascii
import struct
def hostPrint(msg):
now = time.localtime(time.time())
print time.strftime("%Y-%m-%d %H:%M:%S ... | true |
a67c6e21d7af9fafa17ffb4694a3124a51cf09e5 | Python | asdasdqwdqwfsdf/FiniteElement | /Part2_code/test_Nanna.py | UTF-8 | 1,955 | 2.578125 | 3 | [] | no_license | from Part2_code.getplate import getPlate
from matplotlib import pyplot as plt
import numpy as np
from Part2_code.linearElasticity2D import homogeneousDirichlet
from Part1.plot import plot
def PlotMesh(N):
"""Plotting mesh covering the unit disc with N nodes"""
p, tri, edge = getPlate(N)
#print(p,tri,ed... | true |
4dc61fc6240ba5078b8bd5a08381d0883c3ca8e3 | Python | honzaMaly/my-alternatives | /model/transactions.py | UTF-8 | 583 | 2.921875 | 3 | [] | no_license | """Transaction Entities"""
import datetime
from model import ATransaction, AProfile, APlace
class Transaction(ATransaction):
def __init__(self, created: datetime.date, user: AProfile, place: APlace):
super().__init__(created)
self.user: AProfile = user
self.place: APlace = place
def ... | true |
23d22a7324b148a628c862354e81bf8f88d54306 | Python | ken2190/EPFLx-RoboX-Neurorobotics-utils | /epflx_robox_nrp_utils/SOM/SOM_additional.py | UTF-8 | 5,522 | 2.5625 | 3 | [] | no_license | # class SOM_additional (SOM_solution)
import numpy as np
import pandas as pd
import pylab as pl
import matplotlib.pyplot as plt
import matplotlib as mpl
import time
from matplotlib import collections as mc
from matplotlib import patches
from IPython import display
from IPython import get_ipython
class SOM_additiona... | true |
13e046c392e5a925fafbcc17ade366cf937406cd | Python | sanderadam/my-first-blog | /rooster/rommel.py | UTF-8 | 471 | 2.609375 | 3 | [] | no_license | import datetime
from rooster.models import StdDienst
#stdDienst_list = list(StdDienst.objects.all().values('date'))
stdDienst_list = StdDienst.objects.all().values('beschrijving','date','chauffeur','begintijd','eindtijd')
year = 2017
month = 1
dates_list = []
for i in range(1,31):
for stdDienst in stdDienst_lis... | true |
73e9d03a63d79c72e83518a4672e5ff12665c03f | Python | caioverissimo/IA002-python-scripts | /lista1/01-lista1.py | UTF-8 | 1,089 | 4.5625 | 5 | [] | no_license | ### IAL002 - Primeira Lista
### 1. Escreva um programa que leia um número inteiro do teclado e diga se esse
### número é positivo ou negativo
### Program for verify if an integer entry value is negative or positive ###
print('\n');
print("### Program for verify if an integer entry value is negative or positive ###... | true |
126071853a1a0246830688868f0bd8dede9f9f0c | Python | cshweeti77/Backup | /fibo.py | UTF-8 | 219 | 4.09375 | 4 | [] | no_license | #!usr/bin/python3
#version 3
#program to demonstrate usage of function to print upto n fibonacci number
def fibo(n):
a, b = 1, 1
while(a < n):
print(a)
a, b =b, a+b
a = int(input("Enter a number::"))
fibo(a)
| true |
6b407844eb4681b89035cf519a15d1f8eaa454fc | Python | tseiiti/curso_em_video | /mundo_2/ex037.py | UTF-8 | 613 | 4.28125 | 4 | [
"MIT"
] | permissive | from os import system, name
system('cls' if name == 'nt' else 'clear')
dsc = ('''DESAFIO 037:
Escreva um programa que leia um número inteiro qualquer e peça
para o usuário escolher qual será a base de conversão:
- 1 para binário
- 2 para octal
- 3 para hexadecimal
''')
n = int(input('Digite um número: '))
print('1: b... | true |
4cc2a926425ab3a3bc45df8df3494aef301b9873 | Python | ycchhueannu/LeetCode | /python/0459_Repeated_Substring_Pattern.py | UTF-8 | 383 | 2.75 | 3 | [] | no_license | class Solution(object):
def repeatedSubstringPattern(self, s):
"""
:type s: str
:rtype: bool
"""
for n in range(1, len(s)//2 + 1):
if len(s) % n == 0:
sub_str = s[0:n]
if all(s[n*i:n*(i+1)] == sub_str for i in range(0, len(... | true |
d1e8a53283251f562d0ea3f84a2f002c05c641c9 | Python | oshlern/MiscellaneousWork | /pico/vigen.py | UTF-8 | 551 | 2.859375 | 3 | [] | no_license | import string
def d(c, k):
m = ''
for i in range(len(c)):
ki = string.ascii_lowercase.index(k[i % len(k)])
ci = string.ascii_lowercase.index(c[i])
m += string.ascii_lowercase[ci-ki % 26]
# m += chr((ord(c[i])-65)+(ord(k[i%len(k)])-65) % 26 + 65)
return m
m = "vgefmsaapaxpom... | true |
8a4d6843d48e18cc0026fc5a2d92c5abf8039a12 | Python | daniel-reich/ubiquitous-fiesta | /XKEDTh2NMtTLSyCc2_16.py | UTF-8 | 308 | 3.109375 | 3 | [] | no_license |
def valid_credit_card(number):
if len(str(number)) == 16:
y = [int(char) for char in str(number)[::-1]]
for i in range(16):
if i%2:
y[i] = y[i]*2
if y[i] > 9:
y[i] = y[i] - 9
if not sum(y)%10:
return True
else:
return False
else:
return True
| true |
2fe479d49c2d21de2fa4fee90f78a1595d50fdb4 | Python | lowbite/ComputerArchitecture | /Lections/1.py | UTF-8 | 447 | 3.453125 | 3 | [] | no_license | a = 5
def f(x,y = a):
return x*y
print (f(2))
a = 3
print (f(2))
#--------------------------------------------
def f1(a, l=[]):
l.append(a)
print(l)
return l
f1(1)
f1(1)
l = f(1) #Bude zsylatys na 1 komirky pamyati
#--------------------------------------------
def f3(a = None):
if a is None:
... | true |
d93574dca7aa8d113168c65b16566a8322ba33da | Python | wurmfood/highalt | /Testing/ThreadTest.py | UTF-8 | 1,286 | 3.453125 | 3 | [] | no_license | #!/usr/bin/env python3
import threading
from time import sleep
class TestThread (threading.Thread):
def __init__(self, h_array, line):
threading.Thread.__init__(self)
self.headers = h_array
self.line = None
def run(self):
for i in range(1, 15):
self.headers.append... | true |
d9c6c3ada541986691271729c9b7754b9b9e586c | Python | cforth/codefarm | /idea-365/D033_JSON2PY/GifHandle.py | UTF-8 | 2,696 | 3.09375 | 3 | [
"MIT"
] | permissive | from PIL import Image, ImageTk
# GIF动图处理类
class GifHandle(object):
def __init__(self, master_widget, img_path):
# 保存显示图片的控件引用
self.master_widget = master_widget
# 保存图片路径
self.img_path = img_path
# 保存gif格式图片当前显示的帧的数据
self._frame = None
# 保存gif格式图片... | true |
5e5d308b303667bf20831bbc61051cf0fc202436 | Python | jinook929/algoexpert | /_createBinaryTree.py | UTF-8 | 5,073 | 3.609375 | 4 | [] | no_license | # assumed id == value in nodes
def createBinaryTree(nodes, root):
tmp = []
for i in range(len(nodes)):
tmp.append(BinaryTree(nodes[i]["value"]))
def findNode(value):
return list(filter(lambda node: node.value == int(value), tmp))[0]
for i in reversed(range(len(tmp))):
... | true |
7208c8ae3e527967991fba30274941084daaaa63 | Python | justincohler/related_publications | /db.py | UTF-8 | 437 | 3.015625 | 3 | [] | no_license | import json
from sqlalchemy import create_engine
def db_connect():
"""Return a SQLAlchemy DB engine.
Returns:
sqlalchemy.Engine -- a DB engine
"""
with open('credentials.json') as file:
credentials = json.load(file)
DB_USER = credentials["DB_USER"]
DB_PASS = credentials["D... | true |
7d145c1107a11bc336fa6591166785ebdabf9fd3 | Python | yusufrahmatp/opengl | /task-2/script.py | UTF-8 | 383 | 2.703125 | 3 | [] | no_license | filename = 'kuda.txt'
filename_w = 'kuda_modified.txt'
fopen = open(filename, 'r')
fwrite = open(filename_w, 'w')
i = 0
for line in fopen :
if line != '\n':
x,y = line.split(',')
x = (int(x) - 400) / 800
y = ((int(y) - 400) / 800) * -1
fwrite.write('{},{},{}\n'.format(x, y, 0))
... | true |
f4872b538c401e82346508230123c4384a46375a | Python | kayodeomotoye/Code_Snippets | /color.py | UTF-8 | 3,113 | 3.140625 | 3 | [] | no_license | import os
import sys
from string import hexdigits, digits
from typing import Tuple
import urllib.request
# PREWORK (don't modify): import colors, save to temp file and import
tmp = os.getenv("TMP", "/tmp")
color_values_module = os.path.join(tmp, 'color_values.py')
urllib.request.urlretrieve(
'https://bites-data.s3... | true |
4588f4569847b10b11e90ae3e540836bbff96752 | Python | 1946472806/crawler | /day04/06selenium第三方登录知乎.py | UTF-8 | 818 | 2.671875 | 3 | [] | no_license | import time
from selenium import webdriver
#创建谷歌浏览器驱动,使用指定的驱动程序
driver = webdriver.Chrome(executable_path="/home/zhengyj/Downloads/chromedriver_linux64/chromedriver")
driver.get('https://www.zhihu.com')
#先点击登录
driver.find_element_by_xpath('//*[@class="SignContainer-switch"]/span').click()
time.sleep(1)
#第三方登录
#点击社... | true |
d1abc4d867724b81b346f0e20c65061de8dcfd2f | Python | asperaa/back_to_grind | /Trees/post_order_traversal_recursive.py | UTF-8 | 638 | 3.484375 | 3 | [] | no_license | """We are the captains of our ships, and we stay 'till the end. We see our stories through.
"""
"""145. Binary Tree Postorder Traversal [Recursive]
"""
class TreeNode:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
def post_order_traversal_helper(self,... | true |
cc4fa06516940c6390f30ce53bd3fa4184cd1fa4 | Python | Nathaanlennon/multi-fuction_program_with_python | /MainV2.py | UTF-8 | 1,827 | 3.890625 | 4 | [] | no_license | from Class import *
from math import *
def ai():
print("Hello user, I'm Chara, your personal IA. What's your name?")
name = input()
print(f"Hi {name}, I'm happy to meet you ^^")
print("I have a lot of abilities, try to say someone and if I know how do that, i'll try to help you")
print("What's you... | true |
1939f58c35f311ca619fc329b6a1d73f45ba3118 | Python | shockim3710/Programmers-Algorithm | /Level 1/42748_K번째수.py | UTF-8 | 385 | 3.015625 | 3 | [] | no_license | def solution(array, commands):
answer = []
for i in range(len(commands)):
cut = []
for j in range(commands[i][0] - 1, commands[i][1]):
cut.append(array[j]) # commands 범위까지 cut에 추가
cut.sort()
# cut에서 원하는 위치의 숫자를 answer에 추가
answer.append(cut[commands[i][2] -... | true |
5c4161204ef51274e189546d0c4d0849e0c42cdd | Python | mbg17/superlist | /day39/进程池2.py | UTF-8 | 510 | 2.84375 | 3 | [] | no_license | import os
import time
from multiprocessing import Pool
def func(n):
print('start func %s'% n,os.getpid())
time.sleep(1)
print('start func %s'% n,os.getpid())
if __name__ == '__main__':
pool = Pool(5)
# 同步提交进程
for i in range(10):
pool.apply(func,args = (1,))
# 异步提交进程
... | true |
4904b41ebf3e9596667ad9ced0fdda06386ae87c | Python | irfan-gh/MO-PaDGAN-Optimization | /airfoil/surrogate/train_surrogate.py | UTF-8 | 3,191 | 2.609375 | 3 | [
"MIT"
] | permissive |
"""
Trains a surrogate model
Author(s): Wei Chen (wchen459@gmail.com)
"""
import argparse
import numpy as np
import tensorflow as tf
from surrogate_model import Model, preprocess, postprocess
import sys
sys.path.append('../..')
from utils import ElapsedTimer
if __name__ == "__main__":
# Arguments
pa... | true |
de5d29b4451dc734115e8a3ff08493aa69d0e74d | Python | ChangdeDu/generativeSSL | /data/half_moon.py | UTF-8 | 2,114 | 2.9375 | 3 | [] | no_license | from sklearn.datasets import make_moons
import numpy as np
import pdb
def pad_targets(xy):
"""
Pad the targets to be 1hot.
:param xy: A tuple containing the x and y matrices.
:return: The 1hot coded dataset.
"""
x, y = xy
classes = np.max(y) + 1
tmp_data_y = np.zeros((x.shape[0], classe... | true |
64493331e3aee65465481cbbfcf89ec3bdc1c73f | Python | SimGob/PageRank | /MassDistribution.py | UTF-8 | 1,648 | 3.078125 | 3 | [] | no_license | from mrjob.job import MRJob
from mrjob.protocol import JSONProtocol
ALPHA = .15 # Googles number
class MassDistribution(MRJob):
'''
MRJob Class for distributing lost mass across non-dangling nodes.
Also add dampening with alpha=.15, run once node rankings have converged
'''
INPUT_PROTOCOL = JSONProtocol
... | true |
00eb290305db1568041223e05a1ddf1b49465126 | Python | mexiCoders/pyvcf | /src/vcf/hackparser.py | UTF-8 | 7,045 | 2.75 | 3 | [] | no_license | import re
import itertools
# token patterns
p_comma = r","
p_colon = r":"
p_semicolon = r";"
p_equals = r"="
p_slash = r"/"
p_bar = r"\|"
p_dot = r"\."
p_int = r"[-+]?(?:0|[1-9][0-9]*)"
p_float = r"[-+]?[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?"
p_str = r".*"
p_end = r'$'
p_identifier = r"[a-zA-Z][a-zA-Z0-9]*"
p_nucleotide... | true |
a70176edf7771ca00c388c8023e2d8d87986a8fb | Python | chenred/CB_Data_Visualization | /code/code_tags/4.0/dash/crawl_data.py | UTF-8 | 3,725 | 2.703125 | 3 | [] | no_license | import requests
import pandas as pd
import numpy as np
from lxml import etree
import os
import setting
import time
class Spiders():
def __init__(self):
# 使用默认地址为富投网行情全表
self.url = r"http://www.richvest.com/index.php?m=cb&a=cb_all"
self.headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.... | true |
e4d84ccf0c5899373e989ec40261597fd301e453 | Python | maxieds/GATechGTDMMBSoftwareBackup | /RNADB-construction/rna2ndary/Exceptions.py | UTF-8 | 881 | 2.8125 | 3 | [] | no_license | # Exceptions.py : Miscellaneous exceptions used throughout this code.
# Author: Maxie D. Schmidt (maxieds@gmail.com)
# Created: 2019.06.18
class DirectoryError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
##
class SequenceError(Exception... | true |
f177eea5a7fb6192597fc85a5c05dce95fefc947 | Python | vadim-lev/test_task_1 | /main.py | UTF-8 | 2,160 | 2.515625 | 3 | [] | no_license | import os
from datetime import datetime
import requests
import sqlite3
URL_list = 'https://www.investing.com/search/service/searchTopBar'
headers = {'X-Requested-With': 'XMLHttpRequest',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
'AppleWebKit/537.36 (KHTML, like Gec... | true |
76eabfae3f8d6aa4066d24c95209bd29870d5de4 | Python | Aasthaengg/IBMdataset | /Python_codes/p02414/s810363420.py | UTF-8 | 576 | 2.59375 | 3 | [] | no_license | n,m,l = map(int,input().split())
a = [[0 for i in range(m)] for j in range(n)]
b = [[0 for i in range(l)] for j in range(m)]
c = [[0 for i in range(l)] for j in range(n)]
for i in range(n):
mat_tmp = list(map(int,input().split()))
for j in range(m):
a[i][j] = mat_tmp[j]
for i in range(m):
mat_tmp... | true |
f5df9f4dae05a31f115212666118b175b7c60be3 | Python | ao-song/stock | /hs300.py | UTF-8 | 2,019 | 2.828125 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import tushare as ts
import pandas as pd
from pathlib import Path
import time
''' About HS300 '''
#------------------------------------------------------------------------------
__author__ = 'Ao Song'
__email__ = 'ao.song@outlook.com'
START_DATE = '2005-01-04'
F... | true |
191968384b2cf3568199fd2c22b9030b522d2be9 | Python | bonmorz/portScanPublic2 | /portScan.py | UTF-8 | 3,219 | 2.75 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import socket
import re
from scapy.all import *
import subprocess
import re
import xlrd
final_result={}
def read_usage():
wb = xlrd.open_workbook('tcpUsage.xlsx')
# 按工作簿定位工作表
sh = wb.sheet_by_name('Sheet1')
# print(sh.nrows) # 有效数据行数
# print(sh.ncols) # 有效数据列数
# pri... | true |
5d24d549572bffb02c07a05a47b5906007c729fe | Python | greyaurora/greykit | /npc_gen/tables/character/data/desc.py | UTF-8 | 1,332 | 2.609375 | 3 | [] | no_license | # <character> is [descriptor], [descriptor], [descriptor]
descriptors = [
'dangerous', 'manipulative', 'stoic', 'attractive', 'aloof',
'generous', 'armed', 'brave', 'sociable', 'connected',
'jealous', 'active', 'hostile', 'successful', 'experienced',
'ambitious', 'conceited', 'stern', 'wary', 'insi... | true |
1e09a23e34ca2d74f840aa098e8a6b6b34be6f81 | Python | lkqllx/Lim | /Project_2-Forum/download_prices.py | UTF-8 | 1,504 | 3.046875 | 3 | [] | no_license | """
This file will download the prices of target list
"""
import pandas_datareader as web
import pandas as pd
import concurrent.futures
import datetime as dt
from progress.bar import Bar
import threading
import os
lock = threading.RLock()
def prices(targets: list, start='2010-01-01', end='2019-10-15'):
start = ... | true |
e7a1b4813817252921ef502773355eb8f0855356 | Python | jgran/march_madness_2016 | /make_testing_dataset.py | UTF-8 | 5,347 | 3.0625 | 3 | [] | no_license | import pandas as pd
import numpy as np
import itertools as iter
def seed_str_to_num(seed):
return int(float(''.join(i for i in seed if i.isdigit())))
print '\n'
print 'making test dataset'
avg_df = pd.read_csv('season_avg.csv')
seeds_df = pd.read_csv('input/TourneySeeds.csv')
avg_df = avg_df.loc[(avg_df.Season ... | true |
57e9f99178459ae120a53110fc4d8f0858b8e752 | Python | Kamirus/artificial-intelligence | /p1/z5.py | UTF-8 | 3,649 | 2.78125 | 3 | [] | no_license | import random
from z4 import opt_dist
def init_matrix(rows, cols):
return [[random.randint(0, 1) for _ in range(len(cols))] for _ in range(len(rows))]
def get_column(i, matrix):
return [matrix[j][i] for j in range(len(matrix))]
def get_columns(matrix):
return [get_column(i, matrix) for i in range(len... | true |
ce8729a31b42ed5f64b35fe42f6f0127ea109155 | Python | saraiyakush/library-case-study | /Book.py | UTF-8 | 582 | 3.34375 | 3 | [] | no_license | import csv
class Book:
def __init__(self, bookid, name, author, year, genre, count):
self.bookid = bookid
self.name = name
self.author = author
self.year = year
self.genre = genre
self.count = count
def addBook(self):
fh = open('./bookdata.csv', 'a')... | true |
8862e1599c7a7c201b52e8e0438d60407a164fa3 | Python | pk4btc/seleniumScripts | /tests/test_nopCommercecom.py | UTF-8 | 204 | 2.65625 | 3 | [] | no_license | import pytest
class TestClass():
def test_func(self):
x=2
return x+1
def test_two(self):
x="ania"
assert 'i' in x
def test_answer(self):
assert 2==2 | true |
6fb573e3236d0f93316e929ba86beceb6e74325f | Python | apdofficial/AI_hackathon_2019 | /project/download.py | UTF-8 | 724 | 2.96875 | 3 | [] | no_license | import bs4
import requests
from typing import AnyStr
class Download:
"""
Use:
download = Download()
download.download("https://physionet.org/physiobank/database/bidmc/bidmc_csv/")
to download all the data into the <data> folder
"""
@staticmethod
def download(url: AnyStr):
page =... | true |
a171fd9e0d0355e45bb7461ae626efd26b31b09a | Python | eric8607242/DrBC_pytorch | /utils/model.py | UTF-8 | 3,043 | 2.71875 | 3 | [] | no_license | import numpy as np
import torch
import torch.nn as nn
from torch_geometric.nn import MessagePassing
from torch_geometric.utils import add_self_loops, degree
class GCNConv(MessagePassing):
def __init__(self, in_channels, out_channels):
super(GCNConv, self).__init__(aggr="add")
def forward(self, x, edg... | true |
ff252cdc45adc99ba9f16d606e94649f0920bf74 | Python | kangju1/Catalog | /categories.py | UTF-8 | 1,267 | 2.703125 | 3 | [] | no_license | from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from database_setup import User, Base, Category
engine = create_engine('sqlite:///catalog.db')
# Bind the engine to the metadata of the Base class so that the
# declaratives can be accessed through a DBSession instance
Base.metadata.bind = e... | true |
bceb1870f55e78603e4395c449500f02d16d2a39 | Python | NoahPeeters/Alchemy | /client/client.py | UTF-8 | 6,596 | 2.578125 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding: utf-8 -*-
import os, sys
import os.path
import time
import readline
import socket
import getpass
def clear():
pass
os.system("clear")
languages = ["en", "de"]
l = []
start = 35
def load_language_file(name):
global l
l = []
for line in open(name):
l.append(l... | true |
0ed28d157fff4f0b10e57a73ab29d39011a9973c | Python | anihamde/rl-monkey-game | /run.py | UTF-8 | 2,833 | 3.015625 | 3 | [] | no_license | import numpy as np
class ReinforcementLearning(object):
def __init__(self, num_actions, state_dimensions, learning_rate, discount_factor):
self.num_actions = num_actions
self.state_dimensions = state_dimensions
self.learning_rate = learning_rate
self.discount_factor = discount_factor
self.W = np.zeros((se... | true |
efe2ebffa6aa4a63fd2d9fd6230a840ea94450c4 | Python | TIian610/DataAnalysis | /chapter03/pltcolor.py | UTF-8 | 837 | 2.984375 | 3 | [] | no_license | #coding:utf-8
"""
filename:pltcolor.py
display the color of plt
"""
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import matplotlib.cm as cmx
import numpy as np
curves = [np.random.random(20) for i in range(10)]
values = range(10)
fig = plt.figure()
ax = fig.add_subplot(111)
jet = cm = plt.get_c... | true |
380260a84bb8ae944a879a29c0591a8913e63c4e | Python | mianasbat/scikit-surgeryfred | /sksurgeryfred/widgets/interactive_registration.py | UTF-8 | 2,892 | 2.71875 | 3 | [
"BSD-3-Clause"
] | permissive | """
The main widget for the interactive registration part of scikit-surgeryFRED
"""
import matplotlib.pyplot as plt
import skimage.io
import numpy as np
from sksurgeryfred.algorithms.fred import make_target_point, \
PlotRegistrations, \
PointBasedRegistration, AddFiducialMarker
from sk... | true |
8b5b3220101c2fca62094cad6fc82ff5ba0f4780 | Python | Galieve/TFG-Informatica | /src/endogamy/generate_csv.py | UTF-8 | 1,884 | 2.640625 | 3 | [] | no_license | import os
import sys
import pandas as pd
def generate_database():
file_id = 16
file_path = get_path_file('data_in_csv.csv')
dfvalid = pd.read_csv(file_path, sep=';')
for file_id in range(0, 20):
# try:
# df = pd.read_csv('prod8/data_in_csv' + str(file_id) + '.csv', sep=';')
... | true |
8b0f1fd1a19aaac06c99cb957f9da0d7023f235a | Python | seanlahman/patent_scraper | /lahmanlib.py | UTF-8 | 3,295 | 3.09375 | 3 | [] | no_license | #lahmanlib
# Collection of modules written by Sean Lahman - seanlahman@gmail.com
# Created 2013-10-27
def HelloWorld():
print 'hello world'
def PatentScrape(p_id):
# ----------------------------------------------------------------------------
# Given the number of a US patent, s... | true |
876924098e4c50f6c8d64deb9f83b7a58b216c36 | Python | eastonYi/Unsupervised-ASR | /utils/tools_model.py | UTF-8 | 2,748 | 2.6875 | 3 | [] | no_license | import tensorflow as tf
def get_LSTM_UWb(weight):
'''
weight must be output of LSTM's layer.get_weights()
W: weights for input
U: weights for hidden states
b: bias
'''
warr, uarr, barr = weight
gates = ["i","f","c","o"]
hunit = uarr.shape[0]
U, W, b = {},{},{}
for i1,i2 in ... | true |
480c8745e82cb699c11dd2b56e505cdfcc4dd528 | Python | wohnjoods/Sentiment-Model-Flask-App | /tempCodeRunnerFile.py | UTF-8 | 376 | 3.1875 | 3 | [] | no_license | inputText = inputText.split()
text_sequence = []
for word in text:
if word not in vocabulary:
vocabulary[word] = len(inverse_vocabulary)
text_sequence.append(len(inverse_vocabulary))
inverse_vocabulary.append(word)
else:
text_sequence.appen... | true |
4cc32f1893c4cf9fec0ea9c32bc3f4cb955f4e1b | Python | opbeat/opbeatcli | /opbeatcli/client.py | UTF-8 | 4,139 | 2.53125 | 3 | [
"BSD-2-Clause"
] | permissive | """
Opbeat log API client.
"""
import json
import logging
from opbeatcli import __version__
from opbeatcli.log import logger
from opbeatcli import settings
from opbeatcli.exceptions import ClientConnectionError, ClientHTTPError
from opbeatcli.compat import (Request, urlopen, URLError,
HT... | true |
0684f56d14e2c5ea76453a6735277552bcc19b10 | Python | abramik/cs102 | /homework03/life-console.py | UTF-8 | 1,157 | 3.03125 | 3 | [] | no_license | import curses
from life import GameOfLife
from ui import UI
import os
class Console(UI):
def __init__(self, life: GameOfLife) -> None:
super().__init__(life)
def draw_borders(self, screen) -> None:
screen.border('|', '|', '-', '-', '+', '+', '+', '+')
def draw_grid(self, screen) -> No... | true |
5edc3a64a44dcb9f3c5f73c4ca8a9b3716f1ec3f | Python | nyborr/OpenKattisProblems | /A Towering Problem.py | UTF-8 | 593 | 3.0625 | 3 | [] | no_license | import itertools
arr = input()
L = [int(x) for x in arr.split()]
height1 = L[-2]
height2 = L[-1]
s = []
x =[]
for i in range (0,4):
for j in range (i+1,5):
for k in range (j+1,6):
if ((L[i] + L[j] + L[k]) == height1):
s.append(L[i])
s.append(L[j])
... | true |
9f0ebbb14086d8a2806c40499bc0e6f881d34ffa | Python | atjason/Python | /practice/py_ex2.py | UTF-8 | 760 | 4.5 | 4 | [] | no_license | # -*- coding: utf8 -*-
"""
斐波那契数列(Fibonacci sequence),又称黄金分割数列。
如:1、1、2、3、5、8
"""
def fibonacci(num):
result = [1, 1]
if num <= 2:
return result[:num]
a, b = 1, 1
for i in range(3, num + 1):
a, b = b, a + b
result.append(b)
return result
print fibonacci(0)
print fibonacci(1)
print fibonacci(2)... | true |
4bd05f7da031a2d0848afcc301e42f73b48037ed | Python | n8henrie/exercism-exercises | /python/matrix/matrix.py | UTF-8 | 469 | 3.421875 | 3 | [
"MIT"
] | permissive | import typing as t
class Matrix:
def __init__(self, matrix_string):
self._as_rows: t.List[t.List[int]] = [
[int(col) for col in row.split()]
for row in matrix_string.splitlines()
]
def row(self, index):
zero_based_index = index - 1
return self._as_rows[... | true |
59b103c6858fc097fcb259f0e2ec507b1934a018 | Python | jokersunited/UrlAnalyze | /RESTAPI/urlclass.py | UTF-8 | 20,834 | 2.5625 | 3 | [] | no_license | import ssl, OpenSSL
import re
import whois, tldextract
import socket
import json
import pandas as pd
from selenium import webdriver
from selenium.common.exceptions import WebDriverException
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.utils import ChromeType
from bs4 import Beautiful... | true |
d55ddf43db7970d6f19112662d28f636ea6889a7 | Python | shad7/seedbox | /seedbox/db/sqlalchemy/migrate_repo/versions/004_alter_total_time_column_on_MediaFile.py | UTF-8 | 600 | 2.859375 | 3 | [
"MIT"
] | permissive | """Handles converting MediaFile.total_time from Integer to Float"""
import sqlalchemy as sa
def upgrade(migrate_engine):
meta = sa.MetaData(bind=migrate_engine)
table = sa.Table('media_files', meta, autoload=True)
col_resource = getattr(table.c, 'total_time')
# converts Integer to Float
col_resour... | true |
efb3ca120b99d0907592c208b816a078c94d670b | Python | kriegaex/projects | /Python/projectEuler/CombinatoricSelections.py | UTF-8 | 916 | 3.609375 | 4 | [] | no_license | import time
def is_even(num):
if num % 2 == 0:
return True
else: return False
def factorial(num):
if num == 0:
return 1
else:
return factorial(num - 1) * num
def formula(num1, num2):
combination = factorial(num1) / (factorial(num2) * factorial(num1 - num2))
return comb... | true |
9f5edc10aca42dfa995916c210e2a92f24ba9c74 | Python | samedayshipping/python3-amazon-mws | /mws/parsers/errors.py | UTF-8 | 2,404 | 2.53125 | 3 | [
"Unlicense"
] | permissive | import re
from .base import first_element, BaseResponseMixin, BaseElementWrapper
from lxml import etree
class ErrorResponse(ValueError, BaseElementWrapper, BaseResponseMixin):
def __init__(self, element, mws_access_key=None, mws_secret_key=None, mws_account_id=None, mws_auth_token=None):
BaseElementWrapp... | true |
d4eb70a662cf6d186f3fd4bfeb7a3b7fd6ebc686 | Python | hojjat-faryabi/python_binary_genetic_algorithm | /crossover.py | UTF-8 | 802 | 2.546875 | 3 | [] | no_license | from init import init
import numpy as np
import random
def crossover(initValues : init, matingPool : list):
parentNum = np.random.permutation(initValues.n)
newPopulation = np.zeros((initValues.n, initValues.l) , dtype=int)
for j in range(0, initValues.n, 2):
pointer1 = parentNum[j]
pointer2... | true |