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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
d3e90712532f223c731261ae02a9cc44e99a4012 | Python | StBogdan/PythonWork | /Leetcode/1396.py | UTF-8 | 1,598 | 3.578125 | 4 | [] | no_license | from collections import defaultdict
from typing import Dict, Tuple
# Name: Design Underground System
# Link: https://leetcode.com/problems/design-underground-system/
# Method: 2 dictionaries, started journeys and a dict of pairwise of averages
# Time: O(1)
# Space: O(n)
# Difficulty: Medium
Id = int
Station = str
Ti... | true |
bc4316cb46b2daf90827c1b1e08849ab14a3c94c | Python | DonaldButters/Pytho134 | /module3/strings1.py | UTF-8 | 108 | 3.203125 | 3 | [] | no_license | x = 'Peter Parker in Spiderman'
x = str.capitalize('Peter Parker in Spiderman')
print (x)
word= 'Peter Parker in Spiderman'
print(word.find('er',1))
| true |
8ad18853fd5d0332a544a45fdf8afa9e89caddf1 | Python | WikimediaOIT/wikiosk | /osx-hide-mouse.py | UTF-8 | 802 | 2.828125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/python
"""
Move mouse to edge of screen
"""
# osx libraries for mouse control and display sizes
# mouse control
from Quartz.CoreGraphics import CGEventCreateMouseEvent
from Quartz.CoreGraphics import kCGMouseButtonLeft
from Quartz.CoreGraphics import CGEventPost
from Quartz.CoreGraphics import kCGEventMou... | true |
b8ac538a5eb31d6e0118b7b77c67762641a9f0f8 | Python | feng1510/self_driving_car_nd | /term1/P4-Advanced-Lane-Lines/tools/find_perspective_transform.py | UTF-8 | 6,435 | 2.96875 | 3 | [] | no_license | """Helper tool to find perspective transform for birds-eye-view.
Let the user select perspective source points in an image with lanes lines,
and then measure lines dash length and lane width, which provides for
calculation of perspective transformation matrix. The calculation assumes
lane properties as in the USA, see... | true |
906946854561c55fe142abd380f478263edd32b8 | Python | ali-jozaghi/app | /src/common/validators.py | UTF-8 | 381 | 3.09375 | 3 | [] | no_license | import re
def is_none(value) -> bool:
return value is None
def empty_or_none_string(value) -> bool:
return is_none(value) or (str(value).strip() == "")
def not_int(value) -> bool:
return is_none(value) or not isinstance(value, int)
def not_valid_email(value) -> bool:
return is_none(value) or not... | true |
0af790dbed8a3d175a01ea7e9601db36d5d73554 | Python | ZeroPage/algorithm_study2013 | /hashing/yeongjuncho.py | UTF-8 | 100 | 2.53125 | 3 | [] | no_license | #Skywave
data = raw_input().split('$')
print int(data[0][::-1]) + int(data[2][::-1]) + int(data[1]) | true |
5dffaabdc1f6369217dbe604d441a9f0b6083a8f | Python | josueibecerra/Hippotherapy-Simulator-Code | /feedbackloop.py | UTF-8 | 1,744 | 3.15625 | 3 | [] | no_license | import RPi.GPIO as GPIO
import time
rpm = 0
power_output=0
sensor = 40 # define the GPIO pin our sensor is attached to
sample = 20 # how many half revolutions to time
count = 0
start = 0
end = 0
desired_rpm = 1500
GPIO.setmode(GPIO.BOARD) # set GPIO numbering system to BOARD
GPIO.setup(sensor, GPIO.IN) # set ... | true |
b37ce7dccb6d42e6b23d4633b700db583c3d967c | Python | lkreidberg/WASP33_HST12495 | /multiply_sines_bad/vis_1/fit_funcs/models/sine2.py | UTF-8 | 349 | 2.515625 | 3 | [] | no_license | import sys
sys.path.insert(0,'..')
from read_data import Data
import numpy as np
def sine2(t, data, params):
a1, omega1, phi1, a2, omega2, phi2 = params
#FIXME data.t_vis won't work if there are multiple visits
return ( 1. + a1*np.sin(omega1*data.t_vis + phi1) ) * \
( 1. + a2*np.sin(omega2*data... | true |
c1225dc7d69d1134ad94a7d79b07bb8a912f0a9d | Python | HodaeSsi/Algorithm | /패스트캠퍼스_유형별문제풀이(인강)/백준1920_수찾기_PY.py | UTF-8 | 193 | 2.890625 | 3 | [] | no_license | N = int(input())
n = set(map(int, input().split(' ')))
M = int(input())
m = list(map(int, input().split(' ')))
for i in m:
if i in n:
print(1)
elif i not in n:
print(0) | true |
71d3d2c465f04f2580bdeb82143a76fdd995bd0d | Python | XuYan/u_programming_language | /fundamental/fsm_simulator.py | UTF-8 | 469 | 3.203125 | 3 | [] | no_license | # FSM Simulation
edges = {(1, 'a') : 2,
(2, 'a') : 2,
(2, '1') : 3,
(3, '1') : 3}
accepting = [3]
def fsmsim(string, current, edges, accepting):
if string == "":
return current in accepting
else:
letter = string[0]
if (current, letter) not in edges:
... | true |
9aec7c84f7c6e5535bb64ffdbbc97c7059143c97 | Python | BurntBrunch/pydiskmonitor | /src/parse.py | UTF-8 | 1,839 | 3.359375 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
from pyparsing import Word, Optional, ZeroOrMore, alphanums, Literal, StringEnd
def parse_rule(rule):
""" Given a rule string, return a key-value pair """
result = []
def got_pair(tokens):
result.append(tuple(tokens[-2:]))
possibleChars = alphanums+"_-/^... | true |
8c14175fcf6f2e8e8ae6cae79fa94a34b5677870 | Python | MengyingGIRL/python-100-days-learning | /Day04/for3.py | UTF-8 | 243 | 3.65625 | 4 | [] | no_license | '''
输入非负整数n计算n!
@Time : 2020/1/8 9:21
@Author : wangmengying
@File : for3.py
'''
n = int(input('请输入非负整数:'))
if n <= 0:
print('输入错误!')
result = 1
for i in range(1,n+1):
result *= i
print(result) | true |
592a0700088b081b926c51d00b59e23f8b726cfd | Python | shamanu4/biltv | /src/app/tv/roll.py | UTF-8 | 1,721 | 3.359375 | 3 | [] | no_license | # To change this template, choose Tools | Templates
# and open the template in the editor.
class Roll():
def __init__(self):
self.cash = 100
self.bid = [None,None]
self.black = (1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36)
self.red = (2, 4, 6, 8, 10, 11, 13, ... | true |
a8c500d66b3d9699d6acb16648a2cedbf539c326 | Python | spsrathor/Data-Structures-By-Python | /Array/Minimum distance between two numbers.py | UTF-8 | 412 | 2.90625 | 3 | [] | no_license | def minDist(arr, n, x, y):
# Code here
r=-1
if (x in arr) and (y in arr):
xl = []
diff = []
for i in range(len(arr)):
if x==arr[i]:
xl.append(i)
for i in range(len(arr)):
if y==arr[i]:
temp = xl
temp = [a... | true |
d982e4da7ea96f2c134b9ae6373c372eff2ba920 | Python | nmala001/restaurant_menu_project | /app.py | UTF-8 | 230 | 2.9375 | 3 | [] | no_license | import sqlite3
connection = sqlite3.connect("restaurantmenu.db")
cursor = connection.cursor()
cursor.execute("SELECT * FROM restaurant")
results = cursor.fetchall()
for r in results:
print(r)
cursor.close()
connection.close() | true |
adbe1698891adb232526a84be03ecdc0be400d56 | Python | kjappelbaum/oximachine_featurizer | /run/run_featurization.py | UTF-8 | 536 | 2.546875 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
"""Run the featurization on one structure"""
import click
import numpy as np
from pymatgen import Structure
from oximachine_featurizer import featurize
@click.command("cli")
@click.argument("structure")
@click.argument("outname")
def main(structure: str, outname: str):
"""CLI function"""... | true |
6beaa6b424fdafd9a9911cb291f0d039bd58a1a9 | Python | tejaskannan/block-sparse-dnn | /blocksparsednn/analysis/energy_comparison.py | UTF-8 | 2,107 | 2.875 | 3 | [] | no_license | import csv
import os.path
import numpy as np
from argparse import ArgumentParser
from collections import defaultdict
from blocksparsednn.utils.file_utils import iterate_dir
NUM_SAMPLES = 15
BLOCK_DIAG = 'block_diag'
SPARSE = 'sparse'
DENSE = 'dense'
def get_energy(input_path: str) -> float:
energy = 0.0
w... | true |
d3be0da2d59cf788a8e2a4a0ef22faaa9eca5a08 | Python | mashbes/lesson27 | /habrparse.py | UTF-8 | 1,261 | 2.625 | 3 | [] | no_license | import lxml.html as html
from urllib.request import urlopen
import requests
import json
main_domain_stat = 'https://habr.com/'
data = []
main_page = html.parse(urlopen(main_domain_stat)).getroot()
article_links = main_page.xpath(
'//li/article[contains(@class, "post")]/h2[@class="post__title"]/a[@class="... | true |
80b8c5f119b6e60ad73fe0380aacc20e05ecf08d | Python | FrancescoPenasa/UNITN-CS-2018-Intro2MachineLearning | /exercise/exercise9.py | UTF-8 | 5,505 | 3.546875 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 14 17:50:04 2019
@author: francesco
Given the iris dataset CSV file,
apply the k-nearest neighbors algorithm to all the elements of the dataset
using k ∈ {3, 5, 10, 20} and build the confusion matrix.
Using the confusion matrix, compute total ... | true |
b2918b72727e3014e681b6e0b35fe840af6b439f | Python | cqlouis/MyoPS20-HNU | /stage_2/network_architectures.py | UTF-8 | 9,917 | 2.59375 | 3 | [] | no_license | ''' Neural net architectures '''
from tensorflow.python.keras.layers import Input, LeakyReLU, BatchNormalization, \
Conv2D, concatenate, Activation, SpatialDropout2D, AveragePooling2D, Conv2DTranspose, Flatten, Dense, Conv2D, Lambda, Reshape, add, SeparableConv2D, MaxPooling2D, UpSampling2D, GlobalAveragePooling2D... | true |
7cfb81ba1b087ec5d01e1c705ebcebf46317ae13 | Python | pablocelis/K-means-algorithm | /k-means.py | UTF-8 | 2,882 | 3.265625 | 3 | [
"Unlicense"
] | permissive | from numpy import matrix
import numpy as np
import random
import collections
# findClosestCentroids(X, centroids) returns the index of the closest
# centroids for a dataset X where each row is a single example.
# idx = m x 1 is a vector of centroid assignments
# (i.e., each entry in range [0..k-1]... | true |
f3c91097059d2ec16eb7b2dd5fdbf5f9d3334517 | Python | rongyafeng0410/test0001 | /hello.py | UTF-8 | 328 | 2.921875 | 3 | [] | no_license | import unittest
def divid(num1, num2):
return num1 / num2
class MyTest(unittest.TestCase):
def test1(self):
assert (divid(1, 1) == 1)
def test2(self):
assert (divid(0, 1) == 0)
def test3(self):
assert (divid(2, 3) == 0)
print("hello")
if __name__ == "__main__":
unittest... | true |
3a79cad17cbb1747e197cb52a6f46345f5b06924 | Python | johanvandegriff/quest | /tmp.py | UTF-8 | 452 | 3.5625 | 4 | [
"MIT"
] | permissive | #!/usr/bin/python
def memoize(f):
m = {}
def h(*x):
if x not in m:
m[x] = f(*x)
print m
return m[x]
h.__name__ = f.__name__
return h
def plus1(f):
def h(x):
return x *2
return h
def strings(f):
def h(x):
return str(x) + "hi"
return h
@memoize
def fib2(a, b):
if a == 0:
... | true |
e7a8400633574bc5a073afbf7eb5bed01fda63e9 | Python | caoxp930/MyPythonCode | /类/code/单例模式new.py | UTF-8 | 760 | 3.625 | 4 | [] | no_license | # -*- coding: utf-8 -*-
# __new__
class Earth:
def __new__(cls, *args, **kwargs):
if not hasattr(cls, 'instance'): # 如果我的类没有实例对象,那我就去new一个实例对象
cls.instance = super().__new__(cls)
return cls.instance
def __init__(self):
self.name = 'earth'
e = Earth()
print(e)
a = Earth()... | true |
c75386693a933c2a33ad01a143d2cf74579ccec7 | Python | alexaugustobr/impacta-desenvolvimento-aplicacoes-distribuidas | /Client.py | UTF-8 | 3,007 | 2.75 | 3 | [] | no_license | import requests as req
url = "http://localhost:5000/alunos"
print("Cadastrando alunos")
aluno = {"ra":"1700072", "nome":"Alex Augusto"}
print(req.api.post(url, json=aluno).json())
aluno = {"ra":"1700693", "nome":"Cinthia Queiroz"}
print(req.api.post(url, json=aluno).json())
aluno = {"ra":"1700381", "nome":"Michael... | true |
2c80e9e195d3eb832159f05deff175060fab1b73 | Python | heping945/pythonbackend | /python3基础/6 生成器与协程.py | UTF-8 | 818 | 3.625 | 4 | [] | no_license | __author__ = 'pinge'
# 1 什么是生成器
def xx():
yield 'hello'
yield 'world'
x=xx()
print(next(x))
print(next(x))
# 2 基于生成器的协程(python2)
def coro():
hello = yield 'hello' #yield 在右作为表达式,可以被send值
yield hello
c = coro()
print(next(c)) #输出hello ,这里调用next产出第一个值hello 之后函数暂停
print(c.send('world')) ... | true |
4d7a6bc69daf7c5fd097b4949e43d3534f3024a2 | Python | jawad5311/100-Days-Python | /intermediate-Day15-to-Day32/Day_28-Pomodoro_app/main.py | UTF-8 | 3,844 | 3.59375 | 4 | [
"Apache-2.0"
] | permissive |
import math
import tkinter
# CONSTANTS
PINK = "#e2979c"
RED = "#e7305b"
GREEN = "#9bdeac"
YELLOW = "#f7f5dd"
FONT_NAME = "Courier"
WORK_MIN = 25
SHORT_BREAK_MIN = 5
LONG_BREAK_MIN = 20
reps = 0
timer = None
# ---------------------------- TIMER RESET ------------------------------- #
def reset_timer():
""" R... | true |
4c67e48babab4d8cb6a2f57d4d97841449ab1f19 | Python | Marou-Hub/myfirstproject | /learnPython/text1.py | UTF-8 | 381 | 4.21875 | 4 | [] | no_license |
def main():
# creation d'une variable 'username' ayant pour valeur le mot Graven
username = "Graven"
username = "YouTube"
# creation d'une variable 'age' ayant pour valeur 19
age = 19
# change la valeur par 25
age = 25
# afficher la nouvelle valeur
age = age * age
print("Salut "... | true |
b9aa02d3746aea0ece53063baada75e3ea378cf8 | Python | MicrohexHQ/opencoin-historic | /sandbox/mathew/fraction/protocols.py | UTF-8 | 48,857 | 3 | 3 | [] | no_license | """
Protocol have states, which are basically methods that consume messages, do
something and return messages. The states are just methods, and one state
might change the state of its protocol to another state.
A protocol writes to a transport, using Transport.write. It receives messages
from the transport with Proto... | true |
404fd6560db9679e71c08e56cb590b79070a852a | Python | hazardland/train.py | /poloniex/public.py | UTF-8 | 780 | 2.8125 | 3 | [] | no_license | from urllib import request
from datetime import datetime
class InvalidPeriond(Exception):
pass
def returnChartData(currencyPair, start, end, period=300):
if period not in (300, 900, 1800, 7200, 14400, 86400):
raise InvalidPeriond
if isinstance(start, str):
start = int(datetime.strptime(st... | true |
67377118c0977f4313aa98963d457804a7373435 | Python | CormacMOB/UnixCommands | /head.py | UTF-8 | 2,773 | 3.09375 | 3 | [] | no_license | from docopt import docopt
import fileinput
import sys
# Docopt configuration string. See Docopt.org.
doc ="""
Usage:
head1.py [-c <N>| -n <N>] [-q | -v] [FILENAME...]
head1.py [FILENAME...]
Options:
-c <N>, --bytes=N print the first N bytes of each file
-n <N>, --lines=N
-q, --quiet
-v, --... | true |
e4c1c1f57c88c01a4d2399530646a94564572021 | Python | maxotar/algorithms | /algorithms/insertionSort.py | UTF-8 | 255 | 3.078125 | 3 | [
"MIT"
] | permissive | def insertionSort(alist):
for endpoint in range(len(alist) - 1):
for i in range(endpoint, -1, -1):
if alist[i] > alist[i + 1]:
alist[i + 1], alist[i] = alist[i], alist[i + 1]
else:
break
| true |
f193f642845923b49550b594d2f28c10248c8924 | Python | emanoelmlsilva/Lista-IP | /exercicio03/uri1018.py | UTF-8 | 590 | 3.1875 | 3 | [] | no_license | n = int(input())
c = 100
l = 50
t = 20
x = 10
v = 5
d = 2
u = 1
if((n>0) and (n<1000000)):
resc = n // c
n = n%c
resl = n // l
n = n%l
rest = n // t
n = n%t
resx = n // x
n = n%x
resv = n // v
n = n%v
resd = n // d
n = n%d
resu = n
print('{} nota(s) de R$100,00'.forma... | true |
70d049b3fa8384fc527c4f5458af458d9d0a248d | Python | AP-MI-2021/lab-4-AdrianSK75 | /assignment_4.py | UTF-8 | 2,360 | 3.96875 | 4 | [] | no_license | def hiding_repeted_chars(lst):
result = []
for i in lst:
if i not in result:
result.append(i)
print(result)
def find_the_str(string, lst):
if any(string in word for word in lst):
print("Yes")
else:
print("No")
def find_repeated_string(lst):
frq = {}
max_... | true |
ab65127c8dad0c6f36b9ffc847450b48b07bfacc | Python | engrborhanbd/Frequent-Itemset-Mining | /association_rules/frequent_itemset_mining.py | UTF-8 | 16,470 | 2.78125 | 3 | [] | no_license | import pycuda.driver as cuda
from pycuda.compiler import SourceModule
import numpy as np
class FrequentItemsetAlgorithm():
"""Base class"""
def __init__(self):
self.support_dict = {} # records all frequent itemset
self.TXs_amount = 0
self.TXs_sets = []
self.item_sets = set()
... | true |
9c6b0d3e888e73e7f85c1dfe4245c75d953577d0 | Python | asmodeii/Bomberman | /framework/core.py | UTF-8 | 1,380 | 3.234375 | 3 | [] | no_license | import pygame
class GameHandler:
def handle_input(self, event):
pass
def handle_draw(self, canvas):
pass
def handle_update(self, dt):
pass
# noinspection PyMethodMayBeStatic
def running(self) -> bool:
return True
class Game:
def __init__(self, handler: Game... | true |
1516fab2e15c37b44911d3522f8135f0a453b37a | Python | peterwinter/boxcluster | /boxlist.py | UTF-8 | 7,536 | 3.3125 | 3 | [
"MIT"
] | permissive | from collections import abc
from itertools import permutations
from .mixins import FitnessEqualitiesMixin
import random
import numpy as np
class BaseBoxList(abc.MutableSequence, FitnessEqualitiesMixin):
""" basic class functionality """
def __init__(self, boxes=[], fitness=np.inf):
self.boxes = boxes
... | true |
4db1b17608f72de3cae19c9e5a4799b399ae6e5c | Python | Rpratik13/HackerRank | /pangram.py | UTF-8 | 252 | 3.484375 | 3 | [] | no_license | def checkPangram(s):
check = [False] * 26
for i in range(len(s)):
if s[i].isalpha():
check[ord(s[i]) - 97] = True
if all(check):
return "pangram"
else:
return "not pangram"
s = input();
print(checkPangram(s.lower())); | true |
6da8d45397e5e7b60dab534486a6a71c588ba76c | Python | safoyeth/basher | /source/basher.py | UTF-8 | 6,061 | 2.71875 | 3 | [] | no_license | #! /usr/bin/python
# -*- coding: utf-8 -*-
############################################################################
# basher - easy parser of bash.im runet quoter #
# Copyright (C) 2014 Sergey Baravicov aka Safoyeth #
# ... | true |
be103af19de69f49f264195c6f8d96065766b77e | Python | zhangguol/Udacity-FullStack-Project1 | /entertainment_center.py | UTF-8 | 578 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env python
# encoding: utf-8
from media import Movie
from fresh_tomatoes import open_movies_page
idenity = Movie(
"Identity",
"http://goo.gl/K4HIeh",
"https://www.youtube.com/watch?v=S8fjyxM7DgU",
"2003"
)
the_prestige = Movie(
"The Prestige",
"http://goo.gl/Bj06fy",
"https://w... | true |
4ea5bd645194e8952c214603a5a2b71292accb3b | Python | ilanguev/mongodb | /test.py | UTF-8 | 455 | 2.734375 | 3 | [] | no_license | #!/usr/bin/python
from pymongo import MongoClient
import uuid
client = MongoClient('mongodb://10.244.41.118:27017')
db = client.myDB
posts = db.posts
post_data = {
'title': 'Python and MongoDB',
'content': 'PyMongo is fun, you guys',
'author': 'Scott'
}
for i in xrange(1,1000000)... | true |
1c575a7b4e17b3c5f9a23f13302f07b3348e48c3 | Python | natakhatina/file | /file_script.py | UTF-8 | 345 | 3.453125 | 3 | [] | no_license | import math,random
def fooCos(x):
yield math.cos(x)
def fooSin(x):
yield math.sin(x)
def foo(n):
x=random.randint(0,180)
x=x* math.pi/180
for i in range(n):
if x%2==0:
a=fooSin(x)
yield next(a)
else:
a=fooCos(x)
yield next(a)
L=[x f... | true |
c85baa0eb0205f25354733518d4d4e0446bdeb19 | Python | taddeus/advent-of-code | /2019/20_donutmaze.py | UTF-8 | 2,131 | 3.265625 | 3 | [] | no_license | #!/usr/bin/env python3
import sys
from collections import deque
from itertools import chain
def read_grid(f):
rows = [line.replace('\n', '') for line in f]
return list(chain.from_iterable(rows)), len(rows[0])
def find_labels(grid, w):
def get(i):
return grid[i] if 0 <= i < len(grid) else ' '
... | true |
04862d762b56e17f8beb8e84fe345162b61bf825 | Python | ouuzannn/BlackAs---Game-Ular | /main.py | UTF-8 | 8,521 | 2.796875 | 3 | [] | no_license | import pygame
import sys
import random
import TombolMenu,MenuGame
from konstanta import *
class Ular():
def __init__(self):
self.PanjangUlar = 1
self.letakUlar = [((lebar_layar/2), (tinggi_layar/2))]
self.arahUlar = random.choice([atas, bawah, kiri, kanan])
self.nilai = 0
... | true |
5c7b10c4e91819adfa2f7fb194f6a0c2983dc68f | Python | amitarvindpatil/DjangoFrameworkStuff | /ORM.py | UTF-8 | 2,041 | 3.625 | 4 | [] | no_license | # ORM - Object Relational Mapper
# Defin Data Modules Entirely in Python.You get Dynamic database-access API for Free
# A Model is the single,definative source of information about your data.
# It contains the required field to store your data Generally each maodel map to a single database table
# The Basic
# -Each Mo... | true |
100a4dc28a007372c673c30e1079e3c6291e2488 | Python | hishark/Algorithm | /LEETCODE/7_整数反转.py | UTF-8 | 446 | 2.765625 | 3 | [] | no_license | class Solution(object):
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
if x == 0:
return 0
temp = ''
if x < 0:
temp += '-'
x = -x
s = str(x)[::-1]
if s[0] == '0':
s = s[1:]
temp +=... | true |
9c85960955bfb54175b9b8d841154ca6676f6c78 | Python | nepomnyashchii/TestGit | /old/final1/03/put.py | UTF-8 | 725 | 2.671875 | 3 | [] | no_license | import mysql.connector
import time
import uuid
print("Please wait...")
msg = "time3"
exp = 600
pin = 1234
sid = str(uuid.uuid4())
mytime=time.strftime('%Y-%m-%d %H:%M:%S')
return_value = ''
try:
mydb = mysql.connector.connect(
host="db4free.net",
user="coolspammail",
passwd="coolspammail... | true |
c347c5315c616d6b4251a83474e7989179854579 | Python | sravankr96/kaggle-fisheries-monitoring | /src/model_archs/localizer_as_regr.py | UTF-8 | 2,914 | 2.875 | 3 | [] | no_license | """
Copyright © Sr@1 2017, All rights reserved.
*The module contains the architecture of a localization network
*Network is built analogous to VGG network
*The Hyper parameters of the network are passed from the /tasks/localizer.py module
"""
from keras.models import Sequential
from keras.layers impor... | true |
54d001367dcdf7d330245ff52d80c86c9f4e89e6 | Python | littleironical/HackerRank_Solutions | /Python/Set .discard(), .remove() & .pop().py | UTF-8 | 320 | 3 | 3 | [] | no_license | n = int(input())
a = set(map(int, input().split()))
m = int(input())
for _ in range(m):
command = list(input().split())
if command[0] == "pop":
a.pop()
elif command[0] == "remove":
a.remove(int(command[1]))
elif command[0] == "discard":
a.discard(int(command[1]))
print(sum(a))
| true |
1ff17395be20229cfe6b5216f61b7c2e7d63b774 | Python | miguel-pessoa/VI | /scripts/lineData.py | UTF-8 | 798 | 3.1875 | 3 | [] | no_license | import pandas as pd
years = [2016, 2017, 2018, 2019, 2020]
dfs = []
def dfYear(start_df, year):
col = f'happiness_score_{year}'
df = happy_df[['country', col]]
df = df.rename(columns={col: "happy"})
df['year'] = year
print(df.head())
return df
# Read data
happy_df = pd.read_csv('data/final/... | true |
a172a02092cb7359ad15112513131a346b3f5f28 | Python | march-saber/UI- | /PO_v1/TestCases/test_login.py | UTF-8 | 3,058 | 2.65625 | 3 | [] | no_license | import unittest
from selenium import webdriver
import ddt
from PO_v1.PageObjects.longin_page import LoginPage
from PO_v1.PageObjects.index_page import IndexPage
from PO_v1.TestDatas import login_datas as id
from PO_v1.TestDatas import Comm_Datas as cd
#用例三部曲:前置、步骤、断言
@ddt.ddt
class TestLogin(unittest.TestCase):
@... | true |
6329d2e7d01a5392545cd0e8d5cd4a7e849c81ff | Python | Susaposa/Homwork_game- | /solutions/5_methods.py | UTF-8 | 5,410 | 4.59375 | 5 | [] | no_license | # REMINDER: Only do one challenge at a time! Save and test after every one.
print('Challenge 1 -------------')
# Challenge 1:
# Uncomment the following code and fix the typos to practice using the list
# methods. If correct, we should see Shrek, Frozen, Titanic in that order.
my_fave_movies = []
my_fave_movies.appen... | true |
168188f6b996f858f1b68b3b5fc3d83f7532f4f2 | Python | xys234/coding-problems | /algo/array/find_resolved_interval.py | UTF-8 | 1,276 | 3.609375 | 4 | [] | no_license | """
Find "resolved" interval, resolved marked as 1. input [0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1] output [(2,4), (7,7), (9,10)]
Find the start and ending indices of consecutive resolved interval
Facebook Infra DS phone interview
"""
class Solution:
def find_resolved_interval(self, intervals):
i = 0
... | true |
a19f44c08eeb59110576eae0a500e1e348386b3d | Python | IvanVuytsik/RunnerGame_pygame | /Game.py | UTF-8 | 9,034 | 2.734375 | 3 | [] | no_license | import pygame
from sys import exit
from random import randint
def display_score():
current_time = int(pygame.time.get_ticks()/1000) - start_time
score_surface = test_font.render(f'Score{current_time}',False,(64,64,64)) #f string conversion
score_rect = score_surface.get_rect(center=(400,50))
screen.bli... | true |
3306e33874fac796ef1cb4899b129275ff836fd6 | Python | samhofman/AirlinePlanning | /NetworkScheduling/Assignment 1/Functions_P1.py | UTF-8 | 2,026 | 3.21875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Feb 26 15:09:28 2019
@author: hofma
"""
import xlsxwriter
from Data import *
### Make cost matrix ###
cost = np.zeros(shape=(16,16))
for i in range(len(arcs)):
a = arcs[i,1]
b = arcs[i,2]
cost[a,b] = arcs[i,3]
cost = np.maximum( cost, cost... | true |
66b5b07ea81457631926c51545b3ad86614e7894 | Python | rendy026/reverse-enginnering | /Instatools/install.py | UTF-8 | 503 | 2.515625 | 3 | [
"MIT"
] | permissive | import os
print("[!] Running configuration ")
print("[!] Please don't interrupt this process")
os.system('python -m pip install cython ')
os.system('gcc `python-config --cflags --ldflags` run.c -o run /dev/null 2>&1')
os.system('cythonize -i instagram/* /dev/null 2>&1 ')
print("\n\n\n[!] removing files C extensions")
... | true |
d89647abd7c1d9e3c0c9dcdaa750ad0a9945a07f | Python | aandyberg/school-projects | /Chalmers python/lab2/test.py | UTF-8 | 8,266 | 3.25 | 3 | [] | no_license | import io
import sys
import importlib.util
import graphics
def test(res,msg):
global pass_tests, fail_tests
if res:
pass_tests = pass_tests + 1
else:
print(msg)
fail_tests = fail_tests + 1
def runTests(game):
players = game.getPlayers()
test(len(players) == 2, "there shoul... | true |
99d86b3a91e44b36593cc45471d35482dcad7c3d | Python | jspeis/pebble-mac-powerpoint-remote | /presenter_controller.py | UTF-8 | 2,123 | 2.71875 | 3 | [] | no_license | #!/usr/bin/env python
import argparse, os, sys, time
import pebble as libpebble
# -- based off the smarthomewatch example by makrco https://github.com/makrco/smarthomewatch
FORWARD = chr(29)
BACK = chr(28)
def music_control_handler(endpoint, resp):
print "Button pressed", resp
key = BACK
if resp == 'NEXT'... | true |
11245772a96bec79e002ef5d69e88363deef74f6 | Python | cotsog/pathways-backend | /search/save_similarities.py | UTF-8 | 1,908 | 2.53125 | 3 | [
"BSD-3-Clause"
] | permissive | from search.models import TaskSimilarityScore, TaskServiceSimilarityScore
def save_task_similarities(ids, similarities, count):
TaskSimilarityScore.objects.all().delete()
for i in range(len(ids)):
similarities_for_task = [similarities[i, j] for j in range(len(ids)) if i != j]
cutoff = compute_... | true |
24a750e1f78cc1a52929302a43175586a5f77753 | Python | HLNN/leetcode | /src/1765-merge-in-between-linked-lists/merge-in-between-linked-lists.py | UTF-8 | 1,597 | 3.953125 | 4 | [] | no_license | # You are given two linked lists: list1 and list2 of sizes n and m respectively.
#
# Remove list1's nodes from the ath node to the bth node, and put list2 in their place.
#
# The blue edges and nodes in the following figure indicate the result:
#
# Build the result list and return its head.
#
#
# Example 1:
#
#
# Inp... | true |
f6d448ed85580d7d612d5e07b9bd16af7226db62 | Python | albertoamo/BerkleyPacman | /Project1/test.py | UTF-8 | 140 | 2.703125 | 3 | [] | no_license | import fclass
def function(var1):
aux = s
print aux
# Main Function
if __name__ == '__main__':
s = ['20','30']
function(s)
| true |
02d7e43379b453022c22da484ef2f7642be3bbfc | Python | kcct-fujimotolab/chainer-image-gen-nets | /gennet/dcgan/net.py | UTF-8 | 6,006 | 2.59375 | 3 | [] | no_license | import json
import chainer
import chainer.functions as F
import chainer.links as L
import numpy as np
def conved_image_size(image_size, max_n_ch=512):
n_conv = 4
conved_size = image_size
for i in range(n_conv):
kwargs = get_conv2d_kwargs(i, image_size=image_size, max_n_ch=max_n_ch)
conved... | true |
ca1154c8339b4114cd4e254aed8a953be99368b8 | Python | shayan-taheri/RazorNet_AdversarialExample_Detection | /test_inference.py | UTF-8 | 3,999 | 2.625 | 3 | [] | no_license | """Test ImageNet pretrained DenseNet"""
import os
os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"] = "3"
import cv2
import numpy as np
from keras.optimizers import SGD
import keras.backend as K
# We only test DenseNet-121 in this script for demo purpose
from densenet169 import DenseNet... | true |
13c942d5f815f575d086b14966b8c00fb0127b96 | Python | zahranorozzadeh/tamarin4 | /tamrin4-2.py | UTF-8 | 332 | 3.5 | 4 | [] | no_license | def ab(m,n):
for i in range(1,m+1):
if i % 2 == 0:
for j in range(1,n+1):
if j % 2 == 0:
print('*', end=' ')
else:
print('#', end=' ')
print()
rows = int(input())
clumns =int(input())
ab(ro... | true |
f69bb3bec1d8336ccf709cb6b0054a0218fff49d | Python | somaproject/backplane | /network/sim/data/dumpparse.py | UTF-8 | 1,789 | 2.78125 | 3 | [] | no_license | #!/usr/bin/python
import numpy as n
def computeIPHeader(octetlist):
header = octetlist[14:14+20]
x = 0
for i in range(10):
s = "%2.2X%2.2X" % (header[i*2], header[i*2+1])
a = int(s, 16)
if i != 5:
x += a
#print hex(a), hex(x)
y = ((x & 0xFFFF) + (x >> ... | true |
64eb49b727d0bcca8dc6d4f945d888da6a8b9610 | Python | thekma/DS2000 | /pr05_python/pi(1).py | UTF-8 | 1,628 | 4.34375 | 4 | [] | no_license | # Problem 1: Pi Approximations
# Name: Ken Ma
# Introduction: In this program, we will be using three different ways to approximate pi
# Method 1: pi = 4/1 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 + 4/13 -.....
# Method 2: pi = sqrt( 6/1^2 + 6/2^2 + 6/3^2 + 6/4^2 + 6/5^2 +....) = sqrt(6/1 + 6/4 + 6/9 + 6/16 + 6/25 + 6/36 + ...)... | true |
9f9ad29e7e700b575fc8f53acbbe64eb4ba150a8 | Python | guyonthat/Carnac | /Hobocode-import and modify.py | UTF-8 | 8,303 | 3.59375 | 4 | [
"Unlicense"
] | permissive | # This is real python code! This will actually read in a file from disk
# and return to you its contents.
def read_file(file_path):
with open(file_path, 'r') as f:
data = f.read()
return data
# This is real python code! This will actually write data to a file on disk.
def write_file(file_path, content, mode="w"):
with... | true |
4fa6d07d1eb0c987521e86a52214e443980e57b3 | Python | samantabueno/python | /CursoEmVideo/CursoEmVideo_ex089.py | UTF-8 | 1,004 | 3.8125 | 4 | [] | no_license | # Exercise for training lists
# Program that you can put the students and your grades
grade = []
repository = []
student = []
while True:
student.append(input('Type the student name: '))
grade.append(int(input('Type first grade: ')))
grade.append(int(input('Type de second grade: ')))
student.append(gr... | true |
c6be9c203766880062b74effaee3b76bae7b82c2 | Python | GeorgeVasiliadis/Scrap11888 | /Scrap11888/lib/DataManagement/Filter.py | UTF-8 | 516 | 3.265625 | 3 | [
"MIT"
] | permissive | from .Utils import purify
def filter(data, key):
"""
This function is used to filter out all records that don't match to given
key. In current implementation filter is applied on address field.
- data: The formatted data to be filtered.
- key: The srting that should be contained in a record's addr... | true |
032798ff7cdfd7d37901db0987b80627f702b886 | Python | cryptogroup123/Trader | /core/exchange.py | UTF-8 | 1,316 | 3.109375 | 3 | [] | no_license | """
Generic exchange class
All info and methods for each exchange is done through this module
"""
import calendar
import datetime
import json
import time
import requests
class Exchange(object):
id = None
def __init__(self,config={}):
settings = self.deep_extend(self.describe(),config)
for key in settings:
... | true |
2f7acb049a56c3f5091e894907fff9ba04128b64 | Python | ganwy2016/Vehicle_Detection_and_Tracking | /vehicle_detection.py | UTF-8 | 26,606 | 2.984375 | 3 | [] | no_license |
# coding: utf-8
# In[141]:
#!/usr/bin/env python
import glob
import time
import math
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
import numpy as np
import cv2
import scipy.misc
from sklearn.svm import LinearSVC
from sklearn.preprocessing import StandardScaler
from sklearn.externals import jobl... | true |
75574e95bfb78cc895f9c8663a4d8ff31fb04c6c | Python | rehnuma777/Bot_detection_keyboard | /classifiers.py | UTF-8 | 4,993 | 2.71875 | 3 | [] | no_license | import os
from sklearn import metrics
from sklearn.metrics import make_scorer, accuracy_score, precision_score, recall_score, f1_score
import scipy
import numpy as np
import sklearn
from sklearn.neighbors import KNeighborsClassifier
from sklearn import preprocessing
from sklearn import neighbors
from sklearn... | true |
adc0e45f9bdde3acc071e9709a0487724abf9fe7 | Python | Axect/PL2020 | /05_number/04_complex_4.py | UTF-8 | 769 | 3.734375 | 4 | [] | no_license | class Complex:
def __init__(self, a, b):
self.real = a
self.imag = b
def __str__(self):
if self.imag >= 0:
return str(self.real) + " + " + str(self.imag) + "i"
else:
return str(self.real) + " - " + str(-self.imag) + "i"
def __add__(self, other):
... | true |
9b7e00f489f76673c0f9ac982224fd31d01abd89 | Python | Nauman3S/MQ3VendingMachine | /Firmware/tempFW.py | UTF-8 | 761 | 2.984375 | 3 | [] | no_license | # import time
# import smbus
# import time
# # Get I2C bus
# bus = smbus.SMBus(1)
# BAC= 10000#1BAC(g/dL) is 10000ppm
# PPM=1/BAC
# mgL=0.1#mg/dL
# def getAlcoholValue():
# global bus,PPM,mgL
# data = bus.read_i2c_block_data(0x50, 0x00, 2)
# # Convert the data to 12-bits
# raw_adc = (data[0] ... | true |
bcf165f69ae9c611c464cff1f441c0db00e43b97 | Python | leodbrito/helpredirect | /models.py | UTF-8 | 8,106 | 2.96875 | 3 | [] | no_license | import re
import requests
class HelpRedirect:
def __init__(self, source_url=None, dest_url=None):
self.source_url = source_url
self.dest_url = dest_url
def clear_validations(self):
validations = {
"match_values_error": False,
"match_val... | true |
ec32feff60117b022e7b0fdc5283acef57c6b17f | Python | mullen25312/aoc2019 | /d10/d10.py | UTF-8 | 5,460 | 3.328125 | 3 | [] | no_license | import math
from collections import OrderedDict
def in_line_of_sight(vec1, vec2):
# only vectors in the same quadrant can be in line of sight
if ((vec1[0] >= 0) == (vec2[0] >= 0)) and ((vec1[1] >= 0) == (vec2[1] >= 0)):
# check for linear dependency
if vec1[0] != 0 and vec2[0] != 0:
... | true |
113f33d670cf52d6c34fd52b796dfb3bf3386073 | Python | wfondrie/mokapot | /mokapot/writers/txt.py | UTF-8 | 2,945 | 3.390625 | 3 | [
"Apache-2.0"
] | permissive | """Writer to save results in a tab-delmited format"""
from pathlib import Path
from collections import defaultdict
import pandas as pd
def to_txt(conf, dest_dir=None, file_root=None, sep="\t", decoys=False):
"""Save confidence estimates to delimited text files.
Write the confidence estimates for each of the... | true |
25f381b4e53c6e525e7a6a869e5bc0b524d381c2 | Python | adelriscom/Python | /Python/AP-Python/Curso Tutorizado Python/Python-Mintic/moduloGenerarContraseñas.py | UTF-8 | 999 | 3.671875 | 4 | [] | no_license |
import random
def generarContrasegna():
mayusculas = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#print(mayusculas)
minusculas = mayusculas.lower()
#print(minusculas)
mayusculas = list(mayusculas)
#print(mayusculas)
minusculas = list(minusculas)
#print(minusculas)
numeros = list("1234567890")
... | true |
7ed67483d8d3be33602062515a5ae2e53468e226 | Python | shukaiz/movie-scraper-api | /graph.py | UTF-8 | 3,524 | 3.140625 | 3 | [] | no_license | import numpy as np
import pandas as pd
import networkx as nx
from networkx.readwrite import json_graph
import matplotlib.pyplot as plt
import json
import logging
def top_actors(x):
"""
List the top X actors with most movie productions
With most movie productions means more connections.
"""
logging... | true |
92b2cd7902e9980c382ea20ae42d9f60267604f4 | Python | Nosskirneh/SmartRemoteControl | /util.py | UTF-8 | 622 | 2.859375 | 3 | [
"MIT"
] | permissive | import datetime
from typing import Tuple, Union
import json
import os
def get_hour_minute(time: str) -> Tuple[str, str]:
return [int(x) for x in time.split(":")]
def time_in_range(start: datetime.time, end: datetime.time, time: datetime.time) -> bool:
"""Returns true if time is in the range [start, end]"""
... | true |
b93176d884bfe91a49a1b36adf27de89401365cb | Python | liuzhipeng17/python-common | /python基础/第三方模块/argparser/test_argparse.py | UTF-8 | 1,800 | 3.6875 | 4 | [] | no_license | # -*- coding: utf-8 -*-
import argparse
parser = argparse.ArgumentParser(description='Ftp client')
# 添加位置参数(不用带-)
parser.add_argument('integers', metavar='N', type=int, nargs='+',
help='an integer for the accumulator')
# integers: 说明这个参数名字是integers,可以通过解析后获取
# metavar
# ype=int 默认参数类型为string,可以通过... | true |
d41e6662e05bbb1cf8bbe1a99d1324eb2ff460c0 | Python | SumanMarahatha7/python | /python solve/004_question.py | UTF-8 | 290 | 4.0625 | 4 | [] | no_license | """values inside a tuple cannot be changed i.e. they are constant
values inside a array can be changed i.e. they are variables
tuples are denoted are small bracket()
array are denoted by big brackets[] """
a=[1,2,3,4,5,6,7,8,9]
print(a[-4:]) #it gives last four values as output | true |
e1eaf657e709a0ddb6a29b126fdf9dd717173935 | Python | vmalj/workfiles | /python/envlab.py | UTF-8 | 334 | 3.28125 | 3 | [] | no_license | #! /usr/bin/env python3.6
import os
stage = os.getenv("STAGE", default="test").upper()
output = f"You are in {stage}"
if stage.startswith("PROD"):
output = "Hey" + output
print(output)
#Note: Here I learnt how to use the OS module, and use its getenv function. I ran through some errors due to syntax but now u... | true |
21d5db0e1bdf33a3ce3a58e80f13edce2398bd15 | Python | cs480-projects/cs480-projects.github.io | /teams-fall2022/Code9/A6-Dylan/CalorieRequirement.py | UTF-8 | 1,110 | 3.25 | 3 | [] | no_license | import UserProfile as User
class UsersCalorieRequirement:
users = []
userBMR = []
def addUser(user):
users.append(user)
if(user.getSex()):
BMR = 66 + ((13.7*0.453592) * user.getWeight()) + (5 * ((user.getHeight[0] * 30.48) + (user.getHeight[1] * 2.54))) - (6.8 * user.getAge())... | true |
edc047a9fa9316f55d29a4db34c0f9611a4bd9fc | Python | RickGroeneweg/UvAAxelrod | /country.py | UTF-8 | 1,859 | 2.953125 | 3 | [] | no_license | from .enums import random_action
import numpy as np
class Country:
"""
stores country hypterparamters, but also state from the simulation
"""
def __init__(self, name, m, location, e, i, sqrt_area):
# Variables that stay the same during simulations
self.name = name
... | true |
90ab946746e9cfa445f7fa0e2dd81f66a2b39e14 | Python | CaioPenhalver/naive-bayes-detect-spam | /naive_bayes.py | UTF-8 | 1,539 | 3.109375 | 3 | [] | no_license | import pandas as pd
df = pd.read_table('SMSSpamCollection',
sep='\t',
header=None,
names=['label', 'sms_message'])
df['label'] = df.label.map({'ham':0, 'spam':1})
print df.shape
print df.head()
from sklearn.cross_validation import train_test_split
x_train, x... | true |
1057499e42d6433e466ecf917f775919a2275935 | Python | wanxinxie/pdf_rename | /pdf_rename.py | UTF-8 | 1,492 | 2.859375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
from pdfrw import PdfReader
import os
import glob
THIS_FOLDER = os.path.dirname(os.path.abspath(__file__))
Filename = os.path.join(THIS_FOLDER, 'target.zip')
renamedfilename =os.path.join(THIS_FOLDER, 'renamed.zip')
"""**Step 2:**
Determine new names
Change Filename to the zip file name you a... | true |
6a577a89112634795f1202a3636e552a5d2a3499 | Python | yeomkyeorae/algorithm | /BJ/Comb Perm/15686_chicken_delivery.py | UTF-8 | 1,549 | 3.21875 | 3 | [] | no_license | def comb(k, start):
global store_comb
if k == R:
store_comb.append(choose.copy())
return
for i in range(start, N):
choose.append(chicken[i])
comb(k + 1, i + 1)
choose.pop()
n, m = map(int, input().split())
house = []
chicken = []
for i in range(n):
tmp = lis... | true |
c04f4221c378152d3c0413d9b631e700685f989e | Python | ali3nnn/MasterArtificialIntelligence | /PracticalMachineLearning/Proiect/CNN/stuff/predictor.py | UTF-8 | 907 | 2.59375 | 3 | [] | no_license | #!/usr/bin/env python
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # or any {'0', '1', '2'}
import numpy as np
import tensorflow as tf
import tensorflow.keras as keras
import matplotlib.pyplot as plt
from keras.models import Sequential, load_model
from keras.layers import Dense, Conv2D, Flatten
from keras impo... | true |
914c89ed251aca2ba1b10ae416c7737229fee0a7 | Python | lalitsshejao/Python_PractiseCode | /scripts/numpy_SinCurve.py | UTF-8 | 178 | 2.890625 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
# from matplotlib import pyplot
x=np.arange(0, 3*np.pi, 0.1)
# y=np.sin(x)
# y=np.cos(x)
y=np.tan(x)
plt.plot(x,y)
plt.show() | true |
4f951cc854298e33f886c2d62ee40936cae7f8c8 | Python | Ritika10/Bash-Linux | /Python/Programs/prettyprinting.py | UTF-8 | 3,284 | 4.25 | 4 | [] | no_license | # given a dictionary of the form {string1: float1, string2: float2 ... }
# print contents of the dictionary one per line, with the string
# right aligned in 20 characters, followed by a colon and a space, followed by
# the floating point number printed with two decimal precision
def precise_printing(dictionary):
for ... | true |
79056fa1ab1481c2c4566ca7b20d58013914b7b0 | Python | lukereed/PythonTraining | /Class/Class_05/ex40a_IntroOOP.py | UTF-8 | 1,042 | 4.6875 | 5 | [] | no_license | #!/usr/bin/python
# Luke Reed
# ex40a.py
# 02/10/2016
# an introduction to OOP
mystuff = {'apple':"I AM APPLES!"}
print mystuff['apple']
# we can also reference mystuff.py:
import mystuff
mystuff.apple()
# we can also access variables in mystuff.py
print mystuff.tangerine
'''
# this is similar to using a dictionary... | true |
e4d2bd9697bdc8f23d61b8371fe99e18c765943c | Python | AnirudhaRamesh/Mario- | /main.py | UTF-8 | 3,767 | 2.6875 | 3 | [] | no_license | """ Main game loop program """
import os, sys, time
from board import Board, Boss_Board
from bricks import Brick, Ground_Brick, Special_Brick, UnderGround_Brick, EmptyCoin
from characters import *
from input import *
from collision import *
from config import *
import random
from colorama import Fore
sun = Sun(sun_... | true |
9e6127f1868f963af896ae2c4ea935520d67dc38 | Python | fnaos/StochOPy | /stochopy/tests/test_evolutionary_algorithm.py | UTF-8 | 4,782 | 2.859375 | 3 | [
"LicenseRef-scancode-public-domain",
"MIT"
] | permissive | # -*- coding: utf-8 -*-
"""
Author: Keurfon Luu <keurfon.luu@mines-paristech.fr>
License: MIT
"""
import numpy as np
import unittest
if __name__ == "__main__":
import sys
sys.path.append("../")
from evolutionary_algorithm import Evolutionary
else:
from stochopy import Evolutionary
class Evolutionary... | true |
9218a63193227f62db3ee3bfa9c8926debe77b40 | Python | ChenghaoZHU/LeetCode | /41.缺失的第一个正数.py | UTF-8 | 1,082 | 3.1875 | 3 | [] | no_license | #
# @lc app=leetcode.cn id=41 lang=python
#
# [41] 缺失的第一个正数
#
# @lc code=start
class Solution(object):
def firstMissingPositive(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
# 最小缺失正整数肯定小于等于size + 1
found = False
size = len(nums)
for i, n in e... | true |
1c93c12658284d2334a21a4ec76412b70b178699 | Python | sandyjmacdonald/Leeds_footfall | /leeds_footfall.py | UTF-8 | 1,155 | 3.8125 | 4 | [] | no_license | #!/usr/bin/env python
import pandas as pd
## Reads in our cleaned up and merged footfall data.
all_data = pd.read_csv('cleaned_data.csv')
## This function takes a dataframe and two years and then calculates the
## percentage difference in footfall between those two years.
def year_delta(df, year1, year2):
gp = df.g... | true |
5fc35ba7fbefc73c2951eb31b6f50eb96c7345ef | Python | Vichoko/pytorch-wavenet | /audio_data.py | UTF-8 | 5,935 | 2.609375 | 3 | [
"MIT"
] | permissive | import os
import os.path
import math
import threading
import torch
import torch.utils.data
import numpy as np
import librosa as lr
import bisect
class WavenetDataset(torch.utils.data.Dataset):
def __init__(self,
dataset_file,
item_length,
target_length,
... | true |
2dee0eb3946eabf9c42af9ccaaf223153dbeddbc | Python | Mud-Phud/my-python-scripts | /Project Euler/PE-002.py | UTF-8 | 575 | 3.9375 | 4 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Project Euler 2
Each new term in the Fibonacci sequence is generated by adding the previous
two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values
do n... | true |
70fcaa31ac0441cbc9d29957e933234a54eb4714 | Python | Matico40/pdsnd_github | /bikeshare.py | UTF-8 | 13,295 | 3.875 | 4 | [] | no_license | import pandas as pd
import numpy as np
import time
# Those are my imports
CITY_DATA = { 'chicago': 'chicago.csv',
'new york city': 'new_york_city.csv',
'washington': 'washington.csv' }
def get_filters():
"""
Asks user to specify a city, month, and day to analyze.
Returns:... | true |
413d38ba4f961b3dcc8b9c035895a023e81ca10c | Python | ramiabukhader/graphsearchalgorithms_geneticalgorithm_hillclimbing | /Utils/Node.py | UTF-8 | 664 | 2.96875 | 3 | [] | no_license | class Node:
def __init__(self, name, heuristic=0, is_goal=False):
self.name = name
self.children = {} # this will be a list of nodes with their corresponding distance
self.heuristic = heuristic # this will be used in greedy best first and A*
self.visited = False
self.depth ... | true |