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
6236eb84b8f9a9aa5a9453002bd736ab6073df99
tomamic/paradigmi
/python/e5_2011_6_top_words.py
637
3.90625
4
#!/usr/bin/env python3 ''' @author Michele Tomaiuolo - http://www.ce.unipr.it/people/tomamic @license This software is free - http://www.gnu.org/licenses/gpl.html ''' if __name__ == '__main__': words = [] filename = input('Filename? ') while filename != '': with open(filename) as infile: ...
f24565183fe243d1348c169a55c32541cd5b2dab
tomamic/paradigmi
/python/e4_2011_5_dice.py
1,305
3.5625
4
#!/usr/bin/env python3 ''' @author Michele Tomaiuolo - http://www.ce.unipr.it/people/tomamic @license This software is free - http://www.gnu.org/licenses/gpl.html ''' import random, logging N = 1000 DIE_FACES = 6 ATTACK_DICE = 3 DEFENCE_DICE = 2 def roll_dice(dice: list): for i in range(len(dice)): dice[...
e384161f78cfe7990bcd7e0ab15d7f2d35f4876c
Ayokunlewaakinnawo/Loan-Data-Analytics
/Average_interest_rate/Average_interest_rate.py
4,684
4.3125
4
# DATA_ANALYSIS_01 # This Program is designed to analyse the data from the loan1.csv # ... and a line graph is plotted to to show the Average interest rate of each month in 2018 of LC # The data been analyzed is gotten from LendingClub Statistics through kaggle.com # importing the libraries the would be used im...
1a87603ebb22714e7c9c7c4958f405be47ddc8d1
Gitorama/gcf_lcm
/Prime Numbers#2.py
2,113
3.984375
4
def gcf(): #defines function that computes the Greatest Common Factor global number, number2, gcf #sets variables as global number = int(input("Enter a number: ")) #allows user to enter number number2 = int(input("Enter another number: ")) #allows user to enter another number prime_n = [] #creates empty...
d3288c4d5c36b500870e44143972703a98e47e62
merlin9527/leetcode
/medium/74.搜索二维矩阵.py
995
3.5625
4
# # @lc app=leetcode.cn id=74 lang=python3 # # [74] 搜索二维矩阵 # # @lc code=start class Solution: def searchMatrix(self, matrix: List[List[int]], target: int) -> bool: flag = False if not matrix: return flag start_index = 0 # 定义遍历行值的索引偏移量 for rows in matrix: # 从矩阵的右上角开始遍历,...
2bcc3c8c44bb0e4d435fd96c44e10293d88e4dcb
carv-silva/cursoemvideo-python
/Mundo03/exercsMundo03/exerc075.py
1,213
4.21875
4
'''Desenvolva um programa que leia quatros valores pelo teclado e guarde-os em uma tupla. No final mostre: A) quantos vezes aparece o valor 9. B) em que posição foi digitado o primeiro valor 3 C) quais foram os numeros pares.''' tupla = tuple(int(input('Digite um numero: '))for i in range(0, 4)) print(tupla) print(f...
a4891728969df6ec058880613c4ca81d4c2009fd
carv-silva/cursoemvideo-python
/Mundo01/aulasMundo01/aula009.py
335
4.03125
4
## Lista em python frase = str('Curso em Video Python') print(frase[9:21:2]) ##len[frase] ##frase.count('o') print(frase.find('deo')) ##'Curso' in frase frase.upper() ##frase.replace('Python','Android') print(frase) print("""Alguma coisa grande aqui so pra encher linguiça-- as 3 aspa serve para um texto grand...
90ae4b0ff81699ca43a31b2c89c41eb345db6ed3
carv-silva/cursoemvideo-python
/Mundo01/exercsMundo01/ex017.py
518
4.1875
4
'''Faca um programa que leia o comprimento do cateto aposto e do cateto adjacente de um triangulo retangulo, calcule e mostre o comprimento da hipotenusa''' from math import sqrt a = float(input('Entre com o cateto: ')) b = float(input('Entre com o cateto aposto: ')) h = sqrt(a**2+b**2) print(f'A hipotenusa é: {h:.2f...
9fb453af6ee7731a6f2a533ef4c3b78c38476fca
carv-silva/cursoemvideo-python
/Mundo02/aulasMundo02/aula15.py
463
3.703125
4
'''cont = 1 while cont <= 10: print(cont, '--> ', end='') cont += 1 print('Acabou') # while True: --> laço infinito n = cont01 = 0 while cont01 != 3: n = int(input('Digte um numero: ')) cont01 += 1''' # fleg --> significa que acabou # no python vc nao declara variavel vc inicializa n = s = 0 while...
6e79285840205f0ae85729370565006a6383b3a9
carv-silva/cursoemvideo-python
/Mundo02/exercsMundo02/ex036.py
819
4.09375
4
'''Exercício 36 – Aprovando Empréstimo Escreva um programa para aprovar o emprestimo bancario para a compra de uma casa.O programa vai perguntar o valor da casa o salario do comprador e em quantos anos ele vai pagar. Calcule o valor da prestação mensal, sabendo que ela nao pode exceder 30% do salario ou entao o empr...
596b035aac9e22e02ae5cfd22f629bc9450de6a4
carv-silva/cursoemvideo-python
/Mundo01/exercsMundo01/ex002.py
178
3.625
4
'''Faca um programa que leia o nome de uma pessoa e mostre uma mensagem de boas-vindas''' nome = input('Digite seu nome: ') print('\033[1;92;41m Bem vindos, {}'.format(nome))
a7c1d52f39a6b061c082067f05f451f3833f55bc
carv-silva/cursoemvideo-python
/Mundo01/exercsMundo01/ex018.py
787
4.34375
4
'''Faca um programa que leia um angulo qualquer e mostre na tela o valor do seno, cosseno e tangente desse angulo ''' import math a = float(input('Digite um angulo: ')) r = math.radians(a) ## --> tranforma o angulo em radiando para poder fazer a conta print(f'O angulo de {a} tem o Seno de {(math.sin(r)):.2f}') ## o ...
2bd75ae280198f305db856b68e869fbf0bc1bfbe
carv-silva/cursoemvideo-python
/Mundo02/exercsMundo02/ex060.py
803
4.25
4
from math import factorial '''Faca um programa que leia um numero qualquer e o mostre o seu fatorial EX: 5! 5X4X3X2X1 = 120''' ''' n = int(input('Digite um numero inteiro qualquer: ')) fat = 1 i = 1 while i <= n: fat *= i i += 1 print(fat) resultado = 1 numero = int(input('Digite um numero inteiro qualquer:...
7b7ef605632efa89f4d1de71edeeb3e78c933199
carv-silva/cursoemvideo-python
/Mundo01/exercsMundo01/ex035.py
882
4.5
4
''' Desenvolva um programa que leia o comprimento de tres retas e diga ao usuario se elas podem ou nao formar um trinagulo ''' '''a = float(input('Insira o comprimento 1: ')) b = float(input('Insira o comprimento 2: ')) c = float(input('Insira o comprimento 3: ')) if a + b + c == 180: print('Tringulo formado') el...
b3a7c54df6a966963fa5407ed9214c0db6ddf93c
parkerdu/tensorflow-learning
/tensorflow学习/5-3 tensorboard 网络运行参数.py
3,663
3.5
4
"""" 只有输入输出层 激活函数softmax 代价函数:二次代价函数 优化器:梯度下降 """ import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data # 载入数据集 mnist = input_data.read_data_sets('MNIST_data', one_hot=True) # 每个批次的大小 batch_size = 100 # 计算总共多少批次 n_batch = mnist.train.num_examples // batch_size def variable_summaries(var):...
089ca0baa26aa9cebe455f1f57416efdb12fa805
Konan33/Colorful_Painting
/main.py
843
4.0625
4
import turtle #import modules ob = turtle.Turtle() #creat the object with the turtle function ob.speed(0) #object's speed how faster the shape will complate cl = ["red","green","blue"] #colours of the shape, 0, 1, 2 def drawArt(d,angle,x,y): #creat a def function and add the distance with the angle and we called t...
e32d29f50e630522ae74b1e767104255c2bc1c6a
HexF/pyictacp
/pyictacp/checksum.py
407
3.6875
4
from abc import ABC, abstractmethod class Checksum(ABC): length = 0 def __init_subclass__(cls, length:int = 0) -> None: cls.length = length @abstractmethod def calculate(self, data: bytes) -> bytes: pass class ByteChecksum(Checksum, length=1): def calculate(self, data: bytes)...
f0a5c9a115f33a26bf378b1636195f968f29d6f4
HexF/pyictacp
/pyictacp/encryption.py
373
3.765625
4
from abc import ABC, abstractmethod class Encryption(ABC): encryption_type=0 def __init_subclass__(cls, encryption_type:int) -> None: cls.encryption_type = encryption_type @abstractmethod def encrypt(self, data: bytes) -> bytes: pass @abstractmethod def decrypt(self, data: by...
d7d95f73e84fe7100e77a0aea43ddc0b7aa7a9d4
bryanlie/Python
/HackerRank/hex.py
480
3.984375
4
''' CSS colors are defined using a hexadecimal (HEX) notation for the combination of Red, Green, and Blue color values (RGB). Specifications of HEX Color Code 1. It must start with a '#' symbol. 2. It can have 3 or 6 digits. 3. Each digit is in the range of 0 to F. 4. letters can be lower case ''' import re n = ...
f19151fce2c14be35efad14a418a87e724286aa0
bryanlie/Python
/HackerRank/lists.py
1,198
4.46875
4
''' Consider a list (list = []). You can perform the following commands: insert i e: Insert integer at position . print: Print the list. remove e: Delete the first occurrence of integer . append e: Insert integer at the end of the list. sort: Sort the list. pop: Pop the last element from the list. reverse: Reverse t...
7b751a1ac5b1f54ff7b539062b748c4ff9e95c1b
bryanlie/Python
/Effective Python/item14.py
268
3.5625
4
def divide(a, b): try: return a/b except ZeroDivisionError as e: raise ValueError('Invalide inputs') from e x , y = 5, 2 try: result = divide(x, y) except ValueError: print("Invalid inputs") else: print("Result is %.1f" % result)
a7b1b3df46df7d5a7d1ec1ff12cbe7f6b1ebba28
bryanlie/Python
/Effective Python/item18.py
287
3.71875
4
def log(message, *values): if not values: print(message) else: values_str = ','.join(str(x) for x in values) print('%s: %s' % (message, values_str)) log('My numbers are', 1, 2) log('Hi there') favorites = [7, 33, 99] log('Favarite colors', *favorites)
4470d75e49c9e9cdcca4d5842fa604fbd4849f74
FriggD/CursoPythonGGuanabara
/Mundo 2/Desafios/Desafio#54.py
547
3.84375
4
#Crie um programa que leia o ano de nascimento de sete pessoas. No final, mostre quantas pessoas ainda não atingiram a maioridade e quantas já são maiores. from datetime import date atual = date.today().year totmaior = 0 totmenor = 0 for pes in range(1,8): nasc = int(input('{}ª. Digite o ano de nascimento: '.forma...
00394b7c4fda72a634d54b354248d5e9c67b7add
FriggD/CursoPythonGGuanabara
/Mundo 2/Desafios/Desafio#49.py
167
3.9375
4
#Faça a tabuada i = int(input('Digite um número: ')) f = int(input('Digite o fim da tabuada: ')) for j in range (0,f+1): print('{} x {} = {}'.format(i,j,(i*j)))
89c8504779287cad8e9f3d65cebd28b62845bb88
FriggD/CursoPythonGGuanabara
/Mundo 2/Desafios/Desafio#37.py
584
4.15625
4
#Escreva um programa que leia um número inteiro qualquer e peça para o usuário escolher qual será a base de conversão num = int(input('Digite um número inteiro: ')) escolha = int(input(''' Para conversão Para BINÁRIO: 1 Para OCTAL: 2 Para HEXADECIMAL: 3 ''')) if escolha == 1: print('O numero {} em binário é: {}'....
893199325167f78cc01a42e44490c316419e8207
FriggD/CursoPythonGGuanabara
/Mundo 1/CursoPython/CursoPython#10.py
729
4.0625
4
#Condições parte 1 #Condições simples e compostas #if carro;esquerda(): # bloco True # else: # bloco False tempo = int(input('Quantos anos tem seu carro?')) if tempo <=3: print('carro novo') else: print('carro velho') print('--Fim--') #condição simplificada #python não tem operador ternário tempo = int(in...
66c0aeb6aed01f7e4887108de381d5e823d12fe1
FriggD/CursoPythonGGuanabara
/Mundo 1/Desafios/Desafio#22.py
562
4.21875
4
#Crie um programa que leia o nome completo de uma pessoa e mostre: #1. O nome com todas as letras maiúsculas; #2. O nome com todas as letras minúsculas; #3. Quantas letras tem sem contar os espaços; #4. Quantas letras tem o primeiro nome nome = input('Digite seu nome completo: ') print('1. Nome em maiúsculo: {}'.form...
6a40286fc0a6df4746134511c7b0a5350b03e434
FriggD/CursoPythonGGuanabara
/Mundo 1/Desafios/Desafio#25.py
218
3.875
4
#Crie um programa que leia o nomne de uma pessoa e diga se ela tem "Silva no nome" nome = input('Digite o seu nome: ').strip() #in é um operador do Python print('Seu nome tem Silva? {}'.format('Silva'in nome.lower()))
eb1a2b0eb9bd7c2906243cef789f8948a025af65
FriggD/CursoPythonGGuanabara
/Mundo 3/CursoPython/CursoPython#16.py
477
3.859375
4
#Tuplas () # As Tuplas são IMUTÁVEIS lanche = ('Hamburguer', 'Suco', 'Pizza', 'Pudim') # for comida in range(0,len(lanche)): # print(lanche[comida]) # for comida in lanche: # print(comida) # for pos, comida in enumerate(lanche): # print(f'{pos}. {comida}') # print(sorted(lanche)) #Em ordem # a = (2,3,5) # b ...
36fa0d82a540296a84fcfedc10e2c229aeaf60b3
FriggD/CursoPythonGGuanabara
/Mundo 3/Desafios/Desafio#75.py
721
4.15625
4
# Desenvolva um programa que leia quatro valores pelo teclado e guarde-os em uma tupla. No final, mostre: # A) Quantas vezes apareceu o valor 9. # B) Em que posição foi digitado o primeiro valor 3. # C) Quais foram os números pares. # Variáveis simples dentro de () formam as tuplas num = ( int(input('Digite um nú...
376813ccacd963f1c9d433e86be85ce75ab263a3
FriggD/CursoPythonGGuanabara
/Mundo 3/CursoPython/CursoPython#19.py
409
4.03125
4
#Dicionário pessoas = {'nome': 'Gustavo', 'sexo': 'M', 'idade': 22} print(f'O {pessoas["nome"]} tem {pessoas["idade"]}anos') #aspas duplas dentro dos [] print(pessoas.keys()) print(pessoas.values()) print(pessoas.items()) del pessoas ['sexo'] pessoas['nome'] = 'Leandro' for k, v in pessoas.items(): print(f'{k} = {v}...
d9a9fb86513c62c09f5b577d8f016158d12f03fb
rizzlesauce/image-convert
/convert.py
5,232
3.515625
4
#!/usr/bin/env python """Program for converting image files from one format to another. Will convert one file at a time or all files (of a selected format) in a directory at once. Converted files have same basename as original files. Uses workaround: askdirectory() does not allow choosing a new dir, so asksaveasfilen...
917553155ba5137f047c8b45080748887ce534bc
websvey1/TIL
/algorithm/algorithm_week/week10/bo_choong/사냥꾼.py
957
3.53125
4
def isWall(x,y): if x<0 or y<0 or x>=N or y>=N: return False else: return True def hunt(x,y): global cnt dx = [-1,-1,-1, 0, 0, 1, 1, 1] dy = [-1, 0, 1,-1, 1,-1, 0, 1] dno = 0 home_x = x home_y = y while dno < len(dx) : x = x+dx[dno] y = y+dy[dno] ...
d3589943e1db41fe2b46c9ae98b01306d9e1c138
websvey1/TIL
/algorithm/algorithm_week/week5/problem_3.py
849
3.703125
4
import sys sys.stdin = open("problem_3.txt") def compare(a,b): if (a,b) == (1,3) or (a,b) == (3,1) : return 1 elif a < b: return b elif a > b: return a # elif a == b: # if # 이부분을 재귀로 좀더 완성하면 될것같은데. T = int(input()) for tc in range(1, T+1): N = int(input()) data...
4a50847791471fd3090a55bd9ed55423243264c8
websvey1/TIL
/algorithm/algorithm_week/week7/bo_chung/사다리.py
734
3.609375
4
def iswall(data): for i in range(len(data)): data[i].append(0) data[i].insert(0,0) data.append([0] * (len(data)+2)) data.insert(0, [0]*(len(data)+2)) return data def find_road(data): dx = [1,0,0] dy = [0, -1, 1] dno = 0 x,y = 1,1 while data[x][y] !=2: if data...
4c38169c05d7d7ec9d57543cf39d72f7a2381de2
CimyJr/Sistemas-Operacionais-de-Redes
/conversor.py
1,008
3.515625
4
import requests import json requisicao = requests.get("https://economia.awesomeapi.com.br/json/all") cotacao = json.loads(requisicao.text) #print(cotacao) #teste para saber quais moedas tem na api class Conversao: def __init__(self, real): self.dolar = float(cotacao['USD']['ask']) self.euro = fl...
a200b37a9cd72713eba65e75309e968877cc1107
SuperQiQi0701/StoneHenge-and-SubtractSquare
/substract_square_game.py
5,038
3.90625
4
""" Game module classes Game, SubstractSquareGame, and Chopsticks. """ from typing import Any from state_of_game import State, ChopsticsState, SubstractSquareState class Game: """ Represents a game. === Attributes === is_p1_turn - whether it is p1's turn, if not, then it is p2's turn. current_sta...
40410aa9690bc54a384e6aa4a0d3a17ba87b5aef
XiaoweiZuo/Leetcode
/7. Reverse Integer.py
705
3.65625
4
class Solution: def reverse(self, x: int) -> int: # # method 1: math approach # a = abs(x) # rev = 0 # while a != 0: # rev = rev * 10 + a % 10 # a = a // 10 # if ( (-2**31) <= rev <= (2**31 -1) ) : # return -rev if x < 0 ...
f43865a04b78749298b5201938ae7a97a6bdd1a9
quhacks/NoviceJudger2020
/08 - QuackHack/main.py
384
3.78125
4
import sys a, b = sys.stdin.readline().split() for i in range(int(a), int(b)): #includes a but not b number = '' if i % 3 == 0: #the operator % is modulo (or remainder) number += 'Quack' if i % 5 == 0: #if the remainder is 0, it is divisible number += 'Hack' if number == '': #if number...
c2465c05eedc36bf6e94b5e02b43a774ce7cb1f1
quhacks/NoviceJudger2020
/16 - Lunch Break/main.py
692
3.8125
4
import sys meetings = sys.stdin.readline() times = [] #holds both the start and end times #adds all the values to the times list for i in range(int(meetings)): start, length = sys.stdin.readline().split() times.append(int(start)) times.append(int(start) + int(length)) #end = start + length times.sort() #...
7fcba310b2e7901979c374beb3afe54ae50ca23f
canhdominich/ml
/Linear_Regression/linear_regression_demo1.py
883
3.578125
4
from __future__ import print_function import numpy as np import matplotlib.pyplot as plt # height (cm), input data, each row is a data point X = np.array([[147, 150, 153, 158, 163, 165, 168, 170, 173, 175, 178, 180, 183]]).T # weight (kg) y = np.array([ 49, 50, 51, 54, 58, 59, 60, 62, 63, 64, 66, 67, 68]) # Building...
448adcdcd04cb70459ae3305d7616ccf6ff0ed75
roehst/aoc-2020
/py/day3.py
1,172
3.546875
4
#!/usr/bin/python3 from functools import reduce from operator import mul class Toboggan: def __init__(self): self.__rows = [ line.strip() for line in open("../inputs/Day3.txt", "r") ] @property def nrows(self): return len(self.__rows) @property d...
30c2f9470865cf13bf6391495347ad1bc4cac9e8
Smartboysai003/for-loops
/Print numbers 1 to n using for loop.py
100
3.96875
4
#Print numbers 1 to n using for loop n=int(input()) for i in range(1,n+1): print(i,end=' ')
c270f4865da343415ea72349627c690b2bd5ad54
dipikakhullar/Data-Structures-Algorithms
/coding_fundamentals.py
772
4.125
4
def simpleGeneratorFun(): yield 1 yield 2 yield 3 # Driver code to check above generator function for value in simpleGeneratorFun(): print(value) import queue # From class queue, Queue is # created as an object Now L # is Queue of a maximum # capacity of 20 L = queue.Queue(maxsize=20) ...
6f828b70986a5eb6a710bab58f5c0b52e4fe6373
dipikakhullar/Data-Structures-Algorithms
/dp.py
2,492
4.03125
4
def knapsack(weights, items_values, weight_capacity): """ we have an array of items, and a bunch of vals """ rows = len(weights) # we need a column of zeros columns = weight_capacity + 1 table = [[0 for x in range(columns)] for y in range(rows)] # we want to continue to add one more item into the bag # iterat...
d39fc9f7c2504fd3122a243ecc48a9e74c76a1fb
matioli254/practice.py
/differentlists.py
1,316
4.3125
4
#list challenge 7 Different Types of Lists Program print("\n\t\t\tSummary Table") #Define list num_strings = ["15", "100", "55", "42"] num_ints = [15, 100, 55, 42] num_floats = [4.5, 10.5, 16.3, 34.3] num_lists = [[1,2,3],[4,5,6],[7,8,9]] # A summary of each variable (or list) print("\nThe variable num_strings is a ...
a50cadc7674d9316bda56f92e207287db539d78e
shobhit1215/VoiceAssistant
/Jarvis.py
3,181
3.703125
4
#Libraries for making this application import pyttsx3 # to convert text to speeches import datetime # to get current current time import speech_recognition as sr import wikipedia import webbrowser import os engine=pyttsx3.init('sapi5') #init() gives the reference to engine instanse and sapi5 is used for window...
28a982b392e5a1c3e5ecc287f78d63b506349c2a
Aparna768213/Best-Enlist-task-day3
/day7task.py
794
4.34375
4
def math(num1,num2): print("Addition of two numbers",num1+num2) print("Subtraction of two numbers",num1-num2) print("Multiplication of two numbers",num1*num2) print("Division of two numbers",num1/num2) num1 = float(input("Enter 1st number:")) num2 = float(input("Enter 2nd num:")) math(num1,num2) ...
85a7a5bb3940c724f68a6aaae6b36cbc4ecf1127
a554b554/MUA
/LRParser.py
8,320
3.84375
4
import lex import string import random import math import copy import time tokens = [] # token is the parsing object. We use LR parsing algorithm to interpret the tokens. token[-1] is the top tokens on the stack. namespaces = [{}] # namespaces is a stack store the namespace, namespace is a dict which map a word to a ...
fef5a7e843961be25f1457883d42cab7fa20f462
e-findlay/Algorithms-and-Data-Structures
/countEphemeral.py
1,475
3.84375
4
def ephemeral(i): if i in eph_dict: #add all elements in the current sequence to dictionary with same value as element already in dictionary if eph_dict[i] == "Y": for j in temp_set: eph_dict[j] = "Y" return True else: for j in temp_set: ...
317a08484a36629c4de569d70d44187ca6357b5b
vklnka/learn-python-lesson1
/homework_while_2.py
328
3.828125
4
def find_person(name): names = ["Вася", "Маша", "Петя", "Валера", "Саша", "Даша"] while names: first_name = names.pop() if first_name == name: print(name, "нашелся") break find_person("Валера") find_person("Маша") find_person("Саша")
b58ed3cc5c5dab49dda69e264aa3f95df088ac4d
vklnka/learn-python-lesson1
/homework_exceptions.py
434
3.640625
4
def ask_user(): try: while True: user_say = input("Спросите что нибуть? ") if user_say == "Пока": print("Ну пока") break else: print("Я отвечаю на ваш вопрос что нибуть") except (ValueError, TypeError, IndexError, KeyEr...
646cdffbe50bf06786db00972a6054381a5e8bae
magicbe/exericses-Python_EZ_learning
/CH03/if2.py
232
4.09375
4
# else if 另外如果 age = input('請輸入年齡:') age = int(age) if age < 13: print('國小') elif age >= 13 and age < 18: print('國高中') elif age >= 18 and age < 22: print('大學') else: print('社會')
ac3ce7a84e2b23d50d390f63cbbd613d05990804
Marian-N/8Puzzle-greedy
/src/heuristics.py
1,202
3.859375
4
from puzzle_functions import find_box def wrong_boxes_count(puzzle, puzzle_goal): #This function counts how many boxes are in wrong position count = 0 for row in range(len(puzzle)): for column in range(len(puzzle[0])): if(puzzle[row][column] != puzzle_goal[row][column]): ...
f256677eaae42b359dae18686f5d763dbc4629cb
Marsunbi/PythonTest
/ClassTest.py
388
4.03125
4
class Person(object): def __init__(self, name, description): self.person_name = name self.desc = description def __str__(self): return "This person is called {} and says {}".format(self.person_name, self.desc) person1 = Person("Simon", "Hey") person2 = Person("Steffen", "hey") print(p...
a64076fb7fdddf22c810e3d3b80515f771ca7330
SantoshGowrisetty/Learn_by_doing-dataquest.io
/Python_Programming/Intermediate/Dates in Python-166.py
1,384
3.640625
4
## 1. The Time Module ## import time current_time=time.time() print (current_time) ## 2. Converting Timestamps ## import time current_time=time.time() current_struct_time=time.gmtime(current_time) current_hour=current_struct_time.tm_hour ## 3. UTC ## import datetime current_datetime=datetime.datetime.now() curre...
8d7458ca4ed2de7d11bd457fbf55f6240816c779
SantoshGowrisetty/Learn_by_doing-dataquest.io
/Python_Programming/Intermediate/Regular Expressions-164.py
2,868
3.640625
4
## 1. Introduction ## strings = ["data science", "big data", "metadata"] regex = "data" ## 2. Wildcards in Regular Expressions ## strings = ["bat", "robotics", "megabyte"] regex = "..t" ## 3. Searching the Beginnings And Endings Of Strings ## strings = ["better not put too much", "butter in the", "batter"] bad_str...
c28bc62bc1b7a68b6a73b36cceada5cf8f07cd0c
rishikumar69/all
/average.py
239
4.21875
4
num = int(input("Enter How Many Number you want:")) total_sum = 0 for i in range(num): input = (input("Enter The Number:")) total_sum += input ans = total_sum/num line = f"Total Average of {total_sum}is{ans}" print(line)
2541bead71f1bdd47f035c6f046068684e3b5bd6
rishikumar69/all
/practiceproblem1.py
933
3.953125
4
user_input = int(input("Enter Your Age or Year of birth: ")) if user_input <= 100: old = (2020 - user_input)+ 100 print(f"You will we 100 years old in {old} years ") elif user_input >= 1900: givenyear = user_input old = user_input + 100 print(f"you will 100 years old on {old}") else: print("w...
1799492fc0ac0c0d5233e4f2d10d72e0d9b6461d
rishikumar69/all
/practiceproblem3.py
458
3.78125
4
usrinp = int(input("Enter th lenth of numbers: ")) usrinp2 = str(usrinp) i = 0 for i in range(1,usrinp+1): inp = int(input("Enter the number: ")) inp2 = str(inp) if inp2[::-1] == inp2: print("Pelendrome") elif inp2[::-1] != inp2: for r in range(inp,inp+100): r1 = str(r) ...
3aabc24cb17d5d9aa098d34eddc14958d64eaee3
rishikumar69/all
/practiceproblem6.py
1,586
3.875
4
import random a = int(input("Enter The Value of a: ")) b = int(input("Enter The Value of b: ")) ran = random.randint(a, b) ran2 = random.randint(a, b) i = 0 user1 = 1 user2 = 1 print("Player 1st turns...") while True: i = i + 1 a = int(input("Enter The number: ")) if a == ran: print(f"you have...
ce97cbdea39a83f0e5b4d9ef3ec36e0a566494c3
rishikumar69/all
/practiceproblem2.py
554
4.0625
4
harrsapple = int(input("ENTER THE NUMBER OF APPLE HARRY HAS: ")) mn = int(input("Enter the minimum range : ")) mx = int(input("Enter the maximum range : ")) if mn != mx: for i in range(mn,mx+1): if i%2 == 0: print(f"{i} is the diviser of {harrsapple}") else: print(f"{i} is ...
dddb77ed666ff9a9909b3c9eb244d7963e118405
mahmutemrahsari/informatics
/IN1000 v17 Python/OBLIG1/beslutninger.py
299
3.84375
4
print("Vil du ha en brus? ja/nei ") #1 svar = input() if svar == "ja": #2a Hvis brukeren har svart “ja” skal programmet skrive ut “Her har du en brus!” print("Her har du en brus!") elif svar == "nei": #2b print("Den er grei.") else: #2c print("Det forstod jeg ikke helt")
5c60155109cc0837e0a5b3f0a057f96878132e7e
Gaurav716Code/Python-Programs
/Recursive Function/Reverse number.py
159
3.75
4
def printRev(n): if n>0: print(n) printRev(n-1) print('F113 Gaurav Vishwakarma') print('Print numbers in reverse order') printRev(10)
b61056878a607fca8cbe35d9dc3c4d63da9a5be1
Gaurav716Code/Python-Programs
/Tuples/Packing and Unpacking Tuples.py
333
3.96875
4
# A tuple can also be created without using parentheses. This is known as tuple packing. def packingUnpacking(): my_tuple = 3, 4.6, "dog" print(my_tuple) # tuple unpacking is also possible a, b, c = my_tuple print(a) # 3 print(b) # 4.6 print(c) # dog packing...
02d3d46489d545526e173cfcaf7c58f324af07cb
Gaurav716Code/Python-Programs
/Loop Function/bacteria double life interval.py
384
3.984375
4
def bacteriaDoubleLife(): time = 0 pop = int(input("Enter population of bacteria : ")) rate = float(input("Enter growth rate : ")) dubPop = pop*2 while pop <= dubPop : pop = pop + (pop*rate) time = time+1 print("Bacteria Population : ",round(pop)) print("Ba...
6a56ceb00fb302373d36dd1854e6775cba83b7c5
Gaurav716Code/Python-Programs
/Tuples/creating tuples.py
952
4.5
4
def createTuple(): # Different types of tuples # Empty tuple my_tuple = () print("Empty : ",my_tuple) # Tuple having integers my_tuple1 = (1, 2, 3) print("Integer : ",my_tuple1) # tuple with mixed datatypes my_tuple2 = (1, "Hello", 3.4) print("Mixed : ",my_tuple2)...
d6ab91f6579ec619a681ab8f0d6f31240773a194
Gaurav716Code/Python-Programs
/if else if/ph value..py
288
4.125
4
def phvalue(): num = float(input("Enter number : ")) if num > 7 : print(num," is acidic in nature.") elif num<7: print(num," is basic in nature.") else: print(num,"is neutral in nature.") print("~~~~ End of Program ~~~~~~") phvalue()
294b605d152823fb7a8b6c97692914b1a7e5474c
ridwan098/Python-Projects
/random number multiplier.py
415
4.0625
4
# this programme generates two random numbers and tells you to multiply them together import random x = int(random.randint(0,10)) y = int(random.randint(0,10)) z = x * y print("what is; " , x, "*" , y, "?") a = int(input("Please enter your value:")) if a == z: print('that is the correct answer'); else:...
865cb7a533848b52056c8fab0a8652763acf0970
ridwan098/Python-Projects
/tut 30 - init.py
249
3.96875
4
class Tuna: name = "" def __init__(self, object): print("im a fish") self.name = object print("My name is " + self.name) def swim(self): print("I am swimming") fl = Tuna("dsafs") fl.swim()
c89b3407650b7f40b4a92b5f2b665584bc266fe9
ridwan098/Python-Projects
/looping mood of computer.py
1,445
3.5
4
import random contents = '''<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title>Hello</title> </head> <body> loop = 1 == 1 while 1 == True: print("My mood ranges from 1 to 3, \n Enter a number...
d22f4ce6a9cff8d04db8fca268a56a52bb2092e3
ridwan098/Python-Projects
/multiplication table.py
220
4.21875
4
# This program displays the multiplication table loop = 1 == 1 while loop == True: n= input('\nenter an integer:') for i in range(1, 13): print ("%s x %s = %s" %(n, i, i*int(n)))
e4d00925b6e7d22f3f36a97fe670119419ffc614
ridwan098/Python-Projects
/fibonacci sequence(trial 1).py
361
4.15625
4
# This program prints out the fibonacci sequence(up to 100) loop = 1 == 1 while loop == True: number = 1 last = 0 before_last = 0 num = int(input("\nHow many times should it list? ")) for counter in range(0, num): before_last = last last = number number = be...
65231cbba3e873ff6afd6203ffd0fe71a21d74cc
ridwan098/Python-Projects
/name.py
931
3.984375
4
#this program says hello and asks for your details import time, sys print("welcome") print("what is your name?") myname=input() print("it is good to meet you,"+myname) print("how old are you?") age=input("write your age here: ") print("so you are: " +age,"years old") print ("what school do you go to?") school...
e83f5b4dc4a53aa863964675f060578327b45c98
kimnanhee/SerBot
/parabola_update.py
656
3.578125
4
# https://www.delftstack.com/ko/howto/matplotlib/how-to-automate-plot-updates-in-matplotlib/ import numpy as np import matplotlib.pyplot as plt import math g = 9.8 # 중력가속도 seta = 30 # 각도 Vo = 60 # 속도 t = 0 t_period = 0.5 fig = plt.figure() x_list = [0] y_list = [0] while True: t += t_period x = Vo * math.co...
26f0f0fdbbe45e57831f01a07ccdcf501e11515c
kelleyparker/Python
/grades.py
512
4.3125
4
print("This program calculates the averages of five students' grades.\n\n") # Define a list of tuples containing the student names and grades students = [] for i in range(5): name = input(f"Insert student {i+1}'s name: ") grade = float(input(f"Insert {name}'s grade: ")) students.append((name, grade)) # Ca...
317e5a1962617caac2939b78c2a7669e8a4c340d
yanglovewang/python
/Include/函数.py
680
3.5625
4
# pass语句什么都不做,那有什么用?实际上pass可以用来作为占位符, # 比如现在还没想好怎么写函数的代码,就可以先放一个pass,让代码能运行起来 # 在py中函数可以返回多个值所以我们也要用多个值去接收 # 其实返回值是一个tuple!但是,在语法上,返回一个tuple可以省略括号,而多个变量可以同时接收一个tuple # 可以给函数的参数赋值一个默认参数,调用函数的这样降低复杂度 # 定义默认参数要牢记一点:默认参数必须指向不变对象! # 可变参数、关键字参数、命名关键字参数 import math n = math.sqrt(3) print(n)
9ee5bc9855724413e470045ca19b29351f50a56f
cysun0226/junyi-test
/1.py
485
4
4
numbers = [1, [12, 3, [4, [5, 16]]]] def reverse_sentence(sentence): words = sentence.split(' ') result_str = '' for w in words: result_str += (reverse_str(w)+' ') return result_str def reverse_str(str): return str[::-1] str = input('\n1. Please input a string: ') p...
051dac39b157f3af0a0925d05f32f7946395abab
dribbeiro/CursoPython
/aula1/login.py
502
3.84375
4
#!/usr/bin/python # arquivo: login.py usuarios = ['marvin', 'artur', 'ford', 'ze'] senhas = ['marvinpw', 'arturpw', 'fordpw', 'zepw'] print 'Autenticacao' user = raw_input('Login: ') # passw = raw_input('Senha: ') for u in usuarios: if user == u: passw = raw_input('Senha: ') if passw == senhas[us...
8597c1851c483e907e614d586c7f63d024c83278
tr2512/IT1110E
/IT1110E_mid_term/20204877_Q13.py
479
3.90625
4
def box_compare(a,b,c,d,e,f): box1 = [a,b,c] box2 = [d,e,f] box1.sort() box2.sort() if box1 == box2: return 'Boxes are equal' elif box1[0] >= box2[0] and box1[1] >= box2[1] and box1[2] >= box2[2]: return 'The first box is larger than the second one' elif box1[0] <= box2[0] an...
57f8ef0491cc6f0d06502ed176d8e2a2436163d1
Quinn95/movierec
/what2watch/RecommendationsTesting/movie_recommender.py
5,895
3.703125
4
from numpy import * from scipy import optimize # define the number of movies in our 'database' num_genres = 19 # define the number of users in our 'database' num_users = 20 # randomly initialize some genre ratings # a 19 X 200 matrix ratings = random.randint(3, size=(num_genres, num_users)) print ratings # c...
99dbfb4fd94a3edc96418bb54237374cdba94061
Sampreet/Competitive-Programming
/HackerRank/Domains/001 Algorithms/001 Warmup/E - Compare the Triplets [Score If Else]/compare-the-triplets.py
387
3.875
4
def compare_the_triplets(arr_a, arr_b): n = len(arr_a) a = sum([1 for i in range(n) if arr_a[i] > arr_b[i]]) b = sum([1 for i in range(n) if arr_a[i] < arr_b[i]]) print(str(a) + ' ' + str(b)) if __name__ == '__main__': arr_a = list(map(int, input().rstrip().split())) arr_b = list(map(int,...
a7f09af7a9f1f2309c6249ae31906cbe51b97cee
pitcany/practice
/coursera exercises/improved_quicksort.py
1,381
3.59375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Apr 25 13:15:37 2019 @author: yannik """ # Uses python3 import sys import random def partition3(a, l, r): x = a[l] # first place everything less than x to the left j = l for i in range(l + 1, r + 1): if a[i] < x: j ...
c8e94ce4e4e38d9d9bf704fa4aa144893ce8f2d1
pitcany/practice
/coursera exercises/lcm.py
357
3.734375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Apr 22 02:30:19 2019 @author: yannik """ def gcd(a,b): if a==0: return (b) else: return(gcd(b%a,a)) def lcm(a,b): return a*int(b/gcd(a,b)) if __name__ == '__main__': a,b = map(int, input().split()) print(lc...
fa93668bba5b7c3e8969d40c96a34c66030210d0
kristiluu/Country-Search
/main.py
4,003
4.28125
4
# Kristi Luu; Partner: Amir Alaj # A program that works with a list of countries of the world. # The program reads each country data from a file and lets the user search for countries based on their data. from country import Country import csv from collections import defaultdict def getData(fname="country.csv"): ...
02f7461f047b695d8db369581b52b0f5511df8a2
Jacob-Barhak/PrefectDemo
/PrefectDemo.py
3,677
4.0625
4
""" Simple use case of prefect for the evening of python coding """ from prefect import task, Flow import sys import time import datetime # uncomment next line to make this into a task # @task def is_prime(number): """determine if a number is prime""" # 0 and 1 are not considered prime numbers although 1 is ...
f5419339bc2eb6661e5cedc60417633b66e19c9c
stefanostsolos/Movie-Recommendation
/MovieRecommendation.py
1,690
3.53125
4
import pandas as pd import numpy as np from sklearn.feature_extraction.text import CountVectorizer from sklearn.metrics.pairwise import cosine_similarity def get_title_from_index(index): return df[df.index == index]["title"].values[0] def get_index_from_title(title): return df[df.title == title]["index"].v...
c0e70c6ab2fbefaa48752e0baf489f8946f8fca5
symbatoss/python2
/homework1.py
1,731
4.09375
4
#ДЗ Сделать класс fraction тоесть взять из математики дробь и сделать её альтернативу в python, с аттрибутами и методами. Методы должны правильно считать дробь к дроби. К примеру # fraction1.add(fraction2) # тоесть дробь в методах принимает 1 экземпляр дроби и делает красивый принт результата. Дз скидывать мне в ввиде ...
fe08696465a214885066b8e6d2e016bd891b1316
ccollado12/budgetapp
/validation.py
389
3.5625
4
def accountNumberValidation(accountNumber): if accountNumber: try: int(str(accountNumber)) if len(str(accountNumber)) == 10: return True except ValueError: # print('Invalid Account Number') return False except NameError: ...
0eafca3fcdbd14dc52128109f1d629fde780b35b
PabloPolMartin/StructuredPrograming2A
/unit1/activity_03.py
251
3.765625
4
price_hour = 300 min_hour = 40 bon = 1.5 hours = int(input("how many hours worked?")) if (hours>40): hour_extra = hours - min_hour salary = (min_hour*price_hour) + (hour_extra*bon) else: salary = hours*price_hour print("payment", salary)
59bd394676bf16234122b626e5fcffea8b3940d4
anyahayda/tree_lab14
/TicTacToe_task3/game.py
2,641
3.8125
4
import binarynode class InvalidPossitionExcpetion(Exception): def __init__(self, *args, **kwargs): Exception.__init__(self, *args, **kwargs) class OutOfRangePositionException(Exception): def __init__(self, *args, **kwargs): Exception.__init__(self, *args, **kwargs) class Game: def __in...
719e5da322c45e9fc29fdc3b826f9dcc7c6a88c4
SoundKnight/git_init
/T3/MainScript.py
1,550
4.03125
4
# ---<=> MODULOS <=>--- import Funciones # ---<=> DICCIONARIOS <=>--- menu = { 1: 'Buscar Pokemon por Nombre', 2: 'Buscar Pokemon por ID', 3: 'Buscar Pokemon por Tipo', 4: 'Ver Todos los Nombres de Pokemons', 5: 'Salir' } # ---<=> INICIALIZACION <=>--- if __name__ == '__main__': while True: ...
9eab92d2e4fc59e189b47fb5f5b0792cf5041a18
filaone/codewars
/python_skills/040_string_upper_capitalize.py
415
3.71875
4
#!/usr/bin/python #-*- coding: utf-8 -*- string_1 = "abcdJGUYB" string_2 = "sdgIDJdf sdjg222jsd def" print string_1.upper() print string_1.lower() print string_1.swapcase() print "title : ",string_2.title() print "capital : ",string_2.capitalize() def canonical_header_name(str): return "-".join(map(lambda x:x.ca...
bd8f71229dac2468ac373d9585439f28952516e3
filaone/codewars
/python_skills/100_enumerate_lstd.py
450
3.703125
4
#!/usr/bin/python #-*- coding:utf-8 -*- #********************************************************** #Filename: 100_enumerate_lstd.py #Author: Andrew Wang - shuguang.wang1990@gmail.com #Description: --- #Create: 2016-10-03 23:53:28 #Last Modifieda: 2016-10-03 23:53:28 #**************************************************...
7351b0f5868b67754eecf7375c70276d707a09a9
filaone/codewars
/python_skills/065_split_character_every_nth_byte.py
719
3.875
4
#!/usr/bin/python #-*- coding:utf-8 -*- import sys string_1 = "中国中国中国中国中国中国中国" string_2 = u"中国中国中国中国中国中国中国" print sys.getsizeof(string_1) def take_nbytes(s, n): buf = "" # buf has its own size print "enter : ---" for chara in list(s): if (sys.getsizeof(buf) + sys.getsizeof(chara) - 2*sys.getsize...
67979798f81573c4e201aa2e102c38c0f7736313
filaone/codewars
/python_skills/019-048_practice.py
4,922
4.5625
5
#!/usr/bin/python #-*- coding:utf-8 -*- # for 022 import chardet # for 023 import copy # for 025 import re print 'Let\'s Say : ' print "'Hello World'" print '"Hello world"' print 'string1 + ',"String2 + " "'string3'" print u"""Multilines can be written using three \"\"\" """ print 'C:\nowhere' print 'C:\\nowhere' p...
63c8126ad5103fad71713bcf98a95a9389e9831d
filaone/codewars
/python_skills/157_count_file_line.py
386
3.671875
4
#!/usr/bin/python #-*- coding:utf-8 -*- import fileinput class FileLineWrapper(object): def __init__(self,f): self.f = f self.line = 0 def close(self): return self.f.close() def readline(self): for line in self.f: self.line += 1 return self.line f = Fi...
46eabc76c83fbaa7756728a0caa7a3c7db128ac4
filaone/codewars
/python_cookbook/2.16_reformate_text.py
379
3.546875
4
#!/usr/bin/python #-*- coding:utf-8 -*- s = "Look into my eyes, look into my eyes, the eyes, the eyes, \ the eyes, not around the eyes, don't look around the eyes, \ look into my eyes, you're under." import textwrap print(textwrap.fill(s, 70)) print(textwrap.fill(s, 50)) print(textwrap.fill(s, 30, initial_indent=' ...
49f75fdc8c9fb9268b315afa978806436a09f3d0
filaone/codewars
/python_cookbook/2.04_match_search_pattern.py
632
4.03125
4
#!/usr/bin/python #-*- coding:utf-8 -*- # Matching and Searching for Text Patterns text = 'yeah, but no, but yeah, but no, but yeah' # Exact match print(text == 'yeah') # Match at start or end print(text.startswith('yeah')) # Search for the location of the first occurrence print(text.find('no')) import re text1 =...
c6ce8ea317a8d6e3a6a0285d233f0db9a79825b3
filaone/codewars
/python_skills/041_partition_of_string.py
413
3.53125
4
#!/usr/bin/python #-*- coding:utf-8 -*- string_1 = "abcdefghijklmnopqrstuvwxyz" print string_1[1] print string_1[1:-1] print string_1[0:3] string_2 = u"中国人" print "use unicode" print string_2[0:2] string_3 = u" き ki, ひ hi, み mi, け ke, へ he, め me, こ ko, そ so, と to, の no, も mo, よ yo and ろ ro" print string_3[0:10] st...