blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
5c00bfd6d0f2446f2fa0f2ec131d4bb8ee663152
udaykiran640/265105_daily_commits
/abb_user.py
266
3.546875
4
abb=input("enter for abbreviation") if(abb =='lol'): print("laugh out loud") elif(abb=='rofl'): print("rolling on the floor") elif(abb=='lmk'): print("let me know") elif(abb=='sml'): print("shaking my head") else: print("invalid abbreviation")
1807afdf0489eac3e13b90d9340be147960c25cc
makeriet/OsloMet-kode
/Helgearrangement/mish-mash/dekoding_ressurser/letter_frequency.py
2,730
3.75
4
#source: https://gist.githubusercontent.com/mick001/aaf569cd0f027d511782/raw/9b08b6b728bc1b95d02dffe2c01d6461bfc9d942/letter_frequency.py # The following code takes as input a string of text, and then it outputs the barplot of the # frequencies of occurrence of letters in the string. import pylab as pl import numpy as ...
28a5f98d94732a35667029ad48626d8c6ab7c9ce
ylc0006/GTx-CS1301x-Introduction-to-Computing-using-Python
/Coding Problem 5.1.6.py
5,018
4.1875
4
# -*- coding: utf-8 -*- """ Created on Thu Aug 17 23:15:04 2017 @author: yan.yl.chen """ #Copy both your code and ours from the previous exercise. #You should copy your Burrito class and our Meat, Rice, and #Beans classes into this exercise. # #In this exercise, you won't edit any of your code from the #B...
f3e202eadf696a8180214fb9bb16530706799d43
olitskevich/szkolenie
/python/04_day/function.py
951
3.984375
4
# stworzyć funkcję, która jako argument przyjmuje tekst, # a zwraca słownik ze zliczonymi wystąpieniami literek w tym tekście #oblicz wystąpienia literek w tekście. Użyj słownika. #Co zrobić w kodzie: #1. tworzycie tekst (dane wejściowe) #2. tworzycie pusty słownik wystąpień dla literek (wystapienia = dict()) #3. pę...
4d2579aa6dd22eeb4fe33fd967c2fbbc2fd9a73b
aaronbushell1984/Python
/Day5/answers/q1.py
169
3.5625
4
def binary_odds(input_list): odds = [] for number in input_list.split(): if number[-1] == "1": odds.append(number) return odds
ec9c1a6ead882ea902dc3121502c7aa06cf0d4b0
nickzuck/SPOJ-solutions
/base.py
698
3.734375
4
import string digs = string.digits + string.letters def int2base(x, base): if x < 0: sign = -1 elif x == 0: return digs[0] else: sign = 1 x *= sign digits = [] while x: digits.append(digs[x % base]) x /= base if sign < 0: digits.append('-') digits.reverse() return ''.join(d...
1f5f46684ed1d133979c73496ae4cee8428febbb
somedayiamold/head-first-design-patterns
/templatemethod/barista.py
3,096
3.625
4
from abc import ABCMeta, abstractmethod class CaffeineBeverage(metaclass=ABCMeta): def prepare_recipe(self) -> None: self.boil_water() self.brew() self.pour_in_cup() self.add_condiments() def boil_water(self) -> None: print('Boiling water') def pour_in_cup(self) -...
d8f69c91298637a8e1660245900d43cfa9c9ae25
nibelungenwok/letsupgrade
/DSA/assignment2/q2.py
211
3.921875
4
""" Question 2 Write a program to print the following pattern 1 22 333 4444 55555 """ if __name__ == "__main__": for i in range(1, 6): for j in range(i): print(i, end="") print()
2218a335220a9f1f0137b3f53f361f76e36feec0
minhthaitv/Pathfinding
/A_Star.py
4,999
3.5
4
#!usr/bin/env python from tkinter import * import time import random #Mahatan def heuristic(a,b): dist = abs(b.i-a.i)+abs(b.j-a.j) return dist class Spot: #Point def __init__(self,i,j): self.i = i self.j = j self.neighbors = list([]) self.previous = 0 #tìm path s...
487e57a1d2eea2c733cf8275ab532edc05bf1a49
ipha/scripts
/wrap.py
724
3.609375
4
#!/usr/bin/env python3 import sys width = 80 last_newline = 0 if len(sys.argv) >= 2: try: width = int(sys.argv[1]) except ValueError: print("Invalid line width") for line in sys.stdin: sline = line.rstrip() if sline == "": last_newline += 1 else: if last_newline >...
16a0dd6857d9125e6f3772fb208b76c11ae7484e
skybest1/CodeHackProblem
/leetcode/array_stack/155_min_stack.py
1,010
3.9375
4
from collections import deque class MinStack(object): def __init__(self): """ initialize your data structure here. """ self.stack = [] # maintain min value of the stack self.min_stack = [] def push(self, val): """ :type val: int :rtype:...
6d2bc7881c726b70811a8203f40f4d597e7a171d
Sariohara/Face-Recognition-Pro
/Face Recogntion Pro/Face Recognition Pro.py
695
3.640625
4
import cv2 as cv import numpy as np # Get user supplied values # Create the haar cascade face_cascade = cv.CascadeClassifier('haarcascade_frontalface_default.xml') # Read the image image = cv.imread('facere.jpg') gray = cv.cvtColor(image, cv.COLOR_BGR2GRAY) # Detect faces in the image faces = face_casc...
0de8b5565e6fa137bbf6e8096631071fc3290b2c
shubhrarajadhyaksha/Wallbreakers
/Week5/isBipartite.py
996
3.671875
4
class Solution(object): def isBipartite(self, graph): """ :type graph: List[List[int]] :rtype: bool """ colors={} for node in range(len(graph)): if node not in colors: colors[node]=True stack=[node] ...
caf55f8103ef4c0c3ee60b381204b49ccafca5c0
Veronicka/PythonPO
/heranca_multipla/main.py
846
4.125
4
"""Herança Multipla - Quando uma classe herda de mais de uma outra classe. Geralmente usada em classes 'Mixin', que nada mais é que uma classe abstrada, que não foi feita para ser instanciada diretamente, ela terá uma funcionalidade para adicionar em outra classe. Essa classe Mixin, não está presenta na hierarquia d...
2a7aa101c0b7002319ad8f216d2a02506cfaec8b
chache/pystu
/quizTwo.py
440
3.609375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- '''This is the second question answer for Lovely Python 1. Build a reversed dict from an input file 2. һ 88 , 8 ʺ,ÿʺռһ ;Ҫʺ䲻໥, ʺͬһСͬһлͬһԽ,ʹж ֲͬķ ''' import os, sys
f222fb123b1881e57cec403055d8d9388ac7dcfa
rymcguin/sorting
/Lists+Dict
1,410
3.78125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Mar 21 13:23:32 2019 @author: mcguiness """ banking = [{'id' : 4376, 'deposit' : 100, 'withdraw' : 500}, {'id' : 5379, 'deposit' : 300, 'withdraw' : 75}, {'id' : 6473, 'deposit' : 250, 'withdraw' : 100}, {'id' : 7128, '...
fef33052c832e7a32864c8a3abab3ccd96e76e48
PoglianaAlessandro/socket
/client.py
606
3.640625
4
#!/usr/bin/env python3 import socket SERVER_ADDRESS = '127.0.0.1' # The server's hostname or IP address SERVER_PORT = 65433 # The port used by the server sock_service = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock_service.connect((SERVER_ADDRESS, SERVER_PORT)) dati = input("Inserisci messaggio per i...
ed4af732262dbd37a05a8160f6f3218499ac4f88
wandsen/PythonNotes
/File_System.py
403
3.640625
4
import os import glob #Find OS name print('Finding my OS', os.name) #Get current directory print("Current working directory", os.getcwd()) #Create a new directory # os.mkdir('myNewDirectory') #Listing the directories print(os.listdir()) #Changing directory os.chdir('myNewDirectory') os.chdir('..') print(os.getcwd...
f7c8c768217bebbd2a239868664e27a62df7118c
FaDrYL/From0ToPython
/src/Fundamental/Operators/Operators_sample.py
1,471
4.1875
4
""" Author: FaDr_YL (_YL_) """ print("\n--- Arithmetic Operators ---\n") x = 10 y = 3 print("x = {}; y = {}".format(x, y)) print("x + y = " + str(x + y)) print("x - y = " + str(x - y)) print("x * y = " + str(x * y)) print("x / y = " + str(x / y)) print("x % y = " + str(x % y)) print("x // y = " + str(x // y)) print(...
5d288d097920a9b663ed30f65e43f538695e1cd6
tugbaercan/pyodevv
/pyodev2/step2.py
311
3.5625
4
class song(object): def __int__(self, lyrics): self.lyrics = lyrics def sign_me_a_song(self): for line in self.lyrics: print(line) happy_birthday = song['May god bless you, ,', 'Have a sunshine on you,', 'Happy Birthday to you !'] print(happy_birthday.sign_me_a_song())
345d2778156e4c00e0a813b67e7793517dde5464
mckoss/codejam-2013
/code-1b-b.py
458
3.5625
4
#!/usr/bin/env python import fileinput DEBUG = False test_input = """\ """.split('\n') def parse(lines): """ >>> tests = parse(iter(test_input)) >>> len(tests) 0 """ num_tests = int(lines.next()) return [0] * num_tests def main(lines): """ >>> main(iter(test_input)) """ ...
effa444288d98696f539bfa616c22bee3d6f89f3
MrHamdulay/csc3-capstone
/examples/data/Assignment_7/blnaph001/question1.py
339
3.828125
4
#unique list #aphiwe baleni #29 april 2014 list=[] print('Enter strings (end with DONE):') while True: word=input('') if word=='DONE': break counter=list.count(word) if counter==0: list.append(word) if counter>1: continue print() print('Unique list:') for name...
81bae05288ccc393d52a7ab0a79d68d4fba92bd5
shubam-garg/Python-Beginner
/Variables&Datatypes/04_input_function.py
136
4.09375
4
a = input("Enter your Name:") # this fuct. allows the user to take input as a str. only # whether input is "name" or integer 23 print(a)
1463802ae394939a01f302113acc44d03c9744f8
ValentynTroian/Python-Homework
/words_in_text_count_command_line.py
1,642
4.28125
4
''' The script based on assumption that 'a','o' or other one-symbols and abbreviations ('ll','se','d') are the words ''' from collections import Counter from re import split from sys import exit, argv from os import path def read_file(): '''This function reads the file specified as 2nd parameter of the...
c62e5220471fe3743aca9cde2d60efb4e710836c
Steelex/CSE
/Pythagorean Theorem - Steelex Garcia.py
112
3.515625
4
def pythagorean(a, b): s1 = (a ** 2 + b **2) s2 = (s1 ** 0.5) return s2 print (pythagorean(5, 12))
ee53b494d1b965e492c545c3be47fe467afcd237
Clockwick/DataStructureP2
/post_fix.py
1,078
3.828125
4
class Stack: def __init__(self, lst=None): if lst == None: self.items = [] else: self.items = lst def __str__(self): n = map(str, self.items) return ",".join(n) def push(self, i): self.items.append(i) def pop(self): if self.item...
4a9e449a101f0d89e02e60095b027bb2b4ebbeee
emcraciu/PEP20G04
/module2/module2.py
13,205
4.53125
5
######################################################## OBJECTS ####################################################### # accessing object methods using dot notation # add . in Pycharm to get hints for methods - ignore self argument for now my_string = 'something' print('Getting string length using builtin function ...
1dd2c226f2a9eb51e4764cc31540b4226d68882d
snymanc/rock_paper_scissors
/main.py
1,709
4.0625
4
import random import math def play(): user = input( "What's your choice? 'r' for rock, 'p' for paper, 's' for scissors\n") user = user.lower() computer = random.choice(['r', 'p', 's']) if user == computer: return (0, user, computer) # r > s, s > p, p > r if is_win(user, comp...
3e71e93ba2ef99c839213eb7085a71f4867561f8
coderkearns/school
/math/v2/ellipse.py
4,584
4.09375
4
#!/usr/bin/env python3 # classes/name_of_file.py doc = """ ## Ellipse The set of all points in a plane where the sum of the distances from two special points, called focus points or foci, is equal. Every ellipse has two axes of symmetry. The parts of the axes of symmetry which lie inside the ellipse are called the m...
e6c07952a9dcb77a4d10202b299fe9e9ac84b90a
vsostaric/codesignal
/codefights-py3/arcade/file_naming.py
790
3.90625
4
def solution(names): result = list() name_set = set() for name in names: name_set_length = len(name_set) iteration = 0 result_name = name while name_set_length == len(name_set): name_set.add(result_name) if name_set_length != len(name_set): ...
1669c48b2e359817eaad208ff4c2ee64f5f9e013
hyhplus/LeetCodeByPython
/001~100/019RemoveNthFromEndOfList.py
506
3.640625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 19. 给定链表,从链表末尾删除第n个节点并返回其头部 """ class Solution: # https://leetcode.com/problems/remove-nth-node-from-end-of-list/discuss/8802/3-short-Python-solutions def removeNthFromEnd(self, head_, n): def remove(head): if not head: ret...
4f9e2ae29b28aeb65d4018c6b216663e2c871080
pareshh7/beautifulsoup
/10 Parent Method.py
439
3.515625
4
from bs4 import BeautifulSoup #import beautiful soup library def read_file(): #function to read the content of file file = open('three_sisters.html') data = file.read() file.close() return data soup = BeautifulSoup(read_file(),'lxml') title = soup.title parent = title.parent #accessing the p...
719dacc64be4b28af46a0bb29b384eb42afe407c
yosef8234/test
/python_offsec_pentest/Module 2/Data Exfiltration Client - TCP Reverse Shell.py
2,519
3.578125
4
# Python For Offensive PenTest: A Complete Practical Course By Hussam Khrais - All rights reserved # Follow me on LinkedIn https://jo.linkedin.com/in/python2 import socket import subprocess import os # needed for file opertaions # In the transfer function, we first check if the file exisits in the firs...
720050629e05f61dd77ec042d999c49e1a94325d
jaybee1971/DevOps
/Exercises/FizzBuzz/fizzbuzz.py
1,864
4.0625
4
number_list = [] index = 0 number = 1 def print_text(argument): text = { 0: "Fizz", 1: "Buzz", 2: "FizzBuzz", 3: "Bang", 4: "FizzBang", 5: "Bong", 6: "Fezz", 7: "FezzBuzz", 8: "FizzFezzBuzz", 9: "FezzBong", 10: "BuzzFizz" ...
527c8775a4762e4a0d367271b12e6bcded051ac1
kumvika/leetcode-solution
/romanToInteger.py
865
3.828125
4
class Solution: """ Given an string in roman no format (s) your task is to convert it to integer """ def romanToInt(self, roman): roman_nums = { "I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000...
8c2aa6a633aaea1931b9ef74e25ab40c0104146a
FlyBKang/2013180001-2DGP
/Final(superFix)/Item.py
3,025
3.734375
4
class Item: Num = 0 Name = "" Text = "" Level = 0 def __init__(self,num,name,text,level): self.Num = num self.Name = name self.Text = text self.Level = level class inventory: def __init__(self): self.inven = [Item(-1," "," ",-1) for i in range(0,8)] d...
a8a216bdea794e59fd53be1419df15b6acd90986
Fubuki-Shirakami/Tugas-Besar
/tubes_11.py
8,057
3.890625
4
# WELCOME TO TEMPDEC # bagian 1 (login & register) # Infinity loop (ga akan pernah selesai) # pros: program lebih detail (memudahkan user), bisa log in ke username yg udh diregister sblmmya/switch account (register dgn alamat email, no telp & username baru) # cons: bikin flowchart & pseudocodenya ribet from...
5d6acb5eae2ecb46e3e58782a21ca8545b35e8d1
ArrobaAnderson/Ejer_Class
/Sem1/Comprehension - [var for var in datos condicion].py
166
3.890625
4
#Estructuras de Control de Python - FOR #Comprehension - [var for var in datos condicion] [car for car in['a', 'e', 'i', 'o', 'u'] if car not in('a', 'i', 'o')]
70013d3b3d0270b857da9fab7b82d5e10bb3e210
n2oneProgrammer/AlgorithmLearn
/Selection Sort/python/Sort.py
365
3.625
4
def Sort(tab): n=len(tab) for i in range(n): index=-1 smallest = tab[i] for j in range(i,n): if tab[j] < smallest: smallest = tab[j] index=j temp = tab[i] tab[i]=smallest tab[index]=temp retur...
b609270c2551340ac1bfea9cf6b534d55918dedb
sumanthhegde05/Leetcode-Solutions
/2. Add_Two_Numbers.py
1,024
3.6875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: first = ListNode() current=first carry=0 result=0 while l1 !...
c2b845142f069b2d17f6b4cb32c05d4efabe914a
wan-catherine/Leetcode
/problems/N442_Find_All_Duplicates_In_An_Array.py
818
3.890625
4
""" Because those duplicated number only can show twice ,not 3,4.... So we can flip it , when second time meet the number , it will flip again. So next time, meet problems say twice ,we can use this method. """ class Solution(object): def findDuplicates_still_use_extra_space(self, nums): """ :type ...
7e06c12305af407dedcbd8d843fb688823936d4e
ifpb-cz-ads/pw1-2020-2-ac04-team-amandamichel
/questao_15.py
1,033
4.21875
4
''' Escreva um programa que exiba uma lista de opções (menu): adição, subtração, divisão, multiplicação e sair. Imprima a tabuada da operação escolhida. Repita até que a opção "saída" seja escolhida. ''' while(True): print("0. Sair") print("1. Adição") print("2. Subtração") print("3. M...
e2105b758b7b75f57f49a08b8c0bfdda717dca56
youngclick/advGIS
/concert.py
447
4.0625
4
# Arup Guha # 3/9/2013 # Concert Tickets def main(): # Get user input. havetix = input("Did you buy concert tickets?\n") wontix = input("Did you win concert tickets on the radio?\n") # Print out whether they get to go to the concert or not. if havetix == "yes" or wontix == "yes": ...
e8eb1f119db3c246b5defa871485ef6954221b9d
zzz686970/leetcode-2018
/1260_shiftGrid.py
882
3.59375
4
def shiftGrid(grid, k): # sum() takes two parameters iterable and start,i.e.,sum(iterable,start) # by default start=0. so we cannot concatenate a list and integer,that why we are taking start=[ ] empty list m, n = len(grid), len(grid[0]) ## flatten the 2-d list res = sum(grid, []) ## if need to ...
081a4aa7dc6e525577106c31b39348d43da3b566
Danielporcela/Meus-exercicios-phyton
/somar passagem de onibus .py
544
4.09375
4
##031: Desenvolva um programa que pergunte a distância de uma viagem em Km. Calcule o preço da passagem, cobrando R$0,50 por Km para viagens de até 200Km e R$0,45 parta viagens mais longas. km = float(input('Digite o km da viagem :')) print('Você esta preste a começar uma viagem de {:.1f}km'.format(km)) if km <=200: ...
ec3edc61108d0a9269e99b0058f34bc9b768a0d8
krishnakarki195/PythonNote
/PythonClass/notesonfunction/third.py
644
4.0625
4
#!/usr/bin/python # functional arguments # pass by value or pass by reference -> pass by object ''' def add(a,b): print locals() return a + b print add(10,20) print add("linux"," rocks") print add(b=' linux',a='rocks') # you can pass object on position or using key values. ''' # default keyvalues - Note: defa...
0517a6bef12336eb338fb2df971e5c5629a60585
redjoey/games
/invadedhouse/models/chest.py
1,712
3.875
4
from .item import Item class Chest(Item): def __init__( self, name: str, description: str, capacity: int = 2 ): super().__init__(name, description) self.capacity = capacity self.contents = [] def place(self, item: Item): if len(self.content...
1625870919635999d29bd35978f309725444bf4d
jlchamaa/2019_Advent_Of_Code
/7/hello.py
621
3.546875
4
from collections import deque class Repeater: def __init__(self): self.value = deque() self.value.append(1) def add_to_the_list(self, addition): self.value.append(addition) def run_computer(self): return self.get_from_the_list() def get_from_the_list(self): w...
5f3a8904693262a1b2edd1710901f06c0343f300
610yilingliu/leetcode
/Python3/101.symmetric-tree.py
752
3.953125
4
# # @lc app=leetcode id=101 lang=python3 # # [101] Symmetric Tree # # @lc code=start # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def isSymmetric(self, root): if not root or...
3d3d5b3371acd7083acbe65f271552e55c30e74d
pryangadevanathan/ibmlabs
/Palindrome.py
82
3.984375
4
str =input("Enter a string") revstr = reversed(str) print("".join(list(revstr)))
f7df4f0aa5f15bd9c629f563cde364beca6f489b
PinkDiamond1/mud-dev
/world/_gendersubs.py
3,004
3.828125
4
import re # gender maps _GENDER_PRONOUN_MAP = {"male": {"s": "he", "o": "him", "p": "his", "a": "his"}, "female": {"s": "she", "o": "her", ...
fbad6f1168ef6c9f466c558527e908f0b266d660
Hoch3007/practisepython_org
/exercise28.py
176
3.65625
4
##### practicepython.org: Exercise 28 def maximum(a, b, c): if a>b and a>c: return a elif c>a and c>b: return c else: return b
3a00760d977c0706b1cbda0bc4f2af41782df9b0
smartdong/PythonPractise
/Chapter 03/TestCode.py
358
3.78125
4
sth = 123 print(sth) sth = "ABC" print(sth) A = 123 B = "ABC" C = 456 D = "DEF" print(A,B,C,D) name = "John Carpenter" birth = "11/11/2011" print(name,birth) print("String","Theory", sep='-', end=':') print("\n") import sys print(sys.copyright) print(sys.platform) print(sys.version) import datetime from datetime i...
6d31b2f37b953686fe8acfde0dae42d5bc30e2c3
Gyol/Multicampus_Cloud
/common_ground/python_programming_stu/mycode/10_pythonic/pythonic_code.py
2,612
3.640625
4
# join() 함수 colors = ['purple', 'yellow', 'blue'] result = ' '.join(colors) print(result) result = '/'.join(colors) print(result) # split() 함수 print() langs = 'python, java, c#, go' # 공백으로 구분하는 문자열인 경우에는 split()구분자를 주지 않아도 됨 result = langs.split(', ') print(type(result), result) # 일반적인 for loop print() my_list = [] ...
0382e82c5ebf68998ee3cd05705502325c3b5fe5
jmmedel/Python-Reference
/16_Python_Read_Files/01_read_files.py
401
3.734375
4
""" Author: Kagaya john Tutorial 16 : Read File Handling """ """ Python File Open Open a File on the Server Asume we have the following file, located in the same folder as Python:""" """ To open the file, use the built-in open() function. The open() function returns a file object, which has a read() method for...
3adbf1b3c00bafa5be490a6672b03bbd8011e43b
annapeterson816/PythonPrograms
/Comp Sci Labs-2018/prime2.py
314
4.0625
4
def prime2(number) : for num in range(2,number): prime=True for i in range(2,num): if (num%i==0): prime= False if(prime==False) : print str(num)+ " is not a prime number." else: print str(num) + " is a prime number."
7f5459e37150d9703cc1afcc5968317895c9e68f
ay701/Coding_Challenges
/tree/leftNodesBST.py
1,231
4.375
4
# Print Left Nodes of a Binary Tree # Given a binary tree, return the left-most node of each level in the tree. # https://www.geeksforgeeks.org/print-left-view-binary-tree/ # Time Complexity: The function does a simple traversal of the tree, so the complexity is O(n). # # Input : # 1 # /...
2eb91617721cc0aa6732d20bd950e0a7b5c54d4f
EVS-ATMOS/Py-CAWS
/pycaws/io/weather_processing.py
10,424
3.921875
4
""" Code that takes raw weather data and does mean and standard deviation calculations. Processed data can then be saved as excel. """ import numpy as np import pandas as pd def weather_output(filename, excel_filepath): """ Weather output, takes in raw weather data and does preprocessing. Parameter ...
e1baec98077d8903501721b43d7965bc7e89b5e7
sanjeev1996/Hacker_rank
/Regex and Parsing/Validating UID.py
826
3.609375
4
import re for _ in range(int(input())): b=[] a=''.join(sorted(input())).upper() [b.append(True) if re.search('[A-Z]{2}',a) else b.append(False)] [b.append(True) if re.search('[0-9]{3}',a) else b.append(False)] [b.append(True) if a.isalnum() else b.append(False)] [b.append(True) if not re.search(...
c13c13b364c03919d83f233cbf6c4e179c1e631e
alkantugay/Data_Science
/Python Notes (to Remember)/OOP_AbstractClass.py
984
3.75
4
# -*- coding: utf-8 -*- """ Created on Fri Mar 27 17:56:58 2020 @author: alkan """ """ Türetilen sınıflara yani child classlara implement etmek zorunda olduğumuz methodlara abstract method denir. Abstract Class Şartları: 1- Abstract classımdan obje yaratamam 2- animal clasında kullandığım meth...
cc4b41bc31148a48bfd3b507b31839dae866864b
jaxball/justcodeit
/data_structures/linkedlist.py
2,357
3.90625
4
""" Data Structures - Linked List """ class Node: def __init__(self, value): self.val = value self.prev = None self.next = None def setnext(self, nextNode): self.next = nextNode def setprev(self, prevNode): self.prev = prevNode class LinkedList: def __init__(self): self.head = None self.tail = N...
7d2ca844946dd2ebd5177b3e86a9339a06a26a5a
slpdavid/Project_Euler
/p036.py
1,014
3.671875
4
def binaryConverter(num): factor=1 while factor*2<=num: factor*=2 result=0 while factor>0: result*=10 result+=int(num/factor) num%=factor factor=int(factor/2) return result def palindromeGeneratorEven(num): string = str(num) string += string[::-1] ...
57232e2aee778605e934766429c502cfed1920d2
asterix135/Budgetpedia_data
/FIR_DATA/tree.py
5,008
3.640625
4
""" tree class for use in creating data hierarchy """ class Node(): def __init__(self, key, desc=None, val=None, parent_node=None, child_nodes=None): self._key = key self._description = desc self._data = val if parent_node is not None and type(parent_node) is not No...
8a07b97ab69c6716d99564830d3625a9fa9ca17c
acneuromancer/problem_solving_python
/trees/binary_tree/bin_tree_parser.py
3,545
3.984375
4
class BinaryTree: def __init__(self, root): self.key = root self.left_child = None self.right_child = None def insert_left(self, new_node): if self.left_child == None: self.left_child = BinaryTree(new_node) else: t = BinaryTree(new_node) ...
bb6c65c6c76377ccc1785b053cdd5597a589145d
ICANDIGITAL/crash_course_python
/chapter_10/guest_book.py
380
3.796875
4
filename = 'guest_book.txt' prompt = ('Hello user, what is your name?\n') prompt += ('Enter \'q\' to quit: ') while True: user_name = input(prompt) if user_name == 'q': break else: print('\n' + user_name.upper() + '! ' + 'Welcome your majesty!\n') with open(filename, 'a') as file...
791456600b7e1d830a7963b2a6b5dde9e7144f98
daniel-reich/ubiquitous-fiesta
/RxHjtFqu3w8L9i5fx_21.py
358
3.53125
4
import math def binomial(n,k): top = math.factorial(n) bottom = math.factorial(k)*math.factorial(n-k) return top/bottom def stirling(n,k): sum = 0 for i in range(0,k+1): sum+=math.pow(-1,i)*binomial(k,i)*math.pow(k-i,n) return 1/math.factorial(k)*sum def bell(n): sum = 0 for k in range(0,n+1): ...
e685fac89067340fd084fc6bbc21459c400c24d2
mlenahan/bmi_calc
/bmi_converter.py
4,299
3.578125
4
import argparse import csv from datetime import datetime import os class BMIRange: def __init__(self, value, lower_threshold=0.0, upper_threshold=None): self.lower_threshold = lower_threshold self.upper_threshold = upper_threshold self.value = value bmi_ranges = [ BMIRange('underwei...
ccf35bcab8232a9b26d4d0a18cb5cdead5e85a46
abhikbanerjee/Python_DataStructures_Interviews
/interview_questions/Recursion_DP/WordSearchGrid.py
1,103
3.890625
4
from typing import List # Given a 2D Grid, gind if a word exists or not, in the board - LC 79 def word_exist(board: List[List[str]], word: str) -> bool: def dfs(board, i, j, count, word) -> bool: if count == len(word): return True if i < 0 or i >= len(board) or j < 0 or j >= len(board[i]) or board[i][j] != w...
73520cb9e2a9dde8164906d40e36be954ee934b1
GrahamJamesKeane/CS001_2018-19
/L4Q4_CS001_18146619.py
1,505
4.375
4
# Q4. Write a program that draws the following shape and uses a pentagon() function to create the pentagons: import turtle from random import randint # Create a graphics window: win = turtle.Screen() win.setup(.75, .75) win.bgcolor("black") # Create a turtle: shredder = turtle.Turtle() # Create a function to initi...
cf410e4b84c5de64e2ba1051198fda65a670fb39
szepnapot/repo
/coursera_assignments_python/exercise_9_5.py
378
3.65625
4
fname=raw_input("Enter file name: ") try: fh=open(fname) except: print "Error! File not found." exit() add=dict() lst=list() for line in fh: if not line.startswith("From "): continue line=line.strip().split() email=line[1] address=email.split('@') lst.append(address[1]) for co...
0e8291dc0b9688427b19457b8fb4275bf10686f6
yz500223/AID1811
/bubble_better.py
536
3.875
4
def bubble(value): for i in range(len(value)-1): flag=False for j in range(len(value)-i-1): if value[j]>value[j+1]: value[j],value[j+1]=value[j+1],value[j] flag=True if flag==False: break print('遍历次数',i+1) if __name__=='__main__':...
4054a39fd1209b10ab067f49ed9c78d8fe262717
pisskidney/leetcode
/medium/144.py
880
3.859375
4
#!/usr/bin/python # Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def preorderTraversal(self, root): """ :type root: TreeNode :rtype: List[int] "...
9fb6eac54ba7902d5f5191a0182e7295835a33da
Nicomunster/INF200-2019-Exercises
/src/nicolai_munsterhjelm_ex/ex01/letter_counts.py
700
4.53125
5
def letter_freq(txt): """ This function counts the letters/characters in a string, and stores the frequencies in a dictionary. Parameters ---------- txt String from which letters will be counted. Returns ------- counts Dictionary with letter counts. """ counts...
057ccfa30f8ffab8423c64f204f86cd08e1aa6d6
kolyasalubov/Lv-585.1.PythonCore
/HW1/kondnataliia/HW1_2.py
114
3.78125
4
a = 8 b = 5 print("a+b =", a+b) print("a-b =", a-b) print("a*b =", a*b) print("a/b =", a/b) print("a**b =", a**b)
999e059ca56e1c45211d902852718639e3129452
eriDam/CursoPython
/Fase 4 - Temas avanzados/Tema 14 - Bases de datos con SQLite/Leccion 02.1 - Claves primarias, campos autoincrementales y claves unicas.pyw
1,079
3.625
4
""" Campos autoincrementales No siempre contaremos con claves primarias en nuestras tablas (como el DNI), sin embargo siempre necesitaremos uno para identificar cada registro y poder consultarlo, modificarlo o borrarlo. Para estas situaciones lo más útil es utilizar campos autoincrementales, campos especiales que asig...
840e41dcd2ab43ae076cb89e1741e67c1e111e9e
pytorch/tutorials
/beginner_source/blitz/autograd_tutorial.py
12,413
4.34375
4
# -*- coding: utf-8 -*- """ A Gentle Introduction to ``torch.autograd`` --------------------------------- ``torch.autograd`` is PyTorch’s automatic differentiation engine that powers neural network training. In this section, you will get a conceptual understanding of how autograd helps a neural network train. Backgro...
46c107fc989d9b8ce214df2570ae19595dea0122
s-v7/Logica_Progr_Python
/Exer_07.py
914
4.09375
4
### {Silas Vasconcelos Cruz} #### ###Algoritmo para calcular a quantidade de piso para uma sala a ser construída, bem como a quantidade # de tinta a ser usada nas paredes. Precisa também saber qual o volume da sala # em metros quadrados para estimar a potência necessária para o ar condicionado. # # Curso: Tecno...
1dd06049fc63db87270e193c142bbdf47a95107c
s2t2/groceries-inclass-202005
/comprehensions.py
607
3.796875
4
my_numbers = [1, 2, 3, 4, 5, 6, 7] print("ORIGINAL LIST", my_numbers) #for i in my_numbers: # print(i) # # MAPPED LIST: [100, 200, 300, 400, 500, 600, 700] # new_numbers = [] for i in my_numbers: new_numbers.append(i * 100) print("MAPPED LIST", new_numbers) mapped_list = [i * 100 for i in my_numbers] prin...
2a29920a180aa34240329e3eb7fabe50b1cf5c07
CKMaxwell/Python_online_challenge
/HackerRank/Practice/Itertools/itertools_combinations().py
672
3.609375
4
# 20200714 - itertools.combinations() """ from itertools import combinations print list(combinations('12345',2)) [('1', '2'), ('1', '3'), ('1', '4'), ('1', '5'), ('2', '3'), ('2', '4'), ('2', '5'), ('3', '4'), ('3', '5'), ('4', '5')] A = [1,1,3,3,3] print list(combinations(A,4)) [(1, 1, 3, 3), (1, 1, 3, 3), (1, 1, 3,...
e75abc518fde762085dc574ea03e7ee42d216147
grogsy/python_exercises
/interview_question_examples/testdome/icecream.py
908
4
4
''' Implement the IceCreamMachine's scoops method so that it returns all combinations of one ingredient and one topping. If there are no ingredients or toppings, the method should return an empty list. For example, IceCreamMachine(["vanilla", "chocolate"], ["chocolate sauce"]).scoops() should return [['vanilla', '...
fbda787156c4beead8e8d898bf68c24654d8d8df
LTSchmiddy/Python3-pySDL2-examples
/lesson5.py
4,137
3.515625
4
from ctypes import c_long, pointer import ctypes from sdl2 import * from sdl2.sdlimage import * # screen size SCREEN_WIDTH = 640 SCREEN_HEIGHT = 480 # there are better ways to load textures # I'm just trying to mirror the tutorial lesson as closely as possible def loadTexture(filePath, renderer): # loads bmp ima...
cab003b0c402e9d46c02db0bb115cfdbfbfdaa93
izdomi/python
/main.py
2,146
3.703125
4
import random from random import randrange def find_squeare(x): g = random.choice(range(1 ,x)) while g *g != x: g = (g + x / g) / 2 if x == g * g: return g print(find_squeare(16)) def findSqrt(nr): g = round(nr/ randrange(1,nr)) while nr!= g*g: print(g*g, (g+nr/g)...
07e13d9f00adfb6df195cc7940141f626764b0d2
TeBeau/AlgorithmsExamples
/binary_search.py
887
4.09375
4
import math # This is code for a binary search # given a sorted list of numbers, the goal is to identify whether or not a number is included stuff= [] i="empty" while i != "stop": i= input("Enter a number to add to the list, when done, input stop: ") if i!= "stop": stuff.append(int(i)) find=...
93409d8eca12c30ea89620710f9a6a7529d544f0
riska44/rahul
/Tes.py
535
3.859375
4
#!/usr/bin/python print "Hello World !!!" # name = raw_input("R4hu1 4bdre4s5: ") Team = int(raw_input("Annonymous: ")) print "Hello ", R4hu1 4ndre4s5 print "Your Team is : ", Annonymous #!/usr/bin/python def SumValue(a, b): sum = a + b return sum def HelloFunction(Name): print "Hello ", R4hu1, ", how are you?" r...
35e85d97b69d8569dd8cba6461a97e2976ec653e
missmialanae/dog-game
/Game 1/Dog.py
2,121
4.03125
4
import turtle import os #Inspired by Space Invaders but not really #Made on Mac w/ Visual Studio #Background window = turtle.Screen() window.bgcolor("white") #can change to a picture using window.bgpic("name of pic here") #Space for the Dog to thrive = border border = turtle.Turtle() border.speed(0) border.color("...
998f51056c302892a647c32a7107b3554ec932d6
i-fernandez/Project-Euler
/Problem_021/problem_21.py
1,523
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun May 31 11:28:52 2020 @author: israel 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 am...
ee0a07c345a412a666cd3dbcfd424691eb7eee9d
Harish023-git/course_Exercise
/Midterm/sum_intDigits.py
354
3.90625
4
"""Problem 6 Write a recursive Python function, given a non-negative integer N, to calculate and return the sum of its digits.""" def sumDigits(N): ''' N: a non-negative integer ''' if N == 0: return 0 return (N%10 + sumDigits(N // 10)) val = int(input("Enter an integer to count it's ...
63e70feacaf66db582eb2b6849c6c6392b54a962
RohitWaghole/scikit-image
/doc/examples/applications/plot_image_comparison.py
2,510
3.734375
4
""" ======================= Visual image comparison ======================= Image comparison is particularly useful when performing image processing tasks such as exposure manipulations, filtering, and restauration. This example shows how to easily compare two images with various approaches. """ import matplotlib.py...
df201ebec1cbeef8e747e96ae06f5dce43818534
emguffy/ProjectEuler
/058_spiralPrimes.py
772
4.09375
4
from is_prime import * def main(): primesPercent = 1.00 diagonalsCount = 1 primesCount = 0 # We start with the counter at 3 so as to avoid the unusual pattern break at the beginning. counter = 1 sideLength = 1 currentSide = 1 # 1 is climbing on the right, 2 is traversing left on top, 3 is descending on the lef...
199bba6f0a514067bfc6649df66decacbd19d718
spookey/photon
/photon/util/files.py
2,618
3.59375
4
from json import dumps as _dumps from json import loads as _loads from os import path as _path import yaml as _yaml def read_file(filename): ''' Reads files :param filename: The full path of the file to read :returns: The content of the file as string (if `filename` exists) .. ...
cd78cd9e347e08360210ff6bce33138ffdc7b736
eban12/compettitive_programing-cs478-
/Competitive/Day6/largestPerimetre.py
190
3.625
4
def largestPerimeter(A): A = sorted(A) for i in range(len(A) - 3,-1,-1): if A[i] + A[i + 1] > A[i + 2]: return sum(A[i : i + 3]) return 0
3bc0736430700dce808618983ecdb50b8405aa34
Johnyeo/PoemComposer
/poemComposer/algorithm.py
380
3.953125
4
# coding:utf-8 list = [5,2,5,1,8,3] def bubbleSort(ls): # 冒泡排序 total = len(ls) for n in range(total): for m in range(total): if ls[n] > ls[m]: pass elif ls[n] < ls[m]: ls[n],ls[m] = ls[m],ls[n] else: pass return ls d...
16d254f31e91ebe8c82ab2c66d4ccfafc5f1c950
hanggun/leetcode
/20200519_fail.py
1,474
3.859375
4
# -*- coding: utf-8 -*- """ Created on Tue May 19 13:00:35 2020 @author: Administrator """ from sys import maxsize class TreeNone(object): def __init__(self, x=None): self.val = x self.next = None class StockSpanner(object): def __init__(self): self.root = TreeNone(maxs...
5b6e74cbb8c27501722c625942109ce5c9821d16
AVerteC/campo_python
/hacker_baby/ex02/ex02.py
486
3.75
4
#!/usr/bin/env python3 import sys def init(): listo = sys.argv[1:] def arr(): num = 0 global listo listo = sys.argv[1:] for i in listo: num += 1 print("Argv of {0} is {1}".format(num, i)) def lensort(): # lambda x: len(x) replaces a def s(x): re...
9a1b4840944c2d6d5b15a186de7aaa6edbfb86b5
ck-unifr/leetcode
/amazon/721-accounts-merge.py
2,685
4.3125
4
""" https://leetcode.com/problems/accounts-merge/ 721. Accounts Merge Given a list accounts, each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the elements are emails representing emails of the account. Now, we would like to merge these accounts. Two ...
c45e11f9c357ec76cc3af710bd55e86960710109
russel2005/PythonProject
/practice/Day04_list.py
1,394
4.0625
4
names = ['arish','momo','russel','nazrul'] l =[] # l is empty list for person in names: l.append(person) print(l) #below line are same as above 4 lines, comprehensive print([person for person in names]) upper_names = [person.upper() for name in names] print(upper_names) ###################################### name...
791506efee09dc72eddb824b7d7c579b31a3109d
floydchenchen/leetcode
/157-read-n-characters-given-read4.py
1,102
4
4
# 157. Read N Characters Given Read4 # The API: int read4(char *buf) reads 4 characters at a time from a file. # # The return value is the actual number of characters read. For example, it returns 3 if there is only 3 characters left in the file. # # By using the read4 API, implement the function int read(char *buf, i...
f8dbdd0aea1bdeab5cea02a644316aab036d792f
MAPLE-Robot-Subgoaling/IPT
/data/HW5/hw5_062.py
599
4.0625
4
def main(): width = int(input("Please enter the width of the box: ")) height = int(input("Please enter the height of the box: ")) outline = input("Please enter a symbol for the box outline: ") fill = input("Please enter a symbol for the box to fill: ") if(height > 0 and width > 0): print(out...
25a41e52ac9e4046e4acf5dbb94056e13b70433a
Justyouso/python_data_structure
/my_search/orderedSequentialSearch.py
474
3.6875
4
# -*- coding: utf-8 -*- # @Author: wangchao # @Time: 19-9-5 下午2:26 def orderedSequentialSearch(alist, item): pos = 0 found = False stop = False while pos < len(alist) and not found and not stop: if alist[pos] == item: found = True else: if alist[pos] > item: ...
81a476088ae84237cbb24497e00b67e0e2485c16
edu-athensoft/stem1401python_student
/py210110d_python3a/day04_210131/homework/stem1403a_hw_3_yuhaoteng.py
1,985
4.53125
5
""" [Homework] Date: 2021-01-24 Write a Python GUI program to create your own window Common requirements: 1. set a title 2. set an image icon Extra requirements: 1. specify dimension at 16:9 2. make it at center point on your screen 3. set a background color 4. make it topmost 5. set max size and min size 6. make it re...