blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
07a51aa41cb8f64e4e71f85f97e2628a7d5e173a
mitul3737/My-April-2021--March-2022-Learning
/Automate the boring stuff with Python/page 70 guess output.py
391
3.78125
4
def spam(): print(eggs) # ERROR! # here python thinks that this eggs is actually the local 'eggs' # that was on line 3 and thus gives erroring thinking that we want # output before assigning it . # python does not consider the global eggs value within the spam() function in this case eggs = 'sp...
50559dafbe29ef3506cd53b0efadd561bf365fc8
yjw9012/cracking-the-coding-interview
/chapter-4/4.10-check_subtree.py
1,150
3.765625
4
from Node import Node def is_subtree(t1, t2): if t2 is None: return True if t1 is None: return False if t1.data == t2.data and is_same(t1, t2): return True return is_subtree(t1.left, t2) or is_subtree(t1.right, t2) def is_same(t1, t2): if t1 is None and t2 is None: ...
028819deab158aa3bfb4467e0c29af8071216181
i002900/Simple-Digit-Classifier
/ML_1.py
1,731
3.8125
4
## Simple Digit Recognition using Naive Bayes ## The image dataset is imported from Scvikit Learn import matplotlib.pyplot as plt from sklearn.datasets import load_digits from sklearn.model_selection import train_test_split digits = load_digits() # X = digits.data y = digits.target # The dataset is spli...
c3b0bbf6f07e947226107a247289d63b0ef4b1be
peluza/holbertonschool-higher_level_programming
/0x0B-python-input_output/14-pascal_triangle.py
533
4.0625
4
#!/usr/bin/python3 """pascal_triangle """ def pascal_triangle(n): """pascal_triangle(n) Arguments: n {int} -- the number at row Returns: list -- the pascal triangle """ if n == 0: return [] elif n == 1: return [[1]] else: new_n = [1] re...
4a18321b3bad1a84b037c5a88010622c2181014b
ppinko/python_exercises
/math/rearrange_the_number.py
1,401
3.71875
4
""" https://edabit.com/challenge/jwzAdBnJnBxCe4AXP """ def rearranged_difference(n): l1 = sorted(list(str(n)), reverse=True) l2 = sorted(list(str(n))) s1 = '' s2 = '' for i in l1: s1 += i for j in l2: s2 += j return int(s1) - int(s2) """ Alternative solution """ def rearran...
2e4bb1d5c4444d34a844442a046ccb0035a3e813
PdxCodeGuild/class_platypus
/Code/Sky/python_labs/lab10_average number.py
1,995
3.984375
4
# Average Number # By Skyler Parker # Created on 16AUG18 # Imports import random import math # Define global variables and lists # Define Functions def averages(nums): average = sum(nums) / len(nums) print('\nThe average of the numbers you enter is: ' + str(average)) def median(nums): nums = nums.copy...
222d84f0d0015997095ea20e813005a3aa6dd890
grg-rohit/python_assignments
/assignment/pythonLists/capitalizing.py
178
3.734375
4
#changing the first alphabet of all elements of the following list to capital Bob = ["hurricane", "tambourine", "blowing", "numb"] for element in Bob: print(element.title())
995ace98eebbdc8baaca89c02fcccfc69bf84b42
PandeyAditya14/APS2020
/Competition/CodeChef/untgcd.py
397
3.75
4
for _ in range (int(input())): n = int(input()) if n == 1: print(1) print(1,1,sep=" ") elif n%2 == 0: x = int(n/2) print(x) for i in range(1,n,2): print(2,i,i+1,sep=" ") i+=1 else: print(n//2) print(3,1,2,n,sep=" ") ...
56dde7783dee1da5c5edc34fe88470fa177da5cd
jaewonYoon/DS-AL
/array/1.py
153
3.828125
4
def rotate(arr, n ,d): temp1 = arr[n:d] temp2 = arr[0:n] print(temp1 + temp2) #time complexity : o(n) #auxiliary space : o(d)
9d22942854676f080bb492d4621f9c15c1e2e7a5
markjluo/MITOCW6.00.1x
/Week 1/W1_Practice_Count Bob.py
343
3.953125
4
s = 'bobobobobkhadsjlfaaahkabobbob' bob = 0 start = 0 end = 3 for letter in s: if s[start:end] == 'bob': bob += 1 start += 1 end += 1 print('Number of times bob occurs:', bob) # OR num_bob = 0 for letter in s: if s[0:3] == 'bob': num_bob += 1 s = s[1:] print('Number of times bo...
0ec8e3791078ae62f3bcb60be67d310c87296f0c
C-GDA-TC1028-004-2113/tarea1-A00227374
/assignments/05Lustros/src/exercise.py
314
3.859375
4
def main(): #escribe tu código abajo de esta línea nacimiento= int(input("Dame el año de nacimiento: ")) actual= int(input("Dame el año actual: ")) calculo= (actual-nacimiento) lustros= calculo/5 print ("Los lustros que has vivido son:", lustros) if __name__ == '__main__': main()
1ee728547ebc8d78380a877d879a99a073b4ffae
ccu516/Python_Practice
/04.InputOutput.py
1,110
3.84375
4
## >python 04.InputOutput.py AA BB CC import sys print('Hello '+sys.argv[0]+'!') ## Hello 04.InputOutput.py! print('Hello '+sys.argv[1]+'!') ## Hello AA! print('Hello '+sys.argv[2]+'!') ## Hello BB! print('Hello '+sys.argv[3]+'!') ## Hello CC! ## Input name = input('Please enter your name:') print('Welcome',na...
dbae4be0bc00330bcc758ace4aa0839043017774
mehdilebranchu/TP13
/hffoze.py
356
3.5625
4
def printValues(self): print(self.__root.getVal()) self.__root.getLeft() if self.__root.getRight() == None and self.__root.getLeft() == None: return if self.__root.getLeft() != None : print(self.__root.getLeft().getVal()) b = binaryTree(self.__root.getRigh...
84986beec248ee7238a338e469dbd750f4163eaa
atbolsh/primitive_abundant
/primitiveabundant3/code/number_theory2.py
3,481
3.6875
4
'''A module with some of the most common number-theoretic functions.''' import primes2 #told you we would need this. def tau(n, primelist = None, primefactorization = None): '''the number-theoretic method for computing the number of factors of n''' if primefactorization == None: #initiate the prime factorization ...
decd224b8262630bb0e2b21ddfe0b34c02d24d8f
mithun810/IAS_Project
/chisq2.py
2,021
3.703125
4
import pandas import numpy from sklearn.feature_selection import SelectKBest from sklearn.feature_selection import chi2 import csv def load_csv(filename): dataframe = pandas.read_csv(filename) array = dataframe.values #Storing the attribute names with open(filename, 'r') as f: first_line = f.readline() attribut...
95c9047c6056600a2c275b09ab59ac5702ccbe35
WaleedRanaC/Prog-Fund-1
/Lab 6/Coffee/AddRecords.py
872
4.375
4
#this program adds coffee inventory records to #coffee.txt def main(): #create a variable to control loop another='y' #open the coffee.txt file in append mode coffeeFile=open('coffee.txt', 'a') #add records to the file while another=='y' or another=='Y': #get coffee reco...
9c3b93e38adfe8b960a0452f36ab26cf1610493a
Rajdp07/Groking-the-coding-Interview
/invert_binarytree.py
974
3.859375
4
class Node: def __init__(self, val): self.val = val self.left = None self.right = None def levelOrder(root): q = [root] while q: curr = q.pop(0) print(curr.val, end = ' ') if curr.left: q.append(curr.left) if curr.right: q.appe...
f8735ae5641139f11bbc534c618ebc7edfd87cf4
dna001/advofcode2020
/12/12.py
3,721
3.5
4
#!/usr/bin/env python3 """ AdventOfCode day 12. """ import argparse import logging import os import sys import json import fnmatch from datetime import datetime def get_args(): """Parse args from terminal.""" parser = argparse.ArgumentParser( description='AdventOfCode') parser.add_argument( ...
8bbd9d0db31542108bb94bcb0ff96b4d5271596e
PepAnalytics/Python
/homework3/firsttask.py
280
3.859375
4
def first_func(): a = int(input('Enter the first number: ')) b = int(input('Enter the first number: ')) if b == 0: print('Can not entered zero!') pass elif b != 0: result = a / b print(result) return result first_func()
52564328e96a80797ef3248b2c4468ec8b052fd5
jphuse/PythonExamples
/The Python Workbook/Exercize 51.py
1,659
4.34375
4
#Asking the grade of the user. lgrade = raw_input("What is your letter grade? ") #Using the letter grade to get the Grade Point for the class. if lgrade == "A+": print "Congratulations! Your grade points are at a 4.0." elif lgrade == "A": print "Congratulations! Your grade points are at a 4.0." elif lgrade ...
62837af5e7cc900c6ac587b7b3b9b15fe8ae2b3e
LiuFang816/SALSTM_py_data
/python/eliben_deep-learning-samples/deep-learning-samples-master/logistic-regression/regression_lib.py
10,835
3.734375
4
# Common library code for running logistic regressions and classifiers. # # Eli Bendersky (http://eli.thegreenplace.net) # This code is in the public domain import numpy as np def augment_1s_column(X): """Augments the given data matrix with a first column of ones. X: (k, n) k rows of data items, each having ...
11aee0589b214c887b539555ae18971ba84cea24
lawtech0902/py_imooc_algorithm
/tree/449_serialize_and_deserialize_bst.py
1,345
3.8125
4
# _*_ coding: utf-8 _*_ """ __author__ = 'lawtech' __date__ = '2018/5/1 下午2:36' """ # Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None import collections class Codec: def serialize(self, root): ...
fc6d38252ad5396ca9aa19dff9022bb13cdb0776
vlgandara/programas-.py
/imprime_matriz.py
306
3.59375
4
minha_matriz = [[1, 2], [3, 4], [5,6]] def imprime_matriz(minha_matriz): lin = len(minha_matriz) col = len(minha_matriz[0]) for i in range(lin): for j in range(col): if (j != (col-1)) : print(minha_matriz[i][j],end=' ') else : print(minha_matriz[i][j]) imprime_matriz(minha_matriz)
180567adf232cdd1a2fef388083f1540612378d9
Nukalakrupani12345/pythonProblems
/multiples.py
145
4
4
def multiples(): sume = 0 i = 1 while i < 1000: if i % 3 == 0 or i % 5 == 0: sume = sume + i i = i + 1 return sume print(multiples())
90260ff5905bb12ec256b1ed407189ce73a72076
poom9091/Test-Intern
/Intern_3.py
1,083
3.703125
4
import random def randomNumber(): fivenum =[] listrandom = '' for i in range(5): fivenum.append(random.randint(0,9)) for n in range(12): listrandom += str(fivenum[random.randint(0,4)]) # แสดงคำตอบ # print(listrandom) return listrandom def inputnum(listnumber) : count=0 ...
79a29329caf30e04cbf38ddaeead9511083cbc44
JobsDong/leetcode
/problems/141.py
697
3.71875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = ['"wuyadong" <wuyadong311521@gmail.com>'] # Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def hasCycle(self, head): """ :type h...
11ab3501fa866b2a4a069579604706b8e24332c3
Stefo16/Guessing-Game
/GUESSING GAME.py
472
3.875
4
secret_pair = "76" guess = "" guess_count = 0 guess_limit = 10 out_of_guesses = False while guess != secret_pair and not(out_of_guesses): if guess_count < guess_limit: guess = input("Pick any two digit number: ") guess_count += 1 else: out_of_guesses = True if out_of_gue...
ee1542a0977ba409172e2e0b250313b38f7a95d6
tuhiniris/Python-ShortCodes-Applications
/class and objects/Create and use custom Self parameter.py
369
3.921875
4
''' self is an object reference to the object itself, it does not have to be named self , but it has to be the first parameter of any function in the class. ''' class Employee: def __init__(person,salary,name): person.salary=salary person.name=name def printDetails(e): print(f'{e.salary} : {e.name...
76ba14378db38da23a5d767759392687508ee29b
wgmackenz/pdx_code_guild_init
/pdx_code_labs/mad_lib.py
545
4.03125
4
noun1 = input("Give me an animal: ") noun2 = input("Give me another animal: ") verb1 = input("Now give me a past tense verb: ") # I made this past tense so the flow of the final Mad Libs is smoother. verb2 = input("Let's go with one more past tense verb: ") # I made this past tense so the flow of the final Mad Libs is ...
05545ada6b25cfb5e8d39062f618ad96c97082e6
MarcoC1796/interview_programming_problems
/EPI/6.10_write_a_string_sinusoidally.py
487
3.734375
4
# Probelm: write a program which takes as input a string and returns the snakestring of s. # EPI Judge: snake_string.py def snake_string(s): sinusoidal_s = [] def construct_s(start, stop, step): for i in range(start, stop, step): sinusoidal_s.append(s[i]) construct_s(1, len(s), 4) ...
5266f54e8762dc39d7ff5cf3b23737b75ca60704
AlexandrDaultukaev/hirst_painting
/main.py
1,372
3.53125
4
import turtle as t import random # for extract colors from an image import colorgram sc = t.Screen() t.colormode(255) tim = t.Turtle() t.setworldcoordinates(0, 0, sc.window_width(), sc.window_height()) tim.pensize(20) rgb_colors = [(1, 12, 31), (53, 25, 17), (218, 127, 106), (10, 104, 159), (242, 213, 6...
01b734d08ab738ff3fecc7551d1cf207e4398105
Rachitaanand/heartdisease.github.io
/data.py
956
3.53125
4
### PREPERATION ### import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns #data import df = pd.read_csv("/kaggle/input/heart-attack-analysis-prediction-dataset/heart.csv") #shape of dataset print("The shape of the dataset is : ", df.shape) #Preview of the first 5 rows of the ...
8c7ba698768fa682e80052f6c184ba4e425de709
ModeConfusion/how-to-python-code
/challenges/how-to-check-key-in-dictionary/check-key-advance-dict.py
1,191
4.46875
4
# link to original challenge: https://therenegadecoder.com/code/how-to-check-if-a-key-exists-in-a-dictionary-in-python/#challenge # Updated challenge: The main challenge was to look for key in the dictionary where all the keys are lowercase. However, in this challange, keys are in randomcase. dictionary = { "fIRe"...
809981996e5c68b50c9ca003ee02f95c8da600cb
guilhermeG23/CparaPython
/aula3/exercicio/exercicio4.py
604
4.0625
4
salario = float(input('Entre com seu salario: ')) if salario > (780 * 15): print('Seu salario: {}\nMais de 15 salarios minimos'.format(salario)) elif salario >= (780 * 5) and salario <= (salario * 15): print('Seu salario: {}\nEntre 5 a 15 salarios minimos'.format(salario)) elif salario >= (780 * 3) and salario ...
5f436fc1f0e0b1979552ab27d94f616da400be86
Lyxcrea/python-homeworks
/p22_Dice.py
1,499
4.3125
4
# Program Name: p22_Dice.py # Name: Charlize Serrano # Version: Python 3.7.0 # Date Started - Date Finished: 9/28/18 - 9/29/18 # Description: Write a Dice Game program that generates two random dice values # between 1 and 6 for you, and 2 for the computer. print("Beat the computer!") from random import randint while...
066713912089f939647957583630031198607c66
kiki-zjq/LeetCode_Study
/Arith/Python/836. 矩形重叠.py
795
3.8125
4
### 2020/3/18 # 矩形以列表 [x1, y1, x2, y2] 的形式表示,其中 (x1, y1) 为左下角的坐标,(x2, y2) 是右上角的坐标。 # 如果相交的面积为正,则称两矩形重叠。需要明确的是,只在角或边接触的两个矩形不构成重叠。 # 给出两个矩形,判断它们是否重叠并返回结果。 # 示例 1: # 输入:rec1 = [0,0,2,2], rec2 = [1,1,3,3] # 输出:true # 示例 2: # 输入:rec1 = [0,0,1,1], rec2 = [1,0,2,1] # 输出:false class Solution: def isRectangleOverl...
22be8a12f61bae0d8b628705dc1f53f51b99a23c
cp-helsinge/eksempler
/50-function-parameter-by-referance.py
348
3.53125
4
# function parameter by referance def try_to_change_string_reference(the_string): print('got', the_string) the_string[0] = 'In a kingdom by the sea' print('set to', the_string) outer_string = ['It was many and many a year ago'] print('before:', outer_string) try_to_change_string_reference(outer_string) p...
a11050b799bb6300d66320f050bfd9b49adc7cf0
MatthewNewell006/udemy
/src/advanced_python_modules/os_module.py
2,447
3.6875
4
# Python's os module and shutil allow us to easily navigate files and directories on the computer and then perform actions on them, # such as moving them or deleting them. f = open('practice.txt', 'w+') f.write('This is a test string.') f.close() print('\n') # =========================================================...
d45b5c92bd25e5555d1b1e7eafd3a1e3111dd560
kongtaoxing/Freshman-Short_Semester-Python
/实验1源码/4.逆序.py
194
3.671875
4
a=input('请输入一个小于10位数的正整数') arr=list(a)#分开各位数 arr.reverse()#逆序 b=len(arr) print('这个数的长度是{},逆序输出的结果是{}'.format(b,arr))
bbd6016b25fafd3da332e3f945eb79dc22176ceb
SteveBlackBird/EM_HW
/Chapter_8/8_12_EM.py
330
3.640625
4
# Sandwiches def make_sandwich(*toppings): """ Make sandwich with toppings """ print("You want a sandwich with:") for topping in toppings: print(f"-{topping}") return topping make_sandwich('tuna', 'lime', 'butter') make_sandwich('meat', 'bbq', 'cheese') make_sandwich('chicken', 'cheese', '...
2e430cd8135c5d9009b6afde30339bb58181819a
HumanBones/Tic_Tac_Toe
/TTT.py
2,769
3.78125
4
import random # The game board board = [0,1,2, 3,4,5, 6,7,8] def checkDraw(list): #checks for draw,if no str in list if all(isinstance(elem, str) for elem in list): return True else: return False def show(): ...
2f6d88a082b2c9ecfa34b27317a6d306cab57dcd
upRos3/python_masterclass
/basics-of-python/variables2.py
935
4.21875
4
parrot = "Norwegian Blue" print(parrot) print(parrot[0]) print(parrot[3]) print(parrot[-1]) print(parrot[0:6]) # will start from beginning of string print(parrot[:6]) # will start from index 6 till end print(parrot[6:]) # can also go backwards print(parrot[-4:-2]) # slicing everything from index 0 - 6 (non inclusiv...
ccdce30ccefe2728d589d433051ca4aa2124ca25
zahra459/find-uniqe-ip-in-txt
/my code find ip in file txt
582
3.84375
4
#!usr/bin/python #find duplicate ip in ip.txt and write to final_file.txt def read_file(file): x = open(file,"r") content_file = x.read() print(content_file) x.close() lst_ip = content_file.split("\n") #find duplicate item uniqe_list=[] for item in lst_ip: if item not in uniqe_list: uniqe_list.append(item) ...
28cc8abdfe18165faa5e92b62f61e53a5dbb43ef
praneet195/ECE695_DL
/hw1.py
3,519
3.71875
4
# -*- coding: utf-8 -*- """ Created on Thu Jan 23 15:39:35 2020 @author: singh671 """ import random import string class People: def __init__(self,first_names,middle_names,last_names,order=None): self.first_names=first_names self.last_names=last_names self.middle_names=middle_n...
3189f4ea6ebc8061ca045d89039794ad2a06b515
MitchellJohn04/PROJECT-PYTHON-
/456.py
1,525
3.609375
4
#ex-4 cars = 100 space_in_a_car = 4.0 drivers = 30 passengers = 90 cars_not_driven = cars - drivers cars_driven = drivers carpool_capacity = cars_driven * space_in_a_car average_passengers_per_car = passengers / cars_driven print "There are", cars, "cars available." print "There are only", drivers, "drivers availabl...
d4f48b032c66ed8d427122b450eba1bb0be3b808
Wyingying/wwpython
/day05/mydequeue.py
890
4.53125
5
''' python 实现双端队列 ''' class Deque(object): def __init__(self): self.__list = [] '''从列表头部添加一个item元素''' def add_front(self,item): self.__list.insert(0,item) '''从列的队尾添加一个item元素''' def add_rear(self,item): self.__list.append(item) '''从队列头部删除一个元素''' def remove_front(self): return self.__list.pop(0) '''从队列尾...
0ee3c04a50ee278dfe9816089d221de63cc0a5ab
sarmisthamaity/pythonLogicalquestion
/sec_max.py
273
3.546875
4
list1=[23,45,12,11,89,6] index=0 maxi=0 while index<len(list1): if maxi<list1[index]: maxi=list1[index] index=index+1 big=maxi secmax=0 i= 0 while i<len(list1): if maxi >list1[i] and secmax<list1[i]: secmax=list1[i] i=i+1 print ("secmax",secmax) print("max=",big)
761e04b57bcbfb2e2c70c3c0de4fbf09ebf05ce7
reontakado/python2
/4番.py
139
3.5
4
# -*- coding: utf-8 -*- """ Created on Mon Oct 14 23:37:36 2019 @author: reon """ l=[1,2,6,4,5,8,2] for i in l[::-1]: print(i)
d7be1ed954c03672951309f63880d0f273e2e860
tylerthecoder/CheckersAI
/src/move.py
2,264
3.96875
4
class Move(): def __init__(self,start,end,board): self.start = start self.end = end self.board = board self.spots = board.board self.valid = False self.error = "" self.jump = False #not a spot on the board if not self.board.isRealSpot(...
ca4545fd035e3c82dd23dd9c5a4f329d50217ca2
tcandzq/LeetCode
/DeepFirstSearch/SubtreeOfAnotherTree.py
1,652
3.765625
4
# -*- coding: utf-8 -*- # @File : SubtreeOfAnotherTree.py # @Date : 2022-06-21 # @Author : tc """ 572. 另一棵树的子树 给你两棵二叉树 root 和 subRoot 。检验 root 中是否包含和 subRoot 具有相同结构和节点值的子树。如果存在,返回 true ;否则,返回 false 。 二叉树 tree 的一棵子树包括 tree 的某个节点和这个节点的所有后代节点。tree 也可以看做它自身的一棵子树。 输入:root = [3,4,5,1,2], subRoot = [4,1,2] 输出:true 输入...
efd588eb8102310a5671a2158c8451f659ef445f
MercyOtswilla/assignment_3
/assignment_3_3.py
144
4.03125
4
def main(): import math num = int(input("Enter a number: ")) result = math.sqrt(num) print("The square root of", num,"is", result) main()
8e98457357ac42d11ed83bb19944d8376a749d98
jm9176/Data_structures_practice
/Reversing_the_sentence.py
1,552
4.1875
4
''' Reversing the given sentence. For e.g. if the input sentence is 'Hello World' then the output will be returned as 'World Hello' ''' # Class for the stack, to store and pop the word # element class stack: # Initialization def __init__(self): self.stack = [] # Insert the element to the stack ...
93d7361609f8393475c7eda575b92ac1df0e9fa4
u4atharva/my-code-arsenal
/Computer Vision/SolveCube/venv/Print_Z.py
279
3.8125
4
import numpy as np def PrintZ(input1): if int(input1) < 3: return 'Invalid Input! Input should be greater than 2.' else: result = np.eye(input1, dtype=np.int) result[[0,-1]] = 1 return result[::-1].flatten().tolist() print(PrintZ(6))
5dabb9f4a78af240ff757676695dbc876bceeee7
dominicwllmsn/thinkpython
/exercises/chapter9/ex97.py
312
3.796875
4
def consecutive_doubles(word, total): i = 0 doubles = 0 while i < len(word)-2: if doubles >= 3: return True if word[i] == word[i+1]: doubles += 1 i += 2 continue i += 1 return False with open('words.txt') as fin: for line in fin: if consecutive_doubles(line.strip(), 3): print(line)
b1fd517bbac927626e7d0ec0b6763b72def8a056
aashirsaroya/APLAB
/180953276/Lab4/l4_1.py
204
3.65625
4
import math a = int(input('Enter a number of your choice ')) print('The Sine of ',a,' is ',math.sin(a)) print('The Square Root of ',a,' is ',math.sqrt(a)) print('The Log of ',a,' is ',math.log(a))
b1006d923b8c986e007b938c1e336cfd8ef739d0
angcarvas/Code4Fun
/src/python/lambda-expression.py
120
3.65625
4
import functools list1 = [1,2,3,4] print(list1) func = lambda x,y:x*y varf = functools.reduce(func,list1) print(varf)
79cbc581e92a04bd9eef563ecdee2568246e7683
AdamZhouSE/pythonHomework
/Code/CodeRecords/2248/60589/260720.py
135
3.53125
4
n=int(input()) a=int(input()) b=int(input()) num=0 while n>0: num+=1 if num%a==0 or num%b==0: n-=1 print(num%(10**9+7))
1a4495f7c6e32c8d01c54b181d10ab197b430403
bauer1331/AB_python
/vlookup.py
2,473
4.09375
4
# -*- coding: utf-8 -*- """ Andrew Brown 12-29-2015 Look up values from one or more columns in data frame obj and insert them into data frame dataframe. The lookup is accomplished by selecting the first row of obj where all of the columns in the keymapping dictionary have the same value. The keys in keymapping corres...
996f0249f745587666f7cbfa365da86b93b34e1e
yash19021998/assignment-1-yash19021998
/py3.py
266
4.53125
5
#Write python program to enter value in centimetre and convert it to meter and kilometre. cm=input("enter value in centimeter for conversion: ") m=cm/100.0 km=m/1000.0 print "values after conversion for %f centimeters are %f meters and %f kilometers"%(cm,m,km)
c79582d8b3c1e98496d8320e7c32b447fcb709a2
Tech-at-DU/Twitter-Bot
/examples/hash_table_test.py
702
3.5
4
from hash_table import HashTable def test(): htb = HashTable() htb.set('I', 1) htb.set('V', 5) htb.set('X', 10) htb.set('L', 50) htb.set('C', 100) htb.set('D', 500) htb.set('M', 1000) print(htb.get('I') == 1) print(htb.get('V') == 5) print(htb.get('X') == 10) print(htb...
e051ada0d97bfb2d961ca802e250a64c8fe4567f
Mervespm/PythonSortingAlgorithm
/Udemy-DataStructure/QuickSort.py
598
4.03125
4
def quicksort(arr, left, right): if left < right: partititon_pos = partition(arr, left, right) quicksort(arr, left, partititon_pos - 1) quicksort(arr, partititon_pos + 1, right) def partition(arr, left, right): i = left j = right - 1 pivot = arr[right] while i < j: while i < right and arr[i] < pivo...
f258fa8ec1f5d6695c0f8696e63a38be9155cd68
haiou90/aid_python_core
/day04/exercise_personal/02_exercise.py
415
3.875
4
""" 循环变量 -> 开始 循环条件 -> 终止 增减变量 -> 间隔 """ # count = 0 # while count < 4: # print(count) # count += 1 # # count = 2 # while count < 7: # print(count) # count += 1 # # count = 1 # while count < 8: # print(count) # count += 2 # # count = 8 # while count > 3: # print(count) # count -= 1 # co...
2191be8e19583d94bc05a9ca43266bfd3496c1ca
kevinddchen/AlphaGomoku
/player_basic.py
8,182
3.59375
4
import numpy as np import gomoku class FeaturePlayer(gomoku.Player): '''Move according to basic features. 'get_features()' returns a [size, size, 8]-shape array containing 9 features for each position of the board: 0: Number of 2-chains the move will create. 1: " " 3-...
d1266f2981bb3406f2080879dc6eded4dfabe1e9
JLMarshall63/myGeneralPythonCode
/DateTimeFunc.py
3,005
3.96875
4
from datetime import datetime dt = datetime.now() print '%s/%s/%s' % (dt.month, dt.day, dt.year) print dt print dt.month print dt.day print dt.year print '%s-%s-%s' % (dt.month, dt.day, dt.year) print dt.hour print dt.minute print dt.second print '%s:%s:%s' % (dt.hour, dt.minute, dt.second) p...
5ab7670b4d3cd2bd9736f64b33029976497a1aee
Simbadeveloper/QuestionMachine.io
/OOP/OoopQuestionMachine.py
5,507
3.859375
4
user_details = dict() user_posts = dict() user_answers = dict() user_questions = { 1: {'silas': 'what does YOYO mean?'}, 2: {'paul': 'How is KISS DRY concept implemented ?'}, 3: {'joshua': 'Why do you love coding?'}, } user_answers = { 1: {'paul': 'you own your own'}, 2: {'joshua': 'keep it simp...
9a1ec6bde3db5182e26eae795d863cb1d5761634
peterlulu666/ThinkingPythonCode
/scrabble_points.py
1,501
4.09375
4
def bag_of_letters(word_dictionary): """ Params: dictionary where ​key​ = letter and ​value​ = frequency of that letter. Returns: a list of letters, with each one repeated according to its frequency. Example Input: ​{'A':1, 'B':2}​. Expected output:​ ['A', 'B', 'B'] """ # Initialize the letters ...
b487c9988d96cbd6fd3b1747abe15ca27aa39dfd
Sheetal2304/if_else
/Leap_year.py
211
4.1875
4
year=int(input("enter the year")) if year%4==0 and year%100==0 and year%400==0: print("it is a leap year") elif year%4==0 and not(year%100==0): print("it is a leap year") else: print("it is not a leap year")
0eef900b8268f01fc55013b6c57f686330e5c498
st102/2020-1st-St102-Algorithm-Sprint
/week_02/codewars/shHong/200831_Sum of Digits_Digital Root-Python.py
145
3.796875
4
def digital_root(n): number = str(n) while len(number) != 1: number = str(sum(int(num) for num in number)) return int(number)
813aa619c2a5b745ba515ef095df2c345804ae0c
nkmashaev/Courses
/homework3/task04.py
345
3.890625
4
def is_armstrong(number: int) -> bool: """ Define is the number is Armstrong one :param number: number to check :return: True if number is Armstrong else false """ digit_list = [int(x) for x in str(number)] n = len(digit_list) armstrong_sum = sum([x ** n for x in digit_list]) return...
fa18c7b5a91c0eec68f31e9d7f1f86f8ced943d1
AnthonyTsui/AlgoPractice
/LeetCode/Medium/116.Populating Next Right Pointers 2.py
1,585
4.3125
4
# Given a binary tree # struct Node { # int val; # Node *left; # Node *right; # Node *next; # } # Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL. # Initially, all next pointers are set to NULL. # Follow up: # You may only...
12da3a06fd7fde8836a41085c2a76025801b7025
vikas-ukani/Hacktoberfest_2021
/URLShortener/Script.py
423
3.75
4
import pyshorteners def URL_shortener(url): s = pyshorteners.Shortener() shortened_url = s.osdb.short(url) print("Here's your shortened URL:") print(shortened_url) choice = 'y' while(choice == 'y' or choice == 'yes'): url = input("Enter the URL you want shortened: ") URL_shortener(url) ...
d346324b5c80075d7e1c9abc97cbb9a3051658ba
jingshisun/KenyaParliamentaryDebates
/Cabinet Members and MPs/MPsSpeakingCount/MPSpeakingCount.py
4,102
3.6875
4
""" Created on Tue July 18 @author: arian1123 """ import glob import os import re import pandas as pd from collections import Counter years = {1963, 1964, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1977, 1978, 1979, 1980, 1981, 1983, 1985, 1987, 1990, 1992, 1996, 1997, 1998, 1999, 2004, 20...
d5e1d89895e51898e9b5fda614e43db14bd5a5a8
jackywzheng/A01086998_1510_assignments
/A3/test_classes.py
2,783
3.515625
4
"""Unit test for classes function.""" # Jacky Zheng # A01086998 # 03/10/2019 from unittest import TestCase import unittest.mock import io import character from unittest.mock import patch class TestClasses(TestCase): @patch('builtins.input', return_value='Saber') def test_classes_saber(self, input): ...
9deea421c1ea3b1e996bfd3f24b08dad64a1a6b7
euzin4/gex003_algprog
/material/respostas_exercicios/lista9/exe7.py
506
3.71875
4
mat = [ [1, 8, 3, 22, 30], [21, 12, 9, 16, 31], [14, 7, 5, 8, 19], [10, 25, 24, 4, 9], [5, 18, 16, 26, 20] ] coluna = 0 while coluna < len(mat[0]): #Testa o número de colunas da primeira linha if mat[0][coluna] % 2 == 0: #Número par for i in range(5): mat[i].pop(coluna) #Exclui a col...
483f0059ed617267e0ca7b28aa15814e07fda842
vatsalgamit/CodingBat_Python_Problems
/Practice_Examples_Python.py
918
4.40625
4
""" The parameter weekday is True if it is a weekday, and the parameter vacation is True if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return True if we sleep in. sleep_in(False, False) → True sleep_in(True, False) → False sleep_in(False, True) → True """ def sleep_in...
f52a03a87ea127083bc739c288b6b997b70a4863
roldanj/python
/def.py
900
4.15625
4
# # # Make a list called known_people with 3 names # known_people = ["John", "Anna", "Mary"] # person = input("Enter the person you know: ") # # if person in known_people: # print("You know {}".format(person)) # else # print("You do not know {}".format(person)) def who_do_you_know(): people = ...
7a2b8ef4a6bef76074c0fc314ebff9ab8f2e83f4
AnumHassan/ASG
/Q_22.py
308
4.1875
4
x1=float(input("Enter Values of Mass: ")) x2=float(input("Enter Values of Height : ")) x3=str(input("Enter unit A(kg,M) or B(lb,Inch): ")) if x3!="A" and x3 != "B" : print("Error") elif x3=="A": print( "the BMI is: " + str(x1/(x2*x2))) elif x3=="B": print( "the BMI is: " + str(x1/((x2*x2)*703)))
426f4df20bb8d6bcf16f5fbd250beff28ecc117d
GK-SVG/Hello_py
/import1st.py
174
4
4
import calculater a=int(input('enetr 1st number: ')) b= int(input('enter 2nd number: ')) print(calculater.pow(a,b)) print(calculater.add(a,b)) print(calculater.multiply(a,b))
d71d675148925e96667bab7ce8890e7b9b0f8f55
Kirsten-Nancy/Data-Structures-and-Algorithms
/Leetcode/LinkedList/203.remove_llist_elements.py
842
4.09375
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def traverse(self): node = self.head while node is not None: print(node.data, end=' ') node = node.next def ...
94c26d34e086d14c655cce67f69a820223b137bc
dimekai/LearningPython
/CursoPython/Fase 4 - Temas avanzados/Tema 13 - Interfaces graficas con tkinter/Clase 07 - RadioButton/radiobutton.py
863
3.546875
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 8 14:55:31 2020 @author: kaimo """ from tkinter import * # Radiobutton: Cuando quieres proporcionarle una opción entre varias # - Tiene un valor por defecto: 1,2,3,....,N def reset(): opt.set(None) monitor.config(text = "") def selection(): monitor.config(text ...
283a661019efcf6672247d3fe330dab066abf1f9
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_95/2092.py
1,007
3.5
4
#!/usr/bin/env python # -*- coding:utf-8 -*- input = [] ans = [] before = ['ejp mysljylc kd kxveddknmc re jsicpdrysi', 'rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd', 'de kr kd eoya kw aej tysr re ujdr lkgc jv'] after = ['our language is impossible to understand', 'there are twenty six fa...
ba5078a54bf577070559b7bfae11a51b1ef513c5
eronekogin/leetcode
/2020/convert_a_number_to_hexadecimal.py
473
3.796875
4
""" https://leetcode.com/problems/convert-a-number-to-hexadecimal/ """ class Solution: def toHex(self, num: int) -> str: if num == 0: return '0' hexChars = '0123456789abcdef' rslt = [] if num < 0: q = num + (1 << 32) else: q = num ...
02bf469a36b8b45b4e3bed3b40c475ce23b45356
ndminh4497/python
/Exercises 34.py
170
3.9375
4
def sum_of_two(a,b): sum = a + b if sum in range(15,20): return '20' else: return sum print(sum_of_two(10, 6)) print(sum_of_two(10, 2)) print(sum_of_two(10, 12))
2d55474895f18952c0b9d4dff41c8bd95abd7043
Jae0143/Introduction-to-Computer-Science-and-Programming-Using-Python-MITX
/genPrimes
439
3.515625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Nov 29 12:31:07 2018 @author: seongjaegyeong """ def genPrimes(): all_prime_collected = list() candidate = 1 while True: candidate += 1 for tester in all_prime_collected: if candidate % tester == 0: ...
d87ff8fefc1ad13ee4680c653d8131a5a6dce54f
wellington36/Learn_Python
/python012.py
112
3.578125
4
a = int(input('Digite o preço de um produto: ')) print('O preço com 5% de desconto é {:.2f}'.format(a*0.95))
c576eea2a74f948e3497ade6925c5c93d5d0e99e
vins-stha/pythontuts
/rockpaperscissors.py
1,371
4.03125
4
import sys def game(play_again): if(play_again==True): user1 =raw_input("What's your name?\t") user2 = raw_input("And your name?\t") choice1 = raw_input("%s, do yo want to choose rock, paper or scissors?\t" % user1) choice2 = raw_input("%s, do you want ...
3efa798b3296e7dee2345d2bd25910749dec7086
ankitjindal7240/LogicMojo
/Backtracking/2.Parenthesis.py
312
3.921875
4
n=int(input()) arr=[0]*2*n def parenthesis(arr,index,n,open,closed): if closed==n: print(arr) if open>closed: arr[index]="}" parenthesis(arr,index+1,n,open,closed+1) if open<n: arr[index]="{" parenthesis(arr,index+1,n,open+1,closed) parenthesis(arr,0,n,0,0)
6bc50e21ba2cea1e258b53ddc8329b9aa814dee2
Saswati08/Data-Structures-and-Algorithms
/Trees/check_cousins_or_not.py
1,086
3.734375
4
def level(x, root, l): if root == None: return if root.data == x: return l if level(x, root.left, l + 1): return level(x, root.left, l + 1) if level(x, root.right, l + 1): return level(x, root.right, l + 1) def isSibling(root, a, b): if root == None: ...
be170bd98b85f41ac3e5b65667b9271a3a9bd108
dsl16/Algorithms
/Fibonnaci.py
455
3.71875
4
# Uses python3 """ Created on Fri Mar 3 17:17:03 2017 @author: Darrin Lim """ import time def clock(function,*args): t1 = time.time() answer = function(*args) t = time.time() - t1 return answer, t def calc_fib(n): if n <= 1: return n a = 0; b = 1; for i in range(n-1): an...
04e2cb6af95b8f123e815f31dc5b2978a725a541
sendurr/spring-grading
/submission - Homework4/set2/MICHAEL SEAN GREENE_16895_assignsubmission_file_Homework 4h/Homework 4h/plot2.py
290
3.71875
4
from matplotlib.pylab import * # Define the function to plot def f(x): return (exp(x**2))*sin(x) # define the range of the plot x = arange(-3.14,3.14,0.01) y = zeros(len(x)) # define the function within the range of the plot for i in xrange(len(x)): y[i] = f(x[i]) plot(x, y) show()
6f8258a8c97977846cb250c0c7cb23e47dd276a6
Icetalon21/Python_Projects
/blackjack_card_counter/cardcountvalue.py
1,323
4.15625
4
''' cardcountvalue.py Name: Emilia Huerta Collaborators: Date: 9/9/2019 Description: This program takes user input of a card value and prints the card counting number for that card. ''' # MIT card counting values: # # 2 - 6 should add one to the count, so their value is 1 # 7 - 9 have no effect on the count, so...
1eca449af85f2b54ddcdcd9e3c1c43133229ab32
the-hobbes/algorithms_datastructures
/sorting/external_sort.py
1,519
4.0625
4
"""External sort. What happens when you need to sort (or process) a very large file, too large to read into memory? You can break it into pieces small enough to fit into memory (chunks), and sort the data in each of these chunks. Sorted chunks are written back into memory. Finally, once all the chunks are sorte...
d689916b2680e5528281df0c67a0e3a54c862beb
KMDEV99/Playground
/Python/mean_square_error/main.py
476
3.890625
4
""" Complete the function that accepts two integer arrays of equal length compares the value each member in one array to the corresponding member in the other squares the absolute value difference between those two values and returns the average of those squared absolute value difference between each member pair. """ ...
914abf5b9fa0bc788d75501c4fe850e6df740bdc
schm2055/CourseraPythonCourses
/Strings1.py
152
3.890625
4
#String practice file = raw_input('Enter your file name\n') fhand = open(file, 'r') for line in fhand: line = line.rstrip() print line.upper()
ddc1c1cc7498536ebb7f7e18f914fa0a72e6d220
Mi7ai/Algoritmia2
/Testing/numeros_ex25PD.py
501
3.5
4
from Utils.bt_scheme import infinity def numeros(N, K): def L(k, n): if k == 0: return 1 p_max = 0 # if (n, c) not in mem: if k > 0 and n > 0: for d in range(1, n): p_max = max((p_max, (k - 1, n, 0)), (L(k - 1, n - d) * d, (k - 1, n - d, d)) ) return p_max mem = {} sol = [] k, ...
5ffbce17a1dccf559701fd0dd0d613e72b11b2ed
guillermedev75/tp1-python
/questão06.py
1,128
4.28125
4
#Aplicação para descobrir o tipo do triângulo #Função para definir o tipo de triângulo def tipoTriangulo(lados): #Variavel x, y, z = lados[0], lados[1], lados[2] #Verificação do tipo do triângulo if x < y + z and y < x + z and z < x + y: if x == y and y == z: retornoTringu...
998e7eca6288aaed408ac60d29df28db079821bf
kha-github/python-coding-team
/2021.09.15/2750/bw_2750.py
154
3.609375
4
import sys k = int(input()) arr1=[] for _ in range(k): arr1.append(int(input())) arr1.sort() for i in arr1: print(i,sep='\n')
404b0cdd119a96bd82afa7dd6ef02a194db3d5a6
ynjacobs/Reinforcing-Collections
/exercise.py
758
3.65625
4
digits = ['1','2','3','4','5','6','7','8','9'] en = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'] fr = ['un','deux','trois','quatre','cinq','six','sept','huit','neuf'] dictOfWords = dict.fromkeys(digits , en) # print(dictOfWords) # d = dict([(k, v) for k,v in zip (digits[::2], en[::2])]) #...
353ca1f2344d78af1c97b58617411c18b80ec21e
a6361117/code
/Day1-15/Day07/03.py
162
3.90625
4
#while 循环使用 else 语句 c = 0 while c < 5: print(c,"小于5") count = c + 1 else: print (c,"大于或等于5") print("********************")
96badc4cebc221ce835a5709f6695b0a247bdda3
spweps/Day-1-Python
/demos/pythonclassdemoday1.py
995
4.09375
4
my_money = 15 print (type(my_money)) #type adds variable type to printout--classification if my_money > 10: print ("I'm happy") else: print ("I'm broke and sad") #pass -- allows code to continue on likes_bbq = True likes_fruit = False weight = 190.5 iq = 142 name = "Scott" age = "40" print(len(age)) ...