blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
1d5c29659ecd24855090d65452207b1263edf1b9
vincepay/Project_Euler
/python/21-30/Prob24.py
1,233
3.953125
4
#A permutation is an ordered arrangement of objects. #For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. #If all of the permutations are listed numerically or alphabetically, #we call it lexicographic order. The lexicographic permutations of #0, 1 and 2 are: #012 021 102 120 201 210 ...
1be2ba332eefe629d90e61cb0208e46878637ca2
pcattori/maps
/tests/test_nameddict.py
1,640
3.5
4
from maps import NamedDict import unittest class NamedDictTest(unittest.TestCase): def test_create(self): nd = NamedDict({'a': 1, 'b': 2}) self.assertIsInstance(nd, NamedDict) self.assertTrue(hasattr(nd, 'a')) self.assertTrue(hasattr(nd, 'b')) nd = NamedDict(a=1, b=2) ...
e7591e9560562578842483542ea688fba316de8d
ScorcherGray/View
/view.py
2,383
3.75
4
import sys if __name__ == '__main__': args = sys.argv #Need to add default viewsize = 25 #assert(len(args) == 3), "Incorrect arguments " #print(args) def view(fname, view_size=25): pages = [0] words = open(fname, "r") #Traverse the entire file collecing positions where each view_size begins...
717c53cb227e17028a6462c306de0cf6ad97b7c9
waqarsaleem/k-permute
/permute.py
1,307
3.84375
4
# Recursive computation of all k-length permutations given k lists where the # i-th element in each permutation is from the i-th list. import random def get_random_lists(): lists = [] num_lists = random.randrange(2, 10) for _ in range(num_lists): list_size = random.randrange(2, 10) lists.a...
e233cdfca2a40323b15d9ad82ae09d98d79577f9
tonitch/HerChat
/client.py
1,436
3.703125
4
from tkinter import Tk, Frame, Menu, Entry, Label, Button class window(Frame): """ Sub-Class: Frame; window object """ def __init__(self, master): super().__init__(master) def drawMainGui(self): """ draw the main window to the chat """ self.menu = Menu(...
7141d9c960d0cba9e0a37716b09260981fa8f4f8
avischool/ArtOfDataAviKumar
/Lab1/digmonlab.py
2,923
4.0625
4
import csv def largesthp(): with open("digimon.csv", "r") as f: data = csv.DictReader(f) finaldict = {} for pokemon in data: species = pokemon['Digimon'] hp = pokemon['HP'] if species not in finaldict: finaldict[species] = 0 f...
47b08de57384ce0f3f55c8f1c19390d8fec7d63f
GasparyanG/Car_racing_game
/map_of_the_race/map_blueprint.py
3,599
4.21875
4
from map_of_the_race import factory_method, commands_to_iterator """ check out data structure module: update method needed to be a component of data structure implementor more precisely it must implement update method depending on "easy and hard game"! """ # User will have a car and car will h...
9d3e4e6df21c3cf8d75da0d07d84c1b89f4edf73
GasparyanG/Car_racing_game
/implementor_and_decorator_of_car_engine/car_properties/decorator_of_car_engine.py
2,696
3.6875
4
from random import choice # This class will be initialized by car (car_blueprint.py) object, # which will inject its current implementor of engine by constructor of decorater # Decorater absract class with its concrete decoraters class EngineDecorator: def __init__(self): self.product_to_decorate = None ...
a927d01b0cc3990b79749cef75ab8ee37fbfe321
AlexeiBarabash/LPI-Course_Python
/Q1_class
158
3.8125
4
#!/usr/bin/env python3 x=raw_input("Human please inter a number ! ") or "1" x=int(x) def printer(x): if x>1: print("Hello World \n"*x) printer(x)
9f4491a1bdf09e84dab45c9a49ad1cbb933495f2
olleyibi/Security-in-TCP-sockets
/startClient.py
3,147
3.84375
4
# check length of the RNA String def check_len(message): if len(message)%3 != 0: message = "DISCONNECT" print("INVALID RNA LENGTH") return message else: return message # check each nucleotide in RNA String def check_item(message): if message != "DISCONNECT": for...
48e42e1ac901d0fe61b1ead072fa7474f0430e0e
GermanVq/Exercism_python
/series/series.py
281
3.515625
4
def slices(series, length): if length > len(series) or length < 1 or len(series) == 0: raise ValueError("There is no series") else: return [series[i:i+ length] for i in range(0, len(series)) if len(series[i:i +length])==length]
5762e5d2f33c8b349a4f59b48fbb659291350a91
GermanVq/Exercism_python
/darts/darts.py
222
3.609375
4
import math def score(x, y): lands = math.sqrt(x**2+y**2) if lands <= 1: return 10 elif lands <= 5: return 5 elif lands <= 10: return 1 else: return 0
b53be157ee268359db43bb40c5ab0366dac9b23e
KristiyanDimitrov/University-Tasks
/Week_4 BasicTask_9.py
2,226
4.1875
4
""" BINARY_SEARCH_RANGE(alist, range_f, range_l) // Searches for a value within a specific interval (range_f = range from -/- range_l = range last count <-- 0 lst <-- alist.copy() // Makes a copy of the list as it gets altered lst.add(None) first <-- 0 last <-- le...
bf7a076bb88d6ce55ee65f75aa9a2221a957dad7
michaelswitzer/projecteuler
/problem004.py
478
4.0625
4
# A palindromic number reads the same both ways. The largest palindrome # made from the product of two 2-digit numbers is 9009 = 91 * 99. # # Find the largest palindrome made from the product of two 3-digit numbers. from common_funcs import answer, is_palindrome def solve(): largest = 0 for i in range(999,10...
afcad90b5468ef0f965a0575e6191dba5696e81d
michaelswitzer/projecteuler
/problem009.py
610
4.1875
4
# A Pythagorean triplet is a set of three natural numbers, a < b < c, for # which, # # a**2 + b**2 = c**2 For example, 32 + 42 = 9 + 16 = 25 = 5**2. # # There exists exactly one Pythagorean triplet for which a + b + c = 1000. # Find the product abc. from common_funcs import answer def find_abc(sum): for a in ra...
c589c1db154bc5779e839ef381794da3c776d8f5
michaelswitzer/projecteuler
/problem040.py
678
3.765625
4
# An irrational decimal fraction is created by concatenating the positive # integers: # # 0.123456789101112131415161718192021... # # It can be seen that the 12th digit of the fractional part is 1. # # If dn represents the nth digit of the fractional part, find the value of # the following expression. # # d1 * d10 *...
a711dba1e90feb4d8148f983ee6b1d3ada63be70
michaelswitzer/projecteuler
/problem034.py
664
3.765625
4
# 145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. # # Find the sum of all numbers which are equal to the sum of the factorial # of their digits. # # Note: as 1! = 1 and 2! = 2 are not sums they are not included. import math import time from common_funcs import answer def solve(): begin_time = ti...
360a1d24cc703bd67779665c9e5a1dc711d1ba96
michaelswitzer/projecteuler
/problem022.py
1,254
4.0625
4
# Using names.txt (right click and 'Save Link/Target As...'), a 46K text # file containing over five-thousand first names, begin by sorting it into # alphabetical order. Then working out the alphabetical value for each # name, multiply this value by its alphabetical position in the list to # obtain a name score. # # F...
b191593913360db2eea1eb7536b83dd6357e5d03
michaelswitzer/projecteuler
/problem006.py
844
3.75
4
# The sum of the squares of the first ten natural numbers is, # # 1^2 + 2^2 + ... + 10^2 = 385 The square of the sum of the first ten natural # numbers is, # # (1 + 2 + ... + 10)2 = 552 = 3025 Hence the difference between the sum of # the squares of the first ten natural numbers and the square of the sum # is 3025 - ...
9fc3059e1a0fa27078b680a7b01ee7d121c7b50d
SuhaneeP/Wireless-Communications
/AWGN vs Rayleigh/Python/AWGN vs Rayleigh.py
4,353
3.921875
4
import matplotlib.pyplot as plt import numpy as np from scipy.stats import norm def generate_noise(signal, R, EbN0): """Generate the noise array for a given signal and its SNR The array of randomly generated values is multiplied with the noise variance which is computed using the SNR value. The array ...
2c9f414b376627d52e8bc19ed93ea009c715ebbe
Malfunction13/MentorMate-Challenge
/Green_VS_Red_Final.py
4,606
4.0625
4
import copy """Takes user input on board dimension, initializes the board and collects the target to track and number of turns""" board_size = input("Please insert your board size as X, Y: ").split(", ") columns, rows = int(board_size[0]), int(board_size[1]) board = [] for i in range(rows): # takes input on...
e033e80d6f44e5a4f1f4fac00f643183da29844d
josefizuda/python_Exercicios
/aula6.py
251
3.9375
4
nome = str(input('Digite seu nome: ')) print(nome.capitalize()) print('O tipo primitivo é: ', type(nome)) print('Ele é numerico? ', nome.isnumeric()) print('Ele e alfa numerico? ', nome.isalnum()) print('Ele e alfa caixa alta? ', nome.isupper())
ed59bf3d69c86106f9bd34b62833db92585a18bd
Karagul/openrating
/openrating/expenses.py
2,079
4.03125
4
import numpy as np class Expense(object): """ The `Expense` class represents an expense that needs to be paid in the priority of payments. In general we need to instances of this class: * Senior expenses: - shortfall: the senior shortfall - shortfall_rate: the senior shortf...
9ba6b9349f5e9fcd1abe281d6ac79d11ad289efe
RazvanCabalau/Tema1-SDA
/Test/test.py
4,525
3.640625
4
#am facut o parte din rezolvare #nu cred ca e cea mai eficienta posibil #mai sunt inca multe lucruri de facut from itertools import chain, combinations import collections import random def powerset(iterable): s = list(iterable) return chain.from_iterable(combinations(s, r) for r in range(len(s)+1)) #codul ...
9f1a874dd615079862ad6c33c4ab0a47cb5fa5e7
Ayaz-75/Randomisation-using-for-loop-in-python
/highest_score.py
466
4.28125
4
#highest score in the class #loop used to find lenght and integer form of string students_score=input("Enter students score: ").split() for n in range(0,len(students_score)): students_score[n]=int(students_score[n]) print(students_score) #this loop is used to compare the entire list with one element highest_s...
c98df2da45253cc6aca7c9adf6f978f64d94e8c0
bpsmth/PythonHW
/determinant.py
352
3.65625
4
def determinant(x): #this function returns the value of the determinant for a 2x2 matrix det=(x[0][0]*x[1][1])-(x[0][1]*x[1][0]) #above statement calculates the det from the values passed in #below statement returns the calculation return det; #these two statements were used for testing #A = [ [23.0,19.2], [-5....
2b2af4bcd90a204952913f9bc4e3dca2ee9795e7
danlages/Dijkstra-MaxFlow
/algorithm.py
8,197
3.765625
4
infinity = 1000000 invalid_node = - 1 class Node: #Defines a node in the network previous = invalid_node distFromSource = infinity visited = False def populateNetwork(fileName): #Populates list with network nodes taking name of file as parameter network = [] #Defines the list to be populated by netwo...
c47296df1e5259491376ced99c65c764d4f1d6d3
Richard5127/Python
/dtype/dtype-str4.py
82
3.5
4
#!/usr/bin/python # coding: utf-8 x = 123 y = 456 print(str(x) * 3 + str(y) * 2)
c5706e09be0b328b62b4c4d945e93f62d02ba4ed
Richard5127/Python
/ifelse/if1.py
129
3.578125
4
#!/usr/bin/env python # coding: utf-8 var = raw_input("請輸入一字串") if var: print ("輸入的字串是:" + str(var))
c1f69ab545c7ce46d7c1f8b924816726021c9f00
satalahti/procrastination
/asdf.py
252
3.890625
4
''' a = "Hello guys!!" print(a) fruitBasket = ["Apple","Orange","Dragonfruit","Longan","Grapefruit"] #elements of array print((fruitBasket)[2]) ''' print("It's me, Mario") a = "Moro" print(a) print("vittu".upper()) print("SANNI".lower())
726cfc84ce32cf45a8ca32eb27050ccf807d6337
TechAle/CompleteMaze
/main.py
10,016
3.515625
4
## inspired from https://www.youtube.com/watch?v=uuUbdluqSiE ## ## it works but it's bad optimized ## TODO make it better from tkinter import * import time Lista = [] rows = 0 distance = 0 option = 0 n_spawn = 1 n_end = 1 cell = {'spawn': 0, 'end': 0} num = 0 x_start = x_finish = y_start = y_finish = 0 ## class main cl...
986d8ffe5d2be35c629e28d8b2ae999a806d768f
enriquenc/n-puzzle
/puzzle_parser.py
3,603
3.640625
4
import fileinput import re from error import Error, error from argparser import args import sys class Parser: def __init__(self): self.size = 0 self.puzzle_elements = [] self.max_value = 0 self.puzzle = [] def find_size(self, line): line = self.clear_line(line) ...
a2df58871a29525f973a6cf52734a78acd1d60c8
enriquenc/n-puzzle
/priority_queue.py
498
3.6875
4
import queue total_opened_nodes = 0 class myPriorityQueue(): def __init__(self): self.queue = queue.PriorityQueue() # for checking if the queue is empty def isEmpty(self): return self.queue.empty() # for inserting an element in the queue def push(self, border): global tot...
23adc91217bbba01791dd08cbec49300a9d0e410
bergmacr/it3038c-scripts
/Python/Project3/vars.py
1,982
3.5625
4
import random import math width = 800 height = 600 BG = 255, 255, 255 FOOD_C = 128, 0, 0 BODY_C = 0, 0, 0 sqr_size = 10 SPEED = sqr_size def dist(a, b): return math.sqrt((b.pos[0] - a.pos[0])**2 + (b.pos[1] - a.pos[1])**2) def check_food(snake, food): if dist(snake, food) > sqr_size: return False ...
4534e210a61b538955a871c1827e185b0e41407f
cpudvar/Past-Work-Samples
/PYTHON/8Puzzle Solver/Misplaced Version/MisplacedTile_Main.py
5,871
3.921875
4
""" Programmer: Caleb Pudvar For information & statistics about program, please refer to the readme and accompanying report """ from MisplacedTile_BoardClass import * import queue import time # implemented in Python v3.1.2 #===================================================== def main(): timesTo...
ebc8559e66ef0af1ace4f5b0045dd03f5129a253
sebastian-holguin/hw4
/mandelbrot.py
944
3.703125
4
import numpy as np import matplotlib.pyplot as plt # newaxis lets me go up an axis when dealing with the array # so I don't have to manually change the size depending on n. def mandelbrot(n, N_max, threshold): xmatrix = np.linspace(-2, 1, n) # xmatrix uses linspace to create an array of min = -2, max = 1, o...
01c59f6220e900725af3974ce7563fbe1d1bdf84
Mahrokh-Eb/python-visual-studio-2
/8-list-function.py
479
4.0625
4
#adding one course to list myCourses = ['python', 'kotlin', 'Ionic'] myCourses.append('JQuery') print(myCourses) # adding many different items to list myCourses.extend(['x', 'y']) print(myCourses) # adding item in the middle myCourses.insert(1, 'goli') print(myCourses) # index print(myCourses.index('kotlin')) # r...
029eb992ac06e5dcdca03428ffb905fb7baa626f
Mahrokh-Eb/python-visual-studio-2
/27-thanos-3.py
665
3.75
4
import re # opening sample_tweets file f = open("sample_tweets 2.txt", "r") # print(f.read()) # asking user to enter wanted word wantedWord = input('please enter a word that you are looking for! like Ariana : ') # looking for the wanted word x = re.search( wantedWord, f.read()) print(x) if x: print("YES! We have ...
bfc59d8e54ebf22773bfb70eefd421f515ebcedc
Mahrokh-Eb/python-visual-studio-2
/7-list.py
294
3.96875
4
myColor = ['red', 'pink', 'blue', 'green', 'gray', 'broWn' 'black', 'orange'] for color in myColor: print(f'the color is: {color}') print('==============================================') index = 0 while index < (len(myColor)): print(f'the color is: {myColor[index]}') index += 1
6233e4143e50f6b31db548c860c4bec6a20fe0ce
Mahrokh-Eb/python-visual-studio-2
/15-function2.py
823
3.734375
4
# making parameter of the function Dinamically def parameterDynamic(name, *arg): print(name) total = 0 for i in arg: total += i return total print(parameterDynamic('sum of the numbers: ',1, 1, 1, 1, 1, 1)) # sum of the numbers: 6 print('=========================================================...
6ab51cc0d041141605c185c0ef83384507695e57
LaFeeVert/One-Kata-at-a-time
/factor_test.py
1,461
3.5
4
import factor """Unit tests.""" import unittest class TestPrimeFactorization(unittest.TestCase): def test_factor_zero_return_empty_list(self): self.assertEqual(factor.factor(0), []) def test_factor_one_return_empty_list(self): self.assertEqual(factor.factor(1), []) def test_factor_two_r...
a926cef63dc90a5325a1de43331e4acdedd84ea8
lunar7777/hello_world
/test_joseh_archi/create_gamelist.py
1,783
3.578125
4
from reader import load_data import unittest data_list = load_data() class Individual(object): # 一个人作为一个对象,包含多项信息 def __init__(self, name, sex, age): self.__name = name self.__sex = sex self.__age = age def get_name(self): return self.__name def get_sex(self): re...
d679aec7c8d17107166883d883372349e0615e92
lunar7777/hello_world
/third_work/joseph.py
975
4.03125
4
class Joseph(object): # 创建一个约瑟夫类,包含迭代功能、约瑟夫出站规则 def __init__(self, start_num, step, people_list): self._person = people_list self.start_num = start_num self.step = step def __iter__(self): return self def __next__(self): if len(self._person) > 0: self._...
df1711cca5b4ded9d9d6f64c103f1b850cf74b92
lunar7777/hello_world
/third_work/reader.py
2,199
3.578125
4
class Reader(object): # 创建一个Reader类,包含txt,csv和zip格式文件的读取,并返回所有人员的数据 def read_txt(self, path_t="cast.txt"): # 读取txt文件的数据,并返回一个列表 self.path_txt = path_t with open(self.path_txt, "r", encoding="UTF-8-sig") as f_txt: # 读取人员 cast_lst_txt = list(f_txt) # 名单由txt转为列表 cast_list_txt = ...
b111b372665a3274238fa1d835d7fab51cff2804
lunar7777/hello_world
/test_joseh_archi/joseph_rule.py
1,571
3.828125
4
import unittest class Joseph(object): # 创建一个约瑟夫类,包含迭代功能、约瑟夫出站规则 def __init__(self, start_num, step, gamelist): self._person = gamelist self.start_num = start_num self.step = step def __iter__(self): return self def __next__(self): if len(self._person)>0 and self....
a78136293bdf9478f10ee01297f0bec59423c689
sagnikmitra/vehicle-routing-optimization
/csvgen.py
247
3.53125
4
latup = 11.6204374 lonup = 104.9125845 latdown = 11.621318 londown = 104.923603 lat = latdown - latup lon = londown - lonup print(lat, lon) for i in range(0, 5000): print(f"{latdown+lat},{londown+lon},1") latdown += lat londown += lon
33b72a5aecb0c207dde3032f9dd88ecd793f2901
CalebCSanchez/AdventureTheGame
/Game!.py
13,525
4
4
from GAME import * #Intro def battle(health_player,attack_player, inventory, weapon, lesserhealingpotion, healingpotion, greaterhealingpotion, lessermanapotion, manapotion, greatermanapotion ,magic_player,speed_player, health, attack, magic, name, speed, hits, criticalsaying, critical): x=0 y=0 if speed_pla...
63e222429472203c3d1d203dc302d0eff22d5827
cblume/aoc2018
/day-01/day-01_a.py
176
3.921875
4
#! /usr/bin/env python3 frequency = 0 with open('./input.txt') as frequencies: for freq in frequencies: frequency += int(freq) print("Final frequency:", frequency)
a0e2de613b809e5892fd7ba0a499c47a0c4f8b73
phanny-pack/Drone-Thanggg
/data_logging/camera_recording.py
1,203
3.515625
4
# Note that we will need to install picamera on the Raspberry Pi class camera: def __init__(self, x, y): import picamera # Set up the camera self.x = x self.y = y self.c = picamera.PiCamera() # possibly able to change the framerate at higher resolution: # cam...
bdbbc49d8979589ed92856a6942a266e55918ae6
phanny-pack/Drone-Thanggg
/drone-control-simulation/chap4/wind_simulation.py
2,694
3.5
4
""" Class to determine wind velocity at any given moment, calculates a steady wind speed and uses a stochastic process to represent wind gusts. (Follows section 4.4 in uav book) """ import sys sys.path.append('..') import numpy as np import parameters.simulation_parameters as SIM class wind_simulation: def __init_...
885cc72deaa1dccc97a258f41ebe487aeeaa9f23
mr-shubhamsinghal/DSA
/stack/q2_reverse_string.py
621
4.1875
4
""" Reverse a String using Stack """ def create_stack(): stack = [] return stack def size(stack): return len(stack) def isEmpty(stack): return size(stack) == 0 def push(stack, item): stack.append(item) def pop(stack): if isEmpty(stack): return return stack.pop() def reverse_string(str...
29afe3d4214292beb5b2a759f4fddcb337e0f619
TanayKapoor/PythonCodes
/linkedlist.py
712
3.796875
4
import data as data class Node: def __init__(self,data): self.data = data self.next = None class Solution: def display(self,head): current = head while current: print(current.data,end=' ') current = current.next def insert(self,head,data): n...
1cdce5e348981ffe3accbe47bdf571c0dfa9c090
jinjuseo/py_lab
/aver_num.py
237
4.09375
4
#!/usr/bin/python import sys if __name__=='__main__': n = int(input("How many numbers will you add? ")) sum = 0 for i in range(0,n) : num = int(input("input: ")) sum += num; average = sum/n print("average is %d " % average)
5b46fa2b595aedd8fd893880bc79dc6f5b2ab359
shotz19/Code
/recursionpractice.py
510
3.609375
4
'''import sys number=int(sys.argv[1]) def factorial(n): if n==0: return 1 return n*factorial(n-1) #answer=factorial(number) letters="dhuascilx" def count(x): answer=0 if x[len(x)-1]=="x": del x[len(x)-1] return count(x-1) answer=count(letters) print(letters) numbers=9037568 def count(x): if x[x] return co...
af125da25b6efca5bf385e66589e47f1229ef462
shotz19/Code
/elements.py
954
3.515625
4
#https://stackoverflow.com/questions/18412179/reading-a-file-and-storing-values-into-variables-in-python import sys import re from element import Element class PeriodicTable: def __init__ (self, pfile): self.allelements = {} file = open('elements.csv') for line in file: part = line.split(',') oneelement ...
39961320f70b05e1b44ce2181c475de55be2e16c
shotz19/Code
/challenge3.py
325
3.953125
4
#Generate a list of 10 random numbers between 0 and 100. Get them inorder from largest to smallest, removing numbers divisible by 3. import random g=[] for x in range(10): a=random.randint(1,100) e=True while e==True: if a%3==0: a=random.randint(1,100) else: e=False g.append(a) pri...
efa6adccf9c621190bc3ae1221e465cc6352e9e6
shotz19/Code
/Converter.py
60
3.578125
4
dollars= input("Dollars to yen:") dollars*110=yen print(yen)
2acdde13bf78ad2dd645cb85a371a219f8cdd0c6
shotz19/Code
/adventuregame.py
5,282
3.765625
4
#stephanie Hotz adventure text based game 9-24-18 # This is a text based adventure game where the user is asked to make decisions and play mini games. import random #each def is a different part of the game #Here, the user goes to a town then continues on the journey. def town(): print("You go into a town and see an i...
0a963e20d4d981e12031703fce69e62826616216
rafatmunshi/Data-Structures-Algorithms-using-Python
/MinHeap.py
2,553
3.8125
4
import sys class MinHeap: def __init__(self, maxsize): self.maxsize = maxsize self.size = 0 self.Heap = [0] * (self.maxsize + 1) self.Heap[0] = -1 * sys.maxsize self.front = 1 def buildheap(self): n = self.size for posn in range(n // 2, 0, ...
94ffc7ab3a670efd5b40d4a37ebe7a5f790c521c
rafatmunshi/Data-Structures-Algorithms-using-Python
/LinearSearch.py
194
3.890625
4
def linearsearch(arr, key): for i in range(len(arr)): if arr[i] == key: return i return -1 arr = [3, 6, 98, 23, 45, 8, 24, 9] print(linearsearch(arr, 96))
4174fe9fb169f1d87f7dd71ca4f255a9adc21c20
rafatmunshi/Data-Structures-Algorithms-using-Python
/BinaryTree.py
2,909
3.8125
4
class Node: def __init__(self, key): self.left = None self.right = None self.key = key def preordertraversal(self): print(self.key, end=' ') if self.left: self.left.preordertraversal() if self.right: self.right.preordertraversal...
633f8af85afccc79987be7e8a642995732ff0c74
alli959/Kattis
/I Hate The Number Nine/nine.py
232
3.53125
4
import sys import math largest = (10**9) + 7 length = int(sys.stdin.readline().strip()) for i in range(length): size = int(sys.stdin.readline().strip()) - 1 value = 8 * pow(9,size,largest) print(value%largest)
a5b3731fa7555c2dea48232748a008833d1ec1f7
yalvernoz/USPCodeLabLeste_Python
/Desafios URI/1040.py
669
3.5625
4
a, b, c, d = input().split() pA = 2 pB = 3 pC = 4 pD = 1 media = (float(a)*pA + float(b)*pB + float(c)*pC + float(d)*pD) / (pA + pB + pC + pD) mediaFormatada = float(format(media,".1f")) print("Media:", mediaFormatada) if mediaFormatada >= 7: print("Aluno aprovado.") elif mediaFormatada < 5: print("Aluno rep...
b2491493f4fdfa4e981088142bfd0c78eee82281
vicvv/python_scripts
/SensorsTogleAndStats.py
13,408
4.09375
4
""" Program prints out menu options and takes an input from user. Based on the user input program calculates the statistics for temperature sensors and output the results to user. The input file is file.csv """ import os import math def recurciveSort(list_to_sort, key=0): for i in range(0, len(list_to_sort) - 1):...
530fcdb82c00396f31ec3e2f5c0812fa378a83c1
Iskanderka/PythonLearning
/InOut.py
2,572
3.8125
4
# def cleaning(text): # textlist = list(text) # for sign in [" ", ".", ",", "!", "?", ":", ";", "(", ")", "...", "-", "'", "\""]: # if sign in textlist: # for number in range(0, textlist.count(sign)): # textlist.remove(sign) # # cleantext = "".join(textlist).lower() # lo...
eb4a92c7c2463805dc7ed7ad423e45fe477c3925
Iskanderka/PythonLearning
/Algorithms.py
2,430
3.90625
4
# # sort # # # def insert_sort(a): # """Сортировка списка A вставками""" # n = len(a) # for top in range(1, n): # k = top # while k > 0 and a[k - 1] > a[k]: # a[k], a[k - 1] = a[k - 1], a[k] # k -= 1 # # # def choise_sort(a): # """Сортировка списка A выбором""" # ...
600f373281ff4766716579cc0a88622e6a52de71
Shubham529/Predicting-Heart-Diseases
/HDP_2 .py
11,352
3.59375
4
#!/usr/bin/env python # coding: utf-8 # # Heart disease prediction # In[20]: # import the basic packages import numpy as np import pandas as pd import matplotlib.pyplot as plt from matplotlib import rcParams get_ipython().run_line_magic('matplotlib', 'inline') from sklearn.preprocessing import LabelEncoder import...
5a3940765e634ebbda22ece1e2419e2206c25fbe
KaliKaloo/google-Youtube-Challenge
/src/video_player.py
11,235
3.71875
4
"""A video player class.""" from hashlib import new from .video_library import VideoLibrary from .video_playlist import Playlist import random class VideoPlayer: """A class used to represent a Video Player.""" def __init__(self): self._video_library = VideoLibrary() self.current_video_id = " "...
bbb267e46314f84d821f8c1875b2b94a4c3bcb58
PerezJjagwe/Non-repetition-counter
/non repeated alphanumerics.py
681
3.984375
4
letters = "abcdefghijklmnopqrstuvwxyz" numbers = '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' welcome = input("Welcome, may i please have your name? :" ) phrase = input("Excuse me, " + str(welcome) + " , please type the word/phrase/number here :") for letter in letters: count = phrase.count(letter) if coun...
cc711df18a4cccdc2d2f7d11793e281c4e2167f7
krunopz/password-generator
/main.py
1,419
3.703125
4
#Password Generator Project import random letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] numbers...
359af566c6646d594c7c8368ff570be8e921cac2
EvaXue/Algorithm_practice
/Valid_Palindrom.py
891
3.953125
4
##lintcode 415. Valid Palindrome class Solution: """ @param s: A string @return: Whether the string is a valid palindrome """ def isPalindrome(self, s): # write your code here ##consider the null value if s is None or len(s) == 0: return True l = 0 ...
041fe5bb4985c6be0f24d56faa47683e5bf758c9
15137359541/Tornado
/mysite_框架/mysite/models.py
1,564
3.546875
4
""" 确定使用什么ORM操作 pymysql? sqlalchemy? + pymysql pymysql.install_as_MySQLdb() > 目的:为了了解框架底层的东西,尝试自己开发一个完整的ORM操作模块,欢迎使用pymysql > 目的:为了项目[高效]开发,欢迎使用成熟的框架,如sqlalchemy """ from sqlalchemy import Column,String,Integer,create_engine,and_,Text from sqlalchemy.orm import sessionmaker from sqlalchemy.ext...
8f1fea44d7a92db4fc90114ad746eae03efbc651
pickwick-rudge/Practice-Python-Exercise-Solutions---Work-in-Progress
/15 Reverse Word Order.py
1,245
4.28125
4
'''Write a program (using functions!) that asks the user for a long string containing multiple words. Print back to the user the same string, except with the words in backwards order. For example, say I type the string: My name is Michele Then I would see the string: Michele is name My shown back to m...
7f313dfe9b2083b0b633dd11d3fa9827cc68a0cb
pickwick-rudge/Practice-Python-Exercise-Solutions---Work-in-Progress
/12 List Ends.py
623
4.21875
4
'''Exercise 12: List Ends''' '''Write a program that takes a list of numbers (for example, a = [5, 10, 15, 20, 25]) and makes a new list of only the first and last elements of the given list. For practice, write this code inside a function.''' import random def list_begins_and_ends(a): #Returns index ze...
c965a5d698fceebec67b9b611e4688d510eab352
ayosol/python_learn
/emoji_art.py
665
4.03125
4
#Using while loop num = 1 while num < 11: print("\U0001f600" * num) #print("#" * num) num = num + 1 #Using for loop for num in range(1, 11): print("\U0001f600" * num) #print("#" * num) #Using nested loops instead of string multiplication... for num in range(1, 11): count = 1 hasht = "" ...
0e2774bd9519ec550178b9701ade1bdf975c22f3
KhadeejathulHumaira/Python-Internship
/Tasks/Day6.py
2,547
4.25
4
#Todays Task #Day 6 #1)Add 2 to each element in the list list1=[1,2,3,4,5] list2=[] for i in list1: a=i+2 # 2 is added to each element in the list list2.append(a) print(list2) #2)Pattern for i in range(5,0,-1): print("".join(format(j) for j in range(i,0,-1))) #3)Fibonacci Sequence def fibonacci(a...
803de2cc41b9b9a8ee5c01dff2514043d89418f3
highshoe/PYTHON
/python-19-exercise13/src/exercise05-06.py
1,326
3.859375
4
''' Created on 2009-10-4 @author: selfimpr ''' import math class Point(object): def __init__(self, x = 0, y = 0): self.x = x self.y = y def __str__(self): return 'x: %s, y: %s.' % (self.x, self.y) def __repr__(self): return '(%s, %s)' % (self.x, self.y) class Line(object):...
e9f1264bf805b4aa8da74698d1829043ae88c135
highshoe/PYTHON
/python-02-exercise2/src/exercise06.py
454
4.125
4
''' Created on 2009-9-1 @author: selfimpr ''' input = raw_input("Enter a number or exit:\n") while(input != 'exit'): try: num = int(input) except ValueError, e: print "Format your input string to a number error:", e if num < 0: print 'Your number is a negative' elif num == 0: ...
1dabdcb6828b14d3105acd2f555ca956c089365d
highshoe/PYTHON
/python-08-exercise6/src/exercise11.py
309
3.734375
4
''' Created on 2009-9-9 @author: selfimpr ''' first = raw_input("enter first:\n") second = raw_input("enter second:\n") third = raw_input("enter third:\n") forth = raw_input("enter forth:\n") print first + "." + second + "." + third + "." + forth s = raw_input("enter a ip address: \n") print s.split(".")
0dcac75f5d9fa5e1fb68bb5d667d590ed16842d7
toddyamakawa/microbit
/micropython/raindrops.py
523
3.578125
4
#!/usr/bin/python from microbit import * from random import * def array2string(array): return ':'.join(''.join(str(cell) for cell in row) for row in array) def drop(array): new_array = array[0:-1] new_row = [value-5 if value-5>0 else 0 for value in array[0]] new_row[randint(0,4)] = randint(0,9) new_array.insert(...
7178331b2e4665eb202ad72c92638176802bf3aa
kevjiang/couscous
/menu_scraper.py
621
3.640625
4
from bs4 import BeautifulSoup import urllib2 needle = "chicken" found_needle = False r = urllib2.urlopen('http://phillipsacademy.campusdish.com/Commerce/Catalog/Menus.aspx?LocationId=4236&PeriodId=2056&MenuDate=2016-07-06&UIBuildDateFrom=2016-07-06').read() soup = BeautifulSoup(r) menu_item_tags = soup.find_all("spa...
c238e437d3a8130ad5be0fcd641436bba1a20700
nayakshweta/familytree
/tests/test_family.py
3,015
3.515625
4
from unittest import TestCase from person import Person from family import Family class TestFamily(TestCase): def test_family_init(self): husband = Person('Evan', 'Male') wife = Person('Diana', 'Female') family = Family(husband, wife) assert family.husband.name == 'Evan' ...
f58ab8ca8b228549d83c3cd575b96730a7ae78f0
rkdms0116/SWEA
/SW1986_지그재그_숫자_D2/SW1986.py
508
3.59375
4
# 내 머리가 고생 Test_Case = int(input()) for i in range(Test_Case): Test_Num = int(input()) if Test_Num%2: result = int((Test_Num+1)/2) else: result = int(-Test_Num/2) print(f'#{i+1} {result}') # 컴퓨터가 고생 Test_Case = int(input()) for i in range(Test_Case): Test_Num = int(input()) resu...
e2b34b3298fc2a48374f04c899c886e40d232eda
Braamling/information-retrieval
/assignment1/hw1.py
5,509
3.78125
4
import itertools import math import matplotlib.pyplot as plt import numpy as np def retrieve_pairs(): return [(x[:5], x[5:]) for x in itertools.product((0, 1, 2), repeat=10)] # This function returns an iterator which returns a unique ranking of P and E for each iteration def retrieve_pair(): for x in itertool...
3c64cf5099d4af75337ca27208f58d986584726a
rpatelk/SimpleLibrary
/BookTest.py
3,195
3.921875
4
import unittest from Book import Book # Test class for Book class # @author Raj Patel class BookTest(unittest.TestCase): # Tests the methods associated with name. def test_name(self): b = Book("Hatchet", "Gary Paulsen", "Survival, Fiction", "61743") # Passing Test self.assertEqual(b....
4e9b117f93ce8011ac21cf660d80aef3e3e6163c
supersj/LeetCode
/289. Game of Life.py
2,594
3.671875
4
import copy class Solution(object): def gameOfLife(self, board): """ :type board: List[List[int]] :rtype: void Do not return anything, modify board in-place instead. """ tmpboard = copy.deepcopy(board) row = len(tmpboard) col = 0 if row > 0: ...
d0cb703cb2f1a447bb6df63d4f258d52d24fd2ba
supersj/LeetCode
/135. Candy.py
981
3.5625
4
# There are N children standing in a line. Each child is assigned a rating value. # # You are giving candies to these children subjected to the following requirements: # # Each child must have at least one candy. # Children with a higher rating get more candies than their neighbors. # What is the minimum candies ...
4cf2a8b84c3cdd0ebae529ac5397255b44f2e9ee
supersj/LeetCode
/406. Queue Reconstruction by Height.py
1,520
3.546875
4
from operator import itemgetter # todo insert order thinking class Solution1(object): def reconstructQueue(self, people): """ :type people: List[List[int]] :rtype: List[List[int]] """ people.sort(key = itemgetter(1,0)) result = [] start = 0 ...
4c0bb07d69da3a5ca68adbb8fece0113f6a2f9ec
supersj/LeetCode
/171. Excel Sheet Column Number.py
725
3.765625
4
# Related to question Excel Sheet Column Title # # Given a column title as appear in an Excel sheet, return its corresponding column number. # # For example: # # A -> 1 # B -> 2 # C -> 3 # ... # Z -> 26 # AA -> 27 # AB -> 28 # Credits: # Special thanks to @ts for adding this pr...
073b906ede6e58157c1fe1e1bbee9350224fac3d
supersj/LeetCode
/84. Largest Rectangle in Histogram.py
913
3.703125
4
# For example, # Given heights = [2,1,5,6,2,3], # return 10. class Solution(object): def largestRectangleArea(self, heights): """ :type heights: List[int] :rtype: int """ stack = [] maxArea = 0 heights.append(0) zeroindex = 0 for i...
c632ce69448b2a8aeed426df44aeb0d96e75e1c9
supersj/LeetCode
/504. Base 7.py
495
3.5625
4
class Solution(object): def convertTo7(self, num): """ :type num: int :rtype: str """ if num == 0: return '0' result = "" ispositive = 1 if num < 0: ispositive = -1 num = abs(num) while num != 0: ...
68363c9dc9380782da75ca43f39db298b1181a68
supersj/LeetCode
/241. Different Ways to Add Parentheses.py
1,560
3.59375
4
class Solution(object): def diffWaysToCompute(self, input): """ :type input: str :rtype: List[int] """ def diffHelp(operand,operator): result = [] if not operator: return operand for i in range(len(operator)): ...
0c6444de762e36103ffe34bea74ae182da3d9d99
supersj/LeetCode
/142. Linked List Cycle II.py
3,301
3.8125
4
# Given a linked list, return the node where the cycle begins. If there is no cycle, return null. # # Note: Do not modify the linked list. # # Follow up: # Can you solve it without using extra space? # # Subscribe to see which companies asked this question # Definition for singly-linked list. class ListNode(ob...
4f75dcc8d08cf8fe2064de3e2088522ef4ad6ec7
supersj/LeetCode
/214. Shortest Palindrome.py
677
3.59375
4
class Solution(object): def shortestPalindrome(self, s): """ :type s: str :rtype: str """ def makeNext(p): q = 0 k = 0 m = len(p) next = [0 for i in range(m)] for q in range(1, m): while k...
129fc9beae957f42046987de3798cc109fe3eeb2
supersj/LeetCode
/200. Number of Islands.py
3,663
3.90625
4
# Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water. # # Example 1: # # 11110 # 11010 # 11000 # 00000 # An...
ea426a4d87e220d33337544278ac86d734536472
supersj/LeetCode
/118. Pascal's Triangle.py
716
4
4
# Given numRows, generate the first numRows of Pascal's triangle. # # For example, given numRows = 5, # Return # # [ # [1], # [1,1], # [1,2,1], # [1,3,3,1], # [1,4,6,4,1] # ] # Subscribe to see which companies asked this question class Solution(object): def generate(self, numRows): ...
34e5501c7bf67d763c4cd55d0fb44754f3fb05e1
AnastasiiaNabok/Python
/ElementaryTasks/chessboard/chessboard.py
1,326
3.859375
4
class ChessBoard: def __init__(self, width, height): self.width = self.validate_input(width) self.height = self.validate_input(height) def __str__(self): return self.create_board() @staticmethod def validate_input(input_value): if input_value > 0: val = int(...
091dcebd0e2245013f57ac9b44937812872b8347
seeslab/kaggle_kdd
/Roger/alignment.py
861
3.671875
4
from Bio.pairwise2 import align # ----------------------------------------------------------------------------- # Given two strings, return the score of the alignment. The score is # the ratio between the number of matched letters and the total length # of the alignment. Case, hyphens, and spaces are ignored in the #...
fe0f08df9e9853bfb2f1900a12cdeca0bf937ab0
Jak1022/FSU-BCH5884-Fall2020
/20nov05/fib.py
253
4.375
4
#!/usr/bin/env python3 # return the nth element of the fibonacci sequence def fibonacci(n): # return the nth element of the fibonacci sequence skipping 0 and 1 if n < 2: return 1 else: return fibonacci(n-1)+fibonacci(n-2) print(fibonacci(3))
0c7a2257fc21cfc5df1c39d561386ca34ec26d9b
Jak1022/FSU-BCH5884-Fall2020
/20sep22/futuretime.py
389
3.90625
4
#!/usr/bin/env python3 import sys print("here") sys.exit() now=int(input("Please enter a time in 24-hour format: ")) hoursahead=int(input("Please enter some number of hours in the future: ")) then24=(now+hoursahead%24)%24 then12=then24%12 daysahead=hoursahead//24 print("The new time in 24-hour format is", then24,...