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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
2ee6a6e6a8bd76ae0a78c83b3aa90ace74928275 | Python | fbidu/Etudes | /challenges/cod01.py | UTF-8 | 1,910 | 4.0625 | 4 | [] | no_license | import re
def encode_timeslot(time_string):
"""
takes an string in the format Wed 04:25 and returns its position
in a list indexing every minute in a week.
>>> encode_timeslot("Mon 00:00")
0
>>> encode_timeslot("Mon 00:01")
1
>>> encode_timeslot("Mon 01:00")
60
>>> encode_t... | true |
5c473d1d3883b002e8a0ddbbaf9fb502f2e8dae3 | Python | maistrovas/My-Courses-Solutions | /MITx-6.00.2x/Exam_answers.py | UTF-8 | 11,020 | 4.03125 | 4 | [
"MIT"
] | permissive | '''
Problem_1
1."Coefficient of variation" means the coefficient of
the polynomial curve that fits the data best.
-False
2.If we let the k-means clustering algorithm run for a
very long time, we will eventually end up with all the
data points in one cluster.
-False
3.Training an algorithm on data set A and then t... | true |
14f1ae688ef96b51e28e0826d39caa42e8ce6f70 | Python | ahmad2016umkc/_-Code-Learn-Program-with-Python | /Part 2 Learn Program Loops/Part_02_02_Loops_PrintOddNumber.py | UTF-8 | 319 | 4.3125 | 4 | [] | no_license | # ---------- PROBLEM : PRINT ODDS FROM 1 to 20 ----------
# Use a for loop, range, if and modulus to print out the odds
# Use for to loop through the list from 1 to 21
for i in range(1, 21):
# Use modulus to check that the result is NOT EQUAL to 0
# Print the odds
if ((i % 2) != 0):
print "i = ", i | true |
ce7f6e3494f5a186fc5b05fec6bb435624a0f3f7 | Python | cesiztel/learning-roadmap | /refactoring/extract_variable_non_refactor.py | UTF-8 | 743 | 3.71875 | 4 | [] | no_license | class OrderRecord:
quantity = 0
item_price = 0
def __init__(self, quantity, item_price):
self.quantity = quantity
self.item_price = item_price
class Order:
def __init__(self, a_record):
self.data = a_record
def quantity(self):
return self.data.quantity
def it... | true |
437369f63470cb5855231e0a6b8903908c2e3f80 | Python | rlabuda96/Exercise | /Exercise 21.py | UTF-8 | 144 | 3.71875 | 4 | [] | no_license | var_a=int(input("First nubmer:"))
calculating=var_a%2
if calculating == 0:
print("Number is even")
else:
print("Number is odd") | true |
bdd17766d4350a81db6b5259fc842516848553db | Python | wang119c/python | /python_jinjie/4/4-5.py | UTF-8 | 494 | 3.296875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf8')
# 如何对字符串进行左右,居中对齐
# 方法一
# s = 'abc'
# print s.ljust(20)
# print s.rjust(20)
# print s.center(20)
# 方法二
# s = 'abc'
# print format(s, '<20')
# print format(s, '>20')
# print format(s, '^20')
d = {
'zhangsan': 10,
'lisi': 10,
... | true |
8146e0d725f4f492bfb4d596729a62b64ffe6f8b | Python | Hbretonniere/galcheat | /galcheat/__main__.py | UTF-8 | 312 | 2.53125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | from galcheat import survey_info
def main():
for survey, info in survey_info.items():
print(survey, ":")
print(" ", info)
print(" Filters :")
for filtinfo in info.get_filters():
print(" ", filtinfo)
print()
if __name__ == "__main__":
main()
| true |
e9b6350422e036d79b21bb6f9e84816dc37aef4c | Python | Meumax/2019CropDesease | /code/CropDataset.py | UTF-8 | 2,792 | 2.890625 | 3 | [] | no_license | # coding: utf-8
from torch.utils.data import *
import torchvision.transforms as transforms
from PIL import Image
from torchvision.datasets import ImageFolder
from augmentation import HorizontalFlip
class MyDataset(Dataset):
def __init__(self, filenames, labels, transform=None):
self.filenames = filenam... | true |
f8440a427b3872d3cb4bb44858af1c7b961c3f90 | Python | alex-paget/ansible-dissertation | /deploy.py | UTF-8 | 29,942 | 3.421875 | 3 | [] | no_license | #!/usr/bin/python
import subprocess
import re
# Function that prompts users for yes or no response
def yes_no(answer):
# Expected 'yes' formats
yes = set(['yes', 'y'])
# Expected 'no' formats
no = set(['no', 'n'])
# Prompt user for input until they answer either 'yes' or 'no'
while True:
... | true |
5f570248a9a6f283d2bbde719c4bff3063ae9b5d | Python | pht431/How-to-Python-and-Machine-Learning-book-code | /code/ch25_身份证汉字和数字识别/back_all/back_rotate/TextLine_Index.py | UTF-8 | 27,663 | 3.1875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu May 4 13:12:30 2017
@author: yi.xiong
"""
import cv2
import numpy as np
import math
# 去掉嵌套的框
def filter_rect(rects):
result = []
for rect1 in rects:
contain = False
x1, y1, w1, h1 = rect1
for rect2 in rects:
if rect2 != rect1... | true |
a7e68612983ca7ee467c09c74f9d3cf376ce97b7 | Python | haymachandhiran/hackerrank_Python_Codes | /sum_of_ele_in_asc.py | UTF-8 | 488 | 3.625 | 4 | [] | no_license | #Take size and Take array of integers
#Add up the elements in the asc order of their presence and print final op
# 7 , [2,201,2,3,205,4,5] => 2+201 = 203; 2+3+205= 210; 4+5=9;
#Op: [203,210,9]
#Another qn - Print max val : Output = 210
n = int(input())
arr = list(map(int, input().split()))
res = []
arr.append(0)
tot... | true |
e9fd347c6ebeeabea73ce20674ba1fb7dffb8c30 | Python | wanghengquan/repository | /tmp_client/tools/corescripts2/DEV/bin/xlib/yTimeout.py | UTF-8 | 3,552 | 2.578125 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding: utf-8 -*-
# Created on 13:51 2017/10/11
#
import os
import time
try:
import psutil
except (ImportError, AttributeError):
psutil = None
except:
psutil = None
from multiprocessing.dummy import Pool as YosePool
__author__ = 'Shawn Yan'
def say_it(msg, co... | true |
a6a06d8cde1b0fb0093654efbe914976027a1ad3 | Python | Ming-J/LeetCode | /CodeForces/0719A_Vitya_In_The_Countryside.py | UTF-8 | 714 | 3 | 3 | [] | no_license | import sys
'''
'''
def main():
n = int(sys.stdin.readline())
moon = [int(x) for x in sys.stdin.readline().split()]
if n is 1:
if moon[0] == 15:
print("DOWN")
elif moon[0] == 0:
print("UP")
else:
print(-1)
else:
last1 = moon[n-1]
... | true |
b6a200a9b1363b6c1083be278f10513fbdbe6852 | Python | swapnil2me/PyInstr | /lib/instruments.py | UTF-8 | 10,971 | 2.75 | 3 | [] | no_license | import vxi11
import pyvisa
import time
from math import isclose
class Instrument:
def __init__(self,address, cableLoss = 0,name = None,unit = None, freqOffSet = 0.0):
self.address = address
self.name = name
self.unit = unit
self.freqOffSet = freqOffSet #Hertz
self._instR = ... | true |
37f0735964ca135b79def60142d312ee38dd9346 | Python | LucasSimpson/personal_site | /django_dynamodb/fields.py | UTF-8 | 3,698 | 3.125 | 3 | [] | no_license |
# fields hold no value. they are there purely for description, validation,
# and as an adapter between db storage and python rep
from datetime import datetime
class ModelField(object):
# proto is a string representing dynamoBD storage type, ex 'S'/'N'/'B'
@classmethod
def get_proto(cls):
if has... | true |
53e37713f720bb34bcb77cb23300b13ec99b321b | Python | Kandy16/people-networks | /wikipedia-crawl/create_profile_reading_tracker.py | UTF-8 | 965 | 2.6875 | 3 | [
"MIT"
] | permissive | import pandas as pd
import os
def create_profile_reading_tracker(file_name, tracker_file_name) :
#read the given data file and extract all the profile names
pol = pd.read_csv(file_name,sep='\t',encoding="utf-8")
handle_list = [x.split('/')[-1] for x in pol['WikiURL']]
#create a data fram... | true |
74cb29ca11fc8462d67b7ac3fff5450352d8c75d | Python | cecilieboy/FYS3150 | /Project5/flex_runge_kutta.py | UTF-8 | 3,101 | 2.703125 | 3 | [] | no_license | #%%
import numpy as np
from matplotlib import pyplot as plt
from tqdm import trange
import pandas as pd
import random
import seaborn as sns
import matplotlib.pyplot as plt
#%%
def rhs_S(t, S, I, a= 4, b= 1, c= 0.5, A =0, omega =1, f = 0, N=400):
a_t = max(0,A*np.cos(omega*t) +a)
f_t = f #max(0,f*np.cos((ome... | true |
366681c58ae605c236d2bff18bdd071799b46f93 | Python | umdloop/unnamed-pod | /misc/CAN_pdf_to_od/generate_object_dictionary.py | UTF-8 | 2,053 | 2.5625 | 3 | [] | no_license | import re
raw_path = "./raw_lines.txt"
result_path = "./od.eds"
mand_path = "./MandatoryEntries.txt"
fin = open(raw_path, "r")
fout = open(result_path, "w")
fmand = open(mand_path, "r")
print("Parsing lines into object dictionary:")
print("in:", raw_path, "\nout:", result_path)
fout.write(";************************... | true |
32b780127fb534e488e9befb967ba95afe0b7723 | Python | sekiya9311/python-programming-contest | /main.py | UTF-8 | 413 | 2.71875 | 3 | [] | no_license | def get_int(): return int(input())
def get_float(): return float(input())
def get_line(): return input().split()
def get_lines(v): return [get_line() for _ in range(v)]
def get_int_line(): return list(map(int, get_line()))
def get_int_lines(v): return [get_int_line() for _ in range(v)]
def get_float_line(): return list... | true |
9ed3948c8b3e5bf689046d1ffd44bd9c13e72d11 | Python | david-westreicher/gosolve | /vis.py | UTF-8 | 965 | 2.59375 | 3 | [] | no_license | import visdom
import numpy as np
class Vis:
def __init__(self, unnorm):
self.vis = visdom.Visdom()
self.unnorm = unnorm
self.window = None
def showimg(self, img, unnorm=True):
if unnorm:
return self.vis.image(self.unnorm(img))
else:
return self.v... | true |
f53d4076e9275c241886bf3c931ccffd26f0a417 | Python | rashikoz/CarND-Behavioral-Cloning-P3 | /model.py | UTF-8 | 3,819 | 2.546875 | 3 | [
"MIT"
] | permissive | import tensorflow as tf
from keras.layers import Dense, Flatten, Lambda, Activation, MaxPooling2D, Dropout, AveragePooling2D
from keras.layers.convolutional import Convolution2D
from keras.models import Sequential
from keras.optimizers import Adam
from keras.layers.normalization import BatchNormalization
from keras.cal... | true |
003a88220d4b9eb8b25d6d05d942e49e70b2bd7a | Python | hec10r/advent-of-code-2019 | /day-02/2.py | UTF-8 | 979 | 3.328125 | 3 | [] | no_license | def restore_gravity(intcode_, noun, verb):
intcode = [_ for _ in intcode_]
intcode[1] = noun
intcode[2] = verb
size = len(intcode_) // 4
for i in range(size):
j = 4 * i
if intcode[j] == 99:
break
elif intcode[j] == 1:
intcode[intcode[j + 3]] = intcode[... | true |
c70ddf5cb6af7408e799d6e7bea85b2bb37cfc71 | Python | theimgclist/MOOCs | /Machine Learning Udemy/Course/Part 6 - Reinforcement Learning/Section 27 - Upper Confidence Bound (UCB)/upper_confidence_bound.py | UTF-8 | 4,128 | 3.5 | 4 | [] | no_license | # Upper Confidence Bound
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
# ctr is click theough rates
# robots and AI use RL
# in an earlier example, we tried to predict whether a social network user will buy SUV or not
# now the same SUV compan... | true |
c81bfb5a573708c05974c4200c51ebd893be3556 | Python | tiagofrepereira2012/FSPR_miniproject | /presentation/project/tmp_mod.py | UTF-8 | 3,335 | 3.609375 | 4 | [] | no_license | def lda(X, y):
"""Calculates the projection matrix U to perform LDA on X with labels y.
LDA finds the projecting matrix W that allows us to linearly project X to
another (sub) space in which the between-class and within-class variances are
jointly optimized: the between-class variance is maximized while the
... | true |
2b3fd74d2d0443d02efe245c66b2263980593c3e | Python | MD-Studio/cerise | /api/cerise/files/cwltiny.py | UTF-8 | 23,333 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python3
import argparse
import glob
import json
import logging
import os
import shutil
import subprocess
import sys
import tempfile
from urllib.parse import urlparse
# Logging and output
def setup_logging():
format = '%(asctime)-15s: %(message)s'
logging.basicConfig(level=logging.INFO, forma... | true |
fb7f52af9019e6de2e3813f96926b3b63e6571f4 | Python | EthanLo01/Leetcode | /Array/26_Remove_Duplicates_from_Sorted_Array.py | UTF-8 | 365 | 2.6875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Aug 17 21:16:07 2021
@author: user
"""
# God:
class Solution:
def removeDuplicates(self, nums):
nums.sort()
index = 1
for i in range(1,len(nums)):
if(nums[i-1]!=nums[i]):
nums[index] = nums[i]
... | true |
164bc5c3a6ab33926667db1065b98b53386a0c8b | Python | mezklador/learning-tornado | /tornado-book/simple_web_services/string-rev.py | UTF-8 | 2,793 | 3.109375 | 3 | [
"MIT"
] | permissive |
#!/bin/python
# Sample POST request : curl http://localhost:8000/wrap -d text=Lorem+ipsum+dolor+sit+amet,+consectetuer+adipiscing+elit
# Output : Lorem ipsum dolor sit amet, consectetuer
#
# Sample GET request : curl http://localhost:8000/reverse/helbhelb
# Output : blehbleh
#
import textwrap
# bunch of tornado imp... | true |
283c4bb9a0f6e99ba0dc7c62e30b7d28d6bc18ff | Python | seongbeenkim/Algorithm-python | /Programmers/Level1/x만큼 간격이 있는 n개의 숫자(n numbers with interval x.py | UTF-8 | 395 | 3.578125 | 4 | [] | no_license | # https://programmers.co.kr/learn/courses/30/lessons/12954
def solution(x, n):
if x == 0:
return [0] * n
if x < 0:
answer = [i for i in range(x * n, x + 1, -x)]
answer.sort(reverse=True)
else:
answer = [i for i in range(x * n, x - 1, -x)]
answer.sort()
return ... | true |
3d3f1f5f51565bfde35c9f33266426234c158560 | Python | 17shashank17/OS_Project | /tr2.py | UTF-8 | 6,178 | 2.890625 | 3 | [] | no_license |
class Queue:
def __init__(self,size):
self.size=size
self.process=[]
self.burst_time=[]
self.top=-1
self.head=0
def enqueue(self,x,y):
self.process.append(x)
self.burst_time.append(y)
self.top+=1
def dequeue(self,i):
self.process.po... | true |
646d8f2d760a4143838d8506ad12f42489e5c0f0 | Python | CaesarLinsa/oslo_learn | /kombu_learn/config.py | UTF-8 | 1,010 | 2.609375 | 3 | [] | no_license | import os
import types
import errno
class Config(dict):
def __init__(self, root_path, defaults=None):
dict.__init__(self, defaults or {})
self.root_path = root_path
def from_pyfile(self, filename, silent=False):
filename = os.path.join(self.root_path, filename)
d = types.Modu... | true |
ac5b8250627621d58b72611da1d04a98cd9070bb | Python | wngus9056/Datascience | /Python&DataBase/5.12/Python03_22_Chap03Practice_김주현.py | UTF-8 | 1,625 | 4.09375 | 4 | [] | no_license |
## 문제 1. ##
'''
a = "Life is too short, you need python"
if "wife" in a : print("wife") # 만약 a안에 'wife'가 있으면 'wife' 출력
elif "python" in a and "you" not in a: print("python") # a 안에 'python'이 있고 a 안에 'you'가 없으면 'python' 출력
elif "shirt" not in a: print("shirt") ... | true |
c9c60d922cc57d714fca14318ecdc4e018a9bd12 | Python | ishine/HIFIGAN-2 | /models/layers.py | UTF-8 | 2,603 | 2.640625 | 3 | [] | no_license | import torch
import numpy as np
import torch.nn as nn
class ResStack(nn.Module):
def __init__(self, channel, kernel_size, dilations):
super(ResStack, self).__init__()
self.layers = nn.ModuleList([
nn.Sequential(
nn.LeakyReLU(),
nn.utils.weight_norm(nn.C... | true |
8b8e0b84bc31593916f90882f0208c6b70025e17 | Python | 0000000100000000/find-hub | /1-资产收集/附件/1-ICP备案收集根域/ICP备案提取主域信息.py | UTF-8 | 2,452 | 3.109375 | 3 | [] | no_license | import argparse
import json
import pandas as pd
def usage():
parser = argparse.ArgumentParser(description="Example: python3 ICP备案提取主域信息.py -f page1-40个.json -m w");
parser.add_argument("-f", "--file", help="保存后的json文件", required=True);
parser.add_argument("-m", "--mode", help="指定写入csv的格式,w为覆盖,a为追加", requi... | true |
9ab0bd6c72740343a016ee824e1d6695c50f32ee | Python | juanshishido/codewars | /kyu7/xo.py | UTF-8 | 237 | 3.21875 | 3 | [
"MIT"
] | permissive | def xo(s):
assert isinstance(s, str), '`s` must be type str'
x = s.lower().count('x')
o = s.lower().count('o')
if x == 0 and o == 0:
return True
elif x == o:
return True
else:
return False
| true |
d074014ec36574ed90d7d9d0a211b1999a740377 | Python | Datamine/Tetris | /all/tetris.py | UTF-8 | 17,128 | 3.109375 | 3 | [] | no_license | # John Loeber | 26-NOV-2014 | Python 2.7.8 | x86_64 Debian Linux | www.johnloeber.com
from gameproperties import gridline
from tscore import getmaxlines, writemaxlines
from blocks import *
from sys import exit
from ImageColor import getrgb
import time
import pygame
###################################################... | true |
505bbe382fafdc035740dfe931e807b6d6ac5ee8 | Python | todaybow/python_basic | /python_basic_jm_15.py | UTF-8 | 1,348 | 4.0625 | 4 | [] | no_license | '''
클래스
클래스, 인스턴스 차이 중요
네임스페이스 : 객체를 인스턴스화 할 때 저장된 공간
클래스 변수 : 직접 사용 가능, 객체 보다 먼저 생성
인스턴스 변수 : 객체마다 별도로 존재, 인스턴스 생성 후 사용
'''
class UserInfo:
# 속성, 메소드로 구성 되어있음
def __init__(self, name, age, height, weight):
self.name = name
self.age = age
self.height = height
self.weight = weight... | true |
9394beb223d7c011d098dbeda2204358c4e38a9a | Python | efearin/128-Player | /search.py | UTF-8 | 2,366 | 3.15625 | 3 | [] | no_license | import move
#turn= 1(player),0(generator)
def main (state,turn,IL):
initialDepth=0 #constant never change
a=-1 #alfa
b=2048 #beta
board=list(state)
#player
if turn:
return max(state,a,b,initialDepth,IL)
#generator
else:
return min(state,a,b,initialDepth,IL)
#
def min (st... | true |
bb0ea0e3111381e8215a9ae4d0d6020276e8ec4a | Python | stenikolaou/stock_price_forecasting | /08_NeuralProphet.py | UTF-8 | 2,494 | 3.078125 | 3 | [] | no_license | import warnings
import matplotlib.pyplot as plt
import pandas as pd
from neuralprophet import NeuralProphet
# Silence warnings
warnings.filterwarnings("ignore")
# Load data
df = pd.read_csv('01_AMD.csv')
# Select only date and close price
df = df[["Date", "Close"]]
# Rename the columns to ds (timestamp) and y (obse... | true |
628d9ac4c40c11d1bc367acad7bf5f825679ac73 | Python | shinaushin/skull-complete | /deep-learning/data_loader.py | UTF-8 | 549 | 3.15625 | 3 | [] | no_license | import torch
from scipy.io import loadmat
def load_data(data_path, type):
"""
loads the data from the mat files
:param data_path: directory where the path to the mat file containing the data is located
:param type: name of the variable to load from the mat file
:return: return data in tensor form ... | true |
de4e90755aee0f822d1710ac4fc9ea23d67d82db | Python | DanielDng/Fast-Slow-LSTM-IPv6 | /data_preprocessing.py | UTF-8 | 4,395 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | import sys
sys.path.append("/path/to/sklearn")
from sklearn import preprocessing
import numpy as np
import csv
# add at 2018-1-12
# all the value of kdd99
def countingFunction(type_into, name):
s_c = 1
f_c = 1
p_c = 1
protocol_type = ["ICMPv6","IPv6","TCP","UDP"]
# example TCP->1
... | true |
c5077e14e136af35d25d8b1c37aa7eee6716ddac | Python | xeonye/LearnOpenCV | /2DHistograms.py | UTF-8 | 590 | 3.0625 | 3 | [] | no_license | #####OpenCV method
import cv2
import numpy as np
from matplotlib import pyplot as plt
img=cv2.imread('res/home.jpg')
hsv=cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
hist=cv2.calcHist([hsv],[0,1],None,[180,256],[0,180,0,256])
plt.imshow(hist,interpolation='nearest')
plt.show()
# #####2D Histogram in Numpy
# import cv2
# impo... | true |
526fb824f6a1dd7aad3055d1661a90f752645759 | Python | artfintel/UsefulCalculators | /misc.py | UTF-8 | 4,225 | 2.828125 | 3 | [] | no_license | #!/usr/bin/env python
from math import tan, asin, sin, atan, exp,log, pi
import ConfigParser
import os
def get_detectorDiameter() :
detectorDiameter = 0
base_dir = os.path.dirname(os.path.abspath(__file__))
config = ConfigParser.ConfigParser()
config.read(base_dir + '/config.ini')
beamline = co... | true |
2d44eab88036c3cc85c9e26bcb3315d4437f4dc9 | Python | gholamlooAli/single_shot_multibox_detector | /src/utils/box_visualizer.py | UTF-8 | 3,413 | 2.828125 | 3 | [
"MIT"
] | permissive | import matplotlib.pyplot as plt
import numpy as np
import random
from utils.utils import load_image
from utils.utils import list_files_in_directory
class BoxVisualizer(object):
def __init__(self, image_prefix=None, image_size=(300, 300),
arg_to_class=None, seed=None, box_decoder=None):
se... | true |
6d9b8adcabb466f2dfe888fdfb85ada53bde4a8d | Python | kriegaex/projects | /Python/projectEuler/Q13( txt文件的读写 ).py | UTF-8 | 471 | 3.609375 | 4 | [] | no_license | import time
time_start = time.time()
chaozy = open('Q13.txt', "r")
array = []
for line in chaozy:
array.append(line)
# Convert the array into an array of integers
newArray = []
for i in range(len(array)):
#for i in array:
newArray.append(int(array[i]))
print(i)
# Sum up the array and print the first 10 ... | true |
536c1b5403e0e0a0bd0f2767cbd75a76de78cd30 | Python | CSU-Robosub-2017-2018/IMU | /imu_framework/imu_framework/imus/imu_no_thrd_9250.py | UTF-8 | 2,554 | 3.03125 | 3 | [] | no_license | ''' imu_no_thrd_9250.py - Use this class to obtain data from the mpu 9250 imu. The data is obtained without using
threading.
'''
from imu_framework.imu_framework.imus.imu import imu
import smbus
class imu9250(imu):
##
# @brief Obtains data from the mpu 9250 imu without threading
# @param bus The bus numb... | true |
5fd48b4468d444e57e56cad38122ba07ed22f8aa | Python | aig-upf/automated-programming-framework | /domains/old/btree/gen-problem.py | UTF-8 | 1,260 | 2.53125 | 3 | [] | no_license | #! /usr/bin/env python
import sys,time,random
#**************************************#
# MAIN
#**************************************#
try:
ndepth = int(sys.argv[1])
except:
print "Usage:"
print sys.argv[0] + " <ndepth>"
sys.exit(-1)
str_problem=""
str_problem=str_problem + "(define (problem p"+str(ndepth... | true |
ff13927a2db61121eb33d90803e9bd432becb810 | Python | udayadara28/MuJoCo-Uruhl | /real_uruhl.py | UTF-8 | 8,827 | 3.03125 | 3 | [] | no_license | #! /usr/bin/python
import gym
import math
import random
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
from matplotlib import cm
#### Learning related constants ####
MIN_EXPLORE_RATE = 0.01 #The min exploration rate; The max is 1
PULL_UP_EXPLORE_LINE = 10 #Increase this to decrease the rate... | true |
d09e643e725288e0725ff077e6d0a62f5746fca3 | Python | flybass/Gaussian-Mixture-Model | /gmm.py | UTF-8 | 3,826 | 2.8125 | 3 | [] | no_license |
# coding: utf-8
import numpy as np
import random
from scipy.stats import multivariate_normal
class gmm:
#set n_comps
def __init__(self, n_comps=4, delta = 10**-5):
#call this k
self.n_comps = n_comps
self.delta = delta
#data is a matrix n*p (n rows, p dimensional)
def fit(... | true |
1663e3ea449daa4ca373b7e5e3bea35fbb4951eb | Python | priyam304/issue-one | /issueone/helpers.py | UTF-8 | 814 | 2.671875 | 3 | [
"MIT"
] | permissive | from github import Github
def language(lang_name):
search(language, lang_name)
return
def user(username):
search(user, username)
return
def repository(repo_name):
search(repository, repo_name)
return
def topic(topic_name):
search(topic, topic_name)
return
def search(search_type... | true |
ee1c35992e5d1a50cee826fb06b5157b03952792 | Python | yoonicode/of-Algorithms | /008. Dynamic Programming [동적 프로그래밍]/Fibonacci_by_MEMOIZATION.py | UTF-8 | 980 | 4.28125 | 4 | [] | no_license | ''' n번째 피보나치 수를 찾아주는 함수 fib_memo를 Memoization 기법으로 작성하기 '''
def fib_memo(n, cache):
# 입력받은 정수 n의 피보나치 수열을 계산하고, 사전에 저장하는 함수
cache[1] = cache[2] = 1
# 피보나치 수열의 1번, 2번 항은 항상 1이다.
if n in cache.keys():
return cache[n]
# 만약 정수 n을 key로 하는 value가 사전에 이미 저장되어 있다면, value를 return
... | true |
ccd54ef9a23eab0c3d3eef6315f14e5b4bc59b87 | Python | pengjinfu/python-network-programming | /application_layer/http_server_v1.py | UTF-8 | 1,325 | 3.21875 | 3 | [] | no_license | import socket
import multiprocessing
def handle_client(client):
# 接收客户端的数据
client_request_data = client.recv(1024)
print("客户端的请求数据为:%s" % client_request_data)
# 向客户端响应数据,一定要按照http协议规范,带上\r\n,并且一定要注意斜杠的方向
response_start_line = "HTTP/1.1 200 OK\r\n"
response_headers = "Server:My server\r\n"
... | true |
c8316807265fa5f16fee08b71a770aab21c3a9a4 | Python | acoverstone/linda | /commands/screens/jokeScreen.py | UTF-8 | 1,060 | 3.046875 | 3 | [] | no_license | import Tkinter as tk
class JokeScreen(tk.Frame):
def __init__(self, parent, controller):
global label
height = 2000
width = 2000
tk.Frame.__init__(self, parent,width=width,height=height,bg="black")
self.controller = controller
def knock(self):
global knockl
... | true |
405b7c667d66df46b5d831f5dac14f36cc35d418 | Python | johndbigboi/Boutique-CI-project | /products/admin.py | UTF-8 | 937 | 2.65625 | 3 | [] | no_license | from django.contrib import admin
from .models import Product, Category
# Register your models here.
"""
create two classes
product admin and category admin
Both of which will extend the built in model admin class.
"""
class ProductAdmin(admin.ModelAdmin):
list_display = (
'sku',
'name',
'... | true |
b880d6103caf4d89c0281332afe8e6ea7d78ed7b | Python | KondrotM/TextGame | /main.py | UTF-8 | 20,504 | 3.328125 | 3 | [] | no_license | import rooms
import items
import pickle
import enemies
import random
import time
cavern = [[rooms.wall,rooms.spawn,rooms.wall,rooms.wall],[rooms.sword,rooms.enemyC,rooms.wall,rooms.wall],[rooms.wall,rooms.enemyC,rooms.enemyC,rooms.potion],[rooms.enemyC,rooms.switch,rooms.passage,rooms.wall]]
level = cavern
class Pla... | true |
b6b8d10d49d2a4e8e9d8384779e8ebb6debcdece | Python | jeryfast/piflyer | /piflyer/zmq_sensors.py | UTF-8 | 3,967 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | import random as r
from sense_hat import SenseHat
import time
import zmq
import zmq_ports as ports
import zmq_topics as topic
import delays
class sensors():
def __init__(self):
self.pitch = 0
self.roll = 0
self.yaw = 0
self.heading = 10
self.temp = 0
self.humidity = ... | true |
d5a23e0f1b12294b7dcb1f72456d430d97563b0c | Python | SHE-43/Specs-Generator | /source_location_numbering_1.py | UTF-8 | 1,179 | 3.046875 | 3 | [] | no_license | import sys
import os
import random
# We are going to start with 3 sources however this is now based on input only.
number_of_sources = 5; # Input for number of sources needed
start,end = 111,1432; # Starting number and ending number for source IDs.
src_list = []
src_gen = lambda x,y : random.randint(x,y)
... | true |
0756c2d8f4cb23e646cefd7b71997b73d5f37372 | Python | hsumerf/Python_website_links_crawler | /building-blocks/href_spider0.py | UTF-8 | 475 | 3.046875 | 3 | [] | no_license | #!/usr/bin/env python
import requests
import re
def request(url):
try:
get_response = requests.get(url)
return get_response
except Exception:
pass
url = "http://ajwapaste.com.pk"
response = request(url)
print(type(response.content))
# content = str(response.content)
# print(type(cont... | true |
828336bea8e9e219dbddc7b19b4e2f8ad931831b | Python | tomboo/exercism | /python/atbash-cipher/atbash_cipher.py | UTF-8 | 516 | 3.34375 | 3 | [] | no_license | from string import ascii_lowercase
trans_tab = str.maketrans(ascii_lowercase, ascii_lowercase[::-1])
def clean(s):
return ''.join(c for c in s if c.isalnum()).lower()
def encode(s):
t = clean(s)
t = t.translate(trans_tab)
t = ' '.join(t[i:i + 5] for i in range(0, len(t), 5))
return t
def deco... | true |
3d0955ae2fbc112eddeb1a2f76e5d178a9c1049a | Python | rvsmegaraj1996/Megaraj | /looping while.py | UTF-8 | 131 | 3.65625 | 4 | [] | no_license | #print 3 table
tab=int(input("tell us which table you want: "))
num=1
while num<=20:
print(num,"X",tab,"=",num*tab)
num+=1
| true |
82b61ca1c576139f3f42d9870f6920b5fedb1139 | Python | mariognzsa/IDE-python | /lexicAnalyzer.py | UTF-8 | 11,464 | 3.21875 | 3 | [] | no_license | # LexicAnalyzer v1.0
class Token:
def __init__(self, id, tokenType, token, start, end, line):
self.id = id
self.tokenType = tokenType
self.token = token
self.start = start
self.end = end
self.line = line
class LexicAnalyzer:
def __init__(self):
self.toke... | true |
3f6d72d869a5fdefb2a221f5dd6172acb35faf5c | Python | mdeependu/Algorithm-for-Intelligent-System-Robotic | /4. Josephus.py | UTF-8 | 191 | 3.59375 | 4 | [] | no_license | def josephus(n,k):
if (n==1):
return 1
else:
return (josephus(n-1,k)+(k-1)) % n+1
n=int(input("Enter no.of soldiers: "))
k=2
result=josephus(n,k)
print("Safe Position is",result)
| true |
4894f0bfde8d2fb2bc8111842f6306f960c42ae0 | Python | dave2000sang/android-eat-apples | /startmenu.py | UTF-8 | 1,370 | 2.9375 | 3 | [] | no_license | import pygame
import random
import time
import base
import leaderboard
import colours
import text
import controls
pygame.init()
def game_intro():
# Start menu Background
background_image = pygame.image.load("startmenu_background.jpg").convert()
background_x = 0
intro = True
while intro:
... | true |
cff2b585424f7e79e0c9a106ff42a12846ef3831 | Python | mesoic/pythonArchive | /scripts/numeric/preisach.py | UTF-8 | 1,359 | 3.453125 | 3 | [] | no_license | #!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
# Implementation of preisach kernel (archived)
class Preisach:
def __init__(self, npoints = 100):
pass
# Method to expand domain
def domain(self, domain):
return np.array( list(domain) + list(domain[::-1]) )
# Method to evaluate ... | true |
9cce637345ad647ebd9942115558edfc9a303337 | Python | RenanBertolotti/Python | /Curso Udemy/Modulo 04 - Pyhton OO/Aula07 - Associacao/maquinaescrever.py | UTF-8 | 318 | 3.109375 | 3 | [] | no_license | class MaquinaEscrever:
def __init__(self, marca):
self.__marca = marca
# Getter
@property
def marca(self):
return self.__marca
# Getter
@marca.setter
def marca(self, marca):
self.__marca = marca
def escrever(self):
print("Maquina esta escrevendo...") | true |
b7dae3a7703c6a200f814382fdba0de8bb9f32eb | Python | GregHamel/RedditDailyProgrammer | /[12-23-13] Challenge #146 [Easy] Polygon Perimeter.py | UTF-8 | 262 | 3.546875 | 4 | [] | no_license | #[12-23-13] Challenge #146 [Easy] Polygon Perimeter
#http://www.reddit.com/r/dailyprogrammer/comments/1tixzk/122313_challenge_146_easy_polygon_perimeter/
import math
def perimiter(n,r):
print( "{0:.3f}".format(2*n*r*math.sin(math.pi/n)) )
perimiter(5, 3.7) | true |
721e9ee38d9d0c2951141bd8ba19f15e0a7953e7 | Python | bql20000/INT3117-1-18020029 | /test_main.py | UTF-8 | 941 | 3 | 3 | [] | no_license | import pytest
from main import *
@pytest.mark.parametrize(
'weight, distance, expected_output',
[
(25, 15, 160000),
(25, 0, 25000),
(25, 30, 310000),
(25, 1, 32000),
(25, 29, 300000),
(25, -1, -1),
(25, 31, -1),
(0, 15, 150000),
(50, 15,... | true |
26bd1862e2eb5fdb2919bf59266eb656b777a4c3 | Python | Gushono/Aprendendo-API | /app/controllers/default.py | UTF-8 | 1,980 | 2.71875 | 3 | [] | no_license |
from flask import render_template
from app import app
import requests
import json
from app.models.forms import CadastroForm
#from app.models.tables import User
#CONFIGURAÇÃO DA ROTA DE INDEX
@app.route("/index/")
@app.route("/")
def index():
#RENDERIZAÇÃO DO TEMPLATE DA TELA PRINCIPAL
return render_template('i... | true |
217045cbd3a932fa2c9529ba1bb1a2fe26a75749 | Python | alikaikai/myfdm | /modesolver.py | UTF-8 | 15,653 | 3.203125 | 3 | [] | no_license | import numpy
from scipy.sparse import coo_matrix
from scipy.sparse.linalg import eigen
class ModeSolver:
"""
The ModeSolver class computes the electric and magnetic fields
for modes of a dielectric waveguide using the "Vector Finite
Difference (VFD)" method, as described in A. B. Fallahkhair,
K. S... | true |
2f2cf1e894b87d09a76e4aab6291da94388296dd | Python | httpsJay/eRetail-Store | /e-retail-store/app.py | UTF-8 | 7,106 | 2.625 | 3 | [] | no_license | """
Flask Server
"""
# import necessary libraries
from flask import Flask, jsonify, request
from processing import *
# creating a Flask app
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def home():
default = "Hey!!! Service is Up-n-Running"
return jsonify({'data': data})
#route for subm... | true |
563caf626a5bb80f5d7f7e75ca6921fc23a50cd0 | Python | absanyal/gas-equilibrium | /Gas_Equilibrium.py | UTF-8 | 779 | 3.125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu Dec 15 10:07:08 2016
@author: AB Sanyal
"""
import matplotlib.pyplot as plt
import numpy as np
N = 1 * 1000000
t = 3 * 1000000
blue_box = N
red_box = 0
blue_size = 1
red_size = 1
c_blue = []
c_red = []
i = 1
print("Started calculations.")
while (i <= t):
r = np.ran... | true |
571f2c3a890c4401ce9f5a998f25e66226c1e56c | Python | huangyt39/algorithm | /245.py | UTF-8 | 1,102 | 3.984375 | 4 | [] | no_license | """
Definition of TreeNode:
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
"""
class Solution:
"""
@param T1: The roots of binary tree T1.
@param T2: The roots of binary tree T2.
@return: True if T2 is a subtree of T1, or false.
"""
... | true |
8812fe6316bd0a2e7365b5bbff6f0db4da66a9d9 | Python | spacocha/SmileTrain | /tools/fix_index_fastq.py | UTF-8 | 1,428 | 2.921875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
'''
some index fastq's have a weird number of quality line characters. some have an extra
character; others seem to have a single character.
this script truncates quality lines longer than the sequence line and pads quality
lines that are shorter than the sequence line.
author : scott w olesen ... | true |
3133a706ce1e700572ab2af03b1f37be774febfe | Python | ravinderkhangura/Machine-Learning-python- | /ProgAsgStage1.py | UTF-8 | 3,159 | 3.6875 | 4 | [] | no_license | plst=[["PELLETS",22.75,100],["MASH",20.50,90],["ENHANCED FOOD",25.50,125.50]]
qlst=[["PELLETS ",0,0],["MASH ",0,0],["ENHANCED FOOD",0,0]]
#function for printing menu
def print_menu():
print("*"*70,"\n","*"*70)
print(" Chook Food"," "*6,"Price(10kg)"," "*6,"Price(50kg)\n")
... | true |
4c6c0cdb3e6a01488ca50c90dfb24c04e4d04118 | Python | stjordanis/descarteslabs-python | /descarteslabs/workflows/types/array/array_.py | UTF-8 | 3,110 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | import numpy as np
from descarteslabs.common.graft import client
from ...cereal import serializable
from ..core import ProxyTypeError
from ..containers import List
from ..primitives import Int, Float, Bool
from .base_array import BaseArray
DTYPE_KIND_TO_WF = {"b": Bool, "i": Int, "f": Float}
WF_TO_DTYPE_KIND = dict... | true |
b7a3470b264d6eb1b6b175d107e12a211e80b736 | Python | mateuszmidor/DwellingDigger | /src/diagnostics/logger.py | UTF-8 | 1,969 | 2.78125 | 3 | [] | no_license | '''
Created on 17 mar 2015
@author: m.midor
'''
import logging
from multiprocessing import Lock
from logging import StreamHandler, FileHandler
class NullHandler(logging.Handler):
def emit(self, record):
pass
class Logger(object):
'''
This class allows for simple logging to file... | true |
d0c5874e04c539d53194f2eb546dfa3510be13e1 | Python | jana-choi/WebScrapingWithPython | /Chapter 07/7.3.py | UTF-8 | 363 | 3.140625 | 3 | [] | no_license | from urllib.request import urlopen
from io import StringIO
import csv
url = "http://pythonscraping.com/files/MontyPythonAlbums.csv"
data = urlopen(url).read().decode("ascii", "ignore")
dataFile = StringIO(data)
csvReader = csv.reader(dataFile)
for row in csvReader:
# print(row)
print("The album \"{}\" was re... | true |
d95c84f7d6cff13aecac89d2cb5246d59deeed75 | Python | 1MLightyears/clarisse | /clarisse/page.py | UTF-8 | 6,283 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | """
Clarisse
page module.
Define class Page, the canvas of type in types_supported.py.
by 1MLightyears@gmail.com
on 20201211
"""
from PySide2.QtWidgets import (
QPushButton,
QScrollArea,
QLineEdit,
QLabel,
QWidget,
QFormLayout,
)
from PySide2.QtCore import QThread, Signal,... | true |
453f345424ab00ec294f40d1b9c11cadef5ea4d2 | Python | ecollins/TUP-neediness | /analysis/goods_analysis.py | UTF-8 | 31,868 | 2.65625 | 3 | [] | no_license | def df_to_orgtbl(df,tdf=None,sedf=None,float_fmt='%5.3f'):
"""
Print pd.DataFrame in format which forms an org-table.
Note that headers for code block should include ":results table raw".
"""
if len(df.shape)==1: # We have a series?
df=pd.DataFrame(df)
if (tdf is None) and (sedf is None)... | true |
d798c74477c6d2e8916999849f36c5ccc70efdb7 | Python | ariellewaller/Python-Crash-Course | /Chapter 6/glossary_two.py | UTF-8 | 1,426 | 4.9375 | 5 | [] | no_license | # 6-4. Glossary 2: Now that you know how to loop through a dictionary, clean
# up the code from Exercise 6-3 (page 99) by replacing your series of print()
# calls with a loop that runs through the dictionary’s keys and values. When
# you’re sure that your loop works, add five more Python terms to your
# gloss... | true |
f4f8bc54c29cbdefed1514ab9a23ddfef3030cc9 | Python | adrianemikko/wtn-whits | /functions/nx_tools.py | UTF-8 | 2,581 | 3.4375 | 3 | [
"MIT"
] | permissive |
import numpy as np
import networkx as nx
def whits(G, normalized=True, weight=None):
"""Returns HITS hubs and authorities values for nodes.
The HITS algorithm computes two numbers for a node.
Authorities estimates the node value based on the incoming links.
Hubs estimates the node value based on out... | true |
d34ed7d4e7b8512ae5af5202cc27fa845ade4c5c | Python | qinjinjia/ec500c1spring18 | /HW3 Database/phase1.py | UTF-8 | 612 | 2.65625 | 3 | [
"MIT"
] | permissive | # Copyright 2018 Qinjin Jia qjia@bu.edu
# phase1.py
"""
Usage:
show dbs
use airport_location
show collections
read: db.posts.find()
search: db.posts.find({...})
insert: db.posts.insertOne({...})
update: db.posts.updateOne({...})
"""
" Import airport location data to Mongodb"
JSON_FILE_NAME = "airports.json"
# C... | true |
548236733f07ae1f9d80a0b8c3e19940ec9aad76 | Python | BYU-Hydroinformatics/sgwde | /tethysapp/sgwde/api.py | UTF-8 | 4,225 | 2.765625 | 3 | [] | no_license | from django.http import JsonResponse
from utilities import *
import json
def api_get_var_list(request):
'''
Return a JSON object that contains the list of all the available variables. Needs to be changed to be more dynamic.
'''
json_obj = {}
if request.method == 'GET':
variable_options = [... | true |
378eaccad7c86fa0bf25550b3c0f767043a9353a | Python | turheart/2021bnustat | /2021第四季新统学资料/第4讲-简单CNN-Lenet的pytorch实现/train.py | UTF-8 | 3,283 | 2.84375 | 3 | [] | no_license | # _*_ coding:utf-8_*_
# 编写人员:王桢罡
# 编写时间:2021/1/6 10:35
# 文件名称:train
# 开发工具:pycharm
import torch
import torch.nn as nn
from model import LeNet
from torch.utils.tensorboard import SummaryWriter
"""
导入数据集MNIST数据集,代码类似于data.py文件。
"""
##导入MNIST数据集
from torchvision.datasets import MNIST ##torchvision包含一些常用... | true |
3500ea071224d42f984aeacd35f7fde1e0102193 | Python | Aura-Zlata/23.09 | /exx7.gyp | UTF-8 | 386 | 3 | 3 | [] | no_license | a=[2000, 3500, 7000, 1700, 4000, 5500, 3000]
b=['Luni','Marti','Miercuri','Joi','Vineri','Sambata','Duminica']
print('Venitul saptaminal al intreprinderii este=',sum(a), "€")
print('Media venitului zilnic este=',sum(a)/7, "€")
max=a.index(max(a))
print('Ziua in care s a obtinut cel mei mare venit este=',b[max])
min=a.i... | true |
d27d44d1264a6a87773fc3b576ba058ba29b2c90 | Python | MingMingZe/LearnFluentPython | /sao_thread/sao_Queue.py | UTF-8 | 2,921 | 3.609375 | 4 | [] | no_license | import queue
import threading
class SaoQueue:
def __init__(self, maxlength):
self.L = []
self.maxlength = maxlength
self.lock = threading.Lock()
def set(self, list):
if self.isfull():
raise Exception("index is out of range")
# self.lock.acquire(blocking... | true |
bd9b98145d691c090f3f0fb94d87636103509257 | Python | walobit/football_predictions | /fetch_fifa_data.py | UTF-8 | 1,678 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
import BeautifulSoup
import urllib
import re
import csv
RE_CODE = re.compile('association=(...)/')
RE_TEAM = re.compile('title="(.+)"')
RE_SCORE = re.compile('(\d+):(\d+)')
URL = 'http://www.fifa.com/associations/library/_results.htmx?gender=m&idAssociation1=0&idAssociation2=0&MatchStatus=2&rang... | true |
0a8cbc9a507b4a2e58711ed810c6b7f3ca77e192 | Python | MePankaj07/Python_Practice | /SwapWthoutTemp.py | UTF-8 | 176 | 4 | 4 | [] | no_license | def Swapping():
x=int(input("Enter Value for x : "))
y=int(input("Enter Value for y : "))
x,y = y,x
print(f"Value of X : {x}, Value of Y : {y}")
Swapping() | true |
4956be5b3baae09b64c56dcae8e5a37df883ead6 | Python | kpkrishan/Udacity-Programming-for-Data-Science-Using-Python | /Analyse Bikeshare Data/bikeshare.py | UTF-8 | 7,936 | 4.0625 | 4 | [] | no_license | import time
import pandas as pd
import numpy as np
CITY_DATA = { 'chicago': 'chicago.csv',
'new york city': '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 o... | true |
cce1866e4505a167552db694ccd8a666891cc2c5 | Python | sandr12234/DMI | /PYTHON/j0x5.py | UTF-8 | 250 | 3.375 | 3 | [] | no_license | x=1. * input ("Lietotaj, ludzu, ievadi x argumentu: ")
k=0
l=1
a = (-1)**0*x**0/(1)
S=a
print "a0= %.2f"%(a)
while k <=10:
k=k+1
l=l+1
a = a * (-1) * x**2/(k*l*4)
S=S+a
print "a= %.2f"%(a)
print "S = %.2f"%(S)
print "Beigas!"
| true |
74897790e2ed5ad67bbda605ccda129b6bac6b28 | Python | atheenaantonyt9689/Python-Problems | /DAY4/inheritance_sample.py | UTF-8 | 1,316 | 3.53125 | 4 | [] | no_license | """from datetime import datetime
time_now = datetime.now()
print(time_now)"""
from datetime import datetime
#time_now =datetime.now()
#date.today()
#print(date.today().isoformat())
class Book:
def __init__(self, title, isbn, author, total_pages):
"""
:type isbn: object
"""
self.tit... | true |
89ce399ebff43c601f72621b575f5088376bbeae | Python | SamRod12/UNEDL | /Alfabeticamente.py | UTF-8 | 379 | 3.734375 | 4 | [] | no_license | nombre1= input("ingresa un nombre: ")
nombre2=input("ingresa otro nombre: ")
print("nombre 1: "+ nombre1 +"\nnombre 2: "+nombre2)
if nombre1==nombre2:
print("Ingreso dos nombre iguales")
else:
print("ordenados alfabeticamente: ")
if nombre1<nombre2:
print(nombre1)
print(nombre2)
... | true |
b14cf567eb0c5b6a6ef6f6c381b5665d4a270f18 | Python | ApprenticeZ/flavours-of-physics | /src/python/hybrid.py | UTF-8 | 2,764 | 2.921875 | 3 | [] | no_license | # a hybrid model
# use gradient boost tree to transform features
# and train a linear regression model for classification
import numpy as np
import pandas as pd
from sklearn import linear_model
import xgboost as xgb
import matplotlib.pyplot as plt
from sklearn.preprocessing import OneHotEncoder
from sklearn.ensemble ... | true |
b8f0b5534ea1f0766e44a05946fac48bbcacf8dc | Python | gowtham877/python-repo | /variables1.py | UTF-8 | 147 | 3.078125 | 3 | [] | no_license | name="gowtham"#my name
age=21
height=170
weight=75
eyes="brown"
teeth="white"
hair="black"
print "my name is %s", name
print "my age is %d", age
| true |
84b141c96caf4f59e8809ddc48f86f91af781758 | Python | esgrid/factorial-challenge | /challenge.py | UTF-8 | 359 | 4.1875 | 4 | [] | no_license | n = int(input("Enter the number of which you want the factorial: "))
counter = 1
nfactorial = n
typed_answer = str(n)
while counter < n:
nfactorial = nfactorial * (n - counter)
typed_answer = typed_answer + " * " + str(n - counter)
counter += 1
if n == 0:
nfactorial = 1
typed_answer = "1"
print(f... | true |
08c8b6c9e66c8ff9a7d22eb62ec1c2299a10bdfd | Python | chengxxi/SWEA | /D3/5215.py | UTF-8 | 2,665 | 3.484375 | 3 | [] | no_license | # 5215. 햄버거 다이어트 [D3]
'''
조합으로 재료들의 전체 경우의 수 부분집합 구한 다음에,
칼로리 합이 칼로리 제한보다 낮으면서 최대점수보다 큰 경우 -> 최대점수 갱신
'''
def dfs(idx, score, total):
# idx: 재료 / score: 점수 / total: 칼로리
if limit < total: return # 가지치기
if idx == num:
global answer
if answer < score:
answer = score
retu... | true |
cf438da3ecae9ff635a34db8e3b8b08f4e7a85db | Python | Cortolan/Advent-of-Code-2020 | /Day 2/day2.py | UTF-8 | 1,511 | 3.53125 | 4 | [] | no_license | #Day 2 Verify Password Requirments
passwordTypeOneCount = 0
passwordTypeTwoCount = 0
def checkData(unparsedData):
global passwordTypeOneCount
global passwordTypeTwoCount
splitUnparsedData = unparsedData.split(' ', 2)
keyValues = splitUnparsedData[0].split('-', 1)
key = splitUnparsedData[1]
... | true |
9483da5a5fd63de00fc643c2ab40d025b35e4b35 | Python | HaDuong2408/Python_27-Sep-2020 | /pythonProject/b8.py | UTF-8 | 588 | 3.671875 | 4 | [] | no_license | #Dùng lambda,filter kiểm tra số chẵn lẻ
l1=[1,2,3,4,5]
# Kiểm tra từng phần tử của l1 nếu chia hết cho 2 thì sẽ gán vào l2
# l2 lá 1 kiểu giữ liệu filter: trả từng phần tử về giá trị bool (true/false)
l2=filter(lambda a:a%2,l1)
print(type(l2))
# Ép l2 thành kiểu list
print(list(l2))
... | true |
eca7245d664541b851c5b7c979296429eda4bce0 | Python | rowan-adair/file-download-sort | /app.py | UTF-8 | 860 | 2.734375 | 3 | [] | no_license | from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
import os, shutil
import json
import time
destination = "C:/Users/rjada/OneDrive/Documents/Python/download-organisation/Test-1"
source = "C:/Users/rjada/OneDrive/Documents/Python/download-organisation/Test-2"
class Handler(F... | true |
b9d74ec3869587596744b59309cd74bf77d06fc5 | Python | NinfaS/StoppingMuonEnergyReconstruction | /featureGeneration/topologyMethods.py | UTF-8 | 7,956 | 3 | 3 | [] | no_license | import numpy as np
from constantDefinitions import BARE_DET_HULL as det_hull
from constantDefinitions import DET_HULL as outer_hull
from constantDefinitions import CORE_HULL as dc_hull
from constantDefinitions import PE_THRESHOLD
def make_muon(p, prim, pe_counts):
"""There's no nice way to do this. Either it's han... | true |
373321accd2bf53177529df7ada9d3961716081f | Python | XieZengYu/site | /wsgi/myproject/api/views.py | UTF-8 | 3,235 | 2.609375 | 3 | [] | no_license | from django.shortcuts import render
from django.views.generic import View
from django.http import JsonResponse
import requests
from pyquery import PyQuery
class Login(View):
"""
登陆用户, 返回 cookie 作为 token,
之后的操作都需要此 token 作为参数,
用 token 这个词比较像是真正的 api.
post 数据为 ::
{
'username': u... | true |