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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
a47924ef3c2235743fb98c53e080bec11927eb94 | Python | poojakancherla/Problem-Solving | /AlgoExpert_DailyCoding/#4.py | UTF-8 | 222 | 3.515625 | 4 | [] | no_license | # Maximum subarray problem
# Algorithm: Kadane's Algorithm
arr = [-6,-5,-4,-3,-2,-1]
currSum = maxSum = arr[0]
for num in arr[1:]:
currSum = max(currSum + num, num)
maxSum = max(maxSum, currSum)
print(maxSum)
| true |
acd086377ad75c44c27ff614714c4bb0b38b5da4 | Python | OldJohn86/Python_CPP | /TendCode/spider_test/jandan/download_img.py | UTF-8 | 3,846 | 2.515625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import hashlib
import base64
import requests
from bs4 import BeautifulSoup
import re
import threading
import multiprocessing
import os
def _md5(value):
'''md5加密'''
m = hashlib.md5()
m.update(value.encode('utf-8'))
return m.hexdigest()
def _base64_decode(data):
'''bash64解码,... | true |
ef9febcd2b3778af17b704525290755f04ca473d | Python | rheehot/code_test | /programmers/weekly_1.py | UTF-8 | 262 | 3.125 | 3 | [] | no_license | # source : https://programmers.co.kr/learn/courses/30/lessons/82612
def solution(price, money, count):
for i in range(1, count + 1):
money -= price * i
if money > 0:
return 0
else:
return -1 * money
solution(3, 20, 4) | true |
4ec60b178ea1d1896034dfc4a7442b2c437a579e | Python | moozer/skemapack | /bin/ExportHtml | UTF-8 | 2,198 | 2.59375 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
Created on 10 Feb 2012
@author: moz
'''
import sys, codecs
from Configuration.SkemaPackConfig import SkemaPackConfig
from Import.ImportFile import ImportFile
from Output.HtmlTableOutput import HtmlTableOutput
Header = '''<html>
<header>
<title>TF</title>... | true |
897e9c86ff79a63f8f97760d5b22bd860248581f | Python | mdryden/110yards | /yards_py/domain/enums/position_type.py | UTF-8 | 5,175 | 2.59375 | 3 | [
"MIT"
] | permissive | from __future__ import annotations
from enum import Enum
from yards_py.core.logging import Logger
class PositionType(str, Enum):
qb = "qb"
rb = "rb"
wr = "wr"
k = "k"
lb = "lb"
dl = "dl"
db = "db"
ol = "ol"
o_flex = "o-flex"
d_flex = "d-flex"
flex = "flex"
ir = "ir"
... | true |
a7bdc5f443e2283d8a9f74483406c23c18a4c329 | Python | okingniko/AnomalyLogAnalyzer | /syslog_analyzer.py | UTF-8 | 2,745 | 2.609375 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
''' This is a demo file for the Invariants Mining model.
API usage:
dataloader.load_syslog(): load syslog dataset
feature_extractor.fit_transform(): fit and transform features
feature_extractor.transform(): feature transform after fitting
... | true |
cc4e08e49aa5e6b5d7b5afb19032f695683cfdd6 | Python | csz-git/python_repo | /project/scrapy/qingTingFM/qtController.py | UTF-8 | 2,774 | 2.9375 | 3 | [] | no_license | #coding=utf-8
from qtModel import *
from qtView import *
class QtController:
# 初始化
# downloadPath:下载路径
def __init__(self, downloadPath):
self.downloadPath = downloadPath
self._qtView = QtView()
self._qtModel = QtModel()
# 输入校验
def input_check(self, input):
... | true |
dad48d93b26dca068ffe309070f763ef85da397b | Python | shrishyla/shrishyla | /labs111.py | UTF-8 | 239 | 2.953125 | 3 | [] | no_license | import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:
r.adjust_for_ambient_noise(source, duration=5)
print("say something")
while True:
audio=r.listen(source)
print("you said"+r.recognize_google(audio)) | true |
7d26f0dd80e94258cc80da0d696019001868b01e | Python | ekkiii/gitpracticeEKKI | /gitpracticeEKKI.py | UTF-8 | 682 | 3.71875 | 4 | [] | no_license | # Partner 1 Name: Ekki Lu
# Partner 2 Name: Clyde Beuter
###############################
# Assignment Name: GitHub Practice - 2/26/20 - 20 pts
import random as rand
def getNRandom(n):
'''takes in an integer and returns a list of n random integers between 1 and 10, inclusive'''
n_list = []
for i in range(n... | true |
1717502f47c5f2e207784c36852c695887abb5d8 | Python | boukeversteegh/bitcoinbalance | /timecache.py | UTF-8 | 1,386 | 2.953125 | 3 | [] | no_license | import time
from cache import Cache, CacheException
class TimeCache(Cache):
def __init__(self, maxage):
Cache.__init__(self)
self.maxage = maxage
def getTSCache(self, *args):
#print 'TimeCache.getCache(%s)' % repr(args)
value, timestamp = super(TimeCache, self).getCache(*args)
if time.time() > timestam... | true |
0df7673230f46adecec42d0d383f8fd4a1a47a98 | Python | merveozgul/EDA-google-play-store-apps | /data-exploration.py | UTF-8 | 6,552 | 3.53125 | 4 | [] | no_license | import pandas as pd # data science essentials
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
file ='googleplaystore.csv'
apps = pd.read_csv(file)
#viewing the head of the data
with pd.option_context('display.max_rows', 50, 'display.max_columns', 50):
print(apps.head())
print(apps.d... | true |
404ddd05f8fb6d6dffcec06c5c621fbcf67c9795 | Python | aminnj/makers | /disMaker/db.py | UTF-8 | 6,624 | 2.71875 | 3 | [] | no_license | import sqlite3
import pickle
class DBInterface():
def __init__(self, fname="main.db"):
self.connection = sqlite3.connect(fname)
self.cursor = self.connection.cursor()
self.key_types = [
("sample_id", "INTEGER PRIMARY KEY"),
("timestamp", "INTEGER"),
... | true |
c55bcf800bda436793297f614f94192ba0a8d404 | Python | shuq3/CNN | /read_image.py | UTF-8 | 6,139 | 2.640625 | 3 | [] | no_license | # -*- coding: UTF-8 -*-
import os
import tensorflow as tf
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
class DataGenerator:
def __init__(self, filepath, mode, batch_size, num_classes):
self.write_to_tfrecord(filepath, mode)
self.read_from_tfrecord(batch_size, num_classes... | true |
b53547088bd1df9661b7f1923aaea6bd796e91f4 | Python | L-Ramos/MrClean_Poor | /plots_visualization.py | UTF-8 | 2,623 | 2.828125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Dec 10 11:50:51 2019
@author: laramos
"""
#Creating nice plots
import seaborn as sns
import matplotlib.pyplot as plt
frame['mrs']=Y_mrs
def plot_box(var):
sum_poor=list ()
sum_good=list()
sum_nan=list()
var = 'rr_syst'
... | true |
fde35ac5ceafec6719de6e4e064e823a294d6637 | Python | jmackraz/baker-house | /src/skill/lambda/custom/house_lambda.py | UTF-8 | 15,783 | 2.53125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
"""
Based on Skills SDK example
The Intent Schema, Custom Slots, and Sample Utterances for this skill, as well
as testing instructions are located at http://amzn.to/1LzFrj6
For additional samples, visit the Alexa Skills Kit Getting Started guide at
http://amzn.to/1LGWsLG
"""
from __future__ imp... | true |
710aff70a993e6f0e606953ea0cbbd419a383dd2 | Python | kgvconsulting/PythonDEV | /convertMBtoGB.py | UTF-8 | 262 | 3.4375 | 3 | [
"MIT"
] | permissive | # Created by Krasimir Vatchinsky - KGV Consulting Corp - info@kgvconsultingcorp.com
# This program help converting megabytes to gigabytes
# convert megabytes to gigabytes
mb = input("entera number of megabytes: ")
mb = float(mb)
gb = mb / 1024
print(mb, "megabytes is = to",gb, "gigabytes")
| true |
d86a2cab23d7491f5ad71f1b282b4ed09dbe6dfc | Python | samiraabnar/brain-lang | /read_dataset/readHarryPotterData.py | UTF-8 | 9,402 | 3.03125 | 3 | [] | no_license | import numpy as np
import scipy.io
from .scan import ScanEvent
# This method reads the Harry Potter data that was published by Wehbe et al. 2014
# Paper: http://aclweb.org/anthology/D/D14/D14-1030.pdf
# Data: http://www.cs.cmu.edu/afs/cs/project/theo-73/www/plosone/
# It consists of fMRI data from 8 subjects who re... | true |
f1228f35697e8f7c157d97d9d1deaf39ef9a0130 | Python | srideepkar/Driver-Drowsiness-Detection-using-MQ6-gas-sensor-and-vision-sensor | /py7seg/Display108.py | UTF-8 | 243 | 2.796875 | 3 | [] | no_license | # Display101.py
# showText()
from py7seg import Py7Seg
import time
ps = Py7Seg()
ps.showText('HELO')
for i in range(4):
time.sleep(0.5)
ps.setBrightness(7)
time.sleep(0.5)
ps.setBrightness(1)
time.sleep(1)
ps.showText("8YE")
| true |
13d2088df88120c6086ab8e1a1f6570cbec18f0f | Python | dabrunhosa/PhD_Program | /Plotting/NetXNeuroPlot.py | UTF-8 | 8,661 | 2.859375 | 3 | [] | no_license | ## -*- coding: utf-8 -*-
#'''
#Created on September 6, 2017
#@author: dabrunhosa
#'''
#from Plotting.IPlot import IPlot
#import networkx as nx
#from Utilities.Utils import Set
#import operator
#import math
#from Queue import Queue
#import matplotlib.pyplot as plt
#class NetX_NeuroPlot(IPlot):
# ########... | true |
1b3af9b0f4cb02955cbefc3de3fcdfce16ba6b4b | Python | starzc-galaxy/Dynamic-desktop | /main.py | UTF-8 | 781 | 2.671875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""一个设置视频成动态壁纸的工具
"""
__author__ = "zc"
import sys
from PyQt5.QtWidgets import QApplication
from PyQt5.QtNetwork import QLocalSocket,QLocalServer
from wallpaper import Wallpaper
if __name__ == '__main__':
app = QApplication(sys.argv)
serverName = 'wallpaper'
socket = QLocalSocket()... | true |
0a3bdd12583b530a086ab6d1cb89c7948b8a555a | Python | Kenpatner/Python210_Fall2019 | /students/Ken Patner/lesson02/print_grid.py | UTF-8 | 330 | 3.5 | 4 | [] | no_license | def gridprinter(n):
plus = "+"
minus = "-"
line = "|"
print (plus + minus *n + plus+ minus *n + plus)
for i in (range(n)):
print (line+ " "*n + line + " "*n+line)
print (plus + minus *n + plus+ minus *n + plus)
for i in (range(n)):
print (line+ " "*n + line + " "*n+line)
grid... | true |
476aaef8632f785ad26dd14878c608e0f03eafa1 | Python | Sonia-96/Coding4Interviews | /剑指offer/python/1-二维数组中的查找/1-search_in_2D_array.py | UTF-8 | 1,266 | 3.609375 | 4 | [] | no_license |
class Solution:
# Brute Force
def Find1(self, target, array):
n = len(array)
for i in range(n):
if target in array[i]:
return 'true'
return 'false'
# Divide and Conquer
def Find2(self, target, array):
row = len(array)
col = len(array[... | true |
31319e5ad7063dd535d237647c0692ff92aa4e17 | Python | ladyy27/comparacion-planes-NLP | /NLPcode_Lady/proyNLP/detectIdioma.py | UTF-8 | 3,300 | 3.1875 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
########Import textblob
from textblob import TextBlob
from detect_es import *
from detect_en import *
import codecs
#######
""""
stopwordslist = []
with codecs.open('spanish', encoding='utf-8') as f:
for line in f.readlines():
stop = line
stop2 = stop.replace... | true |
9b86756b326b8e9ef7776a03233a23626c858498 | Python | buzoherbert/6.867-Machine-Learinng-in-transportation-safety-perception | /write_confusions.py | UTF-8 | 1,949 | 2.828125 | 3 | [] | no_license |
import csv
import numpy as np
matrices_acc = []
matrices_f1 = []
matrices_reg = []
matrices_gp = []
with open('all_confusions.txt') as file:
i = 0
rows = []
for line in file:
line = line.strip()
if len(line) < 1:
continue
if line[-1] == ":":
i += 1
... | true |
adf06cb5e0f52f96dbb3ad75e6db96a8212dbff5 | Python | AhmedAbdElfatah999/AI-Project-Bounded-and-Unbounded-Knapsack- | /knapsack (PSO).py | UTF-8 | 3,839 | 3.703125 | 4 | [] | no_license | #Define Item class
class Item:
#each with a weight and a value
def __init__(self, weight, value):
self.weight = weight
self.value = value
def Bounded_Knapsack(items, capacity):
knapsack = [] #knapsack container
knapsack_weight = [] #array save all item value's kept in knapsack
knapsack_value = [] #a... | true |
9d8930430efd7c3cc4e430c555615b4eca204e3a | Python | MatheusFeijoo/lyriclook | /bot.py | UTF-8 | 2,862 | 2.765625 | 3 | [] | no_license | import telebot
from telebot import types
import time
from search import pega
bot_token = "795674646:AAHY7s8Xetv-XZK8HKtTQGnzdG2_cL6NDII"
bot = telebot.TeleBot(token=bot_token)
user_dict = {}
class User:
def __init__(self, name):
self.name = name
self.music = None
@bot.message_handler(commands... | true |
706008a7db63bcadbbcddde09a1612c1ee320045 | Python | DaHuO/Supergraph | /codes/CodeJamCrawler/16_0_2/wojiefu/B.pancage.py | UTF-8 | 415 | 3.65625 | 4 | [] | no_license | def flip_count(s):
prev = s[0]
item = s[0]
n = 0
for item in s[1:]:
if item != prev:
prev = item
n += 1
if item == '-':
n += 1
return n
def main():
t = int(raw_input())
for i in xrange(1, t+1):
cakes = str(raw_input())
... | true |
067f1274140a6ff88f1537f1b1cce9b3bb22a6f2 | Python | liquor1014/python_study | /guess_word.py | UTF-8 | 2,193 | 3.015625 | 3 | [] | no_license | import jieba
from wordcloud import WordCloud
from scipy.misc import imread
# 读取文件
with open('D:/Python/Text1/wenjian/threekingdom.txt', 'r', encoding='utf-8') as f:
text = f.read()
# 分词
word_list = jieba.lcut(text)
# print(word_list)
# # 将列表转化成字符串
# words = ' '.join(word_list)
# # 绘制词云
# wc = WordCloud(
# ... | true |
07dd6f4cc33405427524220447fb2cf471c6a6f6 | Python | sydgarnett/PokemonChooser | /Testing/buttontest2.py | UTF-8 | 1,189 | 3.4375 | 3 | [] | no_license | #!/usr/bin/env python3
from tkinter import *
class Application(Frame):
"""a GUI application with 3 buttons"""
def __init__(self,master):
Frame.__init__(self,master)
self.grid()
self.createWidgets()
def createWidgets(self):
self.instruction= Label(self,text= "enter the passw... | true |
930d7eb0a8e27f32f6bffacb12af019ba74eb398 | Python | Int-TRUE/2021knupython | /3. recursion+condition/while_recursion.py | UTF-8 | 502 | 3.984375 | 4 | [] | no_license | # for와 while의 차이
# for문은 정해진 횟수만큼 돌린다
# while문은 정해진 목표까지 돌린다 -> 조건이 참인 경우
# while문 기초
it = 0
while it <5:
it+=1
print(it)
# while문 구조
# while 조건:
# 반복할 명령어1
# 반복할 명령어2
# while 무한루프
# overflow
# it=0
# while True:
# it+=1
# print(it)
# Ctrl + c로 탈출
# while 무한루프 + break
it = 0
while True:
... | true |
aa0529a05b43b3152d392e79040ac84a8cbeecf7 | Python | kuzminArtur/foodgram-project | /recipes/templatetags/user_filters.py | UTF-8 | 576 | 2.671875 | 3 | [] | no_license | from django import template
register = template.Library()
@register.filter
def addclass(field, css):
"""Add CSS class."""
return field.as_widget(attrs={"class": css})
@register.filter
def get_num_ending(num, ending):
"""Make correct declination."""
ending = ending.split(',')
remainder = num % ... | true |
0d6b62be336e6c47a650512872405d7d4366f1ff | Python | sy1wi4/ASD-2020 | /sorting/radix_sort.py | UTF-8 | 1,207 | 3.671875 | 4 | [] | no_license | # sortujemy kolejno "kolumnami" od najmniej znaczacych cyfr, czyli zaczynajac od ostatniej pozycji az do pierszej
# kazda kolumne sortujemy stabilnym counting sortem
from random import randint
def countingSort(arr,pos):
# modyfikacja - sortujemy wzgledem danej cyfry (pos ma wartosci 1, 10 ,100, etc.(cyfra jed... | true |
d3faca8f594f5932e94cfaf32eb96388c930d4b7 | Python | benjaminhuanghuang/py-selenium-job-apply | /login.py | UTF-8 | 1,529 | 2.640625 | 3 | [] | no_license | from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException, ElementClickI... | true |
8938a8415ba96730e576c530dcf8fe8faded0276 | Python | bvsbrk/Algos | /src/CodeChef/snackdown_1a/cardmgk.py | UTF-8 | 777 | 2.671875 | 3 | [] | no_license | from bisect import bisect_right as bs
from collections import Counter
if __name__ == '__main__':
for _ in range(int(input().strip())):
n = int(input().strip())
arr = [int(__) for __ in input().strip().split()]
srtd = sorted(arr)
co = Counter(arr)
if arr == srtd:
... | true |
6730578fa7ddc48e1614f7cdece0495b32fe0384 | Python | danielct/Honours | /Numerics/Pumps.py | UTF-8 | 1,318 | 3.4375 | 3 | [] | no_license | import numpy as np
class SpatialFunction(object):
"""
Not to be used.
Parent class for spatial functions such as the pump and potential.
Spatial functions are required to provide a function that corresponds to
the spatial function. Eg, for a pump, the function would take an x grid and
y grid a... | true |
2d2510756b24a90f2a7fb145f37c5a5110b32ff4 | Python | gregorgabrovsek/ProjectEuler | /Problem058.py | UTF-8 | 841 | 3.640625 | 4 | [] | no_license | # Setting the diagonal direction functions:
u_r = lambda x: 4 * (x ** 2) - 10 * x + 7 # OEIS: A054554
u_l = lambda x: 4 * ((x - 1) ** 2) + 1 # OEIS: A053755
d_l = lambda x: 4 * (x ** 2) - 6 * x + 3 # OEIS: A054569
d_r = lambda x: (2 * (x - 1) + 1) ** 2 # OEIS: A016754
is_prime = lambda y: y % 2 == 1 and len(list(fi... | true |
e75290144f8e5da84c1698d3eb8e08a0922b669a | Python | San-Holo/Adversarial-generation | /utils/build_network_utils_2D.py | UTF-8 | 7,144 | 3.0625 | 3 | [] | no_license | import numpy as np
import pandas as pd
import torch
import torch.nn as nn
def conv_block(in_filter, output_filter, nb_conv, kernel_size, stride, padding, final_nbchannels, normalize, wasserstein, layer_norm, spectral_norm, dropout, activation_function=nn.LeakyReLU(0.2, inplace=True)):
"""To simplify the cr... | true |
5ec286b6bc07d645aa2789d0976e5b81083b06d3 | Python | samar2326/Python-Programs | /copy.py | UTF-8 | 542 | 3.84375 | 4 | [] | no_license |
""" Wap to copy from 1 file to another"""
from shutil import copyfile
print("Enter x for exit")
source_file = input("Enter source file name:")
if(source_file == "x"):
exit()
else:
destination_file = input("Enter destination file name:")
copyfile(source_file,destination_file)
print("File cop... | true |
2b15a2385ba8f9eaea875b346596a02f9e0be4f7 | Python | AndreyPankov89/python-glo | /lesson11/task1.py | UTF-8 | 291 | 3.984375 | 4 | [] | no_license | n = int(input('Введите количество фраз '))
phrases = []
for i in range(n):
phrases.append(input())
search_phrase = input('Введите фразу для поиска ')
for phrase in phrases:
if(search_phrase.lower() in phrase.lower()):
print(phrase) | true |
5e694d37864ca1a89e1cf35e30807945e6fc5faf | Python | michaelSmithUCC/bored_games | /db_functionality/setup_db.py | UTF-8 | 493 | 2.609375 | 3 | [] | no_license | def words_connect():
import pymysql as db
failed=0
server="----"
database="----"
username="----"
password="----"
try:
connection = db.connect(server, username, password, database)
if connection:
cursor =connection.cursor(db.cursors.DictCursor)
if cur... | true |
c9fbe4cdacfb4d1f46a55e827ae9776be85194ef | Python | witness97/computationalphysics_N2015301020062 | /6 in one.py | UTF-8 | 441 | 3.046875 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 1 14:38:00 2018
@author: wangshiru
"""
from pylab import *
from random import choice
numwalk = 6
length = 200
data = zeros((numwalk, length), int)
for n in range(numwalk):
for x in range(1, length):
step = choice([-1, 1])
data[n,x] = data[n,x... | true |
5182bf4b4bad3f873ece298b59c193ad51980540 | Python | pawandeepthind/dev-multivm | /server/library/download.py | UTF-8 | 1,353 | 2.90625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Author: Pawandeep Singh - @rohit01 <pawandeep.singh@expicient.com>
#
# Ansible module to download file from ftp.
#
#---- Documentation Start ----------------------------------------------------#
DOCUMENTATION = '''
---
version_added: "2.0.1"
module: download
short_descrip... | true |
fa412be4974180b52b753b7ef87854eb92068c7f | Python | bcwan/PythonRepo | /Horse/Inheritance/Chef.py | UTF-8 | 199 | 2.625 | 3 | [] | no_license | class Chef:
def make_chicken(self):
print("Cook the chicken!")
def make_salad(self):
print("Make the salad.")
def make_special_dish(self):
print("Make a special dish tonight!") | true |
f5a52d9c640519e18a85c830a2a2ed4cc4a06f5a | Python | astrofrog/old-astropy-versions | /v0.4.2/api/astropy-convolution-Box1DKernel-1.py | UTF-8 | 221 | 2.765625 | 3 | [
"BSD-3-Clause"
] | permissive | import matplotlib.pyplot as plt
from astropy.convolution import Box1DKernel
box_1D_kernel = Box1DKernel(9)
plt.plot(box_1D_kernel, drawstyle='steps')
plt.xlim(-1, 9)
plt.xlabel('x [pixels]')
plt.ylabel('value')
plt.show() | true |
1c6d6af25fe9aac936e8d91371d4ff8f11b4ff51 | Python | sreejithev/thinkpythonsolutions | /c5/condition.py | UTF-8 | 157 | 3.640625 | 4 | [] | no_license | x = input(int)
if x > 0:
print ' x is positive'
if x < 0:
pass # need to handle negative values!
if x%2 == 0:
print 'x is even'
else:
print 'x is odd'
| true |
595be2e074283aa43763c3fd9188e480ba0c5de1 | Python | abdallawi/PythonBasic | /Exercices/ExaminationSchedule.py | UTF-8 | 209 | 3.46875 | 3 | [] | no_license |
exam_st_date = (12, 10, 2019)
print(f'The examination will start from :', exam_st_date[0], '/', exam_st_date[1], '/', exam_st_date[2])
print("The examination will start from : %i / %i / %i" % exam_st_date)
| true |
6e5ceb89e3a6cee5802469f2a70c88761b8f1fdf | Python | brickgao/leetcode | /src/algorithms/python/Surrounded_Regions.py | UTF-8 | 2,015 | 3.359375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
from Queue import Queue
class Solution:
def bfs(self, x, y):
q = Queue()
q.put((x, y))
self.vis[x][y] = True
self.mat[x][y] = True
while not q.empty():
top_x, top_y = q.get()
for mv in self.mvs:
nx, ny = top_x... | true |
d117d2a686eee4d9cfbfac9004b4b28498bb8dca | Python | yestherlee/samplefiles | /Homework 3.py | UTF-8 | 3,149 | 3.71875 | 4 | [] | no_license | #Homework 3 by Ye Eun (Esther) Lee
#Establish Monopoly property group data
psize = {'purple':2, 'light blue':3,'maroon':3, 'orange':3, 'red':3, 'yellow':3, 'green':3, 'dark blue':2}
pcost = {'purple':50, 'light blue':50,'maroon':100, 'orange':100, 'red':150, 'yellow':150, 'green':200, 'dark blue':200}
#Input co... | true |
8060df2db16a83e42a407e355154a6119928cdee | Python | hrtoomer/BIOL5153 | /assn07.py | UTF-8 | 1,981 | 3.34375 | 3 | [] | no_license | #! /usr/bin/env python3
# assn07
from Bio import SeqIO
import argparse
fasta_file='watermelon.fsa'
gff_file ='watermelon.gff'
def get_args():
# create an argument parser object
parser = argparse.ArgumentParser(description = 'This script returns the Fibonacci number at a specified position in the Fibonacci seque... | true |
824af8fc65ff787d3da4a303c0f1e0745dd00947 | Python | kumgleb/SemanticSegmentation | /utils/train_utils.py | UTF-8 | 995 | 2.90625 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
def train_monitor(losses_train, losses_train_mean, losses_val):
fig, ax = plt.subplots(1, 2, figsize=(16, 8))
iters = np.arange(len(losses_train))
n_vals = len(losses_val)
step = int(len(losses_train) / n_vals)
val_steps = np... | true |
a3aae4b00c8b4aa2e64b65b6ab9d1c78255182bc | Python | MarceloBCS/Exercicios_Curso_em_video | /aula_020.py | UTF-8 | 752 | 4.125 | 4 | [] | no_license | def mensagem(txt):
print('-='*10)
print(txt)
print('-='*10)
def soma(a, b):
print(a+b)
def som_pac(*tam):
s = 0
for c in tam:
s += c
print(f'somando os {tam} é {s}')
def contador(*num):
for c in num:
print(num, end='')
print(c, end=' | ')
print()
def d... | true |
62e2b74a80e24805b9db3d6eaa00886dfee6a998 | Python | Clem28L/test | /Chapitre11/SearchString.py | UTF-8 | 309 | 3.734375 | 4 | [] | no_license | SearchMe = "La pomme est rouge et la luzerne est verte !"
print(SearchMe.find("est"))
print(SearchMe.rfind("est"))
print(SearchMe.count("est"))
print(SearchMe.startswith("La"))
print(SearchMe.endswith("La"))
print(SearchMe.replace("pomme", "voiture")
.replace("luzerne", "camionnette"))
| true |
824f66b3ce854d993ac3dd2a0ecd3091a8b13bcc | Python | manosai/tweepy | /assignment_4/majority_vote_template.py | UTF-8 | 2,996 | 3.46875 | 3 | [
"MIT"
] | permissive | #!/bin/python
import csv
import operator
from label_map import mturk_labels
class MajorityVoteGrader():
"""
Implements majority vote quality estimation.
estimate_data_labels returns the most popular label for each tweet
estimate_worker_qualities returns, for each worker, the proportion of labels which matched th... | true |
f0ed8ecfbc426a6ef738430e07c438a4e4b75e4b | Python | Mertkmrc/video-feedback-system | /windowing.py | UTF-8 | 2,756 | 2.625 | 3 | [] | no_license | from sklearn.metrics.pairwise import cosine_similarity
from transformers import AutoTokenizer, AutoModel
import torch
def wndw(input, win_len):
out = []
idx = []
step_size = int(win_len / 2)
le = len(input)
base_idx = 0
end_idx = win_len
# print(le)
while (end_idx < le):
... | true |
b78eef7bd2443a5120f129c112462b64aa4d1f6c | Python | Hyper10n/LearningPython | /find_from_txt_file.py | UTF-8 | 323 | 2.90625 | 3 | [
"MIT"
] | permissive | def find_from_txt_file(source):
email_list = []
try:
fhand = open(source)
except:
print('Could not open file')
for line in fhand:
for word in line.split():
if word == 'From':
email_list.append(line.split()[1])
fhand.close()
return email_li... | true |
0aba617ab855c93d848836723091caa4289d50d0 | Python | MichalMaM/ella | /ella/core/templatetags/authors.py | UTF-8 | 2,517 | 3.0625 | 3 | [
"BSD-3-Clause"
] | permissive | from django import template
register = template.Library()
class AuthorListingNode(template.Node):
def __init__(self, obj_var, count, var_name, omit_var=None):
self.obj_var = obj_var
self.count = int(count)
self.var_name = var_name
self.omit_var = omit_var
def render(self, con... | true |
88492d2ddd14c32ea3abfe6e148eb2f8cd1195ed | Python | Susama91/Project | /W3Source/List/list8.py | UTF-8 | 145 | 4.03125 | 4 | [] | no_license | #Write a Python program to check a list is empty or not
l=[10,20]
if not l:
print("empty list")
else:
print("list contains element: ",l)
| true |
e218b7f5777a8f95b9ecbeac280b7b0b72144ac1 | Python | 18720936539/CANTEMIST | /cantemist/cantemist-evaluation-library-master/src/main.py | UTF-8 | 1,835 | 2.625 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 8 15:22:29 2020
@author: tonifuc3m
"""
import argparse
import warnings
import cantemist_coding
import cantemist_ner_norm
def warning_on_one_line(message, category, filename, lineno, file=None, line=None):
return '%s:%s: %s: %s\n' % (filename,... | true |
cbdbacccdf996cc5d3081796af309aa3716090bf | Python | melikesenol/PythonBeginnerExercise | /Decorators/decorator.py | UTF-8 | 384 | 3.96875 | 4 | [] | no_license | # High order function -> Excepts another function inside
# Decorators Pattern
def my_decorator(func):
def wrap_func(*args, **kwargs):
print('****')
func(*args, **kwargs)
print('******')
return wrap_func
@my_decorator
def hello(greeting, emoji = ':('):
print(greeting, emoji)... | true |
9d6065c2d8a539821ac0a1d57f60b6a8b2076080 | Python | ZiyaoGeng/LeetCode | /Code/199.py | UTF-8 | 553 | 2.859375 | 3 | [] | no_license | from typing import List
import sys
sys.path.append('../functions/')
from tree import TreeNode
class Solution:
def rightSideView(self, root: TreeNode) -> List[int]:
if root == None:
return None
que, l = [], []
count, length = 0, 1
que.append(root)
while len(que) != 0:
p = que.p... | true |
cec776fd9bbd3e094f9d3de8e63e0b5f1ccba5eb | Python | KazukiOhta/tsglive | /workingDirectoy/main.py | UTF-8 | 17,552 | 3.015625 | 3 | [] | no_license | from math import exp
"""
Matrix class (substitution for numpy)
"""
class matrix():
def __init__(self, lst2d=[], filename=None):
if filename == None:
self.matrix = lst2d
else:
with open(filename) as f:
self.matrix = list(map(lambda line: list(map(float, line.sp... | true |
71587e214e407cb551fef282843da83e98bd3dd4 | Python | SebastianRehfeldt/dash-slideshow | /src/elements/plot.py | UTF-8 | 585 | 2.859375 | 3 | [] | no_license | """Module for creating plots"""
import pandas as pd
import dash_core_components as dcc
import plotly.graph_objects as go
def create_histogram(df: pd.DataFrame, column: str) -> dcc.Graph:
"""Create Histogram for dataframe and column"""
return dcc.Graph(
id="graph-{:s}".format(column),
... | true |
a02c3d6da597fe43a4cbd9a74481f767516c78f0 | Python | USC-NSL/ALPS_code | /test_plot_fig/data_for_fig/plot_cdf.py | UTF-8 | 1,026 | 2.65625 | 3 | [] | no_license | import numpy as np
import os,sys
import matplotlib.pyplot as plt
X_LIM = 30
LINE_WIDTH = 3
FONT_SIZE = 17
X_LABLE = 'error(m)'
Y_LABLE = 'CDF'
TITLE = 'Distribution of errors (MTV)'
color_list = ['g', 'r']
legend_list = ['ALPS','Google']
for i in range(1,len(sys.argv)):
data = np.loadtxt(sys.argv[i])
sorted_data ... | true |
ab5234274e23320a2d3088b8209bfb23d4ed8d4f | Python | ManishBhat/Project-Euler-solutions-in-Python | /P345_matrix_sum/P345.py | UTF-8 | 1,031 | 3.28125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon Sep 28 10:00:41 2020
@author: Manish
"""
def f(a):
n = len(a)
rowchosen = {}
c = 0
for r in range(n):
rowchosen[frozenset([r])] = a[r][c]
for c in range(1, n):
newrow = dict()
for x in rowchosen:
range2 = frozenset(ran... | true |
252ed9bbb7bda3768719325b81dd3f5fc0ad5324 | Python | SundeepChand/Ride-the-Road | /play.py | UTF-8 | 5,696 | 3.546875 | 4 | [
"MIT"
] | permissive | import pygame
import random
# Define some colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GRAY = (159, 163, 168)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
CAR_COLOR = (181, 230, 29)
TEXT_COLOR = (250, 105, 10)
pygame.init()
class Car:
def __init__(self, x=0, y=0, dx=4, dy=0, width=30, height=30, ... | true |
17f9ea65e769670503d6692d25e5d264762786e2 | Python | g4m3rm1k3/data-struct-algo-s | /recursive_fib.py | UTF-8 | 563 | 4.40625 | 4 | [] | no_license | def fib_recur(n):
if n == 0:
return 0
elif n == 1:
return 1
return fib_recur(n-1) + fib_recur(n-2)
def long_fib(n):
if n == 0:
return 0
elif n == 1:
return 1
else:
prev = 0
next = 1
for i in range(n-1):
print(f"{prev} + {next} = {prev + next}")
prev, next = next, p... | true |
4dc4039ffd8825848210b85f0fc1dd3c6d6936f9 | Python | buiquangmanhhp1999/Age-Gender-Classification-Based-On-ShuffleNet | /ex.py | UTF-8 | 836 | 2.640625 | 3 | [] | no_license | from PIL import Image
import cv2
im1 = Image.open('./chaubui.png')
im2 = Image.open('./hoailinh_result.png')
def get_concat_h_resize(im1, im2, resample=Image.BICUBIC, resize_big_image=True):
if im1.height == im2.height:
_im1 = im1
_im2 = im2
elif (((im1.height > im2.height) and resize_big_im... | true |
4155badf43d2a0acec64ca8f128b4f8928caa309 | Python | MLAlg/EGC-Dataset-Analysis | /analysis.py | UTF-8 | 2,254 | 2.625 | 3 | [] | no_license | # Prepare Environment
import sys
colab = 'google.colab' in sys.modules
# Download the dataset from my drive(fixed format issue)
if colab:
!wget 'https://drive.google.com/uc?authuser=0&id=1rseU8HjF16lq87CjVtVCLbhrUCqt_lzi&export=download' -O "EGC_dataset.csv"
#imports
import pandas as pd
import numpy as np
import str... | true |
cb27de811eabb5e0fae2559d1d3367ab1643f068 | Python | Parwej0007/FASTAPI-crud-Authentication-Token-ForgetPasswordByEmail-Login | /main.py | UTF-8 | 1,492 | 2.71875 | 3 | [] | no_license | from fastapi import FastAPI
# from pydantic_v import TestPostValidate
from pydantic import BaseModel
from typing import Optional, List
# for debug import uvicorn
import uvicorn
# make FastAPI instance with name app
app = FastAPI()
# DO CRUD WITHOUT DATABASE
# Run - uvicorn module_name:app --reload
# start fir... | true |
9a41f2c7af072d98686996c6ce0c7a60ff1e142e | Python | saidaaisha/enron_CollocateNetworks | /collocation_experiments/code/score_calc_swl.py | UTF-8 | 5,133 | 2.515625 | 3 | [] | no_license | #!/usr/bin/python2.7
from __future__ import division
from multiprocessing import Process, Queue
from nltk.tokenize import sent_tokenize
from nltk import word_tokenize
from collections import Counter
from math import floor, sqrt, log
from time import time
from sys import argv
import Queue as que
import re
import os
impo... | true |
1a9a383292c88aa80b16eb0733d45511d970db2c | Python | yingchuanfu/Python | /com/python5/Pass.py | UTF-8 | 428 | 3.78125 | 4 | [] | no_license | # -*- coding: UTF-8 -*-
#pass语句:Python pass语句是空语句,一般用做占位符,不执行任何实际的操作,只是为了保持程序结构的完整性
#如下例子,else语句本来可以不用写,但写上更为完整,这时候pass占位的意义就体现出来了
num_set = [98, 94, 82, 67, 58, 90, 86]
for i in range(len(num_set)):
if num_set[i] < 60:
print("SomeOne failed!!!")
else:
pass | true |
9eb42e37ebfcc4d30af298c4248c7e56595bd307 | Python | Leahxuliu/Data-Structure-And-Algorithm | /Python/LeetCode2.0/DP/322.Coin Change.py | UTF-8 | 1,088 | 3.5625 | 4 | [] | no_license | #!/usr/bin/python
# -*- coding: utf-8 -*-
# @Time : 2020/05/11
'''
Method - DP
DP[i]: minimum number of coins when amount is i
Steps:
1.build a dp list, the list size is amount + 1; 0,1,2,....amount
2.scan list from 1 to amount
dp[i] = min(choose the coin, don’t)
= min(dp[i], dp[i - ... | true |
37364ab81582328059e676cc1252afb9faf7f54d | Python | lspgl/csat | /sectorImage/core/toolkit/intersection.py | UTF-8 | 526 | 3.28125 | 3 | [] | no_license |
def Intersection(ln1, ln2):
x1 = ln1.x1
y1 = ln1.y1
x2 = ln1.x2
y2 = ln1.y2
x3 = ln2.x1
y3 = ln2.y1
x4 = ln2.x2
y4 = ln2.y2
if (max(x1, x2) < min(x3, x4)):
return False
A1 = (y1 - y2) / (x1 - x2)
A2 = (y3 - y4) / (x3 - x4)
b1 = y1 - A1 * x1
b2 = y3 - A2 * x... | true |
4b1859778942830b062f420d4be192c060506874 | Python | lumeng689/gist | /py/skr/mf_case_5.py | UTF-8 | 952 | 2.5625 | 3 | [] | no_license | import sklearn
from sklearn.datasets import load_digits
from sklearn.model_selection import cross_val_score
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
from sklearn.model_selection import learning_curve
from sklearn.svm import SVC
import numpy as np
import mat... | true |
b271b2d0431d9921b5e77d3b9af747d06e752638 | Python | mstroehle/pydent | /pydent/marshaller/exceptions.py | UTF-8 | 2,922 | 3.0625 | 3 | [
"MIT"
] | permissive | """Marshalling exceptions."""
class MarshallerBaseException(Exception):
pass
class SchemaRegistryError(MarshallerBaseException):
"""Generic schema registry exception."""
class SchemaException(MarshallerBaseException):
"""A generic schema exception."""
class SchemaModelException(MarshallerBaseExcepti... | true |
b86950ec7eafb7b662209e7a7907f69fd3086176 | Python | vaibhavpandey11/daily_coding_problem | /Problem 031.py | UTF-8 | 780 | 4.09375 | 4 | [] | no_license | '''
This problem was asked by Google.
The edit distance between two strings refers to the minimum number of character insertions, deletions, and substitutions required to change one string to the other.
For example, the edit distance between "kitten" and "sitting" is three: substitute the "k" for "s", substitute the... | true |
aedfa1d39eaddb0748586e7e0b9f4cec23b7e304 | Python | abnsl0014/-Machine-Learning-to-Detect-Fake-News | /DATA+SET+2+ACCURACY+PREDICTIONS.py | UTF-8 | 16,769 | 3.15625 | 3 | [] | no_license |
# coding: utf-8
# ## Importng the packages and modules required in the project
# In[328]:
import pandas as pd
import numpy as np
import csv
from sklearn import naive_bayes
from sklearn.naive_bayes import MultinomialNB
from sklearn.neighbors import KNeighborsClassifier
from sklearn import svm
from sklearn.svm import... | true |
a999f14bc3d6730cc2ba315a6ea7f1736c1373e5 | Python | kenoskynci/mad_topic_model | /visualization/examples/flarify.py | UTF-8 | 788 | 3.03125 | 3 | [] | no_license | import sys
import json
from features import analyzer, meter
text_key = "name"
child_key = "children"
ngram_parsers = {
'pos': analyzer.pos_ngrams,
'etymology': analyzer.etymology_ngrams,
'word_count': analyzer.word_count_ngrams,
'syllable': analyzer.syllable_ngrams,
'syllable_count': analyzer.syll... | true |
ec89f170a223a06d1743ba7d8a201176928a2545 | Python | Leedk3/pytorch_study | /neural_network_tutorial.py | UTF-8 | 3,243 | 3.328125 | 3 | [] | no_license | import torch
import torch.nn as nn
import torch.nn.functional as F
device = 'cuda' if torch.cuda.is_available else 'cpu'
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
# input : 1 image channel
# output : 6 ouput channels, 3x3 conv. kernel.
self.conv1 = nn.C... | true |
02ac224b90a817169df695b1a10e2e8a5b2d0447 | Python | InsightSoftwareConsortium/ITK | /Utilities/Doxygen/mcdoc.py | UTF-8 | 6,799 | 2.78125 | 3 | [
"IJG",
"Zlib",
"LicenseRef-scancode-proprietary-license",
"SMLNJ",
"BSD-3-Clause",
"BSD-4.3TAHOE",
"LicenseRef-scancode-free-unknown",
"Spencer-86",
"LicenseRef-scancode-llnl",
"FSFUL",
"Libpng",
"libtiff",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-other-permissive",
... | permissive | #!/usr/bin/env python
import sys, os, re, glob
try:
import io
except ImportError:
import cStringIO as io
def usage():
sys.stdout.write(
"""usage: mdoc.py set group file [files...]
Add the tag "\\ingroup group" to all the doxygen comment with a \\class
tag in it.
usage: mdoc.py check group f... | true |
7db9c9a70159ef0c9b625e986855b37f855a0ab9 | Python | moontasirabtahee/Problem-Solving | /Leetcode/20 Valid Parentheses.py | UTF-8 | 826 | 3.546875 | 4 | [] | no_license | from collections import deque
# Used deque instead of List as deque is faster than List by performance
class Solution:
def isValid(self, s: str) -> bool:
stack = deque()
parentheses = {
"opening": ['(', '{', '['],
"closing_pair": {
")": '(',
... | true |
b1fc69ca7dae24ff590cee8a258c482cd3db87bf | Python | JoseCordobaEAN/refuerzo_programacion_2018_1 | /sesion_2/es_par.py | UTF-8 | 231 | 4 | 4 | [
"MIT"
] | permissive | # Solicitamos el número al usuario
numero = int(input("Ingrese su número\n"))
# Validamos que el dividendo sea par
if numero % 2 == 0:
print("El dividendo",numero,"es par")
else:
print("El dividendo ",numero,"es impar")
| true |
6199846d1501688de64a7a10099afb83ccf16ce2 | Python | HallidayJ/comp61542-2014-lab | /src/comp61542/fastgraph.py | UTF-8 | 2,606 | 3.375 | 3 | [] | no_license | # module fastgraph
# created by Gribouillis for the python forum at www.daniweb.com
# November 9, 2010
# Licence: public domain
# This module defines 3 functions (node, edge and graph) to help
# create a graph (a pygraphviz.AGraph instance) linking arbitrary
# python objects.
# This gra... | true |
7df2210b6377905d51b920f6b054ba8d9ee0278f | Python | rodrigopscampos/python-lp | /ifs/ex4.py | UTF-8 | 210 | 4.3125 | 4 | [] | no_license | #Leia um número, se < 10, criança, se < 18 adolescente, se não, adulto
a = int(input('Informe uma idade: '))
if a < 10:
print('Criança')
elif a < 18:
print('Adolescente')
else:
print('Adulto') | true |
ba3d8a064d0ac0e7add3596e91cd699278ae975c | Python | Liyubov/bikeshare-simulation | /data_prep/data_prep.py | UTF-8 | 1,451 | 3.125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon Nov 30 18:13:32 2020
@author: freddy
Create a JSON file, containing date, time and corresponding weight matrix.
"""
import pandas as pd
import os
if __name__ == "__main__":
data = pd.read_csv("../data/biketrip_data.csv")
data_agg = data[["start_station_id", "end_... | true |
6a4e293b0eed78f50912ae3b540f992ce7d1c62d | Python | ProgramSalamander/AlgorithmLesson | /管道网络.py | UTF-8 | 2,316 | 3.859375 | 4 | [] | no_license | # 管道网络
# 描述
#
# Every house in the colony has at most one pipe going into it and at most one pipe going out of it.
# Tanks and taps are to be installed in a manner such that every house with one outgoing pipe but no incoming pipe gets a tank installed on its roof and every house with only an incoming pipe and no outgoi... | true |
dc77b7b7d811e55b7cbe4a3848f5b6bdf3bd775a | Python | jdiazram/DL4CV_starterBundle | /321_import_image.py | UTF-8 | 264 | 2.9375 | 3 | [] | no_license | #pip install opencv-contrib-python
import cv2
image = cv2.imread("images/example.png") #importar la imagen
print(image.shape) #imprimir dimensiones de la imagen
cv2.imshow("Image", image) #mostrar en ventana nueva
cv2.waitKey(0) #se espera para cerrar la ventana | true |
a2c804b5f7eeb954ae587a3fa5cfa0462c6eaa70 | Python | github-cve-social-graph/cve | /code/get_cves.py | UTF-8 | 1,475 | 2.515625 | 3 | [] | no_license | import pymongo
import requests
import time
from datetime import datetime
from pymongo import MongoClient
client = MongoClient('mongodb+srv://erinszeto:Fall2020CKIDS!@erincluster.mvldp.mongodb.net/test')
db = client.ckids
collections = db.collection_names()
if "cve" in collections: # If collection has been made alread... | true |
85f625d51e9fcee7cfc1dc31390b38591c162f8a | Python | droundy/sad-monte-carlo | /plotting/number-movie.py | UTF-8 | 3,955 | 2.65625 | 3 | [] | no_license | #!/usr/bin/python3
import yaml, sys
import numpy as np
import matplotlib.pyplot as plt
def latex_float(x):
exp = int(np.log10(x*1.0))
if abs(exp) > 2:
x /= 10.0**exp
if ('%.1g' % x) == '1':
return r'10^{%.0f}' % (exp)
return r'%.1g\times10^{%.0f}' % (x, exp)
else:
... | true |
17b86f798f73ea7555104d9d24f1fe763cb45358 | Python | SilkyAnt/rupeng_python | /python_workspaces/Seq_02_SelfWebServer/flaskLearning/04dynRoute.py | UTF-8 | 553 | 2.796875 | 3 | [] | no_license | # 动态路由
# 导入Flask模块
from flask import Flask
from flask import send_file
# 创建一个Flask的实例
app = Flask(__name__)
app.debug = True
# 注册一个路由
@app.route("/")
def index(): # 视图函数
# 代码直接访问静态页面,没有经过Jinja2 模板的渲染。
return send_file("../templates/03Hello.html")
@app.route("/user/<name>")
def user(name):
return "hell... | true |
fe0b7b17ff164b38f0ca0f6e66f2d0e571fffd3a | Python | robertvandeneynde/parascolaire-students | /antoine collon/test4.py | ISO-8859-2 | 1,408 | 2.796875 | 3 | [] | no_license | from __future__ import print_function, division
import pygame
pygame.init()
taille = [700, 700]
ecran = pygame.display.set_mode(taille)
NOIR = [0, 0, 0]
BLANC = [255, 255, 255]
ROUGE = [255, 0, 0]
VERT = [0, 255, 0]
BLEU = [0, 0, 255]
# DBUT
ma_position=100
sens=1
clock = pygame.time.Clock()
HAUT = 273
BAS = 274
G... | true |
206a08ba18411fc1f479c798eef72213bb7f507a | Python | rainwoodman/vmad | /vmad/core/tape.py | UTF-8 | 1,582 | 2.65625 | 3 | [
"BSD-2-Clause"
] | permissive | from . import get_autodiff
class Record(object):
""" A record on the tape.
A record contains the node and the resolved arg symbols to the node.
"""
def __init__(self, node, impl_kwargs):
self.node = node
self.impl_kwargs = impl_kwargs
def __repr__(self):
return '%s /... | true |
5bc37f35ecfb8761a8551ee3be1ea6b247c2fb79 | Python | Err0rdmg/python-programs | /right_triangle.py | UTF-8 | 412 | 3.4375 | 3 | [] | no_license | line = int(input("Enter numbers of lines you want:"))
# astriks = int(input("Enter numbers of astriks per line you want:"))
for i in range(line, 0, -1):
if i == 1 or i == line:
for j in range(1, i+1):
print("*", end="")
else:
for j in range(1, i+1):
if j == 1:
... | true |
cc74d0b018a8299983916320ed8210013df904fb | Python | jskway/data-structures-algorithms | /data_structures/binary_search_tree/binary_search_tree.py | UTF-8 | 2,799 | 4.09375 | 4 | [
"MIT"
] | permissive | import sys
sys.path.append('../stack')
from stack import Stack
from collections import deque
class BSTNode:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
"""
Inserts the value into the tree
"""
def insert(self, value):
if value < ... | true |
a7d81523c5350441e43482861ea69803268c9bc2 | Python | jaean123/SplineInterpolation | /cubic_interpolation.py | UTF-8 | 3,123 | 3.3125 | 3 | [] | no_license | # Cubic Spline Interpolation
import matplotlib.pyplot as plt
def cubic_interpolation(x, y):
n = len(x) - 1
h = [0 for i in range(n)]
b = h[:]
v = h[:]
u = h[:]
# SOME PRE-CALCULATIONS
h[0] = x[1] - x[0]
b[0] = (y[1] - y[0]) / h[0]
for i in range(0, n):
h[i] = x[i + 1] - ... | true |
156d4a1a82341ae7e12e8c52dfb5a407c71c0630 | Python | Hansung-Lee/SSAFY | /hphk/hphk_006/papago.py | UTF-8 | 1,790 | 3.234375 | 3 | [] | no_license |
# 네이버(파파고)야 내가 단어하나 전달할테니, 번역해줘
# 0. 사용자에게 단어를 입력받는다. (추가기능)
# 1. papago API 요청 주소에 요청을 보낸다.
# 2. 응답을 받아 번역된 단어를 출력한다.
import requests
import os
from pprint import pprint as pp
# 함수를 import하는 방법
# import pprint => pprint.pprint()
# from pprint import pprint => pprint()
# from pprint import pprint as pp => pp()
... | true |
abaf927b542299613b3be41b5a1653b484ce9c99 | Python | rkhous/Clemont | /bot.py | UTF-8 | 3,774 | 2.75 | 3 | [
"MIT"
] | permissive | import MySQLdb
from config import *
from requirements import *
import traceback
import sys
database = MySQLdb.connect(host, username, password, db)
database.ping(True)
cursor = database.cursor()
def find_pokemon_id(name):
if name == 'Nidoran-F':
return 29
elif name == 'Nidoran-M':
return 32
... | true |
d03198ee41fef426179868efd89dd6b7b6f806a1 | Python | lucernae/timesheets-converter | /scripts/report.py | UTF-8 | 5,463 | 2.78125 | 3 | [] | no_license | #!/usr/bin/env python
# coding=utf-8
from __future__ import print_function
from builtins import next
import argparse
from datetime import timedelta, datetime
from timesheets.timesheet import TimeSheets
from timesheets.format.harvest import HarvestTimeRecord
from timesheets.format.sageone import SageOneTimeRecord
from... | true |
d76c8e780a72cb91b6bbbf1ffe9142e1717d9249 | Python | abhishek2x/TKinterGUIPy | /GetReady19.py | UTF-8 | 277 | 2.96875 | 3 | [] | no_license | from tkinter import *
root = Tk()
root.title("Article")
root.geometry("654x567")
scrollbar = Scrollbar(root)
scrollbar.pack(side=RIGHT, fill=Y)
txt = Text(root, yscrollcommand=scrollbar.set)
txt.pack(fill=BOTH)
scrollbar.config(command=txt.yview)
root.mainloop() | true |
9fc69de43a5bc539068489bce8f5892d84fc0047 | Python | simsimplay/raspverry_exe | /HC_SR04.py | UTF-8 | 838 | 2.96875 | 3 | [] | no_license | #-*- coding: utf-8 -*-
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
TRIG = 23
ECHO = 24
print('Distance measurement in progress')
# Trig and Echo 핀의 출력/입력 설정
GPIO.setup(TRIG, GPIO.OUT)
GPIO.setup(ECHO, GPIO.IN)
GPIO.output(TRIG, False)
print('Waiting for sensor to settle')
tim... | true |