blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
ea5783ee945864fdec93a2eb6f0068a2307dbd88
bashby2/python_fundamentals
/python_fundamentals/odd_even.py
333
4.46875
4
# Create a function that counts from 1 to 2000. As it loops through each number, have your program generate the number and specify whether it's an odd or even number. for i in range (1, 2001): if i % 2 != 0: print "Number is {}. The number is odd".format(i) else: print "Number is {}. The number is even...
10784b07f768e6be23990a77ed9830e051b14406
mcwhmm/Introduction_to_Algorithms
/chapter 2/selection sort E-2.2-2.py
570
3.671875
4
# -*- coding: utf-8 -*-: import random def selectionSort(x): if type(x) == int: x = list(str(x)) for n in range(len(x)-1): current_val = x[n] i = n min = n while i < len(x)-1: if x[min] > x[i + 1]: min = i + 1 i += 1 x[n]...
d4c91840dbbace778df4a5c2851e9ac8dd50b9b3
nicholaspetru/ADTeach
/archive/tokenizer.py
1,789
3.90625
4
''' This is a tokenizer in python for the language Racket We will make this accept our language later... ''' from linkedlist import checkType def tokenize(expression): expression += " " tokenList = [] temp = "" stringFlag = False for i in range(len(expression)): if expression[i] == '('...
58e7b32475c36f868b2d08e6d5eab2900514174b
iceljc/Explainable-AI-LSTM
/test.py
99
3.546875
4
import numpy as np x = np.array([1,2,3]) y = np.array([4,5,6]) for i,j in zip(x, y): print(i, j)
9de39812dfee79e606eede201bdbbf5174d982e7
patorseing/10_Day_of_Statistics
/Day_7_Spearman_s_Rank_Correlation_Coefficient/Solution_py/Solution.py
442
3.53125
4
def getRank(X, n): rank = dict((x, i+1) for i, x in enumerate(sorted(set(X)))) return [rank[x] for x in X] def rxy(n, X, Y): rx = getRank(X, n) ry = getRank(Y, n) d = [(rx[i] -ry[i])**2 for i in range(n)] return round(1 - (6 * sum(d)) / (n * (n*n - 1)), 3) if __name__ == "__main__": n = int(input(...
f2cdb4598da3aa7c88a4aa8243cc19b96de2d199
madhumithaasaravanan/madhumitha5
/b104.py
98
3.8125
4
n=int(input("enter the number:")) k=int(input("enter the number:")) res=int(pow(n,k)); print(res)
2bf0a9f57235edce1effd7cf0b71a91d8535016c
wwken/Misc_programs
/leetcode/wildcard-matching/test_wildcard-matching.py
5,227
4.09375
4
import unittest from Solution import Solution # Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'. # # '?' Matches any single character. # '*' Matches any sequence of characters (including the empty sequence). # The matching should cover the entire input stri...
b8e41431f1f499c8a998cb1967070db73347b21c
Strokov/PyRuletka
/ucheba.py
1,899
3.625
4
# coding: utf-8 # комментарий import sys import math import datetime import os import psutil import shutil def Info_sys(): print('Вот, что я знаю о системе:') print("Operating System: ", sys.platform) print("Count of processes: ", psutil.cpu_count()) print("Текущая директория: ",os.getcwd()) print ...
f57a9b529348d90ffaa09d873c2c077d20da1ea1
yhytoto12/advent-of-code
/2021/DAY12/main.py
1,435
3.5
4
from itertools import count import numpy as np import networkx as nx G = nx.Graph() S = 'start' T = 'end' with open('input.txt', 'r') as f: lines = f.readlines() edges = [line[:-1].split('-') for line in lines] G.add_edges_from(edges) def countPath1(curr, visited): if curr == T: return 1 ...
f0a9c4fa420573bc7ace1cfd871f955d8b95b36a
chiache1999/1st-PyCrawlerMarathon
/hw1.py
1,769
3.703125
4
#簡答題 '''檔案、API、爬蟲的不同: 1. 檔案資料會包成檔案提供下載,格式可能包含常⽤用的標準格式,例例如「CSV」、「JSON」等等通⽤用的格式。 2. 開放接口(API)提供程式化的連接的接口,讓工程師/分析師可以選擇資料中要讀取的特定部分,⽽而不需要把整批資料事先完整下載回來 3. 網頁爬蟲資料沒有以檔案或 API 提供,但出現在網⾴頁上。可以利用爬蟲程式,將網頁的資料解析所需的部分。 前兩者是資料擁有者主動提供,後者則是被動''' #實作 #根據需求引入正確的Libary from urllib.request import urlretrieve import os,sys #下載檔案到...
c35ec8df64c057205fcc78430c9a247cc707ffa7
devchoplife/DataScience-Python
/src/corrstats.py
375
3.84375
4
import pandas as pd #we want to lool at the correlation between horsepower and car price #Scipy is used for this purpose pearson_coef, pvalue = stats.pearsonr(df["horsepower", df["price"]]) #the result will be the correlation coefficient and the p value #We can also create a correlation heatmap plt.pcolor (pearso...
fac6f49684d612f887e06801b5c0fc42b4aad6eb
Saber-f/code
/other/实验报告/NCM/Least_squares.py
2,492
3.640625
4
# 最小二乘法,矩阵及平方和解 from numpy import * from sympy import * x = symbols('x') # 获取数据 def get_data(): E = input("请输入表达式::").split() i = 0 while i < len(E): E[i] = eval(E[i]) i += 1 X = input("请输入x::").split() i = 0 while i < len(X): X[i] = eval(X[i]) i += 1 while ...
2a04510c95a39effef766fa96a87524643ce5bfe
andrzeji-oss/kursp
/dzien3/dzien3_3.py
736
3.5
4
# wygeneruj 100 elementową tablice z randomowymi wartościami 1-100 # utwórz listę wartości import random randomList = [] count = 0 liczba = int(input("Podaj liczbę z zakresu 1-10:" )) for i in range(100): randomList.append(random.randint(1,10)) print(randomList) if(liczba not in randomList): print("Elemen...
9e07b525252b053cc540144f7df16ef52fbdb92e
menard-noe/LeetCode
/Maximum Depth of N-ary Tree.py
889
3.78125
4
# Definition for a binary tree node. import math class Node: def __init__(self, val=None, children=None): self.val = val self.children = children class Solution: def maxDepth(self, root: 'Node') -> int: if root is None: return 0 def util(node: Node) -> int: ...
69fd86cf88f26831c549d7919adcde0c3d907c02
juliovt-07/FechamentoDeConta
/main.py
2,391
3.640625
4
import time escolha = 1 cont = 0 v = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] while escolha == 1: print("[codigo] nome") print("[ 10 ] Produto 1") print("[ 11 ] Produto 2") print("[ 12 ] Produto 3") print("[ 13 ] Produto 4") print("[ 14 ] Produto 5") print("[ 15 ] Produto 6") codig...
b3d5210421adaec5a6b3b6fe688728d5db23f9d1
ezequiasOR/Exercicios-LP1
/unidade8/cocktail_sort.py
709
3.71875
4
#coding: utf-8 #UFCG - Programação I - 2018.1 #Aluno: Ezequias Rocha #Questão: Cocktail Sort - Unidade 8 lista = [3, 4, 2, 0, 5, 6, 7,1] def cocktailSort(lista): lista_saida = [] lista_aux = [] lista_aux += lista lista_saida.append(lista_aux) trocou = True while trocou: trocou = False lista_aux = [] ...
bcf982d063f36f2538ee4e73ecad8a5fa01fb64c
jonatanbedoya/ST0245-Eafit
/proyecto/CodigoYaEmpezado/decision_tree.py
1,628
3.6875
4
""" Module containing the necessary classes and functions to build a CART Decision Tree. """ from utilities.utils import class_counts from utilities.math import find_best_split, partition class Leaf: """ A leaf node classifies data. It holds a dictionary of class -> number of times it appears in the rows...
4891db9dbcb0b863349fd06ca4c66dda5e3851a7
ZHKO1/leetcode
/74.py
552
3.515625
4
class Solution: def searchMatrix(self, matrix, target): """ :type matrix: List[List[int]] :type target: int :rtype: bool """ nums = [] for i in matrix: nums = nums + i low = 0 high = len(nums) - 1 while (low <= high): ...
bd01f579669f737061837f6fcdf3aadc3e519586
Beelzebub0/PY4E
/10th.py
409
3.984375
4
fname = input("Enter file name: ") try: fh = open(fname) except: print("can't open", fname) quit() count = 0 for line in fh: line = line.rstrip() if not line.startswith("From") : continue if line.startswith("From:") : continue words = line.split() print(words[1]) count...
a1de5ae5e046ba45bd8ed366115bb2b94e6a7aaa
hao44le/CS410-MPS
/MP2-FA19_part1/scraper_code/scraper.py
5,489
3.53125
4
from bs4 import BeautifulSoup from selenium import webdriver from selenium.webdriver.chrome.options import Options import re import urllib.request root_dir = "https://engineering.purdue.edu/Engr/People/ptDirectory" faculty_letters = ["A",'B','C'] BIO_URLS_FILE_LOCATION = "../bio_urls.txt" BIOS_FILE_LOCATION = "../bios...
b7eb9327b50f31af1a2552c9e954429926e870d8
xccane/coursera_1
/3_week_(float numbers)/3.3_lection_lib.py
1,121
4.125
4
import math # импортируется библиотека math print(int(2.5)) # округляет в сторону нуля (отбрасывет дробную часть) print(round(2.5)) # округляет до ближайшего целого, если дробная часть равна 0.5, то к ближайшему чётному # перед каждым вызовом функции из библиотеки нужно писать слово ''math.'', а затем имя функц...
1e569fab695a2dcef4a3aa26efdfbc6db4b5f94b
hansrajdas/random
/max_even_length_string.py
443
3.8125
4
# Fractal Analytics def longestEvenWord(sentence): sentence = sentence.split(' ') max_len_word = '00' for word in sentence: if not (len(word) % 2) and (len(max_len_word) < len(word) or max_len_word == '00'): max_len_word = word return max_len_word print longestEvenWord('It is a pleasant day today') ...
ac4935cd3266d77cd917b42e5843b56f0c2d9e25
YoonKyoungTae/Algorithm
/sort/sort_heap.py
897
4.0625
4
# coding=utf-8 """ [힙정렬] 주어진 배열을 힙트리에 정리 한 후 정렬을 맥스힙(인덱스 0)과 마지막 인덱스의 위치를 교체한다. """ def get_array(): return [10, 2, 5, 4, 7, 6, 8, 9, 3, 1] def make_heap(arr, arr_size): for i in range(1, arr_size): child = i while child != 0: parent = (child - 1) / 2 if arr[parent...
a6a58dcf8bc96ab1276cb497d80d2fe5e15f2bd7
cookm353/Calculator
/calculator.py
2,956
4.34375
4
# !usr/bin/env python3 OPERATORS = ['+', '-', '*', '/'] def get_input(): """Obtain input from user""" operation = input() return operation def clean_input(operation): """Handle whitespace, convert numbers to floats, and append to list""" num = '' statement = [] fo...
e8a37bd9326978c9b21c2221b37e01981c7d058c
sujeongcha/Coderbyte-Python-Practice
/Easy Difficulty/8. Check Nums.py
385
4.1875
4
#Have the function CheckNums(num1,num2) take both parameters being passed and #return the string true if num2 is greater than num1, otherwise return the string false. #If the parameter values are equal to each other then return the string -1. #My Solution def CheckNums(num1,num2): if num2 == num1: return '-1' ...
2ea9f4ea1daff8adff8fa71a5953840169b7d6c8
AlexanderOrloff/AlexanderOrloff
/hwPython1/python1.py
372
3.875
4
a = int(input('введи а')) b = int(input('введи b')) c = int(input('введи с')) if a / b == c: print('а разделить на b равно с') else: print('а разделить на b не равно с') if a ** b == c: print(' а в степени b равно c') else: print(' а в степени b не равно с')
57abf06b9bf7b038965d934ba0f4b7b085ea8e2f
gaurav93d/Python
/interchange_first_last_list.py
382
3.796875
4
def swapNum(newlist): print(newlist) a=newlist.pop() b=newlist.pop(0) newlist.append(b) newlist.insert(0,a) print(newlist) return newlist my = [1,2,3,4,5] swapNum(my) #2nd approch: def swapNum(newlist): print(newlist) get = newlist[0],newlist[-1] newlist[-1],newlist[0]...
2573731b2cae4526bbfb90ddf0c2b57850d299ff
nikmalviya/Python
/Practical 9/prac9_2_complex.py
902
3.921875
4
class Complex: def __init__(self, real, imaginary): self.real = real self.imaginary = imaginary def add(self, other): self.real += other.real self.imaginary += other.imaginary def sub(self, other): self.real -= other.real self.imaginary -= other.imaginary ...
cd2522e3c3d3a80b7d039499d0db0c980a13e8ef
alexprengere/PythonExercises
/05/runner.py
1,857
4.375
4
#!/usr/bin/env python """ Implentation of Runner class. >>> from runner import Runner >>> r = Runner('Sara', run_speed=20) # km/h >>> r.run(distance=10) # distance is km, result in hours 0.5 """ class Runner(object): """A runner """ def __init__(self, name, run_speed): self.name = ...
4e75a22edf32ec64b5ee86d8636d3ed45cc7db1b
vridecoder/Python_Projects
/Factorial/fact.py
241
3.78125
4
class Factorial: def __init__(self, n): self.num = n self.fact = 1 def factorial(self): for i in range(1, self.num+1): self.fact= self.fact*i print(self.fact) __all__ = ['Factorial']
787af7e8416bee081cb332f9e72a7ffa65dd7426
DidiMilikina/DataCamp
/Data Engineer with Python/03. Software Engineering for Data Scientists in Python/04. Maintainability/06. Refactoring for readability.py
1,704
4.59375
5
''' Refactoring for readability Refactoring longer functions into smaller units can help with both readability and modularity. In this exercise, you will refactor a function into smaller units. The function you will be refactoring is shown below. Note, in the exercise, you won't be using docstrings for the sake of spac...
d92f27e2609a7a94d43dc564616379ba0cc37eee
rajatgirotra/study
/interview/algorithms/sortings/merge_sort.py
1,069
3.890625
4
import os import sys def merge(arr, p, q, r): left_arr = arr[p:q+1] right_arr = arr[q+1:r+1] left_index = 0 right_index = 0 for k in range(p, r+1): if left_index >= len(left_arr): arr[k] = right_arr[right_index] right_index = right_index + 1 elif right_index ...
616269df750b2a63b507921baf0c10347d995927
evaldojr100/Python_Lista_4
/15_temperatura_media.py
836
4.1875
4
'''Faça um programa que receba a temperatura média de cada mês do ano e armazene-as em uma lista. Em seguida, calcule a média anual das temperaturas e mostre a média calculada juntamente com todas as temperaturas acima da média anual, e em que mês elas ocorreram (mostrar o mês por extenso: 1 – Janeiro, 2 – Fevereiro, ....
c86048ad1bafcb6014c34d0d9bf0eb2d900abfce
AlexisLeon/challanges
/pascal.py
439
3.703125
4
def triangle(n): arr = [[1],[1,1]] for i in range(1,n): line = [] [line.extend([ arr[i][j] + arr[i][j+1] ]) for j in range(0,len(arr[i])-1)] arr.append([1] + line + [1]) return arr def diagonal(n, p): return sum([x[p] for x in triangle(n) if p <= len(x)-1]) print( 'result: ', ...
bc754ac190d328f48e9c039802dbd1192a378925
limebell/GEOREUM
/tests/georeum/source/source.py
202
3.609375
4
def echo(a): a = a+1 return a def get_pow(a): return a*a def get_abs(a): if a > 0: return a else: return a*-1 def fun01(a, b): return get_pow(a)+get_abs(b)
a2eda1df0d71afff6aab764bf6aeda7e3003f583
iliankostadinov/hackerrank-python
/deque.py
1,042
3.796875
4
#!/usr/bin/env python3 from collections import deque def pilingUp(q): if len(d) > 1: value = "Yes" currentEl = 0 if d[0] > d[-1]: currentEl = d[0] d.popleft() else: currentEl = d[-1] d.pop() for _ in range(len(d) - 1): ...
17130f11792d59f869c82469aaf680c8883f7a3f
AdrianB1995/FunctionalBST
/pyBST.py
5,485
4.25
4
'''Provides basic operations for Binary Search Trees using a tuple representation. In this representation, a BST is either an empty tuple or a length-3 tuple consisting of a data value, a BST called the left subtree and a BST called the right subtree ''' def is_bintree(T): if type(T) is not tuple: return ...
189efc826835b39f57d8ef17693ac4f5c0b50fea
anyl92/ALGORITHM
/swea/4839_binarysearch.py
776
3.671875
4
import sys sys.stdin = open('binarysearch_input.txt', 'r') def binarysearch(n): start = 1 end = len(pages) count = 0 middle = (start + end) // 2 while middle != n: count += 1 middle = (start + end) // 2 if pages[middle] == n: return count elif pages[middl...
06f7b06b9027b9b09134e14acd3f43d88f2eaeff
vhsw/Advent-of-Code
/2019/Day 15/oxygen_system.py
3,657
3.6875
4
"""Day 15 Answers""" from typing import Dict, NamedTuple import networkx as nx from intcode_v15 import Intcode INPUT = "2019/Day 15/input" class Point(NamedTuple): """2D Point""" x: int y: int def __add__(self, other): return Point(self.x + other.x, self.y + other.y) class Maze: def ...
5167451f9c5f7c7c460b8f9f51df40a05f2fa8a9
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/bob/be5baac8abe94e97b4982cac8fa966c3.py
202
3.625
4
def hey(s): if s.isspace(): return "Fine. Be that way!" if (s.upper() == s and s.upper() != s.lower()): return 'Whoa, chill out!' if (s[-1] == '?'): return 'Sure.' else: return 'Whatever.'
17cb4c10939273784b4bc7e09d69d6c71f540eca
WenhaoChen0907/Python_Demo
/01_hellopython/hn_11_sum.py
262
3.640625
4
# 计算 0 ~ 100 之间所有数字的累计求和结果 result = 0 # 保存求和结果 i = 0 # 定义计数器 while i <= 100: result += i # 求和 i += 1 # 处理计数器 print("0 ~ 100 之间所有数字的累计求和结果: %d " % result)
cc574805d0fd6f33305e1ad6a6419c207ca46afb
regynald/Project-Euler-Solutions
/Python/020.py
262
3.84375
4
""" Project Euler Problem 20 ======================== n! means n * (n - 1) * ... * 3 * 2 * 1 Find the sum of the digits in the number 100! """ import math def run(): n = math.factorial(100) sum = 0 for i in str(n): sum += int(i) return sum print run()
850d4d09bd68d64ae5cb1d3d80d9e42c60fb269d
gcavalcantes/100ProgrammingChallenges
/100PCpython/age_calculator/age_calc.py
2,078
4.125
4
''' Program to calculate a person's age by Gabriel Cavalcante ''' from datetime import datetime class Calc_age: def calc_age(): print("===================================================") print("Program to calculate a person's age or the year they were born.") exit = False while ...
4430456aa1f2f3369338a6b5976fdc7170817495
dmitrygost/python-base
/lesson-1/task4.py
381
3.796875
4
for n in range(0, 22): num = n % 10 if n == 0: print(n, 'процентов') elif num == 0: print(n, 'процентов') elif n >= 11 and n <= 14: print(n, 'процентов') elif num == 1: print(n, 'процент') elif num >= 5: print(n, 'процентов') else: print(n, 'пр...
78928c3fa5f0200737a04782390f46f3dadf6da2
AvanthaDS/PyLearn_v_1_0
/function.py
1,322
4.1875
4
__author__ = 'Avantha' def avantha(): print('My first function - Multiply by 12') def mcal(av): amnt=av*12 return amnt # returns the answer to the equation when the function is called #print(amnt) avantha() a_av = int(input('please enter the number you want to multiply by 12: ')) av_ans = mcal(a_av) ...
65741848f34ac57544e21f345eb9127283930e4e
deyuwang/pisio
/src/link.py
758
3.578125
4
import Tkinter class Link(object): "" def __init__(self, fromNode, toNode, text="", color="black", textColor="black", width=1): self.fromNode = fromNode self.toNode = toNode self.text = text self.color = color self.textColor = textColor def cx(self): return ...
d7e504811a1e05497b0198a944b5f8f49cfe7f5e
toladata-ce/IATI
/percentage_recipient_country.py
1,126
3.5
4
#This function allows to fill in the Recipient Country Percentage column in the csv file #For one given activity, we must have the list of the distinct countries and their percentage def percentage_recipient_country(countries,ID): #get an array of #of rows for each activities count_ID=[] for i in range(le...
a4667728ff41bc999f0ffcb8671ef3963b37d0fe
zhouf1234/untitled3
/函数编程函数15LEGB.py
1,005
4.40625
4
#LEGB是Python中名字(变量)的查找顺序 #LEGB 代表名字查找顺序: locals -> enclosing function -> globals -> __builtins_ #locals 是函数内的名字空间,包括局部变量和形参 本作用域(名字空间) #enclosing 外部嵌套函数的名字空间(闭包中常见) 上层作用域(名字空间) #globals 全局变量,函数定义所在模块的名字空间 全局作用域(名字空间) #builtins 内置模块的名字空间 name = '100' age = 16 add = '上海' def demo():...
c3fd5ac39accf39dc9fef868d2833499e9ae1b7b
messersm/sudokutools
/sudokutools/analyze.py
3,865
3.78125
4
"""Rate and check sudokus. Functions defined here: * find_conflicts(): Check sudoku for conflicting fields. * is_solved(): Check, if a sudoku is solved. * is_unique(): Check if a sudoku has exactly one solution. * rate(): Return an integer representation of the difficulty of a sudoku. * score(): Return an integer...
9106c4b8585655fa1694e847888b55e2bf6fe80b
XrossFox/nltk_tests
/Py4Engineer/0/test02.py
1,077
3.609375
4
import nltk.classify.util from nltk.classify import NaiveBayesClassifier from nltk.corpus import movie_reviews from nltk.corpus import stopwords from nltk.tokenize import word_tokenize from nltk.corpus import wordnet """Stopwords, son palabras que ofrecen poco o nulo valor, pero son muy comunes. Toman una gran parte ...
9e14ab009ef4f20ab8f3d987f5a81ee12bfa7b42
CodeKul/Python-Dec-2018-CrashCourse
/Inheritance.py
1,185
3.8125
4
class Polygon: sides = [] def __init__(self,n): super().__init__() self.n = n def inputSides(self): for n in range(self.n): side = input("Enter {} side: ".format(n)) self.sides.append(side) def displaySides(self): for side in self.sides: ...
d90895ac92e2e10b648f389c1ef0ed5f174cce3d
luislama/algoritmos_y_estructuras_de_datos
/algoritmos/24_jose_javier_villena_sort/jose_javier_villena_sort.py
1,759
3.65625
4
''' 24_jose_javier_villena_sort Recorrer el arreglo buscando las posiciones de los numeros mayor y menor Al finalizar cada iteracion colocar los numeros al principio y al final, intercambiando los numeros Luego de cada vuelta, las posiciones a recorrer disminuyen en 2, puesto que los extremos ya han sid...
3ceee6b801ba0f690094d025137a90baaec1b029
DenBlacky808/Algo
/Lesson_1/Task_6.py
131
3.5
4
print('Введите номер буквы в алфавите ') n = int(input('n = ')) n = n + 96 char_1 = chr(n) print(char_1)
88d613585fcf483c124dcbac9d41e9d540f85c55
czs108/LeetCode-Solutions
/Medium/151. Reverse Words in a String/solution (2).py
975
3.8125
4
# 151. Reverse Words in a String # Runtime: 40 ms, faster than 55.52% of Python3 online submissions for Reverse Words in a String. # Memory Usage: 14.3 MB, less than 67.77% of Python3 online submissions for Reverse Words in a String. from collections import deque class Solution: # Deque of Words def revers...
f9da4cd7e82accc93fa614d1299ff7476fdb5267
t-suzuki/cubic_eigen_test
/cubic_eigen.py
4,063
3.8125
4
#!env python # https://en.wikipedia.org/wiki/Eigenvalue_algorithm # https://en.wikipedia.org/wiki/Cubic_function#Roots_of_a_cubic_function # https://en.wikipedia.org/wiki/Eigenvalue_algorithm import matplotlib.pyplot as plt import numpy as np def cubic_eigen(m): # det(x I - m) = 0 # <=> x**3 - x**2 * tr(m) - ...
97359cd4e3741a12a40c443d4a99cd5e2edfc3ab
google-code/a398t672-cs580-sp2015-svn
/test1(2)practise.py
227
3.609375
4
import string def main(): inuser = input("Enter a string:") message = "" for b in inuser: message = b + message print(message) //addind this just to be able to create a conflict main()
8bf36162eca279f2ed3d0cfbc66a19cc12a2b39c
guozhaoxin/leetcode
/num101_200/num151_160/num160.py
1,986
4
4
#encoding:utf8 __author__ = 'gold' ''' Intersection of Two Linked Lists Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: A: a1 → a2 ↘ c1 → c2 → c3 ↗ ...
2d660f284a94b1f1b2f843ef5de96356b4ea4062
nithinprasad94/Coding-Problems
/2 Linked Lists/3_delete_middle_node.py
2,189
4.1875
4
#Author: Nithin Prasad #Date Created: 30/09/2019 #Program Name: delete_middle_node.py #Program Description: this program allows one to delete A middle node in a # linked list, given ONLY that deletable node! class LL_Node: val = None nxt = None def __init__(self,input_val, next_node): ...
605b37d888ffd97c3a83be52271822e7ac0f02ab
meena5/Python_training
/python_classes.py
1,787
4.34375
4
# A Sample class with init method class sample: # init method or constructor def __init__(self, var): self.var = var # Sample Method def print(self): print('variable value is', self.var) s = sample(100) s.print() #class method '''Instead of accepting a self parameter, class methods take a cls p...
f6dd5c7d63fee6092acec6b0f0b154f2f4676512
djuanbei/AutoInput
/python/randvalue.py
1,281
3.90625
4
# -*- coding: utf-8 -*- import random from random import randint import string class RandChar(object): def __init__(self, a=-1, b=-1): self.low=a self.high=b def nextElem(self): if type(self.low) ==type(1) and self.low==-1: # all char return str(random.randint(string.asc...
b6cde917a7c9cd53a7ceb9a80eaf6f8acba6e71f
bazenkov/multitransmitter-RL
/Neuron_modul.py
5,502
3.5625
4
import numpy as np def get_burst_limits(activation_sequence, time): """Finds time limits of each burst. Iterates through every neighboring pair of elements in binary activation sequence of a neuron and finds the time of each activity change (from 1 to 0 and inverse). :param list activation_sequence:...
863525265bfefe9fa1353f0a6cf7491289d584c7
YuliiaShalobodynskaPXL/IT_essentials
/uHasselt/21.09.18zelfstudy/2.7.py
151
3.671875
4
print("enter X") x = str(input()) for i in range(11): lengt_max = len(10*x) l = lenght_max - len(i) print(x, " times ", i, " = ",""*l, i*x)
be5c6e4ebcfddbdf19777c0d8c4391be497d1978
sashakrasnov/datacamp
/28-machine-learning-for-time-series-data-in-python/4-validating-and-inspecting-time-series-models/08-bootstrapping-a-confidence-interval.py
1,556
4.375
4
''' Bootstrapping a confidence interval A useful tool for assessing the variability of some data is the bootstrap. In this exercise, you'll write your own bootstrapping function that can be used to return a bootstrapped confidence interval. This function takes three parameters: a 2-D array of numbers (data), a list o...
7ae420f61e005fb9bbaf88fde64b6c8afc62f562
Nedlloyd1990/Assignments_ML
/multiplicationTable- Assignment1.py
188
3.78125
4
count=20 def multiplicationTable(x): value=x for i in range(0 , count+1): print('2 x {}= {}'.format(i, (x*i))) multiplicationTable(4) # enter the value here
57c5f37cd37c18c493ff6f8f41a4506044d59677
AbuAbir/Python_Task
/task_5.py
2,900
4.15625
4
# TASK FIVE: HIGHER ORDER FUNCTIONS, GENERATORS, LIST COMPREHENSION AND DECORATOR # 1. # Write a program to Python find the values which is not divisible 3 but is should be a multiple of 7. # Make sure to use only higher order function. numbers = filter(lambda x: x%3 != 0 and x%7 == 0, range(10000)) print(next(numb...
1e3a564230ea5ff0c9413c227cce24297d5595ff
bobo137950263/pythoncode
/汉诺塔.py
391
3.5
4
#!/usr/bin/env python #-*- coding:utf-8 -*- def MoveHannuo(n,A,B,C): source = A destination = C if n == 1: pass print("from %s to %s"%(source,destination)) else: MoveHannuo(n-1,A,C,B) MoveHannuo(1,A,B,C) MoveHannuo(n-1,B,A,C) A="A" B="B" C="C" # MoveHannuo(1,A,B...
de805f12e0930431b57ad8b35c4e956ed3c914bc
x4Cx58x54/rubik-image
/svg.py
2,867
3.578125
4
""" Generates SVG patterns. @author Li Xiao-Tian """ def str_round3(x): ''' Round x to at most 3 decimal places and convert to string. ''' if isinstance(x, float): if abs(round(x, 0)-x) < 0.001: y = str(int(x)) elif abs(round(x, 1)-x) < 0.001: y = ...
fe103a16101a059189cd2754cf7f564ef25c7867
Aly622/Python
/test2.py
893
4.125
4
向量化运算 #生成一个整数的等差序列,局限:只能用于遍历 r1_10 = range(1,10,2) for i in r1_10: print(i) r1_10 = range(0.1,10,2) #生成一个小数的等差序列 import numpy numpy.arange(0.1,0.5,0.01) r = numpy.arange(0.1, 0.5 ,0.01) r #向量化计算,四则运算 r+r r-r r*r r/r #函数式的向量化计算 numpy.power(r,5) #向量化运算,比较运算 r>0.3 #结合过滤进行使用 r[r>0.3] #矩阵运算 ...
655b66d08764a4242da4c16255828d2c4f7cc419
TKdevlop/python-
/rangesfun.pyw
319
3.515625
4
lis=[5,20,5,4,100] def div5(x): if x%5==0: return True else: return False xyz=(i for i in lis if div5(i))# use same logic as down in one line #xyz=[] #for i in lis: # if div5(i): # xyz.append(i) for i in xyz: print(i) [print(e) for e in range(5)]
c6a9d92b4b01763d62b73d07bf73c208a4a4d5df
FalsePsyche/Uni_pythonprog
/Homework02/recomend.py
6,858
3.671875
4
"""A Yelp-powered Restaurant Recommendation Program""" from abstractions import * #from data import ALL_RESTAURANTS, CATEGORIES, USER_FILES, load_user_file from utils import distance, mean, zip, enumerate, sample, key_of_min_value ################################## # Phase 2: Unsupervised Learning # ################...
eb0f78c036060812d10d274fef2f1495f5140cbe
AlbertoAlfredo/exercicios-cursos
/Curso-em-video/Python/aulas-python/Desafios/desafio024.py
119
3.6875
4
cidade = str(input("Digite a cidade que você nasceu: ")).strip() cidade = cidade.lower() print(cidade[:5] == "santo")
f01e962fd84e8e2d5022900e7d67ea00eeb9e32a
opencbsoft/kids-worksheet-generator
/application/core/generators/simple_math_addition.py
1,283
3.5625
4
import itertools import random from core.utils import Generator class Main(Generator): name = 'Simple math addition' years = [4, 5] icons_folder = ['food', 'animals'] directions = 'Aduna imaginile si scrie rezultatul in casuta.' template = 'generators/simple_math_addition.html' def generate_d...
ca6bc2ff25a83b19e38fbf2579ab69140ad78bbb
benxiao/python-dynamic-programming
/bisort/bisort.py
933
3.65625
4
""" Binary Insertion sort is a special type up of Insertion sort which uses binary search algorithm to find out the correct position of the inserted element in the array. Insertion sort is sorting technique that works by finding the correct position of the element in the array and then inserting it into its correct po...
4d83a2c0727afc90044d2aa807b02e12fc1b654a
apjemran/PythonLearning
/basics/range_and_enumerate.py
345
3.84375
4
''' Created on 22-Sep-2020 @author: mohd.e.khan ''' range1 = range(10) for i in range(10): print(i) for i in range(5,10): print(i) print("*" * 10) for i in range(0,100,10): print(i) lst = list(range(10,20)) print(lst) # Enumerate to get index t = [1,2,4,5,7,3] for i in en...
94e45c4b31b0013f6e9da8a9afaf633fcfecd2a5
engineer135/coding_test
/DFS&BFS/queue.py
240
3.921875
4
""" 큐=대기 줄이랑 같음 선입선출 """ from collections import deque queue = deque() queue.append(5) queue.append(2) queue.append(3) queue.popleft() #5제거 queue.append(1) print(queue) queue.reverse() #뒤집기 print(queue)
3aae5b783f3687c94b4d748bce1724306b6d54e0
nomadae/tareas
/computo_movil/crypt.py
2,007
4.03125
4
#! /usr/bin/env python3 # -*- coding:utf-8 -*- # Programa de encripción # Gilberto Domínguez def cambiar_letras(step,): alfabeto = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] crypt = {} decrypt = {} for x in alfabe...
d1bebb763b591e045b3a78133a5c7104ceeb4c2e
MichaelAntropov/python-masterclass
/Functions_Intro/functions.py
1,577
4.40625
4
import re def multiply(a: float, b: float) -> float: """ Multiply two arguments and return the result. :param a: The first argument. :param b: The second argument. :return: The result of multiplication. """ result = a * b return result def is_palindrome(string: str) -> bool: """...
d9c783038988b38e7fe1ba9b276f55726e8f58d0
cisco-iamit/spacex-api-home-project
/main.py
826
3.5625
4
""" Print the total number of launches and summary of last n launches. """ # you can import local modules, too. see spacex.py from spasex import get_launches, recent_launches launches = get_launches() n_launches = len(launches) print(f"SpaceX has launched {n_launches} rockets!") n_recent_launches = int(input("How ma...
6cbfcf079647b026427132205a1fa6ba87fc3967
wittawas19/Python-Lab
/Chapter2/63010885_Lab02_03.py
816
3.671875
4
def range(*arg) : myList = list(map(float,arg)) ansList = [] nyFormat = "{0:.3f}" if len(arg) == 1 : end = myList[0] start = 0.0 while end > 0 : ansList.append(start) start += 1.0 end -= 1 elif len(arg) == 2 : s...
6e59bf3b6576bc8c9b697ce6bd9ee0860ddaeaa7
jsaraviab12/Exercism-Python
/isogram/isogram.py
236
4.09375
4
def is_isogram(string): string = string.lower() for letter in string: if letter == "-" or letter == " ": continue if (string.count(letter) > 1): return False return True
f003a4afcbc169135b7a8095eaac525670041b89
sbolla27/python-examples
/class2/factorial.py
162
3.921875
4
# a = 1 # for i in range(1,5): # a*=i # # print(a) def factorial(num): if num == 1: return 1 return num*factorial(num-1) print(factorial(5))
207dc4ef98e7b1a731a50c5bd2ede75cb0967175
pankaj7822/sell_old
/api/serializers.py
2,064
3.5625
4
''' Serializers allow complex data such as querysets and model instances to be converted to native Python datatypes that can then be easily rendered into JSON, XML or other content types. Serializers also provide deserialization, allowing parsed data to be converted back into complex types, after first validating the ...
2d343ffaee9ba6c0891c8a5d3a69f9cc7a5cea9e
warrenwrate/python_scripts
/groupby.py
1,274
3.984375
4
from itertools import groupby things = [("animal", "bear"), ("animal", "duck"), ("plant", "cactus"), ("vehicle", "speed boat"), ("vehicle", "school bus")] #tells the group by to use the first value as the grouping key #shows complete grouping for key, group in groupby(things, lambda x: x[0]): print('this is th...
2d0772c74c48eb27a466eeb83eb9b40c9a451edf
SyedaSamia/Hackerrank-30-days-challenge
/day30_bigSorting.py
186
3.609375
4
if __name__ == '__main__': x = list() t = int(input()) for i in range(t): x.append(input()) x.sort(key=lambda i: (len(i), i)) for i in x: print(i)
0405d5d1b151298a976389ff4dea254ccff54c26
SophieEchoSolo/PythonHomework
/Lesson6/solo06_morsecode.py
2,831
4.59375
5
""" Author: Sophie Solo Course: CSC 121 Assignment: Lesson 06 - Morse Code Description: solos06_morsecode.py - This program is suppossed to ask the user to input a string and it will return the morse code version of that string """ # function to compare letters in the string to morse code characters # this functio...
2a6c34312b6d42e6006fb791c9d6a73b851c01c6
Ze1al/Algorithm-Python
/LeetCode/20.py
626
3.671875
4
# -*- coding:utf-8 -*- """ author = zengjinlin """ """ 有效括号 输入: "()[]{}" 输出: true """ class Solution: def isValid(self, s: str): if len(s) % 2 == 1: return False # 维护一个栈 stack = [] pair = { "]": "[", "}": "{", ")": "(" ...
31ab489878e25522029654c2b91e29ab64d68455
DaHuO/Supergraph
/codes/CodeJamCrawler/16_0_3_neat/16_0_3_supermanwonderwoman_jam3.py
1,421
3.59375
4
import random from math import sqrt from itertools import count, islice def isPrime(n): if n < 2: return False for number in islice(count(2), 9999999): if not n%number: return number return False jamcoins = [] def coin_tester(num): divisors = [] multipliers = [3...
26e6cec9360e81d5157fb92530bf0ba749dd00c0
ankuarya/python_programs
/word_calc.py
399
3.890625
4
sentence = input('Please enter a sentence : ') words=sentence.split(' ') char_count_dict={} for word in words : characters = list(word) for char in characters : if char in char_count_dict : char_count_dict[char] += 1 else: char_count_dict[char] = 1 sorted_keys = sorted(char_count_dict.keys()) for key in...
77f44086e6ddbdd980d51244a7068c01e7be7c3d
catherinenofail/Implementation_Proj
/ConvexHull.py
2,657
3.625
4
import math import random import timeit def makeRandomData(numPoints): #"Generate a list of random points within a unit circle." # numPoints = 10 # Fill a unit circle with random points. t, u , r, x, y = 0, 0, 0, 0, 0 P = [] for i in range(0,numPoints): #random() should be within 0 and 1 t = 2*math.pi*ran...
2c54fe4a9662ca722cf4b1b713bf95f14f87411e
mayankmandloi/pythontut-2-7-18
/Day-15/for.py
106
3.578125
4
for a in range(10): print(a) for a in range(2,20): print(a) for a in range(2,20,2): print(a)
4f3cd05e4dd91274db1921b61e7df7575ee3635c
houxudong1997/Advanced-Artificial-Intelligence
/Uniform-Cost Search.py
1,561
3.78125
4
import heapq graph = { "s": {"a": 8, "b": 5, "c": 10}, "a": {"b": 7, "d": 9}, "b": {"a": 7, "f": 17}, "c": {"e": 13}, "d": {"a": 9, "f": 16, "g":31}, "e": {"c": 13,"f":11,"g":29}, "f": {"b":17,"d":16,"e":11,"g":4}, "g": {"d":31,"e":29,"f":4} } class Dijkstra: def in...
c25ad3658e36e899994e8004e201f9466bf9b38a
HyangSa/study
/Python/2주차(0321)/0321-1-Ellipse.py
997
3.953125
4
import turtle as t import math t.speed(0) def drawLine(): t.penup() t.setx(-200) t.pendown() t.setx(200) t.write('x',font=('',20,'')) t.penup() t.goto(0,200) t.pendown() t.sety(-200) t.write('y',font=('',20,'')) ##a=int(input("장축 a 입력 : ")) ##b=int(input("단축 b 입력 : ")) ##...
438eb372d94e5dc9a8e2af3d0ac646730243254d
Praveenk8051/data-science
/visualizations/visualization_using_dash/makedf.py
3,681
3.578125
4
import pandas as pd import os import numpy as np import datetime def getDataframe(path): #declare the string columns str_columns=['Overall', 'Polarity', 'Response','Unit_Id','rub+buzz','thd'] ##TODO:Append the rows in df def addRow(df,ls): """ Given a dataframe and a list, ap...
ba3da5e6be9389711f85ad8078ca815b59087c72
Zmek95/A.I-Slot-Car
/Main/DataCollectionMain.py
548
3.75
4
#!/usr/bin/env python3 from pwmGenerate import forward, stop, pwm_init from SensorRecord import sensor_record, sensor_calibrate # Get user speed and test time speed = int(input("Enter the desired duty cycle 0 - 100")) sensor_time = int(input("Enter the desired sensor read time in seconds")) # Calibrate BNO-055 sensor...
5efec8cf77caf351914b4cab6fb2a2cebeeecc5d
marcbaetica/Brute-Force-Attack-Utility
/db/db.py
2,714
3.671875
4
import os import sqlite3 as sl class DB: def __init__(self, name): self.name = name self.connection = self._create_db() self.tables = [] def _create_db(self): connection = sl.connect(self.name) return connection def query(self, query): with self.connection...
b621d3680a868209d8d62d3269470d8ea297c4ae
Jayesh598007/Python_tutorial
/Chap4_list_and_tuple/05_tuple_methods.py
182
3.90625
4
t = (1, 3, 4, 2, 6, 1, 4, 1) # counting the elements print(t.count(1)) print(t.count(4)) print(t.count(3)) # searching the index for an element print(t.index(6)) print(t.index(3))
d5df2ef3916e395783d51a27896ba5a85f0828b7
feeroz123/LearningPython
/udemy/ReverseWordOrder.py
486
4.375
4
# Write a program (using functions!) that asks the user for a long string containing multiple words. # Print back to the user the same string, except with the words in backwards order. ustring = input("Enter a sentence: ") splitString = ustring.split(" ") # Separate the words by " " character splitString.rever...
9ab67f773a12cc42061300cb39d1d08f5ca10933
Lihess/AlgorithmStudy
/CodeUP_100/1034 _ [기초-출력변환] 8진 정수 1개 입력받아 10진수로 출력하기.py
125
3.53125
4
a = input() print("%d" % int(a, 8)) # int(숫자, 8)과 같이 지정하면 해당 숫자를 8진수로 변경할 수 있다
8c04b68d31ca11155783a7d40a70e880a3f9c8bc
darcyfzh/algorithm
/leedcode/Search_Insert_Position.py
530
3.6875
4
def Search_Insert_Position(nums,k): if nums == None or nums == []: return 0 low = 0 high = len(nums) - 1 while(low <= high): if k > nums[-1]: return len if k < nums[0]: return 0 mid = (low + high) / 2 midData = nums[mid] if midData == k: ...
1115c3d085790edd6e6cc89087bc25513a27a4dd
harshraj22/problem_solving
/solution/hacker_rank/ConnectedComponent.py
817
3.65625
4
# https://www.hackerrank.com/contests/data-structure-tasks-binary-tree-union-find/challenges/connected-component/problem from sys import stdin par, weight = [], [] nodes = int(input()) connected = nodes par = [i for i in range(nodes+5)] weight = [1 for i in range(nodes+5)] def find_par(u): if par[u] == u: ...