blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
b655ad3772335af93c62e9b9f0c19f21b1f17cb5
timothylevi/exercism-py
/leap/leap.py
354
4.125
4
def is_leap_year(year): """Return true if year is determined to be a leap year.""" def year_div_by(num): """Return true if year is divisible by number.""" return year % num == 0 if year_div_by(400): return True elif year_div_by(100): return False elif year_div_by(4): ...
34ba44d6f637f70dc2d369227d945b5ab7e1dde4
NathanTCz/clustering
/proj1.py
9,837
3.75
4
# ------- K-MEANS AND AVERAGE LINKAGE CLUSTERING -------- # COMMAND LINE INPUT: # 1. Data File: tab delimited excel file or space delimited # values # 2. K: specifically the number of desired clusters # 3. Algorithm: 'kmeans' or 'average' # DESCRIPTION: # This python script aims to implement Lloyds Method ...
0297b491001fe465476530f549156a4143e65f1c
asifs-cse/ACOE-Programming-Assignment
/Data Type/Python Dictionaries.py
438
3.78125
4
thisdict = { "name": "Asif", "branch": "Computer", "roll": "20MH1A0504", "birth": 1999 } print(thisdict) #check length print(len(thisdict)) #check type print(type(thisdict)) thisdict = { "name": "Asif", "branch": "Computer", "roll": "20MH1A0504", "birth": 1999 } x = thisdict.keys() print(x) #before...
7d67f1ab84e2d4b4da8f63db30c6a17da8bcafd4
kaiyiyu/DSA1002
/Practicals/P02/hanoi.py
771
3.625
4
# Towers of Hanoi class Hanoi: count = 1 # used a global and could refactor more but it works! lol def __init__(self): pass def moveTower(self, disks, src, dest, aux): if disks == 1: self.moveDisk(src,dest) elif disks >= 1: self.moveTow...
3464dbd3acbed10b6afc3daab69159d87d6e553f
UCU-programming-tasks/palindrome_list
/palindrome_list.py
1,593
3.828125
4
'''Palindrome class realization.''' from arraystack import ArrayStack class Palindrome: ''' Class for reading and writing data to files and finding palindromes. ''' @staticmethod def read_file(filename: str) -> list: ''' Read words from file. ''' with open(filenam...
25b1606edf5a06ffbbb11a0d6770c4ef320bcbeb
IA-MP/KnightTour
/libs/graph/PriorityQueue.py
5,617
4
4
class BinaryHeapNode: def __init__(self, elem, key, index): """ this class represents a generic binary heap node :param elem: the elem to store :param key: int, the key to be used as priority function :param index: int, the index related to the binary node """ ...
ac4a5a7fecc3ec0884be73d9906985cd34ce77ef
CarlVs96/Curso-Python
/Curso Python/8 Archivos externos/Video 37 - Manejo de archivos/Manejo_archivos.py
772
3.5625
4
from io import open #SIEMPRE CREAR -> ABRIR -> MANIPULAR -> CERRAR #Modo escritura """archivo_texto=open("archivo.txt", "w") frase = "Una tarde estupenda para estudiar Python \neste Lunes" archivo_texto.write(frase) archivo_texto.close()""" #Modo lectura """archivo_texto=open("archivo.txt", "r") texto=archivo_texto.re...
8c6d72c7b740db74c54231964de566e0cdf11d3d
CarlVs96/Curso-Python
/Curso Python/Ejercicios/Video 16/Ejercicio2.py
312
3.953125
4
print("Introduce una contraseña con 8 o más caracteres y sin espacios") password=input("Contraseña: ") validez=True if len(password)>=8: for i in range(len(password)): if password[i]==" ": validez = False else: validez = False if validez: print("Contraseña OK") else: print("Contraseña errónea")
efad52eee5990a0c17a0a2437b0eb62473ec5f32
CarlVs96/Curso-Python
/Curso Python/3 Bucles/Video 14, 15, 16 - Bucles - FOR, RANGES/Bucle_for.py
565
3.96875
4
for i in [1,2,3]: print("Hola") for i in ["primavera","verano","otoño","invierno"]: print(i) #Para que no haga salto de linea for i in ["Hola","que","tal"]: print(i, end=" ") print() #Iteraccion tantas como caracteres #Comprobar si un email es correcto por tener arroba y punto email=False miEmail=input("Introdu...
6be0e0f8fcce41f8345ccedbbf3e4f6885a7b694
CarlVs96/Curso-Python
/Curso Python/4 Generadores/Video 20 - Generadores YIELD FROM/Generadores_yieldFrom.py
723
4.125
4
#Funcion generador que devuelva ciudades #El asterisco significa que se va a recibir un numero indeterminado de elementos. Y en forma de tupla def devuelveCiudades(*ciudades): for elemento in ciudades: for subElemento in elemento: yield subElemento ciudadesDevueltas=devuelveCiudades("Madrid", "Barcelona", "Bilba...
38a0bfe447a4fea1c2a10431c9a44c64c5c65316
CarlVs96/Curso-Python
/Curso Python/8 Archivos externos/Video 38 - Manejo de archivos 2/Manejo_archivos_II.py
506
3.515625
4
from io import open archivo_texto=open("archivo.txt", "r+") # Lectura y escritura #Modificar posicion del puntero. seek(numero del caracter) archivo_texto.write("Hola") print(archivo_texto.read()) #Aqui el puntero se ubica al final, ya que ha leido justo antes print(archivo_texto.read()) archivo_texto.seek(0) print(a...
84545bc4433d7f3f73f9b059c0c136d5e329c978
TomiSar/ProgrammingMOOC2020
/osa09-02_hyvaksytyt_suoritukset/src/hyvaksytyt_suoritukset.py
1,111
3.734375
4
# ÄLÄ MUUTA LUOKKAA Koesuoritus class Koesuoritus: def __init__(self, suorittaja: str, pisteet: int): self.suorittaja = suorittaja self.pisteet = pisteet def __str__(self): return f'Koesuoritus (suorittaja: {self.suorittaja}, pisteet: {self.pisteet})' # TEE RATKAISUSI TÄHÄN: ...
1c54628b85aec92092291b1eacc9309c72f2bf60
TomiSar/ProgrammingMOOC2020
/osa10-08_paivays/src/paivays.py
2,975
3.515625
4
# Tässä tehtävässä toteutetaan luokka Paivays, jonka avulla on mahdollista käsitellä päivämääriä. # Oletetaan tässä tehtävässä yksinkertaisuuden vuoksi, että jokaisessa kuussa on 30 päivää. # Edellisestä johtuen tehtävässä ei poikkeuksellisesti kannata käyttää Pythonin datetime-moduulia. # Toteutetaan luokka itse. ...
0f5735e6c0201b8c8852c1c10dd91b3cb586dd0c
TomiSar/ProgrammingMOOC2020
/osa05-18_vanhin_henkiloista/src/vanhin_henkiloista.py
406
3.65625
4
def vanhin(henkilot: list): vanhin = [] for i in henkilot: vanhin.append(i[1]) hakusana = min(vanhin) for i in henkilot: if hakusana == i[1]: return i[0] if __name__ == "__main__": h1 = ("Arto", 1977) h2 = ("Einari", 1985) h3 = ("Maija", 1953) ...
fe0ec3f85d7fee2ad6c60c5c9f0002f377b8e0f2
TomiSar/ProgrammingMOOC2020
/osa02-18_salasana_uudelleen/src/salasana_uudelleen.py
210
3.859375
4
salasana = input("Salasana: ") while True: salasanauusiksi = input("Salasana: ") if salasana == salasanauusiksi: break print("Ei ollut sama!") print("Käyttäjätunnus luotu!")
560ea49cf6d2060da12b70f313bd9e49821a3ea3
TomiSar/ProgrammingMOOC2020
/osa05-04_sudoku_osa2/src/sudoku_sarake.py
668
3.78125
4
def sarake_oikein(sudoku: list, sarake: int): luvut = [] for rivi in sudoku: luku = rivi[sarake] if luku > 0 and luku in luvut: return False luvut.append(luku) return True #main if __name__ == "__main__": sudoku = [ [9, 0, 0, 0, 8, 0, 3, 0, 0], ...
89689584d7775c029765db33ff22346ee4cd0cd4
TomiSar/ProgrammingMOOC2020
/osa03-15_toinen_esiintyma/src/toinen_esiintyma.py
450
3.8125
4
jono = input("Anna merkkijono: ") osajono = input("Anna osajono: ") eka = jono.find(osajono) #eka esiintymä jono = jono[eka + 1:] #kasvatetaan eka esiintyminen indeksiä yhdellä ja jatketaan hakua toka = jono.find(osajono) #katsotaan löytyykö merkkijonosta toista esiintymää if toka != -1: print("Osajonon t...
450cbc07b5b5e836cb2ba6eb7492176a16a32292
TomiSar/ProgrammingMOOC2020
/osa09-03_kasvatuslaitos/src/kasvatuslaitos.py
2,143
3.9375
4
# Älä muuta luokkaa Henkilo! class Henkilo: def __init__(self, nimi: str, ika: int, pituus: int, paino: int): self.nimi = nimi self.ika = ika self.pituus = pituus self.paino = paino class Kasvatuslaitos: def __init__(self): self.punnitusten_lkm = 0 # Saa...
e3070df1d76ccad6a7c3067c42a4815681eddcdf
TomiSar/ProgrammingMOOC2020
/osa05-17c_muodosta_tuple/src/muodosta_tuple.py
511
3.8125
4
def tee_tuple(x: int, y: int, z: int): lista = [] lista.append(x) lista.append(y) lista.append(z) pienin = min(lista) suurin = max(lista) summa = sum(lista) tuple = (pienin, suurin, summa) return(tuple[0], tuple[1], tuple[2]) if __name__ == "__main__": print(tee_tu...
8cf546f99c9168f6f63fb8710f9cd27d21bc2290
TomiSar/ProgrammingMOOC2020
/osa12-03_pisteiden_mukaan/src/pisteiden_mukaan.py
822
3.59375
4
# Tee funktio jarjesta_pisteiden_mukaan(alkiot: list). Funktio saa parametrina listan sanakirjoja, # jotka edustavat yksittäisiä TV-sarjoja, ja järjestää ne pisteiden mukaiseen laskevaan järjestykseen. # Funktio ei muuta parametrina olevaa listaa, vaan palauttaa uuden listan. def jarjesta_pisteiden_mukaan(alkiot: ...
2db220f51f05c297df4f8f12fb22f1bf9ecfd4c4
TomiSar/ProgrammingMOOC2020
/osa05-03_sudoku_osa1/src/sudoku_rivi.py
973
3.78125
4
def rivi_oikein(sudoku: list, rivi: int): luvut = [] for luku in sudoku[rivi]: if luku > 0 and luku in luvut: return False luvut.append(luku) return True # Tee funktio rivi_oikein(sudoku: list, rivi: int), joka saa parametriksi sudokuruudukkoa esittävän kaksiulott...
e4bb1f09de2814e430836b78599e2432e69b4caf
TomiSar/ProgrammingMOOC2020
/osa08-01_pienin_keskiarvo/src/pienin_keskiarvo.py
790
3.578125
4
def henkilon_keskiarvo(henkilo: dict): return henkilo["tulos1"] + henkilo["tulos2"] + henkilo["tulos3"] / len(henkilo) def pienin_keskiarvo(henkilo1: dict, henkilo2: dict, henkilo3: dict): pienin_henkilo = henkilo1 if henkilon_keskiarvo(henkilo2) < henkilon_keskiarvo(pienin_henkilo): pienin_h...
6f5e6d39ae9d248af31a3d40e559c33e7b690323
TomiSar/ProgrammingMOOC2020
/osa09-08_huoneen_lyhin/src/huoneen_lyhin.py
2,924
3.640625
4
class Henkilo: def __init__(self, nimi: str, pituus: int): self.nimi = nimi self.pituus = pituus def __str__(self): return self.nimi class Huone: def __init__(self): self.henkilot = [] # lisää huoneeseen parametrina annetun henkilön def lisaa(self, he...
5e24631f876f7602e1b89fc9cea5d081c6441526
TomiSar/ProgrammingMOOC2020
/osa02-22_lukujen_kasittelya/src/lukujen_kasittelya.py
463
3.6875
4
print("Syötä kokonaislukuja, 0 lopettaa:") luvut = 0 summa = 0 positiiviset = 0 while True: luku = int(input("Luku: ")) if luku == 0: break luvut += 1 summa += luku if luku > 0: positiiviset += 1 print(f"Lukuja yhteensä {luvut}") print(f"Lukujen summa ...
5c22681963a795f1fb9c2424cf8d4e9a914aab15
jiaqingxie/Fea2Fea
/src/utils.py
2,810
3.53125
4
from itertools import chain, combinations from sklearn.manifold import TSNE import matplotlib.pyplot as plt import matplotlib.colors as colors import numpy as np def powerset(iterable): s = list(iterable) return chain.from_iterable(combinations(s, r) for r in range(len(s)+1)) def subset(a, b): # for exam...
c05e933761f1a14bf307d77aeb5a24ae19f63d46
JiaqiuWang/DataStatusPrediction
/DataPreprocessing/排序算法/快速排序方法1.py
769
4.03125
4
# Method1 def quickSort(arr): less = [] pivotList = [] more = [] if len(arr) <= 1: return arr else: pivot = arr[0] # 将第一个值作为基准 print("pivot:", pivot) for i in arr: if i < pivot: less.append(i) elif i > pivot: ...
9f59506105229a531e07dc5e91c70b0dcf087dc2
JiaqiuWang/DataStatusPrediction
/DataPreprocessing/数据模型/测试/Test5.py
1,725
3.953125
4
""" We already saw in Loading and saving RDF, how triples can be added with with the parse() function. Triples can also be added with the add() function: Graph.add((s, p, o))[source] Add a triple with self as context """ from rdflib import Graph from rdflib import Namespace from rdflib import BNode, Literal from rdfli...
9dee3a96f9e0aa4e224c7ddb298a5c3d2766ea55
JiaqiuWang/DataStatusPrediction
/GenerateData/networkx/generate.py
432
3.875
4
""" Name: Generate Graph: regular graph Author: Jia_qiu Wang(王佳秋) Data: December, 2016 function: """ import networkx as nx import matplotlib.pyplot as plt # regular graph # generate a regular graph which has 20 nodes has 3 neighbour nodes RG = nx.random_graphs.random_regular_graph(3, 20) # the spectral layout pos = n...
1338134a052ab683f83fd99b66eb67c7bbed292f
igor-morawski/FIR_CNN_LSTM
/tools/augmentation.py
1,355
3.75
4
""" For data augmentation of sequences: - temperature (frames, H, W) - flow (frames, H, W, 2) - channels are x, y components """ import numpy as np from numpy.random import randint def random_rotation(array, case = None): '''rotate 0, 90, 180 or 270 degrees (1/4 probability for each of the options) if case is ...
f0e30b20714ce45caf3dbae7466d7a1608fff350
fairofif/PraktikumPengantarKomputasi
/Modul2/H02_16520251_01.py
909
3.765625
4
''' NIM : 16520251 Nama : Rofif Fairuz Hawary Sesi/Kelas : 3.1/D Tanggal : 1 November 2020 Deskripsi : Program ini untuk mencacah bilangan dari 1 ke N Variable Dictionary: N = integer, dimasukkan user sebagai batas looping i = integer, sebagai bilangan kondisi looping ''' # algorithm N = int(inp...
1f8d9831ca97cb41ce5e76939e0d0488f2503766
fairofif/PraktikumPengantarKomputasi
/Modul1/P01_16520251_03.py
1,875
3.703125
4
''' NIM : 16520251 Nama : Rofif Fairuz Hawary Sesi/Kelas : 3.1/D Tanggal : 21 Oktober 2020 Deskripsi : Program ini untuk mencari rute terpendek dari 3 titik, yang setelah beres tiga titik ada 1 destinasi tambahan yaitu ke resto Variable Dictionary: ''' #algorithm #titik Tuan Mor(0,0) #titik Tua...
a7b4d03a9b1142d835092e238dbcb4ba84283a25
fairofif/PraktikumPengantarKomputasi
/Modul2/P02_16520251_03.py
641
3.765625
4
''' NIM : 16520251 Nama : Rofif Fairuz Hawary Sesi/Kelas : 3.1/D Tanggal : 4 November 2020 Deskripsi : Program untuk mencetak pola persegi dengan isi bilangan mengurut Variable Dictionary: n = int, 2n sebagai batas kolom dan baris ''' n = int(input("Masukkan bilangan: ")) print("Pola yang terbent...
93da7a296ae0175db9d84cf4a7472997893f0fe8
nzw0905/oop-python
/bike_example.py
1,265
3.671875
4
""" Bike class for use in a retail shop """ from enum import Enum class Condition(Enum): NEW = 1 GOOD = 2 OKAY = 3 BAD = 4 class MethodNotAllowed(Exception): pass class Bike(object): def __init__(self, description, condition, sale_price, cost=0): self.cost = cost self.sale_...
f1f5c8f04678d24eaf44f1ccf99fa96049740d08
devanshchawlaa/OOPS_Project
/source_code/bmr.py
2,047
4.0625
4
# Function to calculate Basal Metabolic Rate def calculate_bmr(weight, height, age, gender): # weight = float(input("Enter your weight in KG: \n")) # height = float(input("Enter your height in cm: \n")) # age = int(input("Enter your age in years:").strip()) # gender = str(input("Are you male? (M/F)")).s...
0660064dfed7890d7beade569a81ce947a9df960
Excannor/Tente-outra-vez
/Tente_outra_vez.py
1,711
3.734375
4
from random import randint title = '''⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠘⢻⠟⠃⡿⠛⠃⣾⣧⢀⡇⠛⣿⠛⢱⡟⠛⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⣿⠀⢰⡏⠉⢀⡇⢹⣾⠁⢀⡟⠀⣸⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠁⠀⠈⠉⠉⠈⠁⠀⠉⠀⠈⠁⠀⠉⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⢀⡴⠶⢦⠀⣴⠀⢠⡆⠶⣶⠶⢠⡶⢶⡄⠀⣴⡆⠀⠀⢰⡆⠀⣴⢠⡶⠶⠰⠶⣶⠄⠀⠀ ⠀⢸⠁⠀⣼⢠⡏⠀⣸⠁⢀⡏⠀⢸⠷⣞⠁⣼⣁⣿⠀⠀⠈⡇⡼⠁⣸⠓⠂...
65e17806bab5664c6dbf2727cf57a09ab3af5815
ProtikBose/Programming-Practice
/Binary Search/Find Peak Elements(Leetcode 162).py
543
3.53125
4
import math class Solution(object): def findPeakElement(self, nums): """ :type nums: List[int] :rtype: int """ def condition(val): return nums[val] > nums[val+1] left, right = 0, len(nums)-1 while left < right...
1ad38266989302faed723d9885dda186c72ac570
ProtikBose/Programming-Practice
/Math/Power of three.py
353
3.828125
4
import math class Solution(object): def isPowerOfThree(self, n): """ :type n: int :rtype: bool """ epsilon = .0000000001 if n<=0 : return False return (math.log(n) / math.log(3) + epsilon) % 1 <= 2 * epsilon n = 728 sol = Solutio...
20373d06848483f9480e9d3da7e5d410be1abf2b
ProtikBose/Programming-Practice
/Sorting/A list of sorting algorithms.py
958
3.8125
4
# O(n^2) def selectionSorting(arr) : for i in range(len(arr)-1) : imin = i for j in range(i+1,len(arr)) : if arr[j] < arr[imin] : imin = j arr[i] , arr[imin] = arr[imin] , arr[i] return arr # O(n^2) def bubbleSorting(arr) : for i in range(1,...
27997a58b56a52e5c86183115c3f564df0974698
ProtikBose/Programming-Practice
/Binary Search Tree/height of a BST.py
473
3.828125
4
class TreeNode(object): def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def maxHeight(root,height): if root == None: return height return max(maxHeight(root.left,height+1),maxHeight(root.right,height+1)) root = Tree...
c32f807ead1457ae8ed69d0c2b4d0eb08ca7492f
MaximJoinedGit/Python-basics
/lesson_3/homework_3.3.py
522
4.5
4
""" 3. Реализовать функцию my_func(), которая принимает три позиционных аргумента, и возвращает сумму наибольших двух аргументов. """ def my_func(*args): """ Function to calculate the sum of two biggest numbers. :param args: 3 positional arguments. :type args: int :return: sum of the two biggest n...
f070cfe6fde7e9a69688bf58b58d0aa8010dca6a
MaximJoinedGit/Python-basics
/lesson_6/homework_6.4.py
3,137
3.515625
4
""" 4. Реализуйте базовый класс Car. У данного класса должны быть следующие атрибуты: speed, color, name, is_police (булево). А также методы: go, stop, turn(direction), которые должны сообщать, что машина поехала, остановилась, повернула (куда). Опишите несколько дочерних классов: TownCar, SportCar, WorkCar, PoliceCar....
13dfbdb43e4f3a03febb632b2ad0cfc3ff34efbd
MaximJoinedGit/Python-basics
/lesson_1/homework_1.5.py
1,629
4.21875
4
""" 5. Запросите у пользователя значения выручки и издержек фирмы. Определите, с каким финансовым результатом работает фирма (прибыль — выручка больше издержек, или убыток — издержки больше выручки). Выведите соответствующее сообщение. Если фирма отработала с прибылью, вычислите рентабельность выручки (соотношение приб...
83c45d400523294e88aefb9ca2666371f77c80ad
MaximJoinedGit/Python-basics
/lesson_3/homework_3.5.py
1,954
4.15625
4
""" 5. Программа запрашивает у пользователя строку чисел, разделенных пробелом. При нажатии Enter должна выводиться сумма чисел. Пользователь может продолжить ввод чисел, разделенных пробелом и снова нажать Enter. Сумма вновь введенных чисел будет добавляться к уже подсчитанной сумме. Но если вместо числа вводится спец...
d39f240d6f1cef364a59c10aa0f326eca5e030f8
MaximJoinedGit/Python-basics
/lesson_5/homework_5.5.py
868
4.09375
4
""" 5. Создать (программно) текстовый файл, записать в него программно набор чисел, разделенных пробелами. Программа должна подсчитывать сумму чисел в файле и выводить ее на экран. """ with open('homework_5.5.txt', 'w', encoding='utf-8') as w: while True: user_input = input('Введите числа через пробел: ') ...
f79dd80e6c51fef0c17182f73454de1a330da0b3
jcybulsk/coding_problems
/picking_numbers.py
751
3.640625
4
#!/bin/python import sys def max_to_choose(arr): # Make a list (initially of zeros) to store the number # of integers of that number *plus* the integers one # number above. Then, after checking all the numbers in # the input array, and adding one in the appropriate # indices, I simply return th...
18245de631c21dc8e74c24ead43bd06974e41854
jimmykdunn/quadcopterVision
/mnist/use_cnn.py
3,839
3.578125
4
# -*- coding: utf-8 -*- """ FUNCTION: use_cnn DESCRIPTION: Uses a trained CNN on a single data example Based on: https://datascience.stackexchange.com/questions/16922/using-tensorflow-model-for-prediction INPUTS: OUTPUTS: INFO: Author: James Dunn, Boston University Thesis work f...
dc06c30a8f627b4a55b6020767b8887ef86ffa86
jimmykdunn/quadcopterVision
/kalman.py
4,216
3.609375
4
# -*- coding: utf-8 -*- """ FILE: kalman.py DESCRIPTION: Defines kalman_filter class for initiating and maintaining a 2-element state through time. INFO: Author: James Dunn, Boston University Thesis work for MS degree in ECE Advisor: Dr. Roberto Tron Email: jkdunn@bu.edu Date: November 2019...
cae7fbaf628bf7d67a706fdbb5850ae0116c66a4
raghav96/Data_Structures
/py/stack.py
688
3.953125
4
class Node: def __init__(self, value): self.key = value self.n = None class Stack: def __init__(self, value=None): val = Node(value) self.top = val def push(self, value): val = Node(value) val.n = self.top self.top = val def pop(self): self.top = self.top.n def top_val(self): print self.top.k...
3a1fadaaea25ef2aac8a4543df0e8b87f492684e
alex637/Exercise_Vector
/Laba.py
2,276
3.6875
4
__author__ = 'student' import math class Vector: def __init__(self, a=None, b=None, c=None): if b != None: # b!=None -> a,b,c - coordinates self.x = float(a) self.y = float(b) self.z = float(c) else: # b=None -> a is string 'x,y,z' ...
efc5f51a106611ecbbf04b1ec4ff1207c11a36fb
kimnakyeong/changeToAWS
/Dr.Foody/scraper/nameScrapper/make_csv.py
212
3.609375
4
import sys def save_to_file(names): file = open("male.txt", "w") #file을 열고 file 변수에 저장 for name in names : file.write(name+'\n') # writer.writerow(job.values()) return
8e15f8d45142cdb1f98b81cda0e8759639010f16
TomAce22/Homework
/Sandwiches/foo1.py
283
3.625
4
userSandwhich = input("How many sandwhiches can you eat?") brotherSandwhich = userSandwhich +1 print "My brother can eat", (brotherSandwhich), "sandwhiches, you lost!" def module_name(): print "this is in the module" print "and so is this" module_name() module_name()
8d2c0074c1f153bcb388f4646b60bd91ca0099ea
aahmadnejad/Largnumber_array
/main.py
451
3.9375
4
def combine(arr): for i in range(len(arr)): for j in range(i+1, len(arr)): num1 = str(arr[i]) + str(arr[j]) num2 = str(arr[j]) + str(arr[i]) if int(num1) > int(num2): pass else: arr[i], arr[j] = arr[j], arr[i] arr = [str(num...
8bbbb54c686487c71ec059185bd18bb41d1a49d6
JasonCL2015/pythondemo
/20191213/hello.py
152
3.65625
4
def add(x, y, f): return f(x) + f(y) def f(x): return x * x r = map(f, [1, 2, 3, 4, 5, 6, 7, 8, 9]) print(list(r)) print(add(-5, 6, abs))
86f99ea78a5ceef491403f2f81897055bcc07bfb
hgarud/Human-Pose-Prediction-GAN
/codebase/Models.py
6,815
3.578125
4
import torch import torch.nn as nn from torch.autograd import Variable class PoseLSTM(nn.Module): """ This class returns an LSTM model instance for pose prediction. Also used as a base class for adversarial R-GAN """ def __init__(self, input_dim = 39, hidden_dim = 26, batch_size = 32, output_dim =...
0712f31ee4cb5072578d6ed66744bb039cf731f2
chc170/CarND-Advanced-Lane-Lines
/project4.py
27,044
3.5625
4
# coding: utf-8 # ## Advanced Lane Finding Project # # The goals / steps of this project are the following: # # 1. Compute the camera calibration matrix and distortion coefficients given a set of chessboard images. # 2. Apply a distortion correction to raw images. # 3. Apply a perspective transform to rectify binar...
9e79c902851c2286ee9b8b8808869776c63bce0e
Doraemonzzz/Data-Science
/MIT Introduction to Computational Thinking and Data Science/Final/Problem 6.py
1,656
3.65625
4
# -*- coding: utf-8 -*- """ Created on Mon Jun 18 22:33:43 2018 @author: Administrator """ import numpy as np def find_combination(choices, total): """ choices: a non-empty list of ints total: a positive int Returns result, a numpy.array of length len(choices) such that * each element ...
870f6e0c18a71e8bcc4d8023e4c4a338ecd3d915
Doraemonzzz/Data-Science
/南大用Python玩转数据/week1/整数质因数分解.py
512
3.9375
4
# -*- coding: utf-8 -*- """ Created on Thu May 24 20:17:12 2018 @author: Administrator """ from math import sqrt m=int(input()) ans=str(m)+"=" def isPrime(x): if x==2: return True else: m=int(sqrt(x))+1 for i in range(2,m): if x%i==0: return False r...
9e042e9ea236d77893da758cd1e57772f85e5724
Doraemonzzz/Data-Science
/MIT Introduction to Computational Thinking and Data Science/week1/ProblemSet1/ps1.py
4,639
3.984375
4
########################### # 6.00.2x Problem Set 1: Space Cows from ps1_partition import get_partitions import time #================================ # Part A: Transporting Space Cows #================================ def load_cows(filename): """ Read the contents of the given file. Assumes the file conte...
8bb993e2731302ca14ac076dd9495c116d51d5cc
comwilson/SortableChallenge
/run.py
1,259
3.515625
4
''' author: Cameron Wilson date: March 10, 2015 description: The main file for the sortable program ''' import json with open("products.txt") as product_file: product_data = [json.loads(line) for line in product_file.readlines()] with open("listings.txt") as listing_file: listing_data = [json.loads(line) for...
61df79d7c33f79e4346be54924aed9fce2b40265
cheng-hsin/salary160
/160hr.py
106
3.5625
4
number = float(input('請輸入工作時數: ')) print('您目前的月薪是%.1f元整' % (number*160))
d05e00fa527392a77e2f0eb18b43028436310de7
llpyyz/InteractivePythonProgramming
/Assignments/memory.py
2,328
3.6875
4
""" Interactive Programming in Python - Memory card game """ import simplegui import random #globals deck = range(8) + range(8) exposed = [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False] state = 0 card1 = -1 card2 = -1 turns = 0 # helper function to init...
168adb77aee6a53f880ed1935529b960cdc97d11
llpyyz/InteractivePythonProgramming
/CodeFromLecture/InteractivePythonProg_Week0_1.py
5,855
4.40625
4
#Interactive Python - Week 0 ######################################################### #Arithmetic expressions - numbers, operators, expressions ######################################################### print 3, -1, 3.14159, -2.8 #two types of numbers int() and float() print type(3), type(3.14159), type(3.0) #conv...
95ec563edf36ce99f2165784769481330d370674
Dyl6886/Dyl6886
/NumStat/numstat.py
580
3.765625
4
import math while (True): try: fp = input("What is the file name? ") file = open(fp) except OSError: print("The filename entered does not exist. ") else: break list = [int(num) for num in file.read().split()] count = len(list) Sum = sum(list) Max = max(list) Min = min(list)...
2ebb7368ea22f725d12189e8f2b43c3c960d75b2
tuhuiting/ceshi
/homework/cat_c.py
591
3.53125
4
#!usr/bin/env python3.9 # -*- coding:utf-8 -*- from animal_f import Animal class Cat(Animal): def __init__(self,name,color,age,gender): super().__init__(name,color,age,gender) self.hair = "short" def talent(self): print(f'{self.name} 会抓老鼠') def spark(self): print(f"{self....
fd21b9d21bec3f8a89c87661a0e0ff8a7147f463
jcalahor/stocks_crawler
/src/parser_util.py
605
3.53125
4
class Parser(object): def __init__(self, buffer): self.index = 0 self.buffer = buffer def move_to(self, token): res = self.buffer.find(token, self.index) if res > -1: self.index = res + len(token) return True return False def extract_between(...
b968ab40bb2947f9f234ea852f6de5f89b38aa41
bhargavimoram/Data-Mining
/Project3.py
1,242
3.734375
4
# assignment 4 #import the package numpy import numpy as np #import the package pandas import pandas as pd #import the package datasets from sklearn from sklearn import datasets #import the package KMeans from sklearn.cluster from sklearn.cluster import KMeans #import matplotlib.pyplot as plt import matpl...
90c6689c92adc11dd635e319abf3866857679bdd
bhargavimoram/Data-Mining
/pca.py
827
3.859375
4
#data mining assignment 3 #import the package pandas import pandas #import numpy import numpy # read the arrhythimia dataset using method read_csv data = pandas.read_csv('arrhythmia.data',header=None) #replace the data using replace method data = data.replace('?',numpy.NaN) #import Imputer method from skle...
4f5faf616cfc4cd4c0ae07634a4ca49be4af7273
zhitomorrow/python_practice
/practice8/time_test.py
1,898
3.515625
4
# -*- coding: utf-8 -*- # @Time : 2019/12/3 22:12 # @Author : lzm # @Function : time模块练习 import time from datetime import datetime from datetime import timedelta # 从datetime中引入timedelta """ 时间的三种格式: 1.时间戳 2.格式化时间 3.以元组的形势表示时间 """ # 使用help方法查看time模块下的方法 # help(time) # asctime([tuple])->string,传入一个元组,转换...
56a736578305bcf03f16242bc3c005257f38edcd
changfeng012008/winterpy
/pylib/algorithm.py
4,328
3.84375
4
'''一些算法''' def LevenshteinDistance(s, t): '''字符串相似度算法(Levenshtein Distance算法) 一个字符串可以通过增加一个字符,删除一个字符,替换一个字符得到另外一个 字符串,假设,我们把从字符串A转换成字符串B,前面3种操作所执行的最少 次数称为AB相似度 这算法是由俄国科学家Levenshtein提出的。 Step Description 1 Set n to be the length of s. Set m to be the length of t. If n = 0, return m and exit. If m = 0, retur...
02f9d183494f32555fbab6177f5eac913973a0a0
JargonKnight/Intro-To-Graphics
/Final Project - Part A/0.5/FroggerProject.py
934
3.71875
4
'''Author: Jesse Higgins Last Modified By: Jesse Higgins Date Last Modified: July 31st 2013 Program Description: Leapy is a fun little frogger game with unique levels and requires you to collect all the objects in that level in order to move on to the next. version 0.5...
f28a0ccb8a7cc18012f64e5ac2ff574691fd505c
JargonKnight/Intro-To-Graphics
/Final Project - Part A/0.3/FroggerProject.py
782
3.671875
4
'''Author: Jesse Higgins Last Modified By: Jesse Higgins Date Last Modified: July 30th 2013 Program Description: Leapy is a fun little frogger game with unique levels and requires you to collect all the objects in that level in order to move on to the next. version 0.3...
04f06f053e78b2c6119bac0fa6693f563baa0a61
zachleong/sddchallenges
/vigtextencrypt.py
2,889
4.21875
4
#run with python 3 import os #function for encrypt and decrypting using the ceasar cipher def vig (status, key, inputtext): #declare a list with the length of the inputtext output = [None] * len(inputtext); #iterate over the length of the inputtext for x in range(0,len(inputtext)): #set the index...
6c50447e54dbd0328c172e446ea8f4fee584a1e8
imerfanahmed/TopH
/Harryyyyyyyyyyyyyy.py
150
3.515625
4
t=int(input()) for i in range(t): n=int(input()) s="Harry! Khelbe Hogwarts, Jitbe Hogwarts!" S=s.replace("y","y"*n) print("Case {0}:{1}".format(i+1,S))
d21feaa4d11f00c0889a1a44d9efc40f2b51fe8e
imerfanahmed/TopH
/regular is easy.py
372
3.5625
4
def nCr(n, r): return (fact(n) / (fact(r) * fact(n - r))) # Returns factorial of n def fact(n): res = 1 for i in range(2, n+1): res = res * i return res # Driver code t=int(input()) for i in range(t): n=int(input()) result=int(nCr(n...
b6c9b2a34c450ce2673065d28cc3748b3d19340d
imerfanahmed/TopH
/Simple Operation/Simple Operation.py
122
3.578125
4
t=int(input()) for i in range(t): string=input() result=eval(string) print("Case {0}: {1}".format(i+1,result))
f2ab376610f2602eb884724a34918f9eb05c732d
imerfanahmed/TopH
/rename the book.py
214
3.75
4
import itertools def remove_consecutive_duplicates(s1): return (''.join(i for i, _ in itertools.groupby(s1))) #driver code t=int(input()) for i in range(t): print(remove_consecutive_duplicates(input()))
fa136d9bbd6c85ea20fff939d8b602a07f8d714a
imerfanahmed/TopH
/SAtiq The Dengue Fighter.py
98
3.765625
4
s=input() if s=="Fever": print("Go to hospital right now.") else: print("Go to hospital.")
3b801b603fa6c8b99743d183ed3c33e889265980
imerfanahmed/TopH
/Sofdar Ali's Next Day.py
184
3.5625
4
import datetime t=int(input()) for i in range(t): d,m,y=map(int,input().split()) x = datetime.datetime(y,m,d) + datetime.timedelta(days=1) print(x.strftime("%d %b, %Y"),)
523886f5f5d290f523e7281296403203dc197c5c
imerfanahmed/TopH
/say-it.py
155
3.921875
4
#https://toph.co/p/say-it t=int(input()) for i in range(t): s=input() if s.isupper()==True: print("UPPERCASE") else: print("lowercase")
7e638f63231348cc318f0b1fb3125df8d0627ac6
imerfanahmed/TopH
/aryshas first code.py
95
3.515625
4
n=int(input()) count=0 for i in range(n): if i%2==0: count+=1 print(count)
5caabc440a71563c35b923601165627bed783114
imerfanahmed/TopH
/tempCodeRunnerFile.py
363
3.75
4
arr=[] t= int(input()) for i in range(t): string=input() if string in arr: if string[-1].isnumeric()==False: print(string+'1') else: num=int(string[-1])+1 string.replace(string[-1],'num') print(string) else: ...
2d0cb7099e82c1d7120fb2d711550a6ae26de2fe
maclv/AlSerpent
/function/FunctionClient.py
3,356
3.640625
4
# -*- coding:gbk -*- __author__ = 'maclv' import thread def foo0(arg): print "call "+ str(foo0.__name__) +", "+ str(arg[0]) def foo1(args): print "call foo1 " + str(args[0]) + ", "+str(args[1]) def foo2(args): print "call foo2 " + str(args[0]) + ", "+str(args[1])+", "+str(args[2]) foo3=lambda arg1,arg2...
098b2ded0694539851fba3c0f8255e638abd4668
xli119/leetcode
/561array_partition1.py
679
3.671875
4
""" Author: Xiaoyu Li Created on 7/5/2018 Array 561 Array partition1 """ def array_pair_sum(nums): exist = dict() for i in nums: exist[i] = exist.get(i, 0) + 1 sum = 0 is_even = False for n, freq in exist.items(): if freq: freq = freq - 1 if is_even else ...
56335d002a5b7c23ab0841408ed58ebe1efc3fbc
swtnk/Data-Structures
/python3/singly_linked_list.py
1,040
3.65625
4
class Node: def __init__(self, data): self.data = data self.next = None class SinglyLinkedList: def __init__(self): self.root = None def append(self, node, current_node = None): if self.root is None: self.root = node else: if current_node is ...
7fe87aab9bb776ab2a08b583da55fe0128c75959
torstenfeld/coderbyte
/easy-timeConvert.py
168
3.671875
4
def TimeConvert(num): hours = num / 60 min = num % 60 result = str(hours) + ':' + str(min) return result num = 45 print TimeConvert(num)
26a1b40a53948d3008e5bb09c67d6521f1420f59
torstenfeld/coderbyte
/easy-firstFactorial.py
228
4
4
def find_first_factorial(int): result = 1 if int < 2: return int for i in range(2, int+1): result *= i return result integer = 4 result = find_first_factorial(integer) print result
c9a7257d9e7588090c7a0701103cd347bea8b210
torstenfeld/coderbyte
/easy-letterChanges.py
929
3.984375
4
import string alphabet = map(chr, range(97, 123)) vowels = ['a', 'e', 'i', 'o', 'u'] #str = "hello*3" str = "fun times!" def LetterChanges(str): result = [] str = str.lower() array = list(str); for i in range(0, len(array)): try: index = alphabet.index(array[i]) except Va...
eb1007f67353a66188fc7b5e6233a93f4712a55a
hepidad/playground
/coderbyte/Easy/Easy6.py
432
3.984375
4
#http://coderbyte.com/CodingArea/GuestEditor.php?ct=Letter%20Capitalize&lan=Python ''' Using the Python language, have the function LetterCapitalize(str) take the str parameter being passed and capitalize the first letter of each word. Words will be separated by only one space. Input = "hello world"Output = "Hello Worl...
51cdc8facb0962f989ef8d8ab4014b2dbf4db15b
TylerLott/CapstoneProject
/src/DBWriter.py
1,061
3.53125
4
import sqlite3 class DBWriter: def __init__(self, filepath): self.conn = sqlite3.connect(filepath) self.c = self.conn.cursor() self.entry = 1 self.c.execute('DELETE FROM terminal;') self.c.execute('UPDATE data SET actuatorL=?, sensorL=?, actuatorC=?, sensorR=?, actuato...
5095c7a1749bc8620e5a2c3749693d701064112c
joyjoygwapa/Data-Structure-Python-G11
/Linked List Application.py
2,503
3.953125
4
#Linked List by Ethyl Joy I. Badiang class disk: def __init__(self,file,filename): self.file=file self.read=self.file self.root=filename self.arrmain=[] def display(self): #self.arrmain.append(self.root) linked=Linked(self.root) for line in self....
0bb258e8b40b66c177a022527d52d5fc4d162462
zeinabss/Karatsuba_Multiplication
/karatsuba.py
1,663
3.796875
4
""" Created on Mon Apr 8 14:36:29 2019 @author: zeinabss This function calculates multiplication of two number (positive or negative) using Karatsuba algorithm. """ import math def DigitCount(num): if num == 0: n = 1 else: n = int(math.log10(abs(num)))+1 return n ...
be064148d36277f4f27f084c91ba4759c943650a
JayaramachandranAugustin/python_tutorial
/loops/while_loop.py
82
3.921875
4
a=1 while a<10: print(a,end=' ') a+=1 else: print("end of while loop")
a5594a278b9314db9009722c713fd2ec819b1b0c
JayaramachandranAugustin/python_tutorial
/conditions/conditional_expression.py
59
3.671875
4
a=1 value="a is 1" if a==2 else "a is not 1" print(value)
21727e7ad28f1d5585cfae4ab639995b8b90cf7a
featherbear/UNSW-COMP1531
/Labs/lab05/car.py
1,508
3.90625
4
from abc import ABC, abstractmethod class Car(ABC): @abstractmethod def __init__(self, type, make, model, year, rego): self._type = type self._make = make self._model = model self._year = year self._rego = rego self._rate = 0 @property def type(self): return self._type @property...
9bc48fdef80e39545a4555f8add72c8e3f8f2f39
featherbear/UNSW-COMP1531
/Labs/lab03_04/numberGuesser.py
1,694
4.15625
4
''' Number Guessing Game. Guesses are made until all numbers are guessed. The game reveals whether the closest unguessed number is higher or lower than each guess. Numbers are distinct. Typing 'q' quits the game. ''' import random MIN = 0 MAX = 10 NUM_VALUES = 3 def handle_guess(guess, values): # This function ...
b0ddcf86b7b4898b9dd26ac0d4a7e8e4428029de
featherbear/UNSW-COMP1531
/Labs/lab02/number_list.py
1,229
4.03125
4
def find_reverse(numbers): #TODO: find the reverse of the list return numbers[::-1] def find_max(numbers): #TODO: find the maximum of the list return max(numbers) def find_min(numbers): #TODO: find the minimum of the list return min(numbers) def find_sum(numbers): #TODO: fi...
3ab95bb366dd9b41c5c3dd5c8851c012ee02c417
wwg377655460/DataStructureToLeetCode
/binarySearch.py
743
3.796875
4
import random import time from utils.MyUtil import generate_ordered_array def binary_search(arr, n, target): l, r = 0, n - 1 # search in [l...r] while l <= r: # while l==r, this array has one element mid = (l + r) // 2 # bug 容易超出整形的范围 if arr[mid] == target: return mid el...
8c986f3cede7012fceb0a981af6f80a8400d5fbd
wwg377655460/DataStructureToLeetCode
/problem_349.py
472
3.8125
4
class Solution: def intersection(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: List[int] """ new_nums = set(nums1) res = set() for i in range(len(nums2)): if nums2[i] in new_nums: res.add(num...
946d7bfb7dfc4531b9141c9fb5c18b48909ab93a
wwg377655460/DataStructureToLeetCode
/problem_350.py
684
3.546875
4
class Solution: def intersect(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: List[int] """ new_nums = dict() for i in range(len(nums1)): if nums1[i] in new_nums: new_nums[nums1[i]] += 1 el...
06c66b9efa54972e806387a62b6ed9fc6d8c5726
vaishnav-hacks/EduTech1
/type of variables.py
237
3.6875
4
print("welcome\n") print("this software is developed by mr. Vaishnav\n") a = int(input("Enter Any number \n")) b = input("Enter any letter or word\n") c = float(input("enter any decimal number\n")) print(type(a)) print(type(b)) print(type(c))