blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
f969fbc14796652074b533441c2383ed1c1ede34
roshan2M/edX--mitX--introduction-to-computer-science-and-programming-with-python
/Week 2/Lecture 4 - Functions/In-Video Problems/Lec4.6Slide3.py
1,085
4.21875
4
# Lecture 4.6, slide 3 # This function takes in x, power, and epsilon as arguments and returns x taken to the root of power within the range epsilon. def findRoot1 (x, power, epsilon): ''' x and epsilon int or float, power an int epsilon > 0 and power >= 1 Returns a float y such that y ** power is ...
bf7378cf7161e1060b7f26997335d19de1ff9b4a
Jovioluiz/IA
/Tarefas RNAs/gradiente.py
766
3.828125
4
#TAREFA 2 #cálculo do gradiente import numpy as np def sigmoid(x): return 1/(1 + np.exp(-x)) def sigmoid_prime(x): #derivada da função sigmoide return sigmoid(x) * (1-sigmoid(x)) #taxa de aprendizado learnrate = 0.5 x = np.array([1, 2, 3, 4]) y = np.array([0.5])#erro bies = 0.5 #pes...
e69c46f3cee7f01ec37608f025ae05edccdfa011
bpthoms/CGU-IST303-Examples
/mod3/listDays.py
310
4.25
4
#Let's assign our list days=['Monday','Tuesday','Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] print("The first day of the week is " + days[1] + "? That can't be right.") #Let's reassign our list values days[1]='Sunday' print("The first day of the week is " + days[1] + ". Now that's more like it.")
ec4b7a7cad3b21a09a3b035092467d67d3b06c03
SiddarthSingaravel/CS50
/pset6/mario/less/mario.py
368
3.890625
4
from cs50 import get_int # getting correct user input while True: h = get_int("Height: ") if h > 0 and h < 9: break # initalizing i and j to 0 i = 0 j = 0 # running two loops for printing blocks for i in range(h): for j in range(h): if i + j < h - 1: print(" ", end="") ...
c11b2e4314e39ccec779208d5830e8e576d72965
sankalpreddy1998/Classical-Algorithms
/trees/BST.py
1,095
3.90625
4
class Node: def __init__(self,v): self.v = v self.left = None self.right = None class Tree: def __init__(self): self.root = None def insert(self,v): if self.root == None: self.root = Node(v) else: self._insert(self.root,...
86e4ea6ac7b05cf8e0e3272513358253511f4ee7
Scarv3s/DnD-dice-roll
/DiceRoll.py
772
3.796875
4
from random import randint D20 = randint(1, 20) D10 = randint(1, 10) D8 = randint(1, 8) D6 = randint(1, 6) D4 = randint(1, 4) dice = ["d20", "d10", "d8", "d6", "d4", "D20", "D10", "D8", "D6", "D4"] def roll(choice): if choice in ("D20", "d20"): print(D20) elif choice in ("D10", "d10"): ...
387032412a2e09ce4a82a9c2dfa54d42d8005236
TeddyBuckshot/day2Homework
/exercise_b_users.py
4,197
4.125
4
users = { "Jonathan": { "twitter": "jonnyt", "lottery_numbers": [6, 12, 49, 33, 45, 20], "home_town": "Stirling", "pets": [ { "name": "fluffy", "species": "cat" }, { "name": "fido", "species": "dog" }, { "name": "spike", "species": "dog" } ...
4eb36d01aca2b7eecb585ba6adaee149de29267d
DuyDn1305/using-python-GCI-
/helloWorld.py
184
3.75
4
msg = "GCI is great" for i in range(0, 10): print(msg) print("Hi, what's your name ?") name = input() print("Hello "+name+", please to meet you!") name = name[::-1] print(name)
172aa4ac8d61a8075b8d417a8ca8d4df660c17ad
bartko423/zadania_domowe_Bartlomiej_Ufnal
/New_base.py
1,703
3.5625
4
# jako argument domyślny dajemy typ zmienny - listę #def dodaj_imie(imie, imiona=[]): #imiona.append(imie) #eturn imiona # wywołujemy funkcję, bez podawania argumentu domyślnego lista_imion = dodaj_imie("Ola") print(lista_imion) # okazuje się, że kolejne wywołanie funkcji dodaje imie do # listy utworzonej pr...
e367c4b770d9a79eca92f7eca8e09f1fe465b879
bartko423/zadania_domowe_Bartlomiej_Ufnal
/ruletka.py
480
3.71875
4
# 5. ruletka: otrzymawszy liczbę, sprawdź czy jest ona: # czerwona czy czarna* # wysoka czy niska (do 18, od 18) # parzysta czy nieparzysta #PARZYSTE TO CZARNE NIEPARZYSTE TO CZERWON ruletka = int(input("Podaj liczbę")) if ruletka % 2 == 0: print("Czarne pole a więc liczba parzysta") else: print("Cze...
ee731b059372d40a750b8f02fe7ced4f0a2036ce
SamShepp/Practicals-2018
/prac_05/hex_colours.py
559
4.09375
4
""" CP1404 Practical Hexadecimal colour lookup """ COLOUR_CODES = {"AliceBlue": "#f0f8ff", "Blue1": "#0000ff", "BlueViolet": "#8a2be2", "Brown": "#a52a2a", "CadetBlue1": "#98f5ff", "Chartreuse1": "#7fff00", "Chocolate": "#d2691e", "Coral": "#ff7f50", "CornFlowerBlue": "#6495ed", ...
0192795e06e0f4136dafeaecce4855f28312b605
meghabisani/python_programs
/Games/Guess_Me/guess_me.py
1,424
4.125
4
from random import randint def guess_game(): num = randint(1, 100) print("-----WELCOME TO GUESS ME!-----") print("I am thinking of a number between 1 to 100") print("If your guess is within 10 of my number, I will tell you you're WARM!") print("If your guess is more then 10 away from my ...
2087309d2d6befb1f823329e1609f537ec6bc0c7
meghabisani/python_programs
/Games/Tic_Tac_Toe/tic_tac_toe.py
1,738
4.03125
4
from helper import * # Game def tic_tac_toe(): print('Welcome to Tic Tac Toe!') while True: # Reset the board board = ['$'] + [' '] * 9 mark1, mark2 = player_input() chance = choose_first() print(f'{chance} will go first') ans = input('Are you re...
edb13d6b7a4eee175705ad2045c9089d63aaaa9a
KobiBeef/from-richard---Copy
/test00.py
1,914
4.125
4
def compute_grade(): while True: score = input('Enter score from 0.0 to 1.0: ') try: if len(score) == 0: print ('enter a value') else: num_score = float(score) if num_score <= 1.0: if num_score >= 0.9: print ('Grade A') elif num_score >= 0.8: print ('Grade B') elif num...
ee00f309ec001fdb7c6b1171518ef939358e02b4
acevedodavid/ProySistemasOperativos
/servidor.py
14,773
3.859375
4
import socket import sys import time import math import tabulate #clase de Queue para la cola de listos class Queue: #Constructor creates a list def __init__(self): self.queue = list() #Adding elements to queue def enqueue(self,data): #Checking to avoid duplicate entry (not mandatory) ...
bb8f7073ca39b85e3cc01d8b6e7065474d2108a9
zdRan/FuturePlanNodes
/lesson009/code/python_basic/file_operation.py
923
3.953125
4
# 文件操作 from typing import AnyStr def read_file(): # 文件名,权限(r、w) file = open("exception.py", "r", encoding="UTF-8") # print(file.read())# 一次性加载,文件过大占用内存 print(file.read(10)) file.close() # read_file() # with open # func(形参:类型 = 默认值) -> 返回类型 # 非强制,解释说明 def read_file2(filename: str = "aaa") -> Any...
7b63df6495278b79ded259f3b0bb71ac69612faa
zdRan/FuturePlanNodes
/lesson010/code/baisc_python/thread_function_test.py
808
3.578125
4
import threading import time import random num = 1000 def my_print(info, info2): time.sleep(random.randint(1, 10)) print("执行事件" + info + ":" + info2) # 全局变量,多线程共享 global num num = num - 1 print(num) if __name__ == "__main__": # args 参数类型是一个元组 t1 = threading.Thread(target=my_print, a...
fd54e75e449317d6b286795d5587c4cca2ace888
zdRan/FuturePlanNodes
/lesson009/code/python_basic/exception.py
868
4.125
4
""" BaseException 是所有异常类的基类 处理方式 try: 代码块 except 异常名称 代码块:处理异常 else: 代码块,不抛出异常被执行 finally: 总是会被执行 """ # try: # file = open("aa", "r") # i = 1 # except FileNotFoundError as e: # print(e) # print("发现异常,没有找到文件") # else: # print("没有发生异常") # 子类异常在前,父类异常在后, try: file = open("aa", ...
547bbb72e771553073f3beff13e17261e7b9e357
recepsirin/Machine_Learning_Algorithms
/clustering_algorithms/k-means/k-means.py
1,173
3.859375
4
import pandas as pd from sklearn.cluster import KMeans import matplotlib.pyplot as plt data_set = pd.read_csv('customers.csv') X = data_set.iloc[:, 2:].values # picking age, consumption rate and salary columns and making assignment to X # Model Building # n_clusters: The number of clusters to form as well as the nu...
7b459b85a40d569a2935458f000d02ffcef8dec8
JieSun1990/hackerrank-python
/ginortS.py
414
3.625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT a = input() x1 = [] #lower x2 = [] #upper x3 = [] #odd x4 = [] #even for w in a: if w.islower(): x1.append(w) elif w.isupper(): x2.append(w) elif w.isdigit(): if int(w)%2 == 0: x4.append(w) els...
2b37f5fce49833a25d9cee96bd887add115f2743
arbaaz-abz/Programming
/Graphs/djikstra.py
862
3.640625
4
def pick(visited,dist): min = 998 for i in range(0,len(dist)): if i not in visited and dist[i] < min: min = dist[i] index = i return index def djikstra(adjacency_list,dist,visited): visited.append(0) while len(visited) != len(adjacency_list): vertex = pick(visited,dist) print("Picked Vertex : ",vertex...
1e8873f203c643aaefa3a198d78e98b108aabafd
lymanreed/Loan_Calculator
/Loan Calculator/task/creditcalc/creditcalc.py
2,962
3.5
4
import math import argparse import sys def calc_periods(principal, payment, interest): interest /= 100 nom_interest = interest / 12 periods = math.ceil(math.log(payment / (payment - (nom_interest * principal)), 1 + nom_interest)) years = periods // 12 months = periods % 12 print('It will take...
116fd9180010be36f75d6e416fac1baa2d7c2b76
tuanbieber/code-tour
/9-interval-list-intersection.py
805
3.59375
4
from collections import defaultdict from collections import OrderedDict class Solution: def __init__(self): pass def sort(self, A, B): res = [] i = j = 0 while i < len(A) and j < len(B): low = max(A[i][0], B[j][0]) high = min(A[i][1], B[j][1]) ...
9ecfffc1746118a5d2ee81dbea3dfffe23907ee6
MrTresor/Tresor-s-haven
/askisi10.py
843
3.5625
4
#bombomastoras import random rows = int(input("dwse grammes")) cols = int(input("dwse sthles")) while True: bombs = int(input("dwse arithmo gia bombes mikrotero h iso apo rows*cols")) if bombs > ((rows-1)*(cols-1)): print("i said mikrotero") else: print("ok!") break ar...
dd456ceb3395e91747d8df5e9989bd00dafbb33b
Apollo1840/Advanced-Python
/session/leetcode_example/challenges.py
7,382
3.875
4
# ----------------------------------------------- # Intersection of Two Arrays II # Given two arrays, write a function to compute their intersection. class Intersection_of_Two_Arrays_II(object): def intersect(self, nums1, nums2): d = {} result = [] # build up the dict of number # c...
ef5ff22f2757ed6860340cac77e8ef446a6dd500
Apollo1840/Advanced-Python
/02_control_flow_and_function.py
5,605
4.0625
4
# -*- coding: utf-8 -*- # 1 control flow # 1.1 while ''' while else ''' # example: jumping check # 0, 1, 3, 7, 15, 31 numbers = range(1000) index = 0 end_index = 100 wanted = 15 while index < end_index: print(numbers[index]) if numbers[index] == wanted: print("we find it") break ind...
c2452070ac61e033fbf9d08aaa3433c03c12eaf2
dansgithubuser/playground
/languages/python/descriptor.py
2,333
3.6875
4
def major_section(name): print('\n'+'='*20+' {} '.format(name)+'='*20) def minor_section(): print('-'*20) class Decorator(object): def __init__(self, function): print('Decorator.__init__ entered, function is {}'.format(function.__name__)) self.function=function print('Decorator.__init__ returning') def __call...
ef9e3a530ed65423ea68171f8d595ad5ef0c48f7
leafeecs/LinearStructureAndDP
/own/chap2_oop/inheritance_ex.py
1,847
4.125
4
# Super Class(Base Class) class Father(object): # Father 라는 class 의 attribute(member variable) strHometown = 'Jeju' # Constructor(class 를 만들 때 항상 생성되는 것) def __init__(self): print("Father is created.") def doFatherThing(self): print("Father's action") def doRunning(self...
9b5fac2f79d39faad448a3c843cbc71aa6517e5e
leafeecs/LinearStructureAndDP
/own/chap1_python_overview/tuple_ex.py
401
4.03125
4
tplTest = (1, 2, 3) print('-----------------------------------------') print(tplTest) print(tplTest[0], tplTest[1], tplTest[2]) print(tplTest[-1]), tplTest[-2] print(tplTest[1:3]) print(tplTest + tplTest) print(tplTest * 3) # Tuple 은 immutable, 즉 변경할 수 없다. 왜냐하면 여러사람이 쓰는 # 프로그램에서 바꿀 수 없는 값도 필요하기 때문이다. tplTest[0] = 10...
4b0d9a311250a6c2f8749a7617cb4bb16f012da0
leafeecs/LinearStructureAndDP
/own/chap3_linked_list_stack_queue/insert_in_array.py
760
3.796875
4
# Goal: insert 'c' between 'b' and 'd' in list x # Btw, a := instert position index x = ['a', 'b', 'd', 'e', 'f'] print("Before insert 'c' b/w 'b' and 'd':", x) idxInsert = 2 valInsert = 'c' # 1. Make new list, or y, with six cells y = list(range(6)) # 2. Copy the reference links of x[0:a-1] to y[0:a-1] # (retrieval...
a43855412b07379fb0602a06dcb65b89d7e73e97
Jeling/learning-git-task
/shopping_list.py
434
3.546875
4
import os clear = lambda: os.system('cls') clear() shopping_list = { "Piekarnia": ["chleb", "bułki", "pączek", "chałka"], "Warzywniak": ["marchew", "seler", "rukola", "pietruszka"] } counter = 0 print("Lista zakupów") for place, product in shopping_list.items(): print(f"""Idę do {place}, kupuję tu następu...
d3da74a1d4a4b66b28d826fbf14932e557069836
Patriziabattisti/Exercices
/Python/test_code/packagetest/fonctions.py
824
3.5
4
from random import randrange, randint def table(nb, max=10): i=0 while i<max: print(i+1,"*",nb,"=",(i+1)*nb) i+=1 def verif_chiffre(var): verif=True try: int(var) except ValueError: print("Variable incompatible avec un entier") ...
c18637a543a368bf150e01b38f7eea6163cf90ee
zuzu-sun-18/ML-exercise
/Multi_classification_logistic_regression/predictOneVsAll.py
530
3.5
4
import numpy as np from sigmoid import * def predict_all(X, all_theta): # compute the class probability for each class on each training instance h = sigmoid(X @ all_theta.T) # 注意的这里的all_theta需要转置 # create array of the index with the maximum probability # Returns the indices of the maximum values alon...
a2b0fa8aae80403fc15d6fcf884a7610e15a528e
1020431880/flask_demo
/src/utils/PageUtil.py
1,770
3.96875
4
import json """ 分页工具类 """ class PageUtil(object): def __init__(self): self._page_num = 1 self._page_size = 10 self._total_page = 0 self._total_size = 0 self._results = None # 当前页数 @property def page_num(self): return self._page_num @page_num.sette...
bdf060b87f0ee92130e1acbadcfa0808816b8f0d
joycetipping/knights-tour
/knights-tour.py
2,465
4.0625
4
# vim: foldmethod=marker : import math import sys # Assignment: # # Given a square chessboard of arbitrary side length and a knight that starts on an arbitrary # square, output a path allowing the knight to traverse the entire board. The knight moves according # to the traditional rules of chess. # function "moves" ...
e002394446e721f19d21a8d52d7725607274684d
capedcrusader743/A.L.F.R.E.D
/alfred.py
2,363
3.6875
4
import pyttsx3 ##pyttsx3 is a tool use to convert text to speech import datetime import speech_recognition as sr import webbrowser as wb import os alfred = pyttsx3.init() voice= alfred.getProperty('voices') alfred.setProperty('voice', voice[0].id) ## Male voice def speak(audio): print('Alfred: ' + audio) alfr...
eebd81b81a92e90f38bf7c2441a05710e5119c56
PhilipWoulfe/PythonProjectWinter2017
/StockDay.py
2,812
3.765625
4
from datetime import datetime class StockDay(object): def __init__(self, stock_date, open_value, high, low, close, adjusted_close, volume): """ Create a StockDay object :param stock_date: date for Stock values :param open_value: opening value of the stock on date :param hig...
522e619b1e5651e2f4fafd4bd32d08f582987847
PFPF/Conversion
/BossConvert.py
2,753
4.0625
4
# Super converter which took me 2 hours... Units are crazy. print("\n\033[1mffff\033[1mThis is a super converter. You can convert many types of units. ") print("For each item you need to input at first a magnitude then a unit. (items are added together)") print("At last, enter \"end\" and, in a new line, the unit you ...
96af5ed0ed5d2b81de0977c40191755a7278d09c
monish7108/PythonProg
/WordsFrequency.py
1,201
4.09375
4
import sys #print(sys.version) #it is of version 2.7.6 go to line 34 """This program takes a particular file input and gives you the word count of every word present in that file""" for i in range(1,len(sys.argv)): try: data = open(sys.argv[i],"r") except IOError: print("file not found")...
754fdca4ef817e1fa10ca2a974bad6d6875d3511
subhasmitasahoo/leetcode-algorithm-solutions
/maximal-square.py
845
3.515625
4
# Problem link: https://leetcode.com/problems/maximal-square/ # Time complexity: O(m*n) # Space complexity: O(n) class Solution: def maximalSquare(self, matrix: List[List[str]]) -> int: rsz = len(matrix) if rsz == 0: return 0 csz = len(matrix[0]) if csz == 0: ...
1e108cb74064a15296c8c74af2abd1f95cfa1a83
subhasmitasahoo/leetcode-algorithm-solutions
/symmetric-tree.py
780
3.9375
4
# Problem link: https://leetcode.com/problems/symmetric-tree/submissions/ # Time complexity: O(n) # Space complexity: O(n) # 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 clas...
9a49f38c596e6f676dbd4c764aab71f9f8c61566
subhasmitasahoo/leetcode-algorithm-solutions
/construct-the-rectangle.py
460
3.671875
4
#Problem link: https://leetcode.com/problems/construct-the-rectangle/submissions/ #Time complexity: O(sqrt(n)) #Space complexity: O(1) class Solution: def constructRectangle(self, area: int) -> List[int]: root = int(sqrt(area)) for i in reversed(range(1, root+1)): if area%i == 0: ...
6999b82151431cb6606a0a9d811fc226ceb613cd
subhasmitasahoo/leetcode-algorithm-solutions
/can-place-flowers.py
504
4.09375
4
#Problem link: https://leetcode.com/problems/can-place-flowers/ #Time complexity: O(n) #Space complexity: O(1) class Solution: def canPlaceFlowers(self, flowerbed: List[int], n: int) -> bool: i = 0 for i in range(len(flowerbed)): if(flowerbed[i] == 0 and (i == 0 or flowerbed[i-1] == 0)...
2f0e00e99395a6075352b2e302c099297e3f8504
yanlele/python-index
/19年/12月/demo5/python目录动态操作.py
4,457
3.59375
4
class Node(): ''' 节点类型 ''' def __init__(self, data, level=0): self.data = data # 节点数据 self.level = level # 节点类型 self.fatherNode = None # 父节点 self.children = [] # 子节点 class MenuTree(): def __init__(self, rootData): self.initTree(rootData) ...
fd3931133b86f56926ffb2e53c545ce2c8e9b082
yanlele/python-index
/book/01、python编程从入门到实践/项目2、数据可视化/15章、生成数据/random_walk.py
1,935
4.03125
4
from random import choice class RandomWalk(): """ 一个生成随机漫步数据的类 """ def __init__(self, num_points=5000): """初始化随机漫步的属性""" self.num_points = num_points # 所有随机漫步都开始于(0,0) self.x_values = [0] self.y_values = [0] def fill_walk(self): # 不断漫步,直到列表达到指定的长度 ...
7aa94a5e1673ad57b923153be8ebd7cd7f6fef23
yanlele/python-index
/book/01、python编程从入门到实践/03章、数组简介/01、排序方法.py
249
4.125
4
cars = ['bmw', 'audi', 'toyota', 'subaru'] cars.sort(reverse=True) print(cars) print('-----------------------') # 临时排序 这个东西有问题,程序会报错 cars = ['bmw', 'audi', 'toyota', 'subaru'] print(cars.sorted(cars)) print(cars)
d23246fe3afcfe43f409605f570f67013abd56bb
yanlele/python-index
/book/01、python编程从入门到实践/04章、操作列表/示例4.2.py
569
4.1875
4
import math # 切片 arr = ['pizza', 'falafel', 'carrot cake', 'cannoli', 'ice cream'] print('前三个元素为: ', arr[:3]) print('中间三个元素为: ', arr[math.floor(len(arr)/2)-1:math.ceil(len(arr)/2)+1]) print('最后三个元素为: ', arr[-3:]) # 你的比萨和我的比萨 my_foods = ['pizza', 'falafel', 'carrot cake'] friend_foods = my_foods[:] my_foods.append('好吃的...
fce20ac20ac7251c8cc5ac789d79a8c7602239f1
yanlele/python-index
/book/01、python编程从入门到实践/项目2、数据可视化/16章、下载数据/highs_lows1.py
223
3.640625
4
"""分析 CSV 文件头""" import csv filename = 'sitka_weather_07-2014.csv' with open(filename) as f: reader = csv.reader(f) header_row = next(reader) # 这个就是读取的头部信息 print(header_row)
d173725f95bd20c2bb67e6d7b79c0ae65f492497
yanlele/python-index
/book/01、python编程从入门到实践/项目2、数据可视化/16章、下载数据/highs_lows2.py
379
3.90625
4
"""打印文件头及其位置""" import csv filename = 'sitka_weather_07-2014.csv' with open(filename) as f: reader = csv.reader(f) header_row = next(reader) # 这个就是读取的头部信息 for index, column_header in enumerate(header_row): # 对列表调用了enumerate()来获取每个元素的索引及其值。 print(index, column_header)
9122e014d901e2dd2eb79387d480cd416e76f0c0
yanlele/python-index
/book/01、python编程从入门到实践/10章、文件和异常/04、存储数据/remember_me.py
1,179
4.03125
4
# import json # # username = input('你的名字是什么呢?') # filename = 'username.json' # with open(filename, 'w') as f_obj: # json.dump(username, f_obj) # print('已经记住你的名字了!') # import json # filename = 'username.json' # # try: # with open(filename) as f_obj: # username = json.load(f_obj) # except FileNotFoun...
05c172e86e9cd2e3e372f8e09189ff1d3263fe70
bernalde/Herramientas_Computacionales
/Ejercicios en Clase/Ejercicio1.py
931
3.625
4
import numpy as np data=np.loadtxt("edadesvsalturas.txt") def factorial(n): if n==0: return 1 else: return n*factorial(n-1) print factorial(3) """ def square(x): print x**2 def convert(x,y): if y==0: return x*1.16 elif y==1: return x*2.54 elif y==2: ...
540e6eaec277fe10c9559501943d0891a4b88eb7
cama-ka/OC_P4
/round.py
1,741
3.671875
4
class Round: def __init__(self, liste, number): self.liste = liste self.number = number def get_liste(self): return self.liste def get_number(self): return self.number class Round1(Round): def __init__(self, liste, number, groupe1, gr...
43d61d5fc5967d29faff4a58753f7be98cd424cd
kmoon601/teste
/mylib/lab24-2.py
533
3.65625
4
count=0 # 클래스 밖의 변수 class Rectangle: count = 0 #클래스의 변수 def __init__(self, fdata, sdata): self.fdata = fdata self.sdata = sdata Rectangle.count += 1 def calcArea(self): tdata = self.fdata * self.sdata return tdata @staticmethod # 정적메서드선언 def m...
add0ef83806a55b33e4d838e9724a736948875b5
GeorgiSGeorgiev/TheClassifierProject
/graph_plotter.py
10,570
3.8125
4
import numpy as np # defines the Numpy arrays we are using below (and in the other scripts) import matplotlib.pyplot as plt # main Python plotting library # This script contains only functions that create different graphs used by the other scripts. # Created by: Georgi Stoyanov Georgiev. # as par...
88c08b269ded1cb3ca36ea79a7f26b2b6450c3ec
Alxndr3/python_exercices2
/ex086a.py
214
3.953125
4
l = [[], [], []] for x in range(0, 3): for y in range(0, 3): l[x].append(int(input(f'Digite um valor para [{x}, {y}]: '))) for z in range(0, 3): print(f'[ {l[z][0]} ] [ {l[z][1]} ] [ {l[z][2]} ]')
e792d0f3ad0b7496f0d066ce457669dc21e2b9ed
Alxndr3/python_exercices2
/ex065a.py
501
3.859375
4
n = maior = menor = int(input('Digite um número: ')) c = 'S' m = 0 cont = 1 while c == 'S': c = str(input('Deseja digitar outro? [S/N]: ')).upper() if c == "S": i = int(input('Novo número: ')) n += i cont += 1 m = n / cont if i > maior: maior = i if i ...
4975f0f5a1f54895276129986d5c3c75941b7030
Alxndr3/python_exercices2
/ex077b.py
322
3.734375
4
tupla = ('aprender', 'programar', 'linguagem', 'pythom', 'curso', 'gratis', 'estudar', 'praticar', 'trabalhar', 'mercado', 'programador', 'futuro') for palavra in tupla: print(f'\nNa palavra {palavra.upper()} temos', end=' ') for x in palavra: if x in 'aeiou': print(x, end=' ') ...
cad6ab346d4ec309f8a71b0e726592e683009e1a
Alxndr3/python_exercices2
/ex071b.py
548
3.5625
4
print('=' * 21) print(':^30'.format('===BANCO ALEXANDRE===')) print('=' * 21) valor = int(input("Quanto quer sacar? R$")) saq = valor ced = 50 totced = 0 while True: if saq >= ced: saq-= ced totced += 1 else: if totced > 0: print(f'Total de {totced} Cédulas de {ced}') ...
4f8403e1941b8681a4e6de9ed80ab6675c04cfd9
Dakrfox/python_curiosity
/challenge_list_comprehension.py
194
3.609375
4
#a list comprehension with i = multiples of (4, 6 and 9) def run(): list = [i for i in range (1,100000) if i%4==0 and i%6==0 and i%9==0] print(list) if __name__ =='__main__': run()
4d5fe9427f0ff68f5e05e294380ecd99d1a84389
bmusuko/Maze
/maze.py
5,202
3.5
4
from copy import deepcopy import math def jarak(x1,y1,x2,y2): return math.sqrt((x1-x2)**2 + (y1-y2)**2) def solveBFS(filename): file = open(filename,"r") a = [] n = 0 for line in file: y = line.rstrip() temp = [] for c in y: temp.append(int(c)) a.append(temp) n += 1 m = len(a[0]) ...
a119f52105f455056e1000effdb0de88131ef227
brandonmaday/adventofcode2019
/day1.py
766
3.546875
4
from typing import List, TypedDict from puzzleInputs import day1Puzzle # CHALLENGE ONE def parsePuzzleIn (modules: str) -> List [int]: """ Gets puzzle input data in a usable type """ return [int (m) for m in modules.split ("\n")] def moduleFule (mass: int) -> int: """ Calculates the Fuel of a mass """ ...
d8e6b732cd1c9933b5a358196961cce94e17ae7f
jeremysnyder/readdaily
/data/process-reading-plan-csv.py
2,441
3.5
4
import csv, json, copy readers_reading_file = './ReadersBiblePlan-ReadingPlan.csv' verses_reading_file = './VersesReadingPlan-ReadingPlan.csv' def file_to_map(file): readings = {} with open(file, 'r') as f: r = csv.reader(f) for row in r: item = {} day = row[0] ...
e2756037b1c5d1d9d2f9e8c13d27439ddb747301
erick-r-anderson/UPS-_Router
/HashTable.py
2,146
3.78125
4
# implementing a chaining hash table. will use ten buckets # packages will be inserted as objects. key will be the package_id # based on the chaining hash table introduced in the Zybooks text, section 7.8 # Data Structures and Algorithms by authors Roman Lysecky and Frank Vahid class PackageHashTable: def ...
15707761f8f1eec7cdbcefe452c4b02867bc4926
avinit10/facebookdata
/datapull.py
1,849
3.5
4
import requests import json # for this code to run you need to get access_token of the app you made # after you have to extend that token to make is valid for more than because it expires in 2 hours #-----------------class creation to pull data from facebook--------------------------------------- class dataFromFac...
e19c8ef113d904384ba9193296b828866baeaf14
GabbyBarajasBroussard/darden-classification-exercises
/acquire.py
3,175
3.515625
4
#!/usr/bin/env python # coding: utf-8 # In[9]: import numpy as np import pandas as pd import matplotlib.pyplot as plt get_ipython().run_line_magic('matplotlib', 'inline') import seaborn as sns import env import os from sklearn.model_selection import train_test_split from sklearn.impute import SimpleImputer from skle...
6daa3533774e2e389acf5f7f41a447ae4947f916
dexter2206/asc
/source/asc-0.1/src/asc/utils/indexer_property.py
2,851
3.59375
4
class IndexerProperty(object): r""" Class for representing properties that can be indexed (like dictionary) with source of data being user defined functions or methods. """ def __init__(self, get_fun, set_fun, keys_fun): r""" Initializes new instance of IndexerProperty. :par...
907ce8bb08f373c0fef1c0fa9244c5540630a2c5
KSRCEECE/py
/leap.py
153
4
4
print("Enter the Year") a= int (input()) if (a%4 ==0) and (a%100 !=0) or (a%400==0): print(a," Leap Year") else : print(a," Not a Leap Year")
d03cc0cf759eff921a8f78a22f94c85771aec8ee
Vedanth29/PYTHON_Archive
/04_simple_interest.py
162
3.78125
4
#Vedanth M p = int(input("enter the Principle amount::")) t = int(input("enter the Time::")) r = int(input("enter the Ratio::")) s = int((p * t * r)/100) print (s)
ab41f508cadddaba83f3a96e66b010a0522096b5
Vedanth29/PYTHON_Archive
/12_find_ASCII.py
88
4.03125
4
#Vedanth M n = input("enter the alphabet:") print("The ASCII value of "+ n +" is",ord(n))
b6dc6120ce40db9d88977fa9cbb8e72760b4e820
SalvaJ/Python-Examples
/numero_suerte.py
298
3.78125
4
from random import randint print "¡Números de la suerte! Se generarán 3 números." print "Si uno de ellos es '5', ¡pierdes!" recuento = 0 while recuento < 3: num = randint(1, 6) print num recuento += 1 if num == 5: print "Lo lamento, ¡tú pierdes!" break else: print "¡Tú ganas!"
716a85ba31be2441dfc54811d580d6b2490f20e6
SalvaJ/Python-Examples
/purificar.py
297
3.6875
4
# Funcion que toma una lista de numeros y quita todos los impares def purificar(lista): print lista i=0 while i in range(0, len(lista)): if lista[i] %2 != 0: del lista[i] else: i+=1 print lista return lista print purificar([1,2,3])
b61848e5bc4d6beed6f1f2734d241f19a5e69cbe
logancarlf/SARS-CoV-2_simulation
/simulation.py
3,544
3.703125
4
import numpy as np import matplotlib.pyplot as plt import scipy.integrate as sp from differential_eqns import differentials class SIRVD_simulation: def __init__(self, population_size, infected, recovered, vaccinated, deceased, infection_rate, recovery_rate, mortality_rate): ...
32aaa155f6626ce9bfe4eeb8a39cb9d8f2bb2490
TarasKravchuk/geo_random_1
/geo_random/shapes/base.py
1,147
3.71875
4
import math from geo_random import exceptions class Point(): def __init__(self, x, y): self.x = x self.y = y def point_coordinates (self): point = [self.x, self.y] #print(type(point)) return point class Line(): def __init__(self, point_1, point_2): self.poin...
3f517bbb7d3db5c2188086d61edefde95919ffbc
apparent-moon/git_practice
/hello.py
130
3.9375
4
for i in range(1, 10+1): if i%3==0: print('world') elif i%5==0: print('hello') else: print(i)
deadce1a8547298a196eb718a7d458011f9a51b5
apresland/algorithms-and-data-structures
/python/algorithms/algorithms.py
1,338
3.890625
4
class Algorithms(object): def bubble_sort(input): if len(input) <= 1: return input for end in range(len(input)-1,-1, -1): for idx in range(0,end): if (input[idx+1]) < input[idx]: tmp = input[idx] input[idx] = input[idx...
359325e258f5488c3ea9ef3a61eb23cd5c799a79
rrkas/Exercism-Python
/11_acronym/acronym.py
226
3.90625
4
def abbreviate(string): s = "" for w in string.split(" "): if w[0] == '_': s = s + w[1] elif w != '-': for w_ in w.split('-'): s = s + w_[0] return s.upper()
d075faf02101a101f9b361b843c4892bd7dd3bac
rrkas/Exercism-Python
/12_kindergarten-garden/kindergarten_garden.py
609
3.640625
4
class Garden: def __init__(self, diagram, students=["Alice", "Bob", "Charlie", "David", "Eve", "Fred", "Ginny", "Harriet", "Ileana", "Joseph", "Kincaid", "Larry"]): self.diagram = list(diagram.split("\n")) self.students = list(sorted(students)) def plants(self, name): idx = self.stu...
5f0d087e93db7002d10bb66cbc9d2d46c5be227d
rrkas/Exercism-Python
/15_clock/clock.py
808
3.921875
4
mins_in_days = 24*60 class Clock: def __init__(self, hour, minute): m = ((60*hour + minute)%mins_in_days + mins_in_days)%mins_in_days self.hour = m//60 self.min = m%60 def __repr__(self): return f"{self.hour:02d}:{self.min:02d}" def __eq__(self, other): return self...
0bbffa299175720319dcc3361793c2bfb9a79e2b
rrkas/Exercism-Python
/27_yacht/yacht.py
1,913
4.0625
4
""" This exercise stub and the test suite contain several enumerated constants. Since Python 2 does not have the enum module, the idiomatic way to write enumerated constants has traditionally been a NAME assigned to an arbitrary, but unique value. An integer is traditionally used because it’s memory efficient. It is a...
674e9ccac99320d16942996645ea6547e3a867b8
rrkas/Exercism-Python
/52_pythagorean-triplet/pythagorean_triplet.py
408
3.5625
4
from math import floor def triplets_with_sum(n): s = [] for i in range(n // 3): for j in range(i+1, n // 2): k = (i**2 + j**2)**0.5 print(k, int(k), k%1) if i + j + int(k) == n and k%1==0: t = [j, i, int(k)] t.sort() s...
d742f10db5af99e13be43111d2873535caa8143c
rrkas/Exercism-Python
/51_sublist/sublist.py
468
3.6875
4
SUBLIST = 'a in b' SUPERLIST = 'b in a' EQUAL = 'a = b' UNEQUAL = 'a <> b' def sublist(a: list, b: list): if a == b: return EQUAL if len(a) == len(b): return UNEQUAL la = len(a) lb = len(b) if la > lb: if any([b == a[i:i+lb] for i in range(la-lb+1)]): return SUP...
43a314bb3c0120f3d136bc5692f0d3f8523726c0
diegopau/chattyhive-backend
/core/test/text_generator/hive_name_generator.py
940
3.609375
4
from random import randint import os file_path = os.path.join(os.path.dirname(__file__), 'random_english_words.txt') english_words_txt = open(file_path) english_words = english_words_txt.read().split() number_of_words = len(english_words) print("Number of english words: ", number_of_words) def create_hive_name(): ...
3df79e24395c66a3038017db891f20bd08c4d182
razorblaze18/Python-lab
/python/python lab exercises/lab2.6.py
225
3.71875
4
a=input('enter a=') b=input('enter b=') c=input('enter c=') d=input('enter d=') e=input('enter e=') f=input('enter f=') sum=a+b+c+d+e+f print 'sum=',sum percentage=(sum/600.0)*100.0 print 'percentage=',percentage
c90e686eec1f1076d42871f5048ac2d232b52e66
razorblaze18/Python-lab
/python/python lab exercises/lab2.11.py
273
3.90625
4
print 'please enter marks less than 100' a=input('enter marks a=') b=input('enter marks b=') c=input('enter marks c=') d=input('enter marks d=') e=input('enter marks e=') sum=a+b+c+d+e print 'sum=',sum percentage= (sum/500.0)*100.0 print 'percentage=',percentage
f306c405903dbfb5319c3f13741685a98fe8418d
rafavilvert/Senai-SA2-Etapa1
/Exercicio3.py
461
3.96875
4
# 3. Escreva um programa que leia 20 valores inteiros # e informe a média deles, o maior e o menor valor. lista = [] i = 0 while i < 20: L = int(input("Digite o valor %i° valor inteiro: " % (i+1))) lista.append(L) print(list) i += 1 print(lista) media = sum(lista) / len(lista) print("A media dos 20 ...
830f391a56e2bdb3ab7dfe5b21d624805588c862
yasarza/testrep
/wellcome.py
598
3.734375
4
class MyClass(object): instance_count = 0 def __init__(self, value): self.__value = value MyClass.instance_count += 1 print("instance No {} created".format(MyClass.instance_count)) def aMethod(self, aValue): self.__value *= aValue def __str__(self): return "A MyCl...
131efdb43b1d3b1fd6ef9fab1b234da41a360192
almersesunan/ds_fibonacci_function
/find_fibonacci.py
698
4.0625
4
def find_fibonacci(x: int) -> bool: """ Menemukan bilangan bulat x di dalam suatu deret fibonacci. Apabila x ada di dalam suatu deret fibonacci, maka kembalikan True. Jika tidak ada, maka kembalikan False """ # write your code here a = 1 b = 1 while True: #Looping sampai ketemu retur...
6731fa154c9ad98fa6c9371acbf47b1cf5fdae12
ty-smooth/classwork
/week_2/weekend/modules/pandas_helper.py
3,110
3.53125
4
import logging import sys import pandas as pd def display_dataframe(df, n=5): """Displays the first n rows of the dataframe Parameters ---------- df : dataframe The input dataframe Returns ---------- None """ head = df.head(n) logging.info(f"{head}") def groupby_si...
1790c55de132e974c628ca2d34c4bd15d465fe02
ty-smooth/classwork
/week_2/weekend/archive/archive.py
624
3.5625
4
def validate_emails(email, col, index): try: valid = validate_email(email) email = valid.email except EmailNotValidError as e: logging.error(f"Index: {index}, Column: {col}, Not a valid email address.") def validate_email(email, col, index): is_valid_email = bool(re.search(r"^[\w\.\+\-...
942f42e1b5f763d696bfdcf0ac9817d9d6e83095
ask4physics/python-ICDL
/ICDL Computing/StudentCodeFiles_Computing/Lesson 12/ArrowSmall.py
203
3.5625
4
def stars(number_of_stars): answer='' for i in range( number_of_stars ): answer+='*' answer=answer.center(30) return answer print( stars(1) ) print( stars(3) ) print( stars(5) )
e2380badb9156a056c921047a43911d6c6056adf
ask4physics/python-ICDL
/ICDL Computing/TeacherCodeFiles_Computing/Lesson 11/FizzBuzz.py
556
4.15625
4
# This function returns True if x is exactly divisible # by divisor. Otherwise it returns False. def IsDivisibleBy( x, divisor ): return int(x/divisor)*divisor == x for x in range(1,101): if( not IsDivisibleBy( x, 3 ) and not IsDivisibleBy( x, 5)): print( x ) if( IsDivisibleBy( x, 3 ) and not IsDi...
32d4ca78b44e353c2d1f0c73d2d4d7563a5e6034
ask4physics/python-ICDL
/Sample Test/workfiles/Data_Output.py
218
4.21875
4
# The program below asks the user what height they are. # Update the program to output the users height to the screen myHeight = int(input("What is your height: ")) # Update the program here
3dfaea2f61c87a43ef6c719b125ed86f41321eb2
ask4physics/python-ICDL
/Day 2 (29012021)/Arrow.py
370
3.796875
4
def stars(number_of_stars): answer='' for i in range( number_of_stars ): answer+='*' answer=answer.center(30) #The center() method will center align the string, # using a specified character as the fill character. return answer print( stars(1) ) print( stars(3) ) print( stars(5) ) print...
f4befdfd16d850beca3bcc8d6c70f65b9c8ade27
ask4physics/python-ICDL
/Sample Test/workfiles/If_Statement.py
280
4.1875
4
# Insert code below which uses an 'If...Else' statement to check if a students grade is # greater than or equal to 75, or less than 75 myGrade = int(input("Please enter your grade:")) print("This is a passing grade") print("Sorry, this is not a passing grade")
48405f5ef8edfec4595b0113c9395ed06dffa540
kevwill79/Python
/Learning Python/LinkedInLearning_Python/Ch2/variables_start.py
723
4.5625
5
# # Example file for variables # # Declare a variable and initialize it f = 0 print(f) # # re-declaring the variable works #=============================================================================== # f = "abc" # print(f) # # # # ERROR: variables of different types cannot be combined # print("this is a string ...
809f70dc6be9a389af96de2aa71fba78e4c84cc9
Tsumibito/DreamTV_yt
/url_generator/random_text.py
1,095
3.984375
4
import re, random ''' скрипт рендомизации текста. Два вида аргументов: {комнатные|к.|ком.|Комн.} - один из перечисленных [уютно,|тихо,] - мешаем порядок ''' def give_me_rand_text_set(text, set_len): res = set() counter = 0 while len(res) <= set_len: counter += 1 res.add(rand_text(text)) ...
59e7ed8a4a76da8c18c349a8203d20d941f5e7b1
lingpy/linse
/src/linse/segment.py
7,472
4.125
4
""" Segmenting is the process of converting a written word to a sequence of tokens. This module provides functions to segment various kinds of text. An alternative method to segment text - based on orthography profiles - is implemented in the `segments` package. """ import re __all__ = ['ipa', 'asjp', 'sampa', 'samp...
311e4d99cc9483d563962045d7335cc768b13c2a
maxwellyc/octupole_masstable
/masstable_calculation/benchmarks/hpcc_version/create_masstable_input.py
7,000
3.515625
4
import os import sys import numpy as np import math # beta3 = 2424.068 * Q30 / (proton_number + neutron_number)**2 def default_dripline(zz): """ default dripline, for a given Z, returns (N_min,N_max) in a tuple """ # dictionary, key is proton, value is (min_N,max_N) tuple # first create min and max, t...
c155d62e926d2226fb10b2306d5fd4378149c626
ethanm32/python-shopping-cart
/shoppingcart.py
13,438
4.09375
4
import tkinter as tkinter_import from tkinter import messagebox # this allows for notifications from time import sleep # to implement a type of loading screen class ShoppingCart(): """This class is created as a shopping cart.It contains items(the items that the user wants), wallet(money in the users accou...
5657e36a2537baf544744a5581860559450bbcd3
MsDiala/amman-python-401d2
/class-03/demo/expections/expections/examples.py
593
4.0625
4
x = input('Enter an integer: ') try: z = 3/'hi' y = 10/int(x) except ZeroDivisionError: print("you can't divide by zero") except TypeError as e: print(f'Type error happened: {e}') else: print(y) finally: print('Thanks, see you later!') # x = 2/'5' # For developers # age = input("how old are ...