blob_id large_string | repo_name large_string | path large_string | src_encoding large_string | length_bytes int64 | score float64 | int_score int64 | detected_licenses large list | license_type large_string | text string | download_success bool |
|---|---|---|---|---|---|---|---|---|---|---|
dcd12b849a869516b1d62e635e30ce9b47be496a | oxygen-dioxide/vogen | /vogen/synth/__init__.py | UTF-8 | 5,758 | 2.671875 | 3 | [
"MIT"
] | permissive | """PyVogen合成引擎"""
#基于Vogen 7月28日代码
import tqdm
import vogen
import numpy
import pyworld
from typing import List,Optional
from vogen.synth import f0
from vogen.synth import utils
from vogen.synth import prosody
from vogen.synth import acoustics
from vogen.synth import timetable
params=utils.Params()
d... | true |
2e4888041b0f482a4dd675cfaa3cb42d7368993f | CaptFrank/airport_network_monitor | /src/Airport_Monitor/Airport_Monitor.py | UTF-8 | 7,621 | 2.671875 | 3 | [] | no_license | #!/usr/bin/python
#Author: Niket Shah
"""
Top Level SNMP wrapper to fetch various items of data from an Apple Airport
Express/Extreme or a Time Capsule.
To use this wrapper: place this python script (along with all other plugins) to
/etc/munin/plugins folder.
This will create a virtual host in munin for the airport ... | true |
cdde77e9f63b384226b960daab78d6a14a6940ce | Luc-del/TrackmaniaDiscord | /pkg/models/player.py | UTF-8 | 702 | 2.734375 | 3 | [] | no_license | import pkg.models.time as time
from utils.json import marshal_json_dict
class Player:
def __init__(self):
self.pbs = {}
def register_time(self, map_idx, t):
current_pb = self.get_pb(map_idx)
if current_pb is None or t < current_pb:
self.pbs[map_idx] = t
return ... | true |
a3e33732b401a5d6241fca8dbc0e9fd4f990399a | GalymzhanTutkushev/MathAnimations-using-manim | /6_probability.py | UTF-8 | 9,052 | 2.890625 | 3 | [] | no_license | from manimlib import *
class prob(Scene):
def construct(self):
pa = Tex("P(A)=\\frac{m}{n}")
pa.to_edge(UP)
self.play(Write(pa))
class geo_prob(Scene):
def construct(self):
Arcs = []
Lines = []
for a in range(3):
r = (a+0.4)/2
... | true |
ba16f89bca1ba7d568e9fac68f4d4ac53aee8bc2 | sharikgrg/week4.Gazorpazorp | /gazorpazorp_run.py | UTF-8 | 2,386 | 3.125 | 3 | [] | no_license | # import all classes here
from passenger_class import *
from spaceship_class import *
from expedition_class import *
# create objects here
# generate 6 passengers
passenger1 = Passenger('Vish', 'Which', '007')
passenger2 = Passenger('Mous', 'martian', '684')
passenger3 = Passenger('David', 'Which', '666')
passenger4 =... | true |
81ba5df370defb38d1f2528784c3f282f1d38207 | MengSunS/daily-leetcode | /227.py | UTF-8 | 1,293 | 2.890625 | 3 | [] | no_license | class Solution:
def calculate(self, s: str) -> int:
num, stack, sign= 0, [], 1
operator= '+'
for i in range(len(s)):
c= s[i]
if c.isdigit():
num= num*10+ int(c)
if i==len(s)-1 or c in {'+', '-', '*', '/'}:
i... | true |
f45be6d518332005ed3f9694fea86cbe2f932c2c | ver0nika4ka/PythonCrashCourse | /5.10_Checking_Usernames.py | UTF-8 | 538 | 3.390625 | 3 | [] | no_license | current_users = ['Veronica','Nastya','Victor','Alex','admin']
new_users = ['veronica','nastya','bectur','sema','alla']
current_users_lower = []
for user in current_users:
current_users_lower.append(user.lower())
# The same but using comprehension
# current_users_lower = [user.lower() for user in current_users]
fo... | true |
b57e51730a7b0be72d209536564a312a6f096661 | OhmG-999/Python-week3 | /exercise9.py | UTF-8 | 815 | 5.03125 | 5 | [] | no_license | # Write a function which finds all the words beginning with “s” in a list
# and prints them out. It also should say how many words it has found beginning with “s”.
mylist = ['fork','switch', 'battery', 'spoon', 'plate', 'sponge', 'glass']
# the function takes the list as an argument
def startingLetter(list):
# counte... | true |
c3fda5f50483e6ddd00b45b3ea8bf5f20aa34600 | ing-bank/sparse_dot_topn | /sparse_dot_topn/awesome_cossim_topn.py | UTF-8 | 4,870 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | import sys
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse import isspmatrix_csr
if sys.version_info[0] >= 3:
from sparse_dot_topn import sparse_dot_topn as ct
from sparse_dot_topn import sparse_dot_topn_threaded as ct_thread
else:
import sparse_dot_topn as ct
import sparse_dot... | true |
07b9e30a0a0c93e33a58fdce09d7a84cda39e980 | AtulCoder01/Programming-Notes | /Python/mapVSlist.py | UTF-8 | 97 | 3 | 3 | [] | no_license | l=[1,2,3,4,5]
def sqr(x):
return x*x
print ([sqr(x) for x in l])
#or
print (list(map(sqr, l)))
| true |
82af65825061740a4ed0865b0268cd3eddb438c0 | Lucaskabela/UNAST | /src/prepare_data.py | UTF-8 | 1,357 | 2.578125 | 3 | [
"MIT"
] | permissive | import numpy as np
import pandas as pd
from torch.utils.data import Dataset, DataLoader
import os
from utils import get_spectrograms
import audio_parameters as ap
import librosa
from data import data_path
class PrepareDataset(Dataset):
"""LJSpeech dataset."""
def __init__(self, csv_file, root_dir):
""... | true |
ff35933092f2e0bbe9dcc20f9b3aa49df75f7c39 | vtalks/vtalks.net | /web/talks/utils.py | UTF-8 | 609 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | import re
from datetime import timedelta
def parse_duration(duration_string):
hours = 0
minutes = 0
seconds = 0
duration = duration_string
try:
hours = re.compile('(\d+)H').search(duration).group(1)
except AttributeError:
hours = 0
try:
minutes = re.compile('(\d+)M... | true |
c0a716070b8c1344731a0286347bd54999e6d44d | sjyk/dc4ds-core | /dc4ds/dataset.py | UTF-8 | 5,765 | 3 | 3 | [
"MIT"
] | permissive | """
This module defines the main data structure in the dc4ds package.
A dataset is a wrapper class for a Pandas Data Frame that also
contains logical assertions about data quality.
"""
import pandas
import numpy as np
import warnings
from dc4ds.loaders.TypeInference import TypeInference
from dc4ds.utils.feature_utils ... | true |
40617252c9b6866afbf3958da25fcc3afa32aef4 | Smoss/historia | /historia/pops/logic/farmer.py | UTF-8 | 791 | 2.59375 | 3 | [] | no_license | from historia.pops.logic.logic_base import LogicBase
from historia.economy.enums.resource import Good
class FarmerLogic(LogicBase):
def perform(self):
bread = self.get_good(Good.bread)
timber = self.get_good(Good.timber)
tools = self.get_good(Good.tools)
if timber is None or bread... | true |
e34c53b70fdba88974ceb2d87f38da64ff5b5598 | abhaysinh/Data-Camp | /Data Scientist with Python Track Github/29-Cluster Analysis in Python/01- Introduction to Clustering/06-Visualize normalized data.py | UTF-8 | 589 | 3.578125 | 4 | [] | no_license | '''
Visualize normalized data
After normalizing your data, you can compare the scaled data to the original data to see the difference.
The variables from the last exercise, goals_for and scaled_data are already available to you.
Instructions
100 XP
1 Use the matplotlib library to plot the original and scaled ... | true |
4bafa8ba3ce725a57f8b18877a22a8dc93c25875 | prat96/Tensorflow_sandbox | /squares/square.py | UTF-8 | 1,893 | 2.734375 | 3 | [] | no_license | from __future__ import absolute_import, division, print_function, unicode_literals
import tensorflow as tf
import matplotlib.pyplot as plt
import time, os
import numpy as np
tf.logging.set_verbosity(tf.logging.ERROR)
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '1'
input_num = np.linspace(-100, 100, 50000)
np.append(np.linsp... | true |
e25ea776de540fc7b5807b6539d56505e159e5ea | ThibaultSchowing/Bioinformatics3 | /Assignments/Assignment8/BI3_assignment_8_supplement/correlation.py | UTF-8 | 2,673 | 3.84375 | 4 | [] | no_license | from itertools import combinations
def rank(x):
"""
:param x: a list of values
:return: ranking of the input list
"""
# TODO
def pearson_correlation(x, y):
"""
:param x: a list of values
:param y: a list of values
:return: Pearson correlation coefficient of X and Y
"""
# ... | true |
c6ff9439eb18f7191fe09364e2a8e36f2e6119d2 | rmathur101/flask-template | /app/example.py | UTF-8 | 102 | 3.078125 | 3 | [] | no_license | def double (x):
return 2 * x
def triple (x):
return 3 * x
def square (x):
return x * x
| true |
33593adb7a2e7cb0bea8bdfe67131baa38293544 | altairlage/curso_python_devops | /Scripts/Arquivos-Python-com-Banco-de-Dados/6 - Python com Banco de Dados/INSERT_MY.py | UTF-8 | 771 | 3.0625 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
# INSERT_MY.py
"""
Nesse arquivo, vamos fazer um teste de
conexão ao banco de dados
do MySQL.
"""
try:
import MySQLdb
except:
sys.exitfunc("[!] Por favor, intale a biblioteca mysqldb com o comando: sudo apt-get install python-mysqldb")
try:
con = MySQLdb.con... | true |
e2395586fb51ac5ca93dfe6359fcf6ef238553e6 | joseleite19/competitive-programming | /codeforces/101243/B.py | UTF-8 | 172 | 3.171875 | 3 | [] | no_license | inp = file("input.txt", "r")
q = file("output.txt", "w")
n = int(inp.read())
ans = 2**(2*n/3 - 1) + 2**(n/3 - 1) -1
if n % 2:
ans += 2**(n/3 - 1) - 1;
q.write(str(ans))
| true |
ef2adcd35cf3050024eaad85e20cfa17d87d6132 | juancebarberis/algo1 | /practica/6-1.py | UTF-8 | 1,072 | 4.71875 | 5 | [] | no_license | #Ejercicio 6.1. Escribir funciones que dada una cadena de caracteres:
#a) Imprima los dos primeros caracteres.
#b) Imprima los tres últimos caracteres.
#c) Imprima dicha cadena cada dos caracteres. Ej.: 'recta' debería imprimir 'rca'
#d) Dicha cadena en sentido inverso. Ej.: 'hola mundo!' debe imprimir '!odnum aloh'
#e... | true |
d280b1acd16e5d1642e9e1f120a76cc443d7bedb | damiansp/completePython | /concurrency/mastering/03_working_with_threads/example.py | UTF-8 | 838 | 3.640625 | 4 | [] | no_license | import threading
import time
thread_lock = threading.Lock()
def main():
thr1 = MyThread('A', 0.5)
thr2 = MyThread('B', 0.6)
thr1.start()
thr2.start()
thr1.join()
thr2.join()
print('Finished.')
class MyThread(threading.Thread):
def __init__(self, name, delay):
... | true |
113d722cbe4856070b6ee8f999e13190d748b735 | Zaphrog/Encryption---Decryption-Tools | /src/XOR.py | UTF-8 | 466 | 3.328125 | 3 | [] | no_license |
def encrypt(message, key):
message_int = 0
for i in message:
message_int = message_int << 8
message_int += ord(i)
new_message = message_int ^ key
return new_message
def decrypt(message, key):
dec = message ^ key
old_message = []
while dec > 0:
letter = ... | true |
779dd4c9da4796674ea87f56764c1277d7687565 | salina-k/AWS_Face_Detection | /face-analysis/facial_analysis.py | UTF-8 | 1,389 | 2.703125 | 3 | [] | no_license | import boto3
import json
import os
client = boto3.client('rekognition', aws_session_token=os.getenv('aws_session_token'),
aws_access_key_id=os.getenv('aws_access_key_id'),
aws_secret_access_key=os.getenv('aws_secret_access_key'))
# client = boto3.client('rekognition')
file... | true |
c35c1fee897147e51b25909eb1ce325981da20b0 | KingOfPlagues/ViralBot | /discordbot/utils/db.py | UTF-8 | 556 | 2.890625 | 3 | [
"MIT"
] | permissive | """
Database utilities.
"""
from asyncqlio import DatabaseInterface
async def connect(user, password, db, host='localhost', port=5432) -> DatabaseInterface:
"""
Connects to a database.
:param user: Username for database.
:param password: Password for database.
:param db: Database name.
:param... | true |
0b0c1950e78ee6cd1e0a9031faa5a6b0a365c683 | wolfram74/march_makerness | /01/02_01.py | UTF-8 | 1,818 | 2.53125 | 3 | [] | no_license | import solid
import urllib, re, os, datetime, sys, lxml
import math
def make_output():
top_dir = sys.path[0]
date = date_to_string(datetime.date.today())
return open(os.path.join(top_dir,date)+".scad","w")
def date_to_string(date):
year = date.year
month = date.month
day = date.day
return "%r_%r_%r" % (year,... | true |
ed3032e7837a5f703f07566d3398f467e8c0fade | RavinderSinghPB/data-structure-and-algorithm | /graph/Snake and Ladder Problem.py | UTF-8 | 1,213 | 3 | 3 | [] | no_license | from collections import deque
def adj(cn, snkLdr):
an = []
for i in range(cn + 1, cn + 7):
if i > 30:
return an
if i in snkLdr:
an.append(snkLdr[i])
else:
an.append(i)
return an
def bfs(snkLdr):
vstd = set()
vstd.add(1)
throw = 0
... | true |
8906c76837dacc529f70930e7dcbc549c62a63c7 | menfeng/studynote | /third_party_library/scrapy/23-Spider-Middleware.py | ISO-8859-4 | 2,974 | 2.515625 | 3 | [] | no_license | 1.Spider Middleware
SPIDER_MIDDLEWARES = {
'myproject.middlewares.CustomSpiderMiddleware': 543,
}
1.SPIDER_MIDDLEWARES is merged with the SPIDER_MIDDLEWARES_BASE
2.sort
3.engine--first---second---...---spider
2.class scrapy.spidermiddlewares.SpiderMiddleware
process_spider_input(response, spider)
this meth... | true |
737758d59301d0f1c6932c2f79c4719fa5960505 | zhongshuiyuan/Pinyin2HanziPy | /prep/hanzi2pinyin.py | UTF-8 | 1,303 | 2.5625 | 3 | [] | no_license | #coding=utf-8
from ChineseTone import PinyinHelper
import sys
sys.path = ['../../pinyin2hanzi_01'] + sys.path # 将pinyin2hanzi_01导入检索路径
import util
def topinyin(s):
"""
s都是汉字
"""
s = util.as_text(s)
py_list = PinyinHelper.convertToPinyinFromSentence(s)
result = []
for py in py... | true |
90560fc80743048072b79aba4be001a7875b9947 | Rediet8abere/Herd-Immunity-Simulation | /simulation.py | UTF-8 | 8,663 | 3.171875 | 3 | [] | no_license | import random, sys
random.seed(42)
from person import Person
from logger import Logger
from virus import Virus
class Simulation(object):
''' Main class that will run the herd immunity simulation program.
Expects initialization parameters passed as command line arguments when file is run.
Simulates the s... | true |
1b26c6edee0e724641b79665e304c6457373405e | whuper/pythonScript | /netmusic/BeautifulSoup_pres/liberia.py | UTF-8 | 1,352 | 2.671875 | 3 | [] | no_license | # Liberia election results
import sys
sys.path.append('/usr/lib/python2.7/dist-packages/')
from bs4 import BeautifulSoup
import urllib2
import csv
import os
import re
os.chdir("/home/andrew/Dropbox/python/presentation/")
######## Pres/VP #####################
f= csv.writer(open("presidential_res.csv", "w"))
f.w... | true |
8783a694ca75546aba6fe084d18155b6f9ec5d75 | Aasthaengg/IBMdataset | /Python_codes/p03238/s162521815.py | UTF-8 | 134 | 3.65625 | 4 | [] | no_license | age = int(input().rstrip())
if age == 1:
print('Hello World')
elif age == 2:
print(int(input().rstrip()) + int(input().rstrip())) | true |
d5d1748e729bf749d09109cd7d4e3836cd9f325f | Shyanue/CodingTest | /CodeUp_Python_Basic_100/6011.py | UTF-8 | 52 | 2.8125 | 3 | [] | no_license | import sys
x = float(sys.stdin.readline())
print(x) | true |
32f3825aaa61b554709071ff172ece044a1e408d | ParshutinRoman/Class | /Class.py | UTF-8 | 2,958 | 4.03125 | 4 | [] | no_license | meat = 0
class Animals():
"""Class to create an animal"""
def __init__(self, name, weight, ration, voice):
"""initiate new animal"""
self.name = name
self.weight = weight
self.ration = ration
self.voice = voice
def show_animal(self):
"""Prints ... | true |
a1426e88e41e53fae8e508c32f5336290710c297 | cash2one/xai | /xai/brain/wordbase/nouns/_gutter.py | UTF-8 | 457 | 2.546875 | 3 | [
"MIT"
] | permissive |
#calss header
class _GUTTER():
def __init__(self,):
self.name = "GUTTER"
self.definitions = [u'the edge of a road where rain flows away', u'an open pipe, usually at the lower edge of a roof, that collects and carries away rain', u'the lowest level, especially of society: ']
self.parents = []
self.childen =... | true |
231aed31228055da7770da1c5a9cd6f66669e326 | lonewarrior556/Project_Euler | /euler18.py | UTF-8 | 393 | 2.875 | 3 | [] | no_license | f=open('triangle.txt')
ls=[]
a=f.readline()
while a!='':
a=a[:-1]
a=a.split()
for i in range(len(a)):
a[i]=int(a[i])
ls.append(a)
a=f.readline()
def addlastrow(ls):
a=ls[len(ls)-1]
for i in range(len(a)-1):
if a[i]>a[i+1]:
ls[len(ls)-2][i]=ls[len(ls)-2][i]+... | true |
3e6065a5f7e0e30f01fda25be7a7968368f8584f | Saharco/PaDP-2018 | /HW2/my_queue.py | UTF-8 | 677 | 3.640625 | 4 | [] | no_license | from multiprocessing import Lock, Pipe
class MyQueue(object):
def __init__(self):
''' Initialize MyQueue and it's members.
'''
self.lock = Lock()
self.pusher, self.reader = Pipe()
def put(self, msg):
'''Put the given message in queue.
Parameters
-----... | true |
31f1659b1c08db671351e4c2f41660ce4502b885 | vzkrish/Python | /Material/Day-4/ftp.py | UTF-8 | 980 | 2.859375 | 3 | [] | no_license | import ftplib,sys
x=ftplib.FTP('ftp.sunet.se','anonymous', 'anonymous@sunet.se')
print 'connection established'
# display the directory of the remote machine
data=[]
x.dir(data.append)
print 'directory listing of the remote machine'
for m in data:
print m
print
# retrieve a textfile from the remote machine to th... | true |
707bfe341719aa1e19d872960bcb63e1bf78a51c | mugenoesis/fp-bd-dlp-aws | /add_key.py | UTF-8 | 746 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='add_key')
parser.add_argument('--key', action="store", dest='key', )
args = parser.parse_args()
if args.key == 'None' or not args.key:
args.key = None
if args.key:
f = open("constant.py", "w")
... | true |
0ef576d8e4185dcc212a03e8fc1a225028fa2476 | nagarajuiitm/PythonCorseJohn | /MyTripToWalmartAndSets.py | UTF-8 | 293 | 2.90625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu Nov 28 15:12:25 2019
@author: SNR
"""
groceries = {'milk', 'cereal', 'starcrunch', 'beer', 'duct tape', 'lotion', 'beer'}
print(groceries)
if 'milk' in groceries:
print("you already have a milk hoss")
else:
print("oh yeah you need milk!") | true |
cbc5ebe9647fcc0825eeb9dd15fba4ef30e18527 | whshih/Data-Mining-at-USC-Assignment-02 | /task2.py | UTF-8 | 6,956 | 2.71875 | 3 | [] | no_license | from pyspark import SparkContext
import itertools
import time
import sys
# Provide (SON) each mapper with a single keyvalue pair
def single_kv(line, case):
# Let elements of data be single item
line = line.strip() # strings
entries = line.split(',') # list
k = entries[0]
v = e... | true |
4d70c32459e006d38950094f9410becf22287f99 | fhill2/dotfiles | /config/bin/f_normalise_filename.py | UTF-8 | 1,553 | 3.234375 | 3 | [] | no_license | #!/usr/bin/env python
import sys, os
from f.string import normalise_filepath
SHOULD_RENAME= True if len(sys.argv) > 1 and "rename" in sys.argv[1] else False
def stdin_normalise(lines):
if SHOULD_RENAME:
user_input = input(f'WARNING: you are about to rename {len(lines)} files. proceed Y/n? ')
if no... | true |
363b874b8c36dcb336036bab142f76b4f333eafc | vrukhin/grokking | /Chapter 06/06_01_breadth_first_search.py | UTF-8 | 1,373 | 3.625 | 4 | [] | no_license | #!/usr/bin/python
# функция проверки человека
def person_is_seller(person):
return person[-1] == 'm' # для примера будем считать продавцом манго человека, чье имя заканчивается на m
# создание графа
graph = {}
graph["you"] = ["alice", "bob", "claire"]
graph["bob"] = ["anuj", "peggy"]
graph["alice"] = ["peggy"]
... | true |
65d354ca8da388040ea03174f50b90e4b4af9d31 | RobertoPrevato/rocore | /tests/test_datetime_utils.py | UTF-8 | 1,394 | 2.71875 | 3 | [
"MIT"
] | permissive | import pytest
from pytest import raises
from datetime import datetime, date, time
from rocore.exceptions import EmptyArgumentException
from rocore.typesutils import dateutils
def test_parse_with_rx_raises_for_empty_value():
with raises(EmptyArgumentException):
dateutils.parse_time('')
@pytest.mark.param... | true |
f70918808c07b53d5fc30e80263271df5befc326 | maweki/ti-tutorium16 | /2/klammersprache.py | UTF-8 | 612 | 2.703125 | 3 | [] | no_license | from cfg import T, NT, CFG
S = NT()
a = T('a')
b = T('b')
g = CFG(S, [(S, (a,S,b)), (S, (a,b))])
print(g)
g_ = g.chomsky_normal_form()
print(g_)
print(g_.accepts('abaabab', True))
print(g_.accepts('aaabbb', True))
S = NT()
a = T('a')
b = T('b')
gr = CFG(S, [(S, (b,S,a)), (S, (b,a))])
gc = g | gr
gc_ = gc.chomsky_no... | true |
d1808a8664f3d403803b103a55bd04fd2fe6d747 | undercode99/doctor-app-flask | /app/http/api/v1/validations/patient.py | UTF-8 | 1,524 | 2.515625 | 3 | [] | no_license | from cerberus import Validator
from datetime import datetime
to_date = lambda s: datetime.strptime(s, "%Y-%m-%d")
to_time_hours = lambda s: datetime.strptime(s, "%H:%M")
def create_patient_validate(document):
schema = {
"name" : {"required": True, "type": "string", "maxlength": 200, "minlength": 4},
... | true |
81f41e2aabe9c8a17e3e693907bbd7f82a416873 | five510/atcoder | /20190309/main_c.py | UTF-8 | 340 | 3.015625 | 3 | [] | no_license | import math
N,M = map(int,input().split(' '))
ABn =[ list(map(int,input().split(' '))) for _ in range(N)]
ABn.sort(key=lambda x:(x[0]))
amount_yen = 0
for i in range(N):
if ABn[i][1] < M:
M -= ABn[i][1]
amount_yen += ABn[i][0] * ABn[i][1]
else:
amount_yen += ABn[i][0] * M
brea... | true |
cf31c142bbc83887d9cfa2416ff2b0eea415d124 | guofei9987/leetcode_python | /solved/[590]N-ary Tree Postorder Traversal.py | UTF-8 | 452 | 3.484375 | 3 | [] | no_license | # https://leetcode.com/problems/n-ary-tree-postorder-traversal/description/
# Definition for a Node.
class Node(object):
def __init__(self, val, children):
self.val = val
self.children = children
class Solution(object):
def postorder(self, root):
"""
:type root: Node
... | true |
056012669f405dbac252ae85073c4f0b6a1740cb | Wil10w/Beginner-Library-3 | /More String stuff/inside parentheses.py | UTF-8 | 974 | 3.75 | 4 | [] | no_license |
def in_parentheses(string):
first_para = string.find('(')
second_para = string.find(')')
if string:
if (first_para == -1 and second_para >= 1):
return "Closed ) only"
if second_para == -1 and first_para >= 1:
return "Open ( only"
if second_para < first_par... | true |
c228ed24d0084649e141fab6d5670bde7ac5cf69 | elijahc/vae | /src/test_models/adversarial_duplex.py | UTF-8 | 3,192 | 2.515625 | 3 | [
"MIT"
] | permissive | from __future__ import print_function, division
from keras.layers import Input, Dense, Reshape, Flatten, Dropout, Concatenate, multiply, concatenate
from keras.layers import BatchNormalization, Activation, Embedding, ZeroPadding2D, Lambda
from keras.layers.advanced_activations import LeakyReLU,ReLU
from keras.layers.c... | true |
bf1ef7959243eae826059cdf6ae458e4472a4960 | adaskalopoulou/foundations | /02-Python/homework-2-part2-Daskalopoulou.py | UTF-8 | 2,113 | 4.0625 | 4 | [] | no_license | # Aspasia Daskalopoulou
# 05/24/2017
# Homework 2, Part 2
# LISTS
#1
countries = ['Japan', 'Germany', 'Netherlands', 'Switzerland', 'Italy', 'France', 'Belgium']
#2
for country in countries:
print (country)
# 3
[countries.sort()]
# 4
print (countries[0])
# 5
print (countries[5])
# 6
countries.remove('Japan')
# 7
f... | true |
b2dbd7f44be9cd0252679cbb827d812dd21c8dd1 | AngelVI13/visu | /src/views/helpers.py | UTF-8 | 1,033 | 3.1875 | 3 | [] | no_license | import pygame
from settings.display import DISPLAY_SCALING
def get_text_objects(text, font, color):
text_surface = font.render(text, True, color)
return text_surface, text_surface.get_rect()
def create_message(text, pos, font='freesansbold.ttf', size=60, color=pygame.Color("black"), center=True):
pos_x... | true |
c07acbf90434c52d17f9685967e1273588671f52 | xstrengthofonex/webplex | /tests/test_route.py | UTF-8 | 517 | 2.71875 | 3 | [] | no_license | import unittest
from webplex.route import Route, template_to_regex
class TestRoute(unittest.TestCase):
def test_template_to_regex_with_static_path(self):
template = template_to_regex('/a/static/path')
self.assertEqual(template, "^\/a\/static\/path$")
def test_template_to_regex_with_dynamic_pa... | true |
22d041cc21efd50695aae602df9e97e166a6da01 | JiangFengJason/LeetCodePractice | /SolutionsPY/ClimbingStairs.py | UTF-8 | 233 | 3.421875 | 3 | [] | no_license | class climb:
def climbStairs(self, n: int) -> int:
count=[0]*(n+1)
count[0]=1
count[1]=1
i=2
while i<=n:
count[i]=count[i-1]+count[i-2]
i+=1
return count[-1] | true |
eb21d4c9b7618144c1f52dd4d987d37830466612 | jam620/ddos-random-ip | /ddos-randomip.py | UTF-8 | 920 | 2.890625 | 3 | [] | no_license | #!/usr/local/bin/python3
# -*- coding: utf-8 -*-
import random
import scapy
from scapy.all import *
from scapy.layers.inet import IP, TCP
from scapy.sendrecv import send
victima = input ("Ingrese el ip de la victima:\n")
numero_paquete = 1
while True:
a = str(random.randint(1, 255))
b = str(random.randint(1,... | true |
015d6b7603de8dfb57ee45233a8b2574f607e677 | nikolaj74-hub/lessons | /za6v2.py | UTF-8 | 249 | 2.90625 | 3 | [] | no_license | from itertools import cycle
from sys import argv
name, a, b = argv
b = int(b)
print(' список:', a)
print('сколько раз повторить?', b)
c = 0
for h in cycle(a):
if c >= b:
break
print(h)
c += 1 | true |
49d7e4ff1b3180df6a14ac2069cd0f864f984c2d | EarthLifeConsortium/elc_api | /swagger_server/handlers/router.py | UTF-8 | 2,043 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | """Call approproiate custom response handler for database:api_route."""
def response_decode(resp_json, return_obj, options, db, endpoint):
"""
Extract necessary data from the subquery.
:arg db: Database name
:type db: str
:arg resp_json: Database subquery responce object
:type resp_json: dict... | true |
b398fede2051cef89f320cd95107b2d13187b03e | DS-Wen/SSPredict | /build/lib/sspredict/make_prediction/make_composition.py | UTF-8 | 3,961 | 3.046875 | 3 | [
"MIT"
] | permissive | import numpy as np
import pandas as pd
class build_mesh_ternary:
##"build mesh grid for pseudo-ternary diagram"
# input is increment, and composition range for the pseudo ternary components
# generate evenly spaced concentration points for the pseudo ternary components (psA, psB, and psC)
# then for each pseudo tern... | true |
2ff3a62f99471d41341371721d2ef7f209a2d776 | htl1126/leetcode | /1055.py | UTF-8 | 978 | 3.359375 | 3 | [] | no_license | # Ref: https://leetcode.com/problems/shortest-way-to-form-string/discuss/399353/Python-O(M-%2B-N)-using-hash-table.-Space-O(M).-With-notes.
# Algo: greedy
class Solution:
def shortestWay(self, source: str, target: str) -> int:
after, indexes = {}, {}
# indices: inverted index for each char in 'sour... | true |
a066c9a80b184a50f17ddc8d352e4c9fe9b00214 | majapklm/Edx_course | /week_3/lecture5_problems/l5_9_semordnil.py | UTF-8 | 242 | 2.828125 | 3 | [] | no_license | def semordnilap(str1,str2):
if len(str1) != len(str2):
return False
if len(str1) == 1:
return str1 == str2
if str1[0] == str2[-1]:
return semordnilap(str1[1:], str2[:-1])
else:
return False
print semordnilap("live","evil")
| true |
27a054787dd2d94826f99a32df4f6bb367bf577a | Dragon-Dane/project-azua | /research_experiments/GNN/process_goodreads_dataset.py | UTF-8 | 4,687 | 2.6875 | 3 | [
"MIT",
"LicenseRef-scancode-generic-cla"
] | permissive | import pandas as pd
import os
import numpy as np
import re
fns = os.listdir("./")
book_files = [v for v in fns if "book" in v]
user_files = [v for v in fns if "user" in v]
test_ratio = 0.1
val_ratio = 0.1
data_dir = "/PATH/TO/PROJECT/data/goodreads/"
metadata_dir = os.path.join(data_dir, "metadata")
def remove_tag... | true |
ae590122fd5d97eae5fd4d123d724d1cda41454a | lrlab-nlp100/nlp100 | /yukawa/chap4/nlp_36.py | UTF-8 | 253 | 2.75 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import nlp_30
from collections import Counter
l = nlp_30.read()
s_l = []
for line in l:
for word in line:
s_l.append(word['surface'])
counter = Counter(s_l)
for word,cnt in counter.most_common():
print(word,cnt)
| true |
ecdb86532ce9ae697c02b028780c315a2930f07e | IbtisamZ/Bike-Share-System-Analysis | /BikeShare.py | UTF-8 | 6,369 | 3.734375 | 4 | [] | no_license | import time
import pandas as pd
import numpy as np
from datetime import datetime
from time import strptime
CITY_DATA = { 'chicago': '/users/zahrani/desktop/data/chicago.csv',
'new york city': '/users/zahrani/desktop/data/new_york_city.csv',
'washington': '/users/zahrani/desktop/data/washing... | true |
6f7c9f180212436e8e4b0aa2ee48161d55d0c9b7 | alu0100760064/practica07 | /src/uso_modulo.py | UTF-8 | 322 | 2.921875 | 3 | [] | no_license | #! /urs/bin/python
#! encoding: UTF-8
import modulo
t_upla=(10,100,1000,10000,100000,1000000,10000000,100000000,1000000000)
for i in t_upla:
print modulo.aprox(i)
#el numero maximo de la t_upla es el valor 100000000
#para los elementos de 10 valores, es decir 1000000000
#si se puede poniendo: 1e1, 1e2, 1e3...
... | true |
aea4b5df15c6ba708b971bc63cadf6e31e2d59ff | CalmScout/fsdl_2022_land_cover_classification_unet | /diceloss.py | UTF-8 | 512 | 2.65625 | 3 | [] | no_license | import torch
def dice_coef_9cat(y_true, y_pred, smooth=1e-7):
y_pred = torch.softmax(y_pred, dim=1)
y_true_f = torch.flatten(torch.nn.functional.one_hot(y_true.to(torch.int64), num_classes=7))
y_pred_f = torch.flatten(y_pred.permute(0,2,3,1))
intersect = torch.sum(y_true_f * y_pred_f, axis=-1)
den... | true |
fe9d19a0391c6606181505753b738552975a0422 | michaelmangiante/StreamFlow | /Pandas_Calcs_SecondHalf.py | UTF-8 | 3,047 | 2.71875 | 3 | [] | no_license | # Michael Mangiante
# 9/20/2016
# Calculate Total Annual Flow and Mean R&B Flashiness
import csv
import glob
import pandas as pd
#import numpy as np
# Target File Location for Annual Summary Statistics
AnnualCSV = r'H:\Streamflow\US_Watersheds_Automation\Annual_Summary_Flash_Flow.csv'
# Target File loc... | true |
64052b39f8020fd1e72db72fad115577d6792f66 | jddaly2011/adventure | /commands/look.py | UTF-8 | 926 | 2.8125 | 3 | [] | no_license | #1/usr/bin/python
from examine import examine
def look(commands, available_actions, player, room):
if len(commands) > 1:
examine(commands, available_actions, player, room)
else:
print "\t{}".format(room.intro_text())
room.intro_text()
if room.inventory:
for item in ro... | true |
a3f0404211d590cff3646fcb2f0bc8f32abb1e73 | danielmorris12321/Python-Euler | /ProjectEuler4.py | UTF-8 | 795 | 3.6875 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu Dec 26 12:40:37 2019
@author: Daniel
"""
def findMaxPalindrome(currValue, maxRange, minRange):
for countA in range(maxRange, minRange, -1):
maxValue = countA * maxRange
if(maxValue < currValue):
return(currValue)
for countB in range(ma... | true |
e58b2177f9f8eae91fa5fa300f61feb60e05451b | sburstein/Mathematical-Programming-in-Python | /Gaussian_Elim_P2.py | UTF-8 | 4,765 | 3.4375 | 3 | [] | no_license | "Scott Burstein Gaussian Elimination Matrix Solver Part 2"
import numpy as np
def fwd_solve(a, b):
""" fwd. substition for Lx = b,
returning a new vector x with the solution.
"""
n = len(b)
x = [0]*n
for i in range(n):
x[i] = b[i]
for j in range(i):
x[i] -= a[i... | true |
218ddb04c6fd850d66660bfa30ceb3dae11de20f | RibRibble/python_april_2017 | /md_rahaman/python/flask_fundamentals/dojo_survey_with_validation/server.py | UTF-8 | 1,102 | 2.6875 | 3 | [] | no_license |
from flask import Flask, render_template,request,redirect,session,flash
import os
app = Flask(__name__)
app.secret_key = os.urandom(24)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/result')
def result():
return render_template('result.html')
@app.route('/verification', m... | true |
7efcab6dc88cb09ba9c92ba72462876332ad5ce4 | emplam27/Python-Algorithm | /백준/백준_2630_색종이_만들기.py | UTF-8 | 809 | 3.0625 | 3 | [] | no_license | import sys
sys.stdin = open('input.txt', 'r')
read = sys.stdin.readline
def check_paper(piece, size):
global result
# print('piece:', piece, 'size:', size)
if size == 1:
result[piece[0][0]] += 1
return
piece_sum = sum([sum(val) for val in piece])
if piece_sum == 0 or piece_sum =... | true |
b4a86470174a73b96c29922e9ab6140dad1076ac | mnihatyavas/Python-uygulamalar | /Brian Heinold (243) ile Python/p11009i_sınav.py | ISO-8859-9 | 777 | 3.71875 | 4 | [] | no_license | # coding:iso-8859-9 Trke
# x+y+z=100
# x*5 + y*3 + z*1/3 = 100
print ("1 Ananas: 5 TL, 1 Mango: 3 TL ve 3 Portakal = 1 TL ise")
print ("3 meyve toplam says 100 adet ve toplam fiyat 100 TL olabilmesi iin")
print ("Meyvelerin kaar adetlik kombinasyonlar bu artlar salar?\n")
print ("="*50)
print ("{:^50s}" .for... | true |
b225346041b90f3b648cbd263225cf38996104aa | matusrebro/Biocybernetics | /Archive/Diabetes/Data/Nishida 2004 - IVGTT Exercise effects/data info and plot.py | UTF-8 | 3,526 | 2.578125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu May 10 14:45:11 2018
@author: Admin
"""
# Data published in paper:
# Effect of Moderate Exercise Training on Peripheral Glucose Effectiveness, Insulin Sensitivity
# by Nishida et. al. 2004
# all data were extracted from graphs
# contains glucose and insulin data of IVGTT bef... | true |
4582f377734b2c58a9ba3591781d6f0f94d36bcc | khmelinin/AlgorithmsTeorLabs | /Lab5/Lab5.py | UTF-8 | 1,461 | 3.65625 | 4 | [] | no_license | import random as r
def counting_sort(A, k, ind):
B = [0]*len(A)
C = [0]*k #Створюємо масив С розмірністю k
for j in range(len(A)):
C[int_indexator(A[j],ind)] = C[int_indexator(A[j],ind)] + 1 #в C[i] зберігається кількість елементів, які дорівнюють i
for i in range(1... | true |
5c8ca10a18cdc472a193801101231857504ac3c7 | TOM-SKYNET/AL_NIELIT | /ML/Day3_Nov12/q2.py | UTF-8 | 690 | 3.390625 | 3 | [] | no_license | """
2. Develop an ML model to predict the home price from interest rate.(loan.csv file)
"""
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from sklearn import metrics
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
data=pd.read_csv("loan.... | true |
da8c809799d7d6d9592f99015f24ee0ea43eb750 | CHRISTIANCMARCOS/progAvanzada | /EJERCICIO69.py | UTF-8 | 742 | 4.28125 | 4 | [] | no_license | # Ejercicio 69
# π aproximado.
# El valor de π se puede aproximar mediante las siguientes series infinitas:
# Escriba un programa que muestre 15 aproximaciones de π. La primera aproximación
# debe utilizar solo el primer término de la serie infinita. Cada aproximación adicional
# mostrado por su programa deb... | true |
931e83a43ebbc820f07294bfcc77bc06e1ea4be3 | ankurhcu/FogBus2 | /containers/remoteLogger/sources/utils/types/exceptions/message.py | UTF-8 | 370 | 2.703125 | 3 | [] | no_license | class MessageDoesNotContainSourceInfo(Exception):
def __init__(self):
super(MessageDoesNotContainSourceInfo, self).__init__(
'Message does not contain source information')
class MessageDoesNotContainType(Exception):
def __init__(self):
super(MessageDoesNotContainType, self).__ini... | true |
e296bee6bed0176d7dddf1fd56d9826311c17e4d | josip-milic/RU-face-localization-Hough | /RU_Projekt_General_Hough.py | UTF-8 | 58,419 | 3.28125 | 3 | [] | no_license |
# coding: utf-8
# Sveučilište u Zagrebu<br>
# Fakultet elektrotehnike i računarstva
#
# # Raspoznavanje uzoraka
# <a href="http://www.fer.unizg.hr/predmet/rasuzo_a">http://www.fer.unizg.hr/predmet/rasuzo_a</a>
#
# Ak. god. 2015./2016.
#
# #Detekcija i lokalizacija lica na temelju generalizirane Houghove transforma... | true |
6966ca1550b749bdc2161241c98dc418a404d6c5 | developergaurav-exe/Minimal-Python-Programs | /PythonPrograms/menu_driven_dict_program.py | UTF-8 | 1,998 | 3.921875 | 4 | [] | no_license | ch=input('do you want to start the program (Y,y): ')
while ch=="y" or ch=='Y':
print('=====Menu===== \t')
print('1. Add items to the dictionary \t')
print('2. Search for an item \t')
print('3. Display cost of an item \t')
print('4. Re... | true |
c68efef1dc68debab05f6291a180055ae8f19252 | Bersier/tensorflow-1 | /src/run/nanpropagation.py | UTF-8 | 1,382 | 2.75 | 3 | [] | no_license | import tensorflow as tf
from tensorflow.keras import layers, losses, models
FEATURE_COUNT = 2
TRAINING_SET_SIZE = 128
def patch_nans(t: tf.Tensor) -> tf.Tensor:
""":return t with nans replaced by zeros"""
nan_mask = tf.math.is_nan(t)
return tf.where(nan_mask, tf.zeros_like(t), t)
def check_numerics(t:... | true |
874240c99ba5bffb0bb4d1edd0421b5833a33ddb | ratihfriska/Python-Projects-Protek | /Praktikum 05/prak1 lat4.py | UTF-8 | 832 | 2.875 | 3 | [] | no_license | kode=input("Masukkan kode karyawan ")
nama=input("Masukkan nama karyawan ")
gol=input("Masukkan golongan ")
if(gol=='A') or (gol=='a'):
gjpkk=10000000
pot=(2.5)/100
if(gol=='B') or (gol=='b'):
gjpkk=8500000
pot=(2.0)/100
if(gol=='C') or (gol=='c'):
gjpkk=7000000
pot=(1.5)/100
if(gol=='D'... | true |
ff48eded29d49d7ab99a376a1d97e7e9b0b95ae4 | SunYanCN/Seq2seq-for-NER | /Mydata.py | UTF-8 | 6,842 | 2.671875 | 3 | [] | no_license | # coding=utf-8
# @author: qingyue
import numpy as np
import codecs
import os
import random
import logging, sys, argparse
flatten = lambda l: [item for sublist in l for item in sublist] # 二维展成一维
index_seq2slot = lambda s, index2slot: [index2slot[i] for i in s]
index_seq2word = lambda s, index2word: [index2... | true |
933581c94d882d9543f2e0c8d6cd86f7cc2b86ff | RoMalms10/holbertonschool-higher_level_programming | /0x0C-python-almost_a_circle/tests/test_models/test_square.py | UTF-8 | 14,675 | 3.375 | 3 | [] | no_license | #!/usr/bin/python3
""" My module for testing Square
"""
import unittest
import io
import sys
from models.base import Base
from models.rectangle import Rectangle
from models.square import Square
class TestSquare(unittest.TestCase):
""" Tests the square class
"""
def test_id(self):
""" Tests the id... | true |
94897e34dd20b8302ee1b3f22bea9474d06d181f | abhishekkr/lyrical-video-generator | /create-audio.py | UTF-8 | 2,158 | 2.6875 | 3 | [] | no_license | #!/usr/bin/env python
import pyttsx3
from gtts import gTTS
import os
import time
def create_audio_with_gtts(transcript_file, audio_file):
file = open(transcript_file, "r").read().replace("[\n\r]", " ")
language = 'en'
print("creating audio file... started at %s:%s:%s" % (time.gmtime().tm_hour, time.gmtim... | true |
12fba399812059a3f0bc87458caa5fd3679684c0 | rec/nc | /nc/color.py | UTF-8 | 3,643 | 3.03125 | 3 | [
"MIT"
] | permissive | from functools import cached_property
from typing import Tuple
import collections
import colorsys
import math
import numbers
try:
from typing import Self
except ImportError:
from typing import Any as Self
COLOR_TUPLE = collections.namedtuple('Color', 'r g b')
class Color(COLOR_TUPLE):
"""A single Color... | true |
0e0685643d67516a062ef501fe9a2c69b0a69ecc | junesvibes/getting-started | /returns.py | UTF-8 | 67 | 2.875 | 3 | [] | no_license | space= "\n"
def cube(num):
return num*num*num
print(cube(4))
| true |
02f59a9de7b8ed07376aa952482e0ec746fe3c05 | houssou/IA_robot | /cartographie/graph.py | UTF-8 | 4,179 | 2.765625 | 3 | [] | no_license | from cartographie.noeud import Noeud
import math
class Graph:
def __init__(self):
self.listeNoeud = {}
self.step = 1
def serialize(self, hash):
serialization = "<graph"
serialization += " hash='" + hash + "'"
serialization += " step='" + str(self.step) + "'"
se... | true |
f451c09a4bc8b3bdea836af35144bc4c6e365b21 | wilfredarin/geeksforgeeks | /Graph/disjoint-set-union-find.py | UTF-8 | 430 | 3.546875 | 4 | [] | no_license | #https://practice.geeksforgeeks.org/problems/disjoint-set-union-find/1
def find(arr, x):
# Code here
if arr[x-1] == x:
return arr[x-1]
else:
return find(arr,arr[x-1])
# function shouldn't return or print anything
def union(arr, x, z):
# Code here
x_parent = find(arr, x)
z_p... | true |
e6f4111e3b4e1960a17608feb766896bb73db16e | VatsalRaina/SGM_pytorch | /utilities.py | UTF-8 | 2,611 | 2.875 | 3 | [] | no_license | import numpy as np
import os
def _create_word_id_dict(words_index_path):
dict = {}
path = os.path.join(words_index_path)
with open(path, 'r') as f:
for line in f.readlines():
line = line.replace('\n', '').split()
dict[line[1]] = int(line[0]) + 1
return dict
def _word_to... | true |
f3613c6052da991eb25b6ff4cd42783b711eb02b | oquechy/paradigms2016 | /python_4/folder.py | UTF-8 | 8,784 | 2.75 | 3 | [] | no_license | import model
import printer
class ConstantFolder:
def visit(self, tree):
return tree.accept(self)
def visitNumber(self, n):
return n
def visitFunDefinition(self, fd):
return model.FunctionDefinition(fd.name, fd.function.accept(self))
def visitFunction(self, f):
return... | true |
daf0b4e10096ae8f90c50746c8c1d3b4e7ab462d | jucimarjr/zelda | /design_pattern/13_ChainOfResponsability/Python/SoldStates.py | UTF-8 | 829 | 3.21875 | 3 | [] | no_license | from State import State
class SoldStates(State):
def __init__(self, gumball_machine):
self.__gumball_machine = gumball_machine
def insert_quarter(self):
print("Please wait, we're already giving you a gumball")
def eject_quarter(self):
print("Sorry, you already turned to crank")
... | true |
ca83c693c1c713fef602e4b5327a3d477f8eaf50 | justinclark-dev/CSC110 | /code/Chapter-9/card_dealer.py | UTF-8 | 2,376 | 5.03125 | 5 | [
"MIT"
] | permissive | # This program uses a dictionary as a deck of cards.
def main():
# Create a deck of cards.
deck = create_deck()
# Get the number of cards to deal.
num_cards = int(input('How many cards should I deal? '))
# Deal the cards.
deal_cards(deck, num_cards)
# The create_deck function returns a dicti... | true |
094166f537f9c7f50220c3cd9c9eaa6231104cb0 | rayind/weboc | /protocol_reader.py | UTF-8 | 2,014 | 2.5625 | 3 | [] | no_license | __author__ = 'Ray'
import xmltodict
from collections import OrderedDict
class ProtocolReader(object):
def __init__(self, protocol):
self.protocol = OrderedDict()
x = xmltodict.parse(protocol.read())
for msg in x['protocol']['msg']:
if '@server' in msg and msg['@server'] =... | true |
ae45c4485d009157118e2ed37cc368fffcac4901 | jinjinanan/note | /语言/Python/StudyThreading.py | UTF-8 | 925 | 3.5625 | 4 | [] | no_license | import threading
import time
# 创建线程的两种方法
# 一 将要执行的方法作为参数传给Thread的构造方法
# def action(arg):
# time.sleep(2)
# print('the arg is: %s in second way \r' % arg)
# for i in range(4):
# t = threading.Thread(target=action,args=(i,))
# t.start()
# print('the first way to create thread end')
# 二 从Thread继承,并重写ru... | true |
4614bdfcec73155042e6d2993d39b14e9f4976bf | jpalmowswroc/NOKIA_Python | /zadanie2_wyjatki.py | UTF-8 | 244 | 3.5625 | 4 | [] | no_license | my_list = [1,2,3,4,5,6]
index = int(input("podaj index"))
try:
if index <= len(my_list):
print(my_list[index])
if index > len(my_list):
raise IndexError
except IndexError:
print('Poza zakresem')
| true |
aa690e956e741de43e03e88a051871e52bbf7b6c | aaqibkhorasi/bowling_api | /models.py | UTF-8 | 2,128 | 3.015625 | 3 | [] | no_license | from common import constants
class Frame(object):
"""
Frame object which will hold score per frame
"""
def __init__(self, frame_id):
self.frame_id = frame_id,
self.first_throw_score = -1
self.second_throw_score = -1
self.third_throw_score = -1
self.frame_score ... | true |
3cecfe1047038234f1eec23f88841561a0718e0e | bkravitz/climatecode | /code for fun/dice.py | UTF-8 | 1,277 | 3.6875 | 4 | [] | no_license | import random
print "Enter dice you want to roll"
print "Examples: 1d6, 2d12, 2d8+1d4, etc."
print "You can also add modifiers, e.g., 3d6+5"
diceroll=raw_input("> ")
randarray=[]
mod=0
dicevals=0
results=[]
if '+' in diceroll:
diceroll2=diceroll.split('+')
for n in range(len(diceroll2)):
temp=dicero... | true |
75a3487891958c8fcbdd2b37e3c95d395df64a76 | soicem/robot_journalism | /example_code/coroutine/test.py | UTF-8 | 268 | 2.734375 | 3 | [] | no_license | import random
from example_code.coroutine.clockdeco_param import clock
@clock('{name}({args}) dt={elapsed:0.3f}s')
def start():
list = []
for _ in range(60):
list.append(random.randint(0, 10000 - 1))
print(list)
return list
print(start()) | true |
aea4787105cb4d2c6bdd54b8d906819818dd81e8 | sgiuij/aem_dewatering | /tethysapp/aemdewater2/timml/dev/ml.py | UTF-8 | 81,816 | 2.53125 | 3 | [
"MIT"
] | permissive | '''
Copyright (C), 2015, Mark Bakker.
TimML is distributed under the MIT license
'''
import numpy as np
import inspect # Used for storing the input
from scipy.special import k0, k1
from besselaes import potbeslsho, potbesonlylsho, disbeslsho, disbesonlylsho, potbesldho, disbesldho, omegalapldho, omegalaplsho
class Mo... | true |
f0c9c4aae70b14927015c6f468f311f92f2d48e1 | ferhatelmas/algo | /leetcode/algorithms/medium/perfect_squares.py | UTF-8 | 524 | 3.171875 | 3 | [
"WTFPL"
] | permissive | class Solution:
def primes(self, n):
d = 2
while d * d <= n:
c = 0
while (n % d) == 0:
c += 1
n //= d
yield (d, c)
d += 1
if n > 1:
yield (n, 1)
def numSquares(self, n):
while n % 4 == 0:... | true |