blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
22c14c12f08fcc25ab970493f8ef05cb5b73982b
Frindge/Esercizi-Workbook
/Exercises Workbook Capit. 2/Exercise 035 - Even or Odd.py
208
4.125
4
# Exercise 35: Even or Odd? number=int(input("Enter a valid integer number: ")) number1=number % 2 if number1 == 0: number1="the number is even." else: number1="the number is odd: " print(number1)
cd5426229c480e540ae5c3959a46b84fb9cae2c1
AmaiaBerrocal/m02_boot_0
/obPerro.py
1,559
4.0625
4
class Perro(): #Por convenio el nombre de la clase va siempre en mayúsculas. def __init__(self, nombre, edad, peso): #Siempre empieza con esta función constructora. self.nombre = nombre self.edad = edad self.peso = peso # Nos va a permitir crear instancias. def ladrar(self): # Siemp...
a59ebe710deef4d5e21a831240e7bbd7ffbed535
vitormrts/codility
/data-structure-auxiliar/linked-lists/linkedlist.py
3,805
3.9375
4
from node import Node # sequencial = [] # sequencial.append() # Lista Ligada class LinkedList: def __init__(self): # Construtor self.head = None # primeiro elemento da lista self._size = 0 # tamanho da lista def append(self, elem): # O(n) """ Adiciona um elemento ao fim da lista...
6fc9d3afb5de2cb44f80f059d631fb87e9e3b772
aa-iakupova/my_python
/3 lesson/my_func_sinus.py
158
3.765625
4
import math x=float(input('Введите число ')) def fun(x): if 0.2<=x<=0.9: return math.sin(x) else: return 1 print(fun(x))
22443e78fa5b52d5898155a1fa83c90748ee7fb6
Gabkings/coderbyte
/easy/09_time_convert.py
365
4.125
4
# Using the Python language, have the function TimeConvert(num) take the num parameter being passed and return the # number of hours and minutes the parameter converts to (ie. if num = 63 then the output should be 1:3). # Separate the number of hours and minutes with a colon. def CheckNums(num1,num2): if num1 == n...
78bd642c3da55765a2eba41d6ade20cfd7bcb517
JoaoMoreira2002/Linguagens-de-programacao
/Python/pythonProject/exercise/ex021.py
112
3.671875
4
cidade = str(input('Digite o nome da sua cidade')) cidade = cidade.lower().split() print('santos' == cidade[0])
0cc6b24389c282485801b7f5518f4d20b8f77727
demoanddemo/The-Art-of-Doing-Code-40-Challenging-Python-Programs-Today
/8_Functions/challenge_33_code.py
2,996
4.40625
4
#Functions Challenge 33: Bank Deposit and Withdrawal App def get_info(): """Get user information to store in a dict that represents a bank account""" print("Welcome to the Python First National Bank.") #Get user input name = input("\nHello, what is your name: ").title().strip() savings = int(input(...
a8663989ee8fab6bd92f18477634e8b54929ee57
xiaohema233/LearnPythonWithZeroFoundation
/03流程控制语句/06/huangrongvsyinggu_for.py
436
3.90625
4
# -*- coding:utf-8 -*- """ @ 功能:助力瑛姑 ②:for循环版解题法 @ author:无语 @ create:2017-11-13 """ print("今有物不知其数,三三数之剩二,五五数之剩三,七七数之剩二,问几何?\n") for number in range(1000): if number % 3 == 2 and number % 5 == 3 and number % 7 == 2: # 判断是否符合条件 print("答曰:这个数是", number) # 输出符合条件的数
de8a1ad5917b2715930aa8a17d9cf4f4fd448433
Chaeguevara/21_1-SNU
/ManufactureAI/excercise2-1.py
248
3.984375
4
def func(x): func = x**2 return func def derivative_of_func(x): derivative_of_func = 2*x return derivative_of_func x = -5 step = 0.1 for i in range(20): x = x -step*derivative_of_func(x) print(i,"\t: ", x, "\t:", func(x))
4e5ff346a13d70394aaf061506c6ab0a477e5ba7
HripsimeHome/python_lessons
/hw1and2.py
1,603
4.28125
4
import math # 1. Write program for calculating (a+b)^2 for some a and b a = 3 b = 4 c = (a+b)**2 print(c) # 2. Write following program: calculate how much money you should pay for 1500$ bank loan if annual percentage is 16% loan = 1500 sum = loan * 0.16 payment = loan + sum * 0.16 print(payment) # 3. Write program ...
1fd80a8a0697d3bdc5fff8ca7c4404d2df689d59
bqmoreland/EASwift
/algs2e_python/Chapter 05/python/queue_insertionsort.py
4,646
3.765625
4
import random import tkinter as tk from tkinter import ttk def sort_stack(values): num_items = len(values) # Initially consider the last item in the queue to be sorted. num_sorted = 1 num_unsorted = num_items - 1 for i in range(num_items - 1): # Take the next item and positi...
acc8dbeef620a0b24c24d8f062cd30e3a00be297
Sahil1515/sem6-Labs
/IT LAB/lab4/prog2.py
683
3.765625
4
class myClass: arr=[] def get_input(self,N): print("Enter "+str(N)+" values:") for i in range(N): ele=int(input()) self.arr.append(ele) def get_two_numbers(self,target_sum): for i in range(len(self.arr)): for j in range(i+1,len(self.arr))...
5b6956b58dca6c09f24546615b0d26fdc808a8a2
drudger/Learning-Python
/ch05/generator.expressions.py
227
3.953125
4
cubes = [k**3 for k in range(10)] # regular list print(cubes) print(type(cubes)) cubes_gen = (k**3 for k in range(10)) # create as generator print(cubes_gen) print(type(cubes_gen)) print(list(cubes_gen)) print(list(cubes_gen))
70e6fdd2f49c4cb8c5dedb0038b1a55befff5829
RomanPutsilouski/M-PT1-37-21
/Lessons/lesson 04-16/lmbd.py
1,014
3.546875
4
import functools g = lambda x: x+1 #the same thing # def g(x): # return x + 1 def generate_lambda(parameter): if parameter: return lambda x: x+1 else: return lambda x: x*x def f(l, s): for el in l: print(s(el)) #f([1,2,3,4,5], lambda x: x+1) #print(sorted(["Abc","abc","efg"...
14b0a225ec3a3a6312c9cdc7653105b9816b67ef
cmychina/Leetcode
/leetcode_剑指offer_67.剪绳子.py
417
3.59375
4
# -*- coding:utf-8 -*- class Solution: """ 可以基于数学证明,按3分割最好 a1a2...an<=((a1+a2+...an)/n)^n a1a2...an<=(k/n)^n loga1a2...an<=nlog(k/n) 导数为logk-logn-1=0 ->k/n=e->n=k/e 所以按e切分最好 """ def cutRope(self, number): res = 1 while number > 4: res *= 3 numb...
db46c0020dbbfd22d747caa1a62aaca0bc842306
sravyaysk/cracking-the-coding-interview-solutions
/LeetCode/LongestPalindromicStr.py
1,464
3.546875
4
def longestPalindrome2(s): if s == "": return s length = [] s1 = s[::-1] for c, i in enumerate(s): for m, j in enumerate(s1): if i == j: temp = s[c:len(s) - m] if temp == temp[::-1]: length.append(temp) ...
126c7684c31dfed982621bf9ec86e7e4a4c884af
k906506/2020-Algorithm
/8주차_중간고사_연습/42. SelectSort.py
399
3.8125
4
def select_sort(input_list): for i in range(len(input_list)): index = i for j in range(i, len(input_list)): if input_list[index] > input_list[j]: temp = input_list[j] input_list[j] = input_list[index] input_list[index] = temp return inp...
23db91afda1f124c6db1b2ee11d23120eb622fc9
kavdi/data-structures
/src/test_deque.py
8,472
3.515625
4
"""Tests for the deque module.""" import pytest def test_empty_deque_constructor(empty_deque): """Test that a deque created with no arguments is empty.""" d = empty_deque assert d.end is None assert d.front is None assert d._values.length == 0 def test_deque_constructor_with_empty_iterable(): ...
8064b401e915d60291c853b86414d0d5ecf87942
Panthck15/learning-python-repo1
/pandas-part2.py
1,184
3.890625
4
import pandas as pd import numpy as np df_wine_red=pd.read_csv('H:\DE\dsi-python-fundamentals\week6\day11-numpy_pandas\data\winequality-red.csv', delimiter=';') ''' #1.Grab the first 10 rows of the chlorides column. print(df_wine_red.iloc[0:10]['chlorides']) #2.Grab the last 10 rows of the chlorides column. df_la...
5268581037618f82ccd3a9c0dedcf7784382706a
raphaelscandura/python
/Python 3 - Avançando na orientação a objetos/Programa.py
652
3.59375
4
class Programa: def __init__(self, nome, ano, likes): self._nome = nome self._ano = ano self._likes = likes @property def nome(self): return self._nome.title() @nome.setter def nome(self, nome): self._nome = nome @property def ano(self): ...
06fda82a4d6e2463dfedcb1343b883db03976e0d
Swapnil2095/Python
/5. Modules/Inplace Operators/imod.py
478
3.859375
4
# Python code to demonstrate the working of # itruediv() and imod() # importing operator to handle operator operations import operator # using itruediv() to divide and assign value x = operator.itruediv(10, 5) # printing the modified value print("The value after dividing and assigning : ", end="") print(x) # using ...
770ff6cfd2732e2185a6e51d2df5dbcbe2e8df13
Koodle/Financial-Calculator
/GUI.py
7,477
3.9375
4
from tkinter import * from tkinter import ttk window = Tk() #create main window window.title("Finance Calculator") #Creates two tabs by using Notebook nb = ttk.Notebook(window) nb.grid(row=1, column=0,) page1 = ttk.Frame(nb) nb.add(page1, text="Tab1") page2 = ttk.Frame(nb) nb.add(page2, text="Tab2") ...
92a5b52e620fabf557ff30f4d1e471d783db4f2c
shreesha-bhat/Python
/series3.py
417
4.125
4
#Program to accept a number “n” from the user; find the sum of the series 1/23+1/33+1/43……..+1/n3 num = int(input("Enter the value of N : ")) sum = 0 for i in range(1,num+1): if i == 1: print(i,end='+') if i != 1 and i != num: print(f"1/{i}^3",end='+') if i == num: print(f...
181931a155d3a6f73c43a3b2a510a25a4758fb0d
Yalfoosh/AIPR
/dz/dz-02/src/utils/function.py
2,235
3.546875
4
# Copyright 2020 Yalfoosh # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, softw...
cfa8c143b9ae51ab2b1f5203e5b7f81b7824c648
kawallala/Intro_programacion
/ejercicios/ejercicio clase 18/ejercicio clase 18+.py
2,452
3.84375
4
class Fraccion: # __init__:int int -> Fraccion # cra fraccion con numerador x y denominador y # devuelve referencia(direccion) a objeto # ej: Fraccion(1,2) -> referencia a objeto def __init__(self, x=0, y=1): if type(x) == str: i=x.find('/') self.__numerador=int(x[0:i...
cf69bc14ebe8f7debaecd8debed1df8281f6499d
jessiexixit/researchProj
/mapper.py
3,520
3.53125
4
""" mapper.py file: (mapreduce - map) This file contains two function (mapper, preProcess). Using the json file as system input, read json file line by line and generate dictionary line by line. json file line format: {"url": " ", "title": " ", "dop": " ", "text": " "} Extract the words in "text", doing preprocessing ...
8d332f1ba4952b4999425c69d456ac11f801f1db
zhuhuifeng/PyOJ
/string/20_encrypt_string.py
401
3.515625
4
# coding=utf-8 # 给你个小写英文字符串a和一个非负数b(0<=b<26), 将a中的每个小写字符替换成字母表中比它大b的字母。 # 这里将字母表的z和a相连,如果超过了z就回到了a。例如a="cagy",b=3, 则输出 fdjb a = 'abef' b = 4 alphabet='abcdefghijklmnopqrstuvwxyz' res = '' for item in a: i = ord(item) - ord('a') + b res += alphabet[i%26] print res
f733d640a8567cfed7c752d5de09de28cc45c044
swm82/DataStructures-Python
/sorting/quicksort.py
1,634
3.984375
4
# Worst case: O(n^2) # Best case: O(nlogn) # Average case: O(nlogn) def quick_sort(arr): quick_sort_helper(arr, 0, len(arr) - 1) # While the undivided array has more than one element: # The array is partitioned, with the partition ending in it's sorted place # The array is recursively split around the partition d...
f07ef21d13655e2ba81e928ca6d7e73ec2ad2f01
ahmadatallah/rosalind-problems
/Textbook_BA1E.py
2,066
3.734375
4
#!/usr/bin/env python ''' A solution to a code challenges that accompanies Bioinformatics Algorithms: An Active-Learning Approach by Phillip Compeau & Pavel Pevzner. The textbook is hosted on Stepic and the problem is listed on ROSALIND under the Textbook Track. Problem Title: Find Patterns Forming Clumps in a String ...
a644259ad94db9987228c750ff24ff74572956a5
josky1917/leetcode-training
/find the midian in the top K largest element.py
649
3.546875
4
import heapq class Solution: def __init__(self, k): self.k_largest_number = [] self.remain_number = [] self.size = k def add_number(self, num): heapq.heappush(self.k_largest_number, -heapq.heappushpop(self.remain_number, -num)) if len(self.k_largest_number) > self....
b74d1dd8cf1bb0c23ce5790d1c8135e8a4c6d860
yenalbert/file-building
/DictionaryFileManager.py
1,141
3.765625
4
import pickle class DictionaryFileManager: def __init__(self, fileName): self.filename = fileName def write_dictionary_to_file(self, givenDictionary): with open(self.filename, 'wb') as writeToFile: pickle.dump(givenDictionary, writeToFile) def read_dictionary_from_file(self):...
0d64294d542ff4228ff50a3db967bd1ccca2fdf8
Aravind2595/MarchPythonProject
/functions/demo9.py
105
3.703125
4
a="helloo" b=input("enter the word to count") var=0 for i in a: if i in b: var+=1 print(var)
e526e317c308252ac521b8fee29fe5b3b0b9434f
simonhughes22/PythonNlpResearch
/Data/DirUtils.py
259
3.59375
4
import os def list_files(dir): from os import walk for (dirpath, dirnames, filenames) in walk(dir): return filenames return None def dir_exists(folder): return (os.path.isdir(folder)) and (os.path.exists(folder))
6f873babd63136d89bd5b90cf4590d377a5d9b60
shaheershantk/Anand-Python
/other chapters/cls.py
487
3.9375
4
class new: def __init__(self,a): a=3 def fun(self,y): print y def prt(self,a): self.a=a+2 print self.a class old(new): def __init__(self,x,a): print x print new(a) def prt(self,y): self.y print self.y z=old(1,3) pr...
523a7c25c5d0f180259a0d414b7132b0b848618e
alexbenko/pythonPractice
/files/encrypt.py
789
4
4
def encrypt(password="foobar123"): flipped = password[::-1] encrypted = "" for char in flipped: if char == "1": encrypted += "A" elif char == "2": encrypted += "B" elif char == "3": encrypted += "C" elif char == "o": encrypted += "0" elif char == "f": encrypted +...
9227a7a8b9f0ee651e3ce20881cbf999324a394f
sci2pro/pl1c
/week5/while.py
1,485
3.921875
4
import os import sys def main(): # simple while i = 0 while i < 10: # as long as this is True we loop print(f"i = {i}") # modify the value i # whenever <assign_expr> has '<' then i has to be incremented i += 1 print(f"value of i after while: {i}") # reverse loopin...
540ad101fc632c4051ebf88f52e92c4e736c17b6
bascoe10/pen-test-server-python
/server1.py
425
3.65625
4
import socket host = "10.0.0.167" # server address port = 12345 # port of server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # create a socket s.bind((host,port)) #bind server - connects address to socket s.listen(2) # starts the tcp listener conn, addr = s.accept() # use to accept connection from client pr...
cfc95d76e4810cfdc68644a1d42e8af15447d7ac
sameeksharathi/Codes
/ChefAndString.py
1,148
3.859375
4
''' There are N students standing in a row and numbered 1 through N from left to right. You are given a string S with length N, where for each valid i, the i-th character of S is 'x' if the i-th student is a girl or 'y' if this student is a boy. Students standing next to each other in the row are friends. The students...
9c07b148a02ee7c25e56e367f09ab2a04dce90f3
f18-os/python-intro-magiking
/wordCount/coolerWordCount.py
856
4.15625
4
#!/usr/bin/env python3 import sys import re import os from collections import Counter # For easy counting # input and output files if len(sys.argv) is not 3: print("Correct usage: coolerWordCount.py <input text file> <output text file>") exit() inputFname = sys.argv[1] outputFname = sys.argv[2] #check that ...
1f26686e4bfbf8507f872929fde489fe944e635a
xzguy/LeetCode
/Problem 1 - 100/P24.py
439
3.53125
4
class ListNode: def __init__(self, x): self.val = x self.next = None def swapPairs(head: ListNode) -> ListNode: if not head or not head.next: return head beg = ListNode(0) prehead = beg prehead.next = head while prehead.next and prehead.next.next: a = prehead.ne...
b52affd07fbf1039b2a261c39803d78096eaca4d
eltonrp/curso_python3_curso_em_video
/02_estruturas_de_controle/ex061.py
190
3.796875
4
p = int(input('Primeiro termo: ')) r = int(input('Razão: ')) dez = p + (10 - 1) * r while p < dez: print('{} → '.format(p), end='') p += r print('{}'.format(p), end=' → ACABOU')
9c1f9ff23618afb2bb2172b689a49d52aaf2ed68
LeftysWorld/machine_learning_practice
/part_one/lesson_seven/practice/3_computing_sharpe_ratio.py
4,337
3.859375
4
# coding=utf-8 import os import pandas as pd import matplotlib.pyplot as plt import numpy as np """ Computing Sharpe Ratio: Rp: Portfolio return Rf: risk free rate of return σp: std dev of portfolio return # [expected value of the return on a portfolio - Rp] / [standard deviation of same difference] # Called Ex Ante ...
709b7f6b3b76a07929efd2f88ff8572a86bb1e87
AjayKarki/DWIT_Training
/Week3/Assignments/prob_finder.py
727
3.96875
4
""" Write a function to compute the probability of the occurrence of these words in the file provided in the last assignment. i) silver ii) the iii) a """ import re def prob_cal(word, contents, total_occ): favourable = contents.count(word) return favourable / total_occ file1 = open('shakespeare.txt', 'r') ...
11d5481414b840c426920f0406c8bdc5cd4a4613
ninadmhatre/pylrn
/Sort/InsertionSortAddon.py
4,016
3.6875
4
__author__ = 'Ninad' from addonpy.IAddonInfo import IAddonInfo import Helper from Helper import Common class InsertionSortAddon(IAddonInfo, Common): loop_count = 0 @Helper.MeasureTime def execute(self, data, output=True, reverse=False, very_verbose=False): """ Just wrapper around algorit...
ecfe7be735af6e7541b1d0a7a276bb6084c44140
bsamseth/project-euler
/018/18.py
4,164
3.53125
4
""" By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. That is, + + + = 23. Find the maximum total from top to bottom of the triangle below: """ inputdata = """ 75 95 64 17 47 82 18 35 87 10 20 04 82 47 65 19 01 23 75...
e9a7b41df9b7afd82c445d6b8732319fd562a53e
htmlprogrammist/kege-2021
/tasks_22/homework/task_22.5.py
1,155
3.859375
4
""" Задание 22 (№503). Ниже на четырех языках программирования записан алгоритм. Получив на вход натуральное десятичное число x, этот алгоритм печатает число S. Сколько существует чисел x, не превышающих 500, при вводе которых результате работы программы на экране будет выведено число 13. """ # x = int(input()) # S = ...
404e650907feb86fcd25e4aacbfd41eaac004cb0
jessieengstrom/hackbright-challenges
/decode/decode.py
1,025
4.28125
4
"""Decode a string. A valid code is a sequence of numbers and letter, always starting with a number and ending with letter(s). Each number tells you how many characters to skip before finding a good letter. After each good letter should come the next next number. For example, the string "hey" could be encoded by "0h...
73400d401a69f40905d326af2b2bfb019cb6cd87
ZouaghiHoussem/hosvd
/svd/A-AT.py
349
3.609375
4
import numpy as np from math import sqrt A=np.array( [ [5,3,5], [4,2,1], [0,3,3], ] ,dtype = 'float64') print "input:\n",A,"\n\n" l = np.matmul(A, A.T) r = np.matmul(A.T, A) print l print "\n" print r sU, U = np.linalg.eigh(l) sV, V = np.linalg.eigh(r) print "\n" for i in sU: print sqrt(i), #print sU #print sV...
1f24e7dd0cb9514e0ab48684dd1cb9cca2a41a84
d3z/AdventOfCode
/DayTwo/wrapping.py
1,037
4.0625
4
def wrapping(dimensions): """ Calculates the wrapping paper needed for a package of the given dimensions >>> wrapping([2, 3, 4]) 58 >>> wrapping([1, 1, 10]) 43 """ [size1, size2, size3] = dimensions return (3 * (size1 * size2)) + (2 * (size2 * size3)) + (2 * (size1 * size3)) ...
3fa977c4986263b5e44606b2ddf1716fff9c1c92
yoohuck12/2017_06_PLT
/page_speed/learning_algos.py
1,812
4
4
print(__doc__) import matplotlib.pyplot as plt import numpy as np from sklearn import datasets, linear_model import math class LearningAlgorithms: def __init__(self, data, target): self.data = data self.target = target def linear_regression(self): data_X = self.data target_y...
dc43709f1b9be6eb5a96e5b984b0ca6defbc81d9
ZL63388/data-preparation-codes
/feature_scaling.py
649
3.515625
4
# import packages import pandas as pd import numpy as np from sklearn.preprocessing import StandardScaler from sklearn.preprocessing import MinMaxScaler # create a sample dataframe my_df = pd.DataFrame({"Height": [1.98,1.77,1.76,1.80,1.64], "Weight": [99,81,70,86,82]}) # Standardisation scale...
81c806eb984ddb025b0e4c935dd0e7c1caceae96
CollectorFTB/ImageCode
/encode.py
2,469
3.765625
4
from util import * # Encoding part def encode(image, message): encoded_message = encode_message(message) # Data hiding # get rid of nbits least significant bits image = erase_n_bits(image, 'lsb') # put the data into those bits image = insert_data(image, encoded_message) # store length of ...
914e05aa9edac0712df938aaa3712520917f4962
RyanChen1204/MachineLearning
/KNN/kNN.py
2,604
3.71875
4
# !/usr/bin/env python # -*- coding:utf-8 -*- """ KNN algorithm author:Yang Liu use KNN algorithm to achieve digital recognition """ import numpy as np from os import listdir # 读取32*32图像文本,转为向量返回 def img2vector(filename): retVect = np.zeros((1, 1024)) fr = open(filename) for i in range(32)...
6f7f00c50ea0b4788264a3376676c196c3922c84
divyarsada/sample-python-scripts
/get_weathemap.py
1,136
3.703125
4
import requests from argparse import ArgumentParser import sys import os, json #Get the Cityname from the commandline parser = ArgumentParser(description='Get the current weather information') parser.add_argument('city_name',help='Provide the name of the city for which weather info is needed') args = parser.parse_args(...
328f82dfe77a910e6079e3816c88ff7b71482171
akashshegde11/python-practice
/Introduction/intro_7.py
881
4.1875
4
# Simple Calculator Program def add_num(num1, num2): return num1 + num2 def subtract_num(num1, num2): return num1 - num2 def multiply_num(num1, num2): return num1 * num2 def divide_num(num1, num2): return num1 / num2 print( "Please select operation:\n" "1. Add\n" "2. Subtract\n" ...
248397f824d59bfb863faae6c034089f4c88f41c
mohitmukheja/Learn-Python-3-the-Hard-Way
/ex6.py
1,381
4.46875
4
#setting types_of_people value as 10 types_of_people = 10 #using fstring to call out variable value in a string and setting value of x as that string x = f"There are {types_of_people} types of people." #setting variabl values and then using fstring to call call out in a string while assinging value to variable y ...
02e3f5b640bfc1475c75eff96ee5be76244a9dc0
marcos-saba/Cursos
/Curso Python/PythonExercicios/ex073.py
1,099
3.6875
4
lista_times = ('Palmeiras', 'Cruzeiro', 'Grêmio RS', 'Santos SP', 'Corinthians', 'Flamengo', 'Atlético MG', 'Atlético PR', 'Internacional', 'Chapecoense', 'Botafogo', 'São Paulo', 'Fluminense', 'Vasco da Gama', 'Bahia BA', 'Sport PE', 'Vitória BA', 'Ponte Pret...
ad81da60d3449bcc78465bc4d786c6deb0dcbb51
Goessi/Machine_learning
/intermediate/Overfitting.py
4,761
3.640625
4
## 1. Introduction ## import pandas as pd columns = ["mpg", "cylinders", "displacement", "horsepower", "weight", "acceleration", "model year", "origin", "car name"] cars = pd.read_table("auto-mpg.data", delim_whitespace=True, names=columns) filtered_cars = cars[cars['horsepower'] != '?'] filtered_cars['horsepower'] = ...
aed158ece242617250e4b18fb89e3e592ad4f269
Exopy/exopy_qm
/exopy_qm/utils/utils.py
263
3.75
4
def is_float(x): try: a = float(x) except ValueError: return False else: return True def is_int(x): try: a = float(x) b = int(a) except ValueError: return False else: return a == b
7e8b487c8ac791b4d7d22daf403515b5560d5a76
way2muchnoise/Advent2018
/day05/part2.py
741
3.890625
4
import string import StringIO def is_opposite(a, b): return a == b.swapcase() and b == a.swapcase() def react(f): chars = f.read(1) next_char = f.read(1) while next_char: if len(chars) > 0 and is_opposite(chars[-1], next_char): chars = chars[:-1] else: chars +...
259fa4d011e9bb668926a828293c0e35316544b2
fuckualreadytaken/InfoSecuMath
/homework6.py
865
3.734375
4
#! /usr/bin/env python # coding=utf-8 # F2域上的多项式带余除法的实现 def division(str1, str2): if str2[0] == 0 or str1[0] == 0: print "Invalid parameter!" exit() l1 = list(str1) l2 = list(str2) quot_len = len(l1) - len(l2) - 1 quotient = [] remainder = [] windowsize = len(l2) print ...
c7bb1a1af1e6a2ce0ad5a88fbb5b366d80d5ef88
AshciR/stripni-card-game
/textstripni.py
3,651
3.625
4
# textstripni.py # Written by: Richard Walker # Date: June 23, 2014 """textstripni.py Provides a text-based interface for the Stripni game.""" from card import Card class TextInterface: """Creates a text-based interface for the Stripni game""" def __init__(self): """Creates a new player with the gi...
6e34106e43fc352a85705484ec104be4fb40142d
Shinnnyshinshin/LeetCode
/108_SortedArraytoBinarySearchTree.py
1,826
3.578125
4
#------------------------------------------------------------------------------- # #------------------------------------------------------------------------------- # By Will Shin # #------------------------------------------------------------------------------- # LeetCode prompt #--------------------------------...
56287865c48fe91bdd4ba93d4a1a8493109ac2c4
Jesus-Fonseca/Practica_02
/Tarea_2_2.py
2,128
3.890625
4
# -*- coding: utf-8 -*- """ Created on Wed Feb 12 12:19:24 2020 @author: PC """ class User(): def __init__(self,first,second): self.first_name = first self.second_name = second self.num_intentos = 0 def describe_user (self): print ("Primer apellido: " + self.first_...
6d64b8b828e13fda10d762a120889b82c02eb1b3
Aasthaengg/IBMdataset
/Python_codes/p03576/s466877985.py
1,261
3.515625
4
#!/usr/bin/env python3 import sys from itertools import product INF = float("inf") def solve(N: int, K: int, x: "List[int]", y: "List[int]"): sx = sorted(x) sy = sorted(y) m = INF for (i, x1), (j, y1) in product(enumerate(sx[:-K+1]), enumerate(sy[:-K+1])): # 始点を固定 for x2 in sx[i+1:]: ...
057f4a586425cb2fecac287d96e29fd03b6a19a8
lin-br/pythonando-do-lin
/studies/classes/aula006_condicoes/challenge005.py
463
4
4
""" Faça um programa que leia um ano qualquer e mostre se ele é BISSEXTO. """ from datetime import date year = int(input('Digite um ano para verificar se é bissexto (digite 0 para o ano atual): ')) year = date.today().year if year == 0 else year isLeapYear = year % 4 == 0 and year % 100 != 0 or year % 400 == 0 if isL...
480f4e237a9012096ba26e9289ed3c51d8c2a54c
shuvo14051/python-data-algo
/Problem-solving/UVA/12577 - Hajj-e-Akbar.py
221
3.5
4
try: i = 1 while True: inp = input() if inp == '*': break if inp == 'Hajj': print ('Case '+str(i)+': '+'Hajj-e-Akbar') else: print('Case '+str(i)+': '+'Hajj-e-Asghar') i = i+1 except EOFError: pass
bf4b93cf580720d5a17c173eddcdc38d2212cf0b
sebastianwaleka/excersises
/jumpingOnClouds.py
1,594
4.21875
4
''' Emma is playing a new mobile game that starts with consecutively numbered clouds. Some of the clouds are thunderheads and others are cumulus. She can jump on any cumulus cloud having a number that is equal to the number of the current cloud plus 1 or 2. She must avoid the thunderheads. Determine the minimum number ...
62f491de1f8729581857492dd46e9214c2fc68c5
ViniciusDeep/Answers-URI-Online-Judge
/Answers/Python/1011.py
133
3.546875
4
# -*- coding: utf-8 -*- pi = 3.14159 raio = input() raio = raio*raio*raio volume = (4.0/3.0)*pi*raio print("VOLUME = %.3f" %volume)
42fe7ebdc1179b9a0c900d373bc04569e7f43675
livwittlin/o1-.
/Unit 2 Project.py
9,876
3.90625
4
# these are you health points and your opponents health points hp = 100 enemyhp = 100 # this lets your opponet use a move at random import random # these are the level 2 water moves if you pick the pokemon totidile wgun = 40 bubble = 30 # these are the level 2 fire move if you pick the pokemon Cyntiquil flame_wheel ...
897c05f1f482a7ea65e4d287a7afe46394d52824
rafaelpederiva/Resposta_Python_Brasil
/Exercícios de Estrutura de Decisão/Exercício 19 - Centena Dezena Unidade.py
2,498
4.125
4
#Exercício 19 '''Faça um Programa que leia um número inteiro menor que 1000 e imprima a quantidade de centenas, dezenas e unidades do mesmo. Observando os termos no plural a colocação do "e", da vírgula entre outros. Exemplo: 326 = 3 centenas, 2 dezenas e 6 unidades 12 = 1 dezena e 2 unidades Testar com: 3...
bcfe4674dfd5503d72ec43e2ef15cf84b860d897
chowdy/project-euler-python
/solutions/007.py
322
3.875
4
""" By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? """ import solutions.pe_utils as pe def solution(): count = 0 for i in pe.PrimesIterator(): count += 1 if count == 10001: return i...
675f68bdd4008c73224d731e1603e9d7ceb70935
birdhermes/CourseraPython
/3_week/Первое и последнее вхождение.py
840
4.1875
4
# Дана строка. Если в этой строке буква f встречается только один раз, выведите её индекс. Если она встречается два и # более раз, выведите индекс её первого и последнего появления. Если буква f в данной строке не встречается, # ничего не выводите. При решении этой задачи нельзя использовать метод count и циклы. # Форм...
8fbc8f2ce4e7a2bd9ae42a24f82111426a094188
anastasiia-shevchenko/Python-3-course
/lab 09/src/my_class.py
2,898
4.125
4
from abc import ABC, abstractmethod class Library: def __init__(self, name, age): self.persons_list.append(name) self.__name = name # instance variable Переменные экземпляра уникальны для каждого экземпляра self.__age = age # устанавливаем возраст class Books: """Модель книги""" ...
bd9c5c27a057ab493f8340255111cb6edbd10ca3
yunyusha/xunxibiji
/month1/week1/Python_class2/test.py
2,337
3.796875
4
# # 第四题 (星座) # month = (input("请输入出生在几月份")) # day = (input("请输入出生在几日")) # rmonth = int(month) # # rday = int(day) # if rday<10: # day = str(rday) # day = "0" + day # bir = int(month + day) # # if rmonth>12 or rday>31: # print("输入错误") # else: # if bir <= 419 and bir>=321: # print("白羊座") # eli...
6e99c7fcc6b8cd77b8ecfb339a118c5f80fec5db
Megha1507/Python
/Armstrong Number.py
854
4.5625
5
"""A number is called Armstrong number if it is equal to the sum of the cubes of its own digits. For example: 153 is an Armstrong number since 153 = 1*1*1 + 5*5*5 + 3*3*3.""" # to check 3 digit number only num = str(input("Enter a number: ")) p1 = num[0] p2 = num[1] p3 = num[2] num1 = ((int(p1)**3) + (int(p2)**3) + (...
78f5584d784fa08ece4d594788b1dadddf6c9abe
elainechan/Python3_Practice
/metalband_generator.py
1,125
3.90625
4
# A program that generates random metal band names """ Earlier today, in the Recurse Center Slack Room, one of my mentors jokingly suggested a project idea for a "cool metal band generator." I thought that was a fun idea, so I made one. Whether the names generated are cool or not is up for debate. Some examples: asse...
6e5ebced32834ab0adbc59d4e0eac64d3f96f162
nazaninsbr/Attendance-Check
/Backend-Classes/exam.py
396
3.5625
4
class Exam: def __init__(self, id, start_at, end_at, room): self.id = id self.start_at = start_at self.end_at = end_at self.room = room def get_id(self): return self.id def __str__(self): return '-------'+'ID:'+str(self.id)+'-------\n'+' Start:'+self.start_a...
621747e1f1144267956b5222a1930f68072d1e5c
kuqadk3/CTF-and-Learning
/usaco/1.2/friday_the_thirteenth/friday_the_thirteenth.py
1,141
3.5
4
""" ID: kuqadk31 LANG: PYTHON2 TASK: friday """ fin = open('friday.in', 'rb').read() fout = open('friday.out', 'wb') day = 0 day_of_month = 1 N = int(fin) d = {} for i in range(0, 7): d.update({i : 0}) d.update({5 : 1}) arr = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] #day = ...
ef5d51e85ad4ed06f9f972d2255b4134154a98ff
ELLINM/coding_tutorial
/Python/practice190228_2.py
650
3.640625
4
def binary_search(data, target): data.sort() start = 0 end = len(data) - 1 while start <= end: mid = (start + end) // 2 if data[mid] == target: return mid elif data[mid] > target: end = mid - 1 else: start = mid + 1 return None ...
612066060a704804b5d84222550031cd067d35e9
martinmathew/geek4geeks
/python/src/linkedlist/LinkedList.py
1,941
3.921875
4
class LinkedList: head = None class Node: def __init__(self,val): self.val = val self.next = None def insert(self,val)->Node: newNode = LinkedList.Node(val) if self.head is None: self.head = newNode else: temp = self.he...
ed13b126f01c0bb683a4426e5f33a29e60f3ee89
zohaibafridi/Scripts_of_Data_Exploration_and_Analysis_Book
/Volume_I/2-Numpy/Code_Scripts/2.1-Ndarray Object .py
1,764
3.734375
4
#!/usr/bin/env python # coding: utf-8 # ### Example 1 # In[2]: import numpy as np a = np.array([1,2,3]) print (a) # ### Example 2 # In[4]: # more than one dimensions import numpy as np a = np.array([[1, 2], [3, 4]]) print (a) # ### Example 3 # In[5]: # minimum dimensions import numpy as np a = np....
5513fbc2d88ae15f4265149bae006357343ec11a
nurlanotek/python-aiu
/ps/evaluations/square.py
396
4.1875
4
# Week 5 - Problem Set 5. CS 101, Computer Science department, AIU # Write a Python function, 'square', that takes a number and returns its square. def square(x): ''' Function that calculates the square of the given number. :param x: int :return: int or float >>> square(4) 16 >>> square(0) ...
45e45d38f22735ade6c8f58dd8e08fed8d7c6b8a
shuangyichen/leetcode_python_0311
/对称的树.py
1,307
3.53125
4
class Solution: def isSymmetric(self, root: TreeNode) -> bool: if root==None: return True inorder = self.levelOrder(root) print(inorder) for i in range(1,len(inorder)): if len(inorder[i])%2==0: a = inorder[i][0:int(len(inorder[i])/2)]...
7f0ab6c54875660b6349e11e5509c05a2bedb5a3
plammens/python-introduction
/Fundamentals II/Loops/While loop/main.py
528
3.875
4
import random i = 1 while i <= 100: print(i) i += 1 my_list = [] while len(my_list) < 10: my_list.append(random.randint(1, 10)) roll = random.randint(1, 6) while roll%2 == 0: print(roll) roll = random.randint(1, 6) inp = None while not inp: inp = input("Enter a nonempty string: ") print(f"...
9ccb4cc867dc920aae69623f424286efacd04e5b
snehal288/assignment_1
/assign24.py
263
3.90625
4
def fact(n): f=0 for i in range(1,n): if n%i==0: print(i) f=f+i return f def main(): x=int(input("value is:")) ret=fact(x) print("addition of factors:",ret) if __name__=="__main__": main()
7d2ee4cfc375f13181787720e0cb824c2cae5d7e
european-54/python_algos_gb
/Урок 7. Практическое задание/task_1.py
1,977
3.578125
4
""" 1. Отсортируйте по убыванию методом "пузырька" одномерный целочисленный массив, заданный случайными числами на промежутке [-100; 100). Выведите на экран исходный и отсортированный массивы. Сортировка должна быть реализована в виде функции. Обязательно доработайте алгоритм (сделайте его умнее). Идея доработки: если...
fa9572c12601484efa953ad650eba45a252c83cc
shinz4u/CTCI
/Python/dynamic_programming/robot.py
648
3.828125
4
def robot(r, c, no_entry, path): if [r, c] in already_seen: return False if r < 0 or c < 0: return False if [r, c] in no_entry: return False isDestination = (r == 0 and c == 0) if (isDestination or robot(r-1, c, no_entry, path) or robot(r, c-1, no_entry, path)): path...
2a524ab416970802a3a55ed5f983b32c39568836
Rudedaisy/CMSC-201
/Homeworks/hw8/hw8_part1.py
990
4.46875
4
# File: hw8_part1.py # Written by: Edward Hanson # Date: 11/20/15 # Lab Section: 18 # UMBC email: ehanson1@umbc.edu # Description: takes in a user generated list and prints it out in reverse order using a # recursive function def main(): myList = [] response = int(input("Enter a ...
1619f654d3676c5c73b2bdb235b7a084bb4ec891
taishi8117/blackhat_python
/pentester/4_webapp/download_progress.py
1,355
3.609375
4
#!/usr/bin/python """showing the progress of downloading a large file from internet using urllib.urlretrieve - for exercise 4.1""" import urllib, sys, getopt, time from progressbar import ProgressBar p=ProgressBar(100) def usage(): print "Usage: ./download_progress.py <url1> <url2> ... <urln>" def dlProgress(co...
6f5dc9e675a24d3489f7b3e390b3da9f1c63cc4f
yz5308/Python_Leetcode
/Algorithm-Easy/263_Ugly_Number.py
655
4.21875
4
class Solution: def isUgly(self, num): """ :type num: int :rtype: bool """ if num == 0: return False for i in [2,3,5]: while num%i == 0: num /= i return num == 1 """ Time Complexity = O(logn) = O(1) ...
1b61ecfd8a671a62bfdfdc764982af2fcba3fbcf
AdamZhouSE/pythonHomework
/Code/CodeRecords/2691/60648/291237.py
606
3.59375
4
from typing import List class Solution: def largestRectangleArea(self, heights: List[int]) -> int: n, heights, st, ans = len(heights), [0] + heights + [0], [], 0 for i in range(n + 2): while st and heights[st[-1]] > heights[i]: ans = max(ans, heights[st.pop(-1)] * (i - st...
f0dd0130aaae419012d7d92f1d712a639cb235df
TomasYin/arithmetic
/array/rotate_Image.py
382
3.96875
4
# -*- coding:utf-8 -*- """ file:顺时针旋转n*n的二维数组 """ def rotate_Image(nums): new_list = [] n = len(nums) for i in range(n): new_list.append([]) for j in range(n): new_list[i].append(nums[n-1-j][i]) #print(new_list) return new_list if __name__ == '__main__': a ...
afce2d6796cf94147b293513e88bd148a5d90946
Iso-luo/python-assignment
/practice/Ch4_interface design/lalal.py
99
3.59375
4
# -*— coding:utf-8 -*- r = range(9) l = list(range(9)) print(type(r),':',r) print(type(l),':',l)
cc36e56dd64f433408af47f032f6df7fccf6c13f
maci2233/Competitive_programming
/CodeForces/A/270a.py
149
3.65625
4
n = int(input()) for i in range(0, n): a = float(input()) if 360.0 % (180.0-a) == 0: print("YES") else: print("NO")
e0f51214a632185b3c24f743fc26b7fa7652f7ef
brooklynphotos/codingexercises
/main/python/hackerrank/maxSubarray.py
1,074
3.828125
4
# https://www.hackerrank.com/challenges/maxsubarray/problem def maxSubarray(arr): return [max_subarray(arr), max_subsequence(arr)] def max_subsequence(arr): sarr = sorted(arr) if(sarr[-1])<=0: return sarr[-1] sum = 0 for x in sarr: if sum > 0: sum += x elif x>0:...
7537347a5ab78aa116e1735624d625a3edadb768
CatonChen/algorithm023
/Week_07/[628]三个数的最大乘积.py
831
3.5625
4
# 给你一个整型数组 nums ,在数组中找出由三个数组成的最大乘积,并输出这个乘积。 # # # # 示例 1: # # # 输入:nums = [1,2,3] # 输出:6 # # # 示例 2: # # # 输入:nums = [1,2,3,4] # 输出:24 # # # 示例 3: # # # 输入:nums = [-1,-2,-3] # 输出:-6 # # # # # 提示: # # # 3 <= nums.length <= 104 # -1000 <= nums[i] <= 1000 # # Related Topics 数组 数...
668b4f7c6bd55fc2d6831aac0f75ad38110b0bee
radarm/F0005
/f0005c.py
295
3.546875
4
szam1 = 30 szam2 = 62 eredmeny = szam1 + szam2 tipp = int(input('Mennyi ' + str(szam1) + '+' + str(szam2) + '?')) #nem tudtam, hogy mit kéne csinálnom, ezért megnéztem a megoldást... if tipp == szam1 + szam2: print('A megoldás helyes.') else: print('A megoldás nem jó, tökfej.')
f46701d22d1f9f7260aab71e163aa4c67d90f969
salahalaoui/codeWarsPython
/StringIncrementer.py
723
3.578125
4
def increment_string(strng): number = 0 output = "" numberDigit = 0 findNotDigit = False k = 0 for i in range(len(strng) - 1, -1, -1): if strng[i].isdigit() and not findNotDigit: numberDigit = numberDigit + 1 number = number + int(strng[i])*(10**k) k =...
25b949bd52edea52e99c273950129138e0f79ee0
zhucebuliaolongchuan/my-leetcode
/Backtracking/LC89_GrayCode.py
1,671
3.890625
4
""" 89. Gray Code The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0. For example, given n = 2, return [0,1,3,2]. Its gray...