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
2130b5b6e67e5b3f1806913ea3f9f9c298d910cc
zentonllo/gcom
/pr3/pruebas_alberto/test_regression.py
1,817
3.546875
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Test MLP class for regression @author: avaldes """ from __future__ import division, print_function import numpy as np import matplotlib.pyplot as plt import time from mlp import MLP __author__ = "Ignacio Casso, Daniel Gamo, Gwydion J. Martín, Alberto Terceño" # c...
65a5c88485e159098e78957e22149d8101921c5c
npucino/hylite
/hylite/filter/mnf.py
7,887
3.6875
4
import numpy as np import spectral from matplotlib import pyplot as plt # minimum noise filter def MNF(hydata, output_bands=20, denoise_bands=40, band_range=None, inplace=False): """ Apply a minimum noise filter to a hyperspectral image. *Arguments*: - hydata = A HyData instance containing the sourc...
4e38c1c5e24d3e98ad8deeffe955ad1e43785c08
Gulshan06/List-Assessment-
/day4/div.py
102
3.6875
4
import math a = int(input()) b = int(input()) def div(a,b): return math.floor(a/b) print(div(a,b))
5bf45d84141b951e9e74d3346cd0b87f364a42a3
giovannyortegon/holbertonschool-machine_learning
/supervised_learning/0x00-binary_classification/5-neuron.py
3,043
4.09375
4
#!/usr/bin/env python3 """ class Neuron defines a single neuron performing binary """ import numpy as np class Neuron: """ single neuron performing binary """ def __init__(self, nx): """ instance function """ if type(nx) is not int: raise TypeError("nx must be an intege...
bf649019afa7801bee2a6e4774d6755dad1c167a
jameswillett/the-ultimate-pyg-latin-translator
/pyg.py
1,422
3.875
4
original = input('Enter a sentance to translate: ') def is_all_caps(word): if (word[0].isupper() or not word[0].isalpha()) and len(word[1:]) > 0: return is_all_caps(word[1:]) if (word[0].isupper() or not word[0].isalpha()) and len(word[1:]) == 0: return True return False def has_no_letters(word): if n...
bbfa9d0d88d4ca5b75b27b5e7edd692e701e5431
ejrtn/algorithm
/Easy35.py
563
3.5625
4
class Solution(object): def searchInsert(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ r = 0 s = None for i in range(len(nums)): if nums[i] == target: s = i break ...
116651cfa22a16827c38ed2fb9084d97586cfc52
anganesh/PythonLearning
/enumerate_function.py
1,749
4.21875
4
""" enumerate : In built function accepts collection or tuples as inputs and output is an enumerated object with counter for each iterable object """ mylist = ['A', 'B' ,'C', 'D'] e_list = enumerate(mylist) print(list(e_list)) for i in enumerate(mylist): print(i) for i in enumerate(mylist,10): print(i)...
31c8cda4d963fddaf032b9fa2e31bc45034125ca
CR-ari/Python
/p.144.py
670
3.625
4
# -*- coding: utf-8 -*- """ Created on Wed Jan 8 18:37:03 2020 @author: 9876a """ userInventory = {'arrow': '12','gold coin': '42','rope': '1','torch': '6','dagger': '1'} def displayInventory(): print('Inventory:') for key in userInventory.keys(): print(userInventory[key], key) number1 = (int...
f150ace4d6131f685dd132d5b52bb1ce8b14840c
iCode0410/leetwinner
/game3.py
1,339
3.625
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- # # Jasonwbw@yahoo.com ''' [Link] https://oj.leetcode.com/problems/longest-substring-without-repeating-characters/ [Detail] There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should ...
5bd163e790df48303c6e5e6810cb00ec6d569f37
adrians-heidens/python-learn
/01-variables.py
382
4.28125
4
# Variables with integer values. # print(x) -- writes x to output. a = 12 # Assign value 12 to variable a print(a) # Print the value of a (12) b = 21 # Assign value 21 to variable b print(b) # Print value of b (21) print(a) # Print value of a (12) a = 2 # Assign value 2 to variable a print(a) # 2 b = a # As...
299033a34ab66be8f05f3f7a537ec7467df30ee2
Rosebotics/PythonGameDesign2018
/camp/MichaelN/Day 1 - The Game Loop, Colors, Drawing and Animation/01-HelloWorld.py
1,435
3.859375
4
# Authors: David Mutchler, Dave Fisher, and many others before them. print('Hello, World') print('hi there') print('one', 'two', 'through my shoe') print(3 + 9) print('hi i hav no frends') print('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
3e05c46928bb8ba7d6a93c36083caf0843cd6887
thiagofb84jp/python-exercises
/pythonCourseUdemu/algoritmosExercicios/listas/exercicio05.py
446
4.0625
4
""" 05. Write a Python program to count the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings. """ def matchWords(words): ctr = 0 for word in words: if (len(word) > 1) and (word[0] == word[-1]): ctr += 1 ...
f0316fdd3c29cf1d345cb6cefc7249f15175e96b
Valociraptor/Web-Project
/Python/ByeWorld.py
235
3.640625
4
x = "Die in a Fire" print "I'd like you to {}".format(x.upper()) listy = ['beef', 'funnel cake', 42] listx = [1, 2, 5] listy.append('corndog') print sorted(listy) if len(listy) > 12: print 'BOOF' else: print 'TACOS'
f248886a2bccdf49238ba1202fe1f316066964ce
jdHehe/Python_skiLearn
/LinearModel/RidgeRegression.py
729
3.609375
4
# -*- coding:utf-8 -*- print (__doc__) import numpy as np import matplotlib.pyplot as plt from sklearn import linear_model # 生成一个10*10的矩阵 X = 1. /(np.arange(1, 11) + np.arange(0, 10)[:, np.newaxis]) # 生成 10*1的向量 y = np.ones(10) n_alphas = 200 #默认以自然对数为底 alphas = np.logspace(-10, -2, n_alphas) print alphas coefs ...
69e34c63c8ceafee6f9388d720fbad99e8fdb8b5
David-again/learning-python
/105_Lists_and_Tuples/105-07_list_comprehension_conditional.py
721
4.375
4
# The odd_numbers function returns a list of odd numbers between 1 and n, inclusively. Fill in the blanks in the function, using list comprehension. Hint: remember that list and range counters start at 0 and end at the limit minus 1. def odd_numbers(n): return [x for x in range(1, n+1) if x % 2 != 0 ] print(odd_numb...
ba6919625f11144d5660e1aacf26380a9e5ce499
Gourav2000/Cryptographic-Encryptipon-Algorithms
/md5.py
177
3.671875
4
import hashlib str2hash = "Hello there" result = hashlib.md5(str2hash.encode()) print("The hexadecimal of the hash is : ", end ="") print(result.hexdigest())
74d813868e49a9c9987e3bb865a40e2d5eda984e
amitrajitbose/lc-july-2020
/20-Remove-Linked-List-Elements.py
487
3.53125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def removeElements(self, head: ListNode, val: int) -> ListNode: ptr = head dum = ListNode() ptr2 = dum while ptr: ...
4fdf2b7641d12d6316244f4825c1e765a509b311
ianhutomo/Places-Insight
/src/backend/DataBase.py
5,310
3.953125
4
""" An interface and implementation of database operations Here we suppose the implementation of indexing and searching are done through DB operations At the initial phase, we implement the DB through in-memory DB If time permit, we can consider using DB like MongoDB """ from abc import abstractmethod, ABCMeta import j...
580fed1f452d2795e32ef3d44f311dce408b6f28
sungpp04/discord-music-bot-ws
/mb/util.py
602
3.890625
4
# Some generic utility commands. def format_seconds(time_seconds): """Formats some number of seconds into a string of format d days, x hours, y minutes, z seconds""" seconds = time_seconds hours = 0 minutes = 0 days = 0 while seconds >= 60: if seconds >= 60 * 60 * 24: ...
12f8417e40e73203e0078d9a4a3b229a92710143
zyk930/leetcode
/065_valid-number.py
1,398
3.515625
4
#!/usr/bin/env python # _*_coding:utf-8 _*_ #@Time :2019/2/21 22:49 #@Author :ZYK #@FileName: 065_valid-number.py ''' 验证给定的字符串是否为数字。 例如: "0" => true " 0.1 " => true "abc" => false "1 a" => false "2e10" => true 说明: 我们有意将问题陈述地比较模糊。在实现代码之前,你应当事先思考所有可能的情况。 ''' class Solution(object): def isNumber(self, s): ...
52e176e0accd2f6206865249d0ca040f6bee6db1
eeee3/2020.01
/MUNOZ.Agustin/Trabajos anteriores/Ejercicio4.py
111
3.890625
4
nombre = input("Ingrese su nombre: ") num = int(input("Ingrese un numero: ")) print((nombre+"\n") * int(num))
e471e409862ed04ee2fa9d7f7b71343b85988273
taprati/Rosalind
/Algorithmic_Heights/majority_element.py
647
3.75
4
# # Majority Element # def majorityElement(arr,n): counted = [] for i in arr: if i not in counted: counted.append(i) c = arr.count(i) if c > (n//2): return i return -1 # Read in file file = open("Data/rosalind_maj.txt","r") kn = file.readline(...
3aae661ed3c322893712aa994abbc2e18d84854c
shantanu609/Leetcode
/binary-tree-paths/binary-tree-paths.py
1,016
3.53125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: res = None def binaryTreePaths(self, root: TreeNode) -> List[str]: if not root: ret...
4462f241826124e97be2b9712a5009916865a177
Jpaolo09/Python
/calculator.py
628
3.96875
4
import os again = "Y" while again == "Y": os.system('cls') print("Simple Calculator") print("\nChoose an opearation:") print("1: ADDITION") print("2: SUBTRACTION") print("3: MULTIPLICATION") print("4: DIVISION\n") choice = int(input("> ")) x = int(input("\nEnter the first ...
019f48a56bf2a269d1ecd6f53b3ebc4a3ae34afd
jharia/length-estimation-pygame
/Project/Game/testGame.py
793
3.640625
4
import pygame, sys from pygame.locals import * pygame.init() # set up the window DISPLAYSURF = pygame.display.set_mode((400, 300)) pygame.display.set_caption('Hello World!') # set up the colors BLACK = ( 0, 0, 0) WHITE = (255, 255, 255) RED = (255, 0, 0) GREEN = ( 0, 255, 0) BLUE = ( 0, 0, 255) # d...
62befaa1233592992d015562741c4dace0ab7799
SiaAnalyst/MA_2018_Python_course
/Homework02/index.py
1,692
4
4
import SimpleGUICS2Pygame.simpleguics2pygame as simplegui import random num_range = 100 secret = 0 user_guess = 0 num_guesses = 7 def new_game(): global secret, num_range, num_guesses secret = random.randrange(0, num_range) if num_range == 100: num_guesses = 7 elif num_range == 1000: n...
96bd8b67fa5018d6b6e6aee13387ccffacb39b8b
ctmm3/yahtzee
/consolyahtzee.py
14,420
4
4
#!/usr/bin/python # Wednesday, October 16, 2019 # Carter and Noel """An easy-to-play console yahtzee game.""" import random #Globals used throughout the program current_player = 0 # List contains scores of each player. first index is always human, the rest refer to number of NPC's. scores = [] # List contains the o...
7f2f97ec8394021cf74b4e9f8bf09f521b73f8b9
SaloniSwagata/DSA
/Arrays/buyandsell1.py
869
4.21875
4
# You are given an array prices where prices[i] is the price of a given stock on the ith day. # You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. # Return the maximum profit you can achieve from this transaction. If you cannot ach...
fb9ad7e8b64fa235d2131ab369360ca659d711ac
Laikovski/Hyperskills_lessons
/Dominoes/main.py
7,296
3.890625
4
# Stage 1/5: Setting Up the Game import random # class DominoGame: # stock_pieces = [[2, 5], [1, 2], [3, 6], [0, 0], [0, 2], [5, 6], [3, 5], [2, 4], [3, 4], [1, 5], [0, 4], [2, 6], [3, 3], [1, 1], [1, 4], [1, 3], [2, 3], [4, 5], [2, 2], [0, 3], [0, 6], [5, 5], [4, 4], [4, 6], [0, 1], [0, 5], [1, 6],[6, 6]] # p...
bc000a8b7375af7f9f5a6ea463bffd5af188eb1d
BenGriffith/capstone
/util.py
1,433
4.1875
4
def convertAgeToDays(age): ''' Converting value from AgeuponOutcome to age in number of days ''' days_in_week = 7 days_in_month = 30 days_in_year = 365 age_list = age.split() if age_list[1][0] == 'w': age_in_days = int(age_list[0]) * 7 elif age_list[1][0] == 'm': ag...
8d8e4053d1a6d7376524df990bb9a3622e0fb7bc
kun63/lintcode
/option_1/628_maximum_subtree.py
1,068
3.84375
4
""" Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ class Solution: """ @param root: the root of binary tree @return: the maximum weight node """ def findSubtree(self, root): # write your code here ...
a6548ddf0a56f714afc2b81f28155e4903ced770
SOURADEEP-DONNY/WORKING-WITH-PYTHON
/Codevita/TELEVISION SETS.py
2,671
3.875
4
N=int(input()) R1,R2=input().split() Revenue=int(input()) #===========================INPUTS ACCORDINGLY====================================================== #==========================CONVERTING RATES TO INT VALUES=========================================== R1=int(R1) R2=int(R2) #============================...
81e4c2972af8fb200197d074b7f648103fb9ab48
Poolet/ProjectEuler-Problems
/Euler5.py
735
3.625
4
''' Created on Mar 4, 2014 @author: TPoole Problem Summary: 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? ''' import sys; def findAnswer(): i = 1; w...
c4367b5a9bc2a500504c83a45c3d8e48026a9438
wuyongqiang2017/AllCode
/day17.1/复习.py
1,220
3.9375
4
# print("I'm ok.") # print(len(b"ABC")) # print(len("中文".encode("utf-8"))) # print("Hi %s,your score is %d."%("Bart",59)) # print(ord('A')) # -*- coding: utf-8 -*- # s1=72 # s2=85 # r=(85-72)/72*100 # print ("%.1f %%"%r) # classmates = ['Michael','Bob','Tracy'] # print(classmates) # print(len(classmates)) # print(class...
62603035095c2a3ef3797b5deac69dd5a5db6b11
jakehoare/leetcode
/python_1_to_1000/954_Array_of_Doubled_Pairs.py
1,193
3.59375
4
_author_ = 'jake' _project_ = 'leetcode' # https://leetcode.com/problems/array-of-doubled-pairs/ # Given an array of integers A with even length, return true if and only if it is possible to reorder it # such that A[2 * i + 1] = 2 * A[2 * i] for every 0 <= i < len(A) / 2. # Solution requires that numbers are paired a...
a2476fcfd81fcb7f519db30a6cf623b8fbb533b6
janderson412/OOPython3
/Chapter2/point_class.py
583
4.5
4
import math class Point: """ Point class for use in chapter 2 examples. """ def __init__(self, x=0, y=0): """ Initialize the position of the point to X,Y. Default posiiton is x=0, y=0.""" self.move(x, y) def move(self, x, y): """ Move to X, Y. """ self.x = x self.y = y def reset(se...
78bb619dffc9c71d7a411752885358761ae2a9ee
Moabi791/postgreSQL_projects
/PostgreSQL Bootcamp/23_object_oriented_programming/code.py
554
4
4
#01 Example student = {"name":"Bokang", "grades": (89, 90, 93, 78, 90)} def average(sequence): return sum(sequence) / len(sequence) print(average(student["grades"])) class Student: def __init__(self): self.name = "Bokang" self.grades = (90, 90, 93, 78, 90) def average_grade(self): return sum(self.grade...
e80b61b6f2fa2515c856de8bd9cb5f3f97182064
riddhimanroy1010/esc180
/Midterm Prep/Midterm 1/practice_mt.py
272
3.703125
4
''' Problem 1 ''' def second_smallest(nums): return sorted(nums)[1] ''' Problem 2 ''' def has22(nums): for i in range(1, len(nums)): if (nums[i] == 2)and (nums[i - 1] == 2): return True return False if __name__ == "__main__": pass
d3a176af01936686ea9a49dd59426a2bb5a5a30c
4ilo/Advent-Of-Code-2019
/day1/day1.py
740
3.703125
4
#!/usr/bin/python3 import math #FILE = "example.txt" FILE = "input.txt" def required_fuel(mass): return math.floor(mass/3) - 2 def required_fuel_fuel(mass): total = 0 while (1): mass = required_fuel(mass) if (mass <= 0): return total else: total += mass ...
5c3961c372c547750442fcec8daf702e2ef7e679
sghosh1991/InterviewPrepPython
/LeetCodeProblemsEasy/747_Largest_number_atleast_twice_of_others.py
2,013
4.0625
4
''' In a given integer array nums, there is always exactly one largest element. Find whether the largest element in the array is at least twice as much as every other number in the array. If it is, return the index of the largest element, otherwise return -1. Example 1: Input: nums = [3, 6, 1, 0] Output: 1 Explanat...
3ca233e6e277436b5aa461b4cf0b2a9cd9087ebb
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_118/2505.py
1,466
4.0625
4
def is_palindrome(string): """ (string) -> bool Return true if string is a palindrome >>> is_palindrome("a") True >>> is_palindrome("abc") False >>> is_palindrome("aba") True """ if len(string) == 0: return False if len(string) == 1: return ...
2eba10c41e680591e9942a7de8fcb6173e2097c1
kewtree1408/play_with_ml
/neuraln/nn.py
5,688
3.59375
4
from typing import Tuple, Callable import numpy as np from .activations import sigmoid from .derivatives import sigmoid_deriv from .losses import mse class Neuron: def __init__( self, weights: np.ndarray, bias: float, activation_func: Callable = sigmoid ) -> None: self.weights = weights ...
6c13905daa7208e53b8c7f17302ed58bf0a5b150
Khushal-ag/Python_Programs
/loops/pallindrome.py
163
3.84375
4
n = int(input("Enter a number = ")) c, s = n, 0 while n!=0: s = s*10 + n%10 n //= 10 if s == c: print("Pallindrome") else: print("Not Palindrome")
785c7889ae042eb83c00d10532c6aa962c6ce5a8
malika-1100/Neobis_Tasks
/cycle_D.py
171
3.546875
4
n=int(input()) if n<0: print("ERROR") else: n1=0; n2=1; i=1;summa=0; count=0 while i<n: summa+=i n1=n2; n2=i i=n1+n2 print(str(summa))
9ee3cdda66f05d5c11d9bbb6a21a99fe7238b7f7
Aditya-Lamaniya/PythonLearning
/practiceprograms.py/oddnumber.py
161
4.46875
4
#program to find if number is even of odd x=int(input("enter the number ")) if x%2==0 :print("the given number is even") else : print("the given number is odd")
d7ee837dd6cd4401b9e95c7366d11be551a0de6c
Xw-Jia/Sword_Points_To_Offer
/17_树的子结构.py
2,746
3.578125
4
''' 判断B是不是A的子结构(空树不是任何树的子结构) 思路:在A中查找B根节点一致的值,然后判断A中以该节点为根的子树,是不是和B有相同的结构 递归 ''' class Solution: def HasSubTree(self, pRoot1, pRoot2): result = False if pRoot1!=None and pRoot2!=None: if pRoot1.val == pRoot2.val: result = self.DoesTree1haveTree2(pRoot1, pRoot2) ...
b168cfbb8ef5c0311458bd89660690d51b9a23da
TANG16/multilabel-feature-selection-temp
/src/tests/binary_relevance_test.py
870
3.515625
4
# -*- coding: utf-8 -*- """ Created on Tue May 19 21:18:50 2020 @author: Mustehssun """ from unittest import TestCase class BinaryRelevanceTest(TestCase): def test_transform_data(self): total_features = ["action_scenes", "jokes", "cgi_effects", "tech_scenes"] instance_features = [ ...
f3e67e2292a450b7d2b5895128fb441b9c050200
sundusabdullah/saudidevorg
/month_3/week_3.py
5,855
3.90625
4
# day_69 # open() function f = open("hello.txt", "rt") # Open a File on the Server f = open("hello.txt", "r") print(f.read()) # Read Only Parts of the File print(f.read(5)) # Read Lines print(f.readline()) # Close Files f.close() # Write to an Existing File f = open("hello.txt", "a") f.write("Now this file has...
d51cc69e4bf4b0fe9a1d59eeec1fd9be1cf4ebc5
PreranaPandit/PythonLab_29A_29B
/LabOne/one.py
326
4.40625
4
#1.write a program that takes three numbers and prints their sum. # Every number is given on separate lines. num1 = int(input("enter the first value: ")) num2 = int(input("enter the second value: ")) num3 = int(input("enter the third value: ")) sum = num1 + num2 + num3 print(f"The sum of given three numbers is {sum}"...
55861b70b75c3174ca249f167264efb8ae8c566e
wan-catherine/Leetcode
/problems/N2499_Minimum_Total_Cost_To_Make_Arrays_Unequal.py
1,340
4
4
import collections from typing import List """ 1. find all same pair, those pairs we need to do operation. so the minimum cost is sum of index of those pairs. 2. to check if there are any pair is the major during the same pairs . a. if not, then those pair can do exchange , then result will be the cost from #1 ...
86d8825a1590eddd633382aad50eccad4924db4a
vinzydev/DataStructure_pgms
/ds_using_tuple.py
341
3.84375
4
zoo=('lion','hippo','mantis') print('Number of animals in zoo is',len(zoo)) new_zoo = 'kiraba','pyappa',zoo print('All animals in new zoo are',new_zoo) print('Animals bought from old zoo are',zoo) print('Last animal bought from old zoo is',new_zoo[2][2]) print('Total Number of animals in new zoo are', (len(new_zoo)-...
c301f795804ccf32a2aa39818cfd65d8f285c6b6
yangninghua/code_library
/book-code/图解LeetCode初级算法-源码/10/countPrimesV1.py
863
3.765625
4
#!/usr/bin/env python3 #-*- coding:utf-8 -*- # File: /Users/king/Python初级算法/code/10/countPrimesV1.py # Project: /Users/king/Python初级算法/code/10 # Created Date: 2018/10/18 # Author: hstking hst_king@hotmail.com import timeit def countPrimes(n): '''按照质数的定义,用常规的方法来取质数 ''' primesList = [] for i in range(2,...
98868a37e12fc16d5a1e0d49cb8e076a5ffb107d
hackettccp/CIS106
/SourceCode/Module10/button_demo.py
866
4.15625
4
#Imports the tkinter module import tkinter #Imports the tkinter.messagebox module import tkinter.messagebox #Main Function def main() : #Creates the window test_window = tkinter.Tk() #Sets the window's title test_window.wm_title("My Window") #Creates button that belongs to test_window that #calls the sho...
3669a6e91b9b1155ffc93b01122f675a7168cb5f
megantfanning/CrackingTheCodingInterview
/arrays-ch1/rotation1-6.py
702
3.671875
4
# 1-6 # given a image represented by at nxn matrix # were each pixel in the images is 4bytes # write a method to rotate the image by 90 degrees (in place) #Notes: if you can swap the columns with rows because of how nesting working but that swaps the y,x (column, row) to x,y (row, column) coordinates # x,y to rotate =...
e78125f0b696028e1dfc7bd353b4ba5954606ad5
eperkins1/MTranslation
/sample_python_files/nlp_tools.py
1,730
3.609375
4
# $ pip install nltk # $ python # >>> import nltk # >>> nltk.download('all') '''Usage: sentence = 'Hola, como estas?' from nlp_tools import * tokenizer = Tokenizer() tagger = Tagger() stemmer = Stemmer() tokens = tokenizer.tokenize(sentence) tags = tagger.tag(tokens) stems = stemmer.stem(tokens) ''' from nltk imp...
e8556673dc0ab7aeab834921a6759b07503ed08e
GlauberGoncalves/Python
/Lista PythonBrasil/exer16.py
286
3.625
4
t = float(input('informe o tamanho em m² ')) l = float(t / 3) if l % 18 == 0: print('voce precisara de %f latas ' %(l/18)) print('Preço: R$ %0.2f' %((l/18)*80)) else: print('voce precisara de %f latas ' %((l//18+1))) print('Preço: R$ %0.2f' %((l//18 + 1) * 80))
71a19d237733ee9052f687c58c28eebefac7cebf
jeremytrindade/demarrez-votre-projet-avec-python
/random_int.py
956
3.875
4
import random quotes = [ "Ecoutez-moi, Monsieur Shakespeare, nous avons beau être ou ne pas être, nous sommes !", "On doit pouvoir choisir entre s'écouter parler et se faire entendre." ] characters = [ "alvin et les Chipmunks", "Babar", "betty boop", "calimero", "casper", "le cha...
59dca1715f93393fe0d4193c3ded46dc13977f63
mss12138/Python-Crash-Course-Homework
/chapter05/5-7.py
419
4.0625
4
favorite_fruits = ['blueberries', 'salmonberries', 'peaches'] if 'bananas' in favorite_fruits: print("You really like bananas!") if 'apples' in favorite_fruits: print("You really like apples!") if 'blueberries' in favorite_fruits: print("You really like blueberries!") if 'kiwis' in favorite_fruits: pri...
2230cf3dbb0f62123e0bc3137eaa369ee75c79e9
lucken99/Qs
/practice/cm.py
684
3.796875
4
import sys sys.setrecursionlimit = 10**6 def memoize_factorial(f): memory = {} # This inner function has access to memory # and 'f' def inner(num): if num not in memory: memory[num] = f(num) return memory[num] return inner @memoize_factorial...
0912273da8bf680e83e0bd1284aab9acaa428737
messrobd/Lesson4-MovieWebsite
/media.py
677
4
4
class Movie(): def __init__(self, movie_title, movie_storyline, poster_image, poster_attribution, trailer_url): """ 1. behaviour: Constructor for Movie class 2. inputs: string variables for movie properties: title storyline poster poster attrib...
4f54faf1b7a2bcd91357612eba3e4421be96993e
DEEPAKp17/guvi1
/countdigits.py
69
3.515625
4
count=0 a=int(input()) while(a>0): a=a//10 count+=1 print(count)
028a22bf8709e5dae210ea6c0514e066ffda5460
zhangfhub/git_github
/python/ex1/aa.py
294
3.6875
4
score = input("请输入你的成绩:") scores=int(score) if scores>=90 and scores<100: print('A') elif scores>=70 and scores<90: print("B") elif scores>=60 and scores<70: print("C") elif scores>=0 and scores<60: print("D") else: print("你输入的是无效的成绩。")
fc8d0046a196b78086f1a23332739d3af5ed9308
prassanna-ravishankar/BankManager
/bankmanager/account.py
1,434
3.6875
4
from bankmanager.basebank import BankAccountID # Basically a wallet (can easily be blockchainified) class BankAccount(object): def __init__(self, account_id, currency=None): assert account_id is not None # Or generate new account number self._id = BankAccountID(account_id) self._currencies...
8bea3dcb8c2e6107b6bb57f8d7102c29d4ec6e2d
timofei7/master_protein
/Util.py
279
3.59375
4
#!/usr/bin/env python """ some utility functions author: Gevorg Grigoryan, 09/2016 """ import os import re import sys def logMessage(file, message): """ appends the message to the end of the file """ with open(file, "a") as myfile: myfile.write(message + "\n")
85c803ba288311ce8778af163c29a4e8bedd0d66
curiousYi/cs61a
/labs/lab04/lab04_extra.py
1,326
3.9375
4
from lab04 import * # Q13 def flatten(lst): """Returns a flattened version of lst. >>> flatten([1, 2, 3]) # normal list [1, 2, 3] >>> x = [1, [2, 3], 4] # deep list >>> flatten(x) [1, 2, 3, 4] >>> x = [[1, [1, 1]], 1, [1, 1]] # deep list >>> flatten(x) [1, 1, 1, 1, 1, 1] ...
3cef293109a8a796121ac98904fa2ffa92d4377b
Anya3002/Lab_2
/zadanie2.py
302
3.8125
4
#usr/bin/env python3 # -*- coding: utf-8 -*- #определите общие символы в двух строках, введенных с клавиатуры. if __name__ == "__main__": a = {1, 2, 3, 8, 11, 125, 13} b = {2, 5, 11, 125, 9, 60, 12} c = a.intersection(b) print(c)
178b0509689c14c9631e762fba5e9ee5d28b2aca
Yona-Dav/DI_Bootcamp
/Week_5/Day4/Daily_Challenge/daily_challenge.py
2,075
3.5
4
import string import nltk from nltk.corpus import stopwords #nltk.download('stopwords') import re class Text: def __init__(self,text): self.string = text self.text = text.lower().split(' ') self.freq = {} for text in self.text: if text in self.freq: self...
f248a68629b02b71bd7137eb956cb059a86673ad
AdrianKonca/TD_2020_44367
/LAB_10/hamming.py
3,818
3.53125
4
from utilities import make_ordinal def hamming_coding(bits): encoded_bits = [None] * 7 parity_bits = [None] * 3 parity_bits[0] = (bits[0] + bits[1] + bits[3]) % 2 parity_bits[1] = (bits[0] + bits[2] + bits[3]) % 2 parity_bits[2] = (bits[1] + bits[2] + bits[3]) % 2 encoded_bits[0] = bool(pari...
a7b19ee3349cc0f8fefc10bbb15f9ca5b500eca6
kev-kev-2124/calculator
/calculator.py
488
4.0625
4
# calculator def calculator(): operation = input(">>>Calculator: ") # This part defines what num1 is def num1(): input(int(operation)) # This part defines what num2 is def num2(): input(int(operation)) # This part defines what op is def op(): input('+' or '-' or ...
269124b4f5da738ddf6701906d63439377fb395f
caffkane/simple-prog-projects
/tax-calc.py
450
4.28125
4
""" **Tax Calculator** - Calculates the tax for a product with given product price and tax rate. """ class Tax(): def total_cost(price, tax): return int(price) + (int(price) * float(tax)/100) def main(): price = raw_input('Enter the price of an item: $') tax = raw_input('Enter the ta...
345cdf902e6d62c568f016ec41f5036aa35e6762
adityasaraswat0035/PythonDeepDive
/lesson03/airtravel.py
5,333
4.03125
4
"""Model for aircraft flights.""" from abc import ABC class Flight: def __init__(self,number,aircraft): if not number[:2].isalpha(): raise ValueError("No airline code in '{}'".format(number)) if not number[:2].isupper(): raise ValueError("Invalid airline code '{}'".format(...
d48c67b34bf18af7a495c3ca43d02f227315aeaf
rayaherrera/WeekofOct7
/NewWork.py
3,230
3.9375
4
# x = "There are %d types of people. " % 10 # doNot = "don't" # binary = "binary" # y = "Those who know %s and those who %s. " % (binary, doNot) # print(x) # print(y) # print("I said: %r" % x) # print("I also said: '%s'." % y) # hilarious = False # joke_evaluation = "Isn't that joke so funny?! %r" # print(joke_ev...
6dcdf4e8ee5aa89d235b6e051e20547c4f1094b7
JaySurplus/online_code
/projectEuler/p7.py
619
3.59375
4
def sieveOfEratosthenes(n): res = [True for i in range(n-1)] for i in range(int((n-2)**0.5)+1): if res[i] == True: j = (i+2)**2 while j-2 < n-1: res[j-2] = False j += i+2 res = [(i+2,res[i]) for i in range(len(res))] res = filter(lambda ...
259ac156db1e9f71d8e090b4d14a9d19da66827f
Azure/azure-functions-python-worker
/tests/unittests/durable_functions/activity_trigger_dict/main.py
289
3.78125
4
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. from typing import Dict def main(input: Dict[str, str]) -> Dict[str, str]: result = input.copy() if result.get('bird'): result['bird'] = result['bird'][::-1] return result
e58e6a3b9fe5daa73ee3c3af6ac2c95ae54d13b2
qmnguyenw/python_py4e
/geeksforgeeks/python/easy/16_15.py
5,637
4.25
4
Global keyword in Python Global keyword is a keyword that allows a user to modify a variable outside of the current scope. It is used to create global variables from a non-global scope i.e inside a function. Global keyword is used inside a function only when we want to do assignments or when we want to change...
d8a40a974e9d96ca2a71da6be7919dee54246ad8
jeowsome/Python-Adventures
/Rock-Paper-Scissors/Straight A's/main.py
186
3.734375
4
# put your python code here words = input().split() equivalent = 0.0 for word in words: if 'A' in word: equivalent += 1.0 print(round(equivalent / len(words), 2))
cf4325fde8eab194fe87d1957a96fb577859676c
jihanradhana/Prak_Pemrog_1_2021
/Pertemuan 5/belajaroperator.py
423
3.953125
4
a = input("Masukan nilai A = ") b = input("Masukan nilai B = ") print("A == B = " + str(a==b)) print("A != B = " + str(a!=b)) print("A > B = " + str(a>b)) print("A < B = " + str(a<b)) print("A >= B = " + str(a>=b)) print("A <= B = " + str(a<=b)) x = int(a) < 5 and int(b) > 4 print("A < 5 and B > 4 = " + str(x)) print("...
000359011db6d7e72d8e2f151663f319aa351dce
hibalubbad/hiba.baddie
/asst3_hil00/polygons.py
414
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Sep 25 18:06:38 2018 @author: misskeisha """ import turtle def cpolygon(n, size): for i in range(n): if i%2 ==0: turtle.color("black") else: turtle.color("red") turtle.forward(size) turtle.lef...
e2039f4e3a485f83308160bf8848dcc57de8312b
Nefariusmag/python_scripts
/learn_python/lesson3/work_with_file.py
1,194
3.84375
4
# Скачайте файл по ссылке (referat.txt) # Прочитайте содержимое файла в перменную, подсчитайте длинну получившейся строки # Подсчитайте количество слов в тексте # Замените точки в тексте на восклицательные знаки # Сохраните результат в файл referat2.txt def read_file(file): with open(file, 'r', encoding='utf-8') ...
de324b32cd17dfb9c7fa9f84b75d7414037e6550
PetarSP/SoftUniFundamentals
/Lab1_Basic Syntax_Conditional_Statements_and_Loops/05. Can't Sleep Count Sheep.py
203
3.6875
4
num_sheep = int(input()) total_sheep = 0 if num_sheep > 0 and not total_sheep == num_sheep: for sheep in range(num_sheep): total_sheep += 1 print(f'{total_sheep} sheep...', end="")
1f7c087caa93dc1db73a3f8a712d262a8e9dfcad
joowoonk/cs-module-project-iterative-sorting
/src/iterative_sorting/iterative_sorting.py
2,363
4.40625
4
def insertion_sort(arr): # Traverse through 1 to len(arr) for i in range(1, len(arr)): current_item = arr[i] # Move elements of arr[0..i-1], that are # greater than key, to one position ahead # of their current position prev_indx = i-1 while prev_indx ...
286adb7d1125cb6adb80cfb01e67192af06183e9
sankeerthmamidala/python
/forloop_1.py
221
4.3125
4
#printing how many numbers are odd in a given range of numbers x= eval(input('enter the number: ')) for i in range(x): if(i%2==0): print(i,'the number is even',) else: print(i,'the number is odd')
1e0b941ffeeff6049df4acfc48f62e5f2ebb9ddc
Isaac3N/python-for-absolute-beginners-projects
/heros inventory 2.py
1,332
4.09375
4
# heros inventory 2.0 # demonstrates tuples # create a tuple with some items and displays with a for loop inventory = ("sword", "armour", "shield", "healing potion") print ( "your items:") for item in inventory: print ( item ) input (" pls press the enter key to continue.")...
c5fcbe25ba61b2802a8d4baeffadcb36703408ba
ranie2019/PythonLivro
/ex5.7.py
203
3.921875
4
n = int(input('taduada de: ')) inicio = int(input('digite o inicio da tabuada: ')) fim = int(input('digite o fim da tabuada: ')) x = inicio while x <= fim: print(f'{n} x {x} = {n * x}') x = x + 1
ed1c759fdf87161f5ae5d8d302550b38fa51d891
Ozcry/PythonCEV
/ex/ex060.py
773
4.21875
4
'''Faça um programa que leia um número qualquer e mostre o seu fatorial. ex:. 5! = 5 x 4 x 3 x 2 x 1 = 120 (while é for)''' print('\033[1;33m-=\033[m' * 20) n1 = int(input('\033[36mDigite um número:\033[m ')) fatorial = 1 contador = 1 while contador <= n1: fatorial = fatorial * contador contador += 1 print('O ...
e65b65f8784f79eef30ae071d4ac09185acf11d9
DTailor/ipp_course
/lab3/model.py
382
3.78125
4
DATA = [ { 'name': 'Dan', 'surname': 'Tailor', 'age': '22', 'ocupation': 'Web Developer' }, { 'name': 'Bob', 'surname': 'Dylan', 'age': '72', 'ocupation': 'Singer' } ] def get_person_by_name(name): for person in DATA: if perso...
eb1cca6fb6cf4933300c060c511ec504be1847ca
felipevitalrc/CursoEmVideoPythonExercicios
/aula08b.py
163
3.890625
4
import math num1 = float(input('Digite um número: ')) conversao = int(math.floor(num1)) print('O número inteiro do valor digitado é: {}'.format(conversao))
5e3e038c9d31d1e99faaa6354be7fb3bc960ee9e
ykomashiro/machine-learning
/kmeans.py
3,498
3.578125
4
# -*- coding: utf-8 -*- # copyright: ykomashiro@gmail.com import numpy as np class KMeans(): def __init__(self, k=3, max_iter=500): ''' initialize some paramters :param k: the clusters we want to divide. :param max_iter: the max iteration if not convergence. ''' ...
4e01a8261cf33e85d872ecff7b4d0fcecb5d92e1
mathlf2015/Introduction-to-Computer-Science-and-Programming-Using-Python
/code_note/Wordgame_1.py
504
3.78125
4
import random secret=random.randint(1,10) print("工作室") temp = input("猜我心里想的那个数字:") guess = int(temp) while (guess !=secret): temp = input("猜错了,请重新输入") guess = int(temp) if guess ==secret: print("卧槽这都猜对了") print("猜对了也没奖励!" ) else: if guess>secret: ...
aad01c2a833f6be52a317093ec880f87bffef8e3
iara1998/atividades
/Q 13 - repetição.py
795
4.0625
4
#13. Criar um algoritmo que entre com vários números #inteiros e positivos e imprima a média dos números #múltiplos de 3. Considere a leitura de um número #zero terminar. y = [] soma = 0 x = int(input("Escreva números inteiros e positivos (0 encerra): ")) if x == 0: pass else: while x != 0: ...
c399f5b37681a22ee560b9c6925711a196390f43
MichalSudol/programming2021
/Week01-06/hello2.py
245
3.59375
4
# Sample code for labs - testing changes # author: Andrew Beatty name = input(" Hey your prefered name here:") print('Hello '+ name + '\nVery Nice to meet you') # or you could do this with format print('Hello {}\nVery nice to meet you'.format(name))
a4374c0be0730be62a69108635deefe8164e9f97
rkguptaaa/PythonProgram
/OOPS_first.py
1,113
3.875
4
####### One way #class Cat: # species = 'mammal' # def __init__(self, name, age): # self.name = name # self.age = age # # def FindEldestCat(self): # return self.age # #cat_instance = [] #cat_age = [] # #cat_instance.append(Cat('cat1', 59)) #cat_instance.append(Cat('cat2', 25)) #cat_in...
29febbf5058250f0afa49f7cda3d1262ba9a6379
GabrielCernei/codewars
/kyu8/Invert_Values.py
245
3.96875
4
# https://www.codewars.com/kata/invert-values/train/python ''' Given a set of numbers, return the additive inverse of each. Each positive becomes negatives, and the negatives become positives. ''' def invert(lst): return [-i for i in lst]
2ee084ad66cbf5c913dc3c4f4a1d51a4edcdb2a2
Nadunnissanka/Day-16-object-oriented-programing
/exercise_spirograph.py
493
3.609375
4
import turtle as t import random turtle = t.Turtle() t.colormode(255) turtle.speed("fastest") def random_color(): r = random.randint(0, 255) g = random.randint(0, 255) b = random.randint(0, 255) random_rgb_color = (r, g, b) return random_rgb_color for _ in range(100): turtle.color(random_co...
a290c547ebe11774f1c117568a853d9aa708480c
jascals/homework
/ml/Titanic/file_loader.py
965
3.5625
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt import tkinter def __main__(): loadData() def loadData(): dt_train = pd.read_csv('Titanic/train.csv') dt_train_p = dt_train.drop(['Name', 'Ticket', 'Cabin'], axis=1) labels = dt_train_p.groupby(['Survived']) dataSet = dt_tr...
ce462216039b7d0395d9c1b87f7b0f2498eafafb
waverma/battle_city
/battle_city/rect.py
1,428
3.625
4
class Rect: def __init__(self, x: int = 0, y: int = 0, w: int = 0, h: int = 0): self.x = x self.y = y self.w = self.width = w self.h = self.height = h def __eq__(self, other: "Rect") -> bool: return ( self.x == other.x and self.y == other.y ...
d13a3f6e17a6f44a20cd5ed0066058f9c145d77d
mohitsaroha03/The-Py-Algorithms
/src/zSearching/planting.py
296
3.5625
4
# def planting(A, K): counter = 0 for i in range(0,len(A)): if (A[i] == 0 and (i == 0 or A[i-1] ==0) and ( i == len(A)-1 or A[i+1] == 0)): A[i] = 1 counter += 1 if counter == K: return True, A return False print planting([1,0,0,0,1,0,0], 2) print planting([1,0,0,0,1,0,0], 3)
465d09fa3ae8ba45922086d1753c1fc73c277afe
TestowanieAutomatyczneUG/laboratorium-5-Grzeskii
/src/zad2/roman.py
413
3.625
4
class Roman: def roman(number): roman = ('M', 'CM', 'D', 'CD','C', 'XC','L','XL','X','IX','V','IV','I') arabic = (1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1) result = [] for i in range(len(arabic)): count = int(number / arabic[i]) result.ap...
40df882094dd2cec0b96d7228467bcf48f53684d
danicon/MD2-Curso_Python
/Aula14/ex10.py
311
3.859375
4
print('-'*30) print('Sequência de Fibonacci') print('-'*30) n = int(input('Quantos termo você quer? ')) t1 = 0 t2 = 1 print('~'*30) print(f'{t1} \032 {t2}', end='') cont = 3 while cont <= n: t3 = t1 + t2 print(f' \032 {t3}', end='') t1 = t2 t2 = t3 cont+=1 print(' \032 FIM') print('~'*30)
0ff4629650f12aa11068eaa27f57b12ed8193327
siyam04/python_problems_solutions
/Siyam Solved/Problem Set -1/Solutions - 1/16.py
159
3.75
4
print("Enter a fruit name:") Fruit = str(input()) if(Fruit[0] in 'aeiouAEIOU'): print("This is AN ", Fruit) else: print("This is A ", Fruit)