blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
e55ef538dedfa579443687fe8d9c2f09c2546d73
Philisophe/RosalindProblems
/1st.py
3,076
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Mar 21 18:03:23 2018 @author: kalashnikov """ #This one counts the number of nucleotides of every kind def count_nuc (st): results = [0,0,0,0] for i in st: if i == 'A': results[0] = results[0]+1 if i == 'C': ...
1dca16be19c96c5e5e302eca188cbc25454baa27
fdmoscow/learn
/price.py
971
3.8125
4
#def discounted (price, discount, max_discount = 100): #price = abs(float(price)) #discount = abs(float(discount)) #max_discount = abs(float(max_discount)) #if max_discount > 99: # raise ValueError ('Макс скидка не может быть больше 99%') #if discount>=max_discount: # price_with_discou...
c59a3121dfd56cbaaf8e310830371d9b9751ee32
hansrajdas/bowling-score
/utils/singleton.py
605
3.90625
4
"""Implements a function which can be used as a singleton decorator.""" def singleton(classname): """Decorator function which restricts decorated class to be singleton. Args: classname: Reference of class whose object needs to be created. Returns: Instance of requested class. """ instances...
da208479e66a06fc75a2b6abdf0473a2c96a9820
Guzinanda/Interview-Training-Cracking-The-Coding-Interview
/10 Sorting & Searching/sort-bubble-sort.py
793
4.0625
4
""" @ Sort Agorithm | Bubble Sort @ Problem Given an unsorted array, sort it using Bubble Sort Algorithm. @ Example Input: list = [7,2,10,3,1] Output: list = [1,2,3,7,10] @ Explanation: https://www.youtube.com/watch?v=g_xesqdQqvA """ def bubbleSort(lis): indexing_lenght = ...
31e6ec93bb7be97eb0469a5f460d7f7f484c4b3d
Nxykl/Leetcode
/Array/Remove_duplicates.py
210
3.671875
4
def remove_duplicates(num): j = 0 for i in range(len(num)): if num[i] != num[j]: j +=1 num[j] = num[i] return num num = [1,1,2] print(remove_duplicates(num))
e08763760e77a17c625111b7370507b38b9f5571
Nxykl/Leetcode
/Recursive/sum_of_array.py
234
3.875
4
def recur_sum_of_array(nums, length): if length == 0: return 0 value = recur_sum_of_array(nums[1:], length-1) value += nums[0] return value nums=[1,2,3,4,5] length = 5 print(recur_sum_of_array(nums, length))
f9f06ab764315cb1601ece1d4a52be88676d24fb
Nxykl/Leetcode
/HashMap/TwoSum.py
255
3.53125
4
def twosum(nums, target): hashmap = {} for i,n in enumerate(nums): if target-n in hashmap: a = [hashmap[target-n], i] return a hashmap[n] = i nums = [2,7,11,15] target = 9 print(twosum(nums, target))
fed1ba235a42f5c11201c22142cbd12628d10232
Nxykl/Leetcode
/String/CountandSay.py
256
3.546875
4
from collections import Counter def countandsay(input, length): if length == 0: return for key, value in Counter(input).items(): st = "1121" for key, value in Counter(st).items(): new_str = str(value) + str(key) print(new_str)
4e8d23f572647a9534dbafb24856b06aee74297a
rohanlekamge/Python-Tutorials
/7/Tutorial 2 - Class.py
525
3.984375
4
#2 secret = 'westminster' turns = 6 guesses = [] print("Let's Play Guess the Word") print("You Have 6 Turns to Guess the Word!") length = len(secret) print(" _ "*length) while turns >= 1: turns = turns - 1 guess = input("\nGuess the Word:") if guess in secret: i = secret.index(guess) for...
285d41edbed6c77484cc9dc02c2f14e00a46a4ae
rohanlekamge/Python-Tutorials
/9/Tutorial 03.py
1,343
4.1875
4
#1 Display all odd numbers between 0 and 100 c = 1 while c > 0 and c < 100: print(c) c = c + 2 #2 dividend = int(input("Input Number 1: ")) divisor = int(input("Input Number 2: ")) while divisor != 0: dividend = int(input("Input Number 1: ")) divisor = int(input("Input Number 2: ")) quotient = di...
b43ee5b0d5fbc6a897eba6ef75323acbce0c04e4
Fatihturkmen/Class4-CS101Module-Week10
/Week 10-2.Odev.py
280
3.515625
4
def sort(A): zeros = A.count(0) k = 0 while zeros: A[k] = 0 zeros = zeros - 1 k = k + 1 for k in range(k, len(A)): A[k] = 1 if __name__ == '__main__': A = [0, 0, 1, 0, 1, 1, 0, 1, 0, 0] sort(A) print(A)
bb27da0f81d90d5e7952b29889f25d50d89f1342
Learned-Index-Structure/LIS
/utils/generate_lognormal.py
4,413
3.859375
4
from operator import itemgetter from queue import PriorityQueue import os import pandas as pd import csv import numpy as np class Data: """ Class Data used for On Disk Sorting. The comparator is defined here :param line: Row of data :param filename: Name of the file to which row belongs ...
c81e8b18518d03a799a04fb4bcf5e9f15b6fa19a
samarthdubey46/Sudoku-Solver-With-AI
/Intro.py
1,010
3.78125
4
from tkinter import * from settings import * from app_class import * import tkinter.font as tkFont state = "Intro" root = Tk() root.geometry("500x500") global s def play(): a = App() a.run() print(entry.get()) root.configure(bg='black') fontStyle = tkFont.Font(family="Lucida Grande",size=30...
80aaea7235528a721988cf2ee3b65e9137365f22
ryamauti/mimic-keyboard
/robot-reboot-cartesiano.py
727
3.5
4
# -*- coding: utf-8 -*- """ usa o "moveRobo" e o "redefinir" do código robot-reboot-opencv.py Gera uma lista força bruta - produto cartesiano - e aplica os movimentos. Muito lento e não está paralelizando. """ import itertools from random import shuffle # total de tentativas LANCES = 5 robots = [0, 1, 2, 3] direcoes...
b770cf68017939d5e50d97a59210947da75d61c4
Felanrod/PythonGraphics
/Assignment 2/code/joelsSlotMachine_0_2.py
7,794
4.15625
4
# Source File Name: slotmachine.py # Author's Name: Tom Tsiliopoulos # Last Modified By: Tom Tsiliopoulos # Date Last Modified: Tuesday May 22, 2012 """ Program Description: This program simulates a Casino-Style Slot Machine. It provides an GUI for the user that is an image of a slot machine...
23a0f7cdfd0a6374e82a3ccf20b99d05a77ed585
venkypolls/ataStructures-
/arrays/rotate_list.py
605
3.984375
4
__author__ = '212576702' import os import sys def reversearr(arr,start,end): while 1: if start == end or start > end: return arr temp = arr[start] arr[start] = arr[end] arr[end] = temp start += 1 end += -1 original_list = raw_input("please enter the arra...
6760fd36baea173f1644f548ae88749b9dbcccdd
v2tamprateep/phutball
/phutballBoard.py
6,545
3.671875
4
import tkinter as tk class Board(tk.Frame): cursorRow=-1 cursorCol=-1 cursorStoneId = -1 last = None #the last stone to be placed #get nearest grid point (in L_1 norm) to given coordinates def row_col(self,x,y): r = (y-self.vborder + 0.5*self.squaresize)//self.squaresize c = (...
b4b7295744818cd0c4b1db3ea4bcb3dcf03f8460
KalyanTarun/ProgrammingPractice
/DynamicProgramming/EditDistance.py
3,181
3.640625
4
# -*- coding: utf-8 -*- """ Created on Fri Mar 1 15:46:47 2019 @author: Tarun Contributors = ['Akhilez'] # :P """ # Edit Distance problem using a recursive approach min_depth = 99999999 nodes_recursive = [] nodes_dynamic = [] def edit_dist_recursive(str1, str2, m, n): # The following are three terminating co...
cffccc8c4576d98ffd99cd02d654cd3e50329b3e
ITAYCARMI/stratasysProject
/utils/__init__.py
4,762
3.734375
4
import object_generator def quadrangle_validation(quadrangle): """ Check if quadrangle points is valid :param quadrangle: square object :return: true if valid else false """ return 0 <= quadrangle.x1 < quadrangle.x2 and 0 <= quadrangle.y1 < quadrangle.y2 def circle_validation(circle): ""...
61d23c0cc6d3831d848f24888509e75c82c245da
sejin423/Library
/탐색/이진 탐색 소스코드.py
1,571
3.546875
4
# 이진 탐색 소스코드 구현_재귀함수 def binary_search(array, target, start, end): if start > end: return None mid = (start + end) // 2 # 찾은 경우 중간 인덱스 반환 if array[mid] == target: return mid # 중간점의 값보다 찾고자 하는 값이 작을 경우 왼쪽 확인 elif array[mid] > target: return binary_search(array, target, sta...
8c34edaf4334e3f3770f31cd65e91cef4241c4d0
lokeshreddy007/Python-projects
/100 year.py
408
3.859375
4
#this is a simple python program for printing at what year u will get 100 years old print("Hello!,Welcome a simple program Find 100 Year") myName=input("pls enter u r name:") print("Hai" + myName) value1=int(input("pls enter u r age:")) value2=int(input("pls enter current year:")) age = ((100-value1) + ...
9a705da00ecef1c8160c4bfd2288c43806761628
keshav1245/HackerRankSolutions
/Python(LanguagePractice)/map_lambda.py
259
4.1875
4
cube = lambda x: x**3# complete the lambda function def fibonacci(n): # return a list of fibonacci numbers lst = [0,1] for i in range(2,n): lst.append(lst[i-1]+lst[i-2]) else: return lst[0:n] if __name__ == '__main__':
fb2ce4ecd9d44006d8468ebf2752400de3ab8b78
keshav1245/HackerRankSolutions
/Python(LanguagePractice)/html_parser_1.py
726
3.65625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT from html.parser import HTMLParser class MyHTMLParser(HTMLParser): def handle_starttag(self, tag, attrs): print ("Start :", tag) if len(attrs) > 0: for k,v in attrs: print("-> {} > {}".format(k,v)) ...
5a352396ecf8c44391f1f97b1f9583fa1824df7f
Barty200/Python-Login-System
/login.py
1,402
3.84375
4
import base64 def login(path): while True: choose = input("Do you want to login or register: ").title() if choose == "Login": username = input("What is your username: ") try: login = open(path + username, "r") password = login.read() ...
d0187caa048928ce24a3a7a165a1d527048d88cc
ArielBarros/Premiados-SPAECE-ENEM-2014
/premiadosSpaeceEnem.py
1,653
3.890625
4
import pandas as pd import numpy as np import operator arquivo = 'premiados.csv' df = pd.read_csv(arquivo, sep=';') def rankingBycolumn(column): numberNotebooks = {} values = df[column].unique() gb = df.groupby(column) for value in values: numberNotebooks[value] = gb.get_group(va...
120019d6cb9530e7fee32e9ae7e80afaa2844f86
harriscw/advent_of_code_2020
/day25/part1.py
637
3.53125
4
import sys def findloops(num): value=1 loops=0 while value != num: value=(value*7)%20201227 loops+=1 print("Loop size for",value,"is:",loops) #findloops(5764801) #card #findloops(17807724) #door findloops(8458505) findloops(16050997) # Transform def getencryption(loops,key): value=1 for i in range(loops): ...
f9c9fbb3b3ba4b831f2030932a9d6f50231ec98a
Toogii2019/Python210_Fall2019
/students/toogii/lesson08/donor_class.py
2,293
3.5
4
#!/usr/bin/env python3 from datetime import date, datetime class Donor: donation_dict = {} email_template = "Date {}, Dear {}, Thank you for your contribution of {} to our charity. " def __init__(self,name,donation_amount,donations=1): self.name = name self.last_donation_amount = donation...
808204fa5c1378f3b09321f7ae0b9c2adef43574
humblefo0l/PyAlgo
/DP/CoinChange_MinNumber.py
1,682
4.0625
4
""" Find minimum number of coins that make a given value Given a value V, if we want to make change for V cents, and we have infinite supply of each of C = { C1, C2, .. , Cm} valued coins, what is the minimum number of coins to make the change? Examples: Input: coins[] = {25, 10, 5}, V = 30 Output: Minimum 2 coins req...
389adad8d35af5701863144bb768239c72195387
humblefo0l/PyAlgo
/BinaryTree/topView.py
2,057
4.3125
4
""" You are given a pointer to the root of a binary tree. Print the top view of the binary tree. Top view means when you look the tree from the top the nodes, what you will see will be called the top view of the tree. See the example below. You only have to complete the function. For example : 1 \ 2 ...
57e7fcfd8e8993ecffba990e2a481d9ea37f7735
humblefo0l/PyAlgo
/Array/MaxSubarray.py
1,159
4.25
4
""" 53. Maximum Subarray Easy Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. A subarray is a contiguous part of an array. Example 1: Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Output: 6 Explanation: [4,-1,2,1] has the largest sum...
7f781ffc1caf15b3d2f0e15706bc4fc82c82964a
humblefo0l/PyAlgo
/Array/firstAndLastOccuranceOfElement.py
1,562
4.125
4
""" 34. Find First and Last Position of Element in Sorted Array Medium 8844 267 Add to List Share Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value. If target is not found in the array, return [-1, -1]. You must write an algorithm with O(...
97fe706967d3f7ea95f2c6851f7c83046b2eed2a
humblefo0l/PyAlgo
/DP/EditDistance.py
2,357
3.984375
4
""" Edit Distance | DP-5 Given two strings str1 and str2 and below operations that can performed on str1. Find minimum number of edits (operations) required to convert ‘str1’ into ‘str2’. Insert Remove Replace All of the above operations are of equal cost. Examples: Input: str1 = "geek", str2 = "gesek" Output: 1 ...
1db880e6eb3ef4f8b5d1387ce3b1543f5f8770b9
humblefo0l/PyAlgo
/DP/BellNumber.py
2,779
3.59375
4
""" Bell Numbers (Number of ways to Partition a Set) Given a set of n elements, find number of ways of partitioning it. Examples: Input: n = 2 Output: Number of ways = 2 Explanation: Let the set be {1, 2} { {1}, {2} } { {1, 2} } Input: n = 3 Output: Number of ways = 5 Explanation: Let the se...
4d1b46f60aaaca682a37c65bda86edc9eac51d19
humblefo0l/PyAlgo
/BinaryTree/distanceNodeFromRoot.py
1,242
3.984375
4
""" Find distance from root to given node in a binary tree Given root of a binary tree and a key x in it, find distance of the given key from root. Dis­tance means num­ber of edges between two nodes. Examples: Input : x = 45, Root of below tree 5 / \ 10 15 / \ / \ 20 25 3...
143b88f2b735fcdf48fc71158aa5c7cb781d350d
humblefo0l/PyAlgo
/Graph/DFS.py
2,364
3.765625
4
""" Depth First Search or DFS for a Graph Depth First Traversal (or Search) for a graph is similar to Depth First Traversal of a tree. The only catch here is, unlike trees, graphs may contain cycles, a node may be visited twice. To avoid processing a node more than once, use a boolean visited array. Example: Input: n...
50716bdd14b39f1f791d2b461fa7a2f37122b516
humblefo0l/PyAlgo
/Graph/BFS.py
1,281
4.15625
4
""" Breadth First Search or BFS for a Graph Breadth First Traversal (or Search) for a graph is similar to Breadth First Traversal of a tree (See method 2 of this post). The only catch here is, unlike trees, graphs may contain cycles, so we may come to the same node again. To avoid processing a node more than once, we ...
f47a15f89aa7368a57d8d90f7af0367740e8eb70
kyo68820405/1808
/python/day02/guess.py
366
3.828125
4
# import random # number = random.randint(1,10) # answer = int(input('number:')) # if answer > number: # print('猜大了') # elif answer < number: # print('猜小了') # else: # print('对了') # print(number) ################################ a, b = 10, 20 if a <= b: s=a else: s=b print(s) x, y = 10, 20 semll =...
d80cef8a17e8072b76f5bb61acb0d8e291d0d28a
KUPPURAJM/C_Programming
/set8.py
115
3.796875
4
n=int(input("Enter value of n:")) if (n<1 or (n%1)!=0): print("wrong input") else: sum=n*(n+1)/2 print (sum)
6f47b79f765a7dc9777674aac83dd6a5d662ed97
hrithiksagar/program-where-user-will-input-a-list-and-output-will-remove-dublicate-items-in-list
/code.py
192
3.953125
4
l=[] s=int(input("please enter size of list")) for i in range(s): x=int(input("enter list items")) l.append(x) print("items you have entered",l) q=set(l) q= list(q) print(q)
1a508c33cf7b045e337a1c66804d5110978d4890
amishamichelle/python
/interchangelist.py
254
3.875
4
lst=[] n=int(input("Enter n elements: ")) print("Enter elements") for i in range(0,n): ele=int(input()) lst.append(ele) print(lst) def swaplist(nlst): temp=nlst[0] nlst[0]=nlst[n-1] nlst[n-1]=temp return nlst print(swaplist(lst))
f4aeab150b66065e38e4b7b6dd26af7b502500ad
srijamk/python-adventures
/LinkedList.py
2,180
4.25
4
class Node: """ Creates a representation of a Node, which is a single element in the Linked List. Each Node instance has a value and a reference pointing to another Node. """ def __init__(self, value): self.value = value self.next = None def set_next(self, next_node): ...
4398766d962f1f5ed8552b3b93a1e38af1ac6e2f
srijamk/python-adventures
/Heap.py
2,305
3.65625
4
class MinHeap: def __init__(self): self.size = 0 self.items = [] def get_items(self): return self.items def get_size(self): return self.size def getLeftChildIndex(parentIndex): return 2 * parentIndex + 1 def getRightChildIndex(parentIndex): return ...
47483fe95364465657cdb2b0d393250ca32a2495
HEUMMAN/codingTest
/sparta/week_1/02_find_alphabet_occurrence.py
305
4.09375
4
def find_alphabet_occurrence_array(string): alphabet_occurrence_array = [0] * 26 for word in string: if word.isalpha(): alphabet_occurrence_array[ord(word) - ord('a')] += 1 return alphabet_occurrence_array print(find_alphabet_occurrence_array("hello my name is sparta"))
d508fa5734e452177e5b017cce9180831a6b092f
HEUMMAN/codingTest
/sparta/week_4/homework/03_get_all_ways_of_theater_seat.py
785
3.734375
4
seat_count = 11 vip_seat_array = [2 ,5] fibo_memo = { 1: 1, 2: 2 } def fibo(n, fibo_memo): if n in fibo_memo: return fibo_memo[n] fibo_memo[n] = fibo(n-1, fibo_memo) + fibo(n-2, fibo_memo) return fibo_memo[n] def get_all_ways_of_theater_seat(total_count, fixed_seat_array): result = [...
1506264c437247e811acdb6d82a827afc3c69f75
10LGUO/leetcode-tree-generator-for-python3
/tree-generator.py
931
3.796875
4
class TreeNode(): def __init__(self, x): self.val = x self.left = None self.right = None class treegenerator(): def __init__(self, nodelist): self.nodelist = nodelist self.l = len(self.nodelist) def gen(self): root = TreeNode(self.nodelist[0]) i = 1...
66aed415c8a8a0fd48c27583240e7b26eda30b24
Vincent105/1st-PyCrawlerMarathon
/practice/lxml_01_The Element class/lxml_013_Elements_contain_text.py
999
3.890625
4
from lxml import etree root = etree.Element("root") root.text = "TEXT" print(root.text) print(etree.tostring(root)) html = etree.Element("html") body = etree.SubElement(html, "body") # two properties .text and .tail body.text = "TEXT" print(etree.tostring(html)) br = etree.SubElement(body, "br") print(etree.tostri...
2fea1da8be5c5485358139841c5a3f2649c6943a
guruchandranb/Saama-Internship-
/print*.py
110
3.8125
4
row = int(input("Enter the number of rows: ")) n = row while n >= 0: x = "*" * n print(x) n -= 1
6ef2222a551b5dcae73002d059c91ef3c8e8289a
leoliuyt/workspace_python
/python_grammar/my_list.py
1,011
4.0625
4
classmates = ['Michael','Bob','Tracy'] print(classmates) print("list length = %d" % len(classmates)) print(classmates[0]) print(classmates[-1]) # 方法 # 'append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort' classmates.append("Adam") classmates.append("Adam") print("append ...
bc08bc2581fdf0d86e8b92ba9c48d03ae0d0d4f4
leoliuyt/workspace_python
/python_grammar/yield_guide/my_yield_from.py
1,922
3.734375
4
# def yieldTest(): # i = 1 # while i < 4: # print('[yieldtest]:',i) # n = yield i # print('n = ',n) # if i == 3: # return 100 # i += 1 # def itest(): # val = yield from yieldTest() # print('[itest]:',val) # t = itest() # print(type(t)) # t.send(None...
067149aa5851966ba00ebec05c5a0ec6748a4bd5
leoliuyt/workspace_python
/python_grammar/my_tuple.py
300
4
4
# tuple一旦初始化就不能修改 classmates = ('Michael', 'Bob', 'Tracy', 'Adam', 'Adam') print(classmates[0]) t = ('a', 'b', ['A', 'B']) t[2][0] = 'X' t[2][1] = 'Y' print(t) # list和tuple是Python内置的有序集合,一个可变,一个不可变。根据需要来选择使用它们。
a9d34f0f81c3ae888eda4926e0f0ae4180cd338e
ycopin/Informatique-Python
/Annales/exam_1411.py
7,402
3.609375
4
#!/usr/bin/python # -*- coding: utf-8 -*- from __future__ import division import pytest # Classe Vector class Vector (object): """ Classe représentant des vecteurs à deux dimensions. Celle-ci présente un constructeur donnant par défaut le point (0,0), ainsi qu'une surcharge des opérateurs addition,...
c722e36c965e37a56bb3478c51aa002a1e2c5c6e
ycopin/Informatique-Python
/Exercices/syracuse.py
1,538
3.984375
4
#!/usr/bin/env python3 # Time-stamp: <2018-07-26 16:57 ycopin@lyonovae03.in2p3.fr> __author__ = "Adrien Licari <adrien.licari@ens-lyon.fr>; Yannick Copin <y.copin@ipnl.in2p3.fr>" def suite_syracuse(n): """ Retourne la suite de Syracuse pour l'entier n. >>> suite_syracuse(15) [15, 46, 23, 70, 35, 106...
076a7a39e43fea431a2a9b29f49f080b417288da
ycopin/Informatique-Python
/Cours/animal.py
5,291
4.28125
4
#!/usr/bin/env python3 # coding: utf-8 """ Exemple (tragique) de Programmation Orientée Objet. """ # Définition d'une classe ============================== class Animal: """ Un animal, défini par sa masse. """ def __init__(self, masse): """ Initialisation d'un Animal, a priori vivan...
20b84203ff23c82b9ca81c82a870614961de6aaa
CristianRey/CR-Hodes-Python-Kata
/hodes_python_kata/package_1/hello_world.py
893
3.75
4
''' All classes related to Helloworld functionality ''' import logging class HelloWorld(object): ''' Prints stuff to file and console ''' def __init__(self): self.logger = logging.getLogger(__name__) def uppercase(self, data): ''' Takes a string and returns the lowercase ve...
9638690853557bdce179d4f8817cf348274674b3
ecollins2307/HPM573S18_COLLINS_HW1
/HW1_problem1.py
405
4.03125
4
#HW 1, Problem 1 #Part 1 #creating y1 as integer y1 = int(17) #creating y2 as float y2 = float(17) #creating y3 as string y3 = "17" #creating y4 as Boolean y4 = (17==17) #printing the above variable with their type print(y1) print(type(y1)) print(y2) print(type(y2)) print(y3) print(type(y3)) print(y4) print(type(y4))...
f8701abb6d703166ff94545a866857b014f260a7
korniloff75/TestPython
/moduleRandom.py
205
3.546875
4
import random # numbers = [1, 2, 3, 4, 5, 6, 7, 8] numbers = range(1,8) # random.shuffle(numbers) print('numbers= ', numbers) random_number = random.choice(numbers) print('random_number= ', random_number)
2370eeb6757469831af188ae5c9f4a241c57ab05
fabiochiusano/SymbolicRegressionPy
/symreg/tree.py
2,804
3.9375
4
import math import generator as gtr class Tree(object): def __init__(self): pass class Leaf(Tree): def __init__(self): pass def height(self): """ The height of a leaf is always 1 """ return 1 def numOfNodes(self): """ Returns the number of nodes, both internal and leaves, of the subtree with this ...
b32bb8266920296d3428b51875c5279041301531
anto2318/ramdapy
/scripts/any.py
257
3.609375
4
from equals import equals def any(fn, val, list): idx = 0 while(idx < len(list)): if(fn(val, list[idx])): return True idx += 1 return False if __name__ == '__main__': print(any(equals, 3, [1, 2, 3, 4]))
895a9960ed6f766c4576adfd04da7b52ce9f69b6
pipilio/pythonPlayground
/abo/main.py
997
3.734375
4
class Nodo(): def __init__(self): self.valor = None self.izq = None self.der = None def insertar(self, valor): if self.valor is None: self.valor = valor elif valor > self.valor: #tirarlo para la derecha if self.der is None: ...
75588a0642edc35261a335ef42689569371791e7
plankobostjan/practice-python
/09GuessongGame1
412
3.953125
4
#!/usr/bin/python while 1: from random import randint while 1: guess = raw_input("Try to guess number between 1 and 9: ") rnd = randint(1,9) if guess > rnd: print "Your guess is too high. Try again." if guess < rnd: print "Your guess is too low. Try again." else: print "Your guess is correct. Congr...
3ce9bbffe0b7c18cd769044a9025a93d15ed63f6
plankobostjan/practice-python
/18CowsAndBulls
926
3.65625
4
#!/usr/bin/python import random def compare_numbers(num, usr_guess): cowbull = [0,0] count = 0 for i in range(len(num)): if num[i] == usr_guess[i]: cowbull[0]+=1 else: for n in range(len(num)): if usr_guess[n] == num[i]: cowbull[1]+=1 #if count < 1: # cowbull[1]+=1 #count+=1 return...
48f66179f1257b896dff5cfe6db8b55c5c7ce6a7
divyang2401/Artificial-Intelligence
/HW2/Answers_code_2/Code/Greedy.py
1,467
3.5
4
graph={ 'a': set(['b','c']), 'b': set(['a','d']), 'c': set(['a','d','f']), 'd': set(['b','c','e','s']), 'e': set(['d','h','s','r']), 'f': set(['G','c','r']), 'G': set(['f']), 'h': set(['e','p','q']), 'p': set(['s','q','h']), 'q': set(['p','h']), ...
376f01e5877c615cccf758dfdcbca79bfd768dd2
williamg/autolingua
/generate_words.py
868
3.640625
4
import sys import random vowels = ["i", "e", "a", "u", "o", "ai"] consonants = ["m", "p", "b", "f", "n", "t", "d", "s", "l", "k", "g"] complex_onsets = ["fl", "sl", "pl", "kl"] complex_codas = ["st", "nd"] complex_codas.extend([x + "s" for x in consonants]) complex_codas.remove("ss") num_syllables = 3 num_words = 30 ...
45a47331c0eb02b3479c26240dd29c673e9b9c94
Bchass/Neural-Network
/Feedforward/Sigmoid.py
296
3.515625
4
import numpy as np class Sigmoid: def _init_(self): self.W = None #weights self.B = None #biases # forward pass def perceptron(self, x): #take weights and biases return np.dot(x,self.w.T) + self.B # sigmoid function def Sigmoid(self,x): return 1.0/(1.0+np.exp(-x))
46a5401b3d869d61c0ab7f228197b622f096654b
zyq-roxanne/python-homework
/homework2/5Miller_Rabin.py
1,586
3.671875
4
#Miller_Robin import time def Miller_Robin(n): t = 0#calculate t and u through loop u = n-1 while u % 2 == 0: u = u // 2 t += 1 test = [2,3]#testcase, note that it is a necessary condition, but not sufficient one index = 0#decide which number for test, here we verify 2 first whi...
386670e9d48935c5370542a7d0e8b6c6cef2de4e
termuxuser01/notepad.py
/notebook.py
1,503
3.796875
4
from datetime import datetime last_id = 0 class Note: def __init__(self, memo="Empty Note", tags=""): """give option to add attributes to note upon creation""" if input("write a memo? y/n: ".lower()) == "y": self.memo = input("what will your memeo be?\n") else: self.memo = memo if input("...
5ffa28040ce647b1b9a1cc008e27b8e07e0a1d16
alyssatrann/CodeWars
/Prob18.py
349
3.5625
4
while True: try: [H, M] = map(int, input().split(':')) angle_mins = M * 6 angle_hours = H * 30 + M * 0.5 angle = min((angle_mins - angle_hours) % 360, (angle_hours - angle_mins) % 360) print(f'The angle between the Hour hand and the Minute hand is {angle:.2f} degrees') ex...
f5821db2abdcd8e7891babd1d609daa705e6f9a2
xantov/py
/led.py
1,958
3.609375
4
#Create 7x5 LED Matrix Numbers import os from termcolor import colored os.system('color') num = str(input('Input your numbers (0-9): ')) number = [] for n in num: if n in [str(i) for i in range(10)]: number.append(n) on_led = str(input('LED style (@,#,X,O) [Optional]: ')) space ...
d1dd06381234336fe79b3f0178f224da7e89a2e3
PyLadiesTokyo/pyladies-tokyo-homework
/answers/003/answer2.py
547
3.6875
4
# 1から100までの素数を求める(関数利用) def check_prime(num): if num < 2: # 2未満は素数ではない return False elif num == 2: # 2は素数 return True elif num % 2 == 0: # 偶数は素数ではない return False # 奇数を確認 for i in range(3, num, 2): if num % i == 0: re...
92de88c7753df2868627d5f0ffe730b0ec872997
Ryanme513/my-first-python-project
/list.py
2,032
4.1875
4
#names = ["jenny", "alexus", "sam", "grace"] # names = ["jenny", "alexus"] #print(names[0,0]) # names_and_heights = [["jenny", 67], ["alexus", 70]] # print(names_and_heights[0][1]) #prints only the name # # print(names_and_heights[0][0]) + " is " + str(names_and_heights[0][1] + " inches tall") #prints name and heigh...
c4a61598fb9f02e6cf0066dbaed3a8fd3c8a6d95
Ryanme513/my-first-python-project
/Math_&_Operators.py
1,205
4.21875
4
# x = 1 # y = 2 # z = 3 # print(x*y) Multiplying # print(x/y) Divion # print(x**y) Exponent # x = 5 # x += 2 # print(x) # if(5 > 7): # print("hello") # else: # print("goodbye") # expression= "hello" if 6 >=6 else "goodbye" # orint(expression) # sale= True # store_message = "Hello, we have a sale today!" i...
1a6adb0cf7a488bcc72444893aecabea09ace35a
Ryanme513/my-first-python-project
/loops.py
2,420
3.796875
4
# names = ["alex", "john", "ryan", "ramiro", "andrew", "jordan"] # for name in names: # print(name) # rng = list(range(6)) # print(rng) # lst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] # for num in lst: # print(num) # for index in range(len(lst)): # lst[index] = 2 * lst[index] # print(lst[index]) # lst = [1,...
000e6c9d9201b79142180985caca43a19d7333f2
random-weights/prime_numbers
/main.py
4,694
3.921875
4
""" Using python multiprocessing and little common sense, this algorithm can list out all prime numbers before n. Run time complexity is yet to be determined. will be updated in later commits. """ import time from multiprocessing import Process, Pipe, Manager import os def distributor(ls_feed_pipe_open,low,high): ...
0f60ea86190558add32cc07c0d6bd1a9dde4b00e
baiyexing/wc
/wc/.idea/wc.py
3,818
3.734375
4
import sys import os if len(sys.argv ) < 3: print ("输入参数错误") else : func = sys.argv[1] func2 = sys.argv[2] def readfile(name): list = os.listdir(os.getcwd()) if name in list: with open( name, "r", encoding = "gbk") as file: chars = ...
492ded8dabe141c7e2b6a2ae030cca6d5bc8d813
fukumoto94/PythonStudy
/CursoemVideo/Desafio18-ValorSenoCosTan.py
165
3.890625
4
import math a = int(input('Digite ângulo: ')) a = math.radians(a); print('Seno: {:.2f} \n Cos: {:.2f}\n Tan: {:.2f}'.format(math.sin(a), math.cos(a), math.tan(a)))
959cb9d69f67bb630805df83d059cd88346a82a1
fukumoto94/PythonStudy
/CursoemVideo/Desafio6-RaizQuadrada.py
107
3.546875
4
n1 = int(input('Digite: ')) print("Dobro: {}\nTriplo: {}\nRaiz Quadrada: {}".format(n1*2, n1*3, n1**(1/2)))
c896ebc1239d4000d5e5c131a79a2e10c0a2dd84
Rajueleti/simple-maths
/Python/common_divisors.py
469
4.1875
4
def gcd(n1, n2): """ Non-Recursive function to return the GCD of n1 and n2 """ if n1 < n2: n1, n2 = n2, n1 while n1 % n2: n1, n2 = n2, n1 % n2 return n2 def gcd_recursive(n1, n2): """ Recursive function to return the GCD of n1 and n2 """ if n1 == 0: retu...
c82583841fa4830a82c6675b9a556fef4100c9aa
alrus2797/ToBD
/lab1/data.py
2,649
3.703125
4
import csv class Data: def __init__(self, _file): if _file.mode != 'r': return self.data = {} self.reader = csv.reader(_file, quoting=csv.QUOTE_ALL) self.relations = [] self.headers = [] for row in self.reader: # Headers ...
ea13650b3e2ac564bac3f67808ea0900d09f8b45
dieuhah/depot_rapport
/ProjetProba/IA_3_bis.py
13,808
3.71875
4
#!/usr/bin/env python # coding: utf-8 # In[77]: import random # In[78]: class Player: # Abstract base class def __init__(self): self.profits = 0 self.card = None def set_card( self, card): self.card = card def get_bet( self): raise NotImplementedErro...
d0e2a7d11407d8773b1a2866156a3d7bafd8700b
VicDCruz/minimax-game-implementation
/Tictactoe.py
2,163
4.21875
4
""" Programa que implementa reglas básicas para jugar el juego de Gato (Tic-Tac-Toe) """ from Gameboard import Gameboard from copy import deepcopy SCORE = 10 def canMove(board): """ Checar si hay movimientos disponibles """ for i in range(3): for j in range(3): if (board[i][j] == "...
70849bed290c6b343b37b3299427f56209c33ff7
onejajae/LinearAlgebra
/linearequation/gauss_jordan_elimination.py
2,817
3.78125
4
from matrix import Matrix from vector import Vector def augmenting(matrix, uv): if len(matrix) != len(uv): return else: for i in range(len(matrix)): matrix[i].append(uv[i]) return matrix def forward_elimination(matrix): for i in range(1,len(matrix)): if matrix[i-1...
2f773fcbbe5018423e273f546f4180e9653e738b
cortesgnicolas/informatorio2020
/Fernando_enrique/ejercicio1.py
1,509
3.71875
4
class Persona: def __init__(self, nombre, dni): self.nombre = nombre self.dni = dni self.data = {} def __str__(self): return "es de clase Persona {}".formar(self.dni) class Paciente(Persona, Otra_clase): def __init__(self,nombre, dni, historia_clinica): Persona.__init__(self,nombre,dni) self.historia_cl...
88b3f9d34ee97bfcf972a1b7999f8ec143b4740c
cortesgnicolas/informatorio2020
/Rodrigo_Saforcada/caso3POO.py
760
4.03125
4
class triangulo: def __init__(self, lado1, lado2, lado3): self.lado1 = lado1 self.lado2 = lado2 self.lado3 = lado3 class tipo_de_triangulo(triangulo): def __init__(self, lado1, lado2, lado3): triangulo.__init__(self, lado1, lado2, lado3) def segun_lados(self): lista_auxiliar = [self.lado1, self.lado2, se...
40b04dc812d39904429dc0b2cbee3d4000d3f017
cortesgnicolas/informatorio2020
/Paula Herrera/caso_4.py
772
3.84375
4
class Contacto(): def __init__(self, nombre, telefono, email): self.nombre = nombre self.telefono = telefono self.email = email #Solucion 2 #Metodo ''' def aniadir(self): agenda[self.nombre] = [self.telefono, self.email] ''' class Agenda(): def __init__(self): self.lista_de_contactos = [] def aniadir(...
d10c1166aa6e58a2bcc33f12e69e9c1f2de0de62
hitarth-pixel/class97
/class97pro7.py
225
3.78125
4
pocketMoney=int(input("enter your pocket money")) if(pocketMoney>500): print("you are rich") elif(pocketMoney>100): print("you have a good life") else: print("sorry for not getting sufficient pocket money4")
cb77806dfb58f7186f91516a08222858be77e893
LiamWilliams1/prac_02
/files.py
378
3.609375
4
name = (input("whats your name")) out_file = open ("name.txt" ,"w") print(name, file=out_file) out_file.close() in_file = open("name.txt", "r") name = in_file.read().strip() print("Your name is", name) in_file.close() in_file = open("numbers.txt" , "r") first_num = int(in_file.readline()) secound_num = int(in_file.re...
8d1cae79359cd3b420177bc4b1140183ed007866
SanjayDalvai/Selenium
/Excel_Read.py
301
3.703125
4
import openpyxl path="D:\data3.xlsx" workbook=openpyxl.load_workbook(path) sheet=workbook.active rows=sheet.max_row cols=sheet.max_column print(rows) print(cols) for r in range(1,rows+1): for c in range(1, cols + 1): print(sheet.cell(row=r,column=c).value,end=" ") print()
473325caef14ae513d0b8b08addb4f091ef69b9a
Jayant211998/IBM-Training
/Assignments/PythonProgram/Assign2/ques5.py
206
3.515625
4
s=list(input()) d=0 l=0 for i in s: if (ord(i)>=65 and ord(i)<=93) or (ord(i)>=97 and ord(i)<=123): l+=1 if ord(i)>48 and ord(i)<58: d+=1 print("letter",l) print("digits",d)
d71a34206f919d6fa3519c473cfa3247ea882538
Jayant211998/IBM-Training
/Assignments/PythonProgram/Assign2/ques6.py
460
3.5625
4
password=list(input()) pt=0 if len(password)>=6 and len(password)<=16: pt+=1 l=[i for i in range(48,57)] for i in l: if chr(i) in password: pt+=1 break l=[i for i in range(65,93)] for i in l: if chr(i) in password: pt+=1 break l=[i for i in range(97,123)] for i in l: if chr(i) in password: ...
a2f31fe914bde6c2a8e179f87ea1c72a46e118be
uwaiseibna/pythonall
/fb.py
870
3.515625
4
from datetime import datetime, time from pytz import timezone def razibvai(givenmins, bool): pacific= timezone('US/Pacific') now = datetime.now(pacific) time = now.strftime("%H:%M:%S") hours = int(time[:2]) mins=int(time[3:5]) secs=int(time[6:8]) total = hours*60+mins if (bool =...
3e579286fab24b1869e16cad5977f7c52a8e5e2a
Yasmojam/DoYouHaveTheGuts2019
/src/utils.py
1,857
3.828125
4
from typing import Tuple import math Vector = Tuple[float, float] def heading_from_to(p1: Vector, p2: Vector) -> float: """ Returns the heading in degrees from point 1 to point 2 """ x1 = p1[0] y1 = p1[1] x2 = p2[0] y2 = p2[1] angle = math.atan2(y2 - y1, x2 - x1) * (180 / math.pi) ...
a47735f0834584af2840c45391f138abd637ede6
Hye2019/mini-projects
/Game/turtle_game.py
14,955
4.09375
4
''' Turtle Game Nano-framework A set basic functionality for games where the 'Player' controls a turtle, moving it around within a bounded 'Arena' and interacting with 'Bugs' Turtle is controlled by three keys: FOWARD, LEFT, RIGHT Author: J. Fall (based on original idea from T...
bf2cd7240fd67dc063e58990fb78c22018ac2fb8
andyd0/foobar
/level_3/the_grandest_staircase_of_them_all.py
1,391
4.125
4
# The Grandest Staircase of Them All def solution(n): # since n will always be at least 3, no point in building cache # etc if we know it's going to be 1. if n == 3: return 1 # memo is used to avoid retrying any sub solution that may # occur during recursion. +2 is needed for size as height is increment...
136020250218e0816daf3f5a76a2aabecda8bf55
venkataramadurgaprasad/Python
/Python-For-Everybody/Python Data Structures/Week-4/Assignment_8.5.py
855
4.375
4
''' 8.5 Open the file mbox-short.txt and read it line by line. When you find a line that starts with 'From ' like the following line: From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008 You will parse the From line using split() and print out the second word in the line (i.e. the entire address of the person ...
7cd30eec69de09ff73a7c34f70c9c1cb5bb12a5c
nagasaimanoj/Python-Trails
/Basics/Basic_Syntax/regular_expressions.py
356
4.03125
4
from re import findall, match, search inpstrng = input("input string : ") key = input("input key : ") if match(key, inpstrng): print("re.match - Match") else: print("re.match - No match") if search(key, inpstrng): print("re.search - Match") else: print("re.search - No match") print("re.findall - " ...
e46a2b51e165feeebd3218c08b5b0f438ed7a755
nagasaimanoj/Python-Trails
/Basics/Basic_Syntax/getter_method_for_property.py
514
3.734375
4
class Pizza: def __init__(self, toppings): self.toppings = toppings self._pineapple_allowed = False @property def pineapple_allowed(self): return self._pineapple_allowed @pineapple_allowed.setter def pineapple_allowed(self, value): self._pineapple_allowed = value ...
eb4139e7f7c748ce66c0722720717e64decfa26a
nagasaimanoj/Python-Trails
/Basics/Basic_Programs/Prime_Factors.py
481
3.890625
4
n = int(input("Enter a number : ")) prime_factors = [] for i in range(2, n): is_prime = True for j in range(2, i): if (i % j == 0): is_prime = False if (is_prime and n % i == 0): prime_factors.insert(len(prime_factors), i) if (len(prime_factors)): for i in range(len(prime_f...
ddcddc8a2231a5c26aedd431667a39940bd8c126
nagasaimanoj/Python-Trails
/Basics/Files/Excel/Reading/excel_reader.py
379
3.65625
4
import xlrd input_file = "../sample_excel.xlsx" input_workbook = xlrd.open_workbook(input_file) for each_sheet in input_workbook.sheets(): number_of_rows = each_sheet.nrows number_of_columns = each_sheet.ncols for each_row in range(1, number_of_rows): for each_col in range(number_of_columns): ...
b93f002ff7258fc73b7397fe053f6ffdb3bb640d
nagasaimanoj/Python-Trails
/Basics/Basic_Syntax/property_method.py
249
3.609375
4
class Pizza: def __init__(self, toppings): self.toppings = toppings @property def pineapple_allowed(self): return False pizza = Pizza(["cheese", "tomato"]) print(pizza.pineapple_allowed) pizza.pineapple_allowed = True
a1eb51225d3356c79fcd0b811d69355a0acf8093
Eileen-Yu/snippet
/lunarLander.py
2,879
3.703125
4
import re ALTITUDE = 100 VELOCITY = 10 FUEL = 1000 STEP = 0 def match(regex, raw_str): if re.match(regex, raw_str) is not None: return True return False def yes(y_str): return match("[yY].*", y_str) def no(n_str): return match("[nN].*", n_str) def set_integer(param_name): while True...