blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
c07c0d5b9f66478f5b38dcf6c59d0d45cd78df81
zwm/pytest
/WithMengYue/20180519/Test1/test1.py
2,755
3.78125
4
import datetime def isPureNum (dat_str): # if any dismatch, return 1 for i in range(len(dat_str)): if dat_str[i] != '0' and dat_str[i] != '1' and\ dat_str[i] != '2' and dat_str[i] != '3' and\ dat_str[i] != '4' and dat_str[i] != '5' and\ dat_str[i] != '6' and dat_str[i] ...
451f7e9a68c7d0f5c956171d44ae4e63a8e03add
leandroniebles/code-compilation-component
/pseint-code/test/export/py3/05-para.py3
418
3.546875
4
if __name__ == '__main__': a = [float() for ind0 in range(10)] for i in range(1,11): a[i-1] = i*10 for aux_index_0 in range(10): print(a[aux_index_0]) b = [[float() for ind0 in range(6)] for ind1 in range(3)] c = 0 for aux_index_0 in range(3): for aux_index_1 in range(6): c = c+1 b[aux_inde...
4efa574961bf4155f268d68f671602598a09c22d
awheeler294/cs401
/lab4_imdb/IMDB_LASSO.py
5,919
3.578125
4
import pandas as pd import numpy as np from pandas import Series, DataFrame import matplotlib.pylab as plt from sklearn.cross_validation import train_test_split from sklearn.linear_model import LassoLarsCV ### Load the dataset into dataframe, ensure read-in correctly movieData = pd.read_csv("IMDB.csv") movieData.head(...
b86d478d552892a20ca6669a1784fc5467be7415
gabiMSilva/ruspy
/test_cfg_list.py
2,754
3.75
4
""" # cfg-list Representar sequências em notação BNF e EBNF. * Representar sequências com separadores. * Diferenciar separadores intercalados de listas com último separador opcional. * Representar listas com delimitadores. ----- Testaremos esta competência corrigindo a implementação das regras "args" e "xargs" na ...
4424b1ea9798f63e2d2c0f55d7b4dd44564f61b3
manuetov/m02_boot_0
/practicing_apps/calculadoraTkinter/testLambdas.py
385
3.53125
4
def sumaTodos(limitTo): resultado = 0 for n in range(0, limitTo+1): resultado += n return resultado def sumaTodosCuadrado(limitTo): resultado = 0 for n in range(0, limitTo+1): resultado += n ** 2 return resultado def sumaTodosF(limitTo, f): resultado = 0 for n in range...
0b521926edd9e17f16b448692c75b71557fead68
manuetov/m02_boot_0
/practicing_apps/calculadoraTkinter/testIfAnidados.py
228
3.9375
4
numComas = 0 value = input() while value != '*': if value.isdigit(): print('concatena') if value == ',': if numComas < 1: numComas += 1 print('concatena') value = input()
6f555c7791cbe3656cca4e9ee2d263bf3806a255
bagindakarli/Exhaustive-Greedy-Python3.7
/greedy.py
606
3.90625
4
def findMin(V): change = [1, 4, 7, 9] n = len(change) # Initialize Result ans = [] # Traverse through all denomination i = n - 1 while (i >= 0): # Find denominations while (V >= change[i]): V -= change[i] ans.append(change[i]) ...
09c87a129491457d6201dc296c89b4dbe70a0bb9
symborsk/Command-Line-Sqlite3-Interface
/createUser.py
1,770
3.734375
4
import sqlite3 import hashlib import getpass import random from string import ascii_uppercase, digits, ascii_lowercase def GenerateRandomStaffId(): while True: random_key = "".join(random.choice(ascii_uppercase + ascii_lowercase + digits ) for i in range(5)) cursor.execute('SELECT * from staff where staf...
5156911e0bc1ad3dcc584b1590ae17fc0db09f22
annikulin/sendspaceBox
/client/model.py
565
3.515625
4
class File(object): def __init__(self, id, name, path=None): self.id = id self.name = name self.path = path def __str__(self): return 'File [%s]' % self.name def __eq__(self, other): return self.name == other.name class Folder(object): def __init__(self, id, n...
f3581b0c0010e0f6494c0f62a7b2679d758b5ee0
manuabhijit/competitive-programming-practice
/data-structures/modules.py
578
3.703125
4
class Node: value = None nextNode = None previousNode = None leftNode = None rightNode = None def __init__(self, value): self.value = value def update(self, value): self.value = value return self def setNext(self, nextNode): self.nextNode = nextNode ...
2b5844b8c9cc5c776cd85357356ce082a046a2a4
manuabhijit/competitive-programming-practice
/common-functions.py
759
3.890625
4
# Function List # 1. SieveOfEratosthenes # -> list prime numbers to {n} def SieveOfEratosthenes(n): return_data = [] prime = [True for i in range(n + 1)] p = 2 while (p * p <= n): if (prime[p] is True): for i in range(p * 2, n + 1, p): prime[i] = False p...
5792f302d568434ddf7b624021b664d1bd346227
nafanh/how-to-think-like-computer-scientist-answers
/ch 12/12-8.py
2,166
3.609375
4
from unit_tester import test import string def cleanword(str): a = "" for ch in str: if ch not in string.punctuation: a += ch return a def has_dashdash(str): return "--" in str def extract_words(str): a = '' for ch in str: if ch in string.punctuation: ...
31fe84fd5b68d1fdbb7b6f3c4f6132285db3379e
nafanh/how-to-think-like-computer-scientist-answers
/ch 4/4-8.py
169
3.9375
4
''' Write a function area_of_circle(r) which returns the area of a circle of radius r. ''' def area_of_circle(r): return 3.1459 * (r ** 2) print(area_of_circle(2))
4524c571e382410f6bfc4645d138feb7ea72159a
nafanh/how-to-think-like-computer-scientist-answers
/ch 7/7-7.py
256
3.828125
4
def sqrt(n): approx = n/2 while True: better = (approx + n/approx)/2 print(better) if abs(approx - better) < 0.001: return better approx = better print(sqrt(25.0)) # print(sqrt(49.0)) # print(sqrt(81.0))
378665a717394bc493ffa66ae311fcd0d7782dfa
nafanh/how-to-think-like-computer-scientist-answers
/ch 5/5-2.py
852
4.21875
4
''' You go on a wonderful holiday (perhaps to jail, if you don’t like happy exercises) leaving on day number 3 (a Wednesday). You return home after 137 sleeps. Write a general version of the program which asks for the starting day number, and the length of your stay, and it will tell you the name of day of the week you...
645990524dbdd59d38d4cf5fff5375f735745dd4
funnydog/AoC2017
/day19/day19.py
1,406
3.65625
4
#!/usr/bin/env python3 def left(delta): return (-delta[1], delta[0]) def right(delta): return (delta[1], -delta[0]) def add(a, b): return (a[0]+b[0], a[1]+b[1]) def follow(txt): m = txt.splitlines() # find the starting point for x, val in enumerate(m[0]): if val == "|": ...
0c2faf1c43bb1639d6cb057da02d49061eda8e6f
Odinson9/30-Days-Python-HackerRank
/HackerRank_Day16.py
244
4.125
4
def string_to_int(): S = input().strip() # takes input try: # try block print(int(S)) # prints string if it can be converted to an int except: # error/except block print('Bad String') # error message string_to_int()
a2bbcab24f3a8b205a48edec51cf3d6c35338ab0
Odinson9/30-Days-Python-HackerRank
/HackerRank_Day11.py
717
3.625
4
def hourglass(): arr = [] # array placeholder result = [] for arr_i in range(6): # given values arr_t = [int(arr_temp) for arr_temp in input().strip().split(' ')] # given values arr.append(arr_t) # given array for x in range(0, 4): # range for row of 16 hourglasses for y in ran...
bf213d2462e20132ef6134e8ffd43a01060ad914
ElofssonLab/Claudio
/Scripts_Claudio_Bassot/Scripts_2017/gdca_normalization.py
849
3.6875
4
import sys import csv, fileinput import argparse input1 = sys.argv[1] outfile = sys.argv[2] with open(input1, mode='r') as infile: pr = csv.reader(infile, delimiter=' ') res_list = [rows[0:2] for rows in pr] with open(input1, mode='r') as infile: lines = infile.read().split("\n") num_list = [] for line in lines: ...
8f7ac4f6e37edbb9f1df1c19c5714162f6f08f43
travis1230/AdvOSLab1
/some_file_parser.py
438
3.578125
4
with open("some_other_file", "r") as f: out = "" prev_dash = False for line in f: if "ANON" in line or "FILE" in line: continue if "---" in line and prev_dash: out=out[:-3] out += "\n" continue if "---" in line: prev_dash = True continue prev_dash = False if...
d5a34ea85aed7ff9b9aa2dae419b2f47ee7921d2
vidhisharma1212/python-practice
/ch6_2.py
312
3.859375
4
word= 'banana' count=0 for letter in word: if letter=='a': count=count+1 print(count) if len(word)==6: print('hey!') print(''' My name is V. I like to swim, create and code. if there is a hackathon, i like to participate . all have choices if there is a new family nearby , i will meet them. ''')
8f323c43ec34bc928b0cd3900d03b1bbea11a340
Lukawss/guppe
/modos_de_abertura_arquivo.py
1,144
4.1875
4
#-*- coding:latin1 -*- """ Modos de Abertura de Arquivo r -> Abre para leitura - padro w -> Abre para escrita - sobrescreve caso o arquivo j exista x -> Abre para escrita somente se o arquivo na existir. Caso o arquivo exista, gera FileExistsError a -> Abre para escrita, adicionando o contedo ao final do arquivo + -> ...
fe50d170dc76ff4df302e879fe1108ec70b768d1
Lukawss/guppe
/escrever_em_arquivos.py
1,283
4.3125
4
""" Escrevendo em arquivos # OBS: Ao abrir um arquivo para leitura, não podemos realizar a escrita nele, apenas ler. # da mesma forma, se abrirmos um arquivo para escrita não podemos lê-lo, somente escrever. # OBS: Ao abrir um arquivo para escrita, o arquivo é criado no sistema operacional. Para escrevermos dados em...
9d5af15ffdcdfeb7c6fe2aca977f547c0bed13d8
Lukawss/guppe
/list_comprehension_p2.py
640
4.03125
4
""" List Comprehension Nós podemos adicionar estruturas condicionais lógicas as nossas List Comprehension """ # Exemplos # 1 numeros = list(range(1, 31)) print([numero for numero in numeros if numero % 2 == 0]) print([numero for numero in numeros if numero % 2 != 0]) # Refatorar # Qualquer número par módulo de 2...
8205639d2e893a07dc016f5cd5b21def27e3da23
Lukawss/guppe
/debuggando_com_pdb.py
3,133
4.125
4
""" Debuggando com PDB PDB -> Python Debugger # OBS: A utilização do print() para debugar código é uma prática ruim. def dividir(a, b): print(f' a = {a}, b = {b}') try: return int(a) / int(b) except (ValueError, ZeroDivisionError) as err: return f'Ocorreu um problema: "{err}"' print(div...
e0f9a586e40216f5a07108b6709348e527475bb0
Lukawss/guppe
/criando_loops.py
362
4.03125
4
""" Criando sua própria versão de loop for num in [1, 2, 3, 4,5]: print(num) for letra in 'Geek University': print(letra) iter([1, 2, 3, 4, 5]) iter('Geek University') """ def meu_for(interavel): it = iter(interavel) while True: try: print(next(it)) except StopIteratio...
3da3f4449105428ea2152527fa8a63809457f9a8
duncanlindsey/GoogleCodeJam2019
/helperFunctions.py
1,179
3.546875
4
import sys def IsApproximatelyEqual(x, y, epsilon = 1e-6): """Returns True if y is within relative or absolute 'epsilon' of x. By default, 'epsilon' is 1e-6. """ # Check absolute precision. if -epsilon <= x - y <= epsilon: return True # Is x or y too close to zero? if -epsilon <= ...
31e51697aaf0ec8af96a95a3a4b93e73f6b537f3
MatthewBiniam/Enviro-Lynx-SetHacks2020
/src/predictor.py
881
3.703125
4
#!/usr/bin/env python # coding: utf-8 def predict(data, model, vals): """ ret: int year, float value Finds the year when a given parameter will be reacher Finds the value of an environmental issue at a given year """ minimum = int(data[-1] + 1) find_year_inp = vals[0] find_val_inp = val...
439e914c839ddf16d6d05132d8e7c34606a0dd9f
Thestor/Exercises
/Homework_2/Matthew ES - Shuffling Cards.py
498
3.828125
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 25 16:52:56 2019 @author: Matthew """ import random symbols = ["Heart", "Spade", "Diamond", "Club"] numbers = ["Ace", 2, 3, 4, 5, 6, 7, 8, 9, 10, "Jack", "Queen", "King"] to_be_shuffled = [] for symbol in symbols: for n in numbers: to_be_shuf...
b0d9114051b24be57208e4a82dc70a357cb80005
Archanciel/C2
/observer/observer.py
572
3.765625
4
from abc import ABCMeta from abc import abstractmethod class Observer(metaclass=ABCMeta): @abstractmethod def update(self, arg): ''' Called when the observed object is modified. You call an Observable object's notifyObservers method to notify all the object's observers o...
5264482c8a61e4aecc92845b49aec09eca269860
IHSIENHUANG/random-forest
/random_forest_test.py
1,169
3.671875
4
#random Forest Algorithm on mushrooms classfication(poison or non-poison) from random import seed from random import randrange from csv import reader from math import sqrt #import operation def load_csv(filename): dataset = list() #read the data inside with open(filename,'r') as file: csv_reader = reader(file) ...
f0753fc500f0c87ea587d05d4d6096747d2d7ace
ClarkeCodes/DataProcessing
/Homework/Week-1/tvscraper.py
2,660
3.765625
4
#!/usr/bin/env python # Name: Eline Jacobse # Student number: 11136235 ''' This script scrapes IMDB and outputs a CSV file with highest rated tv series. ''' import csv from pattern.web import URL, DOM TARGET_URL = "http://www.imdb.com/search/title?num_votes=5000,&sort=user_rating,desc&start=1&title_type=tv_series" BA...
bd4c5aefe51147b8c193d76fc4ef2e3b38dcb2e1
NonlinearTime/OJ
/LeetCode/97/InterleavingString.py
1,395
3.59375
4
class Solution: def __init__(self): pass def isInterleave(self, s1, s2, s3): """ :type s1: str :type s2: str :type s3: str :rtype: bool """ if s1 == '' and s2 == '': return s3 == '' if s1 == '': return s2 == s3 ...
e8611f9bbde0ea7957bccaf726a98d5c10902fdd
josemariamontero/Lenguaje-de-Marcas
/Entrega2:CadenaCaracteresyListas/ejercicio7.py
882
3.78125
4
lista = [] maximo = 0 suma = 0 alumnos_mayores_edad = [] nombre = input("Introduce el nombre del alumno: ") edad = int(input("Introdce la edad del alumno: ")) while nombre != "*": lista.append([nombre,edad]) nombre = input("Introduce el nombre del alumno: ") if nombre != "*": edad = int(input("Introdce la edad d...
7e6d3795219d0597345315e98f68ea551b450f96
AnnaJakovleva/TestRepository
/3.week/sixthlesson.py
1,724
4.1875
4
import functions ''' Define a function called "count" that has two parameters, called "FirstSequence" and "item" return the number of times the item occurs in the FirstSequence. for example: count ([1,2,1,1]), 1) should return 3 (because 1 appears 3 times in the list). ''' ''' print(functions.count([1,3,4,4], [2,5,5,...
f0f3433698d791ed053074e7ef72d8a7be42fd23
Ashraf-Ghaban/python-repository
/max_heap.py
3,609
3.625
4
import csv class Car: def __init__(self, cid, make, model, year, mileage, price): self.cid = cid self.make = str(make) self.model = str(model) self.year = int(year) self.mileage = mileage self.price = price def __str__(self): return '{}...
cc22f9cc6c1a73b40e4bb9d22ac8ad2948c1c42f
bojotamara/registry-app
/input_util.py
1,442
3.890625
4
from datetime import datetime import re def read_int(message): while True: try: return int(input(message)) except ValueError: print("Invalid input, please try again.") def read_date(message, optional=False): if optional: message = "(Optional) " + message w...
acf2d51987dac2d17a65a7e17fc3069999daaa2e
MikailGio/komputr.py
/diamond.py
647
3.71875
4
# TUGAS BUAT BENTUK DIAMOND DENGAN MENGGUNAKAN # PERULANGGAN DAN FUNGSI # * # *** # ***** # ******* # ********* # ******* # ***** # *** # * #def diamond(n): # i = 0 # while i < n: # print("*", end='') # i = i + 1 # CONTOH MEMBUAT SEGITIGA # def triangle(n): #...
e714b1770e407cdd594498389a175c6f0d4ce270
sudo-justinwilson/python
/negabinary.py
404
3.640625
4
def negaternary(i): digits = [] if not i: digits = ['0'] else: while i != 0: i, remainder = divmod(i, -2) if remainder < 0: i, remainder = i + 1, remainder + 2 digits.append(str(remainder)) return ''.join(digits[::-1]) if __name__ == '...
f9a329ce2d13736a3a7a1c5874376a737734f208
dylanOshima/PyGame-Snake
/snake.py
3,470
3.828125
4
import random WIDTH = 800 HEIGHT = 800 ###### Initalize Snake: snakeHead = Actor('snake_head', pos=(WIDTH/2, HEIGHT/2)) # Initializes an actor named Snake in the middle of the screen snakeHead.dir = 'up' # Sets the default direction of the snake to 'up' snakeHead.alive = True snake = [snakeHead] # generate the r...
2c780184a4d2bb09c374d7a2875adde94c7fb3e2
hoyley/c4
/c4game/game.py
1,247
3.515625
4
class Game: __slots__ = 'board', 'player1', 'player2', 'current_player', 'winner', 'game_over', 'is_training' def __init__(self, board, player1, player2, is_training): self.board = board self.player1 = player1 self.player2 = player2 self.current_player = self.player1 sel...
300312397d54efe5e73e169909856d94492dacd4
a-stockwell/ProfessionalPython
/Chap09.py
145
3.921875
4
x = 3 y = 7 z = 10 if x > y: print(x,'is greater than',y) elif x < z: print(x,'is less than',z) else: print('nothing was the case')
0c036c9c367817070fd5ecfde24746b793c3cb82
oneMoreTime1357/selfteaching-python-camp
/19100101/xiaoguaishou01/mymodule/stats_word.py
1,973
3.578125
4
#创建一个名为stats_text_en的函数 #使用字典(dict)统计字符串样本text中各个英文单词出现的次数 text ='''The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit.我们只中每个英文单词出现的次数''' import re import collections def stats_text_en(text,count): '''1、使用字典(dict)统计text中每个英文单词出现的次数. 2、添加类型检查,如果不是字符串类型为异常''' if t...
9af15ee928edf827c97345a575ec3a08143c16b8
oneMoreTime1357/selfteaching-python-camp
/19100205/11661246/d6_exercise_stats_word.py
1,242
4.0625
4
#统计参数中每个英文单词出现的次数,按词频降序排列数组 def stats_text_en(text): # 统计英文词频 text = text.replace('.', '') text = text.replace('!', '') text = text.replace('--', '') text = text.replace('*', '') text = text.replace(',', '') # 去除标点符号 list_text = text.split() # 将字符串转换为列表 import collections m=collectio...
74cc8276fa96a041f38ac796846439c47447c6f4
AbbyPy/geometry
/geo_element.py
1,957
3.5
4
# geometric calculation fx def cramer(a, b, c, a1, b1, c1): a = float(a) b = float(b) c = float(c) a1 = float(a1) b1 = float(b1) c1 = float(c1) d = a * b1 - b * a1 dx = a * c1 - c * a1 dy = c * b1 - b * c1 if d != 0: x = dx / d y = dy / d return (x, y) ...
4ef1516b2c871081d23c30f45de890d1591ef7d7
jojormani/Programming
/Practice/14/Python/poweroftwo/poweroftwo.py
250
3.703125
4
print ("Введите число") number = int(input()) index = 0 amount = 0 for i in range (1, number+1): power = pow(2, index) if (power <= number): amount = amount + 1 else: break index = index + 1 print (amount)
7ff0591a6cf53892bb7173e6336ece4621813c64
jojormani/Programming
/Practice/09/Python/meet/meet.py
610
3.71875
4
from math import fabs print ("Введите время прихода первого пешехода, пример: '6 : 30'") time1 = input().split() print ("Введите время прихода второго пешехода, пример: '6 : 30'") time2 = input().split() h1 = int(time1[0]) colon = time1[1] m1 = int(time1[2]) h2 = int(time2[0]) colon2 = time2[1] m2 = int(time2[2]) minu...
dc4a3de10b429d1197c4d8f4be885f830ce1f5a3
aneeshneni/Harvard-CS50
/Week 6 - Python/Readability/readability.py
429
3.640625
4
from cs50 import get_string text = get_string("Text: ") words = 1.0 chars = 0.0 sentences = 0.0 for x in text: if x == " ": words += 1 elif x in [".","!","?"]: sentences += 1 else: chars += 1 grade = int(0.0588 * (100/words * chars) - 0.296 * (100/words * sentences) - 15.8) if gra...
31725ecbcda2a04dac7ceeafb1c952a1f0b9131d
Tenbatsu24/python-data-structure
/tree/htree.py
1,244
3.5
4
import collections class Node: def __init__(self, data, parent): self.parent = parent self.data = data self.children = {} def __contains__(self, item): return item in self.children def __getitem__(self, item): return self.children[item] def __setitem__(self, ...
663a8883b027aec8f6978a2d32e8bcb2b0bf484e
ardor090/Retail-Market-
/RETAIL MARKET/shoppingList.py
6,898
3.953125
4
# 1. An inbuilt function for admin to change the price of any of the item. # 2. An inbuilt function for admins to add more items. # 3. An inbuilt function to compute goods purchased per customer and displays a receipt for printing. # a. The function must be able to add 20% VAT for customers buying less than 5 items...
709877dd1705fe12276e5d74da395f0c858db0c8
Vipulhere/Coding-Ninja-solution----Introduction-to-Python
/1. Introduction to Python.py
1,113
3.90625
4
#Find average Marks """ Write a program to input marks of three tests of a student (all integers). Then calculate and print the average of all test marks. """ a = int(input()) b = int(input()) c = int(input()) Average = (a + b + c) / 3 print(Average) #Find X raised to power N """ You are given two integers: X and N. ...
5637f1e147dabffd1d00cd749beb2e837c4d71e1
Vipulhere/Coding-Ninja-solution----Introduction-to-Python
/6. Functions.py
2,807
4.34375
4
#Fahrenheit to Celsius Function """ Given three values - Start Fahrenheit Value (S), End Fahrenheit value (E) and Step Size (W), you need to convert all Fahrenheit values from Start to End at the gap of W, into their corresponding Celsius values and print the table. Input Format : 3 integers - S, E and W respectively ...
9beceeeb25281f17744292b6e64367c1fef578c1
Likhi-organisations/100-days
/xyz.py
344
3.546875
4
n=int(input('enter a number:')) def num(n): s=0 while(n>0): r=n%10 s=s+r**2 n=n//10 return(s) def xyz(n): s1=0 for i in range(2,n//2+1): if n%i==0: print(i) s1+=i if (s1)==num(n): return True else: retur...
15b504e0b8e2690b68793ff89db84d989be98dec
Sinclair19/python_learning
/exercises/6-11.py
483
4.1875
4
cities = {'NewYork':{'country':'USA', 'population':30000000, 'fact':"The USA's biggest city"}, 'Beijing':{'country':'CHINA','population':30000000, 'fact':'The capatal of CHINA'}, 'Tokyo':{'country':'JAPAN', 'population':2000000, 'fact':'New 3rd tokyo'}, } for city,information in cities.items(): pri...
38913e056372269e0a887ef61ffc1a98325fbcfc
Sinclair19/python_learning
/exercises/3-2.py
264
3.9375
4
names = ['alan', 'mike', 'john', 'adam', 'frank'] count = 0 for item in names: message = f"Hi, {names[count].title()}, What's going on recently? " print(message) count +=1 for name in names: print(f"Hi, {name.title()}, What's going on recently?")
c2e74290703568ef42c997fcf016ecedbcb132e9
ayush879/python
/student.py
1,403
3.703125
4
class student: def get_student(self): self.name=input("enter student name:") self.srn=input("enter student srn:") self.gender=input("enter student gender") def show_student(self): print("student details are:") print("Name is:",self.name) print("SRN is:",self.srn)...
7a163dc6b350e180197e1ff0b2bc5b0fc612f6ed
ayush879/python
/n33.py
554
4.03125
4
import pandas as pd import numpy as np d={'name':['Alisa','Bobby','jodha','jack','raghu','Cathrine','Alisa','Bobby', 'kumar','Alisa','Alex','Cathrine'], 'Age':[26,24,23,22,23,24,26,24,22,23,24,24], 'Score':[85,63,55,74,31,77,85,63,42,62,89,77]} df=pd.DataFrame(d,columns=['name','Age','Score']) print(df) print("MINIMU...
abd11d645b263f4faba3188440893ab50d8e55f3
ayush879/python
/7.py
185
3.765625
4
#7 Returns max two characters available after the start of word boundary. import re str1=input("enter a string:").split(" ") for i in str1: print(re.findall('^[a-zA-Z][a-zA-Z]',i))
07431a322fe7f5a3ced8133bed1d68141aa9900b
ayush879/python
/b5.py
230
4.09375
4
num=int(input("Enter the number of rows :")) n = 0 for i in range(1, num+1): for space in range(1, (num-i)+1): print(end=" ") while n != (2*i-1): print("* ", end="") n = n + 1 n = 0 print()
38a43e3ac75a14aff8a79008cc4ae37f409d72df
ayush879/python
/21.py
188
4.375
4
#21) Matches a word containing 'z', not start or end of the word. import re str1 = input("Enter a string : ").split(" ") pattern = '\Bz\B' for i in str1: print(re.findall(pattern, i))
8585692e377af6536648effd5f01a72f3d1a1349
ayush879/python
/c8.py
153
4.15625
4
def recur_sum(num): if num<=1: return num else: return num+recur_sum(num-1) num=int(input("enter a number")) print("sum of numbers",recur_sum(num))
e6691eaa7539dddba735a8775a4223f818626d74
ayush879/python
/n23.py
536
3.78125
4
import numpy as np print("rand function is") print(np.random.rand(3,2)) print("randn function is") print(np.random.randn()) print(2.5*np.random.randn(2,4)+3) print("randint function is") print(np.random.randint(2,size=10)) print(np.random.randint(3,size=10)) print(np.random.randint(5,size=10)) print(np.random.randint(...
b7054363952ad5e1070e4579cc3686de4d0b8253
ayush879/python
/re3.py
260
4.09375
4
my_list=[] num=int(input("Enter a total number of Names ")) for i in range(1,num+1): data=input("Enter Name") my_list.append(data) vowel=['a','e,','i','o','u','A','E','I','O','U'] name=[my_name for my_name in my_list if my_name[0] in vowel] print(name)
d0ed2a822ed22804c56e1f29abf9983738ec746b
ayush879/python
/t22.py
544
3.828125
4
import tkinter as tk from tkinter import messagebox root=tk.Tk() canvas1=tk.Canvas(root,width=800,height=350) canvas1.pack() def ExitApplication(): MsgBox=tk.messagebox.askquestion('exit application','are you sure you wnat to exit the application',icon='warning') if MsgBox=='yes': root.destroy() els...
dec92a5f930982139b5e140e3c112e1128ef8a3c
ayush879/python
/11.py
172
4.3125
4
#11) Return the date from a given string. import re str1 = input("Enter a date : ") pattern = '[0-9]{2}[-|\/]{1}[0-9]{2}[-|\/]{1}[0-9]{4}' print(re.findall(pattern, str1))
37bfd13d755c2f9a3172c068ca9a6a05103dc73f
ayush879/python
/b8.py
335
3.84375
4
n = 1 count = 0 dec = 8 num=int(input("Enter the number of rows :")) for i in range(0, num): for k in range(0, dec): print(end=" ") for j in range(0, i): count = count + 1 n = count temp = n for j in range(0, i): print(n, end=" ") n = n - 1 print() n = temp ...
8164d3062ef3e907fd2268d1259ef2a830936090
ayush879/python
/a9.py
130
3.640625
4
for n in range(10,30): n1=n total=0 while(n>0): num=n%10 total=total+num n=n//10 if(total%2==0): print(n1,"")
958560239d03a3b066f66e5878d49351323fc2e9
ayush879/python
/n24.py
327
3.53125
4
import numpy as np arr=np.arange(10) print(arr) print("the shuffled array is") np.random.shuffle(arr) print(arr) arr=np.arange(10) print(arr) print("the permuted array is") print(np.random.permutation(10)) print(np.random.permutation([1,4,9,12,15])) arr=np.arange(9).reshape((3,3)) print(arr) print(np.random.permutatio...
75731abbf92e7584e5ca86605af8a98c5f175838
ayush879/python
/t2.py
214
3.765625
4
from tkinter import * root=Tk() var=StringVar() label=Label(root,text='how are you doing',relief=RAISED, bg='blue',cursor='cross',bd='4',font='Arial',width=30, underline=15,fg='yellow') label.pack() root.mainloop()
868de7935023b64eee8dd38984de292adf3ab5a4
ayush879/python
/b6.py
512
4
4
num=int(input("Enter the number of rows : ")) val = 65 for i in range(0, num): for j in range(0, i+1): ch = chr(val) print(ch, end=" ") val = val + 1 print() num=int(input("Enter the number of rows :")) n = 65 for i in range(0, num): for j in range(0, i+1): ch = chr(n)num=int...
70c2df40a5ae9f0a7b645cbf63d9d2ff50633b22
ayush879/python
/c2.py
109
4.09375
4
num=list((1,2,3,4,5,6,7,8,9)) def sum(num): sum=0 for i in num: sum+=i print("sum of list",sum) sum(num)
6382131caec51104c7358c5b8af7e84b256ac8db
ayush879/python
/m5.py
151
3.953125
4
statment=input("Enter the statment ") sequence=list(statment) upper=[s.lower() for s in sequence] print('The upper case list is:',end=" ") print(upper)
b77dcc9c1e6089c28a8b5d5cdfa2ad625f9aa927
a-staab/hashmap_implementation
/hashmap.py
1,412
4.03125
4
class Hashmap(object): def __init__(self, length): self.table = [[] for i in range(0, length)] self.length = len(self.table) def hash_func(self, key): return hash(key) % self.length def get(self, key): for item in self.table[self.hash_func(key)]: if item[0] ==...
1cc8c10366d6a3a3adaafa5021bea622823e65e2
Nyyen8/Module12
/custom_exceptions/test_custom_exceptions/test_customer_exceptions.py
4,578
3.734375
4
""" Program: test_customer_exceptions.py Author: Paul Elsea Last Modified: 07/10/2020 Tests to verify functions from ValidationFunctions.py used in customer and customer_exception class function correctly. """ import unittest from custom_exceptions.classes import customer as cust from custom_exceptions.classes import...
7e69c201c364b1e0146b3461eb5995227e3b4d36
Nyyen8/Module12
/custom_exceptions/Validation/ValidationFunctions.py
2,479
3.921875
4
""" Program: ValidationFunctions.py Author: Paul Elsea Last Modified: 07/10/2020 Defining a variety of validation utility functions. """ import re from custom_exceptions.classes import customer_exceptions as cust_ex '''valid_id_check function :param input_num: Number to be checked, required: 4 digit integer between 1...
345ac68d685f3d8ca72b90afe05a0c3485887a12
hadiuzzaman524/Python-Coding-practices
/myrandom.py
464
3.828125
4
import random #print a random number... print(random.random()) #print int type random number with range print(random.randint(2,20)) #choose a person with randomly li=['jaman','habib','rakib'] print(random.choice(li)) # rolled two dice and see the output class Dice: def roll(self): self.number1=random.ra...
198312b3244ca9139fd2619afe9067d7e0e86c04
hadiuzzaman524/Python-Coding-practices
/set.py
1,155
4.09375
4
a={1,2,3,4,5} b={6,7,8,9,5} uni=set(a.union(b)) print("Union of two sets: ",uni) inte=set(a.intersection(b)) print("Intersection of two sets: ",inte) print("Set difference",a.difference(b)) print("Subset: ",a.issubset(b)) print("Disjoint; ",a.isdisjoint(b)) print(a&b) #intersection print(a|b) #union print(a-b) #set d...
bf2cc6e999f81e9422c0a5fde39c8e66bf29f8ea
samcoding123/swapping-final
/swapping.py
320
3.890625
4
def swapping (): file1=input("enter file name ") file2=input("enter file name ") with open (file1, 'r') as a: data_a = a.read() with open (file2, 'r') as b: data_b = b.read() with open (file1, 'w') as a: a.write(data_b) with open (file2, 'w') as b: b.write(data_a) swapping()
9e4fba6a88280e53d2f8f18c30f867b065b96417
kylemaa/Hackerrank
/Dynamic-Programming/fibonacci-recursion.py
267
4.15625
4
# Function for the nth Fib number using recursion method. Time complexity is O(n^2) def fibrecursion(n): if n < 0: return 'ERROR! Invalid number' if n == 1 or n == 0: return 1 else: return fibrecursion(n-1) + fibrecursion(n-2)
fca64658647cd191486589ea4bb734811de7a57d
kylemaa/Hackerrank
/Dynamic-Programming/fibonacci-memoization.py
327
3.578125
4
# Function for the Nth Fib number using dp memoiz method. Time complexity is O(2^n) def fibmemoiz(n, memo): if memo[n] is not None: return memo[n] if n == 1 or n == 2: result = 1 else: result = fibmemoiz(n-1, memo) + fibmemoiz(n-2, memo) memo[n] = result return r...
545ce96c5844dda0d6d310f3f3c7f801afd39c74
kylemaa/Hackerrank
/LeetCode/reverse-int.py
617
3.625
4
class Solution: # naive approach by converting x into string for string manipulation def reverseString(self, x: int) -> int: if x > 0: ret = int(str(x)[::-1]) else: ret = -1 * int(str(x * -1)[::-1]) # for 32-bit overflow cases return ((-2**31 <= ret) and (...
966b85e55755ef3f92bb6784165405352f64b10a
kylemaa/Hackerrank
/Python-Proficiency/fishy-logs.py
2,999
3.796875
4
#!/usr/bin/env python3 import sys import os import re def error_search(log_file): error = input("What is the error? ") returned_errors = [] with open(log_file, mode='r', encoding='UTF-8') as file: for log in file.readlines(): error_patterns = ["error"] for i in range(len(er...
c39191d389608140dbbc116d3fc66ac8f035e9a9
kylemaa/Hackerrank
/LeetCode/Screening/swap-two-numbers.py
383
3.71875
4
def swapTwoDigits(n): n_list = list(str(n)) l = len(n_list) i = 0 ret_s = '' while i < l-1: n_list[i], n_list[i+1] = n_list[i+1], n_list[i] i += 2 if i == l-2 and l % 2 == 1: break for i in range(l): ret_s += n_list[i] return int(ret_s) n = 12345...
903a52c7c374d8c7c5587af85efd70f006d41051
kylemaa/Hackerrank
/LeetCode/simple-calculator.py
760
3.59375
4
class Solution: def eval(self, expression, index): # op variable as empty string to hold operation state op = '+' result = 0 while index < len(expression): char = expression[index] if char in ('+', '-'): op = char else: ...
6096ec777998ea06fba441344532610c24c3553d
chengmoney/test
/小游戏猜数字.py
1,466
4
4
# 开发一个猜数字游戏的程序。即程序在某个范围内指定一个数字,比如在0到9范围内指定一个数字,用户猜测程 # 序所指定的数字大小。 import random # 引入random库 text = input('请输入一个0-9的整数') pd = 1 num = random.randint(0, 9) # random.randint(a,b)表示随机取得a-b之间的自然数 while pd == 1: if text.strip().isdigit(): # 判断输入的是否为数字或者整数 text_num = int(text.strip()) # .strip()去掉空格 i...
fdc4622e28bf0665410ed28396d431df1e0bbb43
chengmoney/test
/practice/01面向对象编程/04.__slots__.py
1,140
4.15625
4
# Python是一门动态语言。通常,动态语言允许我们在程序运行时给对象绑定新的属性或方法, # 当然也可以对已经绑定的属性和方法进行解绑定。 # 但是如果我们需要限定自定义类型的对象只能绑定某些属性, # 可以通过在类中定义__slots__变量来进行限定。 # 需要注意的是__slots__的限定只对当前类的对象生效,对子类并不起任何作用。 # 如果不用__slots__限制绑定属性,可以绑定任何属性 class Student1(object): pass student1 = Student1() student1.name = 'chengyu' student1.age = 29 student1.ge...
d22f4fcb01a939726742af8dc1b076fc2d814ba8
chengmoney/test
/practice/01面向对象编程/06.多态.py
1,292
4.09375
4
""" 子类在继承了父类的方法后,可以对父类已有的方法给出新的实现版本,这个动作称之为方法重写(override)。通过方法重写我们可以让父类的 同一个行为在子类中拥有不同的实现版本,当我们调用这个经过子类重写的方法时,不同的子类对象会表现出不同的行为, 这个就是多态(poly-morphism)。 所谓抽象类就是不能够创建对象的类,这种类的存在就是专门为了让其他类去继承它。Python从语法层面并没有像Java或C#那样提供对抽象类的 支持,但是我们可以通过abc模块的ABCMeta元类和abstractmethod包装器来达到抽象类的效果,如果一个类中存在抽象方法那么这个类就不能够实 例化(创建对象)。 """ f...
8ef15970890ca0a60943662d60c94086afd2fef1
chengmoney/test
/test.py
507
3.5625
4
week = ['Monday', 'Sunday', 'Friday'] lt = [] lt1 = [lt.append(str(i) + n) for i, n in enumerate(week)] print(lt1) lt = [] for i, n in enumerate(week): lt.append('%d : %s' % (i, n)) print(lt) # 用print输出以下文字: # 1. # He said, "I'm yours!" # 2. # \\_v_// # 3. # Stay hungry, # stay foolish. # -- Steve Jobs # 4. ...
d063216c353a836df0e473979a17f64986d91d56
detalikota/scripts
/Playground/first-class-function.py
475
3.5625
4
""" def square(x): return x*x def square_all(func, arg_list): result = [] for i in arg_list: result.append(func(i)) return result x = square_all(square, [1,2,3,4,5]) print(x) """ """ def a(msg): def b(): print ("LOG:", msg) return b a = a("hi") a() """ def html(tag): ...
4ad8109df90551bfc137a3e9b7a527a0cce15c14
fleandrei/Projet-reLAX
/Marriage/mariagepremier.py
563
3.90625
4
#!/usr/bin/python #-*- coding:Utf-8 -*- def mariagepremier(L2,M): """a utiliser dans le cas P,P+1, et permet d'exaucer le premier voeux de la premiere femme""" c=L2.pop(0) #print(L2) #print(c) M[c[0]]=c[1][0] for l in L2: if M[c[0]] in l[1]:#Boucle servant à supprimer les garçon...
216c781d90479c418c9f49cd3622aab3fd240ee5
pbhandaru/Hacker_Rank_Programming_Exercises
/print_rangoli.py
390
3.59375
4
#!/usr/bin/python import string ########## N=int(raw_input()) mid = N - 1 for i in range(N-1, 0, -1): row = ['-'] * (2 * N - 1) for j in range(N-i): row[mid-j] = row[mid+j] = string.ascii_lowercase[j+i] print '-'.join(row) for i in range(N): row = ['-'] * (2 * N - 1) for j in range(N-i): row[mid-...
4b9649e3ad0e5efe8185e9f31d773d974ccb50a2
pbhandaru/Hacker_Rank_Programming_Exercises
/minion_game.py
432
3.5625
4
#!/usr/bin/python ########## def minion_game(string): vs=0 cs=0 V='AEIOU' for i in range(len(string)): if string[i] in V: vs += len(string[i:]) else: cs += len(string[i:]) if vs > cs: print 'Kevin', str(vs) elif vs < cs: print 'Stuart', str...
e8134e6194f823b0ef1ed30fe3f21e604c78d84b
StephenBramble8517/cti110
/P2HW2_MaleFemale_Percentage_StephenBramble.py
560
4.1875
4
#Ask user for number of males #Ask user for number of females #Add the numbers together #Divide the numbers based on respective gender #Show the respective percentages Male = int (input("Enter the number of males in your class:")) Female = int (input("Enter the number of females in your class:")) TOC =...
f6f434cedfbb8dbcb953de7fddd6c3425cbd6868
chiapeilin/Rank
/rank2.py
2,580
3.5
4
data,lis=[],[] #Each line of data after reading \n is removed and stored in the data string. with open("census.csv","r") as f: for line in f: data.append(line.strip()) #(Hive string) divides each row in Data into splits and adds them to the lis string. for l in range(2,len(data)-1): lis.append(data[l].sp...
bc0fa5d88d8909bc90bc29a710a33d9db33a69ee
mpochwat/Learn-Python-The-Hard-Way-Exercises
/ex4.py
734
3.65625
4
#Variables # cars cars = 100 #Car capacity space_in_a_car = 4 #drivers drivers = 30 # passengers passengers = 90 # How many cars are parked cars_not_driven = cars - drivers #Cars in use cars_driven = drivers # Num of ppl that can be driven at a time carpool_capacity = cars_driven * space_in_a_car # Avg number ...
cfff63369e64ecdff1f31a953168df70e877441b
mpochwat/Learn-Python-The-Hard-Way-Exercises
/ex42.py
1,602
4.15625
4
## Animal is-a object (yes, sort of confusing) look at the extra credit class Animal(object): def __init__(self, name): self.name = name def run(speed): print "The animal has run %d km/h" % speed ## Dog is-a Animal class Dog(Animal): def __init__(self, name, speed, height): ## Dog has-a name super(...
84aa060ae2942bcc596092dad774c3ae6cbfae13
PengBoXiangShang/visualization_tool_functions
/src/python_code/bar_plot.py
580
3.78125
4
import matplotlib.pyplot as plt import numpy as np def bar_plot(x_data, y_data, error_data, x_label="", y_label="", title=""): _, ax = plt.subplots() # Draw bars, position them in the center of the tick mark on the x-axis ax.bar(x_data, y_data, color = '#539caf', align = 'center') # Draw error bars to ...
b888e8ebd5f9dbbb0137990819b534d0f3277d24
nonefornothing/Python-for-Everybody-with-Dr.-Chuck-and-OOP-with-Kelas-Terbuka
/Chapter 7/E7.3.py
484
3.671875
4
# Use the file name mbox-short.txt as the file name Jumlah = 0 X = 0 Counter = 0 fname = input("Enter file name: ") if fname == 'na na boo boo' : print("All you doing is just Laughing") else : fh = open(fname) for line in fh: if not line.startswith("X-DSPAM-Confidence:") : continue X = line[...
c62c93c0d6b14794514e9e813cf8c2cda42e95db
nonefornothing/Python-for-Everybody-with-Dr.-Chuck-and-OOP-with-Kelas-Terbuka
/Chapter 8/E8.5.py
411
4
4
counter = 0 #fname = input("Enter file name: ") fh = open("mbox-short.txt") for line in fh : word = line.rstrip() word = line.split() for lines in word : if lines.startswith('From:') : continue elif lines.startswith('From') : print (word[1]) counter = coun...
5721583fa1de22ae58d35ba3ac1d9fcd7a63b97a
BernardWong97/PythonExercise
/codeSnippet/Exercise2.py
576
4.34375
4
# Lists myList = [] myList.append(1) myList.append(2) myList.append(3) print(myList) print(myList[0]) print(myList[1]) print(myList[2]) # Iterate list for x in myList: print(x) myList = [1, 2, 3] # Operators number = 1 + 2 * 3 / 4.0 print(number) reminder = 11 % 3 print(reminder) squared = 7 ** 2 cubed = 2 ** ...