blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
16cf6f60ce743abd1698187a6c8107793a9e9049
HelloYeew/helloyeew-computer-programming-i
/6310545566_Phawit_ex6/ex6_files/try2.py
1,590
3.859375
4
import csv # open Cities.csv file with csv.DictReader and read its content into a list of dictionary, cities_data cities_data = [] with open('Cities.csv', 'r') as f: rows = csv.DictReader(f) for r in rows: cities_data.append(r) # open Countries.csv file with csv.DictReader and read its content into a ...
cef5e148783afa94b122a1d583959097fee526af
HelloYeew/helloyeew-computer-programming-i
/Projects/task1/poly.py
3,857
3.59375
4
import numpy class Polynomial: def __init__(self, num_list): self.for_numpy = numpy.poly1d(num_list) self.num_list_original = num_list self.__num_list = num_list self.final_answer = "" self.other_object = ... def give_list(self): return self.__num_list def ...
b0a74a6e2ce7d3392643479ebbd4280ec9ce554e
HelloYeew/helloyeew-computer-programming-i
/Fibonacci Loop.py
611
4.125
4
def fib(n): """This function prints a Fibonacci sequence up to the nth Fibonacci """ for loop in range(1,n+1): a = 1 b = 1 print(1,end=" ") if loop % 2 != 0: for i in range(loop // 2): print(a,end=" ") b = b + a pr...
abc0cd5c971ca82768256b5ebd641c3ab9832c76
HelloYeew/helloyeew-computer-programming-i
/6310545566_Phawit_ex8/6310545566_Phawit_ex8/play_mastermind.py
395
3.59375
4
from mastermind import * new_game = MasterMindBoard() while True: print(new_game.show_number()) input_guess = input("What is your guess?: ") print('Your guess is', input_guess) if new_game.check_guess(input_guess) == False: print(new_game.display_clue()) print() else: print(...
3dd5303392fe607aa21e7cefce97426d59b90e49
HelloYeew/helloyeew-computer-programming-i
/OOP_Inclass/Inclass_Code.py
1,881
4.21875
4
class Point2D: """Point class represents and operate on x, y coordinate """ def __init__(self,x=0,y=0): self.x = x self.y = y def disance_from_origin(self): return (self.x*self.x + self.y*self.y)**0.5 def halfway(self, other): halfway_x = (other.x - self.x) / 2 ...
0e4fa88d43f58b9b26ebdaec0fb728e23271b2a4
HelloYeew/helloyeew-computer-programming-i
/try2.py
607
3.953125
4
def diamond(n): n = n + 1 loopup = 0 star = 0 while loopup < n: star += 1 print_star = "*" * (star * 2) front_back = " " * int(((n * 2) - len(print_star)) / 2) print(f" {front_back}{print_star}") loopup += 1 while loopup > 0: print_star = "*" * (star *...
5c4e2bdb74dd1f8a9c5f82427acf1e7dc4b2c790
HelloYeew/helloyeew-computer-programming-i
/6310545566_Phawit_ex3/polygon_art.py
636
3.890625
4
import turtle import random turtle.speed(25) turtle.setheading(0) def polygon(x, y, size, n, clr): turtle.penup() turtle.color(clr) turtle.fillcolor(clr) turtle.goto(x, y) turtle.pendown() turtle.begin_fill() for i in range(n): turtle.forward(size) turtle.left(360 / n) ...
d101318dbf12545644a06c53067ca33e0f6ccaec
valevo/LexicalChoice
/compound_splitter.py
901
3.609375
4
#!/usr/bin/python import sys import fileinput import argparse def load_dict(file): splits = {} with open(file) as f: for line in f: es = line.decode('utf8').rstrip('\n').split(" ") w = es[0] indices = map(lambda i: i.split(','), es[1:]) splits[w] = [] ...
bb7dc181239fe833015e83bf9061cc7e5045fbd9
JordanAceto/LED-chaser-game
/src/Timer.py
657
3.5625
4
import time class Timer(): def __init__(self, sample_period): ''' set up the initial sample period and last tick ''' self.sample_period = sample_period self.last_tick = time.time() def outatime(self): ''' return True if the timer has expired, else ...
df24007be07bfa188fb0a80fa63ee538d5f8ada9
alphak007/Training
/toi2.py
607
3.671875
4
row1=list() row2=list() row3=list() row4=list() row5=list() row1.append(1) n=row1[0] n+=3 for i in range(n,n+2): row2.append(i) n=row2[-1]+3 for i in range(n,n+3): row3.append(i) n=row3[-1]+3 for i in range(n,n+4): row4.append(i) n=row4[-1]+3 for i in range(n,n+5): row5.append(i)...
390a1a743fd32d1c547513983bc3f23a9a3b3ef7
Rchana/python-projects
/patient-records.py
1,287
4.03125
4
class patientRecord: # values shared amoung all instances of the class patientCount = 0; # constructor called to initialize new instance def __init__(self, name, healthCardNumber, age, gender): self.name = name self.healthCardNumber = healthCardNumber self.age = age self...
cba7f3eb2893ddd773800b8bbd644b43766693aa
jolubanco/estudos-python-oo
/oo/teste.py
367
3.609375
4
def cria_conta(numero,titular,saldo,limite): conta = { 'numero' : numero, 'titular': titular, 'saldo' : saldo, 'limite' : limite } return conta def deposita(conta,valor): conta['saldo'] += valor def saca(conta,valor): conta['saldo'] -= valor def extrato(conta): ...
175a34cd4447011b7090684bead66bcd63870851
fenrirs/LeetCode
/sum_root_to_leaf_numbers.py
1,326
3.96875
4
#https://oj.leetcode.com/problems/sum-root-to-leaf-numbers/ '''Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the total sum of all root-to-leaf numbers. For example, 1 / \...
6c91df3269280f87f4e8b16d4f7b94aa2082ccb5
fenrirs/LeetCode
/implement_strstr.py
530
3.9375
4
#https://oj.leetcode.com/problems/implement-strstr/ '''Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.''' class Solution: # @param haystack, a string # @param needle, a string # @return a string or None def strStr(self, h...
60b6cd6a276a41378caa234e0767f7d79990ce2a
fenrirs/LeetCode
/valid_parentheses.py
701
3.9375
4
#https://oj.leetcode.com/problems/valid-parentheses/ '''Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the correct order, "()" and "()[]{}" are all valid but "(]" and "([)]" are not.''' class Solution: # @return a ...
bd28eab5afcae116f3039f52e602fb30764a355f
fenrirs/LeetCode
/copy_list_with_random_pointer.py
1,072
3.84375
4
#https://oj.leetcode.com/problems/copy-list-with-random-pointer/ '''A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy of the list.''' # Definition for singly-linked list with a random pointer. # class RandomListNode:...
20ad12ab78c3aada7f7151970db06c3496a13f8f
fenrirs/LeetCode
/longest_common_prefix.py
607
3.6875
4
#https://oj.leetcode.com/problems/longest-common-prefix/ '''Write a function to find the longest common prefix string amongst an array of strings. ''' class Solution: # @return a string def longestCommonPrefix(self, strs): n = len(strs) if n==0: return '' minlen = min(len(s...
e42428038d4bf4238d52bc3ddce1c4f3bfdf944f
AbhAgg/Python-Codes
/login_app.py
2,951
3.6875
4
import tkinter from tkinter import * import tkinter.messagebox from sys import exit import pymysql def Welcome_Screen(): if len (e1.get())==0 or len(e2.get()) == 0: Label(text='Both entries are necessary. ',justify="left",wraplength=100).grid(row=4,column=1) else: string="SELECT * fro...
ac0eac144872639a215ace3a2160a4ab29e05e7b
AbhAgg/Python-Codes
/thread_example4.py
889
3.6875
4
import _thread import threading import threaded import time class thread1: def __init__(self,a): for i in range (0,len(x)): threadLock.acquire() print(x[i]+"\n") threadLock.release() time.sleep(1) class thread2: def...
5aa0f3b7b8b8ff0d330e56ce461a0f0454ba1c47
vipul-royal/A7
/gcd.py
177
3.953125
4
t=0 gcd=0 a=int(input("Enter the value of a:")) b=int(input("Enter the value of b:")) x=a y=b while b!=0: t=b b=a%b a=t gcd=a print("The GCD of",x,"and",y,"is:",gcd)
bba1d2dd5f7133b487ab4d7c469e62c3f26ccbdd
franvergara66/Python_sockets
/python/1s.py
978
3.875
4
#+----------------------------------+ #| Server TCP/IP | #+----------------------------------+ import socket #Creo el objeto socket s = socket.socket() #Invoco al metodo bind, pasando como parametro una tupla con IP y puerto s.bind(("localhost", 9999)) #Invoco el metodo listen para escuch...
6c43b0598523c3590ba54dfc962af52baa71074f
thevindur/Python-Basics
/w1790135 - ICT/Q1A.py
459
4.125
4
n1=int(input("Enter the first number: ")) n2=int(input("Enter the second number: ")) n3=int(input("Enter the third number: ")) #finding the square values s1=n1*n1 s2=n2*n2 s3=n3*n3 #finding the cube values c1=n1*n1*n1 c2=n2*n2*n2 c3=n3*n3*n3 #calculating the required spaces for the given example x=" "*5 x1=" "*4 y="...
4fef20fe627a0889b68856fd64392612b0830776
rafaelferrero/aula25py
/ejercicios1/rafaelferrero_29087702/ejercicios.py
1,271
3.765625
4
# -*- coding: utf-8 -*- from funciones import * from decimal import * print(divide_enteros_y_al_cuadrado(42, 3) == 196) print(divide_enteros_y_al_cuadrado(42, 5.5) == 49) print(divide_enteros_y_al_cuadrado(42, 0.5) == 7056) print(convierte_a_decimal_y_multiplica('4.5', 2) == Decimal('9.0')) print(convierte_a_decimal...
9370080bd1e7fe88b5cdd7e534f6d44cde1118b0
TecProg-20181/03--Mateusas3s
/hang.py
4,844
3.71875
4
import random import sys import string class Words: def __init__(self): self.wordlist_filename = "words.txt" def getWordlistFilename(self): return self.wordlist_filename def loadWords(self): """ Depending on the size of the word list, this function may take a whi...
8b1441d35c30aec092684983a016553284c6e926
Kaspazza/Python_recipes_application
/common.py
3,936
3.65625
4
import imports import algorithms import note # Read input from user def getch(): import sys, tty, termios fd = sys.stdin.fileno() old_settings = termios.tcgetattr(fd) try: tty.setraw(sys.stdin.fileno()) ch = sys.stdin.read(1) finally: termios.tcsetattr(fd, termios.TCSADRAIN...
e7f43f7f4d079ea9fdb9ed6a5da83b2b1c63982f
dean2727/Namex
/namex.py
1,906
3.84375
4
''' Namex: a command line-based program that allows a user to rename all files in a directory. by Dean Orenstein, Edited 6/3/19, 11/12/19 ''' # Import libraries from os import * #~~~ Useful methods ~~~# # listdir(path): os, returns a list of the items in that directory # remove(path, dir_fd=None): os, delete the fil...
44888c3249333f8888c6655a68e13515f72489ea
JasonMTarka/Password-Generator
/password_generator.py
3,324
4
4
from typing import Any from random import choice, shuffle class Password: """Set password generation parameters and generate passwords.""" _STR_OR_INT = str | int def __init__( self, lowercase: _STR_OR_INT = 1, uppercase: _STR_OR_INT = 1, nums: _STR_OR_INT = 1, sy...
2905e3872d902ee20de3c262833692dd3b966f75
vanj81/python
/Задача 3.py
306
3.578125
4
#coding: utf-8 age = int(input('Пожалуйста укажите ваш возраст: ')) if age >= 18: print('Доступ разрешен') access = True # доступ куда-либо else: print('Доступ запрещен') access = False # доступ куда-либо
fdd13bbcbacef17a715629a599e11ff0ffab0848
wasfever2012/huilvjs
/52weekv3.py
925
3.796875
4
# conding = utf-8 """ 作者:shao 功能:52周存钱计算 版本:V3.0 使用for循环 时间:2018-11-18 20:42:41 """ import math def main(): """ 主函数 :return: """ money_per_week = 10 # 每周存入金额 i = 1 # 周数记录 increase_money = 10 # 递增的存额 total_week = 52 # 总共时间(周数) saving =...
bbacd3803582ed1b472670dde3e7df2245bd26dd
wasfever2012/huilvjs
/lecture02-3.py
861
4.09375
4
# coding = utf-8 """ 作者:shao 功能:分形树1-turtle使用 版本:v2.0-绘制渐大五角星 版本:v3.0-迭代函数 时间:2018年11月15日23:04:28 """ import turtle def draw_pentagram(size): """ 绘制一个五角星 :return: """ # 计数器 count = 1 while count <= 5: turtle.forward(size) turtle.right(144) cou...
11ff5eb9c3ba36b44135c2ea8ba781f6afa4e0a8
zh85hy/python-demo
/spider/spider.py
2,774
3.5
4
import re import ssl # from urllib import request import urllib.request as ur class Spider: # url = 'https://www.panda.tv/cate/kingglory' url = 'https://www.douyu.com/directory/game/wzry' # headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0'} headers = {...
aecbec65c508470c367728791c3d0646d9a6426e
WitoldRadzik04/n-root-Calc
/sqrt.py
824
3.921875
4
num = int(input("Input num to be n rooted:\n")) n = int(input("Input n\n")) def sqrt(num): tnums = num a = 0 if(tnums>=1000000): a = 500 elif(tnums>=10000): a = 400 elif(tnums>=1000): a = 300 elif(tnums>=80): a = 200 else: a = 100 for i in range(a): tnums = (tnums + num/tnums)/2 #p...
abe9f3bdb1f8d872f1c96b705bb1e7e89d61e575
chaimleib/intervaltree
/test/intervals.py
3,929
3.515625
4
""" intervaltree: A mutable, self-balancing interval tree for Python 2 and 3. Queries may be by point, by range overlap, or by range envelopment. Test module: utilities to generate intervals Copyright 2013-2018 Chaim Leib Halbert Licensed under the Apache License, Version 2.0 (the "License"); you may not use this fi...
a0519e36bce108138f822d346f8c9e267c9b2b11
gcpeixoto/FMECD
/_build/jupyter_execute/ipynb/06a-introducao-pandas.py
17,311
4.125
4
# Manipulação de dados com *pandas* ## Introdução *Pandas* é uma biblioteca para leitura, tratamento e manipulação de dados em *Python* que possui funções muito similares a softwares empregados em planilhamento, tais como _Microsoft Excel_, _LibreOffice Calc_ e _Apple Numbers_. Além de ser uma ferramenta de uso gratu...
6dc7111834363e610fde5cbb18a4d48156d7e2f1
gcpeixoto/FMECD
/_build/jupyter_execute/ipynb/06b-pandas-dataframe.py
24,063
4.09375
4
# Operações com *DataFrames* Como dissemos anterioremente, o *DataFrame* é a segunda estrutura basilar do *pandas*. Um *DataFrame*: - é uma tabela, ou seja, é bidimensional; - tem cada coluna formada como uma *Series* do *pandas*; - pode ter *Series* contendo tipos de dado diferentes. import numpy as np import pandas...
765d8781c32f938bf3174f675c223fe72ee4d115
harimha/PycharmProjects
/Modules_usage/Syntax_built-in_usage.py
17,976
3.9375
4
""" This documents has been writing to show how to use python syntax and built-in module/function navigator # syn : ... : syntax # bi : ... : built_in function or module # method : ... # : comments / examples """ # syn : is """ id object가 같은지 비교 id(a) == id(b) 비교와 같음 """ a = [1,2,3] b = [1,2,3] a == b # True a i...
8caac84b2f1ec8350cb3117cf9c94143ed5fa023
harimha/PycharmProjects
/Modules_usage/데이터 시각화_활용.py
5,345
3.5625
4
""" Python 시각화 라이브러리 1. matplotlib 2. seaborn 3. plotnine 4. folium 5. plot.ly 6. pyecharts """ import pandas as pd import numpy as np import matplotlib import matplotlib.pyplot as plt # 1. matplotlib """ https://matplotlib.org/index.html """ print("Matplotlib version", matplotlib.__version__) # 버전확인 # plt.figure ""...
024442b68a04a0822ff02711b939005b071f6d1b
harimha/PycharmProjects
/Modules_usage/networkx_usage.py
7,233
3.640625
4
""" NetworkX is a Python package for the creation, manipulation, and study of the structure, dynamics, and functions of complex networks. navigator # Theme : ... # Package : ... # Module : ... # Class : ... # Method : ... # : comments / examples """ import matplotlib.pyplot as plt import networkx as nx help(nx) # Cl...
dc91208aabddc8e4a8e41ef4be9323b4c5ceae7d
box-of-voodoo/python_old
/tkinter_/mesbox.py
444
3.578125
4
from tkinter import * import tkinter.messagebox root=Tk() messagebox.showinfo('asdas','asdasdasdasdasd') answer = tkinter.messagebox.askquestion('question','XX?') print (answer) tkinter.messagebox.showwarning('x','X') tkinter.messagebox.showerror ('y','Y') ans=tkinter.messagebox.askokcancel('Y','Y') print(ans) an...
43b077ab49a89e365f1af7fb4717303c7c94f9cc
box-of-voodoo/python_old
/logo/kvet.py
733
3.71875
4
from turtle import* Screen() t=Turtle() bgcolor('gray') x=0 t.up() t.bk(0) t.down() t.pen(speed=0,shown=False) t.color('red') colo=['red','orange','yellow'] col=['green','blue','cyan'] t.color('green') t.right(90) t.pen(pensize=5) t.fd(360) t.bk(360) t.pen(pensize=1) for i in range(60): x+=3 for z in range(3):...
a3d7635634dd825bbe878c121ce0cd37f2f4c6c4
tirtow/swe-study
/test-2/python/unpacking.py
787
3.9375
4
# unpacking def f(x, y, z): return [x, y, z] # * - requires iterables t = (3, 4) f(2, *t) # [2, 3, 4] f(*t, 2) # [3, 4, 2] - can do unpacking before position # f(x=2, *t) # * has higher precedence than pass by name, gets multiple # values for x # -------------------------------------...
415c453aefdbc94499dd3c6811886d7c6b48a6f1
Ushaakkam/python
/Input.py
190
3.953125
4
x=int(input("enter the value x value:")) y=int(input("enter the value y value:")) z=int(input("enter the value z value:")) print(max(x,y,z)) input("please press enter to exit")
604a599edc09ff277520aadd1bb79fb8157272ee
pallu182/practise_python
/fibonacci_sup.py
250
4.125
4
#!/usr/bin/python num = int(raw_input("Enter the number of fibonacci numbers to generate")) if num == 1: print 1 elif num == 2: print 1,"\n", 1 else: print 1 print 1 a = b = 1 for i in range(2,num): c = a + b a = b b = c print c
021a5f8669dc4f4c530e585af0b536260e1bc76e
DSoutter/PDA_Dynamic_and_Static_Testing
/part_2_code/tests/card_game_tests.py
754
3.765625
4
import unittest from src.card import Card from src.card_game import CardGame class TestCardGame(unittest.TestCase): def setUp(self): self.card1 = Card("Spades", 1) self.card2 = Card("Hearts", 2) self.cards_total = [self.card1, self.card2] def test_highest_card(self): s...
9893c2f8cc419202264698832fb95648a9b8ae41
wpzy/csdn
/del.py
218
3.625
4
#coding:utf-8 import sys import os import re for line in sys.stdin: if len(line)<=0: continue line=line.strip() line=line.decode('utf-8') tmp=line.strip().split(' ') if len(tmp)==2: print line.encode('utf-8')
ab264a97323768b302003da89876e6ba04dd2c29
enterstry/flow-python
/v2/functions.py
548
3.5
4
from typing import Callable def int_to_str(data: int, output: Callable[[str, str], None]): # hier muss nun eine Typenkonvertierung stattfinden, # da der Eingang vom Typ Integer und der Ausgang vom Typ String ist. print("int_to_str", type(data)) output('out', str(data)) def str_to_int(data: str, outp...
ca5d8a47171f6b1fbc2d53f6648da8f0a6b9e900
km1414/Courses
/Computer-Science-50-Harward-University-edX/pset6/vigenere.py
1,324
4.28125
4
import sys import cs50 def main(): # checking whether number of arguments is correct if len(sys.argv) != 2: print("Wrong number of arguments!") exit(1) # extracts integer from input key = sys.argv[1] if not key.isalpha(): print("Wrong key!") exit(...
f9a991a8108218ae3b746c1e29a044dcbe074761
sergchernata/FooBar
/03c.py
3,047
3.515625
4
from itertools import repeat, count, islice from collections import Counter from functools import reduce from math import sqrt, factorial import time def factors(n): step = 2 if n%2 else 1 return set(reduce(list.__add__, ([i, n//i] for i in range(1, int(sqrt(n))+1, step) if n % i == 0))) def combinations(subset): ...
2bbdcb5f16abe238e8dc279da2ff14e1e8b2e1bd
sheilapaiva/LabProg1
/Unidade5/Karel_o_Robo/Karel_o_Robo.py
581
3.71875
4
#coding: utf-8 #Aluna: Sheila Maria Mendes Paiva #Matrícula: 118210186 #Unidade: 5 Questão: Karel o Robô x, y = 0, 0 while True: coordenada = raw_input().split() direcao = coordenada[0] unidade_movimento = int(coordenada[1]) if unidade_movimento == 0: print "Fim de jogo" break else: if direcao == "E": x...
bbf7527869c124395fe806004332bf1a01f6f246
sheilapaiva/LabProg1
/Unidade8/conta_palavras/conta_palavras.py
422
3.921875
4
#coding: utf-8 #UFCG - Ciência da Computação #Programação I e laboratório de Programação I #Aluna: Sheila Maria Mendes Paiva #Unidade: 8 Questão: Conta Palavras def conta_palavras(k, palavras): lista_palavras = palavras.split(":") cont = 0 for i in range(len(lista_palavras)): if len(lista_palavras[i]) >= k: ...
38ce7c743cacbb6a8063c172e403a46ce0ee8b1b
sheilapaiva/LabProg1
/Unidade7/desloca_elemento/desloca_elemento.py
491
3.90625
4
#coding: utf-8 #UFCG - Ciência da Computação #Programação I e laboratório de Programação I #Aluna: Sheila Maria Mendes Paiva #Unidade: 7 Questão: Desloca Elemento def desloca(lista, origem, destino): deslocar = True elemento_origem = lista[origem] while deslocar == True: deslocar = False for i in range(len(l...
d8cf4ed0da53322286aebba455da13faca4499ce
sheilapaiva/LabProg1
/Unidade4/serie_impares_1/serie_impares_1.py
205
3.65625
4
# coding: utf-8 # Aluna: Sheila Maria Mendes Paiva # Matrícula: 118210186 # Unidade 4 Questão: Série (ímpares 1) for i in range(1,103,2): if (i % 3 == 0): print "*" elif (i % 5 == 0): print "*" else: print i
5885ab9f922b74f75ae0ef3af2f1f0d00d2cd087
sheilapaiva/LabProg1
/Unidade8/agenda_ordenada/agenda_ordenada.py
621
4.125
4
#coding: utf-8 #UFCG - Ciência da Computação #Programação I e laboratório de Programação I #Aluna: Sheila Maria Mendes Paiva #Unidade: 8 Questão: Agenda Ordenada def ordenar(lista): ta_ordenado = True while ta_ordenado == True: ta_ordenado = False for i in range(len(lista) -1): if lista[i] > lista[i + 1]:...
d633716cdf39bab10a5a25c46415856871747153
sheilapaiva/LabProg1
/Unidade4/grep/grep.py
373
3.796875
4
# coding: utf-8 # Aluna: Sheila Maria Mendes Paiva # Matrícula: 118210186 # Unidade 4 Questão: Grep palavra = raw_input() numero_frases = int(raw_input()) for i in range(numero_frases): frase = raw_input() lista_palavra_frase = frase.split(" ") for j in range(len(lista_palavra_frase)): palavra_frase = lista_pa...
11c8853faad4f8916a73472af3844e081ad35703
sheilapaiva/LabProg1
/Unidade2/caixa_ceramica/caixa_ceramica.py
596
3.8125
4
#coding: utf-8 capacidade = float(raw_input("Capacidade de revestimento? ")) print "" print "== Dados do vão a revestir ==" comprimento = float(raw_input("Comprimento? ")) largura = float(raw_input("Largura? ")) altura = float(raw_input("Altura? ")) lateral1 = float(2 * (comprimento * altura)) lateral2 = float(2 * (...
a6436b94643cbdb160fcd14bbb1bf871e5fb1f96
sheilapaiva/LabProg1
/Unidade9/soma_moldura_k/soma_moldura_k.py
440
3.921875
4
#coding: utf-8 #UFCG - Ciência da Computação #Programação I e laboratório de Programação I #Aluna: Sheila Maria Mendes Paiva #Unidade: 9 Questão: Soma Moldura k def soma_moldura(m, k): soma = 0 for i in range(k, len(m) - k): for j in range(k, len(m[i]) - k): if i == k: soma += m[i][j] elif i == len(m...
d9679db27c23d1056abbc94e653c19cc5179c0b6
sheilapaiva/LabProg1
/Unidade4/arvore_natal/arvore_natal.py
233
3.78125
4
#coding: utf-8 altura = int(raw_input()) numero_o = 1 numero_espacos = 0 for arvore in range(altura): print " " * (numero_espacos + (altura -1)) + numero_o * "o" numero_o +=2 numero_espacos -= 1 print (altura - 1) * " " + "o"
776d471213c0cb7b7c549d3e7312dfab6f1746cf
sheilapaiva/LabProg1
/Unidade6/caixa_alta/caixa_alta.py
487
3.890625
4
#coding: utf-8 #Aluna: Sheila Maria Mendes Paiva #Matrícula: 118210186 #Unidade: 6 Questão: Caixa Alta def caixa_alta(frase): frase_modificada = "" frase = " " + frase + " " for i in range(1,len(frase) - 1): if frase[i - 1] == " " and frase[i + 1] == " ": frase_modificada += frase[i].lower() elif frase[i -...
2862ae6390595dbd6265849c0f96341077afa02a
didi1215/leetcode
/leetcode/leetcode/editor/cn2/[剑指 Offer 59 - II]队列的最大值.py
1,605
3.84375
4
# 请定义一个队列并实现函数 max_value 得到队列里的最大值,要求函数max_value、push_back 和 pop_front 的均摊时间复杂度都 # 是O(1)。 # # 若队列为空,pop_front 和 max_value 需要返回 -1 # # 示例 1: # # 输入: # ["MaxQueue","push_back","push_back","max_value","pop_front","max_value"] # [[],[1],[2],[],[],[]] # 输出: [null,null,null,2,1,2] # # # 示例 2: # # 输入: # ["Ma...
7a463545ad20fd7445dcc0846284a8679e749459
olgatarr/FaCLTarakanova
/hw3/hw3.py
349
3.734375
4
print('Введите три числа:') a = int(input('a = ')) b = int(input('b = ')) c = int(input('c = ')) if a*b == c: print(a, '*', b, ' = ', c) else: print(a, '*', b, ' != ', c) print(a, '*', b, ' = ', a*b, '\n') if a/b == c: print(a, '/', b, ' = ', c) else: print(a, '/', b, ' != ', c) print(a, '/', b,...
4b50d1346acd52620fff52b7af998043c69701a6
luispabreu/p3ws
/16_read_exn/code.py
594
3.765625
4
def f(x): if (x == 7): raise ValueError("f(7) is illegal") return (x+3)*2 def g(x,y): if (not isinstance(x,int)): raise TypeError("x must be an int in g(x,y)") return x + f(y) def h(x,y): try: return g(x,y-3) except ValueError as e: print(e) return 42 ...
1f4b5b3a2db6bec3dcb91521b09c07fb8956ebb7
luispabreu/p3ws
/01_read_fcn/code.py
251
3.8125
4
def another_function(a): b = a a += 2 print('a is ' + str(a)) print('b is ' + str(b)) print('a + b is ' + str(a + b)) return b def main(): x = 5 y = another_function(x) print('y is ' + str(y)) return 0 main()
bf92dbc9c73edbc655c53b42c9e14ed9871f3f68
luispabreu/p3ws
/07_list_max/listmax.py
1,059
3.546875
4
def listMax(list): if list == None: return None if list == []: return None max = list[0] for i in list: if max < i: max = i pass pass return max def doTest(list): print('listMax(',end='') if list == None: print('None) is '...
50ec2658e785df4348467b8e5b48a352c4ce85c3
anlsh/cs4803
/vocal-mimicry/discriminators/identity_dtor.py
4,203
3.65625
4
""" Architecture ==================================================================== The basic idea of this discriminator is to, given two voice samples, determine whether they belong to the same person. I opted for a Siamese-network approach to the problem, as described in (1): which is a paper on exactly this topic...
4e1d3a7bbecd6871b55f8cc775fb16be9305a6ce
markgalup/topcoder
/Solved/CardCount (SRM 161 Div. 2 250pts).py
712
3.5
4
class CardCount(object): def dealHands(self, numPlayers, deck): revdeck = list(deck) revdeck.reverse() hands = ["" for x in range(numPlayers)] while len(revdeck) >= numPlayers: for x in range(numPlayers): hands[x] += revdeck.pop() return hands ...
b501db930953f14e140e86d73914ce30f1674de0
markgalup/topcoder
/Unsolved/SRM 649 Div. 2 250 pts.py
316
3.75
4
class DecipherabilityEasy(object): def check(self, s, t): #s += " " for x in range(len(s)): print s[:x] + s[x+1:] if s[:x] + s[x+1:] == t: return "Possible" return "Impossible" print DecipherabilityEasy().check("sunmke", "snuke" )
67a879e2bbe86872838034ddd0ff25f941115479
sathishkumar01/Python
/Pattern/number/5.Floyds Triangle.py
133
3.703125
4
n=int(input('Enter n:')) a=0 for i in range(1,n): for j in range(1,i): a=a+1 print(a,end=" ") print()
b77a792dd71b63c3a8e3f0fbb5bcdedf9851380f
sathishkumar01/Python
/Pattern/Alphabets/T.py
174
4
4
for i in range(5): for j in range(7): if ((j==3 ) or (i==0)): print("*",end="") else: print(end=" ") print()
92026682a04db9c3a0559d0e29f02d514193fc29
sathishkumar01/Python
/Pattern/Alphabets/S.py
277
3.9375
4
for i in range(10): for j in range(8): if ((j==0 ) and i>0 and i<3) or ((i==0 or i==3) and (j>0 and j<6)) or ((j==7) and i>3 and i<=5) or ((i==6) and j>0 and j<6): print("*",end="") else: print(end=" ") print()
e9015a5e5384f0c69030c92744d9ac8b911c7751
sathishkumar01/Python
/Pattern/Alphabets/G.py
303
3.921875
4
for i in range(5): for j in range(6): if ((j==0 ) and i!=0 and i!=4) or ((i==0 ) and j>0 and j<5) or ((i==4) and j>0 ) or ((j==5) and i>=2 and i<5) or ((j==4) and i==2)or ((j==3) and i==2) : print("*",end="") else: print(end=" ") print()
bb67b5a4f7a6878544f445bf871eeeafb6f32dcc
sathishkumar01/Python
/19.Fibonacci.py
131
3.859375
4
n=int(input("Enter Number:")) a=1 b=1 print(a) print(b) for x in range(0,n+1): c=a+b; a=b; b=c; print(c)
b5b4f440a749ee18200f2479df34699c6928e1bc
sathishkumar01/Python
/Pattern/Alphabets/W.py
384
3.546875
4
for i in range(5): for j in range(12): if ((j==0) and i==0) or ((j==1) and i==1) or ((j==2) and i==2) or ((j==3) and i==3) or ((j==4) and i==2) or ((j==5) and i==1) or ((j==6) and i==2) or ((j==7) and i==3) or ((j==8) and i==2) or ((j==9) and i==1) or ((j==10) and i==0): print("*",end="") ...
b87e9b3fa5910c2f521321d84830411b624e0c39
SDSS-Computing-Studies/005a-tuples-vs-lists-AlexFoxall
/task2.py
569
4.15625
4
#!python3 """ Create a variable that contains an empy list. Ask a user to enter 5 words. Add the words into the list. Print the list inputs: string string string string string outputs: string example: Enter a word: apple Enter a word: worm Enter a word: dollar Enter a word: shingle Enter a word: virus ['apple', '...
d59fdd889061fdb58065c8d3d2aaf4509dbe76ca
ahmetcanbasaran/MU-CSE-Projects
/Extra/1.Intern(2017)_Middle_East_Technical_University_WINS_Lab/Works/OOP-Python/oop2.py
755
4
4
class Employee: raiseAmount = 1.04 numberOfEmployees = 0 def __init__(self, first, last, pay): self.first = first self.last = last self.pay = pay self.email = first + '.' + last + '@company.com' Employee.numberOfEmployees += 1 def fullName(self): return '{} {}'.format(self.first, self.last) def...
f9ca15657c71d4d67c4e02f82cc972e254526c62
ahmetcanbasaran/MU-CSE-Projects
/7.Semester/CSE4088 - Inroduction to Machine Learning/Homeworks/2/main.py
12,379
3.8125
4
############################################# # # # CSE4088 - Intro. to Machine Learning # # Homework #2 # # Oguzhan BOLUKBAS - 150114022 # # # ############################################...
25e432397ff5acb6a55406866813d141dc3ba2c2
jyu001/New-Leetcode-Solution
/solved/248_strobogrammatic_number_III.py
1,518
4.15625
4
''' 248. Strobogrammatic Number III DescriptionHintsSubmissionsDiscussSolution A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Write a function to count the total strobogrammatic numbers that exist in the range of low <= num <= high. Example: Input: low = "5...
8ca38071dc0271ec0c15a947543bfab9cb8afeba
jyu001/New-Leetcode-Solution
/solved/287_find_the_duplicate_number.py
1,016
3.984375
4
''' 287. Find the Duplicate Number DescriptionHintsSubmissionsDiscussSolution Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one. Example 1: Input: ...
038c31fd2ae5c53532f7eb1acdb46d8bf48a7991
jyu001/New-Leetcode-Solution
/solved/224_basic_calculator.py
2,232
3.90625
4
''' 224. Basic Calculator DescriptionHintsSubmissionsDiscussSolution Implement a basic calculator to evaluate a simple expression string. The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and empty spaces . Example 1: Input: "1 + 1" Output: 2 Exampl...
496fad266efb7da5320b0c1694e88c0b59f43359
jyu001/New-Leetcode-Solution
/unsolved/unsolved_312_burst_balloons.py
3,333
3.859375
4
''' 312. Burst Balloons DescriptionHintsSubmissionsDiscussSolution Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst balloon i you will get nums[left] * nums[i] * nums[right] coins. Here left and righ...
a28af6976e03d8fa8d8507b39755406c31f9cbfc
jyu001/New-Leetcode-Solution
/solved/234_palindrome_linked_list.py
1,728
3.890625
4
''' 234. Palindrome Linked List DescriptionHintsSubmissionsDiscussSolution Given a singly linked list, determine if it is a palindrome. Example 1: Input: 1->2 Output: false Example 2: Input: 1->2->2->1 Output: true Follow up: Could you do it in O(n) time and O(1) space? ''' # Definition for singly-linked list. # cl...
31e0e80766186110342b0c99930cdbaee68ae2a8
jyu001/New-Leetcode-Solution
/solved/95_unique_binary_search_tree_II.py
1,454
3.921875
4
''' 95. Unique Binary Search Trees II DescriptionHintsSubmissionsDiscussSolution Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1 ... n. Example: Input: 3 Output: [ [1,null,3,2], [3,2,null,1], [3,1,null,null,2], [2,1,3], [1,null,2,null,3] ] Explanation: Th...
ac7b6e0c203555acec76e7380d4252c767881768
jyu001/New-Leetcode-Solution
/solved/772_basic_calculator_III.py
3,407
3.890625
4
''' 772. Basic Calculator III DescriptionHintsSubmissionsDiscussSolution Implement a basic calculator to evaluate a simple expression string. The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and empty spaces . The expression string contains only non...
530f1fc8fb3d5693cf7ea5afe8d6a743f3bdf0ff
jyu001/New-Leetcode-Solution
/solved/44_wildcard_matching.py
5,691
3.9375
4
''' 44. Wildcard Matching DescriptionHintsSubmissionsDiscussSolution Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence). The matching should cover the enti...
367d6f206ce0300b7956b4babe6adcbdf8d5c473
jyu001/New-Leetcode-Solution
/solved/753_cracking_the_safe.py
2,373
3.65625
4
''' 753. Cracking the Safe DescriptionHintsSubmissionsDiscussSolution There is a box protected by a password. The password is n digits, where each letter can be one of the first k digits 0, 1, ..., k-1. You can keep inputting the password, the password will automatically be matched against the last n digits entered. ...
68f9e4d6787862d6b741682e62adb1a175699620
jyu001/New-Leetcode-Solution
/solved/654_maximum_binary_tree.py
1,212
3.984375
4
''' 654. Maximum Binary Tree DescriptionHintsSubmissionsDiscussSolution Given an integer array with no duplicates. A maximum tree building on this array is defined as follow: The root is the maximum number in the array. The left subtree is the maximum tree constructed from left part subarray divided by the maximum num...
0062d5c1383541388100388eac74846941dd2836
jyu001/New-Leetcode-Solution
/solved/77_combinations.py
844
3.640625
4
''' 77. Combinations DescriptionHintsSubmissionsDiscussSolution Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. Example: Input: n = 4, k = 2 Output: [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ] ''' class Solution: def combine(self, n, k): """ ...
eb30bd142d3a5add2fe99d5209cafd57e3cea02e
nikolakadic/kurs-uvod-u-programiranje
/predavanje-13/oo_nastavak/static_class_variables.py
383
3.671875
4
""" """ class Fruits: """ """ count = 0 # staticka atribut klase def __init__(self, name, count): self.name = name self.count = count Fruits.count += count apples = Fruits('apple', 10) pears = Fruits('pear', 20) print(getattr(apples,'count')) setattr(pears, 'count', 20...
e0e676f4eda6005dfe5bb2348bd032adc800f46c
nikolakadic/kurs-uvod-u-programiranje
/predavanje-04/petlje.py
666
3.765625
4
a = 5 b = 0 # <, >, ==, !=, and, or, not while b < a: #print('Poceo sam da izvrsavam tijelo petlje') b = b + 1 #print('b je sada ', b) # 1 - inicijalna vrijednost brojaca - range[0] # provjera uslova < range [posljednji clan niza] # povecava brojac brojac = brojac ...
1d3a7a293d517d8799bafa94b6bafaa414c401bd
nikolakadic/kurs-uvod-u-programiranje
/predavanje-08/tooo.py
1,252
3.75
4
""" Pocetak sudoku """ print("IGRATE IGRU SUDOKU") print("") gametable = [ [1, "", "","","","","","",8], ["", 2, "","","","","","",""], ["", "", 3,"","","","","",""], ["", "", "",4,"","","","",""], ["", "", "","",5,"","","",""], ["", "", "","","",6,"","",""], ["",...
7a78fdfe0f82c13209b873926b537be693b2beb7
nikolakadic/kurs-uvod-u-programiranje
/predavanje-12/debugger_tutorial.py
165
3.59375
4
x = 5 print(x) y = 20 print(y) for i in range(200): x = 20 print(i) x = 3 print(x) x = x + 5 + 3 print(x) # REGISTRI, STEK, HIP # REGISTERS, STACK, HEAP
9768625c56b1cae32950f73499e9ea78ab59db6e
FractalBoy/advent-of-code-2020
/ship.py
2,735
3.5625
4
from math import atan, cos, degrees, radians, sin, sqrt class UnitVector: def __init__(self): self.origin = 0, 0 self.theta = 0 def rotate(self, angle): self.theta += angle self.theta %= 360 if self.theta > 180: self.theta -= 360 def translate(self, *...
bad0d581be04c1d145b6874a81272980339da3ce
jghee/Algorithm_Python
/coding/ch6/sort2.py
295
3.625
4
n = int(input()) info = [] for i in range(n): name, score = input().split() info.append((name, int(score))) def setting(data): return data[1] result = sorted(info, key=setting) # result = sorted(info, key=lambda student: studnet[1]) for i in result: print(i[0], end=' ')
8298ec6c8af26231d9561b22a215758912eb667a
clchiou/uva-problem-set
/leetcode/148-sort-list/148.py
5,815
4.125
4
#!/usr/bin/env python3 # # NOTE: You cannot use recursion because stack growth is not # constant space complexity. # class Solution: def sortList(self, head): """ :type head: ListNode :rtype: ListNode """ if not head: return None if not head.next: ...
dc70a991b6d8e3f39f25dd2b4aad14e965cb45ef
clchiou/uva-problem-set
/leetcode/419-battleships-in-a-board/419.py
705
3.734375
4
#!/usr/bin/env python3 class Solution: def countBattleships(self, board): """ :type board: List[List[str]] :rtype: int """ num_ships = 0 for i in range(len(board)): for j in range(len(board[i])): if board[i][j] != 'X': ...
25ebbda61eedaea5aa42cd6017c68dbaad2d9cc9
clchiou/uva-problem-set
/leetcode/513-find-bottom-left-tree-value/513.py
1,315
3.875
4
#!/usr/bin/env python3 class Solution: def findBottomLeftValue(self, root): """ :type root: TreeNode :rtype: int """ leftmost = root.val queue = [root] while queue: leftmost = queue[0].val next_queue = [] for node in queue...
b6d388ca18178eeac5a1e102c00163f10e9884a2
clchiou/uva-problem-set
/leetcode/215-kth-largest-element-in-an-array/215.py
1,188
3.5625
4
#!/usr/bin/env python3 class Solution: def findKthLargest(self, nums, k): """ :type nums: List[int] :type k: int :rtype: int """ import random def solve(nums, nth): if len(nums) == 1: return nums[0] pivot_i = rando...
3b02429c502bd626af33425069025aa8cadac2c9
clchiou/uva-problem-set
/solved/138/solve.py
294
3.625
4
#!/usr/bin/env python3 import math import sys def main(): count = 10 n = 2 while count > 0: k = math.sqrt((n * n + n) / 2) if math.trunc(k) == k: print('%10d%10d' % (k, n)) count -= 1 n += 1 if __name__ == '__main__': main()
0974f977ae53592c7068e046686a84073d227dea
clchiou/uva-problem-set
/leetcode/338-counting-bits/338.py
833
3.765625
4
#!/usr/bin/env python3 class Solution: def countBits(self, num): """ :type num: int :rtype: List[int] """ output = [0] num_ones = 0 binary = [0] * (32 + 1) # Assume num < 2^32. for _ in range(1, num + 1): # Add 1 to `binary`. ...
eca8b4304251854b16c21e977a9f40a556a8211e
skylar02/HighSchoolCamp
/string_practice.py
2,700
4
4
""" title: string_practice author: Skylar date: 2019-06-11 13:45 """ import random #chara = input("Enter a character") #print("a" in chara or "b" in chara or "c" in chara or "d" in chara or "e" in chara or "f" in chara or "g" in chara or "h" in chara or "i" in chara or "j" in chara or "k" in chara or "l" in chara or "m...
cc919777e9f8abc405b711e93b64184543882331
ctl106/AoC-solutions
/2020/03/solution2.py
1,074
3.53125
4
#!/usr/bin/env python3 import sys from functools import reduce KEY = {"end": "!", "tree": "#", "empty": "."} def read_input_file(): inname = sys.argv[1] inlst = [] infile = open(inname, "r") for line in infile: inlst.append(line.strip()) infile.close return inlst def contents(loc, mymap): output = None ...