blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
8c7829300505a62d441d882dbeb92bb0353087a9 | thomman/hackerrank | /bonAppetit.py | 243 | 3.515625 | 4 | n, k = (int(i) for i in input().split())
food = [int(i) for i in input().split()]
price = int(input())
def op(n , k, food, price):
anna = sum(food[i] for i in range(n) if i != k)//2
return 'Bon Appetit' if anna == price else (price - anna)
|
55cfc5125b3606b2483d165d950fcc87da67655b | Rishav78/Python | /enum.py | 151 | 3.65625 | 4 | def index(l,s):
for x,y in enumerate(l):
if y==s:
return x
return -1
l = list([1,2,3,4,5,6])
print(l,4)
print(index(l,4))
|
70680ae6af18a5d6b809dd0c56800e582bb5b18e | kellyeschumann/comp110-21ss1-workspace | /exercises/ex01/numeric_operators.py | 888 | 3.953125 | 4 | """This takes two numbers input from user and completes four mathematical equations."""
__author__: str = "730314660"
left = "Left-hand side"
right = "Right-hand side"
numberOne: str = input("What is the first number? ")
print("You entered: ")
print(numberOne)
numberTwo: str = input("What is the second number? ")
... |
1256563bed6ccbc2749c3efb303eb609c242f41a | MaximilianoCaba/UADE-Programacion-Python | /programacion1/Clase4.py | 801 | 3.546875 | 4 | import random
def buildMatriz(list, rows, colums):
for i in range(rows):
list.append([0] * colums)
def generateRandomNumber():
number = random.randint(0, 999)
return number * number
def chargeMatriz(list):
list_number_uniq = []
for (i, value) in enumerate(list):
for (j, value2... |
1af49ad65404348a3647a298416514ca41dec73d | JanikRitz/Python_Euler_Challenges | /Euler_010_other.py | 755 | 3.78125 | 4 | '''
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
'''
import datetime
# Actual code
# primes = deque([2, 3, 5, 7, 11, 13])
sieve = set()
print("Sum of primes less than...?")
i = int(input())
start_time = datetime.datetime.now()
psum = (i * (i + 1)) / 2
... |
c90205c84bda64806a0b5ff323ed601b0ff2dac1 | easycodescreator/rock-paper-scissors | /Rock-Paper-Scissors.py | 1,106 | 4.21875 | 4 | # The apps first takes your choice.
p1 = input("Enter : ")
p2 = input("Enter : ")
a = "paper"
b = "rock"
c = "scissors"
# check that p1 is equal p2.
while p1 == p2:
p1 = input("Enter again: ")
p2 = input("Enter again: ")
# if p1 and p2 not equal start loop.
while p1 != p2:
if p1 != p2:
... |
e12e517d4ba3a6f505389728f3d9ec3279977685 | Sway007/regex-python-test | /comma.py | 132 | 3.765625 | 4 | import re
txt = input('give me an integer: ')
pattern = r'(?<=\d)(?=(\d{3})+(?!\d))'
p = re.compile(pattern)
print(p.sub(',', txt)) |
583d7c4fe0c32ae782e51288e8e7e2d987225a33 | hemangbehl/Data-Structures-Algorithms_practice | /session4/checkIfWordCanBeMadePalindrombyRearrangement.py | 569 | 3.75 | 4 | def checkPalin(s1):
if len(s1) <= 1: return True
dict1 = {}
odd = 0
for ch in s1:
if ch in dict1:
dict1[ch] += 1
if dict1[ch] % 2 == 0:
odd -= 1
else: #odd freq
odd += 1
else: #not in dict
dict1[ch] = 1
... |
0684d002da984962aae14acd8179eddf04a320a2 | trungtruc123/NLP | /bai3_1_convertEncoding.py | 89 | 3.515625 | 4 | import pandas as pd
text =" T Tan Trung Truc"
print(pd.get_dummies(text.split()))
|
0dd397c9b432e46c645a734617d7b9dde8e35dbb | joestalker1/leetcode | /src/main/scala/SingleElementInSortedArray.py | 763 | 3.609375 | 4 | class Solution:
def singleNonDuplicate(self, nums):
lo = 0
hi = len(nums) - 1
#array shouldn't be sorted but should being pairing
while lo < hi: # strict inequality
m = lo + (hi-lo) // 2
halves_is_even = (hi - m) % 2 == 0
if nums[m] == nums[m+1]:
... |
8b7d2dd6d7aac713356a2591510a9cd12f7ec11c | jianjhihlai/FaceApp | /examples/02.schedulecheck.py | 279 | 3.640625 | 4 | todoList = ["掃地", "拖地", "煮飯"]
notyet = []
for idx, task in enumerate(todoList):
answer = input("您的第{}件事是{},您完成了嗎?Ans:".format(idx+1, task))
if answer != "done":
notyet.append(task)
print("您還剩下以下工作:")
print(notyet) |
e1640eeaf7d36d5d0aa90aa38031efde06835775 | anjihye-4301/python | /ch05if/ch05_03findNum.py | 597 | 3.890625 | 4 | import random
# 랜덤으로 발생된 숫자 10개를 저장하는 리스트
numbers = []
# range(시작번호, 끝번호+1)
for num in range(0, 10):
print(num)
# random.randrage(발생시작 숫자, 발생 끝 숫자+1)
numbers.append(random.randrange(0, 10))
print("생성된 리트스 : ", numbers)
# 0 ~ 9 사이의 각각의 데이터가 있는지 확인해보자
for num in range(0, 10):
if num in numbers:
... |
6197ddb4085c38669106b2b59a5d67dee4fa61c9 | HenryBalthier/Python-Learning | /Leetcode_easy/hash/204.py | 438 | 3.640625 | 4 | class Solution(object):
def countPrimes(self, n):
"""
:type n: int
:rtype: int
"""
if n < 3:
return 0
res = [1] * n
res[0] = res[1] = 0
for i in range(int(n ** 0.5)+1):
if res[i]:
res[i*i:n:i] = [0] * len(res[i*i... |
9020e978d036d06604c0aaaa9645b516c289d378 | Disha-Shivale/Pythonset | /list2.py | 430 | 3.859375 | 4 | #Fetch value with Loop
a = ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6']
for i in a:
print(i)
#Check value in list with loop
a = ['Item 1', 'Felix', 'Item 3', 'Item 4', 'Item 5', 'Item 6']
print()
if 'Felix' in a:
print("Felix ITs System")
print()
else:
print("Value is not available")
... |
078c560e437cb88872b480ebf6378406a4ad6c9e | hollisas/CSCI220 | /triangle.py | 831 | 4.09375 | 4 | # triangle.py
# Author: Zelle (pp. 103-04)
# Modified by Pharr to eliminate coordinates
from graphics import *
def main():
winWidth = 400
winHeight = 400
win = GraphWin("Draw a Triangle", winWidth, winHeight)
message = Text(Point(winWidth/2, winHeight-10), "Click on three points")
... |
c86e75445908fd2c839b3542531f48d8811da9f8 | domspad/text_viz_project | /texttools.py | 2,989 | 3.6875 | 4 | """
Tools and utility functions for working with text
"""
from __future__ import print_function, division
import nltk
from nltk import word_tokenize #, pos_tag
import nltk.data
import string
from syllablecount import sylco, sylco_com
from time import time
import numpy as np
SENTENCIZER = nltk.data.load('tokenizers/pu... |
71cd767a7861ad91cc2d14d03a7af373a3c8a1c4 | jgslunde/INF3331 | /regex/regex_guide.py | 835 | 3.796875 | 4 | import re
s = "asdf ASDF AsDf asdfbat ASDFbat A$DFbat asdfbatasdfbat Adfbat bat asdf"
regex = r"asdf" # Use the r (raw) in fron of the string to tell python the string
# should be interpreted as "raw" and string-commands like \n, \b, etc won't be executedself
### Finding stuff ###
matches = re.findall(regex, s) # R... |
7e64c2dba14b83115c8c2a118e0852401fb0aae5 | pvanh80/intro-to-programming | /round10/cellphone_test.py | 343 | 4.03125 | 4 | # Intro to programming
# Classes and Objects
# Phan Viet Anh
# 256296
import cellphone
def main():
man = input('What is your phone\'s manufacture? ')
mod = input('What is your phone\'s model? ')
price = float(input('What is your phone\'s price? '))
cellphone = cellphone.CellPhone(man, mod, price)
... |
802dfb90515869606ba380d016b40fd9fe761ded | axellbrendow/python3-basic-to-advanced | /aula057-getters-e-setters/aula57.py | 1,300 | 3.6875 | 4 |
class Produto:
def __init__(self, nome, preco):
self.nome = nome
self.preco = preco
def desconto(self, percentual):
self.preco -= self.preco * (percentual / 100)
# Getter
@property
def nome(self):
return self._nome # O nome com underline é apenas uma convenção. Po... |
fcaf61455c0c172d091f61fb79654d2915caa4a5 | awoka333/python_practice | /python crash course 01-10/hisshuhen-sample/chapter07/rollercoaster.py | 196 | 3.84375 | 4 | height = input("身長は何センチ? ")
height = int(height)
if height >= 90:
print("\n乗ってもいいですよ!")
else:
print("\nもうちょっと大きくなったらね。")
|
d719024ff107fe1c4b093f8d402d35c1a34340d4 | po7a7o/Python1 | /Microeconomia/test.py | 887 | 3.5625 | 4 | from sympy import *
from matplotlib import pyplot
import sympy as sy
import numpy as np
import matplotlib as plt
#Función Lineal.
def Qd(x):
return asa
print ("aa: ", Qd(x))
# return 5-0.1*x
#En esta variable se genera una lista con valores del -10 al 10.
#Todos estos valores serán los que tomara x.
x = ran... |
0bda26beb41e65a5623e575d3ac3348625d75a4f | jiarmy1125/Kata | /Pair_of_gloves.py | 1,455 | 3.796875 | 4 | # my_gloves = ["red","green","red","blue","blue"]
# number_of_pairs(my_gloves) == 2;// red and blue
# red_gloves = ["red","red","red","red","red","red"];
# number_of_pairs(red_gloves) == 3; // 3 red pairs
# number_of_pairs(["red","red"]),1
# number_of_pairs(["red","green","blue"]),0
# number_of_pairs(["gray","black",... |
8f6a97395c9b71a6709b88137cbd4092deb72f8e | hariomhardy/Data-Structures-and-Algorithms | /DS/tree_try_first.py | 838 | 3.671875 | 4 | import random
class Tree:
def __init__(self,value):
self.value = value
self.left = None
self.right = None
def add(self,value):
h = Tree(value)
if value > self.value:
if self.right != None:
self.right.add(value)
... |
9c10fac41f793ddcf1d8d88472c46d976f0caa38 | topanitanw/Python_Library | /file.py | 524 | 3.828125 | 4 | import os
def abspath(relative_path, filename):
'''
Return a absolute path of a file in String.
'''
# os.sep = directory separator
relative_filepath = relative_path + os.sep + filename
return os.path.abspath(relative_path)
def listfile(dirpath):
'''
Return a list of files in a direct... |
9e6611d4f69b2ffb5eb3b7ad2c39138812eac4a1 | rbhim/Python-Tools | /SQLite v1.py | 962 | 4.09375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Nov 09 21:44:54 2014
@author: RBhim
"""
import sqlite3
conn = sqlite3.connect("traffic1.sqlite") #connect or create traffic db
curs = conn.cursor()
curs.execute("""DROP TABLE IF EXISTS traffic""")#drop table if it exist
#Create Table traffic with three columns Speed:Flow:L... |
13943c7e5849681461eb92dc38838c7cd8aa998c | hutanugeorge/Data-Structures-Python | /DoublyLinkedList.py | 3,028 | 4.0625 | 4 | class DoublyLinkedList:
class node:
def __init__(self, value = None):
self.value = value
self.next = None
self.prev = None
def __init__(self):
self.head = None
self.tail = self.head
self.lenght = 0
def append(self, value):
new_n... |
e5de1e99a8791c37e017abaa75e8556a93278242 | hunar21/Stock-market-vs-Covid-19 | /COVID-19 VS STOCK MARKET .py | 13,952 | 3.65625 | 4 | #!/usr/bin/env python
# coding: utf-8
# # How did COVID in India impact stock market
# Let us analyse the impact of covid cases and vaccination, either increase or decrease, on stock market. Although it is common sense to conclude that increase in covid cases results in lockdowns and the economy is stopped, the produc... |
e00801a735a5d5223ade8b90e2a47131b4fdf7a6 | zhanghuaisheng/mylearn | /Python基础/day010/02 昨日回顾.py | 1,038 | 3.5 | 4 | # 1.函数的初始
# 函数的作用,封装代码,大量减少重复代码,提重用性
# 函数的定义:
# def 函数名():
#函数体
# 函数名:遵循变量命名规则
# 函数调用 func()
# 作用:调用函数+接收返回值
# return
# 将返回值返回给函数调用者
# 函数执行完后自动销毁函数体中开辟的空间
# 终止当前函数,return下方代码不执行
# 不写return默认返回None,写return不写返回值也是None
# 可以返回任意、多个数据类型(以元组的形式存储)
# 可以写多个return ,只执行一个
# 函数体中存放的是代码,只有函数被调用时,函数体中的代码才会被执行
# 函数的参数
# 形参:函... |
a21d794823409b59053330696bf8bbde696eb947 | Aqoolare/Python | /lesson9/test_rectangle.py | 1,473 | 3.609375 | 4 | import sys
sys.path.append('../Lessons/lesson8')
import task2
class TestRectangle:
def test_rectangle_area(self):
r = task2.Rectangle(2, 3)
assert r.area() == 6
def test_rectangle_print_with_negative_parameters(self):
assert str(task2.Rectangle(-2, -3)) == 'Прямоугольник: (2, 3)'
... |
38cdcac8fc8f8062630c62fa954a27d6d90eba8d | KosmX/quiz-to-moodle.xml | /quester.py | 5,364 | 3.5 | 4 |
def formatQuestion(quest, answers, answer): #quest:description of the question, answers: string containing answers, answer:string containing the answer letter e.g. "D"
return '''
<question type="multichoice">
<name>
<text>{}</text>
</name>
<questiontext format="html">
<text><![C... |
6f6f0acb87547dff21e7f45cb2e2ddded9892585 | khw5123/Algorithm | /SWExpert/2058. 자릿수 더하기.py | 66 | 3.5 | 4 | answer = 0
for n in input():
answer += int(n)
print(answer) |
6f231efd3f92e97497d47d7e70a5a2f3ee65622d | Jackson201325/Python | /Python Crash Course/Chapter 8 Functions/8-9 Magicians.py | 295 | 3.921875 | 4 | def show_magician():
magician_list = []
while True:
magician = input("Name of the magician: ")
if magician == 'q':
break
else:
magician_list.append(magician)
for magicians in magician_list:
print(magicians)
show_magician()
|
44656d1cd01720b7cd60be69c9e7573e65262fdf | vivangkumar/project-euler | /problem4.py | 561 | 4.3125 | 4 | __author__ = 'vivan'
'''
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 * 99.
Find the largest palindrome made from the product of two 3-digit numbers.
'''
def largest_palindrome():
palindrome = []
for x in range(100, 999):
... |
10f5e521f7422b87628153e887c1595f76f0e438 | BermondSmoothStack/python-exercise | /daytwo/main.py | 2,020 | 3.515625 | 4 | import string
def trim_hello_world():
return "Hello World"[8]
def slice_string():
return "thinker"[2:5]
def sammy():
return "Sammy"[2:]
def to_set():
return set("Mississippi")
def palindrome(inputs):
response = list()
for str_input in inputs:
str_input = ''.join(c for c in str_... |
0cc813ed5b7991c3079b41ad302914956201a832 | megalphian/Uncertainity-Based-POMDP-Planner | /Simulator/pomdp_control.py | 13,784 | 3.625 | 4 | import numpy as np
class BeliefDynamicsData:
"""
Data class to store the Belief Dynamics Data linearized about the optimal trajectory
"""
def __init__(self):
self.F = list()
self.Fi_1 = list()
self.Fi_2 = list()
self.G = list()
self.Gi_1 = list()
self... |
e119214e28f7bcbb0d98506c99c76340c88ac6ef | HuangJing0/Data-Structure-and-Algorithm | /SelectionSort.py | 234 | 3.6875 | 4 | #!/usr/bin/env python3
-*- coding: UTF-8 -*-
class SelectionSort:
def selectionSort(self, A, n):
for i in range(0, n-1):
for j in range(i+1, n):
if A[j] < A[i]:
temp = A[j]
A[j] = A[i]
A[i] = temp
return A
|
fe4ed3d9ef4322d87d150b9d9228ac329b4a3b67 | 1642195610/backup_data | /old-zgd/汉明重量(位1的个数).py | 978 | 3.8125 | 4 | # 191.位1的个数
# 编写一个函数,输入是一个无符号整数,返回其二进制表达式中数字位数为 ‘1’ 的个数(也被称为汉明重量)。
#
#
#
# 示例1:
#
# 输入:00000000000000000000000000001011
# 输出:3
# 解释:输入的二进制串
# 00000000000000000000000000001011中,共有三位为'1'。
# 示例2:
#
# 输入:00000000000000000000000010000000
# 输出:1
# 解释:输入的二进制串
# 00000000000000000000000010000000中,共有一位为'1'。
# 示例3:
#
# 输入:1111111... |
5968c8db1baeafc133a5f7751a7e72c69c612bc0 | Jatinmotwani-195/pyprograms | /array reverse.py | 92 | 3.859375 | 4 | from array import *
arr=array("i",[10,11,12,13,14])
arr.reverse()
for a in arr:
print(a) |
5fddd6fbef902ee95c0a59e086706c5f4d05f8e0 | ChangxingJiang/LeetCode | /LCCI_程序员面试金典/面试17.12/面试17.12_Python_1.py | 805 | 3.53125 | 4 | from LeetTool import TreeNode
from LeetTool import build_TreeNode
class Solution:
def convertBiNode(self, root: TreeNode, bigger=None) -> TreeNode:
if root:
# 处理当前节点
left, right = root.left, root.right
root.left = None
# 处理当前节点的右侧节点
if right:
... |
3929fbee9038fbb0764eb05b93a8e64e1f94d42a | vaishnavi2810-code/Regex | /regex_methods.py | 180 | 3.53125 | 4 | import re
pattern=r"pam"
match=re.search(pattern,"eggsspamsausagespam")
if match:
print(match.group())
print(match.start())
print(match.end())
print(match.span())
|
ee666cc786dfbcfc7136ad37110232a191ab0517 | monty0157/Bank-Customer-ANN | /ann.py | 771 | 3.75 | 4 | import numpy as np
import keras
#IMPORT PREPROCESSED DATA
from data_processing import data_preprocessing
X_train, X_test, X, y, y_train, y_test = data_preprocessing()
#BUILDING ANN MODEL
from keras.models import Sequential
from keras.layers import Dense
model = Sequential()
#TWO HIDDEN LAYERS AND OUTPUT LAYER
mode... |
e78adda6d134be97ccee9774721efb6e7d9e5948 | flamesapphire/python-programming | /lists.py | 203 | 3.875 | 4 | #lists
players=[1,2,2,4,5,6]
players.append(10)
players[1:-3]=[10,10]
y = players
print y
if players[1]is players[2]:
print("yes")
elif players[3]is players[4]:
print ("no")
else :
print ("!")
|
ce520b2f6df69f9b741ea4d20283212d7e2e733a | Silocean/Codewars | /7ku_length_of_the_line_segment.py | 566 | 4.25 | 4 | '''
Description:
Find the length between 2 co-ordinates. The co-ordinates are made of integers between -20 and 20 and will be given in the form of a 2D array:
(0,0) and (5,-7) would be [ [ 0 , 0 ] , [ 5, -7 ] ]
The function must return the answer rounded to 2 decimal places in the form of a string.
length_of_line([... |
f5e9debd1ca21762a8784685a3a270ae411ce317 | syedrafayhashmi/Web-Mobile-App-Development | /SMIT/Firebase DB/Firebase/public/file.py | 113 | 3.671875 | 4 | # a=10
# def foo():
# a=a+10
# foo()
# print(a)
# x = {10:'aa',11:'bb',12:'cc'}
# for i in x:
# print(i) |
4f1493348b9e7fb79cac6daded121cdbba1c78a5 | limetree-indigo/allForAlgolithmWithPython | /Part2 재귀 호출/05 최대공약수 구하기/p05-2-gcd.py | 743 | 3.984375 | 4 | # 최대공약수 구하기
# 입력: a, b
# 출력: a와 b의 최대공약수
"""
-유클리드 알고리즘
-수학자 유클리드가 발견한 초대공약수의 성질
1. a와 b의 최대굥약수는 'b'와 'a를 나눈 나머지'의 최대공약수와 같다. 즉, gcd(a, b) = gcd(b, a%b)
2. 어떤 수와 0의 최대 공약수는 자기 자신이다. 즉, gcd(n, 0) = n
예를 들면
gcd(60, 24) = gcd(24, 60%24) = gcd(24, 12) = gcd(12, 24%12) = gcd(12, 0) = 12
gcd(81, 27) = gcd(27, 81%27) = gcd(2... |
1e7f8c287b2414f6d4cd8cdb93e096d67d1bae84 | wangquan-062/wq | /pythontest/day03-01.py | 413 | 3.640625 | 4 | #if/else
#a = 16
# a = input("请输入一个年龄:")
# a = int(a)
# if a > 17:
# print("成年人") # 缩进
# else:
# print("未成年人") # 缩进
hege = []
buhege = []
grade = {"张三":58,"张四":90,"张五":88,"张六":59}
for i in grade:
if int(grade[i]) >= 60:
hege.append(i)
else:
buhege.append(i) ... |
c52109ce3879dc1df4e27344a90a791df020952c | osomat123/LN379_Sampravah | /prediction.py | 915 | 3.625 | 4 | from datetime import datetime, timedelta
def floodPredict(data, timestamp):
# Converting Passed Objects into Arrays with key
enumerate(data)
enumerate(timestamp)
h = 53 # Height of Dam in cm
x, y, x2, n, xy = 0, 0, 0, 0, 0
d0 = timestamp[0] # Base Time ie of first Water Level Data
for ... |
cea293dc384f10663f412e5b8ba1ea223ebd9d11 | ashishvista/geeks | /leetcode/LRU Cache.py | 2,050 | 3.734375 | 4 | class Node:
next = None
prev = None
def __init__(self, key, value):
self.key = key
self.value = value
class LRUCache:
def __init__(self, capacity: int):
self.h = {}
self.capacity = capacity
self.front = None
self.last = None
def get(self, key: int... |
76ba561a0721c8568c26c5dce8b19b469a9dc674 | prava-d/Databases | /projectBplustree.py | 2,905 | 3.59375 | 4 | '''
B+ Tree implementation
'''
class BPlusNode:
order = 3
def __init__(self, iL):
self.isLeaf = iL
self.parent = None
self.keys = []
self.pointers = [None,None,None,None]
self.nextNode = None
self.nodeIdx = None
self.numKeys = 0
def printKeys(self):
for key in self.keys():
print("\n",key
... |
5a3670c7faabdc8727852bcdee6afadc207cd332 | fruitbox12/CS1260 | /tworoots.py | 266 | 4.1875 | 4 | from math import sqrt
a = int(input("Enter int for a: "))
b = int(input("Enter int for b: "))
c = int(input("Enter int for c: "))
addSQRT = (-b + sqrt(b**2 - 4*a*c))/(2*a)
minusSQRT = (-b - sqrt(b**2 - 4*a*c))/(2*a)
print(addSQRT)
print(minusSQRT)
|
021d88158ad6cca189c16b2610f328c9015eb5ec | BinXu-UW/basic-pythoncode | /Xu_Final Exam/list.py | 594 | 3.6875 | 4 | import random
def prim():
for n in range(2, 1000):
for x in range(2, n):
if n % x == 0:
break;
else:
return True
def get_list():
n=int(raw_input("Enter the range of the list:"))
nums=[]
for i in range(n):
a=random.randint(1,10... |
869849c1654fc4e0818b84e550d13b65f7522e6d | 1stthomas/ht7-py-util | /utils-01.py | 762 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Feb 11 16:20:46 2018
@author: 1stthomas
"""
def module_exists(module_name):
"""
Checks if the submitted Module is installed. This Function prints
the Result of the check.
Parameters
----------
module_name : The name of the module to be checked.
... |
7b901b1b746cb14f80ba165d6ce9db37e9e7bbec | Satily/leetcode_python_solution | /solutions/solution67.py | 658 | 3.5 | 4 | from itertools import zip_longest
class Solution:
def addBinary(self, a, b):
"""
:type a: str
:type b: str
:rtype: str
"""
result = list(map(sum, zip_longest(map(int, reversed(a)), map(int, reversed(b)), fillvalue=0)))
for index in range(len(result) - 1):
... |
18f01a8a71306e59073944a5251810cb8737b689 | chengbindai1984/python_learning | /stringProcess_adjust.py | 743 | 3.6875 | 4 | print ('Hello'.rjust(20))
print ('Hello World'.rjust(20))
print ('Hello'.ljust(20))
print ('Hello World'.ljust(20))
print ('Hello'.center(20))
print ('Hello World'.center(20))
print ('Hello'.rjust(20, '>'))
print ('Hello World'.rjust(20, '>'))
print ('Hello'.ljust(20, '<'))
print ('Hello World'.ljust(20, '<... |
c66a662f237859b6bfe95a36daa77de10ee6201b | ag1548/Parla.py | /examples/overhead_test/threading_test.py | 1,007 | 3.640625 | 4 | import threading
import time
from sleep.core import sleep, bsleep
exitFlag = 0
class myThread (threading.Thread):
def __init__(self, threadID, name, counter):
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
self.counter = counter
def run(self):
print("Sta... |
38b514165e56d26124b89391d5afb781a314f8fa | myasul/log-analysis | /log_analyzer.py | 1,816 | 3.625 | 4 | #!/usr/bin/env python3
import psycopg2
DBNAME = "news"
def main():
# Open a file. This is where we will write the
# data that we will fetch from the database.
output_file = open("analysis.txt", "w")
final_output = ""
# Create a connection with the database
conn = psycopg2.connect(database=DB... |
58c3317b8c1bad2eda8ef4bdd7324086f3baf4cb | counterjack/Python | /move_zero_to_last.py | 1,574 | 3.640625 | 4 |
# - List of numbers (including 0)
# Input:
# Output: [1, 2, 4, 3, 5, 0,0,0,]
# - No extra space
# _input = [0, 2, 0, 4, 3, 0, 5, 0]
# # _input = [0,0,0,0,1]
# index_of_zero = 0
# zero_present = False
# zero_at_first_place = _input[0] == 0
# for idx, item in enumerate(_input):
# print (index_of_zero)
# ... |
06a46acd3f9229e5c41d45f9552648c49f4fc8a0 | yuchun921/CodeWars_python | /8kyu/Remove_string_spaces.py | 165 | 3.671875 | 4 | def no_space(x):
char = ''
for i in range(len(x)):
if x[i] == ' ':
continue
else:
char = char + x[i]
return char
|
4d1d8bbc5839d8276b3fd7e110a4ae3d847fc630 | arduzj/NSA_COMP3321 | /Lesson_03/03_13.py | 289 | 4.5 | 4 | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
'''Lecture 03, Exercise 13
Write a for loop that prints out a numbered list of your grocery items.
'''
shopping_list = ['milk', 'eggs', 'bread', 'apples', 'tea']
i = 1
for item in shopping_list:
print(str(i) + ': ' + item)
i += 1
|
12bd432929e96bf7395c18d802f8ae87815eb509 | ruidazeng/online-judge | /Kattis/whatdoesthefoxsay.py | 286 | 3.578125 | 4 | T = int(input())
for _ in range(T):
sound = input().split()
while True:
case = input()
if case == 'what does the fox say?': break
case = case.split()
if case[2] in sound:
while case[2] in sound: sound.remove(case[2])
print(*sound) |
1d2067b493ddd5b50af4eed8d6913b43653cb84c | mahfuzar07/learn_python | /4_area.py | 517 | 4.09375 | 4 | #Traiangle (Area = 1/2 * base * Vertical height)
#Rectangle (Area = Width * height)
#Square (Area = Length of side ^2 )
#Parallelogram (Area = base * Vertical height)
#Trapezoid (Area = 1/2 (a.base + b.base) * Vertical height)
#circle (Area = Pie * radius ^2)
#Ellipse (Area = Pie * a.base * b.base )
#Sector ... |
57269169f37ce820574a7d5573b02d0c429ac8a6 | syurskyi/Algorithms_and_Data_Structure | /_algorithms_challenges/practicepython/PracticePython-master/ch11/03/Answer_a.py | 230 | 3.828125 | 4 | ## Fibonacci number
## 0 1 1 2 3 5 8 13 21 34 55 89 144...
F_len = int(input("請輸入要印出的費氏數列個數:\n"))
a = 0
b = 1
temp = 0
for i in range(F_len):
print(a)
temp = a
a = a + b
b = temp
|
5335fdd3312fbed2c38f8bc32212bdc91f68cd67 | matheisson/ccoolstuff | /systemhello.py | 502 | 4.03125 | 4 | # This is my first Codecool project, the Hello World program
# It shall ask for a name, then write 'Hello XY'
# OR if no name give simply output 'Hello World'
# ===================================================
# -=By: Csányi Levente, Codecool BP 1st semester=-
import sys
def HelloSys(): #With the len() function I... |
c268bf704438be5a8d346d22e9a2401c41e310cf | poojataksande9211/python_data | /python_tutorial/excercise/step_argument.py | 787 | 4.1875 | 4 | #syntax [start argument:stop argument:step argument]
lang="python"
print ("pooja" [1:3])
print ("harshit" [1:5:1]) #(it will print full string starting from a to h)
print ("harshit" [0:5:2]) #(it will print character after 2 step)
print (lang[0:6:3])
print("sudhakar" [1:8:3])
print ("harshit" [0::2]) #(stop argumentbis... |
f6ca1b8a7f7857fb1c54f8299dace8957bc4de77 | harshgoel183/Practice-Python | /NewBoston/range.py | 220 | 3.859375 | 4 | for x in range(10):#by default starts from 0 and increment by 1
print(x)
for i in range(5,12):
print(i)
for x in range(10,40,5):
print(x)
butcher = 5;
while butcher < 10:
print("ttt")
butcher += 1
|
3ed3b4abda3495cade1cf500abb75247c7f24c12 | m1dlace/Labs_Python | /1 Лаба/11..py | 148 | 3.75 | 4 | def frange(X, Y, Z):
while X <= (Y - Z):
yield float('{:.1f}'.format(X + Z))
X = X + Z
for x in frange(1, 5, 0.1):
print(x) |
b5184a81feb2565d9eb40b238ab9e9fce7244a82 | Putind/Aca | /exerclse07.py | 1,267 | 3.984375 | 4 | # 死循环 循环条件永远满足
# while True:
# season = input('请输入一个季度')
# if season == '春':
# print('1月2月3月')
# elif season == '夏':
# print('4月5月6月')
# elif season == '秋':
# print('7月8月9月')
# elif season == '冬':
# print('10月11月12月')
# if input('按e退出') == 'e':
# break
# ... |
6adf59bbd039c929b35ccd75ca88105739e8db13 | lanestevens/aoc2016 | /day07/part1.py | 658 | 3.71875 | 4 | # -*- coding: utf-8 -*-
import re
import sys
def abba(segment):
for i in range(1, len(segment) - 2):
if segment[i] == segment[i + 1] and segment[i - 1] == segment[i + 2] and segment[i - 1] != segment[i]:
return True
return False
def valid(ip):
out = True
is_abba = False
... |
e9607178a941f68f2b50a9add12e47540ab95c60 | moshnar/Maktabsharif | /Maktab_42_HW_02_Mojtaba_Najafi/02_Combination.py | 322 | 4.03125 | 4 | def Combination(n, k):
if n == 0 or n < 0:
return
elif k == 0 or n == k:
return 1
else:
# checking combination recursivly
return Combination(n - 1, k - 1) + Combination(n - 1, k)
n = int(input("Please enter n : "))
k = int(input("Please enter k : "))
print(Combination(n, k)... |
ab8091357552dd32f8e420c35aa14a97a658529c | xiaoyaohu0325/chess_deeplearning | /util/actions.py | 8,372 | 3.75 | 4 | import chess
def move_to_index(move: chess.Move, current_player):
"""
A move in chess may be described in two parts: selecting the piece to move, and then selecting
among the legal moves for that piece. We represent the policy π(a|s) by a 8 × 8 × 73 stack of
planes encoding a probability distribution ... |
f0b69132b521bdc1b88c1be4bbef52dd9f06165d | cunghaw/Elements-Of-Programming | /5.1 The Dutch national flag problem/main.py | 1,391 | 4.09375 | 4 | # -*- coding: utf-8 -*-
"""
Quick sort implementation
@author: Ronny
"""
def quickSort ( array, low, high ):
if ( low < high ):
pi = partition ( array, low, high )
quickSort ( array, low, pi - 1 )
quickSort ( array, pi + 1, high )
return array
def swap ( array, idx1, idx2 ):
temp = array [ idx2... |
9495ddb11e4c7e44043f368e2d33cee6157651dc | bukvicfilip/new_repo | /udemy2.py | 555 | 4.28125 | 4 | def reverse_vowels(word):
_list=[]
word2=[]
n=-1
vowels="aeiouAEIOU"
for w in word:
if w in vowels:
_list.append(w)
_list1=_list[::-1]
for letter in word:
if letter not in _list:
word2.append(letter)
elif letter in _list:
word2.append(_list[n])
n-=1
return("".join(word2))
print(reverse_vow... |
0784d6e485772f226d1de0956b6e42b956ea8749 | mendigali/Good-Samaritan | /some-python/rama.py | 2,261 | 4 | 4 | # Task 1
# Inheritance is when one class can copy all the properties and methods
# of another class and add its own new methods and properties.
class Person:
def __init__(self, name="Ramazan", age="17"):
self.name = name
self.age = age
def showName(self):
return self.name
def showAge... |
00093fc453fbabe6141b0b11f22dac2258e0bb85 | AnkitM18-tech/Data-Structures-And-Algorithms | /Algorithms/Sorting Algorithms/Merge Sort.py | 998 | 4.28125 | 4 | def merge_sort(arr):
if len(arr)>1:
mid=len(arr)//2
left=arr[:mid]
right=arr[mid:]
merge_sort(left)
merge_sort(right)
i,j,k=0,0,0
while i<len(left) and j<len(right):
if left[i]<right[j]:
arr[k]=left[i]
i+=1
... |
8ab7078b162be693006612de7b6cb48cc5f4266e | Andru-filit/andina | /Clase # - copia (8)/ejercicio6.py | 205 | 3.796875 | 4 | loteria=[]
for i in range(5):
numero=int(input("ingrese los numeros ganadores"+ str(i) +"de la loteria: "))
loteria.append(numero)
print("Los numero de la loteria ganadores son:", sorted(loteria)) |
0fbb742459e3d78771e8e8eca6c7c9983508ea76 | nararodriguess/programacaoempython1 | /ex004.py | 507 | 3.78125 | 4 | n = (input('Digite algo: '))
print(f'O tipo primitivo de {n} é {(type(n))}')
print(f'Esse valor é numerico? {n.isnumeric()}')
print(f'Esse valor é alfabetico? {n.isalpha()}')
print(f'Esse vaor é alfanumerico: {n.isalnum()}')
print(f'Esse valor está em maiúsculo? {n.isupper()}')
print(f'Esse valor esta minúsculo? {n.isl... |
42b150ade92ca4e7d2c92d3bdc10d799fd746569 | suryasr007/algorithms | /Daily Coding Problem/12.py | 881 | 4.3125 | 4 | """
There exists a staircase with N steps, and you can climb up either 1 or 2 steps at a time. Given N, write a function that returns the number of unique ways you can climb the staircase. The order of the steps matters.
For example, if N is 4, then there are 5 unique ways:
1, 1, 1, 1
2, 1, 1
1, 2, 1
1, 1, 2
2, 2
Wh... |
7357d59ea8fccfafd879829bce972b711b8a7856 | masterxlp/The-Method-of-Programming | /string_exercises/1_习题_14.py | 1,518 | 3.640625 | 4 | def GenerateSuffixArray(string, length):
# Generate Suffix Array, store it to list
suf_array = list()
start = len(string) - length
end = len(string)
while start >= 0:
suffix = string[start:end]
suf_array.append(suffix)
start -= 1
end -= 1
return suf_array
... |
2f5b5702c4a1bb126337df64a0f37548e5b69249 | poonamangne/Programming-Exercises-1 | /Chapter13_12.py | 2,599 | 4.0625 | 4 | # 13.12 Modify the Triangle class to throw a TriangleError exception
# if the three given sides cannot form a triangle
# Sample Inputs [10, 9, 8] [3, 2, 1]
from GeometricObject import GeometricObject
class Triangle(GeometricObject):
def __init__(self, side1 = 1.0, side2 = 1.0, side3 = 1.0):
if (side1 + ... |
a3f7f0c33f0527a0cfbb5ff836868f90776dc58a | hoanghalc/hoangha-fundamental-c4e18 | /Session 5/bai_1.py | 808 | 3.984375 | 4 | # person = ["Quý",20,0,"Vĩnh Phúc",2,["manga","coding"],3,20]
# dictionary
#Create
person = {
"name": "Quý",
"age": 20,
"ex": 0,
"fav": ["Manga", "Coding"]
}
# print(person)
# name = person["name"]
# print(name)
#Add more
# person["length"] = 20
# print(person)
#Update
# person["length"] = 10
# ... |
d423317847288756cff0af3d70b8ccdd8edae6e5 | chenwu054/Leetcode | /Anagrams.py | 479 | 3.5625 | 4 | class Solution:
def anagrams(self, strs):
map, result = {}, []
if len(strs) >= 1:
for str in strs:
sorted_str = "".join(sorted(str))
if sorted_str not in map:
map[sorted_str] = [str]
else:
ma... |
118acd0bccc3fe1a71a7fda77de6a215c1f8a5d9 | dale-nelson/IFT-101-Lab5 | /Lab05P3.py | 220 | 3.8125 | 4 | str1 = "spam"
str2 = "ni ! "
print(" The Knights who say, " + str2)
print(3 * str1 + 2 * str2)
print(str1[1])
print(str1[1:3])
print(str1[2] + str2[:2])
print(str1 + str2[-1])
print(str1.upper())
print(str2.upper() * 3) |
d85e7a8e39fad91bce44ceebe5e08624441880bc | roshnet/enleren | /utils/validate.py | 762 | 3.625 | 4 |
def validate(name='', uname='', passwd=''):
# Performs basic checks on user input.
# Use regular expressions in production version.
# Applying very basic checks just for testing sake.
if len(name) < 4 or len(uname) < 4 or len(passwd) < 8:
return 0
return 1
'''
In future versions, validat... |
75683e9f0a6308f2c300b3e187886a8075773a52 | MallikarjunH4/python-training | /PRACTICE SET 02-05-2021.py | 1,048 | 3.609375 | 4 | #1
l1=[1,2,3,4]
l2=['a','b','c','d']
d=dict(zip(l1,l2))
print(d)
#2
n=input()
l1=[]
l2=[]
for i in n:
if 97<=ord(i)<=122 or 65<=ord(i)<=90:
l1.append(i)
elif i in """0123456789""":
l2.append(i)
print("Letters : ",len(l1))
print("Digits : ",len(l2))
#3
n=input()
n=n.split()
print(n)
f=0
cou... |
c148d72685b03b00b077b5a7a0279f06c0934f3c | TQCAI/Algorithm | /python/linklist/s148.py | 1,784 | 3.71875 | 4 | from structure import ListNode
def merge(h1: ListNode, h2: ListNode):
p1, p2, dummy = h1, h2, ListNode(0)
dp = dummy
while p1 and p2:
if p1.val < p2.val:
dp.next = p1
p1 = p1.next
else:
dp.next = p2
p2 = p2.next
dp = dp.next
dp.ne... |
52884097dbfb7b73f1b6798cabe2ad5d1b548781 | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_2/387.py | 2,791 | 3.546875 | 4 | #!/usr/bin/python
import sys;
import re;
def schedule_trains(trips_A, trips_B, T):
available_A = [];
available_B = [];
nA = 0;
nB = 0;
while( (len(trips_A)>0) or (len(trips_B)> 0) ):
# find next trip
# A -> B
if((len(trips_B) == 0 ) or ((len(trips_A) > 0 ) and (trips_A[0] < trips_B... |
1be7627bd75bce03e83b918e7359440e87f4f070 | shankarapailoor/Project-Euler | /Project Euler/p21-p30/p25.py | 1,019 | 3.609375 | 4 | from math import *
from copy import deepcopy
import time
def calculate_Fibonnaci():
fn = 0
n = 10
while len(str(fn)) < 1000:
fn = 1/sqrt(5)*((2/(-1 + sqrt(5)))**(n+1) - (2/(-1-sqrt(5)))**(n+1))
n += 1
return int(fn)
def addtwoarrays(a, b):
c = [0]*len(a)
rem = 0
if len(a) != len(b):
print "Array Length... |
3a4ebd71af5f0894d0d9aadcbae342abb0d0adba | vlad0337187/different_helpful_programs | /for_backup/создать папки для монтирования fstab.py | 3,109 | 4.375 | 4 | #! /usr/bin/python3
import os, os.path
import sys # for exiting from program
import shutil # for removing directories with all it's folders
def create_folder(folder):
"""Creates passed to it folder if it's absent,
if it's present - asks user, what to do.
"""
print('')
if os.path.exists(folder) and (os.list... |
39169b0bab3c83ebfecb996329ad040f55836308 | gokarna123/Gokarna | /word.py | 276 | 4.1875 | 4 | words=input("Enter the words;")
length=len(words)
string=""
counter=-1
while counter>(length-1):
string1=words[counter]
string1=string+string1
counter=counter-1
if string==words:
print("the number is palindrome")
else:
print("The number is not palindrome") |
dd714ffd18f4c3d4a49f2a51b1148202eea3acf7 | Computer-engineering-FICT/Computer-engineering-FICT | /II семестр/Дискретна математика/Лаби/2016-17/Братун 6305/Lab_1_backup_4/Lab_1/4ernetka.py | 240 | 3.546875 | 4 | #My function
def differencexz(a, b):
res = []
for i in a:
for j in b:
if i != j:
res.append(i)
return set(res)
x = {1,2,3,4,5,6,7,8,9,10}
c = {1,2,3,4,5}
print(differencexz(x,c))
|
c8eb75a55cb15bf82b74785ea7104b6f7bb137ab | rafaelperazzo/programacao-web | /moodledata/vpl_data/215/usersdata/271/113863/submittedfiles/av2_p2_m2.py | 325 | 3.8125 | 4 | # -*- coding: utf-8 -*-
#ENTRADA
n = int(input('Digite a quantidade de portas : '))
a = []
#PROCESSAMENTO
for i in range (0,n,1) :
v = int(input('Vidas : '))
a.append(v)
x = int(input('Porta de Entrada : '))
y = int(input('Porta de Saída : '))
soma = 0
for i in range (x,y+1,1) :
soma = soma + a[i]
print(som... |
cc226c3f494edcad86a5b765a55accce32c28912 | StevePaget/StacksAndQueues | /stacks.py | 872 | 3.953125 | 4 | # Stacks Demo
class Stack():
def __init__(self, maxsize):
self.maxsize = maxsize
self.contents = [ None for i in range(maxsize)]
self.top = -1
def push(self, newItem):
if self.top == self.maxsize-1:
print("The Stack is full")
else:
self.top +... |
0a61af99b6121ef69568e1231dce79fc6c0b6c37 | twickatwk/codingchallenges | /Leetcode/Easy/242ValidAnagram.py | 923 | 3.53125 | 4 |
# Time: O(N Log N) - because of the sorting | Space: O(1)
def isAnagram(s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
s = list(s)
t = list(t)
s.sort()
t.sort()
return s == t
# Time: O(N) | Space: O(N)
def isAnagram2(s, t)... |
6a2ef1ab884837f51ca1a8570da0c9c113d92565 | abhishekbisneer/Python_Code | /Exercise-14.py | 799 | 4.15625 | 4 | #List Remove Duplicates
#Exercise 14 (and Solution)
'''
Write a program (function!) that takes a list and returns a new list
that contains all the elements of the first list minus all the duplicates.
Extras:
Write two different functions to do this - one using a loop and constructing a list,
and another using sets.... |
15be3acd9ae5d233fb9d4919ff70a7c255676019 | Yogesh-Singh-Gadwal/YSG_Python | /Core_Python/Day-10/26.py | 313 | 3.78125 | 4 | # loops
# patterns
'''
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
'''
'''
v1 = int(input('Enter user value : '))
a = 1
for x in range(v1):
print('1 '*a)
a +=1
'''
v1 = int(input('Enter user value : '))
for x in range(v1):
for y in range(x+1):
print(y+1,end=" ")
print()
|
9ba81dae1bd08ded810345cf6d70953243d7e8ad | LES0915/korea_subway_dataset | /src/make_csv.py | 706 | 3.703125 | 4 | import csv
def write_csv(line_data, city_name):
file = open(f"dataset/{city_name}/{line_data['line_name']}.csv", mode="w")
writer = csv.writer(file)
if city_name == "pusan":
writer.writerow(["number", "line", "name", "english_name", "japanese_name",
"chinese_name", "hanja_... |
d656994d3677e257b228a86f573a38b5723cbcf8 | luxuguang-leo/everyday_leetcode | /00_leetcode/438.find-all-anagrams-in-a-string.py | 880 | 3.5 | 4 | #
# @lc app=leetcode id=438 lang=python
#
# [438] Find All Anagrams in a String
#
# @lc code=start
class Solution(object):
def findAnagrams(self, s, p):
"""
:type s: str
:type p: str
:rtype: List[int]
"""
#和#76相同的思路!
if not s or not p:
return []
... |
d22797d5a0f4a204507f4a08b09d8f9f136633ce | LukeBreezy/Python3_Curso_Em_Video | /IDLE/desafio03.py | 231 | 3.96875 | 4 | print('''======= D E S A F I O 0 3 =======
Siga as instruções e veja a soma dos números.''')
num1 = input('Digite um número: ')
num2 = input('Digite outro número: ')
print(num1, '+', num2, '=', int(num1)+int(num2))
|
1c9026b22d60bb38de26b521ae501ebb815208d2 | Jayesh97/programmming | /special/139_WordBreak.py | 511 | 3.59375 | 4 | s = "leetcode"
wordDict = ["leet", "code"]
def recurse(s,seen,wordset,lengths):
if s=="":
return True
if s in seen:
return seen[s]
for length in lengths:
if s[:length] in wordset and recurse(s[length:],seen,wordset,lengths):
#print(s[:length])
seen[s]=True
... |
c7290853dd16254d90c4b01ca1f9f4126db38df9 | romanbondarev/2048 | /logic.py | 7,666 | 3.796875 | 4 | import os
import time
from random import *
class Game:
"""2048 game."""
def __init__(self):
"""Gamemap and variable initialization."""
self.game_map = {0: '', 1: '', 2: '', 3: '',
4: '', 5: '', 6: '', 7: '',
8: '', 9: '', 10: '', 11: '',
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.