blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
69c0fde401c90569af58c21ef307a215d20b03af
NishchaySharma/Competitve-Programming
/Codechef/GCD LCM.py
339
3.65625
4
#GCD * LCM = product of the numbers! t=int(input()) for i in range(t): a,b=map(int,input().split()) rep1=a; rep2=b while(True): if a==0 or b==0: break elif a>b: a%=b elif a<b: b%=a gcd=b if a==0 else a lcm=int(rep1*rep2/gcd) ...
df1f3eda1900867471f88db1c7cd24a927bb36cf
Asish-Kumar/Python_Continued
/Example2.py
623
4.125
4
# principle_amt = float(input("Input principle amount: ")) # time_yrs = float(input("Input number of yesrs: ")) # interest = float(input("Input interest rate: ")) # while time_yrs: # time_yrs -= 1 # principle_amt += interest * principle_amt / 100 # # print("The final amount is {}".format(principle_amt)) #######...
ae39e324588c14d3714e24f5a13d6436c665839a
angela-xu/python-edX6001
/lab6/part1_encryption.py
5,079
4.3125
4
import string import random WORDLIST_FILENAME = "words.txt" # ----------------------------------- # Helper functions # def loadWords(): """ Returns a list of valid words. Words are strings of lowercase letters. Depending on the size of the word list, this function may take a while to finish. ...
039dc61912d52df5726edfd2704faaf64e5bfeb7
Tyfani21/Blue-EdTech
/Módulo 1 - Lógica de Programação/Aula 08/Exercício 1 Tuplas e Listas.py
471
4.03125
4
# 1- Dada a lista L = [5, 7, 2, 9, 4, 1, 3], escreva um programa que imprima as seguintes informações: # a) tamanho da lista. # b) maior valor da lista. # c) menor valor da lista. # d) soma de todos os elementos da lista. # e) lista em ordem crescente. # f) lista em ordem decrescente. l = [5, 7, 2, 9, 4, 1, 3] print...
82b3b40ba36876bae2431ab58a4394ba86f6d424
emarinhoss/emssamath583
/homeworks/homework2/taylor.py
885
3.84375
4
""" Module containing approximate functions using N terms of the Taylor series. """ import numpy as np def exp(x, N=20): """ Approximate exp(x) using N terms of the Taylor series. """ # first term: term = 1. partial_sum = term for j in range(1,N): # j'th term is x**j / j! whic...
1a7773c3a9c626897c30af21d68c373fd743bb2d
sakurasakura1996/Leetcode
/leetcode未归类题目/problem70.py
388
3.75
4
"""" 70.爬楼梯 经典问题。我们可以用动态规划或者递归,但是递归重复计算过多了 """ class Solution: def climbStairs(self, n: int) -> int: ans = [0] * (n+2) ans[1] = 1 ans[2] = 2 for i in range(3, n+1): ans[i] = ans[i-1] + ans[i-2] return ans[n] solu = Solution() ans = solu.climbStairs(2) print(ans...
6dc85475642a51b5bf79163e7d0f4c4898140015
fatihkgm/mobileApplication-react-fench-id
/Desktop/Desktop/Semester5/AppliedScience/Python Programming/Week 05-Lecture/Lecture 05 Total Code/week_05_13_iterative.py
391
3.890625
4
""" def add_numbers(upper): total = 0 for number in range(upper + 1): total += number return number """ def add_numbers(upper): if upper == 0: return upper else: return upper + add_numbers(upper - 1) def main(): total = add_numbers(5) # total = 15 ...
640590b840c640ae16e11e3ea81f04d38a48f4b0
szwestekPythoneer/chaturanga
/graphic.py
1,701
3.71875
4
from tkinter import * from board import * from random import * root = Tk () root.title ('CZATURANGA') class BoardButton: def __init__(self, text, color, row, column): self.text = StringVar () self.text.set (text) self.color = color self.button = Button (root, textvariable=self.text...
30e2f9f749b5b9a5719fbce74f07119bf16767d4
1velina/bikeshare
/bikeshare.py
7,462
4.25
4
import time import pandas as pd import numpy as np CITY_DATA = { 'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv' } months = ['january', 'february', 'march', 'april', 'may', 'june'] days_of_week = ['monday', 'tuesday', 'wednesday', 'thursday', ...
dc3c7eb82165afdafd8bf06251f6df4fc528e9e3
FatosDefneDemir/Veri-Bilimi-devlerim
/python temeller ödevim.py
369
3.734375
4
#!/usr/bin/env python # coding: utf-8 # In[22]: anapara=1000 b= 12/100 gün=7 print(anapara*(1+b)**gün,"$") print("anapara ve faiz toplam tutarıdır.") # In[24]: a=1000 b="%12" c=1210.68 metin="Hafta başında {} dolarlık bitcoin aldığımızda günde ortalama {} kazançla, bir hafta sonunda {} dolar kazanırdık" print(me...
2c15cc112d7042a937522ccd55a983cfafc84f3d
AdamZhouSE/pythonHomework
/Code/CodeRecords/2670/59140/312385.py
116
3.578125
4
import math t=int(input()) for _ in range(t): temp=int(input()) print(pow(2,int(math.log(temp,2))+1)-temp-1)
6921bb2c115a4877128eaed2ed628f2a5a349482
Prav-Virdi/Python
/cdl-python-lab/string_help.py
176
3.921875
4
x = "infoeducatie" if x == "rosedu": print("miau miau") else: print("cutu cutu") x[0] x[1] x[-1] x[-2] x[3:] x[4:-2] x.replace("e", "#") len(x) "educat" in x
559a1496557ce93f1f1dc4d70a838d965c4f965f
AnthonyBriggs/Python-101
/hello_python_source_py3/chapter 10/mud-0/player.py
3,265
3.546875
4
import random import shlex class Player(object): def __init__(self, location): self.name = "Player" self.description = "The Player" self.location = location self.location.here.append(self) self.playing = True self.hit_points = 3 self.inventory = [] s...
7d27bdef7b0c9bf5d4a4ba09823cb9e012f9195c
linchuyuan/leetcode
/constructBinaryTree.py
1,481
3.78125
4
#given inorder traverval array, construct the tree class binaryTree(): class node(): def __init__(self, data): self.data = data; self.right = None; self.left = None; def __init__(self,data): self.root = self.node(data); def add(self,data): stack = [self.root]; while len(...
5c2d16823c088ed99a264199217df74cca5582c6
xuyingnan90/pythonpractice
/day10/zidian.py
1,993
3.53125
4
''' 字典(类似js中的对象) info={ "k1":"v1", "k2":"v2" } value可以是任意值 列表不可以作为key 但元组可以 字典不可以做KEY 布尔值可以作为KEY,但key里不能有1或0 python3.6中 字典有序 之前版本字典无序 ***比较常用的方法:keys() values() items() get() update() ''' info = { "k1": 18, 2: True, 1: 333, True: 12, "k3": [ 11, [], (), 22, 33, { "kk1": ...
1cf61bc04a8068909c587c09025161633467ebcb
manmeet17/Competitive-Coding
/Codechef/Sept18/bdshuffle1.py
526
3.546875
4
n=int(input()) if(n==1): a=[1] elif n==2: a=[1,2] elif n==3: a=[2,1,3] elif n==4: a=[2,1,4,3] elif n==5: a=[2,1,4,5,3] elif n==6: a=[2,3,4,1,6,5] elif n==7: a=[2,3,1,5,6,7,4] elif n==8: a=[2,3,1,5,6,7,8,4] elif n==9: a=[2,3,4,5,6,1,8,9,7] elif n==10: elif n==9: elif n==10: el...
fdf75f1eb4123ac782d9a2ed4ea92f068f4c88b7
Beniyu/project-complex-members
/Location.py
598
3.78125
4
class Location: def __init__(self, x, y): self.x = x self.y = y def set_location(self, value_name, value): if value_name == "x": self.x = value elif value_name == "y": self.y = value def set_x(self, x): self.x = x def set_y(self, y): ...
e65ca3a4dfed95383d824218b9e40a3a9b2c2a57
flaviowu/ProjetoZ
/main.py
6,201
4.125
4
import personagens import location import random # função para printar qualquer menu recebendo uma lista, pedindo input da escolha e devolvendo uam str com a escolha def menu(listaOpcoes): print("-=-=-=-=-=-= Menu =-=-=-=-=-=-") opcoes = enumerate(listaOpcoes, 1) for i, v in opcoes: print(f"[{i}]...
044b06fda913253faaa6ac13b30308aa18c7aa47
th3n0y0u/C2-Random-Number
/main.py
577
4.4375
4
import random print("Coin Flip") # 1 = heads, 2 = tails coin = random.randint(1,2) if(coin == 1): print("Heads") else: print("Tails") # Excecise: Create a code that mimics a dice roll using random numbers. The code of the print what number is "rolled", letting the user what it is. dice = random.randint(1,6) ...
46620e54cdd7d73cd4a5a81f9ef90ba2190443dc
bryanee23/Advanced-Python-Programming
/Lab 5/LinkedStack.py
755
3.625
4
from Node import Node from AbstractStack import AbstractStack class LinkedStack(AbstractStack): def __init__(self): self._items = None self._size = 0 AbstractStack.__init__(self) def clear(self): """empty the stack""" self._items = None self._size = 0 def push(self, item): """add to...
586d6718256d79526278b6c386d8469d2c192a4f
a313071162/letcode
/letcode_37_解数独.py
2,962
3.859375
4
# -*- encoding: utf-8 -*- """ @File : letcode_37_解数独.py @Time : 2020/9/15 下午2:43 @Author : dididididi @Email : @Software: PyCharm """ class Solution(object): """ 看到这道数独题,心里已经觉得其是使用回溯法来实现 看到难度,害怕呀 首先我们要了解数独游戏是横竖不能出现相同元素,且相同方格也不能有相同元素 但是还是不知道从何处下手,这题直接去看解题思路去了,因为不想花太多时间 设计的很巧妙,自己完全不会...
6b28aa690b2b78100f19df7ef477aa47df30df66
wajeshubham/Linked-list
/linked_list.py
3,102
4
4
class Node: def __init__(self, head=None, next=None): self.head = head self.next = next class LinkedList: def __init__(self): self.head = None def insert(self, data): node = Node(data, self.head) self.head = node def length(self): itr = self.head ...
a3fc95fa904670303cb3707fc9fdfa2be5ef24c8
mrcszk/BOIKWD
/Lab 03/saport/simplex/solver.py
9,042
3.796875
4
from copy import deepcopy from . import model as m from .expressions import objective as o from .expressions import constraint as c import numpy as np class Solution: """ A class to represent a solution to linear programming problem. Attributes ---------- model : Model ...
7bc4e5aa27c66523ee2678189e4edf5841d7ca46
BayanbaevIlyas/Lesson1
/Lesson2/Lesson3/cont7 — копия.py
429
3.859375
4
pas = input('Введите пароль ') degit (1, 2, 3, 4, 5, 6, 7, 8, 9, 0) letters = ('a' 'd','e', 'r', 'g', 'f', 's', 'k', 'l', 'j') hasDigit = False hasLetter = False for sym in pas: if sym in Digit: hasDigit = True if sym in Letters: Letter = True if len(pas) >= 8 and hasDigit == True and hasLette...
554d22311ca52499dc10e01e826330dfe9c0c372
unitedfan1986/test
/Files/2.21.21.py
1,226
3.75
4
class Temperature: def __init__(self, celsius=None, fahrenheit=None, kelvin=None): self._celsius = celsius self._fahrenheit = fahrenheit self._kelvin = kelvin @property def celsius(self): if self._celsius is not None: return self._celsius elif self._fahr...
3c57a04b38e6e7e219ef7efb106c426ea269b4d7
maqnius/oops17
/U1/src/aufgabe_2.py
1,253
4.0625
4
""" Aufgabe 2 --------- Stefaan Hessmann Mark Niehues Jaap Pedersen Calculates different sums, choosen by the user, and prompts them. """ # Definition of functions # The end of the sum is passed as an argument def sum_1(maximum): sum = 0 for i in range(1, maximum+1): sum += i return sum def s...
744971705a3b2aa9a0e7bcf6e6217dd469d1fe49
pallavigs9/python_codes
/CodeAndTest/Src/SumDigit.py
321
3.9375
4
#Return sum of the absolute value of each of the number's decimal digits #IP -10 #OP 1 def sum_digits(number): result = 0 for i in str(number): if i.isdigit(): result = result + int(i) return result print sum_digits(-32) ''' Shortest Soluation sum(int(d) for d in str(abs(number))) ''...
6f560a9d5fe0fa92564b58cbd9e6a718b6980ed1
DIMITRY-GALYAS1/Laba-2.10
/tasks/individual_1.py
1,804
3.75
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Напишите функцию, принимающую произвольное количество аргументов, и возвращающую сумму аргументов, расположенных между первым и последним нулевыми аргументами. Если функции передается пустой список аргументов, то она должна возвращать значение None. В процессе решения...
3c45e6b9d4f0306d404fe682cb0de9b6b9a09150
tmgsr02/Summer-17
/1 Programming/labs/Lab 4/squares.py
375
3.859375
4
from math import sqrt def is_square(n): return float(sqrt(n)) == int(sqrt(n)) def squares(seq): """Returns a new list containing elements of the original list that are perfect squares. >>> seq = [49, 8, 2, 1, 102] >>> squares(seq) [49, 1] >>> seq = [500, 30] >>> squares(seq) [] ...
0e26a9d0436bef1ca8d26300830ec742a80f4045
tdefriess/cs-module-project-recursive-sorting
/src/sorting/sorting.py
1,596
4.15625
4
# TO-DO: complete the helper function below to merge 2 sorted arrays def merge(arrA, arrB): elements = len(arrA) + len(arrB) merged_arr = [0] * elements # Your code here # index trackers for arrA and arrB a_idx, b_idx = 0, 0 for i in range(len(merged_arr)): # if index reaches end of one...
70b6f766066ea8c6062cd951ab3ec9226d4cb175
shantanu609/Leetcode
/longest-word-in-dictionary/longest-word-in-dictionary.py
1,510
3.890625
4
from collections import deque class TrieNode: def __init__(self): self.childrens = {} self.isEnd = False self.word = '' class Trie: def __init__(self): self.root = TrieNode() def _insert(self, word): node = self.root for char in word:...
8864399eb64be28d2f95ebb3671528545bdc857a
devsungmin/Algorithm-Python
/BackJoon/Python/2751.py
702
3.984375
4
""" 문제 : N개의 수가 주어졌을 때, 이를 오름차순으로 정렬하는 프로그램을 작성 하시오 입력 : 첫째 줄에 수의 갯수가 주어지고 둘째줄부터 N개의 수가 주어진다. 이 수는 절대 값이 1,000,000보다 작거나 같은 정수이고 중복되지 않는다. 출력 : 첫째 줄 부터 N개의 줄에 오른차순으로 정렬한 결과를 한 줄에 하나씩 출력한다. """ def sorting_num(num_list): num_list = sorted(num_list) return num_list def main(): cnt_num = int(input()) num_list = l...
3e09bfd3dbe9479da6a8c86594382ff0610aa4a1
alikewater/awesome-pandas-practice
/lesson017/017.py
541
3.609375
4
import pandas as pd import matplotlib.pyplot as plt def score_validation(row): try: assert 0<=row.Score<=100 except: print('#',(row.ID),'\t student ',(row.Name),' has invalidate score ',(row.Score),'.') def score_validation01(row): if not 0<=row.Score<=100: print('#', (row.ID), ' s...
51f087511990669a46d97a9fcc66b6986bb2e1de
cllovis/APP
/analizador_computador.py
1,259
3.515625
4
import platform from time import sleep analisador = int(input("Informe '[1] + ENTER' para analizar ou '[0] + ENTER' para sair:")) a0 = platform._node() b0 = platform.machine() c0 = platform.processor() d0 = platform.system() d1 = platform.version() d2 = platform.release() d3 = platform.win32_edition() e0 = platform.arc...
b32468459fa940d3f7bd2446a52d056a0460318f
JSlowgrove/Bouncing-Box
/bouncing_box/girder.py
5,030
3.9375
4
"""A module that contains the class and functions for the Girder.""" import pygame class Girder: """ This class contains all of the functions and variables that is used by the Girder. """ # The Girder's sprite. Universal to all instances of Girder. sprite = pygame.image.load('assets/images/gir...
24c924e3a0ad0d422935e06ba0670672bea4661b
DanyloTrofymov/LabsPy
/Lab 6/Lab_6.py
866
4.0625
4
import math def degree(angle): return (angle * math.pi) / 180 def square(x1, y1, angle1): return (x1 * y1 * math.sin(degree(angle1))) / 2 qmax = float(0) n = int(input("Введiть кiлькiсть трикутникiв: ")) for i in range(1, n+1): x = float(input("Введiть довжину першоi сторони трикутника: ")) y = fl...
7ef13d4c57cea5a671371ff94ec44c739d108fe0
fesasabil/learn-python
/regex.py
1,551
4.625
5
# A regular expression in a programming language is a special text string used for describing a search pattern. It is extremely useful for extracting information from text such as code, files, log, spreadsheets or even documents. # While using the regular expression the first thing is to recognize is that everything i...
d1aad26f76aa3f56a2c0ad757386d86bdf555bc7
shelyao/LeetCode2020
/leetcode/editor/en/[4]Median of Two Sorted Arrays.py
1,242
3.828125
4
# Given two sorted arrays nums1 and nums2 of size m and n respectively, return t # he median of the two sorted arrays. # # # Example 1: # # # Input: nums1 = [1,3], nums2 = [2] # Output: 2.00000 # Explanation: merged array = [1,2,3] and median is 2. # # # Example 2: # # # Input: nums1 = [1,2], nums2 = [...
d674276358ab4bb34af315e416c63c7192bae4bf
cjcraigportfolio/Python
/Object Oriented Programming/OrderPizza.py
1,418
3.765625
4
if __name__=='__main__': import doctest print( doctest.testfile( 'OrderPizzaUnitTest.py')) class Pizza: def setSize(self,size): self.s = size def __init__(self,size='M',toppings=[]): self.s=size self.t= set(toppings) def __repr__(self): return f"Pizza('{...
ac3f959f8d12d6aaac7d66bd454da2b199083802
blondfisch/CSE
/notes/Alexander Fischer - MadLibPt2.py
2,538
4.15625
4
wordList = [] print("Welcome to Madlibs! I hope you're feeling creative, because only you have the power to make a great story!") wordList.append(input("Submit an adjective.")) # 0 wordList.append(input("Please submit a verb ending with s:")) # 1 wordList.append(input("Please submit a verb:")) # 2 wordList.append...
b2c0087ea3bcefb065004dad26d76a22071daf66
rodrigomoraes2012/CSV-Updater
/main.py
1,799
3.5625
4
import csv # Main List, where all records will be stored csv_list = [] # Output List, where duplicated rows will be replaced and updated by the last one output_csv_list = [] replacingColumns = [2, 3, 4] output_writer = csv.writer(open("output.csv", "w"), delimiter=';') print('----------------------') with open('fir...
9ca655500426be9420021ceeb92748f7a8b5acf7
aluramh/DailyCodingProblems
/DynamicProgramming/2.how_sum.py
3,388
4.375
4
# https://youtu.be/oBt53YbR9Kk?t=5370 # Input: # - target_sum # - array of numbers # Output: # - Array that adds up to target_sum OR null if not possible # NOTE: - If multiple combinations, return a single one def how_sum_recursive(target_sum, numbers): def helper(target_sum): # We return an empt...
5055d1fd675a059ad7efbe313d77f9a03d718881
ashrielbrian/coursera-algorithms-specialization
/02 Data Structures/02 Week 2/parallelization-optimised.py
3,741
3.890625
4
# python3 # Algorithm mimics a set of a number of available parallel worker processes and jobs presented to it. # Algo efficiently assigns the workers to the jobs via a (priority) min-heap queue method. # Priority is given: 1. to the first available worker; 2. to the lowest-indexed worker # Optimised by: Removing the...
6a495c9fea07a43ef3e43669147aba2bdf4bd4c2
morgan5005/trashmyspace
/flask/bin/calculate_route.py
1,157
3.5625
4
import OptimalRoute def main(): addresses = ['3610+Hacks+Cross+Rd+Memphis+TN', # depot '1921+Elvis+Presley+Blvd+Memphis+TN', '149+Union+Avenue+Memphis+TN', '1034+Audubon+Drive+Memphis+TN', '1532+Madison+Ave+Memphis+T...
25395b1d91391d16f516e46996c595ef9c3d34c7
alishalopes87/hb-coding-challenges
/hops.py
501
4
4
# Given an integer list where each number represents the number of hops you can make, # determine whether you can reach to the last index starting at index 0. # For example, [2, 0, 1, 0] returns True while [1, 1, 0, 1] returns False. def hops(lst): hops = 1 for i in range(len(lst)-1): print("current",lst[i]) h...
e5716c59801aa50c0657c8f4120b60d6c8dfef5e
i1988b/Self_python
/hello_world.py
181
3.859375
4
print("Hello Python world") ### 变量 message = "Hello Python world" print(message) message = "Hello Python world!" print(message) print(message.upper()) print(message.lower())
bcf107802738a53952e056c9cd2ea6ef63541ad4
AlexxSandbox/CoffeeMachine
/coffee_machine.py
3,870
4.1875
4
class Coffee_machine: COFFEE_REСIPE = {'espresso':(250, 0, 16, 1, 4), 'latte':(350, 75, 20, 1, 7), 'cappuccino':(200, 100, 12, 1, 6)} def __init__(self): self.coffee_menu = [] for coffee in Coffee_machine.COFFEE_REСIPE: self.coffee_menu.append(coffee) ...
7d4c560747a2c1b05292037cfaecdd6d2272ec4c
Thirupathiswamythanniru/swamy
/kinteger.py
205
3.609375
4
sum = 0 l=[] n = int(input("Enter a number")) k = int(input("Enter a number")) for i in range(n): g = int(input("Enter %d element"%(i))) l.append(g) for i in range(k): sum=sum+l[i] print(sum)
51f63a7402cea0af773e7c3ef6347ccbaccd3be4
294150302hxq/python_learn
/leetcode/36_valid_sudoku.py
1,179
3.578125
4
#!/usr/bin/env python # -*- coding:utf8 -*- """ @author:huang xiaoqin @time: 2020/12/21 @desc: """ class Solution(object): def isValidSudoku(self, board): """ :type board: List[List[str]] :rtype: bool """ rows_check = [] for i in range(9): rows...
f3c9ce3774b3739e7745f7ac488950fc15b6cde3
maccergit/Rosalind
/Algorithmic Heights - DDEG/DDEG/001.py
1,558
3.578125
4
# coding: utf8 """ Double-Degree Array Given: A simple graph with n≤10^3 vertices in the edge list format. Return: An array D[1..n] where D[i] is the sum of the degrees of i's neighbors. Sample Dataset 5 4 1 2 2 3 4 3 2 4 Sample Output 3 5 5 5 0 Roll our own adjacency set approach. """ def processData(inFil...
f72f10e4f2ea13b0d554782376ed91b02785d7ec
Sandy4321/nltk-book
/2_accessing_text_corpora_and_resources/stop_words.py
436
3.515625
4
from nltk.corpus import stopwords , brown def not_common_words_fraction(words): not_common = set( [w.lower() for w in words if w not in stopwords.words("english") ]) return len(not_common) / float( len(words) ) #print [(genre , not_common_words_fraction( brown.words(categories = genre))) for genre in brown.categori...
80c8805e614ba8b5b600e0f0ad859a1897278576
lauramiller512/Beginner-Projects
/input2.py
128
3.59375
4
name = "john Snow" if name == "Arya Stark": print("Valar Morhulis") elif name == "John Snow": print("You know nothing") else: print("Carry on")
6984bbb352b5890f348f8bac3f2e9c58aff18a48
JaeCoding/keepPying
/foo/lc/leetcode/editor/cn/[199]二叉树的右视图.py
1,514
3.953125
4
# Given a binary tree, imagine yourself standing on the right side of it, return # the values of the nodes you can see ordered from top to bottom. # # Example: # # # Input: [1,2,3,null,5,null,4] # Output: [1, 3, 4] # Explanation: # # 1 <--- # / \ # 2 3 <--- # \ \ # 5 4 ...
5ae28aa7ab52d4cb1ffe31f7998ea3919df72bc4
diaokeshijian/pystarter
/src/demo/range.py
195
3.671875
4
x = list(range(101)) # sum = 0 for i in x: sum = 0 sum = sum + i print(sum) L = ['Bart', 'Lisa', 'Adam'] flag = 0 while flag < 3: print('Hello, ' + L[flag]) flag = flag + 1
bba0984cdb7f266846e99593428205cfbe0f5f1b
waabiisaabii/adventOfCode2020
/day_5/solve.py
1,411
3.703125
4
from typing import List mapping = { 'F': 'left', 'B': 'right', 'L': 'left', 'R': 'right' } def binary_search(actions: str, upper: int) -> int: left = 0 right = upper for i in range(0, len(actions)): mid = int(left + (right - left) / 2) action = mapping[actions[i]] ...
b8b196e668677ccc861fec5cf42787403e331d9a
AilingLiu/hackerrank
/kaprekar.py
1,027
3.625
4
#!/bin/python3 import math import os import random import re import sys # Complete the kaprekarNumbers function below. splitN = lambda x: list(map(int, list(str(x)))) getNum = lambda arr: int(''.join(map(str, arr))) def checkNum(val): d = len(splitN(val)) power2 = splitN(val**2) #print('power2 list: ',...
c2207414e42bce58d1affc6353807a5cc29e326c
mayumi04/laughing-memory
/kadai305_01.py
1,683
3.78125
4
from abc import ABCMeta, abstractmethod class Car: def __init__(self, type, nenryo=0, battery=0): self.type = type self.nenryo = nenryo self.battery = battery def run(self, gasoline_kaitensu=0, motor_kaitensu=0): kaitensu = gasoline_kaitensu + motor_kaitensu # 距離 = 回転す...
81e04d624110a0ce38508a6d91d4edd57c1c9448
yukandai/lab
/alumnos/4140-ossandon-cintia/exercises/invierte.py
232
3.53125
4
#!/usr/bin/python3 import sys #leer argumentos #input = sys.argv #leer desde redireccion input = sys.stdin.readlines() result = "" for i in input: x = i.split() for p in x: result += p[::-1] + " " print(result)
41e63cabfc2138f6e65306cbec9e0265b49e92c9
mlunalover/Python-The-Hard-Way
/ex15.py
767
3.96875
4
#Says hey I want to use the from and import module argument from sys import argv #Using script name (ex15.py) then the filename (ex15_sample) complete the argument and allow it to be read. script, filename = argv #Says hey file the text document requested in the above argument. txt = open(filename) #Says hey print t...
5ba5288e380f617c0328793fa806386fbaadeebe
Orderlee/tjoeun
/pycharm/ch03/q02.py
307
3.8125
4
#1~1000 3의 배수의 합계, while 사용 n=int(input('숫자를 입력하세요:')) result=0 i=0 while i <n: #조건식이 True일 동안 반복 처리 i=i+1 if i % 3 == 0: result=result+i #합계를 누적 print('{}부터 {}까지 3의 배수 합계={}'.format(1,n,result))
b9b6a4096763a2cce1049b3927f32b52dbf3f47d
kushalppp/Python-Ass4
/Q9.py
236
3.84375
4
#!/usr/bin/python3 y=[1,2,3] x=[4,2,6] q=len(y) w=len(x) for a in list(range(q-1)): for b in list(range(w-1)): if y[a]==x[b]: print(y[a],x[b],"common in two list") print(x,y) Output:- 2 2 common in two list [4, 2, 6] [1, 2, 3]
49bae68300460a7028e0188164c484d562741fe5
swm82/AdventOfCode2020
/Day3/Day3.py
619
3.78125
4
def find_trees(slope_x, slope_y, rows): row_length = len(rows[0]) i = 0 count = 0 for r in range(0, len(rows), slope_y): i = i % row_length if rows[r][i] == '#': count += 1 i += slope_x return count if __name__ == '__main__': data = [] with open('day3.tx...
d10d5be2f18c888d19f88caf0143f5ed7db11a25
spacyk/knight-fight
/knight_fight/element.py
4,936
3.6875
4
class Element: """Base class for Knight and Item""" def __init__(self, name, symbol, row, column): self.name = name self.symbol = symbol self.row = row self.column = column def __repr__(self): return f'{self.name}' class Knight(Element): def __init__(self, name...
249e027f8512c1e2af42b8a35243701dec0e2f79
Lunchesque/udemy
/fullpythontutorial/debugging/try2.py
487
4.03125
4
# try: # num = int(input("Please inter a number: ")) # except: # print("This is not a number") # else: # print("Im the else") # finally: # print("im running no matter what happened") while True: try: num = int(input("Please inter a number: ")) except ValueError: print("This is n...
01f510310b6adeaf406b3fe8a233cea7545084e2
Shivvrat/Collaborative-Filtering
/train_collaborative_filtering.py
6,081
4.03125
4
import convert_data_to_array import numpy as np import math def train(data): """ This is the function used to train the model :param data: This is the training data :return: We return the mean of each user in the data """ mean_vote_train_data = calculate_mean_vote_train(data) r...
8dded7cce5bc3efbcb73fcfdace14269c8e99e59
jrubin11/neural_network
/Logistic_Regression.py
7,075
4.28125
4
#!/usr/bin/env python # coding: utf-8 # # Maching Learning - Logistic Regression # # CS440/640 # # # <br> This code is about how to implement Logistic Regression # # # In[1]: # Import Python libraries import numpy as np # numpy is th...
77ff94b8b17eaf1c20a662ae5f8c6c4118ee9335
jxhangithub/leetcode
/solutions/python3/542.py
919
3.515625
4
class Solution: def updateMatrix(self, matrix): m, n = len(matrix), len(matrix and matrix[0]) for i in range(m): for j in range(n): if matrix[i][j] != 0: matrix[i][j] = float("inf") if i > 0 and matrix[i - 1][j] + 1 < matrix[i][j]: ...
26a99e43f7badd19c46a40759627275f322a8615
algator/Python
/Pong.py
3,547
3.84375
4
# Implementation of classic arcade game Pong # http://www.codeskulptor.org/#user40_3eyQThAYsX_30.py ball_vel[0] = random.randrange(120/40, 240/40) ball_vel[1] = -random.randrange(60/40, 180/40) elif direction =="LEFT": ball_vel[0] = -random.randrange(120/40, 240/40) ball_vel[1]...
68ce55002cea70781558205c23d008f7e9302d22
athul-santhosh/Cracking-the-coding-interview-Python
/Chapter 2 Linked List/2.3 Delelte Middle.py
407
3.875
4
# cracking the coding interview # solution 2.3 # Delete the middle node Class Node(): def __init__(self,data): self.data = data self.next = None # we can use a runner and striker def deleteMiddle(self,n): if n is None or n.next is None: print("Invalid Node") temp = n.next n.d...
ad82741d66047f5e677196e4750d78df18d21042
Refuse0126/My-Python-Code
/Test/Python-cookbook/P1/4-5.py
1,367
3.78125
4
""" Date:2019.6.9 """ def fun4(): #1.4 heapq堆模块 import heapq nums=[-1,3,0,-5,6,1,4,25,20,23,8,-9] largest3=heapq.nlargest(3,nums) print(largest3) smallest3=heapq.nsmallest(3,nums) print(smallest3) print(min(nums)) heapq.heapify(nums) #列表元素以堆的形式排列,heap[0]始终是堆内最小的元素 print(nums[0]) ...
6f9275b6ae883edecab1285fc8a796884012c5a2
DhanyaSelvaraj/Python
/Basic of Regular Expression using meta functions.py
5,523
4.21875
4
Basic of Regular Expression using meta functions: >>> import re >>> result=re.findall(r"","Java and Python are programming language which is very simple to use") >>> print(result) ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '...
923b2119e9c398b683f5d09e7a86a7fd42c551e5
LeonardoJosedaSilveira/Curso-de-python
/Mundo 1/Desafio/034.py
234
3.765625
4
sal = float(input('Qual o seu salario? ')) if sal > 1250.00: print('Com o aumento seu salario sera R${:.2f}'.format(sal + (sal / 100) * 10)) else: print('Com o aumento seu salario sera R${:.2f}'.format(sal + (sal / 100) * 15))
5bd4d5b67ec96c066e3e9b36bd88ccff1a631942
PicciDavide/esercizi_lab
/esercizio_pag_190_26.py
472
3.71875
4
registro = {} registro_media = [] for i in range(2): nome = input("Inserire il nome dello studente ") while True: try: voto = float(input("Inserire il voto dello studente ")) break except ValueError: print("Si deve inserire un numero") registro[nome] = vo...
1a1919d9fd8cb4067029e279e032a0b3a0a0deed
ibby360/python-crash-course
/chapter7/no_pastrami.py
523
3.796875
4
sandwich_orders = ['pastrami','veggie', 'grilled cheese','pastrami', 'turkey', 'roast beef','pastrami',] finished_sandwich = [] print("We are run out of pastrami today") while 'pastrami' in sandwich_orders: sandwich_orders.remove('pastrami') print('\n') while sandwich_orders: current_sandwhich = sandwich_orde...
34150a9c6c21dec0f6e27ab4466a1dc621a3e938
happyhzr/leetcode
/83/main.py
1,051
3.640625
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def deleteDuplicates(self, head): if not head: return head pre = head current = head.next while current: if current...
07b0165f8d11b8f86ecdb59c052753fd5bba113e
adarshsaji/Computerised-adaptive-assesments
/mcq.py
5,372
3.5
4
#import random import xlrd #to read the excel file import time #to get the system time import get_detail import graph_gen option = ['A','B','C'] #to validate option input time_taken = [] #to store time taken per question # random_list = [] # def random_gen(total_ques):...
2f55a052fedfce884a9f9c964940f22b67dc738f
lidajav/Mission-to-Mars
/Mission_to_Mars.py
2,192
3.53125
4
#!/usr/bin/env python # coding: utf-8 import pandas as pd # Import Splinter and BeautifulSoup from splinter import Browser from bs4 import BeautifulSoup as soup # Set the executable path and initialize the chrome browser in splinter executable_path = {'executable_path': 'chromedriver.exe'} browser = Browser('chrome...
be023e506485c2f71e33b69266fa8cd40b5aa93e
Tkachmaxim/multyplication_table_simulator_DJANGO
/Trainer/modulle.py
1,439
3.578125
4
import random all_parameters = { 'permission': True, 'number_of_tasks': 0, 'action': '', 'total': 0, 'number_example': 0, 'mistakes': 0, 'total_for_save': 0, 'mistakes_for_save': 0 } task=[] gen_task=[] def choice_number(n,action): task.clear() if ac...
36d052310aef013dcf1cea8d61951f18f9362c6b
project-mlx/ADS
/LinkedList/LinkedList.py
2,292
4.28125
4
#Node class for storing data list element #and a key (next) for the next node of data class Node: def __init__(self, data): self.data = data self.next = None #Linked List class for creating the consolidated list and #the basic listoperations class LinkedList: def __init__(self): self.head = None ...
e3ad3bdeddb3839bc0fff1b6503c52ffeac50d35
taboyz/CI4003-NIDA
/week4/2-sumofpositiveodd.py
364
3.84375
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 6 18:44:48 2018 @author: kronprom """ input_int = int(input('Enter a positive integer')) def SumofAllOddSquares(a_int): SumOfSquares = 0 for i in range (1,a_int,2) : print ("{} = {}".format(i,i**2)) SumOfSquares += i ** 2 return SumOfSq...
883635f8731910b0f6bae64e31c7e100fabc58f1
Uzair-Fasih/Sebastian
/leviathon/Update_Munkres.py
885
3.734375
4
'Add functions to Leviathon Munkres\'s Dictionary' import json def entry(string): entryList = string.split('&sep&') fi = open("Munkres's_Dictionary", "r") existList = json.load(fi) fi.close() print(existList) print(entryList) existList.append(entryList); print(existList) f = open(...
87cd7309e4d76964b61979bd15bc23877e434448
PiGuy23/ThereminPi
/Testing/gpio-intest.py
478
3.734375
4
from time import sleep import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library GPIO.setwarnings(False) # Ignore warning for now GPIO.setmode(GPIO.BOARD) # Use physical pin numbering GPIO.setup(40, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Set pin 21 to be an input pin and set initial value to be pulled low (off) print(...
597590938eba572e33602990fa8a021968e21dee
lefterisKl/StockDataCrawler
/exploration.py
3,259
3.671875
4
import requests from bs4 import BeautifulSoup from bs4 import element page = requests.get("https://www.dataquest.io/blog/web-scraping-tutorial-python/") #html_code = page.content.decode("utf-8") .split("\n") #for line in html_code: # print(line) soup = BeautifulSoup(page.content, 'html.parser') #prettify how ...
f5edb96ae79dbc813ef8d77c97104b1a406a0294
gongkouzu/git-test
/python-test/hahaha.py
155
3.671875
4
import random time = 1 win = 0 while win < 3: user = input("请输入对应数字,石头(1)/剪刀(2)/布(3):") computer = random.randint(1,3)
6fd9692fb41d45ffeb6d0c46031c37368333a99f
alexlikova/Python-Basics-SoftUni
/7. Python Basics - More Exercises/2. Conditional Statements - More Exercises/07. Flower Shop.py
682
3.671875
4
import math number_magnolii = int(input()) number_zumbuli = int(input()) number_roses = int(input()) number_cactus = int(input()) price_present = float(input()) magnolii = 3.25 zumbuli = 4.0 roses = 3.5 cactus = 8.0 price_magnolii = magnolii * number_magnolii price_zumbuli = zumbuli * number_zumbuli price_roses = ro...
abdcf52178997bb922916d358709f0dc551ee701
sushant66/Python_Algorithms
/merge_sort.py
573
3.984375
4
#complexity O(nlogn) def mergesort(ls): if len(ls) == 1 or len(ls) == 0: return ls else: middle = (len(ls))//2 left = mergesort(ls[:middle]) right = mergesort(ls[middle:]) com = merge(left,right) return com def merge(left,right): sorted_list = [] i = 0 j = 0 while i<len(left) and j < len(right): ...
a27a0f09162574e43cc88fbf5469897cc8ec7a20
shiratsu/scikit-learn_test
/skutil.py
688
3.84375
4
# coding: UTF-8 import numpy as np import pandas as pd def makeFeatures(x): # 数値変数のスケーリング cn_num = ['age' ,'tenure' ,'execution.score' ,'cognitive.score' ,'social.intelligence' ,'compensation' ,'OT.hour' ,'joining.year' ...
a17a9eade6169db3f5ed92e1dc48f02428fe51fa
vysagh00/Python-programs
/Python_Prog/rough.py
1,871
3.75
4
# import random # from random import randint # def random(): # l = ["qwert","walj","spoof","gald","dernio","wally","asap","end"] # rand = random.randint(0,len(l)-1) # return l[rand] # def change_state(input,insert,current): # modified = " " # for i in range(len(input)): # if cur...
fa68bf4c16e7299edb72893783a5159196c9d26d
rahman-jcc/PyCharmProjects
/RandomChecks/StringCheck.py
649
3.890625
4
#!/usr/bin/python Str = "this is string example....wow!!!"; Str = Str.encode('base64','strict'); suf= "wow!!!"; print "Encoded String: " + Str print "Decoded String: " + Str.decode('base64','strict') print Str.endswith(suf) suffix = "wow!!!" print str.endswith(suffix) print str.endswith(suffix,20) suffix = "is" p...
da4f5aa5e8b42404b9120f8e6aa432b1cf7ac991
jriall/leetcode
/easy/number_of_good_pairs.py
789
3.71875
4
# 1512. Number of Good Pairs # Given an array of integers nums. # A pair (i,j) is called good if nums[i] == nums[j] and i < j. # Return the number of good pairs. # Example 1: # Input: nums = [1,2,3,1,1,3] # Output: 4 # Explanation: There are 4 good pairs (0,3), (0,4), (3,4), (2,5) 0-indexed. # Example 2: # Input:...
211732df48247c493b9884e7ffc526976b72602e
minzsiure/Encrypt-decrypt-ur-message
/ps4a.py
2,528
4.34375
4
# Problem Set 4A # Name: <your name here> # Collaborators: # Time Spent: x:xx def get_permutations(sequence): ''' Enumerate all permutations of a given string sequence (string): an arbitrary string to permute. Assume that it is a non-empty string. You MUST use recursion for this par...
2d4de777c840b65b851ddbc7ecc8605b51073ac4
gffryclrk/ThinkPython2e
/ch8/exercise8.6.py
242
3.953125
4
def find(word, letter, start=0): index = start while index < len(word): if word[index] == letter: return index index = index + 1 return -1 print('Index of \'l\' in \'hello\': ', find('hello', 'l', 1))
ddc9658029688c5c46ed8f9c4acf6f8f3ce198d1
ss2576/Algorithms_Geek
/Урок_1/lesson_1_8.py
842
4.25
4
# Определить, является ли год, который ввел пользователь, високосным или не високосным. # год, номер которого кратен 400, — високосный; # остальные годы, номер которых кратен 100, — невисокосные; # годы, номер которых кратен 4, — високосные. year = int(input('Введите год для определения его на високостность : \n')) ...
a8dbc0b3a91c09250f5511a6ad6a49b3652d94d8
AM-Kovalenko/OOP_Tutorial
/less9.py
1,824
3.53125
4
class Clock: __DAY = 86400 # количество секунд в одном дне def __init__(self, secs: int): if not isinstance(secs, int): raise ValueError("сек должны быть целым числом") self.__secs = secs % self.__DAY def getFormatTime(self): s = self.__secs % 60 # секунды m ...
5d56b6ea6f12baceba70ca2ebfdd6ea8ad771304
amaloun/projet-python
/operations.py
4,642
3.5
4
#!usr/bin/env python3 from math import sin, cos from point import point_aleatoire, Point from segment import Segment """ ce fichier contient toutes les fonctions qui realisent les operations mathematiques """ def symetrie_point(point, axe): """ renvoie la symetrie vertical d'un ponit """ ret...
2893f303f6a2371b03397915c1f9680341a5c844
DemetreJou/AdventOfCode2018
/8/solution.py
765
3.59375
4
import fileinput def parse(input) -> tuple: # from iterating over the input num_children, num_metadata = next(input), next(input) # find all children children = [parse(input) for _ in range(num_children)] # finding metadata of the children metadata = [next(input) for _ in range(num_metadata)] ...
65b3da41c150397ceaf9d2ba0b92bfe7b5b655d6
marcelcosme/URI
/PYTHON/1591(incomplete).py
1,262
3.546875
4
testes = int(input()) def contando(palavra_inicio, palavra_quero): quantidade = 0 for h in range(len(palavra_inicio) - len(palavra_quero) + 1): presenca = True for f in range(len(palavra_quero)): if palavra_quero[f] != palavra_inicio[f]: presenca = False if ...
cb86349aa8a849d5b9e8a3641cca210a796a4463
koking0/Algorithm
/BlueBridgeCup/Subject/2015/Province_C_C++_C/2/solve.py
206
3.5625
4
if __name__ == '__main__': ans = 0 for i in range(1, 10001): if str(i) in str(i ** 3)[-len(str(i)):]: ans += 1 print(f"num = {i}, num ^ 3 = {i ** 3}") print(ans)
5dfd24dd7f66845f43a20b047fa515b81623f3ea
HarshCasper/Rotten-Scripts
/Python/PDF_reorderer/PDF_reorder.py
3,037
4.09375
4
from PyPDF2 import PdfFileReader, PdfFileWriter def ifexists(total_pages, page_no): """ This function checks whether the given page number is in the specified range of total pages. :param total_pages: :param page_no: :return: True or False """ if page_no <= total_pages: return...
df3a369f7d4b0b7bc146175638a7a1a4362b5e1d
Gustavo-CRS/just-coding
/forca.py
1,586
3.8125
4
from os import system from time import sleep def limpar(): system("cls") def main(): limpar() palavra = input("Digite a palavra chave: ") erro_maximo = int(input("Digite o número máximo de erros: ")) limpar() palavra_secreta = list(palavra) letras_descobertas = [] er...