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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
72d6f03c790f32c2b0e5dd8c5338673619743e71 | Python | bmhayduk/CMPUT404-assignment-websockets | /sockets.py | UTF-8 | 4,756 | 2.5625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause"
] | permissive | #!/usr/bin/env python
# coding: utf-8
# Copyright (c) 2013-2014 Abram Hindle, Brandon Hayduk
# Also created referencing http://github.com/abramhindle/websocketsexamples/blob/master
# /chat.py
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Lice... | true |
cfb64641cba1ec84470a3e5f454ca3012b526b4b | Python | alexfatalix/TicTacToe | /grid.py | UTF-8 | 514 | 3.359375 | 3 | [] | no_license | import pygame as pg
WHITE = (200, 200, 200)
BLACK = (0, 0, 0)
class Grid:
def __init__(self):
# simple lines
self.gridLines = [((1, 200), (600, 200)),
((1, 400), (600, 400)),
((200, 1), (200, 600)),
((400, 1), (400, ... | true |
18ba1b269d7b17695cd4610e47ae0c17dd0eaafa | Python | Reo-LEI/SICP-Python | /2.73-2.76 imaginary number.py | UTF-8 | 2,070 | 2.703125 | 3 | [] | no_license | from orderedPair import *
from dataOriented import *
from math import sin, cos, atan
# rectangular imaginary number system
def real_part(z):
return car(z)
def imag_part(z):
return cdr(z)
def make_from_real_imag(x, y):
return cons(x, y)
def magnitude(z):
return ((real_part(z)**2) + (imag_part(z)*... | true |
8479e87ea429ca1c97179885e68bb7dc8a97720a | Python | qinheqing/PythonNote | /python/SET.py | UTF-8 | 2,482 | 4.5 | 4 | [] | no_license | # Python中的Set
# Python的作用是建立一组key和一组value的映射关系,dict的key是不能重复的,有时候我们需要的是dict的key不重复的特性
# set就是这样的集合:set中的元素没有重复,而且是无序的(这点和Java不一样,Java中的set是有序元素)
# 创建set的方式:s = set(['A','B','c'])
myset = set(['a','b','c','d'])
# 查看set的元素,打印出来的set元素是无序的
print myset
# 由于set是无序的,当我们传入重复的元素时候:
myset1 = set([1,2,2,3,4,5,6,6,7,7])
print m... | true |
73a6de5e9f1a14bed2248af0a1f02ab4ac9d17a9 | Python | rodrigocruz13/holbertonschool-interview | /0x00-lockboxes/0-lockboxes.py | UTF-8 | 2,517 | 3.671875 | 4 | [] | no_license | #!/usr/bin/python3
"""
Module used to add two arrays
"""
def canUnlockAll(boxes):
"""
Method that determines if all the boxes can be opened.
Args:
boxes (lst): List of all the boxes.
Returns:
True (bool): for success,
False (bool): In case of failure.
"""
if (type(box... | true |
ba796d01741026afeb16c642a0a83dc750cc007d | Python | chr457/Python-Notes-Projects | /tictactoe.py | UTF-8 | 3,858 | 4.09375 | 4 | [] | no_license | import random
def displayBoard(board):
print(board[7] + ' |' + board[8] + ' |' + board[9])
print('--------')
print(board[4] + ' |' + board[5] + ' |' + board[6])
print('--------')
print(board[1] + ' |' + board[2] + ' |' + board[3])
def player_input():
marker = ''
while marker != 'X' and ma... | true |
15d118580efc33696439209fe7ca02ce57c2d239 | Python | yanami85/PCR_recipe | /pcr_GUI.py | UTF-8 | 5,699 | 2.65625 | 3 | [] | no_license | # coding: utf-8
# PCR_recipe.pyと同じディレクトリにこのファイルを置く
from main import pcr_recipe
import PySimpleGUI as sg
import pandas as pd
import datetime
import os
import shutil
from bs4 import BeautifulSoup
import webbrowser
def bind_html(html_path_list: list) -> str:
'''複数のhtmlを順番に結合する
Args:
html_path_list ([str... | true |
f644291160f460faa368dfa75d162fac9a17898d | Python | pospisil98/CTUcodes | /SEM1/RPH/SPAM_final/utils.py | UTF-8 | 1,046 | 3.390625 | 3 | [] | no_license | ''' Module with some useful functions for spam filter '''
def read_classification_from_file(path_to_file):
'''
Reads clasification from file and returns dict of it
:param path_to_file: path to file with some clasification
:return: Dict --> filename : classification tag
'''
dct = {}
with o... | true |
4f357e289088484ff39391582bb3d4284aa8d72f | Python | tooploox/taxonify_backend | /aquascope/tests/aquascope/util/test_dict_utils.py | UTF-8 | 4,855 | 2.890625 | 3 | [
"MIT"
] | permissive | import unittest
from aquascope.util.taxonomy_dictionary_utils import add
class TestAddListToDictionary(unittest.TestCase):
def test_add_normal_list_to_empty(self):
dictionary = {}
elements = ["1", "2", "3"]
expected_dict = {
"1": {
"2": {
"3... | true |
9ea20bad77f256e9e811f153238398b877a6be73 | Python | DonalChilde/aa_pbs_exporter_old | /src/aa_pbs_exporter/app_lib/chunk_parser.py | UTF-8 | 3,513 | 3.078125 | 3 | [
"MIT"
] | permissive | from collections import deque
from typing import Any, Deque, Iterable, Optional, Sequence
class Chunk:
def __init__(self, key, text_chunk: str) -> None:
# can make this an object with page number, line number
self.key = key
self.text_chunk = text_chunk
class ParseContext:
def __init_... | true |
f39dcd9e0312f0269252adf16d05d00bcfa8a7f0 | Python | cwenck/ctf-crypto | /analysis/EnglishAnalysis.py | UTF-8 | 1,468 | 3.71875 | 4 | [] | no_license | #!/usr/bin/env python3
def matchesTrigram(text, trigram):
if len(text) != 3 or len(trigram) != 3:
return False
trigram = trigram.lower()
text = text.lower()
remainingSpaces = 0
index = 0
for c in text:
if c == ' ' and remainingSpaces > 0:
remainingSpaces -= 1;
elif c != trigram[index]:
return False... | true |
9d11b628b0b8325103530ad9c6833499de3c5a3e | Python | SerhiiDior/EventExpress_v1 | /Base/base.py | UTF-8 | 1,979 | 2.875 | 3 | [] | no_license | from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException, TimeoutException
class BaseSetup:
def __init__(self,driver):
self.driver = driver
def find_element(self, *locators):... | true |
a1f2aae6275b2d6b25a78a85f14c953de7ddc18b | Python | Vanojx1/AdventOfCode2019 | /dijkstra.py | UTF-8 | 2,133 | 2.9375 | 3 | [] | no_license | import collections
import heapq
def dijkstra(grid):
R, C = len(grid), len(grid[0])
location = {v: (r, c)
for r, row in enumerate(grid)
for c, v in enumerate(row)
if v not in '.#'}
keys = tuple()
for k, (r, c) in list(location.items()):
if '@' in... | true |
5a24ed56a3801023a3ca9dc8b364cac7297412e7 | Python | Badr-MOUFAD/algebra-matrix-polynomial | /Polynomial.py | UTF-8 | 2,596 | 3.625 | 4 | [] | no_license |
class Polynomial:
def __init__(self, coefficients):
self.__coefficients = coefficients
# removing eventual zeros from the end of the list ([1, 2, 0, 0] == [1, 2])
j = len(self.__coefficients) - 1
while self.__coefficients[j] == 0:
if j == 0: # case of a null polynomial ... | true |
45f492a61185eb5bfee7905d55d5f35c4481f03b | Python | yashodhank/invana-bot | /invana_bot/utils/selectors.py | UTF-8 | 1,597 | 2.859375 | 3 | [
"MIT"
] | permissive | def clean_data(elems=None, selector=None):
if selector.get('multiple'):
data_cleaned = []
data = elems.extract()
for i, datum in enumerate(data):
if datum:
data_cleaned.append(datum.strip())
return data_cleaned
else:
data = elems.extract_first(... | true |
b20b4d5357734a5a15a005e0bf92917a4cb3222b | Python | keskt/user-signup | /main.py | UTF-8 | 3,387 | 2.765625 | 3 | [] | no_license | from flask import Flask, request, redirect
import cgi
import os
import jinja2
template_dir = os.path.join(os.path.dirname(__file__), 'templates')
jinja_env = jinja2.Environment(loader = jinja2.FileSystemLoader(template_dir), autoescape=True)
app = Flask(__name__)
app.config['DEBUG'] = True
@app.route("/")... | true |
42b5e4aaf500a62082cd344afc55390aebbe388c | Python | noparkinghere/train_py | /35K/第一期活动/task/task_8.py | UTF-8 | 768 | 3.375 | 3 | [] | no_license | """
Created on 2020/5/27 11:52
————————————————————————————————————————————————————————————————————
@File Name : task_8.py
@Author : Frank
@Description : 按照你喜欢的格式来打印九九乘法表。
————————————————————————————————————————————————————————————————————
@Change Activity:
"""
p... | true |
2c63acacbee2a3be682d25ca508492d7bbe57dc1 | Python | jweinst1/Paison | /paison/Containers/ContainerMethods.py | UTF-8 | 974 | 3.578125 | 4 | [] | no_license | #file that contains different sets of string builders to produce instance methods on containers, like lists and tuples.
class ListMethodGenerator:
@staticmethod
def reverselist(self, name):
return "{name}.reverse()".format(name=name)
@staticmethod
def sortlist(self, name):
return "{n... | true |
31357e6308f0a897ac0e8107d2a9e2dfee772bdb | Python | GhostInTheSystem/HeroSystemProject | /CaptainKharok.py | UTF-8 | 137 | 2.59375 | 3 | [] | no_license | from Classes import *
captainKharok = Character("Kharok")
print (captainKharok.name)
captainKharok.sex = "Male"
captainKharok.height = | true |
eebd3ccf2ada1b7acf42ca72bd02deb9fa46238d | Python | Anvesh8263/python-lab-30 | /alpha_string_triangle.py | UTF-8 | 136 | 3.859375 | 4 | [] | no_license | st = input('Enter the string to be pattern in triangle ')
for i in range(len(st)):
print(f'{{0:>{len(st)}}}'.format(st[:i+1]))
| true |
02a81b5df811c2c040ec042597ab41deeddbb2ab | Python | omostic21/personal-dev-repo | /rockpaperscissors.py | UTF-8 | 1,097 | 3.984375 | 4 | [] | no_license | #This is a code for Rock Paper Scissors
print("Welcome to Rock paper Scissors!")
option1 = int(input("Please press 1 for instructions, 2 to play and 3 to exit"))
if option1 == 1:
print("Fuck off, Instructions will come later, and if you don't know how to play this game..then wtf")
elif option1 == 2:
print("1 is... | true |
d434308b755861ffa9db0ac078033d6e18593842 | Python | betoesquivel/Imp | /semantics.py | UTF-8 | 9,430 | 2.671875 | 3 | [] | no_license | #!env/bin/python
import pprint
pp = pprint.PrettyPrinter()
errors = {
'PARAMETER_LENGTH_MISMATCH': 'Function {0} expects {1} parameters and received {2} parameters at line: {3} ',
'REPEATED_DECLARATION': 'Repeated declaration of variable {0} found at line: {1} ',
'REPEATED_FUNC_DECLARATION': '... | true |
62c1350f2bcca5a51e458862f396deffdafd1170 | Python | pasandrei/MIRPR-pedestrian-and-vehicle-detection-SSDLite | /train/backbone_freezer.py | UTF-8 | 1,325 | 2.859375 | 3 | [
"MIT"
] | permissive |
class Backbone_Freezer():
"""
Handles the freezing/unfreezing of the backbone of the model dynamically during training
works for MobileNetV2
"""
def __init__(self, params, freeze_idx=19):
self.params = params
self.freeze_idx = freeze_idx
def freeze_backbone(self, model):
... | true |
5fe1d757f693d4aed3daf10f7e3829c29393eb81 | Python | PDXChloe/PDXcodeguild | /Python/lab24_bogo.py | UTF-8 | 1,802 | 4.75 | 5 | [] | no_license | # Lab 24: Bogo Sort
#
# Bogo sort is one of the least efficient sorting algorithms imaginable!
# It works by generating random arrangements of a list, checking if the list is
# sorted, and if it is, return it. For a list of 200 numbers,
# there are 200! = 7.88*10^374 possible combinations, only one of them is the sorte... | true |
afc184a43355cc84545585934aa80f96c06eb25f | Python | doughepi/opentracing-decorator | /tests/test_tracing_map_parameters.py | UTF-8 | 1,777 | 2.75 | 3 | [
"MIT"
] | permissive | import unittest
from typing import Dict
from opentracing.mocktracer import MockTracer
from opentracing_decorator.tracing import Tracing
class TestTracing(unittest.TestCase):
def setUp(self):
self.tracer = MockTracer()
self.tracing = Tracing(self.tracer)
def test_simple_parameters(self):
... | true |
2cea03ac7f3b4330cabb9ebc8d6a4907d684e613 | Python | suecharo/CPFF | /script/yaml_gene_count_getter.py | UTF-8 | 649 | 2.9375 | 3 | [
"MIT"
] | permissive | #!/bin/env python3
# coding: utf-8
import yaml
import os
import sys
def main():
file_path = sys.argv[1]
with open(file_path, "r") as f:
data = yaml.load(f)
count_1 = len(data["GENE"]["1ST"])
count_2 = len(data["GENE"]["2ND"])
count_all = count_1 + count_2
file_abs = os.path.abspath(fil... | true |
4fdcd0c21c0b97f771e1fe7b05e764c74f30653d | Python | Jaiswal-ruhil/python3-SmartSchema | /SmartSchema/SmartSchema.py | UTF-8 | 2,000 | 2.515625 | 3 | [
"MIT"
] | permissive | from jsonschema import validate, exceptions
# import _types
log = lambda *_: _
class SmartSchema(object):
def __init__(self, defination):
self.defination = defination
self._types = {
"object": self.resolveobject,
"array": self.resolvearray,
"number": self.reso... | true |
3dcb330ba17aa3d064e07878bce7a6900a40d20a | Python | 1325052669/leetcode | /src/JiuZhangSuanFa/TwoPoints/533 Two Sum - Closest to target.py | UTF-8 | 939 | 4.125 | 4 | [] | no_license | # [LintCode] 533 Two Sum - Closest to target 解题报告
# Description
# Given an array nums of n integers, find two integers in nums such that the sum is closest to a given number, target.
#
# Return the difference between the sum of the two integers and the target.
#
#
#
# Example
# Given array nums = [-1, 2, 1, -4], and t... | true |
4c4708f2f2b31a0f9095f2cc220a02f28baa7f7c | Python | Arvini92/python3_essentials | /operators.py | UTF-8 | 277 | 3.203125 | 3 | [] | no_license | def b(n): print('{:08b}'.format(n))
def main():
x, y = 0x55, 0xaa
b(x)
b(y)
b(x | y)
b(x & y)
b(x ^ y)
b(x ^ 0)
b(x ^ 0xff)
b(x << 4)
b(x >> 4)
b(~x)
print(x is not y)
print(True and False)
print(True or False)
if __name__ == "__main__": main() | true |
e0f9daccc2d758fc4de2706c38d7203509df8600 | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_1/367.py | UTF-8 | 1,095 | 2.703125 | 3 | [] | no_license | #!/usr/bin/env python
import sys
# return number_of_queries, number_of_searchengines
def find_all_searchengines(queries, searchengines):
found=set()
n=0
while n<len(queries) and len(found)<len(searchengines):
found.add(queries[n])
n+=1
return n, len(found)
filename=sys.argv[1]
inputfile=file(filena... | true |
e7883504922db26fc1b82068117cf0ed5af7880e | Python | dongyifeng/algorithm | /python/interview/2.6/quick_sort.py | UTF-8 | 369 | 3.875 | 4 | [] | no_license | #coding:utf-8
# 类似快排的做法,两个指针:i,j 同时从左向右
def swap(data,i,j):
tmp = data[i]
data[i] = data[j]
data[j] = tmp
def isOddNumber(d):
return d % 2 != 0
def run(data):
j = 0
for i in range(0,len(data)):
if isOddNumber(data[i]):
swap(data,i,j)
j += 1
data = [2,1,7,3,6,5,4,9,6]
print 'raw',data
print run(data... | true |
9f65f343a89a3acc999dd168801dd00d832326d7 | Python | omarSuarezRodriguez/Python | /Portafolio/programasInterfazGrafica/guiProgram_1.py | UTF-8 | 211 | 2.859375 | 3 | [] | no_license | from tkinter import *
from tkinter import ttk
ventana = Tk()
ventana.title("Programa 1")
ventana.geometry("300x200+300+150")
label_1= ttk.Label(ventana, text="Hola mundo").pack()
ventana.mainloop()
| true |
485a38b3696042f84f00344efed38323269e40e8 | Python | Vishrutha-k/ml_SAheartdisease | /unsupervised_learning.py | UTF-8 | 8,467 | 2.84375 | 3 | [] | no_license | import numpy as np
import xlrd
from pylab import *
from matplotlib.pyplot import figure, show, xlabel, ylabel, plot, legend, bar, title
from sklearn.mixture import GaussianMixture
from scipy.linalg import svd
from scipy.cluster.hierarchy import linkage, fcluster, dendrogram
from sklearn.neighbors import NearestNeighbor... | true |
b7fdf9a4c09b0c641228f9639471a9c74e070e28 | Python | ltakuno/arquivos | /python/URI/Basico/uri2760.py | UTF-8 | 205 | 3.53125 | 4 | [] | no_license | # 2760 - entrada e saida de string
a = input()
b = input()
c = input()
print('{}{}{}'.format(a,b,c))
print('{}{}{}'.format(b,c,a))
print('{}{}{}'.format(c,a,b))
print('{:.10}{:.10}{:.10}'.format(a,b,c))
| true |
e1d82923ee33db517909e4025ced484f29b431af | Python | kmaheshwari/Interactive_programming | /quiz4b-8.py | UTF-8 | 577 | 3.046875 | 3 | [] | no_license | import simplegui
point_pos = [10 , 20]
change = [1, 0.7]
acc = [0 , 0]
time = 0
def tick():
global time
time += 1
global acc
change[0] += time*acc[0]
change[1] += time*acc[1]
acc[0] += 1
acc[1] += 1
def draw_handler(canvas):
point_pos = [10 , 20]
point_pos[0] +=... | true |
a4a11ad6b8d51ee78d23797b4da9d6dcf70d6333 | Python | WeltonKing/Lockbox | /data.py | UTF-8 | 2,605 | 2.71875 | 3 | [] | no_license | '''
project: Lockbox
file: data.py
authors: david rademacher & welton king v
desc: functions that interact with database
'''
import sys
import sqlite3
from sql import *
from classes import msgs
# store new account information on database
def create_account(conn, profile):
profiles_tbl(conn)
if verify_account(... | true |
5da80e6be7b869e84f7a9460c2d168b293f9ef77 | Python | huazhz/WebPortalCollection | /search.py | UTF-8 | 3,871 | 2.6875 | 3 | [] | no_license | # -*-coding:utf-8-*-
# import test1.Spider as Spider
import jieba
import pymysql
conn = pymysql.connect(host='127.0.0.1',port=3306,user='root',passwd='lijiaming',db='NEW',charset='utf8')
stopw = [line.strip() for line in open("stop.txt", encoding = "utf-8")]
stopw = set(stopw)
#切分题目
def CutTitle():
cursor = ... | true |
d84e6a6f976781f7183c43a9fa61bf6a6653237f | Python | jackson-/Terminal-Trader | /markit_wrapper.py | UTF-8 | 572 | 2.78125 | 3 | [] | no_license | import requests
class Markit:
def __init__(self):
self.lookup_url = "http://dev.markitondemand.com/Api/v2/Lookup/json?input="
self.quote_url = "http://dev.markitondemand.com/Api/v2/Quote/json?symbol="
def company_search(self, string):
result = requests.get(self.lookup_url + string).json()
if len(result) == ... | true |
abdce7cd2a06412905895590bfb31437f1a05eb2 | Python | yashrsharma44/mock-practice | /wtmock_02.py | UTF-8 | 257 | 3.046875 | 3 | [] | no_license | from unittest import mock
# We can assign attribute using three methods
# Assign directly
m = mock.Mock()
m.foo = 'bar'
assert m.foo == 'bar'
# We can use the configure_mock function
# to assign values
m.configure_mock(bar='baz')
assert m.bar == 'baz'
| true |
9faba414d8cefc1165f75c837f0e1abc7c815d5c | Python | choumartin1234/GAN-Travel-Frog | /genPic.py | UTF-8 | 1,525 | 2.59375 | 3 | [
"MIT"
] | permissive | from pix2pix import *
import os
import tensorflow as tf
import matplotlib as mpl
import argparse
from matplotlib import pyplot as plt
parser = argparse.ArgumentParser(
description='This is a pix2pix model,Reference:https://www.tensorflow.org/tutorials/generative/pix2pix')
parser.add_argument('--path', hel... | true |
1ece4861d6aeaf7dccea832fb2b86cf14391facc | Python | gisazae/SpoofingDetector | /tool/modules/ssl.py | UTF-8 | 887 | 2.6875 | 3 | [] | no_license | from sslstrip2 import launch as sslstrip
from dns2proxy import dns2proxy as dns
from multiprocessing import Process
import ip_misc
def launch_sslstrip(port):
ip_misc.start_http_redirect(port)
sslstrip.main(['-l', port])
def launch_dns():
ip_misc.start_dns_redirect()
dns.start()
'''
Starts sslstrip a... | true |
b2dff7c3816d970cacacefd57ebdca66f0e31cd9 | Python | mouraa0/python-exercises | /exercises/ex080.py | UTF-8 | 367 | 3.578125 | 4 | [
"MIT"
] | permissive | def wtf(l1):
for i in range(len(l1) - 1):
for j in range(len(l1) - 1):
if l1[j] > l1[j + 1]:
l1[j], l1[j + 1] = l1[j + 1], l1[j]
def ex080():
numeros = []
for i in range(5):
num = int(input(f'Digite o {i + 1}º número: '))
numeros.append(num)
... | true |
2d4f3ff87c840c00e8cd171d7153d61205250984 | Python | olasson/SDCND-P3-BehavioralCloning | /code/io.py | UTF-8 | 3,669 | 3.21875 | 3 | [] | no_license | """
This file contains save and load (I/O) functions.
"""
import json
import pickle
import numpy as np
from glob import glob
from pandas import read_csv
from os.path import join as path_join
import matplotlib.image as mpimg
# Custom imports
from code.misc import parse_file_path
def load_image(file_path):
# Wr... | true |
72d08a840eca22304ba1b5841d197430b45a2ec4 | Python | Palaniappan12345/CSV_file_to_Sqlite3_database | /eg1 database/1st step.py | UTF-8 | 272 | 2.59375 | 3 | [] | no_license | import sqlite3
conn = sqlite3.connect('mysqlite.db')
c = conn.cursor()
#create table
c.execute('''CREATE TABLE IF NOT EXISTS students
(rollno real, name text, class real)''')
#commit the changes to db
conn.commit()
#close the connection
conn.close()
| true |
9ab4fb9cad3891f7a17f90c38c0be597b6094408 | Python | febin-cp/barabasi_albert_graph-and_dijkstra | /djikstra.py | UTF-8 | 634 | 3.15625 | 3 | [] | no_license | from collections import defaultdict
from heapq import *
def djikstra(start,end,edges):
g = defaultdict(list)
for l,r,c in edges:
g[l].append((c,r))
q,seen = [(0,start,())],set()
while q:
(cost,v1,path) = heappop(q)
if v1 not in seen:
seen.add(v1)
path = (v1,path)
if(v1==end):
retur... | true |
bc08405b1051e3a20617ee7a63b1465da267626a | Python | rmMinusR/RapidRomTester | /config.py | UTF-8 | 857 | 2.5625 | 3 | [] | no_license | # Shortcut reading
import win32com.client
_shell = None
def get_shortcut_target(path) -> str:
global _shell
if _shell == None:
_shell = win32com.client.Dispatch("WScript.Shell")
return _shell.CreateShortCut(path).Targetpath
# Detect values
import os.path
data_path: str = get_shortcut_target(os.path.expanduser... | true |
dd4bb988f9867412efa9c263a3bc0af65ea0e5f6 | Python | elsigh/levels | /server/lib/external/shortuuid/main.py | UTF-8 | 2,547 | 3.40625 | 3 | [] | no_license | """ Concise UUID generation. """
import uuid as _uu
class ShortUUID(object):
def __init__(self, alphabet=None):
if alphabet is None:
alphabet = list("23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")
# Define our alphabet.
self._alphabet = alphabet
self._alph... | true |
e897f7ebd8cd3a2290f451818a619692c1a352da | Python | mfalcirolli1/Python-Exercicios | /ex61.py | UTF-8 | 332 | 3.546875 | 4 | [] | no_license | # Progressão Aritmética v2.0 - v1.0 ex51
print('\033[1;7m-=\033[m'*16)
print('Gerador de Progressão Aritmética')
print('\033[1;7m-=\033[m'*16)
num = int(input('Primeiro termo: '))
rz = int(input('Razão: '))
termo = num
c = 1
while c <= 10:
print('{} ↔ '.format(termo), end='')
termo += rz
c += 1
print('F... | true |
69c2b002787f087955a42b42726b42df8495c3be | Python | Tonaaa/DiscretePeerAssignment | /Question1.py | UTF-8 | 482 | 4.4375 | 4 | [] | no_license | # Question 1
user_input = input("Fill in a list of elements in a set to check if it's valid. \n"
"Separate each item with a comma. DO NOT use quotation marks OR spaces ")
set = user_input.split(',')
final_set = []
for item in set:
if item not in final_set:
final_set.append(item)
if set ==... | true |
b9d5c9e5a05e875395f53e6297a42df3a014978c | Python | GrislyMe/algorithm_practice | /SHA/sha256.py | UTF-8 | 3,062 | 2.765625 | 3 | [] | no_license | #!/usr/bin/env python3
from bitarray import bitarray
import random, time
def rotateRight(string: bitarray, num: int):
return string[len(string) - num :] + string[: len(string) - num]
def add(*x: bitarray):
tmp = 0
for i in x:
tmp += int(i.to01(), 2)
return bitarray(f"{tmp:032b}")[-32:]
def s... | true |
a5a8d076fc5dc4421a801bbfa7164a9d0bbab50d | Python | EpicureanHeron/DataAnalyticsBootcampSpring2018 | /Week 7 - Social Media Mining/Practices/Class 2/10-Stu_Hello_Tweet/HelloTweet_Unsolved.py | UTF-8 | 1,119 | 2.671875 | 3 | [] | no_license | # Dependencies
import tweepy
import json
import config
# Twitter API Keys
# Twitter API Keys
consumer_key = config.consumer_key
consumer_secret = config.consumer_secret
access_token = config.access_token
access_token_secret = config.access_token_secret
# auth tweepy
auth = tweepy.OAuthHandler(consumer_key, consumer_s... | true |
8e82d165588d966dd90b8a308d1b1ce75b777592 | Python | gnsaddy/bookRecommendationSystem | /usingKnn.py | UTF-8 | 10,098 | 3.34375 | 3 | [] | no_license | import seaborn as sns
from sklearn.neighbors import NearestNeighbors
from scipy.sparse import csr_matrix
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
class recommendationClassKnn:
def __init__(self):
# dataset books,student,rating
self.books = pd.read_csv('booksForExcel.... | true |
f45371d9a9f73a185091b912ea01dbf3eac4dab6 | Python | sukhvir786/Python-Day-6-Lists | /list14.py | UTF-8 | 416 | 4.5 | 4 | [] | no_license | """
5. extend
"""
# Add multiple items to a list
L = ['RED', 'YELLOW', 'GREEN']
L.extend([1,2,3])
print(L)
# Prints ['RED', 'YELLOW', 'GREEN', 1, 2, 3]
# Add tuple items to a list
L1 = ['R', 'P', 'G']
L1.extend((1,2,3))
print(L1)
# Prints ['R', 'P', 'G', 1, 2, 3]
# Add set items to a list
L3 = ['r... | true |
e8a79d3b5f36486e5f3a20a2b1f9ca49fd03a063 | Python | alvonellos/sandbox | /python/math/int.py | UTF-8 | 227 | 3.359375 | 3 | [] | no_license | def drange(x_0, x_1, step):
curr = float(x_0)
while curr < (x_1):
yield curr
curr += float(step)
def integrate(f, x_0, x_1, step):
acc = float(x_0)
for dx in drange(x_0, x_1, step):
acc += float(f(dx))
return acc
| true |
ab3bd70ece2c506fae581e2e5fad66675fff3afc | Python | ofey404/ofey404.github.io | /tools/lang-ref.py | UTF-8 | 2,289 | 3.328125 | 3 | [] | no_license | #!/usr/bin/python3
# Genreate lang-ref attributes from the filename of posts
#
# My jekyll code would read attribute `lang-ref` and `lang` in posts,
# in order to generate multi-language posts.
#
# But manually filling the attributes is clumsy, so I decided to generate
# them according to filename of posts.
#
# eg:
#... | true |
e4123c704286d8e3175763919f84a42c0a2a3605 | Python | Sujankhyaju/IW_PythonAssignment1 | /datatype/37.py | UTF-8 | 225 | 3.9375 | 4 | [] | no_license | # 37. Write a Python program to multiply all the items in a dictionary
sample_dict={ x:x*2 for x in range(1,5)}
values= sample_dict.values()
print(values)
result =1
for value in values:
result *= value
print(result) | true |
de5a3fe23b71edd41565d64d2ebe2ae71b1f3517 | Python | nite-crawler/Python_Practice | /strings/palindromeCheckWithQueue.py | UTF-8 | 685 | 3.703125 | 4 | [] | no_license | #palindrome check - Queue.py
import queue
from collections import deque
#option 1: queue module
# def plaindrome(s):
# q=queue.Queue(maxsize=0) #inifitie queue maxsize=0
# for i in s:
# q.put(i)
# print(q.qsize())
# for i in s[::-1]:
# if q.get()!= i:
# return "No"
# ret... | true |
d07ea7472a583a645691c3a4a8722a57787975fa | Python | oluwafenyi/code-challenges | /CodeWars/6Kyu/create_phone_number.py | UTF-8 | 320 | 3.53125 | 4 | [] | no_license |
# https://www.codewars.com/kata/create-phone-number
def create_phone_number(n):
return '({}) {}-{}'.format(''.join(str(c) for c in n[:3]), ''.join(str(c) for c in n[3:6]), ''.join(str(c) for c in n[6:]))
print(create_phone_number(range(10)))
print(create_phone_number(([1, 2, 3, 4, 5, 6, 7, 8, 9, 0])))
| true |
bb5cf849a867a10588c2858e43c4a40b9b7a2ff6 | Python | vitoriadias/forca | /vitoria-forca.py | UTF-8 | 4,790 | 3.765625 | 4 | [] | no_license | import random # importa a biblioteca random para gerar números aleatórios #
#palavras = ['abacate','chocolate','paralelepipedo','goiaba'] # gera uma variável que possui uma lista de palavras #
palavras = []
letrasErradas = ''
letrasCertas = ''
FORCAIMG = ['''
+---+
| |
|
|
|
|
=========... | true |
c1eb4978c1ef9a5255ee935a1b0d76889dd7d9f8 | Python | vavrusa/seqalpha | /quadclass/quadclass.py | UTF-8 | 3,757 | 2.625 | 3 | [
"BSD-2-Clause-Views"
] | permissive | #!/usr/bin/env python
import sys, os, glob, getopt
import tetrad
from Bio.PDB import *
def analyze_model(name, model, qclass, result_file):
''' Spatial analysis of model chains. '''
# Analyze guanine tetrads
result = tetrad.analyze(model)
if result is None:
return
if result_file:
(p... | true |
d01a0a44f69bd54ded437e16049326dffb18084b | Python | AlexandreLouzada/Pyquest | /envExemplo/Lista01/Lista01Ex07.py | UTF-8 | 531 | 4.21875 | 4 | [] | no_license | """
Escreva um programa que calcule o índice de massa corpórea (IMC) de uma pessoa,
sendo o peso e a altura fornecidos pelo teclado. Apresentar na tela o peso, a altura
e o IMC calculado.
Exemplo: Valores fornecidos pelo teclado: Peso = 60kg e Altura = 1,67m
Cálculo do IMC = 60 / (1,67)² = 60 / 2,78 = 21,5
"""
peso = f... | true |
a8bb861f780e12ff6cb9b7a5ae176582fb430d60 | Python | floyd-fuh/JKS-private-key-cracker-hashcat | /jksprivk_crack.py | UTF-8 | 5,991 | 3.046875 | 3 | [
"LicenseRef-scancode-mit-old-style",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env pypy
#By floyd https://www.floyd.ch @floyd_ch
#modzero AG https://www.modzero.ch @mod0
# Reads a private key entry from a Java Key Store that was prepared with JksPrivkPrepare.jar and tries to crack the password. The format this script reads is:
# $jksprivk$*checksum*iv*encrypted private key*1 byte DER ... | true |
60a84dfeae086a24191a6f6ab2c3bc8cfbbdfb89 | Python | iamshivanisharma/Telebot | /BOT.py | UTF-8 | 1,335 | 2.703125 | 3 | [] | no_license | import time,datetime
import telepot
from telepot.loop import MessageLoop
import RPi.GPIO as GPIO
import Adafruit_DHT
pin=4
sensor=Adafruit_DHT.DHT11
now=datetime.datetime.now()
def action(msg):
chat_id=msg['chat']['id']
strin =msg['text']
command=str(strin.lower())
print('Recevied:%s'%command)
if... | true |
626cc7e5d79dbd9a329edd2f85b1278de4ea3e66 | Python | AphroditesChild/Codewars-Katas | /string increment.py | UTF-8 | 918 | 3.359375 | 3 | [] | no_license | import re
def increment_string(strng):
num = re.findall("[0-9]+$", strng)
if num != []:
num = num[0]
else :
return strng+"1"
print(num)
digit19 = re.findall("[1-9]+[0-9]*", num)
if digit19 != []:
digit19 = digit19[0]
else :
digit19 = ""
... | true |
fa6f9b6ec63f87652d8cd48919c6ca309df8b120 | Python | JHodorHodor/Chat | /client.py | UTF-8 | 6,817 | 2.625 | 3 | [] | no_license | #! /usr/bin/python3
from tkinter import *
import socket, sys, threading, queue, time, struct
PORT = 40702
HOST = "localhost"
changes = queue.Queue()
listLock = threading.Lock()
class LogIn(threading.Thread):
def __init__(self):
window = Tk()
window.title("Type your name:")
login = En... | true |
7910e27df04d3e5648c3b36d0b168f3cec15dbf4 | Python | croningp/dropbot1_data_analysis | /ternary_trajectories/plot_trajectories.py | UTF-8 | 6,372 | 2.734375 | 3 | [] | no_license | import os
import numpy as np
import matplotlib.pyplot as plt
import ternary
# this get our current location in the file system
import inspect
HERE_PATH = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
# adding parent directory to path, so we can access the utils easily
import sys
root_path... | true |
ac603992d945c3cfefc8fe29980a9858c7b3d242 | Python | jimibarra/cn_python_programming | /02_basic_datatypes/2_strings/02_10_most_characters.py | UTF-8 | 857 | 4.5625 | 5 | [] | no_license | '''
Write a script that takes three strings from the user and prints them together with their length.
Example Output:
5, hello
5, world
9, greetings
CHALLENGE: Can you edit to script to print only the string with the most characters? You can look
into the topic "Conditionals" to solve this challenge.
'''... | true |
68f36bb0f175b1686be0cbbc2614166ad939a857 | Python | Pressio/pressio4py | /demos/settings_for_website.py | UTF-8 | 418 | 2.734375 | 3 | [
"BSD-3-Clause"
] | permissive |
import matplotlib.pyplot as plt
def edit_figure_for_web(ax, leg):
mycolor = 'w'
# makes all axes and text whie
for l in ['bottom', 'left', 'right', 'top']:
ax.spines[l].set_color(mycolor)
ax.xaxis.label.set_color(mycolor);
ax.tick_params(axis='x', colors=mycolor)
ax.yaxis.label.set_color(mycolor);
... | true |
f6d46ebe0b58d7b61964c55145df4a454b90478d | Python | patillacode/k-challenge | /b/challenge_b.py | UTF-8 | 2,500 | 4.03125 | 4 | [] | no_license | #!/usr/bin/env python
# Challenge B:
# - There is a DB [1] with Comments.
# - The object *Comment (id = number, text = string)* will provide *save()* and
# *get_object_by_id(id=[number])* methods, which saves and retrieves the object
# from a DB [1](see notes below).
# - Every object will be saved in one of 4 tables... | true |
f51bcad3fbc479474299876f7327a691d212d095 | Python | AuchityaKatiyar11/GetWell | /server/main.py | UTF-8 | 621 | 2.65625 | 3 | [] | no_license | from flask import Flask, jsonify,request
import smtplib as smtp
from email.message import EmailMessage
app = Flask(__name__)
user = 'rickysharmamailbox@gmail.com'
password = '+++++'
fr_address = 'rickysharmamailbox@gmail.com'
to_address = 'getwellpsit@gmail.com'
smtp_host = 'smtp.gmail.com'
smtp_port = 587
@app... | true |
c80d3f5d91f1c14e27b2e5ec90365137b3ce53a5 | Python | jedbrown/simasm | /ppc.py | UTF-8 | 2,201 | 2.828125 | 3 | [] | no_license | from collections import namedtuple
# Register contents
FPVal = namedtuple('FPVal','p s')
IntVal = namedtuple('IntVal','val')
class Register:
'Contains resolved register name, not values'
def __str__(self):
return self.name
def __eq__(self,x):
return self.name == x.name and self.num == x.nu... | true |
bef3d450545c2f7df8289c44ff4f7e4bdfdca19c | Python | YI-DING/daily-leetcode | /210_course_schedule_2.py | UTF-8 | 1,263 | 3.09375 | 3 | [] | no_license | from collections import deque
class Solution:
def findOrder(self, numCourses: int, prerequisites: List[List[int]]) -> List[int]:
n = numCourses
def create_neighbors(prereq):#prereq ---> node->its neighbours i.e. course, upcoming courses
dicc = {i:set() for i in range(n)}
... | true |
d2ce093831e589a799850bf788deb2c906bc406e | Python | jtlai0921/MP21909_examples | /範例檔(Python)/105年03月/實作題04_血緣關係ok/血緣關係.py | UTF-8 | 3,489 | 3.640625 | 4 | [] | no_license | #函式distance計算中間過程最大深度
def distance(x):
global CHILD, farthest_blood_distance
#最大前兩個的深度
farthest1 = 0 #向下的最大值
farthest2 = 0 #向下的第二大值
depth = 0 #記錄家族成員的深度
if len(CHILD[x]) == 0: return 0 #沒有小孩是遞迴的出口條件
if len(CHILD[x]) == 1: return distance(CHILD[x][0]) + 1#只有一個小孩
else: #2個小孩以上
... | true |
9c8347ae48a9526e037ebf3b3afbf0b7894760cf | Python | Aasthaengg/IBMdataset | /Python_codes/p02881/s737255808.py | UTF-8 | 193 | 3.171875 | 3 | [] | no_license | from math import sqrt
n = int(input())
end = int(sqrt(n))
low = 1
for x in range(end, 0, -1):
if n % x == 0:
low = x
break
high = int(n/low)
ans = low + high -2
print(ans) | true |
be4fd7787266d15004ff75fc1a57bd2df7291215 | Python | cizydorczyk/grad_school_scripts | /Quality_Control_Pipeline/G66_prokka_porthomcl/core_gene_test_1.py | UTF-8 | 2,498 | 2.609375 | 3 | [] | no_license | '''I also wrote a python script, "parse_porthomcl_ortho_group_output_1.py", to parse the ortholog family output from Porthomcl.
It takes the "8.all.ort.group" output file from PorthoMCL, an isolate list file, and a text file with the complete paths to all
isolate .faa files (from Prokka). It outputs a couple summary fi... | true |
db489c8f6efcde3a691a0f81ee05352bad4f6fd1 | Python | Patricia888/data-structures-and-algorithms | /challanges/ll_find_loop/ll_find_loop.py | UTF-8 | 2,592 | 3.734375 | 4 | [
"MIT"
] | permissive | from .node import Node
class LinkedList:
"""
create a linked list
"""
def __init__(self, iterable=[]):
self.head = None
self._size = 0
if type(iterable) is not list:
raise TypeError('Invalid iterable')
for item in reversed(iterable):
self.in... | true |
19275ec94f9b830ea03bb672637fb2ef0ceb1a0b | Python | kirtiswagat/ComputerVisionApplications | /Copying_images_from_a_folder_based_on_image_name_from_csv_file.py | UTF-8 | 1,043 | 2.65625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sat May 2 20:11:49 2020
@author: Kirti Swagat Mohanty
"""
import os
import pandas as pd
from shutil import copyfile
import re
image_path_csv= 'F:/Kirti_Swagat/AI/COVID_19_Predictions/Kirti_training_on_Covid/ResNet50/stage_2_detailed_class_info.csv'
csv_resnet = pd... | true |
5803a878e569da05a3377698f19ba64f5e73b673 | Python | elbow-jason/Uno-deprecated | /uno/parser/path.py | UTF-8 | 1,234 | 2.546875 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
import os
class Path(object):
@property
def html(self):
return self._html
@html.setter
def html(self, value):
self._html = value
try:
self.parent.load_html_files()
except:
pass
@property
def source(self):
... | true |
83cf303a4b97b8b36a35f63d862c14adbef6d25f | Python | muhammad-amhan/network-log-analyzer | /script/analyzer.py | UTF-8 | 6,984 | 2.765625 | 3 | [] | no_license | import os
import re
import sys
from typing import Dict, List, Any, Pattern
import argparse
# Creating regular expressions (regex) to filter out the target log
NETWORK_INTERFACES_PATTERN = 'LINK-3-UPDOWN.*Interface\s([a-zA-Z]*[0-9]\/[0-9]+).*(down|up)'
NETWORK_INTERFACES_PATTERN_COMPILED = re.compile(NETWORK_INTERFACES... | true |
a0cb4dc94a2aa03f7bf27e20cd4754dab3e48b1b | Python | luwachamo/Python-File-Line-Counter | /pycount | UTF-8 | 1,206 | 3.40625 | 3 | [] | no_license | #!/usr/bin/python3
import sys
def line_counter(file_name):
with open(file_name, 'r') as file:
count = 0
large_comment = False
for line in file:
line = line.strip()
line.replace(" ", "")
if line == "":
continue
elif line[0] == '... | true |
64076827f515e89a2b91774da93c668a0bb6148d | Python | hongyeon-kyeong/Algorithm | /Dynamic_Programming/31.py | UTF-8 | 911 | 2.9375 | 3 | [] | no_license | import sys
input = sys.stdin.readline
t = int(input())
def find_gold(x, y, array, gold) :
dx = [1,-1,0]
dy = [1,1,1]
for i in range(3) :
nx = x + dx[i]
ny = y + dy[i]
if 0 <= nx and 0 <= ny and nx < n and ny < m :
gold[nx][ny] = max(gold[x][y] + array[nx][ny], gold[nx][ny])
find_gold(nx, ny, array, ... | true |
464dccec8a5d9cee6da5687d71fd4c9a2b893574 | Python | ahmedBou/Gtx-computing-in-python | /conditional/set problem/findVowel.py | UTF-8 | 165 | 4.25 | 4 | [] | no_license | c = input("Enter any alphabet:")
if ('a' or 'e' or 'i' or 'o' or 'u') in c:
print(f"The alphabet {c} is vowel")
else:
print(f"The alphabet {c} is consonant") | true |
e4411fe093ffc3fdeed0a2c6c3d93d860d80deb1 | Python | kehsihba19/Codeforces | /Codeforces Round #634 (Div. 3)/1335B.py | UTF-8 | 197 | 3.03125 | 3 | [] | no_license | w="abcdefghijklmnopqrstuvwxyz"
for _ in range(int(input())):
n,a,b=map(int,input().split())
ans=w[0:b]
i=0
for j in range(0,n):
print(w[i%b],end="")
i+=1
print() | true |
22a010e523716297a9ee77ef89bcfb35e8029d74 | Python | pradipgit/api_automation_test | /quality-analysis-tool/service/LookupService.py | UTF-8 | 2,465 | 2.53125 | 3 | [] | no_license | import service.constant as constant
import json
import os
from service.ManagementService import ManagementService
class LookupService:
def __init__(self, config):
self.config = config
def update_teams_and_users(self, teams, update_to_file):
teams_lookup = []
users_lookup = []
... | true |
d034f0e33b830fa95df489df1f988c18cc14b834 | Python | Ckingbigdata/cn_labs | /labs/01_python_fundamentals/01_01_run_it.py | UTF-8 | 3,643 | 4.84375 | 5 | [] | no_license | '''
1 - Write and execute a script that prints "hello world" to the console.
2 - Using the interpreter, print "hello world!" to the console.
3 - Explore the interpreter.
- Execute lines with syntax error and see what the response is.
* What happens if you leave out a quotation or parentheses?
* How h... | true |
5e8ac2c290e715bb8e815ab1e552d227eb499921 | Python | mbyase/auto-targeting-turret | /PythonScripts/control.py | UTF-8 | 1,329 | 2.53125 | 3 | [
"MIT"
] | permissive | '''
Scripts for communication between computer and arduino
Created by: Tomas Hromada
tomashromada1@gmail.com
Github: https://github.com/tomash1234/
See: https://www.youtube.com/watch?v=S3CwzkT6cK4
'''
import socket
import requests
from PIL import Image
from io import BytesIO
import time
import s... | true |
11cb1e888535194ed562e8cbad8c820319c32b18 | Python | edisonlz/c1_course_python | /_list_/1_2_迭代.py | UTF-8 | 225 | 3.984375 | 4 | [
"Apache-2.0"
] | permissive | a = [1,2,3,4,5,6]
#数组的基本迭代
for i in a:
print(i)
#迭代器
for i in range(10):
print(i)
range(start,end,step)
start 开始
end 结束
step 步长
for i in range(0,len(a),2):
print(i , end=',')
| true |
3e2749576b7379273d3589f67b693ffd0fd3a6bc | Python | avinash273/quicksort | /QuickSort.py | UTF-8 | 1,887 | 3.953125 | 4 | [] | no_license | #Partiton Code Begin
#Last element of the array is set as pivot
# i is set as the index of the smaller element in the array given
def Create_Partition(Input_Array,Start_Index,End_Index):
i=(Start_Index-1)
pivot=Input_Array[End_Index]
#Start_Index denotes the starting index picked
#End_Index denotes the endin... | true |
b108c2c7de3669c11c6e765d6e213619aa3d91fe | Python | QasimK/Project-Euler-Python | /src/problems/p_1_49/p23.py | UTF-8 | 2,656 | 4.125 | 4 | [] | no_license | '''
A perfect number is a number for which the sum of its
proper divisors is exactly equal to the number.
For example, the sum of the proper divisors of 28
would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is
a perfect number.
A number n is called deficient if the sum of its proper
divisors is less than n and it i... | true |
1cdebf19ce3bf3c083b7dffc60c24c2c0a68768c | Python | johnsonyue/slide | /format.py | UTF-8 | 2,126 | 2.578125 | 3 | [] | no_license | import sys
import json
node_index={
"lon":0,
"lat":1,
"info":2
}
info_index={
"name":0,
"asn":1,
"country":2,
"city":3,
"comment":4
}
def caida():
nodes=[]
while True:
try:
line=raw_input()
fields=line.split('|')
lon=fields[4]
lat=fields[5]
if (lon=="" or lat==""):
continue
name=fie... | true |
fefe1fb92c783798dab87af0701a71d634d01b3c | Python | yellowjung/file-entropy | /parser.py | UTF-8 | 1,218 | 3.078125 | 3 | [
"LicenseRef-scancode-bsd-simplified-darwin"
] | permissive | import re
import sys
filename = sys.argv[1]
data = open(filename, 'r', errors='replace')
result = [0,0,0,0,0]
count = 0
r_text = 0
error = []
empty = []
while True:
readTmp = data.readline()
if not readTmp : break
Tmp = readTmp.split(',')
try:
if '"empty"' in Tmp[2]:
empty.append(co... | true |
b16c3e73077c7bdd0300a1784989b7b2b2ca2c40 | Python | gorkemarslan/Blog-React-Django | /backend/blog_api/permissions.py | UTF-8 | 589 | 2.546875 | 3 | [
"MIT"
] | permissive | from rest_framework import permissions
class IsAuthorOrReadOnly(permissions.BasePermission):
"""
Only post owners can update and delete posts.
Other users only read posts.
"""
message = "Only post owner can edit this post."
def has_object_permission(self, request, view, obj):
# If HT... | true |
772c229a44102b48272f9dcbc9b40a9530b1aa7d | Python | AdamZhouSE/pythonHomework | /Code/CodeRecords/2966/60825/298986.py | UTF-8 | 347 | 2.640625 | 3 | [] | no_license | t=""
while True:
try:
ts=input()
t+=ts
t+="#"
except:
break
if t=='3sss' or t=='1s':
print('''a''')
elif t.startswith('3#5 3#2 1 1 1 1#1 1 1 1 2#5 5#5 2 3 3 4#2 5 3 4 3#5 5#4 5 2 1 4#5 4 2 1 4#'):
print('''YES
5 5
1 1
2 4
NO
YES
2 2
1 1
3 5''')
else:
print(''... | true |
e545811c3221e99e8150f95895e8c96120cc94af | Python | amatzke/python_pipes | /pipes/steps/datestep.py | UTF-8 | 239 | 2.875 | 3 | [] | no_license | import logging
import datetime
""" Add the current date in this step"""
class Step(object):
def run(self, input):
logging.info('Adding the Date')
now = datetime.datetime.now()
input['DATE'] = str(now)
| true |
c9fd57228c80c81f4e934ebdffa37e42389a682e | Python | DL2021Spring/CourseProject | /data_files/395 Longest Substring with At Least K Repeating Characters.py | UTF-8 | 462 | 3.0625 | 3 | [] | no_license |
from collections import defaultdict
__author__ = 'Daniel'
class Solution(object):
def longestSubstring(self, s, k):
if not s:
return 0
cnt = defaultdict(int)
for e in s: cnt[e] += 1
c = min(
s,
key=lambda x: cnt[x],
)
... | true |
fbcdf6cec7bef03ffa59a9feb06f3f6af223dad1 | Python | Bryan-Brito/IFRN | /Programação de Computadores (NCT)/LISTAS/Lista #02/Lista #02 Questão 2A.py | UTF-8 | 543 | 4.3125 | 4 | [] | no_license | print("Vamos calcular as raízes de uma equação de segundo grau utilizando o teorema de Bhaskara")
a = float(input("Coloque um valor para 'a'"))
b = float(input("Coloque um valor para 'b'"))
c = float(input("Coloque um valor para 'c'"))
delta = (b**2 - 4 * a * c)
if a == 0:
print("O valor de 'a' deve se... | true |
d517837336eab33380aadb3f8f08227109b218bd | Python | caveman0612/python_fundeamentals | /09_exceptions/09_03_else.py | UTF-8 | 198 | 3.828125 | 4 | [] | no_license | '''
Write a script that demonstrates a try/except/else.
'''
try:
num = open("integers.txt", "r")
num1 = num.read()
except:
print("failed")
else:
print(num1)
finally:
num.close() | true |
9b7b9838d5cff0f900835a235bd7e0b60a2d2873 | Python | MrHamdulay/csc3-capstone | /examples/data/Assignment_8/gndvah001/question4.py | UTF-8 | 920 | 3.8125 | 4 | [] | no_license | """recursion palindrome prime
Vahin Gounden
2014-05-07"""
import sys
sys.setrecursionlimit (30000)
import math
n = eval(input("Enter the starting point N:\n"))
m = eval(input("Enter the ending point M:\n"))
def main(n,m):
if m<n:
return 0
elif palin(n) == True:
if prime((ro... | true |
40bf9285f90670b73c960a6ec7ad92daff3bf597 | Python | benstoehr/GoldTeamTrack2 | /server/query/Column.py | UTF-8 | 1,769 | 3.03125 | 3 | [] | no_license |
from server.query.Table import Table
class Column:
def __init__(self, table, name, op=None, number=None):
assert isinstance(table, Table), "A Column must belong to a Table."
self._name = name
self._table = table
if op is not None:
op = op.value
self.op = op
... | true |
376910c8fb5ce1f9845efcab06f2a07ecb5ff84b | Python | bcsaldias/syllabus-1 | /Actividades/AC15/main.py | UTF-8 | 1,957 | 3.609375 | 4 | [] | no_license | import threading
class Worker(threading.Thread):
mean_data = dict() # para guardar los promedios
# Sientete libre para usar otras
# variables estaticas aqui si quieres
# programa el __init__
# recuerda imprimir cual es el comando
# para el cual se creo el worker
def __init__(self, st... | true |