blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
82d51eaa75da7ecb8f15cfd3ef9ad2409ca51239
estradanorlie09/hello-python
/estrada_e3.py
90
3.875
4
input = input("Enter a comma separated list of numbers:") x=1 while x < 5: if x & 1:
d674fb8642506cbfd16fee5c211aaa38cfbbb755
estradanorlie09/hello-python
/try.py
578
3.8125
4
# for c in "hello!": # print (c) numbers = [] for x in range(10): numbers.append(x) print(numbers) numbers2 =[x for x in range(10)] print(numbers2) import sys Wind = sys,argv[1] Wind = int(sys.argv[1]) if windintensity == 200: print("Super Typhoon") elif windintensity == 89 or windinten...
e1752393679416438c2c0c1f1d4015d3cc776f58
Jaredbartley123/Lab-4
/Lab 4.1.3.8.py
783
4.21875
4
#lab 3 def isYearLeap(year): if year < 1582: return False elif year % 400 == 0: return True elif year % 100 == 0: return False elif year % 4 == 0: return True else: return False def daysInMonth(year, month): leap = isYearLeap...
b01c4dbdf69033a6dac6cb47e7a1b7072ffae1c1
Basilio0505/CS_303E-Assignments
/PizzaOrder.py
1,501
4.0625
4
class Pizza(object): def __init__(self, size = "Small", crust = "regular", toppings = []): self.size = size self.crust = crust self.toppings = toppings self.cost = 0.0 self.toppings = [] self.completed = False def addToppings(self, topping): for...
c5c7f99a32a89a10274108122e8a3fee2e247454
Basilio0505/CS_303E-Assignments
/RedDeadText.py
24,090
3.703125
4
#Basilio Bazan (bb36366) #Eduardo Alvarez (eja779) '''Will be used to randomly choose who gets hit by enemies in combat''' #Two types of comments pt1 import random '''Slows down the amount of text the player gets by having them hit a key''' def hitEnter(): #Function Definition and Function Cal...
8fa67d306411975418efa1e27a75ebfdd4f9b146
mimichaelckc/Sliding-Puzzle-Solver
/Sliding Puzzle.py
5,755
3.53125
4
import sys from heapq import heappush, heappop import time # class which representing a single game board class GameBoard: def __init__(self, gameState): self.gameState = gameState # return the coordinate of certain value def findCord(self, value): goalState = [[0, 1, 2], [3, ...
a8d29b3e2247885d8dd9648343f7b0ba27b83a4f
sathappan1989/Pythonlearning
/Empty.py
579
4.34375
4
#Starting From Empty #Print a statement that tells us what the last career you thought of was. #Create the list you ended up with in Working List, but this time start your file with an empty list and fill it up using append() statements. jobs=[] jobs.append('qa') jobs.append('dev') jobs.append('sm') jobs.append('...
9357a290fcf98a747cc27d2eab375003bf45ad71
sathappan1989/Pythonlearning
/numberlist.py
308
4.09375
4
# Store the first million numbers in a list. numbers = list(range(1,1000001)) # Show the length of the list: print("The list 'numbers' has " + str(len(numbers)) + " numbers in it.") # Show the last ten numbers: print("\nThe last ten numbers in the list are:") for number in numbers[-10:]: print(number)
5104c7828a149b107ee0a238b65dcbfeeb743bb1
sathappan1989/Pythonlearning
/ListingaSentence.py
201
4.09375
4
#ListingaSentence #Store a single sentence in a variable. Use a for loop to print each character from your sentence on a separate line. names='my name is sathappan' for name in names: print(name)
136de3f6e123df29bfba1cc12c391bd92c181145
sathappan1989/Pythonlearning
/Enumerates.py
238
3.828125
4
dogs = ['border collie', 'australian cattle dog', 'labrador retriever'] print("Results for the dog show are as follows:\n") for index, dog in enumerate(dogs): place = str(index) print("Place: " + place + " Dog: " + dog.title())
f04c7247ba0b372240ef2bc0f118f340b0c9054b
angela-andrews/learning-python
/ex9.py
565
4.28125
4
# printing # Here's some new strange stuff, remember type it exactly. # print the string on the same line days = "Mon Tue Wed Thu Fri Sat Sun" # print Jan on the same line as and the remaining months on new lines months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug" print("Here are the days: ", days) print("Here are t...
9c2d7435cfa98db6f0b7822d0db3ae6931c7e4c8
angela-andrews/learning-python
/ex18.py
539
3.859375
4
# this one is like your scripts with argv # 4 space & don't forget the colon: def print_two(*args): arg1, arg2 = args print(f"arg1: {arg1}, arg2: {arg2}") # ok, *args is pointless, just do this def print_two_again(arg1, arg2): print(f"arg1: {arg1}, arg2: {arg2}") # this takes 1 argument def print_one(arg...
7cd611deacb648a1e0329ea21631d376457f2d54
angela-andrews/learning-python
/ex14.py
757
3.875
4
# prompting and passing #using agrv and input together from sys import argv #don't forget this line script, user_name = argv # this changes the prompt from a blank to a greater than prompt = '> ' # the user_name comes from the commandline as does the script print(f"Hi {user_name}, I'm the {script} script.") print("I'...
c73358f413572fdfa0e1f309c4d0e762e50c5ef2
angela-andrews/learning-python
/ex33.py
1,268
4.40625
4
# while loops i = 0 numbers = [] while i < 6: print(f"At the top is {i}") numbers.append(i) i = i + 1 print("Numbers now: ", numbers) print(f"At the bottom i is {i}") print("The numbers: ") for num in numbers: print(num) # convert while-loop to a function def test_loop(x): i = 0 ...
9cebf17a2a8c4264a653c3cf1ca271548e65e230
Aryant55/K-coin
/ecc.py
4,511
3.6875
4
from random import randint from unittest import TestCase import hashlib import hmac class FieldElement: def __init__(self, num, prime): if num >= prime or num < 0: error = 'Num {} not in field range 0 to {}'.format( num, prime - 1) raise ValueError(error) ...
a2c2fc79eb35ef5d19aa8bf48eed08bc0ddcd238
nasingfaund/DFIR-PUBLIC
/Scripts/ip2hex.py
902
4.09375
4
#!/usr/bin/env python """ ip2hex.py -- Convert IP address to hex and show in yara friendly format. Based on code from Robert V. Bolton (http://www.robertvbolton.com) """ import sys, socket def validateIP(ip): try: socket.inet_aton(ip) return 0 except socket.error: return 1 def convertIP...
e900497ebb2c7cb89e3f425ded9a68c410c58d54
ezxmora/El-Informador-Canario
/utils/weather_conversion.py
848
3.703125
4
weather_conversions = { "Thunderstorm": "Hay tormenta en Madrid", "Drizzle": "Está lloviendo en Madrid", "Rain": "Está lloviendo en Madrid", "Snow": "Está nevando en Madrid", "Clouds": "Está nublao en Madrid", "Clear": "Está clarinete Madrid", } def temperature_conversions(temp): if temp <...
c869af26ae6dbe28279825b6135104b69ff84766
shubxd/CompletedPrograms
/reverse_number.py
104
3.84375
4
#taking input and stripping 0's from both sides num=input().strip('0') reverse=num[::-1] print(reverse)
49bb1b18646aa0aad8ec823f7206ccb08709e36a
rojit1/python_assignment
/q9.py
247
4.375
4
# 9. Write a Python program to change a given string to a new string where the first # and last chars have been exchanged. def exchange_first_and_last(s): new_s = s[-1]+s[1:-1]+s[0] return new_s print(exchange_first_and_last('apple'))
62ed4994bb2ff26ee717f135a50eddff151e0643
rojit1/python_assignment
/q27.py
298
4.21875
4
# 27. Write a Python program to replace the last element in a list with another list. # Sample data : [1, 3, 5, 7, 9, 10], [2, 4, 6, 8] # Expected Output: [1, 3, 5, 7, 9, 2, 4, 6, 8] def replace_last(lst1, lst2): return lst1[:-1]+lst2 print(replace_last([1, 3, 5, 7, 9, 10], [2, 4, 6, 8]))
73e1343256879aedfeae24d09d862b978854dd8e
rojit1/python_assignment
/q39.py
119
4.25
4
# 39. Write a Python program to unpack a tuple in several variables. t = 1, 2, 3, 4 a, b, c, d = t print(a, b, c, d)
ed96b786fb70615608c2bf16d8b2e4522f1fbfd5
rojit1/python_assignment
/q11.py
326
3.984375
4
# 11. Write a Python program to count the occurrences of each word in a given # sentence. def count_occurrences(s): word_count = dict() for i in s: if word_count.get(i): word_count[i] += 1 else: word_count[i] = 1 return word_count print(count_occurrences('appleee...
1891bc7cb066ecf5548d04503d144a60d2872232
rojit1/python_assignment
/q28.py
115
4.0625
4
# 28. Write a Python script to add a key to a dictionary. d = {'a': 'apple', 'b': 'ball'} d['c'] = 'cat' print(d)
4f9ff83562f99c636dee253b7bfdbac93f46facc
rojit1/python_assignment
/functions/q3.py
263
4.46875
4
# 3. Write a Python function to multiply all the numbers in a list. # Sample List : (8, 2, 3, -1, 7) # Expected Output : -336 def multiply_elements(lst): ans = 1 for i in lst: ans *= i return ans print(multiply_elements([8, 2, 3, -1, 7]))
34b04367ec8d16be2b194e8e817b70bed923e50e
treyhunner/project-euler
/python/006-sum-squares.py
309
4.0625
4
"""Print difference between sum of squares and square of sums of 1 to 100.""" def difference_between_sums(numbers): sum_of_squares = sum(n**2 for n in numbers) square_of_sum = sum(numbers)**2 return square_of_sum - sum_of_squares answer = difference_between_sums(range(1, 101)) print(answer)
554c793bf042bb1841587251e29f0681d4e14120
treyhunner/project-euler
/python/044-pentagonal-numbers.py
404
3.6875
4
from utils import CachedSortedIterable from itertools import count def pentagonal(): return ( n * (3*n - 1) // 2 for n in count(1) ) pentagonal_numbers = CachedSortedIterable(pentagonal()) answer = next( n - m for n in pentagonal_numbers for m in pentagonal_numbers.up_to(n) ...
302047cc6f5b78fe0599db062573cf9b9021004e
xala3pa/Introduction-to-Computer-Science-and-Programming-with-python
/week2/Problems/COUNTING_BOBS.py
307
3.9375
4
s = 'azcbobobegghaklbobbobjfuboboo' def counting_bobs(s): pattern = 'bob' index = 0 counter = 0 for letter in s: if letter == 'b': if s.find(pattern, index, index + 3) != -1: counter += 1 index += 1 return counter print counting_bobs(s)
4d24117ef25be0ac54f3b394d9df963db79d9a43
xala3pa/Introduction-to-Computer-Science-and-Programming-with-python
/week3/Problems/L5PROBLEM4.py
280
3.71875
4
def gcdIter(a, b): ''' a, b: positive integers returns: a positive integer, the greatest common divisor of a & b. ''' menor = min(a,b) while menor > 0: if a % menor == 0 and b % menor == 0: return menor menor -= 1
7b0614ad3f05e76bb8ca6400bc9e230f130c3d5e
xala3pa/Introduction-to-Computer-Science-and-Programming-with-python
/week4/Problems/L6PROBLEM2.py
960
4.1875
4
def oddTuples(aTup): ''' aTup: a tuple returns: tuple, every other element of aTup. ''' ans = () index = 1 for c in aTup: if index % 2 != 0: ans += (c,) index += 1 return ans def oddTuples2(aTup): ''' aTup: a tuple returns: ...
10dfa896cf2e91d180adb7e26063dc9bd3ef6bbb
narayana1208/repeating-phrases
/repeating-phrases.py
4,075
3.640625
4
import sys from pprint import pprint def suffix_array(text): suffix = [0]*len(text) for i in xrange(len(text)): suffix[i] = text[i:] suffix.sort() return suffix def longest_common_prefix(suffix): lcp = [0]*len(suffix) previous = "" for i in xrange(len(text)): count = 0 current = suffix[i] max_count =...
4afc0a31dc8a47f654c19aaa39ea5a17dd041a0a
fengshixiang/Target-Offer
/question12.py
1,254
3.8125
4
class Solution: def exist(self, board: List[List[str]], word: str) -> bool: rows = len(board) cols = len(board[0]) visited = [[False]*cols for i in range(rows)] path_length = 0 for i in range(rows): for j in range(cols): if self.has_path(board, i, ...
6b588b64560ceacfba4cbe1676eae2d565a28358
bshep23/Animation-lab
/Animation.py
1,388
4.15625
4
# ------------------------------------------------- # Name: Blake Shepherd and Lilana Linan # Filename: Animation.py # Date: July 31th, 2019 # # Description: Praticing with animation # # ------------------------------------------------- from graphics import * import random class Fish: ...
baefdc82a2d2af26940678bd040c871350cc6a77
swang2017/python-factorial-application
/factorial.py
390
4.15625
4
try: input_number = int(raw_input("please enter an integer\n")) except ValueError: print("Hey you cannot enter alphabets") except FileNotFound: print("File not found") else: print("no exceptions to be reported") # result = 1 # for index in range (1, input_number+1): # result = result * index # # ...
2b7470c9569abd1a45a8ab79b20e9f82418dc941
savithande/Python
/strings1.py
1,290
4.4375
4
# single quote character str = 'Python' print(str) # fine the type of variable print(type(str)) print("\n") # double quote character str = "Python" print(str) # fine the type of variable print(type(str)) print("\n") # triple quote example str = """Python""" print(str) # fine the type of variable print(type(str)...
f855f850a7b1e50ee2a47950439fe2fa13647e24
ishan2468/pythonproject
/python2.py
158
3.84375
4
list1 = [12, -7, 5, 64, -14] for n in list1: if n>=0: print(n) list2 = [12, 14, -95, 3] for n1 in list2: if n1>=0: print(n1)
6b9360006fb67d294150db93cf6c6c006c9c467f
rathod-pravin/my_turtle
/hexturl.py
267
3.625
4
import turtle col=("yellow","red","white","cyan","green") t=turtle.Turtle() screen=turtle.Screen() screen.bgcolor("black") t.speed(25) c=0 for i in range(150): t.color(col[c]) t.forward(i*1.5) t.left(59) t.width(3) if c==4: c=0 else: c+=1 turtle.mainloop()
e614847ff6c548d56322f1956604dd8a0a9ca53f
muhammadahsan21/100DaysOfLearningDataScience
/ThinkStats_Book/think_stats_exercise2_2.py
1,648
3.84375
4
import thinkstats_survey as survey import think_Stats_First as first def mean(number_list): return float(sum(number_list)/len(number_list)) def variance(number_list): mean_of_list=mean(number_list) return mean(([(x-mean_of_list)**2 for x in number_list])) def stddev(number_list): variance_of_list=var...
c8674061675727ba2c7d832d713a7f73b11df0a0
Dannsetti/Line-Simplifier
/Pt.py
337
3.546875
4
import math class Pt(): def __init__(self,x,y): self._x = x self._y = y def getX(self): return self._x def getY(self): return self._y def EuclideanDistance(self,other): return math.sqrt ((self.getX() - other.getX())**2 + (self.getY() - othe...
d932a5be8bf87870703fea8abcf99b9b903b23de
Rajan1812/Python_Threading
/example.py
564
3.671875
4
import threading import time def sleeper(n, name): print"{} sleeping for 5 minutes\n".format(name) time.sleep(n) print"{} woke up from sleep\n".format(name) #t=threading.Thread( target = sleeper, name ='thread1', args= (5,'ram')) #t.start() #t.join() thread_list=[] start=time.time() for i in range(5): t=th...
5dce524a04566f3ddfbba797e4ed2fcbabad0437
jovian34/j34_simple_probs
/coin_change/change_to_return.py
1,523
3.96875
4
from curr_constants import CURR_NAMES, CURR_VALUES def get_inputs() -> int: try: payment = input('How much money did the customer give you (in $)? ') payment = int(float(payment) * 100) price = input("What was the customer's total bill (in $)? ") price = int(float(price) * 100) ...
ac63200605586196d56b7521b2819ed0539c7d23
jovian34/j34_simple_probs
/elementary/04sum_n/sum_n.py
886
4.0625
4
# http://adriann.github.io/programming_problems.html # Write a program that asks the user for a number n and prints # the sum of the numbers 1 to n def get_number_from_user(): print('Enter a number: ', end='') return input() def sum_range(number): sum_total = 0 for i in range(1, number + 1): p...
5cd3edd9cbce8aa65769a8dd142828c072390537
jovian34/j34_simple_probs
/elementary/07mult_table/mult_table.py
372
4.1875
4
# http://adriann.github.io/programming_problems.html # Write a program that prints a multiplication table for numbers up to 12. multi_table_12 = [] for x in range(1, 13): multi_table_row = [] for y in range(1, 13): multi_table_row.append(x * y) multi_table_12.append(multi_table_row) for i in range...
a2fb730cc784a3720dc845069b9a0e1a4821adbe
jovian34/j34_simple_probs
/elementary/05sum_multiples/sum_of_multiples.py
1,239
4.1875
4
# http://adriann.github.io/programming_problems.html # Write a program that asks the user for a number n and prints # the sum of the numbers 1 to n # Modify the previous program such that only multiples of three or # five are considered # in the sum, e.g. 3, 5, 6, 9, 10, 12, 15 for n=17 def get_number_from_user(): ...
5724e2eef39435414d60c5d71c7f395743d6f2fe
jvrs95/Python
/Juros_Compostos.py
626
3.734375
4
def juros_compostos(): lista = list() x = int(input("Digite o Capital Inicial a ser investido: ")) taxa_mensal = float(input("Digite a Taxa Mensal de Juros: ")) Montante_posterior = x n = 1 while n <=12: Montante_posterior = Montante_posterior + Montante_posterior*taxa_mensal ...
6c70a145d55e3955a1807de923b199be40778663
jvrs95/Python
/Listas.py
183
3.90625
4
x=0 a=int(input("Digite um número terminado em 0")) list = [a] while list[x] != 0: list = list.append(int(input("Digite um número terminado em 0"))) x print(list)
74bb760d5fe5e321001f10694d532d983b24e53d
jvrs95/Python
/Celsius.py
206
3.9375
4
TemperaturaFahrenheit = input ("Digite uma temperatura em Fahrenheit:" ) TemperaturaCelsius = (float(TemperaturaFahrenheit) - 32)* 5 / 9 print ("A temperatura em Celsius é ", TemperaturaCelsius)
17501c2a57328ddc4f6d43608d8c047fccf11e4a
jvrs95/Python
/JogodoNIM(Formatado).py
6,511
3.890625
4
m = 0 n = 0 computador = 0 jogador = 0 def partida(): k = 0 n = int(input("Quantas peças? ")) while n <= 0: print("A quantidade de peças informada é inválida! Por favor indique um número inteiro positivo maior que 0") n = int(input("Quantas peças? ")) m = int(input("Limite de...
389369392fae5dfde98da80700a33c48c3d7463a
jvrs95/Python
/PAROUIMPAR.py
173
3.953125
4
a = int(input("Digite um número Inteiro:")) Resto = a % 2 if Resto == 0: print ("O número digitado é par") else: print("O número digitado é impar")
f53c65ce8911d729cbc82da2fc3211ee27d52c30
ScryEngineering/PickOptimiser
/utils/item.py
668
3.671875
4
"""Represent an item in the warehouse""" from utils.dimensions import SpatialDimensions class Item: """Representation of an item in the warehouse""" def __init__(self, *, SKU, weight, dimensions: SpatialDimensions, max_stack: int=1) -> None: """Representations of an item to be stored SKU: stoc...
da2bd6bb86ad92cad4ee24066caf12ce2dfc1df0
J-AugustoManzano/livro_Python
/ExerciciosAprendizagem/Cap09/c09ex01.py
1,144
3.609375
4
class TipoAluno(): nome = "" notas = [] media = 0.0 def calcMedia(self): soma = 0.0 for indice in range(4): soma += self.notas[indice] self.media = soma / 4.0 aluno = TipoAluno() # Rotina para a entrada de dados print(" CADASTRO DE ALUNO ".center...
f0ac6287181852c3d992b7a955037283243641bb
J-AugustoManzano/livro_Python
/ExerciciosAprendizagem/Cap08/c08ex11.py
113
3.859375
4
for letra in "Estudo de Python": print(letra) enter = input("\nPressione <Enter> para encerrar... ")
4b8ed8b5640d919ec0fb73334c44283c19df923d
J-AugustoManzano/livro_Python
/ExerciciosAprendizagem/Cap09/c09ex15.py
303
3.8125
4
class Hexadecimal(object): def __init__(self, valor): self.resultado = hex(valor) def __str__(self): return "%s" % (self.resultado[2:].upper() + "h") valor = Hexadecimal(1965) print("Resultado ", valor) enter = input("\nPressione <Enter> para encerrar... ")
335e5d03b64cc9c8729b54c259b4b95171fb7803
J-AugustoManzano/livro_Python
/ExerciciosFixacao/Cap08/C08EXFIX06.py
331
3.796875
4
a = [] b = [] for i in range(8): a.append(float(input("Entre o {0:2}o. valor em <A>: ".format(i + 1)))) for i in range(8): b.append(a[7 - i]) print() for i in range(8): print("A[{0:2}] = {1:5.2f} | B[{0:2}] = {2:5.2f}".format(i + 1, a[i], b[i])) enter = input("\nPressione <Enter> para encer...
2d54830c179905e57c77dcbe075f1edb6c96b943
J-AugustoManzano/livro_Python
/ExerciciosAprendizagem/Cap08/c08ex12.py
159
3.875
4
lista = [1, 2, 3, 4, 5] for indice in (lista): print(indice - 1, " - ", lista[indice - 1]) enter = input("\nPressione <Enter> para encerrar... ")
5d28d8eb5c8a6455b07838625bf29f2ceab32236
J-AugustoManzano/livro_Python
/ExerciciosAprendizagem/Cap06/c06ex02.py
618
3.546875
4
import math def pausa(): enter = input("\nPressione <Enter> para encerrar... ") # Cosseno hiperbóilico print("%14.10f" % math.cosh(60 * math.pi / 180)) # = 1.6002868577 print("%14.10f" % math.cosh(-1)) # = 1.5430806348 # Seno hiperbólico print("%14.10f" % math.sinh(45 * mat...
aab6583b9d9d2b3dae4693edd4a414a9c2bd893f
J-AugustoManzano/livro_Python
/ExerciciosAprendizagem/Cap08/c08ex09.py
330
3.9375
4
escolar = {} # Entrada de dados for i in range(8): nome = input("Entre o nome do {0:2}o. aluno: ".format(i + 1)) escolar[i] = nome # Apresentação das listas print() for i in range(8): print("Aluno {0} ...: {1}".format(i + 1, escolar[i])) enter = input("\nPressione <Enter> para encerrar.....
f408ce738c1d82e3a47b4fe7c5bbbbcb30fffa37
J-AugustoManzano/livro_Python
/ExerciciosAprendizagem/Cap09/c09ex03.py
533
3.8125
4
class TipoExemploPrivado(): __nome = "" # campo privado @property def nome(self): # propriedade substituindo método getter return self.__nome @nome.setter def nome(self, nome): # método setter self.__nome = nome produto = TipoExemploPrivado() # Rotina para a entra...
38852eeeb2ae9d69749264b2ff3e4cfef866bc02
J-AugustoManzano/livro_Python
/ExerciciosAprendizagem/Cap06/c06ex05.py
599
3.671875
4
import math def pausa(): enter = input("\nPressione <Enter> para encerrar... ") # Exponencial de um número print("%14.10f " % math.exp(3.4)) # = 29.9641000474 print("%14.10f " % math.exp(1)) # = 2.7182818285 # Logaritmo de um número print("%14.10f " % math.log(math.exp(10)...
1e30aa5a74d22a5ae2641b7aebada4f81026f6c8
J-AugustoManzano/livro_Python
/ExerciciosAprendizagem/Cap06/c06ex01.py
1,262
3.765625
4
import math def pausa(): enter = input("\nPressione <Enter> para encerrar... ") # Arco cosseno print("%14.10f" % math.acos(-1)) # = 3.1415926536 print("%14.10f" % (math.acos(0.5) * 180 / math.pi)) # = 60.0000000000 # Arco semo print("%14.10f" % math.asin(-1)) ...
48dfa34c9f3d50a4ce2d47273372810aa8be763c
J-AugustoManzano/livro_Python
/ExerciciosAprendizagem/Cap03/c03ex02.py
295
3.828125
4
a = int(input("Entre valor <A>: ")) b = int(input("Entre valor <B>: ")) r = a + b; if (r >= 10): print("Resultado = %i" % (r + 5)) print("A") else: print("Resultado = %i" % (r - 7)) print("B") print("C") enter = input("\nPressione <Enter> para encerrar... ")
dc5d3295d258b4117c47dbbb1db866351715640b
J-AugustoManzano/livro_Python
/ExerciciosAprendizagem/Cap09/c09ex12.py
536
4.09375
4
def fatorial(valor): if (valor == 0): return 1 else: return valor * fatorial(valor - 1) def somatorio(valor): if (valor == 0): return 0 else: return valor + somatorio(valor - 1) n = int(float(input("Entre o valor numérico inteiro: "))) resposta = fatoria...
0a043cf26faac6a4bc419dea8e7370eac975513b
J-AugustoManzano/livro_Python
/ExerciciosFixacao/Cap08/C08EXFIX09.py
1,361
4.09375
4
linhas = 5 colunas = 3 a = [] for linha in range(linhas): a.append([]) for coluna in range(colunas): a[linha].append(int(0)) b = [] for linha in range(linhas): b.append([]) for coluna in range(colunas): b[linha].append(int(0)) c = [] for...
d3ba9eae4d525591707e7d26919aaebf4b8a3148
J-AugustoManzano/livro_Python
/ExerciciosFixacao/Cap05/Serie A/C05EXFIXSA02.py
315
3.875
4
def potencia(base, expoente): p = 1 for i in range(1, expoente+1): p *= base print("Potência = %i" % p) b = int(input("Entre valor da base ......: ")) e = int(input("Entre valor do exponete ..: ")) print() potencia(b, e) enter = input("\nPressione <Enter> para encerrar... ")
2260c2cefb80380a0110fefeab4b03b401ef218d
J-AugustoManzano/livro_Python
/ExerciciosAprendizagem/Cap09/c09ex11.py
695
3.875
4
class TipoArea(): def area(self, x=0.0, y=0.0, z=0.0): if (isinstance(x, float) and y == 0.0 and z == 0.0): return x ** 2 elif (isinstance(x, float) and isinstance(y, float) and z == 0.0): return x ** 2 * 3.14159 * y elif (isinstance(x, float) and isinstance(...
60c6e802945788f19a178ee8830fa9bcda254176
J-AugustoManzano/livro_Python
/ExerciciosAprendizagem/Cap09/c09ex31.py
663
3.875
4
while (True): try: print("Efetue uma das seguintes entradas:") print() print("Acione <Ctrl> + <C>") print("Acione <Ctrl> + <D>") print("Entre um dado qualquer") print("Informe 'fim1' para sair") print() entrada = input("Entrada: ") i...
06e3141de93bc64d3db30de6f3a75cc4312d2ad9
J-AugustoManzano/livro_Python
/ExerciciosAprendizagem/Cap09/c09ex13.py
207
3.75
4
class Dobro(object): def __init__(self, valor): self.resultado = valor * 2 calculo = Dobro(7) print("Resultado ", calculo) enter = input("\nPressione <Enter> para encerrar... ")
39ae2075c7fbc41f18bcce1ecfc1e0760099ca56
aws-samples/amazon-fsx-for-lustre-usage-metrics-to-amazon-cloudwatch
/fsxlcw/utils/diskfill.py
2,026
4.0625
4
#!/usr/bin/env python3 """ Create some binary files to fill up the filesystem """ import argparse import os def generate_big_random_bin_file(directory, file_name, size): """ generate big binary file with the specified size in bytes :param directory: the parnt directory where the files will be created ...
6f059f8c48932af8fbb1d98eb9d1e8ee4dca55b2
yashgugale/Python-Programming-Data-Structures-and-Algorithms
/NPTEL Course/Programming assignments/4(a)-minmaxfreq.py
2,818
3.984375
4
def frequency(l): #first sorting the list for i in range(len(l)-1, 0, -1): for j in range(i): if(l[j] > l[j+1]): temp = l[j] l[j] = l[j+1] l[j+1] = temp print("Initial sorted list: ",l) #add the distinct elements to a new list ...
b29e7eba5620eb7d8c54715543b62cae65aaeee4
yashgugale/Python-Programming-Data-Structures-and-Algorithms
/NPTEL Course/Concept Practices/inplace_scope_exception2.py
1,222
4.1875
4
L1 = [10, 20 ,30] print("Global list L: ", L1) def f1(): L1[2] = 500 print("L1 from function on in place change is is: ", L1) print("\nShallow copy of L1 to L2") L2 = L1 L2.append(600) print("Lists L1 and L2 are: L1:", L1, "L2: ", L2) print("\nDeep copy of L1 to L3") L3 = L1.copy() ...
1d0ccc2706d98ce0791da26401eeee06aa866a61
yashgugale/Python-Programming-Data-Structures-and-Algorithms
/NPTEL Course/DS/Backtracking and permutations/permutations.py
833
3.578125
4
def permutation(l): i = len(l)-1 while l[i] < l[i-1]: i = i-1 next_suffix = i-1 print(next_suffix) while l[next_suffix] < l[i]: i += 1 swap_letter = i-1 print(swap_letter) print(l) l[swap_letter], l[next_suffix] = l[next_suffix], l[swap_letter] print(l) for...
7b7766fe17c2cd4fe6410c62fae48c806c6de655
L3viathan/scripts
/timer
2,684
3.578125
4
#!/usr/bin/env python3 """ Super simple timer application in "natural" language. """ import ast import sys import time minute = 60 hour = 60*minute DEBUG=False # from /usr/share/misc/units.lib units = dict(map(lambda x: x.split("\t"), """second sec s sec seconds sec minute 60 sec + minutes minute min minute mins mi...
10fc14af8350f3bd72cf3d64613f0b5ceb0b84f8
nfiles/hackerrank
/algorithms/arrays_and_sorting/median/median.py
768
3.671875
4
#! /bin/python def main(): n = int(raw_input()) arr = [int(i) for i in raw_input().strip().split()] median = find_median(arr) print median def find_median(arr): return partition(arr[:], 0, len(arr) - 1) def partition(arr, lo, hi): def swap(arr, i, j): arr[i], arr[j] = arr[j], arr[i] ...
482264cc02dc0f0f0093cb38e531ce50f7041f8f
nfiles/hackerrank
/algorithms/arrays_and_sorting/insertion_sort/insertion_sort_2.py
491
3.875
4
#! /bin/python def main(): N = int(raw_input()) arr = [int(i) for i in raw_input().strip().split()] insertion_sort(arr) def insertion_sort(arr): for i in xrange(1, len(arr)): sort_iter(arr, i) print ' '.join(str(i) for i in arr) def sort_iter(arr, end): unsorted = arr[end] for...
d1c3bba7531f87f51e0ef6b7ade86b4e657b13ea
nfiles/hackerrank
/algorithms/arrays_and_sorting/quicksort/sort.py
556
3.8125
4
#! /bin/python def main(): N = int(raw_input()) arr = [int(i) for i in raw_input().strip().split()] sort = quicksort(arr) def quicksort(arr): if len(arr) <= 1: return arr pivot = arr[0] lower = [] upper = [] for i in xrange(1, len(arr)): value = arr[i] if value...
b948aa4cfa5608c820129074bd050250dddf83eb
nfiles/hackerrank
/algorithms/arrays_and_sorting/running_time/running_time.py
463
3.75
4
#! /bin/python def main(): N = int(raw_input()) arr = [int(i) for i in raw_input().strip().split()] shifts = insertion_sort(arr) print shifts def insertion_sort(l): shifts = 0 for i in xrange(1, len(l)): j = i-1 key = l[i] while (l[j] > key) and (j >= 0): l[j...
bcae10b007172a57dac0121a7a84feff564c60d6
nguyeti/mooc_python_10_app
/date_time.py
790
4.34375
4
from datetime import datetime, timedelta import time # Basic date operation now = datetime.now() yesterday = now - timedelta(days=1) lastYear = datetime(2016,3,8,0,0,0,0) # create a datime object with (year, month, day, hour, minute, seconds, milliseconds) print(str(now)) print(str(yesterday) + ' ***** \n') # convert...
9e750b872b0d154f74f64353e71b0bdeb7e4f122
nguyeti/mooc_python_10_app
/OOP/example.py
1,880
4.21875
4
class Machine: def __init__(self): print("I am a Machine") class DrivingMachine(Machine): def __init__(self): print("I am a DrivingMachine") def start(self): print("Machine starts") class Bike(DrivingMachine): def __init__(self, brand, color): self.brand = brand # __at...
eb2b71845ab019e7fa8131669bf3777e6d93c3d5
nguyeti/mooc_python_10_app
/ex1_c_to_f.py
541
4.1875
4
""" This script converts C temp into F temp """ # def celsiusToFahrenheit(temperatureC): # if temperatureC < -273.15: # print("That temperature doesn't make sense!") # else: # f = temperatureC * (9/5) + 32 # return f temperatures = [10, -20, -289, 100] def writer(temperatures): """T...
40fb26e751a769060f7c2258b2e098f04d57467d
EQUASHNZRKUL/PythonAI
/BinaryTreeNode.py
2,659
3.890625
4
class BinaryTreeNode(object): def __init__(self, val, left=None, right=None): self.val = val if left == None: self.left = None else: self.left = BinaryTreeNode(left) if right == None: self.rite = None else: self.rite = ...
f3a3622d19f650ff7b25532bc12ae5f1786f7d5f
nitin-ch/CodeFights_Arcade
/almostIncreasingSequence.py
1,019
4
4
def first_bad_pair(sequence): """Return the first index of a pair of elements where the earlier element is not less than the later elements. If no such pair exists, return -1.""" for i in range(len(sequence) - 1): if sequence[i] >= sequence[i + 1]: return i return -1 def almost...
95b417d3d2aa05513ed7c887643415b81e4ae929
student-work-agu-gis2021/lesson4-functions-and-modules-15719044
/temp_functions.py
465
4.0625
4
def fahr_to_celsius(temp_fahrenheit): """ The input temperature in Fahrenheit is converted to Celsius. Parameters temp_fahrenheit: Temperature in Celsius. Returns Changed to fahr_to_celsius. """ converted_temp=(temp_fahrenheit - 32)/1.8 return converted_temp def temp_classifier(temp_cel...
2bd70c736f6913b5dbf31563133273e62b7b3ad6
cifpfbmoll/practica-4-python-AlfonsLorente
/src/Ex5.py
2,106
4.09375
4
#!/usr/bin/env python3 #encoding: windows-1252 #Pida al usuario un importe en euros y diga si el cajero autom�tico le puede dar dicho importe utilizando el mismo billete y el m�s grande #(recuerda que el billete puede ser de 500, 200, 100, 50, 20, 10 y 5 �). #Por ejemplo: #25 euros �el cajero te devuelve 5 billetes...
583edbf053189c85f7fe2e79a170f15ddd42ca03
LingB94/Target-Offer
/64求1+2+...+n.py
220
3.6875
4
def Sum0(n): return 0 def SumForN(n): funChoice = {False:Sum0, True:SumForN} flag = not not n result = n+funChoice[flag](n-1) return result if __name__ == '__main__': print(SumForN(5))
563116d7510b865685ac964752d3d44a634be516
LingB94/Target-Offer
/33二叉搜索树的后序遍历序列.py
823
3.5
4
class TreeNode(object): def __init__(self, n): self.val = n self.lchild = None self.rchild = None def verify(L): if(not L): return False p = L[-1] step1 = 0 while(L[step1] < p and step1 < len(L)): step1 += 1 for step2 in range(step1, len(L)):...
04030c3b5d8178b5fa3aa7c82bf9b7b06641ebdc
LingB94/Target-Offer
/29顺时针打印矩阵.py
1,321
3.984375
4
def circleMatrix(M): if(not M): return False rows = len(M) columns = len(M[0]) if(rows == 0 or columns == 0): return False start = 0 while(2 * start < rows and 2 * start < columns ): printCircle(M, rows, columns, start) start += 1 def printCircle(M, r...
c9647c1af580d90d5d48eb4244ccfb69ee933f7d
LingB94/Target-Offer
/45把数组排成最小的数.py
495
3.703125
4
import functools def compare(s1, s2): if(s1+s2 < s2+s1): return -1 if(s1+s2 > s2 + s1): return 1 if(s1+s2 == s2+s1): return 0 def leastCombine(l): if(not l): return False s = [] for i in l: s.append(str(i)) s.sort(key = functools.cmp_to...
3032c7ba41e086d2be4463e79978bd6647999c9d
LingB94/Target-Offer
/38字符串的排列.py
705
3.609375
4
import itertools def permutation(s): if(not s): return None if(len(s) == 1): return list(s) l = list(s) l.sort() result = [] for i in range(len(l)): if(i > 0 and l[i] == l[i-1]): continue part2 = permutation(''.join(l[:i]) +''.join(l[i+1:])...
08a13f19320fdbf8abb7466fcd91c3e3e37dfa4c
LingB94/Target-Offer
/2单例模式.py
455
3.625
4
class singleTon(object): instance = {} def __new__(cls, *args, **kw): if cls not in cls.instance: cls.instance[cls] = super(singleTon, cls).__new__(cls) return cls.instance[cls] class testClass(singleTon): def __init__(self, n = 1): self.coef = n if __name__ ==...
1f90807c81934fd38d38dd8bd5e42102813efa86
c18441084/Python
/Labtest1.py
1,056
4.375
4
#Function to use Pascal's Formula def make_new_row(old_row, limit): new_row = [] new_list = [] L=[] i=0 new_row = old_row[:] while i < limit: new_row.append(1) long = len(new_row) - 1 j=0 h=0 if i ==0: new_list = new_row[:] ...
c06447e51e110f190df86b43d5030bb179694fef
Renan94/renan_pereira_cordeiro
/fracao_continua.py
510
4.03125
4
#REPRESENTAÇÃO EM FRAÇÕES CONTÍNUAS def main(): a = int(input("Digite um numero inteiro : ")) b = int(input("Digite um número inteiro : ")) q = a//b r = a - q*b fr = [] div = False while not div: fr.append(q) a = b b = r q = a//b r = a - q...
779b089cc02c838c569960736cf0fb7c05037024
csy113/iems5718
/time_func.py
589
3.65625
4
from datetime import datetime, timedelta import logging timeformat="%Y-%m-%d %H:%M:%S" def str2datetime(timestr): try: t = datetime.strptime(timestr, timeformat) except ValueError: logging.warn("Received time with invalid format " + timestr) t = None return t def datetime2str(datetime): try: str = dateti...
d0092057d615ba0067f48a07be80c37e423b0cd9
bachns/LearningPython
/exercise24.py
278
4.3125
4
# Write a Python program to test whether a passed letter is a vowel or not. def isVowel(v): vowels = ("u", "e", "o", "a", "i") return v in vowels vowel = input("Enter a letter: ") if isVowel(vowel): print("This is a vowel") else: print("This isn't a vowel")
ece0d3f409b258a7a098917b0a865f2569c8eb10
bachns/LearningPython
/exercise27.py
255
4.15625
4
# Write a Python program to concatenate all elements in a list into # a string and return it def concatenate(list): conc_str = "" for number in list: conc_str += str(number) return conc_str print(concatenate([3, 4, 1000, 23, 2]))
60fe76e0b3bd43e87dde6e7e7d77ad4d5108c326
bachns/LearningPython
/exercise7.py
315
4.25
4
# Write a Python program to accept a filename from the user and print # the extension of that. # Sample filename : abc.java # Output : java filename = input("Enter file name: ") parts = filename.rsplit(".", 1) print("Extension:" + parts[-1]) index = filename.rfind(".") + 1 print("Extension:" + filename[index:])
c3a0e29d457803d6bbae306b86c2ed98e476d77d
bachns/LearningPython
/exercise21.py
334
4.25
4
# Write a Python program to find whether a given number (accept from the user) # is even or odd, print out an appropriate message to the user def check_number(number): if number % 2: return "This is an odd number" return "This is an even number" number = int(input("Enter a number: ")) print(check_nu...
b890be0ff18a909af438207b6382ff21f1695bd4
thandongtb/machine-learning-repo
/regression/linear_regression.py
1,859
3.59375
4
import os import pandas as pd import numpy as np from sklearn import linear_model from sklearn.model_selection import train_test_split def getData(): # Get home data from CSV file dataFile = None if os.path.exists('home_data.csv'): print("-- home_data.csv found locally") dataFile = pd.read_...
aa12efbbf191865f71c3c59c2c50ac58338ac00b
axxporras/LTI-3er-Semestre
/evidencia2.py
2,830
3.78125
4
import pandas as pd import datetime directorio = {} clavos = 20 martillo = 30 taladro = 50 respuesta = '' while respuesta !=4: print('\nDetalle de Ventas Ferretería Don Alberto \n') print('[1] Registrar Venta(s)') print('[2] Consultar Venta(s)') print('[3] Encontras Venta(s) por fecha')...
8f8a2370ca1b3492f057d63523c30394915a863b
KAYDAVID/AnAnomalousEncounter
/tiles.py
6,791
3.53125
4
import random import items, enemies, actions, world global start start = True class MapTile: def __init__(self,x,y): self.x = x self.y = y def intro_text(self): raise NotImplementedError() def modify_player(self, player): raise NotImplementedError() #def get_description(self): #raise NotImplem...
fb2d435f92eb4bd5225df032d9c2187e306bb4ce
kevin556/MAAIN
/vecteur.py
1,147
3.65625
4
#!/usr/bin/python2.7 from math import * class Vecteur(object): def norme(self): somme = 0.0 for i in range(0,len(self.vecteur),1): somme += pow(self.vecteur[i],2) # print "somme %f \n"%(somme) return sqrt(somme) def __getitem__(self,index): if(index < l...
cdc06d42b26d7f5e6c6f9275885858437d3fc553
brianb1/2017Challenges
/challenge_4/python/CindyB/src/Challenge4.py
246
3.640625
4
from Tree import Tree from TreeNode import TreeNode input = [4,2,7,1,3,6,9] my_tree = Tree(TreeNode(input[0])) input.remove(input[0]) for value in input: my_tree.insert(value) my_tree.print_tree() my_tree.invert_tree() my_tree.print_tree()