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
35d484df801607f102f4940be293f335f022542f
5l1v3r1/problem_solving
/Leetcode/oddevenlinkedlist.py
887
4
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def oddEvenList(self, head): """ :type head: ListNode :rtype: ListNode """ #empty case if(head == None or head.next == None): return head; ev...
e94ac2a9ae73a51f7496d65ce8bd874bbf123574
5l1v3r1/problem_solving
/Leetcode/binarytreepruning.py
706
3.96875
4
# Definition for a binary tree root. class Treeroot(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def pruneTree(self, root): if(root == None): return None; else: root.left = self.pruneTree(root.left); root.right = self....
90b6059a00fe1f616d20383ddfa41f3db6f90ab3
torresyara/retipecao-encaixada-exercicio
/repetiçãoencaixada.py
322
4.09375
4
""" Devolve o fatorial do número digitado. Finaliza após receber o número 0. """ numero_digitado = 1 while numero_digitado != 0: numero_digitado = int(input("Digite um número: ")) fatorial = 1 numero = numero_digitado while numero>0: fatorial = numero * fatorial numero = numero - 1 print (fatorial)
b01afb31b985d6da03dc1503a6bbb2f5e980cc0c
tirthb/datasci_course_materials
/assignment3/unique_trims.py
1,275
3.59375
4
import MapReduce import sys """ Consider a set of key-value pairs where each key is sequence id and each value is a string of nucleotides, e.g., GCTTCCGAAATGCTCGAA.... Write a MapReduce query to remove the last 10 characters from each string of nucleotides, then remove any duplicates generated. Map Input The input ...
67c48d0b9797468145ee308e456a7e09184faef8
apdaza/Ciencias3
/arboles/binarios.py
1,396
3.671875
4
class Nodo: def __init__(self, valor, izquierda=None, derecha=None): self.valor = valor self.izquierda = izquierda self.derecha = derecha arbol = Nodo(5, Nodo(3, Nodo(1)), Nodo(10, Nodo(7), Nodo(15, None, Nodo(20)))) def en_orden(arbol): if arbol == None: return [] else: ...
3fdd7e6064e1cefcf27fe2c8d646c1274c295e7a
MatheusMatozo/Python-Library-software
/addpeople.py
3,694
3.625
4
from tkinter import * import sqlite3 from tkinter import messagebox con=sqlite3.connect('database.db') cur=con.cursor() class AddPeople(Toplevel): def __init__(self): Toplevel.__init__(self) self.geometry("650x750+550+200") self.title("Add People") self.resizable(False,False) ...
aa76c8ebe8120d39778876558f94d78028708f92
obarberena/Python
/metodos de cadenas.py
220
3.84375
4
course = 'Curso' my_string = 'Python' result = '{} de {}'.format(course, my_string) result = result.lower() #pone todo el minus. result = result.upper() #pone todo en myus result = result.title() #titulo print(result)
384b08d00ea62de3575c335630fbc6b5179b21be
khadafyb/all-labs-
/lab6quest2.py
138
3.890625
4
def check_string(string): for i in range(len(string)-1): if string[i]==string[i+1]: return True return False
5aeb62da98400815852b99bffb77e53311cf87e1
khadafyb/all-labs-
/lab4question1.py
134
3.734375
4
def calc(): x=int(input("enter an x value: ")) top=x**2+2 bottom=x**2+1 y=(top/bottom)**(1/2)-1 return y calc()
5968931f00a58041e3ae54ba6a285ff84b03314a
Pectin-eng/Lesson-3-Python
/lesson_3_task_1.py
689
4.0625
4
print('Задача 1.') def div(x, y): """ Функция возвращает частное двух позиционных параметров и отсекает ситуацию деления на 0: :param x: Параметр 1 :param y: Параметр 2 :return: Частное двух параметров, округленное до 0,00. """ try: c = x / y return round(c, 2) except Ze...
b9c7eee17e69a1836d0cbf817509a874ebe5514f
nsvir/todo
/src/model/list_todo.py
1,158
4.125
4
class ListTodo: """ List Todo contains name Initialize an empty list lst = ListTodo() To get list >>> lst.list() [] To add element in list lst.add_list(TaskList()) To check if element is contained in list lst.contains_list(TaskList()) True """ def __init__(s...
e17d89bddf5f7add20b82d5c2f1d0c553c10425e
nsvir/todo
/src/db/connect.py
581
3.640625
4
#!/usr/bin/python import sqlite3 from sqlite3 import Error class Connection: """ Create connection to database conn = Connection() conn.create_connection("data.db") """ def create_connection(self, db_file): """ create a database connection to the SQLite database specifi...
4d0163880c441315054ff4bf1ae14c84f70fb5df
GCpython/GC_Python_course
/Tema/tema_4.py
673
3.625
4
# Creati o functie care primeste doua argumente de tip int (a, b, c) si returneaza o functie capabile sa # calculeze ax^2-2bx+c (a^2 = a la puterea 2). Pentru setul de valorile a = 1, b = 3, c = 5 dati valori functiei # returnate in intervalul -10, 10. Printati valoarea lui x pentru care functiia returneaza un minim ...
15857f7073ada5bba10bfba4a2dc76e9f8acef10
Razzy415/python-challenge
/PyPoll/main.py
1,030
3.5625
4
import os import csv import sys # Path to collect data from the Resources folder csvpath = os.path.join('Resources', 'election_data.csv') votes = [] candidates = [] poll = {} votepercentage = [] # Read in the CSV file with open(csvpath, newline="") as csvfile: csvreader = csv.reader(csvfile, delimiter=',') h...
bc14e2887d6b6723957191d99c1f4cf20e1d73c6
UJurkevica/python-course
/session6/rockpaperscissors.py
2,116
4.09375
4
import random import operator guess_choices = "r", "p", "s" #pincorect_user_input = True #pc_guess = random.choice(guess_choices) #print(pc_guess) def pc_game(): pc_guess = random.choice(guess_choices) print(f'pc guess {pc_guess}') return pc_guess def game(): while True: my_guess = inpu...
acee050f0b233e3769df049dc44bd5cfb6af31e3
UJurkevica/python-course
/homework/week2/exercise1.py
538
4.21875
4
#1a for num in range(0,11): if num % 3 == 0: continue else: print(f'number {num}') #1b def print_nums(): for num in range(0,10): if num % 3 == 0: continue else: print(f'Number in function range {num}') print_nums() #1c max_number = int(input('Enter ...
62378cd24cbceffc6deb0dd20bcfbeeefc0dd4cd
UJurkevica/python-course
/homework/week3/exercise3.py
634
4.03125
4
#3a def split(a): return [char for char in a] a = "question" print(split(a)) #3b list_in_lists = [[5,3,2], [1,3,2,1], [3,2,3], [10,1,5], [6,7,2]] print(list(map(sum, list_in_lists))) # print(max(list(map(sum, list_in_lists)))) def item_of_list(): for item in list_in_lists: sum_of_list(item) ...
51ccee0d60358481e6610f01c4e927c1cd630021
UJurkevica/python-course
/session3/exercise1.py
372
3.921875
4
#1a shirt_price = float(input('What is the price of the shirt?')) shirt_in_budget = shirt_price <= 25.00 print(f'Shirt is available within budget: {shirt_in_budget}') shirt_in_color = input('Is shirt yellow? (y/n)') shirt_all = (shirt_in_budget == True) and (shirt_in_color == 'y') #1b print(f'Shirt is available wi...
377f1b437e5d14f078cf1383feab6978edb95f4a
pathim/advent_of_code_2020
/6/main.py
498
3.828125
4
count=0 count_every=0 with open('input') as f: current=set() every_letter=set(chr(ord('a')+x) for x in range(26)) everyone=set(every_letter) for line in f: line=line.strip() if not line: count+=len(current) current=set() count_every+=len(everyone) everyone=set(every_letter) continue current.upd...
be690e0c0a510d3a7d508aad6b099976d8aa524a
abhisheksethi02/Hackerrank
/loops_for.py
209
4
4
''' Task: Read an integer . For all non-negative integers , print . See the sample for details. ''' if __name__ == "__main__": n = int(input().strip()) for i in range(0,n): print(i**2)
9570c497657d9aeae73545869f9681e7ebdabf25
abhisheksethi02/Hackerrank
/If-else odd.py
571
4
4
''' Task: Given an integer, , perform the following conditional actions: If is odd, print Weird If is even and in the inclusive range of to , print Not Weird If is even and in the inclusive range of to , print Weird If is even and greater than , print Not Weird ''' import math import os imp...
9b8746cd8ba94d9bdc66acea6847465ae3839902
wtripp/udacity-cs212-design-of-computer-programs
/cs212_hw4-2_more-pour.py
4,471
3.984375
4
# ----------------- # User Instructions # # In this problem, you will solve the pouring problem for an arbitrary # number of glasses. Write a function, more_pour_problem, that takes # as input capacities, goal, and (optionally) start. This function should # return a path of states and actions. # # Capacities is a tu...
e7375a15b90d80a7402991f40c328ed06175a01a
cdigap/Python_Scripts
/SML_MLT.py
790
3.65625
4
# Ashok Gangadharan 2018-02-18 #https://projecteuler.net/problem=5 # Number initializatoin n = 0 i = 1 # While loop... while n==0: # Incrementing i i=i+1 # Checking if the number is divisible by a 1 to 20 if i%1==0 and i%2==0 and i%3==0 and i%4==0 and \ i%5==0 and i%6==0 and i%7==0 and i%8...
7ccba944ae2cac3a81d973103def9c52e5512f55
Introduction-to-Programming-OSOWSKI/4-4-last-10-RainerMauersberger23
/main.py
145
3.515625
4
def list10(a): if 10 == a[len(a) - 1]: return True else: return False print(list10([5,10,15,20,20]))
f52d7a33408b9645e8b66ddd580e9192732b3021
vitaliy-developer/learning_python
/5.operator.py
762
4.15625
4
number = int(input("Enter a number: ")) if number > 5: print("This number > 5") else: print("Number < 5") name = input("Enter you name: ") if name == "Alex": print("You have entered", name) print("This is my name, too.") else: print("You not Alex") x = int(input(" x = ")) if 0 < x < 7: print...
aa204d890f9260c5bf15a6d4aa1d63c5bb61a244
vickyandpiggy/closest_pair_problem_fast
/closest_pair_problem_fast.py
5,084
3.546875
4
import numpy as np import math #select the points in specific section of dimension x def locate_dimension_x(xl,xh,x,y): location_l=xl<x x=x[location_l] y=y[location_l] location_h=x<xh x=x[location_h] y=y[location_h] return x,y #select the points in specific section of dimensio...
3336bf3cf95df2a252a7457b1eee72dc59b81d4d
jsafrit/lern
/week_08/solution.py
2,254
3.65625
4
# First, you will want to create a text file containing 100 (or a smaller number, if you're less cruel than I am) # exercises. Each exercise will involve addition (+) and subtraction (-) of four randomly chosen positive and # negative integers. Let's say that the integers should range from -40 to 40, but it shouldn't...
fb9ae7b77a890d274a0358546742e31cf798fcb2
jsuarezwd/python-exercises
/calNomina.py
753
3.734375
4
nombre = str(input('Ingrese el nombre del empleado: ')) horas = float(input('Ingrese las horas trabajadas: ')) precio_por_hora = float(input('Ingrese el precio por hora: ')) sub_total = horas*precio_por_hora precio_horas_extras = (precio_por_hora*0.50) + precio_por_hora horas_extras = int() monto_extra = int() desc_af...
2263994c9a91f8301b2fcd812efa5f52ab6b5731
kevinfeng14/PracticasPython
/Prueba/Prueba.py
446
3.609375
4
from tkinter import * from PIL import ImageTk, Image import os ventana=Tk() ventana.geometry("700x700") ventana.title ("Ejemplo IMAGEN") # lo que sale arriba de la ventanita ventana.resizable(0,0) ventana.config(bg="pink") # creamos imagen dir_path = os.path.dirname(os.path.realpath(__file__)) imagen = ImageTk....
7a79f4a0e8462474d80b69199de50beeaefb24d3
kevinfeng14/PracticasPython
/Tarea 3/Problema3.py
586
3.921875
4
print(""" ------ problema 3 ------ """) practicaTotal = 0 for i in range(1, 6): practica = float(input("Introduzca la nota del practica {} : ".format(i))) practicaTotal = practica + practicaTotal parcial = float(input("Introduzca la nota de examen parcial: ")) final = float(input("Introduzca la ...
2bea65a002826bbd36c2cb330caba686eb8232e7
chen-yu-ting/LinearAlgebra
/MatrixMultiplication.py
1,755
3.703125
4
import sys #矩陣相乘 def MatrixMultiplication(_matrix1, _matrix2): row = len(_matrix1) col = len(_matrix2[0]) matrix = [[0 for i in range(col)] for j in range(row)] for r in range(row): for n in range(col): sum = 0 for c in range(col): sum += _matrix1[r][c] * _matrix2[c][n] matrix[...
82ec68ec4ff2ff98681a0639cddc93a091bd4408
jhp0303/Python-Beginner
/Code 4-57.py
394
3.921875
4
# 변수를 선언합니다. example_a = "문자열" example_b = { "키A":"값A", "키B":"값B"} example_c = range(10) # 출력합니다. print("# 문자열에 반복 적용") for char in example_a: print("-", char) print() print("# 딕셔너리에 반복 적용") for key in example_b: print("-", key) print() print("# 범위에 반복 적용") for i in example_c: print("-", i)
a54edc31e0ec817644618d1de84b5208e6678e64
sijanstha/DSA-With-Python
/oop.py
1,758
4.0625
4
class Employee: # this is class variable raise_amount = 1.04 # this is instance variable which is shared by all num_of_emps = 0 # this is like constructor def __init__(self, first, last, pay): self.first = first self.last = last self.pay = pay self.email = firs...
d306f43d54d0a2713bc23a714a949af59714e9f4
Yosolita1978/Google-Basic-Python-Exercises
/basic/wordcount.py
2,898
4.34375
4
"""Wordcount exercise Google's Python class 1. For the --count flag, implement a print_words(filename) function that counts how often each word appears in the text and prints: word1 count1 word2 count2 ... Print the above list in order sorted by word (python will sort punctuation to come before letters -- that's fi...
1f26f6c1d7b41971915f0fa0c41cd9d52ca3354c
ohPeppaPig/workplace
/AfterClass01/04_hanoi.py
200
4.15625
4
# hanoi(N)= 3* hanoi(N-1) +2 def hanoi(num): if num == 1: return 2 else:return 3* hanoi(num-1) +2 num = int(input()) for x in range(num): n = int(input()) result = hanoi(n) print(result)
9028605f90a5a2f4bf2350c0ffd6f77fa2dc97ab
ohPeppaPig/workplace
/Class_03/01_sumhalf.py
719
3.625
4
def findLength(str): n = len(str) maxlen = 0 # Initialize result # Choose starting point # of every substring for i in range(0, n): # Choose ending point # of even length substring for j in range(i + 1, n, 2): # Find length of current substr length = j - i + 1 # Calculate left & right # sums...
e8546df3b1754e8a01ba58affe334da8c3f2782a
ohPeppaPig/workplace
/AfterClass02/08_mergeSort.py
1,508
3.78125
4
# import math # # # def mergeSort(arr): # if len(arr) < 2: # return arr # middle = math.floor(len(arr) / 2) #取中 # left, right = arr[0:middle], arr[middle:] #分割数组left right # return merge(mergeSort(left), mergeSort(right)) # # def merge(left, right): # result = [] #辅助数组 # while left and right: #比较两边数组元素 # if ...
8858175ab03e19c0b1d02bde9caf73f56c73e03e
2706853499/CBOW
/cbow_model.py
6,687
3.515625
4
import numpy as np import matplotlib.pylab as plt import nltk class cbow: """ This class is an implementation of the continous bag of words model by first principles. CBOW model tries to predict the center words from the surrounding words. """ def __init__(self, text, window=2, n=2, learning_rate=0.000...
24f5dea42d8cae1a11650a4cf8de3c94ee269632
aneetauppal/ProgrammingPython2
/findlen.py
387
3.859375
4
#!/usr/bin/python import itertools import sys vcf = raw_input('Enter your filename:') def vcf_parser(vcf_file): file = open(vcf_file, 'r') for line in file: # if not line.startswith ('#'): splitfile = line.strip() parts = line.split() print(parts) # for i in range(le...
5779383b471fccf99ee3dd44c98fb16c6f20ef0c
vechiatto/python-fundamentals
/curso_python/aula1/hands/exec3.py
607
3.78125
4
menu = ''' <=Sistema=> Selecione um opcao abaixo: 1) Cadastrar usuario 2) Acessar sistema 3) Sair ''' usuarios = [] senhas = [] while True: opcao = input(menu) if opcao == 1: login = raw_input('Login: ') senha = raw_input('Senha: ') usuarios.append(login) senhas.append(senha) elif opcao == ...
a44ae78ef30d8d27c8aa88fbacc88f9c2ec6132d
fann0128/pythonLesson
/functions/abstest.py
430
3.71875
4
import math def my_abs(x): if not isinstance(x,(int,float)): raise TypeError('bad operand type') elif x > 0: return x else: return -x def quadratic(a, b, c): if not (isinstance(a,(int)) and isinstance(b,(int)) and isinstance(c,(int))): raise TypeError('bad operand type') else: tmp = b**2-4*a*c if tmp...
12a8cb105a2a7a6a71e09a5cbc612b9a552fbdd5
NardM/KM
/money.py
1,848
3.53125
4
class Money: def __init__(self, rubles, dime=None): self.rubles = rubles self.dime = dime if isinstance(rubles, str): self.rubles, self.dime = self.convert_in_money(rubles) else: self.rubles = rubles self.dime = dime def __str__(self): ...
9ce8a3ea1dfed4fe0f2101a5de03f28caa13c841
ThomasP1234/DofE
/Week 8/Inheritence.py
266
3.859375
4
# Inheritence in python # ref: https://www.w3schools.com/python/ # Author: Thomas Preston class Person: def __init__(self, name, age): self.name = name self.age = age p1 = Person("Joe", 21) print(p1.name) print(p1.age) class student(Person): pass
9368e573f0bd816c214165e71571bccfed73076d
ThomasP1234/DofE
/Week 2/GlobalVariables.py
527
4.125
4
# Global Variables and Scope # ref: https://www.w3schools.com/python/ # Author: Thomas Preston x = "awesome" # When this is commented out there is an error because the final print doesn't know what x is def myfunc(): x = "fantastic" # Where as when this is commented out, the global x is printed print("Python is "...
95f146d5bd21e8f40343ea95c4f7e8f7ea0da0f8
ThomasP1234/DofE
/Week 5/WhileLoops.py
410
4.21875
4
# One of the primary loops in python # ref: https://www.w3schools.com/python/ # Author: Thomas Preston a = 1 while a < 10: print(a) a = a + 1 # Adds 1 to a each loop b = 1 while b < 6: print(b) if b == 3: break b += 1 c = 0 while c < 6: c += 1 if c == 3: continue print(c) # skips this ste...
3315c64c0a9def7985f3277f8b1ce7e3ea2b8bee
ThomasP1234/DofE
/Week 11 (TextGameV2)/Intro.py
876
3.734375
4
# Author: Thomas Preston def introduction(): print('Welcome to this word adventure, puzzle game made with python.') print('For a list of commands, see COMMANDS.md') print('') print('Side Notes') print('- Auto-unlock is on. Once you get a key. The door it unlocks opens.') print('- Auto-pick up i...
56ed3a1710fa1acf37d1075f5a7cf949961fa8e7
LimePencil/Project_Euler
/2_Even_Fibonacci_numbers.py
330
3.796875
4
# Finished on 2020.07.17 fibonacci = [1, 2] first_term = 1 second_term = 2 total = 2 while first_term+second_term<=4000000: new_term = first_term + second_term fibonacci.append(first_term+second_term) first_term = second_term second_term = new_term if new_term % 2 == 0: total += new_term pr...
59680ff3bcf1c7c4455fc006e94b8fb2f21b63c4
parttimeEr/3drCode
/Encoder/blend.py
1,059
3.5
4
from PIL import Image import numpy as np # Load both images and make into Numpy arrays a=np.array(Image.open('out/1.png').convert('RGBA')) b=np.array(Image.open('out/2.png').convert('RGBA')) c=np.array(Image.open('out/3.png').convert('RGBA')) # Make masks of all opaque pixels in each image, i.e. alpha>0 mA = a...
5caa1ea1ab9aab2e1a85af0092d644ce36d8e8b1
Mrityunjay6492/python
/day program.py
1,929
4.375
4
# To determine the day at that the Entered date def date(dd,mm,yyyy): m=[31,28,31,30,31,30,31,31,30,31,30,31] #assinment, number of days in month's if(yyyy%4==0): #increment of 1 for a leap year in the month of feb m[1]=29 days=0 for i in range(0,mm-1,1): ...
2da03b220e8cf1ac8eb1c58b391a0f06f4cd18e2
Centreant/fuelprice
/clean_raw_website_data.py
4,035
3.953125
4
# Import libraries import pandas as pd import os import numpy as np # Get raw file list folder = 'data/raw/website' file_list = os.listdir(folder) file_list = [folder + '/' + x for x in file_list] # Functions def get_header_row(df): """ For a csv or Excel file, it looks through each row starting from the ...
0551d32899f4b63ac02ff22c89dc2cadcd693f7a
aferron/AdventCode2020
/day8.py
3,233
3.828125
4
# advent of code 2020 # day 8 # follow instructions to find the infinite loop class instruct: def __init__(self, function='', value=0, visited=False): self.function = function self.value = value self.visited = visited def display(self): print(self.function, " ", self.value, " ...
77b5d3d732e15669abd4b9e7f136eb062116bfd3
mogonow/ChangeFileNameByPY
/change@2x&@3xToSmall&Big.py
2,203
3.6875
4
import os; import shutil #去除文件夹中的@2x或者@3x def rename(file): "Print usage message and terminate." filepath = file filelist = os.listdir(filepath) for files in filelist: Olddir = os.path.join(filepath,files) if os.path.isdir(Olddir): continue; filename = os.path.spli...
3f2d034252b447ef8b1c57900e54f1e0bed55dea
odessit-qwerty/python-project-lvl1
/brain_games/cli.py
519
3.984375
4
#!/usr/bin/env python3 import prompt def get_user_name(): name = prompt.string("May I have your name? ") print("Hello {}!\n".format(name)) return name def get_user_answer(): return str(prompt.string("Your answer: ")) def show_valid_answer(user_answer, answer, user_name): print(""""{}" is wrong...
65f7c00fdc6a94623711fedd24d1048b2b4c2914
jasmineseah-17/cp2015
/q3_miles_to_kilometre.py
154
4.1875
4
#Converting miles into kilometers miles = round(float(input("Please enter miles: ")), 5) kilometre = round(float(miles / 1.60934), 5) print(kilometre)
9fba4c0eb7046f9b22e1f3a83e0752c961fedcd4
Yfaye/AlgorithmPractice
/python/InsertInterval.py
1,756
4.25
4
# Insert Interval # Description # Given a non-overlapping interval list which is sorted by start point. # Insert a new interval into it, make sure the list is still in order and non-overlapping (merge intervals if necessary). # Example # Insert [2, 5] into [[1,2], [5,9]], we get [[1,9]]. # Insert [3, 4] into [[1,2]...
37b4fbeb9eafac5d6116a362add73d6910a87dda
Yfaye/AlgorithmPractice
/python/MergeIntervals.py
4,415
4.0625
4
# Merge Intervals # Description # Given a collection of intervals, merge all overlapping intervals. # Example # Given intervals => merged intervals: # [ [ # [1, 3], [1, 6], # [2, 6], => [8, 10], # [8, 10], [15, 18] # [15, 18] ] # ] # Challe...
6dd10b6c5ed04e281e1922ec9a1b1e8a986578c8
imontoyah/ST0245-002
/laboratorios/lab04/codigo/arbolFilogenetico.py
3,093
3.625
4
class Person: def __init__(self,name,gender): self.name = name self.gender = gender class Nodo: def __init__(self, data): self.left = None self.right = None self.data = data def __repr__(self): return f'{self.data}' class BinaryT...
e041f0d75e485c7dd784300e939d43a24534da6b
imontoyah/ST0245-002
/talleres/taller08/OpcinalesTaller8.py
673
3.96875
4
from collections import deque from queue import LifoQueue ---------------------- Atencion_en_un_bar_con_colas----------------------- def barCola(n): my_queue = deque() for i in range(n): my_queue.append(input()) for i in range(n): print ("Atendiendo a: " + my_queue.popleft()) ...
9aef58dc0ab91bf824f51d73eef9077f0f2248db
imontoyah/ST0245-002
/talleres/taller02/Suma_Grupo.py
286
3.765625
4
def sumaGrupo(start, nums, target): if start >= len(nums): if target == 0: return True else: return False return sumaGrupo(start+1, nums, target) or sumaGrupo(start+1, nums, target-nums[start]) print(sumaGrupo(0, [2,4,8], 10))
024f6567ae1deb138abd126395970b45d805bd02
imontoyah/ST0245-002
/laboratorios/lab03/codigo/pivote.py
1,308
3.734375
4
import math def pivote(arr): sumL = 0 #C1 sumR = 0 #C2 auxArr = [0]*len(arr) #C3 sumAux = 0 #C4 for i in range(len(arr)): #C5*n , means O(n) where n is the array's le...
4147e66c5a23d70dfe1d885f5816949e808b52d5
GitFromAleksey/pyLearn
/OOP/simpleclass.py
1,011
4.34375
4
##------------------------------------------------------------------------------ class SimpleClass: # имя класса u'Simple Class __doc__' var = 87 # совместно используемая переменная 'Simple Class constructor' def __init__(self): ## self.var = 99 print('SimpleClass.Constructor ') ...
61a82e96c471a2623c8805cabab5ae9cd718b7b4
GitFromAleksey/pyLearn
/python_tmp/1.py
1,147
3.953125
4
import os import sys import mylife print (sys.platform) print ('api_version: ', sys.api_version) print ('\r\n', 2**8) print ('the pright side ' + 'of life') print (mylife.title) import threenames dir(threenames) hello = r"string\nfdadf" print (hello) hello = "string\nfdadf" print (hello) a, b = 0, 1 while b<10: ...
b292f99b08ab9187b8b3d3a180058de44d9e479d
GitFromAleksey/pyLearn
/Snake/field.py
9,349
3.515625
4
import os import random as rnd from enum import Enum ##------------------------------------------------------------------------------ class cDimension(object): def __init__(self, name): self.width = 0 self.height = 0 self.name = name ## TODO перенести в cObject def SetDimension(self, ...
50b91eab5ea979b2aa9fb0ccf5b111c50a7e99db
GitFromAleksey/pyLearn
/gui.py
360
3.734375
4
from tkinter import * root = Tk() root.title('APP') root.geometry('500x400') title = Label(text='label text') title.grid() def Hello(event): print ("Yet another hello world") btn = Button(root, text='Click me', width=5,height=5, bg='white',fg='black') btn.bind('<Button-...
4018b4ef28be1eec3cb5ba31bca01bb25366bbe8
hail-pas/leetcode
/0023-merge-k-sorted-list.py
2,402
3.671875
4
from math import inf from typing import List, Optional # Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def __str__(self) -> str: return self.val def __repr__(self) -> str: return self.val class Sol...
519bf27df459279316d1cde92b9a7e5675f21fc9
vanctate/Computer-Science-Coursework
/CSCI-3800-Advanced-Programming/Final_Project_Web_Scraper/aslkdjf.py
358
3.6875
4
# testing stuff from User import User def check(name, array): for user in array: if user.name == name: return False return True ar = [] if len(ar) == 0: print("zero") name = "vt" p = "abc" user = User(name, p) ar.append(user) for user in ar: if user.name == name: print("==")...
bb711f3653e9dd1ae3f3a88d75a2fd038df612dc
vanctate/Computer-Science-Coursework
/CSCI-3800-Advanced-Programming/HW03/Problem1_Python/piece.py
1,365
4.1875
4
# Patrick Tate # CSCI 3800 HW03 | Problem 1 # class to represent a black or white piece to be inserted into an Othello gameboard # piece has a color(B/w), and a row and column in array notation, to be used with the Grid class class Piece: # subtract 1 from row and column for array notation def __init__(self, ...
e8b56ff496eacbfa2598f2e34b00ee7c0f21eb6d
saugat-77/age-calculate
/agecalculate.py
553
4.09375
4
from datetime import date name=input("enter your name: ") input_year=int(input("enter your year: ")) input_month=int(input("enter your month: ")) input_day=int(input("enter your day: ")) first_time=date(input_year,input_month,input_day) current_time=date.today() delta=current_time-first_time x=delta.days x=x/365 yea...
16f04d7e3246f658c9a6636ae0f336284dcc4478
biancaDanci/CBA
/Tools/Statistics.py
4,786
3.671875
4
import matplotlib.pyplot as plt import numpy as np import seaborn as sns import pandas as pd import logging PATH = '/home/bia/PycharmProjects/CBA/Outputs/stats/' class Statistics: """Class for displaying results and features in a statistics manner.""" def __init__(self, clusters, features): self.feat...
796695d867757555edc2d8fb69c3ece721544809
test-python-rookie/python_study
/No11_集合.py
751
4.125
4
# 集合(set)是一个无序的不重复元素序列。 # 可以使用大括号 {} 或者 set() 函数创建集合,注意:创建一个空集合必须用set()而不是{},因为{}是用来创建一个空字典。 # 集合会自动去重且无序 parame1 = {"apple", "blue", "people", "people"} print(parame1) parame2 = set("好好学习,天天向上!!!") print(parame2) # 将元素 x 添加到集合 s 中,如果元素已存在,则不进行任何操作。 parame1.add("look") print(parame1) # 还有一个方法,也可以添加元素,且参数可以是列表,元组,字典等,语法...
5dc5339dc4914b0e508bac9dfaa84f6baa850e1f
test-python-rookie/python_study
/No04_字符串显示.py
776
4.0625
4
# 定义字符串 str = "abcdefg" # 显示完整字符串 print(str) # 显示第2个到第4个字符(下标从0开始,包头不包尾) print(str[1:4]) # 显示第3个到最后一个字符 print(str[2:]) # 显示倒数第一个字符 print(str[-1]) # 显示从第二个开始到第五个且每隔两个的字符 print(str[0:5:2]) # 显示字符串两次 print(str * 2) # 字符串拼接 print(str + 'dong') # 加“\”转译(\n:换行) print("abc\ndef") # 加“r”取消转译 print(r"abc\ndef") # 例子 # 敏感词替换 st...
1c1021a7fc02ab2c1e6edc43d90906ceec3c49f8
skpycoder786/OS_ALGOs
/Bankers_Algorithm_avoidDL.py
4,373
3.984375
4
# Banker's Algorithm import numpy as np # Gathering Data : #-------------------------------------------------------- P=int(input("Enter the number of processes in system :")) R=int(input("Enter the types of Resources available for system :")) # Allocated Matrix print("Enter the allocated resources for ea...
a8394532f74b9fb04416e5d442e6dcef44022fa2
xcx03132316/xiechenxi
/1.python.py
693
3.984375
4
#10公里等于a英里 a=10/1.61 print(a) #b为每英里花费的时间 b=43.5/a print(b) #c为每小时所跑的英里数 c=60/b print(c) #------------------------------- #计算华氏度 def calcu(x): d=x*1.8; d=d+32; return d; print(calcu(39)) #------------------------------- num1=17/2 print(num1) #width/2的值 8.5 浮点型 num1=17/2.0 print(num1) #width/2.0的值 ...
a2fc2b74370e78be55935921f549a4de6f221057
Ludusamo/offsec
/recurse/test.py
388
3.625
4
def pseudo_fib(n): if n == 0: return 1 if n == 1: return 2 return pseudo_fib(n - 1) + pseudo_fib(n - 2) def find(x=0, y=45, expected=116369): s = x * 1597 + y * 2584 if s == expected: return (x, y) if s < expected: return find(x + 1, y, expected) if s > expected: ret...
84c9da9790ad1383cfc77b97eae344c29a64d627
dongyifeng/geekcode
/recursion/chapter5.py
2,076
4.03125
4
# coding: utf-8 ################################################################ # 思考题 Python 实现 ################################################################ import copy import math def get_product_factors(n): """ get product factors of n """ if n <= 0 or not isinstance(n, int): return [] ...
89a568f79f10a3bf0370d01f195813475979832a
akeeton/leetcode-python
/0283-move-zeroes.py
1,676
4.1875
4
""" Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. Example: Input: [0,1,0,3,12] Output: [1,3,12,0,0] Note: You must do this in-place without making a copy of the array. Minimize the total number of operations. """ class Solution...
ed6ff6bb7a063a3a51165bc3343e505d893cd9bb
akeeton/leetcode-python
/0070-climbing-stairs.py
846
4.09375
4
class Solution: def climbStairs(self, num_steps): """ :type num_steps int :rtype: int """ ways_to_climb_two_fewer_steps = 1 ways_to_climb_one_fewer_step = 2 ways_to_climb_n_steps = None for n in range(3, num_steps + 1): ways_to_climb_n_st...
c2296408acf27bed903d278463688ce20f31674d
akeeton/leetcode-python
/0035-search-insert-position.py
1,408
3.84375
4
class Solution: @staticmethod def binary_search(nums, target, index_left, index_right): """ :type nums: List[int] :type target: int :type index_left: int :type index_right: int :rtype: int """ length = index_right - index_left + 1 if lengt...
5a7860c7df711092b21b2b2d191c34df0f8d128d
c820306/Leetcode_practice
/002. Add Two Numbers.py
1,577
3.671875
4
""" Question Description You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, e...
b95db44bfaba81cc80c1a6bf802a702fbe6fcb00
threebodyyouzi/python_exercise
/day01/guess.py
431
3.875
4
#!/usr/local/bin/python3.6 import random _answer=random.randint(1,100) _count=5 i=0 while i < _count: _guess=int(input("请输入猜的数字:")) if _guess < 1 or _guess > 100 : print("超出范围") elif _guess < _answer : print("猜小了") elif _guess > _answer : print("猜大了") else : print("猜...
e2f6a4410585269526abb2e3af2c7b986d5de8b0
threebodyyouzi/python_exercise
/day06/text_yield.py
182
3.703125
4
def mygen(): a=10+20 yield a yield "hello world" b=a*10 yield b print(mygen()) print(mygen().__next__()) for item in mygen(): print(item) print(type(mygen()))
6e9fd52209aee328ee64f3001b24a23b3153894b
threebodyyouzi/python_exercise
/day06/text_bianliang.py
452
3.625
4
# x=10 # def fun1(): # y="hello" # print(y) # # def fun2(): # x="world" # print(x) # # fun1() # fun2() # print(x) # def fun3(): # global x # x="good" # print(x) # fun3() # print(x) # a=range(1,100) # def fun1(): # len=1 # print(len) # fun1() # print(len) from functools import partial...
99d9c6a20c1adfaf98c0c9f754849695dcb4144d
threebodyyouzi/python_exercise
/day05/text_dict.py
590
3.5
4
#!/usr/local/bin/python3.6 print(dict([("a","b"),("c","d")])) print(dict(["ab","cd"])) print({}.fromkeys(["a","b","c"],1)) adict=dict([("name","sam"),("age",18)]) print("bob" in adict) print("name" in adict) print(len(adict)) for key in adict: print("%s:%s" % (key,adict[key])) print("%(name)s is %(age)s years old...
cc2846a57f1acd13096e560a377f16c2fa5341e5
kkyaruek/project-euler
/python3/test_037.py
969
3.546875
4
from time import time import test_prime as prime import test_runner as runner def solve(): answer = 0 count = 0 num = 7 while count < 11: num = num + 2 if '4' in str(num) or '6' in str(num) or '8' in str(num): continue if is_right_truncatable_primes(num) and is_left...
34f5d1e45f704bf3a4acde63d437528496be6afb
kkyaruek/project-euler
/python2/divisor.py
571
3.71875
4
from math import * def acquire_num_of_divisors(n): count = 0 for i in range(1, int(sqrt(n)) + 1): if n % i == 0: count = count + 1 if int(sqrt(n)) * int(sqrt(n)) == n: return count * 2 - 1 return count * 2 def acquire_sum_of_proper_divisors(n): if n == 1 or n == 2: ...
fc9e6923c77d2cda67b813eabbb32ea95c16c027
Anz131/luminarpython
/flow controls/looping/while demo.py
302
3.8125
4
#print 10 to 0 # i=10 # while(i>=0): # print(i) # i-=1 #multiplication table # num=int(input("Enter a no : ")) # i=1 # while(i<=10): # print(num,"*",i,"=",num*i) # i+=1 #print nos upto the limit num=int(input("Enter the limit : ")) i=1 while(i<=num): print(i) i+=1
6c95bab093d5cb67e872e983c0f7b0e0701ae04e
Anz131/luminarpython
/polymorphism/method overloading.py
327
3.796875
4
#method overloading - same method name diff args #python dosnt support overloading class Person: def show(self,num1): self.num1=num1 print(self.num1) class Student(Person): def show(self,num2,num3): self.num2=num2 self.num3=num3 print(self.num2,self.num3) st=Student st.sh...
befe8ad00aeee1aa01ca15972fd2531a456fe481
Anz131/luminarpython
/inheritance/inheritance.py
4,459
3.953125
4
#single inheritance # class Person: #superclass/baseclass/parentclass # def persondetails(self,name,age,gender): # self.name=name # self.age=age # self.gender=gender # print(self.name) # print(self.age) # print(self.gender) # class S...
5a7355772688b12e1897a208b6f3677ac36260e2
Anz131/luminarpython
/Functions/functional programming/map.py
397
4.21875
4
# map to cover evey data in a list # arr=[2,3,4,5,6] # # #find squares # # def square(num): # return num**2 # #map(function?,iterable) # # squarelist=list(map(square,arr)) # print(squarelist) # arr=[2,3,4,5,6] # # squarelist=list(map(lambda num:num**2,arr)) # print(squarelist) # lst=["anu","appu","achu","kunju"...
6094d89d1ff336e460510511b705af6f86e12cd3
Anz131/luminarpython
/flow controls/age calcu using dob.py
683
4.09375
4
# current year # current month # current date # dob year # dob month # dob date # calculate age cyear=int(input("Enter current year : ")) #2021 cmonth=int(input("Enter current month : ")) #03 cday=int(input("Enter current day : ")) #25 print(cday,"/",cmonth,"/",cyear) #25/03/2021 byear=int(input("Enter birth year : "...
d914d285d00436e9698b339b1026266532d5179e
Anz131/luminarpython
/identifiers/print stmt1.py
140
3.5
4
name=input("Enter your name : ") age=input("Enter your age : ") quali=input("Enter your qualification : ") print(name,"\n",age,"\n",quali)
96bfd4a245c0f7c4d2065b9e43afe1c8c44f0f6d
mateuszklinowski/LearnPythonTheHardWay
/ex21/ex21.py
267
3.75
4
def add(a,b): return a + b def subtract(a,b): return a - b def multiply(a,b): return a * b def divide(a,b): return a / b age = add(30,5) height = subtract(78,4) weight = multiply(90,2) iq = divide(120,2) print(f"{age}, {height}, {weight}, {iq}")
d536d23c6fa6392d41490e7c98aa99d0172e20c8
mateuszklinowski/LearnPythonTheHardWay
/ex13.py
417
3.625
4
from sys import argv #read the WYS section from how to run this script, first, second, third = argv #ok so argv reads the arguments when i run the script # so i run it now like: # python ex13.py one two three # and the ex13.py one tho three are the args i unpack from argv print("script ", script) print("first ", fir...
8ffc3a56230e6792be9c94575e2cc7c52d7f9086
Seeed-Studio/grove.py
/grove/grove_mech_keycap.py
4,461
3.578125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # # The MIT License (MIT) # # Grove Base Hat for the Raspberry Pi, used to connect grove sensors. # Copyright (C) 2018 Seeed Technology Co.,Ltd. ''' This code is for - `Grove - Mech Keycap <https://www.seeedstudio.com/Grove-Mech-Keycap-p-3138.html>`_ which is a mecha...
9990b682d02db0132a89553ec0f3a0e03e6463b8
TidalPaladin/twitlib
/twitlib/util.py
722
3.65625
4
import json import re def list_media(status): """ Lists media URLs in a twitter.Status object Args === status : twitter.Status Status object to extract media from Return === list(str) : List of URLs or [] if the status has no media """ media = status.media return [...
4f0ea4076698d4a7758e7b36ee55037536cdf30f
PHPirates/SolArduino
/Raspberry-Pi/src/panel_control/panel_mover.py
3,283
3.5
4
from src.emergency import Emergency from src.panel_control.solar_panel import SolarPanel from util.stoppable_timer import StoppableTimer class PanelMover: """ This class can move the solar panels up or down, and checks whether that is allowed or not. To avoid confusion, only one instance of this class...
92f50163bb52f515b2116525a75b49f439af0b58
Bartamel/Exercism
/scrabble-score/scrabble_score.py
835
3.578125
4
def score(word): one_point = ["a", "e", "i", "o", "u", "l", "n", "r", "s", "t", "A", "E", "I", "O", "U", "L", "N", "R", "S", "T"] two_point = ["d", "g", "D", "G"] three_point = ["b", "c", "m", "p", "B", "C", "M", "P"] four_point = ["f", "h", "v", "w", "y", "F", "H", "V", "W", "Y"] f...
8eaa6af8e3088ff124ce860a14c94b5bec0e8159
xdze2/OSM_et_Wikidata
/osmandwiki.py
1,196
3.578125
4
import requests from urllib.parse import unquote def imgUrlToFilename(url): ''' Takes an url as "'http://commons.wikimedia.org/wiki/Special:FilePath/Douaumont%20au%20Printemps.jpeg'" and return the string: "Douaumont au Printemps.jpeg" - used to feed the function 'getThumburl' ''' ...
2319f0735e3516b43da4890f2682fc9d9055868f
harekrushnas/python_practice
/guess_the_number.py
1,513
4.21875
4
#The program will first randomly generate a number unknown to the user. The user needs to guess what that number is. # Reference link : https://knightlab.northwestern.edu/2014/06/05/five-mini-programming-projects-for-the-python-beginner/ import random #from colorama import* ran = random.randint(0,1000) #len1=len(str(...
6006318c375be32d879762066e6674fa4619d5ac
Janek-ai/s23882
/zad3.py
358
3.640625
4
print("Aby się zalogować wpisz login i hasło") login=input("Wprowadz login: ") login_wlasciwy="misu" haslo_wlasciwe="abc123" if login = login_wlasciwy else print("Taki użytkownik nie istnieje") print("Teraz proszę wprowadzić hasło") haslo=input("Wprowadz haslo: ") if haslo=haslo_wlasciwe print("Logowanie") else pri...