blob_id large_string | language 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
617ceb1eaa1ebc2004ea9b0b4baaecd027bf13c8 | Python | jsonkao/mks22 | /finalproj/resources/jamba.py | UTF-8 | 2,156 | 2.75 | 3 | [] | no_license | import urllib
def jm_get_num(s):
num_start = s.rfind('<td>')+4
num_end = s.rfind('</td>')
try:
return int(s[num_start:num_end])
except:
return '-'
def jm_store(product_type,info,sort):
url = 'http://www.jambajuice.com/menu-and-nutrition/menu/'+product_type
f = urllib.urlope... | true |
d87b53873b631dc0ea189c8e033caed3c991a263 | Python | geek-ninja/hackerrank_solutions | /hackerrank/holloween_price.py | UTF-8 | 247 | 2.78125 | 3 | [] | no_license | p,d,m,s=map(int,input().split())
total=s;
count=0
if total-p>=m:
total=total-p
count+=1
for i in range(p-d,m,-d):
total-=i
if total>=m:
count+=1
while total>=m:
total-=m
count+=1
print(count)
| true |
f45259da4d410c951bd7fab63394ea93796504a9 | Python | Raistlfiren/sqlalchemy-jsonapi-collections | /flask_sqlalchemy_jsonapi/sort.py | UTF-8 | 3,322 | 3.28125 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
from sqlalchemy import desc
from flask_sqlalchemy_jsonapi.errors import FieldError
class SortValue(object):
"""Validate and sort a provided `marshmallow` schema field name."""
attribute = None
descending = False
join = None
def __init__(self, schema, value):
"""Se... | true |
1739fe3e7fd5312d857a039aa143cc3745aedc54 | Python | zaczap/hail-freq-filter | /python/hail/genetics/ldMatrix.py | UTF-8 | 6,844 | 2.625 | 3 | [
"MIT"
] | permissive | from hail.history import *
from hail.typecheck import *
from hail.utils.java import *
import hail
class LDMatrix(HistoryMixin):
"""
Represents a symmetric matrix encoding the Pearson correlation between each pair of variants in the accompanying variant list.
"""
def __init__(self, jldm):
self.... | true |
90929cdaabc17e91c4888582904cb5a7d7ff1f87 | Python | Pranav-Code-007/Online-Complaint-System-For-Colony | /encrypt.py | UTF-8 | 225 | 2.53125 | 3 | [] | no_license | from cryptography.fernet import Fernet
key = Fernet.generate_key()
fernet = Fernet(key)
def encrypt(message):
return fernet.encrypt(message.encode())
def decrypt(message):
return fernet.decrypt(message.decode())
| true |
831a5cf73765c90c3f6014c245947c4827cd76fa | Python | jesterswilde/dlgo | /dlgo/encoder/sevenplane.py | UTF-8 | 1,773 | 2.796875 | 3 | [] | no_license | import numpy as np
from dlgo.encoder.base import Encoder
from dlgo.goboard import Point, Move, GameState
MY_ONE_LIB = 0
MY_TWO_LIB = 1
MY_MORE_LIB = 2
THEIR_ONE_LIB = 3
THEIR_TWO_LIB = 4
THEIR_MORE_LIB = 5
VIOLATE_KO = 6
class SevenPlane(Encoder):
def __init__(self, board_size):
self.board_width, self.b... | true |
6d5c1c330477cb6977a4e95b6d077d07a94883eb | Python | stevenJoyce/GraphTheoryProject | /project2020/shunting.py | UTF-8 | 1,607 | 4 | 4 | [] | no_license | # Steven Joyce
#The Shunting Yard Algorithm for Regular Expressions
#import unittest to import
import unittest
#default input
infix = "(a|b).c*"
print("Input is:", infix)
exOutput = "ab|c*."
print("Expected :", exOutput)
#Convert infix variable into a stack-ish list
infix = list(infix)[::-1]
#Operator
opers = []
#out... | true |
b06ee4bcb112c811d36dd34b11a073d03f7ce7b8 | Python | sped-br/python-sped | /sped/blocos.py | UTF-8 | 974 | 2.75 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
from .registros import Registro
class Bloco(object):
def __init__(self, nome=''):
self._nome = nome
self._registros = []
def __repr__(self):
return '<%s.%s(%s)>' % (self.__class__.__module__,
self.__class__.__name__, self._nome)... | true |
c33e8f4f992df5dc62d90731c58351e1b1b0482f | Python | altingia/denovoTE-eval | /random_sequence_TEs.py | UTF-8 | 10,694 | 2.578125 | 3 | [] | no_license | import sys
import random
import yaml
import numpy
from Bio import SeqIO
from Bio import Seq
class Repeat:
def __init__(self, name, sequence, num_rep, identity, sd, indels, tsd, frag, nest):
self.name = name
self.sequence = sequence
self.num_rep = num_rep
self.identity = identity
... | true |
13cb9056b167a0608abe8e6940e866eee5f2c472 | Python | amadev/dojo | /spiral.py | UTF-8 | 1,801 | 4.125 | 4 | [] | no_license | # name: return all elements of a matrix in spiral order
# input: 2-d array
# output: list in spiral order
# idea: |
# we have direction variable (r,d,l,u) and borders for each
# side, in cycle from 0 to m * n we will change direction if we hit
# border and at the same time border for the side is decremented
clas... | true |
65235014037f93aa7386397c92d5b9e76fa27221 | Python | PrateekGupta1509/Hinglish-Text-Normalisation | /evalMetrics.py | UTF-8 | 2,891 | 3.1875 | 3 | [] | no_license | #-*- coding: utf-8 -*-
#!/usr/bin/env python
# Script adapted from here https://github.com/zszyellow/WER-in-python
import sys
import numpy
from nltk.translate import bleu_score
import chrf_score
def editDistance(r, h):
'''
This funciton is to calculate the edit distance of refernce sentence and the hypothes... | true |
f6df3c1576bcd537a60269fe9707d587bc6018b3 | Python | ClayLiu/lstm_for_Stock | /trainning.py | UTF-8 | 2,176 | 2.65625 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
import torch
from torch import nn
import torch.utils.data as Data
from net import StockForecast_lstm
from read_data import get_prepared_data
time_window = 3
epoch_count = 10
batch_size = 16
trainning_rate = 0.7 # 使用全部数据的 70% 作为训练数据
x, y = get_pr... | true |
0c8fc7a805998bcdc53d8f41e21986563f335d64 | Python | zegarelli/sentiment_study | /plot_history.py | UTF-8 | 338 | 2.515625 | 3 | [] | no_license | import read_data
import matplotlib.pyplot as plt
data_set = read_data.main('CPC')
date = []
spx = []
cpc = []
spread = []
for day in data_set['days']:
date.append(day.date)
spx.append(day.spx)
cpc.append(day.cpc)
spread.append(day.prior_week_spread)
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, sharex=T... | true |
6da05761083f8e94a5109483543649a628018022 | Python | WickhamLee/Barra_Platform | /tools/mathmatic_tools_trash.py | UTF-8 | 3,411 | 2.890625 | 3 | [] | no_license | import numpy as np
import copy
import time
import warnings
warnings.filterwarnings("ignore")
# +-------------------------------------------------------+
# | Weighted_Linear_Regression |
# +-------------------------------------------------------+
#加权线性回归
def Weighted_Linear_Regression(array_x,... | true |
81291ec77f8ff1983eda47ff35f94cb0339aa0c0 | Python | daglyd/StudieArbeid | /IN1900/Oppgaver/kick.py | UTF-8 | 834 | 3.359375 | 3 | [] | no_license | #Exercise 1.11: Compute the air resistance on a football
from math import pi
rho = 1.2 #kg/m^3
m = 0.43 #kg
g = 9.81 #m/s^2
a = 11 #cm
A = pi*a**2
Cd = 0.4 #drag coefficient
V_hard = 120 *(5.0/18) #m/s
V_soft = 30*(5.0/18) #m/s
Fg = m*g
Fd_hard = -0.5*Cd*rho*A*V_hard**2
Fd_soft = -0.5*Cd*rho*A*V... | true |
0bc07e6dfc0d9c91b8a719c41ec8c4371addf3a8 | Python | jonlin97/CPE101 | /lab6/string/string_101.py | UTF-8 | 338 | 3.28125 | 3 | [] | no_license | from char import char_rot_13
def str_rot_13(string):
new_list = [char_rot_13(elem) for elem in string]
return ''.join(new_list)
def str_translate_101(string, old, new):
new_string = ''
for char in string:
if char != old:
new_string += char
else:
new_string += new
return n... | true |
e602e7197f4f8bf226e02a5da84e716d1e9863bc | Python | crempp/mdweb | /tests/test_page.py | UTF-8 | 21,623 | 2.5625 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
"""Tests for the MDWeb Navigation parser.
Tests to write
* Handle symlinks
* File already open
* Non supported extension (.xls)
* Permissions
Maybe test?
* atime, mtime
* large file
"""
import datetime
from pyfakefs import fake_filesystem_unittest
from unittest import skip
try:
... | true |
0d294f75d9b3e362192c1245b56e85a4ecd187a1 | Python | jiadaizhao/LeetCode | /0801-0900/0824-Goat Latin/0824-Goat Latin.py | UTF-8 | 288 | 2.765625 | 3 | [
"MIT"
] | permissive | class Solution:
def toGoatLatin(self, S: str) -> str:
def convert(word):
if word[0] not in 'aeiouAEIOU':
word = word[1:] + word[0]
return word + 'ma'
return ' '.join(convert(word) + 'a'*i for i, word in enumerate(S.split(), 1))
| true |
f65f90a8a57c2fb969e180b9a7c6243bdfcbc5df | Python | w5802021/leet_niuke | /stack/232.Implement Queue using Stacks.py | UTF-8 | 930 | 4.125 | 4 | [] | no_license | class MyQueue():
def __init__(self):
"""
Initialize your data structure here.
"""
self.itema = []
self.itemb = []
def push(self, x):
"""
Push element x to the back of queue.
"""
self.itema.append(x)
def pop(self):
"""
... | true |
f68b4026921da4a6aa3bb5c6892b25493d28a661 | Python | messa/pyfw | /pyfw/util/misc.py | UTF-8 | 1,462 | 2.59375 | 3 | [] | no_license | import difflib
import reprlib
import sys
from .pretty_yaml import pretty_yaml_dump
_repr_obj = reprlib.Repr()
_repr_obj.maxstring = 80
_repr_obj.maxother = 80
smart_repr = _repr_obj.repr
def print_diff(a, b, a_name='a', b_name='b', context=5, stream=None):
if stream is None:
stream = sys.stdout
a ... | true |
9e5b9e56f603539c0ed3fc8b47163f6a70d17714 | Python | mayrie73/web_fundamentals_projects | /web_fundamentals/week_three/python_stack/python_OOP/animal.py | UTF-8 | 1,112 | 4.125 | 4 | [] | no_license | class Animal(object):
def __init__(self, name):
self.name = name
self.health = 100
def walk(self):
self.health -= 1
return self
def run(self):
self.health -=5
return self
def display_health(self):
print" "
print "My name is {}".format(self.... | true |
64f616f48e8477bacf69c0fc54b66303adc3e5c3 | Python | thecosta/NetworkViewer | /plotter.py | UTF-8 | 10,154 | 2.953125 | 3 | [] | no_license | import h5py
import matplotlib
import matplotlib.collections as collections
import matplotlib.patches as pat
import matplotlib.pyplot as plt
import numpy as np
from core import Tuple, Layer
from layers import Convolution, Dense, Input, Funnel, Output
from matplotlib.pyplot import figure
from matplotlib.collections impo... | true |
c48532f76973e41c748f03268bf46fa9bae7950f | Python | UCSB-CMPTGCS20-S16/CS20-S16-Lecture-04.28-Formatting | /circleTable.py | UTF-8 | 396 | 3.46875 | 3 | [
"MIT"
] | permissive |
from circleFunctions import areaCircle
from circleFunctions import circumferenceCircle
def circleTable(startRadius,stopRadius):
print "%10s %10s %15s" % ("radius", "area", "circumference")
for radius in range(startRadius,stopRadius):
print "%10.5f %10.5f %15.5f" % (radius,areaCircle(radius),circ... | true |
69852fc607d7deed79148ecd980b008c2a0731b5 | Python | tx19980520/Ty-s-Online-Chatting-Room | /test/connecttest.py | UTF-8 | 662 | 2.578125 | 3 | [] | no_license | from socket import *
import struct
import pickle
HOST = '127.0.0.1'
PORT = 21567
BUFSIZE = 1024
ADDR=(HOST,PORT)
class tcpCliSock(object):
def __init__(self):
self.client = socket(AF_INET, SOCK_STREAM)
def link(self):
self.client.connect(ADDR)
def test(self):
self.link()
pack... | true |
38320bc9b97587ca66c40a897d3508c4de8a5cc9 | Python | vamsikrishna6668/python-core | /7-8(am)/05-09-2018/fun1.py | UTF-8 | 292 | 3.328125 | 3 | [] | no_license | # 1. W.A.P on user defined function and that function must call multiple times?
def fun1():
print('function 1')
def fun2():
print('Function 2')
# calling block
fun1()
fun2()
fun1()
fun2()
"""
Output:
function 1
Function 2
function 1
Function 2
Process finished with exit code 0
""" | true |
12c594bb5bd5f3b57979cc5afa2a6fd49330338b | Python | candelibas/Web-Challenge | /backend/server.py | UTF-8 | 1,853 | 2.640625 | 3 | [
"MIT"
] | permissive | from apscheduler.schedulers.background import BackgroundScheduler
from flask import Flask, g
from flask_socketio import SocketIO, emit, send
import requests, json, datetime
from threading import Lock
from database import read_reviews_daily, save_review_daily
# Set this variable to "threading", "eventlet" or "gevent" t... | true |
a6fe20a51aa7e95875f037378656a5dc476cc480 | Python | vixor11/wsb_scraper | /wsb_scraper.py | UTF-8 | 3,725 | 2.640625 | 3 | [
"MIT"
] | permissive | from selenium import webdriver
from collections import Counter
import numpy as np
from datetime import date, timedelta
from dateutil.parser import parse
import requests
import csv
import re
def grab_html():
url = 'https://www.reddit.com/r/wallstreetbets/search/?q=flair%3A%22Daily%20Discussion%22&restr... | true |
e38b53a955011f57eee2888ffa7908b90fd9c9b8 | Python | nextBillyonair/WordEmbeddings | /main.py | UTF-8 | 3,163 | 2.578125 | 3 | [] | no_license | import torch
from torch.nn import CrossEntropyLoss, BCEWithLogitsLoss
from torch.utils.data import DataLoader
from torch.optim import Adam
import sys
from utils import get_device, format, plot
from models import get_model
from dataset import Dataset
MODEL_TYPE = 'NEG' # CBOW | NGRAM | SKIPGRAM | NEG
CONTEXT_SIZE = 1
... | true |
4923b346dbfbad6e78766dda1dcb50a69e9a2b96 | Python | joshuapanjaitan/Gojek-Battleship-Problem | /grid.py | UTF-8 | 1,224 | 3.015625 | 3 | [] | no_license | import point
class Grid:
P = point.Point()
def size(self, leng): # generate the grids
a = ' '
M = []
i = 0
x = 0
while i < leng:
inside = []
while x < leng:
inside.append(a)
x += 1
x =... | true |
9fc7c374af7ca83362b9ee9de932948d570a0b99 | Python | varCODEx/lab-stm-t2-8 | /finite_differences_method.py | UTF-8 | 1,120 | 3.421875 | 3 | [] | no_license | import numpy as np
## - override this section
# 12
#
# xy'' + y' - 1.5xy + x^2 = 0
# <=>
# y'' + y'/x - 1.5y = -x
#
# y'(0.2) = 0
# 1.6y(1.2) + 1.4y'(1.2) = 2.1
##
x0 = 0.2
h = 0.2
N = 5
#
# ay'(x0) = b
# cy(xN) + dy'(xN) = e
a = 1
b = 0
c = 1.6
d = 1.4
e = 2.1
#
# y'' + p(x)y' + q(x)y = f(x)
def p(x):
return... | true |
be6b09d02b892165d10442fc308d36174ad0072d | Python | siddhism/leetcode | /leetcode/130.surrounded-regions-union-find.py | UTF-8 | 3,541 | 3.1875 | 3 | [] | no_license | #
# @lc app=leetcode id=130 lang=python
#
# [130] Surrounded Regions
#
class Solution(object):
"""incomple and confused"""
def dfs(self, i, j, visited):
visited[i][j] = True
bounds = [(i-1, j), (i+1, j), (i, j-1), (i, j+1)]
for next_r, next_c in bounds:
if 0 <= next_r < se... | true |
fc55a1729be504af97d2c76fdae3a743d055e8f5 | Python | cg-taylor/holbertonschool-higher_level_programming | /0x0B-python-input_output/5-to_json_string.py | UTF-8 | 269 | 3.28125 | 3 | [] | no_license | #!/usr/bin/python3
"""My to_json_string module"""
import json
def to_json_string(my_obj):
"""Return the JSON representation of an object
Args:
my_obj: the object to convert to JSON
"""
my_obj_json = json.dumps(my_obj)
return my_obj_json
| true |
4135e0788bc80c4170e11e371048626cb446431f | Python | evanmalmud/furrycorn | /furrycorn/v1_0/config.py | UTF-8 | 942 | 2.71875 | 3 | [
"MIT"
] | permissive | from collections import namedtuple
from enum import Enum
class Mode(Enum):
"""
Describes modeling approach. All modes will fail with exceptions on
irredeemably bad input. For less bad input:
LENIENT: Recommended for non-comformant APIs. Logs WARN messages on
unexpected input. Logging... | true |
f00de076ba629c5e91874f6c2f7434b66ec690fe | Python | colinsongf/Diet_IntentClassifier | /IntentClassification/mlp/MLP_data_generator.py | UTF-8 | 4,200 | 2.65625 | 3 | [] | no_license | # Author : Karun Mathew
# Student Id : 1007247
#
# --------------------------------
# BASELINE TRAINING DATA GENERATOR
# --------------------------------
#
# This python class generates training data in the format that
# is expected by the baseline classifier, a MultiLayer Perceptron
#
# The format is shown below... | true |
f9b5c904f15d3a3ddb019a369fe0a40b6f2a0517 | Python | qianpeng-shen/Study_notes | /第一阶段笔记/程序/jiashe.py | UTF-8 | 259 | 3.75 | 4 | [] | no_license |
y=int(input("请输入年数: "))
t=365
s=y*t
r=s//7
i=s%7
print(y,"年有",r, "周","余",i,"天")
a=int(input("当前小时为:"))
b=int(input("当前分钟为:"))
c=int(input("当前秒为:"))
e=a*3600+b*60+c
print("当前距离0:0:0:过了", e , "秒") | true |
0b3ccd818a21ba41035172a96cd1ef008d873408 | Python | TheAeryan/PTC | /Práctica Robótica/practicaRobotica/caracteristicas.py | UTF-8 | 7,510 | 3.1875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
import math
import json
import os
import csv
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
def leer_fichero_json(nombre_fichero):
"""
Lee el fichero JSON @nombre_fichero y devuelve su contenido como una lista
... | true |
76debf47507e917c8fc21fbc895b2ddd08cbd7df | Python | opent03/drl_api | /drl_api/agents/dqn_agent.py | UTF-8 | 5,297 | 2.609375 | 3 | [] | no_license | import numpy as np
from drl_api.agents import Agent
from drl_api.memory import ReplayMemory
import drl_api.utils as utils
class DQN_agent(Agent):
'''Base class for a DQN agent. Uses target networks and experience replay.'''
def __init__(self,
target_update,
batch_size,
... | true |
7732866813ed8b2189cccb5d723684d976502714 | Python | chagab/ColdAtomsInToulouse | /CAT.py | UTF-8 | 5,775 | 3.015625 | 3 | [] | no_license | from Treatement import Treatement
import pylab as py
py.ion()
py.rc('text', usetex=True)
py.rc('font', family='serif')
class CAT(Treatement):
"""docstring for ."""
left = []
right = []
zero = []
tunnel = []
nonTunnel = []
def sortPopulationByMomentumSign(self):
"""
Argum... | true |
153e69b610d6ba61797dfb570bce279a4d7ff0ba | Python | tickelton/things | /cereal_box/cereal_box.py | UTF-8 | 1,964 | 2.8125 | 3 | [
"CC-BY-4.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env python3
import os
import sys
import cairo
OUTLINE_TOP_IN_MM = (
(0, 40),
(12, 26),
(14, 8),
(25, 8),
(25, 0),
(67, 0),
(67, 8),
(78, 8),
(79, 25),
(81, 27),
(81, 13),
(87, 8),
(116, 8),
(121, 13),
(121, 27),
(123, 25),
(125, 0),
(... | true |
482b09ae371f90f9e361541470cd09655f4bc7fb | Python | fengwu2004/Mining | /testnumpy.py | UTF-8 | 535 | 3.0625 | 3 | [] | no_license |
import numpy as numpy
import pandas
# arr = numpy.array([[1.0,2.0,3.3, 9], [1.0, 2.0, 3.5, 8]])
#
# arr = numpy.transpose(arr)
#
# data = arr[0:,0:]
#
# print(data)
#
# data = arr[0:, 0]
#
# print(data)
#
# df = pandas.DataFrame(data=arr[0:,1:], index=arr[0:,0], columns=["A", "B"])
#
# print(df)
def test()->(bool, ... | true |
5470fb972e892bd3d5c372f0520b30fcc846243d | Python | MaewenPell/Food-suggestor | /management_api/get_data_api.py | UTF-8 | 4,255 | 2.890625 | 3 | [
"MIT"
] | permissive | import requests
from db_management.db_interaction import SqlManagement
from settings_confs_files import settings as st
class ApiManager():
'''
Class use to fetch data from
OpenFoodFact and retrieve informations
'''
def __init__(self):
self.sql_mgmt = SqlManagement()
self.... | true |
988bddccac9eb67ed18b09f79e4f20edf3f72609 | Python | ByUnal/ABitRacey | /PyGame/pyg.py | UTF-8 | 6,474 | 3.078125 | 3 | [] | no_license | import pygame
import time
import random
pygame.init()
crash_eff = pygame.mixer.Sound("Crash.wav")
pygame.mixer.music.load("Bond.wav")
display_width = 800
display_height = 600
black = (0,0,0)
white = (255,255,255) #r-g-b kuralına göre yapıyoruz
red = (200,0,0)
green = (0,200,0)
blue = (0,0,200)
color_thing = (0,20,... | true |
6eb2f6dd5f1463f52b44bc8c4cb966d41bbb741e | Python | devashish89/MultithreadingPython | /main.py | UTF-8 | 995 | 3.59375 | 4 | [] | no_license | import time
import threading
lst_squares = []
lst_cubes = []
def square_nums(numbers):
global lst_squares
numbers = list(numbers)
#print(list(map(lambda x:x*x,numbers)))
for num in numbers:
time.sleep(0.2)
print(f"Square of {num} is {num*num}")
lst_squares.append(num*num)
def c... | true |
ba740f93917a3481227bcd8a39abab404243a4d3 | Python | nandadao/Python_note | /note/my_note/first_month/day17/exercise04.py | UTF-8 | 921 | 4.4375 | 4 | [] | no_license | """
练习:定义函数:my_enumerate函数,实现下列效果
"""
list01 = [1, 2, 55, 3]
dict01 = {"a":1, "b":2, "c":3}
def my_enumerate(iterable):
my_index = 0
for item in iterable:
yield (my_index,item)
my_index += 1
# for index, item in my_enumerate(list01):
# print(index, item)
# print("-----------------")
... | true |
59be530808e5db3de1db2e7eab62600505735242 | Python | hmp36/python_aug_2017 | /kevin_schmitt/multisumavg.py | UTF-8 | 278 | 3.65625 | 4 | [] | no_license | i = 1
for i in range(1,1000):
if (i % 2 == 1):
print i
# x = 5
# for x in range(5,1000000):
# if(x % 5 == 0):
# print x
# commented out so it wouldn't keep running everytime I print
a = [1,2,5,10,255,3]
print sum(a)
print sum(a)/len(a) | true |
11cee9f33473937922ce6edc98c60fbce18390e2 | Python | vatsal-sodha/Coding | /reverse_linked_list.py | UTF-8 | 408 | 3.4375 | 3 | [] | no_license | # class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
def reverseList(self, head: ListNode) -> ListNode:
currentNode = head
prev = None
while currentNode != None:
nextNode = currentNode.next
currentNode.next = pr... | true |
35662ba03f9be87216a55dccdb914ccde24b2783 | Python | hkxIron/hkx_tf_practice | /ScientificComputingWithPython/10/mlab_odeint_lorenz.py | UTF-8 | 395 | 2.796875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
from scipy.integrate import odeint
import numpy as np
def lorenz(w, t, p, r, b):
x, y, z = w
return np.array([p*(y-x), x*(r-z)-y, x*y-b*z])
t = np.arange(0, 30, 0.01)
track1 = odeint(lorenz, (0.0, 1.00, 0.0), t, args=(10.0, 28.0, 3.0))
from enthought.mayavi import mlab
mlab.plo... | true |
298e7f34d19eb4aa088d857a8265fa8a33f407f0 | Python | suren3141/codemaniav2 | /broken_printer/naive.py | UTF-8 | 479 | 3.21875 | 3 | [] | no_license | import sys
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
def read_ints(f_in=sys.stdin):
return [int(i) for i in f_in.readline().strip().split()]
def naive():
ans = -1
return ans
def solve_naive(f_in, f_out):
n = read_ints(f_in)[0]
i = 0
while n > 0:
i +... | true |
c743b53cdebbfbe5347940c0263e71dc6aede447 | Python | loganyu/leetcode | /problems/1198_find_smallest_common_element_in_all_rows.py | UTF-8 | 1,060 | 3.546875 | 4 | [] | no_license | '''
Given a matrix mat where every row is sorted in strictly increasing order, return the smallest common element in all rows.
If there is no common element, return -1.
Example 1:
Input: mat = [[1,2,3,4,5],[2,4,5,8,10],[3,5,7,9,11],[1,3,5,7,9]]
Output: 5
Constraints:
1 <= mat.length, mat[i].length <= 500
1 <=... | true |
67e8b90b67014050bc290d3e62a906a8e2d831cc | Python | dchmerenko/courseraPy | /05/hw0526.py | UTF-8 | 132 | 3.0625 | 3 | [] | no_license | # remove i-th element
lst = list(map(int, input().split()))
k, c = tuple(map(int, input().split()))
lst.insert(k, c)
print(*lst)
| true |
32b0168570e5fb76fa73d899627a2760b4297520 | Python | H-Y-H-Y-H/Introduction-to-Machine | /svm/svm_author_id.py | UTF-8 | 1,398 | 3.15625 | 3 | [] | no_license | #!/usr/bin/python
"""
This is the code to accompany the Lesson 2 (SVM) mini-project.
Use a SVM to identify emails from the Enron corpus by their authors:
Sara has label 0
Chris has label 1
"""
import sys
from time import time
sys.path.append("../tools/")
from email_preprocess import preproce... | true |
430664ceaf18a9144cf68ab03a10ffa80043b986 | Python | kinanweda/Ujian_Digimon_Json | /Ujian_Digimon_Json.py | UTF-8 | 1,371 | 2.78125 | 3 | [] | no_license | from bs4 import BeautifulSoup
import requests
import json
req = requests.get('http://digidb.io/digimon-list/')
soup = BeautifulSoup(req.content,'html.parser')
# print(soup.prettify())
data = soup.find('table', id='digiList')
# print(data)
data = data.find_all('tr')
digi = []
for i in data[1:]:
no = i... | true |
4c56237c0fde2d38b8137273cf2c4ad7d0ac2dc2 | Python | puppetlabs/jabba | /jabba/file_index.py | UTF-8 | 5,147 | 2.78125 | 3 | [
"MIT"
] | permissive |
import os
from collections import OrderedDict
from collections import namedtuple
import yaml
from yaml import load, Loader, dump
import collections
from .file_data import FileData
from .util import is_job_config, convert_path
from .analysis.cyclic_deps import format_cycle
from .dep_extractor import IncludeInfo, in... | true |
fab7f4d53c982037dbed179bb8cc2183ebac57b1 | Python | madhavpoddar/adaptive-sort | /ClassifierPerformanceAnalyzer.py | UTF-8 | 5,287 | 2.671875 | 3 | [] | no_license | from argparse import ArgumentParser
from tqdm import tqdm
import numpy as np
import csv
import random
import importlib
import operator
import sys
# TODO : remove this import
# currently added here to avoid printing of warning during dynamic import
from sklearn.ensemble import RandomForestClassifier
DEFAULT_NUM_ITERA... | true |
9d1a4972f027c8d7aecb08b808da94c747e2ed81 | Python | eselyavka/python | /leetcode/solution_9.py | UTF-8 | 1,045 | 3.609375 | 4 | [] | no_license | #!/usr/bin/env python
import unittest
class Solution(object):
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
"""
if x is None:
return False
if x == 0:
return True
if x < 0:
return False
if x < 10:
... | true |
9fe7726158858e3b2e08f217bf8adaeab510ef2d | Python | mqinbin/python_leetcode | /884.两句话中的不常见单词.py | UTF-8 | 584 | 3.078125 | 3 | [] | no_license | #
# @lc app=leetcode.cn id=884 lang=python3
#
# [884] 两句话中的不常见单词
#
# @lc code=start
class Solution:
def uncommonFromSentences(self, A: str, B: str) -> List[str]:
from collections import Counter
ac = Counter(A.split())
bc = Counter(B.split())
answer = []
for k in ac.... | true |
17fdd4e64fc67094528daaed42ef8af6081a1958 | Python | liuyuzhou/pythonsourcecode | /chapter10/date_time_all_style.py | UTF-8 | 4,050 | 3.46875 | 3 | [] | no_license | import calendar
import datetime
import time
year = time.strftime("%Y", time.localtime())
month = time.strftime("%m", time.localtime())
day = time.strftime("%d", time.localtime())
hour = time.strftime("%H", time.localtime())
minute = time.strftime("%M", time.localtime())
second = time.strftime("%S", time.localtime())
... | true |
52d5c8b4b862a870fdaa789c787a889be31ab4af | Python | teddychao/vespa | /vespa/devtools/get_import_dependencies.py | UTF-8 | 4,205 | 2.859375 | 3 | [
"BSD-3-Clause"
] | permissive | import importlib
import os
import pathlib
import re
import sys
sys.setrecursionlimit(100000000)
dependenciesPaths = list()
dependenciesNames = list()
paths = sys.path
def main(path):
"""
This recursively calls itself for whatever import modules it finds
starting with 'path' and working its way down. ... | true |
9d94328ce17c236fdbbd978790552ae9eff70436 | Python | karolmajta/django-robust-i18n-urls | /src/robust_urls/middleware.py | UTF-8 | 2,584 | 2.6875 | 3 | [] | no_license | '''
Created on 13 lut 2014
@author: karol
'''
from django.conf import settings
from django.core.urlresolvers import get_resolver
from django.utils import translation
from .utils import try_url_for_language
class RobustI18nLocaleMiddleware(object):
"""
If `response.status_code == 404` this middleware makes su... | true |
f20ea1cc971bd5118ae8c99903fcc11aabc44638 | Python | nidhihegde001/CRISMIS | /lacosmic.py | UTF-8 | 3,829 | 2.65625 | 3 | [] | no_license | import numpy as np
import time
from PIL import Image
import os
from astropy import log
from astropy.nddata.utils import block_reduce, block_replicate
from scipy import ndimage
'''
Source: (Modified from) lacosmic library, Astropy
Returns
-------
cr_image : numpy array
Th... | true |
1963e73a2f682a62da39c342c06d87aec36d4ef3 | Python | Mrju10/sensor | /conect/db.py | UTF-8 | 901 | 2.796875 | 3 | [] | no_license | import pymysql
import csv
with open('tabla.csv.csv') as File:
reader = csv.reader(File, delimiter=',', quotechar=',',
quoting=csv.QUOTE_MINIMAL)
for row in reader:
print(row)
try:
conexion = pymysql.connect(host='localhost',port=3306,user='root',password='',db=... | true |
7b1306a50784569059742e0b0b1b54d737d5a377 | Python | oblr/simplex-py | /solver/pivoting/table_functions.py | UTF-8 | 467 | 2.625 | 3 | [] | no_license |
def _m_return(m):
if m >= 0:
return False
else:
return True
def is_not_final_tableau(table):
m = min(table[-1, :-1]) # minimum last row <=> minimum objective fct. coeffs
return m < 0 # <=> not m >= 0
def is_not_final_tableau_r(table):
# print(table, table[:-1, -1])
# print... | true |
364852ec325d05c862df903a33bc67940b3a4d03 | Python | miyu/Transistors | /Old/FoxAndGeese/FoxAndGeese_SVG_VIS_FOR_BRIFL.py | UTF-8 | 2,038 | 2.84375 | 3 | [] | no_license | # Author: S. Tanimoto
# Purpose: test svgwrite with the new SOLUZION server and client
# Created: 2017
# Python version 3.x
import svgwrite
from FoxAndGeese import State, FOX, GOOSE, WHITE_SQ, BLACK_SQ
DEBUG = False
W = 320 # BOARD_WIDTH
SQW = W/8
HALF_SQW = SQW/2
THREE_QUARTER_SQW = 3*(HALF_SQW/2)
def render_state... | true |
ad4d954ad5caeb9b1d6dcc7b86618922be50bbd2 | Python | AyushSingh445132/What-I-have-learnt-so-far-in-Python | /3.2.Substaction Calculation.py | UTF-8 | 225 | 4.34375 | 4 | [] | no_license | #Calculation for Substraction
print("Enter from which the number is going to be deducted ")
s1 = input()
print("Enter the number to be substracted")
s2 = input()
print("Difference of these two numbers is", int(s1) - int(s2)) | true |
8ce0e396dd785ba67a1cfe074eaec4cd8fd8ddbd | Python | rschlaefli/19fs-dspa-project | /scripts/stream_cleaning.py | UTF-8 | 6,923 | 2.6875 | 3 | [] | no_license | import sys
from tqdm import tqdm
if sys.version_info[0] < 3:
raise Exception("Python 3 or a more recent version is required.")
def main():
print("Cleaning 1k User Streams:")
clean_streams(post_stream_path="./data/1k-users-sorted/streams/post_event_stream.csv",
comment_stream_path="./data/1k-users... | true |
4b9627f83cc218d573d2cc653f782c67c6b16de6 | Python | dimasahmad/bootcamp | /hackerrank/challenges/picking_numbers/test_picking_numbers.py | UTF-8 | 190 | 2.71875 | 3 | [] | no_license | from picking_numbers import picking_numbers
def test_case_0():
assert picking_numbers([4, 6, 5, 3, 3, 1]) == 3
def test_case_1():
assert picking_numbers([1, 2, 2, 3, 1, 2]) == 5
| true |
a1b97aacb585af2cdca9cf95755894658631938c | Python | Splixxy/Cron-Job | /File-Changes.py | UTF-8 | 907 | 2.671875 | 3 | [] | no_license | #imports the os package and inotify
import os
from inotify_simple import INotify, flags
#pulls in the package
inotify = INotify()
#runs the below command so this script will keep running once it's finished
os.system("while :; do python3 File-Changes.py; done")
#creates the watch flags
watch_flags = flags.CREATE | flags... | true |
4f03f858c1f981c5b57f1f7417963704e7bfd347 | Python | RainFZY/LeetCode-Practice | /234.回文链表.py | UTF-8 | 1,336 | 3.59375 | 4 | [] | no_license | #
# @lc app=leetcode.cn id=234 lang=python3
#
# [234] 回文链表
#
# @lc code=start
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
# 法一,额外O(n)空间
class Solution:
def isPalindrome(self, head: ListNode) -> bool:
... | true |
72403071f4bcaf23abeb10d5ad3827945132c2e1 | Python | dilipksahu/Python-Programming-Example | /Dictionary Programs/printPossibleWordfromChars.py | UTF-8 | 508 | 4.3125 | 4 | [] | no_license | # Possible Words using given characters in Python
'''
Input : Dict = ["go","bat","me","eat","goal","boy", "run"]
arr = ['e','o','b', 'a','m','g', 'l']
Output : go, me, goal.
'''
def possibleWords(Input, arr):
for word in input:
temp = ''
for ch in word:
if ch in arr:
... | true |
9d5e1e29de43c5307425d7c49fc46dc218621d23 | Python | LuisChaballero/GELU | /Classes/ClassDirectory.py | UTF-8 | 2,576 | 3.3125 | 3 | [] | no_license |
from Classes.FunctionDirectory import FunctionDirectory
# from FunctionDirectory import FunctionDirectory # Import Table class
class ClassDirectory:
def __init__(self):
self.__dir = {} # class_name : FunctionDirectory()
# Add a class to the ClassDirectory
def add_class(self, class_name):
if self.scope... | true |
66e2d7829162564fba83177ecebc345e26148677 | Python | omerdagan84/pythonGUI | /first.py | UTF-8 | 5,222 | 3.203125 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding: iso-8859-1 -*-
import tkinter
from lightswitch import lightswitch
from boiler import boiler
from irrigation import irregation
class simpleapp_tk(tkinter.Tk): #app defined as a class
def __init__(self,parent): #define the init function of the class
tkinter.Tk.__... | true |
dd8574fddfe4f08495f7ec5f00cd15e8e250ea5d | Python | 14rcole/callbacks | /examples/exception_callbacks.py | UTF-8 | 603 | 2.765625 | 3 | [] | no_license | from __future__ import absolute_import
from __future__ import print_function
from callbacks import supports_callbacks
def handler(exception):
print("I handled exception %s" % str(exception))
def reporter():
print("I noticed an exception occured")
@supports_callbacks
def target():
raise RuntimeError
tar... | true |
0e6b515822487aa5c22cb84a29f593bb71c6a104 | Python | Mamath78/Eyetracking-NHP | /Program/Script/Programme_tobii/tobiiresearch/implementation/HMDLensConfiguration.py | UTF-8 | 914 | 3.203125 | 3 | [] | no_license | class HMDLensConfiguration(object):
''' Represents the lens configuration of the HMD device.
Return value from EyeTracker.get_hmd_lens_configuration.
'''
def __init__(self, left=None, right=None):
if ((not isinstance(left, tuple) or
not isinstance(right, tuple))):
rais... | true |
0b620a9e9231c6ec6693deb33930c8d504da09f2 | Python | AJBroomfield/pythonproblems | /tutorial/iteration.py | UTF-8 | 130 | 3.859375 | 4 | [] | no_license | #for i in range(5):
# name=str(input("What is your name? "))
# print(f'{name} is awesome!')
for i in range(5):
print(i) | true |
16e8cdfc00b938d9d4cb8895b8753c2080c874ab | Python | kasmith/physicsTable | /Code/physicsTable/utils/SPSA.py | UTF-8 | 8,273 | 3.296875 | 3 | [] | no_license | #!/usr/bin/env python
"""
A class to implement Simultaneous Perturbation Stochastic Approximation.
"""
import numpy as np
class SimpleSPSA ( object ):
"""Simultaneous Perturbation Stochastic Approximation.
"""
# These constants are used throughout
alpha = 0.602
gamma = 0.101
def __... | true |
7575f9d2a8ec70f273c3d940b5b4f873d1a76ddf | Python | jhonaelramos/Odoo-14-Development-Essentials | /_scripts/ch07_recorsets_code.py | UTF-8 | 5,823 | 2.5625 | 3 | [
"MIT"
] | permissive | """
To run this script, using click-odoo:
$ pip3 install -e /path/to/odoo
$ pip3 install click-odoo
$ click-odoo -c my.conf -b mydb myscript.py
To try the code in the interactive shell:
$ pip3 install -e /path/to/odoo
$ odoo shell -c my.conf
Inspecting the Odoo shell execution environment:
>>> self
res.u... | true |
57b1ce4977271fcbba2b0b08d1890a0a57fd2b72 | Python | haiyennghy/smartvigilance | /Visualization/visualization.py | UTF-8 | 1,703 | 3.28125 | 3 | [] | no_license | # For dataframe
import pandas as pd
# Visualizations
import seaborn as sns
import matplotlib.pyplot as plt
from mlxtend.plotting import plot_learning_curves
class Visualization:
def __init__(self):
self.plot_style = 'seaborn'
# Useful to plot training curves for neural models models such as LSTM, CN... | true |
22405bb8edb6ce2b315c6f416f647a8aa5e196bb | Python | jpborrero/DataScienceProject | /histogram.py | UTF-8 | 1,292 | 2.859375 | 3 | [] | no_license | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
def makeHisto(dataFile, attrX, attrOther, numFilters, catFilters, ranges, bin_num):
columns = [attrX]
for attr in attrOther:
columns.append(attr)
df = pd.read_csv(dataFile, usecols=columns)
#apply filters
df_f = df
for filter in numFilte... | true |
5fd213318731cd0605da9a01fdf48ea51a9fe78c | Python | KangShanR/blogs | /_drafts/python/OS/ThreadSafeQueue.py | UTF-8 | 1,957 | 2.9375 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# ThreadSafeQueue.py
#
# Copyright 2020 kangshan <kangshan123@yeah.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version ... | true |
95e2c1d2f89814a2ed46e27b528a6475c09686cb | Python | cycosan/traning | /hyee/function.py | UTF-8 | 917 | 3.453125 | 3 | [] | no_license | '''name1=input("enter your name")
displacement1=input("enter displacement")'''
def caeser_cipher(name,displacement):
finalstring=""
finalstri1=""
for char in name:
test=ord(char)
if(test>=60and test<=90):
asci=ord(char)+int(displacement)
if(asci>90):
asci=asci-90
asci=64+asci
finalstring... | true |
6a116c68d13a9e37fe6f85dc9d5334abbc21df47 | Python | Gembelton/myGameOfflineVersion | /game/pygame begin.py | UTF-8 | 4,526 | 3.1875 | 3 | [] | no_license | import pygame
import random
#---------------------------Цвета----------------------
black = (0, 0, 0)
white = (255, 255, 255)
green = (0, 255, 0)
red = (255, 0, 0)
#свои цвета
ber = (25,170,175)# березовый
lber = ( 9,220,190)# l - светлый березовый
Dpurple = (70,2,90)# D - темный фиолетовый
purple = ( 190... | true |
d3a14d95e358bfb976b91c9eb0d095059cd9d1a2 | Python | ahdahddl/cytoscape | /csplugins/trunk/ucsd/rsaito/rs_Progs/rs_Python/rs_Python_Pack/tags/rs_Python_Pack090515/Seq_Packages/Motif/SwissPfam_downsize1.py | UTF-8 | 1,115 | 2.546875 | 3 | [] | no_license | #!/usr/bin/env python
import sys
class SwissPfam_Reader:
def __init__( self, ifilename, ofilename = None):
self.ifilename = ifilename
self.ofilename = ofilename
self.fh = open( self.ifilename, "r" )
self.fw = None
def output(self, line):
if self.ofilename:
... | true |
5594d3d0798ee57d3d9e6d31fd0b79eaa1e5439a | Python | SabrineKassdallah/internet-des-objet-IOT | /python/flask-demos/flask-error-page.py | UTF-8 | 482 | 2.890625 | 3 | [] | no_license | # coding: utf8
# Importer la bibliothèque Flask
from flask import Flask, abort
# Initialisze l'application Flask
app = Flask( __name__ )
@app.route('/')
def racine():
return 'Appeler /mon-erreur avec id<100 ou id>=100'.decode('utf8')
@app.route('/mon-erreur/<int:id>')
def demo( id ):
if id > 100:
# Retourner u... | true |
3dec9c339af814e74350a2a31faaabbb6e0ab300 | Python | gabriellaec/desoft-analise-exercicios | /backup/user_076/ch28_2020_03_25_18_57_04_499585.py | UTF-8 | 129 | 3.40625 | 3 | [] | no_license | contador = 0
while contador < 99:
soma =0
soma = soma + 1 / 2**contador
contador = contador +1
print (soma)
| true |
c128b0f2406dbcf010153ccc4383b297fb484ed0 | Python | jerseybiomed/dns-server | /request_parser.py | UTF-8 | 2,401 | 2.625 | 3 | [] | no_license | import binascii
from default_parser import Parser
from answer_parser import AnswerParser
from socket import *
from time import time
class RequestParser:
def __init__(self, storage):
self.parser = Parser()
self.storage = storage
self.answer_parser = AnswerParser()
def parse_request(sel... | true |
6c1144d43160884d3dd253c49b1716b09ecaf232 | Python | yougukepp/flyer | /pc/comm/serial.py | UTF-8 | 1,115 | 2.671875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
from serial import Serial
from serial.tools import list_ports
#from PyQt5.QtWidgets import *
# 1bit 起始位 8bit 数据 1bit停止位
g_a_byte_bit_nums = 10
class FCSerial(Serial):
def __init__(self, port, baudrate):
super(FCSerial, self).__init__()
se... | true |
e6d2d854d4ea449c45ccc42b35da06ffe2bcc8bd | Python | skasai5296/captioning | /code/resize.py | UTF-8 | 406 | 2.5625 | 3 | [] | no_license | import os
from PIL import Image
def main():
inpath = '../../../datasets/mscoco/train2017'
outpath = '../../coco/dataset'
if not os.path.exists(outpath):
os.mkdir(outpath)
for f in os.listdir(inpath):
im = Image.open(os.path.join(inpath, f))
im_resized = im.resize((256, 256))
... | true |
516090796fb874e0e6dd9770e4c66915e827cf18 | Python | ChangXiaodong/Leetcode-solutions | /1/226-Invert-Binary-Tree.py | UTF-8 | 1,618 | 3.546875 | 4 | [] | no_license | __author__ = 'Changxiaodong'
'''
Invert a binary tree.
4
/ \
2 7
/ \ / \
1 3 6 9
to
4
/ \
7 2
/ \ / \
9 6 3 1
'''
import time
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.... | true |
4dc68d613af4461174f2025c0ebca461070f76ad | Python | silenttemplar/tensorflow_example_project | /example/visualization/ch04/bar_plot/rect_object_basic.py | UTF-8 | 916 | 3 | 3 | [] | no_license | import matplotlib.pyplot as plt
import numpy as np
np.random.seed(0)
n_data = 10
data = np.random.uniform(10, 20, (n_data, ))
data_idx = np.arange(n_data)
data_labels = np.array(['class '+str(i) for i in range(n_data)])
fig, ax = plt.subplots(figsize=(10, 7))
ax.tick_params(labelsize=15)
y_ticks = ax.get_yticks()
... | true |
5fe27b86a9ee48992673548e1bf5c9bd7c177460 | Python | aaron-goshine/python-scratch-pad | /workout/base_ten_to_number.py | UTF-8 | 1,024 | 3.765625 | 4 | [] | no_license | ##
# Convert a number from one base to another.
# Both the source base and the destination base must be
# between 2 and 16
#
# from hex_digit import *
def int2hex(number):
hexstring = '' if number > 0 else '0'
while number > 0:
hexstring += '0123456789ABCDEF'[number % 16]
number = int(number ... | true |
8020d1ab37052334efd15995fada0431998d7c10 | Python | dsacco22/code_repo | /python_repo/initial.py | UTF-8 | 1,537 | 3.359375 | 3 | [] | no_license | import numpy as np
import array
import random
np.__version__
result = 0
for i in range(100):
result += i
x = 4
x = 'four'
l = list(range(10))
l
type(l[0])
l2 = [str(c) for c in l]
l2
type(l2[0])
l3 = [True, "2", 3.0, 4]
l3
[type(item) for item in l3]
a = array.array('i', l)
a
np.array([1.22,2,3,4,5], dtype="... | true |
b666646765aa996b1abdf9a47081acefed659536 | Python | jamesnatcher/Old-Python-Stuff | /CS 101/final/conversions(final).py | UTF-8 | 926 | 3.53125 | 4 | [] | no_license | #################################################################
#
# Paul James NATCHER
#
#################################################################
# Points possible: 12
def centimeters_to_us_units(cm):
amount = cm
miles = int((amount)) // int(160934.4)
yards = int((amount) % 160934.4 ) // int(91... | true |
2d4e14cdfb9122381cfb686a922fc73b705ef4d6 | Python | TheStar-Cyberstorm/AllCodes | /chat-client.py | UTF-8 | 1,584 | 2.84375 | 3 | [] | no_license | # use Python 3
import socket
from sys import stdout
from time import time
# enables debugging output, outputs time delta of each recieved data and
# concatenated bytes
DEBUG = False
# set the server's IP address and port
ip = "138.47.102.120"
port = 31337
# covert message settings
covert_delta = 0.090
ge_delta = "1"... | true |
97dc7e23243b2aae2a74ccf3f0d41978cbe38036 | Python | dfdazac/studious-rotary-phone | /00-rl-intro/kbandit.py | UTF-8 | 641 | 3.359375 | 3 | [
"MIT"
] | permissive | import numpy as np
class KBandit:
"""
A k-armed bandit.
Args:
- k (int): the number of actions.
"""
def __init__(self, k):
self.k = k
self.action_values = np.random.normal(size=k)
self.optimal_action = np.argmax(self.action_values)
def get_reward(self, a):
... | true |
cebaddbfcf0f2a3c1a1a14de6bafe623dc15e2e3 | Python | LeaRNNify/Property-directed-verification | /source/hamming_automaton.py | UTF-8 | 6,757 | 3.546875 | 4 | [] | no_license | from dfa import *
import copy
import random
class HammingNFA:
"""
class for hammingNFA of a word for a given distance
"""
def __init__(self, word, distance, alphabet=None):
self.init_state = (0, 0)
self.transitions = {}
self.distance = distance
self.word = word
... | true |
b1a6869b50ab934a1b97432de302f9c289c6026e | Python | KevenGe/LeetCode-Solutions | /problemset/1838. 最高频元素的频数/solution.py | UTF-8 | 711 | 3.640625 | 4 | [] | no_license | # 1838. 最高频元素的频数
# https://leetcode-cn.com/problems/frequency-of-the-most-frequent-element/
from typing import List
class Solution:
def maxFrequency(self, nums: List[int], k: int) -> int:
nums = sorted(nums)
left = 0
sums = 0
ans = 1
right = 1
while right < len(num... | true |
8a54389a6ae23a6591725d19f60609e7f3cca667 | Python | CamiloCastiblanco/AYED-AYPR | /AYED/AYED 2020-1/sduisf.py | UTF-8 | 615 | 3.25 | 3 | [] | no_license | from sys import stdin
def idioma(palabra):
if palabra=="HELLO":
return "ENGLISH"
elif palabra=="HOLA":
return "SPANISH"
elif palabra=="HALLO":
return "GERMAN"
elif palabra=="BONJOUR":
return "FRENCH"
elif palabra=="CIAO":
return "ITALIAN"
elif ... | true |
5c5b70f8f24bbacf953320110c87ad590209eb02 | Python | VimanyuAgg/code-morsels | /trie_construction.py | UTF-8 | 6,923 | 3.390625 | 3 | [] | no_license | class Node:
def __init__(self, val=None, next=None):
self.val = val
self._next = [] ## why can't it be set in the first place?
if next is not None:
print("hi: {}".format(self))
self.next = next
@property
def val(self):
return self._val
@property
def next(self):
# print("{} next called: {}".format... | true |
c4698245e6fe045506b6e845247aaa7d7e0d268a | Python | GenericStudent/alexa-surepet-python | /lambda.py | UTF-8 | 7,422 | 2.5625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# This sample demonstrates handling intents from an Alexa skill using the Alexa Skills Kit SDK for Python.
# Please visit https://alexa.design/cookbook for additional examples on implementing slots, dialog management,
# session persistence, api calls, and more.
# This sample is built using the ... | true |
c7af2c8e2975c24910677615aa8fe9f93db1c7c2 | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_199/331.py | UTF-8 | 468 | 3.140625 | 3 | [] | no_license | t = input()
for T in xrange(1,t+1):
print "Case #"+str(T)+":",
ans = 0
inp = raw_input().split()
x = list(inp[0])
k = int(inp[1])
l = len(x)
for i in xrange(0,(l-k)+1):
if(x[i]=='-'):
ans += 1
for j in xrange(k):
if(x[i+j]=='-'):
... | true |