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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
0bf188df72cecdbb0be30126b2ab71fbc721922a | Python | green-fox-academy/KoDa505 | /Week-5/decorator_pattern/template_method.py | UTF-8 | 1,315 | 3.96875 | 4 | [] | no_license | import random
class Warrior:
def __init__(self, weapon):
self.hp = 100
self.weapon = weapon
def strike(self, other):
self.weapon.strike(self, other)
def __repr__(self):
return "Warrior hp: {}".format(self.hp)
class Weapon:
def __init__(self):
pass
def da... | true |
5535876f3af8f3bef4ef5bcf62eb0cfeaa198bf0 | Python | ShihPingLai/Jacob-deep_learning | /DL_setup.py | UTF-8 | 2,925 | 2.921875 | 3 | [] | no_license | #!/usr/bin/python3
'''
Program:
This is a program to setup DL python3 code.
For Linux and macOS only
Usage:
1. DL_setup.py
editor:
Jacob975
##################################
# Python3 #
# This code is made in python3 #
##################################
20170809
####################... | true |
c4484090e6604792c143acc6c0ecf860f7f60259 | Python | rottendoom001/PYTHON_CORE | /specan.py | UTF-8 | 2,917 | 2.578125 | 3 | [] | no_license | import numpy as np
import wave
import scipy.io.wavfile
import statistics as st
import math
import sys
from pylab import plot, show, title, xlabel, ylabel, subplot
from scipy import fft, arange
from scipy.stats import kurtosis, skew, entropy, gmean
from sklearn.cluster import KMeans
TAINING_M = '/Users/alancruz/Docum... | true |
789d5293268a78cd669b818f541bae807bbbbbb3 | Python | Jiaming0214/JiaMing-scode | /snake_game.py | UTF-8 | 2,955 | 3.734375 | 4 | [] | no_license | #函数引用区
from turtle import *
from snake_base import square
from random import randrange
from time import sleep
#变量声明区
apple_x=randrange(-200,180,10)
apple_y=randrange(-190,190,10) #生成第一个苹果的坐标
snake=[[0,0],[10,0],[20,0],[30,0],[40,0],[50,0]] #生成蛇的初始位置,后面的坐标为前
ward_x=10 #控制蛇移动的方向
ward_y=0
#函数定义区
def ward_change(x,y): #此... | true |
e7ad6aeac4e90d53cfbfcfd02c5e99ae3535f16c | Python | zhaluza/python-notes | /Exercises/http/api_project.py | UTF-8 | 857 | 3.421875 | 3 | [] | no_license | from pyfiglet import figlet_format
from termcolor import colored
import requests
import random
url = "https://icanhazdadjoke.com/search"
msg = "Dad Jokes : ("
welcome_text = figlet_format(msg)
welcome_text_formatted = colored(welcome_text, color="magenta")
print(welcome_text_formatted)
search_term = input("Search f... | true |
05a0604b2cb9ba165deb05c901fc940765230862 | Python | Theeradach/Python-weather-forcast-scraping | /scraping_weather_forcast.py | UTF-8 | 2,097 | 3.09375 | 3 | [] | no_license | #!/usr/bin/python3
# coding: utf-8
import os
import sys, urllib
import csv
import requests
import re
from bs4 import BeautifulSoup
# ==================== FUNCTIONS ======================== #
# chuck data
def divide_chunks(l, n):
for i in range(0, len(l), n):
yield l[i:i + n]
# transpose a matrix... | true |
964968151e1dd545aac63cf047198beaf4583c68 | Python | AM1CODES/Hacky-Discord-bot | /info.py | UTF-8 | 2,789 | 2.8125 | 3 | [] | no_license | import discord
from discord.embeds import Embed
import random
color = 0xFF6500
key_features = {
'name' : 'Name',
'website':'Website',
'start': 'Start Time',
'end': 'End Time',
'city': 'City',
'state':'State',
'country': 'Country',
'virtual':'Virtual Hack?',
'mlhAssociated':'MLH Part... | true |
815d133393b515376eb3a04e4b642ba46a83cc53 | Python | hyedoii/2017_ITE1014_2017029716 | /2017029716_assign1.py | UTF-8 | 121 | 3.3125 | 3 | [] | no_license | result=0
for i in range(1,1000):
if i%3==0:
result+=i
elif i%5==0:
result+=i
else:
continue
print str(result)
| true |
82b8c516be386b972f33ca25a246a2053587291b | Python | anuj378/ForskLabs | /DAY 9 - DataBase Handeling/MyCode/db_University(db4free).py | UTF-8 | 2,292 | 3.1875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu May 16 12:19:41 2019
@author: King23
"""
'''
Code Challenge 1
Write a python code to insert records to a mongo/sqlite/MySQL database
named db_University for 10 students with fields like
Student_Name, Student_Age, Student_Roll_no, Student_Branch.
'''
#!pip install mysql-... | true |
febe99d8e118bec2de88324d032447fc2aac75ff | Python | MassiveZappy/ISBN-Book | /Versions/1.2.2/Ver1.2.2.py | UTF-8 | 8,824 | 2.796875 | 3 | [] | no_license | import requests
import sys
import json
import yaml
#User Pref for the Proof Of Concept
#IDK IF THIS WORKS!!!
#UCSD:[id] for ucsd isbns
#ISBN MUST BE IN LIST FORMAT
Isbns = ['9781975173449','9781608316571','9780781778718']
#extra isbn '9780781778718'
if sys.version_info[0] < 3 and sys.version_info[1] < 7:
raise E... | true |
2c15462929c043167d0d24e805514c30257ed11b | Python | masudurHimel/Problematic_Adventure | /Leetcode/Best Time to Buy and Sell Stock.py | UTF-8 | 320 | 3.03125 | 3 | [] | no_license | class Solution:
def maxProfit(self, prices):
min_v = 999999999999
max_v = 0
for i in prices:
if i < min_v:
min_v = i
if (i - min_v) > max_v:
max_v = i - min_v
return max_v
s = Solution()
print(s.maxProfit([7, 1, 5, 3, 6, 4]))
| true |
b10e8d660e325d4654b3a628032143b0194ce57f | Python | tkoptimizer/Assembly-code-optimizer | /optimizationClass.py | UTF-8 | 1,152 | 2.65625 | 3 | [] | no_license | from basicblock import *
from operations_new import *
class optimizationClass:
"""
Parent optimization class.
"""
def __init__(self, blocks):
"""
Initializes all the necessary variables.
"""
self.name = "Optimization class"
self.optimizedBloc... | true |
99e7878edbd3ba2e574a277dfee2d10c699d38ee | Python | KhizarSultan/Python | /Python Repo/chapter_9/comprehension.py | UTF-8 | 1,600 | 4.125 | 4 | [] | no_license | #List Comprehension
#simple way
squares = []
for i in range(0, 11):
squares.append(i**2)
print(squares)
#comprehension way
#mylist = [append_Item loop]
square2 = [i**2 for i in range(0, 11)]
print(square2)
negative_list = [i for i in range(-1, -11, -1)]
negative_2 = [-i for i in range(1, 11)]
print(... | true |
849efbf8e273ce3936f0acd4535fed10d6182064 | Python | millicentwanjiku/simplecommandapp | /app.py | UTF-8 | 671 | 3.671875 | 4 | [] | no_license | """Simple calculator
Usage:
app.py <operation> <number1> <number2>
app.py (-h | --help)
Arguments
number1 First Number
number2 Second Number
Options:
-h --help Show this screen.
"""
from docopt import docopt
if __name__ == '__main__':
args = docopt(__doc__, version='Simple calculator')
functi... | true |
6724cef4776afbf31acce7555ff3a91fcb2e1f3b | Python | lanpartis/jianzhiOffer_practice | /30_greatestSubarraySum.py | UTF-8 | 538 | 3.171875 | 3 | [] | no_license | # -*- coding:utf-8 -*-
'''
计算连续子向量的最大和
'''
class Solution:
def FindGreatestSumOfSubArray(self, array):
# write code here
res = array[1]
m_indice = [0,0]
su = 0
i = 0
j = 0
while j<len(array):
if i==j:
su = array[i]
else:... | true |
7fa14caf3a9a2dbd10f5a17efeb90d1b7933d1dc | Python | zenmeder/leetcode | /242.py | UTF-8 | 764 | 3.5625 | 4 | [] | no_license | #!/usr/local/bin/ python3
# -*- coding:utf-8 -*-
# __author__ = "zenmeder"
class Solution(object):
def isAnagram(self, s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
# ratio: 0.5%
if len(s)!= len(t):
return False
for i in range(len(s)):
if s[i] in t:
t = t.replace(s[i], '', 1)
else:... | true |
fcdbe0747f0a956e0d06d44cf1d4465369a1d12c | Python | huangwenxi/ubc | /test/s_gc.py | UTF-8 | 1,376 | 2.609375 | 3 | [] | no_license | import socket
import json
import logging
import random
PORT = 6080
HOST = '127.0.0.1'
SOCKET = None
def create_socket():
global SOCKET, HOST,ADDRESS
SOCKET = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
ADDRESS = (HOST, PORT)
return SOCKET;
def main():
create_socket()
heartbeat = {'id':'NT... | true |
ab5719fac5041d62271c2e6278c29f604e00f121 | Python | rafee/mlDataAssignment | /rest_app/main.py | UTF-8 | 1,944 | 2.5625 | 3 | [] | no_license | from flask import Flask, jsonify, request
import csv
from google.cloud import storage
app = Flask(__name__)
def parse_method(BUCKET='assignment1-data', FILE='Input-Data/NDBench-testing.csv'):
client = storage.Client()
bucket = client.get_bucket(BUCKET)
blob = bucket.get_blob(FILE)
csv_data = blob.dow... | true |
1a23dac4ba6950c8783e96c84f3f0ea3796812b0 | Python | pettaroni/nablaweb | /nablapps/poll/tests/test_current_poll.py | UTF-8 | 825 | 2.71875 | 3 | [
"MIT"
] | permissive | from django.test import TestCase
from nablapps.poll.models import Poll
from .utils import create_poll
class CurrentPollTest(TestCase):
def setUp(self):
self.first_poll = create_poll(u"Hvem er du?")
self.second_poll = create_poll(u"Hvor kommer verden fra?")
def assert_is_current_poll(self, po... | true |
12ebc43bcb442c87218ff099cbeae036134ddf53 | Python | saikpr/short_codes | /py/Some Scripts/Duplicate.py | UTF-8 | 393 | 2.71875 | 3 | [] | no_license | import os
import hashlib
hashdir = []
def get_hash(name):
readsize = 1024
with open(name, 'rb') as f:
data = f.read(readsize)
return hashlib.md5(data).hexdigest()
for filename in os.listdir("."):
hashed=get_hash(filename)
if hashed in hashdir:
... | true |
bdea515b62fcd81b65f9d101240a9e3e541a6a1c | Python | Ekaterina-Zykova/python_course | /homework9/tests/test_task02.py | UTF-8 | 862 | 2.875 | 3 | [] | no_license | import pytest
from homework9.task02.task02 import Suppressor, suppressor
def test_suppressor_as_class():
with Suppressor(IndexError):
assert [0][1]
with Suppressor(ValueError):
assert int("string")
with Suppressor(ZeroDivisionError):
assert 1 / 0
with Suppressor(ArithmeticErro... | true |
ab7b333160ac2699952d1b19cbd28f21d403e69b | Python | codeclimate-testing/falcon | /test/test_loops.py | UTF-8 | 235 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | from testing_helpers import wrap
@wrap
def count_threshold(limit, threshold):
count = 0
for item in xrange(limit):
if item > threshold: count += 1
return count
def test_count_threshold():
count_threshold(1000, 50)
| true |
f41d5860dcbc02ccc2658086317f386e251de64d | Python | EstevamPonte/Python-Basico | /PythonExercicios/mundo1/ex012.py | UTF-8 | 108 | 3.625 | 4 | [] | no_license | n1 = float(input('Digite o desconto: '))
n2 = (n1*5)/100
print('Seu produto saira por {:.2f}'.format(n1-n2)) | true |
30dcc11bc720e44a63ecd4230a736587b2fe18e7 | Python | cschu/ngslib | /find_mobile_candidates.py | UTF-8 | 1,048 | 2.734375 | 3 | [] | no_license | #!/usr/bin/env python
'''
Created on Mar 11, 2013
@author: Christian Schudoma (schudoma@mpimp-golm.mpg.de, cschu@darkjade.net)
'''
import sys
import csv
def main(argv):
reader = csv.reader(open(argv[0]), delimiter=',', quotechar='"')
writer = csv.writer(open(argv[0].replace('.csv', '_with_mobile.csv'), ... | true |
04a0b4140dd259662f751a90a5fe62b2a7b94844 | Python | jlejeune/Jarvis-Voice-Recognition | /jarvis/flask/models/epg.py | UTF-8 | 5,187 | 2.546875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# vim:set ai et sts=4 sw=4:
import peewee
from datetime import datetime
import os
import sys
# Update path in order to execute script in standalone
pkg_folder = os.path.dirname(os.path.abspath(__file__)) + '/../../..'
if os.path.exists(os.path.join(pkg_folder, "jarvis")):
sys.path.insert(0... | true |
93d80efbbf1b20c187cb62c4a781e779ac06709f | Python | AntonDos/lessons | /lesson04/classes02.py | UTF-8 | 81 | 3.421875 | 3 | [] | no_license | num = int(input())
for x in range(1, 101):
if x % num == 0:
print(x)
| true |
7781638d81d3534ca6aa3bc78e9b46202b8130b7 | Python | ttjjlw/NLP-Project | /retrieval_QA/lstm_siamese/data_helper.py | UTF-8 | 7,230 | 2.71875 | 3 | [] | no_license | import os
import json
import copy
import random
from collections import Counter
from itertools import chain
import jieba
import gensim
import numpy as np
class SiameseLstmData(object):
def __init__(self, config):
self.__output_path = config["output_path"]
if not os.path.exists(self.__output_path)... | true |
cb9f78b5bce947645733af3f8184a69cb9e0fc94 | Python | rohitnagpal92/MySQL_connection | /Connection_with_MySQL.py | UTF-8 | 931 | 2.8125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Nov 13 18:46:46 2019
@author: rohti
"""
import pandas as pd
import mysql.connector
from mysql.connector import Error
#checking if the DB exists
strDBName="MyDB"
strTableName="demo_data"
try:
connection = mysql.connector.connect(host='localhost',
... | true |
c410d7390855f6e67ef68e76f00de1dce75cee0e | Python | sokolegg/cellular-ml | /Tests.py | UTF-8 | 1,832 | 2.953125 | 3 | [] | no_license | import unittest
from models import Surface
from models import GameException
from models import Game
class Tests(unittest.TestCase):
def setUp(self):
self.surf = Surface()
def test_alive(self):
surface33 = Surface(width=3, height=3)
surface33.get(0, 0).is_alive = True
must_b... | true |
ae5e5aedc5e0eb494334c4d9847cde40ca52bc87 | Python | endy-kento/WashBasin | /CNN/Convolution.py | SHIFT_JIS | 2,605 | 2.96875 | 3 | [] | no_license | #!/usr/bin/env python
#-*- coding:utf-8 -*-
#Convolution_point.pyNX́B
#f[^(d悹Ăēf[^)瓾ꂽWf[^yь덷f[^̎Zo͍sȂB
#łɁA덷f[^߂Ă̂Ƃ
#̂ŁAł͐l݂̂60*609|CgÂW20*20̃f[^ɕϊ邾̃vOłB
import glob
import os, commands
import os.path
import csv
import numpy as np
from tqdm import tqdm
commands.getoutput("find . -name '.DS_Store' -type f -ls -dele... | true |
30be87c27a067f115dd3eaa8086e1ec6ae43f786 | Python | nickjalbert/improved-funicular | /envs/nick_gym_adapter.py | UTF-8 | 931 | 2.921875 | 3 | [] | no_license | """ A wrapper around Nick2048 that makes it use numpy arrays instead of tuples for board states."""
from envs.nick_2048 import Nick2048
import numpy as np
class Nick2048Gym(Nick2048):
def __init__(self, config=None, random_seed=None):
super().__init__(random_seed)
if config:
if "rand... | true |
d7eb05cf956720e4780a1173710306142ab88032 | Python | ZikenY/machine_learning_exercises | /logistic_regression_hands_on.py | UTF-8 | 6,427 | 3.15625 | 3 | [] | no_license | # Logistic Regression Hands on exercise
import numpy as np
import pandas as pd
from patsy import dmatrices
from sklearn.linear_model import LogisticRegression
from sklearn import metrics
import matplotlib.pyplot as plt
# use pandas to read .csv file
data = pd.read_csv("./HR_comma_sep.csv")
# field "left" is the Y la... | true |
0080e1adb713032b2a72a22353cab08e70e0f2cd | Python | ecurtin2/Project-Euler | /src/322.py | UTF-8 | 221 | 3.015625 | 3 | [] | no_license | """
Let T(m, n) be the number of the binomial coefficients iCn that are divisible by 10 for n ≤ i < m(i, m and n are positive integers).
You are given that T(109, 107-10) = 989697000.
Find T(1018, 1012-10).
""" | true |
1348063f5dfcfb55d3699476aa81b669ff444793 | Python | Oscar-Rod/SnakeGame | /snakegame/game/brain.py | UTF-8 | 989 | 3.078125 | 3 | [
"MIT"
] | permissive | from snakegame.neural_network.neuralnetwork import NeuralNetwork
class Brain:
def __init__(self, perception, number_of_cells):
self.perception = self.get_perception(perception, number_of_cells)
self.number_of_cells = number_of_cells
self.neural_network = NeuralNetwork(self.perception.set_... | true |
e78da862c79b7c74a276bbcbf875af096f89f71c | Python | Himske/Deep_Learning_Udemy | /self_organizing_map/som.py | UTF-8 | 1,625 | 2.984375 | 3 | [] | no_license | import numpy as np
import pandas as pd
from minisom import MiniSom
from matplotlib.pylab import bone, pcolor, colorbar, plot, show
from sklearn.preprocessing import MinMaxScaler
# import and split dataset
dataset = pd.read_csv('dataset/Credit_Card_Applications.csv')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, ... | true |
4e3d9d510b3257c118c622fcca171eddad97eb5f | Python | hmtinc/TechnoSync | /server/run.py | UTF-8 | 4,797 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | from datetime import datetime
from typing import Dict
from flask import Flask, request, send_file
from music import BeatTimestamp, FileOffsetRecording
from room import Room
app = Flask(__name__)
rooms: Dict[str, Room] = {}
# Accepts datetime in milliseconds and converts to microseconds
def parse_time(time_as_stri... | true |
ca5a18e468fe1a5d8b30b2bbf96f6a2d7761761e | Python | GregSal/PyUtilities | /CustomVariableSet/parameters.py | UTF-8 | 39,662 | 2.859375 | 3 | [] | no_license | '''Parameter objects with defined validity conditions and defaults.
'''
from pathlib import Path
from abc import ABC, abstractmethod
from collections import OrderedDict
from collections.abc import Iterable
from typing import Optional, List, Dict, Tuple, Set, Any, Union
from file_utilities import FileTypes, set_base_di... | true |
b7c3cefc7cac2b9d0a99c6dbd1fce2df46ce22b5 | Python | hmahmud01/bongo-python-test | /q3.py | UTF-8 | 377 | 3.28125 | 3 | [] | no_license | # Least Common Ancestor problem
def lca(root, n1, n2):
if root is None:
return None
if root.key == n1 or root.key == n2:
return root
right_lca = lca(root.right, n1, n2)
left_lca = lca(root.left, n1, n2)
if right_lca and left_lca:
return root
if left_lca is not None:
... | true |
5c94f57d4ee25487bd6116043763771de8792d51 | Python | asayko/word2vec_research | /create_vocab.py | UTF-8 | 1,233 | 2.8125 | 3 | [] | no_license | #!/usr/bin/env python
import sys
import words_reader
import multiprocessing
import collections
import codecs
def calc_sub_dict(fin_name, queue, part, total_parts):
counter = collections.Counter()
for word in words_reader.read_words(fin_name, part, total_parts):
counter[word] += 1
queue.put(counter)
def calc_di... | true |
d05bb37979754bcb39e8da9768dcf06e40a6d764 | Python | febwinter/skinfoNote | /python/day3/rangeList.py | UTF-8 | 184 | 3.140625 | 3 | [] | no_license | name = ['A','B','C']
kor = [100, 90, 80]
eng = [80, 90, 70]
mat = [50, 60, 70]
for i in range(len(name)): #
print(name[i])
total = kor[i] + eng[i] + mat[i]
avg = total / 3 | true |
4dc53629ca92c2ac6161a254e03ff68870629149 | Python | mtan22/CPE202 | /labs/lab2/stack_array_tests.py | UTF-8 | 3,177 | 3.796875 | 4 | [] | no_license | # Lab 2: Michelle Tan
# Instructor: Prof. Parkinson
import unittest
from stack_array import Stack
class TestLab2(unittest.TestCase):
def test_init(self) -> None:
stack = Stack(5)
self.assertEqual(stack.items, [None] * 5)
self.assertEqual(stack.capacity, 5)
stack = Stack(5, [1, 2... | true |
121c02d3184c71f0e3e4e2073cc78e837b94c237 | Python | Hammerlord/Monbot | /src/ui/health_bar.py | UTF-8 | 1,032 | 3.390625 | 3 | [] | no_license | import math
from src.elemental.combat_elemental import CombatElemental, CombatElementalLog
from src.elemental.elemental import Elemental
class HealthBarView:
@staticmethod
def from_elemental(elemental: Elemental or CombatElemental or CombatElementalLog) -> str:
return HealthBarView().get_view(elemen... | true |
51404877f52397b5de1dd9309bc790ffd787ec45 | Python | n0nBin4ry/Knowledge-Experience_COSC-Courses | /Cosc120_Intro/Junk_and_notes/Class_Exercise2.py | UTF-8 | 1,410 | 4.21875 | 4 | [] | no_license | # number 1: smallest of three
a=7
b=10
c=3
#variables set
if a<b and a<c:
print "%d is the smallest of the three" %a
elif b<a and b<c:
print "%d is the smallest of the three" %b
elif c<a and c<b:
print "%d is the smallest of the three" %c
else:
print "you're fucked"
#number 2: largest odd number
if a%... | true |
8da9ad9d4b79039461d66d8e4535ea7f76aa6382 | Python | sashakrasnov/datacamp | /30-case-studies-in-statistical-thinking/5-earthquakes-and-oil-mining-in-oklahoma/04-how-to-display-your-analysis.py | UTF-8 | 1,193 | 3.984375 | 4 | [] | no_license | '''
How to display your analysis
In the last three exercises, you generated a plot, computed means/confidence intervals, and did a hypothesis test. If you were to present your results to others, which of the following is the most effective order of emphasis, from greatest-to-least, you should put on the respective res... | true |
e8b1092fb0eb44e7c8394074c7af1cfbe335de48 | Python | kotarCreative/usort | /usort/sorting.py | UTF-8 | 14,761 | 2.6875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import sys
from dataclasses import dataclass, field
from pathlib import Path
from typing import Dict, Iterable, List, Optional, Sequence, Tupl... | true |
756b320457f2a4761d8e2bbcef14bdcf9f5c49b8 | Python | nfredrik/pyjunk | /pipes/gen_million.py | UTF-8 | 223 | 2.546875 | 3 | [] | no_license | #!/usr/bin/env python
import time
if __name__ == '__main__':
pipe = open('/dev/pts/3', 'w')
cntr = 1000000000
while --cntr > 0:
# time.sleep(1)
pipe.write('A' *400)
pipe.flush()
| true |
78f876fbd1f7c7651db35745be2d3bb6e0befa71 | Python | zoharmilul/ex8 | /test_nonogram.py | UTF-8 | 1,720 | 2.59375 | 3 | [] | no_license | import nonogram
def test_can_fill():
assert nonogram._can_fill([0,0,0,0,0],2,0) == True
assert nonogram._can_fill([1, 1, 0, 0, 0], 2, 3) == True
assert nonogram._can_fill([0, 0, 0, 0, 0], 7, 0) == False
assert nonogram._can_fill([1, 1, 1, 0, 0], 1, 4) == True
assert nonogram._can_fill([1,1,1,1,0], ... | true |
75fab578fa61a7071e9ddd4ab28eb4c5b61a1e35 | Python | chingfanghsieh/google-api | /pytrends_test.py | UTF-8 | 1,975 | 2.875 | 3 | [] | no_license | from pytrends.request import TrendReq
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
import pandas as pd
import matplotlib.ticker
kw_list = []
pytrend = TrendReq(hl='zh-TW', tz=1200)
num = int(input(print("請輸入要查幾個關鍵字(最多5個)")))
for i in range (num):
keywords = str(input(print("請... | true |
546a2a0998f20d687255e5c664fc84252fb18e63 | Python | egalistmir/PDE | /heatequation.py | UTF-8 | 974 | 2.640625 | 3 | [] | no_license | #import modules
import fenics as fex
import matplotlib.pyplot as plt
import numpy as np
#initializing variables
#declaring parameters
alpha = 3
beta = 1.2
u_D = fex.Expression('1 + x[0] * x[0] + alpha * x[1] * x[1] + beta * t', degree = 2, alpha = alpha, beta = beta, t =0)
u_D.t = t
def boundary(x, on_boundary):
... | true |
ec0196d5865162d3819934736f441e01884c9bdd | Python | ModoUnreal/Breakout | /constants.py | UTF-8 | 988 | 2.625 | 3 | [] | no_license | import pygame as pg
import os
"""HARDCODED CONSTANTS"""
WIDTH = 800
HEIGHT = 600
FPS = 60
SCREEN = pg.display.set_mode((WIDTH, HEIGHT))
"""COLORS"""
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
ORANGE = (255, 165, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
"""IMG DIRECTORY"""
BLUE_DIR = os.path.join("... | true |
77c6376cce443e9a6d31392a8269778d66e834e8 | Python | yxzf/cnn-text-classification-mx | /cnn_text.py | UTF-8 | 1,820 | 2.515625 | 3 | [] | no_license | import data_helpers
import numpy as np
import models
import mxnet as mx
import logging
def preprocess():
x, y, vocab, vocab_inv = data_helpers.load_data()
vocab_size = len(vocab)
# randomly shuffle data
np.random.seed(10)
shuffle_indices = np.random.permutation(np.arange(len(y)))
x_shuffled =... | true |
86fc92141d1296d2157f3099bf266bc77bddb7f1 | Python | dexity/bikespot | /app/views.py | UTF-8 | 1,306 | 2.71875 | 3 | [] | no_license | from flask import render_template, request, jsonify
from . import app
from .api import DirectionsAPI
from .models import Parking, get_nearest, point2latlng
@app.route("/")
def index():
return render_template("index.html", api_key=app.config["GOOGLE_MAPS_KEY"])
@app.route("/directions")
def directions():
"Ret... | true |
b966164326e4fa47be142c4df4fc8b95a5f4f86c | Python | XeniaAllayarova/TAOI | /Классификация-2.py | UTF-8 | 4,711 | 2.921875 | 3 | [] | no_license | import pandas as pd
from sklearn.tree import DecisionTreeClassifier, plot_tree
from sklearn import metrics, preprocessing
from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier, VotingClassifier
import matplotlib.pyplot as plt
import numpy as np
print("Задание 1\n")
col_names = ['age', 'workclass','fn... | true |
9bb65f809060fb8e2a96f5b639832c31d1d5a756 | Python | DigiChanges/python-experience | /src/Shared/Factories/EncryptionFactory.py | UTF-8 | 518 | 2.546875 | 3 | [
"MIT"
] | permissive | from src.Shared.Encryptions.BcryptEncryptionStrategy import BcryptEncryptionStrategy
from src.Shared.Encryptions.Md5EncryptionStrategy import Md5EncryptionStrategy
from src.Shared.InterfaceAdapters.IEncryption import IEncryption
class EncryptionFactory():
@staticmethod
def create(encryptionConfig: str = "bcr... | true |
c6c82a65468860c995c39c014a165277cc689a5b | Python | ene5135/Algorithm_Study | /kakao_coding_test/kakao_bruteforce_3.py3 | UTF-8 | 1,671 | 3.125 | 3 | [] | no_license | N = ['1','2','3','4','5','6','7','8','9']
def init_set(numbers, count):
result = []
if count == 0:
return [""]
for idx, num in enumerate(numbers):
result += list(map(lambda x: num + x, init_set(numbers[0:idx]+numbers[idx+1:], count-1)))
return result
def get_all_combs(ball_coun... | true |
463beeb41e1870e579572e6688ac92cee0c7f9ef | Python | tingansob/JavaHomework | /java1/sandbox/python/imput.py | UTF-8 | 270 | 4.0625 | 4 | [] | no_license | #!/usr/bin/python3
myname = input('What is your name? ')
print('Hello '+ myname)
print(myname + ', let\'s add two numbers!')
a = input('Enter the first number: ')
b = input('Enter the second number: ')
c = int(a) + int(b)
print('The total of a & b is ' + repr(c))
| true |
3d1aa05ffb7cca3061050c8efde319defcdbe15b | Python | Aishwaryasasanapuri/Azure-ML-Capstone-Project | /train.py | UTF-8 | 2,413 | 2.546875 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license.
from sklearn.linear_model import Ridge
from sklearn.metrics import mean_squared_error
from sklearn import __version__ as sklearnver
#from packaging.version import Version
from sklearn.linear_model i... | true |
e923b05d6438103c25f72eee20f14ffa549f71f1 | Python | hnrkcode/game-of-life | /gameoflife/pattern/blueprint.py | UTF-8 | 1,272 | 3.03125 | 3 | [
"MIT"
] | permissive | import os.path
import string
from gameoflife.settings import PATTERN_LIST
def get_patterns():
"""Read patterns from text file."""
count = 1
patterns = {}
with open(PATTERN_LIST, "r") as patterns_file:
name = None
layout = []
for line in patterns_file:
# Ignore ... | true |
3d6ff24544f404410fdcc0da76a1422dc94ae2dd | Python | nik-o-o/tic-tac-toe | /Tic-tac-toe_PROJECT.py | UTF-8 | 2,896 | 3.6875 | 4 | [] | no_license | import random
#GLOBAL
board = [' ']*10
available = [str(num) for num in range(10)]
players = [0, 'X', 'O'] # player[1] == 'X' and player[-1] == 'O'
def display_board(a,b):
print("AVAILABLE TIC_TAC_TOE\n" +
" MOVES\n\n" +
a[7] + '|' + a[8] + '|' + a[9] + ' ' + b[7] + '|' + ... | true |
e6bfaa2a5bf2aecf0542a8322a5844b5a46351d7 | Python | imhyo/codejam | /bipartite_match.py | UTF-8 | 1,807 | 3.640625 | 4 | [] | no_license | from collections import deque
# Hopcroft Karp's Bipartite Match Algorihm
# This code is based on pseudo code of Wikipedia.
# Time complexity is sqrt(V) * E where V is # of nodes and E is # of edges.
class BipartiteMatch:
def __init__(self, U, V, adj):
self.U = U
self.V = V
self.adj = adj
... | true |
f01ac62d25eba12beb033c2111a9218f2ff36d13 | Python | danielthuku/pythonproject | /Test_2.py | UTF-8 | 1,976 | 3.734375 | 4 | [] | no_license | ''' pqt_drawtext_rotated.py
draw rotated text on the PyQt paint canvas via ...
paint.translate(dx, dy)
paint.rotate(degrees)
paint.drawText(x, y, QString text)
Pen and Brush set drawing and fill colors
a color can be selected via ...
red = Qt.red
or r,g,b values 0 - 255
red = QColor(255, 0, 0)
or some colors have name... | true |
4ea5a569fe780d3b18c9af5ea0b4fb1ef877f1f5 | Python | alimogh/coinex-tiny-api | /coinex.py | UTF-8 | 2,925 | 2.625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#doc:https://github.com/coinexcom/coinex_exchange_api/wiki/
import time
import hashlib
import json
import requests
class Client(object):
def __init__(self,access_id,secret_key):
self.access_id = access_id
self.secret_key = secret_key
... | true |
8af1818ef2e020fa3aa464a83c1ac9f4625e3d28 | Python | YJedu1342/109021060-yujian | /test.py | UTF-8 | 60 | 3.3125 | 3 | [] | no_license | a=int(input())
i=0
while a>10:
i+=1
a=a//10
print(i) | true |
18d377100abf4614493f53971fb60661ff1f079f | Python | Kalyan-Amarthi/100-days-python | /6.py | UTF-8 | 611 | 3.65625 | 4 | [] | no_license | '''import math
#n=int(input("enter"))
#i=2
while i<=abs(int(math.sqrt(n))):
if n%i==0:
print(n,'is not a prime')
break
i+=1
else:
print(n,"is a prime")'''
'''a,b,c=map(int,input("enter the number").split())
print(a+b+c)'''
'''s=int(input())
r=int(input())
n=int(input())
... | true |
a1a95afcf87f94097e7d1d0c75a413688f4aa69f | Python | alvin777/alfa-elba-converter | /alpha_csv_to_1c.py | UTF-8 | 2,336 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import csv
import codecs
import pprint
# import sys
# import os
# sys.stdout = codecs.getwriter('utf8')(sys.stdout)
# print os.environ["PYTHONIOENCODING"]
class UTF8Recoder:
"""
Iterator that reads an encoded stream and reencodes the input to UTF-8
"""
d... | true |
4cfb00eeb6752d208a1532875fcbbd9b330080a7 | Python | jhu-lcsr/good_robot | /debug.py | UTF-8 | 1,570 | 2.78125 | 3 | [
"BSD-2-Clause"
] | permissive | #!/usr/bin/env python
import numpy as np
import time
from robot import Robot
# User options (change me)
# --------------- Setup options ---------------
tcp_host_ip = '100.127.7.223' # IP and port to robot arm as TCP client (UR5)
tcp_port = 30002
workspace_limits = np.asarray([[0.3, 0.748], [-0.224, 0.224], [-0.255, ... | true |
bb3da64563bfaefffe4cb6a9fb5b564e623ec018 | Python | VaderSV/learn-py | /Lambda/example1.py | UTF-8 | 76 | 2.96875 | 3 | [] | no_license | def transform(n):
return lambda x: x + n
f = transform(4)
print(f(3))
| true |
7c9401a0154c04d19767accd2789b1521f21119d | Python | BogdanFloris/algo-ds-library | /algorithms/graphs/graph.py | UTF-8 | 11,123 | 3.84375 | 4 | [] | no_license | """
Graphs Module
"""
import queue
import sys
from datastructures.heap import MutablePriorityQueue
# Colors used by the search algorithms
WHITE = 0
BLACK = 1
GRAY = 2
class Vertex:
def __init__(self, key):
self.id = key
# map from a neighbour vertex to the weight of the edge
self.connect... | true |
5c5fd84a91a5b69eb7a51b4c86ae152b5c297f0c | Python | Kallehz/Python | /Keppni/FlattenList.py | UTF-8 | 63 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | def flatten(p):
return [ sorted(p).index(x) for x in p ]
| true |
cdc1c7b43bee57f151f40ec8b4a6ab5500690c58 | Python | hers-belgrade/fabric.js_components | /inkscape/make_placeholder.py | UTF-8 | 1,351 | 2.703125 | 3 | [] | no_license | #!/usr/bin/env python
import sys
sys.path.append ('/usr/share/inkscape/extensions')
import inkex
import gettext
from simplestyle import *
_ = gettext.gettext
class MakePlaceholderEffect (inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.OptionParser.add_option('-n', '--name', action = 'store', ... | true |
cecf2ddc0176f5a9445738314d325c2852275667 | Python | bettalazza99/PCS2-Homework-3 | /MinMaxHeap.py | UTF-8 | 2,665 | 3.765625 | 4 | [] | no_license | import heapq
import matplotlib.pyplot as plt
class MinMaxHeap(object):
def __init__(self):
self.content_min=[]
self.content_max=[]
def add(self, value):
heapq.heappush(self.content_min, value)
heapq.heappush(self.content_max, -value)
def get_max(self):
return -self.co... | true |
17fb3537dba888373ff8c9d9bc166964c2b064c6 | Python | 1alexandra/collage | /src/CornerCreator.py | UTF-8 | 3,676 | 3.421875 | 3 | [
"MIT"
] | permissive | import numpy as np
from PIL import Image, ImageFilter
class CornerCreator:
"""Create corners with a given curvature from ``0`` to ``1``.
Corners size is defined by ``corner_width``.
Type of corners are defined by ``corner_curvature``:
- ``0``: no corners,
- from ``0`` to ``0.5``: hyperbolic conv... | true |
66aacc49de1a966193304ff1723a9253d267596c | Python | Aron-HD/gmail-api | /src/gmail/message.py | UTF-8 | 1,680 | 2.65625 | 3 | [
"MIT"
] | permissive | import logging
from dataclasses import dataclass
from typing import Dict, Union, List, Optional
from abc import ABC, abstractmethod
from base64 import urlsafe_b64decode, urlsafe_b64encode
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
log = logging.getLogger(__name__)
class Mess... | true |
acc949d6ebb8d0c3541b08fe8b5e02444a32148f | Python | panscoding/Natural_Language_Processing_with_Machine_Learning | /1.Word_Embeddings/1.1.vocabulary.py | UTF-8 | 895 | 3.5625 | 4 | [
"Apache-2.0"
] | permissive | import tensorflow as tf
# Skip-gram embedding model
class EmbeddingModel(object):
# Model Initialization
def __init__(self, vocab_size, embedding_dim):
self.vocab_size = vocab_size
self.embedding_dim = embedding_dim
self.tokenizer = tf.keras.preprocessing.text.Tokenizer(num_words=self.v... | true |
dd05c8d844160a3c10b1d8ddebd641c00979ef36 | Python | qilip/ACMStudy | /baekjoon/21610/source.py | UTF-8 | 1,181 | 2.828125 | 3 | [
"CC-BY-4.0",
"CC-BY-3.0"
] | permissive | import sys
input = sys.stdin.readline
n, m = map(int, input().split())
bucket = [list(map(int, input().split())) for _ in range(n)]
mov = [list(map(int, input().split())) for _ in range(m)]
cloud = [[0] * n for _ in range(n)]
cloud[n-1][0] = cloud[n-1][1] = cloud[n-2][0] = cloud[n-2][1] = 1
dirc = [(0, 0), (0, -1), (... | true |
0128a6eb3ae5dd083db15982b7dd364becf34750 | Python | abogaard/combinato | /combinato/basics/arbio.py | UTF-8 | 1,902 | 2.625 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
"""
Basic i/o definitions for Neuralynx files
"""
from __future__ import print_function, division, absolute_import
from os import stat
from datetime import datetime
import re
import numpy as np
# pylint: disable=E1101
i16_type = np.dtype([('data', 'i2')])
class i16File(object):
"""
re... | true |
234b3d4ab03ff508012d1255dec4edd7f83da4d1 | Python | gjbex/training-material | /Python/Interfacing_C_C++_Fortran/Swig/stats_swig.py | UTF-8 | 415 | 2.890625 | 3 | [
"CC-BY-4.0"
] | permissive | #!/usr/bin/env python
import sys
import stats
def main():
n = 100
data = stats.floatArray(n)
for i in range(n):
data[i] = float(i + 1)
data_stats = stats.stats(data, n)
print('mean: {0:.2f}, stddev: {1:.2f}'.format(data_stats.mean,
data_st... | true |
b1781b2269f4fdd9c914beae241a5814730f097f | Python | steder/penzilla | /tutorials/python/modules/book.py | UTF-8 | 1,410 | 4.03125 | 4 | [] | no_license | # Intro To Python: Modules
# book.py
"""
Class: Book( title, author, keywords )
Each book object takes a title, optional author, and optional keywords.
"""
class Book:
def __init__(self, title, author="Unknown", keywords=[]):
"""
Books take three arguments to their constructor
The first a... | true |
32c5675c3782e726f93712705c11f2804167297d | Python | kpedrozag/patrones | /database_file_sg.py | UTF-8 | 1,207 | 3.078125 | 3 | [] | no_license | import sqlite3 as sql
class DB:
ins = None
cur = None
conn = None
def __new__(cls, *args, **kwargs): # crea el objeto pero no lo iniicaliza
if DB.ins is None:
DB.ins = object.__new__(cls)
return DB.ins
def __init__(self): # crea el objeto
if DB.conn is None:
... | true |
65c1d44bf16c93c10b1b5e95d539201fab61dc1b | Python | PI2-2016-2/BEViM-Raspberry-Parser | /routine.py | UTF-8 | 1,776 | 2.859375 | 3 | [] | no_license | #!/usr/bin/python
import time
import threading
from parser import ParserData as Parser
from piserial import PiSerial as Piserial
class routine(threading.Thread):
def __init__(self, threadID, name,flag):
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
self... | true |
38b1f51ab4e60f54f6a1a6481bd70487cb00e9ac | Python | florian-wagner/bert_tools | /stopwatch.py | UTF-8 | 400 | 2.953125 | 3 | [] | no_license | #!/usr/bin/env python
"""
StopWatch
========
Created on Thu Sep 27 11:38:10 2012
by fwagner@gfz-potsdam.de
"""
import time
def start(string="Starting computation..."):
print(string)
global t_0
t_0 = time.time()
def stop():
elapsed = time.time() - t_0
m, s = divmod(elapsed, 60)
h, m = divmo... | true |
39a78bb04c572637dafdbe8ba773cc9f95a5f5c1 | Python | laofang/python_script | /punchtime.py | UTF-8 | 2,282 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | '''
此脚本是通过模拟登陆公司管理系统,来查看打卡时间,可以节省使用浏览器登陆操作的时间
'''
import requests
from bs4 import BeautifulSoup
import base64
import datetime
import time
import http.cookiejar
#如果lxml包没有etree,则需要注意版本,安装相应的.whl
from lxml import etree
ss = requests.session()
#登陆请求页面地址
loginUrl = "http://192.168.15.26/C6/Jhsoft.Web.login/AjaxForLogin.as... | true |
0154d10487b8871e27dcdb2a78b84f1f9b338e14 | Python | rmahfuz/Computer-Vision | /HW08/hw08.py | UTF-8 | 16,917 | 2.765625 | 3 | [] | no_license | import cv2, os
import numpy as np
from scipy import optimize
path = '../Users/rmahfuz/Desktop/661/HW08/'
#====================================================================================================
def homogeneous_from_polar(x):
pt1 = [x[0]*np.cos(x[1]), x[0]*np.sin(x[1]), 1.0]
pt2 = [pt1[0]+100... | true |
142e58d9d9f882274702f3208378714cbe7426af | Python | ohdnf/algorithms | /acmicpc/10828_스택.py | UTF-8 | 582 | 3.046875 | 3 | [] | no_license | import sys
input = lambda: sys.stdin.readline().rstrip()
res = list()
n = int(input())
for _ in range(n):
cmd, *num = input().split()
if cmd == 'push':
res[len(res):] = [int(num[0])]
elif cmd == 'pop':
print(res.pop() if res else -1)
elif cmd == 'size':
print(len(res))
elif... | true |
a9f291fffd49da522a63c489922140fdf43b894d | Python | chenxu0602/LeetCode | /non_leetcode/No8_remove_minimum_parenthesis_make_valid_string_facebook.py | UTF-8 | 2,605 | 3.84375 | 4 | [] | no_license | #!/usr/bin/python
# coding=utf-8
################################################################################
'''
https://leetcode.com/discuss/interview-question/124551/
Given a string str consisting of parentheses (, ) and alphanumeric characters.
Remove minimum number of paranthesis to make the string valid and ... | true |
9ced4336b1227bb038c0e0e48629fb2ae8c4e0ea | Python | smokydash/Mycaptian- | /filename.py | UTF-8 | 214 | 2.953125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Fri Aug 6 22:55:37 2021
@author: gitam
"""
filename= input("input filename:")
f_extns=filename.split(".")
print ("extension of the file is:"+repr(f_extns[-1]))
| true |
361e061f0e8ab0d2e02bd59ce80b1bfe49a6e3ff | Python | WhaleChen/python_toolbox | /json_decoding_skill.py | UTF-8 | 284 | 3.109375 | 3 | [] | no_license | # Specializing JSON object decoding
import json
def as_complex(dct):
if '__complex__' in dct:
return complex(dct['real'],dct['imag'])
return dct
a_complex = json.loads('{"__complex__": true, "real": 1, "imag": 2}',
object_hook=as_complex)
print(a_complex)
| true |
cf012b6a7e30d4b0c2f44c736b01905e636c38e0 | Python | LadySalazar/SimuladorOrbitasPlanetarias | /test.py | UTF-8 | 1,559 | 3.359375 | 3 | [] | no_license | '''
*Universidad Sergio Arboleda
*Autores: Lady Geraldine Salazar Bayona
Fecha:6 Mayo 2021
Computación Paralela y Distribuida
'''
import simulador
import cy_simulador
import time
################################# Inicializar Python
py_sun = simulador.Body()
py_sun.name = 'Sun'
py_sun.mass = 1.98892 * ... | true |
576ef3c32062f85b5d0b9f623285376e128e7332 | Python | muskankumarisingh/function_2 | /atm if else.py | UTF-8 | 1,495 | 2.75 | 3 | [] | no_license | print('welcome to ATM')
print('swip your card here')
language=input('enter your language:')
pin=int(input('enter pin to process:'))
cash==50000
if language=='English':
if pin==4353:
print('choose your transaction:')
transaction=input('enter the transaction')
account_type=input('enter account type:')
if transac... | true |
e2dd48bd907d017ad5ea8719ad5d24e3092864da | Python | johndpope/combustion | /tests/test_combustion/test_vision/test_filters/test_gaussian.py | UTF-8 | 1,630 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import timeit
import pytest
import torch
from kornia.filters import GaussianBlur2d as KorniaGaussianBlur
from packaging import version
from combustion.vision.filters import GaussianBlur2d
has_torch18 = version.parse(torch.__version__) > version.parse("1.7.1")
@pytest... | true |
db02f6c4807d5766dff76b52b778f773acbdff67 | Python | evinlort/scheduler | /scheduler_scripts/printer.py | UTF-8 | 135 | 3.234375 | 3 | [] | no_license |
import time
print("I am a printer!")
def main():
print("In MAIN")
time.sleep(65)
print("I waked up and exit")
main()
| true |
8ece3eb0d412814738a29ea4690d700dc9d6bdab | Python | rtloftin/HAL | /navigation/visualization.py | UTF-8 | 4,545 | 2.765625 | 3 | [] | no_license | import pyglet as pg
import matplotlib.pyplot as pl
from .sensor import Occupancy
from .environment import Action
def visualize(env, sensor, task=None, expert=None):
"""
Starts an graphical, interactive simulation of the given navigation environment.
Uses the Pyglet game engine.
"""
# Select the... | true |
978dbde7d29ba3f4740c799891872da3c38a8c51 | Python | HaminKo/codingbat | /warmup-2/last2.py | UTF-8 | 478 | 3.96875 | 4 | [] | no_license | def last2(str):
"""
Given a string, return the count of the number of times that a substring length 2 appears in the string and also as the last 2 chars of the string, so "hixxxhi" yields 1 (we won't count the end substring).
"""
if len(str) < 2:
return 0
last2 = str[-2:]
count = 0
for i in range(len(str) - 2)... | true |
ee051c186ad8a864d445f4565a03280809af3bdd | Python | edospadoni/inventors-wall | /scraper.py | UTF-8 | 802 | 2.71875 | 3 | [] | no_license | #!/usr/bin/python
from requests import get
from bs4 import BeautifulSoup
import re
r = get('https://en.wikipedia.org/wiki/List_of_inventors')
soup = BeautifulSoup(r.content, 'lxml')
for lel in soup.select('div[class="mw-parser-output"] ul li'):
if len(lel.text.split(", ")) > 1:
text = lel.text.replace(u'\... | true |
26e68d5ba9c52cf5987dac1b98be4b8df94fd3e5 | Python | alinobari/text-compression | /mtfcoding2.py | UTF-8 | 9,062 | 3.171875 | 3 | [] | no_license | # #!/opt/bin/python3
import os
import sys
import binascii
import re
def encode(xx):
W = []
X = []
Z = []
f = open(xx, 'r')
ww = f.read() #read the file
x = 0
word = '' #empty word used to add letter to it, then add word to list
while x < len(ww):
word = '' ... | true |
8911de6b417278f801bd6eafab403e6a1efd0140 | Python | noooorfatima/The-Bridge | /lemmatizer/forms.py | UTF-8 | 2,675 | 2.84375 | 3 | [] | no_license | from django import forms
from django.db import models
from django.core.files.storage import FileSystemStorage
import random
from lemmatizer.models import lemmmatizer, formatlemmatizedtext
def romanMath():
try:
correct = False
while (correct == False):
romanNum = ['0','I', 'II', 'III... | true |
a45d3545f28891e68916f24bcdcde225b5006b36 | Python | pauldmccarthy/win-pytreat | /getting_started/03_file_management/.solutions/write_your_own_os_path_splitext.py | UTF-8 | 859 | 3.4375 | 3 | [] | no_license | def nifti_splitext(path, exts=None):
"""Splits the given path, assumed to be a NIFTI file, into its
prefix and suffix components.
:arg path: Path to split
:arg exts: List of recognised file extensions. Defaults to
`['.nii', '.nii.gz']`, but can be overridden.
:returns: A tuple cont... | true |
9ac41656238de962a90e92591f4bac4df47427e9 | Python | Lakshmisudhakarreddy/fundamentals-of-python | /to calculate compound interest.py | UTF-8 | 250 | 3.5625 | 4 | [] | no_license | #write a program to P,T,R and calculate compound interest
p=float(input("enter principle amount:"))
t=float(input("enter time period:"))
r=float(input("enter rate:"))
CI=p*(1+r/100)**t #compound interest=P(1+1/r)^t
print("compound interest:",CI) | true |
76e9f112cda884e622ea51f4e5482cdb2606502c | Python | Aasthaengg/IBMdataset | /Python_codes/p02682/s639773007.py | UTF-8 | 202 | 2.671875 | 3 | [] | no_license | def score():
A,B,C,K = list(map(int,input().split()))
if K<A+B:
if K<A:
print(K)
return
print(A)
return
print(A-(K-A-B))
return
score()
| true |
ad0ed903c3bb93757f96f86ec5323498b71c82a2 | Python | OSSSP/RESim | /simics/ida/findBlocks.py | UTF-8 | 925 | 2.546875 | 3 | [] | no_license | import json
''' create a file with one line per function containing a list of each of the function's
basic blocks
'''
fname = get_root_filename()
funs_fh = open(fname+'.funs')
fun_json = json.load(funs_fh)
blocks = {}
for fun in fun_json:
fun_addr = int(fun)
print('name %s 0x%x' % (fun_json[fun]['name'], ... | true |