blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
532e4e292289ab880b2001c69e0aaa2a265ea3d2
Dearyyyyy/TCG
/data/3922/AC_py/508103.py
206
3.734375
4
# coding=utf-8 # this is a new learning program while True: a, b = input().split() a, b = int(a), int(b) if b == 0: print('error') continue else: print(int(a/b+0.5))
5a4c4bb87f3952a5c752edffd8b7dac5ba7d9681
pedronora/exercism-python
/nth-prime/nth_prime.py
321
4.03125
4
def prime(number): if number == 0: raise ValueError('Number must be bigger than zero') primes = [2] n = 3 while len(primes) < number: for prime in primes: if n % prime == 0: break else: primes.append(n) n += 2 return primes[-1]...
718f6ff1146a75ea902b6f1afd80cbb05de8d00e
wuxh123/pd23
/11_装饰模式.py
671
3.84375
4
#!/usr/bin/python #coding:utf8 ''' 装饰器 ''' class 店铺(object): def 笔(self): print("笔原价 10元") return 10 def 格尺(self): print("格尺原价 20元") return 20 #装饰模式 双十一 class 双11_店铺(object): def __init__(self, decoratee): self._decoratee = decoratee def 笔(self): ...
2d2a228659d0725fb93e280bc24fe2e59482e2a2
iteong/comp9021-principles-of-programming
/assignments/ass1/multiplication.py
3,639
3.96875
4
# Write a program named multiplication.py that solves the multiplication in such a way # that: # # * * * <==== x # X * * * <==== y # ------- # * * * * <==== product0 # * * * * <==== product1 ...
265eb6a812c73da9791671c8741e25f97aa670c6
saintsim/adventofcode-2019
/src/day8/part1.py
812
3.640625
4
#!/usr/bin/env python3 import collections def find_pixels(pixels, size_x, size_y): number_of_pixels_per_layer = size_x * size_y zero_count = number_of_pixels_per_layer # this is the max number of 0's possible least_zero_layer = [] pixel_index = 0 while pixel_index < len(pixels): layer = ...
c2ffe73a4ef599d10a2f83ad86e19039a2ecae26
drugs-4-3/Stratego---AI-player
/board.py
9,586
3.859375
4
import copy class Board: """ Class representing board on which the game is being played. For each position on board the coordinates are represented as (x, y) Top left position is (0, 0), x is incrementing as we go right, y is incremented as we go down, bottom-down position is (board.size -...
b0c0f59b3e70d87dda360b957f414c6d84365005
slimshady-9/Python
/Ducktype.py
910
3.890625
4
class duck: def swim(self): print("It swims"); def walk(self): print("It walks"); def sound(self): print("It hjonks"); class frog(): def swim(self): print("It swims"); def walk(self): print("It walks"); def sound(self): print("It croaks"); clas...
33385ead645405b3ccb9f7ce87982a480f616ea0
uiandwe/TIL
/algorithm/Daily Coding Problem/전체탐색/7.py
1,111
3.953125
4
# -*- coding: utf-8 -*- """ Given a array of numbers representing the stock prices of a company in chronological order, write a function that calculates the maximum profit you could have made from buying and selling that stock once. You must buy before you can sell it. For example, given [9, 11, 8, 5, 7, 10], you sh...
ba7e66589ca114c38dd1b334daff182c2bfb0d90
hubieva-a/lab4
/PycharmProjects/lab3/1.py
243
3.953125
4
whatsyourname = input("What is your name?") howoldareyou = input("How old are you?") wheredoyoulive = input("Where do you live?") print("This is " + whatsyourname) print("(S)he is " + howoldareyou) print("(S)he lives in " + wheredoyoulive)
a8847e610d32560a3a6832c5e2672d8e1dad92bf
eric496/leetcode.py
/array/485.max_consecutive_ones.py
752
3.703125
4
""" Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: [1,1,0,1,1,1] Output: 3 Explanation: The first two digits or the last three digits are consecutive 1s. The maximum number of consecutive 1s is 3. Note: The input array will only contain 0 and 1. The length of inpu...
ecf385adfbd54b1ba542f8fb8fda479065422d3a
lei-diva/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/tests/test_models/test_square.py
7,678
3.578125
4
#!/usr/bin/python3 """ Unittest for base([..]) """ from models.square import Square from models.rectangle import Rectangle from models.base import Base import io import contextlib import unittest class TestSquare(unittest.TestCase): """class TestSquare""" def test_square(self): """tests for Square ...
74db2cb716b6061ba7af77c4ef33bb2dc6029e52
igor-correia/URI-python
/Categoria iniciante/1035.py
322
3.609375
4
i = 0 numeros = input().split() A = int(numeros[0]) B = int(numeros[1]) C = int(numeros[2]) D = int(numeros[3]) if B > C and D > A: if (C + D) > (A + B): if C >= 0 and D >= 0: if (A % 2) == 0: i = 1 if i == 1: print('Valores aceitos') else: print('Valores nao aceitos') ...
e32268106eee9dadd9dd53963567b209212abc97
DaHuO/Supergraph
/codes/BuildLinks1.01/test_input/sort_codes/graphsort.py
3,084
3.5
4
import random from Tkinter import * import time class numbers(object): def __init__(self): self.genNumbers(50) # Fill list with random numbers def genNumbers(self, num): self.numberList = [] for i in range(num): self.numberList.append(random.randint(1,290...
00d95e0f6903172d9b25085bcff8f6dd5a20deb5
nmicht/algorithm-exercises
/lowest_common_ancestor.py
1,175
4.09375
4
# Design an algorithm for computing the LCA (lowest common ancestor) of two nodes in a binary tree in which nodes do not have a parent field. # The LCA is the node furthest from the root that is an ancestor of both nodes. import collections def lca(tree: BinaryTreeNode, node0: BinaryTreeNode, node1: BinaryTreeNode) -...
6c0e0c16ff0770b31341e2ad8d0c1851b69f3213
philipp-mac/schulrepos
/py_scripts/misc/01102020interfaces.py
1,776
3.5625
4
import abc class Motorisiert(metaclass=abc.ABCMeta): @abc.abstractmethod def motorStarten(self): pass @abc.abstractmethod def tanken(self, treibstoff: str): pass @abc.abstractmethod def ladungAufnehmen(self, anzahl: int): pass @abc.abstractmethod ...
e56885e459b060c797dd33734a23b4055373d5b6
pku-cs-code/algorithm
/bubbleSort.py
633
3.625
4
#!/usr/bin/env python # _*_ coding:utf-8 _*_ # __author__ = caicaizhang class Solution: def sortArray(self, nums): length = len(nums) for i in range(length-1): # value = nums[i] for j in range(i+1,0,-1): # print("j is:{}".format(j)) if nums[...
8962504aab7f012b1028cab2190df9d5bd37f733
Aasthaengg/IBMdataset
/Python_codes/p02645/s271456260.py
198
3.875
4
import random name = input() n = random.choice(name) while name.find(n) > len(name) - 3: n = random.choice(name) num = name.find(n) for i in range(3): print(name[num + i], end = "")
a41eefaf30d1724315c531a11ae6cf1a1377d76e
zhenyakeg/graph_theory
/Graph_Theory_SemiFinal_Preparartion/09_krascal_algorithm.py
1,351
3.59375
4
'''Нахождение остовного дерева минимального веса. Алгоритм Краскала. Реализация на Python 3.''' def read_as_edges_list(): N, M = tuple(map(int, input().split())) edges = [] for i in range(M): edges.append(tuple(map(int, input().split()))) return edges, N def krascal(graph_as_edges, num_of_verte...
f5d88f789c471b2662b0a1264d52fa086216dae4
Beltran89/Curso-Python-Django-Flask
/10-sets-diccionarios/dicccionario.py
808
4.1875
4
""" Diccionario: Un tipo de dato que almacena un conjunto de datos. En formato clave > valor Es un parecido a un array asiciativo o un objeto Json """ personas = { "nombre":"Ruben", "apellido":"beltran", "edad":31 } print(personas["nombre"]) #Para ver el valor de key nombre # Lista con diccionarios con...
5d9dd40e0eeee821a483f909ad7236ce196ba4c3
arjun-krishna1/leetcode-grind
/reverseLinkedList.py
2,916
4.21875
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, val=0, next=None): # self.val = val # self.next = next ''' GIVEN INPUT head of a singly linked list reverse the list return the reversed list e.g. 1 -> 2 -> 3 -> 4 -> 5 : 1 <- 2 <- 3 <- 4 <- 5 1 -> 2 : 1 <- 2 BRUT...
56957080cdaaf8b75f3d1462a250bcb9893d8fc4
anowarh2514/python-first-programs
/myprogram.py
176
3.625
4
h = 10 e = 20 l = 30 o = 40 print(h+e+l+l+o) gretting = input("Write here: ") print(gretting) age = input("Enter your age: ") father_age = float(age) + 25 print(father_age)
f63c8eff9e877b248bb2aec5150a25775b1572b2
Elozzy/guessNumberGame
/gamereloaded.py
2,424
4.09375
4
import random as r print("Enter your name:") name = str(input()) print("=============Welcome " + name + ", to guess the number game. Am thinking of a number between 1 and 10========================") print("-------------------------------------------------------------------------------------------------------------...
f66cadda7d9ab9a49476b2c50bd18c1736697c68
shartrooper/My-python-scripts
/Python scripts/Rookie/table-printer.py
869
3.796875
4
tableData = [['apples', 'oranges', 'cherries', 'banana'], ['Alice', 'Bob', 'Carol', 'David'], ['dogs', 'cats', 'moose', 'goose']] def printTable(table): #store maximum width of each column in new list colWidths=[0]*len(table) for i in range(len(table)): for...
a68922673cf6e6d75fa4c6a5eb784653a81a63b1
jgerardsimcock/ADA
/week2/myQSortB.py
857
3.890625
4
def _partition(array, start, end): count = 0 pivot = start for i in xrange(start, end): count += 1 if array[i] < array[end]: #Swap! array[i], array[pivot] = array[pivot], array[i] pivot += 1 array[pivot], array[end] = array[end], array[pivot] return pivot, count def _quic...
da92a7252751052b548f62a0cf7305cd0ce4cc0c
plazith/test
/functions.py
267
3.734375
4
def sq(arg): return arg * arg def p(num, times): thing = num for x in range(times - 1): thing = thing * num return thing def fac(num): thing = num if num == 1: return print num print fac(num - 1) print p(4, 2) print sq(10) print p(2, 3) print fac(5)
c9c7a10d0fa84a6600418ae752e191876be6cd9b
hiyouga/PY-Learning
/mooc/002.py
273
3.65625
4
#TempConvert.py val = input("Input the temp:(32C)") if val[-1] in ['C','c']: f = 1.8 * float(val[0:-1]) + 32 print("Converted temp is: %.2fF"%f) elif val[-1] in ['F','f']: c = (float(val[0:-1]) - 32) / 1.8 print("Converted temp is: %.2fC"%c) else: print("Wrong input")
3f62b3347a7da2222167c2ded2b738784b5c94fb
NoisNette/Codesignal-solutions
/depositProfit.py
184
3.515625
4
def depositProfit(deposit, rate, threshold): money = deposit years = 0 while money < threshold: money += (money * (rate / 100)) years += 1 return years
3793fd6fa1a771d2ff5d4572a2c0e3cd2a22fbee
runzedong/Leetcode_record
/Python/reversestrii.py
524
3.8125
4
def reversestr(s): # s is a list of char helper(s,0,len(s)-1) runner=0 walker=0 while runner<len(s): #print(runner) while runner<len(s) and s[runner]!=' ': runner+=1 helper(s,walker,runner-1) runner+=1 walker=runner #print('final list') def helper(s,left,right): #input should be a list print('subro...
1b4297586d35d9fd679540776cd7be5cd9029850
adibollam/GreatPros-Demand-Analysis
/Python/OutputDemand.py
2,152
3.53125
4
import sqlite3 import csv #############----Open Database Connection----############# db = sqlite3.connect(dbpath) db.text_factory = lambda x: str(x, 'latin1') d = db.cursor() #############----Select Dates----############# first_date = d.execute("SELECT MIN(DISTINCT Date) from ParsedData").fetchall()[0][0] #must be a...
40f19d65dd5b739d5c12a42c9e827e67c6bfeb78
chrisr1896/Exercises
/intro_&_enviro/data_types_and_control_flow/1_even_odd/Solution/solution.py
118
3.84375
4
# Code your solution here number=int(input()) if (number%2)==0: data="Even" else: data="Odd" print(data)
8a5a1f9b5dcf9ccd23f6d9c198465ebe03508d9c
Starfloat/PCC
/Chapter 7 - User Input and While Loops/pizza_toppings.py
255
4.0625
4
# 7-4 while True: topping = print('What topping would you like for your pizza? ') topping = input("Type 'quit' to exit: \n") if topping == 'quit': break else: print('Adding ' + topping + (' to your pizza.'))
c1302c4757c97d6999ba26d63d299d82993c2737
FrancoisQUI/4425126-testing-python
/calculate/view.py
1,513
3.875
4
class View: @staticmethod def print_menu(): """ Prints all menu items and the corresponding number. """ print("\n=========== MENU ===========") print("1 - Addition") print("2 - Soustraction") print("3 - Multiplication") print("4 - Division") ...
40d0c6fd3da32ccf6535871d6b19edf2acafff80
SourabhShenoy/Python-Code
/Google Foobar/GitCodes/foobar-master-3/minglish_lesson/py/minglishlesson.py
5,141
3.828125
4
""" Minglish lesson =============== Welcome to the lab, minion. Henceforth you shall do the bidding of Professor Boolean. Some say he's mad, trying to develop a zombie serum and all... but we think he's brilliant! First things first - Minions don't speak English, we speak Minglish. Use the Minglish dictionary to lea...
6a4f81b1bbb29f2d7971f86b94b1a2c112d4ec22
caiquemarinho/python-course
/Exercises/Module 04/exercise_41.py
328
3.953125
4
""" Make a program that will read the work hours in a month and generate the salary of an employee with a 10% bonus. """ bonus = 1.10 print('Insert the amount of worked hours') wh = float(input()) print('Insert the value value of your hours') hv = float(input()) salary = (hv * wh)*bonus print(f'Your salary is {sa...
b6dc46abf6b4e143f8418a3d747176b3ae193ef6
zhaomengit/Introduction-to-Algorithms
/src/question/2-1-4.py
996
3.71875
4
# -*- coding:utf-8 -*- """ 2-1-4: 把两个二进制整数加起来 这两个整数分别存储在两个n元组A和B中 这两个整数的和应该按二进制形式存储在一个(n+1)元组C中 """ from random import randint # ab有5位 index = 5 def randoms_to_list(arg_list): for i in xrange(0, index): arg_list[i] = randint(0, 1) return def add_binary_num(a, b, c): for i in xrange(0, len(a)): ...
830f8f9c14c901694c6f38a805b89920f8150a3e
keshav1245/HackerRankSolutions
/Python(LanguagePractice)/PalindromeTriangle.py
618
3.578125
4
#The constrainsts were to not use str and more than 1 for loop and code should be at max 2 lines in side the for loop. #The perfect solution for the same is the 3rd one, however the 1st two are another approaches that can be used to deal with the problem. #Approach 1 for i in range(1,int(input())+1): left = "".jo...
5abbab1e2c6e9503b0e39052ddbaadd6ac1ad084
pymft/mft-vanak
/S11/check_code_runtime.py
1,762
4.15625
4
import time import math import random def is_prime(n): for i in range(2, n): if n % i == 0: return False return True def is_prime_new(n): for i in range(2, int(math.sqrt(n))): if n % i == 0: return False return True def is_prime_3(n): """ Miller-Rabi...
46cd9c0fdf6baddb76b62ce50fd0ebaa918eb7a2
hodevin/speed-surprises
/speedsurprises/lists/sets.py
637
3.640625
4
"""Represent and/or manipulate sets""" # Source and/or inspiration for the function(s): # https://is.gd/GIibZB # Worst-case time complexity: O(len(list_one) * len(list_two)) -- Quadratic def is_subset(first_list, second_list): """Assumes first_list and second_list are lists. Returns True if each element in ...
a5ee8ff87f1bf59e98abd08bbaabe27a510f51d6
Bibin22/pythonpgms
/Tutorials/Class Prgms/static method.py
494
3.625
4
class Student: school = "ICET" #Class Variable def __init__(self, m1, m2, m3): self.m1 = m1 self.m2 = m2 self.m3 = m3 def avg(self): avrg = (self.m1 + self.m2 + self.m3) / 3 print(avrg) #return(self.m1 + self.m2 + self.m3) / 3 @classmethod def inf(cls...
1eb7f0cd9829c150a336f4f164449352745fa0b3
MoKamalian/CSCI2202
/Lab2_Kamalian_Amir/polygon.py
488
4.5
4
# Amir Kamalian - CSCI 2202 - Lab 2 # Ex 1 - This program allows turtle to draw polygons with the number of sides according to input # from the user. import turtle numSides = int(input('Enter the number of sides: ')) turtleWindow = turtle.Screen() turtleWindow.title('Lab2') hendrix = turtle.Turtle(shape='tu...
27ab6df65db2e63566727e5719b434d079512ac7
Mostofa-Najmus-Sakib/Applied-Algorithm
/Leetcode/Python Solutions/Arrays/MaximumSubarray.py
2,670
3.78125
4
""" LeetCode Problem: 53. Maximum Subarray Link: https://leetcode.com/problems/maximum-subarray/ Language: Python Written by: Mostofa Adib Shakib """ """ Brute force solution 1 Time complexity: O(n^3) We use two loops one starts from the first index of the array and the other one starts from the last index of the ...
eef340260ee099ff63a6bb3e5925d040f92ab9a6
dmcdekker/interview-and-coding-problems
/hackerrank/hackerrank-30-days/Day-7/arrays.py
406
3.8125
4
# import math # import os # import random # import re # import sys # if __name__ == '__main__': # n = int(input()) # arr = list(map(int, input().rstrip().split())) # print(" ".join(map(str, arr[::-1]))) def reverse_string(str_in): str_lst = list(str_in) str_out = '' for letter in str_lst[::-1...
fe4f13b18ae08fd482f22a80243acf1ccdf22f99
loveabc/mypython
/Closure.py
451
3.84375
4
#python 闭包与闭包的应用之装饰器 def org(fun): def in_fun(*args): if len(args)==0: return 0 for arg in args: if not isinstance(arg, int): return 0 return fun(*args) return in_fun @org def sum_all(*args): return sum(args) def avg(*args): return sum(arg...
67bcda2864e92495904721a7d033e13d4a423eb7
matrixback/leetcode_python
/234_Palindrome_Linked_List.py
1,124
3.90625
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def isPalindrome(self, head): """ :type head: ListNode :rtype: bool """ def list_size(head): cnt ...
0d9a307ea9fbbae08f8a6b15e35d08b7abc5cf24
hyunjun/practice
/python/problem-math/happy_number.py
1,160
3.5
4
# https://leetcode.com/problems/happy-number import math class Solution: # 21.14% def isHappy0(self, n): digitSum, digitSumSet = 0, set() while 1 != digitSum: digitSum = 0 while 0 < n: digitSum += (int)(math.pow(n % 10, 2)) n //= 10...
5d3d02bee932ea4fba31fad5a0efe14893db2c72
linkcheng/python_demo
/demos/demo/nonlocal_demo.py
448
3.734375
4
# -*- coding: utf-8 -*- def make_counter(): count = 0 def counter(): nonlocal count # use python 3 count = 1 print(count) return count print(count) return counter var = 0 def func(num): print(num) func.var = var # func.var is referring the local ...
9faf7696bf4512389562fd2e018c60666a6ae1f9
IvanWoo/coding-interview-questions
/puzzles/search_a_2d_matrix_ii.py
2,345
4.125
4
# https://leetcode.com/problems/search-a-2d-matrix-ii/ """ Write an efficient algorithm that searches for a value target in an m x n integer matrix matrix. This matrix has the following properties: Integers in each row are sorted in ascending from left to right. Integers in each column are sorted in ascending from top...
776f388a8e68665f80afe7e8ce8910c194091a8a
ortizfer/DeepFind
/Deep Learning/src/4-stack LSTM.py
3,792
3.5
4
# -*- coding: utf-8 -*- """ Created on Sun Apr 15 13:56:18 2018 @author: Rathk """ # Jose's Recurrent Neural Network #Pre-process the data import numpy as np import matplotlib.pyplot as plt import pandas as pd from sklearn.preprocessing import MinMaxScaler from keras.models import Sequential, load_model ...
cc5b97f8bc9b40c261ca8e7502a7923f6342dca8
Liam1809/Python_Practice_Small_Projects
/Classes/Classes_Practice.py
1,635
4.21875
4
# Methods with Arguments class Circle: pi = 3.14 def area(self, radius): return self.pi * radius ** 2 # instance circle = Circle() pizza_area = circle.area(12//2) teaching_table_area = circle.area(36//2) round_room_area = circle.area(11460/2) # print(pizza_area) # print(teaching_table_area) # print(round_room...
dfda77ac886f9d11ce60149ff14680bdf06811ed
AdamZhouSE/pythonHomework
/Code/CodeRecords/2845/60622/284782.py
134
3.765625
4
s=input() t=input() q=input() if s=="2" and t=="1 1" and q=="2 2": print("Poor Alex") else: print(s) print(t) print(q)
65b4b1b487f08e31d713f97561ee42edfef1f36a
Katherinelove/python
/VSPython/classes.py/classes.py/classes.py.py
387
3.828125
4
class myschool(object): name="" address="" type="katherine" def print_school(self): print(myschool.name) print(myschool.address) print(myschool.type) def main(): school1=myschool() school1.name="chengdu" school1.address="changhuaqu" school1.type="daxue...
f25a590bef276a23903a6724855899bd1dc63c7a
brunorijsman/coding-katas
/bank-ocr-python/bank-ocr.py
3,837
3.53125
4
import copy pattern_raw_digits = [ [' _ ', '| |', '|_|'], [' ', ' |', ' |'], [' _ ', ' _|', '|_ '], [' _ ', ' _|', ' _|'], [' ', '|_|', ' |'], [' _ ', '|_ ', ' _|'], [' _ ', '|_ ', '|_|'], [' _ ', ' |', ' |'], [' _ ', '|_|', '|_|'], [' ...
9f62b2de23dcfb6cafc64fe67bc158debf2da090
Fudeveloper/python
/python/常用内建模块/-base64.py
943
3.515625
4
#-*-coding:utf-8-*- ''' 如果要编码的二进制数据不是3的倍数,最后会剩下1个或2个字节怎么办? Base64用\x00字节在末尾补足后,再在编码的末尾加上1个或2个=号, 表示补了多少字节,解码的时候,会自动去掉。 Python内置的base64可以直接进行base64的编解码: ''' import base64 res=base64.b64encode('wang') #d2FuZw== print res print base64.b64decode(res) #wang ''' 由于标准的Base64编码后可能出现字符+和/,在URL中就不能直接作为参数, 所以又有一种"u...
8bbb683074ab6c9ef9b5a830514840f672bb1366
erietz/osu-cs261-project6
/d_graph.py
13,362
3.9375
4
# Course: CS261 - Data Structures # Author: Ethan Rietz # Assignment: 6 # Description: Contains a class which represents a directed graph from collections import deque import heapq class DirectedGraph: """ Class to implement directed weighted graph - duplicate edges not allowed - loops not allowed ...
d71978fa692793d73356f961ffeddcc114ae87be
lenstoner/Lens-Stuff
/Python/EtchASketch/EtchASketch/EtchASketch.py
647
4.4375
4
import turtle # Declare Variables penColor = 'black' lineLength = 0 angle = 0 # Get values from user lineLength = int(input("Enter the line length. Enter 0 to exit: ")) penColor = input("Which color? black, blue, red, or green: ") angle = int(input("What angle? 0 - 360: ")) while lineLength != 0 : turtle.color(...
bd7b4f85344304ef1cfee85b4c4fd1a35599efeb
inshaal/DPSB-Lab-Practicals
/AHZ PRACTICAL PAPER/Received from QA/Q30.PY
1,957
4.09375
4
"""This class is used to get the details of the item to be bought""" class ITEMINFO(object): def __init__(self): """Initializing all the variables used""" self.ICode = 0 self.Item = 0 self.Price = 0 self.Qty = 0 self.Netprice = 0 self.Dis...
f8d2f23247b6631ae389c14437c20aa0298823d8
koengommers/hefi-tool
/hefi_tool/retrieval/documents_page.py
1,665
3.65625
4
"""Contains DocumentsPage class.""" import os import requests class DocumentsPage: """Represents a listings page of non-standardized documents.""" def __init__(self, entry, reload=False): """Init the class. Args: entry (Entry): The entry to get the listings page from. ...
45e714b018aaed69132933b169dd1c8cd61e0d9a
Sicun/homework
/examples/oop.py
520
3.703125
4
#!/usr/bin/env python #encoding=utf8 """ 面向对象示例 """ class A: def __init__(self): self.name = 'A' def dosomething(self): # 多态 print(self.someinfo()) def someinfo(self): return "I am " + self.name class B(A): def someinfo(self): # self.name继承自父类A retur...
d68a79103f472d5bba638f49c0e1d8621bde0cbf
shivrajtaware/Data-Visualization
/scatterPlot.py
218
3.671875
4
import pandas as pd import plotly.express as px df = pd.read_csv("data.csv") fig = px.scatter(df, x = "Population", y = "Per capita", size="Percentage", color="Country", size_max=40) fig.show()
f8cdcfc02e7bfe872749c74f4c2af09a40385637
jinnmen/myPythonJourney
/HardWay/ex33.1.py
524
4.03125
4
i = 0 numbers = [] # while i is less than 20 while i < 20: #print's the first i, from global this is 0 print "At the top i is %d" % i # adds first number into numbers list numbers.append(i) #calculation for i + 2 i = i + 2 #does not calculate here, prints numbers list starting with 0 print "Numbers now: ", n...
f9598f3d48aa7903b0437a16c2a0b17cfabfdd77
Aboushady/SEPM
/menu.py
3,334
3.921875
4
import sys import userProfile import elimination import round_robin def quit(x): if(x.upper() == 'Q'): print('\nbye') sys.exit() def main_menu(): option = 'X' while(option.upper() != 'T'): print('\n') print(" BestGame\n\n") print("Please...
865dc42792ca60ed7f265f83312f23ca40f07dd3
lucasoliveiraprofissional/Cursos-Python
/Curso em Video/desafio016.py
264
4.15625
4
#ler numero real qualquer e mostrar sua porção inteira, sem virgula from math import trunc numero= float(input('Digite um número qualquer com ponto: ')) truncado= float(trunc(numero)) print('O numero {} tem a parte inteira {:.0f}'.format(numero, truncado))
a3791091eb6140a5625535aa9784cbfccdee2255
jun-yoshiyoshi/tkinter_codes
/3filedialog1.py
807
3.515625
4
import tkinter as tk from tkinter import filedialog def get_filepath(): # 全てのファイルの場合 filetype_list = [("all file", "*")] # .txtファイルの場合("text file", "*.txt"),.pyファイルの場合("py file", "*.py"), # ファイル パス の 取得 filepath = filedialog.askopenfilename( initialdir="/home/suteab 12", filetypes=filetype...
89680819af4dfd21e1ce36e926de2d8cf2e52a10
denisefavila/python-playground
/src/linked_list/models/with_tail/linked_list.py
2,218
3.796875
4
from typing import List, Any, Union from src.linked_list.models.protocol import LinkedListProtocol from src.linked_list.node import Node class LinkedList(LinkedListProtocol): """ Implement a single linked list using head and tail implementation. """ def __init__(self): self.size: int = 0 ...
2fffeb42be5c459b2f70808b3253c19c947682a4
xiaomoxifeng/scarpy
/chapter6/edit.py
729
3.515625
4
# -*- coding: utf-8 -*- import urllib import urllib2 import mechanize import login COUNTRY_URL = 'http://example.webscraping.com/edit/United-Kingdom-239' def mechanize_edit(): #login br = mechanize.Browser() br.open(login.LOGIN_URL) br.select_form(nr=0) print br.form br['email'] = login.LOGIN_...
2d501311a365ee4fc785bb035dae8b3411699614
jaevans/fractal-test
/graphics_fractal.py
1,490
3.5625
4
from graphics import * xmin = -2.0 xmax = 1.0 ymin = -1.5 ymax = 1.5 steps = 200.0 itter = 255 def main(): global xmin, xmax, ymin, ymax win = GraphWin("My Fractal", steps, steps, autoflush=False) while True: xstep = (xmax - xmin)/steps ystep = (ymax - ymin)/steps win.setBackgr...
8d724043ebbcaab2f30669c3e0022001f3064602
drgarcia1986/coding
/algorithms/sort/selection/python/selection.py
479
3.9375
4
""" >>> a = [1, 2, 3, 4, 5] >>> selection_sort(a) >>> a [1, 2, 3, 4, 5] >>> a = [4, 2, 5, 1, 3] >>> selection_sort(a) >>> a [1, 2, 3, 4, 5] """ def selection_sort(a): length = len(a) for i in range(length): min_idx = i for j in range(i+1, length): if a[j] < a[min_idx]: ...
2f37d0cd412e412a374241a04c806cd114a958d5
coolxv/DL-Prep
/04_Algorithms/Leetcode/JZ10 矩形覆盖.py
551
3.734375
4
# -*- coding:utf-8 -*- # 动态规划,为n的是为n-1和为n-2的组合,这个memoi也可以不需要,因为是前两项的之和 class Solution: def __init__(self): self.memoi = {1: 1, 2: 2} def rectCover(self, number): if number < 1: return 0 elif number in self.memoi: return self.memoi[number] else: ...
959900adeb345ab0b91c6d19770a260cea2d2933
richardoey/coding-interview
/4-Factorial/Python/factorial.py
214
4.21875
4
def factorial(num): num = int(num) if (num == 1): return num return num * factorial(num - 1) if __name__ == '__main__': number = input('Please enter number: ') print(factorial(number))
77dc8f34c8e2c3515f8aaca3c3d732dc90830f56
Mayur-Birle/PythonCodes
/Sorting.py3
1,960
3.921875
4
import random; def selection_sort(arr): arr = [i for i in arr]; size = len(arr); index = 0; for i in range(size-1): for j in range(i,size): if arr[index] > arr[j]: index = j; arr[i], arr[index] = arr[index], arr[i]; index = i+1; return arr; def bubble_sort(arr): arr = [i for i in arr]; size = len(...
742d17a243ae747561a9c9ce53e30762f8ce2f72
a46461440/python_study
/test/fun_code/return_fun.py
405
3.546875
4
def lazy_sum(arg) : def sum() : sum_real = 0 for per in arg : sum_real = sum_real + per return sum_real return sum list1 = [1,2,3,4,5,6] f = lazy_sum(list1)() print(f) print(f) def count(): fs = [] for i in range(1, 4): def f(): return i*i ...
b456696f715d064a303687489d51eed6110792c5
jdarangop/holbertonschool-higher_level_programming
/0x0A-python-inheritance/101-add_attribute.py
291
3.5
4
#!/usr/bin/python3 """Module add_attribute""" def add_attribute(cls, attribute, value): """Add a new attribute if is posible""" if isinstance(cls, (int, float, str, list, tuple)): raise TypeError('can\'t add new attribute') else: setattr(cls, attribute, value)
310e3b7e322f9044e82f45d541ff054511b37097
rpinedat/python-project
/enero_2021(lista 2)/tabla_de_verdad_58.py
943
3.625
4
# Escriba la función tabla_de_verdad(predicado) que reciba como parámetro un predicado lógico de tres parámetros # e imprima la tabla de verdad del predicado # for anidados # http://elclubdelautodidacta.es/wp/2012/11/python-los-operadores-logicos-y-sus-tablas-de-verdad/ booleanos = [True, False] # Tabla de verdad de ...
9778273e99237adf04dde7d53b5e1e34effd0d86
abhignyab2/LibraryManagement
/main_program.py
861
3.75
4
import classes2 as c print("********WELCOME TO LIBRARY AND INFORMATION CENTRE, CHAITANYA BHARATHI INSTITUTE OF TECHNOLOGY********") print() print(" 1.Add Student", "\n", "2.Issue Book", "\n", "3.Book return", "\n", "4.Display student information", "\n", "5.Display book information", "\n", "6.Add new book", "\n", "7....
9df5e20a42afa799cc2bd83f88be53c2f9c13e29
jorgesmu/algorithm_exercises
/others/key_in_json.py
3,404
3.96875
4
# Given a valid json payload, find the first ocurrency of a given a key at any level. # The payload is recieved as a stream of bytes which means that we can only access # one character at any given time. # Assumptions: # - '"' and ','' are not part of any string keys and values # - the stream of json is valid we dont ...
e0814cabeac9310332338a246aa9f7f33e3fc078
rafaelperazzo/programacao-web
/moodledata/vpl_data/303/usersdata/281/93395/submittedfiles/testes.py
143
3.5
4
# -*- coding: utf-8 -*- #COMECE AQUI ABAIXO a=[4,5,6,7,8] for i in range (0,len(a),1): print(a[i]//2)
36214ef2b9b533e6b67f763e1295726c4f5560fe
linfangzhi/py
/00005.py
272
3.796875
4
def 回文(desStr): desStrfan = desStr[::-1] if desStr == desStrfan: return 1 else: return 0 while 1: desStr = input("请输入一句话\n") if 回文(desStr) == 1: print("是回文\n") else: print("不是回文\n")
c0a1be24578c72f00e29f743c299e7b95049adf3
ipastuszynska/module2
/ch09_lists/ch09_iza_lists.py
7,521
4.03125
4
# -*- coding: utf-8 -*- """ Created on Thu Dec 13 09:31:25 2018 @author: iza """ #----------------------------------------------------- """Module 2 - Wk 6.Compound Data Types..""" """(9) Lists and Tuples """ #KEY LEARNING OUTCOMES #● What the difference is between mutable and immutable data #● What Lists are, their ...
842a8d96f3eee99ab762a9b9d5d56b951e7204bd
velisahiny/tictactoe.py
/tictactoe.py
3,003
3.890625
4
tictactoel=[" ","|", " ","|"," ", " ","|", " ","|"," ", " ","|", " ","|"," ", "--------------", " ","|", " ","|"," ", " ","|", " ","|"," ", " ","|", " ","|"," ", "--------------", " ","|", " ","|"," ", ...
8157539c703cb7323e14b6b3d437e8c30bba9363
KevenGe/LeetCode-Solutions
/problemset/881. 救生艇/solution.py
522
3.515625
4
# 881. 救生艇 # https://leetcode-cn.com/problems/boats-to-save-people/ from typing import List class Solution: def numRescueBoats(self, people: List[int], limit: int) -> int: people.sort() l = 0 r = len(people) - 1 count = 0 while l <= r: if people[l] + people[r] ...
6eec59f611135d40a7439228fec49dfe75d0022a
vindennl48/trade_helper
/money.py
1,975
3.953125
4
class Money: def __init__(self, amount=0, accuracy=8): self.amount = 0 self.accuracy = int(accuracy) self.set(amount) def set(self, x): value = float(str(x)) self.amount = int(value*(10**self.accuracy)) def get_accuracy(self,x): if type(x) is Money: ...
55bdd4b60083ceaeb7dfb9c09fccee985d8b19bc
karan-sohi/Mini-Python-Projects
/BlackJack/blackjack.py
2,218
4.03125
4
import random from logo import logo card_list = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10] def random_card_generator(): cards = [] first_card = random.choice(card_list) second_card = random.choice(card_list) cards.extend([first_card, second_card]) return cards def one_card_adder(card_list): ...
2968fc32717184431f47560352c2abcd8631dacd
iyeranush/100daysOfCoding
/034_lowest_common_ancestor.py
734
3.84375
4
""" Lowest common ancestor: Given a binary tree, find the lowest common ancestor for two given nodes """ class Node: def __init__(self, data): self.data = data self.left = None self.right = None def path_to(self, x): return find_path(self, x, [self]) def find_path(self, ...
09faba5b507d579955297f1993fa4e5f0fa48192
MoniqueLadds/koster_data_management
/utils/db_utils.py
3,713
3.546875
4
import sqlite3 import requests import pandas as pd import numpy as np import io # Utility functions for common database operations def create_connection(db_file): """create a database connection to the SQLite database specified by db_file :param db_file: database file :return: Connection object o...
df093add54e12e85833623101136fe0f66697c33
sureshdontha/cs329e-idb
/app.py
2,588
3.59375
4
from flask import Flask # Import Flask package from flask import render_template # Import render_template function app = Flask(__name__) # Construct Flask object named 'app' ''' @app.route() defines the URLs that route to the index() function. The URLs will be appended to the end of the base URL. Links within HTML fil...
5c82ed80824347390569a5bfdeda281f10b447ed
Victorli888/Python-Tutorial-Workbook
/HackerRank/HR_Kangaroo.py
853
3.796875
4
""" HackerRank Question Link: https://www.hackerrank.com/challenges/kangaroo/problem x1 - starting distance for Kangaroo 1 v1 - jumping speed for Kangaroo 1 x2 - starting distance for Kangaroo 2 v2 - jumping speed for Kangaroo 2 Find: whether or not both kangaroos eventually jump to the same spot Time Complexity: O(1) ...
ff4ac73a70ab59dc4f0e77959b56132acb26005d
JacobLutin/Python_bmstu
/2_semestr/MatrixD.py
1,496
3.75
4
def createMatrix(n): m = [[0 for x in range(n)] for x in range(n)] k = 2 for i in range(1, n): for j in range(0, i): m[i][j] = k k += 1 for i in range(n): m[i][i] = 0 for i in range(n): for j in range(i+1, n): m[i][j] = 1 ...
14f46022fce1e8bd1b55fd5b5cd7e06431b04891
OrElla/BrickBreaker
/Enemy.py
6,397
3.609375
4
import turtle import random class Enemy: enemy_t = [] # enemies_turtle list enemy_list = [] # enemies list and values counter_enemies = -1 # counter any created enemy num_of_enemies = 0 # defines current num of enemies # handle collisions states with player and bullet enemy_collide_pla...
706633884448106639ef1a793a35c225d36cf9c2
TashwillAndries/python-functions
/handout-exercise1/handout-exercise2/main.py
858
3.984375
4
def hotel_cost(nights): return 140 * nights print(hotel_cost(4)) def plane_ride_cost(city): if city == "Cape Town": return 2500 elif city == "Durban": return 2300 elif city == "JHB": return print(plane_ride_cost("Cape Town")) print(plane_ride_cost("JHB")) print(plane_ride_c...
1eb3976e0a4c07888c95aabac109b7cd1cb2dbb7
arhamw/Python-Chess-Game
/ChessEngine.py
19,677
3.828125
4
""" This class is responsible for storing all information about the current state of a chess game. It will also be responsible for determining the valid moves at the current state. It will also keep a move log. """ import keyboard as k class GameState: def __init__(self): # board is an 8x8 2d list, e...
38fabad6eb73dc4737a5636111da40d096664456
bam6076/PythonEdX
/quiz3_part4.py
423
4.1875
4
## Write a function that accepts a list of integers as parameter. ## Your function should return the sum of all the odd numbers in the list. ## If there are no odd numbers in the list, your function should return 0 ## as the sum. def _sumofodd(my_list): sum = 0 for i in my_list: if i%2 != 0: ...
375a4af76effade6d9dad8521b78773b16c85506
jgatt493/pillar_vending_machine_kata_python
/src/vending_machine_test.py
3,847
3.671875
4
import unittest import vending_machine from vending_machine import VendingMachine class VendingMachineTests(unittest.TestCase): def setUp(self): self.my_machine = VendingMachine() def test_when_machine_is_initialized_displays_INSERT_COINS(self): self.assertEqual(self.my_machine.display(),"IN...
7b75f469a5ce0db92483c36180ea944e3e0f8614
rodrigopamaral1/paradigmasprog
/t2/t2parte1.py
2,150
4.1875
4
# 1) Defina uma função addSuffix(suf,nomes) que retorne a lista de nomes com o sufixo suf adicionado. Exemplos: def addSuffix(suf,nomes): return [x+suf for x in nomes] # 2) Escreva uma função countShorts(words), que receba uma lista de palavras e retorne a quantidade de palavras dessa lista que possuem menos de 5 ca...
8930fbed6c4509c0a1119dd03465a0f77fe0e09e
zacharyDez/blog_content
/python-exception-handling-intro/generer_mot_passe.py
1,391
3.53125
4
from random import choice import string """ 1. Saisir longueur mot de passe """ longueur_mot_passe = 1 while longueur_mot_passe < 10 or longueur_mot_passe > 20: try: longueur_mot_passe = int(input("\nSaisir nb. de characteres entre 10 et 20: ")) except ValueError: print("""Vous avez saisie ...
ecad6d6caba8a6e5b765be24fe3709c420bf19d0
sankiteth/TopCoder
/SRMS/SRM 655/BichromeBoardMadeEasy/BichromeBoardMadeEasy/BichromeBoardMadeEasy.py
661
3.734375
4
''' http://apps.topcoder.com/wiki/display/tc/SRM+655 ''' def AbleToDraw(board): for k in range(2): bad = False for i in range(len(board)): for j in range(len(board[0])): if board[i][j] != '?': if board[i][j] != ('W' if (k + i + j) % 2 != 0 e...
0b83663d359ba43ef4b13b1ad4b742747a6e8b3a
dundunmao/lint_leet
/mycode/leetcode_old/1 array(12)/medium/280.py
562
4.15625
4
# coding:utf-8 # 题目:Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3].... # For example, given nums = [3, 5, 2, 1, 6, 4], one possible answer is [1, 6, 2, 5, 3, 4]. #思路:正sorted一下,反sorted一下,然后按顺序互相插入 def wiggle_sort(nums): s1 = sorted(nums) s2 = sorted(nums, re...
55de224b9d2daba5df09a4b572c48ab9509e5ce6
csfranze/PythonCodewars
/odd_or_even.py
401
4.03125
4
#Given an vector of numbers, determine whether the sum of all of the numbers is odd or even. # #Example: #odd_or_even(vec![0]) returns "even" #odd_or_even(vec![0, 1, 4]) returns "odd" #odd_or_even(vec![0, -1, -5]) returns "even" def oddOrEven(arr): s = [ ] if sum(arr) % 2 == 0: s.append('even') els...
c0d1c7aa818cfd50521c03247cce936101e31bb2
YaserSelim/Morse_Complex_PLY
/Functions.py
5,718
3.546875
4
def color(p,c,colorPosition): s = p.split() l="" i=0 while i < len(s): if i <colorPosition or i >=colorPosition+3: l+=s[i]+" " i+=1 else: if c == 'red': l += "255 0 0 " # l += "0 255 255 " elif c == 'green': ...
a1f89a2d841b47e51f0b4e749cbf5b0b17112e62
msraju2009/CodingProblemsPractice
/Trees/lowest_common_ancestor_of_a_binary_tree.py
1,151
3.8125
4
# https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/description/ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def lowestCommonAncestor(self, root...
6ea6e3cf7964fdf3b5c9e209cdb2cb838549e83f
chyt123/cosmos
/coding_everyday/lc500+/lc809/ExpressiveWords.py
2,186
3.5625
4
from typing import List # class Solution: # def expressiveWords(self, S: str, words: List[str]) -> int: # cnt = 0 # for i in words: # cnt += int(self.check(S, i)) # return cnt # # def check(self, S, word): # while word and S: # if S[0] == word[0]: # ...