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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c20327fa5b2a09d00d9948047d082ee30c565b23 | Python | SRserves85/avro-to-python | /avro_to_python/utils/avro/types/primitive.py | UTF-8 | 1,461 | 2.703125 | 3 | [
"MIT"
] | permissive | """ file containing primitive type helper function """
from typing import Union
from avro_to_python.utils.avro.primitive_types import PRIMITIVE_TYPES
from avro_to_python.classes.field import Field
kwargs = {
'name': None,
'fieldtype': 'primitive',
'avrotype': None,
'default': None
}
def _primitive... | true |
1a41c56a0f19367ff2c3cc216975921af33748e2 | Python | igormba/python-exercises | /ex095.py | UTF-8 | 1,536 | 3.921875 | 4 | [
"MIT"
] | permissive | '''Aprimore o desafio 93 para que ele funcione com vários jogadores, incluindo um sistema de visualização de detalhes do aproveitamento de cada jogador.'''
time = list()
dados = dict()
gols = list()
while True:
dados.clear()
dados['Jogador'] = str(input('Nome do Jogador: '))
dados['Gols'] = list()
dad... | true |
a086073a86c76b3fea77588490c4b496922beb6e | Python | IanGSalmon/Functional-Python | /Challenges/discounts.py | UTF-8 | 765 | 4 | 4 | [] | no_license | from functools import partial
prices = [
10.50,
9.99,
0.25,
1.50,
8.79,
101.25,
8.00
]
def discount(price, amount):
return price - price * (amount/100)
# First, import partial from functools
# Now use partial to make a version of discount that applies 10% discount
# Name this partial... | true |
353869e242d29af34e82676af9acfe114f8a844c | Python | mpucci92/MiscRisk | /Stationary_Complete.py | UTF-8 | 2,274 | 2.875 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# In[1]:
### Import all libraries ###
import pandas as pd
import numpy as np
from sklearn import preprocessing
# Visualizations #
import seaborn as sns
import matplotlib.pyplot as plt
get_ipython().run_line_magic('matplotlib', 'inline')
from statsmodels.tsa.stattools import ... | true |
140ed852902f4a5f0f8eb9bbed649aa3c23a6bbf | Python | htn4179/mmo | /clientlogic.py | UTF-8 | 1,135 | 2.546875 | 3 | [] | no_license | g_players = {}
g_player = 0
g_uid = g_player
g_speed = 20
g_wbuffer = []
g_rbuffer = []
g_name = None
g_server_frame = 0
import common
import cPickle
class Player(object):
def __init__(self, _x = 0, _y = 0, _name = '', _speed = 0):
self.x = _x
self.y = _y
self.name = _name
self.target_x = ... | true |
c1e7d95db3a3487cc8fc8c50a3a8246165350f0b | Python | HenrikBradland-Nor/FishFaceRecognition | /dataInspection.py | UTF-8 | 674 | 2.71875 | 3 | [] | no_license | import os
dir = os.getcwd()
for d in os.listdir():
if "Data" in d:
os.chdir(d)
for d in os.listdir():
if "head" in d:
os.chdir(d)
data_label = os.listdir()
tot_dir = [0, 0]
list_of_IDs = []
for label in data_label:
fish_ID, direction, image_nr = label.split('_')
... | true |
45f6f397ccec7e225017bec4fb04077116edb845 | Python | iskwak/DetetctingActionStarts | /helpers/process_hantman_mat.py | UTF-8 | 5,118 | 2.953125 | 3 | [] | no_license | """Get some stats on the hantman matfile."""
import argparse
import numpy
import pickle
def create_opts():
"""Create an opts dictionary."""
opts = dict()
opts['filename'] = ''
opts['outname'] = ''
return opts
def setup_opts(opts):
"""Setup default arguments for the arg parser.
returns a... | true |
5e5542b6a7faacdc016ac9e1a981f59fb7c21efa | Python | qvo117/qvo117_280_GH_Lab5 | /qvo117_280_Lab2_in_Lab5/test_maths.py | UTF-8 | 1,272 | 3.84375 | 4 | [] | no_license | import unittest # Import the Python unit testing framework
import maths # Our code to test
class MathsTest(unittest.TestCase):
''' Unit tests for our maths functions. '''
def test_add_with_new_parameter(self):
actual = maths.add(5, 5, 2)
self.assertEqual(actual, '1010')
... | true |
bfedc218060d367cd89518fe412c9eb02858cb9d | Python | openvinotoolkit/nncf | /nncf/experimental/torch/nas/bootstrapNAS/search/evaluator.py | UTF-8 | 7,980 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | # Copyright (c) 2023 Intel Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writ... | true |
8a5450016c8c0fef9828934b97281da68d303554 | Python | ibllex/learn-tkinter | /layout/02.2_pack_manager_review.py | UTF-8 | 1,181 | 2.9375 | 3 | [] | no_license | from tkinter import Tk, LEFT, BOTH, X, N, Text
from tkinter.ttk import Frame, Label, Entry
from base.ExampleFrame import ExampleFrame
class Example(ExampleFrame):
def __init__(self):
super().__init__("Pack Manager - Review", 450, 500)
def init_ui(self):
frame_01 = Frame(self)
frame_01... | true |
56158906c7e7a79c10c146310d9af9604660e452 | Python | cbcoutinho/learn_tkinter | /intro/main10.py | UTF-8 | 336 | 3.21875 | 3 | [] | no_license | import tkinter as tk
root = tk.Tk()
canvas = tk.Canvas(root, width=200, height=100)
canvas.pack()
blackline = canvas.create_line(0, 0, 200, 50)
redline = canvas.create_line(0, 100, 200, 50, fill='red')
greenbox = canvas.create_rectangle(25, 25, 130, 60, fill='green')
# canvas.delete(redline)
canvas.delete(tk.ALL)
... | true |
c69a85edbc1a5efeb9540f8156f937927c715b42 | Python | Controlman-beep/ML-Foundation-and-ML-Techniques | /hw1/代码/helper.py | UTF-8 | 3,715 | 3.28125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Feb 13 01:31:19 2019
@author: qinzhen
"""
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号
def Judge(X, y, w):
"""
判别函数,判断所有数据是否分类完成
"""
n = X.shape[0... | true |
68f52b11a06e02273565704a53b6b60a5621c9a8 | Python | raoyuanqi/Vehicle-Model-Recognition | /mmr.py | UTF-8 | 11,660 | 2.8125 | 3 | [] | no_license | import numpy as np
from sklearn.mixture import gaussian_mixture as gauss
from sklearn.metrics.pairwise import cosine_similarity
import cv2
import os
import functions as fun
import time
'''This script is the main script of the make and model recognition using unsupervised learning
All of the functions used ... | true |
83297563c68c5370c25c1eb554bfa4aaaf25259b | Python | NikolayVaklinov10/Python_Interview_Challenges | /part12mockSocialNetworkCompany/onSiteQuestion1.py | UTF-8 | 190 | 3.0625 | 3 | [] | no_license |
def solution(lst, target):
seen = set()
for num in lst:
num2 = target - num
if num2 in seen:
return True
seen.add(num)
return False
| true |
45c1b1f456308bd65b4f3070c7640e6fedf9adb9 | Python | Qondor/Python-Daily-Challenge | /Daily Challenges/Daily Challenge #110 - Love VS. Friendship/words_strength_calculator.py | UTF-8 | 321 | 3.703125 | 4 | [] | no_license | def wordsToMarks(word):
"""If a = 1, b = 2, c = 3 ... z = 26, then l + o + v + e = 54
Function to find the "strength" of each of these values.
"""
value = []
value.extend((ord(letter) - 96) for letter in word)
return sum(value)
if __name__ == "__main__":
print(wordsToMarks("attitude")) | true |
fb7bd5d96ceed3a704510715d0ac2e80266b7c25 | Python | tusharcoder/elasticdjango | /core/management/commands/seed_db.py | UTF-8 | 3,469 | 2.5625 | 3 | [
"MIT"
] | permissive | # @Author: Tushar Agarwal(tusharcoder) <tushar>
# @Date: 2017-02-19T18:54:14+05:30
# @Email: tamyworld@gmail.com
# @Filename: sample.py
# @Last modified by: tushar
# @Last modified time: 2017-03-13T14:36:26+05:30
from django.core.management.base import BaseCommand
from model_mommy import mommy
import random
fro... | true |
781181bd6934a88e34020b1ee967c1d136521936 | Python | amorochenets/python | /less07/less07_1.py | UTF-8 | 482 | 3.453125 | 3 | [] | no_license | # !/usr/bin/env python3
# coding UTF-8
# for i in 'hello world':
# print(end='_')
# if i == 'o':
# continue
# print(i*2, end='')
# i = 5
# while i < 15:
# print(i)
# i += 2
newList = []
while True:
word = input('Please enter one word: ')
if word.find(' ') != -1:
print('Too ... | true |
1a1ffc08f5c531c63dd5e898316e4bf31d46f5e3 | Python | PedchenkoSergey/GB-Python-Basics | /task2/task_2_5.py | UTF-8 | 517 | 4.0625 | 4 | [] | no_license | my_list = [7, 5, 3, 3, 2]
while True:
my_num = input("Введите новый элемент рейтинга, или введите exit: ")
flag = True
if my_num == "exit":
break
for i in range(0, len(my_list)):
if int(my_num) > my_list[i]:
my_list.insert(i, int(my_num))
flag = False
... | true |
3920212992d152e09fd41ee17f72c7f249a067f6 | Python | julian-ramos/ksi | /client.py | UTF-8 | 2,842 | 2.671875 | 3 | [] | no_license | #!/usr/bin/env python
"""
This client connects to a wiiRemote
The macAddress of the wiiMote has to be specified on
the file wiiMAC.dat. This file should have the next format
XXXXXXX
XXXXXXX
Where each line is the MAC address
"""
from time import sleep
import cwiid
import socket
import sys
host = 'localhost'
port... | true |
399411a3f0b700a5d3f2bec33a9ddea923003d3f | Python | nikpet/hb | /week1/1/fibonacci.py | UTF-8 | 259 | 3.640625 | 4 | [] | no_license | def fibonacci(n):
result = [1, 1]
for i in range(1, n-1):
result.append(result[i-1] + result[i])
return result[:n]
if __name__ == "__main__":
print(fibonacci(1))
print(fibonacci(2))
print(fibonacci(3))
print(fibonacci(10))
| true |
f4ad44c5aefdda9649739e882d6de3695dac39f6 | Python | sinopeus/thrax | /bin/lexicon.py | UTF-8 | 1,370 | 3.25 | 3 | [] | no_license | import re
from collections import Iterator
chars = re.compile('[,\?\!#&_`\.%·; <>]')
class Corpus(Iterator):
def __init__(self, corpus_file, count=None):
self.text = open(corpus_file)
self.count = 0
if count != None:
self.__setstate__(count)
def __iter__(self):
return self
def __next__(... | true |
e83b2307cc001d16677fa3c370021ae4a4b1405d | Python | edward035358370/Leetcode | /leetcode/Permutations/version1.py | UTF-8 | 459 | 3.171875 | 3 | [] | no_license | class Solution(object):
def permute(self, li):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
def cut(li,temp,res = []):
if len(li) == 1:
res.append(temp + li)
for i in range(len(li)):
cut(li[:i]+li[i+... | true |
1aad45bb2ce8efdc5cd8a874949c3da88308acc1 | Python | scmbuildrelease/gitfusionsrc | /libexec/p4gf_lfs_tracker.py | UTF-8 | 1,506 | 2.515625 | 3 | [] | no_license | #! /usr/bin/env python3.3
"""Check if a Git work tree path is under Git LFS control."""
import p4gf_lfs_checker
class LFSTracker(object):
"""Check if a Git work tree path is under Git LFS control."""
def __init__(self, *, ctx):
"""Create a LFSChecker to do the checking."""
self.ctx = ctx
... | true |
c13bf8c204b23b22a188d0a0d35a3746c26f07ef | Python | NoellePatterson/FFC_QA | /calculations/snowEarly.py | UTF-8 | 2,343 | 2.609375 | 3 | [] | no_license | import numpy as np
from Utils.convertDateType import convertOffsetToJulian
def snowEarly(classes):
snowEarlySpring = {}
snowEarlyWet = {}
for currentClass, value in classes.items():
springTim = []
wetTim = []
for i, results in enumerate(value):
springTim.append(value[i]... | true |
33a0947aab4ee7ac6f9c2ea9c0d721d7fed7ce7e | Python | oyedeloy/Pirple.com_courses | /Python is easy/Classes/classs_inheritance.py | UTF-8 | 1,680 | 3.6875 | 4 | [] | no_license | class Team:
def __init__(self,Name = "Name",Origin = "Origin"):
self.team_name = Name #We have created a variable "Team_name" which is now part of the class.
self.team_origin = Origin
def define_team_name(self, Name):
self.team_name = Name
def define_team_origi... | true |
63013b6fc22c8147319e2c9655cd0d352e884d2b | Python | kamkasz/downlpj.py | /downlpj.py | UTF-8 | 3,845 | 2.671875 | 3 | [
"Unlicense"
] | permissive | #!/usr/bin/env python2.7
# -*- coding: utf-8 -*
#importing modules
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui impo... | true |
d9ed12cddf28f423ef6a31d42f51cea5fff1fb95 | Python | kj-lai/GroceryMarketCrawler | /redtick.py | UTF-8 | 3,984 | 2.546875 | 3 | [] | no_license | from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
import time
import pandas as pd
import numpy as np
start_time = time.time()
driver = webdriver.Chrome()
driver.switch_to_... | true |
aa40c3edf679db7a75d59d986d08f1d86d98bd79 | Python | e125743/ItemChecker | /MarginChecker.py | UTF-8 | 2,935 | 2.953125 | 3 | [] | no_license | # coding: UTF-8
import cv2
import numpy as np
import sys
def patternCut(filepath):
#画像をグレースケール(,0)で取得
img = cv2.imread(filepath,0)
#切り取り画像の左上のpixel
#'無'の左上のpixel
x, y = 720, 4070
#切り取り画像の幅と高さのpixel数
#'無'の切り取りpixel数
w = 775
h = 150
#画像から切り取り実行
roi = img[y:y+h, x:x+w]
... | true |
63fa890be66010425650d457681f0ce515f7c025 | Python | jptboy/NeuralNetwork | /aknet/mnist.py | UTF-8 | 1,887 | 2.6875 | 3 | [] | no_license | # from tensorflow.keras.datasets import mnist
# dataMnist = mnist.load_data()
# train, test = dataMnist
# inputs, targets = train
# import numpy as np
# testx, testy = test
# import numpy as np
# inputs1 = []
# trainx1 = []
# targets1 = []
# for i in range(len(inputs)):
# inputs1.append(inputs[i].flatten())
# for... | true |
7e6ff35a1e723705d1fd3f4b2d7f4e9a9590da2a | Python | tianxiongWang/codewars | /stringIncre.py | UTF-8 | 640 | 3.359375 | 3 | [] | no_license | def increment_string(string):
key = -1
num = ''
for i in range(len(string) - 1, -1, -1):
if ord(string[i]) < 48 or ord(string[i]) > 57:
key = i
break
num += string[i]
if key == len(string) - 1:
return string + '1'
if key != -1:
finallyNu... | true |
95d73f03165651e2ac097eae0e360ef9b06358e9 | Python | Madsss11/IS-206 | /opg5.py | UTF-8 | 454 | 3.5625 | 4 | [] | no_license | name = 'Mads Soeftestad'
age = 21
height = 186
weight = 92
eyes = 'blue'
teeth = 'white'
hair = 'Blonde'
print "Let's talk about %s." % name
print "He's %d centimeters tall." % height
print "He's %d kilos." %weight
print "Beautiful guy."
print "He's got %s eyes and %s hair." % (eyes, hair)
print "His teeth are usuall... | true |
617c29c008b7a78bf4af6f60ddf9dc0f6659c929 | Python | esdalmaijer/2017_Lund_Collaborative_short-term_memory_game | /experiments/short-term_memory_assessment/custom.py | UTF-8 | 15,701 | 3.078125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import math
import random
from constants import *
import pygaze
from pygaze.screen import Screen
from pygaze._misc.misc import pos2psychopos, rgb2psychorgb
import numpy
from psychopy.visual import Circle, GratingStim, ImageStim, Rect
# # # # #
# FUNCTIONS
def pol2car(cor, ... | true |
e8f2eadda03bf28dec092056c0ef2390d3c4c9f5 | Python | hakusama1024/PCI_Report_Generator | /people.py | UTF-8 | 454 | 2.859375 | 3 | [] | no_license | class People(object):
def __init__(self, combi_name=None, status=None, sso=None, First_Name=None, Last_Name=None, bu=None, company=None):
self.combi_name = combi_name
self.sso = sso
self.First_Name = First_Name
self.Last_Name = Last_Name
self.bu = bu
self.status = st... | true |
c2f1391ee6e1ce4aa1cca4a81314f323495dc655 | Python | ProspePrim/PythonGB | /Lesson 5/task_5_2.py | UTF-8 | 985 | 4 | 4 | [] | no_license | #Создать текстовый файл (не программно), сохранить в нем несколько строк,
#выполнить подсчет количества строк, количества слов в каждой строке.
with open('test.txt', 'w') as my_f:
my_l = []
line = input('Введите текст \n')
while line:
my_l.append(line + '\n')
line = input('Введите... | true |
0b76c5263cef809a07234d5e3841d9113b27b0a3 | Python | angelxie2442/weibo2019 | /webscraping_weibo/combinednlp.py | UTF-8 | 2,659 | 3.140625 | 3 | [] | no_license | import copy
import xmnlp
from snownlp import SnowNLP
# replace some words with english before using snownlp
def replacing(chartold):
chart = copy.deepcopy(chartold)
for index in range((len(chart))):
unece = (chart[index][3]).find('L')
if unece > 0:
chart[index][3] = (chart[index][3... | true |
a849cbdc1dc24878d511e52f264796f85aa21d4f | Python | Yu-python/python3-algorithms | /5. LeetCode/912.sort-an-array/3.py | UTF-8 | 2,504 | 4.5 | 4 | [] | no_license | """
方法三:归并排序
解题思路:
「自底向上」使用迭代(iterative)的方式,实现归并排序算法
1. size = 1, 对仅包含单个元素的左右子序列进行合并操作
2. size = 2, 步骤1归并排序后,每2个元素已经是排序好的,所以可以对分别包含2个元素的左右子序列进行合并操作
3. size = 4, 步骤2归并排序后,每4个元素已经是排序好的,所以可以对分别包含4个元素的左右子序列进行合并操作
4. 如此反复执行,就能得到一个有序序列了
"""
from collections import deque
class Solution:
def sortArray(self, nums: List[i... | true |
bb13db54669f9e82b44f6188b914e105e8fcb2f5 | Python | adampann/data_compression | /PA1/coding.py | UTF-8 | 1,886 | 3.390625 | 3 | [] | no_license | # def solution(D, A):
# n = list(A) #output list
# failure_track = [-1] * len(A)
# for index in range(len(A)):
# #print('index: ', index, '| ', end='')
# current = A[index]
# for depth in range(D):
# if current != -1:
# #print(current, ' ', end='')
#
# n[index] = current
# current = A[current]
#... | true |
6b6b1ab7b5c8b477698f7354122fe6235676e4de | Python | guome/BrailleOCR | /data/generate_dataset.py | UTF-8 | 6,196 | 2.71875 | 3 | [] | no_license | import cv2
import argparse
import numpy as np
import os
import glob
import sys
from PIL import ImageFont, ImageDraw, Image
from pathlib import Path
# a function to draw training images
def draw_image(textlist, TLGAN_save_path, CRNN_save_path):
# make sure that the save path exists
Path(TLGAN_save_path).mkdi... | true |
3e9d1c9e0a92ac3be3123ee0a677dcc8ff64befc | Python | jackocoo/PoetrySlam | /stanza.py | UTF-8 | 9,183 | 3.171875 | 3 | [] | no_license |
from Phyme import Phyme
from profanityfilter import ProfanityFilter
#import nltk
import random
import os
import sys
import nltk
import ssl
try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
pass
else:
ssl._create_default_https_context = _create_unverified_http... | true |
cfd901290958322f5c3ea8446497b2ab9e8c2ac7 | Python | PWDAVENPORTJENKINS/GEL_BRUTE | /brute_force_method.py | UTF-8 | 5,118 | 2.984375 | 3 | [] | no_license | """
Created on Mon May 27 12:45:18 2019
P. W. Davenport-Jenkins
University of Manchester
MSc Econometrics
"""
from numba import jit
import scipy.optimize as optimize
from functools import partial
import scipy.stats as stats
import numpy as np
NO_PMC = 6
def make_grid(anchor, mesh_size, size):
mu = anchor[0]
... | true |
03a443e724195a9a66cf309d574aa0b95ad09dd9 | Python | ABLE-KU-Leuven/LISSA-Dashboard | /scripts/VisualisatiePaper/visualiseConversation.py | UTF-8 | 3,861 | 2.546875 | 3 | [] | no_license | import plotly
import plotly.plotly as py
import plotly.figure_factory as ff
import os
import datetime
plotly.tools.set_credentials_file(username='martijn.millecamp', api_key='TYJyoUHlfhRpDa8CZUMU')
pathJasper = "/Users/martijn/Documents/Able/Data/evaluationJasper"
pathBart = "/Users/martijn/Documents/Able/Data/evaluat... | true |
9bdc8a310d9e355c6b752c8c77046046d4816778 | Python | alistair-clark/project-euler | /problem15.py | UTF-8 | 2,384 | 4.21875 | 4 | [] | no_license | '''
Project Euler
Problem #15: Lattice paths
Starting in the top left corner of a 2×2 grid,
and only being able to move to the right and down,
there are exactly 6 routes to the bottom right corner.
How many such routes are there through a 20×20 grid?
Date: May 17, 2019
'''
class Nodes(object):
def __init__(self... | true |
4e30c77ca44905d2382888803ce6b310f822f316 | Python | d0coat01/logs-analysis-project | /Reports.py | UTF-8 | 4,476 | 3 | 3 | [
"MIT"
] | permissive | import psycopg2 as psql
import sys
class Reports:
"""Movie class initializes with a title, image url, and trailer url"""
def connect(self, database_name):
"""Connect to the PostgreSQL database. Returns a database connection."""
try:
db = psql.connect("dbname={}".format(database_n... | true |
6b63e8f8b2388fc6d1c4f25f499ae2de7dac4b39 | Python | konstantinosKokos/directionality-bias | /data/generics.py | UTF-8 | 3,997 | 3.171875 | 3 | [] | no_license | from typing import *
from random import choice
from abc import abstractmethod
Atom = TypeVar('Atom')
Op = TypeVar('Op')
Domain = TypeVar('Domain')
Something = TypeVar('Something')
Atoms = List[Atom]
Ops = List[Op]
class Expr:
@abstractmethod
def __init__(self):
pass
def __str__(self) -> str:
... | true |
a490e4216b0e3129ad18f087bf21fe0676fd753f | Python | lein-hub/python_basic | /programmers/dart_game.py | UTF-8 | 649 | 2.796875 | 3 | [] | no_license | def solution(dartResult):
scores = []
num = ''
for i in dartResult:
if i.isnumeric():
num += i
continue
elif i.isalpha():
if i == 'S':
scores.append(int(num))
num = ''
elif i == 'D':
scores.append... | true |
348d4c0779f00121f949374166b8e3d99829154b | Python | nthon/Julia-sublime | /unicode.py | UTF-8 | 1,930 | 2.546875 | 3 | [
"MIT"
] | permissive | import sublime
import sublime_plugin
import re
from .julia_unicode import latex_symbols, emoji_symbols
RE_COMMAND_PREFIX = re.compile(
r".*(\\[\^_]+[a-zA-Z0-9=+\-()]*|\\[a-zA-Z]+|\\:[_a-zA-Z0-9+\-]+:*)$")
symbols = latex_symbols + emoji_symbols
class JuliaUnicodeMixin(object):
def find_command_backward(sel... | true |
7a443ddc84e32538e99d693233e174fb2cf00030 | Python | elouie/10701NNGRN | /meanSqErr.py | UTF-8 | 285 | 2.734375 | 3 | [] | no_license | import numpy as np
# Get the mean squared error
def meanSqErr(input, res, numRuns, numMols, ts):
error = np.zeros(ts)
for i in range(ts):
for j in range(numRuns):
error[i] = np.sum(np.square(input[j, :, i] - res[j, :, i]))/numMols
return error/numRuns
| true |
97b438fc438310bf2e5f62452b1e7f1846a18881 | Python | Vivekg95/Python-Tutorial | /practise18.py | UTF-8 | 204 | 2.53125 | 3 | [] | no_license | def main():
f=open("C:\\Users\\Vivek Kumar\\Desktop\\python10\\guru99.txt","w+")
for i in range(10):
f.write("this is line %d\r\n" % (i+1))
f.close()
if __name__ == "__main__":main()
| true |
57c903eeb786fca644dcfaf7cbba26b56d46a3fd | Python | jtxiao/Harmonizer | /psola.py | UTF-8 | 2,848 | 2.671875 | 3 | [
"MIT"
] | permissive |
# coding: utf-8
# # 21M.359 Fundamentals of Music Processing
# ## Lab3
# In[1]:
import numpy as np
import matplotlib.pyplot as plt
import IPython.display as ipd
from ipywidgets import interact
import sys
sys.path.append("../common")
from util import *
import fmp
# %matplotlib inline
get_ipython().magic(u'matplot... | true |
967752f9d79be03454194846f37675354edf596a | Python | seongbeenkim/Algorithm-python | /BOJ(Baekjoon Online Judge)/Greedy/1783_병든 나이트(ill knight).py | UTF-8 | 241 | 3.125 | 3 | [] | no_license | #https://www.acmicpc.net/problem/1783
import sys
n, m = map(int, sys.stdin.readline().split())
if n == 1:
print(1)
elif n == 2:
print(min(4,(m+1)//2))
else:
if m >= 7:
print(m-7 + 5)
else:
print(min(4,m)) | true |
3f503a5922d07049f5e4431e562571cb9d3818bd | Python | jtgorman/DCC_jp2_converter | /dcc_jp2_converter/modules/converter.py | UTF-8 | 6,038 | 2.625 | 3 | [] | no_license | """High-level logic for orchestrating a conversion job."""
import logging
import os
import stat
import shutil
import tempfile
from .file_manager import get_tiffs
from .command_runner import CommandRunner
from dcc_jp2_converter import ImagemagickCommandBuilder, Exiv2CommandBuilder
from dcc_jp2_converter import imagemag... | true |
686d8bd0e5a30e54c26f427e1331082f70439363 | Python | marcomarasca/SDCND-Vehicle-Detection | /udacity_parser.py | UTF-8 | 6,457 | 2.703125 | 3 | [
"MIT"
] | permissive | import os
import csv
import numpy as np
import cv2
import argparse
from tqdm import tqdm
"""
The script used to parse the udacity dataset (https://github.com/udacity/self-driving-car/tree/master/annotations)
into usable images to train the vehicle vs non-vehicle classifier. Extracts from the tagged images the boundin... | true |
346087395b1de1955facadf0a28b43440680e6eb | Python | RITIKAJINDAL11/interview-bot | /aiml_category_generator.py | UTF-8 | 1,291 | 2.71875 | 3 | [] | no_license | import os
category=input("\nEnter Category")
current_directory=os.getcwd()
path="{}/aiml/{}".format(current_directory,category)
print(current_directory)
if not os.path.exists(path):
os.makedirs(path)
pattern=input("\nEnter Pattern").upper()
srai=input("\nEnter SRAI").upper()
addmore=1
ans=True
with open("{}/{}.aiml"... | true |
c951f981cd833d8094cf8426f0251b78e8fefba5 | Python | PhyuCin/CP1404PRAC | /Prac_01/test.py | UTF-8 | 30 | 2.78125 | 3 | [] | no_license | x = 4
y = 5
print(is_even(x)) | true |
9580d8f530a1987279b6321b578f9b6b76e5b897 | Python | cliffpham/algos_data_structures | /data_structures/disjoint_set/structure.py | UTF-8 | 2,214 | 4.1875 | 4 | [] | no_license | # Disjoint Set: A "take me to your leader" data structure
# Whenever a union occurs, we point to the nodes' leaders' rank and compare the two
# By doing so we can also assign all of the lower ranking leader's "lackeys" to the higher ranking leader
# aka "Path Compression"
# We can check if a node is directed to the cor... | true |
075a90a1ccc9bd1c280ef087487ba655fffbade6 | Python | jmt-transloc/ondemand-python | /integration/api/test_rides_api.py | UTF-8 | 6,433 | 2.609375 | 3 | [] | no_license | from typing import Generator
import pytest
from pytest import fixture
from requests import HTTPError
from utilities.api_helpers.rides import RidesAPI
from utilities.api_helpers.services import ServicesAPI
from utilities.factories.rides import RideFactory
from utilities.factories.services import ServiceFactory
@pytes... | true |
9679d330a5b1b5c4e04e9227af5f6d3e5f6a9b47 | Python | roperch/codewars-python-algorithms | /who-ate-cookie.py | UTF-8 | 586 | 3.890625 | 4 | [] | no_license | # test cases:
# cookie("Ryan") --> "Who ate the last cookie? It was Zach!"
# cookie(26) --> "Who ate the last cookie? It was Monica!"
# cookie(2.3) --> "Who ate the last cookie? It was Monica!"
# cookie(true) --> "Who ate the last cookie? It was the dog!"
def cookie(x):
if type(x) is str:
return "Who ate... | true |
b69eb4fb66f35d9b45c6a381495924212fc2a861 | Python | Rywells88/Gaussian_NaiveBayes_ML_Classifiers | /GaussianClassifier.py | UTF-8 | 2,333 | 3.3125 | 3 | [] | no_license | import numpy as np
from numpy import pi, exp
from scipy.io import loadmat
import matplotlib.pyplot as plt
data = loadmat('a1digits.mat') #dictionary types
training_data = data['digits_train']
testing_data = data['digits_test']
class_dict = {}
fig, ax = plt.subplots(1, 10, figsize = (18,10))
# this function returns... | true |
32077a02323fa17ec502e4bc2ba5dead2136b663 | Python | JKutt/PyDev | /testDCIP.py | UTF-8 | 6,151 | 2.546875 | 3 | [] | no_license | import unittest
import numpy as np
import DCIPsimpeg.DCIPtools as DCIP
class TestingReCalculationMethods(unittest.TestCase):
# testing rho calculation
def testRhoCalculation(self):
# homogenous halfspace
rho = 2200
In = 1.00
# create synthetic variables testing for a dipole ge... | true |
72afdc049a36330e316f1cbd11e9aea5cfe8c452 | Python | jadeaxon/demongeon | /src/main.py | UTF-8 | 464 | 2.9375 | 3 | [] | no_license | #!/usr/bin/env python3
import sys
from demongeon import *
# PRE: Due to use of f strings, this only works on Python 3.6 or later.
try:
assert sys.version_info >= (3, 6)
except:
print("ERROR: You are not running Python 3.6 or later.")
sys.exit(1)
# Play the game.
major, minor, patch = version
print(f"Welc... | true |
4dd89ebf5ffd330e4aefd8985b387bacc271c491 | Python | VVivid/python-programs | /dict/14.py | UTF-8 | 260 | 3.734375 | 4 | [] | no_license | """Write a Python program to sort a dictionary by key."""
color_dict = {'red': '#FF0000',
'green': '#008000',
'black': '#000000',
'white': '#FFFFFF'}
for item in sorted(color_dict):
print(item, color_dict[item])
| true |
6011a7ff2087f1bc93d9e71f2972af7584cb90cf | Python | tellmemax/ftp-server-bruteforce-attack | /ftpcracker.py | UTF-8 | 557 | 2.703125 | 3 | [] | no_license | import socket
import re
import sys
def connection(op,user,passw):
sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
print('Trying ' + ip + ':' + user + ':' + passw)
sock.connect(('192.168.1.1',21))
data = sock.revc(1024)
sock.send('User' + user + * '\r\n')
data = sock.revc(1024)
sock.send('Password' + pas... | true |
38585735d9937fe3c8484c33e758e5e6c6760c7e | Python | andrewchch/kanban_sim | /kanbansim/models/work.py | UTF-8 | 3,293 | 2.984375 | 3 | [] | no_license | import logging
class Work:
"""
A body of work to be done for a workflow step. Assumption is that all work is done by one actor.
"""
def __init__(self, name='Work', size=0, env=None, workflow=None, case=None):
assert size is not None, "Size must be greater than zero"
self.work_to_do = s... | true |
8b7fbbe1fe05cb819a9300e1bf6de40365e3f0fd | Python | eduardo579/Python3_Curso | /calculadora.py | UTF-8 | 1,037 | 4.46875 | 4 | [] | no_license | print('1. suma | 2. resta | 3. multiplicación | 4. división | 5. salir')
def suma(numero1, numero2):
resultado = numero1 + numero2
print('El resultado es: '+str(resultado))
def resta(numero1, numero2):
resultado = numero1 - numero2
print('El resultado es: '+str(resultado))
def multi(numero1, numero2)... | true |
dcbbaa561ba799814510bcf56c312253870fcd7f | Python | pranithkumar361999/Hackerrank-Solutions | /staircase.txt | UTF-8 | 370 | 3.234375 | 3 | [] | no_license | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the staircase function below.
def staircase(n):
sp=n-1
st=1
for i in range(n):
print((" ")*sp,end="")
print("#"*st,end="")
sp-=1
st+=1
print()
if __name__ == '__ma... | true |
23a91d379a58f1b701e5b98767c031c90e1a27f5 | Python | P1234Sz/PythonKurs | /Spotkanie2/zad2.py | UTF-8 | 336 | 3.578125 | 4 | [] | no_license | def Odsetki (oproc, czas, kwota):
odsetki = kwota * oproc * czas / 12
return odsetki
licz = Odsetki (0.03, 3, 1000)
print(licz)
i = 0
kwota = 1000
while i < 4:
kwota = kwota + Odsetki(0.03, 3, kwota)
i = i + 1
print("Odnawialna = " + str(round(kwota, 2)))
print("Caloroczna = " + str(1000 + Odsetki(0... | true |
424b842c17014e96f6a3bd2c0821389630e9ca1e | Python | Greensahil/CS697 | /matplot.py | UTF-8 | 342 | 3.265625 | 3 | [] | no_license | import matplotlib.pyplot as plt
import math
m = 0.5
c = 4
x = [ i for i in range(100)]
y = [m*i + c for i in x]
#plt.xticks(x,[i for i in range(2010,2020)])
plt.xlabel('Years')
plt.ylabel('price')
plt.plot(x,y)
y = [i**3 for i in x]
plt.plot(x,y)
y = [math.sin(i) for i in x]
plt.plot(x,y)
plt.legend(['exam','w... | true |
3389428130191aa7bb149993646916109121e5d1 | Python | itroot/projecteuler | /solved/level-2/26/solve.py | UTF-8 | 584 | 3.359375 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
def divide1by(number, accuracy):
my1=10**accuracy
return str(my1/number)
def findDividePeriod(numbers, dividerLength):
array=numbers[2*dividerLength+1:]
pattern=array[0:dividerLength]
array=array[dividerLength:]
return array.index(pattern)+1
def p... | true |
e3f0ed38e08f66229dc7dbe47673509833875394 | Python | sanskrit-lexicon/BUR | /issue3/prep_burab_examples.py | UTF-8 | 2,438 | 2.5625 | 3 | [] | no_license | #-*- coding:utf-8 -*-
"""prep_burab_examples.py
"""
from __future__ import print_function
import sys,re,codecs
import digentry
class ABtip:
def __init__(self,line):
m = re.search(r'^(.*)<(.*?)>(.*)</.*?> *\(([0-9]+)\)$',line)
self.ab = m.group(1).rstrip()
self.tipcode = m.group(2)
assert self.tipcode i... | true |
5f5e86ba34a88def9d71eb2345a8aa2f625e1bed | Python | olesmith/SmtC | /Curve/ArcLength.old.py | UTF-8 | 4,074 | 3.21875 | 3 | [
"CC0-1.0"
] | permissive | import time
from Base import *
from Timer import Timer
class Curve_ArcLength():
Integration_NI=10
Integration_Type=1 #(1) simpson, (2)
##!
##! If curve length defined with a function name, call it.
##! Otherwise, use numerical integration.
##!
def S_Calc(self,t,t0=None,n=100):
... | true |
066911240f89abd9e374f64bb8cad8816d7a2ba3 | Python | NonsoAmadi10/Okra | /okra/identity.py | UTF-8 | 3,492 | 2.765625 | 3 | [
"MIT"
] | permissive | import requests
from .okra_base import OkraBase
from .utils import validate_id, validate_dates, validate_date_id
class Identity(OkraBase):
"""This module returns various account holder information on file with the bank, including names, emails phone
numbers and addresses.
Key functions:
get_identiti... | true |
d3bf9e974b28dcfcd44e3b3a3e4e5cb9a06660af | Python | encryptogroup/SoK_ppClustering | /utils/cluster/dataset.py | UTF-8 | 2,876 | 2.703125 | 3 | [
"MIT"
] | permissive | # MIT License
#
# Copyright (c) 2021 Aditya Shridhar Hegde
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modif... | true |
0fed9ea24b66c71616a74e73d93dde4ff5b7d5ad | Python | Adills1494/phrase-hunter-game.py | /constants.py | UTF-8 | 487 | 2.640625 | 3 | [] | no_license | PHRASES = [
("Doth mother know you weareth her drapes", "Shakespeare in the park? More like Tony Stark in the park")
("You gonna eat your tots", "In the cafeteria with Nepoleon Dynomite")
("With great power comes great responsibility", "Bitten by a radioactive spider and this is what you tell me uncle?")
... | true |
956c8a0290e7c55283c7e36753015b7a21c62cd5 | Python | valohai/valohai-yaml | /valohai_yaml/utils/duration.py | UTF-8 | 1,320 | 3.25 | 3 | [
"MIT"
] | permissive | import datetime
import re
from typing import Optional, Union
suffixes = {
"s": 1,
"m": 60,
"h": 60 * 60,
"d": 60 * 60 * 24,
"w": 60 * 60 * 24 * 7,
}
simple_duration_re = re.compile(r"(?P<value>[.\d]+)\s*(?P<suffix>[a-z]*)")
def parse_duration_string(duration_str: str) -> datetime.timedelta:
... | true |
2b70b401626203b0922c4ec7666e0978bd9bc013 | Python | Swastik-Saha/Python-Programs | /Upper&Lower_Triangular_Matrix.py | UTF-8 | 674 | 3.921875 | 4 | [] | no_license | #Upper and Lower Triangular Matrix
def ultMat():
dim = int(raw_input("Enter the dimension of the matrix: "))
mat =[[0 for i in range(0,dim)]for j in range(0,dim)]
for i in range(0,dim):
for j in range(0,dim):
mat[i][j] = int(raw_input("Enter an element o... | true |
7f16a78002b815fb80d10017f93242c7d60dc777 | Python | Confucius-hui/LeetCode | /排序算法/快速排序.py | UTF-8 | 26 | 2.53125 | 3 | [] | no_license | a = [1,23,9]
print(min(a)) | true |
eb9580e7393f073428d23dda1ff37d53a106ce91 | Python | StBogdan/PythonWork | /HackerRank/Intro/Python_if-else.py | UTF-8 | 323 | 3.53125 | 4 | [] | no_license | if __name__ == '__main__':
n = int(input())
if( n % 2 != 00):
print("Weird")
else:
if( 2<=n and n<=5):
print("Not Weird")
elif (6<=n and n<=20):
print("Weird")
elif (n>20):
print("Not Weird"... | true |
f7b3e1b45226dd00147f69a150379f0b95b94eab | Python | ryoryo666/Gazebo_sim | /src/archive/SpeedClass.py | UTF-8 | 578 | 3.0625 | 3 | [] | no_license | class VW():
def __init__(self,TurningData,d,translation_v):
self.r=TurningData.Radius
self.direction=TurningData.Direction
self.d=d
self.v=translation_v
self.v_in =self.v*((self.r+self.d)/self.r)
self.v_out =self.v*((self.r-self.d)/self.r)
def V_IN(self):
... | true |
cb21666fd7fcf24724ef23c9fe54456e5d316339 | Python | AbcSxyZ/GetHome-Leboncoin | /Ad_class.py | UTF-8 | 3,724 | 3.09375 | 3 | [] | no_license | class Ad:
"""Object to represent an Ad of Leboncoin website,
mainly for renting ads"""
def __init__(self, title, link, price=None, pictures=None, phone=None,
description=None, proprietary=None, size=None, rooms=None,
publication_date=None, address=None):
self.title =... | true |
16b245766e87b3b67e190078900dbad9814f622f | Python | icicl/minecraft-map-art-nbt-creator | /mc map nbt.py | UTF-8 | 2,943 | 2.671875 | 3 | [] | no_license | pathtomcsaves = "/Users/admin/Library/Application Support/minecraft/saves/"#path to the minecraft saves folder (this is for mac, if you replace 'admin' with your username
mcworldfolder = "testserv/"#name of the world
image = 'eagle.jpeg'#filepath of image, or image name if it is in the same directory as this file
crop ... | true |
d59007ad7805cd6534f4ef06d563a77b47746519 | Python | y0ge5h/olympic_project_new | /q02_country_operations/build.py | UTF-8 | 600 | 2.609375 | 3 | [] | no_license | # %load q02_country_operations/build.py
# default imports
from greyatomlib.olympics_project_new.q01_rename_columns.build import q01_rename_columns
#Previous Functions
path = './data/olympics.csv'
OlympicsDF=q01_rename_columns(path)
def q02_country_operations(OlympicsDF):
OlympicsDF['Country_Name'] = OlympicsDF... | true |
01580d1945c5883ea37f139bec279fe4bef93a59 | Python | strengthen/LeetCode | /Python3/152.py | UTF-8 | 3,202 | 3.140625 | 3 | [
"MIT"
] | permissive | __________________________________________________________________________________________________
sample 48 ms submission
class Solution:
def maxProduct(self, nums: List[int]) -> int:
def split(nums: List[int], n: int):
"""
Split the list at elements equal to n
"""
... | true |
e3291742ef2c995bc898ac82b5dc3fd1ff13c247 | Python | ashtmMSFT/FoodTruckFinder | /ftf.py | UTF-8 | 4,097 | 3.3125 | 3 | [] | no_license | from geopy import distance
import logging
import os
import pandas
import requests
import sys
## 'Constants'
FOOD_TRUCK_DATA_CSV = "Mobile_Food_Facility_Permit.csv"
FOOD_TRUCK_DATA_URL = "https://data.sfgov.org/api/views/rqzj-sfat/rows.csv?accessType=DOWNLOAD"
## Function definitions
def parse_user_input(user_input):
... | true |
b837c5a5b4f235b360855aa1104a39f08f99c123 | Python | felipee1/GraphQlPython | /database/config/crud.py | UTF-8 | 1,638 | 2.625 | 3 | [] | no_license | import sys
from sqlalchemy.orm import Session
from database.entitys import User
from database.entitys.User import UserAuthenticate
from database.models import UserModel
import bcrypt
def get_user_by_username(db: Session, username: str):
user = db.query(UserModel.UserInfo).filter(
UserModel.UserInfo.userna... | true |
bfaf30eb38170f60ae025a23289038ec5e30835a | Python | tejvi-m/pandas_opencl | /tests/benchmark.py | UTF-8 | 578 | 2.578125 | 3 | [] | no_license | import numpy as np
import os
import scipy.stats
results = []
command = os.popen(' g++ -std=c++17 tests/cppTest.cpp -lOpenCL -O3 -w')
command.close()
for j in [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999]:
xres = []
for i in range(0, 5):
command = os.popen('./a.out ' + str(j))
# print(c... | true |
acc9416df8fd601869ba048584a37c1e32865764 | Python | ankit-cn-47/DSA | /python/minValue.py | UTF-8 | 282 | 3.546875 | 4 | [] | no_license | def main():
arr = [25, 10, 9, 38, 75]
minValue = findMin(arr)
print(minValue)
def findMin(arr):
length = len(arr)
minIndex = 0
for i in range(length):
if arr[i] < arr[minIndex] :
minIndex = i
return arr[minIndex]
main() | true |
38703dbcfe5764f4bb8efc6ce2d85ccf04551aa8 | Python | christensonb/Seaborn | /seaborn/file/file.py | UTF-8 | 7,863 | 2.75 | 3 | [
"MIT"
] | permissive | """ This module contains helper functions for manipulating files """
__author__ = 'Ben Christenson'
__date__ = "10/7/15"
import os
import shutil
import hashlib
import time
import inspect
import json
if os.name == 'posix': # mac
TRASH_PATH = '/'.join(os.getcwd().split('/')[:3] + ['.Trash'])
else:
TRASH_PATH = ... | true |
0fd2a3bf64167ffaaaed9a7e53e3c709d392bfb0 | Python | Maya2468/Python-Code | /AtlantaPizza.py | UTF-8 | 331 | 3.71875 | 4 | [] | no_license | number_of_pizzas = eval(input("How many pizzas do you want? "))
cost_per_pizza = eval(input("How much does each pizza cost? "))
subtotal = number_of_pizzas * cost_per_pizza
tax_rate = 0.08
sales_tax = subtotal * tax_rate
total = subtotal + sales_tax
print("Pizza $",subtotal)
print("Sales Tax $", sales_tax)
print("Total... | true |
f80b72ad5ba3c3cacf7087aff859762016b2c3d3 | Python | a3910/aid1807-1 | /aid1807正式班老师课件/Django/Day06/DjangoDemo06/index/forms.py | UTF-8 | 1,077 | 2.546875 | 3 | [] | no_license | from django import forms
#声明ChoiceField要用到的数据
TOPIC_CHOICE = (
('1','好评'),
('2','中评'),
('3','差评'),
)
#表示评论内容的表单控件的class
#控件1-评论标题-文本框
#控件2-电子邮箱-邮件框
#控件3-评论内容-Textarea
#控件4-评论级别-下拉选择框
#控件5-是否保存-复选框
class RemarkForm(forms.Form):
#评论标题
# forms.CharField() - 文本框
# label : 控件前的文本标签
subject = forms.CharField(... | true |
ea3739dbd8b516026bc94f1639e80ac0e5833fde | Python | oooto/nlp100 | /第4章_形態素解析/ans36.py | UTF-8 | 1,162 | 2.828125 | 3 | [] | no_license | import pathlib
import japanize_matplotlib
import matplotlib.pyplot as plt
import pandas as pd
file_path = pathlib.Path(__file__).resolve().parent / 'neko.txt.mecab'
with open(file_path, encoding="utf-8") as f:
strs = f.read().split("EOS\n")
strs = [s for s in strs if s != ""]
blocks = []
for sentence... | true |
8cdc4d2892d17e31293fe655ed207def4f1e67f8 | Python | KaduHod/Estacao-Metereologica | /Medição.py | UTF-8 | 585 | 3.296875 | 3 | [] | no_license | import dht
import machine
import time
d = dht.DHT11(machine.Pin(4))
while True:
d.measure()
temperatura = d.temperature()
humidade = d.humidity()
if (temperatura > 31) and (humidade > 70):
print("Temperatura de acordo com os requisitos necessários para ligar o relé")
else:
... | true |
9faff3096c23b25682736f693f1b71dce73adcde | Python | PPpiper7/project1 | /ine-phon if-elif3/ex4.py | UTF-8 | 457 | 3.8125 | 4 | [] | no_license | print('Please select operation')
print('1.add')
print('2.Subtract')
print('3.Multiply')
print('4.Divide')
operation = int(input('Select opration form 1, 2, 3, 4 : '))
n = int(input('Enter first number :'))
m = int(input('Enter second number :'))
if operation == 1 :
print( n,'+',m,'=',n + m )
elif operation == 2 :
... | true |
e0d6d1e9986b0e0f17ec5e63b5e400d4774afbc4 | Python | IsaacLaw12/KlotskiSolver | /test_block.py | UTF-8 | 1,938 | 3.0625 | 3 | [] | no_license | import unittest
import numpy as np
from block import Block
class test_block(unittest.TestCase):
def test_adjacent(self):
orig = Block((0,0), (3,3))
down = Block((3,0), (1,1))
right = Block((0,3), (1,1))
inside = Block((0,0), (1,1))
not_adj = Block((5,5), (1,1))
self.... | true |
b51d429070c1aee0949c2470a0181eea50542c41 | Python | ezy0812/asdf | /python/python-in-html/xmlparsing.py | UTF-8 | 571 | 2.546875 | 3 | [] | no_license | import sys
from io import StringIO
import contextlib
import bs4
doc = open('test.html').read()
soup = bs4.BeautifulSoup(doc, 'lxml')
py = soup.find_all(id="#py")
@contextlib.contextmanager
def stdoutIO(stdout=None):
old = sys.stdout
if stdout is None:
stdout = StringIO()
sys.stdout = stdout
y... | true |
2fed69f970c086fdba8791bbcd91d306203f5c10 | Python | indhu6499/guvi | /code/prog13.py | UTF-8 | 214 | 3.015625 | 3 | [] | no_license | p,o = [int(i) for i in input(" ").split(" ")]
m = []
List = [int(i) for i in input().split()]
for _ in range(o):
l, k = [int(i) for i in input().split()]
m.append(min(List[l-1:k]))
for i in m:
print(i)
| true |
889c0ec8b5e68058b2d17b254a248ff3fb52cadc | Python | William1104/how-it-works | /src/main/java/ru/skuptsov/differentiation/autoGradPytorch.py | UTF-8 | 341 | 3.328125 | 3 | [] | no_license | import torch
# x=2, y=3, α = 4, β=5
x = torch.tensor(2.0, requires_grad=False)
y = torch.tensor(3.0, requires_grad=False)
α = torch.tensor(4.0, requires_grad=True)
β = torch.tensor(5.0, requires_grad=True)
# loss = (αx+β-y)^2
loss = pow((α * x + β - y), 2)
loss.backward()
print(loss)
print(α.grad)
print(β.grad)
pri... | true |
46e727bbec38809daca79b159c8b08d700005e73 | Python | ianzhang1988/PythonScripts | /network/hdfs/debug_hdfs.py | UTF-8 | 3,659 | 2.546875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# @Time : 2020/3/18 10:35
# @Author : ZhangYang
# @Email : ian.zhang.88@outlook.com
import subprocess, os
import logging
import logging.handlers
import time
class HDFSError(Exception):
pass
class HadoopFsAdapterClient(object):
def __init__(self, hdfs_user_name, hdfs_root):
... | true |
258deb1b4990ab4fe910a0e03e820edbcd2d1c8d | Python | LungFun/3d-LDA | /src/data/all/trans_info.py | UTF-8 | 223 | 2.765625 | 3 | [] | no_license | import sys
with open(sys.argv[1]) as fp:
for line in fp:
line = line.strip()
if ':' not in line:
print line
else:
print ' '.join([i.split(':')[0] for i in line.split()])
| true |
b98da8a7e33392cfdede3db29b6cd1db06fc67ad | Python | wan-catherine/Leetcode | /test/test_130_surrounded_regions.py | UTF-8 | 879 | 2.953125 | 3 | [] | no_license | from unittest import TestCase
from problems.N130_Surrounded_Regions import Solution
class TestSolution(TestCase):
def test_solve(self):
self.assertListEqual([["O","O","O"],["O","O","O"],["O","O","O"]], Solution().solve([["O","O","O"],["O","O","O"],["O","O","O"]]))
def test_solve_1(self):
input... | true |
73d2afb98798da44d2f1b97a979993b74ccc5149 | Python | knzh/Python | /py/while-if-break.py | UTF-8 | 80 | 3.359375 | 3 | [] | no_license | n=1
while n<=100:
if n>50:
break
print(n)
n+=1
print('END')
| true |