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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
0cadda30c4235460ab0a81e9791d2c1fd31e865d | Python | rmmanseau/ssstatus | /ssstatus.py | UTF-8 | 6,311 | 3.140625 | 3 | [] | no_license | #!/usr/bin/python
import sys
import os
import time
config_dir = os.path.expanduser('~') + '/.config/ssstatus/'
def print_help():
print('Super Simple Status')
print('usage: ssstatus [command]')
print('')
print('set "<your status>" - set the body of your status, it will automatically be split into lin... | true |
e99dda57c107a470af58aed9b20db952bfd38aa5 | Python | KimDongGon/Algorithm | /1000/1000/1076.py | UTF-8 | 264 | 3.046875 | 3 | [] | no_license | color = ['black', 'brown', 'red', 'orange', 'yellow', 'green', 'blue', 'violet', 'grey', 'white']
mul = [10 ** i for i in range(0, 10)]
arr = list(input() for _ in range(3))
print(int(str(color.index(arr[0])) + str(color.index(arr[1]))) * mul[color.index(arr[2])]) | true |
d589087e60102e4d570681422dddd23f3674b463 | Python | zoelie/STS-semantic-similarity | /Poojitha_preliminary_analysis.py | UTF-8 | 1,868 | 3.390625 | 3 | [] | no_license | import pandas as pd
import matplotlib.pyplot as plt
def loaddata(filename):
col_names =["col1","col2","col3","col4","similarity","sen1","sen2"]
return pd.read_csv(filename, sep= "\t", names=col_names, usecols=["similarity","sen1","sen2"])
train_df=loaddata('sts-train.csv')
#Describing the data
print("Diplay... | true |
b80f7392ac9cfdf8228b9f5d3421b8bdc9b903aa | Python | manojakumarpanda/This-is-first | /fundamental/bitwise operator.py | UTF-8 | 1,033 | 3.375 | 3 | [] | no_license | a=int(input('Enter the value for a variable :'))
b=int(input('Enter the value to shift the varialble to some bit:'))
s=a
n=b
f=s<<n
z=n>>s
c=a>>b
d=a<<b
print('The original value of variable :',a)
print('The original value of variable :{:b}'.format(a))
print('The originla value of the bitwise variable is:',b,end=('@@')... | true |
683b83d397b6b300e07bfd80c6cedb9694cdbbe0 | Python | jsamuel3/motor_servo | /motor_servo.py | UTF-8 | 534 | 3.078125 | 3 | [] | no_license | import serial
import time
ser = serial.Serial('/dev/ttyS0', baudrate=9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE,bytesize=serial.EIGHTBITS)
ser.isOpen()
print("Connected to: " + ser.portstr)
while True:
input = raw_input("Enter angle for servo: ")
p = int(float(input));
if p >= 0:
... | true |
a7d1b1f046a597c76d81df909acefadcabc20ca7 | Python | neogyk/DNA-Analitics | /EDIT/app/data_analyse.py | UTF-8 | 219 | 3.15625 | 3 | [] | no_license | def diff(list_1,list_2):
d_list = []
for i in list_1:
if i not in list_2:
d_list.append(i)
return d_list
def Sum(array):
sum=0
for i in array:
sum+=i
return sum | true |
ee20702ac6581cc67bddce4c51b70c2a264ea225 | Python | cyrt63/demos | /Mathematics/NumPy/arithmetic-mul.py | UTF-8 | 275 | 2.84375 | 3 | [] | no_license | from numpy import *
from e3ga import *
x = array([1,2,3])
y = array([9,7,5])
print x * y
e1 = VectorE3(1,0,0)
e2 = VectorE3(0,1,0)
e3 = VectorE3(0,0,1)
x = array([4*e1,1])
y = array([e2,e3])
print x
print y
print x * y
print y * x
print x * 3.0
print 3.0 * x
print x + y
| true |
d69c322624fc3685a25358db4d1209ba698b2be2 | Python | freddyiniguez/data_analysis_and_visualization | /12_lecture.py | UTF-8 | 1,933 | 4.28125 | 4 | [] | no_license | # Lecture 12 - Array Processing
import numpy as np
import matplotlib.pyplot as plt
# In order to see the visualization
%matplotlib inline
# Let's create an array with initial value, stop value and inteval
points = np.arange(-5,5,0.01)
# Create a pair of grids
dx,dy = np.meshgrid(points, points)
# Z values
z = (np.s... | true |
34175c7944424ddb1d4fea3bc7136797d25ad74a | Python | NURDspace/nurdbar | /tests/test_bar.py | UTF-8 | 8,591 | 2.671875 | 3 | [] | no_license | from _basetest import BaseTest
from nurdbar import NurdBar, BarcodeTypes, model
from decimal import Decimal
from nurdbar import exceptions
import logging
class TestBar(BaseTest):
def setUp(self):
super(TestBar,self).setUp()
self.log=logging.getLogger(__name__)
self.member=self.bar.addMembe... | true |
6515192fef3cea92e888f6d917cec8b1df9e6737 | Python | Meincke91/content-ai | /linkUtils.py | UTF-8 | 1,311 | 2.625 | 3 | [] | no_license | from domainExtensions import *
class LinkUtils:
def domainExtension(self):
crimefile = open('domainExtensions.txt', 'r')
yourResult = [line.split(',') for line in crimefile.readlines()]
f = open('workfile.', 'w')
for line in yourResult:
f.write('"%s",' % (line))
print(len(yourResult))
def linkSplitter(... | true |
7c7c82034719f5205210567142eab38b872b4a1c | Python | YuHongJun/python-training | /scripts/producer.py | UTF-8 | 690 | 2.8125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
# -*- coding:utf-8 -*-
__author__ = 'Demi Yu'
import csv
import time
from kafka import KafkaProducer
# 实例化一个KafkaProducer示例,用于向Kafka投递消息
producer = KafkaProducer(bootstrap_servers='127.0.0.1:9092')
# 打开数据文件
csvfile = open("../data/user_log.csv", "r")
# 生成一个可用于读取csv文件的reader
reader = csv.reader... | true |
9ca7a916ee86614ebb50151f99bb8b9071cccd3e | Python | aditinarware/project_euler | /pe001.py | UTF-8 | 559 | 4.4375 | 4 | [] | no_license | """
Project Euler Problem #1: Multiples of 3 and 5
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
"""
def sum(n, k):
"""
Returns sum of multiples of k which are less than n
""... | true |
92b2ec0a5863e88787d25e907bc3672f40d15733 | Python | gabrielvba/ri_lab_01 | /ri_lab_01/spiders/brasil_247.py | UTF-8 | 2,850 | 2.734375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import scrapy
import json
from ri_lab_01.items import RiLab01Item
from ri_lab_01.items import RiLab01CommentItem
class Brasil247Spider(scrapy.Spider):
name = 'brasil_247'
allowed_domains = ['brasil247.com']
start_urls = []
months = ["Janeiro",
"Fevereiro",
... | true |
fe55c8740947fc8b1858e7dc0e8dab44c1b5a763 | Python | glester84/2019-fall-okcoders-python | /02-logs-strings-and-json/03A_my_classes.py | UTF-8 | 352 | 3.171875 | 3 | [] | no_license | class Hitting:
hits = 0
outs = 0
total = 0
def add_hit(self):
self.hits += 1
self.total += 1
def add_out(self):
self.outs += 1
self.total += 1
def __str__(self):
return f'{self.hits} {self.outs} {self.total}'
def bat_avg(self):
return float... | true |
c97c826dd2a70d19b019d2fabe98da1a660d9736 | Python | Lujianyuan99/computational-data-analysis-machine-learning- | /HW4_jlu428/Part2b.py | UTF-8 | 6,232 | 2.71875 | 3 | [] | no_license | # @Time : 2020/10/5 15:17
# @Author : Jianyuan Lu
# @FileName: Part2b.py
# @Software: PyCharm
# @Time : 2020/10/4 22:16
# @Author : Jianyuan Lu
# @FileName: Part1b.py
# @Software: PyCharm
import csv
from scipy.io import loadmat
import numpy as np
import pandas as pd
import matplotlib.pyplot as... | true |
964b53a5eb520b7bac1040a12ac45686258e81f4 | Python | david888844/C-digos-Programaci-n | /Prg28_P.convalorpordefecto1.py | UTF-8 | 296 | 3.15625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Fri Mar 19 10:50:36 2021
@author: David Alzate
"""
def titulo_subrayado(titulo,caracter="*"):
print(titulo)
print(caracter*len(titulo))
# bloque principal
titulo_subrayado("Sistema de Administracion")
titulo_subrayado("Ventas","-")
| true |
b3ebfaf9f23fdfd58778c9cc547696c8e4e0570b | Python | chris-hamberg/statistics_and_data_analysis | /3.3b.py | UTF-8 | 2,131 | 3 | 3 | [] | no_license | import matplotlib.pyplot as plt
import numpy as np
import pathlib
#NOTE Plot Info Configuration
font = 'Serif'
title = 'Cell Phone Usage at Work'
source = 'Source: "Whistle - But Don\'t Tweet - While You Work," www.roberthalftechnology.com, October 6, 2009'
ylabel = 'Cumulative Percentage'
filename = pathl... | true |
b137c58817cd71c5851a406652f6d08898fa81d1 | Python | thirtyHP/CraigslistScraper | /craigslistscraper/json_build.py | UTF-8 | 4,588 | 3.21875 | 3 | [
"MIT"
] | permissive | from craigslistscraper import domain, scraper
import concurrent.futures
import os
from time import strftime
import json
class JsonProcessor:
"""
JsonProcessor takes in 3 arguments, an array of domains, an array of cities,
the string of whats being searched, and whether or not you want car data.
The i... | true |
f88a447ca4cb65177ae43824af0e0b1735a656da | Python | sunstat/icml-workshop | /text-20news/lime_explain_text_multiclass.py | UTF-8 | 2,107 | 2.71875 | 3 | [] | no_license | import lime
import sklearn
import numpy as np
import sklearn
import sklearn.ensemble
import sklearn.metrics
from sklearn.datasets import fetch_20newsgroups
newsgroups_train = fetch_20newsgroups(subset='train')
newsgroups_test = fetch_20newsgroups(subset='test')
# making class names shorter
class_names = [x.split('.')[-... | true |
8b4aee5017c555543a0757e269a7b78a89efff1f | Python | amrutaDesai/pythonPractice | /pythonFundamentals/section10/regexSubVerboseMethod.py | UTF-8 | 1,633 | 3.609375 | 4 | [] | no_license | import re
# find Agent followed by a word whoch is name
str = 'Agent Alice gave all the secret documents to Agent Bob'
nameRegex = re.compile(r'Agent \w+')
print(nameRegex.findall(str))
# O/P ['Agent Alice', 'Agent Bob']
# find and replace(substitute) :- substitute method the sub methid
print(nameRegex.sub('REDACTED'... | true |
1ba22eada939a27326d5955322a65a695af63766 | Python | chch8326/CodingTest | /shortestpath/ShortestPathPrac2.py | UTF-8 | 2,410 | 3.328125 | 3 | [] | no_license | '''
문제: 전보
어떤 나라에는 N개의 도시가 있다. 그리고 각 도시는 보내고자 하는 메시지가 있는 경우, 다른 도시로 전보를 보내서 해당 메시지를 전송할 수 있다.
하지만 X라는 도시에서 Y라는 도시로 전보를 보내고자 한다면 도시 X에서 Y로 향하는 통로가 설치되어 있어야 한다. 예를 들어 X에서 Y로 향하는
통로는 있지만 Y에서 X로 향하는 통로가 없다면 Y는 X로 메시지를 보낼 수 없다. 또한 통로를 거쳐 메시지를 보낼 때는 일정 시간이 소요된다.
어느 날 C라는 도시에서 위급 상황이 발생했다. 그래서 최대한 많은 도시로 메시지를 보내고자 한다. 메시지는 도시... | true |
78e129eef9c8ce718e46eef18f706f4a87ad9359 | Python | dishajain1211/Style-Based-Recommendation-System | /Inconsistency/inconsistency.py | UTF-8 | 544 | 2.703125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sun Jun 3 01:04:20 2018
@author: Disha Jain
"""
from bs4 import BeautifulSoup
soup = BeautifulSoup(open("0.html"), "html.parser")
list = [tag.name for tag in soup.find_all()]
tagset = set(list)
print (tagset)
tagList = []
for p in soup.body.find_all():
... | true |
1ea91d0bd273ea4b7a1b8abd8c20d1cbbb995909 | Python | BearGuy/image-processing | /a1/main.py | UTF-8 | 5,156 | 3.046875 | 3 | [] | no_license | # Image manipulation
#
# You'll need Python 2.7 and must install these packages:
#
# numpy, PyOpenGL, Pillow
import sys, os, numpy
try: # Pillow
from PIL import Image
except:
print 'Error: Pillow has not been installed.'
sys.exit(0)
try: # PyOpenGL
from OpenGL.GLUT import *
from OpenGL.GL import *
from... | true |
9cf3675e4e58e98cdc95fb8d0a3c61df34f60d0d | Python | Bara-Ga/WD1Site | /decorator_exercise_2.py | UTF-8 | 503 | 3.71875 | 4 | [] | no_license | import random
# create a decorator calles chaosmachine
# it replaces all passed values with a random number between 1 and 100
# and then calls the original function
def chaosmachine(func):
def wrapper(*args, **kwargs):
zahl = random.random()*100
result = func(zahl)
#return func(random.rando... | true |
a6d4808b37d483ec072fd75c650b2094733e08b1 | Python | nickvasko/DLTrainer | /example/run.py | UTF-8 | 1,207 | 2.765625 | 3 | [
"MIT"
] | permissive | from DLTrainer.pytorch import DLTrainer
from model import SimpleConfig, SimpleModel
from dataset import SimpleDataset
from metrics import calculate_metrics
"""MODELS Dictionary
The models dictionary contains the model classes to be used during training.
The base format is designed for NLP tasks, however, can be used... | true |
69dc885334a7ce0f11ec77f312ab5407f634e223 | Python | Firekiss/python_learn | /junior/def/keyword_args.py | UTF-8 | 182 | 2.78125 | 3 | [
"MIT"
] | permissive | def info(*, desc, birth, name='imooc'):
print('{name}-{desc}出生于{birth}'.format(name=name, desc=desc, birth=birth))
info(desc='程序员的梦工厂', birth='2013年8月') | true |
2b048dc99d7ecc35791c9b1550d79b2d544e6cb3 | Python | alant/algo1 | /wk2_quick.py | UTF-8 | 839 | 3.671875 | 4 | [] | no_license | def quickSort(array, l, r):
if l < r:
pivot = partition(array, l, r)
quickSort(array,l,pivot-1)
quickSort(array,pivot+1,r)
def partition(array, l, r):
p = r
i = l-1
print ("l: %d, r: %d" % (l, r))
for j in range(l,r):
# print("p: %d, i: %d, j: %d" % (p, i, j))
... | true |
6e5bfd2e7fd64e40f5e517ec0f85e0c2011de14e | Python | JX-Wang/NewCoder | /数列/__init__.py | UTF-8 | 1,017 | 3.78125 | 4 | [] | no_license | #! /usr/bin/python
# coding:utf-8
"""
题目描述
某种特殊的数列a1, a2, a3, ...的定义如下:a1 = 1, a2 = 2, ... , an = 2 * an − 1 + an - 2 (n > 2)。
给出任意一个正整数k,求该数列的第k项模以32767的结果是多少?
输入描述:
第1行是测试数据的组数n,后面跟着n行输入。每组测试数据占1行,包括一个正整数k (1 ≤ k < 1000000)。
输出描述:
n行,每行输出对应一个输入。输出应是一个非负整数。
示例1
输入
复制
2
1
8
输出
复制
1
408
"""
while 1:
n = ... | true |
68512c76aa5e6ebceca4906c3896212eb2e2ab69 | Python | cedadev/ipython_project | /globalmean.py | UTF-8 | 6,583 | 3.15625 | 3 | [
"BSD-3-Clause"
] | permissive | """A module to compute the seasonal mean over a variable in a dataset.
Depends on IPython, netCDF4 and cdms2.
See the run function. time_bounds may also be useful.
"""
from glob import glob
from IPython.parallel import Client, interactive
import numpy
from netCDF4 import MFDataset, num2date
import cdms2
def spl... | true |
e1840344b3ad51e599088ab7b1435febd4f6a6ac | Python | simonromain5/interaction-models | /animate.py | UTF-8 | 3,052 | 3.171875 | 3 | [] | no_license | import tkinter as tk
import numpy as np
class MovementAnimation:
"""
This class represents on a canvas the movement of particles according to different models.
:param cl: model that is represented in the canvas
:type cl: class
:param side: length of the square canvas
:type side: float
"""... | true |
f78b50fb46a65bbc54af72285385993899d7736e | Python | VIBE-APP/Vibe-Backend | /utils/RDS_query_executor.py | UTF-8 | 1,561 | 2.90625 | 3 | [] | no_license | import mysql.connector
class RDS_query_executor:
"""Helper class to manage access to the the-stronghold database"""
cnx = None
def __init__(self, endpoint, user, password, port, dbname):
self.endpoint = endpoint
self.user = user
self.password = password
self.port = port
... | true |
fbabd56a51d68d78c11c28805c6cb6c5ddfe08df | Python | kmoco2am/eink-netatmo-client | /ui/desktop.py | UTF-8 | 6,240 | 2.59375 | 3 | [] | no_license | import os
from datetime import datetime
from typing import Optional, Tuple
from PIL import Image, ImageDraw, ImageFont, ImageChops
from ui.render_result import RenderResult
from widget.panel import PanelWidget
from widget.weather_icon_lookup import WeatherIconLookup
def read_val(data: dict, section: str, value: st... | true |
ee7518c5a93431bb8e8648107029abd4f2e485a1 | Python | zhoutuo/Cracking_the_Coding_Interview | /Linked Lists/2_1.py | UTF-8 | 3,266 | 3.8125 | 4 | [] | no_license | import unittest
import List
def removeDuplicates(input_list):
newList = List.LinkedList()
val_set = set()
for val in input_list:
if val not in val_set:
val_set.add(val)
newList.append(val)
return newList
def removeDupsInPlace(input_list):
try:
curNode = in... | true |
bbafdc20b22f3cff3fae86a936fa6ad953ccccee | Python | pavanvermaR0278/HCL | /first.py | UTF-8 | 1,791 | 3.734375 | 4 | [] | no_license |
class Node:
def __init__(self, key):
self.key = key
self.left = None
self.right = None
def findPath(root, path, k):
if root is None:
return False
path.append(root.key)
if root.key == k:
return True
if ((root.left != None and findPath(root.left, path, k))... | true |
587d26ced230c56ec89a911b7e517e59f00bc818 | Python | UncleGua/learnpy | /返回函数.py | UTF-8 | 1,169 | 4.1875 | 4 | [] | no_license | #方法一:利用指针原理:直接在改变本身来实现。闭包内修改普通类型会报错,但是可以lying改变复杂类型的值,而不
def createcounter() :
a=[0]
def counter():
a[0]=a[0]+1
return a[0]
return counter
cc=createcounter()
print(cc())
print(cc())
#方法二:利用nonlocal声音一个非内部函数的局部变量。从而进行修改。
def createCounter():
n = 0 # 先定义一个变量作为初始值
def counter(): ... | true |
7ab3fa72856cb1d073bba0f3bd457387f4e19eea | Python | SauronsEyes/Python_3_for_Dummies | /urlCode.py | UTF-8 | 443 | 2.53125 | 3 | [] | no_license | import urllib.request
import urllib.parse
url='http://pythonprogramming.net'
values={'s':'basic',
'submit':'search'}
data=urllib.parse.urlencode(values)
data=data.encode('utf-8')
req=urllib.request.Request(url,data)
resp=urllib.request.urlopen(req)
respData=resp.read()
#headers['User-Agent'] = 'Mo... | true |
bdf94346095c9ebc6f1340daefaf14f94e9817d9 | Python | changzeng/KeyBoardMonitor | /data_analyze.py | UTF-8 | 3,115 | 2.6875 | 3 | [] | no_license | # encoding: utf-8
import os
import time
import ujson
from collections import defaultdict
file_name = "output.log"
KEY_MAP = {
"\x05": "ins"
}
def get_raw_data():
res = []
with open(file_name) as fd:
for line in fd:
line = line.strip().split(" ")
key = line[2]
... | true |
31d4cf5a511ed9cacef2bbf62bac292587fae163 | Python | viniciosarodrigues/python-estudos | /ex010.py | UTF-8 | 314 | 3.765625 | 4 | [] | no_license | print('======== Exercício 11 (Calcula área de uma parede ========')
altura = float(input('Informe a altura da parede: '))
largura = float(input('Informe a largura da parede: '))
print('A parede possui {}m², será necessário {}l de tinta para pintar a mesma.'.format(altura * largura, (altura * largura)/2))
| true |
af1aa1bced2264ee20beb4977b7d8bcb423209c5 | Python | Dwan13/AlcoholAdulteradoCNN | /servidor/temp.py | UTF-8 | 3,448 | 2.59375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Editor de Spyder
Este es un archivo temporal.
"""
import librosa
import librosa.display
import numpy as np
from sklearn.preprocessing import LabelEncoder
import keras
import librosa
from flask import Flask, jsonify, request
import json
import wget
from os import remove
from flask import Fla... | true |
b7e6f4983c2c371c5bb3eaa0cc8125d555c91df8 | Python | pristanna/pyladies | /03_cykly/kamaradi.py | UTF-8 | 384 | 3.5625 | 4 | [] | no_license | for kamarad in "Bartulka" , "Mila" , "Martina" , "Yvette" , "Slavek": # prints each string on one line
for darek in "uhli" , "brokolice", "chobotnici":
print("Muj kamarad ", kamarad, "dostane ", darek)
for znak in "python": # prints each character on one line
print(znak)
soucet = 0
for cislo in ran... | true |
35133eca82517616d7c9357a93fa0502f5fc2c92 | Python | jpmcb/interview-problems | /udemyPyInterview/sorting/merge_sort.py | UTF-8 | 647 | 3.859375 | 4 | [] | no_license | def merge(A, l, r):
i = j = k = 0
while i < len(l) and j < len(r):
if l[i] < r[j]:
A[k] = l[i]
i += 1
else:
A[k] = r[j]
j += 1
k += 1
while i < len(l):
A[k] = l[i]
i += 1
k += 1
while j < len(r):
... | true |
9df2891fdc9e694fb6a9fc74108dbdbf29434f74 | Python | boun7yhunt3r/Pythoncodes | /pyimagesearch/10_Image_Descriptors_Algorithms/color_histograms/descriptors/labhistogram.py | UTF-8 | 594 | 3.1875 | 3 | [] | no_license | """ color histograms
- Learn how histograms can be used as Image descriptors.
- Apply K-means clustering to cluster color histogram features.
"""
import cv2
class LabHistogram:
def __int__(self, bins):
self.bins = bins
def describe(self, image, mask = None):
# conver the image to the L*a*b* c... | true |
f7aedaf2939121acb5d7cae1a0f5e94180cbca60 | Python | tulip735/gittest | /python/funTest.py | UTF-8 | 1,448 | 3.3125 | 3 | [] | no_license | # -*- coding:utf-8 -*-
# from time import ctime,sleep
# def tsfunc(func):
# def wrappedFunc():
# print '[%s] %s () called' %(ctime(),func.__name__)
# return func()
# return wrappedFunc
# @tsfunc
# def foo():
# pass
# foo()
# sleep(4)
# for i in range(2):
# sleep(1)
# foo()
#coding:utf-8
def testII(item,x... | true |
f259a3e785fe662f9523c02d6786039e185e0af4 | Python | pingguosanjiantao/Elements-of-Programming-Interviews | /7-Strings/code/7.5-Test Palindromicity.py | UTF-8 | 482 | 4.03125 | 4 | [] | no_license | def isPalindrom(s):
left, right = 0, len(s) - 1
while left < right:
while left < right and not (s[left].isdigit() or s[left].isalpha()):
left += 1
while left < right and not (s[right].isdigit() or s[right].isalpha()):
right -= 1
if left < right and (s[left].lower(... | true |
5dcb4b6ff9be86a19f5bc545c1127c82fc5925d7 | Python | JunhaoWang/keras-gcn | /kegra/utils.py | UTF-8 | 12,439 | 2.671875 | 3 | [
"MIT"
] | permissive | from __future__ import print_function
import scipy.sparse as sp
import numpy as np
from scipy.sparse.linalg.eigen.arpack import eigsh, ArpackNoConvergence
def encode_onehot(labels):
classes = set(labels)
classes_dict = {c: np.identity(len(classes))[i, :] for i, c in enumerate(classes)}
labels_onehot = np... | true |
0003e422129949065cc7ea531ea558333602ffc2 | Python | arjunjanamatti/open_cv_from_freecodecamp | /learn_fast_api_from_documentation/query_parameters.py | UTF-8 | 1,266 | 2.890625 | 3 | [] | no_license | import fastapi
import uvicorn
from typing import Optional
app_api = fastapi.FastAPI()
@app_api.get('/square_result/{item_id}')
def square_number(item_id: int):
return {
f'Square result of {item_id} is': item_id**2
}
@app_api.get('/area_of_rectangle/{item_id_1}/{item_id_2}')
def RectangleArea(item_id_... | true |
d53e0f6bdca5d617dab5912fea0753be89159e57 | Python | L4m4L/LED_Glasses | /scripts/c_generator_display.py | UTF-8 | 2,862 | 2.71875 | 3 | [] | no_license | import cv2
import numpy as np
animations = [{'filename':'animation_heart.png', 'reversed':True, 'name':'display_animation_heart', 'monochrome':True, 'colour':(4,0,0), 'full':False}]
output_filename = 'display.c'
display_width = 10
display_height = 7
display_led_count = 66
display_led_coords = (
(8, 6), (7, 6), (6,... | true |
a40f1f3e7e75edef9777a3dc611352e76cc9faba | Python | ronak007mistry/Python-programs | /coprime.py | UTF-8 | 530 | 4.375 | 4 | [] | no_license | # When gcd of two number is 1, then that two numbers are called Co Prime numbers
from math import gcd
num1 = int(input("Enter number 1: "))
num2 = int(input("Enter number 2: "))
if gcd(num1, num2) == 1:
print(num1, "and", num2, "are Co prime")
else:
print(num1, "and", num2, "are not Co prime")
# Co prime of give... | true |
b34de29ad32317ae1c6b6478895bf95daeaa4b33 | Python | elpwc/anime_crawler | /main.py | UTF-8 | 2,053 | 2.734375 | 3 | [] | no_license | import moegirl
import bangumi_new
import anime_class
import winsound
import win32com.client
import db
import time
def main():
'''
animes = []
a=anime_class.Anime('test', '2012')
a.housou_date = time.strptime("2012-3-9", "%Y-%m-%d")
a.ani_type = 'ova'
animes.append(a)
db.write_all_animes(... | true |
f82d3681b55bec66462d9477297e064af310fe0e | Python | joeltio/mini-maze-django | /mini_maze/test_maze_json.py | UTF-8 | 713 | 2.875 | 3 | [
"MIT"
] | permissive | from django.test import TestCase
from settings import height, width, maze_json_filename
from setup import reset_maze_json
import json
class MazeJSONTest(TestCase):
def setUp(self):
reset_maze_json()
with open(maze_json_filename, "r") as f:
self.maze_json = json.load(f)
def test_... | true |
5a8e35a4a9ea509800e416ec6f4ef806cb79c313 | Python | gmarson/Federal-University-of-Uberlandia | /Comparison of Sorting Algorithms/Trabalho_Final/Codigos/Bubble/BubbleSort.py | UTF-8 | 315 | 2.890625 | 3 | [
"Unlicense"
] | permissive | import numpy as np
@profile
def bubble_sort(a):
""" Implementação do método da bolha """
for i in range(len(a)):
for j in range(len(a)-1-i):
if a[j] > a[j+1]:
t = a[j]
a[j] = a[j+1]
a[j+1] = t
# print(a) O PRINT BUGA O TESTDRIVER
| true |
ede3d08708bfcfe4c387ef86cf71913155544e01 | Python | AlejoObandoGil/API_REST_shop | /API/read.py | UTF-8 | 664 | 3.078125 | 3 | [] | no_license | import urllib.request
import json
def Read():
url = 'http://localhost:5000/api/get/clients'
response = urllib.request.urlopen(url).read()
print("Respuesta: \n")
# print (response)
# print("\n")
listJson = json.loads(response)
# print (listJson)
# print("\n")
print("LISTA DE CLIENT... | true |
f7a55f7bcbbb101978f951b3faa6036d06f2d0f7 | Python | Hrishikesh-3459/leetCode | /prob_905.py | UTF-8 | 283 | 3.03125 | 3 | [] | no_license | class Solution:
def sortArrayByParity(self, A: List[int]) -> List[int]:
e_ans = []
o_ans = []
for i in A:
if (i % 2 == 0):
e_ans.append(i)
else:
o_ans.append(i)
return e_ans + o_ans
| true |
17398f84d631584d544bc38c6fc22a1693d3abde | Python | syncopated/97bottles | /virtualenvs/ninetyseven/src/savoy/contrib/sections/models.py | UTF-8 | 1,160 | 2.65625 | 3 | [] | no_license | import datetime
from django.db import models
from tagging.models import Tag
from savoy.core.tags.utils.tags import get_items_for_tags
class Section(models.Model):
"""
A section aggregates tags in a page or pages on the site.
"""
title = models.CharField(max_length=100, help_text='E... | true |
04f290de51fcb50b5e19eb20002910e4f68925f9 | Python | FrancescoDussin/tpsit_notes_21-22 | /xml06112021.py | UTF-8 | 1,881 | 2.921875 | 3 | [] | no_license | #NOZIONI
#xml -> (generalizzazione di hmtl e sgml) è un linguaggio gerarchico ( + padre - figli e niente nipoti)
#alcuni tag non ammettono all'interno di essi specifici tag.
#serializzazione = prende tutte le zone di memoria che riguardano l'oggetto e trasformarlo in XML
#
#sgml -> utili... | true |
082dc0fd07eb8d4c16004807ea3c64531d13e04c | Python | lixiang2017/leetcode | /leetcode-cn/0016.0_3Sum_Closest.py | UTF-8 | 3,596 | 3.59375 | 4 | [] | no_license | '''
sort + two pointers
T: O(N^2)
S: O(1)
执行用时:200 ms, 在所有 Python3 提交中击败了20.68% 的用户
内存消耗:15.2 MB, 在所有 Python3 提交中击败了9.70% 的用户
通过测试用例:131 / 131
'''
class Solution:
def threeSumClosest(self, nums: List[int], target: int) -> int:
nums.sort()
t = nums[0] + nums[1] + nums[-1]
diff = abs(t - targ... | true |
f8153fc50da7dfc56c1b640b3b33d07adfa20be4 | Python | menzaaa/S4SHackaton | /myapi/resources/auth.py | UTF-8 | 1,372 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env python
import functools
from flask import g, abort
from flask_httpauth import HTTPBasicAuth
from models import User
from db import session
auth = HTTPBasicAuth()
@auth.verify_password
def verify_password(username_or_token, password):
user = User.verify_auth_token(username_or_token)
if not us... | true |
b393db041a75b8e54cd65c0a1de01d704ea67514 | Python | bcabanayan/Cellular-Automata | /src/conways.py | UTF-8 | 8,558 | 3.40625 | 3 | [
"MIT"
] | permissive | import pygame, random
# Define some colors and other constants
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
BLUE = (0 , 0, 255)
GRAY = (25, 25, 25)
WIN_SIZE = 500
# 1. v.1 set up initial states
# cur_states = [0] * 400
# cur_states[10] = 1
# cur_states[30] = 1
# cur_states[50] = 1
# 1. v.2 fill cur_states with random... | true |
ff7c533be809b13b11db8c67526b15213de2990e | Python | wangguanfu/Python_view | /代码/数据结构与算法/二叉树常考题.py | UTF-8 | 1,854 | 3.90625 | 4 | [] | no_license | """
层序遍历二叉树:
广度优先:
判断根 存在 和下一个节点存在 就添加进去
-层层 放
深度优先 : 用level 来查找出每一个值 然后填充进去
切面放进去
"""
# 广度优先
import collections
class Solution:
def levelOrder(self, root):
if not root: return []
res = []
queue = collections.deque()
... | true |
61bf78c03717a050e8167abaab46e0575df8c8ae | Python | sudbasnet/Leetcode-Practice | /minimumCostToHireKWorkers.py | UTF-8 | 4,398 | 3.546875 | 4 | [] | no_license | import heapq
class Solution:
def mincostToHireWorkers(self, quality: [int], wage: [int], K: int) -> float:
'''
Best Explanation:
https://leetcode.com/problems/minimum-cost-to-hire-k-workers/discuss/141768/Detailed-explanation-O(NlogN)
Let's read description first and figure out the... | true |
3545377d918c820f2cbd14096b1eb330f57070b3 | Python | ulrichji/HeightmapTileMaker | /heightmaptilemaker/mesh/mesh_clipper.py | UTF-8 | 2,240 | 2.703125 | 3 | [
"MIT"
] | permissive | from . import mesh
from . import clip_polygon
from progress.null_callback import NullCallback
from progress.progress import Progress
import numpy as np
from math import sqrt
import time
def getHexagon():
hexagon_mesh = mesh.Mesh()
vertices = [(0, 0.5, 0),
(1/4, 0.5 - (sqrt(3)/4), 0),
... | true |
40da59de8006ae6fb42f7b83c71acc465c7c0790 | Python | ducnx1997/gem-training | /simple-blob.py | UTF-8 | 517 | 2.640625 | 3 | [] | no_license | import cv2
import numpy as np
img = cv2.imread("blob.jpg", cv2.IMREAD_GRAYSCALE)
detector = cv2.SimpleBlobDetector_create()
keypoints = detector.detect(img)
# Draw detected blobs as red circles.
# cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS ensures the size of the circle corresponds to the size of blob
img_with_keyp... | true |
d8e33574c1de72a2e501dd4f93132b3e723c8c07 | Python | cahya-wirawan/language-modeling-original | /utils.py | UTF-8 | 2,365 | 2.703125 | 3 | [
"MIT"
] | permissive | import collections
import json
import os
import numpy as np
import tensorflow as tf
from tensorflow.keras.utils import to_categorical
data_path = os.path.join(os.getcwd(), 'data')
def read_words(filename):
with tf.gfile.GFile(filename, 'r') as f:
return f.read().replace('\n', '<eos>').split()
def build_voca... | true |
d9f95d16d1c5331e30e43ef517accc58953b34ec | Python | anisha98/csci5561-cv-hw4 | /main_functions.py | UTF-8 | 7,537 | 2.515625 | 3 | [
"MIT"
] | permissive | import scipy.io as sio
import matplotlib.pyplot as plt
import numpy as np
from cnn import get_mini_batch, fc, relu, conv, conv_backward, pool2x2, pool2x2_backward, flattening
from cnn import train_slp_linear, train_slp, train_mlp, train_cnn
def main_slp_linear():
mnist_train = sio.loadmat('./mnist_train.mat')
... | true |
7b220c5c19d9076ae265c0b9de14aacf40551149 | Python | Vasilic-Maxim/LeetCode-Problems | /problems/849. Maximize Distance to Closest Person/2 - Two Pointers.py | UTF-8 | 408 | 2.953125 | 3 | [] | no_license | from typing import List
class Solution:
def maxDistToClosest(self, seats: List[int]) -> int:
fast = 0
while seats[fast] == 0:
fast += 1
slow = result = fast
for fast in range(fast + 1, len(seats)):
if seats[fast] == 1:
result = max(result, (... | true |
831edd1cd42e451d6ce20b56e82e38190d4f6301 | Python | rubal501/PruebasPython | /PruebaDicto.py | UTF-8 | 216 | 2.71875 | 3 | [] | no_license | import r
postre = ["pastel","merengue","helado"]
sabor =["vainilla","chocolate","menta"]
menu ={}
for i in range(len(postre)):
menu[postre[i]] = sabor[i]
x = str(raw_input("de que tipo de pastel quiere"))
if x != | true |
bed23cb787f91ec723efaafc50135cb55e152f36 | Python | echolimauw/DjangoViaPython | /log_and_reg/apps/login/models.py | UTF-8 | 1,548 | 2.578125 | 3 | [] | no_license | from django.db import models
import re
class UserManager(models.Manager):
def reg_validator(self, postData):
email_regex = r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)"
fn = postData['first_name']
ln = postData['last_name']
em = postData['email']
pw = postData['passw... | true |
45de582b1f5ae6a492059abce217fe0ab0cee2a5 | Python | YUNKWANGYOU/Quiz | /BF/1476.py | UTF-8 | 248 | 2.9375 | 3 | [] | no_license | import sys
e,s,m = map(int,sys.stdin.readline().split())
while 1 :
if e == s and s == m :
print(e)
break
if min(e,s,m) == e :
e+=15
elif min(e,s,m) == s :
s+=28
elif min(e,s,m) == m :
m+=19
| true |
22f3a16341421fc0a477b508faf6c2757aa5d8c8 | Python | alreadytaikeune/euler | /problem33.py | UTF-8 | 901 | 3.453125 | 3 | [] | no_license | def gcd(a, b):
if a == b:
return a
if a < b:
return gcd(a, b-a)
else:
return gcd(a-b, b)
def reduce(a, b):
d = gcd(a, b)
return a/d, b/d
def check(i, j, a, b, frac):
if reduce(i, j) == reduce(a, b):
x, y = reduce(a, b)
frac = frac[0]*x, frac[1]*y
ret... | true |
2dce7647ee450c33417f30cd85bf54e2a2af72f5 | Python | Byczax/SDIZO-Project | /SDiZO-Projekt_2/extra/graphs.py | UTF-8 | 6,408 | 2.90625 | 3 | [] | no_license | import matplotlib.pyplot as plt
import os
import statistics
results = []
def read_text_file(filepath):
with open(filepath, 'r') as txt_file:
counter = 0
number = 1
graph_list = []
graph_matrix = []
round_values = []
for line in txt_file:
counter += 1
... | true |
8727512ce2639a591b1a89b26821f1a294f42bb0 | Python | jamol1741/class_schedule | /db_conn.py | UTF-8 | 9,510 | 2.59375 | 3 | [] | no_license | import sqlite3
class DBHelper:
def __init__(self, dbname="db/schedule.db"):
self.dbname = dbname
self.conn = sqlite3.connect(dbname, check_same_thread=False)
def get_items(self, user_id, day_id, part):
"""
:param user_id: User id
:param day_id: Day id
:param pa... | true |
727fbed4cf465ee9c7928be9bdda16ec745c44ab | Python | DChandlerP/algos_python | /smallestNonConstructibleValue.py | UTF-8 | 383 | 3.109375 | 3 | [] | no_license | # https://www.geeksforgeeks.org/find-smallest-value-represented-sum-subset-given-array/
# https://lei-d.gitbook.io/leetcode/math/smallest-non-constructible-value
def findSmallest(array):
# linear search
max_constructible = 0
for a in sorted(array):
if a > max_constructible + 1:
break
... | true |
1cb046d5e42816e18165e9156c31b5f8b4c8bcc4 | Python | EoJin-Kim/CodingTest | /구현/06ColumnsAndBeamsBuild.py | UTF-8 | 1,047 | 3.15625 | 3 | [] | no_license |
def possible(answer):
for x,y,stuff in answer:
# 0이면 기둥
if stuff ==0:
if y==0 or[x-1,y,1] in answer or [x,y,1] in answer or [x,y-1,0] in answer:
continue
else:
return False
# 1이면 보
elif stuff ==1:
if [x,y-1,0] in ... | true |
866e973052d793e0742950f6a7361ffaf051c7d5 | Python | xiatian0918/auto_scripts | /学习脚本/云计算python学习/Python语言基础学习/函数.py | UTF-8 | 1,221 | 3.875 | 4 | [] | no_license | #!/usr/bin/env python
#-*- coding:utf-8 -*-
# author: xiatian
# 创建函数
def say_hi():
print("hi!")
say_hi()
# 创建有参数的函数
def prt_sum_two(a,b):
c = a + b
print(c)
prt_sum_two(3,6)
# 传入字符串到函数
def hello_some(str):
print("hello %s !" %str)
hello_some("China")
# 有返回值的函数
def repeat_str(str,times):
repea... | true |
ba8438b300a918c9795f226133f821c82a1bdf5c | Python | chrislarabee/kivy-studio | /kivy-studio/widgets/_misc.py | UTF-8 | 510 | 2.96875 | 3 | [] | no_license | from kivy.uix.label import Label
class WrapLabel(Label):
def __init__(self, **kwargs):
"""
Version of kivy's Label with built in wrapping. Whatever widget
is designated WrapLabel's parent will define the boundaries that
any text in WrapLabel will try to fit.
Args:
... | true |
b64a5dd6e87b7c5624b7306ed814b57c0908a686 | Python | Sho1981/NLP-with-Python-chapter3 | /ex26.py | UTF-8 | 189 | 2.78125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import nltk
import re
import random
def aehh500():
return ''.join([random.choice("aehh ") for i in range(500)])
raw = aehh500()
print(' '.join(raw.split()))
| true |
2beb5a5e479d96dac197fda9c70b24150574dd49 | Python | kedenk/tainteddatatypes | /test/astrewrite/subject/test.py | UTF-8 | 272 | 2.890625 | 3 | [] | no_license | from datatypes.taintedint import tint
from taintedstr import tstr
def func(t: str):
print((str(t) + ' Hello'))
d = {3: 'Hello'}
i = 4
func('No')
b = tint(4)
b.to_bytes(2, 'big')
tint(2).in_(d.keys())
i = int(5)
tint(i).in_(d.keys())
s = tstr('hello')
s.in_(d.keys()) | true |
70262b0e6451e3d4a0797193703181c7b97bb284 | Python | kayfilipp/usd_data_sci | /502_data mining/module3/naive_bayes.py | UTF-8 | 1,846 | 3.40625 | 3 | [] | no_license | #NAIVE BAYES IN PYTHON
import pandas as pd
import numpy as np
from sklearn.naive_bayes import MultinomialNB
import statsmodels.tools.tools as stattools
#get data
wine_tr = pd.read_csv("C:/.../wine_flag_training.csv")
wine_test = pd.read_csv("C:/.../wine_flag_test.csv")
# get tabulation for probabilities
t1 = pd.c... | true |
4d27007ee8d402a6eb0cc157169a92acbafe5359 | Python | HadarakDev/Tower-Defense-Pygame | /Projectile.py | UTF-8 | 1,868 | 3.359375 | 3 | [] | no_license | import pygame
from Collide import *
class Projectile:
def __init__(self, x, y, target, damage):
self.pos_x = x
self.pos_y = y
self.target = target
self.damage = damage
self.hitbox = Collide(self.pos_x, self.pos_y, 40, 40)
self.hit_status = False
dest = (sel... | true |
c101078f5e054767fc801f7cf4773998c635dc5a | Python | manhar/misc | /kafkaAnalytics/email_check.py | UTF-8 | 1,289 | 3.265625 | 3 | [] | no_license | #!/usr/bin/python
def fun(s):
# return True if s is a valid email, else return False
valid_username = "abcdefghijklmnopqrstuvwxyz1234567890_-"
valid_website = "abcdefghijklmnopqrstuvwxyz1234567890"
if s.count("@") != 1 :
return False
else:
username, trailer = s.split("@")
... | true |
8e7e279048af6484287dc494a5ee242a24789b0e | Python | GlennTng/basic-dictionary-app | /fp_gui.py | UTF-8 | 9,997 | 3.0625 | 3 | [] | no_license | from bs4 import BeautifulSoup
import requests
import json
import tkinter as tk
from PIL import Image, ImageTk
import random
WEBSITE = "https://www.merriam-webster.com/dictionary/"
filename = "learnt_words.txt"
global score
score = 0
# check if file exists, create if does not
with open(filename, 'a+') as ... | true |
180426f91c881b84a24f2b2989f742dfaa3ebb90 | Python | Dominik1123/advent-of-code-2017 | /11/solve.py | UTF-8 | 905 | 3.328125 | 3 | [] | no_license | import json
import numpy as np
with open('input.txt') as fp:
path = fp.readline().strip()
# Directions are nw-se (index 0), n-s (index 1) and sw-ne (index 2).
vectors = np.asarray(json.loads(
'[' + path.replace('nw', '[1,0,0]').replace('se', '[-1,0,0]')
.replace('ne', '[0,0,1]').replace('sw', '... | true |
0204eb01a9f525be60e4780c905c1988819782aa | Python | JoelRoxell/data-science-cheat-sheet-python | /precentiles.py | UTF-8 | 329 | 3.078125 | 3 | [] | no_license | # %%
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as sp
vals = np.random.normal(0, 0.5, 10000)
plt.grid(zorder=0)
plt.hist(vals, 50, edgecolor='b', zorder=2)
plt.show()
# %%
np.percentile(vals, 50)
# %%
np.percentile(vals, 90)
# %%
np.percentile(vals, 99)
# %%
sp.skew(vals)
# %%
sp.kurtos... | true |
4b0cec99efb16e5ed2010d107fed5d52c5dbd297 | Python | damienrochat/BDA-lab01 | /ex03/count_temperature_reduce.py | UTF-8 | 886 | 3.03125 | 3 | [] | no_license | #!/usr/bin/env python
#
# max_temperature_reduce.py - Count temperature from NCDC Global
# Hourly Data - Reducer part
import sys
last_key = None
count = 0
# loop through the input, line by line
for line in sys.stdin:
# each line contains a key and a value separated by a tab character
(... | true |
a353a6fcc629b506792755329caa0f772c064931 | Python | dannysongyd/dining-bot | /LFs/LF2.py | UTF-8 | 5,961 | 2.8125 | 3 | [] | no_license | import boto3
import json
from elasticsearch import Elasticsearch, RequestsHttpConnection
from requests_aws4auth import AWS4Auth
from botocore.exceptions import ClientError
def get_info_from_sqs():
# Create SQS client
sqs = boto3.client('sqs')
queue_url = 'https://sqs.us-east-1.amazonaws.com/715339036598/... | true |
fc56b1b156661613178742aa7e228b2106b34c8c | Python | btknzn/Uno-Card-Game- | /cnn.py | UTF-8 | 5,366 | 2.71875 | 3 | [] | no_license | import numpy
import pandas
import glob
import matplotlib.pylab as plt
import matplotlib.cm as cm
import warnings
warnings.filterwarnings('ignore')
from keras.models import Sequential, Model
from keras.optimizers import SGD, RMSprop, Adam, Nadam
from keras.callbacks import ModelCheckpoint
from keras.pr... | true |
7f3ec7c739715c693b8ed99ed38eff1350824673 | Python | Jsimmons--dev/python-cli-template | /cli.py | UTF-8 | 998 | 3.28125 | 3 | [] | no_license | import argparse
import sys
class CLI(object):
def __init__(self):
parser = argparse.ArgumentParser(
description="cli tool built using python",
usage='''python -m cli <command> [<args>]
subcommand
''')
parser.add_argument('command', help='sub command to run')
... | true |
5efa1bb2e71c99601967d9efb4f1364146ec576f | Python | leor/python-algo | /Lesson4/Task1/code.py | UTF-8 | 2,275 | 3.984375 | 4 | [] | no_license | '''
В диапазоне натуральных чисел от 2 до 99 определить, сколько из них кратны любому из чисел в диапазоне от 2 до 9.
'''
from timeit import timeit
from sys import setrecursionlimit
# Реализация на циклах
def with_loop():
for i in range(2, 9):
count = 0
for j in range(2, 999):
if j % ... | true |
77a6c20ef9d9426409e9b0455dcb8fd13ba61363 | Python | devsetup/dsbuild_commands | /dsbuild-template | UTF-8 | 1,726 | 2.71875 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env python2.7
#
# dsbuild-template
import argparse
import jinja2
import os
import subprocess
import sys
import yaml
def chmod_file(filename, value):
retval = subprocess.call(["chmod", value, filename])
if retval != 0:
raise RuntimeError("cannot chmod " + filename)
def chown_file(filename, value):
ret... | true |
34ad11dd312f8080f71666126a8751a9897cc2b1 | Python | ogmobot/code-scraps | /py/shoddylisp.py | UTF-8 | 16,792 | 3.078125 | 3 | [] | no_license | import random
DEBUG = False
class Symbol:
def __init__(self, name):
self.name = name
def __eq__(self, other):
if hasattr(other, "name"):
return self.name == other.name
else:
return False
def __hash__(self):
return hash(self.name)
def __repr__(self)... | true |
e9bdefe229f05268aa8f63254f7b65efef6a42c4 | Python | sbtries/Class_Polar_Bear | /2 Python/solutions/password_generator.py | UTF-8 | 945 | 4.46875 | 4 | [] | no_license | """
Let's generate a password of length n using a while loop and random.choice,
this will be a string of random characters, e.g. a62xB95. Allow the user to
enter the value of n, remember to convert its type to an int, as input returns a string.
Hint: random.choice can be used to pick a character out of a string, as we... | true |
f2ca6f3befc6d0c524eaabcb34a3561aaf2f1520 | Python | tripl3a/blockchain | /blockchain.py | UTF-8 | 5,562 | 3.15625 | 3 | [] | no_license | import hashlib
import json
from time import time
from django.core.serializers.json import DjangoJSONEncoder
from functools import reduce
class LazyEncoder(DjangoJSONEncoder):
"""
needed for JSON serialization of my custom classes
"""
def default(self, obj):
if isinstance(obj, Block):
... | true |
0c136a683a5a16539ecb74e9121591a2e0f10cd5 | Python | Aasthaengg/IBMdataset | /Python_codes/p03645/s540624396.py | UTF-8 | 262 | 3.078125 | 3 | [] | no_license | n,m = map(int,input().split())
start_set = set()
goal_set = set()
for i in range(m):
s,g = map(int,input().split())
if s == 1:
start_set.add(g)
if g == n:
goal_set.add(s)
ans = "POSSIBLE" if (start_set & goal_set) else "IMPOSSIBLE"
print(ans) | true |
81262a006a04de5198230f2bb0ec37140c5c105c | Python | WGC575/python_learning | /tutorial/01_IO_syntax.py | UTF-8 | 636 | 4.125 | 4 | [] | no_license | #python use indentation to indicate a code block
class my_class(object):
print("Hello World!")
#pass is used to keep integrity of code, doing nothing.
#Its usage is like "continue" in C++ but it could also be applied to classes and functions.
pass
#print is used to output variables where '+' co... | true |
4d28a15c3a3a96b4795679dac3dbfb817e08aa8f | Python | ecajandig/robotFramework | /ROBOT/InternalLibraries/TestCaseStatus.py | UTF-8 | 503 | 3.015625 | 3 | [] | no_license |
from xlrd import open_workbook
def Excel(filepath,Sheetname,uniq):
wrkbook = open_workbook(filepath)
sheet = wrkbook.sheet_by_name(Sheetname)
rows = sheet.nrows
cols = sheet.ncols
for i in range(0,rows):
for j in range(0,cols):
value1 = sheet.cell_value(i,j)
... | true |
c070ed3cde3bdf2632eb05e507eb45b6100f04a1 | Python | ericbrandwein/CodeforcesAPI | /codeforces/api/json_objects/problem_statistics.py | UTF-8 | 2,497 | 3.40625 | 3 | [
"MIT"
] | permissive | """
This module contains classes for representing ProblemStatistics object
For further information visit http://codeforces.com/api/help/objects#ProblemStatistics
"""
from . import BaseJsonObject
__all__ = ['ProblemStatistics']
class ProblemStatistics(BaseJsonObject):
"""
Represents a statistic data about ... | true |
21cd9c4599d76cbda3e9a47dcb81fb86fa6ce2bc | Python | adusa1019/atcoder | /ABC179/B.py | UTF-8 | 287 | 2.859375 | 3 | [] | no_license | def solve(string):
n, *d = map(int, string.split())
z = [d1 == d2 for d1, d2 in zip(*[iter(d)] * 2)]
return "Yes" if any(z1 and z2 and z3 for z1, z2, z3 in zip(z, z[1:], z[2:])) else "No"
if __name__ == '__main__':
import sys
print(solve(sys.stdin.read().strip()))
| true |
d5557d9167464bcda6deeb17400f606874a513fd | Python | mleijon/AoC2020 | /day2/day2b.py | UTF-8 | 460 | 3.25 | 3 | [] | no_license | with open('p2_input.txt') as fi:
input_data = fi.read().splitlines()
correct_count = 0
for item in input_data:
pos_1 = int(item.split()[0].split('-')[0])
pos_2 = int(item.split()[0].split('-')[1])
check_letter = item.split()[1][0]
passwd = item.split()[2]
if (passwd[p... | true |
ae44abea741b01dce759590bf7f15de8340a5e93 | Python | Krivokulskiy/Algoritms-BG | /Less 1/1-9.py | UTF-8 | 350 | 3.421875 | 3 | [] | no_license | first = int(input('Enter a first num: '))
second = int(input('Enter a second num: '))
third = int(input('Enter a third num: '))
if first < second < third or third < second < first:
print('midscore is :', second)
elif first < third < second or second < third < first:
print('midscore is :', third)
else:
... | true |
4483056039414fd13344682e9d6c6cc02caf0094 | Python | mrbug998877/algorithm014-algorithm014 | /Week_04/102.二叉树的层序遍历-第二遍.py | UTF-8 | 930 | 3.328125 | 3 | [] | no_license | #
# @lc app=leetcode.cn id=102 lang=python3
#
# [102] 二叉树的层序遍历
#
# @lc code=start
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def levelOrder(self, root: TreeNode) -> List[List[int]... | true |