blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
dd3749681cb56f0a22f138d2373c0f1c140c8a91
xiaolongwang2015/Interview
/54螺旋矩阵.py
2,047
3.828125
4
""" 54 螺旋矩阵 难度:中等 题目描述: 给你一个 m 行 n 列的矩阵 matrix ,请按照 顺时针螺旋顺序 ,返回矩阵中的所有元素。 示例1: 输入:matrix = [[1,2,3],[4,5,6],[7,8,9]] 输出:[1,2,3,6,9,8,7,4,5] 示例2: 输入:matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]] 输出:[1,2,3,4,8,12,11,10,9,5,6,7] m == matrix.length n == matrix[i].length 1 <= m, n <= 10...
3eaa2d83b1da5e09358e6cba4fd210a54ad70ced
Julesya/Tugas-Algoritma-dan-Pemrograman
/Python/Menghitung Panjang dan Lebar.py
254
3.703125
4
#!/usr/bin/env python # coding: utf-8 # In[1]: panjang=float(input("ketik nilai panjang =")) lebar=float(input("ketik nilai lebar =")) keliling = 2*panjang+2*lebar luas = panjang*lebar print("keliling = ",keliling) print("luas =",luas) # In[ ]:
ddd4574041cab441d6c2a097dc0eb4ca32164699
omarsaad0/Python-Learning
/Python_Elzero/037_TypeConversion.py
1,302
4.09375
4
# Type Conversion # str() ########################################################################### a = 10 print(type(a)) print(type(str(a))) print("/|"*50) # tuple() c = "Omar" # string d = [1, 2, 3, 4, 5] # List e = {"A", "B", "C"} # Set f = {"A": 1, "B": 2} # Dict print(tuple(c)) print(tuple(d)) print(tu...
0715ab9f5fad4dbad4fbf270764b3f16cf4bfd2d
avinashyeccalluri/java
/Python/First.py
93
3.515625
4
a="WhAt! FiCK! DaMn CAke?" b=a.split(" ") print(''.join(e for e in a if e.isalnum()).lower())
2792ceb1ad68c14652de8bfbfbbaea2907769e77
ch-canaza/holbertonschool-higher_level_programming
/0x0A-python-inheritance/101-add_attribute.py
314
4.125
4
#!/usr/bin/python3 """ module 101-add_attribute contains the function add_attribute """ def add_attribute(obj, name, value): """ if possible, add a new attribute to an object """ if hasattr(obj, '__dict__'): setattr(obj, name, value) else: raise TypeError('can\'t add new attribute')
00626a76a45e6fe396a8d75b2370e3f6ea3e2440
TristaWWP/Python-programming-reference-
/Chapter-4.py
1,781
4.4375
4
""" 4-1 """ pizzas = ['beef', 'chicken', 'fruit'] for pizza in pizzas: print(pizza) for pizza in pizzas: print("I like " + pizza + "pizza") print("I really love pizza") """ 4-2 """ animals = ['dog', 'cat', 'pig'] for animal in animals: print(animal) for animal in animals: print("A " + animal + " w...
35bd55d9f0f2ee7c4b6fc778eeeeb3b76a68d8d0
joaovgotardo/exerciciospython
/ul1 - conceitos básicos/aula02/exemplo de try except com input.py
271
3.78125
4
v_numa = 0 v_numb = 0 v_resultado = 0 try: v_numa = int(input('Digite o primeiro número: ')) v_numb = int(input('Digite o segundo número: ')) v_resultado = (v_numa) / (v_numb) print('Resultado: ' + str(v_resultado)) except: print('Erro na operação')
81e33835b1be25ae7df897dda3e2d9d366074c00
syurskyi/Python_Topics
/065_serialization_and_deserialization/002_json/_exercises/_templates/Working With JSON Data in Python/003_A Real World Example (sort of).py
4,871
3.515625
4
# # -*- coding: utf-8 -*- # # # A Real World Example (sort of) # # For your introductory example, you’ll use JSONPlaceholder, a great source of fake JSON data for practice purposes. # # First create a script file called scratch.py, or whatever you want. I can’t really stop you. # # You’ll need to make an API request to...
ceb2d0d80dc8d444b53c29984ab5a51d35a180fc
XxdpavelxX/Python-Projects
/Simple,Useful Python Projects/mindstorms.py
810
4.09375
4
import turtle # used to draw import math def draw_square(some_turtle): for i in range(1,5): some_turtle.forward(100) # brad moves forward and draws for 100 units some_turtle.right(90) #brad makes a 90 degree turn def draw_art(): window=turtle.Screen() window.bgcolor("red") # Create a red colored back...
7e9e15be6cb1c8fc014449c381f3d6bf287cd9ca
LingB94/Target-Offer
/58翻转字符串.py
481
3.828125
4
def reverse(s): if(not s): return False l = [] for i in s.split(): l.append(i) result = '' for i in l[::-1]: result += (i + ' ') return result[:-1] def leftRotate(s, k): if(not s or k <=-1 or k >= len(s)): return False result = '' resul...
7957de396b130198cbb6f7e4cb5e5afd430770e9
manish-jain-py/general_programs
/ccti/ctci_selected/coin_change.py
614
3.6875
4
def find_coins_count(amount, currency_list): min_coins_dict = {} for i in range(1, amount+1): coins_list = [] for currency in currency_list: if i >= currency: diff = i - currency if diff in min_coins_dict: coins_list.append(min_c...
b28caa83ae1f35b4a67783a22f8a66ef9a03c092
kadarsh2k00/python-exercise
/Python GitHub/Q48.py
207
3.59375
4
##def even(n): ## if n%2==0: ## return True ##l=[] ##for i in range(1,21): ## l.append(i) ##x=filter(even,l) x=(filter(lambda x:x%2==0,range(1,21))) for i in x: print(i)
3728ba89bd50793c8c889f1ced668f9c886e445c
Alokpatek2392/Fibonacci
/Fibonacci.py
533
3.90625
4
def F(n): a=0 b=1 print(a) print(b) for i in range(1,n): c=a+b a=b b=c if(c%3==0 and c%5!=0): print('Buzz') elif(c%5==0 and c%3!=0): print('Fizz') elif(is_prime_number(c)): print('BuzzFizz') el...
40a6e07a3248fec62c2e47217f6d439b5a037500
phlalx/algorithms
/leetcode/685.redundant-connection-ii.py
3,958
3.671875
4
# # @lc app=leetcode id=685 lang=python3 # # [685] Redundant Connection II # # https://leetcode.com/problems/redundant-connection-ii/description/ # # algorithms # Hard (31.14%) # Likes: 619 # Dislikes: 184 # Total Accepted: 30.3K # Total Submissions: 94.9K # Testcase Example: '[[1,2],[1,3],[2,3]]' # # # In this ...
e2af911c9968275e6545d73e6f7b26d14b30a914
leoren6631/Learning-Python
/lab2.py
10,314
4.125
4
#Problem 1: The calculate_grade() function you have just written is part of problem 1. Write 3 more assertEqual() tests to test the function calculate_grade(). In other words, pick three sets of lab scores and test scores, and then calculate (with a calculator if you like) what you think calculate_grade() should return...
502156045ff13f951952874a3ffcd238e733116a
ingRicardo/Neurons
/tools.py
2,654
3.71875
4
""" This module consists of some helper functions for creating neuronal networks. """ import numpy as np def poisson_homogenous(lam, timesteps): """ Generate a poisson spike train for a single neuron using a homogenous poisson distribution. .. image:: _images/homogenous_plot.png :alt: Homogen...
5eacaec6f4dcf9bbe786b09da123765ee5a2bae9
nbolzoni/Train_Dispatcher
/frame.py
2,454
3.5625
4
# Import tkinter for gui and time for train movement and refreshing functions. """ from tkinter import * import time """ # Create gui interface """ tk = Tk() tk.title("Train Dispatcher") tk.resizable(0,0) tk.wm_attributes("-topmost",1) canvas = Canvas(tk,width=1500,height=800,bd=0,highlightthickness=0,bg='black') canv...
9cb857562131f489db6abe0bf51d138292414ea1
greenfox-velox/szemannp
/week-03/day-3/10.py
228
3.734375
4
def draw_triangle(lines): position = lines - 1 stars = 1 for dots in range(1, lines + 1): print ((" " * position) + ("*" * stars)) stars += 2 position -= 1 return print(draw_triangle(8))
38365c8d7ab1ada30e608b2a1ff399e9d52e8961
glangetasq/FundClustering_Fall2020
/Tools/Labeling/define_levels.py
401
3.625
4
def define_levels(array): """returns High/ Mid/ Low categories based on 33%, 66%, 100% percentiles""" low_thresh = array.quantile(1/3) mid_thresh = array.quantile(2/3) temp = list() for i in array: if i <= low_thresh: temp.append('Low') elif i<= mid_thresh: ...
db3c66bb453428d822b5347639fbf02778225a1a
victorpma/LFA-automatofinito
/src/main.py
1,278
3.765625
4
import json from automato import Automato def main(): def readAutomato(): with open('InsiraSeuAutomatoAqui/automato.json') as file: automatoJson = json.load(file) alphabet = automatoJson["alfabeto"] stateInitial = automatoJson["estadoInicial"] stateEnd = automatoJson[...
e7cff9523c64adeafe486178df10fed5540b45f3
asmuth444/NPTEL-Data-Structure-and-Algorithms-in-Python
/Week2/divide_check.py
139
3.859375
4
def divides(m,n): if m%n==0: return True else: return False m,n = map(int, raw_input("Enter Two Nos.:").split()) print divides(m,n)
ce4fd0be6b6f56c1db009bae3e229f15b9b27696
Pedro-Neiva/URI
/Extremely Basic/1020.py
279
3.84375
4
age = int(input()) year = 0 month = 0 day = 0 while age >= 365: age = age - 365 year = year + 1 while age >= 30: age = age - 30 month = month + 1 while age > 0: age = age - 1 day = day + 1 print("%i ano(s)\n%i mes(es)\n%i dia(s)" %(year, month, day))
e4b807dafe8be9069a0f2d5a9e9b69aee6523053
anidh/python-udemy
/starMeta.py
353
3.6875
4
import re def starMetacharacter(): pattern=r"eggs(bacon)*" string="eggsbaconbaconbacon" print(re.findall(pattern,string)) starMetacharacter() def groupsInRegex(): pattern="[A-z]([A-z])+[0-9]" string="AA8" if re.search(pattern,string): print("Match Found") else: print("Mat...
d48541c08f897ad44183748b8ed6f3a0d5b4ca1d
moofarry/data-science-course
/introduccion_python/tipos_estructurados/tuplas.py
393
4.0625
4
#se cuencia inmutables de objetos my_tuple = () type(my_tuple) my_tuple = (1, 'dos', True) #print(my_tuple[1]) my_tuple1= (1) print(type(my_tuple1)) my_tuple1= (1,) print(type(my_tuple1)) #reaccinando my_other_tuple = (2,3,4) my_tuple1 += my_other_tuple print(my_tuple1) #reempaquetar x,y,z = my_other_tuple print(x,...
a1e4d653985b184538a634e3bc97bba3c913cc36
daniemart5/PythangMan
/2Dlists.py
579
4.03125
4
# matrix = [ # [1,2,3], # [4,5,6], # [7,8,9] # ] # print(matrix[2][1]) # matrix[2][1] = 20 # print(matrix[2][1]) # for row in matrix: # for item in row: # print(item) #list methods # numbers = [5,2,1,5,7,4] # print(numbers) # #adds 20 to the end # numbers.append(20) # #adds 10 at the 0 index # numbers.i...
6f20a0f1cbb48ed0d127b32532ef61c5e98bcc2e
cassandrakane/Class-Selection-Sort
/ClassSelectionSort.py
5,172
4.15625
4
# Class Selection Sort Program import csv class Student: # constants for class size range MAX_CLASS_SIZE = 16 MIN_CLASS_SIZE = 10 # constants for class score calculations FIRST_IMPORTANCE = 40 SECOND_IMPORTANCE = 30 GENDER_IMPORTANCE = 20 LARGE_CLASS_IMPORTANCE = -100 SMALL_C...
edb0b8978dbc60c27acd9f164f0a763c1c953cd5
macknilan/Cuaderno
/Python/ejemplos_ejercicios/poo_abstract_base_classes_ejem_01.py
818
4.15625
4
# abstract base classes import abc class Vehicle(abc.ABC): """ Declaracion de la clase abstracta """ @abc.abstractmethod def go(self): pass @abc.abstractmethod def stop(self): pass class Car(Vehicle): """ Clase heredada de -Vehicle- ""...
964929a375cc16aa56a6716c533dcee8a63abf19
mirandaday16/intent_chatbot
/time_zones.py
1,632
4.03125
4
# This file is used to get time zone data for the user # Using Amdoren API: https://www.amdoren.com/time-zone-api/ import requests import json from formatting import cap_first_letters api_key = "vGSiWG7aTLBXuL2W9hPbxMU94u9Vb5" base_url = "https://www.amdoren.com/api/timezone.php" # Takes a string entered by the use...
bb5442f847a0169b830400b9c672f9aeac58ff8b
educardenas97/python_project
/app/Core/Class/Transporte.py
1,950
3.796875
4
import datetime class Transporte(): """ Clase Transporte Parametros: argumento1(Date): fecha de salida del transporte argumento2(int): capacidad de cargo. En Kg argumento3(int): precio del transporte por Kg. En $ argumento4(Date): fecha de llegada. (opcional) """ de...
ff4bf7429737887966134a628f26b199a855e039
nhoxbypass/100days-algorithm
/day45_binary_search_tree/bst.py
7,769
3.671875
4
import random # A Python class that represents an individual node # in a Binary Tree INT_MAX = 4294967296 INT_MIN = -4294967296 class Node: def __init__(self,key): self.left = None self.right = None self.val = key def __str__(self): res = "Val: " + str(self.val) if self.haveLeftChild(): res = res + ...
cd80df887291e4dada90d579bebec4bc460c35fd
Guirguis87/CountWordss.py
/Count_words_from_file.py
2,723
4.25
4
while True: user_text = input (r" Please Enter your file path : ") user_text_file = str(user_text) exceptions_counting = ["?" , "," , "." , "!", "/" , "_", "@"] # Creating dynamic input for user to put the required path in dynamic way myfile = open(user_text_file , "r") myfile.seek(0) myf...
78072bb7fa904449382f0789886e0b248cb9d5b3
XixinSir/PythonKnowledgePoints
/XPath/lxml库的使用.py
1,102
3.640625
4
# 导入lxml库的etree模块 from lxml import etree ''' 使用之前,首先要确保安装好lxml库. 下面为使用XPath对网页进行解析的过程 ''' # 声明一段HTML文本 text = ''' <div> <ul> <li class="item-0"><a href="link1.html">first item</a></li> <li class="item-1"><a href="link2.html">second item</a></li> <li class="item-inactive"><a hr...
86e769e59660181e815fc9175949f6e2d78d4fbd
malyshusness/random-python
/photo_organizer.py
6,485
3.984375
4
import shutil, os, platform import exifread def convert_month_to_number(month): '''Receives a string month and returns the number equivalent For example, October as input will return 10 ''' if month.lower() == 'january': return "1" elif month.lower() == 'february': re...
7b3a2082ef0f5fca03e39cd25891cc9ba0320bde
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_7_User_Input_And_While_Loop/Practice2/greeter.py
270
4.03125
4
# name = raw_input("Please enter your name. ") # print("Hello " + name.title() + "!") prompt = "If you tell us who you are , we can personlaize the message you see." prompt += "\nWhat is your first name? " name = raw_input(prompt) print("Hello " +name.title() + "!")
202c631a7a1b493c8f5e54f78207681e4f9d531c
Samrany/practice_problems
/fit-to-width.py
1,169
4.625
5
""" Write a function that prints a string, fitting its characters within char limit. It should take in a string and a character limit (as an integer). It should print the contents of the string without going over the character limit and without breaking words. For example: >>> fit_to_width('hi there', 50) hi there S...
05ab1e291a3ec246b03b2ad0112068cf4ab07838
juliancomcast/100DaysPython
/Module1/Day06/day06_lists.py
2,710
4.4375
4
#creating an empty list list_1 = [] list_2 = list() print("List 1 Type: {}\nList 2 Type: {}".format(type(list_1), type(list_2))) print("break") print(f"List 1 Type: {type(list_1)}\nList 2 Type: {type(list_2)}") #list function created a list where each character is a seperate entry text = "Luggage Combination" print(...
385fede71146ed571445c11c341376fb9403dbc6
AparnaKuncham/Python-Code
/PycharmProjects/untitled/venv/Scripts/new.py
132
3.6875
4
import re test_string="sphain" pattern='^s...n$' res=re.findall(pattern,test_string) if res: print("Yes") else: print("No")
ef46fb8f34e7c26dbb22b7bc5aadd5cdcc0bc2d8
daodinhngoc/pythonZerotoHero
/Fortnight_1/SRC/Day2/leap.py
187
3.875
4
""" Author: Jashan Date: 2018-May-30 Git: github.com/jashangunike """ Year = int(input("Please Enter Year")) is_leap = (Year %4 ==0 and Year &100 !=0 or Year%400 ==0) print(is_leap)
94af91b678c0c6bd086e296b682bdad529741575
he44/Practice
/aoc_2020/21/p1.py
2,677
3.828125
4
def main(): in_fname = "i1_eg.txt" in_fname = "i1.txt" lines = open(in_fname).read().strip().split('\n') ingreds, allers = grab_all(lines) print(ingreds) print(allers) ingred_to_aller = {key:[val for val in allers] for key in ingreds} print(ingred_to_aller) # for each food...
46830e4faba8d17b5107eccc3642dab43c83f43f
ScottMerrill/Airminecodetest
/Great_Circle_Distance.py
2,716
3.765625
4
#!/usr/bin/python3 import sys import csv import random import math DEGREES_IN_RADIAN = 57.29577 MEAN_EARTH_RADIUS_KM = 6371 filename = 'places.csv' ############################################### Generate Data ############################################### # Read in command line argument o...
bd21748bcc6709684487a7993fee2442c05c608e
mtan22/CPE101
/projects/project3/solver.py
1,136
3.734375
4
#Michelle Tan #11/2/2020 #Project 3 import unittest from solverFuncs import* def main(): #Uses a for loop to create the general format of the puzzle first puzzle = [] cages=get_cages() for index in range(5): puzzle.append(5*[0]) index = 0 checks = 0 backtracks = 0 #Uses a while...
b83d2c8683d951e1964a4cd52a20adccc653d640
aldahirSealtiel/Hangman
/Problems/Checking email/task.py
267
3.625
4
def check_email(string): if ' ' not in string and '@' in string and '.' in string: index_symbol = string.index('@') index_dot = string.find('.', index_symbol) if -1 < index_dot > index_symbol + 1: return True return False
1f35c934efc48ea742157bcf16b9fdc636c64b08
Avvacuum/cources
/test04.py
524
3.96875
4
# TODO: dictionary with values inventory = { 'gold': 500, 'pouch': ['flint', 'twine', 'gemstone'], 'backpack': ['xylophone', 'dagger', 'bedroll', 'breadloaf'] } # TODO: add key_pocket and values to dictionary inventory["pocket"] = ['seashell', 'strange berry', 'lint'] # TODO: ( .sort()) elements in backpack and...
37fb27602b7925bd479e87610be3c6adaeb5fb7a
charles-debug/learning_record
/96-函数说明文档.py
324
3.875
4
# help(len) help函数的作用就是查看函数的说明文档 def sum_num(a,b): """ 求和函数 """ return a + b help(sum_num) # 说明文档的高级使用 def sum_num1(a,b): """ 求和函数sum_num param a: param b: return: """ return a + b help(sum_num1)
a198cfcc18d389e98e7b2254a951c23e15370811
log2timeline/l2tdevtools
/l2tdevtools/versions.py
1,244
4
4
# -*- coding: utf-8 -*- """Functions to handle package versions.""" def CompareVersions(first_version_list, second_version_list): """Compares two lists containing version parts. Note that the version parts can contain alpha numeric characters. Args: first_version_list (list[str]): first version parts. ...
add04089f0100e8268461f90737e09b99b9bbadb
fredrik84/AoC2017
/day3/part1/find.py
837
3.71875
4
#!/usr/bin/python3 import time with open("input") as f: data = int(f.readline().strip()) def move_right(x,y): return x+1, y def move_down(x,y): return x,y-1 def move_left(x,y): return x-1,y def move_up(x,y): return x,y+1 def gen_points(end): from itertools import cycle _moves = cycle(moves) n = 1 pos = 0...
3d69c6c6bb2cee1b2f5747930915f014e45d791e
Shiv2157k/leet_code
/amazon/design/snake_game.py
2,715
4.28125
4
from typing import List from collections import deque class SnakeGame: """ W - Width, H - Height, N - no. of food items Time Complexity: - move method : O(1) - calculate bite itself: O(1) using dictionary - add and remove element from queue: O(1) Space Complexity: - O(W...
aabbf2e2d57a7208cda008e2c28f09b4803418cc
gevishahari/mesmerised-world
/dice2.py
207
3.890625
4
import random while True: x=int(input("press 1 to roll the dice and 0 to quit")) if(x==1): print(random.randint(1,6)) elif(x==0): print("bye!") break else: print("press either 1 or 0")
09d80c11216e021e63432295c322bc7f68e05d77
btemovska/ListsAndTuples
/Tuples_Intro.py
981
4.25
4
t = "a", "b", "c" print(t)#('a', 'b', 'c') <= this is tuples name = "Biljana" age = 10 print(name, age, "Python", 2020) #Biljana 10 Python 2020 print((name, age, "Python", 2020)) #('Biljana', 10, 'Python', 2020) welcome = "Welcome to the Nightmare", "Alice Cooper", 1975 bad = "Bad Company", "Bad Company", 1974 budgi...
7afd871d97f9602ce48cb76febdd51520aff47a3
park950414/python
/第三章/程序练习题/4.py
133
3.875
4
x=input("请输入一个5位数字:") if x==x[::-1]: print("这是一个回文数") else: print("这不是一个回文数")
18328f6032234a20a249f23136c8ed8dfbeca2e0
jamesfallon99/CA116
/lab_week05/pw-login-shell.py
316
3.6875
4
#!/usr/bin/env python s = raw_input() while s != "end": i = 0 while i < len(s) and s[len(s) - i - 1] != ":": i = i + 1 if i < len(s): j = 0 while j < len(s) and s[j] != ":": j = j + 1 if j < len(s): print s[:j], s[(len(s) - i):] s = raw_input()
04d0dd3c8f8f0b36926f97e23bc8d377c029b6b3
XiancaiTian/Leetcode
/q124.py
1,261
3.828125
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 # should consider every node as a new start # should return the better path in each recursion # Note: there is no need to rea...
391976dc68ef9e144f66478807581a8a8f8052c4
gorillacodes/HelloWorld-
/Stone Paper Scissors.py
1,315
3.859375
4
from random import randint print ("Stone = 1\nPaper = 2\nScissors = 3\n") u_score = 0 c_score = 0 def game(): u_input = int(input("Your move? ")) c_input = randint(1, 4) if u_input == c_input: print("Tie") elif u_input == 1 and c_input == 2: print("Computer sh...
76c50e58fb799403bc277b10c96eee8f0c625bff
Peterquilll/interview_questions
/chapter5/pairwise_swap.py
321
3.75
4
def pairwise_swap(a): mask = 0xAAAAAAAA even = a & mask odd = a & mask >> 1 even_shift = even >> 1 odd_shift = odd << 1 swap = even_shift | odd_shift return bin(swap) def main(): a = 0x66 result = pairwise_swap(a) print(bin(a), result) if __name__ == '__main__': main() ...
97a35f1f05a46138655e3b63066395d65fa4808f
KandyKad/Python-3rd-Sem
/Lab4/A4_3_py.py
115
3.5
4
l1 = [int(i) for i in input("Enter a list of numbers: ").split()] l2 = [int(i) for i in l1 if i%2==0] print(l2)
7eb947fdb2363b56d974062ea658766909155308
malker97/CS494ChatRoomProj
/Class/list.py
457
3.578125
4
#!/usr/bin/python3 # creat rooms import Room def creatlotsroom(arr_room,num): for i in range(num): arr_room.append(Room.creatchatroom('Room-'+str(i),i,'Test Uesr')) # return arr_room # show all infomation def listrooms(arr_room): str_roomlist = '' for i in range(len(arr_room)): ...
be361903de9d0d9b9d190cccb6ff81c63dbb7373
Randeepk1/NLP
/NLP_W2S_W2W_STEMMER_LEMME.py
1,421
3.625
4
#!/usr/bin/env python # coding: utf-8 # In[1]: import nltk # nltk.download() from nltk.stem import PorterStemmer,WordNetLemmatizer from nltk.corpus import stopwords # In[2]: Pharagraph = 'Paragraphs are the building blocks of papers. Many students define paragraphs in terms of length: a paragraph is a group of a...
5434aa8f584d09832687d48e3b9c0ea984fbb003
leandro-alvesc/estudos_python
/guppe/exercicios/secao_06/ex009.py
200
4.03125
4
# Ler um número inteiro N e depois imprima os N primeiros numeros naturais impares n = int(input('Digite um número inteiro N: ')) for num in range(1, n + 1): if num % 2 == 1: print(num)
c54d360c9798a7c5243f4e18c1072ff0f284bc52
SiyiGuo/Titan-V
/AlphaHalfGo-Zero/HalfGo/PubgArena.py
3,867
3.5625
4
import numpy as np class Arena(): """ An Arena class where any 2 agents can be pit against each other. """ def __init__(self, player1, player2, game, display=None): """ Input: player 1,2: two functions that takes board as input, return action game: Game object ...
75f5aadd6ca332f0c30a5fbfc39ecc6f1ba4250d
jinurajan/Datastructures
/educative.io/coding_patterns/topological_sort/course_schedule_II.py
1,226
4.03125
4
""" Let’s assume that there are a total of n courses labeled from 0 to n-1. Some courses may have prerequisites. A list of prerequisites is specified such that if prerequisities=a,b , you must take course b before course a Given the total number of courses n and a list of the prerequisite pairs, return the course o...
29d5280f271606bd6379a45b768e035d27c57473
k-young-passionate/Baekjoon
/python_version/p1747.py
645
3.859375
4
from math import sqrt def ispalindrome(num): n = str(num) front = n[:len(n)//2] if len(n)%2 == 0: addition = 0 else: addition = 1 back = n[len(n)//2+addition:] back = back[::-1] if front == back: return True else: return False def isprime(num): if n...
c05186bdfd761d1b80706062d24a8006250b33e7
shruti280401/python
/project-data_analysis_udemycourses.py
1,334
3.8125
4
import pandas as pd data = pd.read_csv('7. Udemy Courses.csv') print(data.head()) #printing data for different subjects which udemey is offering courses print(data.subject.unique())#returns only unique element #######print(pd.Series(data.subject)) #printing data for which subject has maximum no of courses pr...
e1f74711235a4d613c05dfbd559f4717267e3850
ternura001/store
/猜字游戏.py
819
3.78125
4
#任务:开始金币有5个金币,每猜一次减一个为0就退出(or充钱)猜错3次也退出 import random randint=random.randint(10, 20)#随机生成数字的范围:int [] print(randint) i=3 a=5 while i>=1: print("您还有机会%d次"%i) print("您还有金币%d个"%a) num=int(input("请输入您猜的数字")) if num==randint: print("恭喜你猜对了") a=a+3 randint = random.randint(10, 20) ...
3c98897a6108d5b492a506e3237935c7975e5ac3
alirezaghey/leetcode-solutions
/python/remove-duplicates-from-sorted-array-ii.py
376
3.734375
4
from typing import List # Time complexity: O(n) where n is the length of nums # Space complexity: O(1) # Two pointer approach class Solution: def removeDuplicates(self, nums: List[int]) -> int: left = 2 for i in range(2, len(nums)): if nums[left-2] != nums[i]: nums[left]...
f5d3a057ddba1ebd47141433c7e05acad24539d5
fumokmm/language-examples
/Python/0009_isnumber.py
1,016
3.53125
4
# 半角数値 s1 = "1234567890" assert s1.isdecimal() == True assert s1.isdigit() == True assert s1.isnumeric() == True # 全角文字 s2 = "1234567890" assert s2.isdecimal() == True assert s2.isdigit() == True assert s2.isnumeric() == True # 2乗を表す上付き数字² pow2 = "²" assert pow2.isdecimal() == False # decimalではFalse as...
3b7895d1b1b2934805c390bab2dc3d7d99d65050
ccoleman19/Analytic-Avengers
/SalesTaxCalculator.py
974
3.9375
4
# from calcTax import calculateTax def calculateTax(price): tax = round(price*.06,2) total = round(price + tax,2) return tax, price, total def runningTotal(): lastItem = True total = 0 while lastItem == True: price = float(input("Cost of item: ")) if price > 0: t...
bbfafb340cc3dde0857724fe60cffa0d83b8d416
jhiltonsantos/ADS-Algoritmos-IFPI
/Atividade_Fabio_02a_Condicionais/fabio_02a_19_imc.py
368
3.890625
4
def main(): altura = float(input('Altura (em metros): ')) peso = float(input('Peso (em quilogramas): ')) calc_imc = peso / (altura**2) if calc_imc < 25: print('Peso Normal') elif 25 <= calc_imc <= 30: print('Obeso') elif calc_imc > 30: print('Obesidade morbida') ...
d514c75601121d623c7a24de1a6ce6bbd3068ee9
emirbuckun/CS50-Problems
/Problem6/Cash/cash.py
498
3.75
4
def main(): amount = get_amount() print(change(amount * 100)) def change(cents): return round(cents // 25 + (cents % 25) // 10 + ((cents % 25) % 10) // 5 + ((cents % 25) % 10) % 5) def get_amount(): while True: try: n = float(input("Change owed...
15c61272e7a72c3cac14453fc3d2447711c99f68
shengchaohua/shiyanlou-solution
/classic-algorithm-in-action/classic-algorithm-solution-in-python/FactorialTrailingZeroes.py
689
3.578125
4
# -*- coding: utf-8 -*- """ Created on Thu Apr 5 18:47:34 2018 @problem: leetcode 172. & lintcode 2. Factorial Trailing Zeroes @author: sheng """ class Solution: def trailingZeroes(self, n): """ :type n: int :rtype: int """ # loop if n < 0: return -1 ...
57d8727e405c699116a2c052a3072dd1fbffd2ca
marnovo/ml
/ast2vec/token_parser.py
2,466
3.546875
4
import re import Stemmer class TokenParser: """ Common utilities for splitting and stemming tokens. """ NAME_BREAKUP_RE = re.compile(r"[^a-zA-Z]+") #: Regexp to split source code identifiers. STEM_THRESHOLD = 6 #: We do not stem splitted parts shorter than or equal to this size. MAX_TOKEN_L...
57a714dfc0e8946ded0339c71c584f2ead344108
gi4nchi/HW03
/MagicMaze.py
1,017
3.8125
4
import random def life_counter(errors, lives): if errors < 10: errors += 1 elif errors == 10: print("You lost one life") lives += 1 errors = 0 if lives == 3: print("You lost") exit() return errors, lives counter = 0 errors = 0 lives = 0 directions=['N','S'...
8ee9efa2cc92269d2bebc7ea41b31de359da6687
tedbennett/data-structures
/dequeue.py
3,565
3.703125
4
from simple_queue import CircularQueue import unittest class Deque(CircularQueue): def __init__(self, length): super().__init__(length) def add_first(self, item): if self.len >= self.max_size: raise Exception("Deque is full") self.zero_index -= 1 if self.zero_index...
24f0cb316a1bfe1de86c59aaad465f66a039078c
1987617587/lsh_py
/basics/day5/lzt/parameter_test.py
5,700
3.75
4
# author:lzt # date: 2019/11/12 14:20 # file_name: parameter_test # 参数的定义 # 形参:a,b def add(a: int, b: int): """ 为a和b求和 :param a: 数据a :param b: 数据b :return: 两个数据的和 """ return a + b # 函数执行 # c = "a" # d = "b" # # 实参:c,d # print(add(c, d)) # 1.写一个函数根据用户的按键不同角色播放不同的动画。 def doaction(key): ...
544346359175959e4525f48ede467b184a05d878
kabu1zhan/training
/kursOOP/Refactoring.py
5,922
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import pygame import random import math SCREEN_DIM = (800, 600) class Vec2d(): def __init__(self, x, y): self.x = x self.y = y def __add__(self, other): return type(self)(self.x + other.x, self.y + other.y) def __sub__(self, other...
d1c02a5bebe070d0394e5fcf4c5ed8303ddd18f6
zy924/Algo
/insertion1.py
567
4.21875
4
""" Insert a number into a sorted array, the number will in the rightmost cell. Print the array every time a number is shifted. For example: Input: 2 3 4 1 Output: 2 3 4 4 2 3 3 4 2 2 3 4 1 2 3 4 """ #input A = [2,3,4,5,1] def insertion1(ar): m = len(ar) e = ar[-1] for i in xrange(m-2,-1,-1): if ar[i]<=e: ar[i...
cd6b854695b73229b635fe15de3bdea5e1cdff79
maximkavm/ege-inf
/15/Числовые отрезки/Решение.py
311
3.5
4
P = range(2, 10+1) Q = range(6, 14+1) def F(x, An, Ak): A = range(An, Ak+1) return ((x in A) <= (x in P)) or (x in Q) max_len = 0 for An in range(1, 99): for Ak in range(An+1, 100): OK = all(F(x, An, Ak) for x in range(1000)) if OK: max_len = max(max_len, Ak - An) print(max_len) # Ответ: 12
ca367ff37ad0b77d61b84f11c6d6b17156e81c54
side-projects-42/DS-Bash-Examples-Deploy
/CONTENT/DS-n-Algos/ALGO/__PYTHON/word_count.py
432
3.71875
4
file=open("sample.txt","r") d=dict() for lines in file: lines=lines.strip() lines=lines.lower() words=lines.split(" ") for word in words: if word in d: d[word]=d[word]+1 else: d[word]=1 find=str(input("enter the word to count: ")) find=find.lower()...
7f5a6b975822e91f1c7368d7fae4082e444d4f2e
mikeodf/Python_Line_Shape_Color
/ch5_prog_6_line_randomize_1.py
3,990
4.21875
4
""" ch5 No.6 Program name: line_randomize_1.py Objective: Draw two segmented sets of lines with a confined but random (Gaussean)components. Keywords: random vertical, distribution ============================================================================79 Comments: We draw a set of segmented line with partial...
703ca0d2e67f5a6b8146ad8f7e117f157c967bf1
s-rokade/Student-Management
/studenassig_main.py
785
3.78125
4
'''Create a student management application. Create a student table with columns - id, name and marks Create python functions to - 1)show students 2)update student marks with id 3)Insert new student 4)Delete student''' from studenassig import Student #from student import Student while True: print("***********Welc...
15cda0a33628bab338fc72c9076eaa0838dc0a9e
JhonesBR/python-exercises
/9- Python Set Exercise/ex06.py
210
4.03125
4
# Return a set of all elements in either A or B, but not both # Solution: https://github.com/JhonesBR set1 = {10, 20, 30, 40, 50} set2 = {30, 40, 50, 60, 70} set3 = set1.symmetric_difference(set2) print(set3)
044c6032baa0271635feba335720cc316f5c04f1
MRS88/python_basics
/week_2_if_n_while/sum_of_sequence.py
544
4.03125
4
''' Определите сумму всех элементов последовательности, завершающейся числом 0. Формат ввода Вводится последовательность целых чисел, оканчивающаяся числом 0 (само число 0 в последовательность не входит, а служит как признак ее окончания). ''' n = int(input()) res = 0 lst = [] while n != 0: lst.append(n) n = i...
eed9422ed66d956fa1d71634aed8ea7a767c01ea
intaschi/Python-course
/Estruturas de repetição/Ex048.py
264
3.75
4
s = 0 cont = 0 for n in range(0, 501): if n % 2 == 1 and n % 3 == 0: cont = cont + 1 s += n print('A soma de todos os {} resulta da soma {}'.format(cont, s)) #for n in range(0, 500, 3): # if n % 2 == 1: # print(n, end = ' ')
214687e64823aa9fd309f215f4a895574213b600
meng-z/leetcode
/278_first_bad_version/v1.py
709
3.671875
4
# The isBadVersion API is already defined for you. # @param version, an integer # @return a bool # def isBadVersion(version): ''' Runtime: 24 ms, faster than 84.54% of Python3 online submissions for First Bad Version. Memory Usage: 12.7 MB, less than 100.00% of Python3 online submissions for First Bad Version. ''' cla...
708d1e24564b94e1d85b3227ce712cf60156a84e
thiagocmota/python
/exercicio9.py
608
3.921875
4
#9) Faça um programa que calcule o aumento de um salário. Ele deve solicitar o #valor do salário e a porcentagem de aumento. Mostre o valor do aumento e do #novo salário. salario_inicial = float(input("Digite o valor do salario do fuincionario: ")) porcentagem_aumento = float(input("Digite somento o valor da porc...
e45319948b48665763b6b65dc6fe0f7d458a6096
zhangweichina111/RPi-snake
/linkList.py
3,413
3.9375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- def test(): print "Hello,this is list operator class that prepare for snake's body." class Node(object): def __init__(self,x,y,p=0): self.cur_x = x self.cur_y = y # self.cur_dir = dir self.next = p class LinkList(object): def __in...
b997b080fb541e3744378e0be20df1cf029f4991
VANITHAVIJAYA/codekata
/day.py
202
4
4
day={'monday':'working day','tuesday':'working day','wednesday':'working day','thursday':'working day','friday':'working day','saturday':'holiday','sunday':'holiday'} d=input("Enter day") print(day[d])
1db6e5837f61897bcd50144bdf677d31d2b6721d
tejaswisunitha/teja
/85.py
143
3.65625
4
c= raw_input().rstrip() evenB = oddB = '' for j, k in enumerate(c): if j & 1 == 0: evenB += k else: oddB += k print(evenB + " " + oddB)
0ff96e3f446d52fb31699558be76f5f5269b1c6f
YinhaoHe/LeetCode
/interviews/interviewQuestions/slidingWindowMax(SegmentHackerRank).py
1,073
4.1875
4
''' Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Return the max sliding window. Find maximum of minimum for every window size in a give...
c6554ff18c23a61d3694e73b808f44c96f9a19c4
bwalsh0/100DaysOfPython
/lc_338.py
488
3.640625
4
class Solution: def countBits(self, num: int) -> List[int]: total = [] for i in range(num + 1): counter = bin(i).count('1') # for j in bin(i): # if j == '1': # counter += 1 total.append(counter) return total...
fe01b00decfbf0ce1e7f16e81454e2221bbd6785
here0009/LeetCode
/Python/1673_FindtheMostCompetitiveSubsequence.py
2,168
3.890625
4
""" Given an integer array nums and a positive integer k, return the most competitive subsequence of nums of size k. An array's subsequence is a resulting sequence obtained by erasing some (possibly zero) elements from the array. We define that a subsequence a is more competitive than a subsequence b (of the same len...
1b7601b03e331ce8072dc38703aa7525558572c8
ajaykumar011/python-course
/classes/inheritance1.py
634
4.0625
4
# Inheritance allows us to define a class that inherits all the methods and properties from another class. # Parent class is the class being inherited from, also called base class. # Child class is the class that inherits from another class, also called derived class. class Person: #Parent Class def __init__(self,...
2d10c663cad9404f941dae4088808da0ebef70a9
thisisvikasmourya/DS
/Practical1a.py
157
3.96875
4
arr1=[12,35,42,22,1,6,54] arr2=['hello','world'] arr1.index(35) print(arr1) arr1.sort() print(arr1) arr1.extend(arr2) print(arr1) arr1.reverse() print(arr1)
fca0a1e74b22adc9eb88b784df61ae51c08a70c5
JianxiangWang/LeetCode
/33 Search in Rotated Sorted Array/solution.py
1,377
3.78125
4
#encoding: utf-8 # 4 5 6 7 0 1 2 # binary search, always ! # low-mid or mid-high 之间始终有一个是有序的, 所以每一次都可以判断是target 在 low-mid 还是 high-mid 之间 ! class Solution(object): def search(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ n = len(nums...
2f56e0320156ddf592ec5e73a2f083ba55da7187
Sorabh-Singh/HackerRank
/DS/No Idea.py
649
3.515625
4
''' Input Format The first line contains integers and separated by a space. The second line contains integers, the elements of the array. The third and fourth lines contain integers, and , respectively. Output Format Output a single integer, your total happiness. Sample Input 3 2 1 5 3 3 1 5 7 Sample Output ...
271027b140627bc9195ef00b50518b703ed70f00
zNIKK/Exercicios-Python
/Python_3/DEF/MÓDULOS/Moedas--COMPLETO/pacotes/Strings/__init__.py
1,711
3.5625
4
from pacotes import Numeros def erros(txt): v=False while not v: entrada=str(input(txt)) if entrada.isalpha(): if ',' in entrada: re = f'{entrada}'.replace(',', '.') return float(re) print(f'\033[0;31mERRO \"{entrada}\" é um preço invalido...
de18e9b676934ba8591c8a85b2ee0e7fec73581d
cjb5799/DSC510Fall2020
/KOSMICKI_DSC510/cable_install.py
954
4.1875
4
#DSC 510 #Week 2 #Programming Assignment Week 2 #Author Sherry Kosmicki #09/7/2020 #factor used to calculate cost cablefactor = .87 print('Welcome to my invoice generator!') #Prompt user for their name username = input('Please enter your name\n') #Prompt user for company name usercompany = input ('Enter your compan...
e8f9a2e98b7d68ea5f0a353c9b575aec15414ace
SagarikaNagpal/Python-Practice
/QuesOnOops/A-3.py
73
3.8125
4
import math a=int(input("num is: ")) print("squre of a: ",math.pow(a,2))
6d29f4046d736a3891911e00b185e2670ca59d94
Minji0h/Introduce-at-CCO-with-python
/Semana4/exercicio1.py
226
3.765625
4
# Escreva um programa que receba um número natural n n n na entrada e imprima n! n! n! (fatorial) na saída. n = int(input("Digite o valor de n: ")) fator = 1 while(n > 0): fator = fator * n n = n - 1 print(fator)
f79a817bf0c4dac50e28c5b17417d623015e67af
anoy1729/NSL-RAShip-Program
/python-basic/Basic Data Types/Lists.py
700
3.75
4
if __name__ == '__main__': N = int(input()) lst = [] for i in range(N): arr = list(map(str, input().strip().split(' '))) if(len(arr)==2): arr[1] = int(arr[1]) elif(len(arr)==3): arr[1] = int(arr[1]) arr[2] = int(arr[2]) if(arr[0]==...
64573dcc450cda37d8dac46f9f4a346cb5ab0b97
harshitpoddar09/HackerRank-Solutions
/30 Days of Code/Day 3- Intro to Conditional Statements.py
307
3.875
4
#!/bin/python3 import math import os import random import re import sys n = int(input()) if n%2!=0 : print("Weird") elif n==2 or n==4 : print("Not Weird") elif n%2==0 and n>=6 and n<=20: print("Weird") elif n%2==0 and n>=20 and n<=100: print ("Not Weird")