blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
271f09d6dea8257845188ff3b7ee157e6016a4d6
netgroup/ABEbox
/old/Encryptor.py
15,472
3.53125
4
""" This file contains all functions used during encryption process. To perform this procedure, firstly, an hybrid encryption is applied to the plaintext. Then the resulting ciphertext needs to be transformed through an All-Or-Nothing transformation. """ from old.crypto.Const import AONT_DEFAULT_ENCODING, AONT_DEFAULT...
8956e4d15be3616e2fe8040a1938a8ef0c97e71d
chrisliatas/py4e_code
/py4e_ex_02_03.py
99
3.828125
4
hours = input("Enter Hours: ") rate = input("Enter Rate: ") print("Pay:",float(hours)*float(rate))
853061867e2044fbbdee391959f65c38a2ba514b
xili-h/PG
/Python/ch1/dog_age.py
191
4.03125
4
dog_name = input("What is youe dog's name? ") dog_age = int(input("Whai is your dog's age? ")) human_age = dog_age * 7 print('Your dog',dog_name,'is', human_age,'years old0 in human years ')
03fbee68aaee0b13ec392c4d14e14529b7622f98
mehedees/FindPair
/findPair.py
1,158
3.546875
4
class PairFinder: def __init__(self, inputArray, target): self.inputArray = inputArray self.target = target self.items = self.inputArray[1:-1] # stripping square brackets from both end self.items = self.items.split(', ') # getting a string list of the numbers self.items = ...
04ac14ba888c85291eeb34400ee54357a175d205
gabriellaec/desoft-analise-exercicios
/backup/user_211/ch45_2020_04_10_23_16_20_290482.py
109
3.890625
4
x=0 lista=[] i=0 while x>=0: x=int(input("digita um número") lista.append(x) i+=1 print(l[::-1])
e7722ea887a9428086f1fd2c4b0eb1e7ec9a30b7
Global19-atlassian-net/the_pool
/das_schwimmbad.py
1,686
3.765625
4
#das schwimmbad class Liegewiese(object): loc_index = 0 def enter(self): if first_visit: print "Du befindest die auf der Liegewiese des Schwimmbads." else: print "Du warst schon eimal hier." class GertrudesBaum(object): loc_index = 1 loc_name = 'Gertrude\'s Baum...
5cd014e5006782074cfcbda6f9cb22be3d3b2d2b
charliealpha094/Python_Crash_Course_2nd_edition
/Chapter_9/try_9.3.py
1,538
4.25
4
#Done by Carlos Amaral in 04/07/2020 """ Make a class called User . Create two attributes called first_name and last_name , and then create several other attributes that are typically stored in a user profile. Make a method called describe_user() that prints a summary of the user’s information. Make another method cal...
df27d1122dab3d34ae15986b0c4d176feb5ae196
acrual/repotron
/Unidad3_10/src/actividadUF3_10/tresenraya/Partida.py
3,009
3.671875
4
from Tablero import Tablero from random import randint class Partida(object): def __init__(self): self.tablero = Tablero() num = randint(1,2) if num == 1: self.turno = "jugador" else: self.turno = "cpu" def jugar(self): hayGanador = False ...
d21139320f76081bb802016e1ee69e4a589fe577
DB-DeKoN/DeKoN
/06-list.py
814
4.15625
4
lenguajes = ['python','kotlin','java'] print (lenguajes) #los arrays (lists) comienzan en la posicion 0 print (lenguajes[0]) lenguajes.sort() # esta funcion de lista ordena alfabeticamente print(lenguajes) #acceder a un elemento dentro de un texto aprendiendo = f'Estoy aprendiendo {lenguajes[2]}' print(...
0b0cf7c3179553f93b9e5091959535bfc82ff64f
themockingjester/leetcode-python-
/257. Binary Tree Paths.py
1,102
3.84375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def check(self,root,s): if root: if root.left==None and root.right==None: ...
3cfa99e61337350c3acdc5db7fc58fdaec183452
wangerzi/bmtrip-technology-sharing
/2019-11 Python基础分享/code/hanoi.py
453
4
4
def hanoi(n, A, B, C): """表示将n个碟子,从A借助B移动到C""" if n == 1: # A 通过 B 移动到 C,如果只有一个盘子, print("Move %s => %s"%(A, C)) else: hanoi(n-1, A, C, B) # 将 A 上 N-1 个盘子,从 A 借助 C 移动到 B print("Move %s => %s"%(A, C)) # 将 A 上最后一个盘子,直接移动到 C hanoi(n-1, B, A, C) # 将 B 上 N-1 个盘子,从 B 借助 A 移动到 C hanoi(64, "A塔", "B塔", "C塔")
ba3a175344987631912e353b232b0969f1b0bc41
mfkiwl/gnssIR_python
/ymd.py
500
3.734375
4
# -*- coding: utf-8 -*- """ converts ymd to doy kristine larson Updated: April 3, 2019 """ import gps as g import argparse parser = argparse.ArgumentParser() parser.add_argument("year", help="year ", type=int) parser.add_argument("month", help="month ", type=int) parser.add_argument("day", help="day ", type=int) ar...
ff42ab6be1c6ed147ae9aacf5a803ff161e0fdb4
gracomot/Basic-Python-For-College-Students
/Lectures/Lesson 5/Python Libary Functions/circle.py
432
4.46875
4
# A program to find the circumference and area of a circle import math def main(): radius = float(input("Enter the radius of the circle: ")) circumference = 2 * math.pi * radius area = math.pi*radius**2 print("The circumference of a circle with radius",radius, "is",format(circumference,'.2f')...
481af5c8b61daa9e65e9ba48858ddfe074ce15c2
rxue07/TestPython
/test/three.py
288
4.0625
4
''' 今天习题: 1 字符串: a = 'abcd' 用2个方法取出字母d 2: a = 'jay' b = 'python' 用字符串拼接的方法输出: my name is jay,i love python. ''' a='abcd' print(a[3]) print(a[-1]) a='jay' b='python' print(('%s'+ a +'%s'+ b)%('my name is ',',i love '))
826e5e6fe660fba3cb33aa6f6e2776ae03423b9c
devak23/python
/python_workbook/test/ch01/test_summation.py
913
3.640625
4
import unittest from python_workbook.ch01.p07_summation import Summation class TestSummation(unittest.TestCase): def setUp(self): self.summation_instance = Summation() def test_summation_with_positive_number_gives_correct_result(self): self.assertEqual(231, self.summation_instance.summation(...
458c1dc8153440d4a148f7a06def04b274fd87fe
danTaler/Python_examples
/regex.py
2,944
4.1875
4
import re text = "This is a good day" #search looks for some pattern and returns BOOLEAN if re.search("good",text): print("found") else: print("Not found") #the findall() and split() functions will parse the string for us and return chunks: text = "Amy works diligently. Amy gets good grades. Our student Amy ...
3214d258b3b6dd426d622a4ca8b76da43a8a9755
vairus666/lesson9
/fizzbuzz.py
367
4
4
def Fizz(a = 0, b = 0): for number in range(a, b): # if number % 3 == 0 and number % 5 == 0: # print('FizzBuzz') if number % 3 == 0: print('Fizz') # elif number % 5 == 0: # print('Buzz') else: print(number) a = int.inp...
a34d6cdebef1ec6fb8ac8edaf8f102babddb6707
ivan-ops/progAvanzada
/triangulo_dos.py
487
3.515625
4
class Triangulo: def __init__ (self,angulo1,angulo2,angulo3): self.angulo1 = angulo1 self.angulo2 = angulo2 self.angulo3 = angulo3 def checar_angulos(self): suma = self.angulo1+self.angulo2+self.angulo3 if suma == 180: print('True') else: ...
a29667186ab9008018c7e2d8ee93e3f7280c2699
JeffJetton/tia-counter
/tia_counter_demo.py
612
3.578125
4
from tia_counter import * # Create a list-based counter object tia1 = TiaCounterV1() # Create a bit-based counter object tia2 = TiaCounterV2() # Cycle through every period of each and compare states print('\n i List Counter Bit Counter Match?') print('-- ------------ ----------- ------') for i i...
be5632bc7dfac82949bc6876a1d1d836afe3c485
Languomao/PythonProject
/python_learn_01/demo_01.py
475
3.8125
4
from random import randint print("开始游戏,你只有三次机会。。。") i = 0 num = randint(1, 10) while i < 3: input_num = input("随机输入一个数字:") guess = int(input_num) if guess == num: print("恭喜你猜对了!") break else: if guess > num: print("大了。。。") i += 1 if guess < num: ...
c76ba1e8c5f63d665dd062bc018fcc5251baa492
DAGG3R09/coriolis_training
/assignments/Q17_panlindrome_recognizer.py
515
4.125
4
from string import ascii_lowercase lowercase = set(ascii_lowercase) def palindrome_recognizer(string): string = string.lower() string = list(filter(lambda x: x in lowercase, string)) if(string == string[::-1]): return True else: return False if __name__ == "__main__": s1 = "Go ...
6e41e2eff03e996ded0dd0e863880660d085a9e2
irinacastillo/repo-team-tel
/bot login.py
662
3.8125
4
login = str(input("ingrese su ID: ")) list(login) if not login.isnumeric(): print ('esta mtricula: ', login, 'es invalida') elif len(list(login)) == 8: print('la matricula', login, 'es valida') else: print ('su matricula', login, 'es invalida') while login == True: if login: continu...
607da25476a47a13a467a743b75d89ae1d28dfe4
the-nans/py2-repo_gb
/lesson1/lesson1_task3.py
1,411
3.96875
4
""" Написать программу, которая генерирует в указанных пользователем границах: a. случайное целое число, b. случайное вещественное число, c. случайный символ. Для каждого из трех случаев пользователь задает свои границы диапазона. Например, если надо получить случайный символ от 'a' до 'f', то вводятся эти символы. Про...
5aa2906f698b77928c156aa8577c2eee732e629d
arokasprz100/Python-exercises
/banks_task/task.py
8,903
4.1875
4
import json def get_valid_option_from_user(lower_bound, upper_bound): while True: value = input("Please input proper option: ") try: value = int (value) if value < lower_bound or value > upper_bound: continue else: break except ValueError: print ("You should enter integer.\n") retur...
04121b971ea9afe06da156dbaf72925d06e04960
d-ignatovich/Binary-search
/main.py
929
3.71875
4
import timeit # The function determines the index of the first occurrence of the specified element. def ind_rec(numbers, x): low = 0 high = len(numbers) - 1 while low < high: m = (low + high) // 2 if x > numbers[m]: low = m + 1 else: high = m if numbers[...
b792f2d676652222eaf549ca8143d596860efca3
mohits1005/DSAlgo
/maths2/maxgcd-delete-one.py
2,053
3.5
4
''' Delete one Problem Description Given an integer array A of size N. You have to delete one element such that the GCD(Greatest common divisor) of the remaining array is maximum. Find the maximum value of GCD. Problem Constraints 2 <= N <= 105 1 <= A[i] <= 109 Input Format First argument is an integer array A....
4f2ca22001f373ee211bbcaae5227b4d620d434a
Hugo-Oliveira-RD11/aprendendo-PYTHON-iniciante
/download-deveres/para-execicios-curso-em-video/exe037.py
560
4.1875
4
numero = int(input('digite um numero inteiro :')) print('''escolhar um numero para a converçao [ 1 ] BINARIO [ 2 ] OCTAL [ 3 ] HEXADECIMAL''') escolha = int(input('digite um dos numeros dentro das opções :')) if escolha == 1: print('A BINARIA do numero {} e {}'.format(numero, bin(numero)[2:])) elif escolha == 2: ...
8cb6d3090f386cb7a271bdd6fc77890c99df8bb3
jamesgrimmett/geolocation_solver
/geolocation/utils/conversion.py
3,555
3.703125
4
""" Utils for converting coordinates / units. """ import numpy as np from . import earth_model, error_handling def geographic2cartesian(lat, lon, h = None, lat_is_geocentric = True): """ Convert geographic coordinates to geocentric cartesian coordinates. Args: lat: Latitude in degrees (neg. south...
9c8894f6fef436d48eb2e67fa235c41eff295b09
OmkarRatnaparkhi/Basic_Python_Programs
/Problems_on_numbers/Q9_Display_First_Number_In_Second_Number_Times/Module.py
339
3.859375
4
#Defination of Display funtion #Function Name : Display #Description: It is use to display first number in second number times #Date : 08 Feb 2021 #Author name : OMKAR NARENDRA RATNAPARKHI def Display(no,frequency): if (frequency < 0): frequency = -frequency for iCnt in range (0,fr...
57de86fa5f63935fc26b5126c10c25f7b5936a6c
RWEngelbrecht/Learning_Python
/random_tests/whtShldWtch.py
750
3.515625
4
# What Should I Watch import random # def make_choice(possibilities): # secure_random = random.SystemRandom() # print(secure_random.choice(secure_random.choice(possibilities))) def make_choices(possibilities, amount): secure_random = random.SystemRandom() option = possibilities[secure_random.randint...
8956ad6540a92fea4ce4e02b5347dee82ac729c2
furkanbogaci/gaih-students-repo-example
/Homeworks/HW1.py
207
4.03125
4
import numpy as np matrix = [[],[],[]] for i in range(0,3): for j in range(0,3): for k in np.random.randint(0,10,1): matrix[i].append(k) for i in range(3): print(matrix[i])
cb8caa87be5b0dcdd3ad94a0d55fb434ea7c3fc0
JJHYE0N/Bitcoin-Supply-Calculator
/btcsupply.py
556
3.6875
4
#!/usr/bin/env python # -*- coding: utf8 -*- def btcSupplyAtBlock(b): if b >= 33 * 210000: return 20999999.9769 else: reward = 50e8 supply = 0 y = 210000 # reward changes all y blocks while b > y - 1: supply = supply + y * reward reward = int(re...
9f70df178dfbe74702e47c2c0725a6ac74674080
aaryanredkar/prog4everybody
/week 8/8-2.py
424
3.578125
4
fname = raw_input("Enter file name: ") fh = open(fname) dic = dict() for line in fh: if line.startswith('From'): t=line.split() email = t[1] if email not in dic: dic[email] = 1 else: dic[email] +=1 bigcount = None bigemail = None for email,count in dic.items(): if bigcount i...
f93143cd1fe85b15735af4769297eef153316abf
KuMuAB/Python_Flask
/列操作.py
583
3.546875
4
from numpy import column_stack import pandas as pd import numpy as np page_001 = pd.read_excel('Students_27.xlsx',sheet_name='Page_001',) page_002 = pd.read_excel('Students_27.xlsx',sheet_name='Page_002',) students= pd.concat([page_001,page_002]).reset_index(drop=True) # 追加一列 students['Age'] = 30 # 删除列 ...
fa5ed5552e7c46e15d0ff9050684d4939c564715
sage-kanishq/PythonFiles
/Challenges/occurence.py
124
3.515625
4
import itertools as it string = input() for key, grp in it.groupby(string): print(f'({len(list(grp))},{key})',end = ' ')
021e74efc0b738e86709e0e7a8543bfa80e50d0d
PrLayton/SeriousFractal
/PartDesign/Scripts/FilletArc.py
2,687
3.5
4
#! python # -*- coding: utf-8 -*- # (c) 2010 Werner Mayer LGPL __author__ = "Werner Mayer <wmayer[at]users.sourceforge.net>" # Formulas: # M2 = P + b*r2 + t*u # S1 = (r2*M1 + r1*M2)/(r1+r2) # S2 = M2-b*r2 import math # 3d vector class class Vector: def __init__(self,x,y,z): self.x=x self.y=y self.z=z def ad...
e4c3b3026248943e317309a460e6cdea5611d508
742darek/Programming-for-computation
/example_symbolic.py
374
3.640625
4
from sympy import * x = Symbol('x') y = Symbol('y') print (2*x + 3*x - y) # Algebraic computation print (diff(x**2, x)) # Differentiates x**2 wrt. x print (integrate(cos(x), x)) # Integrates cos(x) wrt. x print (simplify((x**2 + x**3)/x**2)) # Simplifies expression print (limit(sin(x)/x, x, 0)) # Finds limit of sin(x)/...
50f87542bda61b46ee81352ae664d4130f52f30f
gabriel-valenga/CursoEmVideoPython
/ex106.py
1,434
4
4
def notas(medias, sit=False): """ Função que recebe as médias de uma turma e retorna uma análise sobre esses dados. :param medias: um ou mais valores do tipo Float :param sit: parâmetro opcional, se for True exibirá também a situação da turma :return: tipo dict, retorna um dicionário no formato: {'t...
4d1bb4a35c46cacb394dc7ad833c3184bc6c63cc
sraaphorst/daily-coding-problem
/dcp_py/day121/day121.py
1,503
4.0625
4
#!/usr/bin/python3 def is_k_palindrome_rec(str1: str, str2: str, m: int, n: int): """" Determine if a string is a k-palindrome: A k-palindrome transforms into a palindrom by removing at most k ccharacters from it. To avoid exponential time, we use dynamic programming. """ # Create a table to ...
9840c1deb0db0c13263ed1205d2e52df96ae6e42
faizanzafar40/Intro-to-Programming-in-Python
/5. Full Exercises/e7_extract_numbers.py
407
4.125
4
""" Problem ------- Write a function that takes a number as input and return all the individual numbers in it as a list For example: if the input is 18382109, the output should be [1, 8, 2, 8, 2, 1, 0, 9] """ def extract_numbers(number): n=list(number) l=[] for i in n: a=int(i) l.append(a)...
fe7dff5f364c1f092fb46df972a093d93e29e7ad
ArisbethAg/Laboratorio_A01274803
/padding.py
590
3.984375
4
import numpy as np #matriz para poder probar el codigo mat1 = np.array([[1,2],[3,4]]) #funcion para agregar padding, recibe la matriz y la dimension del padding que se desea agregar def padding (mat1, pad): row, col = mat1.shape row2 = 0 col2 = 0 #definen las dimensiones de la matriz con el padding row2 = ro...
12e5a01e6ee45aacfff50ba5c727fa5e24d39376
stanlee321/javascript-curso
/clase 2/main.py
159
3.59375
4
# # Funciones en python def calc_vol_cilinder(r, h): V = 3.14159654 * (r ** 2) * (h) return V volumen = calc_vol_cilinder(200, 800) print(volumen)
671a27c1ba58ddf287e9f47b3007f4137a044dab
JulianYG/practice
/fibonnacci_string.py
1,440
4.09375
4
def find_char(s0, s1, n, k): """ Given two base strings s0, s1, find the kth character of the nth fibonnacci string constructed by the two strings. E.g: s0 = "aaa", s1 = "bcdef" n = 5, k = 12 aaa, bcdef, aaabcdef, bcdefaaabcdef, aaabcdefbcdefaaabcdef The 12th character of the 5th string is 'e'. """ if n == ...
36e0dd2223322c83cd91143bc8709d9db67b20f9
LeoKnox/py_essential_training
/hello2.py
262
3.8125
4
print ('words, yada yada yada'.upper()) print ('words, yada yada yada'.swapcase()) class MyString(str): def __str__(self): return self[::-1] s = 'flea fly flo. {}' t = MyString('the fellowship of the ring') print (s.format(8*8)) print (t)
361f3e6b0d2d172114ccca9068a301bbe29ab10a
royels/BeyondHelloWorld
/pythonsnippets/FindPi.py
465
3.5625
4
from sympy import * def FindPi(): limit = int(raw_input("To how many demical places do you want to calculate pi? (can only go up to 200,000) ")) if limit > 200000: limit = 200000 print pi.evalf(limit) piFill = 0 for num in range(0, limit): piFill += 16.0**-num * (4.0 / (8 * num + ...
7b49395389c950ee2547a22205166f27388e2ded
UWPCE-PythonCert-ClassRepos/SP_Online_PY210
/students/travis_nelson/lesson06/cat_dog.py
173
3.96875
4
#! # Return True if the string "cat" and "dog" appear # the same number of times in the given string. def cat_dog(str): return (str.count('cat') == str.count('dog'))
3c0eccf0a3b2ed72e238a276df870400cb2fa04b
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_201/2445.py
2,473
3.578125
4
def main(input): file = open(input) txt = file.read().split() file.close() file = open("result.txt", 'w') i = 0 j = 1 while i < int(txt[0])*2: spaces = int(txt[i+1]) population = int(txt[i+2]) #print spaces, population stalls = [1] ...
f15e54b2ce69ff307ff4def68c7e280543f0f678
w00tzenheimer/pythonformatter
/tests/test_continue/input.py
137
3.703125
4
a = 0 b = 0 while a > 10: if a > b + 10: break elif b > 100: continue a = a + 1 else: b = 100
d18494d6550c762c0c627c64b69a9cf1af168fa6
shanJoy/python_work
/09-类/9_test2.py
4,912
3.921875
4
__Author__ = "noduez" # 9-6冰淇淋小店 class Restaurant(): def __init__(self, name, cuisine_type): self.name = name self.cuisine_type = cuisine_type self.number_served = 0 def describe_restaurant(self): print(self.name.title()+' ' +self.cuisine_type) def open_restaurant(self): ...
2569e495f5b8ab05096d524fab7795bc50b12947
sarat21/Projects-in-Python
/Project2/HW6_sarat.py
8,948
4.3125
4
# import the functions used from their modules # this does NOT import the entire module but only specific functions! However, # it imports them directly into the current name space so you don't have to # call them with their module name in front, e.g. isdir() instead of os.path.isdir() # if you want to use ...
5898494cb1ed8c81b8a955fec3d2e44a674f070b
ThomasLEBRET/programmation_etudes-sup
/BTS-SIO/algorithme/1ère année/TP6-Matrices/exercice1.py
314
3.59375
4
def creerMatrice(n,p): mat = [] for i in range(0,n): mat.append([]) for j in range(0,p): mat[i].append(0) return mat def creerMatriceDeux(n,p): return [[0 for j in range (n)]for i in range(p)] mat = creerMatrice(3,3) mat2 = creerMatriceDeux(3,3) print(mat) print(mat2)
df5add8b164f8cb92e133b49a27cdbe8b3cfddd2
mukosh123/Day1_Exercises
/fizz.py
194
3.71875
4
def fizz_buzz(no): if no % 3 == 0: if no % 5 == 0: return "FizzBuzz" return "Fizz" elif no % 5 == 0: return "Buzz" else: return no
e3e39d38e961bfd599dfa1e4b52b70c3ecd706a4
RuzimovJavlonbek/qudrat-abduraximovning-kitobidagi-masalalarni-pythonda-ishlanishi
/if30/if_10.py
236
3.671875
4
a = int(input("A butun Sonni kiriting: A = ")) b = int(input("B butun Sonni kiriting: B = ")) if a != b: c = a+b a = c b = c print("A = ", a , "B = ", b) elif a==b: a = 0 b = 0 print("A = ", a, "B = ", b) input()
abe2952778b63ef362a8e1773cbac7545df8bf35
pkulkar/Leetcode
/Python Solutions/897. Increasing Order Search Tree.py
1,573
3.90625
4
""" Given a binary search tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and only 1 right child. Example 1: Input: [5,3,6,2,4,null,8,1,null,null,null,7,9] 5 / \ 3 6 / \ \ 2 4 8 / / \ 1 ...
eb6374561baec47b544ac8adb7c52501829e1d69
daniel-reich/ubiquitous-fiesta
/DjyqoxE3WYPe7qYCy_21.py
95
3.640625
4
def reverse_odd(txt): return ' '.join([s[::-1] if len(s)%2 else s for s in txt.split()])
66f68d6b3d082e2953167730ad871656d2b476f5
Aakashdeveloper/python-web
/session8_numpy.py
97
3.609375
4
import numpy as np a = np.array([[1,2,3],['A','B','C']]) print(a) print(a.shape) print(a[1,1])
03039c5a13a501922437ad68ea07103cc03c3c63
kajrud/Python-kurs-iSA
/Homeworks/Day 02/ex_02.py
405
4
4
# Napisz program do przeliczania stopni Fahrenheita na Celsjusza (wyświetlając wzór i kolejne obliczenia) print("""Aby przeliczyć stopnie Fahrenheita na stopnie Celsjusza należy użyć wzoru: T(cel) = 5 / 9 *(T(fah) - 32). Ale od czego jest komputer...""") far = float(input("Podaj temperaturę w stopniach Fahrenheita: ")...
c604ec22ab1973c692a01568484ebc1e1ed2c013
rhzx3519/leetcode
/python/1329. Sort the Matrix Diagonally.py
843
3.71875
4
class Solution(object): def diagonalSort(self, mat): """ :type mat: List[List[int]] :rtype: List[List[int]] """ m, n = len(mat), len(mat[0]) starts = [(i, 0) for i in range(m-1, -1, -1)] + [(0, j) for j in range(1, n)] for x, y in starts: i, j = x...
688d88333d7b4d91729f2815d22e75f836032560
Dpp3a/CSHL_PFB
/Py4/start_end_range.py
427
3.953125
4
#!/usr/bin/env python3 #script that takes the start and end values from the command line. If you call your script like this count.py 3 10 it will print the numbers from 3 to 10 import sys start_num = int(sys.argv[1]) ...
77baeecb49652bf0027b1e1a1bfce6d650ce80de
fabiocoutoaraujo/CursoVideoPython
/mundo-01/aula10-ex033.py
375
3.96875
4
n1 = float(input('Digite o 1º número: ')) n2 = float(input('Digite o 2º número: ')) n3 = float(input('Digite o 3º número: ')) maior = n1 menor = n1 if n2 > n1: maior = n2 if n3 > maior: maior = n3 if n2 < n1: menor = n2 if n3 < menor: menor = n3 print('O menor valor digitado é {}'.format(menor)) prin...
bed628af023416e2c68946fc1d45cf8e692fb523
gautamgitspace/Beginning-with-Python-Scripting
/tuples.py
1,233
4.3125
4
#tuples are like lists but are immutables like strings #things you can't do to tuples: modify, sort, append, reverse #tuples are comparable tupA=tuple print dir(tupA) x = { 'chuck' : 1 , 'fred' : 42, 'jan': 100} y = x.items() print y tupA = (0,1,2) tupB = (0,1,2) print tupB if tupA < tupB: print 'true' else: pr...
e32ed23b1854f1f621011a5a44d1be48b6f4e151
Ankan07/LeetCode
/986.py
983
3.5625
4
from typing import Any, List import math class Solution: def __init__(self) -> None: pass def intervalIntersection(self, firstList: List[List[int]], secondList: List[List[int]]) -> List[List[int]]: firstList.sort() secondList.sort() first_length = len(firstList) second_...
00405aa9b9795de005b6e23a814cb4cb93da5b88
RedwanQ/basicpython3
/mathhw.py
369
4.1875
4
import math # def sq(): width = int(input('Enter the Width')) length = int(input('Enter the Length')) area = width * length print(f'the square footage of a house is {area} ') # Circumference of circle def cir(): radius = float(input('Enter the raduis of your circle')) C = 2*math.pi*rad...
d89aa33587255e2786ca2be259af450d4414252c
yinglin33/calendarocr
/convertToCalendar.py
6,641
3.59375
4
import datetime from PIL import Image import re ''' Takes a string (cal) and looks for month, date, time, and event name in the string. Returns a string containing the event name and Datetime object containing the month, date, time. ''' ''' TODO change convertToCalendar so it returns the time interval of the event ...
1f59169032dcbea6c31ba8bd74f03368a7d8a39b
marcuscarr/UCB_cs61a
/hw/hw1/q4.py
427
4.15625
4
def hailstone(n): """Print the hailstone sequence starting at n and return its length. >>> a = hailstone(10) # Seven elements are 10, 5, 16, 8, 4, 2, 1 10 5 16 8 4 2 1 >>> a 7 """ steps = 1 print(n) while n != 1: if n % 2 == 0: n = n...
5e59675955ccee0ca942a8fad22ea010fef73709
YoungWoongJoo/Learning-Python
/list/list5.py
225
4
4
""" numbers에 5가 들어있을때, "5가 있다"를 출력하도록 빈칸을 채워 보세요. numbers = [1,2,3,4,5] if ___ in ___: print("5가 있다") """ numbers = [1,2,3,4,5] if 5 in numbers: print("5가 있다")
6fdf57067a989749d9c8697a9929dc363679090f
bkelly1984/umba_trial
/generic_dao.py
5,250
3.515625
4
import logging class GenericDao: """ This abstract class contains information and parameters to manipulate a database table. Attributes: GenericDao.table_name (str): the name of this table in the database. GenericDao.columns (list): the names of the columns in this table. ...
97cd6acbcd6cc51d12a95c6f575bbb128e6dad5e
shyams1993/caesars-cipher
/caesar_cipher.py
6,500
4.40625
4
import time,sys encrypted_result=[] decrypted_result=[] def encrypt_caesar_cipher(): ''' DOCSTRING: Function to encrypt a given string using caesar cipher. \nINPUT: Any string. \nLOGIC: To encrypt, it uses the basic formula : (character + shift digits) \nOUTPUT: The encrypted string result...
a82fe6111311f4dd23abffd528c2115caffcde8a
hianjana/Disaster_Response_Pipeline_Project_Udacity
/data/process_data.py
4,459
3.640625
4
#!/usr/bin/env python # coding: utf-8 # # ETL Pipeline # # The intent of this notebook is to load the 2 files which have disaster response data: messages.csv, categories.csv, clean them, combine them and load it into a SQL database. # **Sections:** # 1. Load csv files # 2. Data cleaning # 3. Data merge # 4. Load da...
f5fc349ae2db6e1d1c2eb6b0a7c4b3ee6b2f7fb5
Npurdie/lab2
/processing.py
2,572
3.5625
4
def to_bin(fractional): fraction = float('0.' + fractional) binary = '' while(fraction != 0.0): fraction = fraction * 2 if (fraction < 1): binary = binary + '0' else: binary = binary + '1' fraction = fraction - 1 return binary def to_twos_comp...
ef108e44133cd0ea567bcdea04d3aa08ffeb2a25
humachine/AlgoLearning
/leetcode/Done/71_SimplifyPath.py
1,351
3.828125
4
#https://leetcode.com/problems/simplify-path/ ''' Given a Unix-style path, simplify it. Inp: "/home/" Out: "/home" Inp: "/a/../b/../../c/" Out: "/c" (From directory /, /a + .. + /b + .. brings us back to / and / + .. -> / and lastly / + /c brings us to /c) ''' class Solution(object): def simpl...
8b632abb6c668b0c9163cdffe0e2bb2bf774b126
charles-wangkai/exercism
/python/rotational-cipher/rotational_cipher.py
253
3.640625
4
import string def rotate(text, key): return text.translate(str.maketrans(string.ascii_lowercase + string.ascii_uppercase, string.ascii_lowercase[key:] + string.ascii_lowercase[0:key] + string.ascii_uppercase[key:] + string.ascii_uppercase[0:key]))
563c7188f39af90c2b8dde732789416a10c59517
lollipopnougat/AlgorithmLearning
/力扣习题/538把二叉搜索树转换为累加树/problems.py
2,928
3.75
4
import math from typing import Optional from typing import List # Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def convertBST(self, root: Optional[TreeNode]) -> O...
d2b06c8b312750994e75deb16c9a3c748a960df8
xinghalo/DMInAction
/src/basic/07string.py
240
3.8125
4
var1 = 'hello' var2 = 'world' print(var1[0]) print(var2[1:5]) # 输出原始字符串 print(r'hello\n') # 格式化字符串 str1=''' hello nijhao ''' print(str1) # 内建函数 # print(capitalize('hello')) # center() # count('hello')
34c4fda378bc4a4f80c937232364224088076f79
magedu-pythons/python-25
/25009-qinzhichao/week-2/fib2.py
145
3.59375
4
def fib(a,b): return a+b a=0 b=1 print(a) print(b) for c in range(0,100): c=a+b if c>100: break print(c) a=b b=c
a79595e626088bef4bb095a10dcb5fa8ab0c9a37
mavenskylab/TechnicalAnalysis
/plot_line.py
869
3.59375
4
import matplotlib.pyplot as plt def plot_line(df): """Graph: Plot close with indicators""" plt.plot(df.index, df['close']) for col in df.columns: if col not in ['open', 'high', 'low', 'volume']: plt.plot(df.index, df[col], label=col) plt.ylabel("Price") plt.xlabel("Date") ...
328dbb13e3d3bc8c5480502983b22796b43a325b
Haugen/python-fun
/simplified-fractions.py
547
3.953125
4
# https://edabit.com/challenge/vQgmyjcjMoMu9YGGW # Simplified Fractions def simplify(txt): n,d = map(int, txt.split('/')) result = "" while True: for i in reversed(range(2, int(n)+1)): if (d/i).is_integer() and (n/i).is_integer(): n = n/i d = d/i break break if n > d a...
f34d2c70aea11dfb75123dbc93c45cfd2dfe1d5f
lincolen/Python-Crash-Course
/7 input and while/seating.py
195
3.75
4
party_size = input("nannmei sama desu ka: " ) party_size=int(party_size) if party_size<=8 and party_size>0: print("te-buru ni goannai shimasu") elif party_size>8: print("shosho omachikudasai")
42a417e4ed9f75eba7431c572ed15ac45767d491
jmabf/uri-python
/2029.py
273
3.53125
4
while True: try: v = float(input()) d = float(input()) r=d/2 pi=3.14 ar=(r**2)*pi h=v/ar print('ALTURA = {:.2f}'.format(h)) print('AREA = {:.2f}'.format(ar)) except EOFError: break
e256bad7d1ae7b0684403508a7f28d8942d9141f
KuanTingLin/TibaMe_CFI101
/test.py
2,162
3.53125
4
import sys from datetime import datetime, timedelta import time import os from test.test_file import current_file_dir from argparse import ArgumentParser parser = ArgumentParser() parser.add_argument('-g', '--group', help='Type of mail', dest='group', ...
ce9a1cd223acd185cb4e76afc5f25e262306fe20
Manmohit10/data-analysis-with-python-summer-2021
/part03-e13_read_series/src/read_series.py
614
3.625
4
#!/usr/bin/env python3 import pandas as pd def read_series(): df=pd.Series() a1=[] a2=[] while True: x=input("Enter values separated by string: ") if not x: break try : temp=x.split() if len(temp)>2: raise ValueError ...
f78dd20e575f877e27491235bac4c8fa4b3ddc00
Rodrigo00909/pythonfacultad1
/tp1 Funciones/ej6.py
719
4.09375
4
# 6. Desarrollar una función que reciba como parámetros dos números enteros positivos y devuelva el número que resulte de concatenar ambos valores. Por ejemplo, # si recibe 1234 y 567 debe devolver 1234567. No se permite utilizar facilidades de # Python no vistas en clase. def concatenar(num1, num2): contador...
11a9c40de70ac4fef15f2b8382813b19686e2834
mattman555/python
/ex44.py
1,181
4.09375
4
class other(object):#Make a class called other that has-a object def implicit(self):#Procedure that prints when called print "Other implicit()" def altered(self):#Procedure that prints when called print "Other altered()" class child(object):#Make a class called other that has-a object def __init__(self)...
5c8f611549b886d2813a1428fc4b78e6581d9be1
Morek999/OMSCS_Taiwan_Leetcode
/Max/Max_0056_20200115.py
1,243
3.6875
4
""" 56. Merge Intervals https://leetcode.com/problems/merge-intervals/ Time complexity: O(nlogn) Space complexity: O(n) Solution: """ from typing import List class Solution: def merge(self, intervals: List[List[int]]) -> List[List[int]]: intervals.sort() holding = [] for i i...
866c6088b1e0997299c74dbd96f60a68f9520e08
alexgrand/Grokking-algorhithms
/ch4/ex4.5-4.8.py
781
4
4
print("4.5 Вывод значения каждого элемента массива.") print("O(n)") print('-' * 20) print("4.6 Удвоение значения каждого элемента массива. ") print("O(n)") print('-' * 20) print("4.7 Удвоение значения только первого элемента массива.") print("O(1)") print('-' * 20) print("4.8 Создание таблицы умножения для всех элемент...
ac516544ff41a0f2902ed5811cdc8b2eaca64a57
VanessaCapuzzi/mackenzie_algoritmosI
/app_conhecimento_aula2.py
579
3.859375
4
# Faça um programa em Python que receba o custo (valor em reais) de um espetáculo teatral e o preço do convite (valor em reais) desse espetáculo. Esse programa deve calcular e mostrar: # a) A quantidade de convites que devem ser vendidos para que, pelo menos, o custo do espetáculo seja alcançado. # b) A quantidade de...
3e90a1b05f745febc8d26c5002d9684b92073d83
ccomangi2/Python_study
/venv/35.6 날짜 클래스 만들기.py
526
4.03125
4
#다음 소스 코드에서 Date 클래스를 완성하세요. is_date_valid는 문자열이 올바른 날짜인지 검사하는 메서드입니다. #날짜에서 월은 12월까지 일은 31일까지 있어야 합니다. class Date: @staticmethod def is_date_valid(date_string): year, month, day = map(int, date_string.split('-')) return month <= 12 and day <= 31 if Date.is_date_valid('2000-10-31'): print('...
0ecd2e1075612308ea38121d0d06806f9ab442d6
Sniper970119/Algorithm
/chapter_4/Find_max_subarray.py
2,921
3.5625
4
# -*- coding:utf-8 -*- class FIndMaxSubarray: def __init__(self, init_array): self.init_array = init_array pass def find(self, start, end): """ 递归寻找最大子数组 :return: """ # 递归结束标记 if start == end: return [self.init_array[start]], self.in...
8f7d98181689476800b1d956b95786ee435ab01f
tk42/ProjectEuler
/34. 桁の階乗.py
734
3.890625
4
import math #### DACLARE VARIABLES #### def num2digit(num) : return [int(x) for x in str(num)] def digit2num(digit) : num = 0 for i in range(len(digit)): num += digit[i] * pow(10 , len(digit) - i - 1) return num def digit_factorial(num) : if num == 0: return 1 elif num == 1: return 1 elif num == 2: ...
97d7492ea3cf030d4e21230b99bf833eb0c08d4b
Naateri/JustForFun
/iRacing-Schedules/sched.py
2,980
3.734375
4
import csv import sys import time sched = list() with open("Sched 2017-2.csv", "rU") as f: #importing schedule rows = csv.DictReader(f) for r in rows: sched.append(r) #saving schedule monthsDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] #dias por mes, empezando en Enero def askAuto(): a = raw_input("Se...
3822fc9e8c0c874800c97f7f5fd46cc5b808f3ea
erjan/coding_exercises
/verify_preorder_serialization_of_binary_tree.py
711
3.796875
4
''' One way to serialize a binary tree is to use preorder traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as '#'. ''' class Solution: def isValidSerialization(self, preorder: str) -> bool: preorderList = preorder.split(',...
c454daf1176ea214e9f66efd70f538bf7c78e68e
mingcn/kyleboard
/__init__.py
9,822
3.53125
4
from random import randint """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" # Set Up Board """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" dims = 0 while dims % 2 == 0 or dims < 6: dims = int(raw_input("How many tiles long do you want your board (choose an odd n...
09832a7167a22aa199415c794f00b6cfc03cf8ef
nicecode996/Python_Test
/python基础/for.py
808
3.90625
4
# !usr/bin/env python 3 # coding=utf-8 print("----范围------") <<<<<<< HEAD for num in range(1,100): print("{0} * {0} = {1}".format(num ,num * num)) ======= for num in range(1, 10): print("{0} * {0} = {1}".format(num , num * num)) >>>>>>> 7250e8d (第三次提交) print("----范围------") # for语句 for item in 'Hello': ...
9f0abdf4467c128b6a6e298afc8c7f47c47e3fea
frannyfra/Python-The-Basic
/dictionary.py
623
3.890625
4
# Key value pairs # our_dictionary = {"key1": "one", "key2": "two"} # print(our_dictionary) # product1= "apple" # product2= "hey" # product3= "bye" # products = [product1, product2, product3] # # total = 0 # # for( i = count(products) -1; i>= 1; i++) { # # total += products[i].price # # } # print(count(products))...
bad79752d5189c400d39721b115c0a7e4771c89c
gaohaoning/leetcode_datastructure_algorithm
/LeetCode/HashMap/350.py
2,119
4.09375
4
#!/usr/bin/env python # coding:utf-8 """ 350. 两个数组的交集 II 给定两个数组,编写一个函数来计算它们的交集。 示例 1: 输入: nums1 = [1,2,2,1], nums2 = [2,2] 输出: [2,2] 示例 2: 输入: nums1 = [4,9,5], nums2 = [9,4,9,8,4] 输出: [4,9] 说明: 输出结果中每个元素出现的次数,应与元素在两个数组中出现的次数一致。 我们可以不考虑输出结果的顺序。 进阶: 如果给定的数组已经排好序呢?你将如何优化你的算法? 如果 nums1 的大小比 nums2 小很多,哪种方法更优? 如果 nu...
3315285a7dca97141f1dfb10fb53524d20344eef
yangguangleiyang/selenium-unittest
/study-unittest/类方法、类属性、成员方法、成员属性学习.py
1,023
3.703125
4
import unittest #各个成员之间self对象是不一样的 class TestMyCase(unittest.TestCase): step = 1 ipadder = "192.168.1.1" # 类属性 name = None @classmethod def setUpClass(cls): #类方法 print("-----setupclass") @classmethod def tearDownClass(cls): print("----setupclass") def ...
55838b152583525b429d91e0841a7fdccfc1718e
RakhshandaMujib/Simple-Python-Programs-on-Classic-Algorithms
/11 Counting Sort.py
794
4.03125
4
def counting_sort(list_is, lower, upper): count = {i : 0 for i in range(lower, upper +1)} for i in range(len(list_is)): if list_is[i] > (upper + 1) or list_is[i] < lower: print(f'{list_is[i]} is not within [{lower},{upper}].') return elif list_is[i] in count: count[list_is[i]] += 1 print('The so...
449dd7dd425b896126bd99530d05d2a52458c66b
yuliy/sport_programming
/algorithms/roman2integer/main.py
629
3.6875
4
#!/usr/bin/env python3 # # Solution for leetcode problem: # https://leetcode.com/problems/roman-to-integer/ # class Solution: def romanToInt(self, s: str) -> int: s2r = { "I":1, "V":5, "X":10, "L":50, "C":100, "D":500, "M"...
9debebbd80dd58c6a0cc98fbf592851e56c65952
isdewo/python
/file/practice1.py
981
3.71875
4
''' 파이썬 - 7 파일 다루기 p. 21 연습 문제1 ''' ''' 파일에서 특정 단어를 다른 단어로 교체하는 프로그램을 작성하시오. 예를 들어, "abc", "111로 대체시킴. 파일 이름과 단어 2개는 키보드로 입력받는다. ''' filename = input("파일 이름을 입력하세요: ") word1, word2 = input("단어 2개를 띄어쓰기로 구분하여 입력하세요: ").split(" ") print("filename: ", filename) print("word1: {0}, word2: {1}".format(word1, word2)) # 파일...
58abd84aee77c7035e97e0261b16e0a372fe4a31
bithyf/leetcode_pycharm
/剑指offer/剑指 Offer 24. 反转链表.py
155
3.921875
4
def reverseList(head): p = head while p.next: p1 = p.next p.next = p1.next p1.next = head head = p1 return head