blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
b729a33317640f9a7eaa2d59035eff897ad10581
MartijnPY033/Opdrachten-Python
/Les 10/Final Assignment H10.py
1,109
3.578125
4
import xmltodict def XmlToDict(file): 'zet xml file om naar een dictionary' with open(file) as XMLStations: XMLContent = XMLStations.read() XMLDict = xmltodict.parse(XMLContent) return XMLDict 'haalt de tags uit de xml file' stationsdict = XmlToDict('XML_stations') stations = stationsdi...
e000f0eaf6b2e45597b53386cc48816f502684b1
jennmald/AMS_595_Python
/celsius.py
1,759
4.125
4
## Jennefer Maldonado ## ## Date Due: October 16, 2020 ## import sys def parse_command_line(rawinput): #parse_command_line takes the commandline #arguments of sys.argv. #It returns useful errors. #This command is executed from the commandline. rawinput_list = '' #if there is more than...
4211a01c0974cf47e7bf0497de82807bf3cff182
niteshseram/Data-Structures-and-Algorithms
/Show Me Data Structures/problem_2.py
1,229
4.34375
4
import os def find_files(suffix, path): """ Find all files beneath path with file name suffix. Note that a path may contain further subdirectories and those subdirectories may also contain further subdirectories. There are no limit to the depth of the subdirectories can be. Args...
a5d416412d84b60d45d7653bb928214804b00ae5
mcorrigan89/Algorithms_DataStructures
/Sort/QuickSort.py
394
3.859375
4
def Sort(array): less = [] equal = [] greater =[] if (len(array) > 1): pivot = array[0] for i in array: if i < pivot: less.append(i) if i == pivot: equal.append(i) if i > pivot: greater.append(i) ...
ddae908d0c676c1d3daee036c0e7d032259bca11
paperwraith/Project_Euler
/Project Euler/003.py
1,066
4.1875
4
from math import sqrt num = input('Enter a number to determine if it is Prime. \n') num = int(num) empty = [] def all_factors(num, factors): for i in range(1, sqrt(num)): if num % i == 0: factors.append(i) return factors def is_prime(factors): prime = True if l...
e0cb5b2ff516f4da4e144ff5ffd478a115d502f8
2502797718/script_gb2312
/compare_gb2312.py
1,175
3.890625
4
# coding: gb2312 list_a = [""] list_b = ["С"] list_c = list_a + list_b list_d = [1,3,5,10] #ֳ֧ȵ def compare_str_gb2312(str1, str2, len): for i in range(len): num0 = str1.encode("gb2312")[0]*256 + str1.encode("gb2312")[1]; num1 = str2.encode("gb2312")[0]*256 + str2.encode("gb2312")[1]; if n...
3b51b06a0eb67b571ffcba11b24eb996a77f3b5b
Madhumidha14/python-task-1
/pattern.py
423
3.9375
4
# -*- coding: utf-8 -*- """ Created on Sun Aug 22 17:11:37 2021 @author: DELL """ def triangle(n): k = n-1 #number of spaces for i in range(0, n):# handles no of rows for j in range(0, k): print(end=" ") k = k - 1 for j in range(0, i+1): print("*",...
89dcd2897ddd943794b2f863489ce79751ca3de4
bdintu/Data-Structure
/Lab07-Sort-Heap/sort.py
2,313
3.78125
4
from random import shuffle def bubbleSort(l): for i in range(len(l)): isSwap = False for j in range(len(l) -2, i-1, -1): if l[j] > l[j+1]: l[j], l[j+1] = l[j+1], l[j] isSwap = True if not isSwap: break def selectionSort(l): for i in range(len(l)): min, min_index = l[i], i for j in range...
4f8712fede04c26d271933a6054512ef965eced3
bdintu/Data-Structure
/Lab05-Recursion/pow.py
522
3.75
4
def pow_on(self, x, n): if n == 0: return 1 else: return x * self.pow(x, n-1) def pow_ologn(self, x, n): if n == 0: return 1 if n == 1: return x elif n%2 == 0: return self.pow(x*x, n//2) else: return x * self.pow(x*x, n//2) print(pow_on(2, 0)...
eee7c9f4b695d253e36195e1ff290326c905231d
bdintu/Data-Structure
/Test2-1-Recursion-Tree/doublemore.py
788
3.671875
4
class node: def __init__(self, d, l=None, r=None): self.d = d self.l = l self.r = r def __str__(self): return str(self.d) def add(r, d): if not r: return node(d) else: if d < r.d: r.l = add(r.l, d) else: r.r = ...
fe6deb3ab95ef045ad9e8737db4c1f95ac5a94be
bdintu/Data-Structure
/Lab02-Stack-Queue/lab2-1.py
422
3.828125
4
from stack import Stack s = Stack() name = input() for i in name: s.push(i) print("push : ", i) print(s.items) print() print("items : ", s.items) print("size : ", s.size()) print("empty : ", s.empty()) print("full : ", s.full()) print("top : ",s.peek()) print() while s: print("pop : ", s.pop()) ...
51932aee4623fa01915e8d815e6c218dfd17e18b
bdintu/Data-Structure
/Lab05-Recursion/bsearch.py
623
3.5625
4
def bsearchR(a, x ,l, h): if l > h: return -1 mid = (l+h)//2 if a[mid] == x: return mid elif a[mid] < x: return bsearchR(a, x, mid+1, h) else: return bsearchR(a, x, l, mid-1) def bsearchI(a ,x): low = 0 hight = len(l) -1 while low < hight: mid =...
8fed3a015dca53978b0d2968998c344dc69cd0e2
senecal-jjs/GA_EVOLVE_MLP
/Layer.py
2,199
4.21875
4
import numpy as np import Neuron '''The layer class holds the parameters that are required by a layer within the network, including: the weight matrices, the centroids for an RBF network, as well as the error values and derivatives used in backpropagation. Additionally the layer class is used to propagate inputs...
8ba393eadfa668e76c8bc118aed3db3e565db164
spark856/codes
/Float.py
1,044
4.03125
4
from fractions import Fraction class Float(object): def __init__(self, obj, sub=1, frac=None, pown=1): self.ab = Fraction(obj, sub) if frac is None else frac self.pown = pown self.val = self.ab**self.pown def __pow__(self, other): return Float(1,frac=self.ab, pown=self.pown *...
92265b2f082a5c0878197c007c6983a91127562f
SupraKuning/Project-OKBOSS
/main.py
9,609
3.859375
4
class Pengguna: def __init__(self,level,idPengguna,namaPengguna,password): self.level = level self.idPengguna = idPengguna self.namaPengguna = namaPengguna self.__password = password def info(self): return '''Jabatan = {}\n ID = {}\n Nama = {}'''.format...
0dea982342f63cf7436da7298b6aa5059a76b470
HenintsoaHARINORO/Algorithms_Python
/QuickSort2.py
971
3.9375
4
def quick_sort(array): quick_sort_help(array, 0, len(array) - 1) def quick_sort_help(array, first, last): if first < last: splitpoint = partition(array, first, last) quick_sort_help(array, first, splitpoint - 1) quick_sort_help(array, splitpoint + 1, last) def partition(array, first,...
f71494d2c80a83f3484f1b7b18e867b3968aa432
HenintsoaHARINORO/Algorithms_Python
/Queue.py
1,827
4.0625
4
class Queue(object): def __init__(self,limit=5): self.que= [] self.limit = limit self.front= None self.rear= None self.size=0 def isEmpty(self): return self.size <=0 def enQueue(self,item): if self.size >=self.limit: print('Queue overflow')...
372fa6e77ecabc032cc494ace4346612c415ad9e
HenintsoaHARINORO/Algorithms_Python
/Heap.py
237
3.859375
4
from heapq import heappop, heappush, heapify heap = [] nums = [12, 3, -2, 6, 4, 8, 9] # for num in nums: # heappush(heap,nums) # while heap: # print(heappop(heap)) # return the root node on every iteration heapify(nums) print(nums)
aa27c41f923c18490ca69b159689d175ed29af6e
HenintsoaHARINORO/Algorithms_Python
/Find_Missing Element.py
968
3.875
4
import collections def finder(arr1, arr2): arr1.sort() arr2.sort() for num1, num2 in zip(arr1, arr2): if num1 != num2: return num1 print(arr1[-1]) # the last element of the first array # zip([1,2,3],[4,5,6]) # [(1,4),(2,5),(3,6)] list of tuples # num1 first number of the first ...
f9f5751eac8acfef489a792a7ecd20bea2f0a80e
HenintsoaHARINORO/Algorithms_Python
/RecursiveStringReverse2.py
239
4.03125
4
def reverse(s): if len(s) <= 1: return s return reverse(s[1:]) + s[0] print(reverse("Hello")) # reverse("ello") + 'H' # reverse("llo") + 'e'+ 'H' # reverse("lo") + 'l'+ 'e'+ 'H' # reverse("o")+ 'l' +'l'+ 'e'+ 'H' # olleH
8a35d3840acf7fd365b3011f0d85f1b64bb4452d
HenintsoaHARINORO/Algorithms_Python
/RecursionStringReverse.py
272
3.8125
4
def reverse(s): if (len(s) <= 1): return s else: m = int(len(s) / 2) return reverse(s[m:]) + reverse(s[:m]) print(reverse("Hello")) # reverse(lo)+reverse(Hel) # reverse(o)+reverse(l)+reverse(l)+reverse(He) # reverse(e)+reverse(H) # olleH
28543e0aacd524e9ffd754d4d945dee2574eb11a
GitHubdeWill/code_recom
/error/Predicted_Results/test_sample0_2recom_model1.py
1,281
4
4
def add (x, y): return x + y if __name__ == '__main__': x = 2 y = 3 print('backs ( x , y))def add (x, y): return x + y if __name__ == '__main__': x = 2 y = 3 print('script, ( x , y))def add (x, y): return x + y if __name__ == '__main__': x = 2 y = 3 print(import'httpie'ht...
b36a395b99ee4ee1e20fde2de211f2999a4cfbe7
GitHubdeWill/code_recom
/error/Predicted_Results/test_sample1_1recom_model1.py
6,071
3.6875
4
class BankAccount: def __init__(self, name, money): self.__name = name self.__balance = money def deposit(self, money): self.__balance += money def withdraw(self, money): if self.__balance > money : self.__balance -= money return money ...
060d8594dca6afaf5d612ba4df2c830e40358941
Falcon-I/Rock-Paper-Scissors-Game
/main.py
1,934
3.890625
4
import tkinter as tk import random as r rps = ('ROCK','PAPER','SCISSORS') def clickr(): R = "ROCK" print("You chosen Rock") c.delete(0, "end") computer = (r.choice(rps)) c.insert(0, computer) if R=="ROCK" and computer=="PAPER": c.delete(0, "end") c.insert(0, computer+" ,YOU LOST"...
aa953b812fd380bdefc67e9274587a14025ae9cb
BocHackathon-fintech2/Pintfin
/addstockchange.py
1,753
3.53125
4
import pandas as pd from pandas_datareader import data as web # Package and modules for importing data; this code may change depending on pandas version import datetime import sys # Let's get Apple stock data; Apple's ticker symbol is AAPL # First argument is the series we want, second is the source ("yahoo" for Yaho...
d94da36e72ccda488d23160b50c0a804aed7515d
fangnahz/learning-python
/notes/simple_search_engine.py
3,431
3.5
4
# Queues are used to provide more control over communication between processes # any picklable object can be sent into a queue, # but pickling can be quite costly, # so such objects should be kept small # This engine scans all files in current direcotry in parallel # one process is constructed for each core on the CP...
337033aea5a3d1db78937b366b458555e8dbbf88
Botir-01/ComputerVision-DeepLearning
/numpy_arrays.py
997
4
4
import numpy as np mylist = [1, 2, 3] # Turning a default Python array into numpy array myarray = np.array(mylist) # numpy version of a range np.arange(0, 10, 2) # creating two dimensional array with float(0) np.zeros((10, 5)) # creating two dimensional array with float(1) np.ones(shape=(2, 5)) # creating an arra...
08f30c7e9ecfc075dfd419387c602f3c54e37a6c
Vansh-Arora/InteractWithOS
/testing/makingString.py
545
4.125
4
# Pass a department name and a list of users belonging to that department. # Return a string as dept: names def group_list(group, users): members = group + ":" + " " for user in users: members+= user+',' members = members[:len(members)-1] return members print(group_list("Marketing", ["Mike", "...
33ad37cb19f2a5d6f9f5d7079dd06a7ddea7bb19
Vansh-Arora/InteractWithOS
/diff-file-operations/workingOnCSV/read_with_dictionary.py
251
3.984375
4
#!/usr/bin/env python # Read the contents of a csv file as a dictionary import csv with open('software.csv') as software: reader = csv.DictReader(software) for row in reader: print("{} has {} users".format(row["name"], row["users"]))
0d5f79048cca229f4eff83f31740cabe28e26991
ballanceado/engines
/superlist.py
356
3.671875
4
# [call me by my name] is a simple python script that shows a 'if' message when the right and the wrong answer is input # developed by :: killabomb right_answer = str('killabomb') if right_answer == input('Call me by my nickname...'):print('You got me! My nickname is killabomb! <3') else:print('Not this time,...
d8919e8d6bd95ee3891a1392f92d2d7a93c73138
amulyasharma27797/python-basic
/python.py
9,547
4.125
4
# def add_num(a,b): # """Using f-stings to add two numbers using functions""" # print(f"{a} + {b} = {a+b}") # add_num(3,4) # def add_number(a,b): # """Using return statement""" # return(f"{a} + {b} = {a+b}") # print(add_number(3,4)) # def greet(name="User"): # """Default argument in python""" # return(f"Hello...
333a67418477b59cca0745201397ad86e7694b48
cddas/python27-practice
/exercise-9.py
386
4.09375
4
# solution to exercise-4 num = raw_input("Enter a number : ") num = int(num) num_dev = [] num_dev = [div for div in range(1, num + 1) if (num % div) == 0] if len(num_dev) > 2: print("The number " + str(num) + " is not a prime number. It has " + str(len(num_dev)) + " divisors which are : " + str(num_dev)...
a2f0f121bde0aa95d4d3a5903d42ed2cd19cdf88
Simrang19/sort_n_search
/sorting/insertion_sort.py
277
3.953125
4
def insertion_sort(li): for i in range(1, len(li)): key = li[i] j = i-1 while j>=0 and key<li[j]: li[j+1] = li[j] j-=1 li[j+1] = key return li arr = [2, 3, 4, 1, 4, 6, 3, 9, -1, -7, 10] print(insertion_sort(arr))
c9266b96a5d728dac5eaefe381ff1516302df760
Simrang19/sort_n_search
/Intro to DSA in python/L3-Linked-Lists.py
3,382
4.0625
4
# Implementation of linked list class Node: data=-1 next=None def __init__(self, data): self.data=data # Adding data in linked lists # at head # at tail # in middle somewhere def display_LL(head): tmp=head while tmp!=None: print(tmp.data, end=' ') tmp=tmp.n...
9366b8ef8d0067737e408047b39113d4ccf9fac7
596050/DSA-Udacity
/practice/advanced-algorithms/graph_dfs_search.py
857
3.90625
4
from graph import * def dfs_search(root_node, search_value): visited = [] stack = [root_node] while len(stack) > 0: current_node = stack.pop() visited.append(current_node) if current_node.value == search_value: return current_node for child in current_node.ch...
423ff2d96df67b55716d7c14365a81ffc8ea5882
596050/DSA-Udacity
/practice/data-structures/linked-list/double-linked-list.py
1,114
4.03125
4
class DoubleNode: def __init__(self, value): self.value = value self.next = None self.previous = None class DoublyLinkedList: def __init__(self): self.head = None self.tail = None def append(self, value): if self.head is None: self.head = DoubleN...
bb4ea9e0599847e3febc4b7aeb1b7f38736cca54
596050/DSA-Udacity
/practice/advanced-algorithms/knapsack.py
656
3.9375
4
import collections Item = collections.namedtuple("Item", ["weight", "value"]) def max_value(knapsack_max_weight, items): """ Get the maximum value of the knapsack. """ weights = [0 for _ in range(knapsack_max_weight + 1)] for (weight, value) in items: for capacity in reversed(range(knaps...
28c41a4c2191ac88e197f1a3d11d4a1a730213e4
596050/DSA-Udacity
/practice/data-structures/trees/dfs-tree-traverse.py
1,320
3.984375
4
# DFS # Depth First Search tree traversal from binary_tree import * from stack_helper import * # create a tree and add some nodes tree = Tree(Node("apple")) tree.get_root().set_left_child(Node("banana")) tree.get_root().set_right_child(Node("cherry")) tree.get_root().get_left_child().set_left_child(Node("dates")) # ...
7fa38555c1367f53823f253134ecdbcde7be062e
596050/DSA-Udacity
/practice/basic-algorithms/heaps.py
3,465
3.65625
4
# read and search: O(n) # insert/remove: O(log n) class Heap: def __init__(self, initial_size): self.cbt = [None for _ in range(initial_size)] # initialize arrays self.next_index = 0 # denotes next index where new element should go def size(self): return sel...
39c7c5bda550e32eea9ad8ffb927ff0b0ddd270c
596050/DSA-Udacity
/practice/advanced-algorithms/island-hopping.py
1,497
4.15625
4
import heapq def get_minimum_cost_of_connecting(num_islands, bridge_config): """ :param: num_islands - number of islands :param: bridge_config - bridge configuration as explained in the problem statement return: cost (int) minimum cost of connecting all islands TODO complete this method to returh ...
49e04930e71c2548ac95c6a8850b45453df26485
shazii/Network_TeleTubbs
/client.py
1,414
3.53125
4
import requests # placeholder URL to send packets (simulate user traffic) url = 'http://127.0.0.1:5000/post' while True: ''' Infinite while loop that repeatedly reads the quantity.txt file and sends a corresponding number of packets to simulate user traffic. The number of packets sent is equal to ...
fad94f8462e93e7def511d04a9c3942727dace9f
Aditya7256/Demo
/Adding items.py
384
4.59375
5
# Adding an item to the dictionary is done by using a new index key and assigning a value to it: thisdict = { "model": "s88", "brand": "mahendra" } thisdict["year"] = 2021 print(thisdict) # Add a color item to the dictionary by using the update() method: thisdict = { "brand": "mahendra", "mo...
3dbe47c222f4cdad2bdf9ef0e822ae3015b37df2
Aditya7256/Demo
/Recursion in Python.py
245
4.0625
4
# Recursion in python: def my_function(k): if k > 0: result = k + my_function(k - 1) print(result) else: result = 0 return result print("\n\nrecursion Example Results") my_function(10)
e27a16345133a1daef9b342e1b04b2a3ca3881b6
Aditya7256/Demo
/Basic OOPS in python.py
2,172
4.53125
5
# Basic of Object oriented programing : from os import name class fruits: color = 'red' # That is variable: Apple = fruits() # That is Object: print(Apple.color) Orange = fruits() Orange.color = "orange" print(Orange.color) print(Apple.color) # Object oriented programing: class car: ...
1e42e077d39718997af9a04646b044d777723941
eagletusk/pythonPractice
/CheckIfNandItsDoubleExist.py
399
3.578125
4
#CheckIfNandItsDoubleExist from typing import List class Solution: def checkIfExist(self, arr: List[int]) -> bool: bkt = set(arr) n=0 for i in arr: if i !=0: n = i*2 print(n in bkt, n, bkt) if n in bkt : return True ...
1346ed3e43bbd1b5f853a832909946b9494676b6
eagletusk/pythonPractice
/deque.py
573
3.796875
4
class Deque(object): def __init__(self): self.items = [] def addFront(self,item): self.items.append(item) def addRear(self, item): self.items.insert(len(self.items),item) def removeFront(self): return self.items.pop(0) def removeBack(self): return self.items.pop() def isEmpty(self):...
6a066fbf6dc18b7c3cd6e47779804c095e9e1084
eagletusk/pythonPractice
/rotateLeft.py
262
3.875
4
# Complete the rotLeft function below. def go(): a= [1,2,3] d = 1 result = rotLeft(a, d) return result # print(result, a, d) def rotLeft(a, d): # append and pop value = a.pop(d) a.append(value) # print(a) # return -1 return a
2df70ced702ea64fedc69b810f6e803939620a84
henrydaleywhite/turn-game-app
/FlaskApp/run/src/models/opencursor.py
1,284
3.6875
4
""" OpenCursor: context object for sqlite3 """ import sqlite3 DBNAME = "game.db" def setDB(dbname): """ opencursor.setDB() sets the default DBNAME for OpenCursor objects """ global DBNAME DBNAME = dbname class OpenCursor: """ Context object for sqlite3 """ def __init__(self, db=None, *args, **...
bcca1bf8216b25779f12d609c9319423176bbf34
bryan-hoang/advent-of-code-2018
/day_1.py
429
3.6875
4
frequency = 0 seen_frequencies = set() current_position = 0 # Note: This is a generator - Alex file = list(int(line) for line in open('./day_1_input.txt')) while True: frequency += file[current_position] if frequency not in seen_frequencies: seen_frequencies.add(frequency) else: break ...
315332738ca9072eb8713d48010d814014111d9d
stella-chmt/daily_scripts
/python/practise_for_yingl_lessons/lesson_4/delete_node_in_linked_list.py
1,567
3.8125
4
# coding = utf-8 ''' 删除链表中的元素 给出链表 1->2->3->3->4->5->3, 和 val = 3, 你需要返回删除3之后的链表:1->2->4->5 ''' class Node: def __init__(self, val, next = None): self.val = val self.next = next def traverse(head): vals = [] while head: vals.append(str(head.val)) head = head.next return ...
ad7d02f6df2943eb3fa01751eacd4307ad280883
stella-chmt/daily_scripts
/python/practise_for_codecademy/function-test.py
754
4
4
__author__ = 'mengting.chen' import types def distance_from_zero(arg): tp = type(arg) #return tp if (tp is types.IntType) or (tp is types.FloatType): return abs(arg) else: return "Not an integer or float!" input = raw_input("type something") print distance_from_zero(in...
7459286e2481bf015dec2fcbf6c4e595d3a1a213
ideaPeng/UW-Madison-CS642
/HW01/sha256bruteforce.py
775
3.578125
4
#!/usr/bin/env python3 import hashlib def main(): print(hashlib.sha256("hugh,13145820,20193833".encode("ascii")).hexdigest()) # 13145820 guess_flag = True digits = 1 while guess_flag: bound = 10**digits guess = 0 while guess < bound: guess_str = ("hugh,{:0" + st...
705eca3b6ba66b718d90924462dffddd1e3fd8bd
puneetbawa/python-me2sem
/lecture4.py
2,817
4.15625
4
#Leap Year or not #Convert height of a person from cm into inch and feet #Temprature conversion from c to f and vice versa #Printing tabe of a given number #Least Significant of the entered integer at unit's place #Divisible by 7 and multiple of 5 in given number #gcd import math def check_lp_year(year): if (year...
fadf317c8cf5d000f43115215a140b042dbebfae
francisbyrne/portfolio
/file.py
758
3.65625
4
import os import pandas as pd DATA_DIRECTORY = "data" PRICES_DIRECTORY = "historical_prices" def make_path(name, parent_dir=PRICES_DIRECTORY): """Return CSV file path given filename.""" output_dir = os.path.join(DATA_DIRECTORY, parent_dir) # Make directory if it doesn't already exist try: os...
0f30ac4a369c3185d18c0bbde250300845553613
connordear/projecteuler_problems
/python solutions/ProjectEuler12.py
1,421
3.828125
4
# The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: # # 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... # # Let us list the factors of the first seven triangle numbers: # # 1: 1 # 3: 1,3 # 6: 1,2,3,6...
27c494a9aaebc815a2464242f283181fed2975c1
connordear/projecteuler_problems
/python solutions/ProjectEuler17.py
2,337
3.875
4
# If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. # If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used? def word_builder(a): num_to_word = {} num_to_word...
88d7504104219af6929ddec3837c1bd3320fc832
oumaymabg/holbertonschool-web_back_end
/0x01-python_async_function/1-concurrent_coroutines.py
952
3.984375
4
#!/usr/bin/env python3 """ Import wait_random from the previous python file that you’ve written and write an async routine called wait_n that takes in 2 int arguments: max_delay and n. You will spawn wait_random n times with the specified max_delay. wait_n should return the list of all the delays (float val...
03a52ad2d788799d7ce09bdab1ceed4335941484
oumaymabg/holbertonschool-web_back_end
/0x00-python_variable_annotations/0-add.py
322
4.09375
4
#!/usr/bin/env python3 '''Module that adds two floats and returns the sum as float''' def add(a: float, b: float) -> float: ''' Type-annotated function that takes two floats and returns the sum as float @a: first float @b: second float Return: the sum represented as a float ''' return a + ...
e621089b2e2395a4c8e63e729665550d383063e1
PacktPublishing/Hands-On-Reinforcement-Learning-for-Games
/Chapter02/Chapter_2/Chapter_2_!.py
251
4.09375
4
def Fibonacci(n): if n<0: print("Outside bounds") elif n==1: return 0 # n==1, returns 0 elif n==2: return 1 # n==2, returns 1 else: return Fibonacci(n-1)+Fibonacci(n-2) print(Fibonacci(9))
5b52f57bbcba7e6e8e55d2abe20e5ffff175a351
PacktPublishing/Hands-On-Reinforcement-Learning-for-Games
/Chapter02/Chapter_2/Chapter_2_3.py
333
4.03125
4
fibSequence = [0,1] def Fibonacci(n): if n<0: print("Outside bounds") elif n<= len(fibSequence): return fibSequence[n-1] else: print("Solving for {}".format(n)) fibN = Fibonacci(n-1) + Fibonacci(n-2) fibSequence.append(fibN) return fibN print(F...
4fd0266ef32ef633ad2cd7b2845815b2d0fae6d6
spejamchr/pyku_ebooks
/writer.py
4,171
3.53125
4
import re import random from markov_chain import MarkovChain class Writer: LAST_QUERY = re.compile("[\\.\\?\\!]['\"]?$") FIRST_QUERY = re.compile(r"^[^a-z]*[A-Z]") LINE_END_QUERY = re.compile("[\\.\\?\\!,;:-]['\"\”)]?$") def __init__(self, markov_chain): self.markov_chain = markov_chain ...
984d180f228590a4d681f37d112bfd1446ccc1f8
JJJados/advent-code-2019
/day1/fuel_calculation.py
949
3.703125
4
from math import floor # Calculates fuel based on mass for Part 1 def calculate_fuel(mass): return (floor(mass / 3)) - 2 # Calculates additional fuel based on mass for Part 2 def calculate_additional_fuel(mass): if mass <= 0: return 0 return calculate_additional_fuel(calculate_fuel(mass)) + mass ...
f9caadf0ff0f2e1f1a8957b9337336a285cf5060
CodecoolWAW20171/web-askmate-project-sejsmogrzmoty
/ui.py
2,891
3.71875
4
# Note: no safeguard against wide columns - terminals wrap long lines. # If use suspect wide column be sure to stretch terminal beforehand or # run fullscreen def print_table(table, headers={}, head_form=['<'], cell_form=['<']): """ Prints table with data. Args: table (list): list of dictionaries...
1a5935bebc78ecded6ef1867f3cb9a670855e277
DiegoC386/Taller-de-Funciones
/Ejercicio_6.py
872
3.71875
4
frutas = open('frutas.txt', 'r') numeros= open('numeros.txt','r') lista_frutas=[]#Llenar las lista con los datos del archivo frutas.txt lista_numeros=[]#Llenar las lista con los datos del archivo numeros.txt for i in frutas: lista_frutas.append(i) for i in numeros: lista_numeros.append(i) #Retorna una lista con las...
e4b0dab3464b3cde833713ea6b315ed6fd2e3320
AugmentedMode/Software-Engineering
/OOZero/user_session.py
1,060
3.65625
4
# Basic user session management code. from flask import Flask, redirect, url_for, session from functools import wraps def login_required(func): """Decorator function to wrap each function that requires user login. Redirects to '/login' if no user is logged in. """ @wraps(func) def decorator(*ar...
035ccac254dd5054cfa9df4aff99522e4e108d7f
raghavsaboo/data-structures
/linked_lists/singly_linked_list.py
6,015
3.9375
4
class Node: def __init__(self, data): self.data = data self.next_element = None class SinglyLinkedList: def __init__(self): self.head_node = None def get_head(self): """ O(1) time complexity O(1) space complexity """ return self.head_node ...
3f3c8f43d82ba3226d4c6cbded1582aafb2758fa
swestphal/riceUniversity_Python_I
/project1 - rpsls.py
1,851
4.03125
4
import random def name_to_number(name): """ converts the string 'name' into a number between 0 and 4 """ if name == "rock": number = 0 elif name == "Spock": number = 1 elif name == "paper": number = 2 elif name == "lizard": number = 3 elif name == "s...
9766eff22c6de599ddbb85152ad51be584dc52d6
jgalek/test_repo1
/game.py
26,980
3.609375
4
#coding=utf-8 from flask import Flask, render_template, session, request, redirect, url_for from collections import OrderedDict app = Flask(__name__) app.secret_key = "super secret key" import random """ This program is for the card game Rummy. Rules: - Rummy is a card game based on making sets. - From a stash(or ha...
f352ab875eb04292d05549b6d54b8eb822e378c8
Gricel-lee/Multi-Robot-Task-Allocation
/system_0/utils/utilsFunctions/printXMLprettify.py
1,023
3.59375
4
''' Description: This file prints XML files in a readable manner Last update: 23/09/2020 ''' from xml.etree.ElementTree import Element, SubElement, Comment from xml.etree import ElementTree from xml.dom import minidom def prettify(elem): """Return a pretty-printed XML string for the Element. """ ...
6416ae2a0905891a9d9fad7275e25998c9d104ef
dorinaduma/ECCPR
/zaruri.py
1,488
3.609375
4
''' Problema 2018.3.1 - Zaruri Costică e în vacanță și l-au trimis părinții la țară. Acolo se plictisește groaznic și căutând prin dulapul bunicului, a dat peste o pungă plină ochi cu zaruri. Neavând cu cine să joace zaruri, Costică s-a apucat să le clădească, unul peste celălalt, cât de sus a putut. Uitându-se...
47e676ae691c1db7c1a21acb004e644ef92f13c0
dorinaduma/ECCPR
/cifru_de_substitutie.py
1,708
3.734375
4
''' Una din cele mai vechi metode de a cripta informaţia este printr-un cifru de substituţie. Acest cifru se realizează prin înlocuirea fiecărui caracter din textul de intrare cu alt caracter. Cerinţă Dându-se un text de intrare şi un tabel de substituţie, să se scrie un program care să cripteze textul de intrare. Da...
6dee37e657a0d294a7ccacce5085adbde2da6e72
OpenDevloper/LinuWiki-SearchIt
/main.py
2,644
4.0625
4
# Code for a wiki search app, pretty basic| # ////////////////////////////////////////| # Welcome to my python wiki searcher app!|| # 1 importing the moduels we need from tkinter import * from wikipedia import * import pyttsx3 import os # functions for the proper functioning of search and clear button in li...
26c2aaff481b90e7886b572fbc0258ae485df695
felipegmarques/algorithms-for-optimization-and-statistical-inference
/change_test.py
310
3.5
4
import unittest from change import ( change, ) class TestChange(unittest.TestCase): def test_change(self): coins = [1, 5, 7] value = 10 expected_result = [0, 2, 0] actual_result = change(coins, value) self.assertListEqual(expected_result, actual_result)
bfbc4659a5608e5445a594443cfec8d86603e0a8
jimkiiru/james-kiiru-bc17-week1
/day4/BinarySearch.py
745
3.890625
4
class BinarySearch(list): def __init__(self, a, b): self.a = a self.b = b def search(self, itemToSearch): i = 0 lowerItemIndex = 0 higherItemIndex = self.a - 1 midpoint = lowerItemIndex + (higherItemIndex - lowerItemIndex)//2 if itemToSearch == midpoint: i = i + 1 return {i: midpoint} elif ite...
f878026d6697d310f75d8731b1414ad40d2b8bf3
Robertrui/ops435-a2-1
/a2_arg.py
1,213
3.625
4
#!/usr/bin/env python3 '''Demonstrate the use of the argparse module: how to retrieve the command line argument.''' import argparse parser = argparse.ArgumentParser(description="Usage Report based on the last command",epilog="Copyright 2018 - Raymond Chan") parser.add_argument("-l", "--list", type=str, choices=['user'...
819dbf77bd1d4bbb1e24021b2afe18dfb7187d08
PolicarpoDi/Exerc-cios-mundo-2-Python
/ex065.py
689
4.0625
4
media = 0 soma = 0 maior = 0 menor = 0 cont = 0 resp = 'S' while resp == 'S': numero = int(input('Digite um número: ')) soma += numero cont += 1 if maior == 0 and menor == 0: maior = menor = numero else: if numero > maior: maior = numero if numero <...
dde98a3775086b5ca04e57f6e306de9aa2900e21
PolicarpoDi/Exerc-cios-mundo-2-Python
/ex039.py
1,073
3.921875
4
from datetime import date data = int(input('Digite o ano de nascimento: ')) sexo = str(input('Digite o sexo: ')) ano = date.today().year idade = ano - data if sexo == 'Masculino': if idade < 18: print('Você tem {} anos e ainda vai se alistar ao serviço militar'.format(idade)) falta = 18 - id...
81f6f82b17603f10154d1f4fefa01724ff1ecfbb
PolicarpoDi/Exerc-cios-mundo-2-Python
/ex040.py
478
3.859375
4
n1 = float(input('Digite a primeira nota: ')) n2 = float(input('Digite a segunda nota: ')) m = float((n1 + n2) / 2) if m < 5.0: print('Sua média foi de {:.1f}, portanto você esta \033[1;31mREPROVADO\033[m!'.format(m)) elif m == 5.0 or m <= 6.9: print('Sua média foi de {:.1f}, portanto você esta de \033[1;...
917f2921241ee896886834e3a0c8b36e58af83fc
eddieware/Python_Django_Ln_nJ
/Material_programadores/listas/listas_6_prop.py
138
3.859375
4
num = [1,2,3,4,5] letr = ["a", "b", "c", "d", "e"] for n in range(len(num)): print ("En la asignatura :",num[n],"obtuviste", letr[n])
9200d1d8c1d008c87bd5f251fd26176ae2377f2b
agbrothers/Data-Science-Projects
/wikipedia_pageview_scraping.py
3,207
3.53125
4
import time import numpy as np import pandas as pd import urllib.request from selenium import webdriver # Using Selenium to load & scrape data from dynamic tables generated by JavaScript on Wikipedia's Analytics website """ DEFINE SCRAPING FUNCTION """ def scrape_data(day,month,year): # Scrape the data using the...
7a99ed4cac87582ad3a788204a4e633ca2abcbd7
Dulou/leetcode-python
/Python/easy/657. Robot Return to Origin.py
416
3.671875
4
class Solution: def judgeCircle(self, moves: str) -> bool: updown = 0 rightleft = 0 for move in moves: if move == 'U': updown += 1 elif move == 'D': updown -= 1 elif move == 'R': rightleft += 1 ...
ef9689cd68e19bf73877b6bf8c6e2cc45a2767a4
SamanthaCorner/100daysPython-DAY-5
/fizz_buzz.py
499
4.1875
4
""" 100 days of Python course DAY 5 """ # a quick exercise in logic, using if / elif / else for # the solution to the FizzBuzz challenge # the use of operators is important and the range ensures # that we get numbers from 1 up to and including 100 only for number in range(1, 101): if number % 3 == 0 and ...
3cbc929057900b8b708341cca7bca602801e3c68
Dzeiberg/OverUnder
/src/Gate.py
695
3.53125
4
import pygame class gate(pygame.sprite.Sprite): def __init__(self,location): pygame.sprite.Sprite.__init__(self) # call parent class constructorpygame.sprite.Sprite.__init__(self) # load the image, converting the pixel format for optimization self.image = pygame.image.load("../resources/gate.png").convert() ...
c25e15215e26c8aef2ea5b67429ea85336b2b2aa
m-rahimi/Phyton
/Basic/recursive.py
1,128
3.765625
4
# -*- coding: utf-8 -*- """ Created on Fri Jan 20 19:39:40 2017 @author: Amin """ #recursion function def get_fib(position): if position == 0 or position == 1: return position return get_fib(position - 1) + get_fib(position - 2) #Fibonacci Sequence #0,1,1,2,3,5,8,13,21,34... print ge...
539bdccd45945b7ffd1830816814de4df592c64b
m-rahimi/Phyton
/LinkedList/sum_two_linkedlist.py
3,246
3.625
4
# -*- coding: utf-8 -*- """ Created on Sun Mar 05 19:33:52 2017 @author: Amin sum two linkedlist with same size """ class Element(object): def __init__(self, value): self.value = value self.next = None class LinkedList(object): def __init__(self, head=None): self.head...
b1bd5e39404cda0abf8ee7d87b546480388d8cc6
UCD-pbio-rclub/Pithon_Michelle.T
/pithon_06272018/pithon_0627_ex4.py
361
4.15625
4
birthday = { 'Michelle Tang' : '01/16/1990', 'Barack Obama' : '08/04/1961', 'Ellen DeGeneres' : '01/26/1958', 'Barbara McClintock' : '06/16/1902'} def give_birthday(): print('Welcome to the birthday dictionary. We know the birthdays of:', list(birthday)) birth_lookup = input('Who\'s birthday do you want to look ...
e4bda436ec31d5a31288008f9e117b0a1eb56da1
yashshah4/Data-Science-Projects
/Miscellaneous/stronpassworddetection.py
980
4.4375
4
''' This function check of a password entered by the user is a strong Password A strong password consists of at least 8 characters 1 uppercase character 1 lowercase character 1 digit ''' # importing regex module import re def pswd(): while True: text = str(input("Please enter a password : ")) if l...
ba01dc7bb526124fa41bcca991ee484bff503ce5
jaymit31/Deep-Learning-Specialization
/Course 2: Improving Deep Neural Networks Hyperparameter Tuning, Regularization and Optimization/week2/Optimization Methods.py
42,381
4.53125
5
Optimization Methods Until now, you've always used Gradient Descent to update the parameters and minimize the cost. In this notebook, you will learn more advanced optimization methods that can speed up learning and perhaps even get you to a better final value for the cost function. Having a good optimization algorithm...
6eaed8fa7755741ad30a31c0c422b3f7e3abf6ad
npatel37/Tflow_DL
/2_basics.py
456
3.84375
4
import tensorflow as tf ### -- this is called making a "graph" where you don't run anything! x1 = tf.constant(5) x2 = tf.constant(6) result = tf.mul(x1,x2) ## multiplication print(result) ## --- note: No computation has been done until now! ## -- To actually excecute the multiplication you have to run the session. #...
71bcbfbe3e1fef79dd633b5aa218b2c72e4ec2e9
Rllst/quotes_bot
/database.py
765
3.703125
4
import sqlite3 class Database: def __init__(self, database_file): self.connection = sqlite3.connect(database=database_file) self.cursor=self.connection.cursor() def get_all_quotes(self): with self.connection: return self.cursor.execute("SELECT * FROM `quotes`").fetchall() ...
2a49752614fb7fedfb14055e248ac7207752b46a
crliu3227/practice
/reversesentence.py
581
4
4
# -*- coding: utf-8 -*- # 题目描述 # 将一个英文语句以单词为单位逆序排放。例如“I am a boy”,逆序排放后为“boy a am I” # 所有单词之间用一个空格隔开,语句中除了英文字母外,不再包含其他字符 # 输入描述: # 将一个英文语句以单词为单位逆序排放。 # 输出描述: # 得到逆序的句子 def main(): sentencelist = input().split() sentencelist.reverse() for word in sentencelist: print(w...
e7ccd22717c1870007c801faf7691a09416915e8
jovannovarian1117/stephanusjovan
/Homework 2 Mr.Jude.py
3,596
4
4
# Homework # Question 1 #def max_of_three(x,y,z): # list = [x,y,z] # print(max(list)) #max_of_three(3,5,1) # Question 2 #def list(anything): # i = 0 # for i in range(len(anything)): # print(len(anything)) #anything = ["a","b","c","d"] #print(len(anything)) # Question 3 #def vowel(st...
abb56e29df91f6859002132e08cea84655fc9cca
tkage2/sudoku_solver
/sudoku_gui.pyw
3,351
3.609375
4
from tkinter import ttk from tkinter import messagebox import tkinter as tk from string import ascii_uppercase import sudoku class Application(tk.Frame): def __init__(self, master=None): super().__init__(master) self.master = master self.create_widgets() # Function for creating widge...
5c0c6ae46b209557fe86e0b7c765af7baf5844be
avinash625/CodingProblems
/Hackerrank/Recursion/Recursive_Digit_sum.py
437
3.75
4
""" Problem Link: https://www.hackerrank.com/challenges/recursive-digit-sum/problem """ def getSum(number): if number<10: return number else: tempsum = 0 while number > 0: tempsum = tempsum + number%10 number = number/10 return getSum(tempsum) values = ra...
98786e10aaa23fbf6b13f5f0b48d972e835195d9
Sam40901/Variables
/assignment revision excersise 5.py
977
4.1875
4
print("hello, this program will ask for the dimensions of a lift and a fridge, and work out how much space will be left in the lift once the fridge is inside.") lift_height = float(input("please enter the lifts height: ")) lift_width = float(input("please enter the lifts width : ")) lift_depth = float(input("p...
bdd11314e44b5fd0327fc095492d73049954b2b1
kaleksandrov/advanced-python-training-labs
/word-count/profiler.py
493
3.59375
4
#!/usr/bin/env python3 import time def now(): """Gives the current time into milliseconds""" return int(round(time.time() * 1000)) class Profiler(object): """A context manager that measures the time for execution its content""" def __enter__(self): self.start = now() def __exit__(self, ...
86e2420fa1fda8041268067ce4b31a8babbff22a
felipesant0s/Python
/PythonZumbis/Modulo2/questao01.py
650
3.984375
4
#!/usr/bin/python a = int(input('Valor do Lado 1 : ')) b = int(input('Valor do Lado 2 : ')) c = int(input('Valor do Lado 3 : ')) ok = False if ((a + b) > c) == True and ((b + c) > a) == True and ((a + c) > b) == True: print('Triangulo Existe') ok = True else: print('Não existe') if ok: if (a == b) and ...
f89624c6ee48a43631748844c4ea8bd4c27db0c8
felipesant0s/Python
/PythonZumbis/Modulo1/questao03.py
257
3.875
4
#!/usr/bin/python dias=int(input('Digiteo valor de dias Dias: ')) horas=int(input('Digite o valor das Horas: ')) minutos=int(input('Digite o valor dos minutos minutos: ')) segundos=(minutos*60)+(horas*3600)+(dias*86400) print "Total em segundos:",segundos
5d7466fc72da27f44af5854e4f361a838b02a533
alexoliux/1Prack
/1.3.py
333
3.578125
4
import math from math import * def f13(n, m): sum1 = 0 for i in range(1, n + 1): sum1 += exp(i) - pow(i, 4) - 28 sum2 = 0 for i in range(1, n + 1): for j in range(1, m + 1): sum2 += 18 * pow(i, 7) - sin(j) return sum1 + sum2 print('%.2e' % f13(22, 47)) print('%.2e' % ...
980cab98ebcefb7a75bdf977e6a19138adba389c
scliftas/Small-side-projects
/keyword-encryption.py
3,124
4.40625
4
#Keyword Encryption/Decryption Program import time #Imports the time module, allowing the script to be paused later on. print("Welcome to this keyword encryption and decryption program!") time.sleep(1) ...