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
d02e1ab6bab2cedb819af0046c2bb594ff1da2d1
vbsteja/code
/Python/HA_CF/codefights_user_medal.py
485
3.5
4
def codemania_medal(user_time, gold, silver, bronze): m = user_time.split(":") n = gold.split(":") o = silver.split(":") p = bronze.split(":") u = m[0] * 60 * 60 + m[1] * 60 + m[2] g = n[0] * 60 * 60 + n[1] * 60 + n[2] s = o[0] * 60 * 60 + o[1] * 60 + o[2] b = p[0] * 60 * 60 + p[1] * 60 ...
35718b5b48f85d72174c6e1c766291c1864313dc
vbsteja/code
/Python/HA_CF/April_circuits1.py
956
3.828125
4
def count_consonents(s): c, v = 0, 0 vow = ['a', 'e', 'i', 'o', 'u'] for i in s: if i in vow: v += 1 else: c += 1 # print(c) # print(v) if c > v: return True else: return False def man: return 1 def consec_consonents(s): c =...
5796e991994080a72b42aaf9536b582be3fe3e57
itspaulyg/advent-of-code-2020
/day03/toboggan_trajectory_2.py
531
3.6875
4
#!/usr/bin/python3 import sys def walk_course(course, dx, dy): width = len(course[0]) height = len(course) x = 0 y = 0 trees = 0 while y < height: if course[y][x % width] == '#': trees += 1 y += dy x += dx return trees def main(): course = [] for line in sys.stdin: course.append(line.strip...
d7fa30ec79fd5e598ce4df5190886593e6b05966
itspaulyg/advent-of-code-2020
/day02/psswrd_philo.py
551
3.703125
4
#!/usr/bin/python3 import sys def check_password(password, lower, upper, letter): count = 0 for ele in password: if letter == ele: count += 1 if count >= lower and count <= upper: return True return False def main(): c = 0 for line in sys.stdin: protocol = line.rstrip().split() bounds = proto...
549bbb7da91d7b08308cc9fc530d41dace070d0d
aurorazl/math
/sort/8.merge_sort.py
1,072
3.703125
4
def merge(li,low,mid,high): i = low j = mid+1 li_tmp = [] while i<=mid and j <=high: if li[i]<li[j]: # li_tmp.append(li[i]) i+=1 else: li_tmp.append(li[j]) j += 1 while i<=mid: # 上一个循环结束后,会有一边还没取完,下面两个循环会有一个执行 ...
43f7d762fc70feba4edd50dc23c8f08ea6525849
aurorazl/math
/sort/单链表排序.py
2,660
4.15625
4
# 给你链表的头结点 head ,请将其按 升序 排列并返回 排序后的链表 。 # 思想: 二分、归并排序 # 技巧:快慢指针 """ 1、判定链表中是否含有环 用两个指针,一个跑得快(每次跑两步),一个跑得慢。如果不含有环,跑得快的那个指针最终会遇到 null,说明链表不含环;如果含有环,快指针最终会超慢指针一圈,和慢指针相遇,说明链表含有环。 if (fast == slow) return true; 2.寻找链表的中点 让快指针一次前进两步,慢指针一次前进一步,当快指针到达链表尽头时,慢指针就处于链表的中间位置。 当链表的长度是奇数时,slow 恰巧停在中点位置;如果长度是偶数,slow 最终的位置是中间偏右: while...
67f9c897670417cfb03bd639964a4085de4ec137
aurorazl/math
/leetcode/合并不重叠区间.py
774
3.609375
4
# """ 思路: 维护一个列表,遍历输入列表,每个加入前先判断要加入的位置。 """ def mergeLi(li): tmp = [] for one in li: for t in tmp: if one[1]==t[0]-1: t[0] = one[0] break if one[0]==t[1]+1: t[1] = one[1] break else: tmp.append(...
336b10716f1ecc42acd1c35c4d48ee4902139d1a
aurorazl/math
/Topology/链表反转.py
726
3.859375
4
class ListNode: def __init__(self,val,next=None): self.val = val self.next = next #迭代 def reverseChain(head): prev = None cur = head while cur: next = cur.next cur.next = prev prev = cur cur = next return prev # 递归 def reverseChain2(head): if not ...
44f78771dbe1e635a473abb7412a85f10e74ff8b
aurorazl/math
/Topology/前序、中序、后序遍历.py
1,869
3.984375
4
### """ 前序遍历:根节点->左子树->右子树 中序遍历:左子树->根节点->右子树 后序遍历:左子树->右子树->根节点 """ # 递归法,比较简单 def preOrderTraverse(node): if not node: return None print(node.val) # 调整顺序即可 preOrderTraverse(node.left) preOrderTraverse(node.right) # 非递归法 def preOrderTravese(node): # 第一次访问就输出数据...
9de996e97585cca7c331efbee01e979d4371bd5f
carlosvin/cloudfs
/core/fs.py
2,350
3.515625
4
import os class File: def __init__(self, name): self._name = name self._is_dir = False @property def name(self): return self._name @property def is_dir(self): return self._is_dir def __eq__(self, other): return other and self.name == other.name d...
b8e9ee498f8ccae85c0cf4095d8b1b0ca5805298
Harshp1802/assignment-3-Harshp1802
/q3.py
4,641
3.515625
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt from logisticRegression.logisticRegression import LogisticRegression from sklearn.linear_model import LogisticRegression as LLR from metrics import * from sklearn.datasets import load_digits import seaborn as sns np.random.seed(42) # a) --------- L...
55e1c6b098c65df69da8dbfacad03a3d3760df9f
harlanwang1211/leetcode_problems
/leet_code_easy/0013_roman_to_integar.py
829
3.640625
4
def romanToInt(roman): ''' Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 e.g. Input: "IX" Output: 9 ''' roman_dict = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C'...
2092d3a470a971a11a4f68c7fc5073df3812eeeb
ZivDo/zivdo.github.io
/code/ClassDemo.py
348
3.609375
4
class Dog: name = "" age = 0 category = "A" def __init__( self, _name, _age, _category ): self.name = _name self.age = _age self.category = _category def dogInfo( self ): print( self.name, self.age, self.category ) def function1( self ): pass dog1 = Dog( "Bajie", 4, "B") # print( isinstance( dog1...
4b9cb703853988aa0bf0ad7415df6c5494d184a8
OmarSalah95/Python2
/src/item.py
250
3.578125
4
class Item: def __init__(self, name, description): self.name = name self.description = description def getItem(self): print(f'------ITEM------\n*** Name: {self.name}\n*** Item Description: {self.description}')
b0bc850e8176bfe6b2551317b73cef59ec0fe675
originalMemory/algorithmPython
/listNode/palindromeLinkedList.py
1,145
3.75
4
# coding=utf-8 """ @project : algorithmPython @ide : PyCharm @file : palindromeLinkedList @author : illusion @desc : 234. 回文链表 https://leetcode-cn.com/problems/palindrome-linked-list/ @create : 2021/2/7 1:35 下午:35 """ from listNode.model import ListNode class Solution: def isPalindrome(self, head: Lis...
7fdacde0da37a96b60925b1a15c5751271655156
originalMemory/algorithmPython
/stack/inorderTraversal.py
1,986
3.828125
4
# coding=utf-8 """ @project : algorithmPython @ide : PyCharm @file : inorderTraversal @author : illusion @desc : 94. 二叉树的中序遍历 https://leetcode-cn.com/problems/binary-tree-inorder-traversal/ @create : 2021/6/1 1:26 下午:22 """ class TreeNode: def __init__(self, val=0, left=None, right=None): self....
e2f5d78059ea08bdfd7433f4ac447ecb9fe10c46
originalMemory/algorithmPython
/treeNode/insertIntoBST.py
813
3.890625
4
#!/user/bin/env python # coding=utf-8 """ @project : algorithmPython @ide : PyCharm @file : insertIntoBST @author : illusion @desc : 701. 二叉搜索树中的插入操作 https://leetcode-cn.com/problems/insert-into-a-binary-search-tree/ @create : 2020-08-23 15:20:36 """ # Definition for a binary tree node. class TreeNode: ...
66d50bc8acfe3e1a4a3997170fa10f6f00302f07
kamat-o/MasteringPython
/27_08_2019/AddTwoNumbers.py
239
4.1875
4
# get the input from user num1 = int(input("Enter first number: ")) num2 = int(input("Enter second number: ")) #compute the addition result = num1 + num2 #print the result print ("The sum of {0} and {1} is {2}".format(num1,num2,result))
a65c5f2d60e78fda18111cbf5498d5855d49bfc7
hina-murdhani/python-project
/pythonProject3/demo/set.py
1,391
4.375
4
# set has no duplicate elements, mutabable set1 = set() print(set1) set1 = set("geeksforgeeks") print(set1) string = 'geeksforgeeks' set1 = set(string) print(set1) set1 = set(["geeks", "for", "geeks"]) print(set1) set1 = set(['1', '2', '3', '4']) print(set1) set1 = set([1, 2, 'geeks', 'for', 3, 3]) # add() method is u...
2f4b40b0b435a50c8a59dbb0d3d3eb93cb772e86
hina-murdhani/python-project
/pythonProject3/demo/array.py
1,710
4.3125
4
import array as arr # by importing array module we can generate the array a = arr.array('i', [1, 2, 3]) for i in range(0, 3): print(a[i]) a = arr.array('d', [1.3, 4.5, 6.7]) for i in range(0, 3): print(a[i]) # can add element in array using insert():- at any index ,method and append() method : at the end of ...
d2987241059768207f8ce9cd9c7ab09fd79a49f8
Holthuizen/Final-Project
/GameClasses/Table.py
4,724
3.546875
4
import random #game class Table: def __init__(self,table_id): self.id = table_id self.players = {} #max 3 self.player_ids = [] #list of shuffeld player_id's that determin the playing order. self.current_player = None #player that is allowed to make a move sel...
d0510b204029cb90572b3caaae66017182d76fed
bigpotato920/web_analyzer
/link_parser.py
1,334
3.5
4
import re class LinkParser(object): def __init__(self): self.pattern = re.compile('< *a[^>]+href=\"([^\"]+\\.htm)\"[^>]*>') def parse_content(self, content): """ extract urls from the content :param content: the content of a html file :return a collection of urls ...
9daec233a39e7c1c5e2acaf9b4c3edbd580f166d
nitin-aggarwal/Concurrent-Algorithms
/Mutual Exclusion/LamportBakery.py
1,784
3.609375
4
#Lamport's Bakery Algorithm for n processes #Import required modules import random import threading # Declare global variables required by Lamport's Bakery Algorithm choosing = [] num = [] numThreads = 0 # Define a class Bakery for Lamport's Bakery Algorithm class Bakery( threading.Thread ): def __...
f6304de17f320aa42fc03b220444e7c04e3c4455
jameswu98/pystronghold
/robot_map.py
2,048
3.75
4
import math class RobotMap: """ The RobotMap is a mapping from the ports sensors and actuators are wired into to a variable name. This provides flexibility changing wiring, makes checking the wiring easier and significantly reduces the number of magic numbers floating around. """ # For exa...
d03d79a6e07454a25842e7611bcb761cf910305e
Abeeeee/Abelton
/PONGVOLDOENDE.py
6,926
3.609375
4
# imports import arcade import time # define arcade screenthings WINDOW_WIDTH = 800 WINDOW_HEIGHT = 600 WINDOW_TITLE = " Abelton" WINDOW_BACKGROUND_COLOR = arcade.color.PINK class Ball: def __init__(self, position_x, position_y, delta_x, delta_y, radius, color): # define Ball stuff ...
58ae71ca4135548bd6bb7f52bdefa89feca1cc54
justin-lyon/hello-python
/exercises/logicalOperatores.py
204
4.03125
4
name = " " if not name.strip(): print("is empty") else: print("not empty") age = 22 if age >= 18 and age < 65: print("you're eligible") if 18 <= age < 65: print("you're still eligible")
840c3019607e5873dcff8de0ab0b403b9c6109a9
justin-lyon/hello-python
/exercises/fizzbuzz.py
360
3.921875
4
def fizz_buzz(input: int): message: str = "" if input % 3 == 0: message = "fizz" if input % 5 == 0: message += "buzz" return message if message.strip() else input print(fizz_buzz(3)) print(fizz_buzz(5)) print(fizz_buzz(15)) print(fizz_buzz(7)) # n / 3 = fizz # n / 5 = buzz # n / both...
9dcd641e1b18997ab78e66fdde81c400eecfce7f
DahlitzFlorian/python-training-beginners
/code/solutions/solution_04.py
263
4.40625
4
# This is a possible solution for exercise_04.py word = input("Enter a word (possible palindrom): ") reversed_word = word[::-1] if word == reversed_word: print("Your submitted word is a palindrom.") else: print("Your submitted word is not a palindrom.")
54efab3db21feefee21acae8acd39745e4f70395
DahlitzFlorian/python-training-beginners
/code/exercises/exercise_06.py
331
3.78125
4
# Write a password generator in Python. # Be creative with how you generate passwords - strong passwords have a mix of lowercase letters, uppercase letters, numbers, and symbols. # The passwords should be random, generating a new password every time the user asks for a new password. # Include your run-time code in a ma...
a71ce2d967454b5a8f7d3eb7f7b651a6d463e95f
slb2709673/random-twitter-handles_generator
/randCoordinates.py
836
3.765625
4
import pycristoforo as pyc class randCoordinatesGenerator(): """ RandCoordinatesGenerator generates specified random points for a """ def __init__(self, country_name, num_points): self.country_name = country_name self.num_points = num_points self.points = self.getCoordinates(sel...
c227a78acee39edfba2f587f62501105560fa247
rushimg/amicus_curia_CS591
/link_govtrack_2.py
3,200
3.53125
4
''' Grab data from govtrack api by Bill name sample api call https://www.govtrack.us/api/v2/bill?number=4569&congress=105&format=csv&fields=congress,number,bill_type_label,is_alive,current_status,title_without_number ''' import sys,os,re import fnmatch import csv import urllib2 BILL_FILE = "bill_parsing_billtype.csv"...
1a020f32b2a6b3a72571371ca42c2534f816c579
mr-parikshith/Python
/S05Q02_MaxMinNumber.py
1,366
4.1875
4
""" S05Q02 - Ask the user to enter a number till he enters 0. Print the maximum and minimum values among all entered numbers. Print the number of single, two and three digit numbers entered. """ def print_CurrentMaxMin(Max, Min): print("Current Maximum Number is ", Max) prin...
7ab8e5d554511263c14d6ae6a5737ea43a81b2fe
mr-parikshith/Python
/S04Q02_ExamScore.py
1,833
4.0625
4
""" S04Q02 - Brilliant School sets an exam wherein, English exam is for 80 marks, Science for 90 marks and Mathematics for 100 marks. Ask the student to enter the marks scored in each of these exams. Calculate the total percentag...
1163df1cb6c0cad5800a2f74913a90e5d9bbc9d4
mr-parikshith/Python
/S08Q03_NumberAsString.py
610
4.1875
4
""" S08Q03 Ask the user to enter a number. - If the user enters a number as 5, then generate the following string : - 00001111222233334444 - If the user enters the number as 3, then generate the following string : - 001122 """ def enterNumber(): Number = int(input("Enter Number : ")) while Numbe...
6709065f9501abc012572b2f3b5582dffed976fe
Jasbeauty/Projects-with-Python
/LIS/list.py
1,968
3.65625
4
#!/usr/bin/env python # -*- coding:utf-8 -*- # @Time : 2018/11/26 10:06 AM # @Author: jasmine sun # @File : list.py def user_input(): random_list = input("请以空格为间隔,输入一个整型数组:") format_list = list(map(int, random_list.split())) # print(format_list) return format_list # 求解最长递增子序列及其长度 def longest_sub_i...
45fe1df4cb45f83f677c4444a27d51ec41015b5b
rmbackoTU-dev/fiction-dictionary
/fictdictCli.py
10,675
3.59375
4
from fict_dict.client import fict_dict_cli_access import argparse #TODO #Build out command line arguements and parameters #map to fict_dict_cli_access #run each flag and parameter at least once def main(): cliClient=fict_dict_cli_access() parser=argparse.ArgumentParser(description="Fiction dictionary allows ...
603119f0a0d09212e688d0cf3d16744d75c816a4
kevfallon97/python-bootcamp
/section_17_pdf_and_csv/working_with_csv_files.py
770
3.9375
4
import csv # steps: # open the file # csv.reader # reformat it into a python object list of lists # open the file data = open("example.csv", encoding="utf-8") # csv.reader csv_data = csv.reader(data) # reformat it into a python object data_lines = list(csv_data) # # view data # for line in data_lines[:5]: # print(...
2b03905a42fa1fe58749e792fc6ba6355fbf0816
kedar-calangutkar/tictactoe
/ttt.py
8,247
3.671875
4
import sys ######################### # Show Matrix # # print the state ######################### def showMatrix(mat): for X in range(3): for Y in range(3): print mat[X][Y], print print ######################### # Get CPU's move # # get CPU's move ######################### def getAIMove(mat): global numberOf...
3590095c48debdc29ca013ba05fa062c4b0db02a
nikitatarasenko17/homework
/Lesson_3/Lection_3_task_4.py
312
3.875
4
# Банкомат выдает сумму максимально возможными купюрами a = int(input("Введите сумму: ")) money = [1000, 500, 200, 100, 50, 20, 10, 5, 2, 1] for i in range(0, len(money)): s = money[i] while a - s >= 0: a -= s print(s)
809d980c3bce05e6f413a6c3d4f54cc67ab2fe60
nikitatarasenko17/homework
/Lesson_3/hw_3_task_2.py
763
3.5625
4
# Задача №3 # Написать fizzbuzz для 20 троек чисел, которые записаны в файл. Читаете из файла первую строку, берете из нее числа, считаете для # них fizzbuzz, выводите with open('chisla.py', 'r') as f: l = [_.split() for _ in f] for i in range(len(l)): s = [] a = int(l[i][0]) b = int(l[i][1]) ...
b54cf1a931e8fa7a9da186d7934fb6e54d1ac9ca
nikitatarasenko17/homework
/Lesson_2/hw_2_task_1.py
1,278
4.21875
4
# Задача №1 # Набрать все примеры посимвольно и заставить их работать, разобраться в их работе # Оператор условия if print ("Give it to me!") number = int(input()) if (number >= 100): print ("Thanks, man!) \n") elif ((number > 10) and (number < 100)): print ("OK :( \n") else: print ("WHAAAAT????") if (nu...
168ce7da8501baf8e28e0844442eaaffcfc8814d
r1122d/pdsnd_github
/bikeshare.py
8,022
4.125
4
import time import pandas as pd import numpy as np #Define dictionary of data files CITY_DATA = { 'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv','washington': 'washington.csv' } #Define lists required in several functions months = ['january', 'february', 'march', 'april', 'may', 'june', 'all'] days = ...
efaede91566313a29bbb32bae0be8121edcf991c
vladlemos/lets-code-python
/Aula_6/01.py
553
3.53125
4
# arquivos # persistir dados ''' open() serve para manipular arquivos, modos de acesso: Escrita = w (cria arquivos do zero) Leitura = r (le arquivos existentes) Adicionar = a (cria qdo nao existe, ou acresce qdo existe) ''' arquivo = open('meu_primeiro_arquivo.txt', 'w') arquivo.write('minha primeira mensagem em arqu...
575f17a57fbf571f6c130a71bcac51fbe3071f74
vladlemos/lets-code-python
/Aula_1/11_calculo.py
681
4.4375
4
''' Faça um programa que peça 2 números inteiros e um número real, calcule e mostre: a)o produto do dobro do primeiro com metade do segundo. b)a soma do triplo do primeiro com o terceiro. c)o terceiro elevado ao cubo. ''' primeiro_numero = int(input('digite um número inteiro: ')) segundo_numero = int(input('d...
ec7637bc6241fdefa75a73dcac42080f64cfd762
vladlemos/lets-code-python
/Aula_1/12_imc.py
279
3.796875
4
# Faça um programa que peça o peso e altura de uma pessoa e calcule seu IMC # (Índice de Massa Corporal). Obs: IMC = Peso/Altura2 peso = float(input('informe seu peso: ')) altura = float(input('informe sua altura: ')) imc = peso / altura ** 2 print('seu IMC eh de: ', imc)
80227b6bf950ecb5be5c31c75c64d392acd4a636
wahidikqbal/OOPpython
/13.multipleInherittabce.py
623
3.828125
4
class Tipe: def tipe(self, tipe): self.tipe = tipe def infoTipe(self): print("tipenya adalah",self.tipe) class Team: def team(self, team): self.team = team def infoTeam(self): print("teamnya adalah",self.team) class Hero(Tipe,Team): #class Hero mendapatkan turunan metho...
bfac26b3174d456c22fd059c81118e7dac606a69
newming/PythonLearn
/high/demo8.py
1,044
3.71875
4
# 列表推导式 [] 列表, set 集合, dict 都可以 a = [1, 2, 3, 4, 5] d = {1, 2, 3, 4, 5} # 在 for 循环前边添加对每个 项 要执行的操作 b = [i * i for i in a] # [1, 4, 9, 16, 25] print(b) # 在 for 循环后添加判断条件,先执行 for 然后 if 然后前边的操作 c = [i * i for i in a if i >= 3] print(c) # [9, 16, 25] # 还可以是 set e = {i * i for i in d} print(e) # 而且还可以切换 f = {i * i f...
4154aa96fa2d27348e6cc185c6246967ade6dff0
newming/PythonLearn
/enum/enum.py
1,367
3.765625
4
from enum import Enum ''' 枚举与普通对象或字典的区别: 1. 枚举的值不可以重复,如果重复了,后面的就是前边的别名 2. 不可以随意更改 3. 枚举的属性名不可以重复 ''' class VIP(Enum): YELLOW = 1 GREEN = 1 BLACK = 2 print(VIP.YELLOW) # VIP.YELLOW print(VIP.GREEN) # VIP.YELLOW # 不可以修改值 # VIP.YELLOW = 2 # AttributeError: Cannot reassign members. # 获取某个属性的值 print(VIP.YELLOW...
7ba2d5a56a1e318c3c2a4ed2aff2e37b9a601451
newming/PythonLearn
/oop/class.py
2,008
4.0625
4
class Person(): name = '我是原型上的属性 name' # 类上的属性,类似 prototype age = 0 sum1 = 0 people = 0 def __init__(self, name, age): # 构造函数,初始化属性,挂载到实例化对象上的属性 self.name = name self.age = age print('init', self.sum1, Person.sum1) # 1====> init 0 0 self.__class__.sum1 += 1 print('当前实例化次数为', self.__class__.sum1) # ...
8ce13a22218c08604a9d7746455de7775f975e96
newming/PythonLearn
/high/demo2.py
201
3.90625
4
# 匿名函数 def add(x, y): return x + y ''' 匿名函数,类似与箭头函数 1. 没有名字 2. 不需要 return 3. 冒号后只能是表达式 ''' f = lambda x, y: x + y print(f(1, 2))
4c11ef1533db7dc7f2dfebe2239878e69d9ec9c4
mattlorme/python
/coursera/list_8.4.py
823
4.34375
4
#!/usr/bin/python2.7 # 8.4 Open the file romeo.txt and read it line by line. # For each line, split the line into a list of words # using the split() function. # The program should build a list of words. # For each word on each line # check to see if the word is already in the list # and if not append it to the list. ...
80cea21ec26d5f244f10ed5f2ce398ac1bad201e
mattlorme/python
/coursera/LargeSmall.py
2,637
3.84375
4
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++THIS DIDN"T WORK+++++++++++BECAUSE THERE IS NO NUMBER LESS THAN < NONE+++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ def test(): # while True: # try: # num = int(ra...
858cc13c621dbcb56544af0da42a074ff6abc621
intel/cri-resource-manager
/scripts/testing/pairwise
4,261
4.15625
4
#!/usr/bin/env python3 """pairwise - print var-value combinations that cover all value pairs Usage: pairwise VAR=VALUE [VAR=VALUE...] Example: $ pairwise \\ distro={debian-sid,opensuse,fedora} \\ k8scni={cilium,weavenet,flannel} \\ k8scri={crio,containerd} \\ k8s={1.22.0,1.23.0} """ import sys def ...
ca4a5e52495596f204405e4a93aa7e60bcda45b0
komeon1/library_management_system
/Final Library Management System Bonnien2 4Cr.py
12,799
3.953125
4
# I need Python to recognize all my documentation and date requirements import csv import Patron import Collection import Check_Out import datetime # set all of my variables to empty/zero/null last_patron_id = 0 patron_list = [] new_patron_id = 0 collection_list = [] check_out_list = [] last_check_out_id = 0 # add p...
35d33787ddf917c84f663ba04166531b1da6aa48
sh-shrey/AIproject
/Best-first-search.py
1,723
3.859375
4
SuccList = {'A': [['B', 1], ['C', 2]], 'B': [['A', 5], ['C', 2], ['D', 2], ['E', 3]], 'C': [['A', 5], ['B', 1], ['F', 2], ['G', 4]], 'D': [['H', 1], ['I', 9]], 'F': [['J', 9]], 'G': [['K', 9], ['L', 3]]} Start = 'A' Goal = 'H' Closed = list() SUCCESS = True FAILURE = False State = FAILURE def ...
9d98cd60bd4b7746a16dae195df5eb3506d3496e
RASM17/Codility-Exercises
/Stacks and Queues/Brackets/brackets.py
680
3.734375
4
def checkPairs(left: chr, right: chr) -> bool: if left == '{' and right == '}': return True if left == '(' and right == ')': return True if left == '[' and right == ']': return True return False def solution(S: str) -> int: leftSymbols = [] for symbol in S: i...
cabbefa1d0f2c202470ecebabd30e804f4f30f07
GiliardGodoi/algorithms
/datastructure/queue/queue_inefficient.py
969
4.03125
4
class Queue(object): def __init__(self): self.items = [] def isEmpty(self): return not bool(self.items) def enqueue(self, item): self.items.insert(0,item) def dequeue(self): return self.items.pop() def size(self): return len(self.items) ...
d53204b35c7703be7ecd2079427c40868f62d8f6
GalyaBorislavova/SoftUni_Python_Advanced_May_2021
/2_Tuples_and_sets/10. Phonebook.py
765
3.875
4
def input_to_list(count): lines = [] for _ in range(count): line = input() lines.append(line) return lines def check_and_print_names(p_book, names): for name in names: if name in p_book: print(f"{name} -> {p_book[name]}") else: print(f"Contact {n...
be880aeee9bb97dfbcdeabc70b7893c87df65ed2
GalyaBorislavova/SoftUni_Python_Advanced_May_2021
/2_Tuples_and_sets/04. Parking Lot.py
459
3.6875
4
def input_to_list(count): lines = [] for _ in range(count): line = input() lines.append(line) return lines n = int(input()) data = input_to_list(n) parking_lot = set() for car in data: command, number = car.split(", ") if command == "IN": parking_lot.add(number) else:...
805a0f18e5162d38030874748a91898bbe4d9292
GalyaBorislavova/SoftUni_Python_Advanced_May_2021
/7_Modules/fibonacci Sequence/main.py
562
3.90625
4
from create_and_find_functions import * fibonacci_sequence = [] data = input() while not data == "Stop": command, *rest = data.split() if command == "Create": number = int(rest[-1]) fibonacci_sequence = create_fibonacci_sequence(number) print(*fibonacci_sequence) elif command == "...
bb079abbb6fc9ad03bca9242866004b03c8da120
GalyaBorislavova/SoftUni_Python_Advanced_May_2021
/Exams/Python Advanced Retake Exam - 19 August 2020/03. Numbers Search.py
607
3.828125
4
def numbers_searching(*args): args_as_list = [int(el) for el in args] max_number = max(args_as_list) min_number = min(args_as_list) missing_number = [num for num in range(min_number, max_number + 1) if num not in args_as_list][-1] duplicates = set([num for num in args if args.count(num) > 1]) so...
1dfb0524838174c5f8e91741b8c8d9c8438b5164
GalyaBorislavova/SoftUni_Python_Advanced_May_2021
/4_Comprehensions/02. No Vowels.py
232
4.15625
4
def check_for_vowels(character: chr): if character.lower() in ['a', 'o', 'u', 'e', 'i']: return True return False text = input() no_vowels = [ch for ch in text if not check_for_vowels(ch)] print("".join(no_vowels))
41d2179a2927a56978e243d5c2dca8255480e4b7
GalyaBorislavova/SoftUni_Python_Advanced_May_2021
/7_Modules/Mathematical Operations/operators.py
293
3.71875
4
def apply_sum(num_1, num_2): return num_1 + num_2 def apply_subtract(num_1, num_2): return num_1 - num_2 def apply_multiply(num_1, num_2): return num_1 * num_2 def apply_divide(num_1, num_2): return num_1 / num_2 def apply_power(num_1, num_2): return num_1 ** num_2
af8de9f8164e01670c667c5d54905dc1a2b3b5fc
GalyaBorislavova/SoftUni_Python_Advanced_May_2021
/1_Stacks_and_queques/13. Crossroads.py
1,434
3.640625
4
from collections import deque END_COMMAND = "END" green_light_duration = int(input()) free_window_duration = int(input()) cars = deque([]) everyone_is_safe = True number_of_cars = 0 car = input() while not car == END_COMMAND: if not everyone_is_safe: break if car == "green": if cars: ...
29ba7180eb77c40e5f8a614c405b07dd7dcf9d16
GalyaBorislavova/SoftUni_Python_Advanced_May_2021
/3_Multidimensional_list/03. Primary Diagonal.py
346
3.796875
4
def find_sum_primary_diagonal(square_matrix): sum_diagonal = 0 for r in range(len(square_matrix)): sum_diagonal += square_matrix[r][r] return sum_diagonal size_matrix = int(input()) matrix = [] for row in range(size_matrix): matrix.append([int(el) for el in input().split()]) print(find_sum...
abd92da85a57a32e1ab9bf6c7d8e110d8c2d159c
aklikh/codewars
/src/is_isogram.py
317
3.765625
4
def is_isogram(string): str = string.lower() dict = {} for i in range(len(str)): if str[i] in dict: return False else: dict[str[i]] = str[i] return True #print (is_isogram('moOse')) print (is_isogram('aba')) #print (is_isogram('mas'))
9e251282cde07faa8f8a2b991f9d1c65e520321f
jan-verm/Tripadvisor_prediction
/individual_phase/Bram/Code/data_analysis.py
1,794
3.546875
4
import data import numpy as np import matplotlib.pyplot as plt from collections import Counter from pipeline import learn def histogram_ratings(data): """ Plot a histogram of the ratings in the given data. """ ratings = [review.rating for review in data] plt.hist(ratings, bins=6, normed=True) ...
8d86cde8b7a953dec68ddcc7758a41229541fe50
icbtbo/algorithm
/binarysearch.py
764
3.859375
4
def BinarySearch(a,n,x): left = 0 right = n-1 while left <= right: middle = (left + right) // 2 if a[middle] is x: i = j = middle if a[middle] > x: right = middle - 1 else: left = middle + 1 i = right j = left return i,j def Se...
be45cceb95d221c4d6f6962922ef38ea842ae195
GeromeMart/createlabz-public
/raspberry/respeaker/2-mic-pi-hat/user_button.py
747
3.65625
4
import RPi.GPIO as GPIO import time # Print Start of test print("ReSpeaker 2-Mic Pi Button test") # User button pin BUTTON = 17 # User button setup GPIO.setmode(GPIO.BCM) GPIO.setup(BUTTON, GPIO.IN) # Save previous state previousState = GPIO.input(BUTTON) # Unending Loop (main) while True: # Get button state ...
f233d426fa5637d3af6364986cb3523202a2a487
Rufasgardian/K_means_plus_plus
/k_means.py
7,101
3.5
4
from collections import Counter from math import log2 import pandas as pd import numpy as np import sys import matplotlib.pyplot as plt import csv class K_means_plusplus: """ Note : Cluster names are indicated as numbers (starting from 0) """ def plot_data(self, data): """ Plots the g...
b77f80555a157d143a3089dbf53ef8936193e92f
NewWorldVulture/Sequence-Generators
/look_and_say.py
831
3.78125
4
# Created by Ada # Should probably be considered a beta version of this # There has to be a way to separate a string into a list by character-type # Iterates a look-and-say sequence once using a default offset of 0. (regular look-and-say) # Passing in an offset of 1 moves 1 element of the sequence to the end, then con...
28a5e6fa57c89a266f90a2c2ccd22e15e527d657
eugenereydel99/kmzi
/cipherHill2.py
4,504
3.53125
4
import numpy as np from math import * # создаём ключ def createKey(alphabet, keyWord): keyWordIndex = [alphabet.index(keyWord[i]) for i in range(len(keyWord))] keyWordIndex = np.array([keyWordIndex[:]]) return np.reshape(keyWordIndex, (int(sqrt(len(keyWord))), int(sqrt(len(keyWord))))) # создаем блоки def...
c7a8c900d8f29c4b70003edfb1983fef6b9e8bb6
louesejackson/Learning_Python
/HelloWorld/weight_conversion.py
108
3.71875
4
weight_lbs = input('What is your weight in pounds? ') weight_kg = int(weight_lbs) * 0.45 print (weight_kg )
1479d1d29bf346e38724e02614a062ba93ee1ae9
DeeUnderscore/reddit_util
/karmas.py
2,042
3.734375
4
#!/usr/bin/env python # karmas.py """Gather highly relevant data about a reddit user's karma """ from libredditutil import * def karmas(username, depth=None, kind="sub"): """ Returns an array of karma values for a user's items This is a wrapper around karmas_data() Parameters: kind - can either be "sub" or ...
95c10f7efbbbf6820f815ebadb788e65383dd9cd
lqminhdev/python-design-patterns
/creational/factory.py
702
3.546875
4
class VietnameseGetter(object): def __init__(self): self.trans = dict(dog='Cho', cat='Meo') def get(self, msg_id): return self.trans.get(msg_id, str(msg_id)) class EnglishGetter(object): def get(self, msg_id): return str(msg_id) def get_localizer(language='English'): """The ...
37f0f4565c5b3d88297c6418000af87c3f5fb0b9
SangeetaBiswas/Python
/Basic.py
5,105
4.84375
5
#!/usr/bin/python3 # Purpose: To learn syntex used in Python by following # "A Byte of Python" available on # https://python.swaroopch.com/ # -------------------------------------------------------- # Sangeeta Biswas # Post-Doc Researcher # Brno University of Technology, Czech Republic # 29.6.2018 # -----------------...
2f5cb0d3e14087e235c43da0eb891ff2c183ce22
emmendoza/algorithmicTradingML
/search_algorithm.py
4,245
3.671875
4
import random import pandas import csv import sys # This is a function that generates permutations for hill climbing search algorithm # This will permutate next steps in ema short and long values # This function will initially accept and randomly chosen set of ema values # It wil then find next permutations and referen...
915418553c1421ed86a2ac96951ca7589d87be3b
aceirino/Ch.04_Conditionals
/Grading Program.py
509
4.09375
4
grade=float(input("what is your grade?")) test=float(input("what will you get on the test?")) worth=float(input("what is the test worth?")) worth=worth/100 overall=test*worth+grade*(1-worth) letter="" if overall>=100 and worth==0: letter="A+ you are a lucky guesser" elif overall>=90: letter="A" elif overall>=...
3d27a821149acd4c675195885ffc6110044e036e
tower-maze/backend
/util/stack.py
1,062
3.890625
4
class Node: def __init__(self, value, next_node=None): self.value = value self.next_node = next_node class LinkedList: def __init__(self): self.head = None self.length = 0 def __len__(self): return self.length def add_to_head(self, value): ...
40c128475b32bca40c6019a9787dae0db592b599
eantaev/problem-solving
/palindrome_integer.py
576
3.984375
4
def reversed_number(n): assert n >= 0 r = 0 while n != 0: r *= 10 r += n % 10 n //= 10 return r def is_palindrome(n): if n < 0: return False if n == 0: return True return n == reversed_number(n) assert is_palindrome(0) is True assert is_palindrome(...
b012df090d7ebf8145287d26c3e88410313fd42a
eantaev/problem-solving
/rec_to_iter/simple_method_factorial.py
1,060
4.1875
4
def factorial(n): if n < 2: return 1 return n * factorial(n - 1) # 1 Study the function. # 2 Convert all recursive calls into tail calls. (If you can’t, stop. Try another method.) # 3 Introduce a one-shot loop around the function body. # 4 Convert tail calls into continue statements. # 5 Tidy up. def...
5e724a6b0121ba9c685a73e11a727feb8878fc5e
eantaev/problem-solving
/gcd.py
385
3.828125
4
def gcd(a, b): assert a >= 0 assert b >= 0 if a > b: a, b = b, a assert 0 <= a <= b if b == 0: raise ValueError('gcd(0, 0) is undefined') while a != 0: a, b = b % a, a return b assert gcd(0, 1) == 1 assert gcd(1, 0) == 1 assert gcd(1, 1) == 1 assert gcd(2, 3) == 1 as...
6907c5216cc79c0b7d6fc8e1c5c49883ec477f9e
Icarus1994/companies_test
/基本算法/二叉树遍历_全.py
2,704
3.734375
4
# -*- coding: utf-8 -*- # @Time : 2019-09-27 11:52 # @Author : icarusyu # @FileName: 二叉树遍历_全.py # @Software: PyCharm class treeNode: def __init__(self,val = None): self.val = val self.left =None self.right = None class solution: # 栈实现非递归先序遍历,复杂度O(n) # 思路 # 遍历node时,打印-存起来-移动到左子节点...
21164843eccf32ab55d740847f8990ec306255de
OmniaSalah/CompilerProject
/regex.py
652
4.3125
4
# -*- coding: utf-8 -*- """ Created on Fri Jun 4 23:00:55 2021 @author: LENOVO """ import rstr import re # ask the user to input the regular expression regex=input("Enter regex :\n") # print examples for strings that accepted print("Examples for regex :\n",rstr.xeger(regex)) # ask the user to input if he want to ...
9eedbe5c37d4ecb70ddf723bc6abbb206c4ae7e7
CamA-JCU/cp1404practicals
/prac_02/randoms.py
575
3.9375
4
import random print(random.randint(5, 20)) # line 1 # for line 1 i got 7 # the smallest number i could have seen is 5 and the largest 20 print(random.randrange(3, 10, 2)) # line 2 # for line 2 i got 9 # the smallest number i could have seen is a 3 and the largest 9. # Line 2 could not produce 4 as it has an...
5ecd6088eb904e7d990a96acb9e20fd20ebbb5a6
ori-code/-
/Python/שבוע 4/מעבדה/Untitled-1.py
315
3.734375
4
while (a<=10 or a>=99 and (a)): a = int(input(' Enter a two digit number')) b = a//10 c = a%10 if (b%2==0 and c%2!=0): break #print('zugi no zugi' ) elif (b%2!=0 and c%2==0): break #print('izugi zugi') else: print ('zugi zugi or izugi izugi') cou += 1
9166ae3a15b9f1019231d95d01c498024911f3ed
cmehta/HackerEarth
/Consecutive_letters.py
796
3.703125
4
''' You simply need to perform one operation - if there are two same consecutive letters, delete one of them. Input: The first line contains an integer T, denoting the number of test cases. Each test case consists of a string S, which consists of only lower case letters. Output: For each test case, print the answer t...
c0040fbac423df5313be2f24517f4c9262218e14
nithabalakrishnan/python-challenge
/PyPoll/main.py
2,156
3.65625
4
import csv import os def readingPolling(): # file paths PyPollcsvPath=os.path.join('Resources','election_data.csv') PyPollOutputPath=os.path.join('Resources','Results.txt') # read csv file with open(PyPollcsvPath, mode='r') as csvfile: pyPollReader = csv.reader(csvfile, delimiter=",") ...
6a2f191b5d4be4ae660ea306b7803fd8df58497d
ramnadella/GRIP
/K-Mean Clustering _TASK#2.py
3,743
4.375
4
#!/usr/bin/env python # coding: utf-8 # ### TASK 2: K- Means Clustering # # This notebook will walk through some of the basics of K-Means Clustering. # In[1]: # Importing the libraries import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn import datasets # In[3]: # Load the iris d...
4f80e3c429dcbe8d7509e97c773381aa2fa0ae68
duynguyenhcmus/Py4DS
/Lab2/Ex3_Exploratory_Data_Analysis.py
7,126
3.828125
4
# Exercise 3. Exploratory Data Analysis # Load Libraries import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns def main(): # Load dataframe path = '/home/dinh_anh_huy/GitHub/2020-2021/semester-1/python-for-data-science/Lab2/creditcard.csv' df = pd.read_csv(path) ...
65b8729a30e8e288bc337058198864959e39eef6
Sturmtiger/PythonCourse2
/iterators_and_generators_lesson.py
4,120
3.984375
4
from random import random #ИТЕРАТОРЫ #Итератор - класс, генератор - функция # lst = [54, 23, 20, 54] # #--- # for i in lst: # print(i) # #--- # x = iter(lst) # цикл while примерно представляет более глубоко, как работает цикл for # while True: # # try: # i = next(x) # print(i) # except ...
056a0cd4ac4e2f5ac663ca22c4fa37256f3f9f08
Artemish/School
/crypto/affine/numtools.py
265
3.71875
4
def gcd(a, b): if (b > a): (a, b) = (b, a) while True: (quotient, remainder) = divmod(a, b) print(str(a) + " - " + str(quotient) + "*" + str(b) + " = " + str(remainder)) a = remainder (a, b) = (b, a) if (remainder == 0): return
fd55fa364add15aa39f005e1e0e8c959557e2d7e
Sensaku/6QuiPrend
/src/GameEngine.py
1,480
3.609375
4
from Board import * from card import * import random class Engine: def __init__(self): self.board = None self.deck = [] self.players = [] def initilisation(self): self.board = Board() def generate_card(self): for i in range(1, 105): if i % 11 == 0: ...
8cffbc14ae239aabaab76064030e86b256e43bb7
alathers/AdventOfCode
/2020/5/5.py
962
3.546875
4
#!/usr/bin/env python3 # # Adam Lathers alathers@gmail.com # ''' problem: part 1: for each ticket, calculate the seat_id, which is (row * 8) + col report max ''' import math with open('input.txt') as f: infile = f.read().splitlines() # I don't actually need to store anything I don't think # as the proble...
13a3ce78d19ea56e869226811a9b2fcf76c6c9cd
songyqdevote/Python-100-Days-Practisetice
/Day01-15/code/Day05/guess_song.py
596
3.546875
4
#!/usr/bin/env python # -*- coding:utf-8 -*- # @FileName :guess_song.py # @Time :2020/8/30 17:28 # @Author :宋业强 from random import randint if __name__ == "__main__": count = 0 answer = randint(1, 100) while True: count += 1 num = int(input("请输入一个数:")) if num < answer: ...
73c5cff74b64457c4fdd0368f30b619e070e03f8
songyqdevote/Python-100-Days-Practisetice
/Day01-15/code/Day08/test.py
544
3.9375
4
#!/usr/bin/env python # -*- coding:utf-8 -*- # @FileName :test.py # @Time :2021/6/6 16:04 # @Author :宋业强 def index_words(text): result = [] if text: result.append(0) for index,letter in enumerate(text,1): print(letter) if letter == " ": result.append(index) ...
f879c0a53bf7510fd37c2f2dfccb933126e50d17
songyqdevote/Python-100-Days-Practisetice
/Day01-15/code/Day08/rect_song.py
566
3.5625
4
#!/usr/bin/env python # -*- coding:utf-8 -*- # @FileName :rect_song.py # @Time :2021/1/16 15:00 # @Author :宋业强 class Rect: def __init__(self,width = 0, length = 0): self._width = width self._length = length def area(self): return self._width * self._length def __str__(sel...
9117be1350e5fd5318587b83c717e650ea00c1f1
apreziosir/Flow_PT
/FDM/LHS_Build.py
15,973
3.703125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Sep 27 15:45:42 2017 Function to build LHS of equation system in a different way. Takes into account Dirichlet and Neumann BC for different cases @author: toni """ import numpy as np import scipy.sparse as scsp # ======================================...
bbcada9cb27279eb76348b80d855fd07e781f239
andye456/OXO
/RunFromSavedModel.py
1,429
3.515625
4
import tensorflow as tf from RunGame import run_game from model import TicTacToeModel ticTacToeModel = TicTacToeModel(9, 3, 100, 32) # Get the model from the saved file loaded_model = tf.keras.models.load_model("OXO_model") # Set the model to use in the game to be the one just loaded ticTacToeModel.set_model(loaded_...
edea5333678508b0538a64e09144184c1e708e24
Vysnavi/Python-Progams
/encryptedmessage.py
627
3.9375
4
def encrypt(sentence): words_list = sentence.split("") print(words_list) for i in range(0,len(words_list)): if (i+1) % 2 != 0: words_list[i] = words_list[i][::-1] else: temp_words ="" vowels = "" for char in word...