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 |
|---|---|---|---|---|---|---|---|---|---|---|
b619ba64d4e8c409593850be2bc41cd86efb5a88 | Ruban-chris/Interview-Prep-in-Python | /elements_of_programming_interviews/17/17-1.py | UTF-8 | 899 | 2.9375 | 3 | [] | no_license | def numCombinationsForFinalScore(finalScore, individualPlayScores):
# memo
numCombinationsForScore = [[c for c in range(finalScore + 1)] for r in range(len(individualPlayScores))]
for i in enumerate(individualPlayScores):
numCombinationsForScore[i][0] = 1 # only one way to reach zero
for j ... | true |
469c37528b54738be4365f81b8282f42451ae31c | hj5730/python-crawler | /weblib-practices/client/httpconnection.py | UTF-8 | 588 | 3.40625 | 3 | [] | no_license | # 서버에 연결하는 파일
from http.client import HTTPConnection
conn = HTTPConnection('www.example.com')
conn.request('GET', '/')
resp = conn.getresponse()
print(resp.status, resp.reason) # status: 숫자, reason : 코드 설명
# 성공
# GET / HTTP/1.1 (서버) (url에 www.example.com)
# 200 OK (결과)
if resp.status == 200:
body = resp.read()
... | true |
a811c5cdb93be05a50d46f9660ba644dd6df1c1b | oisinredmond/ML-Bank-Marketing-Preditctions | /assignment.py | UTF-8 | 4,658 | 2.65625 | 3 | [] | no_license | # Oisin Redmond - C15492202 - DT228/4
# Machine Learning Assignment 2
import numpy as np
import pandas as pd
import csv
import matplotlib.pyplot as plt
from pandas.plotting import scatter_matrix
from sklearn import model_selection
from sklearn import metrics
from sklearn.metrics import confusion_matrix
from... | true |
52f6e21233840a7b40941b03ae0fbb92f80ecbb9 | Sensirion/python-shdlc-driver | /sensirion_shdlc_driver/command.py | UTF-8 | 3,777 | 2.875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | # -*- coding: utf-8 -*-
# (c) Copyright 2019 Sensirion AG, Switzerland
from __future__ import absolute_import, division, print_function
from .errors import ShdlcResponseError
import logging
log = logging.getLogger(__name__)
class ShdlcCommand(object):
"""
Base class for all SHDLC commands.
"""
def ... | true |
c466dabcf8f9bcbe61f07ae5abfa2e27c76d2723 | susami-jpg/atcoder_solved_probrem | /バウムテスト.py | UTF-8 | 639 | 2.984375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu Jul 15 18:25:11 2021
@author: kazuk
"""
from sys import setrecursionlimit
setrecursionlimit(10**7)
n, m = map(int, input().split())
adj = [[] for _ in range(n)]
for _ in range(m):
u, v = map(int, input().split())
adj[u-1].append(v-1)
adj[v-1].append... | true |
248d40be88fa3ad10e0eab699ecafa2a326c89df | JanaSabuj/Coursera-Getting-started-with-python-Dr-Chuck-Michigan | /Michigan-Python/xml1.py | UTF-8 | 522 | 2.859375 | 3 | [] | no_license | import urllib.request, urllib.parse, urllib.error
from bs4 import BeautifulSoup
import ssl
import xml.etree.ElementTree as ET
gcontext = ssl.SSLContext()
url = input('Enter the url to parse from')
fhandle = urllib.request.urlopen(url, context = gcontext).read()
tree = ET.fromstring(fhandle)
lst = tree.findall('comme... | true |
45197dd2b67c6532448d38d611052daa60723fd0 | prateksha/Source-Code-Similarity-Measurement | /PythonAssignment/6_Rahul.py | UTF-8 | 282 | 3.625 | 4 | [] | no_license | def ensure(x, y):
if(x > y):
return True
else:
return False
def gcd(x, y):
if(ensure(x, y)):
if(x % y == 0):
return y
else:
return gcd(y, x%y)
else:
return gcd(y, x)
print (gcd(int(input("Enter number 1: ")), int(input("Enter number 2: "))))
| true |
0e53a787122e8735528077ef60c8181c9e406751 | jagritiS/pythonProgramming | /whileBreak.py | UTF-8 | 530 | 4.03125 | 4 | [
"MIT"
] | permissive | # while --> break, pass and continue
i = 1
while i<6 :
print("i = ",i)
if i == 3 :
break # breaks the loop after i reaches 3
i += 1
print("=================================")
j =1
while j <6 :
print("j = ",j)
if j == 3 :
pass # pass --> it passes to the next value
j += 1... | true |
d2978f960c27e079d14c4ccf45a5309f6ff38985 | diegohabarbosa/Basics-Projects | /CursoemVideo/Curso_de_Python/Mundo2_40hs/Exercícios/ex041.py | UTF-8 | 494 | 3.3125 | 3 | [
"MIT"
] | permissive | # Classificando Atletas
from datetime import date
ano = int(input('Digite o ano de nascimento do atleta: '))
idade = date.today().year - ano
if idade <=9:
print('O atleta está na categoria MIRIM')
elif idade >9 and idade <=14:
print('O atleta está na categoria INFANTIL')
elif idade >14 and idade <=19:
print... | true |
a0842051286e0cea9dbdc4b0c23053f3f6007d1b | danieljustice/Forward_Chaining | /test/test_unify.py | UTF-8 | 1,667 | 3.15625 | 3 | [] | no_license | import unittest
import unittest.mock
from unittest.mock import MagicMock
from ..src.unify import compatible_atoms
from ..src.unify import is_variable
from ..src.unify import unify
from ..src.Atom import Atom
class TestUnifyClass(unittest.TestCase):
def test_first_fail(self):
assert True == compatible_atoms... | true |
5c74acd5ff6546c0580b03562ab7d954ad42e9ba | whiteted-strats/GE_Wiki_Maps | /lib/near_geoms.py | UTF-8 | 3,373 | 2.984375 | 3 | [] | no_license | from shapely.geometry import Polygon, LineString, MultiPolygon
from shapely.ops import unary_union
import numpy as np
def splitIntoNearest(poly, nearPoint, farPoint):
n_x, _, n_z = nearPoint["position"]
f_x, _, f_z = farPoint["position"]
k = 4
# Dividing line
mid = ((n_x + f_x) / 2, (n... | true |
ec870ff70b4a7b0a265c792a4a288d834ebacbf6 | aeghian/Wealth_Concentration_ABM | /model_attributes.py | UTF-8 | 7,650 | 2.703125 | 3 | [] | no_license | import sympy as sym
import random
import csv
import pandas as pd
import math
import statistics
import time
class GeneralInputRelationship:
def __init__(self, parameters):
for i in parameters:
setattr(self, i, parameters[i])
def SolveRelationship(self, x, y):
return self.output_mult... | true |
13d1bcf4dca8fc9755ecd4ce0bea72184b3099f9 | c3drive/PythonLecture | /oop/ducktyping.py | UTF-8 | 1,064 | 3.796875 | 4 | [] | no_license | class Duck:
"""
This a class for Duck.
Attributes:
name(str): the name of the duck
Methods:
walk: print ***
quack: print **
fly: ***
"""
def __init__(self, name):
"""
The constructor for Duck clask
:param name: the name of the duck
... | true |
78d8027675af500b26152d6d919e6fb823c69282 | hi-imAndy/Search-Engine | /View/paginacija.py | UTF-8 | 5,532 | 3.484375 | 3 | [] | no_license | from View.rang import *
def paginacija(infoLista):
poziciija = 0 #pozicija u listi koja se stampa
ispisano = 0 #broj ispisanih stavki
print( "=============================================================================================================================================================... | true |
4b6b2c06dbd1b1462c09954dbd2097b38e59e2ca | chriskj/advent-of-code-2020 | /07/main.py | UTF-8 | 1,097 | 3.15625 | 3 | [] | no_license | import re
import json
ruledict = {}
# Parse the ruleset
with open('07/input.txt', 'r') as fp:
rulelist = fp.read().split('\n')
for rule in rulelist:
key = re.match(r'^\w+ \w+', rule).group(0)
ruledict[key] = []
m = re.findall(r'(\d?) (\w+ \w+) (?:bag)', rule)
for entry in m:
if entry[0] !... | true |
4a862a88b9dc6115758fe1fe6385f23b7fd3eb62 | LTRavenwood/RPG | /rpg.py | UTF-8 | 5,749 | 3.640625 | 4 | [] | no_license | from dataclasses import dataclass, field
import time
from queue import PriorityQueue
from typing import List, Tuple
import random
# Name input
print("What is your name?")
name = ''
while name == '':
name = input('>')
# start with the character class
class Character:
# Class of characters
def __init__(se... | true |
a2f0ff5d16ca602010c6f3d406df3374d2289f8c | jkchen2/JshBot-legacy | /parser.py | UTF-8 | 15,490 | 2.625 | 3 | [] | no_license | import socket, time, sys, asyncio, random
from jshbot import configmanager, usermanager, servermanager, tagmanager, soundtagmanager, decider, utilities, botmanager
from jshbot.jbce import bot_exception
EXCEPT_TYPE = "Parse"
BASE_EXCEPT_TYPE = "Base command"
# These lists get filled when each module is initia... | true |
fba0e76282155ca6dcd7501b32bd178cd2f47212 | Mhoares/sinoalice_data_analisys | /daysplayed.py | UTF-8 | 486 | 3 | 3 | [] | no_license | from userdata import UsersData
import matplotlib.pyplot as plt
import sys
daysPlayed = UsersData()
total = daysPlayed.getUsersDaysPlayed()
total_items = total.items()
total_sorted = sorted(total_items)
days = []
players = []
if len(sys.argv) > 1:
total_sorted = total_sorted[:int(sys.argv[1])]
for to in total_sor... | true |
c9b8db8668eca604296568bf7d22c373f5056047 | dr-bigfatnoob/quirk | /technix/de.py | UTF-8 | 5,561 | 2.640625 | 3 | [
"Unlicense"
] | permissive | from __future__ import print_function, division
import os
import sys
sys.path.append(os.path.abspath("."))
sys.dont_write_bytecode = True
__author__ = "bigfatnoob"
from utils.lib import O
from utils.stats import Statistics
import time
from technix.tech_utils import Point, seed
from utils import plotter
from technix... | true |
b6373ebff50ade0b5bf72a12f8e368e24d8fb7c4 | traffic-lights/simple-traffic-lights | /generators/lane.py | UTF-8 | 1,434 | 2.75 | 3 | [] | no_license | import re
import numpy as np
class Lane:
def __init__(self, connection, lane_id):
self.connection = connection
edge_id = self.connection.lane.getEdgeID(lane_id)
# lane index from laneID
self.lane_id = lane_id
self.index = int(re.sub(f"{edge_id}_", "", lane_id))
self... | true |
dd4134d477f6d1c8f379409a14392001311a0f1f | sachin5740/Flight-Data-scraper | /tabular_farmat.py | UTF-8 | 979 | 2.90625 | 3 | [] | no_license | # import pandas as pd
# data=pd.read_csv("FlightsData_1BOM-DEL-10-03-2021.csv")
# print(data.to_sql())
import pandas as pd
from glob import glob
path=r'C:\Users\kapil\OneDrive\Desktop\Test-code'
filesname = glob (path + "/*.csv")
print(filesname)
files = [filesname]
#print(files)
concat_files = pd.DataFrame()
#pri... | true |
294fb33a2414c5e5d29f13ae9a96195cc14400ac | Monardo/Examen_programacion | /DevuelveGanadorTestCase.py | UTF-8 | 851 | 2.96875 | 3 | [] | no_license | import unittest
from Ejercicio4 import devuelveGanador
class DevuelveGanadorTestCase(unittest.TestCase):
def test_envio_lista_vacia_devuelve_cadena_vacia(self):
self.assertEqual('""', devuelveGanador([]))
def test_envio_lista_valida_de_una_partida_devuelve_a(self):
self.assertEqual('a', devu... | true |
17d8910d1ed8676011e06177ff0312c3ba68e255 | xerifeazeitona/PCC_Data_Visualization | /chapter_16/exercises/16_03_san_francisco.py | UTF-8 | 1,200 | 3.609375 | 4 | [] | no_license | """
16-3. San Francisco
Are temperatures in San Francisco more like temperatures in Sitka or
temperatures in Death Valley? Download some data for San Francisco,
and generate a high-low temperature plot for San Francisco to make a
comparison.
"""
import csv
from datetime import datetime
import matplotlib.pyplot as plt
... | true |
203774bb8734d63a25db8f11715b43dbcac092e7 | bhusalashish/DSA-1 | /Data/Sliding Window/Sliding Window/Max Sum of k Consecutive Element Sliding Window.py | UTF-8 | 708 | 3.96875 | 4 | [] | no_license | '''
#### Name: Sliding Window
Link: [link]()
#### Sub_question_name: Max Sum of k Consecutive Element Sliding Window
Link: [link]()
'''
def subarray_sum(arr, k):
n = len(arr)
i = 0
j = 0
min_sum = float('inf')
window_sum = arr[0]
while j < n:
if j-i+1 < k: # If our window is smal... | true |
830bd6676b82b59ec78d43f2801c2f28d7272a6c | zHaytam/AwaitingBits_BlogPostsCodes | /Creating GIFs in Python using Pillow (PIL Fork)/script.py | UTF-8 | 1,170 | 4.03125 | 4 | [
"MIT"
] | permissive | from PIL import Image, ImageDraw
def create_image_with_ball(width, height, ball_x, ball_y, ball_size):
"""
Creates an image and a ball inside it
:param width: The width of the image.
:param height: The height of the image.
:param ball_x: The X position of the ball.
:param ball_y: The Y positio... | true |
7f4aa5c141b9c55d3bb829fbe630a5afa4bcac6c | dpasionek/Python-LeetCode-Runner | /Executor.py | UTF-8 | 1,855 | 3.109375 | 3 | [] | no_license | import LongestSubstr
import time
from Utility import TimeoutHandler
sol = LongestSubstr.Solution()
def main():
# Create function timeout
f = open("test.txt", 'r')
testCases = {
"abcabcbb" : 3,
"bbbbb" : 1,
"pwwkew" : 3,
"": 0,
" ": 1,
"c": 1,
"au": 2... | true |
8525fa389c175fdf9c460f3b9a71e9c1c4d6a422 | KieSun/StudyCode | /MIT 6.0001/week2.1.py | UTF-8 | 801 | 3.71875 | 4 | [] | no_license | def clip(lo, x, hi):
return min(max(x, lo), hi)
a = clip(1, 2, 3)
print a
a = 10
def f(x):
return x + a
a = 3
print f(1)
x = 12
def g(x):
x = x + 1
def h(y):
return x + y
return h(6)
print g(x)
def square(x):
return x * x
def fourthPower(x):
return square(x) ** 2
... | true |
12abb9fd02091acb66c5adf376b18b47cb50a7f3 | jaytanna61/movie_revenue_predication | /poly_regression.py | UTF-8 | 1,034 | 3 | 3 | [] | no_license | import numpy as np
from sklearn.svm import SVR
import pandas as pd
from sklearn.model_selection import cross_val_score
from sklearn import linear_model
def poly_reg():
dataset = pd.read_excel('2014 and 2015 CSM dataset 2.xlsx')
X = dataset.iloc[1:, 1:-1].values
y = dataset.iloc[1:, -1].values
from sk... | true |
ee422d50d6a5121681356a37d08a9ec3181d23ef | HappyButter/ML-learning-visualisation | /ML-learning-visualisation/NN.py | UTF-8 | 3,564 | 3.140625 | 3 | [] | no_license | from typing import List, Tuple
import torch
import torch.nn
import torch.nn.functional
class NN:
"""
Attributes
----------
model: torch.nn.Module
Neural network model created by PyTorch
criterion: torch.nn.CrossEntropyLoss
instance of the criterion
optimizer: torch.optim.SGD
... | true |
c45352aae5c9fe2d2a4530f2c998d14fb2f66cf2 | ChiuNone/lpthw | /ex15.py | UTF-8 | 481 | 4.15625 | 4 | [] | no_license | #打开文本文件,函数open()
from sys import argv
#输入>>>argv>>>变量
script, filename = argv
#打开文件,函数open()在需要时打开文件,不需要时使用方法.close()关闭
#with open()自动关闭文件,不用方法.close()
txt = open(filename)
print(f'Here are your file {filename}:')
print(txt.read())
print('Type the filename again:')
#input可以当作文件
filename_again = input('> ')
txt_agai... | true |
94ca94e2d08034f8675f0f9b6cafad0eda68ddb6 | MemoryForSky/Data-Structures-and-Algorithms | /introduction_to_algorithms/15.2_matrix_chain_order.py | UTF-8 | 3,066 | 3.84375 | 4 | [] | no_license | """
矩阵链乘法
"""
class Solution1:
@staticmethod
def matrix_chain_order(p):
"""
动态规划
"""
n = len(p) - 1
m = [[0] * (n + 1) for _ in range(n + 1)]
s = [[0] * (n + 1) for _ in range(n)]
for l in range(2, n + 1):
for i in range(1, n - l + 2):
... | true |
c145e3b6ce01c164e7f976e8b1a4badd6ca82f6c | sergioalberto/Chatbots | /demo.py | UTF-8 | 2,678 | 2.578125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #!/usr/bin/env python
# Created by Eng.Sergio GQ
# 14/4/2018
# Cartago, Costa Rica
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unles... | true |
de7c21caf82252196c94ef99a7c08f1df5d0799b | DeanHuang-Git/BIOSTAT823 | /Assignment 2/my_prime/__init__.py | UTF-8 | 575 | 4.40625 | 4 | [] | no_license | def prime(num):
"""A function that has a integer, 'num', as input and return 'True' if the number is a prime and 'False' otherwise."""
if num > 1:
# Loop through all the values between 2 and square root of the number
for i in range(2, int(num ** 0.5) + 1):
# Check if the number is d... | true |
5176cab771d22fe6fc4faee03bb359b678ad265f | zohairhashmi17/Programming-Fundamentals-Detailed-Assignment | /3.4.py | UTF-8 | 230 | 3.1875 | 3 | [] | no_license | print('zohair hashmi - 18b-127-cs - Section A')
print('Practice Problem - 3.4')
a = ['joe', 'sue', 'hani', 'sophie']
b = input('enter a login ID:')
if b in a:
print('You can enter')
else:
print('This user is unknown')
| true |
1098eb9ecb561874e6bc5e6f8d16084468b07ca8 | jasonljc/enterprise-price-monitor | /django_monitor/price_monitor/spider/data_loader.py | UTF-8 | 3,067 | 2.59375 | 3 | [
"MIT"
] | permissive | from price_monitor.models import Site, Price, SiteQuery
import json
from os import path
import os
import logging
logging.basicConfig(level=logging.DEBUG, filename="logfile", filemode="a+",
format="%(asctime)-15s %(levelname)-8s %(message)s")
logger = logging.getLogger(__name__)
class DataLoader(o... | true |
6948d3d1054f4363218fe5daaffcd3555d9a20ec | mzj14/job-scheduler | /scheduler.py | UTF-8 | 3,374 | 2.828125 | 3 | [] | no_license | #! /usr/bin/env python3
from threading import Thread, Condition, Event
from queue import Queue
import time
import calendar
import sys
class AddJobThread(Thread):
def __init__(self, condition, job_queue, job_id, start_t, interval_t):
self.job_id = job_id
self.start_t = start_t
self.interval... | true |
d17ae126c483b56c8ddc39be2ff154da3b4ae9c8 | docsocsf/mad2 | /allocations/allocator/allocate.py | UTF-8 | 9,384 | 2.515625 | 3 | [] | no_license | import json
import random
from allocator.models import Family, Fresher
import requests
SEED = 12345
LOCAL_URL = "http://localhost:8080/"
MAX_CHILDREN = 2
ITERATIONS = 1000
random.seed(555)
def dummy_allocate(families, freshers, debug=False):
leftovers = []
# Try fullfill BOTH female and JMC constraints... | true |
d1e5cbf31a20b2c09aabb90876d6316c0783e600 | abakums/OOP_Python | /Task_3/main.py | UTF-8 | 1,810 | 3.984375 | 4 | [] | no_license | from Task_3.Salary import Salary
from Task_3.Fighter_types import *
"""Инициализация бойцов и вывод информации об одном из них"""
u1 = Boxer('Иван', 'Иванов', 20, 70)
u2 = KickBoxer('Петр', 'Петров', 21, 80)
print("ФИ: ", u1)
print("Возраст: ", u1.age)
print("Разряд: ", u1.discharge)
print("Зарплата:", u1.salary)
prin... | true |
c8652db85bd3ea47015188775fe2a1229c61e19b | karlryden/FMIF10 | /plot.py | UTF-8 | 512 | 2.8125 | 3 | [] | no_license | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
months = ['April', 'Maj', 'Juni', 'Juli', 'Augusti', 'September']
regions = ['Norrbotten', 'Västra Götaland', 'Dalarna']
data = pd.read_csv('./data/csv/Norrbotten.csv', index_col=0)
# print(data)
T = [t for t in range(22*6)]
D = []
for i in ran... | true |
1752b068289a6c594060edabcb169498c48837d1 | LautaroEst/LuthierText | /luthiertext/bow_vectorizer.py | UTF-8 | 6,389 | 2.6875 | 3 | [
"MIT"
] | permissive | import numpy as np
from collections import Counter, defaultdict
from itertools import chain, tee, islice
from scipy.sparse import csc_matrix, csr_matrix
from tqdm import tqdm
def get_ngrams(doc, ngram_range=(1,1)):
for n in range(ngram_range[0],ngram_range[1]+1):
tlst = doc
while True:
a, b = tee... | true |
e2a6e6b8d1627dc2bfa9a2dda01beb13f6b86163 | bwaldrep/tic-tac-toe | /python/minimax.py | UTF-8 | 1,147 | 3.359375 | 3 | [] | no_license | # Bill Waldrep
# July 1, 2012
import player
import board
class Player(player.Player):
"""A player that finds a move using a
basic minimax search"""
def getMove(self, board):
return self.pickMaxMin(board, self.marker)[0]
def pickMaxMin(self, board, marker):
moves = board.getMoves(... | true |
8308bd9810d091e90864ffb70944dcbeae8e2b56 | r0nharley/DataDriven21 | /DataDiffFull/parsers/tests/test_table_widget_parser.py | UTF-8 | 2,024 | 2.765625 | 3 | [] | no_license | import os
from RobotFramework.parsers.table_widget_parser import TableWidgetParser
def get_test_file_path(filename):
"""
Gets the path to a file in the table-widget fixtures folder
:param filename: Name of the file
:return: Path to the file
"""
return os.path.join('parsers', 'tests', 'fixture... | true |
1597c3b0c15e5e9875f99ceca5f8a6fc7e710929 | SkiMsyk/AtCoder | /BeginnerContest_A/219.py | UTF-8 | 165 | 2.890625 | 3 | [] | no_license | X = int(input())
if X >= 90:
print('expert')
else:
diff = [max(0, e-X) for e in [40, 70, 90, 100]]
ans = min([e for e in diff if e > 0 ])
print(ans)
| true |
e6d37d5d6d8d27071d97adbca03dd7e988c6cb22 | peeyar/statefarmkaggle | /pycode.py | UTF-8 | 5,454 | 2.71875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sun Jul 17 23:43:02 2016
@author: anandpreshob
"""
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 13 22:03:30 2016
@author: anandpreshob
"""
#%% import libraries
import cv2, os, time, glob
import tensorflow as tf
from sklearn import svm
from sklearn import datasets
import numpy... | true |
049316ade7685ab85cad828f51022efeac0e54a5 | Soyoung-Yoon/for_Python | /print_03.py | UTF-8 | 235 | 4.21875 | 4 | [] | no_license | a = 10
b = 20
c = a + b
# 10 + 20 = 30
print(a,'+', b, '=', c)
# str.format() : 메서드
print( '{} + {} = {}'.format(a, b, c) )
# str % : 연산
print( '%d + %d = %d' % (a, b, c) )
# f-string
print( f'{a} + {b} = {c}' )
| true |
926340a6725b4eb50aa5d4429f46705064ba8baf | scf1984/HebrewPython | /hangman.py | UTF-8 | 1,335 | 4.34375 | 4 | [] | no_license | # Get word to be guessed, and then hide it
# While user has more guesses:
# Ask for user to guess a letter or entire word,
# show word guessed until now and show him number of guesses left
# if letter - reveal letters in word
# if all letters in original word were guessed - notify and end game
... | true |
4fed0ca127ca46193a49ab4593587bd843b71c13 | vincentmuriuki/foodi | /foodi/tests/test_diary.py | UTF-8 | 1,710 | 2.609375 | 3 | [] | no_license | from django.test import TestCase
from foodi.models import Diary, Food, User, Profile
import datetime
class DiaryTestCase(TestCase):
def setUp(self):
User.objects.create(username="Katelyn")
Food.objects.create(name="candy",
img='',
serving_qty ... | true |
16c323c7bec44261c20c4c9165ed8eb64365b768 | 3saster/advent-of-code-2020 | /Day 03/day03.py | UTF-8 | 771 | 3.671875 | 4 | [] | no_license | from math import prod
def readInput():
with open('input.txt') as fp:
lines = fp.readlines()
lines = [l.strip() for l in lines]
return lines
def slopeCheck(trees, xvel, yvel):
sol = 0
x = 0
y = 0
while y < len(trees):
if trees[y][x] == '#':
sol += 1
y +... | true |
e8f56c2dc993553fe7b129a9b7a5a0d5df9eb92c | dr563105/masterarbeit | /code/evaluation/piechart_control_cmds_distribution.py | UTF-8 | 1,046 | 2.625 | 3 | [] | no_license | from matplotlib import pyplot as plt
from matplotlib import style
import numpy as np
import csv
import pandas as pd
import seaborn as sn
#style.use("ggplot")
distribution = {'labels':['Acceleration', 'Braking', 'No Action'],
'slices':[3491,513, 96954]}
df = pd.DataFrame(distribution, columns=['labels','... | true |
9cb87495531904c19bec13d1c7ed6d5a24f3b46d | alluballu1/OOP-tasks | /Tasks/Exercise 4/Exercise4Task8.py | UTF-8 | 1,698 | 4.3125 | 4 | [] | no_license | # File name: Exercise4Task8.py
# Author: Alex Porri
# Description: Checks if the animal objects fit in the car and match the rolled ID
import MammalClass
import DiceClass
import CarClass as Car
# init_species, init_name, init_width, init_height, init_length, init_weight
# Creating the animal, dice and car objects
... | true |
e399f106f77ef8a05671f4b00fb904b3dcf0137b | ankushjassal01/Python-Learning | /D.Python statements/8.binary search.py | UTF-8 | 1,582 | 3.78125 | 4 | [] | no_license | # in binary search we can divide our data set into half and find the value in it.
# if data present in first half then we will follow the first half data set
# if data present in second half then we will follow the second half data set
# in both data set we need to find it mid point . and then if it again gives us
# ... | true |
a5199afb7f9b14faa9503ea333e2b043a62a0625 | Esot3riA/youtube-video-recommender | /src/esot3ria/video_vector_generator.py | UTF-8 | 1,608 | 2.78125 | 3 | [] | no_license | import pandas as pd
import numpy as np
from gensim.models import Word2Vec
BATCH_SIZE = 1000
def vectorization_video():
print('[0.1 0.2]')
if __name__ == '__main__':
tag_vectors = Word2Vec.load("tag_vectors.model").wv
video_vectors = Word2Vec().wv # Empty model
# Load video recommendation tags.
... | true |
53f43c1986942c8847c96ad0145a26a73b1bf63e | atikur4u/Python_From_Biginner_To_Advance | /Advance/CreateOwnCustomIterationFunction.py | UTF-8 | 373 | 3.65625 | 4 | [] | no_license | class Iterator:
def __init__(self, max):
self.n = 0
self.max = max
def __Iter__(self):
return self
def __next__(self):
if self.n <= self.max:
result = self.n
self.n += 1
return result
else:
raise StopIteration
number =... | true |
96c54655993092b2a90e0b2647e14164611646ae | solareenlo/python_practice | /09_データベース/pickle1.py | UTF-8 | 869 | 3.65625 | 4 | [] | no_license | """ Pythonのデータをそのままの形式で保存できるpickleの使い方 """
import pickle
class T(object):
def __init__(self, name):
self.name = name
data = {
'a': [1, 2, 3],
'b': ('test', 'test2'),
'c': {'key': 'value'},
'd': T('test3')
}
with open('data.pickle', 'wb') as f:
pickle.dump(data, f) # data をそのままの形式で, da... | true |
2bef3ac43a0fb4050a4a0657f6926b0eeec37cf3 | klkzl/traffic_stats_collector | /traffic_stats_generator.py | UTF-8 | 527 | 2.546875 | 3 | [] | no_license | from traffic_stats_mysql import init_db, add_record, insert_records
from traffic_stats_files import directory_function, extract_function
# init_db()
# answer = input("Please provide directory with statistic files:\n")
filelist = directory_function('C:/Users/kkoziel/Documents/Python/capstone/test2/')
# print(filelist... | true |
fe7951c91d918ca4dfa6c27d021836d633cc3fa3 | borneywpf/pythonstudy | /python_start/forelse.py | UTF-8 | 316 | 3.59375 | 4 | [] | no_license | #! /usr/bin/env python
#coding=utf-8
from math import sqrt
for n in range(99, 1, -1):
root = sqrt(n)
if root == int(root):
print n
break
else:
print "Notining."
print "-------------------------"
for n in range(99, 81, -1):
root = sqrt(n)
if root == int(root):
print n
break
else:
print "Noting."
| true |
57859e5080de0ca2983b16e3106ec73c18d46128 | AndSoAway/EleSim | /Experiments/normilizeEle.py | UTF-8 | 1,265 | 2.796875 | 3 | [] | no_license | #!/usr/bin/env python
#-*- coding:utf-8 -*-
import os, sys, codecs
def normilize(file_name):
file = codecs.open(file_name, "r", "utf-8")
records = []
for x in file:
records.append(x)
file.close()
first = records[0]
parts = first.split(',')
minVal = float(parts[2])
maxVal = float... | true |
0f95e568b89f97c060cb45fe2eedce644959d31f | AngelJA/leetcode | /python/137-single-number.py | UTF-8 | 692 | 3.5 | 4 | [] | no_license | # https://leetcode.com/problems/single-number-ii/
import unittest
class TestCases(unittest.TestCase):
def test_case1(self):
self.assertEqual(Solution().singleNumber([2,2,3,2]), 3)
def test_case2(self):
self.assertEqual(Solution().singleNumber([0,1,0,1,0,1,99]), 99)
class Solution:
def s... | true |
bb53b13430ed4c6522faedf8ce70b5f274dabb85 | gabriellaec/desoft-analise-exercicios | /backup/user_226/ch59_2020_09_02_20_35_37_068443.py | UTF-8 | 102 | 3.703125 | 4 | [] | no_license | def asteriscos(n):
n = int(n)
print('*' * n)
n = input("Quantos asteriscos? ")
asteriscos(n) | true |
b238e029dcafcfb4ac56c5b9176afcf8b63d6af6 | x-yang11/Git-CocosTry | /F_Code/in_out_Viewer/in_out_viewer.py | UTF-8 | 3,857 | 2.78125 | 3 | [] | no_license | #coding=utf-8
import string
from pyh import *
#filename格式为inout_20141201, dateid格式为20141201
#货币类型
money_type = {"1": u"金钱", "2": u"军需券"}
#投放/回收类型:1为投放(category为正数)2为回收(category为负数)
class inOutViewer():
category_dic = {}
inout_data = []
def _init_(self):
self.getCatgoryDic()
#获取category的类型,id为负数表示回收,id为正数表示... | true |
60eca0e948cf30b144c426b7b0f948f1e8765280 | yh570/sensibility_testbed | /step_peak.r2py | UTF-8 | 1,704 | 2.90625 | 3 | [] | no_license | """
<Program Name>
step_peak.r2py
<Purpose>
This is a script for walking step counter function by peak search. Analysis of the data
from filtered non gravity acceleration to detect the walking / running steps
by using peak searching method. Introducing an preset walking / running interval
to accurate the d... | true |
5c784da6bb58b13d62972a22a724f87aa66b64aa | Sahil-Ansari-99/prml_assgn2 | /GMM.py | UTF-8 | 7,323 | 2.53125 | 3 | [] | no_license | import numpy as np
def get_kmeans(data, k, num_iters=10, diagonal=False):
d = data.shape[1]
init_means = np.random.randint(0, data.shape[0], size=k)
kmeans = np.zeros((k, d))
for i in range(k):
kmeans[i] = data[init_means[i]]
point_means = np.zeros(data.shape)
tol = 0.001
for i in ... | true |
0989e537d7b4fddc735a88873b1cf8b7d1275a3b | TarekAJR/EpreuveDuFeu | /6.Anagrammes.py | UTF-8 | 274 | 3.0625 | 3 | [] | no_license | import sys
print(" ")
print(" EPREUVE DU FEU : ANAGRAMMES\n")
File1 = open(sys.argv[2],"r").read()
File1 = File1.split("\n")
Parametre = sorted(sys.argv[1])
for Anagramme in File1 :
if Parametre == sorted(Anagramme):
print(Anagramme) | true |
3a309539a7c13c8a140ef8d7adc5cc480e92d25d | steffi7574/LayerParallelLearning | /pythonutil/config.py | UTF-8 | 7,450 | 2.78125 | 3 | [] | no_license | #!/usr/bin/env python
# ----------------------------------------------------------------------
# Imports
# ----------------------------------------------------------------------
import os, sys, shutil, copy
import numpy as np
from ordered_dict import OrderedDict
from ordered_bunch import OrderedBunch
from switch imp... | true |
19a965cd21ab8ee96d46023caf8cf510bff5e88e | Masenkyo/F1M1 | /ditbenik.py | UTF-8 | 836 | 3.5625 | 4 | [] | no_license | from Question import Question
question_prompts = [
"Welk niveau deed ik op school?\n(a) VMBO\n(b) MAVO\n(c) HAVO/VWO\n(d) Gymnasium\n\n",
"Hoe oud ben ik?\n(a) 14\n(b) 15\n(c) 16\n(d) 17\n(e) 18\n\n",
"Waar woon ik?\n(a) Amsterdam\n(b) Zaanstad\n(c) Heerhugowaard\n(d) Den Helder\n(e) Maastricht\n\n"
]
pri... | true |
42b6cd5d29afb3329bf0caaae86d4b8c41833aa0 | dkqyqyt/Algorithm | /Codes/Python/Practice/n1261 알고스팟.py | UTF-8 | 1,675 | 2.765625 | 3 | [] | no_license | from collections import deque
dx = [1,-1,0,0]
dy = [0,0,1,-1]
n, m = map(int,input().split())
graph = []
def bfs():
que = deque()
que.append((0,0))
visit[0][0] = 1
while que:
now_x, now_y = que.popleft()
# print(now_x,now_y)
for i in range(4):
next_x = now_x + dx[... | true |
4699558e61a179c9a667b16a35ebb5bed6e65132 | EmersonBraun/python-excercices | /cod3r/proj_todo/desafio.py | UTF-8 | 784 | 3.15625 | 3 | [] | no_license | #!/usr/bin/python3
class Pessoa:
def __init__(self, nome, idade):
self.nome = nome
self.idade = idade
def isAdult(self):
return True if self.idade >= 18 else False
class Vendedor(Pessoa):
def __init__(self, nome, idade, salario):
super().__init__(nome, idade)
self.... | true |
75b059c5130e4bf4c4ec9082a47be7c39f83e0fb | irfan87/python_tutorial | /conditionals/amusement_park.py | UTF-8 | 349 | 3.90625 | 4 | [] | no_license | print("Welcome to my amusement park!\n")
age = input("Before that, please tell us your age: ")
if int(age) < 4:
price = 0
elif int(age) < 18:
price = 25
elif int(age) < 65:
price = 40
elif int(age) >= 65:
price = 20
if price == 0:
print("Admission cost: Free")
else:
print(f"Admission cost: ${p... | true |
9a80aad39725b668585fb437f63458659e93abaa | Hoseung/pyRamAn | /pyram/tree/treeplots.py | UTF-8 | 7,992 | 2.75 | 3 | [
"MIT"
] | permissive | def trajectory_multi(td,thisgal,save=None, out_dir='./'):
import matplotlib.colors as colors
import matplotlib as mpl
import numpy as np
import matplotlib.pyplot as plt
color = td['aexp']/max(td['aexp'])
marker_area = np.sqrt(td['rvir'])
fig = plt.figure(figsize=(8,6))
ax1 = fig.add_s... | true |
001a0a96bfd4b74b32494d7d028d99a30c47e003 | elcymon/inference-analysis | /boundingBoxDrawer.py | UTF-8 | 3,768 | 2.71875 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
import pandas as pd
import matplotlib as mpl
mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['ps.fonttype'] = 42
mpl.rc('image',cmap='plasma')
from glob import glob
#import numpy as np
import matplotlib.pyplot as plt
#import pathlib
import os
import ntpath
#from segment_gt_n_detections import r... | true |
9677da27f4035f30b8fc7c9aff717965a3a27d92 | kiwhy/pythonProject | /9-t2.py | UTF-8 | 552 | 3.171875 | 3 | [] | no_license | from turtlemodule import *
import turtle
##전역변수##
str1 = ''
swidth, sheight = 500, 500
tx, ty, tangle, tsize = [0, 0, 0, 0]
##메인코드##
turtle.title('거북이')
turtle.setup(width = swidth+50, height = sheight+50)
turtle.screensize(swidth, sheight)
turtle.penup()
turtle.speed(20)
str1 = getstring()
for i in str1:
tx, ty... | true |
70ac5dc808545d50aa88b76c44ce0915e0910672 | jorgeortegap/CursoPythonUASD | /Practica1-JorgeOrtega.py | UTF-8 | 3,283 | 4.25 | 4 | [] | no_license | # 1.- Escribe en pantalla el tipo de dato que retorna la expresion 4 < 2
print(type(4 < 2))
# 2.- Almacena en una variable el nombre de una persona y al final muestra en la consola
# el mensaje: "Bienvenido [NombrePersona]"
NombrePersona = input("Por favor introduzca su nombre: ")
print("Bienvenido", NombrePersona)
... | true |
496ece6a6157b44632d79af5664d27067382039f | SamirJoshi/facedetection | /cmc_curve.py | UTF-8 | 1,525 | 3.03125 | 3 | [] | no_license | # generate a CMC curve
import os
import json
import operator
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
def draw_cmc(recog_rates):
n = len(recog_rates)
x = np.linspace(1, n, n)
plt.plot(x, recog_rates, linewidth=3)
plt.title("CMC Curve")
plt.xlabel("... | true |
041bcc9712645db588c75a023dbc277b8a56f2d5 | jonathantsang/CompetitiveProgramming | /leetcode/contest/2019/feb2/986.py | UTF-8 | 1,885 | 3.53125 | 4 | [] | no_license | # Definition for an interval.
# class Interval:
# def __init__(self, s=0, e=0):
# self.start = s
# self.end = e
# Plan
class Solution:
def intervalIntersection(self, A: 'List[Interval]', B: 'List[Interval]') -> 'List[Interval]':
values = {} # key value in A or B, value: array of [valu... | true |
7fde67480abfaa2dbd987bf3d1e82eb02afd7dac | Alexanderamiri/Golden-voyage | /IN1910/Project_3/variations.py | UTF-8 | 3,750 | 3.96875 | 4 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
from chaos_game import ChaosGame
class Variations:
"""
A class to produce variations of a figure
Parameters
----------
x, y, u, v: array_like
Arrays containing the coordiantes
colors : String
String deciding the color of the p... | true |
ccd411dfb8db1bcca4fbcde4b5309e255051dd14 | supria68/ProjectEuler | /python/prime_permutations.py | UTF-8 | 1,256 | 4.28125 | 4 | [] | no_license | """
EP - 49
The arithmetic sequence, 1487, 4817, 8147, in which each of the terms increases by 3330, is unusual in two ways: (i) each of the three terms are prime, and, (ii) each of the 4-digit numbers are permutations of one another.
There are no arithmetic sequences made up of three 1-, 2-, or 3-digit primes, exhib... | true |
1d94d46d9ebee10219a512e478a4b12aa77b45f7 | hemilioaraujo/BomBot | /main.py | UTF-8 | 3,265 | 3.046875 | 3 | [] | no_license | import telebot
from decouple import config
import re
import random
import time
from pyrastreio import correios
TOKEN = config('TOKEN')
bot = telebot.TeleBot(TOKEN)
@bot.message_handler(commands=["oi", "Oi", "oI", "OI"])
def oi(message):
bot.reply_to(message, f"Oi {message.from_user.username}")
@bot.message_han... | true |
277aa5dd2782c837e809ea93deb9020f7e4a5ee1 | CalmScout/LeetCode | /update_readme.py | UTF-8 | 1,023 | 3.0625 | 3 | [
"MIT"
] | permissive | """
Script updates `README.md` with respect to files at ./easy and ./medium folders.
"""
import os
curr_dir = os.path.dirname(__file__)
with open(os.path.join(curr_dir, "README.md"), 'w') as readme:
readme.write("# LeetCode\nDeliberate practice in coding.\n")
langs = [l for l in os.listdir(curr_dir) if os.path... | true |
5db673d73dfe6144bcd79b2d3a3051d5eb60fb37 | ravi4all/PythonFeb_9-30 | /09-FunctionsInDepth/05-Generators.py | UTF-8 | 220 | 3.703125 | 4 | [] | no_license | # Generators - Yield
def calc():
x = 10
y = 13
yield x + y
x = 13
y = 15
yield x - y
x = 15
y = 17
yield x * y
#print(calc())
for result in calc():
print(result)
| true |
67034abc73de3f5260ea9d9c90a9978c8474f0ca | jakemalley/training-log | /traininglog/exercise/views.py | UTF-8 | 20,444 | 2.703125 | 3 | [
"MIT"
] | permissive | # exercise/views.py
# Jake Malley
# 01/02/15
"""
Define all of the routes for the exercise blueprint.
"""
# Imports
from flask import flash, redirect, render_template, \
request, url_for, Blueprint, abort
from flask.ext.login import login_required, current_user
from forms import AddRunningForm, AddCy... | true |
faae75f06be47cb1a901c4e72d63a181c61a944f | jophy/fasttld | /fasttld/FastTLDExtract.py | UTF-8 | 8,821 | 2.953125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@author: Jophy and Wu Tingfeng
@file: psl.py
Copyright (c) 2022 Wu Tingfeng
Copyright (c) 2017-2018 Jophy
"""
import re
import socket
from collections import namedtuple
import idna
from fasttld.psl import getPublicSuffixList, update
IP_RE = re.compile(
r"^(([0-... | true |
1861302695ec1dd0960a86987d52316e7520558c | BSalwiczek/life-game-python | /Plants/SosnowskyHogweed.py | UTF-8 | 1,106 | 2.875 | 3 | [] | no_license | from Plants.Plant import Plant
from GraphicEngine import Colors
import Animals
class SosnowskyHogweed(Plant):
color = Colors.PURPLE
def __init__(self, x, y, world, graphic_engine):
super(Plant, self).__init__(x, y, world, graphic_engine)
self.power = 10
self.SPREAD_PROBABILITY = 0.02
... | true |
9e376bbbdd59cd671f28442208a2d735ff1dbc6b | cagrell/HAL | /HAL/SRA/distributions/multivariate.py | UTF-8 | 1,594 | 3.28125 | 3 | [
"MIT"
] | permissive | from .continuous_marginal import *
import numpy as np
class MultivariateDistribution():
"""
Multivariate distribution for use in FORM
-- Only a list of marginals for now, will include copula later --
"""
def __init__(self):
self.marginals = []
self.dim = 0
def Ad... | true |
f2ecad8bf6ed704de82b735c87da77b0de3170a6 | dhaksaar/Udacity-DevOps-Project3 | /automatedtesting/selenium/publishlog.py | UTF-8 | 2,484 | 2.53125 | 3 | [] | no_license | import json
import requests
import datetime
import hashlib
import hmac
import base64
import sys
# the file to be converted to
# json format
filename = sys.argv[1]
# Update the customer ID to your Log Analytics workspace ID
customer_id = sys.argv[2]
# For the shared key, use either the primary or the secondary Connec... | true |
317ed9197982e357c1741e93eeed9bdc99c7f926 | zppppppx/zpx-s-python-practice | /Yanghui_triangle_generator.py | UTF-8 | 298 | 3.234375 | 3 | [] | no_license | def triangles():
lines = 1
tempt = [1]
while True:
save = [1]
i = 1
j = 1
while i <= lines-2:
num = tempt[i-1]+tempt[i]
save.append(num)
i += 1
if lines >= 2:
save.append(1)
lines += 1
tempt = save[:]
yield save
f = triangles()
for x in range(1,10):
print(next(f))
| true |
4850520760dd3e34d5d8ad7f87e3ba6358a4ac63 | JonSnowbd/Eventity | /eventity/tests/test_entity.py | UTF-8 | 359 | 2.75 | 3 | [] | no_license | from eventity import ECSystem
from unittest import TestCase
class TestEntity(TestCase):
def test_correct_id(self):
ecs = ECSystem()
e1 = ecs.new("Charles")
e2 = ecs.new()
e3 = ecs.new()
self.assertTrue(e1.id is "Charles")
self.assertTrue(e2.id is 2)
self.a... | true |
60c792046826bc4d711da0882a66b8b9c655832f | irskep/clubsandwich | /clubsandwich/blt/context.py | UTF-8 | 4,158 | 2.796875 | 3 | [
"MIT"
] | permissive | from contextlib import contextmanager
from bearlibterminal import terminal as _terminal
from .nice_terminal import NiceTerminal
from .state import blt_state
from clubsandwich.geom import Point
class BearLibTerminalContext(NiceTerminal):
"""
A class that acts like :py:attr:`clubsandwich.blt.nice_terminal.ter... | true |
ea1e1c8c8c2e47976be58815face59a4080a17bf | xisnu/VRP_RL | /VRP_Data.py | UTF-8 | 4,269 | 3.0625 | 3 | [] | no_license | import numpy as np
import tensorflow as tf
import os
import warnings
import collections
np.random.seed(123)
def read_config(config_file):
config = {}
f =open(config_file)
line = f.readline()
while line:
info = line.strip("\n").split(":")
param_name = info[0]
param_value = int(in... | true |
4bd1e99350e2c5811bdcdc7689a6316fa51993e1 | mahendrasaikumargandham/face-detect | /face-detect.py | UTF-8 | 695 | 2.59375 | 3 | [] | no_license | import cv2
from random import randrange
trained_face = cv2.CascadeClassifier('haarcascade.xml')
webcam = cv2.VideoCapture(0)
while True:
successful_frame_read, frame = webcam.read()
grayscaled_img = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
face_coordinates = trained_face.detectMultiScale(grayscaled_img)
... | true |
b7fa96599b310e4022d9aedec5a1afd28616ba49 | Hauke-P/SWEProjekt2021 | /HTTP Server/alte testdateien/TESTdatabasemodul.py | UTF-8 | 1,182 | 2.625 | 3 | [] | no_license | import uuid
import mysql.connector
def connect():
mydb = mysql.connector.connect(
host="193.196.53.67",
port="1189",
user="jack",
password="123123"
)
return mydb
def addUser(Username, Vorname, Nachname, Passwort):
conn = connect()
c = conn.cursor()
Token = uuid... | true |
202b58b56886bfde92f363342cfa8738fb31773d | wikiteams/gh-torrent-queries | /discussions-network/data/transform.py | UTF-8 | 4,906 | 2.875 | 3 | [
"Unlicense"
] | permissive | import csv
import codecs
import cStringIO
import unicodedata
import re
# words_n_spaces_pattern = re.compile(ur'[^\w\s]+', re.UNICODE)
# control_pattern = re.compile(ur'[\c]+', re.UNICODE)
code_pattern = re.compile(ur'```(.)+```', re.UNICODE)
# non_english = re.compile(ur'[^\x00-\x7F]+', re.UNICODE)
# check ... | true |
ed7f895e0df8d934793850125399832dc46bbc9c | Kimonili/data-structures-and-algorithms-python | /general_tree_ex1.py | UTF-8 | 5,407 | 2.828125 | 3 | [] | no_license | class TreeNode:
def __init__(self, name, designation):
self.name = name
self.designation = designation
self.children = []
self.parent = None
def get_level(self):
level = 0
p = self.parent
while p:
level += 1
p = p.parent
r... | true |
945165e1864881552defaf5f0671391dacdc3187 | anandvipul/DataStructure | /pystack/pystack.py | UTF-8 | 1,284 | 4.90625 | 5 | [] | no_license | # Push into a Stack
'''
In a stack the element insreted last in sequence will come out first
as we can remove only from the top of the stack. Such feature is
known as Last in First Out(LIFO) feature.
The operations of adding and removing the elements is known as
PUSH and POP. In the following program we implement i... | true |
5dd91ab14c72f5972b63665ad01462a0902f0e5e | 7oranger/Log_analysis | /pre-process/docu2vec_for_lines.py | GB18030 | 1,036 | 3.078125 | 3 | [] | no_license | #-*-coding:utf-8-*-
from gensim.models import doc2vec
from collections import namedtuple
# Load data
doc1 = ["This is a sentence", "This is another sentence"]
# Transform data (you can add more data preprocessing steps)
docs = []
analyzedDocument = namedtuple('AnalyzedDocument', 'words tags')
for i, text in enumera... | true |
a203e20ab954a7d0ef62da97ea04822e78b0389b | kafitimi/ci-test | /cplx.py | UTF-8 | 690 | 3.453125 | 3 | [] | no_license | import math
class Cplx:
def __init__(self, x, y):
self.x = x
self.y = y
def r(self):
return (self.x**2 + self.y**2)**0.5
def arg(self):
if self.r():
result=0
if self.x>0:
result=math.atan2(self.y, self.x)
if self.x<0 and s... | true |
9ef1ca8e9a58d1d261321a601f6eb26bbd2d7a79 | LinXiyao/Co-teaching | /src/reader/batch_patcher.py | UTF-8 | 4,218 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | import numpy as np
import math
from structure.minibatch import *
from structure.sample import *
class BatchPatcher(object):
def __init__(self, size_of_data, batch_size, num_of_classes, replacement = False):
self.size_of_data = size_of_data
self.batch_size = batch_size
self.num_of_classes =... | true |
c695f6f9b5a7138359f5070268f2ad43424c7caa | athomsen115/Tkinter | /Images/imageViewer.py | UTF-8 | 2,624 | 2.90625 | 3 | [] | no_license | import os
from tkinter import *
from PIL import ImageTk, Image
root = Tk()
root.title("Image Viewer")
root.iconbitmap('inkspot.ico')
image1 = ImageTk.PhotoImage(Image.open(os.path.join('pictures', 'rocks.jpg')))
image2 = ImageTk.PhotoImage(Image.open(os.path.join('pictures', 'flower.jpg')))
image3 = ImageT... | true |
94b4c48544e76e155bbd3a0cd4c1a490bdd9a38b | thewinterKnight/Python | /dsa/miscellaneous/chocolate_distribution.py | UTF-8 | 1,152 | 3.859375 | 4 | [] | no_license |
def quicksort(arr, start, end):
if start < end:
pivot_index = Partition(arr, start, end)
quicksort(arr, start, pivot_index-1)
quicksort(arr, pivot_index+1, end)
def Partition(arr, start, end):
pivot_index = end
pivot_element = arr[pivot_index]
i = start - 1
for j in range(start, end):
if arr[j] < pivo... | true |
1c81e7890b39e18fc0ea033f552a1e528ef42c54 | jusrebollo/Data-Science-677 | /jrebollohw1/jrebollohw1_6/worst_best_days_oracle.py | UTF-8 | 6,489 | 3.34375 | 3 | [] | no_license | """
Justin Rebollo
Class: CS 677 - Spring 2
Date: 3/23/2021
Homework Problem # 6 My stock
Description of Problem (just a 1-2 line summary!):Question 6: Your oracle got
very upset that you did not follow its advice. It decided to take revenge by
giving you wrong advice from time to time.
"""
# given code
import os
imp... | true |
a485ffc5d2c9e6cfa3befe7ae5cb34d8ce861c74 | Meadosc/shapi | /src/shapi/client.py | UTF-8 | 1,541 | 2.546875 | 3 | [
"Unlicense"
] | permissive | """client bindings to query software heritage API."""
import logging
import os
import sys
from functools import lru_cache
import requests
from requests.utils import quote
logger = logging.getLogger("SHClient")
logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))
class SHClient:
URL = "https://archive.... | true |