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
108812be77567c5fd05f694bba29999b315f010e
kiwi1018/gui_tkinter
/entry.py
513
3.734375
4
import tkinter as tk # 使用Tkinter前需要先匯入 # 第1步,例項化object,建立視窗window window = tk.Tk() # 第2步,給視窗的視覺化起名字 window.title('Entry') # 第3步,設定視窗的大小(長 * 寬) window.geometry('500x300') # 這裡的乘是小x def show(): text = en.get() lb.config(text=text) lb = tk.Label(bg='white', fg='blue', text="顯示內容") lb.pack() en = tk.Entry...
631e6750ac99e4a3088bb4888cad5f0c63d596db
tryingtokeepup/Intro-Python-I
/src/stackofstacks.py
665
3.75
4
# imagine a literal stack of plates # if excedes some threshold, the stack will break # implement a data struct that stops increasing once it hits the capacity(?) of said stack and builds another one class SetOfStacks: def __init__(self, threshold, plates): self.threshold = threshold self.plates =...
f9956ce992ed0d0d7024a5829af2f6c4a05cfbff
andywakefield97/Sparta_Training
/Day_6.py
2,526
4.25
4
# class Students: # # def __init__(self, name, age, gender): # self.name = name # self.age = age # self.gender = gender # # def year(self): # if self.age == '14': # return '{} is in Year 7'.format(self.name) # elif self.age == '12': # return '{} is...
ae3309221be2ec5085633ff35c15beebbee78cd4
andywakefield97/Sparta_Training
/python_csv_files/python_csv.py
1,368
3.796875
4
import csv with open("abc.csv", newline='') as csvfile: csvreader = csv.reader(csvfile, delimiter=",") # print(csvreader) # for column in csvreader: # print(column) # # for row in csvreader: # print(row[-1]) # iterable_csv = iter(csvreader) # next(iterable_csv) # for ro...
f55b901ea7e15570e597dddc1078f72631ce6848
belbis/algorithms
/python/data_structures/trees/heap/Heap.py
4,150
3.59375
4
__author__ = 'mike@belbis.com' # standard imports from sys import path # hack for sibling imports path.append('..') # local imports from abstract import Tree from abstract import Node class Heap(Tree): """ a Heap is a specialized tree-based data structure that satisfies the heap property: If A ...
93329934213e0ae9e37500f11baf357c679838aa
pellungrobe/privacy-lib
/parsers.py
9,669
3.5625
4
from data_structures import * def __read_trajectory_datetime(line): itemlist = line.split(",") trj = Trajectory(itemlist[0]) for i in range(1, len(itemlist), 3): trj.add_visit(float(itemlist[i]), float(itemlist[i + 1]), int(itemlist[i + 2])) return trj def __read_trajectory_date_and_time(line...
6c291c935764c099d5c861d070780800d69d965d
HOL-BilalELJAMAL/holbertonschool-python
/0x0B-python-inheritance/11-square.py
1,102
4.28125
4
#!/usr/bin/python3 """ 11-square.py Module that defines a class called Square that inherits from class Rectangle and returns its size Including a method to calculate the Square's area Including __str__ method to represent the Square """ Rectangle = __import__('9-rectangle').Rectangle class Square...
a7b0cb43b03d5d31e00ca3ac2fc51f8466a4116b
HOL-BilalELJAMAL/holbertonschool-python
/0x0C-python-input_output/6-from_json_string.py
392
4
4
#!/usr/bin/python3 """ 6-from_json_string.py Module that defines a function called to_json_string that returns an object (Python data structure) represented by a JSON string """ import json def from_json_string(my_str): """ Function that returns an object represented by a JSON string Args: ...
3713b6a6487d9828a372b0c79ae9519ab8d031e3
HOL-BilalELJAMAL/holbertonschool-python
/0x06-python-classes/1-square.py
350
3.84375
4
#!/usr/bin/python3 """ 1-square.py Module that defines a Square and return square size """ class Square: """ Represents a class called Square with a private instance attribute called size """ def __init__(self, size): """Initialization of the private instance attribute called size"...
820da2f284a53654aff6f17fd15e75b02175050c
HOL-BilalELJAMAL/holbertonschool-python
/0x0B-python-inheritance/7-base_geometry.py
936
3.96875
4
#!/usr/bin/python3 """ 7-base_geometry.py Module that defines a BaseGeometry and return empty dictionary Including Method to calculate the area Including Method to validate an integer """ class BaseGeometry: """Represents a class called BaseGeometry""" def area(self): """Function that...
da4284aa2521689c430d51e0c275b40f2f86348d
HOL-BilalELJAMAL/holbertonschool-python
/0x0C-python-input_output/0-read_file.py
393
4.125
4
#!/usr/bin/python3 """ 0-read_file.py Module that defines a function called read_file that reads a text file (UTF8) and prints it to stdout """ def read_file(filename=""): """ Function that reads a text file and prints it to stdout Args: filename (file): File name """ with ope...
0bbcccf7cb91667ab15a317c53ac951c900d93a6
HOL-BilalELJAMAL/holbertonschool-python
/0x0B-python-inheritance/10-square.py
819
4.28125
4
#!/usr/bin/python3 """ 10-square.py Module that defines a class called Square that inherits from class Rectangle and returns its size Including a method to calculate the Square's area """ Rectangle = __import__('9-rectangle').Rectangle class Square(Rectangle): """ Represents a class called Re...
9d1ba59c4f247f0f605dc75efeb18e9735da92f5
HOL-BilalELJAMAL/holbertonschool-python
/0x0B-python-inheritance/4-inherits_from.py
574
3.65625
4
#!/usr/bin/python3 """ 4-inherits_from.py Module that defines a function that checks if the object is an instance of a class that inherited (directly or indirectly) from the specified class """ def inherits_from(obj, a_class): """ Function that checks if an object is a sub class of a specific ...
ff55dda4908cdd2527dd507610aea532d409f966
Capitaine-Nemo/L3
/Chap_5/AllPath.py
2,328
3.59375
4
import numpy as np # def append_to(element, to=[]): # print(id(to)) # # to.append(element) # # to = to +[element] # cree une nouvelle liste # to += [element] # print(id(to)) # # return to # append_to(1) # print("") # append_to(2) # print("") # append_to(2, []) def isPath(graph, start...
a981e43ae7ca2f4db2ee291865fb952b23e394a1
YuppieCC/algorithms
/Junior/array/ri.py
658
3.796875
4
class Solution: def rotate(self, matrix): """ Do not return anything, modify matrix in-place instead. """ # 先变换最外层,逐渐向内深入 ml = len(matrix) for i in range(ml): for j in range(i + 1, ml): temp = matrix[i][j] matrix[i][j] = m...
7bb92bee3b37e22d33cb481832bda825ac173f7d
nirmaljb/Tic-Tac-Toe
/Tic Tac Toe/app.py
4,898
4.1875
4
# --------------------------- Tic-Tac-Toe --------------------------- # ---- Global variable ---- game_running = True # assumes whether the game is over or not current_player = "X" # assumes who is the current player # -- board -- board = ["-", "-", "-", "-", "-", "-", "-", "-", "-"] #...
50c968a7a60060c76b019abd0e94b31df2d7a722
GianniMarco/Turtle
/star.py
164
3.546875
4
import turtle as t t.color("yellow") t.begin_fill() t.left(36) for x in range(10): t.forward(30) if x % 2 == 0: t.right(108) else: t.left(36) t.end_fill()
08e726a5d0d4c82f4ae10a45e1c5681e47346d23
tiomonky/DevOps-Challenges-Cycle1
/challenge5.py
3,951
3.625
4
## ## Challenge 5: Write a script that creates a Cloud Database. ## If a CDB already exists with that name, suggest a new name like "name1" and give the user ## the choice to proceed or exit. The script should also create X number of Databases and X ## number of users in the new Cloud Database Instance. The script...
252dd4ad6ab668b9aa6cbd5f88237481edfbe2a9
VedantChristian16/Pythagorean-Program
/Pythagoras' Theorem.py
942
3.9375
4
''' Created by Vedant Christian Created on 11 / 10 / 2019 ''' import math def Theorem(): WhichSide = input("Which side are you trying to calculate, the Hypotenuse(H) or an other side(O) ?") if WhichSide == "H": a = input("What is the length of one of the sides in the triangle ?") b ...
50dddb3948b4dc578c95a0496c7f9d8d02460986
edichavez/TravelBookingSystem
/fractals.py
1,157
3.921875
4
import turtle angles_curve = [60,-120,60,0] def KochCurve(tim,x,index): if index>0: for i in angles_curve: KochCurve(tim,x,index-1) tim.setheading((tim.heading()+i)%360) else: tim.forward(x) def KochSnowflake(x,tim,index): for i in range(3): ...
84704740a9fe744d9d268a3690de168d57dd8df4
vlavandeira/master-data-science
/exercises/python/removechar.py
454
3.96875
4
#Función que elimina el carácter n-ésimo de la cadena pasada como primer argumento #Control de cadena vacía -> WARNING #Control de índice demasiado grande -> ERROR def removechar(s,n): if s is None or len(s)==0: print("Warning: First parameter is empty") return None else: if n>len(s): ...
ce95e63c5eb369f44a5fa13f3e18f90ba3ac43a8
mannith/Seek-discomfort
/ceaser cipher algorithm.py
691
3.859375
4
# -*- coding: utf-8 -*- """ Created on Thu Oct 3 11:04:03 2019 @author: Ram """ def encrypt(text,s): result = "" # transverse the plain text for i in range(len(text)): char = text[i] # Encrypt uppercase characters in plain text if (char.isupper()): result...
d5d8076648227732a5faa571fb53ab5037dc8a01
Ronaldo009/leetcode
/Remove Duplicates from Sorted List.py
803
4.03125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2017/6/23 下午3:06 # @Author : Huang HUi # @Site : # @File : Remove Duplicates from Sorted List.py # @Software: PyCharm class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def dele...
0bdc1e5f55b245f3ac85d87ae522bfae48a8394f
Ronaldo009/leetcode
/Binary Tree Inorder Traversal.py
758
3.96875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2017/6/23 下午3:22 # @Author : Huang HUi # @Site : # @File : Binary Tree Inorder Traversal.py # @Software: PyCharm class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(...
9fc4e21d5187d2313a1c14c56447b8a80ea4b4c3
Ronaldo009/leetcode
/Unique Paths.py
894
3.5
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2017/6/30 下午2:36 # @Author : Huang HUi # @Site : # @File : Unique Paths.py # @Software: PyCharm class Solution(object): def uniquePaths(self, m, n): """ :type m: int :type n: int :rtype: int """ dp =...
7a1a5e9cf4af671fabcc134d0484084d2261aadb
manda5566/multiplication-
/multiply.py
776
4.09375
4
# practice solving multiplication problems import random from cs50 import get_int # how many questions? q = get_int("how many question do you want ? ") score = 0 # ask q questions (0,1,...,q - 1) for i in range(q): # get 2 random numbers x = random.randrange(1,12) y = random.randrange(1,12) ...
398bcaab83ba2c4bd34aeda52d8808c3f574e9cc
laughterJ/python
/data_analysis/highs_lows.py
1,220
3.578125
4
import csv from matplotlib import pyplot as plt from datetime import datetime filename = "sitka_weather_2014.csv" # 打开文件,并将文件对象存储在file中 with open(filename) as file: # 创建一个与文件相关联的阅读器 reader = csv.reader(file) # 读取文件第一行 header_row = next(reader) # enumerate()函数用于将一个可遍历的数据对象组合为一个索引序列 for index, c...
470d63b6a46f57a5d177455cf657f52861b619e2
YutaLin/Python100
/Day3/convert.py
268
4.03125
4
# convert in and cm value = float(input('Plase enter value:')) unit = input('Please enter unit:') if unit == 'in': print('%finch = %fcm' %(value, value*2.54)) elif unit == 'cm': print('%fcm = %finch' %(value, value/2.54)) else: print('please enter valid unit')
e3847bdbe99155eb0e7d7233377889a7299eba8e
YutaLin/Python100
/Day6/dictionary.py
571
3.546875
4
def main(): scores = {'Yang': 95, 'Lin': 78, 'Huang': 82} print(scores['Yang']) print(scores['Lin']) for elem in scores: print('%s\t--->\t%d' % (elem, scores[elem])) scores['Kao'] = 65 scores['Wang'] = 71 scores.update(chang=67, tang=85) print(scores) if 'Kao' in scores: ...
573dec7b32c77ab368afa500b635ff43dab96c5e
shoobomb/paths-of-minimum-cost-between-cities-using-Dijkstra-in-Python
/code.py
2,878
3.59375
4
def dijkstraAlgoForShortestCost(graph,source,destination,visitedOnes=None,dist=None,predec=None): if(visitedOnes==None): visitedOnes=[] if(dist==None): dist={} if(predec==None): predec={} if source not in graph: raise TypeError('root of the shortest path tree i...
adee2a41e59f94a940f45ebbf8fddb16582614a6
sonsus/LearningPython
/pywork2016/arithmetics_classEx1018.py
1,334
4.15625
4
#Four arithmetics class Arithmetics: a=0 b=0 #without __init__, initialization works as declared above def __init__(self,dat1=0,dat2=0): a=dat1 b=dat2 return None def set_data(self,dat1,dat2): self.a=dat1 self.b=dat2 retur...
30250259a6ee175f62027464d8e09f3f8688f742
sonsus/LearningPython
/pywork2016/lambdafunction1111.py
517
4.09375
4
#lambdafunction.py mylist=[lambda a, b: a+b, lambda a,b: a*b] print(mylist) print(mylist[0](2,3), mylist[1](3,4)) ''' lambda a, b: (a, b) # here the return is implicit ''' print("two_times() output") def two_times(list): result=[] for number in list: result.append(2*number) return result print(two_times([1,2,3,4...
80fd9eeabd474bfd416de03d223b90b9571e402b
sonsus/LearningPython
/pywork2017/projectEuler37.py
1,021
3.640625
4
#truncatable prime from math import sqrt from time import clock start=clock() def isTruncatable(prime,prime_list): str_p=str(prime) l=len(str_p) if str_p[0]==1 or str_p[-1]==1: return False elif '5' in str_p[1:-1]: return False else: for i in range(l): if int(str_p[i:]) not in ...
be55b335388557db71e62534b02a654ed5aa3cec
sonsus/LearningPython
/pywork2017/DFS.py
1,228
3.921875
4
#DFS in python ''' Dunno whats going on inside, but it exceeds a limit in number of recursion ''' def Visit(n_vertice, visited_list): visited_list.append(n_vertice) def Unvisited_N(current_vertice, G_mat, visited_list): for i in range(len(G_mat[0])): if G_mat[current_vertice][i] and (i not in visited...
45771aee2c1f7d79a690a285e4a053f106f32789
Juwes/python-homework
/task_1_5.py
310
3.859375
4
from math import sqrt a = 5 print('Длинна первого катета = ',a) b = 7 print('Длинна второго катета = ', b) gg = (a * a) + (b * b) g = sqrt(gg) s = 0.5 * (a + b + g) print('Длинна гипотенузы = ', g) print('Площадь треугольника = ', s)
1cdb53cff8d11c6e45aa7dcb59d4aa577090cd6f
pdavinunes/python_fundamentos
/free_dev/quest2.py
428
3.84375
4
import random def gera(): mini = int(input('Defina o numero minimo -> ')) maxi = int(input('Defina o numero maximo -> ')) return random.randint(mini, maxi) num_sec = gera() num = int(input('Digite um numero -> ')) while num != num_sec: print ('Numero muito alto!' if num > num_sec else 'Numero muito baixo!') n...
0e5984d5009e56b1c254e966c149fbb86c62a8e1
pdavinunes/python_fundamentos
/free_dev/uri/1114.py
126
3.796875
4
cond = True while cond: if int(input()) == 2002: print('Acesso Permitido') cond = False else: print('Senha Invalida')
b789ec1e5ff1be7999272b1c0e384da64d4b0c05
PrashishMan/python_init
/while.py
524
3.640625
4
response = None num = [1,2,3,4,4,4,4,5,6,7,8,9,10] num2 = [1,2,3,4,5,6,7,8,9,10] num2.clear() print(num2) num.append(11) num.extend(range(12, 21)) num.insert(2, 2.5) num.remove(4) num.insert(len(num), "Last") item1 = num.pop(2) # item2 = num.pop(4) # item3 = num.pop(5) while response != 'please': response = ...
0b70d646a50074995b3e8878d33e726783634db2
PrashishMan/python_init
/exc2.py
171
3.984375
4
for i in range(20): if i == 4 or i == 13: print(f"{i} is an unlucky number") elif i % 2 == 0: print(f"{i} is an even number") else: print(f"{i} is an odd number")
6cade49b4a10972b75b54e34d33c1eb655d91b2c
PrashishMan/python_init
/cleanRoom.py
110
3.96875
4
num = int(input("How many times do i have to tell you?")) for i in range (num): print("Clean up your room!!")
0a8108ba442359b6c1bf5e51b54921192f392e2c
SGJJSR/Python_challenges
/small_challenges.py
1,093
3.90625
4
# Hangman game: import string import random import numpy as np def scribble_word(list_of_words): random_word = (random.choice(list_of_words).strip()) return(random_word) # sowpods is a list of all possible Scrabble words in English: with open('sowpods.txt', 'r') as f: lines = f.readlines() # You die ...
958b183146b773bc57fcbc3895bcd9b6dad6b1e2
anizadikian/HWs
/Tree.py
1,308
4
4
class Node: def __init__(self, data=None): self.data = data self.right = None self.left = None class BST: def __init__(self): self.root = None def __str__(self): if self.root == None: print("Root is Empty") else: return str(self.root....
54f4bbc11b750474a1d7481bd4fc79223b568a94
anizadikian/HWs
/hw4.py
2,455
3.75
4
class Classroom: classroomIDs = [] def __init__(self, capacity, roomID): self.capacity = capacity self.roomID = roomID self.schedule = [] def isFree (self, start, end): is_free = True for slot in self.schedule: if end < slot["start"] or start > slot["en...
b96e8e49c856ba813f4b3bfddfeb20464f9dbaa2
AngelCarballoCremades/Chess_IronhackProject
/main.py
19,687
4.125
4
""" Autor: Ángel Carballo Cremades Ironhack Data Analytics bootcamp Week 1 mini project Chess """ import os # Type of pieces tuple PIECES =("rook","knight","bishop","king","queen","bishop","knight","rook","pawn") TEAM = ("White","Black") class Piece(object): """Chess piece class, takes inputs type, team and ...
f8c2483af2abfb1fb0719824386aab6a55a95b88
yuzhenduan/AutoTest
/Login/loginSucess/loginSucess.py
2,235
3.6875
4
""" 登录成功为所有类的父类 创建一个跑测试用户(下面用户已注册,只用来跑测试用例) 账户:369CloudTest@datangnet.com.cn 密码:369CloudTest """ #import unittest import os from selenium import webdriver class LoginSucess(): browser=[] def __init__(self,driver="geckodriver.exe", driverPath = "D:\\work\\pycharm\\driver\\Firefox\\eckodriver.exe"): ""...
aa226fc06796e2e12132527b270f9671bd66bb55
annabalan/python-challenges
/Practice-Python/ex-01.py
489
4.25
4
#Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old. def aging(): name = input("Enter your name: ") age = int(input("Enter your age: ")) number = int(input("Enter a number: ")) year = st...
e7795e586e32fd66563b32354403719502aca37a
Sudhakar18/DS-Algo
/Sorting/Selection_Sort/Selection_Sort.py
375
3.84375
4
# Selection Sort # Swapping the lowest element starting from the 0th element def Selection_Sort(A): for i in range(0, len(A)): low = i for j in range(i + 1, len(A)): if A[j] < A[low]: low = j temp = A[i] A[i] = A[low] A[low] = temp return A ...
b7341b4a1054034c1958e870f0aa4fa2f8a910cb
chiangp168/Othello
/game_controller.py
2,981
4.0625
4
class GameController: """Maintains the state of the game.""" def __init__(self, WIDTH, HEIGHT, CELL, score_sheet): self.WIDTH = WIDTH self.HEIGHT = HEIGHT self.cell = CELL self.total_col = self.WIDTH // self.cell self.total_row = self.HEIGHT // self.cell self.play...
67c5a47513e28666450fe11ae30f10cf6a7f7bea
emadsalehi/KnockBall
/Server/knock_ball/model/unit.py
1,155
3.5625
4
import math class Unit: def __init__(self, unit_id, x, y, is_defense, max_offense_power, max_defense_power, velocity): self.unit_id = unit_id self.x = x self.y = y self.is_defense = is_defense self.max_offense_power = max_offense_power self.max_defense_power = max_de...
510141fd0a1924f95897c06a51aa90f1e3040d0b
strawhatasif/python
/database/database.py
1,614
3.78125
4
import sqlite3 connection = sqlite3.connect('simple_database.db') # this is how easy it is to connect to a database! conn = connection.cursor() # simple_database will be created in the same directory as this program # create a couple of tables conn.execute('''CREATE TABLE SUPER_HERO_NAMES( id IN...
bc917efa9ab9aef3260e21326d9c10c7f51cbc0e
strawhatasif/python
/calculate_average_rainfall.py
2,396
4.5
4
# This program calculates and displays average rainfall based on rainfall amounts per month entered by the user. # constant for number of months in a year NUMBER_OF_MONTHS_IN_YEAR = 12 # stores the number of years entered by the user number_of_years = int((input('Please enter the number of years: '))) # if the initi...
e6c7ddd18304dd9cb6fadb4d98058483494c0300
strawhatasif/python
/commission_earned_for_investor.py
2,983
4.34375
4
# This program tracks the purchase and sale of stock based on investor input. # constant percentage for how much commission an investor earns. COMMISSION_RATE = 0.03 # PURCHASE OF STOCK SECTION # Stores the name of the investor when entered. investor_name = input('What is your name? ') # Stores the number of shares ...
7a83ffe9cad171faab83c5b8ed7ae3876475775f
love554468/python-basic
/python_basic/code_usefull/reversed_string.py
127
3.703125
4
stringg = "Hellu Binh" reversed_tringg= stringg[::-1] print("this is string input: %s \n" % (stringg)) print(reversed_tringg);
2a0924e8754704892db74e6aaa95e7d1c4ff3845
love554468/python-basic
/python_basic/juice_Maker.py
314
3.59375
4
class Juice: def __init__(self,name,capacity) -> None: self.name = name self.capacity = capacity def __add__(self,other): return self.name +"&"+other.name+"\n"+str(self.capacity+other.capacity) a = Juice('Orange', 1.5) b = Juice('Apple', 2.0) result = a + b print(result)
5ccf75a5ca1b5ddf3a2025104d7b9794d1865cfa
love554468/python-basic
/python_basic/code_usefull/tim_xem_2_chuoi_co_phai_dao_chu_khong.py
267
3.65625
4
from typing import Counter str1,str2,str3 = "abc","cba","adc" cnt_1,cnt_2,cnt_3 = Counter(str2), Counter(str1), Counter(str3) if cnt_1 == cnt_2: print("la dao chu") if cnt_2 == cnt_3: print("la dao chu") else: print("Khong la dao chu")
26ab10c08a2be11665197a8efd790808181db7d5
love554468/python-basic
/python_basic/regex/searchString.py
152
3.796875
4
import re str = "afas a the rain in Spain asd a the rain in Spain" x = re.search("^the.*Spain$",str) y = re.findall("^the.*Spain$",str) print(y)
6fc6becc03fbd9d920f80033889746e04d5852ed
justintuduong/CodingDojo-Python
/Python/intro_to_data_structures/singly_linked_lists.py
1,957
4.125
4
class SLNode: def __init__ (self,val): self.value = val self.next = None class SList: def __init__ (self): self.head = None def add_to_front(self,val): new_node = SLNode(val) current_head = self.head #save the current head in a variable new_node.next = c...
8daef2421eab45165f8ee5a59b9108bbba94ec1c
ntorguud05/python-tutorials
/Calc.py
202
3.765625
4
x = int(input()) y = int(input()) op = int(input()) if op == 1: print('Amount is', x + y) if op == 2: print('Difference is', x - y) if op == 3: print(x * y) if op == 4: print(x / y)
2a0e64a90e407c01ce65c42298d0b193879a1bf0
IDS6145-Fall2019/assignment1-Messpice
/code/POTS_system/escalator_object.py
541
3.65625
4
class Escalator(): """A simple attempt to model an escalator.""" def __init__(self, steps, handrail, motor): """Initialize steps and handrail and motor.""" self.steps = steps self.handrail = handrail self.motor = motor class Pedestrian(): """A simple atte...
f5eda4ff5e6dfeb22a5fc4b9e4aa2cee920af256
thejuskrishna/codingground
/New Project/isPrime.py
210
4
4
import math def isPrimeNumber(number): if number == 2: return True if number % 2 == 0: return False i = 3 while i<= math.sqrt(number): if number % i == 0: return False i = i + 2 return True
ebd66e992891b50f2071a40fce9a2e2f263159b7
wail0152/SchoolRepo
/Formatieve opdracht 1 algoritmisch programmeren/Opdracht 6 - Gemiddelde berekenen.py
236
3.8125
4
def calc_average(lst): return sum(lst) / len(lst) def calc_list_average(lst): number_sum = 0 list_length = 0 for i in lst: number_sum += sum(i) list_length += len(i) return number_sum / list_length
622ab744c911e9334640de0bd9f902fa049c8538
wail0152/SchoolRepo
/Formatieve opdracht 1 algoritmisch programmeren/Opdracht 11 - Caesarcijfer.py
233
3.9375
4
def caesar_number(): t = str(input("Geef een tekst: ")) r = int(input("Geef een rotatite: ")) new_string = "" for letter in t: new_string += chr(ord(letter) + r) return new_string print(caesar_number())
329d32fc40f66f3df56698b3b0b4ae461885ce5a
stuartmcelhany/zeolite-distance-matrix
/matrix_maker.py
6,338
3.5
4
import csv import math ''' ENTER INFORMATION HERE ''' FILE = 'isomer-1.xyz' # name of unit cell file SIDE_LENGTH = 17.53 # side length of unit cell ANGLE = 60 # angle of unit cell in degrees ''' Creates primitive vectors for trigonal unit cell ''' ANGLE = ANGLE * (math.pi/180) PRIM_VEC_X = [SIDE_L...
cdce0d0701ba4845a3623d11e1d1cf3d1506d442
moolivieJHB/wtc-projects
/draw.py
3,874
4
4
import sys # TODO: Step 1 - get shape (it can't be blank and must be a valid shape!) def get_shape(): while True: shape = input ('Shape?: ').lower() if shape=='triangle' or shape=='sqaure' or shape=='pyramid' or shape == 'rhombus' or shape=='trapezium': return shape # TODO: S...
9dfcf8d5c191bc3837d10f6220fa051bb0939f1a
OneRaynyDay/LinearRegression
/LinearRegression.py
1,296
3.609375
4
import numpy as np class LinearRegression: def __init__(self, matrix): '''X: The input of the supervised learning y: The results of the supervised learning''' biasTerm = np.ones((matrix.shape[0], 1)) print("biasTerm's shape: " + str(biasTerm.shape)) print(matrix) Xco...
a10d1e7924ececc71a79c6624cb4bf27026a9ce6
JacobARose/pyleaves
/pyleaves/leavesdb/.ipynb_checkpoints/preprocessing-checkpoint.py
809
3.734375
4
''' Functions for preprocessing/transforming data between extraction from the database and input to the model. ''' import pandas as pd import dataset def encode_labels(data, y_col='family'): ''' Create 'label' column in data_df that features integer values corresponding to text labels contained in y_col. Argum...
fd6ba443b614d7f59cf227283022ec279c3fc115
mantrupe/Portafolio
/IA-Python/Aviones/final.py
10,397
3.5625
4
from Tkinter import * import ttk as ttk import tkMessageBox import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap import json from collections import deque from math import radians, cos, sin, asin, sqrt def ponderar(lon1, lat1, lon2, lat2): """ Calculate the great circle distance between tw...
55deebb1e3c7f97ad0263e94ee6edd36845272bf
RobertSamoilescu/NemodriveFinal
/util/augment.py
6,319
3.609375
4
import numpy as np import math from simulator import steering from simulator import transformation from .reader import Reader from typing import Tuple class PerspectiveAugmentator(object): @staticmethod def compute_command(data, translation, rotation, intersection_distance=10): """ Computes ...
4c767c84328716706d6a82a9d79f4e6d876989bb
rishavhack/flask-rest-api
/1 Python Refresher/inheritance.py
1,036
3.953125
4
class Student: """docstring for Student""" def __init__(self, name, school): self.name = name self.school = school self.marks = [] def average(self): return sum(self.marks) / len(self.marks) def friend(self,friend_name): return Student(friend_name,self.school) @classmethod def friend(self,friend_name...
4d7809a367298f7042f97581a449948ed196d798
markande98/company-master-data-project
/histogram.py
2,350
3.828125
4
import csv import matplotlib.pyplot as plt arr = [] def read_csv(): with open('Maharashtra.csv', 'r', encoding="latin1") as file: reader = csv.DictReader(file) for row in reader: val = int(float((row['AUTHORIZED_CAP']))) arr.append(val) def select_interval(): while...
5457e1f66077f12627fd08b2660669b21c3f34d3
AmonBrollo/Cone-Volume-Calculater
/cone_volume.py
813
4.28125
4
#file name: cone_volume.py #author: Amon Brollo """Compute and print the volume of a right circular cone.""" import math def main(): # Get the radius and height of the cone from the user. radius = float(input("Please enter the radius of the cone: ")) height = float(input("Please enter the height of the ...
cc58af8b7a299035bee0fec8278cde3035e0af0f
dianess/python-challenge
/PyBank/main.py
3,214
3.859375
4
import os import csv bank_data_csv = os.path.join("/Users/dianeshomefolder/Documents/Code/UA Bootcamp Homework/03-Python/Instructions/PyBank/Resources/budget_data.csv") # Open and read csv with open(bank_data_csv, newline="") as file_object: bank_budget_data = csv.reader(file_object, delimiter = ',') # Read ...
7d7fccd3886b342934e5c7ea5d397d1dc3a9a098
diigguerrero1/Curso_Python_Profesional
/Tipado_estatico_Python.py
1,165
3.96875
4
#Sintaxis Estatica para variables a: int = 5 print(a) b: str = 'Hola' print(b) c: bool = True print(c) #Sintaxis Estatica para funciones def suma(a: int, b: int) -> int: return a + b print(suma(1, 2)) #Sintaxis Estatica para funciones que termina siendo Dinamica def suma(a: int, b: int) -> int: retu...
d6dc66d1e9912290500cff83cc2de92b6afb3779
renatasarmet/robopaa
/TrabRoboCMD/roboProgDinamica.py
1,609
3.921875
4
from random import randint # Definição de funções #Definindo o tabuleiro, cada célula possuindo ou não uma moeda def definir_tabuleiro(n_linhas, n_colunas): T = [] while len(T) != n_linhas: linha = [] while len(linha) != n_colunas: a = randint(0,1) linha.append(a) ...
a67ae8e3f297401fe500dd09108fec16b72aab55
Rumbly9/Py_Git
/to_camel_case.py
203
3.796875
4
def to_camel_case(text): removed = text.replace("-", " ").replace("_", " ").split() if len(text) == 0: return "" return removed[0]+ "".join([txt.capitalize() for txt in removed[1:]])
4755137513295018750a7627cee7beaa3bb3cc61
kyeongseok-lee/TIL
/Algorithm/SWEA/SWEA4874_Forth.py
768
3.59375
4
def calculator(cal, a, b): if cal == '+': return a + b elif cal == '-': return a - b elif cal == '*': return a * b else: return a // b for t in range(1, int(input()) + 1): info = list(input().split()) result = 0 stack = [] cals = ['+', '-', '*', '/']...
e9e2c1d5e4bb3d6a249c31aa6236012e17827a13
kyeongseok-lee/TIL
/Algorithm/PROGRAMMERS/PROGRAMMERS_삼각달팽이.py
906
3.578125
4
def solution(n): answer = [] pyramid = [[0] * i for i in range(1, n+1)] num = 1 r, c = -1, 0 for rotate in range(n): for _ in range(n - rotate): if rotate % 3 == 0: r += 1 elif rotate % 3 == 1: c += 1 else: r...
e93a9c53e043b7c1689f8c5c89b6365708153861
diamondhojo/Python-Scripts
/More or Less.py
928
4.21875
4
#Enter min and max values, try to guess if the second number is greater than, equal to, or less than the first number import random import time min = int(input("Enter your minimum number: ")) max = int(input("Enter your maximum number: ")) first = random.randint(min,max) second = random.randint(min,max) print ("The...
e9b36ead1adc4b66ba23c36bbe23b3582d926a28
diamondhojo/Python-Scripts
/Guess the Number.py
420
4.09375
4
#Try to guess the number import random min = int(input("Enter the minimum number: ")) max = int(input("Enter the maximum number: ")) num = random.randint(min, max) chance = round((min/max) * 100, 2) print("The chances of you guessing correctly is " + str(chance) + "%") guess = int(input("What's your guess? ")) if g...
01d4ea985f057d18b978cdb28e8f8d17eac02a6d
matthew-kearney/cs-module-project-recursive-sorting
/src/sorting/sorting.py
1,938
4.28125
4
# TO-DO: complete the helper function below to merge 2 sorted arrays def merge(arrA, arrB): elements = len(arrA) + len(arrB) merged_arr = [0] * elements # Your code here index_a = 0 index_b = 0 # Iterate through all indices in merged array for i in range(elements): # Make sure that...
2c899e5d0771b070ee7eb6ec8e24b3e4f37a2b58
avi1612/flame
/as1.py
74
3.953125
4
num1 = int(input("Num1:")) num2 = int(input("Num2:")) print(num1 + num2)
893459a9ef5c627e6e4c182674d7e17c1bfa3a16
ShivomShivom/python-snakes-and-ladders
/snakes and ladders.py
10,810
4
4
import random import time print("Hello welcome to my snakes and ladders game") print("You are required to have somebody to play with you,\nIf there is nobody to play with you, just leave now") print("Please enter your names for a more immersive experience") print("Thank you for joining in, I appriciate it") player_1=s...
51cf551ee8713867ff93051ef5eab89fd2aab080
NV25/NBT
/Intervals/MergeIntervals.py
1,063
3.875
4
""" Given a collection of intervals, merge all overlapping intervals. """ class Interval(object): def __init__(self, s=0, e=0): self.start = s self.end = e def mergeIntervals(intervals): # Sort by start time intervals.sort(key=lambda x: x.start) mergedIntervals = [] for inter...
9d57388ed0746d02dfee76555ee25234333eeec7
emreozcan3320/python_apps
/basic_of_python/number_perfect_or_not.py
412
3.96875
4
# Find a number ,that get as input, perfect or not def main(): num1 = int(input("Please enter the number to check it is perfect or not ? --> ")) sum = 0 for i in range(1,num1): if num1 % i == 0: sum += i if sum == num1: print("it is a perfect number") else: ...
2e5bdb5e9abe163570713cb63dbd32fd0dc16d2a
BrianMath-zz/ExerciciosPython
/Exercicios - Mundo1/Ex017.py
205
3.609375
4
#Ex. 017 from math import hypot co = float(input("Digite o comprimento do cateto oposto: ")) ca = float(input("Digite o comprimento do cateto adjacente: ")) print(f"A hipotenusa mede {hypot(co, ca):.2f}")
440503286dc105675ba9c03d95954b8754a7c4b4
BrianMath-zz/ExerciciosPython
/Exercicios - Mundo1/Ex031.py
192
3.796875
4
#Ex. 031 dist = int(input("Qual a distância da sua viagem? ")) if dist <= 200: print(f"Sua passagem custará R${dist*0.5:.2f}") else: print(f"Sua passagem custará R${dist*0.45:.2f}")
63a8c84fa6ee7f0b8649d89cee55f7b9460e646d
BrianMath-zz/ExerciciosPython
/Exercicios - Mundo2/Ex. 055.py
467
3.921875
4
# Ex. 055 """ Versão 1 massMa, massMe = 0, 9999 for i in range(1, 6): mass = float(input(f"Digite a massa (kg) da pessoa {i}: ")) if massMa < mass: massMa = mass elif massMe > mass: massMe = mass print(f"Maior massa: {massMa} kg") print(f"Menor massa: {massMe} kg")""" massas = [] for i in range(1, 6): mas...
4cf10c7c4f601083f005f6fad7d6abce75745c1e
BrianMath-zz/ExerciciosPython
/Exercicios - Mundo1/Ex014.py
102
3.96875
4
#Ex. 014 c = float(input("Digite uma temperatura em °C: ")) print(f"{c}°C = {((9*c)/5)+32:.1f}°F")
7b55266437452514dc20d0200f5253011f07eeea
BrianMath-zz/ExerciciosPython
/Exercicios - Mundo1/Ex032.py
467
3.890625
4
#Ex. 032 from datetime import date ano = int(input("Digite o ano que deseja verificar se é bissexto (0 para usar o ano atual): ")) if ano == 0: ano = date.today().year if ano%4 == 0: if ano%100 == 0: if ano%400 == 0: print(f"\n{ano} é um ano bissexto!") else: print(f...
9b7d3f87d904eb46975cfbb7764b3eafd6c9bb39
BrianMath-zz/ExerciciosPython
/Exercicios - Mundo1/Ex022.py
278
4.09375
4
#Ex. 022 nome = str(input("Digite seu nome completo: ")).strip() print("Seu nome em maiúsculas é:", nome.upper()) print("Seu nome em minúsculas é:", nome.lower()) print(f"Seu nome tem {len(nome) - nome.count(' ')} letras") print(f"Seu 1º nome tem {nome.find(' ')} letras")
da0433b6d6172fe4d82eb77826e8daacc9e9123f
BrianMath-zz/ExerciciosPython
/Exercicios - Mundo1/Ex019.py
258
3.703125
4
#Ex. 019 from random import choice n1 = str(input("Digite o 1° nome: ")) n2 = str(input("Digite o 2° nome: ")) n3 = str(input("Digite o 3° nome: ")) n4 = str(input("Digite o 4° nome: ")) nomes = [n1, n2, n3, n4] print(f"O escolhido foi {choice(nomes)}")
00b7d2b18548c195bedf516c25a3eda1f4a169ed
Joewash1/password
/Password2-2.py
596
4.21875
4
s=input("please enter your password :: ") Password = str( 'as1987Jantu35*^ft$TTTdyuHi28Mary') if (s == Password): print("You have successfully entered the correct password") while (s != Password): print("Hint:1 The length of your password is 32 characters") s=input("please enter your password :: ") if(...
9ad361dd5df21835e89c0db9d3457e4de9efb948
carlosafdz/pensamiento_computacional_python
/primitivos/operadores_condiciones.py
262
4
4
a = int(input("primer numero: ")) b = int(input("segundo numero: ")) print(a==b) print(a<b) print(a>b) print(a<=b) print(a>=b) print(a!=b) #condicionales if a==b: print("a es igual a b") elif a>=b: print("a es mayor a b") else: print("no es igual")
c995373e601beef7ee4ffd7387dd9c99284b9798
carlosafdz/pensamiento_computacional_python
/manejo_de_errores/afirmaciones.py
358
3.671875
4
def primera_letra(lista_palabras): primera_letra=[] for palabra in lista_palabras: assert type(palabra) == str, f'{palabra} no es str' assert len(palabra) > 0, f'{palabra} esta vacio' primera_letra.append(palabra[0]) return primera_letra lista = ['carlos','Jelena', 'Julia','Dani...
a7059770ac951bfcf0a125e7bf6d78202d862e4e
carlosafdz/pensamiento_computacional_python
/manejo_de_errores/try_except.py
327
3.640625
4
def divide_elementos_de_lista(lista,divisor): try: return [i / divisor for i in lista] except ZeroDivisionError as e: print("divisor es 0, no podemos dividir 0/0") print(e) return lista lista = list(range(10)) divisor = 0 print(lista) print(divide_elementos_de_lista(lista,div...
a1d9de8b5b3196eb23ffcc9752804dffc5081c81
ahmadhafi/TUGAS-JOHN-TRAVOLTA
/John Travolta.py
1,138
3.578125
4
# Python Program to count Mr.Tavolta Wage # Name : Ahmad Bisyrul Hafi (11180910000122) # Date : 02 September 2021 # Courses : Software Quality Testing jam_normal = 40 gaji_normal = 15000 gaji_lembur = gaji_normal * 1.5 print(f'Gaji Normal (40 Jam/minggu) = Rp {gaji_normal}/jam') print(f'Gaji Lembur (>40 J...
9ee73a27620c635b6c3f8b6911857407e6494cc5
gpapadop79/gsakkis-utils
/common/iterators.py
2,072
3.515625
4
from itertools import * def take(n, seq): return list(islice(seq, n)) def enumerate(iterable): return izip(count(), iterable) def tabulate(function): "Return function(0), function(1), ..." return imap(function, count()) def iteritems(mapping): return izip(mapping.iterkeys(), mapping...
f533d22c62fd552fafd6c20768a61f750e1270a2
gpapadop79/gsakkis-utils
/common/autopickle.py
2,247
3.5
4
import os import cPickle as pickle __all__ = ['autopickle'] def autopickle(arg): '''If arg is True or False, return a decorator with binmode=arg; otherwise decorate the arg (should be a callable). For example: @autopickle def foo(): pass @autopickle(True) def bar(): pass ''' if arg ...
03ddce5db9dd3927a5abb412f5ba80c743bed6a6
moonyeol/algorithm
/python/acmicpc_2887.py
1,151
3.546875
4
import collections import sys input=sys.stdin.readline def find(parent,node): if parent[node] == node: return node; return find(parent,parent[node]) def union(parent, x, y): x = find(parent,x) y = find(parent,y) #작은 수를 부모로 삼음 if x <y: parent[y] = x return x else: ...
905423f3d42da16484d3eaf11d471662fc549382
dmwcode/CS50
/pset6/cash.py
528
3.734375
4
from cs50 import get_float counter = 0 n = get_float("Change owed? ") while n < 0: n = get_float("Change owed ") break # Converting float to round number cents = round(n * 100) for cent in range(int(cents)): while cents >= 25: cents = cents - 25 counter += 1 while cents >= 10: ...