blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
5c33bc4253bbc6b29bbd097e7a98c0c1c33863ce
kimmothy/PuzzleSolver
/puzzle_solver/BlockPuzzle.py
2,375
3.59375
4
from puzzle_solver.Puzzle import Puzzle class BlockPuzzle(Puzzle): def isValidate(self, newPosition, movedBlockIndex): rowNum = len(self.field) colNum = len(self.field[0]) block = newPosition[movedBlockIndex] if ["position", newPosition] in self.visited: return False ...
13e89dfbc2ba6c54ce9a6309cf128fddf843a7a2
AakSin/CS-Practical-FIle
/Reference/Lab Reference/PC 2/List Worksheet/q9.py
260
3.703125
4
a=["hello","mello","trello"] b=["chellp","nello","mello"] def common(a,b): s=[] for i in a: s.append(i) for i in b: s.append(i) for i in s: if s.count(i)>1: return True break print(common(a,b))
1a46aeae63884ccacbc343f53e0da6d9f7068b9c
pagesofpages/python-pdf
/PdfText.py
24,720
3.515625
4
# PdfText.py """ Classes for managing the production of formatted text, i.e. a chapter. PdfChapter() PdfParagraph() PdfString() """ from PdfDoc import PdfDocument from PdfFontMetrics import PdfFontMetrics import math # global metrics = PdfFontMetrics() FNfontkey = 'F3' FNfontsize = 5 FONTMarker = '^' # function copie...
d361b0228f4c84bb2b244eb616db13ebe8c20a85
cessor/httpcache
/httpcache.py
1,700
3.765625
4
'''Downloads websites and caches them in a sqlite3 database. If the page was downloaded before, it retrieves it from the cache. I used this to retrieve websites that lock you out if you request the same page too often. Free software. Use and change. Improve and distribute. Give credit. Be excellent to each other. Auth...
6dfa6d5f334ab128930a8f3f0c3728a6bce16953
alex-dsouza777/Python-Basics
/Project 2 - The Perfect Guess/main.py
1,179
4.46875
4
'''We are going to write a program that generates a random number and asks the user to guess it. If the player’s guess is higher than the actual number, the program displays “Lower number please”. Similarly, if the user’s guess is too low, the program prints “higher number please”. When the user guesses the correct nu...
875fe898427f0ce88c1ef75674acc3ff5f225b15
ietuday/python-pratice-1-cont
/test/binary_search.py
496
3.9375
4
#!/usr/bin/env python3 def binary_search(arr, item): beg = 0 end = len(arr) - 1 while beg <= end: mid = beg + end // 2 if arr[mid] == item: return (mid + 1) elif arr[mid] < item: beg = mid + 1 else: end = mid - 1 return -1 def main()...
31cf0599ac31c623f18133f01af35716e7200685
thuurzz/Python
/faculd_impacta/tec_prg_1sem/exercicios_py/aula_01/exerc_02.py
258
3.875
4
print('ola, digite uma quantidade em metros e ela sera convertida para miliímetros!') metros = float(input('valor em metros: ')) milimetros = (metros)*1000 print('você digitou:', metros, 'metros, este valor em milímetros é:', milimetros, 'milímetros.')
a5382b37d2bcd1d99600a932ecaf3e7158d6d0be
Holit/XlsxToCsv
/ExcelProtocolHandler.py
3,331
3.578125
4
import xlrd import csv import sys import os if __name__ == '__main__': if len(sys.argv) == 1: print("illegal argument, try again.") elif len(sys.argv[1]) == 0: print("illegal argument, try again.") elif sys.argv[1] == "--help" or sys.argv[1] == "-h": print(""" Excel file handler ...
4299f97b11357f07cf7cca438e5164579b28f749
Ranjanpaul66/python_practie
/practice_1.py
1,225
4.21875
4
# 1) Write the following function’s body. A nested dictionary is passed as parameter. You need to print all keys with their depth. # Sample Input: a = { 'key1': 1, 'key2': { 'key3': 1, 'key4': { 'key5': 4, 'key6':{ ...
64122eb49f6ab72e11f6bd7042de7088c8a117d1
Swathi-Swaminathan/Swathi-Swaminathan
/5.6.21(pattern and iteration)/Display string.py
190
4.375
4
#Python program to display string in right angle triangle str=input("Enter the name:") b=len(str) for i in range(b): for j in range(i+1): print(str[j],end="") print()
d5c73e410bddf2da22905c5a183d92e737db8f89
ZunLayNwe12/GitSample
/Tuple.py
559
4.1875
4
#Tuple Tuple - () t = 12345, 54321, 'hello' t[0] t #tuples may be nested: u = t , (1, 2, 3, 4, 5) u #Tuples are immutable: cannot be replaced t[0] = 88888 # but they contain mutable objects: v = ([1, 2, 3], [3, 2, 1]) v fruits = ("apples", "banana", "cherry", "orange", "kiwi", "melon", "mango") ...
7598155aa8cc4867847b1c0fcc4802d319d78d65
hirobel/todoapp
/4_src/3_other/1_surasura-python/q2-5/q2-5.py
65
3.625
4
number = 10 print('number(10) + 5 = {}'.format(str(number)+'5'))
cc9133502e0695e4c83800f322f9921aad4ae259
IvanWoo/coding-interview-questions
/puzzles/reverse_vowels_of_a_string.py
1,109
4.125
4
# https://leetcode.com/problems/reverse-vowels-of-a-string/ """ Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Input: "hello" Output: "holle" Example 2: Input: "leetcode" Output: "leotcede" Note: The vowels does not include the letter "y". """ def reverse_vowels(s:...
5eca0fbb7c53205a9e7313a1e78386d96d9f59e3
ahwang1995/Cracking-the-Code
/Chapter 1/oneAway.py
617
3.875
4
#check two strings are one or zero edits away def oneAway(str1,str2): #make sure the lengths of the strings don't differ bby more than one diff = abs(len(str1) - len(str2)) if diff > 1: return False list1 = list(str1) list2 = list(str2) diff2 = 0 #remove matching characters from each list one at a time while(le...
75ae3a5c451438b8c288d46ceb39f154a9b19f14
karlicoss/kython
/kython/__init__.py
1,155
4.0625
4
from functools import wraps from .misc import * # https://stackoverflow.com/a/12377059/706389 def listify(fn=None, wrapper=list): """ A decorator which wraps a function's return value in ``list(...)``. Useful when an algorithm can be expressed more cleanly as a generator but the function should retur...
040f37ad9bd59cd2770d0a5d0c1c6cc395370b56
L4sse/smart_uebung
/Test.pu.py
221
4.09375
4
x = 3 y = 4 operation = raw_input("Bitte geben Sie wie folg ein, + - / ") if operation == "+": print x + y elif operation == "-": print x - y elif operation == "/": print x / y else == "*": print x * y
028e73aab6a25145064048c00eb5d9f35d8037c1
PriyaRcodes/Threading-Arduino-Tasks
/multi-threading-locks.py
995
4.375
4
''' Multi Threading using Locks This involves 3 threads excluding the main thread. ''' import threading import time lock = threading.Lock() def Fact(n): lock.acquire() print('Thread 1 started ') f = 1 for i in range(n,0,-1): f = f*i print('Factorial of',n,'=',f) lock.release() de...
9ec3b2b3b7478f7632e13dc506cda74b1e386b28
anushatsatish/File-Processing-The-Payroll-Program
/Lab5_AnushaSatish_Main.py
1,443
3.78125
4
import Lab5_AnushaSatish_Function function_file = Lab5_AnushaSatish_Function def main(): print('**' * 50) print(' ' * 25, "Employee Operations") print('**' * 50) choice = function_file.menu() print(choice) while choice != 6: if choice == 1: function_file.print_all() ...
4cadd9bb2ec39561ad3ce2d2b4cc3028b3548860
minghao2016/AutoBlast
/util/util.py
975
3.765625
4
import os def show_header(title): print "\n" multiply_asterisk = 95 print '#'*multiply_asterisk number_of_remaining_sharp = multiply_asterisk - len(title) put_this_number_of_sharp = int(int(number_of_remaining_sharp)/2) print '#'*(put_this_number_of_sharp-1) + " " + title + " " + '#'*(put_this_...
717c5d99e6895b2be2b22faa9e7554a066b17e77
mgavrin/games
/Battleship AI/battleship-5.py
21,103
3.515625
4
import pygame from pygame.locals import * import random from random import * import math from math import * pygame.init() class Grid: def __init__(self,location,name,dim,game): #Unpack location into x and y co-ordinates of upper left corner self.base_x=location[0] self.base_y=...
b1886665d9be0afdea379ebef37c88a656135f75
GLMF/GLMF198
/Reperes/Tensorflow/Tensorflow/display_image.py
577
3.5625
4
from tensorflow.examples.tutorials.mnist import input_data import matplotlib.pyplot as plt import matplotlib.cm as cm import matplotlib import random import numpy mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) index = random.randint(0, len(mnist.train.images)) img = mnist.train.images[index] img = img...
f6de9fb72f4405a34352338d7828842e82cd3c15
smartinsert/CodingProblem
/algorithmic_patterns/modified_binary_search/ceiling_of_a_number.py
470
3.953125
4
""" Find the smallest number index in the array greater than or equal to the key """ # Time: O(logN) def smallest_number_greater_than(arr, key): n = len(arr) if n == 0 or key > arr[n-1]: return -1 start, end = 0, n - 1 while start <= end: mid = start + (end - start) // 2 if ar...
62f8412617ea39957161d13305278f5ff8cee045
Beltran89/Curso-Python-Django-Flask
/09-listas/predefinidas.py
711
4.125
4
cantantes = ["kase o", "Morodo", "Rapsuskley", "haze"] numeros = [1, 2, 32, 14, 8, 8, 8] #Ordenar print(numeros) numeros.sort() print(numeros) #Añadir elementos cantantes.append("Lirico") cantantes.insert(1,"CPV") #Posicion print(cantantes) #Eliminar elementos cantantes.pop(1) #eliminar por posicion cantantes.re...
6f21caa165132ab8f1983659194f53c568b9e8fe
josemrp/test-python
/Basic/loops.py
218
3.921875
4
def ss(): print(' ') for i in range(5): print(i) ss() names = ['jose', 'carlos', 'maria'] for name in names: print(name) ss() for j in range(len(names)): print(j, names[j]) ss() for n in names[:]: print(n)
1d2f84381f488e7fa211661f21ce97f264a00bab
scls19fr/openphysic
/python/oreilly/cours_python/solutions/exercice_10_07.py
462
3.546875
4
#! /usr/bin/env python # -*- coding: Latin-1 -*- def compteMots(ch): "comptage du nombre de mots dans la chane ch" if len(ch) ==0: return 0 nm = 1 # la chane comporte au moins un mot for c in ch: if c == " ": # il suffit de compter les espaces ...
97c3fcbababb9409058ee3fa656c9d6f160d7e71
Iainmon/Chess-Player-with-Python
/ChessPlayer/chess_manager.py
2,051
3.546875
4
import chess import time from players import player_human, player_minimax, player_random COLOR_TO_STRING = {chess.WHITE : "White", chess.BLACK : "Black"} class ChessManager: def __init__(self, white_player, black_player): self.board = chess.Board() self.white_player = white_player self.b...
c93925308a05feb89e235979de406e6bb0e9b3e8
arvidpm/dvg007.programmeringsteknik
/Uppgift_3/Uppgift3_temp.py
3,174
3.625
4
import random, sys # Programmeringsteknik webbkurs KTH inlämningsuppgift 3. # Robin Chowdhury # 2014-08-06 # Ett nöjesfält där man får välja mellan 3 åkturer # Det finns en chans att åkturen man åker med havererar # Attraktion för nökesfältet. # Har funktioner för att starta, stoppa, skriva reklam. # Denna klass anvä...
9601a5cc11d24d95c89eeeed41be17778a58665b
ruturaj9345/MSAM
/LeastCostMethod.py
1,659
3.59375
4
def getMin(cost_matrix, warehouse_demand, no_of_fac, no_of_wah): min = 1000 i_val = 0 j_val = 0 for i in range(0, no_of_fac): for j in range(0, no_of_wah): if(cost_matrix[i][j] < min): min = cost_matrix[i][j] i_val = i j_val = j ...
82074ffb50970810e5091e0260b596f6fab2b141
Sandbox4KidsTM/Python_Basics
/Supplemental_Material/PythonProjects/GAMES/game.py
1,580
4.375
4
# https://www.raywenderlich.com/24252/beginning-game-programming-for-teens-with-python # 1 - Import library import pygame from pygame.locals import * # 2 - Initialize the game pygame.init() width, height = 640, 480 screen=pygame.display.set_mode((width, height)) keys = [False, False, False, False] #track st...
4c3351152540a3cd39545a6fc33eb53843b4a722
KonSprin/RecruitmentTask
/mac.py
803
3.640625
4
import requests import json import argparse parser = argparse.ArgumentParser() # Taking MAC as an input parser.add_argument("MAC", type=str, help="MAC address") arguments = parser.parse_args() # 44:38:39:ff:ef:57 # Trying to get the response from server try: response = requests.get("https://api.macaddress.io/v...
36163bede6481af5b3c5d08fe7d50c64b09e667a
poojhamuralidharan/ineuronassignment
/printing star pattern.py
205
3.96875
4
for i in range (0,6,1): for j in range(0,i,1): print("*",end=" ") print("\n") for i in range (4,0,-1): for j in range(0,i,1): print("*",end=" ") print("\n")
2d1532bad8bb68a516ac0371998d5277481707ef
jefflike/python_advance
/packet/016.不要轻易继承python的基本数据结构.py
926
4.1875
4
''' __title__ = '016.不要轻易继承python的基本数据结构.py' __author__ = 'Jeffd' __time__ = '4/17/18 5:27 PM' ''' ''' tips: 这里尤其是不建议继承list,dict等底层是c语言实现的一些函数。 ''' class my_dict(dict): def __setitem__(self, key, value): super().__setitem__(key, value*2) d = my_dict(a=1) print(d) # {'a': 1} # def __setitem__(self, *a...
26f104f18065ce8cb466d1c4060e2d142e7097d3
randyarbolaez/codesignal
/daily-challenges/MaxCupCakes.py
336
3.53125
4
# Your task it to find the quality of the Kth cupcake after the cupcakes from the list P are removed from the box. def MaxCupCakes(N, P, K): cupcakeQuality = [] for i in range(1,N+1): cupcakeQuality.append(i) for i in P: cupcakeQuality.remove(i) if len(cupcakeQuality) < K-1: return -1 return cupc...
8af43256102f51fff162c903294e8dcacc3bc99a
DojoFatecSP/Dojos
/2019/20190920 - media1 - python/uritest.py
137
3.78125
4
n1 = float(input()) * 2 n2 = float(input()) * 3 n3 = float(input()) * 5 media = (n1 + n2 + n3)/10 print("MEDIA = {:.1f}".format(media))
b4d13c8aaf5089896903fb573f4eda7a27e6438e
ViajeDeReina/Lets_Practice
/Python Etc/run_turtle_run_2.py
2,883
4.1875
4
#this is upgrade version of Run Turtle Run #basically everything is same except some details import turtle as t import random t.title("Run Turtle Run") t.setup(500,500) t.bgcolor("black") #tframe for just making frame around the window. turtle will only move within this area tframe=t.Turtle() tframe.shape("classic"...
17fbbcd01be831931e534b5a30122f96ea3d78dc
slaveveve/NLP100
/ch01/03.py
633
4.125
4
# 03. 円周率 # "Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics." # という文を単語に分解し,各単語の(アルファベットの)文字数を先頭から出現順に並べたリストを作成せよ. import re def count_word_len(sentence: str) : dropped_sentence = re.sub(r'[.,]', '', sentence) splitted_sentence = dropped_sentence.split() cou...
c114ea87c289705830fc9e2fcbcf5ef29bad489f
cdtibaquicha19/curso-python
/fundamentos/tienda-libros.py
711
3.734375
4
print("Proporcione los siguientes datos del libro ") nombre = input("Proporciona el nombre ") i = int(input("proporciona el id del libro ")) precio = float(input("Proporcione precio del libro ")) enviogratuito = input("Indica si el envio es gratuito (True/False) ") if enviogratuito == "True" : enviogratuito = Tr...
808a0b6ac2984ef6ad8228c785e2d2fd3a5482e4
gmftbyGMFTBY/Study
/Python/StudyPython/python_test_workspace/code2_2.py
130
3.890625
4
import re url = input("Please input your URL:") pattern = "http://www.(.+)\.com" an = re.findall(pattern,url) print(an.group(1))
ec1e4a2c85e0b2ba5eecbc6c9ecadd4ec7619083
timols/spellwalrus
/calling/utils.py
303
3.78125
4
import string def chars_to_digits(word): "Given a string of characters, return the corresponding keypad digits" keypad_mapping = dict(zip(string.ascii_lowercase, "22233344455566677778889999")) return ''.join(str(keypad_mapping[l]) for l in word.lower())
0d80029c5b5598108f5d4eabf9ef355775d359e6
Taiwanese-Corpus/klokah_data_extract
/klokah/補充教材句型篇動詞時態比較.py
1,694
3.5
4
from klokah.補充教材句型篇解析 import 補充教材句型篇解析 from collections import OrderedDict from csv import DictWriter class 補充教材句型篇動詞時態比較: _補充教材句型篇解析 = 補充教材句型篇解析() 祈使對應表 = {'看': '看(如看電視、看東西)', '坐下': '坐著', '起立': '站著'} 否定對應表 = {'看': '看(如看電視、看東西)'} 欄位名 = ['華語', '肯定', '祈使', '否定'] def 輸出檔案(self, 方言編號, 檔名): ...
26105e5db1d2494c94be6b254a4153edd167aae1
pythonfoo/pythonfoo
/beginnerscorner/decorators.py
4,789
3.546875
4
#Dekoratoren #----------- # Dekoratoren sind Funktionen, die Funktionen verändern. # Zuerst brauchen wir eine Funktion, die irgend etwas macht: # Signatur: `f`: int -> int def f(n): """Addiert etwas zum gegebenen Argument.""" return n + 4 # garantiert zufällig gewählt f(13) # Nehmen wir a...
4fa10dd2aa7b79dcc30a8df61f0b22627114030c
iZainAsif/Tkinter-Auction-App
/Listitem.py
2,148
3.671875
4
from tkinter import* from tkinter import messagebox def listitem(hp): name=StringVar() typ=StringVar() startingprice=IntVar() buynow=IntVar() global li li = Toplevel(hp) li.title("List Item") li.geometry("500x520") li.configure(bg="wheat4") Label(li,text="Zain'...
a0f54b2540729052b3702081b28ae708e1616f5f
saby95/Leetcode-Submissions
/Climbing Stairs.py
815
3.703125
4
class Solution(object): def climbStairs(self, n): """ :type n: int :rtype: int """ if n<3: return n a,b =1,1 for i in range(2, n+1): a,b = b,a+b return b def stringToInt(input): return int(input) def intToString(input): ...
20cf1ad3f98da6082b65272981eb58dd2d8b446e
nami-h/Python
/itertools combination and [print("".join(i)) for i in itertools.combinations(sorted(word), i)] .py
147
3.515625
4
import itertools word, n = input().split() for i in range(1, int(n)+1): [print("".join(i)) for i in itertools.combinations(sorted(word), i)]
f6e06e1e3a897d505de94d23aa83c6c587e7b466
karar-vir/python
/return_duble.py
143
3.75
4
def double(num): return num*num print(double(3)) def double_lambda(n): return lambda x:x*n y=double_lambda(3) print(y(5))
954f6bf858924fd06a5e92784bfa282b5e31451b
Goodusernamenotfound/c4t-nhatnam
/session3/asterisk1.py
176
3.578125
4
rows = int(input("Nhập số hàng: ")) if rows<=0: print("Invalid!") else: for i in range (0, rows): for j in range(0, i + 1): print("*", end=' ')
70960e95dafdcf9188c6ab5df6d889ef4d2cfb00
marcossilvaxx/PraticandoPython
/ExercicioPOO/Questao3.py
1,219
3.890625
4
class Retangulo: def __init__(self): self.comprimento = eval(input("Informe o comprimento do retângulo:\n")) self.largura = eval(input("Informe a largura do retângulo:\n")) print("Construtor finalizado.") def mudarLados(self): self.comprimento = eval(input("Informe o novo comprim...
f54d34b7e73d7608a25925058303eadd2b619b43
bobsiunn/One-Day-One-BOJ-Pyhton
/Graph/1697.py
2,282
3.546875
4
#앞뒤 출구가 있어 stack,queue를 유연하게 사용할 수 있는 deaue import from collections import deque #bfs 탐색을 위한 함수 정의 def bfs(): #탐색해야할 위치를 저장하는 큐 선언 q = deque() #해당 큐에 탐색 시작 위치인 N을 저장 q.append(N) #더이상 탐색해야할 위치가 없을 때까지 반복 #if조건에 의해 조기 종료되지 않고, q = empty로 종료시, 탐색 대상이 존재x while q: #popleft...
72ad73420fd703b505543edc2056e72d22ab3ec0
joinalahmed/University_of_Michigan_Python_for_Informatics_Certificate
/2_Python_Data_Structures/Week1_Ch6_Strings/extractcode.py
319
4.09375
4
# 6.5 Write code using find() and string slicing (see section 6.10) to extract the number at the end of the line below. # Convert the extracted value to a floating point number and print it out. text = "X-DSPAM-Confidence: 0.8475" x = text.find('0') y = text[x-1:] val = float(y) print val #Expected output: 0.8475
4c2c90e7022c7be58e90ca1d8c3172bed5f2384c
mdelia17/bigdata-labs
/wordcount/reducer.py
870
3.828125
4
#!/usr/bin/env python3 """reducer.py""" import sys # this dictionary maps each word to the sum of the values # that the mapper has computed for that word word_2_sum = {} # input comes from STDIN (output from the mapper) for line in sys.stdin: # remove leading and trailing spaces line = line.strip() # p...
2258d02169741cf22061ea0374e50dc58a60beb3
JasperMi/python_learning
/chapter_07/rent_seat.py
179
4.125
4
rent_seat = input("How much seat do you want? ") rent_seat = int(rent_seat) if rent_seat > 8: print("There are not enough seats.") else: print("There are enough seats.")
65c77cfe0853aa9773bef4ea304ab777693b6794
daniel-reich/ubiquitous-fiesta
/LByfZDbfkYTyZs8cD_12.py
111
3.703125
4
def areaofhexagon(x): if x <= 0: return None else: return round(3 * pow(3,1/2) * pow(x,2) / 2,1)
63e8e25a11d5e18a93fa472cfdf18dda393359c7
sethuiyer/visualize-GOT
/visualise_char_deaths.py
1,878
3.671875
4
'''Question is how allegiances, nobility and the appearence in the book affect the gender of charecter deaths. ''' #Step 1: Import dependencies import pandas as pd import numpy as np from sklearn.preprocessing import StandardScaler import matplotlib.pyplot as plt from sklearn.manifold import TSNE from sklearn.preproce...
b7b5854abd25923d37dfcde75292dcc5733b70e4
GTRgoSky/TestLOL
/Python/PAT/pat.py
4,854
3.828125
4
# 进程和线程 ### 多进程 ##### fork 多进程模块。 """ Python的os模块封装了常见的系统调用, 其中就包括fork,可以在Python程序中轻松创建子进程 os.getpid() : 获取当前进程号 os.getppid() : 获取父级进程号 """ import os """ print('Process (%s) start...' % os.getpid()) # Only works on Unix/Linux/Mac: pid = os.fork() if pid == 0: print('I am child process (%s) and my parent is %s.' % ...
cd85ce0762726e8c98c7300d9d3d3d01ab8e41b8
bunnybryna/Learn_Python_The_Hard_Way
/ex13s.py
508
3.671875
4
from sys import argv script, first, second, third = argv print "The script is called:", script print "Your first variable is:", first print "Your second variable is:", second print "Your third variable is:", third print "What did you have for breakfast?", breakfast = raw_input() print "What did you have for lunch?",...
a746afa94ba5e4c76342eff0eb0e29d8fba758b8
vjbytes101/Bigdata-project
/New York/Data Analysis/parks/unsafe_parks_queens.py
699
3.546875
4
import sys import csv from pyspark.sql import SparkSession from pyspark.sql.functions import * spark = SparkSession.builder.appName("Python Spark SQL basic example").config("spark.some.config.option", "some-value").getOrCreate() df_parking = spark.read.format("csv").option("header", "true").load("/user/edureka_1...
5f02783ba9aadddf46f029f218478112b3cbf95b
a-angeliev/Python-Fundamentals-SoftUni
/05. Password Guess.py
94
3.515625
4
a = str(input()) if a == 's3cr3t!P@ssw0rd': print('Welcome') else: print('Wrong password!')
c4ff080721938ae3003cd3df9e435f7d8e430905
comedxd/Artificial_Intelligence
/6_BreadthFirstSearch.py
4,969
3.90625
4
class LinkedListNode: def __init__(self,value=0,parent=None,leftnode=None,rightnode=None): self.value=value self.parent=parent self.left=leftnode self.right=rightnode self.visited=False def PreorderWalk(self, node): if (node is not None): pr...
7657df7ce1a2ac63e694cc972b36da9d457286a6
702criticcal/1Day1Commit
/Baekjoon/9095.py
187
3.65625
4
for _ in range(int(input())): n = int(input()) nums = [0, 1, 2, 4] for i in range(4, n + 1): nums.append(nums[i - 3] + nums[i - 2] + nums[i - 1]) print(nums[n])
66afab404dc3f595fe1bedc36673e8a3af47f0c4
DT2004/intro-to-python-arithmetic-
/simple_arithmetic.py
198
3.78125
4
print(1+2) # this function is for addition print(30%2)# this is for finding out the remainder print(1984928347/10823) #using vaariables a = 10 b = 2 print(a/b) #prints out to 5.0 not 5 print(a/b)
aad6d219277e41030628948cf8ad916298f6eb26
nischalshk/IWPython
/Functions/2.py
225
4.0625
4
# Write a Python function to sum all the numbers in a list. # Sample List : (8, 2, 3, 0, 7) # Expected Output : 20 def sumAll(l): sum = 0 for i in l: sum += i return sum print(sumAll([0, 1, 2, 3, 4]))
f616747588095625b937947541a403c41f8d31d8
chuanfanyoudong/algorithm
/leetcode/DividedTwoIntegers.py
963
3.734375
4
""" @author: zkjiang @contact: jiang_zhenkang@163.com @software: PyCharm @file: DividedTwoIntegers.py @time: 2019/2/20 22:49 """ import math class Solution(object): def divide(self, dividend, divisor): """ :type dividend: int :type divisor: int :rtype: int """ positi...
55ff6c1d07e6d079e8a6b0589aaf4495ae1c6337
MikhailRyskin/Lessons
/Module29/03_format_logging/main.py
738
3.515625
4
from log_module import log_methods @log_methods("b d Y - H:M:S") class A: def test_sum_1(self) -> int: print('test sum 1') number = 100 result = 0 for _ in range(number + 1): result += sum([i_num ** 2 for i_num in range(10000)]) return result @log_methods("b ...
c377de2b7e19833a7745caec7dfda790014bf8dd
trigodeepak/Programming
/Palindrome_partioning.py
1,531
4.15625
4
#Program for palindrome partitioning def minPalPartition(string): length = len(string) dp_cuts = [[0 for i in range(length)]for x in range(length)] #This matrix is to determine that the given substring is palindrome or not p = [[False for i in range(length)]for x in range(length)] #This loop is to a...
3468cc033a160811c97cfbf0f6ba37ae1eeac953
alphatrl/IS111
/Lab Tests/2018.1 Lab Test/Original/q3.py
440
3.515625
4
def mask_out(sentence, banned, substitutes): # write your answer between #start and #end #start return '' #end print('Test 1') print('Expected:abcd#') print('Actual :' + mask_out('abcde', 'e', '#')) print() print('Test 2') print('Expected:#$solute') print('Actual :' + mask_out('absolute', 'ab', '#$...
5664be4f80364bd712b04324ab79f3f1f3811bd0
iftakher-m/Library-database-app
/backend.py
1,686
3.625
4
import sqlite3 class Database: def __init__(self, db): # if "self" isn't written, "database" object from 'frontend' will be passsed there. self.conn = sqlite3.connect(db) self.cur = self.conn.cursor() # 'self' to make 'cur' an attribute of 'database' object and later use in other functions. ...
0fe163504a3ff957a7ef925799f778471a0296b5
dwightmulcahy/healthchecker.server
/uptime.py
1,014
3.6875
4
from datetime import datetime class UpTime: def __init__(self): self.startDatetime = datetime.now() def __repr__(self): return self.__str__() def current(self): return (datetime.now() - self.startDatetime).total_seconds() def __str__(self): return self.timetostring(s...
b7d6028761718e621b3740fef73d27d03be44d76
wassimmarrakchi/crimtechcomp
/assignments/Wassim Marrakchi/000-code/assignment.py
1,264
4.03125
4
# Color: Crimson def say_hello(): print("Hello, world!") # Prints message back out to console def echo_me(msg): print(msg) def string_or_not(d): exec(d) def append_msg(msg): print("Your message should have been: {}!".format(msg)) # TODO: understanding classes (an introduction) class QuickMaths(): ...
d5d4d87ebbe418f35fd7ad97a5aff966305ff0ed
liamdebellada/python-utilities-collection
/class-practice.py
1,426
3.5625
4
class setup(): def __init__(self, name, status): self.name = name self.status = status def getName(self): return self.name def getStatus(self): return self.status bools = { "true" : True, "false" : False } for item in bools: print(item) for key, value in boo...
1a997b9760eeeaedfa96f2fcaafa8773fb34664b
1998sachin/CP_reference-material
/Algorithm/DP/factoiral_recursion.py
169
4.125
4
#this is simplest recursive factorial function, it performs very bad def fact(n): if n==1 or n==0: return 1 else: return n*fact(n-1) n=int(input()) print(fact(n))
a959ec08ece97215c5649ed82685c9759b2292a1
kristjanlink/python-wrangling
/process_icons.py
718
3.65625
4
#!/usr/bin/env python3 import os from PIL import Image def process_icons(): """Rotates images 90 degrees clockwise, resizes them to 128 x 128 and saves them in *.jpeg format.""" for image in os.listdir("images"): if not image.startswith('.'): # To skip system files such as ".DS_Store" with Image.ope...
ca600902fbb0e8724b6719bc087c64e135d4dbc0
mrstevenlu/Tuple-and-List
/01.py
740
3.671875
4
# -*- coding: UTF-8 -*- # Filename : 01-string.py23 # author by : Steven Lu # 目的: # 列表和元组 print("开始") import random List1 = ['张飞','赵云','马超','吕布'] Tup1 = ('刘备','曹操','孙权') pos = 0 value = List1[pos] print("取出列表的第%d个值,它是%s"%(pos,value)) print ("输出列表中所有元素") pos = 0 for v in List1: print ("取出列表的第%d个值,它是%s"%(pos,v)...
f89760eff8f701d69c71b82dc06122a7f84501d7
DickyHendraP/Phyton-Projects-Protek
/Pratikum 10/Nomor 3.py
510
3.734375
4
#Program Memofifikasi dari nomor 2 #Program akan diperoleh variable bertipe data ditionari #Membuka file file = open("file.txt" , "r") #Membaca file secara per baris data = file.readlines() #Membuat dictionari kosong dataMHS = {} for i in range(len(data)) : Mhs = data[i] #Memisah data a,b,c = Mhs.split('|'...
d4543122f9435b9d0680ba2e06cf5df710507fa3
yingxingtianxia/python
/PycharmProjects/my_python_v03/base1/ent.py
572
3.640625
4
#!/usr/bin/env python3 #--*--coding: utf8--*-- import keyword import string first_chs = string.ascii_letters + '_' all_chs = first_chs + string.digits def check_id(idt): if idt[0] not in first_chs: return '1st char invalid.' for ind, cha in enumerate(idt[1:]): if cha not in all_chs: ...
a413379d2e7aa18ef97ff8b6835bb45fd4c6b734
elMimu/python-bootcamp
/fatorial.py
102
3.609375
4
def fatorial(x): if x == 0: return 1 return x*fatorial(x -1) N = int(input()) print(fatorial(N))
3f1f692d9c46f727cf263bdd5dfd2395975bd717
manticorevault/100ProjectsIn100Days
/Day 1 - Random Phrases Game.py
3,008
3.5
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 7 15:03:50 2016 @author: Artur """ import random import time def regrasDoJogo(): print("\nNão se sabe muito bem como esse jogo surgiu, mas ele") print("foi trazido para o ocidente pelo bardo e mercador Tenório.") print("Esse jogo fez muito suce...
7649c75bb9c05639ea9ab367dfc1067cee62b7d0
kotaro0522/python
/procon20180512/exponential.py
564
3.640625
4
x = int(input()) maximum = 1 for i in range(2,32): if i*i <= x and i*i > maximum: maximum = i*i for i in range(2, 11): if pow(i,3) <= x and pow(i,3) > maximum: maximum = pow(i,3) for i in range(2, 6): if pow(i,4) <= x and pow(i,4) > maximum: maximum = pow(i,4) for i in range(2, 4): if pow(i,5) <=...
7ed478ff7b098fca0dce8fe05a1514b5c74a4ce4
yemao616/summer18
/Google/2. medium/356. Line Reflection.py
1,190
3.71875
4
# Given n points on a 2D plane, find if there is such a line parallel to y-axis that reflect the given points. # Example 1: # Given points = [[1,1],[-1,1]], return true. # Example 2: # Given points = [[1,1],[-1,-1]], return false. # Follow up: # Could you do better than O(n2)? class Solution(object): def is...
459d145e8f8cd0b95a2a366c0bad86b326c6232f
zhaxylykova/LAB2-TSIS4
/n.py
732
3.828125
4
def addition(a, b): if a == b: return a + b if a > b: if b == 0: return a else: if b > 0: recurs = addition(a, b-1) + 1 return recurs else: recurs = addition(a, b+1) - 1 return recurs ...
5d663c38ce8bb0ba38d9e62aa8ef6217f75f3ce5
dawidsielski/Python-learning
/sites with exercises/w3resource.com/Python Basics/ex34.py
125
3.625
4
def sum(a,b): result = a + b if result >= 15 and result <= 20: return 20 return result print(sum(10,11))
c3b79bac781e64a42b86c03ee81756d923f87dce
guhwanbae/GuLA
/orthogonality/qr_factorization.py
826
3.96875
4
# Author : Gu-hwan Bae # Summary : Find the QR factorization and solving a linear equation. import numpy as np import gula.qr as gQR # Case I : QR decomposition. Find the QR factorization, QR = A. print('Find the QR factorization.') # Col A is linear independent. A = np.array([[1, 1, 0], [1, 1, 1], ...
ae38f4b38413c9e7785cae84334bb1f73de17dba
snowcity1231/python_learning
/list/list.py
582
4.125
4
# -*- coding: UTF-8 -*- # 列表的数据项不需要具有相同的类型 list1 = ['physics', 'chemistry', 1997, 2000] #列表截取 print "list1[0]: ", list1[0] print "list1[2:5]: ", list1[1:3] print "list1[-2]:", list1[-2] # 扩展列表 list = [] list.append('Google') print "list: ", list # 删除元素 print 'list1:', list1 del list1[2] print "after deleting list1:...
204277b17a086cbdf263c3fd30576f32f703cdbb
mustafa7777/LPTHW
/ex21_2.py
879
4.09375
4
def add(a, b): print "ADDING %d to %d" % (a, b) return a + b def subtract(a, b): print "SUBTRACTING %d from %d" % (b, a) return a - b def multiply(a, b): print "MULTIPLYING %d with %d" % (a, b) return a * b def divide(a, b): print "DIVIDING %d by %d" % (a, b) return a / b print "...
92da57cf9d9b87376f945b14ced331d9674fd04a
pnguyen90/HogDiceGame
/strategies.py
7,637
4.1875
4
from dice import * from hog import * ####################### # Phase 2: Strategies # ####################### # This file is the testing ground for strategies. first make your strategy or strategies. # To run your strategy against another one, modify the run_experiments function. # # Experiments """Below are some funct...
d3f502b87fe2a7b857ef922e6d2e20aba2eebd02
nahomtefera/udacity_datastructures_algorithms
/P2/Problem_5/Autocomplete_with_Tries.py
2,219
4.125
4
## Represents a single node in the Trie class TrieNode: def __init__(self): ## Initialize this node in the Trie self.is_word = False self.children = {} def insert(self, char): ## Add a child node in this Trie if char in self.children: return self.chil...
a409961ac62b913219e2ff641656a97ed659b366
MysteriousSonOfGod/adventure_engine
/mechanics.py
3,248
3.75
4
#!/usr/bin/env python27 # -*- coding: utf-8 -*- import sys import yaml import colorama from colorama import Fore, Back, Style class BaseAdventure: """This is a base class for all of our adventure objects.""" def __init__(self, name, description): self.name = name self.description = descriptio...
885a4763dc59947a1d6382a9af13bf5a753ab4df
sandjes1046/Grade-Visualization-System
/Client/LoginGUI1.py
3,756
3.546875
4
# -*- coding: utf-8 -*- """ Created on Tue Mar 9 22:59:02 2021 @author: DanielSanchez """ import tkinter as tk from tkinter import ttk import tkinter.messagebox as msb from tkinter import * class loginGUI: def redirectToSignUp(self): self.command = "sign up" self.win.destroy(...
16b83a6a51a47fa2ffe6ee25ba5225f0a91d9c73
jfernand196/Ejercicios-Python
/primer_ultimo_lista.py
312
3.8125
4
#Obtener el primer y ultimo elemento de una lista lista = ['juan', 'mateo', 'yamile', 'vero'] primer_elemento = lista[0] #OPCION 1 #ultimo_elemento = lista[len(lista) -1] #OPCION 2 CON SLICE ultimo_elemento = lista[-1] print(' primer elemento: {} y ultimo elemento: {}'.format(primer_elemento, ultimo_elemento))
4a873c4721c07c080be39db750042292b6fc9691
SyedSaifi/PythonExample
/com/example/pythonex/InheritanceEx.py
575
3.796875
4
''' Created on Feb 19, 2017 @author: ssaifi ''' class Parent: value1="Value One" def __init__(self,name, age): self.name=name self.age=age def changeAge(self,age): self.age = age def __str__(self): return self.name+" -- "+str(self.age) class Child(Parent): def __...
fe1b9833294d39692842ecc536b2781fc62be6da
CxpKing/script_study
/python/基础/data_type.py
3,611
4.125
4
''' 关于python的数据类型,元组、列表、字典以及集合四大 数据类型的定义、使用及其各自的特性 ''' #元组 tup1 = ('A','B','C') print('tup1->',tup1) #列表 list1 = ['A','B','C'] print('list1->',list1) #字典 dict1 = {'key1':'value1','key2':'value2'} print('dict1->',dict1) #集合 #方式1 使用符号 {} set1 = {'A','B','C'} print('set1->',set1) #方式2 使用 set() 其参数为一个元组, set2 = set(('A','B...
c943411e726e0ba0d904a2e635418163e2711721
toggame/Python_learn
/第二章/test2.py
950
3.609375
4
a = int(input('请输入整数a:')) b = int(input('请输入整数b:')) print(a // b) print(a / b) print(a + b) print(a - b) print(a * b) st1 = input('请输入字符串:') st2 = input('请输入子串:') ct = 0 print(st1.count(st2)) # count计数不会重复 for i in range(len(st1)): # range默认0 start,不包含end项 if st1[i: i + len(st2)] == st2: ct += 1 print(ct...
ea292af4cae942964d9dee084bb87f6106bca56a
VicenteDH/tarea-2-EstebanVega1
/assignments/05Ordena/src/exercise.py
703
4.03125
4
numero1=int(input("Ponga un numero :")) numero2=int(input("Ponga otro numero:")) numero3=int(input("Ponga el ulitmo numero:")) if ((numero1<=numero2) and (numero1<=numero3)): menor=numero1 if(numero2<=numero3): medio=numero2 mayor=numero3 else: medio=numero3 mayor=numero2 el...
cef551d7cc3bcd9cda660a189e8683bd786dc476
OutlawAK/OutlawAK
/Python/dict.py
712
4.09375
4
student = {'name': 'John', 'age': 23, 'type': ['math', 'physics']} print(student['name']) print(student.get('age')) print(student.get('phone', 'not found')) # if found sends the value, if not ,then second value is printed. student.update({'name': 'jane', 'age': 26, 'phone': '555-5555-555'}) print(student) # for upd...
c7f4e85ba75d6db18c45e463e2613b6e82832884
mohammedterry/fuzzy
/fuzzy_bot.py
3,951
3.578125
4
class FuzzyBot: # this bot is robust to: # spelling (using chargrams) # phrasing (using question vector classification method) # and it can learn to speak from example conversations answers = {} answer_ids = {} word_vectors = {} chargram_vectors = {} def clean(self,txt): c...
e54bca9000e3e2b6d62fd9666d9630f52beb0641
nicwigs/231
/Projects/proj10(Alaska)/proj10__2.py
11,287
3.859375
4
import cards # This line is required #-------------------------------------------------------------------------- RULES = ''' Alaska Card Game: Foundation: Columns are numbered 1, 2, 3, 4 Built up by rank and by suit from Ace to King. The top card may be moved. Tableau: Col...
1b55b3537f2848dfbc7cc83a1b3fab98c885fb02
dsbrown1331/Python1
/IterationLogic/compound_interest.py
346
3.96875
4
#Write a program that computes the balance of a bank account with #interest compounded monthly balance = 100 #starting balance rate = 0.05 #interest rate years = 3 num_compounds = years while(num_compounds > 0): num_compounds -= 1 balance *= rate + 1 print(balance) print("After {} years you will have ${}...
1444e0dd67c8a1238efcf452b6480e0d6bb66b6a
edoardovivo/algo_designII
/Assignment1/schedule_greedy.py
3,054
4.09375
4
''' Problem 1: In this programming problem and the next you'll code up the greedy algorithms from lecture for minimizing the weighted sum of completion times.. Download the text file below. jobs.txt This file describes a set of jobs with positive and integral weights and lengths. It has the format [number_of_jobs] ...
e7dd6416c564eece232cc1890b9043e77e4a97bd
drmtv10/samples
/match_paren.py
950
4.09375
4
#!/bin/python # match parenthesis in given string def match_paren(in_str): paren = list() for x in in_str: if x == '(' or x == '[': paren.append(x) elif x == ')': y = paren.pop() if y != '(': return False elif x == ']': y =...
04515093f91cbb41e4c6e9641716fbc5bda39fc1
Sheetal777/ds-algo
/Codechef/Practice Problems/7_small_fact.py
128
3.546875
4
t=int(input()) for j in range(0,t): k=int(input()) fact=1 for i in range(2,k+1): fact=fact*i print(fact)
3265720c866e029eecf5a7b2f2d3dba6e3b87512
Astony/Homeworks
/homework6/task02/hard_classes_task.py
4,888
3.703125
4
from datetime import datetime, timedelta from typing import ClassVar, Type class InvalidError(Exception): """This is my personal error for check_homework_type method""" def check_homework_type(some_obj: ClassVar, homework_class: Type) -> "Homework": if isinstance(some_obj, homework_class): return so...