blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
8e685d1337de9d07a0adce2fce008c64f3dcb9c8
wsnijder/PycharmProjects
/Week_6_Python/Exercise 3/5.3.23.6.py
185
3.546875
4
def scalar_mult(scalar, vector): outcomevector = [] for element in vector: outcomevector.append(scalar * vector) return outcomevector print(scalar_mult(3, [1,2]))
4c5b4f1267bfac5816653cb1ff269f20bc280d62
wh-jung0522/AlgorithmStudy
/Programmers/Test/1.Hash/2_TelephoneList.py
1,370
3.5625
4
def solution(phone_book): ## If One -tepnumber is Another Header -> false phone_book = sorted(phone_book) for i in range(len(phone_book)):## O(N*log(N)) +N if (i == (len(phone_book)-1)): return True else: if (phone_book[i] == phone_book[i+1][:len(phone_book[i])]): ...
3fcdb1c3b0a4af5d727ebbb7e59f3d6d26f185e1
brgjap11/PythonChallenge
/PyParagraphs/raw_data/main.py
1,464
3.9375
4
# Import all the dependencies, libraries and modules import pandas as pd import numpy import os import csv import sys import re # Store the source file path to a variable # ask user to input all of the files names into the code User_Paragraph_File = os.path.join("..", "raw_data", input ("Please enter the input filenam...
e133c39e5afaeaa04d1a3d220b316aa3aac06ba7
mariiamatvienko/python-homework
/laboratory2/lab2.1task.py
333
3.75
4
'''Формула добутку''' import re def int_validator(message): n = input(message) while not bool(re.match(r'^\d+$', n)): n = input(message) return int(n) n = int_validator('введіть n :') x = int_validator('введіть x :') p = 1 for i in range(1, n + 1): p = p * (x ** i + i) print(p)
371a19e616c5cf15f1bf682a29f3a41936b8c9ec
alyssalukpat/foundations_homework
/02-hw/homework-2-part2-lukpat.py
2,698
4.0625
4
# Alyssa Lukpat # Oct. 28 # Homework 2, Part 2 # Lists countries = ["Botswana", "Panama", "Egypt", 'Albania', "Taiwan", "Canada", "France"] tally = 0 for country in countries: print(country) tally = tally + 1 countries.sort() print(f'The first item in the list is {countries[0]}.') reverse_countries = sort...
12285705d280b72168cad24a3e3fc7b8d9462e60
Tanavya/ProjectEuler
/EulerP44.py
689
3.6875
4
# 3n^2 - n - 2x = 0 def isPentagonNum(x): c = -2*x n = (1 + (1 - 12 * c)**0.5)/6 if n.is_integer(): return True else: return False def pentagon(n): return (n*(3*n - 1))/2 def solve(): A,B = 1,100 while True: for a in range(A,B): for b in range(A,B...
3916bb90e2f22e359b3f87eb5c509ea67137ac8b
piyushiitg/leetCodePractice
/arrays/runningSum.py
846
4.21875
4
#!/usr/bin/python # -*- coding: latin-1 -*- """ Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]?nums[i]). Return the running sum of nums. Example 1: Input: nums = [1,2,3,4] Output: [1,3,6,10] Explanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4]. Example 2...
00838b8485f43ff1696e3557f3e76c818572055b
onlybaekhyunee/bestpython2020
/advance/traveller.py
884
3.765625
4
""" 2020-4-4 yfc 旅行距离叠加 非闭包方法,闭包方法 """ def trip(origin): def go(step): result = origin + step return result return go t = trip(0) print(t(3)) t = trip(t(3)) print(t(5)) t = trip(t(5)) print(t(8)) print('~~~~~~~~~~~~~~~~最初的思路~~~~~~~~~~~~~~~~~') def trip1(origin): def go(step): non...
4d01e72cc1675035ce361d4dc71822dd7c5adbe5
tmu-nlp/100knock2020
/hiroto/chapter01/knock09.py
678
3.609375
4
#https://note.nkmk.me/python-random-shuffle/ import random def typoglycemia(str): words = str.split() list = [] for word in words: if len(word) <= 4: list.append(word) else: head = word[0] tail = word[len(word) - 1] temp = word[1 :...
174761339569bb930deded43f7b929dd9b1ef441
mani319/DSA
/binary_trees/01_binary_search_trees/template.py
518
3.84375
4
class Node: def __init__(self, key): self.data = key self.left = None self.right = None def insert(node, data): if node is None: return Node(data) if data <= node.data: node.left = insert(node.left, data) else: node.right = insert(node.right, data) ...
d248e30565c33d5aa7532b69ac4b008858fc83ad
david-sk/projecteuler
/src/problems/0038_pandigital_multiples/v1.py
1,793
4.03125
4
# # Pandigital multiples, v1 # https://projecteuler.net/problem=38 # # Take the number 192 and multiply it by each of 1, 2, and 3: # 192 × 1 = 192 # 192 × 2 = 384 # 192 × 3 = 576 # By concatenating each product we get the 1 to 9 pandigital, 192384576. # We will call 192384576 the concatenated product of 192 and (1, 2, ...
b2e92506c3079794490bcb4aad611f5fa394b22b
toolness/ml-fun
/rl/car_rental.py
6,941
3.90625
4
# This is an attempt to implement the "Jack's Car Rental" example 4.2 # and exercise 4.5 from Sutton and Barto's Reinforcement Learning textbook. import math import random from functools import lru_cache from typing import NamedTuple, Iterator, Tuple, Dict, List DISCOUNT_RATE = 0.9 # Maximum number of cars that can...
8ceeb1312a303c5948e623e75e0301198a7e8a5a
alexlikova/Python-Basics-SoftUni
/8. Python Basics EXAMS/1. Programming Basics Online Exam - 6 and 7 July 2019/04. Club.py
570
3.671875
4
wanted_profit = float(input()) club_income = 0 command = input().title() while command != "Party!": cocktail = int(len(command)) number_of_cocktails = int(input()) price = cocktail * number_of_cocktails if price % 2 != 0: price *= 0.75 club_income += price if club_income >= wanted_pr...
e4161021f47bd3f11df7f5a277ac96e3e9a5b96d
duongdqq/python_oop
/howkteam_2.py
2,010
3.796875
4
# declare variable in class and outside constructor class SieuNhan: suc_manh = 100 def __init__(self, para_ten, para_vukhi, para_mausac): self.ten = para_ten self.vukhi = para_vukhi self.mausac = para_mausac sieunhanA = SieuNhan('bito', 'dao', 'trang den') print(sieunhanA.suc_manh) pr...
6bd47f050f406989bfa4f9978a9668324c4fb528
Leahxuliu/Data-Structure-And-Algorithm
/Python/链表/61.Rotate List.py
2,240
3.796875
4
# !/usr/bin/python # -*- coding: utf-8 -*- # @Time : 2020/05 # @Author : XU Liu # @FileName: 61.Rotate List.py ''' 1. 题目要求: 最后一个node移动到第一个,重复k次 2. 理解: 3. 输出输入以及边界条件: input: output: corner case: 4. 解题思路 5. 空间时间复杂度 ''' ''' two pointers (slow and fast pointer) 仅限于k的取值比链表长度小 1. make dummy, dum...
30e6e16e3c45c10ae4ee0c2b9f99df934a55abf2
Wyntuition/ai-with-python
/book-exercises/2.2-logistic-regression-classifier.py
1,337
4.28125
4
### Logistic Regression # - Go to method for binary classification problems (problems with 2 class values) # - Based on the logistic function, or the sigmoid function, originally developed to describe properties of population growth, so is an S-shaped curve that maps any real number into a value between 0 and 1 exclusi...
5f05e932fd090194a998b1b770d766d4273ccd7d
Harshmenon/robo-builder
/robo builder 2.py
493
3.96875
4
import turtle t = turtle.Pen() def rectangle(h,v,c): t.down() t.pensize(1) t.color(c) t.begin_fill() for i in range(2): t.forward(h) t.right(90) t.forward(v) t.right(90) t.end_fill() t.up() #drawing the feet t.up() t.goto(-100,-150) ...
c6dd47bd8e5743f9088b1794b11ab07d8d5fdcec
geetha79/pythonprograms
/dicefun.py
215
3.796875
4
#!/usr/bin/python3 import random i=0 def myroll(): return random.randint(1,6) while(i<=100): n=input("press r ro roll the dice") if(n=='r'): r=myroll() i=i+r print("u got ",r) print("new position is",i)
2e444c25d4028e482fd5abafad5748e9ae4f2659
BrettMcGregor/practicepythonorg
/27tic_tac_toe_draw.py
3,527
4.53125
5
""" In a previous exercise we explored the idea of using a list of lists as a “data structure” to store information about a tic tac toe game. In a tic tac toe game, the “game server” needs to know where the Xs and Os are in the board, to know whether player 1 or player 2 (or whoever is X and O won). There has also bee...
da675c94b3d10c4291e14ac3105c6ea3686f9e3f
NiteshKumar14/MCA_SEM_1
/Assignments/OOPs pythonn/swap.py
181
4.09375
4
def swap(num1,num2): temp=num1 num1=num2 num2=temp return num1,num2 num1=int(input()) num2=int(input()) swap(num1,num2) num1,num2=swap(num1,num2) print(num1,num2)
cee7ce405a93f9608ae3e95401625575384f389b
Pengjp/lc
/单调stack/sliding_window.py
601
3.859375
4
''' 求滑动窗口最大值 ''' from collections import deque def sliding(arr, size): dq = deque() ans = [] for i in range(len(arr)): # if new element is larger than right most ele, pop it while dq and arr[i] >= arr[dq[-1]]: dq.pop() # maintain a stricly decreasing deque from left to ri...
7d69e13dd1dbef636ff649b16a918482b4bf34a5
AffePelz/CodeFun
/calculator.py
405
3.78125
4
def add(x, y): return x + y def factorial(n): if n == 0: return n elif n == 1: return 1 else: return n*factorial(n-1) def sin(x, N): sum = 0 for n in range(0, N): sum += ((-1)**n*x**(2*n+1))/(factorial(2*n+1)) return sum def divide(x, y): return x/y ...
baff0a4bf713ca8b022a388e6bc6df2f8a8159d7
koukyo1994/algorithms
/src/aoj/9-prime-number/main.py
730
3.9375
4
import numpy as np """ def count_primes_lower_than(N: int): is_prime = np.ones(N - 1, dtype=bool) is_prime[0] = False cursor = 1 while (cursor + 1) ** 2 <= N: if not is_prime[cursor]: cursor += 1 continue """ def count_primes_lower_than(N: int): A = list(range(2, ...
aa7ac1036e64a89290e7e320e49cbbd7a9f2f85b
aysegulkrms/SummerPythonCourse
/Week3/06_Loops_2.py
722
4.375
4
import random # Number Guessing game # Randomly generate a number between 1-99 # if the user guesses a number that is lower than the generated number # The program should say "guess higher" # if the user guesses a number that is higher than the generated number # the program should say "guess lower" # if the user gues...
77dc5e600e37f646b6d4f0a787b6c7fedaa2786c
llh911001/leetcode-solutions
/break_word.py
644
4.34375
4
#!/usr/bin/env python # encoding: utf-8 """ Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. For example, given s = "leetcode", dict = ["leet", "code"]. Return true because "leetcode" can be segmented as "leet code...
22125c0b3514b60a3a27009e0f418cd3852c3ffc
presian/HackBulgaria
/Programming0-1/Week_2/2-List-Problems/sorted_names.py
140
3.515625
4
from utilities import string_input_getter words = string_input_getter() print('Sorted names are:') for word in sorted(words): print(word)
55bb416f10840fdab6af1911510b49cc28549d60
eamonnmag/orderbook
/order_simulator/service/orderbook/__init__.py
1,849
3.59375
4
import abc class AbstractOrderBook(object): """ AbstractOrderBook """ @abc.abstractmethod def clear(self, *args, **kwargs): """ :param args: :param kwargs: :return: """ @abc.abstractmethod def add(self, *args, **kwargs): """ :para...
840b6d8406d425226d74e58ecdbdd2a183621d52
Mgrdich/Statistics-Probability-Python
/distributions/poisson_distribution.py
2,481
3.515625
4
import math from utilities.math import factorial from utilities.util import isZero, isNegative # todo add print each P(X == i) # poisson distribution probability mass function P(X = i) = p(i) i->success with parameter (param_lambda) def poisson_pmf(param_lambda: float, success: int = 1) -> float: if isNegative(...
8d9800c1b7fcd28cb6618c1b2b3f28abac016a38
Rivarrl/leetcode_python
/leetcode/msjd/16-11.py
646
3.515625
4
# -*- coding: utf-8 -*- # ====================================== # @File : 16-11.py # @Time : 2020/7/8 21:42 # @Author : Rivarrl # ====================================== from algorithm_utils import * class Solution: """ [面试题 16.11. 跳水板](https://leetcode-cn.com/problems/diving-board-lcci/) """ de...
10bd0a694a5a3a89cab392f7c3243a42b7e94616
lyuka/data_structure_and_algorithm_using_python
/llistbag.py
2,583
3.640625
4
# Implements the Bag ADT using a singly linked list. class Bag: # Constructs an empty bag. def __init__( self ): self._head = None self._size = 0 # Returns the number of items in the bag def __len__( self ): return self._size # Determins if an item is contained in the bag....
156d38f68e5602180ccf62ded053414fc5c36d5a
btfcal/bouncer
/utils.py
759
3.671875
4
""" Supplementary functions and utilities """ import random def random_string(): """ Create a random string like 'golden-bear-123' to be used in onboarding channel names """ colors = ['Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Cyan', 'Purple', 'White', 'Black', 'Brown', 'Magenta', 'Tan', ...
a5cacde5a67293bdaf318066c406c0a8ce4c9cc9
Jatin0202/MonteCarloLabs
/3/180123060_Jatin_q1.py
493
3.796875
4
# use python 180123060_Jatin_q1.py to run this code import matplotlib.pyplot as plt import random values= [] #store the random value generated by algorithm p= 0.0002 # probability of every sigle element of set for i in range(100000): u= random.random() values.append((int(u/p))*2 + 1) plt.hist(values...
466d8d7f80e856c1df77580f3d78e98176720fac
bssrdf/pyleet
/D/DistinctSubsequencesII.py
1,094
3.875
4
''' -Hard- Given a string s, return the number of distinct non-empty subsequences of s. Since the answer may be very large, return it modulo 109 + 7. A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative po...
a2b3cb2da84cf69d980fef544c96b3b669862813
xeostream/ZOJ
/zoj1241.py
963
3.890625
4
from math import pow, sqrt case = raw_input() result = [] while case != '0 0 0': temp = case.split() if temp[0] == '-1': aa = pow(float(temp[2]), 2) - pow(float(temp[1]), 2) if aa > 0: a = sqrt(aa) result.append({'a': a}) else: result.append('Impowsibl...
0e1d27ddcd4c181a4d719940b1416489b75a3f6e
Abinalakalathil/python-lab
/cycle2/2.13.py
297
4.3125
4
#13 Create a list of colors from comma-separated color name entered by user.Display 1st & last color word = input("Enter the colors : ") color_list = word.split(",") print("The color list is : " , color_list) print("The first and last colors are : ") print( "%s %s"%(color_list[0],color_list[-1]))
1ac298dd035d66e775a384b4cbb18eb8bf9d8a65
cyberskeleton/sandbox
/samples/t14_01_triangle.py
2,552
4.09375
4
# Класи Точка, Відрізок та Трикутник from math import sqrt class Point2: """Клас реалізує точку площини""" def __init__(self, x, y): self._x = x self._y = y def get_x(self): """Повернути координату х""" return self._x def get_y(self): """Повернути...
8663d27504a8898337fd550e06440112c44cadbe
Jashwanth-k/Data-Structures-and-Algorithms
/1.Recorsions - 1/power of N.py
151
4.125
4
def power(x,n): if n == 0: return 0 return x**n x = int(input('enter x val:')) n = int(input('enter n val:')) print(power(x,n))
7f223b324b1951195cb3bdb2e834e416100dcbf2
AyanPerez/coding-challenge
/Questao05-Remove-duplicates-on-email-thread/questao05.py
1,710
4.0625
4
# Question 05 # Remove duplicates on email thread class Node: def __init__(self, mensagem): self.mensagem = mensagem self.next = None def listing(self): node = self while (node): print(node.mensagem) node = node.next def removing_duplicated(self): node_reference = self node_checking = self wh...
53d50f70829b1ebdd67a2299ad123f70183fe9c6
rekhapuduri/wbd
/Navigation/prod/Fix.py
6,092
3.515625
4
import datetime as dt import time import os from xml.etree import ElementTree import Angle as Angle from math import * class Fix(): def __init__(self, logFile="log.txt"): """ Constructor """ self.body = "" self.dt = "" self.tm = "" ...
6123bfe8fa30c7613d3bf37f687891a97978bc90
michellesanchez-lpsr/class-sampless
/msanchez/assignmentTester.py
238
4.375
4
# creates a variable called word and sets it equal to "bird" word = "bird" # sets word equal to itself concatenae with itself - word is now "birdbird" word = word + word word = word + word # word is now birdbirdbirdbird print(word)
bb6a39292293d63cc001f310a3e7bee01a19fc29
PnuLikeLion9th/Summer_algorithm
/janghun/4주차/2016년.py
614
3.609375
4
def solution(a, b): days=['FRI','SAT','SUN','MON','TUE','WED','THU'] if a==1: monthdays=0 elif a==2: monthdays=31 elif a==3: monthdays=31+29 elif a>=4 and a<=8 and a%2==0: monthdays=31*((a//2))+30*((a//2)-2)+29 elif a>=4 and a<=8 and a%2==1: m...
f8a6176b0bc9817eba8424966c56aea425053abc
jenniferc789/Week-2-Day-7-assignment
/Exercise2/sq_cir/__init__.py
577
3.953125
4
### 2) Create a Module in Visual Studio Code and Import It <br> # <p><b>Module should have the following capabilities:</b><br><br> # 1) Has a function to calculate the square footage of a room <br> # 2) Has a function to calculate the circumference of a circle <br><br> # <b>Program in Jupyter Notebook should take in us...
643a8b6f450033d461d277ecfa1ac31fcf0133a4
Tashwri93/Python-Exercise7
/exercise7.4.py
298
3.96875
4
toppings = "\nTell me which toppings you would like on your pizza: " toppings += "\nEnter quit when that is enough." while True: message = input(toppings) if message == 'quit': break else: print("You'll add that to your toppings " + message)
3045ae8c812f89814e74001b3757eb98b45e2405
britko/AI
/DeepLearning/Scratch1/ch03/ReLU함수.py
266
3.984375
4
import numpy as np import matplotlib.pyplot as plt def relu(x): return np.maximum(0, x) #두 입력 중 큰 값을 선택해 반환하는 함수 x = np.arange(-5.0, 5.0, 0.1) y = relu(x) plt.plot(x, y) plt.ylim(-1.0, 5.5) plt.title("ReLU function") plt.show()
4501064cd9e3221d486a03f35244c9b719781d99
xufang5/python-test
/mysite/test/unittest_demo.py
1,903
3.5
4
from django.test import TestCase import unittest def add(a,b): return a+b def sub(a,b): return a-b #必须继承unittest.TestCase class TestAdd(unittest.TestCase): """ 用例必须以test_开头,且每个用例名不能相同;用例执行的时候会自动执行test开头的用例 用例中不能传参和调用,但可以在用例中调用自定义的方法 """ def setUp(self): print("测试开始执行前") def te...
ed66ac32a7b841092db358947274ad0c385add5b
xcola0922/Hello-World
/selection2.py
216
4.1875
4
a = input("input number : ") if a > "5": print("Oh you are so big") if a < "5": print("OH you are so small") if a == "5": print("hey you are my brother") else: print("you kidding me?")
2bf075ddb3f4e0640e790c2e880d5d18bf1eb313
georggoetz/hackerrank-py
/Algorithm/Implementation/two_pluses.py
1,898
3.5
4
# htts://www.hackerrank.com/challenges/two-pluses class Position: def __init__(self, r, c): self.row = r self.col = c def __eq__(self, other): return (self.row, self.col) == (other.row, other.col) def __hash__(self): return hash(self.row) ^ hash(self.col) def __repr_...
c9b4054199e98a14f8e155ce78109a4202cbce73
coolavy/nsf_2021
/Homework_Week_4/group_project.py
1,392
4.03125
4
print("Welecome to the receipt generator!") add_items = input("Do you want to add items (Y/n)?: ") if add_items == "n": print("Thank you for using this program.") item_details = [] items_total = 0 sub_total = 0 tax = 0 while add_items == "y": ## inputs name = input(f"Enter item name {items_total +...
e9580e55e32604c022404351d804421b62cb891e
ytjia/leetcode
/algorithms/python/leetcode/UniquePaths.py
778
3.96875
4
# -*- coding: utf-8 -*- # Authors: Y. Jia <ytjia.zju@gmail.com> """ A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in ...
9fc081a8a0e6694e9629ba71a6b9cf035369c5e9
ankush4144/File-Handling-Questions
/question-2.py
232
4.34375
4
#Q.2- Write a Python program to count the frequency of words in a file. file_object=open('a.txt','r') num=input("String to be counted in file") z=file_object.read() counter=z.count(num) print("Frequency of %s is %d" %(num,counter))
fa6f185e342369a01ef6bf035fd0182fa641a6f2
azake-stud/python_learning
/chapter 1.2.py
7,727
4.21875
4
# >>>(Вопрос 1) Дан список a = [1, 2, 2, 4, 11, 2, 3, 1]. # Напишите код, который выведет список a без дубликатов. # a = [1, 2, 2, 4, 11, 2, 3, 1] # print(set(a)) # b = [] # for i in a: # if i not in b: # b.append(i) # print(b) # >>>(Вопрос 2) Дан список a = [‘John’, ‘Anna’, ‘Raychel’, ‘Katarina’, ‘Mar...
b1b70898146be51815e74c6f708526c54614ee30
chres21/Final_Proyectos
/final.py
811
3.796875
4
from tkinter import * from tkinter.ttk import * #Creacion de interfaz grafica con tkinter index=Tk() index.title("LOGIN") index.geometry("300x150") index.resizable(width=False, height=False) luser=Label(index, text="Ingrese nombre de usuario:") luser.pack() user=StringVar() euser=Entry(index, width...
393a00267f904d360936ffd61a9106ea48629e09
QuickLearner171998/Competitive-Programming
/Arrays/minSubArrayLen.py
748
3.671875
4
""" Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't one, return 0 instead. Example: Input: s = 7, nums = [2,3,1,2,4,3] Output: 2 Explanation: the subarray [4,3] has the minimal length under the problem const...
37c814dfe5f9970cc4548d85ceb467217fa92522
enordberg/adventCode2018
/day3-1.py
1,418
3.5
4
#filePath = "day3Puzzle1Sample.txt" filePath = "day3Puzzle1.txt" with open(filePath, 'r') as f: lines = f.readlines() plannedCoordinates = [] for line in lines[:]: splitValues = line.split(" ") location = splitValues[2] location = location.replace(":", "") locationSplit = location.split(",...
c4873fa97d2e6a6ea7e242cd9c1f391f8db77212
Guilherme-Felix/ModelagemComputacional
/Bifurcacao.py
2,827
3.640625
4
# -*- coding: utf-8 -*- """ Created on Wed Jun 1 15:29:15 2016 Codigo para identificacao via grafico de ciclos para o modelo de crescimento logistico onde f = rx(1-x) O objetivo aqui e evoluir o modelo no tempo de maneira que seja possivel detectar a existencia de um ciclo. Para isso utiliza-se um numero elevado d...
6d6d3c26eb5546d92386100d4c205797e6a0855f
karthika-onebill/python_basics_assignments
/Day3_Assignments/qn1.py
246
4.375
4
# 1) Write a Python Function to find factorial of given number with recursion. def fact(n): if n == 0 or n == 1: return 1 return n*fact(n-1) n = int(input("Enter the limit : ")) print("Factorial of the given no : ", fact(n))
60de9843a079f46306f624d4a9b82ce39cf38474
D-gallinson/game-of-life
/exception.py
1,914
3.75
4
class EndOfGame(Exception): def __init__( self, condition: str, turns: int, final_cells: int, highest_living: int, highest_board: int, lowest_living: int, lowest_board: int ): ends = { "stable": self.__stable, "dead": self.__dead, "turns": self.__turns, "unknown": self.__...
70d5c58d77ee4925b7a37bf12d8125f815f2f196
AnneQSmith/Exercise03
/calculator.py
1,854
4.34375
4
#import sys #sys.path.append("/home/user/src/exercise03") import arithmetic def correct_num_inputs(operator, num_inputs): if operator in ['-', '/','%','pow'] and num_inputs == 3: return True elif operator in ["square","cube"] and num_inputs == 2: return True elif operator in ['+','*'] and n...
558063f45edbb2b221cced1197525bf132aae57b
huytran321/Applied-Algorithmics-340-Project-3-Sort-TimeIt
/Project3/bigo.py
1,003
3.515625
4
# Made by Huy Tran # Bigo module with the four find functions def find1(list, val): for i in range(len(list)): if list[i] == val: return True return False def find2(list, val): tempList = [] tempList[:] = list[:] tempList.sort() low = 0 high = len(list) - ...
509825c3bf0e23253cf0db674c5c97f3d12333d1
vishalsharma14/algo
/string/29.camelcase_matching.py
2,166
4.3125
4
""" LeetCode 1023. Camelcase Matching A query word matches a given pattern if we can insert lowercase letters to the pattern word so that it equals the query. (We may insert each character at any position, and may insert 0 characters.) Given a list of queries, and a pattern, return an answer list of b...
6c620d85c3a48fe4d1df46492fcffd673d43ade7
mustardjelly/University-Examples
/MtG Tournament Organizer - Python/Game.py
3,508
3.5625
4
class Game: def __init__(self, player1, player2, pair_count): self.__player1 = player1 self.__player2 = player2 self.__pair_count = pair_count self.__score = None if self.__player2.get_name() == '**Bye**': self.set_score('2:0') elif self.__player1.get_name...
c9580cdb0dc3ff9f5a630fdde45bf083fa3d3eb8
marcfs31/joandaustria
/M3-Programacion/UF2/Practica4-M03/Exercici1.py
220
3.828125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- def sumarCuentaRegresiva(n): if ( n == 0): return 0 else: return n + sumarCuentaRegresiva(n-1) num = int(input("Primer número: ")) print(sumarCuentaRegresiva(num))
7642dd898aeb3f7906ba98b1222afd010983869c
santoshdurgam/DataStructures
/BinarySearchTree.py
1,857
3.78125
4
class Node: def __init__(self, val): self.left = None self.right = None self.data = val def binary_insert(root, node): if root is None: root = node else: if root.data > node.data: if root.left is None: root.left = node ...
498c8d541a5f7f4d5653db0f8aa0aceddade9697
binlee52/OpenCV-python
/ch06/연습문제/Q6-10.py
930
3.921875
4
# imshow(winname, mat) -> None # . The function may scale the image, depending on its depth: # . - If the image is 8-bit unsigned, it is displayed as is. # . - If the image is 16-bit unsigned or 32-bit integer, the pixels are divided by 256. # That is, the value range [0,255\*256] is mapped to [0,255]. # . - If the ima...
cffe39308f7565a232eeaa73242e142f5dc06e10
daniel-reich/turbo-robot
/bPzBa5JKvb6XFyKMs_11.py
2,433
4.1875
4
""" Primiera (from the french word _prime_ , "prize") is a combination of cards of _Scopa_ , a popular Italian card game. For establishing the value of the Primiera, a separate point scale is used for selecting the best cards in the player's deck, in each of the four suits and totaling those four cards point values...
7f67573cc688f597dee045140b66c0997e287127
bachrc/trajectoire-de-bulle
/preprocessing/datamodel.py
7,468
3.984375
4
from preprocessing.candidates import Candidate from collections import deque from math import sqrt class Point: """ A simple point class (x, y, z). Each point also has a unique numerical ID. """ def __init__(self, p_id, x, y, z): self.p_id = p_id self.x, self.y, self.z = x, y, z ...
cdf5cd285571bb14e56ddbd035ba9fe564848f5f
deepakbairagi/Python3Challenges
/a.py
422
3.796875
4
#!/usr/bin/python3 chars=0 lines=0 words=0 ab=open("a.txt","r") while True: f=ab.read(1) if f: if f=='\n': lines=lines+1 words=words+1 elif f==" ": words=words+1 chars=chars+1 else: print("file end") break print("Number of words in the string:") print(words) print("Number of lin...
c28ef36274d4f8217192f5334648cd773a8675b1
kmh2294/Python_Algorithm
/multi_prime_number.py
557
3.5
4
import math n = 1000 #2부터 1000까지 자연수중 소수판별 #소수인지 아닌지 값을 담을 배열초기화 array = [True for i in range(n + 1)] #2부터 n의제곱근 까지의 모든 수를 확인하여 for i in range(2 , int(math.sqrt(n)) + 1): if array[i] == True : # i 가 소수인 경우 (남아있는경우) j = 2 #i 를 제외한 배수를 모두 제거 while i * j <= n : array[i * j] = False...
c948125a01cf2b5fd3276be482c06789d280f015
JulianNicholls/Adventure
/python/inv1.py
900
3.765625
4
inventory = ( # Immutable Tuple of Items 'Sword of Mord', 'Rope of Hope', 'Potion of Motion', 'Racket Jacket', 'Doublet Goblet' ) find = ( # Another Immutable Tuple of items 'Chest from Brest', 'Jewels from King Jules' ) def print_inv(inv, name = 'inventory'): print(name + ':\n ', end =...
9375809d6110731be27d48ce27a06a4063782beb
Daniel-Benson-Poe/Sprint-Challenge--Data-Structures-Python
/ring_buffer/ring_buffer.py
1,621
3.609375
4
class RingBuffer: def __init__(self, capacity): self.capacity = capacity self.list = [] # create empty list to keep track of values and length self.iter = 0 # create iterator to keep track of index that holds the oldest value def append(self, item): if len(self.list) >= self.c...
a1442e3c00cea135924c61eee192786005aa6906
Francis0121/homework.3.1
/ProgramLanguage/Python/Homework_2/20093267.py
871
3.640625
4
# -*- coding: cp949 -*- import glob import os directoryPath = raw_input("Please enter directory path\n") directoryPath = "%s\*.txt" %directoryPath files = glob.glob(directoryPath) outputFile = open("all_files.txt", 'w') for fileName in (files): inputFile = open(fileName, 'r') # 'r' б 'w' 'a' ߰ wordCount =...
8329804c2b4fb3be3526da15031ec0a41b60f135
festefan/Aprendendo-Python
/Phyton/Wid.py
895
3.828125
4
from tkinter import * tela = Tk() #instancia a classe 'Tk()' através da variável 'tela' tela.title("TELA INICIAL") tela["bg"] = "light yellow" tela.geometry("200x200") #define o tamanho da tela em width (largura) x height (altura) Container = Frame() #definimos o container com um frame Container["pady"] = 10...
71c9c4a38dcb9e839f41e9174236cabea6f39b79
bandat1/python_courses
/python_algorithms/week01/L1.task05.py
255
4.0625
4
# 5. Пользователь вводит номер буквы в алфавите. Определить, какая это буква. a = int(input("Введете число: ")) letter_ord = a + ord('a') - 1 letter = chr(letter_ord) print(letter)
7cb5141f4f65f32b68440927fe838c2614c40990
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/225/users/3999/codes/1635_2447.py
188
3.59375
4
preco=float(input("preco:")) pagamento=float(input("pagamento:")) x= preco-pagamento y= pagamento-preco if(preco>pagamento): print("Falta",round(x,2)) else: print("Troco de",round(y,2))
b6f484d2620accc55d0de38c037ad99e0f9d1c09
kamaligeetha/kamaligeetha
/8887.py
128
3.6875
4
NN=list(input()) AA=[] for j in NN: if j not in AA: AA.append(j) if(NN==AA): print("Yes") else: print("No")
c4c1cf164b111fd1d32f4c4a6bdce40ecd4df52c
harshildarji/Algorithms-HackerRank
/Implementation Challenges/Designer PDF Viewer.py
256
3.6875
4
# Designer PDF Viewer # https://www.hackerrank.com/challenges/designer-pdf-viewer/problem h = list(map(int, input().strip().split(' '))) word = input().strip() height = [] for i in word: height += [h[ord(i) - ord('a')]] print(len(word) * max(height))
ce32e72e496600ca313dcb6d22d42ca62d9fc4ec
alexctk/Uncertainty_Calculator
/parser.py
14,516
3.609375
4
from uncertainty import * # BNF grammars for mathematical expressions: # <expression> ::= <signed-term> | <expression> "+" <term> | <expression> "-" <term> # <signed-term> ::= "-" <term> | <term> # <term> ::= <factor> | <term> * <factor> | <term> / <factor> # <factor> ::= <element> | <element> ** <numeral> # <elem...
0b5d085839bab53e8a91af72709e047d0a701019
daffleskmc/PythonProject
/Demo/PythonBasic2.py
525
4.1875
4
if 5 > 3: print("5 is greater than 3") num = 0 if num > 0: print("This is a positive number") elif num == 0: print("number is zero") else: print("This is a negative number") num = [1,2,3,4,5] sum = 0 for val in num: sum = sum + val print("Total is ", sum) fruits = ["apple" "oranges", "grapes"] ...
29bb4ad7dd8459bc6156c44286e6f4f011faa26c
NikilReddyM/algorithms
/between_sets.py
655
3.5
4
def gcd_rec(m,n): if(n): return gcd_rec(n,m%n) else: return m def lcm(m,n): return (m*n)//gcd_rec(m,n) def gcd_list(a): g=0 for i in a: g=gcd_rec(i,g) return g def lcm_list(a): l=1 for i in a: l=lcm(i,l) return l def betweenTwoSets(a,b): x=...
3cdc443b164f30092ee9cd6de5ba2ec7fa369c11
quinn-dougherty/phys140
/homework/ch1/ch1p20.py
1,275
3.75
4
from utils import print_float3 volume_in_gallons = 187 rate_in_gallons_per_minute = 2.0 gallon_inchescubed_conversion_factor = 231 water_density_kg_per_meterscubed = 1000 volume_cubic_inches = volume_in_gallons * gallon_inchescubed_conversion_factor inches_to_cm_conversion_factor = 2.54 volume_cubic_cm = volume_cu...
9509328ba471f2225b737c35236226a1e91adaa3
MrPidazzo/TicTacToe
/main.py
2,881
3.859375
4
''' Created on May 2, 2017 @author: Ryan ''' moves = [1,2,3,4,5,6,7,8,9] player = 1 PLAYER1_TOKEN = 'X' PLAYER2_TOKEN = 'O' game_won = False def draw_board(board): print '\n\n' print ' | |' print ' ' + str(board[6]) + ' | ' + str(board[7]) + ' | ' + str(board[8]) print ' | |' p...
989f4556d9113e005500e5b9da8c4bccfcce7e33
GuilhermeUtech/udemy-python
/S12/enumerate.py
150
3.9375
4
#enumerate(): vai tipo lista, enumera os dados internos pah lista = ['a','b','c','d'] print(list(enumerate(lista))) #Retorna uma tupla, começa em 0
75cb4c86b899e79b972d03d7fc59f93dceae4adc
haleekyung/python-coding-pratice
/hgp_book/05_function/book_05_3_exercise.py
400
3.796875
4
numbers = [1, 2, 3, 4, 5] print("::".join(map(str, numbers))) numbers = list(range(1, 10 + 1)) print("# 홀수만 추출하기") print(list(filter(lambda x: x % 2 == 1, numbers))) print() print("# 3 이상, 7 미만 추출하기") print(list(filter(lambda x: 3 <= x < 7, numbers))) print() print("# 제곱해서 50 미만 추출하기") print(list(filter(lambda x: x...
6a988171d101d6dd08d3606e4baa4152984a5a6f
Lydia-Li725/python-basic-code
/lambda.py
544
4.125
4
#简化代码:如果一个函数有一个返回值,并且只有一句代码,可以利用lambda简化 #def def fn1(): return 100 #lambda 匿名函数 fn2 = lambda: 100 print(fn2) print(fn2()) #列表数据按字典key的值排序 students = [{'name':'tom','age':20}, {'name':'amy','age':21}, {'name':'rose','age':22} ] #按name值升序排列 students.sort(key=lambda x:...
46d9bbb9d6dbe8cef34438c00b92b981d684e6d7
wyvern934/revision
/python hugo/boucle for.py
166
4
4
nombre = int(input("entrez un nombre : ")) limite = int(input("entrez un nombre limite : ")) for i in range (limite + 1): print(f"{nombre} X {i} = {nombre*i}")
890fe1c5a7bf5c4b5bd7805f13dbf47e6a8ae0ec
louis297/django
/myclist/test.py
348
3.609375
4
class A(object): def __init__(self): print('%d'%1) super(A,self).__init__() print("<%d>"%1) class B(object): def __init__(self): print(2) super(B,self).__init__() print("<2>") class C(A,B): def __init__(self): print(3) super(C,self).__init__(...
fd1cbc088cc5c30a0a8514918814664819b349c5
Jhall1990/prop_grader
/grader.py
2,162
3.984375
4
#!/usr/bin/env python import csv import argparse class User(object): def __init__(self, name, user_answers): self.name = name self.user_answers = user_answers self.score = 0 self.mvp_answer = "" def grade(self, correct_answers): zip_answers = zip(self.user_answers, co...
f1217701a034d8fc3830a57a36006966e5ce2ad3
palhaogv/Python-exercises
/ex087.py
768
3.96875
4
#soma dos valores pares #a soma da terceira coluna #o maior valor da segunda linha lista = [] somapar = 0 somar3coluna = 0 maiorvalor2 = 0 for c in range(1, 10): n = int(input(f'Digite o valor da {c}ª posição: ')) lista.append(n) if n % 2 == 0: somapar += n if c == 3 or c == 6 or c == 9: ...
29a9810a414c4ad868a4873d2bc9c0b3f57f340c
wandershow/Python
/ex073.py
992
3.765625
4
#crie uma tupla preenchida com os 20 primeiros times em ordem de classificação do brasileirão 2018 #mostre os 5 primeiros #os ultimos 4 da tabela #uma lista com os times em ordem alfabetica # em que posição esta o time da chapecoense br = ('palmeiras', 'flamengo', 'inter', 'gremio', 'são paulo', 'atletico mg', 'atleti...
aa17763120ab9f9de8f07d0a216e8ee9588f3c3d
panxl6/leetcode
/404._Sum_of_Left_Leaves/python/404. Sum of Left Leaves.py
1,035
3.84375
4
# author: 潘兴龙 # date: 2019-06-30 13:15 # coding=utf8 """ 1) 题型剖析: 知识点考察。基础操作实现题。 2) 解法: 3) 知识点讲解: 4) follow up: 5) 时间复杂度分析: 6) 备注: 7) 评测结果分析: """ # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = Non...
fd8f141959e9bb9bec5956433e6c6862658bd29a
uyennguyen16900/coding-syntax-conventions
/coding.py
1,038
4.09375
4
from linkedlist import * # Find the middle item in a singly linked list, or two middle items if it contains an even number of nodes. def get_middle_item(ll): fast = ll.head slow = ll.head while fast.next is not None and fast.next.next is not None: fast = fast.next.next slow = slow.next ...
5991383ff6bba3d86d6aa1a932ecb58c3cd078e3
xiaobo1992/cs662-pattern-recognition
/cs662proj1/proj.py
17,095
3.703125
4
import numpy as np from scipy.stats import norm from numpy import matrix from numpy.linalg import linalg import scipy.spatial.distance as distance import scipy.stats as stats import matplotlib.pyplot as plt import math import random ''' this function is used to create covariance matrix for mulitple dimension ''' def c...
7f7fe2d3b59c250d27a5a81e10e72e0a256b9aae
ByeongjunCho/Algorithm-TIL
/백준/1978.py
276
3.5625
4
N = int(input()) numbers = list(map(int, input().split())) prime_count = 0 for num in numbers: if num == 1 or num == 0: continue for i in range(2, num // 2 + 1): if num % i == 0: break else: prime_count += 1 print(prime_count)
cf98eb30939515446ef5c4af5105735189455d89
Rajat2712/MazeSolver
/task1_nt#4341/TeamNum#4341/Task1_Practice/Section-1/section1.py
2,382
4.15625
4
import numpy as np import cv2 ## The readImage function takes a file path as argument and returns image in binary form. def readImage(filePath): ############# Add your Code here ############### ################################################### return binaryImage ## The findNeighbours function takes...
a3e7a8279add0c7d3a5983c0d5bd2b286c56e232
aa2276016/helloSping2018
/n_queens_OOP.py
5,397
4.15625
4
# This is to solve the Eight Queens problem in Chess # TO security set 8 queens in a chess checkerboard where no queen can directly attack the other queens. class Chessboard(object): """each instance should be a single plate that can be filled in with numbers there will be check method to ensure no conflict i...
09d22cb4d0335d17ef65ee60332412e0f8a37974
ayush-programer/pythoncode
/lists.py
9,066
4.3125
4
# A list is a data structure in Python that is a mutable, or changeable, ordered sequence of elements. # Each element or value that is inside of a list is called an item. They enable you to keep data # together that belongs together, condense your code, and perform the same methods and operations # on multiple values ...
19a2697e7f1a6fa2eac64e06f87cc916be3c98de
gabriellaec/desoft-analise-exercicios
/backup/user_256/ch31_2020_04_12_22_25_47_992666.py
330
3.578125
4
def eh_primo(n): i = 1 if n ==0 or n == 1: return False if n ==2: return True while n>2 and i<n: while n %2 !=0: if n%i !=0: return True else: return False i+=2 ...
a3077d66f916321b212046b712e8b4efee1e2fab
zpencerguy/algo_practice
/python_intro_to_algs 2/part_2/quick_sort.py
1,217
4
4
from random import shuffle from typing import List __author__ = 'kclark' def run_quick_sort_simulation(): ordered_values = list(range(100000)) # 100,000 numbers input_values = ordered_values.copy() shuffle(input_values) sorted_values = _compute_quick_sort(input_values) assert sorted_values == ...
db24d0d29f7a22b2947ecbda256bffcc9a407f34
GaborFcm/PAT
/1022.py
295
3.5625
4
# _*_ coding:utf-8 _*_ number = raw_input().split(' ') # please take care of the title number = map(int, number) c = number[0] + number[1] if c == 0: print 0 else: z = '' while c != 0: residue = str(c % number[2]) z = residue + z c /= number[2] print z
f36b2c211e7bb8284095d9db691566e002363806
dstansbury/Code-2020-class-assignments
/calculator.py
339
3.9375
4
def multiply(a,b): return a * b def add(a,b): return a + b def subtract(a,b): return a - b def divide(a,b): return a / b def square(a): return a ** 2 def cube(a): return a ** 3 def square_n_times(num, n): return num ** (2*n) print("I'm going to use the calculator functions to multiply 5 and 6") x = multip...