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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
9e36ec7110913fbb912262af24488ad4250f4c2c | Python | codenomad101/stock_app | /stock_app.py | UTF-8 | 380 | 3.3125 | 3 | [] | no_license | import yfinance as yf
import streamlit as st
import pandas as pd
st.write(""" # Simple Stock App
Shown below are the stocks of dogecoin and closing value
""")
tickerSymbol = 'DOGE-INR'
tickerData = yf.Ticker(tickerSymbol)
tickerDf =tickerData.history(period ='1d',start='2020-1-1' , end='2021-5-15')
s... | true |
df1c46ea93f3a229f9c6d2a6b17f75b82b8508df | Python | mjdawson89/AgileUnoModule7 | /test.py | UTF-8 | 581 | 3.25 | 3 | [
"MIT"
] | permissive | """
Matthew Dawson
11/22/20
AgileUnoModule7
"""
# 1
# import my_module and pprint
import my_module
import pprint
# 2
# use the greeting method from my_module to print out your name
print(my_module.greeting('Matt'))
# 3
# use the letter_text module to print out a string
print(my_module.letter_text(name="Matt",amount=... | true |
512298269a2fb000f7e84a74d618aa615549d0da | Python | suboice114/FirstPythonDemo | /SomeExample/example16.py | UTF-8 | 323 | 3.75 | 4 | [] | no_license | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
# @Time : 2019/9/8 13:25
# @Author : su
# @File : example16.py
"""
题目:有一分数序列:2/1,3/2,5/3,8/5,13/8,21/13...求出这个数列的前20项之和。
"""
a = 2.0
b = 1.0
s = 0.0
for i in range(1, 21):
s += a / b
b, a = a, a + b
print(s) | true |
b2756162b865a221dd2284c8b24f85e340d75b68 | Python | Mushrif/UNH | /HW4_4 | UTF-8 | 1,027 | 3.34375 | 3 | [] | no_license | #!/usr/bin/env python3
import pickle
import shelve
##### GETTING INPUT AND STORE IT IN VARIABLES #######
u_name = input("Hi user, Could you write down your name : ")
u_age = input("your age: ")
u_country = input("Country of Origin: ")
name = [u_name]
age = [u_age]
country = [u_country]
dic_pic= {"name":u_name,"age:":u... | true |
69cb086aeea3fc58ce973efaac38d3a6c6222e42 | Python | nima-hakimi/TDT4113 | /Project2/historian_player.py | UTF-8 | 1,588 | 3.390625 | 3 | [] | no_license | """
Historian player.
"""
import random
from player import Player
from action import Action
class HistorianPlayer(Player):
def __init__(self, name, remember):
super().__init__(name)
self.history = []
self.remember = remember
self.is_beaten_by = {
"rock": "paper",
... | true |
1128445ab7bc4b541f8aaf1e2fcc6901106d7d70 | Python | five-hundred-eleven/DataStructures | /DoublyLinkedListClasses.py | UTF-8 | 4,938 | 3.6875 | 4 | [
"MIT"
] | permissive | class ListNode:
def __init__(self, obj, next_node=None, prev_node=None):
assert isinstance(next_node, ListNode) or next_node is None
assert isinstance(prev_node, ListNode) or prev_node is None
self.__val = obj
self.__next = next_node
self.__prev = prev_node
@property
... | true |
f541823bd1058a430a3f17b4dcc411ae1f136ef3 | Python | flippedZH/Carplate-Recognition | /Find_province.py | UTF-8 | 2,949 | 2.8125 | 3 | [] | no_license |
import numpy as np
import cv2
import cv2 as cv
import os
def load_data(filename_1):
filepath2 = "C:\\Users\\zh\\Desktop\\data_province\\txt\\"
pathlist=os.listdir(filepath2)
path_name=[]
for i in pathlist:
path_name.append(i.split(".")[0])
with open(filename_1, 'r') as fr_1:
tem... | true |
67baade9b270bb474d82bc8a28a14a3bf2b60356 | Python | VictoriaLasso/correlation_viewer | /vcorr/generate_sample_data_set.py | UTF-8 | 515 | 2.953125 | 3 | [
"MIT"
] | permissive | __author__ = 'Diego'
import numpy as np
import pandas as pd
def generate_sample_data(n_vars,n_subjs):
subjects = ["subj_%d"%i for i in xrange(n_subjs)]
df = pd.DataFrame(index=subjects)
for var in xrange(n_vars):
array = np.random.random(len(subjects))
df["var_%d"%var] = array
return... | true |
63659538d129da9ae075271eda249ff6c053af61 | Python | STEllAR-GROUP/phylanx | /tests/regressions/python/794_3d_array.py | UTF-8 | 913 | 2.578125 | 3 | [
"BSL-1.0"
] | permissive | # Copyright (c) 2019 R. Tohid
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
from phylanx import Phylanx
import numpy as np
@Phylanx
def one_d():
return np.array([1, 2])
@Phylanx
def two_d():
return np... | true |
6acbc655b0ca87eac03617b286854c22c65d6745 | Python | bmatilla/ai2es_xai_course | /ai2es_xai_course/utils/occlusion.py | UTF-8 | 10,863 | 2.828125 | 3 | [
"MIT"
] | permissive | """Helper methods for occlusion."""
import numpy
from ai2es_xai_course.utils import utils
from ai2es_xai_course.utils import cnn
DEFAULT_LINE_WIDTH = 2.
def _get_grid_points(x_min, x_spacing, num_columns, y_min, y_spacing, num_rows):
"""Returns grid points in regular x-y grid.
M = number of rows in grid
... | true |
f4963b4683ecbc9459790db48a0fc2887a908bee | Python | ZhaoOfficial/Introduction-to-algorithm | /Part 1/Chapter 5/Acceptance_Rejection.py | UTF-8 | 624 | 3.25 | 3 | [] | no_license | """
Using acceptance rejection to implement
Normal distribution
"""
import numpy as np
import matplotlib.pyplot as plt
n = 10000
# g(x) = e^{-x}
# Y ~ Expo(1)
U1 = np.random.random_sample((n, ))
Y = -np.log(U1)
# c = \sup\frac{f(x)}{g(x)}
c = np.sqrt(2 * np.e / np.pi)
# \frac{f(x)}{cg(x)} = e^{-0.5(x - 1)^2}
U2 = n... | true |
b1f5a27f82c25a1ad2d9292f65eddf9f9945950b | Python | ynivin/vcd-tools | /Types/Module.py | UTF-8 | 1,434 | 3.15625 | 3 | [] | no_license | class Module(object):
def __init__(self, name):
self.name = name
self.parent = None
self.submodules = {}
self.wires = {}
def add_submodule(self, new_submodule):
new_submodule.set_parent(self)
self.submodules[new_submodule.get_name()] = new_submodu... | true |
963b7ad60e7b51e9a0c790faa076d508ce1c654f | Python | IntroCept/cricos_scrape | /cricos_scrape/items.py | UTF-8 | 2,763 | 2.578125 | 3 | [] | no_license | # Define here the models for your scraped items
#
# See documentation in:
# http://doc.scrapy.org/topics/items.html
import re
from scrapy.item import Item, Field
from scrapy.loader import ItemLoader
from scrapy.loader.processors import Compose, Identity
import phonenumbers
class InstitutionItem(Item):
type = Fie... | true |
679c8a32122add2c612f398fe2a47bc5e876ccbe | Python | happyhk/MATH_A | /BP_NN.py | UTF-8 | 2,877 | 2.5625 | 3 | [] | no_license | # 引入相关库
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from sklearn import preprocessing
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "1"
# 读取数据
train_data = np.array(pd.read_csv("./train_data/traindatasets.csv"))
test_data = np.array(pd.read_csv(... | true |
47d9c3575a71bd2cc0b5a49e4bd42d4f88888ca4 | Python | qq453388937/data_mining_faith | /machine_learining/first.py | UTF-8 | 6,250 | 3.5625 | 4 | [
"MIT"
] | permissive | # -*- coding:utf-8 -*-
# Scikit-learn 实现数据集的特征工程
# 机器学习的算法和原理
# 应用Scikit-learn==0.18 实现机器学习算法的应用,结合场景解决实际问题
# 人工智能 > 机器学习(典型问题:垃圾邮件分类) > 深度学习(图像识别)
# 机器学习的定义: 数据, 自动分析获得规律, 对未知数据进行预测
# 意义: 提高生产效率,量化投资,智能客服
# TensorFlow
# 掌握算法的应用场景, 从某个业务领域切入问题
# 特征工程
# : 专业背景知识和技巧处理数据, 使得特征能在机器学习算法上的发挥更好的作用的过程
""" 数据和特征决定了机器学习的上限... | true |
17eb3d38df8e5b4f328ce26b5978acdc6000259e | Python | liuyuzhou/databasesourcecode | /chapter3/delete_exp.py | UTF-8 | 1,539 | 3.578125 | 4 | [] | no_license | import pymysql
# 打开数据库连接,添加端口号写法
db = pymysql.connect("localhost", "root", "root", "data_school", 3306)
# 使用cursor()方法获取操作游标
cursor = db.cursor()
def query_mysql(s_num):
"""
根据条件查找数据
:param s_num:
:return:
"""
# SQL 查询语句
sql = "SELECT * FROM python_class WHERE number={}".fo... | true |
b9707f23bff9f2cbce25e045ca6d2a640e07bbba | Python | preacher6/Rel-IMP | /pygame_mantenimiento.py | UTF-8 | 18,095 | 2.515625 | 3 | [] | no_license | import pygame
import sys
import os
import matplotlib.pyplot as plt
from properties import *
from pygame.locals import *
import pygame_gui
WHITE = (255, 255, 255)
GRAY = (112, 128, 144)
SEMIWHITE = (245, 245, 245)
SEMIWHITE2 = (240, 240, 240)
SEMIWHITE3 = (220, 220, 220)
LIGHTGRAY = (192, 192, 192)
class PGManten:
... | true |
cf0c370137ea8321598c4b84473f1171ba6d263d | Python | fxy1018/Leetcode | /80_Remove_Duplicates_from_Sorted_Array_II.py | UTF-8 | 698 | 3.375 | 3 | [] | no_license | '''
Created on Feb 1, 2017
@author: fanxueyi
'''
class Solution(object):
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
#method1 : two pointers
point1 = 0
point2 = 1
while point2 < len(nums):
if nums... | true |
aeb283bf4986660960dd86b551549b0c23a859e4 | Python | soumyax1das/soumyax1das | /exceptional.py | UTF-8 | 340 | 3.25 | 3 | [] | no_license | import sys
def convert(i):
try:
x=int(i)
print('Value is -',x)
except (ValueError,TypeError) as e:
print('Conversion failed')
print(str(e))
#raise
except (IndentationError, SyntaxError, NameError):
pass
if __name__ == '__main__':
convert(3)
convert('... | true |
6852871e280da8b09e5d3f24edc04c4a0a2a901c | Python | CindyLiu617/parkingPrediction | /appserver/externalsort.py | UTF-8 | 3,755 | 2.734375 | 3 | [] | no_license | import csv
import heapq
import os
import utils
LINES_PER_FILE = 50000
DATE_FORMAT = '%Y-%m-%d %H:%M:%S\n'
def external_sort(local_file):
def record_constructor(uploaded):
def save_sorted(time_str_list, file_name):
sorted_time_str = sort_string_list(time_str_list)
with open(file_... | true |
fafe39cc34b127fb8871ea92e99e0b3096605cc3 | Python | banje/acmicpc | /6588.py | UTF-8 | 388 | 2.984375 | 3 | [] | no_license | b = []
for i in range(2, 1000000):
c = int(i**0.5)
for j in range(2, c+1):
if not i%j:
break
else:
b.append(i)
while True:
c=int(input())
if c==0:
break
d=round(c/4+0.1)
j=1
while j<=d:
if 2*j+1 in b and c-(2*j+1) in b:
print("{} =... | true |
65209ea4a04a4af3315f62508ad2c3410c086893 | Python | Narendon123/python | /167p.py | UTF-8 | 142 | 3.265625 | 3 | [] | no_license | a=input()
a=a.replace(" ","")
e=len(a)
for i in range(2,e):
if(e%i==0):
print("no")
break
else:
print("yes")
| true |
181570b74f565291a60e9677405fd62f1364a75c | Python | gustavogattino/Curso-em-Video-Python | /Mundo 1 - Fundamentos/Aula10/aula10_2.py | UTF-8 | 220 | 4.09375 | 4 | [] | no_license | """Exemplos aula 10."""
nome = str(input('Qual o seu nome? ')).strip()
if nome.upper() == 'GUSTAVO':
print('Seu nome é muito lindo.')
else:
print('Que nome normal você tem.')
print('Bom dia, {}'.format(nome))
| true |
8461429339f312e26ac716d8be99084897a72a21 | Python | katsu-tamashiro/hangman | /chpater10-hangman.py | UTF-8 | 1,534 | 3.453125 | 3 | [] | no_license | import random
def hangman():
answer = ["cat","dog","gollira"]
a=random.randint(0,2)
word = answer[a]
# print(word)
wrong = 0
stages =["",
"______________ ",
"| ",
"| | ",
"| ... | true |
28890e9ddf77ca3b145956f089d7fd4fd7a7e167 | Python | diegofneves/ALGO_REDES_2016_2_LISTA4 | /Questao 3.py | UTF-8 | 684 | 3.484375 | 3 | [] | no_license | maior = 0
salarios = [
[float(input("Digite seu salário: ")), float(input("Digite seu salário: ")), float(input("Digite seu salário: "))],
[float(input("Digite seu salário: ")), float(input("Digite seu salário: ")), float(input("Digite seu salário: "))],
[float(input("Digite seu salário: ")), float(... | true |
1a547028e6a2ef51eb1baf153aba4dfb8dce0922 | Python | LarisaOvchinnikova/python_codewars | /Find the index of the first occurrence of an item in a list (with a twist).py | UTF-8 | 109 | 2.734375 | 3 | [] | no_license | # https://www.codewars.com/kata/585ba66ce08bae791b00011b
def index_finder(lst, x):
return lst.index(x, 1) | true |
82ee287e6845612755d59870798414a2fb868c7c | Python | platformer/Python-Stuffs | /Vector.py | UTF-8 | 5,859 | 3.03125 | 3 | [] | no_license | class vector:
def __init__(self, inlist = [], defsize = 0, defval = None, isUnbounded = False, capFunc = lambda cap:cap+10, truesize = None):
"""Use keyword arguments.
Don't enter a truesize value - this is used by vector when performing deepcopy.\n
inlist: list with which to be initiali... | true |
49ab864f30b6a8c0fae94b003faeb4cfaf79aaf8 | Python | scimaksim/Python | /Nikiforov_2.py | UTF-8 | 2,311 | 4.625 | 5 | [] | no_license | # -----------------------------------------------------------------------------
# Name: Grades
# Purpose: Grade calculator - assignment #2
#
# Author: Maksim Nikiforov
# Date: 10/09/2016
# -----------------------------------------------------------------------------
"""
Computes the letter grade ... | true |
b3941bf4a711e0a240504133fa5146014968b801 | Python | BrushkouMatvey/SatelliteImageSegmentation | /Dataset/CustomGenerator.py | UTF-8 | 513 | 2.625 | 3 | [] | no_license | from abc import ABC, abstractmethod
from keras.utils import Sequence
import numpy as np
class CustomGenerator(ABC, Sequence):
def __init__(self, image_filenames, labels_filenames, batch_size):
self.image_filenames = image_filenames
self.labels_filenames = labels_filenames
self.batch_size =... | true |
ded78c84432cc6f871c3bbda8a5f479e47e66f81 | Python | jixiexiaojie/algorithm015 | /Week_01/移动零.py | UTF-8 | 439 | 3.03125 | 3 | [] | no_license | class Solution:
def moveZeroes(self,nums):
"frist: time:O(n),step:O(n)"
j=0
for i in range(len(nums)):
if nums[i]!=0:
nums[i],nums[j]=nums[j],nums[i]
j+=1
def moveZeroes(self,nums):
"second: time:O(n),step:O(n)"
j=0
for i in range(len(nums)):
if nums[i]!=0:
nums[j]=nums[i]
if i!=j:
... | true |
3853c0f189169fa3db2c2d6b62d3a26a205aabdc | Python | rupak-118/concept-to-clinic | /prediction/src/algorithms/segment/trained_model.py | UTF-8 | 1,847 | 3.4375 | 3 | [
"LicenseRef-scancode-generic-cla",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # -*- coding: utf-8 -*-
"""
algorithms.segment.trained_model
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
An API for a trained segmentation model to predict nodule boundaries and
descriptive statistics.
"""
from src.preprocess.load_dicom import load_dicom
def predict(dicom_path, centroids):
""" Predicts nod... | true |
003abbbbfb6bcef05a76530b0d5d7cb3f99a9db8 | Python | grohj/AdventOfCode2019 | /day_8.py | UTF-8 | 1,073 | 3.203125 | 3 | [] | no_license | def chunk(arr, size):
for i in range(0, len(arr), size):
yield (arr[i: i + size])
if __name__ == "__main__":
width = 25
height = 6
per_layer = width * height
with open("inputs/day_8.txt") as f:
data = f.read()
digits = list()
layers = list(chunk(list(map(lambda x: int(x),... | true |
fe45139d708c2bd05fa957c7a4a8bca0ddfbe4ae | Python | SobertKaos/lifecal | /lifecal.py | UTF-8 | 2,197 | 3.609375 | 4 | [] | no_license | import datetime
import math
import numpy as np
import matplotlib.pyplot as plt
class LifeCal(object):
""" This is LifeCal, documentation pending """
def __init__(self, birth=datetime.datetime(1980, 1, 1), life_expectancy=80):
self.birth = birth
self.life_expectancy = life_expectancy
sel... | true |
dd7d641bdacb4efd7df8a290722bcdd9f8d3f1e0 | Python | mrigya-pycode/cat-dog-game-using-OOPs | /catdog game by oops.py | UTF-8 | 734 | 3.515625 | 4 | [] | no_license | import random
class cats_dogs:
def __init__(self, ran_num):
self.ran_num = ran_num
def for_count(self,cat,dog):
for i in range(len(ran_num)):
if ran_num[i] == user_ip[i]:
cat += 1
else:
dog += 1
print("{}:cat,{}:dog".f... | true |
950dc3f1a22226be8a97ae47b5295ff875ec21de | Python | kanderson102/apptracker | /app.py | UTF-8 | 1,595 | 2.609375 | 3 | [
"MIT"
] | permissive | from flask import Flask, render_template
import pandas as pd
import altair as alt
from vega_datasets import data
from datetime import datetime
import json
app = Flask(__name__)
data_path = 'data/AUM_V4_Activity_2018-06-21_17-16-27.csv'
df = pd.read_csv(data_path, parse_dates=[['Date', 'Time']])
df = df... | true |
c0e5c56f6cf704a78e497f77d1999eaed3cdbe90 | Python | Barret-ma/leetcode | /560. Subarray Sum Equals K.py | UTF-8 | 882 | 3.90625 | 4 | [] | no_license | # Given an array of integers and an integer k, you need to
# find the total number of continuous subarrays whose sum equals to k.
# Example 1:
# Input:nums = [1,1,1], k = 2
# Output: 2
# Note:
# The length of the array is in range [1, 20,000].
# The range of numbers in the array is [-1000, 1000] and the
# range of t... | true |
a38d0b877c93b8fc5c1d0fbdc47128eac2986abf | Python | netzsooc/ExploreLyrics | /canciones.py | UTF-8 | 848 | 2.84375 | 3 | [] | no_license | #%%
import os
import requests
import pandas as pd
data = pd.read_csv("https://raw.githubusercontent.com/walkerkq/musiclyrics/master/billboard_lyrics_1964-2015.csv", encoding="cp1252")
con_letra = data[data["Lyrics"].notnull()]
con_letra["Length"] = con_letra.Lyrics.apply(len)
# Determinar estadísticas
longitud = con_... | true |
22e9f05bcf84b1140a015082cd24f39a7aec9b5a | Python | Svastikkka/DS-AND-ALGO | /Linked List/Palindrome LinkedList.py | UTF-8 | 757 | 3.515625 | 4 | [] | no_license | class Node:
def __init__(self,data):
self.data=data
self.next=None
def LinkedList(arr):
head=None
tail=None
if len(arr)<1:
return
else:
for i in arr:
if i ==-1:
break
NewNode = Node(i)
if head == None:
... | true |
b6dd1ea11e8a3939d1f54cd340b67d2c93e158ba | Python | calixt88/Shuriken-Soldier | /main.py | UTF-8 | 1,020 | 3.046875 | 3 | [] | no_license | import pygame
import os
import time
from StartScreen import *
from Constants import *
from pygame import mixer
#Window Initialize
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
#Sets window title and icon
pygame.display.set_caption("Shurkien Soldier")
shurikenIcon = pygame.image.load(os.path.join(... | true |
6caa1f159e5ddcbe1713990f8ef40767663f37f2 | Python | Boombarm/onlinejudge | /Python/src/uri_beecrowd/STRING/P3313_Wordplay.py | UTF-8 | 774 | 3.296875 | 3 | [] | no_license | # author : Teerapat Phokhonwong
# Problem: 3313 - Wordplay
# Link: https://www.beecrowd.com.br/judge/en/problems/view/3313
# Answer: Accepted
# Submission: 12/12/22, 11:22:12 AM
# Runtime: 0.006s
# Note: สลับตำแหน่งท้ายไปที่ตำแหน่งแรก แล้วหาว่าคำเรียงลำดับ ลำดับไหนเล็กสุด และใหญ่สุด
counter = 0
while True:
arr = ... | true |
36c3a1719bffdb9529cbcd21645ea93f28e20a99 | Python | wesbdss/AIDA-fluxo | /fluxo.py | UTF-8 | 2,314 | 3.109375 | 3 | [
"MIT"
] | permissive | import yaml
import random
import logging
#
# A estrutura
#
# init: LABEL
# label:
# response: "RESPOSTA"
# output:
# label1: "LABEL"
# label2: "LABEL"
class Fluxo:
def __init__(self,diretory="fluxo.yaml"):
self.diretory = diretory
logging.debug("{} - {}".format(self.__class__,"F... | true |
3e3bb30f0734029ac7dad9da8c4228961a3ba7ab | Python | LucasBarbosaRocha/URI | /Strings/1276.py | UTF-8 | 769 | 3.140625 | 3 | [] | no_license | while True:
try:
entrada = input("")
if (entrada == ""):
print()
else:
entrada = entrada.replace(" ","")
ordenada = ''.join(sorted(entrada)) + "$"
intervalos = []
first = 1
intervalo = ""
for i in range(len(ordenada)):
if (first == 1):
intervalo = ordenada[i]
first = 2
else... | true |
84114432fa9cd05c1a89e577cd6c0089ee404040 | Python | complicat9716/EmbroideryFractal | /Old_PythonCodes/CircleJEF.py | UTF-8 | 3,741 | 2.796875 | 3 | [] | no_license | from math import *
# Going through all four sides of the square
# Clockwise, starting at the bottom left
# Sides are 1 cm long, in ten stiches 1mm each
# 246 is the unsigned 8-bit version of -10
##################################################################################################
# Starting stitch
stit... | true |
a9f7678e283752d4c592ad1c9d5b1fc1b4fc9dd9 | Python | Lemmah/tensorflow | /exampleOne.py | UTF-8 | 1,780 | 3.765625 | 4 | [] | no_license | # Getting started with tensorflow
# Done by James Lemayian
import tensorflow as tf
node1 = tf.constant(3.0, tf.float32)
node2 = tf.constant(4.0) # also float32 implicitly
# This does not print the actual value of the nodes because the nodes are not evaluated
print(node1,node2)
# Running the nodes in a session actua... | true |
6a9e1a7b2ada9470950b52b04cdd3858e664207c | Python | Zhifu-Xiao/Log-Analysis-with-Hadoop-and-Hive | /Mapper2.py | UTF-8 | 476 | 2.609375 | 3 | [] | no_license | #!/usr/bin/env python
import sys
import string
all = string.maketrans('','')
nodigs = all.translate(all, string.digits)
for line in sys.stdin:
response_bytes = 0L
line = line.strip()
split = line.split(" ")
month = split[2]
if (month != 'Jul'):
response_bytes = 0L
else:
response_bytes = split[... | true |
403efe59b1a9636228f3596d906a7adc91326b9d | Python | DiegoSantosWS/estudos-python | /estudo-6/lista-01.py | UTF-8 | 1,619 | 4.5625 | 5 | [] | no_license | # Criando uma lista com 3 inteiros
lista_numeros = [25, 78, 55]
# Os elemetos da lista iniciam com zero
# 0=25, 1=78, 2=55
# Na linha abaixo será impresso 78
print(lista_numeros[1])
# Alterando o segundo elemento da lista de 78 para 30
lista_numeros[1] = 30
# Na linha abaixo será impresso 30
print(lista_numeros[1... | true |
c5e97cecf8dd31fd517c5467e25a36a2d281b7d4 | Python | spdut/deep_qa | /deep_qa/data/data_generator.py | UTF-8 | 10,627 | 2.921875 | 3 | [
"Apache-2.0"
] | permissive | from typing import List
import logging
import random
from copy import deepcopy
from ..common.params import Params
from ..common.util import group_by_count
from . import IndexedDataset
from .instances import IndexedInstance
logger = logging.getLogger(__name__) # pylint: disable=invalid-name
class DataGenerator:
... | true |
392b4b90d83cd9ee4b1204757761efbaa54e04db | Python | oeuftete/advent-of-code | /adventofcode/year2020/day16/solution.py | UTF-8 | 5,658 | 2.765625 | 3 | [] | no_license | import logging
from dataclasses import dataclass, field
from typing import Tuple
from aocd.models import Puzzle
logging.basicConfig(level=logging.INFO)
@dataclass
class Ticket:
ticket_values: list = field(default_factory=list)
@dataclass
class TicketValidator:
boundary_rules: dict = field(default_factory=... | true |
5749862cbbecd9d122b587ec0e532df1bd0d664f | Python | noreallyimfine/Rubiks-Cube | /test_cube_mechanics.py | UTF-8 | 32,053 | 2.65625 | 3 | [
"MIT"
] | permissive | import unittest
from cube import RubiksCube
class CubeTurnTests(unittest.TestCase):
def setUp(self):
self.cube = RubiksCube()
def test_L_prime(self):
# Corners
top_back_left = self.cube.top_layer['back_left'].sides.copy()
top_front_left = self.cube.top_layer['front_left'].side... | true |
2b5a3a95890db38dd2662278d72dfc1accd729ee | Python | sanchitkalra/Classes | /conditions_and_loops/odd_and_even_sum.py | UTF-8 | 303 | 3.359375 | 3 | [] | no_license | num = int(input())
count = 0
n_str = str(num)
odd_sum = 0
even_sum = 0
for i in n_str:
count+=1
i = 0
while i < count:
y = int(n_str[i])
if y%2 == 0:
even_sum += int(n_str[i])
else:
odd_sum += int(n_str[i])
i += 1
print(even_sum, " ", odd_sum) | true |
f17e02e0c0d3988e05c6ed351726fb3e260a862b | Python | shaswata56/RsaCtfTool | /_primefac/_factor_algo/_mpqs.py | UTF-8 | 10,407 | 3.140625 | 3 | [
"Beerware"
] | permissive | from __future__ import division
# Multiple Polynomial Quadratic Sieve
# Most of this function is copied verbatim from
# https://codegolf.stackexchange.com/questions/8629/9088#9088
def mpqs(n):
"""
When the bound proves insufficiently large, we throw out all our work and
start over.
TODO: When this happ... | true |
a35a96e242a5011d9a7eaa6db0cfc7c8070bb47b | Python | Hugo-cruz/birdie-ps-webcrawler | /main.py | UTF-8 | 588 | 2.625 | 3 | [] | no_license | from selenium import webdriver
import json
import crawler_functions as crawler
import utils as utils
refrigerator_page = 'https://www.lowes.com/c/Refrigerators-Appliances'
if __name__ == "__main__":
subcategory_pages = crawler.get_subcategory_pages(refrigerator_page)
print(subcategory_pages)
products... | true |
91b0b64da1bc54e2cceb4af15772bc7d14a58ac8 | Python | bendell02/nowCoder | /03_kaoyan/016_n_factorial.py | UTF-8 | 111 | 3.234375 | 3 | [] | no_license | import math
while True:
try:
N = input()
print math.factorial(N)
except:
break
| true |
c3c72c9029be0e30d1b3a130e788aea9420be69b | Python | curieshicy/My_Utilities_Code | /Grokking_the_Coding_Interviews/p77_frequency_sort.py | UTF-8 | 1,031 | 3.796875 | 4 | [] | no_license | import heapq
from collections import OrderedDict, defaultdict
def sort_character_by_frequency(str):
od = OrderedDict()
for ch in str:
if ch in od:
od[ch] += 1
else:
od[ch] = 1
ans = ''
freq_ch = [(freq, ch) for ch, freq in od.items()]
freq_ch.sort... | true |
e34d3c227237ea271c03e7d44a98beeda05bf954 | Python | pbp1992/wear-detection-using-conv_nets | /core/model.py | UTF-8 | 2,208 | 2.78125 | 3 | [] | no_license | import torch
import torch.nn as nn
def Conv2d(in_filters, out_filters, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)):
return nn.Conv2d(in_filters, out_filters, kernel_size=kernel_size, stride=stride, padding=padding)
def Max2d(kernel_size=(2, 2), stride=2):
return nn.MaxPool2d(kernel_size=kernel_size, s... | true |
e3c4ef8519ae1a57dbf4947024ac4fd72b582790 | Python | gebn/wood | /wood/invalidate.py | UTF-8 | 1,362 | 3.140625 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
from typing import Iterator
import abc
from wood.comparison import Comparison
from wood.entities import Entity
class Invalidator(metaclass=abc.ABCMeta):
"""
Implemented by things that know how to invalidate the changes in a
comparison.
"""
def invalidate(self, comparison:... | true |
daa5ac601b64dc62f8f339151adf17452c74f8d6 | Python | metanoia1989/PythonStudy | /DesignPattern/09_责任链模式/bad_call.py | UTF-8 | 927 | 3.671875 | 4 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
糟糕的调用演示
"""
def function_1(in_string):
print("function_1")
return "".join([x for x in in_string if x != '1'])
def function_2(in_string):
print("function_2")
return "".join([x for x in in_string if x != '2'])
def function_3(in_string):
print("fun... | true |
b54a799cfd40c627f4442726cafa15a96e35c528 | Python | RahulMarathe94/Fall-2018-ECE-478-578-Robotics1-TurtleBot_Project2 | /Project Files/Robot Theatre/newton.py | UTF-8 | 820 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env python
'''
says a line if the line exists for the robot.
Then publishes increment to indicate its done.
'''
import rospy
import pygame
import os
import time
from std_msgs.msg import Int32
def lineCallback(data):
line = data.data
audio_file = "/home/turtle1/catkin_ws/src/project2_play/scripts/line... | true |
8ddafa4ab2aa831bfec272f9c5b853a0c1bb5e6b | Python | RalphMul/DataScientistCourseDS | /zelfstudie/Exercise_List4.py | UTF-8 | 1,569 | 4.3125 | 4 | [] | no_license | """
Autor: Ralph Mul
File name: Exercise_List4
Info: This exersise is created based on the Python Data Structure Exercise for Beginners assignment as stated in
https://pynative.com/python-data-structure-exercise-for-beginners/
Date: 17-08-2020
Version 0.1
assignment:
Given a list iterate it and count the occu... | true |
664cec4d35d9fff6ff4917ad37a97150b37f5d7c | Python | mikasiddiqui/Python | /Euler/euler 39.py | UTF-8 | 748 | 3.3125 | 3 | [] | no_license | def rightAngle():
count = 0
number = 0
for p in range(900,1001):
numbers = []
for partition in partitionSum(p,3):
pythagoras = []
for r in partition:
pythagoras.append(r)
if pythagoras[2]**2 + pythagoras[1]**2 == pythagoras[0]**2:
numbers.append(pythagoras)
if (len(numbers) > ... | true |
cf74d3bf5462107dab0e993407ab9bcfa29d9f1c | Python | omarfakhreddine/Focus | /FocusGameTests.py | UTF-8 | 9,846 | 3.765625 | 4 | [] | no_license | # This file contains tests for FocusGame.
import unittest
from FocusGame import FocusGame, Tile, Board
class FocusGameTests(unittest.TestCase):
# write test methods below
def test_initializer_of_focus_game_creates_object_when_passed_valid_parameters(self):
g = FocusGame(("player1", "r"), ("player2", ... | true |
d438ddaea9e9869aebe5fd66adb0620e044be9a2 | Python | aidansmyth95/AlgoExpertSolutions | /Dynamic Programming/Square of Zeroes/Solution1.py | UTF-8 | 1,011 | 4.21875 | 4 | [] | no_license | '''
Dynamic programming.
I like the iterative solutons better, plus they have better time complexity than recursive.
First solution: sub-optimal in time, best in space.
Get all squares, moving top left corner, and then check each to see if square of zeros
'''
# O(n^4) T | O(1) S
def squareOfZeroes(matrix):
n = le... | true |
4ca61bdecfbc78711d14ab57a5e6a1be4b02fa76 | Python | robcharlwood/inference_logic | /tests/data_structures/test_prologlists.py | UTF-8 | 419 | 2.8125 | 3 | [
"MIT"
] | permissive | import pytest
from inference_logic.data_structures import PrologListNull, construct
def test__repr__():
assert repr(construct([1, [2, 3], 4])) == "[1, [2, 3], 4]"
def test__eq__fail():
with pytest.raises(TypeError) as error:
PrologListNull() == 0
assert str(error.value) == "0 must be a PrologL... | true |
7e7ff5f6fe381a38c9a10e685d6e8508503cf547 | Python | monchier/streamlit | /examples/core/checkbox.py | UTF-8 | 207 | 2.5625 | 3 | [] | no_license | import streamlit as st
i1 = st.checkbox('checkbox 1', True)
st.write('value 1:', i1)
i2 = st.checkbox('checkbox 2', False)
st.write('value 2:', i2)
i3 = st.checkbox('checkbox 3')
st.write('value 3:', i3)
| true |
76abb0b5f08260d4a5c735de692bbf9d7ae56250 | Python | thkim1011/graph | /src-python/graph.py | UTF-8 | 1,518 | 3.65625 | 4 | [] | no_license | class Graph:
"""
Implements a simple graph
"""
def __init__(self, vertices):
self.vertices = set(vertices)
self.adj_lists = {}
for vertex in vertices:
self.adj_lists[vertex] = []
def add_vertex(self, vertex):
self.vertices.add(vertex)
def add... | true |
fce666426650d6c8d80e933d12808dfd5f2043c5 | Python | assertpy/assertpy | /tests/test_dyn.py | UTF-8 | 4,512 | 3.171875 | 3 | [
"BSD-3-Clause"
] | permissive | # Copyright (c) 2015-2019, Activision Publishing, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of ... | true |
a06723663e36e64aaf5ba9c0120ca14469559318 | Python | stellarlib/centaurus | /src/game/logic/ai_control/unit_ai/ai.py | UTF-8 | 974 | 2.890625 | 3 | [] | no_license | from .behaviours import *
from src.map import Hex
class AI(object):
def __init__(self, owner):
self.owner = owner
self._alert = False
self._range = 1
@property
def player(self):
return self.owner.game.logic.player
@property
def map(self):
return self.owne... | true |
58f888a3a8283b6252562cd3554daf94b8ea6e9d | Python | wolfdan666/WolfEat3moreMeatEveryday | /公司面试题/深信服cpp软开A卷_2020.5.11做/C栈弹出所有可能.py | UTF-8 | 1,080 | 3.359375 | 3 | [] | no_license | #import itertools
def GetAllSeq(input, i, stk, tmp, res):
# 注意tmp1和stk是要回溯的,所以这两者不能传引用;而res是一直保留结果的,传引用就对
tmp1 = list(tmp)
stk1 = list(stk)
if i == len(input): # 结果记录
stk1 = stk1[::-1]
tmp1.extend(stk1)
res.append(tmp1)
#print(res)
return
stk1.append(input[i])... | true |
5e6dc2cbbd124dfcde4b38d8bbe13590ddf19736 | Python | den4uk/andriller | /andriller/gui/tooltips.py | UTF-8 | 1,388 | 2.71875 | 3 | [
"MIT"
] | permissive | import tkinter as tk
from contextlib import suppress
class ToolTip:
offset = 25
def __init__(self, widget):
self.widget = widget
self.tipwindow = None
self.id = None
self.x = self.y = 0
def showtip(self, text):
"Display text in tooltip window"
self.text = ... | true |
8569075d6601786870596c3945dc0e6dc0d0c9af | Python | fpviviani/python-tkinter | /gui/mainWindow.py | UTF-8 | 1,514 | 3.265625 | 3 | [] | no_license | import tkinter as tk
from gui import buttons as b
class mainWindow:
def __init__(self):
self.window = tk.Tk()
texto = ""
self.initWidgets(self.window, texto)
self.window.mainloop()
def initWidgets(self, window, texto):
self.title = self.window.title('Janela Principal')... | true |
a95253a2c554ad687dd9a29c7f20715a62ec0211 | Python | MarioSanzRodrigo/GREDOS | /others/ManagementLayer/ManagementLayer/RenemaAppManager/Sender.py | UTF-8 | 1,448 | 2.9375 | 3 | [] | no_license | #!/usr/bin/python
#-------------------------------------------------------------------------------------
# This module is part of the PHD Thesis:
# "A User-Centric SDN Management Architecture for NFV-based Residential Networks".
# Copyright Ricardo Flores Moyano 2016.
#-----------------------------------------------... | true |
dc69b5b679e2334d13604f57c372caca0ddcc2db | Python | ctmakro/pimona | /colors.py | UTF-8 | 975 | 2.953125 | 3 | [] | no_license | from termcolor import colored, cprint
import colorama
colorama.init()
def colored_print_generator(*a,**kw):
def colored_print(*items,**incase):
text = ' '.join(map(lambda i:str(i), items))
# escape unsupported unicode in current encoding
# (to prevent emojis from crashing CMD
text... | true |
bbb6a84172623a54ab610bbdd9aa6c178a1cb0cf | Python | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/leap/6a77f22115944d92affaedad6c32d58d.py | UTF-8 | 108 | 2.53125 | 3 | [] | no_license | def is_leap_year(year):
if year % 100 == 0:
return not (year % 400)
return not (year % 4)
| true |
9c21b3b6fe0bb72567eb607bd189beb849efe2a4 | Python | ChitMyoKo/passwdgen | /passwdgen/generator.py | UTF-8 | 5,852 | 3.484375 | 3 | [
"MIT",
"LicenseRef-scancode-mit-old-style",
"LicenseRef-scancode-public-domain"
] | permissive | # -*- coding: utf-8 -*-
import math
from .utils import secure_random, load_word_list
from .constants import *
__all__ = [
"chars",
"words"
]
def chars(charset=None, length=None, min_entropy=None):
"""Generates a character-based password. If the length parameter is supplied, the min_entropy parameter
... | true |
6b47311904d2fee10dcfb30817580e48527cf3e4 | Python | 812231487/periodicity | /periodicity/phase.py | UTF-8 | 4,846 | 3.15625 | 3 | [
"MIT"
] | permissive | import numpy as np
from .acf import gaussian, smooth
def stringlength(t, x, dphi=0.1, n_periods=1000, s=0):
"""String Length
(Dworetsky 1983, MNRAS, 203, 917)
Parameters
----------
t: array-like
time array
x: array-like
signal array
dphi: float (optional default=0.1)
... | true |
0ace6610e3e3f4560d6a5c413eeaa4e30189f00e | Python | antny94/Python | /Loops.py | UTF-8 | 394 | 3.96875 | 4 | [] | no_license | # practice with loops in python
# I imagine it'll be similar to c++?
Anime = ["Avatar: The Last Airbender", "Vinland Saga", "Spirited Away"]
Anime.append("A Place Further Than The Universe")
Anime.append("Naruto")
lengthAnime = len(Anime)
for x in range(0, lengthAnime):
print(Anime[x])
# practice wi... | true |
2bf885fb3b96ca6800d5d454419428676f333a69 | Python | sunjunee/offer_book_python_codes | /codes/T58-2.py | UTF-8 | 442 | 4.1875 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
@ Author: Jun Sun {Python3}
@ E-mail: sunjunee@qq.com
@ Date: 2018-05-27 16:50:18
"""
# T58-2 左旋转字符串
# 字符串的左旋转操作是把字符串前面的若干
# 字符转移到字符串的尾部。比如输入字符串
# "abcdefg"和数字2,该函数将返回左旋转
# 两位得到的结果"cdefgab"
def rotateStrs(strs, index):
return strs[index:] + strs[0:index]
print(rotateStrs("abcdefg", ... | true |
8ac226d3a7bd12be9e1455d16d02c208a8011811 | Python | alexisflores99/Repo-for-Python | /Interfaces Graficas/menu.py | UTF-8 | 732 | 2.671875 | 3 | [] | no_license | from tkinter import *
root = Tk()
barraMenu = Menu(root)
root.config(menu=barraMenu)
archivoMenu = Menu(barraMenu,tearoff=0)
barraMenu.add_cascade(label="Archivo",menu=archivoMenu)
archivoMenu.add_command(label = "Nuevo Archivo")
archivoMenu.add_command(label = "Nueva Ventana")
archivoMenu.add_separator()
archivoMen... | true |
a35b196be5fedfd354b7b38f7ca051b3f2aa12d4 | Python | ShrutiMarwaha/Python | /Rosalind_problems/longest_common_dna_motif.py | UTF-8 | 2,959 | 3.78125 | 4 | [] | no_license | # Problem: Finding a Shared Motif http://rosalind.info/problems/lcsm/
#
# A common substring of a collection of strings is a substring of every member of the collection.
# We say that a common substring is a longest common substring if there does not exist a longer common substring.
# For example, "CG" is a common sub... | true |
09f9db374d9752da2f39a3bd0e335aecc6c69572 | Python | moneymashi/SVN_fr.class | /pythonexp/a10_dataload/a07_insertMysql.py | UTF-8 | 1,364 | 2.9375 | 3 | [] | no_license | '''
Created on 2017. 7. 31.
@author: kitcoop
파이썬에서 삽입과 삭제 또는 갱신..
1. 연결객체인 pymysql.connect()에 있는 cursor() 메서드를 호출하여..
sql(insert into 테이블명 values(##,##,##)) 명령으로 처리한다.
2. excute( sql 명령어 )
3. 연결 객체에 있는 commit() 호출로 반영, rollback() 호출하여 취소
처리된다.
4. 예외 처리..
try:
연결및 sql 처리, commit()
... | true |
99e57669b0c6eb101ced98749b92579fc9deabe7 | Python | RafaelDias108/AulaWeb1 | /Ativ05.py | UTF-8 | 743 | 4.375 | 4 | [] | no_license | # Elabore um código em Python para receber do usuário:
# ▪ Nome do aluno;
# ▪ 02 notas;
# ▪ 02 pesos, respectivamente para cada nota;
# ▪ Retorne uma mensagem para o usuário informando a média ponderada desse aluno;
# ▪ Utilize o método split para separar a entrada do usuário em nota e peso. Exemplo: Digite a nota... | true |
e324438c0aa36daadc165b4fdf88b1035f169eba | Python | thisistom/codesamples | /mastermind.py | UTF-8 | 9,388 | 4.25 | 4 | [] | no_license | #!/usr/bin/env python
"""
Mastermind - a simple command-line logic game.
The game will pick a numerical code, and the player must guess the code in as
few tries as possible. The game will tell users how many correct digits they
have, but not which ones are correct. Users can optionally specify the
difficulty of the ga... | true |
f38cf36fddaf0bdf3fff8d928c3baf9aaee82a92 | Python | maik001/Simplify | /python/admin/modelo/Aluno.py | UTF-8 | 650 | 3.453125 | 3 | [] | no_license | '''
Created on 7 de nov de 2019
@author: jefferson Oliveira
'''
class Aluno:
__nomeAlu = ""
__matricula = ""
__curso = ""
__serie = ""
#getters
def getNomeAlu(self):
return self.__nomeAlu
def getMatricula(self):
return self.__matricula
def getCurso(self):
... | true |
52bc44b7d522faaca6c98f6b0ed080d30317141a | Python | William-Weng/Python | /PyGame/02.Pic/Color.py | UTF-8 | 514 | 2.703125 | 3 | [] | no_license | #-*- coding: UTF-8 -*-
import pygame
pygame.init()
allColors = pygame.Surface((4096, 4096), depth=24) # 4096 * 4096 * 24bits 的白紙 ==> bland_alpha_surface = pygame.Surface((256, 256), flags=SRCALPHA, depth=32)
for r in range(256): # rgb ==> (0,0,0) ~ (255,255,255)
print(r + 1, "out of 256")
x, y = (r & 0b11... | true |
1f9a9ed73c67c92665ffd34a7915993224499415 | Python | HumanCompatibleAI/atari-irl | /atari_irl/utils.py | UTF-8 | 7,278 | 2.828125 | 3 | [] | no_license | """
This may all be thrown away soonish, but I could imagine keeping these design
patterns in some form or other.
I hope that most of our patches to the baselines + gym code can happen in this
library, and not need to move into other parts of the code.
Desiderata:
- Not introduce too many dependencies over Adam's pat... | true |
25ac97f645362cba45e4ff8893599382d34d9a27 | Python | ssbagalkar/PythonDataStructuresPractice | /SlidingWindow/02_first_negative_number.py | UTF-8 | 1,584 | 3.78125 | 4 | [] | no_license | """
Video -> https://www.youtube.com/watch?v=uUXXEgK2Jh8&list=PL_z_8CaSLPWeM8BDJmIYDaoQ5zuwyxnfj&index=4&ab_channel=AdityaVermaAdityaVerma
Problem --> https://www.geeksforgeeks.org/first-negative-integer-every-window-size-k/
Complexity:
Method Time (worst) Auxiliary Space(worst) Passin... | true |
0a1fbe85881b5122e6bb123942fc63639d9b8e70 | Python | himanshukushabhauakolkar/python-lab | /armstrongno.py | UTF-8 | 174 | 2.890625 | 3 | [] | no_license | x=int(input('enter the no '))
q=x//100
r=x%100
r1=r%10
r2=r1%10
q1=r//10
z=q**3+q1**3+r2**3
if x==z:
print('armstrong no ')
else:
print('not a armstrong no')
| true |
ced938088327cf33555bfcff9884a7db63b78c4c | Python | HektorW/sublime-fold-comments | /foldcomments.py | UTF-8 | 2,950 | 2.859375 | 3 | [] | no_license | import sublime, sublime_plugin, re
class ToggleFoldCommentsCommand(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
comments = view.find_by_selector('comment')
regions = []
prev = None
for region in comments:
# multi_line = len(view.lines(region)) > 1
# adjacent = prev and view.rowco... | true |
82000cf061ff0590d5c4902fe2c20ca9beb69880 | Python | Quantomatic/pyzx | /pyzx/circuit/qasmparser.py | UTF-8 | 10,553 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | # PyZX - Python library for quantum circuit rewriting
# and optimization using the ZX-calculus
# Copyright (C) 2018 - Aleks Kissinger and John van de Wetering
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a ... | true |
e11325a8ec900f9c58c7f5d7e13a90dd5302864b | Python | ausaafnabi/Machine-Learning-Projects | /Clustering/K-means.py | UTF-8 | 3,161 | 3.03125 | 3 | [
"MIT"
] | permissive | import matplotlib.pyplot as plt
import pandas as pd
import pylab as pl
import numpy as np
import random
import os
from sklearn.cluster import KMeans
from sklearn.datasets.samples_generator import make_blobs
np.random.seed(0);
X, y = make_blobs(n_samples=5000, centers=[[4,4], [-2, -1], [2, -3], [1, 1]], cluster_std=... | true |
d4ef7c569d617c8f72ed4d1a173c4c5ac8aef154 | Python | justynast/python-dla-kazdego | /06 - funkcje/ćwiczenie_06_02_03.py | UTF-8 | 1,743 | 4.46875 | 4 | [] | no_license | """
2. Zmodyfikuj projekt 'Jaka to liczba?' z rozdziału 3. przez użycie w nim funkcji ask_number().
3. Zmodyfikuj nową wersję gry 'Jaka to liczba?', którą utworzyłeś w ramach poprzedniego zadania, tak
aby kod programu znalazł się w funkcji o nazwie main().
"""
import random
def displayInstruction():
""" display i... | true |
07930b2e41f5669c03113ee1c743f60f831b87f0 | Python | sunilgvs/SDETTraining | /Python/Activity3.py | UTF-8 | 764 | 4.03125 | 4 | [] | no_license | user1 = input("what is Player1 Name ")
user2 = input("what is Player2 Name ")
user1_ans = input(user1 + ", do you want to choose rock, paper or scissor? " ).lower()
user2_ans = input(user2 + ", do you want to choose rock, paper or scissor? " ).lower()
if user1_ans == user2_ans:
print("its tie ")
elif user... | true |
84078a344ca008afff0b64a150f38d13f3360f9e | Python | weiguxp/pythoncode | /ProblemSets/ParseFile.py | UTF-8 | 344 | 3.84375 | 4 | [] | no_license | def ParseF(n):
''' opens file n and returns a list of words
n = name of file
'''
fin = open(n)
myList = []
for line in fin:
word = line.strip()
myList.append(word)
return myList
def ParsePartF(n, l):
''' Opens a file and parses the first l words
n = file name
l = desired length of list'''
myList = Pars... | true |
ecabd59cd8744fa3c869ec76dbb7716028709f46 | Python | mobone/screener | /playit.py | UTF-8 | 1,065 | 2.609375 | 3 | [] | no_license | import sqlite3 as lite
import sys
import pandas as pd
con = lite.connect('screens.db')
cur = con.cursor()
try:
filename = sys.argv[1]
metrics = sys.argv[2]
original_metrics = metrics
metrics = metrics.replace('+', '", "')
metrics = '"' + metrics +'"'
result = pd.read_sql('Select Date, Ticker, ... | true |
4dd57f91155f1e5f2a96d4c1da39dd70b2c88db1 | Python | hyamynl619/DS-Unit-3-Sprint-1-Software-Engineering | /module2-oop-code-style-and-reviews/Making_a_class.py | UTF-8 | 428 | 3.953125 | 4 | [
"MIT"
] | permissive |
"""
Define a Pet class with their attributes
"""
class Pet(object):
def __init__(self, name, speaks):
self.name = name
self.speaks = speaks
def full_name(self):
return f"{self.name}"
def speaks(self):
print({self.name} + ' speaks')
if __name__ ==... | true |
59d9d80eb84f3d84053bb8a9449753c47f3a0cd4 | Python | sourav-crossml/session1 | /week1-august/assigment1withclass.py | UTF-8 | 2,861 | 3.21875 | 3 | [] | no_license | import datetime
from hashlib import new
import uuid
import os,getpass
import json
import random
class UserData:
"""
this class will print user current datetime , local user and output
from the text files and then save that output to json file with userid
email and name
"""
def __init__(self,us... | true |
97b41508dd32944a86b542490d238a94bbb09ec6 | Python | cyrh/pytorch-example | /capsulenet/model/capsnet.py | UTF-8 | 2,587 | 2.515625 | 3 | [] | no_license | #coding:utf-8
import torch
import torch.nn as nn
from torch.autograd import Variable
import torch.nn.functional as F
import sys
sys.path.append("..")
import utils
import config
conf = config.DefaultConf()
class CapsNet(nn.Module):
"""
input :a group of capsule -> shape:[batch_size*1152(feature_num)*8(in_dim)]
... | true |
6aba8898439d95e54d60e99f968e0e4dc7060797 | Python | Divyanshu169/IT556_Worthless_without_coffee_DA-IICT | /201501004_Aashini/Assigment 3 Spacy/Spacy.py | UTF-8 | 750 | 2.65625 | 3 | [] | no_license | import spacy
from elasticsearch import Elasticsearch
from pprint import pprint
import json
import requests
#es = Elasticsearch([{'host': 'localhost', 'port': 9200}])
nlp = spacy.load('en')
doc = nlp(u'Apple is looking at buying U.K. startup for $1 billion')
"""
for token in doc:
print(token.text, token.lemma_, to... | true |
f8ff6558a18738d87c7fb04f0b1ec0c699488360 | Python | ShehanIshanka/t-combo | /t_combo/TextCombo.py | UTF-8 | 2,890 | 3.03125 | 3 | [
"MIT"
] | permissive | import argparse
import json
import re
import sys
def process_multiple_files(config_file):
configs = open(config_file, "r").read()
config_dict = json.loads(configs)
for config in config_dict["configs"]:
process_single_file(config["input_file"], config["output_file"])
def process_single_file(input... | true |
b080ca7293632141ce0aefc0caf8c0074db086e7 | Python | gauravbg/Drug-Abuse-Analysis-using-Twitter-Reddit-Data | /Drug-Abuse-Analytics-on-Twitter-data/MTurk/PostHit.py | UTF-8 | 3,912 | 2.640625 | 3 | [] | no_license | '''
Created on Feb 17, 2017
@author: Gaurav BG
'''
import csv
import sys
from boto.mturk.connection import MTurkConnection
from boto.mturk.question import QuestionContent,Question,QuestionForm,Overview,AnswerSpecification,SelectionAnswer,FormattedContent,FreeTextAnswer
from fileinput import filename
sandbox_host = '... | true |