blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
4a1d1439d8706fe0de36872553c1381fa06f7728
Nockternal/Burger
/intro to programming/Task 17/disappear.py
405
4.0625
4
removel_list = [] sentence = input("Please enter a centence. ") removal = input("would you like to remove a character y/n") while removal == "y": char = input("Please enter character you want to remove") removel_list.append(char) removal = input("would you like to remove a character y/n") ...
111fc33b5ac687a300cf031f9a779820ee978ee2
imflash217/Project_Algorithms
/algorithms/InsertionSort.py
776
4.125
4
# Q: Given an unsorted array A[] of size N; sort the array in ascending order and return it # The below implementation takes O(n^2) running time import sys # Input Array: # input_array = [1,23,43,45,2,0,-100,-3,98,12,4,-43] # Taking the unsorted input array from user input_array = [int(x) for x in raw_input('Please ...
74b97e958304b6eb80637704fd53cb4c7f553ca5
Borghese-Gladiator/spam-classification
/features.py
1,884
3.546875
4
import numpy as np import nltk from utils import spam_words_list, apply_preprocess_all class FeatureExtractor(): def __init__(self, debug=True): from nltk.corpus import words nltk.download('words') self.set_words = set(words.words()) self.debug = debug def _compute_misspelled_w...
65064f7fb6969b1b6df1f2dbbd0bad2e077e43d5
rvaishnavigowda/Hackerrank-SI-Basic
/compute n!.py
363
3.8125
4
''' Given a non-negative number - N. Print N! Input Format Input contains a number - N. Constraints 0 <= N <= 10 Output Format Print Factorial of N. Sample Input 0 5 Sample Output 0 120 Explanation 0 Self Explanatory ''' n=int(input()) def fact(n): if n==0 or n==1: return 1 else: m=n*...
47c592baeaef95ca3e1e2406b6e6caa4399bc584
MahdiRafsan/Sorting_Algorithms_Visualizer
/sorting_algorithms/merge_sort.py
1,928
4.5
4
import time def merge_sort(data, left, right, draw, speed): """ algorithm to visualize merge sort :param data: list of integers to sort :param left: starting index of the array of integers :param right: ending index of the array of integers :param draw: funciton to draw the integers on the canv...
ba3e72c41a6117ae4166a5444613020bb4bfc91f
OhOHOh/LeetCodePractice
/python/No27.py
1,221
3.71875
4
# -*- coding: UTF-8 -*- class Solution: def removeElement(self, nums, val): if len(nums) == 0 or nums is None: return nums left, right = 0, len(nums)-1 while left < right: while left<right and nums[right]==val: right -= 1 while left<right ...
a21d5b67f1181605eb34dc9b97bb5b4182cca4ec
KoliosterNikolayIliev/Softuni_education
/Fundamentals2020/MID EXAM Preparation/Contact list Smart.py
1,083
3.65625
4
contacts = input().split(" ") while True: command = input().split(" ") cmd = command[0] if cmd == "Add": name = command[1] index = int(command[2]) if 0 <= index <= len(contacts): if name in contacts: contacts.insert(index, name) else: ...
b3fe7be9416de993645188f8c6d93d9f1b14b354
MaksimKulya/PythonCourse
/L3_task1.py
693
4.0625
4
# Реализовать функцию, принимающую два числа (позиционные аргументы) и выполняющую их деление. # Числа запрашивать у пользователя, предусмотреть обработку ситуации деления на ноль. print(f"Enter a1") a1 = float(input()) print(f"Enter a2") a2 = float(input()) # by try def division_try(a1, a2): try: retu...
095ca91b05b1391df493e2181237a1956657c50b
daniel-reich/ubiquitous-fiesta
/fRZMqCpyxpSgmriQ6_14.py
497
3.84375
4
import string ​ def sorting(s): init = sorted(s) numbers = [] no_digit = [] ​ # store numbers for i in init: if i.isdigit(): numbers.extend(i) ​ # remove numbers from original string for i in init: if not i.isdigit(): no_digit.extend(i) ​ first_sort = sorted(no_digit, key=string.asc...
03d74721ed17719704f310ae60308d885701185a
gjewstic/GA-Python
/homework/hw-3_pig_game.py
2,586
4.15625
4
import random turn = 1 player_one_total = 0 player_two_total = 0 max_score = 50 selection = int(input('Who will be rolling first? Enter a 1 or 2: ')) turn = selection while True: choice = input(f'Player {turn}, do you choose to roll (r) or pass (p)? ') if choice == 'r': score = rand...
084e6ab50d1d7fccea19aa139e006242c46057cc
GrandDuelist/mRythm
/UNDER/spark-code/exploring/systems/subway/TripEntity.py
2,922
3.515625
4
class Trip(): def __init__(self,start=None,end=None,start_time=None,end_time=None,route= None): self.start = start self.end = end self.start_time = start_time self.end_time = end_time self.all_locations = None #used for intermediate points self.all_times = None #used ...
5d8d21a43fc0bb0cf3bffde89c7bc691a16960f6
HussainPythonista/SomeImportantProblems
/Leetcode Problems/median.py
324
3.984375
4
def median(listValue): mid=len(listValue)//2 if len(listValue)%2==1: return listValue[mid] else: left=listValue[mid-1] right=listValue[mid] return float((left+right)/2) list1=[1,2] list2=[3,4] newList=list1+list2 newList=sorted(newList) print(newList) print(median(newLi...
9893633178d92374cb918432e5995f65ae03ea61
Sungchul-P/TIL
/algorithm/testdome/Python Inteview Question/3_Merge_Names.py
749
3.859375
4
# 이름이 저장된 두 리스트(Array)를 합친 결과를 리스트로 반환한다. # 중복된 이름은 제거한다. # 함수 호출 : unique_names(['Ava', 'Emma', 'Olivia'], ['Olivia', 'Sophia', 'Emma']) # 결과 : ['Ava', 'Emma', 'Olivia', 'Sophia'] # 문제 원형 # ''' def unique_names(names1, names2): return None names1 = ["Ava", "Emma", "Olivia"] names2 = ["Olivia", "Sophia", "Emma"]...
85486b89fb548dd13e0c4f64a2df8f84fee4c8b8
ayumoesylv/draft-tic-tac-toe
/l2 class 8 project v.8.py
3,322
3.90625
4
import random def printBoard(board: list): print(' ' + board[1] + ' | ' + board[2] + ' | ' + board[3]) print('-----------') print(' ' + board[4] + ' | ' + board[5] + ' | ' + board[6]) print('-----------') print(' ' + board[7] + ' | ' + board[8] + ' | ' + board[9]) # lose is not necessary, create...
a3de5fc637765d28efe7e914d6c68770ceee3039
Jonathan-aguilar/DAS_Sistemas
/Ago-Dic-2019/Practicas/1er Parcial/Examen/adapter.py
888
3.765625
4
class Smartphone(object): """docstring for Smartphone""" voltaje_maximo = 5 def carga(self, enchufe): """Carga el smartphone con el voltaje de entrada proporcionado.""" self._carga(enchufe.voltaje_de_salida) @classmethod def _carga(cls, voltaje_entrante): if voltaje_entrant...
fdbf21b52d739cd368212c441c689a58c20c66a8
Aasthaengg/IBMdataset
/Python_codes/p02392/s152482423.py
159
3.640625
4
import sys nums = [ int( val ) for val in sys.stdin.readline().split( " " ) ] if nums[0] < nums[1] and nums[1] < nums[2]: print( "Yes" ) else: print( "No" )
69b9740922a731ca4ee37e97d96b4ca47235311c
kleberfsobrinho/python
/Desafio085 - Listas com Pares e Ímpares.py
280
3.609375
4
v = [[], []] valor = 0 for c in range(0, 7): valor = int(input(f'Entre com o {c+1}º valor: ')) if valor % 2 == 0: v[0].append(valor) else: v[1].append(valor) v[0].sort() v[1].sort() print(f'Os pares foram: {v[0]}') print(f'Os ímpares foram: {v[1]}')
02596a8f271ee838f8cac9311a18e4d04cb7afc8
DmytroLukianchuk/Python
/homeTaskTwoNumbers/numbers.py
3,351
3.90625
4
print("HomeWork#2: User enters number in range 20 - 99 from keyboard and get correct spelling of this number in console") dict_numbers = {"1": "one", "2": "two", "3": "three", "4": "four", "5": "five", "6": "six", "7": "seven", "8": "eight", "9": "nine", "ten": "ten", "twenty": "twenty"...
3c6cafcaa57186f11ecd18700a15f8ee4e5945c0
isk02206/python
/informatics/previous informatics/Infomatics-1/6/REDUCTIO.py
4,374
3.78125
4
''' Created on 2015. 12. 3. @author: User ''' 5.3 Reductio ad absurdum def equivalentFraction(numerator1, denominator1, numerator2, denominator2): """ >>> equivalentFraction(19, 95, 1, 5) True >>> equivalentFraction(532, 931, 52, 91) True >>> equivalentFraction(12, 13, 2, 3) False """ # compare numerators after given ...
46900f5b8a8e12f7f5eea9ed98300e93bf6f5252
akankshaagrawal26/SeleniumBasics
/basics/scrolling.py
924
3.5
4
from selenium import webdriver import time class Scrolling: def scroll(self): base_url = "https://learn.letskodeit.com/p/practice" driver = webdriver.Firefox() driver.implicitly_wait(10) driver.maximize_window() driver.get(base_url) driver.execute_script("window....
7a4f71c0bb76abd198a4a073326287252eea7e4c
Fabricio1984/Blue_Python_VS_CODE
/Aula06_Funcao/aula6ex003.py
527
4.125
4
# 3. Faça um programa com uma função chamada somaImposto. # A função possui dois parâmetros formais: taxaImposto, # que é a quantia de imposto sobre vendas expressa em porcentagem e custo, # que é o custo de um item antes do imposto. A função “altera” o valor de custo para incluir o imposto sobre vendas. def so...
2304f4a19b8129b244673fb73f29a10726329a8d
dominikpogodzinski/hangman_game_object
/hangman_object/hangman_text_game.py
1,287
3.78125
4
from chances_error import ChancesError from hangman import Hangman class HangmanGame: def __init__(self): self.hangman = Hangman() print(self.hangman.get_title()) def play(self): while True: print(f'You have: {self.hangman.get_chances()} chances') print(self.ha...
f0ae9415939bbc80e9f0b41525d0962876dd7af8
npwardberkeley/Radix-Converter
/converter.py
1,767
3.59375
4
import math def bin_to_dec(binary): binary = binary[2:] result = 0 for i in range(len(binary)): result += 2 ** (len(binary) - i - 1) * int(binary[i]) return str(result) def dec_to_bin(decimal): result = "" power = int(math.log2(float(decimal))) decimal = int(decimal) while powe...
3f33347032dc4cc3e5d9a4c1154ee9862fa201a0
Juanllamazares/informatica-uam
/CUARTO/FAA/PRACTICAS/P2/Clasificador.py
10,262
3.859375
4
# -*- coding: utf-8 -*- # Practica realizada por Tomas Higuera Viso y Alejandro Naranjo Jimenez from abc import ABCMeta,abstractmethod import numpy as np import collections import math import numpy as np from sklearn.preprocessing import normalize from scipy.spatial import distance from random import uniform class C...
83ae22e0f17d004186ba3d0f7492c7398a34f4e6
aerosat99/JumpToPython-Ex
/연습 04-1.py
1,224
3.84375
4
# 구구단 for i in range(2,10) : # 2~9단 for j in range(1,10) : # 각 단마다 1~9까지 곱한다 print(i * j, end = ' ') # 각 단은 옆으로 보여주고 print(' ') # 단끼리는 줄 바꾼다 #4-1-1 def is_odd(a) : if a % 2 == 0 : return 'Even' else : return 'Odd' print(is_odd(7)) # 함수 안에 print 없으면 함...
80dd6c1bb1781347e2d7a6ae8dfac06e947e182f
loc-trinh/Graphics
/Fractals/Koch.py
2,519
3.5
4
import Tkinter as tk import tkMessageBox from math import cos, sin, pi class Point(): def __init__(self, x, y): self.x = x self.y = y def __sub__(self, other): return Point(self.x-other.x, self.y-other.y) def __add__(self, other): return Point(self.x+other.x, self.y+other.y) def __rmul__(self, n): re...
690cccf7a7c31db574551dc39f05c51bd0428bc7
CodeHemP/CAREER-TRACK-Data-Scientist-with-Python
/15_Intermediate Importing Data in Python-(part-2)/1-importing-data-from-the-internet/03_importing-non-flat-files-from-web.py
1,695
4.0625
4
''' 03 - Importing non-flat files from the web Congrats! You've just loaded a flat file from the web into a DataFrame without first saving it locally using the pandas function pd.read_csv(). This function is super cool because it has close relatives that allow you to load all types of files, not only fl...
aa90bfa4d6c026bc4d282cbb777731b7e41910e8
srivalli-project/BI_Team_Status
/Santhoshi/Python_hackerrank/find-a-string-code-11.py
862
3.671875
4
def count_substring(string, sub_string): cnt=0 ostring = list(string) osub_string=list(sub_string) string2 = [] #print(ostring,osub_string) for i in range((len(ostring)-len(osub_string))+1): j=i string2 = [] #print(j) k=0 while k < len(osub_string):#for j...
2e9afb0bb3adcec8559e32c75180cfbd375f67ee
PacktPublishing/Modular-Programming-with-Python
/chapter-2/inventoryControl/userinterface.py
3,421
3.6875
4
# userinterface.py # # This module implements the user interface for the InventoryControl system. import datastorage ############################################################################# def prompt_for_action(): """ Prompt the user to choose an action to perform. We return one of the following a...
d56e58c7357859197b845ef42fb53c7f6df18a77
Plain-ST/python_practice_55knock
/09.py
224
3.734375
4
""" 9. 文字列(結合) 'py'と'thon'という2つの文字列をそれぞれ変数に代入し,結合したものを出力してください. 期待する出力:python """ str1,str2='py','thon' print(str1+str2)
afb760ea31783e439c29708c09af736f4143fb0a
georgiosdoumas/BeginningPython3_2017editionApress
/chap10/page221personsDB.py
3,543
4
4
#!/usr/local/bin/python3 # page 221 My implementation of database.py with enhancements for handling some exceptions import sys, shelve, os db_store_file = '/home/yourusrename/Documents/PYTHONbooks/Beginning.Python.3rdEd.2017/ch10/persons.dat' def IDexists(pid, pdb): try: info = pdb[pid] return Tru...
5c82c2cd878d84d8b685e60a97a8bda2534f73c6
Ator97/TkinterExamples
/seir.py
426
3.796875
4
from tkinter import * root = Tk() def leftClick(event): print("Left") def rightClick(event): print("Right") def middleClick(event): print("Middle") frame = Frame(root, width=300 ,height=400) frame.bind("<Button-1>", leftClick) #Boton izquierdo del mouse frame.bind("<Button-2>", middleClick) #Boton cent...
a69bad6b7a5c6117f5a52324bf92459c2ceea4a2
gseverina/curso-python
/Persona.py
329
3.8125
4
class Persona: def __init__(self,nombre): self.nombre = nombre def __repr__(self): return str(self.nombre) def upper_name(self): return (self.nombre).upper() if __name__ == "__main__": p = Persona("Pepo") c = Persona("Coti") print p print c p.upper_name = upper_name print p.upper_name(p) #print c.upper...
f99c497929c1d9d587ed9655161973440f6a2720
sungguenja/studying
/sort/쉘정렬.py
338
3.5625
4
def shell_sort(a): h = 4 while h >= 1: for i in range(h,len(a)): j = i while j >= h and a[j] < a[j-h]: a[j],a[j-h] = a[j-h],a[j] j -= h h //= 3 print(a) return a a = [54,88,77,26,93,17,49,10,17,77,11,31,22,44,17,20] print(a) pr...
b86b4086dae4bc2d4422dc7691eb90f3e6be712c
jimmy623/LeetCode
/Solutions/ZigZag Conversion.py
873
3.53125
4
class Solution: # @return a string def convert(self, s, nRows): grid = ["" for i in range(nRows)] i = 0 zigzag = False zigStart = max(nRows-2,0) for c in s: if zigzag: grid[i]+=c i -= 1 if i <= 0: ...
f0825eded9c1fc91a0e6925d01fea8a81ea0ef6f
robertopc/hackerrank
/python3/introduction/print.py
196
3.6875
4
# Print Function # https://www.hackerrank.com/challenges/python-print/problem if __name__ == '__main__': n = int(input()) o = '' for i in range(n): o += str(i+1) print(o)
977bcb84162c1f0a654e57921cafafa06809022d
stefelmanns/Data_Processing
/Homework/Week_6/convertCSV2JSON.py
1,463
3.828125
4
# # convertCSV2JSON.py # # Author: L.K. Stefelmanns # Course: Data processing # Study: Minor Programming, University of Amsterdam # ''' Function that takes CSV data (saved in a txt file) and converts it into JSON data. ''' import csv import json # opens the 4 datasets used csv_input = open('C:/Users/lucst/De...
57b366f1d8e6b333316b4b754658422cc809a385
jnxyp/ICS3U-II
/homeworks/problem_s6/q2.py
451
4.03125
4
# coding=utf-8 # Course Code: ICS3U # Author: jn_xyp # Version: 2017-11-14 # Problem Set 6 - Question 2 import random def pick(): return random.choice( ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King', 'Ace']) + ' of ' + random.choice( ['Hearts', 'Diamonds', 'Clubs', 'Spades'...
c839582d46243eb6776688d453e556a6e582a8cb
JLowe-N/Algorithms
/AlgoExpert/minnumofcoinsforchange.py
905
3.9375
4
# Given a target amount, n, and different denominations of coins available, # find the minimum number of coins (of types in any amount defined in denom array) # to get target amount of money # Complexity Time O(d * n) | Space O(n) # where d is # of denominations, and n is target amount def minNumberOfCoinsForChange(n,...
c091cda930a318acdb326cf014ee2f658b68ffa6
mxmaria/coursera_python_course
/week1/Стоимость покупки.py
331
4
4
# Пирожок в столовой стоит A рублей и B копеек. # Определите, сколько рублей и копеек нужно заплатить за N пирожков. a = int(input()) b = int(input()) quant = int(input()) cost = ((a * 100 + b) * quant) print(cost // 100, cost % 100)
65f7421c01fc8447186044b7650f5792b1eff5a7
AlexxanderShnaider/AcademyPythonLabs
/5.3.nested_loops.py
240
3.671875
4
n = int(input("Введіть число: ")) if (n > 0) and (n <= 9): for i in range(1, n + 1): for j in range(1, i + 1): print(i, end='') print() else: print("Неправильне значення!")
6774a16462aeed440b97c7d785d671f1016f48ae
polusaleksandra/python-hard-way
/ex4.py
1,706
4.25
4
# Assignment the numbers of cars to a variable 'cars'. cars = 100 # Assignment the numbers of free places in car to a variable 'space_in_a_car'. space_in_a_car = 4.0 # Assignment the numbers of drivers to a variable 'drivers'. drivers = 30 # Assignment the number of passangers to a variable 'passangers'. passangers = 9...
c80b388ecf0f2d063d0eb11ae4807e0b2b4c4966
hejazizo/finTranslateBot
/translation.py
1,312
3.609375
4
#- * -coding: utf - 8 - * - import emoji from finglish import f2p ## Function to detect non english characters def isEnglish(s): try: s.encode(encoding = 'utf-8').decode('ascii') except UnicodeDecodeError: return False else: return True ## Main translation function def translate(message): """ Function to ...
6c022ee95a06dbdb88638430d5dcfb175613c7c3
Saranyaram4291/Python
/Activity_4.py
1,165
4.15625
4
user1=input("Enter the player 1 name ") user2=input("Enter the player 2 name ") while True: user1Option=input(user1+" Select either rock or paper or scissors ").lower() user2Option=input(user2+" Select either rock or paper or scissors ").lower() if(user1Option==user2Option): print("Its a tie...
a2fe091e6c95b80438f0b9e94f23091a602c9b87
inlee12/Python
/factorial.py
420
4.125
4
#edit test def factorial_for(number): result=1 for k in range(number,1,-1): result = result * k return result def factorial_recursive(number): if number < 1: return 1 else: return number * factorial_recursive(number-1) i= input("Enter number:") i= int(i) y= factorial_for(i...
3eb7615eb5068a6cfe282a087e3902a469b7c148
megthehoffman/hackbright-coding-challenges
/easier/pangram/pangram.py
922
4.34375
4
"""Given a string, return True if it is a pangram, False otherwise. For example:: >>> is_pangram("The quick brown fox jumps over the lazy dog!") True >>> is_pangram("I love cats, but not mice") False NOTES: letters can appear mroe than once, but every letter from the alphabet must be inc...
ae0557f782b9cb51dc6f34a605a3f2e545ff0e37
demandingfawn/Lecture-Listener
/ll_keyword.py
20,988
3.890625
4
import operator import wikipediaapi #befoer using it, download wikipedia api using "pip install wikipedia-api" in your terminal #here is also the link to the api instruction page: "https://pypi.org/project/Wikipedia-API/" #you also need to check location and name of the transcript file before using it. (for this ...
497b0a2f4848431c49db7c92115da3a48ffb24fc
daniromero97/Python
/e022-StringMethods/StringMethods.py
2,250
4.40625
4
print("##################### 1 #####################") sentence = "this IS a TEST sentence." print(sentence) print(sentence.capitalize()) """ output: this IS a TEST sentence. This is a test sentence. """ print("##################### 2 #####################") print(sentence) print(sentence.upper()) """ outpu...
abd5f5eececb87bdd17813acca7ed44134dc80e4
christy951/programming-lab
/large of 3 number.py
285
4.125
4
print("enter 3 number/n") num1=int(input("first number:")) num2=int(input("second number:")) num3=int(input("third number:")) if num1>num3 and num1>num2: print(num1,"is large") elif num2>num3: print(num2,"is large") else: print(num3,"is large")
ac713b5c794ab4203d9e00a61dcce08ad0ca6468
akb46mayu/Data-Structures-and-Algorithms
/Dynamic Programming/le64_minimum_pathsum.py
1,434
3.828125
4
""" Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move either down or right at any point in time. """ class Solution(object): def minPathSum(self, grid): """ :type grid: List[...
a95722323fd032517854756f8cf2965aa43ebc8a
daniel-ntr/Python
/CursoEmVideo/desafio016.py
202
3.84375
4
dias = int(input('Quantos dias o carro permaneceu alugado? ')) km = float(input('Quantos quilômetros o carro percorreu? ')) aluguel = (dias * 60) + (km * 0.15) print(f'Custo do aluguel: R${aluguel}')
b3b4889d6a315fb7bb58748b3f500965bbaeb70a
jenni22jennifer1999/jennipython
/test2.py
423
4.28125
4
#!/usr/bin/python3 name="jennifer" #initializing string func print (name) #prints the value of name print (name*3) #prints the value of name 3 times print ("My name is " + name) #prints the sentence name1="Jennifer" name2=" J" print (name1+name2) #prints Jennifer J print (name[0]) #prints J (1st position) p...
7b77e94595eff74e0099632223ff56e7e4a72866
EricShiqiangLiang/Udacity-CS101
/ACE Exam/Type.py
236
3.671875
4
""" Provide a definition of g such that the expression below evaluates to True: """ def g(p): if type(p) == int: return g if type(p) == str: return 1 print type(g) == type(g(1)) != type(g('alpha'))
b907b7c4544b5075ed4a0b0d09420e9e198acc02
henriquesuenaga88/adventofcode
/day2/day2.py
1,806
3.65625
4
dict = { 'U': -1 , 'D': 1 , 'L': -1 , 'R': 1 } x_position = 1; y_position = 1; def getKeypadFromPosition(x, y) : keypad = [ ['1', '2', '3'] , ['4', '5', '6'] , ['7', '8', '9'] ]; return keypad[y][x]; def isAcceptableVerticalValue(direction) : return direct...
fe6338c56059d0fb363a88d0d093b6e22892112d
RussAbbott/TicTacToe
/TTT/archive/TTT - Copy/players.py
13,663
4.03125
4
from random import choice class Player: """ The board is numbered as follows. 0 1 2 3 4 5 6 7 8 """ def __init__(self, gameManager, myMark): self.emptyCell = gameManager.emptyCell self.possibleMoves = list(range(9)) # 9 possible moves self.possibleWi...
b10a4270c5c9170d71513b7dede490be5971deb2
ArtemiiFrolov/Courses
/Main course_Python/lesson24470_1.py
178
3.703125
4
import re pattern = r"cat" line = input() out_line = "" while line: if len(re.findall(pattern, line)) > 1: out_line += line+"\n" line = input() print(out_line)
40910079637dda9f7753b4457f67a376504c8124
AlixLieblich/CodingPracticeProblems
/Problems/high_and_low.py
2,476
4.15625
4
# In this little assignment you are given a string of space separated numbers, and have to return the highest and lowest number. # Example: # high_and_low("1 2 3 4 5") # return "5 1" # high_and_low("1 2 -3 4 5") # return "5 -3" # high_and_low("1 9 3 4 -5") # return "9 -5" def high_and_low(numbers): for num in num...
f08e1e13a6b97028b5eb62f7d015e2b967045739
mohrtw/algorithms
/algorithms/dataStructures/stack.py
1,231
4.25
4
class Stack(object): """Represents a last-in, first-out data structure Public attributes: - items: A list of items in the stack. Functions: - push: Pushes an item to the end of the stack. - pop: Removes and returns the last item in the stack. - peek: Returns the last item in the stack. ...
0184826ef303f513cbe9fa84841cbc397871ef21
google-code/7567-fallas1
/tp3MotorDeInferencia/python/ecuacion.py
6,293
3.640625
4
#!/usr/bin/env python #-*- coding:utf-8 -*- """ Este modulo define la clase Ecuacion, que permite interpretar una ecuacion de una cadena de caracteres y separala en sus componentes, para ser almacenados en notacion polaca inversa. """ import re class Ecuacion(object): """ Represent...
b14402bd3dc6b70752338fabf66b536b0bc4b233
Lekuro/python_core
/CodeWars6/1_distance.py
254
4.03125
4
# Simple: Find The Distance Between Two Points def distance(x1, y1, x2, y2): """ function count the distance between two pont (x1, y1) and (x2, y2) """ return round(((x1 - x2)**2 + (y1 - y2)**2)**(1/2), 2) print(distance(-1, -2, 1, 2))
80dc847d3282114e5865b20c02b6c0a85796807d
jsnreddy/coding_practice
/python/find_missing_number.py
341
4.21875
4
# find the missing number from the sorted list of integers where one integer is missing between 1 to n n = 10 numbers = [1, 2, 3, 4, 5, 6, 7, 8, 10] def find_missing_number(n, numbers): sum_of_numbers = (n * (n + 1)) / 2 for num in numbers: sum_of_numbers -= num return int(sum_of_numbers) print(find_missing...
482f2a337af097b1654ed214c68d9479841d41f6
kimhjong/class2-team3
/fibonach.py
837
3.65625
4
import time #재귀함수를 통한 피보나치수열 def fibo(n): if n <= 1: return n return fibo(n - 1) + fibo(n - 2) #반복문을 통한 피보나치수열 def iterfibo(n): past = 0 current = 1 storage = 1 if (n == 0): return 0 elif (n == 1): return 1 else: for i in range(2, n+1): stor...
9e306bbc15b1ebe9b2a81491e7faf015e3ec1237
Will66/testsigou
/py/filetolist.py
635
3.734375
4
#!/usr/bin/env python def readFile2List(fileName, listName): listName = [] with open(fileName,"r") as f: sentences = [elem for elem in f.read().split('\n') if elem] for word in sentences: listName.append(word.split()) return listName def readFile2Dict(fileName, dictName): fileHandle = open(fil...
367203ef71161797d1df204c9b4c8528769e987d
KRLoyd/holbertonschool-higher_level_programming
/original_repo/0x05-python-exceptions/2-safe_print_list_integers.py
617
4.4375
4
#!/usr/bin/python3 def safe_print_list_integers(my_list=[], x=0): """ Prints the first x elements of a list, only integers Args: my_list -- list to print x -- number of elements to print Return: number of integers printed """ # Start print counter at 0 print_count = 0 # For values ...
9f4aad2311586efc3d0261e4596306c078722db7
amgregoi/School
/K-State/CIS505/Finished-Assingments/Ex3/Ex3-Submit/interpret.py
7,407
3.75
4
### INTERPRETER FOR OBJECT-ORIENTED LANGUAGE """The interpreter processes parse trees of this format: PTREE ::= DLIST CLIST DLIST ::= [] CLIST ::= [ CTREE* ] where CTREE* means zero or more CTREEs CTREE ::= ["=", LTREE, ETREE] | ["if", ETREE, CLIST, CLIST] | ["print", ETREE] ETREE :...
0148e757a71b95bf7bd6e5727ba9fd7f9aec0878
Krondini/CSCI-3104
/Lectures/InsertionSort.py
400
3.546875
4
import sys import csv def insertionSort(arr): key = arr[0] def main(argv): try: if(argv[1]): with open(argv[1]) as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') for row in csv_reader: for element in row: element = int(element) insertionSort(argv[1]) close(csv_file)...
693e1f6b51ded507f3833ed5690ec6b2993ffe71
aaveter/curs_2016_b
/3/6.py
329
3.5625
4
users = [ 'user1', 'user2', 'user3', ] users.append('user3') print( users ) users_set = set( users ) users = list( users_set ) users.sort(reverse=False) print( users ) s = {1, 2, 3} s2 = {3, 4, 5} print( s2.difference(s) ) print( s2.intersection(s) ) print( s2.issubset({3, 4, 5, 6}) ) print( s2.u...
82ef6b1ef179fdc6811884f6af91b6ebfd3b9133
davidbegin/python-in-the-morning
/Fluent_Python/Day43/flag_challenge.py
584
4.0625
4
import string print("\033c") # Challenge: Make a datastructure with every two letter combination # Points for: # - Cleverness # - Shortness # - Speed # - Readability all_the_letters = string.ascii_uppercase a1 = list(all_the_letters) # create a list the length of a1, consisting only of a single characte...
9dd43b6c13ce8ce62b143e6c156e192df1574436
daniel-reich/turbo-robot
/hQRuQguN4bKyM2gik_21.py
1,269
4
4
""" **Mubashir** needs your help in a simple task. Create a function which takes two positive integers `a` and `b`. These numbers are simultaneously **decreased by 1** until the **smaller one reaches 0**. During this process, the greater number can be divisible by the smaller one. Your task is to **count how many ...
ff0ae072ea009df81781fd8da0ac623ebaea66e6
cboe07/CS-Fundamentals
/Unit 4/my_hash_function.py
619
4.09375
4
def my_hash_function(value): first_letter = value[0] alphabet = "abcdefghijklmnopqrstuvwxyz" return alphabet.index(first_letter) print(my_hash_function("abe")) print (my_hash_function("carrot")) def my_hash_function(phone_number): return phone_number[0] + phone_number[1] + phone_number[2] print(...
22adfa8fb297a30f531da93c074e37f57ca611a3
bmdyy/projecteuler
/027.py
682
3.578125
4
def is_prime(n): if n <= 3: return n > 1; elif n % 2 == 0 or n % 3 == 0: return False; i = 5; while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False; i = i + 6; return True; def num_con_primes(a, b): n = 0; while is_prime(n*n+a*n+b): n += 1; return n; best_coeff...
6c48b3fd8c73a99e2248bdf0e5d906212e92a1ae
hswang108/Algorithm_HW
/WEEK4/LeetCode/232Stacks_arraytype.py
1,252
4.25
4
class MyQueue: def __init__(self): """ Initialize your data structure here. """ self.a = [] def push(self, x: int) -> None: """ Push element x to the back of queue. """ self.a.append(x) for i in range(len(self.a)-1,0,-1): ...
5f71130945334b63455fd476a5d70d7f10901938
gurkslask/tiddur
/app/time_cmd/week.py
1,660
4.03125
4
from .scheme import Scheme class Week: """ week() week Schemes within days """ def __init__(self): self.week = {"monday": [Scheme("Work2", 10, 00, 11, 00)], "tuesday": [], "wednesday": [], "thursday": [], "...
2c57f44a10d44060954b4cee82819fa1a22e4561
icyfig/NFA_to_DFA
/nfa_to_dfa.py
9,843
4.15625
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 21 17:37:07 2021 @author: icyfig """ ''' Python Program for converting an NFA to an equivalent DFA INPUT FILE FORMAT: The Input shall consist of 5 Lines. Line 1- Comma-Separated Input States Surrounded by braces Line 2- Comma-Separated Alphabets Surrou...
ebc36c6781006bc6a5d5b19bc5f29ababf692296
katerina-g/python-fundamentals-09-2020
/Basic Syntax, Conditional Statements and Loops - Exercise/Easter Cozonacs.py
565
3.8125
4
budget = float(input()) flour_price = float(input()) eggs_price = flour_price * 0.75 milk_liter_price = flour_price * 1.25 milk_needed_price = milk_liter_price / 4 cozonac_price = eggs_price + flour_price + milk_needed_price colored_eggs = 0 count_cozonacs = 0 while budget >= cozonac_price: count_coz...
51d5d7eae6c9a2ab459aa5b28c166016697c9861
dani3390/Fondamenti-di-Programmazione
/lezione2_esercizio2.py
1,204
3.78125
4
# -*- coding: utf-8 -*- """ Created on Tue Oct 15 23:56:48 2019 @author: Danilo Testo: Scrivere una funzione che dati in ingresso il costo del biglietto per visitare un museo e il numero di studenti di una classe in gita scolastica, ritorna la spesa totale, considerando che se gli...
d93fa2646ca684ef22c8a1b6aed235f2f0e284d7
huwenlong99/pss
/response_web_niji/the_pouden_mack/Get_search_results.py
1,392
3.625
4
# 获取搜索结果Get search results # -*- coding: utf-8 -*- from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.wait import WebDriverWait import time # 声明谷歌、...
9a2524ef812590e81a13ebd44d73699740c576f9
irina08/Python
/cpython.py
1,318
3.796875
4
#!/usr/local/bin/python3 # NAME: student Irina Golovko # FILE: cpython.py # DATE: 04/06/2019 # DESC: Write a universal wrapper program that expects # its command line arguments to contain the absolute path # to any program, followed by its arguments. The wrapper # should run that program and report its exit value ...
08b53cc939b1a4da691b1026d4e20d1613f66aeb
rajeevj0909/FunFiles
/Circle OOP.py
485
3.984375
4
class Circle: def __init__(Circle,r): Circle.radius=r def getDiameter(Circle,r): diam=r*2 return ("Diameter: ",diam) def circum(Circle,r): circum=2*r*3.14159265359 return("Circumference: ",circum) def area (Circle,r): area=r*r*3.1415926...
cf8da00e544d5b5304a87e4809b007ac7a57b2b6
pvo4/week4-tic-tac-toe
/ticTacToe.py
3,878
4.1875
4
def printBoard(board): # TO DO ################################################################# # Write code in this function that prints the game board. # # The code in this function should only print, the user should NOT # # interact with this function in any way. ...
a80bb62e382c506d9651ed4e5d96b043df2f561c
mattling9/COMP1_2014
/Skeleton Program.py
10,255
3.5625
4
# Skeleton Program code for the AQA COMP1 Summer 2014 examination # this code should be used in conjunction with the Preliminary Material # written by the AQA Programmer Team # developed in the Python 3.2 programming environment # version 2 edited 06/03/2014 import random, datetime SameCardLower = True ACE_H...
a6484398bdaf6778d5b056fc56bdba670221ddae
IAmAbszol/DailyProgrammingChallenges
/Problem_29/solution.py
895
3.75
4
import unittest def solve(case): ''' AABBCCD A, 1 A = iter.next() A, 2 A != iter.next() Result append (2A) B, 1 .... ''' if case is None or not case or not all([c.isalpha() for c in case]): return None iterator = iter(list(case)) character, count = 0, 0 resultant = "" while True: try: tmp...
ad34945e094673f7e4aba6f0df80aaffc650f34f
Puzyrinwrk/Stepik
/Поколение Python/Только_плюс.py
1,172
4.53125
5
""" Напишите программу, которая считывает три числа и подсчитывает сумму только положительных чисел. Формат входных данных На вход программе подаются три целых числа. Формат выходных данных Программа должна вывести одно число – сумму положительных чисел. Примечание. Если положительных чисел нет, то следует вывести 0...
8eb00c4e0f3132690a0c692e6d75260bc3d86cd3
hetvi14/ICT-Project
/mail.py
1,709
3.578125
4
import smtplib #simple mail transfer protocol used for email server i.e to create client session obj from io import StringIO from io import BytesIO from email.mime.base import MIMEBase #This is the base class for all the MIME-specific subclasses of Message from email.mime.text import MIMEText #The MIMEText class is...
d862d9dbc133adacab4ad2878df37a1bfcf95cf5
paddyjclancy/eng_57_class_notes
/Python/exercises/107_fizz_buzz.py
970
4.1875
4
# Write a fizz-buzz game ##project # as a user I should be able prompted for a number, the program will print all the numbers up to and including said number while following the constraints / specs. (fizz and buzz for multiples or 3 and 5) # As a user I should be able to keep giving the program different numbers and ...
8e28360d226b62d01152ba495482c289c8297388
khalil-hassayoun/holbertonschool-higher_level_programming
/0x03-python-data_structures/7-add_tuple.py
288
3.75
4
#!/usr/bin/python3 def add_tuple(tuple_a=(), tuple_b=()): a = [0, 0] b = [0, 0] for i in range(min(len(tuple_a), 2)): a[i] += tuple_a[i] for i in range(min(len(tuple_b), 2)): b[i] += tuple_b[i] new_tup = (a[0] + b[0], a[1] + b[1]) return (new_tup)
f65a642d95a1a1a9d0f2483d850801bb11fdd1b9
Natsu1270/Codes
/Hackerrank/LinkedList/GetNodeFromEnd.py
453
3.65625
4
from LinkedList import * def getNode(head,pos): index, run ,res = 0, head, head while run.next: run = run.next index +=1 if index > pos: res = res.next return res.data def getNode2(head,pos): run,res = head,head while pos>0: run = run.next while ...
80eb6b187720ca594bade970e9d6669c375acff5
GruberQZ/AoC-2017
/Day19/day19.py
1,748
3.546875
4
import os import os.path def go(): # Build grid grid = [] input = open(os.path.join(os.getcwd(), 'Day19', 'input.txt')) for line in input: grid.append(list(line.replace('\n', ''))) grid.append([' '] * len(grid[0])) letters = set(list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')) path = [] #...
f309bc43579b79a27986def0681e785071bbf37c
smanisha92/HackRank
/hackerrankpracticeprojects/miniongame.py
840
3.765625
4
"""Kevin and Stuart want to play the 'The Minion Game'. Game Rules Both players are given the same string, S. Both players have to make substrings using the letters of the string S. Stuart has to make words starting with consonants. Kevin has to make words starting with vowels. The game ends when both players have ma...
2a41a811f7c4ec5d223de6ae52ea5395611e294a
yanzixiong/Python-
/10day/03-new.py
260
3.859375
4
class Person(object): def __new__(cls,name,age): print('__new__') instance = object.__new__(cls) return instance def __init__(self,name,age): print('__init__') self.name = name self.age = age p = Person('laowang',33) print(p.name) print(p.age)
19c7cef0a17b3d8a4922d14b355c51ee832a9844
jordanwu97/FooBar
/Level_1_2/bunny_prisoner_locating.py
264
3.515625
4
def answers(x,y): m = 1 for j in range(1, y): m = m + j print m num = y - 1 n = 0 for i in range(y+1,y+x): n = n + i print n + m # for i in range(1,x+1): # n = n + i # print n # answers(input(),input())
8c6e99402c5fc18608b4276e686f2c61c48f2df9
asgarzee/interview-preparation
/bfs_and_dfs.py
831
3.84375
4
from collections import deque from collections import OrderedDict def bfs(graph, start_node): queue = deque([start_node]) visited = OrderedDict({start_node: True}) while queue: v = queue.popleft() for i in graph[v]: if i not in visited: queue.append(i) ...
ef4ffe9497cc469170fbeacaf6cba50550f57b95
leoashcraft/Python-OOP-Blackjack
/blackjack.py
3,838
3.65625
4
import random class BlackJack: def __init__(self): self.cards = [] self.clubs = [] self.diamonds = [] self.hearts = [] self.spades = [] self.suits = (self.clubs, self.diamonds, self.hearts, self.spades) self.suitNames = ("clubs", "diamonds", "hearts", "spades...
e5dd52e81123daf39c092740db3d5fad08e51bfa
jaijaish98/ProblemSolving
/invert_binary_tree.py
1,147
4.125
4
""" Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 4 / \ 7 2 / \ / \ 9 6 3 1 """ #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 clas...
661faef519cd939da80e73c4472b67a11074fc75
bunnydev26/learn_py_asyncio
/tutorial_edge/future_example.py
699
3.640625
4
import asyncio # Define a coroutine that takes async def myCoroutine(future): # simulate some 'work' await asyncio.sleep(1) # set the result of our future project future.set_result("My Coroutine-turned-future has completed") async def main(): # define a future object future = asyncio.Future(...
e96ee3612a15cea97c7afe71b7c3f74a13761bcf
samarthupadhyaya/python-programming
/rock_paper_scissor.py
182
3.578125
4
a=input() b=input() x=input() y=input() if((len(x)==4 and len(y)==7) or (len(x)==7 and len(y)==5) or(len(x)==5 and len(y)==4)): print(f"{a} Win") else: print(f"{b} Win")
fa4833023f64ec475be441b23d5b2e1ffcd49294
ksaubhri12/ds_algo
/interviews/dsa/gameskraft/print_valid_ip.py
2,119
3.53125
4
def print_valid_ip(string_value: str): result_arr = [] def print_util_min(string_value: str): return '.'.join(i for i in string_value) def print_ip(string_value: str, len_needed, output_string: str): if len_needed <= 0: return output_string if len_needed == 1: return string_value ...
b5e5368076b16def0635cfce2c673d80101760be
ivan-verges/BreastCancerClassifier
/script.py
1,202
3.609375
4
import codecademylib3_seaborn from sklearn.datasets import load_breast_cancer from sklearn.model_selection import train_test_split from sklearn.neighbors import KNeighborsClassifier import matplotlib.pyplot as plt #Load Breast Cancer data from imported dataset breast_cancer_data = load_breast_cancer() #Split data int...
9d40c94848ef76665c653b670715f0e08fff2248
90sidort/exercises_Python
/directions_Reduction.py
536
3.5625
4
# Description: https://www.codewars.com/kata/550f22f4d758534c1100025a # My solution: def dirReduc(arr): while True: if arr == []: return [] for x in range(0, len(arr)): if x + 1 == len(arr): return arr elif (arr[x] == 'NORTH' and arr[x+1] == 'SOUTH...
d074207560ea3b30430489e57386bee321b3a743
hasibzunair/randomfun
/algo/greedy.py
1,245
3.9375
4
''' Given a set of intervals L, find the min set of points so that each inteval is covered at least once by a given point. eg input: (1, 3), (2, 5), (3, 6) output: 3 Algo: - sort intervals in increasing order - for interval in interval-set add interval endpoint to set of points ''' def min_points(i...