blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
8ae3139d0ed27e930f4f557dee20b5bdfeb1e17a
tdnzr/project-euler
/Euler062.py
1,443
3.578125
4
# Solution to Project Euler problem 62 by tdnzr. # I originally tried a solution based on going through all permutations of a cube, # and testing if these permutations were also cubes. But this was impossibly slow. # In contrast, this solution is based on the insight that there was no need to compute all permutations....
78450343ff4ac303b8dbbcd5218fa1de9dc8946d
Joey-Rose/oxycsbot
/chatbot.py
6,078
3.765625
4
"""A tag-based chatbot framework.""" import re from collections import Counter class ChatBot: """A tag-based chatbot framework. This class is not meant to be instantiated. Instead, it provides helper functions that subclasses could use to create a tag-based chatbot. There are two main components to a...
71e384765b953861bc117a642d436323136038d3
Kathain/PythonRep
/myLessonPython/Lesson4.py
1,843
3.8125
4
#тут будем изучать что такое list , это список где можно хранить инфу l = [] lis = [1, 54, 'x', 32, 2.44, ['S', 'T', 'R', 'O', 'K', 'A']] print(lis) #list можно заполнять с помощью циклов и др условных операторов a = [a + b for a in 'list' if a != 's' for b in 'soup' if b != 'u'] print (a) # .append добавляет элемент...
961837328193c44cbddd4526543387d6f9adc868
ArkadiyShkolniy/python_lesson_2
/2.py
350
3.875
4
# Задача 2 # Пользователь в цикле вводит 10 цифр. Найти количество введеных пользователем цифр 5. sum=0 for i in range(10): answer = int(input('Введите любую цифру')) if answer==5: sum+=1 print('Количество цифр пять:', sum)
9577c5965b44eb26c28f31f14e76239d1123d82d
angryBird2014/leetcode
/climp stairs.py
448
3.703125
4
class Solution(object): def climbStairs(self, n): """ :type n: int :rtype: int """ data = [1] * (n+1) for i in range(1,n+1): if i == 1: data[1] = 1 elif i ==2: data[2] = 2 else: data[i...
34b80a8dbe984fe3ba39768d8c24c09b834c56bf
pchecinski/losowe-projekty
/sz-int-wsb/lab10/main.py
939
3.71875
4
import nltk nltk.download('punkt') nltk.download('stopwords') from nltk.tokenize import sent_tokenize text="""Hello Mr. Smith, how are you doing today? The weather is great, and city is awesome. The sky is pinkish-blue. You shouldn't eat cardboard""" tokenized_text=sent_tokenize(text) print(tokenized_text) ...
c297f96e0b78082c5a0fa8eff26e39cfdd8894a1
KLC2018/Sunghun-Study-2-day
/practice2.py
95
3.65625
4
a = int(input()) c = [] for b in range(1,a+1): c.append(b) c.reverse() for b in c: print(b)
6c65b9d63216e5ae0e5793031b0a9a3065e06070
cankarabey/Project-Database-1.2
/dateHelper.py
287
3.71875
4
from datetime import * from datetime import date import datetime def futureDate(mydate): entry6_format = '%Y-%m-%d' datetime_obj = datetime.datetime.strptime(mydate, entry6_format) if datetime_obj.date() <= date.today(): return False else: return True
df2bb0e950567d9aa544b70ad3bbc624cc165ae7
dlefcoe/daily-questions
/stackImplement.py
1,252
4.34375
4
''' This problem was asked by Amazon. Implement a stack API using only a heap. A stack implements the following methods: push(item), which adds an element to the stack pop(), which removes and returns the most recently added element (or throws an error if there is nothing on the stack) Recall that a heap has the fol...
b0f9c6dc990738fb72db66a4561206e0cd814bce
llaum/PythonTraining2017
/exo/wc.py
721
3.953125
4
#!/usr/bin/env python3 # Exercice: recode wc en python # > python wc.py fichier.txt from sys import argv from os.path import exists def counting(filename): """ Counts lines, characters & words """ nLines = nWords = nChars = 0 with open(filename, 'r') as f: for line in f: nLines += 1 ...
e0319901b7b752214b81982283301599ca4ca479
skipdev/python-work
/tkinter/EXAM.py
4,146
3.59375
4
from tkinter import * from tkinter import messagebox #the class class Newsletter(Tk): def __init__(self): Tk.__init__(self) #load images self.default = PhotoImage(file="default.gif") self.filled = PhotoImage(file="filled.gif") self.empty = PhotoImage(file="empt...
f1147e79df2b0824e25d8a858d0a033cb36f0940
jorge-sa/porta-tcp
/vestibular.py
1,653
3.9375
4
#função que identifica letras incompativeis def detectarLetras(array): #Letras permitidas alts = "ABCDE" cont = True for n in array: if n not in alts: cont = False return(cont) #função de calculo da nota def calcularNota(g,r): nota = 0 for x in range(len(g)): if ...
955a23bf949dc4e0e2c3d3d65d2effc9e5568402
deepnagariya07/datatypes_hackerank
/loops.py
925
4.15625
4
# Objective # In this challenge, we're going to use loops to help us do some simple math. Check out the Tutorial tab to learn more. # Task # Given an integer, , print its first multiples. Each multiple (where ) should be printed on a new line in the form: n x i = result. # Input Format # A single integer, ...
c9e6efbdd45205acf6aceaf2f33416a28aaeddef
fuckualreadytaken/leetcode
/Median_of_Two_Sorted_Arrays.py
590
3.6875
4
#! /usr/bin/env python # coding=utf-8 class Solution: def findMedianSortedArrays(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: float """ li = nums1 + nums2 li.sort() length = len(li) if length % 2: ...
4a17048ada5b4ee528675741e2ccced10b138ba8
Mekichimo/MekiPythonLearning
/Python/variables/strings.py
150
3.71875
4
x = "hello" print (x) print (x[0]) print (x[1]) print (x[2]) print (x[3]) print (x[4]) x = "hello world" s = x [0:4] print (s) s = x [:4] print (s)
a1540671e9ed3302c3e62a07f8db3754b2740a4f
moasslahi/python-100DaysOfCode
/Challenges/week3Challenge.py
536
4.4375
4
# week 3 challenge #1, create a list and apply 4 methods Mylist = ["Mo",18,"Developer","Football"] Mylist.append("Python") #append method adds an element Mylist.insert(1,"Asslahi") #insert method adds an elemnet at the specified element Mylist.pop() #pop method removes an element Mylist.reverse() #reverse method re...
03812b053ecf23b1f536431f4a6c0276d4b6f086
nestorivanmo/DataStructuresAndAlgorithms
/Lab/Práctica3_Counting_Radix_sort/Node.py
681
3.625
4
import csv from random import randrange class Node: id = 0 city = "" def __init__(self, id, city): self.id = id self.city = city #append Node objects to a list def readFromFile(): lista = [] with open('country50.csv') as file: reader = csv.reader(file, delimiter=',') for row in reader: x = Node(row[...
d132c8729e8e892e2b8471cbabde5fdf2263e12a
piyushgoyal1620/HacktoberFest2021
/Python/sort_words_like_dictonary.py
1,020
4.375
4
def sort_words(): #defining the function for sorting the words. k=1 while k==1: #this condition is used so that the porgram doesnt stop untill all the data has been fed word=input('Enter the word, leave blank if you want to stop') #'word' variable stores the word entered by the user if ...
fb513325cc1609c1bd645df5d4719db75bb7f50e
anisul-Islam/python-tutorials-code
/Program10.py
194
3.703125
4
# Relational operators - >,<,>=,<=, ==, != and Boolean data types -> True / False print(20>10) print(20>=10) print(20>=20) print(20<10) print(20<=10) print(20<=20) print(20==20) print(20!=20)
200a575ffbdb12d8c318c4769e4f93e3f568d997
Beadsworth/ProjectEuler
/src/solutions/Prob28.py
384
3.859375
4
import src.EulerHelpers as Euler import math def find_dia_sum(side): """ for box of size side x side, find sum of diagonals side must be odd """ assert side % 2 == 1, "side must be odd" # closed form solution r = (side - 1) / 2 return int((16 * (r ** 3) + 30 * (r ** 2) + 26 * r + 3) ...
02921ea012a8359c9637cede4ddc4950b8f5483e
MED-SALAH/Data_Preprocessing
/regression_lineaire_multiple.py
1,079
3.546875
4
# Regression lineaire Multiple # importer les librairies import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importer le dataset dataset = pd.read_csv('50_Startups.csv') x = dataset.iloc[:, :-1].values # varialble indépondante y = dataset.iloc[:, -1].values # variable déponddante # Gérer les va...
fcda4ba9a7a70e1077de49839b24cd8ab86136fb
ekbaya/flask-api-back-end
/tasks/task.py
1,412
3.5
4
# import the pymysql module import MySQLdb import datetime import time # Code for creating a connection object db = MySQLdb.connect(host="localhost", # your host, usually localhost user="root", # your username passwd="", # your password db="...
1708aee7f57545f3ed18d56b83888950652f122a
keanubowker8/OPP-Dice-Game
/dice_game.py
3,191
3.921875
4
from multi_sided_die import * class DicePoker: amount = 100 double = False triple = False a = '0' def __init__(self): pass def roll_dice(self): value = [] ms = MultiSidedDie(6) for num in range(5): ms.roll() a = str(...
6a6e5252a48624c5a61adfe21084f65d45b8a032
iAtec-ua/python_course
/practice 5/Task_5_2_Numbers_to_words.py
5,709
3.609375
4
# Script prompts a number from user and prints the number in words # Create libraries for all kind of numbers ordinary_numbers = { "0": "", "1": " один", "2": " два", "3": " три", "4": " чотири", "5": " п'ять", "6": " шість", "7": " сім", "8": " вісім", "9": " дев'ять", "10"...
8ded61e9e792591fa905e3ab9a94f321f4441b34
JacobBarnholdt/battleship
/Highscore.py
1,910
3.6875
4
class Highscores: def __init__(self): self.file_name = "Highscore.txt" self.scores = [] self.read_scores() # self.add_score("nisåss2", 2) self.print_scores() self.write_scores() return def read_scores(self): file = open(self.file_name,"r") ...
3a47ceda8a2304ae0f521481cb3d1ef8b06e5594
heeryoncho/playnview_distinctwordfinder
/crawl_data/jpop.py
13,831
3.53125
4
import os import time import requests import pandas as pd from bs4 import BeautifulSoup ''' # Author: Heeryon Cho <heeryon.cho@gmail.com> # License: BSD-3-clause This code gathers yearly top 100 j-pop song information from the Oricon website. Note that this code only retrieves song name and artist name; the lyrics ...
d869916c1f69c46aa491ffcf1554631d9a6fbf01
marwafar/Python-practice
/length-last-word.py
322
3.671875
4
def length_of_last_word(s): if len(s) == 0: return 0 list_s=s.split() if len(list_s) >1: return len(list_s[-1]) elif len(list_s) == 1: return len(list_s[0]) else: return 0 s = "Hello World" print(length_of_last_wo...
fa7eba89b3c30fd2a5093aba03b19c989a284035
dong-alex/kattis
/sjecista/solution.py
1,797
3.5
4
""" Alex Dong 1413809 List any resources you used below (eg. urls, name of the algorithm from our code archive). Remember, you are permitted to get help with general concepts about algorithms and problem solving, but you are not permitted to hunt down solutions to these particular problems! (binomial th...
8332479462c260120fdec03f48fe5572d1e1e4a6
jagrvargen/holbertonschool-higher_level_programming
/0x03-python-data_structures/7-add_tuple.py
286
3.828125
4
#!/usr/bin/python3 def add_tuple(tuple_a=(), tuple_b=()): myTup = () while len(tuple_a) < 2: tuple_a = tuple_a + (0,) while len(tuple_b) < 2: tuple_b = tuple_b + (0,) for i in range(2): myTup = myTup + (tuple_a[i] + tuple_b[i],) return myTup
0d937c6c68af8e11754ecce1d2af3645a75e5639
amirsaleem1990/python-practice-and-assignments
/Exercises from www.practivepython org/Exercise #30&31&32.py
1,617
3.9375
4
# Exercise #30 & 31 & 32 # http://www.practicepython.org/exercise/2016/09/24/30-pick-word.html # http://www.practicepython.org/exercise/2017/01/02/31-guess-letters.html # http://www.practicepython.org/exercise/2017/01/10/32-hangman.html def pick_word(): import random return random.choice([i.lower() for i in op...
fb9e93df43c42cbb33ff9d4ba1ee2279a7710e87
Darkwing53/Dungeons_and_Dragons
/dungeon_and_dragons.py
2,332
3.859375
4
import random import os def clear_screen(): os.system('cls' if os.name == 'nt' else 'clear') dungeon = [(x,y) for x in range(5) for y in range(5)] def random_items(): return(random.sample(dungeon,3)) def make_dungeon(player_position): print(" _ _ _ _ _") for cell in dungeon: y = cell[1] ...
6e4c1223c5dcbeebfcfd6d67d26744161024e23f
mervesenn/Python-proje
/koşullu durumlar/fibonacciserisi.py
266
4.21875
4
""" fibonacci serisi yeni bir sayıyı önceki iki sayının toplamı şeklinde oluşturulur. 1,1,2,3,5,8,13,21,34..... """ a = 1 b = 1 fibonacci = [a, b] for i in range(10): a , b = b, a + b print("a:", a,"b", b) fibonacci.append(b) print(fibonacci)
6630c0bfc4f1d029acd467d33c3e52e6d31b0a88
zafarali/experiments
/python/calgpa.py
1,870
3.796875
4
from sys import argv script_name, user = argv print "Calculating GPA for ",user f = open(user+".txt", "r") summation = 0 total_credits = 0 def parsegrade(letter): if letter=="A": return 4.0 elif letter=="A-": return 3.7 elif letter=="B+": return 3.3 elif letter=="B": retu...
a884b8ba57610924bfc2338a621adb94f5b7acb3
mathiasesn/obstacle_avoidance_with_dmps
/DMP/obstacle.py
1,771
3.640625
4
import numpy as np class Obstacle: def __init__(self, pos, radius = 0.015, discrete_steps = 15): """ Creates spherical obstacle centered at 'pos' with radius 'radius'. Meshgrid created with amount of steps 'discrete_steps'. """ self.pos = np.array(pos) self.r ...
4da07735cba599c70ee00b04f69d63c33d94c537
ToluwaniO/ITI1120
/a3_8677256/a3_Q3_8677256.py
665
4.0625
4
#Family name: Ogunsanya Toluwani Damilola # Student number: 8677256 # Course: IT1 1120 # Assignment Number 3 Question 3 def longest_run(l): ''' (list of numbers) -> number returns the length of the longest run in the list preconditions: l must be a list ''' mLen = 0 ...
8fe3cfb8487d7757206303b67eb80222ae756b10
DebadityaShome/Coders-Paradise
/Python/Level 0/inRange.py
445
4.03125
4
""" Given an inRange(x,y) function, write a method that determines whether a given pair (x, y) falls in the range (x < 1/3 < y). Essentially, you’ll be implementing the body of a function that takes in two numbers x and y and returns True if x < 1/3 < y; otherwise, it returns False. """ def inRange(x,y): return ...
8de8e20df1dd8e2860c469cb0f1c9af7bf288f32
graviteja28/jetbrains
/Stage 3-4: I'm so lite.py
5,340
4.0625
4
''' Stage 3-4: I'm so lite Description It's very upsetting when the data about registered users disappears after the program is completed. To avoid this problem, you need to create a database where you will store all the necessary information about the created credit cards. We will use SQLite to create the database. S...
36440fbb16612d81dd8f83c201aa970cc7cfcfa4
caszimirbehrens/patatje_met
/python3_III.py
256
4.1875
4
def reverse_string(woord): stringA = "" stringB = "" for letter in woord: stringA = letter stringA += stringB stringB = stringA return stringB woordje = input("geef woord ") print(reverse_string(woordje))
81dd41a5eedecb63d2b6738c5de7ae1398a6992e
Shandmo/Struggle_Bus
/Other/Restaurant.py
615
3.984375
4
## 9-1 Restaurant ## __init__ method should store two attributes. Make two methods, one that describes the restaurant, and one that "opens" the restaurant. class Restaurant(): def __init__(self, restaurant_name, cuisine_type): # attach attributes self.restaurant_name = restaurant_name ...
2dddce458a8f69b5419db323365b4c96d32ae859
4lasR0ban/Belajar-Python
/Tipe data dinamis/latihan01.py
609
3.84375
4
# latihan projek python sayur = ['bayam', 'kangkung', 'wortel', 'selada'] print('Menu:') print('1. Tambah data sayur') print('2. Hapus data') print('3. Tampilkan data sayur') tambah = 1 hapus = 2 show = 3 choice = int(input('Pilihan anda: ')) while True: if choice == 1: x = str(input('Tambah data sayur: ...
c9d8d9b2fa39a113217231b955c1a01e42eb9186
red-sap/cloud1907
/06.function/01.function_defind.py
784
3.640625
4
# 在Python中为了让程序能够得到精简,我们回去引入函数的概念 # number = [1, 4, 2, 3, 5, 1] # for i in range(len(number)): # for j in range(len(number) - 1): # if number[j] > number[j+1]: # number[j], number[j+1] = number[j+1], number[j] # # # number02 = [23, 12, 34, 115, 123] # for i in range(len(number)): # for j in...
704b120794dbc7367dbd65f86c39aed1243c2722
MarcioPorto/federated-phenotyping
/project/phenotyping/dataset.py
992
3.5625
4
import pandas as pd class DatasetProvider: def __init__(self,train_path,test_path): self.train_path = train_path self.test_path = test_path self.data_train = pd.read_csv(train_path) self.data_test = pd.read_csv(test_path) def split_data(self,data_stream,num_parts...
992efbbb16605888dd85496235e5f7cbd73c862a
zois-tasoulas/algoExpert
/medium/linkedListConstruction.py
4,720
3.828125
4
class Node: """ value : int prev : Node next : Node """ def __init__(self, value, prev=None, nxt=None): self.value = value self.prev = prev self.next = nxt class DoublyLinkedList: """ head : Node tail : Node """ def __init__(self): self.hea...
d54a5e47079f0347cfe4680278911596ae923a21
not-sponsored/Guide-to-Data-Structures-and-Algorithms-Exercises
/algorithms/middle_link.py
2,463
3.84375
4
import sys class Node(): def __init__(self, value, next=None): self.value = value self.next = next def print_node(self): print(self.value) class SinglyLinkedList(): def __init__(self, head=None): self.head = head def add_node(self, val): new_node = Node(val) if self.head == None: self.head = new_...
307984652ba4607429f90d40b736121de7735583
konfer/PythonTrain
/src/train/test/NestedLoopTest.py
190
3.78125
4
# coding:utf-8 row = 0 column = 0 theNum = int(raw_input("Please input a num:\n")) i = 1 while i < theNum: i += 1 j = 1 while j < i: print j, j += 1 print
7845c82ef3fb0b8f82fc1d7424e95af1a9cbb816
PrestonTGarcia/Electric-Field
/Electric-Field-3D/visualization.py
8,142
4.375
4
################################################################## # visualization --- Program that creates a 3D matplotlib graph # # that visualizes the electric field created from two particles # # created from the user's inputs. # # @author Preston Garcia ...
68b91a2c95f8a2fd1c7245f16b78d1679c88251d
mintdouble/LeetCode
/Easy/598_范围求和||/main.py
328
3.625
4
# 思路:返回x坐标的最小值与y坐标最小值的乘积,因为坐标值越小加1的次数越多,所以最大值集中在矩阵的左上角 class Solution: def maxCount(self, m: int, n: int, ops: List[List[int]]) -> int: return m*n if len(ops) < 1 else min([x[0] for x in ops]) * min(x[1] for x in ops)
e0507ab3347ed687581ce2d29bd706dd907aa626
ferxohn/proyecto1
/REPORTE-01-GOMEZ-FERNANDO.py
17,897
3.796875
4
#!/usr/bin/env python # coding: utf-8 # Por: Fernando Gómez Perera import lifestore_file as lifestore # Variables que contienen los distintos conjuntos de datos products = lifestore.lifestore_products sales = lifestore.lifestore_sales searches = lifestore.lifestore_searches # Listas con los usuarios y contrasenas ...
493d9421b90820f30501cca861197767bebf2934
zhangxiaoyuan/pythonStudy
/src/loo_test.py
1,294
3.796875
4
#!usr/bin/python #coding=utf-8 #while...else count = 0 while count < 5: print 'count=', count count += 1 else: print count, 'more than 5' count =0 while count < 5: print 'count=', count count +=1 if count ==3: break; else: print count ,'more than 5' print 'if break can not execute else' #for & for...else ...
3435cf59814000c8047d7ccaf6777a9e1f1dd7fe
ArtemBaldin/STUDY
/PYTHON_INTRODUCTION/HOMEWORKS/home_work_4.py
1,746
3.8125
4
# That was intresting))) import sys def if_ru_in_text (text_): ru_a="а, б, в, г, д, е, ё, ж, з, и, й, к, л, м, н, о, п, р, с, т, у, ф, х, ц, ч, ш, щ, ъ, ы, ь, э, ю, я" ru_a=ru_a.replace("," " ", "") ru_a=list(ru_a) ch_text=0 for i in range(len(ru_a)): ch_text +=text_.count(ru_a[i]) return ch_text var_string =...
cc96c3b3eb94b24d228159c0eadf545174cb35df
naix5526/genese-final_python
/assignment-4b.py
1,027
4.1875
4
'''Implement question number 1, 2 and 4 from Session 2 Exercise as different functions in a single (.py) file.''' '''1. Choose a list of your choice and find the sum of all elements of that list. For example, the sum of [6,9,7,5,4] is 31.''' example = [6,9,7,5,4] def ele(choice): sum = 0 for str1 in choice: ...
12f5d00abfa2d3dba5136c76570d5863a579fea2
kidusasfaw/addiscoder_2016
/labs/server_files_without_solutions/lab6/numKnightWays/numKnightWaysSolFast.py
720
3.796875
4
import sys # This function takes as input two coordinates x and y, which the knight # must eventually reach, and a list of pairs L. L[i] should be a list of # length 2, representing a possible knight move--for example, if L[i] is # [4, 5], the knight can move four units horizontally and five vertically # in a si...
a707419fcc9f00aec6c5ff4883de62bf5f25ff92
anastasiia-shevchenko/Python-3-course
/lab 01-02/main.py
924
3.953125
4
import math a=True while a: print("Введите Х (Х>0)") x = int(input()) if x<=0 : print("Вы ввели не верное значение Х") else: a = (math.sqrt((3 * x + 2) ** 2 - 24 * x)) b = (3 * math.sqrt(x) - (2 / math.sqrt(x))) Z = a / b print("Результат:", Z) a=False p...
f7ffda930cc18f0c3a90535acf051fc8e851c486
namhoang1594/PXU_Python
/Find_Min.py
249
3.703125
4
import random n = int(input("Hay nhap so phan tu:")) array = [] for item in range(n): a = float(random.uniform(0,99)) array.append(a) print(array) min = array[0] for item in array: if item < min: min = item print("Min la: ", min)
0c34f144d6e3087d14b5b32a2d90e22742d08e8e
1798317135/note
/python/python函数/匿名函数.py
674
3.59375
4
# 匿名函数 lambad 函数 与 javascript的匿名函数有很大差别 # 匿名函数 不宜处理复杂的程序 # # ****** 方式一 ********* # --- (lambad 形参:返回值)(实参) result = (lambda a,b:a + b)(1,2) print(result) # ******* 方式二 ******** # # --- 用变量接收 匿名函数体 lambad 形参:返回值 result = lambda a,b : a -b print(result(5, 1)) # ******* 运用场景 ******** # # --- so...
1dee15d1d03c2352072e2a0448d1d2ca612de320
pranee786/python-scripts
/networking/tcpipserver.py
629
3.71875
4
import socket host = 'localhost' port = 4000 # Internet Protocol version 4, and TCP IP Protocol connection s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) # Socket to be binded with the set of host and port s.bind((host,port)) # Server will start listening to the port print('Server listening on port: ',port) s...
e93688f364ebf3cbc94ecb4cfa9a706d0edbc1b5
keiirizawa/BootCamp2019
/ProblemSets/Computation/Wk1-DifInt/ProblemSet1b/shut_box.py
1,878
3.859375
4
import box import numpy as np import random import time import sys if len(sys.argv) == 3: player_name = sys.argv[1] time_limit = float(sys.argv[2]) else: print("Need three arguments!") def simulate_roll(numbers_left): if sum(numbers_left) <= 6: return random.randint(1,6) else: r...
70868d3370b048e339a4af0e54b9cb015e9ad2c4
daniel-reich/turbo-robot
/Fpymv2HieqEd7ptAq_11.py
890
3.78125
4
""" Write a function that groups a string into **parentheses cluster**. Each cluster should be **balanced**. ### Examples split("()()()") ➞ ["()", "()", "()"] split("((()))") ➞ ["((()))"] split("((()))(())()()(()())") ➞ ["((()))", "(())", "()", "()", "(()())"] split("((())())(()(()()...
7c5c11c5e0d107735843fbbdf9e7ff60195f192f
Klauanny/LinguagemPOO
/endereco.py
721
3.8125
4
class Endereco(): def __init__(self) -> None: self._bairro = input("Digite o nome do seu bairro: ") self._rua = input("Digite o nome da sua rua: ") self._numero = "S/ Número" try: entrada = int(input("Digite o número da sua casa (caso não haja numero, digite '0'): "...
d555eab6f0b3653722818875a01d94ae1342ed1a
ErickMwazonga/sifu
/heaps/merge_k_sorted_arrays.py
977
3.59375
4
''' Merge K Sorted Arrays Input: [[1, 10, 11, 15], [2, 4, 9, 14], [5, 6, 8, 16], [3, 7, 12, 13]] Output: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] Naive Approach Put k lists in one big list - O(n*k), Then sort the big list quicksort. Overall time complexity would be O(nk) ...
e6476823106ef379ef092d5e44cfe1fa319dc4f0
rafaelperazzo/programacao-web
/moodledata/vpl_data/76/usersdata/184/36510/submittedfiles/jogoDaVelha.py
1,958
3.75
4
# -*- coding: utf-8 -*- import math x1 = int(input('Digite x1: ')) x2 = int(input('Digite x2: ')) x3 = int(input('Digite x3: ')) x4 = int(input('Digite x4: ')) x5 = int(input('Digite x5: ')) x6 = int(input('Digite x6: ')) x7 = int(input('Digite x7: ')) x8 = int(input('Digite x8: ')) x9 = int(input('Digite x9: ')) #CO...
fd24c6f32d12bb3d75a15382950a5d0f21aae9ae
netor27/codefights-solutions
/arcade/python/arcade-theCore/06_LabyrinthOfNestedLoops/043_IsPower.py
316
4.28125
4
def isPower(n): ''' Determine if the given number is a power of some non-negative integer. ''' if n == 1: return True sqrt = math.sqrt(n) for a in range(int(sqrt)+1): for b in range(2, int(sqrt)+1): if a ** b == n: return True return False
378d28574750fe97740d97938cd69c51f0c823bc
lovekobe13001400/pystudy
/py-cookbook/1.数据结构和算法/1.14排序不支持原生比较的对象问题.py
627
3.71875
4
#排序对象 class User: def __init__(self,user_id): self.user_id = user_id #重构__repr__方法后,不管直接输出对象还是通过print打印的信息都按我们__repr__方法中定义的格式进行显示了 #打印对象可视化 def __repr__(self): return 'User({})'.format(self.user_id) myUser = User(23) print(myUser.user_id) users = [User(23),User(3),User(99)] ...
d4f2f8709e5ef7d3e7e633790b352b3225761048
lmthanh2011/luongminhthanh-fundamental-c4e17
/fundamental/session4/tamgiacpascal.py
321
4.09375
4
from turtle import * speed (3) shape ('turtle') for i in range (3): forward (50) left (120) right (60) for i in range (3): forward (50) left (120) right (60) for i in range (3): forward (50) left (120) right (60) forward (50) for i in range (3): forward (50) left (120) mainloop ()...
f0158d1898abbce5b9de153fe975059d5bef0e6e
lemming52/white_pawn
/leetcode/q019/solution.py
1,115
3.90625
4
""" Given a linked list, remove the n-th node from the end of list and return its head. Example: Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked list becomes 1->2->3->5. Note: Given n will always be valid. """ # Definition for singly-linked list. #...
cde071b3b3ea5ebd324c0816843da7bb943a6153
beejjorgensen/bgpython
/source/examples/listops.py
813
3.703125
4
a = [5, 2, 8, 4, 7, 4, 0, 9] print(len(a)) # 8, the number of elements in the list a.append(100) print(a) # [5, 2, 8, 4, 7, 4, 0, 9, 100] print(a.count(4)) # 2, the number of 4s in the list print(a.index(4)) # 3, the index of the first 4 in the list v = a.pop() # Remove the 100 from the end of the list pri...
1e8d45588be301820d689b988c50174fee7ba0b4
davidHards/Twitch_Project
/rowCount.py
1,312
3.96875
4
''' Count number of rows in csv files Date: 24/01/2019 Author: David Hards This is a helper program that serves no purpose for project. This program gets number of rows for each csv file, and displays count for how many have 99, 100 or other number of rows. ''' import glob import os import csv topGames...
c2db1fb5b2099c63897fde6753abd69f4519f4a3
nsudhanva/mca-code
/Sem3/Python/assignment4/4_frequency.py
292
4.03125
4
something = input('Enter a string: ') some_char = input('Enter a character: ') def count_occ(something, some_char): count = 0 for i in something: if i == some_char: count += 1 return count print('Count of', some_char, 'is', count_occ(something, some_char))
987036553f9c57871a524b7394f08efb8cdb87bc
JGuymont/ift2015
/3_tree/LinkedBinaryTree.py
5,655
3.921875
4
#!/usr/local/bin/python3 from BinaryTree import BinaryTree # implémentation de BinaryTree avec des noeuds chaînés class LinkedBinaryTree(BinaryTree): """Binary tree implementation using linked nodes""" class _Node: def __init__(self, element, parent=None, left=None, right=None): ...
0434209a8ae7fd57e09f83906d35e99f9f7938ad
poncho901/python
/Useless Flights.py
2,198
3.796875
4
from typing import List from collections import defaultdict def useless_flight(schedule: List) -> List: book = {} new = {} nodes = set() result = [] for [d1,d2,cost] in schedule: if d1 not in book.keys(): book[d1] = {} book[d1][d2] = cost if d2 not in book.keys()...
460597a99b01a5c48577ab7d5a1372a127001ebd
dinohunter2836/supreme-waffle
/lab1.py
2,672
3.8125
4
import re import argparse def word_count(path): with open(path) as file: text = file.read() arr = re.split(r'\W', text) word_dict = dict() for index in range(0, len(arr)): if arr[index] == '': continue if arr[index] in word_dict: word_dict[arr[index]] +=...
bafdbb6d7d8836986b64d209f6df7c65e2f9c798
shenlinli3/python_learn
/second_stage/day_01/demo_08_条件判断分支.py
1,614
4.0625
4
# input() 输入函数 # 该函数接收到的任何内容都是字符串类型 # in1 = input("请输入账号:") # in2 = input("请输入密码:") # print(in1, in2) # 条件判断分支 # if 如果 # elif 又如果 # else 否则 # num1 = int(input("请输入第一个数:")) # num2 = int(input("请输入第二个数:")) # if num1 > num2: # True False # print("第一个数大于第二个数") # print("Test...1") # elif num...
9b973162d179e63e51093411c528481cdfac5c13
ash/python-in-5days
/day3/05-file-not-there.py
198
3.609375
4
# Catch an exception if there is no file on disk. try: with open('non-existing.txt') as f: data = f.read() print(data) except FileNotFoundError: print('not found') print('ok done')
2c4ba439611466fec7a4dc0efadf6273eaa3c712
DerrickChanCS/Leetcode
/082.py
1,370
3.734375
4
""" Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Example 1: Input: 1->2->3->3->4->4->5 Output: 1->2->5 Example 2: Input: 1->1->1->2->3 Output: 2->3 """ # Definition for singly-linked list. # class ListNode(object): # def __init_...
531c631d1b2b447c97149f81eea69460d1cae602
BingoJYB/Data-Structure-and-Algorithm
/swap vowels in string.py
743
4.15625
4
''' Given a string, your task is to reverse only the vowels of string. Examples: Input: hello Output: holle Input: hello world Output: hollo werld ''' def swap(str_ls, x, y): temp = str_ls[x] str_ls[x] = str_ls[y] str_ls[y] = temp return str_ls def solution(string):...
4cec3b56e303e7ab040159ee67d4b0e8bf320fbf
aguscerdo/183D-capstone
/PHANTOMbots/test.py
328
4.09375
4
desired_h= 5 actual_h = 350 difference = 180 - abs(abs(desired_h - actual_h) - 180) print(difference) if(actual_h < desired_h ): if desired_h - actual_h > 180: print("go left") else: print("go right") else: if actual_h - desired_h > 180: print("go right") else: print("g...
f287cc57e656523333e56b029399324917051ad3
Adasumizox/ProgrammingChallenges
/codewars/Python/8 kyu/StringRepeat/repeat_str_test.py
795
3.671875
4
from repeat_str import repeat_str import unittest import string class TestRepeatStr(unittest.TestCase): def test(self): self.assertEqual(repeat_str(4, 'a'), 'aaaa') self.assertEqual(repeat_str(3, 'hello '), 'hello hello hello ') self.assertEqual(repeat_str(2, 'abc'), 'abcabc') def...
4a27024fe24707c3aeb78e38bf6d52d939b81a46
shambhand/pythontraining
/material/code/advanced_oop_and_python_topics/9_DecoratorApplications/decorator_app4.py
755
3.734375
4
import sys def tracer(func): # State via enclosing scope and func attr def wrapper(*args, **kwargs): wrapper.calls += 1 print('call %s to %s' % (wrapper.calls, func.__name__)) # calls is per-function, not global return func(*args, **kwargs) wrapper.calls = 0 return wrapper @tracer #...
1bb4eab80f49a2667bd3fa4f730ac5997e551ac4
chainchompa/Intro-Python
/src/days-2-4-adv/room.py
1,498
3.6875
4
# Implement a class to hold room information. This should have name and # description attributes. class Room: def __init__(self, name, description, items): self.name = name self.description = description self.items = items self.n_to = None self.s_to = None self.e_to ...
12da54a2c94f5f02f90dc32f7f1f0c2dca893c64
sylvanoz14/hackerrank
/algorithms/strings/bear_and_steady_strain.py
3,484
3.75
4
from collections import defaultdict """ def smallest(s1, s2): assert s2 != '' d = defaultdict(int) nneg = [0] # number of negative entries in d def incr(c): d[c] += 1 if d[c] == 0: nneg[0] -= 1 def decr(c): if d[c] == 0: nneg[0] += 1 d[c] -= 1...
d87731ebe3924041442b2816c0d3464830158f67
jedzej/tietopythontraining-basic
/students/bec_lukasz/lesson_04_unit_testing/fibonacciTests.py
1,329
4.125
4
import unittest def fib(number): if number is not int(number): raise ValueError elif number is None: raise TypeError elif number <= 0: raise RecursionError else: if number == 1 or number == 2: return 1 else: return fib(number - 1) + fib(...
3354a9a4ae759b3a00e66b9bca1cb227cd74c4b5
soham-shah/Intro-to-AI
/Assignment3/asignment3.py
4,920
4.28125
4
#Name: Soham Shah #Class: Intro to AI #Instructor: Rhonda Hoenigman #Assignment 3 #the goal of this is to create a graph from a text file and run a* search on it. import sys import heapq import time class Graph: def __init__(self): self.vertices = {} self.heuristic = {} def addVertex(self, va...
0bac9788ef0adb51e19346d13a8b3bf3f20d0ce6
salilkanitkar/lpthw_exercises
/e20.py
966
3.90625
4
#!/usr/bin/python """ Exercise 20 """ """ PreRequisite: A file e20_sample.txt must be already present before running this exercise. """ from sys import argv script, input_file = argv def print_all(f): f.read() def rewind(f): f.seek(0) def print_a_line(line_count, f): print "LineNum: %d %s" % (line_cou...
a5743efd7661f225e316ca1638bd16b985127a88
enrong/MITx-6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python
/Problem Set 2 Paying the Minimum.py
617
3.71875
4
balance = 5000 annualInterestRate = 0.18 monthlyinterestrate = annualInterestRate/12 upbalance = balance monthlyPaymentRate = 0.02 i=-1 totalPaid = 0 while i < 12: i += 1 minimummonthlypayment = upbalance*monthlyPaymentRate upbalance = (upbalance - minimummonthlypayment)*(1+ monthlyinterestrate) print ...
77b42bcfe2f83c8928b0bfb6c1fffa403a14742a
PRSarte/ProgrammingAssignment1
/getGuessedWord.py
348
4
4
def getGuessedWord (secretWord,lettersGuessed): #The function getGuessedWord was created word = [] #This function shows the word with missing letters for x in secretWord: if x in lettersGuessed: word.append(x) else: word.append('_')...
0df1540ed5a03ffb8cf7b6506b08abf9ed06c4cb
romanticair/python
/basis/turtle-draw-demo/递归Y分形.py
320
3.90625
4
import turtle def tree(n, d): # left -> right if n == 0: turtle.forward(d) else: turtle.forward(d) for angle in (30, - 60): turtle.lt(angle) tree(n - 1, d / 2) turtle.bk(d / 2) turtle.lt(30) turtle.lt(90) tree(9, 150) turtle.mainloop()
25a1ab288c6a8f62b7cb767686ca947bd5312a5e
shubhransujana19/Python
/split.py
270
3.859375
4
# -*- coding: utf-8 -*- """ Created on Sat Oct 2 17:33:23 2021 @author: shubhransu """ import random names = input("Give any names by using comma: ") names_list = names.split(", ") bill = random.choice(names_list) print(f"{bill} will pay the bill")
918f0b361ebf5675f9a12c5002d7fdba1153c866
budaLi/leetcode-python-
/交替位二进制之.py
319
3.59375
4
#-*-coding:utf8-*- #author : Lenovo #date: 2018/8/26 def hasAlternatingBits(n): """ :type n: int :rtype: bool """ num=bin(n)[2:] print(num) num2=num[1:] for i in range(len(num2)): if num[i]==num2[i]: return False return True res=hasAlternatingBits(5) print(res)
d7569a0c4c3d10a44132b72d7cca730f9a111906
jingzli/python
/file_handling/unzipFiles.py
301
3.546875
4
def unzipFiles(): zip_file_path = "C:\AA\BB" file_list = os.listdir(path) abs_path = [] for a in file_list: x = zip_file_path+'\\'+a print x abs_path.append(x) for f in abs_path: zip=zipfile.ZipFile(f) zip.extractall(zip_file_path) pass
79c646c7b807a301c5feb49ddbe477d70db4ec73
Our-Python-Projects/Genetics-ans
/Codes/BCIproject1d.py
1,528
3.703125
4
#part d of project-1 import numpy as np import timeit n = 12 numOfExecutions = 10 # the following function initializes answer data structure and then gets the anser from another function def analyticalAnswer(): ans = np.zeros((n,), dtype=np.int) ans = analyticalConstructor(ans,n) return ans # the following ...
964eab3832b76e8b6f74671435ca52ebfca322d0
Ntims/Nt_Python
/실습20190419-20194082-김민규/P0614.py
466
3.78125
4
while True: dualnum = int(input("양수 입력(3보다 작으면 종료)")) if dualnum < 3: print("프로그램을 종료합니다.") break else: check = False for i in range(2,dualnum): if dualnum % i == 0: print(dualnum, "는 소수가 아니다") check = True ...
59e29be6eafae5cd9cb23f59da6c41b3b26c63e4
GeorgeKailas/python_fundamentals
/09_exceptions/09_05_check_for_ints.py
487
4.59375
5
''' Create a script that asks a user to input an integer, checks for the validity of the input type, and displays a message depending on whether the input was an integer or not. The script should keep prompting the user until they enter an integer. ''' in1 = "" while isinstance(in1, int) is False: try: ...
d8a8944028bbcb932033eb8e58faed1e2bf045cd
IulianStave/wblck
/cmdline.py
2,192
3.984375
4
#Command Line arguments sys.argv import sys argumentsCount=len(sys.argv) script=sys.argv[0] if argumentsCount>1: print("{} arguments passed on command line".format(argumentsCount)) print("The first argument is always the python script that you ran in command line: \'{}\'".format(script)) print("Here is the ...
99fd18d04611949416190f23a0d3d4a26c4e3d5f
albertofcasuso/ejercicios_python
/adivina.py
1,192
3.828125
4
import random a = random.randint(1, 1000) salir = 0 intentos = 0 while salir != "exit": salir = input("Adivina el número o escribe \"exit\" para salir: ") try: int_salir = int(salir) if int_salir == a: if intentos == 0: print("¡¡¡Has acertado a la primera!!!") ...
d8feb126be1f5d86786dcca13e815d56aeae1791
stefano-gaggero/advent-of-code-2019
/2019-20.py
7,827
3.78125
4
# -*- coding: utf-8 -*- """ --- Day 20: Donut Maze --- You notice a strange pattern on the surface of Pluto and land nearby to get a closer look. Upon closer inspection, you realize you've come across one of the famous space-warping mazes of the long-lost Pluto civilization! Because there isn't much space on Pl...
daa745dda0bb75bf6d4994d8ee32bd30da366451
muremwa/Python-Pyramids
/inverted_triangle.py
281
4.15625
4
""" Triangle in the following manner ******** ******* ****** ***** **** *** ** * """ def inverted_right(num_rows): num_rows += 1 for i in range(1, num_rows): line = "*"*(num_rows-i) print(line) rows = int(input("How many rows?: ")) inverted_right(rows)
fd01a6944084314342f59fa3cd277825bdfd447c
iLegendJo/GClegend
/chp5_awex7.py
435
4.25
4
#" exercise 7. The following statement calls a function named half, which #returns a value that is half that of the argument. (Assume the number #variable references a float value.) Write code for the function. " def half(number): total = 0.0 total = number / 2 return total value = float(input...
b6531888028638899460cd4e2ba0b53efcfe4c3d
Zhmur-Amir/Zadacha23
/Zadacha6.py
3,141
4
4
import os path_to_file = 'C:/Users//test/Zadacha6/text.txt' file = open(path_to_file, "r") try: if (os.stat(path_to_file).st_size > 0): print("file opened successfully") if (os.stat(path_to_file).st_size == 0): print("Error: empty file") except OSError: print("cannot ope...
c22c41a7c3601f17d23bd2cfaadaf6b5510a1184
pktrigg/DocumentDelivery
/_bootstrap/_scripts/scan.py
3,732
3.578125
4
# created p.kennedy@fugro.com # created: May 2015 # Based on twitter bootstrap # import os import sys import re import csv # specify a list of folder names which will be skipped in the scanning process. The list can be as long as you like. def convert(name): s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) r...
3f59e7b490a76b86a06de55c9379120eb2169698
EruDev/Python-Practice
/菜鸟教程100例/12.py
180
3.5625
4
# 题目:判断101-200之间有多少个素数,并输出所有素数。 for num in range(101, 200): for i in range(2, num): if (num % i) == 0: break else: print(num)