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
222df9f3f68bb516fc1af21d5bcc37e746e3f07a
Anton-Augustsson/Python-tasks
/Python1/flippblipp-v3.py
639
3.59375
4
def flippblipp(n): if (n % 15 == 0): # samma som (n % 3 == 0 and n % 5 == 0): return 'flipp blipp' elif (n % 5 == 0): return 'blipp' elif (n % 3 == 0): return 'flipp' else: return str(n) n = 1 print(n) while True: n = n + 1 svar = inp...
3504855a58d5595701731641bf174b85a3c610be
Anton-Augustsson/Python-tasks
/Python2/dictionaries.py
635
3.5
4
users = {"nisse":"apa", "bosse":"ko", "stina":"t-rex"} data = {"nisse":["luva", "vante"], "bosse":["spik", "skruv", "hammare"], "stina":["tidsmaskin"]} def view(description, strings): print(description) for n in strings: print(f" {n}) {strings[n]}") print('Användare') for n in users: print(f" ...
663648ebe91b27c31ccd3eebb187ec5b196735ee
Anton-Augustsson/Python-tasks
/Python2/menu-v1.py
368
3.671875
4
options = {"a":"Add item", "l":"List items", "q":"Log out"} def view(description, strings): print(description) for n in strings: print(f" {n}) {strings[n]}") view("Du har matat in följande n strängar", options) while True: o = input("Option: ") if o in options: print(f"You selec...
a902a904c37effe53c9459ac554ca8ee39a90877
raghuprasadks/pythoncrashcourse
/1-GettingStarted.py
592
4.125
4
print("Hello.Welcome to Python") course = "Python" print(course) print(type(course)) ''' Data Types 1. String - str 2. Integer - int 3. Boolean - bool 4. Float - float 5. List 6. Tuple 7. Dictionary 8. Set ''' age = 35 print(age) print(type(age)) amount = 100.5 print(type(amount)) isActive = True print(type(isActive)) ...
cbd830da57829d584e3a2f35c56341717b29f085
keithatan/Computer-Science-In-Code
/Data Structures/Stacks-and-Queues/stack-using-queue-implementation.py
556
3.703125
4
from collections import deque class MyStack: def __init__(self): self.q = deque() def push(self, x): s = len(self.q) self.q.appendleft(x) for i in range(s): t = self.q.pop() self.q.appendleft(t) def pop(self): ...
397a258ce83d796fc8e7d3782902bfa8c86cfb3f
deepu13/LetsUpgrade-Python
/Day6.py
3,416
4.21875
4
# Question 1: # For this challenge, create a bank account class that has two attributes: # Ownername and Balance # and two methods: # Deposit and Withdraw # as an added requirement, withdrawals may not exceed the available balance # Instantiate your class, make several deposits and withdrawals, and test to make s...
bc996ac1e0fbcae54a3bd23052f62e81ba1d6cd8
sasmitoh/raspy-with-python
/raspy/percabangan.py
1,295
3.5
4
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(4,GPIO.OUT) GPIO.setup(17,GPIO.OUT) GPIO.setup(27,GPIO.OUT) jawab = "y" while (jawab == 'y'): perintah = input('masukan perintah : ') if perintah == 'ON led1': GPIO.output(4,GPIO.HIGH) status = 'led...
ac552a3f9274c873d68e1c7fac1fa00912a433d9
bylijinnan/pythonLearn
/checkio/repeatingDecimal.py
1,584
3.5625
4
def checkio(fraction): numerator, denominator = fraction if numerator < 0 or denominator < 0: raise argparse.ArgumentTypeError("invalid input, must be positive integer") q, r = divmod(numerator, denominator) quotient = [q] remainder = [r] while r: r *= 10 q, r = divmod(r...
b0f5606bd1b4569bfdf023128d3772d8db3286c4
bylijinnan/pythonLearn
/checkio/twoArraysBalance.py
1,323
3.90625
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # FileName is twoArraysBalance.py # see http://www.checkio.org/mission/task/info/batteries-loading/python-27/ def checkio(stones): ''' minimal possible weight difference between stone piles ''' length = len(stones) if length == 0: return 0 ...
3b0c60f2c019f155493b3098aab3f3acbbc18aa8
ETBGM03/pythonBasico
/conversorFuncion.py
1,398
4.09375
4
# def impimir_funcion(): # print("mensaje especial") # print("learning using functions") # impimir_funcion() # impimir_funcion() # impimir_funcion() # def conversation(mensaje): # print("hola") # print("cómo estás?") # print(mensaje) # opction = int(input("Elige un opcion (1,2,3): ")) # if opcti...
fa0b2543eaf4c0b2a1483d7795664af25951bfde
LoriSanduleac04/Instructiunea-WHILE
/problema4.py
377
3.703125
4
#Elaborați un program care va calcula suma, produsul și media aritmetică a numerelor de la 1 la n, pentru n introdus de la tastatură. n=eval(input('Introduceti un numar:')) c=0 suma=0 produsul=1 while c<n: c+=1 suma+=c produsul*=c print(f'Suma={round(suma, 2)}', f'Produsul={round(produsul, 2)}'...
c8cdfdb14db21edbe2b2d7cbc7041b5828de9753
kilometersperhour/python-datalogger
/captureGPIO.py
696
3.75
4
#!/usr/bin/python3 # Miles Martin - ECE 331 # Project 3 - Datalogger # Program: captureGPIO.py # Purpose: Collect data from GPIO-based sensor and print to screen import wiringpi PIN_TO_SENSE = 17 def gpio_edge(): if wiringpi.digitalRead(PIN_TO_SENSE): voltage = "HIGH" else: voltage = "LOW" print(f"Edge occurr...
176d5085234a5078a517c10968ecd358fb0215a4
cygwins/Leetcode
/394.Decode String/Solution.py
816
3.625
4
# Aug 18, 2017 import re class Solution(object): def decodeString(self, s): """ :type s: str :rtype: str """ if s is '': return '' parsed = re.sub(r'([^0-9\[\]]+)', r'"\1"', s) # quote all string # print(parsed, 'quote') parsed = parsed.rep...
e70eaa617a95de4a0828892bc1758ed35437a7fa
nh-server/Kurisu
/cogs/results/types.py
3,708
3.796875
4
from typing import Optional class Module: """ Describes a Module. A Module contains a dictionary of ResultCodes, and possibly a second dictionary with extra information. A module itself is basically who raised the error or returned the result. """ def __init__(self, name, data={}, summaries={}...
be5e00cd27adb53a3e3c6f873ffdfc91acf1463f
Nayan356/Python_DataStructures-Functions
/Functions/pgm9.py
676
4.3125
4
# Write a function called showNumbers that takes a parameter called limit. # It should print all the numbers between 0 and limit with a label to # identify the even and odd numbers. def showNumbers(limit): count_odd = 0 count_even = 0 for x in range(1,limit): if not x % 2...
b88b8781aff585532384232fae3028ec7ce2d82d
Nayan356/Python_DataStructures-Functions
/DataStructures_2/pgm7.py
472
4.4375
4
# # Write a program in Python to reverse a string and # # print only the vowel alphabet if exist in the string with their index. def reverse_string(str1): return ''.join(reversed(str1)) print() print(reverse_string("random")) print(reverse_string("consultadd")) print() # def vowel(text): # vowels = "aeiuoAEI...
c5a78bcae376bba759a179839b6eba037ecd6988
Nayan356/Python_DataStructures-Functions
/DataStructures/pgm7.py
232
4.375
4
# Write a program to replace the last element in a list with another list. # Sample data: [[1,3,5,7,9,10],[2,4,6,8]] # Expected output: [1,3,5,7,9,2,4,6,8] num1 = [1, 3, 5, 7, 9, 10] num2 = [2, 4, 6, 8] num1[-1:] = num2 print(num1)
84e673227276da95fa1bc8e4cf0801c5c77080a4
Nayan356/Python_DataStructures-Functions
/Functions/pgm7.py
519
4.4375
4
# Define a function that can accept two strings as input and print the string # with maximum length in console. If two strings have the same length, # then the function should print all strings line by line. def length_of_string(str1, str2): if (len(str1) == len(str2)): print(str1) #print("\n") print(str2) ...
12a117ecc823e95e01caa32c3687afc1009e38ea
sidson1/hacktoberfest2021-3
/bmiCALCULATOR.py
905
4.40625
4
# A simple BMI calculator Using python print("\n******-----MALNUTRATE!******------HEALTHY!******-------OVERWEIGHT!") print("\nWELCOME TO FULLY AUTOMATED BMI CALCULATOR ARE YOU INTRESTED TO KNOW WHO YOU ARE\n\t\t\t *press Y* ") var=input() print("----------------------------------------------------------------------...
d9d7c3dd36ee26f03dc35b22d431d94f48d9f884
parth025sharma/19pythonML
/count.py
462
3.984375
4
#!/usr/bin/python #taking input of string countdigit=0 countalpha=0 countspace=0 string = input("Enter string:") for i in range(0,len(string)): if string[i].isdigit()==1: countdigit +=1 elif string[i].isalnum()==1: countalpha +=1 elif string[i]==' ': countspace +=1 else : ...
199322eb85ff4ef049079bbad860dc91491240c1
ayryu/plasma-viper
/priorityqueue.py
1,863
3.53125
4
import heapq import os import cherrypy from vision import * class PriorityQueue: def __init__(self): self.elements = [] def empty(self): return len(self.elements) == 0 def put(self, item, priority): heapq.heappush(self.elements, (priority, item)) def get(self): ...
42899bb9e100c4f39defecba4b8a63003792a272
Oneul1213/Natural-Language-Processing-With-Python-Cookbook
/codes/Chapter1/BrownWH.py
697
3.640625
4
# 1장 말뭉치와 워드넷 - 브라운 코퍼스에서 세 가지 장르의 wh 단어 모두 세기 import nltk from nltk.corpus import brown # 말뭉치의 모든 장르 리스트 출력 print(brown.categories()) # 장르와 whwords 선택 genres = ['fiction', 'humor', 'romance'] whwords = ['what', 'which', 'how', 'why', 'when', 'where', 'who'] # FreqDist를 이용하여 장르 별 wh 단어의 빈도 수 출력 for i in range(0, len...
4f708d85e2be8dba03ad84c944f1192f7fb9c961
perryl/daftpython
/calc.py
846
4.15625
4
while True: try: x = int(raw_input('Enter a value: ')) break except: print "Integer values only, please!" continue while True: try: y = int(raw_input('Enter a second value: ')) break except: print "Integer values only, please!" continue add = x+y dif = abs(x-y) mul = x*y quo = x/y rem = x%y print 'T...
907ea535008bbe3562cc6cf71082439deef91124
dtsyi100/coffeebot
/coffeebot_v1.py
3,939
4.09375
4
#This version doesn't uses orders = [] as a parameter. #Global Variables orders = [] #Main Coffee Bot function def coffee_bot(): welcome_message() order_taking() receipt() name = input("\nCan I get your name please? ") print("\nThanks, {}! Please proceed to the pick up counter for your order!".fo...
2e659844d057c562896bce4f8f312597921e94a9
Ajsolanki/Soft-Computing
/Membership_Function_Trapezoidal.py
488
3.859375
4
import matplotlib.pyplot as p print("Enter the value of a,b,c,d") inp = input() a=int(inp.split(" ")[0]) b=int(inp.split(" ")[1]) c=int(inp.split(" ")[2]) d=int(inp.split(" ")[3]) x_c = [a,b,c,d] y_c = [0,1,1,0] p.plot(x_c,y_c) p.show() print("Enter the value of x :") x=float(input()) if(x<a or x>d): mem = 0 ...
b05c029a7fd226ab4a5724541222dcb255b1b632
Ajsolanki/Soft-Computing
/ks.py
1,175
3.5
4
import random def input_from_user(): K = int(input("Enter Size of bag in kg: ")) N = int(input("Enter total number of items:")) items = {} for i in range(N): weight = input("Enter the weight of item"+str(i+1)+":") cost = input("Enter the cost of item"+str(i+1)+":") item...
10ecae17c34e026afc68ad34310677eedb6218f2
GItaboo/Project-Manager
/완전수.py
655
3.5
4
''' 1000 이하의 완전수 -> 1부터 시작해서 1000이 되면 종료하도록 한다 자신의 약수의 합이 자신과 같아야 함 -> 약수를 구한다 + 약수들을 더한다 맞으면 yes 로 출력 -> 합이 수와 같은지 if 로 검증 '''a = int(input()) sum = 0 for x in range (1,a): if( a % x == 0 ): sum = sum + x if(sum == a): print('yes') else: print('no') a = int(input()) sum = 0 for x in range...
268a18ab740b143ec91826cc1e866d44297a59a2
karayount/study-hall
/temp_tracker.py
3,013
3.9375
4
""" You decide to test if your oddly-mathematical heating company is fulfilling its All-Time Max, Min, Mean and Mode Temperature Guarantee. Write a class TempTracker with these methods: insert() - records a new temperature get_max() - returns the highest temp we've seen so far get_min() - returns the lowest temp we've...
729c09e0e98972578a57a445c115ffb5751857b3
karayount/study-hall
/merge_sort.py
515
3.890625
4
def merge_sort(lst): if len(lst) < 2: return lst mid = len(lst)/2 lst1 = merge_sort(lst[:mid]) lst2 = merge_sort(lst[mid:]) result = [] while lst1 or lst2: if lst1 == []: result.append(lst2.pop(0)) elif lst2 == []: result.append(lst1.pop(0)) ...
c8c98a63020ff5971183ce90bd3d4a43d95f0b95
karayount/study-hall
/string_compression.py
1,012
4.53125
5
""" Implement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa would become a2b1c5a3. If the "compressed" string would not become smaller than the original string, your method should return the original string. You can assume the string has only u...
6190823da69071ca54625f541a5e90463c9876b7
karayount/study-hall
/highest_product.py
1,388
4.34375
4
"""Given a list_of_ints, find the highest_product you can get from three of the integers. The input list_of_ints will always have at least three integers. >>> find_highest_product([1, 2, 3, 4, 5]) 60 >>> find_highest_product([1, 2, 3, 2, 3, 2, 3, 4]) 36 >>> find_highest_product([0, 1, 2]) 0 >>> find_highest_produc...
123fb3e39f9aafbca15523f059d2898bf423ea36
Love-Sharma2509/AI-Assignment-2
/Q2.py
2,444
3.90625
4
import random # Game Board board=[0,1,2,3,4,5,6,7,8] board_input=["","","","","O","","","",""] def show(): print("\n",board_input[0],"|",board_input[1],"|",board_input[2],"\n ---------- \n",board_input[3],"|",board_input[4],"|",board_input[5],"\n ---------- \n",board_input[6],"|",board_input[7],"|",board_input[8]) ...
f6746103ebf782dc61748464e2c0f7720c3016a8
oarthurvictor/codigos
/Python/Atividade 1 - Consumo de Combustivel - Arthur Victor.py
573
3.9375
4
#Aluno: Arthur Victor #Atividade - 1 lista_modelo = [] lista_consumo = [] for i in range (0,5): lista_modelo.append(input ("Modelo do carro: ")) lista_consumo.append(float(input ("Consumo por litro: "))) print ('\n') print ('Resultado Final') for i in range (0,5): print ('Veiculo {} - Modelo: {} - Km/l: {...
933d8a01596151f4f4ff77c8bcf0acea898ae2ca
konarkcher/ProbabilisticPrimalityTesting
/ECPP_Rabin-Miller/miller_rabin.py
1,110
3.9375
4
""" Implementation of Miller-Rabin test. """ import random def miller_rabin(n, k): """ Main method Args: n: k: number of loops (randomly choosing witnesses) Returns: Miller-Rabin witness or False. """ for i in range(0, k): a = random.randrange(2, n - 1) ...
d1ab897669631dcdd0bcd06bbf65c65398b1d018
dcruzp/GraphGenerator
/graphGenerator.py
3,789
3.671875
4
# # aqui hay varias funciones para crear un grafo pero existe una funcion que le pasas un conjunto de parametros y esta te crea una carpeta con una secuencia de grafos # # import os,argparse import sys import graph import random def checkiscorrectGraph(n, m): return m <= (n*(n-1))/2 def generateGraph(n, m...
2b8fc19eb3c7d4dbeead1b08d00c0779f3a48728
zhuhuren/practice-python
/listinstance.py
544
3.5625
4
class ListInstance: def __attrname(self): result = '' for attr in sorted(self.__dict__): result += '\t{}=\t{}\n'.format(attr, self.__dict__[attr]) return result def __str__(self): return '<instance of {}: address {}:\n{}>'.format(self.__class__.__name__, ...
aab72144171beec632ea34ea1b26bea4bf35c0ef
zhuhuren/practice-python
/sierpinski.py
1,077
3.71875
4
from turtle import Turtle, Screen def drawTriangle(points, col, t): pt1 = points[0] pt2 = points[1] pt3 = points[2] t.color(col) t.up() t.goto(pt1) t.down() t.begin_fill() t.goto(pt2) t.goto(pt3) t.goto(pt1) t.end_fill() def midPT(pt1, pt2): return [(pt1[0] + pt2[0]...
3804800d0cb122ab096c5f07a3cd11c3ee50b357
zhuhuren/practice-python
/unorderedLists.py
4,829
3.796875
4
class Node: def __init__(self, data): self.data = data self.next = None def getData(self): return self.data def getNext(self): return self.next def setData(self, newData): self.data = newData def setNext(self, newNext): self.next = newNext def __st...
a4126b96af3c35d46c73637ff1fe829331043c1b
zhuhuren/practice-python
/copyDict.py
106
3.609375
4
def copyDict(dic): dicNew = {} for (k, v) in dic.items(): dicNew[k] = v return dicNew
972e6e7d06e7ef19a822da47dac7d6fe702048ec
zhuhuren/practice-python
/queues.py
776
3.96875
4
class Queue: def __init__(self): self.data = [] def enqueue(self, value): self.data.insert(0, value) def dequeue(self): return self.data.pop() def isEmpty(self): return len(self.data) == 0 def size(self): return len(self.data) def _repr__(self): re...
0889d01e449ea508f0be4dba986e72bc415a9504
askpatrickw/micropython-stubber
/test/common.py
1,254
3.53125
4
import stubs.dev.btree # First, we need to open a stream which holds a database # This is usually a file, but can be in-memory database # using uio.BytesIO, a raw flash partition, etc. # Oftentimes, you want to create a database file if it doesn't # exist and open if it exists. Idiom below takes care of this. # DO NOT...
bbc01bd8c5ef4c81130c6f7dfbc7f0a4abc78fc9
liaanavarro/MeetUP
/model.py
13,893
3.96875
4
""" Search problem model module. This also includes node and graph models. You don't have to add/change anything in this code. If you think there are errors in the code, please send me a message at sirprrr@gmail.com. You will NOT submit this file. Ref: github.com/aimacode/aima-python """ import utils # __________...
192bab55876e58569c71ead2940934c6fb669eb2
Potatology/algo_design_manual
/algorist/data_structure/linked_stack.py
1,355
4
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Implementation of a LIFO stack abstract data type. Translate from stack.h, stack.c. Add iterator implementation. *""" __author__ = "csong2022" class Node: """Stack node.""" def __init__(self, item, _next=None): self.item = item # data item ...
52cffd996c81e097f71bec337c2dce3d69faecac
Potatology/algo_design_manual
/algorist/data_structure/linked_list.py
1,947
4.21875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Linked list-based container implementation. Translate from list-demo.c, list.h, item.h. Add iterator implementation. """ __author__ = "csong2022" class Node: """List node.""" def __init__(self, item, _next=None): self.item = item # data item ...
af76bb19fcfa690fa49ea0390ef6ea6e9716f133
Potatology/algo_design_manual
/algorist/data_structure/linked_queue.py
1,773
4.375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Implementation of a FIFO queue abstract data type. Translate from queue.h, queue.c. Implement with singly linked list. Add iterator implementation. """ __author__ = "csong2022" class Node: """Queue node.""" def __init__(self, item, _next=None): self...
0a4487579d27dab80de813d3953ff071799b8e61
Potatology/algo_design_manual
/algorist/geometry/geometry.py
7,477
4.0625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Basic geometric primitives and data types -- Lines, Circles, Segments Translate from geometry.h, geometry.c. """ __author__ = "csong2022" from math import sqrt PI = 3.1415926 # ratio of circumference to diameter EPSILON = 0.000001 # a quantity small enough to be z...
96963a93f0ba2b495916373e15e6debfac0ff66e
Potatology/algo_design_manual
/algorist/dp/elevator.py
2,190
3.84375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Elevator stop optimization via dynamic programming. Translate from elevator.c. """ __author__ = "csong2022" MAX_RIDERS = 50 # what is the capacity of the elevator? NFLOORS = 25 # the height of the building in floors MAXINT = 100007 class Elevator: """ Ele...
58dca9f2ee5789ff3644758236d3f4a5fd2d315d
Potatology/algo_design_manual
/algorist/backtrack/permutations.py
984
3.640625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Construct all permutations via backtracking. Translate from permutations.c. """ __author__ = "csong2022" from algorist.backtrack.backtrack import BacktrackCallback class Permutations(BacktrackCallback): """ Construct all permutations via backtracking. "...
fd96bd483b82593170856bc0d62ccab97ad33036
abriggs914/CS2043
/Lab2/palindrome.py
466
4.125
4
def palcheck(line, revline): half = (len(line) / 2) x = 0 while(half > x): if(line[x] == revline[x]): x += 1 else: return False return True class palindrome : line = raw_input("Please enter a string:") print(line) print(line[::-1]) revline = (line...
eb8369ad4ccc4a084ad1f56ad1df72e0f82b42b6
wangpanqiao/bioinformatics_scripts
/bio_a_course/4_4_pre_Kmer2int.py
2,288
3.609375
4
# -*- coding: utf-8 -*- # transform a k-mer Pattern into an integer using a function PatternToNumber(Pattern). # We also should know how to reverse this process, # transforming an integer between 0 and 4**k − 1 into a k-mer using a function NumberToPattern(index, k) # order all 4**k k-mers lexicographically # Buildi...
0b201059316aab955fefadbce6f66a900b735a05
Austin-deMora/ICS3U-Assignment4-Python-Salary
/salary.py
904
4.03125
4
#!/usr/bin/env python3 # # Created by: Austin de Mora # Created on: May 2021 # This program finds the bonus net amount of yearly salaries import math def main(): # This function calculates the bonus net amount of yearly salaries # Input service_years = input("Enter years of service: ") yearly_salary...
d40f6049a3bd8a4ff6b157f2f078fba444416de8
Dechuan0629/LeetCodePractice
/HalvesAreAlike-Python/halvesAreAlike.py
644
3.75
4
class Solution: def halvesAreAlike(self, s: str) -> bool: vowelDict = {'a':1,'e':1,'i':1,'o':1,'u':1} halfLen = len(s)//2 strLeft = s[:halfLen] strRight = s[halfLen:] countL = 0 countR = 0 for i in range(halfLen): sL = strLeft[i].lower() ...
0f65df5c980027755b7320a2f204866e810b4108
Dechuan0629/LeetCodePractice
/isSymmetric-Python/isSymmetric.py
1,257
3.828125
4
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Build: def buildTree(self, preorder: list, inorder: list) -> TreeNode: if len(preorder) == 0: return None node = TreeNode(preorder.pop(0)) i = inorder.index(n...
43a9434109e2ffb70bd2912552c53e4b519a99c6
Dechuan0629/LeetCodePractice
/longestPalindrome-Python/longestPalindrome.py
434
3.625
4
class Solution: def longestPalindrome(self, s: str) -> str: #滑动窗口暴力法 for i in range(len(s)-1): for j in range(len(s)-(len(s)-1-i)): temp = s[j:j+len(s)-1-i] if temp == temp[::-1]: return temp return "" def main(): test = So...
e84e38cd0526e8fd6064eb7dd555a62bf7494728
Dechuan0629/LeetCodePractice
/dayOfYear-Python/dayOfYear.py
737
3.765625
4
class Solution: def dayOfYear(self, date: str) -> int: leap = {"01":0,"02":31,"03":60,"04":91,"05":121,"06":152,"07":182,"08":213,"09":244,"10":274,"11":305,"12":335} unLeap = {"01":0,"02":31,"03":59,"04":90,"05":120,"06":151,"07":181,"08":212,"09":243,"10":273,"11":304,"12":334} year,month,...
744b71fd326ae4e952d72460a67c645c70741dc7
prashanth018/Boolean-WildCard
/SearchEngine.py
9,994
3.78125
4
Docs = ['austen-emma.txt','austen-persuasion.txt','austen-sense.txt','blake-poems.txt','bryant-stories.txt','burgess-busterbrown.txt','carroll-alice.txt','chesterton-ball.txt','chesterton-brown.txt','chesterton-thursday.txt','edgeworth-parents.txt','milton-paradise.txt','shakespeare-caesar.txt','shakespeare-hamlet.txt'...
afba28d82cb1eb395a7566adca057fb2e70c8f27
epacuit/ppe-simulations
/_build/jupyter_execute/intro.py
7,070
3.875
4
# Course Overview Computer Simulations for Philosophy, Politics and Economics<br/> Spring 2021<br/> Eric Pacuit <br/> epacuit@umd.edu <br/> University of Maryland<br/> Computer simulations have been used for almost as long as there have been computers. The earliest scientific use of computer simulations were for ph...
7d029ae301b0bbde656d9067683ebf584998b818
epacuit/ppe-simulations
/_build/jupyter_execute/course-content/schelling/01-schelling.py
15,367
3.640625
4
# Overview of Schelling's Model The Nobel prize winning economist Thomas Schelling developed a model that shows how global patterns of spatial segregation can arise from the effect of *homophily* operating at a local level. *Homophily* is the principle that we tend to be similar to our friends and/or neighbors. T. ...
bbc6e3b96361feb1a7fc2e30af378f6f4b5bc038
josh-W42/LRU_Cache
/lru_cache.py
3,502
3.828125
4
from collections import OrderedDict class LRU_Cache(): def __init__(self, capacity): # We'll use an OrderedDict to keep items in # dictionary-like hash table and also keep track # of when they're inserted like a queue. if type(capacity) != int: raise TypeErro...
64eecea8a2678fce9396b0538a23882a2afc5e39
briannakeune/cs-module-project-hash-tables
/hashtable/hashtable.py
7,521
3.5625
4
class HashTableNode: def __init__(self, key=None, value=None, next_node=None): self.key = key self.value = value self.next_node = next_node def get_key(self): return self.get_key def get_value(self): return self.get_value def get_next_node(self): return...
ba1c7199019a4d5c5a696b4758bc36769567b604
jackdcasey/flipguid
/logic.py
1,201
3.5625
4
# Written with ❤ by Jack Casey def cleanGUID(input): #Removes accessory characters from GUID removedChar = '{}- ' for char in removedChar: input = input.replace(char,"") return input def addbrackets(input): #Adds accessory characters to PID return '{{{0}-{1}-{2}-{3}-{4}}}'.format(input[:8], ...
019157e464dbf192e554e98dbcf66e0b921ee15c
Zidoing/algorithm_graph_schema
/4.1-divice-and-conquer.py
347
3.5
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Created by Z Lei on 2019-02-20. def split_farm(long, short): if long == 2 * short: return short print(long, short) used = (long // short) * short long, short = short, long - used print(long, short) return split_farm(long, short) pri...
5245193f49ccb904e004a3ed3011f12b2e5c7eff
AryaEver/Machine-No-Learning
/Lib/template.py
665
3.796875
4
# Importing the libraries import numpy as np import pandas as pd import matplotlib.pyplot as plt from model import modelToBeImported # Importing the dataset # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = trai...
85d156b95da272ad1d9cdb86cde272cd842e0fa0
imclab/introduction-to-algorithms
/2-1-insertion-sort/insertion_sort.py
728
4.34375
4
#!/usr/bin/env python # # insertion sort implementation in python # import unittest def insertion_sort(input): """ function which performs insertion sort Input: input -> array of integer keys Returns: the sorted array """ for j in xrange(len(input)): key = inp...
2351be70aa75984283268e2449b414c14b5441fb
matrixleon18/SHUFE
/numpy/numpy04.py
879
3.859375
4
# encoding="GBK" """ numpy 的深拷贝,浅拷贝,不拷贝 """ import numpy as np # 完全不拷贝,就是引用 a = np.arange(5) print(a) # [0 1 2 3 4] b = a print(b) # [0 1 2 3 4] b[0] = 1 print(b) # [1 1 2 3 4] print(a) # [1 1 2 3 4] print(b is a) # True # 浅拷贝 a = np.arange(5) print(a) # [0 1 2 3 4] c = a.view() print(c) # [0 1 2 3 4] c[0] = 1 prin...
cd15bee18986230566b41213ca27b432ac055699
matrixleon18/SHUFE
/torch/torch15.py
2,097
3.53125
4
# encoding=GBK """ Զ(Autograd)ԭ """ import torch from torch.autograd.variable import Variable a = torch.tensor(1.0, requires_grad=True) b = torch.tensor(2.0, requires_grad=True) c = a + b d = torch.tensor(3.0, requires_grad=True) e = c * d print("=================================================") print("backward()...
f1a4995431fe4504bfcd3e4815feaf933cc88310
sofi-moshkovskaya/python-labs
/lab_5/_1.py
340
3.84375
4
#Даний рядок. Вивести окремі слова, що входять до нього, розділені пробілами, впорядкованими за алфавітом, в стовпчик. #20.04.2019 str=input("Введите строку: ") words=str.split() words.sort() for i in words: print(i)
97cb7a83324542dbb93ffd9d46d05125f0006e57
sofi-moshkovskaya/python-labs
/lab_8/_2.py
2,267
3.765625
4
#2. Створіть клас з ім'ям train, що містить поля: назва пункту призначення, номер поїзда, час відправлення. # Ввести дані в масив з п'яти елементів типу train, впорядкувати елементи за номерами поїздів. # Додати можливість виведення інформації про потяг, номер якого введено користувачем. # Додати можливість ...
363a5d35f31c177ccb95c1dfc002e856341292fa
sofi-moshkovskaya/python-labs
/lab_3/_2.py
1,106
4.09375
4
#2. По залишку від ділення цілої частини значення функції y = log (x² + ab) на 7 вивести день тижня. Значення змінних а, b, x # отримати випадковим чином на зазначеному користувачем інтервалі. import random import math print("Введите интервал для чисел а, b, x") start=int(input()) end=int(input()) a=rand...
0eaf90d128b5561af53855145eab235f11f07afc
sofi-moshkovskaya/python-labs
/lab_2/_2.py
458
3.8125
4
#2. Дано три цілих числа. Знайти кількість додатних чисел в початковому наборі. a=int(input("Введите первое целое: ")) b=int(input("Введите второе целое: ")) c=int(input("Введите третье целое: ")) amount=0 if a>0: amount+=1 if b>0: amount+=1 if c>0: amount+=1 print("Количество положительных: ", amount)
dd7af2bf10454a3a349eef39517c85693e0fce18
imasoul2/public
/Programmers/Small_exercises/w3_python.py
1,136
3.59375
4
import math as moth import numpy class Person: def __init__(self,name="no name",age=999): self.name = name self.age = age def work(self,minute): print("{} just worked for {} minutes".format(self.name, minute)) def eat(self,*kids): for x in kids: print(...
e7a93186eb76d45d2f002f63db25b17997f2c80d
imasoul2/public
/Programmers/Coding Test Practice/KaKao Winter 2019 Internship Question - Crane Game.py
2,029
3.734375
4
# 2019 Winter Kakao Winter Internship problem # 코딩테스트 연습 # 2019 카카오 개발자 겨울 인턴십 # 크레인 인형뽑기 게임 # Crane Problem # Programmer : CJ Jang # the function is given n by n "board" and a series of "moves". # the "dolls" are number between 1~100 and they are stacked on the n by n board. # the preoccupied space will be assigned...
3df6ec0fac15cd87ac4e93f109aad07069f05536
tommy310310/test_repo
/testing.py
4,216
3.5
4
import random def sgrk(): goal = 30 p1 = 0 p2 = 0 pp = 0 n1 = input('最初にサイコロを振る人の名前は?>') n2 = input('あとにサイコロを振る人の名前は?>') while pp < goal: print(n1 + 'さんはサイコロを振ってください。') s1 = random.randint(1, 6) p1 += s1 print('サイコロの目は '+str(s1)+' です。  '+n1 + ...
bae9eb5a03619e9c3122da0c46af69c90ec02048
TolgaOzdmir/PythonSchoolProjects
/edXProject/pythonProject/p2_q2.py
273
3.90625
4
num = int(input()) pow_list = [] for i in range(num): if 3**i <= num: pow_list.append(3**i) else: break sum = pow_list[len(pow_list)-1] for i in range(len(pow_list)-1): if sum + pow_list[i] > num: break sum += pow_list[i] print(sum)
763e975e748ba8cbc4380c545682dc125858115b
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 08/capitulo 08/capitulo 08/exercicio-08-13.py
1,100
4.03125
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2017 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Primeira reimpressão - Outubro/2011 # Segunda reimpres...
51932bdfca69073d247dba1ebc7fa1d6de942a48
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 02/capitulo 02/capitulo 02/exercicio-02-02.py
1,576
4.21875
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2017 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Primeira reimpressão - Outubro/2011 # Segunda reimpres...
d734ec096be65bd22bd021a364aaa1052d102059
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 11/11.20 - Programa 11.5 - Consulta utilizando parametros.py
1,227
3.703125
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2019 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Segunda edição - Junho/2014 - ISBN 978-85-7522-408-3 # Terce...
1e4a80790e05d962b5d37a67a0ce25b4d4089bf9
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 09/09.31.py
893
3.921875
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2019 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Segunda edição - Junho/2014 - ISBN 978-85-7522-408-3 # Terce...
f58629ab3b18436da63c83b0a14bd1427aaba1a9
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 04/04.04 - Programa 4.3 Calculo do Imposto de Renda.py
995
4.4375
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2019 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Segunda edição - Junho/2014 - ISBN 978-85-7522-408-3 # Terce...
effd68bbed996738bcdf997fe5a8297adf24edef
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 05/capitulo 05/capitulo 05/exercicio-05-25.py
1,330
4.1875
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2017 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Primeira reimpressão - Outubro/2011 # Segunda reimpres...
1964523b11656fc162ea26c6bfa9c033ea832093
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 10/10.38.py
893
3.96875
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2019 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Segunda edição - Junho/2014 - ISBN 978-85-7522-408-3 # Terce...
b467d3cd5637fd886eae302be0fd728110e006a5
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 04/04.05 - Programa 4.4 - Carro novo ou velho, dependendo da idade com else.py
874
4.4375
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2019 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Segunda edição - Junho/2014 - ISBN 978-85-7522-408-3 # Terce...
49d9a01af9e9b47089bc0923ce444d07d5a558b5
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 02/02.21 - Programa 2.2 Calculo de aumento de salario.py
763
4.3125
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2019 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Segunda edição - Junho/2014 - ISBN 978-85-7522-408-3 # Terce...
6403b16a8c2d39723412b29d9db219627b33a5be
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 10/10.31.py
910
3.890625
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2019 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Segunda edição - Junho/2014 - ISBN 978-85-7522-408-3 # Terce...
46ab53fa90708d8af1c1d3d24993c8818feb1983
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 05/05.18.py
657
3.90625
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2019 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Segunda edição - Junho/2014 - ISBN 978-85-7522-408-3 # Terce...
f350339f0416e4933dc04243e192d2fa2a994bea
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 08/08.35 - Programa 8.15 Funcao imprime_maior com numero indeterminado de parametros.py
1,028
4.15625
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2019 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Segunda edição - Junho/2014 - ISBN 978-85-7522-408-3 # Terce...
64300e553123fcf7566b26e33889f4338bf7be7d
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 10/10.13.py
890
3.75
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2019 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Segunda edição - Junho/2014 - ISBN 978-85-7522-408-3 # Terce...
0bb7a966b061650616787a97648fa7bf8783cdd0
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 03/03.21.py
808
3.921875
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2019 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Segunda edição - Junho/2014 - ISBN 978-85-7522-408-3 # Terce...
463ba46cad291a2eae8fb8ffe0b9ddb1491d71c2
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 08/08.41.py
828
4.1875
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2019 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Segunda edição - Junho/2014 - ISBN 978-85-7522-408-3 # Terce...
730ceff21ef8350be3887516f134553b19b403cc
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 09/09.34 - Programa 9.10 Arvore de diretorios sendo percorrida.py
995
3.703125
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2019 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Segunda edição - Junho/2014 - ISBN 978-85-7522-408-3 # Terce...
21f284932e9671219c1a833b55202e180a67364f
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 11/11.08.py
876
3.796875
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2019 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Segunda edição - Junho/2014 - ISBN 978-85-7522-408-3 # Terce...
41f2a9fb93a710fe9813de9549579de8f3d6507b
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 03/03.01.py
654
3.984375
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2019 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Segunda edição - Junho/2014 - ISBN 978-85-7522-408-3 # Terce...
6aebc20bf00b84f380103e3cb24e2af6d1910b6d
soongon01/ContactAdmin
/service/contact_service_db.py
710
3.625
4
""" """ import sqlite3 def regist_contact(contact): query = 'insert into contact values(?,?,?,?);' con = sqlite3.connect('contact.db') cur = con.cursor() cur.execute(query,(contact.name, contact.hpnum, contact.email, contact.age)) con.commit() con.close() def view_all_contact(): pass d...
3e39997a8b4537166ec03e5662f1be3c2146cc98
iamkidding/Algorithm
/Sort.py
437
3.765625
4
import random def insertion_sort(list): i = 1 while i < len(list): key = list[i] j = i - 1 while key < list[j] and j > -1: list[j + 1] = list[j] j -= 1 list[j + 1] = key i += 1 print(list) def merge_sort(list): # l = [2, 4, 768, 1, 34, ...
9bbd25ef694b8235c38c1b8af0e1bf9432f1c117
SnallQiu/algorithm
/insert/insert .py
434
3.828125
4
def insert(list): length = len(list) for i in range(1,length): if list[i]<list[i-1]: index = i #记录插入的位置 value = list[i] #记录插入的值 while index>0 and list[index-1]>value: list[index] = list[index-1] index -= 1 ...
3da6dd0ee9e2b0536fecf55aba6dcfd17b308f84
neochen2701/TQCPans
/程式語言Python 3答案檔/PYA308.py
238
3.8125
4
total = eval(input()) for i in range(total): num = eval(input()) tmp = num sum_digit = 0 while tmp != 0: sum_digit += tmp % 10 tmp //= 10 print("Sum of all digits of %d is %d" % (num, sum_digit))
29f5972f80bc9b3ed89466ca49504f58ead8668a
neochen2701/TQCPans
/程式語言Python 3答案檔/PYA409.py
498
3.703125
4
vote1 = vote2 = null_vote = 0 for i in range(5): n = eval(input()) if n == 1: vote1 += 1 elif n == 2: vote2 += 1 else: null_vote += 1 print("Total votes of No.1: Nami = ", vote1) print("Total votes of No.2: Chopper = ", vote2) print("Total null votes = ", null_vote)...
4c7d5d2e3264b25a0d1812caffeb52e3c066b5bd
neochen2701/TQCPans
/程式語言 V2答案檔/Python/305.py
280
3.953125
4
def compute(input_list): if input_list[1] == 1: return input_list[0] + input_list[2] elif input_list[1] == 2: return input_list[0] * input_list[2] input_list = [] for i in range(3): x = int(input()) input_list.append(x) print(compute(input_list))
85550d5b097424bd59cbb47b262b3eaab2e25c25
neochen2701/TQCPans
/程式語言Python 3答案檔/PYA609.py
804
3.984375
4
def compute(mat, num_row, num_col): for i in range(num_row): for j in range(num_col): print("%d" % mat[i][j], end=' ') print() ROWs = COLs = 2 mat1 = [] mat2 = [] print("Enter matrix 1:") for i in range(ROWs): mat1.append([]) for j in range(COLs): print("[%d, %d]: " % ...
0212be118e8403a8fa5fc00a2d6f1e1b3f868bf9
neochen2701/TQCPans
/程式語言Python 3答案檔/PYA209.py
134
3.71875
4
x = eval(input()) y = eval(input()) dist = ((x-5)**2 + (y-6)**2) ** 0.5 if dist <= 15: print("Inside") else: print("Outside")