blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
af8022cdf5455fba431022649466cc9c138f2aa0
llukitas/Heuristic
/Greedy/TSP/__init__.py
105
3.5
4
# Algoritmo Voraz Greddy A= [6,3,2,7,5,5] A= sorted(A) for i in range(len(A)//2): print(A[i], A[~i])
81dc35a2ba84b4901b390e865ed8efd9aba9b0a5
NikiDimov/SoftUni-Python-Basics
/first_steps_in_coding/square_area.py
82
3.75
4
def square_area(n): return n * n num = int(input()) print(square_area(num))
e469292b6de7c0ed743f7fda545c4948e7cf9459
dotslash-web/PY4E
/Course 3 - Using Python to Access Web Data/Chapter 12/Lecture Material/ParsingWebPages.py
1,888
3.859375
4
'What is Web Scraping?' #When a program or script pretends to be a browser and retrieves web apges, looks at those web pages, extracts information, and then looks at more web pages #Search engines scrape web pages - we call this "spidering the web" or "web crawling" 'Why Scrape?' #might not be legal lmaooo #Pull data ...
9f794cf2ac5c20a2c8dd8c8de993d28c8df6bf32
chenxuhl/Leetcode
/腾讯精选50题/34Rotate_List/rotateRight.py
1,804
4.0625
4
#61.旋转链表 """ 题目描述: 给定一个链表,旋转链表,将链表每个节点向右移动 k 个位置,其中 k 是非负数。 """ #示例1: """ 输入: 1->2->3->4->5->NULL, k = 2 输出: 4->5->1->2->3->NULL 解释: 向右旋转 1 步: 5->1->2->3->4->NULL 向右旋转 2 步: 4->5->1->2->3->NULL """ #示例2: """ 输入: 0->1->2->NULL, k = 4 输出: 2->0->1->NULL 解释: 向右旋转 1 步: 2->0->1->NULL 向右旋转 2 步: 1->2->0->NULL 向右旋转 3 步: 0->1-...
5223ea41e2cfb99ed5adb7a95d3e938b715c5df6
rdelacrz/MetricsReporter
/xl_writer/__init__.py
2,280
3.75
4
""" Contains code for producing various kinds of Excel writers. """ # Built-in modules from time import strftime # Third-party modules from utilities import create_dirpath from xlsxwriter import Workbook class XLWriter(object): """ Abstract class for producing a generic Excel sheet from scratch. It should be i...
f421284b5dc5f98866c02e963dd552aca7b652ec
lulumenon/GameCards
/game_cards.py
5,703
3.890625
4
import sqlite3 from time import time from random import randint import os.path # This is finding the path to the database file BASE_DIR = os.path.dirname(os.path.abspath(__file__)) db_path = os.path.join(BASE_DIR, "computer_cards.db") #This is connecting the database conn = sqlite3.connect(db_path) #This counts how...
8813e1d11cb45aa3524801dcd39255be8a64165b
wanx-wan/OOP
/reg63114540210.py
1,187
3.75
4
class Reg: subject = "There are no courses that can be taken." def __init__(self, number, subject, code): self.number = number self.code = code if number == "63123456789": self.number = "Please enter these courses." if code == "123456": s...
6dc82797e9edae5d7fefd459af63784bda59738f
DouceurTengu/PythonTipsAndTricks
/calculate_age_from_dates.py
1,118
4.5625
5
''' :param: birthdayDate: Date of birth :param: today: the date you wish to compare to the birth date to compute age :return: returns an integer value representing the difference of the two dates NOTE: if you want to use this function with a pandas dataframe, you'd apply it as follows: today = df.columns.get_loc('tod...
24b569d80929fcfb450f03da1e2a4b725e6a7501
yif042/leetcode
/Python3/no203_Remove_Linked_List_Elements.py
783
3.796875
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def removeElements(self, head, val): """ :type head: ListNode :type val: int :rtype: ListNode """ if ...
e9c848429b2b0dab5ad58671de41dcf387b1dc4a
Caroleq/cryptopals
/chall9.py
702
4.125
4
def pad_pkcs7(text, num=16): """ Data are padded so after function execution len(text)%num == 0 If in original text len(text)%num == 0, additial padding block is added Padding value is chr(num - len(text)%num) Padding canbe performed for string or byte objects """ padding_length = num - len(text)%num ...
2874463ab41322c513689b3b1e2bdba9cb0f8970
ProgFuncionalReactivaoct19-feb20/clase04-jecueva1997
/ejercicio3.py
441
4.34375
4
""" Ejercicio 3 autor: jecueva11 # encontrar la siguiente estructura # [((20, 4), "c"), ((30, 1), "b"), ((100, 2), "a")] """ # datos lista = [(100, 2), (20, 4), (30, 1)] lista2 = ["b", "a", "c"] # utilizacion del map para transformar en mayusculas listaM = map(lambda x: x.upper(), lista2) # presentacion de una li...
53bfd89cf859e0fb856446fcf26277d867f630c4
0kba/python
/int type.py
388
3.9375
4
list = [1, "learning python", [], object() ] for int in list: thekind = type (int) print(f" (( {int } )) type is { thekind}") # # result__________________________________________ # (( 1 )) type is <class 'int'> # (( learning python )) type is <class 'str'> # (( [] )) type is <class 'list'> # ((...
20784d7f183c2a91567075decaa12434050b82f3
doubiiot/myLeetcode
/链表/question19/method1.py
534
3.78125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode: p = ListNode(-1) p.next = head q = p o = p list_len = 0 ...
9c91179893835098b2a917757be4727e02cf2cbc
Kiez-Schnitzel/Kiez-Prototype
/Files/rename.py
1,069
3.546875
4
# https://datatofish.com/rename-file-python/ # https://docs.python.org/3/library/os.html#module-os import os import datetime file = input("Bitte geben Sie eine Datei an: ") # Pfad zur Datei # Windows project_root = 'C:\\Users\\exark\\Dropbox\\Private\\coding IXD\\Files\\project_root\\' """ # Raspberry ...
8be34a1cbebec7625470c745182aad5435e6e279
SchermannR/smartninjaWebDev1Python
/lists_and_dictionarys.py
2,122
4.375
4
""" introduction/recap """ a = 1 b = 1.5 c = "string" d = True print(type(a)) print(type(b)) print(type(c)) print(type(d)) """ soft start lists """ some_list = [1,4,12,413,123,18,43] print(type(some_list)) print(some_list) another_list = ["VW","BMW","Mercedes"] print(type(another_list)) print(another_list) another_anot...
34534dff4d2f37aeba6026eb77463d675c7f89a9
sdytlm/sdytlm.github.io
/downloads/code/LintCode/Balanced-Binary-Tree.py
865
3.921875
4
""" Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ class Solution: """ @param root: The root of binary tree. @return: True if this Binary tree is Balanced, or false. """ def maxPath(self, root): if ro...
1afbb9c1bd571e2c1bb76dea9628614a1f096a86
zideajang/python_tuts
/supercharge_your_classes_with_python_super_function/demo_02.py
755
3.8125
4
class Tut: def __init__(self,title,lesson): self.title = title self.lesson = lesson def descrition(self): return f"title: {self.title} , lesson: {self.lesson}" # class Video: def __init__(self,title,lesson): self.title = title self.lesson = lesson def desc...
c85eb2450f49b709ec0badca91938c5f18239b3e
Kuznetsova-28/101programmingtasks
/20.py
525
4.28125
4
Дано число X. Определить, принадлежит ли это число заданному промежутку [a,b]. x = input("введите число для проверки") a = input("укажите начало промежутка") b = input("укажите конец промежутка") if a <= x <= b: print("Число ", x, "Принадлежит множеству [",a,",",b,"]") else: print("Число ", x," не принадлежит ...
199d0d75c0d3c3c4d72e8bc4020f3df0360f13b2
Lokesh-Jothivincent/AppliedMath_Lab
/NumpyIntro/numpy_intro.py
3,447
4
4
# numpy_intro.py """Python Essentials: Intro to NumPy. <Name> Lokesh <Class>Mth 520 <Date>1/29/21 """ import numpy as np def prob1(): """Define the matrices A and B as arrays. Return the matrix product AB.""" #raise NotImplementedError("Problem 1 Incomplete") A=[[3,-1,4],[1,5,-9]] A=np.array(A) B=[...
8dc14b80c4b868a667967048cb78c89787da032a
azuline/aoc2020
/python/src/day05.py
979
3.546875
4
#!/usr/bin/env python from pathlib import Path from typing import List INPUT_FILE = Path.cwd().parent / "inputs" / "day05.txt" def transform_input(input: str) -> List[str]: return input.splitlines() def part1(passes: List[str]) -> int: return max(transform_to_costs(passes)) def transform_to_costs(passes...
96f8a27ce1e9f36e92dd23a99bb0e60600911b95
Timo-Vehvilainen/SheetMusicMaker
/note.py
1,488
3.96875
4
''' @author: Timo Vehvilainen ''' class Note(object): ''' The Note object represents one note or rest on the staff ''' ''' -Initializer- PARAMETERS: - note pitch (an integer from 0 to 11), which correspond to different notes (lowe...
4cbd12820710f1271d60496edfef12c7a0b9a012
eduardofesilva/Processamento-De-Imagens
/Lista3/ex1_FEITO.py
823
3.734375
4
from PIL import Image # Carregando a imagem im = Image.open("ceu.JPG") # Buscando o tamanho da imagem w,h = im.size # Eximbindo a imagem (com o xv) im.show() # Dica: trabalhe a imagem original em uma nova imagem # criando uma nova imagem "RGB" do mesmo tamanho da # original imluz=Image.new("RGB",(w,h)) # Exercicio...
2b89b716161be0c9551c2aee5d849c90185aa017
jaganrajagopalme/Python
/StringCommand.py
77
3.671875
4
myphrase="Welcome to India" myvalue=myphrase.upper().isupper() print(myvalue)
2bde24aec0d633cd57c89340458f9471865b55d9
ankawm/NowyProjektSages
/type_seq_unpack_split.py
1,323
4.21875
4
""" * Assignment: Sequence Unpack Split * Required: yes * Complexity: easy * Lines of code: 1 lines * Time: 3 min English: 1. Using `str.split()` split input data by white space 2. Separate ip address and host names 3. Use asterisk `*` notation 4. Run doctests - all must succeed Polish: 1. Używają...
ee3f5d3991197c0bc1f365396590d6687cd2f025
charuj/interviewcake
/3_highest_product.py
1,533
4.28125
4
''' 3.Given a list_of_ints, find the highest_product you can get from three of the integers. The input list_of_ints will always have at least three integers. ''' import heapq import numpy as np def highest_product(list_of_ints): # if all positive or negative numbers prod=0 if all(x<0 for x in list_of_in...
5d46e44dd99ee24554dde101a91be6ada3df32c2
FranckCHAMBON/ClasseVirtuelle
/Term_NSI/devoirs/4-dm2/Corrigé/S7/E10.py
2,225
3.609375
4
""" Prologin: Entraînement 2003 Exercice: 10 - Solitaire https://prologin.org/train/2003/semifinal/solitaire """ def solitaire(grille:list) -> int: """ Prend une grille qui décrit des positions d'un jeu de solitaire puis recherche et renvoie le nombre de coup possible >>> solitaire([[2, 2, 0, 1, 1, 2, 2], [2, ...
89d55bfc4b5e8fadba7bfb8e96144ba47f521b57
Samclouder/Hacktoberfest
/Udemy/is-prime.py
491
4.15625
4
def is_prime(number): if(number < 2): return False #check if number is divisible by 2 to number - 1 for divisor in range(2, number): if number % divisor == 0: return False return True if __name__=='__main__': n=int(input("Enter your ...
c832b0a45bf1ed7e21bdf7cd1c217a22a646eaff
penkin1993/algo2
/ex10/eq_parse.py
4,335
3.515625
4
""" Module with class for mathematics expressions parsing """ import sys import typing import operator import pyparsing as ps class EqParse: """ Class for parsing and calculating math expression """ def __init__(self): self.__var_dict = {"+": operator.add, "-": oper...
88e6012a4884e152b0ee0fd15c15e049189542a2
Noya-santiago/Python-crash-course
/5- Super easy calculator/Easy Calculator.py
458
4.15625
4
""" We're gonna make a basic calculator!! """ num1 = input("Enter a number: ") num2 = input("Enter another number: ") result = num1+num2 #If you dont specify what are those variables python will understand they as strings... so the result would be the number following the another print(result) result = int(n...
d9f5e020ab4ad87abe59014aa01ee7bfe2b377c9
kjthoward/AdventOfCode2020
/Day 1 - Report Repair.py
633
3.5
4
numbers=[x.strip() for x in open("Day1_input.txt","r").readlines()] # Part 1 for i in range(len(numbers)): for num in numbers: if numbers[i]!=num: total=int(numbers[i])+int(num) if total==2020: print(int(numbers[i])*int(num)) #Part 2 for i in range...
9f35f2f0799ded1f58fc1ff53f9d76f8f420f691
gabriellaec/desoft-analise-exercicios
/backup/user_102/ch32_2019_08_28_17_54_30_379941.py
206
3.921875
4
tem_duvida = True while tem_duvida: resposta = input("Alguma Duvida? (s/não): ") if resposta != "não": print("Pratique mais") else: tem_duvida = False print("Até a próxima")
394fd0553e11cb71f869af95864c46641f5c5109
JadenTurnbull/Crash-Course-Python
/chap08/TryItYourself_p200.py
598
3.90625
4
#8-3 def make_shirt(size, text): print(f"The shirt's size is {size} and you want {text} written on it") make_shirt('large', 'lol xD') make_shirt(size = 'medium', text = 'lol xDs') #8-4 def make_shirt(size = 'large', text = 'I love Python'): print(f"The shirt's size is {size} and you want {text} written on it") m...
bdb963af557b022a496bc4fdf1124b7d8e6bd181
JMGoebel/lc101
/initials.py
540
4.0625
4
""" initials.py: Takes users name as input and returns their initials """ def get_initials(fullname): """ Given a person's name, returns the person's initials (uppercase) """ initials = fullname[0] for index, char in enumerate(fullname): if char == ' ': initials += fullname[index+1] ...
c01147bfdf2f006e2182d9bd4fa9e87e0cfa2e42
gyaresu/stuff
/salary_rise.py
212
3.65625
4
from decimal import * def increase(x = input('What salary?: ')): y = 2010 q = x for i in range(21): print y, "\t", "%.2f" % x, "\t", print "%.2f" % q x = x * 1.02 q = q + x y = y + 1 increase()
4a62fbf0a4e855b9e0b26a33d783165bcabae08f
mwermelinger/m269-library
/lib/priority_queue.py
6,354
4.125
4
"""An implementation of a priority queue (min binary heap).""" # The following constants make the code more readable. _KEY = 0 # pylint: disable=invalid-name _VALUE = 1 # pylint: disable=invalid-name class PriorityQueue: """A collection of priority-item pairs. Items are accessed and removed from highest ...
8d2e93940ccc87ac3314c0ae2d4b9e8babeff15c
vrrohan/Python100DaysOfCode
/Day7-PythonListsD2/Py2-ListComprehension.py
2,064
4.40625
4
#List comprehensions offer a succinct way to create lists based on existing lists. When using list comprehensions, lists can be built by leveraging any iterable, including strings and tuples. #You can literally build a new list using another list with some conditions in a single line #[{varName} for {varName} in {listN...
048ac0ca01d60a78b97e0a079e76983a893b3d22
kagehina919/dsa
/python/hashing/subarray.py
230
3.5
4
a = [1,2,3,4] b = [1,2,3,4,5,6,7] n = len(a) m = len(b) len = 0 dict = {} for i in range(0, m): dict[b[i]] = 1 for i in range(0, n): if a[i] in dict: len += 1 if len == n: print("YES") else: print("NO")
e15cdaa24be7d4a62d8d908bbaf9175d0858572f
JorgeEstrada1/programacion
/Practico_1/Ejercicio 3.py
321
4.03125
4
dividendo = int(input("Escriba el dividendo: ")) divisor = int(input("Escriba el divisor: ")) if dividendo % divisor == 0: print(f"La division es exacta. Cociente: {dividendo//divisor} Resto: {dividendo%divisor}") else: print(f"La division no es exacta. Cociente: {dividendo//divisor} Resto: {dividendo%divisor}"...
620ca4c595973aee7c9879b7f0a4a32fd52cd02e
jinglemansweep/Kindled
/kindled/models.py
1,947
3.625
4
class Recipe(object): """ Recipe Class """ name = None filename = None def __init__(self, name, filename): """ Constructor """ self.name = name self.filename = filename class Recipient(object): """ Recipient Class """ name = None email_address = None d...
86c381432b3d50796292976aa60ec95c95491af1
ademilsoncarvalho/estudos
/python/object_oriented/ABC_example.py
461
3.65625
4
from abc import ABCMeta, abstractmethod, ABC class Software(metaclass=ABCMeta): @abstractmethod def __str__(self): return f'Software' @abstractmethod def version(self): return f'version is 1.0' class Excel(Software): def __str__(self): return f'Excel' def version(s...
77929acb16a4c1274f0f0bea20e42e5d9b9ed532
uwenhao2008/python100-
/python100题目/test85观察.py
519
3.84375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Author:Wen Time:2019年04月09日 10:33 tip-->兴趣是最好的老师<-- """ # 输入一个奇数,然后判断最少几个 9 除于该数的结果为整数 rawData = int(input("请输入一个奇数")) def divisionX(): n = '9' while 1: if int(n)%rawData == 0: print(int(n)) print("{}可以整除{}".format(n,rawData)) ...
92f1db24de612c9c94ddd7fa2b7f495f292ffa89
fleamon/algorithm_python
/programmers/level1/exam/KeypadPush_20201025.py
4,528
3.59375
4
# -*- encoding: utf-8 # https://programmers.co.kr/learn/courses/30/lessons/67256 def solution(numbers, hand): answer = '' leftRow = 1; leftCol = 1 rightRow = 1; rightCol = 3 for number in numbers: if number in (1, 4, 7): if number == 1: leftRow = 4; leftCol = 1 ...
c2d5a3fe38ee6f6426f984299336df8f43ad070e
Artem-Brunov/msu_prac
/python/UnaryNumber.py
578
3.859375
4
class Unary: def __init__(self, string): self.count = len(string) self.counter = 0 def __len__(self): return self.count def __or__(self, other): return Unary("|"*(self.count + other.count)) def __invert__(self): self.count = self.count//2 return self def __next__(self): if self.counter == self.count:...
8393268e7e214e49cf89a1b9bf9f144a3237072b
ammareltigani/top-lists-aggregation
/code/quick_sort_det.py
3,032
3.796875
4
import time import utils import quick_sort_base as qsb ALGORITHM_NAME = "QS-Det" def run(data, params): """ This method implements a quick-sort algorithm that uses a deterministic pivot-selection. In particular, each candidate in a list is considered as a pivot, and the chosen pivot i...
0bc19c8864e895be1e82c54bd761868ef6d6d754
evheniib/lesson2
/if_task_2.py
677
4.1875
4
def str_comparison(str1, str2): if type(str1) is str and type(str2) is str: if str1 == str2: return 1 elif str1 > str2: return 2 elif str1 != str2 and str2 == "learn": return 3 else: raise ValueError("Your variables are not string") test_var =...
6a5d46509f614630d6f13e8c44d8856eec35121e
Navi-nk/MachineLeaningCA
/MovieRecommender/popularity.py
977
3.6875
4
# This function is to determine popularity based on n number of popularities of similar movies provided # currently function returns 1 -> Low (rating <5) 2 -> Medium low (rating <15), # 3 -> Medium (rating <30), 4 -> High (rating <100), 5 -> super (rating > 100) # popularity probability of movie provided in request ...
f0f81abf30f6b188e9a7cc2621921acccc5a1140
dstahtis/Bootcamp
/exercise2.py
411
3.78125
4
fifty = int(input("Enter number of 50 euro banknotes: ")) twenty = int(input("Enter number of 20 euro banknotes: ")) ten = int(input("Enter number of 10 euro banknotes: ")) five = int(input("Enter number of 5 euro banknotes: ")) two = int(input("Enter number of 2 euro coins: ")) one = int(input("Enter number of 1 ...
4eec82ca9c23182f3776fac1e5ea4caa23d90c60
StanleyFung/advent-of-code-2017
/day18/duet.py
12,493
3.734375
4
""" --- Day 18: Duet --- You discover a tablet containing some strange assembly code labeled simply "Duet". Rather than bother the sound card with it, you decide to run the code yourself. Unfortunately, you don't see any documentation, so you're left to figure out what the instructions mean on your own. It seems like ...
167fd7b157d31ab8f92a0237eecc11bb266a5381
pythonvirus/R_Python_PySpark_AzureML_Scrapping
/M.Tech/DSAD/A1_PS11_TF_G143_BST_Tree_code.py
17,002
3.875
4
#Global Variables PoliceRoot=None counter=0 class DriverHash: def __init__(self): """ Updating the Default constructor. initializes DriverHash Class Object which points to NULL """ self.driverhash = None def initializeHash(self): """ initializes Hash Tabl...
bad69f81f28b91d4aae620a36476159d8cca25c4
RondaStrauch/landlab
/landlab/grid/voronoi.py
34,968
3.515625
4
#! /usr/env/python """ Python implementation of VoronoiDelaunayGrid, a class used to create and manage unstructured, irregular grids for 2D numerical models. Do NOT add new documentation here. Grid documentation is now built in a semi- automated fashion. To modify the text seen on the web, edit the files `docs/text_fo...
58f9816dd75af68cafe95fc396c666221b71b35c
Jintze/8-puzzles
/8-puzzles.py
15,583
4
4
import random import math # Lab Assignment #4 # 8-Puzzles Problem # # AUCSC 460 # Author: Jinzhe Li # Instructor: Mi-Young Kim # # This Python program uses simulated annealing algorithm to find the solution. class State(): def __init__(self, first, second, third, fourth, fifth, sixth, seventh, eighth, nineth): s...
f862ce73e010ab77847744884b2097592d6c7e67
vaidyabh/Python
/loops_in_python.py
628
4.40625
4
""" This python file contains the loops statement in python. Contains sample data and the logic to parse the List and Dictionaries over the if, while and for loop. """ #Defining the lists and the dictionary list1 = [1,2,3,4,5] dict1 = {1 : "Python Data", 2 : "Loops in python", 3: "sample data"} #Printing the eleme...
dcf077ad45d368b5e33f02e9255050a1ee959ed4
dinysen/leetcode-algorithm
/easy/283_移动零.py
713
3.734375
4
#/usr/bin/env/ python3 #-*- coding: utf-8 -*- #给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。 #必须在原数组上操作,不能拷贝额外的数组。 #尽量减少操作次数。 class Solution: def moveZeroes(self, nums): """ :type nums: List[int] :rtype: void Do not return anything, modify nums in-place instead. """ #这里最简单的操作就是将不是0的元素放到前面 #当j指向0时会停止,随后...
94c527efe9c623800084cd07351f9b49338ae67d
bligh18/udacity-fsnd-sql-logs
/logs.py
2,147
3.515625
4
""" SQL database logs analysis project Udacity Full Stack Developer Nanodegree program Brendon Smith https://github.com/br3ndonland/udacity-fsnd-sql-logs """ import os import records def query_result(query, is_file=False): """Helper function used to execute SQL queries. --- - Connect to database - Rea...
6bf239e64931b4e5ec7bfcd3b979d487a2a682e2
formularin/wave
/utils.py
2,473
3.859375
4
"""Useful functions for "AM and FM Radio Waves.ipynb" """ import math # ========== Trigonometry ========== # class SinExpression: """A class that allows sine expression outputs to also contain their inputs. """ def __init__(self, x): self.input = x self.multiplier = 1 self.add...
d81f86aecad1953fc342462464e042bf9fe84d2b
IrrevocableCascade/Python_Learnings
/Basic Algorithms/Bit Count.py
1,021
4.21875
4
import binascii __author__ = 'Irrevocable Cascade' """As you probably know, all values inside a computer are represented in binary system. In this simple task you are to write a program which counts the number of non-zero bits in a given value. For example: value binary count 1 000000...
26103d5e437489c970e0c8c3ab482ae7fb6a5226
rayt579/leetcode
/bit_manipulation/counting_bits.py
391
3.515625
4
''' https://leetcode.com/problems/counting-bits/description/ ''' class Solution: def countBits(self, num): """ :type num: int :rtype: List[int] """ counted_bits = [0] * (num + 1) for i in range(num + 1): counted_bits[i] = counted_bits[i >> 1] + (i & 1) ...
48c0ac3cf2bdd85dfb2ed3985eb1273a7be4729b
harshittiwari/LeetCode
/ZigZag Conversion.py
821
3.546875
4
class Solution(object): def convert(self, s, numRows): """ :type s: str :type numRows: int :rtype: str """ ret = "" for i in range(numRows): rem = numRows - i - 1 if i % 2 == 0: ret = ret + s[i::numRows + numRows // 2] ...
e3f5ae21863b81e19b85c9ef7bd8b21c090cdb69
w312752508/Python_study
/day03/str.py
305
4.09375
4
''' 猜数字3、7、3的倍数、7的倍数游戏 ''' while True: num = input("输入数字:") if num == "q" : break elif int(num)%3==0 or int(num)%7==0 or str("3") in str(num) or str("7") in str(num): print(">>>PASS\n") else: print(">说出数字:",num,"\n")
13d3bbdfefb385ce5345f234c52f783bfa68ec14
654866438/week5
/colourLerp - 副本.py
853
3.59375
4
first=input('Enter the first colour: ') sec=input('Enter the second colour: ') total=int(input('Enter the number of colours to generate inbetween: ')) Red1=int(first[2:4],16) Red2=int(sec[2:4],16) if(Red1>Red2): tmp=first first=sec sec=tmp Red1=int(first[2:4],16) Green1=int(first[4:6],16) Blue1=int(first[...
63568eba213a438a4d7011cf86949a5152f59fef
Leo-Dennis/assignments
/04prime_number.py
300
4.03125
4
# Prime Numbers kalan = [] number = int(input("Enter a number: ")) for i in range(1,number): kalan.append(number % i) if number == 2: print(f"({number}) is a prime number.") elif 0 in kalan[1:]: print(f"({number}) is not a prime number.") else: print(f"({number}) is a prime number.")
ea02273ad3216e9738cd70f51ce2def51837c12f
JinGang1998/learn_python
/re/match.py
2,127
3.6875
4
#re.match尝试从字符串的起始位置匹配一个模式,如果不是起始位置匹配成功返回none #re.match(pattern,string,flags=0) pattern:匹配的正则表达式 # string:要匹配的字符串 #flags :控制匹配方式 #re.I|M 多个匹配方式用|连接 #re.I大小写不敏感 ...
3aabafe6023f9b747c812eba773ba5c544fab68d
Ckzzz1/Homework2
/plot.py
1,635
3.609375
4
import matplotlib.pyplot as plt import matplotlib colors = ['red', 'green', 'blue', 'black', 'orange'] class plot(): # 通过修改配置文件matplotlibrc初始化中文字体 # 绘制直方图 def rect(self, dict, name): label = dict.keys() num = [dict[i] for i in dict.keys()] x = range(len(num)) fig = plt.fig...
2d7ad13a3aea5f1aeef7a1fd5feac273bb8f20ac
wude935/CS-313E
/Assignment 9/Bridge.py
4,872
3.984375
4
# File: Bridge.py # Description: This program will calculate the quickest time it takes n number of people to cross a bridge by utilizing two different strategies # Student Name: Victor Li # Student UT EID: vql83 # Partner Name: Derek Wu # Partner UT EID: dw29924 # Course Name: CS 313E # Unique Numbe...
843d1bebd6729214e9075fe02001e029e1a332b7
cdobbs-code-repo/Sunday-Puzzle-Python
/10_04_2020/sunpuzz_10_04_2020.py
1,485
3.875
4
import cmudict from PyDictionary import PyDictionary pydict = PyDictionary() def three_i(bar): count = 0 for x in bar: if x == "i": count += 1 return (count == 3) foo = open("C:/Users/cdobb/AppData/Local/Programs/Python/Python38-32/Lib/site-packages/enchant/data/mingw32/sh...
4817af85b445223696de6dfcbfa2169d532cb00f
cocoon333/leetcode
/791_custom_sort.py
926
4.0625
4
""" order and str are strings composed of lowercase letters. In order, no letter occurs more than once. order was sorted in some custom order previously. We want to permute the characters of str so that they match the order that order was sorted. More specifically, if x occurs before y in order, then x should occur be...
1424b9365eb09d43f7ebfe877235a6273983af56
amirunpri2018/movidius_video_tracking
/src/box_utils.py
1,527
3.5625
4
""" Bounding Box util functions """ def scale_box(box, image): x1, y1, x2, y2 = box height, width, _ = image.shape scaled = [x1 * width, y1 * height, x2 * width, y2 * height] scaled = [int(s) for s in scaled] return scaled def clip_box(box): x1, y1, x2, y2 = box x1 = max(0, x1) y1 ...
c446bebb2682bf018851e94aa2f98c0bcca90d64
andrzejpindor/python-tic-tac-toe
/task/tictactoe/game.py
2,587
3.53125
4
import numpy from collections import Counter def _validate_coordinates(move): if len(move) != 2 or not move[0].isalnum() and not move[1].isalnum(): print('You should enter numbers!') return False else: return True def _print_border(): print('---------') def _print_line(line): ...
015c6d8cd4e00984d049cf149fe91d68a05551e7
koandamb01/AlgoHome
/data_structures/simpleAlgos.py
864
4.25
4
# write a function that take an integer number as an input and return true if the number is prime # and return false if the number is not prime def isPrime(num): i = 2 while i*i <= num: # i < sqaureRoot(num) if num % i == 0: print(f"{num} is divisible by {i} so it's not a prime number") ...
e91099fc72c775a6b901e4b21277151f9b4d07e7
Aguu21/Python
/Ejercicio18b.py
289
3.703125
4
lista = ["Di","buen","dia","a","papa"] def inversorListas(lista): '''Dada una lista, entrega la misma con las mismas cadenas pero con el orden invertido''' for i in range(0, int(len(lista)/2)): lista[i], lista[-i-1] = lista[-i-1], lista[i] return lista
76c5ac05524a7940dddc5950f996df30514405f9
MissAquarius/LearnPython
/AdvanceFeatures.py
8,255
3.75
4
# -*- coding:utf-8 -* from collections import Iterable from collections import Iterator import os # 切片L[a,b] 表示从索引L[a]开始取,到索引L[b],不包括索引L[b] L=list(range(100)) print(L[0:10]) #取前十个数 print(L[90:100]) #取后十个数 print(L[10:20]) #取前11-20十个数 print(L[0:10:2]) #取前十个数,每2个取一次 print(L[90:100:5]) #取后十个数,每5个取一次 print(L[:]) #...
78c9d266bfdc6ef735b6eeabb753b2dc6475a94e
KHilse/bracket-matcher
/Stack.py
1,521
4.125
4
class Node: def __init__(self, data): self.data = data self.next = None class Stack: def __init__(self): self.head = None def isEmpty(self): """Returns True if Stack is empty, False otherwise""" if self.head: return False return True def pus...
e0ba70a8c5f135021087dfeb1ce2ea602fc9d50c
Krope/py4e
/MySQL/OOP/OOP.py
271
3.625
4
stuff = list() stuff.append('python') stuff.append('Chuck') stuff.sort() print(stuff[0]) print(stuff.__getitem__(0)) print(list.__getitem__(stuff, 0)) usf = input('Enter the US Floor Number: ') wf = int(usf) - 1 print('Non-US Floor Number is {}.'.format(wf))
9522c5b128f4d5cd820bb861092182faab9d6358
googoles/Python_Algorithm
/OOP/triangle.py
371
3.6875
4
import math class Figure: def __init__(self,length, name): self.length = length self.name = name def get_area(self): return (math.sqrt(3)/2) * self.length**2 def get_name(self): return self.name def __del__(self): print("Object is deleted") square = Figure(10...
3224bcb47bb10b3253b96a7ddf94d824f092d8ba
paulatumwine/bc-wk2
/app/person.py
3,723
3.703125
4
from abc import ABCMeta from .room import Office, LivingSpace from .utility import generate_id, Storage class Person(object): """ A base class for the different kinds of people accommodated at the Dojo """ __metaclass__ = ABCMeta people_total = 0 def __init__(self, name): try: ...
bb2806a993ac35f675d3486f123fe3a73d8a9772
L0GI0/Python
/Codes/exponent_function.py
252
4.6875
5
#!/usr/bin/python3 #exponent function in python print(2**3) #2^3 #we crating our exponent function def raise_to_power(base_num, pow_num): result = 1 for index in range(pow_num): result *= base_num return result print(raise_to_power(3, 2))
a69990c633bcd3079d50ab01bce3a8e8a2650341
Thiagomrfs/Desafios-Python
/aula12/desafio036.py
517
3.765625
4
# 36 - pergunte o valor de uma casa, o salário do interessado e em quantos anos ele irá pagar. # a prestação mensal não pode exceder 30% do salário do interessado ou o empréstimo é negado. house = int(input("Digite o valor da casa: R$")) sal = int(input("Digite o salário do interessado: R$")) time = int(input("Em quan...
2dd90b8e66e4077ad1b10e1aeea60226732debee
TimothyJao/pythonlearning
/lambdas/zip.py
337
3.578125
4
midterms = [80, 91, 78] finals = [98, 89, 54] students = ['dan', 'ang', 'kate'] final_grades = {pair[0]: max(pair[1], pair[2]) for pair in zip(students, midterms, finals)} print(final_grades) scores = zip( students, map( lambda pair: ((pair[0]+pair[1])/2), zip(midterms, finals) ) ) pr...
4fbf689b319d0f5c4bef49421f6859a7dd37c280
tabatagloria/curso_video_Python
/Mundo_2-Estruturas_de_Controle/desafio_37.py
662
4.21875
4
#conversão de número para bináio, octal ou hexadecimal import math numero = int(input('Digite um número: ')) print('Menu: ') print('1 - Binário \n2 - Octal \n3 - Hexadecimal') opcao = int(input('Escolha uma opção: '))5 if opcao == 1: print('Binário: {}'.format(bin(numero)[2:])) #[2:] só imprime o número eliminand...
9f2ba25710dfbc3f62a8a412c60b560e6cbeb4c6
ailadson/notes
/algorithms/combinatorial_search/code/8_queens.py
3,989
3.859375
4
def eight_queens(): b = Board() data = { 'board' : b, 'finished' : False, 'count' : 0 } solution = [None] * 8 backtrack(solution, -1, data) print data['count'] def backtrack(solution, step, data): if is_solution(solution, step, data): process_solution(solution, step, data) else: ...
26816d45609d7163b2be2155f6da8021c4d459f9
anirbansanu/gipy
/info.py
869
3.71875
4
from tkinter import * from tkinter.font import Font import wikipedia def on_click(): print("clicked") t.delete(1.0, END) try: ans = wikipedia.summary(e.get()) t.insert(INSERT, ans) except: t.insert(INSERT, "Error: Check your internet connection or Input Value") root = Tk() ro...
53a340afa24521fa015c361c781f1d559f578983
vhsw/CodeMasters_Tourney
/Python 3/isSmooth.py
321
3.875
4
# An array is called smooth if its first and its last elements are equal to one another and to the middle. Given an array arr, determine if it is smooth or not. def isSmooth(arr): l = len(arr) if l%2==0: mid = arr[l//2-1] + arr[l//2] else: mid = arr[l//2] return arr[0] == mid == arr[-1...
10223c74b7669d3d9bc41019e7608d441ae7b6a6
mvyushko/blackjack_surrender_game
/tests/test_surrender.py
4,521
3.5625
4
""" Testing surrender(self) method of HumanPlayer class from blackjack_with_chips with Unittest library """ import unittest from player_classes import HumanPlayer class TestSurrender(unittest.TestCase): def test_surrender_1_2(self): """ testing doubling down with 1 White and 1 Red chips in HumanPl...
0bf6aba08ead3fb34e7e2aba8b53de20b52973e7
hoangp/cs3431-18s2-project
/tests/src/reshape_test.py
246
3.71875
4
import numpy as np a = np.array([[ [1,2,3,4],[3,4,5,6],[0,0,0,0] ], [[1,2,3,4],[3,4,5,6],[1,1,1,1]], [[1,2,3,4],[3,4,5,6],[2,2,2,2]] ]) print(a.shape) print(a) s = a.shape b=np.reshape(a.flatten(),s) print("reshape") print(b.shape) print(b)
9ac4b6b3da8544f3fb478d871686e73f7c6271e8
Damianpon/damianpondel96-gmail.com
/zjazd 2/zbiory.py
257
3.5
4
zbior = set() print(zbior) zbior.add("x") zbior.add(1) print(zbior) for element in zbior: print(element) print(dir(zbior)) a = {1, 2, 3} b = {2, 3, 4} print(a | b) print((a & b)) print(a - b) print(a ^ b) print(a.pop()) print(a) print(dir(set()))
83945129dc75790ac1431e1bb7033df8a30fcb33
TUMMIDIANJANNA/Innomatics_Internship_APR_21
/Task_4.py
5,416
4.21875
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: #Question 1 def swap_case(s): return s.swapcase() if __name__ == '__main__': s = input() result = swap_case(s) print(result) # In[1]: # user defined function for sWap cASE method def swap_case(s): result = '' for letter in s: if lett...
6b31bd87edf2adbda38d16e5cdfd486ccbf46d24
artorious/food_coop_schedule_simulation
/food_coop_simulation.py
6,092
4.09375
4
#!/usr/bin/env python3 """ A Food Co-op's Worker Scheduling Simulation Schedule requires two members working (on-the-clock) at all times. Program simulates the number of people that show up for work using two different worker scheduling methods in which; - Workers sign up for certain time slots - Workers sho...
797683ebfd781c0da22fabf50c14ee020a9e4cb3
paradoxoyh/leetcode
/algorithm_82.py
1,073
3.671875
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def deleteDuplicates(self, head): if head==None: return [] cache_val,cache_listnode,tag=[head.val],[head],0 ...
0e0b519be092bf919c333a4b9b78981c524dfb55
anaselmi/simple_python
/very_simple/four_increments.py
572
3.5
4
def is_it_four(original): if len(original) == 4: return True else: return False original = [2, 3, 4, 6] def four_increments(original): right_length = is_it_four(original) if not right_length: return False else: mid = sorted(original) for i, item in enumera...
edb9722e9031eef3f54ac7219e51ce2078eef687
agnaka/CEV-Python-Exercicios
/Pacote-download/Exercicios/ex011.py
252
3.671875
4
lar = float(input('Qual é a largura da parede?: ')) alt = float(input('Qual a altura da parede?: ')) rend = 2 tinta = lar * alt / rend print('La cantidad de tinta necessária para pintar a sua parede é de \033[1;34m{:.2f}\033[m litros'.format(tinta))
d132c8729e8e892e2b8471cbabde5fdf2263e12a
piyushgoyal1620/HacktoberFest2021
/Python/sort_words_like_dictonary.py
1,020
4.375
4
def sort_words(): #defining the function for sorting the words. k=1 while k==1: #this condition is used so that the porgram doesnt stop untill all the data has been fed word=input('Enter the word, leave blank if you want to stop') #'word' variable stores the word entered by the user if ...
16b58f7e15ed0384cd28f28ccfca08fc088a3f7e
TashanM/Programs
/C4 Exercise 13.py
877
3.65625
4
# Exercise 13 # Tashan Maniyalaghan # 693776 # ICS3U0-B # 5 October 2017 # Mr. Veera print ('Enter the amount spent last month on the following items:') print (' ') food = float(input('Food: $')) clothing = float(input('Clothing: $')) entertainment = float(input('Entertainment: $')) rent = float(input('Ren...
bb2e6dc1b89e0b86ce028d9173f166477afea09d
oc0de/pythonEpi
/chap8/r3.py
705
3.984375
4
class LinkedList(object): def __init__(self, data, nextNode=None): self.data = data self.next = nextNode def hasCycle(l): if not l: return None fast = slow = l while fast and fast.next: fast = fast.next.next slow = slow.next if fast == slow: slow = l ...
6c96bffb04bae076cdc8dc8a4a40e8312b5ac00c
PuppyHacker/Content
/Managment System-Made By PuppyHacker.py
3,489
4.125
4
class Users: def __init__(self,name,pay): self.name = name self.pay = pay def get_name(self): return self.name def get_pay(self): return self.pay def get_all(self): return "name: {} pay: {}\n".format(self.name, self.pay) dict_of_users={} def add_user(...
2919e6eddbf9baf8164d460648ef6190a2d1603d
Yeansovanvathana/Python
/Python program/List program/List 3.py
86
3.5625
4
lis = [0, 1, 2, 3, 4] Max = 1 for i in lis: if i > Max: Max = i print(Max)
488897719f40077cff0e8b7ffa6795571ca3b719
ericdanz/stockdata
/stock_api_example.py
998
3.578125
4
import urllib.request as ur import simplejson as json ###This is an example call to the api ###This example was written for Python 3 #first make a request to the API endpoint url req = ur.Request('https://6rthd8ogcg.execute-api.us-east-1.amazonaws.com/prod/stockdata') #then add the headers - the first is the key fo...
b1bc50200b6b607ba5a9e03f26784453e1adb30d
jimbray/python_learning
/growing_python/py_00012/py_00012.py
494
3.78125
4
# -*- coding: utf-8 -*- __author__ = 'jimbray' def is_in_words(input_str): word_list = [] result_str = str(input_str) with open('filtered_words.txt', 'r', encoding='utf-8') as file: for line in file.readlines(): line = line.strip() if result_str.find(line) > -1: ...
577adbab3eb58822a416221104e72aa14eef4285
mattjp/leetcode
/practice/medium/0237-Delete_Node_in_Linked_List.py
726
3.90625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def deleteNode(self, node): """ :type node: ListNode :rtype: void Do not return anything, modify node in-place instead. Node...
9c117418c71d078fa1f6cdf0c559e5fbdeff2a13
maheshmnj/POPULAR_CODING_Questions_Solution
/leetcode/problem_242.py
849
3.6875
4
# Problem 242: Valid Anagram (Easy): https://leetcode.com/problems/valid-anagram/ class Solution: def isAnagram(self, s: str, t: str) -> bool: if(len(s) != len(t)): return False freq_s = {} freq_k = {} for i in range(len(s)): letter_i = s[i] lett...
f860464405a184d412878ab751c57debfc2f4f0c
Adrianozk/exercicios_python
/resolucoes/ex083.py
214
3.875
4
expressao = str(input('Digite uma expressão: ')) left = expressao.count('(') right = expressao.count(')') if left == right: print('A expressão é válida') else: print('A expressão está ERRADA')