blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
aae08efd0249e31e2612453e53d5dfdc5644712f
codewithgsp/text-based-browser
/Problems/Prefix/task.py
197
4.09375
4
def has_prefix(word, prefix): if word.startswith(prefix): return True prefix = input() words = input().split() for word in words: if has_prefix(word, prefix): print(word)
542880689da5d6aef5875e2250645ce0971ea139
hebertmello/pythonWhizlabs
/estudo_map.py
310
4
4
# Map 01 # ------------------------------------- list1 = [1, 3, 5] list2 = [2, 4, 6] result = list(map(lambda x, y: x + y, list1, list2)) print(result) # Map 02 # ------------------------------------- list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] map1 = map(lambda x: x * 5, list1) print(list(map1))
8a897442ebf940c5c6aeccae014166d7334d6bfe
kverdone/euler
/p009.py
770
3.78125
4
import sys import math def main(x): ''' Find a pythagorean triple where the sum of the legs is equal to x. ''' a = -1 c = -1 b = 3 sum = -1 while sum != x: if b % 2 == 1: mn = 2 * b odd = True else: mn = b / 2 odd = False lst = facPairs(mn) for m,n in lst:...
4eed32b7af03dd448dbab19ae97ccee5efce5597
rarch/codeeval
/easy/longestword.py
734
4.03125
4
#!/usr/bin/env python import sys """Sample code to read in test cases: import sys test_cases = open(sys.argv[1], 'r') for test in test_cases: # ignore test if it is an empty line # 'test' represents the test case, do something with it # ... # ... test_cases.close() """ def main(): # read file ...
0ca64435218b8ba34a7995425e2fbfbe71ad1cd2
SupriyaPT/PythonPrograms
/Basics/enumerator_example.py
104
3.90625
4
a = [1, 2, 3] for index,ele in enumerate(a): print("Element {0} is at index {1}".format(ele,index))
b271360b8e96bbb962468f32f4d4846f45d2e245
crystalbai/Algorithm
/IntegerToRoman.py
595
3.5
4
from collections import OrderedDict my_dictionary=OrderedDict() class Solution(object): def intToRoman(self, num): """ :type num: int :rtype: str """ val = OrderedDict([(1000,'M'), (900, 'CM'), (500,'D'), (400,'CD'), (100,'C'), (90,'XC'), (50,'L'), (40, 'XL'), (10,'X'), (9,'I...
94e19f7c9b23397fe7a6d8698add3c12b594a45b
Sasuke214/DataStructureImplementation
/tries.py
1,352
3.59375
4
class Tries: def __init__(self): self.children=[None]*26 self.size=0 def getCharIndex(self,c): return ord(c)-ord('a') def setChild(self,value,child): self.children[self.getCharIndex(value)]=child def getChild(self,value): return self.children[self.getCh...
94c84e2efb82deaaddcee2310f1131075372b18e
narasimhareddyprostack/python-Aug-7PM
/Operators/isop.py
387
3.859375
4
a = 50 b = a print( a == b) #True print (a is b) # True print("******") list1 = [1,2,3,"four"] list2 = [1,2,3,"four"] print(list1 == list2) # True print(list1 is not list2) # False # when you have to compare content ,use == # when you have to compare object ref , use is """ a = 5 str1= " Hello" list1 = [1,2...
63f31a050c1417b56edeca72e69d30ea34951e7e
JungAh12/BOJ
/1924.py
377
3.796875
4
def rule(month, day): days = [31,28,31,30,31,30,31,31,30,31,30,31] week = ['SUN','MON','TUE','WED','THU','FRI','SAT'] ret = 0 for i in range(0, month-1): ret += days[i] ret += day ret %= 7 return week[ret] if __name__ == '__main__': date = input() date = date.split(' ') ...
f55cb0869a7ac6b6b87ae0bf991f5f4bbf55224b
a5eeM/PWB
/Ch 01/ex_31_sum_digits_integer.py
322
3.96875
4
""" display sum of digits of a four digit integer """ # Get Input number = int(input("Enter any 4 digut number: ")) # Compute n1 = number % 10 number = number // 10 n2 = number % 10 number = number // 10 n3 = number % 10 number = number // 10 # Display print(f"{number} + {n3} + {n2} + {n1} = {number + n3 + n2 + n1}"...
724462377a6e2acdfed08a9a098b66389656f8ee
ggdecapia/FrogRiverOne
/AllSolutions.py
5,136
3.796875
4
# I think it's worth noting how the logical solutions improved as I tried to achieve 100% ###SOLUTION 1### A = [5, 3, 1, 1, 2, 3, 5, 4] X = 5 array_len = len(A) ctr = 0 # check if all elements are in the array for i in range(1,X+1): if i in A: ctr += 1 if ctr == X: # find the earliest position of each e...
316d21dddb37c035bc3c4d30bc8b84341c7d5967
saxAllan/gaei2
/dev/s_test/VRML/output.py
983
3.546875
4
filename_i = input("入力ファイル名(拡張子は不要):") print(filename_i + ".txtを読み込んでいます... ") f = open(filename_i + ".txt", "r") lines = f.readlines() orgdata = [] for i in lines: orgdata.append(list(map(float, i.split()))) f.close() size_org = len(orgdata) print("読込完了 (", size_org, "行)") out=str("\n") out+=("DEF TS3 TimeSenso...
157616d8f8538ce116f5d0800792a26c9304f7ed
balalex12/PracticesPython
/Various/Various_Python_Challenges.py
2,196
4.125
4
#Calculate sum of all numbers included in the list. num_list = [0,1,2,3,4,5] def list_sum(num_list): sum = 0 for num in num_list: sum += num print("The sum is "+str(sum)) list_sum(num_list) #Show a random number from a list. import secrets x = [0,1,2,3,4,5] print(secrets.choice(x)) ...
c48a806ef3fdc14ae0d397111775a0acf7ee23f1
multiojuice/advent2017
/passphrase.py
549
3.734375
4
import math def passphrase(lst): dic = {} for e in lst: if e in dic: return 0 else: dic[e] = 1 return 1 def anagram(lst): dic = {} for e in lst: e = ''.join(sorted(e)) if e in dic: return 0 else: dic[e] = 1 ...
87b56dc764d3a6789852da7b59bab00879fc9da8
thrama/coding-test
/python/multiset.py
821
3.8125
4
class Multiset: def add(self, val): # adds one occurrence of val from the multiset, if any pass def remove(self, val): # removes one occurrence of val from the multiset, if any pass def __contains__(self, val): # returns True when val is in the multiset, else retur...
81f7746fff38b38a42b5a207b7d5d61d709f6b57
yagmurerdem123/Machine-Learning-
/linear_regression_python.py
839
3.75
4
import numpy as np import pandas as pd from sklearn.linear_model import LinearRegression as lr import matplotlib.pyplot as plt data=pd.read_csv("linear.csv") print(data) x=data["metrekare"] # veri setindeki metrekare x eksenine ait olacaktır. y=data["fiyat"] #veri setindeki fiyat y eksenine ait olacaktır. ...
ed15ff0be9a15f8bee20380b731ea406d7333be8
maruichen2004/LeetCode
/Reorder_List.py
896
3.78125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @param head, a ListNode # @return nothing def reorderList(self, head): if head is None or head.next is None: return head fast, slow, prev =...
ae48b100ba100c5619cdb7828bb7bff4c95d703d
arnabs542/python_leetcode
/binary_search/rotated_sorted_array_search_2_with_duplicate.py
1,872
3.703125
4
""" 做此题时发现,之前的解答一个都不能用,有序数组中有重复元素时,peak_index和min_index的搜索结果会是错的 这个二分模板是个特例,end的初始值必须是len(nums)而且最坏情况比直接遍历还慢 所以倒不如直接用 return target in nums 在lintcode上都有Your submission beats 91.00% Submissions!的性能 """ from typing import List import unittest # 我还是喜欢这种解法,官方解答分了好多种情况讨论,不太好背诵 # 不求甚解,慢慢领悟这种隐含的边界条件(为什么end一定要等于len(nums)) de...
3b95637f6ba9c4c558934ec8222bb0f6aca44acd
silencerfy/myStuff
/Tax_Calculator.py
365
4.46875
4
#!usr/bin/python #Tax Calculator - Asks the user to enter a cost and either a country or state tax. It then returns the tax plus the total cost with tax. cost = int(raw_input("What is the cost? ")) tax_rate = float(raw_input("What is the tax rate? Please enter in decimal form. ")) tax = cost*tax_rate print "Tax = " + s...
4684abf419ea5da5ffee95139881de5b4089623c
kunal21raut/learnGitRepo
/add_no.py
170
3.796875
4
class add: def add(self): self.a=4 self.b=5 print("Addition of two numbers :",(self.a+self.b)) a=add() a.add() print("THANK YOU !!")
004c42dd79a219b8385b0714dc4fe0cc9147da52
reemahs0pr0/Data-Structures-and-Algorithm
/Graph Algorithms.py
1,049
3.765625
4
import collections def dfs(graph, start, visited = None): if visited is None: print("DFS: ", end="") visited = set() visited.add(start) print(start, end=" ") for vertex in graph[start]: if vertex not in visited: dfs(graph, vertex, visited) def bfs(graph, start): ...
322a0c9b15d98e4fafbc4dc546132ff5837b8b73
DerrickWango/Projects-final
/Alg/Numname.py
13,171
3.984375
4
def numnameint(*args): ''' A function that returns a number in words usage: num_name(args) ''' dct_ones={ 'one':1,'two':2,'three':3,'four':4,'five':5,'six':6,'seven':7,'eight':8,'nine':9,'zero':0, 'eleven':11,'twelve':12,'thirteen':13,'...
a38735f9ed98330c59a9c53775375067c1c3663d
alicia-mctc/capstone_week2lab
/author_class.py
726
3.78125
4
class Author: try: def __init__ (self, name): self.name = name self.books = []#empty list is created to hold books def publish(self, title): self.books.append(title)#append () method adds title to book list def __str__(self): title = ', '.j...
631a66ce1fdd063612407617a3b0af2218e49c7e
alexander-lakocy/command-line-pandemic
/Pandemic_Web_Scraper.py
1,989
3.59375
4
# -*- coding: utf-8 -*- """ Created on Mon Jan 15 19:11:52 2018 @author: alakocy """ import wikipedia def dist_between(cityA,cityB): #Still needed return 1 def find_pop(city): try: pt = wikipedia.page(city,"lxml") print("As-is") except: pt = wikipedia.page(city+" City","lxm...
b254a308713d8be6231e3ec08fc5605bbbbc8473
wen-chen/My_Script
/BioInfo/func/find_position_list.py
341
3.734375
4
# -*- coding: utf-8 -*- """ Created on Mon Jul 30 16:40:41 2018 @author: chenw """ def find_position_list(sub_string, string): position_list = list() position = string.find(sub_string) while position != -1: position_list.append(position) position = string.find(sub_string, position + 1) ...
7200ec4ac6b31dd4e9f9c97aac0f4124c6fa8b5e
isk02206/python
/informatics/Tutor 2017-2018 (2)/Rovarspraket.py
2,669
3.640625
4
''' Created on 2018. 1. 14. @author: TaeWoo ''' ''' >>> encode('robber language') 'rorobbobberor lolangonguagoge' >>> encode('Kalle Blomkvist') 'Kokallolle Bloblomkvomkvistost' >>> encode('Astrid Lindgren') 'Astrostridod Lolindgrondgrenon' ''' def encode(sentence): vowel = ['a', 'e', 'i', 'o', 'u', "'", ',...
68164b86d0e80b16f380473b3499e26ca1e13415
betchart/triangle
/triangle.py
2,907
3.6875
4
#!/usr/bin/env python import copy class TriBoard(object): def __init__(self, size): self.size = size self.points = set() return def copy(self): cpy = TriBoard(self.size) cpy.points = copy.deepcopy(self.points) return cpy def open(self, p): i,j ...
de9ced6eceb33401c7de5b8e67b69f689e2241d6
Aecio1001/Pedra-Papel-e-Tesoura
/Pedra_Papel_e_tesoura.py
4,577
3.765625
4
import random moves = ['pedra', 'papel', 'tesoura'] class Player: def move(self): return 'pedra' def learn(self, my_move, their_move): pass class Player(Player): def move(self): return 'pedra' class RandomPlayer(Player): def move(self): self.their_move = random.choice(moves)...
e513c5ab9740b3d1214f94ffbec97972c5a4879f
manojakondi/geeks4geeksPractice
/frequencySort.py
337
4.1875
4
""" Given an array containing integers, in which the elements are repeated multiple times. Now sort the array wrt the frequency of numbers. """ from collections import Counter list = [1,2,3,4,3,3,3,6,7,1,1,9,3,2] print(list) counts = Counter(list) print(counts) newList = sorted(list, key=counts.get, reverse=True)...
efee079ebea3e18ad714b2e34d3787b5f825d294
Bruna-Fernandes/Python
/05_SomarDiasPassados.py
371
3.78125
4
# 05_Entrar com o dia e o mês de uma data e informar quantos dias se passaram # desde o início do ano. Esqueça a questão dos anos bissextos e considere sempre # que um mês possui 30 dias. dia = int(input("Digite o dia: ")) mes = int(input("Digite o mês: ")) mesDia = dia + mes diasPassados = (((mes - 1) * 30)+ dia) ...
3bb66a6d6efff739039c008f4f01b6133c6d5e7b
tianhaomin/algorithm4
/wordscount.py
792
3.65625
4
#!/usr/bin/python # -*- coding: UTF-8 -*- #词频统计,从文件读取内容正则匹配好好参考 import collections def get_words(file): with open(file) as f: words_box = [] for line in f: words_box.extend(line.lower().strip().split()) new_words_box = [] for word in words_box: if w...
32fe0900dd9e360ad792bafedb8d6f4e08693419
barluzon/OOP_ex3
/src/TestDiGraph.py
2,268
3.546875
4
import unittest from unittest import TestCase from src.DiGraph import DiGraph class TestDiGraph(TestCase): def setUp(self) -> None: self.graph = DiGraph() for i in range(4): self.graph.add_node(i) self.graph.add_edge(0, 1, 1) self.graph.add_edge(1, 0, 1) self....
816f514e36ead890423eabd490f2708332548e7d
mecomontes/Higher-Level-Programming
/0x07-python-test_driven_development/100-matrix_mul.py
2,293
4.0625
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- """ Created on Thu May 21 17:43:34 2020 @author: Robinson Montes """ def check_matrix(matrix, name): """ Check if list of list is a matrix of integer/float Args: matrix (list of list): list of list of int or float name (str): matrix name to test...
ca7e8ad268357ae9a9542848fb8226f4c78ce8a6
davidkowalk/Kalaha
/src/app.py
3,408
3.6875
4
from Board import Board, code_to_list from sys import argv def print_layout(): print("╔══╦══╦══╦══╦══╦══╦══╦══╗") print("║ ║ 6║ 5║ 4║ 3║ 2║ 1║ ║ <- Player 2") print("║ ╠══╬══╬══╬══╬══╬══╣ ║") print("║ ║ 1║ 2║ 3║ 4║ 5║ 6║ ║ <- Player 1") print("╚══╩══╩══╩══╩══╩══╩══╩══╝") def lpad(str, length...
77d47c74818d8261e2e2a176472b93c32f3b24b9
danjpark/python-projecteuler
/020.py
220
3.65625
4
""" Find the sum of the digits go 100! """ import math def main(): """docstring for main""" print(sum(int(item) for item in str(math.factorial(100))) ) if __name__ == "__main__": main()
9d5145e8fb39f35f38cf7f7c9df8c339ef75e0f5
mepesh/IWAssignment
/Q6.py
567
4.21875
4
#6. Write a Python program to find the first appearance of the substring 'not' and # 'poor' from a given string, if 'not' follows the 'poor', replace the whole 'not'...'poor' # substring with 'good'. Return the resulting string. sampleSentence = 'Python is poor and not bad and is for people ' notIndex = sampleSentence...
704a004cd5731b245305109d2a09e56132f64038
wuwei23/SpiderLearn
/Spiderlearn/HTNL解析大法/python与正则/re.search使用.py
282
3.796875
4
#coding:utf-8 #search会扫描整个你string查找匹配 import re #将正则表达式编译成pattern对象 pattern = re.compile(r'\d+') result1 = re.search(pattern,'abc192edf') if result1: print(result1.group())#通过group获取捕获的值 else: print('匹配失败1')
b6a2240e2f240a998989807ae278866d81da0701
vbarrera30/python-a-fondo
/Capitulo_6/formato_con_delimitadores/ficheros_delimitados_csv_tsv.py
2,024
3.59375
4
import csv from dataclasses import dataclass import pandas as pd def lectura_csv(nombre_fichero): with open(nombre_fichero, 'r') as fr: reader = csv.reader(fr) for fila in reader: print(fila) @dataclass class Planeta: nombre: str masa: float radio: float def __post_...
57fa4b15f707aa80ddf4029864ee7131b174dcdf
DenysGurin/-edx_MITx_6.00.1x
/W3_PS3_P1.py
655
3.53125
4
#-*-coding:utf8;-*- #qpy:2 #qpy:console import math #print "This is console module" def f(x): return 10*math.e**(math.log(0.5)/5.27*x) def radiationExposure(start, stop, step): exposure = 0 time = start while time < stop: exposure += f(time)*step time += step #print time, exposu...
51e56cc91ad7d3319757662404ad473701b54e64
aakriti-27/Internity_DataScienceWithPython
/day6/NumPy1.py
2,046
4.46875
4
import numpy #creating arrays #We can create a NumPy ndarray object by using the array() function. arr = numpy.array([1, 2, 3]) print(arr) print(type(arr)) arr = numpy.array((1, 2, 3)) #by passing tuple print(arr) arr1=numpy.array(45) #0-D array arr2=numpy.array([1, 2, 3]) #1-D array arr3=numpy.array([[1, 2, 3]...
c5ecaf96d11f4164fc3b47f430a14a70c62602b9
Paker211/parker40105_sti
/sti_py/chapter8/8_1/9.py
412
3.703125
4
class Leg(): def __init__(self, num, look): self.num = num self.look = look class Animal(): def __init__(self, name, leg): self.__name = name self.leg = leg def show_name(self): return self.__name def show(self): print(self.show_name(), ' have ', self.leg...
b106fbe2d3ef71eb183696d902f58642b71025e6
Kracha0907/YandexProjectPacman
/energy_life.py
985
3.546875
4
import pygame # Полоса энергии и жизни class EnergyLife: def __init__(self, screen, p): self.energy = p.energy self.life = p.health self.screen = screen def render(self, p): self.energy = p.energy self.life = p.health x = 1100 y = 10 color = pyg...
c367f7e3df98a5f9234b8fe152509840c6b3071b
sw561/AdventOfCode2019
/06_orbits/orbits.py
1,368
3.5625
4
#!/usr/bin/env python3 from collections import defaultdict def part1(children): # do a breadth first search to get generation of each node nodes = ['COM'] orbits = 0 g = 0 while nodes: g += 1 new_nodes = [] for node in nodes: new_nodes += children[node] ...
a2652f6151dc992c3002d526718f71ae1ce5e1b4
Relaxforever/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/2-uniq_add.py
119
3.59375
4
#!/usr/bin/python3 def uniq_add(my_list=[]): cont = 0 for i in set(my_list): cont += i return cont
a5cbe13f9a756729b2401c8f6e14018d8a3bced1
AshleyCameron1994/Python-practice
/loop_challenge.py
396
4.09375
4
#loop challenge for QA consulting #user can alter the range limit = int(input("Enter the limit: ")) for i in range(0, limit): print(i, i**2) if i**2 > 200: print("Limit exceeded") break # #Alternatively user can alter value limit # limit = int(input("Enter the limit: ")) # for i in range(0, 101): # j = i*...
d99322a71c6d525f56f51dc72c6d48c932d433a3
sunyeongchoi/sydsyd_challenge
/argorithm/10809.py
279
4
4
alphabet = ['a','b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] word = list(input()) for a in alphabet: try: print(word.index(a), end=' ') except ValueError: print(-1, end=' ')
686905068f986d3cc414995d4eb693c1e180fd78
xzy103/learn_python_course
/chap03/3.7.1.py
1,759
3.5625
4
# -*- coding:UTF-8 -*- # Author:徐熙林-金融162班 # Date:2019.4.28 import csv class UserInfo: def __init__(self, id_, username, name, gender, Tel, password, mail, rank): self.id = id_ self.username = username # 用户名 self.name = name # 用户姓名 self.gender = gender self.Tel = Tel ...
63cf1313edcfb952435711cf7c59815d49847f42
lauradebella/treinamentoPython
/zumbi1.py
272
3.84375
4
#aprendendo tipos de dados #a = 1 #b = 1002 a = ' abacate' b = ' e banana' print (a+b) print (a.upper()) print ('A fruta ' + b + ' e amarela') c = 2.1111 print ('%.2f' %c) c = 42 d = str(c)+a print (d) a, b = b, a print (a+b) a,b,c = 'ola' print(a) print(b) print(c)
9d48654c6dc560302432ab2227d8d0e2d3077af5
here0009/LeetCode
/Python/1545_FindKthBitinNthBinaryString.py
1,967
3.90625
4
""" Given two positive integers n and k, the binary string Sn is formed as follows: S1 = "0" Si = Si-1 + "1" + reverse(invert(Si-1)) for i > 1 Where + denotes the concatenation operation, reverse(x) returns the reversed string x, and invert(x) inverts all the bits in x (0 changes to 1 and 1 changes to 0). For exampl...
fdb208b1db6ddc830b9f25ff24fa294238f8ea78
majard/prog1-uff-2016.1
/Highest Sum.py
483
4.0625
4
matrix = [] highestSum = 0 highestSumLine = 0 for row in range(3): line = [] sum = 0 for column in range(3): line.append(int(input('row {}, column {}: '.format(row + 1, column + 1)))) sum += line[column] if sum > highestSum: highestSumLine = row highestSum = ...
376babd9f9e45fb0cfa28052d0f12867eb0a114e
HillaShx/btcmp
/23 PYTHON/02 Speaking Pythonic/Exercise3_List2/list2.py
256
3.78125
4
# exercise1 def remove_adjacent(l): return [l[i] for i in range(len(l)) if i == 0 or l[i] != l[i-1]] # print(remove_adjacent([2,2,3,4,5,5,6,6,7,7])) # exercise2 def linear_merge(l1,l2): return sorted(l1 + l2) # print(linear_merge([1,4,2],[2,9,3]))
a27961627abb1d9c6dc15896ee37038425d99997
rajatbansal01/Python_DSA
/sorting_algo/insertion_sort.py
574
4.28125
4
#insertion sort #insert the values on comparing with previous one # l is any sequence you want to sort in form of list. def insertion_sort(l): for slice_end in range(len(l)): pos=slice_end while pos>0 and l[pos]<l[pos-1]: (l[pos],l[pos-1])=(l[pos-1],l[pos]) pos=pos-1 #it make...
290dba4639998e0c41f0dbc7a446a5e7ae89470e
ComradYuri/Gen_Rank_Pokerhands
/script.py
10,761
3.515625
4
import random import matplotlib.pyplot as plt import pandas as pd import seaborn as sns # creates dictionary with keys 0-51 paired to a card e.g. 2S, TD, QH. (two of spades, ten of diamonds, queen of hearts) values = [str(i) for i in range(2, 10)] + ["T", "J", "Q", "K", "A"] suits = ["S", "H", "D", "C"] deck = {} for ...
2c173c6c8dd73d9ce66ebefc083621e8b24b05cf
lvah/201903python
/day01/code/user_login.py
505
3.796875
4
#coding:utf-8 import getpass # 尝试次数 tryCount = 0 # 循环三次 while tryCount < 3: tryCount += 1 # 输入用户名和密码 name = input("UserName:") password = getpass.getpass("Password:") # 判断用户名和密码是否正确? if name=='root' and password=='westos': print("Login Success") flag = 1 break else: print('Login Fail, you try %d' %(...
5ba580148050a94006a635f8627d222991a22d11
99dneyleta/CHNU_Python
/2.2.py
240
3.6875
4
def A(n,i): print(n,i) if n == 0: return i+1 elif i == 0 and n > 0: return A(n-1,1) elif n > 0 and i > 0: return A(n-1, A(n, i - 1)) n = 3 sum = 0 for i in range (1, n): sum += A(n,i) print(sum)
da630a28acacf6d68bc95001d7798dc603739a8a
zhangbo111/0102-0917
/day04/09-质数.py
595
3.765625
4
# 输出2-15的质数 # 质数:因数只有自己和1的数叫做质数。 for i in range(2, 16): # print(i) for j in range(2, i): # print(j) if i % j == 0: print('{}不是质数'.format(i)) # 终止内层的循环 不是外层的循环 break # 当前面的for正常运行 没有遇到break时执行这里 else: print('{}是质数'.format(i)) # # 表示从0到9打印出来 #...
1b02d95dd0789d29aa2982c48653d104556889c6
dreznichenko92/repo-python2
/Homework5/task_3_5.py
976
3.8125
4
# 3. Создать текстовый файл (не программно), # построчно записать фамилии сотрудников и величину их окладов. # Определить, кто из сотрудников имеет оклад менее 20 тыс., # вывести фамилии этих сотрудников. Выполнить подсчет средней величины дохода сотрудников. with open('text_salary.txt') as file: list_a = file.rea...
593651cab4fdaf533c145fe2376ada1ff7a3b47a
Cheng-F/Data-Structure-Algo
/Queue.py
707
3.84375
4
class Queue: def __init__(self): self.items = [] def __str__(self): return (str(self.items)) def enqueue(self,item): self.items.insert(0,item) def isEmpty(self): return self.items == [] def dequeue(self): return self.i...
ff78609ed87df7b87adb828d0f3865b509a5c2c8
krishankansal/PythonPrograms
/oops/#042_operator_overloading.py
1,135
4.03125
4
class A: def __init__(self, a): self.a = a # adding two objects # magic method def __add__(self, x): return self.a + x.a def __sub__(self, x): return self.a - x.a def __mul__(self, x): return self.a * x.a def __truediv__(self, x): ...
79926d9f1e0be4656ed6afb6527008ba35b21753
ShiryaevNikolay/Homeworks
/Монеты на сдачу.py
1,958
3.96875
4
# -----------↓↓↓Делаем проверку на ввод числа.↓↓↓ while True: try: number_of_change = int(input("Введите кол-во монет, которые должен отдать кассир: ")) if number_of_change > 0: # Проверка: нужна ли сдача или нет break elif number_of_change == 0: print("Сдача вам не...
fbbe5aba65867ef750181eeea601cb716348c024
michael-act/HyperSkill
/Easy/Tic Tac Toe/Tic Tac Toe Stage 4.py
1,953
3.703125
4
# write your code here def arrangeXO(symbol): global symbols symbols = symbol symbol_m = [[], [], []] temp_symbol = symbol[::] # Print the XO table print('---------') for i in range(3): print('|', end='') for _ in range(3): symbol_m[i].append(temp_symbol[0]) print(f' {temp_symbol[0]}', en...
aa242fe4a0cea91dc2bb578dafcacc6c0737fb0b
Samuel001-dong/Thread_example
/Script_exercise/python_code/grabble_game/garbble_game.py
2,203
3.96875
4
"""" 1.一个回合制游戏,每个角色都有hp和power,hp代表血量,power代表攻击力, hp的初始值为1000,power的初始值为200 2.定义一个fight方法: 3.my_hp = hp - enemy_power 4.enemy_final_hp = enemy_hp - my_power 5.两个hp进行对比,血量剩余多的人获胜 """ class Game: def __init__(self, my_hp, enemy_hp): # 构造函数 self.my_hp = my_hp self.my_power = 200 self.enemy...
ccde506fb4b1240aee54ebd8e90fa895c1f70cac
herolibra/PyCodeComplete
/Others/Builtin/cmp_sample.py
620
3.671875
4
# coding=utf-8 # run via python2.7 """ 它的返回值只有三个,正数,0,负数,下面来看一下: cmp(x, y) 中文说明:比较两个对象x和y,如果x < y ,返回负数;x == y, 返回0;x > y,返回正数。 版本:该函数只有在python2中可用,而且在python2所有版本中都可用。但是在python3中该函数已经被删减掉,这点要特别注意。 """ # -1, 0, 1 print(cmp(1, 2)) print(cmp(1, 1)) print(cmp(5, 2)) # #注意:这时候它会先比较第一个字符,然后比较第二个字符,逐个比较知道能判断出大小为止。 print(...
bde0d99835fb7f4c868a63969c68c66719e8d5f0
anujmalkotia/PRP_ALL
/PYTHON/Python Functions/func1_ADID.py
204
3.78125
4
import math num1_ADID=eval(input('Enter number 1:::')) num2_ADID=eval(input('Enter number 2:::')) def func1_ADID(x,y): avg1_ADID=(x + y)/2 return avg1_ADID print(func1_ADID(num1_ADID,num2_ADID))
b0cabf75cfd9ddd8c6ee9ccf111157f292df30c2
Akansha-Jaisinghani/CalculatorTkinter
/calculator.py
2,020
4.0625
4
import tkinter as tk from tkinter import messagebox mainWindow=tk.Tk() mainWindow.title("Calculator") first_label=tk.Label(mainWindow,text="First Number") first_label.pack() number1=tk.Entry(mainWindow) number1.pack() second_label=tk.Label(mainWindow,text="Second Number") second_label.pack() number2...
837d4eadd59bf2cd85febd89fe7b4b4fd57ec48b
sebutz/John-Zelle-Python-Programming
/calculator.py
194
4.15625
4
# calculator.py # a simple calculator to evaluate expressions. def main(): for i in range(100): expression = eval(input("Enter an expression: ")) print(expression) main()
8cb77cba1be8f14790deb4e4c4b4cb1bbc29e694
paiv/aoc2017
/code/12-2-pipes/solve.py
969
3.609375
4
#!/usr/bin/env python3 from collections import defaultdict def solve(problem): graph = defaultdict(list) for line in problem.splitlines(): p,cs = line.split(' <-> ', 2) for c in cs.split(', '): graph[int(c)].append(int(p)) res = 0 visited = set() fringe = list() ...
f0da15fd85eda3e5c5c2860dece86aa9972824f2
JaimeSilva/Django
/Python_Level_Two/part3_oop_project.py
6,167
4.40625
4
##################################### ### WELCOME TO YOUR OOP PROJECT ##### ##################################### # For this project you will be using OOP to create a card game. This card game will # be the card game "War" for two players, you an the computer. If you don't know # how to play "War" here are the basic r...
c29f4c2b497fca679f41d117fb0de10a07cd0211
tylfin/dojo
/sort/insertion.py
907
4.15625
4
""" Review of insertion sort More information see https://en.wikipedia.org/wiki/Insertion_sort """ from math import ceil def insertion_sort(sorting_list): for current_index in range(len(sorting_list)): value_to_insert = sorting_list[current_index] index_to_check = current_index - 1 while (...
1f9067514a0b241aa3ea5c4d85cbfc6b934d1601
u101022119/NTHU10220PHYS290000
/student/101022207/is_trangle.py
355
3.96875
4
def is_trangle(): a = float(raw_input('Put the first stick length:')) b = float(raw_input('Put the second stick length:')) c = float(raw_input('Put the third stick length:')) if a+b > c and b+c > a and a+c > b: print 'This is a triangle' else: print 'This is not a triang...
b7b877695083c5dd007ea73e8236fc2a08e0d4df
wlgq33092/state_machine
/state_machine.py
2,503
3.703125
4
#! /usr/bin/env python import transitions class Transition(object): def __init__(self, transit, name = ''): self.transit = transit self.name = name class State(object): def __init__(self, name, final = False): self.name = name self.transition_dict = {} self.final = fi...
7587081783ff7f572921a684aba346b4f36e1bda
PixelNoob/PythonNoob
/scripts/dice.py
442
3.921875
4
# A simple Dice game import time import random while True: guess = input("Please select a number from 1 to 6: ") dice = random.randint(1,6) time.sleep(1) print ("The dice throws........and its a.. ") time.sleep(1) print (dice, "!!!") time.sleep(1) if int(guess) == int(dice): pr...
2950c1edcbebd698d1521ca99e3e9b0e6a5ce31b
rrabit42/Python-Programming
/Python프로그래밍및실습/ch9-list&dictionary/lab9-2.py
543
4
4
def computeSum(numbers) : sum = 0 for i in range(len(numbers)) : sum += numbers[i] return sum def computeAvg(numbers) : sum = 0 for i in range(len(numbers)) : sum += numbers[i] average = sum / len(numbers) return average numbers = [] while True: n = int(i...
495cf846f18bd2107b77a98f556646d313c074ae
israelmikan/python-tutorials
/answers.py
1,504
4.34375
4
#Define a function that can accept two strings as input and print the string with maximum length in console. If #two strings have the same length, then the function should print al l strings line by line. #Hints: #Use len() function to get the length of a string def printValue(s1,s2): len1 = len(s1) len2 = len(s2...
6097adff826c37dcb8fd9bae72fdb7bfd9a67d09
Wushida/Penambangan-Data
/2x/Tugas 2.py
3,938
3.53125
4
from tkinter import * root=Tk() root.geometry("600x600") root.title("Data diri mahasiswa") label_0=Label(root,text="DATA DIRI MAHASISWA",width=20,font=15) label_0.place(x=200,y=10) label_1=Label(root,text=" Nama ",width=20,font=("bold",10),anchor=W) label_1.place(x=0,y=60) entry_1=Entry(root) entry_1.place(x=178...
1315e0c6eb9488f7a7d6c12198c2f8c0ea39268b
niravasher/niravasher.github.io
/INCube/pages/static/uploaded_files/task1.py
777
3.5625
4
import os #getting location of files path_dir = input("Write path of directory where files are stored:") os.chdir(path_dir) #inputting files name1 = input("Name of file 1:") name2 = input("Name of file 2:") f1 = open(name1) f2 = open(name2) #reading files line by line lines1 = f1.readlines() lines2 = f2.readlines...
16d2e461028a0c4cee9d31cf014bc85f5d75ad3f
MikuHatsune39/KanColle_RPG
/Kancolle_RPG/Kancolle_RPG.py
827
4.03125
4
print("Story: You have just arived at the navel district after beening") print("recruted to join the fleet.") print(" ") print("???: Hello and welcome to the fleet my name is Shimakaze,") print("I'm the fastest ship around, what's your name?") name = input("Type your name and hit \"ENTER\": ") print(" ") p...
03f8160c48e9e7675745aa048c4c18f80d74587f
Luis456/Tarea1
/ejercicio1/suma2.py
81
3.671875
4
a=str(input('numero:')) b=str(input('numero2:')) suma = a+""+b print (str(suma) )
327a8eb17988efa0ac66a748db50897d69d86289
cdcftj/pythonst
/get_digits.py
181
3.71875
4
digits = [] def get_digits(n): if n > 0: digits.insert(0, n % 10) get_digits(n // 10) num = int(input("请输入个整数:")) get_digits(num) print(digits)
18e2630fa358b978cef93132c951fd0ad5ade983
OlgaLitv/Algorithms
/lesson2/task5.py
514
3.921875
4
""" Вывести на экран коды и символы таблицы ASCII, начиная с символа под номером 32 и заканчивая 127-м включительно. Вывод выполнить в табличной форме: по десять пар "код-символ" в каждой строке. """ start = 32 finish = 127 for i in range(10): for j in range(10): code = 10*i+j+start print(10*i+j+s...
b3f3553971bc10263e3a9e6f1945f40fcefab3c5
mishok13/codechallenge
/renesys/nozealand.py
1,782
3.734375
4
#!/usr/bin/env python # The task itself: # # A customer is interested in a particular subset of # the networks in that file. Find the networks that interest them. # # * They only care about networks in locations having more than # 10 but fewer than 100 networks (or 11-99, inclusive) # # * A location is a d...
a204e6d8227bf34b9f6963813aca799057f78dc1
kiranask/boring_stuffs_with_python
/DS/Numbers/fibonacci_numbers.py
224
3.96875
4
def fibonacci_number_generator(n): sum = 0 first = 1 second = 1 while sum < n : sum = first + second print(first) first = second second = sum print(fibonacci_number_generator(100))
9e8b2d134c5cab40296ebded8a04b3612b273552
zeemyself/tennis
/tennis.py
1,170
3.734375
4
import sys if len(sys.argv) > 1: input = sys.argv[1] else: input = "input.txt" scoreArr = [0, 15, 30, 40] def score(a, b, win): if a > 3 and a - b >= 2: print('A: WIN') return True elif b > 3 and b - a >=2: print('B: WIN') return True elif a > 3 and b > 3 and a==b: ...
7c9604fea0cf566bdf6ac27d48a41f0bf1a00de0
hwy801207/pycookbook
/c15.py
1,065
3.578125
4
#!/usr/bin/env python3 #-*- encoding:utf-8 -*- rows = [ {'address': '5412 N CLARK', 'date': '07/01/2012'}, {'address': '5148 N CLARK', 'date': '07/04/2012'}, {'address': '5800 E 58TH', 'date': '07/02/2012'}, {'address': '2122 N CLARK', 'date': '07/03/2012'}, {'address': '5645 N R...
959ac0ec93b1b5a2d5e931a494fb59c53a10dead
gonsva/Python-week
/listhighestnum.py
235
4.0625
4
numbers=[] while True: num=int(input("Enter any number: ")) if num==0: break else: numbers.append(num) highest = numbers[0] i=1 while i<len(numbers): if numbers[i]>highest: highest=numbers[i] i=i+1 print("Highest", highest)
fead5292082c117df5c55cb375cdada9d7ab1b98
apulps/Design-Patterns
/behavioral_patterns/observer.py
1,116
3.640625
4
""" Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. """ class Subject: def __init__(self): self._observers = [] self._subject_state = None def atach(self, observer): self._observers.appen...
db42de75c62ba9dbfc1e0471c5c3fb10515907e6
Nels885/use-OpenFoodFacts
/package/database.py
4,715
3.9375
4
""" Database management module """ import psycopg2 class Database: SELECT = "SELECT %s FROM %s" WHERE = " WHERE %s" INSERT = "INSERT INTO %s" COLUMNS = "(%s)" VALUE = " VALUES(" RETURN_ID = " RETURNING id;" def __init__(self, log, confSql): """ ## Initialize Class Databas...
ac48986ad860dd8e6df64a4491bda9dd90e0db15
abdullahsher445/projects
/Lab-1_3_b.py
1,152
4.25
4
''' Write a program that prompts the user for an input number and checks to see if that input number is greater than zero. If the input number is greater than 0, the program does a multiplication of all the numbers up to the input number starting with the input number. For example if the user inputs the number 9, t...
ee3ba13a92355ad95eae26eafe87853dceb24412
irvingr/python
/04_cadenas_texto.py
626
3.921875
4
cadena = 'Hello world' print(cadena) print() # H e l l o w o r l d # 0 1 2 3 4 5 6 7 8 9 10 string = "H e l l o w o r l d <= String" posStr = "0 1 2 3 4 5 6 7 8 9 10 <= Posición string" cadena1 = "Hello" cadena2 = " " cadena3 = "world" print(string) print(posStr) print() print(cadena[4],' <= pos #4') print(c...
bde3136ded7aaa844f166ee479917cc09b9ed4e7
selinbilen/Dart
/main 3.py
7,172
3.515625
4
import turtle import random import math t=turtle.Turtle() wn=turtle.Screen() t.speed(10) t.hideturtle() t.setposition(0,-300) t.begin_fill() t.color("black") t.circle(300) t.end_fill() t.penup() t.setposition(0,0) t.left(9) for i in range(10) : t.pendown() t.forward(240) t.left(90) t.color("red") t.begin_f...
0c2710a6529cbc56026f92623ced80276a3e83f6
imcauley/Dominoes
/game.py
2,037
3.640625
4
from card import Card from board import Board from player import Player import random class Game: def __init__(self,size,players,output=True): self.board = Board(size) self.set = self.create_set(size) random.shuffle(self.set) self.num_pieces = ((size) * (size + 1)) // 2 s...
bfc2d08f65f63d57f721b0610c8cfbdefdcf1c92
saikumar-divvela/rentspace
/rentspace/tests/test.py
664
3.5
4
#/usr/bin/python class User(): def __init__(self): pass is_id_verified="" is_email_verified ="" is_phone_verified="" key ="test" ''' def __setitem__(self, key, value): print key,value object.__setattr__(self, key, value) ''' ''' def __setattr__(self,...
4fc0b23cafbe1e410a0d47ddca5b86b95edf6909
nyamba/algorithm
/abramov/ABR0342.py
675
3.5625
4
def average_x(a, m): ''' >>> average_x(3.0, [4.0323, 3.4, 22.3, 1.0]) 4.0 1.0 ''' minum = a - (m[0] + m[1])/2 index = [0, 1] if minum < 0: minum *= -1 for i in xrange(len(m)-1): for j in xrange(i+1, len(m)): k = a - (m[i] + m[j])/2 if k < 0 : ...
4be978deaf830064b3399ad8b0af6ab6a8f207a7
JiahangGu/leetcode
/Medium Topic/src/20-10-20-216-combination-sum-iii.py
765
3.5625
4
#!/usr/bin/env python # encoding: utf-8 # @Time:2020/10/20 15:14 # @Author:JiahangGu from typing import List class Solution: def combinationSum3(self, k: int, n: int) -> List[List[int]]: """ 简单的回溯。要求现有结果含有k项且和刚好为n。 :param k: :param n: :return: """ def dfs(le...
f8fb4bf85f58f04e0bb74c13728b3af9ce3059ca
daniel-reich/ubiquitous-fiesta
/iN48LCvtsQFftc7L9_14.py
1,062
3.65625
4
def word_search(letters, words): horiz = [letters[8*i:(8*i)+8].lower() for i in range(8)] vert = [''.join(letters[8*i + j].lower() for i in range(8)) for j in range(8)] ​ diagr = [] diagl = [] for i in range(15): diagr.append('') diagl.append('') for i in range(8): for j in range(8): ...
a8623b0336d07ebff8310d81268596607cb3493d
adriano-arce/Interview-Problems
/2D-Problems/Rotate-Matrix/Rotate-Matrix.py
841
4.0625
4
def rotate_matrix(A, m, n): """ Rotates the given m by n matrix A 90 degrees clockwise. """ B = [[0] * m for i in range(n)] for i in range(m): for j in range(n): B[j][m - i - 1] = A[i][j] return B if __name__ == "__main__": testMatrices = [ [[0, 0, 0], [...
8bc4a216d214fc664031aaa3f9030293fbc7f51c
pedrohcf3141/CursoEmVideoPython
/CursoEmVideoAulas/Aula013.py
304
3.953125
4
for c in range(0, 6): print('oi', end=" ") print('FIM') for c in range(0, 6): print(c, end=' ') print('FIM') for c in range(6, 0, -1): print(c, end=' ') print('FIM') for c in range(0, 12, 2): print(c, end=' ') print('FIM') for c in range(10, -2, -2): print(c, end=' ') print('FIM')
6f79159d5aec0b966b6f5a29979be5196c2b45b2
Egodrone/Python
/Problemsolving_in_Python/kmom01/lab1/answer.py
9,091
3.625
4
#!/usr/bin/env python3 from dbwebb import Dbwebb # pylint: disable=invalid-name dbwebb = Dbwebb() dbwebb.ready_to_begin() # ========================================================================== # Lab 1 - python # # If you need to peek at examples or just want to know more, take a look at # the [Python manua...
e91a1e295da3689827a04125958a2f52c8e186b3
AdamZhouSE/pythonHomework
/Code/CodeRecords/2339/60676/238233.py
444
3.84375
4
def reverse_count(array): count = 0 for i in range(len(array)-1): for j in range(i+1, len(array)): if array[i] > array[j]: count += 1 return count result = [] for i in range(int(input())): line1 = input() line2 = input().split(' ') for j in range(len(line2))...
56ff707d840872626b7b90da19178548a4f53bf3
hazzarux/project_euler
/src/p7.py
745
4.21875
4
''' By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? ''' NUMBER1 = 6 NUMBER2 = 10001 def is_prime(n): '''check if integer n is a prime''' # range starts with 2 and only needs to go up the squareroot of n for ...