blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
61a293256dff4c87004e8627f0afadd9a9d202ca
shea7073/More_Algorithm_Practice
/2stack_queue.py
1,658
4.15625
4
# Create queue using 2 stacks class Stack(object): def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def size(self): return len(self.items) def pop(self): return self.items.pop() def push(self, item): self.it...
273a7556156975ad82607dd09ebed43e79e785c3
legacy72/suicide_analysis
/prepare_text.py
4,605
3.515625
4
import re from stemmer_porter_algorithm import Stemmer class TextPreparation: def __init__(self, text): self._st = Stemmer() self._text = text def strip_and_convert_to_lower(self): self._text = self._text.lower().strip() def remove_non_letter_characters(self): self._text ...
893f87c55d4e80e667be34e5caacc39c5dc1d81f
luizhsriva/solutions-to-CS50
/minpay.py
1,223
4
4
""" Donald Steinert MIT Intro to CS and Programming pset2a -- minpay.py requests starting cc balance, interest rate and monthly payment rate and prints monthly payment amount and remaining balance for 12 months, as well as total paid for the year interest charged on first day of next month rounds printed results ...
29436d6802295d6eb8992d2f510427219d29f35b
Mark9Mbugua/Genesis
/chatapp/server.py
1,892
4.125
4
import socket #helps us do stuff related to networking import sys import time #end of imports ### #initialization section s = socket.socket() host = socket.gethostname() #gets the local hostname of the device print("Server will start on host:", host) #gets the name of my desktop/host of the whole connectio...
8a621e39c673f20545eb7b4301c5d968fd57581c
parul21/Python-Programs
/try_except.py
157
3.515625
4
text="" try: text=input("Enter something") except EOFError: print "Eof" except KeyboardInterrupt: print "Keyboard interrupt" else: print text
43b9fe070547cf97ba59e181f6aad74505e84d04
parul21/Python-Programs
/objvar.py
909
3.96875
4
#!/usr/bin/python #filename objvar.py class Robot: population=0 def __init__(self,name): self.__name=name print "Initializing {0}".format(self.__name) Robot.population+=1 def say_hi(self): print "Greetings, my master calls me {0}".format(self.__name) ...
704274669bc30218e8dba7341167906e28969761
parul21/Python-Programs
/binarysearch.py
1,882
3.921875
4
"""def binarysearch(slist, value, last_index): length = len(slist) if(length==0): return -1 if(length==1): return 0 if slist[0]==value else -1 index = length/2 if(slist[index]==value): return last_index elif(value<slist[index]): if(length%2==0): last_...
783aaf4e6527d5defcf0a4583268032f72a8205c
lipk/pyzertz
/pyzertz/table.py
2,094
3.59375
4
import copy class Tile: def __init__(self , type : int, col : int, row : int): self.type=type #(-1) - does not exists, 0 - empty, 1 - white, 2 - gray, 3 - black self.col=col self.row=row def __str__(self): return str(self.type) def coord(self): ...
bb8089e56f29132ff9702bb3013a3a1b27794250
GANESH0080/Python-WorkPlace
/StringReplaceMethod/StringCharUpper.py
70
3.53125
4
name = "Ganesh Salunkhe" newString = name.replace('a', 'A') print(newString)
cda9abb1f52c06bd79b34f1fd08c0c80fe95b3da
GANESH0080/Python-WorkPlace
/GetPathOfFile/GetFilepath.py
376
3.546875
4
import os import shutil from os import path # Created file w = open("getPathFileone.txt", "w+") w.close() # Store the file path in the variable src If txt file exist if(path.exists("getPathFileone.txt")): src = path.realpath("getPathFileone.txt"); # Use src variable to split the path & filename haid, tail = path....
80192a8c2357a805072936ccb99b9dabc8e27778
GANESH0080/Python-WorkPlace
/ReadFilePractice/ReadDataOne.py
291
4.25
4
# Created an File file = open("ReadFile.txt" ,"w+") # Enter string into the file and stored into variable file.write("Ganesh Salunkhe") # Open the for for reading file = open("ReadFile.txt" ,"r") # Reading the file and store file date into variable re= file.read() # Printing file data print(re)
4945dc24aafe8f9066734a23642c0cad79c6654a
GANESH0080/Python-WorkPlace
/Loops/StringForLup.py
151
3.53125
4
def sampleSTRForLoop(): str = ["Apple", "Banana", "Grapes", "Mango", "Chiku"] for x in range(2, 5): print(str[x]) sampleSTRForLoop()
d88fef56d6c618ca183bb1be662f23dc19b19c76
GANESH0080/Python-WorkPlace
/CheckingFileorDirectory/ChkFileDirectory.py
412
3.734375
4
import os.path from os import path # Created an file w = open("file.txt","w+") m = open("D:\PythonWorkPlace\samplefile.txt","w+") # Checking file exist in directory or not print("file exist:" + str(path.exists("guru99.txt"))) print("file exists:" + str(path.exists("file.txt"))) print("Directory exists:" + str(path.ex...
24bead458694a8a5cc7138d3f074d052fdfbdec4
GANESH0080/Python-WorkPlace
/Loops/BreakInForLup.py
182
3.625
4
def sampleForLoop(): number = [2, 12, 14, 28, 9, 27, 35, 44, 78] for x in range(2, 7): print(number[x]) if (number[x]==9): break sampleForLoop()
06b1e2900a7e3aa036053b98920ae6d1776c5d7d
GANESH0080/Python-WorkPlace
/TupleInpython/CompareTupleTwo.py
90
3.78125
4
a = (5, 3) b = (5, 4) if (a > b): print("a is bigger") else: print("b is bigger")
7bcbda4e4e0d4da74cdc4dc8ed7e197d37e778c9
GANESH0080/Python-WorkPlace
/ConditionalStatements/IfElseStatementOne.py
165
3.828125
4
def SampleIfElse(): num, num1 = 25, 35 st = (num, "Is less than num1") if (num < num1) else print(num, "Is greater than num1") print(st) SampleIfElse()
74dc8724b152731c57394e5626197592e472c040
GANESH0080/Python-WorkPlace
/TupleInpython/CompareTupleOne.py
90
3.671875
4
a = (0, 5) b = (1, 4) if (a > b): print("a is bigger") else: print("b is bigger")
de3cf5eec6681b391cddf58e4f48676b8e84e727
KapsonLabs/CorePythonPlayGround
/Decorators/instances_as_decorators.py
660
4.28125
4
""" 1. Python calls an instance's __call__() when it's used as a decorator 2. __call__()'s return value is used as the new function 3. Creates groups of callables that you can dynamically control as a group """ class Trace: def __init__(self): self.enabled = True def __call__(self, f): def wr...
b0f164e5a063ff4078bcfeac39870eccd52bf964
BartKeulen/smartstart
/smartstart/environments/generate_gridworld.py
4,963
3.96875
4
"""Random GridWorld Generator module Defines methods necessary for generating a random gridworld. The generated gridworld is a numpy array with dtype int where each entry is a state. Attributes in the gridworld are defined with the following types: 0. State 1. Wall 2. Start state 3. Goal state...
365e560f1b26ed46120f028b8655bfc643fba827
ashleyjohnson590/CS162Python-Project8b
/sort_timer.py
3,268
4.25
4
#Author: Ashley Johnson #Date: 5/20/2021 #Description: Program uses time module and decorator function to time the number of seconds it #takes the decorator function to run and the wrapper function returns the elapsed time. The #compare sorts function generates a list of 1000 numbers and makes a separate copy of th...
f37b8ea7b9cffb3006fcd3a5179b4bd29f1599f4
KrishPagarSchool/Python
/countdigit.py
175
4.125
4
number=int(input("Enter The Number : ")) count = 0 while number > 0: count=count+1 number = number//10 print ("Number of digits in the given number is ", count)
e2ac7012c5b67f134a848d68cdbd969da8f2a6e3
mohamed-okasha/teccamp2020
/Python assignment/AS3.py
1,010
3.734375
4
# a program that allowes u to enter a Name and Grade of tenth student,to know thier mark whether it's excellent, very-good, good, or poor. #with open("AS3.txt") as fabj: # bio = fabj.read() # print(bio) i = 0 while i < 11 : n = input("Pls, Enter ur Name :") grade = int(input("whats ur Grade in %")) if ...
ea2dc66303ac5f4c2a141f604fb396bc84583099
sakhayadeep/Guvi-sessions
/stack.py
477
3.859375
4
''' Implementation of stack in python ''' class stack: st = list() def push(self, i): self.st.append(i) print("pushed : ", i) def pop(self): if(self.st): print("popped : ", self.st.pop()) else: print("nothing to pop!!") def main(): ll = stack()...
ee9cf22dae8560c6ee899431805231a107b8f0e6
smalbec/CSE115
/conditionals.py
1,110
4.4375
4
# a and b is true if both a is true and b is true. Otherwise, it is false. # a or b is true if either a is true or b is true. Otherwise, it is false. # # if morning and workday: # wakeup() # # elif is when you need another conditional inside an if statement def higher_lower(x): if x<24: ...
2dc085cea228f8f6cfc3f6e022b0efd7665fb991
smalbec/CSE115
/math imports.py
513
3.609375
4
import math a = 3.14 y = math.pi y = round(y, 2) b = math.pi b = pow(b, 10) leo = "tonto" leo = leo.replace("tonto", "wea") print("weon " + str(a) + " qlao " + str(y) + " la " + str(b) + " " + str(leo)) import math import math def distance(x,y): euclidian = math.sqrt(((12.5 - x)**2) + (-7.3 - y)**2) ...
36fc1c1937694434e1a9212261f0191d5898d2c3
mfilipelino/codewars-py
/codewars/balance_parathenses.py
908
3.90625
4
class Stack: def __init__(self): self.lst = [] def is_empty(self): return len(self.lst) == 0 def top(self): if self.is_empty() is False: return self.lst[-1] else: return None def append(self, value): self.lst.append(value) def pop(s...
68d7d0e94fdaf221a57846f1811f0023e09eb9f6
mfilipelino/codewars-py
/codewars/linkedlist_operations.py
1,037
3.875
4
from codewars.linkedlist import LinkedList def union(list1, list2): list3 = LinkedList() node = list1.get_head() while node is not None: list3.insert_at_tail(node.data) node = node.next_element node = list2.get_head() while node is not None: list3.insert_at_tail(node.data...
bac850544d06862dd117d75f6d51d9a9ae4bd9a3
mfilipelino/codewars-py
/tests/test_linkelistalt.py
477
3.75
4
from codewars.linkelistalt import LinkedList, Node, rotate_list def test_print_all(): linked_list = LinkedList() for i in range(1, 6, 1): linked_list.add(Node(i)) linked_list.print_all() rotate_list(linked_list, 2) linked_list.print_all() def test_print_all_2(): linked_list = LinkedL...
c5c573f1b2e173b46d60837861d222fabd44df2d
dwang2010/sudoku
/sudoku_classes.py
5,156
3.59375
4
from typing import List, Tuple # single square on board that can hold value from 1-9 class Cell: def __init__(self, i: int, j: int, val: int=0, lock: bool=False): self.pos = (i, j) self.val = val self.lock = lock def set_val(self, val: int) -> None: self.val = val def set_...
2a766709a615d59e92ba87839db761a0eec029c7
maxsch3/keras-batchflow
/keras_batchflow/base/batch_transformers/feature_dropout.py
3,385
3.5
4
import numpy as np import pandas as pd from .base_random_cell import BaseRandomCellTransform class FeatureDropout(BaseRandomCellTransform): """ A batch transformation for randomly dropping values in the data to some pre-defined values **Parameters** - **n_probs** - a *list*, *tuple* or a *one dimension...
31973482ec85f4fd929f8a2ab5f99828a157e2e7
abasnfarah/IP_Algo_DS
/Algo_DS_Python/Algo_DS_Python/algorithms/graphAlgorithms/graphs.py
1,585
3.546875
4
""" Author: Abas Farah This is code for graphs.py This file has some prebuilt graphs using the: --> Adjecency List --> Adjecency Matrix --> Adjecency List with edge weights --> Object oriented graph with edge weights """ import sys import os dirpath = os.path.dirname(os.p...
8ee4c7cdf6ce11084256045ad39df86fa0222125
abasnfarah/IP_Algo_DS
/Algo_DS_Python/Algo_DS_Python/data_structures/AVL_Trees/AVL_Trees.py
5,391
3.828125
4
""" This is the class definition for a AVL_BST (Adelson-Velsky-Landis Binary Search Tree) INVARIANT: all elements in the right sub tree are < root and all elements in the left sub tree are > then the root node. Also, for every node the left and right children's heights differ by at most +-1. This BST ma...
f6c88e028ceef2d200a812d55e5e17621ac6669e
abasnfarah/IP_Algo_DS
/Algo_DS_Python/Algo_DS_Python/data_structures/stacks/stacks.py
11,480
3.65625
4
""" Author: Abas Farah This is code for the arrayStack class. And the listStack class: The Properties of the arrayStack Class: Atributes: stack, top, size. Methods: push, pop, peek, resize, The properties of the listStack class: Atributes: stack, size Methods: push, po...
db20e2e0738b81a45ec1685f4e485418d072b0c5
sithu/cmpe255-spring19
/lab5/linear_algebra.py
470
3.640625
4
import math def vector_subtract(v, w): """subtracts two vectors componentwise""" return [v_i - w_i for v_i, w_i in zip(v,w)] def dot(v, w): """v_1 * w_1 + ... + v_n * w_n""" return sum(v_i * w_i for v_i, w_i in zip(v, w)) def sum_of_squares(v): """v_1 * v_1 + ... + v_n * v_n""" return dot...
7f942c56a2d9e4a495aba97960e4b99ba04a6552
DEKHTIARJonathan/IMA-Deep-Learning
/deepsix/download/flickr.py
1,275
3.546875
4
import flickrapi def session(filename): """Open an instance of the Flickr API given an API key.""" with open(filename) as f: api_keys = f.readlines() api_key = api_keys[0].rstrip() api_secret = api_keys[1].rstrip() session = flickrapi.FlickrAPI(api_key, api_secret) retu...
4c403bd4174b1b71461812f9926e6dac87df2610
JasmanPall/Python-Projects
/lrgest of 3.py
376
4.46875
4
# This program finds the largest of 3 numbers num1 = float(input(" ENTER NUMBER 1: ")) num2 = float(input(" ENTER NUMBER 2: ")) num3 = float(input(" ENTER NUMBER 3: ")) if num1>num2 and num1>num3: print(" NUMBER 1 is the greatest") elif num2>num1 and num2>num3: print(" NUMBER 2 is the greates...
c8b69c1728f104b4f308647cc72791e49d84e472
JasmanPall/Python-Projects
/factors.py
370
4.21875
4
# This program prints the factors of user input number num = int(input(" ENTER NUMBER: ")) print(" The factors of",num,"are: ") def factors(num): if num == 0: print(" Zero has no factors") else: for loop in range(1,num+1): if num % loop == 0: factor = l...
9718066d59cdbd0df8e277d5256fd4d7bb10d90c
JasmanPall/Python-Projects
/Swap variables.py
290
4.25
4
# This program swaps values of variables. a=0 b=1 a=int(input("Enter a: ")) print(" Value of a is: ",a) b=int(input("Enter b: ")) print(" Value of b is: ",b) # Swap variable without temp variable a,b=b,a print(" \n Now Value of a is:",a) print(" and Now Value of b is:",b)
87dfe7f1d78920760c7e1b7131f1dd941e284e5a
JasmanPall/Python-Projects
/odd even + - 0.py
557
4.375
4
# This program checks whether number is positive or negative or zero number=float(input(" Enter the variable u wanna check: ")) if number < 0: print("THIS IS A NEGATIVE NUMBER") elif number == 0: print(" THE NUMBER IS ZERO") else: print(" THIS IS A POSITIVE NUMBER") if number%2...
12c2dfa1a418daf8de31c22a394d4e1465ae2724
ameeshaS11/Greedy-1
/jumpgame.py
515
3.546875
4
#Time Complexity : O(n) #Space Complexity : O(1) # Did this code successfully run on Leetcode : Yes #Any problem you faced while coding this : No class Solution: def canJump(self, nums: List[int]) -> bool: if nums[0]>= len(nums)-1: return True idx = len(nums)-2 dest = len(nums)...
17739c9ef743a4eea06fc2de43261bfc72c21678
elijahwigmore/professional-workshop-project-include
/python/session-2/stringfunct.py
1,612
4.21875
4
string = "Hello World!" #can extract individual characters using dereferencing (string[index]) #prints "H" print string[0] #prints "e" print string[1] #print string[2] #Slicing #of form foo[num1:num2] - extract all elements from and including num1, up to num2 (but not including element at num2) ...
8716e46d6a1e1d119c070dfcd94226473d5c7302
xxxhol1c/PTA-python
/programming/4-13.py
227
3.71875
4
from math import factorial error = float(input()) res = 0 i = 0 while True: res += 1/factorial(i) if 1/factorial(i+1) <= error: res += 1/factorial(i+1) break else: i += 1 print(f'{res:.6f}')
8e2ea8cfb6475161e2c188540a7a79c1e2a96f69
xxxhol1c/PTA-python
/programming/4-6.py
382
3.59375
4
""" timeout def fib(n): if n == 1 or n == 2: return 1 return fib(n - 1) + fib(n - 2) """ def fib(n): pre , cur = 0, 1 for _ in range(1, n): pre , cur = cur, pre + cur return cur n = int(input()) if n < 1: print('Invalid.') else: for i in range(1, n+1): print(f'{fib...
66f3b04df297736341fed29bb2e6c323eb536c5a
xxxhol1c/PTA-python
/programming/5-2.py
221
3.515625
4
n = int(input()) count = 0 sum = 0 for i in range(n): dic = eval(input()) for item in dic: path = dic[item] for key in path: count += 1 sum += path[key] print(n, count, sum)
e17447bfdb6c35860de087bdb5780a3d6569535e
xxxhol1c/PTA-python
/programming/3-17.py
150
3.859375
4
str = input().strip() chr_remove = input().strip() str = str.replace(chr_remove.upper(), '').replace(chr_remove.lower(), '') print(f'result: {str}')
42a8eee49d3119b284903aa38289d33e36acfc0c
xxxhol1c/PTA-python
/programming/4-29.py
263
3.921875
4
lst1 = list(input().split())[1:] lst2 = list(input().split())[1:] res = [] for num in lst1: if num not in lst2 and num not in res: res.append(num) for num in lst2: if num not in lst1 and num not in res: res.append(num) print(' '.join(res))
3d430df61055e0d3dbc68c8f270c964b89b9b3b8
xxxhol1c/PTA-python
/programming/4-26.py
124
3.921875
4
from math import factorial n = int(input()) res = 0 for i in range(1,n+1,2): res += factorial(i) print(f'n={n},s={res}')
8f7136a85530c671e188d90fcf7ef5f51e68412d
sowmyakrishnaraj91/byte_python
/ds_using_list.py
497
3.828125
4
shop_list = ['apple', 'mango','banana'] print('I have',len(shop_list),'items') print('These items are:', end=' ' ) for items in shop_list: print(items, end=' ') print('items', shop_list) print('adding rice') shop_list.append('rice') print('updated: ',shop_list) print('Sorting list') shop_list.sort() print('...
8023d34f620beec2928e834869c35acdcb258dea
sowmyakrishnaraj91/byte_python
/control_flow.py
192
3.75
4
number = 19 guess = int(input('Enter an int:')) if guess == number: print('Spot on') elif guess < number: print('A little higher') else: print('A öittle lower') print('Done')
547bd9ea976fa5b783a27d8474fcc83f883c6b98
akjadon/Deep-Learning
/ANN/1-1-regression.py
1,504
3.890625
4
from keras.datasets import boston_housing from keras.models import Sequential from keras.layers import Activation, Dense from keras import optimizers (X_train, y_train), (X_test, y_test) = boston_housing.load_data() model = Sequential() # Keras model with two hidden layer with 10 neurons each model.add(De...
2244fcdea5ed252a02782ef5fb873fbb5c91b411
lohitbadiger/interview_questions_python
/3_prime_number.py
403
4.25
4
# given number is prime or not def prime_num_or_not(n): if n>1: for i in range(2,n): if (n%i)==0: print('given number is not prime') print(i,"times",n//i,"is",n) break else: print('given number is prime') else: print...
84f0b4335f058c440ac748f165fd7e87ef1e08b2
lohitbadiger/interview_questions_python
/6_letter_reverse.py
724
4.1875
4
#letters reverse in strings def reverse_letters(string): if len(string)==1: return string return reverse_letters(string[1:]) + (string[0]) # string=input('enter string') string='lohit badiger' print(reverse_letters(string)) print('----------------------------') def reverse_letter2(string): ...
039d14e75813ac6601cd9ba752e39fce2ccbf982
gautamgitspace/leetcode_30-day_challenge
/81_single_number.py
1,967
3.71875
4
class Solution(object): def singleNumber(self, nums): """ :type nums: List[int] :rtype: List[int] """ allnumsxor = nums[0] """ this will basically give us the XOR of those two target nums which appear just once in nums note that for 2 ...
80c6c7fdad232dbd8d28c2df8084a303357b9132
gautamgitspace/leetcode_30-day_challenge
/46_find_all_anagrams.py
1,327
3.53125
4
class Solution(object): def findAnagrams(self, s, p): """ :type s: str :type p: str :rtype: List[int] """ res, d = [], {} begin, end = 0, 0 for item in p: d[item] = d.get(item, 0) + 1 counter = len(d) while end < len(s): ...
9b697012de1a21ec58ae88d1df69c39c2f486333
gautamgitspace/leetcode_30-day_challenge
/113_single_number_iii.py
1,394
3.640625
4
class Solution(object): def singleNumber(self, nums): """ :type nums: List[int] :rtype: List[int] """ xorian = nums[0] for item in nums[1:]: xorian ^= item bit_set = 1 while xorian & bit_set == 0: bit_set <<= 1...
1743d3608dc8a99cfeb1257aee77c8c8c676e93e
gautamgitspace/leetcode_30-day_challenge
/98_max_width_bt.py
1,397
3.734375
4
tion for a binary tree node. # class TreeNode(object): # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution(object): def widthOfBinaryTree(self, root): """ :type root: TreeNode :rtype: int ...
a38ec022c6b48c0dd8d2f57add5ab5e1da39cda3
sirisha-8/Array-1
/spiral_matrix.py
1,307
3.75
4
#Time Complexity : O(mn) #Space Complexity : O(1) #Did this code successfully run on Leetcode : yes #Any problem you faced while coding this : no class Solution(object): def spiralOrder(self, matrix): """ :type matrix: List[List[int]] :rtype: List[int] """ rows = l...
0d6b5af34daf68d5dd0b9df6dd8e9b4d632ea230
debjava/external-ping
/main.py
1,922
3.515625
4
import argparse from ping import PingUtil def hello(): argParser = argparse.ArgumentParser() argParser.add_argument('-p', '--ping', nargs= "+", help="Ping IP Addresses.") argParser.add_argument('-t', '--telnet', nargs="+", help="Telnet command") args = argParser.parse_args() # print('...
50a3e1da1482569c0831227e0e4b5ead75433d43
PatrickKalkman/pirplepython
/homework01/main.py
1,872
4.59375
5
""" Python Is Easy course @Pirple.com Homework Assignment #1: Variables Patrick Kalkman / patrick@simpletechture.nl Details: What's your favorite song? Think of all the attributes that you could use to describe that song. That is: all of it's details or "meta-data". These are attributes like "Artist", "Year Released"...
0f5cf4e36e1a01173be26cc50f468368bb2a3e87
PatrickKalkman/pirplepython
/project03/main.py
5,870
4.21875
4
""" Python Is Easy course @Pirple.com Project #3: Pick a Card Game! Patrick Kalkman / patrick@simpletechture.nl Details: Everyone has their favorite card game. What's yours? For this assignment, choose a card game (other than Blackjack), and turn it into a Python program. It doesn't matter if it's a 1-player game, or...
60f8df2f7560e7e6004db05b582521e44f9c6291
alexadusei/DataStructures
/Binary-vs-Trinary.py
5,817
4.15625
4
#------------------------------------------------------------------------------- """ Purpose: To test the complexities of a binary and trinary search. Simply run the program to see the results. Preset values: 5 lists with different lengths (n), and 3 values for k, per experiment. ...
b7ae64773830e76ff884fc1f1b9f0c8422ca99e3
manuelalfredocolladocenteno/NotebooksAI
/Práctica 4/fitness/tsp2d-rect-graph.py
1,770
3.828125
4
#!/usr/bin/python # -*- coding: iso-8859-1 -*- import matplotlib.pyplot as plt # Generate N cities import random cities = [] N2 = 10 for i in range(N2): for j in range(N2): c = [i/float(N2-1), j/float(N2-1)] cities.append(c) N = len(cities) print(N) print(cities) def dist (x, y): return ( (x[0]-y[0])**2...
4bd162dc975f4838dd3b5c8aab8735067432f7f8
Emmanuel289/pandas-python
/index_select_assign.py
2,135
3.90625
4
import pandas as pd iris = pd.read_csv('./Iris_Data.csv', index_col =0) print('The iris species include: \n {}'.format(iris.head())) #print('The length of the sepals are: \n{}'.format(iris.sepal_length)) #use dot notation followed by the name of a column to access its entries #print('The length of the sepals are: \n{...
51d4e80ffcf2fbcd5caa7bff1ca60d9c25933854
schneiderson/ars1
/bot/kalman.py
2,324
3.859375
4
""" Kalman Filter """ import numpy as np __author__ = "Olve Drageset, Andre Gramlich" def kalman_filter(mu_t_minus_1, sigma_t_minus_1, u_t, z_t): """ Given as input a previous believed pose, previous covariance matrix, control input, and sensor correction on pose, determine a new believed pose an...
b85b30bba76aa6351247482ef8a98044e3958679
schneiderson/ars1
/bot/trigonometry.py
8,034
4.21875
4
''' TRIGONOMETRY MODULE ''' import math __author__ = 'Camiel Kerkhofs' def triangulate_beacons(beacons): """ Given a set of beacons and the distance to each beacon, finds the point where they all intersect. We assume the real position of each beacon is known from an internal map. All oth...
4740e2d4ae6d57bbd0c63ab34cc6d62a5cb1de34
dcasanova82/uni-python
/tarea-1-2.py
516
4.0625
4
""" Ejercicio 2 =========== """ try: n1 = float(input('Enter the first number: ')) n2 = float(input('Enter the second number: ')) op = str(input('Enter the operator (+,-,*,/): ')) if op == '+': res = n1 + n2 elif op == '-': res = n1 - n2 elif op == '*': res = n1 * n2 ...
e72fbf0a96b198fd4ab47611bd8968c91d304186
quqixun/Hackerrank_Python
/30 Days of Code/day25_running_time_and_complexity.py
364
3.890625
4
import math def is_prime(n): if n < 2: return False elif n < 4: return True else: for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: return False return True T = int(input().strip()) for t in range(T): n = int(input().strip()) pri...
a6c5ac6798a6f24c69270c940be8689d2f25a58b
quqixun/Hackerrank_Python
/Algorithm/Implementation/electronics_shop.py
657
3.953125
4
#!/bin/python3 import sys def getMoneySpent(keyboards, drives, s): # Complete this function max_price = 0 for k in keyboards: for d in drives: if k + d > max_price and k + d <= s: max_price = k + d return max_price if max_price > 0 else -1 s, n, m = input().strip...
f5de6bd64442266303e1fb3ee192218827b6e0c4
quqixun/Hackerrank_Python
/Algorithm/Implementation/day_of_programmer.py
858
3.5625
4
#!/bin/python3 import sys def solve(year): # Complete this function days_in_months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] if year == 1918: days_in_months[1] = 15 elif year >= 1700 and year <= 1917: if year % 4 == 0: days_in_months[1] = 29 else: if ...
ff2a1544c7998056d5983fca1d65e254226d2b82
jmart047/DrinkRink
/integrationTest.py
5,252
3.65625
4
#!/usr/bin/python3 from tkinter import * from tkinter import messagebox import sqlite3 conn = sqlite3.connect('DrinkRink1.db') c = conn.cursor() top = Tk() top.title("welcome") top.configure(background="#a1dbcd") photo = PhotoImage(file="dr_logo2.png") w = Label(top, image=photo) w.pack() def start():...
9aabee0c1e71af2689f37aa9ee2112cf3c77e9d2
varshitha8142/Binarysearch.io
/23_binary_search_io_programs.py
567
3.875
4
""" Given a list of strings words, concatenate the strings in camel case format. Example 1 Input words = ["java", "beans"] Output "javaBeans" Example 2 Input words = ["Go", "nasa"] Output "goNasa" """ # paste your solution class Solution: def solve(self, words): # Write your code here s = '' ...
14ddce893102b8e7752e32d28f36c4c267c33100
varshitha8142/Binarysearch.io
/03.py
2,403
4
4
# pylint: disable=invalid-name """ Unique Occurrences Given a list of integers nums, return true if the number of occurrences of every value in the array is unique, otherwise return false. Note: Numbers can be negative. Example 1 Input nums = [5, 3, 1, 8, 3, 1, 1, 8, 8, 8] Output True Explanation Yes, ther...
6e72005b59e6d8de3ca35d2e030b76959b013c91
gordongreeff/MITx600
/Lec2.5.4.py
121
4.25
4
## Example from lecture 2.5 slide 4 x = 3 x = x * x print (x) y = float (raw_input ('Pick a number: ')) print (y * y)
6e653a649f753a20b94d9226df98f8caaebdcb0c
weitrue/note
/python/leetcode/linear/list/remove_nth_node_from_end_of_list.py
1,457
3.5625
4
""" Module Description: 19-删除链表的倒数第 N 个结点 Solution: Date: 2021-03-11 13:39:13 Author: Wang P Problem:# 给你一个链表,删除链表的倒数第 n 个结点,并且返回链表的头结点。 # # 进阶:你能尝试使用一趟扫描实现吗? # 示例 1: # 输入:head = [1,2,3,4,5], n = 2 # 输出:[1,2,3,5] # # 示例 2: # 输入:head = [1], n = 1 ...
45b89c4fab9e1e0bdd87117b5b0dd4543914bbef
weitrue/note
/python/leetcode/linear/list/reverse_linked_list_ii.py
1,392
3.5625
4
""" Module Description: 92-反转链表 II Solution: Date: 2021-03-15 19:06:58 Author: Wang P Problem:# 反转从位置 m 到 n 的链表。请使用一趟扫描完成反转。 # # 说明: # 1 ≤ m ≤ n ≤ 链表长度。 # # 示例: # # 输入: 1->2->3->4->5->NULL, m = 2, n = 4 # 输出: 1->4->3->2->5->NULL # Related Topi...
d3621efc07a922a54442e79b08cbb227aaeb9bf9
weitrue/note
/python/algorithm/search/binary_search.py
549
3.984375
4
""" Module Description: 二分查找算法 Problem: Solution: Date: 2020/1/20 Author: Wang P """ def binary_search(arr, target): n = len(arr) left = 0 right = n - 1 while left <= right: mid = (left + right) // 2 if arr[mid] < target: left = mid + 1 elif arr[mid] > target: ...
8007fe45185f608a628b204a7694d2f6d1aa5c94
calebhews/Ch.07_Graphics
/7.2_Picasso.py
4,515
4.40625
4
''' PICASSO PROJECT --------------- Your job is to make a cool picture. You must use multiple colors. You must have a coherent picture. No abstract art with random shapes. You must use multiple types of graphic functions (e.g. circles, rectangles, lines, etc.) Somewhere you must include a WHILE or FOR loop to create a ...
898063b188e360577a48bd0246b7eccdea9c442f
huangty1208/Data-Challenge
/Customer Cliff/RLS.py
1,563
3.734375
4
# Generate 'random' data np.random.seed(0) X = 2.5 * np.random.randn(100) + 1.5 # Array of 100 values with mean = 1.5, stddev = 2.5 res = 0.5 * np.random.randn(100) # Generate 100 residual terms y = 2 + 0.3 * X + res # Actual values of Y # Create pandas dataframe to store our X and y values ...
85d5f1a121d86144e786bb60a2c938e8a0e251e7
seyerspython/shiyanlou
/apple_analysis.py
288
3.65625
4
# -*- coding:utf8 -*- import pandas as pd def quarter_volume(): data=pd.read_csv('apple.csv',header=0,parse_dates=['Date'],index_col=[0]) data_3m=data.resample('Q-DEC').sum() second_volume=data_3m.sort_values(by='Volume')['Volume'][-2] return second_volume print(quarter_volume)
667ace0a8cdbb1ee12acb9282ed7006c18cc107f
phamous2day/courseraChallenges
/UdemyPythonPostgreSQL/makeMethod.py
626
3.8125
4
import random def ask_user_and_check_number(): user_number=int(input("Enter a number between 0 and 9: ")) if user_number in magic_numbers: print("You got the number correct!!") if user_number not in magic_numbers: print("You totally got the number WRONG!") magic_numbers = [random.randint(0...
66bd26baa04365307e68a0cdc57d8f8676c87589
DrunkenAlcoholic/PythonScripts
/Ancient.Ciphers.py
2,353
3.5
4
#!/usr/bin/env python3 """ Description: Ancient implementation of Caesar/ROTxx/Vigenere ciphers. Author: DrunkenAlcoholic Date: June 2019 """ # Custom Alphabet used for Caesar or Vigenre or Both sAlphabet = 'aBcDeFgHiJkLmNoPqRsTuVwXyZAbCdEfGhIjKlMnOpQrStUvWxYz0123456789' iAlphaBet = len(sAlphabet) def caesar(sSource...
7e0c61f3130987cc8bec0408489de75bb194695f
agusaldasoro/gen_tests
/TP1/workspace-autotest/tp1/examples/encryption.py
1,772
3.5625
4
# # Relative letter frequencies for the french and english languages. # First item is letter 'A' _frequency and so on. # ENGLISH = (0.0749, 0.0129, 0.0354, 0.0362, 0.1400, 0.0218, 0.0174, 0.0422, 0.0665, 0.0027, 0.0047, 0.0357, 0.0339, 0.0674, 0.0737, 0.0243, 0.0026, 0.0614, 0.0695, 0.0985, 0.0300, 0.0116,...
f736d12f3cbce12040c58d2cedd7e20586485334
agusaldasoro/gen_tests
/TP1/workspace-autotest/tp1/examples/persons.py
563
3.75
4
''' Created on Sep 1, 2016 @author: galeotti ''' def youngest(ages): if len(ages) == 0: return None min_age = None for name in ages.keys(): age = ages[name] if age < min_age: min_age = age return min_age def oldest(ages): if len(ages) == 0: return None...
5979f5f1eba5eb8fb3706dd8023f5429ae5f2ef2
bulboushead/AtBS
/CoinFlip.py
1,140
3.53125
4
def CoinFlipStreaks(): import random, sys trials = 100000 numberOfStreaks = 0 minStreak = 6 for experimentNumber in range(trials): #Create 100 HT values flips = 100 flipList = [] for i in range(flips): if random.randint(0,1) == 0: ...
1c6321b991aabf63764f2e65f1b4ea0d1f1a537e
Ardrake/PlayingWithPython
/drawstar.py
225
3.84375
4
'''this program draws a five corner star''' # ntoehunt import turtle wn = turtle.Screen() dstar = turtle.Turtle dstar.pencolor('blue') angle = 40 for i in range(5): dstar.right(angle) dstar.forward(100)
b884cc6e8e590ef59a9c3d69cad3b5d574368916
Ardrake/PlayingWithPython
/string_revisited.py
1,674
4.21875
4
str1 = 'this is a sample string.' print('original string>>', str1,'\n\n') print('atfer usig capitalising>>',str1.capitalize()) #this prints two instances of 'is' because is in this as well print('using count method for "is" in the given string>>', str1.count('is')) print('\n\n') print('looking fo specfic string lit...
e385e84609ec8ac97b67310992bf9a74b9f2fa03
skanel/pykhmer-docs
/Dictionaries.py
1,801
3.578125
4
# -*- coding: utf-8 -*- """ Created on Mon Jan 28 16:46:57 2019 @author: Kanel.Soeng """ my_dict = { "key1":"value1", "key2": "value2" } my_dict my_dict["key1"] fruits = {"Apple": 3, "Banna": 1.75, "Cherry": 2} fruits fruits["Cherry"] # 2) Dictionaries with all data type's new_di...
6b8534e3bfa2a2511fffca47f90fbcdbc4b879fd
skanel/pykhmer-docs
/Boolean.py
993
3.859375
4
# -*- coding: utf-8 -*- """ Created on Wed Mar 13 07:03:54 2019 @author: Kanel.Soeng """ # Boolean's ## True true False false type(True) 10 > 9 3 == 2 7 < 5 #example 1: l = [1,2,3,4, -1,-3] #control flow , if else => boolean to control the flow logic of the programs. for i in l: if -3 >= 1 : print(i)...
26afd30edfecaeb3b79bd8fccf0bdb63a114e421
skanel/pykhmer-docs
/fx2.py
2,091
3.59375
4
# -*- coding: utf-8 -*- """ Created on Mon Apr 29 19:03:48 2019 @author: Kanel.Soeng """ from math import sqrt print("ស្រាយ​សមីការដឹក្រេទី 2: ax^2 + bx + c = 0") a = float(input("បញ្ចូល a: ")) b = float(input("បញ្ចូល b: ")) c = float(input("បញ្ចូល c: ")) if a == 0: if b == 0: if c == 0: prin...
88e075ee41de693ffac1d3ead9078941d7cb7ab1
bombero2020/python_tools
/euromill.py
2,891
3.5
4
import pandas as pd # Use this function on premise if there is no data# def actualizarlista(): '''Función que toma todos los números, incluido el último, de los resultados de los sorteos y los mete en Resultados_base.csv''' print("Recuperando datos de Google spreadsheet") ref = "https://docs.google...
93f34502472cddeb27d9d3404fb0f4f5269bb920
ladipoore/PythonClass
/hass4.py
1,239
4.34375
4
""" I won the grant for being the most awesome. This is how my reward is calculated. My earnings start at $1 and can be doubled or tripled every month. Doubling the amount can be applied every month and tripling the amount can be applied every other month. Write a program to maximize payments given the number of month...
a059707c56ec6ca5511f685ae678f8d7938feafc
Chaitainya/Python_Programs
/hello.py
197
3.5625
4
# def greet(names): # for name in names: # print("Hello", name) # greet("monica") def greet(*names): for name in names: print("Hello", name) greet("monica","leon","sheema")
dd6bd262bba20f8b9cbbed4e81f51312986f1440
Chaitainya/Python_Programs
/class_3.py
204
3.890625
4
class Add: num_1 = 4 num_2 = 5 def __init__(self,num_3): self.num_3 = num_3 def num(self): return self.num_1 + self.num_2 + self.num_3 add = Add(6) print(add.num())
f6b533e909b813218b187015c4e36bb8b4b22c86
Chaitainya/Python_Programs
/reverse.py
163
4
4
my_list = [1,2,3,4,5,6,7,8,9,10] print(my_list[::-1]) my_tuple = (1,2,3,4,5,6,7,8,9,10) print(my_tuple[::-1]) my_str = "1,2,3,4,5,6,7,8,9,01" print(my_str[::-1])
18892e6ba25a7f3ec491f1cb5c23f6f3278f0432
mahmutkamalak/word-letter-counter
/char counter.py
3,201
4.0625
4
from tkinter import Tk,Button,Label,StringVar,Entry,DoubleVar ##tkinter window =Tk() #get a new window window.title('Character&word counter') # window.configure(background='red') ...
6e0a0d84763e65fc5b8161a432874cf245fe4b5f
Pawtang/learn-py
/Through Section 5/number_lists.py
181
4.1875
4
even = [2, 4, 6, 8] odd = [1, 3, 5, 7, 9] #Nested List numbers = [even, odd] for number_list in numbers: print(number_list) for value in number_list: print(value)
a46b0b613c55afe16054daab51880a610d5c64ca
aja2000/imbot1
/test.py
301
3.671875
4
swears = open("swears.csv", "r") key = swears.read() split = key.split(",") # print(split) message = 'poop' def bad_word_test(): for word in split: if message == word: return True return False if bad_word_test(): print('bad word') else: print("child of god")
e8490f5d83ca0755a3cb07269a5fff76746a7b58
divij234/python-programs
/python programs/FactorsUsingWhile.py
188
3.984375
4
num=int(input("Enter a number : ")) i=1 print("The factors of ",num,"are :-") while i<=num: if num%i==0: print(i) i+=1
34a526561a96ff912b365dd9a62f92f607f51d9f
divij234/python-programs
/python programs/ForExample.py
151
4.25
4
str=input("Enter a string : ") for x in range(len(str)): print(str[x]) #we can also do it like this:- for element in str: print(element)
9963f40ed9b635d430c35b57695116416ef91654
divij234/python-programs
/python programs/list1.py
213
4.09375
4
#WAP to search for an elemnt in a given list li=[] for i in range(0,6): val=input("enter the elements") li.append(val) if 12 in li: print("it is present") else: print("it is not present")