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
4f8006bf6330423f2fc83e1f53668680df49dc90
pinkrabbit412/tweepy
/examples/API_v2/search_recent_tweets.py
739
3.59375
4
import tweepy bearer_token = "" client = tweepy.Client(bearer_token) # Search Recent Tweets # This endpoint/method returns Tweets from the last seven days response = client.search_recent_tweets("Tweepy") # The method returns a Response object, a named tuple with data, includes, # errors, and meta fields print(res...
79a7d6bdab7a4991df1de9de850c85cd64b4cbe8
pinkrabbit412/tweepy
/examples/API_v2/create_tweet.py
826
3.5
4
import tweepy consumer_key = "" consumer_secret = "" access_token = "" access_token_secret = "" client = tweepy.Client( consumer_key=consumer_key, consumer_secret=consumer_secret, access_token=access_token, access_token_secret=access_token_secret ) # Create Tweet # The app and the corresponding credentials...
c1a8a76734d58b4eacda142fd001a15f7c366ec0
izi-on/tic-tac-toe-ai
/tictactoe.py
9,968
3.671875
4
import random from copy import deepcopy import time class Vector: def __init__(self, xpos, ypos): self.x = xpos self.y = ypos class Board: #init def __init__(self): self.turn = 1 self.memory = [[0 for i in range(3)] for j in range(3)] self.memoryg = [[" " for i in ...
287d3bd2358c740a2b574b0b1ecc2815986a0346
AvaneeshKolluri/Intro-to-Programming
/life_starter/life.py
3,312
3.9375
4
# # life.py - Game of Life lab # # Name: Avaneesh Kolluri # Pledge: I pledge my honor that I have abided by the Stevens honor system. # import random import sys import random def createOneRow(width): """Returns one row of zeros of width "width"... You should use this in your createBoard(width, hei...
4860b1bd85a02365084cf061a3ed593bc1d8f7c3
AvaneeshKolluri/Intro-to-Programming
/hw6.py
3,357
3.5
4
''' Created on 10/14/19 @author: Avaneesh Kolluri (Working with Marjan Chowdhury) Pledge: I pledge my honor thatI have abided by the Stevens honor system. CS115 - Hw 6 ''' # Number of bits for data in the run-length encoding format. # The assignment refers to this as k. COMPRESSED_BLOCK_SIZE = 5 # Num...
70f7775fdd67701a440d1aacf3292f28efa1e8ce
lzfun/LeetCode
/code/54_spiral_matrix_v2.py
1,157
3.609375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Aug 24 16:04:55 2019 @author: lz """ class Solution: def spiralOrder(self, matrix): # m: number of column, n: number of row if not matrix: return([]) m, n = len(matrix), len(matrix[0]) min_i ...
30cd347165f1a3d30b34b67e895ddb2375d14fc7
bs3537/DS-Unit-3-Sprint-2-SQL-and-Databases
/demo_data.py
1,138
3.859375
4
import sqlite3 conn = sqlite3.connect('demo_data.sqlite3') curs = conn.cursor() create_demo_table = """CREATE TABLE demo ( id SERIAL PRIMARY KEY, s TEXT, x INTEGER, y INTEGER ); """ curs.execute(create_demo_table) insert_row = """INSERT INTO demo (s, x, y) VALUES ('g',...
6bfe8e8672f6ff36f14649e16778648bd448f522
easily44/hackerrank_python
/collections_piling_up.py
714
3.65625
4
if __name__ == '__main__': for i in range(int(input())): le = int(input()) my_list = list(map(int, input().split(' '))) direction = True fin = True # 如果为Yes,那么这一串数因该是先变小再变大,于是O(n)检查下就ok for j in range(1, le): if direction and my_list[j-1] >= my_list[j]: ...
77a38f7df7256fcb5685786d9a4accec3a923472
easily44/hackerrank_python
/collections_namedtuple.py
713
3.859375
4
from collections import namedtuple # 法一 # if __name__ == '__main__': # total = int(input()) # avg = -1 # ind = 0 # for i in range(total+1): # columns = list(filter(lambda x: len(x) != 0, input().split(' '))) # if avg == -1: # ind = columns.index('MARKS') # avg =...
5e5124afff278abe13b0549700fecc29c04afc27
daryoush12/joking-bot
/game.py
1,295
3.578125
4
import random class DiceGame(): def __init__(self, initiator:str): self.score = {} def rollDice(self, roller:str): score = int(random.random() * 6) if roller not in self.score.keys(): self.score[roller] = score return self.score[roller], score else: ...
f05dcf821a0537168ea977b58dde9e93a4c5a217
brendanmarks/PythonCrashCourse
/lists.py
428
3.734375
4
guests = ['brendan', 'john', 'mark'] print("Come to my dinner " + guests[0].title()) print(guests[1].title() + " can't come") del guests[1] guests.insert(1, 'benny blanco') print(guests[1].title() + " is now coming") print("I found a bigger table!") guests.insert(0, 'bob') guests.insert(2, 'bill') ...
83a277331712bd94fe73571f43670482db12b240
khushboonyman/artificialintelligence
/box.py
987
3.78125
4
""" Created on Wed Apr 15 21:55:26 2020 @author : """ import location from queue import PriorityQueue class Box: def __init__(self, location, color, letter): self.location = location self.color = color self.letter = letter self.goals = PriorityQueue() def __str__(self)...
6ce47d1e66ff9713f4cfd317a0017411cc8be1af
theors/pdsnd_github
/bikeshare.py
12,251
4.40625
4
import time import pandas as pd CITY_DATA = { 'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv' } def get_filters(): """ Asks user to specify a city, month, and day to analyze. Returns: (str) city - name of the city to analy...
6f0b182548ca7f581e2d73211ab5fdb3ab66e37f
lwllvyb/weixin
/base_db.py
3,912
3.6875
4
#-*- coding:utf-8-*- import sqlite3 DATABASES = { # "维权": {"create":, "query":, "insert":,} } class DB(): def __init__(self, db): self._conn = sqlite3.connect(db) self._cursor = self._conn.cursor() self._db = db def create_table(self, table_name, field_type ): try: ...
79157ee34cfe19bf9a1e1528d1cac56caaa3dee2
Tylerholland12/SPD-2.31-Testing-and-Architecture-
/SPD-2.31-Testing-and-Architecture/lab/refactoring/extract_method.py
1,215
4
4
# Written by Kamran Bigdely # Example for Compose Methods: Extract Method. """ Import math library """ import math def print_stat(): """ write the logic for printing the stats of the class grades """ grade_list = [] # Get the inputs from the user n_student = 5 for _ in range(0, n_student): ...
bcb7903dc7dd35b16f6ec5334d066ca9ec53ee72
Tylerholland12/SPD-2.31-Testing-and-Architecture-
/SPD-2.31-Testing-and-Architecture/lab/refactoring/extract_superclass2.py
1,507
3.8125
4
# by Kami Bigdely # Extract superclass. class Shape: def __init__(self, x, y, visible=True): self.x = x self.y = y self.visible = visible def display(self, message): print(message) def set_visible(self, is_visible): self.visible = is_visible def get_cen...
69109828251c4f0ae8e8a9b252c5e2084f77f9db
stawickiandrzej/Programowanie_w_data_science_podstawy
/24.py
417
3.5
4
# -*- coding: utf-8 -*- """ Created on Mon Feb 10 20:41:31 2020 @author: andrz """ import numpy as np def ux(): liczba = int(input('Ile elementów chcesz wprowadzić: ')) lista = [] for liczba in range(1, liczba+1): lista.append(int(input('Podaj ' + str(liczba) + ' element\n'))) p...
a17d94f5b84e83363d516c1c528b53714de5df6a
adr14n76/juego_python
/ahorcado.py
3,062
3.671875
4
import unicodedata import random import os # Quita las tildes de las palabras pasadas como parametro def normalize(word): normalized=unicodedata.normalize("NFD",word) normalized = "".join([c for c in normalized if not unicodedata.combining(c)]) return normalized.replace("\n","") # Comprueba que la longi...
7ad24632cc282dc1fa22a8cd96712b25920dd782
Bernicehsieh11/WorkPlace_DB
/Insert_table.py
831
3.875
4
import sqlite3 conn = sqlite3.connect("storage/myInfo2.db") # 資料庫連線 print('請輸入myInfo資料庫student2表單資料') class dbDate: def __init__(self, id, name, gender): self.id = id self.name = name self.gender = gender def get_student2(): while True: new_name = input('請輸入您...
c026af4482848c644fe47849d97799961c751661
mudoimeh/Python-Challenge
/PyPoll/main.py
2,569
3.640625
4
import os import csv # Open the CSV File election_csvpath = os.path.join("Resources", "election_data.csv") #Initialize variables voter_id=[] candidates=[] #Read the CSV file with open(election_csvpath, newline ='') as csvfile: #CSV reader specifies delimiter and variable that holds contents csv_reader = c...
35893915ac274b77ff0cea2c79e77ab6a92363d7
eastbeam/Spartan_Algorithms
/Week1/02_find_alphabet_occurrence_array.py
905
3.90625
4
def find_alphabet_occurrence_array(string): alphabet_occurrence_array = [0] * 26 # 이 부분을 채워보세요! for char in string: if not char.isalpha(): continue arr_index = ord(char) - ord("a") alphabet_occurrence_array[arr_index] += 1 return alphabet_occurrence_array # for...
452a90968123516ec858f6685398749ece6d3b45
eastbeam/Spartan_Algorithms
/Week1/homework1/01_find_prime_list_under_number2.py
356
3.765625
4
input = 20 def find_prime_list_under_number(number): # 이 부분을 채워보세요! prime_list = [] for i in range(2, number+1): for d in range(2, i): if (i % d) == 0: break else: prime_list.append(i) return prime_list result = find_prime_list_under_number(in...
ac344590c172cceab76f24d1abf90190fd90afe7
anandi24/PythonGames
/src/8-puzzle/driver_3.py
3,270
3.890625
4
import math import collections def main(): #size = int(input('Input the length of board: ')) size = 3 goalList = list(range(0, int(math.pow(size, 2)))) #print(goalList) #search_initialState = input('Input the search criteria aith the initial position') print("dfs ", bfs([1,2,5,3,4,0,6,7,8],goalList, size))...
9e46f433922de5f50f0a3f527c380c94d8438918
Akhilesh286/python3-tutorial
/inheritenes.py
1,201
4.03125
4
""" class base_slass: def desplay(self): print ("welcome") class sabe_class(base_slass): def hello (self): print ("hello") x=base_slass() x.desplay() y=sabe_class() y.desplay() y.hello() """ """ class base_slass: def desplay(self,name): self.name=name class sabe_class(base_slass)...
e3ca6f86c1b5e97d2813b1512b99c9d53ce5c0c4
Akhilesh286/python3-tutorial
/operators.py
400
3.875
4
""" class sample: def name (self,name): self.name=name first=sample() secound=sample() last=first+secound """ "this is eroar" class sample: def name (self,name): self.name=name def __add__(self,other): name=self.name+other.name return name first=sample() secound=sam...
f30a9c52b7223972fcacf450c8815820989f22a7
AdamJDuggan/starter-files
/frontEndandPython/lists.py
847
4.59375
5
the_count = [1, 2, 3, 4, 5] fruits = ["apples", "oranges", "pears", "apricots"] change = [1, "pennies", 2, "dimes", 3, "quarters"] #this kind of for loop goes through a list for number in the_count: print("This is count {}".format(number)) #same as above for adam in fruits: print("A fruit of type {}...
3ac22ffc7c7235db005faa99632ebe4b502f183c
Rifleman354/Python
/Python Crash Course/Chapter 11 Exercises/techPriestEmployeeTest.py
707
3.515625
4
import unittest from techPriestEmployee import TechPriestEmployee class TestTPE(unittest.TestCase): """Test for the class TechPriestEmployee""" def setUp(self): """Creates the print template for employee raises""" self.helios = TechPriestEmployee("Helios","Archmagos") def throne...
284d58c827ece444a7fec306bb4c6ec5cc6c50e7
Rifleman354/Python
/Python Crash Course/Chapter 5 Exercises/xenosColor2.py
237
3.734375
4
xenos_color = 'red' # Input variable if xenos_color == 'green': print('Player 1 just earned 5 points') if xenos_color != 'green': # Since input variable is not green, it will input this print print('Player 1 just earned 10 points')
3b51c6b69472acfb105874ccc2b828ae47f3697d
Rifleman354/Python
/Python Crash Course/Chapter 9 Exercises/Imports/pythonGlossary2.py
475
3.5625
4
from collections import OrderedDict python_glossary = OrderedDict() python_glossary['variables'] = 'storing individual pieces of information' python_glossary['if_statements'] = 'conditional statement that returns a boolean value' python_glossary['boolean'] = 'true or false value' python_glossary['string'] = 'a...
7da75b4e2487a7ffa0fd6cc241419e0bcab0829a
Rifleman354/Python
/Python Crash Course/Chapter 5 Exercises/xenosColor5.py
301
3.734375
4
xenos_color = 'green' # Input variable if xenos_color == 'green': # A nested conditional that will print this string print('Player 1 just earned 5 points') elif xenos_color == 'yellow': print('Player 1 just earned 10 points') elif xenos_color == 'red': print('Player 1 just earned 15 points')
106f3481f3729ad16d40d4eb0b67a1302d91e777
Rifleman354/Python
/Python Crash Course/Chapter 5 Exercises/checkingUsernames.py
422
3.890625
4
current_users = ['Matthew', 'Amanda', 'Terry', 'Ashley', 'Bruce'] new_users = ['Ashley', 'York', 'Jacob', 'Terry', 'Caitlyn'] for call_new_users in new_users: # A loop that determines redundant names if call_new_users in current_users: print('Username ' + call_new_users + ' is not availible!') else: ...
649709a3d891fb41a6fe3a5701126d2f9abe67f2
Rifleman354/Python
/Python Crash Course/Chapter 4 Exercises/cubingNumbers.py
149
4.1875
4
for value in range(1,11): print(value**3) #Cubes numbers in a for loop, and prints each of those numbers ranging from # 1^3 all the way to 10^3
72f11416599e5b641d106383f15fc2bb80603919
Rifleman354/Python
/Python Crash Course/Chapter 8 Exercises/40K_TankDeployments.py
707
3.90625
4
def Vehicle_Variant(tank_model, tank_variant, deployment_location): """Prints the location where the tank model will be deployed and what variant it is""" make_tank = 'Archmagos, the ' + model + ' (Variant ' + variant + ')' + ' will be deployed in the ' + location + '!' return make_tank while True: print(...
010d88f7955c14f627fd6f41c084959fdcf78938
Rifleman354/Python
/Python Crash Course/Chapter 7 Exercises/banebladeProduction3.py
1,089
3.90625
4
prompt = '\nHow many Baneblades do you want us to mass produce Archmagos?' prompt += '\n(Enter "quit" when you are finished) Type digits here: ' # Prompts the user to input numerical digits of how many Baneblades to deploy active = True # Creates a flag that allows the user to quit the program while active: veh...
8892dec1b9f7deb2dc086c8129da0099f1b6be73
AmberJing88/algorithm-datastructure
/backtracking/Hannouta.py
306
4
4
# datastructure and algorithmm in python #chapter 4 4-14 solution def move(x, y): print("move from " + x + " to "+ y) def Hanot(x, y, z, n): if n==1: move(x, z) else: Hanot(x, z, y, n-1) move(x, z) Hanot(y, x, z, n-1) Hanot('a', 'b', 'c', 3)
6082f4033e597630870dcc50aa1925d560de680d
AmberJing88/algorithm-datastructure
/Array/arrayreview566.py
780
3.96875
4
""" Reshape the rows and columns of given matrix at same row-traversing order.""" def ReshapeMatrix(nums,r,c): temp = [] #r, c = 0, 0 for n in nums: temp += n reshape = [] if r * c == len(temp): for j in range(0, len(temp),c): reshape.append(temp[j:j+c]) ...
347d6a5e8744a20ec24bcf68ae1b271f3662e234
AmberJing88/algorithm-datastructure
/Array/ArrayReview697.py
4,905
3.75
4
# Array problems """leetcode 697: degree of array the longest distance of the repeated numbers in an array, find a subarry which has same degree with the original one""" from collections import defaultdict def findshortest(nums): count, position = defaultdict(int), {} for i num in enumerate(nums): ...
6a158ab3288c24b7fdbced8587c827e334169615
AmberJing88/algorithm-datastructure
/dp/DPReviewFibo.py
4,266
3.828125
4
#Dynamic Programming """Fibonachi problem; 母牛生产问题,一只小母牛从第三年开始生产小母牛,每年都生产一头,每只小母牛3年之后成熟, 又可以生产小牛,求n年后,母牛的数量。假设牛不死亡。""" def numCows(n): if n <=3: return n dp = [0 for _ in range(n+1)] dp[1], dp[2],dp[3] = 1, 2, 3 for i in range(4,n+1): dp[i] = dp[i-1]+dp[i-3] return dp[n] ...
4afd966fb6f6c2927331fdaafb38ba9e701ad42a
AmberJing88/algorithm-datastructure
/Binary-Tree/TreeReview112.py
6,716
3.796875
4
# Tree """112:path sum: given a vinary tree and a sum, determin if the tree has a root to leaf path such that add up all the values along the path equals the given sum. """ class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def...
633a372519eebf07d71db6a795289dc1352f4b4f
sherrymou/CS110_Python
/Mou_Keni_A52_Assignment1/chp2#4.py
471
3.84375
4
''' Keni Mou Cs110-A52 kmou1@binghamton.edu Day calculate Comment: I tried the day within 7 days, exactly 7 days and more than 7 days, they all worked correctly. ''' def main(): #Get input Day = input ("What day is it today? (0 is Sunday and 6 is Saturday)") Days = input (" How many days you want to sta...
478ef69c5baf8083ea67d155969b4b04108c1994
sherrymou/CS110_Python
/Mou_Keni_A52_Lab9/#1-5.py
773
3.78125
4
''' Keni Mou Kmou1@binghamton.edu Lab9, Excerise 1-5 Lab Section 52 CA Kyle Mille ''' ''' Analyze: write a temperature conversion table called tempConv.txt Output to file: tempConv.txt The table will include temperatures from -300 to 212 degree Fahrenheit and their Celsius equivalents. Tasks: fahToCe...
a8e5e788a73225147820189ea73a638e1547345e
sherrymou/CS110_Python
/Mou_Keni_A52_Assignment4/1. gradeChecker.py
1,188
4.125
4
''' Keni Mou Kmou1@binghamton.edu Assignment 4, Exercise 1 Lab Section 52 CA Kyle Mille ''' ''' Analysis Get grade from mark Output to monitor: grade(str) Input from keyboard: mark(float) Tasks allocated to Functions: gradeChecker Check the mark, determine the mark belongs to which grade '''...
c438c3f44c1a2e9b7e12d3a8289e058361f99228
sherrymou/CS110_Python
/Mou_Keni_A52_Lab9/#1-2.py
1,729
4.21875
4
''' Keni Mou Kmou1@binghamton.edu Lab9, Excerise 1-2 Lab Section 52 CA Kyle Mille ''' ''' Analyze To compute the max rain fall, min rain fall, and average rain fall use the readline() method Output to the monitor: maxrain(float) minrain(float) average(float) Input from keyboard: filename(str) Tasks: g...
79e07dfaa15447462adfa03cb4d3e5bba929b767
sherrymou/CS110_Python
/Mou_Keni_A52_Assignment7/#3. cipher_refactor.py
4,924
3.546875
4
''' Keni Mou Kmou1@binghamton.edu Assignment 7, Exercise 3 Lab Section 52 CA Kyle Mille ''' """ Analysis to encrypt or decrypt a cipher Output to monitor: processedMessage(str) Input from keyboard: operator(str) rotationKey(int) Tasks allocated to functions: operationValidated: Check that requested operat...
cc2d9b75be11f392906fab1f1e840f0865773c87
vicasindia/programming
/Python/even_odd.py
376
4.5
4
# Program to check whether the given number is Even or Odd. # Any integer number that can be exactly divided by 2 is called as an even number. # Using bit-manipulation (if a number is odd than it's bitwise AND(&) with 1 is equal to 1) def even_or_odd(n): if n & 1: print(n, "is Odd number") else: print(n, "is Ev...
984502a364fc3b6f38a93ec72569aaaf2721f359
vicasindia/programming
/Python/binary_converter.py
324
3.984375
4
#Input: Decimal Number (Integer) #Output: Binary Number (Signed 2's Complement) num = int(input("Enter the Decimal Number: ")) byt = int(input("Enter the number of bytes you want to your integer be in: ")) bit = byt*8 for i in range(bit): if (num<<i) & (1<<(bit-1)): print(1, end="") else: print(0, end="") print...
3afdc320d01978fd193e7793b5665c5d10163b87
lreissmueller/CECS-328
/ClosestNumber_ToMedian.py
4,616
3.84375
4
import random def median_of_three(arr, left, right): mid = (left + right) // 2 if arr[left] > arr[mid]: arr[mid], arr[left] = arr[left], arr[mid] if arr[mid] > arr[right]: arr[mid], arr[right] = arr[right], arr[mid] if arr[right] < arr[left]: arr[right], arr[left] = arr...
873337135bfd4f15ec675a84881b2a41048f19e3
Robbie-K/Python
/Python Programs/Exercises/ex6.py
1,120
4.0625
4
# function to replace "old" letters in the string "s" with "new" letters def replace(s, old, new): s = s.replace(old,new) # simply use replace and all instances of the input old # become the input "new" in the inputed string "s" return s # just the test function from th...
103bb59b042e5008948b3a08b1f4cc530f91c2b5
Robbie-K/Python
/Python Programs/Tutorials/tut07.py
585
3.890625
4
def reverseVowels(): word = input("Please enter a word: ") vowels = 'aeiou' vowelList = [] posList = [] newList = [] newWord = '' for i in range(len(word)): newList.append(word[i]) for char in word[i]: if char in vowels: posList.append(i...
f79ff843a446b44673aaf22c80b75be276983922
Robbie-K/Python
/Python Programs/Exercises/ex7.py
3,004
4.34375
4
# Robert Karg exercise 7 # function to "flatten" aka get rid of all the [] inside of a list def flatten(numList): newList = [] # creating two lists to be used later finalList = [] indexNum = 0 # used to find the place of index # this if statement just checks if the list is empty then returns it if...
d3e0d225ad6910196cea5cb5351655b3cd780288
Robbie-K/Python
/Python Programs/Exercises/ex8.py
988
4.03125
4
""" Robert Karg Exercise 8 """ import sys def countLettersInString(string): """ Function for counting letters in a given string and printing the results """ letterCount = {} # empty dictionary # creates new keys if they don't exist, adds to them if they do for char in string: # c...
bbe469ad9a327b003c16c7053f89791f91566984
Robbie-K/Python
/Python Programs/Tutorials/tut08.py
2,457
3.8125
4
# question 7 def sortSequence(seqList): newList = [] for i in range(len(seqList)-1): if seqList[i]<seqList[i+1]: newList.append(seqList[i]) if seqList[i] == seqList[-2]: newList.append(seqList[i+1]) else: if seqList[i]>seqList[i+1]: ...
3c3e2be95272bad1d66eec4ffc69d72252b5a4a7
PDXDevCampJuly/john_broxton
/python/Connect_Four_Assignment/Connect_Four/tests/test_check_game_status.py
5,880
3.671875
4
__author__ = 'jbroxton' import unittest from connect_4_controller import Connect_Four_Controller class test_check_win_loss_tie(unittest.TestCase): """Check that the print board function returns a board""" def setUp(self): self.controller = Connect_Four_Controller() print("Running: ", str(se...
f2e905df1a705b1baba954fbdbb63fd8415da8af
PDXDevCampJuly/john_broxton
/python/encode_decode/encoder.py
1,017
3.875
4
# # ***** The ****** # ,------. ,--. #| .---',--,--, ,---. ,---. ,-| | ,---. ,--.--. #| `--, | \| .--'| .-. |' .-. || .-. :| .--' #| `---.| || |\ `--.' '-' '\ `-' |\ --.| | #`------'`--''--' `---' `---' `---' `----'`--' # # ...
419411b48b60121fec7809cb902b8f5ad027a6d2
PDXDevCampJuly/john_broxton
/python/maths/find_prime.py
813
4.1875
4
# # This program inputs a number prints out the primes of that number in a text file # ################################################################################### import math maximum = eval(input("Please enter a number. >>> ")) primes = [] if maximum > 1: for candidate in range(2, maximum + 1): is_prime...
e80520fea7160878811113027d0483d028041d82
PDXDevCampJuly/john_broxton
/python/sorting/insertion_sort.py
1,441
4.25
4
def list_swap(our_list, low, high): insIst[low], insIst[high] = insIst[high], insIst[low] return insIst pass def insertion_sort(insIst): numbers = len(insIst) for each in range(numbers - 1): start = each minimum = insIst[each] for index in range(1, len(insIst)): ...
b6ab651747afa6b017ca57906670805ab480971c
lemons2lemonade/singleLayerPerceptron
/perceptron.py
9,379
3.546875
4
#Written by Matt Wallace and Subhan Poudel on 7/16/17 #This is a neural network that decides whether a sentence is imperative or declarative through a perceptron type model. #The program will stop once the weights do not change on two iterations of the entire input set. #The code is similar to neuralNet.py but uses a p...
24c21296a4f3c99eb006c40e641a920667d5e771
PrathameshDhumal/Python-programming
/Arithematic/Arithematic5.py
229
3.84375
4
#sum of 2 nos with better input method #user defined addition no1 = int(input("Enter First number")) #scanf("%d,&no1); no2 = int(input("Enter second number")) ans = no1 + no2 print("Addition is : ",ans)
1f4d86130c01d518108407fd9e8bac704837bedc
PrathameshDhumal/Python-programming
/format/format.py
360
3.96875
4
#WAP: Addition of two nos using format def Addition(no1,no2): return no1+no2 def main(): value1 = int(input("Enter First number")) value2 = int(input("Enter second number")) ret = Addition(value1,value2) print("Addition of {} and {} is {} ".format(value1,value2,ret)) ...
bfc7ec44375b5bde96896d0c580436d1bcef660f
PrathameshDhumal/Python-programming
/Operators/student.py
581
3.734375
4
class Student: def __init__(self,str,a,b,c): self.name = str self.m1=a self.m2=b self.m3=c def __eq__(self,other): if self.m1==other.m1 and self.m2 == other.m2 and self.m3 == other.m3: return True else: return False ...
7d547bdaf70b0edd9f79afcf1fae6cd9695d9289
PrathameshDhumal/Python-programming
/atm/mt1.py
623
3.796875
4
Amount = 1000 def ATM(func): func() def Deposit(): value = int (input("Enter the amount to deposite")) global Amount Amount = Amount + value print("Deposite successful - Balance : ",Amount) def Withdraw(): value = int(input("Enter the amount to withdraw")) global Amount...
60551a95ada9a8e80ab30fa8544252c9a26fa7b6
Mayank12899/java
/ds/Stack/Python/22_MultipleMissing.py
566
4.03125
4
# You have given an integer array of size N. Array contains numbers from 1 to N-1 but a couple of numbers are missing in an array which also contains duplicates. # Write a Java program to print the missing number from the sequence. # For example, if the given array is {1, 1, 2, 3, 5, 5, 7, 9, 9, 9} then it has length...
6b20f807b9e86d7ddef617a9f7769ebceb188006
duke253/Rost_Sessions
/session_02_1.py
257
3.953125
4
user_dict = {} answ = '' while answ != 'N': user_input = input('enter key-value pair, separated by comma(,)') key, value = user_input.split(',') user_dict[key] = value answ = input('press Y to continue input, N to exit') print(user_dict)
6461d4c75f432b101f44faeb3bd884e04216ad3d
NewDevBr/py-algs
/exer2.py
326
4.09375
4
print("**** Exibe o menor nmero digitado ****") n1 = int(input("Digite um nmero: ")) n2 = int(input("Digite outro nmero: ")) if (n1 > n2): print("{} o menor nmero.".format(n2)) else: if(n1 < n2): print("{} o menor nmero.".format(n1)) else: print("Os valores digitados so iguais.")
df6967a6f27d39111e1b27a67525e7a7fa274929
ICC3103-202110/laboratorio-01-lulygavrilov
/tryput.py
795
3.765625
4
import random size = 20 cardsup = [] cardsdown = [] for i in range (1,size+1): cardsup.append(i) cardsup.append(i) cardsdown.append('X ') cardsdown.append('X ') random.shuffle(cardsup) print(cardsup) def boardcardsup(size): divisibility = [2,3,5] for j in divisibility: if (size%j) == 0: ...
a48379ad176ca8778b1b7689a8e825452e174df3
RMartin7424/rootfinding
/Project.py
24,105
3.53125
4
####################################################################################################################################################################### # Rootfinding Methods (Bisection - False Position - Fixed Point - Newton's - Aitken's Delta Squared) # Rachel Martin ################################...
31ea7b76addea2e6c4f11acd957550a69c864ef1
DKNY1201/cracking-the-coding-interview
/LinkedList/2_3_DeleteMiddleNode.py
1,263
4.125
4
""" Delete Middle Node: Implement an algorithm to delete a node in the middle (i.e., any node but the first and last node, not necessarily the exact middle) of a singly linked list, given only access to that node. EXAMPLE Input: the node c from the linked list a -> b -> c -> d -> e -> f Result: nothing is returned, but...
3aed5cf1457523970b53d09b084248f72128167a
DKNY1201/cracking-the-coding-interview
/ArraysAndStrings/1_1_IsUnique.py
1,324
3.96875
4
""" Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures? """ import unittest def is_unique(s): return len(set(s)) == len(s) def is_unique_no_data_structure(s): L = len(s) for i in range(L): for j in range(i + 1, L): ...
07c82c126fd67695bc76d17a1112e54baa1b5b77
ankurdhoot/reinforcement-learning
/ch5/blackjack.py
6,913
3.984375
4
import random from collections import namedtuple import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D class Blackjack: """Simulates Example 5.1. To replicate the results in the book: b = Blackjack(20, 500000) b.simulate() b.generate_plot() """ # TODO: ...
0a9cf0e1f32557d688c0c1ee4b1665cabc76222e
KUSH2107/FIrst_day_task
/32.py
238
3.8125
4
''' Write a program to generate below Pattern: * * * * * * * * * * * * * * * * * * * * * ''' for i in range(1,6): for k in range(1,6-i): print(" ",end="") for j in range(1, (2*i-1)+1): print("*",end="") print("\n")
bde824ab4e2609733c2b6a4dedb0024bf19987cc
KUSH2107/FIrst_day_task
/21.py
217
4.09375
4
''' By using list comprehension, please write a program generate a 3*5*8 3D array whose each element is 0 ''' a = 3 b = 5 c = 8 lst = [[ [ 0 for col in range(a)] for col in range(b)] for row in range(c)] print(lst)
bb3f4cde389b50ffa4157e4310c764f66d7f9cb0
KUSH2107/FIrst_day_task
/17.py
237
4.125
4
# Please write a program to shuffle and print the list [3,6,7,8] import random a1_list = [1, 4, 5, 6, 3] print ("The original list is : " + str(a1_list)) random.shuffle(a1_list) print ("The shuffled list is : " + str(a1_list))
11bc400d6e84e583a72d3ff7d94a952e7f46aa68
ms0223900/algorithm-python-and-js
/practices/chapter15_greedy/python/ch_15_knapsack_problem.py
1,094
3.546875
4
MAX_WEIGHT = 1 things_in_pack = { 'AppleWatch': (15000, 0.1), 'AsusLaptop': (35000, 0.7), 'Iphone': (38000, 0.3), 'AcerLaptop': (40000, 0.8), 'GoPro': (12000, 0.1) } # 盡可能在max weight之內塞最大價值的物品 # things要先排序 def greedy_pack(things): length = len(things) picked_thing_list = [] # 先塞價值最高的 last_thing = th...
110a9b6feb8bda46b39ab4882746476691499c9d
ms0223900/algorithm-python-and-js
/practices/chapter9_sort/python/ch_9_quick_sort.py
655
3.984375
4
import random def quick_sort(data_list=[]): if len(data_list) <= 1: return data_list left = [] right = [] pivot_arr = [] # 隨機挑一個基準點 pivot_now = random.choice(data_list) for data in data_list: if data == pivot_now: pivot_arr.append(data) elif data < pivot_now: left.append(data) ...
a24116fb8d54a777402cf9c336c756ce91053eca
ms0223900/algorithm-python-and-js
/practices/chapter13_graph/python/ch_13_breadth_first_search.py
996
4.03125
4
def BFS(graph={}, start='', target=''): visited = [] queue = [start] result = False while queue: # 這個很重要,從前面把值取出來,先將同一層的解決,所以是廣度,否則是深度 node = queue.pop(0) if target and node == target: result = True break # 因為是雙向連結,所以可能會往回找,需要偵測是否該節點已經找過 if node not in visited: visited.ap...
bf008909dd26e7e1a664955247ac5acc5a5211d1
ms0223900/algorithm-python-and-js
/practices/chapter4-queue/ch_4_queue.py
673
3.890625
4
class Queue(): def __init__(self): self.queue = [] def enqueue(self, data): # 插入資料 self.queue.insert(0, data) return self def dequeue(self): # 讀取資料(讀完拔除) if self.size(): return self.queue.pop() return "it's empty queue." def size(self): return len(self.queue) def enqueue_sample...
9baf16dc764f6e9887a7766457b7d6b54d248d36
ms0223900/algorithm-python-and-js
/practices/chapter13_graph/python/ch_13_depth_first_search.py
1,072
3.765625
4
def DFS(graph={}, start='', goal=''): solved_paths = [] stack = [start] solved_res = False while stack: node = stack.pop() solved_paths.append(node) if node == goal: solved_res = True break for child in graph[node]: if child not in solved_paths: stack.append(child) ...
603bd6cff650552137e72abd65a81a6aaf12bcb3
Rei-x/advent-of-code-2020
/days/day12/challenge1.py
1,527
4.03125
4
with open("./input.txt") as file: text = file.readlines() text = [x[:-1] for x in text] class Ferry: DIRECTIONS = {"N": 0, "E": 90, "S": 180, "W": 270} def __init__(self): self.degree = 90 self.direction = self.get_direction() ...
86d39a380f1fb40e1613e1c34e38cd8c250a57ff
Rei-x/advent-of-code-2020
/days/day4/challenge1.py
377
3.8125
4
with open("./input.txt") as file: text = file.readlines() fields = ['byr', 'iyr', 'eyr', 'hgt', 'hcl', 'ecl', 'pid'] passport = "" number_of_valid_passports = 0 for lines in text: passport += lines if lines == '\n': if all(x in passport for x in fields): number_of_valid_passports += 1 ...
7e3f7a913620b8093ba0670f8f592ce471e931d7
nak848/nicodemus
/MagicSquare.py
3,925
4.125
4
# File: MagicSquare.py # Description: This is a program that generates completed magic squares from any given odd input # Student's Name: Nicolas Kim # Student's UT EID: nak848 # Course Name: CS 313E # Unique Number: 50205 # Date Created: 8/30/2019 # Date Last Modified: 9/6/2019 def main(): ...
70bc2ec76a4eb4a44c6d4055f819a69b466a6088
akienm/tridi_nov2016
/Host Software/SugarPi 7/shootstring_utils.py
1,969
3.53125
4
import re # loop = '{0,100,10 R* T }' # shootstring = "][close comments]*NEWLINE_TOKEN*[2 layer 60 and 30 degrees]*NEWLINE_TOKEN**NEWLINE_TOKEN*[Usual] S V0 I1 LO LG3*NEWLINE_TOKEN**NEWLINE_TOKEN*[Spatial Calibration Images]*NEWLINE_TOKEN*R0 E0 E80 R20 R0*NEWLINE_TOKEN*{0,351,90*NEWLINE_TOKEN*R* T*NEWLINE_TOKEN*}*NEWL...
e63bc9a75824ace2c4f9b4f07f3a4c2b556a854e
akashtiwari232/AI_Programs
/Best-First-Search.py
891
3.84375
4
from queue import PriorityQueue v = 14 graph = [[] for i in range(v)] def best_first_search(source, target, n): visited = [0] * n visited[0] = True pq = PriorityQueue() pq.put((0, source)) while pq.empty() == False: u = pq.get()[1] if (u==source): print("Start"...
e9406cbab58bfd67591d5040216efb24637b9a9e
Jafree/NOnBacktrackingEmbedding
/clustering/network_properties/modularity.py
5,450
3.703125
4
''' Created on 2014/9/22 @author: Fei Jiang @email: fei.jiang1989@gmail.com ''' from collections import defaultdict def modified_modularity_node(g,community_map_to_node,node_map_to_community,node_v): ''' The input graph is undirected, unweighted graph. This function is used for calculating the mo...
0770c82371a53a87ba1fb43e8b10fb54bb122d1a
somsomdah/Algorithm
/Algorithm-python/_section5/MinimumHeap.py
1,453
3.609375
4
import heapq as hq a=[] while True: n=int(input()) if n==-1: break if n==0: if len(a)==0: print(-1) else: print(hq.heappop(a)) else: hq.heappush(a,n) # wrong answer ''' def downheap(heap): # 노드 제거 res=heap[1] temp...
6a06cccd8ad50ec3a07e8cf2aba6ff2c579a88e2
somsomdah/Algorithm
/BOJ/_10814_SortingByAge.py
186
3.53125
4
n=int(input()) a=[] for i in range(n): age,name=input().split() age=int(age) a.append((i,age,name)) a.sort(key=lambda x:(x[1],x[0])) for p in a: print(p[1],p[2])
6d7e257c67fe2e7a515c69470571479b58b8736a
somsomdah/Algorithm
/BOJ/_1181_WordSorting.py
150
3.78125
4
n=int(input()) words=[input() for _ in range(n)] words=list(set(words)) words.sort(key=lambda x: (len(x),x)) for word in words: print(word)
868057539a7009043682b2733b7f2e55fd6af0a3
somsomdah/Algorithm
/Algorithm-python/_section2/primeNumber.py
891
3.9375
4
''' 소수(에라토스테네스 체) 자연수 N이 입력되면 1부터 N까지의 소수의 개수를 출력하는 프로그램을 작성하세요. 만약 20이 입력되면 1부터 20까지의 소수는 2, 3, 5, 7, 11, 13, 17, 19로 총 8개입니다. 제한시간은 1초입니다. ''' import sys n=int(sys.stdin.readline()) checklist=[0]*(n+1) count=0 for i in range(2,n+1): if checklist[i]==0: count+=1 for j in range(i,n+1,i): ...
ffeba15eeb36b798cd28586c040a01d385d4a531
dilipmkallarackal/opensource_group14
/bob.py
72
3.5
4
name=input("Enter your name-") print(name ,"haha your name is funny")
9ce1337d3cd44371806d7483ff7fe9d1c0f9aefa
sandeepb20/6w6l_project
/python/cat1.py
410
3.53125
4
import argparse import sys import os my_parser=argparse.ArgumentParser(prog='cat') my_parser.add_argument('Path',metavar='path',type=str,nargs='*',help='Adding path to list') #my_parser.add_argument('-f',action='store',help='File to print data') args=my_parser.parse_args() print(vars(args)) input_path=args.Path prin...
41e1a11de432e75310de03aefe6cabc55daa4421
ethanschafer/ethanschafer.github.io
/Python/PythonBasicsPart1/slides/student.py
408
3.8125
4
class Student: """ A class that represents a student """ def __init__ (self, theName, theGrade, theClass): """ Store the parameters as class variables """ self.name = theName self.grade = theGrade self.className = theClass def getName(self): ...
bd6b555131f3e8842353fa23de7b7e2077c957d7
ethanschafer/ethanschafer.github.io
/Python/PythonBasicsPart1/PythonUnit4-Lists/PythonUnit4-Lists/PythonUnit4-Labs/Ground (3).py
1,043
3.515625
4
import pygame, random from pygame.locals import * def drawGround(window): # load all images into a list bgImages = [ "grass.gif", "road.gif", "gtoroad.gif", "rtograss.gif"] # Create variables to keep track of where to # draw the grass bg = 0 x = 0 y = 0 # Outer loop runs as l...
bd4fb7517823537a46ff3d5b28ff2f5fe36efc32
ethanschafer/ethanschafer.github.io
/Python/PythonBasicsPart1/labs/mathRunner.py
957
4.125
4
from mathTricks import * inst1 = "Math Trick 1\n\ 1. Pick a number less than 10\n\ 2. Double the number\n\ 3. Add 6 to the answer\n\ 4. Divide the answer by 2\n\ 5. Subtract your original number from the answer\n" print (inst1) # Get input for the first math trick num = inpu...
216f121789b5d03d90b97a48f8744818fa2c2dea
ethanschafer/ethanschafer.github.io
/Python/PythonBasicsPart1/PythonUnit4-Lists/PythonUnit4-Lists/slides/tuples.py
161
3.75
4
myTuple = (255, 0, 89) print "A tuple" print myTuple print print "The data at index 2" print myTuple[2] print print "Appending to a tuple" myTuple.append(35)
276a52e6422899065bb0fe5a01c59753cb9961c4
soshi-matsuo/udemy
/python-beginToApply/roboter/Robot.py
2,704
3.78125
4
import csv import os from termcolor import colored class Robot: def __init__(self): self.name = 'Roboter' # init csv file if os.path.exists('roboter/ranking.csv') is False: with open('roboter/ranking.csv', 'w') as csv_file: field_names = ['Name', 'Votes'] ...
52a19685b1e1d4e4275b888c1b40c87c485363dd
soshi-matsuo/udemy
/python-beginToApply/algorithm/binary_search.py
620
3.78125
4
import random def binary_search(data, obj): head = 0 tail = len(data) center = (head + tail) // 2 while head <= tail: if obj == data[center]: print('リストの', center, '番目', sep='') return elif obj > data[center]: head = center + 1 center = (h...
2755771cc846cb1070d29e597d783c354d194ce6
coilia/sage_polynomial
/polynomial.py
5,254
3.640625
4
from sage.all import * import os.path def random_coefficients(n, min=-100, max=100): """ random_coefficients(n, min=-100, max=100) n - positive integer min - integer max - integer returns [i_1, i_2, ..., i_n] where i_j are random integers between min and max """ return [randint(min,max) f...
0035a35a8f5cd7de1b74e978c7934b2c0ac4fa76
kangli-bionic/MIT-6.00.2x
/Unit 2/Lecture 4/example.py
2,116
3.890625
4
"""PyLab example.""" import pylab as plt def retire(monthly, rate, terms): """Compound interest.""" savings = [0] base = [0] m_rate = rate/12 for i in range(terms): base += [i] savings += [savings[-1] * (1 + m_rate) + monthly] return base, savings def display_retire_with_mon...
8f899440cb3c8f67e3bcdf4ceb2f4440044c312e
abdessamad-elamrani/CSES-Algorithms
/Weird-Algorithm.py
393
3.828125
4
# my python solution to https://cses.fi/problemset/task/1068/ import sys n = int(sys.stdin.readline()) # read just one line print(str(int(n))+' ',end='') # transform integer to String to print it and concatenate to a space, the 'end='' part is to not return to line while n > 1: if(n%2==0): n=n/2 print(...
08b7bb0b7bc82acab93151309ce8bc30f02ead94
mybirth0407/elice2016
/conditional_statements.py
314
3.75
4
def exercise(score): # 1 evaluation = "" if score < 50: evaluation = "Below average" elif 50 <= score and score < 70: evaluation = "Average" elif 70 <= score and score < 90: evaluation = "Above average" elif score >= 90: evaluation = "Excellent" return evaluation print(exercise(80))
1645a7abd81f241656fb3c28ef8bacb278dc4c6b
mybirth0407/elice2016
/list.py
443
3.71875
4
def exercise(my_language): # 1 programming_languages = ["C#", "Javascript", "Java", "Python", "Matlab", 'R'] # 2 del programming_languages[programming_languages.index("Javascript")] # 3 programming_languages.append("C++") is_my_language = False if my_lan...