blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
639934c70afa23f042371ce06b3ed89fdd6245ca | baluneboy/pims | /recipes/recipes_map_filter_reduce.py | 1,824 | 4.53125 | 5 | #!/usr/bin/env python
"""Consider map and filter methodology."""
import numpy as np
def area(r):
"""return area of circle with radius r"""
return np.pi * (r ** 2)
def demo_1(radii):
"""method 1 does not use map, it fully populates in a loop NOT AS GOOD FOR LARGER DATA SETS"""
areas = []
for r... |
ee130f6c958ecb8877ce9efae4209ba950d9b35c | baluneboy/pims | /utils/benchmark.py | 1,624 | 3.671875 | 4 | #!/usr/bin/env python
from time import time
## simple timing-based benchmark class
#BENCH_TOTAL = 0
#BENCH_COUNT = 0
#def benchmark(startTime):
# global BENCH_COUNT, BENCH_TOTAL
# BENCH_COUNT = BENCH_COUNT + 1
# BENCH_TOTAL = BENCH_TOTAL + (time() - startTime)
# simple timing-based benchmark
class Benchmark... |
04ba39b669f9b43deb922798bdfd538dacd09541 | baluneboy/pims | /sandbox/demo_pandas_to_excel.py | 567 | 3.703125 | 4 | #!/usr/bin/env python
import pandas as pd
# Create 2 Pandas dataframes.
a = [1,2,3,4]
b = [2*i for i in a]
df1 = pd.DataFrame({'Stimulus Time': a, 'Reaction Time': b})
df2 = pd.DataFrame({'Chrominance': b, 'Octaviance': a})
# Create a Pandas Excel writer using XlsxWriter as the engine.
writer = pd.ExcelWriter('... |
2f09f7ea2ac684313292aaa8ec3de346d8d3fb96 | baluneboy/pims | /recipes/recipes_exceptions.py | 2,460 | 3.578125 | 4 | #!/usr/bin/env python
""" Shows how to re-raise an original exception first, and handle the clean up
in a try:finally block. This construction prevents the original exception from
being overwritten by the latter, and preserves the full stack in the traceback.
"""
import sys
import logging
import traceback
import date... |
a9c451b91f2db67eb6652bab68194dabbd450a14 | baluneboy/pims | /pad/binaryToAscii.py | 1,594 | 3.5625 | 4 | #!/usr/bin/env python
# $Id: binaryToAscii.py,v 1.2 2002-02-13 12:42:10 pims Exp $
import sys, struct, string
if len(sys.argv) < 3:
print """
binaryToAscii.py converts PIMS PAD files from binary to ASCII
- output files have the same names as input files with '.ascii' appended
- PAD acceleration files usuall... |
839d8b355d9c872aca4403e4652a09b79deb86bb | Manikranthi/Innomatics_Internship | /day_2/runner_up_score.py | 244 | 3.671875 | 4 | def secondmax():
n = int(input())
arr = list(map(int, input().split()))
l1=[]
for i in range(0,len(arr)):
if(arr[i] not in l1):
l1.append(arr[i])
l1.sort()
print(l1[-2])
secondmax() |
a5598cba3b9130c284ee827aa68dfcbb4f8a8280 | Manikranthi/Innomatics_Internship | /day_1/loops.py | 124 | 3.5 | 4 | def squ(n):
if(n>1):
for i in range(0,n):
print(i*i)
squ(int(input()))
|
3cf347f207e35757cac8225603745f54bf8d2587 | baecheese/ruby_study | /replay/test2.py | 279 | 3.59375 | 4 | #-*-coding:utf-8
'''
단 하나의 print 문을 사용하여 다음을 출력하라.
*
***
*****
***
*
'''
n = 0
while n < 6:
a = ' *'
b = ' ***'
c = '*****'
if n == 1 or 5 :
print (a)
elif n == 2 or 4:
print(b)
else:
print(c)
n = n + 1 |
b6f01dab2e2d79418f64e3bfaf1aeebaebe31e92 | pradeeps9/SnakeWaterGun_Game | /main.py | 903 | 3.96875 | 4 | import random
def gameWin(comp, you):
if comp == you:
return None
elif comp == 's':
if you == 'w':
return False
elif you == 'g':
return True
elif comp == 'w':
if you == 'g':
return False
elif you == 's':
return True
... |
3759e14c51427d7a71e0ea198c719595db132e97 | natefoo/galaxy-beta2 | /lib/galaxy_utils/sequence/transform.py | 3,615 | 3.65625 | 4 | #Dan Blankenberg
#Contains methods to tranform sequence strings
import string
#Translation table for reverse Complement, with ambiguity codes
DNA_COMPLEMENT = string.maketrans( "ACGTRYKMBDHVacgtrykmbdhv", "TGCAYRMKVHDBtgcayrmkvhdb" )
RNA_COMPLEMENT = string.maketrans( "ACGURYKMBDHVacgurykmbdhv", "UGCAYRMKVHDBugcayrmkv... |
d17822e33234548ac75f0b5ee920ce56083cf246 | pradeephyd/CISC4900 | /retrieve_data_from_api.py | 1,292 | 3.515625 | 4 | # Function retrieves data associated with user inputted Symbol and saves json to 'Files' directory.
# Data manipulation will be conducted using those files. 'Outputsize' argument will be
# implemented later to allow for Compact or Full data
#
# Also need to implement solution to prevent invalid entries from having ... |
c824c2e7e4134b1d6ac57ba91d595526abbebdaa | BhoomikaMS/PIP-1BM17CS047 | /evennolist.py | 122 | 3.53125 | 4 | li=list(map(int,input("Enter the list:").split()))
newlist=[]
for i in li:
if i%2==0:
newlist.append(i)
print(newlist)
|
95731ac05e1744bc6d6db1877005a9ac4d41bfe3 | BhoomikaMS/PIP-1BM17CS047 | /universitymanagement.py | 1,071 | 3.59375 | 4 | class Student:
def __init__(self):
self.s_id=None
self.age=None
self.marks=None
def validate_marks(self):
if self.marks>=0 and self.marks<=100:
return True
else:
return False
def validate_age(self):
if self.age>20:
return True
else:
return False
def check_qualification(self):
if sel... |
c73d7b315bcc09f37aa0ff5eb6cc9a4c1b20a3e1 | maryamkaka/nomo404 | /QuestionsBalloons/balloons.py | 1,770 | 3.578125 | 4 | test_cases = int(raw_input(""))
for case in range(0, text_cases):
test_info = raw_input("")
total_qs = int(test_info.split(" ")[0])
lies = int(test_info.split(" ")[1])
arrays = []
for q in range(0, total_qs):
question = raw_input("")
answer = raw_input("")
if "and" in quest... |
3abba9ee1a69d64bc3b95c41cfa532310240907c | Andresrodart/Hobbies | /HackerRank/Minimum Swaps 2.py | 3,335 | 3.84375 | 4 | #Minimum Swaps 2
#So at first it will be naive to go an swap every value as it appears like this
#Al inicio es muy sencillo llegar y hacer los cambios conforme van apareciendo los valores, así.
def minimumSwaps(arr):
swaps = 0
for i in range(0, len(arr)):
if i + 1 != arr[i]: #Check if the e... |
dc9209902406a730885eaf904ac5a179843ea19a | Andresrodart/Hobbies | /CrackingTheCodeInterview/Array&Strings/Python3/PalindormePermutation.py | 639 | 3.734375 | 4 | # HT = HastTable
def PalindromePermutation(string): # Just for ascii strings
string = string.lower().replace(' ', '') # O(n)
HT = {} # O(1)
impair = 0 # O(1)
for char in string: # O(n)
if char in HT: HT[char] +=1 # O(1)
else: HT[char] = 1 # O(1)
for value in HT.values(): # O... |
245ea0fc86c28374f91766dcca3ba951cf976fc1 | Andresrodart/Hobbies | /CrackingTheCodeInterview/BitManipulation/insertion.py | 172 | 3.609375 | 4 | def insertion(N, M, i, j):
right = (1 << i) - 1
left = ~0 << j + 1
mask = right | left
return (N & mask) | (M << i)
print('{0:b}'.format(insertion(1 << 10, 19, 2, 6))) |
0cc8a91ec88e3edb9c4f48577111396dc4451fc5 | Andresrodart/Hobbies | /OmegaUp/NoFibo.py | 180 | 3.953125 | 4 | fibo = 3
a = 1
b = 2
val = int(input(""))
for i in range(3, val):
if i == fibo:
a = b
b = fibo
fibo = a + b
else:
print(i, sep='', end=' ') |
a007f6ab94c8d1a8a57a2ea54131dd383554214c | Andresrodart/Hobbies | /CrackingTheCodeInterview/Array&Strings/Python3/ZeroMatrix.py | 589 | 3.734375 | 4 | def zeroMatrix(matrix):
for i in range(len(matrix[0])):
for j in range(len(matrix[0])):
if matrix[i][j] == 0:
#Note it will just work for n*n matrix
for k in range(len(matrix[0])):
matrix[i][k] = '-'
matrix[k][j] = '-'
for i in range(len(matrix[0])):
for j in range(len(matrix[0])):
if matr... |
5e8a0f50224f3dbaafbe567bb33ea7fec79bc72c | Andresrodart/Hobbies | /Others/levelTreeSum.py | 1,800 | 3.6875 | 4 | # Given a binary tree with no repeted id, staring the root with cero I want to know the
# sum of each level eg:
# 0 -> 0
# 2 3 -> 5
# 1 3 2 4 -> 10
# As a result i want an array with does values [0, 5, 10]
#First we have to see that in worst case the length of the tre will be n = number of nodes
clas... |
4cf593ebcc0b6d27c0cd80d91b339d8da6697310 | Andresrodart/Hobbies | /HackerRank/Making Anagrams.py | 1,108 | 3.765625 | 4 | def makeAnagram(a, b):
listA = [item for item in a] #because string are unmutable we want to use a list
listB = [item for item in b]
listA.sort() #sort to make comparasion simplier
listB.sort()
lenA = len(a)
lenB = len(b)
j = i = res = 0
while i < lenA and j < lenB: #So we iterate ti... |
c287dd5c5bc9a81cae6c4cb7b6d6412fb7919fbd | dnguyenocc/boggle | /trie.py | 2,171 | 3.8125 | 4 | class Node:
def __init__(self, char=None):
self.label = char
self.children = []
self.end = False
def hasChild(self, chr):
"""Returns True if the node has a child matching character chr"""
for child in self.children:
if child.label == chr:
return True
... |
e0b44e182c5693b651e21ca8dba759ed01ab80ea | UW-ParksidePhysics/python-functions-and-branching-omardelgado21 | /trapezint.py | 758 | 3.625 | 4 | import math
def trapezint1(f, a, b):
return (b-a)*(f(a)+f(b))/2
trapezint1(math.cos, 0 , math.pi)
trapezint1(math.sin, 0 , math.pi/2)
def trapezint2(f, a, b):
val = 0
val += (b - a) * 0.25 * (f(a) + f((b - a) * 0.5))
val += (b - a) * 0.25 * (f(b) + f((b - a) * 0.5))
return val
trapezint2(math.co... |
1e6201d2f6f6df652f7ca66b1347c59c3121d067 | ThoPhD/vt | /question_1.py | 918 | 4.25 | 4 | # Question 1. Given an array of integer numbers, which are already sorted.
# E.g., A = [1,2,3,3,3,4,4,5,5,6]
# • Find the mode of the array
# • Provide the time complexity and space complexity of the array, and your reasoning
# • Note: write your own function using the basic data structure of your language,
# please av... |
08c0dbe4b362bdcab68ea20b5e114e5c0a4a1867 | 09pve09/Algorithms_Python | /3Sum_Closest.py | 1,321 | 3.953125 | 4 | Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution.
For example, given array S = {-1 2 1 -4}, and target = 1.
The sum that is closest to the target... |
764f874e6229c8800df1883a60b6a589bc814e4e | 09pve09/Algorithms_Python | /Longest_Substring_Without_Repeating_Characters.py | 919 | 4.03125 | 4 | Given a string, find the length of the longest substring without repeating characters.
Examples:
Given "abcabcbb", the answer is "abc", which the length is 3.
Given "bbbbb", the answer is "b", with the length of 1.
Given "pwwkew", the answer is "wke", with the length of 3.
Note that the answer must be a substring,... |
e9ad560bfbc34ef1c34ddbe84e1e992f79aa191c | 09pve09/Algorithms_Python | /homework.py | 2,691 | 3.671875 | 4 | print 'Реализовать ДЗ-7.2 на основе примера на C++. Файл в Skype (graphToTree.cpp)'
class Edge:
def __init__(self, vertex_a, vertex_b):
self.x = vertex_a
self.y = vertex_b
class Graph:
def __init__(self, number_of_vertices):
self.variety= [i for i in range(number_of_vertices)]
self.graph = []
... |
3bb48624eea19609a3e867127f0cd507cf3422da | VersionBeathon/Python_learning | /chapter_5/conditional.py | 949 | 4.09375 | 4 | # _*_ coding:utf-8 _*_
# bool
# False None 0 "" () [] {} 在作为布尔表达式的时候,会被解释器看作假(False)
print True
print False
print True == 1
print False == 0
print True + False + 42
print bool('I think, there before I am')
print bool(42)
print bool('')
print bool(0)
# 条件执行, if语句, else字句, elif字句
name = raw_input('What is your name? ')
... |
935df152812c57eecf00710f00f25e5eb83e6161 | VersionBeathon/Python_learning | /chapter_1/get-import.py | 234 | 3.859375 | 4 | # coding:utf-8
input("the meaning of life : ")
x = input("x: ")
y = input("y: ")
print x * y
'''Python获取用户输入,但sublime text 不支持此功能,只能通过Tools——sublimeREPL——Python模拟控制台来实现'''
|
eb19b13402b74c075f4b108486bf22df591cabd6 | VersionBeathon/Python_learning | /chapter_2/lsit_operation.py | 4,145 | 3.765625 | 4 | # _*_ coding:utf-8 _*_
# appeng方法用于在列表末追加新的对象
lst = [1, 2, 3]
lst.append(4)
print lst
# 如果使用list作为变量名,就无法调用list函数
''' append方法和其他一下方法类似,知识在恰当位置修改原来的列表。
它不是简单地返回一个修改过的新列表——而是直接修改原来的列表'''
# count方法用来统计某个元素在列表中出现的次数
example = ['to', 'be', 'or', 'not', 'to', 'be']
print example.count('to')
x = [[1, 2], 1, 1, [2, 1, [1, 2]... |
9d2efaa825675dc4e78f15f248114cd5f7b4b6a5 | VersionBeathon/Python_learning | /chapter_6/action_scope.py | 1,158 | 4.03125 | 4 | # _*_ coding:utf-8 _*_
x = 1 # 变量和所对应的值用的是个“不可见”的字典
scope = vars() # 内建vars函数可以返回x的值
print scope['x']
scope['x'] += 1
print x
# 这类不可见字典叫做命名空间或者作用域,每个函数调用都会创建一个新的作用域:
def foo():
x = 42
x = 1
foo()
print x
# 函数内个变量被称为局部变量(local variable)参数的工作原理类似于局部变量
def output(x):
print x
x = 1
y = 2
output(y)
output(x)
... |
dc76d98797c421cf3ff6ca5de691aeec5ad29aa6 | VersionBeathon/Python_learning | /chapter_8/catch_exception.py | 1,648 | 4.28125 | 4 | # _*_ coding:utf-8 _*_
# 处理异常可以使用try/except语句来实现
try:
x = input('Enter the first number: ')
y = input("Enter the second number: ")
print x / y
except ZeroDivisionError:
print "The second number can`t be zero!"
# 不止一个except字句
try:
x = input('Enter the first number: ')
y = input("Enter the second... |
134dd72ff305e5e49c99dcaaca4003a9ffbc07d9 | atanbhardwaj/Python | /Perfect_Num.py | 143 | 3.890625 | 4 | import math
x=int(input('Enter the number \n'))
a=int(math.sqrt(x))
if a*a==x:
print("Perfect Number")
else:
print("Not Perfect") |
cc00412d6d51cd147e624c4322f5847bdc5d780a | olincollege/gimik | /workspace.py | 5,432 | 3.8125 | 4 | '''
Contains the Workspace class for keeping track of objects
'''
from shapes import Cuboid, Spheroid, Cylinder
class Workspace():
'''
A workspace to hold various shapes and to be referenced when interacting
with the user.
Attributes:
_items. A list of Shape objects representing the shapes i... |
91b5577a3bdaf18f5c12e0b48febfce44276a0ae | CyrilGrosjean/python_help | /boucles.py | 349 | 3.671875 | 4 | import time
a = 10
liste = ["Bonjour", "Comment", "Va"]
string = "Test"
for i in range(0, a):
print(i)
time.sleep(5)
for i in liste:
print(i)
time.sleep(5)
for a in string:
print(a)
valide = True
while True:
while valide:
print("Valide est valide")
valide = False
print("Boucl... |
4f4f09017d0629edb2993ed3a6140169f52fb80e | Noni2/pyhton-project | /sort.py | 716 | 3.75 | 4 | # This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
list1 = []
while True:
element = int(input("enter the element"))
list1.append(element)
choice = input("w... |
14b384d867d601cc6b5575e5656f5a226333c274 | Phong-Hua/Udacity_Show-me-the-Data-Structures | /Problem3.py | 9,959 | 3.90625 | 4 | """
Min Heap Implementation
Code from https://www.geeksforgeeks.org/binary-heap/
"""
# A Python program to demonstrate common binary heap operations
# Import the heap functions from python library
from Problem2 import test_case_3
from heapq import heappush, heappop, heapify
# heappop - pop and return the smallest... |
dcbc4546f048b01d63961f53c48212b582f6ad37 | sarathchandra0007/ParkingLot | /parking_slot_info.py | 486 | 3.703125 | 4 | class ParkingSlotInfo:
"""
A Class which contains information of vehicle registration number and the age of the driver of the vehicle.
"""
def __init__(self, registration_number: str, driver_age: int):
"""
Initializes registration_number and age.
:param registration_number: Vehic... |
c0a8468729c53dcbcbfdab828406a071443d3b9c | cloudzfy/euler | /src/68.py | 1,851 | 3.59375 | 4 | # Consider the following "magic" 3-gon ring, filled with the
# numbers 1 to 6, and each line adding to nine.
# 4
# \
# 3
# / \
# 1 - 2 - 6
# /
# 5
# Working clockwise, and starting from the group of three with
# the numerically lowest external node (4,3,2 in th... |
49ec6ca0fbbebf97d2f4d01a192d33b597fd424d | cloudzfy/euler | /src/77.py | 738 | 3.515625 | 4 | # It is possible to write ten as the sum of primes in exactly
# five different ways:
# 7 + 3
# 5 + 5
# 5 + 3 + 2
# 3 + 3 + 2 + 2
# 2 + 2 + 2 + 2 + 2
# What is the first value which can be written as the sum of
# primes in over five thousand different ways?
from math import sqrt
def generate_primes(limit):
is_prime... |
a122d03e99142d97fc1a442229e5cbd172e6fe32 | cloudzfy/euler | /src/150.py | 1,295 | 3.5 | 4 | # In a triangular array of positive and negative integers, we wish to
# find a sub-triangle such that the sum of the numbers it contains is
# the smallest possible.
# In the example below, it can be easily verified that the marked
# triangle satisfies this condition having a sum of −42.
# [../img/p150.gif]
# We ... |
a14a1cb7423a8761ff26ad9392093c6acc06ce55 | cloudzfy/euler | /src/5.py | 744 | 3.671875 | 4 | # 2520 is the smallest number that can be divided by each
# of the numbers from 1 to 10 without any remainder.
# What is the smallest positive number that is evenly
# divisible by all of the numbers from 1 to 20?
size = 20
is_prime = [True for i in range(size)]
for i in range(2, size):
if is_prime[i]:
j = 2
whi... |
604be482da6a2aea20bf660763b23019eea9571f | cloudzfy/euler | /src/88.py | 1,356 | 4.1875 | 4 | # A natural number, N, that can be written as the sum and
# product of a given set of at least two natural numbers,
# {a1, a2, ... , ak} is called a product-sum number:
# N = a_1 + a_2 + ... + a_k = a_1 x a_2 x ... x a_k.
# For example, 6 = 1 + 2 + 3 = 1 x 2 x 3.
# For a given set of size, k, we shall call the smalle... |
63422ce07ca84115e864a78ddfc50364e2331b61 | cloudzfy/euler | /src/102.py | 1,370 | 3.859375 | 4 | # Three distinct points are plotted at random on a Cartesian plane,
# for which -1000 <= x, y <= 1000, such that a triangle is formed.
# Consider the following two triangles:
# A(-340,495), B(-153,-910), C(835,-947)
# X(-175,41), Y(-421,-714), Z(574,-645)
# It can be verified that triangle ABC contains the origin, ... |
b28870a94ded4bc841f39f3ce4263b20591954a7 | cloudzfy/euler | /src/69.py | 1,232 | 3.96875 | 4 | # Euler's Totient function, phi(n) [sometimes called the phi function],
# is used to determine the number of numbers less than n which are
# relatively prime to n. For example, as 1, 2, 4, 5, 7, and 8, are all
# less than nine and relatively prime to nine, phi(9) = 6.
# n Relatively Prime phi(n) n/phi(n)
#... |
f14fb6a9e390c6872f2f79bad67b747cd3312dbf | cloudzfy/euler | /src/92.py | 1,031 | 3.75 | 4 | # A number chain is created by continuously adding the square
# of the digits in a number to form a new number until it has
# been seen before.
# For example,
# 44 -> 32 -> 13 -> 10 -> 1 -> 1
# 85 -> 89 -> 145 -> 42 -> 20 -> 4 -> 16 -> 37 -> 58 -> 89
# Therefore any chain that arrives at 1 or 89 will become stuck
# ... |
98149e4e73c8b8bb2d1ad318b50c7927a90bb519 | hawkfish/sudoku | /sudoku/reduce.py | 2,209 | 3.53125 | 4 | # !/usr/bin/python3
from sudoku.cells import *
from sudoku.regions import *
class ReduceError(BaseException):
pass
# Remove all used values from a cell
def reduceCellByValues(cell, used):
reduced = []
for value in cell:
if not used[value]: reduced.append(value)
if not len(reduced): raise R... |
03f028686704d0b223621546b04893a844ef9148 | NathanJiangCS/Exploring-Python | /Higher Level Python Concepts/Closures.py | 2,029 | 4.6875 | 5 | #Closures
'''
Closures are a record storing a function together with an environment: a mapping
associating each free variable of the function with the value or storage location
to which the name was bound when the closure was created. A closure, unlike a plain
function, allows the function to access those captured var... |
ab32127c6cad655cc7281a20c55ddae0b4354231 | NathanJiangCS/Exploring-Python | /Tkinter/Classes.py | 375 | 4.0625 | 4 | #Python 3
#Learning about the basics of classes
class calculator:
def addition(x,y):
ans = x+y
print(ans)
def subtraction(x,y):
ans = x-y
print(ans)
def multiplication(x,y):
ans = x*y
print(ans)
def division(x,y):
ans = x/y
print(ans)
c... |
d3ea582ed28b3eaa9f7a0376c649bab202c94ffa | NathanJiangCS/Exploring-Python | /Higher Level Python Concepts/String Formatting.py | 2,862 | 4.125 | 4 | #String formatting
#Advanced operations for Dicts, Lists, and numbers
person = {'name':'Nathan', 'age':100}
#######################
#Sentence using string concatenation
sentence = "My name is " + person['name'] + ' and I am ' + str(person['age']) + ' years old.'
print sentence
#This is not readable as you have to ope... |
5c7b6560bb411d150b7e46c22ff9d0f9dd08afbb | JonathanYen1004/password-retry | /password.py | 287 | 3.953125 | 4 | password = '1004'
i = 3
while i > 0:
i = i - 1
pwd = input('please enter your password: ')
if pwd == password:
print('login successfully')
break
else:
print('wrong password' )
if i > 0:
print( i, 'more chance')
else:
print('delete all data')
|
f4f35669edb7b64087a4bbca6ce9fd5c584e09ef | Rizvi-hassan/python | /Bahi Khata/main.py | 9,738 | 4.34375 | 4 | """
This is a program which is a kind of a "bahi- khata"(if you don`t know its meaning please google it).
It is useful for shopkeepers who run khata system for their regular customers.
This program gives you the following features:
* Activate new customers khata
* Stores the debt along with the date when it was... |
d57de477b92b5df747c6a0fbe11272203592cfef | RonakNandanwar26/Python_Programs | /read_write_files.py | 2,211 | 4.09375 | 4 | # File Handling
# reading and writing in files
# reading the file
# syntax:
# object_name = open('file_name.extension', mode)
# f = open('scrapping_tool.txt','r') # scrapping tool.txt is fle name which you want to open and
# # # 'r' stands for read mode which is optional parameter
# # ... |
2efb24a43685c445662294298576badebdc16f39 | RonakNandanwar26/Python_Programs | /practice.py | 3,824 | 4.375 | 4 | # print('my name is mayur,\n\tmayur is my name,\n\twhay is my name?\n\t\twho are you?,\nis there any problem?,\ntell me.\n\twhat is resion behind that?')
# print('my name is mayur,\n\tmayur is my name'\
# '\n\twhat is my name ?\n\t\twho you are,\nis there any problem?'\
# 'tell me.\n\twhat is the resion beh... |
616e0af829a12d78b50fdf016704bb179d2a721c | RonakNandanwar26/Python_Programs | /zip_enumerate.py | 2,367 | 4.40625 | 4 | # zip
# zip returns iterator that combines multiple iterables into
# one sequence of tuples
# ('a',1),('b',2),('c',3)
# letters = ['a','b','c']
# nums = [1,2,3]
# lst = [4,5,6]
# print(zip(nums,letters,lst))
# # #
# for letters,nums,lst in zip(letters,nums,lst):
# print(letters,nums,lst)
# # unzip
... |
69f4dc400970be5a5aefe6f111294bf43859ed83 | Nikita-RP/python-iiec-program | /human.py | 2,025 | 3.515625 | 4 | import pyttsx3
import os
pyttsx3.speak("hello and welcome to python world")
print("Hello")
while True:
print("How can I help you ? ", end=" ")
p=input()
if (("don't" in p) or ("donot" in p) or ("do not" in p) or (" not " in p) or (" no " in p)):
print("okay")
else:
if (("run in p") or ("execute" in ... |
f9c5c721849e568c2d52765c0c833f63a48035e4 | ocelot-saas/clock | /src/clock/clock.py | 1,630 | 3.59375 | 4 | """Datetime setup useful for IoC usage. Inspired by Dart-quiver's Clock."""
import datetime
import pytz
def _system_time():
"""Standard time function which produces a datetime object in UTC.
Returns:
A datetime.datetime object representing the current time in UTC.
"""
return datetime.datetime... |
39c6cf72d27d1444e7fcb21d611ee5673a32b9f1 | fsicardir/sorting-algorithms | /mergeSort.py | 624 | 4.125 | 4 |
# Time complexity: O(n*log(n))
# Space complexity: O(n)
# Stable
def merge_sort(arr):
def merge(list1, list2):
i, j = 0, 0
merge = []
while i < len(list1) and j < len(list2):
if list1[i] > list2[j]:
merge.append(list2[j])
j += 1
else:... |
4091bcc289879949f1a710540781edc9282a025a | JeeyaTalati/ATM-Python | /ATM.py | 756 | 3.765625 | 4 | class ATM():
def __init__(self):
self.ATMNumber=""
self.pinNumber=""
self.Amount=""
def enterATMNumber(self):
self.ATMNumber=int(input("Enter Your ATM Number"))
def enterPinNumber(self):
self.pinNumber=int(input("Enter Your Pin Number"))
def enterAmou... |
e2d356c860fcd0d8b0c21f70aeb2dc02199db310 | WebDevRoadie/OOP-practice | /User_Bank_Accounts.py | 1,466 | 3.84375 | 4 | class BankAccount:
def __init__(self, int_rate=0, balance=0):
self.int_rate = int_rate
self.balance = balance
def deposit(self,amount):
self.balance += amount
return self
def withdraw(self,amount):
if self.balance >= amount:
self.balance -= amount... |
99739b713274c1a7ff184b82d4f8ce0263b39783 | NanoRocket/cs50 | /pset6/sentiments/application.py | 1,804 | 3.578125 | 4 | """
In this file is a "controller" for a Flask-based web app with two endpoints: / and /search.
The first displays the simplest of forms via which you can search for a user on Twitter by
screen name. The second displays one of those pie charts categorizing that user’s tweets.
"""
from flask import Flask, redirect, r... |
0c8b0a46db2f57c7c1a9232e838c6b652ed6d342 | shahsagu787/PythonEssential | /LU Python Day 2.py | 369 | 3.75 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
print("Hello world")
# In[6]:
print("hello python")
# In[12]:
print("python's world")
# In[14]:
print('Python\'s world')
# In[16]:
x=10
y=20
print(x)
print(y)
print(x>y, x<y, x<=y, x>=y)
print(x+y, x-y, x//y, x/y, x**2, y%x)
# In[19]:
a=x&y
b=... |
04a20e6ce697b29460d823c6867b8432874249c9 | chejerlakarthik/PythonExercises | /Exercises/generator_func.py | 626 | 3.953125 | 4 | def isprime(n):
if n==0:
return False
elif n in (2,3):
return True
else:
for i in range(2,n+1):
if n%i==0 and i!=n:
return False
return True
def primes_yield(n=1):
while True:
if isprime(n): yield n
n = n + 1
if __name__ == '... |
baa648fbc217616042bccd431787c762b2e8fc47 | wxhheian/lpthw | /ex41e.py | 2,047 | 4.59375 | 5 | ###继承####
#继承是一种创建新类的方式,在python中,新建的类可以继承一个或多个父类,父类又称为基类 或超类,新建的类称为派生类或子类
#继承分为单继承和多继承
# class ParentClass1: #定义父类
# pass
#
# class ParentClass2: #定义父类
# pass
#
# class SubClass1(ParentClass1): #单继承,基类是ParentClass1 派生类是SubClass1
# pass
#
# class SubClass2(ParentClass1,ParentClass2): #多继承
# pa... |
906479df06633e9d91fc3f452526d21ce546ca25 | wxhheian/lpthw | /ex20.py | 1,393 | 4.0625 | 4 | from sys import argv
script, input_file = argv
def print_all(f): #这里定义f是一个file object
print(f.read()) #read()读取文件
def rewind(f):
f.seek(0)
def print_a_line(line_count,f):
#print(line_count,f.readline(),end='') #思考输出结果为为什么多出一个空行,因为readlin... |
ad23f579580ec4156bfd7d8536c7541acb99ea10 | wxhheian/lpthw | /ex25.py | 5,888 | 4.46875 | 4 | def break_words(stuff):
"""this function will break up words for us.""" ##“”“”放在定义函数里相当于注释 在python环境下运行help(ex25) help(ex25.break_words) (先要import ex25)
words = stuff.split(' ') #以空格为分割符 split()返回的是一个list
return words ... |
74ac94dfe89fd9c4ccb25422155efe36502d7137 | Gopsee/LeetCode | /AddDigits/AddDigits.py | 341 | 3.53125 | 4 | class Solution:
def addDigits(self, num: int) -> int:
counter = 0
while(counter < len(str(num))+1):
summ = 0
for x in (str(num)):
summ += int(x)
print(summ)
num = summ
counter += 1
... |
98d70d1b4e24bd72f4593243fda43e133a58bc25 | Kimyechan/codingTestPractice | /programmers/JadenCase 문자열 만들기.py | 358 | 3.703125 | 4 | def solution(s):
answer = ""
flag = 0
for w in s:
if w == " ":
answer += " "
flag = 0
else:
if flag == 0:
answer += w.upper()
flag = 1
else:
answer += w.lower()
return answer
print(solutio... |
6cbe9e9514d288965c8aa80a1ec9104ee40d4dcc | Kimyechan/codingTestPractice | /programmers/뉴스 클러스터링.py | 2,488 | 3.53125 | 4 | # check
from collections import defaultdict
def solution(str1, str2):
str1 = str1.lower()
str2 = str2.lower()
set1 = set()
dict1 = defaultdict(int)
for i in range(len(str1) - 1):
isAlphabet = True
for j in str1[i:i + 2]:
if ord(j) < ord('a') or ord(j) > ord('z'):
... |
93cbea91e3d55eccd75e29087b517f1ae62d6e3a | Kimyechan/codingTestPractice | /programmers/고득점Kit복습/hash/위장.py | 423 | 3.640625 | 4 | from collections import defaultdict
def solution(clothes):
clotheKinds = defaultdict(int)
for clothe in clothes:
clotheKinds[clothe[1]] += 1
clotheCombinationCount = 1
for count in clotheKinds.values():
clotheCombinationCount *= (count + 1)
return clotheCombinationCount - 1
pr... |
5de700a84e79299a1cdaded5c60b016c815ab2e9 | Kimyechan/codingTestPractice | /programmers/고득점Kit복습/bfs-dfs/타겟 넘버.py | 864 | 3.59375 | 4 | def dfs(idx, numbers, target, result):
if idx == len(numbers) and result == target:
return 1
if idx == len(numbers):
return 0
count1 = dfs(idx + 1, numbers, target, result + numbers[idx])
count2 = dfs(idx + 1, numbers, target, result - numbers[idx])
return count1 + count2
def so... |
36ff03f829f2b8c2527662a77537de270d76e988 | Kimyechan/codingTestPractice | /programmers/DP/도둑질.py | 908 | 3.5 | 4 | def solution(money):
getMoney = [0] * len(money)
# 첫번째집 방문
getMoney[0] = money[0]
getMoney[1] = money[0]
for i in range(2, len(money) - 1):
getMoney[i] = max(getMoney[i - 1], getMoney[i - 2] + money[i]) # 이전집 방문 했을 때, 안했을 때 중 최대값
visit_first = getMoney[-2]
# 첫번째집 방문 X, 두번째집 방문 O
... |
9eca79432f8da539e8f2e576fb8f53eb33b316cf | Kimyechan/codingTestPractice | /baekjun/단어 정렬하기.py | 475 | 3.53125 | 4 | from collections import defaultdict
N = int(input())
strList = list()
for _ in range(N):
strList.append(input())
strList = set(strList)
strList = list(strList)
newStrList = sorted(strList, key=lambda x: len(x))
d = defaultdict(list)
for ns in newStrList:
if len(ns) in d.keys():
d[len(ns)].append(n... |
2f98e5d2b096ad2de542b2c5262c1a0b8aa14f18 | Kimyechan/codingTestPractice | /baekjun/back-tracking/N과 M (1).py | 488 | 3.5 | 4 | n, m = map(int, input().split())
result = []
def backTracking(numMax, numberLen, numberList):
if len(numberList) == numberLen:
result.append(numberList[:])
return
for num in range(1, numMax + 1):
if num not in numberList:
numberList.append(num)
backTracking(num... |
443129b52e799fdece0f19b3c4510d0018aafbc4 | dbhoan/personal_finance | /merge.py | 19,872 | 3.859375 | 4 | # -*- coding: utf-8 -*-
# Author: Hoan Bui Dang
# Python: 2.7
"""
Merge csv data from different bank accounts together in a standard format.
Follow the instruction for reading csv files for each account in accounts.csv.
"""
import numpy as np
import pandas as pd
import re # for regex
import glob # for fi... |
859cd866c4ded684850250819211c7f53d7fc6d8 | saisai/dhamma-upload | /future/DhammaDara-Dr-Kumara-mp3-myanmar/other/dd.py | 2,836 | 3.71875 | 4 | from PIL import Image, ImageDraw, ImageFont
#variables for image size
#img = Image.open("photo-001.jpg")
#img = Image.open("photo-004.jpg")
img = Image.open("photo-003.jpg")
#img = Image.open("photo-002.jpg")
#width, height = img.size
width, height = img.size
x1, y1 = img.size
height = y1
print('width', x1)
print('h... |
a7d494c37a77ff4aec474502cff553348d9e5c17 | alexander-zou/pycheats | /pyps/use_random.py | 1,548 | 4.3125 | 4 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@File : use_random.py
@Author : alexander.here@gmail.com
@Date : 2020-07-10 16:55 CST(+0800)
@Brief : https://docs.python.org/zh-cn/3/library/random.html
'''
from __future__ import print_function
import random
print( 'random.random() generates 0 <= X < 1... |
3b28032599142789a5ed60d109f93c9fc874c611 | aelkugia/machineLearning | /KNN.py | 2,890 | 3.828125 | 4 | #CS7641: Machine Learning
#Fall 2018
#aelkugia3
#k-nearest neighbors
#Citation: https://stackabuse.com/k-nearest-neighbors-algorithm-in-python-and-scikit-learn/
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import time
dataset = pd.read_csv("/Users/aelkugia/Documents/GeorgiaTech/CS7641... |
5771c4fdd110d2ae399673bc697fce911956cca2 | Samrat0009/Python_REPO2 | /#18 LinkedList-2/ReverseList_imporvedTC.py | 2,408 | 3.796875 | 4 | # Basically we remove Traversal within the list!!
from sys import stdin, setrecursionlimit
setrecursionlimit(10 ** 6)
#Following is the Node class already written for the Linked List
class Node :
def __init__(self, data) :
self.data = data
self.next = None
def length(head):
length... |
63cc17bccc942451947cf4ad62704b49558f4a92 | Samrat0009/Python_REPO2 | /#17 LinkedList-1/Insert_@_ith_Posn.py | 1,308 | 3.640625 | 4 | class node:
def __init__(self, data):
self.data = data
self.next = None
def takeInput():
inputList = [int(x) for x in input().split()]
head = None
tail = None
for element in inputList:
if element == -1:
return head
newNode = node(element)
... |
972945730dc292b04d6a86ced077be218b615dce | Samrat0009/Python_REPO2 | /#22 BinaryTrees_2/CoonstructTreeUsingInOrder,Postorder.py.py | 2,575 | 4.09375 | 4 | #For a given postorder and inorder traversal of a Binary Tree of type integer stored in an array/list, create the binary tree using the given two arrays/lists. You just need to construct the tree and return the root
10/19/2020 Coding Ninjas
https://classroom.codingninjas.com/app/classroom/me/1805/content/31530/of... |
7f4af534f28f1a27fe6fb2675cfe145e73296e32 | Samrat0009/Python_REPO2 | /#21 BinaryTrees_1/1.Creating_BinaryTree, Node.py | 378 | 4.0625 | 4 | class BinaryTreeNode:
def __init__(self,data):
self.data = data
self.left = None
self.right = None
btn1 = BinaryTreeNode(1)
btn2 = BinaryTreeNode(4)
btn3 = BinaryTreeNode(5)
btn1.left = btn2
btn1.right = btn3 # since trees are very simple structures you w... |
9a84af3077b599c11231def2af09cb8ccf40141c | stavernatalia95/Lesson-5.3-Assignment | /Exercise #1.py | 448 | 4.5 | 4 | #Create a function that asks the user to enter 3 numbers and then prints on the screen their summary and average.
numbers=[]
for i in range(3):
numbers.append(int(input("Please enter a number:")))
def print_sum_avg(my_numbers):
result=0
for x in my_numbers:
result +=x
avg=result/le... |
6fc70f3792f3833adc049aa248996c9896d74574 | MartaVohnoutovaBukovec/IOS-655-Python-a-Bash | /base_to_base.py | 338 | 3.90625 | 4 | # any base to any base function example
# Function definition is here
def base_to_base(s_in,b_in,b_out):
return str_base(int(str(s_in),b_in),"0123456789abcdefghijklmnopqrstuvwxyz"[:b_out])
def str_base(number, base):
(d,m) = divmod(number, len(base))
if d > 0:
return str_base(d,base)+base[m]
... |
151b1a22a65754d5b9a30a3581c4549f40dc8f6e | MartaVohnoutovaBukovec/IOS-655-Python-a-Bash | /IOS 655 Python a Bash/homework/Moser/mCipher.py | 1,185 | 3.96875 | 4 | def decryptLetter(letter, keyLetter):
if(letter.islower()):
intValueA = ord('a')
intValueZ = ord('z')
keyLetter = keyLetter.lower()
else:
intValueA = ord('A')
intValueZ = ord('Z')
keyLetter = keyLetter.upper()
intValue = ord(letter) - ord(keyLetter) + intValueA
if(intValue < intValueA):
int... |
049e6a9063320992e33937759562c188987f7b52 | MartaVohnoutovaBukovec/IOS-655-Python-a-Bash | /IOS 655 Python a Bash/homework/Anna.Drechslerova/HW5-base to base.py | 1,260 | 4.0625 | 4 | # input information
# input note = only numbers and capital letters are used in lists
number_input = input("Please enter a number: ")
from_base = int(input("Enter the base FROM which you would like to convert the number: "))
to_base = int(input("Please enter the base TO which you would like to convert your number... |
40efd9861b0e0999cf455b48a9e3a633fb98c7dd | MartaVohnoutovaBukovec/IOS-655-Python-a-Bash | /Electronic_station_army-battles_Marta.py | 5,828 | 3.53125 | 4 | # Electronic station https://py.checkio.org/en/mission/army-battles/
# moderate
# marta
# Army battels
# Marta Vohnoutova
'''
Moderate
English RU
...Sir Ronald’s opponent - Umbert, has proved to be a very skillful warrior.
In addition, he was a good fifteen years younger, which gave him a
certain advantage. But Sir... |
f12b105f1b001009fc1de1a5e4c2c2838f4a79ad | linjorejoy/Calulating-the-digits-of-pi | /Gregory-Leibiniz Series-V.py | 792 | 3.890625 | 4 |
import math
def getPi(noOfIter):
piValue = 1
for i in range(1,noOfIter+1):
piValue += (-1)**i * math.pow(math.pow((2*i+1),3),-1)
return math.pow(piValue*32,1/3)
valueOfPi = getPi(10)
print("{0:.50f} and difference is {1}".format(valueOfPi, valueOfPi-math.pi))
valueOfPi = getPi(100)
print("{0:.5... |
acae54c3c5044fcc6714bdf54ac80f984314a91b | linjorejoy/Calulating-the-digits-of-pi | /taninverse.py | 932 | 3.765625 | 4 | """ This is from the inverse trignometric function tan inverse
and its expansion
"""
import math
def getPi(stepCount):
stepSize = 1/stepCount
piValue = 0
xValue = 0
while xValue<=1:
piValue += stepSize/(1+xValue**2)
xValue += stepSize
piValue *= 4
return piValue
valueOfP... |
10b85c70c124009eb6417092b08669a547b988a2 | Pierina0410/t09_palacios_salazar | /salazar/libreria.py | 2,769 | 3.6875 | 4 | # Anderson - Librerias de funciones
#1. Funcion que devuelve el area del rectangulo
def area_rectangulo(base, altura):
resultado = (base*altura)
return resultado
#fin_def
#2. Funcion que devuelve la suma de 2 numeros
def suma(a,b):
resultado=a+b
return resultado
#fin if
#3. Sacar la mitad de un numer... |
be9cb55825f7b8c1fd73cb64ba0adcacaa912f05 | Lumiere2304/Programming-Principles-2-Summer-course- | /TSIS1 (Lecture 1)/Python While Loops.py | 361 | 3.828125 | 4 | # Exercise 1:
i = 1
while i < 6:
print(i)
i += 1
# Exercise 2:
a = 1
while a < 7:
print(a)
if a == 3:
break
a += 1
# Exercise 3:
b = 1
while b < 4:
b += 1
if b == 6:
continue
print(b)
# Exercise 4:
c = 1
while c < 6:
print(c)
c += 1
else:... |
45008b0567d53e3a59c71d288b015ad6e6c1f96d | Lumiere2304/Programming-Principles-2-Summer-course- | /TSIS1 (Lecture 1)/Python If...Else.py | 859 | 4 | 4 | # Exercise 1:
a, b = 3, 4
P = (a + b) * 2
S = a * b
if P > S:
print("P is greater than S")
else:
print("P is not greater than S")
# Exercise 2:
a, b = 2077, 2021
if a != b:
print("Cyberpunk 2077")
# Exercise 3:
a, b, c = 3, 4, 5
if a**2 + b**2 == c**2:
print("Yes")
else:
print('... |
31dc0deef692df210a04af87695bd09c5d6691d3 | Sannan-Uzair/Matplotlib | /plt.py | 1,210 | 3.703125 | 4 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.linspace(0,5,10)
y = x**2
plt.plot(x,y)
plt.title("Days Squared Chart")
plt.xlabel("Days")
plt.ylabel("Days Squared")
plt.subplot(1,2,1) # 1 Row 2 Column and 1 plot
plt.plot(x,y,'r')
plt.subplot(1,2,2)
plt.plot(x,y,'b')
# plt.show()
fig1 =... |
2969c536a48af976fdbd6f9beefe62c9b49fd1c8 | Bijay555/innomatics-Apr21-internship | /Task-Week-2/Task-2/Set_union().py | 211 | 3.671875 | 4 | # Set .union() Operation
# Enter your code here. Read input from STDIN. Print output to STDOUT
n=int(input())
a = set(map(int, input().split()))
m=int(input())
b = set(map(int, input().split()))
print(len(a|b)) |
be34aa7a3e70f2ed5f2916f0bb600ea65271db52 | Bijay555/innomatics-Apr21-internship | /Task-Week-2/Task-5/Detect_Floating_Point_Number.py | 127 | 3.640625 | 4 | #Detect Floating Point Number
import re
for _ in range(0, int(input())):
print(bool(re.match(r"^[-+]?\d*\.\d+$",input()))) |
8b869ea6996eac4a96f04fcc76f3d33784b61508 | Paladin-of-divine-windows/python-start | /spiral_turtle.py | 157 | 3.890625 | 4 | import turtle
distance = 0.5
turtle.shape("turtle")
for x in range (1, 150):
if x % 2 == 0:
distance += 0.5
turtle.forward(distance)
turtle.left(30) |
0c04193537a78b060b472040a77b13b653702654 | Paladin-of-divine-windows/python-start | /spider_turtle.py | 185 | 3.859375 | 4 | import turtle
n = 13
turtle.shape("turtle")
for i in range (n):
turtle.forward(100)
turtle.stamp()
turtle.left(180)
turtle.forward(100)
turtle.left(180)
turtle.left(27.6923076)
|
6b6ff99c9b606c4867d55b064c0e3a151c25ed61 | cwsaunders/ai-ml | /educational/twt_code_and_notes/hidden_markov.py | 1,153 | 3.75 | 4 | import tensorflow as tf
# Hidden Markov Models
'''
Hidden Markov Models
"The Hidden Markov Model is a finite set of states, each of which is associated with a (generally multidimensional)
probability distribution []. Transitions among the states are governed by a set of probabilities called transition probabilities."
... |
99f42b7b645ca44b13a708feeba295199f29a3fa | Naleliwi/Python-Crash-Course | /Chapter 2 - Loops/For_range.py | 197 | 4.0625 | 4 | print ('my name is')
# range method works as a counter , it always start with 0
for i in range (5):
print ('Print Noof five times ' + str(i))
# The program print i as 0 , 1 , 2 , 3 , 4
|
7489e5bb17bcff820a4e438f415b5a1b9f6ea35a | Chia-Network/chia-blockchain | /chia/util/math.py | 463 | 3.78125 | 4 | from __future__ import annotations
from typing import List
def clamp(n: int, smallest: int, largest: int) -> int:
return max(smallest, min(n, largest))
def make_monotonically_decreasing(seq: List[float]) -> List[float]:
out: List[float] = []
if len(seq) > 0:
min = seq[0]
for n in seq:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.