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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ebc4fdbad1d00fc9ad7fe0ac09ec4acc05ccf69c | Python | kolibril13/tricks_for_python | /m3_functions_iter_ad.py | UTF-8 | 268 | 3.984375 | 4 | [] | no_license | # list of vowels
vowels = ['a', 'e', 'i', 'o', 'u']
vowelsIter = iter(vowels)
# prints 'a'
print(next(vowelsIter))
# prints 'e'
print(next(vowelsIter))
# prints 'i'
print(next(vowelsIter))
# prints 'o'
print(next(vowelsIter))
# prints 'u'
print(next(vowelsIter)) | true |
952d7e80523f4c56dfff7a333e739a02f2af6d06 | Python | raulmogos/uni-projects | /FP/labs/tema lab 01/set_C_p16.py | UTF-8 | 780 | 3.75 | 4 | [] | no_license | def gen(n):
'''
program that generates the largest number smaller than n
'''
n=n-1 # the number must be smaller
while perfect_number(n)==False and n>0:
n=n-1
if n==0 : return False
return n
def perfect_number(p):
'''
checks if a number p is perfect or not
... | true |
00a50fc82460029f0ffdbd587d19218c93fbf9a8 | Python | summer-vacation/AlgoExec | /tencent/linkedlist/mergeTwoLists.py | UTF-8 | 1,881 | 3.5 | 4 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
"""
File Name: mergeTwoLists
Author : jing
Date: 2020/3/19
https://leetcode-cn.com/explore/interview/card/tencent/222/linked-list/910/
"""
from tencent.linkedlist.ListNode import ListNode
class Solution:
def mergeTwoLists(self, l1: ListNode, l2: ListNode) ... | true |
69f5dfd32dc895b87948b8398a61f929880e2aae | Python | vsalex/call-stats | /tests/test_models.py | UTF-8 | 2,238 | 2.796875 | 3 | [] | no_license | import unittest
import json
from app.models import DailyStatObj, Call, Duration
class DailyStatTestCase(unittest.TestCase):
def setUp(self):
self.dso = DailyStatObj()
def test_init_obj_True(self):
self.assertIsInstance(self.dso, DailyStatObj)
def test_init_obj_False(self):
with ... | true |
99c003f86cba30f155c6487765dabce042d1e614 | Python | Dark-Llama/text-based-rpg | /Character_Class.py | UTF-8 | 1,684 | 3.515625 | 4 | [] | no_license | import random
class Character:
"""Create Character Class"""
name = ""
def __init__(self):
pass
def basic_attack(self, defender):
# calculate damage
damage = self.atk - defender.dfs
# calculate hit chance
spd_diff = self.spd - defender.spd
... | true |
a4fe1593b9bb21a492b9efb61aefae2867d9aca4 | Python | john-clark/rust-oxide-umod | /old/plugins/other/StartupItems.py | UTF-8 | 4,511 | 2.578125 | 3 | [
"MIT"
] | permissive | # Note:
# I add an underscore at the biginning of the variable name for example: "_variable" to prevent
# conflicts with build-in variables from Oxide.
# Use to manage the player's inventory.
import ItemManager
# Use to get player's information.
import BasePlayer
# The plug-in name should be the same as the ... | true |
d44ea819a48abe67267c85d1fb00d8b298d3e199 | Python | sruthi-batchala/captain | /lists.py | UTF-8 | 305 | 3.421875 | 3 | [] | no_license | #test case1
n=int(input('enter number'))
lst=[]
for i in range(n):
num=int(input('enter the value'))
if num>0:
lst.append(num)
print(lst)
#test case2
n=int(input())
val=[]
num=list(map(int,input().split()))
for i in range(len(num)):
if num[i]>0:
val.append(num[i])
print(val)
| true |
820c2f3407ba3de7af0993aaabb3f7e225b9a9ef | Python | Rodarc20/CC-BuscadorTextos | /reducer-none.py | UTF-8 | 300 | 2.59375 | 3 | [] | no_license | #!/usr/bin/env python3
"""reducer.py"""
from operator import itemgetter
import sys
import math
dictionary = {}
numfiles = 17
for line in sys.stdin:
line = line.strip()
word, info = line.split('\t', 1)
filename, tf = info.split(',', 1)
print('%s\t%s,%s' % (word, filename, tf))
| true |
2f01b188b556084398d6d26915e18ecf68305bcb | Python | helunxing/algs | /leetcode/140.单词拆分-ii.py | UTF-8 | 647 | 2.984375 | 3 | [] | no_license | #
# @lc app=leetcode.cn id=140 lang=python3
#
# [140] 单词拆分 II
#
class Solution:
def dfs(self, s):
if s in self.d:
return self.d[s]
res = []
if not s:
res.append('')
return res
for word in self.wD:
if s.startswith(word):
... | true |
731e6f6b377ce31158fe4b81d695878f962dea19 | Python | vigi4cure/vigi4cure.github.io | /strava_explore_segments.py | UTF-8 | 1,239 | 2.65625 | 3 | [] | no_license | #!/usr/bin/python3
import time
import numpy as np
from stravalib.client import Client
client = Client(access_token='99c2994556a29905b96eb4197996854041ca47ca')
# bounds = (45.380184 , -74.023017, 45.719182 , -73.436622)
flist = open('slist.txt', 'w')
ferror = open('serror.txt', 'w')
# for x in np.arange(45.28,45.71,... | true |
5aebaec848691df94de03cabc4202f42d9e507db | Python | cjh0613/language-blocker-bot | /bot.py | UTF-8 | 2,860 | 2.90625 | 3 | [] | no_license | from os import environ
from sys import argv
from telegram.ext import (
Updater,
MessageHandler,
CommandHandler,
Filters
)
from telegram import Bot
from threading import Timer
RANGES = range(97, 123), range(65, 91)
def valid_message(message: str) -> bool:
for character in message:
if chara... | true |
e3d51334f1fa7c85f775036eea8ce7d230c905ac | Python | prawn-cake/hashcode2018 | /task/solution.py | UTF-8 | 7,513 | 2.8125 | 3 | [] | no_license | import time
from task import parse_input, parse_output, helpers
from collections import namedtuple
Ride = namedtuple('Ride', ['id', 'coord_start', 'coord_finish', 'start_t', 'finish_t', 'dist'])
Order = namedtuple('Order', ['ride', 'actual_start_t', 'actual_end_t'])
class Car:
def __init__(self, idx, t=0):
... | true |
d0f9875ac79f97472f747c291f1dfb987405aaf0 | Python | AhmedRaafat14/CodeForces-Div.2A | /499A - WatchingAMovie.py | UTF-8 | 2,353 | 3.875 | 4 | [] | no_license | '''
You have decided to watch the best moments of some movie.
There are two buttons on your player:
-- Watch the current minute of the movie. By pressing this button,
you watch the current minute of the movie and the player automatically
proceeds to the next minute of the movie.
-- Skip exactly x... | true |
64d02da25568c4f49e97655dd5fba87cada726ef | Python | rorycodinstuff/DSM-artefact | /Python/regexSearch.py | UTF-8 | 935 | 3.3125 | 3 | [] | no_license | #imports
import re, shelve, pyperclip, sys, os
file_list = []
stored_text = []
# Get folder and user regex
folder_name = input('Enter a folder filepath. Add a slash at the end of the path.\n')
search_term = input('Enter an expression you wish to search for.\n')
sregex = re.compile(search_term, re.I)
#... | true |
8c36859f9a1ace1d639725301f2161ba0b9f747a | Python | M1ky/Daily-Coding-Problem | /daily_temperatures.py | UTF-8 | 712 | 4.3125 | 4 | [
"MIT"
] | permissive | '''
Given a list of daily temperatures T, return a list such that, for each day in the input,
tells you how many days you have to wait until the temperature will be warmer.
If there is no such day, put 0.
'''
def days_till_warmer_temperature(arr):
# table holding solution
out = [0]*len(arr)
stack... | true |
ca8dca7831a84c20749c4fe1ef252b470cb613a2 | Python | Aethiles/ppo-pytorch | /test/helpers/parameters.py | UTF-8 | 1,405 | 2.640625 | 3 | [
"MIT"
] | permissive | import torch
import torch.nn as nn
import torch.nn.functional as F
from typing import Tuple
class TestParameters(nn.Module):
def __init__(self,
input_size: int,
output_size: int,
device: torch.device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu... | true |
a4422a501f73501bbce2832a95fee36b98f58720 | Python | thcjylh/JC_Calculate | /GB8076.py | UTF-8 | 4,131 | 2.8125 | 3 | [] | no_license | import random
import math
import four_homes_and_six_entries as f
import numpy
from decimal import Decimal
def bleeding_water(b, c_type, w, g): # 泌水率
b = random.randint(round(b * 9), round(b * 11)) / 10 # 泌水率%
g0 = 800
gw = 9900
if c_type == 0: # 基准混凝土
g0 = random.randint(798, 812) # 筒质量
... | true |
4241f6cdd443fdaed0b56a74afa10aaa23f650a6 | Python | solomongarber/MarkovLowPass | /medQueue.py | UTF-8 | 696 | 2.75 | 3 | [] | no_license | import numpy as np
class medQueue:
def __init__(self,support,frame_shape,num_pixels,num_channels):
self.frames=np.zeros((num_pixels,num_channels,support),dtype=np.uint8)
for i in range(support/2):
self.frames[:,:,i*2]=255
self.frame_shape=frame_shape
self.ind=0
s... | true |
b17591755c36b65d8194736701d10caeb5d11d60 | Python | chgad/numerical_methods | /exercise_1/smallest_number.py | UTF-8 | 783 | 3.84375 | 4 | [] | no_license | import numpy as np
print(b'0')
def produce_smalest(precision=float):
"""
precsion: Class which precision.
return: smallest exponent of 2 wich can be represented
"""
l=1
y = 2
x=2.0
while y>0.0:
y = precision(x**-l)
l+=1
return l-2
exponent = produce_s... | true |
a174a84825a842f23691f6d7e93f3b0d6c43f3f1 | Python | timedata-org/expressy | /expressy/units.py | UTF-8 | 1,875 | 2.515625 | 3 | [
"MIT"
] | permissive | from . import expression, quotes
import keyword, functools, re
"""
This module is a hack to find Pint units in expressions and replace them
with a call to parse that string as a Pint expression.
See https://github.com/hgrecco/pint for more information about Pint.
"""
PINT_MATCH = r"""
( -? \d+ (?: \.\d* )? ) ... | true |
70c4eada6425edfbbf949651e3a9deb5c7e92c6e | Python | shoppon/leetcode | /leetcode/strings/lc_567.py | UTF-8 | 1,561 | 3.28125 | 3 | [] | no_license | from collections import defaultdict
class Solution:
def checkInclusion1(self, s1: str, s2: str) -> bool:
freq = defaultdict(int)
queue = defaultdict(list)
for s in s1:
freq[s] += 1
used = [0] * len(s2)
s1_len = len(s1)
count = s1_len
for i, s in ... | true |
5f3226075fb25cd223efa3fb84b6f81914563894 | Python | s-kostyuk/everpl | /dpl/utils/observer.py | UTF-8 | 811 | 3.1875 | 3 | [
"MIT"
] | permissive | from typing import TypeVar, Generic
T = TypeVar('T')
class Observer(Generic[T]):
"""
Observer is an abstract class which declares the interface to be
implemented by Observer pattern implementations. It specifies a method
for handling of events emitted by Observers - update
"""
def update(self... | true |
0f8066ba53c82e6dd43635308eef510cf1b8cecd | Python | luohoward/leetcode | /codec2.py | UTF-8 | 1,598 | 3.40625 | 3 | [] | no_license | class Codec:
def serialize(self, root):
"""Encodes a tree to a single string.
:type root: TreeNode
:rtype: str
"""
queue = [root]
ans = []
while len(queue) != 0:
node = queue.pop()
if not node:
... | true |
92463c1eb69e28b1f19b9900c30df81c2894835b | Python | puspita-sahoo/codechef_program | /prime.py | UTF-8 | 122 | 3.28125 | 3 | [] | no_license | n = 7
for i in range(2, n):
if n % i == 0:
prime = 'no'
break
else:
prime = 'yes'
print(prime) | true |
7c6b1f5cfa6458bf826eebc03e749ad05b1a7257 | Python | BackupTheBerlios/pyimtool-svn | /PyRAF-Aqua/pyraf/lib/clcache.py | UTF-8 | 10,137 | 2.609375 | 3 | [
"BSD-2-Clause"
] | permissive | """clcache.py: Implement cache for Python translations of CL tasks
$Id: clcache.py,v 1.1 2003/10/08 18:33:12 dencheva Exp $
R. White, 2000 January 19
"""
import os, sys, types, string
import filecache
from irafglobals import Verbose, userIrafHome, pyrafDir
# set up pickle so it can pickle code objects
import copy_... | true |
5007f6e20ce092d26787a56cbf5c21648903242b | Python | ashutosh-narkar/LeetCode | /add_numbers.py | UTF-8 | 1,000 | 4.0625 | 4 | [] | no_license | #!/usr/bin/env python
'''
You are given two linked lists representing two non-negative numbers.
The digits are stored in reverse order and each of their nodes contain a single digit.
Add the two numbers and return it as a linked list.
Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8
'''
class ListNode(objec... | true |
6acab6088a14506cbf0d3d8ab73b395f01cf07f6 | Python | mpyrev/checkio | /secret-message.py | UTF-8 | 109 | 2.90625 | 3 | [] | no_license | def find_message(text):
"""Find a secret message"""
return ''.join([c for c in text if c.isupper()])
| true |
4dae20f84c55fe4dba01ea37a021e39ed54ba462 | Python | EmanuelaMollova/CreeperPP | /creeper_pp/personality_predictor.py | UTF-8 | 2,230 | 2.59375 | 3 | [] | no_license | from sklearn import svm
import numpy as np
import re
from sklearn.preprocessing import normalize
from sklearn.neighbors import KNeighborsRegressor
class PersonalityPredictor(object):
def __init__(self, nn):
self.nn = nn
self.o_clf = KNeighborsRegressor(n_neighbors=self.nn)
self.c_clf = KNei... | true |
3f404c13955c629300cb3e996f44d0a408b0ef32 | Python | momentum-team-4/python-word-freq-tleach01 | /word_frequency.py | UTF-8 | 1,411 | 3.390625 | 3 | [] | no_license | STOP_WORDS = [
'a', 'an', 'and', 'are', 'as', 'at', 'be', 'by', 'for', 'from', 'has', 'he',
'i', 'in', 'is', 'it', 'its', 'of', 'on', 'that', 'the', 'to', 'were',
'will', 'with'
]
def print_word_freq(file):
"""Read in `file` and print out the frequency of words in that file."""
with open(file, 'r')... | true |
0fef7bc0688f885a845b928e1265490ee42a7898 | Python | pedrolucasmr/Algorithms_C_Sharp | /Services/ChartService(WIP).py | UTF-8 | 3,574 | 2.78125 | 3 | [] | no_license | import plotly.graph_objects as _plotly
import mysql.connector as _connector
from mysql.connector import Error
import sys
sys.path.append("../Data")
import datetime
import dbConfig
_dbConfig=dbConfig.readDbConfig()
def GetRuns():
try:
connection=_connector.Connect(**_dbConfig)
connection._open_conn... | true |
3213667c7dec9db73dbaff0db0fd985fbe76bc68 | Python | warbear0129/Margin-Bot | /settings.py | UTF-8 | 2,876 | 2.625 | 3 | [] | no_license | import ConfigParser, os
from utils import *
class Settings(object):
c = ConfigParser.ConfigParser()
def __init__(self, pair):
self._path = "./config/%s.ini" % pair
self.settings = self.parseConfig
printInfo("Checking config file .....\n")
if not os.path.isfile(self._path):
printInfo("No config file ... | true |
04611a08860b50d9e56bdd8c40bf9897ca393801 | Python | Julestevez/Quadrotor-simulator | /Horizontal control of a multidrone system/main.py | UTF-8 | 8,482 | 2.859375 | 3 | [] | no_license | #main file
#This code represents the control of two quadrotors in a horizontal motion in X-Y directions
import numpy as np
import math
import matplotlib.pyplot as plt
import imageio
from skimage.transform import resize
from mpmath import *
from Quadrotor import quadrotor
from Quadrotor import angle_objec... | true |
aaadaa7cee19cc863f6e9f8c6ce1347f38a2ddbf | Python | P-ppc/leetcode | /algorithms/MaxAreaOfIsland/solution.py | UTF-8 | 1,460 | 3.15625 | 3 | [] | no_license | class Solution(object):
def maxAreaOfIsland(self, grid):
"""
:type grid: List[List[int]]
:rtype: int
"""
max_area = 0
dfs_map = {}
for i in range(0, len(grid)):
for j in range(0, len(grid[0])):
if grid[i][j] == 1 and dfs_map.get(str... | true |
1fa4a5b50167e90c0f383e6d38a38ad79f0e71b6 | Python | ipcoo43/hellopython | /nine.py | UTF-8 | 347 | 3.53125 | 4 | [] | no_license | a=int(input('정수 하나 입력 : '))
if a==1:
print(0)
elif a==0:
print(1)
b,c=input('정수 두개 입력 : ').split()
b=int(b)
c=int(c)
if a==1 and b==1:
print(1)
else:
print(0)
if a==1 or b==1:
print(1)
else:
print(0)
if a!=b:
print(1)
else:
print(0)
if a==b:
print(1)
else:
print(0)
if a==0 and b==0
print(1)
else:
print... | true |
6bd0632e256a95e50e1fb29d7af2b1ce141ebf1e | Python | AdamZhouSE/pythonHomework | /Code/CodeRecords/2860/47774/307043.py | UTF-8 | 357 | 3.15625 | 3 | [] | no_license | def dfs(i):
v[i]=1
for j in range(n):
if v[j]==0 and (x[i]==x[j] or y[i]==y[j]):
dfs(j)
n=int(input())
x=[0 for i in range(1000)]
y=[0 for i in range(1000)]
v=[0 for i in range(1000)]
for i in range(n):
x[i],y[i]=map(int,input().split(' '))
ans=0
for i in range(n):
if v[i]==0:
... | true |
403adfac9f01e034db6648f2527dd75911391579 | Python | KarlWenzel/MyScikit-Learn | /class-starting-point.py | UTF-8 | 893 | 2.671875 | 3 | [
"MIT"
] | permissive | import numpy as np
np.random.seed(42) # we may or may not need a seed, but it's a good practice for reproducibility
# pandas tutorial - https://pandas.pydata.org/pandas-docs/stable/10min.html
# pandas cheatsheet - http://datacamp-community.s3.amazonaws.com/9f0f2ae1-8bd8-4302-a67b-e17f3059d9e8
import pandas as pd... | true |
f468ceb05d4191e5a45373a9d12bcedc84c7f3e1 | Python | gwib/s1DataAndProcess | /validation_Dataset.py | UTF-8 | 1,540 | 2.8125 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 29 16:30:21 2020
@author: GalinaJonat
"""
# investigating GLIMS
import pandas as pd
import numpy as np
import datetime as dt
import matplotlib.pyplot as plt
glims = pd.read_csv('/Volumes/ElementsSE/thesisData/validation/glims/glimsPolygons_clippe... | true |
ffce21504ed39e139559c986162ecc4eca42c683 | Python | bipsen/noun_finder | /nlp_tool.py | UTF-8 | 2,011 | 3.234375 | 3 | [] | no_license | """
This script assumes the text column is called "text".
"""
import pandas as pd
import stanfordnlp
import os
import string
import nltk
from tqdm import tqdm
from nltk.corpus import stopwords
nltk.download('stopwords')
"""
Choose which types of words (eg. nouns, verbs) are desired.
For POS tags, see https://univers... | true |
ea818f0f1ab6c4db9094829e98b08f9974a506df | Python | AndrewCarracher/Exercism | /python/isogram.py | UTF-8 | 510 | 3.453125 | 3 | [] | no_license | def is_isogram(string):
no_char_match = True
char_string = split_string(string)
counter=1
count=1
for char in char_string:
if char.isalpha():
while count < len(char_string):
if char.lower() == char_string[count].lower():
no_char_match = False
... | true |
95013101e44bbf892c65b19cb657b914d7038d20 | Python | NBlanchar/exercism | /series/series.py | UTF-8 | 331 | 3.25 | 3 | [] | no_license | def slices(cadena, longitud):
if(len(cadena) >= longitud and longitud >= 1):
resultado = []
for x in range(len(cadena)):
serie = cadena[x:x+longitud]
if(len(serie) == longitud):
resultado.append(serie)
return resultado
else:
raise ValueErro... | true |
95a603dd2f2f68b48b4b199038c9798a004e4e20 | Python | rtstock/EfficientFrontierFromLocalRepository | /py/test_randomnumbers2.py | UTF-8 | 1,008 | 2.828125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Aug 05 15:06:10 2015
@author: justin.malinchak
"""
print '--------------------'
import pandas as pd
import numpy as np, numpy.random
SymbolsList = ['WMT','NKE','T','MCD','JPM','^RUT','XOM','MSFT','YHOO','QQQ','HD','GS','BAC','LEO']
import random
min = 0.0... | true |
8e37b861a829e8951aa5f001e43ea6d783d54b62 | Python | mkhan45/crypto | /rsa/isprimepy | UTF-8 | 367 | 3.34375 | 3 | [] | no_license | #!/bin/python
import sys
import math
def isprime_opt(n: int, primes=[2, 3, 5]):
for i in filter(lambda i: i in primes or isprime_opt(i, primes=primes), range(3, int(math.sqrt(n)) + 1, 2)):
if i not in primes:
primes.append(i)
if n % i == 0:
primes.append(n)
return False
ret... | true |
82bb492cc789a80951ef374de90b1fc52df7d905 | Python | sekhar1926/CSEE_5590_PYTHON_ICP | /team_8_project/Source/cnn.py | UTF-8 | 2,303 | 2.734375 | 3 | [] | no_license |
'''
!tar -xvf crowdai_train_2.tar
!tar -xvf crowdai_test.tar'''
import numpy as np
import keras
from keras.preprocessing import image
from keras.layers import MaxPooling2D,Convolution2D,Dropout, Flatten,Dense,Activation
from keras.models import Sequential,save_model
from keras.utils import np_utils
import os
import ... | true |
64b3868f614f5101c040f7cfa8bd46270c3618aa | Python | lixiang2017/leetcode | /adventofcode/2021/day6/part1_2/lanternfish.py | UTF-8 | 842 | 3.015625 | 3 | [] | no_license |
from collections import Counter
def get_cnt(file_name, day):
dp = Counter()
with open(file_name) as f:
for line in f:
inits = list(map(int, line.strip().split(',') ))
dp = Counter(inits)
for _ in range(day):
next_dp = Counter()
for timer in range(1, 9):
... | true |
c8fcf75dbf5a148d7f1eab116e27b8727455e3b9 | Python | Tom-Lotze/kijkcijferbot | /scrape_kijkcijfers.py | UTF-8 | 585 | 3.0625 | 3 | [] | no_license | import requests
from bs4 import BeautifulSoup as BS
def get_top(url="https://kijkonderzoek.nl/"):
# retrieve the website
response = requests.get(url)
html = BS(response.text, "html.parser")
# extract titles and viewing numbers
titles = html.find_all("td", class_="kc_cdtitle", limit=25)
viewi... | true |
e7e342c1c96d26f36a549c3a98a5635d563b91d8 | Python | lanl/BEE | /beeflow/common/container_path.py | UTF-8 | 947 | 3.296875 | 3 | [
"BSD-2-Clause"
] | permissive | """Path conversion code."""
import os
class PathError(Exception):
"""Path error class."""
def __init__(self, *args):
"""Construct a path error object."""
self.args = args
def _components(path):
"""Convert a path into a list of components."""
if not os.path.isabs(path):
raise... | true |
307656d57298abe8eaae66effa577a0a3d0e3a4e | Python | Taewan-P/attendance-check-nfc | /nfctoid.py | UTF-8 | 234 | 2.828125 | 3 | [] | no_license | from random import randint
def idtest():
return "AD:CG:3F"
def scan_id():
id = ['AD:CG:3F:4B', 'EF:5F:95:60', '3D:51:B9:9A', '25:DB:C0:A4', '4D:D0:56:7D']
num = randint(0, len(id)-1)
#print(id[num])
return id[num] | true |
67e67d6f06c2c2740405cd8ae2e1f034ff1456f4 | Python | nibolyoung/leetcode | /.leetcode/1656.设计有序流.py | UTF-8 | 592 | 3.390625 | 3 | [] | no_license | #
# @lc app=leetcode.cn id=1656 lang=python3
#
# [1656] 设计有序流
#
# @lc code=start
class OrderedStream:
def __init__(self, n: int):
self.id = 1
self.mp = {}
self.cnt = n
def insert(self, id: int, value: str) -> List[str]:
self.mp[id] = value
result = []
while(sel... | true |
5874019a4d65a1833078b0b05fb28bcb3e01c8e8 | Python | IvanBodnar/geocoder_rest | /geocoder/tests/tests_helpers.py | UTF-8 | 4,392 | 2.890625 | 3 | [] | no_license | from django.test import TestCase
from django.db import connection
from geocoder.helpers import Calle, get_calles, interseccion, altura_calle, tramo
from geocoder.models import CallesGeocod
from geocoder.exceptions import CalleNoExiste, InterseccionNoExiste
from .database_definitions import *
def preparar_datos():
... | true |
13ab7f607cbeeb23c41306dfaa033132c751fe17 | Python | itbonds/COP3502-Moss | /organize_submissions.py | UTF-8 | 4,124 | 2.90625 | 3 | [] | no_license | from pathlib import Path
import shutil
import re
import config as cfg
zybooks_submission_regex = "^(?P<first_name>[^_]+)_((?P<middle_name>[^_]+)?\_){0,2}(?P<last_name>[^_]+)_(?P<email>[^_]+)_(?P<date>[^_]+)_(?P<time>[^_.]+)\.?(?P<extension>[\w\d]+)?$"
canvas_submission_regex = "^(?P<student_name>[^_]+)\_((?P<late>LAT... | true |
457eeaa540be31b211c2214d607b0c0114d4a3d1 | Python | bluestar31/dinhthanhlong-fundamental-c4e13 | /Session 4/test.py | UTF-8 | 607 | 3.5 | 4 | [] | no_license | # p = ['Tuan anh', 22, 3, 'Moc Chau', 2]
# print(p)
# person = {}
# print(person)
# person = {
# 'name': 'Tuan Anh'
# }
#
# print(person)
# person = {
# 'name': 'Tuan Anh',
# 'age': 22,
# 'home': 'Moc Chau',
# }
#
# print(person['home'])
# person['home'] = 'Ha Noi'
# print(person)
#
# person['project... | true |
ca95756db2bc5b7c3a87d7d7ed1b96c04ec5e6f8 | Python | Jhonnis007/Python | /ex090.py | UTF-8 | 451 | 4.03125 | 4 | [] | no_license | '''
Faça um programa que leia nome e média de uma aluno, guardando também a situação em um diciário. No final, mostre
o conteúdo da entrutura
=> 7 aprovado menor Reprovado
'''
aluno = {'Nome': str(input('Nome do Aluno: ')),
'Media': float(input('Média: '))}
if aluno['Media'] >= 7:
situacao = 'APROVADO'
el... | true |
befcff29bbb08b51e3ca9b0d8a0c810a103d4383 | Python | likcu/networking | /Assignment3/ss.py | UTF-8 | 2,747 | 2.703125 | 3 | [] | no_license | import udt
import config
import util
import struct
import helper
from datetime import datetime
# Stop-And-Wait reliable transport protocol.
class StopAndWait:
# "msg_handler" is used to deliver messages to application layer
# when it's ready.
def __init__(self, local_ip, local_port,
remote_ip,... | true |
79b60ff9834c56d8be1734bc44bf25eb293691cf | Python | goocy/upscale-detector | /upscaleDetector.py | UTF-8 | 4,444 | 2.625 | 3 | [] | no_license | # This code was written by goocy and is licensed under Creative Commons BY-NC 3.0.
# https://creativecommons.org/licenses/by-nc/3.0/
# Commercial use is prohibited.
# core idea: https://github.com/0x09/resdet
# other helpful sources:
# https://techtutorialsx.com/2018/06/02/python-opencv-converting-an-image-to-gr... | true |
3bda405733a86334fe0e8e647e5e60215c0e49e2 | Python | stefantkeller/errorvalues | /errvallist.py | UTF-8 | 4,697 | 2.984375 | 3 | [
"MIT"
] | permissive | #! /usr/bin/python2.7
# -*- coding: utf-8 -*-
'''
Work with whole lists of errval's:
[v0+-e0, v1+-e1, ...]
'''
import numpy as np
from errval import *
class errvallist(list):
def __init__(self,vals=[],errs=0,printout='latex'):
if isinstance(vals,errvallist):
self.__errl = vals
elif... | true |
54cd3270c8aeade571c21eb1f232505e838dc940 | Python | jfmacedo91/curso-em-video | /python/ex039.py | UTF-8 | 673 | 4 | 4 | [] | no_license | from datetime import date
print('\033[33m{:=^51}\033[m'.format(' Exercício 039 '))
nasc = int(input('Ano de nascimento: '))
hoje = date.today().year
print('Quem nasceu em {} tem \033[33m{} anos\033[m em {}.'.format(nasc, hoje-nasc, hoje))
if (hoje-nasc) < 18:
print('Ainda faltam \033[33m{} anos\033[m para o a... | true |
9b092a47f3b1b55f64e665f6e40bc76074200670 | Python | psy1088/Algorithm | /Baekjoon/Implementation/2753.py | UTF-8 | 151 | 3.34375 | 3 | [] | no_license | def leap_year(n):
if N % 4 == 0:
if N % 100 != 0 or N % 400 == 0:
return 1
return 0
N = int(input())
print(leap_year(N))
| true |
d58459970c645bd588cea6493b12b1222ec0e4f3 | Python | justinmoon/raft | /raft/five_thread_demo.py | UTF-8 | 2,962 | 2.890625 | 3 | [] | no_license | import threading
import queue
import logging
import random
import time
logging.basicConfig(level="INFO", format='%(threadName)-6s | %(message)s')
def send_msg(thread_id, queues, msg):
for i in range(5):
if i != thread_id:
queues[i].put(msg)
print("sent to ", i)
def heartbeat(thr... | true |
0d374c89d3df9950e0fb8a1074b6a5c9c9899ffc | Python | pieterbork/operationbgp | /server/manage_server.py | UTF-8 | 983 | 3.3125 | 3 | [] | no_license | import sys
def kill_server(color):
f = open('colors.txt', 'r')
colors = f.readline().strip().split(',')
colors.remove(color)
f.close()
f = open('colors.txt', 'w')
writeline = ",".join(colors).strip()
f.write(writeline)
f.close()
def add_server(color):
f = open('colors.txt', 'r')
... | true |
a0516d8f331002f71c0b1d27f3be2f42f04de27e | Python | ons-eq-team/eq-questionnaire-runner | /tests/integration/questionnaire/test_questionnaire_is_skipping_question.py | UTF-8 | 1,976 | 2.53125 | 3 | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | from tests.integration.integration_test_case import IntegrationTestCase
class TestQuestionnaireChangeAnswer(IntegrationTestCase):
def test_final_summary_not_available_if_any_question_incomplete(self):
# Given I launched a survey and have not answered any questions
self.launchSurvey("test_is_skipp... | true |
591e1997f1a25b437d3981f853b8082dfa6b880d | Python | krishcdbry/Python-Basics | /fib.py | UTF-8 | 179 | 3.90625 | 4 | [] | no_license | print "Fibonacci Series in Python \n \n"
n = int(raw_input("Enter the range of fib"))
a,b,co,c=0,1,2,0
print "%s %s" %(a,b)
while(co<n):
c = a+b
a,b = b,c
print c
co += 1 | true |
4b68a52f2a8861f2d942f067a2eee824063f3544 | Python | ississ0/PythonWebProject | /OC_1206/function0.py | UTF-8 | 335 | 4.46875 | 4 | [] | no_license |
def 더하기(숫자1, 숫자2):
결과 = 숫자1 + 숫자2
return 결과
결과1 = 더하기(2,3)
print(결과1)
결과2 = 더하기('아','야')
print(결과2)
def sayHello():
return "Hello"
# 재료가 없는 함수
result=sayHello()
print(result)
# 리턴값이 없는 함수
def printHello() :
print("Hello!") | true |
f9f72d95660bc778ef69475c2d4d58f8aa9286d5 | Python | alina-timir/Playground-1 | /Pyton_stuff/HarveyMuddX/4is4.py | UTF-8 | 285 | 3.578125 | 4 | [] | no_license | __author__ = 'darakna'
print("Zero is", 4+4-4-4)
print("One is", 4/4)
print("Two is", (4+4) / 4)
print("Three is", int((4*4-4)/4))
print("Four is", 4)
print("Five is", 4+4/4)
print("Six is", 4 + (4+4) / 4)
print("Seven is", 4+4 - 4/4)
print("Eight is", 4+4)
print("Nine is", 4+4 + 4/4) | true |
63426ae1034dbf7d17f132bbbdf091c32b760a87 | Python | trentcraighart/undergradCoursework | /assignments160/calculator.py | UTF-8 | 1,083 | 3.9375 | 4 | [] | no_license | select = 1
start = 'y'
cookie = 1
print("Hello and welcome to my calculator!");
print("Note, this calculator only works with whole numbers");
print("Please refrain from using any 'words'");
while (start == 'y'):
while (cookie == 1):
opp = str(input("Imput Operand: + - / * % **: "));
if opp == '+':
cookie = 0
... | true |
8838f3e2fdc5d6ea5a9103a1a6366c9105ffcc5f | Python | AK-1121/code_extraction | /python/python_5786.py | UTF-8 | 133 | 2.609375 | 3 | [] | no_license | # numpy: Replacing values in a recarray
for fieldname in a.dtype.names:
ind = a[fieldname] == ''
a[fieldname][ind] = '54321'
| true |
b45bba71d49d685d6a915aba601cebee684d2614 | Python | DuckHunt-discord/DuckHunt-Community-Rewrite | /cogs/basics.py | UTF-8 | 3,125 | 2.71875 | 3 | [] | no_license | import datetime
import random
import discord
from discord.ext import commands
from cogs.helpers.checks import have_required_level
class Basics:
"""
Really basic commands of the bot
Normally one liners or misc stuff that can't go anywhere else.
"""
def __init__(self, bot):
self.bot = bot
... | true |
cb17233783759a1639e901182e3ee55693415dd6 | Python | ssd04/ml-project-template | /src/misc/aws.py | UTF-8 | 3,630 | 2.640625 | 3 | [
"MIT"
] | permissive | import os
import boto3
from botocore.exceptions import ClientError
from botocore.config import Config
from loguru import logger
aws_region = os.environ.get("AWS_REGION")
config = Config(retries={"max_attempts": 5, "mode": "adaptive"})
def get_ssm_parameter_value(parameter_name):
try:
ssm = boto3.client... | true |
d9703600a0dbe0b06b8be713077647d8e748a20b | Python | stevenwongso/Python_Fundamental_DataScience | /5 Pandas/20f_pd_missingDate.py | UTF-8 | 363 | 2.765625 | 3 | [] | no_license |
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df = pd.read_csv(
'20_dataTelkom.csv',
index_col=False,
parse_dates=['Tanggal']
)
df = df.set_index('Tanggal')
df = df.sort_index()
# print(df)
# ada tanggal yg missing krn holiday/weekend
df = df.resample('D').sum()
df = df.replace(... | true |
d1abc0b57b38527bebc566dc8d30f2fefd10859f | Python | davidjuliancaldwell/ScientificSupercomputing | /Astro598bayesian/davidcaldwell_hw4/bayesian_functions_hw4.py | UTF-8 | 829 | 3.03125 | 3 | [] | no_license | import numpy as np
import random as random
import math
import re
import sys
import matplotlib.pyplot as plt
import seaborn as sns
from scipy.stats import beta
def beta_func(theta,a,b):
# beta prior
numSteps = 1000
theta_vector = np.linspace(0,1,numSteps)
vector_int = [x**(a-1)*(1-x)**(b-1) for x in the... | true |
762efbb738bd05133acd8fc9018495d2f3e26e99 | Python | KB-perByte/CodePedia | /Gen2_0_PP/Assignment/leetcode_combinationSumIV.py | UTF-8 | 1,775 | 2.828125 | 3 | [] | no_license | class Solution(object):
def combinationSum42(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: int
"""
def dfs(idx, cur, memo):
if cur == target:
return 1
if cur > target:
return 0
... | true |
07b51d4d5b29e115f6ccf90bf47e59610cd01744 | Python | frostyfeet/craigslist_crawler_lambda | /source/search_master.py | UTF-8 | 1,918 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | import abc
import boto3
import pickle
from slackclient import SlackClient
class SearchMaster(object):
aws_region = "us-west-2"
s3_bucket_name = "temp-lambda-files"
temp_path = "/tmp/"
client = boto3.client('s3', region_name=aws_region)
def __init__(self, urls, s3_filename, slack_token):
s... | true |
2b315440c12984a539b8eaaa7cb6881c0a931500 | Python | oy-vey/AISOBOI | /Python/lab1.py | UTF-8 | 191 | 3.5625 | 4 | [] | no_license | def cumsum(x):
"""Returns cumulative sums of a list"""
s = [0]
for i, v in enumerate(x):
a = v + s[i]
s.append(a)
return s
ml = [1, 2, 3]
print(cumsum(ml))
| true |
05a5320c6bb22301884fbf1621b1bba6630369f5 | Python | tianhm/poetry | /src/poetry/repositories/repository_pool.py | UTF-8 | 4,783 | 2.671875 | 3 | [
"MIT"
] | permissive | from __future__ import annotations
import enum
from collections import OrderedDict
from dataclasses import dataclass
from enum import IntEnum
from typing import TYPE_CHECKING
from poetry.repositories.abstract_repository import AbstractRepository
from poetry.repositories.exceptions import PackageNotFound
if TYPE_CH... | true |
f454c4064f7349048d69324b5362a991f7e58e17 | Python | Abis47/HH-PA2609-1 | /day2.py | UTF-8 | 5,139 | 3.53125 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon Sep 27 19:01:34 2021
@author: vikas
"""
#Conditions
'''
if (conditional statement -> True)
{
Perform Line of Statements
Perform Line of Statements
Perform Line of Statements
}
'''
a = 10
b = 20
if (a > b):
print ("a is greater than b")
if (a>b):
... | true |
5ad2d8ca1baaa8412168fa84c330d6f6a91786d8 | Python | architsharma97/InstanceRetrieval | /Scripts/Test/vocab_tree.py | UTF-8 | 521 | 2.671875 | 3 | [] | no_license | import numpy as np
from sklearn.decomposition import PCA
# loading visual words_reduced
visual_words = np.load('../visual_words.npy')
# PCA
pca=PCA(n_components=500)
visual_words_reduced=pca.fit_transform(visual_words)
print "Compute Unstructured Hierarchical Clustering..."
st = time.time()
ward = AgglomerativeClust... | true |
4382f7b4eb24da5ce3c9a94d4fad2cb90846b7f4 | Python | Liquius/UraniumPower | /Script stuff/controlLuaStuff/controlLuaOnFissionReactorPlace.py | UTF-8 | 1,351 | 2.515625 | 3 | [] | no_license |
def makePrototype( xSize, ySize ):
p = ' elseif event.createdentity.name == "nuclear-fission-reactor-chest-%i" then\n' %(xSize*ySize)
p += ' results = game.findentitiesfiltered{area = {{x1, y1}, {x2, y2}}, name = "nuclear-fission-reactor-%i-by-%i"}\n' %(xSize, ySize)
p += ' if #results == 1 then\n'
p += ' if... | true |
dbf93b804bc8c70d4c6e0a08fba02b7ea6763d68 | Python | hsqf/Course_Python | /chapter_09/iterable_iterator.py | UTF-8 | 1,127 | 4.09375 | 4 | [] | no_license | # -*- coding: utf-8 -*-
from collections.abc import Iterator
"""
迭代器和可迭代对象
"""
class Company(object):
def __init__(self, employee_list):
self.employee = employee_list
def __iter__(self):
return MyIterator(self.employee)
# def __getitem__(self, item):
# return self.employee[i... | true |
f81e6dad032ba794bccb956ebeb298c6c5b54687 | Python | hanlinc27/Allertgen | /testing_api_python.py | UTF-8 | 1,727 | 2.90625 | 3 | [] | no_license | #https://devhints.io/xpath
from lxml import html
import requests
measures = [' cups ', 'cup ', ' teaspoons ', ' teaspoon ', ' tablespoons ', 'tablespoon ', ' plus ',\
' pinch ', ' stick ', ' for serving', ' ounces ', ' ounce ', ' stalk', ' for topping', 'Finely grated zest ', ' of ',\
'can ', ' pounds ', ' po... | true |
47fb09bb3b121070303d3cd7777671a938cad72f | Python | HarryPeach/bAmbi | /bambi/transformers/average_colour_transformer.py | UTF-8 | 2,240 | 2.984375 | 3 | [] | no_license | from bambi.layout import Layout
from bambi.transformers.base_transformer import BaseTransformer
from PIL import Image, ImageGrab
class AverageColourTransformer(BaseTransformer):
def _draw_box(self, img, bb_width, bb_height, start_x, start_y) -> str:
cropped_image = img.crop((start_x, start_y, start_x + b... | true |
60cf0dbd014fa9946ce3a137daecf8ccbb0dab8e | Python | EdwinKato/bucket-list | /backend/api/tests/test_create_item.py | UTF-8 | 1,192 | 2.546875 | 3 | [
"MIT"
] | permissive | import json
from api.test import BaseTestCase
class TestCreateItem(BaseTestCase):
def test_create_item_in_bucket_list(self):
bucket_list_one = {
"description": "Movies i have to watch by the end of the week",
"status": "Pending",
"title": "Entertainment",
... | true |
e9b5f528933c97bb17bbb44586fc184cb4e1198d | Python | DocenkoG/price_eyevis | /eyevis.py | UTF-8 | 11,885 | 2.65625 | 3 | [] | no_license | # -*- coding: UTF-8 -*-
import os
import os.path
import logging
import logging.config
import sys
import configparser
import time
import shutil
import openpyxl # Для .xlsx
#import xlrd # для .xls
from price_tools import getCellXlsx, getCell, quoted, dump_cell, currencyType... | true |
c86d1ff8086248e3d48ccda22ff8c21805f6bbf7 | Python | wangweihao/Python | /5/5-5.py | UTF-8 | 293 | 3.65625 | 4 | [] | no_license | #!/usr/bin/env python
#coding:UTF-8
while 1:
str = raw_input('输入一个小于100美分的数字:')
num = int(str)
i = num / 25
print '25美分 is %d' % i
j = (num - i*25) / 10
print '10美分 is %d' % j
k = (num - i*25 - j*10) / 1
print '1美分 is %d' % k
| true |
4be388f395ea41bbf16ebd5c114972e993524e1b | Python | Shu-HowTing/Code-exercises | /E29.py | UTF-8 | 745 | 3.5625 | 4 | [] | no_license | # -*- coding: utf-8 -*-
# Author: 小狼狗
'''
网易笔试:
x,y都是正整数,x、y<=n,且x%y>=k,求(x,y)一共有多少可能
'''
# def number(n, k):
# count = 0
# for x in range(1,n+1):
# for y in range(1,n+1):
# if x % y >= k:
# count += 1
# return count
# if __name__ == '__main__':
# n,k = [int(x) fo... | true |
2a8a4aa258fcd6947ffb99b5fd621806e7f45740 | Python | tangarmukesh/mukeshpython | /test_module02.py | UTF-8 | 213 | 3 | 3 | [] | no_license | """Sample doctest test module..
test_module02"""
def mul(a,b):
"""
>>> mul(2,4)
8
>>> mul('a',2)
'aa'
"""
return a*b
def add(a,b):
"""
>>> add(1,3)
3
>>> add('a','b')
'ab'
"""
return a+b
| true |
fbceeaa4a908005f0835d675f2985325dd4cc145 | Python | cuiods/Coding | /Python/Course/unit2/pie.py | UTF-8 | 284 | 3.03125 | 3 | [] | no_license | import matplotlib.pyplot as plt
labels = "Frogs","Hogs","Dogs","Logs"
sizes = [15,30,45,10]
colors = ['yellowgreen','gold','lightskyblue','lightcoral']
explode = (0,0.1,0,0)
plt.pie(sizes, explode=explode, labels=labels, colors=colors, autopct='%1.1f%%')
plt.axis('equal')
plt.show() | true |
9ae5e1c04724deaf35efb54e58c42d7cd80a0d57 | Python | zerosum99/python_basic | /myPython/time_date/datetime_date.py | UTF-8 | 1,065 | 3.140625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Feb 03 14:14:15 2016
@author: 06411
"""
import time
from datetime import datetime
from datetime import date
from datetime import timedelta
def date_call() :
da_to = date.today()
print " date min ", date.min, type(date.min)
print " data max ", date.max
print... | true |
c91b010e80c4a333ed2eb3f7b5102d709a2bf355 | Python | alfonsof/music-list | /musiclist.py | UTF-8 | 4,630 | 3.0625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/python
# -*- coding: utf-8 -*-
# musiclist.py
# Main application of musiclist tool.
# This utility allows to read a music structure in your file system,
# and create a file with the information in several formats.
import os
import sys
import argparse
from musicmod import createlist
from musicmod import view... | true |
56536caeca46010e344d75e933d157d2b8bbbd46 | Python | lsroudi/pythonTraining | /quickTour/function.py | UTF-8 | 195 | 3.71875 | 4 | [
"MIT"
] | permissive | def fibonacci(n):
a,b = 0,1
if(n==a):
return a
if(n==b):
return b
return fibonacci(n-1)+fibonacci(n-2)
for n in range(0,10):
print(fibonacci(n))
| true |
a195ec6ea2283840ddb79d1a00f41a17ed4b71e7 | Python | yifr/V1-behavior-neurons | /scripts/data_testing.py | UTF-8 | 2,008 | 2.640625 | 3 | [] | no_license | import os
import h5py
from scipy.io import loadmat
from behavenet import get_user_dir
def test_cell_type_subsamples(session='1', animal='MD0ST5', lab='dipoppa', expt='full_trial',
sample='sst85_sample_0', cell_id=3):
data_dir = get_user_dir('data')
path = os.path.join(data_dir, la... | true |
b7d8d079c17afae1690e988054aa696d5cdab6a5 | Python | Codeducate/codeducate.github.io | /students/python-projects-2016/chada_patel.py | UTF-8 | 4,760 | 3.78125 | 4 | [] | no_license |
#the first input is mathematics
a=int(input())
a2 = str(a)
#the second input is science
b=int(input())
b2 = str(b)
#the third input is english
c=int(input())
c2 = str(c)
#the fourth input is your language course (spanish,french,latin,german)
d=int(input())
d2 = str(d)
#the fifth input is history
e=int(... | true |
5bbbac5755318e5d8c73af35e2e13faf63587b7d | Python | Whitehouse112/Paintings-Detection | /painting_rectification.py | UTF-8 | 7,476 | 2.6875 | 3 | [] | no_license | import numpy as np
import cv2
f_tot = 1000
num_f = 1
focal_length = 1000
def find_intersections(lines):
horizontals = []
verticals = []
for line in lines:
rho, theta = line[0] # x*cos(th) + y*sin(th) = rho
angle = (theta * 360) / (2 * np.pi)
if -45 <= angle < 45 or 135 <= angle ... | true |
1ca927e8b116c29d34c431263d56aad229b8ee77 | Python | mojtabazahedi/News-Recommendation-System | /newstweets.py | UTF-8 | 629 | 2.546875 | 3 | [] | no_license | __author__ = 'Macroboy'
import re
import sqlite3
########################################################
db = sqlite3.connect('NewsData.db')
c = db.cursor()
########################################################
c.execute('select * from news')
rows = c.fetchall()
for row in rows:
rawtext = row[1]
id=str(row... | true |
de8ecd252c8cecee8a8745f1d7bfc8fa860b8227 | Python | lllillly/python_chatting_ass1 | /server.py | UTF-8 | 1,621 | 3.21875 | 3 | [] | no_license | from twisted.internet import protocol, reactor
import names
from colorama import Fore, Back
# 어떤 사용자가 보낸 메시지를 다른 사용자에게 전달
transports = set() # 클라이언트를 저장할 변수
users = set() # 사용자의 이름을 저장할 변수
COLORS = [
"\033[31m", # RED
"\033[32m", # GREEN
"\033[33m", # YELLOW
"\033[34m", # BLUE
"\033[35m", #... | true |
e812c06489cc898cf70e358d678e364fa6f7359a | Python | kspra3/Algorithms-and-Programming-Fundamentals | /Workshop11/Task2A.py | UTF-8 | 865 | 3.96875 | 4 | [] | no_license | import random
import timeit
def power1(x, n):
'computes x to the power of n'
value = 1
for k in range(n):
value *= x
return value
def power2(x,n):
'computes x to the power of n'
value = 1
if n > 0:
value = power2(x, n // 2)
if n % 2 == 0:
val... | true |
132c016cb41fc21e2ccf7fe5ad087edba3bf0d4f | Python | jasonbrackman/writing_a_compiler | /compilers/gone/llvmgen.py | UTF-8 | 16,749 | 3.375 | 3 | [] | no_license | # gone/llvmgen.py
"""
Project 5 : Generate LLVM
=========================
In this project, you're going to translate the SSA intermediate code
into LLVM IR. Once you're done, your code will be runnable. It
is strongly advised that you do *all* of the steps of Exercise 5
prior to starting this project. Don't rush ... | true |
3138f8b48c8e79f871bb7b1d29d28ab77b3e1a16 | Python | junteudjio/pytest-tutorial | /test_pytests/example7/test_example.py | UTF-8 | 515 | 2.59375 | 3 | [] | no_license | from example import get_and_upper_and_persist
import pytest
def test_get_and_upper_and_persist(monkeypatch):
monkeypatch.setattr('builtins.input', lambda:'string-data')
monkeypatch.setattr('example.db_persist', lambda x:None)
data = get_and_upper_and_persist()
assert data == 'STRING-DATA'
... | true |
8ba42a83d212914b429bfabf9980b3423fbf5707 | Python | Gam1999/Practice-Python | /EncryptAndDecrypt.py | UTF-8 | 774 | 3.84375 | 4 | [] | no_license | import string
ROT13Encrypt = str.maketrans(
"ABCDEFGHIJKLMabcdefghijklmNOPQRSTUVWXYZnopqrstuvwxyz",
"NOPQRSTUVWXYZnopqrstuvwxyzABCDEFGHIJKLMabcdefghijklm")
ROT13Decrypt = str.maketrans(
"NOPQRSTUVWXYZnopqrstuvwxyzABCDEFGHIJKLMabcdefghijklm",
"ABCDEFGHIJKLMabcdefghijklmNOPQRSTUVWXYZnopqrstuvwxyz")
... | true |
493b592f8bb76c6ab3e8307d906f4a3129a6f0f5 | Python | bodii/test-code | /python/python_test_002/04/13.py | UTF-8 | 259 | 2.53125 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding:utf-8 -*-
import os
import shutil
# 删除目录
# mkdir 只能删除子目录 该函数只对空目录有用
# shutil.retree(path) 会删除在目录包含其他文件和目录的情况下将该目录删除
| true |
e606db5cfde22cc5f072d7001bf840d2239fd00f | Python | Zorro-Lin-7/Upwork | /direct_messages/services.py | UTF-8 | 2,940 | 2.703125 | 3 | [] | no_license | from django.core.exceptions import ValidationError
from django.utils import timezone
from django.db.models import Q
from .models import Message, ChatRoom
from .signals import message_read, message_sent # 导入Signal
class MessagingService(object):
def send_message(self, sender, recipient, message):
if sende... | true |
fbb9af4baf34162c7eb3f21c6db02d1cdf601066 | Python | dvdmrn/AV-study | /viapoint_editor/animationplayer/keylog_data.py | UTF-8 | 2,585 | 3.140625 | 3 | [] | no_license | import pygame
import time
import collections
import csv
pygame.init()
display_width = 800
display_height = 600
black = (0,0,0)
white = (255,255,255)
red = (255,0,0)
car_width = 73
keylogData = collections.OrderedDict()
gameDisplay = pygame.display.set_mode((display_width,display_height))
pygame.display.set_capti... | true |