blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
0676c8e930dc6d33bccf0e54afc5e9b014341e6d
ramtur22/computersproject_Ram_Turkenitz
/main.py
4,681
3.78125
4
# Python final project # input file handling: #this function converts the file to a dictionary with the keys being the axis titles dx,dy,x,y lowercased. def input_handling(input_file): file1=open(input_file,'r') lines=file1.readlines() data_dict={} data_list=[] for line in lines: ...
126247ce93df225c34e2b484a22debc3d330343a
VishnuVardhanVarapalli/Applied_machine_learning
/cumulative_density_function.py
433
3.53125
4
import pandas import numpy import matplotlib.pyplot as plt import config if __name__ == "__main__": dataset = pandas.read_csv(config.TRAINING_FILE) data = dataset['applicantincome'] data = numpy.sort(dataset['applicantincome']) y = numpy.arange(1,len(data)+1)/len(data) plt.plot(data,y,m...
cfa6b0bc8087365a96f8373e91f418e17638e51e
EduFelix/Exercicios-Python
/ex011.py
299
3.8125
4
altura = float(input('Digite a altura da parede?')) largura = float(input('Digite a largura da parede?')) area = largura * altura ltinta = area / 2 print('A area da parede corresponde a {} \n e a quantidade ' 'de litros de tintas necessarios para pintar a parede é {}'.format(area, ltinta))
712ff4a282bf32bbe295a4c4262d4276b596c190
RodrigoMorosky/CursoPythonCV
/Desafios/des067.py
250
3.828125
4
n = 0 c = 1 while True: n = int(input('Digite um número para saber sua tabuada (número negativo para sair): ')) if n <=0: break for c in range(1,11): print(f'{n} x {c} = {n*c}') c +=1 print('Programa encerrado!')
473a6bfbe66a7e851c7c8bd4168a99d45153406e
NanLieu/COM404
/0-setup/1-basics/4-repetition/1-while-loop/7-factorial/bot.py
171
4.21875
4
print("Please enter a number.") num = int(input()) factorial = 1 while (num > 0): factorial = factorial * num num = num - 1 print("The factorial is",factorial,".")
2f8fc64f13566568ec70648da308a2b2a4767e24
mandychenze/Applied_Machine_Learning_Homework
/HW1/task12.py
275
3.609375
4
def fib(n): """ :type N: int :rtype: int """ if n==0: return 0 if n==1: return 1 if n==2: return 1 else: res = [1,1] for i in range(2,n): res.append(res[-1]+res[-2]) return res[-1]
d22cadfad68dd11e7ed455ebf18ce5c2f4e26a75
purohitdheeraj-svg/python
/linear_search.py
235
3.953125
4
def search_item(list_1, n): for value in list_1: if n == list_1[value]: return list_1.index(value) else: return -1 list_1 = [1,2,3,4,5] print(search_item(list_1 , 2))
3f5dfedecb13de859bfb889e36baca37df91fe5c
JSY8869/CodingTest
/JSY8869/CHAPTER 3/3-1/CodingTest3-1.py
990
3.59375
4
# CodingTest3-1 거스름돈 def coin(N, Coin_Count ,Coin_Value): # 입력 받은 거스름 돈, 동전의 개수, 동전의 값 if N - Coin_Value > 0: N = N - Coin_Value Coin_Count += 1 coin(N, Coin_Count ,Coin_Value) elif N - Coin_Value == 0: print("거스름 돈으로 줘야 할 동전의 최소 개수는 %d개 입니다."%(Coin_Count + 1)) else: ...
e18695df2be2fe0c64de2b71cbef12ce99587f5a
AnanyBahekar28/Maze-generation
/Approach_3_code/pseudo_code.py
705
3.765625
4
""" Configure the start cell Configure bot cell # bot cell will change according to the movement towards the target cell Configure the target cell def createMaze(): def createPath(): the path will randomly generated with the random choosing of ways for the bot def createOthe...
97d5819392614cc808c128c1225f67f7652d8150
Elvis-Almeida/Python
/Programas de exercicios/exercicio006.py
183
3.875
4
#mostra o dobro o triplo e a raiz quadrada de qualquer numero n1 = int(input('digite um numero')) print(' o dobro é {}\n o triplo é {}\n a raiz é {}'.format(n1*2, n1*3, n1**(1/2)))
bc635916cfbf5fd7e6c41df6a2256a310f5e9574
IlkoAng/-Python-Fundamentals-Softuni
/05. Lists Advanced Exercises/01. Which Are In.py
259
4
4
substrings = input().split(", ") strings = input().split(", ") my_list = [] for substring in substrings: for string in strings: if substring in string: my_list.append(substring) print(sorted(set(my_list), key=my_list.index))
fab3f1c429ad4998d779ada470f481893709c6df
Timofeitsi/Repo_dz
/lesson4/less4_2.py
1,107
3.90625
4
""" Представлен список чисел. Необходимо вывести элементы исходного списка, значения которых больше предыдущего элемента. Подсказка: элементы, удовлетворяющие условию, оформить в виде списка. Для формирования списка использовать генератор. Пример исходного списка: [300, 2, 12, 44, 1, 1, 4, 10, 7, 1, 78, 123, 55]. Резул...
db4073068b0e0b606a6392ab3f158f3fa051b0e0
vgattani-ds/programming_websites
/leetcode/0121_maxProfit.py
556
3.796875
4
from typing import List class Solution: def maxProfit(self, prices: List[int]) -> int: if len(prices) <= 1: return 0 max_profit = 0 buy_price = prices[0] for price in prices[1:]: max_profit = max(max_profit, price - bu...
a9cb1682f9056dd9b4ed17632b0ee5e6fe618e75
Kenzo-Sugai/Python
/Lab12/main.py
145
3.546875
4
from text import texto def main(): palavras = input("Digite as palavras desejadas separando-as por hífen(-): ") texto(palavras) main()
02853d1e9d88a6373ee3303d9daf13af58e169f2
joshia5/Indexing_SE
/proximityMatch.py
849
3.84375
4
# This file contains the code and logic to perform # proximity matching # Step 1 # Load the inverted indices in memory # Step 2 # load the inverted index into one object per input document # Step 3 # for each document, # sort the indices by their word positions in the document # Step 4 # take the n...
20ea306e5325d2a781ff628109994529dd052b74
DS-PATIL-2019/Two-Pointers-2
/MergeList.py
1,003
3.9375
4
""" The approach here is to maintain 3 pointers. n1 at the arr1 till the len of m. and n2 till the len of n and k to the len of whole nums1 len. now starting from backwards at each step we check if the value at nums1 or nums2 at the last positions. depending on which is larger. we assign that to the ...
053fc2f0edca54710efa5cbd3206e18d097fd093
Makalella/Python-study
/Chapter 04/list.py
860
3.90625
4
## 리스트 선언 list_a = [1, 2, 3] list_b = [4, 5, 6] ## 출력 print("# 리스트") print("list_a =", list_a) print("list_b =", list_b) print() ## 기본 연산자 print("# 리스트 기본 연산자") print("list_a + list_b =", list_a + list_b) print("list_a * 3 =", list_a * 3) print() ## 함수 print("# 길이 구하기") print("len(list_a) =", len(list_a)) ## ...
837f7d9bb87ed63a82fe1cb1ba1aca6bd497a747
tapumar/Competitive-Programming
/Uri_Online_Judge/2717.py
217
3.78125
4
minutos = int(input()) presente1, presente2 = input().split() presente1 = int(presente1) presente2 = int(presente2) if (presente1 + presente2) > minutos: print("Deixa para amanha!") else: print("Farei hoje!")
88d93b9cf84f9349aea9d6c52318eff361692eb4
snufkinpl/public_glowing_star
/School/AJP introduction in programming/zadania3/3_3.py
1,035
3.5
4
# 3. Napisać program, który wczytuje tablicę 10 liczb całkowitych z zakresu -10..10 i wypisuje jej elementy na ekranie monitora. Następnie program oblicza sumę kwadratów tych elementów tablicy, które przy dzieleniu przez 4 dają resztę 2 lub są niedodatnie oraz wypisuje tę sumę na ekranie. list_of_numbers = [] for i...
e4544928087f4fc3ca840bdbd22248708a2a109f
MehediHasanRaj/Problem-solving
/prime_Sieve.py
504
3.65625
4
import math def prime(n): primes = [1 for i in range(n + 1)] primes[0] = 0 primes[1] = 0 r = int(math.sqrt(n + 1)) for i in range(2,r): if primes[i] == 1: for j in range(2, n + 1): if j * i <= n: primes[i * j] = 0 else: ...
aa529cbcf023594b011aee8dc83ed2efb2574162
awphi/ads-summative
/kWayQS.py
1,455
3.59375
4
import sys def read_input(filename): A = [] try: myfile = open(filename, 'r') except OSError: print('cannot open', filename) sys.exit(0) for line in myfile: A = A + [int(line.strip())] myfile.close() return A def insertionsort(A): for j in ran...
dac4f23113bf0129bc80cd6db11e01ea7be9041a
aakibinesar/Rosalind
/Bioinformatics Stronghold/rosalind_scsp_50.py
3,155
3.8125
4
def main(): file = open("rosalind_scsp.txt", "r") first = file.readline().strip() second = file.readline().strip() file.close() # Build a memo for dynamic programming. The memo will # store the shortest common supersequences. # memo[i][j] holds the length of the # shortest common superse...
2df3ff9b66d23c0ad272130edb6012297ee1e21d
whguo/PythonBasic
/Python/函数式编程/Higher-order Function.py
237
3.734375
4
x = abs(-10) print (x) f = abs print (f) def add(x,y,f): return f(x)+f(y) x = -5 y = 6 print (add(x,y,f)) #加入可变参数 from math import sqrt def same(x,*fs): s=[f(x) for f in fs] return s print(same(2,sqrt,abs))
3588e503062688747e0fcfc0f9461cc4e554a65a
Hemangi3598/chap-7_p13
/p13.py
702
3.609375
4
# wamdpp to keep track on ipl team names team_names = set() while True: op = int(input(" 1 add, 2 display, 3 remove and 4 exit ")) if op == 1: name = input("enter team name to be added ") len1 = len(team_names) team_names.add(name) len2 = len(team_names) if len2 > len1: print(name, "added")...
c4dd8d83a95c6a1bdff8b76c18ff0fdbd6c0c5a3
singhmp968/Hunter
/Ques13.py
82
3.65625
4
x=str(input()) m=x[::-1] if(m==x): print("YES") else: print("NO")
b456608ced4e4df78ab2188b0b83fa2332fe9bb6
Lordjiggyx/PythonPractice
/NumPy/intro.py
1,430
4.59375
5
#NumPy intro import os """ NumPy is a pythin library for woriking with arrays it stands for numerical python It used as lists are slow to use pretty much so this is faster an array object is created called an ndarray To start you need to install numpy if you dont have in the cmd linw call pip install numpy """ "T...
d95117e605d46940a1214f4739811022b06173a9
SymmetricChaos/MyOtherMathStuff
/Fractals/LSystemTurtleHilbertCurve.py
653
3.671875
4
import turtle from LSystem import LSystem def hilbert_curve_rule(S): if S == "A": return "+BF-AFA-FB+" if S == "B": return "-AF+BFB+FA-" else: return S for i in LSystem("B",hilbert_curve_rule,5): rules = i # Strip out anything unnceesaary for drawing rules = rules.replace("A",...
63ff8f651117d3aa4be2d6228b3d42da4d37b777
atg-abhijay/Advent-of-Code-2020
/Day-11/advent-11.py
5,375
3.734375
4
""" URL for challenge: https://adventofcode.com/2020/day/11 """ from itertools import product num_rows, num_cols = 0, 0 def process_input(): """ Since the rules are applied to all seats simultaneously, two grids will be required since the original grid cannot be edited whilst the rules are being...
ef749cfe080b279a9773a6ec101c9e02c2d5a69e
nurav/treasurehunt
/treasurehunt.py
1,535
3.515625
4
__author__ = 'The Joshis' import urllib import urllib2 import json def __main__(): try: file = open('question_data.txt') all_data = json.loads(file.read()) except: print("first use") all_data = [] file = open('question_data.txt', 'w+') order = int(raw_input('start cor...
ef3ba83e1735a50e485a9cf078d9309172e07f77
arthurpbarros/URI
/Iniciante/1002.py
88
3.828125
4
radius = float(input()) area = radius*radius*3.14159 print ("A="+"{:.4f}".format(area))
28b1d205ffe330ca3c6036bfa421503a924cb2ee
PhilLar/Notebook-coursework-
/input.py
2,433
3.9375
4
import os from check import * def input_name(): n = '' while True: name = input('Ввод: ') # check if check_name(name) is False: print('Неверный формат имени!') print('Первая буква заглавная!') print('Имена должны содержать только символы кириллицы!') ...
bc4f6cdb493a1d729d966f1207b98aff77f52970
matteougolotti/project-euler
/0002/P0002.py
304
3.640625
4
import sys def fibs(n): a = 0 b = 1 numbers = [] while((a + b) <= n): c = a + b numbers.append(c) a = b b = c return numbers t = int(input()) for a0 in range(t): n = int(input()) s = sum([ x for x in fibs(n) if x % 2 == 0 ]) print(str(s))
5c694e8288e26ac0a565259b4930b39d543fc33b
deveshpatel0101/python-data-structures-algorithms
/algorithms/sorting/bucket_sort/__main__.py
435
3.859375
4
from sort import BucketSort def start(): bucket_sort = BucketSort() try: size = int(input('Enter the number of elements: ')) arr = [] print('Start entering elements:') for i in range(size): arr.append(float(input())) print('Sorted Array is:') print(b...
2dcb18f936609779e44fc48879353016096d52a5
mit-d/euler
/9.py
538
3.703125
4
# Pythagorean Triplet # a < b < c AND a**2 + b**2 = c**2 # # Find a the one triplet that exists for a + b + c = 1000 def IsTriplet(a, b, c): if a ** 2 + b ** 2 != c ** 2: return False if a < b < c: return True else: return False for b in range(1, 999): for a in range(1, b): ...
5032de42ec9385df86c8ae1b567b69068862849f
svetoslavastoyanova/Python-Fundamentals
/Basic Syntax Lab/04.Number between 1 and 100.py
590
4.09375
4
#Вариант 1 (по-добрият вариант, тъй като при промяна на стойностите трябва винаги да ги промнеянме навсякъде, а #с мин и макс не е необходимо. MIN_NUMBER = 1 MAX_NUMBER = 100 while True: n = float(input()) if MIN_NUMBER <= n <= MAX_NUMBER: print(f"The number {n} is between {MIN_NUMBER} and {MAX_NUMBER}"...
01c48ca10ebe29146e9ffc87528fc7d00344ea78
jonygeta/Data-622-HW2
/pull_data.py
2,323
3.515625
4
# -*- coding: utf-8 -*- """ CUNY MSDS Program, DATA 622, Homework 2 Created: September 2018 @author: Ilya Kats This module reads Titanic data set from public GitHub. """ import pandas as pd # Define data location here for ease of modification root = 'https://raw.githubusercontent.com/ilyakats/CUNY-DATA622/master/HW...
f8b9b3a8e582e3fcab6f7c42b1e425889d6f4a11
soohyunii/algorithm
/mailProgramming/algorithm08_none.py
877
3.765625
4
interList = list(input("Input (Should input [], not {}) : ")) a,b,c,d = 0,0,0,0 outList = [] for i in range(0, len(interList)-1, 1) : a = interList[i][1] b = interList[i+1][0] c = interList[i][0] d = interList[i+1][1] if a < b : if a+1 == b : outList.append([c,d]) else : outList.append([c,a],[b,d]) if ...
35e4df0a11cb489e7f70fe3d4a3b0571fa66845b
hugechuanqi/Algorithms-and-Data-Structures
/剑指offer/05.用两个栈实现队列.py
1,939
3.984375
4
# -*- coding:utf-8 -*- ## 扩展:可以指定位置进行pop,而不用pop所有的栈(与题目实现队列没关系) class Solution: def __init__(self): self.stackA = [] #栈A self.stackB = [] #栈B self.queue = [] #队列 def push(self, node): """进栈""" return self.stackA.extend(node) def pop(self): """出栈...
f9d8a55c5943d26cc9021045d95a004e8d9859bb
Coliverfelt/Desafios_Python
/Desafio071_a.py
1,206
4.03125
4
# Exercício Python 071: Crie um programa que simule o funcionamento de um caixa eletrônico. # No início, pergunte ao usuário qual será o valor a ser sacado (número inteiro) # e o programa vai informar quantas cédulas de cada valor serão entregues. # OBS: considere que o caixa possui cédulas de R$50, R$20, R$10 e R$1. ...
aec20e51b19f25f8681986caeddda14facc5bd5c
kuzmicheff/lemonade-stand
/EventGenerator.py
2,990
3.953125
4
import random class EventGenerator: """The EventGenerator class sets the weather before each new day in the game.""" def __init__(self): pass def generateDayEvent(self, dayWeather): if dayWeather == "Cloudy": eventList = ["Thunderstorm", "Shower", "Overcast", "None", "None", ...
44369fc0f3dcb49006abd35948c1ba3414f0ff85
AsadullahFarooqi/project_euler
/p_041.py
822
4.03125
4
""" Pandigital prime Problem 41 We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime. What is the largest n-digit pandigital prime that exists? """ import math def is_prime(x): if x <= 1: return False ...
c06fe7ab4e6d06f51cd267948caa43cc89ccc194
mayrazan/exercicios-python-unoesc
/listas/10.py
349
3.75
4
listaA = [] listaB = [] listaC = [] for i in range(0, 10): lista1 = int(input("Informe um numero para a lista A: ")) lista2 = int(input("Informe um numero para a lista B: ")) listaA.append(lista1) listaB.append(lista2) listaC.append(listaA[i]) listaC.append(listaB[i]) print("Lista de numeros...
b2731fb0395d09048ab16286b00322684d5dd747
saloni5544/finalprojectgwc
/syriajob.py
13,810
4.25
4
start="..." print("Don't forget to type your responses in all lowercase letters! ") initialinput = input("In this game you will live in a country and face their everyday troubles. You may go to either Syria, New Orleans, Liberia, Chicago or China. ") if initialinput == "China": print("You are stuck in Beijing, Chi...
3ca34d142d622920f252f81979c95240c24b3fc0
c940606/leetcode
/838. Push Dominoes.py
1,271
3.53125
4
class Solution: def pushDominoes(self, dominoes): """ :type dominoes: str :rtype: str """ dominoes = dominoes n = len(dominoes) right = [float("inf")] * n left = [float("inf")] * n i = 0 while i < n: if dominoes[i] == "R": ...
f4555b911927df41ec09cb4ae455f84c0f05195e
leegaryhaig/Automate-the-Boring-Stuff-with-Python-2015
/Ch9_OrganizingFiles/renameDates.py
2,862
3.78125
4
#! python3 # renameDates.py - Renames filenames with American MM-DD-YYYY date format to European DD-MM-YYYY. #Create a regex that matches files with the American date format. import shutil, os, re # shutil or shell utilities - allows you to copy, move rename and delete files in your python programs # os or operating ...
b46cfe87f3b5f99ba25679a39001d80525d826a1
Panthck15/learning-python-repo1
/funct-countwords.py
177
3.84375
4
def get_wordscount(): my_str=input('Please eneter a string : ') my_list=my_str.split(' ') #print(len(my_list)) return (len(my_list)) x=get_wordscount() print(x)
242093dc02ac60a92ccde22a39197271fe953259
terencehh/python-algorithms-data-structures
/Dynamic Programming Algorithms/Fibonnaci_Sequence.py
615
3.90625
4
def top_down_fib(n, table): if n == 0 or n == 1: table[n] = n # If value not calculated, then calculate it if table[n] is None: table[n] = top_down_fib(n - 1, table) + top_down_fib(n - 2, table) # return the value corresponding to the value of n return table[n] def bottom_up_fi...
2ed50a00186dd9a89b56972ec9bcc92cc9b8fd22
marcelomatz/py-studiesRepo
/python_udemy/programa/mapeamento.py
427
3.5
4
from dados import produtos, pessoas, lista # print(lista) # print() # nova_lista = map(lambda x: x * 2, lista) # print(list(nova_lista)) # nova_lista = [x * 2 for x in lista] # print(nova_lista) # for produto in produtos: # print(produto) def aumenta_preco(p): p['preco'] = round(p['preco'] * 1.05, 2) r...
f5365822571ed418dbe04cc9579b7a2ef7229555
hangdragon/DNN
/my_exercise/reversed.py
174
3.625
4
# -*- coding : utf-8 -*- def rev(list_x) : for i in list_x[::-1] : yield i rev_iterator = rev(list(range(1,20))) print(rev_iterator) print(list(rev_iterator))
147f2b992037e348e16b448dd2bee18f7acc0262
grg909/LCtrip
/Binary_Tree/LintCode.448.Inorder_Successor_in_BST.py
1,865
4.09375
4
# -*- coding: UTF-8 -*- # @Date : 2020/1/6 # @Author : WANG JINGE # @Email : wang.j.au@m.titech.ac.jp # @Language: python 3.7 """ """ """ Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None """ # stack迭代,...
fb27e34a73488833e1bde1a696582efea8ec5f17
zeelp741/Data-Strucutures
/Stack_linked.py
9,629
4.03125
4
from copy import deepcopy class Node: def __init__(self, element): """ ------------------------------------------------------- Initializes a linked-list node that contains a copy of the given element and a link pointing to None. Use: node = Node(element) ...
cc520d3fa0d68b1bdf1fc640e0cd995bd9a61fe3
SebasBaquero/taller1-algoritmo
/taller1python/punto6.py
510
4.0625
4
""" Entradas Numero de niños-->int-->men Numero de niñas-->int-->mujer Salidas Porcentaje de hombres-->int-->porcentaje1 Porcentaje de mujeres-->int-->porcentaje """ men= int(input("Escriba el numero de estudiantes hombres: ")) mujer= int(input("Escriba el numero de estudiantes mujeres: ")) suma= (men+mujer) porcentaje...
f7a357d3c080c1970440fe8f2f05ff9993907ee1
doomnonius/advent-of-code
/2022/day10.py
1,918
3.5625
4
from typing import List, Set, Tuple def increase(cycles: int, t: int, x: int) -> Tuple[int, int, int]: cycles += 1 if not (cycles - 20) % 40: if test: print(f"cycle: {cycles}, adding {cycles * x} to {t}") t += (cycles * x) return (cycles, t, x) def part1(comms: List) -> int: cycles = 0...
45e7ffb2e411495ae171e8bf6c375f68fcc44f12
wanghao9696/learning
/数据结构/排序算法/mergeSort.py
542
3.515625
4
import timeit def mergeSort(iList): if len(iList) <= 1: return iList mid = len(iList) / 2 lList = iList[0: mid] rList = iList[mid:] return mergeList(mergeSort(lList), mergeSort(rList)) def mergeList(lList, rList): mList = [] while lList and rList: if lList[0] >= rList...
97224922303f60745a26ebfc8a939219231518b7
Polcsi/Person-Generator-App
/Person.py
744
3.609375
4
from Address import Address class Person: FirstName: str LastName: str Gender: str Age: int address: Address address = Address() @property def FirstName(self): return self._FirstName @FirstName.setter def FirstName(self, firstname): self._FirstName = firstna...
146c60e7483b625f4ae418b56e26c55a2cd1ee1c
moog2009/Python
/ex36.py
2,226
4.15625
4
# -*- coding: utf-8 -*- from sys import exit def bear_room(honeystatus): print "There is a bear here." print "The bear has a bunch of honey." print "The fat bear is in front of another door." print "How are you going to move the bear?" bear_moved=False if honeystatus == 1: while True: next=raw_input(">...
a4830896372da221d5f23594e6d451409963f747
drahmuty/Algorithm-Design-Manual
/03-_01.py
1,131
3.546875
4
# Jolly Jumpers # input: array of numbers # output: true or false for jolly or not jolly # create a "hash table" array of each number 1 to n-1 # set each value in array to False # calculate abs(difference) between each number # if difference is greater than n-1, return false # use difference as index into array # if ...
0f2260896424532b0a80a4618ffd6a9862584443
khayes25/days_in_a_month
/days_in_a_month.py
2,053
4.5
4
""" @author: Keon Hayes """ """ The input function will print "Enter a month (1-12): " and wait for the user to type their entry. When the user presses the "Enter" key on their keyboard, the value they typed will be returned as a string-type and to the month variable, and immediately typecast as an int. """ ...
eba753e54528d17c16f50cdf9e6eb778b797df8f
wenxinjie/leetcode
/tree/python/leetcode98_Validate_Binary_Search_Tree.py
1,229
4.21875
4
# Given a binary tree, determine if it is a valid binary search tree (BST). # Assume a BST is defined as follows: # The left subtree of a node contains only nodes with keys less than the node's key. # The right subtree of a node contains only nodes with keys greater than the node's key. # Both the left and right subt...
533f84b74f9bc2757929e182c2b74fe6d723ee71
BM-Student/test
/turtles_project_2.py
896
3.59375
4
import turtle #def the function def theshape(r): turtle.screensize(canvwidth=400, canvheight=400, bg="#336633") turtle.pen(pencolor="#FFFFCC", pensize=1.5) turtle.turtlesize(0.1, 0.1, 0.1) point_a = [-r, 0] point_b = [-r / (2 ** .5), r / (2 ** .5)] point_c = [0, r] point_d = [r / (2 ** .5)...
57aef760167f279b01ce03a6ad11a53d3eee656a
baekjonghun/PythonBasic
/py_workspace/06_OBJECT/module_number.py
407
3.75
4
number = 5 def print_number(): print('numer value' , number) return def priunt_squre(): print('number squre : ' , number ** 2) return # print('__name__: %s' %__name__) #해당되는 곳에서 실행하면 main 이 되고 import 하면 name 이 출력됨. if __name__ == '__main__': print('number : ' ,number) pri...
8f9ee4563b4e1fd0631144c8e43795a3f7d2464f
monish7108/PythonProg2
/fileCharacterReversing.py
729
4.5
4
"""This program takes existing filename as input and creates a new file by printing the contents of old file in reverse order [Characters]. ===============================================================""" def file_printing(filename,outputFilename): """This function writes characters from one file to another in...
4ddcbd1f804a904c9d538af7e6ea54c2e5a2f389
nofatclips/euler
/python/problem12.py
1,018
3.546875
4
#!/usr/bin/python # # Problem 12 # 08 March 2002 # # The sequence of triangle numbers is generated by # adding the natural numbers. So the 7th triangle number is # 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms are: # # 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... # # (snip) # # What is the value of the...
b82e8f98171a833bd25a8a5b150d493bdd391e28
richdewey/dsp
/python/q7_lists.py
2,428
3.71875
4
# Based on materials copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 def match_ends(words): counter = 0 for word in list1: a = len(word) #print(a) if a >= 2 and (word[0] == word[-1]): counter = counter + 1 else: pass return counter >>> match_ends(['aba', 'xyz', 'a...
64ec422b7d4cb2ff2f119cb0611d2a5fcc5ff133
shivapriya89/leetcode
/findAndReplacePatternb.py
676
3.703125
4
class Solution(object): def findAndReplacePattern(self, words, pattern): res=[] for word in words: if self.patternFind(word,pattern) and self.patternFind(pattern,word): res.append(word) return res def patternFind(self,word,pattern): dict={} i=...
65dd3cf8b94e46199aa515ccd01e7d61dd993801
lukelu389/programming-class
/python_demo_programs/2021/example_20210523.py
2,747
4.21875
4
''' reverse a string given a string, write a function that returns the reversed string e.g "abc" -> "cba" "hello" -> reverse("ello") + "h" reverse("ello") -> reverse("llo") + "e" reverse("llo") -> reverse("lo") + "l" reverse("lo") -> reverse("o") + "l" reverse("o") -> "o" ''' # def reverse_string(word): # if len(w...
9794a798ee46d177c64aa187f3856339bd1e3164
srmccray/project-euler
/solutions/3.py
447
3.796875
4
""" https://projecteuler.net/problem=3 The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? """ def largest_prime_factor(num, start=1): for x in range(start, num): if not num % x: result = largest_prime_factor(int(num / x), start=x+1) ...
92c1a4a6a7a5d0f95f3aa0ad59ddee8d06147398
seoul-ssafy-class-2-studyclub/GaYoung_SSAFY
/알고리즘/알고리즘문제/4873_반복문자지우기.py
297
3.59375
4
for t in range(int(input())): data = list(input()) stack = [] for i in range(len(data)): if not stack or data[i] != stack[-1]: stack.append(data[i]) elif stack and data[i] == stack[-1]: stack.pop() print('#{} {}'.format(t + 1, len(stack)))
5cf73ec8746a9ab2c7b6eb304a504e70018fe874
jitendra1310/codeing_problems
/python-speek/lature53.py
472
3.984375
4
#!/usr/bin/python3 #Methods and Functions Homework Overview def vol(r): return (4/3)*(3.14)*r**3; def ran_bool(num,low,high): return num in range(low,high+1) def ran_check(num,low,high): if num in range(low,high+1): return str(num) + " is in range betwwen "+ str(low) + " and "+ str(high) else...
e6d4e9579645483cf0de151bb36b6fee89974209
vanmathi1998/set3
/21 A.P .py
175
3.9375
4
a=int(input("enter the value")) n=int(input("enter the value")) d=int(input("enter the value")) total=(n*(2*a+(n-1)*d))/2 print("the sum of arithmetic progression is:",total)
4a32472c6bdb2a4a0a2dca1debbb78df57b0fdd0
CenzOh/Python_Exercises
/notes/class.py
6,874
4.40625
4
# 3/15/21 ISI 300 3/15/21 # define a class class Person: # constructor, __ is syntax for some hiddent fcns def __init__(self, init_firstname , init_lastname): ## <-- initial values coming from the outside (caller) # Variables to store first and last name of a person self.firstnam...
1086820de77e7fb44e76a03e04e330ca85d7faa7
CedricMurairi/game_of_life
/life/cell.py
1,670
4.3125
4
""" This file implements the Cell class with all its methods. Each cell has a status, a board and position. We considered the initial status of a cell to be 0 (dead cell). """ class Cell: """Define template for creating a Cell object. A cell's position on the board is a tuple containing the cell'...
ffad00c383b09d58d5ec233494a2fd15600f9953
rjremillard/Coding-from-A-Level
/Section 11/recursion.py
795
3.875
4
"""Recursive binary tree stuff""" import random class Leaf: def __init__(self, data): self.data = data self.left = None self.right = None def __add__(self, other): if other.data < self.data: if self.left: self.left + other else: self.left = other else: if self.right: self.right + ot...
f47c5358cba2c10d0dcccd568b1635a84477b2a2
eezhal92/learn-neural-net
/neural_net9.py
2,830
3.703125
4
""" Train to predict mean Classification """ from keras.models import Sequential from keras.layers import Dense from keras.utils.np_utils import to_categorical from keras.optimizers import Adam import numpy as np model = Sequential() # 10.5, 5, 9.5, 12 => low # < 50 = low # > 50 = high # Add layers to model # quit...
93be34714221442c6d3eb7fabde1ce6e12935981
rahularora/Youtube-source-code
/flask-api-sqlite/api.py
2,241
3.78125
4
from flask import Flask, make_response, jsonify, request import dataset app = Flask(__name__) db = dataset.connect('sqlite:///api.db') ''' Examples: GET request to /api/books returns the details of all books POST request to /api/books creates a book with the ID 3 (As per request body) Sample request body - { ...
fee028b9e2735bafa1f819ec5761fb9e03dabd57
DomenOslaj/Kilometers---miles-converter
/main.py
406
4.3125
4
print "Hello! This is a kilometers to miles converter." while True: kilometers = int ( raw_input ("Tell us the number you want to convert.") ) miles = kilometers * 0.621371 print("%s kilometers is %s miles." % (kilometers, miles)) choice = raw_input ( "Would you like to do another conversion (y/n):" )...
987ac620b4cf0e0136fae1876fc43ee5b9b569b5
Akhil-DevS/D_1
/roll dice.py
546
3.640625
4
import random as rd def dice_roll(): x=True print('\t\t\nRolling dice') y=rd.randint(1,6) i=1 print('dice roll '+str(i)+' = '+str(y)) while(x==True): print('Do you want to continue?(y/n)') ans=input('answer ').lower().strip() if(ans=='y'): y=rd.rand...
df62411e0cf5319b24fdbcb24554025cd1cda4ed
sobriquette/interview-practice-problems
/Interview Cake/3_highest_product_of_3.py
3,255
3.890625
4
""" Implementation on attempt #2: 08/09/2017 """ def highest_product_of_three(nums): if len(nums) < 3: raise Exception('can\'t have less than 3 items') low = min(nums[0], nums[1]) high = max(nums[0], nums[1]) lowest_two = low * high highest_two = low * high highest_three = highest_two * nums[2] for i, n in ...
9602a9d328a8193c979c8ee887af367e530a6d41
Pratyush-PS/tathastu_week_of_code
/day4/program4.py
483
4.28125
4
my_dict={} size = int(input("\nEnter number of keys in the dictionary:")) for i in range(size): print("Key-Value #{}".format(i+1)) key=input("Enter name of key:") value = input("Enter key value:") my_dict[key] = value print() print("\nOriginal dictionary is:", my_dict) copy_dict={} for key,value...
c18eb70521f08ba49a0f07e0403c13bc81c3c905
mai-mad/PythonLearning
/turtles/turtle9.py
343
3.984375
4
from turtle import * from random import * r=360 window = Screen() shape("turtle") bgcolor("#000000") pencolor("red") speed(20) pensize(2) up() goto(0, -330) down() for i in range(360): color(random(),random(),random()) fillcolor(random(),random(),random()) begin_fill() circle(r) end_fill() ...
9ef25ccd57b9b8e71846dd2cfa901fdcf21935ca
barath83/Python-Course-Work
/data structures/lists.py
2,160
4.3125
4
''' - List is a collection which is ordered and changeable - Allows duplicate members - They are written with square brackets ''' someList = ["Red","Green","Yellow","Orange","Blue"] print(someList) #Acessing items print(someList[1]) #Outputs Green 0-based indexing #Negative indexing print(someList[-1]) #Outputs...
d31af68927f25b30f74d6f2153280a6876080d70
iilsouk/Covid_Africa
/pop.py
5,320
4.0625
4
# 1. Import pandas & matplotlib.pyplot import pandas as pd import matplotlib.pyplot as plt # 2. Create World_pop by reading World_POP csv input file. # 3. Create Continent_pop by reading List of countries and continents input csv file. World_pop = pd.read_csv('World_POP.csv') Continent_pop = pd.read_csv('C and C.cs...
95da21d775a91ccb0e5efb491a8d49ace300477d
mammalwithashell/advent-of-code-2020
/Day 5/main.py
1,769
3.53125
4
from pprint import pprint """# build array representation of seats seats = [] for _ in range(128): row = [] for i in range(8): row.append(i) seats.append(row.copy())""" # Open input file and parse input with open("Day 5\input.txt", 'r') as input_file: #print(input_file.readlines()) ...
607badf2b6b83eb5f0de2096c9ce45296335807c
nandanabhishek/Python-programs
/function_to_find_max_of_three_numbers.py
248
4.15625
4
def max(a,b,c): if(a>b and a>c): return a elif(b>a and b>c): return b else: return c p=input("enter any 3 integers: ") q=input() r=input() m=max(p,q,r) print("Max of three numbers is: "+str(m))
654e3ad65b9456fa23494003ac4b04354a9971fc
jscatala/Exercism
/python/hamming/hamming.py
218
3.671875
4
#!/usr/bin/env python #! -*- coding: utf-8 -*- def distance(x,y): if len(x) != len(y): raise ValueError('Size of strings does not match') return sum(map(lambda x: 0 if x[0] == x[1] else 1, zip(x,y)))
fbe1367831ff9f6e3fa2a7f08d43bfc3b72d2afd
MarioEstebanSuaza/holbertonschool-higher_level_programming
/0x0B-python-input_output/7-save_to_json_file.py
185
3.53125
4
#!/usr/bin/python3 import json def save_to_json_file(my_obj, filename): with open(filename, "w") as file: json_format = json.dumps(my_obj) file.write(json_format)
4dc9eecb3ebd922218b223b86417452ec0fc46eb
noblejoy20/python-tutorial-college
/ex 3 (classes)/timeClass.py
1,533
3.9375
4
import math class Time: hours=0 minutes=0 seconds=0 def __init__(self): self.hours=0 self.minutes=0 self.seconds=0 def input_values(self): self.hours=int(raw_input("Enter hours? ")) self.minutes=int(raw_input("Enter minutes? ")) self.seconds=int(raw_in...
871dd43c0c7c7c92ef3e32fc562ae6889b430cd7
kingkk31/BOJ
/source code/2675_문자열 반복.py
216
3.578125
4
t = int(input()) for i in range(t) : mul, strInput = input().split() multiple = int(mul) strOutput = "" for j in range(len(strInput)) : strOutput += strInput[j] * multiple print(strOutput)
4b0d4810dd258eea1093588730e772d1f1e5850d
jaydye/PoetryGen
/syllabletesting.py
6,783
3.53125
4
''' blank verse generator blank verse is written in iambic pentameter, so each line must be 10 syllables long with alternating stressed and unstressed syllables. this blank verse generator takes a corpus text and generates a markov chain-based poem in blank verse of length n lines. it uses a mostly brute force algor...
7947891c6ca012d2c58ab78d03c8ba14688be1d7
optionalg/Cracking-the-coding-interview-Python
/ex3_2.py
987
3.859375
4
class stackwithMin (object) : def __init__ (self): self.array=[0] self.minval=[0] def push (self, val): self.array.append(val) if len(self.array) >= 1: minVal2=self.findMin(val) self.minval.append(minVal2) else: self.array...
c40ec15f7f774804d0243a0a21f0d59f3dbed97c
Abhishek-IOT/Data_Structures
/DATA_STRUCTURES/Stacks&Queues/InterleaveElements.py
873
3.75
4
from queue import Queue def interleave(queue): if queue.qsize()%2!=0: print("You should have the even number of inputs") stack=[] half=int(queue.qsize()/2) for i in range(half): stack.append(queue.queue[0]) queue.get() while(len(stack)!=0): queue.put(stack[-...
5dd947e25ca22a8c01d898871060197927a98d35
eehello/learn_python
/old_learn/list_test.py
200
3.65625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- list001=range(101) a=0 n=int(input("请输入准备取前几个数:")) list002=[] while a<n: list002.append(list001[a]) a=a+1 print(list002)
dc83a4b662ec159910996d5bc791cde58d12abb1
eselyavka/python
/leetcode/solution_544.py
1,063
3.5625
4
#!/usr/bin/env python import unittest class Solution(object): def _rec(self, n, mas=None): if n == 1: return mas arr = list() if mas is None: payload = range(1, n+1) for i in range(len(payload)/2): arr.append('(' + str(payload[i]) + ',...
014cb3e85ba6126a6c5a0044f0e5d86e81de7d19
ChenYenDu/LeetCode_Challenge
/01_BinaryTree/03_Conclusion/09_Build_Tree_From_Preorder_Inorder_Traversal.py
907
3.765625
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def buildTree(self, preorder: List[int], inorder: List[int]) -> TreeNode: lookup = {} for i, num in enumerate(inorder): ...
30721421cac64d552f2641ca7d0e4fa8acfda732
rohithnshetty/-basics
/fibonacci.py
111
3.78125
4
x=input("enter the range ") x=int(x) a=0 b=1 print(a,b) for i in range(2,x): c=a+b a=b b=c print(c)
0a7e07147bfcaa5beb161cc69e957475a83094fc
assuran54/UFABC-PI
/cálculos_de_retângulo.py
326
3.859375
4
lados_A=int(input('insira o comprimento do par de lados A:')) lados_B=int(input('insira o comprimento do par de lados B:')) # lembre de botar int() pra tornar os valores números propriamente ditos!! perimetro=2*lados_A +2*lados_B area=lados_A*lados_B print('o perímetro mede',perimetro) print('a área mede',area...
49cde8d0db3b9a4cac678f3f35f6d746155f90b6
gamez-code/hackerrank_problems
/cavity_map/cavity_map.py
704
3.65625
4
def cavityMap(grid): grid = [[j for j in i] for i in grid] n = len(grid) - 1 for row in range(len(grid)): if row == 0 or row == n: continue for column in range(len(grid[row])): element = grid[row][column] if column == 0 or column == n: co...
8c68d8c728b774a07ce6f3c4185a7fe913027887
djwright1902/Project1
/main.py
1,411
4.34375
4
#The point of this program is to create a funtion that will automatically score a word used in scrabble def score(word): #set the value for points by letters to be counted by the function pointOne = ("L","l","N","n","O","o","A","a","I","i","E","e","S","s","R","r","T","t","U","u") pointTwo = ("G","g","D","d") poi...
eb0295c1565f4b4d872428bef09ec62f50f95e16
mfarzamalam/Snake_Charmer
/employee.py
828
3.8125
4
class Employee(): def __init__(self,first,last,salary): self.first = first self.last = last self.salary = salary self.total = salary self.salary_raise = 0 def give_raise(self,salary_raise=5000): self.salary_raise += salary_raise self.total = self.salary +...
7165bf1d830429bf51fe4622a18c31adfe35252b
MTGTsunami/LeetPython
/src/leetcode/math/bit_manipulation/338. Counting Bits.py
2,880
3.625
4
""" Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array. Example 1: Input: 2 Output: [0,1,1] Example 2: Input: 5 Output: [0,1,1,2,1,2] Follow up: It is very easy to come up with a solution with r...