blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
f84fa1209ea085e51f3737c9a912cac39401783c
pfvaldez/Advanced-Deep-Learning-with-Keras
/chapter2-deep-networks/cnn-y-network-2.1.2.py
2,354
3.6875
4
''' Implementing a Y-Network using Functional API Project: https://github.com/roatienza/dl-keras Dependencies: keras Usage: python3 <this file> ''' import numpy as np import keras from keras.layers import Activation, Dense, Dropout, Input from keras.layers import Conv2D, MaxPooling2D, Flatten from keras.models impor...
af87866ddd840337fcc307e3a6bdacff2b5424d8
DbCrWk/sumgraph
/sumgraph/data_handler/data_accessor/file_based_accessor.py
1,184
3.53125
4
""" This module defines an Accessor that is backed by some type of datafile. """ from __future__ import annotations from abc import abstractmethod from sumgraph.data_handler.data_accessor.accessor import Accessor class FileBasedAccessor(Accessor): """ This class defines accessors that are based on a particul...
82ca382da410dfc04d3940b52f7946527292e12f
syn7hgg/ejercicios-python
/6_4/7.py
422
4.125
4
def factorial(n): factorial_total = 1 x = 1 for x in range(n): factorial_total *= n x += 1 n -= 1 return factorial_total try: numero = int(input("inserta un numero ")) # Ejecutamos la función recusiva para el calculo calculo = factorial(numero) print("E...
0305fb6e80611f48b7e1b3495d3f9f026559f4a3
lunarflarea/pythontraining
/2-4.py
233
4.21875
4
#Goal: Increase a if it's lower than b, and decrease b if it's greater than 0. Print b if its value is odd. a = int(0) b = int(10) while a < b: print(a) a += 1 while b > 0: b -= 1 if (b % 2) != 0: print(b)
b7174b4e911deccc57a034320f49a31be4778757
conibhar90/conibhar90.github.io
/MiTx codes/gcd.py
467
3.75
4
# -*- coding: utf-8 -*- """ Created on Tue Mar 14 00:50:11 2017 @author: FuckYouMicrosoft """ def gcdRecur(a, b): ''' a, b: positive integers returns: a positive integer, the greatest common divisor of a & b. ''' # Your code here if a == 0: return b ...
3c8c74825697c853337ee8972afa28bd763b875d
chinmairam/Python
/regex1.py
325
3.703125
4
from string import ascii_lowercase as lower import re x = 'abcaafabaabdfgz' abc = '' #for letter in lower: # abc += letter+'*' #print(abc) #abc = '*'.join(lower) #abc += '*' #print(abc) abc = 'a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*' pat = re.compile(abc) print(pat) print(max(pat.findall(x),key=l...
284bdfd774a757c5f89b832c6e1e90717b76d1ef
alihasan13/python_hackerrank
/division.py
134
3.796875
4
a = int(input()) b = int(input()) def div(a,b): s=int(a/b) s1=float(a/b) print (s) print(s1) return s,s1 div(a,b)
6557d4aff52b6011ba90081b213a13874092d944
lilyhe19/final_project
/final_project-master/sleepcal.py
722
4.25
4
def sleep(number): #tells you how much sleep you should get based on age #infants not included master= [{'age':[1,2],'hours':"11-14"},{'age':[3,4,5],'hours':"10-13"},{'age':[6,7,8,9,10,11,12,13],'hours':"9-11"},{'age':[14,15,16,17],'hours':"8-10"}] for x in master: if number in x['age']: ...
fcd28137760e4d706751517dc8b25d3b66b34821
Zasterify/Python-Practice
/Functions/test.py
478
4.1875
4
def func1(x): '''to define the function called func1 with a parameter''' return x * 1/2 # to calculate the value of x def func2(y): '''to define the function called func2 with a parameter''' return y * 2 # to calculate the value of y def func3(x, y): '''to define the function called func3 wi...
071bc094d1a281acf99b67b3b24219216491fb1a
YaraBader/python-applecation
/Ryans+Notes+Coding+Exercise+10+More+String+Functions(1).py
1,621
4.46875
4
''' More String Functions To solve this problem: Your output must be exactly the same as you'll see below 1. Create a variable named samp_string and assign the value " This is a very important string " 2. Get rid of the extra whitespace and then provide the following output. You'll have to use multiple functions, con...
ceaa3bc33c984c437091c568734cc125a725a24c
geniousisme/CodingInterview
/leetCode/Python2/131-palindromePartition.py
889
3.515625
4
class Solution(object): def __init__(self): self.res = [] def partition(self, s): """ TC: O(n ^ 2 ~ 2 ^ n) SC: O(n ^ 2) """ if self.res: self.res = [] if s: self.partition_helper(s, []) return self.res def partition_he...
75548fed6500bf208c48936357c5269a1dadf821
CoderDojoLu/py-club
/pygame/kepler.py
3,294
4.0625
4
#Kepler's Laws.py # plots the orbit of a planet in an eccentric orbit to illustrate # the sweeping out of equal areas in equal times, with sun at focus # The eccentricity of the orbit is random and determined by the initial velocity # program uses normalised units (G =1) # program by Peter Borcherds, Universit...
4b3a02b3dd11a6a0fa26c89f8432e6c9b60a67b1
RogerLeitel8/ativijs
/first.py
328
3.6875
4
def receber_valor(separar_valor): for i in range(4): numero = [] digito = int(input("Digite um número: ")) numero.append(digito) return separar_valor() def separar_valor(): if (digito % 2) == 0: par.append(digito) else: impar.append(digito) print(receber_valor())...
bd3c72b94c0c03c7cfc01feb1eff0eef115dd75f
namth2015/python
/1.DataScience/2.BigO/Green18/lec7_standardized_name.py
630
3.609375
4
n = int(input()) a = [] for i in range(n): temp = input() a.append(temp) def manipulate_text(a): b = '' c = [] for i in range(len(a)): for j in range(len(a[i])): if j == 0: b = b + a[i][j].upper() else: b = b + a[i][j].lower() ...
398acac315c218faaa1008c8976249540b96b4f9
EricaWearne/HelloWorld
/Python/LearnPython/HelloVariableWorld.py
302
3.953125
4
Name = "Erica" Country = "Australia" Age = 42 Hourly_wage = 54 Satisfied = True Daily_wage = Hourly_wage*8 print("You live in " + Country) print("You are " + str(Age) + " years old") print("You make $" + str(Daily_wage) + " per day") print("Are you satisfied with your current wage? " + str(Satisfied))
04b1e43761c353523cc6e4f68833d0cde53bcc8b
rvsmegaraj1996/Megaraj
/for in loop.py
305
4
4
#for in loop required=[12,"aravind",98,4,10.3,"gopi"] print(len(required)) #while statement init=2 while init<len(required)-1: print(required[init]) init+=1 #for in range for index in range(0,len(required)-3): print(required[index]) #for in loop for data in required: print(data)
49236ff48c2720652ab4f036f3e67b312b011f33
davidlyness/Advent-of-Code-2015
/12/12a.py
767
3.828125
4
# coding=utf-8 """Advent of Code 2015, Day 12, Part 1""" import json def calculate_total(data): """ Recursively calculates the total for each element of JSON data. :param data: JSON data for which to calculate the total :return: total for the provided JSON data """ total = 0 if isinstance...
4139e07dcb4ce2dae84c4b6737fead8b4b76f65a
anjali-garadkar/if-else
/calculater if_else.py
402
4.21875
4
# num1=int(input("enter the number")) # num2=int(input("enter the number")) # symbol=input("enter the symbol") # if symbol=="+": # print("num1+num2") # elif symbol=="-": # print("num1-num2") # elif symbol=="*": # print("num1*num2") # elif symbol=="%": # print("num1%num2") # elif symbol=="/": # prin...
734b9d1b2ffdeb11794e0f4bb311b62d40a372b2
taklavisha/python-lab
/list_demo.py
214
3.765625
4
#example for lists a=[1,2,3,20,"a"] a.append('5') a.extend(['a','b','c']) a=['1',4,5] b=[5,6,7] a+b d=a.index(5) e=["cmr","good","college"] e.insert(1,"is") e.remove("college") e.insert(3,"university") e.reverse()
ba574c75b9e73e103b826ed783465ed84e40c321
murarijha-kumar/Guess-the-number
/guessthenumber.py
588
4.03125
4
#guess the number and win the game num=4 chance=1 n1=int(input("Enter the number of guesses given to user")) while(chance<=n1): n = int(input("Enter the number which is guessed by the user-")) if(n>num): print("thoda ghatao") elif(num>n): print("thoda badhao") else: pr...
315b62761428c7a7f68cbeca517c1065685389bd
lunevods/practicum_1
/50.py
932
3.734375
4
""" Имя проекта: practicum-1 Номер версии: 1.0 Имя файла: 50.py Автор: 2020 © Д.Л Иоффе, Челябинск Лицензия использования: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/deed.ru) Дата создания: 17/12/2020 Дата последней модификации: 17/12/2020 Связанные файлы/пакеты: min,max Описание: Решение задачи №№ 5...
da0f49c2a71819b57bb343d9152ba4e9746ab23b
MisaelAugusto/computer-science
/programming-laboratory-I/73hp/criptografando.py
554
3.6875
4
# coding: utf-8 # Aluno: Misael Augusto # Matrícula: 117110525 # Problema: Criptografando uma Senha palavra = list(raw_input()) trocas = 0 for i in range(1, len(palavra)): if palavra[i] == "a" or palavra[i] == "A": palavra[i] = "4" trocas += 1 elif palavra[i] == "e" or palavra[i] == "E": palavra[i] = "3" tr...
029a8b3c6a77caf25aad3db72d35e1a15e70ea8a
sonalirahagude/CodingPractice
/python/decimalRepresentation.py
901
4.25
4
#! /usr/bin/python #Write a function which, given two integers (a numerator and a denominator), prints the decimal representation of the rational number "numerator/denominator". #Since all rational numbers end with a repeating section, print the repeating section of digits inside parentheses def decimalRep(num,den):...
0c29015a0786b7b68e490d5b4085c4205ea0b5e7
gbernstein-dev/DojoAssignments
/Python/python_fun/foobar.py
872
4.25
4
# Write a program that prints all the prime numbers and all the perfect squares for all numbers between 100 and 100000. # For all numbers between 100 and 100000 test that number for whether it is prime or a perfect square. # If it is a prime number, print "Foo". If it is a perfect square, print "Bar". # If it is nei...
9b18b45742a98784367df9ecd91095a3cde15aed
lucas-silveira/python-fundamentals
/Control Structures/while.py
349
3.90625
4
from random import randint # number = 0 # while number < 10: # print(number) # number += 1 input_number = int(input('Digite um número: ')) secret_number = randint(0, 9) while input_number != secret_number: input_number = int(input('Errou! Digite um número novamente: ')) print(f'O número secreto {secret_...
da4021eb870c54249fed042d1d9832cfa781bead
guilhermeabel/python-network
/5_ASSIGNMENT.py
385
3.546875
4
import csv with open('csv/devices.csv', 'r') as file: reader = csv.reader(file, delimiter=':') main_list = list() for row in reader: main_list.append(row) print(main_list) # with open('txt/devices.txt') as f: # devices = f.read().splitlines() # mylist = list() # for item in devices: # ...
75fcd0b41995aec6b591cb69cc8bef0f83a7c9d8
FlavianDakka/Dice
/project.py
2,395
3.5
4
# math_gui.py # Interactive GUI for simple math involving two variables. from graphics import * def main(): win = GraphWin(title="Dice Roller", width=300, height=240) win.setBackground(color_rgb(204,236,255)) xtext = Text(Point(20,30), "D2") xtext.setSize(10) xtext.draw(win) yte...
baa4e6b7033b8c39b66f8b14b7ae614e51f6176d
bharatkrishna/ProjectEuler
/q12.py
984
3.6875
4
''' he sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... Let us list the factors of the first seven triangle numbers: 1: 1 3: 1,3 6: 1,2,3,...
77d889200e86871229854b140033bf124433e89f
cgazeredo/cursopython
/mundo01/aula-04_03-data-nascimento-formatada.py
210
3.78125
4
dia = input('Digite seu dia de nascimento: ') mes = input('Digite o seu mês de nascimento: ') ano = input ('Digite seu ano de nascimento: ') print ('Sua data de nascimento é: ' + dia + '/' + mes + '/' + ano)
a97acc2613b4c2d911eb0cc54003ccf460ed96c0
yash03122/learn-python
/hello.py
156
4.21875
4
x = input("Enter Your name : ") y = input("conform yes or no : ") if y == "yes": print("your name is " + x) else: print( " your name is not yash")
45bb0fa3290326a446f957d85955fbb2966fc8cd
firekyrin/train-demo
/py/t3/test7.py
299
3.5625
4
#!/usr/bin/env python import urllib #import urllib.request as urllib def web_lookup(url, saved={}): if url in saved: return saved[url] page = urllib.urlopen(url).read() saved[url] = page return page url = 'https://www.baidu.com' page = web_lookup(url) print 'url=', url print 'page=', page
d69d4d3f0c87299e4255466ae7d895971d2f3a41
k01e/Code-Helper
/Python/Basics in Python.py
1,110
4.1875
4
############ names = ["John", "Bob", "Mosh", "Sam", "Mary"] print(names[0]) # John print(names[-1]) # Mary print(names[0:3]) # ['John', 'Bob', 'Mosh'] names.append("Josh") print(names) # ['John', 'Bob', 'Mosh', 'Sam', 'Mary', 'Josh'] names.insert(3, "Katie") print(names) # ['John', 'Bob', ...
505e403c96a90da9c723dfa06f7bcd983495d4f9
J0BS013/Exercicios-PythonFundamentos
/calculadora_v1.py
1,703
4.28125
4
# Calculadora em Python # Desenvolva uma calculadora em Python com tudo que você aprendeu nos capítulos 2 e 3. # A solução será apresentada no próximo capítulo! # Assista o vídeo com a execução do programa! def soma(num1,num2): soma = num1 + num2 return soma def subtracao(num1,num2): subtracao = num1 - ...
ae54b20e1a18781c3bf49f96579190647e2a0dab
axellbrendow/python3-basic-to-advanced
/aula010-operadores-relacionais/aula10.py
699
4.125
4
""" Operadores relacionais == > >= < <= != """ value1 = 2 value2 = '2' value3 = (value1 == value2) # False print(value3) value2 = 2 value3 = (value1 > value2) print(value3) value3 = (value1 >= value2) print(value3) value3 = (value1 < value2) print(value3) value3 = (value1 <= value2) print(value3) value3 = (valu...
411a08565f73611078160e6d63438de020b19205
viniciusmartins1/python-exercises
/ex074.py
259
3.90625
4
from random import randint num = (randint(1,10), randint(1,10), randint(1,10), randint(1,10), randint(1,10)) for n in num: print(n, end=' ') print(f'\nO maior número sorteado foi {max(num)}',) print(f'O menor número sorteado foi {min(num)}')
49de7525477ec5c6cfb5c5b270d0bba17600ec67
JoyDajunSpaceCraft/leetcode_job
/DeepFirstSearch/MinimumDepthofBinaryTree.py
649
3.65625
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 minDepth(self, root: TreeNode) -> int: if not root:return 0 else : stack = [(1, root)] mindep...
c444ac6bd494b56a0e71d64e62524da1a5fa704e
armsnyder/aoc2019
/13b.py
4,314
3.53125
4
# ref: https://adventofcode.com/2019/day/13 import unittest from typing import Optional def main(inp: str) -> int: inp = '2,' + inp[2:] computer = IntcodeComputer(inp) score = 0 try: joystick = None paddle_x = 0 ball_x = 0 while True: try: x = computer.run(joystick) joysti...
e81ef6d0786e44dbc1aa20cb265c9aedf5f15196
kathleenfwang/algorithms-and-data-structures
/daily_byte_questions/others/day1stringlength.py
2,521
4.25
4
# Given a string, s, return the length of the last word. # Note: You may not use any sort of split() method. # Ex: Given the following string… # s = "The Daily Byte", return 4 (because "Byte" is four characters long). def lastStringLength(str): # loop through string until you find the index of last "space" ...
683f2f32f5ad703bf498554f74ec7c58f607daa5
zefirka/python-as-first-language-course
/homework/1/w2_find_in_list.py
1,944
4.09375
4
# Предварительный код from random import randint integers = list(range(100)) letters = ['a', 'z', 'd', 'u', 'j', 'v', 'i', 'm', 'd', 'x', 'y', 'o', 'p'] # Нужно написать функцию под названием indexof, принимающую 2 аргумента: # 1) list (список) # 2) любой простой типа (искомое значение) # Функция возвращает индек...
e2d138988c05cbb377c325d38df4b8dcac8f094e
xczhang07/Python
/requests/requests_basic.py
5,309
3.765625
4
# requests is a Python module you can use to send all kinds of HTTP requests. # It is an easy to use library with a lot of features ranging from passing parameters in URLs to sending # custom headers and SSL verification. import requests # the requests module needs to be imported first of all from requests.auth imp...
90727cb43244bfc523f2a45cd7a2948f715901b0
andersonmarquees/-uri_python
/judge_1170.py
316
3.5625
4
cont = 0 def food(meal): global cont if meal == 1: return cont if meal < 1: return cont else: meal /= 2 cont += 1 return food(meal) n = int(input()) while n > 0: meal = float(input()) print("{} dias".format(food(meal))) cont = 0 n -= 1
c50836f4185907a5e20fac4a76323d9a5232cf97
igorpsf/Stanford-cs57
/Homework5.py
874
4.21875
4
# 1) Using recursion, calculate n! for any integer >=0. def factorial(n): if n == 1: return n else: return n * factorial(n - 1) print(factorial(5)) # 120 # 2) Using recursion, calculate x^y for any integers x,y >=0. def power(x,y): if y==0: return 1 elif y >= 1: r...
f61ed89643bafa14e3d7c509ff5339dbf9af2ad1
PrincetonUniversity/intro_debugging
/02_python/python_debug/src/no_furniture.py
544
4.5625
5
"""This script should print a list of non-furniture objects in alphabetical order.""" def remove_furniture(items): furniture = {'couch', 'table', 'desk', 'chair'} items_furniture_removed = [item for item in items if item not in furniture] return items_furniture_removed if __name__ == '__main__': # input l...
705646399048c213253714e5823a341b32ba9d48
TapasDash/Hackerrank-solutons-in-Python-3
/Data Structures/Tree : Top View.py
1,686
3.953125
4
class Node: def __init__(self, info): self.info = info self.left = None self.right = None self.level = None def __str__(self): return str(self.info) class BinarySearchTree: def __init__(self): self.root = None def create(self, val): i...
0a0b641f64f3d1d4dbd5c94052b4db976bae6eea
Silent-wqh/PycharmProjects
/pythonProject/Chaos/list_pies.py
140
3.546875
4
pies = ['麻辣鸡肉', '香辣鱿鱼', '酱香肉'] for pie in pies: print(pie) print('I like ' + pie) print('I really like pies')
421aa20200ce555ba82cf858a052ea14919fc8c7
Dishant15/ai-trajectory-replanning
/search.py
2,266
3.640625
4
from utils import Heap class SearchAgent(object): def __init__(self, start_node, goal_node, grid): self.grid = grid self.position = start_node.xy self.start_node = start_node self.goal_node = goal_node self.open_list = Heap() self.start_node.set_val("g", 0) self.start_node.set_val("f", start_node.h_va...
ea75460cef9fb6dcf6f8534e6b5ab3e51e017851
oneTaken/tools
/example.py
354
3.671875
4
import timeit def testTime1(): a, b = 3, 5 a, b = (a, b) if a>b else (b,a) def testTime2(): a, b = 3, 5 x = max(a, b) y = min(a, b) if __name__ == "__main__": times = 100000 time1 = timeit.Timer(testTime1) print(time1.timeit(times)) time2 = timeit.Timer(testTime2) ...
1794bef775eea0966d3d36f8cd3b005ad65bcfea
ahcode0919/python-ds-algorithms
/data_structures/tests/test_binary_tree_node.py
704
3.53125
4
from data_structures.binary_tree_node import BinaryTreeNode def test_init(): tree = BinaryTreeNode(1) left_node = BinaryTreeNode(2) right_node = BinaryTreeNode(3) assert tree.data == 1 assert not tree.left_node assert not tree.right_node tree = BinaryTreeNode(1, left_node, right_node) ...
070b4be9ab16d8da7768500cf82ae2571cad3d1c
Mcps4/ifpi-ads-algoritmos2020
/EXERCICIOS_CAP_4/CAP_4_E_4.3_Q3.PY
227
3.890625
4
import turtle t = turtle.Turtle() def polygon(t,n,length): angle = 360 / n for i in range(n): t.forward(length) t.lt(angle) def main(): polygon(t,6,90) turtle.mainloop() main()
9a62f980d352087e31d20c3cf700f111234a4340
Cule219/mlib
/sorting/merge_sort.py
2,247
4.40625
4
# def merge_sort(list): # """ # Sort a list in ascending order # Returns a new sorted list(does not mutate) # Divide: Find the midpoint of the list and divide into sublists # Conquer: Recursively sort the sublists created in previous step # Combine: Merge the sorted sublists creted in the previ...
a7507246a00f8b2c9a8af5eca8aa556777245e00
Gunglarino/python
/5_Functions/5.4.py
377
3.78125
4
def new_password(oldpassword, newpassword): if newpassword != oldpassword and len(newpassword) >= 6: for char in newpassword: if char.isdigit(): return True return False else: return False oldpassword = "wachtwoord" newpassword = input("Wat wordt uw nieuwe wac...
ff1ca5f69dfa38e6dc664d50b2dc7e3a2573bb35
DavidTurnbough/Geeks-For-Geeks---Python
/Geeks For Geeks/Binary Representation.py
650
3.921875
4
# Name: David Turnbough # Date: Tuesday December 17, 2019 # https://practice.geeksforgeeks.org/problems/binary-representation/0 # Binary Representation def convertToBinary(passedValue): returnValue = 0 while(passedValue > 0): returnValue = int(returnValue * 10) returnValue += int(pas...
1d32952c8bdc4fdbcffa5a37cbaf9181ff35cdb6
jajatisahoo/PythonProgram123
/DailyProgram/loop.py
170
3.96875
4
print("hello world") i = 1; while (i <= 2): print("value of i is" + str(i)); i = i + 1 # j =input("enter a string") name="jajati" length=len(name) print(length)
49c91bcd24f34f792f402d1aa0eedb870cbb5a02
manishhedau/Python-Projects
/Turtle/ex1.py
941
4
4
import turtle my_turtle = turtle.Turtle() # n = int(input('Enter The size of Rectangle : ')) """ Rectangle code """ # for _ in range(4): # my_turtle.forward(n) # my_turtle.left(90) """ Triangle with fill color """ # my_turtle.color('red','skyblue') # my_turtle.begin_fill() # my_turtle.forward(n) # my_turtle...
e1d4f4c45a3534712a03235136d8dffd49c988f0
jtannas/learn-python-the-hard-way
/exercises_1X/ex13.py
1,253
3.8125
4
#!/usr/bin/python2.7 # pylint: disable = C0103, W0105 """Example 13: Parameters, Unpacking, Variables.""" from sys import argv script, first, second, third, fourth = argv # pylint: disable=W0632 print "This script is called:", script print "Your first variable is:", first print "Your second variable is:", second pr...
159b3d95935cf98668b4a3cf1a7b18ae4e9cf663
cameronww7/Python-Workspace
/CTCI/C-2/2.8.py
3,224
4.1875
4
from __future__ import print_function """ Prompt 2.8 : Python - Loop-Detection Make a circular linked list and have a function that finds the original first node EX: Input: Output: Video Watched - https://www.youtube.com/watch?v=Ast5sKQXxEU Site Usin...
09480f84fc4f08d16fa131bcc3cd837e1d6870fa
jemtca/CodingBat
/Python/String-1/ends_ly.py
183
4.25
4
# given a string, return true if it ends in "ly" def ends_ly(str): return True if str[-2:] == 'ly' else False print(ends_ly('oddly')) print(ends_ly('y')) print(ends_ly('oddy'))
1693a547bd0278f0675a13ee34e1fa63ee86a00c
davidcotton/algorithm-playground
/src/graphs/bfs.py
1,790
4.1875
4
"""Breadth-First Search Search a graph one level at a time.""" from collections import deque from typing import List, Optional from src.graphs.adjacencylist import get_graph from src.graphs.graph import Graph, Vertex def bfs_search(start: Vertex, goal: Vertex) -> Optional[List[Vertex]]: """Search for the goal v...
425e441249f0b08e6a6888dca8e28f2388dd5064
pysal/segregation
/segregation/util/plot.py
1,524
3.71875
4
import matplotlib.pyplot as plt import numpy as np def plot_cdf(group_share1, group_share2, label1='', label2=''): """Plot CDF for two series. Convenience function for comparing inequality between two series by plotting their CDFs on the same graph Parameters ---------- group_share1 : pd.Ser...
9342039f2409a205ea080d55c70381801f66955a
TanmayVig/automate-gui
/main.py
4,594
3.828125
4
import tkinter as tk from tkinter import ttk from matplotlib.figure import Figure import matplotlib.animation as animation from matplotlib.backends.backend_tkagg import (FigureCanvasTkAgg, NavigationToolbar2Tk) feet_force=0 LARGEFONT =("Verdana", 35) time = [1,2,3,4,5,6,7,8] feet = [5,5,5,5,5.1,5.6,5.7,60] f = Fi...
3528a24fff51f55a0cfcb50e337fa3d23f2de45b
oelizondo/walnut
/compiler/walnut_object.py
356
3.515625
4
# WalnutObject module # This module stores the name and to which walnut class does the # object belongs to. # # attributes # # walnut_class: the class to which the objects belongs to. # name: the id of the walnut object # import sys class WalnutObject: def __init__(self, walnut_class): self.walnut_class = ...
d164d06d67685f8e717c2f399c4655d56bc82054
SerebriakovaElena/IDE-Group26_Serebryakova
/filter.py
1,077
3.5
4
from PIL import Image import numpy as np def paint_mosaic(arr, size, gradation_step): for i in range(0, len(arr), size): for j in range(0, len(arr[0]), size): arr[i:i + size, j:j + size] = count_average_brightness( arr[i:i + size, j:j + size], size, gradation_step) return ar...
254dc7d4454b86b4750fd7f26a9ba1db4820dd94
sanyache/algorithm
/palindrom.py
254
3.78125
4
def palindrom(s): l = 0 r = len(s)-1 while l < r : if s[l] == s[r]: l += 1 r -= 1 else : rez = 'No' return rez rez = 'Yes' return rez s= 'abyba' print palindrom(s)
1227d8890816e06aefd8d239f69c02bf73271893
YiqunPeng/leetcode_pro
/solutions/73_set_matrix_zeroes.py
959
3.578125
4
class Solution: def setZeroes(self, matrix: List[List[int]]) -> None: """Array. Running time: O(n * m) where n and m are the size of matrix. """ fr, fc = False, False m, n = len(matrix), len(matrix[0]) for j in range(n): if matrix[0][j] == 0: ...
9a23b456349086aab5f7172a461ce2154458313f
eduardoldk-hub/curso_python
/notas/Exercicios Apostila python/Exercício 8 - Strings.py
891
3.515625
4
#-----------------------------------------------EXERCICIO 8 - STTRING----------------------------------------------------------------------------------------------------------------------------------------------------------- print(dir(str)) # possui muitos metodos na conotação ponto # print(help(str.format)) aju...
95cddd9afb839d70abcf5e9ac0c0865b9278268d
JacksonMike/python_exercise
/python练习/老王开枪/配置房子.py
1,323
3.796875
4
class Home: def __init__(self,newArea,newKind,newAddress): self.area = newArea self.kind = newKind self.address = newAddress #剩余面积开始时候是等于初始面积 self.leftArea = newArea self.containItems = [] def __str__(self): msg= "房子的总面积是:%d,可用面积是:%d,类型是:%s,地址是:%s"%(self.a...
623172508940f3aa2860f2b0d2a6471053329d5d
arunsramalingam/python-3.x
/filie_exists.py
312
3.578125
4
import os # todo check for existing file. if os.path.isfile('./PBIOutput.txt'): # check to see if file exists data = open('./gradebook.dat', 'rb') # if file exists open, read all data. data.close() else: print("The file gradebook.dat was not found.\n") print("We will create one....\n")
365ed22bb635b93b62c988d102198a70f8f5002a
slavojstar/project-euler
/102 TriangleContainment.py
3,681
3.6875
4
# Find the number of triangles for which the interior contains the origin import numpy as np from matplotlib.patches import Polygon import matplotlib.pyplot as plt def FindTriangleContainment(): # List containing lists of length 6 representative of each # triangle triangles = [] with open("102 Triangles.txt") a...
f63366eb937d4c2807e8fbcaa36cdb5e107d33c4
jenkins2099/Python-CSCI-7
/Days/Day 2/bmi.py
437
4.4375
4
#Calculate the users bmi and tell them which range they fall in weight=int(input("Enter your weight in lbs ")) height=int(input("Enter your height in inches ")) bmi= round((weight/height**2)*703,2) print("Your BMI is",bmi) if bmi < 18.5: print("You are underweight") elif bmi >=18.5 and bmi <=24.9 : ...
0e9e985b8ace5785d2f5c1c671401c5d0371c927
khygu0919/codefight
/Intro/isDigit.py
188
4.09375
4
''' Determine if the given character is a digit or not. ''' def isDigit(symbol): try: if int(symbol)==0 or int(symbol): return True except: return False
c3e2fad78d130bfdbce9bd786ec63103cb9730dc
raja0612/LearnPython
/Examples/NumPy/NumPy.py
568
4.25
4
import numpy as np x = [5, 10, 15, 20, 25] y = [] for value in x: y.append(value / 5) print("\nOld fashioned way: x = {} y = {} \n".format(x, y)) # list comprehensions; # syntax [do something for list] z = [value / 5 for value in x] print("List Comprehensions: x = {} z = {} \n".format(x, z)) try: a = ...
fcb053480403f26d016c400b645cbb6474a22848
SpiderlingJr/bf_cc
/difficulty_2/yoda.py
806
3.703125
4
# https://open.kattis.com/problems/yoda num_1 = input() num_2 = input() l1 = len(num_1) l2 = len(num_2) num_1 = list(num_1) num_1.reverse() num_2 = list(num_2) num_2.reverse() if l1 < l2: pads = l2 - l1 for _ in range(pads): num_1.append('0') elif l2 < l1: pads = l1-l2 for _ in range(pads):...
a932417fd1adf4126433a05d2ee87e62586c2988
adanvr/python_morsels
/csv_columns.py
624
4.09375
4
import csv def csv_columns(file): ''' This function accepts a file object and returns a dictionary mapping CSV headers to column data for each header. Example: h1,h2 1,2 3,4 Returns: {'h1': ['1', '3'], 'h2': ['2', '4']} ''' with open(file) as f: data = [row for row in cs...
342929909324ff7d9032dc5ccdfdf579f151566e
tutaczek/py_excercises
/validateInput.py
349
3.6875
4
while True: print('Podaj swój wiek:') age = input() if age.isdecimal(): break print('Wiek musi być wartością liczbową.') while True: print('Wbierz nowe hasło (tylko litery i cyfry).') password = input() if password.isalnum(): break print('Hasło musi składać się z liter ...
085884b55e3d4c241e66da42977648393325c06e
ibrahimgurhandev/mycode
/challenges/chal01.py
153
3.78125
4
#!/usr/bin/env python users_name = input("What is your name:") day = input("What is today:") print("Hello, "+ users_name + "!" + " Happy " + day + "!")
e48e72625173fc176ff3ff3a72f505bbd1e32b77
subdash/FastAPI-SMA
/src/client/gpg_service.py
5,579
3.546875
4
from getpass import getpass from typing import Set, Optional import gnupg import os class GPGService: """ GNU Privacy Guard service to encrypt and decrypt messages and files. This service is designed to be used in a web app or API to increase security of messaging. Usage note: All methods return...
b1a775112d8bd5de474411a371835df134aadc7a
bitspusher/project-euler
/src/problem34.py
1,035
3.96875
4
factorials = [] def fact(num): factorial = 1 while(num != 0): factorial = num * factorial num = num - 1 return factorial def getSumOfFactorialOfDigits(num): global factorials sumOfFactorialOfDigits = 0 for i in str(num): sumOfFactorialOfDigits = sumOfFactorialOfDigits + factorials[int(i)] #print("Sum of ...
304fd28bca5421074e795443b9d5497bc0c3465c
aktivx/CS106A-Python-raw
/AS2-compute_interest.py
1,651
4.5625
5
""" File: compute_interest.py ------------------------- Add your comments here. """ def main(): """ You should write your code for this program in this function. Make sure to delete the 'pass' line before starting to write your own code. You should also delete this comment and replace it with a be...
fd94efb050075cbdbe1d5d39fb31f3bf71e5a9b2
zakaleiliffe/IFB104
/Week Work/Week 3/IFB104-Lecture03-Demos/09-test_obscure.py
2,357
3.671875
4
#--------------------------------------------------------------------- # # Demonstration - Automatically testing a function # # This file illustrates the way we can use Python's "doctest" # module to automatically run several tests of a function. # # Scenario: As a security measure, credit card and ATM receipts # usual...
f31ca60bcf37eaddaf3b8aff53a5d8b7312e1e13
tapa8728/code_2_win
/mirror_replace_2_with_abc.py
382
3.6875
4
def f(n): if n <=0: return "" elif n == 1: return "1" elif n == 2: return "11" elif n == 3: return "abc1abc" elif n == 4: return "abc11abc" elif n%2 == 0: #even return str(n//2) + f(n-2) + str(n//2) elif n%2 != 0: #odd return str(n//2 + 1) + f(n-2) + str(n//2 + 1) print f(1) print f(2) pri...
df7d95cc41ac4a6d207b8296f95b4aa15b3afc45
iCodeIN/algo-2
/dijkstra/dijkstra.py
2,705
4.25
4
def dijkstra(graph, costs, node_parents): """ Apply Dijkstra's algorithm on graph :param graph: the graph to apply the algorithm on (dict) :param costs: the initial known costs (dict) :param node_parents: the initial known parents (dict) :return: the final costs and the calculated parents (tupl...
80e5e095c57135f5afcfe4e0ce19fd3cd3c05a2b
DemetrioCN/python_projects_DataFlair
/basic_email_slicer.py
289
3.796875
4
print("\n") print(10*"-", "Email Slicer", 10*"_") print("\n") email = input("Introduce your email: ").strip() user_name = email[:email.index('@')] domain = email[email.index('@')+1:] output = f'Your usernam is {user_name} and your domain name is {domain}' print(output) print('\n')
f86211c9a14715cf8194351c10845cafc1ba32d8
mouse-reeve/context-free-grammar
/cfg/CFG.py
1,711
3.65625
4
''' Generate randomized CFG sentences ''' from nltk.grammar import Nonterminal from nltk import CFG as nltkCFG import random import re class CFG(object): ''' a grammar from an input file ''' def __init__(self, grammar): self.grammar = nltkCFG.fromstring(grammar) def get_sentence(self, start=None...
a4977ce900d15eac1cbcfb382a6843713d0e07ae
skrall3119/prg
/Furniture.py
2,523
3.78125
4
# Superclass "Furniture" class Furniture: def __init__(self, category, material, length, width, height, price): self.__category = category self.__material = material self.__length = length self.__width = width self.__height = height self.__price = price ...
36b544d974595f6381b5ff422e1fdd80b6edfd92
CristopherDavid/matriculapy
/fecha.py
866
3.84375
4
from datetime import datetime class DateObject(): def __init__(self,string_date): self.string_date =string_date.strip() self.date_validation() self.get_day_number() def date_validation(self): #Date format validation we can have '-' or '/' as our date separator if(self....
20fb12a4538e8054ebc2e468a15de34efc02a591
kenkh/course-material
/exercices/050/solution.py
176
3.734375
4
# -*- coding: utf-8 -*- """ Created on Mon Sep 22 23:11:57 2014 @author: Ken N """ s = 0 for i in range(1, 1000): if i % 3 == 0 or i % 5 == 0: s = s + i print(s)
e65bc57342d75b16ed92ce9661a7aba9fd955a1e
iamsiva11/Codingbat-Solutions
/logic2/round_sum.py
1,582
4.09375
4
""" For this problem, we'll round an int value up to the next multiple of 10 if its rightmost digit is 5 or more, so 15 rounds up to 20. Alternately, round down to the previous multiple of 10 if its rightmost digit is less than 5, so 12 rounds down to 10. Given 3 ints, a b c, return the sum of their rounded values. T...
b57c067c94a1c6534b8c366604fee3bb2b6a219b
aymhh/School
/SAC_1_part_3/binarySearch.py
2,309
4.125
4
# By: Ameer Al-Shamaa # Date: 29/03/2021 # binarySearch.py # An alogrithim loop (binary) to sort through the pokemon collection and iniaite swaps if no pokemon exists within current array from pokemonArray import pokemonList # Import's the pokemon character list from another moudle. def binarySearchAlgo(array,item): ...
02d9e4bd7cb25a0ab74eb15781b10761816f9b1e
do-park/swexpertacademy
/problem/2003/00_200320/5688-세제곱근을찾아라.py
265
3.546875
4
for tc in range(1, int(input()) + 1): N = int(input()) answer = -1 for n in range(1, N + 1): result = n ** 3 if result == N: answer = n break elif result > N: break print(f'#{tc} {answer}')
e1d6b9cfa09c8fc8ac512d457f667e13aca8c14f
steveayers124/PythonStandardLibraryEssentialTraining
/Ex_Files_Python_Standard_Library_EssT/Exercise Files/Chapter 1/01_05/mathMyExample.py
3,784
3.515625
4
import math # https://docs.python.org/3/library/math.html print("ceiling of") f1 = 4.0 print(f" math.ceil({f1}) = |{math.ceil(f1)}|") f1 = 4.1 print(f" math.ceil({f1}) = |{math.ceil(f1)}|") f1 = 4.5 print(f" math.ceil({f1}) = |{math.ceil(f1)}|") f1 = 4.9 print(f" math.ceil({f1}) = |{math.ceil(f1)}|") i1 = 3 print...
4a5e7d1f218faa0b54d9787dc90e4873013c5e05
cmmolanos1/holbertonschool-machine_learning
/supervised_learning/0x03-optimization/4-moving_average.py
553
3.78125
4
#!/usr/bin/env python3 """ Bias correction """ def moving_average(data, beta): """Calculates the weighted moving average of a data set. Args: data (list): data to calculate the moving average of. beta (float): weight used for the moving average. Returns: list: moving averages of ...
83da20a3b7f84837a66b047e92f0ad5876f946fa
codeaffect/py_projects
/strings/manipulations.py
583
4.0625
4
print("*" * 10 + "START" + "*" * 10) message = "How are you" # index of a string print(f'Index of "you" in "{message}"') print(message.find("you")) # replace string print('Replacing "you" with "YOU"') message = message.replace("you", "YOU") print(message) # lower and upper case print("lower:" + message.lower() + "\nUPP...
040c1ec075ceb32ba5e24501ee9abea70044c2dc
amitabhnag/FakeReviewGenerator
/fakereviewgenerator/tests/test_eval.py
1,464
4.09375
4
"""Provide unit tests for the eval.py script. There are 2 types of test inputs: with an input .txt file and an input String. The goal of eval.py is to deliver the grammar score of a given .txt or String. Require: pip install language-check Author: Toan Luong, May 2018. """ import unittest from fakereviewgen...
c0be979e833533078c9c503ca7272db5701bc0b8
arossbrian/my_short_scripts
/BeautifulSoup/Scrape_scientists_names.py
574
3.546875
4
#!/usr/bin/python3 """ I want to scrape a list of Scientists from a website and store the information in a DB. I shall decide the nature of the DB """ import requests from bs4 import BeautifulSoup url = "http://www.fabpedigree.com/james/mathmen.htm#Legendre" source = requests.get(url) results = source.con...
7b070664b9927279b6f3099fd4953e3e166b8efb
timeeeee/qwantzle
/utils.py
1,684
3.96875
4
from string import digits QWANTZLE_COUNTS = "12t10o8e7a6l6n6u5i5s5d5h5y3I3r3fbbwwkcmvg" def matches_counts(word, counts): """Check if there are enough characters to make up a word""" local_counts = counts.copy() for char in word: if char not in local_counts or local_counts[char] == 0: r...
02fb67809cd99897fb7c21369ed71a1f52e82e25
laxur1312/py4e
/ex_02_03.py
190
3.984375
4
hours = input('How many hours do you work? ') fhours = float(hours) rate = input('How much do you get paid by hour? ') frate = float(rate) pay= frate*fhours print('You get paid', pay)
0629a8a4a1b7e0eaec26516c635cae5c468e5d4f
Zenterio/opensourcelib
/k2/k2/utils/test/test_interpreter.py
1,046
3.5625
4
from unittest import TestCase from ..interpreter import find_where_instance_is_defined OBJECT = object() ANOTHER_OBJECT = object() REFERENCE_TO_ANOTHER_OBJECT = ANOTHER_OBJECT class TestFindWhereInstanceIsDefined(TestCase): def test_instance_can_not_be_found(self): assert len(find_where_instance_is_de...
3fb3fee5a50e230c7c0182aea93bcb30e05e7b9f
csuwu/DeftCodersv5-Answers
/Binary Stream to Text/isuru118/binarytotext.py
618
4.1875
4
import binascii #we need python binascii library for this easy question x=int(input("")) #get the number of lines that will be given to read for i in range(0,x): #loop for the given number of lines n=input("") if not(len(n)%8==0): #check for any invalid stream (we need to read exactly 8 bits for each output cha...
d4e3dc1360c61de507993908b9663defd0b0f9cf
JimmyVaras/JimmyCode
/Apuntes Basicos/Condicionales_And_Or_In.py
1,329
4.15625
4
print("Vamos a evaluar las probabilidades de obtener la beca en base a las siguientes condiciones: Distancia al centro, familia numerosa y el salario familiar.") distancia=int(input("Introduce la distancia a la escuela en km:")) print("Te encuentras a", distancia, "kms de la escuela") hermanos=int(input("Número de he...
6af5baea7124fb0721ae7326dda1241f41d78780
miaozaiye/PythonLearning
/miaozaiye/clock.py
2,826
3.640625
4
#绘制一个时钟,有秒钟,分钟,时钟指针 #秒钟指针每1秒移动一次。 #用户可以设置小时,分钟。 ''' 1. r = 1 大圆,分12等分 2。时钟指针 Hour_L 0.3, 分钟指针 Min_L 0.45, 秒钟指针 Sec_L 0.6 3. 每过1秒钟,秒钟指针移动1/60 圈;每过 1分钟, 分钟指针移动 1/60圈,每过1小时,时钟指针移动1/12 圈 ''' from stdpackage import stddraw from stdpackage import stdarray import math import sys def draw_clock(H = 0,M = 0, S = 0): std...