blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2c97a48761b3ce1a69c5da43f174c27fff401af0
KatsunoriWa/slowCodingCV
/samples_Python/ex_argsort.py
410
3.734375
4
import numpy as np a=np.array([ [ 6, 22, 14, 4, 22], [10, 11, 18, 1, 4], [1, 13, 7, 13, 0], [23, 18, 1, 17, 3], [ 3, 18, 0, 14, 23]]) print a print "ROW|ASCENDING" print np.argsort(a, axis=1) print "ROW|DESCENDING" print np.argsort(a, axis=1)[:, ::-1] print "COLUMN|ASCENDING" pr...
32ca10a765afb01cb4727a51459de8b201f54f72
ValeriyMartsyshyn/BLITZ_LABs
/Lab3/Task[13-15].py
1,914
4.59375
5
""" Task 1 A simple way of encrypting a message is to rearrange its characters. One way to rearrange the characters is to pick out the characters at even indices, put them first in the encrypted string, and follow them by the odd characters. For example, the string message would be encrypted as msaeesg because the even...
a3f31675ef114ec39ec6a9f1bde755dac240b561
Rutie2Techie/Hello_python
/function/add_num_map.py
213
4.09375
4
## add some constant value to each member of the list. values=[2,4,6,8] #We convert the returned map object to # a list data structure for printing purpose addition=list(map(lambda x:x+10,values)) print(addition)
23658f7404592d5344616599dcb05085adf94ff5
luisotaviocap98/Radix_Implementation
/telefone.py
6,359
3.703125
4
import sys class No: def __init__(self,dado, telefone): self.dado = dado #palavra a ser mostrada no Nó self.listaNos = list() #lista contendo os filho daquele Nó self.ePalavra = True #se a palavra é valida, se pode ser encontrada self.pOriginal = dado #a palavra completa, usada na ...
eac2ad217899883d06da84eb3efbd0aa424e34bb
romkravets/python-data
/41/list_and_if/list_numbers.py
1,600
3.671875
4
#Напишіть програму Python, щоб роздрукувати всі парні числа із заданого списку чисел у тому самому порядку та зупинити друк, #якщо в послідовності є числа, що приходять після 237. numbers = [ 386, 462, 47, 418, 907, 344, 236, 375, 823, 566, 597, 978, 328, 615, 953, 345, 399, 162, 758, 219, 918, 237, 412,...
094f58bd7c6dcf83cb8327cbe9f5c9929df77842
Rohit263/python-practice
/soln3_smallest_divisible.py
963
4.15625
4
def div(): #l_lim = lower limit of the searching range #u_lim = upper limit of the searching range #declaring x,y,l_lim,u_lim as global variable global x,y,l_lim,u_lim l_lim =1 u_lim =1 values = [] # Getting the value of lower limit and upper limit of the search for any x and y fo...
b451ff30f233891bdb0c4aabb3e96818666583bd
benlinhuo/algorithmpy
/leetcode/Array/Simple/question_53.py
696
3.75
4
#!/usr/bin/python3 ''' 对应链接:https://leetcode-cn.com/problems/maximum-subarray/ 53. 最大子序和 给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。 示例: 输入: [-2,1,-3,4,-1,2,1,-5,4], 输出: 6 解释: 连续子数组 [4,-1,2,1] 的和最大,为 6。 进阶: 如果你已经实现复杂度为 O(n) 的解法,尝试使用更为精妙的分治法求解。 ''' class Solution(object): # 复杂度为 O(n) # 因为是需要...
98779b523fe47886dfa7999416d96a021e524ee6
wsysissi/NanYang-program-interview
/question_1/code_question_1_1.py
7,102
4.28125
4
#Since the value of each member in a row of the matrix given in the example is #equal to the number of that row, the matrix generated in this code is also of this form, #but can be replaced with other matrices in other cases. ''' README input of the code is like the example below: e.g.we want to find the oper...
0a91d3ec66ec1a74bfdbfb24e213ce56b8d531d0
wangmj88/TestCode
/TestMianShi-1/TestList.py
726
3.8125
4
#python 查找重复项 l = [1,2,3,2,1] for i in l: print("this %s ha fount %s" %(i,l.count(i))) print('split line----------------------------') s = set(l) for j in s: print("the %s has fount %s" %(j,l.count(j))) #删除重复元素 listA = ['python','语','言','是','一','门','动','态','语','言'] print(sorted(set(listA))) #[python] 查找列表中重复...
1682220ba56697cfb665856e989f6af1bfea5c07
ben174/stickerletters
/sticker.py
3,658
3.96875
4
# importing Numpy for Calculations on Arrays # i would recommend avoiding numpy for a problem as simple as this one. import numpy as np # importing Money for Proper Handinling of Currency # definitely avoid importing libraries that aren't a part of the # standard library unless completely necessary. from money import ...
f6feb5c320cd61dacdb28672d34869193e6f8d35
worksking/algrithm
/MergeSort.py
1,940
3.96875
4
import numpy as np def Merge(left, right): output = [] while len(left) > 0 and len(right)>0: if left[0] <= right[0]: output.append(left.pop(0)) else: output.append(right.pop(0)) #while循环出来之后 说明其中一个数组没有数据了,我们把另一个数组添加到结果数组后面 output += left output ...
20897130ff998a3c1a89846b0a42195d9eedb69f
Prerna983/260567_PythonPractiseLTTS
/Assignments1/if_elseQ4.py
177
4.125
4
# Write a python program to check if the input number is # -real number # -float numner # -string- # complex number # -Zero (0) x=eval(input("Enter a number: ")) print(type(x))
539f5b058b05a1b441c4459bf99803536f9823cb
Christyan-Cyan/py_training
/Belajar Mandiri/array.py
336
3.65625
4
kondisi = True basic = ["ipan suki", "maman", "hizbool", 'cyan'] def fungsi() : inp = input("siapa yg ingin di eksekusi? ") for i in basic : if i == inp : print(i + " telah rip") break else : print("ok sip") while kondisi == False : fungsi() if inp == "end"...
d0cfa3fa4d3d966db5ab0d10b1dc1710ffbc5203
shulyak86/hillel_ira
/homework 7 lesson/task2.py
635
3.734375
4
a = input('vvedite temperaturu: ') b = input('vvedite shkalu (C, K, F): ') def isx_c(): print(a, 'C', '\n', int(a)+273, 'K', '\n', int(a)*1.8, 'F') def isx_k(): print(a, 'K', '\n', int(a) - 273, 'C', '\n', int((int(a)-273) * 1.8), 'F') def isx_F(): prin...
a8a2cb9b762028044d5648ea69d5f4530adf9368
cu-swe4s-fall-2019/version-control-sahu0957
/calculate.py
549
3.71875
4
import argparse import math_lib as ml parser = argparse.ArgumentParser() parser.add_argument("numerator", help="first number to add, and numerator", type=int) parser.add_argument("denominator", help="second number to add, and denominator", type=int) args = parser.parse_args() if __name__ == '__main__': x3 = ...
1d709a79f7e5c4ff49397091fe76ebd51e4e48f6
Ashish9426/Python-Tutorials
/6. frozenset_dictionary/Page2_Dictionary.py
3,612
3.765625
4
def function1(): # empty list l1 = [] print(f"l1 = {l1}, type = {type(l1)}") # empty list l2 = list() print(f"l2 = {l2}, type = {type(l2)}") # empty tuple t1 = () print(f"t1 = {t1}, type = {type(t1)}") # empty tuple t2 = tuple() print(f"t2 = {t2}, type = {type(t2)}") ...
b5ef1196655dbc592960c0732fc9ae824f66fb74
navneet28/PythonForBeginners
/learnURLlib.py
553
3.625
4
import urllib.request import urllib.parse ''' req=urllib.request.urlopen('https://www.google.com') print(req.read()) ''' values = {'q':'python programming tutorials'} data = urllib.parse.urlencode(values) url = 'https://www.google.com/search?'+data print(data) #data = data.encode('utf-8') #oop #self,*args,**kwargs he...
f6a01745223aea375c255875c8d1de978200c522
Aujasvi-Moudgil/Classification-and-Representation-Learning
/Lab_Tutorials/Tutorial2/Tutorial 2.a code.py
1,987
3.59375
4
# -*- coding: utf-8 -*- """ Created on Mon Oct 9 10:34:48 2017 @author: Aujasvi """ from numpy import * import matplotlib.pyplot as plt #Load the data set data = loadtxt('nonlinear_classification.data') X = data [:, :2] T = data [:,2] N, d = X.shape #Parameters eta = 0.05 #Learning rate K = 15 #Number of hidden neu...
5579bec4095292b0de8968de0de25447a991dca4
xexxatechng/MyGitProfile
/Python/furniture_pricing.py
705
4.03125
4
#Code written by: Christian Nwachukwu #Date: 25/05/2019 #Application puppose: Application gives the correct price if the right options and chosen else prompts for re-entry. while True: print() print("Enter 1, 2 or 3 to obtain prices") option = int(input()) if option == 1: ...
7edf55548f01de3c27bc3ae4bfb26ea7d884c649
ChenFu0420/leranpython
/part6/item.py
240
3.75
4
class Item: #直接在类命名空间中放置可以执行的代码 print("正在定义Item类") for i in range(10): if i % 2 == 0: print("偶数", i) else: print("奇数", i)
5c5352f4e10a55c33a50dd66527cf91fc5a86c80
aaryanredkar/prog4everybody
/L1C7_Game.py
734
3.984375
4
import random guessesLeft = 15 userName = input("Please enter your Name :") number = random.randint(1, 1000) print("Hello", userName, "I'm thinking of a number between 0 and 1000.") while guessesLeft > 0: print("You have", guessesLeft, "guesses left") guess = int(input("Guess a number : ")) guessesLeft =...
3245fb0dacbbd460dee45333a339bb08b813da9f
aasthaagrawal/Algorithms_and_Data_Structures
/leetcode/268_Missing_Number.py
284
3.5625
4
#https://leetcode.com/problems/missing-number/ #Complexity: O(n) class Solution: def missingNumber(self, nums: List[int]) -> int: lenArr=len(nums) sumres=int(((lenArr+1)*lenArr)/2) for i in range(lenArr): sumres-=nums[i] return sumres
04968513d8fbf1de1c7bc477b1ccf4ee9d6a34d5
Techfighter/Histoires
/debug.py
412
3.578125
4
liste_arme = ["épée", "fusil", "baton", "knif", "lame", "styleto", "canon", "pistolet", "revolver", "fusil-a-pompe"] inventaire = ["épée", "bananas"] equiper = 0 dommage = 10 key = input("?>") if key == "attaquer": if (inventaire[equiper] in liste_arme): print("Vous frapper avec", inventaire[equiper]...
f7dae2eafc2fd07ccb8e1563a68d6093b25fd3c8
genii01/coding_test
/yb/Q_12_max-profit.py
369
3.578125
4
from typing import List import sys class Solution : def maxProfit(self,prices:List[int]) -> int: profit = 0 min_price = sys.maxsize for price in prices: min_price = min(min_price,price) profit = max(profit,price - min_price) return profit prices = [7,1,5,...
136464443538c5b2dd6bca897a1439b244c3ad91
mccmrunal/TIC-TAC-TOE
/TICTACTOE.py
2,957
3.671875
4
#board import sys import os from os import system, name def clear(): os.system('cls' if os.name == 'nt' else 'clear') table = ["-","-","-", "-","-","-", "-","-","-",] count = 0 lis = [] def boardreset(): for i in range(0,9): table[i] = "-" global count count = 0...
f155ec6fa9cac1f2f8634e36e89d9ece1762cdd3
Namdrib/adventofcode
/src/main/template/day.py
929
3.640625
4
#!/usr/bin/python3 import sys class DayXX: """ Solution for https://adventofcode.com/2022/day/XX """ def __init__(self) -> None: """ Constructor """ self.input: list = None def read_input(self) -> None: """ Read input from stdin and parse it into a ...
921594ef34d6b55242c598ca970c95c5a7aae821
hyunjun/practice
/python/problem-dynamic-programming/climbing_stairs.py
640
3.84375
4
# https://leetcode.com/explore/featured/card/recursion-i/255/recursion-memoization/1662 class Solution: # runtime; 32ms, 32.63% # memory; 13.7MB def climbStairs(self, n: int) -> int: dp = [0] * (n + 1) for i in range(1, len(dp)): if i == 1: dp[i] = 1 ...
b87ff2d1d673b90c9ef0bd9c92c25b3d50f7dade
Chukwunonso/Rot13
/main.py
960
3.875
4
def collect(word): small_alphabet = range(97,123) #Ascii characters for small letters cap_alphabet = range(65, 91) #Ascii characters for cap letters encrypt_word = "" for i in word: if ord(i) not in range(97,123) + range(65,91): new_i = str(i) else: if ord(i) in r...
25c8221b67029fb85b3a0943f9b28ee59174e4c1
akhil960/akhilnmgd
/flow controls/decisionMaking/2ndLargest.py
274
4.0625
4
n1=int(input("enter n1:")) n2=int(input("enter n2:")) n3=int(input("enter n3:")) if(n1==n2)&(n2==n3): print("numbers are equal") elif(n1>n2): if(n1<n3): print(n1) else: print(n3) else: if(n2<n3): print(n2) else: print(n3)
cab6caf9c012d5f2306a78d3ad5c8c93aade350d
soply/curve_interpolation
/geometry_tools/utils.py
747
4
4
# coding: utf8 import numpy as np def means_per_label(X, labels): """ Calculates the means of all subsets of X. Subset membership is indicated by labels. Parameters ================= X : np.array of floats, size D x N Data points labels : np.array of ints, size N Indicate...
757f26c9dd7bfbb900594c2100db19d4f8700279
chagaleti332/HackerRank
/Practice/Python/Itertools/itertools_combinations.py
1,454
3.921875
4
""" Question: itertools.combinations(iterable, r) This tool returns the r length subsequences of elements from the input iterable. Combinations are emitted in lexicographic sorted order. So, if the input iterable is sorted, the combination tuples will be produced in sorted order. Sample Code: >>>...
50a68ed30ff2205d1a013eb9a14bf76fdd364789
Jose-Humberto-07/pythonFaculdade
/jogo-tabuleiro/jogo.py
852
3.859375
4
import funcoes as f casas = 17 fim = casas - 1 vencedor = "" print(("+"*23)+" O JOGO "+("+"*23)) print("Quanto jogadores vão jogar? ") quant = int(input()) if quant > 4 : quant = 4; jogadores = f.RecebeJogadores(quant) tabuleiro = f.IniciaTab(casas, quant, jogadores) print(("+"*23)+" Inicio "+("+"*23)) f.MontaTab(quan...
a0d1124a99d029736f384745258fe284720f1ceb
rajlath/rkl_codes
/Helpers/random_array_integers.py
548
3.765625
4
import random def create_random_int_arr(element_count, range_start, range_end, distinct= True): ''' create an array of integers haveing number of element=element_count having values between range_start and range_end - inclusive :type element_count int :type range_start int :type range_end ...
6a7cfdc49852c592a2d8049d249fb8af5508443d
Clara-Kloster/Guldkorpus
/code/python/find_problem_pos.py
2,447
3.671875
4
# -*- coding:utf-8 -*- # This program takes user input of lemma, pos to find which files contain the problematic pos import re import csv import os import sys # Find relative path sys.path.append(os.path.realpath('../..')) directory = sys.path[-1] + '/transcriptions/org/lemmatisation/' print("This program searches f...
7e62557d91d43b54b628d79eb56793fbd6ead435
zhangchizju2012/LeetCode
/551.py
597
3.5625
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Sat Apr 15 19:24:46 2017 @author: zhangchi """ class Solution(object): def checkRecord(self, s): """ :type s: str :rtype: bool """ count = 0 countL = 0 for i in s: if i == "A": ...
fb2242c69e389637d9de6d8dd6da7cf1f390048b
ask4physics/python-ICDL
/Day 1 (28012021)/Name.py
169
4.4375
4
Name = input ("What is your name? ") #ask the user to input. Variable will be stored in #name variable. print("Your name is:", Name) #print message and variable value.
f8b50b147dda8588396bdef5c1d845cb2154d72e
rajdharmkar/Python2.7
/math/matrixprod1.py
286
3.609375
4
X = [[1,2,3],[4,5,6],[7,8,9]] Y = [[1,2,3],[4,5,6],[7,8,9]] product = [[0,0,0],[0,0,0],[0,0,0]] for i in range(len(X)): for j in range(len(Y[0])):#why len(Y[0])taken? for k in range(len(Y)): product[i][j]+=X[i][k]*Y[k][j] for r in product: print(r)
287caa285aeb7989b8277d10df668d2ac99c22cc
hwanginbeom/TIL
/algorithms/source/42.loop1.py
387
3.890625
4
# 문제 1. # 10보다 작은 자연수 중에서 3 또는 5의 배수는 # 3,5,6,9가 존재해요! 이것들의 합은 23입니다. # 1000보다 작은 자연수 중에서 3 또는 5의 배수들을 # 구해서 모두 합하면 얼마인가요? sum_value = 0 for i in range(1,1000): if i % 3 == 0 or i % 5 == 0: sum_value += i print("문제 1번 : {} ".format(sum_value))
5693f1d1aaba7b34ac168da108a62f555833bef5
ngvinay/python-projects
/spring-2017/src/python-onramp/hw3/Assignment3.py
3,830
3.9375
4
# 1. You have been given a barGraph.csv file. Using the data of this file you have to draw a bar graph showing all 8 emotions corresponding to each business. import pandas import os import matplotlib.pyplot as plt import numpy as np relativePath=os.getcwd() dataFilePath=relativePath+"/Resources/barGraph.csv" ...
ed3965619cc03879b693814a582591e634c17250
backtrunck/learning_python2
/alo.mundo.py
275
3.625
4
print "alo mundo" print "alo mundo" print "alo mundo" print "alo mundo" print "alo mundo" print "alo mundo" print "alo mundo" print "alo mundo" print "alo mundo" print "alo mundo" h=raw_input("digite uma tecla") for k in range(999): print "%d alo mundo 2"%k print "tchau"
6f8a42c59558282b81dd86a4112ba9e3729ddcb8
drifftingcanoncuddle/szawiola-zadanie
/simulation/SimFrame.py
692
3.515625
4
from typing import * from simulation.Particle import Particle class SimFrame: """ One state of world in some moment in time """ def __init__(self, particles: List[Particle]): """ :param particles: list with particles in world """ self.particles = particles def get_...
eb81acc6086d947fa43beabda7027ef68621f1f1
heldaolima/Exercicios-CEV-Python
/ex012.py
305
3.890625
4
print('--- CALCULADOR DE DESCONTO ---\n') prod = float(input('Qual o preço produto em questão? R$')) desc = (5/100) * prod final = prod - desc print('----') print(f'Estamos oferecendo 5% de desconto. Serão descontados R${desc:.2f}.\n' f'Portanto, a sua compra terá novo valor de R${final:.2f}.')
cc497e6af1dac8bdbd0c0391ea5aa53bd701ef27
slvborisov/slvborisov.github.io
/exs1.py
323
4.03125
4
print ("Greetings!") name = input("What is your name? ") print ("Nice to meet you " +name+"!") age = int(input("Now, what is your age? ")) year = str((2020 - age)+100) message = name + ", you will be one hundred in " + year print (message) repeat = int(input("Now give me a random number: 1-10 ")) print (message * repea...
1cda1300b8ad592a57f61ecdb1e541803ec53e20
bhulet/courseraRicePython
/stopwatch.py
2,191
3.640625
4
"Stopwatch: The Game" import simplegui # define global variables interval = 100 count, sec, min, y, x = 0, 0, 0, 0, 0 ratio = str(x) + "/" + str(y) time = str(min) + ":" + str(sec) + "." + str(count) game = True # define helper function format that converts time # in tenths of seconds into formatted string A:BC.D d...
ac603dcf32df70fb56a6d5347b76850a63628cd0
FelipeECarvalho/Primeiros-Projetos
/Estrutura de Dados/funcao_recursiva.py
857
4.09375
4
def soma(array): if len(array) == 0: return 0 else: return array[0] + soma(array[1:]) def conta(array): if len(array) == 0: return 0 else: return 1 + conta(array[1:]) def maior(array): if len(array) == 2: return array[0] if array[0] > array[1] else array[1]...
b2961dbcfd0c81266f1ff45e66e27bd61deb87d8
AdamZhouSE/pythonHomework
/Code/CodeRecords/2732/60723/272851.py
139
3.6875
4
num=int(input()) for i in range(num): temp=input().split() A=int(temp[0]) B=int(temp[1]) C=int(temp[2]) print((A**B)%C)
81684f580271eeb483768bcce6d0a4be721e68c2
LeoAuyeung/Leo-assignments-12700
/05/cipher.py
1,191
3.84375
4
def encode_letter(c,r): #Low & Up alphabets to account for both lower and upper case letters alph_low='abcdefghijklmnopqrstuvwxyz' alph_up='ABCDEFGHIJKLMNOPQRSTUVWXYZ' #Lower Case: if c in alph_low: c_loc = alph_low.index(c) new_loc = c_loc + r #Only 26 letters in alphabet, s...
dfd1f733f503c204481f226cb48c2343313811f4
shreyakapadia10/PythonProjects
/Python Programs/file_reading.py
1,399
4.28125
4
""" r = Opens file in read mode = default mode w = Opens file in write mode x = Creates file if not exists a = Appends to file t = Opens file in text mode b = Opens file in binary mode + = Opens file in read and write mode """ # File reading and printing entire file using read print("# Fil...
31595b9759e11d1cd797bca1b0d5237b6b8232c6
Ecqonline/streamlit-example
/streamlit_app.py
2,076
3.734375
4
# IMPORTAR AS BIBLIOTECAS NECESSÁRIAS E O ALGORIMO K-NN import streamlit as st import pandas as pd import numpy as np from sklearn.neighbors import KNeighborsClassifier from sklearn.preprocessing import MinMaxScaler sc = MinMaxScaler() # CRIAR FUNÇÕES NECESSÁRIAS PARA CARREGAR DADOS E TREINAR MODELO. # Função para t...
26de4009fd3a4ac208ef9adb1e8577968c2064b4
yedaloc/proyecto-paradigmas
/Main.py
1,209
4
4
#! /usr/bin/python3 #Main.py import os from controller import Controller c = Controller() def menu(): """ Función que limpia la pantalla y muestra nuevamente el menu """ os.system('clear') print ("Sistema de Auditoria") print ("\t1 - Agregar empresa") print ("\t2 - Realizar Auditoria") print ("\t3 ...
a4d5231c5454746cd2db7531394d3e3071c5462c
manishcomp1/Python
/code/decorator.py
254
3.578125
4
def sample_decorator(addition): def wrapper(x, y): print x,y return addition(x, y) return wrapper @sample_decorator def addition1(x, y): result = x + y print "result",result return result x = 5 y = 10 result = addition1(x , y) print result
c06c6d4afe2ba57f18640eee73ea4bb0fc73fa6f
MartinPSE/E.T.C
/Codesignal/Hello_Python/bit_length.py
370
3.640625
4
n = 5 n.bit_length() # 이렇게 활용할 수도 있고 # bit 수에 맞게 print를 하고 싶으면? # 예를 들면 integer "5"을 0'b0101 네자리 표현을 하고 싶을 경우 BitLen = n.bit_length() # bit length를 구하고 bit length는 3 BitLen = 4 Form = '0' + '{0}'.format(BitLen) + 'b' # '04b' print("Binary Format : 0'b{0}".format(format(n, Form)))
219b6380c85dbffd5bcb0a52d35dac28beb1e60f
mucciz/News
/tests/news_test.py
1,043
3.765625
4
import unittest from app.models import News # News = news.News class NewsTest(unittest.TestCase): ''' Test Class to test the behaviour of the Movie class ''' def setUp(self): ''' Set up method that will run before every Test ''' self.new_news = News('abc-news','ABC NEWS...
f502ed2a1e7245e8eb8b06c9a022d82d19d85aba
robinyms78/My-Portfolio
/Exercises/Python/Learning Python_5th Edition/Chapter 5_Numeric Types/Examples/Other Numeric Types/Fractions/Example6/Example6/Example6.py
505
3.796875
4
from fractions import Fraction # Float object method print((2.5).as_integer_ratio()) # Convert float -> fraction: two args # Same as fraction (5,2) f = 2.5 z = Fraction(*f.as_integer_ratio()) print(z) # x from prior interaction x = Fraction(1,3) # 5/2 + 1/3 = 15/6 + 2/6 print(x + z) # Convert fraction -> float pr...
0629358a5f590905fad4baae5fb634af853ed89e
jiaqiyusun/Python
/1_3.py
1,541
3.9375
4
#String print(type("hi hello i am here!")) username = 'supercoder' password = 'supersecret' long_string =''' WPW = = ... ''' # long string with three single quotes print(long_string) first_name = "jiaqi" last_name = "Yu" full_name = first_name +' '+ last_name #space between last name and first name print(full_name...
fc3b8a2eee36062324c6f0bf7176a9425c69bf4e
sforrester23/SlitherIntoPython
/chapter7/Question3.py
930
4.15625
4
# Write a program that takes a string as input from the user. # The string will consist of digits and your program should print out the first repdigit. # A repdigit is a number where all digits in the number are the same. # Examples of repdigits are 22, 77, 2222, 99999, 444444 # Building upon the previous exercise, # ...
b658ee5282565a260e1587236095fce043b8d1c8
DPDominika/checkio
/elementary/Index Power.py
276
3.84375
4
# https://py.checkio.org/mission/index-power/ def index_power(array, n): """ Find Nth power of the element with index N. """ if n == 0: return 1 elif len(array)-1 < n: return -1 elif len(array)-1 >= n: return (array[n])**n
48fcb99bd4daccc3dc0299c91e1c22e405893d7b
zielman/Codeforces-solutions
/B/B 1331 Limericks.py
128
3.578125
4
# https://codeforces.com/problemset/problem/1331/B a = int(input()) d = 2 while a % d != 0: d += 1 print(f"{d}{a//d}")
aa97b0278459bb51b78691727f28b91e8f7b1fba
xhimanshuz/time-pass
/Python/Data_Structure/linear_search.py
1,004
4.125
4
#!/usr/bin/python3 # LINEAR SEARCH SIMPLE PROGRAM from sys import argv class LinearSearch: def __init__(self, size=None): self.size = size self.array = [] self.flag = 0 self.count = 0 def algo(self): for i in range(self.size): self.count+=1 ...
116c3e03ca403f1aa64d26ae9aea50d969d0b533
aakashmt97/My-Python-Games
/Guess Number.py
694
4.09375
4
import random guessTaken = 0 name = input("What is your Name: ") print("Well, " + name + " I'm thinking of a number between 1 to 20") number = random.randint(1, 20) for guessTaken in range(6): guess = int(input("Guess the number: ")) if guess < number: print("Your guess is too low") if guess...
9b59538392a8aa730eaf93ae9885b8bd5a56fd5a
feliciaamy/movie-trailer-website_1
/media.py
1,029
3.84375
4
import webbrowser class Movie(): """This class provides a way to store movie related information""" def __init__(self,title='',storyline='',poster='',youtube='',rating='',rank=''): self.title = title self.storyline = storyline self.poster_image_url = poster self.tr...
0bb6244e975f141bd095a7f542055f47711035c9
govindnayak/CODING
/ARRAYS/kth_largest_after_insertion.py
594
3.65625
4
#Given an input stream of n integers the task is to insert integers to stream and print #the kth largest element in the stream at each insertion #Use HEAP instead of an array window! import heapq t = int(input()) while(t): t-=1 k, n = map(int, input().split()) a = list(map(int, input().split())) s = [] for j...
5b7e1d1ca2403112eebbea50b1165def516a4c3a
diningphills/eulerproject
/problems/20~29/25/dy.py
397
3.78125
4
def digitCount(n): count = 1 while n >= 10: count += 1 n = n/10 return count def Fibonacci(F, i): if i==0 or i==1: return 0 else: newValue = F[i-2] + F[i-1] F.append(newValue) F = [1, 1] i=2 while True: Fibonacci(F, i) print(F[i], i) if digi...
62eb75f2ec5595c79abb0453e2c04b5fe0c06bb3
clprenz/de_sim
/de_sim/examples/random_walk.py
3,729
3.71875
4
""" A simulation of a random walk where a variable is incremented or decremented with equal probability at each event :Author: Arthur Goldberg <Arthur.Goldberg@mssm.edu> :Date: 2018-02-27 :Copyright: 2018-2020, Karr Lab :License: MIT """ import argparse import random import sys from de_sim.simulation_engine import Sim...
3d1412ba02b62065e248aa6dc1b3c95f586d5c67
tkremer72/Python-Masterclass
/PythonCodingExercises/11.Continue/without_continue.py
89
3.75
4
# Without continue for x in range(21): if x % 3 != 0 and x % 5 != 0: print(x)
6fe6b4201536b987eb7716d0e7d232f7f15f6bdb
VineethChandha/Cylinder
/Packing&Unpacking.py
743
4.53125
5
#PY.01.14 Introduction to packing and unpacking L=[1,2,3,4] P="abc" print(P) print(*P) print(L) print(1,2,3,4) print(*L) #* is used in unpacking the data def add(*numbers): #by using the * in parameter it acts as tuple and can take any number of arguments total=0 for number in numbers: ...
41ccf2f9e3694ddf5b6c1658f372aaf4c7a8e721
dilkas/project-euler
/096.py
2,200
3.640625
4
import copy def square_range(i): return range(i - i % 3, i - i % 3 + 3) def neighbours(I, J): return ([(I, j) for j in range(9)] + [(i, J) for i in range(9)] + [(i, j) for i in square_range(I) for j in square_range(J)]) def insert(grid, I, J, value): grid[I][J] = value for i, j in neighbo...
208692b5473d0f038818b135ac992aa17a5df64d
BiniyamMelaku2/alx-low_level_programming
/0x1C-makefiles/5-island_perimeter.py
446
3.53125
4
#!/usr/bin/python3 """ module for island grid perimeter """ def island_perimeter(grid): ''' defines island grid method ''' val = 0 for i in range(len(grid)): for j in range(len(grid[i])): if grid[i][j] == 1: val += 2 if i > 0 and grid[i - 1][j] == 1: ...
ffc2cb368a442864a7a5e2b2c0b81fccbe8417bb
bvshyam/CUNY-repository
/602 - Python/Assignment 8 - Image Processing/practice/lessons/matplotlib/examples/plot_bar_ex.py
718
4
4
""" Bar plots ========== An example of bar plots with matplotlib. """ import numpy as np import matplotlib.pyplot as plt n = 12 X = np.arange(n) Y1 = (1 - X / float(n)) * np.random.uniform(0.5, 1.0, n) Y2 = (1 - X / float(n)) * np.random.uniform(0.5, 1.0, n) fig = plt.figure() ax = fig.add_axes([0.025, 0.025, 0.95,...
624a83a4fa1395d933e21974247bb7778e105cac
joaocassianox7x/Apostila
/codigos/kuttaprimeiraordemedo.py
721
3.53125
4
y0=5 #valor inicial t0=0 #ponto inicial tf=10 #ponto final n=10**5 #numero de pontos dt=(tf-t0)/n y=[] y.append(y0) def func(a,b): #a=y e b=t return(-a+b) for i in range(n): t=i*dt #t #print(t) k1=func(y[i],t) k2=func(y[i]+k1*dt/2,t) k3=func(y[i]+k2*dt/2,t+dt/2) k4=f...
57fbd548bb3517b2ca7002a7b96c0fc13a4d7b0e
DaHuO/Supergraph
/codes/CodeJamCrawler/16_0_2/ParticleMan/b.py
702
3.671875
4
#!/usr/bin/env python def printResult(case, result): print "Case #{}: {}".format(case, result) def flip(s, num): return ''.join([other(x) for x in s[:num][::-1]]) + s[num:] def other(c): if c == '+': return '-' else: return '+' t = int(raw_input()) for i in xrange(1, t + 1): stat...
3db31c0fbad45f2d9132722d1189a156a8e506ad
viirii/CAS_project
/dp/merger.py
875
3.578125
4
import csv # created by Christine Baek # November 26, 2016 # merge 2 .csv files into single .csv in criss-cross format semiglo = [] local = [] def readCSV(filename, destination) : print(filename) with open(filename, 'r') as csvfile : filereader = csv.reader(csvfile, delimiter=' ', quotechar='|') for row...
1b8c2a49b2f7968bf806ea5e18e57569af18327c
Etoakor/wuxing
/RedFlag.py
1,578
3.828125
4
import turtle import time turtle.setup(width=0.9, height=0.9) # width, height,输入宽和高为整数时, 表示像素; 为小数时, 表示占据电脑屏幕的比例 turtle.bgcolor("red") # 画布背景颜色 turtle.fillcolor("yellow") # 绘制图形的填充颜色 turtle.color('yellow') # 绘制图形颜色 turtle.speed(10) # 绘制图形的速度 # 主星 turtle.begin_fill()# 准备开始填充图形 t...
9b76298a0ee4ab2282a72232c8f12fc3fede1c9a
yesseli/Proyecto
/Buscaminas.py
13,546
3.734375
4
import tkinter, configparser, random, os, tkinter.messagebox, tkinter.simpledialog #Importamos una la libreria de tkinter, analizador de configuracion, generador de variables random, un modulo os, un modulo caja de mensajes de Tkinter y un modulo de dialogos simples window = tkinter.Tk() #agregamos a la variable Wi...
18568cf39642a69a3335d4aaaacb0cc9163beaf4
buaazyz/battery_detect
/preprocessing/Preprocessing.py
524
3.6875
4
import cv2 #统一输入尺寸 def Resize_Input(img,size = (1040,2000,3)): """ 输入: 待转换的图片img,目标尺寸size,默认为1040*2000*3 输出:转换好后的图片img_new """ if img.shape<=size: img_new = cv2.copyMakeBorder(img,0,size[0]-img.shape[0],0,size[1]-img.shape[1],cv2.BORDER_CONSTANT,value=[255,255,255]) else: img...
e9625d0791619322549c19bdfeb60a849eec1ea9
bhavya20051/codacademy_course_part2
/codacademy_2/python loops/games loop.py
351
3.65625
4
# -*- coding: utf-8 -*- """ Created on Sun Apr 12 17:30:33 2020 @author: bhavy """ board_games = ['Settlers of Catan', 'Carcassone', 'Power Grid', 'Agricola', 'Scrabble'] sport_games = ['football', 'football - American', 'hockey', 'baseball', 'cricket'] for game in board_games: print(game) for game...
b578ce2b8dbd0673d336d3e16e3eb5518b3a6090
Hacker5preme/pwlist-algorithm
/code/user_inputs.py
2,573
3.6875
4
# Version 0.3 def pw_len_limit(): length_limit = input("PLEASE ENTER THE MAXIMUM LENGTH FOR THE PASSWORDS GETTING GENERATED | FOR NO LIMIT ENTER 0: ") return length_limit def user_inp_information(): print("*** INFORMATION SPIDER FOR GENERATING THE PASSWORD-LIST ***") print("*** ENTER DATES IN THIS FOR...
d7393b4ac08c0bfe6ad9205d488adb67501ef128
iandavidson/SSUCS115
/Lab11/Lab11c.py
4,401
3.78125
4
""" Program: CS 115 Lab 11c Author: Ian Davidson Description: This program will open a file and then search its contents using linear and binary search. """ def readfile(filename): """ Reads the entire contents of a file into a single string using the read() method. Parameter: the name of...
868a678621c004fbb01670290e32c3c4b2b2fef8
kesappagarimohan/python-practice
/factorial.py
126
3.546875
4
def fact(number): result=1 for i in range(1,number+1): result=result*i return result print(fact(5))
2d4633eb90ffab4efdaa84a8490944ca843e7b45
michal-franc/CodingKatas
/interview-cake/product-of-other-numbers.py
572
4
4
def product_of_other_numbers(list_of_ints): product_values = [0] * len(list_of_ints) # calculate product for before i product_so_far = 1 for i, integer in enumerate(list_of_ints): product_values[i] = product_so_far product_so_far *= integer product_so_far = 1 # calculate produ...
aaad245345f605b320981baf74fac7c16f181770
bassemhussein-code/4--Programming-Foundations-Algorithms
/sexth.py
2,206
3.8125
4
import sys A = [-10, -3, 5, 6] # def findMaximumProduct(A): # max_i, max_j = 0, 0 # max_product = -sys.maxsize # for i in range(len(A)-1): # for j in range(i+1, len(A)): # if max_product < A[i] * A[j]: # max_product = A[i]*A[j] # (max_...
0f1c366219a8a9ea6ac41db86b74e795ff37c473
abhishm/cs61a
/set_using_linked_list.py
4,384
3.796875
4
class Link(object): empty = () def __init__(self, first, rest=empty): self.first = first self.rest = rest def __repr__(self): if self.rest: return "Link({0}, {1})".format(self.first, repr(self.rest)) else: return "Link({0})".format(self.first) d...
17273c0faa852864473992b92ac49c8ffacb1d30
pedrom505/AlbionAnalytics
/Errors.py
1,156
3.546875
4
import logging class ApplicationError(Exception): """ Generic exception class used by every exceptions implemented """ def __init__(self, *args): self.logger = logging.getLogger(__name__) if args: self.message = args[0] else: self.message = None def...
06f183868101c135652436fc4686c3a82c4de01c
Boot-Camp-Coding-Test/Programmers
/day12/problem4/[노태윤](재도전 성공!)문자열 내 마음대로 정렬하기.py
2,252
3.546875
4
# 테스트 5~7 / 11~12 실패 def sorting(sorted_list,starting_index,ending_index) : sorted_list[starting_index:ending_index+1] = sorted(sorted_list[starting_index:ending_index+1]) return sorted_list def solution(strings, n): answer = [] sorted_list = sorted(strings,key=lambda x : x[n]) starting_index = 0 ...
032dfecb448992d92146a9878a72c0e822ff4c84
Bytamine/ff-olymp
/14 primality test/4.py
306
4.03125
4
#!/usr/bin/env python3 def isPrime(n: int) -> bool: d = 2 while d * d <= n and n % d != 0: d += 1 return d * d > n k = int(input()) if k == 1: print(2) else: count = 1 i = 1 while count != k: i += 2 if isPrime(i): count += 1 print(i)
86fd8bd90a7461362881a18fa1ae7eb8120e8d12
pedrogomez2019upb/Taller_PracticaProgramacion
/44.py
496
3.921875
4
#Escribe un algoritmo que, dados dos números, verifique si ambos están entre 0 y 5 o retorne false sino es cierto. Por ejemplo 1 y 2 ---> true ; 1 y 8 ---> false #Primero hay que recibir los valores a analizar a=int(input("Bienvenido! Por favor ingresa el primer número: ")) b=int(input("Por favor ingresa el segundo val...
eb2685d163ef8c8bb59e93063cac5c77a4d55625
minorl/hackcu
/mlprototype/coroutinetest.py
339
3.515625
4
def coroutine(func): def start(*args, **kwargs): cr = func(*args, **kwargs) cr.next() return cr return start @coroutine def f(): i = 0 yield None while True: print "Iterating" yield i print "In between" j = (yield) print "Got: " + str(...
42554afaeffd721b8407f102ddf02644db051259
gdh756462786/Leetcode_by_python
/BinaryTree/Arranging Coins.py
1,092
4.09375
4
# coding: utf-8 ''' You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. Given n, find the total number of full staircase rows that can be formed. n is a non-negative integer and fits within the range of a 32-bit signed integer. Example 1: n = 5 The coi...
eaeda89fb3847229fc49a71c4f554a83def50c12
carlos-echeverria/RobotTuples
/generateGroupsSwap.py
2,443
4.15625
4
#!/usr/bin/env python3 # Script that generates 2 groups, each consisting of 24 robot 3-tuples. # The first group is generated by populating it with random elements from the # list of all possible combinations of 18 robots in 3-tuples. The second set is # generated by choosing two random tuples from the first set and s...
b04d75103e187087eee02b2bc897d741ac5fea9d
wolfecameron/structural_RNN
/vis_structs.py
5,205
4.28125
4
"""Creates visualizations of structures created by the circle RNN using matplotlib""" import numpy as np import matplotlib matplotlib.use("TkAgg") import matplotlib.pyplot as plt def vis_spring(all_pts): """takes in a list of tuples containing r and theta values and creates a polar plot of these coordinates with ...
074e633c2b8d07b14286880121d723cd871f434b
JGproyectos/Laboratorios-de-Algoritmos-2
/Algoritmos II/ProyectoII.py
11,071
3.5625
4
""" Nombres: Gaspar Hermán Sandoval, Jesús Marcano carnets:13-10637, 12-10359 Descripción: Proyecto II paja El misterio del robo de DACE """ # Importando algunos modulos import sys import random # Definiendo algunas funciones def borrar_espacios(x): # Funcion que carga una lista en un arreglo y quita el "\n" y =...
d4f94c7d783e5efb3a25f695e6e218b5e79d8285
jianghaoyuan2007/algorithm
/Week_03/id_38/LeetCode_429_38.py
499
3.65625
4
from collections import deque class Solution: def levelOrder(self, root): result = [] if not root: return result queue = deque() queue.append(root) while queue: items = [] for _ in range(len(queue)): node = queue.popleft()...
c220881e3b25f203c94ddbd47842f951b4db3669
RinuElisabath/Competitive-programming-
/basics/nonRepeatingCharacters.py
133
4.21875
4
#find non repeating characters in a string str1=input("enter string:") for i in str1: if str1.count(i)==1: print(i)
1774c4b5e15bbbace71f9f65690cdf8578f41f91
vvalotto/Patrones_Disenio_Python
/patrones_gof/Strategy/graznido.py
405
3.65625
4
from abc import ABCMeta, abstractmethod class Graznido(metaclass=ABCMeta): @abstractmethod def graznar(self): pass class GraznidoSilencioso(Graznido): def graznar(self): print('<< Silencio >>') class GraznidoFuerte(Graznido): def graznar(self): print("Graznido Fuerte") ...
c709f087f021f3ae2034bd1a55a791eb9e83772f
tuhiniris/Python-ShortCodes-Applications
/list/Remove the Duplicate Items from a List.py
909
4.40625
4
""" Problem Description The program takes a lists and removes the duplicate items from the list. Problem Solution 1. Take the number of elements in the list and store it in a variable. 2. Accept the values into the list using a for loop and insert them into the list. 3. Use a for loop to traverse through the el...
da6b7e88da8fcb5b4efb999bb42e64b4b790cfe8
Gramotei-vlad/Task
/Without_LSP.py
961
4.125
4
class Rectangle: def __init__(self): self.width = 0 self.height = 0 def setWidth(self, width): self.width = width def setHeight(self, height): self.height = height def perimeter(self): return (self.width + self.height) * 2 def area(self): return se...
d3c868c77af1d1d280f4faede570901799f08518
fanzijian/leet-code-practice
/src/code/code_m_0107.py
638
3.875
4
#!/usr/bin/env python #-*- coding: utf-8 -*- """ 题目链接:https://leetcode-cn.com/problems/rotate-matrix-lcci/ Authors: fanzijian Date: 2020-04-06 11:23:56 """ class Solution(object): def rotate(self, matrix): """ :type matrix: List[List[int]] :rtype: None Do not return anything, modify mat...
6caba9bea554aada682c536b2528dd6b0720b41b
Raj-kar/PyRaj-codes
/dobble_game.py
1,022
4.03125
4
from random import choice, shuffle words = ['goon', 'loser', 'criminal', 'carbon', 'collection', 'helpless', 'crisis', 'adventure', 'bloodsport', 'mouse'] def get_random_word(): # choose a random word from list of words rand_word = choice(words) # remove the word, for stop repetation word...
c714bf4fb145df2c8e37c646104cfd09d8dbbe91
liuya2360/H2-Computing
/Python/Pop quizes/Pop quiz 3/bonus2.py
824
3.59375
4
def get_dist(x1,y1,x2,y2): dist = ((x1-x2)**2+(y1-y2)**2)**0.5 return dist def check_rectangle(a): n = len(a)#number of points cnt_rec = 0 for i in range(len(a)-3): for j in range(i+1, len(a)-2): for k in range(j+1, len(a)-1): for l in range(k+1, len(a)): dis_i_j = get_dist(a[i][0],a[i][1],a[j][0],...
66a2eee8a2bfeada035f14a73660c5193399b2e5
teuntjepeeters/Voorbeeldcode_OWE1a_1920
/exception_handling_valueerror.py
399
3.609375
4
def invoer(): """Voer uw leeftijd in Return: getal - str, leeftijd """ getal = input("Voer uw leeftijd in (jaren): ") return getal def main(): try: jaren = int(invoer()) print("U bent "+ str(jaren) + " jaren oud") print("Dat is "+ str(jaren*12) + " maanden") ex...