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
c5e26c0c95208e20485c90d9a05f291be512c9ad
rahulcode22/Data-structures
/Binary-Search/Rotated-Array-search.py
1,003
4.0625
4
''' Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2 ). You are given a target value to search. If found in the array, return its index, otherwise return -1. You may assume no duplicate exists in the array. ''' def sortedarraySearch(arr): ...
1407860af79d4aed39a225915441e0c62a08482d
rahulcode22/Data-structures
/Stack/Balanced-Expression.py
2,033
3.90625
4
class Stack: def __init__(self): self.items = [] #Push a new item to the last index def push(self,item): self.items.append(item) #Remove the last item def pop(self): #if stack is empty if not self.items: return None return self.items.pop() ...
293bce70695f8d184618186c064544e2afdd8e61
rahulcode22/Data-structures
/LinkedList/Rotate-List.py
553
3.6875
4
''' Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL. ''' def rotate(self,k,head): if k == 0: return head count = 1 curr = head while count < k and curr is not None: curr = curr...
de2a87222f29708f7661c139a7f8f8eb3697e0d2
rahulcode22/Data-structures
/Arrays/Count-The-Triplets.py
508
3.921875
4
#Given an array of distinct integers. #The task is to count all the triplets #such that sum of two elements equals the third element. #Complexity O(n^2) def findTriplet(arr): arr.sort() n = len(arr) i = n-1 count = 0 while(i>=0): j=0 k=i-1 if (arr[i]==arr[j]+arr[k]): ...
387179e6134508a1d71e818542318548d568258b
rahulcode22/Data-structures
/Math/FizzBuzz.py
670
4.125
4
''' Given a positive integer N, print all the integers from 1 to N. But for multiples of 3 print “Fizz” instead of the number and for the multiples of 5 print “Buzz”. Also for number which are multiple of 3 and 5, prints “FizzBuzz”. ''' class Solution: # @param A : integer # @return a list of strings def fi...
f675a20b4fb1b4acd7b8ca903097b07a666909f2
rahulcode22/Data-structures
/Tree/level-order-traversal.py
952
4.125
4
class Node: def __init__(self,key): self.val = key self.left = None self.right = None def printLevelOrder(root): h = height(root) for i in range(1,h+1): printGivenOrder(root,i) def printGivenOrder(root,level): if root is None: return if level == 1: p...
9e0af4b793796a17b7bc294ed5e436b3357cb39c
rahulcode22/Data-structures
/Stack/Introduction.py
1,730
3.859375
4
'''-->It is a linear data structure. -->Follows a paarticular order in which the operations are performed.' -->Order may be FILO or LIFO -->Main operations are 1)push-->Add an item in the stack 2)pop-->removes an item in the stack 3)peek-->get the topmost item. -->stack may be implemented using two ways: ...
f79d1e2d07f4cafe0476ee98b872dc3e78b37868
rahulcode22/Data-structures
/Arrays/find-permutations.py
594
3.671875
4
"""Given a positive integer n and a string s consisting only of letters D or I, you have to find any permutation of first n positive integer that satisfy the given input string. D means the next number is smaller, while I means the next number is greater.""" def findPerm(arr, b): ans = range(1,b+1) cnt = 0 ...
7a2e7a3eab9085d43383e79ca3c894b9390bc947
rahulcode22/Data-structures
/Math/Rearrange-Array.py
258
3.90625
4
''' Rearrange a given array so that Arr[i] becomes Arr[Arr[i]] with O(1) extra space.Don't return anything. ''' def RearrangeArray(arr): for i in range(len(arr)): arr[i] +=(arr[arr[i]]%n)*n for i in range(len(arr)): arr[i] = arr[i]/n
ba2d6b6297ea813c6fbfd92782aada21cb368555
rahulcode22/Data-structures
/Doublylinkedlist/DLL_insertion.py
1,145
4.28125
4
#Insertion at front def insertafter(head,data): new_node=node(data) new_node.next=head new_node.prev=None if head is not None: head.prev=new_node head=new_node #Add a node after a given node def insertafter(prev_node,data): if prev_node is None: return #Allo...
908db575b0369524812158fa035e8a889dcde904
rahulcode22/Data-structures
/LINKEDLIST/LL_INTRO.py
381
3.859375
4
#uses python2 Class Node: def __init__(self,data): self.data=data #intializes data self.next=None Class Linkedlist: def __init__(self): self.head=None #initializes head #Main Part if __name__ =='__main__': ll=Linkedlist() ll.head=Node(1) ll.second=Node(2) ll.third=Node(3...
2732fdac88b377e88ad1e1f3d3ee265634029499
rahulcode22/Data-structures
/String/Roman-To-Integer.py
860
3.9375
4
''' Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. ''' def value(num): if num == 'X': return 10 if num == 'I': return 1 if num == 'V': return 5 if num == 'L': return 50 if num == 'C': return 100 ...
c4e9f170df7444eae3616c5a6c6fbd7a6bcf63bf
rahulcode22/Data-structures
/Tree/Binary-Search-Tree-Search.py
218
3.5625
4
def binarySearchTree(root,key): if root is None or root.val == key: return root if root.val>key: return binarySearchTree(root.left,key) else: return binarySearchTree(root.right,key)
f56206ae7bf6a260b23f55ad30a966450a661c45
mahendrap1512/TicTakToe-Game
/tictaktoe.py
4,568
3.53125
4
class TTTBoard: def __init__(self): self.board = [[-1,-1,-1],[-1,-1,-1],[-1,-1,-1]] self.moves = 1 def __str__(self): #try(IndexError): if self.moves == -1: print("| _ _ _ |") print("| _ _ _ |") print("| _ _ _ |") else: ...
18208ba62478503b314bb7cae82f24194e732050
cassiakaren/Manipulando-Textos
/aula09.py
867
4.5
4
#FATIAMENTO '''frase='Curso em Video Python' print(frase[3])#vai printar a quarta letra frase='Curso em Video Python' print(frase[:13])#vai de um caracter a outro frase='Curso em Video Python' print(frase[0:15:2])#vai de um caracter a outro pulando de 2 em 2 frase='Curso em Video Python' print(frase[::2]) frase='Curso ...
ae2b3d17edb1e68ecb2730d96918cea4954cf3b3
PavlinKolev/Hack-Bulgaria-Python-101-v5
/Week03/Polynom/polynom.py
1,523
3.625
4
from parser import Parser from monomial import Monomial class Polynom: def __init__(self, polynom_): if type(polynom_) == list: self.list_monomials = polynom_ elif type(polynom_) == str: self.list_monomials = Parser.to_polynom(polynom_) else: raise TypeE...
71c213aba647430ee8d79a61ea039fa4a803c648
PavlinKolev/Hack-Bulgaria-Python-101-v5
/Week01/Extra Tasks/Goldbach Conjecture/goldbach_conjecture.py
538
3.59375
4
import math def is_prime(n): if n <= 1: return False if n == 2: return True for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: return False return True def goldbach(n): goldbach_list = [] visited = [] for i in range(2, n): if is_prime(i):...
938b222fdc748746bfb17c58495d622446d2e5f3
PavlinKolev/Hack-Bulgaria-Python-101-v5
/Week12/Generators/book_generators.py
1,536
3.6875
4
import os import string import random ALL_SYMBOLS = string.ascii_letters + string.digits + string.punctuation MIN_WORD_LEN = 3 MAX_WORD_LEN = 15 DEFAULT_BOOK = "book.txt" def book_reader(book_directory): pages = filter(lambda f: f.endswith('.txt'), os.listdir(book_directory)) for page in pages: with...
220acb592bbdf3f4d4be0a7cdde0a9c751050a6d
PavlinKolev/Hack-Bulgaria-Python-101-v5
/Week07/MusicLibrary/test_song.py
2,317
3.53125
4
import unittest from song import Song from hour import Hour class TestSong(unittest.TestCase): def setUp(self): self.song_1 = Song("Alone", "Alan Walker", "Alan Walker", "02:43") self.song_2 = Song("Cheap Thrills", "Sia", "This Is Acting", "03:31") def test_str(self): self.assertEqual...
cb09b61463fdf4e480b4dc005bf1f5e8bd2136b3
PavlinKolev/Hack-Bulgaria-Python-101-v5
/Week06/Tree and FlattenFyleSystem/tree_node.py
775
3.640625
4
class Node: def __init__(self, value, level=0): self.value = value self.children = [] self.level = level def __str__(self): if self is None: raise TypeError("Cannot cast to string None Node!") return str(self.value) def __repr__(self): return sel...
34c8b58f232e69083da6849cf28ed41c4703e9b2
ZhongXinWang/python
/objectAdvance.py
1,488
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #Author:Winston.Wang print('-------高级特性------------') #__slots__限制对象属性被调用 class Person(object): #设置运行被对象直接访问的属性 __slots__=('name','age') def __init__(self,name,age): self.name=name self.age = age def toString(self): return self.name,self.age print('-------------...
9f621a938ac05ed35e5318bc17df2d6b79661934
ZhongXinWang/python
/objectMessage.py
1,321
4
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #Author:Winston.Wang print('---------------获取对象信息-----------------') #判断对象类型 type,<class 'int'> print(type(123)) print(type('hello')) #判断函数 print(type(abs)) #判断类型是否相同 if(type(123) == type(456)): print('相同类型') #isinstance类型判断对象 class Animal(object): def __init__(self): ...
be17b6deb0485ddc0b6b95280313b6fdb76b8361
ZhongXinWang/python
/extend.py
592
3.90625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #Author:Winston.Wang print('--------------------继承----------------------') #定义一个Aniaml类 class Animal(object): def run(self): print('Animal 动物类') #定义Dog类继承自Animal class Dog(Animal): def run(self): print('Dog run.....') #定义Cat类 class Cat(Animal): def run(self): pri...
d2410a28755f765a70dc5aa2850ae5efe856c463
ranizz2000/Python-by-doing
/Files/csv_file.py
286
3.65625
4
f = open('csv.txt', 'r') lines = f.readlines() lines = [line.strip() for line in lines[1:]] f.close() for line in lines: person = line.split(',') #print(person) print(f'{person[0].title()} is {person[1]} years old and is studying {person[2].capitalize()} at {person[3]}')
bdac003337a8bd9e294a84a5108a287eb2fd7976
SamanehGhafouri/Data-Structures-and-Algorithms-in-python
/Experiments/most_duplicated_O(n^2).py
943
3.953125
4
# ### Find the most repeated number in an array ## # # The time complexity is O(n^2) def most_frequent_num(arr): if len(arr) == 0: return 0 most_rep_num = arr[0] most_rep_num_count = arr.count(arr[0]) for num in arr: if arr.count(num) > most_rep_num_count: most_rep_num_co...
2485e35e9c0b727184080c6cc55408ebf7f9c6c2
SamanehGhafouri/Data-Structures-and-Algorithms-in-python
/Recursion/ch4.7_Exercises.py
3,575
3.921875
4
# R-4.1 Recursive function for finding a max element inside array def recursive_max(i, j, array): if j >= len(array): return array[i] else: if array[j] > array[i]: i = j return recursive_max(i, j+1, array) some_array = [3, 2, 5, 1, 4] max_val = recursive_max(0, 0, some_arra...
d3123c6a569f57767865a6972bde32d3b858d348
SamanehGhafouri/Data-Structures-and-Algorithms-in-python
/Experiments/find_largest_element.py
676
4.3125
4
# ######### Find the largest element in array ######## def largest_element(arr): if len(arr) == 0: return None max_num = arr[0] for i in range(len(arr)): print(i, arr[i]) if arr[i] > max_num: max_num = arr[i] return max_num ar = [90, 69, 23, 120, 180] print(largest...
5692a8e56f59808656816b733166021af8f5d3c1
SamanehGhafouri/Data-Structures-and-Algorithms-in-python
/Sorting/bubble_sort.py
682
4.3125
4
# Bubble sort: takes an unsorted list and sort it in ascending order # lowest value at the beginning by comparing 2 elements at a time # this operation continues till all the elements are sorted # we have to find the breaking point # Time Complexity: best case: O(n) # average and worst case: O(n^2) de...
e35fd14187b0b277064bfc4d2019079376ba4781
SamanehGhafouri/Data-Structures-and-Algorithms-in-python
/Recursion/reverse_str.py
516
4.15625
4
# C-4.16 reverse a string def reverse_str(string): if len(string) == 0: return '' # we cut the first character and put it in # the back of the string each time else: ...
f4c946984653fc122f2ebbf06f6dbae4a67e9c35
maguilarga/python-challenge
/PyBank/main.py
2,731
3.640625
4
# Import the necessary dependencies for os.path.join() import os import csv Revenue = 0 NumMonths = 0 Change = 0 SumChange = 0 Grt_Inc_Dec = ["", 0, "", 0] # Specify path and file name # csv_file = os.path.join(".", "budget_data.csv") csv_file = os.path.join(os.sep, "Rice", "Data_Analytics", "RICEHOU201906DATA1", "HW...
27b529536e038d33bba898892f812c6a4627a5f4
sk-timan/python-practice
/code/python小技巧.py
943
4.0625
4
text='hello!\nmy name is Lisa.\nwelcome!' file_1=open('test file.txt','w') file_1.write(text) file_1.close() append_text='\nThis is an appended file' file_2=open('test file.txt','a') file_2.write(append_text) file_2.close() file_3=open('test file.txt','r') content=file_3.readline() print(content) ...
b46bf6cfa00972a1f64efeba45e8ff5d56e54e35
SachinKtn1126/python_practice
/12_dictionaries.py
1,009
4.03125
4
# Title: Dictionaries in Python # Author: Sachin Kotian # Created date (DD-MM-YYYY): 08-12-2018 # Last modified date (DD-MM-YYYY): 08-12-2018 # # ABOUT: # This code is to try and test how to use dictionaries in python # Defining dictionaries day_con...
7a37455274916403acdee17331216be6d7cc0810
SachinKtn1126/python_practice
/11_better_calculator.py
905
4.40625
4
# Title: Creating a better calculator # Author: Sachin Kotian # Created date (DD-MM-YYYY): 07-12-2018 # Last modified date (DD-MM-YYYY): 07-12-2018 # # ABOUT: # This code is to create a better calculator using if else statement and user input. # Inpu...
ab0ca448a75ff4094c8c7cfe7f112647a22ec37d
SachinKtn1126/python_practice
/10_if_statements_comparisons.py
1,217
4.15625
4
# Title: If statement in python # Author: Sachin Kotian # Created date (DD-MM-YYYY): 07-12-2018 # Last modified date (DD-MM-YYYY): 07-12-2018 # # ABOUT: # This code is to try and test the working of if statement # Defining boolean variables is_male ...
8b332841b0b610e92db2f959da5a630244169c48
asilva111/CS3_Lab_2_Sorting
/LinkedListModelCode.py
3,090
3.921875
4
# -*- coding: utf-8 -*- """ Created on Thu Feb 21 19:19:10 2019 CS 2302 - Andres Silva > Teacher: Olac Fuentes > TAs: Anindita Nath & Maliheh Zargaran > Lab #2 - Linked list Class > LAST MODIFIED: FEB 27th, 2019 """ #Node Functions class Node(object): # Constructor def __init__(self, item, next=No...
9a577d09d85e0734036286b15871cbbe262bbd6f
LeeGeunHAHAHA/AlgorithmStudy_MathPuzzle
/Q21_linked_listLoop/Main.py
1,448
3.921875
4
class Node : data = None next_node = None def __init__(self,data): self.data = data next_node = None def __str__(self): return str(self.data) def setNext(self,nextNode): self.next_node=nextNode class LinkedList : head = None def __init__ (self,head): ...
01433373555daaec9f419cef021fa02359487488
LeeGeunHAHAHA/AlgorithmStudy_MathPuzzle
/Q83_boj_2986/Main.py
159
3.515625
4
import math n = int(input()) r = int(math.sqrt(n)) for i in range(2,r+1): if not n%i : print(n-(n//i)) break; if i == r : print (n-1)
59c5a2ae50f1b209f6d54abba1de1aad4289627c
ErioY/String_Apply-Python
/输出指定长度单词.py
461
3.84375
4
''' @Autor: ErioY @Date: 2019-10-08 19:08:19 @Email: 1973545559@qq.com @Github: https://github.com/ErioY @LastEditors: ErioY @LastEditTime: 2019-10-08 20:54:30 ''' # 编写程序,用户输入一段英文,然后输出这段英文中所有长度为3个字母的单词。 # str = input("please input sth: ") str = "abcd abb aa vvv" arr = [] arr = str.split() print("长度为3的单词为:") for i in ra...
a6e57d2ef26f9443e2e721ac51b5bba08cd90c1e
lila-yilmaz/alistirmalar-4.hafta
/soru2.2.py
201
3.546875
4
#Demetin içinde olan elemanlardan sadece str olanları yazdırma demet= (2,3,4,2,14,"Mustafa",132,"Kemal","Atatürk",5) for eleman in demet: if type(eleman) == str: print(eleman)
ea91b1724f8f13da13d8e1babdc342d01592d0b2
natnew/Python-Projects-Calorie-Calculator
/calorie counter.py
527
4.09375
4
#this is a calorie counter python program date = input("What day is it today: ") print(date) breakfast = input("How many calories did you have for breakfast? ") print(breakfast) lunch = input("How many calories did you have for lunch? ") print(lunch) dinner = input("How many calories did you have for dinner? "...
eb2fbacb42aafb1a8d39271d81c3b5a887ecd87c
BreezeDawn/LeetCode
/first/字符串/跳过/22. 括号生成.py
1,186
3.734375
4
# 深层递归 class Num22(object): def leetcode(self, n): res = [] self.generate(n, n, "", res) return res def generate(self, left, right, str, res): if left == 0 and right == 0: res.append(str) return if left > 0: self.generate(left - 1, rig...
01e645d87bc6d725f5db2c8dadf6441be98c9140
BreezeDawn/LeetCode
/first/字符串/中等/583. 两个字符串的删除操作.py
426
3.65625
4
class Num583(object): @staticmethod def leetcode(word1, word2): new_1 = '' new_2 = '' res = 0 for i in word1: if i in word2: new_1 += i for i in word2: if i in word1: new_2 += i return new_1,new_2 def mai...
46ea0c24947f2844bc04065b882e5dc5f8fc3e49
yurifarod/UVA-URI
/uri1036.py
276
3.515625
4
# -*- coding: utf-8 -*- a, b, c = map(float, raw_input().split()) delta = (b**2)-(4*a*c) if a == 0 or delta<0: print "Impossivel calcular" else: r1 = (-b + delta**0.5)/(2*a) r2 = (-b - delta**0.5)/(2*a) print "R1 = %.5f" %r1 print "R2 = %.5F" %r2
43a1408285af6394f4b42836abc5f707cb87f8c2
yurifarod/UVA-URI
/uri1008.py
182
3.71875
4
# -*- coding: utf-8 -*- num = int(raw_input()) horas = int(raw_input()) valor = float(raw_input()) salario = horas*valor print "NUMBER = %i" %num print "SALARY = U$ %.2f" %salario
a3ed24f11fd40c62c93995d1573f3494527eed16
pylixm/darker
/dark_os/Python生成目录树.py
4,230
3.515625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import optparse LOCATION_NONE = 'NONE' LOCATION_MID = 'MID' LOCATION_MID_GAP = 'MID_GAP' LOCATION_TAIL = 'TAIL' LOCATION_TAIL_GAP = 'TAIL_GAP' Notations = { LOCATION_NONE: '', LOCATION_MID: '├─', LOCATION_MID_GAP: '│ ', LOCATION_TA...
cbfd4a6bede79ffa30a01443ff486d131ef9223b
charmisuk/IOTA-randomseed
/random.py
259
3.5
4
import random def genSeed(): x = None chars = "9ABCDEFGHIJKLMNOPQRSTUVWXYZ" seed = "" while (len(seed) < 81): seed += chars[random.randint(0, len(chars) - 1)] print ("Generated random seed!\n") return seed print (genSeed())
2cbd500d923e7e094b98196cb36d0c45b41843c3
alfredvoskanyan/Alfred_homeworks
/Homeworks/Shahane/Alfred_Voskanyan_homework4/ex_4.py
252
3.65625
4
a = 10 try: print(a.name) except Exception as ex: print(type(ex).__name__) print("*******************************") try: print(a.name) except AttributeError: print("Object 'a' has no attribute 'name'") except: print("Unknown Error")
be3740694925b39b38a2fd0fce8a41995bb40fea
alfredvoskanyan/Alfred_homeworks
/Homeworks/Xoren/Alfred_Voskanyan_homework2/century.py
235
3.75
4
def get_century(n): return (n+99)//100 while True: year = int(input("Enter the year or 0 to exit")) if not year: print("Thanks") break print("Year: %s ---- Century: %s" % (year, get_century(year)))
7dccc8e023f5abc096fc502e0d456b73cf052aaa
alfredvoskanyan/Alfred_homeworks
/Homeworks/Shahane/Alfred_Voskanyan_homework2/ex_1.py
226
4.125
4
list1 = [3, 6, True, True, -1, "abc", (1, 2), [2, 3], 6] for i in range(len(list1)): if isinstance(list1[i], tuple): print("Count of elements are ", i) print("Tuple's index in list is :", i) break
7c8ed21aa7a00c013e0abc020f53392ee9b06d59
keene080324/myPythonProgram1
/test123/_123.py
1,488
3.515625
4
import calendar, time data=time.localtime() a=input("你的姓名是:") print("你好,"+a) e=int(input("你的生日年(只要填數字)是:")) while e>data[0]: e=int(input("這一年還沒到,請重新填寫:")) b=int(input("你的生日月(只要填數字)是:")) c=int(input("你的生日日(只要填數字)是:")) if b==1: if c<22: f="魔羯座" else: f="水瓶座" elif b==2: if c<20: f="...
8e5273d381763f0a9dda2457e2a06bdd6f6f40d4
keene080324/myPythonProgram1
/單位換算機/單位換算機.py
11,997
3.8125
4
while True: a=input("請輸入想要換算的單位類型的代號(1長度、2面積、3體積、4容量、5重量)或是輸入no結束計算:") while a!="1" and a!="2" and a!="3" and a!="4" and a!="5" and a!="no": a=input("請重新輸入想要換算的單位類型的代號(1長度、2面積、3體積、4容量、5重量)或是輸入no結束計算:") if a=="no": break elif a=="1": b=input("請輸入想要換的種類代號(1.mm→cm、2.cm→m、3.m→km、4.mm...
1158ecd21a9d6fb22ceec2603d66eafc624b30f8
rbiegacz/Udacity-DeepLearning
/Caffe/1st-nn-caffe2.py
480
3.53125
4
# Create the input data data = np.random.rand(16, 100).astype(np.float32) # Create labels for the data as integers [0, 9]. label = (np.random.rand(16) * 10).astype(np.int32) workspace.FeedBlob("data", data) workspace.FeedBlob("label", label) # Create model using a model helper m = cnn.CNNModelHelper(name="my first n...
ad58afd3f9f7bd9c9aa356441e25d9c5a70b89a7
EstebanLauKoo/testPython
/Note/Basic.py
6,379
4.125
4
''' this is just a note ''' import math import re ''' Setting a variable ''' job = 'hello' ''' Printing Hello World''' print('hello world') ''' Printing variable 'job' ''' print(job) ''' Printing a concatenation of Hello Nick''' print("Hello, " + "Nick") ''' Splitting a string according to :''' print("Hello:Nick"...
7b51e52736bda562c8c4192ac5d8e8b654f6252e
MaxLucio528/MalGraphProject
/queryFunctions/dateQuery.py
1,406
3.609375
4
''' Here we import the following libraries: 1 - rdflib: To query the graph, transform the data typed by the user in the Literal format. ''' from rdflib import Graph, Literal # Date query function. def dateQuery(g): ''' This variable is SPARQL command that looks for the Start Date, End Date and the broadca...
04ab890f85814db735b17fddef050dca0aec3adc
MaxLucio528/MalGraphProject
/animeGrapher.py
4,513
3.59375
4
''' Here we import the following libraries: 1 - time: To have a delay after 2 animes are obtained due to API limitations; 2 - graphGenerator: Function that generates the graph; 3 - getAnimeData: Function that gets the anime data. ''' import time from graphFunctions.graphGenerator import graphGenerator from graphFunct...
08abc91bd861813fce3895236859dd0765cb1fb4
green-fox-academy/criollo01
/week-04/day-02/garden.py
1,635
3.90625
4
class Garden(object): def __init__(self): self.plants = [] def add(self, plant): self.plants.append(plant) def water(self, amount): print("Watering with {} amount".format(amount)) self.watering = [] for plant in self.plants: if plant.needs_water() == "n...
71111a542b32a7815b1dd9c7f55ea93d3e75c2b0
green-fox-academy/criollo01
/week-02/day-05/palindrome_maker.py
299
4.3125
4
#Create a function named create palindrome following your current language's style guide. # It should take a string, create a palindrome from it and then return it. word = str(input("Write a word! ")) def palin_maker(word): new_word = word + word[::-1] print(new_word) palin_maker(word)
ade654e60e1e691637bb5a0bfd22191ac6cc08de
green-fox-academy/criollo01
/week-03/day-05/triangle.py
663
3.78125
4
from tkinter import * import random root = Tk() canvas = Canvas(root, width='300', height='300', bg = 'black') canvas.pack() colors = ["red", "orange", "yellow", "green", "blue", "violet"] def triangle(x, y,width): canvas.create_polygon(x - width/2, y - width/2, x + width/2, y - width/2, x, y + width/2, outline ...
601f2398b30c816fb76ee389a8a93995b98d2fa5
green-fox-academy/criollo01
/week-02/day-02/reverse.py
306
4.5625
5
# - Create a variable named `aj` # with the following content: `[3, 4, 5, 6, 7]` # - Reverse the order of the elements in `aj` # - Print the elements of the reversed `aj` aj = [3, 4, 5, 6, 7] # ---solution 1--- for i in reversed(aj): print(i) # # ---solution 2--- (nicer) print(list(reversed(aj)))
8a99f7dce9bd10620b7a1b39ae4ce85f5c6c26f4
green-fox-academy/criollo01
/week-03/day-03/11_purplesteps.py
298
3.859375
4
from tkinter import * root = Tk() canvas = Canvas(root, width='300', height='300') canvas.pack() x = 0 y = 0 def purple_steps(x, y): square = canvas.create_rectangle(x, y, x + 10, y + 10, fill="purple") for i in range(1, 20): x += 10 y += 10 purple_steps(x, y) root.mainloop()
eda38f1c9c530bd3d6d60498d101fb6d7bccce84
green-fox-academy/criollo01
/week-03/day-05/envelope.py
530
3.5
4
from tkinter import * import random root = Tk() canvas = Canvas(root, width='700', height='700', bg = 'black') canvas.pack() color = ['blue', 'green', 'red', 'yellow', 'brown', 'purple', 'white', 'orange'] def envelope(x, y, a, b): line = canvas.create_line(x, y, a, b, fill = random.choice(color)) i = 0 while ...
ea4caa7c3c6f309294c50d3e8eed001767461b13
green-fox-academy/criollo01
/week-03/day-01/doubled.py
222
3.6875
4
# Create a method that decrypts the duplicated-chars.txt def decrypt(file_name): with open(file_name) as f: text = f.read() decrypted = text[::2] print(decrypted) decrypt("duplicated-chars.txt")
f3439b9ae64a0476a7df6f3fa3eeaa96431b05b1
six9/CS-Berkeley
/61A/Lecture Notes/22.py
4,550
4
4
# Cycles def cycle_demo(): """A linked list can contain cycles. >>> s = Link(1, Link(2, Link(3))) >>> s.first = 5 >>> t = s.rest >>> t.rest = s >>> s.first 5 >>> s.rest.rest.rest.rest.rest.first 2 """ # Bear Environment def oski(bear): """Oski the bear. >>> oski(abs)...
e0a0b7fd1a04153be16eb71f1bd7158e2905124a
pydanny/conference-talk-work
/extreme-zen/fib_wikipedia.py
164
3.53125
4
def fib_wikipedia(n): if n < 2: return n else: return fib_wikipedia(n-1) + fib_wikipedia(n-2) for i in xrange(10): fib_wikipedia(i)
9efc9d8849d47ce7f49613ffc444e5a7398ba676
Ryednap/Maze-Game-using-AI-algorithms
/Red.py
2,323
3.5
4
from Setting import * from helper import * from math import ceil from Algorithms import Astar, Pair, BFS import pygame import random class Red: def __init__(self, App, x, y): self.App = App self.currPos = self.Scale(Pair(x, y)) self.nextPos = self.currPos self.dir = Pair(0, 0) ...
aefbde1daef14b3bd4ebc4b073d444d7d37d5848
danieltavares1301/alunos_matriculados
/tres.py
632
3.640625
4
class Aluno: # inicializando com nome do aluno e sua matricula def __init__(self, nome, matricula): self.nome = nome self.matricula = matricula self.nota1 = 0 self.nota2 = 0 self.trabalho = 0 # adicionando notas e trabalhos def addNotas(self, nota1, nota2, trabal...
e8168b59680941c01548278634f99b0c41aca8ac
chadfraser/Kattis-solutions
/(Py3)-Bank-Queue.py
1,825
3.90625
4
""" https://open.kattis.com/problems/bank A program to find the most money you can get from customers that must be served before various times. """ customer_dict = {} possible_money_to_collect = [] total_sum = 0 initial_input = input() initial_input_list = initial_input.split(' ') amount_people_in_queue = int(initia...
9d89274ce40b4e94ceea7f2e607db72624837da2
ok-fa/ICT4370-Week10-Project
/stocks.py
2,913
3.8125
4
''' Author: Fabio Okubo Date: 7/28/2020 Description: Week 7 Assignment ''' from datetime import date class Stock: ''' stock class ''' def __init__(self, symbol, purchase_price, current_price, quantity, \ purchase_date, investor_id, id): self.symbol = symbol self.purchase_pri...
bb6ecf43564c3c39b881f7a430936927e996f643
hkawabata/python-machine-learning
/script/classification/data_set_generator/data_set_generator.py
1,285
3.625
4
# -*- coding: utf-8 -*- import numpy.random import random def generate_two_circle_data_set(num, x1=1, y1=1, r1=1, x2=-1, y2=-1, r2=1): data_set = [] for i in range(num / 2): x = numpy.random.rand() * r1 * 2 - r1 y = numpy.random.rand() * r1 * 2 - r1 while x * x + y * y > r1 * r1: ...
ef6d10bd3be16a6142490fadd0af6a62c9840579
Mrsth/Data-Visualization
/Matplotlib/Histogram_plot.py
407
3.65625
4
import matplotlib.pyplot as plt import numpy as np from numpy import random x = random.randint(0,100,30) bins = 30 x_ticks = np.arange(0,100,5) # Bins is the number of bars required plt.hist(x, density=True, bins=30, ec="white", width=5 ) plt.xticks(x_ticks) plt.xlabel("X-axis") plt.ylabel("Y-axis") ...
f9d046503e2905395c8f5c52648cd7ebb8781435
brando90/hbf_tensorflow_code
/python_playground/multi_processing/mp_test1.py
510
3.734375
4
from multiprocessing import Pool import contextlib import time def my_code(x): time.sleep(2) xx = x*x print('x*x: ',xx) return xx num_pool_workers=1 # can be bigger than 1, to enable parallel execution with contextlib.closing( Pool(num_pool_workers) ) as po: # This ensures that the processes get close...
3093eed4f2d18b863ab04e37241327920b7903a9
brando90/hbf_tensorflow_code
/python_playground/quick_attempts/args_kwargs_pcatt_code.py
696
3.78125
4
>>> def f(*args): ... for arg in args: ... print arg ... >>> f(1) 1 >>> f(1,2) 1 2 >>> f(1,2, 3) 1 2 3 >>> def g(**kwargs): ... for k,v in kwargs.iteritems(): ... print k,v ... >>> g(a=1, b=2) a 1 b 2 >>> g(**{'a':1, 'b':2}) a 1 b 2 >>> def h(*args, **kwargs): ... pass ... >>> h(1,2,...
7bd1b55b56236299283fd2426ffac907c04c0f32
shreevatsa/misc-math
/mse_103377_binom_slow.py
1,825
3.65625
4
#!/usr/bin/env python from __future__ import division import math def binom(n, k): """Returns n choose k, for nonnegative integer n and k""" assert k >= 0 assert n >= 0 assert k == int(k) assert n == int(n) k = min(k, n - k) ans = 1 for i in range(k): ans *= n - i ans //...
5e8897617fa52414cab764181f2a2a8d72ab5dab
shreevatsa/misc-math
/cardguesswrong-old.py
2,584
3.84375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from fractions import Fraction ''' The probability of making it through a deck of cards without guessing any card correctly, assuming optimal strategy. http://math.stackexchange.com/questions/43588/failing-to-guess-each-card-in-a-deck/43813#43813 ''' memo = {} ncalled = 0...
d8cbc5f1f1e55658aa1a706374b53c76d2a35717
mridulganga/ipl7
/Prelims/Solutions/namit.py
965
3.59375
4
str_main = "" def revstr(s): return s[::-1] def getword(s,n): st = s.split(" ") st = filter(None, st) # fastest return st[n] def wordcount(s): st = s.split(" ") st = filter(None, st) # fastest return len(st) def shrink(w): st = list(w) i =0 st2=[] for x in st: if i%2...
e49c9b3d1995b22f296afb9a607aaa2977fbbbe3
chen-bowen/Natrual_Language_Processing_Projects
/sentiment_analysis/sentiment_analysis/utils/word_tokenizer.py
801
3.640625
4
import nltk from nltk.corpus import stopwords from nltk.stem import WordNetLemmatizer class WordTokenizer: def __init__(self): pass @staticmethod def tokenize_sentence(s): """ build customer tokenizer by lower case, lemmatize and remove stopwords """ wordnet_lemmatizer = WordNetLe...
bf10e6478f4a284539ded859f7291a072e2e7915
buniumasta/NearEarthObject
/write.py
2,568
3.78125
4
"""Write a stream of close approaches to CSV or to JSON. This module exports two functions: `write_to_csv` and `write_to_json`, each of which accept an `results` stream of close approaches and a path to which to write the data. These functions are invoked by the main module with the output of the `limit` function and...
d00d45e57e5f130d3356cefa7bc7b50d63a185fe
saikrishna96111/StLab
/triangle.py
516
4.1875
4
print("enter three sides of a Triangle in the range (0 to 10)") a=int(input("Enter the value of a ")) b=int(input("Enter the value of b ")) c=int(input("Enter the value of c ")) if a>10 or b>10 or c>10: printf("invalid input values are exceeding the range") if (a<(b+c))and(b<(a+c))and(c<(a+b)): if a==b==...
7963f9e50a69af5833bee65c089d509c11308580
lhs1996/UserBehaviorAnalysis
/merge.py
5,940
4.15625
4
# CSE 160 # Huanshu Liu and Angel Chen # Merging two csv files # We need to conduct this merge.py first then run our code in pj.py import csv # Read in the csv files: user_log_format1.csv (longer list one) and user_info_format1.csv (shorter one) # rename the csv file names: user_actions.csv & user_demographi...
abc28cc6001d0f1c626995ec69eda14235636446
brybalicious/LearnPython
/brybalicious/ex15.py
2,707
4.4375
4
# -*- coding: utf-8 -*- # This line imports the argv module from the sys package # which makes the argv actions available in this script # Interestingly, if you run a script without importing argv, yet you type # in args when you run the script in shell (!= python interpreter), it # still runs and just igno...
712b189becdfd3d7e3d7c4d86d745425e839345c
mkaanery/practicepython.org
/13.py
329
4.1875
4
num = int(input("Number of fibonacci numbers: ")) def fibonacciNumberGenerator(thisMany): fib = [] counter = 0 cur = 0 prev = 1 while(counter != thisMany): cur = cur + prev prev = cur - prev counter = counter + 1 fib.append(cur) print(fib) fibonacciNumberGener...
25b152c36a293bc11daaf914f09500404f4e5207
lucrae/flag-stats
/run.py
1,198
3.5
4
from PIL import Image import matplotlib.pyplot as plt import numpy as np def get_colour_frequency(im, tolerance=0.01): # tolerance is the 'threshold' of minimum colour usage colour_frequency = {} width, height = im.size # iterate through image for i in range(width): for j in range(height)...
610fc38e6edbd169fb3c892269c88f79a57eea10
piyushchopra101/Default_classification_on_Loan_level_data
/case_Analysis.py
18,810
3.59375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Dec 11 12:46:17 2020 @author: PiyushChopra """ # ============================================================================= # TASKS TO BE COMPLETED. # #1.How well should the department expect your model to identify defaults? # #2.How confident are y...
b9d0113abc4f9ca6ca4e62aeb38d03fdbc61d5f5
amithimself/rbac
/rbac_app/models/resources.py
824
3.515625
4
class Resources: def __init__(self): self.resourcesList = {} def add_resource(self, resources_name, required_persmission): """Add a resource in the system :param name: name of resource and permission associated for the resource """ self.resourcesList[resources_name] = ...
8a4a776935025f3d7ab195773247cf2c468979ed
Benny0624/Clustering-for-TW-financial-product-custumer
/c_visuals.py
9,472
3.75
4
########################################### # Suppress matplotlib user warnings # Necessary for newer version of matplotlib import warnings warnings.filterwarnings("ignore", category = UserWarning, module = "matplotlib") # # Display inline matplotlib plots with IPython from IPython import get_ipython # get_ipython().ru...
32697b3f6860cba74a6a7a7ba2929354831754d5
sherlock1987/Leetcode
/88. Merge Sorted Array.py
1,721
3.609375
4
class Solution(object): def merge(self, nums1, m, nums2, n): """ :type nums1: List[int] :type m: int :type nums2: List[int] :type n: int :rtype: None Do not return anything, modify nums1 in-place instead. """ i = 0 j = 0 k = ...
7660ae9aa4b516ba48db59c5cdae2dbafad1d615
sherlock1987/Leetcode
/24.merge three lists.py
683
3.828125
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def mergeKLists(self, lists): """ :type lists: List[ListNode] :rtype: ListNode """ self.num = [] ...
5daac8ded69a72df0d768223cb29944628915464
boazsantosalves/ExercicioRevisaoPython
/questao04.py
1,254
3.9375
4
#Cardápio print("CARNES DISPONÍVEIS\n") print("File Duplo Alcatra Picanha\n") #Valores a serem lidos tipo = input("Qual tipo de carne você dejesa?\n") tipo = tipo.lower() quant = float(input("Qual quantidade(em kg) você deseja?\n")) pagamento = input("Qual o tipo de pagamento?\n") pagamento = paga...
3df7f370464af5c1e242826f899d8964657d53d0
puneet-kaushal/Playing-with-dictionaries-python
/playing_with_python.py
527
3.875
4
data = {"Mouse":150,"LED":7500,"Keyboard":200,"CPU":10000} #representing dictionary key and values using the format method print("First way:") print (' '.join(['{0}:{1}'.format(k, v) for k,v in data.items()])) print("Second way:") #representing dictionary key and values using for loop for key,value in data.items():...
f33e5381871821b2d9d2bfae7577a75131a1c943
breadpitt/SystemsProgramming
/python_stuff/tuple_test.py
119
3.71875
4
#!/usr/local/bin/python3 tuple = ("hello", 3, 4) print(tuple[0]) print(tuple[1]) print(tuple) f = tuple[0] print(f)
9fcc427f9fadd9ef92d03362caa7cf70da086fe9
breadpitt/SystemsProgramming
/python_stuff_2/top_two.py
522
3.859375
4
#!/usr/local/bin/python3 mylist = [10,23,66,4,87,200,0] def top_two(list): a = len(list) if a < 2: print("Error provided list too small") max = list[0] secmax = list[1] if max < secmax: temp = max max = secmax secmax = temp for i in list: if max < i...
a9ac682716f455dad84f242ae37a76b5e732d4b4
breadpitt/SystemsProgramming
/python_stuff/simple_calculator.py
472
4.34375
4
#!/usr/local/bin/python3 numone = input("Please enter number one ") op = input("Please enter an operator ") numtwo = input("Please enter number two ") numone = int(numone) numtwo = int(numtwo) if op == "+": result = numone + numtwo print(result) elif op == "*": result = numone * numtwo print(result) elif op == ...
13f751e94fcc3fcf1a7c17e5c430c2c3988137e6
breadpitt/SystemsProgramming
/python_stuff_2/classic_shape.py
1,729
4.0625
4
#!/usr/local/bin/python3 from functools import reduce class Shape: def __init__(self, num_sides, side_lengths=[]): self.num_sides = num_sides self.side_lengths = side_lengths def perimeter(self): return reduce(lambda x, y: x + y, self.side_lengths) #def area(self): # pass...
2708a4c32a8655f69ca3fa6389e3d33878d89c27
radekv23/pands-ps
/Es.py
623
3.875
4
# Radoslaw Wojtczak - G00352937 # program that reads in a text file and outputs the number of e's it contains. # The program take the filename from an argument on the command line. # variables : file for getting txt from user and counter to start counting "e" file=input("Enter your file name:") # my file is houn.txt...
37b20a8ede78cf56266d615a27d865b019177cf4
ItdeerLab/PythonDemo
/2019-03-21/九九乘法表.py
391
3.828125
4
#!/usr/bin/python # -*- coding: utf-8 -*- # 作者: itdeer # 时间: 2019/3/21 ## 99 乘法表 # 1 * 1 = 1 # 1 * 2 = 2 2 * 2 = 4 # 1 * 3 = 3 2 * 3 = 6 3 * 3 = 9 # 1 * 4 = 4 2 * 4 = 8 3 * 4 = 12 4 * 4 = 16 num = 1 while num <= 9: tmp = 1 while tmp <= num: print(str(tmp) + " * " + str(num) + " = " + str(tmp *...
8dbe0055fa90159d608683eb5b011b740616ba34
prem-pratap/matplotlib
/num_vs_list_fast.py
507
3.609375
4
import numpy as np import time import sys #first with 1000 then large size size=1000000 #defining two lists li1=range(size) li2=range(size) #defining two ndarrays arr1=np.arange(size) arr2=np.arange(size) initial=time.time() result1=[(x,y) for (x,y) in zip(li1,li2)] print("Time taken to compute sume of list",time.t...
f370e4db359b0700084c6101f50c395acfcf8b91
changsman/changs
/practice/collatz.py
264
3.859375
4
def solution(num): answer = 0 if num == 1: return answer while True: num = num/2 if num % 2 == 0 else (num*3)+1 answer += 1 if num == 1: return answer elif answer == 500: return -1 return answer print(solution(6))
b9c8c75e461dc7ee6447a20419f509db4bc46fa7
changsman/changs
/practice/average.py
161
3.65625
4
def solution(arr): if(arr==0): return 0 answer= sum(arr) /len(arr) return answer number=[1,2,3] print("평균값은",solution(number))
cf2e5290446ee2a209f11ce0a4b29baea5d721ef
changsman/changs
/practice/maxnum2.py
248
3.578125
4
def solution(number, k): answer='' result='' arr=str(number) for i in arr: answer.append(''.join(i)) answer.sort(reverse=True) ###['5','4','3','2'] for i in answer[0:k]: result=answer[i]+answer return answer print(solution(1234,2))
d14f0a43ff90aac0fb98fe0c9f324bc7a2d02d70
DipalModi18/PythonTutorial
/RestService/RequestsLibrary/RequestsLibrary.py
3,471
4.0625
4
import requests from requests.exceptions import HTTPError # # # The GET method indicates that you are trying to get or retrieve data from a specified resource. # To make a GET request, invoke requests.get(). response = requests.get('https://api.github.com') # # print(response.status_code) # Return value of get() i...