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
5aafdef9eee55103097a6a98518bc24a31c8725d
kc3327/Dynamic-Prgoramming
/max_thief.py
781
3.609375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri May 15 13:00:56 2020 @author: alun """ #%% recursive money=[2, 5, 1, 3, 6, 2, 4] def max_thief_recursive(money): return max_thief_recursive_solve(money,0) def max_thief_recursive_solve(money,current_index): if current_index >= len(money): ...
e0fed43db726fa33bf7aa1187d72e2b20522ac5c
gabjohann/python_3
/PythonExercicios/ex030.py
479
4.09375
4
# Crie um programa que leia um número inteiro e mostra na tela se ele é par ou ímpar. num = float(input('Digite um número: ')) resto = num % 2 if resto == 1: print('O número é ímpar!') else: print('O número é par!') # Resolução da aula # número = int(input('Me diga um número qualquer: ')) # resultado = nú...
570793d57c2ab553ab893ad864c7f3dc142b6cd5
gabriellaec/desoft-analise-exercicios
/backup/user_231/ch26_2020_03_31_22_35_12_754780.py
232
3.921875
4
c=int(input('qual o valor da casa?')) s=int(input('qual o seu salario?')) a=int(input('em quantos anos vai pagar?')) pm=c/(a*12) x= s*0.3 if pm<=x: print('Empréstimo aprovado') else: print('Empréstimo não aprovado')
cb599e55d82540b3054bc4ac3fc4affbb243a758
guilhermejcmarinho/Praticas_Python_Elson
/01-Estrutura_Sequencial/17-Calc_Tinta_Preco.py
742
3.71875
4
import math qntMetros = float(input('Informe a quantidade de m² a serem pintados:')) tintaTotal = round(qntMetros/6, 2) qntGalao = math.ceil(tintaTotal/3.6) qntLatas = math.ceil(tintaTotal/18) precoGalao = qntGalao*25 precoLata = qntLatas*80 if precoGalao > precoLata: maisBarato = precoLata else: maisBarato ...
c5dea1c9708fd15dea0b1c7d8ed0d30375ea1b34
steban1234/Ejercicios-universidad
/11_elevacion_p.py
3,398
3.65625
4
'''Elevacion del punto (p)''' # Marlon Steban Romero Perez _20202131029 #Solicitar los datos de campo al usuario: ca = float(input('Digite cota del punto A:')) cb = float(input('Digite cota del punto B:')) hia = float(input('Digite altura instrumental del punto A:')) hib = float(input('Digite altura instrumental d...
4013a88b09b50e8263461ce9f6c124da276fbc3b
semone/advent-of-code-2019
/day01/day1.py
679
3.703125
4
# --- Day 1: The Tyranny of the Rocket Equation --- import sys import os def calculate_fuel(mass): return mass // 3 - 2 def calculate_fuel_4_real(mass, sum): fuel = calculate_fuel(mass) if fuel <= 0: return sum else: return calculate_fuel_4_real(fuel, sum + fuel) def day1(): su...
7f235138f89f3b12f0862bfaf5f959d99aee88a0
purvimisal/Leetcode
/lc-67.py
342
3.84375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Oct 1 17:13:34 2019 @author: purvi """ def addBinary(a: str, b: str) -> str: a = int(a,2) b = int(b,2) sum = bin(a+b) s = sum[2:] return str(s) if __name__ == "__main__": a = "101011010011" b = "1011110011" ...
43cd11f65d47a64656c137e968325ffd237fa8b3
yuihmoo/algorism
/python study/5063.py
205
3.640625
4
V = int(input()) V_list = [] V_list = list(str(input())) if V_list.count('A') > V_list.count('B'): print('A') elif V_list.count('A') < V_list.count('B'): print('B') else: print('Tie')
f62e90255d9ba63a0ffd4139f3c3b995e0983a15
shubhpatel9/Multithreaded-Server
/client.py
1,645
3.59375
4
# ECE 5650 # Project 2 - Client Side # Shubh Patel # Reanna John # 11/18/2020 from socket import * from client_helperfunctions import * from server_helperfunctions import compress_file, uncompress_file SERVERNAME = 'localhost' SERVERPORT = 12000 # dictionary to work as a switch what_to_do = { ...
1c282b9db4e52041bc8cc7dafcfb132558d95313
amysolman/CMEECourseWork
/Week2/Code/lc2.py
1,503
3.859375
4
#!/usr/bin/env python3 # Date: Oct 2019 __appname__ = 'Ic2.py' __version__ = '0.0.1' """In shell either run lc2.py (for ipython) or python3 lc2.py. Script contains four modules. First two use list comprehension to pull high and low rainfall data. Second two modules serve the same function but using conventional loops...
b63c786a919f9c4e3ef480328078a30b3f613880
VictorSega/toxic-substances-ship
/Domain/User.py
834
3.53125
4
import sqlite3 import hashlib conn = sqlite3.connect('Navio.db') def InsertUser(username, password): encodedPassword = hashlib.sha1(password.encode()).hexdigest() cursor = conn.cursor() cursor.execute(f"INSERT INTO User (Username, Password) VALUES ('{username}', '{encodedPassword}');") conn.comm...
e6265197aaf3f43c110a3c282d834c9888ca1952
LiuFang816/SALSTM_py_data
/python/dvklopfenstein_PrincetonAlgorithms/PrincetonAlgorithms-master/tests/test_Stack.py
4,178
3.6875
4
#!/usr/bin/env python """Tests using a Stack""" import sys from AlgsSedgewickWayne.Stack import Stack from AlgsSedgewickWayne.testcode.ArrayHistory import run def test_Stack_lec_quiz(prt=sys.stdout): """Run the quiz in Stats 1, Week 2 lecture, 'Stacks (16:24)'""" expected = "5 4 3 2 1" run(Stack(), "1 2 3 4 5 ...
f1732f2bfcb96c8d48a04d4d47ebf5924df3f52a
daniel-reich/turbo-robot
/cgyHTJDW5brpXGDy6_3.py
948
4.40625
4
""" Create a function that takes `time1` and `time2` and return how many hours have passed between the two times. ### Examples hours_passed("3:00 AM", "9:00 AM") ➞ "6 hours" hours_passed("2:00 PM", "4:00 PM") ➞ "2 hours" hours_passed("1:00 AM", "3:00 PM") ➞ "14 hours" ### Notes `time1` will...
9dd6e3a4054820fe471021030f474be1b6c8d7b3
Kangjinwoojwk/algorithm
/baekjoon/2562.py
157
3.765625
4
max_number = 0 idx = 0 for i in range(1, 10): a = int(input()) if a > max_number: max_number = a idx = i print(max_number) print(idx)
ce2b942418b1e163b38dad275f80280239b44ed7
nikkoenggaliano/AlProg
/python/calculator_sederhana.py
790
4
4
# fungsi penjumlahan def add(x, y): return x + y # fungsi pengurangan def subtract(x, y): return x - y # fungsi perkalian def multiply(x, y): return x * y # fungsi pembagian def divide(x, y): return x / y # menu operasi print("Pilih Operasi.") print("1.Jumlah") print("2.Kurang") print("3.Kali") print("4.Ba...
6f3d0db8986d09a910233460857f265bd9cc8524
0732sta/starter-python
/standard-input/area_calc.py
353
4.125
4
name=input('Tell me your name:') #print('salam '+name) age = input('age? ') print(name,'you are',age,'!!') #Calc the area of a circle #radius=input('Enter the radius of your circle (m):') #area=3.142*radius**2 # line-8 is error because you not declare the type of radius #area=3.142*int(radius)**2 #print("T...
cd0712dfa52454e442dab96e1038227b75305d5a
liuluyang/mk
/py3-study/BaseStudy/mk_15_object_study/测试/study_2.py
5,755
4.375
4
""" class第二阶段学习 面向对象的三大特征:封装、继承和多态 """ """ 私有属性和方法 作用: 限制属性和方法的随意调用和修改,使代码更加健壮 """ """ 需要注意的是,在Python中,变量名类似__xxx__的,也就是以双下划线开头,并且以双下划线结尾的, 是特殊变量,特殊变量是可以直接访问的,不是private变量,所以,不能用__name__、__age__这样的变量名。 有些时候,你会看到以一个下划线开头的实例变量名,比如_name,这样的实例变量外部是可以访问的, 但是,按照约定俗成的规定,当你看到这样的变量时,意思就是,“虽然我可以被访问,但是, 请把我视为私有变量,不要随意访问”。 ""...
42b7b5c2775a4a7ee5fe3504fa58988a36f2897f
heittre/Year2-Sem2-sliit
/DSA/Exams/Online Exam 1/A1/inserta1.py
264
3.96875
4
def insertion_sort(A): n = len(A) for j in range(1, n): key = A[j] i = j -1 while(i >= 0 and key < A[i]): A[i + 1] = A[i] i -= 1 A[i + 1] = key arr = [12, 11, 13, 5, 6] insertion_sort(arr) print(arr)
7aae22d1b04434580da5ab7fbc8088b4f513d7e9
I-del-hub/Ishmarika-shah
/calculator.py
605
4.125
4
print("enter your choice") print("select operation") print("1.add") print("2.subtract") print("3.multiply") print("4.division") x=int(input("enter first no.")) y=int(input("enter second no.")) c=int(input("enter your choice")) def add(x,y): return(x+y) def subtract(x,y): return(x-y) def multiply(x,...
3fd53ccefe4ea03926a224aac8d2d0760cd102c8
6851-2021/MostSignificantSetBit
/mssb_lookup.py
921
3.875
4
# Find the most significant set bit for given n def most_significant_set_bit(n): if n == 0: return -1 else: return most_significant_set_bit(n >> 1) + 1 def print_lookup_table(nbits): lookup = "" lookup_name = "lookup_{}bit".format(nbits) max_value = 2 ** nbits # Open up the ...
4ea8b9138920af0be650f735d886ec58d19d6b14
morzen/Greenwhich1
/COMP1753/week5/L03 Decisions/05HelloNames.py
314
4.125
4
first_name = input("What is your first name? ") last_name = input("What is your last name? ") if first_name == str("Chris") and last_name == str("Walshaw"): print("Hello Chris Walshaw, COMP1753 module leader") else : print("Hello " + first_name + " " + last_name) print() input("Press return to continue ...")...
acbef13254cb3f499763d474c236c6f9ad7489a4
WesGtoX/Intro-Computer-Science-with-Python-Part01
/Week2/Tarefa 01/Exercicio_02_media_aritmetica.py
286
3.625
4
priN = int(input("Digite a primeira nota: ")) segN = int(input("Digite a segunda nota: ")) terN = int(input("Digite a terceira nota: ")) quaN = int(input("Digite a quarta nota: ")) media = priN + segN + terN + quaN media_final = media / 4 print("A média aritmética é", media_final)
cb54dfd38405458b6173a9733715e914a513067c
Yi-Mu/learnpython
/palindrome.py
160
3.734375
4
#-*- coding:utf-8 -*- def is_palindrome(n): return str(n)==str(n)[::-1] and len(str(n))>1 output=filter(is_palindrome,range(1000)) print(list(output))
5c14251f832def28f67172451b51b92a9c8f1e66
Flimars/Python3-for-beginner
/_curso_em_video/codes-python-intellij/_exemplos_aulas/aprensentacao.py
545
4.0625
4
''' Curso em Vídeo: Aula 04 - Usando input - Desafio 01 Curso de Programação em Python The Python language created in 1991 by Guido Van Rossum. Aiming at productivity and readability. ''' print('****************************************************************************') print('**************************...
cfb8e689e009349dd826955682f1b56759ed8031
Legonaftik/Yandex-ML-introduction-Coursera
/week1/titanic.py
2,802
4.03125
4
""" Какое количество мужчин и женщин ехало на корабле? В качестве ответа приведите два числа через пробел. """ import pandas data = pandas.read_csv("titanic.csv", index_col="PassengerId") sex = data["Sex"] print("Number of MEN:", sex.value_counts()[0]) # Number of MEN: 577 print("Number of WOMEN:", sex.value_counts()[...
db792b8717bf0eca48dca40bdd242608383e988c
yomarcs/CodiGoVirtualBack-4
/pruebas/semana1/dia3/dia3-clases.py
457
3.578125
4
class Mueble: tipo = 'futon' valor = '' color = 'negro' especificaciones = ['Hecho en Perú','Cedro'] def devolver_especs(self): return self.especificaciones mueble1 = Mueble() mueble1.tipo = 'familiar' mueble1.valor = 500 mueble1.especificaciones = ['Hecho en Perú','2da mano','2009'] print...
6e18239faddde030c57bb158604adb4dc3c76779
kieferca/quality-indicators-for-text
/python metrics/ws_uppercased(4).py
1,197
3.671875
4
# -*- coding: utf-8 -*- """ Created on Thu Nov 8 16:14:12 2018 Percentage of uppercased letters """ from pickle import load import nltk from nltk import word_tokenize # ------------------------------------------------------------------------------ def LoadPickle( fname ): # from pickle import load f = op...
b843e7e34a941e3b12fedc21515e80bc6a2792ce
yred/euler
/python/problem_125.py
1,960
3.625
4
# -*- coding: utf-8 -*- """ Problem 125 - Palindromic sums The palindromic number 595 is interesting because it can be written as the sum of consecutive squares: 6² + 7² + 8² + 9² + 10² + 11² + 12². There are exactly eleven palindromes below one-thousand that can be written as consecutive square sums, and the sum of ...
bcd3268707544041bbe83c2789ef39286a4439f0
Proxy-FHICT/proxy_py_barcode_scanner
/TestBits/AtList.py
1,321
3.546875
4
class AttList: def __init__(self): self.StudList = [] def Check(self, inpid): if inpid > 0: first = 0 thelist = self.StudList last = len(thelist) - 1 found = False while first <= last and not found: middle = (first +...
c5daeec1a582b76163fb0180c2f37f0db0438aef
Ximana/INVASAO-ALIENIGINA
/alien.py
883
3.65625
4
import pygame from pygame import sprite from pygame.sprite import Sprite class Alien(Sprite): """CLASSE PARA REPRESENTAR UMA ALIEN NA FROTA""" def __init__(self, ai_settings, screen): super(Alien, self).__init__() self.screen = screen self.ai_settings = ai_settings #CAR...
a4805c668d709a952b30d094474b431e849c982c
dawid0planeta/advent_of_code_2020
/d02/sol.py
1,011
3.625
4
def parse_data(filename: str) -> list: data = [] with open(filename) as f: for line in f: splitted = line.split(":") data data.append([splitted[1].strip(), splitted[0]]) return data def get_part1(data: list) -> int: count = 0 for line in data: pas...
1fb7d709d75fae4b433063df2ae1f9ce103b3873
mgould1799/Intro-To-Python
/CSCI220/code from class/practice test.py
374
3.84375
4
def printVar(): total = 0 for i in range(5): total=total+(i+1) print(total) print() def printVar2(): total=0 for i in range(1,4): for j in range(i,5): total=total+j print(total) print() def threes(): num2=100 for i in range(num2): ...
249ce7efa1d32f05bdc71dffd905fb8549e8122c
codethor/dynamik
/egg_dropping.py
559
3.578125
4
import sys def eggdrop(n,k): # n = no of eggs # k = no of floors eggfloor = [[0 for i in range(k+1)] for j in range(n+1)] for j in range(1,k+1): eggfloor[1][j] = j for i in range(1,n+1): eggfloor[i][0] = 0 eggfloor[i][1] = 1 for i in range(2,n+1): for j in range(2,k+1): eggfloor[i][j] = sys.maxsize...
b6edfab11b371b63829addcbead969b925a1a9dd
vancher85/hwork
/hw2/src1/demo_utils.py
2,026
3.515625
4
"""Task4. Создать demo_utils.py в котором объединить все предыдущие задания. Написать функцию, которая сперва выводит: 1. Фибоначчи 2. Евклид 3. Счетчик картинок Ввелите номер Demo функции: Через input() принимает от пользователя номер задания, и выводит входящие праметры функции, и результат. Пример: Ввелите номер Dem...
270779d5e2ce77f559bcabf59282c8fab1e923a7
zishunwei/Point-in-Polygon-Test-App
/Project Draft/test4.py
682
3.71875
4
a = [(1, 2), (2, 4), (3 , 5), (1, 2)] b = [5, 6, 7, 8] def line_crossing(x3, y3, x4, y4, x1, y1): # arguments are points to be tested, # (x3, y3, x4, y4) define the lines of poloygon, # (x1, y1) define the ray which is parallel with the x-axis if y3 == y4: if y1 == y3: if x1 <= x3 or x1 <= x4...
ba544a9961c2187697fe9dfa9adc3c27f8553f8a
raghuprasadks/pythontutoriallatest
/assignment/9-RemovePunctuation.py
319
4.375
4
# define punctuation punctuation = '''''!()-[]{};:'"\,<>./?@#$%^&*_~''' # take input from the user my_str = input("Enter a string: ") # remove punctuation from the string no_punct = "" for char in my_str: if char not in punctuation: no_punct = no_punct + char # display the unpunctuated string print(no_punct)
9615e62990d09c0e47cdda77239371bfc95e0c0e
stolmen/assetto-corsa-virtual-wheel-display
/src/wheeldrawer.py
2,141
3.546875
4
import sys import os sys.path.append(os.path.dirname(__file__)) import abc from shapes import ShapeCollection, Annulus, Point, Line from canvas import Canvas class WheelDrawer(metaclass=abc.ABCMeta): @abc.abstractmethod def paint(self, vectors: ShapeCollection) -> None: raise NotImplementedError ...
20e82095de257a9d5528045b86d85f5f0b7bea6e
nangia-vaibhavv/Python-Learning
/CHAPTER 7/03_fruitsList.py
148
4.03125
4
# print list of fruits using loops fruits=['banana','mango','grapes','apple','kela'] i=0 while(i<len(fruits)): print(fruits[i]) i+=1
3dd9413f0c96301f81d43157f026ba7ca38c45e0
EvanDyce/Sorting-Visiualizer
/Sorting/insertionsort.py
568
3.765625
4
import time red = '#ff0000' green = '#00b32d' black = '#000000' white = '#ffffff' grey = '#a6a2a2' purple = '#ce9eff' light_blue = '#94afff' light_pink = '#ffbffc' light_yellow = '#fffebf' def InsertionSort(array, func, timeSleep): i = 1 while i < len(array): j = i while j > 0: if...
e667720cd142283f4432a6018f2c5eff9b9bd233
daniel-reich/turbo-robot
/6LAgr6EGHKoZWGhjd_14.py
972
3.984375
4
""" You face 1 out of the 4 compass directions: `N`, `S`, `E` or `W`. * A **left turn** is a **counter-clockwise turn**. e.g. `N` (left-turn) ➞ `W`. * A **right turn** is a **clockwise turn**. e.g. `N` (right-turn) ➞ `E`. Create a function that takes in a starting direction and a sequence of left and right tur...
e3d75c766d97c95527890e3d883281532ae8b8f1
bdugersuren/exercises
/cses/weird.algorithm.py
163
3.6875
4
# https://cses.fi/problemset/task/1068 n=input() while n!=1: n=int(n) print(n, end=' ') if n%2==0: n>>=1 continue n=n*3+1 print(1)
d75cae79f85327a48abbf07655495582cd9b8c6d
slimdy/some-Important-things-in-Python
/Decorator_study.py
5,414
4.28125
4
""" 装饰器本质上是一个Python的函数,它可以让其他函数在不需要做任何代码变动的前提下增加额外的功能 装饰器的返回值是一个函数对象,它经常用于有切面需求的场景,比如:插入日志、性能测试、事务处理、缓存、权限校验等场景 有了装饰器,我们就可以抽离大量与函数功能本身无关的雷同代码并继续重用 简单地说:就是给已有的函数添加额外的功能 """ #sample case def foo(): print("I'am foo") foo() print('*'*50) #现在有个新的需求 每个函数输出的时候 还要输出函数名称 def printName(): import inspect caller = insp...
dc7798c7d03713b3f6d39265918e7cf05825b7f4
omar9717/Qodescape
/src/nodetypes/_stmt_while.py
1,874
3.671875
4
from utils import Print ''' Describes a While block. TODO: 1. Call a generalized function to map nodes in stmts. HOW IT WORKS! 1.) It creates a custom node name for the "while" node as it can have multiple "while" nodes in a single scope. - WHILE.name = WHILE_line_127 2.) Then it...
ceffb7fa904badf9d6304964f2223bbfca5caba0
wan-catherine/Leetcode
/problems/ValidAnagram.py
635
3.53125
4
class Solution: def isAnagram(self, s, t): """ :type s: str :type t: str :rtype: bool """ if s == t : return True sl = list(s) tl = list(t) sl.sort() tl.sort() if ''.join(sl) != ''.join(tl): return False ...
fbcba0a95e98a1764612e4007162f02555502865
cham0919/Algorithm-Python
/프로그래머스/정렬/H_Index.py
503
3.59375
4
"""https://programmers.co.kr/learn/courses/30/lessons/42747?language=java#fn1""" citationsList = [ [3, 0, 6, 1, 5] ] returnList = [ 3 ] def solution(citations): citations.sort() for v in range(0, len(citations), 1): h_index = len(citations) - v if h_index <= citations[v]: ...
a4213deb7886ed6d6fcae858f56b6e0eb587bd75
CoderSaha10/Simple-Calculator
/My_Claculater.py
2,931
4.0625
4
from tkinter import * root=Tk() root.title("My Calculator") # Creating entry window e=Entry(root,width=65, borderwidth=5) e.grid(row=0,column=0,columnspan=3,padx=10,pady=10) # The Methods def click(number): current=e.get() e.delete(0,END) e.insert(0,str(current) + str(number)) def clear(): ...
5e03224cf1026d7a064aec991decc365e0e311f5
cnishop/pycode
/类属性方法.py
844
3.9375
4
class Human: ''' this is doc ''' name='ren' gender ='male' age='25' __money = 8000 def __init__(self,name,age): print("#"*50) self.name=name self.age=age print("#"*50) self.var2 ="实例的属性" self.__var3 ="实例的私有属性" #def __str__(self): ...
031da6e2d9ff8931ffdc4c242f1ce4e2a61a8ddb
phontip/python
/W1/w1_t3.py
506
3.96875
4
num1 = input("input num1 :") num2 = input("input num2 :") num3 = input("input num3 :") num4 = input("input num4 :") num5 = input("input num5 :") print('complex of 1 Equal',complex(num1)) print('float of 2 Equal',float(num2)) print('complex of 2 Equal',complex(num2)) print('float of 3 Equal',float(num3)) print('complex ...
f3fcd0761f054953a39b09dc39e4e3c982aae0f8
abhih/ds-algo
/reduce_number_zero.py
370
3.734375
4
#https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero/ count=0 def numberOfSteps(num): global count print(num) if num<1: print("count",count) return count if num%2==0: num=num//2 count+=1 else: num=(num-1) count+=1 return number...
ce8816394ce074054d1e7c67f592bf2290f3e432
rhkdgh815/rhkdgh815
/문9.py
302
3.796875
4
n1 = int(input()) n2 = int(input()) n3 = int(input()) if n1>n2: if n2>n3: print(n1,n2,n3) else: print(n1,n3,n2) if n2>n1: if n1>n3: print(n2,n1,n3) else: print(n2,n3,n1) if n3>n2: if n2>n1: print(n3,n2,n1) else: print(n3,n1,n2)
a245bcb8f79eb2c62beae910b1045e4ce3cded53
nyme92/snake_game
/snakegame.py
4,152
4.03125
4
# **************************************************************************** # # # # ::: :::::::: # # snakegame.py :+: :+: :+: ...
04be6b60570dfc9f60a12ac27f64897643e484fe
balajisraghavan/micropython-debounce-switch
/example/main.py
803
3.53125
4
import machine from switch import Switch import time def main(): switch_pin = machine.Pin(5, machine.Pin.IN, machine.Pin.PULL_UP) my_switch = Switch(switch_pin) while True: my_switch_new_value = False # Disable interrupts for a short time to read shared variable irq_state = machi...
73882337a6c315e32bf77889b8425d8953cf2382
Mahek2000/Python-Intership
/D3/For list.py
69
3.84375
4
list1=[10,20,"Mahek kalariya"] for i in list1: print("Value is :",i)
fcf0f7aa93c1f00a441ff5e3a966df5a95522243
NickMonks/AlgorithmsAndDataStructure
/QuickSort.py
2,450
4.40625
4
import unittest # Best Time : O(n log n) | space O(n log n) def quickSort(array): # Explanation of quick sort: we use the Quick sort technique, which consist of declaring # three pointers: the pivot (P), which is the number we will sort, Left (L) # which is the leftmost element of the subarray , and Right (R). The ...
7d278ddd00a0c1453cf4aa0f955f1e9fc34f4325
rafaelperazzo/programacao-web
/moodledata/vpl_data/55/usersdata/67/23114/submittedfiles/av2_p3_civil.py
206
3.609375
4
# -*- coding: utf-8 -*- from __future__ import division import numpy as np n=input("Digite a dimensão da matriz:") pdp=input("Digite a posição a qual deseja pesar o valor da peça:") linha=n coluna=n
d8e541384f506e5f6e89b13e85b5b1bc7db54c5a
Samkiroko/python-data-structure-and-algorithms
/.history/Recursion/note_20210512154854.py
2,554
4.3125
4
# def factorial(n): # assert n >= 0 and int(n) == n, 'The number must be positive integer only' # if n in [0, 1]: # return 1 # else: # return n * factorial(n-1) # print(factorial(10)) # Fibonacci number - Recursion # def fibonacci(n): # assert n >= 0 and int(n) == n, 'The number must...
1ef246ae2041d8c8b1cda75c6e637131b8002caf
David27XG/Train-Problems
/trainsproblem.py
3,965
3.578125
4
from railway import RailSystem, NoSuchRoute, NoSuchStation """Data for the examples. Test Input: For the test input, the towns are named using the first few letters of the alphabet from A to D. A route between two towns (A to B) with a distance of 5 is represented as AB5. Graph: AB5, BC4, CD8, DC8, DE6, AD5,...
bf87bfb3e34363db827155d6c25b3745594a9a27
raj-andy1/mypythoncode
/AnandthirthRajagopalan_Homework5.py
824
4.0625
4
""" Homework5 - Anandthirth Rajagopalan """ total = 0 myNumList = [] while True: userNum = input("Enter a number:") if userNum == '': break try: userNum = float(userNum) except: print("That's not an integer") continue myNumList.append(userNum) #print (myNumList) ...
25891f02b31468e6d4f25b595fae6ef3e9620c74
Jashwanth-k/Data-Structures-and-Algorithms
/11. Graphs/DFS code .py
1,517
3.515625
4
class Graph: def __init__(self,nVertices): self.nVertices = nVertices self.adjMatrix = [[0 for i in range(nVertices)]for i in range(nVertices)] #same as 2D array def addEdge(self,v1,v2): self.adjMatrix[v1][v2] = 1 self.adjMatrix[v2][v1] = 1 def removeEdge(self,v1...
a56d322336ea2ffdf874925beb192b4d83d6e701
MapsaBootCamp/django5
/Algorithm_Section/sorting/merge-sort.py
739
4.1875
4
def merge_sort(arr): middle_len = len(arr) // 2 if len(arr) > 1: left = arr[:middle_len] right = arr[middle_len:] left = merge_sort(left) right = merge_sort(right) arr = [] print("left: ", left) print("right: ", right) while len(left) > 0 and len...
1e96e2a651e0fbc0908f6643943768cc63ef4625
adam-weiler/GA-OOP-Inheritance-Part-3
/system.py
2,367
4.03125
4
class System(): all_bodies = [] #Stores all bodies from every solar system. def __init__(self, name): self.name = name self.bodies = [] #Stores only bodies from this solar system. def __str__(self): return f'The {self.name} system.' def add(self, celestial_body): i...
f1dec1d21481e4e05b0e76ae8bf0a0041910232c
Jgoschke86/Jay
/Classes/py3intro/EXAMPLES/math_operators.py
190
3.75
4
#!/usr/bin/python3 x = 5 x += 10 y = 22 y *= 3 z = 98.7 print("x is ",x) print("y is ",y) print("2^16",2**16) print("x / y",x/y) print("x // y",x//y) print("x / z",x/z) print("x // z",x//z)
983ec2073a864c41d8786853f77ca5e632148828
qinzhouhit/leetcode
/subsets/95generateTrees.py
1,447
3.640625
4
''' keys: Solutions: Similar: 96 T: n*G S: n*G, G as the Catalan number G(n) = 4^n / (n^(3/2)) ''' # Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: # Estimated time ...
13192fb881efa7d327182876f729dd29ba1776d4
gourav47/Let-us-learn-python
/8 simple interest and addition.py
288
3.90625
4
p=input("Enter principle amount: ") r=input("Enter rate of interest: ") t=input("Enter the time: ") si=float(p)*float(r)*float(t)/100 print("simple interest is:", si) x=input('Enter 1st number: ') y=input('Enter 2nd number: ') z=int(x)+int(y) print('sum of two number is: ',z)
3ae1e409a87c5500a9267fef6742009191ea9b23
EmyTest/untitled5
/pr.py
354
3.984375
4
import practise def main(): x = float(input("enter x-coordinate of point: ")) y = float(input("enter y-coordinate of point: ")) z = float(input("enter z-coordinate of point: ")) h = float(input("enter h-coordinate of point: ")) p=practise.Point(x,y,z,h) print("distance from origin:{0:,.2f}".form...
5b02830b73b56e68d91bd98bb8e05ad8972095df
boniaditya/scraping
/SoupTest.py
607
3.546875
4
import urllib2 from bs4 import BeautifulSoup def getTitle(url): try: html = urllib2.urlopen(url) except urllib2.HTTPError as e: return None try: bsObj = BeautifulSoup(html.read()) title = bsObj.body.h1 except AttributeError as e: return None return title tit...
8d7539f982fd59911afbef3ddb39f47a9b363cc2
nikhilbommu/DS-PS-Algorithms
/Leetcode/LeetCode Problems/NumberofStepstoReduceaNumbertoZero.py
275
3.53125
4
class Solution: def numberOfSteps (self, num): count=0 while num != 0 : if num%2 == 0: num = num//2 else: num -= 1 count += 1 return count s = Solution() print(s.numberOfSteps(6))
371f213a07011e44095ec0d14c4fbb9d4f84bcf7
Xzib/piaic
/nested_loops.py
390
3.578125
4
# my_list = [1,2,3,4,5,6,7,8,9,10] # for val in my_list: # count = len(my_list) # item = val*2 # list_2=item # print(list_2) # for i in my_list: # for x in range(4): # print(i,x) user_val = int(input('Énter value one: ')) user_val_1 = int(input('Énter value two: ')) for i in range(user_val...
e8bf3b7b3a4f37a80f65580316565b294e5caa4d
devsantoss/lambda
/EjerMuerteSubita.py
1,359
3.921875
4
""" @author: David S 1. Usando map extraer de una lista de listas el primer y ultimo elemento de cada lista 2. Dada una lista de numeros enteros, usando map y filter retornar una lista con los numeros superpares(Todos los digitos son pares) 3. Usando reduce y map extraer los valores máximos de cada lista de una l...
512042886111c1af160244b2f75c11184a87f659
edward-murrell/robot
/robot/parser.py
1,741
3.875
4
from robot import Robot, Aim class Parser: """ Parse lines into robot commands. """ def __init__(self, robot: Robot): """ Wrap a parser around a robot object. :param robot: Constructed Robot object. """ self.__robot = robot self.__map = { '...
84a369ef1fb43fa0d7330a568a009b3124f169e8
Aasthaengg/IBMdataset
/Python_codes/p02686/s254604144.py
1,150
3.9375
4
from collections import namedtuple Line = namedtuple('Line', ['lowest', 'end']) def main(): N = int(input()) up_lines = [] down_lines = [] for i in range(N): s = input() now = 0 lowest = 0 for c in s: if c == "(": now += 1 else: ...
e85e04eaa3bce7a2487b579ac3c19598532f8dd9
StuartJSquires/solar-system-sim
/class_definitions.py
8,077
3.71875
4
from read_input import read_body from itertools import chain, imap import numpy as np import os class Body(object): """This is the class used for all bodies. We might want to make subclasses for different types of bodies at some point in the future. Attributes: name: the name of the body ...
3e34e9f79401253a736881a6da0e0276a9b28f53
kurakikyrakiujarod/python_
/day47/05 多继承以及MRO顺序.py
5,639
4.21875
4
# 多继承以及MRO顺序 # 1. 单独调用父类的方法 class Parent(object): def __init__(self, name): print('parent的init开始被调用') self.name = name print('parent的init结束被调用') class Son1(Parent): def __init__(self, name, age): print('Son1的init开始被调用') self.age = age Parent.__init__(self, na...
a158f7cd365f57f1251d879528232508d3d2cb73
DreamisSleep/pySelf
/chap5/sum_all_with_default.py
444
3.953125
4
# 기본 매개변수와 키워드 매개변수를 활용해 범위의 정수를 더하는 함수 # 함수 선언 def sum_all(start=0, end=100, step=1): # 변수 선언 output = 0 # 반복문을 돌려 숫자를 더한다. for i in range(start, end+1, step): output += i # 리턴 return output # 함수 호출 print("A.", sum_all(0, 100, 10)) print("B.", sum_all(end=100)) print("C.", sum_all(end...
890de0f72382467c74121042c435ff9cd854e953
thatmatt24/Network-Security
/TEA_Encryption.py
2,014
3.921875
4
""" Tiny Encryption Algorithm (TEA): Takes user inputs K0, K1, K2, K3, L0, R0 as strings, converts to hexadecimal. Encrypts using two rounds of blocks, resulting in L1 and R1, and L2 and R2. With L2 and R2 representing the final results. Author: Matt McMahon Date: 9/1/19 """ from ctypes import c_uint32 as u32 DEL...
9a756fc8eac6f99a6e95a7cbe9e99c04ce777eb0
xpony/LearnPython
/filter.py
2,078
4.25
4
#filter( )函数 用于过滤序列。同样接收一个函数和一个序列,把传入的函数依次作用于每个元素, #然后根据返回值是True还是False决定保留还是丢弃该元素。和map()一样返回的是Iterator #例如,在一个list中,删掉偶数,只保留奇数,可以这么写: def is_odd(n): return n % 2 == 1 # 判断是否为奇数 num = filter(is_odd, [1, 2, 3, 4, 5, 6, 10]) print(list(num)) #把一个序列中的空字符串删掉,可以这么写: def not_empty(s): return s and s.strip() #strip()去除字...
d12cd79e67929b300c0a2ad4a45484a2be032e37
aqc112420/meachine-learning
/Machine-learning/Adaboost/caogao.py
132
3.671875
4
a = [1,3,5,7,9,11,13,15] for x in a: for y in a: for z in a: if x + y + z ==30: print(x,y,z)
45e392d3cbcdd7d58bf033475786a5ed6f1c9d21
rabeeaatif/Photo-Editing-using-Python
/image_operations.py
15,814
3.9375
4
from PIL import Image import array as arr import math import copy ### Parent Class MyList and its Iterator ### class MyListIterator: ''' Iterator class to make MyList iterable. https://thispointer.com/python-how-to-make-a-class-iterable-create-iterator-class-for-it/ ''' def __init__(self, lst): ...
609db306b29533fa346b56fe367ef86654bdfd26
vippiv/python-demo
/demo/module/module1-demo.py
576
3.765625
4
# 模块,一个python文件就是一个模块,每个python都应该是可以导入的 # 导入模块时,python会搜索当前目录指定模块名的文件,如果有直接导入 # 如果没有,再搜索系统目录(由于存在这种行为,如果定义一个和系统模块重名的文件,将导致系统模块无效) import m1 import m2 import random m1.say_hello() m2.say_hello() c = m1.Cat() print(c) d = m2.Dog() print(d) print("+" * 100) print("生成随机数") print(random.randint(0, 10)) print("当前模块加载路径...
47c3857fc22632de47f97b6ddf6ab2207765a9d9
asenyarb/Pool-Game
/ball.py
7,041
3.671875
4
from cfg import * from vector import Vector from utils import * class Ball: location: [int, int] radius: float mass: float velocity: Vector force: Vector impulse: Vector graphical_radius: int chosen: bool def __init__(self, add_to_balls_array: bool = False, location: (int, int) = ...
03e4892a9226b932874a12606fdb7dcaf7eed484
iRobot2397/Discord_Bot
/Discord Bot.py
2,359
4.34375
4
def calculator(): operation = input("Which operation would you like to do(+, -, *, /): ") number1 = float(input("Enter the first number: ")) number2 = float(input("Enter the second number: ")) whole = input("Would you like to round to a whole number(y/n): ") #addition if operation == "+"...
2f09215dd2a91b7f5a1d4e3b2d6e572bd809dd28
awhitney1/cmpt120Whitney
/IntroProgrammingLabs/madlib.py
272
3.5625
4
# Andrew Whitney # Intro to Programming adjective = input("Enter an adjective: ") noun = input("Enter a noun: ") verb = input("Enter a verb: ") adverb = input("Enter an adverb: ") print("Your MadLib:") print("The", adjective, noun, verb, adverb, "under the quick red fox.")
4ee52a0c2d68fcab9090fb904ca2d451ee14466c
Iverance/leetcode
/505.the-maze-ii.py
3,513
3.6875
4
# # [505] The Maze II # # https://leetcode.com/problems/the-maze-ii # # algorithms # Medium (38.57%) # Total Accepted: 8.6K # Total Submissions: 22.4K # Testcase Example: '[[0,0,1,0,0],[0,0,0,0,0],[0,0,0,1,0],[1,1,0,1,1],[0,0,0,0,0]]\n[0,4]\n[4,4]' # # There is a ball in a maze with empty spaces and walls. The ball...
be89a3d690370f7896d35a9ae9f090a5d0b77521
jiinmoon/Python_Projects
/Code_Challenges/square_root.py
343
3.75
4
# Problem #18 def herons_method(x, n): result = 1 for _ in range(0, n): result = (result + x / result) / 2 return result def main(): f = open('test_square_root.txt', 'r') f.readline() for line in f: (x, n) = map(lambda x: int(x), line.strip().split()) print(herons_method(x, n)) if __name__ ...
9302c6df0084c15b44ed020a3f410c4cde0860f7
nunoa94/Python-Simple-API
/app.py
529
3.59375
4
#import flask module from flask package. #It is used to create instances of web applications. from flask import Flask #creating instance of web application app = Flask(__name__) #define the route @app.route("/") #define function that will be executed when we access the route above def hello(): return "Hello Wor...
bfe9d0427fe9c6946ccae5549a93d795a1a3d12a
yuyangzi/python_study
/src/basic/7-03.py
233
3.515625
4
`# for x in range(0, 10): # print(x) # for x in range(0, 1+9, 2): # print(x, end= ' | ') a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] # for x in a: # if x % 2 == 0: # print(a[x]) print(len(a)) b = a[0:len(a):2] print(b)
bbe0d2cf910fb3f5ebd049fe5b26bf40e4de9d8b
rodolfocruzbsb/clean-jboss-tmp-directories
/Banco.py
512
3.5625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- #importando módulo do SQlite import sqlite3 class Banco(): def __init__(self): self.conexao = sqlite3.connect('favorites.db') self.createTable() def createTable(self): c = self.conexao.cursor() c.execute("""create table if not exists favorite_ser...
12e28ec2d8129ef34a3a589d6a745c946d1a9cb7
KelwinKomka/JudgeProblems
/Python/1060.py
422
3.65625
4
a = float(input()) b = float(input()) c = float(input()) d = float(input()) e = float(input()) f = float(input()) positivo = 0 if (a > 0): positivo = positivo + 1 if (b > 0): positivo = positivo + 1 if (c > 0): positivo = positivo + 1 if (d > 0): positivo = positivo + 1 if (e > 0): positivo = ...
fc893699e2ea2aa155f7d59ef2886f06c255b0c2
MonstroVini/Spock1
/Game.py
2,123
3.65625
4
# -*- coding: utf-8 -*- """ Created on Wed Mar 18 15:46:30 2015 @author: viniciusra """ import random print ('Vamos jogar?') print ('Regras do jogo:') print ('papel cobre pedra') print ('papel refuta spock') print ('spock vaporiza pedra') print ('spock esmaga tesoura') print ('tesoura corta papel') print ('tesoura de...
4ac9f33875709596c227c3dfb607fe3cad5dd167
yusseef/Tkinter-simple-Calculator
/Tkinter Calculator.py
996
4.09375
4
from tkinter import * def calculation(): number1=Entry.get(E1) number2=Entry.get(E2) operator=Entry.get(E3) number1=int(number1) number2=int(number2) if operator=="+": answer=number1+number2 if operator=="-": answer=number1-number2 if operator=="*": answer=number1...
4442b41065a8a470acfe0225555536c2613ca0ef
chandraprakashh/Data_Handling
/Day_1_revision_python/looping_concept.py
1,171
3.96875
4
# -*- coding: utf-8 -*- """ Created on Mon Aug 19 11:09:14 2019 @author: BSDU """ """Hands On 1 # Print all the numbers from 1 to 10 using condition in while loop """ """ Hands On 3 # Print all the even numbers from 1 to 10 using condition in while loop """ """ Hands On 5 # Print all the odd n...
e8721e6742daa08d1f2e4c9e4bfc2e204d66109f
omerRabin/monitoring
/Manual.py
2,413
3.609375
4
import string import datetime class Manual: def __init__(self, timestamp_a, timestamp_b): self.timestamp_a = timestamp_a self.timestamp_b = timestamp_b self.year = datetime.date.today().year # self.month = datetime.date.today().month txt = open("serviceList.txt"...
c2181b4682b93f830f432ca3a10f55696879e104
joshurban5/Data-Structures-and-Algorithms
/BST_Test.py
10,334
4.0625
4
################################################################# # Team Name: TheRevenant # Binary Search Tree Unit Testing Class # Project IV: Less Left, More Right # CSCI 241: Data Structures and Algorithms ################################################################# import unittest from Binary_Search_Tree impo...
a17989a2004a69988f47225d29f29a6cb790fd0c
hnz71211/Python-Basis
/com.lxh/exercises/20_get_dict_value/__init__.py
223
3.8125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 以列表形式返回字典 {‘Alice’: 20, ‘Beth’: 18, ‘Cecil’: 21} 中所有的值 dict = {'Alice': 20, 'Beth': 18, 'Cecil': 21} L = list(dict.values()) print(L)
82691c706c7b837cb8e86b947867610adbeb17cb
leighlondon/foobar
/when_it_rains_it_pours/solution.py
4,285
3.8125
4
""" The solution to the "when_it_rains_it_pours" problem. """ def answer(heights): """ The solution. Move along the list of heights, starting at index 0, and search for a local maxima (a 'peak'). If next neighbour to the right is higher, then discard the current peak and move forward. I...
d89f8866bd35dbc794de6c20e906284bb676d356
Yashasvii/Project-Euler-Solutions-hackerrank
/forProjectEuler/002.py
594
3.90625
4
""" Project Euler Problem 2 ======================= Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... Find the sum of all the even-valued terms in the sequence which do ...
02ed404fc401f4d4544481dc429657073b7c936d
SergiodeGrandchant/introprogramacion
/practico/ejercicio3.py
356
3.90625
4
# https://bit.ly/36LtifW dividendo = int(input("Dame el dividendo: ")) divisor = int(input("Dame el divisor: ")) cociente = dividendo // divisor resto = dividendo % divisor if dividendo % divisor == 0: print("La division dada es exacta") else: print("La division dada no es exacta") print("El cociente es: ", coc...
fe3c3d77c33c68e02b746af7f17450104b715b46
qcgm1978/py-test
/test/others/args.py
2,701
3.65625
4
import unittest class TestIs(unittest.TestCase): def testArgs(self): # Python program to illustrate # *args for variable number of arguments def myFun(*argv): aList=[] for arg in argv: aList.append (arg) return aList self.ass...
ef177c1651a700ced2a8e7bafd3342c38f0873d2
amitray1608/PCcodes
/python/while.py
201
4.09375
4
#18BCS2059 #AMIT KUMAR ''' PROGRAM TO IMPLEMENT WHILE LOOP AND PRINT EVEN NUMBERS IN A RANGE (1 - 20) ''' n = 20; i = 1 print("Even numbers in the range 1 - 20") while i <= 20: if(~i&1): print(i) i+=1
556b2fd6d7cbaffa3e6ff5ea60d23505e1b4fb2e
DillonCh/youtube_to_spotify
/custom/youtube_to_spotify.py
3,319
3.921875
4
""" Add Youtube liked songs to a playlist in Spotify Tasks: Step 1. log into youtube Step 2. Get to liked videos Step 3. Create a new playlist Step 4. Search for the song in spotify Step 5. Add the song to the new playlist API's: Youtube API Spotify Web API youtube-dl library """ from datetime import datetime as dt ...