blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
5eba380e4a6bae72ac7ad35d3670ca36a4fa517d
fabriciocovalesci/ListOfBrazilPythonExercises
/SequentialStructure/number_2.py
348
4.34375
4
""" [PT] 2. Faça um Programa que peça um número e então mostre a mensagem "O número informado foi [número]". [EN] 2. Make a Program that asks for a number and then displays the message "The number entered was [number]". """ def enternumber() -> str: number = input('\nEnter a number: ') return f'\nThe number ...
f43c0ca9c0eea197c4afe74656923bf5af674c2c
Faith-muroa/pre-bootcamp-coding-challenges
/task9.py
205
3.953125
4
multiples = [] b = 1 while b < 1000: if b % 3 == 0 or b % 5 == 0: multiples.append(b) print(b) b = b + 1 print(multiples) sum = 0 for i in multiples: sum = sum + i print(sum)
a18ede81f8de3ec56fc6c75ad6a2758f719e4dc6
Maheshwari2604/Competitive-Programming-linkedlist-and-Stack-
/linkdedlist/detect_loop.py
892
3.984375
4
class node: def __init__(self, data): self.data = data self.next = None class linkedlist: def __init__(self): self.head = None def push(self, new_node): new_node = node(new_node) new_node.next = self.head self.head = new_node def detect_loop(self): ...
b68d3a8c88a28fa0b2e14545f43fb2a1a7831886
kangmin1012/Algorithm
/2020.01.13(MON)/2037_SMS.py
2,949
3.5625
4
button, rest = map(int,input().split()) # button = 입력 시간 , rest = 같은 숫자 연속입력 시 기다리는 시간 result = 0 check = 0 text = list(input()) al_dic = { 2 : ['A', 'B', 'C'], 3 : ['D', 'E', 'F'], 4 : ['G', 'H', 'I'], 5 : ['J', 'K', 'L'], 6 : ['M', 'N', 'O'], 7 : ['P', 'Q', ...
bdc085c28c2ad50438bf7ac2a70ee0d8da4e4076
rohaneden10/luminar_programs
/flow controls/decision/secondlargestnumber.py
117
3.828125
4
a=int(input("enter 1st no")) b=int(input("enter 2nd no")) c=int(input("enter 3rd number")) if(a>b)&(a<c) print(a)
d65e8a7297b6e931d5fa9c219feb333cb046d9c8
Niteesh3110/Algorithms
/selectionsort.py
434
4.03125
4
import random # the function def selection_sort(arr): unsorted_arr = arr sorted_arr = [] minimum_value = 0 for i in range(len(arr)): minimum_value = min(arr) sorted_arr.append(minimum_value) arr.remove(minimum_value) print(sorted_arr) return sorted_arr # array arr = [-1,8,3,4,-5,9] # Creating random number ...
4bec55dcc2364dda99201e15efff14455077bdb8
epasseto/pyprog
/UdacityProgrammingLanguage/Course/src/Final_LogicPuzzle.py
2,333
3.734375
4
#! /usr/bin/python # To change this template, choose Tools | Templates # and open the template in the editor. __author__="epasseto" __date__ ="$28/05/2012 15:03:33$" """ UNIT 2: Logic Puzzle You will write code to solve the following logic puzzle: 1. The person who arrived on Wednesday bought the laptop. 2. The prog...
5af62c56e4e41583bd35b85ff28f05d050caefc7
gmoore803/Schedule-Planner-cs
/semester project.py
2,930
3.765625
4
print("-"*110) print(' Jacksonville State University ') print(' Fall Semester 2019 ') print(' Grayson Moore ') print(' ...
5828947810a17b820f6182c139cc1e9715a5e19a
sujilnt/UdacityCoursework
/Task0.py
1,072
3.609375
4
#!/usr/bin/env python # coding: utf-8 # <h4>Task 0 </h4> # <br/> # <p><b>Print this message</b></p> # <ol> # <li>First record of texts, <b>incoming number</b> texts <b>answering number </b> at time <b>time</b></li> # <li>Last record of calls, <b>incoming number</b> calls <b>answering number</b> at time <...
e614f9666dff56f2ad37f1bdda37e4d5cebce424
vicuartas230/holbertonschool-higher_level_programming
/0x0B-python-input_output/0-read_file.py
309
4.09375
4
#!/usr/bin/python3 """ This program defines a function read_file """ def read_file(filename=""): """ This function reads a text file (UTF8) and prints it to stdout """ with open(filename, 'r', encoding='utf-8') as new: reading = new.read() print(reading, end='') new.close()
078431e1485665658fa4e04d530853ddb8670028
chandrakala199/codeketa
/queue.py
826
4.25
4
print("queue implementation") queue=[] while True: print("what operation would you like to perform?\n 1.enqueue 2.dequeue 3.size 4.empty 5.exit") c=int(input()) if c==1: print("Enter the element to be inserted:") l=input() queue.append(l) print(" the element in the queue are...
90db0739d7c33ffc775a4238975a127f1c702e64
yazdejesus/FirstLessons-Python
/CursoEmVideo/070 - EstatisticaCompra.py
899
3.78125
4
#ler nome e preço de vários produtos. Perguntar se vai continuar #total gasto na compra, nr de produtos acimia de 1000 e nome do mais barato total = bem_caros = 0 compra = mais_barato = 0 while True: nome = input("Introduza o nome do produto: ") preco = float(input("Introduza o preco do produto: MZN_")) continuar ...
a8579e6d0c571b966f9e86e688d1684634b23178
mateusfagundes/Exercicios-Python
/Estudos intermediários/Controle/while1.py
636
3.96875
4
x = 10 while x: # Conta do 10 ao 1 depois para o laço print(x) x -= 1 print('Fim') x = 0 while x != -1: # Enquato não for digitado -1 o laço não para de rodar x = float(input('Informe o numero ou -1 para sair: ')) print('Fim') total = 0 qtde = 0 nota = 0 while nota != -1: # Soma as...
f315d5d12d89b03256a89395540ab34a3155ff3f
Crimson-Jacket/Ciphers
/letnumCipher.py
972
4.09375
4
def ltnc(text): """ Description: A cipher that converts letters to its corresponding number (position in alphabet). Doctests: >>> ltnc("this is a test") '20 8 9 19 9 19 1 20 5 19 20' """ return " ".join(format(ord(x) - 96, "d") if 97 <= ord(x) <= 122 else x for x in text.lower()) ...
d5397d1cda626f8f6bb194023f3ccd61504180e5
Connor-Cahill/madlibs
/madlibs.py
3,050
4.46875
4
# Need to find set of 2-3 stories #store stories in a list #create function that gets inputs from user (NEED: Verb, Noun, Adjective, etc.) #choose random index from list to pick story ##Format the list to inject the user_inputted values into the necessary spots # make sure user input can only be letters import random #...
de2d68ad14d865306facd5e45c0bf4108a2e2ec0
dale-nelson/IFT-101-Lab4
/Lab04/Lab04P3.py
811
4.09375
4
def main(): print("This program will calculate the addition of natural numbers in sequence.") userInput = validLoop() posCheck = isPos(userInput) print("The sum of all the natural numbers up to {0} is {1}".format(posCheck,naturalNumAdd(posCheck))) return def naturalNumAdd(i): if i <= 1: retur...
052b40c6de09c05f01efeb115b4a1ae964836564
bmk316/daniel_liang_python_solutions
/8.6.py
321
3.953125
4
def count(str1): c = 0 for i in range(len(str1)): if str1[i].isalpha() > 0: c += 1 return c def main(): string = input("Enter your string to be counted:").lower() result = count(string) print("The numbers of letters in the string is:", count(string)) main(...
ebb51b090fa28230fb6975c393d125ff8323b979
Toby-Tan/tanjiahao
/python_ck/class/class_10day/class_10_global.py
476
3.6875
4
# 多线程全局变量 # 如果多个线程同时对一个全局变量操作,会出现资源竞争问题,从而会导致数据结果错误 import threading import time a = 100 def fun1(): global a for i in range(1000000): a += 1 print(a) def fun2(): global a for i in range(1000000): a += 1 print(a) t1 = threading.Thread(target=fun1) t2 = threading.Thread(ta...
a4ac18fc264f6ef01ef8686200b23bb567cc5475
yodeng/sw-algorithms
/python/binary_tree/symmetric_tree.py
1,789
3.75
4
#!/usr/bin/env python # encoding: utf-8 """ @author: swensun @github:https://github.com/yunshuipiao @software: python @file: symmetric_tree.py @desc: 判断对称树 @hint: 比较对称位置,递归和非递归。也可以根据前面二叉树反转,来判断两棵树是不是一样。 """ from binary_tree import BinaryTree # 递归 def symmetric_tree(root): if root is None: return Tr...
bb2eee274ad8629f1c7f9a31c248b46a90f1e0ba
AmritaDeb/Automation_Repo
/PythonBasics/Prog_18_12_27/ReversedItemInListComprehension.py
236
3.796875
4
l1=['hi','hello','bye'] l2=[] for i in range(len(l1)): l2.append(l1[i][::-1]) print(l2) revList=[l1[i][::-1] for i in range(len(l1))] print(revList) s="amrita" s1=list(s) print(s1) # revStr=[s1[i][::-1] for i in s] # print(revStr)
88d21333e4a5eeeef9ef0def2f4c8f0c29081084
devendra3583/Python
/D_Day10/10/2_class.py
127
3.625
4
class A: c=10 def __init__(self,x,y): self.x = x self.y=y def dis(self,x,y): print x+y+self.c a = A(5,8) a.dis(1,2)
6b3352029c5d37b52f15400738807ad7a35b6c64
riprap/dailies
/python/day003easy.py
1,348
4.21875
4
"""Welcome to cipher day! write a program that can encrypt texts with an alphabetical caesar cipher. This cipher can ignore numbers, symbols, and whitespace. for extra credit, add a "decrypt" function to your program!""" def crypt(user_string, caesar_shift): letters = ['a','b','c','d','e','f','g','h','i','j','k','l',...
553fd317e297a110c115f1e2a32169da73cd7ba9
AHKerrigan/Think-Python
/example6_3.py
386
4.0625
4
""" This is a solution to an example from Think Python, 2nd Edition by Allen Downey http://thinkpython2.com Copyright 2015 Allen Downey License: http://creativecommons.org/licenses/by/4.0/ Chapter 6 Example 3: As an exercise, write a function is_between(x, y, z) that returns True if x ≤ y ≤ z or False otherwise. "...
68f1c5a3a491eb32d7244561d5e4990282550313
fhylinjr/Scratch_Python
/final project.py
2,209
3.765625
4
import random def Pshootout(): print('Hello there!, Welcome to the Penalty Shootout Game!') diffmode=int(input('Select difficulty mode, Enter 1 for easy mode and 2 for hard mode: ')) print('There are several directions to place your kick.') print('They are represented as TL-TopLeft, ML-MiddleLeft, ...
dd8cccd0bbb8219504411f0ad8f4821da3d86faa
uli-rizki/mona
/mona.py
193
3.515625
4
#!/usr/bin/python flag = True while flag == True : sentence = raw_input("User : ") if sentence == "quit" : exit() else : response = sentence.lower() print "Mona :", response
da7b5ced97d00c30b2cf6df1b83faa9dbcc1a64d
danielhamc/PythonInformationInfrastructure
/number_sum.py
245
4.125
4
# Daniel Ham # Number Sum num_list = [] while True: num = input("Please enter a number or STOP: ") if num.upper() == 'STOP': break num_list.append(int(num)) print("The total sum is", sum(num_list))
e0d49e0f4a3aee383900ad1e79aacbf9a4993032
ash/amazing_python3
/147-ternary2.py
231
4.3125
4
# Let's see another paradigm # you can use with conditional # statements for i in range(1, 5): # is i odd or even? # oe = 'odd' if i % 2 else 'even' print('odd') if i % 2 else print('even') # print(f'{i} is {oe}')
3783d216789d7a76c90e140e4f261a93bd90bfff
vmirisas/Python_Lessons
/lesson7/part6/set.comprehensions.py
648
3.859375
4
my_set = {number for number in range(3)} my_set1 = {number for number in range(10) if number % 2 == 0} my_set2 = {number if number % 2 == 0 else number / 2 for number in range(10)} """ my_set3 = set() for i in range(2): for j in range(3): my_set3.add(i,j) """ my_set3 = {(i, j) for i in range(2) ...
95d801a6b9ed2faba40644ae2ade8998f61457c9
nptit/checkio
/numbers_factory.py
819
3.84375
4
#!/usr/bin/env python # -*- coding:utf8 -*- def checkio(data): result = [] while data > 9: is_found = False for i in range(9, 1, -1): if data % i == 0: is_found = True result.append(i) data = data // i break if...
3b36890ae8beddfda384d4d4348f091555e11d5a
tisTrashBoat/FrankPalafox
/Assign 3.py
539
4.125
4
grades=int(input("How many grades would you like to input?")) grade_list= [] grade_average = 0 for i in range(grades): print ("What was your grade?") entered_vari=int(input()) grade_list.append(entered_vari) grade_average = grade_average + entered_vari print grade_list a= grade_average a = a/grades prin...
b030babafd64f76f06cd4944bf5ac4ea12dcd2c2
NishaUSK/pythontraining
/ex8.py
356
4.15625
4
#using methods(join,split,replace) pen = "Students have different types of pens to write" print(" ".join(pen)) print("-------------------------------------") print(" ".join(reversed(pen))) print("-------------------------------------") print(pen.split("e")) print("-------------------------------------") prin...
dcff8ce33c9db3902be0bcdcb6cdb207d1af9562
sds1994/Text-Documents-Repo
/Python/Divisors.py
125
3.828125
4
n = int(input('Enter any number : ')) list=[] for i in range(1,n+1): if(n%i == 0): list.append(i) print(list)
17a7b7787aa47f1fe4d8c269a41cf3c61cb12765
tahsinalamin/leetcode_problems
/leetcode-my-solutions/404_sum_of_left_leaves.py
688
3.640625
4
""" Author: Sikder Tahsin Al Amin Problem: Find the sum of all left leaves in a given binary tree. """ class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def sumOfLeftLeaves(self, root: TreeNode) -> int: ...
5023416228842b7fd6c7ec685b77c9b27082f67b
esl4m/python-design-patterns2
/02_Command_Pattern/switch.py
2,115
3.546875
4
class Switch: """ The INVOKER class""" def __init__(self, flipUpCmd, flipDownCmd): self.__flipUpCommand = flipUpCmd self.__flipDownCommand = flipDownCmd def flip_up(self): self.__flipUpCommand.execute() def flip_down(self): self.__flipDownCommand.execute() class Light...
22efdf4543362f81adb8010a40466ed3810629cd
algebra-det/Python
/DataStructures/Selection_Sort.py
831
4.21875
4
# In Bubble_Sort we consume to much cpu power and memeory and time because # we have to iterate through every element upto last value and then iterate again # upto last second value and so on # In SELECTION SORTING, we take the max or min value from the list and then swap it with the first # then second than so one wh...
86b5b7e68a3fc41223699d8350e7282d711a3c3f
krother/advanced_python
/error_handling/get_traceback.py
644
3.53125
4
""" Example: Print the state of all variables when an Exception occurs. """ import sys, traceback def print_exc(): tb = sys.exc_info()[2] while tb.tb_next: # jump through execution frames tb = tb.tb_next frame = tb.tb_frame code = frame.f_code print("Frame %s in %s ...
a5d557caf0ebc2d6fbcf935b768d883704e8be8f
mumarkhan999/python_practice_files
/Lists/13_using_lists_as_queue.py
238
4.0625
4
# using lists as queue l1 = [] for i in range(1,11): l1.insert(0, i) print("Adding ",i) print("After inserting values l1 is ", l1) while len(l1) > 0: print("Removing ", l1.pop()) print("After removing values l1 is ", l1)
a154ba1563502288d74e8633dd35f0675784208b
pruvi007/PBFT_Consensus
/shortestPath.py
1,974
3.5625
4
from heapq import heappop, heappush, heapify class shortestPath(): def __init__(self,graph,source,destination): self.source = source self.destination = destination self.G = graph self.X,self.Y,self.W = [],[],[] self.edge = [] def getPath(self): # heap c...
f37f83d7ab9c9e0e8dd5c777833e51d2ee4d8712
Bobby981229/Computer-Vision-Based-Vehicle-Integrated-Information-Collection-System
/labelme/rename.py
275
3.515625
4
# 为数据集重命名 -- 用数字命名 import os path = '../labelme/pictures' files = os.listdir(path) for i, file in enumerate(files): NewFileName = os.path.join(path, str(i)+'.jpg') OldFileName = os.path.join(path, file) os.rename(OldFileName, NewFileName)
c0911e4dd418627f8f9e8fed72da90d0a49df584
claudiordgz/coding-challenges
/algorithms/hardcore.py
1,776
3.890625
4
class node: def __init__(self, data): self.left = None self.right = None self.data = data def insert(self, data): """ Insert new node from data """ if self.data: if data < self.data: if self.left is None: ...
abdcdf9e11c63b6903b9d418af90973150cce069
meretciel/backtesting_platform
/initialize_platform.py
2,200
3.578125
4
""" Script: initialize_platform.py This script will initialize the platform when it is download from the Github. User can modify the parameters defined in this script. Please find more details in the comments. To initialize the platform, please run this script in python. """ import os from os import path import pa...
9697f7a36b82150f7272024294fe92bde7712ab1
krissmile31/documents
/Term 1/SE/PycharmProjects/pythonProject/huh/Adaptive Huffman.py
5,255
3.828125
4
import heapq import os import sys import time class Tree: # Initialize an empty tree: 1 root, 1 empty node def __init__(self, character, frequency): self.char = character self.freq = frequency self.left = None self.right = None def less_than(self, other): return ot...
95fb114c5f4d0d760b4dd1577a32921b9051695a
erjan/coding_exercises
/partition_array_such_that_maximum_difference_is_k.py
1,718
3.640625
4
''' You are given an integer array nums and an integer k. You may partition nums into one or more subsequences such that each element in nums appears in exactly one of the subsequences. Return the minimum number of subsequences needed such that the difference between the maximum and minimum values in each subsequence ...
bf89461701da5f64af91050f7e3de8d8762f5041
forwardslash333/PythonPractice
/11. Calender.py
270
3.90625
4
import calendar #This module contains functions for calender year = int(input('Enter the year')) #Input values month = int(input('Enter the month')) print(calendar.month(year,month)) print(calendar.__doc__) #Print
18abc44012ee42dfae1e2121882b99de05c8b06d
ferasezzaldeen/data-structures-and-algorithms
/python/code_challenges/tree_intersection/intersection.py
781
4.0625
4
from trees import * def tree_intersection(first: Binary_Tree,second: Binary_Tree): if(first.root and second.root): list1=first.pre_order() list2=second.pre_order() sol=[] for x in list1: for i in list2: if x==i: sol.append(x) ...
5f5b6bdd251bf68fcc573997e47313685c7b153b
MechZombie/Python-Basico
/Tuplas.py
327
3.734375
4
# -*- coding: utf-8 -*- #Tuplas são similáres a um vetor, exceto pelo fato de serem imutpaveis words = ("spam","eggs","sausages") # words[0] = "cheese" vai dar erro. #Outra forma de criar tuplas. tuplas = "primeiro","segundo" print(tuplas[0]) #É possível atribuir valores dessa forma. tupla = (1,(1,2,3)) print(tupla[...
4b47ad848c10580d68c84de9ecc468b532706797
BlackTimber-Labs/DemoPullRequest
/Python/palin.py
133
3.96875
4
def palindrome(s): s=s.replace(" ",'') reverse=s[::-1] if s==reverse: return True else: return False
1d566d0135acbb09e669fb144abf3614542cffd0
yansenkeler/pyApp
/DoubleBasePalindromes.py
844
3.75
4
# The decimal number, 585 = 10010010012 (binary), is palindromic in both bases. # Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2. # (Please note that the palindromic number, in either base, may not include leading zeros.) import math, time def is_palindromes(num): ...
9cb7eec5ed3870d3c307d1b025f246f61f14aed5
Huijuan2015/leetcode_Python_2019
/314. Binary Tree Vertical Order Traversal.py
3,051
3.796875
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def verticalOrder(self, root): """ :type root: TreeNode :rtype: List[List[int]] """ ...
81d1f14eb8ba54ee5875c0227daee187d4d4ec2f
ReaseySereiNeath/Share-Python
/reasey.sereineath19/week01/c11_hello_loop.py
85
3.9375
4
num = int(input("Enter a number: ")) for i in range (num): print("Hello World!")
9df5be8e57c5219b6ca4da5ebca7b14d74600293
sufailps/erp_project
/empfunc.py
4,285
4.0625
4
print("employee management") emp=[] empdict={} groups={} def manage_all_group_menu(): print("\t 1 for create group") print("\t 2 for display group") print("\t 3 for manage group") print("\t 4 for delete group") print("\t 5 for Exit") def create_group(): gname=input("Enter group name") groups[gname] = [] def d...
e7028a1e4ce2ca77b268585a0b8d9dc351f6885e
chryswoods/siremol.org
/chryswoods.com/intro_to_mc/software/2/metropolis.py
7,802
3.671875
4
import random import math import copy # Set the number of atoms in the box n_atoms = 25 # Set the number of Monte Carlo moves to perform num_moves = 5000 # Set the size of the box (in Angstroms) box_size = [ 15.0, 15.0, 15.0 ] # The maximum amount that the atom can be translated by max_translate = 0.5 # angstro...
833727497f0946ba150a72bc2bdc4122f19368fb
rubinpar/Code-Connects
/hw/hw7.py
3,311
4.15625
4
# 1. write a function # 2520 is the smallest number that can be divided # by each of the numbers from 1 to 10 without any remainder. # What is the smallest positive number that is evenly # divisible by all of the numbers from 1 to 20? def divisible_by_n(i, n): """ i is divisible by n without a remainder ""...
6f5ad9be7d104570d2b7e60e25fd0affb08e5269
arnab-sen/practice_projects
/python/chess/chess_v1.0.py
20,652
4
4
""" A text-based chess game """ import copy import random import time def initialise_board(): # Initialise the 8x8 board matrix # Extra top layer to make it same in dimension to the display board # doing board = [["_"] * 8] * 9 creates 9 sets of the same list, # so altering any element changes that el...
a1c63aff1b5221900c2e4d498e622e3f446d411b
myles/five-little-monkeys
/five-little-monkeys.py
696
4.28125
4
NUMBERS = { 5: 'Five', 4: 'Four', 3: 'Three', 2: 'Two', 1: 'One', } def main(): for key, value in reversed(NUMBERS.items()): if key == 1: print("%s little monkey jumping on the bed" % value) print("They fell off and bumped their head") else: ...
2a98ffb520d3ba6e11428f187ecebcd36f43c884
AjayKumar2916/magicwords
/magic_word_1.py
1,264
3.890625
4
#!/usr/bin/env python import sys, getopt # Defining Python Command Line Arguments def main(argv): jumbled_word = '' proper_word = '' # Getting command line argument try: opts, args = getopt.getopt(argv,"hj:p:",["jword=","pword="]) except getopt.GetoptError: print 'usage : python %s -j <jumbled word> -p <prop...
81fc1142c4238003083f5d7bc117017890948ec0
binaythapamagar/insights-workshop-assignment
/py-assignment-I/functions/8uniquelist.py
229
3.640625
4
def manupulate(words): for i in range(len(words)): if i < (len(words)-1) and words[i] == words[i+1] : del words[i] return words print(manupulate([1,2,3,3,3,3,4,5]))
664221d33396310aa9df1cd067e69bbf65c9c9fc
xiaohao890809/Thread_Python
/Queue.py
787
3.546875
4
# author: xiaohao # time: 2018.01.30 23:28 from multiprocessing import Process,Queue import time,random # 写入进程 def write(q): for value in ['A','B','C']: print('put %s to queue...' % value) q.put(value) time.sleep(random.random()) # 读取进程 def read(q): while True: value = q.get(T...
1307f43512c72b49a350b9077f36fe0c6c52e562
JenZhen/LC
/lc_ladder/company/gg/Open_The_Lock.py
2,861
4.125
4
#! /usr/local/bin/python3 # https://leetcode.com/problems/open-the-lock/submissions/ # Example # You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'. # The wheels can rotate freely and wrap around: for example we can turn '9' to be '0', or '...
a94352b76efb0c58cdac5c58685aa8a65e341bc3
RichieSong/algorithm
/算法/二叉树/二叉树最大深度.py
1,026
3.765625
4
# coding:utf-8 ''' 给定一个二叉树,找出其最大深度。 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。 说明: 叶子节点是指没有子节点的节点。 示例: 给定二叉树 [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 返回它的最大深度 3 。 解题思路: 1、递归 2、 ''' class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None...
af2b932d97d7bd688cf253f1c4c7072768c53efb
dip4k/Competitive-Programming
/HackerRank/Data Structures/PrintLinkedListInReverse.py
1,257
4.15625
4
''' Problem Statement You are given the pointer to the head node of a linked list and you need to print all its elements in reverse order from tail to head, one element per line. The head pointer may be null meaning that the list is empty - in that case, do not print anything! Input Format You have to complete the v...
6bc65c29164b2ff2e7bba134477ece79396f54f8
LYU-Zhe/Codewars
/Did_I_Finish_my_Sudoku.py
2,066
4.28125
4
""" Write a function done_or_not/DoneOrNot passing a board (list[list_lines]) as parameter. If the board is valid return 'Finished!', otherwise return 'Try again!' Sudoku rules: Complete the Sudoku puzzle so that each and every row, column, and region contains the numbers one through nine only once. Rows: There a...
3334a058053fb40f80c608d1e5de684d2fb5a3e0
mukultaneja/TaskDistributionSystem
/com/itt/tds/thread/threads.py
1,125
4.3125
4
"""Threading Example in Python""" # importing modules from threading import Thread from _thread import allocate_lock class ThreadExample(Thread): """ThreadExample class inherits Thread module to make custom threads""" counter = 0 lock = allocate_lock() def __init__(self): """ThreadExam...
1e9d409805f8751f4e66cbaf09ece83e20dbee72
lauragmz/proyecto-intro-ciencia-de-datos
/transform_data.py
2,488
3.828125
4
# Definición de la función tranformar_minusculas que recibe como argumento un dataframe, convierte a minúsculas la información contenida en cada una de las columnas y devuelve el dataframe con esta modificación. def transformar_minusculas(df,columnas): return df.apply(lambda x: x.astype(str).str.lower() if x.name ...
11ab3d8ba7f6f6c74d020c744b520ec9329bd89d
bopopescu/education
/chapter 2_lists/list2.py
150
4
4
#заставляем списки работать bobb = ['s','f','a'] www = "sofa" for letter in www: if letter in bobb: print(letter)
c0a4b16a1d9a2d072892909a4a50def04dc9cb68
masterzht/note
/other/python/code/2_list.py
709
4.3125
4
# this is the code of list word=['a','b','c','d','e','f','g'] a=word[2] print " a is : " +a b=word[1:3] print b # index 1 and 2 elements of word. c=word[:2] print c # index 0 and 1 elements of word. d=word[0:] print "d is " print d # All elements of word. e=word[:2]+word[2:] print "e is :" print e # All elements of w...
3b52bf6f3d759b675a594b161f060d42fd0589bd
pisskidney/graphs
/graph.py
2,868
3.53125
4
#!/usr/bin/python class Vertex(): def __init__(self, identifier): self.identifier = identifier self.out = list() self.inn = list() @property def in_deg(self): return len(self.inn) @property def out_deg(self): return len(self.out) def __str__(self): ...
f802eee1d89a2c901503a5f1056257ec8a044be6
LeeTann/python-algorithms-practice
/write_numbers_in_expanded_form.py
610
4.46875
4
# Write Number in Expanded Form # You will be given a number and you will need to return it as a string in Expanded Form. For example: # expanded_form(12) # Should return '10 + 2' # expanded_form(42) # Should return '40 + 2' # expanded_form(70304) # Should return '70000 + 300 + 4' # NOTE: All numbers will be whole num...
8f0951b84980dfa4c09a20e4eb968981dded6185
plediii/stuff
/js-for-python-programmers/classes.py
665
3.71875
4
class Foo(object): def __init__(self, bar): print 'Creating a new Foo' self.bar = bar def zoop(self): print 'Foo.zoop invoked: bar = ' + self.bar def zap(self): print 'Foo.zap invoked: bar = ' + self.bar class Quux(Foo): def __init__(self, bar): print 'Cr...
c3f775501d56ef9945ea6171e8bdbc82f6117bbe
IngridDilaise/programacao-orientada-a-objetos
/listas/lista-de-exercicio-07/questao08.py
1,110
3.625
4
class Tamagotchi: def __init__(self,nome): self.nome=nome self.fome=10 self.saude=10 self.idade=0 def alterar_nome(self,novo_nome): self.nome=novo_nome def retornar_fome(self): return self.fome def retornar_saude(self): return self.saude def retornar_idade(self): return self....
8fe1b50f9fe5406858d8c25a6f4100db04d88c05
WGJBV/data-structures-and-algorithms
/largest-product-array.py
203
3.609375
4
def largest_product_array(): product = 0 array = [[1,2][3,4][5,6][7,8]] for i in len(array): if array[i][0] * array[i][0] > product: product = array[i][0] * array[i][0] return product
9e157e9a168555d23b84d6cf0ee14df2d54c907d
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/223/users/4175/codes/1716_2506.py
208
3.671875
4
x = float(input("x: ")) y = float(input("y: ")) w = float(input("w: ")) t = 0 y = y/100 while 0<x<12000: a = x*y x = a + x x = x - w t += 1 if x <= 0: print("EXTINCAO") else: print("LIMITE") print(t)
f6b458de517ee80a20f3e3f4d36b6ea1bcb47a83
larsx2/devz-ctci-challenge
/python/chapter_01/03_permutation.py
547
3.734375
4
import unittest import random def randomize(s, as_list=False): l = list(s) random.shuffle(l) return l if as_list else ''.join(l) class TestPermutation(unittest.TestCase): def test_solution(self): s = "abcdeff" for _ in xrange(100): self.assertTrue(is_permutation(s, rand...
512414eceefa7c4ef977442cd619fd857265cea9
Lyc1103/Aritificial-Intelligence_Path-Finding-of-Maze
/mazeMaker.py
1,165
3.625
4
import numpy as np import sys # Global Variable # np.random.seed(1) # needs to small than 1000 x 1000 hight = 10 width = 10 maze = [[0] * width for i in range(hight)] def PrintMaze(m): for i in range(hight): for j in range(width): print(m[i][j] + " ", end='') print() # end func Peint...
014928cfac8d3c498b72c5c24f4b1af587217b2e
ToshineeBhasin/Python-Programs
/numbrGuessing.py
1,218
4.03125
4
import random import math#taking inputs lower = int(input("Enter lower limit : ")) upper = int(input("Enter upper limit : ")) x = random.randint(lower,upper) print("\n \tYou have only ",round(math.log(upper - lower +1, 2 )), "Chances to guess the integer !\n") #initializing no of guess count = 0 #minimum ...
61dfc770812a67011c0759d602d4edcca5f104e7
mohanrajanr/CodePrep
/lhs.py
629
3.53125
4
from typing import List def findLHS(nums: List[int]) -> int: currValue = 0 longestValue = 0 minv = maxv = nums[0] for i in range(1, len(nums)): minv = maxv = nums[i] currValue = 0 for j in range(i-1, -1, -1): minv = min(minv, nums[j]) maxv = max(maxv,...
d13c919d2a04998ec1b85fb62731ca2ea171e7d5
sanislav/homework
/coursera/algorithms_2/01/p_01_02/greedy.py
2,549
4
4
"""In this programming problem and the next you'll code up the greedy algorithms from lecture for minimizing the weighted sum of completion times.. Download the text file here. This file describes a set of jobs with positive and integral weights and lengths. It has the format [number_of_jobs] [job_1_weight] [job_1_leng...
76db04758225da604537a3159bd02159bd774f6f
yuueuni/algorithm
/WarmUp/PlusMinus.py
569
3.828125
4
#!/bin/python3 import math import os import random import re import sys # Complete the plusMinus function below. def plusMinus(arr, n): plus, minus, zero = 0, 0, 0 for i in range(n): if arr[i] > 0: plus += 1 elif arr[i] < 0: minus += 1 else: zero +=...
778d77ac7fbd580f9eb9cc0264b5f17ebb10e87a
wolima/python
/exercicios/ex.py
1,469
3.796875
4
#Exercicio 1# x = input() for i in x: print(str(i).lower()) #Exercicio 2# lista = [] for i in range(3): lista.append(input()) print(max(lista)) print(min(lista)) theSum = 0 for i in lista: theSum = theSum + int(i) print(theSum) #Exercicio 3# for i in range(10,100): if i%5 == 0: print(i) #Exercicio 4# def ...
63f87417ca5a09c5a40839ee1697e34fe98b1a53
fanyuan1/Project-E
/problem_12.py
565
3.53125
4
from math import sqrt from functools import reduce def factorize(n): for i in range(2,int(sqrt(n)+1)): if (n%i == 0): if i in factors: factors[i] += 1 else: factors[i] = 1 return factorize(n//i) if n in factors: fac...
d7e7e790517d35167b597d78a9b460e2e4f19303
scuate/MOOC
/data_wrangle/src/parse_csv.py
864
3.734375
4
##parse csv file, store all the data in a list import csv import os DATADIR = "" DATAFILE = "745090.csv" # csv.reader creates an iterable object, "for" loop calls next() function every time and a list is created for each row def parse_file(datafile): name = "" data = [] counter = 1 with open(datafile,...
9aea83b6c76f185fc9ef6f571b3b29e86d54f055
JavaGoodDay/Projects
/First.py
284
3.96875
4
Maths =80 Chemistry=100 Physics=100 Total=Maths+Chemistry+Physics Per=Total*100/450 print() print() print("the chemistry result is",Chemistry) print("the maths result is",Maths) print("the physics result is",Physics) print() print("Percentage",Per) print("the total result is",Total)
bf2a31dca1de2438463c19bb03cabf6ef4c2fe8d
tinmaker/ekf
/thread.py
887
3.53125
4
#!/usr/bin/python # -*- coding: UTF-8 -*- import threading import time a=100 lock = threading.Lock() def print_time1( threadName, delay): global a while 1: time.sleep(1) lock.acquire() a +=1 lock.release() print "%s: %s" % (threadName, time.ctime(time.time()) ) def print_time2( threadName, delay): gl...
a8c8f5d3c3f6334cd3dba7a9a08a8284d1b9dcef
hoodielive/pythonnerd
/algorithms/array-lessons/list-array.py
639
4.3125
4
# one-dimensional one_dimensional_array = [1,2,3,4,5] print(one_dimensional_array[0]) # O(1) -> if you specify index # two-dimensional two_dimensional_array = [1, 2, 300, 3, 4, 5] # for loop O(n) for num in two_dimensional_array: print(num); # insert O(n) two_dimensional_array[1] = "Insert" # for loop O(n) f...
53fecb2c72c3714efc1f886d8be1419590390dcf
DaHuO/Supergraph
/codes/CodeJamCrawler/16_0_3_neat/16_0_3_xke_C.py
3,642
3.65625
4
import math inputfile = open('C-large.in') outputfile = open('C-large.out.txt', 'w') # returns 0 if a prime number # returns a divisor otherwise # adaptation of # https://www.daniweb.com/programming/software-development/code/216880/check-if-a-number-is-a-prime-number-python def is_non_prime_get_divisor(n): '''c...
9b6540d151fb36a2bfb4deddc9e66ea6e01e2f5f
kishan3/leetcode_solutions
/72.py
925
3.734375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jan 2 16:29:34 2019 @author: kishan """ def edit_distance_between_two_strings(str1, str2): len1 = len(str1) len2 = len(str2) if len1 == 0 or len2 == 0: return len1 + len2 dist = [[0 for _ in range(len2 + 1)] for _ in range(l...
ea270252970ef3d515771c66af14aeaba32f225e
pomegranate66/coderLife
/September/左旋转字符串.py
1,043
3.71875
4
class Solution: def reverseLeftWords(self, s: str, n: int) -> str: ''' s : 输入的字符串 n : 从第几位开始旋转 例子: 输入: s = "abcdefg", k = 2 输出: "cdefgab" 输入: s = "lrloseumgh", k = 6 输出: "umghlrlose" 分析: 1...
fbe548294c7c9806ca42f34cbdd19f7d28ffb5c0
michalfoc/python
/python/ex20.py
1,328
4.40625
4
# Ex20. Functions and files # a program using functions to work on files from sys import argv script, input_file = argv # define few functions # def, function name, (function arguments), COLON!!! def print_all(f): print(f.read()) def rewind(f): f.seek(0) def print_a_line(line_count, f): print(line_cou...
f3f5b1c5fd3e21258f3eec7f58fa771e17cc7ce3
RasmusBuntzen/Python-for-data-science
/Projekter/Øvelser/String Øvelse 1+2.py
443
3.609375
4
#Øvelse 1 First_name = "Rasmus" Last_name = "Buntzen" Age = 22 print("Name: " + First_name + " " + Last_name + "\nAge: "+ str(Age)) #Øvelse 2 DNA = "AAGCAGAATGCTTAGGACTAGTTAC" RNA = DNA.replace("T","U") print("DNA sekvensen :"+DNA) print("RNA sekvensen :"+RNA) print("Længden af RNA sekvensen er: "+ str(len(RNA)) + "\n...
6ea70a3ff2989b81cbbc078fb04876b4133cf07c
acrip/PythonMisionTIC
/Clase9_19MAY21/listasCompuestas.py
1,672
3.984375
4
#listaCompuesta = [[1,2,3],[4,5,6],[7,8,9],[10,11,12]] #print(listaCompuesta) #print(listaCompuesta[0]) #print(listaCompuesta[0][0]) #print(listaCompuesta[2][2]) #print() #for i in range(len(listaCompuesta[0])): # print(listaCompuesta[0][i]) #for i in range(len(listaCompuesta)): # for j in range(len(listaCo...
a9888e0784807ff05149ddd4871ecfb9af53ba1c
Karamba278/DZP1
/max_number.py
396
3.640625
4
n= int(input('Введите целое положительное число ')) n_hist=n if n < 10: print ('Вы ввели число с единственной цифрой') else: n2 = n % 10 n = n // 10 while n > 0: if n % 10 > n2: n2 = n % 10 n = n // 10 print('Максимальная цифра в числе ', n_hist, '- ', n2)
30089834599c0c9d1b82641f4608d2dfde20ba66
tcano2003/ucsc-python-for-programmers
/code/lab_04_Sequences/lab04_2(3)_TC.py
631
4.15625
4
#!/usr/bin/env python3 """ Ask the user for exactly 5 words, one at a time. After each word is collected from the user, print it only if it is not a duplicate of a word already collected. """ def AskForAndPrintUniqueWords(number_of_words): words = [] for loop in range(number_of_words): #range is the number of ...
6eaeb4be50a3d4b59cfa8cc547e0d4c0f532348a
ridwanrahman/datastructures
/Arrays/problems/permutation.py
344
3.9375
4
# Q: Permutation def permutation(list1, list2): if len(list1) != len(list2): return False list1.sort() list2.sort() if list1 == list2: return True return False def main(): list1 = [1,2,3] list2 = [3,2,2] print(permutation(list1, list2)) if __name__ == "__...
918462d60e20c1c31fa6931dd74eddb6a00ef497
NoneNgai/Codium-Test
/leapyear.py
510
4.28125
4
#2. Write a program that determine whether or not an integer input is a leap year. def leap(year): if(year % 400 == 0): print(str(year) + " -> true") elif(year % 4 == 0 and year % 100 != 0): print(str(year) + " -> true") else: print(str(year) + " -> false") while(1): x = int(in...
6e3ffc6001fecb75a9e22462f859fd9e030c9b81
2001052820/Actividades-de-Python
/funciones2.py
396
4.03125
4
def conversacion(mensaje): print("Hola") print("Cómo estás") print(mensaje) print("Adios") opcion = int(input("Elige una opción (1,2,3): ")) if opcion == 1: conversacion("Elegiste la opcion 1") elif opcion ==2: conversacion("Elegiste la opcion 2") elif opcion ==3: conversacion("...
42d7d4c4015d52a11a9a63514976507b8633926c
vitorbarros/byu-cse110
/w13/13_prove_assignment.py
690
4.09375
4
def wind_chill(temperature, wind_speed): return 35.74 + (0.6215 * temperature) - 35.75 * (wind_speed ** 0.16) + 0.4275 * temperature * (wind_speed ** 0.16) def convert_to_fahrenheit(value): return value * (9 / 5) + 32 def wind_speed_loop(): return temp_input = int(input('What is the temperature? ')) u...
140252035a9196c8a4a60f2fe23d874069447b7a
TypMitSchnurrbart/DACH_TEST
/scripts/files/get_data.py
4,676
3.59375
4
#!/usr/bin/python3 #!-*- coding: utf-8 -*- from files.const import DATA_HANDLE #----------------------------------------------------------------------------------------------------------------------------------- def get_user_data(activ_uid, string1, string2 = None, string3 = None): """ Function to ask user da...
1364daed164faeb07a25230cdef379f91a4e1aa9
Damnstein/conversor-monetario
/conversor_dol.py
208
3.796875
4
dolars = input("How many dolars you have?: ") dolars = float(dolars) peso_value = 74 pesos = dolars * peso_value pesos = round(pesos, 2) pesos = str(pesos) print("You have " + pesos + " pesos from Argentina")
f4fe4897397f64aa99f5266cf457800c8126983b
Prashast07/Python-Projects
/merge2arrInDescOrder.py
510
3.953125
4
# n = size of array1 # m = size of array2 def merge(array1, array2, n, m): x = 0 y = 0 result = [] k = 0 while (x < n) and (y < m): if array1[x] > array2[y]: result.append(array1[x]) x += 1 else: result.append(array2[y]) y += 1 whi...
bd5d7f44925eedea757b39054a595ee2a9f0fb4f
lookfiresu123/Interacive_python
/calculator.py
1,322
3.84375
4
# Application : Calculator # Data: Store, Operand # Print, Swap, Add, Subtract, Multiple, Divide # calculator layout # left: Control area # right: Canvas # import modules import simpleguitk as simplegui # initalize globals store = 0 operand = 0 # define functions that manipulate store and operand: a helper function...