blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
29bffe754e6bd303f1a533584676836245cbe9f1
ameena63033/Non_Linear-Data-Structures
/Reversal_of_SLL_using_two_pointers.py
1,478
4.25
4
#node class for creating node object class node: def __init__(self,val = None): self.val = val self.next = None #to create linked list object class linkedlist: def __init__(self,head = None): self.head = head #function for printing sll def print_linked_list(ll1): ptr = l...
4e33f5d54fad7f93a7b7ca13e6db8b8abf75aae9
MrzvUz/Python
/Python_Entry/movie_exercise.py
3,376
4.625
5
# Incomplete app! MENU_PROMPT = "\nEnter 'a' to add a movie, 'l' to see your movies, 'f' to find a movie by title, or 'q' to quit: " movies = [] # You may want to create a function for this code title = input("Enter the movie title: ") director = input("Enter the movie director: ") year = input("Enter the movie rele...
8b400a3d94acb9797454fdb0c7efae49c65c20af
LiJieSu0/LeetCode
/python/1275.FindWinnerTicTacToe Game.py
910
3.640625
4
def tictactoe(moves): aList=moves[::2] bList=moves[1::2] aList.sort() bList.sort() if [0,0] in aList and [1,1] in aList and [2,2] in aList or [0,2] in aList and [1,1] in aList and [2,0] in aList: return "A" if [0,0] in bList and [1,1] in bList and [2,2] in bList or [0,2] in bList and [1,1] in bList and [2,0] in...
614f942da599ff50d2b8608b07f4f8a5a1cb218e
RaviMudgal/AlgoAndDataStructures
/recursion/SumList.py
338
3.875
4
def listSum(numList): sum = 0 for i in numList: sum += i return sum print (listSum([1,2,3,4,])) # listSum using recursion def listSumRecursion(numList): if len(numList) == 1: return numList[0] else: return numList[0] + listSumRecursion(numList[1:]) print(listSumRecursion([...
7a01efbdfdff029b7468673718789857aabf584e
bossyjossy/IAmLearninPython
/exercises/LPTHW_Exercise6.py
1,545
4.5625
5
# This is my completed exercise for Learn Python The Hard Way Exercise 6 # # This is slightly modified from the lesson so that I can test things out # and really solidify what I learned. # # EXERCISE 6: Strings and Text # Setting variable 'x' to a string. Also using string formatting operation to format a number with...
2c588cb3ddeaf4b59f77397f6022c3dcff2214cd
kju2/euler
/problem044.py
1,495
4.0625
4
""" Pentagonal numbers are generated by the formula, P_n = n(3n - 1)/2. The first ten pentagonal numbers are: 1, 5, 12, 22, 35, 51, 70, 92, 117, 145, ... It can be seen that P_4 + P_7 = 22 + 70 = 92 = P_8. However, their difference, 70 - 22 = 48, is not pentagonal. Find the pair of pentagonal numbers, P_j and P_k, f...
99c382213340924219f3d48ec00cfd2b2e9c41cd
szweibel/szweibel.github.io
/workshops/pythonWorkshop/ex7.py
359
4.53125
5
the_count = [1, 2, 3, 4, 5] fruits = ['apples', 'oranges', 'pears', 'apricots'] # this first kind of for-loop goes through a list for number in the_count: print "This is count", number # same as above for fruit in fruits: print "A fruit of type: ", fruit # This loop has an 'if' clause for fruit in fruits: ...
fe28bee82390c662f705673f76a604783f5c4223
nasir-001/Week-One
/Vid_3.py
290
3.546875
4
"Naisr Lawal" "Nasir is awesome" "I don't think she's 18" 'she said, "What part of the cow is meatloaf from"' "I don\'t think she's 18" print("Hey now brown cow") print(r'C:\\Nasir\Desktop\PythonWithTahir') first_name = "Nasir" first_name + " Lawal" first_name + " Aliyu" first_name * 5
65a4ce0289421d1271c0760ade58c7905f29a75d
omakasekim/2020_SoftwareDesign
/Code/2-2/2.py
222
3.796875
4
str1 = input() str2 = input() str3 = input() strResult = str1 + str2 + str3 float1 = float(input()) float2 = float(input()) float3 = float(input()) floatResult = float1 + float2 + float3 print(strResult) print(floatResult)
6113d6812301b2c4e7a1ab8acf82a988fd58abf6
hannahac/recursion
/recursions.py
343
4.0625
4
def power(number, power_to_raise): #2^4 = 2*2*2*2 #2^4 = 2^3*2 if power_to_raise > 1: power_to_raise = power_to_raise - 1 return number * power(number, power_to_raise) elif power_to_raise < 0: raise Exception("Math error") else: return 1 result = power(3, -4...
5e8f6c398b2204936f18edc1c081cb8231091b02
Tandd2015/python_stack
/python_stack_2.7/Python OOP/mathdojo/mathdojo.py
5,256
3.5625
4
# part 1 class MathDojo(object): def __init__(self): self.equals = 0 def add(self, *args): for add_int in args: self.equals += add_int return self def subtract(self, *args): for sub_int in args: self.equals -= sub_int return self ...
bbf04ccc135e5e0fb9161c71cc5c4ee67dc7c209
taka-rui/takasite
/class.py
201
3.703125
4
class Car: class_name = "Car" def __init__(self): self.name = None def show(self): print(self.name) car = Car() car.name = "セダン" car.show() print(Car.class_name)
f876a69b0758ec1faf800c70e3403a2e39b7b8c9
StephanRaab/pythonProgramming
/lesson2.py
3,046
4.09375
4
# for i in [2, 4, 6, 8, 10]: # print("i = ", i) # # for i in range(0, 11, 2): # print (i) # # # problem 1: print odds from 1 - 20 # for i in range(1, 21): # if (i % 2) != 0: # print(i) # # your_float = input("Enter a float: ") # your_float = float(your_float) # print("Rounded to 2 decimals: {:.2f}"....
bc69118506c2a5dfd3605fc845c04589e59509bf
dimDamyanov/Py-Fundamentals
/11. EXCERCISE - Functions/06.py
516
4.03125
4
password_input = input() def is_valid(password: str): valid = True if not 6 <= len(password) <= 10: print('Password must be between 6 and 10 characters') valid = False if not password.isalnum(): print('Password must consist only of letters and digits') valid = False if ...
83870fd4b1ff04dbfd59924e710d3c45ccb1d10b
mumer29/100-days-code-challenge
/Union-of-two-arrays.py
698
4.09375
4
#User function Template for python3 class Solution: #Function to return the count of number of elements in union of two arrays. def doUnion(self,a,n,b,m): final_list = list(set(a)|set(b)) return len(final_list) #code here #{ # Driver Code Starts #Initial Templat...
7c8235058bdaf9ee8300bcc89b705dfad9b30532
LYC199124/_LeetCode_Study_
/array/Leecode_intersect_function1_.py
558
3.75
4
#!/usr/bin/env python3.0 #!-*coding:utf-8 -*- #!@Time :2018-5-22 11:07 #!@Author : LYC #!@File : Leecode_intersect_function1_.PY class Solution(object): def intersect(self, nums1, nums2): list_interset = [] for p in nums1: for k in nums2: if p == k: li...
155752006c5732a69c421e3866dcd2d77c66e56f
IbrahimOladepo/Python-Projects
/Age_Calculator/age_opt.py
2,524
4.0625
4
# -*- coding: utf-8 -*- """ Created on Thu May 5 09:55:04 2016 @author: IbrahimOladepo """ import time import age_FUNCTION import pandas as pd # inputs name = input("Enter your name: ") # input year of birth and check validity currentYear = int(time.strftime("%Y")) birthYear = int(input("En...
1ad74249d657b1a98c9aa4b55b0efd5569603c9f
friessm/math-puzzles
/p0010.py
966
3.765625
4
""" Solution to Project Euler problem 10 https://projecteuler.net/problem=10 """ def sieve_of_eratosthenes(number): """ Sieve of Eratosthenes Return the sum of all prime numbers from 2 to number. Standard implementation of Sieve with some optimisations. https://en.wikipedia.org/wiki/Sieve_o...
486c39e524365c89da367029856ce6c5d6b09e54
LucasAraujoBR/Python-Language
/pythonProject/Python Basic/aula8.py
807
4.5625
5
""" Aula 8 - Desafio prático """ """ *Criar variáveis para nome(str), idade(int) *altura(float) e peso(float) de uma pessoa *cria variável com o ano atual (int) *obtem o ano de nascimento da pessoa (baseado na idade e no ano atual) *obtem o IMC da pessoa com 2 casas decimais (peso e na altura da pessoa) *Exibir um tex...
ce809b5dd2842cd8e73ce3992bafcfd20db8198a
aenima1983/Dual-Heap-Sorting-Algorithm
/dualheapsort.py
1,794
3.96875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jun 20 15:32:31 2019 ¡prototype dual-heap sorting algorithm! slight downfall: user must enter each value individually, which could be impractical for very large arrays. in the future, consider file parsing--taking an array directly from a file and inp...
ea34893d80aa2e03b9821b43b7f4cc0dde0dd126
Pollack72/2021-1-Algorithm-Study
/week3/Group9/boj4779_pollack72.py
241
3.609375
4
data = [] while True: try: data.append(int(input())) except: break def Cantor(n): if n == 0: return '-' else: return Cantor(n-1)+' '*(3**(n-1))+Cantor(n-1) for i in data: print(Cantor(i))
f83a718a8e46f56888a98987c9a12ec75a3e1d6a
razmanika/My-Work-Python-
/Udemy/UdemyTest.py
2,419
4.21875
4
''' ### 43(lecture) ### *args and **kwargs ''' ''' print(issubclass(C, A)) print(issubclass(C, B)) ვამოწმებთ არის თუარა C a და b კლასების შვილობილი ''' ''' ### 49(lecture) ### Map ...
90cdf0e7902c1b7e34fe103b91a912699f9a3319
tashakim/puzzles_python
/mruQueueDesign.py
658
4.09375
4
class MRUQueue: """ Purpose: Design a MRU (Most-Recently-Used) Queue. Brute force """ def __init__(self, n: int): """ Purpose: Constructs the MRUQueue with n elements: [1, 2, ..., n] """ self.data = [x for x in range(1, n+1)] def fetch(self, k: int) -> int: ...
4ba44d24bee72d561da282fc3c487772a0eb5b3a
motleytech/crackCoding
/linkedLists/palindrome.py
966
4.09375
4
''' check if a list is a palindrome ''' from llist import LinkedList def isPalindrome(lst): ''' return true if lst is a palindrome ''' nodes = list(lst) for x, y in zip(nodes, reversed(nodes)): if x.data != y.data: return False return True def isPalin2(lst, curr): ''' ...
c62c60779616e7cad892e205e92be1cc71cc5d1d
jacobgarrison4/Python
/p21_sqrt.py
2,043
4.28125
4
""" Square Root CIS 210 F17 Project 2 Authors: Jacob Garrison Credits: Python Programming in Context Approximate sqrt of a given number with iterative function """ from math import * def mysqrt(n, k): """(int, int) -> float Returns an approximation of the square root of a givven numbe...
5911669e869de0be34679f73c7d67874240ac5fb
cathyq/practice-code-a-day
/diagonal_difference.py
378
3.6875
4
#!/bin/python # Given a square matrix NxN, calculate the absolute difference between the sums of its diagonals. # This problem is from hackerrank. import sys n_row = 3 a = [[11,2,4], [4,5,6], [10,8,-12]] primary = 0 secondary = 0 for i in range(n_row): primary += a[i][i] for j in range(n_row): second...
f2bd313a5e5eec61504dc02107744b3b7dc027ea
SoksanSerey/bootcamp
/sereysoksan16/week01/projects/01_dice.py
843
4.28125
4
import random dice = [1, 2, 3, 4, 5, 6] result = 0 print('Welcome to the dices game!') while 1: number_dices = input('Enter the number of dices you want to roll: ') if number_dices.isdigit() and (1 <= int(number_dices) <= 8): number_dices = int(number_dices) if number_dices == 1: di...
a499758ec1960d4b3762183e63925c5399238a9f
anax-code/Estudos
/Scripts/Python/URI/1010.py
507
3.71875
4
linha1 = input().split() p1 = int(linha1[0]) n1 = int(linha1[1]) v1 = float(linha1[2]) linha2 = input().split() p2 = int(linha2[0]) n2 = int(linha2[1]) v2 = float(linha2[2]) valor = (n1*v1)+(n2*v2) print('VALOR A PAGAR: R$ {:.2f}'.format(valor)) #A função split() faz com que cada objeto digitado dentro da string se...
a79806969e292cb7482e7d79083bcab5d4abca67
ishankkm/pythonProgs
/progs/LengthLLArray.py
353
3.5
4
''' Created on Nov 8, 2017 @author: ishank ''' def solution(A): if A[0] == -1: return 1 lenLL = 1 current = A[0] for _ in xrange(1, len(A)): if A[current] == -1: return lenLL + 1 else: lenLL += 1 current = A[current] return lenLL A ...
8e62a7a4c32952b62876e7eb0cb0a21e33396079
rafaelperazzo/programacao-web
/moodledata/vpl_data/186/usersdata/269/108337/submittedfiles/volumeTV.py
172
3.859375
4
-*- coding: utf-8 -*- v=int(input('digite: ')) t=int(input('digite: ')) for i in range(0,t,1): ai=int(input('digite as trocas de volume: ')) v=v+(ai) print(v)
41c0fccd4f8fca878ff0ae0d6ea64dc039936173
Nextc3/aulas-de-mainart
/Listas/Lista 7/q7.py
548
3.546875
4
''' 7.Dado um pais A, com 5.000.0000 de habitantes e uma taxa de natalidade de 3% ao ano, e um pais B com 7.000.000 de habitantes e uma taxa de natalidade de 2% ao ano. calcular e imprimir o tempo necessário para que a população do pais A ultrapasse a população do pais B; ''' paisA = 5000000 paisB = 7000000 ano = 0 wh...
f044d03a0dbcb53575b43cb35cf4787ba0ac65b9
a-angeliev/Python-Fundamentals-SoftUni
/exame/05. Excursion Sale.py
487
3.65625
4
money = 0 sea_trips = int(input()) muntain_trips = int(input()) while (sea_trips !=0 or muntain_trips !=0): a = input() if a == 'sea' and sea_trips>0: money = money + 680 sea_trips = sea_trips - 1 elif a == 'mountain' and muntain_trips>0: money = money + 499 muntain_trips = m...
181ebf7fc0f2ec161224addd5685fd4ff2f806f4
kommisar5150/assembler
/InstructionForms.py
2,605
3.609375
4
#!/usr/bin/env python """ This file contains all potential states of an instruction. The parser gathers info about the instruction and arguments. The arguments are identified as either registers, immediate values, flags, or width. These idenfitications are then concatenated together as a "state" string. Because instru...
2e394c0a2e983a37bfca386c1d2fd78def4f523d
niksm7/March-LeetCoding-Challenge2021
/Generate Random Point in a Circle.py
1,354
4.40625
4
''' Given the radius and the position of the center of a circle, implement the function randPoint which generates a uniform random point inside the circle. Implement the Solution class: Solution(double radius, double x_center, double y_center) initializes the object with the radius of the circle radius and the positi...
c17fc4c50d3ab9135eea9c4cf63f99123d9d8e97
ocewulf/scrapy
/lottery.py
165
3.5
4
from random import randint balls = set() while len(balls) < 7 : red_ball = randint(1, 36) balls.add(red_ball) print(balls) s = list(balls) s.sort() print(s)
388417f6bcdd9c0fd97c21677ea5b522dc964d1f
yeulucay/python_algorithms
/sort_algorithms/selection_sort.py
484
3.9375
4
""" - O(n**2) worst case time complexity - Find the smallest item in list and put it to the first sequence. Scan the rest in linear manner - In place sort """ def selection_sort(list): n = len(list) for i in range(0, n-1): min = i for j in range(i+1, n): if list[j] < list[min]:...
2323f4b71d6ea608e702fd460410f12a9fb20b36
llhbum/Problem-Solving_Python
/python-for-coding-test/팀 결성.py
713
3.609375
4
''' INPUT 7 8 0 1 3 1 1 7 0 7 6 1 7 1 0 3 7 0 4 2 0 1 1 1 1 1 ''' def find_union(parent, x): if parent[x] != x: parent[x] = find_union(parent, parent[x]) return parent[x] def union_parent(parent, a, b): a = find_union(parent, a) b = find_union(parent, b) if a < b: parent[b] = a ...
f1f0baed1a96dbdfefc49b071ed50e05d3669035
thghu123/python-basic-example
/1109/ex1.py
520
3.578125
4
class myclass : def __init__(self): #생성자 self.name ='' #초기화 : 오류 방지 def __del__(self): #소멸자 - 객체가 메모리 상에서 삭제될 때 호출 #할일 있을 때 쓰자. self.name ='' def setName(self, n): #멤버 메서드 정의 self.name = n #self는 this, 초기화 부 #멤버 메서드 정의시 반도시 첫번째 인자는 현 객체의 레퍼런스인 self 넣어준다 de...
5dd56def30c47f339c5cbd8ec88efc43393773b2
folabi-masha/LicenseCountApp
/database.py
3,381
3.75
4
import sqlite3 class Database: def __init__(self): self.conn = sqlite3.connect("init.db") self.cursor = self.conn.cursor() def create_database(self): return self.conn def load(self): products = """CREATE TABLE if not exists products ( product_id i...
c4c2206b9102fd3d7224828add43f8bc92ea7877
vladi-dev/exercism
/python/word-count/wordcount.py
224
3.90625
4
# -*- coding: utf-8 -*- import re from collections import Counter def word_count(str): regexp = '\W|_' return Counter(word for word in re.split(regexp, str.decode('utf-8').lower(), flags=re.UNICODE) if word != '')
76390c10b19dbb5e3c9c4163ff3663b99c27156f
sejin1996/pythonstudy
/ch03/function/03_function_return.py
1,230
3.96875
4
# 03_function_return # 함수 정의 : 반환값이 있는 함수 # 반환값은 함수 호출 후 함수 내부 문장을 실행하고 실행된 결과를 # 함수를 호출한 지점으로 반환하는 값 # 함수정의 # 함수이름 : sum # 함수 기능 : 사용자로부터 두개의 정수를 입력받아 / 더한결과/를 반환하는 함수 def sum(): num1 =int(input("정수 1 입력 :")) num2 =int(input("정수 2 입력 :")) return num1+num2 # 한개의 값을 반환 # 함수 호출 했을 때 결과가 반환되는 함수만 결과...
f701d3dd552f4d8ed27b52872713aa9946509b1a
ananyaarv/Python-Projects
/InsertNumberonBoard/main.py
516
3.84375
4
# Name: Ananya Arvind # Date: 3/12/2021 # Period: 8 # Activity: Lab 2.05 a=input("Select a spot on the board to change:") print("Instead of the number you chose, there will be an X on the spot.") b=['1', '2', '3'] c=['4', '5', '6'] d=['7', '8', '9'] a=int(a) if (a==1): b[0] = 'X' elif (a==2): b[1] = 'X' elif (a=...
48ce5011eff8b6a93965bcbbb16afcb0842ec01f
shashank-shark/numpy-experiments
/BasicPixels/DrawCrossOneNature.py
527
3.65625
4
from scipy import misc import matplotlib.pyplot as plt # read the image imageHere = misc.imread ('nature.jpg') # get the max ranges of pixels in x * y xmax = imageHere.shape[0] ymax = imageHere.shape[1] print (xmax) print (ymax) # use the iterator object of numpy imageHere [range(xmax), range(ymax)] = 0 imageHere [...
be83b6f5e9c2c4cdbc86ba5177e1dc129e22b337
SHAZAM3107/FOSS-TASKS
/MEDIUM/cli.py
1,129
3.828125
4
from PIL import Image availableitems=['asus zenfone','honor 7a','samsung galaxy s9','oppo f9','vivo v11'] price=['10000','11000','9000','50000','15000'] price=list(map(int,price)) print("the cost of each items are listed below respectively") print(availableitems) print(price) n=int(input("how many products do you want ...
1d185ca9c81fb101d939d3dca26a423e85dffebe
ZASXCDFVA/LeetCodeAns
/letter-combinations-of-a-phone-number.py
680
3.640625
4
from typing import List class Solution: def __init__(self): self._map_of = ["abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"] def _append(self, result: List[str], prefix: str, current: str): if current == "": if prefix != "": result.append(prefix) ...
d3167dc953dcc731c9947fb5e838e495f3981dd3
aklgupta/pythonPractice
/Q15 - countdown/countdown.py
376
4.0625
4
"""Q 15 - Countdown Input a integer N from user Print numbers N to 0 in a single line, however, each number should be printed at an interval of 1 second. eg. Input: 5 Output: 5 4 3 2 1 0 (The output is generated over a time of 5 seconds, printing one number per second) """ import time N = input("Enter a number: ") ...
4c5b379b50a8e814e1e608140d1ae3bade9d4ce2
Fragilegod/LinearRegression
/LinearRegression.py
1,553
3.765625
4
import matplotlib.pyplot as plt learning_rate_ALPHA = float(0.0001) initial_theta_0 = float(0) initial_theta_1 = float(0) nombre_iterations = 2000 X=[i for i in range(3000)] Y=[2*i for i in range(3000)] M=len(X) def calc_derivatives(oldtheta_0, oldtheta_1): derivtheta_0 = float(0) derivtheta_1 = float(0) ...
460fc9175814d26f7d552ba0a46742a0a50892ff
Jonathan0137/Sokoban
/soundeffect.py
1,045
3.5
4
import json import pygame def soundEffect(): """This is a function that plays the box moving sound when a box is pushed """ json_file = open("env.json", "r") options_dict = json.load(json_file) if(options_dict["sound_effects"] == "On"): move_box_sound = pygame.mixer.Sound("box_movi...
cd519634b477edc750ab62f974231c399e723152
ycAngus2415/python_learning
/opp.py
1,988
3.75
4
class Student(object): def __init__(self, name, score): self.__name = name self.__score = score def print_score(self): print('%s:%s' % (self.__name, self.__score)) def get_grade(self): if self.__score >= 90: return 'A' elif self.__score >= 60: ...
8de30d1f17d5a3d05ca055b898160885d17fdd04
deelaws/AlertWeb
/AlertWeb/threading_example.py
437
3.5
4
import threading e = threading.Event() threads = [] def runner(): tname = threading.current_thread().name print('Thread waiting for event: %s' % tname) e.wait() print( 'Thread got event: %s' % tname) for t in range(100): t = threading.Thread(target=runner) threads.append(t) t.start() in...
e05b0657015c2a1727df5104565a2cf210cc6142
SeungHune/Programming-Basic
/과제 6/실습 6-3.py
913
3.671875
4
#행렬안에 중복된정수 여부(스도쿠) def issudoku(mat): matlist = [] size = len(mat) for i in range(size): for j in range(size): matlist.append(mat[i][j]) matlist = sorted(matlist) while (matlist != []): if len(matlist) == 1: break if (matlist[0] == matlist[1]): ...
98cae0ea82f3c50f23bcfd80ef82c5f1530103d2
WYC15822755124/spiders
/re_test2.py
336
3.640625
4
#encoding: utf-8 import re #r = raw =原生的 # text = "apple price is $299" # ret = re.search("\$\d+",text) # print(ret.group()) text = "\\n" #= '\n' #python : '\\n' = \n #\\\\n-> \\n #正则表达式中:\n= #\\n->\n # ret = re.match('\\\\n',text) # print(ret.group()) text = "\\n" ret = re.match(r'\\n',text) print(ret.group())
d57bc13fd4d6755cc804d1171d7bce32a1eb3dfe
karasatishkumar/python-practice
/day3/loop.py
324
3.546875
4
datlst = [ "10-nov-2020", "15-dec-2010", "5-apr-1998", "31-dec-1990" ] for cursor in datlst: print("%s - %s" %(cursor.split("-")[1], cursor.split("-")[1][0].upper())) res = [cursor.split("-")[1] + " - " + cursor.split("-")[1][0].upper() for cursor in datlst] print(...
d96d60079e6c15649f0075d3bf45919c98b86082
ASzczesna/Python-1M
/script5.py
214
3.5625
4
napis = "wiek "+str(18) print napis print napis.replace('w','W') print napis.lower() print napis.upper() nap = "ta liczba %f to %s" % (3.14, "licz") print nap print '{0}, {1}, {2}'.format('a','b','c')
163d96671f43f0dea118ea6693473e20cba81157
krusovaa/UdP_cviceni
/kd_tree.py
1,030
3.71875
4
from point_generator import random_square, circle N_POINTS = 100 sq = random_square(N_POINTS) def kd_tree(points, axis): axis = 'x' or 'y' # if len(points) = 1, only print point and return if len(points) == 1: print(points) return # sort points according to axis if axis == 'x':...
ebae7cbaf9c2764e54dc5de60e7d38d8cdbaba7e
Dealead/Employee_Attrition
/Employee-Attrition.py
4,259
4.0625
4
""" An employee attrition data to predict the likelyhood of employee retention. The following points should be noted: (1) Since the data splits the employees into two: those who have left and existing employees, It is necessary to first add an 'Attrition' column and then bring them together as one solid dataset. This ...
351843236f94624df661bd5480d6c5d789b78651
qiubinbin/exercise
/@contextmanager.py
465
3.734375
4
"""利用@contextlib.contextmanager和yield生成器实现上下文管理""" import contextlib @contextlib.contextmanager def pp(m): print('begin') m += 1 yield m # 把传递给yield的值用作__enter__()方法的返回值 """只有在with语句块执行未出现错误时才会执行下面的语句(可以使用finally代替)""" print('end') with pp(6) as temp: try: print(temp / 0) except...
12b8f57b3dce0d8a3a369d4ae15ad128213d1b84
Master-sum/pycharmfiles
/trim.py
252
3.609375
4
""" 作者 :bjx 创建时间 :2020/8/24 11:04 下午 文件名称 :trim.PY 开发工具 :PyCharm """ def trim(s): if s[:1] == ' ': s = s[1:] if s[-1:] == ' ': s = s[:-1] return len(s) print(trim(" ncd "))
1c327c3fa8d8fda5e63e014715c5caf5e84cba29
stimko68/daily-programmer
/challenge_anwers/159_intermediate.py
5,119
4.25
4
""" Rock Paper Scissors Lizard Spock - Part 2 The basic game as seen on The Big Bang Theory, plus a few enhancements: - Looping so the player can play more than once# - Recording of win/tie/lose record of each player and the number of games played# - At the end of the game loop, display the stats from games ...
ec34bf799daa12ddc46d40e8d2edb308b018c53e
LucaCappelletti94/crr_labels
/crr_labels/utils/normalize_cell_lines.py
500
3.75
4
from typing import List def normalize_cell_lines(cell_lines: List[str]) -> List[str]: """Return normalized cell lines. Currently, the only normalization procedure is to convert the cell lines to uppercase. Parameters ---------------------- cell_lines: List[str], The list of the cell ...
a7bbd057d47cd7e2d3c7f54b6395ecec0e6eb2d7
surjitchoudhary/hellogit
/second.py
768
4.28125
4
var1='hello' var2=10 var3=12.4 #check the type of variables in python3 'str'=string,int=integer, float=decimal value print(type(var1)) print(type(var2)) print(type(var3)) #we are here to check what kind of type does input BYDEFAULT TAKE a=input('Bydefault str') b=int(input('Enter integer value')) c=float(input('Enter ...
e07c374a627647f939853f2dbc9dc2dd4176c0d0
pruthvipatnala/CalendarApp
/calendar_app.py
2,265
3.65625
4
""" Calendar """ import calendar import datetime as dt import sys import re import subprocess def display_calendar(month_offset=0): """ Function to display calendar with current date highlighted """ if month_offset > 12 or month_offset < -12: print("The application does not handle offsets gre...
229e31e98acff077faf521f789f23a9796f19d46
BRIANHG89/Python-Exercises-
/condicionalcompuesta/validatresdigitos.py
366
3.90625
4
#ingrese un valor de hasta tres digitos positivos num=int(input("Ingrese un valor de hasta tres digitos positivos")) if num<10: print("Tiene un digito") else: if num<100: print("Tiene dos digitos:") else: if num<1000: print("Tiene tres digitos") else: print("Error e...
ac00eff9f1fe52b8ce22168dd2b48b52e6ce4ec5
kavi707/pythod_examples
/calculator.py
1,049
4
4
def add(a, b): return a+b def substract(a, b): return b-a def multiply(a, b): return a*b def divide(a, b): if b == 0: return "Syntax Error" else: return a/b def getInputs(): print " " print " " print "Welcome to calculator from python" print "your options are:" print " " print "1) Addition" ...
7381fdadafc61c72fdeedac352958550de715060
linminhtoo/Pentago
/game.py
5,174
3.90625
4
import numpy as np from typing import List, Optional class Game: def __init__(self, num_humans: int, game_size: int, win_length: int, first_player: str, sec_player: str, level: Optional[int]=None): self.num_humans = num_humans self.game_size = game_size se...
161e1ababdf6db57f495b821aaad1681c2f81a47
MrHamdulay/csc3-capstone
/examples/data/Assignment_9/dsxriy002/question3.py
1,323
4.09375
4
#Riya Desai #Assignment 9 - Question 3 #15 May 2014 sudokugame = [ ] check = True #keep adding numbers to the grid for i in range(9): sudokugame.append(input()) grid = [ ] for i in range(9): grid.append(sudokugame[i][0:3]) for i in range(9): grid.append(sudokugame[i][3:6]) f...
a6eeafe205707290647075bb74754cf78a550554
PrithviSathish/School-Projects
/ListSort.py
1,008
3.671875
4
# Maximum and Minimum n = int(input("Enter the value: ")) L = [] for i in range(n): print('Enter L[',i,']: ') L += [int(input())] print("Original List: ", str(L)) L2, L3 = list(L), list(L) ch = 0 while ch != 5: print("\n1. Maximum Value\n2. Minimum Value\n3. Ascending Order\n4. Descending Order\n5. Exit") ch = ...
83b8b4ee1611505600a4f425eacdca7ab4beec68
VolodymyrKM/alfred_pennyworth
/Classes/lecture_2/slots.py
1,120
3.75
4
# Slots # https://stackoverflow.com/a/28059785/5841818 # ****************** # What problem solve # ****************** # __slots__ allows to predefine set of attributes class instance will have. (avoid dynamically created attributes) # Reason to use: # 1. Faster attribute access # 2. Space savings in memory # ********...
4a7bd524c42a6493b5ce0791cacf0a76dd68e10d
junhaalee/Algorithm
/solved/LeetCode/course_schedule/course_schedule.py
1,770
3.515625
4
numCourses = 2 prerequisites = [[0,1],[0,2],[1,2]] # visited 없을 때 from collections import defaultdict class Solution: def canFinish(self, numCourses, prerequisites): graph = defaultdict(list) for a,b in prerequisites: graph[a].append(b) visit = set() def dfs(nu...
c5a545412d8bec68565f01493babc87e7c47ae64
Andong501/LeetCode-with-Python
/496-Next-Greater-Element-I.py
1,594
3.71875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # LeetCode with Python # You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corresponding places of nums2. # # The Next Greater Number of a number x in nu...
f8a985159ea3501b21d251f68c24f8902f65adf4
Jay28497/Problem-solution-for-Python
/Python HackerRank Problem Solution/Collections/companyLogo.py
725
3.5625
4
from collections import Counter, OrderedDict import math import os import random import re import sys if __name__ == '__main__': s = input() chars = Counter(s).items() for char, n in sorted(chars, key=lambda c: (-c[1], c[0]))[:3]: print(char, n) ########## # OR ########## chars = Counter(input(...
42f04d0f35a2f5c7b0516e6902be7a099bc5c246
bcaldwell/devops
/setup.py
3,163
3.546875
4
import subprocess import sys import yaml import json import os def query_yes_no(question, default="yes"): """Ask a yes/no question via raw_input() and return their answer. "question" is a string that is presented to the user. "default" is the presumed answer if the user just hits <Enter>. It mu...
c68f9a17146e12de3e24a85322ceede3c0978c6d
chenxu0602/LeetCode
/1198.find-smallest-common-element-in-all-rows.py
1,241
3.71875
4
# # @lc app=leetcode id=1198 lang=python3 # # [1198] Find Smallest Common Element in All Rows # # https://leetcode.com/problems/find-smallest-common-element-in-all-rows/description/ # # algorithms # Medium (74.17%) # Likes: 71 # Dislikes: 7 # Total Accepted: 6.1K # Total Submissions: 8.2K # Testcase Example: '[[...
7261e6a13f693bd6088a2b1488212ea1de748486
Uche-Clare/python-challenge-solutions
/Darlington/phase1/python Basic 2/day 22 solution/qtn9.py
426
3.9375
4
#program that compute the area of the polygon . The vertices have the names vertex 1, vertex 2, vertex 3, ... # vertex n according to the order of edge connections. def poly_area(c): add = [] for i in range(0, (len(c) - 2), 2): add.append(c[i] * c[i + 3] - c[i + 1] * c[i + 2]) add.append(c[len(c) - 2] * c[...
9f2edfec886b2a005ab8315a024e93eec1aeac57
Otumian-empire/tkinter-basic-gui
/bgrid.py
633
3.828125
4
from tkinter import Tk, Label, mainloop from random import choice root = Tk() b = Label(text="I am using a grid here for the B label", width=70, height=10) b.grid(row=3,column=3,padx=5, pady=5) colors = ['black', 'white', 'green', 'red', 'yellow'] for i in range(4): for x in range(4): bgc = choice(colors)...
17f5462a59712e18ff94cc0fdadb039baed080db
GuileStr/proyectos-py
/testInterSection.py
242
3.515625
4
# -*- coding: utf-8 -*- """ Created on Thu Feb 27 15:52:06 2020 @author: palar """ a=[-19,-17,-15,-5,13,18] b=[-14,-13,-11,1,6,7,14,16,18] print("a",a) print("b",b) c=[] for i in a: if i in a and i in b: c.append(i) print("c",c)
eacc425b5cd8e839fb33ef5c64be110cc6cedceb
jpbat/advent-of-code
/2018/day_06/part2/script.py
2,203
3.5625
4
from collections import namedtuple Place = namedtuple('Place', ['x', 'y']) FRINGE_SIZE = 10000 fringe = {} def read_input(): lines = [] while True: try: lines.append(input()) except EOFError: break return lines def fill_grid(place): for fringe_key, fringe...
d9b45aad4a507741df807d9904814eae78d97d0d
rizniyarasheed/python
/oops/multilevelinheritance.py
249
3.625
4
class Parent: def m1(self): print("inside parent") class Child(Parent): def m2(self): print("inside child") class SubChild(Child): def m3(self): print("inside subchild") obj=SubChild() obj.m3() obj.m2() obj.m1()
23655568cfb786d81e034d4b6ed80fb69c189308
Ytr00m/Listas
/Lista2 AED/Questao3.py
116
3.984375
4
pi = 3.14 raio = int(input("Digite o raio do circulo:")) area = pi * raio ** 2 print("A area do circulo é",area)
e9f08082e3f535c92c002cc4af58686019005954
sethgerou/PlantingLog
/backend.py
1,535
3.6875
4
import sqlite3 class Database: def __init__(self, db): self.conn=sqlite3.connect(db) self.cur=self.conn.cursor() self.cur.execute("CREATE TABLE IF NOT EXISTS plants (id INTEGER PRIMARY KEY, crop text, quantity int, plant_date datetime, outcome text, notes text)") self.conn.commit()...
e6fa6e47e776ec2dc5abade3bdbe16d3577e1f7d
SantiagoJSG/Trabajo_Final_30_Abril
/Ejercicio20.py
1,012
3.546875
4
# Ejercicio 20 valor = 0 cien = 0 cincuenta = 0 veinte = 0 diez = 0 cinco = 0 mil = 0 valor = int(input("Ingresa la cantidad de dínero (Mínimo 1.000): ")) if valor >= 1000: cien = int(valor / 100000) reserva = valor % 100000 cincuenta = int(reserva / 50000) reserva = reserva % 50000 ...
06140dcee702faa6edc417e75b2f4b5487567aae
p4r4n0rm4l/random-scripts
/copycontent.py
565
3.609375
4
from sys import argv script, fromFile, toFile = argv def copy(fromFile, toFile): # Open file 'fromFile' for reading as binary sourceFile = open(fromFile, "rb") data = sourceFile.read() sourceFile.close() # Open (or create if does not exists) file 'toFile' for writing as binary destFile = op...
f601d308f6f6816f510220a19cd1a43dc8321461
PanyushkinOOP/OOPb
/datasql.py
2,080
3.609375
4
import os import sqlite3 as db emptydb = """ PRAGMA foreign_keys = ON; create table materials (code integer primary key, name text, priceForGramm integer); create table product (code integer primary key, name text, type1 text, weight integer, price integer, material integer); create table sell (code integer ...
e9140cf46ea883c3f86c2de63735e964e9e2889b
sherinfazer/python
/python38.py
273
3.921875
4
s = float(input(" Please Enter the First Value s: ")) j = float(input(" Please Enter the Second Value j: ")) print("Before Swapping two Number: s = {0} and j = {1}".format(s, j)) temp = s s = j j= temp print("After Swapping two Number: s = {0} and j = {1}".format(, j))
b72f0c91b7339e2fa6ef8909221f0e893926221a
Nikkuniku/AtcoderProgramming
/ABC/ABC200~ABC299/ABC234/a.py
86
3.828125
4
def f(x): return x**2 + 2*x +3 t=int(input()) ans=f(f(f(t)+t)+f(f(t))) print(ans)
86f0d70ea94461b03df823bf130d1e1998259ca3
Kirankumar422/HelloWorld
/programFlowControl.py
573
3.9375
4
# for i in range(1, 12): # print("No {} squared is {} and cubed is {:4}".format(i, i**2, i**4)) # print("Calculation completed") # print("Try again") print("Please guess a number between 1 and 10: ") guess = int(input()) if guess != 5: if guess <5: print("Please guess higher") else: #guess...
43377decd1e70ff4d35070db41d2149703ec2bfe
mkdika/learn-python
/basic/substring.py
109
3.640625
4
str = 'maikel' print(str[-1]) x = len(str)/2 print(int(x)) strx = str[1:len(str)-1] print(f">>> {strx}")
da72f53cb5a87be57964cbeeaef6fd1e28712473
sbsdevlec/PythonEx
/Hello/Lecture/Day04/listType/list04.py
923
4.3125
4
# 리스트에 추가하기 list = [] print(list) list.append(9) list.append(8) list.append(7) print(list) list.append([6,5,4]); print(list) print("*"*30) # 리스트 수정하기 list[0] = 88 print(list) list[1:2] = [77,66,55,44] print(list) #list[1:5] = 33 # TypeError: can only assign an iterable list[1:5] = [33] print(list) p...
4a6432a888a944690081ca22fe7596aa5182107f
tgkei/Algorithm_study
/by_python/programmers/42861.py
875
3.65625
4
from queue import PriorityQueue from math import inf def solution(n, costs): answer = 0 linked = [[inf for _ in range(n)] for _ in range(n)] q = PriorityQueue() visited = set() for p1, p2, cost in costs: linked[p1][p2] = cost linked[p2][p1] = cost idx = 0 visited.add(idx)...
99235b43190897d41f69c810954b46e1e8f438b9
jwyx3/practices
/leetcode/dynamic-programing/largest-sum-of-averages.py
1,072
3.546875
4
# https://leetcode.com/problems/largest-sum-of-averages/ # https://leetcode.com/problems/largest-sum-of-averages/solution/ # Time: O(N*N*K) # Space: O(N) class Solution(object): def largestSumOfAverages(self, A, K): """ :type A: List[int] :type K: int :rtype: float """ ...
1cb649073f435cd622c0e1ad95be884a1a224906
bekbusinova/-1
/arr.py
338
4.125
4
def arr_min(arr): min = arr[0] for elem in arr: if elem < min: min = elem return min def arr_avg(arr): count = len(arr) summ = sum(elem for elem in arr) return summ / count arr = [1, 2, 4, 6, 0] print("minimum") print(arr_min(arr)) print("average") p...
07a8fc2ad5f6981d39cc3506d5ab7fe4203f6d84
Fondamenti18/fondamenti-di-programmazione
/students/1797637/homework01/program02.py
5,743
3.671875
4
def conv(n): '''Viene composta la stringa formata dalle cifre del numero in input in forma letterale. Esse vengono costruite attraverso la chiamata di funzioni secondarie (unita, centinaia, migliaia, ecc)''' numero=str(n) numero='0'*(12-len(numero))+numero num_lett="" num_lett=unita(numero[0],'!...
004bdc7a78db6a8fb131de6978e7d0f2248a7d88
kashyapa/interview-prep
/revise-daily/educative.io/medium-dp/longest-common-subsequence/1_longest_common_substring.py
885
3.546875
4
def find_LCS_length(s1, s2): return find_lcs_rec(s1, s2, 0, 0, 0) def find_lcs_rec(s1, s2, i1, i2, count): if i1 == len(s1) or i2 == len(s2): return count if s1[i1] == s2[i2]: count = find_lcs_rec(s1, s2, i1+1, i2+1, count+1) c2 = find_lcs_rec(s1, s2, i1, i2+1, 0) c3 = find_lcs_r...
24d7edfa905a5ca42695463a74ff1ea611fe4b50
Klinsmann-Agyei/Python-Syntax-Medical-Insurance-Project
/python Syntax Medical Insurance Project.py
1,232
4.1875
4
# create the initial variables below age = 28 sex = 0 bmi = 26.2 num_of_children = 3 smoker = 0 # Add insurance estimate formula below insurance_cost = 250*age - 128*sex + 370*bmi + 425*num_of_children + 24000*smoker - 12500 print("This person's insurance cost is "+ str(insurance_cost) + " dollars") # Age Factor age...
2f875989cc2ff026c53e6f3ed8384b7948a4547b
attoPascal/risk-simulator
/risk.py
1,710
3.6875
4
from sys import argv from random import randrange def roll_dice(): return randrange(1,7) def attack(units): if units >= 3: cast = [roll_dice(), roll_dice(), roll_dice()] elif units == 2: cast = [roll_dice(), roll_dice()] else: cast = [roll_dice()] return sorted(cast, rever...
fcddddd5aab587312d7aa04aa44e27426922242b
jonahliu0426/leetcode
/algo/easy/706.design-hashmap.py
1,968
3.5
4
class ListNode: def __init__(self, key, value, node): self.val = [key, value] self.next = node class LList: def __init__(self, key, value, nxt=None): self.head = ListNode(key, value, nxt) def get(self, key): temp = self.head if not temp: ...
f81f65e8711b3bc4e773cb596fadf3303405f5a7
elhanan18/hello
/RPN_2.py
3,207
3.53125
4
import sys ''' Run: python RPN_2.py "a b +" Variables input: a 2 b 3 ''' class Calculator: def __init__(self): self._expression = [] self._variables = {} self._op_dict = { '+': lambda a, b: a + b, '-': lambda a, b: a - b, '*': lambda a, b: a * b, ...
ed17f29e704ec4d60b190e0aa4c564a08c9e6877
HotHunter/PYTHON-__-begin-to-learn
/Python2Test/d9-6(1.py
289
3.5625
4
__author__ = 'Administrator' l = [0, 10, 20, 30, 40, 50] cnt = len(l) n = int(raw_input('print a number:')) l.append(n) for i in range(cnt): if n<l[i]: for j in range(cnt, i, -1): l[j] = l[j-1] l[i] = n break print 'The new sorted list is:', l
1e9daae6e541ec6bbd6e51b47fcd6863e832a244
Charles-Paley/calculator
/main.py
1,585
3.96875
4
from math import * import math question = input("Enter Sine, Cosine, Tangent, Square Root, Type 1 for 4 operations: ") if question == "sine": sine_num = input("put the number you want to sine here: ") sine_num = float(int(sine_num)) result_sine = (math.sin(float(int(sine_num)))) print(resul...
f131f370b4d835d5d27ff2ce130a998416a8618d
rafaelperazzo/programacao-web
/moodledata/vpl_data/5/usersdata/64/1997/submittedfiles/atm.py
642
3.875
4
# -*- coding: utf-8 -*- from __future__ import division import math #ENTRADA v = int(input('Digite a quantidade a ser sacada: ')) d20 = 0 d10 = 0 d5 = 0 d2 = 0 d1 = 0 #PROCESSAMENTO] while v >=20: d20 = d20 + 1 v = v - 20 while v >= 10 < 20: d10 = d10 + 1 v = v - 10 while...