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
ae293b17e42c469af4052399bec4f35eb4351fb2
asperaa/back_to_grind
/Linked_List/add_two_num_2_no_modify.py
2,217
3.953125
4
"""We are the captains of our ships, and we stay 'till the end. We see our stories through. """ class ListNode: def __init__(self, val): self.val = val self.next = None class LinkedList: def __init__(self): self.head = None def print_list(self, head): mover = head ...
6ec77e863ccf92164c7c17d6b28151e9acfc910b
asperaa/back_to_grind
/Trees/leaf_similar_trees_space_o(h).py
972
3.515625
4
"""We are the captains of our ships, and we stay 'till the end. We see our stories through. """ """872. Leaf-Similar Trees [T - O(n) and S - O(h)] """ class TreeNode: def __init__(self, val): self.val = val self.left = None self.right = None class Solution: def dfs(self, stack): ...
b53e227ca249e916320e36c9bc5864af1a8fb933
asperaa/back_to_grind
/Graphs/323. Number of Connected Components in an Undirected Graph.py
781
3.5
4
"""We are the captains of our ships, we stay 'till the end. We see our stories through. """ """323. Number of Connected Components in an Undirected Graph """ class Solution: def countComponents(self, n, edges): visited = [False for _ in range(n)] graph = {i: [] for i in range(n)} num_conn...
66feab7cb624e525503a09966386d4df919c0c75
asperaa/back_to_grind
/Two_Pointers/345. Reverse Vowels of a String.py
922
3.875
4
"""We are the captains of our ships, and we stay 'till the end. We see our stories through. """ """345. Reverse Vowels of a String """ class Solution: def reverseVowels(self, s): str_list = list(s) start, end = 0, len(str_list) - 1 vowels = { 'a': True, 'e': True, 'i...
54e48516833d112f94e6d7dfffd5b405b1073fa2
asperaa/back_to_grind
/Linked_List/add_two_num.py
1,559
3.609375
4
class ListNode: def __init__(self, val): self.val = val self.next = None class LinkedList: def __init__(self): self.head = None def push(self, val): node = ListNode(val) if not self.head: self.head = node return temp = self....
9fa10a479f86a747299c3f077d27f7aaefe98b8b
asperaa/back_to_grind
/bactracking/1215. Stepping Numbers.py
916
3.78125
4
"""We are the captains of our ships, and we sty 'till the end. We see our stories through. """ """1215. Stepping Numbers """ class Solution: def countSteppingNumbers(self, low: int, high: int): self.ans = [] for i in range(10): if i == 1: # 1 comes 2 times (i.e dfs from 0 gives 1 too) ...
890af9b73d4654bc9e45db4e4b5aa3f7d919f498
asperaa/back_to_grind
/Trees/sum_of_left_leaves.py
793
3.734375
4
"""We are the captains of our ships, and we stay 'till the end. We see our stories through. """ """404. Sum of Left Leaves """ class TreeNode: def __init__(self, val): self.val = val self.left = None self.right = None class Solution: def sum_of_leaves_dfs(self, root, is_left_child):...
3bb09a3b231b7e412c85f72402c8d01f6c27d0d7
asperaa/back_to_grind
/Trees/binary_tree_paths.py
777
3.71875
4
"""We are the captains of our ships, and we stay 'till the end. We see our stories through. """ """257. Binary Tree Paths """ class TreeNode: def __init__(self, val): self.val = val self.left = None self.right = None class Solution: def dfs(self, root, curr_path): if not roo...
79322d8a1808f72937c6d571971d4fe6eb93ca7b
asperaa/back_to_grind
/DP/956. Tallest Billboard.py
843
3.546875
4
"""We are the captains of our ships, and we stay 'till the end. We see our stories through. """ """956. Tallest Billboard """ class Solution: def tallestBillboard(self, rods): summ = sum(rods) n = len(rods) dp = [[float('-inf') for _ in range(2*summ + 1)]for _ in range(n+1)] d...
a8c15a7782ec33bef75321b0250755ab31ad9c9e
pooja-subramaniam/webscraping_2018
/bild_scraping.py
5,273
3.546875
4
# coding: utf-8 # Created by Pooja Subramaniam and Marc Aurel Vischer on Tue, May 8. # Temperature is given as a tuple of daily high and low value, both in degrees Celsius as ints. # # Precipitation is given as "probability" as float. # # Wind is given as a tuple of strength in Bft (int) and direction (e.g. "NE" i...
75ea24fe7b5a756c2a7479e837ffdd1959d9f6ea
northkevin/python_changes
/Wheel_of_Fortune.py
6,241
4
4
import random import time BLANK_LETTER = '_' valid_choices = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] def word_choice(): """ Picks a word at random from the text file of potential word choices. """ words = open('WheelOfFortune.txt', 'r') w ...
49fdfaa8225135b539b8fc818c04ee17a8a579a4
kivensu/learnpython3
/Condition/alien.py
793
3.515625
4
alien_01 = {'color': 'green', 'points': 5} # print (alien_01['color']) # print (alien_01['points']) # new_points = alien_01['points'] # print ("Your just earned " + str(new_points) + " points!") # print(alien_01) alien_01['x_position'] = 0 alien_01['y_position'] = 25 alien_01['speed'] = 'medium' # print("The alien_01 c...
0704dff3bae91c29dadd9867b9fc72259f59c1ce
kivensu/learnpython3
/ListAndOperation/bicycles.py
1,246
4.1875
4
# print list bicycles = ['creak', 'cannondale', 'trip', 'alex'] print(bicycles) # list indexes # print(bicycles[0]) # print(bicycles[1]) # print(bicycles[-1]) print("My first bicycles is " + bicycles[0].title() + " !") # change list element motorcycles = ['honda', 'yamaha', 'suzuki'] print(motorcycles) # motorcycles[...
53db03e937decb0fa53ab5567637b9c7b32fbac6
kivensu/learnpython3
/Func/make_albums.py
686
3.9375
4
def make_album(singer_name, album_name, album_number=''): album_info = {'singer_name': singer_name.title( ), 'album_name': album_name.title()} if album_number: album_info['album_number'] = album_number return album_info #album01 = make_album('zhoujiellun', 'qilixiang') # print(album01) #album0...
f3c17c7b429029ecacacbced12ddcca71c78beeb
kivensu/learnpython3
/Projects/DataVisualization/scatter_squares.py
495
3.8125
4
import matplotlib.pyplot as plt #x_values = [1, 2, 3, 4, 5, 6] #y_values = [1, 4, 9, 16, 25, 36] x_values = list(range(1, 101)) y_values = [x**3 for x in x_values] plt.scatter(x_values, y_values, s=40, c=y_values, cmap=plt.cm.Reds, edgecolor='None') #title, x, y plt.title("Square Numbers", fontsize=24) pl...
28f4443ebcf54ac4845f6dbd4a6daa3de3ebc927
gchilczuk/ProjectEuler
/python/p4.py
260
3.671875
4
# brute force def is_palindrome(x): x = str(x) return x == x[::-1] def hihhest_3digit_palindrome(): for i in range(999,900,-1): for j in range(999,900,-1): pos = i * j if is_palindrome(pos): return i, j, pos print(hihhest_3digit_palindrome())
0462623b8ece934f15e909b6c2ecaccc820fbdde
gchilczuk/ProjectEuler
/python/p10.py
446
3.578125
4
import time # https://projecteuler.net/problem=10 start = time.time() def is_prime(x): if x == 2: return True # naive, not so vlever colution sqrtx = x ** (1/2) sqrtx = int(sqrtx)+1 for i in range(2, sqrtx): if x % i == 0: return False return True # brute force solution: primes = [2] for i in range(3,2...
7928e5ce41ebcaada9146563521dc9cb61776715
stephra34/MIT-OCW
/turtle_test.py
1,889
4.125
4
#setup import turtle s = turtle.getscreen() t = turtle.Turtle() t.shape("turtle") t.speed(9) #set up screen #turtle.bgcolor("blue") turtle.title("Hunter's Game") # #u = input("Would you like me to draw a shape? Type yes or no: ") #if u == "yes": # t.penup() # t.goto(200,200) # t.pendown() # n=10 # whil...
fd00acdfa7e5f6187dcef82ca53e2a34595bb3e9
erinmiller926/adventurelab
/adventure_lab.py
2,337
4.375
4
# Adventure Game Erin_Miller import random print("Last night, you went to sleep in your own home.") print("Now, you wake up in a locked room.") print("Could there be a key hidden somewhere?") print("In the room, you can see:") # The menu Function: def menu(list, question): for item in list: print(1...
a590ee8efe34324abb36fed1d57417ea7ecaea50
ashraf1lastbreath/LinkedList
/llist.py
3,695
4.0625
4
class Node: def __init__(self,data): self.data= data self.next= None class LinkedList: def __init__(self): self.first=None self.last=None def printList(self): node=self.first print"" print " Printing the list..." print" ...
eac9b96a71f96e8d9a75393caa19b91fb3334430
Clearyoi/advent2018
/6/part1.py
1,835
3.53125
4
class Parser(object): def __init__(self, nodes): self.nodes = nodes self.left = min(self.nodes, key=lambda x: x[0])[0] self.right = max(self.nodes, key=lambda x: x[0])[0] self.top = min(self.nodes, key=lambda x: x[1])[1] self.bottom = max(self.nodes, key=lambda x: x[1])[1] ...
4710e4cac64fc12b3f7ef7c2fc68195de7b2d9f6
Clearyoi/advent2018
/2/part2.py
733
3.515625
4
class NearDuplicateFinder(object): def __init__(self): self.match = "" def check_for_duplicates(self, short_words): list_of_words = set() for word in short_words: if word in list_of_words: self.match = word break else: ...
01d74721191739bde807d2e6afd0fb0553df5502
Shisunlel/python-final-SQ1
/classes/People.py
421
3.765625
4
class People: id = None name = None address = None def input(self): print("==========") self.id = int(input("Enter id= ")) self.name = input("Enter name= ") self.address = input("Enter address= ") def output(self): return '{0:<5}'.format(str(self.id)) + '{0:...
8ebf4a750c5d4621fa3fa7913c060849c84df7a6
satvikkarumuri/python
/main.py
2,031
3.953125
4
# def test(t, t2): # print(t) # print(t2) # test(20, "test2") # c = 1 # d = 1 # if c != d: # print("nope") # elif c == 1: # print("its 1") # elif c == d: # print("yes") # else: # print("this will never happen") # def hi(a, b, c, d,): # print(a) # print(b) # print(c) # print(d) ...
b271f5a99d825c214d65046c1fc22eddb3ffe23e
satvikkarumuri/python
/while2.py
256
3.8125
4
import turtle family =[] name = turtle.textinput("family names", "input your name or press ENTER to exit") while name != "": family.append (name) name=turtle.textinput("family names", "input your name or press ENTER to exit") print(family)
d2aa2bef87af0cbde84e864534c713c1d5e9f393
duongdo27/geeks-for-geeks
/search/algorithms/linear_search.py
368
3.9375
4
""" Link: https://www.geeksforgeeks.org/linear-search/ """ def linear_search(array, value): """ :param array: list of values :param value: value to search for :return: index of the value If not found, return -1 Time complexity: O(n) """ for idx, ele in enumerate(array): if ele...
e9fa6b1f5c8894d7d9085b4b1d204d41f91fcb66
duongdo27/geeks-for-geeks
/search/algorithms/jump_search.py
1,012
3.875
4
""" Link: https://www.geeksforgeeks.org/jump-search/ """ # pylint: disable=invalid-name import math def jump_search(array, value): """ :param array: list of values :param value: value to search for :return: index of the value If not found, return -1 Time complexity: O(sqrt(n)) """ n =...
4b37ee3bbcf67ad75f69d913964c775b330f755c
duongdo27/geeks-for-geeks
/search/problems/find_floor_ceiling.py
695
4
4
""" Link: https://www.geeksforgeeks.org/ceiling-in-a-sorted-array/ """ # pylint: disable=invalid-name # pylint: disable=inconsistent-return-statements def find_floor_ceiling(array, number): """ :param array: given non-decreasing sorted integer array :param number: a given number :return: the floor and...
98a3951ce79768ef870ed2baa074456b5233dc4c
VihaanVerma89/pythonCodes
/codingBat/warmup2/last2.py
376
3.671875
4
def last2(str): if len(str) < 2: return 0 last2 = str[len(str) -2 :] count = 0 for i in range(len(str)-2): subString = str[i:i+2] if subString == last2 : count+=1 return count print 'last2('hixxhi') :',last2('hixxhi') print 'last2('xaxxaxaxx') :',last2('xaxx...
5a9a219fb770da95b85ca521eb48894f22fe81b8
VihaanVerma89/pythonCodes
/codingBat/warmup2/front_times.py
218
3.828125
4
def front_times(str, times): if len(str) > 3: return str[:3] * times else: return str * times print front_times('Chocolate', 2) print front_times('Chocolate', 3) print front_times('Abc', 3)
d869c7f3089fc89c2dccdbbb6364d7121fc65d37
VihaanVerma89/pythonCodes
/codingBat/warmup1/sum_double.py
228
3.9375
4
def sum_double(a, b): if a == b : return 2*(a+b) else: return a + b print 'sum_double(1, 2) :', sum_double(1, 2) print 'sum_double(3, 2) :', sum_double(3, 2) print 'sum_double(2, 2) :', sum_double(2, 2)
f3484b89bbee80e5bf193613765bf8a73df2cff7
itmeson/grade.txt-cli
/report.py
2,241
3.515625
4
import datetime def send(text, email="itmeson@gmail.com", test = False, subject="None"): # Import smtplib for the actual sending function import smtplib # Import the email modules we'll need from email.mime.text import MIMEText # Open a plain text file for reading. For this example, assume that # the text ...
da6969a8ba266d04b65047476d99432d5beb596f
amber-lab/CateringWare
/CateringItems.py
1,239
3.5
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Created on Mon Jul 22 02:32:42 2019 @author: L.A.B """ class CateringItems: def __init__(self, name): self.name = name self.items = {self.name : dict()} def add(self, item, value = 1): if issubclass(type(item...
76ced80665e29834f4103c03a7e7183265dbeccc
amontilla0/C4NN
/c4nn/Board.py
11,286
4
4
# # Code by Abraham Montilla. # Adapted from Carsten Friedrich (https://github.com/fcarsten/tic-tac-toe). # import numpy as np from enum import Enum class GameResult(Enum): """ Enum to encode different states of the game. A game can be in progress (NOT_FINISHED), lost, won, or draw """ NOT_FINISHED =...
3efdfd5bfdcf3cec52dff444b1fb0163a2d14eef
Jacob-Hinchey/MS4713
/Python/Proofs/Mod03Proof.py
1,515
3.78125
4
#! python3 #Jacob Hinchey #given lists list_one = [100,'Potential',-76,'opposed','storage','Drum',78,-17,75,'Organize','dome','reign',480,'claim',148,'hope',105,'claim',100,'second'] list_two = ['Palace',94,'leadership','Second','Layout',-118,-295,-60,'tiptoe','Denial',-231,'Organize',-240,'Countryside','reign','Res...
bc4cf020e12cef8167f0ce3cad98399b5d7d9f8f
michealwave/trainstation
/lesson.py
1,763
4.4375
4
# Calculation, printing, variables # Printing to the screen # The built in function print(), prints to the screen # it will print both Strings and numbers print("Printing to the screen") print("Bruh") # in quotes are called strings print('bruhg') print(6) #a number print("6") print(6 + 6) #prints 12 print("...
5f101b23c1893d5775cced2f72b63654ff78108a
michealwave/trainstation
/practice1.py
390
3.734375
4
# Michael Williams # 9/23/19 P1 # practice1.py print("4 * 8 = " + str(4 * 8)) print("12 / 2 = " + str(12 / 2)) print( "-5 - 6 * 3 = " + str(-5 - 6 * 3)) age = input("What is your age? ") age = int(age) + 10 print("In ten years you will be " + str(age)) print("Go vipers\n" * 20) myNum = 20 myNum = 20 + ...
65bcc52ac976eb07778a798a141cc23a76725ecd
kai-arsenault/encryption
/TripleDES.py
5,464
4.15625
4
#! /bin/python class UserInfo: def __init__(self): self.message = input("Enter message: ") self.key = input("Enter key (must be integer): ") def NewInfo(self): self.__init__() # This class can be used to manipulate (encrypt or decrypt) a message (ceaser and rail fence cipher) with a ...
47a139d5386ba2a27df86ed2e0213a33ca8e166d
WineyeLiu/dataStractureAndAlgorithms
/python-implements/shufflingMachine.py
1,082
3.671875
4
""" @author liuwenai Shuffling Machine """ def getNewPokerSuit(): l = [] for x in 'SHCD': i = 0 while i < 13: l.append(x + str(i+1)) i += 1 l.append('J1') l.append('J2') return l def shuffling(cardList, ruleList): l = [x for x in range(len(cardList))] ...
4c0636d6aa3c737a07881a7eff708717ab7c95bd
QassemNa/Composite-Simpson
/composite.py
1,813
3.75
4
import math import numpy as np def f(x): # Function of x x = float(x) y = (math.e ** x) / x return y def fillaray(n): # this function will make an array of x+ih xi = float(a) for i in range(0, n - 1): xi = xi + h barry.append(xi) def multi(): # this function will multiply th...
a0e4cd1b5a18f767a3ee66d9fa36ff6920a14ebd
pedrooste/Year-12-Major-Project
/pygame_template.py
2,016
3.71875
4
""" Short, one line description of the project ending with a period. A longer description of the module with details that may help the user or anybody reviewing the code later. make sure you outline in detail what the module does and how it can be used. """ __author__ = "Your Name" __license__ = "GPL" __version...
e18acb4fb469dd4b771686348a653f9c4d2ec92b
medo962006/portfolio
/equation solver.py
2,585
3.734375
4
class evaluate : def __init__(self , equation): self.prob=equation self.eq = self.prob.split('=') self.multiply() self.divide() self.addd() self.minus() self.equal() self.evall_str() self.evall() def is_number(self,var): ...
665ce1b537e5753e4f6e14260fb47c51e99dc27e
geeksniper/python-programming-basics
/Day01-variable/challenge1.py
117
4.21875
4
# write a program that prints the number of characters in a user's name print(len (input('enter the user name: ')))
9999ddd6a02d991160bd5e379e2737c779eb48c7
rsata/kais-gradebook
/Delete_class.py
1,223
3.953125
4
import db import os def run(classes): os.system('clear') #KS set up the menu for Delete a Class Record using the string method .center title = ("Delete a Class Record") print(title.center(80, ' ')) print() delete(classes) print() #KS create an infinite loop where user has to pick "Y...
a03eb211c78e2b5e72298162525243a8b26bdaeb
AlexKlogin/WorldOfGames
/MemoryGame.py
1,868
3.953125
4
import random from time import sleep from Utils import Screen_cleaner difficulty = 3 list = [] def generate_sequence(): global list for index in range(0, difficulty): list.append(random.randint(1, 100)) def get_list_from_user(): guess_list = [] for index in range(1, difficulty + 1): ...
2094f9cdc36282e658b2f3f8fe655418b0e134dd
clmoreno/AutoMergeTool
/amtlcs.py
4,018
3.578125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- class LCSAnalyser: """ A utility class able to find the LCS between three strings / arrays """ def __init__(self, comparator=lambda a, b: a == b, concatenate=lambda a, b: a + b, boxing=lambda x: [x]): ...
b482d85a690bb538625af8acacb26ba12e7a1567
abhishekshahane/A-Tic-Tac-Toe-Game
/main.py
3,551
4.03125
4
import random from time import sleep lista =[ [None, None, None], [None, None, None], [None, None, None] ] another = True tieNotTrue = True def printlist(): print("Tic-tac-toe Board: ") print("\n") for row in lista: print(row) print("\n") def tie(lista):...
2f34a7ba3705b2aae3edb85d2a300308b0a4bccb
tertsdiepraam/Genetic-Algorithm-Test
/tree.py
5,457
3.828125
4
import math import random import functools # Each operator has a lmabda function which is used to solve the Formula # and it has a mathmatical representation, which will be formatted using the # format method for strings operators = { 'add': (lambda x, y: x+y, '({}+{})'), 'sub': (lambda x, y: x-y, '({}-{})'), 'mul'...
840ac0b807f67faca806e65f63fb4512c8ec1f40
niskrev/OOP
/old/NotQuiteABase.py
636
4.28125
4
# from Ch 23 of Data science from scratch class Table: """ mimics table in SQL columns: a list """ def __init__(self, columns): self.columns = columns self.rows = [] def __repr__(self): """ pretty representation of the table, columns then rows :return: ...
86e05b265594685723447480cf0727cb59fc33f3
aschimmichanga/FashionClassifier
/Fashion-Classifier.py
3,017
4.21875
4
# Classifying images from Fashion MNIST Kaggle dataset # Tutorial: https://www.freecodecamp.org/news/creating-your-first-image-classifier/ # Dataset: https://www.kaggle.com/zalando-research/fashionmnist # Import statements ################################################# import numpy as np import pandas as pd import...
36872204f3439dbafd3370cc89e3a26fb245930a
pranavnatarajan/CSE-163-Final-Project
/MatchTree.py
2,753
4.15625
4
""" Alex Eidt- CSE 163 AC Pranav Natarajan - CSE 163 AB CSE 163 A Final Project This class represents a Data Structure used to build up the bracket of the UEFA Champions League to create the bracket graphics. """ import random class MatchTree: """ Data Structure used to represent a full brack...
46a4ef43db855f77cc12605c30897f9e5d1f88eb
Beun-Team-Twente/spaceapps2020
/modules/computer_vision/conversions.py
394
3.5
4
import numpy as np from PIL import Image import cv2 def pil_to_opencv(img): # Converts a PIL image to OpenCV format numpy_image = np.array(img) return cv2.cvtColor(numpy_image, cv2.COLOR_RGB2BGR) def opencv_to_pil(img): # Converts an OpenCV image to the PIL format img = cv2.cvtColor(img, cv2.COL...
f330c73ae420f58891d6cf1316fd31bb747f1f59
dylwwj123/my-beautiful-python
/Python基础笔记.py/Python面向对象/对象与类属性.py
561
3.78125
4
from types import MethodType class cla(object): #这里的属性为类属性 #用类名来调用 name = "111" def __init__(self,name): #对象属性 #添加属性 self对象 self.name = name def addmthod(self): print("add") print(cla.name) c = cla("222") #动态的给对象添加属性 c.age = 18 print(c.name) print(c.age) #动态添加方法 c.add...
abca38cb339253656b00988bc056570ba7fe070f
dylwwj123/my-beautiful-python
/Python基础笔记.py/Python面向对象/单继承/SonClass.py
226
3.5
4
from PersonClass import Person class Son(Person): def __init__(self,name,age,height): #调用父类中的init方法 super(Son,self).__init__(name,age) #自身的属性 self.height = height
bbc8cf326c73c42ed85a3648a2a40fbca659b303
dylwwj123/my-beautiful-python
/Python基础笔记.py/Python多线程/线程/2.启动一个线程.py
681
3.609375
4
import threading import time num = 10 def run(age): print("子线程(%s)启动" %(threading.current_thread().name)) time.sleep(2) print(num) print(age) print("子线程(%s)结束" %(threading.current_thread().name)) if __name__ == '__main__': #任何进程默认就会启动一个主线程。主线程可以启动子线程。 #threading.current_thread()返回线程...
f9d31e568ab4b31b2d53a0016c70914fcd71c769
dylwwj123/my-beautiful-python
/Python基础笔记.py/小项目/自动化办公/读写csv文件/读csv文件.py
506
3.59375
4
import csv def readCsv(path): infolist = [] with open(path, "r")as f: allFileInfo = csv.reader(f) for rowstr in allFileInfo: allcount = rowstr.count('') print(allcount) for newrows in range(allcount): rowstr.remove('') infoli...
d9b3aa1198d4148d5af1db50120b160e7412b222
jerryweihuajing/Drone-Python
/2D/Module/Circle.py
1,960
3.890625
4
# -*- coding: utf-8 -*- """ Created on Thu Aug 8 15:03:32 2019 @author: Wei Huajing @company: Ameng Science and Technology Education Co., Ltd @e-mail: jerryweihuajing@126.com @title:Module-Circle """ import numpy as np #------------------------------------------------------------------------------ """ calculated p...
05bf7cca61f737209510d94615c0d89f5847d6e5
hafijul233/dj4e
/c1w7/assignment5-2.py
879
4.09375
4
# Write a program that repeatedly prompts a user for integer numbers # until the user enters 'done'. Once 'done' is entered, print out the # largest and smallest of the numbers. If the user enters anything # other than a valid number catch it with a try/except and put out # an appropriate message and ignore the number....
4ffedd84f90f83020671c985b478e7f79ec5c99a
hafijul233/dj4e
/c2w3/assignment7-2.py
1,007
3.953125
4
# Write a program that prompts for a file name, then opens # that file and reads through the file, looking for lines of # the form: X-DSPAM-Confidence: 0.8475 Count these lines # and extract the floating point values from each of the # lines and compute the average of those values and produce # an output as shown be...
16f298461d92d438ef71f7de67c387953cb4bcc3
hafijul233/dj4e
/c2w6/assignment10-2.py
865
3.84375
4
# Write a program to read through the mbox-short.txt # and figure out the distribution by hour of the day # for each of the messages. You can pull the hour out # from the 'From ' line by finding the time and then # splitting the string a second time using a colon. # From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2...
a66e8593012a905bab5ff4d92de796f7a30deb01
GTaf/ML_project_1
/implementations_JB.py
7,060
3.71875
4
import numpy as np def standardize(x): """ Standardize the original data set """ mean_x = np.mean(x,axis=0) x = x - mean_x std_x = np.std(x,axis=0) std_x = np.where(std_x==0,1,std_x) x = x / std_x return x def calculate_mse(e): """ Calculate the mse for vector e """ ...
59476d25d2f80d847304e1ff04a6dfd1ee4dd267
JamesMConroy/CostMapSearch
/Graph.py
2,203
3.734375
4
# This file contains a graph class which is a class containing nodes class Node: parent = None def __init__(self, row, col, value): self.position = (row, col) self.value = value self.cost = 1 - value self.parent = None self.neighbors = [] self.visited = False ...
0e180c7692a5807f278056be53142739700d5fce
anitakumarijena/Python_advantages
/deepak.py
1,275
4.1875
4
graph ={ 'a':['c'], 'b':['d'], 'c':['e'], 'd':['a', 'd'], 'e':['b', 'c'] } # function to find the shortest path def find_shortest_path(graph, start, end, path =[]): path = path + [start] if start == end: return path shortest = None for node in graph[start]: if n...
901bb3862dc552fcbf86057483ef8c590e75ee51
Isoxazole/Python_Class
/HW7/hm7_william_morris_ex_2.py
1,249
3.84375
4
""" Homework 7, Exercise 2 William Morris 3/17/19 This program searches the term the user has chosen as the argument in the terminal. The program then searches that term on imgur and copies all of the search result pictures to a pictures folder in the same directory. """ import re import requests import bs4 import sys...
4c786e38d93357f3a768506f39993248e8414b64
Isoxazole/Python_Class
/HW2/hm2_william_morris_ex_1.py
447
4.1875
4
"""Homework2, Exercise 1 William Morris 1/29/2019 This program prints the collatz sequence of the number inputted by the user.""" def collatz(number): if number == 1: print(number) return 1 elif number % 2 == 0: print(number) return collatz(int(number/2)) else: prin...
5e4d121ef247320d9f3a90162561d10694c2ab49
Isoxazole/Python_Class
/HW4/hm4_william_morris_ex_1.py
1,461
4.21875
4
""" Homework 4, Exercise 1 William Morris 2/22/19 This program has 3 classes: Rectangle, Circle, and Square. Each class has the functions to get the Area, Diagonal, and perimeter of their respective shape. At the end of this program, the perimeter of a circle with radius the half of the diagonal of a rectangle with len...
baf7402eaca1cd735b00a457b73092e7addaa8a6
Isoxazole/Python_Class
/HW2/hm2_william_morris_ex_4.py
789
4.03125
4
"""Homework2, Exercise 4 William Morris 1/29/2019 This program transposes a given 2d array by turning it clockwise 90degrees""" grid = [['.', '.', '.', '.', '.', '.'], ['.', '0', '0', '.', '.', '.'], ['0', '0', '0', '0', '.', '.'], ['0', '0', '0', '0', '0', '.'], ['.', '0', '0', '0', '0...
673b9507c60b798ff33bff24401d144014aac4e6
Isoxazole/Python_Class
/midterm_william_morris_ex_2.py
401
3.8125
4
def integers(): i = 1 while True: yield i i = i + 1 even = (x for x in integers() if x % 2 == 0) odd = (x for x in integers() if x % 2 == 1) def take(n, seq): seq = iter(seq) result = [] try: for i in range(n): result.append(next(seq)) except StopIterat...
d57991f5faa7b5b8d3ed8ade332d57c55242bb98
Ottermad/PythonBasics
/times_tables.py
564
4.125
4
# times_tables.py # Function for times tables def times_tables(how_far, num): n = 1 while n <= how_far: print(n, " x ", num, " = ", n*num) n = n + 1 # Get user's name name = input("Welcome to Times Tables. What is your name?\n") print("Hello " + name) # Get timestable and how far do you want ...
7b6739be5389da8351294fa3b430002989b83b84
avin82/Programming_Data_Structures_and_Algorithms_using_Python
/basics_functions.py
2,225
4.59375
5
def power(x, n): # Function name, arguments/parameters ans = 1 for i in range(0, n): ans = ans * x return ans # Return statement exits and returns a value. # Passing values to functions - When we call a function we have to pass values for the arguments and this is done exactly the same way as as...
94e3ff44e3b5cf458720a9cb680ebd8513328358
avin82/Programming_Data_Structures_and_Algorithms_using_Python
/manipulating_lists.py
3,205
4.59375
5
# Lists are mutable. Both names list1 and list2 point to the same object. Any change by either list1 or list2 affects both the lists which are pointing to the same object. list1 = [1, 3, 5, 6] list2 = list1 list1[2] = 7 print(list1) print(list2) # Concatenation produces a new list. If we start reassigning a list usin...
afb7da3e748314b8ce084b43ebf40f63a764de7f
avin82/Programming_Data_Structures_and_Algorithms_using_Python
/handling_files.py
3,886
3.90625
4
''' Dealing with files Standard input and output is not convenient for large volumes of data Instead, read and write files on the disk Disk read/write is much slower than memory Disk buffers Disk data is read/written in large blocks "Buffer" is a temporary parking place for disk data _____________ ...
77529b036ef85de36e6e2c982b6c761dca12203c
avin82/Programming_Data_Structures_and_Algorithms_using_Python
/basics_control_flow.py
1,487
3.640625
4
# Shortcuts for conditions # Numeric value 0 is treated as False # Empty sequence "", [] is treated as False # Everything else is True import math def gcd(m, n): if m % n: # This is another way of using condition m % n != 0 (m, n) = (n, m % n) else: return n print(gcd(16, 4)) # Multiwa...
d07a37cdee7689803d39283aca30784b7a7dd01e
avin82/Programming_Data_Structures_and_Algorithms_using_Python
/basic_types_statements.py
1,086
3.859375
4
import math i = 5 j = 2 * i j = j + 5 print(i) print(j) j = j - i print(j) print(7 / 2) print(7 / 3.5) print(8 + 2.6) print(9 // 5) print(9 % 5) print(3 ** 4) print(math.sqrt(36)) print(math.log2(2)) print(math.log2(4)) i = 5 print(type(i)) i = 7 * 1 print(type(i)) j = i / 3 print(type(i)) print(type(j)) i = 2 * j ...
c58b71e04f8d980a51e3037d01af5c58da7de131
idansto/stocks
/quick examples/Holidays.py
346
3.671875
4
from datetime import date import holidays # Select country us_holidays = holidays.US() # If it is a holidays then it returns True else False print('01-01-2018' in us_holidays) print('02-01-2018' in us_holidays) print('02-01-2017' in us_holidays) # What holidays is it? print(us_holidays.get('01-01-2018')) print(us_ho...
cc6ec10735f36eaff04c97eab0410794c5a3ed8d
Jerzke/Python_Exercises_Week2
/Python_Exercsies_Week2/Exercise_3.py
157
3.875
4
rng = range(1,2,3,4,5,6,7,8,9,10) nmbr = int(input("Your number:")) if nmbr in rng : print(nmbr, "is in range") else : print(nmbr, "is not in range")
575a3df204489a2cf3bea12904c667734bc013af
guillemarsan/Machine-Learning
/2-Logistic regression/LogisticRegression.py
6,140
3.671875
4
# -*- coding: utf-8 -*- """ Coursework 2: Logistical regression """ #%% """ Imports and definitions """ import numpy as np from pandas.io.parsers import read_csv import matplotlib.pyplot as plt from sklearn.preprocessing import PolynomialFeatures import scipy.optimize as opt def carga_csv(file_name): """ ca...
9b52217c5b343c668e4d33acc78c5f6c140503d2
isakura313/01_2_2
/files/read_lines_simple.py
245
3.515625
4
name_of_file = input("Введите имя файла: ") name_of_file += ".txt" count = 0 with open(name_of_file) as file: for line in file: if line == '\n': break print(count, line.strip()) count += 1
823304af61865e1acc40c62e49574cb0934a5b40
isakura313/01_2_2
/files/all_sum.py
389
3.75
4
name_of_file = input("Введите имя файла для анализа") name_of_file += '.txt' amount = 0 with open(name_of_file, 'r') as file: lines = file.readlines() for line in lines: amount += int(line) print("Общая сумма у нас состоявляет", amount) print("Среднее у нас получается: ", amount/len(lines))
ad67986ae1cf76c30371a23e1e087054e76ef61e
patrik-williamm/Python-dasar
/Tugas 4/countGaji.py
2,268
3.671875
4
print("\n\n\tPROGRAM HITUNG GAJI KARYAWAN PT. STMIK DP") print("--------------------------------------------\n") isStop = True while isStop: nip = int(input("\tMasukkan Nip \t\t\t\t: ")) nama = input("\tMasukkan Nama \t\t\t\t: ") gol = input("\tMasukkan Gol(I, II, III, IV) \t\t: ") gaji_pokok=0 if gol=="...
af925926e9ca0846922c18ca2f2b4a22f5f31e18
patrik-williamm/Python-dasar
/Tugas 4/impelementasi.py
460
3.96875
4
class Stack(): def init(self): self.top = None self.size = 0 pass def isEmpety(self): return self.items == [] pass def push(self, item): self.items.append(item) pass def pop(self): return self.item.pop() pass def peek(self): return self.items[len(self.item)-1] pass def size(self): return len(self....
a843b64dec8465af19f20a2123a9e1dece5bc59a
patrik-williamm/Python-dasar
/Tugas 3/tugas.py
688
3.65625
4
def add(x, y): return x + y pass def kurang(x, y): return x - y pass def kali(x, y): return x * y pass def bagi(x, y): return x / y pass def moduls(x, y): return x % y pass bil1 = int(input("masukkan bil 1 : ")) bil2 = int(input("masukkan bil 2 : ")) option = input("masukkan pilihan [1..5]? : ") ...
ccfa7ff8ca0512f864bcea6c531d2e69081b586b
Shahrullo/10_Days_of_Statistics_Hackerrank
/Day_6_The_Central_Limit_Theorem_III.py
244
3.5
4
import math sample = int(input()) mean = int(input()) std = int(input()) distribution = float(input()) z = float(input()) A = mean - (std / math.sqrt(sample)) * z B = mean + (std / math.sqrt(sample)) * z print(round(A, 2)) print(round(B, 2))
9d959780aa7486ee24d69cf4420f445d5030dbbd
chenhu4/Nowcoder-and-Leetcode
/newcoder.py
14,920
3.828125
4
# -*- coding: utf-8 -*- """ Created on Tue Jun 9 11:14:01 2020 @author: 76754 """ #1. 两个栈实现队列(Two Stacks to realize queue) #using two stacks to achieve the reversed order. #1. using pushlist to store the pushed element. using poplist to pop the first element in the pushlist(queue) #2. if poplist has elem...
12ed5375fb0dbf921373bdd68f494d5a91b60408
Zhangooses/Machine-Learning
/perceptron.py
2,224
3.984375
4
""" Implementation of a perceptron classifier """ #Andy Zhang #Michael Liu from numpy import * from binary import * import util class Perceptron(BinaryClassifier): def __init__(self, opts): BinaryClassifier.__init__(self, opts) self.opts = opts self.reset() def reset(self): ""...
fb89f223c794dfdab662ae673b9c34f2df53c691
edwin-19/notes_forked
/scratchpad/swap_two_numbers.py
415
4.0625
4
# swap two variables without using a third a = -100 b = 100 print('initial') print(a, b) a, b = b, a print('tuple') print(a, b) a = -100 b = 100 a = a + b # a = a + b b = a - b # b = a - b = (a + b) - b = a a = a - b # a = a - b = (a + b) - b = (a + b) - a = b print('arithmetic') print(a,...
dbf9e906acb97b0d2ab86b009422fc8a2cb95b6f
michaelsas4/python-training
/guess.py
424
4.09375
4
#Guess Game# secret_num1 = "2" guess = " " guess_count = 0 guess_limit = 3 out_of_guesses = False while guess != secret_num1 and not(out_of_guesses): if guess_count < guess_limit: guess = input("enter guess: ") guess_count +=1 else: out_of_guesses = True if out_of_guesses: print...
e493f7de8db940423f622e9f01745d76bea24234
dhanushkamath/NLTKscripts
/NLTK1.py
645
3.65625
4
# STOPWORDS # Stopwords are words that do not help much or help very little in gaining the overall meaning of text such as # the,i,me,who,myself,which,those etc. So we remove them import nltk # Because nltk data was downloaded in the D drive. nltk.data.path.append('/media/dhanush/DATA/PyCharm_Projects_Ddrive/nltk_dat...
c3c16a2489497233698aef01b03b1c262ad3021c
easyCZ/programming-practice
/data_structures/linked_list.py
1,470
4.0625
4
class Node: """ Common Node implementation for a LinkedList. Equality of value and to string are supported. """ def __init__(self, value=None, next=None): self.value = value self.next = next def __str__(self): return str(self.value) def __eq__(self, other): ""...
2e7aa2b76532676ef1cd49e3f550d215f8696952
rhutuja3010/function
/count latter and number.py
1,049
3.59375
4
# a=(3,4,53,4,7,55,8,22,14,37) # i=0 # x=0 # y=0 # count1=0 # count2=0 # while i<len(a): # if a[i]%2==0: # print(a[i],"even") # x=x+a[i] # count1+=1 # else: # print(a[i],"odd") # y=y+a[i] # count2+=1 # i+=1 # print("total even no=",count1) # print("total odd n...
d1892de89ab66ca4dcaa4421d50f86b4168b32bb
rhutuja3010/function
/meraki Q 4.py
223
3.71875
4
# def add_numbers(num1,num2): # sum=num1+num2 # print(sum) # add_numbers(56,12) def add_number_list(a,b): i=0 while i<len(b) : print(a[i]+b[i]) i+=1 add_number_list([50,60,10],[10,20,13])
b720684a806dab7ac38a09005c201fd274cad75a
rhutuja3010/function
/maximum no.py
209
3.859375
4
def max_function(): numbers = [3, 5, 7, 34, 2, 89, 2, 5] i=0 num=numbers[0] while i<len(numbers): if numbers[i]>num: num=numbers[i] i+=1 print(num) max_function()
4fc5fdd08358fb53ad96f5a038d8425c890c17d4
Sabina-K/lesson1
/ask_user.py
150
3.5
4
def ask_user(): while True: ans = input("Как дела? ") if ans == "Хорошо": print("Ну и отлично!") break ask_user()
731f778d965eda111eb96c7d2c82244a8a5e7089
MillaKelhu/tiralabra
/Main/Heuristics/basic_check.py
2,424
3.96875
4
from Heuristics.helper import line_checker from tictactoe import TicTacToe # Gives a score to the board based on the combinations found # Combination is expressed as a tuple where first parameter contains the string/combination and second parameter its value # Input parameters: # tictactoe: state of the board # mark: ...
6dd4a143316bb8a3f38abf7c3dd8ff3fbcb798ce
MillaKelhu/tiralabra
/Main/Heuristics/boundaries_check.py
985
3.546875
4
from tictactoe import TicTacToe # Calculates the distance of the marks from the boundaries. Center positions are valued higher than edge positions # Input parameters: # tictactoe: state of the board # mark: X or O # first_time: If computer goes second, encourages computer to put its mark so that it's connected to oppo...
ea834767462615e5a124b4e723e4507dcf393cec
MillaKelhu/tiralabra
/Main/Start/board.py
2,127
4.28125
4
from parameters import delay, error_message import time # User interface for asking for the board size from the user def get_board(): while True: print("Choose the size of the board that you want to play with.") print("A: 3x3 (takes three in a row to win)") print("B: 5x5 (takes four in a ...
f7c2fb9a3fce5116354feddee59026c1ba07c044
Mesquita001/Conte-doPython
/scripts-python/ex013.py
257
3.703125
4
salario = float(input("Qual é seu salário R$ ")) aumento = salario*15/100 print("Parabéns você recebeu um aumento de 15% q é R$ {} pelo ótimo desempenho".format(aumento)) total = salario + aumento print("Seu novo salário é de: R${} ".format(total))
5e8527a56ebd313785eecb0bc76533e434e80954
Mesquita001/Conte-doPython
/scripts-python/ex014.py
159
3.703125
4
graus = float(input("Qual a temperatura ")) conversor = (graus * 1.8) + 32 print("A temperatura {}C convertida em Fahrenheit é: {}F ".format(graus,conversor))
e16aa01c242c5fc654d01f889c1a3cde6551d618
elvargas/calculateAverage
/calculateAverage.py
2,865
4.4375
4
# File: calculateAverage.py # Assignment 5.1 # Eric Vargas # DESC: This program allows the user to choose from four operations. When an operation is chosen, they're allowed to choose # two numbers which will be used to calculate the result for the chosen operation. Option 5. will ask the user how # many numbers th...
0571c7e7fe75c942a88166e837d6b9ef43b9b930
broadinstitute/pdb2pqr
/pdb2pqr/cells.py
3,255
3.984375
4
"""Cell list to facilitate neighbor searching.""" import logging _LOGGER = logging.getLogger(__name__) class Cells(object): """The cells object provides a better way to search for nearby atoms. A pure all versus all search is O(n^2) - for every atom, every other atom must be searched. This ...