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
44040eb8915ddda92ee3f53c92eef8dd25352365
Miquerox/codewars.com
/python/kyu_6/training_on_equal_sides_of_an_array.py
313
3.765625
4
# https://www.codewars.com/kata/5679aa472b8f57fb8c000047/train/python def find_even_index(arr): index = 0 while index < len(arr): lhs_sum = sum(arr[:index]) or 0 rhs_sum = sum(arr[index + 1:]) or 0 if lhs_sum == rhs_sum: return index index += 1 return -1
b4a486d2740d85c94ac1701f45d16dc371c2b0d2
mayconrcampos/Python-Curso-em-Video
/Exercicios/Exercício - 049 - Tabuada v2.0.py
543
3.984375
4
from time import sleep n = int(input('Digite um número para ver sua tabuada: ')) cont = 1 while cont <= 10: tabuada = cont * n sleep(0.5) print('{} x {} = {}'.format(n, cont, tabuada)) cont += 1 print('Esta aí sua Tabuada de {} usando a função while!'.format(n)) #---------------------------------------...
8ca315488525d0a3bd2ef71858fe33e4a37f6164
mayconrcampos/Python-Curso-em-Video
/Exercicios/Exercício - 067 - Tabuada v3.0.py
621
4.03125
4
while True: n = int(input('Digite um número para ver sua tabuada: ')) if n < 0: print('Fim do Programa!') break for c in range(1, 11): print(f'{n} x {c} = {n * c}') #Quando for pra fazer tabuada simples, pode se fazer com while, #Porém se quiser que o programa refaça a pergunta pr...
426a0f258a7ca0b51be146b3a5eae6e8a6be96ba
mayconrcampos/Python-Curso-em-Video
/Exercicios/Exercicio - 015 - Aluguel de carro.py
220
3.515625
4
dias = float(input("Quantos dias alugado? ")) km = float(input("Quantos km foi rodado? ")) pago = (dias * 60) + (km * 0.15) print("O valor a ser pago por {} dias e {} km rodados será de R${:.2f}".format(dias, km, pago))
547388b177738ee3bc823d751cbb271c829a1328
mayconrcampos/Python-Curso-em-Video
/Exercicios/Exercicio - 077 - Encontrando Consoantes - Tuplas.py
404
4.09375
4
minha_tupla = () continua = ' ' while continua not in 'nN': adiciona = str(input('Digite uma palavra: ')).upper() continua = str(input('Quer acrescentar mais um item? S/N: ')) minha_tupla += adiciona, for palavra in minha_tupla: print(f'\nA palavra {palavra} temos as consoantes', end=' ') for letra...
e4e3fb036fa7dea368ea039a402a97d146861a25
mayconrcampos/Python-Curso-em-Video
/Exercicios/Exercício - 018 - Seno Cosseno e Tangente.py
761
4.03125
4
import math angulo = float(input("Digite o ângulo que você deseja: ")) seno = math.sin(math.radians(angulo)) coseno = math.cos(math.radians(angulo)) tangente = math.tan(math.radians(angulo)) print("O ângulo de {} tem o seno de {:.2f}".format(angulo, seno)) print("O Cosseno é {:.2f}".format(coseno)) print("A Tangente é ...
8213b36e3728eac349dce94f77f619b3869a25d4
mayconrcampos/Python-Curso-em-Video
/Exercicios/Exercício - 089 - Boletim com Listas Compostas.py
661
3.734375
4
lista = [] continua = ' ' while continua not in 'nN': nome = str(input('NOME: ')) nota1 = float(input('Nota 1: ')) nota2 = float(input('Nota 2: ')) continua = str(input('Continua? S/N: ')) media = (nota1 + nota2) / 2 lista.append([nome, [nota1, nota2], media]) print('-=' * 20) print(f'{"No.":<5...
24e1d186d3e303e630e5af015a331e0ecf9a99da
mayconrcampos/Python-Curso-em-Video
/Exercicios/Exercício - 084 - Lista Composta e Análise de dados.py
830
3.859375
4
pessoas = [] pesos = [] leves = [] nomespesados = [] nomesleves = [] pesados = [] continuar = ' ' while True: nome = str(input('Nome: ')) peso = int(input('Peso: ')) continuar = str(input('Quer continuar? S/N: ')) pessoas.append(nome) pesos.append(peso) if continuar in 'nN': break fo...
19422cc5932c379fe3e7c1f2f6dbbc63f0cbee52
mayconrcampos/Python-Curso-em-Video
/Exercicios/Exercício - 013 - Reajuste Salarial.py
501
3.90625
4
salario = float(input("Quanto você ganha de salário?: R$ ")) au = float(input("Digite quantos % você quer de aumento salarial ")) #aqui voc￿ê escolhe a porcentagem de aumento) valor = salario + (salario * au / 100)#Aqui vai ser calculado com a porcentagem escolhida) aumento = salario + (salario * 15 / 100) print("Seu s...
5ee839bca4f449b1e1f4946d785b402b30f6b35b
mayconrcampos/Python-Curso-em-Video
/Exercicios/Exercício - 028 - Jogo da adivinhação v1.0.py
204
3.890625
4
import random numero = int(input('Adivinhe um numero entre 0 a 5: ')) escolhido = random.randint(0, 5) if numero == escolhido: print('Parabéns! Você acertou na mosca!!!') else: print('Errou!!')
53f16ccd315cebddd0e170ad6cabd1409514d7f5
mayconrcampos/Python-Curso-em-Video
/Exercicios/Exercício - 082 - Dividindo valores em várias listas.py
487
3.609375
4
lista = [] lista_pares = [] lista_impares = [] while True: n = int(input('Digite um número: ')) continua = str(input('Quer continuar? S/N: ')) lista += n, if continua in 'nN': break elif n in lista: if n % 2 == 0: lista_pares.append(n) else: lista_im...
6f8d82a05165af93f2093a292bfb353ee822adf5
CFM-MSG/Code_SDN
/extension/recorder.py
1,481
3.59375
4
from collections import defaultdict class DictMeter(object): """Computes and stores the average and current value""" def __init__(self, momentum=0.9): self.momentum = momentum self.data = defaultdict(lambda: defaultdict(float)) self.count = defaultdict(int) def reset(self): ...
7a6ea5c9fa1c6a6669db83d09962630bba9b29b7
supermanhuyu/my_atm
/core/time_cal.py
1,964
3.6875
4
# -*- coding: utf-8 -*- # @Time : 2017/12/22 19:31 # @Author : superman # @FileName: time_cal.py # @Software: PyCharm Community Edition # @Blog : """ 时间处理模块 """ import datetime,time def get_22nd_of_last_month(): """ 获取上个月第一天的日期,然后加21天就是22号的日期 :return: 返回日期 """ today=datetime.datetime.today()...
93dd61a81f9a497e4d94165c4186c4b34e68ae74
carolynkpi/HDB_getLocationData
/myFunctions.py
5,748
3.578125
4
#Import Libraries import pandas as pd import requests import json as json import time import csv import pandas as pd import requests import json as json import time import csv ''' tryGET: Function to keep trying a GET request, handling the following errors: 1. Request function error 2. Request returned error 3. Googl...
b8da10fe0d52d9d8ff08344c4bc8d3465b8f3e6d
atifahsan/project_euler
/p1.py
275
4.21875
4
# If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000. numbers = [i for i in range(1, 1000) if not i % 3 or not i % 5] print(sum(numbers))
575fdc03c9f49954e0b6e13b60484d87756bdc4f
abhishekvermasg/codeforces
/Strings/59A.py
144
3.578125
4
a = input() l = sum([int(i.islower()) for i in a]) u = sum([int(i.isupper()) for i in a]) if l >= u: print(a.lower()) else: print(a.upper())
bf2d364b9be4f7b44d4c6d6dd9394fa5ca981070
abhishekvermasg/codeforces
/Strings/520A.py
87
3.5625
4
_, a = input(), input().lower() if len(set(a)) == 26: print('YES') else: print('NO')
1179247685bb98e5de3d5de793ba677670d18e55
ananth-duggirala/Data-Structures-and-Algorithms
/Arrays and Strings/reverse_string.py
338
4.28125
4
""" Problem statement: Reverse a string. """ def reverseString(string): newString = "" n = len(string) for i in range(n): newString += string[n-1-i] return newString def main(): string = input("This program will reverse the entered string. \n\nEnter string: ") print(reverseString(string)) if __name__ == "_...
03bccdc7f71d23716f391b9b8405b5fa103b02af
MingkaiMa/Software-Construction-Linux-Script_Language
/Python/echon.py
381
3.515625
4
#!/usr/bin/python import sys import re if(len(sys.argv) != 3): print('Usage: {} <number of lines> <string>'.format(sys.argv[0])) sys.exit(1) match = re.match(r'^[0-9]+$', sys.argv[1]) if not match: print('{}: argument 1 must be a non-negative integer'.format(sys.argv[0])) sys.exit(1) string = sys.a...
01c65c847ad8ca3837d0ae0d5a2a8f7cd419e9a7
giknik/AoC2020
/day12/day12_part1.py
681
3.65625
4
# # AoC 2020 py solution for day 12 # Part 1 evasive actions: # make all the moves and # calculate the Manhattan distance # with open('moves.txt') as f: lines = f.read().splitlines() nesw = [0, 0, 0, 0] curr_direction = 90 for move in lines: direction, val = move[0], int(move[1:]) if direction in "...
66437888772efa4e99570b8ab5d2a99464e5f2ae
radleap/Blockchain
/Support/block_errors.py
2,274
3.8125
4
#------------------------ def myFunc(int_in): return int_in/5 print("function only output", myFunc(100)) #------------------------ # class myClass: # oneval = 17 # # C = myClass() # print(C.oneval) #------------------------ # class myClass: # oneval = 17 # def div(self, int_in): #need self to invoke #...
2be5f42d0096461736d039d1638d3d139dda5f53
Ellenfei/simulation_data
/simulation_data/drawPicture.py
3,933
3.640625
4
import matplotlib.pylab as pl import numpy as np # # 隐藏层函数比较(ReLu和Sigmoid函数) x1 = np.linspace(0, 10000, 1000) y1 = np.loadtxt('./activation_function/relu85.data') x2 = np.linspace(0, 10000, 1000) y2 = np.loadtxt('./activation_function/sigmoid63.data') pl.plot(x1, y1, 'r', linewidth=2.0, linestyle='-', label='ReLu,N...
14fb2fc84971fe058b6cb80ebddc55a59bc243d4
fahad30897/FlipBookLanguage
/models/Image.py
743
3.75
4
from copy import copy,deepcopy class Image(object): def __init__(self, name, position, size, path): self.name = name self.position = position # self.frameNumber = frameNumber self.size = size self.path = path def resize(self, width, height): self.size.first = wid...
9616830c66699c75c8502aa68ea0048332c2698f
ClaudiaStrm/Introducao_ciencia_da_computacao
/02-07_perto.py
778
3.9375
4
#Receba 4 números inteiros na entrada. #Os dois primeiros devem corresponder, respectivamente, às coordenadas x e y de um ponto em um plano cartesiano. #Os dois últimos devem corresponder, respectivamente, às coordenadas x e y de um outro ponto no mesmo plano. #Calcule a distância entre os dois pontos. #Se a distânc...
fd4eb5330b061418a769c2c436f369f353197f58
ClaudiaStrm/Introducao_ciencia_da_computacao
/02-04_buzz.py
240
3.96875
4
#Receba um número inteiro na entrada e imprima Buzz se o número for divisível por 5. #Caso contrário, imprima o mesmo número que foi dado na entrada. x = int(input("Informe o número: ")) if x % 5 == 0: print("Buzz") else: print(x)
277cf603c8c3652936bc7f1ff1e6ded0111c82b0
ClaudiaStrm/Introducao_ciencia_da_computacao
/04-01_fizzbuzz.py
572
4.125
4
#Escreva a função fizzbuzz que recebe como parâmetro um número inteiro e retorna #'Fizz' se o número for divisível por 3 e não for divisível por 5; #'Buzz' se o número for divisível por 5 e não for divisível por 3; #'FizzBuzz' se o número for divisível por 3 e por 5; #Caso a função não seja divisível 3 e também não sej...
58d9e8ee1ebc6b1d7487d0d7c740e08447371a2a
kajolz/first
/p1.py
562
3.828125
4
e=eval(input('enter english marks')) h=eval(input('enter hindi marks')) m=eval(input('enter maths marks')) s=eval(input('enter science marks')) g=eval(input('enter geography marks')) ma=((e+h+m+s+g)/500)*100 if ma>75: print('o grade') else: if ma>=60 and ma<75: print('a grade') else: if ma>=...
1a351054dfea0aea8015eb2b699037ae5f80efee
xlhtc007/ud120-projects
/svm/svm_author_id.py
1,630
3.71875
4
#!/usr/bin/python """ This is the code to accompany the Lesson 2 (SVM) mini-project. Use a SVM to identify emails from the Enron corpus by their authors: Sara has label 0 Chris has label 1 """ import sys from time import time workspace_dir = "C:/Users/dm1-3266/PycharmProjects/ud120-projects/...
de4694fb71452e755965668012a088947a292c9c
dzhunkovskyi/test_exercise
/exercise_2.py
210
3.6875
4
def handle_string(value): count_letters = 0 count_digits = 0 for element in (value): if element.isalpha(): count_letters+=1 if element.isdigit(): count_digits+=1 return count_letters, count_digits
8d3b93f79c3283fccdd919da235766aa7ebccc2f
kodfun/PythonOgreniyorum
/TekMiCiftMi.py
318
3.78125
4
# bu iki satır console ekranını temizlemek için import os os.system("cls") print("Bu program girdiğiniz sayının tek mi çift mi olduğunu söyler.") # sayı tek mi çift mi sayi = int(input("Sayı: ")) if sayi % 2 == 0: print("çift") else: print("tek") """ bu yorum çok satırlı bir yorumdur """
8391191aa5fc0ff6eb1d36d55e9105a6dc655c01
kodfun/PythonOgreniyorum
/Strings5.py
2,834
4.1875
4
# STRING METOTLARI # https://www.w3schools.com/python/python_strings_methods.asp s = "merhaba DÜNYA" print(s.capitalize()) print(s.upper()) print(s.lower()) print("01234567890123456789") print("KODLUYORUM".center(20)) print("KODLUYORUM".center(20,"*")) # KAÇ TANE A HARFİ GEÇİYOR? s = "ankara" print(s.count("a")) ...
cde27024d109e0e08904c8a33a9d0ba17a6df26a
Pkpallaw16/List-and-string-level2
/Minimum Number Of Platform.py
302
3.59375
4
def Minimum_Number_Of_Platform(arr,dep): arr.sort() dep.sort() n=len(arr) i=0 j=0 cmax=0 omax=0 while i<n: if arr[i]<=dep[j]: cmax+=1 i+=1 else: cmax-=1 j+=1 omax=max(omax,cmax) return omax
f5fa5cec67c3a8b428e6ab3a185c4321e99e3a1d
Pkpallaw16/List-and-string-level2
/19 Sort Array By Parity.py
228
3.5
4
def Sort_Array_By_Parity(nums): j=0 i=0 while i <len(nums): if nums[i]%2!=0: i+=1 else: nums[i],nums[j]=nums[j],nums[i] i+=1 j+=1 return nums
dbaa01a0577e8881287fe5c5c7c4c541d5f31487
Pkpallaw16/List-and-string-level2
/7 Next Greater Element I I I.py
880
3.5
4
def dipIndex(lis): dip=-1 i=len(lis)-1 while i>0: if lis[i-1]<lis[i]: print("hi") dip=i-1 return dip i-=1 return dip def ceilIndex(lis, indx): for i in range(len(lis)-1,-1,-1): if lis[i]>lis[indx]: return i return -1 def rev...
87b0926d466483377994d493124ccba225d05bc7
IMaresaLI/QuizApplication
/DatabaseManager.py
2,043
3.75
4
import sqlite3 class sqliteData(): def __init__(self): pass def Connect(self): connection = sqlite3.connect("quizApp.db") cursor = connection.cursor() list = [connection,cursor] return list def UsersAdd(self,username,passwd,e_mail,name_lastname,...
dea4949c87b39688dd8fac86294671d02542f0a2
JoseMorisJr/LeetCode-Python
/Palindromo.py
484
3.5
4
class Solution: def isPalindrome(self, x: int) -> bool: from copy import deepcopy num = deepcopy(x) if (x == 0): return True elif (x < 0) or (x % 10 == 0 ): return False rev = 0 while (x != 0): pop = x % 10 ...
2105be6c3cf68ade8a976e86f09534557ea514d3
klamx/CompuGrafica2020-2
/Ejercicios-2clase/e2.py
407
3.84375
4
# Solicitar numero al usuario y mostrar la secuencia de Fibonacci def fib(n): if n < 2: return n else: # fn = fn-1 + fn-2 return fib(n-1) + fib(n-2) def getNumber(): numb = raw_input() numb = int(numb) return numb if __name__ == '__main__': print "Ingrese la posicion de la seri...
bbcad27fe559b75b35303717d01a4d8f1c18b1e2
Jamesargy6/AdventOfCode
/2017/day17/day17p1.py
291
3.9375
4
import sys pInput = 312 buf = [0] index = 0 #iterate 2017 steps for x in range(2017): #pass through the list and add the next "x" for y in range(pInput): index = (index+1)%len(buf) index += 1 buf.insert(index, x+1) #return the value of the next item in the array print(buf[index+1])
fe250866feca05b0938583050bdc8bb509a2add0
Jamesargy6/AdventOfCode
/2015/day5/day5p1.py
616
3.515625
4
import sys file = open("../inputs/day5input.txt", "r") directions = file.read().split("\n") vowels = ["a","e","i","o","u"] badStrings = ["ab", "cd", "pq", "xy"] goodStrings = 0 for d in directions: #bad string check hasBadString = False for bs in badStrings: if bs in d: hasBadString = True if hasBadString: ...
74e5de2a78fb1da1c95d526d54c0d8a448408eb4
Jamesargy6/AdventOfCode
/2018/python/day11/day11.py
2,602
3.59375
4
import sys from typing import List, Dict def get_hundredths_place(input: int) -> int: input = input // 100 return input % 10 def get_power_level(grid_serial_number: int, x_index: int, y_index: int) -> int: rack_id = x_index + 10 power_level = rack_id * y_index power_level += grid_serial_number ...
97c20f5ec2f15f19c1cebaaaf831806800e0be48
Jamesargy6/AdventOfCode
/2017/day4/day4p2.py
517
3.640625
4
import sys file = open("../inputs/day4input.txt", "r") passphraseLines = file.read().split("\n") validPhrases = 0 index = 0 for line in passphraseLines: isValidLine = True words = [] for word in line.split(): word = ''.join(sorted(word)) if word in words: print("Line ", index, " invalid: ", word) isValidL...
2c34a63e2117d238becec5f916bfb1a865cac876
knight134/clock_in_python
/saveMoney_challenge.py
1,381
3.96875
4
#!/usr/bin/python # -*-coding:utf8 -*- import datetime ''' 52周存钱挑战 输入一个日期,判断是第几周,然后输出该周的存款金额 ''' import math def main(): """ 主函数 :return: """ money_per_week=10 # 初始化每周存入金额 i=1 # 初始化周数 increase_money=10 # 每周递增的钱数 total_week=52 # 总共52周 saving=0 # 账户累计钱数 money_l...
28cbcb9342692e9e44f56d41dfda6d98d443d533
Thybat/Snake
/Main.py
8,465
3.5625
4
import tkinter as tk import sys import time import random secondes = time.time() print("Seconds =", secondes) matrix_x = 1 matrix_y = 0 orientation_memory = 0 snake = [] fruit = 0 snake_queue = 0 check_queue = True def fruit_generation(): fruit = [random.randint(0, 39), random.randint(0, 27)] print(fruit[0], ...
0e805ca2b13db38535e56922eea28bdfeb1487b9
Suman196pokhrel/TkinterPractice
/src/m3e_button_callback.py
4,074
4.59375
5
""" Example showing for tkinter and ttk: -- How to CONSTRUCT and DISPLAY a WIDGET (in this case, a ttk.Button) -- How to associate a widget (here, a ttk.Button) with a CALLBACK function that is a LAMBDA (anonymous) function. Authors: David Mutchler, Mark Hays, and their colleagues at Rose-H...
8af2e44e30d2e180e9b16f63c69d2d53d6a1594b
Suman196pokhrel/TkinterPractice
/more_examples/m7e_canvas_and_mouse_events.py
2,551
4.3125
4
""" Example showing for tkinter and ttk how to: -- Capture mouse clicks, releases and motion. -- Draw on a Canvas. Authors: David Mutchler and his colleagues at Rose-Hulman Institute of Technology. """ import tkinter from tkinter import ttk class PenData(object): def __init__(self): self.co...
629eb246f65ed62d31e5d32b31cd63fffc0fa296
khaleeqArshad1/test
/Lab6_Python/task2.py
115
3.578125
4
integral_number = raw_input("Enter Integer : ") dict = {} for i in (0, integral_number): dict[i] = i*i print dict
5777e4ccb119601a816f0966e91f5b61b4a9f793
njagdale/code-magic
/puzzles/MS_Projects/PythonApplications/RandomNumberDice.py
158
3.65625
4
import sys import random x = "y" while x == "y": num = random.randint(1,6) print num x= raw_input('want to continue? (y/n) ') print "Goodbye !"
a6187a3ea433bcab00a2d0ecc7e843d69fec7163
maainul/Python
/Total_sum_of_number_and_average_using_for_loop.py
200
4.1875
4
num = int(input('Enter a number: ')) sum = 0 for i in range(0, num+1): sum = sum + i average = sum//num # print(i) print('Sum of Number is:', sum) print('Average of number is: ', average)
d6577d3cba76440597da1653413a156453e16514
maainul/Python
/pay_using_try_catch.py
244
4.125
4
try: Hours=input('Enter Hours:') Rates=input('Enter Rates:') if int(Hours)>40: pay=40*int(Rates)+(int(Hours)-40)*(int(Rates)*1.5) print(pay) else: pay=int(Hours)*int(Rates) print(pay) except: print('Error,Please enter numeric input.')
40dd9571ea493b4e8747d24fcfdc21bccd014d64
maainul/Python
/Regular_Ex_Find_complex_Combination.py
15,245
3.609375
4
# Search for lines that start with 'X' followed by any non # whitespace characters and ':' # followed by a space and any number. # The number can include a decimal. # Search for lines that contain 'From' import re file = open('mbox-short.txt') count=0 for line in file: line = line.rstrip() if re.search('^X\S*: ...
92a38318f10a81e8ed2a88c9d19896ed3ecd96c9
maainul/Python
/oop_creating_method_in_python.py
423
3.875
4
class Parrot: #instance attributes def __init__(self,name,age): self.name = name self.age = age #instance method def sing(self,song): return "{} sings {}".format(self.name,song) def dance(self): return "{} is now dancing".format(self.name) #instantiate the object...
7a5309d036bb4eab1546665e05fa14d9f16c998c
maainul/Python
/Automate the boring stuff/Chapter_6/Creat_separation_using_bracket.py
209
3.96875
4
import re phone=re.compile(r'(\d\d\d)-(\d\d\d-\d\d\d\d)') mo=phone.search('My phone number is 412-444-9870') print(mo.group(1)) print(mo.group(2)) print(mo.group()) """ Output: 412 444-9870 412-444-9870 """
dc54502a549f56b66637befa2cbf522f744357c0
maainul/Python
/Centimeter_to_feet_and_inch.py
265
4.125
4
cm=int(input("Enter the height in centimeters:")) inches=0.394*cm feet=0.0328*cm print("The length in inches",round(inches,2)) print("The length in feet",round(feet,2)) OUTPUT: Enter the height in centimeters:50 The length in inches 19.7 The length in feet 1.64
033ff075c77ebce00b53078d0727863eb0179db0
Empty-Engineering/Module-4-project
/PRC0008.py
3,077
3.640625
4
import csv def GET_ROW_COUNT() -> int: with open('battle_royale.csv', 'r') as source: battleRoyaleData = csv.reader(source, delimiter=',') row_count = sum(1 for row in battleRoyaleData) return row_count def DISPLAY_PLAYERS() -> None: data = [] with open('battle_royale.csv', 'r') ...
61ce88ac3c84ed9898f39296d333c55b14b1085a
Onososen/CODE-LIKE-GEEK-TUTOR
/Area of a triangle.py
189
4.125
4
#PROGRAM TO CALCLULATE AREA OF A Triangle b = float(input("What is the base:\n")) h = float(input("What is the height:\n")) area = (b * h)/ 2 answer = round(area,2) print(answer)
f1bcc04ea2273151fa67a14d9ba1445bd60d93f9
aedades/adventofcode-2020
/1.py
945
3.734375
4
#!/usr/bin/python3 # Find two entries that sum to 2020 & multiply those two numbers d = dict() f = open('day1-input.txt', 'r') for line in f.readlines(): num = int(line.strip()) if num not in d.keys(): d[2020 - num] = None else: result = num * (2020 - num) break print(f'part 1: {...
4ede5330af241d138407327dfe7dd016d39f8405
tanvir0ahmmed/Programming
/LeetCode/isPalindrome.py
523
3.53125
4
class Solution(object): def isPalindrome(self, s): st = "" for i in range(len(s)): if (s[i] >='a' and s[i]<='z') or (s[i] >='A' and s[i]<='Z') or ((s[i] >='0' and s[i]<='9')): st += s[i] n = len(st) print(st) a = "" for i in range(...
ce0751389f1915bbcfe6dea8b9401d6fb03eb569
HacksDev/PythonHW
/List/hw8.py
373
3.84375
4
def userInput(): inp = input("Введите число: \n"); if (inp.lower() == 'cancel'): return "Bye!" try: value = int(inp) except: print("Не удалось преобразовать введенный текст в число.") return userInput() return int(value / 2) if (value % 2 == 0) else value * 3 + 1 print(userInput())
9b845b4ef31481f7a2b932bbd0a8a2a3ea21b9f5
patialashahi31/CDAC-Python
/23rd jan 2020.py
1,775
3.953125
4
class Student: def __init__(self,name,n,s=[],t=0,avgs=0): self.name = name self.n = n self.s= s self.t=t self.avgs=avgs def setscores(self,s): self.s = s def getscores(self): return self.s def settotal(self,t): sel...
dc2d2b93e9bb05612fd9a90023f8f9d8d83e2edf
varunmuriyanat/competitive_programming
/selection_sort.py
598
3.78125
4
def selection_sort(arr): starting_index = 0 while starting_index < len(arr)-1: low_value = arr[starting_index] low_index = starting_index for i in range(starting_index, len(arr)): if arr[i] < low_value: low_value = arr[i] low_index = i ...
a37c3ece9bb807fe5acacef8a872964b4bf9acbd
varunmuriyanat/competitive_programming
/insertion_sort.py
489
4.09375
4
def insertion_sort(arr): for i in range(1, len(arr)): counter = 1 temp_value = arr[i] while((i - counter) >= 0) and (arr[i - counter] > temp_value): arr[(i - counter) + 1] = arr[i - counter] arr[(i - counter)] = temp_value print("i:{} counter:{} i-counte...
5e253373091e6cda6fabd5bfddeefdf3c7abb225
beckermath/ScrambleSquaresSolver
/src/two_sided_puzzle2x2.py
4,048
3.6875
4
from random import shuffle from graph_display import build_solution_graph_two_sided import random PIECES = [ 'BCDd', 'CDbB', 'Bdba', 'CAcb' ] BOTTOM, LEFT, TOP, RIGHT = 0, 1, 2, 3 SQUARE_LINKS = ( ((RIGHT, 1, LEFT), (BOTTOM, 2, TOP)), ((LEFT, 0, RIGHT), (BOTTOM, 3, TOP)), ((TOP, 0, BOTTOM), (RIGH...
378bd28374239cb315b0a3c0af202b417cefd2b7
kuldeepc08/PythonPrograms
/count.py
251
3.921875
4
''' accept a list from user and an element whose presence in the list is tobe counted''' count=0 x=input("enter the number") l2 = input("enter the list element") for y in l2: #l2.count(x) if y==x: count+=1 print count
0a04bf5f56a35b2747d6679d329603d02acd65f2
kuldeepc08/PythonPrograms
/ratingusingfuntion.py
659
3.90625
4
'''Write a program to calculate rating where 5 is Exceptional, 4 is Excellent, 3 is Very good, 2 is good and 1 is Poor.''' def CalculateRating(rating): if rating==1 and rating>0: print("Your rating is %d" %rating) if rating==2 and rating>1: print("Your rating is %d" %rating) if rating==3 and rat...
1c63f8a54abcfe9be80d2725ecdb73078fce7791
kuldeepc08/PythonPrograms
/countLine.py
526
3.90625
4
"""Write a program to count number of lines, number of words and number of character in the given file.""" def Counts(): infile = open("count.txt", 'r') lines = 0 words = 0 characters = 0 for line in infile: wordslist = line.split() lines = lines + 1 words = words ...
aa062e5f9aea4518f18bdb21885359a3835e7f91
kuldeepc08/PythonPrograms
/pattern1.py
462
3.640625
4
'''wap to accpet number of rows from user print A B A B C B A B C ''' def Pattern(n): for i in range(0,n): char = 65 for j in range(0,n-i-1): print '\t' for j in range(0,i+1): ch=chr(char) print(ch), char += 1 n=n+1 print'...
f0efb4420fc64de14a50e2ad08c873ba103fcc11
kuldeepc08/PythonPrograms
/palindrome.py
451
4.25
4
'''Palindrome number''' def Reverse(num): rem=0 while num!=0: rem=num%10+rem*10 num= int(num//10) return rem def main(): num=input("Enter the number") num1=Reverse(num) print("Reverse number is %d" %num1) if (num1==num): ...
4719c9d94b43e37e25802ebdb2f92a8eaeb735a8
sudheer-sanagala/intro-python-coursera
/WK-03-Loops/while_loops.py
2,178
4.3125
4
# while loops x = 0 while x < 5: print("Not there yet, x =" + str(x)) x = x + 1 print("x = "+str(x)) #current = 1 def count_down(start_number): current = start_number while (current > 0): print(current) current -= 1 #current = current -1 print("Zero!") count_down(3) """ Print prime numbers A...
2a166bd5d5d6a48c7c93e7f31011d3fb7b08faca
megamer07/MachineLearning
/Algorithms/multiple_regression.py
1,925
3.84375
4
#data preprocessing #import libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd #importing dataset dataset=pd.read_csv("50_Startups.csv") #f5 to set directory X=dataset.iloc[:,:-1].values y=dataset.iloc[:,4].values #encoding categorical data from sklearn.preprocessing import LabelEnco...
86342c8481330d2c06bbc580c3762aaa3194819e
KlaraOppenheimerSchule/Grundlagen-Programmierung_Python
/01_Einfuehrung_OOP/01_Einfuehrung/TypingClassReference2.py
945
3.921875
4
from typing import Type class Animal: def __init__(self, name: str): self._name = name def getName(self) -> str: return self._name class Cat(Animal): def __init__(self, name: str): super().__init__(name) class Dog(Animal): def __init__(self, name: str): super(...
02b58d7f809569392994a9cfd3821b5f40dd7ea1
KlaraOppenheimerSchule/Grundlagen-Programmierung_Python
/02_Vertiefungen_OOP/03_Vererbung/gewaesseraufgabe.py
2,861
3.5
4
import abc class Gewässer(metaclass=abc.ABCMeta): def __init__(self, name, schiffbarkeit, schadstoffbelastung): self.name = name self.schiffbarkeit = schiffbarkeit self.schadstoffbelastung = schadstoffbelastung def getName(self): return self.name def setName(se...
47eb5408dff8aa4adc8c1b2b9fec3f79e1b203e5
KlaraOppenheimerSchule/Grundlagen-Programmierung_Python
/01_Einfuehrung_OOP/03_Programmverzweigungen/Uebung_Schaltjahr_JR/main.py
458
3.96875
4
from Year import * def main(): print("Wilkommen beim Schaltjahrprogramm") print("___________________________________________") print("Bitte geben sie eine Jahreszahl ein!") inputYear = input("Eingabe: ") bool = Year.isSchaltjahr(inputYear) if bool: txt = "Das Jahr " + inputYear + " i...
bee9fe245eb5c1fde2c27cb99b547d861c90937b
Shankhesh-16/Tic-Tac-Toe
/main.py
3,695
3.9375
4
board = ["-", "-", "-", "-", "-", "-", "-", "-", "-"] def displayBoard(): print("\n") print(board[0] + " | " + board[1] + " | " + board[2] + " 1 | 2 | 3") print(board[3] + " | " + board[4] + " | " + board[5] + " 4 | 5 | 6") print(board[6] + " | " + board[7] + " | " + boa...
60529835a7e7e0761822d80b16cd67ab0426e571
Robbot/ibPython
/src/Tkinter/widgets.py
389
4.09375
4
''' Created on 13 kwi 2018 @author: Roju ''' from tkinter import * from tkinter import ttk root = Tk() button = ttk.Button(root,text="Click me!") button.pack() button['text'] = 'Press me' #first method of change text on button button.config(text='Push me') # second method of change text on button t...
dd0c19ae77a22d440a86212bb03966d240c56b91
Robbot/ibPython
/src/IbYL/Classes/Polymorphism.py
1,050
4.1875
4
''' Created on 16 Apr 2018 @author: Robert ''' class network: def cable(self): print('I am the cable') def router(self): print('I am the router') def switch(self): print('I am the switch') def wifi(self): print('I am wireless router, cable does not matter') class tokenRing(network): de...
17ffab11530b73bac49d1340f8d1f431baec581c
Robbot/ibPython
/src/IbYL/BasicYL/Ib_sorting.py
128
3.625
4
grocery=['bread','cheese','milk','eggs','corn','juice'] newlist=sorted(grocery, key=lambda x: x, reverse=True) print (newlist)
8642a27588648f98c8ae04b5a1304755905e01fd
keppen/Recursion
/3-var.py
315
3.953125
4
def foo(number): n1 = 0 n2 = 1 print (n1, n2, end = ' ') for i in range (number - 2): n3 = n1 + n2 print (n3, end = ' ') n1 = n2 n2 = n3 return n1 + n2 print (foo(6)) ''' the idea is to pass the value of an item to next one, there n3 is kind of temporary '''
31cf8ed94dc93a4c1b29866c17b28e00cd6122c1
rlzayas/Projects
/Minesweeper.py
9,604
4.28125
4
"""Program intended to be ran inside of a python 3 programing environment""" """Program prompts user to enter certain data to create a Minesweeper map""" import sys import time class MinesweeperMap: def __init__(self, row=0, column=0, num_of_mines=0, mine_locations=None): if mine_locations is None: ...
dad9389eba76f14c61702d3ce42fe5ceb8e2acee
Nicole00/Algorithm
/HeapSort.py
2,813
3.796875
4
#coding=utf-8 # @author Nicole #下移节点。 我写的这个比较左右孩子的方法太幼稚了==== def sift_down1(a,cur_pos,length): #确定当前节点cur_pos的左右孩子的下标 left = cur_pos * 2 + 1 right = cur_pos * 2 + 2 temp= a[cur_pos] #当前位置为叶节点时停止下移 if left >= length and right >= length: return #当前节点只有左孩子且比左孩子小时,交换 elif left <...
293bea30ad63ec783386cce62bb6418e5bf91b81
Nicole00/Algorithm
/RotateArraySearch.py
988
3.515625
4
#coding=utf-8 # @author Nicole #问题描述:在旋转数组中查找最小元素,时间复杂度小于O(n) #根据给定的长度进行旋转数组 def rotateArray(a,k): if len(a) < k or k < 0: print "invalid position" return if len(a) == k or k == 0: return a temp = [] for i in range(k): temp.append(a[i]) for j in range(len(a) - k): ...
2bc54314536f4eed299c59432d5bcb7840b63e70
LaMemeBete/TP-INFORMATIQUE
/perimetre.py
1,134
3.578125
4
def perimetre(largeur, longueur): """int*int->int hypothese : (largeur>=0) and (longueur>=0) hypothese : longueur >= largeur retourne le perimetre du rectangle defini par sa largeur et sa l omgu eur.""" return 2*(largeur + longueur) #jeu de test assert perimetre(2, 5) == 14 def surface(largeur...
dd6a5c21c70e78b2f81b52687212708707ba9c30
itsayellow/tictoc
/tictoc.py
1,437
3.984375
4
import time import datetime class Timer: def __init__(self): self.start_time = time.time() def start(self): """Start this timer.""" self.start_time = time.time() def eltime(self): """Return number of seconds since start() Returns: float: number of sec...
31ecf545c28c04345d259715a728c9d0a853a809
ggeo/Deep_Learning
/Perceptron/Perceptron.py
4,137
4.15625
4
import numpy as np import matplotlib.pyplot as plt import seaborn as sns sns.set() class Perceptron(): """ The Perceptron classifier. Parameters ---------- nb_iterations : int Number of passes over the training dataset. eta : float Learning rate 0 < eta < 1. ...
6b62302221a020391f104d247d553d41b2790e93
rachelwarren/CPE_Covid_Model
/model/build_models.py
6,130
3.515625
4
import numpy as np import pandas as pd """ Parse groups size DataFrame into the initial values required for the model Params ------ groupsize_df: DataFrame Includes columns for 'Population_Size', 'Recovery_Rate', 'Initial_Infection_Rate' for each of the groups. return ------- gn: array with the group names ...
7999ace79084e36c7190d8a1bd42eca5daad30f6
leon-sleepinglion/daily-interview-pro
/014 Number of Ways to Climb Stairs/main.py
413
4.15625
4
''' If we look at the solution as a function f(n) where n = number of steps f(1) = 1 f(2) = 2 f(3) = 3 f(4) = 5 f(5) = 8 f(6) = 13 This is in fact a fibonacci sequence! Hence the solution can be implemented as a function that calculates the (n+2)th fibonacci number ''' def staircase(n): x = [0,1] for i in range(n):...
ba1dfddb9d47e0b5bbd23736d959c8c3e45e6aaa
leon-sleepinglion/daily-interview-pro
/004 Validate Balanced Parentheses/main.py
664
3.96875
4
class Solution: def isValid(self, s): stack = [] opening_bracket = ['(', '[', '{'] for char in s: if char in opening_bracket: stack.append(char) elif char == ')' and stack.pop() != '(': return False elif char == ']' and stack.pop() != '[': retur...
a0b195fdd98b23bf8c36436c985da4216cf94199
orif981/Hangman
/Hangman.py
1,601
3.9375
4
import random stages = [''' +---+ | | O | /|\ | / \ | | ========= ''', ''' +---+ | | O | /|\ | / | | ========= ''', ''' +---+ | | O | /|\ | | | ========= ''', ''' +---+ | | O | /| | | | =========''', ''' +---+ | | O | ...
03a6b23b9c0112ff7908508199eb635bc61f1149
rolikag07/Python
/calculator.py
559
4.09375
4
print("Let's Calculate") print("1.Addition") print("2.Substraction") print("3.Multiplication") print("4.Division") ca = int(input('enter operation to perform (1-4): ')) num1 = float(input('enter first number: ')) print(num1) num2 = float(input('enter second number: ')) print(num2) if ca==1: sum=num1+num2 print(...
a6caf00314d0053d316992df1caefd32bd217f65
BREN0-MORAIS/Python
/EXERCICIOS/EX10.py
89
3.578125
4
cel = float(input("Celsius: ")) fah = float(cel*1.8 + 32) print("Fahrenheit: "+str(fah))
d69787aaae029b32f3ece3b82eedda0a9fd11068
tyrosine1153/Practice_Python
/3/stdiooo.py
1,530
3.859375
4
print("Python", "Java") print("Python", "Java", sep=",") # 변수 사이의 문자열을 sep 으로 지정할 수 있음 print("Python", "Java", end="?\n") # 문장의 끝부분에 올 문자열을 지정할 수 있음 import sys print("Python", "Java", file=sys.stdout) # 표준출력 print("python", "Java", file=sys.stderr) # 표준에러. 에러로 표시됨 score = {"수학": 0, "영어": 50, "국어": 100} for subjec...
25cac529202eda7c87d0c5671e50bbfe2b17681f
tyrosine1153/Practice_Python
/school_smrvacation_2020/calculator.py
318
3.765625
4
def plus(num1, num2): return num1 + num2 def minus(num1, num2): return num1, num2 def multi(num1, num2): return num1 * num2 def divide(num1, num2): return num1 / num2 if __name__ == "__main__": print("모듈 파일에서 실행") else: print("다른 파일에서 임포트되어 실행")
99baf46f2c32aca6ee1f563a71cf330be623e539
tyrosine1153/Practice_Python
/1/strring3.py
698
4.0625
4
python = "Python is Amazing" print(python.lower()) # 소문자 print(python.upper()) # 대문자 print(python[0].isupper()) # 대문자 확인 print(len(python)) # 글자 수 (공백포함) print(python.replace("Python", "CLang")) # 첫번째 문자열이 있는 위치를 찾아 두번째 문자열로 바꿈 index = python.index("n") print(index) # n 이 있는 첫번째 위치 index = python.index("n", ind...
103f80c7de5c465f706f0fa732758ef9053f1837
saraeldeeb9/Explore-bikeshare-us-data-
/bikeshare.py
7,243
4.09375
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: #!/usr/bin/env python # coding: utf-8 # In[ ]: import time import pandas as pd import numpy as np CITY_DATA = { 'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv' } def get_filters(): """ ...
62f26ce1d39be95da070bdd3413d65bda25f2885
JunKiBeom/codeup.kr
/1288_7365757(AC).py
188
3.65625
4
def fact(n): if n == 1: return 1 return n * fact(n - 1) n,r=input().split() n,r=int(n),int(r) if (n==r): print(1) else: print(int(fact(n)/(fact(n-r)*fact(r))))
7ff60a0db85290c24e0a57de8189511ecb046e03
JunKiBeom/codeup.kr
/1451_7096102(AC).py
110
3.59375
4
n=input() a=[] for i in range(int(n)): a.append(int(input())) a.sort() for i in a: print(i)
d5d450b527d4d79ccd3ad9bee7711d5358382911
JunKiBeom/codeup.kr
/1274_7119823(AC).py
153
3.90625
4
num=int(input()) cnt=0 for i in range(1, num+1): if num%i==0: cnt+=1 if cnt==2: print("prime") else: print("not prime")
8792cfb9e7b5dba704334fa0201a821e129b9a7b
JunKiBeom/codeup.kr
/6022_17169793(AC).py
77
3.5625
4
a=input() for i in range(0,len(a)//2): print(a[i*2:i*2+2],end=" ")
a243426aeba8889a612bd2617023aca1a060b37a
HeftyB/cs-module-project-hash-tables
/applications/markov/markov.py
555
3.53125
4
import random import os paths = os.path.join(os.getcwd(), "applications", "markov", "input.txt") # Read in all the words in one go with open(paths) as f: words = f.read() # TODO: analyze which words can follow other words # Your code here print("words") print(words) split = words.split(" ") dict = {} for index,...
fd70e94d9c5528f66eae9dd03995260d211cc915
Jaewon0702/Python_for_Beginner_Turtle
/인스턴스_변수와_클래스_변수.py
549
3.984375
4
class Car: color="" speed=0 count=0 def __init__(self): self.speed=0 # speed를 instance variable로 -> 설계도 Car.count+=1 # count를 Class variable로 -> 자동차 샘플을 만들음, 저장공간 공유 myCar1=Car() myCar1.speed=30 print("자동차 1의 현재 속도는 %dkm, 생산된 자동차는 총 %d대 입니다."%(myCar1.speed,Car.count)) myCar...
f02f6371b083f59a9a1c5f7e1a7ccfc235bdef65
Jaewon0702/Python_for_Beginner_Turtle
/임의의 위치에 글자를 쓰는 거북이.py
734
3.515625
4
import turtle import random from tkinter.simpledialog import * instr='' swidth,sheight=300,300 tx,ty,txtsize=[0]*3 turtle.title('임의의 위치에 글자를 쓰는 거북이') turtle.shape('turtle') turtle.setup(width=swidth+50,height=sheight+50) turtle.screensize(swidth,sheight) turtle.penup() instr=askstring('문자열 입력','거북이로 쓸 ...