blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
569ba0b2a041c57f29effce4f5d0769bae0dc109
Paolopdp/finished-school-projects
/Elaborato_Python/progetto.py
6,561
3.78125
4
#!/usr/bin/python """ Codice per l'esame """ #P1 """ dato un dizionario che associa gli id del FASTA file alla stringa di DNA, ritorna il numero di record nel dizionario """ def get_num_records(records): return len(records.keys()) #P2 """ dato un dizionario che associa gli id del FASTA file alla stringa di DNA, rit...
12c5c89a4aa589a8dc530300b4d0aafea0bc7141
cdchris12/Project_Euler
/Project_9.py
1,120
4.21875
4
#!/usr/bin/python def FindTriplet(): a = 1 b = 2 c = 3 while a <= 334: while b <= 499: while c <= 997: if a + b + c == 1000: if ((a * a) + (b * b) == (c * c)): return ((a, b, c)) # End if ...
f01e2b0d1fd9ed196c71fbef7a95a02b45789059
hashbanger/Python_Advance_and_DS
/DataStructures/Minimal/Stacks/01_Stack.py
653
4.125
4
# Implementing a stack class Stack(object): def __init__(self): self.items = [] def isEmpty(self): return len(self.items) == 0 def push(self, item): self.items.append(item) def pop(self): return self.items.pop() def peek(self): return self.items[len(sel...
a2db4ca5084f19a6e54260465765e44a05725b31
rbrokenshaw/Python-Challenges
/Mathematical/Pairs of Prime Number/prime_pairs.py
548
3.6875
4
import itertools def primePairs(n): if n >= 4: # find all prime numbers between 2 and n multiples = [] primeNums = [] for i in range(2, n+1): if i not in multiples: primeNums.append(i) for x in range(i*i, n+1, i): multiples.append(x) # find all pairs that meet constraint pairs = [] ...
172f55b1a394695bab0b7dcd90cf632a5b1d5e80
kyeongbukpjs/python-programming
/exercise2/problem2.py
135
3.78125
4
#y = 7x^3 + 4x^2 + 2x +5 #x는 표준입력으로, y는 표준 출력으로 x = int(input()) y = 7*(x**3) + 4*(x**2) + 2*x +5 print(y)
3a4f66afa7f8c213b1879882a97da75411999a35
bpuderer/python-snippets
/util/list_of_dictionaries.py
1,276
3.96875
4
""" list of dictionaries helpers """ def exists_lod(lst, key, val): """is key-value in list of dicts""" return any(d[key] == val for d in lst) def index_lod(lst, key, val): """index of first occurrence key-value in list of dicts""" return next((i for (i, x) in enumerate(lst) if x[key] == val), -1) d...
93ac6f48157222bebf9cd71b991cc59576a366da
owensheehan/ModularProgramming
/Revision_Lab1_Question1.py
409
3.828125
4
#Script: Revision_Lab1_Question1.py #Author: Owen Sheehan #Description: Read and display Students name and over all mark ok=True try: while ok: studentName=input("Please enter the name of the student:") overallMark=int(input("Please enter the students overall exam mark (numerically):")) pr...
371b1b10cbfc33771ef441621c2a94b37fb7684b
laurenwolfe/coding-practice
/trees/bin_tree_traversal.py
2,239
4.09375
4
from trees import binary_tree from lists.linked_list import build_linked_list, LinkedList from collections import deque def build_tree_from_linked_list(head): """Converts a linked list to binary tree. Add nodes to queue as they're traversed. Popped value is current root. """ tree_queue = deque() ...
4869609a2a12d0ec5f101d60bc4369f33f34453f
perfect-python/perfect-python
/part4/chapter16/nx1.py
911
3.890625
4
import networkx as nx def main(): # edgeのリストを渡して初期化 g = nx.Graph([(0, 1), (1, 2), (2, 3), (10, 20), (20, 30), (30, 40), (40, 10)]) # nodeのリストを取得する print(g.nodes()) #=> [0, 1, 2, 3, 40, 10, 20...
963c1655b9d12ad386b4c20d62a76b31e883b8c4
d3zd3z/euler
/python3/pr037.py
1,367
4.15625
4
#! /usr/bin/env python3 """ Problem 37 14 February 2003 The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we can work from right to left: 3797, 379, 37, and 3. Find the su...
f4c98e1a5e8b7cb56f6851f5e64753b34fff7097
vojtadavid/IV122
/10/monty_hall_problem.py
1,873
3.78125
4
import random repeat = 10000 #option=0 never change tour guess #option=1 always change your guess #option=2 randomly change your guess def monty_hall(option=1): good_guess = 0 for i in range(repeat): car_position = random.randint(0,2) choosen_pos = random.randint(0,2) host_pos = -1 ...
9f5d70a0384e24e214e795dbf66dcbee88270f16
Kulchutskiyyura/Yura
/play_bango/play_bango.py
202
3.984375
4
def play_banjo(name): if name[0]=="r" or name[0]=="R": return name + " plays banjo" else: return name + " dont plays banjo" name=input("enter name: ") print(play_banjo(name))
43e9d27327251ea1d9408f540d119cbdc32e4b2e
rsnastin/Zad3-CB-Snake
/venv/snake.py
2,978
3.5
4
import random import curses class Snake: #head = 0 body = 0 move_snake = 0 grow = 0 class Food: position = 0 new = 0 remove = 0 class Game: key = 0 snk_x = 0 snk_y = 0 def update_snake(snake, action = 'move'): if action == 'move': w.addch(Snake.body[0], Snake.bo...
d396a0aa92456c83c6563a461a30c7bafa089b89
timwangmusic/Algorithm-Design
/Linked_list/LFU_cache.py
3,028
3.953125
4
""" Analysis: Take the idea from LRU cache, inc freq of an item and move the node to the list with new freq. Track linked-list node reference with hash table Track linked-list head with frequency count For evictions, we need to track the least frequency If the current LF = 3, and there are 2 items with freq=3. After e...
7c4da5b21313b15f5036a12c44d7d07a6ee04525
inthescales/art-gen
/src/color.py
1,953
3.625
4
class Color: def __init__(self, r, g, b, a=1.0): self.r = r self.g = g self.b = b self.a = a hsv = rgb_to_hsv(r, g, b) self.h = hsv[0] self.s = hsv[1] self.v = hsv[2] def string_rgb(self...
4a1758b1e38ae8cc6c1e20c6e5e2eb21bb352efc
dsurraobhcc/CSC-225-T1
/classes/class4/Coordinate.py
637
4.03125
4
import math ''' 2-dimensional coordinate (x, y) ''' class Coordinate(): # constructor def __init__(self, x, y): self.x = x # instance variable self.y = y # sqrt((x1 - x2)**2 + (y1 - y2)**2) def get_distance(self, other): return math.sqrt((self.x - other.x)**2 + (self.y - other...
b19c76376f0ab525b33c9d829071322ad5d966d1
senavs/knn-from-scratch
/model/point.py
2,891
3.734375
4
import numpy as np class Point: def __init__(self, axis): """Point constructor :param axis: iterable with point coordinates :type: list, tuple and np.array :example: x y z w axis = [1, 0.3, 6.4, -0.2] """ ...
4d6a3be54d4d4c9ffcdb247783de1c5892aeb440
Kasrazn97/SMFinal_Project
/Country.py
3,644
3.859375
4
""" This module defines the attributes and methods of a Country class. Some countries are only 'senders', some are both senders and receivers. """ import pandas as pd import numpy as np class Country(): def __init__(self, data, num_agents, country_name): # input is a table with all info for a country, columns:...
61e9dfa08cedc014078b24c551c82dcd30a2c12d
adeywojo/ATM
/validation.py
530
3.6875
4
def account_number_validation(account_number): if account_number: try: int(account_number) if len(str(account_number)) == 10: return True except ValueError: return False except TypeError: return False return False def us...
06052c22928c9a4c9c7c4c8f59687e6694231ea7
Irkhammf/TBA_Tubes
/Lexical Analyzer_TBA.py
9,919
3.515625
4
import string print('-----------------------------------------------------------------------------------------------------') print('Selamat datang, silahkan lakukan chek validasi kata dengan menginputkan kata yang ada dalam daftar') print('Berikut adalah daftar kata yang bisa dichek pada lexical analyzer ini: ') print...
48055149e85ef7c7a9195c33f05c6ea033a59e27
bopopescu/HumanResourcesDepartment
/sum.py
281
3.515625
4
for i in range(10000): t = (i * 3 + 3) * 3 tSTR = str(t) sum = 0 for j in tSTR: sum += int(j) if sum != 9: print('Загадано: '+ str(i)+ ', Результат вычислений:'+str(t)+ ', Сумма результата: '+ str(sum))
e89a94f69dc6baa4a6da72d3a4f09e35afac8de5
Kenlin205/guess-num
/guess.py
484
4.125
4
import random start = int(input("Please choose an number to start -> ")) end= int(input("Please choose an number to end -> ")) r = random.randint(start,end) count = 0 while True: count += 1 # count = count +1 num = int(input("guess a number ->")) if num == r: print("you have guess it !!! ") print("This is" , co...
4ccca9cf73186d3b5b42378dc7815108c5fcde00
b-meson/basic_crypto
/matasano/simplecrypt.py
2,399
3.515625
4
#!/usr/bin/python """ Solutions to Matasano's first set of cryptography challenges. As well as some bonus bits that might be useful for other things. """ import binascii import base64 import numpy as np import collections import string import array from string import ascii_lowercase import pdb def hex_to_ascii(hexs...
bc3a894231ff0bc416c22793b5fce3649192746a
Chencx901/Problem-Solving-with-Algorithms-and-Data-Structures-using-Python
/Class.py
1,956
4.09375
4
# Fraction Class class Fraction(object): """docstring for Fraction""" def __init__(self, top,bottom): #初始化 self.den = bottom self.num = top def show(self): #展示函数 print(self.num,'/',self.den) # 重新定义__str__方法,后续可以使用print() def __str__(self): return str(self.nu...
4c57c8ee0302ea85dcb2df3a0ca569cb8a8af1d4
dsspasov/HackBulgaria
/week0/1-Python-simple-problems-set/problem5.py
367
3.921875
4
#problem5.py from problem4 import is_prime def prime_number_of_divisors(n): count = 2 for x in range(3,n): if(n%x==0): count = count +1 if(is_prime(n)): return True else: return False def main(): print (prime_number_of_divisors(8)) # a = prime_number_of_divisors(8) # if (a): # print("True") # else: # pr...
d9c28357ab0dd148db03cabf0f712527e1fdf32c
vpfeifer/evlutionary-computing-algorithms
/genetic/led_number_recognizer.py
9,767
3.6875
4
import random import numpy as np import matplotlib import matplotlib.pyplot as plotter # 0 - Imprime somente a geracao resultante # 1 - Imprime o resultado a cada geracao (populacao, aptidao de cada individuo, aptidao media) # 2 - Imprime os passos do algoritmo (selecao, reproducao, mutacao, avaliacao) # 3 - Imprime o...
d9c5d76966d86de923ee31a678050096ce125e6e
3baaa/python-test
/10/10.py
2,895
3.65625
4
''' a = [1,2,3,4,5,6,3,3] r_set = {3,5} result = [i for i in a if i not in r_set] print(result) a = 'aaa' print(a*2) import math print(math.sqrt(25)) import math as m print(m.sqrt(25)) from math import sqrt print(sqrt(25)) from math import * print(pi) print(sqrt(25)) from math import sqrt as s print(s(25)) impo...
4ffc78535c0c63d8153dfdc80054316df8084aff
raffaellomarchetti/uri-python
/1873.py
1,094
3.734375
4
c=int(input()) while c > 0: a, b = input().split() a=a.lower() b=b.lower() if a=='lagarto': if b=='spock' or b=='papel': print('rajesh') elif b=='tesoura' or b=='pedra': print('sheldon') else: print('empate') elif a=='papel': if b==...
dd59d47fa6ce522efa8682f9c5198d57c79fb257
jordan-carson/DataStructures-and-Algos
/ds_and_algos/structures/structures.py
392
3.765625
4
# class Stack class Node: def __init__(self, value): self.edges = list() self.value = value class Edge: def __init__(self, value, node_from, node_to): self.value = value self.node_from = node_from self.node_to = node_to class Graph: def __init__(self, nodes=list...
073c8f9c727b9887b1ac5fd9851b54162d9eae84
victor-iyi/email-classification-challenge
/tools/staff_graph.py
3,597
3.59375
4
import community from matplotlib import pylab as pl import networkx as nx import numpy as np import pandas as pd def construct_graph(df_emails): '''From an email dataframe, output the biggest connected component of the graph where nodes are sender/recipients and edges are emails sent between them....
7942b4770f958373f8482d527200e06820a8904f
msabbir007/Introduction-to-Python
/Assignment(Round3)/kolmio.py
475
4.15625
4
# Johdatus ohjelmointiin # Introduction to programming # Area def area(a,b,c): s=(a+b+c)/2 import math tem=(s-a)*(s-b)*(s-c) result= math.sqrt(s*tem) return result def main(): line_a = float(input("Enter the length of the first side: ")) line_b = float(input("Enter the length of the second...
2fa5dabf2e39eab6a5864e69fbf636fbcad55343
nidhiatwork/Python_Coding_Practice
/Lists/flipAndInvertImage.py
342
3.765625
4
def flipAndInvertImage(A): """ :type A: List[List[int]] :rtype: List[List[int]] """ result = [] for row in A: result.append(list(map(lambda x: 0 if x == 1 else 1, row[::-1]))) return result nums = [[1,1,0,0],[1,0,0,1],[0,1,1,1],[1,0,1,0]] print(fli...
1c4dcfa2aeb211442db69a230cd6d376a1e5897d
yamasampo/pathmanage
/huge_file_handler.py
10,302
3.734375
4
"""This script splits contents of one file into multiple files. Example ------- An input file contains >>ID1 >1 data >2 data >>ID2 >1 data >2 data >3 data ... >1000 data Then this script will output three files. One contains lines for the items for ID1 [outfile 1] >>ID1 >1 data >2 data The other two contain li...
a6227413b9490f64803c60d41446470cd1bb9a16
moenka/rc
/.bin/jsontree
668
3.5625
4
#!/usr/bin/env python3 """Print out the directory structure as json dict.""" from sys import argv import json import os def path_to_dict(path): d = {'name': os.path.basename(path)} if os.path.isdir(path): d['type'] = "directory" d['children'] = [path_to_dict(os.path.join(path,x)) for x in os....
5824bcb46d95ac0afe8029b521f2f45fbb138491
dinob0t/first_zero_in_binary_number
/first_zero_in_binary_number.py
441
3.921875
4
""" Algorithm to find the index of first zero in a binary number where index zero is furtherest right in array """ number = 20 bin_number = bin(number) print "Number is %d" %number print "Binary represendation is %s" %bin_number def get_first_zero(bin_number): for i in reversed(range(len(bin_number))): if bin_numbe...
693599e601211b8475b3cdeedfeb3b70360b0adb
xiao-a-jian/python-study
/剑指offer/3.two-dimensional_array.py
1,093
3.8125
4
""" 题目:在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。 请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数 从右上角(左下角)开始找, 1)命中,查找成功 2)右上角数字比target大,删除最右一行 3)右上角比target小,删除上一行 PS:类似的,从左下角开始查找也是相同的道理。 PS2:该算法的利用的是夹逼的思想,不断从左右进行逼近,直至最终结果。 """ class Solution: def Find(self, target, array): m = len(array) - 1 ...
26b1e8108601de13a6a25ad62f8dd2b6e7c854d8
10-15-5/Covid19-Tracker
/covidrequests.py
3,253
3.734375
4
import requests class ByCountryTotal: def __init__(self, country, date1, date2): """ :param country: The country that the user has chosen :param date1: The from date that will be sent to the Covid19 API :param date2: The to date that will be sent to the Covid19 API """...
f8840974a55f960b4a9bcf8b236bb3f7a331c90f
Kblens56/ccbb_pythonspring2014
/2014-05-21_class_pt2.py
2,969
3.546875
4
import pandas import numpy cd documents/ccbb_pythonspring2014/ # open sites_complicated in pandas as an Excell file and then parse out Sheet 1 xl_c = pandas.ExcelFile('sites_complicated.xlsx') df_c = xl_c.parse('Sheet1') # how to output file in pandas # to write file in pandas and make csv will be called output.csv ...
224d21d56bb2a280def3c051ad798a472b4a18b6
wook0709/python
/class_prac.py
2,043
4.03125
4
''' python class 일반적인 c++ 이나 java에서 사용되는 class의 개념과 동일함. 인스턴스화 및 oop의 개념에 대한 부분을 python에서도 제공하고 있음 또한 global keyword를 통해 전역 변수도 지원해주고 있음. ''' result = 0 def adder(num): global result result += num return result print(adder(2)) print(adder(3)) ''' 위의 예제에서 다중 adder가 필요한 경우 별도의 이름으로 함수를 여러개 생성하여 사용하여...
3bd4393d5f1ded92b7c4c9c451137cccdec3adac
reemahs0pr0/Machine-Learning
/Exercise 5 More Classification.py
1,640
3.625
4
#!/usr/bin/env python # coding: utf-8 # # More Classification - Decision Tree # In[27]: import pandas as pd import numpy as np import matplotlib.pyplot as plt import sklearn # In[28]: df_train = pd.read_csv('LoanProfile-training.csv') df_test = pd.read_csv('LoanProfile-test.csv') # In[29]: df_train # In[3...
9aae564f7d723b41afe0c65dae0474342dd2bd6a
YoupengLi/leetcode-sorting
/Solutions/0055_canJump.py
1,658
4.1875
4
# -*- coding: utf-8 -*- # @Time : 2019/4/7 0007 20:20 # @Author : Youpeng Li # @Site : # @File : 0055_canJump.py # @Software: PyCharm ''' 55. Jump Game Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your...
df528a14d0a076e9c5ae6bc0938fb2a94a0da201
kellytranha/cs5001
/hw12/connect_four/game_controller.py
1,465
3.625
4
from board import Board from chip import Chip from random import choice YELLOW = color(255, 255, 0) RED = color(249, 16, 0) class GameController: """ Maintains the state of the game and manages interactions of game elements. """ def __init__(self, num_row, num_col, side): """Initialize t...
aaf0c419e15269a23cd779d15aa620dbab2ec5b7
forvicky/python_learn_new
/func_learn.py
739
4.125
4
""" 函数 """ def student_info(name,age=18,address='人民路小学'): # 默认参数 return name,age,address #返回多参序列 #序列拆包,最好用多个变量来接受多参返回值,这样每个变量含义比较明确 name,age,address=student_info('zww') print(name,age,address) name,age,address=student_info('zdd',address='柳园小学') #指定参数 print(name,age,address) """ 匿名函数 """ de...
ad438b481ccadb3aaa816781a2538ab0f48fd0f5
WoodsChoi/algorithm
/al/al-81.py
1,977
3.75
4
# 搜索旋转排序数组 II ''' 假设按照升序排序的数组在预先未知的某个点上进行了旋转。 ( 例如,数组 [0,0,1,2,2,5,6] 可能变为 [2,5,6,0,0,1,2] )。 编写一个函数来判断给定的目标值是否存在于数组中。若存在返回 true,否则返回 false。 示例 1: 输入: nums = [2,5,6,0,0,1,2], target = 0 输出: true 示例 2: 输入: nums = [2,5,6,0,0,1,2], target = 3 输出: false ---------------------------------------- 题解: 和 al-33 一样二分法,只不过在二...
ac8916031d34706842bb0d3765cdc82fc8f9bc02
cristianS97/patterns
/piramide.py
1,169
3.9375
4
try: pisos = abs(int(input("Ingrese la cantidad de pisos de la piramide: "))) except ValueError: print("El valor ingresa no es un número, se usara el valor 3") pisos = 3 print("Manera clásica") for piso in range(pisos): for espacio in range(pisos - piso): print(" ", end="") for asterisco i...
9ed14f7fea49d8c693e1a6521dfc06a5af05907d
matteokg/PDXcodeguild-fullstack-night-03052018
/madlibs.py
914
3.671875
4
Adjective1 = input("Tell me an adjective and press enter.") Adjective2 = input("Give me another adjective.") Adjective3 = input("One more adjective") Noun1 = input("Hit me with a noun") Noun2 = input("Another noun") Number1= input("Give me a number") Number2= input("Another Number") Partofbody= input("What's a part of ...
6968c7ad0f088ff9f94acab28347da75a9151e60
timebird7/Solve_Problem
/SWEA/1224.py
1,537
3.6875
4
class Stack: def __init__(self): self.stack = [0]*50 self.pnt = 0 def push(self, x): self.stack[self.pnt] = x self.pnt += 1 def pop(self): if self.pnt == 0: return None else: self.pnt -= 1 return self.stack[self.pnt] ...
89a0408fd1acf3e735dfbbd460118a64933b09fa
poipiii/app-dev-tutorial
/prac-test-revision/q3.py
5,831
3.796875
4
class Book: def __init__(self,isbn,title,author,quantity): self.__isbn = isbn self.__title = title self.__author = author self.__quantity = quantity def set_isbn(self,isbn): self.__isbn = isbn def set_title(self,title): self.__title = title def set_author(...
40c77aa9a0da6954c90b0442f0af82f4e9e41ad7
Vladyslav92/PythonIntro02
/lesson_03/example_1.py
519
4.0625
4
# Проверка принадлежит ли точка окружности. # Исходные данные: # x0, y0 - координаты центра окружности # r - радиус # x, y - координаты точки msg = ('Point coordinate X: ', 'Point coordinate Y: ', 'Circle center of coordinate X: ', 'Circle center of coordinate Y: ', 'Radius of circle: ') x, y, x0, y0, r = (flo...
aebeaed28bb5fb0604c11be2e2fcdb99f367c6a2
sje30/ATI-Feb20
/practical/main.py
4,446
3.65625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Dec 3 11:45:14 2018 backprop for the XOR problem. 19th March 2019 JVS modified code and added graphics. """ import numpy as np import matplotlib.pyplot as plt # set random seed so get same sequence of random numbers each time prog is run. np.random.se...
e7366b4749ad9c7f68a1848790c7dea404ed67ff
MulderPu/legendary-octo-guacamole
/codewars/valid_phone_number.py
280
4.125
4
def validPhoneNumber(phoneNumber): if ' ' not in phoneNumber: return False elif '-' not in phoneNumber: return False elif len(phoneNumber) > 14: return False return True phoneNumber = "(323) 456-7890" print(validPhoneNumber(phoneNumber))
f9f6db5dc557e5c54fc4f354da644bd153205264
kisstom/cppdist
/src/scripts/main/common/data_gen/generate_biased.py
580
3.75
4
import sys, random def randomize(x, y, max): global maxP, minP if x < max / 2 and y < max /2: if random.random() < maxP: return 1 elif x >= max / 2 and y >= max /2: if random.random() < maxP: return 1 else: if random.random() < minP: return 1 return 0 numRow = int(sys.argv[1]) maxP = float(sys....
b4277e4de6dad0d959ec366f6defd576745a1a94
jsyoungk/CodingDojoAssignments
/python_time_time/MSA.py
308
3.78125
4
#for x in range (1, 1000): #if (x%2==1): #print x #print range(5,100000,5) a=[1,2,5,10,255,3] def sumList(a): aSum = sum(a) print(aSum) aAvg = aSum/len(a) print aAvg sumList([1,2,3]) sumList(a) #this is how you make it into a function num = (1, 5, 7, 3, 8) print sorted(num)
259a03cee33be7e44c9be208cafe632d50ab6619
yassh-pandey/Data-Structures
/stack1.py
881
4.03125
4
class Stack(): def __init__(self, *args): self.list = list(args) def push(self, item): self.list.append(item) def display(self): for index, item in enumerate(self.list): if index == ( len(self.list) - 1 ): print("{}".format(item)) else: ...
4418f0401eb37afa6791fb8d2fb39d8703d77814
dhellmann/presentation-zenofpy
/procedural.py
191
3.921875
4
def my_function(arg1, arg2): """This function multiplies arg1 by arg2. """ return arg1 * arg2 results = [] for i in range(5): results.append(my_function(i, i)) print results
4cd02741abbc8bf9a9be60faa4c7fb9ccff77ce2
SaashaJoshi/algorithm-design-and-analysis
/Data Structures/StackUsingLinkedList.py
1,603
4.09375
4
# Implementing Stack using Linked Lists class Node: def __init__(self, data): self.data=data self.next=None class Stack: def __init__(self): self.start=None self.enterchoice() def push(self, data): if self.empty(): self.start=Node(data) else: ...
bbeec3cc08096e6f5353f586097f7bbea5eb48a6
osydorchuk/ITEA2
/lesson6/iters_example.py
142
3.71875
4
list = [1, 2, 3] b = list.__iter__() print(b.__next__()) print(b.__next__()) print(b.__next__()) # StopIteration print(b.__next__())
0d35eb75fc642d230ce4eeacef326cdf9412ff6b
SyncfusionWebsite/Python-Succinctly
/Python_Succinctly/chapter_6/10.py
191
4.03125
4
#!/usr/bin/env python3 contacts = {'David': '555-0123', 'Tom': '555-5678'} for person, phone_number in contacts.items(): print('The number for {0} is {1}.'.format(person, phone_number))
d7c1729539430feee61d34820c7cdecc06b89fcc
andreykutsenko/python-selenium-automation
/hw_alg_9/Sorts.py
213
3.859375
4
array = [3, 5, 8, 9, 4, 25, 6, 8, 56] array.sort() sorted(array) print(array) print(sorted(array)) # sort(*, key=None, reverse=False) # sorted(iterable, *, key=None, reverse=False) b = 'HelloH' print(sorted(b))
5208dea0a2005e1ac22d39a7971c332cddd9602e
cpe202fall2019/lab1-jackfales
/lab1.py
1,946
4.46875
4
# Name: Jack Fales # Course: CPE 202 # Instructor: Paul Hatalsky # Assignment: Lab 1 # Term: Fall 2019 def max_list_iter(int_list): # must use iteration not recursion """finds the max of a list of numbers and returns the value (not the index) If int_list is empty, returns None. If list is None, raises ValueErro...
ed03a5d550a90fdcf1aa0a4f5743e06caeb9428a
tanujp99/2019-Winter-Work
/Week2/form og.py
3,814
4
4
import tkinter as tk from tkinter import * from tkinter import ttk import tkinter.font as tkfont root = tk.Tk() root.title("College Form") time = tkfont.Font(family='sERIF', size=30) Label(root, text="TERNA ENGINEERING COLLEGE", font=time, justify = tk.CENTER, padx = (int((root.winfo_screenwidth() / 3)))).gr...
4bb3322710df63c00c842fbae4b4bbfc0f6141d3
mak428/Learning_Python
/ex3.py
775
4.375
4
# prints a statement print "I will now count my chickens:" # Gives an equation to find how many hens there are print "Hens", 25 + 30 / 6 # Gives an equation to find how many Roosters there are print "Roosters", 100 - 25 * 3 % 4 # prints a statement print "Now I will count the eggs:" # calculations print 3 + 2 + 1 - 5 +...
25e2c130fc8e214d4196271d82536f1918816d21
hb4y/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/2-matrix_divided.py
1,154
3.96875
4
#!/usr/bin/python3 """ matrix_divided - divide a matrix for a number matrix: matrix to divide div: integer to divide the matrix """ def matrix_divided(matrix, div): """ Divide matrix method """ error_list = "matrix must be a matrix (list of lists) of integers/floats" error_size = "Each row of the ...
ab90f4756d1011ec566d8f6a3cff65b5efae33c1
iamovrhere/lpthw
/py2/ex33.py
412
4.1875
4
def number_loop(length): #i = 0 numbers = [] #while i < 6: while len(numbers) < length: print "At top i is %d" % len(numbers) numbers.append(len(numbers)) #i += 1 print "Numbers now: ", numbers print "At the bottom is %d" % len(numbers) print "The numbers: ...
7628634ce3b8c3884eb1e679b42e374c1e642f3e
Mr-Umidjon/python-tasks-sariq-dev
/36-lesson/tubSonmi.py
293
4
4
# -*- coding: utf-8 -*- """ Created on Mon Jul 12 08:11:19 2021 @author: WINDOWS 10 """ def tubSonmi(n): if n == 2 or n == 3: return True if n % 2 == 0 or n < 2: return False for i in range(3, n, 2): if n % i == 0: return False return True
67002994cdced64fdbdac90ace02e5dea5e6b639
xDarKyx/School-Work
/Python/Lab2-4/Lab2-4P03/addFunctions.py
1,747
3.921875
4
import time ''''List with the only valid types of expenses allowed for the dictionary''' expTypes=["Transport","Food","House keeping","Clothing","Telephone&Internet","Others"] '''add() function: adds to a specific day a specific type and a amount of expense''' def add(expenses): t=input("Type:") #Type of exp d...
8feaa089fd51fd5d83120ac0d25ebfedef1c9099
AprilBlossoms/py4e
/ch_06/ex_06_04.py
240
4.09375
4
# Exercise 4: There is a string method called count that is similar to the function in the previous exercise. # Write an invocation that counts the number of times the letter a occurs in “banana”. str = 'banana' print(str.count('a'))
44cb0866c481d67eee8961bff5ca12f7aaceb44b
prasannatuladhar/30DaysOfPython
/prime_or_not.py
558
4.28125
4
#get a number and find prime or not using For loop num = int(input("enter a number :")) for divider in range(2,num): if num%divider==0: print("This is not Prime Number") break else: print(f"The {num} is prime number") #get a number and find prime or not using While loop new_num=int(input(...
d327bc981bcf0d88eee477ab9981a5312010caad
hetal149/Python_Django
/Day5/class_interest.py
339
3.703125
4
#calculate Interest class cal3: P=0 R=0 T=0 def __init__(self,P,R,T): self.P=P self.R=R self.T=T def callinterest(self): I=self.P*self.R*self.T/100 self.I=I def display(self): print("Interest is",self.I) myc=cal3(1000,3.75,5) myc.callinterest() my...
7230509922bcac73b8a1ec1d18a3c42237bb4f28
Liusihan-1/PTA-Python
/判断素数.py
276
3.9375
4
def isPrime(num): num=int(num) for i in range(2,num): if num%i==0 : return False if(num!=1): return True n = int(input()) for i in range(1,n+1): t=int(input()) if(isPrime(t)): print("Yes") else: print("No")
285ce1ece82520565b717e5f23afcf3ed35d8238
tkp75/studyNotes
/learn-python-from-scratch/library_heapq1.py
294
3.671875
4
#!/usr/bin/env python3 import heapq heap = [] # Empty heap # Inserting elements in the heap heapq.heappush(heap, 10) heapq.heappush(heap, 70) heapq.heappush(heap, 5) heapq.heappush(heap, 35) heapq.heappush(heap, 50) # Popping the smallest value minimum = heapq.heappop(heap) print(minimum)
c5d544f4a4a2d1cf6a75797274d9b3966ef4e4a1
EwenFin/exercism_solutions
/python/sieve/sieve.py
336
3.90625
4
import math def sieve(limit): result = [] if limit >= 2: result.append(2) for x in range(3, limit+1, 2): if is_prime(x): result.append(x) return result def is_prime(n): i = 3 while (i <= math.sqrt(n)): if (n % i == 0): return False i += 2...
4b37a56b2957afbac5783c34e0e291d382c15a4d
mcerbauskas/battlescript
/main.py
3,012
3.859375
4
from classes.game import Person, bcolors #instantiating Person class for a mage character #array for 'magic' each spell has a name, mp cost, damage done magic = [{"name": "Fire", "mpcost": 10, "dmg": 100}, {"name": "Blizzard", "mpcost": 10, "dmg": 124}, {"name": "Frost", "mpcost": 10, "dmg": 100}] p...
1e3d741fd99fba1163948f1b9b6c0fdb39ccd6d9
kakakoszaza/CP3-Yotin-Saowakhon
/assignments/Exercise_8_Yotin.py
1,451
3.5625
4
print('--------------------------','LogIn','--------------------------') user = input('Username : ') password = input('Password : ') if user == 'ronin' and password == '1996' : print('------------------','Connected Done !','------------------') print('Welcome To _Smile_Shops...') print('>>> User : %s >>>\n'...
93d8953397cc52b3474fc5b3da578570bf01711a
HomingYuan/python_training
/Day1_homework.py
949
4.09375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @author: Homing @software: PyCharm Community Edition @file: Day1_homework.py @time: 2017/5/8 19:14 """ import random def guess_the_num(num): while True: a = int(input("Please enter a number:")) if a > num: print("The number is bigger:...
81a903a00474b6b855636b08ae4c138ff8c6ace0
Nic30/pyMathBitPrecise
/pyMathBitPrecise/utils.py
240
3.703125
4
from itertools import zip_longest def grouper(n, iterable, padvalue=None): """grouper(3, 'abcdefg', 'x') --> ('a','b','c'), ('d','e','f'), ('g','x','x') """ return zip_longest(*[iter(iterable)] * n, fillvalue=padvalue)
da3b9c90c1f8abef6d770361c78d351dc2bdda21
reshmapalani/pythonprogram
/1.py
120
3.578125
4
a=5 b=3 print(a,b,a+b) print(a,b,a-b) print(a,b,a*b) print(a,b,a/b)
e2ff007ed9f04c6ecae99e5ea4a9dd8088128b71
SaiKrishnaMohan7/Playground
/Python/100ProbsBishAintOne/P7.py
194
3.953125
4
X = int(input('Enter X: ')) Y = int(input('Enter Y: ')) matrix = [[0 for a in range(Y)] for b in range(X)] for i in range(X): for j in range(Y): matrix[i][j] = i * j print(matrix)
02f3ad2c664c33e3fa14a9769d5e304de7c5359e
yuryanliang/Python-Leetcoode
/100 medium/8/395 longest-substring-with-at-least-k-repeating-characters.py
990
4.09375
4
""" Find the length of the longest substring T of a given string (consists of lowercase letters only) such that every character in T appears no less than k times. Example 1: Input: s = "aaabb", k = 3 Output: 3 The longest substring is "aaa", as 'a' is repeated 3 times. Example 2: Input: s = "ababbc", k = 2 Output...
d269ac479f3a7c03c520ea4d11174e0cdefc1620
nicktakahashi/budget-tracker
/budget_calculator.py
738
3.765625
4
def main_method(): # each data has 3 fields a description and a value +/- , and a date TEST_DATA = [('paycheck', 1150, '07-20-2018'), ('rent', -850, "08-1-2018")] def calculate_net_cashflow(financial_data): net_cash = 0 for data in financial_data: net_cash += data[1] return net_cash monthly_net_cash...
30f53fc217638b6bb6abbbbc5e02ddcbe21f5d3d
tanya525625/Introdution-to-Python
/Fibonacci_Number_Generator.py
466
3.984375
4
def fibonacci_generator(n): a = 0 b = 1 i = 1 isOtr = False if n < 0: n = -n isOtr = True elif n == 0: yield 0 while i < n: b = b + a a = b - a i += 1 if (i % 2 != 0): if (isOtr == True): yield -a; ...
c6ccf796445e9bebf7c41c1a57c771b9ea17b9a7
kumar-atul-au13/WoodpeckerTA_Codes
/Week6/Day5/Asignment/BFS_using_list.py
833
3.796875
4
#video[6:00] https://drive.google.com/file/d/1btERkgmo2f8Rv2OT2DlKmgYk_26vMptE/view?usp=sharing from queue import Queue graph= { 'A': {'B': 1, 'D': 4}, 'B': {'C': 1, 'A': 1}, 'D': {'A': 4, 'C': 1, 'E': 2, 'F': 11}, 'E': {'D': 2, 'F': 7}, 'F': {'D': 11, 'E': 7}, 'C': {'B': 1, 'D': 1, 'H': 2, 'G'...
3b6a5d614c2f51b09c128e5382df86b3d4135e9b
Lewizkuz/lewrep
/ttiw0300_data-analytiikka/tehtavat/kerta1/t1b_tuplat.py
265
3.703125
4
def Poistup(sana): sana = sana.lower() tmp = [] for kirj in sana: if kirj not in tmp: tmp.append(kirj) return ''.join(tmp) print Poistup("AnaNasakäämä") print Poistup("Saippuakauppias") print Poistup("Floridalainen broileri")
15513ef4a7a940482c16a63114e633f7dd66e94f
newgarden/CtCI
/ch_01_arrays_and_strings/pr_09_string_rotation.py
1,344
4.21875
4
# -*- coding: utf-8 -*- """ String Rotation Problem statement: Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, sl and s2, write code to check if s2 is a rotation of sl using only one call to isSubstring (e.g., "waterbottle" is a rotation of "erbottlewat"). "...
e2cb62c9a2a2f04334aa44f082d3412be3391c8c
tjt7a/AutomataZoo
/YARA/code/yara2pcre.py
8,939
3.578125
4
# # Converts yara rules to PCRE # import os import sys import plyara import re import string # def addDelimiters(string): delim = "/" return delim + string + delim # Converts list of 0-255 int values to a string charset def values2Charset(values): retval = "[" for val in values: # ret...
a44adc36994b1926a42d7d25f01c29f21fe82694
outrageousaman/Python_study_marerial
/pd/options.py
1,529
3.78125
4
# pandas options # pandas provides the api to change some aspects of its behaviour # the api is composed of 5 relavent options # get_option # set_option # reset_option # describe_option # option_context # get_option takes a single parameter and returns the value as given in the output below import pandas as pd prin...
fc9b86286e93628d0b5335a441bb4e2a5b58acdf
AnaArce/introprogramacion
/Flujo_ciclico/E_3.py
68
3.625
4
for n in range(15,81): if n%5 == 0 or n%3 == 0: print(n)
eff0710a35069e165e2184f0ae6cc8e89e3ce31f
viv-Shubham/Computer-Society
/Basic/Calculate Factorial of A Number/SolutionByVanika.py
185
3.90625
4
# -*- coding: utf-8 -*- """ Created on Sat Mar 7 22:29:00 2020 @author: Vanika """ #factorial N = int(input("Enter number")) ans = 1 for i in range(1,N+1): ans = ans * i; print(ans)
981210cf8f49e5be0b5bdfce607627d03880652b
Y-Joo/Baekjoon-Algorithm
/pythonProject/divide and conquer/Quad-Tree.py
535
3.6875
4
def quad(x, y, n): check = nums[x][y] for i in range(x, x + n): for j in range(y, y + n): if check != nums[i][j]: print("(",end="") quad(x, y, n // 2) quad(x, y + n // 2, n // 2) quad(x + n // 2, y, n // 2) quad(...
bfca54cf7863556582464fe1a9c41c6e71a5161e
acc-cosc-1336/cosc-1336-spring-2018-Skynet2020
/src/homework/homework 12 last/win.py
608
3.65625
4
from tkinter import Tk, Button, Frame from display_labels import DisplayLabels class Win(Tk): def __init__(self): Tk.__init__(self, None, None) self.wm_title('Miles to km converter') self.geometry('320x90') self.frame = Frame() self.my_button = Button(self.frame...
a550f8bff3fa125ed2bbc37800176bbdb03d8bbd
appy2k13/python_codes
/ass8.4.py
243
3.765625
4
fh = open('romeo.txt') lst = list() for line in fh: tlist = line.rstrip().split() #print (tlist) for word in tlist : #print(word) if word not in lst : lst.append(word) lst.sort() print(lst)
a42acbb485c2d777da2be045c6825083c09f71b5
python-ops-org/python-ops
/dates/26-08-2020/l2.py
771
3.546875
4
import subprocess from subprocess import Popen from subprocess import Popen, PIPE #subprocess.run executes a command and waits for it to finish # """ Popen you can continue doing your stuff while the process finishes and then just repeatedly call subprocess. communicate yourself to pass and receive data to your pr...
f79380940e811b405414617af132d17d3687f781
buyi823/learn_python
/some_practices1/function_variable.py
254
3.9375
4
#!/usr/bin/python3 total = 0 #这是一个全局变量 def sum(arg1,arg2): total = arg1 + arg2 # total在这里是局部变量 print("函数内是局部变量 : ", total) return total sum(10,20) print('函数外是全局变量:' ,total)
b0a3b4a5dfba3f254a48a8a2dcf05016901f1370
kimth007kim/python_choi
/Chap7/Ex7_2.py
320
3.796875
4
import turtle t=turtle.Turtle() t.shape("turtle") def hexagon(): # turtle.penup() # turtle.goto(x,y) # turtle.pendown() for i in range(6): turtle.forward(50) turtle.left(60) # hexagon(125,125) # hexagon(0,0) for i in range(6): turtle.forward(50) turtle.right(60) hexagon()
940d939a9c92bf7da5f31bed65a88defc54e7e37
hezudao25/learnpython
/名片管理/cards_tools.py
2,747
3.875
4
#所有名片记录的列表 card_list=[] def show_menu(): """显示菜单""" print("*" * 50) print("欢迎使用【名片管理系统】 v1.0") print("") print("1.新增名片") print("2.显示全部") print("3.查找名片") print("") print("0.退出系统") print("*" * 50) def new_card(): """新增名片""" print("*" * 50) print("新增名片") #1. 提示用户输...
2da81254ad00fabbb5ce192e12ffc2d0714e455b
HenriqueHideaki/100DaysOfAlgo
/Day 81/Determinant.py
1,558
4.21875
4
''' The value of determinant of a matrix can be calculated by following procedure – For each element of first row or first column get cofactor of those elements and then multiply the element with the determinant of the corresponding cofactor, and finally add them with alternate signs. As a base case the value of dete...
6cf82ece8a78afda1a3ee0231829d5084b90e8ff
Anvi23/Practice_Programs
/factors of n.py
176
4.375
4
#Write a program to print all the factors of a given number. n=int(input('Enter a number: ')) print('Factors of n are: ') for i in range(1,n+1): if n%i==0: print(i)
380ca8177c0bf6f561b7856c697dd9758f403a68
Santhosh-23mj/Simply-Python
/VulnerabilityScanner/04_VulnerabilityScanner.py
1,016
3.609375
4
#!/usr/bin/python3 """ Program_4 The Most basic Vulnerability Scanner! """ import socket def retBanner(ip,port): s = socket.socket() try: s.connect((ip,port)) res = s.recv(1024) return res except Exception as e: print("[-] Error - "+str(e)) return def checkVulns(...
1e85fc96836d9eb53f63fa50ef3638fcaac2d723
webclinic017/New-Osama-Python
/Sending Email/osamasendemail.py
1,894
3.8125
4
""" import csv import yagmail emails = [] names = [] with open("contacts_file.csv") as file: reader = csv.reader(file) next(reader) # Skip header row for name, email, grade in reader: emails.append(email) names.append(name) yag_smtp_connection = yagmail.SMTP(user="osamapython@gmail.com", p...
534bd3260f0056ce94e33a4b5efc9af0df2e7b09
daniel-reich/ubiquitous-fiesta
/SYmHGXX2P26xu7JFR_17.py
1,159
3.640625
4
def number_groups(group1, group2, group3): z=[] h=[] a=set(group1) b=set(group2) c=set(group3) p=a.intersection(b) k=a.intersection(c) l=b.intersection(c) print(p,k,l) if p==set() and k==set(): return sorted(list(l)) elif p==set() and l==set(): return s...