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
f72e611a5282dfb43cb9cebb06665c8c0e2b24ff
kannangates/autoclean_csv
/autoclean.py
4,899
3.5625
4
import streamlit as st import pandas as pd st.set_page_config(layout="wide") st.title('Auto_clean your csv file for data exploration') # @st.cache(allow_output_mutation=True) def load_data(file): df = pd.read_csv(file) return df @st.cache # IMPORTANT: Cache the conversion to prevent computation on every rer...
4fb20a239432c5608cf0f1f32bee92a496a6a369
Aasthaengg/IBMdataset
/Python_codes/p03323/s350032161.py
120
3.65625
4
import sys s = input().split(' ') x, y = int(s[0]), int(s[1]) if (x > 8 or y > 8): print (":(") else: print ("Yay!")
0fb4ab0d13bd84012b92f2dd417e7385b8e05b39
khanmazhar/Python12Projects
/p4_rock_paper_scissors.py
574
3.953125
4
import random def play(): user_choice = input( "What is your choice? 'r' for rock, 'p' for paper, 's' for scissors\n") comp_choice = random.choice(['r', 'p', 's']) if user_choice == comp_choice: return 'It\'s a tie!' if is_win(user_choice, comp_choice): return 'Yo...
9858d17e09712baeb9ad6b221360e04cf67f34ab
VSRLima/Python
/Scripts/Tupla/Tupla D2.py
679
3.75
4
times = ('Athletico-PR', 'Atlético-GO', 'Atlético-MG', 'Bahia', 'Botafogo', 'Bragantino', 'Ceará', 'Corinthias', 'Corinthians', 'Coritiba', 'Flamengo', 'Fluminense', 'Fortaleza', 'Goiás', 'Grêmio', 'Internacional', 'Palmeiras', 'Santos', 'São Paulo', 'Sport', 'Vasco') print('Os 5 primeiros são:', end=...
37ec5c271a4d442095219abaecf0feefcd4ddfe0
jacksteveanderson/python-assignment
/primenumber.py
1,357
4.15625
4
# Prime Number Check (Finds 5 Prime Number) times = 0 while times < 5 : enterprime = True while enterprime: number = input("Enter a positive integer number : ") digits = len(number) if not number.isdigit(): if number.count(",") == 1 and number.replace(",", "1").isnumeric() an...
43f8a6e2cd3fda84a3661d821ea32222daccd4cc
gtraiano/SiCalcPy
/Terminal.py
1,934
4.1875
4
from Calculator import Calculator class Terminal: """ A terminal for the Calculator class """ def __init__(self): self._input = "" self._calc = Calculator() def main(self): while True: self._input = input("> ").lower() if self._input == ...
906d2388e95ed4183abf0a80106dfa099419c8d3
whitebluecloud/padp_ko
/tasks/9th/FrogJump_cloud.py
1,116
4.03125
4
''' A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. The small frog always jumps a fixed distance, D. Count the minimal number of jumps that the small frog must perform to reach its target. Write a function:...
05270ffda10fee046f46648d56a47be0744348ee
drieswijns/ahorn
/ahorn/GameBase/Actor.py
850
3.96875
4
import abc class Actor(metaclass=abc.ABCMeta): """An actor performs actions and drives a game from state to state. Parameters ---------- Returns ------- """ @abc.abstractmethod def __init__(self): pass @abc.abstractmethod def get_action(self, state): """Return...
112bd30151f96ec93cebe7016776be232374ccf8
DanielZuerrer/AdventOfCode2020
/day-4/a/main.py
533
3.859375
4
with open('input.txt', 'r') as f: input = f.read() double_space_separated = input.replace('\n', ' ') passports = double_space_separated.split(' ') necessary_fields = ['byr', 'iyr', 'eyr', 'hgt', 'hcl', 'ecl', 'pid'] def is_valid(passport): is_valid = True for field in necessary_fields: is_valid...
c9441a85001a7fbfa220ebdbe4b552dc4788dfec
kakukosaku/DSA
/sort/py_impl/merge_sort.py
1,555
4.0625
4
#!/usr/bin/env python3 # coding: utf-8 # # author: kaku # date: 19/10/10 # # GitHub: # # https://github.com/kakukosaku # # © 2019-2022 Kaku Kosaku All Rights Reserved from typing import List, NoReturn def merge(arr: List[int], low: int, mid: int, high: int, arr_tmp: List[int]) -> NoReturn: for i in range(low, ...
dc18276eaca427c2b7c4d3528600d43eac41fc31
R4f4Lc/Programacion1Daw
/Primer Trimestre/7- Python/Ej8Dimension.py
724
4.03125
4
""" Realiza un programa que pida la temperatura media que ha hecho en cada mes de un determinado año y que muestre a continuación un diagrama de barras horizontales con esos datos. Las barras del diagrama se pueden dibujar a base de asteriscos o cualquier otro carácter. __author__ = "Rafael López Cruz" """ mes = ["En...
1321cf87a1f5edfb3c7f97c6daef4a3811ac6111
guyalone/pyptest
/pavan-sample-programs/sample_funtions.py
404
4.21875
4
uservalue = input("Enter a value to get factorial:") def fact(number): factorial = 1 if number < 0: print ("factorial doesnot exist for negative numbers") exit() elif number == 0: print ("Factorial of 0 is 1") exit() else: for i in range(1, number + 1): ...
dc751522efe8d70fd5ae0a3b903c64627033a049
AP-MI-2021/lab-4-AndreiFeier
/main.py
4,500
4.03125
4
def citire_lista(): ''' Citeste lista :return:list,lista de numere ''' lista =input("lista : ") lista=lista.split() lista=[int(el)for el in lista] return lista def afisare_negative(lista): ''' Afiseaza numerele negative din lista :param lista:list,lista de numere initiala ...
7bf4a0b968658e5517f40c3844520865e0a74935
ralenth/testing-homework
/homework.py
1,398
3.65625
4
import argparse import json import os from typing import List, Union current_dir = os.path.dirname(__file__) def take_from_list(li: list, indices: Union[int, List[int]]): """ This function returns list of elements for given indices. :param li: list of elements :param indices: single index or list of ...
2884191b57020d0a4d9ba2334870d348312d1632
jitendra1310/codeing_problems
/code/prime_number.py
581
3.96875
4
import math class Prime: def __init__(self): num = input("Enter a number: ") self.num = int(num) def method1(self): print(math.floor(math.sqrt(self.num))) for i in range(2,math.floor(math.sqrt(self.num))): if self.num % i ==0: ...
d16363816a863f9c810391015ec21e98dec64bd9
Color4/2017_code_updata_to_use
/绘图代码/plot_v8.py
327
3.6875
4
import matplotlib.pyplot as plt fig = plt.figure() x = [1,2,3,4,5,6,7] y = [1,3,4,2,5,8,6] left,bottom,width,height = 0.1,0.1,0.8,0.8 ax1 = fig.add_axes([left,bottom,width,height]) ax1.plot(x,y,'r') left,bottom,width,height = 0.2,0.6,0.25,0.25 ax2 = fig.add_axes([left,bottom,width,height]) ax2.plot(y,x,'b') plt....
70ca7c0485140ade11e0dff3c86ad8649c83c7d8
skok1025/python_ch2.3
/symbol_table.py
748
3.84375
4
def f(): l_a = 2 l_b = '마이콜' print("f_local: ",locals()) class MyClass: x=10 y=20 print(globals()) g_a = 1 g_b = "둘리" # print(globals()) f() # 1. 정의된 함수 f.k = 'hello' print("--",f.__dict__) # 2. 클래스 객체 MyClass.z = 10 # print(MyClass.__dict__) # 내장 함수는 심볼 테이블이 없다 -> 확장 x # print(print.__cla...
09fb7e8bc5951c7445088b16f7fdea6633d6460b
ozzi7/Hackerrank-Solutions
/Python/Itertools/itertools-permutations.py
160
3.71875
4
from itertools import permutations text = input().split() s = text[0] k = int(text[1]) li = list(permutations(s,k)) li.sort() for x in li: print("".join(x))
fad1c62e82bc4aff21d1faab54564ed7e3a65d7b
cristiano250/pp1
/04-Subroutines/zad. 37.py
152
3.578125
4
tab=[2,3,1,2,5,6,4,5,6,3] def unikat(tab): u=[] for i in tab: if tab.count(i)==1: u.append(i) print(u) unikat(tab)
75c9bec35fab1baf964840ee3bde3c063dade0e5
JaneHQ1/Path-to-Python3-v2
/pythonic/c8.py
2,342
4.6875
5
''' 14-8 __len__与__bool__内置方法 ''' """ class Test(): def __bool__(self): return False def __len__(self): return 0 """ # 这两个方法的返回结果将影响test对象最终的bool取值。 # 这两个方法如何影响最终的bool返回结果? # __len__ 返回0,False # __len__ 返回非0,True """ class Test(): def __len__(self): # return '8' #...
09bf2e12c7d2990267ab54c39ec44001ac0db469
mooksys/Python_Algorithms
/Chapter39/file_39_3e.py
399
3.5625
4
def my_divmod(a, b, results): return_value = True if b == 0: return_value = False else: results[0] = a // b results[1] = a % b return return_value # 메인 코드 res = [None] * 2 val1 = int(input()) val2 = int(input()) ret = my_divmod(val1, val2, res) if ret == True: print(r...
467142fb96d266c3c40af877cbd67ee2289cd671
kumarvadivel/python-training
/sample38.py
87
3.5625
4
x,y=map(int,input().split(",")) print("true" if x==y or x+y==5 or x-y==5 else "false")
eb3330a9dc29227e32859f6be6d60ff0cbb9b934
abiB1994/CMEECourseWork
/Week2/Code/loops.py
498
3.90625
4
# !/usr/bin/env python """Loops and infinite loops in python""" __author__ = "Abigail Baines a.baines17@imperial.ac.uk" __version__ = '0.0.1' # for loops in Python for i in range(5): print i my_list = [0, 2, "geronimo!", 3.0, True, False] for k in my_list: print k total = 0 summands = [0, 1, 11, 111, 1111] for s...
b916cd8121a2bfe0ecda309892bd9d8cb26e438b
rahuljnv/Python_Tutorial_rg
/E8_Factotrial_Trailing_Zero.py
1,028
4.15625
4
# Part 1: cal the factorial # Part 2: cal the no of trailing zeros in factorial def factorial(number): if number == 0 or number == 1: return 1 else: return number * factorial(number-1) # # Iterative method # i = 1 # fac = 1 # for i in range (i,number+1,1): # fac = fac *...
9cf4181932fd5b89dae392d73ffc97e29f04e02a
vipnambiar/py_training
/Exercises/grade.py
672
3.578125
4
import sys d = {} for score in range(90,101): d[score] = 'A' for score in range(80, 90): d[score] = 'B' for score in range(70, 80): d[score] = 'C' for score in range(60, 70): d[score] = 'D' def main(): while True: score = raw_input("Enter a score: ") try: ...
24bcf8c39f9070469d44d1d9cf2da0b39a3b2cd5
ralsouza/python_data_structures
/section23_binary_search_tree/241_traverse_bst.py
2,391
4.125
4
# Traversal of Binary Search Tree # Insert a node to BST import QueueLinkedList as queue class BSTNode: def __init__(self, data): self.data = data self.left_child = None self.right_child = None def insert_node(root_node, node_value): if root_node.data is None: root_node.data ...
538792c0ac5f4e0073d02367931e0aa1394ebecd
mightykim91/algorithm_and_data_structure
/quicksort.py
635
3.90625
4
def quickSort(array, left, right): if left >= right: return pivot = array[(left+right)//2] index = partition(array, left, right, pivot) quickSort(array, left, index-1) quickSort(array, index, right) def partition(array, left, right, pivot): while (left <= right): while (array[l...
274339867a215ebe1644ddf71d89a7a9896820f4
danieltshibangu/Mini-projects
/PYTHON-CH3-16.py
544
3.90625
4
# program aks users to enter a year and identify a leap year # set up programming constants for february LEAP_YEAR = 29 NORM_YEAR = 28 # prompt user for number of years and store year = int( input( "Enter a year: " ) ) # create conditional statemtents for years entered if year % 100 == 0: if year % 400: ...
f134019655250147d21a8c605226f66fbcaf345a
pauldepalma/CPSC427
/E-Linear-Regression/iterative/linear-regression1.py
1,883
4.0625
4
''' Iterative version of gradient descent for linear regression Code is adapted from and data comes from : ...github.com/mattnedrich/GradientDescentExample ''' import numpy import csv import matplotlib.pyplot as plt def gradient(b_current, m_current, points, learningRate): b_gradient = 0 m_gradient = 0 N =...
e1d263262828bf063828ffffd72a780f9c2c6aa5
tobielf/DSAP
/Leetcode/Maximum Depth of Binary Tree/maximum_depth_of_binary_tree.py
769
3.875
4
# source:http://oj.leetcode.com/problems/maximum-depth-of-binary-tree/ # report: # Problem Description: # Given a binary tree, find its maximum depth. # The maximum depth is the number of nodes along the longest path # from the root node down to the farthest leaf node. # @author: tobielf # @date: 2014/03/16 class Tre...
cd54556f06103d62efcf925fb5fe4c6ec6d3e820
eliasantoniorodrigues1/curso_expressoes_regulares
/aula5_comeca_com_termina_com.py
655
3.84375
4
# Meta Caracteres: # ^ - No inicio da expressão regular quer dizer COMEÇA COM dentro da lista NEGA o dado da lista. # $ - TERMINA COM # [^a-z] - LISTA NEGADA - qualquer coisa que não seja de a-z import re cpf = '147.852.963-12' # Abaixo temos ? no mínimo 1 0-9 três posições com um ponto, esse grupo se repete duas ve...
bedd381b26006411ad7fd8ba803545dc76b7caf2
Ekeopara-Praise/python-challenge-solutions
/Ekeopara_Praise/Phase 3/PYTHON CHALLENGE/Day95 Task/Task2.py
307
4.1875
4
'''2. Write a Python program to compute the sum of all the multiples of 3 or 5 below 500. All the natural numbers below 12 that are multiples of 3 or 5, we get 3, 5, 6, 9 and 10. The sum of these multiples is 33. ''' n = 0 for i in range(1,500): if not i % 5 or not i % 3: n = n + i print(n)
9103796362e36fc83d81ce84a9ed3154ddeb37db
lvoinescu/python-daily-training
/matrix_word_finder/main.py
1,406
3.890625
4
# Given a matrix of characters, and a input word, # determine if the word can be found in the matrix, # by traversing the matrix in any direction (top, bottom, left, right) def seek_solution(matrix, i, j, word, position): if position == len(word): return True print("Checking [" + str(i) + "," + str(j)...
fbbbb7cf86a729198e48f955a669b5f7644835cf
Tenedra/HW-Shool-Best-Practice
/HW3/HW3_task5.py
630
3.53125
4
r = int(input()) # число, ближ.знач. в ряде Фиббоначи которого нужно суммировать count = 0 # счетчик n-значночти числа x=r while x!=0: x//=10 count+=1 # определим сколько эллементов ряда нужно вывести if count==1: a=7 else: a = 6*count f1 = 0; f2 = 1; A = 0 fibonacci_series = [] for i in range(a+1):...
5a1f9e48b15a36fabbea639408fd42a7a96f0bad
dusty-phillips/pyjaco
/tests/strings/zipstring.py
132
3.96875
4
s1 = "hello" s2 = "world" s3 = "abcd" s4 = zip(s1,s2,s3) for item in s4: print "----" for val in item: print val
79534cf2f1a315e6b590ce54c6e1e3cf84fb2dfe
thinkerston/curso-em-video-python3
/mundo-03/exercicio-073.py
2,404
3.78125
4
'''Crie uma tupla preenchida com os 20 primeiros colocados da tabela do campeonato brasileiro de futebol. na ordem de colocação. Depois mostre? - Apenas os 5 primeiros colocados; - os ultimos 4 colocados; - uma lista de times em ordem alfabetica; - em que posição esta o time da Chapecoense.''' tabelaBrasileirao = ('F...
f4af530244c0b8222e80af3d1211f58f9bc293d9
josephburton06/rio_olympics
/nationality_helpers.py
1,547
3.84375
4
import numpy as np import pandas as pd from sklearn import preprocessing from sklearn.preprocessing import LabelEncoder def create_top_medalist(): ''' This function is used to create a dataframe of athletes that received medals for countries that received more than 90 medals. ''' df = pd.read_csv...
93942bf9f1687ff2b439feb4edd1fb939595077a
guiw07/leetCode
/7_ReverseInteger.py
671
3.96875
4
""" 7. Reverse Integer Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 """ class Solution(object): def reverse(self, x): """ :type x: int :rtype: int """ ...
b4da301278fa5218a651434257102ce8aaa36572
PhilanthropistBright/MyPython
/MyExercise/class.py
296
3.78125
4
class MyClass: i=12345 def f(self): return "hello world" x= MyClass() print(x.i) print(x.f()) class MyClass1: sum = 0 def __init__(self,sum1,sum2): self.sum = sum1+sum2 self.su1=sum1 self.su2=sum2 y = MyClass1(10,20) print(y.sum,y.su1,y.su2)
efe58633da1b46c785f1292f9dff95966ece90df
joerihofman/pythonjoostjoeri
/Week1/opgave8.py
130
3.5
4
T = int(input('Temperatuur:')) #temp B = int(input('Beaufort:')) #beaufort G = 13+0.62*T-14*B**0.24+0.47*T*B**0.24 print(G)
568759e0825e1cf48fd29c2a8b3a0717906cdea1
alanmmckay/population_protocol_simulator
/scanner.py
1,850
3.78125
4
from general_token import GeneralToken, GeneralTokenType #--- --- ---# #A scanner super class that simply iterates through an #input string and assumes each character is an individual #token. #--- --- ---# class Scanner: def __init__(self, input_str): self.input_str = input_str self.pos = 0 ...
ebb311ebca6d22138b05841b7e3fb5fadea85fae
MohammedJ94/pdsnd_github
/bikeshare.py
7,646
4.5
4
import time import pandas as pd import numpy as np CITY_DATA = { 'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv' } def get_filters(): """ Asks user to specify a city, month, and day to analyze. Returns: (str) city - name o...
1aa2769833121938ba30fdb8a4eefe52b71861b1
akimi-yano/algorithm-practice
/lc/review_820.ShortEncodingOfWords.py
1,727
3.8125
4
# 820. Short Encoding of Words # Medium # 904 # 350 # Add to List # Share # A valid encoding of an array of words is any reference string s and array of indices indices such that: # words.length == indices.length # The reference string s ends with the '#' character. # For each index indices[i], the substring of s ...
8be4394314c32466d122f65a1ce25168560c3b0f
unstory/tutorial
/pandas_tutorial.py
7,145
4
4
# coding: utf-8 # ### quick start for pandas # #### 1. preview # 1. python基础语法 # 2. 面向对象思想 # #### 2. pandas数据结构 # #### 2.1 Series # Series(序列)与list相似,功能更加强大。series是学习dataframe的基础,一个dataframe是由多个series构成的数据结构。 # ##### series的常用属性 # In[9]: import pandas as pd # 构建一个series s = pd.Series([1,2,"c",5,1],index=ran...
a5bc6fe234953c5a427c52edef0bcfa9174d1bd5
n1k-n1k/python-algorithms-and-data-structures--GB-interactive-2020
/unit_03_arrays/hw/hw_03_1.py
443
3.546875
4
""" 1. В диапазоне натуральных чисел от 2 до 99 определить, сколько из них кратны каждому из чисел в диапазоне от 2 до 9. Примечание: 8 разных ответов. """ count = {} for i in range(2, 100): for j in range(2, 10): if i % j == 0: count[j] = count.get(j, 0) + 1 for k, v in count.items(): pri...
edc29f492f2004d181f6b0f980ced3f83728e599
lealex262/RRT-Mobile-Manipulator
/src/scripts/rrt.py
6,144
3.765625
4
#!/usr/bin/env python """ Path planning Sample Code with Randomized Rapidly-Exploring Random Trees (RRT) author: AtsushiSakai(@Atsushi_twi) edited: Alex Le """ import math import random import sys import time import matplotlib.pyplot as plt import numpy as np import cmap import move show_animation = True class...
38d5f2737700ee389adb5a0a50f421846114ad81
Olivia-Zhang-08/Olivia_Files
/CS50/pset6/bleep/bleep.py
1,129
3.796875
4
# Olivia Zhang, P-Set 6, Bleep import sys from cs50 import get_string # in this file, one function main is defined, which is called at the end of the file def main(): # accept only exactly 2 command-line arguments; if not 2, exit with usage message, which automates return 1 if len(sys.argv) != 2: ...
e947f3a07e504f7ed7db540a4d0c886cf2e8a402
VigneshPeriasami/hackerrank
/permuted_divisibility.py
1,473
3.78125
4
#!/usr/bin/python def tables(): tables = set() for x in range(13, 126): tables.add(x*8) return tables class ExtNumber: def __init__(self, n): self.number = n self.number_frequency = { x:0 for x in range(0,10) } self.number_stack = set(map(self.read_int, str(n))) def read_int(self, n_i): ...
6188e582b76bb984ca49476a5a7c3c8c597c317d
anschauf/master_thesis
/src/evaluators/evaluator_base.py
1,171
4.125
4
from abc import ABC, abstractmethod class Evaluator(ABC): @abstractmethod def evaluate(self, results: list, targets: list) -> list: """ Evalutes the results compared to the target :param results: NMT results :param targets: gold results :return: the evaluated scores in...
c4c17e420ae764a5f219148a778b81529a4addbc
printfoo/leetcode-python
/problems/0849/maximize_distance_to_closest_person.py
743
3.828125
4
""" Solution for Maximize Distance to Closest Person, Time O(n) Space O(1). Idea: Count 0s and divide 2. """ # solution class Solution: def maxDistToClosest(self, seats: "List[int]") -> "int": middle, this, begin, end = 0, 0, 0, 0 for s in seats: if s == 0: this += 1 if s =...
2300188b58ce79821854d887207f91773ab47537
31784/Virtual_Pet
/VirtualPet.py
1,765
4.1875
4
class VirtualPet: """An implementation of a Virtual pet""" #contructor method def __init__(self,name): #attributes self.name=name self.hunger= 50 print("Hi,I've been born and I am called {0}".format(name)) #methods def talk(self): print("Hello...
6cc464b78403dd73161a1be58afdcc9706b3c08c
akniels/Data_Structures
/Project_2/Problem_3.py
6,842
3.734375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Aug 21 15:28:56 2020 @author: parallels """ import sys from heapq import heappush, heappop, heapify from collections import defaultdict class Node(object): def __init__(self,value = None, letter = None): self.value = value ...
6eebf94e3c29de2cbd196e6d61fc19be4153a9b1
zaghir/python
/python-for-beginner/01-first-python-project/while_exercises.py
426
3.796875
4
# print_squares_upto_limit(30) # //For limit = 30, output would be 1 4 9 16 25 # # print_cubes_upto_limit(30) # //For limit = 30, output would be 1 8 27 def print_squares_upto_limit(limit): i = 1 while i * i < limit: print(i*i, end = " ") i = i + 1 def print_cubes_upto_limit(limit): i = 1 ...
3659314b5d465615726032db69a210aa7ee5238f
lucaschf/python_exercises
/exercise_7.py
1,841
3.78125
4
# Faça um programa que percorre uma lista com o seguinte formato: [['Brasil', 'Italia', [10, 9]], # ['Brasil', 'Espanha', [5, 7]], ['Italia', 'Espanha', [7,8]]]. Essa lista indica o número de faltas que cada time fez # em cada jogo. Na lista acima, no jogo entre Brasil e Itália, o Brasil fez 10 faltas e a Itália fez 9....
e933bc3af41dd05e85a6bbff4b4c18e70e1a786c
oskip/IB_Algorithms
/Invert.py
885
4.3125
4
# Given a binary tree, invert the binary tree and return it. # Look at the example for more details. # # Example : # Given binary tree # # 1 # / \ # 2 3 # / \ / \ # 4 5 6 7 # invert and return # # 1 # / \ # 3 2 # / \ / \ # 7 6 5 4 # Definition for a binary tree node clas...
ad0e6ed96cc4ddcecca9f425a0a33c54331ec5b1
AGiantSquid/advent_of_code
/python/2020/day_3/day_3.py
1,452
3.546875
4
#!/usr/bin/env python3 ''' Solves Advent of Code problem for day 3. ''' from functools import reduce from operator import mul from aoc_utils import get_aoc_data_for_challenge def prod(list_of_ints): '''Return the product of list of ints. This method is built into numpy, but recreated here to keep import...
fc4f41a06bfdf27a054580943515ff30289b0f08
w2kzx80/py
/dz6/3.py
656
3.71875
4
class Worker: def __init__(self, name, surname, position, wage, bonus): self.name = name self.surname = surname self.position = position self._income = { "wage":wage, "bonus":bonus } class Position(Worker): def __init__(self, name, surname, position, wage, bonus): super...
e3b25d9b357064460a9ceee35240aea43c1de0ba
alexlevine1220/robotcar
/practice/python_program.py
2,929
4.0625
4
# A13528608 # HELPER # %% def distance(p1, p2): """Calculate distance between p1, p2. Args: p1 (float, float): coordinates of p1 p2 (float, float): coordinates of p2 Returns: float: distance """ return ((p2[1] - p1[1]) ** 2 + (p2[0] - p1[0]) ** 2) ** 0.5 def computeLineT...
766bcce96dc83faeaa85f4951176786ff4d6eedb
lukejskim/sba19-seoulit
/Sect-A/source/sect07_class/s742_instance_var.py
498
3.65625
4
# 인스턴스 변수(인스턴스간 공유 안됨) class Cat: def __init__(self, name): self.name = name self.tricks = [] # 인스턴스 변수 선언 def add_trick(self, trick): self.tricks.append(trick) # 인스턴스 변수에 값 추가 cat1 = Cat('하늘이') cat2 = Cat('야옹이') cat1.add_trick('구르기') cat2.add_trick('두발로 서기') cat2.add_trick('죽은척 하기...
2486813bf87962c8c603545711d22a35588e213e
matthieujac/Twitter-Clone-Language-Moderator
/python-ml-service/utils.py
349
3.671875
4
import nltk from nltk.corpus import stopwords import string print("Downloading English Stop words.") nltk.download('stopwords') def text_process(mess): nopunc = [char for char in mess if char not in string.punctuation] nopunc = ''.join(nopunc) return [word for word in nopunc.split() if word.lower() not in...
d6a2b970afc849c972314f82381da300f3affc37
Abusagit/practise
/Stepik/pycourse/Cipher.py
908
3.875
4
import simplecrypt """САЙТ: https://pypi.org/project/simple-crypt/""" string = '' with open("encrypted.bin", "rb") as inp: encrypted = inp.read() with open("passwords.txt", 'r') as file: file = file.readlines() for i in range(len(file)): file[i] = file[i].strip() print(encrypted) print...
d4223d72cf5327e84026272c01914783bb8f8cc0
tavalenzuelag/Optimizacion
/Tarea1/visualization.py
299
3.828125
4
from matplotlib import pyplot as plt def visualization(error_list, name = None): iterations = [x for x in range(len(error_list))] plt.plot(iterations, error_list, '.') if name is not None: plt.title(name) plt.xlabel('n° Iteración') plt.ylabel('Error') plt.show()
86d951c83554fb3f51462050065dd9d39de4e06c
BenGH28/neo-runner.nvim
/testfiles/run.py
92
3.71875
4
print("Hello world from python") name = input("enter in you name: ") print("thanks", name)
efaea333c58e31283bfa3f70c6bc16e79c8ad159
BoswellBao/PyLearn
/shiyanlou/IteratorsExp.py
820
3.75
4
''' Python 迭代器(Iterators)对象在遵守迭代器协议时需要支持如下两种方法: __iter__(),返回迭代器对象自身。这用在 for 和 in 语句中。 __next__(),返回迭代器的下一个值。如果没有下一个值可以返回,那么应该抛出 StopIteration 异常。 ''' class Counter(object): def __init__(self, low, high): self.current = low self.high = high def __iter__(self): # 如果没有这个方法,就会报类型错误-->TypeError...
ab7c6a65655ba4336f245992203186a045f787f5
JasmineRain/Algorithm
/Python/Tree/113_Medium_路径总和II.py
929
3.765625
4
from collections import deque # Definition for a binary tree node. from typing import List class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def pathSum(self, root: TreeNode, sum: int) -> List[List[i...
9fde2c404e2bc2eccfedf496f76413593e92c0b8
iorzt/leetcode-algorithms
/add_two_numbers.py
1,774
3.828125
4
# coding=utf-8 """ You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. You may assume the two numbers do not contain any leading zero, except the numb...
e8bcadbb1d14c5372d495c85e7c7dfb53b93a688
serapred/academy
/ffi/tcpauto.py
1,800
3.65625
4
""" Create a finite automaton that has three states. Finite automatons are the same as finite state machines for our purposes. Our simple automaton, accepts the language of A, defined as {0, 1} and should have three states: q1, q2, and q3. Here is the description of the states: q1 is our start state, we begin reading...
fb7d49c47e182d60ab75f57cb452ba1837182561
saransh-khobragade/Python
/syntax/dictionary.py
1,193
4.09375
4
#blank dicktionary dic={} dic["a"]=5 dic["b"]=10 #how to loop over dictionary for x, y in dic.items(): print(x, y) for x in dic.keys(): print(x) for y in dic.values(): print(y) #how to check key exists in dictionary if 'x' in dic: dic['x']+=1 else: dic['x']=1 # Set unique but no unordered set_itmes ...
9d8b06d95eb152e6e22f358a6517a1ee8cf9d9c8
MichalxPZ/PUT-HackerRank-Python
/Medium/CheckTheCoprimes.py
357
3.75
4
import math def checkthecoprimes(liczba): ogranicznik = liczba // 2 for i in range(ogranicznik, 1, -1): if math.gcd(liczba, i) == 1: return (i) return (1) def main(): N = int(input()) for i in range(N): liczba = int(input()) print(checkthecoprimes(liczba)) i...
ed0f91ae83b72ff0fef24d5fce18b7ab2817b5fb
rafaelperazzo/programacao-web
/moodledata/vpl_data/173/usersdata/273/82248/submittedfiles/moedas.py
360
3.984375
4
# -*- coding: utf-8 -*- a=int(input('Digite o valor de a: ')) b=int(input('Digite o valor de b: ')) c=int(input('Digite o valor de c: ')) if c%a==0 and c%b!=0: print(c/a) print('0') elif c%a!=0 and c%b==0: print('0') print(c/b) d=c/b elif c==(c//a)+(c/b) and c==d: print (c//a) prin...
7ebf6572effb4532a4fbc9ae27696b7517fb046f
PranavAnand587/Hangman-Game
/story.py
1,740
3.859375
4
storyText = '''You open your eyes and realize that you are not in the safety of your house. Your hands are tied, and you cannot move.You look around you , hoping to find some way to escape. There are no windows, just a single lightbulb hanging above you in the darkroom and a chalkboard in front of you.The rest of the...
a23776fd2e0855f3f4bb36bd9e50159d2cc0263a
davisonWang/Python_test
/city_functions.py
296
3.765625
4
### 动手试一试 def get_formatted_name(city, country, population=''): if population: city_full_name = city + ' ' + country + ' ' + population return city_full_name.title() else: city_full_name = city + ' ' + country return city_full_name.title()
35fbf359ea587c9f61a555112ad44c56f54269d0
AFatWolf/cs_exercise
/8.3. Implementing sorting/ssort.py
344
3.671875
4
def ssort(xs): for i in range(0, len(xs) - 1): maxval = xs[i] maxpos = i for j in range(i + 1, len(xs)): if xs[j] > maxval: maxval = xs[j] maxpos = j if i != maxpos: tmp = xs[i] xs[i] = maxval xs[maxpos] = tmp b = [5,2,3,1,4] print("Before sort:", b) ssort(b) ...
e601b70a9b0c90e26a254b61247373305f95ceb4
somecallmetim/csc_849_hw1
/InvertedIndexConstructor.py
2,910
3.515625
4
from nltk.stem import PorterStemmer import string # class to help track data for each term in our document list vocabulary class InvertedIndexTerm: # constructor def __init__(self, name, docId): # fields self.__name = name self.__frequency = 1 self.__postingList = [] #s...
ca15c6e888d17156884615ebcb31bbd980f44b8c
PLUSLINKID/petri-net
/petri_net.py
4,321
3.609375
4
""" Modeling approach: * define Petri nets in terms of their transactions * define transactions in terms of the actions of their arcs * define arcs in terms with their action on their in- or outgoing place * define places as basic containers Run with python 2 or 3, for the example coded up in in __main__, vi...
8aeaa404bed3714e1bd9126ce2149baf7d5053b0
maxiumalong/m_c_problem
/search_initial.py
2,317
3.65625
4
def heap_adjust(lists, pos, length): # 堆排序(升序排列,构建大根堆): max_ = pos lchild = 2 * pos + 1 # 由于lists下表从0开始,所以左右孩子下标为2*pos+1,2*pos+2 rchild = 2 * pos + 2 if max_ < length // 2: # 注意符号是<,堆调整时,必定是从(length//2)-1开始 if lchild < length and lists[lchild][3] > lists[max_][3]: max_ = lchild ...
85c12851e6c61c42c6d4bec176714475dd4c387c
kazu74/hangman
/hangman.py
1,361
3.8125
4
def hangman(word): life=10 rletters = list(word) board = ["_"] * len(word) #win=False print("ハングマンへようこそ!") while life > 0 : print("\n") msg = "1文字を予想すべし" char =input(msg) if char in rletters: cind = rletters.index(char) board[cind] = char...
822d03054dde6bda0adf1057bb6690ec23d90ddf
kdonthi/Leetcode
/LinkedList/remove_nth_node_from_end_of_list/remove_nth_node_from_end_of_list.py
640
3.75
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode: dummy = ListNode() dummy.val = head.val dummy.next = head.nex...
84bfbd1b1425382bf1610da2c80c6cc6c3b2a660
gschen/where2go-python-test
/1906101059王曦/12月/day20191203/15.1.py
1,026
3.59375
4
#找出井字棋的获胜者 class Solution: def tictactoe(self, moves: list[list[int]]) -> str: set1 = {0,1,2} list3 = [] list4 = [] list5 = [] list6 = [] for i in range(0,len(moves),2): if i<len(moves): list3.append(moves[i][0]) list4.appen...
5e31e00bc9a8d9973d76f9ed94fc3750d4f21cd9
ema-rose/wordnik-repl
/practice/lists_and_dictionaries/ex9-7.py
212
3.5
4
n = [1, 3, 5, 6, 9, 17] # Remove the first item in the list here n.remove(1) # removes the item print n n.pop(2) # removes by place number print n del(n[2]) # will act like pop, but won't return answer print n
ba260d894df4e4466f34e82d29b98cf41a32106a
cyg2695249540/WorkWeiXin
/leetcode/demo.py
399
3.8125
4
# !/usr/bin/env Python3 # -*- coding: utf-8 -*- # @FILE : demo.py # @Author : Pluto. # @Time : 2020/11/2 19:15 class Test: listA = ['python', '是', '一', '门', '动', '态', '语', '言', '言', '语'] def test_demo(self): resultList = [] for i in self.listA: if i not in resultList: ...
d0b7736138b7034e0e5a489894d8836e874ed06b
alpablo11/Python---V1
/27.Geometri Örnek Fonksiyon.py
1,404
3.875
4
# AAI Company - Python # Fonksiyonlar konumuzu pekiştirmek için örnekle devam edelim; # Üçgen ve dörtgenleri bulacağımız bir geometri fonksiyonu yazalım: def geometri(sekil): if len(sekil)==3: a=sekil[0] b=sekil[1] c=sekil[2] if(a+b)>c and(a+c)>b and (b+c)>a: ...
2efb5584d67507e9fabee5be6aac65d6af9cecdb
gauriindalkar/list
/count length mississipi.py
481
3.671875
4
########count length of word#### how many letters reaming in word # user="mississipi" # list1=list(user) # print(list1) # i=0 # a=[] # b=[] # while i<len(list1): # count=0 # j=0 # while j<len(list1): # if list1[i]==list1[j]: # b.append(list1[j]) # count+=1 # j+=1 # ...
52439e7ad404c98c2fb18ae9443845a58393b0b0
Luna-Moonode/Moonode
/Studio-TaskNo.1/venv/lib/ToolBox/main.py
1,347
3.96875
4
# coding=utf-8 print("Welcome to the earth!\nThere're three functions:") print("1---Base64") print("2---Dictionary_Reverse") print("3---QRcode_Transfer") while True: try: choice=input("Please input the number before a function(q to quit):") except: print("Invalid input! Try again!") else: ...
8d26b1de602f884d23994da76465c2f8734d081a
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/3 Problems on range/1_DisplayNumbersInRange/Demo.py
566
4.125
4
''' Write a program which accept range from user and display all numbers in between that range. Input : 23 35 Output : 23 24 25 26 27 28 29 30 31 32 33 34 35 Input : -10 2 Output : -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 ''' def Display(iStart,iEnd): if(iStart>iEnd): print("Invalid range"); return; ...
7050cbd48ea8f9c8193295b0b7f51c8c3ef82982
ericsolis8/curso_Python
/calculadora.py
342
3.921875
4
salir=0 resultado=0 while salir==0: num1=input("Escribe un numero: ") num2=input("Escribe un segundo numero: ") calcular=input("Escribe que operacion deseas realizar: ") if calcular == "suma": suma = num1 + num2 print (suma) terminar = input("Salir S/N") if terminar == "s": salir=1 e...
7915c35ec9bf23dd7c5116706f239fe34685cc4a
Yuandjom/Automate-the-Boring-stuff-with-Python
/Chapter 5 Dictionaries/Fantasy Game Inventory.py
291
4
4
Inventory = {'rope':1, 'torch':6,'gold coin': 42,'dagger': 1 , 'arrow':12} def displayInventory(inventory): print("Inventory") total = 0 for k,v in Inventory.items(): print(v, k) total += v print("Total number of items:",total) displayInventory(Inventory)
56c4915c267d17d2cad368b1b9b08f6157312aa6
diogogarbin/curso_python
/funcao.py
644
3.78125
4
#!/usr/bin/python3 def soma(x, y): return x + y print(soma('daniel' , 'prata')) #__________________________________________________________ def boas_vindas(nome): return 'Seja bem vindo {}'.format(nome.title()) print(boas_vindas('daniel')) #_________________________________________________________ def l...
9aea97f6fc75434717e92b416e1cf0719b4904ce
ayesh99747/Python-Programming-Udemy-Course-Theory-and-Hands-on
/src/Tutorial1/Q5a.py
707
4.125
4
# Arithmetic Operators # a) Create, save and run the following program. Check the output is as expected. # #01-09.py # print(2 + 4) # print(2.5 + 4.2) # print(6 - 4) # print(6.0 - 4.5) # print(6 * 3) # print(6 / 3) # print(6 % 3) # ...
6839b16e17a881155b6fcc92f1f0a345bf167d92
Vokaunt/lesson1
/answers.py
207
3.796875
4
def get_answers(question): answers={"hello":"Hey, dude!", "what's up?":"thee best", "bye":"see u"} return answers[question.lower()] question=input("Ask yuor question?") print(get_answers(question))
1d92935b0927970611fbeb595acab327fb15de2f
mannerslee/leetcode
/146.py
1,983
3.78125
4
class Node: def __init__(self, data): self.data = data self.previous = None self.next = None class LRUCache: def __init__(self, capacity: int): self.lru_dict = {} self.point_dict = {} self.q_head = Node(-1) self.q_tail = self.q_head self.capacit...
a791f30f26442e3eae66ebdd8fe07a4ffcfd3aaa
wang264/JiuZhangLintcode
/Algorithm/L6/optional/652_factorization.py
1,898
3.75
4
# 652. 因式分解 # 中文English # 一个非负数可以被视为其因数的乘积。编写一个函数来返回整数 n 的因数所有可能组合。# # 样例1 # 输入:8 # 输出: [[2,2,2],[2,4]] # 解释: 8 = 2 x 2 x 2 = 2 x 4 # 样例2 # 输入:1 # 输出: [] # 注意事项 # 组合中的元素(a1,a2,...,ak)必须是非降序。(即,a1≤a2≤...≤ak)。 # 结果集中不能包含重复的组合。 class Solution: # @param {int} n an integer # @return {int[][]} a list of combinat...
1e3b9aad629ce86d7bf3b6cbbad3352c96f11c6e
whenhecry/Rokken
/myFilters.py
955
3.6875
4
# assuming the input is a list of articles sorted by date # return a list of article list divided by month # eg. [..., [article1 of 2015/7, article2 of 2015/7, ...], [article1 of 2015/6, ...], ...] def listOfMonth(articlesList): myList = [] year = None month = None for article in articlesList: t...
e1fb7b4c6d10810cdd07167104f6c08b7e064ea7
Dhanushu99005005/PythonAssignment
/PythonAssignment/Q6_DiffLowest.py
133
3.640625
4
"""Find the difference between two lowest numbers in the list""" list1=sorted(list(map(int,input().split()))) print(list[1]-list[0])
7be8552b9c0d3c9ba6797fe90ff7737cf213ffff
chaudhary1337/Flappy-Bird
/Game/Birds.py
2,177
3.890625
4
import pygame import config as cfg import time import random class Bird(): def __init__(self): # Design self.color = cfg.BIRD_COLOR # PHYSICS # As given in the config file ## Positions self.x = cfg.BIRD_X_INIT self.y = random.randint( \ cfg.BIRD_...
10bd21d19b4e2e3681e7ad3a90054a9e9237758f
G-itch/Projetos
/Ignorância Zero/017Exercício1.py
147
4.0625
4
n = int(input("Digite um número que eu direi seu fatorial: ")) m=1 for i in range(1, n+1): m*=i print("O fatorial de",n,"é igual a",m)
93551a004e6181f28dc95cffe5b3819c3ebd20d3
sagarambalam/fsdse-python-assignment-59
/build.py
156
3.515625
4
def solution(num1, num2, end_num): li= [] for i in range(1,end_num): if (i%num1)==0 and (i%num2)==0: li.append(i) return li
aa8718dcd8596f752d857e6819edb4f5372e16f9
chetandg143/Module
/cccc.py
586
3.984375
4
class Student: def __init__(self, name, rollno, gender, age): self.name = name self.rollno = rollno self.gender = gender self.age = age def display(ob): dict = {"sname": ob.name, "sno ": ob.rollno, "gender": ob.gender, "sage": ob.age } for x, y in dict.items(): ...
3ebbc93fb965521b2e3bed7d87cdab211da83f08
elizabethejs/practicasPython
/main.py
595
3.625
4
import argparse,sys def main(): parser=argparse.ArgumentParser() parser.add_argument('--x', type=float, default=1.0, help='Elije el primer numero para copiar') parser.add_argument('--y', type=float, default=1.0, help='Elije el segundo numero para copiar') parser.add_argument('--operation', type=str, d...
5b9ec9f0462df0454ecc46f2763138b08a2260f5
Nicko72/Harvard-Course
/Python/Loops.py
147
3.671875
4
# Nick May - Harvard Course - May 2021 for i in [0, 1, 2, 3, 4, 5]: print(i) # or do this for the same result for i in range(6): print(i)