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
dc8392e140ee351b4abf3653980ec0f855e87147
l04m33/pyx
/pyx/http.py
21,163
3.5625
4
""" Routines & classes that are related to HTTP protocol processing. A basic HTTP server can be assembled in a simple way:: import asyncio from pyx.http import (HttpHeader, HttpConnectionCB) @asyncio.coroutine def req_cb(req): resp = req.respond(200) resp.headers.append(HttpHeader('Co...
a787e71bc1d59b4db05d19bdd3d36d315d060a03
raspibrick/install
/lib/Motor.py
4,653
4.0625
4
# Motor.java ''' Class that represents a motor. This software is part of the raspibrick module. It is Open Source Free Software, so you may - run the code for any purpose - study how the code works and adapt it to your needs - integrate all or parts of the code in your own programs - redistribute copies of the ...
15564acf8e611e682209b78dac181c2ea0f08bf7
G-Node/pyneuron_documentation
/source/quickstart/src/part2lib.py
5,620
3.625
4
""" Tutorial about PyNEURON ======================= (Given at Advanced Course of Computational Neuroscience, Freiburg 2009) Library for part II """ import matplotlib as mpl import matplotlib.pyplot as plt import numpy as np import sqlite3 as sqlite import neuron def make_compartment(length, diameter, nseg=None): ...
cb0b85093a8a68af7205238143324204c979e51a
tomasolodun/lab8
/1.py
908
3.53125
4
#виведіть на екран елементи лінійного масиву (заданий користувачем) у \ #зворотному порядку import numpy as np #Імпортуємо бібліотеку numpy while True: while True: try: A = np.array(list(map(int, input('Введіть лінійний масив: ').split())))[::-1] print(A) # Розвертаємо введени...
0483eddddc37ff362329581c58536f053ea0b854
Valink16/Pendu
/pendu.py
1,061
3.734375
4
#Writed by: Valink, on: 27.11.2017 from func import loadFile, prtDebug, createMask from random import randint wordList=loadFile("wordList")["content"] wordTab=wordList.split("\n") #Separating wordList into a tab wordToGuess=list(wordTab[randint(0, len(wordTab)-1)]) #Getting a random word and turning it into a list wo...
27b16e6ee0cbd9477fc99475382e5e8e95d1efb7
gautamdayal/natural-selection
/existence/equilibrium.py
2,379
4.28125
4
from matplotlib import pyplot as plt import random # A class of species that cannot reproduce # Population is entirely driven by birth and death rates class Existor(object): def __init__(self, population, birth_rate, death_rate): self.population = population self.birth_rate = birth_rate sel...
629c3386d309c4b76f6c5f9c30fae8fcc2692c23
Onrtsn/c-projeleri
/format.py
298
4.03125
4
name= 'onur' surname='tosun' age=22 #print("my name is {0} {1} I'm yaers {2} old".format(name,surname,age)) #result =100/2 #print("the result={r:1}".format(r=result)) #print(f"my name is {name} {surname} I'm yaers {age} old") #result= name[1:3] result= name[::-1] print(result)
abe43020be2cc26b309029e01eff24a24866914a
obiwanknabe/Python
/conditions.py
462
3.75
4
is_hot = False is_cold = False if is_hot: print("It's a hot day") print("Drink plenty of water!") elif is_cold: print("It's a cold day") print("Wear warm clothes!") else: print("It's a lovely day") print("Enjoy your day.") home_price = 1000000 credit_is_good = True credit_is_bad = False if cred...
1a5f5335e97941b5797ba92bc13877e4a73acd00
markagy/git-one
/Mcq_program.py
1,487
4.25
4
# Creating a class for multiple choice exam questions.Each class object has attribute "question" and "answer" class Mcq: def __init__(self, question, answer): self.question = question self.answer = answer # Creating a list of every question test = [ "1.How many sides has a triangle?\n (a) 1\...
f795bbe775a9e0271a29f7f6c2dd9294f093a640
bartlomiejmusial/SquirrelsCount_Using_Pandas
/main.py
630
3.59375
4
import pandas # Read the .csv file data = pandas.read_csv("2018_Central_Park_Squirrel_Census_-_Squirrel_Data.csv") # Count squirrels of each color grey_squirrels_count = len(data[data["Primary Fur Color"] == "Gray"]) red_squirrels_count = len(data[data["Primary Fur Color"] == "Cinnamon"]) black_squirrels_count = len(...
477494782eeaaa6c9f546d6c090e1fb7aa0a8ee0
RonDico/moa-iot
/Drawing-with-Canvass-andText.py
701
3.84375
4
# canvas_draw.py from tkinter import Tk, Canvas, Label root = Tk() canv = Canvas(root, width=600, height=400) canv.pack() # Draw blue line from top left to bottom right with wide dashes canv.create_line(0, 0, 600, 400, fill='blue', dash=(5, 15)) # Draw green rectangle at (100,50) to (120,55) canv.create_rectangle(10...
43ade81be7089a700c3e48f66d4319d552bc9fcf
RonDico/moa-iot
/ButtonsWithCallbacks.py
299
3.875
4
from tkinter import Tk, Button root = Tk() exit_button = Button(root, text='Exit Program', command=root.destroy) exit_button.pack() def my_callback(): print("The button was clicked!") print_button = Button(root, text='Click me!', command=my_callback) print_button.pack() root.mainloop()
65bc47cadcac31fea22088cd9118ab55918711e5
ffarassati/Metherate-Lab
/Lab/Notes/ComboBox.py
254
3.53125
4
import tkinter as tk import tkinter.ttk as ttk def on_select(event): print(cb.get()) root = tk.Tk() cb = ttk.Combobox(root, values=("1", "2", "3", "4", "5")) cb.set("1") cb.pack() cb.bind('<<ComboboxSelected>>', on_select) root.mainloop()
4068f8d33794d7487a830ddc79557ec30232c7bc
yuichimukai/python-procon
/ABC181/a.py
58
3.5625
4
n = int(input()) print("Black" if n % 2 == 1 else "White")
dc648e1fb6d79d59e3c3c13c320ca8f5b488cdf3
yuichimukai/python-procon
/algorism-practice/chapter3-5.py
612
3.953125
4
N = int(input()) A = input().split() #バブルソート def bubble_sort(A, N): for i in range(N): for j in reversed(range(i+1, N)): if A[j][1] < A[j-1][1]: A[j-1], A[j] = A[j], A[j-1] #選択ソート def selection_sort(A, N): for i in range(N-1): j_min = A.index(min(A[i:], key=lambda a:a[1]), i) A[i], A[j_m...
b69921ca1a71252693ec91f55624f22990e35523
cjakuc/cs-module-project-algorithms
/eating_cookies/eating_cookies.py
1,240
3.9375
4
from itertools import combinations_with_replacement, permutations, product ''' Input: an integer Returns: an integer ''' def eating_cookies(n): # Your code here # if n == 0: # return 1 # # https://www.geeksforgeeks.org/python-itertools-product/ # solutions = [] # for x in range(1,n+1): ...
35fa32621314e75b1fd980ecf43c6b957018a1de
jbao161/mentalmath
/display.py
1,704
4
4
''' Created on Jan 3, 2013 Displays text and interprets strings. @author: jbao ''' import functions def display_input_set(input_set,operation): # displays the arithmetic problem # note: operation is a string, e.g. ' x ' string='' for number in input_set: string+=str(number)+(operation) return s...
a3e8cfb8a4f8f7765e9088883440d151e6d972d5
nagios84/AutomatingBoringStuff
/Dictionaries/fantasy_game_inventory.py
767
4.1875
4
#! python3 # fantasy_game_inventory.py - contains functions to add a list of items to a dictionary and print it. __author__ = 'm' def display_inventory(inventory): total_number_of_items = 0 for item, quantity in inventory.items(): print(quantity, item) total_number_of_items += quantity ...
4d6e44a33360c915a1327fba29823e206e17e060
CarrotCoding/techdegree-project-1
/guessing_game.py
3,289
4.28125
4
import random highscore = 0 print("Welcome to the number guessing extravaganza") print("In this game you can guess as much as you like") print("Until the magic random number has been found\n") #creating a function to create the winning number within the game boundaries def guessing_game(): # since I wanted the ...
9ec3aea450e3d0d63c278201bbec912ab1b31e91
yasmirnova/python_learning
/chat_with_women.py
110
3.5625
4
name = input() a = len(set(name)) if a % 2 == 0: print('CHAT WITH HER!') else: print('IGNORE HIM!')
248bef6ea0c14d9ad54c02aff8e2a46be902020c
vbshah/INS-Practicals
/monoalphabatic.py
537
3.796875
4
n = int(input("1) Encryption 2) Decryption : ")) key = input("Type substitution string : ") s = input("Type the string for encryption or decryption : ") data = dict((chr(i + ord('A')), j) for i, j in enumerate(key)) ans = [] if n == 1: for i in s: try: ans.append(data[i]) except: ...
a40f2e71bf58e25e4336343c752493499b8fd94f
doug-silva1992/basicoPython
/Usando Iterações no Python/tudoJunto.py
176
3.765625
4
def count(number): total = 0 for x in number: if x < 20: total += 1 return total list_1 = [1, 3, 7, 15, 23, 43, 56, 98, 17] print count(list_1)
017b0543fd031602af8129b05cd6567ce67fc5db
AnuraghSarkar/DataStructures-Algorithms_Practice
/queue.py
1,671
4.53125
5
class queue: def __init__(self): self.items = [] def enqueue(self, item): """ Function to add item in first index or simply enqueue. Time complexity is O(n) or linear. If item is added in first index all next items should be shifted by one. Time depends upon list length....
6e1f21f8afe63f0f3cec9e046e6bed52d3b4442f
Sean329/data-science-prep
/code/symmetric_tree.py
1,159
3.828125
4
from __future__ import annotations from dataclasses import dataclass from typing import Optional @dataclass class TreeNode: val: int left: Optional[TreeNode] = None right: Optional[TreeNode] = None def is_tree_symmetric(node: TreeNode) -> bool: def _is_tree_symmetric(left: TreeNode, right: TreeNod...
796377487aecf6ba0ae26e6cfcca957fa9036647
xpansong/learn-python
/循环/for-in循环(练习题).py
193
3.671875
4
#找到100到999之间的水仙花数,153=3*3*3+5*5*5+1*1*1 for item in range(100,1000): a=item//100 b=item%100//10 c=item%10 if item==(c**3+b**3+a**3): print(item)
eba29d0c0479ed5412a114ae6ca7f7bce6dd156b
xpansong/learn-python
/字符串/8. 字符串的切片操作.py
416
3.8125
4
s='hello,python' s1=s[:5] #不指定起始位置,从0开始 print(s1) s2=s[6:] #不指定结束位置,到最后结束 print(s2) s3='!' print(s1+s3+s2) print('---------------切片标准格式[start:end:step]------------------') print(s[1:5:1]) #从1开始,包括1,到5结束,不包括5,步长为1 print(s[::2]) #从0开始,到最后结束,步长为2 print(s[::-1]) print(s[-6::])
75d580033b9ae7be6a86340e7b214ac101d25fdb
xpansong/learn-python
/对象(2)/3. 方法重写.py
1,079
4.21875
4
print('----------方法重写---------------') '''如果子类对继承自父类的某个属性或方法不满意,可以在子类中对其(方法体)进行重新编写''' '''子类重写后的方法中可以通过super().XXX()调用父类中被重写的方法''' class Person: #也可以写Person(object) def __init__(self,name,age): self.name=name self.age=age def info(self): print(self.name,self.age) class Student(Person)...
582fe920cc4dd459ec3f9b102f3f91dc5fd3960f
xpansong/learn-python
/列表/列表元素的排序.py
750
4.25
4
print('--------使用列表对象sort()进行排序,不生成新的列表,原列表直接运算,不需要重新赋值----------') lst=[10,90,398,34,21,77,68] print(lst,id(lst)) #调用列表对象sort(),对列表进行升序排序 lst.sort() print(lst,id(lst)) #通过指定关键字参数,对列表进行降序排序 lst.sort(reverse=True) print(lst,id(lst)) print('-------使用内置函数sorted()进行排序,生成新的列表,因此新列表需要重新赋值----------') lst=[10,90,398,34,21...
839d902b9cc0d7d760cfa93ed93d1eaea3c3cf5c
xpansong/learn-python
/对象(2)/7.1 __new__和__init__方法.py
1,299
3.953125
4
print('----------------使用new创建对象------------------') class Person: def __new__(cls, *args, **kwargs): print('__new__被调用执行了,cls的id值为{0}'.format(id(cls))) obj=super().__new__(cls) print('创建的对象的id为:{0}'.format(id(obj))) return obj def __init__(self,name,age): print('__init_...
3d0e37cee24acbfa1fa17c7a72cde1c397e9be13
xpansong/learn-python
/对象(2)/1. 封装.py
548
3.984375
4
print('----------面向对象的三大特征-----------') '''封装''' class Student: def __init__(self,name,age): self.name=name self.__age=age #age不希望在类的外部使用,所以加了__ def show(self): print(self.name,self.__age) song=Student('宋晓盼',33) song.show() print(song.name) #print(song.__age) #在类之外不能使用,不想让其他人在类之外访问,那么...
5ba5b7e604f2d1918066d3cbfd1d6837b56404af
xpansong/learn-python
/函数/1. 函数的创建和调用.py
216
3.6875
4
def multi(a,b): #a和b是占位符,是形式参数(形参),位置在函数的定义处 c=a*b return c result=multi(3,4) #3和4称为实参值(实参),位置是函数的调用处 print(result)
e81608b5a398ff1d9e60ceccc2640fe108d51817
xpansong/learn-python
/编码格式和文件打开模式/4. 文件对象的常用方法-read.py
418
3.78125
4
print('----------------读取文件的方法---------------------') file=open('china.txt','r') #print(file.read()) #read()会把文件中的所有内容读取出来,可以在括号中加数字,设置读取的字符个数 #print(file.readline()) #readline()会把文件中第一行内容读取出来 print(file.readlines()) #readlines()会把文件中每一行作为独立的字符串,放到列表中返回
0691a5c774938c7f0b81e4a96696b9805e111d17
stayfu0705/python1
/M6/keyword_argument.py
186
3.609375
4
def msg(name,age): print("{} is a {} years old.".format(name,age)) def main(): msg("mary","24") msg(name='mary',age=34) #msg(age=30, 'andy') msg('andy',age=25) main()
af094ce3cf05b2be6ca75b9dde8e5da545f0b6ef
stayfu0705/python1
/M7/1Dloop.py
1,072
3.546875
4
# list1=[[1,2,3],[7,8,9]] # print(list1[0][0],end=' ') # print(list1[0][1],end=' ') # print(list1[0][2],end=' ') # print(list1[1][0],end=' ') # print(list1[1][1],end=' ') # print(list1[1][2],end=' ') # print() # # list2=[[1,2],[3,4],[8,9]] # print(list2[0][0],end=' ') # print(list2[0][1],end=' ') # print(list2[1][0],en...
ed275af511c34a4fba87dd3361d5d2f44e6d3070
stayfu0705/python1
/M10/Account2.py
1,132
3.703125
4
class Account: def __init__(self, number, name, balance): self.number = number self.name = name self.balance = balance def deposit(self, amount): try: if amount <= 0: raise ValueError self.balance += amount except ValueError: ...
d075b89383128b98da0483b0b261ed4e42bc2a7f
stayfu0705/python1
/M3/basic.py
542
4.09375
4
print(9/4) # 除法 print(9//4) # 整除 print(3**4) # 次方 print(9%4) # 餘數 print(-9//4) # 負數的除法跟其他語言不同,是向負無窮取值 print(-9%4) print(2+3) print(int("2")+3) a = 40 print("a = ", a) print("a>>2 = ", a>>2) # 右移 print("a<<2 = ", a<<2) # 左移 print("a>>3 = ", a>>3) x = 10 y = 10 print("x is y : ", x is y) # is比...
39768f5f5217adf08077dfc98865f9a298526804
stayfu0705/python1
/M5/method.py
683
4.25
4
str1='hello 123' print(str1.isalnum()) #有空白就算兩個字串 print(str1.isalpha()) print(str1.isdigit()) print(str1.isidentifier()) str2='hello' print(str1.isalnum()) print(str1.isalpha()) print(str1.isdigit()) print(str2.isidentifier()) print(str2.isspace()) str5='hello world' print(str5.startswith('he')) print(str5.endswith("d...
b449e52d7af62e16670f6bbaf97440a48ff672a3
stayfu0705/python1
/M4/99.py
631
3.828125
4
for i in range(1, 10): for j in range(1, 10): print("{0}*{1}={2}".format(i, j, i*j), end="\t") print() print("=====================================") for j in range(1, 10): for i in range(1, 10): print("{0}*{1}={2}".format(i, j, i*j), end="\t") print() #先跑j再跑i print("====================...
8d35cbc91c9045da2fa346871030c663a86cd796
cherrykka/my-first-blog
/python_intro.py
168
3.59375
4
def hi(name): if name == "Kirsi": print("Hi Kirsi") elif name == "Sonja": print("Hi Sonja") else: print("Hi anonyymi") hi("Sonja")
cf64d18d26007b8c93a2c558b2829cda6f96e9c8
nicolasbgr/TwitterMarkovBot
/MTG.py
3,488
3.734375
4
import json from random import randint def Extraction_From_TXT(Data_File): """ parameters: a txt file (str). result: a list of every words used in the txt. """ with open(Data_File, "r", encoding="utf-8") as read_file: tweets = json.load(read_file) data = "" for tweet in tweets.k...
a29f06832bf4caa10f1c8d4141e96a7a50e55bb9
YashMali597/Python-Programs
/binary_search.py
1,180
4.125
4
# Binary Search Implementation in Python (Iterative) # If the given element is present in the array, it prints the index of the element. # if the element is not found after traversing the whole array, it will give -1 # Prerequisite : the given array must be a sorted array # Time Complexity : O(log n) # Space complexity...
de7cb8bb33a31a677b47d8c2915416145dcae572
phillipemoreira/HackerRank
/Python/BasicDataTypes/Lists.py
618
4.15625
4
#Problem link: https://www.hackerrank.com/challenges/python-lists list = list() number_of_commands = int(input()) for i in range(0, number_of_commands): s = input().split(' ') command = s[0] args = s[1:] if command == "insert": list.insert(int(args[0]), int(args[1])) elif command == "print...
b2c28049245c73f0a6cbf62919cfc4bebe0e0ef4
ck5354/haojie_python
/test_hj/python_study/test_函数h.py
561
3.984375
4
def multiple(arg, *args): # *args args为元组 print("arg: ", arg) # 打印不定长参数 print(type(args)) for value in args: print("other args:", value) multiple(1, 2, 3) def chang_int(a): a += 100 print("函数内取值:", a) c = 99 chang_int(c) print("函数外取值: ", c) def multiple2(a,b,**args): # *...
a3694c723fd19b769ead3aa04259ea1aba450769
ck5354/haojie_python
/python_knowledge/Python基础/list用法/zip()_tuples组成list.py
92
3.640625
4
list1 = [1,2,3,4] list2 = ["a","b","c","d"] res = [i for i in zip(list1,list2)] print(res)
6fff8277e51e2b25790ff2abbd6c93dcff7730be
Revys17/RL_18xx
/e30/stock_market_slot.py
2,373
3.59375
4
from enum import Enum from typing import Optional, Union, Tuple class StockMarketSlotColor(Enum): BROWN = 0 ORANGE = 1 YELLOW = 2 WHITE = 3 class StockMarketSlot: def __init__(self, location: str, up=None, right=None, down=None, left=None): self.location: str = location # value h...
261f2ae583f5155a19a1cf3eafecbbee9f7eaf5e
naresh508/oop
/oop_submissions/oop_assignment_004/complex_number.py
2,438
3.671875
4
import math class ComplexNumber: def __init__(self,real_part=0,imaginary_part=0): if type(real_part)==str and type(imaginary_part)==str: raise ValueError("Invalid value for real and imaginary part") if type(real_part)==str: raise ValueError("Invalid value fo...
9b30c957f1fb4ecb5f126588a867286f71f475ac
Himanshu123-abc/projects-accomplished
/himanshu python123.py
4,277
4
4
print("**Welcome to the Binary Adder**") print("\n") input1 = "yes" while input1 =="Yes" or input1 =="yes": output = False while output == False: try: H=int(input("Please enter the first number: ")) if H>255: print("The number should be in range of 0 an...
3174e99ee63b01eca8192b6f71d73e3cf5125892
KVD51/BestFit_SimpleRegression
/Simple_Linear_Regression.py
1,171
3.703125
4
# Define basic regression formula def get_y(m, b, x): y = m * x + b return y # Calculate error for a data point def calculate_error(m, b, point): x_point, y_point = point return abs(get_y(m, b, x_point) - y_point) # Calculate the total error for all points def total_error(m, b, points): tota...
ed67fddb3cd4941e793dff2128bfe2b9cdce4c95
sonukrishna/project--Simple-Pygame
/sample_examples/sample3.py
793
3.546875
4
"""multiple objects """ import pygame import random import sys res = [] pygame.init() black = (0, 0, 0) white = (255, 255, 255) color1 = (144, 145, 255) color2 = (255, 200,0) size = [720, 480] screen = pygame.display.set_mode(size) pygame.display.set_caption("snow animation") clock = pygame.time.Clock() for i in ra...
bacb0bfb5ceff2c49fbbc983a092c8fc1155029b
min19828257/leetAlgorithm
/kimminsu/2week/0114.py
2,327
3.5625
4
import copy class sol: def __init__(self, nums, target): self.nums = nums self.target = target self.current_state = 0 self.count = 0 def front_run(self): self.end_recursive() return self.count def end_run(self): self.front_recursive() return...
d089562243b35b8be2df3c31888518a235858c43
xiaoying1990/algorithm_stanford_part1
/merge_sort.py
2,293
4.53125
5
#!/usr/bin/python3 import random def merge_sort(ar): """ O(n*log(n)), dived & conquer algorithm for sorting array to increasing order. :param ar: type(ar) = 'list', as a array of number. :return: None, while sorting the parameter 'arr' itself. We can change it, because list is mutable. """ ar...
8165a87cb5eb03806555ca2a50a94141d9ed7ff2
bitcodr/pythonds
/intersect/main.py
156
3.65625
4
x = [7, 3, 7, 9, 2, 5, 1, 0] y = [8, 3, 0, 1, 6] m = {} for i in x: m[i] = i g = [] for i in y: if m.get(i) == i: g.append(i) print(g)
29759be9903c1bc1bd1feddda6b3e0036da0e500
aadityaks/skylark_assignment
/pts_of_interest.py
3,686
3.5625
4
import math import pysrt import piexif import csv from Tkinter import * import Tkinter, Tkconstants, tkFileDialog import os #---------------lat,lon to degree conversion----------------------------------------------- def degrees(value): d0 = value[0][0] d1 = value[0][1] d = float(d0) / float(d1) ...
950e7d2a4f2566899cbcee48c7cb2b8cf53b14be
GitKote/PythonKnowledge
/allAndany.py
313
3.8125
4
#DEFINITION """ The all() and any() they work on iterables as parameters, they used to predict whether the iterable has elements or zeros, None """ #EXAMPLES all([2,3,4,5]) #DIFFERENT_CASES all([0,None]) any([0,None]) all([]) """ It says that zero and None doesnt return True,also empty list its different """
49b2eeb36f060eb73102833d1eb7701815c496e8
faxinwang/OJ_PAT
/1 basic/py/1001. 害死人不偿命的(3n+1)猜想 (15).py
119
3.703125
4
n = input() n = int(n) cnt = 0 while(n>1): if(n%2==1): n = (3*n+1)/2 else: n = n/2 cnt = cnt + 1 print(cnt)
6eaf88e1496a0641e60c19fead83df72ea6a0f22
Maxim666ENG/Coder
/blocksdone.py
4,961
4.21875
4
def main(): account = input("Welcome to gog.com, please enter '1' to sign up") #asking to create an account errors = [] # these 4 lines are like a storage class_list = {} class_list2 = {} username1 = '' username2 = '' #setting password criteria while True: if account...
a9d09ebd063cc7b06de73a5e020aa4e7c3d9e45d
jackyjkchan/surgical_consumable_supplychain
/scm_simulation_archive/simulation_processes.py
7,780
3.515625
4
def book_surgeries(env, hospital, booking_lead_time=14): """Process: Generates random number of surgeries to book K days into the future. This process assumes that at every period, we will book all surgeries K periods away. This is a simplification of having surgeons make their surgery schedules known 2 ...
cd5352e41f9ecabad9340092b156fd2a18c6717d
sih4sing5hong5/tshu2-li2_tiong1-gian5-inn7_piau1-im1
/test/part3_unittest.py
8,180
3.5
4
import unittest class part3: def compare_fst_string(self,s1): '''測試目標1:把編號切出來 參數: s1 - 原句,例如:dv0146003 若是日頭黃昏e時,/na2-si3-rit3-tau5,hong3-hun1-e2-si5- fst_result - 可使用的Output(如果測試都Ok),例如:s1[0,9] ''' tmp='' if(s1[9] == ' '): #假設編號長度是固定(9)且編號之後會空一格,若...
f748e7a49c24732b9750aef8b9560a8af70eb7fd
sih4sing5hong5/tshu2-li2_tiong1-gian5-inn7_piau1-im1
/試驗/走全部試驗.py
1,465
3.734375
4
""" 著作權所有 (C) 民國103年 意傳文化科技 開發者:薛丞宏 網址:http://意傳.台灣 語料來源:請看各資料庫內說明 本程式乃自由軟體,您必須遵照SocialCalc設計的通用公共授權(Common Public Attribution License, CPAL)來修改和重新發佈這一程式,詳情請參閱條文。授權大略如下,若有歧異,以授權原文為主: 1.得使用、修改、複製並發佈此程式碼,且必須以通用公共授權發行; 2.任何以程式碼衍生的執行檔或網路服務,必須公開該程式碼; 3.將此程式的原始碼當函式庫引用入商業軟體,且不需公開非關此函式庫的任何程式碼 此開放原始碼、共享軟體或說明文件之使用或散佈不負擔保責任,...
355bcd95c0c6c22a3653cb84f5bb6ca7b02e1a28
boilerfixer/my-first-blog
/python_intro.py
131
3.828125
4
def hi(name): print('Hi' + name + '!') girls = ['Rachel', 'Billy', 'Maggie'] for name in girls: hi(name) print('Next girl')
e69f86e3007b23a97d0ebc1baedd54afcaf46999
SouvikRoy31/mini_games
/hanf.py
2,091
3.890625
4
import random hangmanpic = [''' +---+ | | | | | | =========''', ''' +---+ | | O | | | | =========''', ''' +---+ | | O | | | | | =========''', ''' +---+ | | O | /| | | | =========''', ''' +---+ | | O | ...
b2fd30399643df39af6ffec72616414846306cb8
darwinini/practice
/python/maxSum.py
525
3.96875
4
# This program returns the greater sum of an array with window size k def maxSum(K, arr): maximum, windowSum, windowStart = 0.0, 0.0, 0 for windowEnd in range(len(arr)): windowSum += arr[windowEnd] if windowEnd >= K - 1: # print(f"The max at index {windowEnd} is {maximum}") ...
092456e8cf7b788e6a34b5adcde89d5a3a30e9f3
darwinini/practice
/python/class.py
877
4.09375
4
# Defining a Flight class class Flight(): def __init__(self, capacity): self.capacity = capacity self.passangers = [] # method to add passanger to the flight def add_passangers(self, name): if not self.open_seats(): # similar to if self.open_seats() == 0 return False ...
0e48b82567ddcd2eabacdb0c1a4fb514f0e97eb7
darwinini/practice
/python/avgArray.py
655
4.21875
4
# Program to find the average of all contiguous subarrays of size ‘5’ in the given array def avg(k, array): avg_array = [] for i in range(0, len(array) - k + 1): sub = array[i:i+k] sum, avg = 0, 0 # print(f"The subarray is {sub}") for j in sub: sum+= j avg =...
565cc0baba295adf973102e4a6b82a5be4bcef06
darwinini/practice
/python/name.py
101
4
4
name = input("name: ") #in python 3 we have f strings (formatted strings print(f"hello, {name}")
1f1d21ee84e8bfeba81dfb953f4e7f4f93d47fd9
MorphisHe/conceptExtraction
/pca_plot.py
3,373
3.59375
4
''' This file plots a document and it's ckps to 2d graph Run Guild: - run in the dir of this script - python3 pca_plot.py [mode=(w2v | d2v)] [model_path] - if "w2v" is passed, plots the word matrix in model to 2d graph - if "d2v" is passed, plots doc, ckps, selected ckps to 2d graph ''' from s...
eba45fd3ed8523fceccf08482512a8d06d2c550f
NAMZseng/numerical-analysis
/1_1_bisection.py
782
3.859375
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Author : Nam Zeng # @Time : 2018‎/11‎/19 ‎‏‎22:03 # @Desc : 使用二分法(bisection method)求解方程的近似根 from sympy import symbols, lambdify, plot def bisecrt(): x = symbols('x') f = x ** 3 + x - 1 func = lambdify(x, f) a = -1 b = 1 tol = 0.000001...
7191b4c06c25b7c9f1a8ea63379dbe0a4f688b34
bielikvladyslav/Bielik
/Bielik_Calculator.py
30,986
3.703125
4
import tkinter as tk from tkinter import messagebox import re import numpy as np import math from tkinter import * hist=0 def add_digit(digit): '''Добавляем цифру и если перед ней стоял нолик, то нолик удаляется. НО если мы выполняем какую-то операцию над ноликом, то он остается. ''' va...
4e115e841cf40b74326291526ec2aee693fc5129
sitaowang1998/CSC443-DBMS
/assignment1/reader.py
886
3.609375
4
class Reader: @staticmethod def read_varint(db): """ Read the varint from db file object """ value = 0 for _ in range(8): byte = int.from_bytes(db.read(1), byteorder='big', signed=False) value = value << 7 | (byte & 0x7F) if not (byte...
95ccd0430819b88d016758679f861120852d4232
KishoreArani/DataStructures-python
/queuelInkedlist.py
1,031
4.0625
4
class node: def __init__(self,data): self.data = data self.next = None class Queue: def __init__(self): self.front = None self.rear = None def enQueue(self,data): if self.rear == None: self.front = self.rear = node(data) return self.r...
fef4a878e12b6639d22ef2b732aec285c11a2e13
ApocalyVec/mGesf
/utils/transformation.py
4,458
3.796875
4
import numpy as np import itertools as it from scipy.spatial import distance def transform(m, trans_m): """ NOTE: this function is called by other transformation functions, do not call this function directly :param m: the n * 3 matrix for which to apply translate :param trans_m: the 4 * 4 transformatio...
e5228696dbee897f5eeacf1d64a1916445217296
Revaun/Machine-Learning-IV
/kmeans.py
560
3.53125
4
#K-Means clustering implementation #Some hints on how to start have been added to this file. #You will have to add more code that just the hints provided here for the full implementation. # ==== # Define a function that computes the distance between two data points # ==== # Define a function that reads ...
805391eab5a3c4f887a2b1e053889ac5c283eec8
AbhishekPatnaik/stranger_chats
/test.py
855
3.84375
4
""" if id not in count: count.append(id) roomName = "Room" + str(random.randint(0,3)) print(roomname_already_exists(roomName,roomChat)) if roomname_already_exists(roomName,roomChat) == True: roomName = shuffle_except_this_roomname(roomNam...
0c0718a685533344d5fea9cfdf1ec9d925dbdcd9
Surya0705/Number_Guessing_Game
/Main.py
1,407
4.3125
4
import random # Importing the Random Module for this Program Random_Number = random.randint(1, 100) # Giving our program a Range. User_Guess = None # Defining User Guess so that it doesn't throw up an error later. Guesses = 0 # Defining Guesses so that it doesn't throw up an error later. while(User_Guess != Random_Num...
99b9c2c168ad8f2686c3327c2d3d6e3252ae2729
bnew59/sept_2018
/notes.py
15,088
4.40625
4
9/19 # Dictionaries #first_name = input("Enter First Name: ") #last_name = input("Enter Last Name: ") #street = input("Enter Street: ") #city = input("Enter City: ") #state = input("Enter State: ") #user = {"FirstName": first_name, "LastName": last_name} #address = {"Street": street, "City" : city, "State" : state}...
16d1c6a7eca1df4440a78ac2f657a56fa1b8300b
bnew59/sept_2018
/find_largest_element.py
275
4.21875
4
#Assignment: Write a program which finds the largest element in the array # def largest_element(thing): # for num in thing: # if num + 1 in # elements = [1, 2, 3, 4] a=[1,2,3,4,6,7,99,88,999] max = a[0] for i in a: if i > max: max=i print(max)
20f1c927a7caaff2238acef2ebb9f8aa8a1dfede
bnew59/sept_2018
/shopping_list.py
4,563
4.65625
5
# Assignment # Grade: N/A # View Grade Information. Opens a dialogue # Assignment: # You are responsible for creating an app that manages groceries. Your groceries are characterized by # Shopping Lists which can contain grocery items. Here are the features you need to implement: # * You need to ask the user for the ...
2ef24ff625bcc33303bddfe4546c850ff37982bb
yotaMLei/learning-theory-project
/main-logistic regression.py
9,609
3.671875
4
""" Introduction to Machine Learning - Programming Assignment Exercise 04 December 2020 Yotam Leibovitz """ from sklearn.datasets import fetch_openml from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler from sklearn.utils import check_random_state import matplotlib.pyplo...
247c624503d0ac933e407af18873b9d6e4cc66aa
ykodama/codingbat_python
/count_evens.py
98
3.546875
4
def count_evens(nums): count = 0 for ni in nums: if ni % 2 == 0: count += 1 return count
3a3025a0e171a841ab17a0f569a536c2319ec588
Samyak2607/CompetitiveProgramming
/Hackerrank/Abbreviation.py
1,065
3.625
4
def abbreviation(a, b): A=a.lower() B=b.lower() flag=0 dic={} B=b.lower() A=a.lower() aa=set(a) bb=set(b) x='' if B in A: ind=A.index(B) end=ind+len(b)-1 for i in range(len(a)): if (i>end) or (i<ind): if a[i].isupper(): ...
da562b48b8a5695020d9aabd531df79d5e26e326
Samyak2607/CompetitiveProgramming
/Codechef/PAWRI.py
95
3.734375
4
for _ in range(int(input())): s=input() s=s.replace('party','pawri') print(s)
c64b1e0c45ea4de9c2195c99bfd3b22ab2925347
Samyak2607/CompetitiveProgramming
/Interview/postfix_evaluation.py
1,133
4.15625
4
print("For Example : abc+* should be entered as a b c + *") for _ in range(int(input("Enter Number of Test you wanna Test: "))): inp=input("Enter postfix expression with space: ") lst=inp.split(" ") operator=['+','-','/','*','^'] operands=[] a=1 for i in lst: if(i not in operator): ...
f90e51c9dec2307818b1496b812163e80540f4a5
Samyak2607/CompetitiveProgramming
/Hackerrank/viralAdvertising.py
223
3.71875
4
def viralAdvertising(n): x=5 s=0 for i in range(n): s+=(x//2) x=(x//2)*3 return s for _ in range(int(input())): n=int(input()) result=viralAdvertising(n) print(result)
cee84103dc334f894a08b2db60366f6fbe6b7f61
Samyak2607/CompetitiveProgramming
/Hackerrank/Sherlock and the Valid String.py
728
3.53125
4
for _ in range(int(input())): s=input() word={} freq={} for i in s: if i in word: word[i]+=1 else: word[i]=1 print(word) for i in word: if word[i] in freq: freq[word[i]]+=1 else: freq[word[i]]=1 print(freq) i...
438ef24bfbdcce72ba42182799e01bc806724268
Samyak2607/CompetitiveProgramming
/Hackerrank/New Keyboard.py
1,216
3.6875
4
def is_char(a): try: int(a) return False except ValueError: return True for _ in range(int(input())): s=input() st=[] af=False ans='' lock=True key=False ## for i in s: ## if i=='*': ## if not st: ## continue ## st...
85b73119c3d7a8a2e8552c9fc4475513f53c5942
Samyak2607/CompetitiveProgramming
/GeeksForGeeks/BitWise/swapBits.py
244
3.59375
4
def swapBits(n): s='' x=bin(n).split('b')[1] if len(x)%2!=0: x='0'+x[:] for i in range(len(x)-1,0,-2): s=x[i]+x[i-1]+s return int(s,2) for _ in range(int(input())): n=int(input()) print(swapBits(n))
5044a217187c1f5599abeac191530c88975179b2
Samyak2607/CompetitiveProgramming
/HackerEarth/bubble_sort.py
391
3.625
4
def bubble_sort(a): count=0 n=len(a) swp=True while swp!=False: swp=False count+=1 for i in range(0,n-1): if a[i]>a[i+1]: temp=a[i] a[i]=a[i+1] a[i+1]=temp swp=True return count for _ in range(int(inp...
42139f7567450e03edbfe65be9abbbdeb38287b1
Samyak2607/CompetitiveProgramming
/Codechef/Factorial.py
171
3.609375
4
for _ in range(int(input())): n = int(input()) z=0 temp=5 chk=n while(chk != 0): z+=n//temp chk = n//temp temp*=5 print(z)
deeb36892f83b2dffdbf05b8716a2fbb2fc130b8
jayyunas/evil_hangman
/main.py
659
3.84375
4
#main.py #Main function #Jay Yunas #17th December, 2018 from words import * from hangman import * from hangmanui import HangmanUI import config def main(): """Main Function""" #always start a new game while True: #initialize dictionary word = randWord(config.minWordLength, config.maxWordLe...
d5bcb62f24c54b161d518ac32c4a2434d01db76e
PaLaMuNDeR/algorithms
/Coding Interview Bootcamp/16_linked_list.py
1,665
4.25
4
""" Return the middle node of a Linked list. If the list has an even number of elements, return the node at the end of the first half of the list. DO NOT use a counter variable, DO NOT retrieve the size of the list, and only iterate through the list one time. Example: const l = LinkedL() l.insertLast('a') ...
5c584f8ddebef96fb3c78a957abdef40cd2aac60
PaLaMuNDeR/algorithms
/Algo Expert/131_find_loop.py
857
3.671875
4
""" Find Loop Write a function that takes in the head of a Singly Linked List that contains a loop (in other words, the list's tail node points to some node in the list instead of the None (null) value). The function should return the node (the actual node - not just its value) from which the loop originates in constan...
d74c7b4510731a5208777dec92363e7f8dbc8550
PaLaMuNDeR/algorithms
/Coding Interview Bootcamp/13_vowels.py
1,103
4.09375
4
import timeit import re """ Write a function that returns the number of vowels used in a string. Vowels are characters 'a', 'e', 'i', 'o', 'u' Examples: vowels('Hi There!') -> 3 vowels('Why do you ask?') -> 4 vowels('Why?') -> 0 """ def vowels(text): """Just iterating on the letters and comparing them...
edbbd4fe3fc4a8646c52d70636369ff1c1c23bd5
PaLaMuNDeR/algorithms
/Coding Interview Bootcamp/10_capitalize.py
2,096
4.28125
4
import timeit """ Write a function that accepts a string. The function should capitalize the first letter of each word in the string then return the capitalized string. Examples: capitalize('a short sentence') -> 'A Short Sentence' capitalize('a lazy fox') -> 'A Lazy Fox' capitalize('look, it is wor...
e566b744ecde037c26580866f6d4b45059ecd075
PaLaMuNDeR/algorithms
/22_hackerland_roads_libraries.py
5,768
3.921875
4
#!/bin/python import os """ https://www.hackerrank.com/challenges/torque-and-development/problem The Ruler of HackerLand believes that every citizen of the country should have access to a library. Unfortunately, HackerLand was hit by a tornado that destroyed all of its libraries and obstructed its roads! As you are th...
52cf1f1b5914447294ae9eb29b40abaa5086f644
PaLaMuNDeR/algorithms
/Algo Expert/113_group_anagrams.py
894
4.34375
4
""" Group Anagrams Write a function that takes in an array of strings and returns a list of groups of anagrams. Anagrams are strings made up of exactly the same letters, where order doesn't matter. For example, "cinema" and "iceman" are anagrams; similarly, "foo" and "ofo" are anagrams. Note that the groups of anagrams...
cdfa714d56aad96ba4cbcd6ff4dfd25865d8e085
PaLaMuNDeR/algorithms
/Algo Expert/101_Two_number_sum.py
819
4.125
4
""" Two Number Sum Write a function that takes in a non-empty array of distinct integers and an integer representing a target sum. If any two numbers in the input array sum up to the target sum, the function should return them in an array, in sorted order. If no two numbers sum up to the target sum, the function should...
995aaacefeb011ff0ef04a62d4c9fd4688b4450e
PaLaMuNDeR/algorithms
/Algo Expert/124_min_number_of_jumps.py
1,006
4.125
4
""" Min Number Of Jumps You are given a non-empty array of integers. Each element represents the maximum number of steps you can take forward. For example, if the element at index 1 is 3, you can go from index Ito index 2, 3, or 4. Write a function that returns the minimum number of jumps needed to reach the final inde...
09f8d90903de5075e9202f2632244da6dc87e145
skdls-/Python
/Week0/Week0-2/Count_unique_words.py
228
3.953125
4
def Count_unique_words(arr): if arr == []: return 0 count = 1 for i in range(0,int(len(arr)-1)): if arr[i+1] not in arr[0:i+1]: count += 1 return count print (Count_unique_words(["apple", "banana", "apple", "pie"]))
20bfe890bbb6821d51099cc970168a869b274576
skdls-/Python
/Barbut/bonus_functions.py
835
3.65625
4
from random import randint def all_same_three(items): return all(x == items[0] for x in items) and len(items) == 3 def one_three_five(items): if 1 in items and 3 in items and 5 in items: return True return False def two_four_six(items): if 2 in items and 4 in items and 6 in items: ...
461f6aa8d406ffcc297e1117eaa55f8939bc5a6b
skdls-/Python
/Week0/Week0-1/is_Prime.py
165
3.71875
4
def is_Prime(num): devisor = 2 while devisor <= int(num ** 0.5): if num % devisor == 0: return False devisor += 1 return True