blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
efdab853d59d23b60963aa22d19d57d35e508419
ulgoon/fcwps-project1
/ssungs_project1/hanoitower.py
669
3.6875
4
def hanoi_tower(disk_num, first, third, seccond): # recursion 함수로 disk_num이 1이 될때까지 반복 if __name__=='__main__': if disk_num == 1: print('{}번 원반을 {}에서 {}로 이동'.format(1, first, third)) else: # 시작점과 이동점, 도착점위치를 받는 위치 변경으로 변경 hanoi_tower(disk_num-1,first,seccond,t...
e722a5c47ce6c2207fed0b31f8739f8c433de46d
supriyaprasanth/test
/9_july/test3.py
763
3.65625
4
from Exam import random file = open('ex.txt','r+') nwfile = open('ex1.txt','r+') print(file.read()) file.seek(0) #function to scramble the words def scramble(i): l = len(i) m = l-1 first = i[0] last = i[m] i = list(i) scram = "" index = 0 nwwrd = "" for j in range(len(i)-2): ...
a7725cac689335bf9a189a90bfffa5301dc32fec
taylor009/Code-Challenges
/hackerRank/practice/stringFormating.py
321
3.640625
4
def string_formatter(number): width = len(bin(number)[2:]) for i in range(1, number + 1): deci = str(i) octa = oct(i)[2:] hexa = (hex(i)[2:]).upper() bina = bin(i)[2:] print(deci.rjust(width), octa.rjust(width), hexa.rjust(width), bina.rjust(width)) string_formatter(17)...
b0efd75f689b154449b1e66c455b3c101b3bf635
glilley54/Week_2Day_4_All_work
/tdd_fizzbuzz/e48_solution/src/fizzbuzz.py
619
4.375
4
# function will take an integer as an argument def fizzbuzz(input): # check if we have received an integer: if type(input) != int: # return error message return "Please enter an integer" # check if it is divisible by both: elif input % 3 == 0 and input % 5 == 0: # return fizzbuzz...
1a07c9f44f56ab08143e87fdc2ace4014129235f
Anthony4421/Python-Exercises
/padlockchallenge6.py
613
4.0625
4
#Padlock Code Challenge - www.101computing.net/padlock-code-challenge-6/ ''' code = Total number of 3-digit combinations where one digit is equal to the sum of the other two digits. ''' code = 0 #Used three for loops to loop through individual digits #from 000 to 999 #Compares x,y and z to see if eithe...
dda5c4e07fc09a304fe992bc7734b5b72ba1246c
picardcharlie/python-201
/04_functions-and-scopes/04_06_sandwich_stand.py
548
4.125
4
# Write a function called `make_sandwich()` that sticks to the following: # - takes a type of bread as its first, required argument # - takes an arbitrary amount of toppings # - returns a string representing a sandwich with the bread on top # and bottom, and the toppings in between. def make_sandwich(bread = "Sourdo...
9d6172cacf977c4c7f8c45f517d124fbdd2b6500
tanmayaggarwal/character-level-RNN
/main.py
2,245
4.25
4
# # This application builds a character-level RNN using LSTMs with PyTorch # The network will train character by character on some text, then generate new text # character by character. # Input: text from any book # Output: model will generate new text based on the text from input book # There are four main steps incl...
a91fa3321e770003373f9fa7bd3870e8de2443f0
IshitaG-2002IGK/basic-programs
/5(b)-binary search.py
659
3.859375
4
print("20CS241_ISHITA G") data=[] n=int(input("Enter the number of elements in the array:")) print("Enter the elements in an Ascending order !") for i in range(0,n): x = int(input("Enter the element %d :"%(i+1))) data.append(x) e=int(input("Enter the element to be searched :")) first=0 last=n-1 fo...
613d903953eea906e4bef1371ce76c860538cde6
NicholusMuwonge/Simple-Learning-challenges
/GroupAnograms.py
191
3.875
4
from itertools import groupby some=['eat', 'em','tea', 'lump', 'me', 'plum'] annogramed=[list(arranged) for words,arranged in groupby(sorted(some, key=sorted),sorted)] print (annogramed)
9d0aa30e7ad120f47895a3086522d4afa521e7fe
Guanhuachen1995/Leetcode_practice
/algorithm/461. Hamming Distance/461.py
319
3.6875
4
class Solution(object): def hammingDistance(self, x, y): """ :type x: int :type y: int :rtype: int """ count=0 while x!=0 or y !=0: if (x & 1) != (y & 1): count = count +1 x=x>>1 y=y>>1 return count
ffb1dd003b877d5b472bfa84603a2615a9f3897c
devendra-gh/ineuron_assignments
/python-assignment-1.py
2,417
4.15625
4
import math """" 1. Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5, between 2000 and 3200 (both included). The numbers obtained should be printed in a comma-separated sequence on a single line. """ # Definition for Get Valid Numbers function def get_val...
2b10195127a33f5174d4be3cb78d0e63b5fe5cde
CristinaMarzo/PrimeraEvaluacion
/Calculadora par-impar.py
252
3.8125
4
def calculadora(): print 'Bienvenido a la calculadora de numeros pares o impares.' n = input('Introduzca su numero aqui: ') if n % 2 ==0: print 'Su numero es par' else: print 'Su numero es impar' calculadora()
053ee66b58ab0dc9240cf8eef2fc5f765cbaa7ec
Ledz96/ML_Project_1
/utils_predictions_manipulation.py
502
3.515625
4
# -*- coding: utf-8 -*- """Utils functions for handling predictions""" import numpy as np def probability_to_prediction(y,threshold=0.5): """given an array of probabilities y, returns a prediction (1 or -1) for each""" replacer = lambda p: 1 if p > threshold else -1 vfunc = np.vectorize(replacer) ...
f3e3ba7493ca929f2d9c74c84e5be9f1d9abf103
DavidAndrade27/DataScienceAndMLBassics
/IA_dovo_r/3_Clustering/K-means/K-means-clustering.py
1,844
4.09375
4
# -*- coding: utf-8 -*- """ Created on Fri Jul 10 18:03:14 2020 Clustering using K-means Important: 1 . Random initialization of centroids (consider using the k-means ++ algorithm) 2 . Determine the number of clusters (consider the elbow method) @author: andra """ # Libraries import numpy as np import matplotl...
7eab03472f265969761aa57574ce6b3962416136
BarryMolina/ITDEV-154
/assignment-4/stack.py
1,001
3.953125
4
from node import Node class Stackll: def __init__(self): self.head = None # object representation def __repr__(self): nodes = [] for node in self: nodes.append(node.data) return f"[{', '.join(nodes)}]" def __iter__(self): node = self.head wh...
535ec4903f18dafc4748d490ba16286fedee15d9
BitBitcode/Numerical-Analysis
/矩阵相关/矩阵运算.py
1,011
3.5625
4
import numpy # 二维输出 A_matrix = numpy.mat("1,2,3; 4,5,2; 7,8,9") B_matrix = numpy.mat("1,2,3; 4,5,2; 7,8,9") print("原矩阵:\n", A_matrix.A) # 转置矩阵 A_matrix_T = A_matrix.T print("转置矩阵为:\n", A_matrix_T) # 共轭转置矩阵 A_matrix_H = A_matrix.H print("共轭转置矩阵为:\n", A_matrix_H) # 逆矩阵 A_matrix_N = A_matrix.I print("逆矩阵为:\n", A_matri...
bc99cc6b2e41cc77edeaebf09bda9d44a1c91bbf
santoshankr/parliament
/parliament/finding.py
1,119
3.53125
4
class severity: """ Used by Findings """ MALFORMED = 1 # Policy is so broken it cannot be checked further INVALID = 2 # Policy does not comply with documented rules HIGH = 3 MEDIUM = 4 LOW = 5 class Finding: """ Class for storing findings """ issue = "" severity = "" locat...
66d3ac24e1659a3bacdec83cb7b55844244d06c3
anantkaushik/leetcode
/238-product-of-array-except-self.py
835
3.59375
4
""" Problem Link: https://leetcode.com/problems/product-of-array-except-self/description/ Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. Example: Input: [1,2,3,4] Output: [24,12,8,6] Note: Please solve it...
36664faea454e5d08427dfb841d6e2f7efeaefa2
Hemanthkumar2112/gcd-of-two-numbers
/gcd and gcd_eculid.py
337
3.671875
4
a = 98 b = 56 def gcd(x,y): if x==0: return y if y==0: return x if x>y: return gcd(x-y,y) return gcd(x,y-x) def gcd_eculid(x,y): if x==0: return y elif y==0: return x else: return gcd(y,x%y) gcd_eculid(a,b) ##14 more efficient gcd(a...
03f634dc1e1e7094ac7261f10f5043d2f3700656
rohitm131/opencv
/drawing and writing on image.py
707
3.59375
4
import cv2 import numpy as np img = cv2.imread('watch.jpg', 1) #cv2.IMREAD_COLOR = 1 #drawing shapes cv2.line(img, (0, 0), (150, 150), (255, 255, 255), 15) cv2.rectangle(img, (15, 25), (200, 150), (0, 255, 0), 5) cv2.circle(img, (100, 63), 55, (0, 0, 255), -1) #-1 to fill the circle with color ...
3acbf3aedffd5f591826bbcc2fb98255c9a20664
hieubz/Crack_Coding_Interview
/leetcode/easy/print_all_permutation.py
670
3.578125
4
class Tools: def __init__(self): self.permutation_arr = {} @staticmethod def to_string(list_chars): return ''.join(list_chars) # O(n!) def permute(self, string, l, r): if l == r: self.permutation_arr[(self.to_string(string))] = 1 else: for st...
d6d96f5d315f4685a3a7069318f271592018eb30
ebondy/Python
/ListOverlap.py
980
4.15625
4
#!/usr/bin/env python3 #Author: Eric Bondy #List overlap practice import random #Import the random module ListA = [random.randint(0, 51) for i in range(1, (random.randint(1, 51)))] #Generate two random lists of integers between 0-50 with a random ...
30bb48b833570df2c1b48cbecec51acb911f23a5
Rayna-911/LeetCode
/LC/python/Reorder List.py
1,086
3.8125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @param head, a ListNode # @return nothing def reorderList(self, head): if head == None or head.next == None: return head ...
9d33f05c5942fff37f4fc5fc3e4787b38e07a15e
rhaeguard/algorithms-and-interview-questions-python
/string-questions/one_away_string.py
1,397
3.859375
4
""" One away string It means if two strings are 1 edit away 1 edit - add, delete, change letter to other letter (even itself) """ def one_away_string(st1, st2): if abs(len(st1) - len(st2)) > 1: return False if st1 == st2: return True if len(st1) < len(st2): st1, st2 = st2, st1 ...
fc56ce68360a6bf55b39835871d69a5c9b9a9769
JoseCordobaEAN/refuerzo_programacion_2018_1
/sesion_5/imprimir_numeros.py
154
3.515625
4
import time # Vamos a imprimir los numeros entre 0 y -10 usando python numero =0 while numero > -11: print(numero) numero -=1 time.sleep(1)
eb491a1feb6ef8294124367e5d350579fbaca5cf
EdwaRen/Competitve-Programming
/Leetcode/37-sudoku-solver.py
1,795
3.96875
4
class Solution(object): def solveSudoku(self, board): """ :type board: List[List[str]] :rtype: None Do not return anything, modify board in-place instead. Backtracking solution that iterates all possible combinations and stops recursing when a board is invalid """ ...
9c82f6839b77fc333d681d56698dbc56ed0b99b5
andylampi/esercizi_workbook_python
/capitolo_7/esercizio_158.py
1,262
3.84375
4
#!/bin/python3 import os def remove(file_1): counter_2 = 0 counter_1 = 0 list_prove = list() list_complete = list() file_find = os.path.abspath(file_1) file_open = open(file_find, "r") list_file = list(file_open) for counter in range(0, len(list_file)): string = "" moment...
228fcb83d8ca4257fa64949da8bc07c2d243b679
syurskyi/Algorithms_and_Data_Structure
/_algorithms_challenges/leetcode/LeetCode/959 Regions Cut By Slashes.py
3,047
4.1875
4
#!/usr/bin/python3 """ In a N x N grid composed of 1 x 1 squares, each 1 x 1 square consists of a /, \, or blank space. These characters divide the square into contiguous regions. (Note that backslash characters are escaped, so a \ is represented as "\\".) Return the number of regions. Example 1: Input: [ " /",...
96c6a1824bb4cd7d6cb752aa14b442e121dcef0b
m1ghtfr3e/Competitive-Programming
/Leetcode/Python/April-30-day-Challenge/moveZero_2.py
325
3.859375
4
def moveZero(nums): x = 0 # we use it as a pointer for i in nums: if i != 0: nums[x] = i x += 1 for i in range(x, len(nums)): nums[i] = 0 return nums if __name__ == '__main__': print(moveZero([0,1,0,3,12])) print(moveZero([0,0,...
dbe5557dd951d7ccc080f7f229c0a614f8ce9728
Dipanshisharma97/spychat
/oddeven.py
110
4.09375
4
a=input("enter a number") if a%2==0: print " it is an even number" else: print "it is a odd number"
f5215d9326de93313b3636a47be4530151b57bba
MonilSaraswat/hacktoberfest2021
/basicCalculator.py
1,119
4.21875
4
def inputValues(): firstNumber = int(input("Enter first number : ")) secondNumber = int(input("Enter second number : ")) return [firstNumber , secondNumber] choice = 'Y' while(choice in ('Y' , 'y')): values = inputValues() operation = input("What Do you want to perform : ") if (operation in ('+...
a0af3002fc2e01654b9140a7b55c71bbc073007a
abimarticio/practice-problems
/basic/prob_12.py
729
4.25
4
# Get the Hamming distance. # Hamming distance is the number of positions at which the corresponding symbols in compared strings are different. # Input # KAROLIN # KERSTIN # Output # 3 def get_hamming_distance(first_text: str, second_text: str): count = 0 for index in range(len(first_text)): if first_t...
40535cdf2f07100843be82b5c64bd71d75f7c945
Harsh1t-coder/Python
/Alarmclock.py
568
3.578125
4
#Alarm Clock from datetime import datetime import urllib import webbrowser time=input("ENter the alarm time : HH:MM:SS ") hour = time[0:2] minu = time[3:5] sec= time[6:8] print("Setting your alarm") while True: now = datetime.now() curr_hour = now.strftime("%H") curr_min = now.strftime("%M") curr_sec ...
7302ec38f9b7748836bf0f34cdb5ebbbefc8993e
KX-Lau/python_algorithms
/02_反转链表.py
528
3.90625
4
class Node: def __init__(self, data): self.data = data self.next = None class Solution: """反转链表, 输出表头""" def ReverseList(self, pHead): # 空链表或链表只有一个结点 if pHead is None or pHead.next is None: return pHead cur_node = pHead pre = None whi...
24cf7942192af48a50b0de8176a90fc87f3b4c3c
jaswanthrk/CV
/blob_detection.py
1,081
3.5
4
# BLOBS : GROUPS OF CONNECTED PIXELS THAT ALL SHARE A COMMON PROPERTY # simpleBlobDetector : CREATE DETECTOR => INPUT IMAGE INTO DETECTOR => OBTAIN KEY POINTS => DRAW KEY POINTS import cv2 import numpy as np image = cv2.imread('images/Sunflowers.jpg', cv2.IMREAD_GRAYSCALE) detector = cv2.SimpleBlobDetector() keypo...
48fccc209d27af25587c06c0e000dea63d2eeb18
kdanyss/ExerciciosPython
/Lista 3/questao3.py
674
3.875
4
name = str (input ('Diga teu nome: \n')) while len(name) <= 3: name = str (input ('Inválido. Diga teu nome: \n')) idade = int (input ('Diga tua idade: \n')) while idade < 0 or idade > 150: idade = int (input ('Inválido. Diga tua idade: \n')) salario = float (input ('Diga teu salário: \n')) while salario < 0: ...
b4932eec2902dcdfbfaf2e3f0b6131cbb1749296
sswietlik/helloPython
/nr10_Operacje_WEJŚCIA_I_WYJŚCIA/nr002_moduł_OS_LAB.py
628
3.625
4
import os import time dir = input('podaj ścieżkę dostępu do katalogu') if not os.path.isdir(dir): print('%s must be a directory' % dir) else: file = input('Wprowadź nazwę pliku :' % dir) path = os.path.join(dir,file) if not os.path.isfile(file): print('file not exist') #print('File %s doe...
3cb950597cffe2da2fdc26c263b826f39f130198
Shiwoo-Park/crawlpy
/utils/log.py
8,319
3.78125
4
#!/usr/bin/env python #coding: utf8 import logging import sys import logging.handlers from os import path,makedirs,listdir,remove #define handler FILE_HANDLER = 0 ROTATING_FILE_HANDLER = 1 TIMED_ROTATING_FILE_HANDLER = 2 STREAM_HANDLER = 3 CRITICAL = logging.CRITICAL ERROR = logging.ERROR WARNING = logging.WARNING I...
91ef7c63e63abf8e18f2109083a3f4fa34dd09fd
solomon585858/BasePython
/homework_01/main.py
1,191
4.21875
4
def power_numbers(*numbers): """ функция, которая принимает N целых чисел, и возвращает список квадратов этих чисел """ return [number ** 2 for number in numbers] # filter types ODD = "odd" EVEN = "even" PRIME = "prime" def is_prime(numbers): prime_list = [] for num in numbers: i...
d4b8894a47573a2986af41af5ca59703fb973fd4
James-Joe/jun_dev.py
/madlibs.py
861
4.1875
4
print("Welcome to Mad libs!") #This function provides the basic functionallity of the game. #The function finishes by calling play_again(), which gives the player #the choice to try again or quit the program. def mad_lib(): part_1 = "I went to the store and saw a " print(part_1) entry_1 = input() part...
2f110050d358f6b5a01a7f6096c31389aec15414
VdovichenkoSergey/QAutomation_python_pytest
/Profile/Person.py
1,138
3.625
4
import datetime class Person: def __init__(self, full_name, year_of_birth): self.full_name = str(full_name) self.year_of_bitrh = int(year_of_birth) self.name_parsing = self.full_name.split() def first_name(self): f_name1 = self.name_parsing[0] return f_name1 def su...
6eaeb2de9cc2b448f450f0a218ada87f124e811a
GenerationTRS80/JS_projects
/python_starter/py_json.py
392
3.8125
4
# JSON is commonly used with data APIS. Here how we can parse JSON into a Python dictionary #Import JSON module import json #Sample JSON userJSON = '{"first_name":"John","last_name":"Doe","age":30}' #Parse to ** DICTIONARY ** user = json.loads(userJSON) print(user) print(user['first_name']) car ={'make': 'Mazda','...
8043be9245f16fb8eea6768df98978a794c07262
IkuyaYamada/plural_form
/plural.py
1,438
3.703125
4
#singular to plural def get_words(): """ comment gizagiza """ rows = int(input()) words_list = [] for i in range(rows): words_list.append(input()) return(words_list) get_words = get_words() target = [x[-2:] for x in get_words] rest = [x[:-2] for x in get_words] def appender(...
c3baf716d2cda2d2d49a86432b87598378464ea0
dersenok/python3_Les2
/venv/LES_1/Les_1_task_7.py
437
4
4
# 7. Определить, является ли год, # который ввел пользователем, # високосным или невисокосным. y = int(input('Введите год в формате YYYY: ')) if y % 4 != 0: print("Обычный") elif y % 100 == 0: if y % 400 == 0: print("Високосный") else: print("Обычный") else: print("Високосный")
e746c5927f0a1757bc0148a3b84e90efc4030100
szymonj99/PythonPractice
/diceRollingGenerator.py
396
4.1875
4
#!/usr/bin/env python3 //Runs on Python 3 import random diceLowerLimit = 1 diceUpperLimit = 6 def diceThrow(): diceResult = random.randint(diceLowerLimit,diceUpperLimit) print("You threw:",diceResult,".") diceAnotherThrow = input("Do you wish to throw again?\n") if diceAnotherThrow == "yes" or diceAn...
c1bde90ee255a8cb67c722deed6225f93762e8ac
marb61a/Course-Notes
/Artificial Intellingence/Python/Notebooks/PyImageSearch University/OpenCV 104/simple_equalization.py
1,049
3.671875
4
# USAGE # python simple_equalization.py --image images/moon.png # This uses the cv2.equalizeHist function # It applies equalisation globally across the entire image rather than # piecemeal which is the approach that the adaptive equalisation takes. # This can lead to washout effects in an image if there is a bright l...
ed88d9018d8e401bdfffa51174fa1a578df63229
prabhatse/ds-algo-practice
/data_structure/heap.py
5,351
3.53125
4
from __future__ import division import sys """ Array LinkedList Space O(n) O(n) Get Min/Max O(1) O(1) Dequeue O(1) O(1) Size O(1) O(1) """ class MinHeap(object): def __init__(self, capacity): sel...
09453e8452699000f20810b3618d762423cc7f6c
mradu97/python-programmes
/primRecur.py
299
3.8125
4
pr = 0 i =2 def prime_rec(n): global pr global i if (n % i) == 0: pr=1 i = i +1 if n > i: prime_rec(n) if pr==0: print("no is prime") else: print("no is not prime") j = int(input("Enter some number")) prime_rec(j)
b7c60fcf76fbab9d4627120ba680f7a9b0d4a0cd
oguh43/bilicka
/ulohy_2.py
2,692
3.578125
4
import re import sys import time from random import randint from itertools import permutations def ask(): x = str(input("\n1) Pankrac\n2) Tajna sprava\n3) Sedi mucha na stene\n4) Alergia\n5) Rigorozka\n6) Statisticky urad\nPre ukoncenie stlacte ENTER\n>")) if x == "1": pankrac() elif x == "2": ...
b1661445ad9ed61b3a2f93a67628e430ed58d877
IBMStreams/streamsx.health
/loinc_generate.py
1,236
3.625
4
import argparse parser = argparse.ArgumentParser() parser.add_argument("--start", type=int) parser.add_argument("--num", type=int) parser.add_argument("--noX", action="count") args = parser.parse_args() start = args.start num = args.num noX = args.noX def nextTen(n): if (n % 10): n = n + (10 - n % 10) ...
46ba09f1fc08b0bd6ce77a1003a3ad4de1dca71d
blankd/hacker-rank
/python/src/blankd/hackerrank/python/str/yourname.py
345
3.625
4
''' Created on Jun 11, 2017 @author: blankd https://www.hackerrank.com/challenges/whats-your-name ''' #No need to one line this in a file def print_full_name(fname, lname): strTemplate = "Hello %s %s! You just delved into python." print strTemplate % (fname, lname) if __name__ == '__main__': print_full_name(...
8dab84e5c295bb1ae8670e07ef84a12a8b9b9cb3
Emmanuel102/Program_Assignment
/firstpractice.py
425
3.546875
4
from typing import ForwardRef print("Hello World!!!") # step 1 name = 'LeBron' # string age = 35 salary = 37.44 # float plays_basketball = True #boolean jersey_number = '23' # string # step 2 car_name = 'ford' x = 50 my_first_name = 'Kurowei' print(type(name)) print(type(age)) print(type(salary)) print(type(plays_b...
6480d550a68b7286bb13ff363ecfa3bbc9a37a3b
bucioluis/python-exercises
/leap_year.py
676
4.3125
4
################################################################################ # This program calculates the leap year from given year ################################################################################ year = int(input("Please input a year: ")) # message = " " #if year > 0: # divisible by 100 if y...
4ef9f46d7b327b2f6425d8ad3465e76b6e187c3a
tomheon/hazardchamber
/parse.py
2,724
3.546875
4
""" Parsing (and unparsing) boards, teams, games, etc. """ from pyparsing import Keyword, Word, nums, Or, Optional, Group import board from constants import BOARD_SIDE import tiles def create_board_parser(side): Edge = Keyword('|') Yellow = Keyword('Y') Blue = Keyword('BL') Black = Keyword('BK') ...
5881ae193e053921dbd7eea8dee68d34747296d2
janaalbinali/python-foundations
/age_calculator.py
1,080
4.1875
4
from datetime import datetime def check_birthdate(year,month,day): today = datetime(2020,1,26) birthdate = datetime(year, month, day) if today > birthdate: return True return False def calculate_age(year,month,day): today = datetime(2020,1,26) birthdate = datetime(year,month,day) ...
307fcb97686a26689864a2b78635d63dce1e0d5b
supercym/python_leetcode
/070_Climbing_Stairs.py
572
3.53125
4
# Author: cym def climbStairs(n): """ :type n: int :rtype: int """ # ********* Low Efficient ************* # if n > 2: # total = climbStairs(n-1) + climbStairs(n-2) # elif n == 2: # return 2 # else: # return 1 # return total # *********...
802b88ffa28463f47221ef6b7d75f5c9837e73a6
Shreyash-A/ComputerProjectES102
/HandCricket.py
1,504
4.1875
4
import random #printing game rules print(" Welcome") print("Lets play Hand Cricket") print("Winning Rules are as follows:") print("You need to enter runs from 1 to 6 \n Then computer will choose a random number \n Whose number is greater WINS \n If both are equal you are out " ) name = input...
701334cb6b276b23efd1076ebbdd00a0aa9d8012
dkokonkwo/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/4-print_square.py
361
4.375
4
#!/usr/bin/python3 """defines function to print square""" def print_square(size): """prints square of given size with '#' character""" if type(size) is not int: raise TypeError("size must be an integer") if size < 0: raise ValueError("size must be >= 0") for row in range(size): ...
c818bbdc1abc018887c1c37be214d85349b980b4
gjwei/leetcode-python
/easy/RemoveDuplicatesfromSortedArray.py
507
3.734375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Created by gjwei on 2017/2/21 """ class Solution(object): def removeDuplicates(self, nums): """ :type nums: List[int] :rtype: int """ if len(nums) < 2: return len(nums) id = 1 for i in range(1, l...
7234fa3d267a83769f4cdd82d6cb1b85b0d6461c
ic3top/KPI-labs
/Python-Gui-Labs/Sem_1/CPC_3/Task_7.py
77
3.640625
4
res = 0 for num in range(0, -21, -2): res += num print(f'Result: {res}')
3ed74909480b4fbe016cbad311f3e732dadc9cf0
vaibhavkrishna-bhosle/DataCamp-Data_Scientist_with_python
/25-Machine Learning with Tree-Based Models in Python/Classification and Regression Trees/Linear regression vs regression tree¶.py
819
3.796875
4
''' Linear regression vs regression tree In this exercise, you'll compare the test set RMSE of dt to that achieved by a linear regression model. We have already instantiated a linear regression model lr and trained it on the same dataset as dt. The features matrix X_test, the array of labels y_test, the trained linear...
f042bb02db6b4840ffef61b3a9cd66e31c11e755
edencheng/NSD_Python
/07_file-access_activity.py
400
4.0625
4
file = open("devices.txt","a") #allow to append a item to the file while True: newItem = input("Please Enter the New Devices: ") if newItem == "exit": print("All done!") break file.write(newItem+"\n") file.close() device_list = [] file = open("devices.txt","r") for item in...
0326fde6a63e57fa035dd04afe0f4f27a1e75c39
ethan-haynes/coding-problems
/python/src/mm.py
313
3.53125
4
def mm(n, m1, m2, m): for i in range(0,n): for j in range(0,n): val = 0 for k in range(0,n): val += m1[i][k] * m2[k][j] m[i][j] = val return m n=2 print(mm( n, [[1,3],[4,2]], [[1,3],[2,1]], [x[:] for x in [[0] * n] * n] ) )
dbf70672adb72124b417cb57742b5ce4c7f1cc67
robinwettstaedt/codewars-kata
/7KYU/count_vowels.py
315
3.84375
4
""" Return the number (count) of vowels in the given string. We will consider a, e, i, o, u as vowels for this Kata (but not y). The input string will only consist of lower case letters and/or spaces. """ def getCount(s): return s.count("a") + s.count("e") + s.count("i") + s.count("o") + s.count("u")
ebc00c6a2d4556677cad9b34ff7eaa4f45c2e0c1
l897284707/index
/继承/__init__.py
962
3.65625
4
# class Amphibian: # name='两栖动物' # def features(self): # print('幼年用鳃呼吸') # print('成年用肺兼皮肤呼吸') # class Frog(Amphibian): # def attr(self): # print(f'青蛙是{self.name}') # print('我会呱呱叫') # frog=Frog() # print(frog.name) # frog.features() # frog.attr() # def digui (ar): # if ar=...
0daaca97e67258d2ada9fbb56d88b0491c446aff
bu3nAmigue/livecoding-tools
/Troop/src/message.py
9,016
3.546875
4
""" Server/message.py ----------------- Messages are sent as a series of arguments surrounnded by <arrows><like><so>. """ from __future__ import absolute_import import re import inspect import json def escape_chars(s): return s.replace(">", "\>").replace("<", "\<") def unescape_chars(s): r...
0c2a50402a21ee30d52bd854a4eaeed47ed4a52e
RyanCirincione/BrainInspiredComputingRepo
/Assignment2/LineDetector.py
383
3.546875
4
import math def createLine(degrees): angle = degrees * math.pi / 180 matrix = [] for i in range(11): matrix.append([0] * 11) x = 0.0 y = 0.0 while x < 6 and y < 6 and x > -6 and y > -6: matrix[5 + int(y)][5 + int(x)] = 1 matrix[5 - int(y)][5 - int(x)] = 1 x += m...
39fd982f7c634e06095443356961580d29cd8475
sungminoh/algorithms
/leetcode/solved/679_24_Game/solution.py
2,828
3.9375
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # # Copyright © 2020 sungminoh <smoh2044@gmail.com> # # Distributed under terms of the MIT license. """ You are given an integer array cards of length 4. You have four cards, each containing a number in the range [1, 9]. You should arrange the numbers on ...
d1a6cf1b658d460a48d5b05ae64b714ae7386a45
bethmlowe/Python
/avg_sale_calc.py
3,149
4.1875
4
#=============================================================================== #Program: Average Sale Calculator #Programmer: Elizabeth Byrne #Date: June 19, 2021 #Abstract: This program will input a salesperson's name follwed by the # first sale amount then the number of sales as...
fcf86017662e1d4fc65a5942afa4de195f1dce91
rafaelperazzo/programacao-web
/moodledata/vpl_data/168/usersdata/264/76257/submittedfiles/exercicio24.py
182
3.84375
4
# -*- coding: utf-8 -*- import math x= int(input('Digite x:')) y= int(input('Digite y:')) i=1 while (i<=x): if(x%i)==0 and (y%i)==0: MDC=i i=i+1 print (MDC)
f6d33b7ae8931af971ba648e577baefac0fe4aa1
munsangu/20190615python
/START_PYTHON/2日/07.フォーマッティング/02.フォーマッティング.py
845
3.796875
4
#변수를 이용하여 포매팅 가능 num = 3 print("I eat %s cakes"%num) print("\n===2개 이상의 포매팅===") #2개 이상의 포맷문자 %() 괄호로 묶어줍니다. print("I eat %s %s cakes"%(num, "cakes")) print("\n===포매팅을 활용한 정렬===") #%와 s사이에 양수로 적어주시면 그 숫자만큼 공간을 확보하고 우측정렬 print("%10s%5s"%("name","age")) print("=" * 20) print("%10s%5s"%("jinwoo","30")) print("%10s%5s"%(...
5154db2044902741379c967525ef6d5128f42635
pedrohbraz/python_codes
/imposto.py
210
3.984375
4
salario = int(input('Salario? ')) imposto = input('Imposto em % (ex:27.5)? ') if not imposto: imposto = 27.5 else: imposto = float(imposto) print("valor: {} ".format(salario - (salario * (imposto * 0.01))))
8e20afba2037a7a0110a911064713a73ad1fffac
Arpit599/Data-Structures-with-Python
/Arrays/Basic/invPermutation.py
410
3.8125
4
def inversePermutation (arr, n) : arr1 = [0] * n for i in range(n): arr1[arr[i] - 1] = i + 1 return arr1 # Driver Code Starts for tc in range(0, int(input("Enter the number of test cases: "))): n = int(input("Enter n: ")) arr = list(map(int, input("Enter the array: ").strip().spli...
be9d9d36faba6dca13247b7faa657c2e09ae6e48
shubgene/AdditionalExercise3
/cone_area.py
680
4
4
# -*- coding: utf-8 -*- """ Created on Tue Aug 21 21:48:53 2018 @author: shurastogi """ class Cone: def __init__(self,radius,height): self.radius=radius self.height=height def area_of_cone(self): pi=3.14159265 area=float(pi*self.radius*(self.radius+((self...
b1023fb0da0e81206f2f1dec8bbba32fb3229d64
katarinarosiak/python_fundamentals
/excercises/fundamentals/lettercase_counter.py
1,238
4.5
4
# Lettercase Counter # Write a method that takes a string, and then returns a hash that contains 3 entries: one represents the number of characters in the string that are lowercase letters, one the number of characters that are uppercase letters, and one the number of characters that are neither. import string def is...
ef04eced5e56c77913c2017619879206c76279a1
Malar86/python-programming-problems
/pg3.py
179
3.8125
4
import random n=5 while n>0: a=int(input("enter a number")) b=random.randrange(0,5) if(a==b): print("you won") break else: print("you lost")
eb2df8c0db09badb3e77d511ec3e623b642b90b3
dhk1349/Algorithm
/Algorithm Assignment/dp_binomial coefficient.py
710
3.515625
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 8 16:52:46 2020 @author: dhk13 """ def bin(n,k): #n, k represents nCk #Dvide and conquer using the concept of Pascal's triangle. if(k==0 or n==k): return 1 else: return bin(n-1, k-1)+bin(n-1, k) def bin2(n,k): #Tihs function ad...
cdf81dda4136b48d7c9cc9cab2f391469eff7f9d
x43s3y/circle_motion
/drawCircle.py
531
4
4
import turtle turtle.colormode(255) window = turtle.Screen() window.title("circle motion") window.bgcolor("pink") red,green,blue = 100,255,0 draw = turtle.Turtle() draw.color(red,green,blue) radius = 150 for i in range(12): try: draw.circle(radius) draw.penup() draw.setposition(i*0, 10...
3e5b4f931d137f51c6d856b1e86efa6302ee5970
Auto-SK/Sorting-Algorithms
/bucket_sort.py
803
3.796875
4
# -*- coding: utf-8 -*- """ @project: Sorting-Algorithms @version: v1.0.0 @file: bucket_sort.py @brief: Bucket Sort @software: PyCharm @author: Kai Sun @email: autosunkai@gmail.com @date: 2021/8/5 14:15 @updated: 2021/8/5 14:15 """ def bucket_sort(arr): min_val = min(arr) ...
96ba44d461dbfba684da27736930eb0521f38529
saintograph/codewars-solutions
/isThisATriangle.py
205
4
4
def add(a, b): return a + b def is_triangle(a, b, c): if add(a, b) <= c: return False if add(a, c) <= b: return False if add(c, b) <= a: return False return True
8989fbdab9c326e7149b30a608ffe4be5edbd070
DJBorn/practice
/python/data_structures/linked_list.py
1,338
3.984375
4
class LinkedList: def __init__(self): self.head = None self.tail = None def print_list(self): output = "" cur_node = self.head while cur_node is not None: output += f"{cur_node['value']} " cur_node = cur_node["next"] print(output) def...
ecb18199f9d45503e9585a723350d3d8c01c1d03
foqiao/A01027086_1510
/midterm_review/most_vowels.py
899
4.21875
4
def most_vowels(tuple): vowel_in_tuple = [] vowel_rank = set() vowel_amount = 0 tuple_of_string = range(0, len(tuple)) for i in tuple_of_string: if tuple[i] == ',': vowel_in_tuple.append(" ") if tuple[i] == 'a': vowel_in_tuple.append(tuple[i]) if tuple[...
189a1be81821808a6024417757cdd8ccc238cc39
gjq91459/mycourse
/Scientific Python/matplotlib/subplots/3_subplots.py
1,118
3.734375
4
import matplotlib.pyplot as plt # plot multiple subplots within one figure def plotSomeExtraData(axes): for i in range(0,8): axes[i].plot([50, 75, 100]) def plotSomeData(axes): for i in range(0,8): axes[i].plot([4, 9, 16, 25, i**2]) def setCustomAxis(fig): left = 0.15 bottom = 0.1 ...
e422554deab94dc0b4cbd8259b19d2efddecfe2b
KronosOceanus/python
/Tk多窗口/myWindow.py
766
3.78125
4
# 窗口类 import tkinter as tk from tkinter import messagebox class myWindow: def __init__(self,root,myTitle,flag): # 创建窗口 self.top=tk.Toplevel(root,width=300,height=200) # 设置窗口标题 self.top.title(myTitle) # 顶端显示 self.top.attributes('-topmost',1) # 根据不同...
fed722f028d28f19296568b77513cdb23190e1e6
saurabhkadam09/Training
/iteration.py
299
3.53125
4
#a=[10,20,30,40] #itr=iter(a) #print(itr.__next__()) class repeat: def __init__(self,m): self.k=1 def __iter__(self): return self def __next__(self): val=self.k self.k=self.k+1 return val b=[11,22,33,44] itr2=repeat(b) print(itr2.__next__())
ab6243933f0ad00f901e0755405659a448bb2af5
asymmetry/leetcode
/0050_implement_pow/solution_1.py
580
3.5625
4
#!/usr/bin/env python3 # O(log(n)) class Solution: def myPow(self, x, n): """ :type x: float :type n: int :rtype: float """ if n == 0: return 1 elif n == -1: return 1 / x else: val = self.myPow(x, n // 2) ...
e666def88e719e2a02ec97b9852d25c3b0a0fce8
gbhuvneshwar/hypertype
/hypertype.py
7,926
4.09375
4
""" (↑t) - hypertype ~~~~~~~~~~~~~~~~ Haskell inspired type system and pattern matching for Python. """ import inspect class BaseType: """Base class for all types. """ def valid(self, value): raise NotImplementedError() def __or__(self, other): return OneOf([self, other]) class Simpl...
d07398f56eedc98ecc2d52c58fb0c59370b9b4af
bits2018wilp/python-lab
/src/main/prep/swap_in_pair_list.py
648
3.75
4
from src.main.prep.node import Node def print_ll(h): lst = [] while h: lst.append(h) h = h.next print(lst) head = Node(1) head.next = Node(2) head.next.next = Node(3) head.next.next.next = Node(4) head.next.next.next.next = Node(5) head.next.next.next.next.next = Node(6) tmp = head h2 =...
58ebf7e7ca781ce05ccfc44b4fcdc7272c5a2224
basu0001/first-pr-Hacktoberfest--2019
/codes/algorithms/quick_sort/python/quicksort.py
772
3.96875
4
def partition(li, start, end): pivot = li[start] left = start + 1 right = end done = False while not done: while left <= right and li[left] <= pivot: left += 1 while right >= left and li[right] >= pivot: right -= 1 if right < left: done = ...
fbb42e2fac5b1e59f82ed2fbe5259e952523baf2
JRYSR/store
/python基础/day07/表格.py
1,490
3.5625
4
import xlrd # 打开文件 wb = xlrd.open_workbook(filename=r"F:\python自动化测试\day07_mysql工具类与excel读取\2020年每个月的销售情况.xlsx") # 确定选项卡 # month = input("请输入月份数字(1-12):") # for month in range(1, 13): # sheet = wb.sheet_by_name("%s月"%(month)) # # 获取表格有多少行,多少列 # rows = sheet.nrows # cols = sheet.ncols # info = "行:%s,列:%s" # print...
8d87fb42934ea268ed3765186e7b5e886a385c32
sjafernik/Hangman
/hangman_2_WORK.py
7,030
3.9375
4
import random import re import sys import string #from words import word_list from display_hangman import stages from display_hangman_hard import stages_hard def Main(): f=open("countries_capitals.txt", "r") word_list=f.read().replace('\n'," | ").split(" | ") #word_list = open("countries_capitals.txt", "r"...
4ffeb71eef1e54c60b3104655c0ea862d7fc6a57
ryanthomasdonald/python
/week-1/python-exercises/small-ex10.py
135
3.953125
4
side = int(input("How big is the square? ")) for i in range(side): for i in range(side): print("*", end = " ") print()
b7873a256a1cee54a448db4adecb2afdcd65d87c
Moro-Afriyie/10-Days-Of-Statistics-Hackerrank
/10 Days of Statistics/Poisson Distribution I.py
614
3.84375
4
from math import factorial def poisson(k, mean): ''' poission probability the probability of getting exactly k successes when the average number of success or mean is given :param k: the actual natural number of successes that occur in the specified region :param mean: the average number o...
8fb55aa5a1d485826674d521823d9791f6206053
mayankmr2-dev/Python-Interview-Prep
/adjacentproduct.py
365
3.671875
4
# Adjacent Element Product # Lets Suppose # 0 1 2 3 4 # mylist = [1, 2, 3, 4, 5] # Expected Output - 5*4 = 20 # we have to iterate till 4 mylist = list(map(int, input().split(","))) print(mylist) sum = [] for i in range(len(mylist)-1): # range is 4 i.e. 0 1 2 3 sum.append(mylist[i]*mylist[i+1]) large...
06ba0d773ab491371232c49a9d8911b3dc70b02b
nkchangliu/puzzles
/leetcode/target_sum.py
697
3.5
4
def target_sum(lst, s): if len(lst) == 0 and s == 0: return 1 elif len(lst) == 0: return 0 cache = {} cache[lst[0]] = 1 cache[-lst[0]] = 1 if lst[0] == 0: cache[0] = 2 for i in range(1, len(lst)): new_cache = {} for key in cache: new_key ...
39bb97fe38df161f39d67fd8bb95e02a9c0d1da3
chars32/grupo-python
/semana3/Sem3Eje2+CarlosGarcia.py
533
4.03125
4
#Hacer un metodo que reciba cuatro parametros, y devuelve el primero #por el segundo, el tercero entre el cuarto, y el segundo menos el tercero. #funcionRara(10,5,6,3) #(50,2,-1) def funcionRara(): lista = [] lista2 = [] print "Dame 4 numeros" print "---------------" for x in range(4): numero = input("Dame un...
24b43bddc911e8934f753805b6986aa269673ff6
IntroProgramacion-P-Oct20-Feb21/trabajofinal-1bim-JamilErasmo
/semana 6/ejercicios-clase-06-1bim-JamilErasmo/ejemplos-while/Ejemplo07.py
484
3.78125
4
suma_total = float(0) contador = 0 bandera = True print("Ingrese las notas de los estudiantes de su materia") while (bandera): calificacion = float(input("Ingrese calificacion: ")) suma_total = suma_total + calificacion contador = contador + 1 temporal = int(input("Ingrese el valor -1 para salir del cic...
cbaf7d1af5b51850a60aa09c8870f35db863811f
m365462129/AutomatedTesting1
/UIAutomatedTest/04pytest/test_fixtures_02.py
720
3.703125
4
print("-------------------------02") def multiply(a,b): return a * b class TestMultiply: @classmethod def setup_class(cls): print("--setup_class--") @classmethod def teardown_class(cls): print("--teardown_class--") def setup_method(self,method): print("--setup_meth...
968307035e279453a183eb05adf8f8e2378bae6b
ucsb-cs8-m18/code-from-class
/08-22/guess_the_number.py
385
4.15625
4
import random up_to = int(input("What number do you want to guess up to? ")) assert(up_to >= 1) number = random.randint(1, up_to) # pick a number from 1 to 100 guess = -1 while guess != number: guess = int(input("Enter your guess: ")) if guess < number: print("Too low") elif guess > number: ...
66506840d9c9bd6f5145a0018c5490fd22984bdf
deepkumarchaudhary/python-poc
/Prep/passingCars.py
552
3.75
4
#The function should return -1 if the number of pairs of passing cars exceeds 1,000,000,000. ##For example, given: # A[0] = 0 # A[1] = 1 # A[2] = 0 # A[3] = 1 # A[4] = 1 #the function should return 5, as explained above. #(0,1) (0,3) (0,4) (2,3) (2,4) MAX_PAIRS = int(1e9) def solution(A): east = passes = 0 ...