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 |
|---|---|---|---|---|---|---|---|---|---|---|
369d2c0f3bc02d5e3127cbd92728bf37b17e91ca | cvam29/Python | /reverse_string.py | UTF-8 | 168 | 3.46875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Feb 17 15:06:33 2021
@author: home
"""
string=input('Enter the string: ')
reverse_string=string[::-1]
print(reverse_string) | true |
032f0b3bee5f5970821d7923de603ff376b1b77a | Matheus-Pontes/Curso-Python-3 | /ex115/lib/interface/__init__.py | UTF-8 | 684 | 3.578125 | 4 | [
"MIT"
] | permissive | def leiaint(msg):
while True:
try:
n = int(input(msg))
except (ValueError, TypeError):
print("\033[31m[ERROR] digite um valor inteiro valido...\033[m")
continue
except KeyboardInterrupt:
n = 0
break
else:
return ... | true |
774679ade24e35ac3a84e3f59501b33661579586 | sibarras/PythonExamples | /diferencia_super_and_literalsuperclass.py | UTF-8 | 567 | 4.375 | 4 | [] | no_license | class Super:
def __init__(self, nombre):
self.nombre = nombre
def __str__(self):
return "Mi nombre es " + self.nombre + "."
# Si utilizo la funcion super, no es necesario usar self
# ni saber el nombre de la superclase que utilizo.
class Sub(Super):
def __init__(self, nombre):
supe... | true |
2a3ae1765a11cb6a7c5af257d7f6eafca3f655ad | WatanukiRasadar/flow_core | /core/validators/_dict.py | UTF-8 | 762 | 2.671875 | 3 | [] | no_license | from kylin.extras.validator import Validator
from asyncio import wait, FIRST_EXCEPTION
from typing import Dict, AnyStr
class DictValidator(Validator):
def __init__(self, schema: Dict[AnyStr, Validator]):
self.schema = schema
async def validate(self, value):
if not isinstance(value, dict):
... | true |
547293ca75c5a7c8e4c5bba419d7365cef0cdf8a | CarlEkerot/aoc2017 | /day16.py | UTF-8 | 902 | 3.015625 | 3 | [] | no_license | def parse():
with open('day16.txt') as f:
return f.read().strip().split(',')
def solve1(movs, ps=list('abcdefghijklmnop')):
l = len(ps)
for m in movs:
if m[0] == 's':
n = int(m[1:])
ps = ps[l - n:] + ps[:l - n]
elif m[0] == 'x':
i, j = tuple(map(... | true |
7a2003cb9c4f41351844c1642bd329983b7ca839 | Orcha02/holbertonschool-higher_level_programming | /0x02-python-import_modules/2-args.py | UTF-8 | 678 | 3.453125 | 3 | [] | no_license | #!/usr/bin/python3
if __name__ == "__main__":
import sys
if len(sys.argv) is 2:
print("{:d} argument:".format(len(sys.argv) - 1))
# To show not just "argument" and the count, but the actual argument
print("{:d}: {}".format(len(sys.argv) - 1, sys.argv[1]))
elif len(sys.argv) is 1:
... | true |
45de8997af117860ddd982ebf8543c21c3922fed | Choi-SeoYun/Korean-License-Plate-Recognition-WeatherCondition | /first_django/firstproject/data/augmentation.py | UTF-8 | 2,742 | 3.28125 | 3 | [] | no_license | '''Augmentation methods used are Padding, Horizontal shearing in clockwise direction,
Vertical shearing in clockwise direction, Horizontal shearing in anti-clockwise direction,
Vertical shearing in anti-clockwise direction'''
# Importing libraries
import cv2
import numpy as np
import pandas as pd
from augmentation_m... | true |
1247f4b4ff9b94e7fb011914d746b29702b4c149 | MoisesHer/gluon-nlp | /scripts/language_model/transformer/softmax.py | UTF-8 | 17,317 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | true |
4f83c39ddcbd72b500ab9769798a6f295ad250b4 | RalfiCode/Introduction | /Introduction/Lesson8/function8.py | UTF-8 | 363 | 3.484375 | 3 | [] | no_license | def mail() -> str:
isim = input("Isim igiriniz: ")
soyad = input("Soyad giriniz: ")
domain = input("Domain giriniz: ")
if not domain:
return "{}.{}@bilgeadam.com".format(isim,soyad)
else:
return "{}.{}@{}".format(isim,soyad,domain)
a = mail()
print(a)
print(type(a))
print("Mail meto... | true |
fd61d57da9231dc2a98f4b0245a504a836c817d8 | pchampin/fsa4streams | /utests/test_issue_6.py | UTF-8 | 1,583 | 2.53125 | 3 | [] | no_license | from fsa4streams.fsa import FSA
from test_fsa import assert_matches
from unittest import skip
@skip('not fixed yet')
def test_issue_6_a():
fsa = FSA.make_empty(allow_overlap=True)
(fsa
.add_state("start")
.add_transition("a", "s1")
.add_state("s1")
.add_transition("b", "s2")
.add... | true |
e7c5fc33b48e6c1304532891947b843eb06f72b5 | Egorshve/Esercizi-informatica | /es32pag192.py | UTF-8 | 464 | 3.796875 | 4 | [] | no_license | mappa={}
while True:
conto=input("Scrivi il numero del conto: ")
saldo=input("Scrivi il numero del saldo: ")
mappa[conto]=saldo
risposta=int(input("Se vuoi continuare schiaccia 1 "))
if risposta==1:
print()
else:
break
conto=input("Di quale conto vuoi sapere il sald... | true |
fbbd63437a4d0cf1969c80d7d82eb334c554b13a | kayarre/dmsh | /test/test_polygon.py | UTF-8 | 608 | 2.5625 | 3 | [
"MIT"
] | permissive | import dmsh
from helpers import assert_norm_equality, save
def test(show=False):
geo = dmsh.Polygon(
[
[0.0, 0.0],
[1.1, 0.0],
[1.2, 0.5],
[0.7, 0.6],
[2.0, 1.0],
[1.0, 2.0],
[0.5, 1.5],
]
)
X, cells = dmsh... | true |
813b1b1af5e2367d0656f16eedc1175a047c1124 | iarakshana/hw3 | /t2_checkerboard.py | UTF-8 | 1,524 | 3.9375 | 4 | [] | no_license | #!/usr/bin/env python
import turtle
t = turtle.Turtle()
import turtle
t = turtle.Turtle()
t.speed(0)
#let us define a function that draws and fills one square
def square(size,alternate,color):
t.color(color)
t.begin_fill()#to fill and set the color
for i in range(4):
t.forwa... | true |
5aed8c260719867c7982cabcd749e24f9398de53 | Clinical-Medical-Physics/ImageShifts | /defs.py | UTF-8 | 513 | 3.078125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Fri Dec 4 18:34:16 2020
@author: haywoojr
"""
import datetime
#generator for fridays in the year
def allFridays(year):
d=datetime.date(year,1,1)
d += datetime.timedelta(days = 4 - d.weekday())
while d.year == year:
yield d
d += datetime.timedelta(da... | true |
9bb66d8973a83701307fa77749f4bbe7761f7688 | emmanuelurbina/pywombat_ejercicios | /basicos/cuadrado_lista/cuadrado.py | UTF-8 | 146 | 3.25 | 3 | [] | no_license | lista = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
def cuadrado(lista):
res = list(map(lambda n: n**2, lista))
return res
print(cuadrado(lista))
| true |
1e6cc80020ed91918b516026df265b6d59bd86fe | ClementPinard/SfmLearner-Pytorch | /datasets/stacked_sequence_folders.py | UTF-8 | 2,029 | 2.671875 | 3 | [
"MIT"
] | permissive | import torch.utils.data as data
import numpy as np
from imageio import imread
from path import Path
import random
def load_as_float(path, sequence_length):
stack = imread(path).astype(np.float32)
h,w,_ = stack.shape
w_img = int(w/(sequence_length))
imgs = [stack[:,i*w_img:(i+1)*w_img] for i in range(s... | true |
0fac620d17693c383ad63afbeaeddbfd5c7e021e | laserson/numba | /oldnumba/tests/test_extern_call.py | UTF-8 | 1,955 | 2.703125 | 3 | [
"BSD-2-Clause"
] | permissive | #! /usr/bin/env python
# ______________________________________________________________________
'''test_extern_call
Unit tests checking on Numba's code generation for Python/Numpy C-API calls.
'''
# ______________________________________________________________________
import sys
import unittest
from numba import *
... | true |
eda52e3de48531eab0aaf5a9fa7a8ca393a690fc | ismcalpi/R3GI | /lib/pokedex.py | UTF-8 | 2,922 | 3.125 | 3 | [] | no_license | import json
with open('./lib/pokedex.json', 'r') as f:
pokedex_json = json.load(f)
class Team:
def __init__(self, config):
with open(config) as c:
config_json = json.load(config)
self.members = []
for key in config_json.keys():
self.members.append(Pokemon(key[... | true |
83f6c4658cb09d6c97d814112835c0b615b33741 | TAMREF/problem-solving-storage | /AutoDownloaded Codes/sshstamref/1065/1065.py3.py | UTF-8 | 154 | 2.8125 | 3 | [] | no_license | n=int(input())
if n<100:
print(n)
exit()
cnt=99
for i in range(111,n+1):
s=list(map(int,str(i)))
if 2*s[1]==(s[0]+s[2]): cnt+=1
print(cnt) | true |
6379857cb6fbf4b78b70a536038d66fb97f3a8f0 | alankrit03/HackerRank_Algorithms | /Almost Sorted.py | UTF-8 | 938 | 3.46875 | 3 | [] | no_license | #!/bin/python3
# Complete the almostSorted function below.
def almostSorted(arr):
sorted_arr = sorted(arr)
n = len(arr)
i = 0
j = n-1
if arr==sorted_arr:
print('yes')
else:
while (arr[i]==sorted_arr[i] or arr[j]==sorted_arr[j]):
if arr[i]!=sorted_arr[i]:
... | true |
b923ec0e3451664fd8a2040406df890eb11f293c | PacktPublishing/Learning-Python-Artificial-Intelligence-by-Example | /4. Predicting the steering angle of a car/Source/data/generators.py | UTF-8 | 3,951 | 3.109375 | 3 | [
"MIT"
] | permissive | """
Data generators for loading training, validation and test data sets
"""
import pandas as pd
import numpy as np
import cv2
import os
import scipy.misc
from keras.utils import Sequence
def get_image(image_path, crop_position=100, image_size=(66, 200, 3), debug=False):
"""
Load an image and return resized ... | true |
5af69b7d01867ab1043475afb57e7dac6a0d2110 | halilyaman/gender_prediction | /neural_network.py | UTF-8 | 2,652 | 3.375 | 3 | [] | no_license | import numpy as np
import pandas as pd
import random
gender_data = pd.read_csv("datasets/gender.csv")
# data preprocessing
test_size = round(33/100*len(gender_data))
indices = gender_data.index.tolist()
test_indices = random.sample(population=indices, k=test_size)
# splitting train and test data
training_data = gend... | true |
5e2bae38f343bc71f27fb1059e69cf1b6b58862e | ashmita18-dxc/python-assignments | /config/scratches/flowcontrol.py | UTF-8 | 736 | 4.46875 | 4 | [] | no_license | #if-else
a=int(input('Enter 1st number: '))
b=int(input('Enter 2nd number: '))
c=int(input('Enter 3rd number: '))
if a>b and a>c:
print(a)
else:
if b>c:
print(b)
else:
print(c)
#assignment2
marks=int(input('Enter marks: '))
if marks>0 and marks<=100:
if marks>=0 and marks<=39:
... | true |
ed7b7b87b076ce2b59eccda5a3d79de06ec513dc | fafachen61/DoA_experiment_code | /auto_calculate_PC_N3.py | UTF-8 | 8,216 | 2.78125 | 3 | [] | no_license | import paho.mqtt.client as receive #import library
import numpy as np
import math
import collections, time
import matplotlib.pyplot as plt
import pandas as pd
from matplotlib.animation import FuncAnimation
from scipy.interpolate import interp1d
import scipy
MQTT_SERVER = "192.168.50.117" #specify the broker address, ... | true |
db0e16dfc356ddf5e0b12eec827bad278bd08f93 | reniass/MIT-Introduction-to-Computer-Science-and-Programming-Using-Python | /midterm_exam/general_poly.py | UTF-8 | 612 | 3.640625 | 4 | [] | no_license |
def general_poly(L, x):
exponent = len(L) - 1
function_value = 0
s = 'F(%r)= ' %x
for i in range(len(L)):
function_value += L[i] * x ** exponent
exponent -= 1
if i == len(L) - 1:
s1 = ' ' + str(L[i]) + ' *' ' ' + str(x ** exponent) + ' ='
else:
... | true |
388f9be3e18911e104ede1f7c3b147d4e868ba00 | icyJoseph/codejam2018 | /solD/solutionD.py | UTF-8 | 2,665 | 3.21875 | 3 | [] | no_license | import sys
import math
PI = math.pi
def solve(case_number, area):
# center of the faces
x_center = [0.5, 0, 0, 1]
y_center = [0, 0.5, 0, 1]
z_center = [0, 0, 0.5, 1]
# normal vectors
cos_x_n = cos_N(x_center[:3])
cos_y_n = cos_N(y_center[:3])
cos_z_n = cos_N(z_center[:3])
proj_a... | true |
c7181bfefe1bca28cb2fa0c64e962ea1f26d6643 | honeythisa/LPI | /exerc/o resto/isso apareceu na gravaçao.py | UTF-8 | 124 | 2.96875 | 3 | [
"MIT"
] | permissive | a = input('Que horas o alarme deve tocar?:')
print('Acordar,já são {} horas da manhã, hora de ir para o IFTM.'.format(a)) | true |
42dc45e57c05c8f86e7991b5cdfa60b617b3809b | nstrashevskii/py_110_for_git | /prac_3/json_pickle.py | UTF-8 | 793 | 3.09375 | 3 | [] | no_license | import json
import pickle
def to_json_string(obj):
print(json.dumps(obj))
def to_pickle_file(obj, filename):
if not filename.endswith('.json'):
filename += '.pickle'
with open(filename, 'wb') as pickle_file:
pickle.dump(obj, pickle_file)
def to_json_file(obj, filename: str, indent=4):
... | true |
863a4ea381ed3ef391b0a731480ce3044ffc82d3 | MANSURTHAPA/AttendanceManagementSystem | /Recognizer.py | UTF-8 | 6,242 | 2.578125 | 3 | [] | no_license |
from imutils.video import VideoStream
from imutils.video import FPS
import face_recognition
import imutils
import pickle
import time
import datetime
import pandas as pd
from df2gspread import df2gspread as d2g
import cv2
from openpyxl import Workbook
import gspread
from oauth2client.service_account import ServiceAcco... | true |
bbedeed3a73f548a9b1039fa1d11568afd2b79ba | donbranson1/test | /Assignment2/Machine Learning.py | UTF-8 | 90,925 | 2.546875 | 3 | [] | no_license | import unittest
import pandas as pd
import numpy as np
import sys
from colorama import Fore
import matplotlib.pyplot as plt
from sklearn.neighbors import KNeighborsClassifier
from sklearn.neural_network import MLPClassifier
from sklearn.ensemble import AdaBoostClassifier
from sklearn.ensemble import RandomFore... | true |
5edd91b374ebe208b49066cb683cd3ad5f64a6d6 | Lagom92/TIL | /Algorithm/pro/Problem/num_p_and_y.py | UTF-8 | 667 | 4.0625 | 4 | [] | no_license | # 프로그래머스 문자열 내 p와 y의 개수
# https://programmers.co.kr/learn/courses/30/lessons/12916
'''
p 와 y의 개수가 같은지 체크하는 문제
대소문자 구별 X
'''
def solution(s):
s = s.upper()
num_p, num_y = 0, 0
for i in s:
if i == 'P':
num_p += 1
elif i == 'Y':
num_y += 1
if num_p == num_y:
... | true |
1bed50fd9c8d3d3385ad73b9dc38d2c42cc7c4c9 | shantamdas/mypostsd | /mypost/utils.py | UTF-8 | 1,351 | 2.625 | 3 | [] | no_license | import hashlib
import hmac
import re
from config import *
USER_RE = re.compile(r"^[a-zA-Z0-9_-]{3,20}$")
PASSWORD_RE = re.compile(r"^.{3,20}$")
EMAIL_RE = re.compile(r'^[\S]+@[\S]+\.[\S]+$')
def render_str(template, **params):
"""
Return a string rendered by a Jinja2 template
"""
t = JINJA_ENV.get_template(tem... | true |
d7fb48620dcd3b62bcd7da9a37f47b2fa0235046 | Harbes/python | /quant_low_price.py | UTF-8 | 1,645 | 2.609375 | 3 | [] | no_license | import pandas as pd
import numpy as np
from pandas import DataFrame
# low-price 在中国是不显著的
#data=pd.read_pickle('F:/data/xccdata/PV_datetime')[['adj_open','adj_close']]
data=pd.read_pickle('/Users/harbes/data/xccdata/PV_datetime')[['amount','opnprc','clsprc','adj_open','adj_close','size_tot','size_free']]
filter_=pd.rea... | true |
f5525517a1baa43ec9172d46d0ed71f47094c4a9 | baldFemale/Machine-Learning-from-Numpy-Scratch | /NeuralNetwork/main.py | UTF-8 | 2,393 | 2.703125 | 3 | [] | no_license | import struct
import numpy as np
from NeuralNetwork.BPNetwork import BPNetwork
def load_data():
for file in ["train-images.idx3-ubyte", "train-labels.idx1-ubyte", "t10k-images.idx3-ubyte",
"t10k-labels.idx1-ubyte"]:
filepath = "../dataset/"+file
data = open(filepath,"rb").read()
... | true |
85b5fd237b3842bd28270fa11b9f33c2ece20777 | Cova14/PythonCourse-Lists | /exercises/sum.py | UTF-8 | 243 | 3.765625 | 4 | [] | no_license | # def calculate_sum():
# calculate_sum()
print('Lets calculate a sum of lot of numbers')
print('Heres the list')
numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10]
print(numbers)
total = sum(numbers)
print('The sum of the numbers is:', total) | true |
fa8cca088ee337560fb75ae4c154df69f9ca78d5 | Yeharold/Rasp-APP | /app/models.py | UTF-8 | 504 | 2.734375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2017-12-12 17:03:10
# @Author : YeHarold (1174484433@qq.com)
# @Link : http://example.org
import sqlite3 as db
conn = db.connect('app/database/app.db',check_same_thread = False)
c = conn.cursor()
def putData(tempData,timeData):
''' 往数据库中放入数据
temp... | true |
653fca966576a6ff9cf79aeddb9487b8c0bed9a6 | the-fridge/miscellaneous | /huffman_kodierung.py | UTF-8 | 2,221 | 3.09375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon Dec 18 17:45:36 2017
@author: Jonas
"""
import math
text = input( 'Text: ' )
code = input( 'Code: ' ) # das ist ein Alphabet keine doppelten Buchstaben
letters = { }
for l in text:
if l in letters:
letters[ l ] += 1
else:
letters[ l ] = 1
tLetters =... | true |
5def94df1fdc61698c8ea086616df7ede63e40cd | arslan-gait/leetcode-tree-problems | /06.02_100_same_tree.py | UTF-8 | 1,138 | 3.703125 | 4 | [] | no_license | # https://leetcode.com/problems/same-tree/
from collections import deque
class Solution:
# iterative
# space and time complexity - O(min(nodes(p), nodes(q)))
def isSameTree(self, p: TreeNode, q: TreeNode) -> bool:
stack = [(p, q)]
while len(stack) > 0:
first, second = stack.pop(... | true |
72e355704a574f8e3003c5a9b92baaea86b4ede7 | LQDatEco/CodeGym-Project | /DrawCircle.py | UTF-8 | 160 | 3.453125 | 3 | [] | no_license | import turtle
turtle.pensize (10)
turtle.pencolor ("red")
turtle.fillcolor ("yellow")
turtle.begin_fill()
turtle.circle (200)
turtle.end_fill()
turtle.done | true |
452528442d7d84f6d5342ef3f728fe478d513fde | sheldore/ShowMeTheCode | /0010/0010.py | UTF-8 | 874 | 3.0625 | 3 | [] | no_license | # -*-coding:utf8 -*-
# author: yushan
# date: 2017-03-02
# 参考廖雪峰的PIL生成验证码教程
import string
import random
from PIL import Image,ImageDraw,ImageFont,ImageColor,ImageFilter
def get_char():
return random.choice(string.letters)
def get_color():
return (random.randint(64,255),random.randint(64,255),random.randint(6... | true |
93da652bba87f513a517b328a8d7dcc03fb6241c | nikozhuharov/Python-Fundamentals | /Final Exam August/3.py | UTF-8 | 736 | 3.234375 | 3 | [] | no_license | notebook = {}
words = input().split(' | ')
for word in words:
word_arg = word.split(": ")
if word_arg[0] not in notebook:
notebook[word_arg[0]] = [word_arg[1]]
else:
notebook[word_arg[0]].append(word_arg[1])
for word in notebook:
notebook[word].sort(key=lambda x: -len(x))
new_words = i... | true |
33ae3779387a3abccfaa7517ac6d453bc61f18f7 | dilkas/project-euler | /082.py | UTF-8 | 541 | 2.890625 | 3 | [] | no_license | f = open('p082_matrix.txt', 'r')
matrix = []
for line in f.readlines(): matrix.append(map(int, line.split(',')))
f.close()
sums = []
for i in range(80): sums.append([0] * 80)
for i in range(80): sums[i][79] = matrix[i][79]
for j in range(78, -1, -1):
sums[0][j] = sums[0][j + 1] + matrix[0][j]
for i in range(1... | true |
ac7993aebd315b4d762aec2b18c217e801512d54 | nmvijay/feast-spark-engine | /example_spark.py | UTF-8 | 1,612 | 2.640625 | 3 | [] | no_license | """
This is an example for the feature store (end to end)
To show how you could use a custom offlinestore
"""
import pandas as pd
from pandas import Timestamp
from pathlib import Path
from feast import FeatureStore
from feast.repo_config import load_repo_config
# custom offline store
from feast_spark import FileOfflin... | true |
436657de39b50b623f2aa9a72642aa90104d4514 | heitorchang/learn-code | /battles/challenges/created/functionTower.py | UTF-8 | 8,366 | 4.4375 | 4 | [
"MIT"
] | permissive | draft2 = """
You are given a **Function Tower** of multiple levels as an array of strings. The Tower is made of **Bricks** of variable horizontal size and one character tall.
Integer values flow from top to bottom, starting from the topmost level (the first string of the `tower` array).
A brick `[ ... ]` (includ... | true |
5becdfa2c1121ccfd6e808ba12bed101565a6586 | ahmedlone127/nlu | /tests/nlu_core_tests/component_tests/classifier_tests/pos_tests.py | UTF-8 | 359 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | import unittest
from nlu import *
class TestPOS(unittest.TestCase):
def test_pos_model(self):
df = nlu.load("pos", verbose=True).predict(
"Part of Speech Tags identify each token in a sentence with a grammatical label"
)
for c in df.columns:
print(df[c])
if __nam... | true |
cac6d36071176a63271cdceef9931bf76326ed28 | Ibramicheal/Onemonth | /Onemonth/input.py | UTF-8 | 251 | 3.734375 | 4 | [] | no_license | name = input("What is your name my frined? ")
year_of_birth = int(input("When were you born? "))
curent_year = int(input("What is the current year? "))
age = curent_year - year_of_birth
print(f"{name} you are {age} years old, wowowo that's old!!!") | true |
ba112071b48383b4b5c178dfa0d359de42b77d24 | phani-1995/week2 | /datastructures1/Strings/first_Occurance.py | UTF-8 | 388 | 2.984375 | 3 | [] | no_license | class change_frst_rep:
def frst_rep(self,string):
for i in string:
if (i=='r'):
i='$'
print(i,end='')
def change_char(self,str1):
char=str1[0]
str1=str1.replace(char,'$')
str1=char+str1[1:]
print(str1)
string='restart'
chng_str=chan... | true |
76b2c764a6361a34b319dec9086798bd5828e350 | wwy2018/w201710 | /python/tupian.py | UTF-8 | 1,433 | 2.796875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import re
import urllib
import urllib2
import os
def getHtml(url):
page=urllib.urlopen(url)
html=page.read()
return html
def makeDir(path):
path=path.strip()
isExists=os.path.exists(path)
if not isExists:
print 'not exist'
os.makedirs(path)
return True
else:
print... | true |
06a8c5fa184806903f52902e5fd9c8d2c6c70225 | vistanler/Hangman | /Problems/Long live the king/main.py | UTF-8 | 291 | 3.265625 | 3 | [] | no_license | row = int(input())
col = int(input())
if (row == 1 and col == 1) or (row == 8 and col == 8) or (row == 1 and col == 8) or (row == 8 and col == 1):
print(3)
elif ((row == 1 or col == 1) or (row == 8 or col == 8)) and ((row or col < 8) or (row or col >1)):
print(5)
else:
print(8) | true |
87e3f800188ceeac395faeb8b2b8f8f8f31e484e | MichalBrzozowski91/algorithms | /leetcode/medium/0328_Odd_Even_Linked_List.py | UTF-8 | 843 | 3.34375 | 3 | [] | no_license | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def oddEvenList(self, head: ListNode) -> ListNode:
if not head:
return None
if not head.next:
return head
... | true |
951810a3ce908a530f4abebf750a7e6415fb2fa3 | SrtaCamelo/SistemasOperacionas2018.2 | /SO_Processos/processo_Buffer.py | UTF-8 | 1,025 | 3.96875 | 4 | [] | no_license | #Sistemas Operacionas 2018.2
#Raissa Camelo
#Atividade: Processos - Buffer
#----------------Def Structs---------------
buffer = []
buffer_size = 5
buffer_index = 0
def appendBuffer(item,buffer_index):
if buffer_index < buffer_size:
buffer.append(item)
buffer_index += 1
print("Um item foi a... | true |
df2e89c5813124f3fd0f9b62e26936959bc2cea3 | zbx911/test-http2 | /http2/client.py | UTF-8 | 2,001 | 2.5625 | 3 | [] | no_license | from socket import socket, AF_INET, SOCK_STREAM
from stream import Stream
from http import (Request, Status)
BUFF_SIZE = 1024
ADDR = ('localhost', 8080)
def main(): # Testing HTTP/1.1
client = socket(AF_INET, SOCK_STREAM)
client.connect(ADDR)
# client.send('GET / HTTP/1.1\r\n\r\n')
data = client... | true |
83f9fc8e96061942bc7888f82cce9400b740e06c | Alexanderme/algorithm_testing_platform_django | /algoSdk/common/iter_files.py | UTF-8 | 1,432 | 2.75 | 3 | [] | no_license | """
# @ModuleName: iter_files
# @Function:
# @Author: Ljx
# @Time: 2020/12/9 20:59
"""
from collections import defaultdict
import os
def iter_files(rootDir, *args, **kwargs):
"""
根据文件路径 返回文件名称 以及文件路径名称
:param rootDir:
:return:
"""
filenames = defaultdict(list)
for root,... | true |
ad52eaa82582969c73743edf6b05f8e752506451 | merak0514/Leetcode | /Problem/19. 918. Maximum Sum Circular Subarray/prefix_sum.py | UTF-8 | 1,036 | 3.171875 | 3 | [] | no_license | # Time: O() ms %
# Memory: O() MB %
from typing import *
class Solution:
def maxSubarraySumCircular(self, A: List[int]) -> int:
n = len(A)
longer = A + A
p = [0] * (2 * n)
p[-1] = A[-1]
count = [0] * (2 * n)
count[-1] = 1
for i in range(2 * n... | true |
ceb916fc20670c7af2b864089a7c0cd635ee84d5 | Sophie-Xiying-Liu/Analysis_and_Modelling_Social_Interactions | /graphs.py | UTF-8 | 1,724 | 3.203125 | 3 | [] | no_license | import pandas as pd
from operator import itemgetter
import numpy as np
import networkx as nx
class CreateGraph:
def __init__(self):
data = 'European_electricity_network.csv'
self.Network = pd.read_csv(data)
self.graph = np.asarray(self.Network[['Origin', 'Destination']])
self.... | true |
a7ec94536b1650c6ce05649f6a3fb173bf9fbabf | ULL-ESIT-PL-1819/mini-pascal-compiler | /mpaslex.py | UTF-8 | 3,348 | 2.828125 | 3 | [] | no_license | #-----------------------------------------------------------------------------
# Name: mpascal.py
# Purpose:
#
# Author: Daniel Bernal - Jonathan Alvarez
#
# Created: 12/09/2012
# Copyright: (c) Daniel Bernal - Jonathan Alvarez 2012
# Licence: Free share
#------------------------------------------... | true |
32bf152cf3aa4fd714099a625798ea33fa60cf45 | GottfriedHerold/M6G | /DBInterface/models/dict_models.py | UTF-8 | 4,130 | 2.59375 | 3 | [] | no_license | from __future__ import annotations
from collections import abc
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from .meta import MyMeta, KEY_MAX_LENGTH, MAX_INPUT_LENGTH, MANAGER_TYPE
from .char_models import CharVersionModel
class DictEntry(models.Model):
class Meta(MyMeta):
... | true |
38497ccd8bf26fc696f7567d2b248dd3c4dc3238 | bx-h/LFTP | /Lftp.py | UTF-8 | 20,554 | 2.578125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import socket
import struct
import json
import Event
import sys
from random import randint
from Logging import Logger
from Logging import Level
# 基本功能包
lftpSockets = []
logger = Logger("LFTP", Level.TRACE)
def createSocket(addr, port):
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRA... | true |
feb38e877df22b6d341c0381f666a96bc4174bd7 | apusdigital/creditcard-orc-opencv | /template.py | UTF-8 | 6,896 | 3.078125 | 3 | [] | no_license | # Credit card digits detector - https://github.com/alexcamargoweb/creditcard-orc-opencv.
# Reconhecimento de dígitos de um cartão de crédito utilizando Python e OpenCV.
# Adrian Rosebrock, Credit card OCR with OpenCV and Python. PyImageSearch.
# Disponível em: https://www.pyimagesearch.com/2017/07/17/credit-card-ocr-wi... | true |
614bc8a1d918108d03e9191cda1d0190f7591e56 | cjuub/advent-of-code | /2022/17/aoc17.py | UTF-8 | 5,598 | 3.140625 | 3 | [] | no_license | import dataclasses
from pathlib import Path
from typing import Tuple, List
def print_chamber():
chamber = [["." for x in range(chamber_width)] for y in range(chamber_height)]
for rock in rocks:
for x, y in rock.points:
chamber[y][x] = "#"
for y in range(len(chamber)):
for x in ... | true |
26e1f89edd6aa1e5d87668995539b85141ba199e | LookACastle/Oiram | /entities/entity.py | UTF-8 | 3,786 | 2.875 | 3 | [] | no_license | from constants import *
import math
class Entity:
def __init__(self, sheet, id, x, y):
self.id = id
self.sheet = sheet
self.x = x
self.y = y
self.vx = 0
self.vy = 1
self.speed = 0
self.collision = False
self.entitycollision = False
self.held = False
self.solid = False
self.width = 1
self.hei... | true |
46818f1303913a15bb181001fa043a699b12fa29 | RCairncross/meshcontrol | /meshbecon.py | UTF-8 | 1,109 | 2.953125 | 3 | [] | no_license | import meshtastic
import time
import datetime
# By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0
# interface = meshtastic.SerialInterface()
# or sendData to send binary data, see documentations for other options.
# interface.debugOut()
# interface = meshtastic.SerialI... | true |
1d44cbbe623c18f2123196d995c4ade4ffdd6860 | eruvanos/flightplan | /flightplan/cli.py | UTF-8 | 4,881 | 2.515625 | 3 | [] | no_license | import io
import shutil
import tempfile
from pathlib import Path
from subprocess import run, PIPE
from typing import Dict
from warnings import warn
import black
import typer
import yaml
from black import WriteBack
from typer import Typer
from flightplan.render import Pipeline, Var
app = Typer()
def _load_py_file(s... | true |
8b5bab364c18c1f69d1e3d975ee6ed3b4e107b10 | AnnaZillmann/exercicios_python | /exercicio_secao05/exercicio24.py | UTF-8 | 1,193 | 4 | 4 | [] | no_license | def welcome():
print('Olá!\n')
imposto()
def imposto():
prod = float(input('Informe o valor do produto.'))
est = str(input('Escolha o Estado:\n'
'MG para Minas Gerais\n'
'SP para São Paulo\n'
'RJ para Rio de Janeiro\n'
'... | true |
2870411e6694f1714a80548262e75d8efba429ff | TravelSir/leetcode_solutions | /601-700/643. Maximum Average Subarray I.py | UTF-8 | 657 | 3.78125 | 4 | [] | no_license | """
这题很简单,从头开始遍历的,长度为k的滑动窗口一直往后滑动,不断比较总数就行了,最后再由最大总数求的平均数。时间复杂度为O(n)
"""
class Solution:
def findMaxAverage(self, nums, k):
left = 0
length = len(nums)
_max = sum(nums[left:left+k])
tem = _max
left += 1
while left + k <= length:
tem = tem - nums[left-1] ... | true |
23a301328a53488256065d070ec94fb2158d30f5 | AldrinAJ/Contracts_Testing_Scripts | /vulnerability_finder/crawler.py | UTF-8 | 1,886 | 2.8125 | 3 | [] | no_license | import sys
import os
import requests
import re
# Etherscan API
# Compound contract
# https://api.etherscan.io/api?module=contract&action=getsourcecode&address=0xc00e94cb662c3520282e6f5717214004a7f26888&apikey=5Q5XRN6BZHNNKPR2XW94F2RQWG91954C2K
REST_URL = "https://api.etherscan.io/api?apikey=5Q5XRN6BZHNNKPR2XW94F2RQWG... | true |
1f2654e001010a39f1c4dde3f35011dedf826d4f | mrspiggot/tbic2021 | /apps/owner.py | UTF-8 | 1,663 | 2.546875 | 3 | [] | no_license | import sqlalchemy
import pandas as pd
import dash_bootstrap_components as dbc
import dash_core_components as dcc
import dash_html_components as html
from app import app
from forex_python.converter import CurrencyRates
from pathlib import Path
import plotly.express as px
from modules.Portfolio import Portfolio
from dash... | true |
c6313d193d28d8b9457715c6416f2f4d2f7587f9 | Melissious/rapport-cms | /app/auth/forms.py | UTF-8 | 1,869 | 2.640625 | 3 | [
"MIT"
] | permissive | from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, SubmitField, SelectField, DateField
from wtforms.validators import Required, ValidationError, DataRequired, Length, EqualTo, Email, NumberRange, Regexp
from app.models import UserModel
class LoginForm(FlaskForm):
userna... | true |
28aac488c99c722e2e09be715de03fa299180afc | bcgov/flatfile-tools | /py/forever.py | UTF-8 | 954 | 3.125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-unknown"
] | permissive | # to run a terminal command repeatedly, e.g. for monitoring processes, prefix it with "forever"
# e.g.: forever 1 ls -latrh to monitor files produced by a process
import os
import sys
import time
from misc import *
default = 10 # default interval (s) to repeat command
args = sys.argv
delay, arg = default, " ".join(arg... | true |
918b96495880a6e8f6005f1753cbd92ad2d847af | serapp98/project | /Assestment1.py | UTF-8 | 1,084 | 3.046875 | 3 | [] | no_license | Python 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> list1=[9,11,17,23,39,41,47,51,55,89,93,125]
>>> list2=[8,12,18,26,34,42,50,58,64,72,88,100]
>>> list1.extend(list2)
>>> print(list1)
[9, 11, 1... | true |
71a994946b9fa73b7739bf815c942817e0f7b7e8 | Rhoana/butterfly | /scripts/database_trials/rt_generate.py | UTF-8 | 1,321 | 2.703125 | 3 | [
"MIT"
] | permissive | import json
import time
import argparse
import numpy as np
from rtreedb import RTreeDB
def generate_synapses(_count):
# All sides same in fictional volume
side_length = 512000
dtype = np.uint32
# Make _count rows of 3 coordinates
shape = [_count, 3]
synapses = np.random.randint(0, side_length,... | true |
fc63a1032f486d7f834876f9c1889582f8910469 | trungne/TankIt | /util/helper.py | UTF-8 | 614 | 3.171875 | 3 | [] | no_license | from constants import WIN
def out_of_horizontal_axis(rect) -> bool:
"""Check if the given rect has reached horizontal boundary.
Parameters:
rect (pygame.Rect): pygame.Rect object to perform checking on
"""
return any([rect.top <= 0, rect.bottom <= 0, rect.top >= WIN[1], rect.bottom >= WIN[1]]... | true |
0cd76f5b1c3e788f8dbb39268430e4e841f7ddf9 | preetum/ballbot | /vision/court/findlines.py | UTF-8 | 14,618 | 2.921875 | 3 | [] | no_license | import sys
import numpy as np
import cv
import util
from optparse import OptionParser
verbose = False
def cvOpen(src, dst, element):
cv.Erode (src, dst, element)
cv.Dilate(src, dst, element)
def cvClose(src, dst, element):
cv.Dilate(src, dst, element)
cv.Erode (src, dst, element)
def hv2rgb(hue, value):
... | true |
cf6fe589054beb166b8fb9ba33761649a9a1a543 | terryhuang1215/AIOT45days | /homework/HW17_05_Upload_Multiplefiles.py | UTF-8 | 609 | 3.359375 | 3 | [] | no_license | # 引用需要的套件, 若有多個套件要引用,可使用逗號隔開
from flask import Flask, request
app = Flask(__name__)
# 設定網址路由,及接受的 method(預設是 GET)
@app.route('/', methods=['POST'])
def index():
files = request.files.getlist('file') # 若有多個檔案,必須使用 getlist
total = 0
for file in files:
total += 1 # 讀到一個檔案就加一
file.save(file.... | true |
b9971ef808b25ac9eb6f56f7e06e49b529256bd2 | Sourav-Sharma-191940/Mail-Sender | /emailsender.py | UTF-8 | 1,354 | 2.828125 | 3 | [] | no_license | # for sending mail through smtp you need to enable less sequre app in your email account.
from email.message import EmailMessage #this is use for send in the email format.
import smtplib # this is use for connect to gmail.
import imghdr # this is use for attach images to mail.
contacts = ['example1@gmail.com', 'e... | true |
52fa4a76aee989cfc9ea430e15d2175cfe414227 | sunruina2/InsightFace_TF | /nets/L_Resnet_E_IR_MGPU.py | UTF-8 | 36,930 | 2.546875 | 3 | [
"MIT"
] | permissive | import tensorflow as tf
import tensorlayer as tl
from tensorflow.contrib.layers.python.layers import utils
import collections
# from tl_layers_modify import ElementwiseLayer, BatchNormLayer, Conv2d, PReluLayer, DenseLayer
# MGPU和issue9的主要区别点:
# (1)layer>>BatchNormLayer, Conv2d, PReluLayer, DenseLayer在Layer源码上修改:加上了 /cp... | true |
e434990a7abdf1851a613eb5f14843ab903e5040 | tylercrompton/project-euler | /p043/p043.py | UTF-8 | 445 | 3.0625 | 3 | [] | no_license | from itertools import permutations as _permutations
def p043():
total = 0
for permutation in _permutations('0123456789'):
n = ''.join(permutation)
if int(n[1:4]) % 2 == 0 and \
int(n[2:5]) % 3 == 0 and \
int(n[3:6]) % 5 == 0 and \
int(n[4:7]) % 7 == 0 and \
int(n[5:8]) % 11 == 0 and \
int(n[6... | true |
ba3288e12c8eea20652e63f22569ab085ed7ddc7 | lokier/earnmi | /vnpy/earnmi_demo/Strategy1.py | UTF-8 | 3,690 | 2.859375 | 3 | [
"MIT"
] | permissive | from datetime import datetime, timedelta
from earnmi.chart.Indicator import Indicator
from earnmi.data.Market2 import Market2
from earnmi.data.MarketImpl import Market2Impl
from earnmi.strategy.StockStrategy import StockStrategy, Portfolio
"""
使用三个指标来:
obv、rsi、boll指标
"""
class Strategy1(StockStrategy):
def ... | true |
daf79bd8d7e9f93793bd267bb36d7d790eeca8a6 | lunar-r/sword-to-offer-python | /leetcode/39. Combination Sum.py | UTF-8 | 3,701 | 3.421875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
File Name: 39. Combination Sum
Description :
Author : simon
date: 19-3-26
"""
"""
这种求和的问题 应该在每一步使用减法而不是最后使用加法
"""
class Solution(object):
def combinationSum(self, candidates, target):
"""
:type candidates: List[int]
:type target: i... | true |
250be711e67319609bccfd25e77a53fbfa9f2311 | XiaoqingWang/python_code | /python语法基础/06.匿名函数、文件操作/01-匿名函数.py | UTF-8 | 250 | 3.421875 | 3 | [] | no_license | def test1(a, b):
return a+b
result1 = test1(11, 22)
test2 = lambda a, b: a + b
result2 = test2(11, 22)
result3 = test2(11, 22)
print("result1=%d, result2 = %d"%(result1, result2))
print("再重新调用一次匿名函数: result2:%d"%result3) | true |
539fce05c6f9d5254977e3b958886723c6292d61 | familytime/BerkeleyWebCopy | /cs61a spring2018/cs61a.org/assets/slides/15.py | UTF-8 | 1,171 | 4.0625 | 4 | [] | no_license | class Clown:
"""An illustration of a class statement. This class is not useful.
>>> Clown.nose
'big and red'
>>> Clown.dance()
'No thanks'
"""
nose = 'big and red'
def dance():
return 'No thanks'
class Account:
"""An account has a balance and a holder.
All accounts sha... | true |
02ac5e1464e40937214e3ef0488e4972bea1ec9f | saurabtharu/pyAssignment | /6_While/02.py | UTF-8 | 901 | 4.4375 | 4 | [] | no_license | #!/usr/bin/python
'''
Deli: Make a list called sandwich_orders and fill it with the names of various sandwiches.
Then make an empty list called finished_sandwiches . Loop through the list of sandwich orders
and print a message for each order, such as I made your tuna sandwich. As each sandwich is made,
move it to th... | true |
9e42f714e84ec4e71c2519ae423e31f170f39bf4 | Limsanity/LFTP | /Packet.py | UTF-8 | 174 | 2.703125 | 3 | [] | no_license | class Packet:
def __init__(self, seq, content):
self.seq = seq
self.content = content
def getSeq(self):
return self.seq
def getContent(self):
return self.content | true |
11452899a63615d01860a96a2394519776a75420 | boyshen/NLP_project | /chinese_chatbot/module/joke/joke.py | UTF-8 | 479 | 2.71875 | 3 | [] | no_license | import numpy as np
class JokeConf(object):
def __init__(self):
self.mysql = None
self.debug = None
class Joke(object):
def __init__(self, mysql, debug=False):
self.mysql = mysql
self.debug = debug
def joke(self):
mysql_joke = self.mysql.query_joke()
answe... | true |
13f1693b511f9b0ec02df4e92676de937fa3ff11 | grezesf/Research | /Reservoirs/Task0_Replication/code/preprocessing/extract_phone_list.py | UTF-8 | 916 | 2.890625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/python
import os
import sys
def main():
# path to files to be processed
workdir = os.path.abspath(os.path.normpath(sys.argv[1]))
# path where to save results
savedir = os.path.abspath(os.path.normpath(sys.argv[2]))
# create save dirs
if not os.path.exists(savedir):
# print "creating sub-directory... | true |
801a6d1384866cb7b1397ba5ca4d6e41256071a2 | dajofischer/Datacamp | /Network_Analysis_in_Python/E02_Queries_on_a_graph.py | UTF-8 | 279 | 2.71875 | 3 | [] | no_license | # Use a list comprehension to get the nodes of interest: noi
noi = [n for n, d in T.nodes(data=True) if d['occupation'] == 'scientist']
# Use a list comprehension to get the edges of interest: eoi
eoi = [(u, v) for u, v, d in T.edges(data=True) if d['date'] < date(2010, 1, 1)]
| true |
bb16f384c26442f66c4b3a3d11faf0b3f4245d1f | shankar7791/MI-10-DevOps | /Personel/pooja/python/practice/23feb/multiple.py | UTF-8 | 526 | 4.96875 | 5 | [] | no_license | # Program 6 : Write a Python program which iterates the integers from 1 to 50. For multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".
for fizzbuzz in range(51):
if fizzbuzz % 3 == 0 and fizzbuzz ... | true |
8dde506f4ece5806ded72259f947df80e75311aa | ramonfmir/deblurring-public | /data_generator/tests/test_preprocessing.py | UTF-8 | 1,738 | 2.53125 | 3 | [] | no_license | from __future__ import absolute_import
from shutil import copyfile
from copy import deepcopy
import sys
import os
import unittest
import cv2
import data_generator.preprocessing.colour_normalize as cn
import data_generator.preprocessing.histogram_equalisation as he
import data_generator.preprocessing.kmeans as km
impo... | true |
e138d4c4c06c2c69504b6c1e896eaf1ecc8265ee | VictorSimao/TrabalhosPython | /Aulas/Aula19/exercicios/exercicio2.py | UTF-8 | 1,307 | 3.734375 | 4 | [] | no_license | # Aula 19 - 04-12-2019
# Lista com for e metodos
cab = ['nome', 'telefone', 'email','idade']
pess = [ ['Alex' ,'Paulo' ,'Pedro' ,'Mateus' ,'Carlos' ,'João' ,'Joaquim'],
['4799991','4799992','4799993','4799994','4799995','4799996','4799997'],
['a@a.com','b@b.com','c@c.com','d@d.com','e... | true |
aeb84f13a486976c1f55f441f5872206ef01a815 | SevanthGH/Computer-Vision | /RP Lidar/laser_values/src/task1.py | UTF-8 | 567 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | #! /usr/bin/env python
import rospy
from sensor_msgs.msg import LaserScan
def callback(msg):
b = min(msg.ranges)
print("Distance of the closed object %s" %(b*100))
#index = msg.ranges.index(b)
#print(index)
i=0
for i in range(0,360):
if msg.ranges[i] != b:
i = i+1
el... | true |
2b1912a2341df4519e58414c392a41095014fa3f | sai-byui/NeuralNetV2 | /Pseudocode/FeedForwardNetwork.py | UTF-8 | 4,991 | 3.8125 | 4 | [] | no_license | import Network
class FeedForwardNetwork(Network):
"""Network class. Contains all the code needed to describe a simple feedforward network.
Layers, neurons, weights, etc. Contains functions for training the network."""
def __init__(self, topology, training_rate, temperature):
# Call the base clas... | true |
98e50ac02562097b3c56ca23e4b936ecee5b73ea | iremtopsakal/numpy_notes | /1d_array_np.py | UTF-8 | 2,143 | 3.8125 | 4 | [] | no_license | #NUMPY in 1D
import numpy as np
a = np.array([0,1,2,3,4])
#type(a) : numpy.ndarray
#a.dtype : dtype('int64')
#a.size : 5
#a.ndim: 1 --> (dimension)
#a.shape: (5,) --> (a tuple of integers indicating the size of the array in each dimension.)
####Arrays are mutable
a[0]=100 #a: [100,1,2,3,4]
d=a[1:4] #d: [1... | true |
2f882b856f245ed8f8d6ba94bbf88231b9394905 | Platingamer42/DigitRecognition | /RasPI/Drawer.py | UTF-8 | 2,593 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | import pygame
class Drawer:
def __init__(self, gui):
self.pygame = pygame
self.GUI = gui
def drawStream(self):
screen = pygame.Surface((250,250))
screen.fill((255,255,255))
self.drawRect = self.GUI.updateSurface(screen)
pygame.event.clear()
past_mouse_x,... | true |
63911728d9fcf096abed1d968529030abef7ab3a | gormasab/thesis_public | /scrapyard/ToShowDepth.py | UTF-8 | 2,539 | 2.515625 | 3 | [] | no_license | import matplotlib.pyplot as plt
import numpy as np
import pyrealsense2 as rs
from functions.basics import scale_im
""""
Improved version of Projasis.py
function that makes and shows depth pictures. close window to refresh each picture.
"""
pipeline = rs.pipeline()
# Create a config and configure the pipeline to str... | true |
404371e9e6489b119607da1bcdeca154e3a385c2 | larsnohle/57 | /34/thirtyFour.py~ | UTF-8 | 339 | 2.859375 | 3 | [] | no_license | #!/usr/bin/python3
# -*- coding: utf-8 -*-
import random
EMPLOYEES = ["John Smith", "Jackie Jackson", "Chris Jones", "Amanda Cullen", "Jeremy Goodwin"]
def main():
question = input("What's your question? ")
answer_index = random.randint(0, len(ANSWERS) - 1)
print(ANSWERS[answer_index])
### ... | true |
492edf1c6b096a4358e1d493b3d50e45fb913869 | TriniBora/ISFDyT166 | /ProgramaciónOrientadaObjetos/RepasoPython/EjerciciosLibro/Funciones/funciones.py | UTF-8 | 1,072 | 4.375 | 4 | [] | no_license | '''DOCUMENTACIÓN DE UNA FUNCIÓN
def hola(alguien):
#Documentación de la función
""" Imprime por pantalla un saludo, dirigido a la persona que
se indica por parámetro. """
print ("Hola ",alguien,"!")
print ("Estoy programando en Python.")
hola("Trinidad")
#Lectura de la documenttación
help(hola)''... | true |
46c97d1fa95177b8c9bcfc5b4ee5e00e7d8a6e9b | gennei/deep-learning-from-scratch | /ch04/4_2_1.py | UTF-8 | 377 | 3.484375 | 3 | [
"MIT"
] | permissive | # 2乗誤差
import numpy as np
def mean_squared_error(y, t):
return 0.5 * np.sum((y-t) ** 2)
y = [0.1, 0.05, 0.6, 0.0, 0.05, 0.1, 0.0, 0.1, 0.0, 0.0]
t = [ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
print(mean_squared_error(np.array(y), np.array(t)))
y = [0.1, 0.05, 0.1, 0.0, 0.05, 0.1, 0.0, 0.6, 0.0, 0.0]
p... | true |
42deef391640b345df3e49abe523deb8deb07a72 | Jonysegal/labmojo | /utils.py | UTF-8 | 1,788 | 2.640625 | 3 | [] | no_license |
def remove_objects(pi, remove_list, key_name):
"""
Remove the scholarly objects from PI payload - for Detail
"""
num_to_remove = len(pi[key_name])
if num_to_remove:
x = 0
while x < num_to_remove:
pi[key_name][x] = pi[key_name][x].__dict__
for item in remove_... | true |
7f51d41e9a5d82f93a1965460f29e02df2316caa | singultek/ModelAndLanguagesForBioInformatics | /Python/List/3.sublist.py | UTF-8 | 1,876 | 3.796875 | 4 | [
"MIT"
] | permissive | from typing import List, Any
def ascending(list):
for i in range(len(list)-1):
if list[i] < list[i+1]:
return True
return False
def subset(list1: List, list2: List) -> bool:
"""
Check if all the element of list1 are inside list2, preserving
only the order
:param list1: li... | true |
340201858d410a3fcb5440110595c2f7df79c6b1 | chengtang48/stochastic_kmeans | /experiments/image_preprocess.py | UTF-8 | 5,331 | 3.171875 | 3 | [] | no_license | """
This module has some handy functions for preprocessing images
author: Cheng Tang, chengtang48@gmail.com, June 2016
"""
import numpy as np
import random
def rsubsample(X, n_per_image, width, height, labels = None):
"""
randomly subsampling patches from a set of images
----------------
Input
X: ndarray of ... | true |