blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
bb1c9a9495d4808c4083d1ad214fe81975ba043b
itsolutionscorp/AutoStyle-Clustering
/intervention/results/1114011_1447543523_15_4_3.71.py
412
3.75
4
def num_common_letters(goal_word, guess): without_repeats = set(guess) return sum([1 for letter in without_repeats if letter in goal_word]) Positive Hints ...using a call to len....using a binary operation (<<, >>, &, ^, ~, |). Try to combine it with you call to set.. Negative Hints ...not using a call to s...
cca02813166a286e43e64f7bf7756e60ca703d9a
AiZhanghan/Leetcode
/code/399. 除法求值.py
2,756
3.71875
4
from collections import deque class Solution: def calcEquation(self, equations, values, queries): """BFS Args: equations: list[list[str]] values = list[float] queries = list[list[str]] Return: list[float] """ ...
2a56c8597a98fe209c909c9ea8b8e69ff39d1495
ummmh/price_comparer
/02_get_products_v2.py
1,135
3.890625
4
"""Component 2 of Price Comparer Get a list of products with their volume and price for comparison Created by Janna Lei Eugenio 3/08/2021 - Version 2 - checks for valid input and re-asks """ # Not Blank Function def not_blank(question, string, error): letter = False while True: ask = input(question) ...
beafb9815c12833c668b9e2b50053548dfa0d8e1
jdanray/leetcode
/groupThePeople.py
1,269
3.65625
4
# https://leetcode.com/problems/group-the-people-given-the-group-size-they-belong-to/ class Solution(object): def groupThePeople(self, groupSizes): N = len(groupSizes) people = sorted(range(N), key=lambda i: groupSizes[i]) res = [] i = 0 while i < N: sz = groupSizes[people[i]] res.append([]) while...
52daea189ad2690bce0fa8a5ceaa7d85b767042d
Sanyarozetka/Python_lessons
/Lesson_05/tuples.py
372
3.609375
4
tup = () print(tup, type(tup)) tup = tuple("Hello World!") print(tup, type(tup)) lst = list(tup) print(lst, type(lst)) tup = (1, 2, 3, 4, 4.6, 'test', False) print(tup, type(tup)) t1 = (1, 2, 3) t2 = (4, 5, 6) t3 = t1 + t2 print(t3) t4 = t3 * 4 print(t4) t5 = 50, 68, 78 print(t5, type(t5)) a, b, c = t5 print(a, b...
e03a861c2ec2f195291a837184e0f40df0b94043
Jesuvi27/Best-Enlist-2021
/task7.py
957
4.3125
4
1)Create a function getting two integer inputs from user. & print the following: Addition of two numbers is +value Subtraction of two numbers is +value Multiplication of two numbers is +value Division of two numbers is +value Here the value represents math function associated Ans: print("Input value of x and y") x,...
462557988f46d5c0aa2220543d90eff324281241
gcyantis/AoC2017
/day19.py
2,211
3.53125
4
class MapRunner: directions = { 'N':(0,-1), 'S':(0,1), 'E':(1,0), 'W':(-1,0) } def __init__(self, file=''): self.diagram = MapRunner.getMap(file) self.letters = [] self.x = self.diagram[0].index('|') self.y = 0 self.heading = 'S' ...
7459ad08f31a9fce0089d3c8d88b1e8272cc8314
EkaterinaRosnovskaya/infa
/lab3/3_draw.py
8,111
3.84375
4
#!/usr/bin/python # -*- coding: utf-8 -*- import pygame from pygame.draw import * pygame.init() FPS = 30 screen = pygame.display.set_mode((400, 400)) # Colours for the picture BRIGHT_GREEN = (0, 200, 0) BLUE = (0, 200, 255) GRAY = (200, 200, 200) GREEN = (0, 150, 0) LIGHT_GREEN = (0, 200, 0) PINK = (255, 192, 203) ...
c8ae657ae6adb6cdd0f5670f8be770167f7ac89d
mahmudz/UriJudge
/URI/URI/1865.py
219
3.609375
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 21 00:24:54 2017 @author: Matheus """ n = int(input()) for i in range(n): a,b = input().split() if(a == 'Thor'): print ("Y") else: print ("N")
5ebacaf54b134dae753df7213cee31133c9d0d92
Acebulf/gsoc-examples-ims
/programming_examples/circuit_sim/classes.py
3,936
4.0625
4
# -*- coding: utf-8 -*- # Copyright 2013, Patrick Poitras (acebulf at gmail dot com) # License : Creative Commons Attribution 3.0 Unported (CC BY 3.0) class NodeContainer: """ Container for nodes. Stores the nodes in a dictionary where the position is the key, represented as a tuple (x,y) or (x,y,z) and th...
616c3e8f63ae4f1b46c568c117158c49d26c444f
mhoff73/Python
/ball.py
1,479
4.0625
4
import pygame #initialize all modules in pygame pygame.init() #defining colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = (255, 0 , 0) BLUE = (0, 0, 255) #set width and height of the screen (x,y) size = (700, 500) #creates the screen screen = pygame.display.set_mode(size) #include an capti...
cc2a01df4dae2283e13450f578365d3da083c630
pseudo11235813/Random-Python-Ciphers
/DETECTENGLISH.py
1,813
3.859375
4
#Self-dev English Detector #you need to download an English dictionary Text File to use this module #go to google or any search engine and download an English Dictionary File #a one you can use : #import the module first then use the funcs. #nltk Englishletters = "abcdefghijklmnopqrstuvwxyz" fullEnglishLetters = Eng...
8f1f6e270019c77578747926a3d713249823fe71
Pato38/EDI
/ejercicios python-1/supermercado corte de control.py
553
3.671875
4
marca=input() codigo=int(input()) prod=input() stock=int(input()) precio=int(input()) while(codigo!=-1): if(marca==x): cant_prod=0 prod=1 cant_prod=prod+1 print("la cantidad de productos x es: "(cant_prod)) if(stock==0): stock=prod print("el producto con o stock es: "(prod)) digito=1 if(digi...
4571bd56887f2c982cf77cf841e6a97b38942016
mahesh-keswani/data_structures_algorithms_important_problems
/majority_element_in_array.py
1,256
4.34375
4
# Using Moore's voting algorithm # Majority element is element, whose count > len(array) / 2 # idea is, keep track of count of current element, if (i + 1)th element is equal to ith element # then increase the count, if not equal then decrease the count by 1, if count = 0, then keep track of current element # count and ...
68b8d8ccc5d19f324bb703212193cf0ebceab7b5
emejia01/SoftwareEngineeringTest
/Classes/EmployeeClass.py
601
3.5
4
EMPLOYEE_ID_NUMBERS = [100, 101, 102, 103] class Employee: def __init__(self, first_name, last_name): self.firstName = first_name self.lastName = last_name # Generate ID number from current list. self.ID_number = EMPLOYEE_ID_NUMBERS[-1] + 1 EMPLOYEE_ID_NUMBERS.append(sel...
06a5e715c7085dc5b051ff75a8ea8a93b98bb0c3
ALOHAWORLD7/mycode
/iftest2/ipask2.py
624
3.921875
4
#!/usr/bin/env python3 ipchk = input("Apply an IP address: ") # this line now prompts the user for input IPvalidated = False try: ipaddress.ip_address(ipchk) IPvalidated = True except ValueError: IPvalidated = False # if user set IP of gateway if ipchk == "192.168.70.1": print("Looks like the IP add...
5d71257ebdb31678891d8cfabb6f27c977da5280
csu-anzai/draw_path
/path/compute_distance.py
597
3.859375
4
encoding = 'utf-8' def get_distance(p1, p2): distance = abs(p1[0] - p2[0]) + abs(p1[1] - p2[1]) return distance def get_arr_distance(arr): arr_sum = 0 for i in range(len(arr) - 1): arr_sum += get_distance(arr[i], arr[i + 1]) return arr_sum def get_all_distance(arr): total_sum = 0 ...
be8b28fcfd6c0af6dbe658418b1ceba4362e1508
in8inity/1
/collection_of_procedures.py
3,450
3.609375
4
''' This module is a collection of small procedures used as solutions to multiple tasks from the CheckiO.org site. I believe these short pieces of code can show my style of coding in Python. All the solutions are authentic, not copied ''' def brackets(expr): '''Find if all the brackets were closed in expr ''' ...
b568e5f86cdcf67f357e868222ad1066f4b6bb97
realpython/materials
/top-python-game-engines/pygame/pygame_basic.py
1,525
4.5
4
""" Basic "Hello, World!" program in Pygame This program is designed to demonstrate the basic capabilities of Pygame. It will: - Create a simple game window - Fill the background with white - Draw some simple shapes in different colors - Draw some text in a specified size and color - Allow you to close the window """ ...
0090d56a5b6e20962f617ed3b25881abce28c837
aziddddd/SIR-model
/GOL.py
5,543
3.625
4
# Python code to implement Conway's Game Of Life import argparse import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation import datetime # setting up the values for the grid ON = 255 OFF = 0 vals = [ON, OFF] def randomGrid(N): """returns a grid of NxN random values...
c18c14491ddb43604b7784304eaafc755446f5fe
MiltzJrr/Python-shuffle
/shuffle (alpha).py
794
3.765625
4
# Python program to shuffle a deck of card using the module random and draw 5 cards # import modules import itertools, random, time L="" def riffle_once(L): L = list(itertools.product(range(1,20),[ " alpha " , " beta " , " gamma " , " delta " , " epsilon " , " zeta " , " eta " , ...
0f21f30020a5d777e3881f7a0590514cb6f7281d
tazbingor/learning-python2.7
/python-basics/unit10-class/py089_create_class.py
745
3.625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 17/12/11 下午8:29 # @Author : Aries # @Site : # @File : py089_create_class.py # @Software: PyCharm ''' 定义类 ''' class MyClass(object): # 构造函数 def __init__(self, name, age): self.name = name self.age = age def personal_inform...
162936d48ce192f601e60fe8c191c70fbe81d4a8
appleboy919/python_tutorial
/Structured_Data/list_and_tuple.py
287
3.796875
4
def print_list(o): for i in o: print(i, end=' ', flush=True) print() # list is mutable list_a = ['a', 'b', 'c'] print(', '.join(list_a)) # output: a, b, c print_list(list_a) #tuple is immutable tuple_a = ('1', '2', '3') # tuple_a.append('4') # this occurs an error
16f1a8addd7274dd6317e2425cae6c22569d38a3
biki234/PythonNotes
/basics/ifelse.py
719
4.0625
4
""" Decision Making: If Elif Else """ #Input from Keyboard age = int(input("Enter your age: ")) #Type casting String input to Int print("Age :",age) #If Block if age <= 20: print("Age is < or = 20") elif age>20 and age<=30: #condition and condition == TRUE (both), condition or condition == any one c...
c1b0225a114dc4ac04fc576eae51818e61c98811
Pigoman/Lehman_College
/Learning_Python/cw/02_08_17_cw3.py
125
4.09375
4
#!/usr/bin/env python3 numRepeat = input("Enter a number:") numRepeat = int(numRepeat) for i in range(numRepeat): print(i);
27762f08095c8a78391d3d660a5999b34784ea08
kcjavier21/Python-Course
/DataStructures.py
4,021
4.03125
4
import os os.system('cls') # === LISTS === # letters = ["a", "b", "c", "d"] # matrix = [[0, 1], [2,3]] # zeros = [0] * 5 # combined = zeros + letters # numbers = list(range(5, 20)) # chars = list("Hello World") # print(chars) # === Accessing Items === # letters = ["a", "b", "c", "d"] # letters[0] = "A" # print(lett...
9c509c64cd02126603f62d11c2ef76cc802516ed
tywins/TC1014
/funWithNumbersFunction.py
792
4.09375
4
#Paulina Romo Villalobos #This program sums two integers given by the user def integersum (a,b): ans = a + b return ans; def integerdiff (a,b): ans = a - b return ans; def integerprod (a,b): ans = a * b return ans; def integerdiv (a,b): ans = a / b return ans; def integerrem (a,b): ...
cea980605c4849ea03a44d0a330aea621b40e8bd
laurencesk/DojoAssignments
/Python and Django/Python/compareLists.py
454
3.609375
4
list_one = ['celery','carrots','bread','milk'] list_two = ['celery','carrots','bread','cream'] lenList1 = len(list_one) lenList2 = len(list_two) identical = 0 if lenList1 == lenList2: for i in range(0,lenList1): if list_one[i] == list_two[i]: identical+=1 if identical == lenList...
ce749607218024b855309efc12e375deba9fc8a9
maxtong9/smart_meetings
/python_server/word_to_num.py
1,747
3.765625
4
nums = { "first": 1, "one": 1, "second": 2, "two": 2, "third": 3, "three": 3, "fourth": 4, "four": 4, "fifth": 5, "five": 5, "sixth": 6, "six": 6, "seventh": 7, "seven": 7, "eighth": 8, "eight": 8, "ninenth": 9, "nine": 9, "tenth": 10, "ten": 10, "eleventh": 11, "eleven": 11,...
4192da75ccc4507d1b46dc402c7234b9274e0b27
bakmaks/Algorithms
/Жадные алгоритмы/my_binary_heap.py
6,016
3.609375
4
# Задача на программирование: очередь с приоритетами. # # Первая строка входа содержит число операций 1 <= n <= 10^5. # Каждая из последующих nn строк задают операцию одного из следующих двух типов: # Insert x, где 0 <= x <= 10^9 — целое число; # ExtractMax. # Первая операция добавляет число x в очередь с приоритетами...
df49d9ad3ec4b1eb762822dd6b170c9fe2a1b33f
cavillag/myrepo
/ALGORITHMS/ring_buffer.py
1,273
3.765625
4
#### The below code implements a Ring Buffer as requested by LeetCode Stack data structures lesson 1 from collections import deque class MyCircularQueue: def __init__(self,length): self.length=length self.que=deque([]) def enQueue(self,enq): if len(self.que) == self.length: ...
9c7bd6f1e9cd2c7dec689ad2f6ecf4bb981b9714
vikumsw/Algorithms_For_Problem_Solving
/Solutions/CounttheIslands.py
1,136
3.90625
4
''' Challenge Count the Islands: This problem was asked by Amazon. Given a matrix of 1s and 0s, return the number of "islands" in the matrix. A 1 represents land and 0 represents water, so an island is a group of 1s that are neighboring whose perimeter is surrounded by water. For example, this matrix has 4 islands. ...
0a430665b0c0cfa9fe1beef459da3d3c77238a62
teofanesowo/pythonkk
/Python46.py
237
3.765625
4
# inversão numero = int(input('Digite um numero de 0 a 999: ')) centena = str(numero//100) dezena = str((numero%100)//10) unidade = str(numero%10) valorreverso = unidade + dezena + centena print('Valor inverso: {}'.format(valorreverso))
8d7e7c74d9760802c1bf7d32f19354a6324421dc
hyunjun/practice
/python/problem-linked-list/reverse_a_doubly_linked_list.py
789
4.09375
4
# https://www.hackerrank.com/challenges/reverse-a-doubly-linked-list class DoublyLinkedListNode: def __init__(self, data): self.data = data self.next = None self.prev = None def reverse(head): p, c = None, head while c: n = c.next if p: p.prev = c ...
839201b5c12c2147bcb0ab7d55d1855656d54e64
LIKELION-VN-WORKS/class-stuffs
/week3-2/python_fundamentals/6_For_while_format.py
147
3.609375
4
#for loop format for i in range(1,11,1): print(i) print('\n') # line space #while loop format k=1 while(k<=10): print(k) k+=1
550ed86e6c6f745bfa8a9432c8dd9f40bd965119
rahulcs754/100daysofcode-Python
/code/files/62.py
371
3.875
4
# Python code to illustrate # chaining comparison operators x = 5 print(1 < x < 10) print(10 < x < 20 ) print(x < 10 < x*10 < 100) print(10 > x <= 9) print(5 == x > 4) # Python code to illustrate # chaining comparison operators a, b, c, d, e, f = 0, 5, 12, 0, 15, 15 exp1 = a <= b < c > d is not e is f exp2 =...
7db63d39bc66c31b3b811e05f3b3a2d68e279b5d
Priyankk18k/BlueStacks-Assignment
/main.py
7,016
3.75
4
import time import json class Admin: def __init__(self, user_name='priyank'): self.user_dict = self.read_json_file() self.main(user_name) def read_json_file(self): with open('user_data.txt') as json_file: data = json.load(json_file) print(data) ...
91e9c1470ff7930b047886fd8e99c0f3c0d72e6b
vattikutipujitha/Pythonprograms
/Program30.py
310
3.890625
4
#prime numbers in given range r = int(input("Enter upper range: ")) for num in range(1,r + 1): if num > 1: for i in range(2,num): if (num % i) == 0: break else: print(num) """ OUTPUT: Enter upper range: 5 2 3 5 """
c722fba16963f7cd3628e51f432bcf13357c4024
ClementeCortile/Basic_Software_Engineering
/1_Structure_and_Modules/main.py
1,297
3.84375
4
#The program will run from this main file ( C style!) #Read every comment from top to bottom #Try running the file from the terminal with | python3 main.py | command #Python modules are imported from import sys #print(sys.path) #Importing modules import os import numpy as np os.getcwd() #...but we can import our o...
fc7b911d72b96eba02168dc5393b6251f34900d8
Joysingh1709/python3
/elesum.py
154
4
4
list1=[10,20,34,65,32,21,74,24,13] summ=0 for ele in range(0,len(list1)): summ=summ+list1[ele] print("Sum of the elements of list is : ",summ)
ea9598a62d5ddcf330dca316b5729ccbf6c11fa9
ophirSarusi/Yazabi
/scrape.py
2,345
3.546875
4
import requests from bs4 import BeautifulSoup def find_songs(artist): """ (url, artist) -> songs Returns the names of the songs in the input artist latest (non-empty) setlist, by requesting an XML file from given URL and parsing the text. Args: artist: A string containing the n...
f8b530fea992d19074533ebb500629f2be468a0d
willyii/CS235-New-York-Airbnb
/KNN/KNN_demo.py
648
3.578125
4
from KNN.KNN_cs235 import KNN import numpy as np import pandas as pd from sklearn.model_selection import train_test_split if __name__ == '__main__': # Generate the random dataset. The label equals to the sum of every feature plus the noise dataset = np.random.rand(5000, 60) label = np.sum(dataset, axis=1)...
24cdeed56354ee819af042c18c5a1fb89d1f58ae
xiaonanln/myleetcode-python
/src/Merge Intervals.py
890
3.859375
4
# Definition for an interval. # class Interval: # def __init__(self, s=0, e=0): # self.start = s # self.end = e class Solution: # @param intervals, a list of Interval # @return a list of Interval def merge(self, intervals): intervals = [ [i.start, i.end] for i in intervals] ...
9f8e137edd33a6db9eb695c62377019e7ab51214
lucascoelho33/ifpi-ads-algoritmos2020
/ATIVIDADE G - FÁBIO 2b - CONDICIONAIS/fabio2b_q10.py
1,137
3.671875
4
#10. Leia as duas notas parciais obtidas por um aluno numa disciplina ao longo de um semestre, e calcule a sua média. #A atribuição de conceitos obedece à tabela abaixo: #Média de Aproveitamento Conceito #Entre 9.0 e 10.0 A #Entre 7.5 e 9.0 B #Entre 6.0 e 7.5 C #Entre 4.0 e 6.0 D...
770ba7493c7c1981f0cd1dd4aa16f76121e90d25
Zinko17/FP
/list.py
2,474
4.09375
4
# Неизменяемый список # my_list = [1,2,3,4,5] # my_tuple = (1,2,3,4,5) # my_tuple.count() # print(my_tuple) # criminals = ['johny', 'sparrow', 'harry', 'jack', 'selena'] # # name = input("Enter the name:") # if name not in criminals: # criminals.append(name) # print(criminals) # import random # i = 0 # user_info...
679aee38b1258678a2d457875f47549dce336ef1
nilavann/HackerRank
/Python/itertools/itertools.combinations_with_replacement().py
286
3.515625
4
#!/bin/python3 from itertools import combinations_with_replacement s, n = input().strip().split() # loop combinations_with_replacement() conv tuple to string, unpack print( *[ "".join(element) for element in combinations_with_replacement\ ( sorted( s), int( n))], sep = "\n")
f6abac58ffcdccb6f73c77b6dbf607581a644314
berkozdoruk/Python
/Sort Compare.py
3,339
4.09375
4
# Compare Sorts # selection_sort # insertionSort # bubblesort # short_bubble_sort # quickSort # mergeSort # import random import time def selection_sort(a_list): for i in range(len(a_list) - 1, 0, -1): max_pos = 0 for location in range(1, i + 1): if a_list[location] > a_list[max_pos]: ...
7047ad569795533001a503c36bc3e48de4cf11a4
davidedr/aiplan
/MissionariesAndCannibals/src/MissionariesAndCannibals.py
6,826
3.96875
4
''' Created on Jan 11th, 2015 @author: davide ''' import copy import Queue import sys N = 3 GOAL_STATE = (0, 0, False, N, N) def missionaries_and_cannibals(): """Solve the "Missionaries and Cannibals" problem """ closed = [] start_state = (N, N, True, 0, 0) plan = [] s...
08baf6aa61d31aaceea557fb106417d9873c0c77
MaggieWensiLyu/csc1002
/1002tut3#4.py
193
3.640625
4
n= int(input("please input a number:")) k = n-1 i = 1 direction = 1 for i if i%7==0 or str(i).find("7") : direction= - direction else: pplist=range(i,0,-1) print(pplist[k])
5e4decaf42cbe2364d99c37493278cc9508f86ce
jorgegilberto/python
/leia_4_notas_mostre_medias_tela.py
641
3.78125
4
# fazer um programa que leia 4 notas, mostre as notas e a média na tela. ''' x = 0 vetor = [] media = 0 total=1 while x < 4: nota=float(input("Nota: ")) vetor.append(nota) media = media + vetor[x] x+=1 total=media/4 print("A media foi: ", total) print("As notas: ", vetor) ''' # outra forma de se resolv...
48e7c0a2e0df1d820181cdc810bb3dbd9f561c6c
Chunzhen/leetcode_python
/problem_10.py
1,549
3.5625
4
#! /usr/bin/env python # -*- coding:utf-8 -*- !!! 未解决 class Solution(object): def isMatch(self, s, p): """ :type s: str :type p: str :rtype: bool """ if len(s)==0: return True s_index=0 last_p=0 use_star=False for i in range(l...
7b5ec21947d8bd0dcb23555c6f518ad4eb81199d
lebrancconvas/Data-Playground
/dict.py
499
3.6875
4
grade = { "A": { "English": 3, "Math": 4 }, "B": { "English": 2, "Math": 3.5 }, "C": { "English": 4, "Math": 2.5 } } subject_weight = { "English": 2, "Math": 3 } student_gpa = [] for i in grade: sum_score = (grade[i]["English"] * subject_weight["English"]) + (grade[i]["Mat...
8ea0c423ddd9c4b151b954d697651a5023ab1185
mohamedhassan218/AlgorithmsUnplugged
/Topsort in python.py
884
4
4
from collections import defaultdict class Graph: def __init__(self,n): self.graph = defaultdict(list) self.N = n def addEdge(self,m,n): self.graph[m].append(n) def sortUtil(self,n,visited,stack): visited[n] = True for element in self.graph[n]: if...
0f9219e52351fc20c56d0a51abb09d81ac3a593b
Theanonymous-hub/Hacker_rank-for-python
/Division.py
582
4.28125
4
#The provided code stub reads two integers, and , from STDIN. #Add logic to print two lines. The first line should contain the result of integer division, // . The second line should contain the result of float division, / . #No rounding or formatting is necessary. #Input Format #The first line contains the first in...
9fca41af9deee8b08d993e3641126ceb5930954d
nwolthuis5/Phys304
/submitted_hw/hw_6/wolthuis_hw6_problem2.py
733
3.59375
4
# coding: utf-8 # In[1]: #Huge collaboration points to Katharine Bancroft print("problem 6.16") #defining constants accuracy = 10 G = 6.674 * 10 ** (-11) #m**3 kg **(-1) * s ** (-2) M = 5.974 * 10 ** 24 #kg m = 7.348 * 10 ** 22 #kg R = 3.844 * 10 ** 8 #m Rearth = 6.371 * 10 **6 Rmoon = 1.7371 * 10 **6 omega = 2.662...
3563e344c5c83de3a131ced704c66bcfcd5e8ff2
mrtong96/RPS
/gameset.py
1,577
3.78125
4
from cpu import CPU from human import Human class GameSet(): def __init__(self): self.p1 = None self.p2 = None self.moves = [] while True: p1 = raw_input('player 1: human or cpu?\n') if p1 == 'human' or p1 == 'cpu': break else: ...
6eb7f6192b1eb708410bfce4e5d0229e4057b5f4
Hesh5462/mrctest
/main.py
1,716
3.75
4
import time,sys vistor_list = [] vistor_cnt = int(0) work = True def in_or_out(vistor_cnt): print('Check in : 1\nCheck out : 2\nShow List : 3') choose = input('Check in or out:') if choose is '1' : return vistor_in(vistor_cnt) elif choose is '2': return vistor_out(vistor_cnt) elif ...
f74f926da298b0d9a206632511c0204430051c86
xzpjerry/learning
/Coding/playground/dynamic_change_maker.py
993
3.5625
4
import time coins = [1, 5, 10, 25, 50] def _get_change(coins, amount, last_coin, result): if amount >= last_coin: result[last_coin] += 1 _get_change(coins, amount - last_coin, last_coin, result) elif coins: current_max_coin = coins.pop() _get_change(coins, amount, current_max_c...
78a7e836028ead47bc78fc8549c7ee0834054407
AllisonBolen/Desserted-Drive
/Neighborhood.py
2,366
3.9375
4
from Home import * class Neighborhood(Observer): ''' The neighborhood is made up of homes laid out in a grid. When created, the neighborhood should automatically build houses and attach them to one another in a grid. The size of the grid is set when the neighborhood is created. ''' ...
158861d797d36e8cbe8d91aab2afc39179216b4d
UWPCE-PythonCert-ClassRepos/SP_Online_PY210
/students/anthony_mckeever/lesson1/task2/string-2.py
1,107
3.875
4
""" Programming In Python - Lesson 1 Task 2: Puzzles - String-2 Code Poet: Anthony McKeever Date: 07/20/2019 """ # String-2 > double_char def double_char(inString): output = "" template = "{0}{0}" for c in inString: output = output + template.format(c) return output # String-2 > count_hi def...
c6c7ae0f6e317c4a8b2300ac3938b14217270b09
Prateek-Chaudhary/python-projects
/health_management.py
4,548
3.78125
4
import datetime print("Health Management System") def rohanwrite(): def rdiet(): with open("rdiet.txt", "a") as rd: date = datetime.datetime.now() dt = input("Enter your food -\t") dd = str(date) + "\t" + dt + "\n" rd.write(dd) def rexerci...
f2b280fd92b8c2f70668ea7d36893304cfc290dc
bookwyrm12/adventofcode2017
/day12/day12.py
1,610
3.578125
4
############################# # Advent of Code 2017 # # Day 12: Digital Plumber # # April Jackson # ############################# # Get the data with open('day12.in') as f: data = f.read() # Helper method: Loop around circular list, from end to beginning def data_to_dict(data): data_dict...
904332f18ccd9e6f447e03f402a7f64309823c09
Alexis-Lopez-coder/PythonChallenges
/basic/03_main.py
250
3.671875
4
# Escribir un programa que la funcion acepte dos enteros, los divida y regrese el resultado con dos decimales # ademas del resto entre esos dos numeros def quot_rem(num1, num2): return round(num1 / num2, 2), num1 - num2 print(quot_rem(179, 176))
f92472550ddb524c263440915cc68493e9c94a5b
dariahazaparu/FMI
/Year I/Algorithms Programming in Python/Greedy/LAB 5/Minimizarea timpului mediu de așteptare.py
1,847
3.71875
4
# 1. Minimizarea timpului mediu de așteptare # Din fișierul “tis.txt” se citesc numere naturale nenule reprezentând timpii necesari pentru servirea # fiecărei persoane care așteaptă la o coadă. # Să se determine ordinea în care ar trebui servite persoanele de la coadă astfel încât timpul mediu # de așteptare să fie min...
17a9502b17f125974c6823c89bf01fca0f06fd38
marusheep/python-course-practice
/course-6-introduction-to-loops/6-9-factorial.py
528
4.25
4
# Programming Challenge: Factorial # # Create a function which takes one positive integer as its input and returns its factorial. # To make sure that your function works correctly, # you should call it with the inputs 3, 4, and 5 and print what is returned by those calls. # For those inputs, you should get 6, 24, and ...
2b3249eac731587bd4c362106b8b5d5bfdcf254f
Sharonbosire4/hacker-rank
/Python/Contests/Project Euler/euler_004/python_pe_004/__main__.py
1,037
3.65625
4
from __future__ import print_function import sys, operator palindromes = [] def pe_004(num): if len(palindromes) <= 0: find_palindromes() if palindromes[0] > num: return None for i in range(1, len(palindromes)): if palindromes[i] > num: return palindromes[i-1] def fi...
1d0710d64c04dacb5aed1d13d70dbd42de133c82
haole1683/Python_learning
/Python/2019-8-2-快排调试.py
5,664
3.765625
4
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> def MyQuickSort(data): if len(data) != 1: left = [] right = [] mid = data[len(data) - 1] data.remove(mid) for each in data: ...
e36e933b1897cc2130b8a632b1e296fa2798f9eb
varuncnaik/cs838-sp17
/stage2/code/join_reviews.py
1,529
3.796875
4
#!/bin/python """ Usage: python join_reviews.py yelp_restaurants.json yelp_users.json labeled_reviews.json > joined_reviews.json Prints each review, with additional keys "restaurant" and "user", to stdout. """ import json import os import sys from collections import OrderedDict def read_file(filename, key): ""...
9a81f65f9dde574a564bc31b4328292fe086e476
byasoares/pythonaula2
/exercicio1.py
573
4.125
4
listanome = [] listanota1 = [] listanota2 = [] listanota3 = [] aluno = 0 nota1 = 0 nota2 = 0 nota3 = 0 calculo = 0 def matricular(): aluno = (input("Digite o nome do aluno: ")) listanome = aluno nota1 = (input("Digite a primeira nota: ")) listanota1 = nota1 nota2 = (input("Digite a segunda nota: "...
be0e6e38060cfee00f0936b1819a67a7c8526f49
ankushsharma0904/Infytq-assignment-solution
/Programming Fundamentals using Python/Day-3/Assgn-26.py
818
3.640625
4
#PF-Assgn-26 def solve(heads,legs): error_msg="No solution" chicken_count=0 rabbit_count=0 flag = False #Start writing your code here #Populate the variables: chicken_count and rabbit_count for i in range(0, heads+1): x, y = i, heads - i head_test = x + y ...
24605b91aa79f8520715cddc91ec7f9523bb1520
Nil69420/Sudoku_Solver_Using_Graph_Coloring
/graph.py
2,206
3.8125
4
class Node: #constructor def __init__(self, idx, data=0): self.id = idx self.data = data self.connectedto = dict() def add_neighbor(self, neighbor, weight=0): if neighbor.id not in self.connectedto.keys(): self.connectedto[neighbor.id] = weight ...
ad8c31e19855dceebd3b525520b1e401ff65563f
Aarom5/python-newbie
/determinegender.py
175
3.6875
4
def gender(s='unknown'): if s =='m': print("Male") elif s =='f': print("Female") else: print(s) gender('f') gender('m') gender()
d62a0a5120827d15b4a551515ec5c504f57513bd
tchudi/hudi
/kyb_ui/app/cal.py
325
3.640625
4
# Calculator.py class calculator(object): def __init__(self, a, b): self.a = a self.b = b def add(self): return (self.a + self.b) def minus(self): return (self.a - self.b) def multip(self): return (self.a * self.b) def divide(self): return (self.a / se...
4611bed92f06de16f547172ecb0ad06c9c48a7ed
matthewatabet/algorithms
/sort/nuts.py
1,381
3.625
4
def ex(data, i, j): print '%s<=>%s %s' % (i, j, data) t = data[i] data[i] = data[j] data[j] = t print '==', data def partition(data, v, lo, hi): j = lo if data[lo] == v: ex(data, lo, hi) for i in range(lo, hi): print 'v=%s i=%s data[i]=%s lo=%s hi=%s' % (v, i, data[i],...
14245985cb6eced60b27c40e957e3ca838a6af7e
Conquerk/test
/python/day06/code/lianxi1.py
169
3.5
4
x=int(input("输入一个整数:")) y=int(input("输入一个整数:")) z=int(input("输入一个整数:")) l=[x,y,z] print(max(l)) print(min(l)) print((sum(l)/3))
f8ec8d76159daaed3a5ca376a549ab34714637ad
DanRud/PracticePython
/16_Password_Generator.py
320
3.734375
4
import random passLength = int(input('How many length password you need? Put a number: ')) s = "abcdefghijklmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()?" def generatePassword(passLength): password = ' '.join(random.sample(s, passLength)) return password print(generatePassword(passLength))
0906f10c76cc6849a82383d56ea959f2fb52a766
TangoMango223/PythonProjects
/Dice/dice.py
940
4.1875
4
#Python - 6 sided Dice Rolling Simulation import random #has the random function to randomize! import time #allow sleeping while True: times = int(input("How many times do you want to roll this dice? ")) if (times < 0): print("Oh, invalid number. Please try again.") else: break #Keep trac...
7fca9719076a50f4cbbf8d94d2a643f4450a7240
royabouhamad/Algorithms
/Sorting/BubbleSort.py
303
3.734375
4
numbers = [11, 2, 32, 9, 29, 0, 15, 40, 8, 1, 37] swapMade = True while swapMade == True: swapMade = False for i in range(0, len(numbers) - 1): if numbers[i] > numbers[i + 1]: numbers[i], numbers[i + 1] = numbers[i + 1], numbers[i] swapMade = True print(numbers)
4bff87b6b7562831878434c1b5e29a8be28e5abe
rayanaprata/uc-praticas-em-desenvolvimento-de-sistemas-II
/second-class/activity-3/main.py
287
4.0625
4
# Implementar um programa em Python que recebe um nome e sobrenome e escreva a quantidade de caracteres total. name = input("Type your name: ") lastname = input("Enter your last name: ") fullNameLen = len(name) + len(lastname) print(f'The name has {fullNameLen} characters in total.')
3d80b6a7e1c78b31679ab1c430e68060abbf5f5e
Lithrun/HU-jaar-1
/Python/IDP - MySQL version/sql_sportschool.py
1,933
3.5625
4
# MySQL settings username = 'benno' global databasename databasename = 'sportschool' password = '' host = '' # Einde MySQL settings import sqlite3 #import mysql.connector def createTables(): pass #def connectToDatabase(): # My SQL # cnx = mysql.connector.connect(user=username, password=password, # ...
0508333baf0901b2f1267ff0a3d3fb8878734fbe
ahmadsadeed/linkedIn-courses-exercises
/Python_design_patterns/Ch03/composite_final.py
3,077
4.4375
4
''' The composite design pattern maintains a tree data structure to represent part-whole relationships. Here we like to build a recursive tree data structure so that an element of the tree can have its own sub-elements. An example of this problem is creating menu and submenu items. The submenu items can have their ...
60e933ba6539d46f426ebc39d50b2901ddc333d1
aldrichwidjaja/CP1404PRAC
/PRAC_04/list_comprehensions.py
1,575
4.75
5
""" CP1404/CP5632 Practical List comprehensions """ names = ["Bob", "Angel", "Jimi", "Alan", "Ada"] full_names = ["Bob Martin", "Angel Harlem", "Jimi Hendrix", "Alan Turing", "Ada Lovelace"] # for loop that creates a new list containing the first letter of each name first_initials = [] for na...
b6c461d39417ac476cd971b7ae39c2b111fb4d3c
huit-sys/progAvanzada
/64.py
1,656
3.921875
4
# Ejercicio 64 #El 4 de febrero de 2013 fue el último día en que Royal Canadian Mint distribuyó centavos. #Ahora que los centavos se han eliminado, #los minoristas deben ajustar los totales para que sean múltiplos de 5 centavos cuando se pagan en efectivo #(las transacciones con tarjeta de crédito y débito se si...
a7be99cad8701343f5ab0e720e5655312d42924c
amitmeel/Machine_Learning
/Part 2 - Regression/Section 6 - Polynomial Regression/my_practice.py
1,546
3.90625
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('C:\\Users\\IBM_ADMIN\Desktop\\Machine_Learning_AZ\\Part 2 - Regression\\Section 6 - Polynomial Regression\\Polynomial_Regression\\Position_Salaries.csv') X = dataset.iloc[:, 1:-1].values y = dataset.il...
bbd9078ab7aabfe734d0032995933f5539428473
senthilkumaar/testcodes
/collection/ordereddict.py
199
3.734375
4
from collections import OrderedDict o=OrderedDict() o['a']=3 o['c']=1 o['b']=4 print(o) o.move_to_end('c',last=False) print(o) print(o.popitem()) o['d']=5 print(o.popitem(last=False)) print(o)
131ae0f3a8435b6794afdc0e2a14020bcf6b9898
sophmintaii/UCU_2term_homework
/modules/studentgroup.py
7,920
3.78125
4
""" Contains implementation of StudentGroup class. StudentGroup class is inherited from AgeGroup. """ from modules.agegroup import AgeGroup, test_input class StudentGroup(AgeGroup): """ Representation of StudentGroup, which is AgeGroup, but has additional parameters. """ def __init__(self, age, d...
439f20a83eabc7352fde9e1c592538161e2434d5
xiaohai0520/Algorithm
/algorithms/51. N-Queens.py
880
3.65625
4
一行一行往下backtrack 每次往下一行,都要检查当前列和两个斜对角 当最后一行也通过时,则加入结果集 class Solution: def solveNQueens(self, n: int) -> List[List[str]]: if n == 0: return [] res = [] row = set() pre = set() last = set() def dfs(i,path): if i == n: ...
ca5b6df59aef619935eac70bd132c82d60571d4e
matthewmazzanti/cmsc320finaltut
/pronounce.py
3,319
3.65625
4
import pronouncing import string from collections import defaultdict import re sentence = '''His palms are sweaty, knees weak, arms are heavy There's vomit on his sweater already, mom's spaghetti He's nervous, but on the surface he looks calm and ready To drop bombs, but he keeps on forgettin' What he wrote down, th...
64e83008576576b1a1da974729780c251728a57b
wzdnzd/leetcode
/python3/0124.二叉树中的最大路径和.py
1,742
3.640625
4
# # @lc app=leetcode.cn id=124 lang=python3 # # [124] 二叉树中的最大路径和 # # https://leetcode.cn/problems/binary-tree-maximum-path-sum/description/ # # algorithms # Hard (45.28%) # Likes: 1938 # Dislikes: 0 # Total Accepted: 319K # Total Submissions: 704.6K # Testcase Example: '[1,2,3]' # # 二叉树中的 路径 被定义为一条节点序列,序列中每对相邻节点...
35eca6be93c5b7df21cfc8a59f0fe039ec7ad699
kitkogan/python_sandbox
/dictionaries.py
802
4.125
4
# A Dictionary is a collection which is unordered, changeable and indexed. No duplicate members. # Simple dicionary person = { 'first_name': 'Jay', 'last_name': 'Cat', 'age': 40 } # Using a constructor # person = dict(irst_name='John', last_name='Doe', age=30) # Access value print(person['first_name']) p...
69b2f2da13bc89c63b12b13d2aee13a2314cd0b2
StevenGeGe/pythonFromIntroductionToPractice01
/com/chapter_08/section_03/task_8.3.2_functionChoose.py
1,272
3.71875
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2020/11/20 21:06 # @Author : Yong # @Email : Yong_GJ@163.com # @File : task_8.3.2_functionChoose.py # @Software: PyCharm # 让实参变成可选的 # 可选值让函数能够处理各种不同情形的同时,确保函数调用尽可能简单。 def get_formatted_name(first_name, middle_name, last_name): """返回整洁的姓名""" full_...
d9c522249e1a64c9f080568c8ecdf8ef528ff79e
estraviz/codewars
/6_kyu/Count the smiley faces/count_smileys.py
318
4
4
""" Count the smiley faces! """ def count_smileys(arr): return sum(1 for s in arr if is_a_smiley(s)) def is_a_smiley(s): eyes, noses, mouths = (':', ';'), ('-', '~', ''), (')', 'D') eye, nose, mouth = s[0], s[1:-1], s[-1] return True if eye in eyes and nose in noses and mouth in mouths else False
8e659039dd7c1ddd88904dae8a8569a24c094d12
chuckclift/progressMap
/progressMap.py
825
3.53125
4
#!/usr/bin/python3 import time def status_bar(function, iterable, status_label="status"): return_list = [] previous = 0 for i,val in enumerate(iterable): return_list.append(function(val)) percent = round(i / len(iterable), 1) out_of_ten = int(10 * percent) if out_of_ten != ...
cc7040e638be11399af56a187cfe8038a97669e3
lilyef2000/lesson
/01/input.py
765
3.71875
4
# -*- coding: utf-8 -*- #!/usr/bin/env python while True: input = raw_input("请输入你的姓名:") if input == 'lili': password = raw_input("请输入你的口令:") p = '1qaz2wsx' while password != p: print '错误的口令!重试一下吧' password = raw_input("请输入你的口令:") else: ...
bae4846bda4570c662d96abe099c4a9d8781ca5a
YamitCohenTsedek/ClientServerChatApplication
/client.py
936
3.625
4
# Client side import sys from socket import socket, AF_INET, SOCK_DGRAM def main(): # The first argument to main is the dest IP of the client (the source IP of the sever). dest_ip = sys.argv[1] # The second argument to main is the dest port of the client (the source port of the sever). dest_port = in...
b7d2e3de39aac2ef4fbe2c3813af6fc61e3d737b
peonyau/SPE10117-Information-System-lab3
/simple billing system.py
4,271
3.546875
4
''' Simple Billing System Created on Nov 20, 2020 @author: tchan ''' import fileinput import sys def displayFile(datafile): for line in fileinput.input(datafile): sys.stdout.write(line) def main(): instructions = """\nEnter one of the following: 1 to print the contents ...
4023a0b16ea0f77d17ad31ffe81517241f35d4b1
kaitey/AtCoder
/AtCoderBeginnerContest192/C.py
430
3.5625
4
def main(): n, k = input().split(" ") k = int(k) num = int(n) for i in range(k): target_num_asc = int(''.join(sorted(n))) target_num_desc = int(''.join(sorted(n, reverse=True))) new_num = target_num_desc - target_num_asc if new_num == num: print(new_num) ...
eb1ae07407d30df59c0cb0e56536b4096edf4d17
tsvetelinastef/ctci
/ch2-linked-lists/kevin/linkedlist.py
1,649
3.84375
4
class LinkedList: def __init__(self, head): self.head = head def __eq__(self, other): if not isinstance(other, LinkedList): return False self_ptr = self.head other_ptr = other.head while self_ptr and other_ptr: if self_ptr.value != other_ptr.value...
7eb2cdd06444e5a790be9fb3db824e5412d82c93
Maldonam8074/CTI110
/M2T1_SalesPrediction_Maldonado.py
680
4.03125
4
# CTI-110 # M2T1-Sales Prediction # Manuel Maldonado # 08/30/2017 # Suggested Variables: totalSales, annualProfit # ask the user for total sales totalSales = int(input("What were your sales?: ")) # calculate the profit amount annualProfit = 0.23 * totalSales # print the profit amount print ("the annua...
311b0c23726705a26fd4a84e71071baa18afef95
sandhiya2206/Python-Internship-files
/age.py
163
3.921875
4
days=int(input("please enter number of days:")) years=int(days/365) weeks=int(days%365)/7 print("The Age for",days,"days is",years,"years and",weeks,"weeks.")