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
cf8e7e6f5dd8af275d9effed0319bd551c9b7ba9
tomelisse/ESS
/animals.py
712
4.03125
4
class Bird(object): ''' class for individual birds ''' _max_age = 1 # thresholds for increasing numer of offspring _thr1 = 50 _thr2 = 100 _thr3 = 150 def __init__(self): ''' bird's characteristics ''' self.age = 0 self.HP = 100 def litter(self): ...
283aa771a824074e7947c09c53c6ea308faf0692
HariMuthu/Python_Code
/Code/linecount.py
307
3.96875
4
sname = input('Enter the file name to be counted : ') sfile = open(sname) count = sum( 1 for line in sfile) print('No of lines : ', count) #sfile.close() ##rfile = open(sname) sfile.seek(0) for i in range(1,count+1): str = sfile.readline() print('No of words in line %d is ' %i, len(str)) sfile.close()
f891215f068d1bf0e75cf525a158d0f429812f45
gvamsi/Hacker-rank
/hfu.py
419
3.765625
4
import sys def hackon(n): if n == 1: return 1 if n == 2: return 2 if n == 3: return 3 if n>3: return ( 1*hackon(n-1) + 2*hackon(n-2) + 3*hackon(n-3) ) def main(): n = int(raw_input()) for i in range(1,n+1): val = hackon(i) print i if (val%2 == 0)...
ea2f56a76f377153c762373f926b473aa45ea393
vincentbuit/sudoku-solver
/find_y.py
211
3.5
4
def find_y(sudoku): all_y_rows = [] for x in range(0, 9): row = [] for y in range(0, 9): row.append(sudoku[y][x]) all_y_rows.append(row) return all_y_rows
08f945bcd04793e37f247a5ac77954d478346c5f
jessetutor97/adventofcode
/day6/main.py
2,013
3.78125
4
from linkedlist import LinkedList # Takes a LinkedList object and returns a python list def getConfig(linkedList): list1 = [] nodePtr = linkedList.getFront() for i in range(linkedList.getSize()): list1.append(nodePtr.getData()) nodePtr = nodePtr.getLink() return list1 def main(): ...
16d4ed4418854e4bb7b629636dd76873309c7490
explocomposer/TP
/menu.py
251
3.59375
4
running = True def start(): print('aplication lancée') def quit(): global running running = False while running: state = input('start/quit ') if state == 'start': start() elif state == 'quit': quit()
f7908cac40fdf81c60044beb85677c92f53f4933
cdferguson4/Pandas
/PandasSeries.py
568
3.5625
4
import pandas as pd #1 demensional############################################################ grades = pd.Series([87, 100, 94]) # print(grades) grades2 = pd.Series(98.6, range(3)) # print(grades2) grades = pd.Series([87, 100, 94], index=['Walley', 'Eva', 'Sam']) grades = pd.Series({'Walley': 87, 'Eva': 100, 'Sa...
18a1e688a3a00b1892e16a73c56248ddc846030d
mogproject/mog-cli
/scripts/magic_util.py
1,323
3.765625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """Utilities for finding magic number""" usage = """ Usage: Use functions in the Python REPL. Example: $ python3 >>> from scripts.magic_util import * >>> x2i(0x0080200802008000) [15, 25, 35, 45, 55] >>> i2x([15, 25, 35, 45, 55]) 36064015784378368 """ from ...
5453d424776a83369a00769284b506bdd1764ff2
amw-zero/algorithms
/searching/bfs.py
1,189
3.65625
4
class Node: def __init__(self, v): self.value = v self.neighbors = [] def print_visited(visited): print("Visited:") for k, v in visited.items(): print('{}, {}'.format(k.value, v)) na = Node('a') nb = Node('b') nc = Node('c') nd = Node('d') ne = Node('e') nf = Node('f') ng = Node('g...
f3800fa90c5cae9b793c430634abba58fa0ec2bd
noelpdot/Election_Analysis
/PyPoll.py
4,141
4.28125
4
# Add dependencies import csv import os # Assign a variable for the file to load and the path file_to_load = os.path.join("Resources","election_results.csv") #file_to_load = 'Resources/election_results.csv' # This code is to write a file to a direct or indirect path to the file. file_to_save = os.path.join("analysi...
39066ed1d33d50b9fa6c3d2b4c0273b5774d8207
Madhumithapriya/Madhumitha
/string numeric.py
178
4.15625
4
# Python code for implementation of isnumeric() # checking for numeric characters string = '123ayu456' print(string.isnumeric()) string = '123456' print( string.isnumeric())
d6f1a9962420c067210c73cd6a548684ae0557a5
massich/exercism-xpython
/leap/leap.py
236
3.671875
4
def is_leap_year(y=1): _is_divisible = lambda x: y%x == 0 answer = True if _is_divisible(4) else False answer = False if _is_divisible(100) else answer answer = True if _is_divisible(400) else answer return answer
056c90136c6bf33ec10ce306c98d793bd213681d
StepicOrg/submissions-clustering
/subsclu/primitives/tree.py
3,839
4.15625
4
"""Implementation of simple tree.""" from collections.abc import Set from itertools import chain __all__ = ["Tree"] class Tree(Set): """The tree class itself, nothing special.""" def __init__(self, value, children=None): """Create tree node (i.e, tree) with value and children. Args: ...
79d9d7e7100de9616d41e5ef02315c2adbcd22ad
woodenbrick/wedding
/blog/xmlparser.py
2,157
3.765625
4
#!/usr/bin/env python import xml.etree.ElementTree as ET import os class XML_Parser(object): def __init__(self, xml_doc, wanted_data, wanted_attrib = {}): """Parses an xml document. wanted_data is all the tags that you wish to parse, including the tags of attributes. Send a dictionary of wanted_a...
5d58f4313ec979113d68ee9800f67c0bb8a19925
smoh/mpltools
/io.py
1,256
3.546875
4
""" Functions related to I/O """ import urllib import os, errno from urllib2 import urlopen, URLError, HTTPError __all__ = ['mkdir_p', 'downloadfile'] def mkdir_p(path): """ Mimic mkdir -p """ try: os.makedirs(path) except OSError as exc: # Python >2.5 if exc.errno == errno.EEXIST...
5c773bead4c91bd8a50fb5441f9631cbe9edc027
yurizirkov/PythonOM
/if.py
657
4.125
4
answer = input("Do you want to hear a joke?") #affirmative_responses = ["Yes", "yes", "y"] #negative_responses = ["No", "no", "n"] #if answer.lower() in affirmative_responses: #print("I am against picketing, but I do not know how to show it.") #elif answer.lower() in negative_responses: #print("Fine") #i...
bf8a90d0cd1474a203f5ac587440efe161bcb070
OmahTI-UGM/HacktoberFest2020
/Python/simpson.py
749
3.71875
4
import math from sympy import var from sympy import sympify def func(x): res = expr.subs(varx, x) return res def simpsons(a, b, n): h = (b - a) / n hasil = 0 i = 0 while i <= n: x = a + i * h fx = func(x) if i == 0 or i == n: hasil += fx elif i % ...
2dabe72bf403b814caf5d768f741547b19cbdb8b
kelvi5/Kelio
/Python/CriptografiaCesar.py
440
3.75
4
#lista de letras para criptografar alfabeto = "abcdefghijklmnopqrstuvwxyz" #a chave secreta é 3 chave = 3 contador = 0 while(contador<70): letra = input("Por favor, entre com uma letra para criptografar: ") posicao = alfabeto.find(letra) novaPosicao = (posicao - chave) % 26 letraCriptograf...
f8438365436386b268117e0848590c03b1a6c1fb
oceancoll/leetcode
/排序算法/answer.py
5,396
3.53125
4
# coding:utf-8 """八大排序算法""" a = [2,5,1,3,8,5,7,4,3] """ 冒泡法 左右两个数据进行对比,大的数据位于右侧,小的数据位于左侧 每一次排序会选出剩余数的最大值 时间复杂度为:n^2,稳定 """ def maopao(origin): count = len(origin) for i in range(count): for j in range(count-i-1): if origin[j] > origin[j+1]: origin[j], origin[j+1] = origin[j+...
173dd4e3cd270868929cbf1dbc7e2d77a3c4718d
oceancoll/leetcode
/回溯法模版化/八皇后/answer.py
1,344
3.65625
4
# coding:utf-8 """ 八皇后问题: 如何能够在 8×8 的国际象棋棋盘上放置八个皇后,使得任何一个皇后都无法直接吃掉其他的皇后? 为了达到此目的,任两个皇后都不能处于同一条横行、纵行或斜线上。 """ # 皇后个数1 n = 8 # 一个解 x = [] # 解的集合 X = [] # 剪枝函数 def conflict(k): global x # 遍历已经确定的前k-1的值,是否与k行有冲突 for i in range(k): # 上述条件的检验标准: # 不能位于同一行已满足条件(queen_list的index) # 不能位于同一列:...
84f8e8369bfc1f1ec36ac803e2f9b6515bfb7ebd
oceancoll/leetcode
/365.水壶问题/answer.py
531
3.625
4
# coding:utf-8 # 计算最大公约数 def gcd(x,y): # 辗转相除法 # 通过判断两数相除的余数来判断是否能够整除 tmp = x % y while tmp != 0: x = y y = tmp tmp = x % y return y def canMeasureWater(x, y, z): """ :type x: int :type y: int :type z: int :rtype: bool """ if x == 0 or y == 0: ...
10df31af91fbc8d6fe4fbf088d40a5160725f860
oceancoll/leetcode
/剑指offer/求1+2+3+...+n/answer.py
614
3.984375
4
# coding:utf-8 """ 求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C) https://leetcode-cn.com/problems/qiu-12n-lcof/solution/mian-shi-ti-64-qiu-1-2-nluo-ji-fu-duan-lu-qing-xi-/ """ class Solution: """ 根据递归的思想 if n==1:return 1 n+=Sum_Solution(n-1) return ct 因为不能使用if 故使用n>1 an...
722f114e2362b56f465300a22806bb0595bf46db
oceancoll/leetcode
/动态规划-不同路径/answer.py
680
3.734375
4
# coding:utf-8 """ 一个机器人位于m*n的左上角,要到右下角去,一共有多少种方法 """ def uniquePaths(m,n): """ 使用动态规划的方法,记录到达每一个点的有多少种不同方法 则某点的多少种方法等于,该点上面点的方法次数+左边点的方法此次 最后右下角的点对应的次数,即为总的次数 """ result = [[1 for _ in range(n)] for _ in range(m)] # 因为左上角是起始点,所以从非左上角的点开始 for i in range(1,m): for j in range(1,n):...
860585c1e869ece8229dfa9cb6b2e7ca1ca7f1ae
oceancoll/leetcode
/最长无重复子数组/answer.py
783
3.90625
4
# coding:utf-8 """ 给定一个数组,找出最长的无重复子数组的长度是多少 输入:[1,2,3,1,2,3,2,2] 输出:3 输入:[2,2,3,4,8,99,3] 输出:5 思路: 用一个临时数组,存当前满足周期内的数。 注意:当遇到相同值时,从相同值的地方进行截断,相当于是又一轮的开始 比如[7,8,9,1,2,3,1,2,3],遇到第二个1时,从第一个1的位置进行截断,从而可以继续累加第2次的1 """ def maxLength(arr): maxl = 0 tmps = [] for i in arr: if i in tmps: ...
01facab0bddc2a4f52e65cd74c3a64fc2c0e6d39
pranavmswamy/leetcode
/mathworks/rightSideViewBinaryTree.py
1,200
3.96875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def rightSideView(self, root: TreeNode) -> List[int]: ans = list() # edge case if no...
8ccbd64015712d9a9110b8c8b499a838e0039187
pranavmswamy/leetcode
/implementPrefixTreeTrie.py
2,924
4
4
class Trie: def __init__(self): """ Initialize your data structure here. """ self.end = False self.trie = list() def insert(self, word: str) -> None: """ Inserts a word into the trie. """ cur_trie = self # iterat...
1945e703d5675a5d4341f5ee17a13d4fe82cbb49
pranavmswamy/leetcode
/mathworks/countingBits.py
1,911
3.828125
4
class Solution: def countBits(self, num: int) -> List[int]: result = [0]*(num+1) # when the number is odd, then the last bit is 1 # so the number of 1's in it are 1 + number if ones in number-1 since number-1 will be the even number that has same 1's except the last one. ...
37df76b9dcdbfc108b3b6820d4a65b08904dc847
pranavmswamy/leetcode
/maxPathSumBinaryTree.py
1,682
3.96875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def __init__(self): self.max_val = float('-inf') # because there are negative values in the tre...
9aa7d3d29548e026e260cbbae28e79ae8e3076a5
pranavmswamy/leetcode
/mathworks/rectangleOverlap.py
2,472
3.90625
4
class Solution: def isRectangleOverlap(self, rec1: List[int], rec2: List[int]) -> bool: # sort x coord for rec1 and rec2 # sort y coord for rec1 and rec2 # if both intersect, then the rectangles overlap. rec1_x = sorted([rec1[0], rec1[2]]) rec1_y = sorted([rec1[1], r...
2c8bbac71b1d442d7c71ddfef8f167d778d91d4a
pranavmswamy/leetcode
/mathworks/verticalOrderTraversal.py
767
4.0625
4
def verticalOrderTraversal(root): # keep track of dist wrt 0 for root node. # if you go left, do level-1 # if you go right, do level+1 # collect all nodes of the same level in the dict # print them. # keep track of min and max level so that it helps you to print later. vertical = dict() max_left = 0 max_right...
853f36d2b70faaf0757768ca1467d70ab38d6c91
pranavmswamy/leetcode
/mathworks/numberOfOperationsToMakeConnectedNetwork.py
1,255
3.78125
4
class Solution: def makeConnected(self, n: int, connections: List[List[int]]) -> int: # find number of connected components in the network # number of connections reqd = number of connected components - 1 # this is a simple graph connected components question # if the number...
d612f9d9df965a834ec802522f0678840926f733
tree3205/Projects
/my_projects/1024Spark/minispark_bass/topByKey.py
2,742
3.546875
4
from heapq import * import heapq class MyHeap(object): # order: # True:maxHeap, ascending, low to high # False:minHeap, descending, high to low def __init__(self, n, key=lambda x: x, order=True): self.key = key self.n = n self._data = [] self.order = order def pu...
ced70907f86305d93474600493c0dd4a19f21e87
Booja97/python
/Day1/while.py
147
4.1875
4
print("Enter the range of number to be printed:") range= int(input()) number=1 while number <= range: print(number, end=' ') number+=1
8f894adbd809129076bbe7f3ae8d4dab5089bd48
Booja97/python
/Day1/fizzBuzz.py
170
3.96875
4
for i in range(1,100): if i%3 == 0 and i%5 ==0 : print("FizzBizz") elif i%3==0 : print("Fizz") elif i%5==0 : print("Bizz") else: print(i)
408db23d89a5c83244807c8bc6ca55d0319f7982
satyam1075/Python-Starter
/Dictionary.py
8,882
4.21875
4
#import copy #Dictionary in Python --> #1.Python dictionary is an unordered collection of item. #2.While other compund data types have only value as an elemnet a dictionary has a key value pair #3. Dict are optimized to retrieve values when the key is known #How to create dict #Creating a dictionary is as sim...
54350fa18acd1e86e8fcb6170501f035596a10c6
hushenghua/HH_PY_Lib
/HH_File_Lib.py
2,909
3.78125
4
# -*- coding: utf-8 -*- """ --- 当年万里觅封侯,匹马戍梁州。--- HH 私人订制Python开发库 -- 文件处理开发库 -- 1,文件处理开发库 基准库数据处理接口库: 数据文件处理,csv,txt,excel.处理成 xy train test数据。对数据处理结果进行输出层csv txt excel数据。 数据处理对来自于数据库的或者api json/xml等的格式输入输出处理。 接口API封装开发。 2,算法库: 各种算法封装为 fit, score, result。 参数设定输入。 3,算法整合库,自动调参: 对参数的自动校正,根据结果评判,自动调参。...
d4f4ec48ce1fdd652422baed9b9c3e0128d85b51
hansinla/Euler
/Euler problem 17.py
1,622
4
4
""" If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used? NOTE: Do not count spaces or hyphens. For example, 342 (t...
3d52861bb592cc8477d05928a291a882a1dc8635
hansinla/Euler
/Euler problem 30.py
594
3.9375
4
""" Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits: 1634 = 1^4 + 6^4 + 3^4 + 4^4 8208 = 8^4 + 2^4 + 0^4 + 8^4 9474 = 9^4 + 4^4 + 7^4 + 4^4 The sum of these numbers is 1634 + 8208 + 9474 = 19316. Find the sum of all the numbers that can be written a the sum ...
767b3997ef0a6723f02bb295145b6f846e203de5
hansinla/Euler
/Euler problem 42.py
1,644
4.09375
4
""" The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1); so the first ten triangle numbers are: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... By converting each letter in a word to a number corresponding to its alphabetical position and adding these values we form a word value. For example, the word...
753f1b05e2c5a1bee07f5c8593a39c01dc0a3e34
freephys/algo
/binarySearch.py
1,779
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Jul 17 15:45:57 2021 @author: Josh Liu """ def searchLeft(nums, target): """ Binary search that returns the minimum index i, such that A[i] >= target. If no such element exists, return N, the length of A. Input: A, a list of elements to be ...
2d407f545a8a94c6394281cd9bbee377e91990b5
MohamedKari/dbit
/retail.py
886
3.78125
4
class Product: # Constructor, wird ausgeführt, wenn die Klasse instanziiert wird def __init__(self, name, tax_rate, net_price): print("Product instantiated!") self.name = name self.tax_rate = tax_rate self.net_price = net_price def compute_gross_price(self): return round(self.tax_rate * s...
2696a5e722f7ff42849dc94be4ff1ba90b805db4
abhinavsharma629/Data-Structures-And-Algorithms-Udacity-Nanodegree
/Level 2/File Recurrsion.py
1,206
3.875
4
import os def find_files(suffix, path): #Using BFS for all dirs fin_list=[] '''----main_dir---- / \ \ / \ \ Level1 Level 2 Level 3''' # If given path exists if(os.path.exists(path)): #If isFile if(os.path.isfile(path)): #...
601de9a8c4650c6620f2fdb61762c11a16c38a5c
abhinavsharma629/Data-Structures-And-Algorithms-Udacity-Nanodegree
/Level 3/get_max_min.py
797
3.953125
4
import sys def get_min_max(ints): """ Return a tuple(min, max) out of list of unsorted integers. Args: ints(list): list of integers containing one or more integers """ mini=sys.maxsize maxi=0 for i in range(0, len(ints)): if(ints[i]>maxi): maxi=ints[i] if(ints[i]<mi...
5422fcd979390a85e2b9cc50c91f25f6757ac26e
balkon16/noisy_channel_model_thesis
/plewic_handler.py
10,787
3.5
4
import pprint import time pp = pprint.PrettyPrinter(indent=4) def parse_ruby_yaml_to_python_dict(file='plewic.01.0001.yaml'): """ changes Ruby-like YAML file to a list of dictionaries of dictionaries etc. The created dictionary has the following form: { text: , new_text: , att...
b11cb1ebe969611b74f196886519884cb6186588
GaoX2015/intro_ds
/ch02-python/mini_project/components/counter.py
429
3.5625
4
# -*- coding: UTF-8 -*- """ 此脚本用于实现计数器 """ def wordCount(data): """ 输入一个列表,统计列表中各个元素出现的次数 参数 ---- data : list, 需要统计的列表 返回 ---- re : dict, 结果hash表,key为原列表中的元素,value为对应的出现次数 """ re = {} for item in data: re[item] = re.get(item, 0) + 1 return re
f4e27ea2d7193f1044761fb3df780886abacb6b7
GaoX2015/intro_ds
/ch02-python/python_basic.py
2,828
3.859375
4
# -*- coding: UTF-8 -*- """ 此脚本用于展示Python的基础语法 """ # 保证脚本与Python3兼容 from __future__ import print_function import sys if sys.version_info[0] == 3: from functools import reduce else: pass # dict基本操作 ## 初始化一个dict类型变量x x = {"a": 1, "b": 2, "c": 3} print(x) ## 读取x中的一个元素,直接读取或者使用“get”方法 print(x["a"], ",", x.ge...
b3a62b58976604522bb7ca5d55151319c76b3b20
mmerrittsmith/markov_predictions
/hash_table.py
10,396
3.671875
4
''' MPCS 51042 S'20: Markov models and hash tables M. Merritt Smith ''' from map import Map from functools import reduce class Hashtable(Map): """ class Hashtable(Map): A class that implements a hash table in Python. Inherits from the Map abstract base class, implementing the functions laid out ther...
09dc986d6cf33b788f278e65be7e026a383b71dd
F3NYX-MX/Ejercicios_Python
/02_datatype.py
598
3.75
4
# Strings print('Hello world') print("hello world") print('''hello world''') print("""hello world""") print("hola" + "mundo") # Numbers print(10) # Float print(3.1416) # Boolean print(False) print(True) # List Lista de valores [10,89,45,78] [45,"Hello",78] [3.145,78,"Adios",True] # Tuples Lista de valor...
1c606279dfa71dcca90f2caa3d53f5eebba73c8b
F3NYX-MX/Ejercicios_Python
/matematicas.py
209
3.828125
4
#modulo con las funciones basicas de + - * / def sumar(n1, n2): print(n1 + n2) def resta(n1,n2): print(n1 - n2) def multiplica(n1, n2): print (n1 * n2) def divide(n1, n2): print(n1 / n2)
31f7fb543049400cd828cfb4e5d225191e92cb58
rajjaya29/PESU-IO-SUMMER
/4.py
204
3.671875
4
num = int(input("Input a four digit numbers: ")) x=num//1000 x1=(num - x*1000)//100 x2=(num - x*1000 - x1*100)//10 x3=num - x*1000 - x1*100 - x2*10 print("The sum of digits in the number is", x+x1+x2+x3)
af20aa7e3320a9b720e86ee904aac24bc3c38736
AveniusPL/Moje_projekty
/kalkulator.py
3,556
3.640625
4
print("Witaj w programie <|::Kalkultor::|>") def menu(): print (""" """) print ("""..::::::::::::::::::::.. || MENU || ..::::::::::::::::::::..""") print (""" """) print ("..:: 1 - dodawanie ::..") print ("..:: 2 - odejmowanie ::..") print ("..:: 3 - mnożenie ::..") ...
b40fa3ed7cfd83a46f24eaa9fbcc05b5ad35dee3
Xigua2011/mu_code
/names.py
278
4.28125
4
name = input("What is your name?") print("Hello", name) if name=="James": print("Your name is James. That is a silly name") elif name=="Richard": print("That is a good name.") elif name=="Anni": print("Thats a stupid name") else: print("I do not know your name")
c6575d47cd9f211b873715f4c4a18a4cea022d54
Xigua2011/mu_code
/game3.py
883
3.53125
4
# Draw a backround image with Krita, save it as png file # Draw an alien image, save it as png file # Draw a girl image, save it as png file import pygame joystick = pygame.joystick.Joystick(0) joystick.init() WIDTH = 600 HEIGHT = 600 background = Actor("background") alien = Actor("face") alien.x = 200 alien.y = 20...
33ff787eec64039c9c11849c70acde05ecde8672
Xigua2011/mu_code
/num2.py
170
3.65625
4
apples = 80 pears = 0 banana = 0 apples = apples + 1 apples = apples + 1 apples = apples + 1 apples = apples * 2 total = apples + pears + banana print("fruit is", total)
b50e4c6cc282a868e78a603fccb943a0e90d7bc9
Xigua2011/mu_code
/forloop.py
217
3.5
4
for i in range(0, 1): print(1*12) print(2*12) print(3*12) print(4*12) print(5*12) print(6*12) print(7*12) print(8*12) print(9*12) print(10*12) print(11*12) print(12*12)
7a1424ab3354f47920fa51d0f3785bb92d16a619
shivveerq/python
/condition.py
257
3.984375
4
b=int(input("Enter your brand number Name")) print("Input Number is:",b) if(b==1):print("It is not good brand") elif b==2: print("This is cat brand") elif b==3: print("It is parrot brand") else: print("This is invalid input")
628e319d65d3dd83d540ab326913f2bb62cca265
shivveerq/python
/replacementop.py
430
4.25
4
name="shiva" salary=15000 gf="sunny" print("Hello {0} your salary is {1} and your girlfriend waiting {2}".format(name,salary,gf)) # wint index print("Hello {} your salary is {} and your girlfriend waiting {}".format(name,salary,gf)) print("Hello {x} your salary is {y} and your girlfriend waiting {z}".format(x=na...
cfb7320acddb90bf052dd047b4ae14e2190e6142
pavarotti305/python-training
/fred.py
162
4.15625
4
name1 = input('Please enter your name here''\n') if name1 == 'fred': print('Welcome %s' % name1) else: print("Please %s I expect another Name " % name1)
4b878ad0a5540f6b743360ece2fa5a466ede8048
pavarotti305/python-training
/loop_count_list.py
197
3.734375
4
toys = ['Batman', 'Superman', 'Spiderman', 'Thor', 'Hulk', 'Ironman'] lenght = len(toys) for element in range(0, lenght): print("The toys that have index %s is %s." % (element, toys[element]))
b4c433ee6ddb5c5f1e04c27963d9b56ce104ce87
pavarotti305/python-training
/while_loop.py
599
4.125
4
print('') print("Use while with modulus this expression for x in xrange(2, 21): is the same as i = 2 while i < 21:") i = 2 while i < 21: print(i) stop10 = i == 10 if i % 2 != 0: break if stop10: break i += 2 print('') print("Same code with for") for x in range(2, 21): if x % 2 =...
a37de490c4738e54d1f68f6194af7c2a47c96969
pavarotti305/python-training
/if_else_then.py
2,994
4.4375
4
print('') print('''Here is the structure: if expression: like on this example if var1 is true that means = 1 print the value of true expression statement(s) else: else var1 is false that means = 0 print the value of false expression statement(s)''') truevalue = 1 if truevalue: print("1 - Got a true expression valu...
0af1b4b23e6ebc3d11c1ee935571b6522f72fe6d
fskypro/exporter
/src/src/scripts/libs/FriendMethod.py
2,008
3.75
4
# -*- coding: utf-8 -*- # """ 实现类似 C++ 中的友员 使用实例: from FriendMethod import FriendMethodMeta from FriendMethod import friendmethod class A(object): __metaclass__ = FriendMethodMeta @friendmethod("B") # 将函数 __func 设置为名称为“B”的类的友员 def __func1(self): pass @friendmethod("B", "C") def __func2(sel...
c3af3cc94d6ca7dfa21d3898fc449c71a5b0f2a5
SHLMax/AI
/regression.py
7,939
4
4
import numpy as np from matplotlib import pyplot as plt import csv import math # Feel free to import other packages, if needed. # As long as they are supported by CSL machines. def get_dataset(filename): """ TODO: implement this function. INPUT: filename - a string representing the path to the...
4017d74ece8cae3dd686b16e5f5d6dd8cd2844b2
mcolvinphd/chem160project1
/diffuse.py
726
3.640625
4
from random import choice npart=300 side=35 #Should be an odd number time=0 steps = [(1,0),(-1,0),(0,1),(0,-1)] grid=[[0 for x in range(side)] for y in range(side)] for ipart in range(npart): # Start particle at center x,y = side//2,side//2 counter=0 # perform the random walk until particle departs ...
f62f9f153a2b413d32bf07f4cd9e660e4adfcfea
SaurabhRuikar/CdacRepo
/Python and Advanced Analytics/Lab Practice/ConsonantReplace.py
1,176
4.15625
4
''' Q. 1. Given a dictionary of students and their favourite colours: people={'Arham':'Blue','Lisa':'Yellow',''Vinod:'Purple','Jenny':'Pink'} 1. Find out how many students are in the list 2. Change Lisa’s favourite colour 3. Remove 'Jenny' and her favourite colour 4. Sort and print students and their favourite colours ...
cc07db2b18ca1aa04d42e29f440ef07d06e39063
SaurabhRuikar/CdacRepo
/Python and Advanced Analytics/Lab Practice/MiddleValueList.py
526
3.796875
4
##lst=["xyz","ayz","pqr","ayz"] lst=[] ans="y" while ans=="y": s=input("Enter the string") for i in lst: if s[1]==i[1]: lst.insert((lst.index(i)),s) print(lst) break else: lst.append(s) ans=input("do you want to add more string y/n") ...
280a0bdb6bc012ab97a2c9d9ae5a527f3363ce65
SaurabhRuikar/CdacRepo
/Practical Machine Learning/TensorFlow1.py
4,889
3.796875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Dec 26 09:34:25 2019 @author: student """ #Need to have tensorflow version 1.1x #Version 2.x does not have Session Command #If version 2.x #import tensorflow.compat.v1 as tf #tf.disable_v2_behaviour() import tensorflow as tf #Version print(tf.__ver...
8ee6a5e0a13f0db31fdae73f1492ba225a6c480d
SaurabhRuikar/CdacRepo
/Python and Advanced Analytics/Advanced Analytics/libraries3.py
1,819
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Dec 7 17:19:54 2019 @author: student """ import sys import numpy as np def createArange(): r1=int(input("Enter the number of rows for matrix A ")) c1=int(input("Enter the number of column for matrix A ")) m1=r1*c1 a=np.arange(m1).re...
bd45bb319f97908b561ca9f9caccb3da50c92c8e
SaurabhRuikar/CdacRepo
/Python and Advanced Analytics/Lab Practice/usemodule.py
573
3.65625
4
#import mymodule as m import sys from mymodule import * choice=0 while choice!=4: print("1.Factorial") print("2.printtable") print("3.Prime") print("4.exit") choice=int(input("Enter the choice")) if choice==1: num=int(input("Enter the number")) f=factorial(num) print("...
a0e62cb715102e37c7d507b847200714b8b717b0
SaurabhRuikar/CdacRepo
/Python and Advanced Analytics/FileHandling/filefunctions.py
919
3.59375
4
def read(flst): for i in flst: print(i,end="") print() def write(flst): lst = [] lst.append(input("Enter ID ")) lst.append(input("Enter Name")) lst.append(input("Enter Dept")) lst.append(input("Enter Salary ")) lst.append(input("Enter Designation")) flst.append(":".join(lst...
c265b5b6cc1c0b4abba9d8d23d4e6944916e133b
SaurabhRuikar/CdacRepo
/Python and Advanced Analytics/Class/Day4.py
8,065
4.0625
4
#inet addr:192.168.1.34 PC IP #FUNCTIONS #WE USE KEYWORD DEF FOR DEFINING FUNCTIONS #never print values in functions as far as possible. Use return statements instead. ''' import sys #Prime no Check def prime(n): for i in range(2,n): if n % i == 0: return True ...
d8ff5b2120acc3d38e45ebe0b0362c23ee03ccad
SaurabhRuikar/CdacRepo
/Python and Advanced Analytics/Database/Mongo/product.py
2,092
3.78125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Dec 7 16:50:58 2019 @author: student """ from pymongo import MongoClient import sys client=MongoClient('localhost:27017') print('connection done') db=client.Product def insert(): try: pid=int(input('Enter Product id : ')) pName...
14e688e1b7f4f8116a1ac43140a8bb508bcfa392
SaurabhRuikar/CdacRepo
/Python and Advanced Analytics/Database/sqlite3/database.py
2,039
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Dec 6 12:27:14 2019 @author: student """ import sqlite3 import sys db=sqlite3.connect('mydb1.db') #Connecting to database if db!=None: print("Connection done") else: print("Connection not done") cursor=db.cursor() #cursor generate some...
c8bf55489b11b9a2139344c36cccea903ba9ba9c
inwk6312fall2017/programming-task-final-mohit0713
/task-1.py
643
3.921875
4
x = open("Book1.txt", "r") #open first file y = open("Book2.txt", "r") #open second file z = open("Book2.txt", "r") #open third file def find_big(a): # this function will check the biggest in all the books): longest_word = '' for word in a.read().split(): if len(word)> len(longest_word): longest_word = w...
92799c5dad508dbe76b9a231dc82cfa22e01b7f5
erferguson/CodeWars
/9.13.20/kata.py
1,639
4.15625
4
# 8kyu # This kata is from check py.checkio.org # You are given an array with positive numbers and a number N. # You should find the N-th power of the element in the array with the index N. # If N is outside of the array, then return -1. # Don't forget that the first element has the index 0. # Let's look at a f...
9dfe1eb181d7260f35d81c380e385008ebcf519d
run-fourest-run/PythonBeyondTheBasics
/Inheritence/singleinheritence.py
885
4.15625
4
####Example given by instructor##### class Base: def __init__(self): print('Base Intilizer') def f(self): print('Base.f()') class Sub(Base): def __init__(self): super().__init__() print('Sub Intilizer') def f(self): print('Sub.f()') #####################Sel...
f6f7b6089fbbc145cae78265ffe5c2dacc751670
edsimon/adventOfCode2019
/src/day04_short.py
564
3.5625
4
def main(low, high): num_codes_1, num_codes_2 = 0, 0 for code in range(low, high+1): arr_code = [ int(i) for i in str(code)] if arr_code == sorted(arr_code): if any([ j > 1 for j in [arr_code.count(i) for i in range(10)]]): num_codes_1 += 1 if any([ j == 2...
94b08e5f2e8310da7bf304f9ebce3c39d66ff2a7
L202173001/prak-ASD
/Modul1_X_L202173001.py
4,151
3.625
4
#1 def cetakSiku(x): for n in range(x+1): print("*"*n) #2 def gambarlahPersegiEmpat(a,b): print("@"*b) for n in range(0,a-2): print("@"+" "*(b-2)+"@") print("@"*b) #3 def jumlahHurufVokal(x): vokal=0 for n in x: if n in "aiueoAIUEO": vokal+=1 return(len(...
3b2da42046bcb00ac24c5ab8350ed2b321a4c947
bmacaw/PythonWorkout
/E7UbbiDubbi.py
3,527
4.03125
4
# Write a function called ubbi_dubbi that takes a single word (string) as an argument # and returns a string, the word's translation into Ubbi Dubbi. Example: if the # function is called with octopus, the function will return the string uboctubopubus. import string def ubbi_dubbi(any_word): ud_translation = [] ...
1c44e33f725fbc0d5268277482ce1c001c614025
rkidwell2/teachingPython
/HowManyCows.py
1,444
4.21875
4
""" Rosalind Kidwell 6/26/19 This program creates an interactive riddle for the cow game, and is being used to demonstrate python fundamentals for high school students """ import random from time import sleep def cows(): print('') myList = [[0, "? "], [2, "How many? "], [3, "How ma...
fd17d5c10287ca0ad796fcc270733ed2b666fff9
ShihabAhmed09/HackerRank-Solutions-Python
/Mathematics/Number Theory/PowerOfLargeNumbers.py
406
3.5625
4
def solve(a, b): a, b = int(a), int(b) mod = 10 ** 9 + 7 b = b % (mod - 1) return pow(a, b, mod) # def solve(a, b): # a, b = int(a), int(b) # m = 10 ** 9 + 7 # return pow(a, b, m) if __name__ == '__main__': t = int(input()) for t_itr in range(t): ab = input().split() ...
63aa45ba0a8260bf24a70bd66b4e6b8e0d1a5099
ShihabAhmed09/HackerRank-Solutions-Python
/Language Proficiency/Numpy/FloorCeilAndRint.py
557
3.703125
4
import numpy my_array = numpy.array(input().split(), float) numpy.set_printoptions(sign=" ") print(numpy.floor(my_array)) print(numpy.ceil(my_array)) print(numpy.rint(my_array)) """floor: The tool floor returns the floor of the input element-wise. The floor of x is the largest integer i where i<=x numpy.floor(my_arr...
629ed05904c026eb01bee776dd2be5471ffbe17b
ShihabAhmed09/HackerRank-Solutions-Python
/Data Structures/Linked Lists/DeleteDuplicateValueNodesFromASortedLinkedList.py
1,177
4.03125
4
class SinglyLinkedListNode: def __init__(self, node_data): self.data = node_data self.next = None class SinglyLinkedList: def __init__(self): self.head = None self.tail = None def insert_node(self, node_data): node = SinglyLinkedListNode(node_data) if not ...
f07c36bb3e630bd3e2e9e888f86b0477bec00654
ShihabAhmed09/HackerRank-Solutions-Python
/Regex/Applications/FindASubWord.py
551
4
4
import re n = int(input()) text = "\n".join(input() for _ in range(n)) # print(text) test = int(input()) for _ in range(test): query = input().strip() # print(len(re.findall(r"\B" + query + r"\B", text))) # print(len(re.findall(r'\w%s\w' % query, text))) print(len(re.findall(r'(?<=\w)%s(?=\w)' % query,...
a885f082891e2d40bec1742107df098dbd68f27e
ShihabAhmed09/HackerRank-Solutions-Python
/Regex/Applications/DetectHTMLTags.py
284
3.640625
4
import re regex_pattern = r'<(\w+)' sets = set() for _ in range(int(input())): html = input() res = re.findall(regex_pattern, html) # print(res) for tag in res: if tag not in sets: sets.add(tag) # print(sorted(sets)) print(*sorted(sets), sep=";")
a0196618624bc6df424308b0c2089a08b3aa1817
ShihabAhmed09/HackerRank-Solutions-Python
/Data Structures/Arrays/LeftRotation.py
389
3.765625
4
def rotateLeft(d, arr): return arr[d:] + arr[:d] # shifted = arr[d % len(arr):] + arr[:d % len(arr)] # return shifted if __name__ == '__main__': first_multiple_input = input().rstrip().split() n = int(first_multiple_input[0]) d = int(first_multiple_input[1]) arr = list(map(int, input().rs...
9db0cade4f260b99109424d3305f05dad95082ab
ShihabAhmed09/HackerRank-Solutions-Python
/30 Days Of Code/Day_28_RegExPatternsAndIntroToDatabases.py
449
3.71875
4
import re if __name__ == '__main__': N = int(input()) data = [] for N_itr in range(N): firstNameEmailID = input().split() firstName = firstNameEmailID[0] emailID = firstNameEmailID[1] # email_pattern = r"^[a-z.]+@gmail\.com$" email_pattern = r".*@gmail\.c...
1665ffe1a99acce6b98e7522d6f2318f5b82753b
ShihabAhmed09/HackerRank-Solutions-Python
/Mathematics/Fundamentals/SummingTheNSeries.py
749
3.9375
4
import os def summingSeries(n): mod = pow(10, 9) + 7 return pow(n, 2, mod) # return pow(n, 2) % mod # return pow(n, 2, 10**9+7) if __name__ == '__main__': # fptr = open(os.environ['OUTPUT_PATH'], 'w') t = int(input()) for t_itr in range(t): n = int(input()) result = su...
113602dc3012b5bd02f75881e170ec77bfe7ef71
ShihabAhmed09/HackerRank-Solutions-Python
/Regex/Assertions/NegativeLookbehind.py
448
3.828125
4
import re Test_String = input() Regex_Pattern = r"(?<![aeiouAEIOU])." # Regex_Pattern = r"(?<![aeiouAEIOU])(.)" match = re.findall(Regex_Pattern, Test_String) print("Number of matches :", len(match)) # (?<!regex_2)regex_1 # The negative lookbehind (?<!) asserts regex_1 not to be immediately preceded by regex_2. Loo...
f307f779de933a92f3f082e423f63e8921d55708
ShihabAhmed09/HackerRank-Solutions-Python
/10 Days Of Statistics/Day_1_Quartiles.py
937
3.859375
4
def quartile(data): size = len(data) if size % 2 == 0: return (data[size // 2 - 1] + data[size // 2]) // 2 else: return data[size // 2] n = int(input()) data = list(map(int, input().split())) data.sort() # print(data) if n % 2 == 0: lower_half = data[0:n // 2] upper_half = data[n ...
aa885a5096195aa1ec14db08409892081e50a21d
ShihabAhmed09/HackerRank-Solutions-Python
/Regex/Assertions/NegativeLookahead.py
393
3.921875
4
import re Test_String = input() Regex_Pattern = r"(.)(?!\1)" match = re.findall(Regex_Pattern, Test_String) print("Number of matches :", len(match)) # regex_1(?!regex_2) # The negative lookahead (?!) asserts regex_1 not to be immediately followed by regex_2. Lookahead is # excluded from the match (do not consume ma...
92ffc1f94f57cad933de2f480e93d27bc657b974
ShihabAhmed09/HackerRank-Solutions-Python
/Language Proficiency/Collections/Collections.namedtuple().py
629
3.734375
4
from collections import namedtuple N = int(input()) student = namedtuple('student', input().strip().split()) total = 0 for i in range(N): total += float(student(*input().strip().split()).MARKS) print(total/N) # print(sum(float(student(*input().strip().split()).MARKS) for _ in range(N))/N) # Detailed Approach: ...
012f5c0106dd40ad823c36d4dfc2cf649196b86b
ShihabAhmed09/HackerRank-Solutions-Python
/Mathematics/Combinatorics/nCrTable.py
353
3.703125
4
from math import factorial def solve(n): result = [] for i in range(n+1): ncr = (factorial(n) // factorial(i) // factorial(n-i)) % 10**9 result.append(ncr) return result if __name__ == '__main__': t = int(input()) for t_itr in range(t): n = int(input()) result =...
f877fc9695a7db6d7c892ec8cdd6c86c26d593ea
ShihabAhmed09/HackerRank-Solutions-Python
/10 Days Of Statistics/Day_7_Spearman's Rank Correlation Coefficient.py
1,133
3.5625
4
def get_rank(data): temp = sorted(data) rank = dict() for i in range(len(temp)): rank[temp[i]] = i + 1 return [rank[i] for i in data] n = int(input()) X = list(map(float, input().split())) Y = list(map(float, input().split())) rx = get_rank(X) ry = get_rank(Y) d = [(rx[i] - ry[i]) ** 2 for i...
83318893a1cf5711aec8c873d9e15244f364b6e8
ShihabAhmed09/HackerRank-Solutions-Python
/Language Proficiency/Numpy/LinearAlgebra.py
548
3.53125
4
import numpy # The linalg.det tool computes the determinant of an array. n = int(input()) my_array = numpy.array([input().strip().split() for _ in range(n)], float) numpy.set_printoptions(legacy="1.13") determinant = numpy.linalg.det(my_array) print(determinant) # The linalg.eig computes the eigenvalues and right ...
ca05848fc61bd7d848294ce13df1eccf2eee37a7
ShihabAhmed09/HackerRank-Solutions-Python
/Data Structures/Arrays/ArraysDS.py
221
3.71875
4
def reverseArray(a): return a[::-1] if __name__ == '__main__': arr_count = int(input()) arr = list(map(int, input().rstrip().split())) res = reverseArray(arr) print(res) # Time Complexity: O(n)
7962b07d840b8184b78795f3c4f274e02ee13007
hurr1canexd/numerical-methods
/num-methods-lab4/src/helper_methods.py
416
3.765625
4
# Делит строки системы def divide_row(A, f, row, divider): A[row] = [a / divider for a in A[row]] f[row] /= divider # Прибавляет к строке другую строку, умноженную на коэффициент def combine_rows(A, f, row, source_row, weight): A[row] = [(a + k * weight) for a, k in zip(A[row], A[source_row])] f[row] ...
f77c0c59e87a9fbadc82c1336e20f0000587d043
erfanh3h/projeinternetclass
/dummy.py
681
3.671875
4
import datetime from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from tabledef import * engine = create_engine('sqlite:///tutorial.db', echo=True) # create a Session Session = sessionmaker(bind=engine) session = Session() # Create and object of class User user = User(111, "admin","passw...
389b2826c6f9ab6a0ab39423ff8a7c66311f05e7
em0flaming0/Mock-Database
/mock_db.py
1,075
4.34375
4
#!/usr/bin/python #demonstrating basic use of classes and inheritance class Automobile(object): def __init__(self, wheels): self.wheels = wheels #all autmobiles have wheels class Car(Automobile): def __init__(self, make, model, year, color): Automobile.__init__(self, "4") #all Car objects should have 4 whee...
a3e51be7cf41d2b61067dcada223802c802580c9
JJHick95/NFL-Play-Predictor
/deployment_material/src/utils.py
1,076
3.59375
4
import pandas as pd def extract_feature_values(data): """ Given a params dict, return the values for feeding into a model""" # Replace these features with the features for your model. They need to # correspond with the `name` attributes of the <input> tags EXPECTED_FEATURES = [ "game_minu...