blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
17ed1954aef7212bf33317ee7e8c174d7f26ca65 | AnnMokhova/PROGA | /hw10/hw10.py | 839 | 3.5625 | 4 | #вариант 2
import re
def open_file(file):
with open(file, 'rb') as f:
f = f.read()
return f
def search_write():
ask = input('Введите название города, часовой пояс которого вы хотите узнать ') #Москва Берлин Нью-Йорк
if ask == 'Москва':
doc = 'Moscow.html'
if ask == 'Б... |
fc7534418fb1b55e1b4aa92c6718bb2553b8efc7 | AnnMokhova/PROGA | /hw2.py | 225 | 3.921875 | 4 | word = str(input('введите слово для задания 2 варианта: '))
for i in range(len(word)):
if (i % 2 == 0) and (word[i] == 'п' or word[i] == 'о' or word[i] == 'е'):
print(word[i])
|
47e84bf4f6a9c1479c1a5ecfd96a983f3f083698 | HarrisonMc555/exercism | /python/isogram/isogram.py | 327 | 3.609375 | 4 | def is_isogram(s):
sletters = list(filter(str.isalpha, s.lower()))
return len(set(sletters)) == len(sletters)
def is_isogram_(s):
seen = set()
for c in s.lower():
if not c.isalpha():
continue
if c in seen:
return False
seen.add(c)
else:
retur... |
a391e811b9248b693273f996d670b5e45cb0c55f | HarrisonMc555/exercism | /python/allergies/test.py | 476 | 3.515625 | 4 | import unittest
from allergies import Allergies
class AllergiesTests(unittest.TestCase):
def test_allergic_to_eggs_in_addition_to_other_stuff(self):
allergies = Allergies(5)
# print('lst:', allergies.lst)
self.assertIs(allergies.is_allergic_to('eggs'), True)
self.assertIs(allergies... |
52c4f2131fa1b0380b9d3e1c6abdfac944a0e254 | HarrisonMc555/exercism | /python/bob/bob.py | 840 | 3.828125 | 4 | import string
def hey(phrase):
if is_yelling_question(phrase):
return 'Calm down, I know what I\'m doing!'
elif is_question(phrase):
return 'Sure.'
elif is_yelling(phrase):
return 'Whoa, chill out!'
elif is_saying_nothing(phrase):
return 'Fine. Be that way!'
else:
... |
a62cde765969fc2327e8149a08492313436b201b | viniciusrogerio/lista_controle_2 | /4.py | 672 | 4.09375 | 4 | '''4. Faca um programa que solicite ao usuário 10 números inteiros e, ao final, informe a
quantidade de números impares e pares lidos. Calcule também a soma dos números pares e a
media dos números impares.
'''
i=1
qtdpares=0
qtdimpares=0
somapares=0
mediaimpares=0
while(True):
if i>10:
break
num=int(input(f'D... |
b037f4057f2ab8c9c74c1eb697b9d31b598b2565 | booler/spatial-interpolators | /spatial_interpolators/legendre.py | 3,694 | 3.578125 | 4 | #!/usr/bin/env python
u"""
legendre.py (03/2019)
Computes associated Legendre functions of degree n evaluated for each element x
n must be a scalar integer and X must contain real values ranging -1 <= x <= 1
Program is based on a Fortran program by Robert L. Parker, Scripps Institution
of Oceanography, Institute for ... |
7972dcd1ccb20497b56dde4ee725bb1e833b43c8 | xuhyang/practice | /solution/heap.py | 596 | 3.625 | 4 | class Heap:
def heapify(self, nums):
# (len(nums) - 1) // 2 or len(nums) // 2 or len(nums) // 2 - 1 all okay
for i in range(len(nums) // 2, -1, -1):
self.siftDown(nums, i)
def siftDown(self, nums, i):
#check if left child will be out of index, not i < len(nums)
whil... |
009209f32d917829d0a5ee111fdc3cbc8cddaec3 | ruthraprabhu89/Hiku-tester | /hiker1.py | 1,143 | 4 | 4 | class hiker:
def haiku(self,line):
print("line{}".format(line))
lines = line.split('/')
print("no of lines {}".format (len(lines)))
if not len(lines)<3:
raise ValueError('Haiku should contain three lines. No of lines found:{}'.format(len(lines)))
return
syl = [0,0,0]
for i in range... |
a5de4f9c3abf4ce25c5353680f63d4d2bed21a63 | Crazyinfo/Python-learn | /basis/错误、调试和测试/调试.py | 1,426 | 4.0625 | 4 | # 第一种方法将错误打印出来,用print()
# 第二种方法,凡是用print()来辅助查看的地方,都可以用断言(assert)来替代
def foo(s):
n = int(s)
assert n != 0,'n is zero' # ssert的意思是,表达式n != 0应该是True,否则,根据程序运行的逻辑,后面的代码肯定会出错。
return 10 / n
def main():
foo('0')
if __name__ == '__main__':
main()
# 第三种方法,把print()替换为logging是第3种方式,和assert比,logging不会抛出错误... |
aeb8f28c7c87fcf9df9f60e1a0b65786b9910beb | Crazyinfo/Python-learn | /basis/基础/偏函数.py | 766 | 4.3125 | 4 | print(int('12345'))
print(int('12345',base = 8)) # int()中还有一个参数base,默认为10,可以做进制转换
def int2(x,base=2):
return int(x,base) # 定义一个方便转化大量二进制的函数
print(int2('11011'))
# functools.partial就是帮助我们创建一个偏函数的,不需要我们自己定义int2(),可以直接使用下面的代码创建一个新的函数int3:
import functools
int3 = functools.partial(int , base = 2) # 固定了int()函数的关键字参数... |
e1fefe2ea38f94fda67111e127d82109902e2dea | Crazyinfo/Python-learn | /try/习题/珊.py | 744 | 4 | 4 | '''
# 第二题
class Time():
def __init__(self,hour,minute,second):
self.hour = hour
self.minute = minute
self.second = second
# 第三题
class Date():
def __init__(self,year,month,day):
self.year = year
self.month = month
self.day = day
# 第四题
class Datetime(Date,Time):
... |
4a993902e7e1412bce1c4edffbf397a426a400eb | Crazyinfo/Python-learn | /basis/基础/dict.py | 194 | 3.96875 | 4 | m = {5 : 1, 9 : 2, 4: 3}
if 1 in m:
print('Yes')
else:
print('No')
if 5 in m:
print('Yes')
else:
print('No')
m[8] = 4
if 8 in m:
print(m.items())
else:
print('No')
|
5199e375852e970c925414edd8f6ceea3be216d8 | Crazyinfo/Python-learn | /basis/高级特性/迭代.py | 330 | 3.921875 | 4 | d = {'a': 1,'b': 2,'c': 2}
for m in d:
print(m)
for n in d.values():
print(n)
for x,y in d.items():
print(x,y)
from collections import Iterable
h = isinstance(1233,Iterable) #判断一个对象是否可以迭代
print(h)
for m,n in enumerate([1,2,3,4]):
print(m,n)
for x,y in [(1,2),(3,4),(5,6)]:
print(x,y) |
9e0314bd94c25a0a1b012545cb2047d796a949b1 | true-false-try/Python | /A_Byte_of_Python/lambda_/natural_number.py | 1,551 | 4.21875 | 4 | """
Дано натуральне число n та послідовність натуральних чисел a1, a2,
…, an. Показати всі елементи послідовності, які є
а) повними квадратами;
б) степенями п’ятірки;
в) простими числами.
Визначити відповідні функції для перевірки, чи є число: повним квадратом,
степенню п’ятірки, простим числом.
"""
import r... |
65ed9bd112ebeab025d2f9c3bb6177bdab0f050d | true-false-try/Python | /A_Byte_of_Python/OOP/inheritance/passanger/main.py | 1,869 | 3.671875 | 4 | from random import randint
class Person:
def __init__(self):
self.name = None
self.byear = None
def input(self):
self.name = input('Прізвище: ')
self.byear = input('Рік народження: ')
def print(self):
print(self.name, self.byear, end=' ')
class P... |
1bc85861d977bb4312e0ff8ed5de02265ad9eb95 | true-false-try/Python | /A_Byte_of_Python/set_()/find_char.py | 1,406 | 3.96875 | 4 | """
Дано рядок з малих латинських літер.
Надрукувати:
a) перші входження літер до рядка, зберігаючи початковий взаємний порядок;
b) всі літери,що входять до рядка не менше двох раз в порядку збіьшення (a - z);
c) всі літери, що входять до рядка по одному разу
"""
string = 'abc abs sda faj'
words = string.spli... |
19cf04b25a91f1e0ccfe8023cc925cba97bb31dd | true-false-try/Python | /A_Byte_of_Python/file_/file_tasks/real_number/main.py | 1,520 | 3.5625 | 4 | file = open('file_numbers.txt', 'r')
x = [i.rstrip() for i in file]
string = ' '.join(x)
lst = string.split()
convert = [int(i) for i in lst]
# a)
def total():
global lst
return sum([int(i) for i in lst])
# b)
def minus():
global convert
return sum([1 for i in convert if i < 0])
... |
6d4671b842d2780d0a28998d856e9663129e0d6f | true-false-try/Python | /A_Byte_of_Python/dictionary_()/dictionary_tasks/car.py | 2,137 | 4.03125 | 4 | """
Відомості про автомобіль складаються з його марки, унікального
номера і прізвища власника. Дано словник, який містить відомості про
декілька автомобілей. Скласти процедури знаходження
a) прізвищ власниківі номерів автомобілей даної марки;
b) кількості автомобілей кожної марки.
"""
cars_dictionary = {'AA3... |
ee3c93fb3f3b9307aad80df30ca8b2a66007f551 | priiperes/IntroPython | /Aula1.py | 3,357 | 4.0625 | 4 |
#Aula 1
#exercío 1
print('Exercício 1')
print('Se você fizer uma corrida de 10 quilômetros em 43 minutos e 30 segundos, qual será seu tempo médio por milha?')
km=10
milha = km/1.61
tempo=43*60+30
hora= tempo/3600
resultado = hora/milha
print('resultado =',resultado,'h/milha')
print('\n')
print('Qual é... |
64d01a920fcf73ad8e0e2f55d894029593dc559d | zitorelova/python-classes | /competition-questions/2012/J1-2012.py | 971 | 4.34375 | 4 | # Input Specification
# The user will be prompted to enter two integers. First, the user will be prompted to enter the speed
# limit. Second, the user will be prompted to enter the recorded speed of the car.
# Output Specification
# If the driver is not speeding, the output should be:
# Congratulations, you are within... |
0a58f6868af57dcba6babf48ed32c1a31f8350eb | zitorelova/python-classes | /competition-questions/2017/S2-2017.py | 1,287 | 3.890625 | 4 | """
Input Specification
The first line contains the integer N (1 ≤ N ≤ 100). The next line contains N distinct space-
separated positive integers, where each integer is at most 1 000 000.
Output Specification
Output the N integers in the unique order that Joe originally took the measurements.
Sample Input
8
10 50 40 ... |
b43877784392fe97c441f2998172bd7765d8d1ff | zitorelova/python-classes | /competition-questions/2010/S2-2010.py | 1,893 | 3.53125 | 4 | # Input Specification
# The first line of input will be an integer k (1 ≤ k ≤ 20), representing the number of characters and
# associated codes. The next k lines each contain a single character, followed by a space, followed
# by the binary sequence (of length at most 10) representing the associated code of that charac... |
a6a74f456b6c6b484e577de6aefdd5a6e6a4b799 | zitorelova/python-classes | /J1-2020.py | 559 | 3.75 | 4 | """
Input Specification
There are three lines of input. Each line contains a non-negative integer less than 10. The first line
contains the number of small treats, S, the second line contains the number of medium treats, M ,
and the third line contains the number of large treats, L, that Barley receives in a day.
Outp... |
6bfea6232f02b525708f2c88cb7a3ad64cb6b13b | Halfkeyboard567/M_mathews_84706_project01_Paint.py | /Paint_C.py | 6,833 | 3.640625 | 4 | #Part C
from graphics import *
class Shape:
def __init__(self, win):
self.win = win
def line(self):
T1 = Text(Point(400, 50), "Line: Enter 2 points")
T1.setSize(8)
T1.draw(self.win)
p1 = self.win.getMouse()
p1.draw(self.win)
p2 = self.win.getMous... |
84674ce996ed3ae5e0b13032b05c2803ab6508cd | naveenshukla/OpenQA | /question_processing/question_phrases.py | 326 | 3.875 | 4 | #!/usr/bin/python3 -tt
question_words = ['who','why','where','what','when','how','which','whose','whom', '?', '.', ':', ';', '"', '\'']
def remove(text):
text = text.lower().strip()
if text in question_words:
text = ''
return text
def main():
print(remove(input()))
if __name__ == '__main__':
main()
... |
cbbcbf765114f341b973c55c30490ed8984f98bf | zyq507/Pythoncore | /Dict_Test.py | 1,248 | 3.65625 | 4 | phonebook = {'Alice':'2341','Beth':'9102','Cecil':'3258'}
items = [('name','FCK'),('age','21')]
d =dict(items)
print(d)
print(d['name'])#其中的key相当于索引
print(len(d))
print('age' in d)
d['job'] = 'worker'
print(d)
del d['job']
print(d)
k = 'my name is %(name)s, I\'m %(age)s years old'% d
print(k)#字典的key可以做为%s的说明符
x = {'k... |
c7f4cc528ed6497a05e435e7ef3f5ee47e5b3dfc | dechevh/SoftwareUniversity | /Python-Fundamentals/softUni_reception.py | 405 | 3.71875 | 4 | efficiency_one = int(input())
efficiency_two = int(input())
efficiency_three = int(input())
students_count = int(input())
all_employees_per_hour = efficiency_one + efficiency_two + efficiency_three
time_needed = 0
while students_count > 0:
time_needed += 1
if time_needed % 4 == 0:
pass
else:
... |
e64c96b39f822ce75b5b92d0c843248903f9c0ff | University-Assignment/PythonProgramming | /2018037010_7.py | 4,088 | 4.03125 | 4 | '''
# 미션1: 연락처 관리 프로그램
menu = 0
friends = []
while menu != 9:
print("--------------------")
print("1. 친구 리스트 출력")
print("2. 친구추가")
print("3. 친구삭제")
print("4. 이름변경")
print("9. 종료")
menu = int(input("메뉴를 선택하시오: "))
if menu == 1:
print(friends)
elif menu== 2:
name = i... |
c1507b325a379d1b386e4592e546ec6306ee38a1 | University-Assignment/PythonProgramming | /test.py | 833 | 3.5 | 4 | #변수 x는 원소의 수가 100개인 1차원 배열이다. 변수 x의 원소는 0에서 255까지의 정수를 랜덤하게 갖는다.
# 변수 x를 파이선의 random 모듈을 이용하여 구하시오.
import random
x = []
for i in range(100):
x.append(random.randint(0, 256))
print(x)
# a=[1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, 0]로 정의된 벡터의 FFT 출력
import numpy as np
import matplotlib.pyplot as plt
a = [1, 2, 3, ... |
5693de8003cd127a82c42b5ee8bb2985a79f045b | shreyasbapat/Astronomy-Code-Camp-Slides | /one.py | 206 | 3.921875 | 4 | def check(num):
if num <= 9:
print("Single Digit")
elif num >9 and num <=99:
print("Double Digit")
else:
print("Others")
if __name__ == "__main__":
num = int(input("Input a number:"))
check(num) |
fbe4f97912ae394e43a5d2b2928ab20297c4fcf8 | escnqh/PracticesWhenLearnPython | /math.py | 516 | 3.796875 | 4 | #在Python中,有两种除法,一种除法是/:
print(10/3)
#/除法计算结果是浮点数,即使是两个整数恰好整除,结果也是浮点数:
print(9/3)
#还有一种除法是//,称为地板除,两个整数的除法仍然是整数:
print(10 // 3)
#整数的地板除//永远是整数,即使除不尽。要做精确的除法,使用/就可以。
#因为//除法只取结果的整数部分,所以Python还提供一个余数运算,可以得到两个整数相除的余数:
print(10%3) |
e85612854387fb68172ad444981ca2590a40d1e3 | escnqh/PracticesWhenLearnPython | /formatting.py | 1,285 | 3.953125 | 4 | #格式化
#最后一个常见的问题是如何输出格式化的字符串。我们经常会输出类似'亲爱的xxx你好!你xx月的话费是xx,余额是xx'之类的字符串,而xxx的内容都是根据变量变化的,所以,需要一种简便的格式化字符串的方式。
#在Python中,采用的格式化方式和C语言是一致的,用%实现,举例如下:
print('hello,%s'%'world')
print('Hi, %s, you have $%d.' % ('Michael', 1000000))
#你可能猜到了,%运算符就是用来格式化字符串的。在字符串内部,%s表示用字符串替换,%d表示用整数替换,有几个%?占位符,后面就跟几个变量或者值,顺序要对应好。如果只有一个%?,括号可以... |
83e3c6fb686616a919d2e28037e1e02cc97fd6cf | x64x6a/ircbot | /ircbot/standard_io.py | 831 | 3.578125 | 4 | '''
This is used to handle stdin and stdout input and output for the library
'''
import time
import sys
import threading
STDOUT_BUFFER = []
def print_stdout_buffer():
'''Continously flushes the stdout buffer'''
global STDOUT_BUFFER
try:
while 1:
if STDOUT_BUFFER:
out = STDOUT_BUFFER[0]
STDOUT_BUFFER =... |
497835d4aed9639a52e9b17ce039d6f7e2584cc6 | Pasquale-Silv/Bit4id_course | /Some_function/SF1_poppaLista.py | 260 | 3.515625 | 4 | def poppaLista(lista):
"""Poppa l'intera lista passata come argomento."""
for i in range(0, len(lista)):
val_poppato = lista.pop()
print(val_poppato)
print(lista)
list1 = [3, 4, 5, 8]
print(list1)
poppaLista(list1)
|
693c554c403602ca49fb6a852648c4e9547723d7 | Pasquale-Silv/Bit4id_course | /Course_Bit4id/ThirdDay/Loop_ex1.py | 711 | 4.40625 | 4 | items = ["Python", 23, "Napoli", "Pasquale"]
for item in items:
print(item)
print()
for item in items:
print("Mi chiamo {}, vivo a {}, ho {} anni e sto imparando il linguaggio di programmazione '{}'.".format(items[-1],
... |
1b6ca4e89dd7d1082eb7d9aba899748ff51c8421 | Pasquale-Silv/Bit4id_course | /Course_Bit4id/SecondDay/es2_numParioDisp.py | 153 | 4.03125 | 4 | num = int(input("Inserisci un numero: "))
if(num % 2 == 0):
print("Il numero", num, " è pari")
else:
print("Il numero", num, " è dispari!") |
52b7ab845ddcc63afb61d533148e64e2077da353 | Pasquale-Silv/Bit4id_course | /Course_Bit4id/TwelfthDay/LC_and_lists/ex5_cifratura.py | 2,149 | 3.859375 | 4 | # Prendi stringa e inverti caratteri della stringa. Per ogni stringa, la ribaltiamo.
# Associare un numero intero a ogni carattere della stringa e separarli con una |pipe| o altro carattere speciale.
# Per associare il numero usa la funzione ord() che restituisce l'equivalente in codice ASCII.
# pipe anche all'inizi... |
4895a53522b4957765e61b27e10239f729b2c2bb | Pasquale-Silv/Bit4id_course | /Some_function/SF9_genNumPrimiDivisa.py | 616 | 3.6875 | 4 | def isPrimo(numInt):
"Restituisce True se un numero è primo, altrimenti False."
for i in range(2, numInt):
if(numInt % i == 0):
return False
return True
def genNumPrimi2func(inizio, fine):
"Raccoglie in un generatore tutti i numeri primi compresi nel range specificato."
... |
35a9c81798a968e5306deb13d4587650c65c7e7d | Pasquale-Silv/Bit4id_course | /Course_Bit4id/EleventhDay/Giochi_di_parole/ClasseGiochiDiParole.py | 1,834 | 3.796875 | 4 | class GiochiDiParole():
lista_parole = ["fare", "giocare", "dormire", "fittizio", "lira", "sirena", "fulmine", "polizia", "carabinieri",
"luce", "oscuro", "siluro", "razzo", "pazzo", "sillaba", "tono", "oro", "argento", "moneta",
"panna", "zanna", "simulare", "creare", "... |
56ce5b83d5ed2b0fb6807d22e52cc0dc9514a9d6 | Pasquale-Silv/Bit4id_course | /Some_function/SF6_factorialWithoutRec.py | 822 | 4.28125 | 4 | def factorial_WithoutRec(numInt):
"""Ritorna il fattoriale del numero inserito come argomento."""
if (numInt <= 0):
return 1
factorial = 1
while(numInt > 0):
factorial *= numInt
numInt -= 1
return factorial
factorial5 = factorial_WithoutRec(5)
print("5! =", factor... |
878f5bb5efec177a0ae72b5a33eca20889dabb05 | Pasquale-Silv/Bit4id_course | /Course_Bit4id/FifthDay/DictComprehension_DC.py | 107 | 3.84375 | 4 | word = 'dictionary'
letter_count = {letter:word.count(letter) for letter in word}
print(letter_count)
|
d1a68267f5fa87fcaf1726fc05579e5db9965380 | Pasquale-Silv/Bit4id_course | /Course_Bit4id/SeventhDay/Gestione_delle_eccezioni/ecc1.py | 645 | 4 | 4 | # try
# except
# else This executes ONLY if no exception is raised
# finally Viene eseguito sempre
print("Devi dividere due numeri")
num1 = int(input("Scegli il primo numero:\n"))
num2 = int(input("Scegli il secondo numero:\n"))
try:
res = num1 / num2
print(res)... |
c66f129442daf2ee1efacb2a1549dabcde4018c3 | Pasquale-Silv/Bit4id_course | /Course_Bit4id/FifthDay/ifAssign.py | 334 | 3.765625 | 4 | # if ternario
età = int(input("Qual è la tua età?"))
stato = "maggiorenne" if (età >= 18) else "minorenne, vai dalla mammina"
print("Hai", età, "anni...", stato)
# ("no", "yes")[True] ------> (0, 1) nella tupla, quindi accedi al valore corrispondente a False(0) o True(1)
print("Ciao Pasquale" if(... |
716636aa9bcd32032127d3c4be3050b98d876481 | Pasquale-Silv/Bit4id_course | /Course_Bit4id/FourthDay/funz_alt_print.py | 574 | 3.71875 | 4 | animal = "dog"
animals = ["dog", "cat", "mouse", "horse", "turtle"]
# Sono placeholder
# %s s sta per string
# %d d sta per digit(cifra)
print("I have a %s" % animal)
print("I have a %s, a %s and a %s." % (animals[0], animals[1], animals[-1])) # Passi gli argomenti come tuple
number = 23
numbers ... |
ed1208ad2fadaa5406721bf32b38179cef46e1bf | Pasquale-Silv/Bit4id_course | /Course_Bit4id/SeventhDay/Gestione_delle_eccezioni/ecc4.py | 712 | 3.8125 | 4 | nomi = ["Pasquale", "Alfonso", "Luca"]
for nome in nomi:
print(nome)
risp = int(input("\nQuanti nomi presenti nella lista vuoi vedere?\n"))
try:
for i in range(0, risp):
print(nomi[i])
except (IndexError): # Se non specifichi nessun tipo di errore, Python catturerà tutti i tipi d... |
54ceb93532b9046a2474e55a4de058c4c20d4b53 | Pasquale-Silv/Bit4id_course | /Course_Bit4id/FourthDay/ex1_List.py | 288 | 4.0625 | 4 | names = ["Pasquale", "Bruno", "Lucia", "Antonio", "Giacomo"]
while(len(names) >= 3):
print("La stanza è affollata, liberare!")
print("Via", names.pop())
if(len(names) < 3):
print("La stanza non è affollata!")
print("\nPersone in stanza:", names, ", ottimo!")
|
ceb9862e7d277490de90854f070afe9daab3d9e8 | Pasquale-Silv/Bit4id_course | /Some_function/kata2_reverseWords2.py | 301 | 3.6875 | 4 | def reverse_words(str):
newStr = []
for i in str.split(' '):
newStr.append(i[::-1])
return ' '.join(newStr)
primo = reverse_words("La vita è bella! vero?")
print(primo)
secondo = reverse_words('double spaced words') #, 'elbuod decaps sdrow')
print(secondo)
|
c32334bce0e237b3ad2dac4de7efeb73cdbfb123 | Pasquale-Silv/Bit4id_course | /Course_Bit4id/FourthDay/ex5_SortingIntList.py | 808 | 4.5 | 4 | nums = [100, -80, 3, 8, 0]
print("Lista sulla quale effettueremo le operazioni:", nums)
print("\nOriginal order:")
for num in nums:
print(num)
print("\nIncreasing order::")
for num in sorted(nums):
print(num)
print("\nOriginal order:")
for num in nums:
print(num)
print("\nDecreasing ord... |
1215b573ac6647498439014f1d3b6062d0966c7c | Pasquale-Silv/Bit4id_course | /Course_Bit4id/TenthDay/OOP7.py | 1,237 | 3.5 | 4 | class Gatto():
tipo="felino" # Variabile/Attributo di classe
def __init__(self, nome, anni, fidanzato=False, padrone=None):
self.nome = nome
self.anni = anni
self.fidanzato = fidanzato
self.padrone = padrone
g1 = Gatto("Fuffy", 3)
g2 = Gatt... |
82c05807574232ec277e3779dfea98b9f1f251f1 | Pasquale-Silv/Bit4id_course | /Course_Bit4id/FifthDay/FunctionsIntro/ex_func2.py | 444 | 3.78125 | 4 | def writeFullName(firstname, lastname):
print("Hello %s %s, are you ok?" % (firstname, lastname))
writeFullName("Pasquale", "Silvestre")
writeFullName("Giulio", "Di Clemente")
writeFullName("Armando", "Schiano di Cola")
print("------------------------------------------------------")
def sum2num(num1, nu... |
5329f13a9b2a3d52451e79d8ece8b90512aaf037 | Pasquale-Silv/Bit4id_course | /Some_function/SF7_factorialWithRec.py | 274 | 4 | 4 | def factorialWithRec(numInt):
if(numInt <= 1):
return 1
factorial = numInt * factorialWithRec(numInt - 1)
return factorial
factorial5 = factorialWithRec(5)
print("5! =", factorial5)
factorial4 = factorialWithRec(4)
print("4! =", factorial4)
|
94fd34899c3c92b34e5fdcae999928a0573b9c1f | mariahfernnn/udemy-python | /copying.py | 230 | 4.03125 | 4 | # EXERCISE: Stop Copying Me - While Loop
# Repeat user input until they say the magic word/phrase
copy = input("Are we there yet? ")
while copy != "I'll let you know when":
print(copy)
copy = input()
print("Yes, we're here!") |
35dc8158e1cecf78e95b9ea0ea23f3da26f3355a | nj137/Fee-estimation | /fee_estimate.py | 2,868 | 4 | 4 | #Program to estimate the fees for a course
print "Fees to be paid:"
#List of fees to be paid
fees=['application fees','exam fees']
#Exam fee structure
exam_fees={'Nationality':['Indian','Foreign','NRI','SAARC'],'Courses':['Ayurveda','Dental','Medical'],'Level':['UG','UG-Diploma','PG']}
#Application fee structure
ap... |
88cb690799b6fd6aa32ced1feab805eec6aaefd6 | Azureki/LeetCode | /lc19.py | 615 | 3.703125 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def removeNthFromEnd(self, head, n):
"""
:type head: ListNode
:type n: int
:rtype: ListNode
"""
if n... |
4309f01c9e87cf50157393eeaea2857980856d77 | Azureki/LeetCode | /lc892.py | 1,187 | 3.859375 | 4 | '''
之前有道题求投影,这个是求表面积,因此需要考虑凹的情况。
上下(也就是平行于xy平面)容易,依然是投影。
平行于yz、xz平面的分成两部分:
1. 先求周围一圈
2. 再求被挡住的
'''
class Solution:
def surfaceArea(self, grid):
"""
:type grid: List[List[int]]
:rtype: int
"""
n = len(grid[0])
xy = sum(v > 0 for row in grid for v in row) * 2
... |
101e3174916e5959999f8dc9aeb9f63d6e058415 | Azureki/LeetCode | /lc938. Range Sum of BST.py | 871 | 3.546875 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
from bisect import bisect_left
class Solution:
def dfs(self, root, lst):
if not root:
return
self.dfs(root.left, lst)
... |
74274ba211d24f26d6056d52df0ebe385434af5b | Azureki/LeetCode | /lc888.py | 416 | 3.5625 | 4 | class Solution:
def fairCandySwap(self, A, B):
"""
:type A: List[int]
:type B: List[int]
:rtype: List[int]
"""
sumA=sum(A)
sumB=sum(B)
dif=sumA-sumB
tem=int(dif/2)
A=set(A)
B=set(B)
for a in A:
if a-tem in B:
... |
895c3d7d11a6584c5eb83c6ea1519b25988c48c8 | Azureki/LeetCode | /lc167. Two Sum II - Input array is sorted.py | 547 | 3.546875 | 4 | class Solution:
def twoSum(self, numbers, target):
"""
:type numbers: List[int]
:type target: int
:rtype: List[int]
"""
left = 0
right = len(numbers) - 1
while left < right:
tem = numbers[left] + numbers[right]
if tem > target:
... |
b8cb0d6f5da2b6177bbb78304070827be4d6f6e1 | rachelyeshurun/papercutting | /connect.py | 10,035 | 3.5 | 4 | ''' connect all the black components of the image and thicken the connecting paths
'''
import errno
import os
import sys
import numpy as np
import cv2
from utils import show_image
import numpy as np
import cv2
from pprint import pprint
# The following class is based on answer by Boaz Yaniv here: https://stackoverf... |
d67ecfdeaa6a10e83058d5bf4a2d160abaa8a5a0 | odiepus/PLP6 | /p6.py | 3,234 | 3.71875 | 4 | import re
str = "( + (+ 3 2) (- 7 3))"
global lastLeftParen
lastLeftParen = 0
global lastRightParen
lastRightParen = 0
class Error(Exception):
pass
class OperationError(Error):
pass
class OperandError(Error):
pass
def tokenize_str(input_str):
new_str = input_str.replace(" ", "")
new_str = ne... |
5670d0bec92648eea1b37bc852ec858de9dce2dd | a1ip/python-learning | /lutz.LearningPython/script1.py | 307 | 3.609375 | 4 | #!/usr/bin/env python3
# Первый сценарий на языке Python
import sys # Загружает библиотечный модуль
print(sys.platform)
print(2 ** 100) # Возводит число 2 в степень 100
x = 'Spam!'
print(x * 8) # Дублирует строку
input ()
|
6da48b1d055c81f33d761c13c3ceef41133231bb | a1ip/python-learning | /phyton3programming/1ex4.awfulpoetry2_ans.py | 1,576 | 4.1875 | 4 | #!/usr/bin/env python3
"""
добавьте в нее программный код, дающий пользователю возможность определить количество выводимых строк (от 1 до 10 включительно),
передавая число в виде аргумента командной строки. Если программа вызывается без аргумента,
она должна по умолчанию выводить пять строк, как и раньше.
"""
import... |
2fbbc1a17133c74dd37c612200ddee48a0b2c4ca | a1ip/python-learning | /lutz.LearningPython/P1129.py | 923 | 3.890625 | 4 | #!/usr/bin/env python3
registry = {}
def register(obj): # Декоратор функций и классов
registry[obj.__name__] = obj # Добавить в реестр
return obj # Возвращает сам объект obj, а не обертку
@register
def spam(x):
return(x ** 2) # spam = register(spam)
@register
def ham(x):
return(x ** 3)
@register
class Eggs:... |
9a261241acebb6fe2d50116cd6227f22c9571b1b | a1ip/python-learning | /empireofcode.com/adamantite_mine_1MostNumbers.py | 1,034 | 3.71875 | 4 | #!/usr/bin/env python3
def most_difference(*args):
if len(args) > 0:
nums=sorted(args)
min=nums[0]
max=nums[-1]
print (max,'-',min,'=',round(max-min,3))
return round(max-min,3)
return 0
if __name__ == '__main__':
# These "asserts" using only for self-checking and not necessary... |
445aafce7f87fa1181a00366875fe06bb8ea8a24 | a1ip/python-learning | /phyton3programming/sort.py | 347 | 3.796875 | 4 | #!/usr/bin/env python3
numbers = [9,6,2,4,5,1]
print(numbers)
#Сортировка
i=0
while i<len(numbers):
j=0
print("")
while j<len(numbers)-i-1:
print(i,j)
#
if numbers[j]>numbers[j+1]:
#
tmp=numbers[j]
numbers[j]=numbers[j+1]
numbers[j+1]=tmp
print(numbers)
j+=1
#
i+=1... |
ecad1b1fc73e3f4a21f139b7702cca8f2a293045 | a1ip/python-learning | /lutz.LearningPython/tester.py | 1,436 | 3.796875 | 4 | ##tester func
"""
def tester(start):
state = start # Обращение к нелокальным переменным
def nested(label): # действует как обычно
nonlocal state
print(label, state) # Извлекает значение state из области
state += 1
return nested
"""
#tester class
"""
class tester: # Альтернативное решение на основе классов (Час... |
a3982626451b29e21a6077cbf8c0b7be10fbc31b | a1ip/python-learning | /lutz.LearningPython/part3ex1c.py | 181 | 3.59375 | 4 | #!/usr/bin/env python3
S='t s'
L=[]
for x in S:
print ('ASCII code for symbol', x, '=', ord(x))
L.append(ord(x))
print ("\nlist for S as ASCII code:", L)
#or list(map(ord, S))
|
efba9a36610e4837f4723d08518a5255da5a881a | TonyZaitsev/Codewars | /8kyu/Remove First and Last Character/Remove First and Last Character.py | 680 | 4.3125 | 4 | /*
https://www.codewars.com/kata/56bc28ad5bdaeb48760009b0/train/python
Remove First and Last Character
It's pretty straightforward. Your goal is to create a function that removes the first and last characters of a string. You're given one parameter, the original string. You don't have to worry with strings with less ... |
0c17db71399217a47698554852206d60743ef93e | TonyZaitsev/Codewars | /7kyu/Reverse Factorials/Reverse Factorials.py | 968 | 4.375 | 4 | """
https://www.codewars.com/kata/58067088c27998b119000451/train/python
Reverse Factorials
I'm sure you're familiar with factorials – that is, the product of an integer and all the integers below it.
For example, 5! = 120, as 5 * 4 * 3 * 2 * 1 = 120
Your challenge is to create a function that takes any number and r... |
3d35471031ccadd2fc2e526881b71a7c8b55ddc0 | TonyZaitsev/Codewars | /8kyu/Is your period late?/Is your period late?.py | 1,599 | 4.28125 | 4 | """
https://www.codewars.com/kata/578a8a01e9fd1549e50001f1/train/python
Is your period late?
In this kata, we will make a function to test whether a period is late.
Our function will take three parameters:
last - The Date object with the date of the last period
today - The Date object with the date of the check
c... |
019b5d23d15f4b1b28ee9d89112921f4d325375e | TonyZaitsev/Codewars | /7kyu/Sum Factorial/Sum Factorial.py | 1,148 | 4.15625 | 4 | """
https://www.codewars.com/kata/56b0f6243196b9d42d000034/train/python
Sum Factorial
Factorials are often used in probability and are used as an introductory problem for looping constructs. In this kata you will be summing together multiple factorials.
Here are a few examples of factorials:
4 Factorial = 4! = 4 * ... |
56be1dd38c46c57d5985d8c85b00895eeca5777d | TonyZaitsev/Codewars | /5kyu/The Hashtag Generator/The Hashtag Generator.py | 2,177 | 4.3125 | 4 | """
https://www.codewars.com/kata/52449b062fb80683ec000024/train/python
The Hashtag Generator
The marketing team is spending way too much time typing in hashtags.
Let's help them with our own Hashtag Generator!
Here's the deal:
It must start with a hashtag (#).
All words must have their first letter capitalized.
If... |
a5ebb27b3e709396ad81c482ff164bf372e9bf96 | kepler471/katas | /esolangInterpreter/ministring.py | 202 | 3.5625 | 4 | def interpreter(code):
count = 0
accum = ''
for i in code:
if i == '+':
count = (count + 1) % 256
elif i == '.':
accum += chr(count)
return accum
|
ef2c835a3bcefbf4b26cea5291d3478014f877fd | uzunovavera/learnPythonTheHardWay | /venv/ex13.py | 593 | 3.875 | 4 | from sys import argv
#read the WYSS section for how to run this
script, first, second, third = argv
age = input("What is your age?")
print("The script is called:", script)
print("Your first variable is:", first)
print("Your second variable is:", second)
print("Your third variable is:", third)
# To execute this you n... |
7cc9db5d288ce69ff8d87079d92ad899ac52026b | mehedieh/dice | /dice.py | 2,997 | 3.75 | 4 | import random
import time
import getpass
import hashlib
HASHED_PASSWORD = "b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86"
USERS = ('User1', 'User2', 'User3', 'User4', 'User5')
def login(max_attempts=5):
attempts = 0
while atte... |
d78ad76a67dfa6b320a78cf88427b8ef791bb814 | movingpictures83/MATria | /networkx_mod/generators/stochastic.py | 1,433 | 3.6875 | 4 | """Stocastic graph."""
# Copyright (C) 2010-2013 by
# Aric Hagberg <hagberg@lanl.gov>
# Dan Schult <dschult@colgate.edu>
# Pieter Swart <swart@lanl.gov>
# All rights reserved.
# BSD license.
import networkx as nx
from networkx.utils import not_implemented_for
__author__ = "Aric Hagberg <aric.hagberg@g... |
285505ccfb2e2dbd706c6ef6f884c92f1fa0214c | LiamTHCH/Boids-Simulation | /Test Version/main (0).py | 1,974 | 3.53125 | 4 | import random
import time
from tkinter import *
master = Tk()
master.title("Points")
canvas_width = 1000
canvas_height = 800
w = Canvas(master, width=canvas_width, height=canvas_height)
w.pack(expand=YES, fill=BOTH)
w.pack()
##definir les variables
Ox = (random.randint(100, 900))
Oy = (random.randint(100, 700))
m... |
74e2b19f5933103ad676852617eb303038fbe3ce | ckasper21/CS265 | /lab04/s1.py | 591 | 3.671875 | 4 | #!/usr/bin/python
# s1.py
# Author: Chris Kasper
# Purpose: Breakdown students input file, outputs name and average
import sys
if len(sys.argv)==1: # Check to make sure theres an arg (other then the script)
sys.exit()
f = open(str(sys.argv[1]), 'r') # Open the file from arg
l=f.readline()
while l :
total=0
l=l.... |
f9df830f5502a1652f458cfa5f3d25832a27fc54 | caohanlu/test | /阶段01/08 类与类之间的调用、继承.py | 9,933 | 4.78125 | 5 |
"""
类与类之间的调用:
需求:老张开车去东北
类:承担行为 【行为一样的,划分成一个类】【按照行为,划分成类,就叫做封装】
对象:承担数据 【每个对象的数据不一样,但是每个对象的行为是一样的】
1. 识别对象
老张 车
2. 分配职责
去() 行驶()
3. 建立交互
老张调用车
4.东北没有动作,所以不用划分成类
"""
# 写法1:直接创建对象
# 语义... |
3afc1ab7a0de2bb6dc837084dd461865a2c34089 | mirpulatov/racial_bias | /IMAN/utils.py | 651 | 4.15625 | 4 | def zip_longest(iterable1, iterable2):
"""
The .next() method continues until the longest iterable is exhausted.
Till then the shorter iterable starts over.
"""
iter1, iter2 = iter(iterable1), iter(iterable2)
iter1_exhausted = iter2_exhausted = False
while not (iter1_exhausted and iter2_exhausted):
... |
410c378f69b9d4b2ff43c1ec249bb2bf63d94589 | organisciak/programming-puzzles | /finished/euler/001-multiples-of-3-5.py | 336 | 3.859375 | 4 | # Find the sum of all the multiples of 3 or 5 below 1000.
x = 10
# Simple solution
print sum([n for n in range(0, x) if n % 3 == 0 or n % 5 == 0])
# Adding the sums of iterate by 3 and iterate by 5 ranges, then subtract
# the iterate by 15 range. No comparisons!
print sum(range(0, x, 3)) + sum(range(0, x, 5)) + sum(r... |
821e12b328bc80de48c097fd78617807d1430bdd | django/django-localflavor | /localflavor/uy/util.py | 324 | 3.921875 | 4 | def get_validation_digit(number):
"""Calculates the validation digit for the given number."""
weighted_sum = 0
dvs = [4, 3, 6, 7, 8, 9, 2]
number = str(number)
for i in range(0, len(number)):
weighted_sum = (int(number[-1 - i]) * dvs[i] + weighted_sum) % 10
return (10 - weighted_sum) %... |
1d5d793833094834c00371b46286e3057187a968 | vampire7414/bin_dec_hexa | /binary_to_hexa.py | 210 | 4.09375 | 4 | print('hello I can change the number from binary to hexa')
binary=input('enter a binary number:')
decimalsolution=int(binary,base=2)
hexasolution=hex(decimalsolution)
print('the answer is')
print(hexasolution)
|
c155a4b2a15f2934639592340350320d40367904 | shiny0510/DataStructure_Python | /Algorithm analysis/graph.py | 688 | 3.828125 | 4 | import matplotlib.pyplot as plt
import numpy as np
n = np.arange(1, 1000)
m = np.arange(1, 31)
plt.figure(figsize=(10, 6))
# set new range m, because 2^1000 is to big to show
plt.plot(n, np.log(n), label="$\log_{2} n$") # 수의 subscribt를 나타내는 LaTeX
plt.plot(n, n, label="n")
plt.plot(n, n*np.log(n), label="... |
ea3fb234b041a3eabf8a459e23de7a777d34e109 | james122823/DivideAndConquer | /week03/local_min.py | 4,294 | 3.734375 | 4 | def local_min(matrix):
"""
Assume matrix as a list of lists containing integer or floating point
values with NxN values.
"""
if len(matrix) == 2:
a = matrix[0][0]
b = matrix[0][1]
c = matrix[1][0]
d = matrix[1][1]
sort = sorted([a, b, c, d])
return so... |
cd73a1f2faa6aa7c4c7f39a12133b1a34f45ad81 | zhihao0040/CodingPractice | /sort/InsertionSort/insertionSort.py | 1,308 | 4.09375 | 4 | import sys # to get command line arguments
sys.path.append("C:/Users/61491/Desktop/Youtube/Code/CodingPractice/sort")
import sortAuxiliary
# print(sys.path)
# print(len(sys.path))
fileName = sys.argv[1]
fileDataTuple = sortAuxiliary.getFileData(fileName)
# print(fileDataTuple)
# Insertion Sort
j = 0
key = 0
for i in ... |
e95ce9ca229634753a9e4815b556d56b6d1e6d84 | joemac51/expense_tracker | /main.py | 597 | 3.78125 | 4 | import matplotlib.pyplot as plt
from random import randint
def main():
total = 1000
monthly_total = []
net_income = 0
months = ['JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC']
for i in range(12):
income = randint(800,1000)
... |
2ce9b6b91689544425656cf62e63a1db0fa6c804 | EkajaSowmya/SravanClass | /Oct5/PythonOperators/ArithmeticOperators.py | 482 | 4.0625 | 4 | a = 8
b = 2
add = a + b
sub = a - b
mul = a * b
div = a / b
mod = a % b
pow = a ** b
print("addition of {0} and {1} is {2}" .format(a, b, add))
print("subtraction of {0} and {1} is {2}" .format(a, b, sub))
print("multiplication of {0} and {1} is {2}" .format(a, b, mul))
print("division of {0} and {1} is {2}" .format(a,... |
3a1566cb54285e6f282a6e871ec37ff22caba743 | EkajaSowmya/SravanClass | /conditionalStatements/ifStatement.py | 295 | 4.25 | 4 | n1 = int(input("enter first number"))
n2 = int(input("enter second number"))
n3 = int(input("enter third number"))
if n1 > n2 and n1 > n3:
print("n1 is largest", n1)
if n2 > n3 and n2 > n3:
print("n2 is largest number", n2)
if n3 > n1 and n3 > n2:
print("n3 is largest number", n3)
|
84b07291c22afde33416f88cde4351fb0d601b97 | EkajaSowmya/SravanClass | /MyworkSpace/sqrtOfNumber.py | 662 | 3.984375 | 4 | import math # this function will import only to this file
x = math.sqrt(25)
print(x)
#math round up to nearest number..
# between 2.1 to 2.4 will be round upto to 2
# between 2.5 to 2.9 will be round upto to 3
print(math.floor(2.9)) #floor func will always rounds up to least value
print(math.ceil(2.2)) #ceil func will ... |
b05456fa275f9e3df3f2d381607ee3efbd3d2fa8 | EkajaSowmya/SravanClass | /conditionalStatements/forLoopDemo/assign3.py | 321 | 4.0625 | 4 | """1.WAP to print the following pattern below by skipping even number rows
* * * * *
* * *
*
"""
rows = int(input("Enter the number of rows: "))
for i in reversed(range(0, rows+1)):
for j in range(0, i+1):
if i % 2 == 0:
print("*", end=' ')
else:
print(end=' ')
print(... |
4cd5b2b9b4c6764e849cb01e653b9c7de4e23545 | fredcallaway/hci | /python/gui.py | 3,972 | 3.703125 | 4 | #!/usr/bin/python
"""Gui is a Tkinter Entry object cmd line interface coupled with a Tkinter Canvas object
for display and Text object for history. The cmd line accepts natural language input
and the Canvas serves as the graphical interface. """
from Tkinter import *
"""
class ObjInfo:
def __init__(self, id, name, ... |
9c8ff15b91ab3900f5007c33f615ccc06a50f740 | miljimo/pymvvm | /mvvm/argsvalidator.py | 796 | 3.703125 | 4 |
class ArgsValidator(object):
'''
@ArgValidator : this validate the argument given to make sure
that unexpected argument is given.
'''
def __init__(self,name, expected_args:list):
if(type(expected_args) != list):
raise TypeError("@ArgValidator: expecting a first object of th... |
86f5185710ab26a4789b844911a16e8399444ead | vivinraj/python4e | /ex_08/ex_08_05.py | 314 | 3.96875 | 4 | fname = input("Enter file name: ")
fh = open(fname)
count = 0
words=list()
for line in fh:
words=line.split()
if len(words)>1 :
if words[0] != 'From' :
continue
else:
word=words[1]
print(word)
count=count+1
print("There were", count, "lines in the file with From as the first word")
|
fe84ca931af6ee9ebce2b0d4013b01ea42275728 | crystal2001/U4Lesson5 | /problem5.py | 420 | 3.9375 | 4 | from turtle import *
bean = Turtle()
bean.color("black")
bean.pensize(5)
bean.speed(9)
bean.shape("turtle")
def drawStar():
for x in range(5):
bean.forward(50)
bean.left(144)
def row():
for x in range(3):
drawStar()
bean.penup()
bean.forward(70)
bean.pendown()
for y in range(4):
row()
bean.penup()
... |
22377fd49f81c618e0d106af62e713383c03ac44 | soldierloko/Fiap | /Sprint1/Socket_IP.py | 218 | 3.8125 | 4 | import socket
resp ='S'
while (resp == 'S'):
url = input("DIgite um URL: ")
ip=socket.gethostbyname(url)
print("O IP referente à URL informada é: ", ip)
resp=input("Digite <S> para continuar: ").upper |
2d2deb268503beaefa09a399ea35fab09deaa86c | rahulremanan/akash_ganga | /src/create_video.py | 1,949 | 3.78125 | 4 | """
Dependencies:
pip install opencv - python
pngs_to_avi.py
Makes all the PNGs from one dir into a video .avi file
usage: pngs_to_avi.py [-h] [-d] png_dir
Author: Avi Vajpeyi and Rahul Remanan
"""
import sys
import argparse
import glob
import cv2
import os
def make_movie_from_png(png_dir, delete_pngs=False):
... |
bb6d7d12aef583ea46f13c948dc52c61416225ac | yuyaxiong/interveiw_algorithm | /剑指offer/表示数值的字符串.py | 1,361 | 3.8125 | 4 | """
请实现一个函数用来判断字符串是否表示数值(包括:整数和小数)。
例如,字符串“+100”、“5e2”、“-123”,"3.1416"及“-1E-16”都
表示数值,但“12e”,"la3.14","1.2.3", '+-5'及’12e+5.4’
"""
class Solution(object):
def is_numeric(self, n):
num_str = [str(i) for i in range(1, 11)]
if len(n)<=0:
return False
if n[0] in ['+', '-']:
... |
f2f78e6d9900affeec2f38188471d95f25ed009a | yuyaxiong/interveiw_algorithm | /LeetCode/二叉树/652.py | 981 | 3.90625 | 4 | # Definition for a binary tree node.
# 652. 寻找重复的子树
from typing import Optional
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def findDuplicateSubtrees(self, root: Optional[TreeNode]) -> List[Optiona... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.