blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
905b03fb4670e1ef7dd9af4e6dbb8ebfbc5ac40b
wnz27/About-Math
/content/line_algebra/line_algebra_learn/playLA/Vector.py
3,324
3.5625
4
# -*- coding:utf-8 -*- # Create by 27 # @Time : 2020/3/29 23:01 __author__ = '27' import math from content.line_algebra.line_algebra_learn.playLA._global import EPSILON class Vector: def __init__(self, lst): # 防止引用在外部被修改,所以复制一份 self._values = list(lst) @classmethod def zero(cls, dimension...
3c89371792b9046ec8aa7ad6240ee1a61cc69066
OperationFman/LeetCode
/Easy/Shortest-Word.py
258
3.828125
4
def find_short(s): if s == None: return None array = s.split(' ') smallest = '' for i in array: if smallest == '': smallest = i elif len(i) < len(smallest): smallest = i return len(smallest)
305c1ad781e47913369e0f81c0925d8a568d8322
Franklin-Wu/project-euler
/p033.py
2,939
3.890625
4
# Digit cancelling fractions # # The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that 49/98 = 4/8, which is correct, is obtained by cancelling the 9s. # # We shall consider fractions like, 30/50 = 3/5, to be trivial examples. # # There are...
6d6f2b158ef40c8ad71b114e41a8e55ceb55fe2a
dynamoh/Interview-solved
/Important/repr_method.py
218
3.8125
4
# printing objects/class class MyClass: def __init__(self, a, b): self.a = a self.b = b def __repr__(self): return "a: " + self.a + "b: " + self.b m = MyClass("hi", "there") print(m)
faf72028f196555ff4776fe365dd6c1dccf26721
yanpan9/Some-Code
/TreeNode/113.py
801
3.515625
4
from data_structure import TreeNode from typing import List class Solution: def pathSum(self, root: TreeNode, sum: int) -> List[List[int]]: res = list() def dfs(lst, sum_): node = lst[-1] if node.left: lst.append(node.left) sum_ += node.left.v...
c44375ce00465f690ae766631cbb139925170329
thorwhalen/ut
/ut/util/prand.py
892
3.78125
4
"""Utils to work with randomness""" __author__ = 'thor' import numpy as np from decimal import Decimal from numpy import random def rand_numbers_summing_to_one(n_numbers, granularity=0.01): n_choices = 1.0 / granularity assert round(n_choices) == int( n_choices ), 'granularity must be an integer...
e0ff9b0e341bccc4cd5096efea8fe9c6e0c5dac9
xiaoloinzi/worksplace
/GR1/Algorithm/20170721_02.py
1,073
3.71875
4
# encoding=utf-8 # 1、二叉树的广度优先遍历 from Queue import Queue class TreeNode(object): def __init__(self,var,left=None,right=None): self.var = var self.left = left self.right = right class BinaryTree(object): def __init__(self,root=None): self.root = root def breathSearch(self):...
f804b6b764f42a96f23f96edbae4132dc2eed007
AdamZhouSE/pythonHomework
/Code/CodeRecords/2474/60676/256459.py
649
3.515625
4
def func(s): length = 0 for i in range(len(s)-1): if s[i:i+2] == '()': temp = s[:i] + s[i+2:] count = 2 while (i+1 < len(temp) and temp[i:i+2] == '()') or (len(temp) > i > 0 and temp[i-1:i+1] == '()'): count += 2 if temp[i:i+2] == '()':...
71bf58edf082178da659de8be51a8aae44b59c3b
michaelChen07/studyPython
/cn/wensi/idle/you.py
1,112
3.71875
4
# -*- coding: utf-8 -*- #冒泡 def maop_block(pend_list): if type(pend_list).__name__!="list" and type(pend_list).__name__!="tuple": print"please input a list or tuple" return if len(pend_list)<=1: return pend_list if type(pend_list).__name__=="tuple": list(pend_list) for i ...
fb52d28c4a1487c9bb7008d8a334b2db1c1419b1
minus9d/programming_contest_archive
/event/kupc2015/a/a.py
478
3.53125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def solve(s): idx = 0 ret = 0 while True: i1 = s.find("kyoto", idx) i2 = s.find("tokyo", idx) # print(i1,i2) if i1 == i2 == -1: return ret else: if i1 == -1: idx = i2 elif i2 == -1: id...
9cded10e629e29e37410f347e14adad6076f3184
RAJU009F/my-work
/PYHTON/Clock.py
867
4.46875
4
#!usr/bin/python import sys import os """ Example for Inheritance Clock class """ class Clock(object): def __init__(self, hours=0, minutes=0, seconds=0): self.__hours = hours self.__minutes = minutes self.__seconds = seconds def set(self, hours, minutes, seconds): self.__hours = hours self.__minutes...
7ffed00fa4bd05b079c2ea36cc82fd54ef3d831b
Jonathan-aguilar/DAS_Sistemas
/Ago-Dic-2018/Max/Primer-Parcial-Examen/Ejercicio2.py
628
3.625
4
class CafeAbstracto(): def tipo(self): pass def precio(self): pass class CafeSimple(CafeAbstracto): def __init__(self, tipo, precio): self.tipo = tipo self.precio = precio def ingrediente(): return 'Cafecito con: ' def precio(): return 25 def imprime(self): ...
08823f540327149c6d4de3749d5d2317cdbd0e34
duanyiting2018/learning_python
/student_list1.py
694
3.5625
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 2 18:56:32 2020 @author: duanyiting """ class student: def __init__(self): self.name="" self.score=0 self.next=None head=student() head.next=None ptr=head select=0 while select !=2: print("输入1添加数据,输入2离开:") select=int(input()) if se...
0a50a017880b335666a225e1f78f81e82a981fe4
Nehanavgurukul/function_ques
/debug_average.py
90
3.765625
4
def Avg(number1,number2,number3): avg=(number1+number2+number3)//3 print(avg) Avg(1,3,2)
3a1eab207df9446760d844fd9e0a3cc37d24e991
hjones2199/remotepysorter
/client/remotesorter_client.py
2,149
3.65625
4
#!/usr/bin/env python3 """ TCP client implementation that reads words from a file line by line and asks the server to sort the words alphabetically on a per line basis. """ import socket class defaults: """ Common default values used throughout the program, possible candidate for refactoring into its own s...
5713ab171ba79a967c2b0e776fb1f3817feaca65
guoweifeng216/python
/mysql/email_test.py
2,054
3.703125
4
#!/usr/bin/env python # coding=utf-8 """ @athor:weifeng.guo @data:2019/4/18 11:35 @filename:email_test """ #coding:utf-8 from socket import * msg = b"\r\n I love computer networks!" #需要发送的数据 endmsg = b"\r\n.\r\n" # Choose a mail server (e.g. Google mail server) and call it mailserver mailserver = ("163mx02.mxmail....
4cf30ec199ec441762d7db021cbfc255c5b58122
pandabearcoder/kaizend-session-three
/exercises/products_csv_parser.py
476
3.546875
4
import argparse import pandas as pd parser = argparse.ArgumentParser(description='Generate a new file from csv of products') parser.add_argument('filename', help='filename of the csv to filter') args = parser.parse_args() csv_filename = args.filename products_df = pd.read_csv(csv_filename) filtered_products_df = pr...
720e13653111777fbbd972d6a3b2aee8321c5776
sakthiit/saki
/fact.py
87
3.984375
4
a=int(input('Enter a number')) fact=1 for i in range(1,a+1): fact=fact*i print('fact')
b05699de428d9702681d9aa8f338a934748e9c22
ttetrafon/practice
/python/regex/pattern matching.py
577
3.546875
4
import re mobileNumberRegex = re.compile(r'0\d\d-\d\d-\d\d-\d\d\d\d') mo1 = mobileNumberRegex.search("My number is 075-98-47-1692") print(mo1) print('Phone number found: ' + mo1.group()) # phoneNumberRegex = re.compile(r'(\+\d\d)-(\d\d\d)-(\d\d\d-\d\d\d\d)') # mo2 = phoneNumberRegex.search("My number is +44-415-582-...
5c4f7101e3794459a833f9005fd6a96207cf4103
fxy1018/Leetcode
/290_WordPattern.py
1,308
4.21875
4
''' Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str. Examples: pattern = "abba", str = "dog cat cat dog" should return true. pattern = "abba", str = "dog cat cat fish" should ...
125891df68a3d29963571abd8c2e2a6faa3de8b4
njpayne/pythagoras
/Archive/Geometry_Choice.py
3,540
4.5
4
# Write a program that allows the user to choose from one of 4 different # options and return the value of those functions. Specifically: # 1) Area of a circle # 2) Circumference of a circle # 3) Area of a rectangle # 4) Perimeter of a rectangle # Allow the user to make a choice prior to executing the function that # ...
961d6669b6c1e8372b978c5ae34d40af2dfdc0a6
VINSHOT75/PythonPractice
/python/palindrome.py
205
3.96875
4
x = int(input('enter a number')) num = x rev = 0 temp = 0 while x>0 : temp = int(x%10) rev = (rev*10) + temp x= int(x/10) if rev==num : print('palindrome') else: print('no palindrome')
b98fb8270e60a5238975d81d9f77321f641a3cce
Kevin-Lyy/mks66-line
/draw.py
1,196
4.0625
4
from display import * def draw_line( x0, y0, x1, y1, screen, color ): if x0 > x1: draw_line(x1,y1,x0,y0,screen, color) return x = x0 y = y0 A = y1 - y0 B = -1 *(x1 - x0) # Octant 1 if 0 <= A and A <= -B: d = B + 2 * A while x <= x1: plot(screen...
ce6f5df8895c415ab2217ef397da9f42d0bfaf2f
FB-18-19-PreAP-CS/math-helper-Egor-Mikhaylov
/math_helper_mikhaylove.py
8,952
4.40625
4
import math def main(): ''' The main component of Math Helper Allows user to select and use five different formulas related to math ''' #Helper for Math Class (5 Formulas) print("Welcome to Egor's Math Helper") print() print("Here is a list of all of the six formulas which are available in ...
0df77b197165bd25d42e8dd893eaf72e2b372dec
bopopescu/Python_Begining
/test.py
107
4.1875
4
for x in range(1, 6): if(x % 2 == 0): print(x, "is odd") else: print(x, "is even")
4cfff899488313d4c7f06f24f179546c3090e671
anishk07/PYTHON-HACKERRANK
/BASIC-DATA-TYPES/2_runners_up_score.py
663
4.0625
4
# @author: ANISHK YADAV """ Given the participants' score sheet for your University Sports Day, you are required to find the runner-up score. You are given scores. Store them in a list and find the score of the runner-up. Input Format: The first line contains n. The second line contains an array A[] of n integers ea...
2abb5aaeff5a1322ee25b7f45527896bd030afdf
LannibaleS/Python_fullstack
/day11/1.作业讲解.py
507
3.65625
4
# 2、写函数,接受n个数字,求这些参数数字的和 def sun_func(*args): sum = 0 for i in args: sum += i return sum print(sun_func(5,6,5,6,4)) # 3、读代码,写出a b c的值 a = 10 b = 20 def test5(a, b): print(a, b) # 20, 10 c = test5(b, a) print(c) # None 因为test5没有返回值,所以c为None # 4、3、读代码,写出a b c的值 a = 10 b = 20 def test5(a, b): ...
620d396822b43f5cd5a9c20d1f9370235f3275bd
zheedong/BaekJoon
/python/A.py
661
3.625
4
t = int(input()) for _ in range(t): x_list = [None] + list(map(int, input().split())) x_list[9] += x_list[6] x_list[6] = 0 desirable_num = '' for number in range(9, 0, -1): for i in range(x_list[number]): desirable_num += str(number) def get_reverse(num_list): if ...
7473a36a9c9a734a1ea0a6f529a62fe449779ab1
Baidaly/datacamp-samples
/4 - manipulating dataframes with pandas/Case Study - Olympic Games/2 - Using .pivot_table() to count medals by type.py
1,026
3.8125
4
''' Rather than ranking countries by total medals won and showing that list, you may want to see a bit more detail. You can use a pivot table to compute how many separate bronze, silver and gold medals each country won. That pivot table can then be used to repeat the previous computation to rank by total medals won. I...
ded04779b2715905e0dd2dc7d5e2ac38a9a034e2
beaubeaubeau/pong
/player.py
4,606
4.09375
4
import constants import pygame class Player(): """ A class used to represent a player. Each player is represented as a rectangular paddle. Attributes ---------- WIDTH: int Constant width of the paddle HEIGHT: int Constant height of the paddle SPEED: int Constant...
041bb6f9af2a5a4d21799969d18df9ea8a232085
kaamayao/AlgorithmsUN2021I
/Lab12/5_organizing_a_lottery/points_and_segments.py
1,354
3.8125
4
# Uses python3 import sys from functools import cmp_to_key def segment_cmp(a, b): if a['point']> b['point']: return 1 elif a['point']< b['point']: return -1 else: return 0 def countBefore(segments, point): count = 0 def fast_count_segments(starts, ends, points): starts.sor...
c2a8f433535db4402ce14be0bca1d88dae4e6a54
DanLesperance/Bioinformatics
/Python Work/BioComputations/TandRep.py
760
4.09375
4
#input #seq = 'AAAAAAAAAAAAAA' #seq = 'CACACACACACAC' seq = 'ATTCGATTCGATTCG' #seq = 'TTAGCTTAGC' def TandemRep(seq): HalfLength = len(seq)/2 answer = "There is not an integer number of tandem repeats" for i in range(0,HalfLength): #Do not want to divide by 0 (impossible) or by 1 (always == itself...
64de2f1272375c82f8bdfebad5d77ad233a95268
mlevesquedion/ctci
/16_25.py
816
3.703125
4
class LRUCache: """Naive solution, __setitem__ is O(size)""" def __init__(self, size): self.size = size self.cache = dict() self.time = 0 def __contains__(self, key): return key in self.cache def __setitem__(self, key, value): self.cache[key] = (value, self.tim...
26aa9d92667e8ae5c94f5249120a8e139da55fe6
daniel-reich/ubiquitous-fiesta
/n4KPv4eaLmkYeD6gq_7.py
125
3.609375
4
def face_interval(num): if type(num)!= list: return ":/" r = num[-1]-num[0] return (":)" if r in num else ":(" )
10772acbe04816588f2406b290d05500e876d317
mingweihe/leetcode
/_0367_Valid_Perfect_Square.py
496
3.625
4
class Solution(object): def isPerfectSquare(self, num): """ :type num: int :rtype: bool """ # Approach 2 l, r = 1, num while l < r: mid = l+(r-l)//2 if mid**2>num: r = mid - 1 elif mid**2<num: l = mid + 1 else: r...
ee34a19b72a0ebb11216f3afcc94e4da1464b1a5
CharlesFee/CS115-Code
/life_starter/life.py
3,485
3.921875
4
# # life.py - Game of Life lab # # Name:Charles Fee # Pledge:I pledge my honor that I have abided by the Stevens Honor System # import random import sys def createOneRow(width): """Returns one row of zeros of width "width"... You should use this in your createBoard(width, height) function.""" ...
a60ade9e6f6da64907a4cd461a4adf3c7390f7d9
reedhop24/python-labs
/x_primes/prime.py
280
4
4
import math def is_prime(x): if x == 2: return True elif x > 2 and x % 2 == 0: return False sqrt = math.floor(math.sqrt(x)) for i in range(3, 1 + sqrt, 2): if x % i == 0: return False return x > 1 print(is_prime(9))
8c289d4c48b021cf6273acdc2b65d35501519949
leminh2511/Homework
/Turtle_circles.py
117
3.65625
4
from turtle import * shape("turtle") pencolor("green") speed(-1) for i in range(100): circle(100,360) lt(25)
3dbc5ea681201bbe256c07f319cbafb758a90d9d
carmenwnyc/Sudoku
/sudoku.py
9,385
4
4
#!/usr/bin/env python #coding:utf-8 """ Author: Carmen Wu """ """ Each sudoku board is represented as a dictionary with string keys and int values. e.g. my_board['A1'] = 8 """ import copy import time import statistics from statistics import mean ROW = "ABCDEFGHI" COL = "123456789" def print_board(board): """Help...
2f277f0e26ae0b5ecf15257981f909325dcebb33
markaaron88/Lab13
/lab13_madlibs.py
2,527
4.03125
4
#Lab 13-Madlibs #Team 10 - M. Mariscal, C. Piwarski, W. Robleh #Step 1: Find a news article online #You only need between 100 and 200 words for a decent mad lib, so if you find #a really long story, take only part of it. #Step 2: Remove some words #Go through the article and turn it into strings in Python and rem...
d936febc4286b3e2169ca2e579f24d08c56be6b2
pau1tuck/nlp-python
/src/tokenizing/sentence_trainer.py
918
3.515625
4
from nltk.tokenize import PunktSentenceTokenizer # NLTK corpus method: from nltk.corpus import webtext text = webtext.raw('overheard.txt') # Direct method: with open('/usr/share/nltk_data/corpora/webtext/overheard.txt', encoding='ISO-8859-2') as f: text = f.read() # p.15 # The PunktSentenceTokenizer class uses an...
11e01ab2e84bd135b9c8f6f628936c6482507f62
liangxiaoxuan/Algorithm-training
/Leetcode/Python/easy/12_2_1_Valid Palindrome.py
414
4.3125
4
# Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. # # Note: For the purpose of this problem, we define empty string as valid palindrome. # # Example 1: # # Input: "A man, a plan, a canal: Panama" # Output: true def isPalindrome(s): """ :type s: str...
c2456412a51e3c9956e67a7428248bd19bb02337
1923851861/Python_Base
/day33/02 守护进程.py
1,513
3.515625
4
''' 1、守护进程 守护进程其实就是一个“子进程” 守护=》伴随 守护进程会伴随主进程的代码运行完毕后而死掉 2、为何用守护进程 关键字就两个: 进程: 当父进程需要将一个任务并发出去执行,需要将该任务放到一个子进程里 守护: 当该子进程内的代码在父进程代码运行完毕后就没有存在的意义了,就应该 将该子进程设置为守护进程,会在父进程代码结束后死掉 ''' # from multiprocessing import Process # import time,os # # def task(nam...
e369cbd38788278078698bf3cf21a48cacc76b3b
MavineRakiro/golclinics-dsa
/assignments/searching.py
2,824
4.03125
4
#ASSIGNMENT ONE """ Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. Example 1: Input: nums =...
4c1938005d40957baeb5b5c6e216d2850258612b
dpedu/advent2018
/9/a.py
1,646
4.21875
4
#!/usr/bin/env python3 def gameround(players, currentplr, field, curmarb, nextmarb): """ Simulate a round of the game. Clockwise is index++ counterckw is index-- :param players: list of players :param currentplr: index of the player who's turn we will simulate :param field: list of marble...
ea9641697361401dbb887a2065c442ea8ed44e9a
tharindupr/Algorithms
/CodeJam 2014/Qulify/C/mine2.py
8,499
3.53125
4
import math file = open("C-small-practice.in","r") outfile=open("outl.txt","w") t_case=file.readline() def last(board,R,C,M): #print("last") #print(empty) empty=(R*C)-M sqr=int(math.sqrt(empty)//1) for x in range(R,1,-1): remain=empty-sqr**2 #print(R,sqr,remain) #print(empty...
24234ccdb212d4d17afa70f9cf77b79b9f46ddbb
thenol/Leetcode
/ToDo/5390.185. Minimum Number of Frogs Croaking.py
2,763
4.0625
4
''' Given the string croakOfFrogs, which represents a combination of the string "croak" from different frogs, that is, multiple frogs can croak at the same time, so multiple “croak” are mixed. Return the minimum number of different frogs to finish all the croak in the given string. A valid "croak" means a frog is prin...
9a410eb4c48c4965beb01319d40cbee4f54265a8
julenka/euler
/063.py
495
4.0625
4
#!/usr/bin/env python __author__ = 'julenka' """ The 5-digit number, 16807=7**5, is also a fifth power. Similarly, the 9-digit number, 134217728=8**9, is a ninth power. How many n-digit positive integers exist which are also an nth power? """ def digits_in(n): return len(str(n)) nth_powers = set() for i in ran...
cd7b2e62797ff32b872f6c782280a1a3663b45ad
nathanlo99/dmoj_archive
/done/ccc97s1.py
338
3.515625
4
import itertools for _ in range(int(input())): a = int(input()) b = int(input()) c = int(input()) aa = [input() for i in range(a)] bb = [input() for i in range(b)] cc = [input() for i in range(c)] for a in aa: for b in bb: for c in cc: print(a, b, c, end=...
6ba571d1b5975faeeab9cbc9ee5fac5aee16aeb1
jonatan-SO/PilasColas
/Colas.py
1,335
3.734375
4
class colaEstatica: __tamCola = int(0) __listaCola = [] def __init__(self,tamCola): self.__tamCola = tamCola def Insertar(self,elemento): if self.Colallena(): return False else: self.__listaCola.append(elemento) return True def quitar(sel...
63562b251e665de170a86fef18829fc2d5cc931e
Darrenrodricks/IntermediatePythonNanodegree
/RepresentingData/buildBlock.py
606
4.09375
4
1 == 1 # => True 2 * 3 == 5 # => False 1 != 1 # => False 2 * 3 != 5 # => True 1 < 10 # True 2 >= 0 # True 1 < 2 < 3 # True. Computes 1 < 2 and 2 < 3 3 # => 3 (int) 3.0 # => 3.0 (float) 1 + 1 # => 2 (int) 1.0 + 1 # => 2.0 (float) 8 - 1 # => 7 (int) 10 * 2 # => 20 (int) 8 * 2.5 # => 20.0 (float) 5 /...
54e4d800b2ef318de12f2cf27a15446cd8b28dd3
mbromberek/Python_One_Liners
/ch05_regex/07_grouping.py
183
3.609375
4
import re s = 'helloworld' regex_1 = 'hello(world)' regex_2 = '(hello(world))' print(re.findall(regex_1, s)) # ['world'] print(re.findall(regex_2, s)) # [('helloworld', 'world')]
1ce0fca12c32b47a0e8d6e1ed30f1214beb4438f
Imyyy/ML_Prescribing
/ML_binary_setup_base_to_copy.py
3,482
3.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Feb 26 16:51:25 2020 @author: imyyounge """ # Set up import os import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import numpy as np os.chdir('/Users/imyyounge/Documents/4_Masters/4_Machine_learning/Nov_2019_Prescribing_Data/Cod...
e0fcc59c7e4f32b1af1bae2b5b11637d8c541e21
victor-da-costa/Aprendendo-Python
/Curso-Em-Video-Python/Mundo-2/EXs/EX047.py
244
3.96875
4
for num in range(1, 51): if num % 2 == 0: print(num, end=' ') print('FIM') # A segunda solução é melhor pois são feitos menos "for" exigindo menos do computador. for num in range(2, 51, 2): print(num, end=' ') print('FIM')
a4f8d5ffcf78b0bb501e33f4c54243c2b930b9c2
chenlei65368/algorithm004-05
/Week 1/id_525/LeetCode_283_525.py
848
3.515625
4
from typing import List class Solution: def moveZeroes(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. 解法一 """ j = 0 for i in range(len(nums)): if nums[i] != 0: nums[j] = nums[i] i...
331439d2ecfef38a90fc3eeb02ac9cf0b3a6a667
vinny0965/phyton
/1P/meuprojeto/Atividades 1VA/Nova Aula/Lista de Exercicios 1/Aula5/04.py
114
3.90625
4
x = input("Digite alguma coisa:") contador=0 for i in x: if i.islower(): contador+=1 print(contador)
43c513a6959fb149d0996969cbb4a18cda7b31a6
sharmishah/guvi
/code kata/swapevoddposition.py
117
3.578125
4
M=input() for V in range(len(M)): if V%2==0: print(M[V+1],end='') else: print(M[V-1],end='')
40bb8516ddf528535c025df22c0351ff6832f695
AhmedFahmy-cyber/py_examples
/table.py
112
3.640625
4
for i in range (1,13): for j in range (1,13): print('%d*%d=%d' %(i,j,i*j)) print('-----------')
e566d336acae486d0ae9a59ff787e14a14201f1e
Storiesbyharshit/Competetive-Coding
/GeeksforGeeks/Array/Rotate Arr.py
211
3.796875
4
def rotateArr(A,D,N): # reverse array from 0 to D A[0:D]=reversed(A[0:D]) # reverse array from D to N A[D:N]=reversed(A[D:N]) # reverse whole array A[0:N]=reversed(A[0:N])
b21adc8bb3b9b5e0d12fea49eb8d6cd02318dba1
renesugar/python-type-inferencer
/.svn/text-base/pytype.py.svn-base
4,266
4.09375
4
""" Type objects for python. The goal is to be as general and abstract as possible. Single type objects often describe many different types. For example, an InstanceType could be an int, a str, or any user-defined type. A FuncType could have an infinite number of type signatures. All types have a typestr, or type s...
29f38d83b281942e27f89b8eaba8ae9f61fb0451
nmaslov255/SICP-assignments
/Chapter 1/assignment_16.py
252
3.765625
4
def power_iter(x, n): if n % 2: return x * power_iter(x, n - 1) while n > 1: n = n / 2 x *= x return x print(power_iter(2, 32)) # 4294967296 print(power_iter(6, 9)) # 10077696 print(power_iter(8, 5)) # 32768
071565787ebae766223737a417c24a18f956a554
RobertNguyen125/Udemy-Python-Bootcamp
/6_list/1_accessList.py
317
3.515625
4
# colors = ['purple', 'teal', 'magenta'] # # for color in colors: # print(color) # # i = 0 # while i < len(colors): # print(f'{i} : {colors[i]}') # i+=1 sounds = ["super", "cali", "fragil", "istic", "expi", "ali", "docious"] results = '' for sound in sounds: results += sound.upper() print(results)
89983aaeb5020b8150db785a6d09d18c7362ed88
venkatsvpr/Problems_Solved
/LC_Largest_Substring_Between_Two_Equal_Characters.py
1,574
4.03125
4
""" 1624. Largest Substring Between Two Equal Characters Given a string s, return the length of the longest substring between two equal characters, excluding the two characters. If there is no such substring return -1. A substring is a contiguous sequence of characters within a string. Example 1: Input: s = "aa"...
1c51d806c455c557e42e84e7932f6e5e6bddeb98
hannahslevin/Programming-for-Data-Science-Data141
/Project_2.py
2,611
3.546875
4
import string from random import randint, choice, choices, sample, shuffle def password_specs(length = 14, min_spec = 0, min_num = 0, min_upper = 0): spec = randint(min_spec,length - min_num - min_upper) num = randint(min_num,length-spec-min_upper) upper = randint(min_upper,length - spec - num) lower =...
b7fee7d29b75faa817e9e4ba58bc7088307a3397
descifixer17/kaizend
/session-3/exercises/products_csv_parser.py
1,908
3.578125
4
# Kaizend 3: Python for Scripting - Exercises # # Requirements: # Name the exercise file products_csv_parser.py # Use argparse for passing the filename of the CSV input file # Remove all products that don’t have categories # Output a new CSV file that contains all products that have categories # Pr...
a7edf8e9c311098e08c728149491095c5814a147
EricaEmmm/CodePython
/LeetCode/树_104_二叉树的最大深度_递归orBFS.py
1,252
3.5625
4
''' 二叉树的最大深度 给定一个二叉树,找出其最大深度。 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。 说明: 叶子节点是指没有子节点的节点。 示例: 给定二叉树 [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 返回它的最大深度 3 。 ''' from tool import TreeNode class Solution(object): def maxDepth1(self, root): ''' 递归/DFS ''' if not root: ...
1297cb0702d5d70458d76d171a6a9e9e5bcf988b
aistein/playground
/leetcode/python3/coin_change.py
2,642
3.765625
4
#!/usr/local/bin/python3 import unittest from collections import deque # recursive solution def coinChange(coins, amount): memo = {} return coinChangeHelper(memo, coins, amount) def coinChangeHelper(memo, coins, amount): if amount == 0: memo[amount] = 0 return 0 curr_min = float('inf') ...
988c052f937ea00c9a0566ad2a7ff802f0646fe6
jtanadi/drawbotSketches
/_lib/CPrimitives.py
5,186
3.71875
4
""" This module is to be used in addition to DrawBot primitive shapes. IT IS DEPENDENT ON DB MODULE. It has shape objects that are drawn from a center point, not from the bottom left corner. Currently there are 3 supported primitive shapes: - CRect: Rectangle if both width & height are provided. Square object if onl...
6d154d702d9f0f5beea56f02e3182213d4ab1f5c
raghumina/Python_CloudxLab
/StringLoop.py
1,680
4.375
4
# counting the list # by using the loop ''' count = 0 print("count") for numbers in [2, 5, 6, 4, 3, 2, 4, 6]: print("numbers") count = count + 1 print(count, numbers) print("after ", count) # submission of the list # using loops ''' ''' sum = 0 for numbers in [3, 5, 6, 7, 85, 32, 5, 4, 2]: sum = sum + ...
ce17c9e2be3b3fa385e233781deaeb60373ef84c
AlanJYLi/leetcode_practice_python
/week_1/2020_05_23.py
1,940
3.59375
4
# 69. Sqrt(x) class Solution: def mySqrt(self, x: int) -> int: if x < 2: return x else: l, h = 1, x while l <= h: mid = (l+h) // 2 if mid**2 == x: return mid elif mid**2 > x: ...
321089b53e0cf6fa99f2c73328123445e37d6159
yveslox/Genesisras
/practice-code-orange/programme-python/factorial-recursion.py
151
4.125
4
#!/usr/bin/python def factorial(n): if(n==1): return 1 else: return n * factorial(n-1) print("Factorial of 6: ",factorial(6))
df65febd03398568aabbba2c69286d0327d96910
matcar1972/Python
/LeapYear.py
375
4.125
4
# -*- coding: utf-8 -*- """ Created on Wed Jul 7 18:16:45 2021 @author: cmartinez """ Spyder Editor def is_leap(year): if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0): return True else: return False year = int(input("Write a year : ")) if is_leap(year): print(f"{year} is a Lea...
b1cfc1f662739160bb1df9b48dac97f7acb1a3c4
Dominic2681998/python
/lab10-2.py
188
3.84375
4
n=int(input("Enter the number:")) try: if(n>90 and n<=100): print(n) else: raise ValueError('Abnormal Condition') except ValueError as v: print(v)
b4c23c57952b23c2d43664d6caa0c20ce3918e72
Smalley2001/Mini_Coding_Exercises
/calories.py
656
4.21875
4
# Running on a particular treadmill you burn 4.2 calories per minute. Write a program that uses a loop to display the number of calories burned after 10, 15, 20, 25, and 30 minutes. # Make a list, make a for loop, convert to calories burned, and print each result minutes= [10,15,20,25,30] for i in minutes: calories...
9d2146e23ecbc5c080657c09550e6534193ba636
CyanoFresh/KPI-Labs
/AI/lab1/xor2.py
781
3.5625
4
import numpy as np def f(x): return 1 / (1 + np.exp(-x)) def f_derivative(x): return x * (1 - x) def predict(x, w): return f(np.dot(x, w)) if __name__ == '__main__': x = np.array([ [0, 0], [0, 1], [1, 0], [1, 1] ]) y = np.array([[0, 1, 1, 0]]).T w = ...
6b8a99932aea5fcac40fddcae0c9bd86f3df88fe
no701ubyd10/Madlibs-Project
/madlib.py
273
3.8125
4
# random import random # open madlibtext file f = open('madlibtext.txt','r') # read file madlibtxt = f.readlines() madlib = random.choice(madlibtxt) noun = input('Enter noun: ') # replace word ioi! in txt to noun madlib = madlib.replace('ioi!',noun) print(madlib)
f14744a63828cc6f8ab04b0db0d16d166b65a649
yusufyilmazfr/tasarim-desenleri-turkce-kaynak
/builder/python/lesson_builder.py
555
3.5625
4
from abc import ABC, abstractmethod from lesson import Lesson class LessonBuilder(ABC): """ UML diyagramındaki Product'a denk gelen Lesson sınıfıa ait nesnenin oluşturulması için soyut arayüz sağlar. Yapılması gereken adımlar içerisinde tanımlıdır. """ lesson: Lesson @abstractmethod def g...
af0991ddef2252faa0046645b1f46a4123b03c91
praveen509/Python
/listcomprehension.py
626
4.09375
4
#Ex1 old method fruits = ["apple", "banana", "cherry", "kiwi", "mango"] newlist = [] for x in fruits: if "a" in x: newlist.append(x) print(newlist) #Ex2 fruits = ["apple", "banana", "cherry", "kiwi", "mango"] newlist = [x for x in fruits if "a" in x] print(newlist) #Ex3 #Only accept items that are not "appl...
7e835209b881eb0a293ca91df0e90416f5b41ff8
Nigelmnz/epi-py
/src/ch04_ptypes/p04_07.py
1,112
4.28125
4
""" Problem: Given a float X, and a positive integer Y, compute X^Y. """ def power_brute(x: float, y: int) -> float: """ Solution A: Just mutiply X, Y times. Runs in O(n), where n is the size of y. """ result = 1 for n in range(y): result *= x return result def power_rec...
4671ea5e54a4600a1b62978d5cb13a626a7d842c
marcoportela/python
/exercicio2_20.py
910
3.984375
4
# -*- coding: utf-8 -*- """ Created on Sat Oct 25 15:23:32 2014 2.20 Faça um Programa que peça uma data no formato dd/mm/aaaa e determine se a mesma é uma data válida. @author: Marco Portela """ data = raw_input("Digite uma data no formato dd/mm/aaaa: ") #Verifica o formato da string pelo tamanho if len(data) < 10: ...
90b3c3471b04aab7435ed2a8a4fbf25de5eb755f
durgaprasad23/python
/list.py
1,116
4.28125
4
#**** lISTS **** players = ["Kobe","Lebron","Kyrie","Jordan","Harden"] #List Mutable - we can change the lists numbers = [10,40,90,23,16,13,50] jerseyno = (10,13,40,27,18) #Tuple immutable - we can change this print(players) print(numbers) print(jerseyno) print(players[::2]) # List with 1 skip print(players...
f758a99c90079eb41efd931c5e3c3b2db9e651d2
sisi0205/leetcode
/dataprocess.py
3,916
3.59375
4
#!/opt/local/bin/python import numpy as np import os class Product(object): """"The struct for product, Numcst: the number of customers who rated the product listcst:List of customer """ def __init__(self, id): self.asin=0 self.id=id self.Numcst=0 self.listcst=set()...
6e2b5bd32ceb6173317bc8ba4ca3d48178fefffa
ankitshu/Python
/PythonClass_demo.py
2,876
3.84375
4
# class ClassExmaple: # """A simple example class""" # # def __init__(self): # print('INIT called') # self.i=10 # # def f(self): # self.i=11 # return 'hello world' # # obj=ClassExmaple() # # print(obj.i) # s=obj.f() # # print(s) # # print(obj.i) # #obj.f() # #...
3c24964b00379bb8b59492f317679dbfc6286c7b
SudhamathiAthi/Codekata
/table.py
102
3.84375
4
num=int(input("Enter the table no:")) for i in range(1,20): print (+num,'*',+i,'=',num*i)
ff32f49b434ac86513d512554b4e9a31b64eff03
VitaliiStorozh/Python_Core
/HW11/11.2.py
372
3.765625
4
class Employee: def __init__(self, firs_name, last_name): self.firs_name = firs_name self.last_name = last_name self.fullname = firs_name + ' ' + last_name self.email = firs_name.lower() + '.' + last_name.lower() + '@company.com' def __repr__(self): return "Your fullname ...
78bce85f133e3502bd707045244e24865d323062
mateuscv/competitive-programming-exercises
/UVa/10114.py
1,240
3.515625
4
loan = input().split() loan_duration = int(loan[0]) while loan_duration >= 0: down_pay = float(loan[1]) loan_amount = float(loan[2]) parcela = loan_amount/float(loan_duration) number_of_records = int(loan[3]) initial_value = loan_amount + down_pay deprecated_value = initial_value dicio...
d190cae4b30a7781be7b1331e14486f6061abb3b
chymoltaji/Algorithms
/ReplaceSpaces.py
196
3.53125
4
def replace_spaces(s): return "%20".join(s.split(" ")) s=" This is not a very long sentences, but it have spaces! " print(replace_spaces(s)) # This works as well print(s.replace(" ", "%20"))
b0b59d661d8328fa281ba93774210d734c7a36cb
pl6c2/Python-ML-DL
/ICP4/NB.py
1,650
3.78125
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt # importing csv datafile using pandas train = pd.read_csv('glass.csv') train.describe() # to see all column names print(train.keys()) # taking data as a dataframe train1 = pd.DataFrame(train) # taking feature data except(dropping) target column...
42dcb40b671985382ee55cb1833ca4c0bda1c1f2
dthangavelu/Python
/Hospital/Patients.py
451
3.765625
4
class Patient(object): Id = 0 def __init__(self, name, allergies): Patient.Id += 1 self.Id = Patient.Id self.name = name self.allergies = allergies self.bedNum = "none" def __str__(self): return "\nId: {}\nName: {}\nAllergies: {}\nBedNumber: {}\n".format(self.Id, self.name, self.allergies, self.bedNum) ...
7ef9356d0d6e46a89b164790bf69298ddff5fabc
davidbusch1/pythonExercises
/ex14.py
624
4.09375
4
#Faça um programa que leia as repostas de três questões de #múltipla escolha (a, b, c, d). Em seguida, leia o gabarito #dessas questões, ou seja, as respostas corretas. Depois, #compare as respostas dadas com as do gabarito e indique quantas respostas estão corretas gabarito = ['a', 'b', 'c'] r1,r2,r3 = input("...
23f034fc3959c3119f08e60de3e8dc5295a6d7ad
DDR7707/Final-450-with-Python
/Arrays/19.Merge Intervals.py
392
3.78125
4
def merging_intervals(arr): arr.sort(key = lambda x : x[0]) final = [arr[0]] print(arr) for a,b in arr[1:]: last = final[-1] if a <= last[1]: final[-1][1] = max(last[1] , b) else: final.append([a,b]) print(final) return final ...
952f6a57d40655fef7ce1b416e84eefec529c78f
SinbadFreedom/Doc
/educate/python/second_degree/6.3.2_2.py
1,083
3.8125
4
lt = ["1010", "10.10", "Python"] print(lt) ls = ["1010", [1000, "1000"]] lt = lt + ls print(lt) lt = ["1010", "10.10", "Python"] lt.insert(1, 1000) print(lt) lt.clear() print(lt) lt = ["1010", "10.10", "Python"] print(lt.pop(2)) print(lt) lt = ["1010", "10.10", "Python"] lt.remove("10.10") print(lt) lt = ["1010"...
90f195a85658ef24c7f8211fe1089302106267f9
v1siuol/2sComplement
/2s_complement_calculator.py
1,541
4.125
4
""" 计算补数 写得好复杂 looking for a simpler way to approach Introduction: Compute 2's complement __author__ = v1siuol __date__ = 2017.2.22 """ def toggle(st): return "1" if st == "0" else "0" def Complement2s(): """ This is a calculator[V1.0] for 2's complement Enter the number in binary forms (e.g. 010101...
7cd69339acf46cc4b3092d8b2a597fa90d19d9f8
BassP97/CTCI
/Med/longestIncreasingSubseq.py
888
3.875
4
""" Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Input: [10,9,2,5,3,7,101,18] Output: 4 Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4. """ from bisect import bisect_left def lengthOfLISDP(nums): if not nums: ...
0cd653e80f4015317212d695939efbfd55d07f29
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/space-age/ed77aa5b55734ff7a5331cd840771a11.py
873
3.5
4
seconds_in_earth_orbit = 24 * 3600 * 365.25 class SpaceAge(object): def __init__(self, seconds): self.seconds = seconds self.earth_years = seconds / seconds_in_earth_orbit def on_earth (self): return round(self.earth_years, 2) def on_jupiter (self): return r...
14a29f6bc053e78806f75c3f5820b839cefb1c75
piyush546/Machine-Learning-Bootcamp
/Machine Learning programs/Supervised ML programs/Classification SML Programs/human_activity/Human_activity.py
5,601
3.71875
4
# -*- coding: utf-8 -*- """ In an experiment with a group of 30 volunteers within an age bracket of 19 to 48 years, each person performed six activities (WALKING, WALKING UPSTAIRS, WALKING DOWNSTAIRS, SITTING, STANDING, LAYING) wearing a smartphone (Samsung Galaxy S II) on the waist. The experiments have been video-r...
c7465bbfc8b20400945ba63d7d99819e1fbb650b
jamesfallon99/CA116
/lab_week05/first-capital.py
144
3.78125
4
#!/usr/bin/env python s = raw_input() i = 0 while i < len(s) and s[i] == " ": i = i + 1 if i < len(s): print s[i] else: print "-1"
1ddb1fc967da21dae866c436bd365001be1825cc
VinodMeganathan/Guvi
/Convert_Roman_Number_To_Integer.py
211
3.859375
4
''' PROGRAM TO CONVERT ROMAN NUMBER TO INTEGER ''' a=input() b=["","I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII","XIII","XIV","XV","XVI","XVII","XVIII","XIX","XX"] if a in b: print(b.index(a))
54cdf2d9a4a40d3c3aee12991ea43e9a7370fcc2
maxwell-martin/gaddis-python2018-projects
/property_tax/property_tax.py
331
3.9375
4
ASSESSMENT_VALUE_RATE = 0.60 TAX_RATE = 0.0072 actual_value = float(input("Enter actual value of property: ")) assessment_value = actual_value * ASSESSMENT_VALUE_RATE print("Assessment value: $", format(assessment_value, ",.2f"), sep="") tax = assessment_value * TAX_RATE print("Property tax: $", format(tax, ",.2f"...
99326a2582d319cb24594dd259d61c45633a9859
cz0634/pythonStudy
/regular/test2.py
339
3.5625
4
import re print(re.findall(r'[a-z]', "cz cool")) print(re.findall(r'[^a-z]', "cz cool")) #除了a-z其他都匹配 s = "<html><title>cz cool</title></html>" print(re.search(r'<.+>', s)) #贪婪匹配 print(re.search(r'<title>.+</title>', s)) #贪婪匹配 #print() result = re.search(r'<.+?>', s) #非贪婪匹配 print(result.group())