blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
5d440ddbf15e8efb9a1f84a0c76aa4500e12e586
kliner/leetcode
/242.py
556
3.515625
4
class Solution(object): def isAnagram(self, s, t): """ :type s: str :type t: str :rtype: bool """ a = [0 for i in xrange(256)] if len(s) != len(t): return False for ch in s: a[ord(ch)]+=1 for ch in t: a[ord(c...
efccdc4e1f31fb2bbe290c886d61e62a9569aa44
ElliottBarbeau/FYOScript
/Science/Student.py
573
3.53125
4
class Student: """Class for student""" def __init__ (self, name, answers, longAnswers, email): self.longAnswers = longAnswers self.matches = {} self.name = name self.answers = answers self.isMatched = False self.mentor = None self.temp = [] self.topMentors = [] self.email = email def setMatch(sel...
5771b6e5cd964e0fa1313d5e2ddb8c8ca07b4b79
M4cs/Ease-of-Use-Python-Scripts
/DupeRemover.py
1,969
3.75
4
class header: banner = """ DupeRemover by Macs Version: 1.0 Description: Remove duplicate combinations from your Combo lists. Works with 1 line, 1 combo format lists. Instructions: 1. Start the program by entering a lowercase y when prompted. 2. Input file name of Combolist (don't in...
cb27f80c0268793c4c76cf9a6778ea203f58b5c2
anastasiacebotari15/Instructiunea-If-While-For
/probl5.py
904
3.921875
4
"""Conform calendarului japonez fiecare an poarta numele unui animal.Fiecare denumire se repeta exact la 12 ani.Deci, un ciclu este format din 12 ani cuurmatoarele denumiri de animale in aceasta ordine:sobolan,bou,tigru,iepure,dragon,sarpe,cal,oaie,maimuta,cocos,caine,porc. Stiind Stiind ca anul 2000 a fost anul dr...
c34867bdd646ad0cdb3253a89549f161cd24e51f
AFreeDreamer/show-me-the-code
/answer/0004/T0004.py
444
3.78125
4
import re from collections import Counter # 任一个英文的纯文本文件,统计其中的单词出现的个数。 def getWordsList(filename): ret = [] with open(filename, 'r') as f: lines = f.readlines() [ret.extend(re.findall(r'[a-zA-Z]+', line)) for line in lines] return ret print(Counter(getWordsList(r'.\words.txt')).most_common...
525917e352167bc921da540dbc6d135ae3a561fb
atm1504/tkinter-learn
/database.py
7,202
4.03125
4
from tkinter import * from PIL import ImageTk, Image import sqlite3 root = Tk() root.title("Learning Tkinter") root.iconbitmap("./images/quality.ico") root.geometry("800x800") # database # # create a database or connect to one # conn = sqlite3.connect("address_book.db") # # Create Cursor # c = conn.cursor() def su...
2e692e8811f3fa78bcd38ee7aeecda58dac2b956
anderson-br-ti/python
/Projetos/testando f no print.py
261
3.625
4
salário = int(input('Salário: ')) porcentagem = int(input('porcentagem: ')) salário_final = salário + (salário * porcentagem/100) aumento = salário_final - salário print ('Salário final é %.2f' %(salário_final)) print ('Aumento de %.2f' %(aumento))
ffd3278aaa3d16f24f77e2ca4ae1640f51e62f66
MrHamdulay/csc3-capstone
/examples/data/Assignment_2/mskdan001/question2.py
2,442
3.953125
4
ans=str('yes') print("Welcome to the 30 Second Rule Expert") print("------------------------------------") print("Answer the following questions by selecting from among the options.") while True: a=input("Did anyone see you? (yes/no)\n") if a==ans: b=input("Was it a boss/lover/parent? (yes/no)\n"...
629c610bfe934d2d495ec5f69df30580919c96af
savi003/HacktoberFest2021
/extrasession/pythonfiles3/greaterthan.py
844
4.15625
4
# Given an integer array Arr of size N the task is to find the count of elements whose value is greater than all of its prior elements. # Note : 1st element of the array should be considered in the count of the result. # For example, # Arr[]={7,4,8,2,9} # As 7 is the first element, it will consider in the result. ...
647a6ef010f2ba7a1ece36b0be06064541e59028
RahulTechTutorials/PythonPrograms
/Graphics/Plotx2andx3graph.py
673
4.1875
4
import matplotlib.pyplot as plt def plotfunction(a,b,step): nsteps = int((b-a)/step) x = [a+step*i for i in range(nsteps+1)] y1 = [t**2 for t in x] y2 = [t**3 for t in x] plt.plot(x,y1,'ro--',label = 'x vs x**2') plt.plot(x,y2,'r<-.',label = 'x vs x**3') plt.legend() plt.xlabel('X') ...
0c335062977e50102bc47c8922cfab96abe2508e
grevutiu-gabriel/PythonPrograms
/Sentence Alternate Worder Program.py
273
3.828125
4
#Sentence alternate worder #Sentence breakdown #input Sentence to breakdown Sentence= (input("What sentence would you like analysed?")).upper() #Breking down and choosing letters y=1 while y in range (1,len(Sentence)): print(Sentence[y]) y= y+2
d287fd7b2856cfceb6bc0ff114d4b8eaee9cfb00
skywalker-0104/exLinux
/Projects/Python-Projects/Multiplication-Table.py
451
3.8125
4
""" Author; Captain Murlidhar Singh Purpose; The Multiplication Table Using Python3 Date; 15 october 2020 """ print('\n" THE MULTIPLICATION TABLE "') print("Enter The Number [a]") a=int(input()) print('The Table Of [a] :- \n') print('a*1=', a*1) print('a*2=', a*2) print('a*3=', a*3) print('a*4=', a*4) print('a*5=...
e68dcfae05644280bd9d3713342d3d1f5465bc8f
yonlif/FinancialAlgorithms
/Ex6.py
1,595
3.890625
4
from typing import List """ Implementing algorithm A (Greedy) - pick the highest value until full. """ weights = [100] + [2] * 50 max_weight = 100 def choices(values: List[float]) -> List[bool]: weight_sum = 0 pick_list = [] # Sorting the items by value sorted_values_weights = sorted(zip(values, wei...
c650a6ba2203464a75aebd88ce1bbc75d843bdc0
GongFuXiong/leetcode
/topic10_queue/T239_maxSlidingWindow/interview.py
2,322
3.78125
4
''' 239. 滑动窗口最大值 给定一个数组 nums,有一个大小为 k 的滑动窗口从数组的最左侧移动到数组的最右侧。你只可以看到在滑动窗口内的 k 个数字。滑动窗口每次只向右移动一位。 返回滑动窗口中的最大值。 进阶: 你能在线性时间复杂度内解决此题吗? 示例: 输入: nums = [1,3,-1,-3,5,3,6,7], 和 k = 3 输出: [3,3,5,5,6,7] 解释: 滑动窗口的位置 最大值 --------------- ----- [1 ...
4515fdd26dca6836bb5b8b2d9350231caa5c85c1
Arditagalliu/Python-Beginners-Notes
/HelloWorld.py
3,826
4.4375
4
# This is our first python script # import a library with extra math operations from math import * import Modules ''' First we learn how to print something to the terminal with the print() built-in function ''' print("----------------------------------\n" "Hello World\nWelcome to Python\n" "------...
3f7889f5896aa56b7b6002caec6cbf2a595c9fef
malaffoon/euler
/python/utils/harshad.py
3,583
3.6875
4
"""Helpers for dealing with Harshad numbers A harshad number is a number that is divisible by the sum of its digits. NOTE: we are considering only base-10 harshad numbers. https://en.wikipedia.org/wiki/Harshad_number https://oeis.org/A005349 First 61 harshad numbers: 1,2,3,4,5,6,7,8,9,10,12,18,20,21,24,27,30,36,40,4...
d7811c13bf22e4eca828b78e42b10363d241c24e
Rahul0506/Python
/Worksheet1/1-11.py
1,066
4
4
1. 12 2. i. Not legal, reserved ii. Legal iii. Legal iv. Legal v. Not legal, starts with a number vi. Not legal, special character vii. Legal viii. Legal 3. i. bool ii. float iii. string iv. int v. string vi. float vii. string viii. bool ix. string x. int xi. float...
e4bd1a960dbf87e198c0cae9fc220addca830f65
robobyn/code-challenges
/return-substring.py
724
4.1875
4
def return_longest_substring_length(character_str): """Returns the length of longest substring of unique characters.""" substring = "" counter = 0 highest_count = 0 longest = "" for char in character_str: if char not in substring: counter += 1 substring += char...
373bbbd9b0abef889adca263018bcc98124c9a3a
aksa1/infoshare_2
/my list.py
1,259
4.21875
4
# my_list = list(range(0,11,2)) # my_list.append(13) # print(my_list) # # my_list.reverse() # print(my_list) # my_list2 = reversed(my_list) #@ todo: sprawdzy czy my_list jest indet z my_list2 my_list = list(range(10)) my_list2 = reversed(my_list) #@ todo: sprawdzy czy my_list jest indet z my_list2 print(my_list) print...
e9f22d1740b00ca2fb60b2c0df3c834507eda557
malhotrasahil/coding_ninjas
/pycharm/loops_&_pattern/pattern_12.py
350
3.8125
4
n=int(input()) i=0 while i<=n: space=0 star=1 rev_star=1 while space<=i: print(' ',end='') space +=1 while star <=n-i: print('*', end='') star +=1 while rev_star <=n-i-1: print('*', end='') rev_star +=1 i=i+1 print() ...
49290de5e94860d7029b731b865bd84896b6a04c
Shaikhmohddanish/python
/python/challenges/2.py
403
3.5625
4
user=int(input("Speed De apun uski maarta hai BTC :")) def speed(n): point=0 if n<=70: print("OK") elif n>70: for i in range(0,((n-70)//10)*2): point+=1 if point>=12: print("LICENCE SUSPENDED") if user%5==0 and user%10!=0: point+=1 for i in ra...
911e6f96a110a0cbe42cae070903fc34c01f054d
Joel-Flores/ejercicios_python
/4.Ejercicios_de_listas_tuplas/ejercicio_1.py
323
4.03125
4
''' Ejercicio 1 Escribir un programa que almacene las asignaturas de un curso (por ejemplo Matemáticas, Física, Química, Historia y Lengua) en una lista y la muestre por pantalla. ''' def run(): curso = ['Matemáticas', 'Física', 'Química', 'Historia', 'Lenguaje'] print(curso) if __name__ == '__main__': run()
56b44ba45b055e6833b3f3b4e320babf4c397750
Amrithasuresh/Useful_Scripts
/merge_excel_file/merge_two_files.py
536
3.625
4
#sample files dataset1.xlsx and dataset2.xlsx are provided #BTW pandas are fantastic import pandas as pd #Writing in excel from pandas import ExcelWriter # Write to the file name writer = ExcelWriter('common_dataset.xlsx') #read files x1 = pd.ExcelFile("dataset1.xlsx") x2 = pd.ExcelFile("dataset2.xlsx") #read the ...
45bdc6f0c97e9333006881b574e8e73c9ab53211
rich1123/PythonFundamentals.Exercises.Part5
/palindrome.py
318
4.34375
4
def is_palindrome(value: str) -> bool: """ This function determines if a word or phrase is a palindrome :param value: A string :return: A boolean """ reverse = value[::-1] if reverse == value: return True elif reverse != value: return False # is_palindrome('madam')
b39a3120ef38dae768786bfbd724729a3329ee0a
Extomvi/GDGUnilag
/inPython/datastructures/findlongestsubarray.py
540
3.546875
4
"""Finding the longest Subarray by Sum""" class Solution: def findLongestSubarrayBySum(self, s: int, arr: List[int]) -> int: result = [] sum = 0 left = 0 right = 0 while (right < arr.length): sum += arr[right] while (left < right and sum...
fdf5646eeab165a4cf2979c160c9364e6dfff2b1
josue0ghost/Python-Exercises
/14-fileSystem/directories.py
425
3.53125
4
import os, shutil # create folder if not os.path.isdir("./my-folder"): os.mkdir("./my-folder") else: print("The folder 'my-folder' already exists") # delete folder os.rmdir("./my-folder") # copy folder original_Path = "./my-folder" new_Path = "./my-folder (copied)" shutil.copytree(original_Path, new_Path) #...
6530bde1597b298c09cb65d402f14f5f46dcbf2d
sushantkumar-1996/Python_GeeksForGeeks
/Python_RandomNo.py
410
4.3125
4
"""Python Program to generate a Random number--- For this purpose we will be using randint() function which belongs in random module which can be found in python tutorials section""" import random a = int(input("Enter Lower Limit of Random number")) b = int(input("Enter Upper Limit of Random number")) print(random.ran...
26a5fd6ef185deb53b3063af45db96b08f321ba6
jtristao/SCC530-Path-Finder
/Maze/stats.py
2,251
3.859375
4
from Maze import Maze import matplotlib.pyplot as plt import numpy as np import Algorithm import Animation def plot_result(tamanhos, result, title): labels = [str(name) for name in tamanhos] x = np.arange(len(labels)) # the label locations width = 0.12 # the width of the bars fig, ax = plt.subplots() offset =...
295fe15f75a214b83519f7655e4a99200681d391
RonanChance/competitive-programming
/AlphabetSpam.py
358
3.984375
4
import fileinput file = fileinput.input("test.txt") line = file.readline() count = len(line) symbols = 0 for char in line: a = ord(char) if a < 48: symbols += 1 if 57 < a < 65: symbols += 1 if 90 < a < 95: symbols += 1 if a == 96: symbols += 1 if a > 122: ...
a9c61f5ebed1bead37303b7feef8fb9567878fc1
karolinanikolova/SoftUni-Software-Engineering
/2-Python-Fundamentals (Jan 2021)/Course-Exercises-and-Exams/06-Objects-and-Classes/01_Lab/01-Comment.py
1,344
3.890625
4
# 1. Comment # Create a class with name "Comment". The __init__ method should accept 3 parameters # • username # • content # • likes (optional, 0 by default) # Use the exact names for your variables # Note: there is no input/output for this problem. Test the class yourself and submit only the class # class Comment: # ...
a2168ff7a99fa7d927bfdee20b876716815d5ce8
yongsoo-kim/basic_agorithms_and_data_structures
/python_algo_interview/ch.6_string_manipulation/ex.1_Valid Palindrome/ex.1_Valid Palindrome_onbook3.py
602
3.78125
4
# Quiz description URL: # https://leetcode.com/problems/valid-palindrome/ # Point: # Use Slicing # result # Runtime: 32 ms, faster than 98.11% of Python3 online submissions for Valid Palindrome. # Memory Usage: 15.7 MB, less than 24.18% of Python3 online submissions for Valid Palindrome. class Solution: def isPa...
2f023ece23979926df0d226a12a7ef0026ae98d2
Zahed75/Python_practice
/swap_two_value.py
203
4
4
num1 = int(input("please enter your first number:")) num2 = int(input("please enter your Second number:")) temp= num1 num1=num2 num2=temp print("the 1st value is",num1) print("the 2nd value is",num2)
6b42ccb99cbc1b63f2b65103c2ed2beb06aecd25
gabriellaec/desoft-analise-exercicios
/backup/user_083/ch37_2020_03_12_22_13_12_295242.py
176
4
4
senha=True while(senha): a=input('diga uma palavra: ') if a!='desisto': print('Continue tentando') else: senha=False print('Você acertou a senha!')
7c5ae6c6f27838b2112af8fe8a47da5add1bb704
Ryanjso/DS2000-1
/Practicums/Practicum-3/Practicum_3.py
1,877
3.890625
4
# DS2001 # Practicum 3 # Ryan Soderberg # Part 0 - Get the Data FORECLOSURES = [ 11, 10, 6, 8, 4, 13, 11, 8, 6, 10, 3, 4, 10, 10, 6, 2, 6, 8, 10, 11, 14, 6, 10, 6, ] PETITIONS = [ 44, 50, 6, 14, 12, ...
d876ba1f778de1620987144e8acf92ccf3c6b18a
ivansaji/TCS-IRA-practice
/Python/EmloyeeOrganizationLeave/Employee_Leave.py
2,069
4.03125
4
class Employee: def __init__(self,employee_name,designation,salary,leaveBalance): self.employee_name = employee_name self.designation = designation self.salary = salary self.leaveBalance = leaveBalance class Organization: def __init__(self,employee_list): self.employee_l...
335e9e8d2bc7d86e17a400353ba007c888f7615d
wwtang/code02
/list2.py
2,527
4.53125
5
# D. verbing # Given a string, if its length is at least 3, # add 'ing' to its end. # Unless it already ends in 'ing', in which case # add 'ly' instead. # If the string length is less than 3, leave it unchanged. # Return the resulting string. def verbing(s): # +++your code here+++ if len(s) >= 3: if s[-3:...
cef242f4c75caa50f317dd9dbeea7c310cec3e3f
huixionghexiyi/hx-notebook
/b-language/python/b-common-pkg/request库的使用.py
3,134
3.5625
4
import requests ''' 常见异常 requests.ConnectionError 网络连接异常:DNS查询失败、拒绝访问等 requests.HTTPError HTTP错误 requests.URLRequired URL缺失 requests.TooManyRedirects 超过最大重定向次数 requests.ConnectTimeout 从发送url到返回整个过程的超时异常 requests.Timeout 与远程服务器连接的超时异常 ''' # 构造一个像服务器请求资源的Request对象给服务器 ,并返回一个Response对象 ''' get(url,param,kwargs) r ...
4b236c235d6a101bd56ce89fcf42652e54be26fb
Rahul-Sagore/hackerrank-python
/two-string.py
508
3.796875
4
#!/bin/python3 import os from collections import Counter # Complete the twoStrings function below. def twoStrings(s1, s2): s1Ctr = Counter(s1) s2Ctr = Counter(s2) return 'NO' if len(s1Ctr) + len(s2Ctr) == len(s1Ctr + s2Ctr) else 'YES' if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], ...
b606572f5ae6e0a9821d4af4544b110cad244b67
MarcusVinix/Cursos
/curso-de-python/exemplos/listachr.py
167
3.515625
4
i = 1 while i < 255: print(i, "-->", chr(i)) i += 1 codigoAscii = [] i = 1 while i < 255: codigoAscii += (i, "-->", chr(i)) i += 1 print(codigoAscii)
5519ede7f80a1d949ffae0be9fd3cb8e54e9af0a
gengo/jirasurvivor
/src/survivor/timeutils.py
1,570
3.9375
4
"Time and timezone helpers" from datetime import datetime, timedelta, tzinfo import time def with_local_tz(dt): """ Returns a copy of a datetime with the local timezone attached. No conversion happens; `datetime` is assumed to already represent a local time. Use this function when interoperating with...
6d1cfab3cacdb30798ada9215042d7df91837139
fovegage/learn-python
/数据结构/搜索/二叉搜索.py
578
3.921875
4
# -*- coding: utf-8 -*- # @Time : 2018/12/30 16:00 # @Author : fovegage # @Email : fovegage@gmail.com # @File : 二叉搜索.py # @Software: PyCharm # 假设存在一个有序的列表 我们不断地取中间进行搜索 def binsearch(target, list): left = 0 right = len(list) - 1 while left <= right: mid = (left + right) // 2...
85a1f90d041e7a4cc7798ff138173683279e9857
lvfds/Curso_Python3
/mundo_2/desafio_037.py
1,191
4.3125
4
""" Escreva um programa que leia um número inteiro qualquer e peça para o usuário escolher qual será a base de conversão: - 1 para binário. - 2 para octal. - 3 para hexadecimal. """ cor_vermelha = '\033[1;31m' limpar_cor = '\033[0m' numero_inteiro = int(input('Digite um número: ')) numero_escolhido_p...
b75bbb656823ec32bd847fe4b0dfeaff85274da8
codingJWilliams/codingChallenges
/002/002.py
963
4
4
print("Type numbers, with an enter inbetween. Type a for average or q for quit.") userValues = [] # Store the values while True: # Forever loop currentInput = input(">") # Get input from user if currentInput == "a": ...
bbb62e5adbba9472d8ece3a3fbaad73a8ef26811
limsehui/likelionstudy
/8,9일차/number.py
324
3.796875
4
five1 = 5 five2 = 5.0 five3 = 5.00000 print(five1) print(five2) print(five3) five4 = 5 * 1 five5 = 5 * 1.0 print(five4) print(five5) div1= 6 /5 div2= 6 // 5 print(div1) print(div2) a =6 b = 5 print(a==b *(a//b)+(a%b) print(0.1 + 0.1 == 0.2) print(0.1+0.1 +0.1==0.3) print(int (5.0)) print(float(5)) print(5* ...
3dd523ee0c2f6caccb282d87c490bce1883dffcf
donsolana/Hotels_in_lagos
/Consume Hotel API.py
517
3.65625
4
# Import package import requests import pandas as pd # Assign URL to variable: url url = 'https://hotels-apis.herokuapp.com/state/lagos' # Package the request, send the request and catch the response: r r = requests.get(url) # Decode the JSON data into a dictionary: json_data json_data = r.json() # Pri...
b76aaa58c39c6969d02118500d2bc2eb056caff4
rowan-maclachlan/IPDSDGA
/Gene.py
4,069
3.921875
4
""" This class is a wrapper for the list of characters that the gene is. In our genetic algorithm, the rule is defined by a binary decision tree, encoded as a string of 'c's and 'd's. The logic of a rule's decision making is within this class. """ import auxiliaryGenetics as ag import random import math from params i...
303e8ac3b62a7b57a43d2faaa224470c26cb793c
jluocc/jluo2018
/python/python/老师笔记/python/day06/day06/exercise/list2.py
338
3.96875
4
# 1. 输入三个数,存于列表中,打印出这三个数的最大值,最小值和平均值 a = int(input("请输入第1个数: ")) b = int(input("请输入第2个数: ")) c = int(input("请输入第3个数: ")) L = [a, b, c] print("最大值是:", max(L)) print("最小值是:", min(L)) print("平均值是:", sum(L)/len(L))
07e846c8bbef233c999478b12fb6e09927731a93
balajikulkarni/hackerrank
/Sherlock-and-Cost.py
425
3.671875
4
#!/bin/python3 import sys from collections import Counter def isValid(s): count = [] validate =0 for _,cnt in Counter(s).items(): count.append(cnt) count = sorted(count) for i in range(1,len(count)): if count[i]-count[i-1] >= 1: validate +=1 if validate >=1: ...
478b12e2a0e65b4b3bb0588de1b693bf8cd76889
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/leap/d3ce9693fcc644e8af1ab52997b9b2a5.py
103
3.609375
4
def is_leap_year(year): return True if year%4 == 0 and (year%100 != 0 or year%400 == 0) else False
6043deba6310d136a8849c6b39f577fd90609420
tbrotz/ProjectEuler
/Problem0009.py
637
3.921875
4
#~ Special Pythagorean triplet #~ Problem 9 #~ A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, #~ a2 + b2 = c2 #~ For example, 32 + 42 = 9 + 16 = 25 = 52. #~ There exists exactly one Pythagorean triplet for which a + b + c = 1000. #~ Find the product abc. i = 1 while True: j = i + 1 w...
eef206afe25b509b0de0f2cf9633972bf4ba79e8
iwema/PfB2017_problemsets
/Python_Biologists.py
14,681
4.25
4
#Chapter 2 : Printing and manipulating text # Calculating AT content dna = "ACTGATCGATTACGTATAGTATTTGCTATCATACATATATATCGATGCGTTCAT" A = dna.count("A") T = dna.count("T") length = len(dna) AT_content = (A + T) / length print("The AT content is " + str(AT_content)) print("The DNA length is " + str( length)) print("A c...
7eb7db1bcff9b122083f044d10d6a6e57d001b32
nagalr/algo_practice
/src/main/Python/LinkedList/find_cycle_in_LinkedList.py
274
3.609375
4
def detect_cycle(head): if head.next is None: return head curr = head nodes_set = set() while curr: if curr not in nodes_set: nodes_set.add(curr) curr = curr.next else: return curr return None
7d213669f1b65a2826752ad55fee410c56a91444
pideviq/quizzes
/Python/break_rings.py
5,327
3.890625
4
''' == EN == A blacksmith gave his apprentice a task, ordering them to make a selection of rings. The apprentice is not yet skilled in the craft and as a result of this, some (to be honest, most) of rings came out connected together. Now he’s asking for your help separati...
6caea43dc7f9f9f799252d641eea3cc3dd7ca8a0
0xDECAFC0FFEE/Euler
/27.py
819
3.796875
4
def primes(maxNum): def primesRecursive(arrayOfMaybePrimes): if (len (arrayOfMaybePrimes) == 1): return arrayOfMaybePrimes else: return [arrayOfMaybePrimes[0]]+primesRecursive([ x for x in arrayOfMaybePrimes[1:] if not(x%arrayOfMaybePrimes[0] == 0)]) return primesRecursive(list(range(2,maxNum+1))) listOf...
c0e7e8c86814d0a22a6b26aed7f30af5a3289078
princo19/python-practice
/cls2.py
143
3.625
4
class test: l=10 b=10 def area(self,l,b): print("area is",self.l*self.b,"\n area is:",l*b) ob1=test() ob1.area(5,6)
47942081793f32048bbb4d89986ba633fc18dc79
naomatheus/daily-interview
/skyline.py
639
4.125
4
# This problem was recently asked by Facebook: # Given a list of buildings in the form of (left, right, height), return what the skyline should look like. # The skyline should be in the form of a list of (x-axis, height), where xaxis is the next point where there is a change in height starting from 0, and height is th...
3e53f62af24f686edb114b448f9c5612f462c386
jed4h/BESI_Basestation
/Localization_test/generatData.py
2,768
3.8125
4
import random TOTAL_ROOMS = 3 # possible rooms 0, 1, or 2 START_ROOM = 0 TOTAL_TIME = 50 P_LEAVE = 0.3 # probability of leaving a room during a given timestep P_CHANGE_CONNECT = 0.8 # probability that the connection will switch to the correct room P_DS_TRIGGER = 0.95 # porbability that the door sensor will...
1bfdabd0cec2c25f14bf4b00ad447586de4c9130
stephenchenxj/myLeetCode
/rotate.py
733
4
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Mar 3 15:29:50 2019 @author: dev """ class Solution(object): def rotate(self, nums, k): """ :type nums: List[int] :type k: int :rtype: None Do not return anything, modify nums in-place instead. """ r...
7b730b0c8ba2af9b5b70017a0c9499cce07029c1
AATopp/AllaT_Portfolio_Data_Scientist
/Python Practice problems/a mean of n.py
253
4.15625
4
# For loop -> A mean of n # Write a program that calculates the arithmetic mean. The arithmetic mean is a sum of all numbers divided by their total count. n = int(input()) sum_i = 0 for i in range(n): x = int(input()) sum_i += x print(sum_i/n)
3222a5cf41be21fcc669967efd1db897db19ffe7
RichardEsquivel/Sprint-Challenge--Data-Structures-Python
/names/names.py
2,773
3.609375
4
import time start_time = time.time() f = open('names_1.txt', 'r') names_1 = f.read().split("\n") # List containing 10000 names f.close() f = open('names_2.txt', 'r') names_2 = f.read().split("\n") # List containing 10000 names f.close() duplicates = [] # Return the list of duplicates in this data structure # Re...
f797ec654ae24188b6c90664e73d82d3334bbd7d
betty29/code-1
/recipes/Python/492223_ProtectUTF8/recipe-492223.py
1,840
4.40625
4
def protect_utf8(wrapped_function, encoding='UTF-8'): """Temporarily convert a UTF-8 string to Unicode to prevent breakage. protect_utf8 is a function decorator that can prevent naive functions from breaking UTF-8. If the wrapped function takes a string, and that string happens to be valid UTF-8,...
c53a7671b59a54e8a93338e8705f54004293f7e9
AlmogAlon/CSVChain
/main.py
3,403
3.828125
4
import csv from abc import ABC, abstractmethod class Cursor: def __init__(self, file_name): self.file_name = file_name self.current_line = None self.current_result = None self.index = 0 input_file = open(file_name, "r") self.reader = csv.reader(input_file) #...
2bbbb1d0ea3c69147054b731388ac8a95e947524
Pyroshark42/Python-Programming-Practical-4
/Q6_Prac_4.py
161
3.59375
4
# q6_compute_sum.py def sum_digits(n): num = str(n) digitSum = 0 for i in num: digitSum += int(i) return digitSum print(sum_digits(875))
513522504b4f265f4506a71569dc18bc75b7caa9
yamauchih/3b1b_manim_examples
/graph_2d/example_graph2d_02.py
4,505
3.890625
4
# -*- coding: utf-8; -*- # # Graph 2D example 02 # Copyright (C) 2020 Hitoshi Yamauchi # # License: BSD 3-Clause License # # References: # * 3Blue1Brown (https://github.com/3b1b/manim) # * Todd Zimmerman (Talking Physics https://talkingphysics.wordpress.com/) # * Theorem of Beethoven (https://www.youtube.com/channel...
0902dd493d5b1535b85640e026d331414ec7142f
JamesMakovics/PythonClassProjects
/Programs/StringsExercises/digits.py
195
3.625
4
#Returni a itring with only numberi def getDigits(s): x = 0 newInt = "" while x <= len(s) - 1: if s[x].isdigit(): newInt += s[x] x += 1 return newInt
d63b98cc6820f5f8475c01ba6782759073b3bd24
rtsfred3/PythonExamples
/1 - Python/13 - MathDojo.py
529
3.8125
4
class MathDojo: def __init__(self): self.result = 0 def add(self, num1, *nums): self.result += num1+sum(nums) return self def subtract(self, num1, *nums): self.result -= num1+sum(nums) return self def main(): print('==MathDojo==') md = MathDojo() ...
62c0eb6baa5ce9f8127352ec4e158d8787c897dc
arjungoel/Real-Python
/str_repr_2_demo.py
500
4.375
4
# __str__ vs __repr__ # __str__ is mainly used for giving an easy-to-read representation of your class. # __str__ is easy to read for human consumption. # __repr__ is umambiguous and the goal here to be as explicit as possible about what this object is and more meant # for internal use and something that would make thi...
321819584c7e437ecf3fe74553f88ea2eb6f96e5
phucle2411/LeetCode
/Python/univalued-binary-tree.py
611
3.984375
4
# https://leetcode.com/problems/univalued-binary-tree/ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def isUnivalTree(self, root): """ :type root: Tr...
c52f329084efd4806c3f740619b5bcc83eeb5814
FleeaniCh/python
/first_step/exception_handling/ex01_exception.py
488
3.8125
4
""" 定义函数,在控制台中获取成绩函数 要求:如果异常,继续获取成绩,直到得到正确的成绩为止; 成绩还必须在0--100之间 """ def get_score(): while True: try: score = int(input("请输入成绩:")) except Exception: print("未知错误") continue if 0 <= score <= 100: return score re = get_...
b533517eb4276181c05a9f0a907160b60e71dd59
Tella-Ramya-Shree/Python_Assignment
/321810304048-Area of circle.py
121
4.34375
4
#Area of circle pi=3.14 r=float(input('Enter the radius of the circle:' )) Area=pi*r*r print("Area of the circle:" ,Area)
d8fcaba9c91db5d3f0523fe9097aa05ba6037957
KseniaMIPT/Adamasta
/1sem/lab10/m_task_1.py
121
3.578125
4
__author__ = 'student' A = set('bqlpzlkwehrlulsdhfliuywemrlkjhsdlfjhlzxcovt') B = set('zmxcvnboaiyerjhbziuxdytvasenbriutsdvinjhgik') C = str() for x in A: if x not in B: C += x print(C)
30a49267b8854ef35125b85921cee5eaba89f758
aanand5003/gitLab
/Week11/Task02.py
5,314
3.796875
4
from Task01 import * import timeit """ @name: shourya raj @email id: sraj0008@student.monash.edu @created on: /05/2019 """ def load_dictionary(hash_table, filename): """ Reads each line of text into a string, returning a list of strings associated to the file :param name: The String name of the fi...
aed64458756ff11ca7de48c047ae4e9d86c32c0e
Xlaaf/weather-scrape-google
/wibu.py
563
3.8125
4
import requests import bs4 # Taking thecity name as an input from the user city = "palembang" # Generating the url url = "https://google.com/search?q=weather+in+" + city # Sending HTTP request request_result = requests.get( url ) # Pulling HTTP data from internet soup = bs4.BeautifulS...
a6928ad2d2ebbb9a9410c187412d6f82f040bb52
Dhruvit/Coding-practice-python
/Flood Fill.py
1,061
3.84375
4
# -*- coding: utf-8 -*- """ Created on Fri Jan 24 12:00:38 2020 @author: dpatel """ #we can solve through recursive neighbour coloring def floodFill(image, sr, sc, newColor): if image[sr][sc] == newColor: return image #do coloring for connected neighbour doFloodFill(imag...
4d4da9def50c22fd9305f90dacd646068a919ce7
claytonjwong/Sandbox-Python
/towers_of_hanoi.py
1,071
4.28125
4
""" Towers of Hanoi Sample input/output: Before: A: [1, 2, 3] B: [] C: [] After: A: [] B: [1, 2, 3] C: [] """ class Solution(object): def move(self, m, src, dst, aux): # base case, no disks to move if m == 0: return # Step A) move m-1 disks f...
faffa282dbd2c9b56b95658d8261bf2fba0dd6ba
daniel-reich/ubiquitous-fiesta
/JFLADuABfkeoz8mqN_22.py
334
3.734375
4
class Person: def __init__(self, name, age): self.name = name self.age = age ​ def compare_age(self, other): comp = ['older than', 'younger than', 'the same age as'] string = comp[0] if self.age < other.age else comp[1] if self.age > other.age else comp[2] return '{} is {} me.'.format(other.nam...
923442d3f05312b3eb2739fea31592cff1e6adb0
KatyaKalache/hanzi
/web_flask/decompose.py
1,462
3.515625
4
#!/usr/bin/python3 # Decomposes character into components from sys import argv from pymongo import MongoClient import re client = MongoClient() db = client.dictionary def decom(): if (len(argv) < 2): print ("Please enter at least one character") else: argument = argv[1] valid = re.fin...
ca625cae88a1522b9ae9a25f026534f14248402f
Radu-Dunarentu/CodeEval
/Easy/#Multiples of a Number.py
687
3.953125
4
#Multiples of a Number #Given numbers x and n, where n is a power of 2, print out the smallest multiple of n which is greater than or equal to x. Do not use division or modulo operator. import sys file = open('test.txt') for line in file: sentence = line.replace("\n","").split(",") first = int(sentence[0]) second =...
029ab0b4a79b91133948f6123f95dafef91ecd3f
HuichuanLI/play-with-data-structure-python
/Chapter21_CountingSort/lc57.py
856
3.6875
4
class CountingSort: # 能处理取值范围[L,R]范围的技术 def __init__(self, L, R, nums): self.L = L self.R = R self.cnt = [0] * (R - L + 1) self.nums = nums self.index = [0] * (R - L + 2) def sort(self): for elem in self.nums: self.cnt[elem - self.L] += 1 ...
1b3db4e430e537cdedca7aa1fcd56aed6e5ddd71
hunterEdward98/Money_Owe_to_Parents
/totalCalculator.py
541
3.5
4
# Python program for reading # from file import re h = open('tabDetails.txt', 'r') # Reading from the file content = h.readlines() # Varaible for storing the sum a = 0 # Iterating through the content # Of the file for line in content: # Checking for the digit in # the string ...
7d696f44dee47ea162387eb976dcf8db08f3edca
chrifl13/is105
/lab/python/exercises/ex4.py
907
3.625
4
cars = 100 space_in_a_car = 4.0 drivers = 30 passengers = 90 cars_not_driven = cars - drivers cars_driven = drivers carpool_capacity = cars_driven * space_in_a_car average_passengers_per_car = passengers / cars_driven print "there are", cars, "cars available." print "there are only", drivers, "drivers available." pri...
e2c124368b63b261a34831f639609adf0a4dca30
bridgenashawn84-gmail-com/friendly
/tests/runtime/test_zero_division_error.py
6,772
3.84375
4
import friendly def test_Division_operator(): zero = 0 try: 2 / 1 / zero except ZeroDivisionError as e: friendly.explain_traceback(redirect="capture") result = friendly.get_output() assert "ZeroDivisionError: float division by zero" in result if friendly.get_lang() == "en": ...
9870efffc20334d312fd716f6a1c85ab19bc1b11
hanqingzdev/Everything101
/Algorithm/LeetCode/523_continuous_subarray_sum.py
3,089
4.03125
4
""" # Problem Statement Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to a multiple of k, that is, sums up to n*k where n is also an integer. ## Constraints: The length of the array won't exceed 10,000. You...
f6adcae584f0a01d016c3c8bf9b257bafffeefc4
240-coding/2020-winter-python
/0106 - 조건문 반복문 활용/0106-1.py
116
3.5625
4
lst = [5, 4, 7, 3, 2, 6, 2] new_lst = [] for i in range(len(lst)) : new_lst.append(lst[i] + 1) print(new_lst)
e6c5d708ebfaf1762f1ca4d3a995e2adc73e9529
TerryLeeMurphy/python-jumpstart-course-demos
/apps/04_journal/you_try/journal.py
1,036
3.515625
4
""" Journal Module Handles all File I/O for the Journary """ import os def load(name): """ load a new journal file :param name : the name of the file to load :return : a data structure populated with file data """ data = [] rows = 0 filename = get_full_pathname(name) print('Loading...
1bc113d273fbc5051e86925dfee10ebcfbe49d6a
hoddi84/FinalProject
/Utilities/rename.py
393
3.703125
4
# Add a prefix to all the files in a folder with the # specified extension, e.g. "txt". # Usage: # python rename.py "fileextension" "new file prefix" # Example: # python rename.py prefab hhp_ import os import sys extension = sys.argv[1] prefix = sys.argv[2] for filename in os.listdir("."): t = filename.split('.'...
2880243674af4c4b1560ece70756acf298f281c5
wuhengliangliang/python
/元类介绍.py
681
4.15625
4
# 什么是元类 是类的模板 # 原类就是类的类,是类的模板 # 元类是如何创建类的,正如类是创建对象的模板一样 # 元类的实例为类,正如类的实例为对象(f1对象是Foo类的一个实例,Foo类是type类的一个实例) # type是python的一个内建元类,用来控制生成类,python 中任何class 定义的类实质都是type类实例化的对象 class Foo: pass f1=Foo()#f1是通过Foo实例化的对象 print(type(f1)) print(type(Foo)) # 类的类就是对象 def __init__(self): pass def test(self): pass FFo=ty...
2cde3b6ff73dd7ed6bcd9bb356c5b8960bc00693
TheUmezude/War-card-game
/Card game.py
6,867
4.03125
4
# In this program, a 'War card game' is created on backend. # To do this, properly, we would be creating three classes. # A card class that handles all the card information (suit-name and rank) # A deck class # A player class # A values dictionary -- as a global dictionary variable # A suits-name tuple (so that i...
892c483c2f9f0c033a306368befdba53bc6a5203
samakshjain/hackerrank
/py/Math/find angle MBC.py
164
3.921875
4
from math import atan, degrees, ceil, sqrt AB = int(raw_input()) BC = int(raw_input()) theta = int(round( degrees( atan(float(AB)/BC)))) print str(theta) + ""
ae9b434231ce6d690d6585e38d392c5967484404
prashantkadam-py/deepdive_part2
/project3_68/goal1.py
2,049
3.515625
4
from collections import namedtuple from functools import partial from datetime import datetime filename = "nyc_parking_tickets_extract.csv" def parse_column_names(): with open(filename, "r") as rows: row = next(rows) column_names = [ column_name.strip().replace(" ", "_").lower() for column_name in row...
7e67c5e81c2ef61b2ccf4558eac80c77e3b87b54
Nilsonsantos-s/Python-Studies
/urionlinejudge-python/1019.py
643
3.90625
4
''' Leia um valor inteiro, que é o tempo de duração em segundos de um determinado evento em uma fábrica, e informe-o expresso no formato horas:minutos:segundos. Entrada O arquivo de entrada contém um valor inteiro N. Saída Imprima o tempo lido no arquivo de entrada (segundos), convertido para horas:minutos:s...
d8a5f4768a865121415b128a394571ae56ba8460
Abdelaziz-pixel/Project-PENDU
/main.py
2,306
4.03125
4
"""call all the functions""" from fonctions import * from nom_fichier import * """these variables will start the program""" mot_a_trouver = choisir_mot() position_tout = [] essais = 0 lettres_trouvees = [] """loop when the game does not exceed 6 tries""" while essais < 6: lettre_joueur = "" lettre_joueur ...
95848ef72319f1529eb42bc26337eb2c4655a5ad
rRupeshRanjan/project-euler
/src/main/python/Q61_70.py
237
3.78125
4
def question62(): cubes = [] i = 1 while True: cube = sorted(list(str(i**3))) cubes.append(cube) if cubes.count(cube) == 5: return cubes.index(cube)**3 i = i+1 print(question62())
9fa9fad3b3b891ede6d553440e01d3f9f781544e
ywsun95/data-structures-and-algorithms-in-python-exercises
/Chapter1/1.22.py
438
4.09375
4
####################################################### # 1.22 # 思路:使用索引进行遍历 ####################################################### def dot_product(a, b): c = [] for i in range(len(a)): c.append(a[i]*b[i]) return c def test(): a = [1, 2, 3, 4, 5] b = [2, 3, 4, 5, 6] print(f"a={a}") ...
d6ab35d51587bfb090b3a1198cc560ab576b0e52
diegozencode/holbertonschool-higher_level_programming
/0x0B-python-input_output/14-pascal_triangle.py
310
4.03125
4
#!/usr/bin/python3 """ Pascal's triangle module """ def pascal_triangle(n): """returns a list of lists of integers representing the Pascal's triangle Args: n (int): numbers of lists Returns: list: list of lists """ my_list = [] if n <= 0: return my_list
2907017434ea80053a0d9917a9ccebd8636c48c9
himanshu2801/leetcode_codes
/53. Maximum Subarray.py
844
3.9375
4
""" Question... Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 Explanation: [4,-1,2,1] has the largest sum = 6. Follow up: If you have figured out the O(n) solution, try coding...
f90c58b0f610415844e1ba2bacdc951d9e447c97
htl1126/leetcode
/2340.py
509
3.59375
4
# Ref: https://leetcode.com/problems/minimum-adjacent-swaps-to-make-a-valid-array/discuss/2292193/Python3-O(n).-Find-min-and-max-value-index class Solution: def minimumSwaps(self, nums: List[int]) -> int: minidx, maxidx = -1, -1 for i, v in enumerate(nums): if minidx < 0 or nums[i] < nu...
82b0e3c95492bc2324ff1e605c57e837843d6ec7
apriantoa917/Python-Latihan-DTS-2019
/nature of string/immutable.py
448
3.890625
4
# 5.1.8.9 The nature of strings in Python alphabet = "abcdefghijklmnopqrstuvwxyz" # del alphabet[0] # alphabet.append("A") # alphabet.insert(0, "A") # alphabet = String yang dapat dioperasikan namun tidak dapat dilakukan penambahan, pengurangan / penghapusan dengan metode list #Namun dapat diakali dengan concaten...
f749a09fa89c2669a44b5791d2c26dfd0a4a12fc
nishanbe/Practicals
/prac_02/password_checker.py
3,249
4.46875
4
""" CP1404/CP5632 - Practical Password checker "skeleton" code to help you get started """ MIN_LENGTH = 2 MAX_LENGTH = 6 SPECIAL_CHARS_REQUIRED = True SPECIAL_CHARACTERS = "!@#$%^&*()_-=+`~,./'[]<>?{}|\\" def main(): """Program to get and check a user's password.""" print("Please enter a valid password") ...
c947a3db72fb13049b56d636ecc52403ed1637f8
mfarukkoc/AlgorithmsDaily
/Problem-03/Python_skahk.py
303
3.71875
4
# Name : Saksham Sharma # College Name : Amrita School of Engineering # Year/Department : IV/CSE # E-Mail Id : saksham6620@gmail.com print('Enter the list(space seperated): ',end=' ') li=list(map(int,input().split())) print('Enter n: ',end=' ') n=int(input()) if n==0 or n>len(li): print('Error') else: print(li...