blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2bdafc920ae230564488bd6c7a87ce342d815a07
gauravg26/python_codeChallenges
/gaurav_gupta_OpenEdx submission 05.py
156
3.75
4
values = raw_input("enter the number by comma seprated: ") list = values.split(",") tuple = tuple(list) print 'list:', list print 'tuple:',tuple
06f6fecef2ae3e07f7ae9aa3e19aee3ad0267761
herissonsilvahs/ListPy
/linkedlist.py
2,429
3.84375
4
from node import Node class LinkedList(): lenght=0 head=None def __init__(self): pass def append(self, element): node = Node(element) if self.head == None: # if first element self.head = node else: # if existing some element current = self.head...
479005dc7116fe50538b3170a1af0adb61c4b598
salalals/ojPython2
/leetcode/Num_55_Jump_Game.py
970
3.71875
4
#!/usr/bin/python # -*- coding: utf-8 -*- class Solution(object): def canJump(self, nums): """ :type nums: List[int] :rtype: bool """ ''' 从后向前做动态规划,超时了 ''' bools = [False for i in range(len(nums) - 1)] + [True] for i in range(len(bools) - 2, -...
3a40b6ce7587d177f8e78de29642cb4c6bb89c3f
rafaelsierra/sierra-utils-rand
/src/sierra/utils/rand.py
1,793
3.890625
4
# -*- coding: utf-8 -*- import random import string import collections class stringsets(object): DEFAULT = string.ascii_letters+string.digits+string.punctuation HOMOGLYPH_SAFE = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789' ONLY_LETTERS = string.ascii_letters LETTERS_AND_NUMBERS = string.as...
056f7063c9c2273c99999e80ccbcd151858055b8
balwantrawat777/assignment-2
/assignment4.py
549
4.03125
4
#Q.no.1 lst=['jacob','will','sam',11,23,44] lst.reverse() print(lst) #Q.no.2 str="This World Is Beautiful" for i in str: if i==i.upper(): print(i,end=" ") print(str) #Q.no.3 string=(input("enter elements separated by comma")).split(",") s=list(string) print(s) #Q.no.4 a=input("enter number:") if a[::...
1f16e4804352c07dd57c323971d3bee5ebda85a9
Naereen/ansicolortags.py
/ansicolortags.py
40,629
3.875
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- """ An efficient and simple ANSI colors module (and also a powerful script), with functions to print text using colors. https://bitbucket.org/lbesson/ansicolortags.py The names of the colors follow these conventions: * for the eight ANSI colors (:black:`black`, :red:`r...
2ed9bbcf8c8db2be2a1113e1770213af85e176e9
learndevops19/pythonTraining-CalsoftInc
/training_assignments/SandipBarde/SandipBarde_day_5_assignment/logging_03.py
1,349
4.21875
4
import logging # 3. Write a program to check students percentage, accept percentage from user, # if percentage is >=80 log the debug message, # if percentage >=65 & <80 log info message, # if percentage >=50 & <65 log warning message, # if percentage >=35 & <50 log critical message, # and if percenage <35 log error me...
5a742e6c5db259c276dba61bbef1bd7d61b53438
Hejnaso/wombo-combo
/ai.py
5,142
3.546875
4
import random as rnd def tah_ai(pole, symbol): if symbol == "x": while True: if "o" not in pole and len(pole) > 5: pozice = rnd.randrange(2, len(pole) - 3) return tah(pole, pozice, symbol) elif "o" not in pole and len(pole) < 6: pozic...
29e890ce9a59de10235a6a907aa5dc7825e69eab
N3CROM4NC3R/python_crash_course_exercises
/classes/three_restaurants.py
801
3.8125
4
class Restaurant(): def __init__(self,restaurant_name,cuisine_name): self.restaurant_name = restaurant_name self.cuisine_name = cuisine_name def describe_restaurant(self): print("The name of the restaurant is: "+self.restaurant_name.title()) print("The name of the cuisine is: "...
725e0a4e205b8768107dfc052cd0564590871885
sjishan/strtest
/main.py
1,038
3.90625
4
import unittest def first_non_repeating_letter(str): #stores the frequency of the letter frequency_table = {} #lower case representation of the word lc_word = str.lower() word_length = len(lc_word) #if the letter is found for the first time then #initialize the key-value in the dictiona...
1c264d863f7b49ed797e512b61ff74d3c3564949
kaushik4u1/DATA-STRUCTURE-AND-ALGORITHM
/Arrays/Two Dimensional array/4-traverse2DElement.py
334
3.953125
4
#Travesing elements in 2D Array. import numpy as np twoArray = np.array([ [1,3,4,5],[11,32,43,54],[23,65,34,41],[22,32,43,54] ]) def traverseElement(array): for i in range(len(array)): for j in range(len(array)): print(array[i][j]) searchElement(twoArray) #Time Complexity:O(n^2) #Space Co...
e966b4e539b083ba5ca8b0cc1fc8eda09ca5f89e
Eduardo211/EG
/Lecture/Chapter_06_File_Input_and_Output/write_names.py
868
4.15625
4
# This program gets three names from the user # and writes them to a file def main(): # Get three names print('Enter the names of three friends. ') name1 = input('Friend #1: ') name2 = input('Friend #2: ') name3 = input('Friend #3: ') # Open a file named friends.txt # and use variable myfi...
fadf3822a0db7253b29198bb84c5f2871596bf12
AdamZhouSE/pythonHomework
/Code/CodeRecords/2407/60610/238347.py
678
3.625
4
date=raw_input(); time=date.split('-'); year=int(time[0]); month=int(time[1]); day=int(time[2]); JiLu=0; if year%400==0: JiLu=1; else: if year%4==0 : if year%100!=0: JiLu=1; if month == 2: day = day + 31; elif month == 3: day = day + 59; elif month == 4: day = day + 90; elif mont...
c23cd41d84c13441f1cf79c05843c5cc79770a44
SSITB/CorePython
/List_Index.py
196
4.0625
4
a = input('Enter you name: ') b = input('Enter you surname: ') if a == 'Kushal': if b == 'Bhavsar': print('Hello' +' '+ a +' '+ b) else: print('your surname is incorrect')
efadb13c2fcbbd744b5c01421f4a7d3a7922784b
MilindaRanawaka/ResourceKit
/Python/Array Reverse/Array/ArrayReverse.py
166
4.09375
4
arr = [11, 22, 33, 44, 55] print("Array is :",arr) res = arr[::-1] print("New array:",res) arr.reverse() print("After reversing Array using method reverse():",arr)
a94bbd1c3e4eddfbc2c1ed90a15517e1d7c14552
KhaledAbuNada-AI/Python-DataStructures
/Stack Implementation.py
2,107
3.71875
4
""" Python’s built-in list type makes a decent stack data structure as it supports push and pop operations in amortized O(1) time. """ s = [] s.append('khaled') s.append('Nada') s.append('Abood') print(s) s.pop() print(s) s.pop() print(s) s.pop() print(s) print(s) # collections.deque: Fast and Robust Stacks الأفض...
6ffbf8fed9a5cb74f628ee0d8d30e506758cbebf
LondonAppDeveloper/beginners-guide-to-python
/dictionaries.py
401
3.953125
4
apples = { 'cox': 17, 'braeburn': 21, 'pink lady': 7, 'royal garla': 12, 'fuji': 1 } cox_stock = apples['cox'] print('We have ' + str(cox_stock) + ' cox apples.') for apple in apples.keys(): print(apple) for apple, stock_count in apples.items(): print('We have ' + str(stock_count) + ' ' ...
c9d589786abeec443792bce99a60148c97e9cac5
LucasEdu10/Coursera
/Exercicios/semana_#2/Lista-2/exercicio1.py
298
3.875
4
name = input('Digite o seu nome: ') due_date = input('Digite o dia de vecimento: ') due_month = input('Digite o mês de vencimento: ') value = input('Digite o valor da fatura: ') print('Olá,',name,'\nA sua fatura com vencimento em',due_date,'de',due_month,'no valor de R$',value,'está fechada.')
345075b8a0be533cca019337a852bf0eaeca90a5
njuro/advent-of-code-2017
/day7/tower.py
3,429
3.8125
4
''' https://adventofcode.com/2017/day/7 ''' import re from collections import defaultdict class Program: def __init__(self, name, weight, children): self.name = name self.weight = int(weight) # Weight of this program + weight of all his children self.total_weight = self.weight ...
93cd67c84600f6b1484249bbabab2ffc8c1f6d62
Szubie/Misc
/My Files (America)/Tic-Tac-Toe computer.py
12,345
4.125
4
#Unsure what to make. Thinking back to what I did during edX: hangman? #How about a tic-tac-toe program? Text only, but with a computer opponent. #Perhaps could work on something that checks the possible outcomes for next turn and selects the best. #Could implement that first, then allow it to check multiple moves in ...
a9fa88bfe0ae46d784dc70e35b123bf3ada67372
xaowoodenfish/Chapter2
/Chapter2_pro2.py
428
3.6875
4
# Time Oct.20 2015 # The height of the folded paper def hei(times): for i in range(1,times): paper = 1.0/120 tims = 2**i paper *=tims if 10**5>paper>10**2: print 'this %d fold will be %f m. '%(i,paper/10**2) elif 10**5<paper: print 'this %d fold will b...
20b79119128b9e504e4b9049cfba54c307e1849b
tom-sherman/alphabear-solver
/hashdict.py
1,902
3.8125
4
__author__ = "Tom Sherman" """ This script reads from a file (dictionary.txt), generates a hashmap (dict) and dumps it to a json file. Only needs to be run once, unless the dictionary changes. It's quite slow, but once completed lookup of valid matches is blazing fast. """ from collections import...
e84a730c8c94e4563d7481c07faab7bc93d4a9f7
Seariell/basics-of-python-video-course
/Home work 001/002.py
1,099
4.1875
4
# Используя цикл, запрашивайте у пользователя число, пока оно не станет больше 0, но меньше 10. # После того, как пользователь введет корректное число, возведите его в степень 2 и выведите на экран. # Например, пользователь вводит число 123, вы сообщаете ему, что число неверное, и говорите о диапазоне допустимых. # И п...
f7f7b52bc28d00e63b826756aa557a0e78b32ee3
SauravJalui/data-structures-and-algorithms-in-python
/Binary Search Tree/BinarySearchTree.py
2,613
3.875
4
from queue_linkedlist import LinkedQueue class BinarySearchTree: class Node: __slots__ = "element", "left", "right" def __init__(self, element, left = None, right = None): self.element = element self.left = left self.right = right def __init__(self): ...
11004ee8397abb22869639ffe95dd0b07868cecb
harrychy8/pig-latin-translator
/translater.py
2,591
3.96875
4
#------------------------------------------------------------------------------- # Name: translator # Purpose: comp sci 20 assiment # # Author: 0802384 Harry # # Created: 05/11/2015 # Copyright: (c) Harry 2015 # Licence: <your licence> # # As a WMCI Computer Science student, I state on my hon...
d32367d6553f53c353b020a8cc154f8adedc3691
felipeserna/holbertonschool-machine_learning
/supervised_learning/0x0D-RNNs/4-deep_rnn.py
665
3.75
4
#!/usr/bin/env python3 """ Performs forward propagation for a deep RNN """ import numpy as np def deep_rnn(rnn_cells, X, h_0): """ Returns: H, Y """ t, m, _ = X.shape l, _, h = h_0.shape H = np.zeros((t + 1, l, m, h)) # Initial hidden state H[0, :, :, :] = h_0 Y = [] for st...
c6d3343689d140dc7178d57b6bbc955fa845bc12
Gyutae-Jo/algorithm
/baekjoon/0203/11720.py
141
3.5
4
import sys n = int(sys.stdin.readline()) numbers = sys.stdin.readline().rstrip() sum_ = 0 for i in numbers: sum_ += int(i) print(sum_)
dfad545c4eb63e51eee2510c57f7788f0aa6723d
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/225/users/3995/codes/1756_672.py
124
3.515625
4
# Não se esqueça de incluir o módulo numpy from numpy import* n=int(input("quantidade:")) v1=ones(n, dtype=int) print(v1)
8c08262e7463dacca920ef0d55ba01718d777294
dlingerfelt/DSC-510-Fall2019
/programmingAssignment2_1.py
1,116
4.09375
4
""" File: programmingAssignment2_1 Name: Kim Gonzalez Date: 12/4/2019 Course: DSC510-T303 Introduction to Programming Desc: Program calculates quantity and costs of fiber optic cable needed by customer and prints receipt. In: Company name from user, number of feet of fiber optic cable needed Out: Receipt for us...
d849e3f68d880401b9654cb6834693c918acecef
queryor/algorithms
/leetcode/179. Largest Number.py
954
4.09375
4
'''给定一组非负整数,重新排列它们的顺序使之组成一个最大的整数。 示例 1: 输入: [10,2] 输出: 210 示例 2: 输入: [3,30,34,5,9] 输出: 9534330 说明: 输出结果可能非常大,所以你需要返回一个字符串而不是整数。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/largest-number 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 ''' import functools class Solution: def largestNumber(self, nums) -> str: ...
5abd4c9b5d083b5ffa5d161aa93e41351a31f6c9
lovehhf/LeetCode
/28_实现strStr.py
1,856
3.765625
4
# -*- coding:utf-8 -*- __author__ = 'huanghf' """ 实现 strStr() 函数。 给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0开始)。如果不存在,则返回 -1。 示例 1: 输入: haystack = "hello", needle = "ll" 输出: 2 示例 2: 输入: haystack = "aaaaa", needle = "bba" 输出: -1 """ class Solution: def strStr(self, haystack: st...
15f7e4318aba129a1d4b8837eee5f78478c4b773
katemcg93/PANDS
/Week4/guess.py
375
3.921875
4
import random numberToGuess = random.randint(1,100) userGuess = input("Please guess a number:") while int(userGuess) != numberToGuess: print("wrong") if int(userGuess) > numberToGuess: print("Too high") else: print("Too low") userGuess = input("Please guess again:") else: print("...
669d2593227b9cb2d4f195df203edc72d20af702
Jayharer/dockerTest
/src/utilspy.py
957
3.890625
4
from datetime import date,datetime import traceback from pathlib import Path def convert_date_to_excel_number(datevalue): """ Convert datetime value into numeric value :param datevalue: python datetime value. :type datevalue: date. :returns: int -- Number equivalent to datetime. >>> ...
76471f3c74f343d28528c68ce22b61919c4ec102
catsecorg/CatSec-TryHackMe-WriteUps
/Python Playground/getConnorPW.py
603
3.75
4
import string import math characters = string.digits + string.ascii_lowercase hashstring = 'dxeedxebdwemdwesdxdtdweqdxefdxefdxdudueqduerdvdtdvdu' ord_chars = [ ord(i) for i in hashstring ] password = [ ord(j) for i in range(1,len(ord_chars),2) for j in characters if (ord(j) % 26 + 97) == ord_chars[i] ...
112eab5d2c6a4e21696f02c6ee1882ea44dcd58f
lunathirteen/algo
/addends/__init__.py
698
3.703125
4
""" Различные слагаемые По данному числу 1≤n≤10^9 найдите максимальное число k, для которого n можно представить как сумму k различных натуральных слагаемых. Выведите в первой строке число k, во второй — k слагаемых. """ def addends(n): array = [] i = 1 while n - i >= 0: n -= i array.app...
46eb7fef8ba4b2c56a08c39e16b90da97f49225e
josemvaldivia/PyIFT
/pyift/image.py
1,712
3.8125
4
class Image(): """ Image is a list of values """ def __init__(self, xsize, ysize, zsize): self.val = [0 for i in range(xsize * ysize * zsize)] self.xsize = xsize self.ysize = ysize self.zsize = zsize def __repr__(self): img = '' if self.n() <= 100 a...
4c97c22b9adb03c41d71d826c93230165b409a03
HomeRunning/hubbox
/chapter12高级函数/filter_test.py
127
3.53125
4
# filter 需要判断真假或1,0 list_x = [1,2,1,1,2,1,1] r = filter(lambda x: True if x==1 else False, list_x) print(list(r))
495fa2c2a2757222c92223d319319a555bbe642d
Taizul1579/Pythonbasic
/Area_Of_Rectangle.py
149
4.03125
4
hight = float(input("Enter The Hight Of Rectangle : ")) width = float(input("Enter The Width Of Rectangle : ")) Area = hight * width print(Area)
bf450367d11e160e4c59f0f7eb28b6ef7a810025
Andru-filit/andina
/Clase # - copia (8)/ejercicio5.py
277
3.9375
4
subjects = ["Matematica", "Fisica", "Quimica", "Historia", "Lengua"] scores =[] for subject in subjects: score= input("¿Que nota has sacado en ", subject, "?") scores.append(score) for i in range(len(subjects)): print("En", subjects[i] , "has sacado", scores[i])
42b1e9b006162072da4d8e7963ca6d772deedf8a
rubenvf/Frecuency-plot-package
/frecuency_plot.py
3,526
4.25
4
import matplotlib.pyplot as plt import seaborn as sb import pandas as pd class Countplot(): '''The Countplot class is used to visualize in a bar plot the frecuency of occurrence of a unique value list contained in an list-like column Attributes: Color (string): the color of the bar...
e281a1dae385a44b6ba15b6ad1aebfff3c8b3f3c
raghavbhatnagar96/Python-Codes
/prime.py
114
4
4
n=input("enter:") if(n>1): for i in range(2,n): if(n%i==0): print "not prime" break else: print "prime"
9e154f69cbd5035d6bfa3f349d6a6bfa5a88260b
vegatek/FinanceScrape
/extract_financial_documents.py
2,287
3.53125
4
#!/usr/bin/env python3 """ This is a script that will scrape financial information. I will be using the website: https://financialmodelingprep.com/developer/ Free plan! Upside: More accessbile and more open to other competitiors such as Yahoo Downside: 250 requests per day Upgrade with a plan Pr...
c153febf77f585de7f86303338196ee85989a834
ThePattersonian/test3
/source/Sphinx.py
4,092
3.8125
4
""" ======== Sphinx ======== This page will be dedicated to my experiences with learning about Sphinx. First Steps ============ First things first, make sure you have Sphinx installed:: pip install Sphinx Now that Sphinx is installed, it helps to have a project created. For this project, Blog, I'm going to u...
8bfdb8a24f8031f9225c60e1477e6fa7ea73d15e
VinceBro/TeamNumberOne
/src/Workspace/Interface/MotionCommandInterface.py
2,125
3.8125
4
import abc import numpy as np class MotionCommandInterface(abc.ABC): @abc.abstractmethod def acceleration(self) -> float: """ Get the acceleration (percentage) of your motion command. > Example: _acceleration = motion.acceleration """ pass @abc.abstractmethod d...
099ddb7185a8b2625af0ac971a59cf5815e2892f
Israelgd85/Pycharm
/excript/app-comerciais-kivy/Int.Ciencia_da Computacao_Python/semana-2/Lista de execicios - 1/area_quadrado.py
203
3.75
4
quadrado = int(input("Digite o valor correspondente ao lado de um quadrado: ")) perimetro = quadrado*4 area = quadrado**2 print("O perímetro do quadrado é: ", perimetro, "E a área é: ", area)
4010e4e158d51bf9d95e22b6899eac6cf22f4db6
TravisEntner/RockPaperScissors
/main.py
1,248
4.15625
4
import random userChoice = input("Chose rock, paper, or scissors.") choices = random.choice(['scissors', 'rock', 'paper']) if(userChoice == "rock" and choices == 'scissors'): print("YOU WON, you chose " + userChoice + " The computer chose " + choices + ".") elif(userChoice == "paper" and choices == 'rock'): print("...
d26560ec2f07767fe305cba918287edb8948da91
BrenoTeodor-o/Python
/strings.py
2,873
4.3125
4
# @Author: Breno Ribeiro Teodoro # Strings # As Strings são usadas em Python para registrar informações de texto, como nomes ou frases. # As strings em Python são na verdade uma sequencia, o que basicamente significa que o Python # acompanha cada elemento da string como uma sequência de caracteres. # Por exempl...
a52c6441d4aa6a40dff5c9b6a809cf3a26999412
nhl4000/kattis
/isithalloween/main.py
179
4
4
[month, day] = raw_input().split() if (int(day) == 31) and (month == "OCT"): print("yup") elif (int(day) == 25) and (month == "DEC"): print("yup") else: print("nope")
0229fbe9fb4520210889428274c94ac9eda55b10
ali-mahani/ComputationalPhysics-Fall2020
/PSet3/p3/include/generation.py
1,238
3.953125
4
#!/usr/bin/env python """ Generate a grid of size L*L and give random binary values """ import numpy as np from sys import argv def gen_binary_rand(prob): """return 1 with probability p, return 0 otherwise""" rand = np.random.uniform() if rand < prob: return 1 else: return 0 def ra...
d24fb832ca7880db374e393a25cc6f8d8d4f2b74
shankarkalmade/learnPython
/src/assignments/file_number_overlap.py
1,247
3.578125
4
from random import randint # read two files and find out overlapping numbers def write_file_one (): path = "numbers1.txt" with open(path, "wb") as write : for i in range(1,250): ran = randint(200,500) write.write(str(ran)+"\n") def write_file_two (): path = "numbers2.txt...
2c1698e4ba4dca028585440951b5da35c6aad3ab
ehauckdo/note-parser
/parser.py
1,131
3.828125
4
def read_lines(filename): lines = [] source = open(filename, "r") for line in source: lines.append(line) return lines def write_lines(lines, filename="out.txt"): with open(filename, 'w') as the_file: for l in lines: the_file.write(l) def is_hiragana(s): return fcc(s) > min_hiragana and fcc(...
65f7421c01fc8447186044b7650f5792b1eff5a7
AlexxanderShnaider/AcademyPythonLabs
/5.3.nested_loops.py
240
3.671875
4
n = int(input("Введіть число: ")) if (n > 0) and (n <= 9): for i in range(1, n + 1): for j in range(1, i + 1): print(i, end='') print() else: print("Неправильне значення!")
6c5ad1ebd40a2d8ea7f1339fccd49642e166d053
rainvare/py4e
/ex_02_05.py
108
3.859375
4
print("Exercise 2.5") c = input("Enter Celcius: ") c = float(c) f = (c * 9/5) + 32 print("Fahrenheit:", f)
0232ec0e66569b74a908a832f28a06c7b26e8d9f
Shamabanu/python
/pangram or not.py
136
3.84375
4
s=input() m=[] for i in s: if(i not in m): m.append(i) if(len(m)==27 or len(m)==28): print("yes") else: print("no")
b4b7560135f92903b339ab08ec6d6fd51471b18b
BhagyashreeKarale/loop
/9set1ques5.py
687
3.765625
4
#Loop ka use kar ke yeh pattern print karo. # 1, -2, 3, -4, 5, -6 ..99, -100 # Hint # Notice karo ki kaise pehla nuber positive, dusra number negative, fir firse positive number aur uske baad negative number. # Pattern mein ek tareeke se Positive (+) Number, Negative (-) Number, Positive (+) Number, Negative (-) Numbe...
d0d9b2142fb05c2c45d15224a94bcca06894964e
bcwood/adventofcode2020
/3/collisions.py
535
3.609375
4
with open("3/input.txt", "r") as file: data = file.read().split('\n') def collisions(data, dx, dy): height = len(data) width = len(data[0]) x = 0 count = 0 for y in range(0, height, dy): if (data[y][x] == "#"): count += 1 x = (x + dx) % width retur...
29924a2229d055db84f3e28008d9c7b28f1d4336
gvassallo/LeetCode
/062-UniquePaths.py
862
4.0625
4
# A robot is located at the top-left corner of a m x n grid. # The robot can only move either down or right at any point in time. # The robot is trying to reach the bottom-right corner of the grid. # # How many possible unique paths are there? class Solution(object): def uniquePaths(self, m, n): """ ...
e5c5945a18317158d23c9b33651987ab10db63b8
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/223/users/3858/codes/1595_1016.py
329
3.84375
4
from math import * # Teste seu codigo aos poucos. # Nao teste tudo no final, pois fica mais dificil de identificar erros. # Nao se intimide com as mensagens de erro. Elas ajudam a corrigir seu codigo. a = float(input()) b = float(input()) c = float(input()) s = (a+b+c)/2 area = sqrt(s*(s-a)*(s-b)*(s-c)) print(round(...
27271dc93ee283f61e9f91efef4f3f22919fd5e6
devLorran/Python
/ex066.py
527
4.03125
4
'''Crie um programa que leia varios números inteiros pelo teclado o programa só vai parar quando o usuario digitar o valor 999, que é a condição de parada. No final mostre quantos números foram digitados e qual foi a soma entre eles (DESCONSIDERANDO O FLAG)''' n = s = 0 nm = -1 while True: nm +=1 n = in...
1743b36db71c90a32f7757b26c1a179fde41159c
rtammisalo/ot-harjoitustyo
/src/ui/components/keypad_frame.py
4,588
3.78125
4
import functools from tkinter import StringVar, ttk, constants from entities.settings import Settings class KeypadFrame: """A keypad frame used for inputting answers without a keyboard. By default the keypad starts out hidden. Users can show it by clicking a button. Attributes: keypad_hidden: An...
85ce08aec5e47572593b4b2a0ce7c889010b839f
Nikita-2007/HardChildhood
/Python/Lessons/Lesson4 - Циклы и рандом.py
1,650
3.828125
4
# Yrock 4 import random x = 0 while x < 10: x += 1 print(x) print("") Game_over = False while not Game_over: x += 1 if x > 20: Game_over = True print(x) print("") # Циклы for: стоп, старт-стоп, старт-стоп-шаг for i in range(5): print(i) print("") for i in range(10, 13): ...
cfe4be24d6db986e50346d3d7bb4191b54287220
raghavkishan/Bio-informatics---python
/q17.py
901
3.578125
4
import math f = open('rosalind_prob.txt','r') #reading the input from a file input = f.readlines(); string = input[0] GCcontents = (input[1].split(' ')) #splitting the contents into elemnts of a list GCcontents = [float(i) for i in GCcontents] #converting strings into...
82b8795bc433193c004a7459f2dbae9064bb4f80
rpiza/adaudita
/python/menuClass.py
1,068
3.515625
4
#import funcions as funcions #from funcions import print_results #from connecta import ad class Menu(): def __init__(self, choices="", txt_menu=""): # a default value but can also be fed in. self.choices = choices self.txt_menu = txt_menu # self.adObj = adObj self.seguir = ...
710d0a91c3000c9012715d952bd5ea1fb0f01847
alexkie007/offer
/lintcode/string/replace_blank.py
666
3.65625
4
class Solution: @staticmethod def replace_blank(s): origin_size = len(s) number_of_blank = 0 for i in s: if i == " ": number_of_blank += 1 new_size = origin_size + 2 * number_of_blank p2 = new_size - 1 p1 = origin_size - 1 s2 = ...
0bfa4ac541467fa53b3fcd07e466e04c931e08da
jeesidhu/advent_calendar
/question_1.py
616
3.5
4
from utils import read_file_as_lines def calc_fuel(mass): return mass // 3 - 2 def total_fuel_part_1(masses): return sum(calc_fuel(mass) for mass in masses) def total_fuel_part_2(masses): total_fuel = 0 for mass in masses: fuel = calc_fuel(mass) while fuel > 0: total_fu...
323f0d5205933b2f3b7e2a1a8207fcb4bb6d28b4
celisun/LC19
/problems/rotate_array.py
652
3.703125
4
def rotate_array(A, n): # 1 2 3 4 5 # 3 4 5 1 2 n %= len(A) m = len(A) # O (m) time, constant space for i in range(n): tmp = A[i] j = i + n while j < m: A[j-n] = A[j] j += n A[j - n] = tmp # O m * n time, O 1 space # def rotate_1(...
7a0b3eda8689eb263ed25777c8159a68fa6da954
CHENG-KAI/Leetcode
/161_interaction_of_two_linked_list.py
1,821
3.546875
4
class ListNode: def __init__(self,x): self.val = x self.next = None class Solution(object): def getinteraction(self,headA,headB): m = self.getsize(headA) n = self.getsize(headB) if m < n: return getinteraction(self,headB,headA) fo...
ee4569722b51c6c9d60865bd509aa0d904f4f587
goswami-rahul/pythoncodes
/bankers-algo.py
2,982
4.09375
4
#!/usr/bin/python3 """ @author - Rahul Goswami run as: python3 bankers-algo.py Output: Enter the number of processes (n): 5 Enter the number of resources (m): 3 Enter the total available instances of each of the resources (space separated): 10 5 7 Enter the maximum resources (space separated) for each process: Pr...
fc22dd25af9d008c44173d038be0227b295115a1
sanjaynair20/Data-Science-
/Diabetes US 130.py
15,376
3.546875
4
#!/usr/bin/env python # coding: utf-8 # ## Data Science Project 1 ## # The data-set represents 10 years (1999-2008) of clinical care at 130 US hospitals and integrated delivery networks. It includes over 50 features representing patient and hospital outcomes # # The main objective of the data-set is to record whethe...
72edfb681c96b2510aa00c4fd49c8256740e0837
jkoo0604/Dojo_Python
/Python_Intro/BankAccount.py
1,053
3.6875
4
class BankAccount: def __init__(self, accountid, int_rate=0.01, balance=0): # don't forget to add some default values for these parameters! self.accountid = accountid self.int_rate = int_rate self.account_balance = balance def deposit(self, amount): self.account_balance += amount return self d...
a45a775468ad119bd26a7e9ce1261626d34446c1
danlucss/Cursoemvideo
/Mundo3/ex088.py
842
4.25
4
"""Exercício Python 088: Faça um programa que ajude um jogador da MEGA SENA a criar palpites. O programa vai perguntar quantos jogos serão gerados e vai sortear 6 números entre 1 e 60 para cada jogo, cadastrando tudo em uma lista compost """ from random import randint print('*-' * 15) print(f'MEGA SENA SIMULATOR') pr...
1a97fa4b3260ec71b7b66efe87a58a482ec08dc6
diohabara/sat-solver101
/src/main.py
2,201
3.703125
4
""" Solves SAT instance by reading from stdin using a recursive watchlist-base backtracking algorithm. Empty lines adn lines starting with a # will be ignored. """ from argparse import ArgumentParser, FileType from sys import stdin, stdout from typing import Any, TextIO from libs.error import eprint from solver im...
1715d878c34541b9d85a03261240ac5eed756860
Patryk-Baracz/Warsztat_01
/cyberpunk_2001.py
2,471
4.09375
4
import random def roll_dice(dice_type): d_list = [3, 4, 6, 8, 10, 12, 20, 100] if int(dice_type) not in d_list: raise ValueError(f"There are no {dice_type}D dice's") return random.randint(1, int(dice_type)) def player_turn(): d_list = [3, 4, 6, 8, 10, 12, 20, 100] while True: d1 ...
6a5ffc2f7e603f0ae9309d3ad91cabc676fc42fc
gcoop-libre/ejemplos_cursosfp
/alumnos/facu_albarracin/adivinarnumeroCgcoop.py
943
3.875
4
#! -*- coding: utf8 -*- # Problemas con if, while, booleanos. import random # Problema 3. Adivinar número al azar print ("Bienvenido! Adivine un número en tres intentos!") numerodef= random.randint (1, 8) intentos= 3 intento= 0 # Sentencia break que rompe con la iteracion de un bucle! while...
29e5ac31dc2a81a520c1a98a16e2082b1084d59d
tossacoin/PyAlgorithms
/les_1_task_8.py
481
3.90625
4
# Определить, является ли год, который ввел пользователь, # високосным или не високосным. a = input("Введите год: ") if (a.isdigit()): b = int(a) % 4 if b == 0: print("Год является високосным.") else: print("Год не является високосным.") else: print("Введенное значение не является годом...
fb7ac8cd2caa5523fa5fd568d116327310d6bfb5
tuxx42/btcbot
/token_bucket.py
1,323
3.625
4
from time import time class TokenBucket(object): """ An implementation of the token bucket algorithm. """ def __init__(self, n_req): """ Initialize a request limiting token bucket. Input: n_req number of requests per second (integer) """ sel...
441885ddfa5b156ef6bd87654eab163c0dc776e4
Tikva1989/developer-institute
/week4/day5/challenges_week4day5.py
5,574
4.125
4
# Challenges: import math # #1. Insert item at a defined index in a list: # my_list = ['a', 'b', 'c'] # my_list.insert(2, 'b1') # print(my_list) # # 2. Write a script that counts the number of spaces in a string: # my_str = " I L ove spaces" # spaces = my_str.count(" ") # print(spaces) # # 3. Write a scrip...
878738e291e88a5078d2c1c672e80591e3260110
SonOfWinterstone/pynet_test
/exercises/names.py
220
4.15625
4
#!/usr/bin/env python str1 = "One" str2 = "Two" str3 = "Three" print("{:>30}{:>30}{:>30}".format(str1,str2,str3)) str4 = raw_input("Enter fourth word: ") print("{:>30}{:>30}{:>30}{:>30}".format(str1,str2,str3,str4))
40f798f52307a566b5d510008010a7497763b31b
liuchangling/leetcode
/217.存在重复元素.py
1,336
3.625
4
# # @lc app=leetcode.cn id=217 lang=python3 # # [217] 存在重复元素 # # https://leetcode-cn.com/problems/contains-duplicate/description/ # # algorithms # Easy (50.55%) # Likes: 217 # Dislikes: 0 # Total Accepted: 109.7K # Total Submissions: 212.6K # Testcase Example: '[1,2,3,1]' # # 给定一个整数数组,判断是否存在重复元素。 # # 如果任何值在数组中出...
089b4fca9629889973d19bfc7968d50a8aa75be7
Mozzie-atles/Almostperfect
/main.py
668
3.921875
4
import sys import math # Ctrl + z or Ctrl + c to see on console. def main(num): sums = [] for factor in range(1, int(math.sqrt(num) + 1)): if num % factor == 0: yield factor if factor*factor != num: sums.append(int(num/factor)) for divisor in reversed(sums)...
e74c776f5737d5ec29dc757cbd5da856d980c317
geokai/python_prog_beginner
/Ch.02/useless_trivia.py
1,117
3.96875
4
#!/usr/local/bin/python3 # Useless Trivia # Gets personal information form the user and then # prints true but useless information about him or her: import sys sys.path.insert(0, "lib/modules") import clear clear.screen_clr() print () print ("Useless Trivia Game") print () name = input ("Hello, Please enter your ...
90f5f5c80b3a0edc1890e890f8242be520304ccb
joe-bq/dynamicProgramming
/python/LearnPythonTheHardWay/Xml/XmlList1_WritingXml.py
696
3.546875
4
''' Created on 2012-4-23 @author: Administrator ''' from xml.etree import ElementTree as ET def main(): # create the root element root_element = ET.Element("root") # create the child <child>one</child> child = ET.SubElement(root_element, "child") # set the text of the child element...
9cbf7c9228cc9f2abce40aefad8c98e4ed7792e8
liujiahuan94/LeetCode
/100Liked/Easy/Valid_Parentheses.py
663
3.875
4
def valid_parenthes(par): """ :type par: list[str] :rtype: bool """ left = '([{' par_dict = {')': '(', ']': '[', '}': '{'} # stack = [par[0]] stack = [] if len(par) % 2 != 0: return False for i in range(0, len(par)): if par[i] in left: stack.append(p...
601840fd0a7e917adecc59da4767c0a8bde6be30
chendian1229/RaspberryPi_python
/GUI/lean.py
562
3.59375
4
from tkinter import * class Application(Frame): def __init__(self,master=None): Frame.__init__(self,master) self.grid() self.createWidgets() def createWidgets(self): self.helloLabel=Label(self,text='This is test') self.helloLabel.grid(row=0,column=0,sticky=W) se...
a960796a76380697c869b1819ddb139300dfc5ed
ChristineWasike/data_structures
/week_one/four.py
1,981
3.671875
4
import matplotlib.pyplot as plt import numpy as np from week_one.functions import * from week_one.one import * from week_one.two import * from random import random, choice from string import ascii_uppercase import string # TIME PLOTS def plot_func(function, plot_title, y_axis_label): input_x_axis = [] time_y...
a9aba5273aaa55c4090849eaa6d83fb9a47f4210
Milleraj66/DetectWordRE
/DetectWordRE.py
1,594
4.34375
4
''' FileName: DetectWordRE.py Author: Arthur J. Miller Date: 02-01-2016, AJM: 02-04-2016 Purpose: ECE480 HW 1 - Develope a function that takes a string as its input and computes the frequency of every word in the string and returns a...
8a5977cf4c8cc2c5f14d36d824eb6aa9b63a55d3
shenyuanwu/python-learning
/hw7.py
1,548
3.9375
4
#1. def all_above(num_list,num_given=0): """determin all the number in the list is greater that given number num_given defaults to 0 list, num -> bool list -> bool""" for number in num_list: if num_given >= number: return False return True #2. def skip_stri...
f5ee060becdc5e65f1fb8bad87cb1012ab25071f
IsmailTitas1815/Data-Structure
/sorting algorithm/insertionSort.py
482
4
4
def insertion_sort(list): for i in range(1,len(list)): # for j in range(i-1,-1,-1): middle e -1 dewar reason hocche 0 index porjonto chalabo # if list[j] > list[j+1]: # list[j],list[j+1]= list[j+1],list[j] # else: # break j = i-1 while...
7daa8ad5fbadf7a0ba3698a45fa6e6f8f45829fc
paner-xu/python-learning-code
/08面向对象特征/xp_16_02_使用继承创建动物类和狗类.py
672
3.71875
4
class Animal: def eat(self): print("吃---") def drink(self): print("喝---") def run(self): print("跑---") def sleep(self): print("睡---") class Dog(Animal): # Dog类是Animal类的子类(派生类), # Animal类是Dog类的父类(基类), # Dog类从Animal类继承(派生) # def eat(self): # print("吃...
60374031cf6e9d717e5929ac127de94bdc2191a6
vitaliakhokhlova/POE_Python
/demo.py
1,302
3.84375
4
import math def factorielle(n): if n < 2: return 1 else: return n * factorielle(n - 1) def isprime(n): if n < 2: return False for i in range(2, round(math.sqrt(n))+1): if n % i == 0: return False return True #sans recursivité """def sum(tab): somm...
85cba50aa9331a98d559d2e7fd9414268783cc15
0xtinyuk/LeetCode
/Algorithms/36. Valid Sudoku.py
821
3.640625
4
class Solution: def isValidSudoku(self, board: List[List[str]]) -> bool: mark=[[False for i in range(9)] for j in range(9)] for i in range(9): row=[False for i in range(9)] col=[False for i in range(9)] for j in range(9): if board[i][j]!=".": ...
824b063d988764cd81470f207ea21fe4a97c11a7
masande-99/python
/guesing_game.py
388
4
4
import random def guessing(): number = random.randint(1, 10) number_of_guesses = 0 while number_of_guesses < 5: guess = int(input()) number_of_guesses += 1 if guess < number: print('Your guess is too low') if guess > number: print('Your guess is too...
000c044c028172dab1a00b76638b929341d15783
Bralor/python-workshop
/materials/07_gui/calculator.py
2,415
3.8125
4
from tkinter import * gui = Tk() gui.wm_title("simple calculator") equation = StringVar() entry = Entry(gui, width=35, borderwidth=5, textvariable=equation) entry.grid(row=0, column=0, columnspan=4, padx=10, pady=10) equation.set("Enter the expression") entry = "" def on_click(value): global entry entry +=...
a95531a87f3ace9119b7ebe1d47f8494293bc9d6
AdamZhouSE/pythonHomework
/Code/CodeRecords/2097/60604/238037.py
131
3.921875
4
a=int(input()) b=int(input()) if a%b==0: print(a//b) else: if a/b==2/3: print("0.(6)") else: print(a/b)
2f26d5ea5df022e7484dd7d5fcd9bf3f8e8ca2f7
galid1/Algorithm
/python/baekjoon/1.data_structure/queue/lib_queue.py
502
3.59375
4
#hackerrank Queue using Two Stacks import sys import queue ######## queue 생성시 변수 이름 queue로 하지 않기 ######## 크기를 별도로 지정하지 않아도 속도차이 크게 없는듯 n = int(sys.stdin.readline()) execute = [] q = queue.Queue() for i in range(n): execute.append(list(map(int, sys.stdin.readline().rstrip().split(" ")))) for i in execute: i...
543d691e9eac1c3d61ec9754907e62cf2a9bf602
zhaolianzhou/LeetCode_Python
/0-100/20_validPaentheses.py
678
3.859375
4
class Solution: def isValid(self, s): """ :type s: str :rtype: bool """ left = ['(', '[', '{'] parenthese_pair = {'(': ')', '[': ']', '{': '}'} stack = [] for c in s: if c in left: stack.insert(0, c) else: ...
a2e0257b3127faa0e092d6d478238ae56767142b
SixStringsCoder/pdx_coding
/21.py
956
3.578125
4
""" created by Steve Hanlon Make a function that advises a player on the best next move in a round of blackjack. For now, just use 15 as a Hit/Stay Threshold. Feel free to add testable features. >>> advise_player(10, 5) 15 Hit. >>> advise_player('Q', 5) 15 Hit. >>> advise_player('A', 'K') 21 Blackjack! >>> advise...
2ae5996fb4902037fb6f8985226e33941c6588be
lawrence-ms/codewars
/tribonacci_sequence.py
216
3.640625
4
# https://www.codewars.com/kata/556deca17c58da83c00002db def tribonacci(signature, n): trib_list = signature[:n] for i in range(3, n): trib_list.append(sum(trib_list[i-3:i])) return trib_list
47d00b758d7a97700e3d33fef27c57f6b16da6ee
swcarpentry/web-data-python
/code/parse-manually.py
294
3.515625
4
input_data = '1901,12.3\n1902,45.6\n1903,78.9' print('input data is:') print(input_data) as_lines = input_data.split('\n') print('as lines:') print(as_lines) for line in as_lines: fields = line.split(',') year = int(fields[0]) value = float(fields[1]) print(year, ':', value)
234bc8c0878f16ea4d828e2eb48a04f0240aa2a2
darrenvong/cryptography
/mod_int.py
5,249
3.890625
4
# -*- coding: utf-8 -*- """This module contains a (partial) implementation of a number mod another integer n (i.e. Z/nZ), written to practise writing magic functions to overload common Python operators. @author: Darren Vong """ import itertools class ModularInt(object): """This class represents integers modular ...