blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
f3532d2e768187aa39d756f763755bdf3ebf4f75
pilot-github/programming
/leetcode/rotateRight.py
1,646
3.984375
4
########################################################### ## Given a linked list, rotate the list to the right by k places, where k is non-negative. ## ## Example 1: ## ## Input: 1->2->3->4->5->NULL, k = 2 ## Output: 4->5->1->2->3->NULL ## Explanation: ## rotate 1 steps to the right: 5->1->2->3->4->NULL ## rotate 2...
d80e7ee5b9580fc2ac5978eef24763447b87f820
pilot-github/programming
/Sorting Algorithms/insertion_sort.py
299
3.890625
4
def insertion_sort(num): for i in range(1, len(num)): next = num[i] j = i-1 while num[j] > next and j>=0: num[j+1] = num[j] j = j-1 num[j+1] = next return num num = [19,2,31,45,6,11,121,27] print (insertion_sort(num))
82a55c0b7128beec9f63e1ffe47b1ce9ba78e26a
PabloMtzA/cse-30872-fa20-assignments
/challenge18/program.py
1,198
3.875
4
#!/usr/bin/env python3 ## Challenge 18 ## Pablo Martinez-Abrego Gonzalez ## Template from Lecture 19-A import collections import sys # Graph Structure Graph = collections.namedtuple('Graph', 'edges degrees') # Read Graph def read_graph(): edges = collections.defaultdict(set) degrees = collections.defau...
6ff19bcd3f99699c58fa6b659b9840126591e386
willianresille/Learn-Python-With-DataScience
/DSA-Python-Capitulo2-Numeros.py
773
3.84375
4
# Operações Básicas # Soma 4 + 4 # Subtração 4 - 3 # Multiplicação 3 * 3 # Divisão 3 / 2 # Potência 4 ** 2 # Módulo 10 % 3 # Função Type type(5) type(5.0) a = 'Eu sou uma String' type(a) # Operações com números float # float + float = float 3.1 + 6.4 # int + float = float 4 + 4.0 # int + int = int 4 + 4 ...
2a21f0fda2b30dc18f20e798182d285ab7f4b9e1
lepoidev/blossom
/blossom/structures.py
2,796
3.5
4
from helpers import sorted_pair # represents an undirected edge class Edge: def __init__(self, start, end, num_nodes): self.start, self.end = sorted_pair(start, end) self.id = (self.start * num_nodes) + self.end def __hash__(self): return hash(self.id) def __eq__(self, other): ...
0eb37e3ffbd4addfa7e642bfd5fe0c39032285af
gingerComms/gingerCommsAPIs
/utils/metaclasses.py
870
3.609375
4
import types class DecoratedMethodsMetaClass(type): """ A Meta class that looks for a "decorators" list attribute on the class and applies all functions (decorators) in that list to all methods in the class """ def __new__(cls, class_name, parents, attrs): if "decorators" in attrs:...
5b0ab335563146599a579b204110ff11d6b70604
DragonWolfy/hw7
/hw8.py
1,143
3.984375
4
def get_words(filename): words=[] with open(filename, encoding='utf8') as file: text = file.read() words=text.split(' ') return words def words_filter(words, an_input_command): if an_input_command==('min_length'): print('1') a=('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
70917209c731ea36c0df05a94def58233f28a736
dendilz/30-Days-of-Code
/Day 6: Let's Review
356
3.84375
4
#!/usr/bin/env python x = int(input()) for _ in range(x): string = input() new_string = '' for index in range(len(string)): if index % 2 == 0: new_string += string[index] new_string += ' ' for index in range(len(string)): if index % 2 != 0 : new_string += s...
41c20076d3e9ba1433191c4f267605ccb6b351bf
zha0/punch_card_daily
/第二期-python30天/day2 变量/基础.py
554
4.15625
4
#coding: utf-8 #pring print("hello,world") print("hello,world","my name is liangcheng") #len #输出5 print(len("hello")) #输出0 a = "" print(len(a)) #输出3,tuple b = ("a","b","c") print(len(b)) # list 输出5 c = [1,2,3,4,5] print(len(c)) # range 输出9 d = range(1,10) print(len(d)) # dict 字典 输出1 e = {"name":"liangcheng"} pr...
21007e7b568b8ec5c39231759d282ec9d77f2f49
zha0/punch_card_daily
/第二期-python30天/day4 字符串/strings.py
5,298
4.5625
5
#coding: utf-8 #创建字符串 letter = 'P' print(letter) print(len(letter)) greeting = 'Hello World' print(greeting) print(len(greeting)) sentence = "this is a test" print(sentence) # 创建多行字符串 multiline_string = '''I am a teacher and enjoy teaching. I didn't find anything as rewarding as empowering people. That is why I cre...
d29c3d2cbfc84a08e26f7128431b91a9ddacd489
zha0/punch_card_daily
/第二期-python30天/day17 异常处理(exception handling)/day17_ Unpacking.py
2,542
3.53125
4
# coding: utf-8 def sum_of_five_nums(a,b,c,d,e): return a + b + c + d + e lst = [1,2,3,4,5] # TypeError: sum_of_five_nums() missing 4 required positional arguments: 'b', 'c', 'd', and 'e' # print(sum_of_five_nums(lst)) def sum_of_five_nums(a,b,c,d,e): return a + b + c + d + e lst = [1,2,3,4,5] print(sum_of...
d5f417eb2376e467d58c96d9d31fc10a2379dff6
LakshmiSaicharitha-Yallarubailu/TSF_TASKS
/Exploratory Data Analysis-Retail.py
3,181
3.8125
4
#!/usr/bin/env python # coding: utf-8 # # THE SPARKS FOUNDATION # NAME: Y.LAKSHMI SAICHARITHA # # # 1.Perform ‘Exploratory Data Analysis’ on dataset ‘SampleSuperstore’ 2.As a business manager, try to find out the weak areas where you can work to make more profit. # In[34]: #Importing the libraries import numpy as...
8764b0e4ca1d4a8ca5c3995bddb193f959204385
skyworksinc/ACG
/ACG/VirtualObj.py
865
3.859375
4
import abc class VirtualObj(metaclass=abc.ABCMeta): """ Abstract class for creation of primitive objects """ def __init__(self): self.loc = {} def __getitem__(self, item): """ Allows for access of items inside the location dictionary without typing .loc[item] """ ...
6085c6ada49aeee0f84a290d490cf12dd683f5f3
cw2yuenberkeley/w205-fall-17-labs-exercises
/exercise_2/extweetwordcount/scripts/finalresults.py
810
3.546875
4
import sys import psycopg2 from tcount_db import TCountDB if __name__ == "__main__": if len(sys.argv) > 2: print "Please input only one or zero argument." exit() # Get DB connection c = TCountDB().get_connection() cur = c.cursor() # Check if there is exactly one argument if len(sys.argv) == 2: word = ...
feffbb540e544c11f4ff843f19f81fb5171c4de3
xuwei1997/CNN
/convelution3.py
2,227
3.53125
4
from keras.models import Sequential from keras.layers import Dense, Activation,convolutional,pooling,core import keras from keras.datasets import cifar10 if __name__ == "__main__": (X_train,Y_train),(X_test,Y_test)=cifar10.load_data() Y_train=keras.utils.to_categorical(Y_train) Y_test=keras.utils.to_categ...
172253e3166a026da90af4c7b3d4896dc3b705e3
CeriseGoutPelican/ISEN
/Python/Séance 1/Exercice 1/liste.py
2,134
3.90625
4
import sys def min_value(liste): """Permet de recuperer le plus petit element (nombre) d'une liste""" # Pour rechercher le premier element first = False # Parcours la liste list element par element for e in liste: if isinstance(e, (int, float, bool)): if first == Fa...
8e862b30b7af63b3110f0ce4efcf683f35d2bf5f
bertmclee/ML_Foundation_Techniques
/ml_foundation_hw3_pa/hw3_q8.py
3,714
3.828125
4
import numpy as np from scipy.special import softmax from collections import Counter import matplotlib.pyplot as plt import math from scipy.linalg import norm # Logistic Regression """ 19. Implement the fixed learning rate gradient descent algorithm for logistic regression. Run the algorithm with η=0.01 and T=2000, ...
9446b95ea3cb2f71014a9197aa934f03dbb12c5a
JiaoPengJob/PythonPro
/src/_instance_.py
2,780
4.15625
4
#!/usr/bin/python3 # 实例代码 # Hello World 实例 print("Hello World!") # 数字求和 def _filter_numbers(): str1 = input("输入第一个数字:\n") str2 = input("输入第二个数字:\n") try: num1 = float(str1) try: num2 = float(str2) sum = num1 + num2 print("相加的结果为:%f" % sum) exce...
15d7ba4a79abd8f79d4349d310eae243a9191960
alecordev/web-screenshotter
/web_screenshotter.py
4,034
3.546875
4
""" Module to automate taking screenshots from websites. Current features: - URLs list from file (one URL per line) given from command line - Specify one URL from command line """ import os import sys import logging import datetime import argparse from selenium import webdriver from bs4 import BeautifulSoup import r...
1be8d27189ffd3e447915108db7618325189afe4
MrClub/Poker
/dealer.py
1,427
3.53125
4
# This is a place to add all my functions # Todo Full House detection # TODO betting import random deck_of_cards = [] def deck_builder(list): # builds the deck because I'm too lazy to type everything out suit_list = ["Diamonds","Hearts","Clubs","Spades"] for suit in suit_list: for n in range(2,...
52a59e02d585be6d7a6deaaa9cf9fab5b9a7277e
R-N/lmfit-py
/examples/example_use_pandas.py
801
3.953125
4
""" Fit with Data in a pandas DataFrame =================================== Simple example demonstrating how to read in the data using pandas and supply the elements of the DataFrame from lmfit. """ import matplotlib.pyplot as plt import pandas as pd from lmfit.models import LorentzianModel ########################...
51bbbaab98e42f9dab3090417103cdaf23200f40
LSSalah/Coding-dojo-Python
/basics/Forloob2.py
1,494
3.90625
4
#Biggie Size def biggie(l): for i in range(len(l)): if l[i] > 0: print("big") else: print(l[i]) print (biggie([-1,5,5,-3])) #Count Positives def countpos(l): sum = 0 for i in range(len(l)): if l[i] > 0: sum += 1 l[-1...
b35f6f1d51bcaa483d71640b77687d6860edaba3
ChaseSnapshot/algorithms
/python/src/ChainedHashTable.py
1,756
3.6875
4
class ChainedHashTable: """ A hash table implementation that uses chaining to resolve collisions TODO: Implement this with support for providing custom hash functions """ ''' Initializes the hash table ''' def __init__(self, numBuckets): self.buckets = [] for bucketIter in rang...
b58b216d3a3b02e7e6e237c250e792d993baa384
ChaseSnapshot/algorithms
/python/src/Sort.py
10,629
4.4375
4
''' Calculates into which bucket an item belongs ''' def whichBucket(item, maxItem, numBuckets): bucket = int(float(item) * float(numBuckets - 1) / float(maxItem)) print "Item: ", item print "MaxItem: ", maxItem print "NumBuckets: ", numBuckets print "Bucket: ", bucket return bucket ''' S...
fd1257e7e33b27e828b1b67d1aac686b4fd1ef9b
Coohx/python_work
/python_base/python_class/car_old.py
2,288
4.34375
4
# -*- coding: utf-8 -*- # 使用类模拟现实情景 # Car类 class Car(): """模拟汽车的一个类""" def __init__(self, test_make, test_model, test_year): """初始化汽车属性""" self.make = test_make self.model = test_model self.year = test_year # 创建属性odometer_reading,并设置初始值为0 # 指定了初始值的属性,不需要为它提供...
0ae8cd1cdf3d35d0ba6fd20293d5c235a405cc43
Coohx/python_work
/python_base/python_unittest/name_function.py
646
3.578125
4
# -*- coding: utf-8 -*- # Date: 2016-12-23 def get_formatted_name(first, last, middle=''): """General a neatly formatted full name""" if middle: full_name = first + ' ' + middle + ' ' + last else: full_name = first + ' ' + last return full_name.title() def custom_info(city, country, po...
79bd1b686f72927ad2c94a8c27449e78e4a0fde9
Coohx/python_work
/python_base/python_class/dog.py
2,117
4.125
4
# -*- coding: utf-8 -*- # Date: 2016-12-16 r""" python class 面向对象编程 类:模拟现实世界中的事物和情景,定义一大类对象都有的通用行为 对象:基于类创建,自动具备类中的通用行为 实例:根据类创建对象被称为实例化 程序中使用类的实例 """ # 创建Dog类 # 类名首字母大写 class Dog(): # Python2.7中的类创建:class Dog(object): """一次模拟小狗的简单尝试""" # 创建实例时方法__init__()会自动运行 # self 形参必须位于最前...
428b6201575083154aed82d01c1d7e5825d26745
Coohx/python_work
/python_base/python_if&for&while/do_if.py
2,123
4.3125
4
# -*- coding: utf-8 -*- # if 语句进行条件判断 # Python用冒号(:)组织缩进,后面是一个代码块,一次性执行完 # if/else 简单判断 age = 17 if age >= 18: print('you are a adult.') print('Welcome!') else: print('You should not stay here, Go home!') # if/elif/else 多值条件判断 age = 3 if age >= 18: print('adult!') elif age > 6: print('teenager!')...
1554c10f9378b8010c8b886bd28b61c912baeef2
Coohx/python_work
/python_base/python_function/quadratic_root.py
828
4.03125
4
# -*- coding: utf-8 -*- import math # 求解一元二次方程 def quadratic(a, b, c): # 参数类型检查 if not isinstance(a, (int, float)): raise TypeError('bad operand type') elif not isinstance(b, (int, float)): raise TypeError('bad operand type') elif not isinstance(c, (int, float)): raise TypeErro...
df77a4970641d56ba65fc04971e9baf61e3914c2
naveenr414/neon-rider
/geometry.py
1,694
3.859375
4
class Rectangle: def __init__(self,x,y,width,height): self.x = x self.y = y self.width = width self.height = height def getSize(self): return (self.x,self.y,self.width,self.height) def __str__(self): return str(self.x) + " "+str(self.y) + " "+str(self.width)...
ad26bc261c977e74bba5990a2fe1aafc1d7b86b0
ameenmanna8824/PYTHON
/Day 3/Classes/Classes/p2-constructor.py
235
4.0625
4
class Car: def __init__(self,x,y): # This is a constructor self.x=x self.y=y def forward(self): print(" Left Motor Forward") print(" Right Motor Forward") bmw=Car(2,3) bmw.x=10 print(bmw.x) print(bmw.y)
8c26a4ded7c2f5c936cc4031d134db4f773f60cd
aaaadai/algorithm
/insertionSort.py
547
4.09375
4
def insertionSort(sortingList): j = 1 while (j<len(sortingList)): i = j - 1 while (i >= 0): if (sortingList[j]>sortingList[i]): break i = i - 1 insert(sortingList, j, i + 1) j = j + 1 def insert(insertingList, insertingIndex, insertedIndex): temp = insertingList[insertingIndex] j = insertingIndex...
6af698873e2e251755da7a1986981ad48926b909
dashuncel/gb_algorithm
/bda2_4.py
444
3.734375
4
#4. Найти сумму n элементов следующего ряда чисел: 1 -0.5 0.25 -0.125 ... # Количество элементов (n) вводится с клавиатуры. num = int(input('Введите число элементов ряда: ')) my_list = [1] for i in range(1, num): my_list.append(my_list[i-1] * -1 / 2) print(my_list) print(f'Сумма чисел ряда: {sum([i for i in my_l...
c76db21aebb23ceb1342e4fa4edbc0c10a0639e3
dashuncel/gb_algorithm
/byankina1_8.py
378
3.984375
4
# 8. Определить, является ли год, который ввел пользователем, високосным или невисокосным. year = (int(input("Введите год: "))) if year % 4 == 0 and (year % 100 != 0 or year % 400 == 0): print(f'Год {year} високосный') else: print(f'Год {year} не високосный')
eca11f026deccf03ba63fbd946be4219101d4395
dashuncel/gb_algorithm
/byankina1_7.py
1,042
4.1875
4
#7. По длинам трех отрезков, введенных пользователем, определить возможность существования треугольника, # составленного из этих отрезков. Если такой треугольник существует, то определить, является ли он разносторонним, # равнобедренным или равносторонним. len1 = float(input("Длина 1: ")) len2 = float(input("Длина 2: ...
737320858a090ad0c06074353d8260bebe3f0c27
dashuncel/gb_algorithm
/byankina2_9.py
497
3.84375
4
# 9. Среди натуральных чисел, которые были введены, найти наибольшее по сумме цифр. # Вывести на экран это число и сумму его цифр. COUNT = 3 my_list = [] def counter(num): summa = 0 while num >= 1: summa += num % 10 num = num // 10 return summa for i in range(COUNT): my_list.append(...
37f140d1772315b7e81152858360c9ca89801555
danvk/march-madness-data
/one_seeds_eliminated.py
828
3.71875
4
#!/usr/bin/env python3 """What's the earliest round in which all 1 seeds were eliminated""" import sys from utils import get_flattened_games def count_one_seeds(games): count = 0 for g in games: if g[0]['seed'] == 1 or g[1]['seed'] == 1: count += 1 return count def main(): game...
b4792f0558ad038836d308eedd1df18d1da3e0a8
ckoller/secretsharing
/mpc_framework/tests/arithmeticCircuits/arithmetic_circuits.py
1,595
3.5
4
from tests.circuit import ArithmeticCircuitCreator # Arithmetic circuit are created with the gates: add, mult and scalar_mult. # The gates can take gates as inputs. # c.input(3), means that we create and input gate with the id 3. class ArithmeticCircuits: def add_1_mult_2_3(self): # fx. 8+8*8 c...
f37a3a22ad3f2272e65ba5077308a6bfb5364429
ItaloPerez2019/UnitTestSample
/mymath.py
695
4.15625
4
# make a list of integer values from 1 to 100. # create a function to return max value from the list # create a function that return min value from the list # create a function that return averaga value from the list. # create unit test cases to test all the above functions. # [ dont use python built in min function, ...
e6b6e203bd5d2eb7fdc8cfe07a7ee45c57b74879
Dorsv/Blackjack_game_python
/scripts.py
4,735
3.890625
4
from random import randint from time import sleep class Card(): ''' creates card object takes in: face name (number and suit) and value/s ''' def __init__(self, face, value1, value2=0): self.name = face self.value1 = value1 self.value2 = value2 def __str...
28d199190b36dc864a26c83201d563d84a802b74
leleh5/curso_intro_python
/aula5_lista_tupla.py
812
3.828125
4
lista = [1, 3, 5, 7] lista_animal = ['cachorro', 'gato', 'elefante', 'lobo', 'arara'] tupla = (0, 2, 5, 10) #print(len(tupla)) #print(len(lista_animal)) # tupla_animal = tuple(lista_animal) # print(tupla_animal) # lista_animal_novo = list(tupla_animal) # print(lista_animal_novo) lista_animal.insert(0, 'h') print(list...
377097ce553b010a48e42f9f82c09652d5c4e746
leleh5/curso_intro_python
/aula4_lacos_repeticao.py
750
3.75
4
# a = int(input('digite um número: ')) # div = 0 # # for x in range(1, a+1): # resto = a % x # if resto == 0: # div += 1 # if div == 2: # print('O número {} é primo.'.format(a)) # # else: # print('O número {} não é primo.'.format(a)) # Números primos de 0 a 100: # for a in range(101): # div...
7b45da984eb491ba4ad63bff772688b927c6e7ef
rajasree-r/Array-2
/minMax_array.py
962
3.875
4
# Time Complexity : O(N) # Space Complexity : O(1) # Did this code successfully run on Leetcode : not in Leetcode, executed in PyCharm # Any problem you faced while coding this : no def minMax(arr): num = len(arr) # edge case if num == 0: return if num % 2 == 0: # array with even elements ...
39d2934b985efd9bc61b931bbebcd2e3fa853b87
DFYT42/Python---Beginner
/Python_Turtle_Fruitful_Function_Pattern_Gui.py
7,638
3.5625
4
##Using Python Turtle Module and user input parameters with gui dialogue boxes, ##open screen to width of user monitor and ##create repeated pattern, centered on screen, based on user input ##User parameter options: pattern size, ##pattern speed, and pattern colors. ############################################...
ae197e0c4a9273828a15a773428038fe1b5abab0
AErenzo/Python_course_programs
/ranNum.py
854
3.8125
4
import random def ranNum(): N = random.randint(1, 10) guess = 0 tries = 0 print('Im thinking of a number \nbetween 1 and 10.') while guess != N and tries < 5: guess = int(input('What do you think it might be? ')) if guess < N: print('Your gue...
77eaea810b5029891e8743479f0285675104897b
AErenzo/Python_course_programs
/timeTable.py
179
3.609375
4
def timesTables(): tt = int(input('Please enter the timetable you would like to veiw: ')) for i in range(1, 11): print(tt, 'x', i, '=', tt*i) timesTables()
fb04abbc101deaa7fcbca077676d3484952f959d
AErenzo/Python_course_programs
/gradeCal.py
361
4.03125
4
def gradeCal(): grade = int(input('Please enter your grade from the test: ')) if grade >= 70: print('Your score an A+') elif grade >= 60: print('You scored an A') elif grade >= 50: print('You scored a B') elif grade >= 40: print('You socred a C') else: ...
4d6cdd8085636c356181b0b859827bb7fe109009
AErenzo/Python_course_programs
/usernamePasswordCheck.py
431
3.875
4
'''p u''' while True: U = input('Please enter your username: ') if U.isalnum(): break else: print('Username must consist of alphanumeric values') while True: P = input('Please enter your password: ') if P.isnumeric() and len(P) < 11: break else: ...
abd6d1be349ee7042e1e2e2c3e5be88f6e98acaf
AErenzo/Python_course_programs
/reversePyramid.py
212
3.859375
4
for i in range(1, 7): # below determines the spaces for each new line, to create the reverse pyramid affect print(" " * (7 - (8 - i))) for j in range(1, 8 - i): print(j, end = " ")
cf53362a8c3de1db8106e18d29e6c642a2a2dc13
AErenzo/Python_course_programs
/studentSubjectMatrix.py
4,706
3.875
4
students = ['maaz', 'farooq', 'maria', 'aslam'] subjects = ['math', 'physics', 'chemistry', 'biology'] matrix = [[0]*4 for i in range(4)] total = 0 for i in range(4): for j in range(4): matrix[i][j] = int(input('Please enter student marks for the matrix: ')) for i in matrix: for j in i...
f289bd52b2eaf19d4e34ec72b37345af0f747d05
AErenzo/Python_course_programs
/acronym.py
640
4.21875
4
phrase = input('Please enter a phrase: ') # strip white spacing from the phrase phrase = phrase.strip() # change the phrase to upper case phrase = phrase.upper() # create new variable containing the phrase split into seperate items words = phrase.split() # create empty list for first letter of each it...
554862cc48f286e7707a456f21794f69972ff7e3
AErenzo/Python_course_programs
/List.py
367
4.0625
4
List = [] Sum = 0 for i in range(5): item = int(input('What would you like to add to your list? ')) List.append(item) if len(List) == 5: print('Your list contains', List) for j in range(len(List)): Sum = List[j] + Sum print('The sum of your list is ', Sum) print('The aver...
b63899e121f4b30e778a5b630a0768af218ea707
julianalvarezcaro/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/101-remove_char_at.py
194
3.71875
4
#!/usr/bin/python3 def remove_char_at(str, n): posn = 0 new = '' for pos in range(0, len(str)): if pos == n: continue new = new + str[pos] return new
136a6aa0c778ac61364395fc5ccc046994d1a2c5
julianalvarezcaro/holbertonschool-higher_level_programming
/0x02-python-import_modules/iwasinalpha.py
125
3.765625
4
#!/usr/bin/python3 def alpha(): for letter in range(65, 91): print("{}".format(chr(letter)), end='') print()
ea71e69d6846d08c7cbb47cd6c37c0b6ef533f35
julianalvarezcaro/holbertonschool-higher_level_programming
/0x0A-python-inheritance/4-inherits_from.py
277
3.5
4
#!/usr/bin/python3 """4-inherits_from module""" def inherits_from(obj, a_class): """Checks if an object is and instance of a class that inherited from a_class""" if issubclass(type(obj), a_class) and type(obj) is not a_class: return True return False
f028bde75c24f7d2eec83ee24a638d0240b5628c
julianalvarezcaro/holbertonschool-higher_level_programming
/0x06-python-classes/6-square.py
1,780
4.40625
4
#!/usr/bin/python3 """6-square module""" class Square: """Square class""" def __init__(self, size=0, position=(0, 0)): """Class constructor""" self.size = size self.position = position def area(self): """Returns the area of the square""" return self.__size * self._...
839885965d7d384e0e645c5f54d7d870c0614e42
julianalvarezcaro/holbertonschool-higher_level_programming
/0x03-python-data_structures/5-no_c.py
247
3.65625
4
#!/usr/bin/python3 def no_c(my_string): new = "" if len(my_string) == 0: return new for pos in range(len(my_string)): if my_string[pos] != 'c' and my_string[pos] != 'C': new += my_string[pos] return new
80439397baa335d5433916eb296174eca263d8c1
ieshaan12/Interview-Prep
/LeetCode/Problems-Python/543 Diameter of a Binary Tree.py
666
3.71875
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 inOrder(self,root): if not root: return 0 right = self.inOrder(root...
1cbf67a80aae5b7491a9c948526447f37f1a809c
ieshaan12/Interview-Prep
/LeetCode/Problems-Python/166 Fraction to Recurring Decimal.py
1,013
3.5
4
class Solution: def fractionToDecimal(self, numerator: int, denominator: int) -> str: ans = "" if numerator == 0: return "0" if (numerator<0 and not denominator<0) or (not numerator<0 and denominator<0): ans += "-" numerator = abs(numerator) d...
2bfd45022f083535fbd56167c016c9252367ca1e
ieshaan12/Interview-Prep
/LeetCode/Problems-Python/199 Binary Tree Right Side View.py
769
3.703125
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 inOrder(self,root,depth): if root: self.lists.append((root.val,depth)) ...
4eed791e27a4f5ca9c6a45625d41113b3d38e701
ieshaan12/Interview-Prep
/LeetCode/Problems-Python/344 Reverse String.py
250
3.703125
4
class Solution: def reverseString(self, s: List[str]) -> None: """ Do not return anything, modify s in-place instead. """ t = len(s) for i in range(t//2): s[i],s[t-i-1] = s[t-i-1],s[i]
dc4b0a658270447c6907b32b892c3965402a1fcb
DhavalLalitChheda/class_work
/Programs/ConvertCelsiusToFahreneit.py
211
4.1875
4
def convertToFahreneit(temp_Celsius): return temp_Celsius * 9 / 5 + 32 temp_Celsius = float(input("Please enter temp in celsius: ")) print("The temperature in Fahreneit is: ", convertToFahreneit(temp_Celsius))
62197b8a530277f020699d7dafcfb06c5d97e5ad
DhavalLalitChheda/class_work
/Programs/ReturnMiddleList.py
116
3.8125
4
def middle(list): return list[1 : len(list) - 1] letters = ['a', 'b', 'c', 'd', 'e','f'] print(middle(letters))
c093d77031e4dcb7058ad3823203a23ab3641ba0
DhavalLalitChheda/class_work
/Programs/ReadInsertList.py
323
3.953125
4
file = input('Please enter valid file: ') try: fHandle = open(file) except: print('File does not exist') exit() try: list = [] for line in fHandle: words = line.split() for i in words: if i in list: continue; list.append(i) list.sort() print(list) except: print('File contains no data') exi...
73823a8daba83bbeeeb5c1c34e25283ccb0f0c28
aleix214/Bucles-white
/mayorK05.py
279
3.8125
4
#coding: utf­8 num1 = int(input("Escribe un número: ")) suma=0 while num1 > 0: suma+=num1 num1 = int(input("Escribe otro: ")) print "El total de la suma de los numeros positivos es:", str(suma) + "."
415f457124953e2159fad841f84d986103145636
putonsky/jb_loan_calculator
/creditcalc.py
4,318
4.0625
4
import math import argparse # Creating a function calculating nominal interest rate (i) def nominal_interest_rate(interest): i = interest / (12 * 100) return i # Creating the function for calculating the number of payments def calculate_payments_number(p, a, interest): i = nominal_interest_rate(interes...
de46edfe66ee6a76c0827d4957b4b720fb71b1a3
wmcknig/Advent-of-Code-2020
/day5.py
2,028
4.03125
4
from sys import argv """ Advent of Code Day 5 Part 1 You are given a list of strings where each string consists of the characters F, B, L, or R, meaning front, back, left, or right, respectively. The strings consist of 10 characters, the first seven of them being F or B and the latter three being L or R. The fi...
6d84ceebf81c8d7df78041d4a6a063b0a77cd651
wmcknig/Advent-of-Code-2020
/day14.py
3,725
4.375
4
from sys import argv """ Advent of Code Day 14 Part 1 You are given a series of instructions either of the form "mask = STRING" or "mem[ADDR] = VAL", where STRING is a 36-element string of X, 1, or 0, ADDR is a decimal integer, and VAL is a decimal string, both expressible as 36-bit unsigned integers. These ins...
042ccd0b5581f59ed89b021382c6aebee009c1fc
wmcknig/Advent-of-Code-2020
/day12.py
4,700
4.3125
4
from sys import argv """ Advent of Code Day 12 Part 1 You are given a series of instructions for navigating along a grid of the following forms: -NC, SC, EC, WE for north, south, east, or west C units (C is a non-negative integer) -LD, RD for turning left or right by D degrees (D is non-negative multiple of 9...
280d9f887fd4f0d898dc5974adea5e9bb625c329
alewand78/Python
/Calculator.py
545
3.9375
4
def doMath(a, b, operation): if operation == 1: return str(a + b) elif operation == 2: return str(a - b) elif operation == 3: return str(a * b) elif operation == 4: return str(round(a / b, 2)) else: return str(a % b) a = int(input("Enter first number :...
b2e9bd595ba9f8be888acef9ddc95f77166b403b
fredcommo/datasci_course_materials
/assignment3/solutions/friend_count.py
681
3.546875
4
import MapReduce import sys """ Count friends If personA is linked to personB: personB is a friend of personA, but personA can be not a friend of personB. """ mr = MapReduce.MapReduce() # ============================= # Do not modify above this line def mapper(record): # key: personA # value: 1 is as a frie...
2aca9b20394221e74b27da128aafd95ff4455ccc
capt-alien/alien_refactor
/strings.py
1,781
3.859375
4
def life(count, secret_word): """Gives life count after guess""" if count == 7: print("V") print("O") if count == 6: print("V") print("O") print("|") if count == 5: print(" V") print(" O") print(" |") print("/") if count == 4: ...
c40ca095e76f7040ef231e426975e22d4c3bd26d
pylangstudy/201711
/22/00/4.py
833
3.515625
4
import argparse # sub-command functions def foo(args): print(args.x * args.y) def bar(args): print('((%s))' % args.z) # create the top-level parser parser = argparse.ArgumentParser() subparsers = parser.add_subparsers() # create the parser for the "foo" command parser_foo = subparsers.add_parser('foo') par...
31e3e267e80cad6472c1ae0fa969f988c88dec89
pylangstudy/201711
/19/01/6.py
221
3.515625
4
import argparse import textwrap parser = argparse.ArgumentParser(prog='PROG', prefix_chars='-+') parser.add_argument('+f') parser.add_argument('++bar') print(parser.parse_args('+f X ++bar Y'.split())) parser.print_help()
b0bea18fc3d48dd1bda2e83ff52e589c7f54d1bf
kshitijgupta/all-code
/python/A_Byte_Of_Python/objvar.py
1,130
4.375
4
#!/usr/bin/python #coding=UTF-8 class Person: '''Represents a person.''' population = 0 def __init__(self, name): '''Initializes the person's data.''' self.name = name print '(Initializing %s)' % self.name Person.population += 1 def __del__(self): '''I am dying''' print '%s syas bye.' % self.name ...
d72f79ad097f5eace2fcb22d0471c0d3424290ac
elYaro/Codewars-Katas-Python
/8 kyu/Convert_number_to_reversed_array_of_digits.py
320
4.21875
4
''' Convert number to reversed array of digits Given a random number: C#: long; C++: unsigned long; You have to return the digits of this number within an array in reverse order. Example: 348597 => [7,9,5,8,4,3] ''' def digitize(n): nstr = str(n) l=[int(nstr[i]) for i in range(len(nstr)-1,-1,-1)] return l
ae32fe698d8afb7b31a70999c9875af162c2dbe6
elYaro/Codewars-Katas-Python
/8 kyu/Is_it_a_number.py
582
4.28125
4
''' Given a string s, write a method (function) that will return true if its a valid single integer or floating number or false if its not. Valid examples, should return true: isDigit("3") isDigit(" 3 ") isDigit("-3.23") should return false: isDigit("3-4") isDigit(" 3 5") isDigit("3 5") isDigit("zero") ''' def i...
3a50733a988cee4b84b30465185774de479efee3
elYaro/Codewars-Katas-Python
/8 kyu/Sum_of_positive.py
352
4.09375
4
''' You get an array of numbers, return the sum of all of the positives ones. Example [1,-4,7,12] => 1 + 7 + 12 = 20 Note: if there is nothing to sum, the sum is default to 0. ''' def positive_sum(arr): if arr!=[]: suma=0 for i in arr: if i >0: suma=suma+i return...
8b34ef774c1f41255d399714c2792da64f291fcb
elYaro/Codewars-Katas-Python
/8 kyu/You_only_need_one_Beginner.py
290
3.59375
4
''' You will be given an array (a) and a value (x). All you need to do is check whether the provided array contains the value. Array can contain numbers or strings. X can be either. Return true if the array contains the value, false if not. ''' def check(seq, elem): return elem in seq
ba06a43362449d7f90a447537840c42b591b8adf
elYaro/Codewars-Katas-Python
/8 kyu/String_cleaning.py
955
4.125
4
''' Your boss decided to save money by purchasing some cut-rate optical character recognition software for scanning in the text of old novels to your database. At first it seems to capture words okay, but you quickly notice that it throws in a lot of numbers at random places in the text. For example: string_clean('! !...
ca9334b0325fdbe0e9d4505dd4ab89649d0628f3
elYaro/Codewars-Katas-Python
/8 kyu/Find_Multiples_of_a_Number.py
708
4.59375
5
''' In this simple exercise, you will build a program that takes a value, integer, and returns a list of its multiples up to another value, limit. If limit is a multiple of integer, it should be included as well. There will only ever be positive integers passed into the function, not consisting of 0. The limit will a...
0e771ee2e4afebdcb615e419c37779f44776ae0f
elYaro/Codewars-Katas-Python
/7 kyu/Find_twins.py
490
3.796875
4
''' Agent 47, you have a new task! Among citizens of the city X are hidden 2 dangerous criminal twins. You task is to identify them and eliminate! Given an array of integers, your task is to find two same numbers and return one of them, for example in array [2, 3, 6, 34, 7, 8, 2] answer is 2. If there are no twins in t...
79d418430029288067984d7573880866b3e43328
elYaro/Codewars-Katas-Python
/7 kyu/KISS_Keep_It_Simple_Stupid.py
1,093
4.34375
4
''' KISS stands for Keep It Simple Stupid. It is a design principle for keeping things simple rather than complex. You are the boss of Joe. Joe is submitting words to you to publish to a blog. He likes to complicate things. Define a function that determines if Joe's work is simple or complex. Input will be non emtpy st...
0dccf695f2c3a3b8db544619fdb07159eb250847
hacker653/Hash-Cracker
/Hash- cracker/crack.py
1,291
3.828125
4
import hashlib print(""" _ _ _ _____ _ | | | | | | / ____| | | | |__| | __ _ ___| |__ ______ | | _ __ __ _ ___| | _____ _ __ | __ |/ _` / __| '_ \ |______| | | | '__/ _` |/ __| |/ / _ \ '__| | ...
c35fc57fec26636282eba11ea122628c8a07c0a3
ericaschwa/code_challenges
/LexmaxReplace.py
1,192
4.34375
4
""" LexmaxReplace By: Erica Schwartz (ericaschwa) Solves problem as articulated here: https://community.topcoder.com/stat?c=problem_statement&pm=14631&rd=16932 Problem Statement: Alice has a string s of lowercase letters. The string is written on a wall. Alice also has a set of cards. Each card contains a single let...
9bd2566b812d15348a25c877936fe84716989ba6
jupiny/PythonPratice
/code/print_star.py
1,079
3.5625
4
def print_star1(count): """ 첫번째 별찍기 함수 """ for i in range(count): print("*" * (i+1)) def print_star2(count): """ 두번째 별찍기 함수 """ for i in range(count): print(" " * (count - i - 1) + "*" * (i + 1)) def print_star3(count): """ 세번째 별찍기 함수 """ for i in range(...
f8ea64652ce06b2f434a7cb2499365f06a0b3f0b
limingrui9/1803
/1.第一个月/07day/3.计算器.py
313
4
4
print("*****这是一个神奇的计算器*****") a = float(input("请输入一个心仪数字")) b = float(input("请输入一个数字")) fuhao = input("请输入+-×/") if fuhao == "+": print(a+b) elif fuhao == "-": print(a-b) elif fuhao == "×": print(a*b) elif fuhao == "/": print(a/b)
4874333b6f5467713260714f07fd1ba357881dbe
limingrui9/1803
/1.第一个月/20day/2-wangzhe.py
1,266
3.65625
4
list = [] def register(): account = int(input("请输入账号")) pwd = input("请输入密码") #判断账号存在不存在 flag = 0 for i in list: if account == i["account"]: print("账号已经存在") flag = 1 break if flag == 0: dict = {} dict["account"] = account dict["pwd"] = pwd list.append(dict) print("注册成功") def login(): a...
7f2150fa8cb19d1dd0c6b87bc5274bc0f1648418
limingrui9/1803
/2-第二个月/16day/1-多线程非全局变量.py
317
3.5
4
from threading import Thread import time import threading def work(): name = threading.current_thread().name print(name) numm = 1 if name == "Thread-1" num+=1 time.sleep(1) print("呵呵呵%d"%num) else: time.sleep(1) print("哈哈哈%d"%num) t1 = work()
3a1efb41dab0012141e77237084d0b11337fce7d
limingrui9/1803
/1.第一个月/08day/8-三角形.py
128
3.765625
4
count = 1 while count<=5: if count<=5: print("*"*count) if count>10: print("*"*(10-count)) count+=1
d78887854013f18fe02f258ae8adf75929244c41
limingrui9/1803
/1.第一个月/07day/1.微信登录.py
135
3.5
4
a_passwd = "123" passwd = input("请输入密码") if passwd == a_passwd: print("密码正确") else: print("请从新输入")
7df8dee9fddf614952305e829d0a0e45f159f534
LiYingbogit/pythonfile1
/03_面向对象/ustc_04_家具类.py
1,326
3.96875
4
class HouseItem: def __init__(self, name, area): self.name = name self.area = area # print("初始化") def __str__(self): return "[%s]占地[%s]平米" % (self.name, self.area) class House: def __init__(self, house_type, area): self.house_type = house_type self.area = a...
906cc9e6a8d5aa97f6d0327c73d58fb2a8a14a21
LiYingbogit/pythonfile1
/05_文件操作/ustc_01_读取文件.py
582
3.84375
4
# _*_coding:utf-8_*_ # 1.打开文件 # file = open("README", encoding='UTF-8') # with open("README", 'r', encoding='UTF-8') as file: # # 2.读取文件 # text = file.read() # print(text) file = open("README", 'r', encoding='UTF-8') text = file.read() print(text) # 文件指针的概念,当第一次打开文件时,通常文件指针会指向文件的开始位置,当执行read方法后,文件指针会移动到读取内容...
f41130f09592bc6201cc088b49ee2ddab0f8deae
lintgren/EDA132
/src/LAB2/Tree.py
1,043
3.8125
4
class Tree(object): "Generic tree node." def __init__(self, name='root',values =[] ,children=None): self.name = name self.values = values self.children = [] if children is not None: for child in children: self.add_child(child) def __repr__(self): ...
a10242f6ed3268cad16740d2a072e5851cff7816
Bhaney44/Intro_to_Python_Problems
/Problem_1_B.py
1,975
4.28125
4
#Part B: Saving, with a raise #Write a program that asks the user to enter the following variables #The starting annual salary #The semi-annual raise #The portion of the salary to be saved #The total cost of the dream home #Return the number of months to pay for the down payment. starting_annual_salar...
2cac2a4335a4e564c4a40868555a1e763488ae32
francis95-han/python-study
/algorithm/data_structure/热土豆问题.py
1,294
3.53125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' 热土豆问题也称作 Josephus 问题。这个故事是关于公元 1 世纪著名历史学家Flavius Josephus 的,传说在犹太民族反抗罗马统治的战争中, Josephus 和他的 39 个同胞在一个洞穴中与罗马人相对抗。当注定的失败即将来临之时,他们决定宁可死也不投降罗马。于是他们围成一个圆圈,其中一个人被指定为第一位然后他们按照顺时针进行计数, 每数到第七个人就把他杀死。传说中 Josephus 除了熟知历史之外还是一个精通于数学的人。他迅速找出了那个能留到最后的位置。最后一刻,他没有选择自杀而是加入了罗马的阵营。这个故事还有...
b5200bfe1c433f011bdd4a73e54343ccc6e0c129
francis95-han/python-study
/algorithm/sort/希尔排序.py
805
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 算法复杂度O(n^(3/2)) def shellSort(alist): sublist_count = len(alist)//2 while sublist_count > 0: for start_position in range(sublist_count): gapInsertionSort(alist,start_position,sublist_count) print("After increments of size",sublist_coun...
61fca1a552524037498739e3ca02c1f34a1af459
LutherCS/aads-class-pub
/src/exercises/binheapmax/binheapmax.py
1,274
3.5625
4
#!/usr/bin/env python3 """ Binary Heap implementation @authors: @version: 2022.9 """ from typing import Any class BinaryHeapMax: """Heap class implementation""" def __init__(self) -> None: """Initializer""" self._heap: list[Any] = [] self._size = 0 def _perc_up(self, cur_idx: i...
00d06440311ac21983118a1cd26aeac53fb79679
PanDeBatalla94/AT06_API_Testing
/MariaCanqui/session_4/practice4/regular_expressions.py
1,302
4.03125
4
import re #Add a method that is going to ask for a username : def ask_username(): username = verify_username(input("enter username(a-z1-9 ): ")) return username #Need to be write with lowercase letter (a-z), number (0-9), an underscore def verify_username(name): while True: if re.fullmatch("([a-z0...
22bcd98ec42268d83ffa618ca9931f36b9582353
TroyJJeffery/troyjjeffery.github.io
/Computer Science/Data Structures/Week 3/CH3_EX10.py
2,066
4.0625
4
""" Implement a radix sorting machine. A radix sort for base 10 integers is a mechanical sorting technique that utilizes a collection of bins, one main bin and 10 digit bins. Each bin acts like a queue and maintains its values in the order that they arrive. The algorithm begins by placing each number in the main ...