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
7f86d00a7c2e9d1637a1999ba40e364446978415
shubhamjain31/demorepo
/Data_Structure/bubble_sort.py
398
3.921875
4
def bubble_sort(lt): for i in range(0, len(lt)-1): for j in range(0, len(lt)-i-1): # descending order if lt[j] < lt[j+1]: lt[j], lt[j+1] = lt[j+1], lt[j] # ascending order # if lt[j] > lt[j+1]: # lt[j], lt[j+1] = lt[j+1], lt[j...
43ce4ebc546448138f08c44761f4486c5347fe63
shubhamjain31/demorepo
/Data_Structure/linear_search.py
373
3.734375
4
def linear_search(lt, num): flag = False for index, element in enumerate(lt): if element == num: flag = True break if flag == True: print('Element Present At {}'.format(index)) else: print('Element Not Found') lt = [23, 45, 12, 4, 89, 64, 10, 4] sea...
2eac944c973274b03f590771c2a9019e0ab63fe8
shubhamjain31/demorepo
/OOPS_Concept/Destructor.py
257
3.515625
4
class Employee: #constructor initializing def __init__(self): print('Employee Created') #Deleting(Calling constructor) def __del__(self): print('Destructor called, Employee Deleted') emp = Employee() del emp
c66764a4eb1d70c1c977e2eb46882fbcd45c5647
shubhamjain31/demorepo
/Python_practice/Merge_Two_Dictionaries.py
115
3.921875
4
x = {"a":1,"b":2} y = {"b":3,"c":4} #In python 3.5+ z = {**x,**y} print(z) #In python 2x z = dict(x,**y) print(z)
41bac5b84ed3e03a44faaf6a3cdcb39649e8ba0d
shubhamjain31/demorepo
/Python_practice/Practice_10.py
330
4.125
4
from collections import Counter str = 'In the example below, a string is passed to Counter. It returns dictionary format, with key/value pair where the key is the element and value is the count. It also considers space as an element and gives the count of spaces in the string.' count = Counter(str).most_common(10) pr...
40df186632c8244aeaecd692be1b45a730ec9fdb
Ilia69/module0_number_predict
/search_alg.py
1,885
3.875
4
def binary_search(left_edge, right_edge, number): '''Реализует подсчёт числа шагов при поиске number в отрезке [left_edge, right_edge] при помощи двоичного поиска''' count = 1 left = left_edge right = right_edge predict = round((right - left) / 2) if (left == number) or (right == number)...
41fa658e13b359f674d71e7728b4333203b0a3a6
sampleprojectt/foss_project_changed
/main.py
3,685
3.546875
4
#AIzaSyCxVRqztJej5NYJZCnVFDCA5UuEoC7HfiY #https://www.youtube.com/playlist?list=PLonJJ3BVjZW6_q8gh7XoLUIhRIyBcYJLP import requests import os import youtube_dl import argparse import sys # Set up command line options for this program parser=argparse.ArgumentParser() parser.add_argument("url",help="URL is the url of the...
59ebc5724bff8e0dca26fbc9be0105d3ef9c1eed
hmc-aozdemir/fluency-lab
/hw3pr1.py
10,022
3.671875
4
# -*- coding: utf-8 -*- import random import math from csaudio import play, readwav, writewav from copy import deepcopy import os import wave wave.big_endian = 0 def scale(L, scale_factor): '''Given a list L, scales each element of the list by scale_factor''' return [scale_factor * n for n in L] def wrap1( ...
2b006f4a7ce122cd2ef2e919b1fa029bcf561aad
shashanks01/smart-temperature-sensor-alert
/user.py
496
3.71875
4
def register_user(): name = input("Enter your name: ") city = input("Enter your city: ") phone = input("Enter your 10 digit phone number: ") with open("D:\\Code\\Demo\\userdata.csv", 'a') as f: f.write(name + "," + city + "," + phone +"\n") print("Hello {}, Your registration is complete".f...
940c487f32ef21f5daebedb361391a278212d423
Nadeem-Abdelkader/Student-Tutor-Matching-Old
/System/application.py
599
3.75
4
from login import Login class Application: """ This is the main class that initialises the Login class and calls its main method (login()) which creates the login screen of the system """ # Class variables API_KEY = "mPRM67bLTWDwchrMCtBCrWbh89tQb6" login_page = None def __init__(self)...
856d7ce5875ba2a1807ad72e259ceeb731634ea0
Manjuguna/pythonpractice
/diffNMQ6969.py
98
3.546875
4
x1,y1=map(int,input().split()) mul1=x1-y1 if(mul1%2==0): print("even") else: print("odd")
0f6c9e057a74a49683a61d9e7ad58a9f61bd3bb8
Manjuguna/pythonpractice
/vow.py
358
3.578125
4
x=str(input()) li=['a','e','i','o','u','A','E','I','O','U'] li2=['B','C','D','F','G','H','J','K','L','M','N','P','Q','R', 'S','T','V','W','X','Y','Z','b','c','d','f', 'g', 'h', 'j', 'k','l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z'] if x in li: print("Vowel") elif x in li2: print("Consonan...
7e8bc087a18bb108549004a3f870f8ee720d25bd
Manjuguna/pythonpractice
/concatStr.py
64
3.5625
4
str1,str2=map(str,input("").split()) str3=str1+str2 print(str3)
1bed89c1112e4f262f47c99ddad7fcb2ec912652
Manjuguna/pythonpractice
/avg.py
138
3.5
4
x=int(input()) li=list(map(int,input("").split())) su=0 avg=1 for i in range(0,x,1): su=su+li[i] avg=su//x a=int(avg) print(avg)
a866463640bf268dc00ece18ea037e28c70cb05c
Manjuguna/pythonpractice
/Q60.py
69
3.59375
4
x=int(input("")) su=0 for i in range(1,x+1,1): su=su+i print(su)
6001331a4f541d5a0e27474df17257883c97955c
Siddardha21/NUMERICAL-METHODS
/bisection method.py
339
3.5625
4
import sympy as sym from sympy import * x=symbols('x') a=0 b=3 fx=2*x-5 for i in range(8): x_i=(a+b)/2 value_a=fx.subs(x,a) value_b=fx.subs(x,b) value_x_i=fx.subs(x,x_i) print("a\t=",a,"\tb\t=",b,"\txi\t=",x_i) if value_a<0 and value_x_i<0: a=x_i else: ...
6ad58d5245bad903ce16648f61d2a31508fe8b51
Siddardha21/NUMERICAL-METHODS
/Differentiation_3_Formula.py
2,974
4.15625
4
from sympy import Symbol, Derivative import sympy as sym import math x = Symbol('x') # Given the Initial Conditions. fx = x**3 - 6*x**2 + 11*x - 6 x_gvn = 0.5 h = 0.5 # ---------------------------------------------- x_plus_h = x_gvn + h x_minus_h = x_gvn - h # ------------------------------------...
d39fd6e5e119959aa925225efd01b46abce8243f
tt-n-walters/uria-python
/adv_dictionaries/adv_dictionaries.py
696
4.125
4
hair_colours = { "Arthur": "ginger", "Bill": "ginger", "Charlie": "ginger", "Draco": "blond", "Errol": "feathers", "Fred": "ginger", "George": "ginger", "Harry": "black" } # Accessing items that may not exist print(hair_colours.get("Lucius", "Hair colour not found.")) # keys, values, ...
2ed22bc9d9e9ab4e4ca9c1fa48df6f3af4f959f4
tt-n-walters/uria-python
/week8_session2/exercise5.py
540
3.65625
4
# Tagging I # Tag the following text in english. # Also, the function pos_tag can receive 2 arguments: the text and the language. Set the language to "universal" an spot the differences from english from nltk.tokenize import word_tokenize from nltk.tag import pos_tag text = ''' Joe waited for the train. The train was...
c5e1487754c260293e3f030307ef0270207ac700
kimbyungsang/air
/python/headfirstpython/ch6_data_object2.py
2,470
3.640625
4
class AthleteList(list): def __init__(self,a_name, a_dob=None, a_records=[]): list.__init__([]) self.name = a_name self.dob=a_dob self.extend(a_records) def top3(self): return(sorted(set(sanitize(each_data) for each_data in self))[0:3]) def sanitize(time_stri...
2ef7088f45b225f59a6358cf98b05948509938eb
SirajKarim/Python-Crash-Course
/Chap9.py
3,026
4.1875
4
# class Dog(): # def __init__(self,name,age): # self.name=name # self.age=age # def sit(self): # print(self.name.title() + " is now sitting") # def roll_over(self): # print(self.name.title() + " is now rolled over ") # my_dog = Dog("tommy",14) # print("My dog name is " +...
f802db5a12af9f213fbed9bfa6731e8af07813e8
HernanMontenegro/AirBnB_clone
/tests/test_console.py
829
3.5
4
#!/usr/bin/python3 '''Test for the console''' import unittest import cmd import pep8 from console import HBNBCommand class ConsoleTest(unittest.TestCase): '''Test class for the main concole''' def test_obj_creation(self): '''Test when an object is created''' self.assertFalse(HBNBCommand().o...
14c62bf5c42a6acc35fcf498f6a723da99d231bb
numbertheory/pico-fermi-bagels
/bagels.py
1,641
3.984375
4
"""Pico-Fermi-Bagels game.""" # The goal here was to make a pico-fermi-bagels game that used # math to evaluate the guesses, rather than string manipulation. from __future__ import print_function import random # All guesses are compared to the magic number. MAGIC_NUMBER = int(random.randrange(100, 1000)) WIN = False G...
07abe52b74da059b548eebb9297dc24412c979e5
jmtorrespalma/Restabarteria4-0
/SourceCode/programa.py
1,652
3.625
4
#!/bin/python3 from tkinter import * def alta_usuario(cadena): print(cadena) ### Creamos frame principal root = Tk() ### Asigns a window to root root.minsize(500,500) ### Sets window minimum size to 500x500 mainLabel = Label(root, text='Gerente', font=('Verdana', 30)) ### Creates a label mainLabel.place...
8f0071f4d88460020d8078f17a45fd340e8b1c09
Serrones/grupyladies
/ex6_pyladies_divisao.py
313
3.9375
4
# ex 6 pyladies funcao divisao def divisao(a,b): c = a / b d = a // b e = a % b print('A divisão entre {} e {} é: {}'.format(a,b,c)) print('A divisão arredondada entre {} e {} é: {}'.format(a,b,d)) print('O resto da divisão entre {} e {} é: {}'.format(a,b,e)) # divisao(2325.2,5)
40c2c88f9389d1c2ccfa53e8d4f6872d64121c11
Serrones/grupyladies
/ex5_pyladies_soma.py
170
3.6875
4
# exercicio 5 - funcoes def soma(): a = int(input('Favor digitar um número:')) b = int(input('Favor digitar outro número:')) return a + b #print(soma())
7d8c49d5ffbca44c95fef73f9162cf5ede025cde
abhik1368/frowns
/perception/rings.py
7,659
3.515625
4
"""A new ring detection algorithm inspired by talking to various people""" from frowns.Cycle import Cycle from frerejaque import frerejaqueNumber from InRings import getAtomsBondsInRings class Path: """A span is really a path back to a central atom. Consider it a type of linked list that can compute a linear ...
446e3523de7edff34b7fad7e1fd7c4ec5fb0169a
abhik1368/frowns
/Chirality/TetraHedral.py
2,462
3.78125
4
"""TetraHedral.T(order, chirality) order = atoms in the input order of the smiles string. chirality = @ anti-clockwise @@ clockwise TetraHedral.T.getChirality(neworder) -> return the chirality of the new order of the atoms order -> atom order of the molecules around the center. If the number of atom...
7d9f2c990d240a2cb6fcd868c7ce45ebd4243c7a
jackyk/bc-7-ContactManager
/venv/Test/storage.py
436
3.59375
4
import sqlite3 class ContactStorage: def __init__(self): self.db_1 = sqlite3.connect("test1.db") self.db_1 = db_1.execute('''CREATE TABLE USERS(ID INT PRIMARY KEY AUTO INCREMENT,NAME TEXT NOT NULL,PHONENUMBER INT NOT NULL)''') self.cursor = db_1.cursor def user_input(self,name, phone...
38290d1464013c2912ee9a80240b60bb2cf5122d
jackyk/bc-7-ContactManager
/venv/Test/userinput.py
1,070
3.765625
4
from storage import ContactStorage class ContactList: ''' Create a contact list from users input, Confirm how many times it appears Store it in ContactStorage ''' def __init__(self,name,phonenumber): self.name = name self.phonenumber = phonenumber def name_number...
da0ca896219f48f99ca7f365d8b0cd5f103d9966
DaltonSchutte/DrBertsOffice
/drbert/colab.py
3,572
3.734375
4
import os from google.colab import drive class ColabLink: """Links Colab Notebook to Google Drive Provides collected interface to connect to your drive, load data, save data, and interact with the specified directory Attributes ---------- base_dir : str path to the base directory paths : dict ...
d7e12cb1a4379debc5e4ad84f8ba56ee670519b7
INRIA/scikit-learn-mooc
/python_scripts/ensemble_adaboost.py
7,633
3.765625
4
# --- # jupyter: # kernelspec: # display_name: Python 3 # name: python3 # --- # %% [markdown] # # Adaptive Boosting (AdaBoost) # # In this notebook, we present the Adaptive Boosting (AdaBoost) algorithm. The # aim is to get intuitions regarding the internal machinery of AdaBoost and # boosting in general. # ...
b27e6441361c233f22e3a1f652736c8f2b4b481f
INRIA/scikit-learn-mooc
/python_scripts/trees_sol_01.py
3,642
4.34375
4
# --- # jupyter: # kernelspec: # display_name: Python 3 # name: python3 # --- # %% [markdown] # # 📃 Solution for Exercise M5.01 # # In the previous notebook, we showed how a tree with a depth of 1 level was # working. The aim of this exercise is to repeat part of the previous experiment # for a depth with 2...
57715829be1b33c4d32d1b74b0b88e12dd00b734
INRIA/scikit-learn-mooc
/python_scripts/cross_validation_grouping.py
6,570
3.734375
4
# --- # jupyter: # kernelspec: # display_name: Python 3 # name: python3 # --- # %% [markdown] # # Sample grouping # We are going to linger into the concept of sample groups. As in the previous # section, we will give an example to highlight some surprising results. This # time, we will use the handwritten di...
46537b1ef2da8a4f8a0ac0d527c19e70d8e05d9d
INRIA/scikit-learn-mooc
/python_scripts/linear_models_ex_05.py
2,411
3.609375
4
# --- # jupyter: # jupytext: # text_representation: # extension: .py # format_name: percent # format_version: '1.3' # jupytext_version: 1.14.5 # kernelspec: # display_name: Python 3 # name: python3 # --- # %% [markdown] # # 📝 Exercise M4.05 # # In the previous notebook we set `...
116b28da618e5426d93528f54dd08fc976255058
INRIA/scikit-learn-mooc
/python_scripts/trees_dataset.py
3,287
3.9375
4
# --- # jupyter: # kernelspec: # display_name: Python 3 # name: python3 # --- # %% [markdown] # # The penguins datasets # # In this notebook, we make a quick presentation of the [Palmer penguins # dataset](https://allisonhorst.github.io/palmerpenguins/) dataset. We use this # dataset for both classification ...
13fd3e41ce9a30347c7f97cc5f99fc994a4e542f
INRIA/scikit-learn-mooc
/python_scripts/linear_models_sol_04.py
8,744
4.28125
4
# --- # jupyter: # kernelspec: # display_name: Python 3 # name: python3 # --- # %% [markdown] # # 📃 Solution for Exercise M4.04 # # In the previous notebook, we saw the effect of applying some regularization on # the coefficient of a linear model. # # In this exercise, we will study the advantage of using s...
c769620505a71588df3b63c67c65b3297f185248
TeacherAngelica/PSB-Console-Game
/team.py
3,677
3.546875
4
import utils import json playerOneTeam = [] playerTwoTeam = [] def build(numberOfCharacters, player, playerName): count = 0 while count < numberOfCharacters : utils.clearScreen() count += 1 ordinal = None if (count == 1): ordinal = 'first' elif (count == 2):...
5da4d887c506471ee467d7d8a6a94b72a2f77ee3
lpatruno/airline-time-analysis
/PythonScripts/get_ny_code.py
404
3.71875
4
""" This script is to extract the airport code for JFK airport The script prints out all rows from the airports.csv file where the city is 'New York' @author Luigi Patruno @date 28 Apr 2015 """ import csv # relative path to file airports = '../data/airports.csv' with open(airports) as csvfile: reader = csv.read...
f99c13691abd25532edd5e54e3945882d799dd4b
szasohel/lca
/Documents/udacity/projects/p9lca/lca.py
2,217
3.96875
4
head = None class Node(object): def __init__(self,root): self.root = root self.right = None self.left = None # Function to insert a new node at the beginning def push_right(node, new_data): new_node = Node(new_data) node.right = new_node return new_node # Function to insert a new node at th...
2c9c2ae9b60aaeb264f957503cd069aa46867eb5
guptakartik0235/Computer_vision-Image
/5.py
1,094
3.625
4
import cv2 c = (str(input("You want Image to be Canny :- ")).lower()) path = "Ai_Practical\images\lambo.jpg" if c == "y": Image = cv2.imread(path) Image_C = cv2.Canny(Image,10,10) cv2.imshow("2nd",Image_C) cv2.waitKey(0) else : g = (str(input("You Want Image to be Grayscale :...
a882e0c2d57311412643bc79da0919b917904478
Nirzak/Digital-Signal-Processing
/5 DFT of a signal.py
304
3.609375
4
import numpy as np x = [0,1,2,3] N = len(x) X = [0+0j,0+0j,0+0j,0+0j] def dft(x,N): for K in range(N): temp = 0+0j for n in range(N): temp = temp+x[n]*np.exp(-2j*np.pi*n*K/N) X[K] = np.round(temp) return dft(x,N) print('Discrete Fourier Transform of x =',X)
426c41346139c93dd18748356fd3a5808508ce81
dabslee/Leetcode
/1TwoSum/1TwoSumSort.py
1,244
3.59375
4
# returns the key of a value in a value-sorted pseudo-dict def binarySearchDict(thedict, thevalue): min = 0 max = len(thedict) while min < max: print(f"searching from {min} to {max} for {thevalue}") mid = (max+min)//2 if thedict[mid][1] > thevalue: max = mid else...
c674e6249e91a08a9684ee19619d15f2e03bc8db
ataeiamirhosein/NetFuncVirt
/MultibitNode.py
4,367
3.640625
4
# date March 2020 import itertools import timeit STRIDE = 3 class MultibitNode(object): def __init__(self): self.children = {} def AddChild(self, prefix, path): if path == "": return if len(path) < STRIDE: # if the path is shorter than the stride # Expand...
e5491519fcbf505a030ab3c669884a9de78b8392
nikitakumar2017/Assignment-3
/StringQuestion3.py
133
4.09375
4
'''Replace the word "World" with your name in the string "Hello World". ''' str1="Hello World" print(str1.replace("World","Nikita"))
a5506650883d751c5bb2e131aed30360ea4713ab
RomeoMed/INT3803_finalProject
/data_cleanser/cleanser.py
8,567
3.921875
4
import csv class Cleanser: def __init__(self, infile): self._infile = infile self._outfile = 'TripAdvisor_sanitized.csv' def _clean_up(self) -> None: """ This method is used to parse the original .csv file, convert it to utf-8 encoding, and remove any of the latin-1 ch...
1fd98ee0243d3a61fef92ab759509ddb2e5c7b17
HaoMoney/leetcode
/lc_jz22.py
485
3.671875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def getKthFromEnd(self, head: ListNode, k: int) -> ListNode: cur = ListNode(0) cur = head length = 0 if not head: return ...
0198222bf397babfa2bca245f3e419735f0a5acf
cfizette/seeing-eye-pi
/camera_app/buttons.py
804
3.8125
4
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) class GPIOButton(object): def __init__(self, pin, pull_up_down=GPIO.PUD_UP): self.pin = pin self.pull_up_down = pull_up_down GPIO.setup(pin, GPIO.IN, pull_up_down=pull_up_down) ''' If pin is set with a pull_up resistor, then its...
fff470a80f9c34172c57d8ec756e2544dce9d6d8
Kiran-Udayan/HackerRank
/Problem-Solving/Simple-Array-Sum.py
777
3.953125
4
#!/bin/python3 import os import sys # # Complete the simpleArraySum function below. # def simpleArraySum(ar): # # Write your code here. sum=0 #initialising sum since we are adding something to it for i in ar: sum+=i #adding the sum of each element one-by-one on each iteration re...
85e5ce9d95af898fec389900409d64817c336fc2
carbon-ahs/python_OOPConceptPractice
/method_overloding.py
393
3.765625
4
class Numbers: def sum(self, a=None, b=None, c=None): s = 0 if a != None and b != None and c != None: s = a + b + c elif a != None and b != None: s = a + b else: s = a return s numbers = Numbers() print(numbers.sum(10+20+30))...
79465925dc5c3a7379d1219dbf50ac9c6f971f43
sky-bot/Interview_Preparation
/LeetCode_30days_challenge/Number_Complement.py
364
3.640625
4
def findComplement(num): binary = list(bin(num).replace('0b', "")) invertedBinary = list() for x in binary: if x == '0': invertedBinary.append('1') else: invertedBinary.append('0') invertedBinaryString = "".join(invertedBinary) return int(invertedBinary...
ad947590ffed3dcfe73337bea8ffe8e68b6910ef
sky-bot/Interview_Preparation
/Educative/Permutation_in_a_String_hard/sol.py
1,806
4.40625
4
# Given a string and a pattern, find out if the string contains any permutation of the pattern. # Permutation is defined as the re-arranging of the characters of the string. For example, “abc” has the following six permutations: # abc # acb # bac # bca # cab # cba # If a string has ‘n’ distinct characters it will hav...
a1ff9c00543721443a49cee0b3c9ecbe1741f740
sky-bot/Interview_Preparation
/Educative/LinkedList/Palindrome_LinkedList.py
1,343
4.125
4
class Node: def __init__(self, value, next=None): self.value = value self.next = next def is_palindromic_linked_list(head): slow = head fast = head tail = None count = 1 middle = None while(fast.next and fast.next.next): slow = slow.next fast = fast.next.n...
70f85fcfec141a8b2f27ca86232a9c8fbeb43aa9
sky-bot/Interview_Preparation
/LeetCode/path_sum_II.py
840
3.515625
4
class Solution: def pathSum(self, root: TreeNode, targetSum: int) -> List[List[int]]: all_paths = list() self.inorder(root, [], 0, all_paths, targetSum) return all_paths def inorder(self, root, list_till_now, sum_till_now ,all_paths, target): if no...
a4a5c4d3279e12893add93e46f0db037a83a4d22
Dukeo0/first_project
/projekt_5_6.py
195
3.84375
4
my_str = "Elemér" vanbenne = False for c in my_str: if c == "e": vanbenne = True break if vanbenne: print("Van benne 'e' betű") else: print("Nincs benne 'e' betű")
863dc767e4f8df6ac15ed2e4281365f0e4a4b569
Dukeo0/first_project
/Projekt_max_szam.py
463
3.984375
4
#adj meg 5 számot, kiírja a számokat, és megkeresi benne a maxot numbers = [] print("Adj meg öt számot:\n") while len(numbers) < 5: num = input() numbers.append(int(num)) print(f"A megadott számok: {numbers}") max = numbers[0] for num in numbers: print(f"Ezt vizsgáljuk:{num}") print(f"Ez most a legna...
604da6753ccd6584b1cdc2f8feff7bb7a6f5b89d
darcysaffery10/codewars-solutions-python
/disemvowel.py
277
3.765625
4
# https://www.codewars.com/kata/52fba66badcd10859f00097e def disemvowel(string): newWord = string vowels = ['a', 'e', 'i', 'o', 'u'] for letter in string: if letter.lower() in vowels: newWord = newWord.replace(letter, '') return newWord
ba5aef692e9fe6d2de5e3f5cd07c57b19f56bed4
ikonnikovaev/coffeemachine
/coffeemachine.py
4,203
4.34375
4
#For the espresso, the coffee machine needs 250 ml of water and 16 g of coffee beans. It costs $4. #For the latte, the coffee machine needs 350 ml of water, 75 ml of milk, and 20 g of coffee beans. It costs $7. #And for the cappuccino, the coffee machine needs 200 ml of water, 100 ml of milk, and 12 g of coffee. It co...
f5896bad23e67e10cc044f16e52ae94cb45d464a
sandeep-skb/Algorithms
/Graphs/depth_first_search.py
1,300
4.03125
4
class Stack: def __init__(self): self.l = [] def push(self, val): self.l.insert(0, val) def pop(self): return(self.l.pop(0)) def peek(self): return (self.l[0]) def isEmpty(self): return (len(self.l) == 0) class Graph: def __init__(self, num_vertices): self.num_vtx = num_...
95f8f18abcf91e0382821f5d78fbfdca3f6c38e9
sandeep-skb/Algorithms
/Searching/BinarySearch.py
551
3.953125
4
def binarySearch(arr, target): l = 0 r = len(arr)-1 while (l < r): mid = ((r-l)//2) + l if arr[mid] == target: return mid if arr[mid] < target: l = mid + 1 else: r = mid if arr[l] == target: return l else: return -1 arr = [1,2,3,5,6] # In the array print(binary...
54b43807690df33d4e4092254bc4d352294c6868
Rasmunis/bioai
/project1/crossover.py
4,166
3.796875
4
from random import random, randint, choice import copy """ HOW THIS CROSSOVER WORKS Take a random chunk from a random car of one parent (P1), with a length between 2 and the length of the car, and insert it into a random car of another parent (P2), while deleting the duplicate customers from elsewhere in P...
b63c9c809c1509bfd08b7089fff5737d58cc6007
hbalakrishna/DataStructures
/Code/BSTMirror.py
1,067
3.90625
4
class Node: # Utility function to create new node def __init__(self, key): self.key = key self.left = None self.right = None def __str__(self, depth=0): ret = "" # Print right branch if self.right != None: ret += self.right.__str__(depth + 1) ...
89b954dae92f111bd25665b4a16fb11d70e6e0b2
hbalakrishna/DataStructures
/CodePad/codepad.py
495
3.5625
4
# str1_ = 'dog' # str2_ = 'god' # d= {} # # for i in str1_: # if i not in d: # d[i] = 1 # else: # d[i]+=1 # # for i in str2_: # if i not in d: # print('Not in permutation') # exit(0) # else: # d[i] -= 1 # # result_ = all(x == 0 for x in d.values()) # if result_: #...
38e43c5a8844c8f95fc059a9745f3a6648e44be0
hbalakrishna/DataStructures
/Code/LL_Length.py
4,342
4.3125
4
class Node: # Function to initialise the node object def __init__(self, data): self.data = data # Assign data self.next = None # Initialize next as null # Linked List class contains a Node object class LinkedList: # Function to initialize head def __init__(self): self.head = ...
32f60b1f412b0c4860a607897ae25831682cb84a
hbalakrishna/DataStructures
/Code/candy.py
114
3.53125
4
candy = [1,1,2,2,3,3] if len(candy)/2 > len(set(candy)): print(len(set(candy))) else: print(len(candy)/2)
6bb38a585bd97e3846ff8964effb150591e7eeba
m-yasir/numerical-computing
/bisection_method.py
893
3.5
4
def bisectionMethod(xl, xu, f, currError = 1, calls = None, iters = 1): if (calls != None and calls <= 0): return (xl, xu) xr = (xl+xu)/2 if (currError <= 0.1): return (xl, xu) R = f(xl)*f(xu) if R < 0: currError = abs(xr-xu)/xr print(f"#{iters} Current Error: ", cu...
263f5853130393f085f3388802589fa8c1bb34d0
aakacenoks/finding-path
/main.py
6,466
3.84375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys import csv import re import numpy def get_dictionary_from_csv(file_path): """ Get CSV file content as dictionary. :param file_path: Relative path to source file. :return: Dictionary containing CSV file content. """ full_dictionary = []...
98433ce57a69774afb35484b6aad3789122dc518
gshachar12/music-generator
/lstm.py
9,291
3.703125
4
import numpy as np from funcs4nn import activation, derivative """ LSTM model-version 1.0 *General explanation: *variables and dimensions: x-(n_x, m, T_x) hidden state (a)-(n_a, m, T_x+1) cell-(n_a, m, T_x+1) y-(n_y, m, T_x) parameters: weights- biases- reference: -LSTM https://www.g...
179576de0a97a3a2957d7cdcedf93d53e203869e
Switters37/helloworld
/lists.py
758
4.25
4
#print range(10) #for x in range (3): # print 'x=',x #names = [['dave',23,True],['jeff',24,False],['mark',21,True]] #for x in names: # print x #print names [1][1] #numbers in square brackets above will index over in the list. So in this case, the list will index over 1 list, and then 1 space in th...
486f7302cfe0e48456503a8b82b4e5d0c87c1690
HarryZ7G/MachineLearning11
/Assignment 4/center_initializations.py
1,596
3.734375
4
""" CSCC11 - Introduction to Machine Learning, Fall 2020, Assignment 4 B. Chan, S. Wei, D. Fleet """ import numpy as np def kmeans_pp(K, train_X): """ This function runs K-means++ algorithm to choose the centers. Args: - K (int): Number of centers. - train_X (ndarray (shape: (N, D))): A NxD matrix co...
0aeb414165faeabbf012b1f4b7f8b23986f2cf5d
clepperdesign/miscellaneous
/horridNames.py
522
3.984375
4
import random first = ['craig','phil','ayd','bryn','rya','jova','zae','avi','jace','ade','kay','bray','paiz','kayt','jayce','kam'] last = ['lyn','lynn','elle','ory','liper','lee','zlee','ree','leigh','leaigh','den','don','son','syn','myn','nee','ryn'] def makename(): newname = random.choice(first) + random.choice(...
398ce2157ca45bf2afaf892844b513f8b62e6b05
Fractal2017/myJupyterWorkflow
/myPKG/myLib.py
730
3.546875
4
import os import pandas as pd from urllib.request import urlretrieve # Get the DATA into local filesystem # https://data.seattle.gov/Transportation/Fremont-Bridge-Hourly-Bicycle-Counts-by-Month-Octo/65db-xm6k URL = 'https://data.seattle.gov/api/views/65db-xm6k/rows.csv?accessType=DOWNLOAD' """ Function get_myFreemont...
51856a2019aaf8192564b2e4868339e33fd61f49
lalyman/cme211-lalyman
/hw3/airfoil.py
12,051
3.875
4
import glob import math import os.path class Airfoil: """Returns a data table. Specifially, the method returns a table of the lift coefficient (cl),stagnation point, and pressure coefficient for various angles of attack (alpha) given alpha data files in the user-inputted directory.""" def ...
eb0c3759cc95430858bca5384a162b5c519b5f03
StoyankaNikiforova/HackBG-Python
/Week_02/Coding_skill/coding_skill.py
1,159
3.53125
4
import sys import re import json import collections def the_best_programmers(file_name): dict_of_file = {} result_dict = {} level_max = {} with open(file_name, 'r') as f: dict_of_file = json.loads(f.read()) dict_of_people = dict_of_file['people'] for person in range(len(dict_of_people)...
d7373aac985fa44f9b9d4b02b6e0cf957a7e3c40
StoyankaNikiforova/HackBG-Python
/Week_03/Fraction/fractions_test.py
258
3.609375
4
from fraction_class import Fraction def main(): print(Fraction(2, 4)) a = Fraction(1, 2) b = Fraction(2, 4) # print(a == b) # True print(a + b)# 1 print(a - b)# 0 # print(a * b) # 1 / 4 if __name__ == '__main__': main()
4672571d4995f17d8ac02b1c320894bd23224c0e
StoyankaNikiforova/HackBG-Python
/Week_15/MySite/MySite/helpers.py
1,198
3.75
4
from itertools import groupby import re def fibonacci_numbers(number): fibonacci_nums = [1] if number > 1: fibonacci_nums.append(1) for index in range(2, number): fibonacci_nums.append(fibonacci_nums[index-1] + fibonacci_nums[index-2]) return fibonacci_nums def get_factorial(...
279245527c5dbe621efb64cc8419e673079ad9ea
StoyankaNikiforova/HackBG-Python
/Week_03/Fraction/fraction_class.py
1,857
3.859375
4
class Fraction: def __init__(self, nomerator, denominator): self.nomerator = nomerator self.denominator = denominator def is_prime(self, x): if x < 1: return False for n in range(2, (x)-1): if x % n == 0: return False return True ...
584049eda57b19537e4272276eecaf11cc5f6b54
CSC591-MASE-ASA/x9115asa
/hw/code/6/optimizers.py
7,036
3.578125
4
from __future__ import division import math, random, abc class Optimizer: def __init__(self): self.print_buffer = [] @abc.abstractmethod def compute(self): return None def print_output(self): for line in self.print_buffer: print line class sa(Optimizer): def __i...
77e2a5e97c0b1f8769535849046a6f03777c5737
UniqueXiao/python-notes
/02-python-basis/02.05-list-and-tuple.py
4,235
3.953125
4
#!usr/bin/env python #-*- coding: utf-8-*- #生成列表 list是一个 有序 序列,其中的元素用 , 隔开,列表元素不需要是同一类型,甚至可以包含列表,同时列表的长度也不固定 lst_1 = [] lst_2 = list() lst_3 = range(5) #函数生成列表,[0,1,2,3,4] '''列表操作''' #查看列表长度 len(lst) #加法和乘法 lst_1 = [1,2,'hello'] lst_2 = [2,4,'world'] print lst_1 + lst_2 #输出[1,2,'hello',2,4'world'],返回 新列表,原列表不变 p...
c16eea7be98f67a95ea99ccfd7b27f308073123b
Aditya-Nannapaneni/calculator-flask-app
/utils/checkStringIsFloat.py
222
3.90625
4
def isfloat(value): ''' AIM: a boolean helper function to check if the input number is a decimal number INPUT: a number OUTPUT: True / Flase ''' try: float(value) return True except ValueError: return False
2c06ceb62b503e2733cbd407b895d58b3913c9e4
SilverQ/dl_study
/Udacity_ud187/lab01_degree.py
1,207
3.859375
4
# create a model to change the degree of celsius to fahrenheit # celsius inputs : [-40, -10, 0, 8, 15, 22, 38] # fahrenheit outputs : [-40, 14, 32, 46, 59, 72, 100] import numpy as np x = [-40, -10, 0, 8, 15, 22, 38] y = [-40, 14, 32, 46, 59, 72, 100] w = 10.0 b = 10.0 x = np.float32(x) b = np.float32(b) def hx(...
9d5fe30944a5b81658aba4240808ef9124db2642
sumeetkumar1/My_python_experience
/P2/scripts/BSA2.py
1,163
3.5625
4
# importing the required Libraries/ import urllib.request, urllib.parse, urllib.error from bs4 import BeautifulSoup import ssl # Taking User Input url = input("Enter Url:") count = input("Enter Count:",) position = input("Enter Position:",) # testing User Input try: count = int(count) position = int(position) e...
ef6861131830b086060eb94cfc93751007919e42
sumeetkumar1/My_python_experience
/P1/Scripts/10.2.py
827
3.984375
4
# reading file name fn = input('Enter file name: ') # making sure user enters valid file name try: fh = open(fn) except: print('Invalid Name') quit() # creating dictionary & list counts = dict() lst = list() # reading through the file for ln in fh: # finding the required line if ln.startswith('From '): ...
78b7179a3df8d632d6765f268f303db1a428bf1a
NihalSayyad/python_learnigs
/51DaysOfCode/005/Mathematical_Operations.py
294
3.6875
4
#Division a, b, c, d, e = 3, 2, 2.0, -3, 10 print(a/b) print(a/c) print(d/b) print(a//b) print(d//b) #Addition a+=b print(a) print([1, 2, 3] + [4, 5, 6] ) #Exponentional print(a**b) #Subtraction print(b-a) #Multiplication print(a * b) #Modulus print(-9 % 2) print(9 % -2) print(-9 % -2)
fb7682a58e138d0dd4a723716132bf16196746e6
NihalSayyad/python_learnigs
/51DaysOfCode/045/cordinates.py
817
3.5
4
members = [] for _ in range(int(input())): members.append(int(input())) edges = {} for _ in range(int(input())): cordinates = input().split() print(cordinates) if int(cordinates[0]) in edges: print(edges[int(cordinates[0])]) array = edges[int(cordinates[0])] array.append(int(cor...
9fc35c812d1c044fe5cc626b2ea9ea837c5a6362
NihalSayyad/python_learnigs
/51DaysOfCode/034/DoublyLinkedList.py
890
3.71875
4
class Node: def __init__(self, data): self.data = data self.prev = None self.next = None class DoublyLinkedList: def __init__(self): self.head = None def print(self): itr = self.head while itr: print(str(itr.data) + " <---> ", end=" ") ...
4597696a796e39a7378f09274bdab00b20bb58e0
NihalSayyad/python_learnigs
/51DaysOfCode/004/enums.py
252
3.96875
4
from enum import Enum class Color(Enum): red = 1 green = 2 blue = 3 print(Color.blue) print(Color(1)) print(Color['green']) #Iterating through Enum print([c for c in Color]) #Output = [<Color.red: 1>, <Color.green: 2>, <Color.blue: 3>]
1260a7849253566d81c9d5c8d0836f3c20b71bac
NihalSayyad/python_learnigs
/51DaysOfCode/017/Enumerator_in_py.py
221
4.15625
4
''' In we are interested in an index of a list, we use enumerate. ''' countries = ['Finland', 'Sweden', 'Norway', 'Denmark', 'Iceland'] for index, i in enumerate(countries): print(f"country {i} is at index {index}")
d7b32bf21650d53b2f613228f82e132c7b3036ec
NihalSayyad/python_learnigs
/51DaysOfCode/010/List_Slicing.py
286
4.09375
4
# reversing a list a = [1,2,3,4,5,6] print(a[::-1]) lst = ['a','b','c','d','e'] print(lst[::2]) #Shifting a list using slicing def shift_list( array, s): s %= len(array) s *= -1 shifted_array = array[s:] + array[:s] return shifted_array print(shift_list(a, -7))
3c58899faa7353f2241b49fdb9f96e414c4499cb
NihalSayyad/python_learnigs
/51DaysOfCode/016/date_time_in_py.py
521
3.890625
4
import datetime print(dir(datetime)) from datetime import datetime now = datetime.now() print(now) # 2019-12-04 23:34:46.549883 day = now.day # 4 month = now.month # 12 year = now.year # 2019 hour = now.hour # 23 minute = now.minute ...
2e9afd80a702d974aa8a6d108df0907c05174686
NihalSayyad/python_learnigs
/51DaysOfCode/039/Stack_using_deque.py
757
4.09375
4
from collections import deque class Stack: def __init__(self): self.container = deque() def push(self, data): self.container.append(data) def pop(self): return self.container.pop() def peek(self): return self.container[-1] def is_empty(self): return len(s...
79321751a6523c357e4ab8fce18107dd0ff0cd2a
NihalSayyad/python_learnigs
/51DaysOfCode/004/mySet.py
276
3.6875
4
a = {1,2,3,4,5} b = {4,5,6} print(a.intersection(b)) print(a.union(b)) print(a.difference(b)) #multi set operations #Counter from collection will not keep ordering, but keeps the count from collections import Counter counterA = Counter(['a','b', 'c','b']) print(counterA)
7efe997ac1e34afb5b9e2df228aa6b33bcf97e50
NihalSayyad/python_learnigs
/51DaysOfCode/007/Loops.py
342
4.03125
4
#Break and Continue in Loops #Break -- breaks the loop for i in range(10): if i == 4: print('Breaking at 4') break #Continue -- this will skip the current execution of further lines i = 0 while i < 10: print(i) i += 1 if i == 4: print('Skipping 4') continue print('...
193502359cd355e286eefec4d4409c1506669b04
NihalSayyad/python_learnigs
/51DaysOfCode/014/Function_as_a_Parameter.py
217
3.5
4
def sum_numbers(nums): print(type(nums)) return sum(nums) def high_order_function(f, *args): summation = f(*args) return summation result = high_order_function(sum_numbers, [1,2,3,4,5]) print(result)
7e3e522712e7d3ded71fc2c75450a400817409bc
KSaxena16/TODO-App
/todo.py
3,346
3.921875
4
from tkinter import * import random #Creating the root window root = Tk() #Change root window title root.title("My Super To Do List") #Change background color of Window root.configure(bg="white") #Change the Size of the window root.geometry("300x275") #Creating an empty list tasks =[] #Creating default list tasks ...
9b8ad3ece569038e1a5d5efd65a483fbac70b913
devanbenz/PythonStuff
/Algorithms/Sorting/Problem1.py
454
3.828125
4
#Sorting golf scores def obtainInput(): print('Please enter 10 golf scores') arr = [] for i in range(10): arr.append(int(input('Please enter a score: '))) return arr def sortScores(arr): for index in range(1,len(arr)): arrVal = arr[index] i = index - 1 while index > 0 and arr[i] > arrVal...
8e95e9d4f47c6032cb8e4693e2a10c05df77c3dd
devanbenz/PythonStuff
/Algorithms/Sorting/TestScores.py
422
4.0625
4
import BubbleSort def testScoreInput(): testScores = [] flagged = True while flagged: score = input('Please input test scores (exit if you are finished with input): ') if score == 'exit': flagged = False else: testScores.append(float(score)) return testScores scores = testScoreInput() ...
465380ce5b174a59245d0691e8394672def2d779
devanbenz/PythonStuff
/MIT OCW/LectureSix/lectureSix.py
2,618
4.40625
4
## Recursion - # **Process of repeating items in a self-similar way # '''Droste effect''' - picture within a picture # Divide and conquer # Decrease and conquer # Algorithmically we reduce a problem into smaller parts in #order to solve problems # Semantically it is a function that is called within the body #o...
2debadfdad2e64406722f2587f2f51956b29d581
devanbenz/PythonStuff
/MIT OCW/BookQuestions/approx_cube.py
374
3.875
4
cube = 27 epsilon = 0.01 guess = 0.0 increment = 0.0001 num_guesses = 0 while abs(guess**3 - cube) >= epsilon and guess <= cube: guess += increment num_guesses += 1 print('Number of guesses: ', num_guesses) if abs(guess**3 - cube) >= epsilon: print('With given properties cube cannot be approximated.') else: ...
bb17f15513d9e77d524d9396beabff0470adab0e
sejalg1019/project-97
/guessingGame.py
559
4.3125
4
import random print("Number guessing game!") number = random.randint(1,9) chances = 0 print("Guess a number between 1-9 (You only have 5 chances to guess correctly)") while chances < 5: guess = int(input("Enter your guess:")) if guess == number: print("Congratulations, you won!") break ...