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
0f08367fb9ef159c3c6bd6713c70002a90842539
Yasothakandasamy/python-programming
/player level/eligible for voting.py
106
3.546875
4
a=23 if(a>20): print("the age is eligible for voting") else: print("the age is not eligibe for voting")
99352a2ead5e9c8979eb9129ec1d64e2e4403fb6
Yasothakandasamy/python-programming
/beginner level/print nearest even number.py
71
3.65625
4
a=int(raw_input()) b=a-1 if(b%2==0): print(b) else: print(a)
896535feedaebe877826b43521c154c87a7e73e1
snegyeliczky/Python
/pythonideas4.py
1,627
3.828125
4
def file_reader (file_name): with open(file_name,"r") as file_for_read: file_container = [] for lines in file_for_read: #lines = file_for_read.readline() lines_for_clean = (str(len(file_container)+1)+": "+lines) print(lines_for_clean) clean_lines =...
9c45a835d725e566226206db816b51f4b16bc615
snegyeliczky/Python
/pythonTuples.py
159
3.5625
4
#Tuples never gona change and thets the diferent between lists# cordinats = (2, 4) listOfCordinates = [(3,5),(2,5),(7,10),cordinats] print(listOfCordinates)
3eb17e29136fc1219f84f6fbddeb7d49d8883749
YeahLi/PythonCookbook
/multiprocess_copy.py
866
3.578125
4
''' 1. Define copy size per time. 2. Generate a process pool 3. Define a copy function, copy 2M. 4. start processes to execute the copy function ''' from multiprocessing import Pool import time process_num=5 copy_unit=20 pos=0 def test(file_path, new_file_path,pos): try: with open(file_path, "r") as file: file...
955de51d6d0c99f68f58fe3e6c9c13d693802513
YeahLi/PythonCookbook
/myExercise/老王开枪/2_设计类并创建对象.py
1,012
3.734375
4
class Person(object): """docstring for Person""" def __init__(self, name): super(Person, self).__init__() self.name = name class Gun(object): """docstring for Gun""" def __init__(self, model): super(Gun, self).__init__() self.model = model class Charger(object): """docstring for Chager""" def __init__...
adfc59f608a1f95fbcc31707990e25337311b68b
YeahLi/PythonCookbook
/CreateProcess.py
1,935
4
4
#Method 1: from multiprocessing import Process def test(): while True: print("----test----") time.sleep(1) p = Process(target=test) p.start() Process() #Method 2: from multiprocessing import Process import time class MyNewProcess(Process): """docstring for MyNewProcess""" def __init__(self): s...
66e69e2d870a7e65206d396c375c3e496524cd3d
YeahLi/PythonCookbook
/if_in_verify.py
698
3.8125
4
#test if an instance can use if is in class User(object): """docstring for User""" def __init__(self, name): super(User, self).__init__() self.name = name user1 = User("haha") user2 = User("heihei") l = [user1, user2] user3 = User("heihei") print("user %s with id %d" %(user2.name,id(user2))) print("user %s wi...
561732cb8ca38a173ca1cf34d748a3fddd95e85c
tianhongfeng/Lab_learn
/test_lab/test_lab_1.1.py
19,043
3.984375
4
import random import math # 初级 1.1 # 随机生成N个数的list def random_list(n): # 生成一个空的 list nn = [] for i in range(n): # 生成 100 以内的随机数 cc = random.randrange(100) nn.append(cc) return nn # 1.输入整数N,随机生成N个数的list,写一个函数,返回list中最大的数 def function1(n): # 调用方法 生成n个数的list nn = functi...
c7e8eb405936e8a3abfc69068c6946a6489ee5ac
Rajeshkumark26/Algorithms_coding_practice
/isZeroSum.py
273
3.65625
4
array=[-3,4,-3,-1,1] def isZeroSum(array): preSum=0 h=set() for i in range(len(array)): preSum += array[i] if preSum == 0 or preSum in h: return True else: h.add(preSum) return False isZeroSum(array)
a93541ce64053b6fc54e94faf3f2c1d2cc413043
Rajeshkumark26/Algorithms_coding_practice
/moveElementToEnd.py
305
3.625
4
""" array =[2, 1, 2, 2, 2, 3, 4, 2] toMove = 2 output = [4, 1, 3, 2, 2, 2, 2, 2] """ def moveElementToEnd(array, toMove): i=0 j=len(array) - 1 while i < j: while i < j and array[j] == toMove: j -= 1 if array[i] == toMove: array[i],array[j] = array[j],array[i] i += 1 return array
f91de09dde390980a88c6a46bdf84de4fc098823
Rajeshkumark26/Algorithms_coding_practice
/isMonotonic.py
338
3.90625
4
""" input array : [-1, -5, -10, -1100, -1100, -1101, -1102, -9001] output : """ def isMonotonic(array): isNonDecreasing=True isNonIncreasing=True for i in range(1,len(array)): if array[i] > array[i-1]: isNonIncreasing = False if array[i] < array[i-1]: isNonDecreasing = False return isNonDecreasing or...
865b92a4f6b955ae4b512bb27c2f8708d7894cdd
anguss-li/exercism-python
/grade-school/grade_school.py
740
3.734375
4
class School: def __init__(self): """Store the names and grades of school students.""" self.students = {} def add_student(self, name: str, grade: int) -> None: """Add a student to a grade in the roster.""" school_grade = self.students.setdefault(grade, []) school_grade.a...
87cb99cfffeba575365c48a0fbe12d365a49b7a8
anguss-li/exercism-python
/series/series.py
341
3.546875
4
from typing import List def slices(series: str, length: int) -> List[str]: '''Slice series of digits into subsections of set length''' if length > (digits := len(series)) or length < 1: raise ValueError(f'Cannot slice {digits} digits using {length} length') return [series[i:i+length] for i in ran...
0abdc910d90f44928f950eb06b79b3dc362a74e6
anguss-li/exercism-python
/raindrops/raindrops.py
318
3.625
4
FACTORS = [(3, 'Pling'), (5, 'Plang'), (7, 'Plong')] def convert(number: int) -> str: '''Convert number into raindrop sounds.''' converted = ''.join(factor[1] for factor in FACTORS if number % factor[0] == 0) return converted if converted else str(number)
4b05922c0f4cdcc081b7763323f585396bf2e76d
anguss-li/exercism-python
/allergies/allergies.py
1,000
4.0625
4
from dataclasses import dataclass from typing import List ALLERGENS = { 'eggs': 1, 'peanuts': 2, 'shellfish': 4, 'strawberries': 8, 'tomatoes': 16, 'chocolate': 32, 'pollen': 64, 'cats': 128 } @dataclass class Allergies: '''Record items that an individual is allergic to from aller...
7c303d25a8d442b3db3554f8a73ca71fdeb9e539
anguss-li/exercism-python
/word-count/word_count.py
269
4
4
from collections import Counter from re import findall from typing import Dict def count_words(sentence: str) -> Dict[str, int]: '''Return all words in sentence as well as their frequency''' return Counter(findall(r"[a-z0-9]+(?:'[a-z]+)?", sentence.lower()))
1711e785ce65b69afce4baf3341c63fc3faa8a27
anguss-li/exercism-python
/wordy/wordy.py
1,074
3.90625
4
from operator import add, floordiv, mul, sub from re import split OPERATIONS = { 'plus': add, 'minus': sub, 'multiplied by': mul, 'divided by': floordiv } def answer(question: str) -> int: """Calculate the answer to a simple maths word problem.""" phrases = split(r' (?!\bby\b)', question.repl...
623a4267b790297e855d028244fddad4dcd256bf
davyzor/tools_for_big_data
/script1.py
822
4.0625
4
"""Write a script which reads a matrix from a file like this one and solves the linear matrix equation Ax=b where b is the last column of the input-matrix and A is the other columns. """ import numpy as np def from_file_to_matrix(filename): matrix = [] array = [] with open(filename) as f: for line in f: dat...
c082771b2d0637c7900797b748bdef75490e16b1
ErsanSam/NIOMIC_intermediate_python
/8. While loops.py
171
3.5625
4
angka = 50 while angka > 1: angka = angka / 4 print(angka) print("__________") bilangan = 0 while bilangan < 10: bilangan = bilangan + 0.73 print(bilangan)
fd865cf3eaa4ff7ec6cff386650dfce85ed03b64
laixintao/NLP-with-python-demo-code
/5.Categorizing-and-Tagging-Words/5.1-POS-tagger.py
309
3.515625
4
import nltk text=nltk.word_tokenize("And now for something completely different") print nltk.pos_tag(text) # find similar word text = nltk.Text(word.lower() for word in nltk.corpus.brown.words()) print text.similar("woman") print text.similar("bought") print text.similar("over") print text.similar('the')
321abe804a7ce7b47ee132886559168e3b52d640
wojlas/Guess-the-number
/guess_the_number.py
909
4.1875
4
import random def guess_the_number(): try: """function checks if the given number is equal to the drawn number and displays an appropriate message""" user_number = int(input("Guess the number: ")) index = 0 while user_number != random_number: if user_number < ra...
26e3644b25ec9a1494e65611f26c8517b8d3cfd9
ayoskovich/notes
/src/generators.py
801
3.984375
4
#!/usr/bin/env python # coding: utf-8 # ## Generators # # Generator functions allow for us to define functions that behave like iterators. I can use this thing in a for loop. # In[1]: x = !dir # In[1]: import time def timeit(func): def wrapper(*args, **kwargs): t1 = time.time() rv = func(*a...
0e250418e3a7590856f8a072d8379f391fd430a3
ArqumUsmani/AI_Assign1_Q2_codes
/DFS.py
1,525
3.84375
4
# we have implement an adjacency list which stores each node in a dictionary along with a set containing their adjacent nodes. # As the graph is undirected each edge is stored in both incident nodes adjacent sets. graph = {'A': set(['B', 'C']), 'B': set(['A', 'D', 'E']), 'C': set(['A', 'F']), ...
e8e50cf7baf69268f03e5d66f352ecf3ab894d5f
Hellrungj/CSC-386-Computational-Complexity
/Labs/Hellrungj-Praters-L4/Tree.py
912
3.9375
4
#John Hellrung & Shadia Prater # A8/L4 # CSC 386 # simple binary tree # in this implementation, a node is inserted between an existing node and the root # http://stackoverflow.com/questions/2598437/how-to-implement-a-binary-tree-in-python def add(node, v): new = [v, [], []] if node: left, right = node...
6aa34779b911b93a6ad57d840409df0313ccbcdf
bestzye/PyLadies-ukoly
/ukol13.py
181
3.828125
4
for radek in range (1,7): if radek == 1 or radek == 6: for znamenko in range (6): print ("X", end="") else: print ("X X", end="") print()
8d5c9083689d5bfc6403a23e8adc8bff8ddd3a4d
tonyhan18/CSE2003_Exercise
/ex10-2/L182204_실습10_1.py
550
3.53125
4
# title : 실습 10B 1번(16p) # Develop by : 20182204 한찬희 # Date : 2021-05-26 # Prime number test (소수 확인 프로그램), fill the blank def chk() : if (N < 2): return (False) if(N == 2 or N == 3): return (True) if(N % 2 == 0 or N % 3 == 0): return (False) for i in range(5, int((N**(1/2))) + 1, 6): if(N % i...
26db1bd58521f2238bbd125f5f9b0214c2c58c4f
xCaioP/show-do-milhao
/main.py
2,250
3.6875
4
""" Desenvolvido por Caio Ponte """ import functions saldo_jogador = 0 functions.introducao() functions.explicacao() for indice, dado in enumerate(functions.dados): if indice != 0: functions.mostrar_valor_parar(saldo_jogador) functions.mostrar_valor_proxima_pergunta(dado["valor_acertar"]) ...
9fc123830e1c589c9b78f43c7824992f070f1e39
henryadams/Charleston-TDA-ML
/persistent-homology/sphere_points.py
741
3.71875
4
#!/bin/env python # # A script to sample points uniformly at random from the unit sphere # # Author: Henry Adams import sys import numpy as np import argparse import matplotlib.pyplot as plt def main(npoints=500, ndim=3): descriptor = "Sample points uniformly at random from the unit sphere" # Sample vectors...
d6e20c093051fe5ac950b981c51c3765300f2684
robertcinciuc/HackerRank
/QueensAttack2/queensAttack2.py
2,916
3.65625
4
#!/bin/python3 import math import os import random import re import sys from collections import defaultdict # Complete the queensAttack function below. def queensAttack(n, k, r_q, c_q, obstacles): obsDict = defaultdict(list) res = 0 # Put obstacles into a default dictionary : key = row; value = list...
030708f373cae5a147a148f7444664f9009b25c3
Bodhinaut/PyMOTW-3
/capwards_fun.py
292
4
4
# string_capwords.py import string s = 'The quick brown fox jumped over the lazy dog.' print(s) print(string.capwords(s)) """ The results are the same as those obtained by calling split(), capitalizing the words in the resulting list, and then calling join() to combine the results. """
cb8bcf98e69ef88a62c15d3fcde4c01df4bb3851
zenniferp/melon-delivery-report
/produce_summary.py
518
3.625
4
def print_report(day, file_name): print("Day", day) the_file = open(file_name) #open Day's file for line in the_file: #go through every line in file line = line.rstrip() words = line.split('|') melon, count, amount = words print("Delivered {} {}s for total of ${}".format( ...
9a5d618cf7c56504352e85922ec1c57c81146dc7
mehak5868/Training
/venv/Session1A.py
573
3.6875
4
#multi value container #tuple b=10,20,30,40 # homogeneous d=10,20,30,40 print(b) print(d) print("hash code of b" , id(b)) print(" type of b" , type(b)) print("hash code of d" , id(d)) print("type of d" , type(d)) c=10 ,'helloo',2.3,5 #homogeneous print(c ,type(c)) #list b=[10,20,30,40] print(b) print(" type of b" , ty...
3319fab861ae762a0c1673a2b0f26699244b2b82
mehak5868/Training
/venv/Session23.py
223
3.8125
4
import numpy as np arr =np.array(([[1,2,3],[4,5,6],[7,6,9]])) print(arr) print(arr.shape) print("<<<<<<<<<<<<<<<") print(arr[0:2]) print("<<<<<<<<<<<<<<<") print (arr[0:2, 0:2]) print("<<<<<<<<<<<<<<<") print(arr[0:3,0:3])
1c2339d4ef80b0be4cac4b43659153e96581b23b
mehak5868/Training
/venv/Session6As.py
212
3.703125
4
a=1 b=0 def brick(num): global a if a<=num: for i in range (1,num): b=b+i if b <= num : for c in range (2*i , i): b=c brick(13)
91145102aff22b5e73f263d525bf4bd539fd8a0b
Jolene817/grady
/grades.py
682
3.859375
4
# read in grades.txt # print out a list of students # and their avg grade for class # and rank them in order # from high to low # i.e., bob 98, sue 97, sara 76 from collections import defaultdict def get_grades(fn): grades = defaultdict(list) with open(fn) as f: for line in f: name, grade ...
25c8421d7b7377897c2b7b1eabb7d92cd81e2785
Brandonops/python-rpg-game
/main.py
1,271
3.84375
4
from hero import Hero from goblin import Goblin from zombie import Zombie """ In this simple RPG game, the hero fights the goblin. He has the options to: 1. fight goblin 2. do nothing - in which case the goblin will attack him anyway 3. flee """ def main(): my_hero = Hero() goblin = Goblin() zombie = Zo...
f79af021a9c28f27a0415801e1fc18cb665e973f
vydg5/Pythone_exercises
/finobacci.py
363
4.0625
4
# -*- coding: utf-8 -*- """ Created on Mon Feb 29 23:14:52 2016 @author: virea_000 """ def fibonacci(number): b = [1 for i in range (0,number)] for i in range(2,number): b[i] = b[i-1]+b[i-2] print(b[i-2]) return print("Here is your Fibonacci list: " + str(b)) a = int(input("How m...
bc92fd5481137b313ee2e75b77cd282d9a1775df
vydg5/Pythone_exercises
/divisors.py
216
3.890625
4
# -*- coding: utf-8 -*- """ Created on Wed Feb 24 11:55:26 2016 @author: Vireak """ num = int(input("Enter a number: ")) [print(str(i) + " is a divisor") if (num%i) == 0 else 0 for i in range(1, int(num/2 + 1))]
ef81ae33a3864234b0133814368ee72c549851aa
daikidev111/HashTable_dictionary
/frequency.py
8,734
3.921875
4
from hash_table import LinearProbeHashTable from dictionary import Dictionary from list_adt import ArrayList from enum import Enum from typing import Tuple, List import random from string import punctuation import sys class Rarity(Enum): """ A Subclass of Enum is Rarity class that contains Enum member values....
f88c54a37952128e3c2ff80691b9b0c7472ad66e
wjddn1892/PycharmProjects
/MyProject/python_basic/9_class/1_class.py
637
3.5625
4
class Unit: def __init__(self, name, hp, damage): # __init__ : 생성자 self.name = name self.hp = hp self.damage = damage print("{} 유닛이 생성되었습니다.".format(self.name)) print("체력 {}, 공격력 {}".format(self.hp, self.damage)) marine1 = Unit("마린", 40, 5) marine2 = Unit("마린", 40, 5) tank...
d25c3534d46daa45ceea1cd418c5c66c3b9c802a
wjddn1892/PycharmProjects
/MyProject/python_basic/12_quiz/level4.py
376
3.71875
4
import random words = ["apple", "banana", "orange", "melon", "pineapple"] alphabet_lst = [] answer_lst = [] random_word = words[random.randint(0, len(words) - 1)] for aword in random_word: alphabet_lst.append(aword) answer_lst.append("_") cnt = 10 i = 1 while (i <= 10): alphabet = input("알파벳을 입력하세요 : ")...
29ab376394ff53ed3542e6f22877b23d5d115e72
dchtexas1/pythonFiles
/division.py
233
4.4375
4
"""Gives quotient and remainder of two numbers.""" a = input("Enter the first number: ") b = input("Enter the second number: ") print("The quotient of {} divided by {} is {} with a remainder of {}.".format( a, b, a / b, a % b))
82d66024b8265582f6d756af441c3c3ed19bac1f
dchtexas1/pythonFiles
/Chaos.py
3,998
3.890625
4
############################################################################### # Name: Dax Henson # Date: 2017/03/30 # Description: Utilizes the chaos game to create a Sierpienski Triangle ############################################################################### from Tkinter import * from random import randint ...
770212b2b4fe4d93437108b9d93bbb4d43fd5bd0
dchtexas1/pythonFiles
/power.py
186
4.28125
4
"""Raises a number to a power and returns the answer.""" a = input("Enter a number: ") b = input("Enter another number: ") print "{} raised to the power {} is {}".format(a, b, a ** b)
26b4e1e5d6ea492dbdb0c0708680904c3bc37f0a
vaibhavkrkm/Mini-Projects
/Python/Counter_collections_module.py
436
3.859375
4
from collections import Counter c = Counter("gallad") print(c) c = Counter(["a", "a", "b", "c", "c"]) print(c) d = Counter(a=1, b=2) print(c["a"]) e = Counter("a") print(c | e) # subtract() -> subtracts a counter from another # update() -> adds _________________________ # most_common() -> # clear() -> clears a co...
a8f75dd238c1844333445ecc598d925fdcf057fa
vaibhavkrkm/Mini-Projects
/Python/CityBlock.py
2,013
3.640625
4
def path_func(dir_list, length): working_dir_list = None working_length = None origin = (0, 0) current_place = list(origin) unit_distance = 5 suppressor = None # variable for storing if length is less than len(dir_list) or len(dir_list) is less than length # when length is greator th...
a26ccd37bf1d09a17d4d1ab6dd232980a8cd8c61
n0obcoder/fun-with-python
/todo_list_maker/todo_list_maker.py
2,989
3.921875
4
# doskey todo=python "C:\Users\anime\Documents\Python Scripts\todo_list_maker\todo_list_maker.py" $* # todo --do "write a blog about this windows aliasing for a do-to list maker over the weekend." --name new_list.txt -v -n -l # "" are used only when the argument has a space in it import sys # A function for exiting t...
88cb18925a67570cc548a039b40ea70fcf473889
Woutah/AutoConvert
/timer.py
2,290
4.25
4
"""Simple timer which can be used to get the wall/cpu time of a process. Implements the "with x:" to measure timings more easily. """ from time import process_time import time class CpuTimer: def __init__(self): self._start_time = process_time() self._paused = True self._pause_time = process_time() self._...
82ab1e117e258569c4ec14583a2595e577a1a182
suhyunjeon/algorithm
/leetcode/easy/1281.subtract_product_and_sum.py
637
4
4
""" Given an integer number n, return the difference between the product of its digits and the sum of its digits. Example 1: Input: n = 234 Output: 15 Explanation: Product of digits = 2 * 3 * 4 = 24 Sum of digits = 2 + 3 + 4 = 9 Result = 24 - 9 = 15 """ import functools import operator class Solution: def subtr...
8c25a31f8dd7dba671150a51ef052880bdc5c402
Garce09/ShirleysMentees
/logic_recursion.py
1,856
4.375
4
############ Q1. Ask the user for an integer, multiply it by itself + 1, and print the result # Topic: user input ############ Q2. Ask the user for an integer # If it is an even number, print "even" # If it is an odd number, print "odd" # Topic: conditionals, user input ############# Q...
93c59632571a447dc91e0f743ae581c7311f67c4
HasanovNorbek/PythonDarslari
/12-11/6-masala.py
283
3.59375
4
# 5-masala #raqamni kiriting va shu indeksiyaga fibonochi sonlar ro'yhatini tuzing #fibonochi sonlar -> 1, 1, 2, 3, 8, 13, 21 indeks = int(input("=>")) a = [] for i in range(indeks +1) if i ==0 or i==1: a.append(1) else: a.append(a[i-1]+a[i-2]) print(a)
792a758ddee42ac08fa1d0c44062dd5f5196b4c3
xtyghost/python_helloworld
/controller/syntax/reduce.py
911
3.734375
4
from functools import reduce def add(x, y): return x + y print(reduce(add, [1, 3, 5, 7, 9])) def fn(x, y): return x * 10 + y def char2num(s): digits = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} return digits[s] def char3num(s): digits = {'0': 0, '1': 1...
13c792005c4c694f5b83485df8d08a81713a04d8
eternal-flame-AD/eflog
/eflog.py
1,517
3.671875
4
from common import loghandler class logger(): ''' a logger class handles a log system which write logitems to stdout and/or a file stdout (bool): whether to write log to stdout writer (StreamWriter): file writer (None for no file output) showdate (bool): if you dont want to output ...
75dee5fdf717115f210982396adf2738e25d470c
k018c1072/Challenge03
/C-3_3.py
121
3.53125
4
import re hoge = input('入力> ') hoge = re.split('[.!?]', hoge) if hoge[-1] == '': del hoge[-1] print(len(hoge))
363e4c7af90d26c2bc117470f07dad74812d5b7b
Baksonator/machine-learning-algorithms
/2a.py
4,936
3.5
4
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt def create_feature_matrix(x, nb_features): """ Creates feature matrix out of the input array of training data. The dimensions of the matrix are m X n, where m represents number of training data and n number of features. """ ...
16e78b8320b8231d5f32b4b9d84497366978c2ed
ssinghaldev/10_days_statistics
/day5/poisson_distribution_2.py
207
3.6875
4
# Enter your code here. Read input from STDIN. Print output to STDOUT A = 0.88 B = 1.55 repair_A = A + (A*A) repair_B = B + (B*B) print(round(160 + (40*repair_A), 3)) print(round(128 + (40*repair_B), 3))
3306b16c579d385f7e1541591f93de232930d065
ssinghaldev/10_days_statistics
/day0/weighted_mean.py
313
3.9375
4
# Enter your code here. Read input from STDIN. Print output to STDOUT n = int(input()) numbers = list(map(int, input().split())) weights = list(map(int, input().split())) product = [num*weight for num, weight in zip(numbers, weights)] weighted_mean = round(sum(product) / sum(weights), 1) print(weighted_mean)
2deb3b81b70127df74ef5671829ab8fb6d9b128c
ssinghaldev/10_days_statistics
/day5/normal_distribution_2.py
347
3.578125
4
# Enter your code here. Read input from STDIN. Print output to STDOUT import math #https://stackoverflow.com/a/9448324 def norm_cdf(x, mean, std): return 0.5 * (1 + math.erf((x - mean)/math.sqrt(2 * std**2))) print(round((1-norm_cdf(80, 70, 10))*100, 2)) print(round((1-norm_cdf(60,70,10))*100, 2)) print(round(n...
e6ebed088d2912e29440a6f4fdfb14fca2a44b52
divyansh-gupta-0210/BinarySearch.io
/UnivalTree.py
950
3.921875
4
# Univalue Tree # Given a binary tree root, return whether all values in the tree are the same. # Constraints # n ≤ 100,000 where n is the number of nodes in root # Example 1 # Input # root = [2, [2, [2, null, null], null], [2, [2, null, null], null]] # Output # True # Explanation # Every node has the value 2 # Exam...
a756a51362e090a47e7cb936a80d1224b8ad947d
divyansh-gupta-0210/BinarySearch.io
/SubsequenceStrings.py
634
3.59375
4
# Given two lowercase alphabet strings s1 and s2, determine if s1 is a subsequence of s2. # Constraints # n ≤ 100,000 where n is the length of s1 # m ≤ 100,000 where m is the length of s2 # Example 1 # Input # s1 = "ppl" # s2 = "apple" # Output # True # Example 2 # Input # s1 = "ale" # s2 = "apple" # Output # True ...
d456768d8af7beb068d4ad3284325ad033d82a06
ohquai/LeetCode
/day13/code22.py
2,594
3.515625
4
# -*-coding:utf-8 -*- """ 给出 n 代表生成括号的对数,请你写出一个函数,使其能够生成所有可能的并且有效的括号组合。 top93.48% """ import time import sys class Solution(object): def add_candidate(self, candidate_list, i, k, count_l, count_r): # print(candidate_list) # print('i: {0}, l: {1}'.format(i, k)) if i < k: # print...
44a6c740945c26a708cea5f61db06f1f7c86f189
ohquai/LeetCode
/day17/code30.py
3,068
3.53125
4
# -*-coding:utf-8 -*- """ 给定一个字符串 s 和一些长度相同的单词 words。找出 s 中恰好可以由 words 中所有单词串联形成的子串的起始位置。 注意子串要与 words 中的单词完全匹配,中间不能有其他字符,但不需要考虑 words 中单词串联的顺序。 """ import time import sys class Solution(object): def get_substring(self, s, words, word_len, index): if len(words) == 0 and index > 0: return True...
d9d470e5b248f10edf2404d3f3d38edf2a93d5c0
ohquai/LeetCode
/day11/heap_sort.py
2,440
3.546875
4
# -*-coding:utf-8 -*- """ 堆排序 """ import time import sys import random class Solution(object): def __init__(self): self.s = [] def heapify_desc(self, i, j): """ 最大堆排序 :type i: int :type j: int :rtype: list """ left_child = 2 * j + 1 righ...
fa81e8ea2f88c20cc8e6a7b70f63e9fdde39f7d9
ohquai/LeetCode
/day10/binary_insertion_sort.py
1,240
3.59375
4
# -*-coding:utf-8 -*- """ 折半插入排序 """ import time import sys import random class Solution(object): def binary_insertion_sort(self, s): """ :type s: list :rtype: list """ for i in range(len(s)): tmp = s[i] if i >= 1 and s[i] < s[i-1]: l...
69f0ce73efe8b2d12c6b7a0d6532363132954dc5
kirakchirag/Heart_Disease_Prediction_Django
/random_forest.py
1,767
3.546875
4
# Load modules import pandas as pd from sklearn.model_selection import train_test_split from sklearn.ensemble import RandomForestClassifier df = pd.read_csv(r"dataset.csv",header=None) df.columns=['Age','Sex','Chest_Pain','Rest_BP','Cholestrol','Fast_BS','Rest_ECG','Max_Heart_Rate','Exercise','ExertoRest','Slope','...
e218dd90cc8faa93e74eaed013cd230431084238
erdingRene/turtle_crossing
/myturtle.py
502
3.875
4
from turtle import Turtle class MyTurtle(Turtle): def __init__(self): super().__init__() def create_turtle(self): self.shape("turtle") self.color("green") self.penup() self.goto(0, -280) self.setheading(90) def create_text(self, text): self.color("...
1d156bef163afa0a8f579d300a2d1be8540e41bd
Sandeep-2511/Python-Practise
/prog5.py
84
3.953125
4
string="Hello, world!" c='e' count=string.count(c) print("the count of e is",count)
5208f5ccd5502a5feb10b2e62a430e7853a05a75
Sandeep-2511/Python-Practise
/prog47.py
367
3.65625
4
class addition: def __init__(self,j,k): self.first=j self.second=k def display(self): print("first number:"+str(self.first)) print("second number:"+str(self.second)) print("addition="+str(self.answer)) def calculate(self): self.answer=self.first+self.second ob...
e1512ccfbfa656cdb8b4bf95e4c4973240c1eb02
Rechenmann-Data-EIRL/MatlabBetterCode
/core/core.py
2,123
3.578125
4
import re def is_line_function(line): return "function" in line def is_line_condition(line): return "if" in line def is_line_for_loop(line): return "for" in line def is_line_while_loop(line): return "while" in line def is_line_switch(line): return "switch" in line def is_line_operation(l...
13e83f9f1f813afe4d74ba738011d1f27250fc49
YourongYe/Leetcode
/python/valid_parentheses.py
755
3.5625
4
#https://leetcode.com/problems/valid-parentheses/description/ class Solution: def isValid(self, s): """ :type s: str :rtype: bool """ if len(s)%2!=0: return False stack = [] for i in range(len(s)): c = s[i] ...
af1547674df31d7c892e510f8dd246a3108629b6
ramses-tech/ra
/ra/marks.py
836
3.734375
4
class Mark(dict): pass def _dict(obj): """Work with obj.__dict__ or obj if it doesn't have one (it should be one). This lets us pass in regular objects or their dicts (like f_locals). """ return getattr(obj, '__dict__', obj) def mark(obj, **attrs): """Creates ``__ra__`` marker dict of :obj: w...
9520bbe6bc272e4d494b6bee5bb91e8d79df1151
reconstruir/bes
/lib/bes/text/word_boundary.py
1,295
3.578125
4
#-*- coding:utf-8; mode:python; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- import string from bes.system.check import check class word_boundary(object): # Default word boundary behavior in python regular expressions does # does not treat the underscore as a word boundary character. So the # d...
f6156631d5e1d0d4c0439d6b4d9cc79a5c3b32ac
saifrinds1/Python-OPP-Practice
/Python OPP(4)(5) Methods.py
536
3.609375
4
class Fighter: def __init__(self, name): self.name = name self.health = 100 self.damage = 10 def attack(self, other_guy): print("{} attacks {}!".format(self.name,other_guy.name)) print("{} loses {} health points".format(other_guy.name,self.damage)) other_guy.hea...
b4eddaa8ceada22cdf3d2c3f12e441752cfb6425
larlyssa/checkio
/home/house_password.py
1,648
4.1875
4
""" DIFFICULTY: ELEMENTARY Stephan and Sophia forget about security and use simple passwords for everything. Help Nikola develop a password security check module. The password will be considered strong enough if its length is greater than or equal to 10 symbols, it has at least one digit, as well as containing one up...
eca2f97252075f1e986ac272eb4561258107fedc
larlyssa/checkio
/home/pawn_brotherhood.py
3,278
4.3125
4
""" DIFFICULTY: SIMPLE Almost everyone in the world knows about the ancient game Chess and has at least a basic understanding of its rules. It has various units with a wide range of movement patterns allowing for a huge number of possible different game positions (for example Number of possible chess games at the end...
5ffc5b48ce4e0c95c077c20e54c6c6addb669aea
jde10/CSC2417---Algorithms-in-Genome-Analysis
/A2/fmindex.py
3,167
3.703125
4
#! /usr/bin/env python # Modified from Ben Langmead's code in his teaching materials # http://www.langmead-lab.org/teaching-materials/ import argparse import math def naiveOcc(bw): ''' Given BWT string bw, return the occurrence array Occ[i][a] where Occ[i][a] is the number of times a occurs in BWT[0, i] ...
6f28d13bcf68d2acbfc7990dfce92fef01735e8f
lelivre/python_exercise
/Find_Min.py
260
3.578125
4
# Find min def main(): def findMin(x): minNum = x[0] for i in x: if minNum > i: minNum = i return minNum print(findMin([0,1,2,3,4,5,-3,34,-56,-1000])) # = -1000 if __name__=='__main__': main()
f1053a896ab4d62501f8f1930514e2d0e2e08dde
RodrigoAk/exercises
/solutions/ex13.py
545
4.3125
4
''' You are given a positive integer N which represents the number of steps in a staircase. You can either climb 1 or 2 steps at a time. Write a function that returns the number of unique ways to climb the stairs ''' import math def staircase(n): spaces = n//2 + n % 2 num2 = n//2 answer = 0 while(spac...
6b0763623dd21c8f8a0cfaa66c6846766821910a
RodrigoAk/exercises
/solutions/ex8.py
517
3.84375
4
''' Given a list of numbersm where every number shows up twice except for one number, find that one number. Example: Input: [4, 3, 2, 4, 1, 3 ,2] Output: 1 ''' def singleNumber(nums): flag = True for i in range(len(nums)): for j in range(len(nums)): if(i == j): continue ...
b8584a341e1b80eb82809de04b7ec7984a0f0e52
antsankov/interview-practice
/binary-converter.py
279
3.9375
4
def convertToInt(binary): answer = 0 swap = binary swap.reverse() for i in range (0, len(swap)): if (swap[i] == 1): val = 2 ** i answer += val print(answer) convertToInt([1,0,0,0,1,0,0,0]) convertToInt([1,0,1,1,0,0])
74ec0c3112aea6992d54a59e2cec323143085df8
hitanshkadakia/Python_Tutorial
/function.py
1,419
4.75
5
# Creating a Function # In Python a function is defined using the def keyword: def my_function(): print("Hello from a function") # Calling a Function # To call a function, use the function name followed by parenthesis: def my_function(): print("Hello from a function") my_function() # Arguments ...
5f2b869fad97bd52b0381a4f95ebce15c54c6568
hitanshkadakia/Python_Tutorial
/if-elsestatement.py
711
4.21875
4
#If statement a = 33 b = 200 if b > a: print("b is greater than a") #elif a = 33 b = 33 if b > a: print("b is greater than a") elif a == b: print("a and b are equal") #else a = 200 b = 33 if b > a: print("b is greater than a") elif a == b: print("a and b are equal") else: print...
1e5c512fb908a9000af0cc0d0c38d59fb0c5ab3f
ncrafa/infosatc-Ip-avaliativo-08
/exercicio 2.py
535
3.984375
4
def leiaInt(): try: numeroInt = int(input( "Informe um numero inteiro: " )) except: print ( "Inválido ! Somente dígito inteiro " ) else: print("número",numeroInt,"válido") def leiafloat (): try: nfloat = float(input( "Insira um nume...
bc64bd74099a98f9591fe75b7273669b71ab01e9
moguju/Python-training
/number/num2.py
188
3.65625
4
# -*- coding: utf-8 -*- # int(引数) -> 引数を数値に変換 # ""の中は文字列になる # 引数が数字じゃないとエラー test_str = "100" print int(test_str) + 100
63cc9680c104c33ae9e2b7cf75c10872005ab38e
moguju/Python-training
/list/list4.py
151
3.53125
4
# -*- coding: utf-8 -*- test_list_1 = ['1','2','3','2','1'] print (test_list_1) print("") # 値の削除 test_list_1.remove('2') print test_list_1
c4f1d322721601635bb239f972c8b7d3508e602f
moguju/Python-training
/first day/if.py
113
3.875
4
# -*- coding: utf-8 -*- a = int(input()) if a % 5 == 0: print("やったね!") else: print("しゅん")
947fe5de815aede52e22247165d66219ff096e97
peytonchance/start_python
/bmi.py
176
4.03125
4
age = input("How old are you?") height = input("How tall are you in inches?") weight = input("How much do you weigh in pounds?") print((int(weight)/(int(height) ** 2)) * 703)
41964c3e8074a6507954b1648e1788b2aa5c154a
marcinluczkowski/structuralCircle
/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/PythonFiles/firstPython.py
335
3.765625
4
import sys import pandas as pd import matplotlib.pyplot as plt num1 = sys.argv[1] num2 = sys.argv[2] df = pd.DataFrame({'A': [0, 1, 2], 'B' : [2, 3, 4]}) #result = float(num1) * float(num2) result1 = num1 print("Two input numbers are multiplied and result is seen below.") sys.stdout.flush() print(f'Result: {result1}'...
e37f9bbd84b1f97d72c316ad8266d3899e07c700
Mikecast/python-search-engine
/application.py
5,628
3.53125
4
# -*- coding: UTF-8 -*- """ Este programa pide el ingreso de dos páginas y una palabra. Compara que página tiene mayor cantidad de la palabra elegida. """ import urllib2 #Ayuda en la apertura de URL. import re #Cuenta las letras dentro de las palabras en la pagina. import time # Controla el tiempo de una variable. imp...
51e3ea1caa2352c1528c7af01314228e07f3e050
merkste/SQList
/sqlist.py
8,628
3.71875
4
#!/usr/bin/env python import argparse import csv import sys from ast import literal_eval from collections import Sequence from inspect import getargspec from itertools import chain, ifilter, imap from operator import itemgetter def SELECT_DISTINCT(COLUMNS, FROM, WHERE=None): """Deduplicate selected rows. See also S...
f412b311761832eab92ff21b0ca0041816b52fcc
jppriet0/CAAP-CS
/Lab3/lab3.py
3,101
3.859375
4
# Juan P. Prieto # Lab 3 from random import randint from time import sleep # global variable of chutes and ladders # chutes and ladders playable up to a 16*16 board. chutes_ladders = {4:7, 8:15, 12:2, 14:6, 21:42, 28:84, 36:44, 47:26, 49:11, 51:67, 56:53, 62:19, 64:60, 71:91, 80:10...
6fe83a361ad3c6a54647a8d32fbef4519716bf9e
jppriet0/CAAP-CS
/hw1/Sigma.py
411
4.09375
4
def sigma(): summation = 0 input("How many numbers are you going to add? ") E_list = eval(input("Okay. Now, please provide the numbers to add separated by commas. e.g. 1,2,3: ")) for i in E_list: summation += i print("The total is: ", summation) returnE = input("Do you want to do another summation? (yes/no) ") ...
3f2562eb0b583b05a78fdb7c0a1e68f255fcd217
Lesaje/repository_name
/FindWords.py
2,448
3.96875
4
import random def word_searching (j, FIELD_SIZE): word_num = random.randint(100, 900) word = open('words.txt').read().split('\n')[word_num] word = list(word) #making a list from our string word_len = len(word) if (word_len>(FIELD_SIZE-j)): ...
b66933961853fe84decd862381b161d70c099f6a
VectoAbhi/Network-Control-System
/MessageBox.py
402
3.953125
4
from tkinter import * import tkinter.messagebox root = Tk() tkinter.messagebox.showinfo("Window Title ... Monkeys can live up to 300 years ") answer = tkinter.messagebox.askquestion("Question 1--Do You Love China?") if answer == 'yes': print("Thats My Girl Asshole! Back off!") Label(root,text="Enter Directory...
1cc02e5c0f78d30ce43d076ac68c86437a9f43c5
sandirobnik/ProjectEuler
/Problem8.py
538
3.625
4
# Author: Aleksander Robnik # Project Euler: Problem 8 - Largest product in a series def LPS(number): currentProduct = 1 maxProduct = 1 for i in range(0, len(number) - 13): for j in range(i, i + 13): currentProduct *= int(number[j]) if currentProduct > maxProduct: ...
ba3d482874710352ab5062878a78afef4b7e2ebc
wanghui0225/PythonApplication1
/PythonApplication1/scripts/writeHDF4.py
602
3.53125
4
from pyhdf.SD import * # import Numeric Python package -- Numpy from numpy import * data = array(((1, 2, 3), (4, 5, 6)), int16) # Create an HDF file sd = SD("hello.hdf", SDC.WRITE | SDC.CREATE) # Create a dataset sds = sd.create("sds1", SDC.INT16, (2, 3)) # Fill the dataset with a fill value sds.setfillvalu...
51202483d82f497b02bee2bdfc6447df7e2e22d4
steven52502/Steven52502
/files/sctask.py
1,167
4.0625
4
print "Bike Selector" print ("\n") def introduction(): print "Welcome to your Bike Selector" print ("\n") print "Let's try and find a bike that's right for you" print ("\n") select_bike() def select_bike(): print "Are you looking for Gears, suspension, speed or tires in a bike" print ("\n") ...
6aa27ba37311b9ce0b9c80c8c5cef214ec4c2ea8
lucasboscatti/algorithms_numeric_calculus
/met_bissecao.py
720
3.609375
4
import math def f(x): # Solve the equation y = 3*x - math.cos(x) # Escreva aqui a função return y a0 = 0 # Intervalo inicial b0 = 1 # Intervalo final erro = 0.01 # 𝜀 > 0 (precisão); if f(a0) * f(b0) < 0: stop = False x0 = (a0 +b0)/2 i = 0 while stop == False: i...
4674e2a1cc6c0290c4e8b8a11f8e2e0908ad37e1
simplylizz/trash
/interviews/skyscanner/comon_parent.py
432
3.5
4
def get_parents(node): p = node.parent while p: yield p p = node.parent def common_parent(first, second): first_parents = list(get_parents(first)) second_parents = list(get_parents(second)) last_common_parent = None for fp, sp in zip(first_parents[::-1], second_parents[::-1...