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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
eae4c1adc77a1774f42e73aacef024f969c44f06 | Python | gunzigun/Python-Introductory-100 | /47.py | UTF-8 | 482 | 4.125 | 4 | [] | no_license | # -*- coding: UTF-8 -*-
"""
้ข็ฎ๏ผไธคไธชๅ้ๅผไบๆขใ
็จๅบๅๆ๏ผๆ
"""
def exchange(a,b):
a,b = b,a
return (a,b)
"""
if __name__ == '__main__':
x = 10
y = 20
print 'x = %d,y = %d' % (x,y)
x,y = exchange(x,y)
print 'x = %d,y = %d' % (x,y)
"""
A = int(raw_input("please input A:"))
B = int(raw_input(... | true |
b6bfac492780baa41f0465cbf9317648bd0dfdb0 | Python | kitsuneninetails/python-utils | /python_utils/tests/utils/test_utils.py | UTF-8 | 279 | 2.8125 | 3 | [] | no_license | import unittest
def run_unit_test(test_case_name):
suite = unittest.TestLoader().loadTestsFromTestCase(test_case_name)
try:
unittest.TextTestRunner(verbosity=2).run(suite)
except Exception as e:
print('Exception: ' + e.message + ', ' + str(e.args))
| true |
fa2ba6a4346bd244249fc73775afffe5d14ca949 | Python | Lamppost122/Controlled-assessment-Final | /AddTeam.py | UTF-8 | 12,279 | 2.796875 | 3 | [] | no_license | import json
import tkinter as tk
from tkinter import font as tkfont
from tkinter import messagebox
from tkinter import ttk
from Gui import *
import Config
class AddTeam :
"""
Method:
SaveTeam
GetPlayer
updateListboxes
MovePlayer
RemovePlayer
Variab... | true |
755e74b8993de8389e4c4e4337b710e438f8520d | Python | mo1233/floor | /les 4/Pe 1.py | UTF-8 | 251 | 3.375 | 3 | [] | no_license | leeftijd = eval(input('Geef u leeftijd: '))
Paspoort = (input('bent u in bezit van een Nederlandse Paspoort?: '))
if leeftijd >= 18 and Paspoort =='ja' :
print('Gefeliciteerd je mag stemmen')
else :
print('je mag nog niet stemmen')
| true |
a32ded4ecfe0af9b5dcb304f5a896dc6a9d1981a | Python | Garretming/cocos2dx-lua-tools | /tools/python/cocosstudio/parseText.py | UTF-8 | 3,929 | 2.625 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding: UTF-8 -*-
def parse(node,array):
isRichText = False
string = ''
if (array.get('UserData') != None and array.get('UserData') != ''):
UserData = array['UserData'].lower()
if UserData.find('richtext') >= 0:
isRichText = True
if (isRichText):
... | true |
837950768b7508aa6da9895b916fc31821980053 | Python | keesvanginkel/OSdaMage | /preproc_functions.py | UTF-8 | 4,847 | 2.796875 | 3 | [
"MIT"
] | permissive | """
Preprocessing functions of OSdaMage 1.0.
Contains the preprocessing functions required for running the OSdaMage model. The functions are called from a Jupyter Notebook 'Preproc_split_OSM.ipynb'
This code is maintained on a GitHub repository: github.com/keesvanginkel/OSdaMage
@author: Elco Koks and Kees van ginke... | true |
dd611ce6333cadf48311b1d94884adcb6e543a3d | Python | heitorchang/learn-code | /battles/challenges/dwarvenTreasure.py | UTF-8 | 3,464 | 3.015625 | 3 | [
"MIT"
] | permissive | def checkinvalidchars(s):
s = s.upper()
return "J" in s or "K" in s or "Q" in s or "V" in s
def compress(s):
return "".join(sorted(set(s)))
commands = "NORTH SOUTH EAST WEST ONE TWO THREE FOUR SIX EIGHT NINE TEN"
tomb_message = "HERE LIES THE EXALTED DWARF KING DWALIN THE FOURTH"
print(set(co... | true |
05939965b4b81719bd62d478a43910477044b606 | Python | Youka/botlet | /tests/test_utils.py | UTF-8 | 1,137 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | """ Test internal utilities """
from os import chmod
from os.path import isdir, isfile
from stat import S_IREAD
from unittest import TestCase
from botlet.utils import SafeTemporaryDirectory, SafeQueue
class TestUtils(TestCase):
""" Test suite for utility methods """
def test_tempdir(self):
""" Check a... | true |
dd18149260890d47f70cfae065c2712074df7d29 | Python | SSKim76/Python_OpenCV | /OpenCV/49_Background_Subtraction.py | UTF-8 | 3,547 | 3.0625 | 3 | [] | no_license | """
49๊ฐ. ์์์์ ๋ฐฐ๊ฒฝ์ ๊ฑฐํ๊ธฐ
๋ฐฐ๊ฒฝ์ ๊ฑฐ๋ ๋ง์ ์ข
๋ฅ์ ๋น์ ๊ธฐ๋ฐ ์ดํ๋ฆฌ์ผ์ด์
์์ ํ์ฉ๋๋ ์ฃผ๋ ์ ์ฒ๋ฆฌ ํ๋ก์ธ์ฑ ๊ณผ์
CCTV ์ ๊ฐ์ ๊ณ ์ ๋ ์นด๋ฉ๋ผ๋ฅผ ์ด์ฉํด์ ์ถ์
ํ๋ ๋ฐฉ๋ฌธ๊ฐ ์๋ฅผ ๊ณ์ฐํ๋ ํ๋ก๊ทธ๋จ์ด๋, ๊ตํต๋ ์กฐ์ฌ๋ฅผ ์ํ ํ๋ก๊ทธ๋จ์์ ํ์ฉ
๋ณดํต ๊ณ ์ ๋ ์นด๋ฉ๋ผ์์ ์ดฌ์ํ๋ ์์์ ๊ฒฝ์ฐ, ๋ฐฐ๊ฒฝ์ด ๋๋ ๋ถ๋ถ์ ์์ง์ด์ง ์๋ ์ ์ง์์์ด๊ณ , ์ถ์
ํ๋ ์ฌ๋์ด๋ ์๋์ฐจ๋ฑ์ ์์ง์ด๋ ๊ฐ์ฒด
๋ฐ๋ผ์ ๊ธฐ์ ์ ์ผ๋ก ๋ฐฐ๊ฒฝ์ ๊ฑฐ๋ ์ ์ง๋ ๋ถ๋ถ์์ ์์ง์ด๋ ๋ถ๋ถ๋ง ์ถ์ถํ๋ฉด ๊ฐ๋ฅํจ.
์์ง์ด๋ ๊ฐ์ฒด์ ๊ทธ๋ฆผ์๊ฐ ํฌํจ๋์ด ์์ผ๋ฉด ๋ฐฐ๊ฒฝ์ ์ถ์ถํ๋์ผ์ด ๋ณต์กํด์ง.... | true |
527bfead7139ccf94563487642fb91083daf0eb5 | Python | HSabbir/Python-Challange | /day 7.py | UTF-8 | 180 | 3.390625 | 3 | [] | no_license | # counting bus system carries people per year
daily_carry = 1200000
yearly_carry = 0
for i in range(365):
yearly_carry +=daily_carry
print(yearly_carry)
#print(365 * 1200000) | true |
5b0b1c5991569e57b7239a7f72474f75c4e6108c | Python | jscheiber22/lazylister | /lazylister/lazylister.py | UTF-8 | 1,243 | 3.78125 | 4 | [
"MIT"
] | permissive | # I always have to write custom code to pull items off of a text document list, so this will be a nice little
# auto list creator "library" to return each individual line of a text document as its own element in a list.
# Written by James Scheiber, 4am 9/19/2020 :)
class Lister:
def __init__(self, filePath = "list... | true |
1c1d1021ef5628ef581a6af729a8c662a917caf3 | Python | mendovitskaya/autotests_stepik_homework | /lesson2_list.py | UTF-8 | 613 | 2.859375 | 3 | [] | no_license | from selenium import webdriver
import math
link = "http://suninjuly.github.io/selects2.html"
browser = webdriver.Chrome(executable_path = '/Users/mendovitskaya/environments/selenium_env/Scripts/chromedriver')
browser.get(link)
x_element = browser.find_element_by_id("num1")
x = x_element.text
y_element = browser.find_... | true |
1b867d819adf765eb0c1686d2e2506a7a7289174 | Python | jnottin/bookClub | /bookClub_project/views.py | UTF-8 | 2,939 | 2.734375 | 3 | [] | no_license | from django.shortcuts import render
from .models import Book
import requests
from random import randint
# from functions import getCover
# import functions as f
# Create your views here.
nyt_apiKey = 'i2gBHvKpbi0ZxGtoRAzX85JBi8iOot7t'
googleBooks_apiKey ='AIzaSyDs_cKUw7nk8l-QIVUVwyPlx1a3aRo_s2Q'
background_colors = ['... | true |
c69f1bfb039af6c86956641c4f6f2a5dcb2d438a | Python | YuzhenWANG/kaggle-KDD | /volume_info_pretreat.py | UTF-8 | 8,152 | 2.640625 | 3 | [] | no_license | # rewrite volume info pretreat file
# save all volume info into a good matrix
import numpy as np
import pandas as pd
from datetime import datetime,timedelta
from matplotlib import pyplot
import seaborn
import statsmodels.api as sm
from sklearn.model_selection import KFold
# step 1 : change table 6 rural data into 20 ... | true |
3d0503b3be6fd54a6cd036d0711bc79ed05f2f17 | Python | brandoneng000/LeetCode | /medium/921.py | UTF-8 | 590 | 3.578125 | 4 | [] | no_license | class Solution:
def minAddToMakeValid(self, s: str) -> int:
stack = []
for p in s:
if p == "(":
stack.append(p)
elif not stack and p == ")":
stack.append(")")
elif stack[-1] == "(" and p == ")":
stack.pop()
... | true |
0b035fc5168d98069a11bfd330cd03541c5583a5 | Python | t-ye/pysha3 | /hw5/utils.py | UTF-8 | 580 | 3.484375 | 3 | [
"MIT"
] | permissive | def expcount(base, modulus=None, coeff=1) :
"""
Yield coeff, coeff*base, coeff*(base**2), ...
"""
if modulus != None :
exp = coeff % modulus
else :
exp = coeff
while True :
yield exp
if modulus != None :
exp = (exp * base) % modulus
else :
... | true |
43ff17579a95811026c9f8e69ee0cf100edfe977 | Python | lengmoXXL/code-repo | /2019/9/random_file_image_gen.py | UTF-8 | 855 | 3.109375 | 3 | [] | no_license | import random
from PIL import Image
from io import BytesIO
def generate_random_file(size=random.randint(5000, 10000)):
ret = BytesIO()
for _ in range(size):
ret.write(random.randint(0, 255).to_bytes(1, byteorder='little'))
ret.seek(0)
return ret
def generate_random_picture(height=random.randin... | true |
7c6793b531a2b2fe6dad7818f50649b5e4b5c9fa | Python | Safery/RSX-Tracker | /v0.0/RSX_TrackerV2.py | UTF-8 | 4,286 | 2.71875 | 3 | [
"MIT"
] | permissive | import matplotlib.pyplot as plt
from matplotlib.offsetbox import TextArea, DrawingArea, OffsetImage, \
AnnotationBbox
from matplotlib.cbook import get_sample_data
import matplotlib.image as mpimg
import numpy as np
fig, ax = plt.subplots()
class RSX_Mapper():
'''Initiate RSX_Mapper Class'''
def __i... | true |
21609beae7007d6a4eece82362be724754d7a535 | Python | TrevistoAG/DigitalFestival2019-DeepReinforcementLearning | /__main__.py | UTF-8 | 2,034 | 2.59375 | 3 | [] | no_license | import argparse
from agents import *
FLAGS = None
def main(FLAGS):
agent = PPO2(FLAGS)
if FLAGS.train == True:
print('---- TRAIN ----')
agent.train(game=FLAGS.game, state=FLAGS.state,num_e=FLAGS.envs)
if FLAGS.eval == True:
print('---- EVAL ----')
agent.evaluate(game=FLAGS... | true |
fd9b81a23f258ada1d668bdaee68bce64ddb7347 | Python | Shubzedm007/ShowCase | /BMI Calculator/BMI calculator.py | UTF-8 | 2,242 | 3.25 | 3 | [] | no_license | print('Welcome to my BMI scanner and workout planner')
print('Are you ready?')
answer = str(input())
if answer == 'yes':
print('lets get some measurements!')
print('what is your height in meters?')
height = float(input())
print('what is your weight in Kg?')
weight = float(input())
chest... | true |
bc896cc30fac89d9aa0efccb14c03f46c3122012 | Python | GiuliaSim/Community_Prediction | /csv_from_user_infos.py | UTF-8 | 924 | 2.578125 | 3 | [] | no_license | from pyspark.sql import SparkSession
from pyspark.sql.functions import explode, avg, col, count
spark = SparkSession \
.builder \
.appName("BigData") \
.config("spark.mongodb.input.uri", "mongodb://127.0.0.1/BigData.user_infos") \
.getOrCreate()
df_user_infos = spark.read.format("com.mongodb.spark.sql.De... | true |
26652cbfdaaa91eb630398872230f235b4d77827 | Python | Nikkuniku/AtcoderProgramming | /ABC/ABC200~ABC299/ABC240/d.py | UTF-8 | 360 | 2.78125 | 3 | [] | no_license | n=int(input())
a=list(map(int,input().split()))
from collections import deque
d=deque()
ans=0
last=-1
for i in range(n):
if last==a[i]:
d[-1][1]+=1
ans+=1
if d[-1][1]==a[i]:
ans-=d[-1][1]
d.pop()
else:
d.append([a[i],1])
ans+=1
last=-1
if... | true |
d93106a57a1e42fdc3cc8e959c66a5d73f8f672f | Python | Cphayim/learn-py | /src/package/decorate/c1.py | UTF-8 | 211 | 3.546875 | 4 | [] | no_license | import time
# ๅผ้ญๅๅ๏ผๅฏนไฟฎๆนๆฏๅฐ้ญ็๏ผๅฏนๆฉๅฑๆฏๅผๆพ็
def f1():
print('This is a function')
def print_current_time(func):
print(time.time())
func()
print_current_time(f1)
| true |
b74261a22c483427091e8c9fbdf99f1ebc7e5466 | Python | althetinkerer/price-comparison-app | /API/app.py | UTF-8 | 4,000 | 2.75 | 3 | [] | no_license | from flask import Flask, jsonify, request
from flask_cors import CORS, cross_origin
import re
import requests
import json
# Read from config.json file
with open('config.json') as f:
config = json.load(f)
f.close()
app = Flask(__name__)
CORS(app)
def physicalPrices(upc):
value = {'target': 'Product not... | true |
752a3df3e91b6647158afa6d92d16f936db7c2a8 | Python | khs50851/git-crawling | /section02_1/section02_1/spiders/class02_1.py | UTF-8 | 1,195 | 3.234375 | 3 | [] | no_license | import scrapy
class Class021Spider(scrapy.Spider):
name = 'test2'
allowed_domains = ['blog.scrapinghub.com']
start_urls = ['https://blog.scrapinghub.com/']
def parse(self, response):
"""
:param : response
:return : Title Text(์ ๋ชฉ ํ
์คํธ ๋ฆฌํดํ ๊ฑฐ)
"""
# 2๊ฐ์ง(CSS Selector... | true |
3e6a9694d8d10ebd0884779ab2defc8a788be814 | Python | jnlorenzi/rRNA_Evolution_2022 | /make_ani.py | UTF-8 | 2,613 | 3.109375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
import os
import re
import sys
import shutil
import argparse
def parseArguments():
# Create argument parser
parser = argparse.ArgumentParser(description = 'This script computes all the pairwise ANIb for each genome in the given repository (sequence must be in fasta format). \n\t # Comm... | true |
7b3b9eb229506e75c63d345689e77a0345f01f87 | Python | sajinchrisantony/pythonprograms | /functionalprogramming/filter.py | UTF-8 | 140 | 3.234375 | 3 | [] | no_license | lst=[2,3,4,5,6]
#even nos
evens=list(filter(lambda num:num%2==0,lst))
print(evens)
odd=list(filter(lambda num:num%2!=0,lst))
print(odd)
| true |
194963bd5509804430a768a920c1cd6840a472a7 | Python | 17111748/Falcon-the-Gym-Pro-Assistant- | /Signal_Processing/legRaiseAnalysis.py | UTF-8 | 6,529 | 2.96875 | 3 | [] | no_license | import numpy as np
import os
expectedHipAngle = 100
parallel = 180
perpendicular = 90
# bodyParts[0] = Shoulder
# bodyParts[1] = Elbow
# bodyParts[2] = Wrists
# bodyParts[3] = Hip
# bodyParts[4] = DefaultKnee
# bodyParts[5] = OtherKnee
# bodyParts[6] = DefaultAnkle
# bodyParts[7] = OtherAnkle
class LegRaiseRes... | true |
602fc46cb419baa4d5b2cc37c1b54d5172f6c685 | Python | Fumipo-Theta/matdat | /matdat/dotdict.py | UTF-8 | 1,472 | 3.40625 | 3 | [
"BSD-2-Clause"
] | permissive |
class dotdict(object):
"""ใชใใธใงใฏใใฐใฉใๅ
ใฎ่พๆธ่ฆ็ด ใใใญใใใฃ้ขจใซใขใฏใปในใใใใจใๅฏ่ฝใซใใใฉใใใผใ
DotAccessible( { 'foo' : 42 } ).foo==42
ใกใณใใผใๅธฐ็ด็ใซใฏใใใใใใจใซใใใใฎๆๅใไธๅฑคใชใใธใงใฏใใซใไธใใใ
DotAccessible( { 'lst' : [ { 'foo' : 42 } ] } ).lst[0].foo==42
"""
def __init__(self, obj):
self.obj = obj
def __repr__(self... | true |
e55a8f002fc22762e4072037f8f82192b28503d1 | Python | trychiOO/python_all | /learn/python_all/porint/xiami.py | UTF-8 | 1,161 | 3.34375 | 3 | [] | no_license | import requests
from lxml import etree
url_ = "https://www.xiami.com/artist?spm=a1z1s.2943549.1110925385.4.PnoO3b"
headers_ = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87'
}
page_source = requests.get(url=url_, headers=headers_)
print(... | true |
2d2dd61ce5b96f8e41fe17613414983765b65e60 | Python | agneet42/IoT | /Social/user_sensor.py | UTF-8 | 1,305 | 2.796875 | 3 | [] | no_license | import csv
from collections import Counter
f = csv.reader(open('nodes_things.csv','r'))
f2 = csv.reader(open('nodes_things.csv','r'))
f1 = csv.reader(open('nodes_users.csv', 'r'))
arr_t = []
arr_u = []
for rows in f:
value = rows[0]
if(len(value)==3):
arr_t.append(value)
for rows in f1:
arr_u.append(rows[0])
... | true |
168486ce3ce5d866fd1f4314cb2169079f65ef14 | Python | shloch/CODING_PRACTICE | /Python/helloWorldName.py | UTF-8 | 591 | 4.34375 | 4 | [
"MIT"
] | permissive | '''
Define a method hello that returns "Hello, Name!" to a given name, or says Hello, World! if name is not given (or passed as an empty String).
Assuming that name is a String and it checks for user typos to return a name with a first capital letter (Xxxx).
Examples:
hello "john" => "Hello, John!"
hello "aliCE" ... | true |
c00b140241ad2535780bdf25afcfcc5910219727 | Python | mdhvkothari/Python-Program | /simple/stare.py | UTF-8 | 121 | 3.359375 | 3 | [] | no_license | a = int(input("enter the number :"))
for i in range(0,a):
for j in range(0,i+1):
print "*",
print "\n"
| true |
c3723b17ddbe18287baf0bbfc2bb821fd127fc5b | Python | grasshopperTrainer/coding_practice | /baekjoon/accepted/20055 ์ปจ๋ฒ ์ด์ด ๋ฒจํธ ์์ ๋ก๋ด.py | UTF-8 | 2,729 | 2.859375 | 3 | [] | no_license | from sys import stdin
from collections import deque
class Place:
half_len = None
num_broken = 0
convoyer = deque()
def __init__(self, id, dur):
self.id = id
self.__dur = dur
if self.convoyer:
self.convoyer[-1].__next = self
self.__next = self.convoyer[... | true |
daacd9a9fae90982d8464d435fffc7c9097aff98 | Python | MinSu-Kim/python_tutorial | /sqlalchemy_tutorial/tutorialspoint/sqlalchemy_orm_building_relationship.py | UTF-8 | 1,739 | 2.546875 | 3 | [] | no_license | from sqlalchemy import create_engine, ForeignKey, Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, scoped_session, sessionmaker
Base = declarative_base()
class Invoice(Base):
__tablename__ = 'invoices'
id = Column(Integer, primary_key=T... | true |
95e1834e9686882983a7f3d2d61a18d650fd6e02 | Python | texnofobix/python-genbadge | /genbadge/utils_flake8.py | UTF-8 | 6,233 | 2.703125 | 3 | [
"BSD-3-Clause"
] | permissive | # Authors: Sylvain MARIE <sylvain.marie@se.com>
# + All contributors to <https://github.com/smarie/python-genbadge>
#
# License: 3-clause BSD, <https://github.com/smarie/python-genbadge/blob/master/LICENSE>
from __future__ import division
from warnings import warn
import re
from .utils_badge import Badge... | true |
8d3261beaa921b61be8576d1d6f4e6d5d4810cfc | Python | joeyhuaa/Texas-Hold-Em | /poker/Cards.py | UTF-8 | 2,709 | 3.90625 | 4 | [] | no_license | # Card and Deck class definitions
class Card:
# first, the suits and ranks, in order
# note the order is important as it is used to compare
suits = ["c", "d", "h", "s"]
ranks = ["2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K", "A"]
# create a card; default is AS
def __init__(self, ra... | true |
6b4bdf802013bed0645a4985fd95af2eab70996a | Python | riaz4519/python_practice | /programiz/_51_dictonary.py | UTF-8 | 457 | 4.03125 | 4 | [] | no_license | #normal
dict1 = {1:'Geeks',2:'for',3:'geeks'}
print(type(dict1))
#with different type
dict2 = {1:"geek",'name':"Fahim",'rol':5,'List':[1,2,3,5,6]}
#printing a dictonary
for x in dict2:
print(dict2[x])
#creating with dict method
dict3 = dict({1:2,2:"faghi"})
#creating pair
dict4 = dict([(1,3),("FAhim",4)])
... | true |
73523a4d9f45b48b75c2be97a297b425c700ea90 | Python | hiroshikinofu/hoihoi | /hogehoge/python/sura2yomeruPython/chap2/chap2-3-1.py | UTF-8 | 74 | 3.359375 | 3 | [] | no_license | text = input('ๅ
ฅๅใใ')
if text.isdigit():
print('ๆฐๅญใงใ')
| true |
c06d6c3fbb345237e7eb19c97c911c7be9303753 | Python | AmalLRK/Pyhton-Game | /pin.py | UTF-8 | 2,084 | 3.203125 | 3 | [] | no_license | import random
attempts = 0
digit = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
digit_code_v0 = 0
num = 0
def checkPin(guessed_pin) :
global attempts
tab_res = []
initialAttemp()
digit_code = list(digit_code_v0)
mon_tab = []
attempts += 1
print("attempts : ", attempts)
try:
... | true |
16dbf5d6835f377be804282936f5fcd2c2131783 | Python | SummerBigData/Nick-Kyriacou-Repo | /Keras_Practice/Keras_NN.py | UTF-8 | 2,112 | 3.296875 | 3 | [] | no_license | #Purpose: The following code will create a neural network using Keras
#Created by: Nick Kyriacou
#Created on: 7/19/2018
#Importing Packages
import numpy as np
from keras.models import Sequential
from keras.layers import Dense
import struct as st
import gzip
# Reads in MNIST dataset
def read_idx(filename, n=None):
w... | true |
7431f9d9bed79a5312a034a41b2f64b23a24ec90 | Python | dustinfreeman/IglooKitchener | /old/dustin_shadow_example.py | UTF-8 | 1,039 | 2.703125 | 3 | [] | no_license | import viz
from ShadowTheatre import *
ground = viz.add('tut_ground.wrl')
ground2 = viz.add('tut_ground.wrl', pos = (0,0,8), euler = (0,270,0) )
#Add avatar
avatar = viz.add('vcc_female.cfg',pos=(0,0,6),euler=(180,0,0))
avatar.state(5)
SHADOW_RES = 256
#Postion of shadow projector
SHADOW_POS = [0,2,3]
SHADOW_EULER ... | true |
cf10c8d3dc023e7e264b8b6fe5f8b71005707c4c | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_135/1792.py | UTF-8 | 1,255 | 3.140625 | 3 | [] | no_license | #!/usr/bin/python
with open('A-small-attempt0.in') as f:
n_case = int(f.readline())
for case in range(n_case):
x1= 0
x2=0
x3=0
x4=0
d1=[]
d2=[]
first_row = int(f.readline())
data1 = []
data2 = []
for i in range(4):
data1... | true |
25d7397e93a3b8439c215bba517f01f6ba133f4b | Python | souravt/wordsearchpuzzler | /main.py | UTF-8 | 10,763 | 2.625 | 3 | [] | no_license | import random
import string
import numpy as np
import pandas as pd
import pdfkit
import yaml
from PyPDF2 import PdfFileMerger
from time import time
import itertools
gridLen = 12
basepath = "C://Users/sourav/Desktop/book_generation/"
path_wkhtmltopdf = r'C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe'
template_h... | true |
1721a6bc70ed5accd638fff6ea9ef39a1657de50 | Python | petersonprojects/python-exercises | /listExercises/listEx3.py | UTF-8 | 111 | 3.34375 | 3 | [] | no_license | numList = [89,2,17000,105,512,74,7,600]
numList.sort()
print(f'Smallest number in the list is: {numList[0]}') | true |
838bc96d0059758b21c3bbde455a8f7dfd63f4aa | Python | aklefebvere/bobs-book-club-api | /app/DB.py | UTF-8 | 1,315 | 3.53125 | 4 | [] | no_license | import psycopg2
from dotenv import load_dotenv
import os
load_dotenv()
# DB info
URI = os.getenv("DATABASE_URL")
def book_info(id):
"""
Function to query the Postgres table with given book id to return that
book's price and title
Inputs: id - The book id the user is trying to retrieve inf... | true |
7699815f1011918098c33cc11e68e99ec6001504 | Python | vinnis/python-projects | /cards.py | UTF-8 | 2,120 | 3.53125 | 4 | [] | no_license | import random
print ("there are 4 types of deck available to play namely diamond, hearts, club, spades")
nod=input("number of decks you want? ")
naofd=[]
if int(nod)>1:
for i in range(1,int(nod)+1):
naofd.append(input("name of the {} deck you want ".format(i)))
else:
naofd.append(input("name of the ... | true |
a2e42a606e66eaf51d5affdca050f11cd1b3a4ff | Python | SmartFox97/MyLeetCode | /#0310/minimum-height-trees.py | UTF-8 | 3,593 | 3.40625 | 3 | [
"MIT"
] | permissive | from collections import deque
from collections import defaultdict
import collections
class Solution:
def findMinHeightTrees(self, n: int, edges) -> list:
# ็ฎๅๆ ๅๅพ๏ผๅฅ่ทฏๆฏๅปบๅพๅนถ้ๅ
# ๅปบๅพ๏ผ้ปๆฅ่กจ
# ้ปๆฅ่กจไธบmap,ๅ
ถๅผไธบlist,ๅฎ็sizeๅฐฑๆฏๅ
ฅๅบฆๆฐ
if n == 2:
return [0,1]
if n == 1:
retur... | true |
7312f4d72f418a8738e7a7843b35f1ecf6dda933 | Python | rishabhchatterjee/Virtual_Dresser_ComputerVision_OpenCV | /superimpose_api.py | UTF-8 | 4,549 | 2.65625 | 3 | [] | no_license | import cv2
import numpy as np
import math
import copy
class Superimposition(object):
def superimpose(self, jewel_image, user_image, angle, bodyx, bodyy, jewel_length, jewellery_type):
if jewellery_type == 'earring':
jewel_image = self.rescale(jewel_image, self.getscalingfactor(jewel_image, jew... | true |
cbf1708b5a64a01c4426122e5f958f52d22f31c3 | Python | wuxu1019/leetcode_sophia | /medium/twopointer/test_3_Longest_Substring_Without_Repeating_Characters.py | UTF-8 | 2,038 | 3.84375 | 4 | [] | no_license | """
Given a string, find the length of the longest substring without repeating characters.
Examples:
Given "abcabcbb", the answer is "abc", which the length is 3.
Given "bbbbb", the answer is "b", with the length of 1.
Given "pwwkew", the answer is "wke", with the length of 3. Note that the answer must be a substri... | true |
250739c88952e82bd76b8eaf28f4441078b00701 | Python | jinpan/pkb2015 | /v1/tryhard.py | UTF-8 | 4,185 | 3 | 3 | [] | no_license | import re
class Tryhard:
"""
This class handles looking over all the previous actions in a hand
to identify special moves (like 3-bets).
"""
@staticmethod
def study(game,historypak):
"""
Updates game move history given a historypak.
Also determine whether a player has folded.
"""
g = game # For easy ... | true |
6370de506b1d6a0a7090a173c4ba4ec4bc881bec | Python | Bhaveshsadhwani/Test | /ASSESSMENT/Que 23.py | UTF-8 | 218 | 3.046875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Oct 10 17:33:01 2017
@author: User
"""
fo=open("Demo.txt","a")
str=raw_input("Enter the string:")
fo.write(str)
fo.close()
f1=open("Demo.txt","r")
a=f1.readlines()
print a
| true |
d76ca3ab942212216366940792a802ef66d8378a | Python | testTemtProj/OLD_PROJECT | /get/2013/site/getmyad/other/mongostat-analyzer.py | UTF-8 | 1,220 | 2.90625 | 3 | [] | no_license | # encoding: utf-8
# ะกะบัะธะฟั ะฐะฝะฐะปะธะทะธััะตั ัะฐะนะป ั ะปะพะณะฐะผะธ mongostat ะธ ะพะฟัะตะดะตะปัะตั, ัะบะพะปัะบะพ ะฒัะตะผะตะฝะธ ะฑะฐะทะฐ ะดะฐะฝะฝัั
ะฑะตะทะดะตะนััะฒะพะฒะฐะปะฐ
# (ะผะตะฝััะต 10 ะทะฐะฟัะพัะพะฒ ะฒ ัะตะบัะฝะดั). ะะฐ ะดะฐะฝะฝัะน ะผะพะผะตะฝั ะพะดะธะฝ ะทะฐะฟัะพั ะบ ะฟะพะบะฐะทั ัะตะบะปะฐะผั GetMyAd ะดะพะปะถะตะฝ
# ะฟัะพะธะทะฒะพะดะธัั ะพะดะธะฝ ะทะฐะฟัะพั ะบ mongodb, ัะฐะบ ััะพ ััะพ ัะฐะบัะธัะตัะบะธ ะฟะพะบะฐะทะฐัะตะปั ัะฐะฑะพัะพัะฟะพัะพะฑะฝะพััะธ GetMyAd
impor... | true |
c9a20f2c1ddf7abc9fbf4896f0ee03c424d3cacc | Python | marlanbar/academic-projects | /ith-tp1/src/scripter.py | UTF-8 | 1,252 | 2.875 | 3 | [
"MIT"
] | permissive | '''
Objeto que permite crear el script de praat
'''
class Scripter():
def __init__(self, difonosFolder):
self._script = ""
self._cantidad = 1
self._difFold = difonosFolder
def agregarDifono(self, difono):
difFold = self._difFold
script = self._sc... | true |
e59a92e76b7ecb42cff7b5bd2e6e45ad59e5dc1f | Python | rebecca0323/Predicting-Migraines-IAIF | /utils.py | UTF-8 | 1,000 | 3.109375 | 3 | [
"MIT"
] | permissive | import numpy as np
import pandas as pd
def load_and_preprocess_data():
""" Load data from total_diary_migrain.csv file
and return the data matrix and labels
Returns
-------
features - np.ndarray
Migraine data matrix
features_list - list
List of Features in... | true |
ac3c83eaaf8bf84b7c0d5aa127b0b7c2ff35bb9c | Python | yasinshaw/leetcode | /test/n1_test.py | UTF-8 | 310 | 2.734375 | 3 | [] | no_license | import unittest
from n1 import *
solution = Solution()
class MyTestCase(unittest.TestCase):
def test_something(self):
self.assertEqual(solution.twoSum([1, 2, 3, 4], 5), [1, 2])
self.assertEqual(solution.twoSum([1, 3, 5, 6], 6), [0, 2])
if __name__ == '__main__':
unittest.main()
| true |
5c8ccaf37a1cf0db3c6ca247d2dbf79ead698b33 | Python | emmaremy/pill-images | /code/image_segmentation.py | UTF-8 | 4,331 | 2.9375 | 3 | [] | no_license | import numpy as np
import cv2
import scipy.spatial.distance as sp_dist
""" threshold_seg: creates image segmentations using simple thresholding
techniques along with morphological operations.
params:
img - a numpy array containing a 3-channel image
hsv_space - a boolean indicating if the image s... | true |
37df5f7a78ae7cd3b874b8acbc4cec6d80c32fef | Python | PacktPublishing/Hands-On-Deep-Learning-Architectures-with-Python | /Chapter02/first_dfn_keras.py | UTF-8 | 1,528 | 3.3125 | 3 | [
"MIT"
] | permissive | # importing the Sequential method in Keras
import keras
from keras.models import Sequential
# Importing the Dense layer which creates a layer of Deep Feedforward Network
from keras.layers import Dense, Activation, Flatten, Dropout
# getting the data as we did earlier
fashionObj = keras.datasets.fashion_mnist
(trainX... | true |
a0f804fe78b0398c7b18ab2ba7fca66c85cd2e5d | Python | mildrock/weekend | /ๅทฅไฝ/main2.py | UTF-8 | 597 | 2.65625 | 3 | [] | no_license | from openpyxl import load_workbook
def getDataFromExcel(index,obj):
row = list(sheet.rows)[index]
obj["entity"] = row[0].value
obj["entityCheck"] = row[1].value
obj["vendor"] = row[2].value
obj["vendorCheck"] = row[3].value
obj["invoice_number"] = row[4].value
obj["beTax"] = row[5].value
... | true |
0409ae707c1c6f2425b0ffcb185e623eda6fbadc | Python | sasqwatch/SmokeyJab | /framework/modules/hostsfilemod.py | UTF-8 | 1,322 | 2.5625 | 3 | [] | no_license | try:
from framework.main import ModuleBase
except ImportError:
pass
class HostsFile(ModuleBase):
@property
def tags(self):
return ['IntrusionSet5']
@property
def needs_root(self):
return True
@property
def relative_delay(self):
# On a scale of 1 (least) to 100 ... | true |
e6f0906c4a6ccb44aeef965613bbebb57b331c7f | Python | Matthias84/panpy | /pan.py | UTF-8 | 12,306 | 2.78125 | 3 | [] | no_license | import argparse
from datetime import datetime, timedelta
from enum import Enum
import xml.etree.ElementTree as ET
from pathlib import Path
from printy import printy
import re
import sys
"""
PAN.py - Read & analyse XML files of Persรถnlicher Arbeitszeit-Nachweis (PAN)
PAN is a JAVA desktop software to log your working... | true |
f36b8447b65e34e2657e16abdfa6f0d6bfec1556 | Python | miniii222/PythonAlgorithm-Interview | /๋ฌธ์์ด/Problem01_valid-palindrome(my).py | UTF-8 | 398 | 3.609375 | 4 | [] | no_license | #https://leetcode.com/problems/valid-palindrome/
#best
def isPalindrome(self, s: str) -> bool:
s = s.lower()
my = ""
for ss in s :
#isalnlum() -> alphabet๊ณผ ์ซ์๋ง ํํฐ
if ss.isalnum() :
my += ss
return my == my[::-1]... | true |
9647c6a14b3a937384a2a8546913e981634f2223 | Python | naveenk2k/Project-Euler | /P125_PalindromicSums.py | UTF-8 | 1,145 | 4.375 | 4 | [] | no_license | '''
QUESTION: The palindromic number 595 is interesting because it can be written as the sum of consecutive squares: 62 + 72 + 82 + 92 + 102 + 112 + 122.
There are exactly eleven palindromes below one-thousand that can be written as consecutive square sums, and the sum of these palindromes is 4164. Note that 1 = 02 + ... | true |
8556e0a03d660092512c5556fbe0ac5cdb91cc94 | Python | swordey/vitrab | /core/strategies/DEMA.py | UTF-8 | 5,219 | 2.859375 | 3 | [
"MIT"
] | permissive | #! DEMA.py
# Double Exponential Moving Average Strategy
import numpy as np
import pandas as pd
from bokeh.models import ColumnDataSource
from core.strategies.indicators.DEMA import DEMA
from core.strategies.indicators.SMA import SMA
from core.strategies.base_strategy import BaseStrategy
class DEMAConfig:
def __i... | true |
c3534b0552a218c86c689d8ea6698915888f9954 | Python | prusovae/TDM | /test/unit/datasource/model_test.py | UTF-8 | 625 | 2.546875 | 3 | [] | no_license | import unittest
from mock import Mock
from datasource.model import IQDataSource
class TestIQDataSource(unittest.TestCase):
def test_get_list_of_table_names_works(self):
mock_iq_gateway = Mock()
my_iq_ds = IQDataSource(name='ะขะตััะพะฒัะน ะธััะพัะฝะธะบ', gateway=mock_iq_gateway)
data = ['d_entity'... | true |
056224b119eb9610f1bff1da6bbeb940abeb42b4 | Python | gomezvillegasdaniel/ecommerce-api | /src/tests/unit/test_product.py | UTF-8 | 1,360 | 2.65625 | 3 | [] | no_license | from tests.base_test import BaseTest
from models.product_model import ProductModel
class ProductTest(BaseTest):
def setUp(self):
super().setUp()
with self.app_context():
self.product = ProductModel('Product X', 'PieceXYZ123', 100, 75.95)
self.product.save_to_db()
def... | true |
28928a460be9c26bcda770d21c37e364fa040b74 | Python | zarar-shah/Chapter-3-Assignment | /3.31.py | UTF-8 | 440 | 3.8125 | 4 | [] | no_license | print("Name: Zarar Ali Shah")
print("Roll #: 18B-075-CS (A)")
print("Assignment")
print("\n Exercise 3.31\n")
radius = 8
x = float(input("Please enter the x-coordinate: "))
y = float(input("Please enter the y-coordinate: "))
import math
a = math.sqrt((x*x)+(y*y)) < radius
if a ==True:
print("\nAre the... | true |
de005ac7f1068d3c2d474db2ce13833dc748e9ec | Python | miraflynn/Pie3-MiniProject-LineFollower | /receive_data.py | UTF-8 | 2,314 | 3.578125 | 4 | [] | no_license | # ******************************************************************
# * *
# * *
# * Example Python program that receives data from an Arduino *
# * ... | true |
f0cd5013fa92e64ebee7b8b032ac23730fe4d1c2 | Python | KevinGevers/NetComputing | /Manager/manager.py | UTF-8 | 4,502 | 2.828125 | 3 | [] | no_license | import pika
import json
import datetime
from threading import Lock, Event, _start_new_thread
#TODO: Currently the same lock is used for locking access to parking_lot and reservations. Make 2 locks??
POOL_TIME = 10 #Seconds
RESERVATION_DURATION = 60 * 2
'''
This Class is the ParkingLot Manager
ParkingLots at the Mana... | true |
d93dff47152e9cee3480e880d52579f56122edda | Python | urbanskii/UdemyPythonCourse | /secao04/se04E19.py | UTF-8 | 467 | 4.25 | 4 | [] | no_license | """
19 - Leia um valor de volume em litros e apresente-o convertido em metros cรบbicos mยณ. A
fรณrmula de conversรฃo รฉ: M = L/1000, sendo L o volume em litros e M o volume em metros cรบbicos.
"""
def main():
volume_litros = float(input('Digite um valor de volume em litros: '))
volume_m_cubicos = volume_litros/1... | true |
90e7588c9d11bc5156f5416ada05cef9aeac3107 | Python | Tyboon/MOCAD | /A2DI/part2/TP7/code-stub/py/polka/classification/binary.py | UTF-8 | 11,606 | 2.71875 | 3 | [] | no_license | """
Online learner for binary classification.
"""
import sys, os
from numpy import zeros, dot, inf, sqrt, resize, identity, double, array, matrix, append
from numpy.linalg import norm
import time
from polka.common.datasource import BinarySource as Source
from polka.common.alphabet import Alphabet, POS_LAB, NEG_LAB
fro... | true |
7566fafe15bb6cfe5cbbe6e46567d86afef05740 | Python | Penaz91/Glitch_Heaven | /Game/components/triggerableItem.py | UTF-8 | 773 | 2.6875 | 3 | [
"MIT"
] | permissive | # Triggerable Item Component
# Part of the Glitch_Heaven Project
# Copyright 2015-2016 Penaz <penazarea@altervista.org>
import pygame
class triggerableItem(pygame.sprite.Sprite):
def __init__(self, location, pwd, inactive, active, *groups):
super(triggerableItem, self).__init__(*groups)
self.inact... | true |
3127d121f6f06faa85a09de26f6879220b6fd00d | Python | paarubhatt/Assignments | /Fibonacci series.py | UTF-8 | 634 | 4.53125 | 5 | [] | no_license | #Recursive function to display fibonacci series upto 8 terms
def Fibonacci(n):
#To check given term is negative number
if n < 0:
print("Invalid Input")
#To check given term is 0 ,returns 0
elif n == 0:
return 0
# To check given term is either 1 or 2 because series for ... | true |
6c4469b32c5989eaa85c56569be09f3c6a0ae1a8 | Python | onur-kantar/Gold-Price-Analyzer | /Code/Data Scraping/Main.py | UTF-8 | 3,892 | 3.171875 | 3 | [] | no_license | import pandas as pd
import Preprocessing as pre
import Scrape
import Analysis
import WriteToCSV as wcsv
import Augmenter as aug
# Tweet Kazฤฑma ------------------------------------
url = 'https://twitter.com/search?f=live&q=(%23XAUUSD)%20lang%3Aen%20-filter%3Areplies&src=typed_query'
minTweetSiz... | true |
2a6040f3a3f1015f461429326407f04719979046 | Python | Tyyrhjelm/cse210-student-jumper | /jumper/game/New folder (3)/cse210-student-hilo-master (2)[1337]/cse210-student-hilo-master/cse210-student-hilo-master/hilo/game/DisplayGuy.py | UTF-8 | 1,263 | 3.40625 | 3 | [] | no_license | from game.WordBank import word_bank
class board:
def __init__(self) -> None:
self.fails = 0
self.blanks = []
self.word = word_bank.get_word()
i = 0
while i < len(self.word):
self.blanks.append('*')
i += 1
def guy(self):
print(self... | true |
3d129869622c0420dcf703be6f618f7d7d12a7f9 | Python | shahkeval0101/Intelligent-Interview-System | /program/mcq.py | UTF-8 | 1,754 | 3.484375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sun Dec 13 15:12:15 2020
@author: keval
"""
def coding_mcq():
print("Now you will have your Mutltiple choice question test")
print("Each question will have 4 answers and you have to select one ")
print("Here are your questions")
count = 0
ans1 = input("W... | true |
f1a7853542ce32d95d9ce63ccc018c45920b9d61 | Python | tastelessjolt/aarohi | /src/utils.py | UTF-8 | 370 | 2.75 | 3 | [] | no_license | import os
import numpy as np
def convertOggToWav(filespath):
for path, dirs, files in os.walk(filespath):
for file in files:
print(file)
if ( file[len(file)-3:] == "ogg" ):
os.system("oggdec -o " + filespath + "/" + file[:-4] + ".wav " + filespath + "/" + file)
def binary_from_int16(num):
inum = bin(np... | true |
c8ca024ebd5bcbf8322cfd2bb8e886912ffe27ac | Python | alfisiemcse/pythonproject | /filehandlingpart2.py | UTF-8 | 322 | 2.609375 | 3 | [] | no_license | k = dict()
i = 0
l = []
f = open("alfismacho.txt")
for x in f.readlines():
if x[:-1] == "!":
if len(l) == 0:
continue
else:
k[i]= l
i = i+1
l=[]
else:
l.append(x[:-1])
k[i]=l
for i in k.values():
print(i)
... | true |
be8e2034214c422bf9be242911b01ad877e8a23b | Python | JasonQVan/Self-Taught-Assignments | /Inheritance.py | UTF-8 | 417 | 3.890625 | 4 | [] | no_license | class Shape():
def what_am_i(self):
print("I am a shape")
class Rectangle(Shape):
def __init__(self, w, l):
self.width = w
self.length = l
def calculate_perimeter(self):
return (self.width*2 + self.length*2)
class Square(Shape):
def __init__(self, s):
self.s1 = s
def calculate_perimet... | true |
226f2f0b40cdc0cfa2c704bf9a90505cc915cd38 | Python | asuprem/imag-s | /testing/goof.py | UTF-8 | 6,028 | 2.65625 | 3 | [] | no_license | import sys
import operator
import time
from neo4j.v1 import GraphDatabase
import pdb
from synset_explorer import SynsetExplorer
from nltk.corpus import wordnet as wn
from nltk.corpus.reader.wordnet import WordNetError
from itertools import product
#import approximate_utils
uri = "bolt://localhost:7687"
driver = GraphD... | true |
26fb484792b53187336c1161f17ec1e25c8ff42e | Python | seravb/IndoorCyclingApp | /examples/cairo_gtk.py | UTF-8 | 1,765 | 3.25 | 3 | [] | no_license | #! /usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk, gobject, cairo
# Create a GTK+ widget on which we will draw using Cairo
class Screen(gtk.DrawingArea):
# Draw in response to an expose-event
__gsignals__ = { "expose-event": "override" }
# Handle the expose-event by drawing
def do_e... | true |
531d89a4a6f370a7f46787f4b3d650b08ba77d32 | Python | reikamoon/CS_1.3_Core_Data_Structures | /Code/double_linked_lists.py | UTF-8 | 2,746 | 3.953125 | 4 | [
"MIT"
] | permissive | #!python
class ListNode:
def __init__(self, data):
#stores data
self.data = data
#stores reference for the next item
self.next = None
#store reference for previous item
self.previous = None
return
def has_value(self, value):
if self.data == value... | true |
b2431adcbc9c3c4b37f1302220f112928b5b5ee8 | Python | snarkfog/python_hillel | /lesson_04/n_sqrt.py | UTF-8 | 815 | 4.15625 | 4 | [] | no_license | """
1. ะะพ ะดะฐะฝะฝะพะผั ัะตะปะพะผั ัะธัะปั N ัะฐัะฟะตัะฐัะฐะนัะต ะฒัะต ะบะฒะฐะดัะฐัั ะฝะฐัััะฐะปัะฝัั
ัะธัะตะป, ะฝะต ะฟัะตะฒะพัั
ะพะดััะธะต N, ะฒ ะฟะพััะดะบะต ะฒะพะทัะฐััะฐะฝะธั.
ะะฐะฟัะธะผะตั:
50 1 4 9 16 25 36 49
10 1 4 9
9 1 4 9
4 1 4
1 1
100 1 4 9 16 25 36 49 64 81 100
99 1 4 9 16 25 36 49 64 81
"""
n = abs(int(input("ะะฒะตะดะธัะต ัะธัะปะพ: ")))
... | true |
ebe0b9bb5e033133f9cfa24b8643628d0ac988dc | Python | justin-tt/ctci-6e | /ch1/string_builder2.py | UTF-8 | 1,346 | 3.78125 | 4 | [] | no_license | # https://stackoverflow.com/questions/476772/python-string-join-performance
def join_strings(string_list):
string_accumulator = ""
for string in string_list:
string_accumulator += string
# using + creates new strings for string_accumulator
# every single pass, a lot of memory allocation and
... | true |
5ef17163c455480dc6832a677e81435e7924f041 | Python | marmichcash/Python-Script-Programming | /files_numbers_sum_average.py | UTF-8 | 1,061 | 4.46875 | 4 | [] | no_license | # This program reads all the values in a file and
# calculates the average and sum of all values read.
def main():
# Define variables for calculation
num_sum = 0.0
num_avg = 0.0
running_total = 0.0
count = 0
# Open numbers.txt in read mode
num_file = open("numbers.txt", "r")
... | true |
f94dca11decde4e7487fcad9cbeff506170613af | Python | jaehyek/axidraw-xy | /modules/utils.py | UTF-8 | 4,058 | 2.625 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
from numpy import array
from numpy import row_stack
def get_bounding_box(xy):
mi = xy.min(axis=0).squeeze()
ma = xy.max(axis=0).squeeze()
xd = ma[0]-mi[0]
yd = ma[1]-mi[1]
return mi, ma, xd, yd
def print_values(mi, ma, xd, yd):
print(('x: min {:0.08f} max {:0.08f} d {:0.08f}'.form... | true |
9323c8ee27eb83836291031846da70fb313dab94 | Python | SammyAgrawal/python-references | /india_class_stuff/web_scraping/scrapy1.py | UTF-8 | 337 | 2.59375 | 3 | [] | no_license | from urllib.request import urlopen
from bs4 import BeautifulSoup
html=urlopen("http://www.niitahmedabad.com/")
gn=BeautifulSoup(html.read(),"lxml");
print(gn.h1)
#print(gn.get_text())
print(gn.title)
print(gn.head)
print(gn.title.text())
print(gn.table)
print(gn.table.get_text())
print(gn.p.text())
print(gn... | true |
5627756297e1c417fd6daa49594b666a08b115a3 | Python | imphatic/fair_credit | /src/api/fair_credit.py | UTF-8 | 7,782 | 3.15625 | 3 | [] | no_license | from src import app, db
from sqlalchemy import exc
from src.models import Transactions, CreditLines
from datetime import datetime
from time import time
from src.api.exceptions import CreditLimitExceededError
class FairCredit:
def __init__(self, apr, credit_line_id=None):
self.apr = apr
self.credi... | true |
0b9221e105ae8092e1b60051bff2e1288f57c793 | Python | gasparRuben01/TeoriaAlgoritmos1 | /TP1/recorridos en grafos/pqueue.py | UTF-8 | 655 | 3.171875 | 3 | [] | no_license | from heap import *
class NQueue(object):
"""docstring for NQueue."""
def __init__(self, key, value):
super(NQueue, self).__init__()
self.key = key
self.value = value
def __cmp__(self, other):
return self.key - other.key
class PQueue(object):
"""docstring for PQueue."""
... | true |
98bf591eb63d559101937e008394e0d9980e3aa9 | Python | pedrohcms/reconhecimento_facial | /cadastro.py | UTF-8 | 2,806 | 2.90625 | 3 | [] | no_license | #coding: utf8
import tkinter as tk
import os
import images
from db_interaction.User import User
from intelligence import train_neural_network
import shutil
def Cadastro():
new_user = False
def process_name(name):
name = name.strip()
name = name.upper()
name = name.replace(' ','_')
... | true |
f18a4142a0500083accfaf7b169837def44248ed | Python | nguyendo24/intro-to-ml-with-kubeflow-examples | /ch04/code/Lightweight Pipeline.py | UTF-8 | 2,703 | 3.4375 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
# coding: utf-8
# # Setup
# In[1]:
get_ipython().system('pip install kfp --upgrade --user')
import kfp
from kfp import compiler
import kfp.dsl as dsl
import kfp.notebook
import kfp.components as comp
# Simple function that just add two numbers:
# In[2]:
#Define a Python function
def add(a:... | true |
ca3f90e455be52f5510d938bda4cf55334ec0f8f | Python | cyrilq/BudgetSprint_2 | /rating_task51/sample.py | UTF-8 | 255 | 2.828125 | 3 | [] | no_license | import matplotlib.pyplot as plt
import json
data = {}
with open('result.json') as data_file:
data = json.load(data_file)
print(data)
plt.bar(range(len(data)), data.values(), align='center')
plt.xticks(range(len(data)), data.keys())
plt.show()
| true |
6a9d667a041ca52e697e1976e684bacdc3c78ea9 | Python | buddly27/nomenclator-nuke | /source/nomenclator/widget/error_widget.py | UTF-8 | 6,109 | 2.609375 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
from nomenclator.vendor.Qt import QtWidgets, QtCore
class ErrorManagerWidget(QtWidgets.QFrame):
"""Widget used to display error messages."""
def __init__(self, parent=None):
"""Initiate the widget."""
super(ErrorManagerWidget, self).__init__(parent)
self._setu... | true |
966e5b3b3a4a5a1b331f069ac30256987b580b10 | Python | SuzyWu2014/coding-practice | /python practice/Hashtable/e_202_happy_number.py | UTF-8 | 923 | 4.40625 | 4 | [] | no_license | # 202. Happy Number
# Write an algorithm to determine if a number is "happy".
# A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops... | true |
0f860c1da1e90b68fc687b1f46331920c2dc0660 | Python | mstern98/topylogic-git | /pysrc/test.py | UTF-8 | 1,623 | 2.734375 | 3 | [
"MIT"
] | permissive | from topylogic import *
import topylogic
'''
s = stack()
s.push(1)
s.push("hello")
s.push((2,3,4,2))
print(s.get("a"))
print(s.pop())
print(s.pop())
print(s.pop())
a = AVLTree()
a.insert(1, 2)
a.insert("hi", 3)
print(a.find(3))
print(a.find(0))
a.preorder(s)
print(s.pop())
print(s.pop())
a.de... | true |
b4f66a97e658d9f546c46d51f1df52fd8fc09c16 | Python | SilvesSun/learn-algorithm-in-python | /ๅๆ้/345_ๅ่ฝฌๅญ็ฌฆไธฒไธญ็ๅ
้ณๅญๆฏ.py | UTF-8 | 532 | 3.1875 | 3 | [] | no_license | class Solution:
def reverseVowels(self, s: str) -> str:
vowels = 'ioeauIOEAU'
n = len(s)
s1 = list(s)
i, j = 0, n - 1
while i < j:
while i < n and not s1[i] in vowels:
i += 1
while j > 0 and not s1[j] in vowels:
j -= 1
... | true |
f62f00ffd24e1e55799d761372931264d8754d8c | Python | yyq1609/Python_road | /120 flask็ปไปถ/1.flask_cache/test.py | UTF-8 | 481 | 2.546875 | 3 | [] | no_license | import datetime
from flask import Flask
from flask.ext.cache import Cache
cache = Cache(config={'CACHE_TYPE': 'simple'})
app = Flask(__name__)
cache.init_app(app)
@app.route('/')
def hello():
return "hello, world!"
@app.route('/t')
@cache.cached(timeout=60 * 30)
def cached_page():
time = datetime.datetim... | true |
f1003539d5e3102b7f5b1521b0f2a72c6d7a1b58 | Python | TALASOSUSAN/bankaccount | /__init__.py/account.py | UTF-8 | 5,402 | 3.171875 | 3 | [] | no_license | class BankAccount:
bank ="KCB"
def _init_(self,first_name,last_name,phone_number,bank):
self.first_name = first_name
self.last_name = last_name
self.balance = 0
self.phone_number=phone_number
self.bank=bank
self.deposit=deposit[]
self.withdraw=withdra... | true |
8da8ab560e8df2a0d1fea46cf9a857ed969effd5 | Python | roy860328/fuzzy_system | /fuzzy_system.py | UTF-8 | 3,635 | 3.25 | 3 | [] | no_license |
#-1 == Small, 0 == Medium, 1 == Large
class Fuzzifier(object):
def __init__(self):
self.d1scale, self.d1mu = 0, 0
self.d2scale, self.d2mu = 0, 0
self.d3scale, self.d3mu = 0, 0
def run(self, straight, right, left):
self.straightFuzzifier(straight)
self.rightFuzzifier(rig... | true |
59a07aab8990bc572c5e0e75e6dd8554f4ecc6b0 | Python | lectricas/ml-intro | /hw2.py | UTF-8 | 2,910 | 2.8125 | 3 | [] | no_license | from sklearn.datasets import make_blobs, make_moons, make_swiss_roll
import numpy as np
import random
import matplotlib.pyplot as plt
import matplotlib
import copy
import cv2
from collections import deque
from sklearn.neighbors import KDTree
def visualize_clasters(X, labels):
unique_labels = np.unique(labels)
... | true |