blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
8ff0c72d13d626ba00613fe7d77857aec40282d8
dar-kin/tic-tac-toe
/Problems/mixedCase/task.py
114
3.625
4
a = input().split() a[0] = a[0].lower() for i in range(1, len(a)): a[i] = a[i].capitalize() print("".join(a))
1497df0b1672dffdfa150ea8a0c7501144fd9e48
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/kindergarten-garden/73ba8823b1ed49a8a9ceeb7f447d29b6.py
658
3.796875
4
#/usr/bin/env python class Garden: plantdict = {'V':'Violets', 'R':'Radishes', 'C':'Clover', 'G':'Grass'} def __init__(self,gard,students = ['Alice','Bob','Charlie','David','Eve','Fred','Ginny','Harriet','Ileana','Joseph','Kincaid','Larry']): self.gard = gard.splitlines() self.students = sorted(students) def pla...
cf3c14159da20086511573f6252650de76d56e89
DevanshiPatel12/PythonAssignmentCA2020
/Weekend_Activity_On_Data_Structures/Qn-11.py
381
4.1875
4
# Write a program to find out the occurrence of a specific word from an alphanumeric statement. # Example: 12abcbacbaba344ab # Output: a=5 b=5 c=2 make sure you should avoid the numbers in you logic s = '12abcbacbaba344ab' dict = {} for char in s: if char.isalpha(): if char not in dict: dict[ch...
7b3f75bfc09059b25ac84000e67a809ffd66243c
BingzheJiang/pachong
/pa13.py
502
3.5
4
#协程操作模板 import asyncio import time async def dowload(url): print("开始抓取") await asyncio.sleep(3)#模拟发送请求 print("下载结束",url) async def main(): urls=[ "http://www.baidu.com", "http://www.hhh.com" ] tasks=[dowload(url) for url in urls] done,pedding=await asyncio.wait(tasks) f...
39c6c0d2193440894dceca5803cd2e8106775fa1
avnemykin/11-klass
/fiz_model.py
3,178
3.515625
4
from math import * from tkinter import * v_0=40 a = 30 s = 60 H = 2 g = 9.8 root = Tk() root.geometry("500x500") canv_h = 300 canv_w = 450 canv = Canvas(root, width = canv_w+10, height = canv_h+10, bg = "white") #Создадим холст canv.create_line(10,canv_h,canv_w,canv_h,width=2, fill='green',arrow=LAST) ...
4e0104f8cb0e0178bcb0b355428754ed1d6cfac4
kn285-zz/StatisticsCalculator
/Tests/test_calculator.py
1,105
3.78125
4
import unittest from Calculator.Calculator import Calculator class MyTestCase(unittest.TestCase): def setUp(self): self.calculator = Calculator() def test_instantiate_calculator(self): self.assertIsInstance(self.calculator, Calculator) def test_calculator_return_sum(self): resu...
22d5ad576cdca3a63c6c4faddad19c6b07d1d448
Yobmod/dmltests
/bf/brainfuck.py
2,329
3.921875
4
# from typing import Optional def bf(src: str, data: str="", left: int=0, right: int=0, idx: int=0, strict: bool=True) -> str: """ brainfuck interpreter src: source string, left: start index, right: ending index data: input data string, idx: start-index of input data string """ if left < 0 or left >= le...
37a88cf0b687dfff2570bc8a3571759a038eb4ec
vlad-zankevich/LearningPython
/person.py
380
3.640625
4
def run(): def build_person(first_name, last_name, age=''): """Return dictionary with information about person.""" person = {'first': first_name, 'last': last_name} if age: person['age'] = age return person builded_person = build_person('jimi', 'hendrix', 27) pr...
e2da5a390fdb4be6ae31cb1c43b32fe2f8fc3b50
SushmitaSingh96/Codility_problems_my_solutions
/odd_occurrences_in_array.py
323
3.5625
4
def solution(A): # if only one item exists in the list if len(A)==1: return A[0] A = sorted(A) for i in range(0,len(A),2): #if the odd number is the last item of the list if i == len(A)-1: return A[i] if A[i] != A[i+1]: return A[i] p...
eb2a26df7a7e6dce33f3ba7aa3904331f4309e75
pramod-Paratabadi/InfyTQ-Course-Solutions-and-References
/DSA in Python/Day-5/Assignment-21.py
6,911
3.921875
4
#DSA-Assgn-21 class Queue: def __init__(self,max_size): self.__max_size=max_size self.__elements=[None]*self.__max_size self.__rear=-1 self.__front=0 def is_full(self): if(self.__rear==self.__max_size-1): return True return False def is_empt...
132c94442a600a707e032fd234443f6fdb4edd03
hastagAB/Awesome-Python-Scripts
/Remove-Duplicate-Files/removeDuplicateFiles.py
2,012
3.84375
4
import os import hashlib # function to compute SHA-1 hash of a file def computeFileHash(fileName): genHash = hashlib.sha1() with open(fileName, 'rb') as file: block = 0 while block!=b'': block = file.read(1024) genHash.update(block) file.close() return genHash.he...
254a194dcc910f65bef629310c1fc298ca1d0093
OmarMontero/150-challenges-for-python
/ninety-two.py
471
3.890625
4
from array import * import random def main(): array_given = array ("i", []) array_user = array ("i", []) for i in range(5): array_given.append(random.randint(0, 100)) for i in range(3): array_user.append(int(input("Type in a number: "))) array_given.extend(array_user) ...
ec1403841ca262113547898e351c7a78323baec7
JohannesHeidecke/UPC-MAI-INLP
/Assignment 1/code/zipfs_functions.py
5,892
3.625
4
''' These are the functions used by zipfs.py UPC MAI INLP 2016/2017 Assignment 1 - Zipf's Law ''' import matplotlib.pyplot as plt import matplotlib.patches as patches import matplotlib.path as path from nltk.stem.porter import PorterStemmer from nltk.tokenize import WordPunctTokenizer import numpy as np from operator...
85879af87d6d9b1f478f7bb44d57f2ea2025a49d
NagahShinawy/100-days-of-code
/day_4/6_treasure_map.py
362
3.984375
4
row1 = ["😊", "😊", "😊"] row2 = ["😊", "😊", "😊"] row3 = ["😊", "😊", "😊"] _map = [row1, row2, row3] print(f"\t1\t\t2\t\t3") print(f"1 {row1}\n2 {row2}\n3 {row3}\n") position = input("Enter Position Row Col") row = int(position[0]) - 1 col = int(position[1]) - 1 print(row, col) treasure = "Gold" _map[row][col] ...
6b81f32e75e15e1fe29a8a373c47b5c7128feb61
lacerda92/exercicios-python
/ex009 tabuada.py
1,729
4.3125
4
#faça um programa que leia um número INTEIRO qualquer e mostra na tela a sua tabuada. print('Olá, eu consigo calcular a tabuada de QUALQUER número, você consegue acreditar nisso?') """numero = int(input('Digite um número: ')) x1 = numero*1 x2 = numero*2 x3 = numero*3 x4 = numero*4 x5 = numero*5 x6 = numero*6 x...
7934473cc158b2af3ff02cb6fc58f38d359f3669
ckidckidckid/leetcode
/LeetCodeSolutions/73.set-matrix-zeroes.python3.py
1,961
3.796875
4
# # [73] Set Matrix Zeroes # # https://leetcode.com/problems/set-matrix-zeroes/description/ # # algorithms # Medium (36.66%) # Total Accepted: 140.7K # Total Submissions: 383.6K # Testcase Example: '[[1,1,1],[1,0,1],[1,1,1]]' # # Given a m x n matrix, if an element is 0, set its entire row and column to 0. # Do it ...
0e4a2a6373c6832d957f3e3fc082b86f714053b8
liuchenghao2000/1807
/1807-2/11day/06-闭包.py
89
3.59375
4
def show(num): def inner(a,b): return a+b+num return inner a = show(1) print(a(1,2))
2c766b6c524b6c092ad1ed590ac91ed91c8136ec
BibekKoirala/DataStructures
/Topological_Sort_problem_DFS.py
4,067
3.5
4
import numpy as np # Graph must be directed acyclic graph # Graph is represented as Edge list. Here Edges = np.array([('A', 'D'), ('B', 'D'), ('C', 'A'), ('C', 'B'), ('D', 'G'), ('D', 'H'), ('E', 'A'), ('E', 'D'), ('E', 'F'), ('F', 'K'), ('F', 'J'), ('G', 'I'), ('H', 'I'), ('H', 'J'...
10d655f915640a815aa6d8c0582486429e8332bc
songeuna/python
/MLB/Pandas/Pandas_slice.py
493
3.890625
4
from pandas import Series ''' house_price = Series([10, 20, 30, 40, 50]) print(house_price) print(house_price[2]) ''' house_price = Series([10, 20, 30, 40, 50], index = ['강원', '인천', '전라', '제주', '서울']) ''' print(house_price) print(house_price['제주']) print("index : ", house_price.index) print("va...
22a744eed01f22f5d1468a0bb9c2b1a4957d5d74
kumar-roheit/Algorithm_practice
/Roman_Integer.py
867
3.640625
4
class Solution: def romanToInt(self, s: str) -> int: dictionary for conversion conversion = { "I" : 1, "V" : 5, "X" : 10, "L" : 50, "C" : 100, "D" : 500, "M" : 1000 } num = 0 # 1. I + V will ...
905faef78ccb25de6f92b88d5ae225967b67d22e
maheshbaviskar/Seagull_backup
/python/temp_sorted.py
362
3.703125
4
guest=['mahesh','vaibhav','mohit'] for i in guest: print("Good Evening: "+i.title()+" Welcome") print("*"*50) print(sorted(guest)) print("Non sorted") print(guest) guest.insert(0,'anand') print(guest) guest.insert(0,'znand') print(guest) guest.sort() guest.reverse() print(guest) print("*"*40+'\n Revesing the or...
b769e17923bb7c47071009308324948a2e593184
a8ksh4/junk
/Python/examples/EXAMPLES/db_sqlite_fetchiter.py
570
3.5625
4
#!/usr/bin/env python import sqlite3 def fetch_iter(cursor,chunk_size): """ Fetch chunk_size records, but parcel them out one at a time """ while True: rows = cursor.fetchmany(chunk_size) if not rows: # no more recs break for row in rows: yield row with sqlite3...
8f34ff984a9377376af95836a9c032b6e955aac4
aadiupadhyay/CodeForces
/codeforces/59/A.py
179
3.625
4
a="abcdefghijklmnopqrstuvwxyz" b=a.upper() s=input() c,d=0,0 for i in s: if i in a: c+=1 else: d+=1 if d>c: print(s.upper()) else: print(s.lower())
193c81fdc631ca31fe03d6bc34d9a5abf49819ac
takamuio/DesafiosAulaYoutube
/venv/teste70.py
837
3.609375
4
total = menor = contador = contador_mil = 0 nome_menor = '' print('=-'*10) print('=== Mercado do Zé ===') print('=-'*10) while True: nome = str(input('Nome do produto: ')) preco = float(input('Preco do produto: ')) total += preco contador += 1 if contador == 1: menor = preco if preco < m...
ae5e830c304db01a5f36168d7c0178a38655a0b1
DarrenChiang/Python-2016
/Word Generator/WordGenerator.py
2,483
3.765625
4
def readText(filename) : file = open(filename, "r") text = file.read().lower() textList = text.split() return textList def findWord(string, textList) : #generates a list that contains all the positions (elements of all matching words) stay = False for i in textList : if string == i : ...
1d783d392e94653ddd861cc40f796c2b1fe4999c
WillieShubert/DojoAssignments
/Python/Python_OOP/animal/animal.py
1,211
4
4
class Animal(object): def __init__(self, name): print 'New Animal!!!' self.name = name self.health = 100 # define methods def displayHealth(self): # pass self into all methods to access attributes print str(self.name) print "Health: "+str(self.health) def walk(self): ...
5930ab01cb9c7110234c3b797569cd9edc089859
GutembergPraia/Curso-Introducao-a-Ciencia-da-Computacao-com-Python-USR
/Parte - 02/Lista de exercicios - 1/dimensoes_matriz.py
534
4.34375
4
''' Exercício 1: Tamanho da matriz Escreva uma função dimensoes(matriz) que recebe uma matriz como parâmetro e imprime as dimensões da matriz recebida, no formato iXj. Exemplos: minha_matriz = [[1], [2], [3]] dimensoes(minha_matriz) 3X1 minha_matriz = [[1, 2, 3], [4, 5, 6]] dimensoes(min...
92e5fdaba1fe666406f75dabbdea8e3ceeb6654d
apranav19/pystructures
/tests/test_linked_list.py
1,902
3.734375
4
from builtins import range from unittest import TestCase from pystructures.linked_lists import LinkedList, Node, DoublyLinkedList class TestNode(TestCase): def test_value(self): """ A simple test to check the Node's value """ node = Node(10) self.assertEqual(10, node.value) def test_i...
48210f202bb251cab8ac6a7d965440dde44d18f4
hpcll/test
/leaplear3.py
864
4.0625
4
months = (0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334) months1 = (0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335) def is_leapyear(): year = int(input("请输入年份:")) month = int(input("请输入月份:")) day = int(input("请输入日子:")) if (year <= 0) | (1 > month | month > 12) | (1 > day | day > 31): ...
19988007bcab31832e0d4d99eb6142cbe32c0081
vashiig/Air-India-project--Data-Handling-Using-Python
/prog1.py
9,666
3.671875
4
# this program is to clean the data import pandas as pd import csv Name_of_file = input("Enter the name of file you want to clean ", ) # this program is for single na data only d = 0 file = open(Name_of_file + ".csv", "r") file1 = open(Name_of_file + "_na_data_single.csv", 'w') my_list = list(csv.reader(file)) c2 = c...
d8e28fd1421198c280643aab7cbb154be09708e5
alissonoliveiramartins/programacao-orientada-a-objetos
/listas/lista-de-exercicio-03/questao-12.py
1,040
4.0625
4
valor_por_hora = float(input('Valor por hora: ')) quantidade_de_hora = float(input('Quantidade de horas: ')) valor_ir= int(0) salario = valor_por_hora * quantidade_de_hora print('Salário Bruto ({} * {}) : R$ {:.2f}'.format(quantidade_de_hora,valor_por_hora,salario)) if salario <= 900: print('IR Isento') elif 9...
c9d1b40dda60ca991be043b9b29516f68d97fc50
Anu-01-rb/test-logic
/num.py
411
3.75
4
def main(): try: num = int(input("Enter your Line Number : ")) init = 1 time = init for i in range(1,num+1): tmp = init for j in range(i): print(tmp,end=' ') tmp += 2 print() time += 2 init...
f8cfa8cc7ded03c41166b1cb2925ccf95d14c295
ryandavis3/leetcode
/longest_palindrome/longest_palindrome.py
772
3.796875
4
from collections import Counter def longestPalindrome(s: str) -> str: """ Find longest palindrome in string. Args: s (str) Returns: str """ ct = Counter(s) even = 0 odd = 0 max_odd = 0 # Iterate over items for _, count in ct.items(): # If even, add t...
8fdd132c3ab7dea17e1ce7ac760e989992479b7f
elaginaekaterina/python
/Функции. Словари. Файлы. Модули/Модули, подключение модулей.py
3,315
3.953125
4
''' Напишите программу, которая подключает модуль math и, используя значение числа pi из этого модуля, находит для переданного ей на стандартный ввод радиуса круга периметр этого круга и выводит его на стандартный вывод. ''' import math r = float(input()) p = math.pi*r*2 print(p) ''' Напишите программу, ко...
b26117f583fde281d27b209bd6c575588bb6d1c0
guozhi666/python
/example/example.py
164
3.609375
4
# -*- coding:utf-8 -*- #题目:输出9*9乘法口诀 for i in range(1, 10): print for j in range (1, i + 1): print "%d * %d = %d" %(i, j, i*j),
d6f3e3450f9cc5d3bb1ff6b9fe6685d22aa56066
Ramshiv7/Python-Codes
/Multiply_within_list.py
209
4.15625
4
#Write a Python function to multiply all the numbers in a list. def multiply(numbers): out = 1 for i in numbers: out = out * i print(out) multiply([1,2,3,-4]) multiply([2,3,4,5,6,7,8])
1de3a1e5d7584f80a3dd5a6f78d5ba7ccf52cdf4
Bhavan24/Python_test
/Q3B.py
933
3.609375
4
import random from time import perf_counter start = perf_counter() total_question = 0 correct_questions = 0 num1_list = [] num2_list = [] status_list = [] while total_question < 10: num1 = random.randint(1,50) num2 = random.randint(1,50) if num1 >= num2: usr = int(input(f"What is {num1} - {n...
a179605fbadfd2da1dc6313ae824817bff785c96
candi955/doublyLinkedList
/DoublyLinkedListPage.py
36,159
3.875
4
# Github repository: https://github.com/candi955/doublyLinkedList # This module is being utilized as a set-up and conceptuality page for the doubly-linked list concept. A user can call # the various functions from the class DoublyLinkedList() to implement various doubly-linked list processes. # The output at this tim...
256af5062c6c6c3c6aa65f1f043b64b692bf0bdc
KamarajuKusumanchi/sampleusage
/python/plot_dataframe/plot_y_vs_rownum.py
685
4.4375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ This script shows how to plot a column in a dataframe against its row number. This is useful to visually detect outliers in the data. Created on Sun Jun 4 20:03:02 2017 @author: rajulocal """ """ demonstrates | create a new dataframe with fewer columns, add a seque...
96744ad0c840012573baf16d064227d75d189922
Kabzel55/Codility_Python
/4.3_MissingInteger.py
800
3.78125
4
def solution(A): """ Find the smallest positive integer that does not occur in a given sequence :param A: A non-empty array A of N integers is given :return: returns the smallest positive integer (greater than 0) that does not occur in A. """ A = sort_01(A) if len(A) == 0: return 1 ...
117db1c230e3680bcd4f3d7151b383a2fb435960
Lexkane/ComputerScience
/Tasks_3_Week/Counter.py
402
3.625
4
from collections import Counter import os #encoding="utf-8-sig" def main(): file = open(r"input.txt", "r") wordcount = Counter(file.read().split()) for item in wordcount.items(): print("{}\t{}".format(*item)) with open('answer.txt', 'a') as answer: for word in wordcount.items(): answer.writ...
c79ffe37d79f78686f67c7195a7708e19a726019
marjorie78/march5
/FOR EX 3.py
173
3.921875
4
sentence=input("give me a sentence") number_words=0 for letter in sentence: if letter==" ": number_words=number_words+1 print("there are",number_words+1,"words")
33e9411d2165fd3832f0b9d3ffe9db06a1b65ec2
Deaseyy/algorithm
/HJ/HJ107 求解立方根.py
678
3.953125
4
""" 题目描述 计算一个数字的立方根,不使用库函数。保留一位小数。 输入描述: 待求解参数,为double类型(一个实数) 输出描述: 输入参数的立方根。保留一位小数。 示例1 输入 216 输出 6.0 """ """ 牛顿迭代法:https://blog.csdn.net/sunbobosun56801/article/details/78088085 """ import math def getCubeRoot(num=None): # INPUT number = float(input().strip()) # 初始化一个估计解 t = 5 while abs(t ...
2217a74ffdb5d366676bcc9fc02417c8cafeccc3
gitlearn212/My-Python-Lab
/Python/Functions/Ex_calculae_three_if_value_trice.py
537
4.15625
4
# Calculate the some of three given number # if the given numbers(all 3 number) are same than trice the value def sum_trice(x, y, z): sum = x + y + z if x == y == z: sum = sum * 3 return sum # num = input("enter a numbe: ") # num2 = int(input("enter a numbe: ")) # num3 = int(input("enter a numbe...
df12d34742506517703832fc3ac3d8c42cfd2b37
thonyeh/Numerical-analysis-1
/Sistema lineal/LDLT.py
1,625
3.578125
4
from math import * #Metodo Doolitle: M=[] n=input('ingrese la dimension de la matriz:') for i in range(n): M.append([0]*(n+1)) for i in range(n): print'ingrese los %d elementos de la fila %d:'%(n+1,i+1) for j in range(n+1): M[i][j]=input('') print "matriz:" L = [] D = [] LT = [] DLT = [] for i in ...
f416f1128ae55afd64942fa410b188c1017c0d96
JMRBDev/1DAW
/Sistemas Informáticos/Módulos de Python/Off Topic/palindromo.py
891
3.9375
4
# Detectar si un input es palíndromo import sys import string import unicodedata if len(sys.argv) > 1: myinput = sys.argv[1] myinput_lower = myinput.lower() isTrue = True mystring = myinput_lower.replace(" ", "") mystring_normalized = unicodedata.normalize("NFKD", mystring).encode("as...
1f0fced72a7402e0fcd414f68ce9649b89999db2
wangfmD/pypro
/02_check/02_class/classmethod/fruit.py
898
3.9375
4
# coding=utf-8 # class Fruit(object): # def __init__(self, total=0): # self.__total = total # def set(self, total): # self.__total = total # def print_total(self): # print "total is {}".format(self.__total) # app = Fruit() # app.print_total() # app.set(10) # app.print_total() # class Apple(Fruit): # def set(self, ...
ad553e4760e84862625d497a75c09af3d6a53451
yameenjavaid/University-projects-1
/Collecto Python/final-programming-project-kelvin-collecto/Program/ball.py
482
3.515625
4
from Program.helpers.constants import Constants class Ball: def __init__(self, color): self.color = color self.neighbors = [] self.diameter = Constants.DIAMETER self.position = 0 def set_position(self, position): self.position = position def get_position(self): ...
fe7f89f57fe01afa56c2579ea50c8a80ce32628d
Ivoneideduarte/curso-de-python-3
/Mundo II/02 - Repetições em Python (for)/13 - Estrutura de repetição for/pythonExercicios/ex047.py
236
4
4
# DESAFIO 47: Crie um programa que mostre na tela todos os números pares que estão no intervalo entre 1 e 50. ''' for n in range(1, 51): if n % 2 == 0: print(n, end=' ') ''' for n in range(2, 51, 2): print(n, end=' ')
e96f66658b02f51b760f494a53752886928311a8
sthuck/vertex-cover
/algorithms/reductions/remove_contained.py
662
3.53125
4
from igraph import Graph, Vertex from typing import List, Union, Tuple def remove_vertex_if_contained_neighbors(graph: Graph): to_remove_set = set() v: Vertex for v in graph.vs: u: Vertex for u in v.neighbors(): if u in to_remove_set: # not checking containment of to be remove...
ba9dd1582c3482e08fb9082d7f0680d4a3980f0d
ecwolf/Programming
/Python/anwesha-mohanty_ArmstrongNumber.py
386
4.34375
4
#An Armstrong number is a number whose sum of cube of digits is equal to the same number. #For example 153 is an armstrong number num = int(input("Enter a number\n")) temp = num sum = 0 while(temp > 0): digit = temp % 10 sum += digit ** 3 temp = temp // 10 if sum == num: print("%d is an Armstrong Numbe...
4a8c08cf9fedfed1a48d0a64429bf9f3ef7d426b
McGillAISociety/mais-bootcamp-w2019
/Lecture-3/src/perceptron.py
4,186
3.796875
4
# import numpy as np class Perceptron: """ A perceptron model. >>> p = Perceptron(3, [1,2,3], 4) >>> p.input([0,1,0]) 0 >>> p.input([1,0,1]) 0 >>> p.input([0,1,1]) 1 """ def __init__(self, num_inputs, weights, threshold): if num_inputs != len(weights): raise ...
f79970d9d7f1dd3fa9af29930466a87f7310fe62
CodingTestStudy/WindBag_Repo
/210113/FAIL/1463.py
164
3.71875
4
a = int(input()) count = 0 while a != 1: if a % 3 == 0: a /= 3 elif a % 2 == 0: a /= 2 else: a -= 1 count += 1 print(count)
2516442b5d0cd62e85578c4e7454bcf62cfdf9aa
amyanu-sudo/cummulations
/generators/genexp.py
296
4.1875
4
my_list = [1, 3, 6, 10] #generator expression a = (x**2 for x in my_list) print(next(a)) print(next(a)) print(next(a)) print(next(a)) #Generator expressions can be used as function arguments. When used in such a way, the round parentheses can be dropped. print(sum(x**2 for x in my_list))
e3758d1b6c3d5774d154676f740ad680e2937f58
inwk6312winter2019/week4labsubmissions-navya0511
/lab5/lab5task1.py
193
3.5
4
import string file1 = open("58820-0.txt") for line in file1: line = line.strip() line = line.lower() line = line.split() for word in line: print(word.strip(string.punctuation))
edcb64ff4d5e2baf43c3aaac6236fd46c0d9efcb
xren/algorithms
/4-4.py
550
3.96875
4
# Given a binary tree, design an algorithm which creates linked list of all the # nodes at each depth def getLinkedList(root): result = [] current = getLinkedList() if not root: current.add(root) while current: result.append(current) parents = current currentLinkedList...
ff34733d563079dd833f3566e8db4fcdb274ec02
weydaej/Spelling-Correction-in-Python
/wikification-for-NER.py
1,873
3.578125
4
import sys import http.client import urllib.request, urllib.parse, urllib.error import json from pprint import pprint def get_url( domain, url ) : # Headers are used if you need authentication headers = {} # If you know something might fail - ALWAYS place it in a try ... except try: conn = http.client.HTTP...
9449a072437ebc737145d0df7de7b95092353f01
laxbista/Python-Practice
/String_Excercises/q5.py
322
4.125
4
# Exercise Question 5: Count all lower case, upper case, digits, and special symbols from a given string str1 = "P@#yn26at^&i5ve" digits = 0 char = 0 sym = 0 for i in str1: if i.isalpha(): char += 1 elif i.isnumeric(): digits += 1 else: sym += 1 print(digits, char, sym)...
c428993296a361f9145bc1ea86c21e94e5d23081
Steinsmuga/Skoli
/Forritun 1/Skilaverkefni/Skilaverkefni 3/FORR1FG_ Skilaverkefni3_Liður5_Steinn_Þorkelsson.py
1,589
3.890625
4
#FORR1FG05AU-Hát - Skilaverkefni 3 - Liður 5 - Steinn Þorkelsson print('halló') teljari = 1 val = [1,2,3] while val != '3': print('1. Biður um 10 tölur. Finnur summu þeirra og meðaltal.') print('2. Biður um tölu og athugar hvort talan sé jöfntala eða oddatala ') print('3. Hætta í forritinu og skri...
f6cee0840152551bafae07400f2213d85d52eb66
mmmacedo/python
/Capitulo 1/19 - booleano2.py
269
3.671875
4
# -*- coding: utf-8 -*- if True and True: print ("Bloco 1 será executado") if True and False: print ("Bloco 2 não será executado") if True or False: print ("Bloco 3 será executado") if False or False: print ("Bloco 4 não será executado")
e72e28e8d70e75e85483ce392919a033752ee70b
Mr-cpc/idea_wirkspace
/learnp/basic/bupt_2017_11_07/lca.py
2,272
3.890625
4
class Node(object): def __init__(self,val:int): self.left,self.right = None,None self.val = val def traverse(root:Node, res:list,nd:Node,cur:list): if root is None or len(res) == 1: return elif root is nd: res.append(cur[:]) else: cur.append(root) trav...
4fe5fb8d6ddc4db5f498c558f07c6a0c65a83237
fabiomartinezmerino/python_tests
/tribonacci.py
942
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jul 18 22:26:43 2018 @author: Alicia """ _loaded = False tribcache = {} def load_trib(my_list): global tribcache global _loaded if not _loaded: _loaded = True my_index = 0 for i in my_list: tribcache[m...
7b502ea26ff09dc8bb0187b14be279958feca297
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/anagram/fac92c249dbf4b42a284528b85e46987.py
422
3.765625
4
class Anagram: def __init__(self, word): self._word = word.lower() def match(self, words): return [word for word in words if self.is_anagram(word.lower())] def is_anagram(self, word): w = self._word if w == word: return False for c in word: ...
ccf15225964e995ec0a91f559ebb87a89eed91d9
malleswar0511/Assignments
/number_division.py
307
3.890625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jun 2 07:00:56 2020 @author: mahi """ items = [] num = [x for x in input("enter a binary number").split(',')] for p in num: x = int(p, 2) if not x%5: items.append(p) print("the divisible binary number is ",','.join(items))
ab4e8fb25fd10909583a26b8794e90f8b964ef6a
brslv/code
/python/recursive_primes/recursive_primes.py
496
4.21875
4
# Write a program that prints all prime numbers. Use recursion. import math up_to = int(input("How many primes do you want me to generate?: ")) counter = 1 current = 2 def is_prime(number, i): if i < math.sqrt(number): return True if number % i == 0: return False else: return is_...
99dc628c6f36e3b52c2e6cdb748ce526090f57f4
Katt44/misc_prac
/shopping_list.py
457
4.375
4
#shopping_list #make a list to hold items # print out instructions how to use app #ask for new items #add new items to our list #be able to quit the app #print out list shopping_list = [] print("What should we buy at the store?") print("Enter 'DONE' to stop adding items") while True: new_item = raw_input("> ")...
7f6a427327ba708bb53875abb8954d52121e2161
RFulle/Ally
/ZZPYthon programs/SimpleDice.py
877
3.875
4
# -*- coding: utf-8 -*- """ Created on Thu Apr 4 09:52:47 2019 Ally Dice @author: RFuller """ import random def rolldie1(): sides = [1, 2, 3, 4, 5, 6] num1 = random.choice(sides) return num1 def rolldie2(): num2 = random.randint(1,6) return num2 def rollboth(): ...
0fc9076f7ea003f53e7ca7cab9ffb870b2848d29
kmiya/contest
/LeetCode/116-Populating_Next_Right_Pointers_in_Each_Node.py
502
3.703125
4
# straightforward recursive solution # time: O(#nodes) # space: O(#nodes) class Solution: def connect(self, root: 'Node') -> 'Node': def rec(left: 'Node', right: 'Node'): if not left: return left.next = right rec(left.left, left.right) rec(le...
2d5c39aab5903d4559a4a9d2d64a9ffb600a2ca7
sanraj99/practice_python
/acronym_generator.py
603
4.03125
4
from __future__ import print_function # ---------- PROBLEM : ACRONYM GENERATOR ---------- # You will enter a string and then convert it to an acronym # with uppercase letters like this ''' Convert to Acronym : Random Access Memory RAM ''' # Ask for a string orig_string = raw_input("Convert to Acronym : ") # Convert ...
6b672404040724237c9e55fcbb5ba6be9c995c92
saxena-cs/python_tkinter
/rock_paper_scissor.py
1,800
4.03125
4
import tkinter as tk import random root = tk.Tk() root.geometry("500x600") root.title("Rock Paper Scissor") user_sc = 0 computer_sc = 0 def random_computer_choice(): return random.choice(['stone', 'paper', 'scissor']) def choice_to_number(choice): rps = {'stone': 0, 'paper': 1, 'scissor': 2} return rps[...
1be6f3c383c51aae32c761e008b9adff14dfcf8f
cpe202fall2019/lab0-ZachLofquist
/planets.py
343
3.828125
4
def weight_on_planets(): earthweight = float(input("What do you weigh on earth? ")) marsweight = earthweight * 0.38 jupiterweight = earthweight * 2.34 print("\nOn Mars you would weigh {0} pounds.\nOn Jupiter you would weigh {1} pounds.".format(marsweight, jupiterweight)) if __name__ == '__main__':...
b86fe68ad836e2637fce54fd0b566a4274b612bc
onceahero/data-python
/hanoi-tower-simple.py
276
4.03125
4
def hanoi(n, a, b, c): global stepCount if n > 0: hanoi(n-1, a, c, b) stepCount += 1 print('stepCount: {}'.format(stepCount)) print('{} --> {}'.format(a, c)) hanoi(n-1, b, a, c) stepCount = 0 hanoi(2, 'A', 'B', 'C')
23991e3161d9230a6f02931ca79a609962acd2ff
o-Ian/Practice-Python
/02 - Arithmetic operators/Des_007.py
163
3.84375
4
n1 = float(input('Digite a nota um: ')) n2 = float(input('Digite a nota dois: ')) print('A média entre a nota {} e a nota {} é {:.1f}' .format(n1,n2,(n1+n2)/2))
8e36d3626f91887cee615df067c2c8b0dd78516e
KusumaNavya/cspp1-assignments
/M22/assignment1/read_input.py
319
4.1875
4
''' Write a python program to read multiple lines of text input and store the input into a string. ''' def main(): """ read line""" line = int(input()) l_l = [] for _ in range(line): l_l.append(input()) for each_line in l_l: print(each_line) if __name__ == '__main__': main()
750e961d09be3eafe90ff04ed54e8342b9382b1a
lucasvaz25/Python
/Seleção/NotaAprovado.py
254
3.78125
4
n1 = float(input('informe a 1ª nota: ')) n2 = float(input('informe a 2ª nota: ')) m = (n1 + n2)/ 2 if m == 10: print('aprovado com Distinção, média: ', m) elif m > 7: print('aprovado, media: ', m) else: print('reprovado, média: ', m)
1970deb4a3db3630cf1c91b3995d97132ff0f8eb
eagerithm/leetcode
/bugoverdose/53.py
1,805
4.03125
4
from typing import List # Runtime: 64 ms, faster than 72.70% of Python3 online submissions for Maximum Subarray. # Memory Usage: 15 MB, less than 31.66% of Python3 online submissions for Maximum Subarray. class Solution: def maxSubArray(_, nums: List[int]) -> int: cur_sum = nums[0] max_sum = cu...
d432179a28761fe615d5644e7202b3c31b0ba73d
peterilhardt/Twitter_AI
/twitter_api_functions.py
7,780
4.125
4
# Helpful functions for interacting with the Twitter API using Python def tweet_to_string(tweet): """ Takes Tweet text in JSON format (dictionary) and converts it to a useful string output. Parameters --------- tweet: dictionary Tweet in JSON format as returned by requests.get(...).js...
a79c3f24e5f25c5bc7527638a939f7a06a6ae218
hhoangphuoc/data-structures-and-algorithms
/algorithm-questions/dynamic_programming/coin_change.py
1,912
4.28125
4
# -*- coding: UTF-8 -*- ''' coin change problem Given a value N, if we want to make change for N cents, and we have infinite supply of each of S = { S1, S2, .. , Sm} valued coins, how many ways can we make the change? ''' # Time complexity: O(2^n) as each coin has two possibility either included or not included...
f83715e817afdbaa60fdbe943852691d5eeb4636
Mariam-ke/Andela
/cart.py
1,482
4
4
class ShoppingCart(object): def __init__(self): self.total = 0 self.items = dict() def add_item(self, item_name, quantity, price): self.total = self.total + (price*quantity) self.items[item_name] = quantity def remove_item(self, item_name, quantity, price): quantityLeft = self.items[i...
8c10df689476a65cdaa693003fc75eefc86e4c4b
portegestary/NewsCrawler
/NewsCrawler_PTT/Create_db.py
487
3.59375
4
import sqlite3 import csv with open('DbSql\\create_db.sql') as f: create_db_sql = f.read() db = sqlite3.connect('ptt.db') with db: db.executescript(create_db_sql) #db.executemany('INSERT INTO members (name, group_name) VALUES (?, ?)', members) #c = db.execute('SELECT * FROM members LIMIT 3') """ wi...
461696e59e59f8c76bcfbec1d58c4d77d2fda689
dacl010811/curso-python-jupyter
/ejercicios-clase/unidad9/animales.py
1,010
3.84375
4
# Super Clase class Animal(): tipo = '' def __init__(self): pass def respirar(self): print(" Soy de tipo {} y estoy respirando".format(type(self))) def comer(self): print(" Soy de tipo {} y estoy comiendo".format(type(self))) def dormir(self): print(" Soy de...
ece624a8a9fbbe1fe7086414a2391cdba80c2e2c
mkurde/the-coding-interview
/problems/stack/stack.py
1,966
4.09375
4
""" This is a simple implementation of the Stack data structure Use it as you please ^_^ """ class Stack(): """ Simple LIFO Stack data structure """ def __init__(self): """Constructor declaring the private variable""" self._items = [] def is_empty(self): """Check the e...
e25877a322d59dfd0b7861faf4a0b953b7651132
MrHamdulay/csc3-capstone
/examples/data/Assignment_2/scrsha001/question3.py
343
4.09375
4
# Pi calculation and area of circle def main(): import math pi = 2 y = math.sqrt(2) while y != 2 : pi = pi * (2/y) y = (math.sqrt(2+y)) print("Approximation of pi:",round(pi,3)) r = eval(input("Enter the radius:\n")) Area = round(pi * (r**2),3) print("Are...
a0641334cc478b267c205e47b475129a8e42fcaa
tanuj87/Deep_Learning
/Tensorflow_basic_using_Keras.py
5,352
3.53125
4
# coding: utf-8 # # TensorFlow basics # In[1]: import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns # In[2]: df = pd.read_csv('TensorFlow_FILES/DATA/fake_reg.csv') # In[3]: df.head() # In[4]: # very simple dataset # we will treat it as a regression problem, feature 1...
92e584780b9db0da3931560b3a648d0bb9d4fa97
jickw/my-project
/python/lnh_learn/201812/1210/类方法静态方法.py
1,587
3.84375
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- # class A: # def func(self): # print(self) # # @classmethod # def func1(cls): # print(cls) # A.func1() # 类方法,通过类名调用的方法,类方法中的第一个参数约定俗成称cls,python自动将类名(空间)传给cls # a1 = A() # a1.func1() # 对象调用类方法,cls传的是类本身 # 类方法应用场景: # 1、类中 有些方法是不需要对象参与 # clas...
a6f9ef386f468a9b737af1ddc36f6ed978231096
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_3/104.py
1,864
3.875
4
#!/usr/bin/env python import math import sys def indef_integral(x1, x0, r0): def f(x): return (x/2.0) * math.sqrt(r0*r0-x*x) + r0*r0*math.asin(x/r0)/2.0 return f(x1) - f(x0) def square_arc_intersect_area(c_x, c_y, d, r): # does the bottom-left of the square lie outside the arc? if c_x * c_x ...
3f76dbd84e430fe469a52f9fe733ab7e041d3daa
dtran39/Programming_Preparation
/01_Arrays/026_Remove_Duplicates_Sorted/RemoveDuplicateSorted.py
1,388
3.921875
4
''' Problem: - Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this in place with constant memory. ---------------------------------------------------------------------------------------...
6337b91e3f423b73d17133d7623384c7a915d089
miskazava/python-012021
/cviceni/cykly.py
803
3.65625
4
sales = { "Zkus mě chytit": 4165, "Vrah zavolá v deset": 5681, "Zločinný steh": 2565, } print("Vydané knížky: ") for key in sales: print(key) total = 0 for key, value in sales.items(): print(f"Knihy {key} se prodalo {value} kusů.") total += value # total = total + value print(f"Celkem bylo p...
57813529611afe8a9460e6655448f3ceebd6cbfe
qmnguyenw/python_py4e
/geeksforgeeks/python/medium/25_7.py
2,514
4.15625
4
Python program to add two matrices **Prerequisite :** Arrays in Python, Loops, List Comprehension Program to compute the sum of two matrices and then print it in Python. We can perform matrix addition in various ways in Python. Here are a two of them. Examples: Input : X= [[1,2...
2b4a0ef3905a01e6550e70d1359f98c498f0e427
absoluteabutaj/Guvi
/VowOrCons.py
183
3.9375
4
# Created on 02-Sep-2016 # @author: AbuTaj s = input('Enter Char')[0].lower() if(s == 'a'or s == 'e'or s == 'i'or s == 'o'or s == 'u'): print('Vowel') else: print('Constant')
d7c5fc8f4f253d5933902ec0333e9a30f480a39f
sbo97t/BootCamp
/C to F converter.py
427
4.125
4
# C to F converter print("Enter a temp in Celsius to convert to Fahrenheit") temp = float(input("Celsius ")) print((temp * 9/5) + 32) print("Would you like to convert from Farhneheit to Celsius? (Y or N) ") answer=input() if answer=="Y": print("Enter a temp in Fahrenheit to convert to Celsius") tempF ...
9dc9685324e02eae3940561a263c736436ab4dde
baobao98/ML_FinalProjectThirdYear
/ML_Final/Multiple_Linear_Regression.py
2,270
3.703125
4
# Multiple Linear Regression # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd from sklearn.externals import joblib from sklearn.metrics import r2_score # Importing the dataset dataset = pd.read_csv('Datasets\Startups.csv') #bỏ cột cuối Profit X = dataset.iloc[:, :-1] #...
fc4c278283bdd2de60fcdd85c65e3af134d0ec9c
GambuzX/AdventOfCode
/2019/Day 17/day17_1.py
3,770
3.640625
4
def supports_second_arg(instr): return instr != 3 and instr != 4 and instr != 9 def supports_third_arg(instr): return instr == 1 or instr == 2 or instr == 7 or instr == 8 def assure_key_values(nums, i, rel_base): if i+1 not in nums.keys(): nums[i+1] = 0 if i+2 not in nums.keys(): nums[...
46677179045d1cba73272e9d6b4fb3320d671d17
DDR7707/Final-450-with-Python
/Bit Manipulation/473.Two Non Repeating Numbers.py
1,300
3.875
4
def UniqueNumbers2(arr, n): sums = 0 for i in range(0, n): # Xor all the elements of the array # all the elements occurring twice will # cancel out each other remaining # two unique numbers will be xored sums = (sums ^ arr[i]) # Bitwise & the sum with it's 2'...
c2055489a8e44c16cf5117d71893ea30bbcdd3d3
oddjsh/Python-Practice-Works
/Tutorial/PW-learning codes(基礎功能).py
1,556
3.984375
4
def epic(): ('wow this is great!') #定義EPIC的功能 if __name__ == '__main__': print('such great module!') #定義當執行的文件是這個文件(PW-learning code.py)時 #將會印出such great module這行文字 #反之當執行的文件不是這個文件而是由其他文件導入(import)此文件時 #將不會執行這行命令下的指令 print(''' So this is a simple muti-line print, pretty cool, huh? or eh? ==...
721b2a4ee709b80aecacb0363700df0fdb2a720c
brannerchinese/algorithm_play
/python_abacus/test_abacus.py
2,336
3.6875
4
import abacus def single_chars_only(lst): """Confirm that no list-element has other than one char""" return all(len(i) == 1 for i in lst) def integers_only(lst): """Confirm that no list-element contains other than integers as chars""" try: _ = [int(i) for i in lst] except: return F...
6dcb81eb50b1dbd5c13e306b73faa1f6e2c85dfa
floscha/pewdieplot
/pewdieplot/graph/linechart.py
1,386
3.796875
4
"""Module for the LineChart class.""" from graph import Graph import matplotlib.pyplot as plt import numpy as np class LineChart(Graph): """A `Graph` displaying one more multiple lines.""" def __init__(self, *args, **kwargs): """Initialize the LineChart object.""" # Pass dict of constructor ...
5298fb4d1315eae602f72720e9633db9ac834c65
BDanalysis/HBOS-CNV
/mytime.py
1,454
3.671875
4
import time as t class MyTimer(): def __init__(self): self.unit=['year','month','day','H','M','S'] self.prompt="not begin yet" self.lasted=[] self.begin=0 self.end=0 #开始计时 def __str__(self): return self.prompt __repr__=__str__ def __add__(self,oth...
5687af0d7892dfda015877c967edac5d57a999e7
nevidjen/SpajalicaPreporuke
/Data/generateData.py
1,229
3.546875
4
import csv import numpy as np import pandas as pd import random cities = []; userNames = []; gender = ['male', 'female']; age = range(18, 60); # this is main array area Users = []; # end of array # cities extraction with open('cities.txt') as f: lines = f.readlines(); for city in lines: cities.append( ((cit...
9679d1bbf80bf835fb4c27d4c888d2ff0e69706d
Kawser-nerd/CLCDSA
/Source Codes/AtCoder/abc030/A/4826890.py
125
3.5625
4
a,b,c,d = map(int,input().split()) if a/b<c/d: print("TAKAHASHI") elif a/b>c/d: print("AOKI") else: print("DRAW")