blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
30452fd31391b67d154772145b87f9c6d88bd903
ryachen01/Python-UTXO-Implementation
/UTXOs.py
3,417
3.5
4
import random import time from datetime import datetime from datetime import timezone class TransactionOutput: def __init__(self): self.year = random.choice(range(2008, 2017)) self.month = random.choice(range(1, 13)) self.day = random.choice(range(1, 29)) self.date = datetime(...
43b3688ac418b5a2b7633405de753f7821067886
apiwatc/snake-game
/snake.py
1,629
3.546875
4
from config import Config import random class Snake(): UP = 'up' DOWN = 'down' LEFT = 'left' RIGHT = 'right' HEAD = 0 def __init__(self): self.x = random.randint(5, Config.CELLWIDTH - 6) self.y = random.randint(5, Config.CELLHEIGHT - 6) self.direction = self.RIGHT ...
47f1e4b0aa4bfc1a112b563e456c17a5588e8a42
nkini/CMP203-HW4
/hw4.py
16,689
3.6875
4
#!/usr/bin/python # TEAM: # Sneha Das (sndas@ucsc.edu) # Ankit Gupta (agupta29@ucsc.edu) # Nikhil Kini (nkini@ucsc.edu) ################################ SCANNER ################################ import re import collections from pprint import pprint import math import sys import fileinput # We used regular expressi...
637ef4c37f661f540aba5cf8097683d8a0306da8
sandeep-india/Euler
/problem2.py
572
3.796875
4
''' Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. '...
0b0e62242db3343bc6578ffcc23e3b6ada4d0fe0
sandeep-india/Euler
/problem23.py
703
3.5625
4
import time start = time.time() upper = 28123 abundant_list = [] abundant_sums = [] for i in range(0,upper+1): sum = 0 for j in range(1,i): if i%j == 0: sum += j if sum > i: print i abundant_list.append(i) length = len(abundant_list) print "list lenghth is %s" %str(length) for i in range(0,length): ...
8fa0e1de7b43beb8ed307b6d2282d924d24a9340
sandeep-india/Euler
/problem4.py
348
4.09375
4
#A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is Find the largest palindrome made from the product of two 3-digit numbers. large = 0 for i in range(100,1000): for j in range(100,1000): num = i*j if str(num) == str(num)[::-1]: if num > large: ...
67cfe3706b8259965feb08098a4a086b34fdf830
Deepti3006/InterviewPractise
/Amazon Interview/leadersOfArray.py
270
3.546875
4
def leaderOfArray(arr): for i in range(len(arr)): for y in range(i+1,len(arr)): if arr[i] <= arr[y]: break if y == len(arr) - 1: # If loop didn't break print(arr[i],) arr = [16,17,4,3,5,2] leaderOfArray(arr)
02f58d42e0a6a35d801437b17f744f82bc80c441
Deepti3006/InterviewPractise
/Amazon Interview/nonRepeatingString.py
280
4.09375
4
def nonRepeatingCharacter(): string1 = input("Enter the string :") string1 = string1.lower() count =0 for i in string1: index = string1.count(i) while count < 1 and index==1: print(i) count = count+1 nonRepeatingCharacter()
cd2de2e8c61007f5a54508ecc3e058987f9e42db
Deepti3006/InterviewPractise
/Amazon Interview/breadthFirstSearch.py
471
3.671875
4
graph = { 'A' : ['B','C'], 'B' : ['D', 'E'], 'C' : ['F'], 'D' : [], 'E' : ['F'], 'F' : [] } visited =[] queue =[] def breathFirstSearch(visited,graph,node): visited.append(node) queue.append(node) while queue: s= queue.pop(0) print(s) for neigbhour in graph[s]: ...
0c561a04138befdec92cb954bc0b16a76a722da4
Deepti3006/InterviewPractise
/Amazon Interview/numberOftriplets.py
335
3.6875
4
def numberOfTriplets(arr): count =0 for i in range(len(arr)): for y in range(i+1,len(arr)): if arr[i]+arr[y] in arr: count=count+1 print(arr[i],arr[y]) if count==0: return -1 else: return count arr =[1,5,3,2] count =numberOfTriplets(ar...
810f440938826199e3ff0633967a4f84c40f97cc
Deepti3006/InterviewPractise
/Amazon Interview/commonPrefix.py
554
3.953125
4
def commonPrefix(arr): s1= set(arr[0]) s2 = set(arr[2]) s3 = set(arr[1]) string1 ="" for i in range(len(arr)): for y in range(len(arr)): for z in range(len(arr)): if arr[i][i] == arr[y][i] == arr[z][i]: if arr[i][i] not in string1: ...
2fe9b5dcdcc7ea40b26b0aab6159127cd3033126
Deepti3006/InterviewPractise
/Amazon Interview/permutationsOfWords.py
289
3.8125
4
import itertools def permutationOfWords(word): char_p =[] char_sequences = itertools.permutations(word) for char in char_sequences: print(char) #string_permutation = "".join(char) char_p.append(char) print(len(char_p)) permutationOfWords("ABSG")
d64e446e9730ed833bb0dfd669d3c6aba98e6653
Deepti3006/InterviewPractise
/Amazon Interview/OccuranceOfElementInArray.py
370
4.15625
4
def numberOfOccurancesOfNumberinArray(): n = int(input("Enter number of Elements")) arr =[] for i in range(n): elem = input("enter the array number") arr.append(elem) print(arr) find_element = input("Enter the element to be found") Occurances = arr.count(find_element) print...
67402040119e4f6c6ea21cef2e8ce60c8f1741a2
Deepti3006/InterviewPractise
/PythonDatatimeFunctions/convertDatePattern.py
175
3.578125
4
import datetime def convertDatePattern(): date_object = datetime.datetime.strptime("Jan 1 2014 2:43PM",'%b %d %Y %I:%M%p') print(date_object) convertDatePattern()
d136f79d21971d0f612d295c1123296dc171264d
Deepti3006/InterviewPractise
/vowelsConsonants.py
477
4.0625
4
def findVowelsConsonants(): string1 = input("Enter the String ") vowels =[] consonants =[] for char in string1: if ((char == 'a') or (char == 'e') or (char == 'i') or (char == 'o')): print("I am vowel") vowels.append(char) else: print("I am consonant"...
c2a2a10233ef2b23828553ff1278cf033e85b0e1
Deepti3006/InterviewPractise
/Amazon Interview/reverseSentenceWithoutReversningWords.py
514
3.734375
4
def reverseSentenceWithoutReversingWord(string1): length =0 string2 ="" arr =[] for i in string1.split("."): length = length+1 arr.append(i) print(length) print(arr) length = length-1 while length >= 0: if length == 0: string2 = string2+arr[len...
99239e6322308f63b013a6252d0d749f5ec49f8b
Deepti3006/InterviewPractise
/Amazon Interview/countNumberOfWordsInFile.py
238
3.90625
4
def countNumberOfWordsInFile(): count=0 with open("1.txt","r") as f: for line in f: words = line.split() for word in words: count=count+1 print(count) countNumberOfWordsInFile()
719743bcdf5bd24f43a21268a6106e9dbdb559f4
Deepti3006/InterviewPractise
/sumOfDigits.py
397
3.6875
4
class sumOfDigits(): def digitSum(self): number = int(input("Enter the number :")) total = 0 while number > 0: dig = number%10 print(str(dig)) total = total + dig number = number//10 print("I am in //" + str(number)) p...
35830d4181f89ff617ae31fabfc1f29a3a668896
Deepti3006/InterviewPractise
/Amazon Interview/012sort.py
218
3.71875
4
def sort_012(arr): low =0 mid = 1 for i in range(len(arr)): if arr[i+1] == "0": arr[i+1],arr[i] = arr[i],arr[i+1] print(arr) arr =[0, 1, 1, 0, 1, 2, 1, 2, 0, 0, 0, 1] sort_012(arr)
61928206b44b7dd71118c29dfde1761e5bab4fde
konsta78/PY111-git
/Tasks/b0_linear_search.py
543
4.0625
4
""" This module implements some functions based on linear search algo """ from typing import Sequence arr_ = [] def min_search(arr: Sequence) -> int: """ Function that find minimal element in array :param arr: Array containing numbers :return: index of first occurrence of minimal element in array ...
79cf8b12856a72c72e5771ecf0ebe22025562f01
konsta78/PY111-git
/Tasks/a1_my_queue.py
1,089
4.0625
4
""" My little Queue """ from typing import Any queue = [] def enqueue(elem: Any) -> None: """ Operation that add element to the end of the queue :param elem: element to be added :return: Nothing """ global queue queue.append(elem) print(elem) return None def dequeue() -> Any: ...
0ddde4d456273d50981419f5cd09d082d600a970
Prim90/iShere
/Zad_4.py
259
3.796875
4
print ("Podaj dowolną czterocyfrową licznę.") od = "Liczba: " l = input(od) print("Pierwsza cyfra to", l[0], "ostatnia cyfra to", l[3]) #W tym zadnaniu miałem problem z wskazaniem indeksu ostatniej cyfry bez określenia z góy liczby cyfr w liczbie.
8a5a89454826deacfdaa4b03c2ad455b2353148d
joaofilis/Banco_Gringotes-
/Banco gringotes comeback !/consultar_saldo.py
238
3.5625
4
def consul_sal (): senha_cad = 1234 saldo = 1000 senha = int(input('Digite sua senha: ')) if senha == senha_cad: print('Seu saldo atual é R${:.2f}'.format(saldo)) else: print('Senha incorreta!')
38d31ccbf0766d583be6e84e3638b9f1d0180c5f
YashBohra-07/Python-practice-problems
/PASCAL TRIANGLE.py
429
3.609375
4
def pascal(n): l=[1] print(' '*(n-1),1) for i in range(n-1): nl=[] nl.append(l[0]) for j in range(len(l)-1): nl.append(l[j]+l[j+1]) nl.append(l[-1]) l=nl print(' '*(n-i-1),end='') for k in range(len(l)): print(l[k],end=...
1b9ffc2e886a8d489857d7db9c6f1b8139328d61
HenriqueSoares28/Python-EX
/ex115/pacote/arquivo/__init__.py
1,414
3.859375
4
def leiaInt(texto): while True: try: i = int(input(texto)) except: print('\033[0;31mERRO: por favor, digite um número inteiro válido.\033[m') else: return i def mostrar(nome): try: a = open(nome,'r') except: print('Erro ao encon...
abc2ff1057ef0b879c34550d9acc39fbdeae68ca
HenriqueSoares28/Python-EX
/ex022.py
336
3.953125
4
nome = str(input("Escreva seu nome completo: ")) print('Nome em maiusculo: ',(nome.upper())) print('Nome em minusculo: ',(nome.lower())) num = (len(nome)) esp = (nome.count(' ')) letras = (num-esp) print ('Quantidade de letras: ',(letras)) nome1 = (nome.split()[0]) num1 = (len(nome1)) print ('Quantidade de letras do 1°...
a15a25535a1f53888de3583dccc2277f4b787620
HenriqueSoares28/Python-EX
/ex085.py
364
3.78125
4
números = [[], []] for c in range(0,7): valor = int(input(f'Digite o {c+1}° valor: ')) if valor % 2 == 0: números[0].append(valor) else: números[1].append(valor) print('='*60) números[0].sort() números[1].sort() print(f'Os valores pares digitados foram: {números[0]}') print(f'Os valores ímpa...
5e6237e8dd820d8c9884af35b07b2f2bfac4a463
HenriqueSoares28/Python-EX
/ex104.py
333
3.953125
4
def leiaInt(num): while True: resp = str(input(f'{num}')).strip() if resp.isnumeric(): resp = int(resp) return resp else: print('ERROR! Digite um número valido') #main n = leiaInt('Digite um número: ') print(f'Você acabou de digitar o núm...
ad4273b2eeaa6f681f954a71474046390c217c01
HenriqueSoares28/Python-EX
/ex052.py
343
3.8125
4
num = int((input('Digite um número: '))) tot = 0 for c in range(1, num +1): if num % c == 0: print('\033[34m', end='') tot += 1 else: print('\033[m', end='') print(f'{c} ', end='') print('\033[m') if tot == 2: print('O número escolhido é primo!') else: print('O número escolhi...
b0d31143da6936ed8e3cc90adcf46160bec3c3b1
HenriqueSoares28/Python-EX
/ex032.py
315
3.84375
4
from datetime import date ano = int(input('Me diga um ano qualquer (coloque 0 para analizar o ano atual): ')) if ano == 0: ano = date.today().year if (ano % 4) == 0 and ano % 100 != 0 or ano %400 == 0: print('O ano escolhido é um ano Bissexto!') else: print('O ano escolhido não é um ano Bissexto!')
481954bb8d8c0269354dab7c68cedc78b6ddcc54
HenriqueSoares28/Python-EX
/ex012.py
189
3.546875
4
p = float(input('Qual é o preço do produto? R$')) porcentagem = p*5/100 print('O produto que custava R${}, na promoção com desconto de 5% vai custar R${:.2f}'.format(p,(p-porcentagem)))
52ba5b88ba82c4d97e9bd7c7473c67a39adbd120
HenriqueSoares28/Python-EX
/ex016.py
223
3.96875
4
import math n = float(input('Digite um número: ')) #print('O valor digitado foi {} e a sua porção inteira é {:.0f}'. format(n,n)) print('O valor digitado foi {} e a sua porção inteira é {}'. format(n, math.trunc(n)))
8be2a3cae3b4d67e6a6d211c1cee094e7a309a27
HenriqueSoares28/Python-EX
/ex039.py
423
4.0625
4
ano = int(input('Ano do nascimento: ')) idade = 2021 - ano print ('Quem nasceu em {} tem {} em 2021.'.format(ano, idade)) if idade < 18: print('Ainda faltam {} anos para seu alistamento'. format(18 - idade)) elif idade == 18: print('Você tem que se alista IMEDIATAMENTE!') else: print('Você já deveria ter se...
5b8f1528e384d5998d2d7b0d2eb554a1c91d1035
HenriqueSoares28/Python-EX
/ex084.py
792
3.578125
4
galera = [] dados = [] peso = [] pesomais = pesomenos = 0 # Recebendo dados while True: dados.append(str(input('Nome: '))) dados.append(float(input('Peso: '))) galera.append(dados[:]) peso.append(dados[1]) dados.clear() cont = str(input('Quer continuar? [S/N] ')) if cont in 'Nn': br...
32134e29858c78228f57b3dbcecdfd5c23abece0
myles-obrigewitsch/RPG-Game---Myles
/losing_screen.py
920
3.796875
4
# Import statements import player_name import sys import os # Function found from internet, used to restart program def restart_program(): """Restarts the current program. Note: this function does not return. Any cleanup action (like saving data) must be done before calling this function.""" python ...
a879e81154ee95ecfee58feee07a64152331b2ff
ROM1NABLOOM/GPA_Calculator
/file.py
2,134
3.953125
4
""" Title: File class for Final Project Author: Landon Dahl Objective: Take in a file with number grades ex: 90% and find the average ******** Different methods needed - importFile method (takes in the file and reads it) - stripFile method (takes the contents of the file, stips it to a list, and create...
3d41c842f524e1228e8d2edbe75106e02e5a0096
zoro666/Travelling_Santa_2018
/output.py
832
3.515625
4
# Laod all the libraries from argparse import ArgumentParser def read(path, filename): # read file with open(path + filename, 'r') as f: score = [line.rstrip('\n') for line in f] print(score) if __name__ == "__main__": # Read the filepath for csv files from command line parser = Argum...
2eb7016701c2f1b1d6368a1ba08994e89930be57
Jenell-M-Hogg/Codility-Lesson-Solutions
/Lesson1-FrogJmp.py
1,296
4.125
4
'''A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. The small frog always jumps a fixed distance, D. Count the minimal number of jumps that the small frog must perform to reach its target. Write a function: d...
81cdf81b4b462db885696e5047394400deae812d
amjedsaleel/Python-for-Everybody
/python Data Structures/week 3/workout2.py
322
3.875
4
file_name = input('Enter file name: ') if file_name.endswith('.txt'): pass else: file_name = file_name + '.txt' try: files = open(file_name) except: print('File not exists, Please try agin!!!') quit() count = 0 for line in files: line = line.rstrip() count += 1 print('Total lines:', count...
3c6ce9ee2b86831e931c370375e24883d0ab5fc2
amjedsaleel/Python-for-Everybody
/Getting started with python/ass_3.1/ass_3.1.py
250
3.8125
4
hrs = input("Enter Hours:") h = float(hrs) srate = input("Enter rate") rate = float(srate) if h > 40 : normal_pay = h * rate over_time = (h - 40.0) * (rate * 0.5) pay = normal_pay + over_time else: pay = h * rate print('Pay:', pay)
ce8b862cff7ab87ec4d3117194d5df8fc98c39fc
amjedsaleel/Python-for-Everybody
/Using Python to Access Web Data/week 2/Assignment/assignment.py
279
3.6875
4
import re file = open('actual_regex_sum.txt') sum = 0 words = 0 for line in file: line = line.rstrip() numbers = re.findall('[0-9]+', line) if len(numbers) > 0: for number in numbers: words += 1 sum += int(number) print(words, sum)
87357087658b638958befe9ba5971586a2a5d1a9
LarissaMerida/projeto-and-analise-of-algorithms
/codes/divide_conquer/10611.py
970
3.71875
4
def binary_search(vector, size, element): start, end, end1, start1 = 0, size, 0, 0 while( start < end): center = (start+end)//2 if( element > vector[center]): start1 = start start = center+1 else: end1= end end = center #print(end, start, end1, start1) return start-1, end ta...
8e14d143c6f7ce9729b383b929f17d759764aa92
LarissaMerida/projeto-and-analise-of-algorithms
/codes/divide_conquer/bread_meter.py
1,717
3.609375
4
def quickSort(vector): left, right, pivot_list = [], [], [] if(len(vector) <= 1): return vector else: pivot = vector[0] for i in vector: if( i < pivot): left.append(i) elif(i > pivot): right.append(i) else: pivot_list.append(i) right = quickSort(right) left = quickSort(left) return...
308e0f01bb65085d980789b52a1f0fe66d0d265d
LarissaMerida/projeto-and-analise-of-algorithms
/codes/divide_conquer/where_marble.py
954
3.640625
4
from math import * def quickSort(vector): left, right, pivot_list = [], [], [] if(len(vector) <= 1): return vector else: pivot = vector[0] for i in vector: if( i < pivot): left.append(i) elif(i > pivot): right.append(i) else: pivot_list.append(i) right = quickSort(right) left = quic...
7010883be08971a456e25898fdb6057be109a812
molinaangeldavid/pythonexercises
/ejercicio_poema.py
2,841
4.0625
4
# Se pide hacer un programa que abra un archivo de texto llamado entrada.txt el mismo contiene el siguiente poema de Ruben Dario # y permita al usuario poder buscar palabras. Si las mismas se encuentran deberá: # a- indicar cuántas veces aparece y en qué línea del poema está. # b- copiar la línea a un archivo llamado s...
4c5ca074108fd315c6a409b015c88ceacc708cef
JennSosa-lpsr/class-samples
/calculateDonuts.py
312
3.671875
4
import sys donuts = 40 donuts_str = str(donuts) people = 11 people_str = str(people) print( "Our party has : " + people_str + " people and " + donuts_str + " donuts" ) amount = (donuts / people) donutsAndpeople = str(amount) print( "Each person at the party gets : " + donutsAndpeople + " donuts" )
1906feea42bd77dbe4f1e15cff5dced824468e32
JennSosa-lpsr/class-samples
/inputTester.py
411
3.5
4
print("What is your name?") name = raw_input() print("Hi, " + name) print("What is your favorite color?") color = raw_input() print("Cool me two, what do you wanna talk about?") talk = raw_input() print("That's nice lol") lol = raw_input() print("It's nice otside huh") huh = raw_input() print("harry potter is the...
74b87ea175e4c7ef7ac9802e865783101a87097d
JennSosa-lpsr/class-samples
/4-2WritingFiles/writeList.py
405
4.125
4
# open a file for writing # r is for reading # r + is for reading and writing(existing file) # w is writing (be careful! starts writing from the beginning.) # a is append - is for writing *from the end* myFile = open("numlist.txt", "w") # creat a list to write to my file nums = range(1, 501) # write each item to the ...
715cfb565d350b68bf0d20367cedcde62562e66c
JennSosa-lpsr/class-samples
/remotecontrol.py
1,080
4.40625
4
import turtle from Tkinter import * # create the root Tkinter window and a Frame to go in it root = Tk() frame = Frame(root) # create our turtle shawn = turtle.Turtle() myTurtle = turtle.Turtle() def triangle(myTurtle): sidecount = 0 while sidecount < 3: myTurtle.forward(100) myTurtle.right(120) ...
0490f36d918cea79ecd78e8a98a5d84485e0b0db
akichim21/python-machine-learning
/numpy/numpy-100/12.py
202
3.828125
4
# Create a 10x10 array with random values and find the minimum and maximum values (★☆☆) import numpy as np Z = np.random.random((10, 10)) Zmin, Zmax = Z.min(), Z.max() print(Z) print(Zmin, Zmax)
1f77b14f65c72538acf8a2da8ef3ead96baf3877
akichim21/python-machine-learning
/numpy/numpy-100/49.py
280
3.703125
4
# How to accumulate elements of a vector (X) to an array (F) based on an index list (I) ? (★★★) import numpy as np X = [1, 2, 3, 4, 5, 6] I = [1, 3, 9, 3, 4, 1] # Iの数値をindexとし、Xの値を足しあわせてそのindexに入れる F = np.bincount(I, X) print(F)
98523282f0176c6c507d9a1ca839f43611f262ba
grygko/data2mplib
/print4apdl.py
5,277
3.53125
4
# Author: Grygoriy Kravchenko # Date: 2013-01-24 """Produce text output for generating ANSYS APDL scripts """ import sys import time import numpy as np def gen_preamble(author = 'GK', gen_time=time.ctime()): """Generate preamble with author's name and time The <!> sign is necessary to comment out a line""" ...
f521107c8c1210ce01fa7e57d7f17d030dc675b1
JakeRezac/3D_Scanner
/triangulation/delaunay.py
8,611
3.875
4
import math import delaunay_lib import os import sys #3D_points are described as a thruple to form a 3D coordinate # (x, y, z) # x, y, and z are all floats that descirbe the points projection onto # that respective axis #triangle are described as a thruple of verticies # (v1,v2,v3) # verticies are integers th...
b1f500fa494c159baf08dd250cec26d9900ad13e
hans/mt-project
/code/translator/better/gramm_expand.py
3,410
3.71875
4
# -*- coding: utf-8-*- # Grammatical Expansion # This should happen AFTER word order has been rearranged to # be more English-like def get_conjugated_ending(verb, tag): tiempo = tag[3] persona = tag[4] numero = tag[5] if (persona == '3' and numero == 's' and tiempo == 'p' and verb != 'is' and...
f587701be6bd9ef6d0205de2efc71ff8483f5fcc
kusenabdullah-123/list_contact
/list_contact.py
936
3.546875
4
from module_contact import show_contact from module_contact import add_contact from module_contact import delete_contact from module_contact import find_contact list_menu = ['list contact', 'add contact', 'delete contact', 'find contact', 'shutdown server'] list_contact = [] while True: print('======...
c33bfef4f2bc79bae43b15f484133bd81ecf5b3a
rebootedcqwe/spider
/t24.py
186
3.75
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @version : Python 3.7 namebook = {"Name": "Alex", "Age": 7, "Class": "First"} for key, value in namebook.items(): print (key, value)
02e407ddf2a0b90139d0c679258cf33c47f55646
Ramil51/Repoz
/guest.py
573
3.828125
4
class Guest: def __init__(self, firstname,lastname, city, status): self.firstname = firstname self.lastname = lastname self.city = city self.status = status def our_guest(self): my_guest = (self.firstname + ' ' + self.lastname + ' ' + self.city + ' ' + self.status) ...
aee334631c1cec1d0a7c21b89e8f6e88404e405c
shub0/python_cookbook
/algorithm_cookbook.py
1,325
3.53125
4
#! /usr/bin/python def unique_no_order(sequence): # elements in sequence are hashable O(N) try: return list(set(sequence)) except TypeError: pass # elements in sequence are with full comparision O(NlogN) t = list(sequence) try: t.sort() except TypeError: del...
e0be7d0c51eadf0c05187d271443f43294e48f56
koduj-z-klasa/python101
/docs/podstawy/przyklady/01_trojkat.py
1,519
3.890625
4
#! /usr/bin/env python3 # -*- coding: utf-8 -*- import math # dołączamy bibliotekę matematyczną op = "t" # deklarujemy i inicjujemy zmienną pomocniczą while op != "n": # dopóki wartość zmiennej op jest inna niż znak "n" dane = input("Podaj 3 boki trójkąta (oddzielone przecinkami): ") lista = [] # definic...
5807e186a6c6d4c13166a657e1abc8a58eca1bec
koduj-z-klasa/python101
/docs/pylab/pylab02.py
365
3.609375
4
#! /usr/bin/env python3 # -*- coding: utf-8 -*- import pylab a = int(input('Podaj współczynnik a: ')) b = int(input('Podaj współczynnik b: ')) x = range(-10, 11) # lista argumentów x # wyrażenie listowe wylicza dziedzinę y y = [a * i + b for i in x] # lista wartości pylab.plot(x, y) pylab.title('Wykres f(x) = a*x...
af69f8449da32f0c31f885672a83760a63ad149e
hiyori99/credit
/credit.py
1,729
3.546875
4
count = 0 keta = 0 sum1 = 0 sum2 = 0 ketasu = 0 while True: number = int(input("Number: ")) if 0 < number: break count = int(len(str(number))) # 桁数が偶数の時 if count % 2 == 0: for i in range(count, 0, -1): # 一桁ずつ計算していく keta = int(number / (10 ** (i - 1))) if i == count: ...
9074906ad97d897394a7b7d11007350320fb26d9
hilletc7/tf-MNIST-demo
/tf_images.py
5,835
3.890625
4
# https://www.tensorflow.org/tutorials/keras/classification # starts the env # activate tf # TensorFlow and tf.keras import tensorflow as tf from tensorflow import keras # Helper libraries import numpy as np import matplotlib.pyplot as plt import random print(tf.__version__) # Importing the Fashion M...
437d85ab17051962b83a44bebb2b4473a592c252
WaitingForBan/python_bootcamp
/string-slice.py
393
3.859375
4
s = "hello!" print(s[0:4]) #cztery znaki print(s[-3]) #3-ci znak od końca s = "ruda tanczy jak szalona" arr = s.split(" ") print(arr) print(arr[3]) print(s[0:16:2]) #od 0 do 16 co drugie print(s[::3]) #wszystkie stringi co 3-ci print(s[::-1]) #revers napisy print("hello" + " world!") a = "cokolwiek" b = "napiszę" ...
6be9c16234bce8c56ef1a85654d3952f0b2942b4
ernchern/twitter_corpus
/swear.py
1,116
3.53125
4
import csv import nltk from nltk.tokenize import word_tokenize from nltk.stem.wordnet import WordNetLemmatizer as lem swear_list = ['fuck','fucks','fucked','fucking','shit','damn','suck','sucks','wtf','wth','stupid','dick','heck'] def read_tweet(filename): negative = 0 f = open(filename, encoding="utf8") reade...
8857cc9623afc6b1d30ee24fe996238342969c5b
liuge1994/corepython
/7.py
1,621
3.578125
4
__metaclass__ = type # class Person: # def setName(self, name): # self.name = name # def getName(self): # return self.name # def greet(self): # print("Hello, world! I'm %s." % self.name) # foo = Person() # bar = Person() # foo.setName('Luke Skywalker') # bar.setName('Anakin Skywalker') # ...
b2c54bf776f9b3c8fe27a45ff11d96e3a74ed78a
MDavid92/Digital-Phonebook
/digital_phonebook.py
5,358
3.796875
4
import json print("Digital Phonebook") with open("contacts.json", "r") as f: data = json.load(f) sorted_json = json.dumps(data, sort_keys=True) def check_answer(allowed, answer): if answer in allowed: return "answer_allowed" else: return "not_allowed" def delete_profile(): ...
15c32b8dd94a9f1137594da207614b137f230c5b
joo7998/Python_Basic
/quiz_03.py
1,858
3.9375
4
def q1(): while True: num = input("수를 입력하세요:") try: int(num) # 캐스팅 except: print("정수가 아닙니다. 다시 입력하세요") else: # try 블록에 예외 없을 때 break total = 0 to = int(num) # for i in range(1, to + 1): # 1 ~ to # if i % 3 == 0: # ...
8fc918dd26a0bbccaeaaf5747b2d9b5ad550ea70
mit-d/euler
/19.py
311
3.859375
4
# How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)? from datetime import date, timedelta day = date(1900, 1, 1) ct = 0 while day < date(2000, 1, 1): if day.weekday() == 6 and day.day == 1: ct = ct + 1 day = day + timedelta(1) print(ct)
525365fb5497781fdafd80eb2f1936561db3f55c
AJoh96/BasicTrack_Alida_WS2021
/Week40/4.9.6.py
332
3.703125
4
import turtle window = turtle.Screen() window.bgcolor("lightgreen") finn = turtle.Turtle() finn.color('blue') def draw_poly (t, n, sz): angle = 360/n for _ in range(n): t.forward(sz) t.left(angle) def draw_equitriangle (t, sz): draw_poly(t, 3, sz) draw_equitriangle(finn, 50) window...
f623fbc9ad297294904cf231202e7e2ae1282524
AJoh96/BasicTrack_Alida_WS2021
/Week38/2.14_5.py
476
4.25
4
#solution from Lecture principal_amount = float(input("What is the principal amount?")) frequency = int(input("How many times per year is the interest compounded?")) interest_rate = float(input("What is the interest rate per year, as decimal?")) duration = int(input("For what number of years would like to calculate th...
03cbd650ca821f1d858002a94f556b23fabea152
rjg1998/Data_structure_algorithm
/lowest_no.py
367
3.6875
4
def low_no(arr): if len(arr)==1: return arr[0] elif len(arr)==0: return 'no number in array' else: for i in range (len(arr)-1): if arr[i]>arr[i+1]: x= arr[i+1] break else : x= arr[0] return x arr...
5341a861db53a422215d68c77a012bc3dd99f1cc
rjg1998/Data_structure_algorithm
/reverse_func.py
192
3.71875
4
arr=[23,45,67,12,36] def reverse_func(arr): n=len(arr) for i in range (n//2): arr[i],arr[n-1-i]=arr[n-1-i],arr[i] return arr result = reverse_func(arr) print(result)
cd0a03f8cb6e0a925f88c36a77c9fb034e0a3e56
rjg1998/Data_structure_algorithm
/candies_count.py
846
3.640625
4
def candies_count(children, candies): x=((candies * 2) ** (1 / 2)) #s is total no. of times chocolate will be distributed if x>int(x)+0.5: x=int(x) s=x else: x=int(x) s=x-1 # r is total chocolates in exact amount r=(s*(s+1))/2 t= candies - r#extra c...
dcc781e4028314a262e6ff3826dac0488c0e4000
g1ovannab/ti-sistemas-embarcados
/servo-motor.py
1,685
3.78125
4
# Importando biblioteca que já vem no Raspberry Pi que ocntrola os pinos GPIO. # Nomeia-se essa biblioteca como GPIO para facilitar a implementação. import RPi.GPIO as GPIO # Importando o módulo 'time' que trabalha com tarefas relacionadas a tempo. import time # Configurando o modo de acesso ao GPIO via BOARD - métod...
cd1b80af92171d7481e79b37e59ede16bc020dcb
LydDeb/formation-Arinfo-2020
/Python/tic-tac-toe/tictactoe.py
6,114
3.640625
4
""" display matrix 1 2 3 4 5 6 7 8 9 display available positions: 1 2 3 4 5 6 7 8 9 make your choice: replace the position by O/X in matrix: complete dictionnary for player O/X win if 147, 258, 369, 159, 753, 456 in dictionary switch O/X """ from random import randint import math import sys player_1 = "\033[32...
ab43c2fc8431191c68c59ad7b079adb0f4657c5b
dolphcoder/assignements
/Python/Set 1/2.py
85
3.734375
4
#2 l = input("Enter numbers separated by commas: ").split(',') print(l,"\n",tuple(l))
2804b90acb1ac9948591173d0a43e2204f003939
markhend/dna-seqs
/wk4a.py
1,494
3.984375
4
import itertools def overlap(a, b, min_length=3): '''return length of longest suffix of 'a' matching a prefix of 'b' that is at least length 'min_length' characters long. Return 0 if no such overlap exists. ''' start = 0 # start all the way to the left while True: start = a.find(b[:min...
6c475bf47ed4985dccc7ec089f2958c865ebcfef
wangfuchaoooooo/leetcode
/Unclassified/addTwoNumbers.py
1,511
3.828125
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def addTwoNumbers(self, l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode """ result = ListNode(0) ...
833676dc43bc03938d343c122d91bffa03a677a8
wangfuchaoooooo/leetcode
/Unclassified/nextPermutation.py
805
3.71875
4
class Solution: def nextPermutation(self, nums): """ Do not return anything, modify nums in-place instead. """ length = len(nums) i = length - 2 while i >= 0 and nums[i] >= nums[i + 1]: i -= 1 # 从右向左找到 nums[i] <= nums[i + 1] if i>=0: j = length - 1...
499e4cb1c2c70907119fe9b81b1b502e26d537c1
cpumichael/study
/read4.py
2,116
3.8125
4
''' Given a file and assume that you can only read the file using a given method read4, implement a method to read n characters. Method read4: The API read4 reads 4 consecutive characters from the file, then writes those characters into the buffer array buf. The return value is the number of actual characters read....
98d574a3e170f6bdf927c16d61e01eb9003c303b
andreyQq972/base_of_Python
/homework_1/task_2.py
525
4.125
4
time = int(input("Введите количество секунд и мы переведем их в формат чч:мм:сс: ")) time_hours = time // 3600 time_minutes = (time % 3600) // 60 time_seconds = ((time % 3600) % 60) # print(f"{time_hours}:{time_minutes}:{time_seconds}") if time < 360000: print ("%02i:%02i:%02i" % (time_hours, time_minutes, time_sec...
922f2973bb9b5668619430fba649afe47e3171ef
andreyQq972/base_of_Python
/homework_6/task_4.py
1,849
3.953125
4
class Car: def __init__(self, speed, color, name, is_police): self.speed = speed self.color = color self.name = name self.is_police = is_police def go(self): return f'{self.name} поехала' def stop(self): return f'{self.name} остановилась' def turn_righ...
27bdadd191e01dbcb6a4127f7812bd4e3942af91
andreyQq972/base_of_Python
/homework_1/task_5.py
874
3.9375
4
proceeds = int(input("Введите значение выручки вашей фирмы: ")) costs = int(input("Введите значение издержек вашей фирмы: ")) profit = proceeds - costs paying = profit / proceeds if proceeds > costs: print("Ваша фирма работает с прибылью. Рентабельность вашей фирмы составила: ", "%.2f%%" % (paying)) members = i...
6bcc90eba608bee002a1ed8c2560111004682c4e
andreyQq972/base_of_Python
/homework_2/task_3.py
827
3.90625
4
try: month = int(input("Введите месяц в виде целого числа от 1 до 12: ")) except ValueError: print("Введены некорректные данные.") seasons_list = ['зима', 'весна', 'лето', 'осень'] seasons_dict = {1 : 'зима', 2 : 'весна', 3 : 'лето', 4 : 'осень'} if month == 12 or month ==1 or month == 2: print(seasons_list...
bbe7340bf257b5893b84410ddc70e9033a9db207
abhishekkaushik07/test_source_code
/sudoku.py
1,415
3.875
4
#solving sudoku def is_arr_fill(a): flag=1 for i in range(0,9): for j in range(0,9): if(a[i][j]==0): flag=0 return i,j break if(flag==1): return 1 def is_safe(a,row_posi,column_posi,num): flag=1 for i in range(9): ...
3541b8cda8b5e6bbcbbca44e1035dc4aa74773a1
mikecrab/CSC421
/pieces.py
1,160
3.8125
4
numberRoutes = int(input()) routeGraph = dict() for i in range(0, numberRoutes): route = input().split() station = route[0] if station not in routeGraph: routeGraph[station] = set() connections = route[1:] for connection in connections: if connection not in routeGraph: ...
5bda7e74b5e730a6e84adf9dcdcbf8b00fcb21a9
uraboer/MyLeetCode_Learning
/Problemset/contains-duplicate-ii/contains-duplicate-ii..py
1,398
3.640625
4
# @Title: 存在重复元素 II (Contains Duplicate II) # @Author: uraboer # @Date: 2019-03-26 14:40:38 # @Runtime: 68 ms # @Memory: 20.4 MB # # @lc app=leetcode.cn id=219 lang=python3 # # [219] 存在重复元素 II # # https://leetcode-cn.com/problems/contains-duplicate-ii/description/ # # algorithms # Easy (33.19%)...
6a175d9744313b13538d4fbc76e3abe3825da15f
weyderfs/PythonCourse
/CursoEmVideo/Mundo 01/Exercicios/Aula10/desafio30.py
196
3.9375
4
from time import sleep n = int(input('Digite um número inteiro: ')) r = n % 2 sleep(2) if r == 0: print ('O número {} é PAR'.format(n)) else: print('O número {} é IMPAR'.format(n))
b5cb318046930c6bbb1fa247b8a53bbb0492d497
weyderfs/PythonCourse
/CursoEmVideo/Mundo 01/Aulas/aula9.py
1,249
3.515625
4
frase = 'Curso em Vídeo Python' print(frase[1:15]) print(frase[3]) print(frase[3:13]) print(frase[:13]) print(frase[1:15:2]) print(frase[1::2]) print(frase[::2]) print("") print("""Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever s...
0e03a5303c015f93a6fb2f9c2e5d02a20a1e0f71
weyderfs/PythonCourse
/CursoEmVideo/Mundo 01/Exercicios/Aula10/desafio29.py
237
3.78125
4
v = float(input('Qual a velocidade do carro? ')) m = (v - 80) * 7 if v <= 80: print('Boa viagem!!!! Dirija com segurança') else: print('Você está acima do limite de velocidade de 80 KM/h e foi multado em R${:.2f}'.format(m))
03d756a2db684720ac8b8b63db543b074c6906b3
weyderfs/PythonCourse
/CursoEmVideo/Mundo 01/Exercicios/aula07/aula07a.py
544
3.859375
4
print(5+3*2) print(29//2) print(19/2) print(pow(4,3)) print(25**(1/2)) print(125**(1/3)) print('='*20) nome = input('Qual teu nome? ') print('Prazer {}!'.format(nome)) n1 = int(input('Um valor:')) n2 = int(input('Outro Valor: ')) sm = n1 + n2 sb = n1 - n2 m = n1 * n2 d = n1 / n2 dint = n1 //n2 exp = n1 ** n2 raiz = ...
9da8e13fedba5951356b5c1579281829ada5651e
weyderfs/PythonCourse
/CursoEmVideo/Mundo 01/Exercicios/Aula10/desafio28.py
491
3.890625
4
from random import randint from time import sleep t = randint(0, 5) #Randomiza um número dentro do range informado. print(' ') print('#£#' * 20) print('Estou pensando em um número entre 0 e 5. Tente adivinhar') print('#£#' * 20) print(' ') n = int(input('Insira um número inteiro entre 0 & 5: ')) #O Jogador tentar adiv...
e7dbf41b22d6fbc11876b48b7c74b76c8d50a40b
sahilpathan/Practice-Problems
/strange_advertising.py
462
3.890625
4
# https://www.hackerrank.com/challenges/strange-advertising import math def viral_impact(days,people): if (days == 0) : return 0 liked_people = math.floor(people/2) days-=1 people = liked_people*3 x= viral_impact(days,people) return (liked_people+x) ...
15d7aef2e62c3d16312d7a6d1b11125a175f84dd
r0744454/python
/examenvraag/oefening 2.py
411
3.640625
4
def count_code(str): count = 0 word = "" while "co" in str: index = str.find("co") if len(str) >= 4 and "e" == str[index + 3]: word = "co" + str[index + 2] + str[index + 3] count += 1 str = str[0:index] + str[index + 4:] else: str = st...
f92165b5ce3293d9b5be83e8f9eb62a5c4e6e737
David-Papworth/python-examples
/Monday_problem/monday_problem.py
449
3.875
4
def even_between (number_lower, number_upper): count = number_upper even_numbers = [] while count >= number_lower and count <= number_upper: if (int(count // 1000)) % 2 == 0: if (int(count // 100)) % 2 == 0: if (int(count // 10)) % 2 == 0: if count % 2...
fc0d58442cc03ac4a0d9e721c95e953217754b66
charlinox/grandpy
/app/tests/test_parser.py
638
3.703125
4
#!/usr/bin/python3 # coding: utf-8 from app.parser import Parser def test_remove_accents(): parser = Parser("éèâ") expected_result = "eea" assert parser.remove_accents().text == expected_result def test_parser_text(): parser = Parser( "Salut, comment vas-tu? Pourrais-tu par hasard m'indique...
969353261235eba76b13ce1893511ea87319415d
Vivicos/TimeSeriesForecasting
/fibo.py
437
3.90625
4
n = int(input("Numero de la serie de Fibonacci: ")) # n = 8 m = 0 p = 0 # print(fibo(n)) for i in range(1,n): if m == 0: p = m print('0 : ', p) m = m + 1 print('1 : ', m) elif m == 1: p = m m = m + p print(i, ':',m) else: ...
63506020b5d36464d0f8ee48e4fdffcb462eac05
nsforero10/holbertonschool-higher_level_programming
/0x06-python-classes/100-singly_linked_list.py
1,711
4.0625
4
#!/usr/bin/python3 """ Single Linked List """ class Node: """Class constructor""" def __init__(self, data, next_node=None): self.data = data self.next_node = next_node @property def data(self): return self.__data @property def next_node(self): return self....
d442eb5d352ee58ad340f01a48a860ab6d4df34f
nsforero10/holbertonschool-higher_level_programming
/0x03-python-data_structures/2-replace_in_list.py
145
3.65625
4
#!/usr/bin/python3 def replace_in_list(lis, idx, elem): if idx < 0 or idx >= len(lis): return lis lis[idx] = elem return lis
674f44ce9396b6687f33563d871731b7986c24fc
nsforero10/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/4-only_diff_elements.py
247
3.71875
4
#!/usr/bin/python3 def only_diff_elements(set_1, set_2): diff = [] for el1 in set_1: if el1 not in set_2: diff.append(el1) for el2 in set_2: if el2 not in set_1: diff.append(el2) return diff