blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
742e0b135c8c19f4a604b24d1225fc5bf3f3c699
Alevtina2283/cd101
/age_count.py
226
3.953125
4
furst_name = input("ur furst name") second_name = input("ur second_name") birth_year = input("please, enter ur Bday") curent_year = 2021 age = curent_year - int(birth_year) print(F"name:{furst_name} {second_name} age: {age}")
7168ee2a01b6dc489696bd2f1a8c5d37c9dd0b7f
baloooo/coding_practice
/reverse_integer.py
978
4.15625
4
""" Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Return 0 if the result overflows and does not fit in a 32 bit signed integer """ def my_reverse(self, x): ans = 0 if x >= 0: while x: # ans*10, since one unit place was added with this ite...
81a2d55c8de43273bc6a4a5f915b7431f4556add
AmithSahadevan/No_repetition
/NOrep.py
540
4.125
4
Input = input("Enter a phrase: ") #Taking in input. lizt = list(Input) #Convering Input into a list and storing it in a variable called lizt. dictionary = dict.fromkeys(lizt) #Converting the above list into a dictionary. back_to_list = list(dictionary) #Converting the above dictionary back to list. for letters in b...
67f7d37b82e337c1c94ffc26c02464236cf14e21
yiming1012/MyLeetCode
/LeetCode/回溯法/5635. 构建字典序最大的可行序列.py
2,763
4.125
4
""" 5635. 构建字典序最大的可行序列 给你一个整数 n ,请你找到满足下面条件的一个序列: 整数 1 在序列中只出现一次。 2 到 n 之间每个整数都恰好出现两次。 对于每个 2 到 n 之间的整数 i ,两个 i 之间出现的距离恰好为 i 。 序列里面两个数 a[i] 和 a[j] 之间的 距离 ,我们定义为它们下标绝对值之差 |j - i| 。 请你返回满足上述条件中 字典序最大 的序列。题目保证在给定限制条件下,一定存在解。 一个序列 a 被认为比序列 b (两者长度相同)字典序更大的条件是: a 和 b 中第一个不一样的数字处,a 序列的数字比 b 序列的数字大。比方说,[0,1,9,0] 比 [0,1,5,6...
149cffd532d7683795d3c4d8d8fb33156f575898
Vagacoder/Codesignal
/python/Arcade/Core/C152CountElements.py
3,188
4.09375
4
# # * Core 152. Count Elements # # * You've been invited to a job interview at a famous company that tests programming # challenges. To evaluate your coding skills, they have asked you to parse a given # problem's input given as an inputString string, and count the number of primitive # type elements within it. # ...
19985800277a9f5dce7288e9e65003f60a8726f5
cogito0823/learningPython
/从入门到实践/2-4.py
601
3.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ######################################################################### # File Name: 2-4.py # Created on : 2019-11-21 17:04:14 # Author: cogito0823 # Last Modified: 2019-11-21 17:04:14 # Description: 调整名字的大小写: 将一个人名存储到一个变量中,再以小写、大写和首字母大写的方式显示这个人名。 ######################...
c551dcf8141b0b465e99be80637980c7bab450b5
d4rkr00t/leet-code
/python/leet/5-longest-palindromic-substr.py
681
3.859375
4
# Longest palindromic substr # #url: https://leetcode.com/problems/longest-palindromic-substring/ # #medium def longestPalindrome(s): # cbbd ans = (0, 0) def expand(str, start, end): # 1 2 while start >= 0 and end < len(s) and str[start] == str[end]: start -= 1 end += 1 ...
684b548367b90150a6d61bb7273e356d6192f8c4
S-ghanbary98/python_Exception_Handling
/files_and_exception_handling.py
719
3.8125
4
# print(1/0) # ZeroDivisionError # We will create a file with required Permissions and see what errors/exception are possible # First iterations #file = open("order.txt") # open() takes string argument of file name. #print(file) # Produces an FileNotFoundError # Second Iteration try: file = open("app/order.t...
5f7cba7bdf299c915d0d01cc23b183f17267e3b0
gibum1228/Python_Study
/lab1.py
989
3.84375
4
number = "Hi" #number의 타입이 문자열 print(number) #문자열 출력 number = 10 #number에 정수를 저장했으므로, number의 타입이 정수형이 되었음 print(number) #정수형 number를 출력 # 변수 a, b에 값을 저장한 후, 합을 c변수에 저장 후, c를 출력 a = 4 b = 5 c = a+b #4 + 5 = 9와 같이 출력하라. msg = "%d + %d = %d" #출력하려는 문자열을 변수로 정의할 수 있다. print(msg %(a, b, c)) #변수를 여러 개 출력하고 싶을 때, %( , , )를 ...
a6dbea4a2b36d99d2a32bb1369893c6dd436b2a2
Elliot-L/comp551-a3
/tut_ex.py
2,568
3.90625
4
# not mine, source is the class PyTorch tutorial from __future__ import print_function import os, pickle import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torchvision import transforms from torch.autograd import Variable class TwoLayerNet(to...
ebcedf23649e11f819e6faa6c13bff16a053a0b0
waelnaseeb/TicTacToe-1
/main.py
4,062
3.984375
4
import random EMPTY_SLOT = "-" X_PLAYER = "X" O_PLAYER = "0" TIE = "tie" WIN_COMBINATION_INDICES = [ # Complete row [0, 1, 2], [3, 4, 5], [6, 7, 8], # Complete column [0, 3, 6], [1, 4, 7], [2, 5, 8], # Complete diagonal [0, 4, 8], [2, 4, 6] ] def initialize_board(): board = [EMPTY_SLOT, EMPT...
b86fe90e473350799cccb707072eb40b2314b557
gatecrasher83/stepik-python
/tests/3.6.py
214
3.890625
4
str1 = "one" str2 = "two" str3 = "three" print(f"Let's count {str1}, then goes {str2}, and then {str3}") actual_result = "abracadabra" print(f"Wrong text, got {actual_result}, something wrong") print(f"{2 + 3}")
3589234dc4866f58175ac0997900612b26810e0c
gsy/leetcode
/greedy/splitIntoFibonacci.py
1,131
3.75
4
class Solution: def isValid(self, sub, result): if sub[0] == '0': if sub != '0': return False number = int(sub) if number < 0 or number > 2**31 - 1: return False length = len(result) if length >= 2: if int(result[-2]) + i...
dde5a4fc7a08dacd55f806f2f38873654629ed37
ZL4746/Basic-Python-Programming-Skill
/First_Part/05_Goldbach.py
2,111
4.03125
4
def is_prime(num): is_prime = True divisor = 2 limit = int(num**0.5) + 1 while (divisor < limit) and is_prime: if (num%divisor == 0): is_prime = False divisor += 1 return is_prime def main(): #prompt the user to i...
f5562b1a9330e2bb3b767377e81df25217642930
Pradhapmaja/Pradhap
/string is numeric.py
166
3.828125
4
num=['1','2','3','4','5','6','7','8','9','0'] s=input() flag=True for i in s: if i not in num: flag=False if flag: print("yes") else: print("no")
7cfd8346d6846014568ae18c8b8ef23e62cd8cab
qkreltms/problem-solvings
/Programmers/전화번호 목록/1회차.py
1,331
3.578125
4
# 통과 되면 안되는 문제인데 통과가 되어버렸다... import re phone_book = ['123', '12', '145', '567', '88'] def solution(phone_book): phone_book.sort() if (len(phone_book) == 1): return True jubdooau = phone_book[0] phone_book = phone_book[1:] for i in phone_book: if jubdooau == i[0:len(jubdooau)]: ...
5f621b601d87c7462eaec42d36afec137feef98c
zqfan/taurus
/code-interview/baidu/baidu.py
1,528
3.875
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim: tabstop=4 shitwidth=4 softtabstop=4 def matrix_has_element(matrix, k): """return true if k in matrix. else false. O(m*n)""" return k in [j for i in matrix for j in i] def ordered_matrix_has_element(matrix, k): """return true if k in matrix, else false....
79e13caee28e5e309d63a501bd182b160f971feb
wangyendt/LeetCode
/Biweekly Contests/0-50/biweek 29/1491. Average Salary Excluding the Minimum and Maximum Salary/Average Salary Excluding the Minimum and Maximum Salary.py
553
3.875
4
#!/usr/bin/env python # encoding: utf-8 """ @author: Wayne @contact: wangye.hope@gmail.com @software: PyCharm @file: Average Salary Excluding the Minimum and Maximum Salary @time: 2020/06/27 22:30 """ class Solution: def average(self, salary: list) -> float: return sum(sorted(salary)[1:-1]) / (len(salary...
f8bccb8a062b9ca904af7e620a7214faf3766edf
Neckmus/itea_python_basics_3
/shevchenko_mike/04/4.1.py
2,326
4.1875
4
from collections import Counter tesla_story = 'Now in it is fourth model year, the Tesla Model three manages to be efficient, luxurious and fun to ' \ 'drive. For those reasons and more, the Tesla Model three is Edmunds\' top-rated Luxury ' \ 'Electric Vehicle for 2020. ' \ 'Y...
a1919257ac6b518cd92952c3ac5e5ec1098007c9
andreLubawski/pyB-sico
/coleções/collections-ordered dict.py
224
3.875
4
from collections import OrderedDict # garante que a exibição será feita conforme minha inserção d1 = OrderedDict({'a': 1, 'b': 2, 'd': 4, 'c': 3}) for key, value in d1.items(): print(f'chave:{key} valor:{value}')
61d81ed77ba18d430721daba3808ab5cb1f6ef67
dexman/AdventOfCode
/2016/aoc05.py
2,262
3.90625
4
# --- Day 5: How About a Nice Game of Chess? --- # You are faced with a security door designed by Easter Bunny engineers that # seem to have acquired most of their security knowledge by watching hacking # movies. # The eight-character password for the door is generated one character at a # time by finding the MD5 has...
eeb0fae215fa9341695899a0b8d25b66ba01218a
kielejocain/AM_2015_06_15
/StudentWork/arielkaplan/PE/pe003.py
1,050
3.671875
4
# Largest prime factor # The prime factors of 13195 are 5, 7, 13 and 29. # What is the largest prime factor of the number 600851475143 ? f = open('primes.txt') # Save primes in a list (of strings) primes = f.read().split("\n")[:-1] f.close() number = 600851475143 print "Let's factor the number " + str(number) + "." ...
4ff600f35f226903d5bc0af7bb96bfa5cf043d01
bibash28/python_projects
/function/recursion.py
122
3.6875
4
def factorial(x): if x==1: return 1; else: return x*factorial(x-1); def main(): print(factorial(5)); main();
d499bcfa92216c181d25990a890cae2065c49de6
TynanWilke/boost_python_presentation
/example_3_game_entity/main.py
1,179
3.609375
4
import game from random import randint class Wizard(game.Entity): """ Low HP, high power. """ def __init__(self): super(Wizard, self).__init__("Wizard", 20) self.min_power = 0 self.max_power = 40 def power(self): return int(randint(self.min_power, self.max_power)) class Dr...
c56df31765ab8c2b2adc74a0f7793eb90b7112e9
SeanBackstrom/DS-Unit-3-Sprint-2-SQL-and-Databases
/module1-introduction-to-sql/rpg_queries.py
3,736
3.609375
4
import sqlite3 conn = sqlite3.connect('rpg_db.sqlite3') curs = conn.cursor() print("\nPart 1\n") #how many characters print("Objective 1:") count_characters = 'SELECT COUNT(*) FROM charactercreator_character;' print("Total characters:", curs.execute(count_characters).fetchall()) #How many ...
cf3f0515a95030a26395eabad2e586a17d098a68
waterspout11/hyperskill-Smart-Calculator
/calculator.py
10,220
3.5
4
from collections import deque class SmartCalculator(): OPERATOR = '+-*/^()' map_priotity = { '-': 3, '+': 3, '*': 4, '/': 4, '^': 5, } def __init__(self): self.var_dict = {} self.postfix_out = deque() # for postfix notation self.stack_o...
49c9680f845cbae1551e32881a8af3bb27f37ba6
rtroshynski/one-python-project-a-day
/2019-06-13-Python_Playing_Cards.py
1,438
3.75
4
# https://stackoverflow.com/questions/50769728/how-to-randomly-shuffle-a-deck-of-cards-among-players import random class Card: def __init__(self, kind, rank, deck): self._kind = kind self._rank = rank self.deck = deck self.where = None def __repr__(self): return 'Card...
d3b6868ba04186532d3973eff67971c52098f1db
umbs/practice
/IK/DP/HW/CountWaysToClimb.py
347
3.796875
4
def countWaysToClimb(steps, n): res = [0] * (n+1) for i in range(0, n+1): for s in steps: if i == s: res[i] += 1 elif i > s: res[i] += res[i-s] return res[n] if __name__ == "__main__": steps = [2, 3] n = 7 res = countWaysToClim...
dd2f7415a21602c8c4ff4dad93d259ec7fea3846
romwil22/python-textbook-exercises
/chapter6/exercise3.py
365
4.25
4
"""Encapsulate this code in a function named count, and generalize it so that it accepts the string and the letter as arguments.""" fruit = 'banana' # Count how many letter "a" in a strings def count(f): count = 0 for letter in f: if letter == 'a': count += 1 return count # Print ...
2a50ba09aa5804116a13bcde6936cf0034a7eeea
steve3p0/LING576
/corpus_project/single2bitext.py
4,302
3.78125
4
import nltk # Reference: # This code comes from here: # https://github.com/flycrane01/nltk-passive-voice-detector-for-English def isPassive(sentence): # all forms of "be" beforms = ['am', 'is', 'are', 'been', 'was', 'were', 'be', 'being'] # NLTK tags "do" and "have" as verbs, which can be misleading in t...
e1825d563d3ffd8e2290d2c347671eb48ff9ff6f
malikxomer/static
/10.Excersices/8.Usain Bolt races me and a guy.py
844
4.03125
4
# give choice to get back a name def number_to_choice(choice): if choice==1: return 'Usain' elif choice==2: return 'Me' elif choice==3: return 'Qazi' else: return 'Not a member of race' # give name to get back a position def choice_to_number(choice): i...
5f04bd96a9c97e39e62a63d3564d67825f27c733
ArrayZoneYour/LeetCode
/337/House Robber III.py
987
3.984375
4
# /usr/bin/python # coding: utf-8 # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def rob_node(self, node): if not node.left: rob_node_left, not_rob_node_left = 0...
a2fb9ceb92954f5163f0a072b73240a0c6d0516b
RaquelFonseca/P1
/Unidade6a10/Agenda-telefonica.py
883
3.734375
4
# coding: utf-8 # Agenda Telefonica agend_nom = [] agend_num = [] def insertion_sort(lista1): for j in range(1, len(lista1)): chave = lista1[j] i = j - 1 while lista1[i] > chave and i >= 0: lista1[i + 1] = lista1[i] i -= 1 lista1[i + 1] = chave return lista1 while True: comando = raw_input() if co...
223d35bf87ccd66e251bc87f00dc0b142a679d73
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/bob/89f705c829cb4995bfb0daacbbfaafdd.py
623
4.0625
4
# # Skeleton file for the Python "Bob" exercise. def hey(answer): # Get rid of all the leading and trailing white space in a string answer = answer.strip() # Answer if string is in all UPPERCASE letters if answer.isupper(): return "Whoa, chill out!" # Answer if string ends with a...
2f4df165a03378fef88f51970fcd5a494af5738b
ericsporto/Python
/Variaveis_1.py
3,798
4.21875
4
# fazer um programa onde o computador vai pensar em um número inteiro de 0 a 5 # peça para o usuário tentar descobrir este numero # mostre se o usuario acertou ou não import random print("Vamos jogar? Estou pensando em um número de 0 a 5. Quer tentar adivinhar?") n = int(input("Digite um número de 0 a 5: ")) lista = ...
ee27ec7c417492b45250419fd8ad7e20674d4406
jayakrishna35/Coding
/tuple.py
76
3.515625
4
tuple=(4,6,8) print(tuple[2]) list=[(3,5),(9,0),(7,4)] print(list[0] )
f3f599dc9010e9ef3a9abaae85502376f000f117
Arfameher/challenge-card-game-becode
/utils/card.py
1,107
4.125
4
import typing # Parent Class class Symbol: """ Class defining the color and icon of the card. Using the icon, the variable color is set to respective color. ♦ ♥ --> Red ♣ ♠ --> Black """ def __init__(self, icon: str): # icon = "♥, ♦, ♣, ♠" self.icon = icon ...
ac0a032d1c05762e48be1f1b2f77b06c0ba071b6
zranguai/python-learning
/day34/04 数据共享.py
1,181
3.640625
4
# 可以通过Manager进行数据共享 from multiprocessing import Process, Manager, Lock def change_dic(dic, lock): with lock: dic['count'] -= 1 if __name__ == '__main__': # 用法1: # m = Manager() # lock = Lock() # dic = m.dict({'count': 100}) # # dic = {'count': 100} # p_l = [] # for i in range(...
ee4cbce12ffb2be4e8642edc79d4d9cd04ea42e3
TingGingLiao/Computer-Thinking
/廖挺均Week15.py
611
3.5
4
import turtle shelly = turtle.Turtle() shelly.shape("turtle") shelly.position() shelly.color("green", "red") shelly.pencolor("black") shelly.turtlesize(10,10,2) shelly.resizemode("auto") shelly.turtlesize(5,5,3) shelly.forward(100) shelly.left(90) shelly.circle(250) shelly.circle(250, 180, 30) shelly.end_f...
825b0375e44a6db539bedfc9d014da2f72a56792
gstvmoura/ppzombies
/ppzombies/LISTA 1 PYTHON PARA ZOMBIES/Total em segundos.py
248
3.71875
4
d = int(input("Escreva a quantidade de dias: ")) h = int(input("Escreva a quantidade de horas: ")) m = int(input("Escreva a quantidade de minutos: ")) s = int(input("Escreva a quantidade de segundos: ")) tt = d*24*60*60 + h*60*60 + s*60 print(tt)
42a6b9f7043f94aba1707135a07dd0dd7ba3558c
dhruvbaldawa/challenges
/dailyprogrammer/rail_fence_cipher.py
4,355
3.875
4
""" (Intermediate): Rail Fence Cipher Before the days of computerised encryption, cryptography was done manually by hand. This means the methods of encryption were usually much simpler as they had to be done reliably by a person, possibly in wartime scenarios. One such method was the rail-fence cipher[1] . This involve...
eb2f4676f8e4140d778d4e1da05425c8c693d4c2
Ashudeshwal/DFA-Function-Solution
/dfaCode.py
2,551
4
4
''' Write a function solution that, given a string S consisting of N letters 'a' and/or 'b' returns Accepted when all occurrences of letter 'a' are before all occurrences of letter 'b' and return Not Accepted otherwise. Examples 1. Given S = "aabbb", the function should return Accepted. 2. Given S...
ce0cc3e4fd3a9a5e207df05abffaed2e5b4b734f
PigsGoMoo/LeetCode
/unique-word-abbreviation/unique-word-abbreviation.py
712
3.59375
4
class ValidWordAbbr: def __init__(self, dictionary: List[str]): self.table = collections.defaultdict(list) for word in dictionary: abbrev = word[0] + str(len(word) - 2) + word[-1] if word not in self.table[abbrev]: self.table[abbrev].append(word) ...
bef69bd7fe3f8f8be03e1093d926ef23337ebb2a
ygberg/labbar
/code alongs and misc/second_lowest_garde.py
323
3.53125
4
names = [] scores = [] for _ in range(int(input())): name = input() score = float(input()) scores.append(score) names.append(name) st = dict(zip(names,scores)) sv = sorted(st.values()) sk= sorted(st, key=str.lower) ab= list(dict.fromkeys(sv)) s_l = ab[2] for s_l in sk: print(st.items(s_l...
13c5b12164bf6a2510356b36bdb0c7020e63038c
vrrohan/Python100DaysOfCode
/Day25-ClassesAndObjects/Py2ClassInit.py
4,225
4.78125
5
#How to initialize a class #The instantiation of the class happened at the line - per = Person(). #You may have noticed that the property stored_name does not exist in the object until we assign a value to it. #This can give very serious headaches if someone calls the method get_name before actually having a name store...
d321d41c9ba560fe4148b481737962481f7d62c3
frances-zhao/ICS207
/homework/lesson 8/lesson8_3.py
627
4.25
4
#***************************************************** # #Program Author: Frances Zhao #Completion Date: May 10 2021 #Program Name: Lesson8_3 #Description: Ask the user for a positive integer. #Print the ten times table for that number all on one line. # #***************************************************** #variable...
ed2ef09c332c147deb16090ad069b03acd0c2a0c
dineshbalachandran/mypython
/src/daily/daily4.py
1,325
3.765625
4
""" Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well. For example, the input [3, 4, -1, 1] should give 2. The input [1, 2...
637df499f8e005776dc26ab263a6468f6ea8d56b
apriantoa917/Python-Latihan-DTS-2019
/string in action/string comparasion.py
420
3.65625
4
# 5.1.10.1 String in action, 5.1.10.2 String in action # operator yang bisa digunakan ==,!=,>,>=,<,<= print('alpha' == 'alpha') print('alpha' == 'Alpha') #case sensitive print('alpha' != 'Alpha') print('alpha' > 'alpha') print('alpha' >= 'alpha') print('alpha' < 'alphabet') print('alphabet' < 'alpha') '10' == 10 '1...
f87959c25858522913c2e6d00e6857f6133810c5
thebigshaikh/PythonPractice
/randomGuess.py
424
3.84375
4
import random number=random.randint(0,10) print(number) while True: uinput=input("Enter a number? \n") print(uinput) if uinput.isdigit(): if int(uinput)==number: print("Woah You should be gambling!") break elif int(uinput)>number: print("AH too high") ...
4b238ca8ddb8721a47e2dda80b49ee0b93da0aea
dwilhelm/projecteuler
/problem_31.py
1,354
3.75
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- """ In England the currency is made up of pound, £, and pence, p, and there are eight coins in general circulation: 1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p). It is possible to make £2 in the following way: 1×£1 + 1×50p + 2×20p + 1×5p + 1×2p + 3×1p How...
5ab3ddae2c03f3a6e29670a72943cf117d4a4087
mossytreesandferns/CFPDXDataStorageObj
/ShouldIGoHiking.py
1,341
3.890625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Aug 23 23:00:47 2018 @author: meganporter """ """This is a boolean look at whether I should go hiking or not and whether I will draw in my nature journal or keep a photographic record. I won't go if it's below 45F or above 80F. I also won't go if I d...
da4c114a7f21d6cf027c12b7c30aeaf01c919bb8
dvncan/python_fun
/listcomprehension/evennumbers.py
99
3.59375
4
#lst = [x for x in range(2,21,2)] #print(lst) lst = [x for x in range(1,21) if x%2==0] print(lst)
32cf5bb3ec295b8f8807a9e03ac51ee44dadde5e
yveso/ProjectEuler
/0001-0100/0001-0020/0004/0004.py
264
3.765625
4
def is_palindrome(number): return str(number) == str(number)[::-1] answer = 0 for x in range(100, 1000): for y in range(x, 1000): current = x * y if is_palindrome(current) and current > answer: answer = current print(answer)
0ef4196ddf73b4da3eb64c1f5ce3ff02ccbdbd0f
sahilguptaBackup/learn-python
/dic.py
278
3.875
4
# customer = { # "name" : "sahil", # "age" : 25, # "is_verified" : True # } # # print(customer.get('name')) numbers = { '0' : 'Zero', '1' : 'One', } input = input('Enter a number ') output = "" for i in input: output += numbers.get(i, "") print(output)
67896feb38b6621bba529295a95735ac07bdab0b
lizawood/Apple-Health-Fitness-Tracker
/Package/myfitness/summary/maxmin.py
1,708
3.78125
4
# coding: utf-8 # In[ ]: def getMax(data): """ Find the maximum number of steps in the data and the date it was achieved. Parameters: data: Pandas DataFrame containing Apple Health data imported from a .csv file. Return: The row of values for when the ma...
e795bea0ba602aeecac5be55eadb7ecdfe156847
arsamigullin/problem_solving_python
/leet/amazon/trees_and_graphs/1334_Find_the_City_With_the_Smallest_Number_of_Neighbors_at_a_Threshold_Distance.py
3,641
3.609375
4
import collections import heapq from typing import List class SolutionWrong: def findTheCity(self, n: int, edges: List[List[int]], distanceThreshold: int) -> int: # a deque is faster at removing elements from the front graph = collections.defaultdict(dict) for u, v, dist in edges: ...
47d983b56b8db5afe7802a4ee8c87e39bb4030cd
jorgedelavg04/Algorithms-Analysis-
/Algorithms.py
5,255
3.703125
4
import matplotlib.pyplot as plt import numpy as np import time import random import sys sys.setrecursionlimit(1500) __Nombre__ = "Jorge C De la Vega C" ### Algoritmos ### # Insertion Sort(Ciclico) def insertionSort(arr): for i in range(1, len(arr)): key = arr[i] j = i-1 ...
c7b61c0a0684712788b9311295911d5db9536fe7
CB150/Exercice-Python
/Exercice 16.py
669
3.953125
4
#création de la fonction avec 2 paramètres def distance_hamming(str1,str2): cpt=0 #si la taille d premier mot n'est pas égale à celle du deuxième if (len(str1)!=len(str2)): #Renvoie la phrase ci-dessous et met fin au programme. return("Les mots ne sont pas de la même longueur") else: for i in range(len(str1)...
c5199c9198aa609a5c61c93f9d280ad37e6a49a4
gbucar/Sudoku
/new_possible.py
1,095
3.734375
4
def row_to_column(row): column = [[] for i in range(3)] for r in row: for ii, char in enumerate(r): column[ii].append(char) return column def create_base_three(): line = [i for i in range(3)] base = [] for a in range(3): base.append(create_order_row(line)) li...
2b2cc7d99e3ec57dbbd9268b2488767b179bbe9a
meetmemathanram/python_programs
/professional_tax.py
326
3.859375
4
from __builtin__ import str salary = int(input('Enter the salary. ')) employer_type = str(raw_input('Enter the type of employer. ')) def showpt(salary , employer_type): if(employer_type == "government"): print(salary) else: tax = 0.25*salary print(tax+salary) showpt(salary, employer_type...
9c86a3bc79a5611d9d7217dfaf538ce60c7fbdbb
Mr-Wolfram/MiniSQL
/test/mk.py
1,075
3.625
4
name = ['alice', 'bob', 'charlie', 'dave', 'eve', 'issac', 'ivan', 'justin', 'mallory', 'matilda', 'oscar', 'pat'] import random import string def generate_random_str( randomlength=1): """ 生成一个指定长度的随机字符串,其中 string.digits=0123456789 string.ascii_letters=abcdefghigklmnopqrstuvwxyzABCDEFG...
4ad1afb3d4de1d3eb451a5e5d79accc6f3ccc4f8
sherlockwu/programming_study
/python_practice/learn_2.py
496
3.671875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys import string def _greet_1(name): print("hello, %s" %name) def _greet_2(name): print("hi, %s" %name) def greeting(name_1): temp_len = len(name_1) if temp_len<=5: _greet_1(name_1) else: _greet_2(name_1) def test(): temp = sys.argv temp_l = len(...
8dbba7602b7988e28784dad99f0083e610d10919
catalinc/aoc2020
/src/day3.py
1,219
3.65625
4
import unittest from typing import List import sys def count_trees(grid: List[List[str]], right: int, down: int) -> int: w, h, r, c, cnt = len(grid[0]), len(grid), 0, 0, 0 while r < h: if grid[r][c] == '#': cnt += 1 c = (c + right) % w r = r + down return cnt def par...
1480e4f71cc8b0bc2b27f113937ba4b1cafe8cfb
saif93/simulatedAnnealingPython
/LocalSearch.py
2,948
4.125
4
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" implementation of Simulated Annealing in Python Date: Oct 22, 2016 7:31:55 PM Programmed By: Muhammad Saif ul islam """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" import math import random from copy import deepcopy ...
8a804aed82fafdaed8e26856906f352fcc35ab0e
Shalom91/Password-Checker
/tests/test_password_is_valid.py
927
3.515625
4
from password_checker.password_checker import password_is_valid import pytest # Testing for each condition of password_is_valid def test_password_is_valid(): with pytest.raises(Exception) as e: assert password_is_valid("") assert str(e.value) == "password should exist" with pytest.raises(Exception...
c0a3397f75247a87d9c55314f3e42e985ad1b5fc
Priyangshu-Mandal/JARVIS
/jarvis.py
4,881
3.65625
4
import time import pyttsx3 import datetime import speech_recognition as sr import wikipedia import webbrowser import os import random import pygame engine = pyttsx3.init('sapi5') voices = engine.getProperty('voices') engine.setProperty('voice', voices[0].id) def speak(audio): """ :param audio: any text ...
bfe1c225f11bca754da630d9bc38205732bfcb6a
sarthaksaini7/python
/learn33.py
202
3.859375
4
import random for i in range(3): number = random.randint(10, 20) print(number) for i in range(5): members = ['John', 'Mary', 'Harry'] leader = random.choice(members) print(leader)
0e3e33b0c280f36a86830a663507cc5923aa413a
sushengyang/yelp-review-sentiment-analysis
/src/util/reservoir_sampling.py
572
3.703125
4
import random def generate_sample(n, population): sample = []; for i, item in enumerate(population): if i < n: sample.append(item) elif i >= n and random.random() < n/float(i + 1): replace = random.randint(0, len(sample) - 1) sample[replace] = item ...
224890a992080b8a76830031954bb0551b6cfed1
szhmery/leetcode
/DFS-BFS/617-MergeTrees.py
2,390
3.84375
4
# Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: # DFS # 时间复杂度:O(min(m,n)),其中 m 和 n 分别是两个二叉树的节点个数。对两个二叉树同时进行深度优先搜索, # 只有当两个二叉树中的对应节点都不为空时才会对该节点进行显性合并操作,因此被访问到的...
37ece193102f1b3308efdf0ba4f98e15561f3b75
Andersonabc/practice_Python
/week7-1.py
3,648
3.921875
4
""" #分數四則計算 (若為 C 語言此題不使用陣列,必須使用指標) 此題自訂 add function,計算兩個分數相加。 function input -------------------- n1: 第一個數的分子 d1: 第一個數的分母 n2: 第二個數的分子 d2: 第二個數的分母 function output ------------------------------ numerator: 相加結果的分子 deniminator: 相加結果的分母 此題自訂multiply function 定義,計算兩個分數相乘。 function input -----------------...
55c180463bb42b0b6d5c679dd076ab481aa3596e
chenxu0602/LeetCode
/660.remove-9.py
966
3.609375
4
# # @lc app=leetcode id=660 lang=python3 # # [660] Remove 9 # # https://leetcode.com/problems/remove-9/description/ # # algorithms # Hard (51.70%) # Likes: 75 # Dislikes: 116 # Total Accepted: 5.4K # Total Submissions: 10.5K # Testcase Example: '10' # # Start from integer 1, remove any integer that contains 9 su...
d19f25a122306d614c3ca76a08892dd590d5260f
fl-ada/Toy_programs
/Python_programming/sort_maxnum.py
1,069
4.03125
4
# get maximum possible number by listing integers in array 'numbers' # 1 <= len(numbers) <= 100,000 # 1 <= elements in numbers <= 1,000 import numpy as np def fill_digits(numbers): # make all elements into 3 digit numbers new_numbers = [] for i in range(len(numbers)): if numbers[i] < 10: ...
13249c6c042ea783f89cbcbd81705e1773f98036
alemas/k-means-python
/iris_plant.py
1,153
3.75
4
import math class IrisPlant: sepal_length = 0 sepal_width = 0 petal_length = 0 petal_width = 0 name = "" def __init__(self, sl, sw, pl, pw, name): self.sepal_length = sl self.sepal_width = sw self.petal_length = pl self.petal_width = pw self.name = ...
2144c62172922791836baaa57b3d0eb1e29e36be
crampete/full_stack_course
/python/01_basic_python/03_control_statements/02_for/05.py
157
3.984375
4
desired_sum = 0 for number_iter in range(501): if number_iter % 3 == 0 and number_iter % 5 != 0: desired_sum += number_iter print(desired_sum)
24fdfbab8aff055f9fa550589e1d6048b652ec75
Gurendar/Python-Basic-Codes
/rock_paper_scissors.py
1,977
4.03125
4
# First Working Code for Rock-Paper-Scissors from random import randint # print(ord('p'),ord('P')) for i in range(1): class RPS(): def __init__(self): self.player1_name = input("Please enter your name: ") self.player1 = (input('Select any one of the options \nRock(r), ...
015d98f55c0664e8bd0d8b9d37f0f915f2ee3b1e
xujianhai/backtest
/backtest/backtest/Util/SetUtil.py
718
3.734375
4
#集合的操作 #交集 def intersection(a,b): return list(set(a).intersection(set(b))) #获取两个list 的并集 def union(a,b): return list(set(a).union(set(b))) #获取两个 list 的差集 def difference(a,b): return list(set(a).difference(set(b))) # a中有而b中没有的 def dict_to_string(dict): result = '' for key, value in dict.items(): ...
26d4fa2db35a791ee5016cd01490892c688007f2
mohithvegi/GFG
/Strings/multiplyStrings.py
448
4.03125
4
# https://practice.geeksforgeeks.org/problems/multiply-two-strings/1 #User function Template for python3 def multiplyStrings(s1,s2): # code here # return the product string return str(int(s1)*int(s2)) #{ # Driver Code Starts #Initial Template for Python 3 if __name__ == "__main__": t=int(input()) ...
b5f5c1ced9b8a4263a213e436d2654be4d93bf4e
serhansezgin/introtoprogramming
/serhansezgin_third_exercise_at_class_exercises.py
7,848
4.1875
4
''' def addtwo(a,b): print(a+b) return(a+b) print (addtwo(1,2) + 3) ''' ''' def season(month): if month == 1 or month == 2 or month == 12: print("winter") elif month == 3 or month == 4 or month == 5: print("spring") elif month > 5 and month < 9: pri...
bd2dd960e601bd594f913e0c448078e412d09bb4
sudiptapadhi/fibonacci-series
/datastr1.py
581
4.375
4
ASSIGNING ELEMENTS TO DIFFERENT LIST test_list = [9, 3, 6, 5] print("The original list : " + str(list)) list.extend(range(5)) print("The list after adding range elements : " + str(test_list)) ACCESSING DATA USING TUPLE tup1 = ('red', 'green', 9, 10); tup2 = (1, 2, 3, 4, 5, 6, 7 ); print "tup1[0]: ", tup1[0]; print "...
7b3812aefa02b1bf93d4cbfd1b7f00b4bbcaec93
espmihacker/study_python
/class1_2_08/02-private.py
285
3.71875
4
class Dog: # 私有方法 def __test1(self): print("------Messing") # 公有方法 def test2(self, money): if money > 1: self.__test1() else: print("余额不足!") print("------2") dog = Dog() dog.test2(-1)
6075a9f1544c77b0940a41ae7a489caceb4b53a4
karthikh07/Python-core
/Functions/No_Arg_No_Rtn.py
128
3.84375
4
def add(): a=int(input('Enter a value')) b=int(input('Enter b value')) c=a+b print(a,'+',b,'=',c) add()
e994a356226e3715799a012aaf61e44cb2d2ba98
beau-tie/Python-Library
/hatsAndGames/perfectNum.py
490
4.21875
4
# This program will determine if a number inputed is a perfect number or not def is_plus_perfect(n): digitsN = len(str(n)) number = str(n) digitPowerSum = 0 for i in number: x = int(i) digitPowerSum += x**digitsN return digitPowerSum n = input("Enter a number: ") pr...
8630cbac70723290cc6294d0f8a9550efecc58cc
hfsvv/python-basics
/testing/new.py
171
3.640625
4
lst=[1,2,3,4,5,6] s=0 #eveb or not for n in lst: if n%2==0: print(n) for i in range(0,len(lst)): print(lst[i]) # total sum for n in lst: s=s+n print(s)
6edc4c6b337133eded281ab3bda444f59a426b8f
CallumGray/Countdown
/TrieList.py
3,184
4.0625
4
from typing import List class TrieNode: def __init__(self, letter: str, complete_word: bool): # Letter of current node self.letter: str = letter # Children of this node self.children: List[TrieNode] = [] # If current node is a complete_word node self.complete_wor...
821bf0185688ef84f9ed2f703c36e16987aa2975
AnjoliPodder/Anjoli-Project
/podder_hw04_simple.py
1,900
4.09375
4
'''''' ''' Create a sorted list from the following list of 2-tuples by the second element of each tuple. The original list should be left intact. Hint: you could use list comprehension and lambda function Hint: ''' indata = [ ('a', 0), ('b', 2), ('c', 1), ] def sort_tuples(input): reversed = [(b, a) for a, ...
6ac836866f52a303b80078b593ad98920856cbe7
jinurajk/PythonProject
/TwitterPgm5.py
1,364
3.859375
4
#This programs is for retrieving tweets from a particular hashtag import json import TwitterLogin import os import codecs twitter_api = TwitterLogin.login_twitter1() iterator = twitter_api.statuses.sample() iterator1 = twitter_api.statuses.filter(track="Travel", result_type='recent', language="en") # Print each tweet...
e17b08273d7e4ef969ec3f1045a1b0428b8ac92d
siddu1998/PythonCP
/TurboSort.py
101
3.515625
4
t = int(input()) a = [] for i in range(t): a.append(int(input())) a.sort() print(*a, sep='\n')
1658511ddf06d9124b17445af3164864cdd45c39
nilearn/nilearn
/examples/05_glm_second_level/plot_second_level_design_matrix.py
1,994
4.34375
4
""" Example of second level design matrix ===================================== This example shows how a second-level design matrix is specified: assuming that the data refer to a group of individuals, with one image per subject, the design matrix typically holds the characteristics of each individual. This is used i...
fa9b779bc8e4f2c9d15ed623d75fc81feed61956
texnofile1/Python
/triangulos.py
843
4.15625
4
#ESTE PROGRAMA IDENTIFICA SI EL TIRANGULO INGRESADO #ES INVALIDO,ISOSELES,ESCALENO O EQUILATERO def es_triangulo(a,b,c): if int(a)> int(b) + int(c): return False elif int(b)> int(a) + int(c): return False elif int(c)> int(b) + int(a): return False else: return True def...
2eb09e042b4434cdc4a212ec62783493b69959f1
OneRaynyDay/MarkovChain
/FileReader.py
1,888
3.703125
4
import re, string, random class FileReader: fileName = "" listOfWords = [] RADIUS = 2 adjacencyMatrix = {} # Example : { ("a","b","c") : {"a" : 0, "b" : 2, "c" : 3} } def __init__(self, fileName): self.fileName=fileName with open(fileName,'r') as f: for line in f: ...
f3988cc49ca7ec3ce3937379fa982530684d14e3
ms-wanjira/python-class
/question16.py
288
3.6875
4
email=input("Enter email: ") password =str(input("Enter password: ")) def my_login(): x = email y = password if (x == "admin@gmail.com") and (y =="Admin@123"): print("Login Succesful!") else: print("Fail login!") my_login()
47032eb825f5e65f4718f292f21d7d65b31a1bcf
sjhaluck/sea-level-predictor
/sea_level_predictor.py
1,000
3.734375
4
import pandas as pd import matplotlib.pyplot as plt from scipy.stats import linregress def draw_plot(): # Read data from file df = pd.read_csv('epa-sea-level.csv') # Create scatter plot fig = plt.figure(figsize = (12,8)) plt.scatter(df['Year'],df['CSIRO Adjusted Sea Level']) # Create first li...
35cde7dbda15f3ce90190ee55c1d5387b89cce60
Vaironl/CarDatabase
/DBConnection.py
3,553
3.71875
4
import sqlite3 import os _db = None def initConnection(db): global _db _db = str(db) conn = sqlite3.connect(_db) cursor = conn.cursor() #Create tables cursor.execute('''CREATE TABLE IF NOT EXISTS carlist (ID integer primary key, make TEXT, model TEXT, year TEXT, horsepower TEXT, engi...
60440796a244ce64945c42c007c6258d5d67a19d
jin1101/Leetcode
/007Reverse Integer.py
294
3.6875
4
class Solution: def reverse(self, x): """ :type x: int :rtype: int """ reversed_int = int(str(abs(x))[::-1]) if reversed_int >= 2 ** 31 - 1 or x == 0: return 0 return reversed_int * -1 if x < 0 else reversed_int
b04f9423605f1e87a16056ea18a554dd91d8517c
DeepakSunwal/Daily-Interview-Pro
/solutions/roman_numerals.py
1,146
3.890625
4
def convert(string): result = 0 string_to_val_dict = {"I": 1, "IV": 4, "V": 5, "IX": 9, "X": 10, "XL": 40, "L": 50, "XC": 90, ...
aee989de3a8e3bff4b771a9387874d9745a6a89c
somewayin/MyComputerCollegeCourses
/leetcode/langqiao_419/括号匹配.py
420
3.75
4
s=[] def permutations(arr, position, end): if position == end: print(arr) s.append("".join(arr)) else: for index in range(position, end): arr[index], arr[position] = arr[position], arr[index] permutations(arr, position+1, end) arr[index], arr[position] = arr[position], arr[index] arr = ["(","(","(","...
aaa5b13b59f4193477d16020cf8dabe987d3e598
pandrey76/Python-Project-By-Lynda.com
/3. 3. Using Design Patterns/08. Creating the maze in Python using the Builder design pattern/CountingMazeBuilder.py
1,200
3.75
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- #------------------------------------------------------------------------------- # Name: модуль1 # Purpose: # # Author: Prapor # # Created: 05.09.2017 # Copyright: (c) Prapor 2017 # Licence: <your licence> #--------------------------------------------...
9be4acd802f7f7e9c1d5df6310b4bfbed7de16c9
coolsnake/JupyterNotebook
/new_algs/Graph+algorithms/Hungarian+algorithm/templateMatching.py
6,094
3.5625
4
import cv2; import numpy as np; #https://docs.opencv.org/3.1.0/dc/d2e/tutorial_py_image_display.html # input = cv2.imread('templates/test.jpg', cv2.IMREAD_COLOR); version = "Laplace"; if version == "Laplace": mode = cv2.IMREAD_GRAYSCALE; else: mode = cv2.IMREAD_COLOR; #Templates to match again...
90b3f24e17c215fa3f5bfa7680be1473d55a29d9
abhishekjani123/CodeChef-Solved-Questions
/Beginner - ATM [HS08TEST].py
150
3.5625
4
x,y = input().split() x = int(x) y = float(y) if(x%5 == 0 and x+0.50<=y): x = x+0.50 t = y-x print('%0.2f' %t) else: print('%0.2f' %y)
07f31bfac40b12e353347b0bde03b2d0d436a4c1
sethdeane16/projecteuler
/resources/pef.py
4,135
4.46875
4
import math import sys def is_pandigital(number): """ Determine if a number is pandigital. https://en.wikipedia.org/wiki/Pandigital_number Args: number: Number to check for pandigitality. Returns: True if number is pandigital, False otherwise """ number = str(number) ...