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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
8008b5b7edc963db19adf1404e30cceccc953ab1 | Python | akshatapatel/Next-word-predictor | /main1.py | UTF-8 | 1,681 | 2.78125 | 3 | [] | no_license | from subprocess import check_output
from bs4 import BeautifulSoup
import pandas as pd
import re
import numpy as np
import nltk
import csv
import extract_bigrams
from nltk.corpus import stopwords # Import the stop word list
mean_words_pos0=[]
data=pd.read_csv("Book1_pos.csv")
mean_words_pos=[... | true |
937694c273a380cb53175731390961f41657217d | Python | valeryvpetrov-dev/ML-ITIS-classes | /24_09_2020/main.py | UTF-8 | 7,329 | 2.921875 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
import os
import glob
CLUSTER_CENTER_MOVED_EPS = 0.1
def euclidean_dist(x1, y1, x2, y2):
return np.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
def assign_points_to_clusters(x_points, y_points, x_cluster_centers, y_cluster_centers):
points_number = len(x_points)
... | true |
f27a2664ff28e30ed89a151cb8488470d96d40ef | Python | kiryanchi/pythonlecture | /venv/20190927/PY03_4_2017112387_박기현.py | UTF-8 | 248 | 3.53125 | 4 | [] | no_license | price = []
price = list(map(int, input("가격을 입력하세요: ").split(';')))
# 오름차순 정
price.sort(reverse=True)
# print(price[i].format(3,','), end="")
for i in range(0, len(price), 1):
print("%9s" % format(price[i],',') ) | true |
2ff0f112804706cd152c919d36ebe001046589dc | Python | muse321/muse_Test | /usl.py | UTF-8 | 1,166 | 2.953125 | 3 | [] | no_license | from game2048.bll import *
import os
class GameConsoleView:
def __init__(self):
self.__controller = GameCoreController()
def __start(self):
self.__controller.generate_numer()
self.__controller.generate_numer()
self.__draw_map()
def __draw_map(self):
os.system('clea... | true |
73dce13bd4ddbb63a5690b058ceeff210bc825f7 | Python | Toontown-Open-Source-Initiative/Toontown-Pizza-Ordering | /pizzapi/menu.py | UTF-8 | 5,318 | 3.171875 | 3 | [
"MIT"
] | permissive | from __future__ import print_function
from .urls import Urls, COUNTRY_USA
from .utils import request_json
# TODO: Get rid of this class
class MenuCategory(object):
def __init__(self, menu_data={}, parent=None):
self.menu_data = menu_data
self.subcategories = []
self.products = []
s... | true |
c130354ee43b3163f064b279de39547052a47b4f | Python | sunivers/Study__Algorithm | /Section_05/15. 경로탐색/aa.py | UTF-8 | 670 | 3.203125 | 3 | [] | no_license | import sys
sys.stdin = open("in1.txt", "r")
# 방향그래프이기 때문에 자기자신보다 작은 숫자의 정점이라도 갈 수 있다.
n, m = map(int, input().split())
g = [[0] * (n + 1) for _ in range(n + 1)]
ch = [0] * (n + 1)
path = []
cnt = 0
for _ in range(m):
x, y = map(int, input().split())
g[x][y] = 1
def DFS(v):
global cnt
if v == n:
cnt += ... | true |
fff04847f1709144ee39b24e76f51d564b13c530 | Python | gandrel31/DjangoWebProject1 | /DjangoWebProject1/app/forms.py | UTF-8 | 2,260 | 2.71875 | 3 | [] | no_license | """
Definition of forms.
"""
from django import forms
from django.contrib.auth.forms import AuthenticationForm
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django import forms
from django.core.exceptions ... | true |
b439b90d94c1f5e8668dd684fa9388d670bd7aa6 | Python | GIA-USB/recoge-latas | /detectarLata.py | UTF-8 | 8,122 | 2.921875 | 3 | [] | no_license | # Deteccion de formas
# import the necessary packages
import numpy as np
import argparse
import cv2
import imutils
global boxmax
boxmax = -1
global boxmin
boxmin = 10000000
global maximo
maximo = -1
global minimo
minimo = 10000000000
##--------------------------------------------------------------##
# Funcion que per... | true |
3dc39f809427b85487c43dad707428ffa1e155b6 | Python | Dhrumil-Zion/Competitive-Programming-Basics | /Hackerrank/The_Time_in_Words.py | UTF-8 | 1,107 | 3.3125 | 3 | [] | no_license | def timeInWords(h, m):
li_hr = ["","one","two","three","four","five","six",
"seven","eight","nine","ten","eleven","twelev"]
lis_min = ["o' clock","one","two","three","four","five","six","seven","eight","nine", "ten","eleven", "twelve", "thirteen", "fourteen", "quarter", "sixteen", ... | true |
3e98e1d7938bca4dc333308aba5def1cbc1cb0ae | Python | luokeychen/blog | /utils/helper.py | UTF-8 | 2,115 | 2.953125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# __author__ = chenchiyuan
from __future__ import division, unicode_literals, print_function
import markdown
from bs4 import BeautifulSoup
class HtmlFormatter(object):
@classmethod
def format_html(self, html):
html = self.format_table(html)
return html
@classmetho... | true |
374148f3dc413f2b9b23a7d893b85652b722dfcf | Python | yugenechen/SAMS-Python-24hr-Training | /Lucky.py | UTF-8 | 472 | 2.734375 | 3 | [] | no_license | """Python_Sams20, p 221, Developing for the Web with Flask \
# Ch 20 Course Training excercise
print("Open a URL and type in http://127.0.0.1:5000")
"""
import os
from flask import Flask, render_template
app = Flask(__name__)
@app.route("/")
def lucky():
# return render_template("C:/Users/Lifygen/projects/... | true |
8957f93dc3da6bcbfcee1ccc78240dbb72d189b6 | Python | Minku-Koo/simple_shopping_mall | /order/models.py | UTF-8 | 12,996 | 2.671875 | 3 | [] | no_license | from django.db import models
from django.core.validators import MinValueValidator, MaxValueValidator
from coupon.models import Coupon
from shop.models import Product
class Order(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
email = models.EmailFiel... | true |
fe7b953394a1962e488c7e9c6d4584e970cad6e6 | Python | davidmashburn/columnar_records | /columnar_records/columnar_records.py | UTF-8 | 16,134 | 2.734375 | 3 | [] | no_license | """Columnar records is a datastructure that contains a named list of array
It will eventually support all the same concepts as a record array or
data frame, but should hopefully be easier to reason about and more efficient
At it's root, it only needs two pieces of data:
a list of arrays and a list of names
In fact, y... | true |
3a5b3dcdd17fab60065c21994f82490717bb4fb2 | Python | LipinskiyL0/model_prognoz_volume_actual | /get_period_elast_correction.py | UTF-8 | 6,803 | 2.90625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu Jun 24 00:19:43 2021
трансформатор данных при погнозировани спроса при управлении запасом
Является новой версией файла get_period.py
В отличии от предудущей версии тут происходит коррекция данных на основании информации о скидках
Рассчитывается модель эластичности, которая вы... | true |
2b4091fb6f2f2629e91ba86198fade4fb057050e | Python | oscar-coin/twitter-stream | /src/twitter_stream.py | UTF-8 | 1,915 | 2.65625 | 3 | [] | no_license | import argparse
import stream
import mongo
def main():
args = parse_args()
db = mongo.get_mongo_database_with_auth(args.dbhost, args.dbport, args.dbname, args.username, args.password)
year = int(args.phrase_year)
query = db[args.phrase_collection].find({'year': year})
titles = []
for cursor i... | true |
1ed311a41745857483992986f4090f768eb22d04 | Python | Aasthaengg/IBMdataset | /Python_codes/p03263/s058841671.py | UTF-8 | 882 | 2.921875 | 3 | [] | no_license | H,W = map(int, input().split())
a = [[int(i) for i in input().split()] for _ in range(H)]
move = []
for i in range(H):
if i % 2 == 0:
for j in range(W):
if a[i][j] % 2 == 1:
if j == W - 1 and i < H - 1:
move.append((i+1,j+1,i+2,j+1))
a[i][... | true |
f817cf1ac4ab6cc0d50406d212b404bd94fe941d | Python | myusko/algosproblems | /algos/arrays/find_maximum.py | UTF-8 | 291 | 3.484375 | 3 | [] | no_license | def find_maximum(arr):
max_value = arr[0]
min_value = arr[0]
for x in range(len(arr) - 1):
if max_value < arr[x + 1]:
max_value = arr[x + 1]
if min_value > arr[x + 1]:
min_value = arr[x + 1]
return '{} {}'.format(max_value, min_value)
| true |
f4df6b8160b7980e06f02e9c016592b791895f9d | Python | kevintandean/fin | /fin/HelpText.py | UTF-8 | 1,975 | 2.859375 | 3 | [
"MIT"
] | permissive | from fin.Config import Config
CLINAME = "fin"
class HelpText(object):
def __init__(self):
self.text = ""
self.usage_list=[]
self.options = ""
def create_usage(self):
text = "usage: \n"
for item in self.usage_list:
text += ' ' + item + '\n'
return t... | true |
8bbd7cf629e55bf5ed6f9ea1752f19baaebbd25d | Python | harshmalik9423/SeleniumPractice | /Data driven testing/readExcel.py | UTF-8 | 486 | 3.21875 | 3 | [] | no_license | import openpyxl
path = r"C:\Users\harsh\Desktop\test.xlsx" # r for reading as raw string
workbook = openpyxl.load_workbook(path)
# sheet = workbook.get_sheet_by_name("Sheet1") # Extracts by name
sheet = workbook.active # extracts active sheet
print("Rows = ", sheet.max_row)
print("Columns = ", shee... | true |
3d791b38a80312e26e336b31173b3f9a63dc63a5 | Python | athena15/leetcode | /remove_duplicates_from_sorted_array.py | UTF-8 | 421 | 3.515625 | 4 | [] | no_license | # https://leetcode.com/problems/remove-duplicates-from-sorted-array/
class Solution:
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
unique_nums = set()
i = 0
while i < len(nums):
if nums[i] in unique_nums:
del nums[i]
else:
unique_nums.add(nums[i])
i += 1
... | true |
493e93156dad1e38e7af1ca81ac79b41fe2fe7b3 | Python | alexkie007/offer | /Target Offer/39. 数组中出现次数超过一半的数字.py | UTF-8 | 697 | 4.0625 | 4 | [] | no_license | '''
数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字。
例如输入一个长度为9的数组{1,2,3,2,2,2,5,4,2}。
由于数字2在数组中出现了5次,超过数组长度的一半,因此输出2。如果不存在则输出0。
'''
class Solution:
def MoreThanHalfNum_Solution(self, numbers):
dict = {}
length = len(numbers)
for i in numbers:
if dict.get(i):
dict[i] = dict[i] +... | true |
c5a71e90c7d3969d4641c863ccc7ecdd5e3b8409 | Python | philippwindischhofer/FastProp | /Analysis.py | UTF-8 | 741 | 3.65625 | 4 | [] | no_license | import functools
class Analysis:
def __init__(self, name):
self.name = name
self.morphisms = [] # need to apply them in the correct order!
def add_morphisms(self, morphs):
for morph in morphs:
self.add_morphism(morph)
def add_morphism(self, morph):
sel... | true |
ce880deda289b186ccf573dcd3c52fcf662c025b | Python | dinobobo/Leetcode-HackerRank | /validate_BST_98.py | UTF-8 | 2,007 | 3.71875 | 4 | [] | no_license | class Node:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
# class Solution:
# def isValidBST(self, root):
# return self.valid_limits(root, -float('inf'), float('inf'))
# def valid_limits(self, root, lo... | true |
a6512faeff7ffe761a031dae0a903a001533d831 | Python | p4-team/ctf | /2017-12-09-seccon-quals/crypto_vigenere/vigenere.py | UTF-8 | 1,611 | 2.984375 | 3 | [] | no_license | s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz_{}"
def _l(idx, s):
return s[idx:] + s[:idx]
def decrypt(ct, k1, k2):
s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz_{}"
t = [[_l((i + j) % len(s), s) for j in range(len(s))] for i in range(len(s))]
i1 = 0
i... | true |
af2e648f88fd2b312d4c11595b29e7aab9c0fb06 | Python | PunithaRaniSimha/areaofcircle | /area.py | UTF-8 | 102 | 3.609375 | 4 | [] | no_license | import math
r=float(input("enter the radius of circle"))
A=math.pi*r**2
print("area of the circle",A)
| true |
4c8e445685552a8b5cc9bef3b51883cafa67b2a0 | Python | zopefoundation/Products.GenericSetup | /src/Products/GenericSetup/tests/test_content.py | UTF-8 | 34,527 | 2.515625 | 3 | [
"ZPL-2.1"
] | permissive | ##############################################################################
#
# Copyright (c) 2005 Zope Foundation and Contributors.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS I... | true |
0dece898fa1c30f26b9f2170ba7630a8cc88e8db | Python | sebastiaoLa/sqliteORM | /fields.py | UTF-8 | 5,537 | 2.890625 | 3 | [] | no_license | #coding:utf8
import sqliteClient
import uuid
import md5
class User():
def __init__(self,nome,login,pwd,admin,id = None):
if id:
self.id = id
else:
self.id = uuid.uuid4()
self.nome = nome
self.login = login
if id:
self.pwd = pwd
el... | true |
3f6bca095d2d1a63fc35c784ce96c43b6a20357c | Python | nixonpj/leetcode | /Product of Array Except Self.py | UTF-8 | 775 | 3.609375 | 4 | [] | no_license | """
Given an integer array nums, return an array answer such that answer[i] is equal
to the product of all the elements of nums except nums[i].
The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer.
"""
from typing import List
class Solution:
def productExceptSelf(self, nums: List[... | true |
49e1038379acb2aa2692b042c83b75b595b03280 | Python | caiolv/ceub_projeto_final_disciplina_str | /algoritmos_python/RR.py | UTF-8 | 3,650 | 3.59375 | 4 | [] | no_license | # ROUND-ROBIN
def round_robin(processos, quantum, qnt_processos):
# Criando uma lista de Burst Time restante dos processos
bt_restante = [0] * qnt_processos
# Criando uma lista de Waiting Time
wt = [0] * qnt_processos
# Copiando BurstTime dos processos para o bt_restante
for i in range(qnt_proce... | true |
d8f90b6ea40904ff431504660edd79b7558f8d14 | Python | Aurora-yuan/Leetcode_Python3 | /0122 买卖股票的最佳时机(2)/0122 买卖股票的最佳时机(2).py | UTF-8 | 2,665 | 3.875 | 4 | [] | no_license | #label: dynamic programming difficulty: easy
"""
第一种思路:
不限制买卖次数,要求算最大利润,
根据贪心的思想:那么能赚钱就买卖啊,
举例:对于输入[7,1,5,3,6,4], 已经提前知道了所有第 i 天,股票的价格 price[i] ,
那么先持有7,发现第二天价格会跌,就卖掉手上的价格为7的股票,转而等到第二天买价格为1的股票,
到第三天,发现价格涨了,可以赚四块钱,果断卖掉盈利,同时买入当天的价格为5的股票,
发现第四天价格又跌到了3,于是把价格为5的股票抛出,转而等到第四天买入价格为3的股票,
第五天,能赚三块,卖掉盈利,然后持有价格为6的股票 ,
发现第... | true |
3398fa2ebb650ef0f663c413526bb25b936612d1 | Python | jerrylizilong/python-selenium-demo | /demo3_pytest_version/test_convert_md5.py | UTF-8 | 741 | 2.796875 | 3 | [] | no_license | import unittest
from demo3_pytest_version import convert_md5
class MyTestCase(unittest.TestCase):
def test_letters(self):
keyw = 'abcdD'
self.assertEqual(convert_md5.convert_md5().md5(keyw),convert_md5.convert_md5().md52(keyw) )
def test_numbers(self):
keyw = '1234'
self.asser... | true |
14588765a0b3bb68ebfc7a789f6d5dbc2a820460 | Python | stonewell/code-snippets | /iphone_backup_photo_norm/photo_norm.py | UTF-8 | 1,223 | 2.640625 | 3 | [] | no_license | import sys
import pathlib
import hashlib
import subprocess
from collections import deque
BUILTIN_IGNORE = set(
['.git', '.svn', 'CVS', '.hg', '.gitignore', '__pycache__', '.MISC'])
def walk_directory(path):
children = deque([path])
while len(children) > 0:
cur_entry = children.popleft()
for child ... | true |
38d8d3e172b5a9a38eecd6840d503f3dc1904939 | Python | Alexzhoucs/pythonCourse-Liuzhen | /20190331LZCourse.py | UTF-8 | 619 | 3.765625 | 4 | [] | no_license | # 函数
print("---------------函数")
def multi(x, y):
return x ** y
print(multi(3, 2))
def multi1(x, y=2):
return x ** y
print(multi1(3))
print(multi1(3, 3))
print(multi1(y=3, x=2))
def multi2(x, y=2):
return x ** y, x, y
a, b, c = multi2(3)
print(type(a))
print(a)
a = multi2(3)
print(type(a))
print(... | true |
625c1254cc6493ed852803babbb495adc2e3dfd4 | Python | lzj322/leetcode | /House_Robber.py | UTF-8 | 638 | 3.234375 | 3 | [] | no_license | 'LeetCode 198 House Robber'
class Solution(object):
def rob(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if not nums:
return 0
depo=[0]*(len(nums)+1)
# depo=[0,nums[0]]
depo[1]=nums[0]
# for i,item in enumerate... | true |
a080e29e119c752296afcb5aa33b023628e80980 | Python | caltechlibrary/acacia | /run-server | UTF-8 | 13,643 | 2.625 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env python3
# ==========================================================================
# @file run-server
# @brief Wrapper around mod_wsgi-express to start Acacia server for testing
# @created 2021-01-12
# @license Please see the file named LICENSE in the project directory
# @website https://github.co... | true |
4d1aae22ad4faff9169cacc1a7873515ea6ca0d1 | Python | sebasoba/P97fixed | /guessingGame.py | UTF-8 | 510 | 4.40625 | 4 | [] | no_license | import random
print("number guessing game")
number=random.randint(1,9)
chances=0
print("guess a number (between 1 and 9):")
while chances < 5:
guess=int(input("Enter your guess:-"))
if guess == number :
print("Congratulation You won!!")
break
elif guess < number:
print("Your guess was too low:gue... | true |
0711bb1df3622a11d6319102db84262af850ecc9 | Python | jagannath/imageAnalysis | /beadAnalysis/linePlots.py | UTF-8 | 4,260 | 2.6875 | 3 | [] | no_license |
######### LINE PLOTTING FUNCTION ######################
def plot_LineIntensity(circles,imageDir,subDir):
# Note = For accesing the images, the coordinates are read as (y,x) [rows
# and cols]
def __plotCircle(cChoice,cCoords):
cCoords = circles[0][cChoice]
print cChoice,nbrCircles
... | true |
4034e1c5e509b770d7f3269ea95b5bb43b751a5f | Python | EmilianStankov/HackBulgaria | /week0/problem 29 - simplify_fraction/solution.py | UTF-8 | 1,003 | 3.390625 | 3 | [] | no_license | def is_prime(n):
if n < 0:
n = abs(n)
if n == 1:
isPrime = False
if n == 2:
isPrime = True
for i in range(1, n + 1):
if i != 1 and i != n:
if n % i == 0:
isPrime = False
break
else:
isPrime = True
... | true |
60dd69ab2ecb9d6bff428ac7ad88a47acda68f48 | Python | dankeyy/Advent-of-Code-2020 | /day05/solve5.py | UTF-8 | 1,029 | 3.421875 | 3 | [] | no_license |
def id_getter(bpfile = 'inp.txt'):
lower = lambda l: l[: len(l) // 2]
upper = lambda l: l[ len(l) // 2 :]
narrow = { 'F' : lower, 'B' : upper, 'L' : lower, 'R' : upper }
row, column = [ *range(128) ], [ *range(8) ]
with open (bpfile) as boarding_passes:
for bp in boarding_passes: ... | true |
a3499d1645294e77281b3cda32395691dc16bad4 | Python | MadhuraSS/cmpe295-project | /Scripts/parser-scripts/combine_json.py | UTF-8 | 1,418 | 2.9375 | 3 | [] | no_license | import json
import time
t0 = time.time()
DISEASES_DICT = {}
def processJson(jsonData):
for x in jsonData["diseases"]:
disease_name = str(x["disease"].encode('utf-8'))
symptoms = x["symptoms"]
disease_set = set()
for s in symptoms:
sym = str(s.encode('utf-8'))
disease_set.add(sym)
if disease_name in D... | true |
e732775163fff3263744a8becd442d559cc015fc | Python | jaivrat/python_codes | /ml-python/nlp_lda_topicModelling/ldaModel.py | UTF-8 | 3,165 | 3.46875 | 3 | [] | no_license | ### Taken from https://media.readthedocs.org/pdf/gensim/stable/gensim.pdf
import logging
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s',level=logging.INFO)
### From Strings to Vectors
from gensim import corpora, models, similarities
documents = ["Human machine interface for lab abc compute... | true |
c972158a020106c50b20d32ddff8a836652b714c | Python | AidaQ27/python_katas_training | /loops/exes_and_ohs.py | UTF-8 | 1,022 | 4.5 | 4 | [] | no_license | """
Check to see if a string has the same amount of 'x's and 'o's.
The method must return a boolean and be case insensitive.
The string can contain any char.
Examples input/output:
XO("ooxx") => true
XO("xooxx") => false
XO("ooxXm") => true
XO("zpzpzpp") => true // when no 'x' and 'o' is present should return true
XO... | true |
fb3514b1daf6441db2c55b420c4812fb93464215 | Python | lgope/python-world | /oop/classObjExample.py | UTF-8 | 258 | 3.515625 | 4 | [] | no_license | class Person:
def __init__(self, name, email):
self.name = name
self.email = email
def showInfoFunc(self):
print(f"Name: {self.name}\nEmail: {self.email}")
personObj = Person("Lakshman", "email@example.com")
personObj.showInfoFunc()
| true |
2def44e0911f1a3f94c24603ec453eb9b214bdb9 | Python | GomesMilla/TreinaWeb | /ediaristas/api/pagination/diaristas_cidade_pagination.py | UTF-8 | 972 | 2.703125 | 3 | [] | no_license | from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
class DiaristaCidadePagination(PageNumberPagination):
page_size = 6
# O page_size mostra a quantidade de valores que deve ser mostrado inicialmente, ou seja,
# se tiver 50 resposta ele vai mostrar os sei... | true |
ff4122dc73ee2953f6555edced86b99da53349cb | Python | TheNizzo/hackathon-epita | /approaches_testing/read_pics.py | UTF-8 | 2,612 | 2.78125 | 3 | [] | no_license | """
Script python pour ouvrir les fichiers de traces de clavier
"""
from pdb import set_trace
import matplotlib.pyplot as plt
import numpy as np
from sklearn.linear_model import LinearRegression
import time
import itertools
from scipy.signal import find_peaks
import seaborn as sns
from scipy.fft import fft
def read_... | true |
046a72253fba2a1ac952d641c5dbc4aaf280349b | Python | AnesBenmerzoug/Machine-Learning-Projects | /MNIST/main.py | UTF-8 | 2,152 | 2.578125 | 3 | [
"MIT"
] | permissive | import faulthandler
import time
import click
from pathlib import Path
from src import *
class Parameters:
image_size = [28, 28]
hidden_size = 64
output_size = 10
model_dir = Path("./trained_models/")
# Dataset Parameters
dataset_dir = Path("./data/")
num_workers = 2
# Training Paramet... | true |
eef0ffa02af300664838730a89f6242dc5db0425 | Python | MiguelEmmanuel46/BaseDeDatos | /contador.py | UTF-8 | 66 | 2.9375 | 3 | [] | no_license | i = 0
while i < 10:
print "Contador:"
print i
i= i+1
| true |
8ee11aaeb077b2f4db8527879f5a795b7e90fbf1 | Python | FrancisDinh/Smart-Energy-Project | /application/DemandSideNew/Building/Building.py | UTF-8 | 2,312 | 3.140625 | 3 | [
"MIT"
] | permissive | from Building.Device import Device
from Building.DemandProfile import DemandProfile
import numpy as np
class Building:
def __init__(self):
#Total energy need, including Uncontrollable Devices UD and Controllable Devices CED
self.E = np.zeros(24)
self.E_CED = np.zeros(24)
self.E_UD = ... | true |
3504e7532d5b49472fea68849a8dcfe1a8db9c5a | Python | xiaominwanglast/xml_csv | /csv_xml/easy_excel.py | UTF-8 | 606 | 2.59375 | 3 | [] | no_license | # coding=utf-8
import win32com.client
import os
class easy_excel:
def __init__(self, filename=None):
self.xlApp = win32com.client.Dispatch('Excel.Application')
if filename:
self.filename = filename
self.xlBook = self.xlApp.Workbooks.Open(self.filename)
else:
... | true |
a6d884ed6d0d00622832c740a91a874d659751d8 | Python | yys9905/computerAlgorithm | /InsertionSort.py | UTF-8 | 310 | 3.390625 | 3 | [] | no_license | def sort_process(arr):
for i in range(1, len(arr)):
point = i
a = arr[i]
while(a < arr[point-1] and point > 0):
arr[point] = arr[point-1]
point -= 1
arr[point] = a
return arr
arr = [64, 25, 12, 22, 11]
array = sort_process(arr)
print(array)
| true |
ca11b5fa2c3163188408ccd4e44c5c961cd849f0 | Python | alec-djinn/OnionChat | /nodotjs/chat.py | UTF-8 | 4,883 | 2.578125 | 3 | [] | no_license | import json
import time
import uuid
# REDIS KEYS
ROOMS = 'rooms'
USERS = 'users'
MESSAGES = 'messages'
IP = 'ip'
TIMESTAMP = 'timestamp'
SECRET= 'secret'
# JSON KEYS
ID = 'id'
USER = 'user'
NAME = 'name'
MESSAGE = 'message'
TIME = 'time'
LENGTH = 'length'
def path(key, *path):
"""
Generate a path for redis.
... | true |
c47e4881496514b44e75be0bb103c004fed9a640 | Python | wesselb/lab | /lab/shape.py | UTF-8 | 4,030 | 2.84375 | 3 | [
"MIT"
] | permissive | from functools import wraps
from plum import Dispatcher
from . import B, dispatch
__all__ = ["Shape", "Dimension", "unwrap_dimension", "dispatch_unwrap_dimensions"]
_dispatch = Dispatcher()
class Shape:
"""A shape.
Args:
*dims (number): Dimensions of the shape.
Attributes:
dims (tupl... | true |
5a8394d47e0e75989ac3abf7de05ddc9e7b36f51 | Python | miltonsarria/teaching | /basics/ex1.py | UTF-8 | 215 | 3.828125 | 4 | [
"MIT"
] | permissive | #Un programa simple que imprime diferentes mensajes en pantalla
print("Mary tiene una oveja,")
print("Su pelo era blanco como la nieve;")
print("Y todo lugar al que Mary iba,")
print("su oveja seguro tambien iba.")
| true |
65151f3e32459e036f4f60fcbd7951447bd5cb88 | Python | Nu2This/pybites | /105/slicing.py | UTF-8 | 1,891 | 4.625 | 5 | [] | no_license | from string import ascii_lowercase
text = """
One really nice feature of Python is polymorphism: using the same operation
on different types of objects.
Let's talk about an elegant feature: slicing.
You can use this on a string as well as a list for example
'pybites'[0:2] gives 'py'.
The first value is inclus... | true |
0e12d383acb3fa82e0c5ae9f7be3eec073880803 | Python | DanielJuravski/Bank | /GUI.py | UTF-8 | 11,561 | 3.046875 | 3 | [] | no_license | import os
import socket
import re
import cPickle
class ConsoleGUI:
def __init__(self):
global clear
clear = lambda: os.system('cls')
global numberOfBitsToRecv
numberOfBitsToRecv = 1024
self.dataArrey = list()
pass
def getDataArrey(self):
return self.data... | true |
31a3227abefdd1a542d66372dbbffd8e666d43e4 | Python | AntonyXXu/Learning | /Python practice/LeetCode/max_Binary_Tree.py | UTF-8 | 1,280 | 4.28125 | 4 | [] | no_license | # You are given an integer array nums with no duplicates.
# A maximum binary tree can be built recursively from nums using the following algorithm:
# Create a root node whose value is the maximum value in nums.
# Recursively build the left subtree on the subarray prefix to the left of the maximum value.
# Recursively... | true |
5a1fe976b12c2012531b0a5aec71c33c4744c5d1 | Python | NewtonFractal/Project-Euler-34 | /Project Euler #34.py | UTF-8 | 1,890 | 3.546875 | 4 | [] | no_license | import time
import math
Factorials = [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880]
Digit_Factorials = []
start = time.time()
def Digit_factorials_3digits(x, upper_bound):
while int(x) < upper_bound:
if str(x) == str(int(Factorials[int(x[0])]) + int(Factorials[int(x[1])]) + int(Factorials[int(... | true |
4875e867dadfc31aa126752f3804d8d094ae0bbf | Python | shaoqiming/PythonLesson | /day6/PIComplete.py | UTF-8 | 373 | 3.3125 | 3 | [] | no_license | # coding:UTF-8
from random import random
from math import sqrt
from time import clock
DARTS = 120000
hits = 0
clock()
for i in range(1, DARTS):
x, y = random(), random()
dist = sqrt(x**2 + y**2)
if dist <= 1.0:
hits = hits + 1
pi = 4 * ((hits*1.0)/DARTS)
print('PI的值是%s' % pi)
print((4.0/5))
pr... | true |
01571a491a6018f9702fba3d9f1774d598db1678 | Python | VladSemiletov/Methods-of-collecting-and-processing-data-from-the-Internet | /Lesson_3/Lesson_3_2.py | UTF-8 | 1,863 | 2.796875 | 3 | [] | no_license | from pymongo import MongoClient
client = MongoClient('127.0.0.1', 27017)
db = client['vacancies']
hh = db.hh
usd = 72.77
eur = 84.38
user_message = int(
input('Введите минимальную сумму заработной платы,которая вас устраивает: '))
def find_vacancies(database, message, USD=usd, EUR=eur):
print(f'Вакансии, за... | true |
c2891c2260120669168dd1770d086cdb643a0005 | Python | jnparry/machinelearning | /load_mpg.py | UTF-8 | 1,597 | 2.890625 | 3 | [] | no_license | from StringIO import StringIO
import numpy
import pandas as pd
import numpy as np
from sklearn import preprocessing
def load_mpg():
# read in files and add temp column
auto_mpg_file = pd.read_csv("auto_mpg_data.csv")
auto_mpg_file.columns = ['temp']
# reformat csv file
formatted_data = ""
fo... | true |
6197f518c94872fc53e4caf1949fbe162de39ebe | Python | kamyu104/LeetCode-Solutions | /Python/deepest-leaves-sum.py | UTF-8 | 507 | 3.3125 | 3 | [
"MIT"
] | permissive | # Time: O(n)
# Space: O(w)
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
def deepestLeavesSum(self, root):
"""
:type root: TreeNode
:rtype: int
... | true |
18f3095ffdb4db95d61d4d11e776c5a1a0d99557 | Python | alexandraback/datacollection | /solutions_2645486_0/Python/DayBit/B.py | UTF-8 | 981 | 2.875 | 3 | [] | no_license | '''
Created on 27/04/2013
@author: David
'''
def read_data(filename):
f=open(filename,'r')
T=int(f.readline().strip())
data = []
for _ in range(T):
E, R, N =(int(v) for v in f.readline().strip().split())
values = [int(v) for v in f.readline().strip().split()]
data.ap... | true |
043c50e44fdf9b210b49407d997d1d9bc1ea4c1e | Python | shoaibkamil/asp | /tools/debugger/gdb.py | UTF-8 | 2,580 | 2.78125 | 3 | [] | no_license | import subprocess
import re
class gdb(object):
def __init__(self, python_file, cpp_file, cpp_start_line):
self.process = subprocess.Popen(["PYTHONPATH=stencil:../.. gdb python"],shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE, cwd='.')
self.process.stdin.write("run " ... | true |
5f5ca01aac797e5edfdc6a5f46e88fd30f4c6662 | Python | carbondriller/planerecover | /eval/generate3D.py | UTF-8 | 4,601 | 2.515625 | 3 | [
"MIT"
] | permissive | import os
import numpy as np
import scipy.misc
import PIL.Image as pil
import cv2
'''
Generate 3D model from the input depth
@author -- Fengting Yang
@created time -- Mar.10 2018
@Usage:
1. Set TEST_LIST and all the DIR. Note for dir, a final '/' is required
2. Ensure a right intrinsics, resize it if resizing ... | true |
e403eca6028736236a54abb922bcdafa303fa8d6 | Python | MarcosFloresta/python-examples | /matrix_multiplication_using_nested_list_comprehension.py | UTF-8 | 336 | 3.796875 | 4 | [
"MIT"
] | permissive | # Program to multiply two matrices using list comprehension
# 3x3 matrix
X = [[12, 7, 3],
[4, 5, 6],
[7, 8, 9]]
# 3x4 matrix
Y = [[5, 8, 1, 2],
[6, 7, 3, 0],
[4, 5, 9, 1]]
# result is 3x4
result = [[sum(a*b for a, b in zip(X_row, Y_col))
for Y_col in zip(*Y)] for X_row in X]
for r in resu... | true |
23dd80e5d0cf2d28880e80cad044fa62c3d729ff | Python | daniel-reich/ubiquitous-fiesta | /Mb8KmicGqpP3zDcQ5_21.py | UTF-8 | 323 | 2.59375 | 3 | [] | no_license |
def josephus(n, k):
killed = []
alive = list([True]*n)
x, i = 0, 0
while len(killed) < n:
if alive[i]:
x += 1
if x == k:
alive[i] = False
killed.append(i+1)
x = 0
i += 1
if i == n:
i = 0
return killed[-1]
... | true |
d83706229ad7369609e6e59361fa5330f34429de | Python | maxkashyap41/pythonDSA | /String/Mars_Exploration.py | UTF-8 | 627 | 3.125 | 3 | [] | no_license | # input : SOSSPSSQSSOR
# SOSSOT
# SOSSOSSOS
# output : 3
# 1
# 0
# explanation : Expected signal: SOSSOSSOSSOS
# Recieved signal: SOSSPSSQSSOR
# Difference : X X X
def mars_exploration(string):
length = len(s... | true |
23033591c55ae0169027b1137f4b6bba977758fd | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_201/1577.py | UTF-8 | 749 | 2.84375 | 3 | [] | no_license | #!/usr/bin/env python
import sys
import heapq
#@profile
def solve(*args):
(N, K) = args
# trivia
if N == K:
return "0 0"
B = [-N]
heapq.heapify(B)
for k in xrange(K):
n = -heapq.heappop(B)
Ls = n/2
Rs = n - Ls - 1
if Ls > 0:
heapq.h... | true |
0d1ac613785934e481268e42df1be24315604b85 | Python | mjgpinheiro/pynosh | /tools/find_beautiful_states.py | UTF-8 | 8,204 | 2.59375 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
#
"""Solve the Ginzburg--Landau equation.
"""
import numpy as np
import meshplex
import krypy
import pynosh.numerical_methods as nm
import pynosh.modelevaluator_nls as gm
def _main():
args = _parse_input_arguments()
# read the mesh
print("Reading the mesh...")
mesh, _, _, _ ... | true |
c07e8eafcd0d8a060388f736fd8aa20373238c00 | Python | zonezoen/blog | /python/Python数据库骚操作/redis/m_redis.py | UTF-8 | 6,783 | 3.328125 | 3 | [] | no_license | import redis
import time
# 连接
# 普通连接
# r = redis.StrictRedis(host='localhost', port=6378, db=0)
# r = redis.StrictRedis(host='localhost', port=6378, password="your password", db=0)
print()
# 连接池
"""
redis-py使用connection pool来管理对一个redis server的所有连接,避免每次建立、释放连接的开销。默认,每个Redis实例都会维护一个自己的连接池。
可以直接建立一个连接池,然后作为参数Redis,这样就可以实... | true |
1f21a345bf3b6e53e064ea5f9d000b3accdd68a2 | Python | alexandrustanimir/puzzles | /ContactManagement/ContactManagement.py | UTF-8 | 2,824 | 3.203125 | 3 | [] | no_license | # Python distribution containing tools for working with MongoDB
# http://api.mongodb.org/python/current/tutorial.html
import pymongo
from pymongo import MongoClient
client = MongoClient('mongodb://localhost:27017/')
database = client['tb']
collection = database['contact']
historycollection = database['h_contact']
def ... | true |
86896fd0edfa6ad540a2fb64ddea062469a8d7a9 | Python | dazaiosamuzms/learn-note | /学习/爬虫/lianxi.py | UTF-8 | 198 | 3.359375 | 3 | [] | no_license | st = input()
lis = st.split(' ')
lis2 = []
lis3 = []
for i in lis:
lis2.append(i[0])
lis3.append(i[-1])
if lis2[1:] == lis3[:-1]:
print('YES')
else:
print('NO')
while True : pass
| true |
088abf1f4fcab4ee20c3a68fe7266fb99edfcb3b | Python | SimonCouv/zoe-data-prep | /processing/age_from_year_of_birth.py | UTF-8 | 1,445 | 2.703125 | 3 | [] | no_license | # Copyright 2020 KCL-BMEIS - King's College London
# 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 copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed... | true |
c9c97e67cebefacf0eaafabd0b3e28a435ee3ed3 | Python | qq763253009/Fluent-Python | /第五章一等函数/5-4.py | UTF-8 | 200 | 3.75 | 4 | [] | no_license | '''
高阶函数
'''
fruits = ['strawberry','apple','cherry','banana']
# 展示高阶函数sorted的使用
print (sorted(fruits,key=len))
'''
OUT:
['apple', 'cherry', 'banana', 'strawberry']
''' | true |
b361ada53f62bfa1fe1e07ae7c55ce45268a26d5 | Python | GazeProject05/PythonCode | /Code/NaiveBayes.py | UTF-8 | 19,717 | 2.6875 | 3 | [] | no_license | import pandas as pd
from sklearn.model_selection import train_test_split
from scipy.stats import multivariate_normal as mn
import math as m
import operator
import numpy as np
##---------------------------- import csv-------------------------------------------------------------##
def loadCSV(filename):
data = pd.re... | true |
5e377e88b9537560ef27eb89455f41c7a717c0fa | Python | estiben/BuildBot | /Buildbot_backup1.py | UTF-8 | 14,640 | 3.109375 | 3 | [] | no_license | #!/usr/bin/python
import pygame, sys, os
import math
import astar
import itertools
from pygame.locals import *
def load_image(name, colorkey=None):
fullname = os.path.join('data', name)
try:
image = pygame.image.load(fullname) #load a surface
except pygame.error, message:
print 'Cannot loa... | true |
94950a6b8fccbf85f1e76d8e14854b2f846146d6 | Python | jjashinsky/CS241 | /homework/proveHomework4.py | UTF-8 | 1,541 | 4.09375 | 4 | [] | no_license | from collections import deque
class Song:
def __init__(self):
self.title = deque()
self.artist = deque()
def add_at_end(self):
self.title.append(input("Enter the title: "))
self.artist.append(input("Enter the artist: "))
def add_at_beginning(self):
... | true |
dcefd0fdf798ee20dbac1ec8035c29e1c0d087b7 | Python | uvesten/geneprediction | /predictor.py | UTF-8 | 22,603 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env python3
import re
import fileinput
import functools
import textwrap
import argparse
import queue
import sys
import array
import numpy as np
import tempfile
import collections
import copy
from operator import itemgetter
from typing import List
from typing import Dict
__author__ = 'uvesten'
# definition... | true |
5a7e2b2117016a0f027e721fb401244d6602efa6 | Python | mtbannister/fundamentals | /fundamentals/mysql/sqlite2mysql.py | UTF-8 | 9,332 | 2.921875 | 3 | [
"MIT"
] | permissive | #!/usr/local/bin/python
# encoding: utf-8
"""
Take a sqlite database file and copy the tables within it to a MySQL database
Usage:
sqlite2mysql -s <pathToSettingsFile> <pathToSqliteDB> [<tablePrefix>]
Options:
pathToSqliteDB path to the sqlite database file
tablePrefix a string to prefix... | true |
77200c5283c99a3c17f3b013f6517f181832d0e9 | Python | mxnavid/Project-Euler | /Fibonacchi.py | UTF-8 | 890 | 3.984375 | 4 | [] | no_license | #Author: Mohammed Nafiuzzaman
"""Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum ... | true |
c7f027df4b5d4d4ccc4d931fc12757819c358082 | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_155/3054.py | UTF-8 | 722 | 2.921875 | 3 | [] | no_license |
with open("A-large.in") as input_file:
output_file = open("output.txt", "w")
skip = input_file.readline().strip()
for index, line in enumerate(input_file):
case_info = line.split()
max_shyness = int(case_info[0])
friends_needed = 0
audience = 0
for min_needed, shyn... | true |
837ac6ea7e6e83f93385a3dc79832827768a1aff | Python | MaksimSimanskiy/2.10 | /Individual2.py | UTF-8 | 865 | 3.671875 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Дано время забега на 100 метров студентами в виде ключ-значение,
найти минимальное время забега
стометровки и минимальный результат забега
"""
def shop(**keywords):
sum = 0
n = len(keywords)
min = keywords["Вася"]
for kw in keywords:
... | true |
046ceba002717271d192987a9964a00b2a690b40 | Python | Sue9/Leetcode | /Python Solutions/003 Longest Substring Without Repeating Characters.py | UTF-8 | 767 | 3.546875 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Fri Apr 12 10:53:01 2019
@author: Sue
003. Longest Substring Without Repeating Characters
"""
class Solution(object):
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
if (len(s) <= 1):
return len(s)
... | true |
17ce5226bd091123aa9b8d3330e227eeac3d3d4d | Python | satishp962/40-example-python-scripts | /23.py | UTF-8 | 1,035 | 3.671875 | 4 | [] | no_license | class Student:
def __init__(self, name, dept, marks):
self.name = name
self.dept = dept
self.marks = marks
def get_name(self):
return self.name
def get_Dept(self):
return self.dept
def get_marks(self):
return self.marks
def get_stu(self):
r... | true |
333383b0a1388ccf48aa0c494e57ba7d584a9aa2 | Python | Mozilla-GitHub-Standards/b5cdab03960ce7b497e9d58f440a676b7f7257695daa9bb679b32bb034f0cad8 | /marteau/node.py | UTF-8 | 590 | 2.84375 | 3 | [] | no_license | import json
class Node(object):
def __init__(self, **data):
self.name = data['name']
self.enabled = data.pop('enabled', True)
self.status = data.pop('status', 'idle')
self.owner = data.pop('owner', None)
self.metadata = dict(data)
def __getattr__(self, attr):
... | true |
c8814b9b2699af97fa9fbe16f0d020af7400a4f1 | Python | anuraga2/Coding-Problem-Solving | /Sorting/Merge Sorted Arrays.py | UTF-8 | 725 | 3.8125 | 4 | [] | no_license | # writing merge subroutine for two sorted arrays
arr1 = [10,15]
arr2 = [5,6,6,30,40]
def merge_sorted(arr1, arr2):
if len(arr1) == 0 and len(arr2) == 0:
return []
elif len(arr1) == 0:
return arr2
elif len(arr2) == 0:
return arr1
comb_arr = []
a = len(arr1)
b =... | true |
5e973e2ea3cb5813e114d5d0da2c0a4005a5f05c | Python | ko1keith/youtube_mp3_downloader | /GUI.py | UTF-8 | 3,343 | 3.15625 | 3 | [] | no_license | from tkinter import *
from tkinter.ttk import *
from Download import Download
import math
import os
class GUI(Frame):
def __init__(self, master=None):
self.urls = []
Frame.__init__(self, master, width=800, height=500)
self.master.title("Not Illegal Youtube Downloader")
self.master.... | true |
7961c003f35ac98adbedf309673bbe0f37a21a47 | Python | MurradA/pythontraining | /Challenges/P002.py | UTF-8 | 155 | 3.984375 | 4 | [] | no_license | fname = input("Enter your firstname: ").strip().title()
lname = input("Enter your lastname: ").strip().title()
print('Hello {0} {1}.'.format(fname, lname)) | true |
60126cd31e0716ff4389fa66640f5e30a9042ecf | Python | someshjaishwal/Machine-Learning | /Part 8 - Deep Learning/1_ann.py | UTF-8 | 2,271 | 3.4375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# artificial neural network
# basic libararies
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# import dataset
dataset = pd.read_csv('Churn_Modelling.csv')
X = dataset.iloc[:,3:13].values
y = dataset.iloc[:,13].values
### PART 1 - Preprocessing Dataset
# encoding cate... | true |
82bb7fce734ce43732cc89dc2e99b8d84f28a37e | Python | MennaEwas/Al-abakera | /Al-abakera.py | UTF-8 | 1,611 | 3.78125 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Al abakera scoring
consist of 2 teams each with 4 player
need to score each team and best player
"""
class AP:
def __init__(self):
self.team1 = {'Menna':0, 'Omar': 0, 'Shaza': 0, "Ahmed": 0}
self.team2 = {'Mona':0, 'Amr': 0, 'Shimaa': 0, "Ali": 0}
#self.best = ' ... | true |
1ff26da4a68f1b2867bba0ea14164fdb43033af1 | Python | Yangliang95/VSE | /tools/video2img.py | UTF-8 | 2,705 | 2.53125 | 3 | [] | no_license | import os
import cv2
from PIL import Image
from tqdm import tqdm,trange
import imageio
import os.path as osp
def video2img(sp,dp):
""" 将视频转换成图片
sp: 视频路径 """
cap = cv2.VideoCapture(sp)
suc = cap.isOpened() # 是否成功打开
frame_count = 0 #-1
while suc:
frame_count += 1
suc, frame... | true |
cdd553a7774fffd81d32aef5023909c417bc389c | Python | Bhoomika73/Interview_Preparation | /Session 3/ReverseWords.py | UTF-8 | 207 | 3.6875 | 4 | [] | no_license | #Link: https://practice.geeksforgeeks.org/problems/reverse-words-in-a-given-string/0
t = int(input())
for i in range(0,t):
S = input()
L = S.split('.')
L = L[::-1]
print(*L,sep=".") | true |
18eb9b92fd471f03b0d1f7ec9bd42d30d16ad5f4 | Python | cdzm5211314/PythonFullStack | /01.PythonDoc/04.变量-函数-返回值-参数/20.递归函数-计算阶乘案例.py | UTF-8 | 697 | 4.4375 | 4 | [] | no_license | # -*- coding:utf-8 -*-
# @Desc:
# @Author: Administrator
# @Date: 2018-04-29 13:23
### 递归函数:
# - 在函数内部调用自己本身
# - 递归函数本质上是一个函数的循环调用,注意:有可能出现死循环
# - 一定要定义递归的边界(什么时候退出循环)
### 练习:计算阶乘 n! = 1 * 2 * 3 * 4 * 5 * ... * n
"""
1! = 1
2! = 2 * 1 = 2 * 1!
3! = 3 * 2 * 1 = 3 * 2!
4! = 4 * 3 * 2 * 1 = 4 * 3!
...
n! = n * (n-1)!
"... | true |
2e8fdc1653137f9213e641eacb33d98efb82e488 | Python | mirvn/capstone | /recent_earthquakes/recent_earthquakes.py | UTF-8 | 2,914 | 2.546875 | 3 | [] | no_license | import requests
from bs4 import BeautifulSoup
from google.cloud import storage
from google.cloud import firestore
import os
import time
def read_earthquake():
try:
r = requests.get('https://www.bmkg.go.id/gempabumi/gempabumi-terkini.bmkg')
if r.status_code == 200:
soup = Be... | true |
fc5f4c8fbf3275f2f1e89c70a0f4e9514bd9d011 | Python | Sukrant/Ishu | /admin-task/hostname.py | UTF-8 | 3,882 | 3.21875 | 3 | [] | no_license | #!/data/conda/bin/python
import subprocess as sp
import os
import sys
os_dis,os_maj = None,None
''' This used to change hostname Os Linux machine
Capable of change hostname on Ubuntu/Redhat(5,6,7,8)/CentOS(5,6,7,8)
This is depend on two files to know Machine details
1. /etc/redhat-release
... | true |
ab40b5a909d3299799956092f89a20df273c4093 | Python | ram326798/Python_coding | /Day-2/json-dump-load.py | UTF-8 | 910 | 3.546875 | 4 | [] | no_license | # import json
# data = {
# "president": {
# "name": "Zaphod Beeblebrox",
# "species": "Betelgeusian"
# }
# }
# # serialisation
# with open("data_file.json", "w") as write_file:
# json.dump(data, write_file)
# # Note that dump() takes two positional arguments: (1) the data o... | true |
ef585e5230182246c9eb62eb56afa04c601dd63d | Python | nismod/water_demand | /water_demand/__init__.py | UTF-8 | 785 | 2.59375 | 3 | [
"MIT"
] | permissive | #
# Root of the water_supply module.
# Provides access to all shared functionality.
#
def get_version():
""" Read version number from water_demand/version """
import os.path
root = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(root, 'version'), 'r') as f:
return f.read().st... | true |
26b6651b6dac14e7169c5f299ed6efe03e2ec3b0 | Python | sannpeterson/TumorSTOppy | /tumorstoppy/data/data_filter.py | UTF-8 | 812 | 3.515625 | 4 | [
"MIT"
] | permissive | # Constants
range_of_strings = 30
# Loads the data from a file and outputs it into corresponding directory
print("Input the desired file for processing:")
file_name = input()
# Input file and data
f = open(file_name+".txt","r")
strings_list = f.read().split("\n")
f.close()
# Locations for the strings that will be ... | true |
cdef24f606353d3a9e7da27c5ca0b9a3f8841a4d | Python | utk1801/Sentence-Representation-using-DAN-and-GRU | /sequence_to_vector.py | UTF-8 | 6,568 | 3.046875 | 3 | [] | no_license | # std lib imports
from typing import Dict
# external libs
import tensorflow as tf
from tensorflow.keras import layers, models
class SequenceToVector(models.Model):
"""
It is an abstract class defining SequenceToVector enocoder
abstraction. To build you own SequenceToVector encoder, subclass
this.
... | true |
5ee3c4cff3a4c92b08659e64791966f91f89d928 | Python | GeoffEvans/python_stuff | /algorithms/data_structures/linked_list.py | UTF-8 | 890 | 3.796875 | 4 | [] | no_license |
class SinglyLinkedList(object):
def __init__(self):
self.list = None
def append(self, value):
self.list = [value, self.list]
def get(self, index):
elem = self.list
for n in range(index):
elem = elem[1]
return elem[0]
class DoublyLinkedList(object):
... | true |