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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
34afc486703912cd9df92e0583f0a6d3297eac10 | Python | kierangoodson/210CT--Programming-Coursework | /Week 1/1. [WEEK 1] Shuffling Arrays.py | UTF-8 | 623 | 4.6875 | 5 | [] | no_license | def shuffleArray():
'''A function that randomly shuffles an array. The function takes a random element from
the array and swaps it's position with the element in index 0. It does this for every number in
the array.'''
array = [1,2,3,4,5,6,7,8]
print("The original array: ",array)
import random
for i... | true |
1e0e8861defeac70ccc1461834e398c11ea0cf3b | Python | Pratyaksh7/Algorithmic-Toolbox | /week 2/fibonacci.py | UTF-8 | 227 | 3.609375 | 4 | [] | no_license | # Uses python3
def calc_fib(n):
arr = [1] * n
result = [0, 1, 1]
for i in range(2, n):
arr[i] = arr[i-1] + arr[i-2]
result.append(arr[i])
return result[n]
n = int(input())
print(calc_fib(n))
| true |
9726f2bd13758c79542664f542cd98986c07dc78 | Python | Mpolozov/GeographyScraper | /CoordBot.py | UTF-8 | 592 | 3.0625 | 3 | [] | no_license | from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
def CoordBot(url):
PATH = "/Users/mitchellpolozov/Downloads/chromedriver"
driver = webdriver.Chrome(PATH)
driver.get(url)
search_bar = driver.find_element_by_name('q')
search_bar.clear()
time.sleep(5)
... | true |
4508c69d67159530fb0b8fe5f3e761c3e272e585 | Python | benk691/HomeProjects | /Budget/MoneyManager.py | UTF-8 | 4,897 | 3.15625 | 3 | [] | no_license | from decimal import Decimal
from AllocationManager import AllocationManager
from General.Common import WarningMsg, InfoMsg, DebugMsg, TWOPLACES, setContext, DEBT_KEY, EXTRA_KEY
class MoneyManager:
def __init__(self, moneyPath, allocationPath, savingsPath):
setContext()
self._moneyPath = moneyPath
self._savingsP... | true |
be82fc2a2b228552ba73955b02788c0267997daf | Python | zybine/NeutronRadiation | /python files/Water Activation.py | UTF-8 | 837 | 2.703125 | 3 | [] | no_license | # reads in a g4beamline output TEXT file, and plots the number of protons at each z vs distance
import pandas as pd
import os
NEURTRON_PDGid = 2112
PROTON_PDGid = 2212
GAMMA_PDGid = 22
directory = "./data/WaterActivation/"
f_header = ["x", "y", "z", "Px", "Py", "Pz", "t", "PDGid", "EventID", "TrackID", "ParentID", "W... | true |
309420fa7f4de5a2aef34fc504f29944b123fe95 | Python | grehujt/SmallPythonProjects | /CdfDrawing/cdf.py | UTF-8 | 300 | 2.921875 | 3 | [
"MIT"
] | permissive |
import numpy as np
import matplotlib.pyplot as plt
def draw_cdf():
data = np.loadtxt('err.txt')
x = np.sort(data)
y = np.arange(len(x)) / float(len(x)-1)
plt.plot(x, y, label='some text')
plt.grid()
plt.legend()
plt.xlabel('estimated error')
plt.savefig('cdf.png')
| true |
5def4a0a09ea516fd46d317b9d285fbfc3dcfd6e | Python | Dualve/Simple-Tasks | /number_e.py | UTF-8 | 318 | 2.984375 | 3 | [] | no_license | number_e_list = list("2.7182818284590452353602875")
exp = int(input())
if exp == 25:
print("".join(number_e_list))
elif exp == 0:
print(3)
else:
if int(number_e_list[exp+2]) >= 5:
number_e_list[exp+1] = str(int(number_e_list[exp+1])+1)
print("".join(number_e_list[:exp+2]))
| true |
34670824db2e5c45f7aa31288fe013c7fab6d384 | Python | ojwills/MIT-6.00.1x-Intro-to-CS-and-Python | /Final_Exam/Problem_3.py | UTF-8 | 1,491 | 4.65625 | 5 | [] | no_license | # Problem 3
# 10/10 points (graded)
# Numbers in Mandarin follow 3 simple rules.
# There are words for each of the digits from 0 to 10.
# For numbers 11-19, the number is pronounced as "ten digit", so for example, 16 would be pronounced (using Mandarin) as "ten six".
# For numbers between 20 and 99, the number i... | true |
edaa04cb74074cd698ba118865401e26de212cbe | Python | kristelsamoy/minichiello.py | /20gen.py | UTF-8 | 1,723 | 3.296875 | 3 | [] | no_license | from tkinter import *
from tkinter import filedialog
def browseFiles():
filename = filedialog.askopenfilename(initialdir = "/", title = "Select a File", filetypes = (("Text files", ".txt"), ("all files", ".")))
label_file_explorer.configure(text="File aperto: "+filename)
def crea_grafico():
import str... | true |
e8477d4467ac387e710ab56caa28556010e456dc | Python | art-vasilyev/instachatbot | /tests/test_bot.py | UTF-8 | 7,774 | 2.515625 | 3 | [
"MIT"
] | permissive | from instachatbot.bot import InstagramChatBot
from instachatbot.nodes import (
MenuNode, MenuItem, MessageNode, QuestionnaireNode, DummyNode,
NotifyAdminNode)
class FakeBot(InstagramChatBot):
def __init__(self, menu, storage=None, trigger=None):
super(FakeBot, self).__init__(menu, storage=storage,... | true |
e9ef333962a5dc4f2d0988bd05f4230dc7fca2f7 | Python | kylemsguy/creepy-octo-lamp | /linkfixer.py | UTF-8 | 1,083 | 2.84375 | 3 | [] | no_license | from html.parser import HTMLParser
class LinkHTMLParser(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)
self.tags_src = ("img", "bgsound", "embed", "iframe", "script", "input")
self.tags_href = ("a", "link", "area")
self.tags_misc = {"body":("background"), "form":("action"), "object":("data"),
... | true |
57ae95d062e9d75dbbc5d14109859e0af50428dd | Python | AuFeld/cs-module-project-algorithms | /moving_zeroes/moving_zeroes.py | UTF-8 | 577 | 4.1875 | 4 | [] | no_license | '''
Input: a List of integers
Returns: a List of integers
'''
def moving_zeroes(arr):
# create zeroes array with len(arr)
moved_zeroes = [0] * len(arr)
i = 0
# loop through array
for k in range(len(arr)):
# if element is non-zero, overwrite from left
if arr[k] != 0:
mov... | true |
bdea3adbc4562843c7a6229d02c1cc0961a0e27e | Python | chyidl/leetcode | /0022-generate-parentheses/generate-parentheses.py | UTF-8 | 946 | 3.96875 | 4 | [
"MIT"
] | permissive | # Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
#
#
# Example 1:
# Input: n = 3
# Output: ["((()))","(()())","(())()","()(())","()()()"]
# Example 2:
# Input: n = 1
# Output: ["()"]
#
#
# Constraints:
#
#
# 1 <= n <= 8
#
#
class Solution:
def generate... | true |
7ed8c3d2a8474d146b6ebcc4f1005d12e9cd0518 | Python | jainamshroff/SnakeWaterGunGame---Python-Exercise | /main.py | UTF-8 | 2,706 | 4.34375 | 4 | [] | no_license | # Snake Water Gun Game
import random
print("Starting Snake Water Gun, 10 Rounds Per Game, One with Max Score Wins")
print("At Any Point Press 9 To exit")
computerScore = 0 # Score Handler For Computer Player
humanScore = 0 # Score Handler For Human Player
bool = True
round = 10
while(bool == True):
... | true |
1abefd0c761380f35411f2a0f45972df1ff3c79d | Python | Aasthaengg/IBMdataset | /Python_codes/p03048/s219553898.py | UTF-8 | 320 | 2.734375 | 3 | [] | no_license | R,G,B,N = (int(x) for x in input().split())
maxr = N // R
maxg = N // G
count = 0
for i in range(maxr+1):
for j in range(maxg+1):
checker = N - (i*R + j*G)
if checker // B >= 0:
if checker % B == 0:
count += 1
elif checker == 0:
count += 1
print(count) | true |
ab9f7326541ccfb3999adbf3b7898d66a56d535f | Python | kitkat-24/AdventOfCode2020 | /day09/script.py | UTF-8 | 2,984 | 4.15625 | 4 | [] | no_license | import itertools
def read_data(file):
with open(f'day09/{file}') as f:
nums = []
for line in f:
nums.append(int(line))
return nums
def validate(nums, n):
# For a list of integers and a preamble of length n, this function checks
# all numbers to see whether they follow the... | true |
404e8c42ec354ec0e88ad6f9657ca9c0618d415b | Python | nsbgit/IIT-S21-CS-484 | /Old Materials/Additional Github/dvtate/cs484/in-class/Week 2 Nearest Neighbors Unsupervised.py | UTF-8 | 2,087 | 3.171875 | 3 | [
"MIT"
] | permissive | # Load the necessary libraries
import numpy
import pandas
from sklearn.neighbors import NearestNeighbors as kNN
cars = pandas.read_csv('cars.csv', delimiter=',')
cars["CaseID"] = cars["Make"] + "_" + cars.index.values.astype(str)
cars_wIndex = cars.set_index("CaseID")
# Specify the kNN
kNNSpec = kNN(n_neighbors = 4... | true |
248ef64ee2f9817df2b182c1599333af1aa0157e | Python | PasaLab/forestlayer | /forestlayer/layers/factory.py | UTF-8 | 2,605 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | # -*- coding:utf-8 -*-
"""
Factory methods to Layers.
"""
# Copyright 2017 Authors NJU PASA BigData Laboratory.
# Authors: Qiu Hu <huqiu00#163.com>
# License: Apache-2.0
from .layer import PoolingLayer
from ..estimators.estimator_configs import ExtraRandomForestConfig, RandomForestConfig
from .window import Window, P... | true |
e336303c212c02b28486a2017ea231a516d1a917 | Python | sinemelifhaseki/ROS-Kinetic-Robotics | /shape_color_detection/roboroach/src/camera_test.py | UTF-8 | 5,224 | 2.609375 | 3 | [
"MIT"
] | permissive | import rospy
import sys
from sensor_msgs.msg import Image, LaserScan
import matplotlib.pyplot as plt
import time
import numpy as np
import cv2
import base64
from geometry_msgs.msg import PoseStamped
print("**************************HELLO I AM ROBOROACH!**************************")
print("********************I WILL FIN... | true |
07e4329aa3e3b054fa4863226abf6e4df4377448 | Python | alunfes/bybit-bot2 | /AccountConverter.py | UTF-8 | 802 | 2.53125 | 3 | [] | no_license |
from Bot import Bot
from SimAccount import SimAccount
from BotAccount import BotAccount
class AccountConverter:
'''
'''
@classmethod
def convert_bot_account(cls):
sim_ac = SimAccount()
hd = BotAccount.get_holding_data()
if hd['side'] != '':
sim_ac.holding_side = hd[... | true |
cbb35a9d2f06e4629b131a9079e434702fc3cd0b | Python | blairg23/Particle-Simulator | /examples/bouncingBall.py | UTF-8 | 3,263 | 3.4375 | 3 | [] | no_license | # This script animates a bouncing ball using OpenGL.
# Written by Glen Granzow on November 11, 2011.
# Modified by Glen Granzow on November 18, 2011.
from OpenGL.GL import *
from OpenGL.GLUT import *
#### Reshape Call-back Function ####
def reshape(width, height):
glViewport(0,0,width,height)
glMatrixMode(GL_... | true |
a96187e2aa25b50d4dc89ff3c7e3ce81945f7131 | Python | khrogos/pelican-gui | /main.py | UTF-8 | 11,343 | 2.875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/python
# coding: utf-8
# TODO :
# delete draft if saved as published
# use pelicanconf to more flexible paramters
# config file with default pelican blog
#
import Tkinter as tk
import ScrolledText
import tkFileDialog
import os
import getpass
import subprocess
import ttk
class MainApplication(tk.Frame):
... | true |
e6a49bff09a81bf8fe2c26bf78eb1ba8176b18ea | Python | MrHamdulay/csc3-capstone | /examples/data/Assignment_2/kngtho005/question2.py | UTF-8 | 2,810 | 4.0625 | 4 | [] | no_license | # question2
# a program to decide whether to eat a cupcake that has fallen on the floor
# Thomas Konigkramer
# 8 March 2014
# introduction to what the program does
print("Welcome to the 30 Second Rule Expert")
print("------------------------------------")
print("Answer the following questions by selecting from... | true |
8f2553d34ca2ca5d8c3ed55906dcd90dd10df64a | Python | jaisanant0/face-recognition | /encode-faces.py | UTF-8 | 2,191 | 2.859375 | 3 | [
"MIT"
] | permissive | # network architecture for face recognition is based on ResNet-34.
# the network is trained by Davis King on LFW having 99.38% accuracy.
import face_recognition
import os
import glob
import argparse
import cv2
import csv
import pandas as pd
import numpy as np
# command line argument
parser = argparse.ArgumentParser()
... | true |
262ab6787492a2da14fc5ad66ece10617b7eb7ea | Python | vbakhteev/segmentation_pipeline | /models/utils.py | UTF-8 | 4,198 | 2.5625 | 3 | [] | no_license | import torch
from torch import nn
def get_layers_by_dim(n_dim: int) -> dict:
assert n_dim in (1, 2, 3)
layers = {
"batch_norm": (nn.BatchNorm1d, nn.BatchNorm2d, nn.BatchNorm3d),
"conv": (nn.Conv1d, nn.Conv2d, nn.Conv3d),
"conv_transpose": (nn.ConvTranspose1d, nn.ConvTranspose2d, nn.Co... | true |
8e508bac431ae10afe67d37641f7f94ac65a9c30 | Python | OpenReader/LeetCode | /Python3/304_Range_Sum_Query_2D_-_Immutable.py | UTF-8 | 1,221 | 3.421875 | 3 | [] | no_license | class NumMatrix:
def __init__(self, matrix: List[List[int]]):
m = len(matrix)
if m == 0:
return
n = len(matrix[0])
if n == 0:
return
self.acc = [[0] * n for _ in range(m)]
self.acc[0][0] = matrix[0][0]
# init first row
for j in... | true |
35c0966fc9b30fffa4f3dab40528d240aaba3358 | Python | jasonfangmagic/Python_Basics | /basics.py | UTF-8 | 3,502 | 4.03125 | 4 | [] | no_license | #Input
print("Hello what's your name")
name = input()
print("Hello,", name)
#operator
num1 = 34
num2 = 3
#only have integer
print(num1 // num2)
#only residual
print(num1 % num2)
#expotion
print(num1 ** num2)
#convert numbers
print("pick a number")
num1 = input()
print("pick another number")
num2 = input()
su... | true |
9c889a43972bb4b37157a1cd5f1386787f489e84 | Python | indrajitbarve/riptide | /riptide/running_median.py | UTF-8 | 2,746 | 3.4375 | 3 | [
"MIT"
] | permissive | import numpy
from bisect import insort, bisect_left
def running_median(data, width):
if not width % 2:
raise ValueError("width must be an odd number")
l = width * [data[0]]
mididx = (width - 1) // 2
result = numpy.zeros_like(data)
for idx, new_elem in enumerate(data):
old_elem = da... | true |
ad60d463d92c5c4331bf7704bc512ba855b03d1c | Python | SupakornNetsuwan/Prepro64 | /test14.py | UTF-8 | 147 | 3.296875 | 3 | [] | no_license | """Func"""
def func():
"""Modulo func"""
base = int(input())
modulo = int(input())
print(base - (modulo * (base//modulo)))
func()
| true |
1c70a5ebb62420b9cb48e909561d293c1d681df8 | Python | zh1047592355/ApiAutoTest | /day05/test_001.py | UTF-8 | 2,004 | 2.953125 | 3 | [] | no_license | '''
mock
1.接口测试的测试场景比较难模拟,需要大量的工作才能做好
2.该接口的测试,依赖其他模块的接口,依赖的接口尚未开发完成
测试条件不充分,怎么开展接口测试
使用mock模拟接口的返回值
'''
import requests
from unittest import mock
'''
支付接口:http://www.zhifu.com/
方法:post
参数:{"订单号":“12345”,"支付金额":20.56,"支付方式":"支付宝/微信/余额宝/银行卡"}
返回值:{"code":200,"msg":"支付成功"}、{"code":201,"msg":"支付失败"}
接口尚未实现
'''
class Pay... | true |
925b760986df857a6881421bb112cb27bc94920f | Python | scande3/Tic-Tac-Toe | /tictactoe/game/tests.py | UTF-8 | 10,902 | 2.609375 | 3 | [] | no_license | import logging
from django.test import TestCase
from django.http import HttpRequest
from django.conf import settings
from django.core.urlresolvers import reverse
from django.test import Client
from tictactoe.game.models import TicTacToeModel
class GameViewsTest(TestCase):
def test_index(self):
"""
... | true |
5456a633cba7d6d42ec507dbb32356e1b558af07 | Python | Bapan0814036/2nd-repository | /staticvar1.py | UTF-8 | 223 | 2.75 | 3 | [] | no_license | class A:
var="hello"
def __init__(self,a):
self.a=a
if __name__=="__main__":
a=A(12)
print(a.__dict__)
print(a.var)
print(a.__dict__)
a.var=24
print(a.__dict__)
print(A.var) | true |
4b878664cb8abc9967c4ebfbb0b01156ff5ffe22 | Python | michealtianlan/cloudtask | /cmd_destroy_workers.py | UTF-8 | 2,643 | 2.625 | 3 | [] | no_license | #!/usr/bin/env python
#
# Copyright (c) 2010-2012 Liraz Siri <liraz@turnkeylinux.org>
#
# This file is part of CloudTask.
#
# CloudTask is open source software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version ... | true |
2b971d7a5b6a058da77074d7b0c58feccd6e9bc9 | Python | callmepr/Discord-chatbot | /bot.py | UTF-8 | 1,564 | 2.8125 | 3 | [] | no_license | import discord
token="NwijinnNIOMiiomdwfoihSDFwqwfohFw"#---enter your token id here--#
client=discord.Client()
@client.event
async def on_member_join(member):
for channel in member.server.channels:
if str(channel)=='general':
await client.send_message(f"""welcome to the server {member... | true |
daa0f622cc999a11f9b6e78ef2e84eea8f6d5445 | Python | alder711/linux-dotfiles | /GENTOO/dotfiles/bin/conky_rss.py | UTF-8 | 364 | 2.953125 | 3 | [] | no_license | #!/usr/bin/env python3
# This script takes an RSS feed and outputs
# the results.
# imports
import feedparser
# VARIABLES
RSS_SITE = "https://security.gentoo.org/glsa/feed.rss" #'.rss' URL to get feed from
# parse feed
feed = feedparser.parse(RSS_SITE)
# print feed title
#print(feed['feed']['title'])
# print fir... | true |
16ab377f265325b0dcfc6a1ac5a5a310357c06ef | Python | hilsabeckt/auto-ERT | /classes.py | UTF-8 | 12,173 | 2.625 | 3 | [] | no_license | class Raid:
def __init__(self):
self.team = {}
self.roles = [0,0,0]
def add(self,player):
if isinstance(player,list):
for p in player:
self.add(p)
return
if player.spec in self.team:
speclist = self... | true |
ddb780a5457e03654a530f299225a991a2112ca4 | Python | dalaAM/month-01 | /day04_all/day04/exercise03.py | UTF-8 | 554 | 4 | 4 | [] | no_license | """
累加0 1 2 3 4 5 6 7 8
累加3 4 5 6 7 8 9 10
累加2 4 6 8 10 12
累加8 7 6 5 4 3
累加-1 -2 -3 -4 -5 -6
"""
# 循环前 ... 创建
count = 0
for item in range(9):
count += item # 循环中 ... 累加
print(count) # 循环后 ... 结果
count = 0
for item in range(3, 11):
count += item
print(count)
count = 0
for item in range(2,... | true |
2498febd9107d5f40c528a1f1ec5eea755c74e00 | Python | anumoshsad/Algorithmic_Toolbox_Coursera_UCSD | /Assignment_2/fractional_knapsack/fractional_knapsack.py | UTF-8 | 970 | 3.359375 | 3 | [] | no_license | # Uses python3
import sys
def get_optimal_value(capacity, weights, values):
value = 0.
# write your code here
value_per_weight = [x/y for (x,y) in zip( values, weights)]
weights = [ x for (y,x) in sorted(zip(value_per_weight, weights))][::-1]
values = [ x for (y,x) in sorted(zip(value_per_weight, v... | true |
b6a8a0a600101c4287ff9f42606db8b9cda00159 | Python | RiddhiRex/Leetcode | /Add One Row to Tree.py | UTF-8 | 1,554 | 3.34375 | 3 | [] | no_license | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def traverse(self, node, v, d, curd):
if(node is not None):
if(curd==d-1):
if(node.l... | true |
fe3645b4cec318da77ed402df36c1f382cb5c08c | Python | paletteOvO/LeetCode | /lc409.py | UTF-8 | 275 | 2.5625 | 3 | [] | no_license | class Solution(object):
def longestPalindrome(self, s):
"""
:type s: str
:rtype: int
"""
k = collections.Counter(s).values()
return sum([x // 2 * 2 for x in k]) + \
(1 if any([x % 2 == 1 for x in k]) else 0) | true |
d139256b510b6d543ec14470139a255505a10288 | Python | MarcusPeixe/marvin | /python/poesiaVogon/fase05/ex08/soletrar.py | UTF-8 | 90 | 2.5625 | 3 | [] | no_license | def soletrar(string):
array = [];
for i in string:
array.append(i);
return array; | true |
6d0ab2969b3c8a94bd2f0b040c9517cfd5e8688f | Python | Suvrojyoti/APS-2020 | /Codeforces_Submissions/1113B.py | UTF-8 | 1,099 | 3.328125 | 3 | [] | no_license | import math
# method to print the divisors
def printDivisors(n) :
lol=[]
# Note that this loop runs till square root
i = 1
while i <= math.sqrt(n):
if (n % i == 0) :
# If divisors are equal, print only one
if (n / i == i) :
... | true |
39caecba45e7eba770a211cc53cd7a40a4fe9e7e | Python | vtheno/lang | /Lex.py | UTF-8 | 3,103 | 3.078125 | 3 | [] | no_license | #coding=utf-8
# add lex support float number
class Ident(object):
def __init__(self,sym):
self.sym = sym
def __repr__(self):
return f"id{ {self.sym} }"
class GetNextTokenErr(Exception) : pass
class Lex(object):
def __init__(self,spectab,keywords,separators):
self.spectab = spectab ... | true |
92064c618d7b9d7e77b51a1eca4ac1e28be68c19 | Python | kusum95/Elastic_Application | /AppTier/appInstance.py | UTF-8 | 5,203 | 2.84375 | 3 | [] | no_license | import schedule
import subprocess
import boto3
import json
import botocore
import os
import time
INPUT_BUCKET_NAME='cse546-input-p1' #input s3 bucket to download images for classifier
OUTPUT_BUCKET_NAME='cse546-output-p1' #output s3 bucket to store results
# schedule a job to check for any messages availab... | true |
63c4ae18d1dd1479b1e3684adad4d714bb3de60b | Python | mccullerlp/python-declarative | /test/test_properties.py | UTF-8 | 1,393 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Test of the argparse library
TODO: use automated features
"""
from __future__ import (division, print_function, absolute_import)
from declarative import (
OverridableObject,
mproperty,
NOARG,
)
oldprint = print
print_test_list = []
def print(*args):
... | true |
f767b17b3eb135ea2719b899685611267f4136df | Python | KeithDinh/Coding-Interview-Practices | /LeetCode/C#/Medium/Maximum DIfference Between Node and Ancestor.py | UTF-8 | 1,344 | 3.265625 | 3 | [] | no_license | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def maxAncestorDiff(self, root: TreeNode) -> int:
if not root:
return 0
diff =[0... | true |
238f4f3778e1b52b275bf3ffdf9aee029492d569 | Python | askdjango/snu-web-2016-09 | /class-20160928/report/박정훈_경영/a1_1.py | UTF-8 | 356 | 3.75 | 4 | [] | no_license | number = int(input("출력하고자 하는 구구단의 숫자를 입력하세요. 1단부터 9단까지 가능합니다. : "))
while number < 1 or number > 9 :
number = int(input("1단부터 9단까지만 출력가능합니다. 1 이상 9이하의 숫자를 입력하세요."))
for x in range (1,10) :
print(number, 'x',x,'=',number*x)
| true |
cfa9f38bb40feebe2d368689af2ac90bb73abf0f | Python | lostmarinero/slcsp | /rate_helpers.py | UTF-8 | 2,216 | 3.390625 | 3 | [] | no_license | from helpers import isfloat
def pull_unique_rate_silver_plans(plan_list):
'''
This function pulls all plans with a meta level of 'Silver' from a list of
plans and removes any silver plans with the same 'rate'
'''
seen = set()
return [x for x in plan_list
if (
x['met... | true |
86a7205c581ec5c92e225979556ecc10dfa1fc2b | Python | arianaolson419/AccessibleCooking | /app/helper_functions/conversions.py | UTF-8 | 11,444 | 2.53125 | 3 | [] | no_license | from flask_mongoalchemy import *
from bson.objectid import *
from app.helper_functions.media import video_id_from_url
from app.document_models.recipe_documents import Recipe
from app.document_models.tip_documents import Tip
from app.document_models.object_documents import Instruction, Ingredient, Equipment
import logg... | true |
f35d4b9b890b0624c06fbcd32411500750c6c41e | Python | shihyuuuuuuu/LeetCode_practice | /prob1282.py | UTF-8 | 316 | 2.703125 | 3 | [] | no_license | class Solution:
def groupThePeople(self, groupSizes: List[int]) -> List[List[int]]:
groups = {}
for uid, i in enumerate(groupSizes):
groups[i] = groups.get(i, [])
groups[i].append(uid)
return [groups[i][j:j+i] for i in groups for j in range(0, len(groups[i]), i)]
| true |
5b16eac549a6034cb0a6c45a387a331cfeb4e71e | Python | whitej6/DeviceRename | /DeviceRename.py | UTF-8 | 2,151 | 2.765625 | 3 | [] | no_license | import netmiko
from getpass import getpass
''' User input for password not displayed on screen '''
def define_password():
password = None
while not password:
password = getpass('Enter TACACS+ Password: ')
passwordverify = getpass('Re-enter TACACS+ Password to Verify: ')
if not password ... | true |
38a2a6575a8c3deb44876971c751b73ef3dcaa10 | Python | jordanmslack/pytorch-plagiarism-detection | /methods.py | UTF-8 | 2,374 | 3.328125 | 3 | [] | no_license | import re
import operator
def create_datatype(df, train_value, test_value, datatype_var, compare_dfcolumn, operator_of_compare, value_of_compare,
sampling_number, sampling_seed):
df_subset = df[operator_of_compare(df[compare_dfcolumn], value_of_compare)]
df_subset = df_subset.drop(column... | true |
e6bd649fa3fc8a2ece7e9ea4b03718664a1e630e | Python | xjr7670/book_practice | /MasteringDataMiningwithPython/chapter4/basicNetworkMetrics5.py | UTF-8 | 1,088 | 2.609375 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 28 22:03:23 2017
@author: cavin
"""
import networkx as nx
g = nx.read_weighted_edgelist('data/edgelist64.csv')
graphDegree = nx.degree(g)
pos = nx.spring_layout(g)
degree_values = [item[1] for item in graphDegree]
nx.draw(g,
pos,
... | true |
246e1e4021b1161445aa7ea448886acc6dab9a3b | Python | TengXu/CS-2015 | /CS 111/ps2pr3.py | UTF-8 | 1,747 | 4.0625 | 4 | [] | no_license | #
# ps2pr3.py - Problem Set 2, Problem 3
#
# Indexing and slicing puzzles
#
# name: teng xu
# email: xt@bu.edu
# 1
def mult(n, m):
""" takes two integers n and m as inputs and returns the product
of those integers
"""
if n == 0:
return 0
elif n < 0:
return -mult(-n, m)
else... | true |
1b7db7a7a9160b76249903130e248ba5a2532808 | Python | vm2591/StochasticGD | /Tester.py | UTF-8 | 824 | 2.953125 | 3 | [] | no_license | import GradientDescent as gd
import Plotter as pl
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_csv('https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data', header=None)
y = df.iloc[0:100,4].values
y = np.where(y == 'Iris-setosa' , -1 , 1)
X = df.iloc[0:100 , [... | true |
bece17e97ec4c52c60dcf6eddc07504154489a50 | Python | andrew-christianson/Polyglot-Euler | /Problem 6.py | UTF-8 | 411 | 3.53125 | 4 | [
"MIT"
] | permissive | # Constraied to one-liners for this one
from __future__ import print_function
# I'm relatively satisfied here. All computation is one line, following pep8
s, r = sum, list(range(101)); a = s(r) ** 2 - s(i ** 2 for i in r)
print("The answer to Euler Probelm 6 is", a)
# A true one liner disregarding pep8 could be:
# p... | true |
d6b4a3fbe50c6804acd4dadf9037cd49a22f6d0a | Python | reichlj/PythonBsp | /Schulung/py05_listcompr/lb_26_defaultdict.py | UTF-8 | 563 | 3.671875 | 4 | [] | no_license | from collections import defaultdict
def letter_frequency(s):
letter_fre = defaultdict(lambda : 0)
for letter in s.lower():
if letter.isalpha():
letter_fre[letter] += 1
items = [ (c,round(f/len(s),4)) for c,f in letter_fre.items()]
# items.sort(key=itemgetter(1,0),reverse=True)
... | true |
369246abe2eee6158e9eb7c339e804313fcf2f87 | Python | DougWilkinson/led-dotclock | /node.py | UTF-8 | 3,247 | 2.578125 | 3 | [] | no_license | import urandom
from neopixel import NeoPixel
from sensorclass import Sensor
from machine import Pin
import time
# ledclock2
# updated 2/1/2021
def set_nightlight(brightlevel):
#print("brightlevel: " + str(brightlevel))
global led
for x in range(13):
led[x] = (brightlevel,brightlevel,brightlevel)
... | true |
8a942f99e54a5b9a18b235bc79179cabd2025ba4 | Python | ymccarter/flashcard_project | /codeacademy/Reggie_Linear_Regression.py | UTF-8 | 146 | 2.90625 | 3 | [] | no_license | def get_y(m,b,x):
return m*x+b
print(get_y(1, 0, 7))
print(get_y(1, 0, 7) == 7)
print(get_y(5, 10, 3) == 25)
#def calculate_error(m, b):
| true |
2d1e0e359a21d7f1a17eee27a980f32381e13859 | Python | SpicyGarlicAlbacoreRoll/AI_Water | /scripts/make_vrt.py | UTF-8 | 1,427 | 2.625 | 3 | [] | no_license | import json
import os
import re
from argparse import ArgumentParser
from collections import Counter
from osgeo import gdal
PROJECTION = re.compile(r'AUTHORITY\["([A-Z]+)","([0-9]+)"\]')
def main(path: str, vrtname: str):
path_and_proj = []
proj_counter = Counter()
for fname in os.listdir(path):
... | true |
6ee80366bda59548968cf69b116d6e0c9cdbd1cb | Python | okassov/dvbcastlib | /code/libs/dvbobjects/generator/NITGenerator.py | UTF-8 | 3,243 | 2.53125 | 3 | [] | no_license | import os
from dvbobjects.utils.SectionLength import *
from dvbobjects.utils.Write import *
from dvbobjects.PSI.NIT import *
from SQL.NITSQL import *
from SQL.SQLMain import *
#############################
# Network Information Table #
#############################
def nit(network_object_id, network_id, network_dat... | true |
73c5c8b3a45b52f804a93eeab72b552d5136afd1 | Python | LuckFXY/python | /practice_for_python/FigureCanvas.py | UTF-8 | 1,267 | 3.09375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sun Mar 12 11:17:34 2017
@author: rain
"""
from tkinter import *
class FigureCanvas(Canvas):
def __init__(self,container,figureType,width=100,height=100):
super().__init__(container,width=width,height=height)
def drawFigure(self):
func_list=[dis... | true |
d41f299ac90de3f783496f78a18a50f47aea53ac | Python | TangHa0/Realization-of-Handwritten-Chinese-Characters-Recognition | /openfile.py | UTF-8 | 935 | 3.046875 | 3 | [] | no_license | import pickle,pprint
with open('result.dict', 'rb') as f:
# The protocol version used is detected automatically, so we do not
# have to specify it.#协议版本被自动探测到并且使用,所以我们不需要明确它是什么。
data = pickle.load(f) #使用pickle的load函数下载被打开被读取到的数据。
with open("char_dict", "rb") as f:
data1 = pickle.load(f)
... | true |
a9b2ba2b8a512543d7a39c936444f19e0c7c436c | Python | kitt10/master_thesis_2016 | /py/scripts/kitt_classify.py | UTF-8 | 3,493 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
scripts.kitt_classify
~~~~~~~~~~~~~~~~~~~~~
This script classifies testing data with a trained classifier provided by kitt :-).
@arg clf : name of the classifier file
"""
import matplotlib as mpl
mpl.rcParams['axes.labelsize'] = 18
mpl.rcPa... | true |
0a6e5941aa027cb47ca51a77ee6c478b96139e36 | Python | Ramos159/BuffettBot | /cogs/info.py | UTF-8 | 2,736 | 2.953125 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | from discord.ext import commands
class Info(commands.Cog):
"""
Info Module
Will contain commands that pertain to any information regarding the bot
Inherits from the cog class, as all command cogs do
...
Attributes
----------
bot : commands.Bot
Bot instance from main.py
... | true |
8f3be37bad53e1d7ec919450f5c28f3e6ce34e38 | Python | thnglhu/NetVis | /Visual/Canvas/port.py | UTF-8 | 1,237 | 2.65625 | 3 | [] | no_license | class Port:
# region Declaration
def __init__(self, name, device, port_id=None, mac_address=None):
self.name = name
self.device = device
self.link = None
self.id = port_id if port_id else id(self)
self.mac_address = mac_address
self.active = True
def save(se... | true |
6b5ecf59aee91287debfc7a264002ca531ac0eb0 | Python | hasin-abrar/Machine-Learning | /Decision-Tree-with-Adaboost/MainCode/DecisionTreeFull.py | UTF-8 | 19,422 | 3.015625 | 3 | [] | no_license | # pre processing
import math
import random
import datetime
import numpy as np
import pandas as pd
class PreProcessing(object):
def __init__(self, examples):
self.examples = examples
# takes a list as input and gives the mode. (1)[0][0] 1st appearance and more signifies
def Most_Common(self, lst... | true |
ab1a715e0bbaae5f768af042b90040b288c150cd | Python | reesporte/euler | /17/p17.py | UTF-8 | 1,618 | 3.796875 | 4 | [] | no_license | """
project euler problem 17
i kept misspelling forty as fourty and so i kept trying a thousand different
ways to solve the problem and the real problem with my code was the spelling of the
word FORTY
i am So angry
"""
def please_god():
cache = [0] * (1001)
cache[0] = 0
cache[1] = len('one')
cache[2]... | true |
1d22eca056d357759d265d228f253f40c6f22440 | Python | DLTarasi/LPTHW | /ex3.py | UTF-8 | 1,163 | 4.21875 | 4 | [] | no_license | # prints I will now count my chickens:
print("I will now count my chickens:")
# divides 30 by 6 then adds the result to 25
print("Hens", 25.0 + 30.0 / 6.0)
# multiplies 25 * 3 then gives the remainder of that result divided by 4 and subtracts it from 100.
print("Roosters", 100.0 - 25.0 * 3.0 % 4.0)
#prints I will now c... | true |
611f061c1a018d8a4fdaecfe7ce866b514442a2a | Python | Gorazor/leetcode | /栈/32. 最长有效括号.py | UTF-8 | 728 | 3.28125 | 3 | [] | no_license | class Solution:
def longestValidParentheses(self, s: str) -> int:
self.max_length=0
stack=[-1]
for i,c in enumerate(s):
if c=='(':
stack.append(i)
else:
tmp=stack.pop()
if not stack:
stack.append(i)
... | true |
ec220f980666423ff543b622ca5a636360f8deda | Python | NordThing/TopCut | /AutoPilot/v1.py | UTF-8 | 11,185 | 2.625 | 3 | [] | no_license | #2020-09-13 Latest updated
#Author Henrik Allberg @henrikallberg
#Start of the autopilot for the lawnmower
#First it will just take use of the Magnetometer and GPS from a network stream
#Will put waypoints in a vector - would be nice to have an alogritm for that later
#Should make this program works first
import os
fr... | true |
509b82aea0e1b808d6112bed492bce1785ce27ff | Python | RadwanDuadu/Privacy-Source | /HOG detector/dlib_detectorTest.py | UTF-8 | 2,298 | 2.84375 | 3 | [] | no_license | import dlib
import cv2
import glob
import os
import time
# initialize dlib's face detector (HOG-based) and then create the
# facial landmark predictor
print("[INFO] loading facial detector")
detector = dlib.get_frontal_face_detector()
def rect_to_bb(rect):
# take a bounding predicted by dlib and convert it
... | true |
ad259aa8a4f84792e07248bf1fb8b5bec2dd2bc8 | Python | williamwang8901/Algorithm-Data-Structure | /LeetCode_Python/Rotate_Array_189.py | UTF-8 | 786 | 3.3125 | 3 | [] | no_license | import pdb
class Solution(object):
def rotate(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: void Do not return anything, modify nums in-place instead.
"""
if k <= 0 or len(nums) == 0:
return
length = len(nums)
k %= length
... | true |
a60d81d7b3e9363b61b912d36080e6eec982f705 | Python | buxuele/algo_snippet | /junk/127_word_dragon.py | UTF-8 | 313 | 3.28125 | 3 | [] | no_license | # author: fanchuangwater@gmail.com
# date: 2020/4/12 下午9:59
# 目的:
# beginWord = "hit"
# wordList = ["hot","dot","dog","lot","log","cog"]
#
nums = [1,1,1,1, 1, 2, 2, 2, 2,2,3]
i = 0
while i < len(nums) - 1:
if nums[i] == nums[i+1]:
nums.pop(i)
print(nums)
i += 1
print("in the end :", nums)
... | true |
ddeacd1685c8a111708a50dcc1c51a1d0728c9c9 | Python | pipichensir/pytorchtool | /walk.py | UTF-8 | 514 | 3.640625 | 4 | [] | no_license | def walk_modules(module, name="", depth=-1):
"""生成器。根据depth遍历pytorch模块,生成Trace元组"""
child_list = list(module.named_children())
'''
遍历到叶子结点或depth指定的深度时返回当前模块元组;
否则继续向下遍历
'''
if depth == 0 or len(child_list) == 0:
yield (name, module)
else:
for child in child_list:
... | true |
cc9053d4f541a3e13c981ea6b60ad60a8a1954e3 | Python | cfbanks/data-533-lab4 | /duel_learnspells_test.py | UTF-8 | 1,548 | 2.703125 | 3 | [] | no_license | from potterworld.sub2 import learn_spells
from potterworld.sub2 import duel as dl
import unittest
class TestDuel_LearnSpells(unittest.TestCase):
@classmethod
def setUpClass(cls):
print("\nsetUpClass\n")
cls.learn_spells = learn_spells.learn_spells()
def setUp(self):
print('setU... | true |
61134c6a602710d24fd40304f3d10c9371e41eaa | Python | mehdi1902/natural_computational_tools | /arc_diagram.py | UTF-8 | 1,693 | 3.703125 | 4 | [] | no_license | """
Very simple application for vizualizing the arc diagrams
@ Mehdi Saman Booy
"""
import matplotlib.pyplot as plt
from matplotlib.patches import Wedge, Arc, Circle
import numpy as np
from sys import argv
def _arc(i, j, width=1, linestyle='-', color='black'):
"""
Creating a single arc from i to j
"""
return Ar... | true |
ab25e617a29b34e14c93a199b4f18ccf2176045c | Python | fm1randa/curso-desenvolvimentoweb-python-django | /aulas/modulos/modulo_math.py | UTF-8 | 170 | 4 | 4 | [] | no_license | import math
print(math.sqrt(5)) #raiz quadrada
print(math.floor(5.9)) #obtem a parte inteira
print(math.ceil(5.1)) #obtem a parte inteira + 1
print(math.factorial(3)) | true |
da52c694eeb06177edc2a7cdc07fccd70365992b | Python | SimaSheibani/Assignments_Northeastern_University | /numbers/triangular_number_list.py | UTF-8 | 655 | 4.28125 | 4 | [] | no_license | def triangular_number():
'''
Takes a number and calculates the triangular of that number
Input: Integer -> Return: Integer
when done printed, It return the list of triangular numbers
'''
number = input("Enter a number, or enter 'done' :")
list_sum_number = []
while (number != 'done'):
... | true |
ed4b5e4538b17cd8ed78b1ad69bfbd7e48ae050d | Python | pystatic/pystatic | /pystatic/arg.py | UTF-8 | 6,105 | 2.6875 | 3 | [
"MIT"
] | permissive | import copy
import itertools
from pystatic.error.errorcode import *
if TYPE_CHECKING:
from pystatic.typesys import TypeIns
from pystatic.infer.util import ApplyArgs
class Arg(object):
def __init__(self, name, ann: "TypeIns", default=None, valid=False):
"""
valid: whether this argument has... | true |
3e3761e9f3675d08bbfde6eb8e339462fcde006d | Python | m-zakeri/IUSTCompiler | /language_apps/expr2/expr2main.py | UTF-8 | 1,006 | 2.5625 | 3 | [
"MIT"
] | permissive | """
Main script for grammar Expr2
"""
__version__ = '0.1.0'
__author__ = 'Morteza'
from antlr4 import *
from language_apps.expr2.gen.Expr2Lexer import Expr2Lexer
from language_apps.expr2.gen.Expr2Parser import Expr2Parser
from language_apps.expr2.expr2listener import *
# Step 0: Give an input
input_string = 'y = ... | true |
7c635e92fc6119bdd0bb38fc1501de528257d504 | Python | JingkaiTang/github-play | /next_life_and_part/way_or_different_hand/get_case_under_old_problem.py | UTF-8 | 202 | 2.609375 | 3 | [] | no_license |
#! /usr/bin/env python
def time(str_arg):
child_and_first_day(str_arg)
print('have_week')
def child_and_first_day(str_arg):
print(str_arg)
if __name__ == '__main__':
time('problem')
| true |
a6e2084a79f221f6da1cb693c24288996b26a5b0 | Python | jdfr/Foreground-detection-for-moving-cameras-with-stochastic-approximation | /UtilBM.py | UTF-8 | 8,746 | 2.5625 | 3 | [] | no_license | import numpy as np
import scipy.signal as ssig
import imageio as i
def readImg(imname):
return np.array(i.imread(imname), dtype=np.float64, order='F')
#FROM ExtractFeatures.m
def ExtractFeatures(VideoFrame,SelectedFeatures):
NumRowsImg=VideoFrame.shape[0]
NumColsImg=VideoFrame.shape[1]
NumFeatures=... | true |
d5f114246e15ddc0613c3095d90fcea8f43ef76c | Python | zhimu66/Python-Crypto | /DES_CFB.py | UTF-8 | 1,110 | 3.203125 | 3 | [] | no_license | from Crypto.Cipher import DES
from Crypto import Random
BS = DES.block_size
pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS)
unpad = lambda s : s[0:-ord(s[-1])]
class DESCipher:
def __init__(self, key):
self.key = key.decode("hex")
def encrypt(self, pt):
pt = pad(pt)
iv... | true |
75d2f4a7d96213df8ace263dea96563837194806 | Python | linzihan-backforward/PyTorchTransformer | /Transformer/Decoder.py | UTF-8 | 3,403 | 2.578125 | 3 | [
"MIT"
] | permissive | import torch
import torch.nn as nn
from MultiHeadAttention import MultiHeadAttention
from PositionalWiseFeedForward import PositionalWiseFeedForward
from PositionalEncoding import PositionalEncoding
def padding_mask(seq_k, seq_q):
"""
:param seq_k: key 序列
:param seq_q: query 序列
:return: Attention 中用到... | true |
21d1a3a7f344a8bbdf11f8860badf6bba10d53dc | Python | Shekharrajak/competitve-programming | /spojPython/TRT.py | UTF-8 | 604 | 3.015625 | 3 | [] | no_license | def getMaxMoney():
n = int(input())
a = []
for i in range(n):
a.append(int(input()))
done = [False for i in range(n)]
ans = 0
start = 0
end = n - 1
# print(("n => {}, a => {}, done => {}").format(n, a, done))
for i, v in enumerate(a):
if a[start] < a[end] and done[sta... | true |
a7560ff9c520f8829aa352473b3fb2e98b4527db | Python | sebastianceloch/wd_io | /lab5/zadanie2.py | UTF-8 | 196 | 3.453125 | 3 | [] | no_license | class Kwadrat():
def __init__(self, x):
self.x = x
self.y = x
def __add__(self, kwadrat):
return self.x + kwadrat.x
kw = Kwadrat(5)
kw1 = Kwadrat(6)
print(kw+kw1) | true |
27370914284271dce19b72d6f8870789e56c8c89 | Python | ajha17/wikidetox | /conversation_reconstruction_local_pipeline/test_utils/query.py | UTF-8 | 1,971 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | import requests
import json
import os
def query_with_end(title, end):
request = {}
request['action'] = 'query'
request['format'] = 'json'
request['prop'] = 'revisions'
request['titles'] = title
request['rvprop'] = 'ids|timestamp|user|content|userid|sha1'
request['rvlimit'] = 'max'
reque... | true |
fdfde4d0cae5460b2b8e236f7f6e5071e9902cd5 | Python | daimessdn/py-incubator | /exercise list (py)/praktikum/latprak2/beasiswa.py | UTF-8 | 375 | 3.265625 | 3 | [] | no_license | # 12217070
# Dimas Wihandono
# 3 September 2018
# Latihan Praktikkum: Beasiswa
# Menampilkan kategori beasiswa dari faktor IP dan pendapatan orang tua
# KAMUS
# ip, pot = float
# ALGORITMA
ip = float(input(""))
pot = float(input(""))
if (ip >= 3.5):
print (4)
else:
if (pot < 1):
print (1)
elif (pot < 5):
if (... | true |
56647bf27790caa6e4cd2a0ef70f6b82713324da | Python | hrishikesh38/hrishi-choco | /Untitled.py | UTF-8 | 962 | 3 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import numpy as np
import pandas as pd
# In[3]:
df = pd.read_csv('example.txt')
df
# In[6]:
df = pd.read_csv('example.csv')
df
# In[7]:
import pandas as pd
import numpy as np
# In[8]:
from numpy.random import randn
np.random.seed(101)
# In[11]:
df = ... | true |
7b2a1e87c11b371bb831c4229671e0e2a5216e57 | Python | nsshayan/Python | /Learning/Network_process_WA/Day1/2020_Jul23/run_test_py3.py | UTF-8 | 195 | 2.65625 | 3 | [] | no_license | from subprocess import run, CalledProcessError
try:
ret = run(["ls", "/bin"], check=True)
except CalledProcessError as e:
print("*** Caught exception:", e)
else:
print("ret =", ret)
| true |
1d62dc3c5a927f4c3b47cf77b34f529239fc8604 | Python | milanmenezes/python-tutorials | /solutions/unit1/sumofn.py | UTF-8 | 159 | 3.8125 | 4 | [] | no_license | def sum(x):
if(x==0):
return 0
return x+sum(x-1)
x=eval(raw_input("Enter a number\n"))
print "The sum to "+str(x)+ " natural numbers is: "+str(sum(x)) | true |
e7e46bc47293282bfdfd83614b300fbb52ce93f3 | Python | semapu/DateParse | /xor.py | UTF-8 | 1,497 | 3.328125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Aug 1 10:46:57 2017
@author: CTTC
"""
#Librerias a importar
import numpy as np
#keras permite dos APIs --> functional/sequential
from keras.models import Sequential
#keras afrece muchos tipos de capas. En nuetro caso DENSE
from keras.layers.core import Dense
... | true |
4a819d36ff732504476256a92e0405b7ab375b8e | Python | Mnenmenth/Python | /Main.py | UTF-8 | 2,285 | 3.0625 | 3 | [] | no_license | import pygame
from Python import Python
from Food import Food
pygame.init()
pygame.display.set_caption('Python')
screen_width, screen_height = (640, 480)
screen = pygame.display.set_mode((640, 480))
python = Python((200, 200))
food = Food()
pygame.font.init()
game_over_font = pygame.font.SysFont(pygame.font.get_defa... | true |
a6f16c1c558380571bc5abbf8669dba01c228229 | Python | nemanjatesic/Masinsko | /ml_d1_rn1-17_y_z/4.py | UTF-8 | 13,219 | 3 | 3 | [] | no_license | import os
import pandas as pd
import re
import numpy as np
import random
from nltk.tokenize import wordpunct_tokenize
from nltk.stem import PorterStemmer
import sys
class MultinomialNaiveBayes:
def __init__(self, nb_classes, nb_words, pseudocount):
self.nb_classes = nb_classes
self.nb_words = nb_w... | true |
673980962211a4cc84cd07fe4d0e8239c341b37f | Python | jaynedu/digital-image-processing | /canny.py | UTF-8 | 4,462 | 3.09375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# @Time : 2020/6/24 15:04
# @Author : Du Jing
# @FileName: canny.py
# @Usage : Canny
import cv2
import numpy as np
import matplotlib.pyplot as plt
"""
1.原始图像与高斯核卷积,获得稍模糊的图像,目的是降噪,因为导数对噪声敏感
2.使用一阶偏导算子sobel计算梯度
3.非极大值抑制,寻找像素点局部的最大值,目的是排除非边缘像素
4.双阈值法抑制假边缘,连接真边缘
低于阈值1的像素点会被认为不是边缘;
高于... | true |
7d834eaec80c48506cbff69fa06d099e33d42b6c | Python | rpplayground/CS814 | /practical1_miu/miu_breadth_first_search.py | UTF-8 | 1,737 | 3.484375 | 3 | [] | no_license | # University of Strathclyde - MSc Artificial Intelligence and Applications
# CS814 - Artificial Intelligence for Autonomous Systems
# Assignment 1 - Part 2 - MUI Next States Function
# File Created - 15th October 2019 - Barry Smart
#
# ABOUT:
# This file contains the function that...
# We will use the next_states fun... | true |
a8f54eeca445b85ce27e9ff2beb944dd98fb2ad7 | Python | tielushko/The-Modern-Python-3-Bootcamp | /Section 34 - Regular Expressions/substitute_regex.py | UTF-8 | 291 | 3.3125 | 3 | [] | no_license | import re
text = "Last night Mrs. Daisy and Mr. White murdered Ms. Chow"
pattern = re.compile(r'(Mr\.|Mrs\.|Ms\.)([A-Za-z]) ([a-z])+', re.IGNORECASE)
#1st arg - the string you want to work as a sub, and second the sting in which matches occured
print(pattern.sub("\g<2>\g<1>", text))
| true |
c6b21447acd80b34864984c122a27205fa66ebb3 | Python | aevear/Stonktastic | /src/stonktastic/optimization/optimizeRanFor.py | UTF-8 | 5,469 | 2.890625 | 3 | [
"MIT"
] | permissive | """
.. module:: optimizeRanFor
:synopsis: Preforms optimization scenarios for Random Forest and reports on best configuration options
"""
import itertools
import time
import pandas as pd
from stonktastic.config.config import ranForEstimators, ranForVariables
from stonktastic.machinelearning.prepDataSets import pre... | true |
9dc50845f4c27652cc70cd64c746c5cbf80d3bce | Python | palbbel/git-lesson | /dz/0423/task_bubble_sort.py | UTF-8 | 371 | 3.390625 | 3 | [] | no_license | def bubble_sort(lst):
for i in range(len(lst)-1):
k = len(lst) - 1
while k != i:
print(k)
print(lst[k])
print(lst[k - 1])
if lst[k] < lst[k - 1]:
lst[k - 1], lst[k] = lst[k], lst[k - 1]
k -= 1
print(lst)
bubble_sort([9... | true |