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
414e495900fabcad180e54d88c31c92abfb0c7fd
mahidhar93988/python-basics-nd-self
/growth.py
265
3.546875
4
n = int(input()) list = [] for i in range(n): element = int(input()) list.append(element) add = 0 for i in range(0, len(list)): add = add + list[i] ave = add / n if ave > 100: print("Excellent!") else: print("Not Excellent!")
73521ec81d51bc78eeda2c636402f9be0e796776
mahidhar93988/python-basics-nd-self
/difference_sum_even_odd_index.py
539
4.125
4
# difference_sum_even_odd_index # You should name your function as difference_sum_even_odd_index # It should take a list of integers # Return an integer def difference_sum_even_odd_index(arr): e = 0 o = 0 for i in range(len(arr)): if i % 2 == 0: e += arr[i] else: ...
2479e27d0408a075e71e9288676ca008737a5156
mahidhar93988/python-basics-nd-self
/natural_numbers_sum.py
163
3.703125
4
# natutral numbers sum n = int(input()) #5 output = 0 for i in range (1,n+1): output = output + i #1 #3 #6 #10 #15 # print(i,output) print(output)
79417b11af9bdfbdb64d3e6858b254fea41d854f
mahidhar93988/python-basics-nd-self
/input_reader.py
723
3.765625
4
# input_reader class input_reader: def __init__(self): self.data = [] def read_strings(self, N): while(N > 0): self.data.append(input()) N -= 1 def read_integers(self, N): while(N > 0): self.data.append(int(input())) N -=...
b26ec291617997e5f7e51165a0e364be58e15861
mahidhar93988/python-basics-nd-self
/Life_the_Universe_and_Everything.py
118
3.53125
4
# Life, the Universe, and Everything A = int(input()) while A != 42: print(A) A = int(input()) # nd
4060453ccecbf0e81d6b2771f6ac553613b56186
mahidhar93988/python-basics-nd-self
/cheking_prime_numbers.py
379
3.71875
4
# finding prime number N = int(input()) i = 0 while (i < N): n = int(input()) if (n == 1): print("NO") i += 1 # i = i+1 continue j = 2 ind = 0 while(j <= n-1): if (n % j == 0): ind = 1 j += 1 if(ind == 0): print("Yes"...
c3e5c1627f1c367a1849a52d7a4cb2fc9597471d
gabymy/siguetucamino
/Eligetucamino.py
1,988
3.90625
4
import random import time def mostrarIntroduccion(): print('Acabas de despertar, en una tierra desconocida. No salis de tu asombro') time.sleep(2) print('ya que te habias dormido placidamente en tu cama.') time.sleep(2) print('Miras alrededor y descubres, dos cuevas:') time.sleep(2) ...
1ddc3ca40dcd813f75cb572c00bccfb3c2f521bb
Sahandfer/PyBlockChain
/Server/BlockChain.py
2,711
3.59375
4
import time import json import Block from hashlib import sha256 class BlockChain: difficulty = 2 # Difficulty for proof of work def __init__(self): """ Constructor for the `Blockchain` class. """ self.chain = [] # The blockchain self.pending_transactions = [] # Yet...
2c0d032eb368350ce81868ba4fc53b8d66df2244
SharifahS/Python-Challenge
/PyBank/main.py
3,367
3.984375
4
import os import csv filepath = os.path.join('Resources', 'budget_data.csv') # Identify my tile with spacing print(''' Financial Analysis''') print('''...................................... ''') # open and read csv file, then create a variable for the number of rows within the file # number of rows within the file h...
777fd7f72d1643d21f6ae9b41c9853b97ab5f6a0
tsubauaaa/CheetahBookPython
/Capter3/3-1.py
188
3.65625
4
def get_max_num(array): ret = array[0] for i in range(1, len(array)): if array[i] > ret: ret = array[i] return ret # print(get_max_num([1, 2, 3, 4, 5]))
0a39b48e8da9d6507d94638673025d2b8fba7c85
naveenshandilya30/Decision-Control-System
/Assignment_5.py
1,241
3.890625
4
#Question_1 year=int(input("enter year")) if year%4==0: print("The year is a leap year") else: print("The year is not a leap year") #Question_2 length= int(input("Enter length:")) breadth= int(input("Enter breadth:")) if length==breadth: print("dimensions are square") else: print("dimensions are re...
2cc1b81668dd9ab6c64b69f42acbacac27df274f
mlucas-NU/advent_of_code
/2020/day_1/main.py
1,193
3.65625
4
import argparse import logging # Helper functions def part2(expenses): for exp1 in expenses: for exp2 in expenses: for exp3 in expenses: if len(set([exp1, exp2, exp3])) < 3: continue if exp1 + exp2 + exp3 == 2020: return...
092e6138bec899df4f7ba6a4c68ee9460e0a4065
WilliamCawley/prime-test
/PrimeTest.py
3,191
4.375
4
#!/usr/bin/env python """PrimeTest.py - Processes a provided list of words and then searches this for an anagram provided by the user""" DATA = """\ starlet startle reduces rescued realist recused saltier retails secured """ # The below constant contains the letters of the English language sorted by fr...
4555566a61490ad7e77ec3c83845e765411e6bb7
twodog1953/GUI-Password-Recorder
/main.py
4,095
3.625
4
from tkinter.messagebox import showinfo from tkinter import * import sqlite3 from os import path from datetime import datetime root = Tk() root.title('Password Logger') root.geometry("450x600") # db table if path.exists('password.db') == False: conn = sqlite3.connect('password.db') c = conn.curso...
e6ecde6b0fc4b8de945ee3b2c8b8de9e0e40fdab
yshutaro/study_leetcod
/1252/solution.py
826
3.515625
4
class Solution: def oddCells(self, n: int, m: int, indices: [[int]]) -> int: result = 0 matrix = [[0 for i in range(n)] for j in range(m)] #print("matrix step0:", matrix) for index in indices: row = index[0] col = index[1] #print(row) #print(col) ...
9ae94441013e93535eabead119941d52bd727998
harshitashetty1605/Ml
/social.py
1,449
3.703125
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd data3=pd.read_csv('Social_Network_Ads.csv') x=data3.iloc[:,1:4].values y=data3.iloc[:,4].values #plt.scatter(x,y) '''Produces a graph with two separated classes use sigmoid function ie 1/(1-e**(-y))) y=B0+B1x standard scaling=(x-xmean)/Standard d...
6fa9ed9a92dbd611cd7a8b6645d823e74a7bdce3
presstwice/Python-
/data_camp/lambda_function.py
217
3.828125
4
read_books = {'week 1': 1, 'week 2': 1, 'week 3': 0} for item in read_books: if 'week 3' in read_books == 0: print("You read a book this week") break else: print("You suck")
e140bd8915d97b4402d63d2572c056e61a0d9e5a
presstwice/Python-
/data_camp/simple_pendulum.py
487
4.1875
4
# Initialize offset offset = -6 # Code the while loop while offset != 0 :b # The goal is to get offset to always equal 0 print("correcting...") # Prints correcting to clearly state the loop point if offset > 0: # You start the if statement by checking if the offset is positive offset = offset - 1 # If...
eb197ecf36d5ac1020e92ef532d2e6cec5bab744
presstwice/Python-
/pytut1/functions.py
421
3.765625
4
def sayhi(name, age): print("Hello " + name + ", you are " + age) sayhi("Mike", "30") sayhi("Steve", "70") #functions let you break up your code #functions should be all lowercase #functions with more than two words should use _ #A paramter is a piece of information you give to the function #sayhi(name) with ...
2a0e052f6f570ab034285e50daf699aba8428818
jsimmond/App-Jing
/backend/Placement/utils.py
1,345
3.5
4
import copy def sort_and_place(items, *, key, start=1, allow_ties=True): def get_key(item): key_list = key if (isinstance(key, list) or isinstance(key, tuple)) else [key] values = [] for k in key_list: if isinstance(k, str): values.append(item[k] if k[0] != "-" ...
50823aaa002f670682669a04b4337d9f508eed24
grem848/Assignment3Python
/module.py
3,932
3.5625
4
import numpy as np import country_codes_english import country_codes # list of country codes of native English-speaking countries country_codes_english = country_codes_english.country_codes_english english_ccs = list(country_codes_english.keys()) # list of country codes of native English-speaking countries country_co...
a7b2b6aa0cf87e8c8e97061350c14730f4d44f32
Thehunk1206/Sorting-alogorithm-comparison
/bubbleSort.py
426
3.859375
4
from random import randrange from time import time NUMBER_OF_ELEMENTS = 10000 a = [randrange(1,100) for i in range(NUMBER_OF_ELEMENTS)] def bubbleSort(arr): n = len(arr) for i in range(n): for j in range(0, n-i-1): if arr[j] > arr[j+1] : arr[j], arr[j+1] = arr[j+1], ar...
9837dff732929ed5f6533c5265e17788d975f76f
scylla/masters_thesis
/code/seq2seq_graph/src/downhill-0.2.2/downhill/dataset.py
7,344
3.71875
4
# -*- coding: utf-8 -*- r'''This module contains a class for handling batched datasets. In many optimization tasks, parameters must be updated by optimizing them with respect to estimates of a loss function. The loss function for many problems is estimated using a set of data that we have measured. ''' import climat...
dce2e480dec644bec0457b747991857896edd9f8
sebas-mora28/Algoritmos-Estructuras-Datos-II
/Diseño-Algoritmos/Programación-Dinámica/LCS_benchmark.py
3,338
3.5
4
from time import time """ SUBSTRING MAS LARGO Divide y Conquista """ def LCS_recursivo(string1, string2): return LCS_recursivo_aux(string1, string2, len(string1), len(string2)) def LCS_recursivo_aux(string1, string2, size1, size2): if(size1 == 0 or size2 == 0): return 0 if(string1[size1-1] ...
f86dad4088932947d48f2dfa42aa21df0437c208
aaptedata/Sorting
/src/iterative_sorting/iterative_sorting.py
752
4.03125
4
# TO-DO: Complete the selection_sort() function below def selection_sort(arr): # loop through n-1 elements for i in range(0, len(arr)): smallest_index = i for j in range(i+1, len(arr)): if arr[smallest_index] > arr[j]: smallest_index = j arr[i], arr[smallest_...
fc146ca2a310461c17c85ffd2a3183e84562a9f0
comiee/little_games
/_2048.py
3,052
3.5
4
from tkinter import* import random root=Tk() root.title('2048') root.resizable(0,0) root.geometry('400x400') size=4#边长 def cmplist(a,b): #二维列表比较函数,完全相同返回0 for c,d in zip(a,b): for e,f in zip(c,d): if e!=f: return 1 return 0 class block: def __init__(self):...
09d7398dcfb17295e44aba18d4a97c15b14634f8
YUMI0917/karen_teoria2
/ordenar_listas.py
3,138
3.90625
4
#!/usr/bin/python3 from time import * from random import * import random import string def creaListaObjetos(cantidad): elementos = [] lista_enteros=[] lista_flotantes=[] lista_cadenas=[] listaOrdenada = [] # Llenamos la lista con diferentes tipos while len(elementos) != cantidad: ...
46d30a2f92ee50af1d92afdd36b673bd5a4c0847
xinshuoyang/algorithm
/src/845_GreatestCommonDivisor/solution.py
748
3.859375
4
#!/usr/bin/python ################################################## # NAME : solution.py # # DESC : # # AUTH : Xinshuo Yang # # DATE : 20180324 # ################################################## class Solution: """ @param a: the given number @param b: another number @return: the greatest common div...
5c96149135b418e0eb26552b131ef65c28423af8
xinshuoyang/algorithm
/src/224_ImplementThreeStacksbySingleArray/solution.py
1,861
4
4
#!/usr/bin/python ################################################################################ # NAME : solution.py # # DESC : # # AUTH : Xinshuo Yang # # DATE : 20181230 # ################################################################################ class ThreeStacks: """ @param: size: An integer ...
5bcac62a7a4f63b412a53740185bbdd89b9beb1b
xinshuoyang/algorithm
/src/474_ LowestCommonAncestorII/solution.py
1,510
4.0625
4
""" Definition of ParentTreeNode: """ class ParentTreeNode: def __init__(self, val): self.val = val self.parent, self.left, self.right = None, None, None class Solution: """ @param: root: The root of the tree @param: A: node in the tree @param: B: node in the tree @return: The ...
727a1ed9e2b089ae4eaf4ed2b563958f35a534b2
xinshuoyang/algorithm
/src/8_RotateString/solution.py
747
3.859375
4
#!/usr/bin/python ################################################################################ # NAME : solution.py # # DESC : # # AUTH : Xinshuo Yang # # DATE : 20180303 # ################################################################################ class Solution: """ @param str: An array of char ...
903c731285d58cda9c6b802ecaeacb0658e76831
xinshuoyang/algorithm
/src/452_RemoveLinkedListElements/solution.py
1,085
3.78125
4
#!/usr/bin/python ################################################## # NAME : solution.py # # DESC : # # AUTH : Xinshuo Yang # # DATE : 20180328 # ################################################## """ Definition for singly-linked list. """ class ListNode: def __init__(self, x): self.val = x self...
395901ee3f32955fe43cdde579de2a5bfaf82710
xinshuoyang/algorithm
/src/617_MaximumAverageSubarrayII/solution.py
1,414
3.640625
4
#!/usr/bin/python ################################################################################ # NAME : solution.py # # DESC : # # AUTH : Xinshuo Yang # # DATE : 20180327 # ################################################################################ class Solution: """ @param: nums: an array with pos...
6af40ba17bdcc27fed7c81ef5e33d56bf73978e0
xinshuoyang/algorithm
/src/994_ContiguousArray/solution.py
1,095
3.640625
4
#!/usr/bin/python ################################################## # NAME : solution.py # # DESC : # # AUTH : Xinshuo Yang # # DATE : 20190101 # ################################################## class Solution: """ @param nums: a binary array @return: the maximum length of a contiguous subarray ""...
867fea3d0cc9c8115035a37808c6d9539e2ea46c
xinshuoyang/algorithm
/src/888_ValidWordSquare/solution.py
909
3.78125
4
#!/usr/bin/python ################################################## # NAME : solution.py # # DESC : # # AUTH : Xinshuo Yang # # DATE : 20180328 # ################################################## class Solution: """ @param words: a list of string @return: a boolean """ def validWordSquare(self,...
52a37613b6dc3222720076be6c2038a93eb71133
xinshuoyang/algorithm
/src/138_SubarraySum/solution.py
897
3.734375
4
#!/usr/bin/python ################################################################################ # NAME : solution.py # # DESC : # # AUTH : Xinshuo Yang # # DATE : 20171212 # ################################################################################ class Solution: """ @param: nums: A list of integer...
8432807124a22d166a2ebf31ee083113a35a0b36
xinshuoyang/algorithm
/src/807_Palindrome_Number_II/solution.py
956
3.765625
4
#!/usr/bin/python ################################################## # NAME : solution.py # # DESC : # # AUTH : Xinshuo Yang # # DATE : 20180217 # ################################################## import math class Solution: """ @param n: non-negative integer n. @return: return whether a binary represen...
5bb93386281cf3ef51629fb3a47455393b73b98d
xinshuoyang/algorithm
/src/1482_MinimumSumPath/solution.py
1,163
3.828125
4
#!/usr/bin/python ################################################################################ # NAME : solution.py # # DESC : # # AUTH : Xinshuo Yang # # DATE : 20181228 # ################################################################################ """ Definition of TreeNode: """ class TreeNode: def __i...
4c28047a199b9e6d7ac21b0231a0530a4bd50981
Nagumkc/Python-Programing
/Tutorial 4/Source/lab 4/sort.py
77
3.6875
4
str=input("Enter string") li=str.split(",") sr=sorted(li) print(",".join(sr))
747c3e0a5ecf8966b118b61ec8edf3afaba4160e
Nagumkc/Python-Programing
/Tutorial 7/Source/lab7/in-class.py
1,675
3.515625
4
from nltk.corpus import wordnet as w from nltk.tokenize import word_tokenize,sent_tokenize,wordpunct_tokenize from nltk.stem import LancasterStemmer,WordNetLemmatizer from nltk import pos_tag,ne_chunk,ngrams from collections import Counter s="Sport (British English) or sports includes all forms of competitive physical ...
c1c58fb077cd4fbc9c9f60d3424cba85e2a1193a
Lilas-w/python-for-everybody
/cur.py
800
3.546875
4
import json import sqlite3 conn = sqlite3.connect('rosterdb.sqlite') cur = conn.cursor() # Do some setup cur.executescript(''' DROP TABLE IF EXISTS User CREATE TABLE User ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, name TEXT UNIQUE, count INTEGER ) ''') fname = input('Enter file name:...
b44741056009f67ef7c137ad7f3733f9c97046a1
jhall-ambient/green_button
/green_button.py
5,235
3.515625
4
import sys, datetime from bs4 import BeautifulSoup class Reading(object): """ Reading object, contains cost, value and date""" def __init__(self, date_string, cost, value): """ Date String should be passed as POSIX - Cost is in thousands of a cent 2691 = .02691 cents - Value is Energ...
2bbc3f90a59cc56dfea769b29e32c3e3e95341e4
saad2999/learn-first
/Login.py
829
3.609375
4
# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ def signup(): n=input("Enter the username:") m=input("Enter the password:") d[n]=m def login(): i=1 while(i<=3): n=input("Enter the username:") m=input("Enter the password:") s=d[n] ...
1c8af0c8f4739993ef63328d682bf07212004ca6
webclinic017/Predicting-Equity-Prices
/profit_ratios.py
817
3.546875
4
import pandas as pd #Profitability ratios #Importing the csv file df = pd.read_csv (r'sample.csv') #create empty dataframe df1 = pd.DataFrame() #Calculate each ratio and append to the respective column in the dataframe df1['grossMargin'] = df['grossProfit']/df['totalRevenue'] df1['operProfitMargin'] = df['ebitda']/d...
d22f5a9a6851525504cc7e4f1952a2bbb8ab27ae
BalaRajendran/guvi
/large.py
336
4.21875
4
print ("Find the largest number amoung three numbers"); num=list() arry=int(3); a=1; for i in range(int(arry)): print ('Num :',a); a+=1; n=input(); num.append(int(n)) if (num[0]>num[1] and num[0]>num[2]): print (num[0]); elif (num[1]>num[0] and num[1]>num[2]): print (num[1]); else: prin...
adbe298bfa10285cc907af9c874bc0251af17b3e
BalaRajendran/guvi
/permutation.py
250
3.890625
4
from itertools import permutations def allPermutations(str): permList = permutations(str) for perm in list(permList): print (''.join(perm)) if __name__ == "__main__": #str = '123' str=str(input()); allPermutations(str)
38c0367fc0c668633ee2dc82c290ea909628fc1a
BalaRajendran/guvi
/range.py
282
3.890625
4
num=list() n=int(input("Enter the number array :")); n1=int(input("Enter the number to count the array: ")); print("Enter the element"); a=int(0); for i in range (n): k=input(); num.append(k); for j in range (n1): a+=int(num[j]); print(a); print (a); #print (num);
2df8a0982b5488d09e4fa60a77ad56a1aed71a01
Sandhya-02/programming
/0 Python old/017_tuples.py
169
3.8125
4
ttuple = ("jack", "manasa", "tanusree") print(ttuple) list = ["jack", "jack"] print(list) a = [10 ,"sandhya" ,30] b = (10 ,"sandhya" ,30) #*angular brackets print(a,b)
d2ac60b5656a50c69828f4e4987fc0f2710879cc
Sandhya-02/programming
/0 Python old/09_change_list.py
2,106
3.796875
4
# dreamers = ["manasa","tanusree","karishma "] # dreamers[2] = "sandhya mama" # print(dreamers) # earth = ["sun","moon","sky","jack","sandhya"] # earth[3:5] = ["manasa","tanusree"] # print(earth) # earth = ["sun","moon","sky","jack","sandhya"] # earth[1:3] = ["manasa","abc","edf"] # print(earth) # earth = ["sun",...
f1e7ec01dfc215f7d36781bfb30c329b757c080a
Sandhya-02/programming
/0 Python old/07_revision.py
266
3.5
4
a = "= igijrdhg7rtyrgtryt tub8yti5yuh4y4utw7 rjy8e t" b = 3 c = 3j d = 3.55 e = 50 print(type(b)) print(type(c)) print(type(d)) print(type(a)) #! int-float float -string string to int print(str("idoit fellow")) print(str(e)) print(float(b)) print(type(float(b)))
349ee9f5d34c45151c671f7a1545eaac7a49d02c
Sandhya-02/programming
/0 Python old/05_lit_to_ml.py
559
3.859375
4
#! liters to ml #! 1 lit = 1000ml # lit=2 # mil = lit * 1000 # print("mil =" ,mil) #! one kid came to shop, shop guy can convert ml to lit and lit to ml #! shop guy asks the kid "denloki convert cheyali" #! kid gives him input and gets the output name= input("em convert cheyali") if name =="ml": value= float(inp...
ca0409110b5846759427529b9a487ea95a84dadc
Sandhya-02/programming
/0 Python old/09_sandeep_milk_using_list.py
504
4.15625
4
""" mummy and sandeep went for shopping sandeep trolley lo [eggs , meat,small milk packet, bread,jam,] teskocchadu mummy said get big milk packet sandeep small milk packet ni teesesi big milk packet bag lo pettukunnadu """ list = ["eggs","meat","small milk packet","bread","jam"] print(list) if "small milk packet" in...
ac080a7e3ae251ae8de33e0c59b990164f54c23d
Sandhya-02/programming
/0 Python old/016_function.py
735
3.875
4
first = int(input("enter the number ")) second = int(input("enter the number ")) select =int(input("press 1 to add\n press 2 to sub\n press 3 to mul \n press 4 to div\n ")) print ("what do u want to do\n") if (select == 1): sum = first+second print(first,second," = ",sum) if (select == 2): sub = first...
6c52df82ce8e9d6f854ca15cb28a7f570729bfcd
Sandhya-02/programming
/python/mid libs.py
188
3.953125
4
""" enter a noun enter another noun enter a verb print noun verb noun """ s1 = input("enter a noun ") s2 = input("enter a noun ") s3 = input("enter a verb ") print(s1 ,"", s3 ,"", s2)
34e5f127fb80d464c06a9ba56636866ade70fd1d
Sandhya-02/programming
/0 Python old/05_if_else.py
99
3.953125
4
a = "male" b = "Male" if(a==b): print("both are equal ") else: print("both are not equal")
6dc3495707c6c437ef7a215abafbb18f58a58816
gplambeck/unit_1
/module03/plambeck_password_challenge.py
1,314
3.953125
4
# Computer guesses what the password is and displays the number of guesses. import random, time # Set the execution limit to 60 seconds t_end = time.time() + 60 characters = ["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"] ...
f81b7e6712e68a27539f2f7667e23b97921aad5e
gplambeck/unit_1
/module01/plambeck_hello_turtle.py
1,667
3.96875
4
#Draws a picture of the olympic rings logo import turtle my_turtle = turtle.Turtle() #creates a pen my_turtle.width(10) #sets the pen width to 10 #Black ring my_turtle.circle(100) #draws a black circle of radius 100 #Blue ring my_turtle.up() #lifts up the pen my_turtle.bac...
13b1add4604bf1e60ba9d5a6061f00718466e7a1
frarue/mviri_lib
/mviri/mviri_tools/tools_plotting.py
546
3.8125
4
""" this file contains functions for plotting """ import matplotlib.pyplot as plt import numpy as np def printimage(pix,tit,maxi=255,save=0): """ Simple plotting of an MVIRI image Inputs: pix array with pixel values tit title/name of the image """ pix=np.array(pix) pix[pix>maxi]=ma...
e1837b3b485e3bb608e00a55d1655fb5dfab16d7
Marina-lyy/basics
/8-爬虫/v23.py
753
3.5
4
import requests from urllib import parse import json baseurl = "http://fanyi.baidu.com/sug" # 存放用来模拟form的数据一定是dict格式 data = { # girl 是翻译输入的英文内容,应该是由用户输入,此处使用编码 'kw': 'girl' } # 我们需要构造一个请求头,请求头部应该至少包含传入的数据的长度 # request要求传入的请求头是一个dict格式 headers ={ # 因为使用post,至少应该包含content-length 字段 'Content-Length': s...
cbc817342037d50747ab9fcf58120d33e2762719
jmckinstry/doodles
/fizzbuzz/second.py
729
3.734375
4
# -*- coding: utf-8 -*- """ Created on Thu Mar 28 11:42:25 2019 @author: Asier """ # Pass 2: Extended FizzBuzz. Start and stop with specified ints, allows for modifiable divisors and output words # Finished in 9:07.92 def fizzbuzz( start = 1, stop = 100, words = [(3, 'Fizz'), (5, 'Buzz')] ...
dd3cc65e39d067a3d516d4ca7d20ce10c3ba3fdd
UWPCE-PythonCert-ClassRepos/220-Advanced-Summer-2019
/students/FredBallyns/lesson09/assignment/src/jpgdiscover.py
1,648
3.625
4
""" a png discovery program in Python, using recursion, that works from a parent directory called images provided on the command line. The program will take the parent directory as input. As output, it will return a list of lists structured like this: [“full/path/to/files”, [“file1.png”, “file2.png”,…], “another/path”,...
28e38f1d14d545615c1d65f0061811e8dc620653
UWPCE-PythonCert-ClassRepos/220-Advanced-Summer-2019
/students/PeterB/Lesson01/Assignment/inventory_management/furniture_class.py
741
3.546875
4
from inventory_management.inventory_class import Inventory class Furniture(Inventory): """ This class handles the Furniture Object """ def __init__(self, product_code, description, market_price, rental_price, material, style): # Creates common instance variables from the parent class...
d1919104c7356cc4ca480107a80e97d6216416b7
UWPCE-PythonCert-ClassRepos/220-Advanced-Summer-2019
/students/Sally_Shen/lesson09/assignment/src/database.py
799
3.6875
4
from pymongo import MongoClient class MongoDBConnection: def __init__(self, host="localhost", port="27017"): self.host = f"mongodb://{host}:{port}" self.connection = None def __enter__(self): self.connection = MongoClient(self.host) return self def __exit__(self, a, b, c):...
8db44ab47ac883b22b2ffe5f3d7f6518c741984f
UWPCE-PythonCert-ClassRepos/220-Advanced-Summer-2019
/students/rimlee_talukdar/lesson09/assignment/src/jpgdiscover.py
680
3.53125
4
import os def list_jpg_files(folder, file_extension=".png", dirs=[], result=[]): dirs.append(folder) print(f"Checking folder: {folder}") current_dir = "/".join(dirs) print(f"current_dir: {current_dir}") for item in os.listdir(current_dir): print(f"Checking directory: {item}") if os...
7defa6a493af5b4a124e65effb0febd9ac569a80
UWPCE-PythonCert-ClassRepos/220-Advanced-Summer-2019
/students/ArchWu/lesson01/assignment/test_unit.py
6,619
3.875
4
""" Unit tests for inventory management """ from unittest import TestCase, mock import unittest from inventory_management.inventory_class import Inventory from inventory_management.furniture_class import Furniture from inventory_management.electric_appliances_class import ElectricAppliances from inventory_management i...
2e4f2256c5ab9ab4268579e6b162e1317e6f9f16
UWPCE-PythonCert-ClassRepos/220-Advanced-Summer-2019
/students/rimlee_talukdar/lesson02/assignment/src/charges_calc.py
5,961
3.875
4
""" Returns total price paid for individual rentals """ import argparse import json import datetime import math import logging def parse_cmd_arguments(): """ creates an argument parser for the program """ parser = argparse.ArgumentParser(description='Process some integers.') parser.add_argument('-...
5e0c461e5b4d1f9e6c328dcc78d88b5c8a08d410
UWPCE-PythonCert-ClassRepos/220-Advanced-Summer-2019
/students/AndrewMiotke/lesson04/class_work/generators.py
466
4.21875
4
""" Generators are iterators that returns a value """ def y_range(start, stop, step=1): """ Create a generator using yield """ i = start while i < stop: """ yield, like next(), allows you to increment your flow control e.g. inside a loop """ yield i i += step...
deb811d7c1a936a03ddc2767e5456dcc2316a1f6
4papiez/2017win_gr2_kol2
/kol2.py
4,093
3.875
4
# Class diary # # Create program for handling lesson scores. # Use python to handle student (highscool) class scores, and attendance. # Make it possible to: # - Get students total average score (average across classes) # - get students average score in class # - hold students name and surname # - Count total attendan...
bb0828b74f6eb99c20ffc39e3cae82f0816ada65
droidy12527/AlgorithmsInPythonandCpp
/anargrams.py
409
4.125
4
def findAnargrams(arr): answers = [] m = {} for elements in arr: make = ''.join(sorted(elements)) if make not in m: m[make] = [] m[make].append(elements) for hello in m.values(): answers.append(hello) return answers arr = [ "eat", "tea", "tan", "ate", ...
37d5f6d5ca327f97571c1313d194ae6b15492b66
droidy12527/AlgorithmsInPythonandCpp
/longestsubstringwithnorepeatingchars.py
610
4.03125
4
#Function to Find the longest Substring which has non repeating characters def findLongestSub(s): left = 0 right = 0 m = {} length = len(s) answer = 0 while left < length and right < length: element = s[right] if element in m: left = max(left, m[element]) m[e...
3e41dcdae48b284a2f4dc23b62a8155cce617952
NTR0314/advent_of_code
/2019/day1/fuel.py
424
3.546875
4
f = open("fuel_input.txt", "r") def fuel_mass(x): return (int(int(x) / 3) - 2) def mass_fuel_rec(mass): result = fuel_mass(mass) if fuel_mass(result) > 0: result += mass_fuel_rec(result) return result # A1 if f.mode == 'r': f1 = f.readlines() fuel_a1 = 0 fuel_a2 = 0 for x i...
63d5b174ae1125ddefd58c403cfcb4a2ca1d0e1e
koalaah/aiforgames
/Spike13/Action.py
2,257
3.578125
4
class Action: def __init__(self, description, effects,cost): self.effects = effects self.description = description self.cost = cost # def PerformAction(self): # for effect in self.__effects: # effect["goal"].UpdateGoalInsistance(effect["insistance_change"]) # ...
e0792571ee2c9634790529ac5b113627a0a8286e
vineelBoddula/ASCII-Art-Generation
/createAsciiArt.py
3,730
3.828125
4
#Citation 1: Collier, R. "Lectures Notes for COMP1405B – Introduction to Computer Science I" [PDF document]. #Retrieved from cuLearn: https://www.carleton.ca/culearn/ (Fall 2015) from SimpleGraphics import* #function to get file name def file(convChars): fileName = str(input("What is the file name: ")) r...
486196aad0561415533d9127f984fc76966b4b74
misaelHS/curso
/Paquetes/Funciones.py
4,980
3.953125
4
import re # Se importa la libreria para las expresiones regulares #---------------------------------------- TAREA1: FUNCION DE PIEDRA PAPEL Y TIJERAS ------------------------------------------------ def funcion(seleccion, maquina_String, opciones_String): # Se define la funcion que valida los valores a...
8633a4cf6b46857954151576703598bbaef77b63
cmaureir/ep2021_learn_cpython_by_breaking_it
/slides/a.py
258
3.515625
4
# This is a comment #import my_module def add(a: int, b: float) -> float: return a + b def main(): msg: str = "hello world" x: int = 3 y: float = 3.14 z: float = add(x, y) print("%f" % z) if __name__ == "__main__": main()
f6656b8475c786cd235236b8a0d2a3bc8eb4e455
codewalkertse/codewalkertse.github.io
/downloads/code/multitask/threading_join_setDaemon.py
909
3.53125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # @Date : 2018-07-30 10:21:42 # @Author : Simon (simon.xie@codewalker.meg) # @Link : http://www.codewalker.me # @Version : 1.0.0 from threading import Thread from time import process_time, sleep, time_ns flag = 0 def do_something(name, sec): print(f'Do {name}...
07e96b93c8b18179b4546bee0cd967be4729f7c0
codewalkertse/codewalkertse.github.io
/downloads/code/string_bits.py
505
3.953125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # @Date : 2018-08-10 12:02:36 # @Author : Simon (simon.xie@codewalker.meg) # @Link : http://www.codewalker.me # @Version : 1.0.0 def string_bits(str): return ''.join([str[x] for x in range(len(str)) if x % 2 == 0]) # Same as # new_str = [] # for x ...
c61d3fc1c7a42f6e8bc8240a81ac69aaff41015c
glebite/uatu
/src/config_organizer.py
977
3.515625
4
""" config_organizer - more than just a parser but builds what is needed """ import os import configparser class ConfigOrganizer: """ ConfigOrganizer - configuration file class and other data """ def __init__(self, config_file=None): """ initialize file and configuration data "...
6ef9f37035dc2b361fc8fdc4cf6b39377b633a54
syedshowmic/Algorithm1_UCSanDiegoX
/1 Algorithm Design and Techniques/Week 2/2.2/St_fibonacci_lastDigit.py
1,108
3.890625
4
# Uses python3 def calc_fib(n): fibonacci_list = [0, 1] for i in range(2, n + 1): fibonacci_list.append(fibonacci_list[-1] + fibonacci_list[-2]) return fibonacci_list[-1] n = int(input()) print(str(calc_fib(n))[-1]) # ==========================================================================...
345858db7aa127d23ea355b58f042f7c9f643db9
muditabysani/BFS-1
/Problem2.py
1,426
3.6875
4
from collections import deque class Solution: def canFinish(self, numCourses: int, prerequisites: List[List[int]]) -> bool: # Time Complexity : O(mn) where m is the number of prerequisites and n is the number of courses # Because for every course we are going through the entire prerequisites array ...
c23da6b7dd6d3a621c413ea3304ec092a062781b
yiguid/LeetCodePractise
/todo/692.py
568
3.59375
4
import collections import heapq class Solution: def topKFrequent(self, words, k): """ :type words: List[str] :type k: int :rtype: List[str] """ count = collections.Counter(words) heap = [(-freq, word) for word, freq in count.items()] heapq.heapify(hea...
9f4c997fda005a87349ada251909d884b4dbcf19
yiguid/LeetCodePractise
/todo/054.py
1,206
3.546875
4
class Solution: def spiralOrder(self, matrix): """ :type matrix: List[List[int]] :rtype: List[int] """ m = len(matrix) if m == 0: return [] n = len(matrix[0]) if n == 0: return [] top, right, bottom, left = 0, n, m, 0 ...
4a898a315052ec783f8472c858c7b4d8dd38063e
yiguid/LeetCodePractise
/finished/heap.py
2,456
3.796875
4
class Heap(object): def __init__(self, data): self.items = data for index in range(len(self.items) // 2, -1, -1): self.percolate_down(index) def percolate_down(self,index): while index * 2 + 1 < len(self.items): left = index * 2 + 1 if index * 2 + 2 ...
2e3ae3a6fdab94ec835524d29c38b67ef06112b8
yiguid/LeetCodePractise
/test.py
303
3.59375
4
class Solution: def swap(self, a, b): a, b = b, a def swap_array(self, nums): nums[0], nums[1] = nums[1], nums[0] self.swap(nums[0], nums[1]) print(nums) s = Solution() a = 10 b = 20 s.swap(a, b) print(a) print(b) nums = [1,2] s.swap_array(nums) print(nums)
e8b9a2a3c20b96f578c73aa1adfd88b7c0266ea8
yiguid/LeetCodePractise
/finished/147.py
1,184
3.921875
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def insertionSortList(self, head): """ :type head: ListNode :rtype: ListNode """ if head == None or head.next == None: re...
d1afb6bf415eac55d665ba18170bda9fb915e6d4
yiguid/LeetCodePractise
/explore/dp/337.py
1,788
3.625
4
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def rob(self, root): """ :type root: TreeNode :rtype: int """ # flag = True means rob the root, else not. r...
f64e948d5fbe7a794fe53f9e15c8e07599015989
yiguid/LeetCodePractise
/todo/069.py
844
3.578125
4
class Solution: def mySqrt(self, x): """ :type x: int :rtype: int """ # for i in range(x // 2 + 1): # if i * i == x: # return i # elif i * i > x: # return i - 1 # else: # continue # re...
9c5da5e315fd6ad6675f395e2a7ed85bf27704a7
yiguid/LeetCodePractise
/finished/047.py
738
3.5625
4
class Solution: def permuteUnique(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ def perm(i): if i == len(nums) - 1: res.append(nums[:]) return used = set() for j in range(i, len(nums)): ...
4180399a3d83722a2b81164c737d6cee0d8cbac1
njberejan/CurrencyConverter
/CurrencyConverter.py
6,223
4.125
4
#Objects in class: #be able to create Currency object with amount and currency code (ex: USD or EUR) #must equal another Currency object with the same amount and currency code (dollar == dollar) #must NOT equal another Currency object with different amount or currency code (dollar != dollar, dollar != euro) #must be ab...
aa2325ffb17b7a7fcd729ad30beffc9befd20509
takkin-takilog/python-eclipse-sample
/plot_sample_002.py
3,762
3.515625
4
# ============================================================================== # brief Plotサンプルコード 002 # # author たっきん # ============================================================================== import pandas as pd import matplotlib.pyplot as plt data = {"value": [120, 100, 90, 110, 150, ...
36379f639d9fb48ec2004fc1f62b1dedf2851059
paveldavidchik/CreatePhoneNumber
/main.py
249
3.6875
4
def create_phone_number(n): return '(' + ''.join([str(num) for num in n[:3]]) + ') ' + \ ''.join([str(num) for num in n[3:6]]) + '-' + ''.join([str(num) for num in n[6:]]) print(create_phone_number([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]))
69c47d2f47c5169e8bd31591b96b3660309f27fb
scuttlebugg/CSIT_175
/asgn4_module.py
575
3.984375
4
""" This module contains functions for completing and satisfying requirements for assignment 4 in this Python class. """ def is_field_blank(string): """ accepts a string from user input returns a boolean value to input prompt loop """ if len(string) == 0: return True el...
3af0421e3ca2b8c6a8dcee8323120e09f36f3f19
ajgrinds/adventOfCode
/2019/day01.py
355
3.515625
4
with open('input.txt', 'r') as f: masses = f.read().splitlines() fuel = list(map(lambda mass: int(mass) // 3 - 2, masses)) fuel_total = sum(fuel) # part 1 print(fuel_total) for num in fuel: added_fuel = num // 3 - 2 while added_fuel > 0: fuel_total += added_fuel added_fuel = added_fuel //...
2948bcec98743ca4b12feb2828c6337ce22673ae
ishmatov/GeekBrains-PythonBasics
/lesson03/task_03_03.py
840
4.1875
4
""" 3. Реализовать функцию my_func(), которая принимает три позиционных аргумента, и возвращает сумму наибольших двух аргументов. """ def check_num(value): try: return True, int(value) except ValueError: print("Не число. Попробуйте ещё раз") return False, -1 def sum_doble_max(num1, n...
afec691f540c742d23f04dddec8bf6a673ca7277
ishmatov/GeekBrains-PythonBasics
/lesson03/task_03_05.py
1,502
3.953125
4
""" 5. Программа запрашивает у пользователя строку чисел, разделенных пробелом. При нажатии Enter должна выводиться сумма чисел. Пользователь может продолжить ввод чисел, разделенных пробелом и снова нажать Enter. Сумма вновь введенных чисел будет добавляться к уже подсчитанной сумме. Но если вместо числа вводится спец...
6c3c8bbae37317462a202481c0474008869186c5
ishmatov/GeekBrains-PythonBasics
/lesson01/task_01_06.py
1,914
4.1875
4
""" 6. Спортсмен занимается ежедневными пробежками. В первый день его результат составил a километров. Каждый день спортсмен увеличивал результат на 10 % относительно предыдущего. Требуется определить номер дня, на который общий результат спортсмена составить не менее b километров. Программа должна принимать значения п...
ebdbdd22bbecdfe270c3dd6b852d8efd2253228b
Densatho/Python-2sem
/aula2/ex13.py
284
4.03125
4
while True: try: n = int(input("Coloque o numero de lados do poligono: ")) break except ValueError: print("Não colocou um valor valido\n") diagonais = int((n * (n - 3)) / 2) print(f'O numero de diagonais: {diagonais}')
c3c967096dba70d85268ae07ea868ac01dd74eea
Densatho/Python-2sem
/LOGIN E SENHA.py
1,189
3.765625
4
usuario = [] senha = [] while True: print('escolha uma das opções abaixo: \n ') resposta = int(input(' 1 - Login \n 2 - Resgistrar \n 3 - Sair \n')) if resposta == 2: while True: user = input("Novo usuario: ") for i in usuario[:]: if user == usu...
077f037ab225f651f5ace6e8d5e4ad10e77d5f4e
Densatho/Python-2sem
/aula3/ex18.py
281
3.90625
4
a = int(input("Insira o valor de A: ")) b = int(input("Insira o valor de B: ")) if a > b: print(f"A diferença de A para B é {a - b}") elif b > a: print(f"A diferença de B para A é {b - a}") else: print("Os dois tem o mesmo valor e a diferença é zero.")
6f35094f9c120170ce8d64e86c29b8647a7b484c
Densatho/Python-2sem
/aula2/ex3.py
654
3.828125
4
while True: try: salario_velho = float(input("Coloque o salario: ")) break except ValueError: print("Não colocou um salario valido valida\n") while True: try: percentual = float(input("Coloque o percentual: ")) break ...