blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
c5de235a8c73376963dab1bfa1d648a5ff317818
javierunix/ca_computerscience
/CS102/AsymptoticNotation/main.py
1,500
4.1875
4
from linkedlist import LinkedList def find_max(linked_list): current = linked_list.get_head_node() maximum = current.get_value() while current.get_next_node(): current = current.get_next_node() val = current.get_value() if val > maximum: maximum = val return maximum #Fill in Function def sor...
7d05ca97917a056dcf1b724a77f6b59f23d4cb30
Moaz-Morsy/coursera-data-structures-algorithms-specialization-UC-San-Diego
/3. Algorithms on Graph/Week5-Spanning-Trees/1_connecting_points/connecting_points.py
1,392
3.859375
4
#Uses python3 import math def minimum_distance(n, x, y): # result = 0 #write your code here nodes = tuple(zip(x, y)) pos = 0 nodes_distance = [] while pos < len(x)-1: for i in range(pos+1, len(x)): x_dist = (nodes[pos][0] - nodes[i][0]) ** 2 y_dist = (nodes[pos]...
b5fa93d3edbc4f0061fe3afa9983312c0c8e89d0
jz33/LeetCodeSolutions
/940 Distinct Subsequences II.py
1,102
3.703125
4
''' 940. Distinct Subsequences II https://leetcode.com/problems/distinct-subsequences-ii/ Given a string S, count the number of distinct, non-empty subsequences of S . Since the result may be large, return the answer modulo 10^9 + 7. Example 1: Input: "abc" Output: 7 Explanation: The 7 distinct subsequences are "a"...
18aa03066f108c14c9e94f3b5ade0f92ae2fc5f0
XiangLei5833/Python-
/practise5-13.py
290
3.8125
4
#!/usr/bin/env python # -*- coding: utf-8 # 时间转换 def Min(a, b): min = a*60 + b return min if __name__ == '__main__': M = input('Enter a time: ') try: (h, m) = M.split(':') print Min(h, m) except ValueError: print 'Please input again'
5495502d71055f6a4963e986064377d5356aec6a
amadi5892/PythonPrac
/methods_func_hw.py
2,420
4.09375
4
# # Volume of Sphere # import math # def vol(rad): # return (4/3)*math.pi*(rad ** 3) # print(vol(2)) # Write a function that checks whether a number is in a given range (inclusive of high and low) # def ran_check(num,low,high): # if low < num < high: # return f'{num} is in the range between {low} an...
3a0c79a3728a89b1ae50527827d7cb1998fb91b1
devangverma/CTCI
/linked_list/2.6.py
2,500
4.25
4
class Node: def __init__(self,val): self.val = val self.next = None def traverse(self): node = self while node != None: print(node.val) node = node.next def size(node): len = 0 while node != None: len+=1 node = node.next return len def reverse(node): head ...
c66620ed76ea040c7370170c65c6531a45e705c7
therouterninja/Studies
/hackerrank/algorithms/02_implementation/02_sherlock_and_the_beast.py
172
3.515625
4
#!/bin/python import sys for _ in range(int(input())): n = int(input()) c = 5*(-n%3) if c > n: print(-1) else: print('5' * (n-c) + '3'*c)
8c6e6f1dd17d1be736fcadf9a98523416873fa6b
Paradiddle131/Hackerrank
/Python/ProblemSolving/Easy/ChocolateFeast.py
396
3.5
4
def chocolateFeast(n, c, m): count = 0 wrapper = n / c while wrapper >= m: newChocolate, wrapper = divmod(wrapper, m) wrapper += newChocolate count += newChocolate return int(count + n/c) print(chocolateFeast(15, 3, 2)) # 9 bars print(chocolateFeast(10, 2, 5)) # 6 bars print(...
855bfc465553ffc6db4862dd780e46cb604510a9
InfiniteWing/Solves
/zerojudge.tw/c381.py
446
3.5
4
def main(): while True: try: arr = input().split() except EOFError: break n, m = int(arr[0]), int(arr[1]) if(n == 0 and m == 0): break words = [] for _ in range(n): words.append(input()) word = ''.join(words) arr = [...
7ddbe6f7a0693df49ffa484f04383b5bbfa5e3dc
1frag/alg_and_data
/programming-languages/lesson1/t13n.py
841
3.875
4
# 3. В первой строке задано количество людей и автомобилей такси, # в следующих двух строках расстояние в километрах для каждого # человека и цена за километр для каждого такси. Необходимо # сопоставить каждому человеку стоимость такси, чтобы суммарная # цена поездок была минимальна. def pass_stuff(): input() d...
0a3c5894e554adb6194d7b1ca4b86eb14047340d
hammer-spring/PyCharmProject
/06_Tkinter/6.12 使用tkinter鼠标事件.py
2,899
4.0625
4
from tkinter import * # 处理鼠标光标进入窗体时的事件 def handleEnterEvent(event): label1["text"] = "You enter the frame" label2["text"] = "" label3["text"] = "" # 处理鼠标光标离开窗体时的事件 def handleLeaveEvent(event): label1["text"] = "You leave the frame" label2["text"] = "" label3["text"] = "" # 处理在窗体内单击鼠标左键的事件 ...
4d1f11fe74c1690b04d63bd7674a20036509147f
urbanskii/UdemyPythonCourse
/secao04/se04E38.py
396
3.671875
4
""" 38 - Leia o salário de um funcionário. Calcule e imprima o valor do novo salário, sabendo que ele recebeu um aumento de 25%. """ def main(): fun_salario = float(input('Digite o salario: ' )) aumento = fun_salario*0.25 novo_salario = aumento+fun_salario print(f'Resultado do salario com aumento ...
a7ff5e553b7171c374f2d5e5b05915ab65712fa7
luxuguang-leo/everyday_leetcode
/00_leetcode/127.word-ladder.py
4,053
3.640625
4
# # @lc app=leetcode id=127 lang=python # # [127] Word Ladder # # @lc code=start class Solution(object): def ladderLength(self, beginWord, endWord, wordList): """ :type beginWord: str :type endWord: str :type wordList: List[str] :rtype: int """ #method 1.a,单向...
f44f3b8431e898dac8444fac4ce5cf1904a8b449
CalmScout/LeetCode
/Python/easy/1450_number_of_students_doing_homework_at_a_given_time.py
1,234
3.703125
4
""" Given two integer arrays startTime and endTime and given an integer queryTime. The ith student started doing their homework at the time startTime[i] and finished it at time endTime[i]. Return the number of students doing their homework at time queryTime. More formally, return the number of students where queryTime ...
2124627b9af47243dc5db466391e34d7059dbcb5
kovacszitu/Essentials
/PythonBootcamp/decorator.py
1,138
4.03125
4
def func(): return 1 def hi(): print("Hi!") hi2= hi del hi hi2() def hello(name="Agent"): print("The hello() function has been executed!") def greet(): return "\t This is the greet() function inside the hello()" def welcome(): return "\t This is welcome() function inside...
dd113b79e3ea24153d0c23f74636a3e9d715f92c
shymarrai/pset6
/dna/dna.py
2,288
3.671875
4
import sys import csv DNA_AGATC = "AGATC" DNA_AATG = "AATG" DNA_TATC = "TATC" def main(): base, dna_sequence = verify_args() sequence = read_sequence(dna_sequence) people = read_people(base) dna = compare_sequences(sequence) person = lookup_people(people, dna) if person: print(person...
20df0c9a1eecd48655b55d4307e905844ef0a256
LRal/Python003-003
/week08/week08_2.py
339
4.375
4
""" 自定义一个 python 函数,实现 map() 函数的功能。 """ from typing import Callable, Sequence, Iterator def map_(func: Callable, *seq: Sequence) -> Iterator: for args in zip(*seq): yield func(*args) if __name__ == '__main__': a = map_(lambda x: x ** 2, range(100)) print(next(a)) print(list(a))
1f512cbbb2291f605a2f7376a77d3d8cac49f123
ca-lynch/CIS2348
/FinalProjectPart2/FinalProject_Part2.py
13,881
3.59375
4
# Cody Lynch # 1954220 import csv # Imports csv module import sys from datetime import date, datetime # Imports datetime module class InventoryItem: # Creates class to store item information for each item serial_num = int() manufacturer = str() product_type = str() damage_status = Fals...
52e312f1470870107e3c14e782268a8298c20cbe
joez/letspy
/lang/module/fraction.py
337
3.96875
4
#!/usr/bin/env python3 from fractions import Fraction from functools import reduce import operator def product(fracs): t = reduce(operator.mul, fracs, 1) return t.numerator, t.denominator if __name__ == '__main__': n = int(input()) l = [Fraction(*map(int, input().split())) for _ in range(n)] pr...
4af45c14032599ecd37b9432baae297e5af79383
PanMaster13/Python-Programming
/Week 4/Tutorial files/Week 4, Exercise 2.py
1,753
3.78125
4
print("Google Grocery shop") print("[V]egetable selection") print("[M]eat selection") print("[S]eafood selection") print("\n") ipt = input("Enter your selection:") ipt1 = ipt.lower() if ipt1 == "s": print("Seafood section") fish = int(input("Fish:")) prawn = int(input("Prawn (per 100gram):")) crab = in...
5770d333feccedd300bdbde414a440b2363ed8e3
janet-dev/pokemon-data
/pokemon-data.py
2,132
3.984375
4
""" Retrieve multiple Pokemon and save their names and moves to a file. Use a list to store 6 Pokemon IDs. Then in a 'for' loop call the API to retrieve the data for each Pokemon. Save their names and moves into a file called 'pokemon.txt' """ import requests pokemon_ids = [] # initialise the Pokemon ID list """ Th...
c7e48d006c22df9548c53e109a47498e6400ede1
arnabs542/Data-Structures-And-Algorithms
/Queues/First non-repeating character.py
1,958
3.78125
4
""" First non-repeating character Problem Description Given a string A denoting a stream of lowercase alphabets. You have to make new string B. B is formed such that we have to find first non-repeating character each time a character is inserted to the stream and append it at the end to B. if no non-repeating charac...
a56d69c2da14a83ae8ea48036159534a618106cd
tploetz/MNIST-CNN-Tensorflow
/MNIST.py
4,262
3.5
4
from __future__ import absolute_import from __future__ import division from __future__ import print_function import argparse import sys import keras from keras.datasets import mnist from keras.models import Sequential from keras.layers import Dense, Dropout, Flatten from keras.layers import Conv2D, MaxPooling2D from ...
342aff9221751d03ceb1cdb59e0c36fd2f84ec6e
Ph0en1xGSeek/ACM
/LeetCode/75.py
773
3.6875
4
class Solution: def sortColors(self, nums): """ :type nums: List[int] :rtype: void Do not return anything, modify nums in-place instead. """ nums_len = len(nums) if nums_len == 0: return left = 0 right = nums_len - 1 index = 0 ...
218104726f76eb30400a9653740c32c4f9fce4c7
msjahun/python_snips
/multiple_assignment_.py
290
3.6875
4
def multiple_return(): a =15 b=90 return a,b if __name__== "__main__": #this is a demonstration of chained assignment a = 5 a, b = a+1, a c=1000 a, b = multiple_return() print(a) print(b) print(eval(input())) print(range(49))
2ed1bc032d8ce3babb8d7396dbd4daa5c7a06b56
pulum03/HackerRankStudy
/ProblemSolving/hr_Utopian Tree.py
1,010
3.890625
4
# There is a pattern on the height every year. # original height: 1 # year 1 (2 cycles) : 1*2+1 = 3 # year 2 (4 cycles) : 3*2+1 = 7 # year 3 (6 cycles) : 7*2+1 = 15 # year 4 (8 cycles) : 15*2+1 = 31 # year 5 (10 cycles) : 31*2+1 = 63 # and you can notice the value in binary is like this # year 1 (2 cycles) : 1*2+1...
539da040bd4eb481fc56db70d895c6f50be35671
JeremiahZhang/gopython
/python-programming-an-introduction-to-CS/src/ch07/convert2.py
420
3.984375
4
# convert2.py def main(): celsius = eval(input("What's the Celsius temperature?")) fahrenheit = 9/5 * celsius + 32 print("The temperature is {} degrees in Fahrenheit.".format(fahrenheit)) # Print warnings if fahrenheit > 90: print("It's relly hot out there. Be carefully.") if fahrenhe...
e529a442b2ba34d1138ab97d3b8b4304f9efb012
Disat/python_spider
/tk.py
520
3.609375
4
import tkinter as tk url = '' window = tk.Tk() window.title('My Window') window.geometry('800x200') O_url = tk.Text(window,width = 100, height = 1.5) O_url.pack() # 在文本末尾插入entry输入框的数据 def click_to_run(): global url url = O_url.get("1.0","end") t.insert('end', ) b2 = tk.Button(window, text = 'click to r...
90dcdc242065784d226e361611347355a3b5a511
pooja-pichad/ifelse
/15.new.py
358
4.34375
4
# we have to check whether the number is divisibal by 3 and then show "fizz". # and its divisibal by 5 then show "buzz".the number is divisible by both then show # "fizzbuzz". num=int(input("enter a number")) if num%3==0 and num%5==0: print("fizz-buzz") elif num%3==0: print("fizz") elif num%5==0: prin...
439215d4ea2002922ad24ec8a335d922bbf05c89
TardC/books
/Python编程:从入门到实践/code/chapter-6/favorite_numbers.py
1,468
3.640625
4
favorite_numbers = { 'lily': 0, 'andrew': 1, 'tom': 2, 'jen': 3, 'phil': 4, } print("Lily's favorite number: " + str(favorite_numbers['lily']) + "\n" + "Andrew's favorite number: " + str(favorite_numbers['andrew']) + "\n" + "Tom's favorite number: " + str(favorite_numbers['tom...
27e53b2d976d1d7f1ca8ce1521934f497de14261
HillYang/PythonExercises
/PycharmProjects/python.geekbang.com/zodiac_list.py
178
4.0625
4
# 列表的使用例子 # 列表与元组的区别:列表可以增加删减数据 a_list = ['abc', 'xyz'] a_list.append('X') print(a_list) a_list.remove('xyz') print(a_list)
5a24962633e4391138d308b12f6e5e717d8e595c
maxwelnl1/arvore-binaria
/arvore_binaria.py
1,065
3.78125
4
class No: def __init__(self, valor): self.valor = valor self.esquerda = None self.direita = None def obtervalor(self): return self.valor def obteresquerda(self): return self.esquerda def obterdireita(self): return self.direita def setesquerda(self,...
6d5283e49e60c87fd7de194e0f3590dfc4b27482
VBakhila/project-euler-python
/083.py
616
3.703125
4
from lib import Dijkstra from itertools import product def main(file): with open(file, 'r') as f: matrix = [[int(n) for n in line.rstrip().split(',')] for line in f] size = len(matrix) START = (0, 0) FINISH = (size - 1, size - 1) vertices = product(range(size), repeat=2) def neighbours(v): x, y = v if x ...
5f0a2fe72d95e820deaa35c906e4d2c9c7ad8544
uwenhao2008/python100-
/python100题目/test30这里判断进位数的方法好.py
1,098
3.671875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Author:Wen Time:2019年03月22日 15:52 tip-->兴趣是最好的老师<-- """ # 一个5位数,判断它是不是回文数。即12321是回文数,个位与万位相同,十位与千位相同。 """ ------------------------------------------------------ 思路:使用数组处理非常简单,直接ls[1]?ls[-1]之间判断就可以,不过我想换个思路试一试 ------------------------------------------------------ """ d...
3b71e1b628d9062b011c4f616dba44ff12111453
anant-pushkar/competetive_programming_codes
/old/5th sem/py/testProject/Main.py
68
3.609375
4
t=int(input()) for i in range(t): num=int(input()) print(num+1)
1b48afd8557579c01c8ba951302e6c75ed014a66
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/224/users/4348/codes/1734_2499.py
190
3.640625
4
from math import* k = int(input("Digite o numero natural:")) soma = 0 #acomuladora i = 0 #contador fim = k-1 while (i <= fim): soma = soma + (1/factorial(i)) i = i + 1 print(round(soma,8))
31cad4ecd768e97b933faec280219998a61ac734
lastbyte/dsa-python
/problems/easy/symmetric_binary_tree.py
1,493
4.40625
4
''' Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center). Example 1: 1 / \ / \ 2 2 / \ / \ 3 4 4 3 Input: root = [1,2,2,3,4,4,3] Output: true Example 2: 1 / \ ...
7780158942bd3f354cbe5d2470cf8d4d4ea26c0c
adrielyeung/job-ad-compare
/src/Report_Writer.py
2,007
3.53125
4
# -*- coding: utf-8 -*- class Report_Writer: ''' Writes info into a .txt report. ''' def __init__(self, filename, filepath): ''' Initialises the report writer. Parameters ---------- filename : string File name. filepath : string Di...
2e4cdf38d60054cf3c0ee3e94a2521984ef2483a
deepeshchaudhari/learnOOPython
/tut5[list,dict].py
693
4.125
4
''' List comprehension Dictionary comprehension Set comprehension Generator comprehension ''' list =[1,2,3,2,1,32,3,1,25,45,1,32,54,1,2,54,1,5,21,5] div_by_3=[] for x in list: if x%3==0: div_by_3.append(x) print(div_by_3) print('without using list comprehension',div_by_3) print('using list c...
0b109d519e1b5cb29e591a0330c929451a0b5a68
marcosfsoares/INTRO-COMPUTER-SCIENCE-WITH-PYTHON
/Projeto Jogo NIM/40_Jogo_do_NIM.py
3,107
4.0625
4
''' JOGO NO NIM n é o número inicial de peças m é o número máximo de peças que é possível retirar em uma rodada''' def computador_escolhe_jogada(n,m): escolhida=m while(escolhida>0): if((n-escolhida)==0): return escolhida elif((n-escolhida)%(m+1)==0): return escolhida ...
519ba8b41634777328f062399229b5282c12ed02
feannag/cryptography
/one_time_pad.py
1,451
3.671875
4
alphabet_dictionary = {'A': 0, 'B': 1, 'C':2, 'D': 3, 'E':4, 'F': 5, 'G': 6, 'H': 7, 'I': 8, 'J': 9, 'K': 10, 'L': 11, 'M': 12, 'N': 13, 'O': 14, 'P': 15, 'Q': 16, 'R': 17, 'S': 18, 'T': 19, 'U': 20, 'V': 21, 'W': 22, 'X': 23, 'Y': 24, 'Z': 25} reversed_alphabet_dictionary...
6613a07ea3c11f209828e074e9a2b36dd4ecf13e
Giang285/C4T-B13
/session8/read&index.py
1,027
3.796875
4
# cleanlist # items = ['40k', 'wargame', 'GoT'] # new_item = input("Thu khac:") # items.append(new_item) # print(*items, sep="") # ---------------------------------------------------------- # cleanlist2 # items = ['40k', 'wargame', 'GoT'] # new_item = input("Thu khac:") # items.append(new_item) # print(...
6d795bb8c048d2aa95f7d07865fe2e79b0ca3de2
abnatop/Lesson1
/task_4.py
521
4.0625
4
# 4. Пользователь вводит целое положительное число. Найдите самую большую цифру в числе. # Для решения используйте цикл while и арифметические операции counter = 0 digit = input('Введите целое положительное число: ') max_digit = digit[0] while counter < len(digit): if digit[counter] > max_digit: max_digit...
781e450ba9ad3dc8b6b5e495706e9a83dc5d6d44
lilian0726/my-project
/source-code-main/20210131/if_else.py
300
3.890625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Jan 23 13:21:15 2021 @author: JasonChang """ grade = 1000 # there's no () if grade >= 90: print('Excellent!') elif grade >= 60: ## else if print('Good enough!') else: ## last print('Loser!')
842a3fc30f51e9b8bdc2fdf8c262a5f9acd516fd
Lukawss/guppe
/escopo_de_variaveis.py
1,036
4.46875
4
""" Escopo de variáveis Dois casos de escoopo: 1 - Variáveis globais; - Variáveis globais são reconhecidas, ou seja, se escopo compreende, todo o programa. 2 - Variáveis locais; - Variáveis locais aão reconhecidas apenas no bloco onde foram declarados, ou seja, seu escopo está limitado ao bloco onde f...
2896e0edcd6ca1b2d3264f39d1265bf7f9013d06
CherylXu917/coding_practice
/LeetCode/270. Closest Binary Search Tree Value.py
1,041
3.96875
4
""" 270. Closest Binary Search Tree Value Easy 1160 81 Add to List Share Given the root of a binary search tree and a target value, return the value in the BST that is closest to the target. Example 1: Input: root = [4,2,5,1,3], target = 3.714286 Output: 4 Example 2: Input: root = [1], target = 4.428571 Outpu...
2e7ff2cd311ef0908ce6f004dc5ee734027bb2f9
Shubhamrathore3196/pydic
/Dictionary.py
765
3.75
4
import json from difflib import get_close_matches data = json.load(open('data.json')) word = input('enter a word') def translator(word): if word in data: return data [word] elif word.lower() in data: return data [word.lower()] elif word.upper() in data: return data[word.u...
2adc9f41d47e351c892a603f82dc580b88e63ea3
cjtapper/advent_of_code_2018
/day_02_inventory_management_system/ims_p1.py
425
4.03125
4
#!/usr/bin/env python3 import argparse from collections import Counter parser = argparse.ArgumentParser() parser.add_argument('input_file') args = parser.parse_args() twos = 0 threes = 0 with open(args.input_file) as f: for line in f: count = Counter(line) if 2 in count.values(): tw...
d4bf8799ee62b0232555d1b7ab2ad4a8f76fdbdd
ermeydan-coder/Python-IT-Fundamentals
/python_laboratory_solutions/args_example.py
383
3.75
4
# arguments first # def brothers(bro1, bro2, bro3): # print('Here are the names of brothers :') # print(bro1, bro2, bro3, sep='\n') # family = ['tom', 'sue', 'tim'] # brothers(*family) # arguments second solution. def brothers(*args): print('Here are the names of brothers :') for i in args: pri...
22be27924e29e5c616bd06534db8680c70eb861c
wmm98/homework1
/7章之后刷题/9章/有理数加法.py
773
4.0625
4
'''【问题描述】 定义有理数类,定义计算两个有理数的和的方法。程序输入两个有理数,输出它们的和。 【输入形式】 输入在一行中按照a1/b1 a2/b2的格式给出两个分数形式的有理数,其中分子和分母全是正整数。 【输出形式】 在一行中按照a/b的格式输出两个有理数的和。注意必须是该有理数的最简分数形式,若分母为1,则只输出分子。 【样例输入】 1/3 1/6 【样例输出】 1/2''' from fractions import Fraction class yl_shu: # def __init__(self, x, y): # self.x = x # self.y = y ...
5f5efebc3147c75a6347b5d34dc645c15e2cc897
index30/pypractice
/nock/part1/08.py
400
3.640625
4
#coding: UTF-8 import sys argv = sys.argv if len(argv) != 2: print('Usage: # python %s x' % argv[0]) quit() s_list = [] def cipher(x): for i in range(len(x)): v = ord(x[i]) if v > 96: v = 219 - v s_list.append(chr(v)) return "".join(s_list) def main(args): ...
97089175da7d7d97719863ef38a30ae9d4c5b836
digipodium/string-and-string-functions-akhil2761222
/solution_18.py
154
4.1875
4
number = input('enter your number:') numb = number.isnumeric() if numb is True: print('this is a number') else: print('this is not a number')
7d16305016a5e83544737e00991d2fd85fb1d88d
binghe2402/learnPython
/test/test_listmap_列表推导.py
686
3.75
4
''' 不一定谁快。前一个map再list快,后一个列表推导快 ''' import timeit ss = 's="1 2 3 4 5 6 7 8 9 10".split()' s1 = "a = list(map(int,s))" s2 = 'b = [int(i) for i in s]' t1 = timeit.timeit(stmt=s1, setup=ss, number=2000000) t2 = timeit.timeit(stmt=s2, setup=ss, number=2000000) print(t1) print(t2) ss = ''' with open('e://project_dat...
ea14a902178f77c8db0a1d5a8a152d89fd8785b8
sidsharma1990/officeprac
/Polynomial Regression Office 1.py
987
3.5
4
# Polynomial Regression import pandas as pd import numpy as np import matplotlib.pyplot as plt dataset = pd.read_csv('Position_Salaries.csv') X = dataset.iloc[:,1:-1].values y = dataset.iloc[:,-1].values # Linear model from sklearn.linear_model import LinearRegression lr = LinearRegression() lr.fit (X...
578ac16bc2bee5ab330e9754c15a9dd1759b01bd
peistop/Leetcode
/accept/459.RepeatedSubstringPattern.py
983
3.890625
4
""" 459. Repeated Substring Pattern Easy: 98.99% Testcase Example: "abab" Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase English letters only and its length will not ex...
036414135aa7c11b54fa36da48ca9703bc8649f5
aconfee/PythonPractice
/negateBinary.py
891
3.578125
4
import math def negateBinary(binaryCharArray): # Flip each bit for i in range(len(binaryCharArray)): binaryCharArray[i] = '0' if binaryCharArray[i] == '1' else '1' # Add one for i in reversed(range(len(binaryCharArray))): if binaryCharArray[i] == '1': binaryCharArray[i] = ...
a093cf17d8be0da15cfea18ef94dd7c13de16cef
tat2133/walmart-scrape
/code/walmartScrape.py
3,046
3.546875
4
# -*- coding: utf-8 -*- """ @author: taylorthompson Module containing functions to open a webpage, source it, parse the html """ from bs4 import BeautifulSoup from urllib.request import urlopen import re from datetime import datetime import csv #csv name and searches can be modified by user CSV_NAME = 'results.csv' ...
da4174d39abce30d828695a577d38d3ab9eda798
horzone/hwPython
/hw9-problem40.py
682
3.59375
4
# -*- coding: utf-8 -*- from functools import reduce # problem40 - list comprehension # # An irrational decimal fraction is created by concatenating the positive integers: # # 0.123456789101112131415161718192021... # # It can be seen that the 12th digit of the fractional part is 1. # # If dn represents the nth digit o...
14c00ccbc59185b2d7981d15b28cb1c38894bde5
nathanwang000/deep_exploration_with_E_network
/env/algorithms.py
14,019
3.609375
4
import numpy as np from gym.envs.my_env import bridge import gym import matplotlib.pyplot as plt import matplotlib def value_iteration(env, gamma = 0.9, theta = 0.0001): ''' Performs value iteration for the given environment. If there's a tie, use the first occurrence of max value. :para...
45b456061c331671950a3f450d8072c19aff0329
grass-mudhorse/Twitter-bot-test
/Responsive Dumpling maker/responsive rule generation.py
1,148
3.578125
4
def exchange(s): l = [] s = s.split() for i in range(len(s)): temp = "" for j in s[i]: a = "["+str.upper(j)+"|"+j+"]" temp += a l.append(temp) b = " ".join(i for i in l) return b def ww(s): l = [] b = s[0] for i in s: a = "\"" +ex...
cf3824e7c67decb5bd43c04299f3d3bd168723e8
gsrr/leetcode
/array/maximum_sum_array.py
771
3.78125
4
import random # n:int def create_int_array(n): return [random.randint(-100,100) for r in xrange(n)] def test_create_int_array(): print create_int_array(10) def find_maximum_sum_subarray(arr): print arr tmp_sum = 0 max_sum = 0 start = 0 tmp_start = 0 end = 0 for i in range(len(...
f6211008b582ae8765e5850d97da20bc32097812
ArtemBorodinEvgenyevich/DiskUsage
/DiscUsage_Console/DUCore/DUSpinner.py
1,590
3.6875
4
# -*- coding: utf-8 -*- """ A module containing a thread class to create a new thread for waiting animation.""" from threading import Thread import time import sys class Spinner(Thread): """Class for enabling a new thread with waiting indicator animation. .. note:: Works as a daemon. """ de...
c9f83f41c3bc39e1512c3d2f8ad68e63ea868cc5
Digits88/chi
/examples/models.py
1,655
3.8125
4
""" Tutorial for chi.model ---------------------- This is how we can use python functions to define models """ import os import chi import tensorflow as tf from tensorflow.contrib import layers # Keras-style layers from tensorflow.contrib import learn chi.set_loglevel('debug') # log whenever variables are cr...
72e7f87651c04fbdcee1aed55eae652d2f4e5230
La0/advent
/2016/3.py
651
3.765625
4
import re def is_triangle(sides): total = sum(sides) for i in range(3): remaining = sides[i] if (total - remaining) <= remaining: return False return True def solve(lines): grid = [map(int, re.findall('(\d+)', line)) for line in lines] triangles = [] for i in rang...
5e3277d2ded388beb5ae2c9d0cab84d03df20e7d
The-1999/Snake4d
/src/score.py
7,058
3.5625
4
# -*- coding: utf-8 -*- """ Created on Fri May 25 22:01:56 2018 @author: Mauro """ #============================================================================== # Score board #============================================================================== import datetime import os from tkinter import Label, Toplevel...
6e4811d4e32cd8f39fa7472ecbfafac9103c7b8f
Stevman17/Python-Practice-Problems
/NAIVE_BAYES_email_project.py
2,402
3.6875
4
from sklearn.datasets import fetch_20newsgroups from sklearn.naive_bayes import MultinomialNB from sklearn.feature_extraction.text import CountVectorizer #2.We're interested in seeing how effective our Naive Bayes classifier is at telling the difference between a baseball email and a hockey email. #We can select the ...
d13d3ed717b09d8c9c5822685856a5f360c8db4e
akashhnag/coding-ninja
/python/ex.py
249
3.6875
4
# basic method of input output # input N n = int(input()) # input the array arr = [int(x) for x in input().split()] print(arr) # initialize variable summation = 0 # calculate sum for x in arr: summation += x # print answer print(summation)
58276cdcc0048f41f9681820f3368fa6a4232018
seungjaeryanlee/clarity
/clarity/Board.py
63,726
3.859375
4
#!/usr/bin/env python3 """ This file defines the Board class. """ from .BitBoard import BitBoard from .Color import Color from .Direction import Direction from . import constants as const from .Move import Move from .MoveType import MoveType from .Piece import Piece from .Sq import Sq class Board: """ This cl...
ef58870389bfa423f255a9368f9d7bcfd44c6daa
sympy/sympy
/sympy/combinatorics/schur_number.py
4,437
3.578125
4
""" The Schur number S(k) is the largest integer n for which the interval [1,n] can be partitioned into k sum-free sets.(https://mathworld.wolfram.com/SchurNumber.html) """ import math from sympy.core import S from sympy.core.basic import Basic from sympy.core.function import Function from sympy.core.numbers import Int...
97831fa7bea539ec12835150b446a19c5bf1a1b6
MaxKreitzer/FixWifi
/SRC/FixWifi.py
1,690
4.0625
4
#!/usr/bin/python3 #creating GUI window #Also remember to install sudo apt install python3-tk import tkinter as tk win = tk.Tk() win.resizable(0, 0) win.title("FixWifi") #Adding text to the GUI mylabel = tk.Label(win, text="Would you like to run FixWifi?") mylabel.grid(row=0, column=0, columnspan=3, padx=10, pady=10)...
f647062c093159a42a7a87f9be25ba636ddb5d4c
minseunghwang/YouthAcademy-Python-Mysql
/작업폴더/09_Set/main.py
1,755
4.125
4
# Set # 파이썬에서 집합 처리를 위한 요소 # 중복을 허용하지 않고, 순서 혹은 이름으로 기억장소를 관리하지 않는다. # set 생성 set1 = {} set2 = set() print(f'set1 type : {type(set1)}') print(f'set2 type : {type(set2)}') print(f'set2 : {set2}') set3 = {10, 20, 30, 40, 50} print(f'set3 : {set3}') print(f'set3 type : {type(set3)}') # 중복 불가능 (중복제거용도로 사용) print('중복 No-...
417e8e96913dca2a9c58ba80c4f650f9838247bc
bishnu12345/python-basic
/list.py
699
4.09375
4
fruits=['Apple','Banana','Grapes','Lemon','Mango'] print(fruits) print(fruits[0:2]) print(fruits[-2]) print(fruits[2:]) print(fruits[::2]) new_fruits=fruits[:] print(type(new_fruits)) new_fruits.append('Orange') #adds single element to the list print(new_fruits) print(new_fruits.count('Grapes')) print(fr...
0cfb17e0a579d6c4a0f9e9277cb166d3e6a00284
KnJbMfLAgdkwZL/codewars.com
/Kata/6 kyu/The Supermarket Queue/main.py
559
3.640625
4
# The Supermarket Queue # https://www.codewars.com/kata/57b06f90e298a7b53d000a86 def queue_time(customers, n): time = 0 kiosk = [] customers.reverse() while len(kiosk) or len(customers): while len(kiosk) < n and len(customers): kiosk.append(customers.pop()) for i, k in enume...
f56139586bddb4fe2b08978b9a6c047a7187908d
drahmuty/Algorithm-Design-Manual
/04-45.py
2,910
4.4375
4
""" 4-45. Given a search string of three words, find the smallest snippet of the document that contains all three of the search words---i.e., the snippet with smallest number of words in it. You are given the index positions where these words occur in the document, such as word1: (1, 4, 5), word2: (3, 9, 10), and wo...
18949eac8ca44486a8a3807f93452218c2fc4406
plilja/project-euler
/problem_50/consecutive_prime_sums.py
588
3.5
4
from common.primes import PrimeSieve SIEVE = PrimeSieve(1000) def consecutive_prime_sum_less_than(num): (longest_count, longest_prime) = (0, 2) primes_less_than_num = SIEVE.primes_less_than(num) for i in range(0, len(primes_less_than_num)): count = 0 _sum = 0 for prime in primes_l...
e8ef2e77312825f88bfdb2f7e1686a0f53fb13c2
camiloperezv/dojo_empresariales_python
/main.py
1,445
3.5
4
from tkinter import * operador = "" root = Tk() root.geometry("1000x500+0+0") root.title("Dojo Python") text_input = StringVar() Tops = Frame(root, width=1600, height = 80, bg = "powder blue", relief=SUNKEN) Tops.pack(side = TOP) frame = Frame(root, width=300, height = 700, bg = "powder b...
0cc4bf031d275bb98ea7305f354645e9827d1b32
aliakseik1993/skillbox_python_basic
/module1_13/module12_hw/task_4.py
1,319
3.96875
4
print('Задача 4. Число наоборот') # Вводится последовательность чисел, # которая оканчивается нулём. # # Реализуйте функцию, # которая принимает в качестве аргумента каждое число, # переворачивает его и выводит на экран. # Пример: # Введите число: 1234 # Число наоборот: 4321 # # Введите число: 1000 # Число наоборот:...
fd429f15e5bfc9d5b3c97d62361c1b50c8d8893e
AndresRCA/python-proyecto-1
/main.py
4,542
3.625
4
import os import glob from datetime import datetime from classes.db_model.SQLiteDB import SQLiteDB from classes.Pizza import Pizza from classes.Order import Order def readOrders(pz_file): """ Read each '.pz' file in the directory returns a list with the orders in each .pz file fill with a list for each order o...
ef0d206f1723fae45218509e7984283b873718ab
ynXiang/LeetCode
/538.ConvertBSTtoGreaterTree/solution.py
1,089
3.71875
4
#https://discuss.leetcode.com/topic/83469/python-simple-with-explanation # 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 convertBST(self, root): """ ...
81447d6de1bb355b94eccf5b8b7cbb8c633df270
jiahsuanlo/artificial-intelligence
/Exercises/4_Game Class/minimax_helpers.py
1,040
3.765625
4
# -*- coding: utf-8 -*- #%% helper functions def min_value(gameState): """ Return the game state utility if the game is over, otherwise return the minimum value over all legal successors # HINT: Assume that the utility is ALWAYS calculated for player 1, NOT for the "active" player """...
b53731be336842e5bd0304b5d1ed0ab52fce0efe
PnS2018/UnixJesusWorshippers-exercises
/session_04/conv-net-with-keras-layers-template.py
4,456
3.859375
4
"""Convolutional Neural Network for Fashion MNIST Classification. Team UnixJesusWorshippers """ from __future__ import print_function, absolute_import import numpy as np import matplotlib.pyplot as plt from keras.layers import Input, Dense, Conv2D, MaxPooling2D, Flatten from keras.losses import categorical_crossentr...
fd2efcb7e2f8902c7c4221e1c921bf8c9dafeb37
JaiBalaj/Programs-Practiced
/CuttingRope.py
910
3.59375
4
def SingleDigit(arr,n): for a in arr: sum=1 cnt=0 while(sum<n): sum*=a cnt+=1 from itertools import combinations if __name__=="__main__": n=int(input("Enter the Length of N meters: ")) arr=[] for i in range(2,n): arr.append(i) ...
a4d57e0be6529387179f2542c2b417c2b4efb9e3
LiYu123456/pythonTasks
/tasks-基本语法/时间和日期.py
619
3.65625
4
# coding:UTF-8 print("Start....") import time import calendar print("得到1970年1月1日到现在的秒数:") t=time.time() print("时间戳为:",t) print("得到时间元组:") localtime=time.localtime(time.time()) print("本地时间为:",localtime) print("得到格式化日期:") t=time.asctime(time.localtime(time.time())) print(t) t1=time.strftime("%Y-%m-%d %H:%M:%S",time.lo...
0fa2b8c6510a63f1c8c0710d45f93713bb3010b6
SuhaasGupta/Hello-World
/RPS.py
1,502
3.8125
4
import Tkinter import random def rock(): a=random.choice(['rock','paper','scissors']) if a=='rock': print('you choose rock') print('computer choose',a) print('So Draw') elif a=='paper': print('you choose rock') print('computer choose',a) print('YOU LOSE') ...
a948d3a6e1cd93275933a24a1b93d7fd672eb1b8
iamashu/Data-Camp-exercise-PythonTrack
/part11-Cleaning-Data-in-python/No26-Dropping-duplicate-data.py
1,855
4.28125
4
#Dropping duplicate data ''' Duplicate data causes a variety of problems. From the point of view of performance, they use up unnecessary amounts of memory and cause unneeded calculations to be performed when processing data. In addition, they can also bias any analysis results. A dataset consisting of the performance ...
fcceb337c9a1ac7f7bdfad55dbe5f97d0f26a135
pscx142857/python
/上课代码/Python高级第二天/01is和==的区别.py
504
4.21875
4
""" is:是判断内存地址是否一样 ==:是判断值是否一样 """ name = "张三" name1 = "张三" # 因为字符串是不可变的,所以是简单数据类型,相同的数据不管定义多少次,都只会开辟一个内存空间 print(name is name1) # True print(name == name1) # True ls = ["张三","18"] ls1 = ["张三","18"] # list是可变的数据类型,复杂数据类型,相同的数据,定义几次就会开辟几次内存空间 print(ls is ls1) # False print(ls == ls1) # True
4592dba45344ed93969a3b25f3a28d8c67d6bd5f
amirsaleem1990/python-practice-and-assignments
/assigmints from sir zia 4-11-17/front_x (incomplete). 2.py
272
3.578125
4
def front_x(words): a = [] b = [] words.sort() for i in words: if i[0] == 'x': a.extend([i]) for ib in a: if ib in a: words.remove(ib) return a + words print(front_x(['mix', 'xyz', 'apple', 'xanadu', 'aardvark']))
c65723e6fb886cc197557100865223bafca023f8
vishwasks32/python3-learning
/myp3basics/exers/exer5.py
479
3.96875
4
#!/usr/bin/env python3 # # Author : Vishwas K Singh # Email : vishwasks32@gmail.com # def iseven(num): if num%2 == 0: return True else: return False if __name__ == '__main__': # Direct Conversion program fails if anything other than number is # Entered ...
91ec1e3d8e29fc6b66c1f200992ed2978940c8af
vivekworks/learning-to-code
/4. Discovering Computer Science/Python/Chapter 4 - Growth And Decay/Exercises 1/exercise411.py
450
4.0625
4
""" Purpose : Print integers from 0 to 100 Author : Vivek T S Date : 29/10/2018 DCS, Python introduction """ def print100(): """ Description: Print integers from 0 to 100 Parameters: None Return value: None """ for integer in range(0, 101): print(integer) def main(): """ Description:...
46084e955532d2daa4ae973e87ae8efc374c9c3a
mscwdesign/ppeprojetcs
/recebendo_dados_usuario.py
1,236
4.375
4
""" Recebendo dados do usuario input() -> Todo dado recebido via input é do tipo String Em Python, string é tudo que estiver entre: - Aspas Simples; - Aspas duplas; - Aspas simples triplas; - Aspas duplas triplas; Exemplos: - Aspas simples -> 'angelina' - Aspas duplas -> "Angelina Jolie" - Aspas simples triplas -> '...
f4606ea1c04c2ac9871362a76bb13ecdd79b36e3
dileepmenon/HackerRank
/Python/Tutorials/Cracking_the_Coding_Interview/Arrays_Left_Rotation/solution.py
235
3.546875
4
#!bin/python3 def array_left_rotation(a, n, k): return a[k%n:] + a[:k%n] n, k = map(int, input().strip().split(' ')) a = list(map(int, input().strip().split(' '))) answer = array_left_rotation(a, n, k); print(*answer, sep=' ')
b9988fddabeabfbb3b10b79d68ee0e03c1552a54
AlinesantosCS/vamosAi
/Módulo - 2/Módulo 2-4 - São tantas emoções, bicho!/fila_POO.py
580
3.546875
4
class Fila: def __init__(self): self.fila = [] def entrar(self,nome): self.fila.append(nome) def sair(self): self.fila.pop(0) supermercado = Fila() supermercado.entrar('Eduardo') supermercado.entrar('Maria') supermercado.entrar('Luiz') print(superm...
6191cea0fe07c87783dba5ab16f152ab22be675c
vkvasu25/leetcode
/linked_list/leetcode_reverse_list.py
1,228
4.09375
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def print_list(self, head): current = head out = 'here is our list: \n' while current: out += str(current.val) + '-->' ...
0754ba5a92cb52001833501285c70c3d4c8e081e
sylvainpelissier/PyPDF2
/Scripts/booklet.py
2,211
3.671875
4
#!/usr/bin/env python """ Layout the pages from a PDF file to print a booklet or brochure. The resulting media size is twice the size of the first page of the source document. If you print the resulting PDF in duplex (short edge), you get a center fold brochure that you can staple together and read as a booklet. """ ...
df8a286f6d7ad9616cc298de4d5cbb54ac5bd422
faneco/Programas
/Curso_Online/aula31.py
276
3.8125
4
lista = [1, 2, 3, 4] print (lista) indice = int(input('Digite o indice a ser removido: ')) ''' print ('Elemento: ', lista[indice]) b = [] for i in range (len(lista)): if i != indice: b.append(lista[i]) print (b) ''' print ('O elemento: ', lista.pop(indice)) print (lista)
b1154cbb6bd3d1f0b8140f6384490868ed3b8fb6
mrHickman/CS480_IBTL_Compiler
/CS480_Compiler/src/lexicalAnalyzer.py
7,655
3.625
4
''' Created on Jan 25, 2014 @author: mr_hickman Description: This is the primary tokenizing class. Using scanner to clean up the input from the file it traverses our dfa model to determine what attributes a token requires and produces the tokens. ''' ''' regular expression for each of the strings = ^"[...
36fc57ec98bdc8ec15141afa9554e62868845b0d
Justincw04/GameDesign
/Chapter 1/pyramid.py
922
4.03125
4
#Justin Cortez Wartell x=0 #controls where it wil finish #will break if number is over 10 y=10 for line in range(x,y): #mkae sure each number is on a diffrent line print() #both loops uses line to control flow for space in range (9-line): #prints spaces on first side print(" ",end='') fo...
ce08d5ce11d416ab5243fad87bf93df2e986dda4
MarkMoretto/python-examples-main
/recursion/string_range.py
1,644
4.21875
4
""" Purpose: Date created: 2021-08-08 Contributor(s): Mark M. """ #!/usr/bin/env python # -*- coding: utf-8 -*- from typing import Iterator def srange(start: int, stop: int = None, step: int = 1) -> Iterator: """Simple recursive generator that returns numeric values as a string type. Should be a dro...
d6c2e40550f3229ce26a3ebe08c5451c80280e5b
MirrorN/NLP_beginner
/LSTM_GRU/TextLSTM.py
4,323
3.765625
4
""" 任务: make、 need、coal 等等每个单词都被看做是一个字符序列,使用 LSTM 来通过前三个字符预测最后一个字符 例如 使用 mak -> e 所以在预测的时候也就相当于一个分类问题 ,类别的数量就是所有的字符的数量 26 Pytorch 建立 LSTM 使用 torch.nn.LSTM() def __init__(self, input_size: int, hidden_size: int, num_layers: int = ..., bias: bool = ..., b...
65284feaada14466996a1d3988d23fdfd0c24998
spemer/study_python
/fruitCalc/getFruitNumber.py
676
3.796875
4
APPLE = 2000 GRAPE = 3000 PEACH = 1000 #####GET TOTAL AMOUNT##### def TOTALAMOUNT(getAppleQty, getGrapeQty, getPeachQty): fruitAmount = getAppleQty + getGrapeQty + getPeachQty return fruitAmount #####GET TOTAL PRICES##### def TOTALPRICES(getAppleQty, getGrapeQty, getPeachQty): ApplePrices = getAppleQty...