blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
e6dfe35066366a6655fabebb82d7c12bdaa9fa63
Asgavar/pork
/pork/entities.py
1,024
3.84375
4
import abc class WorldObject(abc.ABC): @abc.abstractmethod def description(self) -> str: pass class Door(WorldObject): def __init__(self, door_name: str, door_direction: str, is_open: bool = False) -> None: self._door_name = door_name self.door_direction = door...
9820e6a9b9f14734989d25df899dc3ec78bdda03
docxed/codeEjust
/Sequence V.py
239
3.578125
4
"""main""" def main(): """main function""" num = int(input()) cnt = 0 for j in range(num, 0, -1): if cnt == 7: print() cnt = 0 print(j, end=" ") cnt += 1 print() main()
700ee9093a2dbd55ebf6fb1028ca1c44eee76a9f
Ldarrah/edX-Python
/PythonII/3.3.3 Coding Problem sumloop.py
947
4.125
4
mystery_int = 7 #You may modify the lines of code above, but don't move them! #When you Submit your code, we'll change these lines to #assign different values to the variables. #Use a loop to find the sum of all numbers between 0 and #mystery_int, including bounds (meaning that if #mystery_int = 7, you add 0 + 1 + 2 ...
272eb367dcd7f410f9a63a754c8e8635a9306b03
AnnDWang/python
/DataStructure/ch5/Search.py
3,596
3.84375
4
def sequentialSearch(alist,item): pos=0 found=False while pos<len(alist) and not found: if alist[pos]==item: found=True else: pos=pos+1 return found testlist=[1,2,32,8,17,19,42,13,0] # print(sequentialSearch(testlist,3)) # print(sequentialSearch(testlist,13)) ...
10a34cf9da0e1b5200f6b1ef43f44b4c7e40db92
xddongx/study-python
/03.영어 단어 맞추기 게임/englishword-game.py
1,001
3.984375
4
''' 1. 영어단어장 만들기 2. 문제낼 랜덤한 단어장(단어장의 한글) 배열 만들기 3. 단어 맞출 기회 4. 기회만클 정답과 비교 5. 맞추면 정답, 틀리면 정답 출력 ''' import random, os, re os.system('cls') word_dict = { '사자': 'lion', '호랑이': 'tiger', '사과': 'apple', '바나나': 'banana', '음식': 'food' } quiz_word = [] for i in word_dict: quiz_word.append(i) random...
34f562b3701fc8c596e712c6bf487d807fea2c01
NoeliaHS/DamM09
/Ejercicio2.py
186
3.953125
4
'''Ejercicio 2: ''' a = int(input("Introduzca un número: ")) if a >= 10: print("El número introducido es correcto",a) else: print ("El número es inferior a 10") input()
ebeb71ccd8adfbad3659187380967aba61699c88
sylvaus/presentations
/python/code/exercise_solutions/09_exception.py
804
4.34375
4
""" Exercise 1 Write a code that asks the operator for its name and throws an exception if the string is longer than 20 characters """ def exercise1(): name = input("what is your name") if len(name) > 20: raise Exception("too long") exercise1() """ Exercise 2 Write a code that asks the operator for...
c892e6dfc1d41fb482b41297c643bdcddcbda603
Kjell-Nina/my_first_python_proyect
/Proyectos_basicos_de_python/converso.py
712
3.765625
4
def conversor(tipo_moneda,valor_dolar): moneda = input('¿Cuantos '+ tipo_moneda +' tines?: ') moneda = float(moneda) #valor_dolar = 4.025 se quita por que ya se invoca en la parte de función dolares = moneda / valor_dolar dolares = round(dolares,2) dolares = str(dolares) print('Tienes $'+ d...
37ab352a7cc7c78f25815b7f0a474873b43c0abe
shreyaspadhye3011/algoexpert
/Heaps/min_heap.py
3,897
3.859375
4
# Do not edit the class below except for the buildHeap, # siftDown, siftUp, peek, remove, and insert methods. # Feel free to add new properties and methods to the class. # Approach: Look at conceptual overview. # The implementation is based on two basic methods: siftUp & siftDown # peek: return min. heap[0] # siftUp:...
c4560293be628519f242be511c861de46a0e4e1c
ongsuwannoo/Pre-Pro-Onsite
/Super Extra Center_justify.py
151
3.5
4
""" [Super Extra] Center_justify """ def main(): ''' input ''' num = int(input()) cha = input() print(cha.center(num)) main()
2a67548049882a5870467afba3d7db9050e5281c
SalyaW/Binus_TA_Session_Semester_1
/Driving simulation.py
576
3.828125
4
u = 0 vlimit = 60 s = int(input("input distance:")) a = float(input("insert acceleration:")) t = int(input("input time:")) for i in range(0,t+1): s2 = int(0.5 * a * i * i ) s2 = int(s2/10) print("Duration:",i,"Distance:","*"* (s2)) v = t * a if v <= 60: v = t * a print("Was not over the speed limi...
9dc2e48cef08f424f58a59e02558711b18d8c459
daniel-reich/ubiquitous-fiesta
/xdSKkXQkkMroNzq8C_17.py
127
3.90625
4
def count_d(sentence): count = 0 for x in sentence: if 'd' == x or 'D' == x: count = count + 1 return count
a18d266c0e5d0157c7941e72a1b5cd10e58bfb68
Keerti-Gautam/PythonLearning
/Functions/FuncWithMultipleArgs.py
2,261
5
5
# You can define functions that take a variable number of positional args, which will be interpreted as a tuple by using * # Writing args and kwargs are not necessary, you can write var or vars and it would work the same def varargs(*args): return args print varargs(1, 2, 3) # => (1, 2, 3) # You can define func...
e3ce81207237709eccd7a8fe5d6d73578df0bf0f
YuanLiuLawrence/SoftwareForEmbeddedSytem
/Lab0/program4.py
474
3.8125
4
#Lab0-Program4-liu1827 def program4(): date = { "Albert Einstein": "03/14/1879", "Benjamin Franklin": "01/17/1706", "Ada Lovelace": "12/10/1815" } print("Welcome to the birthday dictionary. We know the birthdays of:") print("Albert Einstein"); print("Benjamin Franklin"); ...
88dc1ced4d71688f3adb938977db8f2d07e51580
jbanerje/Beginners_Python_Coding
/tic_tac_toe_test.py
1,901
3.890625
4
# This is the basic gaming structure print("***-----------Tic Tac Toe table---------------------------***") print(" [1,2,3]\n","[4,5,6]\n","[7,8,9]") print("***-------------------End---------------------------------***") play_count = 0 player1=[[1,2,3],[4,5,6],[7,8,9]] #Total 9 opportunities will be present f...
6c4f20fdfa7688452addaa77d00914b66828f365
legolas-zeng/scripts
/test.py
1,118
3.84375
4
# coding=utf-8 # @author: zwa❤lqp # @time: 2021/2/27 17:47 import os,re # a = 0 # b = 1 # n = 10 # # for i in range(n): # a,b = b,a+b # print(a) # def fib_yield_while(max): # a, b = 0, 1 # while max > 0: # a, b = b, a + b # max -= 1 # yield a # # # def fib_yield_for(n): # a, b = ...
fa15d06e0c9d40cfce38398d6bc557656173bc4f
marrerap/python_project
/window_choice2.py
636
3.6875
4
import time def Window2(): print() print() time.sleep(2) print('For some reason the idea of ending it all seems to be the best option') time.sleep(2) print('Why continue this game you\'re bored of.') time.sleep(2) print('You rush to the window, it opens as fast as you run to it.') ...
f27b1eef630572110df5e8cc72e06d6f700cd92b
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_200/5107.py
279
3.53125
4
t = int(input()) a = 0 while(a<t): thing = 0 num = int(input()) for i in range(num+1): word = str(i) arr = list(word) if sorted(arr) == arr: thing = arr ans = ''.join(thing) print("Case #" + str(a+1) +":" , ans) a=a+1
a1804f5612208fcf8618d5c72b238e993689fb83
ZirvedaAytimur/Reinforcement_Learning_For_Maze
/RandomActions.py
2,660
3.703125
4
import pygame from time import sleep from random import randint as r from common_functions import create_maze, act_random, layout, calculate_mse, is_done, is_user_exit, move n, display_maze, reward, obstacles, states = create_maze() actions = {"up": 0, "down": 1, "left": 2, "right": 3} # all actions current_positio...
be9930856e8fd84bf2e320d7547b60ee8389b389
Zedomas/HackerRank
/Python/Starecase.py
149
3.984375
4
def staircase(n): for x in range(1, n+1): if x < n: print((" " * (n - x)) + "#" * x) else: print("#" * x)
06c93b90caf8819524c527446b24795dc3e444fb
ayush879/python
/12.py
163
4.40625
4
#12) Return the year of the date from a given string. import re string = input("Enter a date : ") pattern = '.*([1-3][0-9]{3})' print(re.findall(pattern, string))
65f74f5018e3e78a6a8784469f56bb98d1f90a6c
YaoCheng8667/PythonLearn
/sort.py
473
3.65625
4
''' Test sort ''' print('==========================Test Sort====================================') l = [('ASDD',123,0.9),('DsdD',13,0.817),('JKKll',781,0.776),('OOkl',89,1.514)] print(sorted(l,key=lambda x : x[0])) print(sorted(l,key=lambda x : x[1])) print(sorted(l,key=lambda x : x[2], reverse = True)) print('-----...
53ef184707069c63d1b2344b7001f6c1bc97fe52
pieisland/ProjectEuler
/pro3_3.py
714
3.625
4
#coding:utf-8 """ 2019.03.14.Thu <소인수분해> 효율적인 버전. 다른 분이 푸신 걸 보고 다시 풀어봄 """ def primeNumber(n): """ 소인수분해하는 함수 n이 큰 수라도, 나눈 결과로 다시 되기 떄문에 빠르게 수행이 되는 듯. result 자체에 중복되는 소수가 들어가지 않게 in 을 추가로 더 넣어봄. """ i=2 result=[] while(i<=n): if(n%i==0): n=n//i if i not...
1ddc9d8413d0dc87340b4093ec536ee7a3822617
Dvyabharathi/My_python_code
/fizz.py
378
3.90625
4
def fizzBuzz(n): for i in range(1, n+1): if i%3==0 and i%5==0: print("Fizzbuzz") elif i%3==0: print("Fizz") elif i%5==0: print("Buzz") else: print(i) fizzBuzz(15) def Reverse(lst): new_lst = lst[::-1] return n...
36202b91575b81066d92f8ed757dd6f991be9588
Fea-Sin/python-core-50day
/src/ch8/pyd.py
953
3.578125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2020/11/12 2:39 下午 # @Author : FEASIN class Person: def __init__(self, name, age): self.name = name self.age = age def eat(self): print(f'{self.name}正在吃饭') def sleep(self): print(f'{self.name}正在睡觉') class Student...
fc63ca3e0d73586720e34b5de1d1fb19aee44c0b
ekirlilar/Game_of_RPS_PythonHW-master
/gameFiles/compare.py
2,036
3.703125
4
import time from random import randint def comparing (player, computer): global player_lives global computer_lives global player global computer global choices if ( player == computer ): print("*******Tie!*******") elif ( player == "rock" ): if (computer == "paper"): print("*******You ...
e5d9330d0986de75e21279942ae6704da947cead
cicekozkan/python-examples
/datetime.py
2,010
4.03125
4
# -*- coding: utf-8 -*- """ Created on Thu Nov 13 19:13:58 2014 @author: ocicek """ import datetime def print_today(): today=datetime.date.today() print "Year=%d, month=%d, day=%d" %(today.year, today.month, today.day) def find_age_birthday(year, month, day): """takes a birthday as input and prints ...
8d80a6c2fe9c7443f89eb28bb38d44e251e6add9
LuoJiaji/LeetCode-Demo
/Contest/biweekly-contest-10/A.py
479
3.6875
4
class Solution(object): def arraysIntersection(self, arr1, arr2, arr3): """ :type arr1: List[int] :type arr2: List[int] :type arr3: List[int] :rtype: List[int] """ ans = [] for i in arr1: if i in arr2 and i in arr3: ans.appe...
bb6a579de50a5ad8fc691fac4adf8885d0323e69
NickKletnoi/Python
/03_Algorithms/03_Misc/06_TravelItinerary.py
2,805
3.546875
4
#Copyright (C) 2017 Interview Druid, Parineeth M. R. #This program is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. from __future__ import print_function import sys def handle_error() : p...
1afc36f53654b03e2f353e64b656b39dff8c2e0e
HannaRF/Linguagens-de-Programacao
/aula_testes.py
2,772
3.578125
4
# programação via testes (tdt) import unittest class Biblioteca: def __init__(self,artigos): self.artigos = artigos self.autores = set(list(a)) def get_vizinhos(self,autor): art = [t for t in self.artigos if autor in t] for a in art: v = a[0] if a[1] != autor else a[...
c23e40d49ad9d8899150984b68a335a287bf44b9
MeabhG/Python-Games
/02. Guess the number.py
2,507
4.28125
4
# Mini-project #2 - Guess the number # # 'Introduction to Interactive Programming in Python' Course # RICE University - coursera.org # by Joe Warren, John Greiner, Stephen Wong, Scott Rixner # run the code using www.codesculptor.org # link to code http://www.codeskulptor.org/#user28_5wDR9vkBbB_0.py # input will com...
55cb9282bea6be1a0a3c80c9f9629f6800a0f80e
appscluster/stock-market-simulator-1
/best_strategy.py
1,093
3.5625
4
""" Generate Best Possible Strategy Created on Tue Apr 4 23:29:43 2017 @author: Xiaolu """ import csv import pandas as pd from indicators import get_prices def test_run(): # Input data dates_in_sample = pd.date_range('2008-01-01', '2009-12-31') symbols = ['AAPL'] prices = get_prices(symbols, date...
fba94e48ccba43f08b51964de83ff98337453902
luckytiger1/data_structures_usd
/week1_basic_ds/check_brackets.py
1,185
3.890625
4
from collections import namedtuple Bracket = namedtuple("Bracket", ["char", "position"]) def are_matching(left, right): return (left + right) in ["()", "[]", "{}"] def find_mismatch(text): opening_brackets_stack = [] for i, nextElem in enumerate(text): # print(f'{nextElem}, {i}') if nex...
1d8290932e03c3b43daef7911ea7f1c1741d75b5
HEMALATHA310/python_basics
/tupleOPERATIONS.py
244
3.828125
4
print((1,2,3)+(4,5,6)) print(("7")*3) tup=('h','e','m','a') #del tup[1]#TypeError: 'tuple' object doesn't support item deletion print(tup) del tup print(tup)#entire tuple can be deleted then we get [NameError: name 'tup' is not defined]
1fb6291ce47d04153c7e2436efc91a4ddcc0c981
ABlued/PythonAlgorithmProblem
/programmers/hash/Phone_number_list.py
552
3.625
4
def solution(phone_book): dic = {} for i in range(len(phone_book)): for j in range(len(phone_book[i])): if phone_book[i][:j + 1] in dic: return False dic[phone_book[i]] = 1 for i in range(len(phone_book)): for j in range(len(phone_book[i])): if phone_book[i]...
ab98bff47ccade473ac371b065bb76fccade6ff6
ganeshuprety446/pythonexample
/quadraticifelese.py
475
4.03125
4
# Solve the quadratic equation import math a = float(input('Enter a: ')) b = float(input('Enter b: ')) c = float(input('Enter c: ')) d = (b*b) - (4*a*c) print('value for drscriminant is',d) if d < 0: print ('This equation has no real solution') elif d == 0: sol1= (-b+math.sqrt(d))/2*a print ('This equation has...
9b93d9af7773f5c435828a42f523ca3f6a11c038
chenxu0602/LeetCode
/1018.binary-prefix-divisible-by-5.py
1,479
3.640625
4
# # @lc app=leetcode id=1018 lang=python3 # # [1018] Binary Prefix Divisible By 5 # # https://leetcode.com/problems/binary-prefix-divisible-by-5/description/ # # algorithms # Easy (46.80%) # Likes: 112 # Dislikes: 65 # Total Accepted: 14.3K # Total Submissions: 30.5K # Testcase Example: '[0,1,1]' # # Given an ar...
c52e05d6bd83536bfcdad407984a23dcfe5f8f1e
apatti/csconcepts
/sorting/bubblesort/python/bubbleSort.py
276
3.71875
4
#bubble sort def Sort(input: list) -> list: for k in range(len(input)-1): for i in range(len(input)-k-1): if input[i]>input[i+1]: temp = input[i+1] input[i+1] = input[i] input[i] = temp return input
d84f18872421c1e8590ea6c52c4870e1e065e475
toliveirac/Alura
/Python/Parte 03/playlist.py
2,158
3.796875
4
# Classe mãe, que contem os atributos comuns as classes Filmes e Séries class Programa: # Método init parâmetros def __init__(self, nome, ano): ##Inicialização de valores, self = proprio object self._nome = nome.title() self.ano = ano self._likes = 0 @property def likes...
5d775319065502ed26a147b620286113b8c72207
Valinor13/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/0-add_integer.py
843
4.21875
4
#!/usr/bin/python3 """ A module to store simple functions for testing ... Functions --------- add_integer(a, b=98) Returns two integers or floats added together Exceptions ---------- raise : TypeError Raises a TypeError if a or b are not int or float """ def add_integer(a, b=98): """A function to safe...
76c67e1df93f7887796581793be854046634537a
GriffinBabe/ARSWA
/tournament.py
5,088
3.59375
4
#Tournament Mode if gamemode == 't': #Loadings players_number = 0 players_number_text_count = 1 players_list = [] players_classes = [] players_wins = [] eliminated = [] existing_tree_players_number = [2,4,8,16] tree_plat pools_best_of = 0 brackets_best_of = 0 pools_eliminations = 0 players_t...
5b89a9c4fe809df926f13fd0b762c12b42c418ff
bakunobu/exercise
/1400_basic_tasks/chap_7/7_16.py
982
4
4
def give_num(text:str='Введите число: ') -> float: while True: try: a = float(input(text)) return(a) except ValueError: print('Используйте только числа (разделитель - \'.\')') def is_sum_bigger(n:int, lim:float) -> bool: total = 0 for x in range(n): ...
ec6a6541c3bdbe563b327eb9512f5b24cfabb373
ursu1964/Libro2-python
/Cap1/Ejemplo 1_5.py
3,240
3.8125
4
# -*- coding: utf-8 -*- """ @author: guardati Ejemplo 1_5 Copia de listas: ejemplo de uso de funciones del módulo copy. """ import copy # ============================================================================= # Ejemplos de copias superficiales y profundas de listas con datos inmutables. # ============...
891d46105b104c8f141eccdafe8269bd18fff080
kumbharswativ/Core2Web
/Python/DailyFlash/19mar2020/MySolutions/program4.py
345
3.734375
4
''' write a program to print the following pattern 1 2 3 4 5 6 7 7 6 5 4 3 3 4 5 5 ''' num=1 for i in range(4): v=num for j in range(7): if(j-i<=-1 or i+j>=7): print(" ",end=" ") else: if(i%2==0): print(num ,end=" ") num+=1 else: num-=1 print(num,end="...
8f2c36c2eb3b0604313b31db0cb812de0f3d659b
willpiam/oldPythonCode
/PlayingWithFiles.py
878
4.40625
4
#William... Febuary 8th 2016 #program will show #1. how to creat a .txt file #2. How to write to a .txt file #3. how to read from a text file #1 and 2 f = open("test.txt","a") #opens file with name of "test.txt" if does file does not excist this line creates it f.write("New End") f.close() #3 #this rea...
f57c3ed7d91231623ed4ce8cb2ffc235f5c8f198
NastyaZotkina/STP
/lab3.py
178
3.765625
4
a= int (input("Введите число 1 ")) b= int (input("Введите число 2 ")) print("a+b =", a+b) print("a-b =", a-b) print("a*b =", a*b) print("a/b =", a/b)
96fd4155c6fd3484a2721d323700e6017daed05a
Uriell77/PostulacionIsep
/hello_world.py
643
4.34375
4
#!/usr/bin/python # -*- coding: latin-1 -*- # Jueves 12 de Noviembre de 2020 # Test de Conocimiento del lenguaje de Programacion Python # Luis Hermoso # 1. Escribe una funcion que devuelva la cadena "Hola, mundo!"; esta debera requerir 2 parametros tipo cadena, "Hola" y "Mundo", tambien deberas realizar un print de l...
8bd558a82f6e6868b19968e107348dcc90f85fda
agermain/Kattis
/Python 3/Whatdoesthefoxsay.py
268
3.59375
4
for i in range(int(input())): sounds = input().split() while True: s = input().split() if s[0] == "what": break else: sounds = list(filter((s[2]).__ne__, sounds)) print(' '.join(str(x) for x in list(sounds)))
25f01f4be06fd277be72a3508505743284c7f573
neo4reo/euler
/eulerlib.py
3,021
3.84375
4
''' The purpose of this module is to collect functions that are useful for solving project euler problems. For example, many of the euler problems invole primes, hence many prime functions are collected here. Code aggregated and/or written by Justin Ethier ''' #import itertools import math from functools imp...
9bdaab47c9a7ea8766ac2a1f3c864a76a08fe2de
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/225/users/4005/codes/1635_2703.py
110
3.578125
4
idade= int(input("idade:")) if (idade>=18): mensagem="eleitor" else: mensagem="nao_eleitor" print(mensagem)
e8f80a07267065161cc2a7f744b38df2fbbfa78f
hieudtrinh/leetcode_python
/facebook_questions/arrays/group_by_caesar_cipher/GroupStringsByCaesarCipher.py
1,166
3.96875
4
from collections import defaultdict alphabet = 'abcdefghijklmnopqrstuvwxyz' # Idea # 1) find the base 'anagram' for each string # 2) put in dictionary[anagram] = string # 3) return the values in the dictionary, where value is a list def group_caesar(los): dict = defaultdict(list) # i is index base 0 # str...
2463fe13482886c203bb7b93e01a3ce964ae8117
TeamAIoT/python-tutorial
/5.Python_반복문/실습코드/pr05_06.py
102
3.59375
4
for i in range(2,10): for j in range(1,10): print(i,'x',j,'=',j*i,end='\t') print()
52ed31548e782714afcb5b6615138f3c4239be16
melissaarliss/python-course
/hw/hw-5/problem2.py
679
3.953125
4
employees = [ { "name": "Ron Swanson", "age": 55, "department": "Management", "phone": "555-1234", "salary": "100,000" }, { "name": "Leslie Knope", "age": 45, "department": "Middle Management", "phone": "555-4321", "salary": "90,000" }, { "name": "Andy Dwyer", "age": 30, "department": "Shoe ...
8258d9f571f9f53b6eb20bf82754b4396f2ecede
wcwagner/Algorithms
/COP4531/missingval.py
661
3.671875
4
import math def find_missing_val(A): # case that n+1 is missing if A[len(A) - 1] == len(A) - 1: return len(A) hi = len(A) - 1 lo = 0 mid = 0 while mid < hi: mid = int(math.ceil((float(hi) + float(lo)) / 2)) print(lo, mid, hi) if A[hi] - A[mid] > hi - mid: ...
c1325ad661df940716ce4b2fe13ae75d4b98d957
janhavik/my_projects
/Course 3/Week 1/week1_prims.py
3,176
3.890625
4
from heappractice import Heap from math import isinf import os import pprint # filename = "F:\\Learning\\coursera\\Algorithms Exercises\\stanford-algs\\testCases\\course3\\assignment1SchedulingAndMST\\question3\\input_random_2_10.txt" filename = "edges.txt" def readGraph(filename): with open(filename) as fp: ...
7b4a286b432372a602120a3cde98a8e8a47d9ad0
khagendra1998/Coding-Problems
/Solution1.py
263
3.734375
4
#The Beginning of Everything test_case = int(input()) for i in range(test_case): s = str(input()) a = "ldrwolloeh" #a = "".join(sorted(a)) if("".join(sorted(s)) == "".join(sorted(a))): print("Yes\n") else: print("No\n")
d2bde4fd64582370ce8d147f5ec1640a724ddb5e
KonstantinKlepikov/all-python-ml-learning
/python_learning/oop_lutz.py
1,381
4.34375
4
class FirstClass: """Empty class """ def setdata(self, value): """Class method Args: value (any type): example of class attribute """ self.data= value def display(self): """Print class attribute """ print(self.data) class SecondClass...
0bd117bbc87a27386eb24d83568d7c3bc3fde02b
hellokathy/MarketSim
/testAgent.py
3,337
3.546875
4
from agent import * import unittest HUNGRY_UTIL = {"apple": 10, "orange": 9, "water": 2, "land": 3, "clothes": 1, "money": 1} THIRSTY_UTIL = {"apple": 1, "orange": 2, "water": 8, "land": 2, "clothes": 1, "money": 1} """ random_sample returns a random sample of an inventory set. avg_cou...
9491c24653c9333643b3d7b47491868cb3d150ea
JackRossProjects/Computer-Science
/u1m1.py
11,664
4.15625
4
from __future__ import print_function, division import os import sys # CS31 U1M1 # Part 1 ''' 1.) How many seconds are there in 21 minutes and 15 seconds? 2.) How many miles are there in 5 kilometers? 3.) If you run a 5 kilometer race in 21 minutes and 15 seconds, what is your average pace (time per mile in minutes ...
6a6d0907ffe8e48826f8b10855f5038044252dc3
ljsuo/ProjectEulerProblems
/projeuler6.py
412
3.796875
4
#Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum. def diff(num): sum_first = 0 sq_first = 0 index1 = 1 sum_first = index1 + num sum_first *= num sum_first = sum_first / 2 while index1 <= num: sq_first += index1**2 ...
be97a60c7318cc798057651c618e7c4818b07a86
rallen0150/class_notes
/new_prac/nfl_draft.py
839
3.59375
4
from bs4 import BeautifulSoup import time import requests round_num = input("What round would you like to see:\n>") url = "http://www.espn.com/nfl/draft/rounds/_/round/{}".format(round_num) x = requests.get(url) soup = BeautifulSoup(x.text, "html.parser") # print(soup) num = 1 print("Round {} of 2017 NFL Draft".forma...
b9c814045ac1a56f1362fa942e69da660ce72df2
jcotillo/princeton_algorithms
/week_4/heap_sort.py
872
3.8125
4
def heap_sort(arr): n = len(arr) # set up binary heap for k in range(n/2, 0, -1): sink(arr, k, n) # order it now while n > 1: _exch(arr, 1, n) n -= 1 sink(arr, 1, n) return arr def sink(arr, k1, k2): while 2*k1 <= k2: j = 2*k1 if j < k2 and _l...
29b5fed013fc7e42fb1573938626f9f57284570c
lygtmxbtc/learning_notebook
/data_structure/linked_list.py
890
3.671875
4
class ListNode: def __init__(self, val): self.val = val self.next = None def reverse(self, head): prev = None # head不断向后遍历,将head的前一个元素作为下一个元素 # prev不断赋值新的head while head: tmp = head.next head.next = prev prev = head ...
dbbff9c767dea8860844dd8ee8e179d715356df8
MehediMehi/LearnPython3
/3. Variables objects and values/variable-numbers.py
737
4.21875
4
#!C:\Users\Mehedi Hasan Akash\Anaconda3 # -*- coding: utf-8 -*- """ Created on Wed Aug 7 19:43:51 2019 @author: Mehedi Hasan Akash """ def main(): num = 42 # integer number print(type(num), num) num = 42.0 # float number print(type(num), num) num = 42 / 9 # divide and get float value...
45ac8371c86c82b65f933a85ed56edf28d7d19f8
anubeig/python-material
/MyTraining_latest/MyTraining/18.sorting_and_searching/QuickSort.py
2,198
4.15625
4
#http://interactivepython.org/courselib/static/pythonds/SortSearch/TheQuickSort.html def quickSort(alist): quickSortHelper(alist,0,len(alist)-1) def quickSortHelper(alist,first,last): if first<last: splitpoint = partition(alist,first,last) quickSortHelper(alist,first,splitpoint-1) quickSo...
e47ae328a31f9ece2d9fbdcd540adc587b789747
gabriellaec/desoft-analise-exercicios
/backup/user_020/ch20_2020_03_04_18_39_09_893530.py
255
3.546875
4
# Exercicio 4 def preco_da_passagem(km): if km <= 200: preco = km*(0.5) return preco elif km > 200: preco = km*(0.45) return preco a = int(input('Insira a distância da viagem em km: ')) print(preco_da_passagem(a))
916c3858ab34ea4766f247a571a36593d60868cd
takecian/ProgrammingStudyLog
/AtCoder/ABC/106/b.py
201
3.796875
4
# https://atcoder.jp/contests/abc106/tasks/abc106_b def count_div(n): return sum([n % i == 0 for i in range(1, n+1)]) N = int(input()) print(sum(count_div(i) == 8 for i in range(1, N + 1, 2)))
63f4ab590a17108c41d6f7ce3dd7b939be5d0f40
rodrigodub/Moby
/moby.py
13,338
3.578125
4
################################################# # Moby # Moby Dick is a sailing simulator # intended to cross the seven seas. # # Usage: # > python3 moby.py # # v0.034 # Issue #7 # 20180217-20180306 ################################################# __author__ = 'Rodrigo Nobrega' # import import os...
5e7081cfa430965c735bdabb7fbeb83ed22b66a2
Leeyp/DHS-work
/practical 2/q2_triangle.py
588
4.15625
4
x = 1 while x != 0: valid = "no" sides = [] for side in range(0,3): print("Enter side", side+1) sides.append(int(input(" "))) a = sides[0] + sides[1] b = sides[1] + sides[2] c = sides[0] + sides[2] if a > sides[2]: if b > sides[0]: ...
75f888845d9193a2a7bb8a4559244bd07efcfb76
Madhu-Kumar-S/Python_Basics
/OOPS/Inheritance/i2.py
597
3.734375
4
# creating Student class and deriving attributes and methods from Teacher class to Student class from i1 import Teacher class Student(Teacher): def set_marks(self, marks): self.marks = marks def get_marks(self): return self.marks si = int(input("Enter id:")) sn = input("Enter name:") sa = i...
cd8d6f48b99db5789127095034b0ecfc022d2a16
aryasoni98/Face-X
/Snapchat_Filters/Festive-Filters/Rakshabandhan Festival Filter/Code.py
931
4
4
from PIL import Image img_path=input("Enter your image path here:") #ex -> r'C:\Users\xyz\images\p1.jpg' img = Image.open(img_path) img = img.resize((900, 900), Image.ANTIALIAS) img.save('resized_image.jpg') #img.show() filename1 = 'resized_image.jpg' filename='rakshabandhan.png' # Open Front Image frontImage =...
6df041b8b5f76c8146ac90b6a5f87d7fddfaf74b
brumazzi/Python2.x-Exemples
/gerador_yield.py
716
3.765625
4
#!/usr/bin/python # *-* coding:utf-8 *-* gen1 = (x for x in range(10)) def gen_function(): yield 5 yield 3 yield 5 yield 1 yield 8 yield 7 gen2 = gen_function() # gen1 e gen2, são ambos geradores, a diferença é que o gen1 por # ser gerado pela estrutura, é um objeto do tipo genexpr. # por gen...
c334651eb4d65447ab697f3cf0b5630daf82ab68
poipiii/app-dev-tutorial
/pratical-wk-2/Game.py
2,824
3.578125
4
#class Question: # Questionbank = {} # answerbank = {} # def __init__(self): # self.__question = [] # self.__answer = [] # def set_Question(self,question): # for i in self.__class__.Questionbank.keys(): # if i == question: # self.__question.append(self.__class_...
878968ea8334078dc49b73964dc6a6d8591345c1
hemenez/holbertonschool-higher_level_programming
/0x03-python-data_structures/6-print_matrix_integer.py
319
4.09375
4
#!/usr/bin/python3 def print_matrix_integer(matrix=[[]]): for first in range(len(matrix)): for second in range(len(matrix[first])): print('{:d}'.format(matrix[first][second]), end="") if second < len(matrix[first]) - 1: print("", end=" ") print("\n", end="")
01fccb0e7c170b562a98f9a55f2cc102523cbf45
wyaadarsh/LeetCode-Solutions
/Python3/0023-Merge-K-Sorted-Lists/soln.py
889
3.953125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Pair: def __init__(self, val, node): self.val = val self.node = node def __lt__(self, other): return self.val < other.val class Solution:...
96d7069a88d02f7934c5c11bf737522ec5a7d942
ryansama/karan-Projects-Solutions
/Networking/ip-country-lookup.py
779
4.0625
4
#Country from IP Lookup - Enter an IP address and find the country that IP is registered in. Optional: Find the Ip automatically. # Usage: python ip-country-lookup.py <country> # Outputs user's current country by default import urllib2 import json import sys if len(sys.argv) > 1: response = urllib2.urlopen("http:...
1af1aba8f07392db0ad4426b9d2b8f2c201b6f81
kgermeroth/tic_tac_toe
/tic_tac_toe.py
3,757
4.15625
4
def make_move (board, player, symbol): print("Ok, {}, make your move!".format(player)) while True: # asks user for a row row_choice = int(input("Row 1, Row 2, or Row 3? > ")) - 1 print() # asks user for a column column_choice = int(input("Column 1, Column 2...
d9a33fcf4325cba2d1fc0048165120c9a4e4e152
abiraaaaaaf/Digital-Image-Processing
/Homework1/ipl_utils/interpolate.py
776
3.515625
4
import numpy as np class Interpolation: @staticmethod def avg_interpolate(img_array): row, col, _ = img_array.shape # Filling With Zeros The Out Array new_img_array = np.zeros((row, col*2, 3)) # first assigning image pixels to the even cells in new array for i in range...
56f528060b59511279092dfb2b39ddeb1cc807d7
AKDavis96/Data22python
/Advent of code/day3.py
626
3.578125
4
list = [str(x.strip()) for x in open("day3_details.txt", "r").readlines()] def finding_trees(r, d): trees = 0 a = 0 b = 0 row = len(list[0]) c = len(list) - 1 while a != c: a += d if b > row - (r + 1): b -= row b += r elif b <= row - (r + 1): ...
0ef79dcd906ad987077c74a160b46f9d7376aa39
daniel-reich/ubiquitous-fiesta
/6BXmvwJ5SGjby3x9Z_5.py
269
3.71875
4
def hours_passed(time1, time2): a,b=','.join(i[:-6] if i[-2:]=='AM' else str(eval(i[:-6])+12) for i in (time1,time2)).split(',') if time1=='12:00 AM': return b+' hours' elif a==b: return "no time passed" else: return str(eval(b)-eval(a))+' hours'
36c0e611ed86721d32e8b388b2d5fea2d12fb849
kcpedrosa/Python-exercises
/ex099.py
508
3.890625
4
#programa para mostrar o maior def funcmaior(* num): cont = 0 maior = 0 print('=-'*30) print('Analisando números para retornar o MAIOR...') from time import sleep for c in num: sleep(0.5) print(f' {c} ', end=' ') if cont == 0: maior = c elif c > maior:...
e17304a785c9208325182225b8cb48b40b3a7956
Aasthaengg/IBMdataset
/Python_codes/p03854/s582347237.py
151
3.640625
4
s = input()[::-1] words = ["eraser","erase","dreamer","dream"] for i in words: s = s.replace(i[::-1], "") if s == "": print("YES") else: print("NO")
0491a31fb42b517b96f65655653b2fcb22f5cf89
SheetanshKumar/smart-interviews-problems
/Contest/B/Check Subsequence.py
861
3.90625
4
''' Check Subsequence https://www.hackerrank.com/contests/smart-interviews-16b/challenges/si-check-subsequence/submissions/code/1324385337 Given 2 strings A and B, check if A is present as a subsequence in B. Input Format First line of input contains T - number of test cases. Its followed by T lines, each line contai...
3e5b20c793131d9ed158841e0e6069cb0d0cf579
rodrigolousada/LEIC-IST
/1st_Year/FP/1st_Project/1stProject_81115.py
10,022
4.0625
4
#81115 Rodrigo Lousada #Algoritmo de Luhn def last_digit(cc): '''Recebe uma cadeia de caracteres que representa um numero e devolve o ultimo digito''' last = eval(cc)%10 return last def remove(cc): '''Primeiro passo do Algoritmo de Luhn: Recebe como argumento uma cadeia de caracteres que representa u...
d501f1e26e093cba6719af9a632ff576c63d6d83
jtquisenberry/PythonExamples
/Interview_Cake/combinatorics/two_egg_drop_formula_working.py
3,278
4.15625
4
import unittest import math ####################### # Problem ####################### # A building has 100 floors. One of the floors is the highest floor an egg can be # dropped from without breaking. # If an egg is dropped from above that floor, it will break. If it is dropped from # that floor or below, it will be...
52b3e6364c0b17223ec86ea66b389fb3f44bcaa9
Aasthaengg/IBMdataset
/Python_codes/p03109/s586538202.py
123
3.578125
4
S=input() month=int(S[5:7]) day=int(S[8:10]) if (month==4 and day<=30) or month<4 : print("Heisei") else : print("TBD")
a4851aeede04161d4e98645eef86f23120e80523
YBrady/dataRepresentation
/Labs/week09/selectAllRows.py
676
3.859375
4
# Import mySQL connector python package import mysql.connector # Set up the connection to the database db = mysql.connector.connect( host="localhost", user="root", password="", database="datarepresentation" ) # Create the cursor cursor = db.cursor() # The mySQL select - take away the where id bit if yo...
5850fe3192dcc3841144d585cf6f7cc200c59eef
coci/camo
/common/date.py
2,125
3.796875
4
""" converting date """ import datetime def gregorian_to_jalali(date): if date.find("-"): new_date = date.split("-") gy = int(new_date[0]) gm = int(new_date[1]) gd = int(new_date[2]) elif date.find("/"): new_date = date.split("/") gy = int(new_date[0]) gm = int(new_date[1]) gd = int(new_date[2]) el...
f90248384d99936a1829fbcf2beb8b749ae881cc
miguelmartinez0/MISCourseWork
/MIS 304/iteminfo.py
3,687
4.15625
4
#Author: Miguel Martinez Cano #Homeowkr Number & Name: Homework #8: The COOP #Due Date: Monday, November 7, 2016 at 5:00 P.M. #Item Info #Class Name: Item Info #List of Attributes: Item Number, Quantity, Price, Name, Mode #List of Methods:__init__(), get_item_num(), set_item_num(new_item_num), get_qty(), #update_qty(ne...
bcfb930c58785072b5e2fb2f530f9fd65d0c5b57
sheikhiu/Easy-URL-Shortener
/urlshortener.py
1,039
3.765625
4
import pyshorteners import tkinter as tk from tkinter import messagebox import webbrowser shortener = pyshorteners.Shortener() #This method shortens the URL using pyshorteners def URLshort(): x=pyshorteners.Shortener() a=x.tinyurl.short(entry.get()) shortened.insert(0, a) #start of the...
143d33f24290569b3d381e009be5fc92b9bfd08f
jameslehoux/a-test
/mysoftware/functions.py
1,961
4.34375
4
import numpy as np def square(x): """ Takes a number x and squares it. Parameters: ----------- x, float or int: Number which is to be squared. Returns: -------- float: Square of x Examples: --------- >>> square(2) 4 >>> square(-1) 1 """ ...
cf67580e31a2916c5f763f431ec0f3d78a3e4677
Mai-pharuj/lab03-two-character
/lab03.py
1,121
4.03125
4
# lab03.py for Shulin Li and Pharuj Rajborirug # CS20, Spring 2016, Instructor: Phill Conrad # Draw some initials using turtle graphics import turtle def drawS(s,w,h): # draw a letter S using s-Turtle, with some width and height # set up initial position s.penup() s.setx(-100) s.sety(-1...
147254cf2f4016a7c51f8152580a16aa0119a566
kabirsrivastava3/python-practice
/BOOK/PRACTICAL-BOOK/chapter-2/01-remove-element-0-index.py
373
4.09375
4
# A program that accepts a list and removes the value at index 0 from the list. def removeElementArray(): numList = [] size = int(input("Enter the size of the array: ")) numValue = 0 for index in range(size): numValue = int(input("Enter the number: ")) numList.append(numValue) nu...
d1cdee75de845f523400072d8d2edb3db7e8abe0
Err0rdmg/python-programs
/3.py
135
4.21875
4
text = input("Enter the string:") count = 0 for i in text: count += 1 print("The numbers of letters in your string is :", count)
531e3830c10cfc2e280197b213cf2ae725dc4f66
DilyanTsenkov/SoftUni-Software-Engineering
/Python Fundamentals/Mid exams/03_school_library.py
995
3.96875
4
book_names = input().split("&") while True: command = input().split(" | ") if command[0] == "Done": break if command[0] == "Add Book": if command[1] not in book_names: book_names.insert(0, command[1]) elif command[0] == "Take Book": if command[1] in boo...
c78702647213bd077603733c360b40b56be87ca0
braca51e/CS231A_3DCV
/E1/ps1_code/p2.py
3,782
3.765625
4
# CS231A Homework 1, Problem 2 import numpy as np ''' DATA FORMAT In this problem, we provide and load the data for you. Recall that in the original problem statement, there exists a grid of black squares on a white background. We know how these black squares are setup, and thus can determine the locations of specifi...
7ca6f72797c6eb1b5cbbb7ffcdff67c2fd073f2f
raghuxpert/Array7Boom
/Comprehension.py
1,440
3.859375
4
# list = [i for i in range(5)] # print(list) #[0, 1, 2, 3, 4] # # list = [i for i in range(1,5)] # print(list) #[1, 2, 3, 4] # # list = [i for i in range(1,5,2)] # print(list) #[1, 3] # # list = [i for i in range(5,1,-1)] # print(list) #[5, 4, 3, 2] # # list = [i for i in range(5,1,-2)] # print(list) #[5, 3] # # # # ##...
569af16cef42e215594ab26fa5c7ab734514ca95
frankpiva/leetcode
/problemset/20.py
1,466
3.953125
4
""" 20. Valid Parentheses Easy Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Example 1: In...
2b41318b51bb4b1a11909edb66509fdc742f0f84
maddiegabriel/python-tutoring
/moreLoops.py
236
4.21875
4
#!/usr/bin/python # while loop that prints the numbers from 1 to 5 count = 1 fruit = "BANANA" while count <= 5: print fruit count += 1 while count < 6: print count count += 1 for letter in "BANANA": print letter
d364b61b2eae7f736cf4416d93812df7e7aa89bc
gamingrobot/WotMiniMapMaker
/manualconverter.py
939
3.515625
4
def main(): import Image themap = raw_input("Map: ") background = Image.open("mapsRaw/" + themap + "/mmap.png") gametype = raw_input("Gametype: ") thescale = int(raw_input("Scale: ")) done = False while(done != True): foreground = Image.open("icon/" + raw_input("Marker Filename: "...