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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
286bd4bce16bb77eaf5cecbad3dc4832fb0c71a5 | Python | BackupTheBerlios/damaris-svn | /damaris-0.9/frontends/bluedamaris/Resultable.py | UTF-8 | 1,962 | 2.90625 | 3 | [] | no_license | # -*- coding: iso-8859-1 -*-
#############################################################################
# #
# Name: Class Resultable #
# ... | true |
85dcb4a7161307c030c9c875f42aa96d1b718100 | Python | sleevewind/practice | /day02/practice.py | UTF-8 | 245 | 3.484375 | 3 | [] | no_license | # 获取十六进制颜色 0xF0384E 的RGB值,以十进制形式打印
color = 0xF0384E
red = color >> 16
green = (color & 0x00ff00) >> 8
blue = color & 0x0000ff
print("red = ",hex(red))
print("green = ",hex(green))
print("blue = ",hex(blue))
| true |
ebf4e139cd733d0f9d6f62f8eaae841183cc02fd | Python | sty61010/2019CV_hw1_106034061 | /HW1_106034061/hw1_2/white_balance.py | UTF-8 | 2,024 | 3.078125 | 3 | [] | no_license |
import numpy as np
import cv2
def generate_wb_mask(img, pattern, fr, fb):
'''
Input:
img: H*W numpy array, RAW image
pattern: string, 4 different Bayer patterns (GRBG, RGGB, GBRG, BGGR)
fr: float, white balance factor of red channel
fb: float, white balance factor of bl... | true |
b134da6d6c1cb99dbe9ac174c6dd0b6ed2a8d321 | Python | Aasthaengg/IBMdataset | /Python_codes/p00001/s254331958.py | UTF-8 | 117 | 3.25 | 3 | [] | no_license | a = [];
for i in range(0, 10):
a.append(int(input()));
a.sort(reverse = True);
for i in range(0, 3):
print(a[i]); | true |
f8044447c54d78893c29bb816d1243eae6d8e24e | Python | gregorulm/advent_of_code_2016 | /16/part1.py | UTF-8 | 1,017 | 3.65625 | 4 | [] | no_license | # Advent of Code 2016: Day 16, Part 1
# Gregor Ulm
def checksum(xs):
acc = []
while len(xs) > 1:
first = xs[0]
second = xs[1]
xs = xs[2:]
if first == second:
acc += '1'
else:
acc += '0'
if len(acc) % 2 == 0:
return checksum(acc)
return "".join(acc)
... | true |
8137e6c31b7b5fad28e1951d989257d2db190d45 | Python | ThomasMcDonnell/computational_thinking | /language_python/problem_sets/greedy_cow_transport.py | UTF-8 | 2,357 | 4.4375 | 4 | [] | no_license | """
One way of transporting cows is to always pick the heaviest cow that will fit onto the spaceship first. This is an example of a greedy algorithm. So if there are only 2 tons of free space on your spaceship, with one cow that's 3 tons and another that's 1 ton, the 1 ton cow will get put onto the spaceship.
Implement... | true |
e05695378f015314dc2ef6b1439419eb3c00f41d | Python | sbrouil/hivery-backend-challenge | /backend/routes/validation.py | UTF-8 | 587 | 3.015625 | 3 | [] | no_license | import uuid
import re
from backend.exceptions import BusinessException
COMPANY_NAME_PATTERN = re.compile('^[A-Z]*$')
def bool_param_type(boolStr):
return boolStr.lower() == 'true'
def UUID(value):
return uuid.UUID(value)
def validate_uuid(uuid_str):
try:
uuid.UUID(uuid_str)
except ValueError... | true |
78ed5e27e900312d9ad8310d3dec4d5c47c3630e | Python | ufgf/RIFE-Colab | /frameChooser.py | UTF-8 | 3,731 | 2.75 | 3 | [] | no_license | import os
from Globals.GlobalValues import GlobalValues
def chooseFrames(framesFolder, desiredFPS):
frameFiles = os.listdir(framesFolder)
frameFiles.sort()
lastFile = int(frameFiles[-1][:-4])
desiredFrameSpacing = (1 / desiredFPS) * GlobalValues.timebase
timecodesFileString = ""
currentTime = d... | true |
9feb3c84996f8a2c0d60a5d901c8425755ca9180 | Python | Jean-Baptiste-Camps/OCR_workshop | /randomise_data.py | UTF-8 | 485 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env python3
import sys
import random
if __name__ == '__main__':
train = open("train.txt", "w")
val = open("val.txt", "w")
test = open("test.txt", "w")
random.seed('1214')
for i in sys.argv[1:]:
monRand = random.random()
if monRand <= 0.1:
test.write(i+"\n"... | true |
e4a73abb7b084f5d1ea872cffdcc1b884bf16588 | Python | trxw/CDIPS_PandoraTeam | /twitter/tweepy_API.py | UTF-8 | 1,141 | 2.90625 | 3 | [] | no_license | #Access the Twitter API through tweepy
#Extracts some basics stats from specified users; saves output as twitter_followers.csv
#Requires your APP/outh KEY and secret
#User input: list the artists twitter account (future iteration to accept actual name/verified account?)
userlist = ['taylorswift13', 'monstersandmen']
... | true |
8280934a4d2bdb1cebe911b9a120b5e40ec221a8 | Python | esix/competitive-programming | /acmp/page-03/0102/main.py | UTF-8 | 205 | 2.75 | 3 | [] | no_license | A,B,C,O = [list(map(int, input().split(' '))) for i in range(4)]
def S(A,B,C):
return abs((B[0]-A[0])*(C[1]-A[1]) - (B[1]-A[1])*(C[0]-A[0]))
print(['Out','In'][S(A,B,C) == S(A,B,O)+S(B,C,O)+S(C,A,O)])
| true |
657d3ad579a5a5729814ee63a2a701e9ba4f4536 | Python | hysfwjr/dssp | /src/vocab_2_theme.py | UTF-8 | 2,044 | 2.609375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# @author hysfwjr()
# date 2018-01-08
# 使用训练好的word2vec 模型找出本例中较为相近的『word』
from gensim.models import Word2Vec
from gensim.models import KeyedVectors
import re
import json
import sys
import common
reload(sys)
sys.setdefaultencoding("utf-8")
def gen_simword_dict(vocab_path, simi_threshold=0.9):
... | true |
9da120f10c93e8328c0f6102809fa4231e1fe4e3 | Python | amitks815/pycode | /dictcomprehensive.py | UTF-8 | 165 | 3.109375 | 3 | [] | no_license | list1=[1,2,3,4]
list2=[5,6,7,8]
dict1=zip(list1,list2)
d={ key:value for (key,value) in zip(list1,list2)}
print(d)
# di=dict(zip(list1,list2))
#
# print(di) | true |
faff6467cf4bb9dba8f5bdde03c3dd4db58395bd | Python | TiiratsT/DSTask3 | /two-phase-program.py | UTF-8 | 6,375 | 3 | 3 | [] | no_license | import sys
import logging
import process
import random
import time
from multiprocessing import Lock
# Global variables
processes = []
coordinator = ""
historyType = ""
states = []
# Used to print out all processes consistency histories
def printProcessHistory(pool):
print("")
for node in pool:
pool[no... | true |
1c5feb761a9bbc021664fcff8a27af69f878645a | Python | alatalab/articles_theme | /test.py | UTF-8 | 2,248 | 2.765625 | 3 | [] | no_license |
import time, re
import math
import nltk
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
def split_article(article):
words=["Copyright ","©","elsevier inc rights reserved", "elsevier science inc", "elsevier science ltd"]
result=article
for word in words:
result=result.split(word)[0... | true |
42df28e7165fdb0b07179d9f99cec427ed1c3ba3 | Python | RafayelGardishyan/knnFruitSorter | /database/models.py | UTF-8 | 505 | 2.640625 | 3 | [] | no_license | from django.db import models
from .constants import SHAPES, TEXTURES, COLORS
# Create your models here.
class Fruit(models.Model):
name = models.CharField(max_length=100)
size = models.IntegerField()
texture = models.IntegerField(choices=TEXTURES)
shape = models.IntegerField(choices=SHAPES)
color =... | true |
77e4560b001cd1de1a81606700da0c0fde106dd7 | Python | pahaz/crawler | /crawler_util.py | UTF-8 | 1,689 | 2.6875 | 3 | [] | no_license | import cgi
from html.parser import HTMLParser
import threading
import urllib.parse
__author__ = 'pahaz'
class UrlThreadSafeStore(object):
def __init__(self):
self._store = set()
self._lock = threading.Lock()
def check_and_add(self, obj):
self._lock.acquire()
has = obj in self... | true |
321ed0a81d9ab1fff592f88e98bec08fa3211bc7 | Python | meghakoushik/Machine-Learning-Fellowship | /week1/Basic Python/prog6.py | UTF-8 | 356 | 3.9375 | 4 | [] | no_license | # program to calculate number of days between two dates
# date class is import from the datetime module
from datetime import date
first = date(2014, 7, 2) # FIRST DATE
second = date(2014, 7, 11) # SECOND DATE
diff = second-first # DIFFERENCE BETWEEN TWO DATE
print(diff.days) ... | true |
123f1fb3800552c2963b0183c2dfec6ac640e8dd | Python | anshulkamath/gopher-world-source | /geneticAlgorithm/library.py | UTF-8 | 3,161 | 3.453125 | 3 | [] | no_license | import numpy as np
import random
from classes.Encoding import Encoding
import geneticAlgorithm.constants as constants
"""
A library of all essential functions for the genetic algorithm
"""
def generateTrap(encoder: Encoding = Encoding()):
member = []
for i in range(12):
cellCode = random.randrange(2, l... | true |
bbc423f6a6205a97f5c6bb6badccd97b90d885ec | Python | joseph-ismailyan/AMS-129 | /hw5/main.py | UTF-8 | 270 | 3.140625 | 3 | [
"MIT"
] | permissive | from newtons import newtons
def f(x):
return (2*x**7 + 4*x**5 - 2*x**3 + 3*x + 1)
def df(x):
return (14*x**6 + 20*x**4 - 6*x**2 + 3)
def main():
initial_guess = 10.
threshhold = 1.E-8
newtons(f, df, initial_guess, threshhold)
if __name__ == "__main__":
main()
| true |
605a5759c68cb989180cc3ec6ab4d174c4f4f556 | Python | KhalilSawant/gcj | /2016/1A/2-rank-file/rank-file.py | UTF-8 | 704 | 3.125 | 3 | [] | no_license | #!/usr/bin/python
################################################################
# Author: Khalil Sawant
# https://code.google.com/codejam/contest/433101/dashboard#s=p1
################################################################
import sys;
T = int(raw_input());
for i in range(T):
N = int(raw_input().strip(... | true |
ac8a26460948f51744dfcfe631ac33a4a32aea3b | Python | sumeet0420/100-days-python | /day28/pomodoro-start.py | UTF-8 | 1,227 | 3.25 | 3 | [] | no_license | from tkinter import *
YELLOW = "#f7f5dd"
window = Tk()
window.title("Pomodoro")
window.config(padx=10, pady=10, bg=YELLOW, highlightthickness=0)
timer_label = Label(text="Timer", font=("Courier", 24, "bold"))
timer_label.grid(column=1, row=0)
canvas = Canvas(width=400, height=400, bg=YELLOW)
tomato_img = PhotoImage(fi... | true |
8ff4bd7b20eaf80496063caa179b44e2bac8442e | Python | LeeTaylorLondon/Neural-Network-Diabetes-Classifier | /main.py | UTF-8 | 2,956 | 3.109375 | 3 | [] | no_license | import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
from sklearn import preprocessing
from sklearn.model_selection import train_test_split
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
np.random.seed(1)
def load_diabetes():
return pd.read_csv('d... | true |
c2cab84e43fb548ed1d90363564ab39c0e3b8b79 | Python | daniel-reich/turbo-robot | /tRHaoWNaHBJCYD5Nx_11.py | UTF-8 | 498 | 3.84375 | 4 | [] | no_license | """
Create a function that returns `True` if two strings share the same letter
pattern, and `False` otherwise.
### Examples
same_letter_pattern("ABAB", "CDCD") ➞ True
same_letter_pattern("ABCBA", "BCDCB") ➞ True
same_letter_pattern("FFGG", "CDCD") ➞ False
same_letter_pattern("FFFF", ... | true |
84d282184f5e73f69bc513127f985c5f16922bb7 | Python | Naier15/Project_for_car_owners_bot | /bd.py | UTF-8 | 9,752 | 2.59375 | 3 | [] | no_license | import sqlite3
import pytz
from datetime import datetime
# Функции Базы данных
def create_db(message):
try:
connection = sqlite3.connect("{}.db".format(message.chat.id), check_same_thread = True)
cursor = connection.cursor()
cursor.execute("CREATE TABLE IF NOT EXISTS cars (gosnum TEXT NOT ... | true |
5140266c4110f5d448b7e6c45774372a7f5e2c24 | Python | datartathon/PySDMs | /PySDMs/internal/validation_visuals.py | UTF-8 | 4,617 | 2.6875 | 3 | [
"MIT"
] | permissive | # Module: PySDMs/internal
# Author: Daniel Ryan Furman <dryanfurman@gmail.com>
# License: MIT
# Last modified : 8/9/21
# https://github.com/daniel-furman/PySDMs
import pandas as pd
import numpy as np
import sklearn
from matplotlib import pyplot as plt, style
from pycaret import classification as pycaret
import pickle ... | true |
4838bbd292ec5188c28de36e72dad92793baeca3 | Python | srinath157/spro_test1 | /test.py | UTF-8 | 1,369 | 2.734375 | 3 | [] | no_license | import pprint
from utils import *
x = NestedDict()
# example of benefit using NestedDict class is
# assigning nested key value with out initializing it.
x['a']['b']['c'] = 45
a = {'B': {'fc': {'fc5.1': {'port': 'fc1/35', 'switch': 'SJC-H7-FC1'}}}}
b = {'B': {'fc': {'fc6.1': {'port': 'fc1/33', 'switch': 'SJC-H7-FC1'}}... | true |
3c7b66f9a5a7a569d73c905fd86dd4d0e4161236 | Python | agladman/futuremash | /futuremash/tweetbuilder.py | UTF-8 | 4,804 | 2.921875 | 3 | [] | no_license | #!/usr/bin/env Python3
"""tweetbuilder.py: a script to generate and tweet fake tech news
headlines using markov chains.
For now output will just be sent to the command line.
"""
import logging.config
import markovify
import os
from random import choice
from twython import Twython
import yaml
log_cfg = ... | true |
02c57dd814d8d0dac918f69aa19f883aadec069a | Python | spacetime314/python3_ios | /extraPackages/matplotlib-3.0.2/examples/subplots_axes_and_figures/two_scales.py | UTF-8 | 1,533 | 3.765625 | 4 | [
"BSD-3-Clause"
] | permissive | """
===========================
Plots with different scales
===========================
Two plots on the same axes with different left and right scales.
The trick is to use *two different axes* that share the same *x* axis.
You can use separate `matplotlib.ticker` formatters and locators as
desired since the two axes... | true |
491f990e0b729cb24d30472292d34737ced5da6e | Python | fcrespo82/xbox-one-backcompat-games | /manage.py | UTF-8 | 2,436 | 2.78125 | 3 | [] | no_license | #!/usr/bin/env python
#!coding: utf-8
"""
Updates games.json and starts up the angular site
usage:
./manage.py (runserver [--update]|update-games-list) [-v]
options:
runserver Start Angular app
update-games-list Update games list
-v Verbose [default: True]
--update ... | true |
4d9f506f4f8a4c6523c2b82f3332e5dda1d771d7 | Python | Dirack/Estudos | /SCons/Help/SConstruct | UTF-8 | 176 | 2.671875 | 3 | [] | no_license | Help('''
Type 'scons -h' to get help
Study about scons!!!
Type 'scons i=2' to see something cool!
:)''')
if ARGUMENTS.get('i'):
print("You passed i="+ARGUMENTS.get('i'))
| true |
c9c705dfd6b0afbd6efd03b0a9a76f3769a06792 | Python | yakuza8/peniot | /src/GUI/utils.py | UTF-8 | 8,741 | 2.8125 | 3 | [
"MIT"
] | permissive | # This file contains methods which are used in the GUI.
import importlib
import inspect
import os
import pkgutil
import shutil
from Tkinter import *
from hard_coded_texts import project_title, window_size, window_background_color
from Utils.ExtendUtil.import_util import ImportUtil
# list of default protocols
DEFAULT_... | true |
add76e62fc29e28b9a7bcb293d6e7e2574ccc361 | Python | VISHNU-P-M/Reportlab | /pie.py | UTF-8 | 501 | 2.5625 | 3 | [] | no_license | from reportlab.graphics.shapes import *
from reportlab.graphics.charts.piecharts import Pie
from reportlab.platypus import SimpleDocTemplate
story = []
d = Drawing(400,400)
pc = Pie()
pc.x = 150
pc.y = 50
pc.data = [10, 20, 30, 40, 50, 60]
pc.labels = ['a', 'b', 'c', 'd', 'e', 'f']
pc.sideLabels = 1
pc.slices.strokeWi... | true |
18065cdb0d68ca9c48f42521d25a34c0c53dd914 | Python | cravo123/LeetCode | /Algorithms/0516 Longest Palindromic Subsequence.py | UTF-8 | 3,092 | 3.78125 | 4 | [] | no_license | # Solution 1, DP with O(n) space
class Solution:
def longestPalindromeSubseq(self, s: str) -> int:
# if dp[left][right] means longest palindromic subsequence in s[left:(right + 1)]
# dp[left][right] depends on
# dp[left + 1][right - 1]
# dp[left][right - 1]
# dp[left + ... | true |
dc7f7796f871ec785a806e5aa261a73de02dfbf2 | Python | PaulACoroneos/fcc-python-for-beginners | /better-calculator.py | UTF-8 | 301 | 3.8125 | 4 | [] | no_license | num1 = float(input("Enter first nunber: "))
op = input("Enter an operator: ")
num2 = float(input("Enter a second number: "))
if op == "+":
print( num1 + num2)
elif op == "-":
print(num1-num2)
elif op == "*":
print(num1*num2)
elif op == "/":
print(num1/num2)
else:
print("invalid operator") | true |
0f813c36b0959a09d9591f5d3d76337f4f8b10b6 | Python | tian-yu/INF552 | /hw6/hmm.py | UTF-8 | 7,733 | 3.078125 | 3 | [
"MIT"
] | permissive | """
INF 552 Homework 6
Hidden Markov Model(HMM) and Viterbi Algorithm
Group Members: Tianyu Zhang (zhan198), Minyi Huang (minyihua), Jeffy Merin Jacob (jeffyjac)
Date: 4/15/2018
Python 3.6
"""
import math
import numpy as np
grid_world= []
tower_location = []
noisy_distances = []
states =[]
transition_matrix = []
ini... | true |
a603de67954e192ea310f2436e6d7ce78b624984 | Python | rjdirisio/DMC_DescendentWeighting | /HarmonicOscillatorDW.py | UTF-8 | 4,551 | 2.625 | 3 | [] | no_license | import numpy as np
import math
import matplotlib.pyplot as plt
import copy
from mpl_toolkits.mplot3d import Axes3D
#mass H = 1.6727346e-27
#masss e- = 9.109e-31 kg
numAtoms = 1
initialWalkers = 2000
wvnmbr = 4.55634e-6
omega = 2000.0000*wvnmbr #in atomic units
dimensions = 1
mass = 1836.35/2
deltaT = 5.0... | true |
47d62dfb81c6709380636b5aa4ed24c3fd04ebd1 | Python | x2ever/Smart-Elevator-With-RL | /model/setting.py | UTF-8 | 919 | 2.953125 | 3 | [] | no_license | from src.Mission import Mission
from src.Person import Person
import gym
people = [Person(4, 4) for i in range(25)] + [Person(5, 5) for i in range(25)]# 2 ~ 5층에서 일하는 50명의 사람
breakfast = Mission(2, 7.5 * 60 * 60, 8.5 * 60 * 60) # 아침식사
morning_conference = Mission(3, 9 * 60 * 60, 10 * 60 * 60) # 아침회의
lunch = Mission(2,... | true |
8c98fac48ebf1a8e02f1d776d9f9e38a57c30105 | Python | gauravkalge/Doraemon-jump-game-python | /Doremon_Jump.py | UTF-8 | 5,830 | 2.78125 | 3 | [] | no_license | import pygame, sys
from pygame.locals import *
#intialization of modules
pygame.init()
#font
font=pygame.font.Font("freesansbold.ttf",20)
#setting screen size for the game
screen=pygame.display.set_mode((700,500))
#(width,height)
pygame.display.set_caption("Doremon Jump")
#color
white = (135,206,235)
black=(0,0,0)
#dor... | true |
ec1a27e8c78a7194177de00e4cc72727e7536dd4 | Python | Archeane/Hackers | /algorithmn/process.py | UTF-8 | 4,941 | 2.5625 | 3 | [] | no_license | from random import randint
import sys
import json
# import zerorpc
'''
c = zerorpc.Client()
c.connect("tcp://127.0.0.1:4242")
currentHackathon = c.sendTestHackathon()
c.close()
'''
# print("Output from Python")
currentHackathon = json.loads(sys.argv[1])
# TODO: change this current user to logged in user
currentHac... | true |
7802e87ce6cd55ee3395d91253baa33258431398 | Python | HimavarshiniKeshoju/AI-Track-ML | /17K41A05F8-ANN-P10-3.py | UTF-8 | 5,559 | 2.765625 | 3 | [] | no_license | import pandas as pd
import numpy as np
data=pd.read_csv("D:\LoadDatainkW.csv")
data.head()
data.shape
#x=data[0:-1, 2]
#y=data[1:,2]
x = data.iloc[0:-1, 2]
y = data.iloc[1:, 2]
normalized_datax=(x-x.mean())/x.std()
normalized_datax
normalized_datay=(y-y.mean())/y.std()
normalized_datay
from sklea... | true |
850c259666f461ba00b500a2b830db65a0884385 | Python | zigri2612/botbuilder-python | /samples/Core-Bot/dialogs/main_dialog.py | UTF-8 | 3,488 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-generic-cla"
] | permissive | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from datetime import datetime
from botbuilder.dialogs import ComponentDialog, DialogSet, DialogTurnStatus, WaterfallDialog, WaterfallStepContext, DialogTurnResult
from botbuilder.dialogs.prompts import TextPrompt, ConfirmProm... | true |
d71733a5d6d4dfb6e33577f78e3fc1aad5a117fd | Python | RuthPetrie/uor | /PYTHON/cmss/prac1_LinAdvect/advection/FTCS_stability_analysis.py | UTF-8 | 730 | 2.921875 | 3 | [] | no_license | import pylab as pl
# plot the magnitude of the amplification factor for FTCS for c =0.2,
# and range over k Dx = 0:pi
# a range of values of c
#c = pl.linspace(-1.5,1.5,31)
# set c
c = 0.2
#set kdx
kdx = pl.linspace(0.0,pl.pi,30)
# cosine kdx
coskdx = pl.cos(2*kdx)
#print coskdx
# set cos(kdx) = pi/2 => cos(pi/2... | true |
33099883d6a52193a7512422f243bf687d96d1d3 | Python | surgesg/PyOracle | /Resources/PyOracle/PyOracle.py | UTF-8 | 7,495 | 3.109375 | 3 | [] | no_license | #############################################################################
# pyoracle.py
# builds a factor oracle from an input string of audio features
# modified 03.18.2013
# greg surges
# copyleft 2011 - 2013
#############################################################################
import time
from random ... | true |
486b2cd1f5aaa4775dae0b9ba4a4bcce100b418c | Python | hyunwoo-song/TOT | /startcamp/day04/dict.py | UTF-8 | 1,690 | 3.96875 | 4 | [] | no_license | # 1. 딕셔너리 만들기
lunch = {
'중국집':'02-1123-4544',
'양식집':'053-216-4545',
'한식집':'054-451-5452',
}
dinner = dict(중국집='02-1233-4544') #딕셔너리로 변환시켜주는 내장함수 # key값은 문자열이 아닌 양쪽 따옴표 없이 기입
# int()
# list()
# 2. 딕셔너리 내용 추가하기
lunch['분식집'] = '053-123-4567'
# 3. 딕셔너리 내용 가져오기
print(lunch['중국집']) #=> 02-1123-4544
idol = {
... | true |
c3977491b022359d6083d4c7443e2b965ae25946 | Python | m215910/website | /sql_playground.py | UTF-8 | 352 | 3.25 | 3 | [] | no_license | import sqlite3
def main():
conn = sqlite3.connect('database1.db')
cursor = conn.cursor()
cursor.execute("SELECT * FROM tweets ORDER BY likes DESC") #DESC or ASC
results = cursor.fetchall()
#print(results)
#for x in results:
#print(x[0])
for x in results:
print('TWEET: %s LIK... | true |
2a519e3cff468975bb3620240415f5ad56a72307 | Python | StevenLee1/pandas | /test.py | UTF-8 | 567 | 2.75 | 3 | [] | no_license | from captcha.image import ImageCaptcha
import matplotlib.pyplot as plt
import numpy as np
import random
# %matplotlib inline
# %config InlineBackend.figure_format = 'retina'
import string
characters = string.digits + string.ascii_uppercase
print(characters)
width, height, n_len, n_class = 170, 80, 4, len(characters)... | true |
b552c2d632cdb2f95f61973e00430c0c564ea157 | Python | wangerde/codewars | /python3/kyu_7/sum_of_two_lowest_integers.py | UTF-8 | 510 | 4.46875 | 4 | [] | no_license | """Sum of two lowest integers
https://www.codewars.com/kata/sum-of-two-lowest-integers
Create a function that calculates the sum of the two lowest numbers given an
array of minimum 4 integers. No floats or empty arrays will be passed.
For example, when an array is passed like [19,5,42,2,77], the output should be
7.
... | true |
7d672e3e817d7734759855b0c7f44cf298a62e2e | Python | lalo967/raspberry | /python/pruebassensores/PyMLX90614-0.0.3/MLXpruebatxt.py | UTF-8 | 1,409 | 3.1875 | 3 | [
"MIT"
] | permissive | import time
import numpy as np
from smbus2 import SMBus
from mlx90614 import MLX90614
arc=open("/tmp/tem.txt","a")
#arc=open ("/home/pi/mnt/drive/tem.txt","a")
def hora():
ahora = time.strftime("%c")
print (ahora)
print ('\n')
time.sleep(0.005)
return ahora
def objeto(): #se declara la funcion
... | true |
677f118698f57d1266c6dbd041d934a8211e46e0 | Python | AdamSyauqi/Text_Based_Python_Game | /GameV2.py | UTF-8 | 4,000 | 3.3125 | 3 | [] | no_license | import csv
from icecream import ic
class Rooms:
def __init__(self, name, text, lock, items):
self.name = name
self.text = text
self.lock = lock
self.items = items
self.north = None
self.east = None
self.south = None
self.west = None
def take_it... | true |
c5b2100da47a778a3fa173723c0d9aa311abe6aa | Python | Aasthaengg/IBMdataset | /Python_codes/p02400/s502139904.py | UTF-8 | 87 | 2.765625 | 3 | [] | no_license | import math
k=float(raw_input())
s=k*k*math.pi
t=2*k*math.pi
print "%.6f %.6f"%(s,t) | true |
705287aba95deb7242744d428b86a360a11d22fd | Python | nh2/cde-git-vortrag | /main.py | UTF-8 | 169 | 3.015625 | 3 | [] | no_license | #!/usr/bin/env python3
print("hello wonderful world!")
print("hello 2")
for i in range(10):
print(i)
print("hello 3")
print("this is the great new feature 4...")
| true |
8dbd5ab3a53ad239528056977b23e19d74b5b54c | Python | lisaylee/snippets | /snippets2.py | UTF-8 | 5,538 | 3.296875 | 3 | [] | no_license | import psycopg2
import logging # will allow you to track what happens in the application, and identify problems with the code
import argparse
import sys
# set the log output file, and the log level
logging.basicConfig(filename="snippets.log", level=logging.DEBUG)
logging.debug("Connecting to PostgreSQL")
# connect to... | true |
1e80cb51af38fdebf9246e997c0a32fc17533f37 | Python | A-Wagatsuma/mahjong | /Check_win.py | UTF-8 | 602 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env python
def int_2_tile(n):
if n < 10:
return(str(n) + 'm')
elif n < 20:
return(str(n-10) + 'p')
elif n < 30:
return(str(n-20) + 's')
else:
return(str(n-30) + 't')
def check_win(hist, index): #mode 0:pair mode 1:set
ret_tmp = []
##------------... | true |
6ebc534154b28a73ed2c5e17a42c03c0a40fa24f | Python | utunga/nga-kupu | /tests/test_functions.py | UTF-8 | 1,191 | 2.625 | 3 | [] | no_license | import context
from taumahi import *
def test_māori_word():
assert hihira_raupapa_kupu('kupu', True)
def test_māori_uppercase():
assert hihira_raupapa_kupu('KUPU', True)
def test_english_word():
assert not hihira_raupapa_kupu('mittens', True)
def test_tohutō():
assert hihira_raupapa_kupu('rōpū',... | true |
5a97f8fc4de23343ca31178e4d38feb5c5105c20 | Python | jasonbrackman/advent_of_code_2019 | /day_18.py | UTF-8 | 6,439 | 2.9375 | 3 | [] | no_license | from __future__ import annotations
import helpers
from collections import deque, namedtuple
from typing import NamedTuple, Optional, List, TypeVar, Callable, Tuple
from dataclasses import dataclass
class Pos(NamedTuple):
row: int
col: int
class Maze:
@classmethod
def load_object_data(cls, instructio... | true |
bd4bac046cac34f08ce48f55e7f227e516c0617a | Python | nguyenquangnhat1208/NguyenQuangNhat-fundamental-c4e27 | /Fundamentals/Session02/homework/turtle1.py | UTF-8 | 208 | 3.375 | 3 | [] | no_license | from turtle import *
shape("turtle")
color("red")
left(60)
for i in range(4):
for i in range(2):
forward(100)
left(60)
forward(100)
left(120)
left(90)
mainloop() | true |
e9cd911a9617c27894b69013a9fce5603b864c4c | Python | vcamilo/3sem | /sistema_atividades/sistema_atividades.py | UTF-8 | 4,144 | 2.765625 | 3 | [] | no_license | from flask import Flask,jsonify,abort
from flask import make_response, request, url_for
import acesso
app = Flask(__name__)
atividades = [
{
'id_atividade':1,
'id_disciplina':1,
'enunciado': 'crie um app de todo em flask',
'respostas': [
{'id_alun... | true |
7dc61198ea65fb1f692aaa842c590d3b9929981f | Python | lbr10/TIPE | /graph.py | UTF-8 | 339 | 3.046875 | 3 | [] | no_license | def graph() :
return []
def is_empty(graph) :
return graph == []
def add_vert(graph,list) :
n = len(graph)
graph.append(list)
for k in list :
graph[k].append(n)
return graph
def add_edge(graph,i,j) :
graph[i].append(j)
graph[j].append(i)
return graph
def adj(graph,i) :
... | true |
e5f5a66f5132d73c8b2c8f5a59c8f514b993a3dc | Python | PAULESAKKI/guvi | /code kata/adaM.py | UTF-8 | 136 | 3.265625 | 3 | [] | no_license | a=input()
b=a[::-1]
a=int(a)
c=a**2
b=int(b)
d=b**2
d=str(d)
f=d[::-1]
f=int(f)
if(c==f):
print("adam number")
else:
print("not")
| true |
6ca86892859f17d0f298aafe68831c8a62d07d74 | Python | rafaelgoncalvesmatos/estudandopython | /CodeCademy/Trocando_string.py | UTF-8 | 371 | 3.890625 | 4 | [] | no_license | #!/usr/bin/python
# *-* coding:latin1 *-*
pyg = 'ay'
original = raw_input('Entre com uma palavra: ')
word = original.lower()
first = word[0]
new_word = word + first + pyg
new_word = new_word[1:]
# Checando se o usuário colocou a palavra - isalpha falso caso o usuario digite numero
if len(original) > 0 and original.i... | true |
7c146a1e914ad1055a6049760af72b8730fe65c4 | Python | willRicard/MPSI-Info | /01_primes/primes_test.py | UTF-8 | 428 | 3.390625 | 3 | [
"MIT"
] | permissive | import unittest
from primes import *
class TestPrimes(unittest.TestCase):
def test_is_prime(self):
self.assertFalse(is_prime(1))
self.assertTrue(is_prime(2))
self.assertTrue(is_prime(29))
def test_next_prime(self):
self.assertEqual(next_prime(1), 2)
self.assertEqual(nex... | true |
360f4ad43214c2cb1bb74b37c76aa7a13702bf90 | Python | abdurrahmanregi/respy | /respy/likelihood.py | UTF-8 | 19,531 | 2.515625 | 3 | [
"MIT"
] | permissive | """Everything related to the estimation with maximum likelihood."""
import warnings
from functools import partial
import numba as nb
import numpy as np
from scipy import special
from respy.conditional_draws import create_draws_and_log_prob_wages
from respy.config import HUGE_FLOAT
from respy.pre_processing.data_check... | true |
a5a9e2c2bfa0aea4744f57dbc2f665e12c0d816b | Python | ConradMare890317/Python_Crash.course | /Chap10/pi_string.py | UTF-8 | 420 | 3.625 | 4 | [] | no_license | file_path = 'text_folder/pi_million_digits.txt'
with open(file_path) as file_object:
lines = file_object.readlines()
pi_string = ''
for line in lines:
pi_string += line.rstrip()
birthday = input("Enter your birthday, in the form of mmddyy: ")
if birthday in pi_string:
print("Your bithday appears in the first mill... | true |
03a67a6bb835ed0184ba8a74031e20a059dc38b4 | Python | austinsonger/CodingChallenges | /Hackerrank/_Contests/30 Days of Code/Day 08 - Dictionaries and Maps!/main.py | UTF-8 | 303 | 3.125 | 3 | [] | no_license | from collections import defaultdict
import sys
phone = defaultdict(str)
for _ in range(int(input())):
name = input()
phone[name] = input()
for line in sys.stdin:
name = line.strip()
if len(phone[name]) > 0:
print(name + "=" + phone[name])
else:
print("Not found")
| true |
c837847f0623e0cdd08435f704af7b9e915b26d8 | Python | rafaelperazzo/programacao-web | /moodledata/vpl_data/38/usersdata/110/13625/submittedfiles/decimal2bin.py | UTF-8 | 144 | 3.359375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
from __future__ import division
b=input('Digite número binário: ')
cont=0
n=b
while n>=1:
cont=cont+1
n=n/10
| true |
496f537f507ca86bd08cd70bad7d7d2540a090e7 | Python | GRCosta/vgp245 | /Final Project/TetrisMenu.py | UTF-8 | 1,173 | 2.90625 | 3 | [
"MIT"
] | permissive | import tkinter
import PIL.Image
import PIL.ImageTk
main = tkinter.Tk(className="#Tetris")
logo = tkinter.PhotoImage(file='tetrisCover.png')
label = tkinter.Label(main, compound = tkinter.CENTER, image = logo)
label.pack()
mframe = tkinter.Frame(main)
mframe.pack()
def clearwin(event=None):
'''Clear the main wi... | true |
7d211f1e6f6ad5b4a64567496ade03248285e525 | Python | arvindr9/competitive-programming | /Contests/Atcoder/ABC182/A.py | UTF-8 | 79 | 2.84375 | 3 | [] | no_license | a, b = list(map(int, input().split()))
mx = 2 * a + 100
ans = mx - b
print(ans) | true |
034083a8993038dad6af767940f4f22aa57b4c6d | Python | RobAkopov/IntroToPython | /Week2/Practical/Problem9.py | UTF-8 | 401 | 3.890625 | 4 | [] | no_license | import datetime, time, calendar
a = datetime.datetime.today()
b = datetime.date.today()
c = datetime.timedelta(days = 5)
print('Current date and time', a)
print('The value of the current year', b.year)
print('The value of the current month', b.month)
print('The value of the current day of the week', b.isoweekday... | true |
95fb986d64070e6491ffddb41ef85cf35568f6b0 | Python | grocer-of-despair/CheatSheets | /PythonCheatSheet.py | UTF-8 | 141 | 3.0625 | 3 | [] | no_license | try:
print (int(s))
except ValueError:
print "Error"
n**p = n to the power of p
if condition:
raise Exception("Error message")
| true |
d0575ee267801e8bfe9786a362c6ad705373ea06 | Python | mtreml/project-euler | /011_020/15.py | UTF-8 | 387 | 3.5 | 4 | [] | no_license | # Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.
#
# How many such routes are there through a 20×20 grid?
from scipy.special import comb
# The number of NE-lattice paths from (0,0) -> (n, k) is given by the Binom... | true |
3e2fa196a36903845577abd6b006ea44a350a23d | Python | Sundareshan98/sundareshan | /count.py | UTF-8 | 36 | 2.671875 | 3 | [] | no_license | a=list(input())
a1=len(a)
print(a1)
| true |
5ba839ded483f2f2237fe1cc19675866f020f384 | Python | ZanW/Python | /dictionary.py | UTF-8 | 272 | 3.234375 | 3 | [] | no_license | '''
Created on Aug 27, 2016
@author: Administrator
'''
classmates = {'lay': 'nice and helpful', 'han':'handsome and diligent', 'ke': "naughty and fond of play"}
print(classmates)
print(classmates['lay'])
'\n'
for k, v in classmates.items():
print(k+' '+v) | true |
7568d69d664117d456f5585f48cb8212fbd8de1b | Python | paepcke/kafka_bus_python | /src/kafka_bus_python/kafka_bus_utils.py | UTF-8 | 1,675 | 2.9375 | 3 | [] | no_license | '''
Created on May 31, 2015
@author: paepcke
'''
import cStringIO
import functools
import json
#----------------------------------- Extension to json.JSONEncoder -------------------
class _JSONEncoderBusExtended(json.JSONEncoder):
# Partial function to use by clients of this library
# when specifying t... | true |
415bdd1bb30c0c0c7345eb0112b44f76a3408989 | Python | kosiarka0/Rozszerzony-kurs-pythona-17-18 | /List4/zad2.py | UTF-8 | 723 | 3.390625 | 3 | [] | no_license | def paragraphs(stream):
last_sign = None
ret_str = ""
while True:
sign = stream.read(1)
if sign == "":
yield ret_str
return
if last_sign == "\n" and sign == "\n":
yield ret_str
last_sign = None
ret_str = ""
conti... | true |
ad310ec5cfbcc70d996c11e963f2ca9682cd5fbf | Python | manojtummala/Sathyabama-News-API | /scrapper.py | UTF-8 | 2,533 | 2.90625 | 3 | [] | no_license | import requests
from bs4 import BeautifulSoup
import re
class News:
@staticmethod
def getevents() :
response = {}
response['list'] = []
url = 'https://sathyabama.ac.in/events'
r = requests.get(url)
# print(r.content)
soup = BeautifulSoup(r.content, 'html5lib')... | true |
4524d171852ff5ccbe7c24694ec56c509b029709 | Python | weiminsong/lauztat | /lauztat/hypotests/discovery.py | UTF-8 | 1,500 | 2.515625 | 3 | [
"BSD-3-Clause"
] | permissive | from .hypotest import HypoTest
from scipy.stats import norm
from ..calculators import AsymptoticCalculator
from ..parameters import POI
class Discovery(HypoTest):
def __init__(self, poinull, calculator):
super(Discovery, self).__init__(poinull, calculator)
def result(self, printlevel=1):
"""... | true |
621022b00efe330447e4436cf543aff020311de0 | Python | GaspardVCS/AdventOfCode2020 | /day16.py | UTF-8 | 3,664 | 3.1875 | 3 | [] | no_license | # Data
def load_data():
f = open('/Users/macuser/Desktop/AdventOfCode/day16_input.txt', 'r')
l = f.read()
f.close()
category, ticket, nearby_tickets = l.split('\n\n')
category = category.split('\n')
# category
c = {}
for i in range(len(category)):
category[i] = category[i].repl... | true |
9c0bcbd03736e2af02d6c972648e4688bd86e156 | Python | victorkifer/ud120-intro-to-machine-learning | /svm/svm_author_id.py | UTF-8 | 1,349 | 3.09375 | 3 | [] | no_license | #!/usr/bin/python
"""
this is the code to accompany the Lesson 2 (SVM) mini-project
use an SVM to identify emails from the Enron corpus by their authors
Sara has label 0
Chris has label 1
"""
import sys
from time import time
sys.path.append("../tools/")
from email_preprocess import preproc... | true |
30709db17d97aaa7539754476f371c4dc37ac3e4 | Python | KashyapAdarsh/Sentiment_Analysis | /streamer.py | UTF-8 | 1,312 | 2.875 | 3 | [] | no_license | import sys
import tweepy
import json
consumer_key = 'CVUDTjqhfAD4FTWAt2PaJXUvv'
consumer_secret = 'RZtR7ugKaTIw8k8I1ww0fNKvPox2PVOlj4jhtKYHgHmKQxfL4C'
access_key = '797551482765770752-d16fT8KuByxp54wBfcT2BdAZkjuwCpQ'
access_secret = 'WRnHiYAUcpRVuF4vhG9SCw0lWJRqZ1CBpagyUqE26ddGG'
auth = tweepy.OAuthHandler(c... | true |
899aa4b1f2072b5989419067a5888777c412f4cd | Python | fBaz92/Cryptopals_solutions | /Sol1_3.py | UTF-8 | 4,357 | 3.421875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon Feb 24 22:19:27 2020
@author: franc
"""
def english_score_v2(presumable_plaintext):
'''
Parameters
----------
possible_plaintext : bytes
DESCRIPTION.
possible plaintext in byte
Returns
-------
score : float
DESCRIPTIO... | true |
c40bdd02f6b66473cbd20b5af7735c627de3c4f8 | Python | Yash-5/nn4nlp-asgn1 | /utils.py | UTF-8 | 3,790 | 2.515625 | 3 | [] | no_license | import gzip
import numpy as np
from tqdm import tqdm
from collections import defaultdict, Counter
import random
import mimetypes
label2index = defaultdict(lambda: len(label2index))
word2index = defaultdict(lambda: len(word2index))
word2index["<UNK>"] # Putting UNK to 0
def save_bin_vec(vocab, fname, save_name):
k... | true |
c35b6be187a98372a3e1c23854342a5954b92d17 | Python | marchowardbegins/quasar_source | /database_api/nosql_databases/mongodb_api.py | UTF-8 | 5,948 | 2.828125 | 3 | [
"MIT"
] | permissive | # coding=utf-8
"""This module, mongodb_api.py, is a simple interface to using a MongoDB database."""
# Python library for accessing MongoDB.
import pymongo
from universal_code import path_manager as pm
from universal_code import useful_file_operations as ufo
# MongoDB Data Types and Corresponding ID number.
data_ty... | true |
b2c716b7d5ff9f2480c1815218af26a500f151d7 | Python | sprdave/CS50-2021 | /Week_9/finance/portfolio/test_portfolio.py | UTF-8 | 2,971 | 2.796875 | 3 | [] | no_license | import pytest
import sqlite3
from mock import patch
from dataclasses import asdict, dataclass
from portfolio import get_shares_info, fill_qty, get_company_and_price, Share
from app_config import CMP_NOT_FOUND
@dataclass(order=True)
class Share:
symbol: str
company_name: str
qty: int
price: float
to... | true |
3d395a6b72c772a207e8ce4925784758bbc8e9dd | Python | jeremypress-old/projecteuler | /EulerTools.py | UTF-8 | 1,285 | 3.59375 | 4 | [] | no_license | import math
def isPrime(x):
if (x == 2):
return True
elif (x % 2) == 0:
return False
counter = 3
while counter <= math.sqrt(x):
if x % counter == 0:
return False
counter += 2
return True
def isPalindrone(x):
number = str(x)
if len(number) % 2 == 0: #even
divAmount = len(number)//2
else:
divAmou... | true |
f02fb873ded113a4a3f0a8997897d70055a0e963 | Python | wsinbol/DataStructure | /Array/findErrorNums.py | UTF-8 | 1,854 | 4.34375 | 4 | [] | no_license |
'''
给一个长度为 N 的数组 nums,其中本来装着 [1..N] 这 N 个元素,无序。但是现在出现了一些错误,nums 中的一个元素出现了重复,也就同时导致了另一个元素的缺失。请你写一个算法,找到 nums 中的重复元素和缺失元素的值。
总结:
对于这种数组问题,关键点在于元素和索引是成对儿出现的,常用的方法是排序、异或、映射。
映射的思路就是我们刚才的分析,将每个索引和元素映射起来,通过正负号记录某个元素是否被映射。
排序的方法也很好理解,对于这个问题,可以想象如果元素都被从小到大排序,如果发现索引对应的元素如果不相符,就可以找到重复和缺失的元素。
异或运算也是常用的,因为异或性质 a ^ a = 0, a... | true |
c773ae4038afc6e308229664fe4618add0c9f605 | Python | SimpleDrunk/pythonchallenge | /19/19.py | UTF-8 | 442 | 2.6875 | 3 | [] | no_license | # http://www.pythonchallenge.com/pc/hex/bin.html
# butter fly
# import base64
#
# text = open('./19att.txt', 'r').read()
# indian = open('indian.wav', 'wb')
# wav = base64.b64decode(text)
# indian.write(wav)
# indian.close()
import wave
wi = wave.open('indian.wav', 'rb')
wo = wave.open('indian_out.wav', 'wb')
wo.se... | true |
75e5f101037e1d78f3cbefe2c49f84cc93b81821 | Python | quasipedia/ants | /stats.py | UTF-8 | 3,285 | 2.8125 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Contest entry for the Fall 2011 challenge on http://aichallenge.org
This file contains a visualiser for log and profile information. It is not
part of the uploaded package. It is a devel's tool.
Some information on the format of the log file:
- Each line of data tha... | true |
fa907d0e8bcbc2592c45eda8dbcec6457203e3c5 | Python | stevenweaver/projectrobo | /code/beagleboard/tests/object_in_way.py | UTF-8 | 6,248 | 2.75 | 3 | [] | no_license | #Import the modules we need
import setup
import motor
import avoidance
import beacon
import compass
import path_find
import comm
from defines import *
import time
import math
#main loop
def main():
#initialization, our huge lists of information
ser = comm.comm()
sensor_data = []
gps_list = []
rs... | true |
7d21ef31d7a79427971dc9908eb6e188e1a74615 | Python | grazder/HSE-SPb-RL | /HW4. DDPG/agent.py | UTF-8 | 1,026 | 2.5625 | 3 | [] | no_license | from collections import deque
import numpy as np
import torch
from torch import nn
from torch.nn import functional as F
from torch.optim import Adam
import random
import copy
DEVICE = 'cpu'
class Actor(nn.Module):
def __init__(self, state_dim, action_dim):
super().__init__()
self.model = nn.Sequen... | true |
e48bdd834bc5235de2a0c16d6961adcffb150c74 | Python | H56/Chat | /test.py | UTF-8 | 1,412 | 2.640625 | 3 | [] | no_license | import sys
import select
import threading
from time import sleep
import termios
import tty
import thread
class iter_test:
def __init__(self):
self.data = [1, 2, 3, 4]
self.index = 0
pass
def __iter__(self):
self.data_next = self.data.__iter__()
return ... | true |
7495a879e96e5128d35d52b31d43a39f9adc1f7e | Python | makerbot/mw-scons-tools | /log.py | UTF-8 | 1,301 | 2.5625 | 3 | [] | no_license |
_error = 'error'
_warning = 'warning'
_spam = 'spam'
# Set up command line args used by every scons script
def common_arguments(env):
env.MBAddOption(
'--log-level',
dest='log_level',
metavar='LEVEL',
type='string',
action='store',
default=_warning,
help='Se... | true |
52b52026f60f4d93b3c1d192a91d99bf28fff137 | Python | rpytel1/clickbait-challenge | /ml/AdaBoost/random_search.py | UTF-8 | 1,124 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | import pickle
from sklearn.ensemble import AdaBoostRegressor
from sklearn.metrics import make_scorer, mean_squared_error
from sklearn.model_selection import RandomizedSearchCV, StratifiedShuffleSplit
def rf_randomized_search(X, y):
mse_scorer = make_scorer(mean_squared_error)
# Create the random grid
pa... | true |
c1bf93814d52d9bd5631a10b85ce3afaa1fa1ba1 | Python | u-t-autonomous/sydar | /sydar/cvx_gen.py | UTF-8 | 6,672 | 2.625 | 3 | [
"BSD-3-Clause"
] | permissive | """
.. module:: cvx_gen
:platform: Unix
:synopsis:
.. moduleauthor:: Mohammed Alshiekh
"""
from region import *
def tree_leaf_count(tree):
"""
This function takes a tree and returns its number of leaf.
"""
n = 0
if isinstance(tree,Workspace):
return 0
elif isinstance(tree,Ter... | true |
4e46519f56d407b493036278c4d8c4a9d0612d36 | Python | jorgepdsML/DIGITAL-IMAGE-PROCESSING-PYTHON | /CLASE5_PYTHON/PROYECTO_ARDUINO_PYTHON.py | UTF-8 | 1,286 | 3.40625 | 3 | [] | no_license | #uso de la comunicación serial
import serial
#importar todo del modulo tkinter
from tkinter import *
#arduino=serial.Serial()
#Crear objeto serial
arduino=serial.Serial()
# definir atributo baudrate
arduino.baudrate = 9600
arduino.port = "COM8"
#intentar conectarse al objeto serial
try :
#INICIAR COMUNI... | true |
f5e966794fbce088674f4a1c2d03463cf5bc97a8 | Python | nopilei/courses | /api/utils/base_viewsets.py | UTF-8 | 2,740 | 2.78125 | 3 | [] | no_license | """
Provides superclasses for project ViewSet classes
We can see some kind of hierarchy between project models. Lecture can attached to Course, Hometask - to Lecture,
FinishedTask - to Hometask, Comment - to FinishedTask. In other words:
Course <- Lecture
Lecture <- Hometask
Hometask <- FinishedTask
FinishedTask <- C... | true |
207844593dd5737a606157724bdc84c657d97700 | Python | sergiogarver/busquedasFSI | /run.py | UTF-8 | 937 | 3.171875 | 3 | [] | no_license | # Search methods
import search
ab = search.GPSProblem('A', 'B', search.romania)
ea = search.GPSProblem('E', 'A', search.romania)
ld = search.GPSProblem('L', 'D', search.romania)
#print search.breadth_first_graph_search(ab).path()
#print search.depth_first_graph_search(ab).path()
#print search.iterative_deepening_s... | true |
7f7328772cf28b27855c7b72d2f0fa2b7640b699 | Python | jhuang739/180DA-WarmUp | /serverTest.py | UTF-8 | 515 | 2.890625 | 3 | [] | no_license | import socket
# add TCP/IP protocol to the endpoint
serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# assign a port for the server that listens to clients connecting to the port
serv.bind(('0.0.0.0', 8080))
serv.listen(5)
while True:
conn, addr = serv.accept()
from_client = ''
while True:
... | true |
025bb5051b761b5752815da76acf79ac661af2be | Python | daniel-reich/ubiquitous-fiesta | /pmYNSpKyijrq2i5nu_11.py | UTF-8 | 1,119 | 2.765625 | 3 | [] | no_license |
def darts_solver(sections, darts, target):
p,q=[],[]
if darts == 3:
for a in sections:
for b in sections:
for c in sections:
if (a + b + c)== target:
z=[]
z.append(a)
z.append... | true |
0479af93bcbfa1ad9f83c080e328cda8abcedd91 | Python | wojiaolds/python-test | /pandas_test/series.py | UTF-8 | 1,287 | 3.828125 | 4 | [] | no_license | import pandas as pd
import numpy as np
s = pd.Series()
print(s) # 空系列
print('----'*10)
data = np.array(['a', 'b', 'c', 'd'])
s = pd.Series(data)
print(s)
print('----'*10)
data = np.array(['a','b','c','d'])
s = pd.Series(data,index=[100,101,102,103])
print(s)
print('----'*10)
df = pd.DataFrame(s.values,index=s.inde... | true |