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
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 ...
54d13bef355f59710b0b6f7a314d86a6daf8af68
TroyJJeffery/troyjjeffery.github.io
/Computer Science/Data Structures/Week 4/CH5_EX3.py
2,347
4.5
4
""" Modify the recursive tree program using one or all of the following ideas: Modify the thickness of the branches so that as the branchLen gets smaller, the line gets thinner. Modify the color of the branches so that as the branchLen gets very short it is colored like a leaf. Modify the angle used in turnin...
952a66e0dcde2ef1da5214ba50f443b355df9d4e
PythonPostgreSQLDeveloperCourse/Section13
/2_queue/linkedlist.py
3,011
4.3125
4
from node import Node class LinkedList: """ You should implement the methods of this class which are currently raising a NotImplementedError! Don't change the name of the class or any of the methods. """ def __init__(self): self.__root = None def get_root(self): return sel...
21f0ba5e725f4dcde7406db8a215105e4402e383
gitcardoso/Pyquest
/Pyquest 1/ex_3.py
698
4.0625
4
"""Faça um programa para solicitar o nome e as duas notas de um aluno. Calcular sua média e informá-la. Se ela for inferior a 7, escrever "Reprovado”; caso contrário escrever "Aprovado".""" aluno = str(input('Digite o nome do aluno:')) nota1 = float(input('Digite a primeira nota do aluno {}:'.format(aluno))) nota2 = f...
d787c39a40fb55aff1e6eb34259254def303f9c4
walkoncross/mxnet-test-zyf
/lr_scheduler/advanced_lr_schedulers.py
15,438
3.828125
4
#!/usr/bin/env python # coding: utf-8 # # Advanced Learning Rate Schedules # # Given the importance of learning rate and the learning rate schedule for training neural networks, there have been a number of research papers published recently on the subject. Although many practitioners are using simple learning rate sc...
ea6bae24ae2729aaf178c6be03102f6d6ab8b5d1
ovravindra/SentimentAnalysis
/word_embeddings.py
10,339
3.75
4
# word embeddings are the vector representations of a word in the context. # similar words have similar embeddings, in the sence that they have similar cosine score # # %% import pandas as pd import numpy as np import nltk import matplotlib.pyplot as plt import re twitter_df = pd.read_csv('twitter_train.csv') twitt...
a11978bb1c6f16924822da8859b245108fe65de0
Wattanajit/Python
/week3/work3.py
4,026
3.578125
4
#แบบฝึกหัดที่ 3.1 """print("\tเลือกเมนูเพื่อทำรายการ") print("#"*50) print("\tกด 1 เลือกจ่ายเพิ่ม") print("\tกด 2 เลือกเหมาจ่าย") choose = int(input(" ")) #เลือกจ่ายเพิ่มหรือเหมาจ่าย km = int(input("กรุณากรอกระยะทาง กิโลเมตร\n")) #กรอกระยะทาง if choose == 1 : #เลือกแบบจ่ายเพิ่ม if km <= 25: #ถ้าไม่ถึง 25 km จ่าย 2...
4a2ebd50aeeb20316d67ac7e3262c492d97dceb4
pddpp/alogrithm-practice
/Kth-Largest-Element/solution.py
1,671
3.859375
4
class Solution: # @param k & A a integer and an array # @return ans a integer def kthLargestElement(self, k, A): # Bubble sort is time consuming, use two pointer and quick sort # This question needs review, it is a two pointer question and use the module of quick sort from "partition array" ...
b7a7a03ef0b5849bf80ebc548ae178e371a1f79b
leonardolginfo/Exercicios_python_org
/Coursera/semana_3/desafio_raiz.py
756
3.828125
4
import math a = int(input("Digite o valor de a:")) b = int(input("Digite o valor de b:")) c = int(input("Digite o valor de c:")) delta = (b**2)-4*a*c if(delta >= 0): delta_teste = math.sqrt(delta) #print("Delta =", delta_teste) if (delta < 0): print("Não existe raiz, pois o delta é menor qu...
bcaadd4ef1abe91fdbd9bb9a2c0bf906b58dd825
leonardolginfo/Exercicios_python_org
/EstruturaSequencial/calcula_salario_base_horas.py
423
3.875
4
# Faça um Programa que pergunte quanto você ganha por hora e o # número de horas trabalhadas no mês. Calcule e mostre o total do seu salário no referido mês. print() valorhora = float(input('Qual o valor da hora trabalhada? ')) qtd_horas_trabalhadas = float(input('Quantas horas trabalhou esse mês? ')) salario = valorh...
20e673cfe85c66080f258e1aca0ddc0fff6b5380
leonardolginfo/Exercicios_python_org
/EstruturaSequencial/exerc_16_latas_tintas.py
640
3.9375
4
# Faça um programa para uma loja de tintas. O programa deverá pedir o # tamanho em metros quadrados da área a ser pintada. Considere que a cobertura da tinta # é de 1 litro para cada 3 metros quadrados e que a tinta é vendida em latas de 18 litros, que custam R$ 80,00. # Informe ao usuário a quantidades de latas de tin...
d51b87217e551bafae041a03411606f6c89d5f9b
leonardolginfo/Exercicios_python_org
/EstruturaDeDecisao/exerc_3_veri_F_ou_M.py
357
4.09375
4
# Faça um Programa que verifique se uma letra digitada # é "F" ou "M". Conforme a letra escrever: F - Feminino, M - Masculino, Sexo Inválido. print() sexo = input('Digite uma letra em caixa alta para ientificar o sexo: ') if sexo == 'F': print(f'{sexo} - Feminino') elif sexo == 'M': print(f'{sexo} - Masculino')...
08639865633197e713d1d89bb5ffa8a721898a4f
leonardolginfo/Exercicios_python_org
/EstruturaSequencial/exer_12_calc_peso_ideal.py
287
3.8125
4
#Tendo como dados de entrada a altura de uma pessoa, construa um algoritmo que #calcule seu peso ideal, usando a seguinte fórmula: (72.7*altura) - 58 print() altura = float(input('Qual sua altura? ')) peso_ideal = (72.7 * altura) - 58 print() print(f'O seu peso ideal é {peso_ideal}')
829fb6b015d406292e9bebfc73817be1e3c8f7ce
vpelletier/python-prepy
/prepy.py
5,281
3.671875
4
r""" Simple python preprocessor. All keywords are on a new line beginning with "##", followed by any number of whitespace chars and the keyword, optionally followed by arguments. Names Definitions can be anything the regular expression "\w+" can match. Expressions Expressions are evaluated in python with current def...
c8e6fd0ff21b2b52effc3948ff6472ee2c0c9db0
koteswaracse/Pycharm-Prac
/Practice1.py
772
4.03125
4
#!/usr/bin/python var = 100 if ( var == 100 ) : print ("Value of expression is 100") print ("Good bye!") var1 = 'Hello World!' var2 = "Python Programming" print ("var1[0]: ", var1[0]) print ("var2[1:5]: ", var2[1:5]) var1 = 'Hello World!' print ("Updated String :- ", var1[:6] + 'Python') print ("My name is %s and ...
85c26afa478691ad15a99435f734a79453178c54
damianmc88/python-challenge
/PyBank/main.py
1,199
3.5625
4
import os import csv data = [] with open('C:/Users/damia/Desktop/UDEN201811DATA3/Week3/HW/Instructions/PyBank/Resources/budget_data.csv') as f: reader = csv.reader(f) next(reader) months=0 total=0 for row in reader: months+=1 data.append(row) total+=int(row[1]) pairs ...
9d9bb277ecea40850906449755bc6de5f39826a1
tanureuyo/uyovbievbo_story
/m/python_functions/mathfunctions.py
289
4.09375
4
""" Math Functions """ a = 27 b = 4 c = 3 # Addition / Subtraction print (a+b) print (a-b) # Multiplication / Division print (a*b) print (a/b) # Exponents print (a**b) print (b**a) # Roots print (b**(1/2)) print (a**(1/3)) # Modulus -- Only returns the remainder after division print (a%c)
9929886a03e43fa46190c72e5f13766c4e0d39f6
wise-bit/g3po
/Fractals and NCBI api (Stray functions)/cantor1.py
476
3.828125
4
import turtle t = turtle.Turtle() def cantor_loop(length, current_loop_number): t.penup() t.setposition(0, current_loop_number) t.pendown() for i in range(int(current_loop_number*3/10)): t.forward(length) if t.isdown(): t.penup() else: t.pendown() if current_loop_number == 1: current_loop_number ...
c27137e5ecbc98f3eb1ce9461b964f4b4664b455
RohithKalvakota/Cybersecurity-Algorithms
/Vernam Cipher.py
2,103
3.90625
4
print("Kalvakota Rohith") choice = input("Encryption(E/e) or Deceyption(D/d)?") if ord(choice.upper()) == 69: plaintext = input("Enter Plain Text:") key = input("Enter key:") if(len(key) == len(plaintext)): def split(pt): return list(pt) ptlist = [] for...
a0bef2e102937c13953f0aee0e0838c536572646
joshey-bit/Short_Codes
/number_series.py
505
3.609375
4
def meth_1(n): diff = 1 a0 = 1 li = [] while n > 0: a_num = a0 + (n - 1)*diff n = n - 1 li.insert(0, str(a_num)) k = "".join(li) print(k) def meth_2(n): diff = 1 a0 = 1 li = [] num = 1 while num <= n: a_num = a0 + (num - 1)*diff num = num + 1 li.append(str(a_num)) k = ...
8a00f9a865c069cf0946932a8ee0859ffc4a7d15
vinicius-hora/python_udemy
/intermeriario/aula71.py
143
3.59375
4
from itertools import count contador = count(start = 5, step = 2) for valor in contador: print(valor) if valor >=100: break