blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
371d862ac49e9c80dc0095451b52f2610094317a
anuragull/algorithms
/leetcode/15.3Sum.py
1,497
3.765625
4
""" Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: The solution set must not contain duplicate triplets. Example: Given array nums = [-1, 0, 1, 2, -1, -4], A solution set is: [ [-1, 0, 1], [...
8cf101d9ea1e087e8205480d38ff760f2755762e
kmadathil/sanskrit_parser
/sanskrit_parser/parser/sandhi.py
11,621
4.0625
4
# -*- coding: utf-8 -*- """ Intro ===== Sandhi splitter for Samskrit. Builds up a database of sandhi rules and utilizes them for both performing sandhi and splitting words. Will generate splits that may not all be valid words. That is left to the calling module to validate. See for example SanskritLexicalAnalyzer Exa...
e8234258252f633baef8f390fc32e5db2049ebed
prabhupant/python-ds
/data_structures/bst/dfs_recursion.py
615
3.734375
4
class Node(): def __init__(self, val): self.val = val self.left = None self.right = None # Depth First Search def inorder(root): if root: inorder(root.left) print(root.val) inorder(root.right) def postorder(root): if root: postorder(root.left) ...
08585d156fed8de6ed7b104ab73aab97f135c625
mpresto/dojo
/python_stack/_python/OOP/chaining.py
1,246
4.09375
4
class User: """A Class for bank users""" def __init__(self, username, email_address): self.name = username self.email = email_address self.account_balance = 0 def make_deposit(self, amount): self.account_balance += amount return self def make_withdrawal(self, am...
66629c477b96fadafe7559ff4750794d0dcf45ea
LandenBrown/ProjectFrog
/src/frog_species.py
4,351
3.953125
4
import random class Frog: def __init__(self, name, external_attributes, internal_attributes, days_alive, lifespan_days, days_without_food, starvation_days, is_dead, mate_chance, infertile): self.name = name self.external_attributes = external_attributes self.internal_attributes = internal_...
02a5b163f5a83d037d3d50cb73db148b69df6521
coderMaruf/Problem_solving
/1021.py
326
3.515625
4
#Banknotes and Coins a = float(input()) print('NOTAS:') for i in [100,50,20,10,5,2]: print(f'{int(a/i)} nota(s) de R$ {i}.00') a = float(f'{a%i:.2f}') # print (a) print('MOEDAS:') for i in [1.00,0.50,0.25,0.10,0.05,0.01]: print(f'{int(a/i)} moeda(s) de R$ {i:.2f}') a = float(f'{a % i:.2f}') # pri...
3e42962f01b5950ffac1e82bc802a10d9c73225e
alf808/python-labs
/01_python_fundamentals/01_07_area_perimeter.py
419
4.03125
4
''' Write the necessary code to display the area and perimeter of a rectangle that has a width of 2.4 and a height of 6.4. ''' rectangle_width = 2.4 rectangle_height = 6.4 rectangle_area = rectangle_width * rectangle_height rectangle_perimeter = rectangle_width * 2 + rectangle_height * 2 print(f"Area of a 2.4 by 6.4...
e3a38ceb0859d518f4fa4c56fd59e30bc66c3211
gscr10/Python_study
/r_26_文件目录管理操作.py
373
3.703125
4
# 文件目录操作 # 导入 os模块 import os # 文件操作 os.rename("test.txt", "Test.txt") # os.remove() # 目录操作 print(os.listdir(".")) # eval函数 # 将字符串当成有效的表达式,并返回计算结果 # 不要使用eval函数直接转换 input 的结果 # 案例:计算器 input_str = input("请输入算术题:") print(eval(input_str))
7989259788936ab2041acec7df842b72e75eebc8
amitsingh790634/tathastu_week_of_code
/day1/program5.py
903
4.03125
4
run_player1=int(input("Enter the run scored by player1 in 60 balls: ")) run_player2=int(input("Enter the run scored by player2 in 60 balls: ")) run_player3=int(input("Enter the run scored by player3 in 60 balls: ")) strikerate1=run_player1 * 100/60 strikerate2=run_player2 * 100/60 strikerate3=run_player3 * 100/60 print...
f1009259b4e576b0555dc2bc55272c11927578fa
hamazumi/Leetcode
/detect-capital/detect-capital.py
357
3.734375
4
class Solution: def detectCapitalUse(self, word: str) -> bool: if word.isupper(): return True elif word.islower(): return True elif word == word.capitalize(): # capitalize() turns the first letter capital and the rest are turned lowercase return True ...
13ed209ec1af069c6f45eb843898ef9b4cdf055c
bjaus/RealPython
/sql/assignment3b.py
964
4.4375
4
# Assignment 3b - prompt the user # import the sqlite3 library import sqlite3 # create the connection object conn = sqlite3.connect('newnum.db') # create a cursor object used to execute SQL commands cursor = conn.cursor() prompt = """ Select the operation that you want to perform [1-5]: 1. Average 2. Max 3. Min 4. ...
ed24cb5b592af17291c01d6cf9927a5c57320fb3
SimeonTsvetanov/Coding-Lessons
/SoftUni Lessons/Python Development/Python Advanced January 2020/Python Advanced/23. EXAM/01. Expression Evaluator.py
829
3.828125
4
import math from collections import deque the_ugly_expression = input().split() current_nums = deque([]) check = True for symbol in the_ugly_expression: if symbol.isdigit() or len(symbol) >= 2: current_nums.append(symbol) else: if check and (symbol == "/" or symbol == "*"): ...
fb9903c28aaf1aec877b8db2e59066bf5ee6cef0
JaredColon-Rivera/The-Self-Taught-Programmer
/.Chapter-7/Challenge_4.py
397
4.03125
4
list_num = [1, 2, 3, 4, 5, 6, 7, 8, 9] guess_q = "What number is in the list?: " while True: print("Input q to quit") guess = input(guess_q) if guess == "q": print("Goodbye") break try: guess = int(guess) except ValueError: print("please type a number or q to quit") if guess in list_num: print("You got ...
3848b6baaddf728df150a746a8c97ed0da8ad3ac
Taller-Python-SEGuach/Leccion7
/parametres_ex.py
293
4
4
def saludo(idioma): if idioma == "En" : print("Hello") elif idioma == "Fr" : print ("Bonjour") elif idioma == "Es" : print("Hola") else : print("No es un idioma") Entrada=input("Ingrese el idioma del saludo (En, Fr, Es):") saludo(Entrada)
454e64f53768d881701fbe2556e9a7758992f295
timisenman/python
/projects/Codewars/high_and_low.py
807
3.953125
4
# In this little assignment you are given a string of space # separated numbers, and have to return the highest and lowest number. #high_and_low("1 2 3 4 5") # return "5 1" # def high_and_low(numbers): # high = max(numbers.split()) # low = min(numbers.split()) # return str(high) + " " + str(low) # print high_an...
c3948b74ac59fa06636f009621b63dd866b7c5a3
grzegorz-rogalski/pythonGrogal
/zaj2/zad2.py
129
3.59375
4
""" wyswietl tabliczke mnozenia """ for x in range(1,11): for y in range(1, 11): print "%3i" %( x*y), print "\n"
83d40dfa25747056a0fbbf226e3648270abf0acb
kyirong6/ds-for-fun
/arash/recursion/Reverse_Sequence.py
352
4.03125
4
def reverse(S, start, stop): if start < stop - 1: S[start], S[stop - 1] = S[stop - 1], S[start] reverse(S, start + 1, stop - 1) S = [1, 2, 3, 4, 5, 6, 7, 8] reverse(S, 0, 8) # Reverses the sequence print(S) reverse(S, 4, 5) # Nothing happens print(S) reverse(S, 3, 5) ...
4f1e5d4b10010a13792998a305d0bc179b643ec4
hossainlab/dsn-template
/book/_build/jupyter_execute/demo/debugging.py
5,480
3.703125
4
(debugging)= # Debugging > \"Debugging is twice as hard as writing the code in the first place. > Therefore, if you write the code as cleverly as possible, you are, by > definition, not smart enough to debug it.\" -- Brian Kernighan ## Overview Are you one of those programmers who fills their code with `print` stat...
5145a4ab3eb447954260bc844cf08d32fc9f2293
SophieEchoSolo/PythonHomework
/Lesson2/solos02_celsius2fahrenheit.py
522
4.28125
4
""" Author: Sophie Solo Course: CSC 121 Assignment: Lab: Lesson 02 - Variables - Individual Description: Converts user input from celsius to fahrenheit """ # Input - Ask user for tempterature input in celsius celsius = input("Enter temperature in Celsius: ") # Convert the user input from string to float cels...
1e0305078426211c35d1bc434468b490f30985d5
beomjun96/python-study
/2.1 if_statement_practice/if_practice2_1_6.py
571
4.0625
4
# 영문 대문자를 입력받아 # 'A'이면 “Excellent”, # 'B'이면 “Good”, # 'C'이면 “Usually”, # 'D'이면 “Effort”, # 'F'이면 “Failure”, # 그 외 문자이면 “error” 라고 출력하는 프로그램을 작성하시오. # 입력 예: B # 출력 예: Good word = input("영문 대문자 입력:") if word == 'A': print("Exellent") elif word =='B': print("Good") elif word == 'C': print("...
7d8af0bf673542c57045b7796eb2ab3e5ab87036
maddrings/comp110-21f-workspace
/exercises/ex01/hype_machine.py
240
3.640625
4
"""Hype phrases with your name as a variable.""" __author__ = str("730396516") name: str = input("What is your name? ") print(name + ", you rock!") print("That's right, " + name + ", you are a baddie!") print("Talk yo stuff " + name + "!")
82d3b10fb2c32c864982aee09ad341c8dc6467c4
Nfrederiksen/PythonRep
/ML/DeepNN_inNumPy.py
3,617
4.28125
4
import numpy as np from matplotlib import pyplot as plt def sigmoid(z): """sigmoid activation function on input z""" return 1 / (1 + np.exp(-z)) # defines the sigmoid activation function def forward_propagation(X, Y, W1, b1, W2, b2): """ Computes the forward propagation operation of a neural netwo...
0386733594c90607a4d34b0f5468fd6340644c52
muzigit/PythonNotes
/section1_语法基础/action3.py
945
4
4
# 条件判断 age = 18 # if...elif...else的定义 if age < 18: print('未成年') elif age == 18: print('刚好成年') else: print('已成年') # 练习: # 小明身高1.75,体重80.5kg。请根据BMI公式(体重除以身高的平方)帮小明计算他的BMI指数,并根据BMI指数: # # 低于18.5:过轻 # 18.5-25:正常 # 25-28:过重 # 28-32:肥胖 # 高于32:严重肥胖 height = 1.78 # 单位:m weight = 60 # 单位:kg # ** 表示求平方 BMI = w...
229f1481265b25beaecbb58976d926ef43f86081
nagauta/Codecademy
/DataStructure/data_structure/Graph/graph.py
2,680
3.90625
4
from vertex import Vertex class Graph: def __init__(self): self.graph_dict = {} def add_vertex(self, node): self.graph_dict[node.value] = node def add_edge(self, from_node, to_node, weight = 0): self.graph_dict[from_node.value].add_edge(to_node.value, weight) self.graph_dict[to_node....
314c06fdb778ea671c3bfa2e4cb97bc3a4e2fabb
linth/learn-python
/data_structure/list/list_iter.py
1,498
4.4375
4
""" iterable (可) - Lists, tuples, dictionaries, and sets are all iterable objects. - list, tuple, dict, set 都是 iterable 的 object。 - 通常是一個容器 - iterable實作__iter__方法回傳一個參考到此容器內部的iterator iterator - an iterator is an object which implements the iterator protocol, which consist of the methods __iter...
abc62e87950a26fb88985c6396b67609876dee9f
nog642/MathTools
/mttools/CalculusTools/__init__.py
904
3.9375
4
from mttools.Constants import EPSILON from mttools.Core import check_inf def derivative(f): """ Takes a lambda function and returns the derivative as a lambda function :param f: A one dimensional lambda function :return: f'(x) """ g = lambda x, h: f(x + h) return limit(()) # TODO Difer...
39eb9fbd59ff77e277d98f109422384dbc75d6db
anaheino/investmentCalculator
/investmentCalculator.py
1,000
3.609375
4
#!/usr/bin/python3 import sys def calculateInvestments(investmentsPerYear, years, gainAsNumber, calcOnlyWholeSum): i = 0 wholeSum = investmentsPerYear if calcOnlyWholeSum else 0 while i < years: if calcOnlyWholeSum: wholeSum = wholeSum * gainAsNumber else: wholeSum...
5243f74dcc584041296672cd446568fa9642c067
ohmygodlin/snippet
/ctf/misc/dijkstra.py
2,752
3.59375
4
#https://www.cnblogs.com/P201521440001/p/11415504.html #https://blog.csdn.net/imotolove/article/details/80633006 #https://blog.csdn.net/anlian523/article/details/80893372 #https://blog.csdn.net/AivenZhong/article/details/84385736 import heapq class Node: def __init__(self, cur): self.cur = cur self.edges = {...
9cbd0275df06a26853121366ea8dc338bda8746a
KonekoTJ/Level-3_Python
/Homework4/Fenrir/Homework4_4.py
664
3.953125
4
# -*- coding: utf-8 -*- """ Created on Tue Oct 27 20:33:30 2020 @author: Fenrir Description : 数値の表示、総計、及び平均数値を表示する事。 総計値と平均値、全て小数点以下は1桁に留める事。 Variable: Input:(a~e) sum:総計 average:平均数 Algorithm/Calculation: sum = a + b + c + d + e average = sum/5 """ # input a = int(input("input a:")) b = ...
e1c197b8dabd59ebc8c71bf29ed462d57e11053e
nerissavu/D4E-TC-NGA
/Session4/hw/serious_exercise1.py
174
3.875
4
name = str(input('Write your name: ')) name_lower = name.lower() name_notab = " ".join(name_lower.split()) updated_name = name_notab.title() print('Updated:', updated_name)
f32c0671b50aec14b9c629a9e880c7e0adbbacc8
The-Fungi/Hacktoberfest2021-1
/ProductOfNintegers.py
151
3.828125
4
a= int(input("Enter No of Numbers: ")) b = [] d = 1 for i in range a: c = int(input("Enter Number: ")) b.append(c) for x in b: d = d*x print(d)
37fc67d49aa8964814b97b24b338ea7e7807ebee
WaleedRanaC/Prog-Fund-1
/Lab 7/IndexList.py
862
4.4375
4
#this program demonstrates how to get the #index of an item in a list and replace it w/ # a new one def main(): #create a list with some items food=["pizza","chips","burgers"] #display the list print("Here are the utens ub the food list: ") print(food) #get the item to...
d3e887175c602883043179247c4423098a099d2f
selvi7/samplepyhon
/19.py
132
4.21875
4
n=int(input("Enter a number:")) fact=1 for i in range(1,n+1): fact=fact*i print("The fact of",n,"is",end="") print(fact)
5b12892a17e62ba2df60c28306d899f4e83e1083
RocketryVT/rocket-os
/src/sensors/scripts/sensor_monitor.py
5,303
3.546875
4
#! /usr/bin/env python3 ''' Sensor Monitor: Monitors and Displays the data streams of various sensors. + Num of Functions: 4 + Num of Classes: 1 ''' from time import time import rospy from std_msgs.msg import String, Bool, Float32 from sensors.msg import SensorReading import csv import numpy import re sen...
01fb8c6cca4f94e7cad4442be7e95b187d733f4c
kononovk/HomeTasks
/hw3/t03Hangman/hangman.py
2,081
4.125
4
from random import randint from hw3.t03Hangman.hangman_logic import get_guessed_word, is_word_guessed from termcolor import colored from string import ascii_lowercase def rand_word_gen(filename): with open(filename) as file: words = [row.strip() for row in file] random_word = words[randint(0, len(word...
a47a7b170b44df13bb3de2f3ea1110e7fa2b2433
sr-utkarsh/python-TWoC-TwoWaits
/day_6/12th.py
533
3.890625
4
def longestCommonPrefix( a,n): if (n == 0): return "" if (n== 1): return a[0] a.sort() end = min(len(a[0]), len(a[n - 1])) i = 0 while (i < end and a[0][i] == a[n - 1][i]): i += 1 if(i==0): print("No common prefix is found") else: ...
b0df20782b5b63e402c7e50dd39983f121a82a15
quochoantp/Project2
/PythonBTCoBan/1.5.py
155
3.65625
4
a= float(input()) b= float(input()) if a==0: print("Phuong trinh vo nghiem") else: c= -b/a print("Phuong trinh co nghiem la") print(c)
33ed443cc1ed26c1273cded15f229c21c92a5869
daniel-reich/ubiquitous-fiesta
/TsRjbMRoNCM3GHuDk_21.py
516
4.4375
4
def syllabification(word): ''' Returns a syllabificated version of words as per the instructions. ''' s_word = '' i = len(word) - 1 # step backwards through word VOWELS = {'A', 'a', 'e', 'i', 'o', 'u'} # the Persian vowels ​ while i >= 0: if word[i] not in VOWELS: s_wor...
e9b47397b86abfaa39863f5e9c0ba652fddd54a7
jdrkanchana/python_beginner_days
/printing_patterns.py
120
3.6875
4
a=[5,2,2,5,2] length_a=len(a) for x in range(0,length_a): y=a[x] for z in range(0,y): print('x', end='') print("")
f52a3545299ef5b0226757417bebe68e57147765
shash95/datastructures-and-algorithms
/LeetCode/Longest Substring Without Repeating Characters.py
1,378
4.125
4
""" Given a string s, find the length of the longest substring without repeating characters. Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: s = "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1. Example 3: ...
925ececf074a0820a4910bbe81649badcc833edc
awpathum/hackerRank
/jc.py
550
3.765625
4
# number of elements # n = int(input("Enter number of elements : ")) # a = list(map(int,input("\nEnter the numbers : ").strip().split()))[:n] # print("\nList is - ", a) #print("Enter the string : ") s = input() #print("Enter index : ") n = int(input()) #count = 0 def findChar(s,e): c = 0 p =0 fo...
f64dc7059ceaad30539a8c93d4ed54e573e98d6a
suiup/pythonProject
/python_learning/装饰器/demo02.py
273
4.125
4
""" 一个没有装饰器的方式 将 function 当成参数传入另一个function """ def decorator(fn, name): print(name+"say I'm in") # 这是我的前处理 return fn(name) def outer_fn(name): print(name+"say I'm out") decorator(outer_fn, "mofanpy")
11532104c40d82302696e278cb3cac8f429a4b78
smwa/double_elimination
/double_elimination/participant.py
865
3.9375
4
""" The Participant class represents a participant in a specific match. It can be used as a placeholder until the participant is decided. """ class Participant: """ The Participant class represents a participant in a specific match. It can be used as a placeholder until the participant is decided. """ ...
12c7759dba81ce6faddf5c1a7fadc4ebc0835be7
uhvardhan/ML_Python
/Vectors-Matrices-Arrays/max_min.py
540
4.40625
4
# Load library import numpy as np # Create matrix matrix = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) # Return maximum element print("The maximum element in the array is: {}".format(np.max(matrix))) # Return the minimum element print("The minimum element in the array is: {}".format(np.min(matrix))) # Find maximum ...
9517a2cd95f99dfb4523ad79792f539c4bdb403c
zhiyiTec/machineLearn
/python/pythonProject/Demo15.py
785
3.796875
4
# A = {"python", 123, ("python", 123)} # print(A) # B = set("pypy123123") # print(B) # C = {"python", 123, "python", 123} # print(C) # A = {"p", "y", 123} # B = set("pypym123") # print("A-B:{}".format(A - B)) # print("B-A:{}".format(B - A)) # print("A&B:{}".format(A & B)) # print("A | B:{}".format(A | B)) # print("A ^...
21629315646742b0cbe75278e0477204d2d042b2
ruslan-baichurin/magic
/problems/calculating_pi.py
287
3.96875
4
def calculate_pi(n_terms: int) -> float: numerator, denominator, operation, pi = 4.0, 1.0, 1.0, 0.0 for _ in range(n_terms): pi += operation * (numerator / denominator) denominator += 2.0 operation *= -1.0 return pi print(calculate_pi(100000000))
4a85948723fa0bcc0ef41bc564a34028503678d5
sudhanthiran/Python_Practice
/Competitive Coding/Nearest multiple of 10.py
322
3.71875
4
def nearest(n: int): str_n = str(n) digit_2_add_or_sub = 0 last_digit = int(str_n[len(str_n)-1]) if(last_digit <=5): n = n - last_digit else: digit_2_add_or_sub = 10 - last_digit print(n+digit_2_add_or_sub) T = int(input()) for i in range(T): N = int(input()) nearest(N...
b6520a6269edfec658ad6652e1c712692eaf117d
javamaasai/python_crypto_test
/encrypt-one-two-way-test.py
1,647
4.0625
4
#!/usr/bin/env python3 from Crypto.Cipher import AES import uuid import hashlib import binascii import os # A function to hash password using sha256 salt def hash_it_with_salt(strg): # uuid is used to generate a random number salt = uuid.uuid4().hex return hashlib.sha256(salt.encode() + strg.encode()).he...
f1706c934b3a3ab7fbbf45ce705fa0438089ef08
seohae2/python_algorithm_day
/이것이코딩테스트다/chapter06_정렬/03_성적이낮은순서로_학생출력하기/seohae.py
492
3.625
4
n = int(input()) array = [] for i in range(n): input_data = input().split() # 이름은 문자열 # 점수는 정수형으로 변환하여 저장 # 리스트안에 튜플 형태로 저장 array.append((input_data[0], int(input_data[1]))) # 점수 오름차순 # 람다 사용 # 점수를 기준으로 정렬함을 명시 array = sorted(array, key=lambda student: student[1]) print(array) # 출력은 이름으로 for st...
5cef9d4fa53ebb00307edc2b5920aa70ea23e53d
PyroAVR/easygrade
/grade.py
866
3.515625
4
from gradeitem import gradeitem class grade: def __init__(self): self.max_score = 100 self.total_points = 0 self.score = 0 self.items = dict() def add_grade_item(self, item): self.items[item.name] = item self.total_points += item.total_p...
4aa270ca8fd3a034df0fa4256bc0578039453596
sammyrano/tech-project
/TASK 2.py
556
3.96875
4
def likes(array): if len(array)== 0 : print('no one like this item') elif len(array) == 1: print(array[0], 'likes this item') elif len(array) == 2: print(array[0], 'and', array[1], 'likes this item') elif len(array) == 3: print(array[0], ',', array[1...
e66c89bb1de64593bdb2bf8f73601b568ad67a1d
ashracc/TC4002_Development_Exercises
/lab3/lab3_16.py
1,119
3.625
4
""" Given the math.ceil function, - Define a set of unit test cases that exercise the function (Remember Right BICEP) """ import unittest import math class TestCeil(unittest.TestCase): def test_happy_paths(self): # Test ceil function when input >= 0 self.assertAlmostEqual(math.ceil(1), 1.0) ...
9d0e6ac91a7edd4f1ceefe7e3ab34c341fe834f2
xavieroldan/Phyton
/Proyecto1/fori.py
176
3.75
4
if __name__ == '__main__': # Usuario entra palabras hasta que la palabra sea salir word = "hola" for i in range(0,len(word)): print(len(word)+str(word))
1b699c33d603677377811a1fec21c46e9a9fcef4
ksparkje/leetcode-practice
/python/graph/q310_minimum_height_tree.py
3,124
4.09375
4
# 310. Minimum Height Trees # Nice problem! # Medium # # For an undirected graph with tree characteristics, we can choose any # node as the root. The result graph is then a rooted tree. Among all # possible rooted trees, those with minimum height are called minimum # height trees (MHTs). Given such a graph, write a fu...
0d30f622972f7d20db406f0ff6ea0d1f9f20c116
thiagoiferreira/treinamento-git
/code.py
207
3.796875
4
print ('Treino') a = range(1,21) b = range (2,12) print(a) b = range (21,121) print(a) a = range(1,21) b = range (21,121) print('Nova Alteracao') for i in a: print(str(i) + 'BOA NOITE AMIGOS')
22be0688880e92ac8a4b8196533be6fb6b2177f0
iRoy7/python_examples
/while_with_condition.py
684
3.796875
4
list_test = [1, 2, 1, 2] value = 2 while value in list_test: list_test.remove(value) print(list_test) import time number = 0 target_tick = time.time() + 5 while time.time() < target_tick: number += 1 print("5초 동안 {}번 반복했습니다.".format(number)) #break/continue i = 0 while True: ...
671bde6a5b6ba6e3e6dd70cf636b83161aa72447
bronydell/python-cipher
/vigenere.py
967
3.8125
4
from string import printable TABLE_WIDTH = len(printable) ASC_A = ord(printable[0]) # ThX Chines guy def init_table(): return [[chr((col + row) % TABLE_WIDTH + ASC_A) \ for col in range(TABLE_WIDTH)] \ for row in range(TABLE_WIDTH)] def encrypt(table, words, key): cipher = '' c...
efff4be6b8c21ae1cc6f997508e228d6612c29c8
cflin-cjcu/test-python
/6-f.py
121
3.765625
4
n=int(input()) a=1 # print(1,end=' ') b=1 # print(1,end=' ') i=3 while i <= n: a,b=b,a+b i += 1 print(b, end=' ')
97d289ea86a156567d5827bf7e42a42ba05355dd
jiangw41/LeetCode
/739.py
1,372
4.09375
4
''' 739. Daily Temperatures Medium Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put 0 instead. For example, given the list of temperatures T = [...
d1de22d6669152b83c2a37284461d43aa1b20d7d
chavarera/SentimentAnalyzerWithRealtimeVoice
/SentimentAnalyzerWithRealtimeVoice.py
1,623
3.609375
4
import speech_recognition as sr from textblob import TextBlob as blob import pyttsx3 ''' speech_recognition: For Realtime Speech Recognizer textblob : Sentimental analysis pyttsx3 : Text-to-speech conversion library if you got any error Please check Readme.md File To solve it. ''' __AUTHOR__='Ravishankar Chavare' _...
1477f881644208f1623068e0b584ecef97794173
Akshay-Chandelkar/PythonTraining2019
/Ex32_ValidTime.py
521
4.0625
4
def ValidTime(hh,mm,ss): if hh >= 0 and hh < 25: if mm >= 0 and mm < 60: if ss > 0 and ss < 60: print("The time {}:{}:{} is valid.".format(hh,mm,ss)) else: print("ss %d is invalid." %ss) else: print("mm %d is invalid." %mm...
be7a3a09dd9a229fc630c52a036ad3af4e2b813a
robsondrs/Exercicios_Python
/ex043.py
486
3.75
4
peso = float(input('Qual é seu peso? (Kg) ')) alt = float(input('Qual é sua altura? (m) ')) imc = peso / alt ** 2 print('O IMC dessa pessoa é de {:.1f}'.format(imc)) if imc < 18.5: print('Você esta ABAIXO DO PESO normal.') elif imc < 25: print('Parabéns, você esta na faixa de PESO NORMAL.') elif imc < 30: p...
fa7bdd13db37666ab4ab8a7f690f794837953cff
andylshort/dotfiles
/bin/filter-row
1,069
3.9375
4
#!/usr/bin/python3 import argparse import csv import fileinput def create_parser(): parser = argparse.ArgumentParser(description="Filters rows from csv") parser.add_argument("-f", "--file", type=str, help="Path to csv file to filter") parser.add_argument("-i", "--indices", metavar="I", type=int, nargs="+",...
c1c3a272670b97f5d81676e7d4f143816b224a4e
shekhar-hippargi/test
/recommendation_system/surprise_library_exploration/ContentBased/scripts/preprocessing.py
2,193
3.921875
4
# Data frame manipulation library import pandas as pd # Math functions, we'll only need the sqrt function so let's import only that from math import sqrt import numpy as np import matplotlib.pyplot as plt # Loading datasets # Storing the movie information into a pandas dataframe movies_df = pd.read_csv('../data/movie...
5a669b1d387f4836a989e06596a787526483d69c
TorpidCoder/Python
/HeadFirst_DocQuestions/B16.py
125
4.0625
4
letter = input("Please enter a letter : ") if(letter.islower()): print(letter.upper()) else: print(letter.lower())
a0d50b703df2c6905bccd4271d862c2d56393894
PetitPandaRoux/python_katas
/next_palindrome/next_palindrome.py
159
3.9375
4
def is_palindrome(number): number_string = str(abs(number)) if number_string[::-1] == number_string: return True else: return False
c6d9476190e9973650eeb26f3ac052201de2faad
PrivateGoose/LaboratorioRepeticionRemoto
/mayor.py.py
308
3.875
4
n=int(input("De 10 números cuantos son positivos, negativos y cero")) pos=0 neg=0 cero=0 conta=0 if n>0: pos=pos+1 if n<0: neg=neg+1 if n=0: cero=cero+1 while (conta <=10) #Comment 1 print("Hay {} números positivos, hay {} números negativos y hay {} ceros".format(pos,neg,cero))
42d857c67a0b51fbc657c1efe2f87282e7555560
taeheechoi/coding-practice
/F_next-greater-element-i.py
1,569
3.921875
4
# https://leetcode.com/problems/next-greater-element-i/ # Example 1: # Input: nums1 = [4,1,2], nums2 = [1,3,4,2] # Output: [-1,3,-1] # Explanation: The next greater element for each value of nums1 is as follows: # - 4 is underlined in nums2 = [1,3,4,2]. There is no next greater element, so the answer is -1. # - 1 is u...
e635cec1dd0b5d9d02443bbe208fc295bef04d63
Shorokhov-A/repo-algorithms_python
/lesson_3/task_3_2.py
203
3.828125
4
numbers = (8, 3, 15, 6, 4, 2) even_numbers_indices = [] for idx in range(len(numbers)): if numbers[idx] % 2 == 0: even_numbers_indices.append(idx) print(numbers) print(even_numbers_indices)
0f37d14b91effcf6a79f9cf0f27c2d42e7ed1d4e
Bzan96/FreeCodeCamp_Projects
/Scientific_Computing_with_Python/polygon_area_calculator/shape_calculator.py
2,035
3.734375
4
import math def handle_undefined_values(height, width): if height == None and width == None: raise Exception("None", "height and width are not set.") elif height == None: raise Exception("None", "height is not set.") elif width == None: raise Exception("None", "width is not set.") class Rectan...
0d359a3c30b12076205a4b030b7723ecf65b7ba0
asiguqaCPT/Hangman_1
/hangman.py
1,137
4.1875
4
#TIP: use random.randint to get a random word from the list import random def read_file(file_name): """ TODO: Step 1 - open file and read lines as words """ words = open(file_name,'r') lines = words.readlines() return lines def select_random_word(words): """ TODO: Step 2 - select rand...
019af9dd2bdc9511e090453e21604e88386768e9
luketibbott/Predicting-Shelter-Animal-Outcomes
/breeds.py
745
3.578125
4
# Parses a wikipedia page listing dog breeds recognized by the American Kennel Club and the # group of dog each breed belongs to. import wikipedia dog_breeds = wikipedia.page('List of dog breeds recognized by the American Kennel Club') counter = 0 dog_groups = dict() for line in dog_breeds.content.split('\n')[1:]:...
9eca73ddd171a14fd45fbd6986dc7faeb2d8525d
bigtree1952/zb
/caoke.py
1,322
3.703125
4
#!/usr/bin/env python # coding=utf-8 import sys import os #运行方式安装好python #D:\>python caoke.py a1.txt 即可以生成如下 #转换成功!文件为: coverted_a1.txt def convert(source_file): dest_file = 'coverted_' + os.path.basename(source_file) ret = {} with open(source_file,'r',encoding='UTF-8') as f: for line_no, line in enume...
2887d886574a5be45d2ed29e0a12817b02bdf277
PawarKishori/Alignment1
/Transliteration/Transliterate_Dict.py
3,272
3.546875
4
#This program creates a transliteration dictionary for entire corpus once. #This program calls Roja mam's program which runs in python2 #import check_transliteration.py as ct ##Pending task to do, once roja mam completes this will be complete def remove_punct_from_word(word): word=word....
26b757c234e5903d175d099a005b338b0a9a390d
Su-Shee/open-data-weather
/pandas-weather.py
1,196
3.703125
4
#!/usr/bin/env python import sys from datetime import datetime, date, time import pandas from pandas import Series, DataFrame, Panel import matplotlib.pyplot as plt import matplotlib as matplot matplot.rc('figure', figsize=(12, 8)) data = pandas.read_csv('tageswerte-1948-2012.csv', parse_dat...
77d0b4efc172374d6e00e841e03279c27964635e
zilunzhang/puzzles
/puzzles-BFS-DFS/mn_puzzle.py
7,476
3.53125
4
from puzzle import Puzzle class MNPuzzle(Puzzle): """ An nxm puzzle, like the 15-puzzle, which may be solved, unsolved, or even unsolvable. """ def __init__(self, from_grid, to_grid): """ MNPuzzle in state from_grid, working towards state to_grid @param MNPuzzle s...
d266388b5c4382d697f0717915d8fd8cd1a457cc
oneshan/Leetcode
/accepted/097.interleaving-string.py
1,570
3.734375
4
# # [97] Interleaving String # # https://leetcode.com/problems/interleaving-string # # Hard (24.41%) # Total Accepted: # Total Submissions: # Testcase Example: '""\n""\n""' # # # Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and # s2. # # # # For example, # Given: # s1 = ...
26ec638ed1cd5c3cc65dd69956407d9653219468
gabriellaec/desoft-analise-exercicios
/backup/user_139/ch22_2020_03_04_11_28_13_775698.py
102
3.671875
4
a = int(input('Quantos cigaros por dia?') b = int(input('Há quantos anos?') p = (a * 10) * b print(p)
9ff556f4126ee4fa9a8db224cadd0684a4458bbc
Serg-Protsenko/NIX_Education_Python
/BEGINNER_Python_Level_1/Task_09_two_list/Task_09.py
592
4.5
4
# Создать функцию, которая принимает на вход два списка: первый — список, который нужно # очистить от определённых значений, второй — список тех значений, от которых нужно очистить. # Например, list1 = [1, 2, 3, 4, 5], list2 = [1, 3, 4], функция должна вернуть [2, 5] def two_list(list_1, list_2): return list(set(l...
c5e03974ee795edd8a89e232bb1024d4a0a7b7d5
smartinsert/CodingProblem
/product_subarrays/maximum_product_subarray.py
1,350
4.375
4
""" Given an integer array nums, find a contiguous non-empty subarray within the array that has the largest product, and return the product. The test cases are generated so that the answer will fit in a 32-bit integer. A subarray is a contiguous subsequence of the array. Example 1: Input: nums = [2,3,-2,4] Output...
afe9df8c2d8bc493de4d813e4f4f61a33ef5220a
Aliexer/calcular_area_fg_geometrica.py
/area_geometricas.py
1,902
4.0625
4
#CALCULO DE FIGURAS GEOMETRICAS #esta funcion dibuja un triangulo def triangulito(l): for i in range(0,l,1): for j in range(0, i+1, 1): print("*", end="") print("") #esta funcion dibuja un cuadrado def cuadrito(m,n): for i in range(1, m+1): for j in range(1,n+1): print("*", end="") print(" ") #el ci...
63548e60872ab436938c60a8b79d9d443268abe1
Uttam1982/PythonTutorial
/10-Python-Exceptions/05-Catching-Specific-Exceptions-in-Python.py
833
4.34375
4
#------------------------------------------------------------------------------------------ # Catching Specific Exceptions in Python #------------------------------------------------------------------------------------------ # A try clause can have any number of except clauses to handle different exceptions, # however...
ee91560206660719417f4ffedc75772a436845cb
LokeshKD/MachineLearning
/ML4SE/Pandas/dataframe.py
1,388
3.546875
4
import pandas as pd ## 2-D data df = pd.DataFrame() # Newline added to separate DataFrames print('{}\n'.format(df)) df = pd.DataFrame([5, 6]) print('{}\n'.format(df)) df = pd.DataFrame([[5,6]]) print('{}\n'.format(df)) df = pd.DataFrame([[5, 6], [1, 3]], index=['r1', 'r2'], colu...
89393cbeeaeb1c65f8988ffe6930667660fe1dcd
NeelJVerma/Daily_Coding_Problem
/Construct_Sentence/main.py
1,325
4.0625
4
""" Given a dictionary of words and a string made up of those words (no spaces), return the original sentence in a list. If there is more than one possible reconstruction, return any of them. If there is no possible reconstruction, then return null. For example, given the set of words 'quick', 'brown', 'the', 'fox', a...
57fa5c44139713a0533b98670f74454ab346d500
Henrique970/Monitoria
/21.py
988
3.703125
4
import random nome = input('Informe o seu nome: ') qt = int(input('Informe a quantidade de partidas que você que jogar: ')) quantidade_jogador = 0 quantidade_computador = 0 for n in range(1, qt + 1): escolha = input('Escolha se quer par ou impa[p/i]: ') numero = int(input('Informe o número: ')) computador =...
3b8ea81eff17df67e7c58d47dd6d757545eb64b8
Python-x/Python-x
/寒假作业/6/喜欢的数字2.py
193
3.515625
4
favorite_number = {"小红":["1","2","3"],"小刚":["4","5","6"],"小李":["7","8","9"]} for k,v in favorite_number.items(): print("%s最喜欢的数字有:"%k) for i in v: print("%s\t"%i)
d524c3c39c789873a559b7972537cb99f87c1958
alexforcode/py_arcadegames_craven
/ch18/18.5.py
242
3.515625
4
def getInput(): userInput = input("Введите что-нибудь: ") if len(userInput) == 0: raise IOError("Пользователь ничего не ввёл") try: getInput() except IOError as e: print(e)
94d5d5a14eec346776108c5cdb4792d75c068977
hputterm/Projects
/HMM/HMM.py
21,894
4.21875
4
import random import numpy as np class HiddenMarkovModel: ''' Class implementation of Hidden Markov Models. ''' def __init__(self, A, O): ''' Initializes an HMM. Assumes the following: - States and observations are integers starting from 0. - There i...
bf936dcfec2f928298f331ccd42eb959585a2522
roshanpiu/PythonOOP
/05_Instance_Attributes.py
341
3.859375
4
'''instance attributes''' #attributes in a class is holds the state of the instance import random class MyClass(object): '''My Class''' def __init__(self): self.rand_val = 0 def dothis(self): '''dothis''' self.rand_val = random.randint(1, 10) MYINST = MyClass() MYINST.dothis() p...
09bc7a629ff1e70a1f6f1d00f3f03e1a1c9bedd6
ThomasMGilman/ETGG1801_GameProgrammingFoundations
/Notes/Bullet example.py
1,723
3.59375
4
#bullets example: dynamic game object creation import pscreen import random import time def distance(x1,y1,x2,y2): return ((x2-x1)**2 + (y2-y1)**2)**0.5 #initialize pscreen pscreen.loadScreen() pscreen.fontSelect() #initialize game variables bullet_list=[] bullet_recharge_time=0 #start the game loop while True:...
59e254743dc69e165168b38519df681600bb9b07
TheXGood/AIDS
/Python/Game/3x3_Matrix.py
1,469
3.625
4
import math blank = 1; Matrix = [[0 for x in range(3)] for y in range(3)]; def istaken(pos): if Matrix[int(pos % 3)][int((pos/3))] == 0: return 0; return 1; def playerone(): xy = max(min(int(input()),8),0); #x = input(); #y = input(); if istaken(xy): xy = max(...
b0ae2c9d32772fc77c405d2fadae11e6b98d9d96
bobvo23/PointCloudUDA
/src/utils/timer.py
2,324
3.640625
4
from datetime import datetime def timeit(func): def timefunc(*args, **kwargs): start = datetime.now() result = func(*args, **kwargs) end = datetime.now() print("{} time elapsed (hh:mm:ss.ms) {}".format(func.__name__, end - start)) return result return timefunc @timeit ...
4b3d6d14dce031f13b13c27d553f114922104571
jmg5219/First-Excercises-in-Python-
/for_loops.py
151
4.125
4
num_list = [1,2,3,4,5,6,7,8,9,10]# input list for i in num_list:#iterating through the list with a for loop print(num_list[i])#printing the list
a16f471560c2e8c7e747ba5830667bbbfaff60a5
mayelespino/code
/LEARN/python/using-yield/yield-examples.py
396
3.734375
4
#!/usr/local/bin/python3 def yieldFibbunacci(number): """ generate a fibunnaci series :param number: :return: """ fibb, prev = 0,1 for x in xrange(number): fibb, prev = fibb+prev, fibb if x > 0: yield fibb # # # def main(): print("Main") for fibb in yield...
84da9e6abc1e8ea632490f6247aeaa664d38bdda
BeccaFlake/Python
/contacts_RCF.py
3,583
4.375
4
#!/usr/bin/env python3 #import the csv library and define the file to be used import csv FILENAME = "contacts.csv" #function that writes to the file def write_contacts(contacts): with open (FILENAME, "w", newline="") as file: writer = csv.writer(file) writer.writerows(contacts) #func...
2d88332ac88bbbc60eb11cf578312055f106f2ba
mrtsif/Py1
/2/Lesson 2 task 3.py
223
4.15625
4
number = int(input('Enter number of month')) if 0 < number <= 12: result = number // 3 month = {1: 'spring', 2: 'summer', 3: 'autumn', 4: 'winter', 0: 'winter'} print(month.get(result)) else: print('Error')
363054b2eb818c1f4c8dbda1899d14988ace5e1e
turo62/exercise
/exercise/codewar/removesmallest.py
289
3.546875
4
def remove_smallest(numbers): list = numbers if list == [] or len(list) == 1: list = [] else: b = list.index(min(list)) del list[b] return list def main(): list = remove_smallest([158]) print(list) if __name__ == "__main__": main()
e9237459e13c27c6b04fe2356a329d7820d52279
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_136/2712.py
1,026
3.578125
4
#!/usr/bin/env python3 # Cookie clicker # Start with 0 cookies # 2 cookies/sec by clicking on a giant cookie # Having C cookies, you buy a cookie farm # A cookie farm costs C cookies and gives +F cookies/sec # You with with X cookies not spent on farms # How long it will take you to win using the best possible strat...
0e5e9debbcce33e723667dcd5d1d39cc66df54f6
andresflorezp/UVA_PYTHON
/12250.py
850
3.546875
4
import sys def sol(): val="0" count=1 while val!= "#": val=sys.stdin.readline().strip() if val=="HELLO": print("Case {}: ENGLISH".format(count)) if val=="HOLA": print("Case {}: SPANISH".format(count)) if val=="HALLO": print("Case...
2d39b1d00bd676faadfbc20f52d4f141862727ce
woodie/coding_challenges
/max_in_sorted_array.py
428
3.90625
4
#!/usr/bin/env python import collections d = collections.deque(range(1,18)) d.rotate(-3) data = list(d) def find_max(a): if a[0] <= a[-1]: return a[-1] pivot = len(a) / 2 if a[pivot] > a[-1]: return find_max(a[pivot:]) else: return find_max(a[:pivot]) print "input: %s" % ','.join(str(x) for x in...