blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
58f1f4e76f9a92ed63eeb172800550bb21bdda79
Antrikshhii17/myPythonProjects
/DataStructure_Algorithm/Longest_valid_parentheses.py
491
3.8125
4
""" Program to find the length of longest valid parentheses using stack data structure """ def isValid(string): stack = [-1] res = 0 for idx, i in enumerate(string): if i == '(': stack.append(idx) else: stack.pop() if not stack: stack.app...
56136cb26202a12360bc1dcb27380548167920da
Antrikshhii17/myPythonProjects
/DataStructure_Algorithm/my_sorting_algo.py
504
3.984375
4
""" Program for sorting algorithm based on the subtraction of numbers """ def diffsort(numbers): numbers[numbers.index(min(numbers))], numbers[0] = numbers[0], min(numbers) for i in range(len(numbers)-2): #for j in range(i+1, len(numbers)-1): if numbers[i] - numbers[i+1] > numbers[i] - numbers...
1838b979bbf1c1b6ee4f1e872367325f2e3ea6da
Antrikshhii17/myPythonProjects
/DataStructure_Algorithm/Bubble_sort.py
516
4.3125
4
""" Bubble sort. Time complexity- Worst case = O(n^2) , when the array is in descending order. Average case = O(n^2) , when the array is jumbled. Best case = O(n) , when the array is already sorted. """ def bubblesort(list): for i in range(len(list)): for j in range(len(list) - i - 1): ...
1a0c4a6b2fb3c3ea3c66fe73e02fa6d0f513b265
vkhalaim/pythonLearning
/tceh/lection3/task3.py
136
3.578125
4
def magic(x, y): if x > 0 and y > 0: return x + y elif x < 0 and y < 0: return x - y else: return 0
3d21ee648748e49a1c83351647fde6e5f83cb1fc
vkhalaim/pythonLearning
/tceh/lection3/homework_simple/exceptions.py
350
3.953125
4
# num = int(input()) # # if num > 10: # raise IndexError('It\'s too big') # elif num < 0: # raise TypeError('Less than zero!') # elif num % 2 == 0: # raise ValueError('Is even!') # list_ = [1, 2, 3, 4, 5, 6, 7, 8] inp = int(input('Which index do you want?')) try: print(list_[inp]) except IndexError: ...
aba880ab4100a7c30c4b9fe8dbc5fd52da08a225
vkhalaim/pythonLearning
/tceh/lection2/list_task_2.py
359
4.15625
4
objectList = ["Pokemon", "Digimon", "Dragon", "Cat", "Dog"] # first method for i in objectList: print("Element of list -> " + i + "[" + str(objectList.index(i)) + "]" + "(in square braces index of element)") # enumarate print("-------------------") for index, element in enumerate(objectList): print(...
305c6d89679c47ec59f84fe4c053cd1f657464c0
popsauce/ACM-ICPC-finals
/2018/problem-f/firstdraft.py
2,772
3.5625
4
# Constraints # 1) line width >= longest word # 2) no trailing whitespaces # 3) words cant be split #input format """ numofwords=int(raw_input()) txtinput=str(raw_input()) wordlist=list(map(str,txtinput.split())) """ #arrange to line width """ linewidth=21 line="" linelist=[] numoflines=0 i=0 while i!=numofwords: ...
94a22ec4cf15613bf3ccce939d29bf6ba89f4a51
J-Gottschalk-NZ/Random_String_generator
/main.py
721
4.21875
4
import string import random # Function to check string length is an integer that is > 0 def intcheck(question): error = "Please enter an integer that is more than 0 \n" valid = False while not valid: try: response = int(input(question)) if response < 1: print(error) else...
bbd1ad87e39f3c94b4c501128b5ba3e12892677c
GurgelDavi/Phyton-examples
/09 py funcFileAppend.py
173
3.703125
4
def appendFile(): f = open("tmp/myfile.txt", "a") texto=[] texto.append('teste') f.writelines(texto) f.close print ('hi!reading file') appendFile()
07c883f8fc0c761e210688b095c5c0e0d5cd82c8
MMGroesbeck/cs-module-project-recursive-sorting
/src/sorting/sorting.py
2,097
4.1875
4
# TO-DO: complete the helper function below to merge 2 sorted arrays def merge(arrA, arrB): elements = len(arrA) + len(arrB) merged_arr = [0] * elements # Your code here i = 0 a = 0 b = 0 while i < elements: if a >= len(arrA): merged_arr[i] = arrB[b] b += 1 ...
76c9ff5dd13ac7ac1e5293399037474866fae7b7
mazoko/python
/03_プログラミング入門/test3-5.py
114
3.5
4
number1 = 20 number2 = 3 remainder = number1 % number2 quotient = (number1 - remainder) / number2 print(quotient)
a9b68d9000c26e0fccc40517894cf415e632b6af
mazoko/python
/13_オブジェクト指向/test13-4.py
442
4
4
# 騎手クラス class Rider: def __init__(self, n): self.name = n # 馬クラス class Horse: def __init__(self, n, r): self.name = n self.rider = r # 騎手クラスのインスタンス生成 rider1 = Rider("アレキサンダー") # 馬クラスのインスタンス生成 horse1 = Horse("ブケファラス", rider1) print("{0}「ぼくの騎手は {1} !」".format(horse1.name, horse1.rider....
25bb54f77470789c6ff6305e22ca862518b5a2fa
mazoko/python
/04_関数/test4-2.py
142
3.96875
4
# 引数を出力する def PrintString(string): print(string) string = input("文字を入力してください:") PrintString(string)
a78f796791e1f4b19015707640a4e683325fba34
mazoko/python
/05_コンテナ/test5-2.py
106
3.796875
4
number = 10 print(number) if number < 10 : print("10未満です") else : print("10以上です")
fc50c4846e03e605b8100ff4007bbdb7ddd04244
mazoko/python
/04_関数/test4-4.py
648
3.84375
4
def Quotient(num): """ 引数(整数)を2で割った値(整数)を返す :param num : int型 整数 :return : int型 引数を2で割った値(整数) """ return num // 2 def Product(num): """ 引数(整数)に4を掛けた値を返す :param num : int型 整数 :return : int型 引数(整数)に4を掛けた値 """ return num * 4 inputNum = input("数値を入力してください:") ...
c0fdd5f8b40a8bce1db3e6808c3a9341789b6292
mazoko/python
/14_もっとオブジェクト指向/test14-1.py
1,222
4.1875
4
# 図形クラス class Shape: def __init__(self): pass def what_am_i(self): print("I am a shape!!") # 正方形クラス(図形クラスを継承) class Square(Shape): # 作成済み正方形リスト square_list = [] def __init__(self, s): self.side = s # リストにインスタンスを追加 self.square_list.append(self) # 外周計算メ...
ff678176e76cd23cf12be77e5c61aa830b0f2f8c
Dalelkhanova/WEB
/lab7/codingbat/String-2/count_code.py
142
3.75
4
def count_code(str): cnt = 0 for i in range(len(str)-3): sub = str[i:i+2] + str[i+3] if sub == 'coe': cnt += 1 return cnt
25c7b0f4dbe1abd6decea502dca0640ee76b1a5d
L200170068/prak_ASD_B
/modul_1_200170068.py
4,012
3.828125
4
#no.1 def cetakSiku(x): i=1 while i<=x: print("*"*i) i+=1 cetakSiku(5) #no.2 def gambarlahPesegiEmpat(a,b): i=1 print("@"*b) while(i<a): print("@"+" "*(b-2)+"@") i+=1 print("@"*b) gambarlahPesegiEmpat(4,5) #no.3a def jumlahHurufVokal(x): ...
d46c777407a3e45bfa98c7a9b7a8ea3e8d2b8e8b
Laisky/Coursera
/interactivepython-005/mini_project_3.py
1,559
3.515625
4
# Mini-project # 3 - "Stopwatch: The Game" import simplegui IS_RUNNING = False SUCCESS_STOP = 0 TOTAL_STOP = 0 SECONDS = 0 def format(n_sec): """ param n_sec: int, seconds * 10 """ minutes = n_sec // 600 seconds = n_sec % 600 // 10 millisec = n_sec % 10 return '%d:%02d.%d' % (minutes, ...
6496f27e75381706b4ed8b7d180cc0149ea413ac
vikasdesaitech/Graph-Traversal-Algortihms
/Graph_Algorithms/bfs.py
838
3.5625
4
class Bfs: def __init__(self, *args, **kwargs): self.adjacency_list = kwargs.get('adjacency_list', None) self.total_nodes = kwargs.get('total_nodes', 0) def shortestpath(self, start, end): queue = [] visited = [-1] * (self.total_nodes + 1) queue.append(start) vi...
ceb8399ec1f9cab8f73c205fdc5633bfe041990f
kepas06/Letters-Recognition
/app.py
1,485
3.90625
4
import network as net from random import random, uniform def main(): """ P1 and P2 are the given examples A is the most cottect answert and C is the most incorrect answer.P3 is test case. """ bias = 1.0 P1 = [1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0,...
df325169f35685b1e467da5b2e1465790eca74b1
chinnurtb/problem_sets
/uva/blocks_problem.py
8,064
4
4
#!/usr/bin/env python # A semi-literate-programming Python solution for the **Blocks Problem** # problem from [streamtech's](http://www.streamtech.nl/problemset/101.html) # problem set by [Brendan Hay](http://www.github.com/brendanhay). # ### Brief # #### Background # Many areas of Computer Science use simple, abs...
f2072679089d447efd2ed79d7994ca9b7b4c647c
NoteHon/PAT
/乙级/1017(20)A除以B.py
194
3.921875
4
#Python可以实现任意精度的计算,所以用Python做这个题就非常容易 a, b = map(int, input().split()) q = a // b r = a % b print(str(q) + " " + str(r)) #print("%d %d" % (q, r))
a6079ca9dd18ad71ea9a3aee7159e14985c90d63
serereg/homework-repository
/homeworks/homework7/hw2.py
2,154
4.3125
4
""" Given two strings. Return if they are equal when both are typed into empty text editors. # means a backspace character. Note that after backspacing an empty text, the text will continue empty. Examples: Input: s = "ab#c", t = "ad#c" Output: True # Both s and t become "ac". Input: s = "a##c", t = ...
e10d7fa1b2457d129396d35cc6885d03f4dee095
serereg/homework-repository
/homeworks/homework4/task_1_read_file.py
1,784
4.1875
4
""" Write a function that gets file path as an argument. Read the first line of the file. If first line is a number return true if number in an interval [1, 3)* and false otherwise. In case of any error, a ValueError should be thrown. Write a test for that function using pytest library. You should create files require...
c91cea964cc5f6b8931497a93c6ac1b37cf8ca62
serereg/homework-repository
/homeworks/homework2/hw5.py
1,611
4.15625
4
""" Some of the functions have a bit cumbersome behavior when we deal with positional and keyword arguments. Write a function that accept any iterable of unique values and then it behaves as range function: import string assert = custom_range(string.ascii_lowercase, 'g') == ['a', 'b', 'c', 'd', 'e', 'f'] assert = c...
c312bb50572e8260c13796c143961aa68d2cb8f8
serereg/homework-repository
/homeworks/homework2/hw3.py
752
4.125
4
""" Write a function that takes K lists as arguments and returns all possible lists of K items where the first element is from the first list, the second is from the second and so one. You may assume that that every list contain at least one element Example: assert combinations([1, 2], [3, 4]) == [ [1, 3], [...
764e06c119d1690a26a80ed11f51c517bf2fc6de
MohitSojitra/PythonExcersise
/Forloop.py
402
4.1875
4
# here i will show ypu a how we use a for loop list1 = ["mohit" , "parth" ,"manoj " , "mamu" , "kinjal" , 34, 54, 456] dictionary1 = {"mohit" : "moylo" , "parth" : "vando" , "manoj" : "bahubally"} for i, j in dictionary1.items(): print(i,j) list2 = ["mohit" , "mamu" , 45 ,54 , 23, 234, 2, 1, 3, 4, 5,6] for ite...
4117c2e4868e30898ffe65a65b702c5123c78a9c
MohitSojitra/PythonExcersise
/Oops8.py
891
3.796875
4
class Employee: def __init__(self, name, id): self.name = name self.id = id def show_detail(self): print(f"name is {self.name} and id is {self.id}") @classmethod def get_detail(cls, info): return cls(*info.split(",")) @staticmethod def print_com...
678be74407c266933fbe30990e0efaa0cde3a6a0
MohitSojitra/PythonExcersise
/Excersise5 snake water gun game.py
2,329
4
4
i = 1 computer_win = 0; win = 0 tie1 = 0 def computer_win_match(): global computer_win computer_win += 1 print(" you loss \n") print(f"computer win {computer_win} time") print(f"you win {win} time") print(f"total tie {tie1} match\n") print("choice again \n") def tie(): print("ti...
d9085475d79d664153e73818e7a07fe628910a06
DonCastillo/learning-python
/0060_sets_intro.py
2,661
4.25
4
farm_animals = {"sheep", "cow", "hen"} # sets are unordered, can set the order randomly every time the code is ran print(farm_animals) # sets only contains one copy of each element for animal in farm_animals: print(animal) print("=" * 40) wild_animals = set(["lion", "tiger", "panther", "elepha...
8cb403f83c4adda048cac31e73b14741d7ba2efa
DonCastillo/learning-python
/0009_formatting.py
1,235
4.09375
4
for i in range(1, 13): print("No. {0:2} squared is {1:4} and cubed is {2:4}".format(i, i**2, i**3)) # {index : width length which is the number or characters that will fit into the width} # right aligned (default) print() for i...
425cdc0106de1ee6b3920697503dbde5a0875467
DonCastillo/learning-python
/0062_file_IO_intro.py
1,052
3.78125
4
print() # opening, reading, and explicitly closing the file jabber = open("./data/sample.txt",mode="r") for line in jabber: if "jabberwock" in line.lower(): print(line, end='') jabber.close() print() # no need to explicitly close a file. # 'with' does that with open("./data/sample.txt", mode="r") as jab...
60ad66c0c83879d0b3578c83b453ffeeada1e0e0
DonCastillo/learning-python
/0001_printing.py
298
4
4
print('Hello, World') print(1 + 2) print(7 * 6) print() print("The end", "or is it?", "keep watching to learn more about Python", 3) # each argument is printed with whitespaces between them # converts int to string
dbe17c9eb2ac8c21844ca6ddd4d8aa22b9ea23bf
DonCastillo/learning-python
/0004_operators.py
244
3.84375
4
a = 12 b = 3 print(a + b) # 15 print(a - b) # 9 print(a * b) # 36 print(a / b) # 4.0 print(a // b) # 4 interger division print(a % b) # 0 print() # loop for i in range(1, a // b): print(i) print(a + b / 3 - 4 * 12)
f281c090cbdb408b9fece2852911b2ffb721ed97
rratliff/adventofcode2019
/wiregrid.py
7,230
4.125
4
import unittest def manhattanDistance(x, y): '''given a point, find its manhattan distance''' return abs(x) + abs(y) def findCrossingPoints(route1, route2): '''given 2 routes, find all the crossing points''' s1 = set(route1) s2 = set(route2) allCrossings = s1.intersection(s2) allCrossings....
33e5f4d3d80ce4dbf1de37d47766ce30e6c79473
nanayunn/py_sqlite
/backup_yourfile.py
4,904
3.71875
4
# -*- coding: utf-8 -*- import os import time def get_file_path_input(): source = raw_input("Input your file path: \n") # input 값을 source에 받는다. try : if not os.path.exists(source): print "FILE PATH INPUT ERROR : please input existing file\n" else: print "Loading..."...
bc8cdf916c7d7b3f58ede341b201685e8be77ff2
jerovane/TrainingPDI
/Questions/29/answer.py
862
3.640625
4
import cv2 import numpy as np # Read a rgb image image = cv2.imread('image.png') # Transform to grayscale grayscale_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # Apply hough transform circles = cv2.HoughCircles(grayscale_image, cv2.HOUGH_GRADIENT, 1, 30, param1=150, param2=25, minRadiu...
ea4a86cc32bfe8c474a07b123d02639349e4e32d
jerovane/TrainingPDI
/Questions/28/answer.py
483
3.75
4
import cv2 # Read a rgb image image = cv2.imread('image.jpg') # Transform to grayscale grayscale_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # Apply an adaptive threshold thresholded_image = cv2.adaptiveThreshold(grayscale_image, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 11, 2) # Show the input image ...
e8c85bd109e1a45a65edaa88c5bc36efa68b0c09
maxhumber/hickory
/hickory/colors.py
2,167
3.890625
4
from typing import Tuple, Union class Color: """ A composable coloring object. RED = Color(91) RED_FOREGROUND = RED BLUE_BACKGROUND = Color(104) # Sum Colors to combine them: RED_FORE_BLUE_BACK = RED_FOREGROUND + BLUE_BACKGROUND # Apply it to strings about to be printed >>> pri...
380da5ccdadb0bef3a7a4b97f15c05d8f69c4d73
marioluan/data-structures-and-algorithms
/algorithms/python/src/searching_algorithms/exponential_search.py
420
3.90625
4
from binary_search import binary_search_tn def exponential_search(ordered_list, x): """ implementation of an exponential search algorithm taken from: https://en.wikipedia.org/wiki/Exponential_search """ list_size = len(ordered_list) bound = 1 while bound*2 < list_size and ordered...
c67e8738b515c6f514123d1b27e57bdbee27a628
mnovak17/wojf
/lab01/secondconverter.py
497
4.125
4
#secondconverter.py #Translates seconds into hours, minutes, and seconds #Mitch Novak def main(): print("Welcome to my Second Converter! \n") print("This program will properly calculate the number of \n minutes and seconds under 60 from a given number of seconds") n = eval(input("How many seconds have you...
5c8c994d67629eec2aade0b86e8b4a1ad3d807ae
mnovak17/wojf
/lab02/fibonacci.py
370
4.25
4
#fibonacci.py #prints the fibonacci number at a given index #Mitch Novak #1/7/13 def main(): print("My incredible Fibonacci number generator!") n = eval(input("Plaese enter an integer:")) f0 = 1 f1 = 1 for i in range(3, n+1): temp = f0 + f1 f0 = f1 f1 = temp print("The",...
48bc41e4af31e5d9467cc9d202ef6930f15e2e9a
RinkuAkash/Python-libraries-for-ML
/Numpy/28_remove_specific_elements.py
390
3.796875
4
''' Created on 21/01/2020 @author: B Akash ''' ''' Problem statement: Write a Python program to remove specific elements in a numpy array. Expected Output: Original array: [ 10 20 30 40 50 60 70 80 90 100] Delete first, fourth and fifth elements: [ 20 30 60 70 80 90 100] ''' import numpy as np array=np.array([ 10...
8ef371fbb98f3cbe758871ee52a69fd0333711dc
RinkuAkash/Python-libraries-for-ML
/Numpy/12_common_values.py
365
3.703125
4
''' Created on 20/01/2020 @author: B Akash ''' ''' Problem statement: Write a Python program to find common values between two arrays. Expected Output: Array1: [ 0 10 20 40 60] Array2: [10, 30, 40] Common values between two arrays: [10 40] ''' import numpy as np array1=np.array([0,10,20,40,60]) array2=np.array([1...
4a0738f39e7d517d81903dd7a63f76b7f6b8d7a5
RinkuAkash/Python-libraries-for-ML
/Numpy/23_scalar_multiplication.py
426
4.1875
4
''' Created on 21/01/2020 @author: B Akash ''' ''' problem statement: Write a Python program to create an array of (3, 4) shape, multiply every element value by 3 and display the new array. Expected Output: Original array elements: [[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11]] New array elements: [[ 0 3 6 9] [12 15 18 21]...
cb09985c88ec082a2d2db93286e99854480a7a42
RinkuAkash/Python-libraries-for-ML
/Numpy/20_zeros_ones.py
314
3.953125
4
''' Created on 20/01/2020 @author: B Akash ''' ''' Problem statement: Write a Python program to create an array which looks like below array. Expected Output: [[ 0. 0. 0.] [ 1. 0. 0.] [ 1. 1. 0.] [ 1. 1. 1.]] ''' import numpy as np array=np.zeros((4,3)) for i in range(0,3): array[i+1:,:i+1]=1 print(array)
67d8bb07c7557b8bf56459c878e73b4f6bc544a7
SuryaSankar/concepts-lab
/concepts/sort/bubble_sort.py
202
3.921875
4
def bubble_sort(lst): for end_ptr in reversed(range(len(lst))): for i in range(end_ptr): if lst[i] > lst[i+1]: lst[i], lst[i+1] = lst[i+1], lst[i] return lst
c63b123bb4c1cb6a4de2e08de1e8e19d56c71714
smd-faizan/single-unit-neural-network
/code/tempusClassification.py
3,017
3.796875
4
import numpy as np import sys import pdb import time feature_vector_size = 16562 num_of_training_samples = 420 num_of_test_samples = 110 num_of_iterations=500 neeta = 1 input_data_url = "C:\\Users\\faizi\\Downloads\\DScasestudy1\\takehome1.txt" train_data = np.zeros(shape=(num_of_training_samples, feature_vector_siz...
ad0992fc6d028b4354ed58521ee6824da414576e
jullianzz/EC441-Assignment-1
/client_server/server-python.py
1,504
3.703125
4
############################################################################### # server-python.py # Name: # BU ID: # Email: ############################################################################### import sys import socket RECV_BUFFER_SIZE = 2048 QUEUE_LENGTH = 10 def server(server_port): """TODO: Listen...
8833887efc975f7bbc66e79a7122e0517cdb9542
AJV1416/SIP-2018-starter
/U2-Applications/U2.1-Data/data_vis_project_starter.py
1,139
3.71875
4
''' In this project, you will visualize the feelings and language used in a set of Tweets. This starter code loads the appropriate libraries and the Twitter data you'll need! ''' import json from textblob import TextBlob import matplotlib.pyplot as plt def avg(lst): return sum(lst)/len(lst) #Get the JSON data ...
0ac549f8f324ddc0246cc9a6227ed0ddb715ffde
sabgul/python-mini-projects
/guess_the_number/main.py
1,110
4.28125
4
import random def guess(x): random_number = random.randint(1, x) guess = 0 while guess != random_number: guess = input(f'Guess a number between 1 and {x}: ') guess = int(guess) if guess < random_number: print('Guess was too low. Try again.') elif guess > ran...
bb5dcd73bf847b40557321085fba1e43c002248a
Confuzerpy/checkio_solve
/home/password.py
214
3.515625
4
import re def checkio(password): if len(password) >= 10 and re.search("[a-z]+", password) and re.search("[A-Z]+", password) and re.search("[0-9]+", password): return True else: return False
6f912f266609e25f26a33f675a1fd61e3d9bd30c
DIEE-ISDe-code/design_pattern
/observer/observer3.py
2,088
3.671875
4
# observer3.py (Python 3) # The Observer class Subscriber: def __init__(self, name): self.name = name def update(self, message): print( self.name,' received the message ', message) # The Observable class Publisher: def __init__(self, events): # The constructor accepts in input a ...
9344665701723ff283e6b5e0adede3716dc66c9b
JIdigit/Part4-Task13
/task13.py
425
3.578125
4
def superDigit(n, k): super_num = n*k # print(len(super_num)) if len(super_num) == 1: return super_num else: temp_num = 0 for i in super_num: temp_num = temp_num + int(i) return superDigit(str(temp_num),1) return 'hey' if __name__ == '__...
5a41105ad05aaab4362485514895d403326885c8
batrakaushal/Py4e
/804.py
275
3.953125
4
fname = input("Enter file name: ") fh = open(fname) lst = list() for line in fh: for a in line.split(): #prints eack word if not a in lst: #add words to list if not there lst.append(a) #print(lst) lst.sort() print(lst)
1cede85ea16ec7ddfd792da933582cc76f4d2432
batrakaushal/Py4e
/url.py
194
3.78125
4
# Use the file name mbox-short.txt as the file name fname = input("Enter file name: ") fh = open(fname) count=0 all=0 for line in fh: if line.startswith("htt") : print(line)
235b4389b12f4e043c925988a12de86921cbb424
PymPhekasut/Practical_Python
/FileWordCount.py
927
4.03125
4
def create_wordcount_dict(filename): # Your code goes here to create and return a dictionary file = open("bigdata.txt","r") count = 0 for line in file: words = line.split(" ") count += len(words) file.close() print("Number of words in a T...
2a149cd5a70b29427abca1c05bbfa7a930de7cb7
HackerDom/ctfcup-2019-tb
/ideas/misc/iq-test/service/server.py
1,609
3.59375
4
#!/usr/bin/env python3 from decimal import Decimal, getcontext def center_line(line, length): return line.rjust((length + len(line)) // 2).ljust(length) def build_banner(value): value = str(value) padding = ' ' * (len(value) + 3) lines = [ '', '95% of people cannot solve this!', ...
c040c8e75b84f80a127cf251d633a4cb358c2d3c
OmarKimo/100DaysOfPython
/Day 024/main.py
498
3.578125
4
#TODO: Create a letter using starting_letter.txt #for each name in invited_names.txt #Replace the [name] placeholder with the actual name. #Save the letters in the folder "ReadyToSend". starting_letter = open('Input/Letters/starting_letter.txt', 'r').read() with open('Input/Names/invited_names.txt', 'r') as f: f...
5f215b292c15000d73a2007e8ed8e81d32e536a5
OmarKimo/100DaysOfPython
/Day 001/BandNameGenerator.py
465
4.5
4
# 1. Create a greeting for your program. print("Welcome to My Band Name Generator. ^_^") # 2. Ask the user for the city that they grow up in. city = input("What's the name of the city you grow up in?\n") # 3. Ask the user for the name of a pet. pet = input("Enter a name of a pet.\n") # 4. Combine the name of their c...
cdd057077f289e5837b03cf63d38a5e00021c3a0
OmarKimo/100DaysOfPython
/Day 019/TurtleRace.py
893
4
4
from turtle import Turtle, Screen from random import randint screen = Screen() screen.setup(width=500, height=400) in_color = screen.textinput( title="Make your bet", prompt="Who will win the race? Enter a color:" ) objects = [Turtle(shape="turtle") for _ in range(6)] rainbow = ["red", "orange", "yellow", "green...
ebca9d6de69c7539774b2a57852d492ab0d7295d
Nicodona/Your-First-Contribution
/Python/miniATM.py
2,703
4.25
4
# import date library import datetime currentDate = datetime.date.today() # get name from user name = input("enter name : ") # create a list of existing name and password and account balance nameDatabase = ['paul', 'peter', 'emile', 'nico'] passwordDatabase = ['paulpass', 'peterpass','emilepass', 'nicopass'] accountB...
9adaf076dd8cdb4f27067e3430e66121c65d612d
jsterf/dat-119-2019-spring
/Sterf_Final_Project.py
8,253
4.09375
4
""" Joe Sterf 4/28/2019 Python 1 - DAT-119 - Spring 2019 Final Project Tic-Tac-Toe Game """ import random #create dictionary build board and track player moves board = {1:'1',2:'2',3:'3',4:'4',5:'5',6:'6',7:'7',8:'8',9:'9'} #create list to track which spaces have been played spaces_taken = [] #prints tic-tac-t...
bc3b76c61d6de689fc4892f9ef365000130bb483
Raghav14200/python
/1month/functions.py
174
3.734375
4
def greet(name): return "hi"+name print(greet("Raghu")) a=9 b=7 c=sum((a,b))#built-in function print(c) def multiply(a,b): return a*b d=multiply(3,4) print(d)
39aebcb475446bf89420a31dbdeee091878a410d
Raghav14200/python
/1month/try_except.py
180
3.75
4
print("Enter num 1") num1 = input() print("Enter num 2") num2 = input() try: print(int(num1)+int(num2)) except Exception as e: print(e) print("This is very important")
ce950d8d8266186b78e3a4a57ab9bd6e09d70a7d
jeremyosborne/python
/regex_lab/regex1.py
386
3.546875
4
# Find the IP address in the following line using a regex group and the # re.search function. Print the IP address using the match object group # method, as well as the index of where the grouping starts and ends. log = '208.115.111.73 - - [01/Apr/2013:06:30:26 -0700] "GET /nanowiki/index.php/1_November_2007_-_Day_1 HT...
404cdd24f5ff35c10fe60fa6961647220fa3ea0d
jeremyosborne/python
/encoding_decoding/hash.py
967
3.578125
4
# Can use the hashlib to return the hash value of a string. # import hashlib # File contents with open("data/example.xml") as f: test = f.read() # To see what hashes we have supported (new in 2.7) print "What hash algorithms are available:", hashlib.algorithms # To get the md5 using a hexadecimal syst...
68074c4bbb2e20fd85836126e4d1b7086f1f28ae
jeremyosborne/python
/datatypes/tuples.py
936
4.0625
4
# Tuples: immutable list-like structures. # Very similar to lists, but being immutable, their semantics, while not # strictly enforced, can be powerful. (A coordinate on the globe is easily, # semantically expressed as a simple tuple.) # Two ways to create an equivalent tuple. t = (1, 2, 'hello') t2 = 1, 2, 'hello' #...
029d10098cdfea29780e7791b53db3da785b9d69
jeremyosborne/python
/general/wrestling/wrestling.py
4,410
4
4
""" Fictitious pro wrestling! Make fictitious people wrestle it out in a fake pro wrestling match. """ from StringIO import StringIO from random import randint, choice from wrestler import Wrestler, get_wrestlers import db def create_a_wrestler(): while True: try: name = raw_input("What wil...
3169513a799ac50425a401ee27e7755698829c19
jeremyosborne/python
/http/httprequests.py
1,693
3.59375
4
import urllib import urllib2 from urlparse import urlparse # Sample url. See: http://ivanzuzak.info/urlecho/ url = "http://urlecho.appspot.com/echo" # Query string, specific to the data = urllib.urlencode({"status": 200, "Content-Type": "text/plain", "body": "Y...
6614083932d6659190d7eb0dc5ba9693d2faa44e
jeremyosborne/python
/iters_lab/solution/itools.py
816
4.28125
4
""" Lab --- Using the iterutils, figure out the number of permutations possible when rolling two 6-sided dice. (Hint: Think cartesian product, not the permutations function.) Print the total number of permutations. Make a simple ascii chart that displays the count of permutat...
e04e3b16929bf788bfbba340cca837abaed31249
Marckartur66/tareitas_paradigmas_marcos
/Calculadora.py
1,734
4.0625
4
#calculadora con programacion funcional print ("vienvenido a la calculador; elige una opcion \n 1: suma \n 2: resta \n 3: divicion \n 4: multiplicacion \n 5:modulo") elec = int(input()) def seleccion (elec): elec = int(input("ingrese la eleccion (0: salir)")) return elec def Suma(): nu...
9ea74277b1eb0d0ebd5a25414dc7b125813320e1
Kieldro/hello
/python/hello.py
2,789
4
4
""" hello python examples of python features no curly braces for function bodies no semicolons no datatypes implicit main """ #import otherPy # Main Function if __name__ == '__main__': # doesn't not execute when imported 2 4 x = 4 # variable declarations don't need data types s = 'concat ' + "\ndouble and si...
9db008600e3ef450450d4ae0489eff69c803522f
JasonHannanto/Mp3Player
/tests/test_songplayer.py
824
3.53125
4
import unittest from songplayer import SongPlayer from user import User class SongPlayer_test(unittest.TestCase): def setUp(self): self.player = SongPlayer("Jason") self.raw_songlist = self.player.data_input("song_list.txt") self.songlist = self.player.import_song(self.raw_songlist) ...
8f4f3dc2dbd7867f5ae52b9d4f52fcb64f7c04b4
laphayen/Algorithm-Python
/sort/shell sort.py
496
3.953125
4
# 셸 정렬 def gap_insertion_sort(x, start, gap): for target in range(start+gap, len(x), gap): val = x[target] i = target while i> start: if x[i-gap] > val: x[i] = x[i-gap] else: break i -=gap x[i] = val ...
27af2c2e3862b90078c77763ad55828ecc1060d1
laphayen/Algorithm-Python
/max/max.py
230
3.59375
4
# 최대값 def max_n(n): x = len(n) max_first = n[0] for i in range(1, x): if n[i] > max_first: max_first = n[i] return max_first a = [16, 18, 1, 6, 8, 33, 9] print(max_n(a))
edc84c8a30911e7bd2d8c82fbdcac975cd3a1f40
Deathcalling/Data-Analysis
/pythonData/pythonPandas/pandasBasics1.py
1,529
4.125
4
import pandas as pd #Here we import all necessary modules for us to use. import datetime import matplotlib.pyplot as plt import numpy as np from matplotlib import style #This simply tells python that we want to make matplotlib look a bit nicer. style.use('ggplot') #Here we tell python what kind of style we would l...
9855b6bd43957ddc7a1a7d32943e87cfbcc0484d
BORB-CHOI/python-theory
/src/3.3~3.4 Methods.py
961
3.78125
4
# def start(self): # print(self.color) # print("I started") # porche = Car() # porche.color = "Red Sexy Red" # porche.start() class Car(): def __init__(self, **kwargs): self.wheels = 4 self.doors = 4 self.windows = 4 self.seats = 4 self.color = kwargs.g...
a16d343ead1a5cd53a9ee66adb9179e9023b9b45
BORB-CHOI/python-theory
/src/1.9 Code Challeange.py
438
4
4
def plus(x, y): return float(x) + float(y) def minus(x, y): return float(x) - float(y) def times(x, y): return float(x) * float(y) def division(x, y): return float(x) / float(y) def negation(x, y): return -float(x), -float(y) def power(x, y): return float(x) ** float(y) print(plus(5,...
55871ebaaaa897b1df072f6cb557f7b85c8415c7
siddharth456/python_scripts
/python/for_loop.py
164
4.25
4
for letter in 'python': print("Current letter is: ",letter) fruits = ['apple','banana','mango'] for fruit in fruits: print("Current fruit is: ",fruit)
ef5ad01f85285601321ec6fa246a16e6f07b775b
siddharth456/python_scripts
/python/add_elements_to_a_list.py
251
4.34375
4
# add elements to an empty list testlist=[] x=int(input("enter number of elements to be added to the list:")) for i in range(x): e=input("enter element:") testlist.insert(i,e) print() # adds an empty line print("Your list is",testlist)
765ef2015ab6e9c4083ca4265bebb32f33f508b6
siddharth456/python_scripts
/python/time_calendar_module.py
883
3.5625
4
# time and calendar module import time import calendar # number of ticks since epoch print("Number of ticks since epoch:",time.time()) print() # the time tuple print(time.localtime(time.time())) print() # current formatted time print("the current time is:",time.asctime(time.localtime(time.time()))) print() # get c...
78b33ab48d790cca0d83a2dfb8610aedded2a2dd
siddharth456/python_scripts
/python/for_else.py
186
4.25
4
# testing 'else' with for loop for letter in 'printer': if (letter=='z'): print("hello") else: for letter in 'printer': if (letter=='i'): print("bye")
911040a477c107f353b3faace1d688dafde3064d
siddharth456/python_scripts
/python/create_user_input_list.py
209
4.375
4
# We will create a list using user input userlist = [] # this is how you initialize a list for i in range(5): a=input("Enter element:") userlist.append(a) print ("your created list is:",userlist)
340f652250eb353d8779ecafcbcbd56e45559193
richpath/Pi-WS2801-test
/key_move_test_v2.py
3,296
3.796875
4
import pygame import random # Define some colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = (255, 0, 0) BLUE = (0, 0, 255) YELLOW = (255, 255, 0) ORANGE = (255, 165, 0) DKGREEN = (0, 100, 0) GREENYELLOW = (173, 255, 47) CYAN = (0, 255, 255) DARKVIOLET = (148, 0, 211) MAGENTA = (255, 0, 255) G...
1d36b50e2754c1fa17ce802936181cff8a936929
eshkil/Python_Prometheus_Courses
/Lesson6.1.py
499
3.625
4
def count_holes(n): dict = {1:0,2:0,3:0,4:1,5:0,6:1,7:0,8:2,9:1,0:1} if type(n) in [str,int,long]: if type(n) == str: try: n = long(n) except ValueError: return 'ERROR' if type(n) in [int,long]: n = str(n) if n[0] == '-'...
d2bac6e3960c6b09a6dddad8c3e59f5870339394
eshkil/Python_Prometheus_Courses
/Test_zipfile.py
6,856
3.5
4
import sys import os import zipfile import datetime def zipping_process(directory, year, prefix, isdelete): if os.path.exists(directory): catalog_list = os.listdir(directory) # list all from catalog files_for_zip = filter(lambda x: x.endswith(year[2:] + '.zip'), catalog_list) # list files for zippi...
644da977f7f6d1eef95c760fecdab4e069a227a2
pranayvissa/project-learning
/linked_lists/double_linked_list.py
2,732
3.984375
4
#!/proj/olympus/work/sw/hware/tools/centos-7/bin/python class Node: def __init__(self, data): self.data = data self.prev = None self.next = None class MyLinkedList: def __init__(self): """ Initialize your data structure here. """ self.length = 0 ...
b0d241d8fc80af44989ebe427a9625d1d28bb29a
IntertwineIO/contextualize
/contextualize/utils/singleton.py
1,816
3.84375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from itertools import chain class Singleton: """ Singleton A base class to ensure only a single instance is created. Several measures are taken to encourage responsible usage: - The instance is only initialized once upon initial creation and arg...
778d810d3069578f97477cbdafdaf13d08a664ff
zeyh/rating-data-processing-tools
/sanity_check.py
1,609
3.703125
4
''' read in a file and print out shape, first 3 rows, min and max value, distinct items in each column, sparsity !all assuming in int32 (4 byte int) run >> $ python3 sanity_check.py dataset/storage/extracted_0.csv will get outputs like: (10775085, 3) row sample: [ 1 29 7] [ 1 32 7] min/max value in co...
46a31cb543b31f928eba3e29810b3887482567c1
BradleyPelton/Leetcode-Solutions
/contests2020q2/leetcode20200404/testfunctions.py
435
3.703125
4
def construct_optimal_string(a,b,c): alphabet = [('a', a), ('b', b), ('c',c)] alphabet.sort(key=lambda x: x[1]) print(alphabet) # construct_optimal_string(1,1,7) # construct_optimal_string(1,0,5) def within_two(a,b,c): if a-b <= 2 and b-a <=2 and a-c <= 2 and c-a <= 2 and b-c <= 2 and c-b <=2...
35ea8d19804a4e242f2b5ff25ec3069dad9dcc78
BradleyPelton/Leetcode-Solutions
/contests2020q2/leetcode20200523/palintree.py
2,577
3.984375
4
# Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right from collections import Counter # Accepted after 3 attempt. Solved at 11:26. # Fell into a famous trap where I was appending the point...
12cc12b7cf34daae85af319a1097abeecd291074
BradleyPelton/Leetcode-Solutions
/contests2019/leetcode20191130biweekly/notes.py
333
3.53125
4
def isintersect(interval1,interval2): # [[a,b],[c,d]] if interval2[0] < interval1[1]: return(True) return(False) print(isintersect([1,3],[2,4])) print(isintersect([1,10],[10,15])) print(isintersect([0,30],[10,20])) print(isintersect([1,3],[2,4])) print(isintersect([1,3],[2,4])) print(isintersect(...
7fd6214e48b1831b3eefa6b71ee1d78ba26230de
BradleyPelton/Leetcode-Solutions
/contests2019/Leetcode20191123/minimumtime.py
807
3.546875
4
from typing import List class contests2020q4.leetcode20201017.Solution: def minTimeToVisitAllPoints(self, points: List[List[int]]) -> int: pass def distance(node1,node2): # distance = 0 vector = [node2[0]-node1[0],node2[1]-node1[1]] #[3,2] - [1,1] = [2,1] ...
74f4ddc86a28e44b5712d0ef807a9b73080f0564
BradleyPelton/Leetcode-Solutions
/contests2020q2/leetcode20200404Biweekly/circlesquare3.py
2,690
3.71875
4
import math # BRUTE FORCE DIDNT WORK. CHECKING 4000 POINTS ON THE SQUARE DIDNT WORK class contests2020q4.leetcode20201017.Solution: def checkOverlap(self, radius: int, x_center: int, y_center: int, x1: int, y1: int, x2: int, y2: int) -> bool: """ check overlap""" def euclidean_...
b2512a94aa79124f489da5c485247365029833b8
BradleyPelton/Leetcode-Solutions
/contests2020q2/leetcode20200627biweekly/subarray.py
3,843
3.59375
4
from typing import List ## FIrst attemtp rejected, edge case [1,0,0,0,0] # Accepted after second attempt, forgot to handle the edge case where candidate_lengths was empty # I liked this problem, but I'm sure my approach was barbaric. 85 lines is pretty long. class contests2020q4.leetcode20201017.Solution: def l...
4aeb82d2de60ebaf476dc067a757aec115944a2e
BradleyPelton/Leetcode-Solutions
/contests2020q3/leetcode20200822biweekly/functionacalls.py
1,682
3.53125
4
from typing import List ### first two attempts: I misunderstood the problem. you can add +1 at any time ### Switching two functionacalls2.py class contests2020q4.leetcode20201017.Solution: def minOperations(self, nums: List[int]) -> int: """ """ num_of_operations = 0 two_arr = [2**i for...
6808c4bc7697f718522dbb8caad218c95efe727a
BradleyPelton/Leetcode-Solutions
/contests2020q2/leetcode20200627biweekly/avgsalary.py
558
3.5625
4
from typing import List # Accepted first try, 4 minutes. class contests2020q4.leetcode20201017.Solution: def average(self, salary: List[int]) -> float: max_sal = max(salary) min_sal = min(salary) correct_salaries = [sal for sal in salary if sal != max_sal and sal != min_sal] # p...
75eb4b3832031ee4fd7f1ab5fd4b4d4588bea640
BradleyPelton/Leetcode-Solutions
/contests2020q2/leetcode20200613/helperfuncts.py
446
3.84375
4
def possible_boq(bool_list , k): """Return the number of bouquets, OF SIZE k, can be made from bool_list""" bool_string = '' for flower in bool_list: bool_string += str(flower) # print(bool_string) ones = bool_string.split('0') # print(ones) good_boqs = 0 for subset in ones: ...