blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
42189e2e052d8ec6f0c64e11bb9f3ca0a1e3359f
jiwonryu/Practice-Project_Python
/Week9/상속 연습.py
710
3.53125
4
class HousePark: lastname = '박' def __init__ (self, name): self.fullname = self.lastname + name def travel(self,where): print("%s, %s 여행을 가다." %(self.fullname, where)) def love(self, other): print("%s, %s 사랑에 빠졌네." % (self.fullname, other.fullname)) def __add__(self,other): ...
590f6cae1cf0d60786058e0631531cc0ead91fc9
noahhenry/python_for_beginners
/challenges/refactor_converting_emojis.py
414
3.609375
4
# refactor the "converting_emojis.py" into a reusable function emogis = { ":)": "😀", # press ctrl + cmd + space to get emogi picker ":(": "🙁", ":*": "😘" } def convert_special_characters_to_emojis(message): words = message.split(" ") output = "" for word in words: output += emogis.get(word, word) +...
295945e65cd13a053863662eb1bb309c596b9ba8
AllieChen02/LeetcodeExercise
/Stack/P224BasicCalculator/BasicCalculator.py
1,258
3.875
4
import unittest class Solution: def calculate(self, s: str) -> int: stack = [] s = list(s) res, sign, num = 0, 1, 0 for idx, val in enumerate(s): if val.isdigit(): num = 10*num + int(val) elif val == '+': res += num * sign ...
7a02696815a79ee4193116e84e5941825a7bec62
ballcarsen/Networks_1
/board.py
2,171
3.78125
4
# Reads in the board from a text file, returns the array representing the board def read_board(file_name): with open(file_name) as file: next(file) #skips first row of the file since its all numbers anyway board_array = [line.split() for line in file] return board_array # Saves the board...
07592c11c816f5cc76615f839d0b6fc45686b0fe
vhutchinson/Breakthrough
/my_breakthroughgame.py
16,275
3.515625
4
#################################################################################### # CSC 412 - Programming Assignment 1 # # my_breakthroughgame.py holds main and the BreakthroughGame class. # The Breakthrough class includes board and piece information, as well as the steps to run different games of breakthrough. #...
ad882f97f7485ab7e3efc2895f54c581577500a7
guestl/6_password_strength
/password_strength.py
2,061
3.625
4
from string import digits from string import punctuation import getpass def get_uppercase_amount(string_to_process): return sum(1 for single_char in string_to_process if single_char.isupper()) def get_locase_amount(string_to_process): return sum(1 for single_char in string_to_process if single_char.islower(...
1a4be53680163ce466045c361e8666a77aa9305d
daniel-reich/turbo-robot
/662nTYb83Lg3oNN79_22.py
884
3.84375
4
""" Given a list of four points in the plane, determine if they are the vertices of a parallelogram. ### Examples is_parallelogram([(0, 0), (1, 0), (1, 1), (0, 1)]) ➞ True is_parallelogram([(0, 0), (2, 0), (1, 1), (0, 1)]) ➞ False is_parallelogram([(0, 0), (1, 1), (1, 4), (0, 3)]) ➞ True ...
6839553fd6788134bc1c1b40b4ef7e11150db6b9
l1lhu1hu1/web-saliency-map
/webpage_saliency_map/hello.py
79
3.671875
4
a = [1,2,3,4,5,6,7] a.append([10, 11]) print(a) # for val in a: # print(val)
9e692afe26647f3b0ff13f0bf46978460c19f004
mjshipp25/CS50x
/Week6/cashPrac.py
746
3.875
4
from cs50 import get_float def main(): # Prompt user for change while True: change = get_float("Change owed: ") if change > 0: break change = change * 100 # Convert change to int to avoid float imprecision counter = 0 # Counts number of coins # Checks quarter...
4d3227699b460c2328b1e998b2d81ac39d8c48c2
LIN-ai/LeetCode
/HW9.py
266
3.546875
4
#509. Fibonacci Number class Solution(object): def fib(self, N): """ :type N: int :rtype: int """ F = [i for i in range(N+1)] for i in range(2,N+1): F[i] = F[i-1]+F[i-2] return F[-1]
2502d1bfcf26d11f383f0cc8b91e15c0c8a60c83
davenfarnham/CSCIP14100
/examples/1/list_answer.py
540
4.125
4
#!/usr/bin/python # A. match_ends # Given a list of strings, return the count of the number of # strings where the string length is 2 or more and the first # and last chars of the string are the same. # Note: python does not have a ++ operator, but += works. def match_ends(words): size = 0 for word in words: i...
e6685b3a2530ba0161d5c5f1dc5449f8a1563cbe
thomascottendin/GeeksforGeeks
/Medium/findMissingRepeatingNum.py
1,000
3.8125
4
#Given an unsorted array of size N of positive integers. One number 'A' from set {1, 2, …N} is missing and one number 'B' occurs twice in array. Find these two numbers. from collections import Counter def findMissingRepeating(listNum): numCount = Counter(listNum) repList=[] for x in numCo...
e81ee81142b673af2ebcf4eed648be66a9e62e8d
ivansdj68/regex-presentation
/4-4metacharacters.py
602
4
4
import re # Match if there is a vowel on the string vowels_class = r"[aeiou]" # If the 5 is not written two times, no match curly_pattern = r"85{2,2}19" # From beginning to end, check if last name repeats 1 or more times group_pattern = r"^Ivan (Santiago)+$" if re.search(vowels_class, "Ivan Santiago"): ...
a96728d2f9aa77ae735e6a3cec17ecb3d3087a73
leojusti/Justin-Leo-Coding-Projects-Undergrad
/Python A3/flag.py
1,200
4.3125
4
# using the SimpleGraphics library from SimpleGraphics import * import math # use the random library to generate random numbers import random diameter = 15 ## # returns a valid colour based on the input coordinates # # @param x is an x-coordinate # @param y is a y-coordinate # @return a colour based on the input ...
6625cdbb0d3f1e8a5282319346458715adc3a6d0
linhnt31/Python
/Fundamentals/Basic/Day8.py
985
3.765625
4
""" 12 / 3 / 2019 - Material : https://dttvn0010.github.io """ import time # set_ = set() # set_.add(10) # print(set_) # dicts = { # 'one' : 1, # 'two' : 2 # } # print(dicts.get('one')) # for k in dicts: # print(k, ' -----> ', dicts[k]) # for k, v in dicts.items(): # print(k, ' ---> ', v) # prin...
fcd19fb1bfff2f1f03af7acdbaaab153f054c554
aknowxd/python_cursoemvideo_1
/pythonProject/ex035.py
546
4.21875
4
#Desenvolva um programa que leia o comprimento de tres retas e diga ao usuario se elas podem # ou nao formar um triangulo. #formula ( b - c ) < a < b + c # (a - c ) < b < a + c # ( a - b ) < c < a + b a = int(input("Digite o lado a: ")) b = int(input("Digite o lado b: ")) c = int(input("Digite o lado c...
bc5d8bd8ca6e25bffb8b04281afb2146f1d3d856
kangli914/pycharm
/iterators/ex48_time_wait.py
820
4.125
4
#!/usr/bin/env python3 """ex49 return time and item""" import time MINIMUM = 2 ''' Normally, invoking a function multiple times means that the local variables are reset with each invocation. However, a generator function works differently: it’s only invoked once, and thus has a single stack frame. so local variabl...
6765a05d2890f49199ea53953e09f8ddf7e21639
RMarc96/OSU-Classes
/CS160/calculator.py
800
4.21875
4
while 1: operand = input("Enter a number operation (+, -, /, *, **, %): ") if len(operand) == 0: print("Please try again and put something in next time!") break num1 = float(input("Enter your first number: ")) num2 = float(input("Enter your second number: ")) if operand == "+": print(num1 + num2) elif opera...
0a5d6e5ab59f26bcc1123b6d02eb0a384a0348d7
opiddubnyi/Stepik_Python_Basics
/second_module/2.2/days_count.py
1,167
4
4
""" В первой строке дано три числа, соответствующие некоторой дате date -- год, месяц и день. Во второй строке дано одно число days -- число дней. Вычислите и выведите год, месяц и день даты, которая наступит, когда с момента исходной даты date пройдет число дней, равное days. Примечание: Для решения этой задачи испо...
2c0811cdf4cb749799316a29874d24e97ef02c98
agamjot3/Python-Basics
/Guess Game/guess.py
603
4.0625
4
# Take Name of Player name = input("Please Enter Your Name:") answer = 7 # Take Choice choice = input( "Do you want to play a simple game?\nPlease answer in either 'Yes' or 'No'\t") # Check Choice if choice == 'Yes' or choice == 'YES': print("Great! Brace Up For Fun {0}!".format(name)) guess = int(input("...
a191cb51cad104dfbc81544be2865160f9e2a12f
Study-Projects/UltraBot-2k17
/vk_bot/weather_api.py
835
3.53125
4
import urllib.request import json def fetch_weather(weather_key, city): url = 'https://api.apixu.com/v1/current.json?key=%s&q=%s' % (weather_key, city) site = urllib.request.urlopen(url) weather = json.loads(site.read().decode("utf-8")) current_weather = weather["current"] last_updated = current_w...
3ceaa4873e9dccd6c7d20fd14f7997861cde0072
goateater/SoloLearn-Notes
/SL-Python/Functions/Map_and_Filter.py
1,324
4.4375
4
# Map and Filter # The built-in functions map and filter are very useful higher-order functions that operate on lists (or similar objects called iterables). # The function map takes a function and an iterable as arguments, and returns a new iterable with the function applied to each argument. # MAP def add_five(x): ...
6ce0f02d25c46744a8bbc733e361e709d1d21f70
BerilBBJ/scraperwiki-scraper-vault
/Users/N/nethunt/paul_bradshaw_-_tutorial_scrape_resultspage_behind.py
8,210
3.828125
4
#This scraper grabs the results of an empty search on http://www.isi.net/reports/ #An empty search gives us all the data, but the results page doesn't have its own URL #So we need to use mechanize to 'submit' that search #and then BeautifulSoup and scraperwiki to grab the resulting (temporary) results page #first we n...
e98efdedd4a37aa5692baef7693fe18985bb1458
TeamAIoT/CS
/1.OOP/예제코드/ex01_5.py
277
3.828125
4
class university: name="" def show(self): print("대학교 클래스 입니다.") print("대학 이름 : {}".format(self.name)) class sejong_university(university): def __init__(self,name): self.name=name sejong=sejong_university("sejong") sejong.show()
8e52c62b9c7514f8f3063deb25799f47558637d6
pitikdmitry/leetcode
/binary_tree/add_search_word_data_structure.py
2,102
4.0625
4
''' Design a data structure that supports the following two operations: void addWord(word) bool search(word) search(word) can search a literal word or a regular expression string containing only letters a-z or .. A . means it can represent any one letter. Example: addWord("bad") addWord("dad") addWord("mad") search(...
58dc55c0b617c41cd2967ef1a165dc4036a51aea
aprebyl1/DSC510Spring2020
/CORPUZ_510/DSC510Wk6.py
1,084
4.625
5
""" File : DSC510Wk6.py Name: Caleb Corpuz Date: 04/15/2020 Course: DSC510-T303 Introduction to Programming (2203-1) Description: The program will do the following: Ask the user how many temperatures they wish to input Prompt the user to input a temperature Display the max and min temperatures Tell the user ho...
66f4f3b03583970396fea472c46031f3928171c3
gabrielerzinger/python3-bootcamp
/Iterators and Generators/generators.py
801
4.1875
4
''' A generator function that creates a generator ''' import math def next_prime(): prime = 2 while True: prime += 1 count = 0 for i in range(1, int(math.sqrt(prime))+1): if not prime%i: count += 1 if count <= 1: yield prime primes = ne...
b1976bdc511bf7f7874f12e2a44c55afa45f85af
Slepnev-Vladimir/infa_2019_slepnev
/ex6.py
252
4.09375
4
# the program contains a function # that subtracts one list from another list_1 = [1, 2, 3, 4, 5, 6, 153] list_2 = [3, 4, 5, 6, 7, 8, 9] def difference(list_1, list_2): return(list(set(list_1) - set(list_2))) print(difference(list_1, list_2))
f844c776570c427e02462f28652f1e25caafc4e9
shinyaa31/DeepLearningFromZero
/chapter01/chapter1-3_python_interpreter.py
1,089
3.984375
4
# -*- coding: utf-8 -*- import sys ## Anaconda連携確認 print sys.version ## 1.3 Pythonプリンタ ## 1.3.1 算術計算 print (1 - 2) print (4 * 5) print (7 / 5) ## 1.3.2 データ型 print type(10) print type(2.718) print type("hello") ## 1.3.3 整数 x = 10 print(x) x = 100 print(x) y = 3.14 print type(x * y) ## 1.3.4 リスト a = [1,2,3,4,5] prin...
55c47ebb6399e951c3a7bbaad6881af48c9b531a
kzbigboss/scc-csc110
/module 1/KazzazMarkLab01B.py
644
4.1875
4
# Project: Lab:1 # Name: Mark Kazzaz # Date: 2017-07-05 # Description: Lab 1B: Program that uses loops to print numbers ## Print out the numbers 0 through 9 def mainA(): print('Printing numbers 0 through 9...') for i in range(0,10): print(i) print('') ## Print out the numbers...
881b6769b0587ff84638a73d7c43364e8a3f4343
ceberous/osxSettings
/stringToUnicode
110
3.5
4
#!/usr/bin/env python3 import sys print( ''.join( r'\u{:04X}'.format( ord( chr ) ) for chr in sys.argv[1] ) )
a9853cf6df84a09153d1d97f968bc05c177bcf62
BaoJY0915/Py_Grade2
/第9章/ans2.3.py
457
3.59375
4
from turtle import * def inputnum(): x,y = eval(input('请输入:')) return x,y def drawline(): ## hideturtle() x = -100 y = -50 pensize = 50 for i in range(10): x += 50 r,g,b = 0,abs(-x/280),1 pencolor((r,g,b)) penup() goto(x,y) ...
599c8df4d641e252c51a05725151d3993e78930d
ricardotetti/Checkers_DS
/lista5/ex5.py
780
3.8125
4
class Diretores: def __init__(self): self.diretores = [] self.filmes = [] self.quantidade = [] def insere_diretores(self, nome, numero): self.diretores.append(nome) self.diretores.append(numero) self.quantidade.append(numero) def insere_filmes(self, filme, ano, duracao): for i in self.quantidade: wh...
dfaba766547dc742fb09f6c0b1348e1e75b3df45
advinstai/python
/solucoes/e_savio/lib_04/dict.py
1,260
3.65625
4
def iniciar(): print('Iniciando') def count_freq(lista): a =[a**2 for a in lista if a < 3] print(a) #QUESTAO 36 def count_freq2(): f = open('char.txt','r') a = f.readlines() lista = [] countpy, countc, counttxt = 0,0,0 for item in a: item = item.strip('\n') lista.append(item) if 'def' in item: countp...
e0be1b2085e0162ea1c12f103c9fd0527521f257
ardavast/hackerrank
/python/04_sets/p11.py
351
3.640625
4
#!/usr/bin/env python3 # coding: utf-8 """ The Captain's Room https://www.hackerrank.com/challenges/py-the-captains-room """ from collections import Counter if __name__ == '__main__': input() l = [int(x) for x in input().split()] ctr = Counter(l) for k, v in ctr.items(): if v == 1: ...
7b65a1a42a6a62779de505e0598d13c390487919
Neha-kumari31/DS-Unit-3-Sprint-1-Software-Engineering
/sprint_challenge/acme_report.py
2,125
3.828125
4
import random from random import randint, sample, uniform from acme import Product # Useful to use with random.sample to generate names ADJECTIVES = ['Awesome', 'Shiny', 'Impressive', 'Portable', 'Improved'] NOUNS = ['Anvil', 'Catapult', 'Disguise', 'Mousetrap', '???'] def generate_products(num_products=30): '''...
82d2fcbd6e3d14f1b0875595391ef84547dcc687
rosameo/Indovina_chi
/programmaindovinachi/indovina_chi.py
12,222
3.578125
4
# -*- coding: utf-8 -*- """ Spyder Editor This is an intelligent agent who plays "Guess who?". A set of people are presented and the user (the second player, in person) chooses one of the people (unknown person) among the set of people. (The characteristics (carat) of the people are contained in the database.json file...
7fecac63322594191dd33981a86ce1b7c260198e
tima-chan/Bikeshare
/function4_StationsStats_test.py
1,147
3.71875
4
def station_stats(data_table): """Displays statistics on the most popular stations and trip.""" print('\nCalculating The Most Popular Stations and Trip...\n') start_time = time.time() # display most commonly used start station common_start_station = data_table['Start Station'].mode()[0] print(...
2b3211aa10d7a21c414626ff3f79ef99cc538f29
LukeJakielaszek/DecisionTree
/pa2.py
8,104
3.609375
4
''' In PA 2, you might finish the assignment with only built-in types of Python 3. However, one may choose to use higher level libraries such as numpy and scipy. Add your code below the TO-DO statement and include necessary import statements. ''' import sys import csv from sklearn.tree import DecisionTreeClass...
43429fb25ef3f3be0f018f985a53dc1c374db3b4
clarencecastillo/PythonTraining
/extra/q4.py
781
4.0625
4
# Q4 # # Define a class StringReader which has at least two methods: # inputString: to get a string from console input # printStringUpper: to print the string in upper case # # The object should have one property string which holds the # current value of the string. # # The method printStringUpper should first check if...
6fd245a13db68b07e1b2a1dec9d7266bd29cf69f
nelldkLee/python_practice
/01_01.py
325
3.890625
4
# 키보드로 정수 수치를 입력 받아 그것이 3의 배수인지 판단하세요 data = input("수를 입력하세요: ") if(not data.isdigit()): print("정수가 아닙니다.") exit(0) data = int(data) if(data % 3 != 0): print("3의 배수가 아닙니다.") else: print("3의 배수 입니다.")
710acb428b4a7f14f901c828849361058ccdd3ec
szhx/Python
/University projects/a05/a05q4.py
803
3.734375
4
import check # is_folded(old, new) returns if the new strand can be folded from the old # strand by removing either the first or last of the old and adding to the # end of the new # is_folded: Str Str -> Bool # requires: len(old) == len(new) # Example: is_folded('AACTC', 'ACATC') => True def is_folded(old, new): ...
74d458b35d252a1fc2dd4b85670da407c27a591c
maknetaRo/pythonpractice
/list_ex14a.py
1,293
4.28125
4
""" Write a program that asks the user to enter a length in feet. The program should then give the user the option to convert from feet into inches, yards, miles, millimeters, centimeters, meters or kilometers. Say if the user enters a 1, then the program converts to inches, if they enter a 2, then the program converts...
2c5140be61d54c261548d389296f93977674338f
zadraleks/Stepik.Python_3.First_steps
/Lesson 1-6/1-6-5.py
1,155
3.90625
4
#Даны значения двух моментов времени, принадлежащих одним и тем же суткам: часы, минуты и секунды для каждого из #моментов времени. Второй момент времени наступил не раньше первого. Определите, сколько часов, минут и секунд прошло #между двумя моментами времени. #Программа на вход получает две строки данных: часы, мину...
fa012081b8a25f843466ba2aed8c533e347355d6
matthijskrul/PythonExercism
/Solutions/word_search.py
4,921
3.59375
4
class Point(object): def __init__(self, x, y): self.x = None self.y = None def __eq__(self, other): return self.x == other.x and self.y == other.y class WordSearch(object): def __init__(self, puzzle): self.puzzle = puzzle def search(self, word): searches = [ ...
c6e07e3cd168199770153ec808e7e8ed93c50469
theredferny/CodeCademy_Learn_Python_3
/Unit_06-Strings/06_01_10-Strings_and_Conditionals_I.py
214
3.84375
4
def letter_check(word, letter): for i in word: if letter == i: return True return False print(letter_check("bee", "b")) print(letter_check("john", "n")) print(letter_check("john", "y"))
aa2192e9160dac6476aa8d0b3a875f75ba950890
helloworlddata/usgs-earthquakes
/wrangle/scripts/fetch_month_from_archive.py
1,462
3.5625
4
""" Does a single month query of the USGS site for earthquake data Sample query: http://earthquake.usgs.gov/fdsnws/event/1/query.csv\ ?starttime=2016-08-09%2000:00:00\ &endtime=2016-08-16%2000:00:00\ &orderby=time-asc """ from copy import copy from dateutil import rrule from datetime import datetime from pathlib impo...
c0624cec2359cfde031a2bce3485a16c43a8f5e7
vpatov/ProjectEuler
/python/projecteuler/complete/51-100/p080.py
1,023
3.53125
4
""" https://projecteuler.net/problem=80 Square root digital expansion It is well known that if the square root of a natural number is not an integer, then it is irrational. The decimal expansion of such square roots is infinite without any repeating pattern at all. The square root of two is 1.4142135623730950488...
e94b0fb88d317c88948e25697f3b0f3ca6ecdfc7
max19736/python_practice
/chapter3/PythonApplication1/PythonApplication1/practice3-3-6.py
558
3.875
4
#建立一個字串變數內容為'1101 台泥',指派給s1並印出 s1='1101 台泥' print("s1=>",s1) #輸出'1'出現的次數和字串長度 x=len(s1) print("出現1的次數:",s1.count('1')) print("字串長度:",x) #建立出來的變數利用空白字元分割,並用lis1儲存,輸出lis1的長度 s1.split() lis1=[s1] y=len(lis1) print("lis1的長度",y) #加入'1102','亞泥'在lis1後面,模擬二維陣列lis2 s2='1102 亞泥' lis2=[[s1,s2]] print("驗證0-0:",lis2[0][0]) #0之0...
535ae11c9268b7f4c15f8bc2124736e648311b4a
tkremer72/Python-Masterclass
/1.HelloWorld/strings.py
1,023
4.46875
4
print("Today is a good day to learn Python.") print('Python is fun.') print("Python's string are easy to use.") print('We can even include "quotes" in strings.') print("Hello" + " world!" + " This is done with string concatenation, this is where python" + " adds multiple strings" + " together in" + " one line.")...
c66a3aae3ebb29310a7aa3d92f9a712fde5a1c2f
Baidaly/datacamp-samples
/8 - statistical thinking in python - part 1/thinking probabilistically/will the bank fail.py
782
4.53125
5
''' Plot the number of defaults you got from the previous exercise, in your namespace as n_defaults, as a CDF. The ecdf() function you wrote in the first chapter is available. If interest rates are such that the bank will lose money if 10 or more of its loans are defaulted upon, what is the probability that the bank w...
1c918e62bfcdcbc820f58d2c2901b008431802cc
kirillismad/algorithms
/graphs/dfs.py
1,175
3.703125
4
from graphs import Node, init_tree, init_graph, init_cycle_graph def dfs_recursive_tree(root: Node, searched): if root.name == searched: return root for ch in root.children: result = dfs_recursive_tree(ch, searched) if result is not None: return result def dfs_recursive_...
043805ecc6c0add07c034de9e7d7324b69979b3b
OkayJosh/pythonSololearn
/functional programming/quest0.py
256
4.15625
4
### Recursion: The fundamental part of recursion is self reference def factorial(x): '''' the base case act as the exit condition of the recursion '''' if x==1: return 1 else: return x * factorial(x-1) print(factorial(5))
ae92d2624f3d707e5156c3f6d78f2021daf9bae1
aliyevorkhan/MachineLearningPractices
/MachineLearningWithPython/1_simpleLinearRegression/simpleLinearRegression.py
973
3.5625
4
import pandas as pd import matplotlib.pyplot as plt import numpy as np from sklearn.linear_model import LinearRegression from sklearn.metrics import r2_score data = pd.read_csv("hw_25000.csv") boy = data.Height.values.reshape(-1,1) kilo = data.Weight.values.reshape(-1,1) regression = LinearRegression() regression.fit...
9424df512925e0f5cbadf5baa9b5e00ee1e575e7
smartao/estudos_python
/18_programacao_funcional/a171_funcao_primeira_classe.py
923
4.6875
5
#!/usr/bin/python3 ''' Funcao que armazena uma variavel, é uma funcao de primeira ordem ou first class No inicio da aula é explicado os conceitos da funcao zip O Python permite trabalhar com duas funcoes como se fosse dados funcs = [dobro, quadrado] * 5 = Armazenando as duas funcoes dentro lista e * 5 sera remetid...
3b3f289f9a5af9ead1cee6d5904f956bbf99eb81
BenJohnK/pythonprograms
/oop/Bank.py
984
4.09375
4
class Bank: bank_name = "SBI" def __init__(self, accno, pname, minbal): self.accno = accno self.pname = pname self.balance = minbal def deposit(self, amount): self.balance += amount print("Account Credited with: ", amount, "Balance: ", self.balance) def withdra...
4c893044c83c2a8617641cd63c1fad9f69aee887
biroska/ear-migrator
/br/com/experian/util/Cache.py
1,318
3.5625
4
import logging class Cache: """Classe utilitaria para armazenar os valores informados pelo usuario a fim de serem reaproveitados pelo programa""" parameters = {} @staticmethod def addParameter( key, value): """ addParameter adds a value into the parameter cache Returns: True if s...
f9c3d756255594b2cdd4af3f53ae1a0c74a6934c
Gcriste/Python
/dictionarycomprehension.py
94
3.578125
4
str1 = "Abc" str2 = "123" combo = {str1[i]: str2[i] for i in range(0, len(str1))} print(combo)
ac816a5fceccf7b828b7042748af094fa97ee2f8
mariavallarelli/age_analytics
/deps/FeaturesTweetExtractor.py
5,235
3.859375
4
import re from datetime import datetime import emoji def assign_range(age): """ This method assign a numeric value to the target variable.""" if age: if int(age) <= 29.0: return 1 elif int(age) <= 39.0 and age >= 30.0: return 2 elif int(age) <= 49.0 ...
1f3edb018998676eeffde2928ea59e15453d2cbe
gagandeepbhangal/sudoku
/sudoku_gui.py
8,503
3.59375
4
from tkinter import * import puzzles as all_puzzles from random import randint from PIL import Image, ImageTk class SudokuGUI: def __init__(self, master): """ Create Sudoku application page to select from three difficulties (represented by buttons). """ self.frame = Frame(master) ...
55861d11eb9e3d52f6849c0840547c3035cbc622
Nicholas1771/Blackjack
/Hand.py
1,436
3.546875
4
from Card import Card class Hand: def __init__(self, cards): self.cards = cards self.bust = False def __str__(self): string = '' for card in self.cards: if card.visible: string += card.__str__() + ' ' else: string += 'XX...
886a33e1544e18673e3e29f4b2b28346da9f5473
mcfaraz/CSAssignments
/CS917/Assignment1/part1.py
820
3.9375
4
"""This module should filter and sort uk phone numbers from the text file provided. """ import sys import re if __name__ == "__main__": # Your code here inputFile = sys.argv[1] # Input file argument # Open the input file and read all the lines with open(inputFile) as f: lines = f.readlines()...
a7b32c162972ecf85d60333ec5aadc97250b91a2
S-Rosemond/Beginner0
/0Algorithms/Search/Binary_Search.py
155
3.84375
4
import math def binary_search(array, value): left = 0 right = len(array) - 1 middle = math.floor((left + right) / 2) # while(value != )
5c0365c5ee9e366e9331f249669fd02c206b6258
winsbe01/poc_retry_decorator
/main.py
832
3.84375
4
import random from decorators import method_decor class ExampleClass: def __init__(self): self.state = "initialized" def this_is_a_callback(self): self.state = "calling-back" @method_decor() def random_exception(self): print(f"in random_exception: {self.state}") denom = random.randint(0,1) 1 / denom ...
74f472593936792bd01d31cca08adc2c32f4a4a4
aoschwartz7/HarvardCS50
/pset7/houses/roster.py
994
4.1875
4
import sys import cs50 # Write a program that prints a list of students for a given house in alphabetical order. # Check usage if len(sys.argv) != 2: print("Usage: roster.py [house]") exit() # Open db we want to read from open("students.db", "r") db = cs50.SQL("sqlite:///students.db") houseName = sys.argv[...
a99d5950dd828c3d5f459e0e706bb7dde11b272b
kkaixiao/pythonalgo2
/leet_0067_add_binary.py
2,482
3.953125
4
""" Given two binary strings, return their sum (also a binary string). The input strings are both non-empty and contains only characters 1 or 0. Example 1: Input: a = "11", b = "1" Output: "100" Example 2: Input: a = "1010", b = "1011" Output: "10101" """ def add_binary(chars1, chars2): if len(chars1) > len(c...
583f06944c25f53775a8ae057d9a43f337373d07
liviaamaral/sea-level-predictor
/sea_level_predictor.py
1,098
3.765625
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", float_precision='legacy') x = df['Year'] y = df['CSIRO Adjusted Sea Level'] # Create scatter plot plt.scatter(x, y) # Create first line of...
ea2638797b8f339b3a16f09b52a918690b1df4e6
karacanil/Practice-python
/#13.py
243
4.15625
4
#13 inp=int(input('How many fibonnaci numbers you want me to generate:\n')) def fibonnaci(num): counter=0 x=1 y=0 while counter<num: print(x) temp=x x+=y y=temp counter+=1 fibonnaci(inp)
a35c123d408df616d4c5349594996c1f0dd1b6b9
dtliao/Starting-Out-With-Python
/chap.5/03 p.229 ex.2.py
713
3.8125
4
state_rate=0.05 county_rate=0.025 def main(): amount=0 state_tax=0 county_tax=0 amount=int(input('Enter the amount of purchase: ')) state_tax = state_rate * amount county_tax = county_rate * amount sum(amount, state_tax, county_tax) def sum(amount, state_tax, county_tax): total_sale_ta...
c7e4c6c8aba8ab142969be26876e48bf8e67b219
eddowh/Project-Euler
/031_to_040/033_Digit_Cancelling_Fractions.py
4,019
4.03125
4
# -*- coding: utf-8 -*- # Conventions are according to NumPy Docstring. """ The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that 49/98 = 4/8, which is correct, is obtained by cancelling the 9s. We shall consider fractions like, 30/50 = 3...
a5cdd52466d437aa92783f9cb24763821550eac5
arabae/ALGORITHM
/Baekjoon/1436_영화감독숌.py
389
3.640625
4
""" - 종말의 숫자: 6이 적어도 3개이상 연속으로 들어가는 수 (666; 종말을 나타내는 숫자) - 제일 작은 종말의 숫자: 666 (이후 1666, 2666, 3666 ...) - N번째 영화 제목에 들어간 숫자를 출력 """ N = int(input()) serise_number = 666 while N: if '666' in str(serise_number): N -= 1 serise_number += 1 print(serise_number-1)
a988aab71859772f05fb0846c66e9d1fdd46d3ca
qingchn/pythontest
/factorial.py
970
4.03125
4
#!/usr/bin/env python #-*- coding:utf-8 -*- def add_factorial(n): empty_list=[] #声明一个空列表,存各个阶乘的结果,方便这些结果相加 for i in map(lambda x:x+1,range(n)): #用传进来的变量(n)来生成一个列表,用map让列表都+1,eg:range(5) => [1,2,3,4,5] a=reduce(lambda x,y:x*y,map(lambda x:x+1,range(i))) #生成阶乘,用map去掉列表中的0 empt...
7de4aacdee343c49a3001a9b38d9cdf4f4761e63
luizzetlopes/CCP210
/aulasPraticas/programaP2.py
270
3.96875
4
# hip = diametro from math import* a = float(input('Valor do primeiro cateto: ')) b = float(input('Valor do segundo cateto: ')) h = sqrt((a ** 2) + (b ** 2)) r = h / 2 area = pi * (r ** 2) print('O valor do raio é de %.2f' %r) print('O valor da área é de %.2f' %area)
450ff35a82a6d064cb0fba23dcec87ff88bb1c1b
Iverance/leetcode
/650.2-keys-keyboard.py
2,960
3.546875
4
# # [650] 2 Keys Keyboard # # https://leetcode.com/problems/2-keys-keyboard # # Medium (43.21%) # Total Accepted: # Total Submissions: # Testcase Example: '3' # # # Initially on a notepad only one character 'A' is present. You can perform two # operations on this notepad for each step: # # Copy A...
8927c66c1a9a2f747a0be076ff915d02bf590bbe
acc-cosc-1336/cosc-1336-spring-2018-BarndonSelesino
/src/assignments/assignment7.py
792
4
4
''' Create a function sum_list_values that takes a list parameter and returns the sum of all the numeric values in the list. Sample Data joe 10 15 20 30 40 bill 23 16 19 22 sue 8 22 17 14 32 17 24 21 2 9 11 17 grace 12 28 21 45 26 10 john 14 32 25 16 89 ''' #joe_list = [10, 15, 20, 30, 40] #bill_list = [23, 16, 19, 22...
ceeec2431e7fa7a4d68e6158111b5a2ede1fda94
PetitEsprit/BI423-BioInfo
/td3/suite/ex03.py
265
3.546875
4
sq = raw_input("Entrer une sequence:").upper() lensq = len(sq) i = 0 n = 0 while i < lensq and n < 1: if(sq[i] != 'A' and sq[i] != 'T' and sq[i] != 'C' and sq[i] != 'G'): n+=1 i+=1 if n < 1 : print "Chaine correcte" else : print "Il y a au moins une erreur"
422ba7cbddd3a6f6904a53aa16a364ae6692adab
arthurDz/algorithm-studies
/leetcode/corporate_flight_bookings.py
880
3.65625
4
# There are n flights, and they are labeled from 1 to n. # We have a list of flight bookings. The i-th booking bookings[i] = [i, j, k] means that we booked k seats from flights labeled i to j inclusive. # Return an array answer of length n, representing the number of seats booked on each flight in order of their lab...
7b9f9be3147688e3c758a3f0871bed77cc2c2585
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/pybites/intermediate/291_v2/srt.py
1,499
3.546875
4
from datetime import timedelta from typing import List def get_srt_section_ids(text: str) -> List[int]: """Parse a caption (srt) text passed in and return a list of section numbers ordered descending by highest speech speed (= ratio of "time past:characters spoken") e.g. this section:...
5ecba9e4b1bb44f8acf73a4e742560157de881bd
bawejakunal/leetcode
/verify-preorder.py
901
3.765625
4
""" I did not subscribe to leetcode so writing a generic solution https://leetcode.com/problems/verify-preorder-sequence-in-binary-search-tree/ """ """ Assume you are given a pre-order traversal of a binary search tree in the form of an array. You have to verify whether that is a valid pre-order traver...
c222ebefa2b13b52af09b5411ad1b76ad405e90d
iniyan-kannappan/python
/Programs/set5/Name_Relation_Address_StCity.py
785
3.84375
4
def details(): print('What is your name?') name=input() print('Who is your relation?') relation=input() print('What is your address?') address=input() print('What is your St City?') Stcity=input() print('What is ...
07c111eefdab5b74bf6707bcf0b9412f6ac871a5
ra1nty/CS440-AI
/mp2/2.0/board.py
8,624
3.578125
4
import sys import pdb import os import copy class board: # lol no magic numbers NONE = 0; BLUE = 1; GREEN = 2; BOARD_SIZE = 6; MAX_NUM = 0; # board values for each square vals = [[0 for x in range(BOARD_SIZE)] for x in range(BOARD_SIZE)]; # who occupies each square on the board # 0: none # 1...
5d3ba6098b8b5efc3b46d82ec2a165b28ee6c066
divakar239/NLP
/NLP.py
2,624
3.59375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Mar 15 12:11:51 2017 @author: DK """ import numpy as np import matplotlib.pyplot as plt import pandas as pd import seaborn as sn #importing dataset dataset=pd.read_csv('/Users/DK/Documents/Machine_Learning/Python-and-R/Machine_Learning_Projects/NLP/Re...
01dd8821784d76c0d785fd1c2752a07329b1b376
NagahShinawy/The-CompPython-Course-Learn-Python-by-Doing
/1-Intro-to-Python/23-enumerate.py
509
4.28125
4
# https://blog.teclado.com/python-enumerate/ names = ["loen", "daniel", "stephen", "james", "john", "adam"] names = list( enumerate(names, start=1) ) # list of tuples [(1, 'loen'), (2, 'daniel'), ...] print(names) print("#" * 100) # do the same of enumerate without using enumerate items = ["iphone", "macbook",...
6481f94daac9375c8495e262d8b291e346ba3210
drvpereira/hackerrank
/data structures/linked lists/delete a node/solution.py
433
3.828125
4
def Delete(head, position): current_position = 0 prev_node = None curr_node = head while current_position < position: current_position += 1 prev_node = curr_node curr_node = curr_node.next if prev_node and curr_node: prev_node.next = curr_node.next elif ...
8b9b39e3c2cec7b4941a016d483080f7094e58c7
Connor1996/Core-Python-Promgramming-Exercise
/Chapter 6/6-12.py
440
3.671875
4
import string def findchr(string, char): for i, j in enumerate(string): if j == char: return i else: return -1 def rfindchr(string, char): myString = string[::-1] for i, j in enumerate(mystring): if j == char: return len(string) - i - 1 else: return -1 def subchr(string, origchar, newchar): newSt...
d19eac08c1ad725c89af012ae938c083203f580a
volha-mitrakhovich/belhard_5_tasks
/tasks/medium/pow_2.py
381
3.984375
4
""" Проверить, является ли число степенью двойки. Вернуть True или False Является ли число степенью 2 """ def is_pow_2(number) -> bool: return None if __name__ == '__main__': assert is_pow_2(4) assert is_pow_2(16) assert is_pow_2(256) assert not is_pow_2(123) print("Решено")
7b792c003172988c1cd897a5ae6d094249ae8b21
danielfsousa/algorithms-solutions
/leetcode/Graphs/200. Number of Islands.py
2,302
4
4
# https://leetcode.com/problems/number-of-islands/ from collections import deque from typing import List class Solution: def numIslands(self, grid: List[List[str]]) -> int: """ Depth first search r = number of rows c = number of columns Time complexity: O(r * c) ...
cd40e74b617a690a99e190c5a923ed82d8684329
cassiorodrigo/python
/matriz.py
655
3.75
4
linha1 = list() linha2 = list() linha3 = list() matriz = list() num = 0 count = 0 linha = coluna = 0 for c in range(0, 9): num = int(input(f'Diginte um número para a posição {linha, coluna}: ')) if c < 3: linha1.append(num) elif 2 < c < 6: linha2.append(num) elif 5 < c < 10: linh...
7477a978a926cf3493fbec3c90d735ee3dbbe699
Harshwin/Learning
/practiceCoding/projectEuler/HackCountSundays.py
2,388
3.921875
4
months = ['jan', 'feb', 'mar', 'apr', 'may', 'june', 'july', 'aug', 'sept', 'oct', 'nov', 'dec'] numberOfDaysInMonth = [31 ,28 ,31 ,30 ,31 ,30 ,31 ,31 ,30 ,31 ,30 ,31] daysInWeek = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'] beginningDaysOfMonth1900 = ['mon' ,'thur', 'thur' ,'sun' ,'tue' ,'fri' ,'sun' ,'wed'...
3c269a0194736ba3a380a82141a3ba9985501a47
gonnawanna/univertasks
/Python (diff tasks)/pytask02-19.py
112
3.5
4
a1 = float(input('a1 = ')) d = float(input('d = ')) n = float(input('n = ')) s = (n/2)*(2*a1+(n-1)*d) print(s)
a05c38bfa2e653a0cbe52402a624a3978b1fc054
luis-wang/Robotics_408I
/path_planning/a_star_simulation.py
2,969
3.546875
4
import random from a_star import AStar GRID_HEIGHT = 100 GRID_WIDTH = 100 ROBOT_SIZE = (4,4) OBSTACLE_SIZE = (2,2) FINISH_PT_SIZE = (2,2) def printGrid(grid): for y in range(0,len(grid)): for x in range(0,len(grid[y])): if(grid[y][x] == AStar.EMPTY_VAL): print " ", else: print str(grid[y][x]) + "...
05a206c4c6850b64a5b6bb2b02e7b6445a22deb7
larsnohle/57
/16/sixteen.py
327
4.0625
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- def main(): age_string = input("What is your age? ") age = int(age_string) output_string = "You are old enough to legally drive." if age >= 16 else "You are not old enough to legally drive." print(output_string) ### MAIN ### if __name__ == '__main__': ...
1c67adff913c15f0aefeace324028a619aac6ebe
gyoforit/study-algorithm
/baekjoon/boj_6581_html.py
666
3.609375
4
words_list = [] while True: try: words = input().split() words_list += words except: break result = [] sentence = '' for w in words_list: if w == '<br>': result.append(sentence) sentence = '' elif w == '<hr>': if sentence: result.append(sente...
cab9efaa4df45f090d496e1bbf22966ae62c4474
zefciu/vavatech_szkolenie
/slajdy/lekcja1/function_arg.py
134
3.515625
4
def factorial(n): """Zwraca silnię danej liczby""" result = 1 for i in range(n+1): result *= i return result
2d4c44e080b6425b18df7c8483b88fca68a31b24
Kerman-Sanjuan/IBM-Data-Science
/Python for Data Science and AI/Week 3/object_and_classes.py
851
3.96875
4
#En Python, las variables tienen un tipo de dato definido, pero todo esta tratado como un objeto. #Todos los objetos tienen: tipo, datos (atributos) y procedimientos para interactuar con otro objeto. import matplotlib.pyplot as plt class Circle (object): # Constructor def __init__(self, radius=3, color='blue'):...
c21b8515a21b2592cdea1ea9f02266e4fc5582fd
rtanyas/git-geekbrains
/algorithms_lesson2/2.11.py
188
3.609375
4
a = 10 print() for i in range(1, a+1): for j in range(1, a+1): if i==j or i == a-j+1: print('№', end='') else: print(' ', end='') print()
478b184f2073d4354ffd95a8d63f2d2ae73c045d
rui1/leetcode
/rotate_image.py
1,028
3.71875
4
class Solution: # @param matrix, a list of lists of integers # @return a list of lists of integers def rotate(self, matrix): n = len(matrix) if n <=1: return matrix if n>1 and n%2: mid1= n//2-1 mid2 = n//2 else: mid1=mid2= n//2-...
0dd50eba435269c6ae7a0d58dd466f0f7b99ff1c
LiamGG/Python
/Exercises/Human_readable_time.py
425
3.796875
4
# Human readable time # 5 kyu from math import floor def make_readable(seconds): if seconds >= 3600: hours = floor((seconds/3600)) else: hours = 0 seconds -= (int(hours)*3600) if seconds >= 60: minutes = floor((seconds/60)) else: minutes = 0 se...
24e2ac0f6617d5c90227ee8146567e146ce01702
kgmonisha/PythonScripts
/String/string1.py
306
3.921875
4
import string print(string.ascii_letters) print(string.digits) print(string.hexdigits) print(string.punctuation) str1 = "Hi i am monisha" str2 = "12345678" #convert str1 to ascii letters text = "".join([c for c in str1 if c in string.ascii_letters]) print(text) print(all([c.isnumeric() for c in str2]))
a42487a666011721649e11736031913e21cb1162
matthewelse/british-informatics-olympiad
/2021/q1.py
565
3.828125
4
def is_pat(s): """ all letters in left string are later then all the letters in the right string, and left and right are both pats """ if len(s) == 1: return True for split_point in range(1, len(s)): l, r = s[:split_point], s[split_point:] if min(*l) > max(*r): ...