blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
ad837feefc7578b9390d433e3b73d903ac6ef833
loopDelicious/oo-melons
/melons.py
3,604
3.859375
4
"""This file should have our order classes in it.""" import random import datetime class AbstractMelonOrder(object): """basic class for melon orders""" def __init__(self, species, qty, country_code): """Initialize melon order attributes""" self.species = species self.qty = qty ...
65406d5394e0082ac0e3c3e8323aac1fa5522996
ShlokKatare/Mobile-Company-Interactive-Python-Game
/final_project.py
7,244
3.828125
4
import time import random def print_sleep(pr, s): print(pr) time.sleep(s) def intro(): print_sleep("You are the owner of a new cellphone " "company, you have to take appropriate " "decisions to maximize profits and " "balance before the game ends! \n", 3) ...
82178e384bccbc45cf9d83039793737716b70f38
iammax/leetcode
/solutions/py/p0374_guess_number.py
398
3.5
4
class Solution(object): def guessNumber(self, n): leftbound = 1 rightbound = n+1 while True: myguess = (leftbound+rightbound)/2 result = guess(myguess) if result == 0: return myguess elif result == 1: leftbound ...
4a3c7eb77e23ae86db76fe3ec419bb983cabb175
iammax/leetcode
/solutions/py/p0507_perfect_number.py
550
3.53125
4
class Solution(object): def checkPerfectNumber(self, num): def root_checker(num): if num == 1: return 0 total = 1 for q in range (2,1+ int(num**.5)): if num%q == 0: total += q quo = num/q ...
850cc6b14bd1ea49d795fd875e7bc9644f948290
TokenJan/algorithm
/leetcode/#53.maxSubArray(linear).py
349
3.90625
4
def maxSubArray(nums): """ :type nums: List[int] :rtype: int """ cum_sum = max_sum = nums[0] for i in range(1, len(nums)): cum_sum = max(nums[i], cum_sum + nums[i]) max_sum = max(cum_sum, max_sum) return max_sum if __name__ == '__main__': array = [-2,1,-3,4,-1,2,1,-5,4] ...
4e89679476cb71a5ad816c7bfb5ffd74a74e463b
randolph182/EDD_S2_2021
/Matriz_Dispersa/Matriz/Encabezado.py
1,785
3.8125
4
from Estructuras.Lista import Lista class Encabezado(Lista): def __init__(self): Lista.__init__(self) def insertar(self, nuevo): if self.primero == None: # inserta al principio y devuelve el primero self.primero = nuevo self.ultimo = nuevo return self.prim...
db1b851513811953376e9a6fda0bc31a3b0e0b05
randolph182/EDD_S2_2021
/Matriz_Dispersa/Matriz/ListaComida.py
924
3.59375
4
from Estructuras.Lista import Lista from Estructuras.Nodo import Nodo class ListaComida(Lista, Nodo): def __init__(self): Nodo.__init__(self) Lista.__init__(Nodo) self.fila = 0 self.columna = 0 def insertar(self,fila,columna, comida): self.fila = fila self.col...
00fd840f906562baf14c940faa7ed505813115c7
adr2403/Python-Pgm
/file.py
93
3.59375
4
myfile=open("myfile.txt","w") name=input("enter your name") myfile.write(name) myfile.close()
542bc31600489712218edbe8846dac38d060671c
shifatearman/Digital-Image-Processing
/6. Compression/lzw.py
467
3.59375
4
given_string = "BABAABAAA" s = given_string[0] diction = [] for c in given_string: if c not in diction: diction.append(c) output = [] for characters in given_string[1:]: c = characters if s + c in diction: s = s + c else: # print(diction.index(s)) output.append(di...
60a6a618b368a6b311340e06f22f891f94f3d55d
BrunoGomesCoelho/small-bang
/useful/preprocessing.py
1,799
3.734375
4
import numpy as np from sklearn import datasets from scipy import stats def check_data(data, warnings=True, col_size=None, row_size=None): """ Does some basic verification on our data, checking various things to make sure we have correctly formatted everything. """ if len(data.shape) != 2: ...
75f70b81dcb479b2f2f82537fe60c97811819f5d
diegoro1/Tutorials
/python/GUI/new_window.py
544
3.703125
4
from tkinter import * from PIL import ImageTk, Image root = Tk() root.title("Main Window") def open(): global my_img top = Toplevel() top.title("Second Window") my_img = ImageTk.PhotoImage(Image.open("/Users/diegorodrigues/Desktop/Tutorials/python/GUI/assets/hi.png")) my_label = Label(top, image=m...
88d04e1dbdcf51dff40c48bfa7bb71b5913f7ff1
diegoro1/Tutorials
/python/numberss.py
535
3.8125
4
#---------------------------------------------------------------------------------------------------------- # Numbers #---------------------------------------------------------------------------------------------------------- from random import randint from random import see...
15df8b069768a02c7a2c759b0532a3ed8abd478b
KieranCoppins/Dungeon-Salvos
/Interface.py
6,304
3.546875
4
#Kieran Coppins import tkinter as TK class Interface(): def __init__(self): self.root = TK.Tk() self.mainframe = TK.Frame(self.root) #Text Based map design - using characters to represent tiles. self.map = TK.Text(self.mainframe, width = 100, height = 40) self.map.grid(row = 1, rowspan = 2, column = 1) ...
e86ed7dcfcac6ec323db7d9f34e2260a956f6df6
link00000000/mimic
/mimic/Logging/TkinterLoggingHandler.py
1,126
3.65625
4
"""Logging to Tkinter.Text widget for Python's built-in logging library.""" import logging import tkinter as tk class TkinterTextHandler(logging.Handler): """Register Tkinter.Text as logging handler.""" def __init__(self, text: tk.Text): """ Register Tkinter.Text element as logging handler. ...
033135e146d219ea5a78067b3bd1369e3408d0d6
Estrada1997/Estrada1997
/sintaxis.py
2,539
3.96875
4
# num = 20 # if type(num) == int: # print("Resultado: ", num*6) # else: # print("El numero no es numerico") # def mensaje(mensj): # print(mensj) # mensaje("Mi primer Programa") # mensaje("Mi segundo Programa") #********************************************************************************...
e8ec66cd3ea5cde58bee36fd316e9c1599557658
Estrada1997/Estrada1997
/While.py
257
3.765625
4
#Estructuras de control de phyton - While '''while validation''' vocal = input("Ingrese vocal: ") while vocal not in ('a','e','i','o','u'): if vocal == '-': break vocal = input("Vocal: ") print('Su vocal o punto es: {}'.format(vocal))
59466dd3a41fb4e5ed44f4fe7b41830b82a9d940
jearnest88/flask_practice
/full_friends/server.py
2,907
3.515625
4
from flask import Flask, redirect, render_template, request, session, flash from mysqlconnection import MySQLConnector app = Flask(__name__) app.secret_key = "lol123" # Connect to the DB mysql = MySQLConnector(app,'friendsdb') # Set up index route @app.route('/') def index(): query = """SELECT * FROM friends""" f...
62b66b1710490d2fd353dd4e5d428fd59fe7df50
Gomer1800/python_data_structures
/projects/3a_huffman_encoding/huffman.py
8,254
3.890625
4
""" Luis Gomez Data Structures """ class HuffmanNode: def __init__(self, char, freq): self.char = char # stored as an integer - the ASCII character code value self.freq = freq # the frequency count associated with the node self.left = None # Huffman tree (node) to the left self...
06d8ca277a8d320efe2e0286f047a07882612287
Gomer1800/python_data_structures
/handouts/4/binary_tree2.py
1,982
4.125
4
# Binary Tree code with traversal and height functions external to class class BinaryTree: def __init__(self,key): self.key = key self.leftChild = None self.rightChild = None def getRightChild(self): return self.rightChild def getLeftChild(self): return self.leftChi...
d0c83062d15c3fdb07f3cce54accd05519a4bd7f
Gomer1800/python_data_structures
/projects/4_concordance/concordance.py
4,881
3.84375
4
""" Luis Gomez Python Data Structures Concordance Generator. Uses a Quadratic Probing hash table to generate a stop words table and concordance table. Stop words table MUST be loaded prior to building concordance table. This was a crazy project, so relieved """ from hash_quad import * import string class Concordanc...
3b2418c59dbb3cb52d6cdc7a9c57c65fdb7cd3b1
Venkat-Rajgopal/Python_Tricks_and_OOP
/codewars/name_to_initial.py
628
3.90625
4
""" Function to convert a name into initials. Strictly takes two words with one space in between them. The output should be two capital letters with a dot seperating them. Example Sam Harris => S.H Patrick Feeney => P.F """ def abbrevName(name): splits = name.split() # split word into characters. ...
7dc100fb5830de49a9955262a9e4670821085333
dianemagnin97/BASC0023
/ClusterNetworkGraph.py
10,188
3.609375
4
import pandas as pd import networkx as nx import numpy as np from numpy import genfromtxt import matplotlib.pyplot as plt #remember to download files + change path for CSV imports ###### this part I got online https://www.udacity.com/wiki/creating-network-graphs-with-python ## I recommend using an online provider tha...
fa83f3a5d89190aa2a666c44323aa3380845d5be
rautionmaa/Web_Scraping_NBA_Missed_Games
/basketballgames/basketballgames/spiders/basketballgames_spider.py
1,008
3.6875
4
# This spider scrapes NBA wikipedia page for games per season. # Most recent season have 82 games, a few have less because of lockout season from scrapy import Spider from basketballgames.items import BasketballGamesItem class basketballgamesspider(Spider): name = "basketballgames_spider" allowed_urls = ['https://e...
5d7254b6f43df67b87300e686e874968c6823ecf
MaxKrivulin/Home_Work
/HW_1/Home_work_1_6.py
827
4.09375
4
start = float(input("Введите минимальное количество километров для старта: ")) finish = float(input("Введите максимальное кол-во километров, которое хотите достигнуть: ")) progress = start * 0.1 result = start + progress final = result - start days = round(final / progress) if finish < start: print('Вы задали невер...
e447fad64420b518e417192c112c61f42958e15b
originalix/Original
/python/hello.py
2,553
3.75
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- 'a test module' __author__ = 'Lix' import sys import math def my_abs(x): if not isinstance(x, (int, float)): raise TypeError('bad operand type') if x >= 0: return x else: return -x # print(my_abs(100)) def nop(): pass def move(...
441436de5c8edbf29f157d881360d67829af7723
dongrerohan421/python3_tutorials
/08_slice.py
606
4.34375
4
''' Slicing is used to separating slice from the list. ''' myList = [0,1,2,3,4,5,6,7,8,9,10] print ("myList:") print (myList) # To print values from 4-8 print ("myList[4:8]:") print (myList[4:8]) # To print till end print ("myList[4:]:") print (myList[4:]) print (myList[4:11]) print ("myList[-4:-2]:") print (myLis...
7ea26f47f4f76938c0b1a9a009b08fd246cf40c8
dongrerohan421/python3_tutorials
/10_nested_elif.py
750
4.46875
4
''' This program explains nested if else. ''' name = input("Name: ?") # Example of elif: if name == "Mark": print ("The name entered is ", name) elif name == "Adam": print ("The name entered is ", name) elif name == "Viraf": print ("The name entered is ", name) elif name == "Ravi": print ("The name ...
cbbedfd0939695e46f4ad530009d85169a6daf69
entropy2333/leetcode
/easy/20_isValid.py
468
3.71875
4
# 24ms 11.5MB class Solution(object): def isValid(self, s): """ :type s: str :rtype: bool """ stack = [] judge = {'()', '[]', '{}'} for i, ch in enumerate(s): if not stack: stack.append(ch) elif stack[-1] + ch in judge: ...
6bf0c98243921343b3058d30d16531efe69af498
entropy2333/leetcode
/easy/70_climbStairs.py
378
3.640625
4
class Solution(object): def climbStairs(self, n): """ :type n: int :rtype: int """ if n == 0: return 0 if n == 1: return 1 else: l = [0, 1, 2] for i in range(3, n+1): l.append(l[i-1] + l[i-2]) ...
db351e59cdc8d13da12f7f4526a075572627aa28
entropy2333/leetcode
/medium/24_swapPairs.py
608
3.734375
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def swapPairs(self, head): """ :type head: ListNode :rtype: ListNode """ if not head or not head.next: ...
e9a5487e2545df7d2d3df1a50ab956744a88b931
entropy2333/leetcode
/medium/56_merge.py
981
3.78125
4
class Solution(object): def merge(self, intervals): """ :type intervals: List[List[int]] :rtype: List[List[int]] """ n = len(intervals) if n == 0 or n == 1: return intervals intervals.sort() res = [] left = 0 right = 0 ...
571a4abafb6f48638a9df37a1ee9b6b783588617
AlineMilene/d303-python-POO
/python.py
1,804
4.125
4
# ESTRUTURA DA CLASSE # class CuboMagico(self) # self é utilizado para se referir ao objeto que foi criado a partir dessa classe # *********** EXEMPLO 1 - CUBO MAGICO ************ # class CuboMagico(): # def __init__(self, cores, lados): # self.colors = cores # self.sides = lados # d...
73a8c3e664e4067e006cacb17e02b4322a0f15da
niteshjha001/template-python-flask
/test.py
145
4
4
#print(9>>2) a=int(input("Enter first number: ")) b=int(input("Enter second number: ")) min=a if a<b else b print("minimum value of two is:",min)
9b0d6a22e95dca52295ef125408a921307506fb7
primaayunda/Send-email
/emailscript.py
1,165
3.6875
4
# getpass used to make user's password invisible # smtplib is a a library taht provided by python import getpass import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText # mimetext because you will only send a text message sender = str(input("Please input your username: ")) pa...
eb0fd890b78e765c16d53114864f7c2b57af2037
samuelpackmanBUSD/Hammond-Project
/__main__.py
294
3.765625
4
#Import neccecary Bridge class and plotting class from Bridge import Bridge import matplotlib.pyplot as plt #Initialize a bridge of size 22 B=Bridge(size=22) #Print the bridge to the terminal print(B) #Perform repeated addition 100 times B.itter(reps=100) #Print the updated bridge print(B)
ccf3ee62d5b54a795b67d0b947357e043aa08151
rahulrajewar/gui
/calculator.py
3,808
3.75
4
import tkinter from tkinter import Frame,Tk, Button calcu = Tk() calcu.title("Calculator") calcu.resizable(0, 0) class appli(Frame): def __init__(self, master): Frame.__init__(self, master) self.widget() def widget(self): self.display = tkinter.Entry(self, font=("Helvetica", 16)) ...
fa45e0453fac2e919a00fbcf1d76eca248ad0851
izza-khalid/ICS3U-Unit3-06-Python
/try_catch.py
972
4.15625
4
#!/usr/bin/env python3 # Created by: Izza Khalid # Created on: October 2019 # This program checks if the number you chose matches # with user input import random some_variable = random.randint(1, 100) # a number between 1 and 100 def main(): # This function checks if the number you chose matches # input ...
656e16547bc8b4e04c1230d5a2604aef3eb9f0f9
wholemann/daily-coding-dojo
/20200306/python/onetwofour_test.py
803
3.890625
4
def solution1(n): answer = '' while n > 0: n -= 1 answer = '124'[n % 3] + answer n //= 3 return answer def solution2(n): return step(n - 1) def step(n): if n < 3: return '124'[n] return step(n // 3 - 1) + step(n % 3) def test_solution(): for solution i...
ae29c94306cb72c3a4cfbba7dcd3a38d5bf2eceb
wholemann/daily-coding-dojo
/20200302/python/trucks_test.py
958
3.765625
4
def solution(length, weight, trucks): second = 0 bridges = [] while bridges or trucks: if ready(bridges, weight, trucks): bridges, trucks = go(bridges, trucks) bridges = shift(length, bridges) second += 1 return second + 1 def shift(length, bridges): bridges = [...
e3009c4e07d6d6777aa9963cc1b03582227fd365
gleissonneves/software-development-python-study
/curso_em_video/modulo_1/desafios/d4.py
471
3.875
4
str_a = 'Gleisson Neves' str_number = '3' int_a = -3 float_a = 3.14 bool_a = False print(type(str_a), type(int_a), type(float_a),type(bool_a)) print('String: "{0}", Int: {1}, float: {2}, boolean: {3}'.format(str_a, int_a, float_a, bool_a)) print("É número: {}, É número: {}, É Letra: {}, Está todo em letra maiúscula: ...
a0e989109a63e937ab7491d75664e4f3ed27c8bf
gleissonneves/software-development-python-study
/curso_em_video/modulo_1/desafios/d23.py
674
4.0625
4
#nome completo """ requisitos - todas letras minúsculas - todas letras maiúsculas - quantas letras tem sem consiterar os espaços - quantas letras tem o primeiro nome """ from os import name nome = str(input("Qual seu nome completo: ")).strip() nome_mi = nome.upper() nome_ma = nome.lower() nome_...
22d81763b1f79f8a176c071d4bb43e286cc84d72
gleissonneves/software-development-python-study
/curso_em_video/modulo_1/desafios/d3.py
95
3.640625
4
a = input('digite um número: ') b = input('digite um número: ') c = int(a) + int(b) print(c)
0bb57d0b302e3ef6fbf34694b0d3891fb1b2ef09
gleissonneves/software-development-python-study
/curso_em_video/modulo_1/desafios/d18.py
295
3.96875
4
# programa para ler os agulos seno cosseno e tangente from math import radians, sin, cos, tan, radians import math an = float(input('ângulo: ')) print('Seno: {:.2f}'.format(sin(radians(an)))) print('Cosseno: {:.2f}'.format(cos(radians(an)))) print('Tangente: {:.2f}'.format(tan(radians(an))))
107ef63e5526520a62bdae8a31cc4434a4da6890
gleissonneves/software-development-python-study
/curso_em_video/modulo_2/desafios/d16.py
245
3.609375
4
""" Progressão Aritimétrica Requisitos: """ a = int(input('termo: ')) b = int(input('razão: ')) c = a + (20 - 1) * b for i in range(a, c, b): print("{}=> ".format(i), end='') if i >= 20: print("babouuuu ", end=':)')
1c250bf5f62dc3fbcb3b2f0ca81ff2b80a7d9079
gleissonneves/software-development-python-study
/curso_em_video/modulo_2/t2.py
431
3.875
4
""" Estrutura de repetição for aprendedo """ i = int(input("inicio:")) f = int(input("fim:")) p = int(input("passo:")) for c in range(i, f, p): print(c) """ for x in range(10, 0, -1): # range (contador, até, tipo de loop "pulo") # interação reversa if x == 10: print('contagem regress...
2eb76c3fdb2cb8849e4a3abdadcbe6bfa3325f80
gleissonneves/software-development-python-study
/curso_em_video/modulo_1/desafios/d19.py
381
3.609375
4
#o professor que sortear um de seus 4 alunos para apagar o quadro # sistema de sorteio from random import choice from emoji import emojize a1 = str(input("aluno 1: ")) a2 = str(input("aluno 2: ")) a3 = str(input("aluno 3: ")) a4 = str(input("aluno 4: ")) arrAluno = [a1, a2, a3, a4] escolido = choice(arrAluno) print...
febc7fc8d5b7e7ad6c626569f6e43fc9a291e7cc
gleissonneves/software-development-python-study
/curso_em_video/modulo_1/desafios/d32.py
465
3.71875
4
import emojis distancia = 200 val_user = float(input('quantos KM foi percorrido: ')) if distancia >= val_user: valor_viagem = 0.50 valor_total = val_user * valor_viagem print(""" O valor da viagem é de {} """.format(valor_total)) elif distancia < val_user: valor_viagem = 0.45 va...
f4ae29b3c6bfa4c81df9b27702125542d39ce566
Erick76697/Proyecto
/PycharmProjects/ProyectoATM/main.py
1,913
4
4
print("################# Cajero Automatico ###############") dinero = 1000 menu_principal = { "1": "Ingresar", "2": "Nuevo Usuario" } for contador in menu_principal: print(menu_principal) contador = int(input("Escriba el numero de la opcion que desea")) if contador == 1: clave = int(input...
fdd83bb276dc930415b3504c751e0cfd0ab8c05e
nmounikachowdhary/mounikan28
/assignment(2-7-2020)_321910301006_Mounika.py
1,068
4.21875
4
#!/usr/bin/env python # coding: utf-8 # In[3]: #creat atuple with different types tuplex = ("tuple", False,3.2,1) print(tuplex) # In[4]: #convert a tuple to a string tup = ('e', 'x', 'e', 'r', 'c' ,'i', 's',) str = ''.join(tup) print(str) # In[6]: tuplex=(2,3,4,5,6,7) _slice=tuplex[3:5] print(_slice) _slice...
a49ad651cceba1c1b17e8a405486c933649832a3
Gabbo-3477/Esercizi_scheda
/es1scheda.py
189
4
4
parola = input("Inserisci una parola: ") if parola == parola[::-1]: print("La parola che hai inserito è palindroma") else: print("La parola che hai inserito non è palindroma")
2739233dcbc97a90e6b823ac5e02e34bfea1942e
201315060025/test
/data_structure_example/er_ca_shu.py
2,101
4.15625
4
# encoding: utf-8 """ 二叉树方面的考点 """ class Node: def __init__(self, data, left=None, right=None): """ 声明一个节点""" self.data = data self.left = left self.right = right class B_Tree: def __init__(self, root=None): self.root = root def add(self, data): """add nod...
057ebbbdd6d69b0265e2bdc2c446c4a963aac1a5
loveofdriving/liars-dice
/src/liarsdice/players/AbstractPlayer.py
1,438
3.828125
4
''' Created on Jun 16, 2017 @author: Paul Stone ''' class AbstractPlayer(object): ''' Abstract Player that chooses what to bid next. Must implement get_bid. ''' def __init__(self, player_name): ''' Constructor ''' self.player_name = player_name def __repr_...
b4040fe498d15b5fd3535bfcdb5431344ff22d72
mugeshmuthukumaran/MUGESHKUMAR
/pro21.py
190
3.546875
4
#mugi number=int(input()) l=[int(x) for x in input().split()] av=int(number/2) l1=l[:av] l2=l[av::] m1=sum(l1)//len(l1) m2=sum(l2)//len(l2) if m1==m2: print("yes") else: print("no")
458b7b4ee9739a47b4f6ae0a3f57dc6937a78f97
mugeshmuthukumaran/MUGESHKUMAR
/exp2.py
106
3.921875
4
a=int(raw_input()) if(a<0): print ("invalid") elif(a%2==0): print ("Even") elif(a%2==1): print ("Odd")
5a3cf3cc349e94c096ddeef61fe08db331545d41
mugeshmuthukumaran/MUGESHKUMAR
/palindrome.py
157
3.84375
4
m=int(raw_input()) temp=m reverse=0 while(m>0): dig=m%10 reverse=reverse*10+dig m=m/10 if(temp==reverse): print("yes") else: print("No")
81e207e4ec91875e54b30fe019a2faf53d2f5b0d
abuchin/biovis
/biovis/vismorph.py
9,681
3.53125
4
import pylab as plt import numpy as np import h5py import math import matplotlib as mpl from mpl_toolkits import mplot3d from matplotlib.collections import LineCollection def set_axes_equal(ax): ''' Make axes of 3D plot have equal scale so that spheres appear as spheres, cubes as cubes, etc.. This is...
e76a800da94920e303a3ff29a9ed76f4de6ce4e0
XiShao-art/Resolution_FOL
/utils.py
3,617
3.5
4
from FOL import * def remove_or_redundance(sentence): for i in range(len(sentence)-1): for j in range(i+1, len(sentence)): if sentence[i]!=None and sentence[i].equals(sentence[j]) : if sentence[i].negation == sentence[j].negation: sentence[j] =None whil...
b4349a6e765c74451008b187ab74c39a586df40d
jan-at-school/bscs-semester-6
/AI/LABS/LAB03B/solution/task4.py
1,807
3.625
4
from PIL import Image import itertools from PIL import ImageDraw image = Image.open("res/input.png") binarizedImage = image.convert("L") # convert to singal channeled image binarizedImage = binarizedImage.point( lambda x: 0 if x < 150 else 255, '1') # binarized image width, height = image.size cx = 0 cy = 0 n ...
734bf8189c8c3255e4b9210a64d57ead26835eb9
osmanrkhan/learnpython
/ex34.py
306
3.84375
4
list1 = ["zoop", "zop", "zippity", "zappity", "zap"] printable = list1[3] print list1 print printable # Time for fun with lists. zoop = ["bippity", "bop"] zap = ["deputy", "mayun"] nationalities = ["Mexican", "Paksitani", "Irish"] list2 = [zoop, zap, nationalities] print list2
8df8c2eeb973eccca47bfa41f1c7c628f60079e6
aerosayan/Learning-Machine-Learning
/src/01_soup_sale.py
1,446
4.125
4
# LANG : Python 2.7 # FILE : 01_soup_sale.py # AUTH : Sayan Bhattacharjee # EMAIL: aero.sayan@gmail.com # DATE : 2/JULY/2018 # INFO : How does hot soup sale change in winter based on temperature? # : Here, we do linear regression with ordinary least squares import numpy as np import matplotlib.pyplot as plt n = ...
ad97cc4b20bbeee9397c34204c43af143df999f9
akhanss/ML-KU
/bri507/classifiers/linear_svm.py
2,383
3.546875
4
import numpy as np def svm_loss(W, X, y, classes, reg): """ Structured SVM loss function, vectorized implementation. Inputs have dimension D, there are C classes, and we operate on minibatches of N examples. Inputs: - W: A numpy array of shape (D, C) containing weights. - X: A numpy array of shape (N, ...
bdb31f4f766fd5620e23a029cb41ed306152b810
0xecho/KattisSubmissions
/whatdoesthefoxsay.py
217
3.71875
4
for i in range(int(input())): x = input() l = [] inp = input() while inp != "what does the fox say?": l.append(inp.split()[-1]) inp = input() print(" ".join([i for i in x.split() if not i in l]))
90c77d81b1ab7fb3ec958dab893dab55ae6f62a8
0xecho/KattisSubmissions
/datum.py
177
3.65625
4
from datetime import date print(["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"][date(2009,*[int(i)for i in input().split()][::-1]).isoweekday()-1])
a7547399f95d5cdc2a4103268ba8bf81b6f07cdf
0xecho/KattisSubmissions
/dasblinkenlights.py
209
3.8125
4
def gcd(x, y): while(y): x, y = y, x % y return x def lcm(x, y): lcm = (x*y)//gcd(x,y) return lcm a,b,c = [int(i)for i in input().split()] print("yes" if lcm(a,b)<=c else "no")
da86088e31bddea3277897f4b73c50ac55bd79bd
ROF618/Think_Python
/CS9.4.py
891
4.09375
4
fin = open("word.txt") #function must return true if word contians only letters found in required letters def uses_only(word, required_letters): # make the for loop break the word out into single characters and then we will check they match required letters broken_down_word = [] required_letters_list = [] ...
2330141220c044d8e6b185b530cd1ff204a50c6c
ROF618/Think_Python
/ex10.1.py
321
4.03125
4
def nested_sum(ints): int_nested = [] total = 0 for num in ints: if num != int: for x in num: return x int_nested.extend(num) for single_int in int_nested: total += single_int print(total) test = [1, 2, 3, 4, [22, 24, 25], 5, 6] nested_sum(test...
5295d787e56b91cf2c0da9cfc0ebb630fadba1c4
ROF618/Think_Python
/CS9.8.py
324
3.75
4
def check_palindrome(numbers): num_list = [] i = 0 for digit in str(numbers): num_list.append(int(digit)) num_list_reversed = list(reversed(num_list)) while i < len(num_list): if num_list[i] == num_list_reversed[i]: print(num_list[i]) i += 1 check_palindrome(5...
91fa6a5a670b9f36519d9c140edcaec497407549
Q-debug410/jtc_class_code
/challenges/03_primitive_data_types_part_1/temperature.py
232
3.921875
4
# # formula to convert farenheit to celsius celsius_100 = (100-32)*0.55 print(celsius_100) celsius_0 = (0-32)*0.55 print(celsius_0) print((32.4-32)*0.55) celsius_5 = (5/.55)+32 celsius_temp = (30.2/.55)+32 print(celsius_temp)
c9cdf770bad77b9c76b88b97fc56ef5efec8489a
JavierLario77/practicaSeguridadPython
/menucripto-javierlario/main.py
1,982
3.796875
4
import hashlib #creo la funcion que muestra el menu y guarda el numero que le pasamos en una variable def menu(): while True: try: respuesta=input("FUNCIONES HASH \n 1-Resumen MD5 de una cadena \n 2-Resumen SHA1 de una cadena \n 3- Resumen MD5 de un fichero \n 4-Resumen SHA1 de un f...
fa9b11ca7b2585bf2a854f72e9e00b2da8e9f2f6
LakshayDutta14/Sorting-Visualizer
/bubblesort.py
699
3.640625
4
import time def bubble_sort(data,drawdata,timetick):#timetick mein speed scale se value aayegi for _ in range(len(data)-1): for j in range(len(data)-1): if data[j]>data[j+1]: data[j],data[j+1]=data[j+1],data[j] drawdata(data,['green' if x==j or x==j+1 else '...
06cd5b767981d540bfdae6f1e35ea599eaf2da59
Beck-Haywood/Homework4SPD
/findUniqueLetters.py
313
3.953125
4
def findSubstring(string): arr = [] current_longest = [] for letter in string: if letter in arr: if len(current_longest) < len(arr): current_longest = arr arr = [] arr.append(letter) return current_longest print(findSubstring('qwerqtyuq u'))
640736fe18ecd44c6b6edb88ebbe8af012a47dbc
schintatkun/algorithms
/Python/Array/sumArray.py
288
3.96875
4
#Sum array #Solution 1 #Time complexity = O(N) def sumArr1(n): result = 0 for x in range(n+1): result += x print(result) return result sumArr1(5) #Solution 2, using Math formula #Time complexity = O(1) def sumArr2(n): return (n*(n+1)/2) print(sumArr2(5))
2565f801d57e2303117e0e53ac46c18c4327796b
felipe265/devops-aula06
/src/primos.py
198
3.609375
4
n = int(input()) for i in range(1, n+1): divisores = 0 for divisor in range(1, i+1): if i % divisor == 0: divisores += 1 if divisores == 2: print(i, end=' ')
5dd7082c0ffd525b91b926d9f8b343e50b22d364
diogo55/OnlinePythonTutor
/v1-v2/test-programs/newstyle_class.py
152
3.609375
4
class A(object): bla = "A" def __init__(self): self.blb = "B" def x(self): self.bla = self.blb a = A() a.x() print a.bla print A.bla
f6a76abd639f3455631ce0c695b536128a2577bb
diogo55/OnlinePythonTutor
/v1-v2/tutorials/advanced/map.py
156
3.5625
4
def square(x): return x*x def map(f, lst): ret = [] for elt in lst: ret.append(f(elt)) return ret y = map(square, [1,2,3,4,5,6])
d281d88a609d141b84a1572b2b5f8759a2d17ebd
jimdoran-26/structures
/interview-questions/monotonic.py
384
3.75
4
# Given an array of integers, determine whether the array is monotonic or not. def solution(arr): inc=0 dec=0 for i in range(len(arr)-1): if arr[i]<arr[i+1]: inc=1 elif arr[i] > arr[i+1]: dec=1 return dec ^ inc A = [6, 5, 4, 4] B = [1,1,1,3,3,4,3,2,4,2] C = [1,1...
9e1a8285776ddf8d6bf917665ec082cc2ab2ff58
fanosA/PythonSolvedProblems
/Paying_the_minimum.py
943
4.21875
4
r""" Problem 1: Paying the Minimum 10.0/10.0 points (graded) Write a program to calculate the credit card balance after one year if a person only pays the minimum monthly payment required by the credit card company each month. The following variables contain values as described below: balance - the outstanding balanc...
11eee9f4c482f81084e09855677f7d68c0afb4a2
fanosA/PythonSolvedProblems
/Counting_Vowels.py
873
3.921875
4
r"""Counting Vowels 10.0/10.0 points (graded) Assume s is a string of lower case characters. Write a program that counts up the number of vowels contained in the string s. Valid vowels are: 'a', 'e', 'i', 'o', and 'u'. For example, if s = 'azcbobobegghakl', your program should print: Number of vowels: 5 For problems ...
1a4e31e0e09ebeae978acdc6c232096f8577dd88
bzerath/Miscellaneous
/Gwenaelle/data_structures.py
7,244
3.953125
4
""" Queue : X -> [XXXXXXX] -> X Stack : X <-> [XXXXXXX] """ import Gwenaelle.stacks as stacks import Gwenaelle.queues as queues def exercice_1_1_v1_reverse(given_stack): output = stacks.create_stack() while not stacks.is_empty(given_stack): output = stacks.s_push(output, stacks.peek(given_...
30653c3a285fe96adad126f7c7cc2a225409c415
bzerath/Miscellaneous
/Gwenaelle/tri/algos.py
5,231
3.625
4
import random def selection_sort(tab): for i in range(len(tab)): min_pos = i # Recherche du plus petit élement du reste de la liste for j in range(i+1, len(tab)): # pour chaque élément à droite du pivot if tab[j] < tab[min_pos]: # on checke s'il est le plus petit ...
ff5aba206fc1cf28cb2763b76bc18ad41dbb127f
bzerath/Miscellaneous
/Pb_de_5e.py
545
3.921875
4
def check_triangle(a, b, c): if a + b + c > 20: return False if a >= b+c or b >= a+c or c >= a+b: return False else: return True if __name__ == "__main__": resultat = set([tuple(sorted((A, B, C))) for A in range(1, 20) for B in range(1, 2...
3fe4be840922fe6c861e952acace4cb29da90fd7
patrickfuchs/buildH
/buildh/lipids.py
3,756
3.53125
4
""" Module for the lipid topology json files. This module contains functions for parsing the json files. """ import pathlib import json # Directory name of the json files JSON_DIR = "lipids" # Absolute path of the json files PATH_JSON = pathlib.Path(__file__).parent / JSON_DIR def read_lipids_topH(filenames): "...
82b9dea8b117f2e69e0a20e82790dda53b786970
Tyrest/pyOthelloTournament
/player.py
1,559
3.578125
4
#!/usr/bin/env python """ player.py Humberto Henrique Campos Pinheiro Human and Computer classes """ from evaluator import Evaluator from config import WHITE, BLACK from minimax import Minimax import random def change_color(color): if color == BLACK: return WHITE else: return BLACK class H...
c926b17f822dcf199c94bad57f9ebe06bd5afb37
fragosoluana/id-human-activity
/BoxDimensionality.py
4,902
3.578125
4
''' Name: Flaviu Vadan Date: Mon, Jun 17th, 2016 Email: flaviuvadan@gmail.com DISCUS Lab Modifications by: Luana Fragoso Date: Mon, Jun 25th, 2017 Email: luana.fragoso@usask.ca DISCUS Lab Algorithm for determining the intrinsic dimensionality, or box-counting dimensionality, of a data set. Given a database th...
7d97b09e9c40fa61cdf723de102bc11132d92512
jordanrsteele/CTCL
/chapter_1/palindrome_permutation.py
563
3.828125
4
from collections import Counter # returns all possible permutations of a string def palindrome_permutation(myString): counter = Counter() for c in myString: counter[c] += 1 start = 0 end = 1 s = [] for key in counter: if counter[key] >= 2: s.insert(start, key) ...
0f5b87679ed9664aa7967c314c0ff66e84833327
jordanrsteele/CTCL
/chapter_3/sort_stack.py
476
3.859375
4
from random import * def sort_stack(stack): temp_stack = [] while stack: temp = stack.pop() # if top of temp stack is greater than temp while temp_stack and temp_stack[len(temp_stack)-1] > temp: stack.append(temp_stack.pop()) # add temp to temp_stack temp...
d31aeefafa7a779c90503f2922098cebcb9775b1
jordanrsteele/CTCL
/chapter_2/singleLinkedList.py
1,123
3.796875
4
class Node: def __init__(self, data=None, next=None): self.data = data self.next = next class singleLinkedList: def __init__(self): self.head = None self.tail = None def add(self, data): new_node = Node() new_node.data = data # list ist empty ...
ffb55bf2180b232f55073a6020e3b654bd646c93
John-Beam/Learning_Python
/PycharmProjects/Learning_Python/002_Logical_Type.py
2,301
4.15625
4
# -*- coding: UTF-8 -*- import datetime import calendar year = datetime.date.today().year print(year) year=2020 print(year) is_leap=year%4 == 0 and (year%100!=0 or year%400==0) print(is_leap) print(calendar.isleap(2020)) ######################## #Строки и операции с ними quote="а роза упала на лапу азора" print(quot...
f32099247afddbe0285db3f6e2d764c734be3e67
odenas/cs231n
/assignment1/cs231n/classifiers/softmax.py
3,983
3.859375
4
import numpy as np from random import shuffle #from past.builtins import xrange def softmax_loss_naive(W, X, y, reg): """ Softmax loss function, naive implementation (with loops) Inputs have dimension D, there are C classes, and we operate on minibatches of N examples. Inputs: - W: A numpy ar...
df2c50f0153e50b0a4a2d7bbc03288b510b305f5
PaulCardoos/SectionCode_CIP
/8ball.py
1,097
4.375
4
""" Simulates a magic eight ball. Prompts the user to type a yes or no question and gives a random answer from a set of prefabricated responses. """ #we need to import random here in order to generate a random index for our responses import random #our responses are global meaning we can access them from anywhere in t...
67f684567f773e98e52f46819cee9562e8da2bd1
Jesus-E-Rodriguez/pyparticles
/game/game.py
1,978
3.515625
4
"""Custom game class.""" from __future__ import annotations from pygame.color import Color from typing import List, Any, Tuple, Union, Callable from .utils import Window import pygame import sys # Wrapper game class, for ease of use class Game(object): """Models a game class.""" def __init__(self, window_si...
f5bea9a6bfd7318fad2a50cb3a06e1fca5d2da9f
M0nica/python-foundations
/01/homework-1/homework-1-powell.py
4,025
4.125
4
# Monica Powell # May, 23rd, 2016 # Homework 1 year_of_birth = input("What year were you born?") age = 2016 - int(year_of_birth) if age < 0: year_of_birth = input("Give me a year that is not in the future! What year were you really born?") age = 2016 - int(year_of_birth) print("You are approximately ", age, ...
b7c32c0fa00e3763b0031e7c1583cb92e0bc0f77
6thfdwp/pyalg
/sort/sort.py
2,207
4.28125
4
""" # 4,2,1,5,3 # 2,4,[1],5,3 lastSortedIdx = 1 # 1,2,4,[5],3 lastSortedIdx = 2 In place sorting """ def insertsort(A): """ Loop invariant: all items before i that's in current for loop are sorted efficient when most of items are already in sorted position Time: O(n^2) upper bound if in reverse order ...
940eedc78a677be3daf642f5e89bc66d73783ba3
6thfdwp/pyalg
/seq/interval.py
2,559
3.921875
4
def merge_intv(intervals): """ https://www.interviewbit.com/problems/merge-overlapping-intervals/ @params intervals (list of list) [(1,3),(2,6),(8,10],[15,18]] @return (list) [1,6],[8,10],[15,18] merged all overlapped intervals and sorted by start Clarify: If end of pre...
9bf008e419709494d4aef0f2ed1d1775ab4ab09f
6thfdwp/pyalg
/tree/build.py
3,974
3.6875
4
import random, array, tempfile, heapq from collections import deque from bstree import * """ Construct balanced BST with BFS """ def build_bintree(sortedlist): """ Simulate BFS, insert level by level, e.g for array with 8 items first mid in the 8 items (0-3-7) then mid in the left half (0-1-2) the...
9d4b28d0e8f73d4d8ce771bf8a5797d767d97aa3
6thfdwp/pyalg
/tree/walk.py
2,181
3.84375
4
""" 9 / \ 4 10 / \ \ 3 6 15 / \ 5 20 """ from collections import deque from bstree import * def walk_preorder(root): """ @return (list): [9, 4, 3, 6, 5, 10, 15, 20] middle -> left-sub -> right-sub ...
8d5227bb991dded5034a5c970f6881bff6aaef92
msoro/netology_pyda
/pyda13-hw02.py
6,834
4.1875
4
# Задание 1 # Дана переменная, в которой хранится слово из латинских букв. Напишите код, который выводит на экран: # среднюю букву, если число букв в слове НЕчетное (ошибка в задании на сайте); # две средних буквы, если число букв (не)четное (ЧЕТНОЕ). # Примеры работы программы: # word = 'test’ # Результат: # es # word...
97cc775f7e2f08311674fa4974cc6741e9e34235
supermao/Interview_Street_Questions
/In Progress/Coin on the Table/Python/coin_on_the_table.py
4,319
3.625
4
from copy import deepcopy class Game: DESTINATION = '*' MOVE_UP = 'U' MOVE_DOWN = 'D' MOVE_LEFT = 'L' MOVE_RIGHT = 'R' POSSIBLE_MOVES = [MOVE_UP, MOVE_DOWN, MOVE_LEFT, MOVE_RIGHT] def __init__(self, N, M, k): self.board = [[None] * M for i in xrange(N)] self.destCell = Non...
5e95fc93e9551fb8d7c9faa8f6fce2f677f17b3b
supermao/Interview_Street_Questions
/In Progress/Save Humanity/Python/save_humanity_kmp.py
6,553
3.96875
4
MISMATCH_TOLERANCE = 1 # Function: Z_Algorithm(word) # Usage: table = Z_Algorithm("aabcaabxaaaz") # ------------------------------------------------------------------------------ # The Z Algorithm finds, for each position in the specified word, the maximal # number of consecutive characters starting at that position ...
aa39012d6e7c36aee15ad638ab7f7a61dfdbe341
supermao/Interview_Street_Questions
/All Passed/Even Tree (C++, Java, Python)/even_tree.py
5,317
3.984375
4
# File: even_tree.py # Author: Chris Lewis (cmslewis@gmail.com) # ----------------------------------------------------------------------------- # This program offers a solution to the "Even Tree" challenge on the # InterviewStreet website (URL: https://www.interviewstreet.com/challenges/ # dashboard/#problem/4fffc24d...