blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
4db8635f1b3bd9d6acc01fbca2dff3e761ddf500
Saptarshi-prog/Algorithmic-toolbox-Coursera-Assignments
/Week 2/last_digit_of_fibonacci_number.py
159
3.640625
4
n = int(input()) def lastdigit(n): a,b = 0,1 for _ in range(n-1): c =a+b c=c%10 b,a = c,b print(c) if n<=1: print(n) else: lastdigit(n)
7a85a1eb3176072288a744da95afbbed2e61b1ee
angjerden/oiler
/problem015.py
655
3.703125
4
__author__ = 'b543840' h = 9 w = 9 def printLattice(lattice): output = "" for i in range(0, len(lattice)): for j in range(0, len(lattice[i])): output += "[" + str(lattice[i][j]) + "]" output += "\n" print output + "\n" def initLattice(lattice): for i in range(0, h): ...
37a8ffe45cbc2953805c761a35895532020bd899
Nidhogglin/Python
/practice/代码提升小组/股票利润3_1.2.py
571
3.734375
4
#!usr/bin/env python3 # coding: utf-8 # @time :2020/10/10 15:41 class Solution: def maxProfit(self, prices) -> int: buy_1 = buy_2 = float('inf') # 第一二次买之前的最低价 pro_1 = pro_2 = 0 for p in prices: buy_1 = min(buy_1, p) pro_1 = max(pro_1, p - buy_1) buy_2 =...
96855469edb93b84316598457f8f48ce23ded825
eduardoportella/python
/exercicios/ex030/ex030.py
123
3.78125
4
n = int(input("Diga um numero inteiro qualquer: ")) if n%2 == 0: print(f'{n} é par') else: print(f'{n} é ímpar')
ecf14ddfa8da0c0be50332d18b82468e2115a2c8
NotUrNeighborMrWang/OpenCV-Learning-Notes
/tutorial_13.py
505
3.53125
4
""" 仿射变换 """ import cv2 as cv import numpy as np def fangshe(image): rows, cols, ch = image.shape pts1 = np.float32([[50, 50], [200, 50], [50, 200]]) pts2 = np.float32([[10, 100], [200, 50], [100, 200]]) M = cv.getAffineTransform(pts1, pts2) dst = cv.warpAffine(image, M, (cols, rows)) cv.imshow("In...
b1f366b073f756d20982a5908b2ab424f7c76b29
buddyjasmith/5143-OS-Smith
/Assignments/A04/PyShell/assignments/shell/cmd_pkgs/mkdir.py
1,577
3.984375
4
""" NAME: mkdir Usage: mkdir [path] mkdir - make a new directory in the path supplied by user """ from colorama import Fore, Style import os import sys import errno from cmd_pkgs.arg_parser import ArgParse from cmd_pkgs.return_status import ReturnStatus def mkdir(args, cwd): ''' :Function: mkdir :Par...
71fda3982e67e2106910b4a2cf3d37027309d57f
Nideayu/codeing
/section1/1.1认识Python.PY
1,487
3.65625
4
''' 1.Python的发音与拼写 2.Python的意思是蟒蛇,源于作者喜欢的一部电视剧 (C呢?) 3.Python的作者是Guido van Rossum(龟叔) 4.Python是龟叔在1989年圣诞节期间,为了打发无聊的圣诞节而用C编写的一个编程语言 5.Python正式诞生于1991年 6.Python的解释器如今有多个语言实现,我们常用的是CPython(官方版本的C语言实现),其他还有Jython(可以运行在Java平台)、IronPython(可以运行在.NET和Mono平台)、PyPy(Python实现的,支持JIT即时编译) 7.Python目前有两个版本,Python2和Python3,最新版分别为2.7....
6d6a97a09034b3612b8b0bd02e93621926c84798
reashiny/python.
/python_player/variable.py
587
3.53125
4
#------------------------------------------------------------------------------- # Name: module1 # Purpose: # # Author: 16cse037 # # Created: 21/10/2017 # Copyright: (c) 16cse037 2017 # Licence: <your licence> #------------------------------------------------------------------------------...
99f3f95c3ac53dfe595550970283fcd98be5b9e3
jorgesanme/Python
/Ejercicios/Pildoras/operadores_comparación.py
624
4
4
# evaluar salarios de una empresa, condiciones y # concadenación de operadores comparación salario_presi= int (input("cuanto cobra este Presi: ")) print("El Presi cobra: "+ str(salario_presi)) salario_direc= int (input("cuanto cobra el director: ")) print("El Director cobra: "+ str(salario_direc)) salario_adminis...
f092dd6a073f4e474285db33cb1538aa2831da5b
lawrencechang/parking
/src/printTimeSlots.py
751
3.859375
4
# Used to print out time slots and their values, clearly. def printTimeSlots(jsonLine): periods = ['am','pm']; hours = [0,1,2,3,4,5,6,7,8,9,10,11]; minutes = ['00','15','30','45']; days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']; print "__________ S M T W Th F S" for perio...
47b5362714d2d94efa5ac07d126b29effa5d4832
NEHAISRANI/Dictionary_Questions
/dict_ascending_descending.py
117
3.671875
4
seq = {1, 2, 3, 4, 5} print("Ascending Order :", sorted(seq)) print("Descending Order :", sorted(seq, reverse=True))
389334ef3d0af9299dcb8dd9d6931baf76272258
WonderPro/Engineering-Practical-Experiments
/Semester 4/Analysis of Algorithm/exp02_MergeSort.py
1,556
4.21875
4
def mergeSort(alist): # dividing lists in halves if len(alist) > 1: mid = len(alist)//2 lefthalf = alist[:mid] righthalf = alist[mid:] mergeSort(lefthalf) mergeSort(righthalf) # merging i = 0 j = 0 k = 0 # add elements in list by ...
4ad928d586890fd30d65e2f72f05eb8c2840e48c
bvegetabile/RapidIntroPython
/2016_11_04_CalStateFullerton/scripts/counter_example.py
305
3.90625
4
# Example of a simple counter function counter = 0 print 'Starting Counter Position: ' + str(counter) while counter <= 1000: counter += 1 if not counter % 100: print 'Counter : '.rjust(15) + str(counter) print 'Bad Indents' print 'Final Counter Position : ' + str(counter)
8a87b3218d37d33212200262ef3c0bc0204d9e52
sdksfo/leetcode
/easy_414. Third Maximum Number.py
664
3.8125
4
""" Approach: Keep there variables and update them based on the number in the array Complexity: Time: O(n) Space: O(1) """ class Solution(object): def thirdMax(self, nums): """ :type nums: List[int] :rtype: int """ first = second = third = None for n in nums: ...
d7489af2464d814bcedbbc5ec554f963cace6269
chintanvadgama/Algorithms
/twoSum.py
1,689
3.875
4
""" Question: Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not z...
1d4e5fae4634f2e9cb59091de5733732d97ac453
Dheeraj-1999/interview-questions-competitve-programming
/python/programs python/for.py
116
3.671875
4
k=1 for i in range(1,6): for j in range(1,i): print(k,end=" ") k+=1 k=1 print("")
9c59c3fe7033786d3750040d8a8abe53c66d0811
abhikot1996/Python-Python-All-In-One-Mastery-From-Beginner-to-AdvanceEasy-Way-
/Python-Python-All-In-One-Mastery-From-Beginner-to-AdvanceEasy-Way-/Functions.py
228
3.875
4
''' Function ''' # E.g 1), # def add2(x): # y = x + 2 # return y # # print(add2(3)) # E.g 2), # def add2(x): # y = x + 2 # return y # # c = add2(3) # def add3(x): z = x + 2 return z print(add3(3))
7cb8440c99c82ce2b462d406110a77b910bc8bd4
jrog20/sentinelloop
/sentinelloop.py
356
3.984375
4
""" File: sentinelloop.py ------------------ Simulate rolling two dice, and prints results of each roll as well as the total. """ def main(): total = 0 num = int(input("Enter a number: ")) while num != -1: total += num num = int(input("Enter a number: ")) print(total) if...
cb840958bfce5efed88deb6e69192031f542c130
hofmannicusrex/DMACC_Python_202003
/Module3/strings_and_string_methods.py
1,385
4.21875
4
""" Program: strings_and_string_methods.py Author: Nick Hofmann | nickhofmann1989@hotmail.com | nohofmann@dmacc.edu Last Modified: 6/6/2020 Program specifications: The program will demonstrate different Python string methods. """ string_to_test = 'Aragorn in The Lord of the Rings' # capitalize print("---capitalize---...
47fe0720956fd8852f7767b20e92ce33fe6697c5
Hug00/ninmonkey
/boilerplate/pygame/3. draw Sprite/draw image.py
3,548
3.546875
4
WINDOW_TITLE = "pygame boilerplate - draw image " import pygame from pygame.locals import * from pygame.sprite import Sprite import random import os # ( draw image edit: 2011/06/30 ) jake class Snake(Sprite): """Derives from Sprite(). this gives us a Surface() and a Rect() to store a loaded ...
68401d6da19ab310bd9e84dc88e1be2272b0bc7c
WizardsOrb/Casper
/add_account.py
1,100
3.625
4
import sqlite3 class AddAccount: def __init__(self): self.added = False self.connection = sqlite3.connect('account.db') self.cursor = self.connection.cursor() self.cursor.execute("""CREATE TABLE IF NOT EXISTS accounts (list INTEGER, account VARCHAR(64), secret VARCHAR(64), ...
933c8218190c96cd4ce23fef5bdb3e2ee3297403
maxuw/glasses
/glasses_queue_unique.py
5,908
3.84375
4
#- initial functions #- Tuple update def new_tuple(tuple_, i, change): tpl = tuple_[:i] + (change,) + tuple_[i+1:] return tpl # print(tpl) #- #- print content glasses def print_content_glasses(state_filled, desired_level, glasses_capacity): return_string = "" ch = 'A' for i in range(len(glasses...
b88392f4fc24b7f52e96a72db3f4287bc43f0673
Storiesbyharshit/Competetive-Coding
/LeetCode-Solutions/653. Two Sum IV - Input is a BST.py
611
3.71875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def dfs(self, root, k, aux): if not root: return False if k - root.val ...
87e0ef4b073bd3141237b216c8481c622e5537a5
2amitprakash/Python_Codes
/Grokking_Algo/SelectionSort.py
445
4.03125
4
def findSmallestIndx(arr): Index = 0 # for smallest as default for i in range(1, len(arr)): if arr[i] < arr[Index]: Index = i return Index #End of function findSmallest def selectionSort(arr): newArr = [] for i in range(len(arr)): index = findSmallestIndx(arr) newArr.append(arr.pop(index)) return newArr ...
00a153b1e0860cc8739c180df61f715e8e4da15a
csrhau/sandpit
/python/cryptanalysis/simplecaesar/solver.py
1,608
3.5625
4
#!/usr/bin/env python3 import argparse import string def process_arguments(): parser = argparse.ArgumentParser(description="Simple Ceaser Solver", formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("-w", "--wordlist", type=argparse.FileType('r'), requir...
eec02e3857e2598f2384f84ef6b8a4581ca4c77f
horia94ro/python_fdm_29ianuarie
/day_3_part_2.py
1,773
3.71875
4
# lista_mea = [("Laurentiu", 27), ("Cristi", 32), ("Dani", 25)] # dictionar = dict(lista_mea) # dictionar = { # 'Laurentiu' : 27, # 'Cristi': 32, # 'Dani' : 23 # } # print(dictionar) # # dictionar['Dani'] = 26 # print(dictionar) # # dictionar['Robert'] = 34 # print(dictio...
7b1f1531e65c5a6a5ce542e16c52e434a3f93a2b
filipeclduarte/tutorial_julia_python_r
/tutorial.py
2,620
4.8125
5
# Tutorial de Python # 1. Criar variáveis x = 10 x y = -10.5 y # 2. Função print print(x) print('o valor de x é ', x) # 2.2 Interpolação de string print('o valor de x é {}'.format(x)) print(f'o valor de x é {x}') print(f'o valor de y é {y}') # 3. Coleção de valores ## 3.1 Lista ### 3.1.1 Unidimensional x = [1,...
3928692ab67bb8ee168511712f64cd5627132aa7
Nydream/cz3005-lab1
/Task1/task1(old).py
1,984
3.640625
4
import json from queue import PriorityQueue class Graph: def __init__(self, num_of_vertices): self.v = num_of_vertices def dijkstra(self, source_vertex, target_vertex, graphData, distData): visited = set() distance = {source_vertex: 0} parent_vertex = {source_vertex: N...
abcf2ff1a228a10f11ca3bc84586dfaa6fffd005
lilimehedyn/Small-projects
/list_practice.py
1,102
4.21875
4
# create a list nums = [1, 3, 5, 35, 567, 45673, 8, 890, 1000] print(nums) # print out a list with another name my_list = [] for n in nums: my_list.append(n) print(my_list) # list comprehension, easier to code and understand my_list = [n for n in nums] print(my_list) my_list = [n*n for n in nums] # n*n is a squa...
04ddac7908b2f40f75c10369dbdace56f0e99ccb
kohrongying/aoc
/2019/python/day6.py
1,889
3.609375
4
f = open('../input/day6.txt', 'r') lines = f.readlines() d = {} def print_dict(d): for key in d: print(f'{key}: {d[key]}') # Build a tree of key [orbiter]: value [parent] # Each planet has exactly ONE parent def build_tree(): for line in lines: station, orbiter = line.strip().split(")") if station not...
093dd5bd6283c4598cf2f74435ca6d85e524fe13
larileonso23/exercicio-groger_bank
/aula4/calcular.py
430
3.765625
4
import datetime dia = input('Digite o dia que vocẽ nasceu') mes = input('Digite o mes que voce nasceu') ano = input('Digite o ano em que você nasceu') total = datetime.date(year=ano,day=dia,month=mes) def calcular_dias(data): if data in None: error='ops' return error hoje = datetime.date.tod...
c5e867581475efac7b5754d6f66ac24b8ddc40a1
dzmitrybutar/course
/task1/process_data.py
567
3.875
4
from collections import defaultdict class Action: """Class for working with input data.""" def __init__(self, students: list, rooms: list): self.students = students self.rooms = rooms def union(self): """Combining data into a list of rooms where each room contains a list ...
fe319a5cb09aa57939973509b7277a126cab21cc
xhanak2/CodeWars-Python
/StringOfNames.py
542
3.546875
4
def namelist(names): result1=[] result2=[] result3="" last="" if len(names)>0: for n in names: result1.append(n['name']) last=result1.pop() result2= ", ".join(result1) if len(result1)>0:result3=result2 + " & " + last else: result3=last retu...
aa2cee51eb7073a723f58dfbcb29ba1b64187990
cry999/AtCoder
/beginner/071/B.py
216
3.875
4
def not_found(S: str)->str: for c in 'abcdefghijklmnopqrstuvwxyz': if c not in S: return c return 'None' if __name__ == "__main__": S = input() ans = not_found(S) print(ans)
d51f60180f6e81edb777b35f77dca4aef28c133d
Salmon420/Math-Quiz
/Maths_Help_Class.py
2,514
3.875
4
from tkinter import * from functools import partial # To prevent unwanted windows import random class Help: def __init__(self, partner): background_color = "cyan" # disable help button partner.help_button.config(state=DISABLED) # Set up child window (ie: help box) se...
eea043fdee2fecaecbc922909ef8c8243d69361b
PdxCodeGuild/20170626-FullStack
/lab20-piglatin.py
351
4.125
4
# lab 20: piglatin # If the first letter is a consonant, move it to the end # Add "ay" to the end of that # If the first letter is a vowel, just add "yay" to the end vowels = 'aeiou' word = input('what is your word? ') if len(word) > 1: if word[0] in vowels: word += 'yay' else: word = word[1:...
9e9884e960196519a849c9e2d35e3e1b63adec95
krishna924/PythonTutorial
/asignments/methods_asg.py
911
3.515625
4
fed_tax = 10 state_tax = { "texas" : 0, "illinois" : 6, "new yorck" : 5, "ohio" : 3 } def netIncome (state, gross): """ method should return net income = :param state: :param gross: :return: """ fed_cut = (gross) * (fed_tax/100) st_tax = state_tax[state] if state...
afa42f8bb4162230100223489a06e593f66a5140
amitkaintura/HTML-PARSER
/parser.py
1,111
3.65625
4
#Requirements #pip3 install bs4 # Basic fundamentals of web scraping # import BeautifulSoup for selecting HTML tags easily from bs4 import BeautifulSoup json = {} #file handling operation with open('New Lead .html', 'r') as src: text = src.read() # Create a variable called "soup" to parse the HTML conte...
5aac6fedfa7b6ac2623ee4dd22bce1d6bee3c6d0
jicruz96/coding-exercises
/hackerrank/regex/detect-html-links.py
1,904
3.578125
4
#!/usr/bin/python3 """ solution to HackerRank's 'Detect HTML Links' regex problem See problem description and input format here: `https://www.hackerrank.com/challenges/detect-html-links/problem` """ from sys import stdin import re regex_sub_strings = [ r'<a\s+', # match 'a' tag opening r'...
bf5c88fb71799cbeff7299cfc4739d683bfbdb3f
ZabretRok/HW4.1_Mood_checker
/mood_checker.py
444
4.125
4
user_mood=input("What mood are we in today?").capitalize().lower() if(user_mood)== "happy": print("It is great to see you happy!") elif(user_mood)== "nervous": print("Take a deep breath 3 times.") elif(user_mood)== "sad": print("Don't worry, everything will be alright.") elif(user_mood)== "excited": pr...
80d958ecc1df7477ab555c4d015632aae3cd4248
Roberto-Sartore/Python
/exercicios/PythonExercicios/ex87.py
726
3.875
4
matriz = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] spar = mai = scol = 0 for l in range(0, 3): for c in range(0, 3): matriz[l] [c] = int(input(f'Digite um valor para [{l}, {c}]: ')) print('= ' * 36) for l in range(0, 3): for c in range(0, 3): print(f'[{matriz[l] [c]:^5}]', end = '') if matriz[l]...
5be19c8e4b780a1df12833e9c87f51bf359350c3
Bar-BelliedCuckooshrike/EstudosPython
/Funcoes_comParametro.py
343
3.546875
4
""" Funções com parâmetro: """ def quadrado(numero): return numero ** 2 print(quadrado(4)) print(quadrado(5)) print(quadrado(6)) def olaHumano(humano): print(f'olá, {humano}') olaHumano('felipe') def nome_completo(nome, sobrenome): return f'seu nome completo é: {nome} {sobrenome}' print(nome_completo('Fe...
aa86b05da4266b73876e1b7c17ad1472fb34c49b
magnushedin/AOC
/2019/dec_01/p1.py
118
3.609375
4
input_file = open('input') total_fuel = 0 for line in input_file: total_fuel = int(int(line)/3)-2 print(total_fuel)
6b0379d0a68479b6a573ee3f5f9c8741195a7108
ari-jorgensen/asjorgensen
/PolyAlpha.py
1,250
4.21875
4
# File: PolyAlpha.py # Author: Ariana Jorgensen # This program handles the encryption and decryption # of a file using a polyalphabetic cipher. # NOTE #1: For simplicity, all characters are converted to lowercase # NOTE #2: I created this algorithm to work by line, i.e. shift # is based on that letter's index in regar...
25f764aa1f194a714edf3f0c35f3d95b3d51787e
KeiShimon/AtCoder
/ABC120/ABC120_A.py
121
3.578125
4
cost, wallet , target = map(int, input().split()) t = wallet //cost if t > target: print(target) else: print(t)
fe8da18355e30ae691016b04afad096d39262a06
nihalgaurav/acadview_python
/class11/1-thread_sleep.py
248
3.671875
4
#Create a threading process such that it sleeps for 5 seconds and then prints out a message. import threading from threading import Thread import time def message(): time.sleep(5) print("hello python") t= Thread (target=message) t.start()
0d3d25ba82d8259b892231793f2b4af38dcf40e8
bemova/Tensorflow-Pytorch-Classify-MNIST-Dataset-in-Biger-and-less-than-3
/tensorflow/tensorflow_solution.py
17,357
3.5625
4
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data import numpy as np import argparse import time # read mnist dataset from tensorflow repository if it is not downloaded yet. mnist = input_data.read_data_sets("MNIST_data/",one_hot=True) # Weights def init_weights(shape): """ t...
1c857261c2cc3d71f477d9e1edb09377c5d9ce6c
agusiol/python_sii_homework
/pogodynka.py
2,636
3.84375
4
""" Napisz program pogodynka Po podaniu przez uzytkownika dnia i miesiaca zaproponuj pogodę na ten dzien. Uwzglednij: - pore roku (np. jesienią jest zwykle deszczowo) - temperature (przedstawiona w sopniach Farhenheita, Celcjusza i w Kelvinach) Dla chetnych: - uwzglednij opady - uwzglednij stopien zachmurzenia / nasl...
823b4296c0c433a380879eeb6171c61e710631ad
VidarHUN/learn_python
/creditcalc.py
3,255
3.609375
4
import math import argparse def interest(i): return (i / 100) / 12 def count_of_months(principal, monthly_payment, i): n = math.ceil(math.log((monthly_payment / (monthly_payment - i * principal)), 1 + i)) years = math.floor(n / 12) months = n - (years * 12) if months != 0: print("You need ...
695765a2a600eea23800bfabcb507eddb30b92e9
tritogeneia/room-object-game-thing-challenges
/item.py
269
3.53125
4
class Item(): def __init__(self, item_name, item_description): self.name = item_name self.description = item_description self.in_room = True def describe_item(self): print("You find " + self.name + "!") print(self.description) print("-------------")
32819bb7a2b7dae9d2001eefecf21cea3fdd082f
rafaelperazzo/programacao-web
/moodledata/vpl_data/446/usersdata/328/104488/submittedfiles/diagonaldominante.py
212
3.921875
4
# -*- coding: utf-8 -*- d=int(input ('Digite a ordem da matriz:')) m=[] for i in range(d): l=[] for j in range(d): l.append(float(input('Dê valores a matriz:'))) m.append(l) print(m)
95b4b3dd11b65e9fedebcfb5a4bc8dfb8c474291
abbhowmik/PYTHON-Course
/chapter 7.py/10_reverse.py
148
3.890625
4
# for i in range(10, 0, -1): # print(i) n = int(input('Please enter the number: ')) for i in range (10, 0, -1): print(f'{n}X{i}={n*i}')
eae5a1d18cbe890754f50d76d55299c44c220a82
Ree3a/-New-Python-lab-
/ques4.py
607
4.46875
4
''' Given the integer N - the number of minutes that is passed since midnight- how many hours and minutes are displayed on the 24h digital clock ? The number of program should print two numbers : the number of hours (between 0 and 23 ) and the number of minutes (between 0 and 59) eg , if N = 150 , then 150 minutes have...
b3ab19777c2a2dae27610b3aa0ec2c8f7c2c1e04
lytl890/DailyQuestion
/Paranoid-kid/zen_of_python_03.py
958
3.5625
4
# -*- coding: utf-8 -*- # ----------------Ver 1.0---------------- # path = 'd:/import_this.txt' # with open(path, 'r') as text: # words = text.read().split() # result = {} # for word in words: # print('{} - {} times'.format(word, words.count(word))) # result[word] = words.count(word) # ...
88e029a881f60f822984568940a667ef42178595
andriarna98/hmmm
/UI/Print_rent_menu.py
2,405
3.59375
4
import os class Print_rent_menu(object): def Page_1(self): """ Prints out the menu where the customer chooses location to pick up his desired car """ os.system('cls||clear') print("\t~ Location ~") print("\tPage 1 of 8\n") print("Select pick up location:") p...
2b906cacf05db6cf70772f73098b8a33eec47622
rootid23/fft-py
/sort/valid-anagram.py
861
4.03125
4
class Solution(object): def isAnagram(self, s, t): #W/ aux_map import collections m,n = map(len , [s,t] ) if(m != n) : return False mp = collections.defaultdict(int) for i in range(m) : mp[s[i]] += 1 mp[t[i]] -= 1 for k in mp.keys() ...
32c8566b2c3ee8bd4939526ac860855038fa3362
perimosocordiae/TheGoddamnChatbot
/tgdcb/colors.py
925
3.578125
4
COLORS = { 'k':"", 'r':"", 'g':"", 'y':"", 'b':"", 'm':"", 'c':"", 'w':"", 'd':"", 'x':"", 'E':"", 'e':"", 'N':"", 'n':"", 'U':"", 'u':"", } def notify(char, color, string): i...
18cc4243736d1016ed5ed13ad5c01912c3afc3dd
j16949/Programming-in-Python-princeton
/2.2/22.py
1,070
3.75
4
#判断是否是素数 def prime(a): if len(factors(a)) == 2: return True else: return False #判断是否互质 def relativelyPrime(a,b): fa = factors(a) fa.remove(1) fb = factors(b) fb.remove(1) for s in fa: if s in fb: return False return True #求所有因子 def factors(a): b = [] for i in range(1,a+1): t = a % i if t == 0: ...
38532956a97b0e5ac02b77a784144ea41b6823d6
omer662/Python-Calculator
/Calculator/main.py
3,684
3.84375
4
from tkinter import * calc = Tk() calc.title("Calculator") calc.grid_columnconfigure(0, weight=1) calc.grid_columnconfigure(1, weight=1) calc.grid_columnconfigure(2, weight=1) calc.grid_columnconfigure(3, weight=1) calc.grid_rowconfigure(0, weight=1) calc.grid_rowconfigure(1, weight=1) calc.grid_rowconfigure(2, weigh...
e9bbcaa7c0e02db9e32b8450f168254c532a8147
sandeep9889/datastructure-and-algorithm
/problems/sorting/bubblesort.py
266
3.84375
4
def Bubblesort(arr): for i in range(len(arr)-1): for j in range (len(arr)-i-1): if arr[j]>arr[j+1] : arr[j],arr[j+1]=arr[j+1],arr[j] return arr arr=[50,10,456,22] sortedarr=Bubblesort(arr) print(sortedarr)
40c916c82044ed042ee92971a00ef2ff3d516e82
romanfinkin/rep
/HW2/rand/ran.py
225
3.703125
4
import random x = random.randrange(1, 10) y = int(input('Enter option ')) while True: if x == y: print('Sucсess, you WIN!') break else: print('Not bad') y = int(input('Try again '))
2b67379c2375e77aa7f5750e8827fce118e12139
daniel-reich/ubiquitous-fiesta
/QEDPxbfHjvWXQQtpH_2.py
105
3.765625
4
def count_palindromes(num1, num2): return sum(str(i) == str(i)[::-1] for i in range(num1, num2 + 1))
0b1a44f7363f6251b94fa6c7146163159940519e
anaypant/anaypant.github.io
/Single Projects/Stock/stock_gen.py
2,465
3.546875
4
# This is the code that will create and make charts of stocks. import random import matplotlib.pyplot as plt from matplotlib import style import time import matplotlib.patches as mpatches # 4 Stocks: Apple, Google, Microsoft, IBM stock_name = ['Apple', 'Google', 'Microsoft', 'IBM'] stock = [] style.use('seaborn-paper'...
bf0e1378a9c4e7227ae1c9ba350c358f84e02e9c
bryantbyr/LeetCode-solutions
/94. Binary Tree Inorder Traversal.py
1,413
3.828125
4
#94.Binary Tree Inorder Traversal # Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None #Created by bryantbyr on 20181019 #Time:O(n) #Space:O(n) #Tree + Recursion class Solution: def inorderTraversal(se...
dc2f22ca1f2e8683d08e7255b63923495dced9eb
CyberMobius/Partition_Number
/partition_number_generator.py
6,594
4.28125
4
class partition_number_generator: """A class for generating partition numbers. The results are cached for speed. For some instance X: - X.nth_partition_number(n) Returns the partition number for the number n """ def __init__(self): """Create an object that can calculate partiti...
09ee48510afca32f864ee1a49dc3c16f53f7ea19
marvinAlvarenga/SimpleBankingSystem
/simple_banking_system/banking/utils.py
474
3.828125
4
""" Utils. """ class LuhnAlgorithm: @staticmethod def get_luhn_sum(card_number): """Apply luhn algorithm. A returned value is ready to be added or checked with a checksum value. """ digits = [int(digit) for digit in card_number[:-1]] for i in range(len(digits))...
6ca4b3d854dc41e11d9caed1e2f391b6d712e080
The-Marauder/FizzBuzz
/Table maker.py
169
3.875
4
x = int(input("Enter a base number")) y = int(input("Enter a number to choose how long the table will last")) for i in range(1,y+1) : print(f'{x} x {i} = {x * i}')
2d9bc64fd4e76d29066e569a70f5cac9191dc590
jeelani-903/appcreate
/mohammed jeelani.py
1,811
3.609375
4
import pgzrun from random import randint WIDTH = 1000 HEIGHT = 550 player = Actor("monkey") player.bottom = HEIGHT player.x = WIDTH // 2 banana_y_speed = 0 missed = False score=0 bananas = [] def draw(): screen.clear() screen.blit("jungle.jpg" , (0,0)) player.draw() draw_bananas() display_score() if misse...
60e1831e9f35c5c3302d89c7a5ee400344079179
carmelbythesea/Loan-Default-Prediction
/src/data/etl.py
1,202
3.5
4
def clean_data(path, file_name, N_samples, rs): import pandas as pd import numpy as np from sklearn.utils import resample print("start of clean_data") df = pd.read_csv(path +"/"+ file_name) # create the target column # If maxoverduedays>90, we say that the borrower has defaulted on the loan...
5cbac01b7d4c3bffd62676eb1414eda2cd85d184
jjmaldonis/Data-Structures-Code
/p04/sssp.py
818
3.59375
4
import heapq def single_source_shortlest_path(self,n): #A heap pops off the thing that is the lowest in the heap queue = [] #queue = Heap() #Inserting as a tuple heapq.heappush(queue,(0,n)) dist = {n:0} path = {n:None} visited = {} while(len(queue)): #The following line actua...
f0f420a402387601f569280e8fc913d30e0d7d3a
EricMontague/Leetcode-Solutions
/medium/problem_11_container_with_most_water.py
630
3.84375
4
"""This file contains my solution to Leetcode problem 11: Container with Most Water.""" # time complexity: O(n), where 'n' is the number of elements in heights # space complexity: O(1) class Solution: def maxArea(self, heights: List[int]) -> int: maxArea = float("-inf") low = 0 high = len(h...
42273fb364e9af8ad0919c7a369842cb772d07ba
clesmes10/Exf
/ejercicio2.py
303
3.546875
4
# Escriba el codigo necesario para que al ejecutar python ejercicio2.py # se cree una grafica con una funcion sinusoidal entre 0 y 2pi. import numpy as np import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt x= np.linspace(0, 2*np.pi, 1000) y= np.sin(x) plt.plot(x,y, "m") plt.show()
d77fcb2e2961029c71358dc75e1aef029d52abc0
jeevii1071998/python-programming
/Beginner level/max element.py
172
4.1875
4
j=[] x=int(input("enter the no of elements:")) for i in range (1,x+1): d=int(input("enter elemenmt:")) j.append(d) j.sort() print("largest element is:",j[x-1])
cf1c36f12fc2c7dea1b2d763f679168bce8e9bf9
gessicamayara/PythonExercises
/World - 1/ex032.py
440
3.921875
4
#Faça um programa que leia um número qualquer, e mostre se ele é bissexto #(Um ano bissexto é o ano que tem um dia a mais) from datetime import date ano = int(input('Que ano voce quer analizar? Coloque 0 para atualizar o ano atual: ')) if ano == 0: ano = date.today().year if ano % 4 == 0 and ano % 100 != 0 or ano %...
bd5217359a0874dc8173571188cedb4e729ef156
green-fox-academy/bertokpeter
/week-03/day-03/envelope_star.py
634
3.6875
4
from tkinter import * root = Tk() canvas_width = 300 canvas_height = 300 canvas = Canvas(root, width=canvas_width, height=canvas_width) canvas.pack() # reproduce this: # [https://github.com/greenfox-academy/teaching-materials/blob/master/workshop/drawing/envelope-star/r2.png] center = canvas_width//2 def half_envel...
99f8e520d8471744e03c9a8088c7f16fde462b78
6185541513/exercism
/python/isogram/isogram.py
139
3.75
4
import re def is_isogram(string): str_alpha = re.sub('[^a-z]*', '', string.lower()) return len(str_alpha) == len(set(str_alpha))
8b758004f18ed3739494500eee8f95f58a83a36f
chiseungii/baekjoon
/01259.py
231
3.5625
4
while 1: s = input() if s == '0': break isPal = True for i in range((len(s) - 1) // 2 + 1): if s[i] != s[-i-1]: isPal = False break if isPal: print("yes") else: print("no")
e7c0878eee408af779c8d7183f1922bb8474590b
GhadeerElmkaiel/Segmentation_Metrics
/test.py
678
3.609375
4
import pandas as pd dict_one = {"A":1, "B":2, "C":3} dict_two = {"A":10, "B":20, "C":30} plcaeholder = {"A":0, "B":0, "C":0} test_dict = {"1":{}, "4":{}} test_dict["1"] = plcaeholder.copy() test_dict["4"] = plcaeholder.copy() test_dict["1"]["A"] = 1 test_dict["4"]["B"] = 5 # print("plcaeholder: ") # print(plcaeholde...
bca6fa2ec55b2b90da99f9d7a09bd14161efbb65
eaamankwah/Fundamentals-of-Computing
/Course5-Algorithmic-Thinking1/Project1-Degree-Distribution-for-Graphs/degreeDistribution.py
2,855
4.0625
4
# Project #1 Description # Degree distributions for graphs # https://www.coursera.org/learn/algorithmic-thinking-1/supplement/hw1o3/project-1-description ''' three graph examples prescribed by the assingment; see project1.png set of test case graphs at: http://storage.googleapis.com/codeskulptor-alg/alg_module1...
3340deba432f18cfebb317231f04d3178ad54275
devprofe/python
/guia1_forEjercicio3.py
311
3.96875
4
celsius = [] kelvin = [] fahrenheit = [] for x in range(3): celsius.insert(x, float(input("Ingrese Celsius: "))) kelvin.insert(x, celsius[x] + 273.15) fahrenheit.insert(x, ((kelvin[x] - 273.15) * 1.8) + 32) print("Celsius: ", celsius) print("Kelvin: ", kelvin) print("Fahrenheit: ", fahrenheit)
1bc3dd4e0c589252145d24fca02253a522f8783b
leandirangu/pythonCollection
/defarea.py
326
3.921875
4
def area_triangle (base,height): return 0.5*base*height def area_circle (radius): return 3.14*radius*radius def area_rectangle(base,height): return base*height height,base, radius = 50,70,14 print ("area of triangle {}".format (area_triangle(base,height))) print("area of circle {}".format(area_circle(rad...
e92514a1aaa20c27ca27e480e9557cd485694d72
zjg39/americanHistoryQuizGame
/quiz.py
2,816
4.1875
4
# Quiz Game Project import time print('Welcome to the Quiz!') readyornot = input('Are you ready to play? ').lower() if readyornot.lower() != 'yes': print('Okay, we\'ll see you next time!') quit() else: print('Okay, let\'s play a game!') time.sleep(2) score = 0 answer1 = input('How many stripes does the...
66173427529b11b085c4fe8f5793422283d10753
Goel-Akshit/Algorithms
/Python/Binary Search Tree/BST.py
14,601
3.78125
4
#BST DS helps to perform insertion, Deletion, Search in O(logn). only if its basic property is maintain. # to maintain its basic property and keep the time complexity of all operation caped at O(logn) one need to keep it balance #one of the approaches to keep it balance is AVL implementation of BST. #so this is a AV...
15fa7aea30fe549108819b6607c756b3a079eb47
Balaji-V19/Python
/update_function4.py
163
3.71875
4
def funct(dic): for i in range(1,21): dic[i]=i**2 for x,y in dic.items(): print(x) dic=dict() funct(dic)
188cf881432a8b4c4d7cc346134e6bc47fb798e9
Pumpkintitan/advent-of-code-2020
/day3/day3.py
300
3.75
4
file = open("day3.txt").read().split("\n") def slope(x, y): tc = 0 s = x sy = y while sy < len(file): if file[sy][s % len(file[0])] == "#": tc += 1 s += x sy += y return tc print(slope(1, 1)*slope(3, 1)*slope(5, 1)*slope(7, 1)*slope(1, 2))
e29658b512849c475d1f8b172eeeb11a4f9863cf
NisseAnd/P-Info
/library/privat_parking.py
1,379
3.5625
4
import pandas as pd import numpy as np """ Vis fordelingen af private parkeringspladser og parkeringsmuligheder for el-biler ift hver bydels gennemsnitlige bruttoindkomst. """ def privat_parking_electric_cars(data, data_income): # pivot table is a table of statistics that summarize the data of a more extensiv...
c5a2b5c4d28b9339e292d5f77ef831b68b540e27
KedroBoss/Python-Mega-Course
/DataBase/script1.py
1,058
3.59375
4
import sqlite3 def create_table(): conn=sqlite3.connect('lite.db') cur=conn.cursor() cur.execute("CREATE TABLE IF NOT EXISTS store (item TEXT, quantity INTEGER, price REAL)") conn.commit() conn.close() def insert(item, qu, price): conn=sqlite3.connect('lite.db') cur=conn.cursor() cur.e...
c1295af09ac9779bbf50088f2d23282666c7aba7
DesignisOrion/Data-Sci-Misc
/methods.py
149
3.84375
4
place = "poolhouse" place_up = place.upper() print(place) print(place_up) print(place.count('o')) # Introduced to count(), help(str)
a356708b128d59fa5cc8b84627f9c82fdd884d6d
udoy382/PyTutorial_telusko
/tut_51.py
535
3.828125
4
class Computer: def __init__(self): self.name = 'Udoy' self.age = 28 def update(self): self.age = 30 def compare(self, other): if self.age == other.age: return True else: return False c1 = Computer() c1.age = 30 c2 = Computer() # print(id(c...
04f0807018faa05e702de4e8e3f96f7245416c72
akshayparakh25/wikipediaInfoboxExtractorForInformationExtraction
/dump.py
408
3.65625
4
import csv import pickle def dump_dictionary(fileName, dictionaryName): print("dumping "+fileName) with open(fileName, 'wb') as handle: pickle.dump(dictionaryName, handle, protocol=pickle.HIGHEST_PROTOCOL) def dump_dictionary_csv(fileName, dictionaryName): with open(fileName, "w+") as csv_file: writer = csv.w...
3e2c622860202c00d93a1fc93d20b8965c127af8
mecomontes/Higher-Level-Programming
/0x07-python-test_driven_development/3-say_my_name.py
604
4.375
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- """ Created on Thu May 21 17:43:34 2020 @author: Robinson Montes """ def say_my_name(first_name, last_name=""): """ priint a full name Args: first_name (str): First string to print last_name (str): second string to print Raises: Typ...
adf9121e18a3e51b17cf10ee2e84d6e5dd2123c2
sip227/lab-09-functions
/factorial.py
305
3.96875
4
def factorial(n): total = 1 for i in range(n): total = total * (n - i) print("Current i is " + str(i)) return total userstring = input("Number please: ") usernum = int(userstring) print(str(usernum) + "! is " + str(factorial(usernum)))
cb996fe906e647d442cc9756d255cf0685b108ab
BennyJane/python-demo
/list_dict_set_tuple/_set.py
1,100
3.984375
4
# !/usr/bin/env python # -*-coding:utf-8 -*- # PROJECT : Python-Exercise # Time :2020/12/29 18:04 # Warning :The Hard Way Is Easier s1 = {1, 2, 3, 4, 5, 6} s2 = {5, 6, 7, 8, 9, 10} # 删除操作: 输入值 s1.remove(1) print("删除数据", s1) # 弹出: 不接收参数,默认弹出索引为0的数据; 当元组为空,抛出keyValue res = s1.pop() print("弹出数据", res, s1) #...
e1961371fb1eb62bcbdd994754e07ebdfa22c926
JeffryHermanto/Python-Programming
/05 Data Structures/03_list_unpacking.py
215
4.25
4
# List Unpacking numbers = [1, 2, 3] first, second, third = numbers print(first) print(second) print(third) print("") numbers = [1, 2, 3, 4, 5, 6, 7, 8] first, second, *other = numbers print(first) print(other)
c9a62e6b6c4653f43479837c4dd388a762a41748
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/sort/552fb470-1124-4d4b-b281-e1c216240b9a__insertion_sort.py
822
3.640625
4
''' Created on 2011-09-17 @author: Alec ''' def insertion_sort(items): sorted_items = [items.pop()] while items: item = items.pop() for index, sorted_item in enumerate(sorted_items): if item < sorted_item: sorted_items.insert(index, item) ...
fb7338d6acf86e910c8959de44972e08228b2b7d
alexdosreissilva/python-help
/atributos_privados.py
559
3.609375
4
# coding=UTF-8 class Ponto(object): def __init__(self, x, y): self.__x = x self.__y = y def get_x(self): return self.__x def get_y(self): return self.__y def set_x(self, x): if x > 0: self.__x = x def set_y(self, y): if y > 0: ...
626b2cdc061166f2d6f6b5a4a7c577110ec6d40e
Rolf1e/go-l3
/main.py
1,798
3.515625
4
import playerlib import gamelib import matplotlib.pyplot as plt import time def graph(x, y, xlabel, ylabel): plt.figure(figsize=(5, 5)) plt.plot(x, y, label="performance") plt.title("Monte carlos Go") plt.xlabel(xlabel) plt.ylabel(ylabel) plt.legend() plt.show() # plt.grid() def game(d...
0d241e34e706e3ed53fabb7c6c66ff7e302c44fe
Absurd1ty/Python-Practice-All
/findWords.py
624
3.875
4
"""Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below. """ class Solution: def findWords(self, words: List[str]) -> List[str]: top = set('qwertyuiopQWERTYUIOP') middle = set('asdfghjklASDFGHJKL')...
9359b3435914f649b40c98a823a53304aeb36e37
T-Litt-zz/filesort
/filesort.pyw
2,872
3.734375
4
from os import listdir, mkdir from os.path import isdir, isfile, join, exists from shutil import move from tkinter import * from tkinter import ttk, messagebox def filesort(): if messagebox.askyesno(message=f"Are you sure you want to sort all the files in {path.get()}?", icon="...
653ce0e6f038dc98eed78beabc50ef43534bacd3
qiangwennorge/AlgorithmInPython
/DownHeapify.py
1,413
3.515625
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 19 19:05:51 2017 @author: qiangwennorge """ L = [50,88,27,58,30,21,58,13,84,24,29,43,61,44,65,74,76,30,82,42] # Heap shortcuts def left(i): return i*2+1 def right(i): return i*2+2 def parent(i): return (i-1)/2 def root(i): return i == 0 def leaf(L,i): ...