blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
32b885cb28b5d02b0671f08143f2bc9cbd41da71
ArmandoCarrillo91/Platzi
/Cursos/basic_python/break_continue.py
520
3.65625
4
def run(): # for contador in range(1000): # if contador % 2 != 0: # continue # print(contador) # for i in range(10000): # print(i) # if i == 5668: # break # texto = input('Esccribe un Texto: ') # for letra in texto: # if letra ==...
0adc5de808e6c03f240ca745e39b417bb84d5b1d
zhagyilig/AdvancePy
/03-深入类和对象/class_method.py
1,350
3.703125
4
# -*- encoding: utf-8 -*- ''' @Author : ericzhang @Version : python3.6 @File : class_methid.py @Time : 2019/11/10 21:59:40 @Desc : 类方法、静态方法、实例方法 @Docs : ''' class Data: def __init__(self, year, month, day): self.year = year self.month = month self...
6e30b8cc3a87012ef061e574dcc674ca3c150dae
xia0m/LPTHW-Next
/Trees/DFS_pre_order.py
2,286
3.75
4
class Node(object): def __init__(self, value=None): self.value = value self.left = None self.right = None def get_value(self): return self.value def set_value(self, value): self.value = value def set_left_child(self, node): self.left = node def set...
edb6c962043125d6390f063973e2d73463508436
andyc1997/Data-Structures-and-Algorithms
/Advanced-Algorithms-and-Complexity/Week1/stock_charts.py
6,745
4.34375
4
# python3 from queue import Queue # Task. You’re in the middle of writing your newspaper’s end-of-year economics summary, and you’ve decided # that you want to show a number of charts to demonstrate how different stocks have performed over the # course of the last year. You’ve already decided that you want to show the ...
6c8514cd8de14acd6324f6d692915aeff8060de4
yyxt11/Leetcodes
/树结构/98.验证二叉树搜索树.py
898
3.90625
4
#确保左边子节点恒小于当前节点和父节点的值, 右边子节点恒大于当前节点和父节点的值 # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def isValidBST(self, root: TreeNode) -> bool: def search(root:TreeNode,lowbo...
9f9806894d0c369a462ce21f7c540216d2e4cfa4
tnfranco/courses
/Java/Login.py
253
4.09375
4
usuario = input("Digite o nome do seu usuario: ") senha = input("Digite sua senha: ") while senha == usuario: print("Senha nao pode ser igual ao usuario") usuario = input("Digite o nome do seu usuario: ") senha = input("Digite sua senha: ")
53879e9fe3a6705e8aba7ee98ec52443cebb2950
pandas-dev/pandas
/pandas/tests/arithmetic/common.py
4,362
3.609375
4
""" Assertion helpers for arithmetic tests. """ import numpy as np import pytest from pandas import ( DataFrame, Index, Series, array, ) import pandas._testing as tm from pandas.core.arrays import ( BooleanArray, NumpyExtensionArray, ) def assert_cannot_add(left, right, msg="cannot add"): ...
394b17d841707da8dc2b13c48581e250dd69390b
NagahShinawy/problem-solving
/pynative/3_ifelse_forloop/ex_7.py
316
3.9375
4
""" Exercise 7: Print the following pattern using for loop 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 """ for i in range(5, 0, -1): for j in range(i, 0, -1): print(j, end=" ") print() print("#" * 30) n = 5 k = 5 for i in range(0, n + 1): for j in range(k - i, 0, -1): print(j, end=" ") print()
9dcf1d1e3d13782fd1a5788fafcd64b3b6cfeba6
codeepicure/python-bootcamp
/09 - Secret Auction/main.py
643
4.03125
4
from replit import clear from art import logo #HINT: You can call clear() to clear the output in the console. print(logo) user_bids = {} no_more_users = False while not no_more_users: name = input("What is your name? ") bid = int(input("What is your bid? ")) user_bids[name] = bid has_more_users =...
aed22b4b26a44135f1c665ea3ecae379177aef0c
phlalx/algorithms
/leetcode/274.h-index.python3.py
416
3.765625
4
# TAGS array # can we do without a sort? def hindex(citations): citations.sort(reverse=True) i = 0 n = len(citations) while i < n and citations[i] >= i + 1: i = i + 1 return i class Solution: def hIndex(self, citations): """ :type citations: List[int] :rtype: ...
5bd177fa807b68a4399669242ff90d17ef0374e0
Mystified131/DAPSupplementalCode
/Lists2.py
414
4.125
4
#Here I set up the three lists alst = [1, 5, 6, 8, 7, 6, 3] blst = ["bear", "cat", "shark"] clst = [1.2, 3.6, 3.42] #Here I create a new list finlst = [] #Here I loop through each list, adding the elements to the new list for elem in alst: finlst.append(elem) for elem2 in blst: finlst.append(elem2) for ele...
fe38966903cc139b6f2f3c7b31eaa55ccc171bf1
jtannas/intermediate_python
/slots_magic.py
1,539
4.4375
4
""" 10. __slots__ Magic In Python every class can have instance attributes. By default Python uses a dict to store an object’s instance attributes. This is really helpful as it allows setting arbitrary new attributes at runtime. However, for small classes with known attributes it might be a bottleneck. The dict wastes...
5787e2b352c4a64b4ced2adaa169b8cd52effb94
crypdick/btree
/btreenode.py
5,840
3.796875
4
class BTreeNode(object) : '''represents a node in a B-tree, containing q < p references to child nodes and a key-pointer pair between each pair of references: ... | child i | key i, ptr i | child i+1 | key i+1, ptr i+1 | ... In the picture, child node ref i refers to the root ...
84d9a29b4b28a287f5dff164a25b2e28b27d3bd3
danield309/cs1.1-bank-account
/BankAccount.py
2,062
4.125
4
# bank account class class BankAccount: def __init__(self, full_name, account_number, routing_number, balance): self.full_name = full_name self.account_number = account_number self.routing_number = routing_number self.balance = balance # deposit method def deposit(self, amou...
8bdc54a4132656ea67d24c419965fab0358879aa
shapovalovdev/AlgorythmsAndDataStructures
/src/LinkedList/linked_list_sum.py
1,059
4.1875
4
from src.LinkedList.linked_list_realization import LinkedList, Node def sum_equal_lists(List1, List2): #check if List1 or List2 is Linked list if not return if type(List1) is not LinkedList or type(List2) is not LinkedList: raise Exception("Types of parameters are not linked list. ") return ...
9068b68e3a098f8ac8685f4f240306bfae738bad
pirate765/bridgelabzbootcamp
/day1/nosuchmethod.py
201
3.75
4
class MyClass: "This is my custom class" a = 10 def func(self): print('Hello', self.a) obj1 = MyClass() print(obj1) print(obj1.func()) print(obj1.func2()) # print(MyClass.a) # print(obj1.func())
562b810ac10c047df807426b78452123ef995336
eselyavka/python
/leetcode/solution_99.py
1,965
3.765625
4
import unittest class TreeNode(object): def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution(object): def recoverTree(self, root): """ :type root: TreeNode :rtype: None Do not return anything, modi...
d780813480c20b2f1c1dc546bf58b29adbe3ca54
arcogelderblom/AppliedAI
/Week_5/6.2.py
16,850
4.1875
4
""" Genotype is a list/array of 24 items, with the first 6 being A, the next 6 being B and so on. Each item can be a 1 or a 0. The fitness will be calculated by calculating the lift. The higher the fitness the better the individual. Mutation will happen on 4 spots. Every input for the lift function gets mutated. A ra...
70aaab72bc3bc85794d4fda30d589184f3368935
1769258532/python
/py_core/day5/day1/d19.py
440
3.703125
4
#-*-coding:utf-8 -*- #!/usr/bin/python3 # @Author:liulang ''' for in 循环 ''' test_datas = [ 1 , 2, 3, 4 ] # for i in test_datas: # in 列表,元组 # if i == 3: # break #完全跳出循环 # print(i) for i in test_datas: # in 列表,元组 if i == 3: continue # 终止本次循环,接着执行下一次迭代 print(i) # i = 0 # # whil...
037f1246d1fbc7ffb57eb13f058dc1d8271abc03
mh70cz/py
/misc/t_and_t/default_val_dict.py
1,079
3.875
4
""" Using get() to return a default value from a Python dict keywords: disctionary, default_value, lefpad, padleft, string_format based on: https://dbader.org/blog/python-dict-get-default-value """ name_for_userid = { 382: "Alice", 950: "Bob", 590: "Dilbert" } ids_to_greet = [382, 999] def non_py...
9cd9d932fa246692c485172aaec6f7d2b7fd07b4
AlexisPin/TP_CS-DEV
/penduConsole/Pendu.py
4,794
3.625
4
#Alexis PINCEMIN #30/11/2020 #Jeu du Pendu version console #Lien gitbub https://github.com/AlexisPin/TP_CS-DEV import random #on ouvre le fichier contenant la liste de tout les mots / le fichier est dans le même répertoire que le code continuer_partie = True while continuer_partie: # varibales utiles words =...
00e1eb6cd027002dc208c6c171c31fafea11b7f7
ABCmoxun/AA
/AB/linux2/day14/code/raise.py
519
3.71875
4
# raise.py # 此示例示意raise语句的用法 # 以下示意其它语言中不用异常机制,用返回值方式返回错误问题 def make_except(n): # 假设n必须是 0~100之间的数 print("begin...") if n > 100: # 传过的来参数无效,怎么告诉调用者呢? return -1 if n < 0: return -2 print("end") return 0 value = int(input("请输入一个整数:")) r = make_except(value) if r < 0: print...
590f7625baa96553fd28a68dd170f44445ca2851
Pranay2309/Python_Programs
/unity matrix.py
214
3.671875
4
x=[[7,12,17], [18,45,19], [65,14,13]] y=[[0,0,0], [0,0,0], [0,0,0]] for i in range(len(x)): for j in range(len(x[i])): y[i][j]=x[i][j]//x[i][j] for r in y: print(r)
b37ff95d5249f8ff913f382a7767f0e79c51fb70
brarajit18/Credit-Card-Fraud-Detection
/analyzeData2.py
25,424
3.984375
4
# -*- coding: utf-8 -*- """ Credit card fraud detection This notebook will test different methods on skewed data. The idea is to compare if preprocessing techniques work better when there is an overwhelming majority class that can disrupt the efficiency of our predictive model. You will also be able to see how to appl...
9a91f5e25b27cbd52e827d324ef3dd064dd4d1ec
jeffbulmer/DnDStuff
/Goblinator/SkillSet.py
2,631
3.53125
4
# -*- coding: utf-8 -*- """ Created on Fri Mar 10 15:44:47 2017 @author: jeff """ from random import randint import math class SkillSet: def __init__(self, possibleSkills): self.skills = {} self.populateSkills(possibleSkills) def populateSkills(self, possibleSkills): for...
6c78d7b69c798c835dc21edc1b17b06c3e58baa0
oscarEDA1/EDA1
/practica11/ejerc8.py
1,368
3.828125
4
# Medición y gráficas de los tiempos de ejecución importar matplotlib . pyplot como plt de mpl_toolkits . mplot3d import Axes3D importar al azar del tiempo de importación tiempo desde programa5 import insertSort desde programa6 import quicksort datos = [ ii * 100 para ii en el rango ( 1 ,...
378e7e5fa5f71cc81d58f3bbd1a561108fe68365
bishalpokharel325/python7am
/fourthday conditionalandloops/ecommerce.py
3,181
4.25
4
print("------------WELCOME TO E-COMMERCE WEBSITE----------") print("Here are our products and their selling prices:") print("SN Products Price") print("---------------------------\n") print("1 Dell 50000") print("2 Mac 150000") print("3 Tosiba 65000") print("------------------...
8cdd9fdfa9be8e7b1e0479b3ba36c22cb3b34a2c
meenakshi25jan/python_assignment
/assign16.py
604
4.125
4
""" 16.Take the input from the user for(Total number of people, toatl number of busses, Number of seats for bus). Based on the input Deside whether there is su fficient busses or not and give solution for how many extra busses required. """ import math tp=input("Enter total number of people:") tb=input("Enter to...
d50e395e05c5b6486ff5463c6f21e295540cc947
basu-sanjana1619/database_files
/create_table.py
539
3.8125
4
import sqlite3 con = sqlite3.connect('IT_company.db') cur = con.cursor() cur.execute('''DROP TABLE IF EXISTS Employee''') cur.execute('''CREATE TABLE Employee( name TEXT, emp_ID INTEGER)''') #[IF NOT EXISTS] option will create a table if table does not exist cur....
4f6ec68e46e3768b1f585a2a3fa3d2f1273dc9bd
landry-ming/leetcode_python
/Tree/offer34_二叉搜索树的后序遍历.py
2,097
3.96875
4
""" 后序遍历:左子树 + 右子树 + 根节点 二叉搜索树:左子树所有节点的值<根节点, 右子树所有节点的值>根节点,其左右子树也是二叉搜索树 递归分治: 根据递归, 判断所有子树的正确性。 递归终止条件:当i>=j,说明此子树的节点数量<=1,无需判别正确性, 直接返回True 递推工作: 1. 划分左右子树, 遍历后序遍历的[i,j]的元素, 寻找第一个大于根节点的节点, 索引为m, 此时左右子树的区间为[i, m-1], [m, j-1], 根节点索引为j 2. 判断是否为二叉搜索树, 左子树区间[i, m-1]中的所有节点都应<postorder[j], 而第 1.划分左右子树 步骤已经保证左子树区间的正确性,因此只...
c6021b00af713e70ec08955078caba153b177acf
lucasbezerra06/Exercicios
/exe045.py
530
3.734375
4
from random import randint from time import sleep op = int(input('''1 - pedra 2 - papel 3 - tesoura: ''')) jokenpo = ('Pedra', 'Papel', 'Tesoura') oppc = randint(1, 3) print('JO') sleep(1) print('KEN') sleep(1) print('PO') if 0 > op > 3: print('opção invalida') else: print('-='*10) print('{} X {}'.format(jo...
2357b9b27ad38511b7ab5ad75c580c4c365eb5dd
Jiawei-Wang/LeetCode-Study
/528. Random Pick with Weight.py
2,579
3.859375
4
# 暴力解:将每个元素的下标以它的weight的数量加入一个list,从list中随机取一个返回 # space超标 class Solution: def __init__(self, w: List[int]): self.w = w self.weight = [] for i in range(len(self.w)): self.weight += [i] * self.w[i] def pickIndex(self) -> int: index = random.randint(0, len(...
ce169b8caa488199f9f9db67075eb578125e4bbe
liubei90/leetcode
/405.数字转换为十六进制数.py
1,473
3.703125
4
# # @lc app=leetcode.cn id=405 lang=python3 # # [405] 数字转换为十六进制数 # # https://leetcode-cn.com/problems/convert-a-number-to-hexadecimal/description/ # # algorithms # Easy (50.68%) # Likes: 76 # Dislikes: 0 # Total Accepted: 12.5K # Total Submissions: 24.7K # Testcase Example: '26' # # 给定一个整数,编写一个算法将这个数转换为十六进制数。对于负...
d6412139b348989b01130ace9357a3e0f8665126
Alcogu/Master-Python
/12-Modulos/main.py
917
3.640625
4
""" Son funcionalidades ya hechas para reutilizar. """ #Importar modulo propio #primera forma """ import mimodulo print(mimodulo.holaMundo("Peluchito")) print(mimodulo.calculadora(3,5, True)) """ #Segunda Forma #from mimodulo import * importa todo from mimodulo import holaMundo #print(holaMundo("Peluchito")) # Mo...
b34cca6ba3c28de26e833f5a562a6209884120d6
pariamahmoudi/GN.Portal.Odoo
/Addons/gn_portal_parnian/distance.py
1,650
4
4
def iterative_levenshtein(s, t, costs=(1, 1, 1)): """ iterative_levenshtein(s, t) -> ldist ldist is the Levenshtein distance between the strings s and t. For all i and j, dist[i,j] will contain the Levenshtein distance between the first i characters of s and the f...
15307d63373622f4d3052c38c22bdfb65a2f4dfa
jvs--/rl
/cliff_walk.py
9,833
3.546875
4
#!/opt/local/bin/python2.7 # An implementation of Q-learning and SARSA on the cliff walk environment based # on [Sutton & Barto, 1998]'s exmaple 6.6. # # Written by: # github.com/jvs-- May 2014 import numpy as np import matplotlib.pyplot as plt import random import pprint ##############################...
a28a3cf535cf4cf1e9382e9414b213d17c9dd1ed
subinYoun/python-basics
/Lambda Express.py
163
3.640625
4
def add(a, b): return a+b #일반적인 add() 메서드 사용 print(add(3,7)) #람다 표현식으로 구현한 add()메서드 print((lambda a, b: a+b)(3, 7))
7db1fadd942d3460c4ff29d6078a167e9177582b
stacygo/2021-01_UCD-SCinDAE-EXS
/08_Statistical-Thinking-in-Python-1/08_ex_2-10.py
644
3.8125
4
# Exercise 2-10: The standard deviation and the variance import numpy as np versicolor_petal_length = [4.7, 4.5, 4.9, 4., 4.6, 4.5, 4.7, 3.3, 4.6, 3.9, 3.5, 4.2, 4., 4.7, 3.6, 4.4, 4.5, 4.1, 4.5, 3.9, 4.8, 4., 4.9, 4.7, 4.3, 4.4, 4.8, 5., 4.5, 3.5, 3.8, 3.7, 3.9,...
4c683a97b45606897563b12ead45911c089d34cd
dxmahata/codinginterviews
/leetcode/swap_nodes_in_pairs.py
1,016
3.984375
4
''' Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant space. You may not modify the values in the list, only nodes itself can be changed. URL: https://leetcode.com/problems/swap-nod...
93b0e864fa4e825fe7d28fd4e0e0ce5ae780d181
PdxCodeGuild/class_redmage
/code/scott/python/lab06_passgen.py
1,503
4.15625
4
#lab6_passgen.py #import random and string to source characters and to randomly choose from them import random import string # priming usercaps = "" userlower = "" usersym = "" capstring = string.ascii_uppercase lowerstring = string.ascii_lowercase symstring = string.punctuation password = "" # collecting desired va...
effabe997cec338c4697fb36b3dbd38e443caf7d
BrunoCruzIglesias/Python
/Pacote Download/Ex039_12_Alistamento_Militar.py
1,531
4.15625
4
#programa que leia o ano de nascimento de um jovem e informe: # Se ele ainda vai se alistar no serviço militar # Se é a hora de se alistar # Se já passou o tempo do alistamento # O programa tb deverá mostrar o tempo que falta ou tempo q passou para o alistamento import datetime # from datetime import date # ano_nasc = ...
c680f88f1ebcdd6fe33614387c41502786cb43ff
maliksh7/Data-Structure-and-Algorithms-in-Python
/Practice Codes/hashmaps.py
1,630
3.6875
4
class Hashmap: def __init__(self): self.size = 10 self.map = [None] * self.size def _get_hashed(self,key): if type(key) == int: return key % self.size if type(key) == str: return len(key) % self.size if type(key) == tuple: return len(key) % self.size def add(self,key,value): k...
fb2b0ad06a5c75df8db6c92d6c79040797ade439
victorffernandes/Classes_Homework
/Swap_217031107.py
348
3.96875
4
try: x = int(input("Insira o primeiro valor: ")) y = int(input("Insira o segundo valor: ")) print("X: ", x, end="\n") print("Y: ", y) aux = x x = y y = aux print("\n") print("X: ", x, end="\n") print("Y: ", y) except ValueError: print("Valor não pode ser convertido para n...
a4a069a9c965f34ebdab52ed9dbe56bab514d450
Edward-Becerra/Cuemby-Backend-Test
/algorithm.py
1,472
3.984375
4
""" Escriba un programa para verificar si una matriz se puede dividir en una posición tal que la suma del lado izquierdo de la división sea igual a la suma del lado derecho. """ from random import randint print("Digite el tamaño del arreglo : ") t = int(input()) # list_1=[randint(1,10) for i in range(t)] list_1 = [...
36e939e2939b66c707719dc088b0e60ac2968f40
carljhn/Assignment-3-PLD-BSCOE-1-6
/moneyv2.py
594
3.984375
4
import math def _money(): money=int(input("You have an amount of: ")) return money def aplprc(): apl_price=int(input("An apple costs: ")) return apl_price def maxapls(): max_apls=int(money/apl_price) return max_apls def getTotal(): total=apl_price * max_apls return total def getChan...
01a6f1d35b173fcfe7587537deb3b2771ed82955
mguomanila/programming_tests
/lesson11/count_semiprimes.py
3,828
4.03125
4
''' CountSemiprimes Count the semiprime numbers in the given range [a..b] A prime is a positive integer X that has exactly two distinct divisors: 1 and X. The first few prime integers are 2, 3, 5, 7, 11 and 13. A semiprime is a natural number that is the product of two (not necessarily distinct) prime numbers. The fi...
0f6ad330cc4cd190ad0604c48cfb106ec61051cd
NPettyjohn/Python
/Python_Fundamentals/multiples_sum_average.py
343
4.25
4
# Multiples example. # Print odd numbers 1 to 1000. for i in range(1,1000): if i % 2 != 0: print i # Print multiples of 5 from 5 to 1,000,000. for i in range(5,1000000): if i % 5 == 0: print i # Sum list example. a = [1, 2, 5, 10, 255, 3] for i in a: print i # Average list example. prin...
f8eae1a655787d1738f1ec1c0f2316e2d6fd414f
noahvendrig/imgclassifier1
/split_video.py
1,348
3.78125
4
''' Using OpenCV takes a mp4 video and produces a number of images. Requirements ---- You require OpenCV 3.2 to be installed. Run ---- Open the main.py and edit the path to the video. Then run: $ python main.py Which will produce a folder called data with the images. There will be 2000+ images for exampl...
fbd40f17ede701ed1ea8bc88edd2690d7bf22901
LeonOram/Files
/test_data_exercise.py
784
4.125
4
##def get_test_results(): ## test_results = [] ## for test in range(3): ## test_results.append(int(input("Please enter a score: "))) ## return test_results def average_test_result(results): total = 0 for test in results: test=int(test) total += test average = total/len(resul...
8b2d65b6e37940aa8c5d8b3105ef96891e17f377
emirot/hackerrank
/algo/ChalengeExample/mergeSort/mergeSort.py
728
3.78125
4
__author__ = 'nolanemirot' def merge(leftA, rightB): result = [] ia = 0 ib = 0 while ia < len(leftA) and ib < len(rightB): if leftA[ia] <= rightB[ib] : result.append(leftA[ia]) ia+=1 else: result.append(rightB[ib]) ib+=1 if leftA: ...
c7ef57c151c4cb58686607d1dd209a02a8db9a80
chaudharymanishkumar/Network-lab
/mono.py
1,048
4.09375
4
#Mono Alphabetic cipher Encryption and Decryption #MKChaudhary #26nov'19 monoalpha_cipher = { 'a': 'm', 'b': 'n', 'c': 'b', 'd': 'v', 'e': 'c', 'f': 'x', 'g': 'z', 'h': 'a', 'i': 's', 'j': 'd', 'k': 'f', 'l': 'g', 'm': 'h', 'n': 'j', 'o': 'k', 'p': 'l', ...
c200be9d452f550b8e6081834c1acc3370c8df3d
hsiangyi0614/X-Village-2018-Exercise
/Lesson03-Python-Basic-two/exercise4.py
204
3.9375
4
#Exercise1: N^X def number(n): def power(x): return n ** x return power n = int(input("input a number : ")) m = number(n) x=int(input("input a power : ")) print(n,"的",x,"次方 :",m(x))
9700cef64df665b88ed748eeaec645f501c0a0b5
KumarAmbuj/GEEKSFORGEEKS-DYNAMIC-PROGRAMING
/93.LARGEST SUM CONTIGUOUS ARRAY.py
352
3.78125
4
def findlargestsum(arr): maxendinghere=0 maxsumsofar=0 for i in range(len(arr)): maxendinghere+=arr[i] if maxendinghere>maxsumsofar: maxsumsofar=maxendinghere elif maxendinghere<0: maxendinghere=0 print(maxsumsofar) a = [-2, -3, 4, -1, ...
9f68b66bc65ae53090f8f7ec2925f154cc73de6f
remintz/programacaoemcasa
/exercicios/lista_aula_2/exercicio_4.py
293
4.21875
4
""" (Exercício de while ou for) Faça um programa que leia 3 números usando input e mostre a soma e a média deles. """ soma = 0.0 for i in range(3): numero = float(input(f'Informe o número {i+1}: ')) soma = soma + numero print(f'A soma é {soma}') print(f'A média é {soma / 3}')
ab8a1c6802074aca2b185b57b8e08445bcf1f00d
ckallum/Daily-Coding-Problem
/solutions/#075.py
959
3.75
4
from collections import deque from copy import copy def get_len(x): return len(x) def longest_subsequence(numbers): subsequences = [[numbers[0]]] for num in numbers[1:]: additional_sequences = [] for index, subsequence in enumerate(subsequences): if num > max(subsequence): ...
50a4e105a56210a23276ae2244129cfb448cbb8b
andyyang777/PY_LC
/67_AddBinary.py
1,317
3.75
4
# Given two binary strings, return their sum (also a binary string). # # The input strings are both non-empty and contains only characters 1 or 0. # # Example 1: # # # Input: a = "11", b = "1" # Output: "100" # # Example 2: # # # Input: a = "1010", b = "1011" # Output: "10101" # # # Constraints: ...
a7180da0486bcd21c2984cbd2f3f33a8fbcfcd1d
aalicav/Exercicios_Python
/ex040.py
403
3.921875
4
n1 = float(input('Digite a sua primeira nota :')) n2 = float(input('Digite a sua segunda nota:')) media = (n1+n2)/2 if media < 5: print('A sua média é {:.1f} e você foi reprovado'.format(media)) elif 5.0 <= media <= 6.9: print('A sua média é {:.1f} e você está de recuperação'.format(media)) elif media >= 7: ...
c2a952c22f65a07cfdc0e6ae8d12452a3d443c6a
BerryHN/DJH-Python
/data structure/day3.py
1,350
3.796875
4
# coding:utf-8 from pythonds.basic.stack import Stack class StacToQueue(object): def __init__(self): self.stack_one = Stack() self.stack_two = Stack() def enqueue(self, item): self.stack_one.push(item) def dequeue(self): if self.stack_two.isEmpty(): while not self.stack_one.isEmpty(): self.stack_...
fc80afeb2b951fd1c173d6500da211b7e650e791
niavivek/Python_programs
/all_files/HW4/HW4_extra_NiaVivek.py
946
3.546875
4
""" For extra credit, write an additional program to automatically generate the top 10 books catalog.txt from this web page (top 100 EBooks yesterday): <a href="http://www.gutenberg.org/browse/scores/top" target="_blank">http://www.gutenberg.org/browse/scores/top</a> """ """ http://docs.python-guide.org/en/latest/scen...
49221d5d6ff43301acd0f6dcc59932b68a7b4d40
Toyosie/Employee-attrition-prediction-files
/wrangling_datasets.py
1,071
3.796875
4
#Data wrangling #importing libraries import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns #importing datasets and saving them as a csv file dataset = pd.ExcelFile('study_problem.xlsx') sheet1 = dataset.parse('Existing employees') sheet1.to_csv('Existing_employees.csv', sep=','...
257ddd700fe20f653b3da73f1e8757e099e8249d
PauloLima87/CEVP_Desafios
/Desafio 40 - Média.py
397
3.9375
4
n1 = float(input('1ª Nota: ')) n2 = float(input('2ª Nota: ')) if (n1+n2)/2 >= 7: print(f'\n{"PARABÈNS! VOCÊ FOI APROVADO":=^80}\n\nSua Média final foi: {(n1+n2)/2}') elif (n1+n2)/2 >= 5 and (n1+n2)/2 <= 6.9: print(f'\n{"VOCÊ ESTA DE RECUPERAÇÃO":=^80}\n\nSua Média final foi: {(n1+n2)/2}') else: print(f'\n{...
78ff41e3d7ec171b967160fc6553cb9ed6df5099
dlingerfelt/DSC-510-Fall2019
/May_DSC510_Assignment3.py
2,086
4.28125
4
#May_DSC510_Assignment3.py #Name: Brandon May #Date: 9/8/19 #Course: DSC 510 - Introduction to Programming #Descr: Purpose is to quote pricing for feet of fiber optic cable for the May company using conditional statements and booleans. print('Welcome to the May Company') companyname = input('What is your company ...
dba9a759594cf2cc9d1d40a4778c6c5c9e5d6b47
RaghuA06/CCC-Canadian-Computing-Contest-Problems
/Waterloo J1 2015.py
363
4.125
4
# Raghu Alluri # Special Day is February 18th month = int(input()) day = int(input()) year = [month, day] if year[0] > 2: print('After') elif year[0] < 2: print('Before') elif year[0] == 2 and year[1] == 18: print('Special') elif year[0] == 2 and year[1] > 18: print('After') elif year...
793036a5518d464b386d9119aeccb6174b963e76
Lum1naT/python
/practice/list_less_than_7.py
182
3.640625
4
import sys a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] result = [] for val in a: if(val < 7): if val not in result: result.append(val) print(*str(result))
0da5ec7be37f1bc134895b20bacb6d1acaa55d62
zaman13/Particle-Swarm-Optimization-PSO-using-Python
/Code/pso_2D_animation_v1.py
7,809
3.59375
4
# -*- coding: utf-8 -*- """ Created on Sat Apr 11 17:48:18 2020 @author: Mohammad Asif Zaman Particle swarm optimization code - General code, would work with fitness function of any dimensions (any no. of parameters) - Vectorized fast code. Only one for loop is used to go over the iterations. Calculations over all ...
295454baba1d84032add0b4f5e0f18388202c081
giridhararao/new
/string without repeated.py
145
3.515625
4
i=input() b=[] c=[] for j in range(0,len(i)): b.append(i[j]) e=[] for j in b: if j not in e: e.append(j) print("".join(e))
83a720ab2fb445e5036ff56220d91ed1423f0d35
glenonmateus/ppe
/secao7/counter.py
1,522
4.03125
4
""" Módulo Collections - Counter (contador) Collection -> High-performance Container Datetypes Counter -> Recebe um interável como parâmetro e cria um objeto do tipo collection counter que é parecido com um dicionário, contendo como chave o elemento da lista passada como parâmetro e como valor a quantidade de ocorrên...
82ef0d5d2cb66dd44d213af05dea38e0b1991b62
robertggovias/robertgovia.github.io
/python/cs241/w10/list/list.py
3,000
4.59375
5
fish = ['barracuda','cod','devil ray','eel'] fish.append('flounder') print("append: ", fish) fish.insert(0,"anchovi") print("inserted achovi: ", fish) more_fish = ['goby','herring','ide','kissing gourami'] fish.extend(more_fish) print("extended a new list: ", fish) fish.remove('kissing gourami') print("removed kiss...
b8caf72ce03c9851ac38d5d35bf63601af83e8d8
urstkj/Python
/math/pi.py
988
3.890625
4
#!/usr/local/bin/python #-*- coding: utf-8 -*- # PI = 4 * (1 / 1 - 1 / 3 + 1 / 5 - 1 / 7 + ...) def pi(n): i = 0 num = 1.0 sum = 0 while i < n: sum += (-1) ** i * (1.0 / num) i += 1 num += 2 return sum * 4 def pi_new(n): y = n * 2 list1 = [1 / x for x in range(1, y...
2c4374b1aca3c59fe38134b9aa040fd668b3f70c
rcalix1/Deep-learning-ML-and-tensorflow
/TensorFlow2.0/general_examples/basics/activation_functions.py
3,578
3.5
4
## activation functions ############################################################# import numpy as np import tensorflow as tf ############################################################# X = np.array([1, 1.4, 2.5]) w = np.array([0.4, 0.3, 0.5]) #############################################################...
6fffbb8fa7bdb216cc4b9af704dda445d8039658
antweer/learningcode
/intro2python/plotting/playagain2.py
305
3.859375
4
#!/usr/bin/env python3 def playagain(): while True: answer = input("Do you want to play again(Y or N)?").lower() if answer == "y": return True break elif answer == "n": return False break else: print("Invalid input.") continue if __name__ == "__main__": print(playagain())
f6a11e69e348eac50c8dc2d0a498f20f9634ca05
osmansanteliz/Python
/bucleFor.py
379
3.859375
4
semana = ['lunes', 'martes', 'miercoles', 'jueves', 'viernes'] for dia in semana: print(dia) cantidad = int(input('Digite la Cantidad de Personas:\n')) nombre = [] salario = [] for x in range(cantidad): nom = str(input('Ingrese su Nombre:\n')) nombre.append(nom) sueldo = float(input('Ingrese ...
17f05cbb35179a2373cc47591b7d325f8d798617
AnishHemmady/Data-Struct-Python
/quicksrt.py
758
3.640625
4
''' Quicksort ''' import pdb def partn(a,strt,end): #pdb.set_trace() pivt=a[end] k=strt for m in range(strt,end): if a[m]<=pivt: a[m],a[k]=a[k],a[m] k+=1 a[k],a[end]=a[end],a[k] return k def quicksort(inp,strty,endy): #pdb.set_trace() if strty<endy: indx=partn(inp,strty,endy) quicksort(inp,strty...
9a5197e465ea046034438fb9c7ce74814b26be43
green-fox-academy/Komaxor
/week2/tue/tic_tac_toe.py
5,679
3.953125
4
p1 = " " p2 = " " p3 = " " p4 = " " p5 = " " p6 = " " p7 = " " p8 = " " p9 = " " mark = " " # draws map def draw_map(p1, p2, p3, p4, p5, p6, p7, p8, p9): for i in range (0, 9): if i == 1: print(" " + p1 + " | " + p2 + " | " + p3 + " ") elif i == 4: print(" " + p4 + " ...
9774c03b170eb9e2c1ae8994db74758ed96c3eb1
Galyndo/MetodosNumericos
/numpyMatrices.py
1,716
4.25
4
import numpy as np # Python no posee un tipo incorporado de datos para manejar matrices # por lo que en general se utilizan listas de listas para el manejo # de matrices A = [[1, 4, 5, 12], [-5, 8, 9, 0], [-6, 7, 11, 19]] # NOTA: Se debe recordar que las listas en Python inician en el índice 0 #...
e36eb18ba505173792da5770f1ef72a687b1e9cb
iamkissg/nowcoder
/algorithms/coding_interviews/09_frog_jump_1_recursively.py
490
3.78125
4
# -*- coding:utf-8 -*- """运行超时:您的程序未能在规定时间内运行结束,请检查是否循环有错或算法复杂度过大。""" class Solution: def jumpFloor(self, number): # write code here if number == 1: return 1 elif number == 2: return 2 elif number > 2: return self.jumpFloor(number-1)+self.jumpF...
355c8c71fa7dc56b3eaa13b14210abaffb51ee59
Hrushikesh-github/python_notes
/get_set_has_attr.py
442
4.375
4
class Person: age = 23 name = 'Adam' person = Person() print('Person has age?:', hasattr(person, 'age')) print('Person has salary?:', hasattr(person, 'salary')) #The hasattr() method returns true if an object has the given named attribute and false if it does not. #hasattr(object, name) print('Person age is',...
da5fde616d15e19edec3ee8a608491898f86511b
VictorCastao/Curso-em-Video-Python
/Desafio79.py
401
3.9375
4
print('=' * 12 + 'Desafio 79' + '=' * 12) resp = 'S' lista = [] while resp == 'S': a = int(input("Digite um valor: ")) if a in lista: print("Número não adicionado (já existente na lista)!") else: lista.append(a) print("Número adicionado!") resp = input("Deseja continuar[S/N]? ")....
7696e7389a5128fb879f398c87c5adb2771e2fb6
vladcipariu91/DSA-Problems
/chapter_3/graphs/dfs_iterative.py
1,361
3.734375
4
class GraphNode(object): def __init__(self, val): self.value = val self.children = [] def add_child(self, new_node): self.children.append(new_node) def remove_child(self, del_node): if del_node in self.children: self.children.remove(del_node) class Graph(objec...
cf29c017e640284c93c5e14c1aa46340d15b79ee
armandyam/euler_projects
/py/euler_24.py
685
3.65625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = "Ajay Rangarajan, Jeyashree Krishnan" __email__ = "rangarajan, krishnan@aices.rwth-aachen.de" import numpy as np import math as math from decimal import * import itertools dig = 10 a = list(itertools.permutations(range(dig), dig)) print a[999999] """ A per...
576fdece59690fceb8c5f0e93724f1809d7aead0
spuliz/Python
/test2/codeacademy.py
258
3.5625
4
my_list = [i**2 for i in range(1,11)] # Generates a list of squares of the numbers 1 - 10 f = open("output.txt", "w") for item in my_list: f.write(str(item) + "\n") f.close() # with with open("text.txt", "w") as my_file: my_file.write("Success!")
0dca16f2c1c7968c346377d1d886224d24110f36
cph-ms782/pythonSemProject
/utils/old/PDFutils.py
1,082
3.5
4
import PyPDF2 def read_pdf(address): """ convert data into text TODO lav open with ressources så den lukker ressourcen selv Done- merge to pageObjects til een med mergePage, https://pythonhosted.org/PyPDF2/PageObject.html#PyPDF2.pdf.PageObject """ # creating a pdf file object pdfFileObj = ...
8875103ae20b8817f92ad8acfcdcfeed15dff846
erx00/modified-lsb
/lsb.py
1,912
3.828125
4
from utils import str_to_binary, binary_to_str from utils import int_to_binary, binary_to_int def encode_lsb(image, message): """ Converts the input message into binary and encodes it into the input image using the least significant bit algorithm. :param image: (ndarray) cover image (supports gra...
d325c9bbcc2408ee6012032326bb7fa34c5df072
ziadawn/codeguild-class
/Python Assignments/Week 1 Python/lab7-random-password.py
752
3.859375
4
''' lab 7, a code that generates a random password, of N length input by user, from a bucket of characters and special characters other variation to try: asking how many of each kind of things I need (capitals, numbers, special characters ''' import random #these are split so I could ask for each part separately, bu...
6aaff990c7f8c7ae33248225d6937fd7cd45ba63
ncux/Python---2017-August
/List Comprehensions Example 3.py
122
3.75
4
letters = 'abcd' numbers = range(4) myList = [(letter,number) for letter in letters for number in numbers] print(myList)
81948d7d010e7b7bdbe91f9490dd14cdbdf2d500
mayur2402/python
/pattern.py
751
3.890625
4
''' accept input from user and display below pattern input : 4 4 output : * * * # 1,1 1,2 1,3 1,4 2 3 4 5 * * # * 2,1 2,2 2,3 2,4 3 4 5 6 * # * * 3,1 3,2 3,3 3,4 4 5 6 7 # * * * 4,1 4,2 4,3 4,4 5 6 7 8 ''' class Pattern: def __init__(self,Row,Col): self.Row = Row...
5ced3d1534c13dbefa2865702f940496c8019cb5
alexanderfranca/keggimporter
/keggimporter/AnendbFileSystem.py
6,681
3.734375
4
#!/usr/bin/python # -*- coding: utf-8 -*- import os import sys import shutil import pprint class AnendbFileSystem: def fileExists( self, file_path=None ): """ Test if the file path exists. Args: file_path(str): Path of the file. Returns: (boolean) ...
1ce086e01bd0d711bef2c1b5fa5a8d866c4a7955
huozhiwei/PyQt5_RapidDevolpment
/Chapter02/py202str.py
324
3.640625
4
# -*- coding: utf-8 -*- dss='hello pyqt5' print('dss',dss) #1 print('\n#1') s2=dss[1:];print('s2,',s2) s3=dss[1:3];print('s3,',s3) s4=dss[:3];print('s4,',s4) #2 print('\n#2') s2=dss[-1];print('s2,',s2) s3=dss[1:-2];print('s3,',s3) dn=len(dss);print('dn,',dn) #3 print('\n#3') print('s2+s3,',s2+s3) print('s3*2,',s3*2...
9b8f8f3d41e6da194338c052f94c286fc7cd4081
Pythonyte/python-oops
/advance_formattings.py
403
3.71875
4
# formatting numbers for i in range(9,11): print('Num is {:02}'.format(i)) print('Num is {:04}'.format(i)) # format decimal precisons pi = 3.1415667777 print('pi is {:.2f}'.format(pi)) # add commas in large numbers money_in_bank = 100000000000000 print('Total money: {:,}'.format(money_in_bank)) """ Num is 0...
ce7bc4cecf5a520b88057e42f4bccd82eb344b20
SalihTasdelen/Hackerrank_Python
/String_Formatting.py
319
4.125
4
def print_formatted(number): # your code goes here for i in range(number): #put i + 1 while right adjusting with the width of bin version print('{0:>{w}d} {0:>{w}o} {0:>{w}X} {0:>{w}b}'.format(i + 1, w=len(bin(number))-2)) if __name__ == '__main__': n = int(input()) print_formatted(n)
6c06a1055fcf093bc6a2e63cd3074cd98b055f2f
DIceEvYo/CECS274
/MaxStack.py
1,505
3.703125
4
from Interfaces import Stack import SLLStack class MaxStack(Stack) : def __init__(self): #O(1) self.stack = SLLStack.SLLStack() self.maximum = None def max(self) ->object: ''' Returns the max element O(1) ''' return ...
7033de535e7cda47ad485c8fd95a485373ebf219
dimitriacosta/python-examples
/automate_the_boring_stuff/try_catch.py
256
4.0625
4
#!/usr/bin/env python print('How many cats do you have?') cats = input() try: if int(cats) >= 4: print('That is a lot of cats.') else: print('That is not that many cats.') except ValueError: print('You did not enter a number.')
37c296e3c76ae1bde23d9731d91feb779ada7821
irving2/leetcode
/leetcode/976. Largest Perimeter Triangle.py
1,509
3.59375
4
#!/usr/bin/env python # coding=utf-8 # Project: leetcode # Author : chenwen_hust@qq.com # Date : 2019/5/13 class Solution(object): def largestPerimeter(self, A): """ :type A: List[int] :rtype: int """ # def quick_sort(a): # right=[] # left=[] ...
ab227a639994b342bae7fff18bf12e4a32f5f0e5
Navron4500/CoursesLearning
/Coding Ninjas/Classes_Files/OOPs/OOPS_1/Public_Private_Modifier_OOPS_1.py
947
3.640625
4
class Student: __passingPercentage = 40 def __init__(self,name,age=15,percentage=80): self.__name = name self.age = age self.percentage = percentage def studentDetails(self): print("Name = ", self.__name) print("Age =" , self.age) print("Percentage = ", self.percentage) def isPassed(self): if ...
09101436a73fd02820be56dffb8878e6ecd021f9
Zap123/REST-Lights-Out-Puzzle
/app/cellgame.py
623
3.515625
4
class Cellgame: def __init__(self): pass def move(self, cell, grid): cells_to_change = [cell] + cell.neighbours_cells(grid) self.invert_cells(cells_to_change) @classmethod def invert_cells(cls, cells): for cell in cells: cell.state = 1 - cell.stat...
315a592ea7ba9fcc4a8bf404c467430e62239143
bendevera/DS-Unit-3-Sprint-2-SQL-and-Databases
/module4-acid-and-database-scalability-tradeoffs/join_practice.py
975
3.890625
4
import sqlite3 conn = sqlite3.connect("chinook.db") curs = conn.cursor() num_tracks = "SELECT COUNT(*) FROM tracks;" print(f"Num tracks: {curs.execute(num_tracks).fetchone()[0]}") # what tracks are in the most playlists? (top 10) query = """ SELECT tracks.Name, albums.Title, COUNT(pt.TrackId) FROM playlist_track ...
20801658f0d60d187416f4e2ec2e1e06ed5b3939
zeromtmu/practicaldatascience.github.io
/2016/tutorial_final/77/scraper.py
4,819
3.53125
4
# coding: utf-8 # # Web Scraper (45 pts) # In[2]: # setup library imports import io, time, json import requests from bs4 import BeautifulSoup def retrieve_html(url): """ Return the raw HTML at the specified URL. Args: url (string): Returns: status_code (integer): raw_ht...
f843797d4f34a57af799317b1a61602340aa3436
LintangWisesa/ML_Sklearn_MultivariateRegression
/0_2varRegression.py
702
3.8125
4
# multivariate linear regression # linear regression with multiple variables # y = m1x1 + m2x2 + b import pandas as pd import numpy as np import matplotlib.pyplot as plt dataRumah = { 'luas': [2600, 3000, 3200, 3600, 4000], 'kamar': [3, 4, 1, 3, 5], 'harga': [550000, 565000, 610000, 595000, 760000] } df =...
cca42ac741b6699275a82ef6f10e2453cb5c75eb
n4rzzzls/textReadability
/Source/text_parser.py
597
3.71875
4
from nltk import sent_tokenize, word_tokenize, pos_tag def text_parsing(raw_text: str) -> dict: """ Transforms raw text into sentence and word tokens, tags them. :param raw_text: raw text from input file :return: a dictionary of raw text word, sentence tokens and tags. """ word_token = [] ...
36a1b1d5af43284d6a7e207381f18b36c4af5415
hassanbazari/python-practice-book
/anandology_chapter_2/2prb21_split_line.py
440
3.859375
4
#program to slice the line in a text file at a specific size import sys filename = sys.argv[1] Size=sys.argv[2] size=int(Size) lines = [] with open(filename) as f: lines = f.readlines() for line in lines: splitline = [line[i:i+size] for i in range(0, len(line), size)] #split line at specific size x=splitline[-1] ...