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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
726bb8d02c0a5f29ba3dd2ed0ad26faab197050b | Python | magnusjonsson/tidder-icfpc-2008 | /playground/python/alpha-beta/tictactoe.py | UTF-8 | 3,504 | 3.578125 | 4 | [] | no_license | import alphabeta
import minimax
# note:
# in tic-tac-toe, the end games in a draw if
# both players play optimally
def getRow(grid,x,y,dx,dy):
result = []
for i in range(0,3):
result.append(grid[y][x])
x += dx
y += dy
return ''.join(result)
def getAllRows(grid):
# horizontal
... | true |
98c53b31ed3e29c1eb7b893ed2d8329dc2fc5ffc | Python | christelle-git/births-rate | /births_py/__init__.py | UTF-8 | 3,132 | 3.390625 | 3 | [] | no_license | from IPython.display import display, HTML
import pandas as pd
import numpy as np
import datetime
def remove_nan_entries(df):
"""
Remove the NaN values of the Dataset.
* Args: df (pandas.DataFrame)
* Return: clean_df (pandas.DataFrame)
"""
df_initsize = len(df)
print('Initial datase... | true |
177bb7f36bd1edf459f2eff9b1bd24b21362344a | Python | ifffffs/testsss | /demo.py | UTF-8 | 389 | 3.390625 | 3 | [] | no_license |
# print ("hello world ",end="你好好好好")
# print (123456,end="你好好好好")
# print (12.123,end="不好")
# print (True,False)
# print (())
# print ([])
# print ({})
# print ("你好",666,"世界")
# print ("haha"*10)
# jjcc = 1+1+2*2%2
# print (jjcc)
# a = int(input ("输入"))
# b = int(input ("请输入"))
# print(a+b)
a = (input("请输入: "... | true |
8680c500f8cbd6a4bfb5ae4af7e6583bf00198b9 | Python | YatinGupta777/ML-Algorithms | /my_apriori.py | UTF-8 | 749 | 2.90625 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 2 14:46:00 2018
@author: yatingupta
"""
#Apriori
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
'''Header = None means no column headings but first row is also data'''
dataset = pd.read_csv('Market... | true |
7e03e5108bd8fb767185dd40b8573f9e431c911c | Python | facdo/Courses | /Python/Tutorials/PyQt/PopUp_Alert.pyw | UTF-8 | 3,335 | 3.03125 | 3 | [] | no_license | import sys, time
from PyQt5.QtCore import *
# from PyQt5.QtGui import *
# from PyQt5.QtWidgets import QLabel, QApplication
from PyQt5 import QtWidgets, QtGui
def app_structure():
label_window.setGeometry(220,60,1000,600)
font = QtGui.QFont()
font.setPointSize(48)
font.setBold(True)
message = "GET U... | true |
f1031beffe3bc15b924d1d22da77f411e8671f1f | Python | Moonshile/ChineseWordSegmentation | /wordseg/hashtree.py | UTF-8 | 3,151 | 3.65625 | 4 | [
"MIT"
] | permissive | #coding=utf-8
"""
A simple implementation of Hash Tree
Author: 段凯强
"""
from functools import reduce
class HashTreeNode(object):
def __init__(self, name=''):
self.val = 0
self.name = name
self.level = 0
self.children = {}
def addBag(self, bag):
"""
Note that bag... | true |
adabf50d72ad015f2dea41840149d9e65e4dd2cb | Python | emmabernicerivera/UnixSystemAdmin | /hw3/two.py | UTF-8 | 1,338 | 2.640625 | 3 | [] | no_license | # coding: utf-8
import sys
import re
data = {"total": { "known": 0, "unknown": 0}, "known": {}, "unknown": {} }
def getIp(line):
return re.findall(r'\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]', line)[0]
with open("log2", "r") as f:
for line in f:
if "postfix" in line and "connect" in line:
if "unknown" in line:
... | true |
420082249bc5d5e1b22896b34d3afcd00745be3a | Python | ilkeryaman/learn_python | /matplotlib/matplotlib3.py | UTF-8 | 1,154 | 3.421875 | 3 | [] | no_license | import matplotlib.pyplot as plt
import numpy as np
# for visualising in jupyter notebook, following codes are required
"""
%matplotlib inline
"""
x = np.arange(1, 6)
y = np.arange(2, 11, 2)
""" Beautifying Lines """
fig = plt.figure()
axes = fig.add_axes([0, 0, 1, 1])
axes.plot(x, x ** 2,
color="red", ... | true |
e996c3561d5179166d8147dadf9cb82a37c38c78 | Python | m80126colin/Judge | /since2020/CodeForces/650A.py | UTF-8 | 466 | 2.921875 | 3 | [] | no_license | '''
@judge CodeForces
@id 650A
@name Watchmen
@tag Math
'''
from sys import stdin
from collections import Counter
input()
lines = [ tuple(map(int, line)) for line in sys.readlines() ]
xs, ys = zip(...lines)
a = sum([ x * (x - 1) // 2 if x > 1 else 0 for x in Counter(xs).values() ])
b = sum([ x * (... | true |
5d88b31eaa90a8004d5ed74c4ac97c2840a89dc9 | Python | thien-truong/learn-python-the-hard-way | /ex40internet.py | UTF-8 | 5,734 | 4.6875 | 5 | [] | no_license | # Modules, Classes, And Objects
# Python is something called an "Object Oriented Programming Language".
# What this means is there's a construct in Python called a class that lets you structure
# your software in a particualar way. Using classes you can add consistency to your
# programs so that they can e used in... | true |
0be792b16cf573a47c69466db2047e4643a495dd | Python | wonderwrj/sound_field_analysis-py | /test/time_spatFT.py | UTF-8 | 5,198 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | """This test the equality and execution speed of different implementations to
spatially decompose a sound field.
Exemplary execution:
======================
_TIMEIT_REPEAT = 10
_TIMEIT_NUMBER = 60
_FILE = ../examples/data/CR1_VSA_110RS_L_struct.mat
_ORDER_MAX = 8
_NFFT = 8192
======================
node "C18TTLT"
====... | true |
b28e50994bd5cf689af680cffe2a162e62c26fda | Python | fossabot/Python.ImageRound | /lib/imageTracerJs.py | UTF-8 | 1,513 | 2.875 | 3 | [
"MIT",
"Python-2.0"
] | permissive | """
Author FredHappyface 2020
Uses pyppeteer to leverage a headless version of Chromium
Requires imagetracer.html and imagetracer.js along with the modules below
"""
import asyncio
from pyppeteer import launch
from pathlib import Path
THISDIR = str(Path(__file__).resolve().parent)
async def doTrace(filename, mode="de... | true |
be7bbac972ef188b9acd048e71a29e502a9ddffd | Python | moonhyunkim/Cloud_Simulator | /choice_Host.py | UTF-8 | 11,799 | 2.71875 | 3 | [] | no_license | """
Cloud Simulator
• Author : Moonhyun kim
• Date : May 22 , 2020
• Last modified date : Aug 2, 2020
• Department of Computer Science at Chungbuk National University
"""
from random import randrange
from random import shuffle
import time
import module
def random_choice(VM, Host_list, Run_VM) :
flag = 0
... | true |
0ca9d831fef3d7f075b395494e347237882a27b0 | Python | scikit-learn/scikit-learn | /examples/gaussian_process/plot_gpc_xor.py | UTF-8 | 2,073 | 3.265625 | 3 | [
"BSD-3-Clause"
] | permissive | """
========================================================================
Illustration of Gaussian process classification (GPC) on the XOR dataset
========================================================================
This example illustrates GPC on XOR data. Compared are a stationary, isotropic
kernel (RBF) and ... | true |
316dbb9afc609f90c5dd3afea889de4b8e8b93ff | Python | robetraks/kaggleProjects | /titanic/main.py | UTF-8 | 11,517 | 2.640625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon Nov 11 15:07:40 2019
@author: aj4g2
"""
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.preprocessing import OneHotEncoder
from sklearn.preprocessing import StandardScaler
from sklearn.compose import ColumnTransformer
from skl... | true |
5d11346e895fddbca1f6314e8a8b0947a95cb249 | Python | mrupark/Machine-Learning-From-Scratch | /P0Perceptron/dd.py | UTF-8 | 3,235 | 2.9375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon Jul 1 03:45:23 2019
@author: miru
"""
import numpy as np
import pandas as pd
import math
def preprocess(fname):
data = pd.read_csv(fname)
data = np.array(data)
return data
def lsq(X, t1):
W = np.linalg.lstsq(X, t1, rcond=None)[0]
return W
def signFun... | true |
a3350cd5d2e2bd24cd5ef44d3b8c78aa061791b6 | Python | scotwheeler/LocalRoadMap | /setup_roads.py | UTF-8 | 10,834 | 2.9375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Creates a GeoDataFrame containing LineStrings for all roads within area
defined by exterior polygon.
@author: Scot Wheeler
"""
__version__ = 2.1
import os
import numpy as np
import pandas as pd
import geopandas as gpd
from shapely.geometry import LineString, Polygon
import kml2shp
impo... | true |
36c262e7557f57dac9a0e4ea4b21d10a1dbe91a6 | Python | PatrickSowinski/BrEx | /OpenCVTest/contour_belly_red.py | UTF-8 | 5,149 | 2.859375 | 3 | [] | no_license | ###Patricks code
import time
import random
import numpy as np
import cv2
# open video from file
#cap = cv2.VideoCapture("../Hack2020_breathing_mp4.mp4")
# open webcam directly
cap = cv2.VideoCapture(0)
# save most right position of chest and stomach
mostRightChest = -1
mostRightStomach = -1
while(cap.isOpened()):
... | true |
b378c40513cb143ac798bf5c232c3b9d445ce779 | Python | yrachkov/Python_2_online | /lesson9/hw4.py | UTF-8 | 94 | 2.96875 | 3 | [] | no_license | s = {'n':2,'d':6,'h':4,'u':11}
for y,l in s.items():
if l >=5 and l <=10:
print(y) | true |
6ee669ce280ff52998e308814594d00bf986327f | Python | JeanneBM/Python | /py_calc/serwer.py | UTF-8 | 1,930 | 3.3125 | 3 | [] | no_license | #$ export FLASK_APP=serwer.py
#$ flask run
#%%
from flask import Flask, request
app = Flask(__name__)
@app.route('/')
def obsluz():
strona = ''
strona += '<h1>Select please one of the following operations: </h1>\n'
strona += '<p>"1-Addition; 2-Subtraction; 3-Multiplication; 4-Division"</p>
strona... | true |
a316091e09d7febce4b092f9ed1e0f66bd78e177 | Python | Nurbekttt/introToML | /coding/project/arima.py | UTF-8 | 4,103 | 3.015625 | 3 | [] | no_license | import warnings
from matplotlib import pyplot
from pandas import read_csv
from sklearn.metrics import mean_squared_error
from statsmodels.tsa.arima_model import ARIMA
TRAINING_PERCENTAGE = 0.6
TESTING_PERCENTAGE = 1 - TRAINING_PERCENTAGE
NUMBER_OF_PREVIOUS_DATA_POINTS = 3
LENGTH_DATA_SET = 0
TRAINING_SET_LENGTH = 0
T... | true |
6ff0bc9f58c64f563e4abaf201eb84b784c21938 | Python | poph55/yahtzoom | /YahtzeeClass.py | UTF-8 | 9,563 | 3.421875 | 3 | [] | no_license | import random
from DiceClass import Dice
import sys
#Class for our game Yahtzoom
# We have to initialize a lot of stuff at the beginning, mostly stuff that deals with
# scoring as that is something that has to carry through all the functions.
class Yahtzoom:
def __init__(self, list1):
self.list1 = list1
self.sco... | true |
8db80d5e652183e5a84f48ce093ea6093ca77799 | Python | MatthewQuenneville/blackbox | /utils.py | UTF-8 | 19,554 | 3.046875 | 3 | [
"MIT"
] | permissive | from scipy.optimize import minimize,fmin
import numpy as np
import matplotlib.pyplot as plt
from scipy.special import erf
import blackbox as bb
def chisqToPDF(chisq,d):
fRed = np.exp(-np.divide(np.subtract(chisq,np.min(chisq)),d))
return np.divide(fRed,np.sum(fRed))
def PDFtoChisq(fRed,d):
chisq = np.multiply(-np.... | true |
bb88df78a25dde7f9ab5a1720a20a10b6f116648 | Python | szagot/python-curso | /1-Iniciante/exercicios/2-Tipos-Primitivos/1.py | UTF-8 | 706 | 4.125 | 4 | [] | no_license | # Testando os tipos de conversão
texto = input('Digite algo: ')
input('Você digitou "{}"'.format(texto))
input('É alfabético? {}'.format(texto.isalpha()))
input('É alfanumerico? {}'.format(texto.isalnum()))
input('É decimal? {}'.format(texto.isdecimal()))
input('É numérico? {}'.format(texto.isnumeric()))
input('É díg... | true |
254067194b0dfe084468ee601990640e3d1b1dc0 | Python | JayanthiPriyaS/Jay-Python | /vowel.py | UTF-8 | 368 | 4.1875 | 4 | [] | no_license | char=raw_input("Enter Alphabet:")
if (char=='a' or char=='e' or char=='i' or char=='o' or char=='u' or char=='A' or char=='E' or char=='I' or char=='O' or char=='U'):
print("Alphabet is a vowel")
else:
print("Alphabet is not a vowel")
'''vowel='aeiouAEIOU'
if(char in vowel):
print("Alphabet is a vowel"... | true |
568a321cb93429d211e1725a39d9894c169d3599 | Python | himoon/my-first-coding | /ch05/repeat-while01.py | UTF-8 | 77 | 3.53125 | 4 | [] | no_license | count = 1
while count < 4:
print(str(count) + "!")
count = count + 1
| true |
8ffceaa1451d1344c6ed8f70a3ed7d9a1b17cb15 | Python | quyuanhang/pku_lab | /onlline_social_transfer/DYP.py | UTF-8 | 4,311 | 2.703125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sat Sep 23 23:31:44 2017
@author: QYH
"""
import tensorflow as tf
class CML(object):
def __init__(self, n_users, n_items, embed_dim=50, master_learning_rate=0.1):
self.n_users = n_users
self.n_items = n_items
self.embed_dim = embed_dim
self... | true |
4a0d4104c9a82b088968f8b137298c9621112b5f | Python | Swanekamp/turbopy | /turbopy/core.py | UTF-8 | 38,321 | 3.15625 | 3 | [
"NRL",
"CC0-1.0"
] | permissive | """
Core base classes of the turboPy framework
Notes
-----
The published paper for Turbopy: A lightweight python framework for \
computational physics can be found in the link below [1]_.
References
----------
.. [1] 1 A.S. Richardson, D.F. Gordon, S.B. Swanekamp, I.M. Rittersdorf, \
P.E. Adamson, O.S. Grannis, G.T... | true |
a1cb0b1fa908b1478fd380b346dac88aeea34ceb | Python | sami-one/mooc-ohjelmointi-21 | /osa08-11_lukutilasto/src/lukutilasto.py | UTF-8 | 1,013 | 3.90625 | 4 | [] | no_license | # Tee ratkaisusi tähän:
class Lukutilasto:
def __init__(self):
self.lukuja = 0
self.luvut = []
def lisaa_luku(self, luku:int):
self.lukuja += 1
self.luvut.append(luku)
def lukujen_maara(self):
return self.lukuja
def summa(self):
return sum(self.luvut)
... | true |
f3c00f501be7fcf12022542707d8cb038102669c | Python | ferdyandannes/Monocular-3D-Object-Detection | /data_processing/raw_data_processing/parse_raw_to_KITTI_form.py | UTF-8 | 6,118 | 2.546875 | 3 | [
"MIT"
] | permissive | '''
read the tracklets provided by kitti raw data
write the label file as kitti form
'''
import os
import cv2
import numpy as np
import shutil
from utils.read_dir import ReadDir
import parseTrackletXML as xmlParser
def makedir(path):
if not os.path.exists(path):
os.mkdir(path)
else:
shutil.rmtr... | true |
552d393f505be1cb2e55aee1c01fd828a4d3b740 | Python | kmnkit/django-docker-portfolio-api | /users/managers.py | UTF-8 | 815 | 2.578125 | 3 | [] | no_license | from django.contrib.auth.models import BaseUserManager
class CustomUserManager(BaseUserManager):
def create_user(self, email, nickname, password=None):
if not email:
raise ValueError("이메일이 입력되지 않았어요!")
normalized_email = self.normalize_email(email)
user = self.model(
... | true |
52c82e8e3a5928f881164e0b36ada7e80e37fb81 | Python | venkatbalaji87/guvi | /loop/armstrongNumber.py | UTF-8 | 271 | 3.859375 | 4 | [] | no_license | inputNumber=int(input())
sumNumber=0
temp=inputNumber
while(temp>0):
digits=temp%10
sumNumber=sumNumber+(digits*3)
temp
if(sumNumber==inputNumber):
print(inputNumber,"is Armstrong Number")
else:
print(inputNumber,"is not Armstrong Number")
| true |
21a525ebe8944b8acbc230dbcdf18328c3ce4f8f | Python | visajkapadia/numpy-tutorial | /slicing_stacking_indexing.py | UTF-8 | 1,083 | 3.90625 | 4 | [] | no_license | import numpy as np
a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
print(a)
print(a[2, 1]) # element in 2nd row and 1st column
# Slicing
print(a[0:2, 1]) # [rows from 0 to 1, column index 1]
print(a[:, 1:])
# iterate
for row in a:
print(row)
# iterate as single dimensional array
for x in a.flat:
print(x... | true |
ec2905ff0c383169198bbc7844b790a9caf2410d | Python | sofiamalpique/fcup-programacao-01 | /tri.py | UTF-8 | 154 | 2.765625 | 3 | [] | no_license | def triangular(n):
k=0
s=0
while n>s:
k+=1
s+=k
if s==n:
return True
else:
return False
| true |
0eb2dd5e836f4d953628a49d08cdbf765abbee5a | Python | q531977795/Pycharm_workspace | /pace1/venv/Include/Lesson_6.py | UTF-8 | 9,172 | 3.84375 | 4 | [] | no_license | # 问题1:
# 有四个数字:1、2、3、4,能组成多少个互不相同且无重复数字的三位数?
# 各是多少?
# if __name__ == '__main__':
# count = 0
# for a in range(1, 5):
# for b in range(1, 5):
# for c in range(1, 5):
# if (a != b and a != c and b != c):
# count += 1
# print(a * 100 + b... | true |
1aff0b9e6325accaae6a7e102efc2bae6aa95490 | Python | gtam25/Auto-Serving-Bot | /2016-cs684-Auto Serving Bot/Code/UI Code/php_server/comnwithxbee.py | UTF-8 | 8,401 | 2.984375 | 3 | [] | no_license | #! /usr/bin/python
'''
/****************************************************/
// Filename: comnwithxbee.py
// Created By: Amit Pathania,Manjunath K, Goutam
// Creation Date: 23-10-2016
// Purpose/Description: For serial communication between bot and Xigbee and sending/recieving data to/from Xigbee. It reads table numbe... | true |
4f8d6c1db50839f501cc0494d8c027e71b6ea5fc | Python | vidyamm/pdsnd_github | /bikeshare_2.py | UTF-8 | 7,248 | 3.9375 | 4 | [] | no_license | import time
import pandas as pd
CITY_DATA = { 'chicago': 'chicago.csv',
'new york': 'new_york_city.csv',
'washington': 'washington.csv' }
def get_filters():
"""
Asks user to specify a city, month, and day to analyze.
Returns:
(str) city - name of the city to analyze
... | true |
cae70cdd859f869e4e686d1195a2e40dde89e4d9 | Python | mate86/mentors-life-oop | /education.py | UTF-8 | 378 | 3.171875 | 3 | [] | no_license | import random
class Education:
def teaching(self): # not implemented
raise NotImplementedError()
def motivational_speak(self, students):
for i in students:
i.energy_level += random.randint(5, 10)
print("The mentor gives a motivational speech like no other!\n")
def r... | true |
676319f9faa7e22cacf3b0ee307eff842e463bfc | Python | kim4pb/TIL | /minjukim/Python/Lecture_Note_Ashal/code/score_total_avg.py | UTF-8 | 288 | 3.90625 | 4 | [] | no_license | def total(scores):
total_score = 0
for score in scores:
total_score += score
return total_score
def average(scores):
avg_score = total(scores) / len(scores)
return avg_score
my_scores = [80, 100, 70, 90, 40]
print(total(my_scores))
print(average(my_scores))
| true |
4cd8fdae9195cbbdcca3ff471984aaa84ecd00fd | Python | jeffder/legends | /main/constants.py | UTF-8 | 1,874 | 2.53125 | 3 | [] | no_license | # AFL/Legends for games and ladders
AFL = 'AFL'
LEGENDS = 'Legends'
# Prize categories
class PrizeCategories(object):
categories = \
PREMIER, RUNNER_UP, MINOR_PREMIER, WOODEN_SPOON, COLEMAN, BROWNLOW, \
MARGINS, CROWDS, HIGH_SEASON, HIGH_ROUND = \
'Premier', 'Runner Up', 'Minor Premi... | true |
ba28cf634e9bc678eedfb551eadd160f4b7a1230 | Python | Tkootstra/Evo-computing- | /exp_pseudo.py | UTF-8 | 2,054 | 3.0625 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 18 12:42:33 2020
@author: timo
"""
import exp_helperfunctions as helper
import Builder as builder
# LOOP VOOR 25 ITERS
# 1. Maak random populatie. N = 10. alleen multiples gebruiken
# LOOP
# 2. Doe crossover, family selection maak nieuwe children.
#... | true |
07f0b612527a142e36ec7da814d8e7b184516f79 | Python | jalexspringer/toolkit | /db_manage.py | UTF-8 | 2,739 | 2.6875 | 3 | [] | no_license | import sqlite3
def create_connection(db_file):
conn = sqlite3.connect(db_file)
return conn
def create_table(conn, create_table_sql):
c = conn.cursor()
c.execute(create_table_sql)
def create_record(conn, record):
sql = ''' INSERT INTO records VALUES(?,?,?,?,?,?,?)'''
cur = conn.cursor()
... | true |
3df214f3c30583e4d4d9f3d74a61c6db9249cb44 | Python | watiri98/django-projects | /student/tests.py | UTF-8 | 2,787 | 2.75 | 3 | [] | no_license | from django.test import TestCase
from .models import Student
import datetime
from student.forms import StudentForm
from django.test import Client
from django.urls import reverse
# Create your tests here.
class StudentTestCase(TestCase):
def setUp(self):
self.student = Student(
first_name = "Cat... | true |
fb49ca91d58187bff429da9242489789998528be | Python | TheEYL/python-flask-scrapy | /flask_web_app/models.py | UTF-8 | 476 | 2.78125 | 3 | [] | no_license | from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class Movies(db.Model):
__tablename__ = 'movies'
id = db.Column(db.Integer, primary_key = True, autoincrement = True)
title = db.Column(db.String)
url = db.Column(db.String)
image = db.Column(db.String)
rating = db.Column(db.String)
def __init__... | true |
123c469ece1d9f029bcaa7d530c2a2ea1c4ea652 | Python | Mozilla-GitHub-Standards/54c69db06ef83bda60e995a6c34ecfd168ca028994e40ce817295415bb409f0c | /make_mozilla/base/html.py | UTF-8 | 1,859 | 2.515625 | 3 | [
"BSD-3-Clause"
] | permissive | from functools import partial
from hashlib import md5
import bleach
from django.conf import settings
from django.core.cache import cache
from django.utils.safestring import mark_safe
LONG_CACHE = 60 * 60 * 24 * 7
def cached_render(render_function, source, cache_tag, cache_time=LONG_CACHE):
"""Render a string th... | true |
a0a53866c8fac49f886eed1f70a0cf84f8894bfa | Python | limitmhw/audio_classification | /utils/state.py | UTF-8 | 182 | 2.640625 | 3 | [] | no_license | from enum import Enum
class State(Enum):
power_off = 1 # 关机
not_exist = 2 # 空号
overdue = 3 # 欠费
out_of_service = 4 # 停机
other = 0 # 其他
| true |
b6ef1bc8d85bebcb31d0ec2eba8a0b817d1d42cb | Python | YannisDC/Maths-and-Algos | /Hilbert/image.py | UTF-8 | 527 | 3.03125 | 3 | [
"MIT"
] | permissive | import numpy as np
from PIL import Image
def scaleForRank(rank):
im = Image.open('kolala.jpg').convert('L')
width, height = im.size # Get dimensions
new_width = 450
new_height = 450
left = (width - new_width)/2
top = (height - new_height)/2
right = (width + new_width)/2
bottom = (he... | true |
5f48984a3ead68f0f3a6caa4980218d8c361501c | Python | sanket2221/ML_examples | /K_means.py | UTF-8 | 1,338 | 3.1875 | 3 | [] | no_license | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
dataset = pd.read_csv('Mall_Customers.csv')
x = dataset.iloc[:,[3,4]].values
wcss = []
from sklearn.cluster import KMeans
"""
for i in range (1,11):
kmeans = KMeans(n_clusters= i , init = 'k-means++',max_iter=300 )
kmeans.fit(x... | true |
3419426993cef1a99352fb3ceeeae09d57547a3d | Python | leon890820/python-numbertower | /雜項/黃梓翔的期中考/6.py | UTF-8 | 253 | 3.03125 | 3 | [] | no_license | w="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
m,n=eval(input())
a,b,c=4*(n-1)-1,n,3*n-3
for i in range(n):
print(w[i%m],end='')
print()
for i in range(n-2):
print(w[a%m]+" "*(n-2)+w[b%m])
a-=1
b+=1
for i in range(n):
print(w[c%m],end='')
c-=1
| true |
c5a7b576b8144edf2860e156aed153f0650b1f6e | Python | nicozorza/speech-to-text | /src/tfrecord_from_timit.py | UTF-8 | 3,113 | 2.59375 | 3 | [] | no_license | import os
import pickle
from src.utils.AudioFeature import FeatureConfig, AudioFeature
from src.utils.Database import DatabaseItem, Database
from src.utils.LASLabel import LASLabel
from src.utils.Label import Label
from src.utils.OptimalLabel import OptimalLabel
from src.utils.ClassicLabel import ClassicLabel
from src.... | true |
6fcbc682a5dfe09b542a801d1fd7918c91431848 | Python | hearnderek/ExampleJapanese | /scripts/textprep.py | UTF-8 | 1,293 | 3.65625 | 4 | [] | no_license | """ This reads in a Japanese txt file and splits the sentences onto their own lines then gives each sentence a difficulty """
import re
import sys
from readkanji import KanjiReader
# Read from specified file
file = sys.argv[1]
# main
with open(file) as fp:
kr = KanjiReader()
for line in fp:
# Split... | true |
e4a32059914330d136efa27c0410e59c9d6b89c6 | Python | italotoffolo/Emu86 | /assembler/WASM/data_mov.py | UTF-8 | 5,290 | 2.609375 | 3 | [] | no_license | from assembler.errors import check_num_args, InvalidArgument
from assembler.tokens import Instruction, NewSymbol, IntegerTok
class Global_get(Instruction):
"""
<instr>
global.get
</instr>
<syntax>
global.get var
</syntax>
<descr>
Copies ... | true |
9bb6a0e77b7d8182fc7c7df248f2cfe2e980c490 | Python | guozengxin/myleetcode | /python/addTwoNumbers.py | UTF-8 | 1,115 | 3.59375 | 4 | [
"MIT"
] | permissive | # https://leetcode.com/problems/add-two-numbers/
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def addTwoNumbers(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
... | true |
19c960d6810f8d9b905b5df9442e8720dedb5d54 | Python | audrl1010/Python | /First_Project/sources/views/mainMenu.py | UTF-8 | 1,044 | 2.953125 | 3 | [] | no_license | """
########StudentProgram#######
1. Show all students information.
2. Insert a student information.
3. Delete a student information.
4. Modify a student information.
5. Exit.
##############################
select number:
#1
-----------------------------------------------------
No. | Name | StudentID | Age | Gender... | true |
9086b79ceda3175fc5f960a0a087f870e2681f09 | Python | RenanBertolotti/Python | /Curso Udemy/Modulo 04 - Pyhton OO/Aula13 - Classes Abstratas/main.py | UTF-8 | 366 | 3.03125 | 3 | [] | no_license | from contapoupanca import ContaPoupanca
from contacorrente import ContaCorrente
cp = ContaPoupanca(1739, 2201802138, 500.00)
cp.sacar(500)
print(cp.saldo)
cp.depositar(1000.50)
cp.detalhes()
print("#############################")
cc = ContaCorrente(1535, 2222222222, 1000.00)
cc.detalhes()
cc.sacar(1000.00)
cc.saca... | true |
409733bb442d74db3b7c079313c8bd5ec50bb699 | Python | dungmanh88/tutorial | /actor_spider/actor_spider/spiders/actor_spider.py | UTF-8 | 1,083 | 2.75 | 3 | [] | no_license | import scrapy
from scrapy.selector import Selector
from scrapy.item import Item, Field
class ActorItem(Item):
url = Field()
tag = Field()
name = Field()
description = Field()
class ActorSpider(scrapy.Spider):
name = "actor_spider"
category = "actor"
start_urls = []
page = 10
id = ... | true |
73ca57f9590f483c5b8003768eb7ac4bfad324ce | Python | YenChiWen/webCrawler_ptt | /ptt/ptt/spiders/ptt.py | UTF-8 | 3,551 | 2.59375 | 3 | [] | no_license | from ..items import PttItem
import scrapy
import time
class PTTSpider(scrapy.Spider):
name = 'ptt'
allowed_domains = ['ptt.cc']
start_urls = ['https://www.ptt.cc/bbs/Stock/index.html']
condition_words = ['聯電', '2303', '聯華電子']
def parse(self, response):
for i in range(1): # numb... | true |
14fb0a4de9be3bee7872403b157ba10bdcddf91d | Python | leskat47/cracking-the-coding-interview | /linkedlists/remove_dups.py | UTF-8 | 736 | 3.5 | 4 | [] | no_license | class Node(object):
def __init__(self, data, next=None):
self.data = data
self.next = next
def __repr__(self):
return "<Node {}>".format(self.data)
def remove_dups(ll):
"""
>>> d = Node("berry")
>>> c = Node("cherry", d)
>>> b = Node("berry", c)
>>> a = Node("apple... | true |
c3f6867987b2ad2b7edd5cb4fcb0f73624993219 | Python | Vayne-Lover/Python | /file/read.py | UTF-8 | 689 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/local/bin/python
import pprint
#with open('/Users/Vayne-Lover/Desktop/CS/Python/PythonPractice/file/somefile.txt') as f:
# print f.read(7)
# print f.read()
# f.close()
#f=open('/Users/Vayne-Lover/Desktop/CS/Python/PythonPractice/file/somefile.txt')
#for i in range(3):
# print f.readline()
#f.close()
#pprint.... | true |
9501c4692458cc326f9651f0f73f20021c898f68 | Python | gchoi/fcn-instances-pytorch | /instanceseg/models/simple_sym_fcn.py | UTF-8 | 7,204 | 2.953125 | 3 | [] | no_license | import torch
import torch.nn as nn
################################################################################
'''
Helper functions
'''
# Choose non-linearities
def get_nonlinearity(nonlinearity):
if nonlinearity == 'prelu':
return nn.PReLU()
elif nonlinearity == 'relu':
return nn.ReLU... | true |
0d3a09956ea3d3fde3f41723898cb769c3603e7a | Python | osule/bookworm | /compass/tests/test_views.py | UTF-8 | 2,205 | 2.671875 | 3 | [
"MIT"
] | permissive | from django.test import TestCase, Client
from ..models import Category, Book
class CompassTest(TestCase):
@classmethod
def setUpClass(cls):
cls.client = Client()
super(CompassTest, cls).setUpClass()
def test_can_view_search_page(self):
response = self.client.get('/')
self.... | true |
aaea9f30118c7cd15e8b561ed691436c04fdfb45 | Python | BlackHenry/RedditTitleNN | /test_on_input.py | UTF-8 | 1,039 | 2.65625 | 3 | [] | no_license | from keras import models
from keras.preprocessing import sequence
import numpy as np
import pandas as pd
import metadata
import json
from scraper import prepare_word
def test():
model = models.load_model('model.h5')
user_input = prepare_word(input('Suggested title:\n'))
print(user_input)
... | true |
7364bae9d032673dc29b724572b3010fa84c6ab2 | Python | SoushiAnzai/atcoder | /python/kyopro_educational_90/055.py | UTF-8 | 369 | 2.75 | 3 | [] | no_license | # 数列 A = (A[1], A[2], ..., A[N]) があります。
# この中から重複なく 5 個を選ぶ方法のうち、その積を P で割ったあまりが Q になるような方法の数を求めてください。
# 【制約】
# ・5 ≦ N ≦ 100
# ・0 ≦ A[i] ≦ 10^9
# ・0 ≦ Q < P ≦ 10^9
# ・入力はすべて整数
# ・実行時間制限は 5 秒 | true |
f44aeade98f3b66b485d9d134a7ead0676dc86ba | Python | exchangefree/OptimalControl | /Ch.1/scripts/model.py | UTF-8 | 3,806 | 2.828125 | 3 | [] | no_license | import matplotlib.pyplot as plt
import numpy as np
class lambModel:
"""
构造函数
n 段路和 m 盏灯
"""
n_ = 0
m_ = 0
mapSize_ = np.zeros(2)
pix2meter = 240
lambs_ = []
mapPos_ = []
ans_ = []
map_ = []
p_ = []
Iks = []
A_ = []
def __init__(self, n, m, mapSize=[4... | true |
a7396958fb49d1a17cf751812abffaeb122c6d22 | Python | clausia/tetromiq | /src/tetromiq.py | UTF-8 | 8,217 | 2.703125 | 3 | [
"MIT"
] | permissive | from pathlib import Path
from src.board import *
from src.table import *
from src.effects import *
import cv2
def draw_centered_surface(screen, surface, y):
screen.blit(surface, ((WINDOW_WIDTH + GRID_WIDTH - surface.get_width()) / 2, y))
def game():
pygame.init()
pygame.display.set_caption("TetromiQ")
... | true |
cc525ee3c54ad9494b00dffe55028c73e0ea2cd2 | Python | Fablab-Sevilla/ghPython101 | /Día_003/01_EJ/Recursive_scaling.py | UTF-8 | 1,024 | 2.5625 | 3 | [
"MIT"
] | permissive | import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import math as m
def scaling(c):
crvArea = rs.CurveArea(c)[0]
crvCentroid = rs.CurveAreaCentroid(c)[0]
#print crvCentroid
# Comprobando casos
if abs(target-crvArea)>tolerance:
if target > crvArea:
print "caso... | true |
f79835538c6bf15cf774949fa88334d8364fa252 | Python | uysalserkan/Python-Topics | /unsorted/model_creating/file.py | UTF-8 | 975 | 2.578125 | 3 | [] | no_license | import os
import numpy as np
import tensorflow as tf
from tensorflow import keras
print(tf.version.VERSION)
test_input = np.random.random((128, 16))
test_target = np.random.random((128, 1))
def create_model():
model = tf.keras.models.Sequential(
[keras.layers.Dense(1, activation="relu", i... | true |
e5d1b594910935bc2ac4b745e7d64ae52efda323 | Python | diaozhende/pythonStudy | /python基础demo/pythonDemo/面向对象高级编程.py | UTF-8 | 240 | 3.15625 | 3 | [] | no_license | class Student(object):
def __init__(self,name):
self._name = name
stu = Student("zhangsan")
from types import MethodType
def set_name(self,name):
self.name = name
stu.set_name = MethodType(set_name,stu)
print(stu._name) | true |
161ce0d52d0ee0cd8f4e51ffc59a86a454ff1e7a | Python | povert/Programming | /python/网络编程.py | UTF-8 | 2,323 | 3.21875 | 3 | [] | no_license | ''' tcp 与 udp
区别:tcp基于有连接,udp基于无连接
对系统资源的要求(TCP较多,UDP少)
TCP保证数据正确性,UDP可能丢包,TCP保证数据顺序,UDP不保证。
所以tcp可靠,udp不可靠。
TCP面向字节流,实际上是TCP把数据看成一连串无结构的字节流;UDP是面向报文的
UDP没有拥塞控制,因此网络出现拥塞不会使源主机的发送速率降低
TCP首部开销20字节;UDP的首部开销小,只有8个字节
TCP是1对1 UDP 支持支持一对一,一对多,多对一和多对多的交互通信
'''
#tcp的三次握手与四次挥手 https://b... | true |
c8a6d786c849ec7f57dde916fab977481caee4b3 | Python | ostap4bender/talking_calendar | /dates_as_pixels/rows&cols.py | UTF-8 | 388 | 3.4375 | 3 | [] | no_license | from datetime import datetime, date, time
YEAR = 2021
first = last = 0
flag_first = flag_last = True
for i in range(1, 8):
beginning = date(YEAR, 1, i)
ending = date(YEAR, 12, 32-i)
if beginning.weekday() == 5:
if flag_first: first += 1
flag_first = False
if ending.weekday() == 6:
... | true |
dfb887de93532a29641ff80e41fe679ad6072d6c | Python | sirnfs/OptionSuite | /base/stock.py | UTF-8 | 1,355 | 3.125 | 3 | [
"MIT"
] | permissive | import dataclasses
import datetime
import decimal
from typing import Optional, Text
@dataclasses.dataclass
class Stock:
"""This class defines one the basic types for the backtester or live trader -- a stock.
Attributes:
underlyingPrice: price of the underlying / stock which has option derivatives in dolla... | true |
3af53b1bd094b057e22c505f01851d386c73f7d2 | Python | ritesh-deshmukh/Algorithms-and-Data-Structures | /180Geeks/Linked List/Rotate a Linked List.py | UTF-8 | 2,611 | 4.625 | 5 | [] | no_license | # Given a singly linked list, rotate the linked list counter-clockwise by k nodes.
# Where k is a given positive integer smaller than or equal to length of the linked list.
# For example, if the given linked list is 10->20->30->40->50->60 and k is 4, the list should be modified to 50->60->10->20->30->40.
class Node:
... | true |
15e87f4e606cdf70f5e2de9fffa3d9933d7821e2 | Python | leejaeyong7/UnNormNet | /utils/loss.py | UTF-8 | 1,049 | 2.828125 | 3 | [] | no_license | def surface_normal_loss(surface_normals, dense_corrs, rotmat):
'''
surface_normals: 2x3xHxW surface normal values
dense_corrs: 2xHxWx2 correspondence representing ref->src coordinates
NaN if correspondence is not found / out of range
rotmat: 1x3x3 rotation matrix from in-plane rotation
... | true |
289c7a58a5dbb62a6e7f64bf6ae6b7773a1d4a65 | Python | luckyJim-dev/baidu_poi | /mapapi/example/uid.py | UTF-8 | 1,302 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | # -*- coding: utf-8 -*-
import json
import logging
from baidu.place_api import get_place_by_uids
import codecs
def get_locs(data):
for item in data:
loc = get_place_by_uids(item['uid'])
if loc:
item['lat'] = loc['location']['lat']
item['lng'] = loc['location']['lng']
... | true |
80ab6ea85e60a8e1916c589651ed93f87950d9e2 | Python | Tarnasa/tan_game | /ww.py | UTF-8 | 1,165 | 2.75 | 3 | [] | no_license | import pygame
from loader import images
from player import Player
from keys import *
from physics import V
class WW(Player):
def __init__(self, **kwargs):
sprites = [images['ww_right'], images['ww_up'], images['ww_left'], images['ww_down']]
kwargs['id'] = kwargs.get('id') or 'w'
... | true |
c84e988e90ec27ca5bdd4b75bbc1085620cd96f8 | Python | henrikland/advent2020 | /day7/7-1.py | UTF-8 | 652 | 3.046875 | 3 | [] | no_license | import sys
import re
def parseRule(rule):
cleaned_rule = re.sub(r"( \d )|\sbags?\s?\.?|no other bags\.", "", rule)
[node, children] = cleaned_rule.split("contain")
return (node, None if len(children.strip()) == 0 else children.split(","))
nodes = {}
for rule in sys.stdin.read().split("\n"):
(node, children) ... | true |
3f74d3dbf175c64a259378ac103c11b14acbbe96 | Python | yujunsen/python | /pycharm/new/09_scray_demo/useranget_demo/useranget_demo/spiders/httpip.py | UTF-8 | 294 | 2.5625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import scrapy
import json
class HttpipSpider(scrapy.Spider):
name = 'httpip'
allowed_domains = ['httpbin.org']
start_urls = ['http://httpbin.org/ip']
def parse(self, response):
origin = json.loads(response.text)['origin']
print(origin)
| true |
5140a08642a9903d0930fa0a8fd7f218717da832 | Python | lcongdon/tiny_python_projects | /14_rhymer/test_pig_latin.py | UTF-8 | 2,703 | 2.765625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
"""tests for pig_latin.py"""
import random
from subprocess import run
import pytest
class TestPigLatin:
@pytest.fixture
def program_name(self):
"""Name of program under test"""
return "./pig_latin.py"
def test_take(self, program_name):
"""leading consonant"... | true |
0e68512c5db436612f9fab8e964d5ad126b9fedc | Python | TBurchfield/AdventOfCode2017 | /d13/p1.py | UTF-8 | 256 | 2.59375 | 3 | [] | no_license | #!/usr/bin/env python3
import sys
severity = 0
#FINISHED, do not edit
for line in sys.stdin:
line = line.split()
depth = int(line[0][:-1])
ran = int(line[1])
cycle = ran*2 - 2
if (depth % cycle == 0):
severity += depth*ran
print(severity)
| true |
da86e836b9188e161c3f6a4b59bb38975a1ce607 | Python | 0ushany/learning | /python/python-crash-course/code/8_function/6_city_name.py | UTF-8 | 192 | 3.265625 | 3 | [] | no_license | # 城市名
def city_country(name, country):
print('\"'+ name + ', ' + country +'\"')
city_country("Santiago", "Chile")
city_country("Shenzhen", "China")
city_country("Tokyo", "Janpan")
| true |
843a33d5c2fe5fb195f79e256d8e665289627973 | Python | tayates76/web-caesar | /caesar.py | UTF-8 | 835 | 4.09375 | 4 | [] | no_license | from helpers import alphabet_position, rotate_character, isupper, ALPHA_STRING
def rotate_string(rot, text):
"""receives as input a string and an integer rot which specifies the rotation amount. Your function should return the result of rotating each letter in the text by rot places to the right"""
new_text = ... | true |
18f405427b9ef7e770696ea76f1671d3c475fcbe | Python | Pongpisit-Thanasutives/ASR | /hw1/friends/analysis2.py | UTF-8 | 6,492 | 2.8125 | 3 | [] | no_license | import numpy as np
import pandas as pd
from sys import exit
# Implement Word recognition accuracy for fast, normal, slow speed
# ความยาวของประโยคทดสอบที่ทำให้ผลการทดสอบออกมาดี ๆ อยู่ใน range ใด ทำเป็น range เพราะมีตัวแปลที่เป็นความยากง่ายของการออกเสียงแต่ละคำในแต่ละประโยคทดสอบด้วย
def isEqual(string1, string2):
if... | true |
ff05c47668d3b410fae064db1a0cd2d29a3ed81b | Python | Deltares/hydromt | /hydromt/workflows/forcing.py | UTF-8 | 26,873 | 2.671875 | 3 | [
"MIT"
] | permissive | """Implementaion of forcing workflows."""
import logging
import re
from typing import Union
import numpy as np
import pandas as pd
import xarray as xr
import xarray.core.resample
from .._compat import HAS_PYET
if HAS_PYET:
import pyet
logger = logging.getLogger(__name__)
def precip(
precip,
da_like,
... | true |
a64c63edb1e4a6f1c17684b4bbc05fee33a94981 | Python | whoiskx/com_code | /utils/WX/WX_qingbo/send_backpack.py | UTF-8 | 1,451 | 2.609375 | 3 | [] | no_license | import time
class Article(object):
def __init__(self):
self.url = ''
self.title = ''
self.content = ''
# 作者即公众号名称
self.author = ''
self.From = ''
self.time = ''
self.readnum = ''
self.likenum = ''
class Acount(object):
def __init__(sel... | true |
eb5c4db09b40f2c7a6ae8903e7ee7b599e4f3914 | Python | MphoKomape/MphoEDSA | /tests/test.py | UTF-8 | 488 | 2.96875 | 3 | [] | no_license | from mypackage import myFunction
def recursion():
"""
make sure recursion works correctly
"""
assert myFunction.sum_array(np.array([5,5,5,3]))==18
assert myFunction.fibonacci(4)==3
assert myFunction.factorial(5)==120
assert myFunction.reverse("komape")=='epamok'
def sorting():
asser... | true |
116eca7f832c640aff7004d82dffec857c483841 | Python | dalleng/Interview-Practice | /cracking-the-coding-interview/Ch4-Trees-Graphs/4.1/main.py | UTF-8 | 3,450 | 3.875 | 4 | [] | no_license | import unittest
"""
Problem 4.1
-----------------------------------------------------
Implement a function to check if a tree is balanced.
For the purposes of this question, a balanced tree is
defined to be a tree such that no two leaf nodes differ
in distance from the root by more than one.
"""
cl... | true |
10a4e72c76b46da0798d1a1742af10e7caf54223 | Python | TimothySjiang/leetcodepy | /Solution_986.py | UTF-8 | 620 | 3.21875 | 3 | [] | no_license | class Solution:
def intervalIntersection(self, A: List[List[int]], B: List[List[int]]) -> List[List[int]]:
p1 = 0
p2 = 0
res = []
while p1 < len(A) and p2 < len(B):
interval1 = A[p1]
interval2 = B[p2]
if interval1[1] >= interval2[0] and interval2[1... | true |
3929cf458a07dfec53507cfa7c13892c982e262d | Python | Ntakato/AtCoder | /ABC166/b.py | UTF-8 | 277 | 2.640625 | 3 | [] | no_license | n, k = (int(i) for i in input().split())
d = []
A = []
for i in range(k):
d.append(int(int(input())))
A.append(list(map(int,input().split())))
x = [0] * n
for a in A:
for i in a:
x[i-1] += 1
ans = 0
for i in x:
if(i == 0):
ans += 1
print(ans)
| true |
abb582acde261aa0bd61e94bd3e4e28605856316 | Python | zouhairagasmi/QnA-Test | /qna_solution.py | UTF-8 | 577 | 4 | 4 | [] | no_license | # Python program to find the 10 most frequent words
# from a text file
import re
import collections
#Read input file
with open('Tempest.txt') as f:
text = f.read()
#retrieve the words in the text file using regex
words = re.compile(r"[\w']+", re.U).findall(text.lower())
#counting the each word's occurence and ... | true |
e9e09e7f0c1c5e10761b15748b07589d335f3d49 | Python | Vishnuprasad-Panapparambil/Luminar-Python | /looping/factorial.py | UTF-8 | 105 | 3.5625 | 4 | [] | no_license | n1=int(input("enter the number"))
pro=1
for i in range(1,n1+1):
pro=pro*i
print("factorial =",pro)
| true |
efc33bd281f05b8e2157820d0e0513219a949641 | Python | rmlopes/thinkful | /fizzbuzz.py | UTF-8 | 310 | 3.765625 | 4 | [] | no_license | import sys
try:
n = int(sys.argv[1])
except:
print 'Please provide an integer as input (eg.: python fizzbuzz.py 100)'
sys.exit(0)
for i in range(1, n):
if i % 3 == 0 and i % 5 == 0:
print 'Fizz Buzz'
elif i % 3 == 0:
print 'Fizz'
elif i % 5 == 0:
print 'Buzz'
else:
print i | true |
ad9b193ea9c4fcbb94472f0d4431579abf8c772a | Python | maletsden/secp256k1-schnorr-sign | /secp256k1/Secp256k1Types.py | UTF-8 | 638 | 2.609375 | 3 | [] | no_license | from __future__ import annotations
from typing import NewType, NamedTuple, Union, TypedDict
class PointNTuple(NamedTuple):
x: Union[int, None]
y: Union[int, None]
class Point(PointNTuple):
def isNone(self) -> bool:
return self.x is None or self.y is None
def toBytes(self) -> bytes:
... | true |
6dd284d198794be01ae7fa1e748d959a22e13dce | Python | JeanJunior18/py-directory | /main.py | UTF-8 | 588 | 3.625 | 4 | [] | no_license | from classes.Directory import Directory
contactList = []
print('Lista Telefonica')
while True:
print('\nOpções:')
print('1 • Novo | 2 • Lista Telefônica | 3 • Sair da Lista ')
op = int(input('Escolha uma das opções: '))
if op == 1:
name = input('Nome: ')
phone = int(in... | true |
9aa00ed2a37afcfc8ca08bce606d17452e7b1c94 | Python | AniketSanghi/Kisan-Query-Analysis | /src/plant_protection_analysis/per_crop_disease_analysis/src/cotton.py | UTF-8 | 4,083 | 2.625 | 3 | [] | no_license | import json
import re
import csv
def unique(z):
freq = {}
for x in z:
if x[0] not in freq:
freq[x[0]] = 0
freq[x[0]] += x[1]
ans = []
for x, y in freq.items():
ans.append((x,y))
return ans
def output(header, data, filename):
with open(filename, 'w') as ... | true |
b9d50b25f0a14eb73542a1b08978d2c6b2492c70 | Python | robertdahmer/Exercicios-Python | /Projetos Python/Aulas Python/Aula 14/Desafio 057.py | UTF-8 | 471 | 3.984375 | 4 | [
"MIT"
] | permissive | #Faça um programa que leia o sexo de uma pessoa, mas só aceite os valores 'M' ou 'F'. Caso esteja errado
# peça a digitação novamente até ter um valor correto.
sexo = str(input('Informe seu sexo: [M/F] ')).upper().strip()[0]
while sexo not in 'mMnN':
sexo = str(input('Dados inválidos. Por favor, tente novamente: ')... | true |
b1f47d729b9adb23eac97d8943895d259b42c4dc | Python | esevillano1/386_Pong | /pong.py | UTF-8 | 1,740 | 2.890625 | 3 | [] | no_license | import pygame
# from pygame.locals import *
# import time
from pygame.sprite import Group
from settings import Settings
from game_stats import GameStats
from scoreboard import Scoreboard
from ball import Ball
from button import Button
import game_functions as gf
from menu import Menu
def run_game():
# Initialize... | true |
945aba9e03ee51d02353623aee8f1d9917e71689 | Python | AvivYaniv/FireWall | /hw4/Proxy/DLP.py | UTF-8 | 3,476 | 2.71875 | 3 | [] | no_license | import re
import time
import string
import operator
from RegExp import *
from DetectorC import *
from DetectorCS import *
from DetectorCPP import *
from DetectorJava import *
from DetectorPython import *
from DEBUG import *
#### Main Section ####
class CDataLeakPreventor:
# Conf... | true |
93277f445efaabe3a7d3132e5f1970a671d22315 | Python | bhklab/DataIngestion | /PharmacoDI/PharmacoDI/write_pset_table.py | UTF-8 | 786 | 3.125 | 3 | [
"MIT"
] | permissive | import os
from datatable import Frame
def write_pset_table(pset_df, df_name, pset_name, df_dir):
"""
Write a PSet table to a CSV file.
@param pset_df: [`DataFrame`] A PSet DataFrame
@param pset_name: [`string`] The name of the PSet
@param df_dir: [`string`] The name of the directory to hold all th... | true |
2f13386c094ccce2c837407678d76bfff06b9973 | Python | liushh/falcon-backend-template | /api/resources/trips.py | UTF-8 | 3,513 | 2.703125 | 3 | [] | no_license | import json
from datetime import datetime
from dateutil import parser
import falcon
from models import Trip, User, Origin, Destination
class TripsResource:
REQUIRED_REQUEST_ATTRS = [
'email',
'driveOrRide',
'time',
'origin',
'destination'
]
def on_post(self, req,... | true |
345f0ad7407e46d6f83bd8d57e711c5cea7363d8 | Python | liran1024/Python_demo | /PythonTest/函数的定义和操作.py | UTF-8 | 1,106 | 3.515625 | 4 | [] | no_license | # 读取人物名称
# f = open('name.txt', 'r', encoding='UTF-8')
# data = f.read()
# print(data.split('|'))
# 读取兵器名称
# 取奇数行
# f2 = open('weapon.txt', encoding='UTF-8')
# i = 1
# for line in f2.readlines():
# if i % 2 == 1:
# print(line.strip('\n'))
# i += 1
# 读取三国演义
# f3 = open('sanguo_utf8.txt', encoding='UTF-8'... | true |