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 |
|---|---|---|---|---|---|---|---|---|---|---|
3f8905a498da75c16dac8b5354cbca1dedef5a21 | HenryBalthier/Python-Learning | /multi/arraytest.py | UTF-8 | 294 | 2.859375 | 3 | [] | no_license | from multiprocessing import Process, Array
def test(a):
for i in range(len(a)):
a[i] = -a[i]
if __name__ == '__main__':
arr = Array('i', range(10))
p = Process(target=test, args=(arr, )) #需要将arr对象传递给子进程
p.start()
p.join()
print(arr[:])
| true |
5eb1b0316e8fc60ad1e5f5cb2313ab606546c3ac | 0xck/pob_builds | /color_combinations.py | UTF-8 | 861 | 3.109375 | 3 | [] | no_license | from itertools import chain, permutations
from typing import Final, List
from sys import argv
Colors = List[List[str]]
POSSIBLE_COLORS: Final[str] = "bgrw"
def split_input(input_: List[str]) -> Colors:
splitted = {"".join(sorted(i)) for i in (k.lower() for k in input_) if len(i) > 1 and len(i) < 7 and all(False ... | true |
c44029cca6d0ae96da0137836af2a618d10ca4a6 | liuchangfu/E-selenium_py | /Practice Case/第一节/login.py | UTF-8 | 4,667 | 2.984375 | 3 | [] | no_license | from selenium import webdriver
import HTMLTestRunner
import unittest
import time
class Login(unittest.TestCase):
def setUp(self):
print("Test case begin!!!")
self.br = webdriver.Chrome()
self.br.get("http://192.168.1.113:10086/wordpress/wp-login.php")
def test_login1(self):
"""... | true |
7311bf1a2a1c73716835faf8c8d7631fc6739615 | payneka/python | /lab1/.utility/utility.py | UTF-8 | 2,834 | 3.171875 | 3 | [] | no_license | #!/usr/bin/env python
from volumes import cylinder_volume, torus_volume
from close import close
from words import letter_count
from me499 import GradingHarness,is_close
from math import pi
from random import uniform,random,choice
from string import ascii_letters
class Grader(GradingHarness):
total_points = 10... | true |
44dc8ef335c9fd89492ff4ce461c674e48b8ff05 | perezmtzdavid/uHunt | /245.py | UTF-8 | 723 | 3.203125 | 3 | [] | no_license | import sys
lines = sys.stdin.readlines()
words = []
word = ''
out_text = ''
for text in lines:
for i in text:
if i.isalnum():
word += i
else:
if word == '0':
break
if word.isnumeric():
temp_word ... | true |
297301eaddd8e90068e05f4983ff7af122c105a7 | NikolasBurzynski/MNIST_Classifier | /runTest.py | UTF-8 | 2,232 | 2.84375 | 3 | [] | no_license | import numpy as np
import tensorflow as tf
from keras.datasets import mnist
import PIL
from PIL import Image
import decimal
import matplotlib.pyplot as plt
def main():
(train_data, train_labels), (test_data, test_labels) = mnist.load_data()
trained_weights = np.load('HWONLYvectorizedDTNN', allow_pickle=True)
... | true |
40cd8d3d57966453c140f71897f8167e8cdee90f | pedrofbo/sisprog-PCS3216-2019 | /instructions.py | UTF-8 | 14,710 | 3.15625 | 3 | [] | no_license | from memory import Memory
### instrucao MOVE ###
def MOVE(memory, operando1, operando2, PC):
op1 = operando1
mem = memory.memory
if operando1 in memory.registers:
if operando1[0] == 'd':
operando1 = memory.registers[operando1]
elif operando1[0] == 'a':
operando1 = in... | true |
117ad0566a1adc57a6f0093e76edf0f0663da165 | vicente-palomero/coolnu-scraper | /cinema/wikilists.py | UTF-8 | 4,095 | 2.703125 | 3 | [] | no_license | #!/usr/bin/python
from urllib.request import urlopen
from urllib.error import HTTPError
from urllib.error import URLError
import csv
import sys, getopt
from bs4 import BeautifulSoup
from bs4 import re
wikipedia = 'https://es.wikipedia.org'
def main(argv):
url = ''
outputfile = ''
try:
opts, args =... | true |
8976c5d0f460df124cf644293fea2ee974d51a60 | DMevada/sojern-questions | /math_api.py | UTF-8 | 5,239 | 2.859375 | 3 | [] | no_license | import flask
from flask import request
from flask import jsonify
import heapq
import math
app = flask.Flask(__name__)
app.config['JSONIFY_PRETTYPRINT_REGULAR'] = True
@app.route("/min", methods=['POST'])
def getMin():
header = request.headers['Content-Type']
isJSON = request.is_json
#checks for correct ... | true |
40db0337f30aaa40a94fa0d4f6ce75957224c7c4 | kawerty2/Python-tasks | /Data.py | UTF-8 | 196 | 3.890625 | 4 | [] | no_license | userName = raw_input('What is your name? ')
age = raw_input('How old are you? ')
place = raw_input('Where do you live? ')
print "This is", userName
print "It is", age
print "She lives in", place | true |
7671e7efe9d6c0d084562d488bbb5e6742d8f2ad | xWasp97x/BulbsControl | /connection_tester.py | UTF-8 | 288 | 2.515625 | 3 | [] | no_license | import urequests
class ConnectionTester:
def ping(self):
try:
response = urequests.get("http://clients3.google.com/generate_204")
return response.status_code
except:
return 300
def isConnected(self):
if 200 <= self.ping() < 300:
return True
else:
return False
| true |
bcef38ff1a96bc83af2e65d9f98a6d80ebc5acf2 | slouli/Cisco-Scripts | /MCU-Wrapper/CKO_Controller_Test.py | UTF-8 | 2,246 | 2.796875 | 3 | [] | no_license | import unittest
from lxml import etree as ET
from CKO_Controller import CkoController
class CkoControllerTester(CkoController):
def __init__(self, url='http://fakeurl', user='testUser', pwd='testPass', \
confName='7760362'):
super(CkoControllerTester,self).__init__(url, user, pwd, confNam... | true |
41a39acd4a4a6288b321de0ed445ac31dc6a8d21 | OaklandPeters/getcounty | /getcounty/test/test_pipeline.py | UTF-8 | 4,575 | 2.5625 | 3 | [
"MIT"
] | permissive | from __future__ import absolute_import
import unittest
import os
import collections
#Set current directory to being same directory as this file
fdir, fname = os.path.split(__file__)
os.chdir(fdir)
from getcounty.pipeline import processing
from getcounty.shared import csv_io
from getcounty.pipeline.getzipcodes impor... | true |
f299af14d0fac3a6e0cf63780a8113a8e56eebf2 | EdwinSantos/EECS-4088 | /flask/desktop/multiplegame.py | UTF-8 | 7,039 | 2.984375 | 3 | [] | no_license | import desktop
class MultiGameUI (desktop.DesktopUI):
window = ""
timerLabel = ""
prevGame = ""
def __init__(self, ui, obj):
'''
Initial setup for the game
'''
self.window = ui
super().setWindow(self.window.win)
super().setscreen(self.window.screen... | true |
9d290d73721280c92bbc6925dd82266b60486ed7 | BennyMurray/eye-Pi | /main.py | UTF-8 | 4,177 | 2.84375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import Tkinter as tk
import cv2
from PIL import Image, ImageTk
import datetime
import time
#RECORD AND CHANGE VIEW BUTTON FUNCTIONS
def change():
global output
if b.cget('text') == u"MOG":
b.config(text=u"RAW")
else:
b.config(text=u"MOG")
def recordPlay():
if b... | true |
3bb1573cea4ee41a8d39fd8529a5380b0335d0c4 | xenron/sandbox-github-clone | /yubinbai/pcuva-problems/LA 2565 - Calling Extraterrestrial Intelligence Again/main.py | UTF-8 | 2,446 | 3.109375 | 3 | [] | no_license | '''
Created on Jul 17, 2013
@author: Yubin Bai
'''
import time
from multiprocessing.pool import Pool
from bitstring import BitArray
from bisect import bisect_left
from math import sqrt
parallelSolve = False
INF = 1 << 31
def prime_sieve(top=10000000):
b = BitArray(top) # bitstring of ’0’ bits
for i in range(... | true |
657ef5c19e1f7b60534644ed9c87dce49147342b | SteveHao74/shahao_gmnet_robot | /tools/goto_point.py | UTF-8 | 4,695 | 2.546875 | 3 | [] | no_license | '''
@Description: In User Settings Edit
@Author: Lai
@Date: 2019-11-13 17:00:16
@LastEditTime: 2019-12-10 22:16:41
@LastEditors: Lai
'''
import sys
import os
import cv2
import numpy as np
file_path = os.path.dirname(os.path.abspath(__file__))
root_path = os.path.abspath(os.path.join(file_path, '..'))
print(root_path)
s... | true |
a9735b31d9bc02d97936c9cfe20bc5ce739e2e5c | theeluwin/kata | /cs224d/assignment1/q2_neural.py | UTF-8 | 3,180 | 2.6875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
from __future__ import unicode_literals, print_function, division
import random
import unittest
import numpy as np
import matplotlib.pyplot as plt
from sklearn import datasets
from q1_softmax import softmax
from q2_sigmoid import sigmoid, sigmoid_grad
from q2_gradcheck import gradcheck_naive
... | true |
97bd61b78c9df2380d84d17c0f793965825fea10 | JusticeBoi/Codewars-Challenges | /py/countBits.py | UTF-8 | 424 | 3.328125 | 3 | [] | no_license | def findMaxBit(n):
i = 0
while(pow(2,i) <= n):
i += 1
print("max bit : ",i-1)
return i -1
def countBits(n):
max = findMaxBit(n)
bits_with_1 = 0
while( max >= 0 and n >= 0 ):
if(n / pow(2,max) >= 1 ):
bits_with_1 = bits_with_1 + 1
n = n - pow(2,max... | true |
3adaab1bed13672433ad9f20131b0a26fdd2ba64 | jobaamos/gap-year-club-code | /AMOS24.py | UTF-8 | 193 | 3.78125 | 4 | [] | no_license | #python program to know if at least one of two digits ends woth a 0
a=int(input('1st digit'))
b=int(input('2nd digit'))
if a%10==0 or b%10==0:
print('yes')
else:
print('no')
| true |
a272540a305464df83388e7d4638b70c1752676b | edu-athensoft/cdes1201dataanalysis | /session03/numpy_shape/ndarray_01_shape/shape_changeshape.py | UTF-8 | 714 | 3.890625 | 4 | [] | no_license | # Shape Manipulation
# change the shape of an array
import numpy as np
a = np.floor(10*np.random.random((3,4)))
print(a)
print()
b = a.ravel() # returns the array, flattened
print(b)
print()
b = a.reshape(6,2) # returns the array with a modified shape
print(b)
print()
a.T # returns the array, transposed
b =... | true |
60688cafdf597e0d3254d9d769b0528a34c4f4d9 | sweenejp/learning-and-practice | /practicepythondotorg/exercise3.py | UTF-8 | 396 | 4.09375 | 4 | [] | no_license | source = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
user_input = int(input("Please enter a number: "))
list_b = []
for item in source:
if item < user_input:
list_b.append(item)
print(list_b)
# using filter and lambda (?)
print(list(filter(lambda x: (x < user_input), source)))
# list comprehensions (?)
lis... | true |
508a04fb4c09d89f3766e4203276843af4cda85f | tjablons/tj-automation | /pages/search_page.py | UTF-8 | 1,829 | 2.953125 | 3 | [] | no_license | from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
class AutomationSearchPage:
"""
Class with selectors and methods for Search Results page
"""
RESULT_FIELD = (By.XPATH, "//p[contains(@class,'alert a... | true |
9984d74a6b1bd25ef11839a74b9c2019c6ce3984 | con-f-use/yadmdotfiles | /devel/python/_Notes/graceful_kill.py | UTF-8 | 1,019 | 3.484375 | 3 | [] | no_license | #!/usr/bin/python
from __future__ import print_function
import time
import signal
class GracefulKiller:
kill_now = False
def __init__(self):
# These take precedence over a KeyboardInterrup exception!
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self... | true |
205249ecadf92398e1b69ce2268c671ce46ca35a | 3774257/python_learning | /Python算法题/sort.py | UTF-8 | 4,625 | 3.03125 | 3 | [] | no_license | # 经典常用排序算法实现
from common.funtiontime import getfuntime
from random import shuffle
from math import log, ceil
@getfuntime
def bubble_sort(li):
n = len(li)
for i in range(n - 1):
for j in range(n-i-1):
if li[j] > li[j+1]:
li[j], li[j+1] = li[j+1], li[j]
@getfuntime
def bubb... | true |
1f87a836c61d42730091cf9e173be26f2a1758e5 | wjhwangjinhui/wenshu | /WenshuProject/db/insert_data_to_redis.py | UTF-8 | 570 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import platform
import redis
pl = platform.system()
if pl == "Linux":
redis_obj = redis.Redis(host='127.0.0.1', port=6379, db=1)
else:
redis_obj = redis.Redis(host='master', port=6379, db=1)
def start(file):
file = open(file, "r", encoding="utf-8")
con... | true |
34611f38cb20ec4c1b3acb8d98399631906217be | cw-fsfe/python | /primzahlen3.py | UTF-8 | 1,521 | 3.9375 | 4 | [] | no_license | #primzahlen ausgeben
#For-Schleife mit Else anstelle Flag
#Wenn eine For-Schleife ein Else am Ende hat, wird der dortige Teil ausgeführt, wenn die For-Schleife ohne Break durchläuft
zahlen = list(range(1, 101))
primzahlen = []
for zahl in zahlen: #Für jede 'Zahl' in den 'Zahlen': mach etwas...
print(zah... | true |
e672ee03c9844b2eceb437c9074c42d1fcf3cadf | Sdoof/Trapyng | /Examples/3.3 EURUSD_example/old version/3. main_TimeSeries.py | UTF-8 | 7,123 | 2.5625 | 3 | [] | no_license |
# Change main directory to the main folder and import folders
import os
import sys
base_path = os.path.abspath('')
sys.path.append(base_path + "/")
os.chdir("../../")
import import_folders
# Classical Libraries
import datetime as dt
import matplotlib.pyplot as plt
import numpy as np
import copy as copy
# Own graphica... | true |
c786648bce438c14d9dfb070ce4447a3e854a872 | domestos/python_lessons | /first_project/Lesson_String/lesson_Dictionary.py | UTF-8 | 591 | 3.8125 | 4 | [] | no_license |
# -------------------------------------------------
# (--------Item--------)
# (key) (value)
#
enemy = {
'loc_x':70,
'loc_y':50,
'color': 'green',
'health': 100,
'name': 'valera',
}
print(enemy)
print("location X = " + str (enemy['loc_x']))
print("location y" + str... | true |
9643848f114f5f18370b081a316ca0cb8427608b | seke626/insurance_tests | /palindrome_final.py | UTF-8 | 1,503 | 4.65625 | 5 | [] | no_license | #Problem #4 Palindrome
def reverse_sentence(sentence):
print ("Sentence: " ,sentence)
sentence = remove_whitespace(sentence)
return sentence[::-1]
def remove_whitespace(sentence):
strip = sentence.strip()
remove_space = strip.replace(" ", "")
sentence = remove_space
return sente... | true |
b1714c9c2c8fd3a668e97f076d5aaab4a4b99f00 | wangruichens/algorithms | /线段树.py | UTF-8 | 892 | 3.765625 | 4 | [
"Apache-2.0"
] | permissive | # leetcode 307
class NumArray(object):
def __init__(self, nums):
self.l = len(nums)
self.tree = [0] * self.l + nums
for i in range(self.l - 1, 0, -1):
print(i << 1, i << 1 | 1)
self.tree[i] = self.tree[i << 1] + self.tree[i << 1 | 1]
print(self.tree)
de... | true |
671c204a64d85a369e82ca04a74de9e684676eea | ibairos/MTPQuickMode | /qm-receive-simple-v2.py | UTF-8 | 3,097 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Receiver part for the Quick Mode competition of Team B
# This version uses STOP&WAIT with timeout if the ACK is not received
# It also uses CRC to ensure packet integrity
# Date: 10/04/2019
# Version: 1.0
import RPi.GPIO as GPIO
from lib_nrf24 import NRF24
import time
imp... | true |
d92918c3c627da10f93253b63f4b614488f338be | esarder/pyrobot | /robots/LoCoBot/circle_anim.py | UTF-8 | 1,256 | 3.21875 | 3 | [
"MIT"
] | permissive | import numpy as np
from matplotlib import pyplot as plt
import time
# Running script in conjuction with command to move robot
# Will have to subscribe to something that tells me when the robot *actually* starts to move
robot_started = True
velocity = 0.2
distance = 1.8
time_to_goal = distance/velocity
init_time = in... | true |
64c1456a3202076703ed9feff47684872bb73a72 | Jharvar/scripts | /saveInjection.py | UTF-8 | 2,129 | 3.328125 | 3 | [] | no_license | #!/usr/bin/python
# vamos a montar un script en python que sea una consola
# -*- coding: ascii -*-
import os,sys
import mysql.connector
import argparse
#lee el manual.txt que esta en el directorio raiz del script
def createManFile(self):
file='manual.txt'
with open(file,'w+') as reader:
for line in rea... | true |
7d2fe4ba6cab900b3d284a1cddbe171bbbe02b3a | ns408/practice_python | /book_python crash course/example_modules/my_car.py | UTF-8 | 578 | 3.5625 | 4 | [] | no_license | #!/usr/bin/env python3
from module2.car import Car, ElectricCar
"""
module1 is the directory in which car.py is present
# Another technique is adding it to the path.
import sys
sys.path.insert(1, '/path/to/application/app/folder')
import file
"""
my_car = Car("Ford", "Endeavour", 2020)
print(f"My car on gas: {my_car... | true |
63817f5e639b4b62449a1ea4c743d15ded1930eb | iamrahul-9/Python-College-Assignment | /Assignment_02.py | UTF-8 | 103 | 4.40625 | 4 | [] | no_license | for i in range(1,51):
if i%2==0:
print(f"Even {i}")
else:
print(f"Odd {i}") | true |
2b2f6228142ea5de09bd8343c73e4d791390b06d | GeekGianca/MininetPyFiles | /topo-multihost.py | UTF-8 | 915 | 2.59375 | 3 | [] | no_license | from mininet.topo import Topo
class MyTopo(Topo):
"Simple topology example."
def __init__(self):
"Create custom topo."
# Initialize topology
Topo.__init__(self)
# Add Host and Switches
Host0 = self.addHost('h0')
Host1 = self.addHost('h1')
Host2 = self.... | true |
69620f5015a704b3fb526b77e61671b7882d5023 | OChacon/ISProject | /projectDriver.py | UTF-8 | 4,529 | 2.75 | 3 | [] | no_license | """
Driver for the project files see readme for more information
Author: Mike Hurlbutt
"""
import reddit_download
import vectors
import SeparateData as seg
import support_vector_classify as svc
import random_forest_classify as rfc
import LSTM_classify as lstm
import os
import argparse
def download_Data_Vector():
... | true |
64f673f5a0943d7ffda553f8354253ecedd8c29e | Bhoomika-KB/Python-Programming | /lastlist.py | UTF-8 | 124 | 3.65625 | 4 | [] | no_license | # -*- coding: utf-8 -*-
#Create a list and remove last element from it.
list1=[1,2,3,4,5,6]
list1.remove(list1[-1]) | true |
28575cbdf2112af2a18f742a20c5b240c2060741 | borko81/Algorithms-Data-Structures-Python | /sortings/insertion_sort.py | UTF-8 | 379 | 3.8125 | 4 | [] | no_license | # O(N2)
# Slow, but it fast on small array 10 to 20
def insertion_sort(nums):
for i in range(len(nums)):
temp = i
while temp > 0 and nums[temp - 1] > nums[temp]:
nums[temp - 1], nums[temp] = nums[temp], nums[temp - 1]
temp -= 1
if __name__ == '__main__':
arr = [-4, 2, ... | true |
5b36e8589d39dc0e35396d8503bb6559cc4a8265 | haretaro/miniture.py | /HsiMod.py | UTF-8 | 1,056 | 2.640625 | 3 | [] | no_license | import numpy as np
import math
from PIL import Image
hsiTransform = np.array([
[1/math.sqrt(2),-1/math.sqrt(2),0],
[1/(math.sqrt(2)*math.sqrt(3)),1/(math.sqrt(2)*math.sqrt(3)),-2/(math.sqrt(2)*math.sqrt(3))],
[1/math.sqrt(3),1/math.sqrt(3),1/math.sqrt(3)]])
def getHsiModulationTransform(mod):
(h,s,v) = mod
hsiMo... | true |
2b1d2b7dd06e4897e0ba9840ab8385684c7f2c39 | Cao-Labs/SynthQA | /tools/SBROD/datasets/compute_scores.py | UTF-8 | 3,855 | 2.84375 | 3 | [
"BSD-2-Clause"
] | permissive | #!/usr/bin/python2.7
""""
This script measures the structural similarity between predicted
protein models and their corresponding native structures.
(A wrapper for running TMscore in multiple threads)
Dependency: the TMscore tool https://zhanglab.ccmb.med.umich.edu/TM-score
Usage: ./compute_scores.py <structures_pat... | true |
03e5f1d025b2b37529df20b7f61d88ce1cbfccd8 | ProjetRobotique/Projet | /tests/test_balise.py | UTF-8 | 3,950 | 2.90625 | 3 | [] | no_license | from PIL import Image
d1= {"green":(0,150,0), "red":(150,0,0),"blue":(34, 54, 91), "yellow":(230,230,0), "cyan":(0,255,255),"purple":(255,0,255), "white":(255,255,255), "black":(0,0,0)}
d= {"green":(99,134,97), "red":(130,66,57),"blue":(34, 54, 91), "yellow":(221,214,129), "cyan":(0,255,255),"purple":(255,0,255), "whi... | true |
7e5cf002086703e6d6942842e7607550de0851b6 | solmaro/200910766 | /Practice_WebData_Kospi200.py | UTF-8 | 370 | 2.78125 | 3 | [] | no_license |
# coding: utf-8
# In[2]:
import urllib
f=urllib.urlopen("https://www.google.com/finance/historical?q=KRX%3AKOSPI200&ei=sUjxV8maGYKT0gTOz7qoDA")
mydata=f.read()
import lxml.html
from lxml.cssselect import CSSSelector
html = lxml.html.fromstring(mydata)
sel = CSSSelector('#prices > table')
nodes=sel(html)
len(nodes)
... | true |
938ce3ef102b728b4f74115ad21f598f08a34a4f | titaneric/AutoDiff-from-scratch | /examples/regression/boston.py | UTF-8 | 1,438 | 2.578125 | 3 | [] | no_license | #pylint: disable=no-member
import warnings
from sklearn.datasets import load_boston
import matplotlib.pyplot as plt
import matplotlib.cbook
import autodiff as ad
from autodiff.utils.model_utils import Dataset, DataLoader, train_procedure
from autodiff.nn.optimizer import GradientDescent
from autodiff.nn.criterion imp... | true |
d487447c8beb721a7990a39b77db3cf848c26594 | Eastz0r/TimeChanger-1 | /utils.py | UTF-8 | 1,426 | 2.765625 | 3 | [
"MIT"
] | permissive | from PIL import Image, ImageFont, ImageDraw
from datetime import datetime
from pytz import timezone
import os
import config
def get_current_time():
return datetime.now(timezone('Europe/Moscow')).strftime('%H:%M')
def generate_image(text):
image = Image.open(os.getcwd() + config.photo_filename)
W, H = i... | true |
101ab5cf5afb9cb711b170b7739b6da1bfb09c00 | mrivoire/INRIA-Parietal-Intership | /Optimization_For_DataScience/Annales/Optimisation/Cours 6/optim_utils.py | UTF-8 | 4,334 | 3.375 | 3 | [] | no_license | """
Example cost functions or objective functions to optimize.
"""
import numpy as np
###############################################################################
# Gaussian functions with varying conditionning
def gaussian(x):
return np.exp(-np.sum(x**2))
def gaussian_prime(x):
return -2*x*np.exp(-np.su... | true |
4c2e35bbd9c8378d7b0148bd243bbd0b8d30105f | guomo233/GomokuAI | /player.py | UTF-8 | 1,539 | 2.90625 | 3 | [] | no_license | import copy
import abc
from mcts import *
from game import *
class Player (metaclass = abc.ABCMeta):
def __init__ (self, player_id):
self.player_id = player_id
@abc.abstractmethod
def __str__ (self):
pass
@abc.abstractmethod
def gen_action (self, board):
pass
class HumanPlayer (Player):
... | true |
79be3bbb3da01fc2ee9557ddd8f73e1e51e85ae4 | cassiorodrigo/python | /cadastros.py | UTF-8 | 1,085 | 3.703125 | 4 | [] | no_license | from datetime import date
count = 0
male = 0
female = 0
ano = date.today().year
maiores = 0
mmaiordeXanos = 0
while True:
count += 1
nome = str(input('Digite o Nome: '))
nascimento = int(input(f'Digite o ano de nascimento de {nome}: '))
sexo = str(input(f'Escolha o sexo de {nome} [M/F]: ')).strip().lowe... | true |
ec6a565e5d010ada6209c96a5b1b8df9c3e11149 | kylerisse/python-workout | /src/ch2_test.py | UTF-8 | 1,378 | 3.109375 | 3 | [] | no_license | #!/usr/bin/env python3
# pylint: disable=all
'''
Chapter 2 Tests
'''
import ch2
def test_pig_latin():
'''
test ch2.pig_latin()
'''
test_cases = {
'air': 'airway',
'eat': 'eatway',
'python': 'ythonpay',
'computer': 'omputercay',
}
for k, v in test_cases.items()... | true |
cde6c16ba5ff1a74ae44b1a346f5cb7bb9ec804e | NamanJn/FinalProject | /other_scripts/myClass.py | UTF-8 | 4,946 | 2.796875 | 3 | [] | no_license | import inspect
import cv2
import pdb
import numpy as np
import operator
ee = execfile
class Tracker(object):
def __init__(self,frame):
self.frame = frame
self.gray = cv2.cvtColor(frame,code=cv2.COLOR_BGR2GRAY)
self.gray_float = self.gray.astype("float32")
self.accumulator = self.... | true |
48b89a1566696e897f3a70e70ab40a49dbc39351 | nneonneo/eqgrp-free-file | /Firewall/BUZZDIRECTION/BUZZ_1210/SeconddateCnC/noarch/StoreFc.py | UTF-8 | 4,171 | 2.921875 | 3 | [] | no_license | #!/usr/bin/python
"""
This is wrapper for Store.py that FELONYCROWBAR will use. This
program takes an xml file as input. This xml file will contain
a series of configuration name value pairs. The xml file is in
this format (quotes escaped for inclusion in this comment block):
<BinStoreConfig>
<ConfigItem name=\... | true |
39fd8cfaa95f0c46063cb52ae3e8585372c1a818 | jhladka/PISKVORKY | /VERSION_2_WITH_TESTS/test_piskvorky.py | UTF-8 | 1,340 | 2.671875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Aug 3 12:57:06 2016
"""
import pytest
from mock import patch
import piskvorky
def test_vyhodnot():
assert piskvorky.vyhodnot('ooxxxooxoxox') == 'x'
assert piskvorky.vyhodnot('oooxxooxoxox') == 'o'
assert piskvorky.vyhodnot('ooxoxooxoxox') == '!'
assert piskv... | true |
e86e5ded5650d54ef14b1c3d36a935732a39fcf5 | Ruby-Dog/III | /人工智慧與機器學習/lab/9-5-lottery.py | UTF-8 | 558 | 3.9375 | 4 | [] | no_license | # def 函式定義 樂透彩
import random
def new_ticket():
t = set()
while len(t) < 7:
t.add(random.randint(1, 48))
return t
prize = new_ticket()
print("開獎號碼為: ", prize)
count = 0
while True:
lottery = new_ticket()
print("我買的樂透彩卷為: ", lottery)
count = count + 1
win = 0
for n in lottery... | true |
585f6506ab2461a46d51b3666ce52820cddaefd7 | Himanshuhub/Python | /python_fundamentals/Bike.py | UTF-8 | 874 | 3.703125 | 4 | [] | no_license | class Bike(object):
"""docstring for Bike."""
def __init__(self, price, max_speed, miles=0):
# super(Bike, self).__init__()
self.price = price
self.max_speed = max_speed
self.miles = miles
def displayInfo(self):
print "Bike info: Price $", self.price, " Maximum Speed:... | true |
0e815f5e33c896594faa892b847e0765c5bd4496 | nhuzaa/roboconDranzer | /lineFollower/takeGPIO.py | UTF-8 | 1,003 | 3.203125 | 3 | [] | no_license | import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
bit0Pin = 19
bit1Pin = 20
bit2Pin = 21
# Set up the GPIO channels
GPIO.setup(bit0Pin, GPIO.IN,pull_up_down=GPIO.PUD_DOWN) # This could be used to detect a switch
GPIO.setup(bit1Pin, GPIO.IN,pull_up_down=GPIO.PUD_DOWN) # This is going to supply the ... | true |
4a043a660dd93a12accb45d47434044296a355d1 | johnkbarrera/msmprofiles | /code/5-Resultados.py | UTF-8 | 12,071 | 2.671875 | 3 | [] | no_license |
# coding: utf-8
# # Análisis de Resultados (Generales)
# In[1]:
import numpy as np
import datetime
from datetime import date
import json
import pylab
import pandas as pd
import matplotlib.pyplot as plt
import os, sys
from sklearn.preprocessing import normalize
# In[2]:
import configparser
Config = configparser... | true |
0eacbda945f96ba230d3857b3f49da5c90097421 | andressl91/UiO | /Fenics/Nonlinear Poisson equation/Poisson.py | UTF-8 | 1,493 | 2.859375 | 3 | [] | no_license | # Solving nonlinear poisson equation
#-del * (q(u)del(u)) = f(u)
from dolfin import *
#Define mesh and functionspace
mesh = UnitIntervalMesh(10)
V = FunctionSpace(mesh, "CG", 1)
#Define functions in the equation
def q(u):
return 1.0+u
#Define boundary conditions
def left(x, on_boundary):
return x[0] < DOLFIN_EPS... | true |
999b1cbf70a188028399efc1db34554b3313a679 | zhaoke2018/leetcode-1 | /script/copy_old_code_to_Solutions.py | UTF-8 | 2,832 | 3.109375 | 3 | [] | no_license | '''
- 本文件用来合并同名 markdown 文件, 一次性使用.
- 之后可以用来学习或者代码参考
- 这里用到的 fuzzyfinder 值得学习一下
'''
import os
import re
import logging
class TransferCode():
def __init__(self):
self.sols = []
self.path_solution = os.path.join(os.getcwd(), 'Solutions') # getcwd() 是运行目录
self.path_old_code = os.path.join(os... | true |
c1bd3736c37b12ca6954ff1e1555602fef6751f1 | IlyaDzh/SevSU | /4 курс/7 семестр/ТОПК 3/Программа/main.py | UTF-8 | 3,903 | 2.75 | 3 | [] | no_license | import re
index = -1
consts = {}
# декоратор
def decorator_function(func):
def wrapper(*args, **kwargs):
try:
global index
index += 1
return func(*args, **kwargs)
except Exception as e:
return 0
wrapper.__name__ = func.__name__
return wrapper
def read_consts(name_file):
cons... | true |
4584b633f18f9b0d2de94a18fabb125ce086adea | sascho1993/asr-disfluency | /sony-egs/swbd_disfluency/switchboard_data/utils/get_duration_features.py | UTF-8 | 6,097 | 2.828125 | 3 | [] | no_license | """
This script generates duration features in 8 steps:
- phone id dictionary - phone id : phone name
- read kaldi alignments and store phone durations in dictionary - phone name : [dur1, dur2, dur3, ...]
- Get mean duration and std for each phone - phone name : [mean_dur, std]
- Store lexicon with all pronunci... | true |
53fc8ebbff4a412b040f6bdd6126ec11a85e25cd | ShelRoman/Python | /Sorter.py | UTF-8 | 1,420 | 3.40625 | 3 | [] | no_license | def bubble_sort(list_l):
while True:
is_changes_made = False
for i in range(1, len(list_l)):
if list_l[i] < list_l[i - 1]:
list_l[i], list_l[i - 1] = list_l[i - 1], list_l[i]
is_changes_made = True
if not is_changes_made:
break
retu... | true |
be0c15d9d8260143733ea8668a3f77be79e1b7eb | NikolasHofmann/pcc | /07-07-2021/avoid_index_errors.py | UTF-8 | 162 | 3.359375 | 3 | [] | no_license | cfood = ["burger", "fries", "pizza"]
try:
print(food[3])
except:
print(food[2])
#if you get index error try adjusting the indexes you
#are asking by 1
| true |
cde4f6243b1aa696ca9d583b8f60cb779bb8c9e5 | anmolkaur18/DSA_Team12_Uplift_Project | /Loops_Patterns_Print/InputOutput/RishabhVerma/Day1/P2.py | UTF-8 | 243 | 4.5625 | 5 | [] | no_license | # Take a I/P number, print its table
# (eg: if n=3: Print: 3x1=3 3x2=6 ... 3x10=30)
number=int(input("Enter the number "))
print("Table of {} is : ".format(number))
for i in range(1,11):
print( "{}x{}={}".format(number,i,number*i))
| true |
693da7c248fd3c54131bcd6a8273e680243ea848 | makhmudislamov/pythonExercism | /armstrong-numbers/armstrong_numbers.py | UTF-8 | 305 | 3.75 | 4 | [] | no_license | def is_armstrong_number(number):
string_num = str(number)
power = len(string_num)
total_sum = 0
for digit in string_num:
total_sum += int(digit) ** power
print(total_sum)
if total_sum != number:
return False
return True
print(is_armstrong_number(153))
| true |
56c2316cc26d6905e7f45f0b5590a2badbb14cd0 | Vwan/sicp-lamp | /execises/python/1.3.3_fixed_point.py | UTF-8 | 345 | 3.71875 | 4 | [] | no_license | import math
def fixed_point(f, x):
#print("--x---", x)
if abs(f(x)-x) < 0.0001:
return x
else:
#print("++f(x)+++", f(x))
return fixed_point(f, f(x))
print(fixed_point(math.cos, 1.0))
def average(x, y):
return (x + y) / 2
def sqrt(x):
return fixed_point(lambda y: average(y,... | true |
6c4dd18aa617335f0efc6e5171bb79c2e124ea08 | claimchain/muacryptcc | /muacryptcc/filestore.py | UTF-8 | 2,752 | 2.546875 | 3 | [] | no_license | import os
from base58 import b58encode, b58decode
import msgpack
from hippiehug.Nodes import Leaf, Branch
from claimchain.utils.wrappers import Blob
from hippiehug.Chain import Block
def key2basename(key):
return b58encode(key)
def basename2key(basename):
return b58decode(basename)
def default(obj):
... | true |
2f2cd53ae56e9c0ae485cc223fd9732c5200b20e | WeiBin0205/Neural-Networks-for-Solar-Radiation-Forecasting | /Single MLP/mlp_utils.py | UTF-8 | 2,688 | 2.734375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sat Nov 17 01:20:12 2018
@author: Giorgia Tandoi
"""
import pandas as pd
from sklearn.neural_network import MLPRegressor
import numpy as np
# convert series to supervised learning
def timeseries_to_supervised(data, r_inc, n_in=1, n_out=1, dropnan=True):
n_vars =... | true |
b398a9e2ddffc69a05babf20d919ea9b58d21066 | jslim7812/jslim7812 | /st01.Python기초/py42클래스/py42_09_FourCal/FourCal2.py | UTF-8 | 1,552 | 4.625 | 5 | [] | no_license |
# 작업 순서
# 1. 모듈 또는 클래스 import
# 2. 클래스명은 파스칼 표기법으로 정한다. 첫글자는 대문자로.
# 생성자 선언 : 인스턴스가 생성될 때 실행
# 소멸자 선언 : 소멸자는 인스턴스가 소멸할 때 실행
# __str__() 메서드 오버라이딩
# 접근자( getter ) 메서드 선언. 비공개 인스턴스 변수 읽기
# 설정자( setter ) 메서드 선언. 비공개 인스턴스 변수 수정
# 사용자 메서스 선언
# 3. main() 메서드 만들기
# 인스턴스 생성
# 4. 이 모듈이 단독으로 사용되면 mai... | true |
a77ee8983a42cdbbd6f990660bd10bb48f7d238e | ajoydas/alexa_contest_reminder | /crawler/Calendar.py | UTF-8 | 7,405 | 3.078125 | 3 | [] | no_license | """
Developed by
Sajid Samsad
samsadsajid@gmail.com
"""
from urllib.request import urlopen, Request
from bs4 import BeautifulSoup
from datetime import datetime
from collections import OrderedDict
import pytz
def process_list_header(_list):
header = [x.replace('\r', '').replace('\n', '').replace(' ', '') for x in _... | true |
4219d736d7f134fe37a5af8af2f35c70dd07c52a | Ancestry/VCFcontam | /estimateMixtureModel.py | UTF-8 | 2,289 | 3.234375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
from argparse import ArgumentParser
import pomegranate as pom
import numpy as np
import json
### Functions ###
def get_args():
parser = ArgumentParser(
description="Takes an array of less commonly observed allele fractions and returns a lognormal mixture model fitted to the allele... | true |
e51338695d29e51ca565ca93d02dfd1f298ff662 | tjsantos/wiktionary-explorer | /wikiparser.py | UTF-8 | 9,768 | 3.125 | 3 | [] | no_license | import json
import os
import re
import string
import sys
class Wikitext(str):
'''A string with extra helper methods to process wikitext'''
def filter_sections(self, *args):
r'''Return a new `Wikitext`, filtered by case-insensitive section titles in the order of the
given `*args` strings. Retur... | true |
b2ca54aade3cbeec673e8f842a852a0d1a4a2c9c | rajatdiptabiswas/competitive-programming | /CodeChef/MAXSC.py | UTF-8 | 711 | 3.375 | 3 | [] | no_license | #!/usr/bin/env python3
def main():
def max_less_than_target(list, target):
if target not in list:
list.append(target)
list.sort()
return list[list.index(target) - 1]
q = int(input())
for queries in range(q):
n = int(input())
array = [[0 for x in range(n)] for y in range(n)]
for i in range(n):
... | true |
9e00d469398903c6f81323e2e853d886f4d7e7c2 | letuan195/AI | /Lession4/gradient_descent.py | UTF-8 | 4,161 | 3.234375 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
class GradientDescent(object):
def __init__(self, X, y):
self.X = X
self.y = y
self.N = self.X.shape[0]
def func(self, a):
'''
cost function
:param a: coef
:return: value cost
'''
return ... | true |
b6588e9e7980b5afa65750a9502c1722bc432d66 | nwthomas/code-challenges | /src/leetcode/medium/unique-paths/unique_paths.py | UTF-8 | 1,099 | 3.78125 | 4 | [
"MIT"
] | permissive | """
https://leetcode.com/problems/unique-paths
There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1]). The robot can only move either down or right at any point in time.
Given the two in... | true |
551deeeb99b58909eea7ac3bd5fde3d7aa19db86 | maxqlord/Crypto | /Railfence-Encode/railfence.py | UTF-8 | 942 | 3.65625 | 4 | [] | no_license | #railfence.py
def prepare_string(s, alphabet, make_uppercase = True):
if make_uppercase == True:
s = s.upper()
for char in s:
if char not in alphabet:
s.replace(char, '')
s.replace(' ','')
s = ''.join(s.split())
return s
def railfence_encode(plaintext, alpha):
top =... | true |
4afd8a00bf118571f0eef1ba57063ddd48a39021 | hpzju/Python | /Metaprogramming/MetaClasses/class_methods.py | UTF-8 | 695 | 3.421875 | 3 | [] | no_license | class A:
a = 3
def __init__(self):
self.a, self.b = 1, 2
def imeth(self):
print(f'in imeth: {vars(self)}')
@classmethod
def cmeth(cls):
print(f'in cmeth: {vars(cls)}')
@staticmethod
def smeth():
print(f'in smeth: {A.smeth}')
if __name__ == '__main__':
... | true |
ea4aa2a7d8d4b7c8d604e392791119db34a7934d | diddi-/pymock | /tests/test_mock_object.py | UTF-8 | 2,155 | 3.09375 | 3 | [
"MIT"
] | permissive | from typing import Any
from unittest import TestCase
from pymock.action.return_action import ReturnAction
from pymock.mock_object import MockObject
class Blog:
def get_post(self):
pass
class TestMockObject(TestCase):
def set_value(self, obj: MockObject, value: Any):
obj._MockObject__PyMock... | true |
5e177d9c22255d0a5ce1a28a3674703e8066532a | raghvendraacharya95/vending_machine | /coffee_machine/beverage.py | UTF-8 | 153 | 2.671875 | 3 | [] | no_license | class Beverage:
def __init__(self, beverages_type, ingredients):
self.beverages_type = beverages_type
self.ingredients = ingredients
| true |
b7cddd17bb95a545294c6ff69491f24d73820813 | thomasly/neutrophil | /source/test/check_evaluation.py | UTF-8 | 1,248 | 2.765625 | 3 | [
"MIT"
] | permissive | import numpy as np
import logging
import tables as tb
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
logging.basicConfig(level=logging.INFO)
csv_file = open('epoch98_ResNet50_20181005_042643PM_tiles_76.csv', 'r')
hdf5_file = tb.open_file('../../data/test/tiles_76.hdf5', mode='r')
data = cs... | true |
1484636a201e28bee75586d54b4c29020cd62a88 | learnpythonfa/cracking_passwords | /hash_cracker.py | UTF-8 | 716 | 2.984375 | 3 | [
"MIT"
] | permissive | import hashlib
import string
from string import hexdigits
import time
txt = b'hellow'
tic = time.time()
hash_msg = hashlib.md5(txt)
toc = time.time()
alphabet = string.ascii_lowercase
alph = list(alphabet)
print(alph)
tic= time.time()
for i1 in alph:
for i2 in alph:
print(i1+i2)
for i3 in alph:
... | true |
3e8e6ce9d4fb207010a7b36528c67e77e630d14c | giosermon/holbertonschool-higher_level_programming | /0x0C-python-almost_a_circle/models/rectangle.py | UTF-8 | 3,412 | 3.78125 | 4 | [] | no_license | #!/usr/bin/python3
""" New class Rectangle """
from models.base import Base
class Rectangle(Base):
""" Class Rectangle that inherist from class Base """
def __init__(self, width, height, x=0, y=0, id=None):
""" Class construnctor """
super().__init__(id)
self.width = width
self... | true |
9682a63ea6a4fba5eb844f7ad6e74dd764405564 | sheetaljantikar/python-codes | /bianrytree.py | UTF-8 | 1,209 | 3.5 | 4 | [] | no_license | class Node:
def __init__(self,data):
self.left = None
self.right = None
self.data = data
class BinaryTree:
## def __init__(self):
## self.root = None
##
##
## def insert_node(self,root,element):
## if self.root is None:
## self.root = Node(element)
## ... | true |
0d6ebc099957cb75b5b84c8c00954cd0e379213e | Hemaditya/OpenBCIWebApp | /OpenBCIPython3/gameDataCollector.py | UTF-8 | 4,001 | 2.953125 | 3 | [] | no_license | import mneProgram as MNE
import pandas as pd
from pathlib import Path
import bandpower as b
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
import os
import sys
# Check if there are any command line argumnets
x = ""
if(len(sys.argv) == 2):
x = sys.argv[-1]
else:
x = input("Enter the sessi... | true |
e93b66d11a4da57dec5c9b277b3d6f334d64043a | MayankMaheshwar/DS-and-Algo-solving | /2395-find-subarrays-with-equal-sum/2395-find-subarrays-with-equal-sum.py | UTF-8 | 304 | 3.0625 | 3 | [] | no_license | class Solution:
def findSubarrays(self, nums: List[int]) -> bool:
sums = set()
for i in range(len(nums)-1):
t = nums[i]+nums[i+1]
if t in sums:
return True
else:
sums.add(t)
return False | true |
a933f35f7e7ea735d19b668ad2f3f1c08a98b7ce | wonnerky/codemaster | /ym/14/10989.py | UTF-8 | 151 | 3.203125 | 3 | [] | no_license | import sys
n= int(sys.stdin.readline())
s=[]
for i in range(n):
a=int(sys.stdin.readline())
s.append(a)
s=sorted(s)
for i in s:
print(i) | true |
7b4904f38bcf50102927f80c13ca611638645a63 | aksain/deep-learning-python | /nlp/spacy_nlp_demo.py | UTF-8 | 1,171 | 3.3125 | 3 | [] | no_license | # import SpaCy module
import spacy
# load English language model
nlp = spacy.load('en')
# Text needs to be in unicode string
doc = nlp(u'Haemophilia is a mostly inherited genetic disorder that impairs the body\'s ability to make blood clots, a process needed to stop bleeding')
print "\n\nSentences in the analysed te... | true |
fb800d8fcfd6783f15bc8e066decfbe8e18b0004 | rodrigogatti/ProjetoFinalDPDSOFT | /Teste/Jogo.py | UTF-8 | 34,230 | 2.53125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed May 23 00:45:49 2018
@author: mathe
"""
import pygame,sys,random,time
import menu
from firebase import firebase #armezando os dados em nuvem , usando Firebase
#-------------------------------------------------------------------------------------------------------------------... | true |
41f3cec7b4b8326dfbdeb5dbdcb1bdb31c59a8ce | bhargavaganti/horse_racing_etl_redshift_spark | /utils/truncate_redshift_tables.py | UTF-8 | 591 | 3.4375 | 3 | [] | no_license | from typing import List
def truncate_table(table_names: List[str], database_name: str, cursor, logger) -> None:
"""
Truncates a given table name against the database connection associated with the cursor object specified
as an argument.
"""
for table in table_names:
logger... | true |
2ad9c17fd4cf9a919baefbaa24ddfdec96b50ccd | CaveroBrandon/TicTacToe | /main.py | UTF-8 | 881 | 3.265625 | 3 | [] | no_license | # Tic tac toe game, not ussing IA, just random numbers
from tkinter import *
def fun_console_version():
root.destroy()
import TicTacToe_V1
def fun_gui_version():
root.destroy()
import TicTacToe_V2
def fun_exit():
root.destroy()
root = Tk()
root.title('TIC TAC TOE')
la... | true |
fc416722d917b533e6d01e42942f008a6b6552b6 | rupertbauernfeind/aiml | /PA2/src/utils.py | UTF-8 | 387 | 2.515625 | 3 | [] | no_license | from pathlib import Path
from sys import platform
def get_project_root(is_endbracket):
if is_endbracket and platform == 'linux':
root_path = str(Path(__file__).parent.parent.parent) + "/"
elif is_endbracket:
root_path = str(Path(__file__).parent.parent.parent) + "\\"
else:
root_pat... | true |
37cb65d7639bc91da9422aaf85d50a5503120e60 | stefie10/slu_hri | /pytools/vision/bin/flickr/flickr_test_images.py | UTF-8 | 1,687 | 2.65625 | 3 | [] | no_license | from glob import glob
from sys import argv
import cPickle
import Image
from scipy.misc.pilutil import *
from random import randint
from scipy import *
from pca import *
def get_random_indicies(num_elts, num_images):
I = {}
if(num_elts > num_images):
I = range(num_elts)
else:
done = False
... | true |
ffc1c4b46e61e361a071a44d5327b2d28533c9c8 | sethc23/BD_Scripts | /Projects/GAE/src/lib/django/django/utils/datastructures.py | UTF-8 | 8,374 | 3.40625 | 3 | [
"BSD-3-Clause",
"MIT",
"Apache-2.0"
] | permissive | class MergeDict(object):
"""
A simple class for creating new "virtual" dictionaries that actualy look
up values in more than one dictionary, passed in the constructor.
"""
def __init__(self, *dicts):
self.dicts = dicts
def __getitem__(self, key):
for dict in self.dicts:
... | true |
0f292f097cec443112a75fbd046e10c3fe6a2b12 | rioshen/Problems | /leetcode/python/reverse_words_in_a_string.py | UTF-8 | 461 | 3.453125 | 3 | [] | no_license | class Solution:
# @param s, a string
# @return a string
def reverseWords(self, s):
if not s:
return ""
else:
return ' '.join(s.strip().split()[::-1])
def reverseWords(self, s):
if not s:
return ""
s = s.strip().split()
lo,... | true |
597b7f96ad4d42495aff9a1eee7d159a415b7086 | daffaaflah6/Pemrograman_Jaringan_D | /progjar4c/Tugas_Kelompok_4c/server.py | UTF-8 | 3,755 | 2.890625 | 3 | [] | no_license | import socket
from _thread import *
import sys
from collections import defaultdict as df
import time
class Server:
def __init__(self):
self.rooms = df(list)
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
d... | true |
67c9197ffc40da53d9daafffd93e5487bb539fa8 | MatthewFoulk/cuttle | /src/Cuttle.py | UTF-8 | 33,116 | 3.109375 | 3 | [
"MIT"
] | permissive |
import sys
import random
import pygame
from CardGame import *
from Gui import *
class Player():
def __init__(self):
self.hand = []
self.pointsCards = []
self.permCards = []
self.jacks = {} # Dictionary with card keys that have list of jack cards attached to them
self.sc... | true |
b913d539cd92fedb9a750feb351dcb4f7c9ab5ec | earth25559/Swift-Dynamic-Test | /Number_1/to_do/myapp/templatetags/message_tags.py | UTF-8 | 701 | 2.578125 | 3 | [] | no_license | # Use datetime if not localizing timezones
import datetime
# Otherwise use timezone
from django.utils import timezone
from django import template
register = template.Library()
@register.filter
def hours_ago(time, hours):
return (time - timezone.now()+datetime.timedelta(hours=7) + datetime.timedelta(hours=24) < ... | true |
a43cd3080d812678cd2609bd46afe017cf1a2241 | jetakasabaqi/Great-Number-Game | /server.py | UTF-8 | 1,476 | 2.8125 | 3 | [] | no_license | from flask import Flask, render_template, request, redirect,session,flash
import random
app = Flask(__name__)
app.number = random.randint(1,100)
app.secret_key = 'secretkey'
@app.route('/')
def index():
game_info = {
"message": None,
"css_class": None
}
if 'generated' not in session:
... | true |
c08a2eb8f03a77fcc6070c599d9461037d1915cc | ravishankar920/class-ladst | /88.py | UTF-8 | 392 | 3.875 | 4 | [] | no_license | i=int(input("enter a number"))
j=int(input("enter a numaber"))
o=input("which operation you want =,-,*,/ ")
def add(i,j):
return i+j
def sub(i,j):
return i-j
def mul(i,j):
return i*j
def div(i,j):
return i/j
if(o==+):
print("addition =",add(i,j))
elif(o==-):
print("subtraction =",sub(i,j))
elif(o==*):
print(... | true |
ed20d942c510700ed10ffdea5f84afb1d3c78179 | qiaolunzhang/download-helper | /getfile_simple.py | UTF-8 | 1,529 | 2.671875 | 3 | [] | no_license | import requests
from bs4 import BeautifulSoup
import os
def get_ref(start_url):
try:
kv = {'user-agent': 'Mozilla/5.0'}
r = requests.get(start_url, headers=kv)
r.raise_for_status()
except:
print("failed to get the start url")
return
text = r.text
... | true |