blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
498046b4bf2682fdfbedd5e55516d9e5a2b420df
nima-siboni/recruiter-problem
/plotter.py
609
3.53125
4
import numpy as np import matplotlib.pyplot as plt def plot(x_y_data, title='', xlabel='x', ylabel='y', xtics=1, filename='.res.png'): """ A simple plotter """ plt.scatter(x_y_data[:, 0], x_y_data[:,1]) # making title plt.title(title) # making labels plt.xlabel(xlabel) pl...
77bbefb945e77313b2bc7f5590172ad92cfec5a2
YujiaBonnieGuo/learn_python
/ex39错误处理.py
7,025
4.3125
4
# 在程序运行的过程中,如果发生了错误,可以事先约定返回一个错误代码,这样,就可以知道是否有错,以及出错的原因。在操作系统提供的调用中,返回错误码非常常见。比如打开文件的函数open(),成功时返回文件描述符(就是一个整数),出错时返回-1。 # 用错误码来表示是否出错十分不便,因为函数本身应该返回的正常结果和错误码混在一起,造成调用者必须用大量的代码来判断是否出错: def foo(): r=some_function() if r==(-1): return (-1) #do something return r def bar(): r=foo() if r=...
f81278e623c5d00f379826f51e090a98cf8b159a
Tarik-INC/VicesaBot
/email/check_email.py
293
3.84375
4
import re def check_email(email): error = false if (re.search(".+@.+com")) raise ValueError("Email read from file isn't in the correct format") elif not(re.search(".+@.+com\s*.")): raise ValueError("The file has two or more email address in the same line")
8d2e34d72fbee981ad2003d7574d974e7f580dd5
codewithshubham/pes_python_assignmentsset-1
/6.py
309
3.71875
4
x = "Hello_World " print x print ("Characters in %s are " %x) for i in x: print i first=x[0:5] second=x[6:] print("Printing %s 100 times using repeat operator ") print(x*100) print("Sub string of %s is " %x) print first print second print("Concatination of %s and %s is %s" %(first ,second,first+second))
59c423140b030c6d7e1e3757f2016c1e9830eb1f
Moanana/grammatik
/PROJEKT_test.py
2,510
3.515625
4
######importe###### import spacy nlp=spacy.load("de") from PROJEKT_defs import * ######code####### print ("GRAMMARCHECK") print ("Gib einen Satz ein:") while True: eingabe= nlp(input(">>> ")) ###funktionenzuweisung### for token in eingabe: # print(token.pos_) if "DET" in token.pos_: ARTIKEL(token.text) ...
bfcf4e1b75a53e7bfc99955e878ac53639261a91
GuhanSGCIT/Trees-and-Graphs-problem
/Shin chan cheese.py
1,754
3.96875
4
""" Shin chan is a health-conscious mouse who loves eating cheese. He likes cheese so much that he will eat all the available cheeses. Currently, he has N cheese with distinct calorie value a1,a2,...,an. Shin chan wants his total calorie intake to be K. To achieve his calorie diet, he can steal at most 1 cheese such...
f41242392bc6181da1c30befcebc08c3516f2847
tur-ium/WWW_physics_BSc
/networkx_extended.py
1,383
3.5625
4
# -*- coding: utf-8 -*- """ Created on Fri Feb 2 18:33:25 2018 @author: Ramandeep Singh @author: Artur Donaldson #TODO: Add functionality for adding DiGraphs #TODO: Add functionality for adding MultiDiGraphs #TODO: Use this to make timslices """ from networkx import * import random class Graph(Graph)...
3c97a77328b1d3aab11cee894954b7602543a41f
fpelaezt/devops
/Python/Workbook/1-4.py
337
3.921875
4
lenght = input("Please insert the lenght of the field : ") lenght_float = float(lenght) widht = input("Please insert the widht of the field : ") widht_float = float(widht) area = lenght_float * widht_float acrefactor = 43560 print("The area of the field is", area, "square feet") print("This is equivalent to", area/acre...
abd325f5e5a90cf5a3c84e506eac6a3d7c6102f3
Tylerman90/LPTHW
/ex36.py
1,332
3.921875
4
from sys import exit def eddie(): print("You're in the middle of gunfire!") print("Run away! or Start shooting?") choice = input("> ") if "run" in choice: print("You are shot in in the head while running away and find yourself back on the beach") start() elif "shooting" in choice: print("You win the shoot...
2f9a472c4149086fa82e313099bfa218da7e8fa1
lakshyatyagi24/daily-coding-problems
/python/27.py
1,510
4.1875
4
# ---------------------------- # Author: Tuan Nguyen # Date: 20190609 #!solutions/27.py # ---------------------------- """ Given a string of round, curly, and square open and closing brackets, return whether the brackets are balanced (well-formed). For example, given the string "([])[]({})", you should return true. ...
9601b76db6f7e0b85cff7ee5a7da0559460ed987
gousiosg/attic
/coding-puzzles/ch3.py
1,255
3.703125
4
#!/usr/bin/env python3 import random class Stack_3_2(): def __init__(self, init_size = 10): self.stack_size = init_size self.back_arr = [None] * init_size self.head = 0 def push(self, num): if self.head == 0: minimum = num else: minimum = min(sel...
f4dc3d5c07302d9794c78388fcc533112f18b5ac
bhav09/data_structures
/Arrays/NaiveApproach_SecondLargestElement.py
400
4.1875
4
#returning the index of the second largest element def SecondLargest(arr): max_ele=arr[0] for i in range(len(arr)): if arr[i]>max_ele: max_ele=arr[i] sec=-1 for i in range(len(arr)): if arr[i]!=max_ele: if arr[i]>sec: sec=arr[i] if sec==-1: print('No second largest element') else: ...
1c5e0efd9aaaffe15137ec0c395532830d0ffd66
M0use7/python
/python基础语法/day7-字典和集合/03-字典相关的运算.py
1,919
3.796875
4
"""__author__ = 余婷""" # 1.字典不支持'+'和'*' # 2. in 和 not in : 是判断key是否存在 computer = {'brand': '联想', 'color': 'black'} print('color' in computer) # 3.len() print(len(computer)) # 4.字典.clear() # 删除字典中所有的元素(键值对) computer.clear() print(computer) # 5.字典.copy() # 拷贝字典中的所有的元素,放到一个新的字典中 dict1 = {'a': 1, 'b': 2} dict2 = dict1 ...
777ec29ee5d34bb092d0f45f7cc7e493dcb2e66a
shahad-mahmud/learning_python
/day_1/taking_input.py
193
4.1875
4
# input() -> takes input name = input('Enter your name: ') age = input('Enter your age: ') print(name, 'is', age, 'years old.') # write a program to take your name as input # print the value
134d74d8764c6c71d3da93914b055c6a651b8a27
GordonWei/python-ftp
/getfile.py
593
3.78125
4
#!/usr/bin/env python3 # -*- coding: utf8 -*- #author GordonWei #date 07/31/2020 #comment connect ftp and get file from ftplib import FTP filterName = input('Pls Enter The FileName:' ) filterName = filterName + '*.*' ftp = FTP() ftp.connect(<ip>,<port>) ftp.login(<loginuser>, <userpasswd>) def get_File(filt...
0b666b0bb53224cbf66872cb3d916364432f7d1a
eduardosacra/learnpython
/semana7/exercicios/4removendo_repeditos.py
833
3.96875
4
# Exercício 4 - Removendo elementos repetidos # # Escreva a função remove_repetidos que recebe como parâmetro uma lista com números inteiros, verifica se tal lista possui elementos repetidos e os remove. A função deve devolver uma lista correspondente à primeira lista, sem elementos repetidos. A lista devolvida deve es...
5817cca865ebf601719aaec569f38004be651f5d
PaulRitsche/programming-for-life-sciences
/our_package/math.py
724
3.890625
4
"""Collection of math functions.""" def add_integers(*args: int) -> int: """Sum integers. Arguments: *args: One or more integers. Returns: Sum of integers. Raises: TypeError: No argument was passed or a passed argument is not of type `int`. Example: ...
49cd3106fd2a476c326af620911f85961e708ef7
kaustubhharapanahalli/MWP
/prog3.py
119
4.03125
4
number = input("Enter a number: ") number = int(number) if number % 2 == 0: print("Not Weird") else: print("Weird")
6230af1cb52f1083855b7353eeea3b80562f5d4f
katavasija/python_basic_07_09_2020
/les6/task1.py
3,087
3.5625
4
""" Создать класс TrafficLight (светофор) и определить у него один атрибут color (цвет) и метод running (запуск). Атрибут реализовать как приватный. В рамках метода реализовать переключение светофора в режимы: красный, желтый, зеленый. Продолжительность первого состояния (красный) составляет 7 секунд, второго (желтый) ...
ec560397c393da2d8edef59287b535d1327e2879
herbertguoqi/drivercommend
/logic/recommend.py
769
3.625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- #抽象类加抽象方法就等于面向对象编程中的接口 from abc import ABCMeta,abstractmethod class recommend(object): __metaclass__ = ABCMeta #指定这是一个抽象类 @abstractmethod #抽象方法 def Lee(self): pass def Marlon(self): pass class recommendImplDB(recommend): def __init...
9d532e1c6e09afe6ee7e0120257f547d4602b5a9
charlie-choco/my-first-blog
/djangogirls.py
360
3.6875
4
def hi(name): if name=='ola' : print('hey Ola!') elif name == 'sonia': print('hey sonia!') else: print('hey lilou!') hi("ola") hi("sonia") hi("doug") def hi(name): print('hi' + name + '!') girls = ['Rachel', 'Monica', 'Phoebe', 'Ola', 'You'] for name in girls: hi(name) print('next girls') for i in range(...
c18dd83d61193ce02e57e75b105019b3b727b2f0
renchong1993/LeetCode-Daily
/Leet Code #110 Balanced Binary Tree.py
638
3.78125
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 isBalanced(self, root: TreeNode) -> bool: def get_height(root): if root is ...
979e90ba79dac69d08a6c0f6f45e0221dedbd46f
mickeymoon/pylists
/intersectionOfSortedLists.py
532
4.03125
4
from list import Node from list import LinkedList def intersectionOfSortedLists(a, b): result = LinkedList() while a and b: if a.data == b.data: result.append(a.data) a, b = a.next, b.next elif a.data > b.data: b = b.next else: a = a.next ...
bab1bd4572af62117c8e0fd29acce27b4d0945cb
not-notAlex/holbertonschool-low_level_programming
/0x1C-makefiles/5-island_perimeter.py
618
3.875
4
#!/usr/bin/python3 """ module for perimeter """ def island_perimeter(grid): """ returns perimeter of an island """ total = 0 for x in range(0, len(grid)): for y in range(0, len(grid[0])): if grid[x][y] == 1: if x == 0 or grid[x - 1][y] == 0: ...
7cc3c247789ba57c0d38ba7b550e405957c5c3a8
abhipec/HAnDS
/src/HAnDS/url_conversion_helper.py
3,080
3.75
4
""" This file contains various function related to url encoding-decoding. """ import urllib.parse __author__ = "Abhishek, Sanya B. Taneja, and Garima Malik" __maintainer__ = "Abhishek" def sanitize_url(url): """ Convert url to Wikipedia titles. """ title = urllib.parse.unquote(url) # Remove '#' fr...
f4b02bdcc4ae1a21f6cb47e462388b170c6bd342
TimothySjiang/leetcodepy
/Solution_36.py
697
3.671875
4
class Solution: def isValidSudoku(self, board: List[List[str]]) -> bool: rows = [set() for i in range(9)] cols = [set() for i in range(9)] squares = [set() for i in range(9)] for i in range(9): for j in range(9): if not board[i][j] == '.': ...
2c6f77a948405457f3d7795a6c8deeaee96a6297
orozcosomozamarcela/Paradigmas_de_Programacion
/quicksort_mejorado.py
1,756
4.1875
4
def quick_sort(lista): """Ordena la lista de forma recursiva. Pre: los elementos de la lista deben ser comparables. Correo: la lista está ordenada.""" _quick_sort ( lista , 0 , len ( lista ) - 1 ) def _quick_sort ( lista , inicio , fin ): """Función quick_sort recursiva. Pre: los índices ini...
cca2ab5bb6dc2ba7a079775650fdac621cae2748
mironmiron3/SoftUni-Python-Advanced
/StacksAndQueues/Firework.py
1,244
3.8125
4
from collections import deque firework_effects = deque([int(el) for el in input().split(", ") if int(el) > 0]) explosive_powers = [int(num) for num in input().split(", ") if int(num) > 0] palms = 0 willows = 0 crossettes = 0 ready_with_fireworks = False while not ready_with_fireworks: if not firework_effect...
50775c960ca6a5f639012fdc4c8b74ea0d36a77d
mostafa-asg/Algo
/geeksforgeeks/bit-magic/find-first-set-bit/solution1.py
640
3.5625
4
#{ #Driver Code Starts #Initial Template for Python 3 import math # } Driver Code Ends #User function Template for python3 ##Complete this function def getFirstSetBit(n): def find(n, counter): n, rem = divmod(n, 2) if rem == 1: return counter + 1 else: return ...
134f1c40de3c7ba900dd7cd8d4f30af20b8322da
bestyoucanbe/joypypr0901sensitiveinfo
/patient.py
3,887
3.9375
4
# Practice: Sensitive Information # Create a class to represent a patient of a doctor's office. The Patient class will accept the following information during initialization # Social security number # Date of birth # Health insurance account number # First name # Last name # Address # The first three properties should...
5e614a8bb2d4ae875aad2ce46c91fa25b72aa5f9
NikolaosPanagiotopoulos/PythonLab
/lectures/source/lecture_05/lecture_05_exercise_3.py
516
3.578125
4
temp = [] i = 0 while i < 30: num = int(input("Δώσε θερμοκρασία: ")) temp.append(num) i += 1 maxThesi = 0 minThesi = 0 i = 0 while i < len(temp): if temp[i] < temp[minThesi]: minThesi = i if temp[i] > temp[maxThesi]: maxThesi = i i += 1 print("Η μέγιστη θερμοκρασία είναι", t...
148a215eac0ce8ff3b0e681e55bb76fad93fcc39
bukurocci/AtCoder
/ABC049C/code.py
328
3.65625
4
S = str(input())[::-1] pos = 0 words = [s[::-1] for s in ["dream", "dreamer", "erase", "eraser"] ] res = "YES" while True: if(pos >= len(S)): break ok = False for word in words: if(S[pos:pos+len(word)] == word): ok = True pos += len(word) break if(not ok): res = "NO" break prin...
e67aef37361be03b76823caef3b317a9875d2c69
matheusglemos/Python_Udemy
/Declarações em Python/Range/range.py
467
4.34375
4
# Projeto em python 3 referente a aula 30 do Curso python da plataforma Udemy. # Gerando uma lista de 0 à 9 com a função 'Range' e exibindo-a em seguida a = range(0,10) print(list(a)) # Exibindo o tipo do objeto 'range' print(type(a)) # Gerando uma nova lista com parâmetros start/stop e exbindo-a em seguida start = ...
937efafceac114b232355141fb59e9fd2cf51ae2
Mateo2119/Ejercicios-psba
/83 operaciones binario/modulo.py
1,098
3.890625
4
# -*- coding: utf-8 -*- """ Crear un módulo que maneje funciones para operar en sistema binario, las operaciones que se deben implementar son suma, resta, multiplicación y división. """ def a_entero(num): l = len(num) - 1 entero = 0 for i in num: potencia = 2 ** l entero =...
c7612d8f575f6bcb378e7b948e47961b0eb2c9e8
daniel-reich/ubiquitous-fiesta
/YzZdaqcMsCmndxFcC_22.py
186
3.578125
4
def centroid(x1, y1, x2, y2, x3, y3): if (x1-x2)*(y1-y3) == (y1-y2)*(x1-x3): return False else: x = round((x1+x2+x3)/3, 2) y = round((y1+y2+y3)/3, 2) return (x, y)
ae2006d87334b1c865825db8a0eb9aefcc897d25
Shijie97/pandas-programing
/ch06/1-gruopby&aggregate.py
4,442
3.71875
4
# !user/bin/python # -*- coding: UTF-8 -*- import pandas as pd import numpy as np # gruopby函数,根据某一列或者某几列将数据帧分组 df = pd.DataFrame({'Country':['China','China', 'India', 'India', 'America', 'Japan', 'China', 'India'], 'Income':[10000, 10000, 5000, 5002, 40000, 50000, 8000, 5000], ...
b64a40c841d2fcd86d5bc733559c05743a53ede7
mhaytmyr/Algorithms
/AlgorithmOnGraphs/dijkstra/dijkstra.py
1,782
3.671875
4
#Uses python3 import sys from queue import Queue,PriorityQueue def Dijkstra(adj, s, t): dist, prev = {},{} for vertex in adj: dist[vertex] = sys.maxsize prev[vertex] = None dist[s] = 0 p = PriorityQueue() #initilize priority queue to hold visited nodes p.put((dist[s],s)) while not p.empty(): curr_dist,...
e63963c850ac4d2d14fe2607503071f19541e600
StevenBryceLee/TripScheduling
/TripScheduling/TimePriorityQueue.py
789
3.96875
4
class TimePriorityQueue: ''' This class is a priority queue based on the trip class. Note, it is sorting based on the date attribute of each element in the queue This will only work based on the Trip class currently, but could be modified ''' def __init__(self): self.q = [] def ins...
bd24872ab370d6f75b0d506a2489ae4d701b339f
DmitryPukhov/pyquiz
/test/leetcode/test_SmallerNumbersThanCurrent.py
344
3.71875
4
from unittest import TestCase from pyquiz.leetcode.SmallerNumbersThanCurrent import SmallerNumbersThanCurrent class TestSmallerNumbersThanCurrent(TestCase): alg = SmallerNumbersThanCurrent() def test_smaller_numbers_than_current(self): self.assertListEqual([2, 1, 0, 3], self.alg.smaller_numbers_than...
10230b94ed8332c20d0707515ec7a7c0dec12339
Mud-Phud/my-python-scripts
/média.py
318
3.890625
4
primeira_nota =float(input("Digite a primeira nota: ")) segunda_nota =float(input("Digite a segunda nota: ")) terceira_nota =float(input("Digite a terceira nota: ")) quarta_nota =float(input("Digite a quarta nota: ")) print("A média aritmética é",(primeira_nota+segunda_nota + terceira_nota + quarta_nota)/4)
b5395a0ced5c77398d6cb024c78b69ced92c6169
ky7527/Python
/baekjoon/10809.py
205
3.65625
4
# 알파벳 찾기 S = input() abc = 'abcdefghijklmnopqrstuvwxyz' for i in abc: if i in S: # S에 알파벳 존재 유무 확인 print(S.index(i), end=' ') else: print(-1, end=' ')
e894bcd3631e7dbbc9af7b1473a311fd77219f3d
kumar-akshay324/projectEuler
/proj_euler_q021.py
1,304
3.78125
4
# Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). # If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers. # # For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 11...
077bb7b34b1d1d8f861a4136e567c3e8ae640b2e
OlegLeva/udemypython
/10/task_1.py
519
3.921875
4
my_string = 'Hello Python!' print(my_string[3]) print(('Hello Python!')[3]) print(('Hello Python!')[0:2]) my_string = 'Hello Python!' print(my_string[:2]) # 'Path' из строки 'Hello Python!' my_string = 'Hello Python!' new_string = my_string[6] + 'a' + my_string[8:10] print(new_string) my_string = "z"*7 print(my_st...
02864406af3182530e7308231f7fb770cc15b1ef
romch007/projetnsi
/src/algo.py
6,064
3.703125
4
import math def create_dict(nodes, relations): """Crée une liste d'adjacence à partir d'une liste de noeuds et de relations""" result = {} # Pour chaque noeud for node in nodes: id = node[0] neighbours = [] # Pour chaque relation for relation in relations: s...
2fc593dfa8ceb20273bdf471bb48c423aa004c0b
jorgeescorcia/EjerciciosPython
/Ejercicios/numero mayor menor igual.py
1,485
4.125
4
#Realizar un programa en python que pida 2 numero por teclado y diga, #si es mayor o menor o igual. print ("---------------------------------------") print ("|Calcular Mayor, Menor , igual|") print ("---------------------------------------") print ("1. Mayor") print ("2. Menor") print ("3. Igual") print...
ca348953510d92c4825728aced3cef01806beb05
JAcciarri/Simulation
/TP2.2/distributions.py
2,585
3.5
4
# -*- coding: utf-8 -*- from numpy.random import random from numpy import floor, log as ln, exp # Uniform Distribution Generator def uniform(a, b): r = random() x = a + (b - a) * r return x # Normal Distribution Generator def normal(m, d): sum = 0 for _ in range(12): r = random() ...
68465be1102e43fa84044b5ed1b1aee5a0456495
SimeonTsvetanov/Coding-Lessons
/SoftUni Lessons/Python Development/Python Fundamentals September 2019/Problems And Files/07 EXERCISE DATA TYPES AND VARIABLES - Дата 27-ми септември, 1430 - 1730/01. Integer Operations.py
521
3.75
4
""" Data Types and Variables - Exercise Check your code: https://judge.softuni.bg/Contests/Practice/Index/1722#0 SUPyF2 D.Types and Vars Exercise - 01. Integer Operations Problem: Read four integer numbers. Add first to the second, divide (integer) the sum by the third number and multiply the result by the four...
7c841c2df2cdaf078a6634786e8ac33f21f61aac
KattieCam/WK15-test
/final.py
3,124
3.59375
4
""" Kattie Cameron-Ervin ITEC 1150-60. This is my Random Recipe Cookbook, final coding that's going to generate a few random taco recipes, as well a random photo of a taco. """ import requests from PIL import Image, ImageDraw, ImageFont import docx im = Image.open('tacos-unsplash.jpg') # this open my image width = ...
d1f09f96e52d1a4eb3346bfaace92e1fc1bd0257
zimorodokan-edu/Hyperskill-Python--Coffee-Machine
/main.py
5,702
4
4
class CM: def __init__(self): self.water = 400 self.milk = 540 self.beans = 120 self.cups = 9 self.money = 550 self.operate_state = None def print_state(self): print() print('The coffee machine has:') print(f'{self.water} of water') ...
fccd91fd48f4bb1a49df382c13dcc5683792ca3c
ABean06/Coursera
/Misc/Chapter9ownextras.py
1,109
4.03125
4
counts = dict() print 'Enter a line of text' line = raw_input('') words = line.split() #update if capital letters print 'Words:', words print 'Counting...' for word in words: counts[word] = counts.get(word,0) + 1 for key in counts: print key, counts[key] #print list(words) - this will print out the keys onl...
b1e1c33df45e71a3a2d39df8e49e350ae0f51794
tolekes/new_repo
/conditionals.py
375
4.03125
4
# name = input("Enter your name:") # if 'a' in name: # print("my name has an a-vowel") # print("i love my name") # print("my name rocks") # else: # print("wrong name") if 1==1:print("you are right");print("ok, lets go") Acredited_voters = 100,000 voters = 120,000 if voters>Acredited_voters:print("co...
68b35cb9ef51fb98de277741169bfcc5df92c30d
C-VARS/cvars-back-end
/script/Facades/UserRegisterFacade.py
575
3.546875
4
from typing import Dict class UserRegisterFacade: def __init__(self, connection): self.connection = connection def register_user(self, user_info) -> Dict: """ An method to register a new user with user_info in the database :param user_info: JSON format argument that contains...
4fca7a950af1107a65f4abdf741746a71015c038
allenxzy/Data-and-Structures-and-Alogrithms
/python_data/Chapter 1/P/P-1.33.py
385
3.65625
4
#-*-coding: utf-8 -*- """ Write a Python program that simulates a handheld calculator. Your program should process input from the Python console representing buttons that are “pushed,” and then output the contents of the screen after each operation is performed. Minimally, your calculator should be able to process the...
eb9bfd62db1e67b1d0fd6ff928daaa61422331a1
nderkach/algorithmic-challenges
/reverse_words.py
445
3.640625
4
# def reverse_words(message): # m = ''.join(message[::-1]) # return ' '.join([e[::-1] for e in m.split()]) def reverse_words(message): m = list(message) m = m[::-1] j = 0 for i in range(len(m)+1): if i == len(m) or m[i] == ' ': m[j:i] = m[j:i][::-1] j = i + 1 ...
50d618086c3dfd5ac6c98bdacd9683c1c6567c0a
Sambou-kinteh/Pythonmodules
/tkinter_f_math_bionomial.py
6,756
3.59375
4
import tkinter from tkinter import* import math from tkinter import messagebox import webbrowser root = Tk() root.geometry('600x200+50+50') root.title('Bionomial Theorem') #---------------------------------FUTURE PROGRESS- (A+X)(X+Y)(1+X)(CALCULUS)----------------------# root.maxsize(width = 650, height ...
9fca8045797d89aba8e6db9cbd6631bb060a93bb
UWPCE-PythonCert-ClassRepos/220-Advanced-Summer-2019
/students/JonSerpas/lesson03/assignment/src/basic_operations.py
3,843
3.53125
4
import peewee database = peewee.SqliteDatabase("customers.db") try: database.connect() except Exception as e: print(e) database.execute_sql('PRAGMA foreign_keys = ON;') # <-- can use this to execute sql cmds # database.execute_sql('drop table if exists customer;') class BaseModel(peewee.Model): class ...
997b9263418e66f3ec852105c83aa3113996a334
mamemilk/acrc
/プログラミングコンテストチャレンジブック_秋葉,他/src/2-4-3_03_arc097_b__TLE__.py
1,384
3.5
4
# https://atcoder.jp/contests/arc097/tasks/arc097_b class UnionFind(): def __init__(self, N): self.parent = [i for i in range(N+1)] self.rank = [0 for _ in range(N+1)] self._members = [ [i] for i in range(N+1)] def root(self, x): return x if self.parent[x] == x else se...
7c9cd494da22e2ab209287da81e7eaa196d634b1
Light2077/LightNote
/python/python测试/example/vector/vector.py
607
3.625
4
class Vector: def __init__(self, x, y): if isinstance(x, (int, float)) and \ isinstance(y, (int, float)): self.x = x self.y = y else: raise ValueError("not a number") def add(self, other): return Vector(self.x + other.x, ...
40cbf970b27a593571951cf471250eba2f023199
kodyellis/Python
/testingfinal/testing months final .py
974
3.734375
4
# -*- coding: utf-8 -*- """ Created on Sun Dec 10 14:02:04 2017 @author: Kody Ellis """ #august and september wont work for some reason months = { "January" : "01", "Febuary": "02", "March": "03", "April": "04", "May": "05", "June": "06", "July"...
9b99c35e6cfe78261b935b4a5ccda69901940e8f
davidfoster0127/sorting-simulation
/bubblesort.py
492
3.890625
4
class BubbleSort: def __init__(self): self.spaceUsed = 0 self.name = "BubbleSort" print("Init BubbleSort") def sort(self, arr): n = len(arr) self.spaceUsed = n done = True self.spaceUsed += 1 while done: done = False f...
7af444d05e6592699891ba8bd6f109ce4cf7c2a8
xw-nie/practice
/lesson8.py
622
3.96875
4
# coding:cp936 import os def search(key,address): file_list = [] for path,dirnames,filenames in os.walk(address): print('search'+path+'...') for name in filenames: if key in name: file_list.append(path+'\\'+ name) ''' with open(path+'\\'+name)...
bc4e182ae8e3b6bedfe96f45949df31e1f88fe3a
beatobongco/MITx-6.00.1x
/Week_2/fe_8_gcd_iter.py
269
3.890625
4
def gcdIter(a, b): ''' a, b: positive integers returns: a positive integer, the greatest common divisor of a & b. ''' # Get smaller smaller = a if a > b: smaller = b for i in range(smaller, 0, -1): if a % i == 0 and b % i == 0: return i
e2994ba77010c8b31314e05879224881d74a3e1c
jnaylor92/python-package-documentation-example
/my_docs/helpers/helper_one.py
708
4.09375
4
""" Helper Class for doing something """ class HelperOne: """ Simple helper class """ def __init__(self, msg): """ Constructor :param msg: A message to print :type msg: str """ print('__init__') self._msg = msg def print_it(self): ...
dd46177fba22bee7936b80778453a10625834e89
SofiaLouisy/testing
/unittesting/test_examples.py
520
4
4
import unittest class NumberTest(unittest.TestCase): """ Uses subtest to display all tests within a test method """ def test_even_numbers(self): """ with subtest, all failures are shown """ for i in range(10): with self.subTest(i=i): self.ass...
d3afdf56261f4d5ff7fb6d2810577568bf382969
cameron9100/Cameron9100.github.io
/Usher_Series Notation.py
2,563
4.1875
4
/* Task 1 */ def SomeFunction(n): y = n**2 + 3*n + 1 return y acc=0 for i in range(2, 6): print(SomeFunction(i)) if i < 5: print('+') else: print('=') acc = acc + SomeFunction(i) print(acc) /* Task 2 */ import math def taylor(x): series = 0 for n in range (16): ...
061a007d0933c213e0e5ab74f7da3245d7b071e7
macoto35/Algorithms_Kata
/python/blog/sort/mergeSortButtonUp.py
643
4.0625
4
def mergeSort(A, B, n): width = 1 while (width < n): i = 0 while (i < n): merge(A, B, i, i+width, i+2*width) i = i + 2 * width copyArray(A, B, n) width *= 2 def merge(A, B, st, mid, ed): i = st j = mid k = st while (k <...
622a1c5a92fd6d43cf525bd8eeda924e86ba397d
ri-rewe-digital/robotics-packaging
/knapsack/dynamic_programming.py
2,777
4
4
import numpy as np def fill_knapsack(current_volume, item, volumes, values, dynamic_results): # check for valid item count if item < len(volumes): # did we calculate the value already (dynamic programming) if dynamic_results[item][current_volume] != -1: return dynamic_results[item]...
c1939c364f6463be38f2a4294af6e9c2cac79294
darumada/alghoritms
/geeksforgeeks/Equilibrium index of an array /equilibrium.py
290
3.609375
4
def equilibrium_point(arr): total_sum = sum(arr) left_sum = 0 for i in range(len(arr)): total_sum -= arr[i] if total_sum == left_sum: return i left_sum += arr[i] return -1 arr = [-7, 1, 5, 2, -4, 3, 0] print(equilibrium_point(arr))
76d80fe17426ad892d020d91556c25469f7d2d1b
Hamza-CU/CU-Notes
/practiceproblems/pp8.py
377
4.03125
4
#Problem 2 (Leap Years - **) year = int(input("please input a year and I will check if its a leap year\n")) check1 = (year % 100) check2 = (year % 400) check3 = (year % 4) if check1 == 0: if check2 == 0: print("leap-year") else: print("not a leap-year") else: if check3 == 0: print...
7076f1d706b6343d30bf82e6c1623cb42bbace2b
Dmi3y888/Project-Sky
/Tasks/Task1/Homework1/dis3.py
131
3.796875
4
print("Введите число") a = int(input()) if a%2: print("Непарное", (a)) else: print("Парное", (a))
ee545e7952876990c2dcb892b9aaebf688ce1820
shumbul/DSA
/Algorithms/Sorting Algorithms/Python/bubbleSort.py
309
4.15625
4
def bubbleSort(array): n=len(array) for i in range(0,n): for j in range(i,n-i-1,-1): if(array[j]<array[j-1]): array[j],array[j-1]=array[j-1],array[j] #swapping process return array a=[1,2,4,3,0,6,7,8,12,11] #edit as needed print(bubbleSort(a))
56fb23435bad52e861ea74c971fdea7b7642c65b
emmetio/py-emmet
/emmet/scanner_utils.py
2,798
3.859375
4
nbsp = chr(160) def is_number(ch: str): "Check if given code is a number" return ch.isdecimal() def is_alpha(ch: str): "Check if given character code is alpha code (letter through A to Z)" return 'a' <= ch <= 'z' or 'A' <= ch <= 'Z' def is_alpha_numeric(ch: str): "Check if given character code is...
28ec0361654047f423e133a3b02a9c830b06833e
Rem-G/bus_network
/data/data2py.py
829
3.671875
4
#!/usr/bin/python3 #-*-coding:utf-8-*- data_file_name = '1_Poisy-ParcDesGlaisins.txt' #data_file_name = 'data/2_Piscine-Patinoire_Campus.txt' try: with open(data_file_name, 'r') as f: content = f.read() except OSError: # 'File not found' error message. print("File not found") def dates2dic(dates)...
0ec7df0b2d87e032f48a75d91b2065de32d9b5ca
Kchour/simpleGraphs
/simpleGraphM/algorithms/search/search_utils.py
8,777
3.515625
4
"""Custom data structures for our search algorithms. Import methods are: Classes: CustomQueue: Queue: PriorityQueue: PriorityQueueHeap: DoublyLinkedList: CycleDetection: Functions: heuristics: grid-based heuristics atm (maybe redundant) reconstruct_path: path_length: Todo: ...
3e683396c965d61e5cc893ceb421639f2c5269d1
Divyesh15/Web_api_with_lambda
/student.py
195
3.578125
4
class Student: def __init__(self, roll_no, name): self.roll_no = roll_no self.name = name def to_dict(self): return {"roll_no": self.roll_no, "name": self.name}
649fabe74e1263f154872c207bd144a295280100
Risvy/30DaysOfLeetCode
/Day_25/25.py
450
3.65625
4
/* https://leetcode.com/problems/count-the-number-of-consistent-strings/ Tags: String, Easy */ class Solution: def countConsistentStrings(self, allowed: str, words: List[str]) -> int: c=0 for i in words: flag=0 for k in i: if allowed.find(k)==-1: ...
ef745198a29982408fd5da92c933f1716cb6fee8
Prtmplish/College-Stuffs
/SEM3/PYTHON/College_Codes/Functions/exercise6.py
701
4
4
flag=1 while(flag==1): num = int(input("Enter the number: ")) size = len(str(num)) sum = 0 def isArmstrong(n): global sum global num global size if n < 10: sum += n ** size return num == sum else: sum += (n % 10) ** si...
9e2fcf05a82de2918b89b816f23a9cc915ec3e18
pminkov/wip
/algorithms/lru_cache.py
2,916
3.953125
4
class Node: def __init__(self, value): self.prev = None self.next = None self.value = value class LinkedList: def __init__(self): self.head = None self.tail = None self.size = 0 def insert(self, value): if self.head == None: self.head = Node(value) self.tail = self.head ...
dc6a41d2f1a5222c218b6352bf362899175b5c4d
omarespindola/HOoop
/detector.py
242
3.515625
4
class Detector(object): def __init__(self): pass def detectar(self,senal, senal_ref): if max(senal_ref)>max(senal): print "Se detecto un objeto" else: print "No se detecto nada en este intervalo de tiempo" return 1
26026e1e4ab9f28cae4a811a886819e24f4daa05
Carlosleonolivares/M03
/bucles/bucles-sumas/ejercicio-bucle-sumar1.py
236
3.859375
4
# coding: utf8 # Carlos León # 19/03/2018 salir = "N" numero=1 maximo=5 suma=0 while ( salir=="N" ): print (numero) suma=suma+numero numero=numero+1 if ( numero > maximo ): salir = "S" print ("=" , suma )
ed70fd971c52e47d323d1e00f7cbd81e00ccfd69
niteshadow53/project-euler
/project_euler_55.py
1,374
3.671875
4
# lychrel_count = 0 # For possible_lychrel in ( 0 to 9999 ) # count = 0 # sum = possible_lychrel + reverse(possible_lychrel) # if is_palindrome(sum) # if count < 50 # pass # else # lychrel_count++ # elif count > 50 # lychrel_count++ # continue # else # count++ def is_palindr...
b4239f61c3739fbdafbec18ef565968d58f4889c
KumarAmbuj/BINARY-TREE-MISCELLANEOUS
/54.count of single valued subtree.py
769
3.703125
4
class Node: def __init__(self,val): self.val=val self.left=None self.right=None def findsinglevalued(node,count): if node==None: return True ls=findsinglevalued(node.left,count) rs=findsinglevalued(node.right,count) if ls==False or rs==False: ...
59d32103d8afd9e42399bc4061e88613be978aad
JatinR05/Python-3-basics-series
/13. Global and Local Vars.py
2,849
4.71875
5
''' Welcome to another python 3 basics video, in this video we're going to now discuss the concept of global and local variables. When users begin using functions, they can quickly become confused when it comes to global and local variables... getting a the dreaded variable is not defined even when they clearly see th...
989e397709908e65047acb672f678325552d4df1
vitcmaestro/hunter2
/freq_in_one.py
165
3.515625
4
import collections n = int(input("")) a = list(map(int,input().split())) freq = dict(collections.Counter(a)) for x,y in freq.items(): if(y==1): print(x)
3d8a578fa7c0ef3e7e8836d88ccf2b38490f71aa
Aasthaengg/IBMdataset
/Python_codes/p03852/s465052413.py
112
3.796875
4
c = input() v = ["a", "i", "u", "e", "o"] if all (c!=n for n in v): print("consonant") else: print("vowel")
969bbfcedfabc71fa5590848f5e65581977d89f6
jockaayush/My-Codes
/ex_mail.py
1,089
3.515625
4
# Import smtplib for the actual sending function import smtplib,getpass # Import the email modules we'll need from email.mime.text import MIMEText # Open a plain text file for reading. For this example, assume that # the text file contains only ASCII characters. username = input('Enter Your Username (Sender) :- ') ...
1c0b8faecf3853625d3095e6370a29f4a5699004
Macbear2000/Homework
/experiment4_9.py
128
3.578125
4
#输出到一半就挂了 i = 0 a=['p','y','t','h','o','n'] while i<6: if(a[i]=='h'): break print(a[i]) i+=1
3e864165f16ef714ec8cc5b9003163a48aca2533
janelia-flyem/neuclease
/neuclease/util/csv.py
2,596
4.15625
4
import csv import numpy as np import pandas as pd def read_csv_header(csv_path): """ Open the CSV file at the given path and return it's header column names as a list. If it has no header (as determined by csv.Sniffer), return None. This function handles a special case that Python's ``csv.Sniffer...
103d58f5c1cab068c2931febbc994c51182abbed
UlisesBrunoLozano/privatr
/ulises/02:12:16III.py
510
3.953125
4
import matplotlib.pyplot as plt import numpy as np x=np.linspace(3,-3,100) #100 numeros entre el -3 y el 3 y=x**2 z=x w=x**3 plt.plot(x,y,linewidth=3,color='r',label='parabola') plt.plot(z,w,linewidth=3,color='g',label='cubica') plt.legend() plt.title('Muchas gracias') plt.xlabel('Algo') plt.ylabel('Una funcion de algo...
ae37df088a85f3df12754e479db6627136901265
kelr/practice-stuff
/leetcode/1409-querypermutations.py
1,184
3.5625
4
from collections import deque # Just follow the prompt algorithm, loop through queries, find the index of that value in perm # Append that to the result list, then remove that value in perm and stick it in the front. # O(N*M) time where N is length of query and M is m or how large perm will be. # Can probably be ...
f6915028844d3f31f8536f1254c38a4b9edab497
grwkremilek/leetcode-solutions
/python/0160.intersection-of-two-linked-lists/intersection_of_two_linked_lists.py
582
3.765625
4
#https://leetcode.com/problems/intersection-of-two-linked-lists/ # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None def getIntersectionNode(headA, headB): """ :type head1, head1: ListNode :rtype: ListNode """ ...
39bdd550ad1afc62db6ff8217e730b31fc4df592
ozcayci/python_examples
/examples_06/q7.py
1,533
3.609375
4
# -*- coding: utf-8 -*- def is_valid_identification_number(val: str): assert isinstance(val, str) try: val = int(val) if 100000000000 > val > 9999999999: odd_sum_result = sum_odd_numbers(val) even_sum_result = sum_even_numbers(val) result = odd_s...
7e1811b380f4501c45242557a5bca797b60c88c4
GunarajKhatri/python-challanges
/projecteuler.net _problems/problem9.py
378
3.71875
4
#There exist only one pythagorean triplet for which a+b+c=1000.Find the product abc. #a^2+b^2=c^2------(1) #a+b+c=1000--------(2) #1000*(500-b) % (1000-b)------(from (1) & (2)) array=[] a=0 for b in range(1,500): if 1000*(500-b) % (1000-b) == 0: array.append(b) for i in array: a=a+i c=1000-a array.append(c) produc...
cd223a14cfa0d4584742d2df2bb400b065913426
AdamZhouSE/pythonHomework
/Code/CodeRecords/2589/60785/267990.py
184
3.8125
4
t=int(input()) def fib_recur(n): if n <= 1: return n return fib_recur(n-1) + fib_recur(n-2) for i in range(t): n=int(input()) print(fib_recur(n+1))
78931e4670e7b5d96ad14b837cfee4e6bc9ae5d6
1055447806/python-learning
/hello-if.py
449
4.09375
4
x = 10 # odd if x % 2 == 0: print('odd') else: print('evan') # x equals 10 if x > 10: print('x bigger than 10') elif x < 10: print('x less than 10') else: print('x equals 10') ACTUALLY_RELEASE_YEAR = 1991 inputYear = int(input("please guess the python release year:")) if inputYear > ACTUALLY_REL...
6694336a5fd1bfe49be574c2532bbcef26e530d6
Shuricky/Intro-to-Computer-Science
/number_guess.py
930
4.03125
4
''' Created on Mar 28, 2017 @author: Shurick ''' import random MAX_TRIES = 7 print(''' --- Welcome to Guess My Number --- I'm thinking of a number between 1 and 100. Try to guess my number in %d''' % MAX_TRIES, end = '') if MAX_TRIES == 1: print('atempt...') else: print('attempts...') number = random....
fc46e519852533aa3af87aacee052674b587cd35
wseungjin/codingTest
/kakao/2020_summer/20_summer_kakao_intern2.py
6,464
3.5
4
def solution(expression): i=0 stack = [] expressionList = [] while(1): try : if(expression[i]=="*" or expression[i]=="-" or expression[i]=="+"): number=0 for j in range(len(stack)): now=stack[0] stack.pop(0) ...
663ec9c73a40c78ea6f39056d271b326a3770fd1
GARTosto/Desafio-Curso-Video-Python-Aula-13
/desafio49.py
190
3.8125
4
print('{:=^40}'.format('TABUADA')) num = int(input('Escolha um número: ')) for i in range (1, 11): tab = num*i print(f'{num} x {i} = {tab}') print(f'Essa é a tabuada de {num}.')
5e2825b93ffddd270d43cba0410e394eb5f32dc7
purushottamkaushik/DataStructuresUsingPython
/DyammicProgramming/EggBreakHardest.py
1,441
3.734375
4
# Dynamic Programming Approach import sys def EggBreak(n,k): table = [[ sys.maxsize for column in range(k+1)] for row in range(n+1)] for col in range(1,k+1): table[1][col] = col for row in range(1,n+1): table[row][1] = 1 for i in range(2,n+1): # for number of eggs for j i...
85c7090dbede3dc63ab0eaf2b9b6d6e2bba94a97
sahilkapila/Python_Doodles
/Automate_The_Boring_Stuff/guessTheNumber.py
1,258
3.640625
4
# This is a guess the number game. import random, sys from varname import nameof randfrom = random.randint(1,3) randto = random.randint(8,10) secretnum = random.randint(randfrom,randto) debugmode = { "Status":"Active" } print("Enter Y for DEBUG Mode N for Normal (Default: Active):",end=" ") try: inputvar1 =...