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
02beb0d730bc97ff19548c2667eb23a36a9ddb62
gschen/where2go-python-test
/1300-蓝桥杯/year-2012/JAVA-C(2)/test-10.py
868
3.578125
4
# 10.土地测量 # 造成高房价的原因有许多,比如土地出让价格。既然地价高,土地的面积必须仔细计算。遗憾的是,有些地块的形状不规则,比如是如图【1.jpg】中所示的五边形。 # 一般需要把它划分为多个三角形来计算。 # 已知三边求三角形的面积需要用海伦定理,参见【2.jpg】 # 各条边长数据如下: # AB = 52.1 # BC = 57.2 # CD = 43.5 # DE = 51.9 # EA = 33.4 # EB = 68.2 # EC = 71. #>>>>>>>>>>>>方法一 def hailun(a,b,c): p=(a+b+c)/2 S=(p*(p-a)*(p-b)*(p-c))**(1...
7ca4a24d80f5e340ac1fa523450d87e47e13d898
gschen/where2go-python-test
/1906101001周茂林/第10周/7.py
325
3.828125
4
''' 给定一个字符串,请你找出其中不含有重复字符的最长子串的长度。 ''' def ababab(l): l2 = [] for m in range(len(l)+1): for n in range(len(l)+1): if m < n and len(l[m:n]) == len(set(l[m:n])): l2.append(len(l[m:n])) print(max(l2)) ababab('abcabcbb')
e92a5bd4a53e1d3e55cdd1512c35d01344c023f8
gschen/where2go-python-test
/1200-常用算法/回溯算法/数独.py
2,012
3.84375
4
''' 编写一个程序,通过已填充的空格来解决数独问题。 一个数独的解法需遵循如下规则: 数字 1-9 在每一行只能出现一次。 数字 1-9 在每一列只能出现一次。 数字 1-9 在每一个以粗实线分隔的 3x3 宫内只能出现一次。 空白格用 '.' 表示。 ''' result = [] # N = 9 # board = [['.' for j in range(N)] for i in range(N)] def is_valid(board, row, col, num): n = len(board) # 每一列不能重复 for i in range(n): if b...
0c014960c031136cef2eb08b32cc99a134cce7b2
gschen/where2go-python-test
/1906101038江来洪/day20191216/Test_3_1.py
228
3.59375
4
#选出大于平均数的身高 list = input('请输入你班级的身高:').split() i = int(len(list)) S = 0 for x in list: x = int(x) S = S+x X = S/i for a in list: a = int(a) if a>X: print(a,end=' ')
52e693cd51269f89593f4eb8ac6795ccae5de9a5
gschen/where2go-python-test
/1906101105石涛/蓝桥杯寒假练习/2015年java B组/text2.py
560
3.671875
4
# coding=utf-8 ''' 2.立方变自身 • 观察下面的现象,某个数字的立方,按位累加仍然等于自身。 1^3=1 8^3=512 5+1+2=8 17^3=4913 4+9+1+3=17 • 请你计算包括1,8,17在内,符合这个性质的正整数一共有多少个? ''' # (思路:从一定范围取出的数字,然后将它们str分开然后int后相加,与原来那个对比下看是否相等) j=0 for i in range(1,10000): m,n=i**3,0 for k in str(m): n+=int(k) if n==i: j+=1 print('符合这个性质的...
63151c8db5383361ed3c3ac1df46be5aa63fa24f
gschen/where2go-python-test
/1906101007李和龙/Day20191115/取球博弈.py
1,204
3.5625
4
""" 取球博弈 今盒子里有n个小球,A、B两人轮流从盒中取球,每个人都可以看到另一个人取了多少个,也可以看到盒中还剩下多少个,并且两人都很聪明,不会做出错误的判断。 我们约定: 每个人从盒子中取出的球的数目必须是:1,3,7。 轮到某一方取球时不能弃权! A先取球,然后双方交替取球,直到取完。 被迫拿到最后一个球的一方为负方(输方) 请编程确定出在双方都不判断失误的情况下,对于特定的初始球数,A是否能赢? 程序运行时,从标准输入获得数据,其格式如下: 先是一个整数n(n<100),表示接下来有n个整数。然后是n个整数,每个占一行(整数<10000),表示初始球数。 程序则输出n行,表示A的输赢情况(输为0,赢为1)。 例如,用户输...
9cc20e321530c6113c6e8b9e11f4cb21f8a7a187
gschen/where2go-python-test
/1906101007李和龙/Day20191126/实验六2.py
413
3.65625
4
""" 2. 有helloWorld()函数,请使用装饰器,在每次调用该函数的时候可以显示当前时间,注意引入datatime def helloWord(): print(‘Hello wolrd’) """ from datetime import datetime def now(func): def wrapper(*args,**kw): print(datetime.now()) return func(*args,**kw) return wrapper @now def helloWord(): return 'Hello world' print(hell...
720851f883e4051555bb275700dd1482aa1662e1
haonanq666/ics3u
/moneycount/window.py
4,677
3.6875
4
from moneycount.count import player print('hello') def main(): action = input('')#this is where the players input commands action = action.split() canbuy = True #checks if a property is allowed to be bought syntax = False #checks for syntax errors from the user if(len(action)==0): ...
66165b183781131a5e37fa228be845a2e7be5ca9
haonanq666/ics3u
/moneycount/count.py
2,693
3.953125
4
class player(object): #players who play the game of monopoly def __init__(self, name, initialmoney): self.__name = name self.__money = initialmoney self.__properties = [] def paymoney(self, amount): self.__money = self.__money - amount def addmoney(self, amount): ...
54ad0ffa364c82c9405cf43ca7fca22891904b44
haonanq666/ics3u
/abitflashy/gamewindow.py
7,634
3.53125
4
import pygame from numpy.random.mtrand import randint import sys from sympy.sets.sets import Interval, Intersection from abitflashy.filewrite import gethighscore, savehighscore def intro(): #this is the opening page of the game if(firsttime): #detects if it is first time running program, deter...
4e441ab239c7d9bec2ed15b889002935808f9adc
pcebollada/Python
/Ejercicios de clase/Buenos días, tardes, noches.py
493
4.15625
4
# -*- coding: cp1252 -*- #hacer un programa que segun la hora que sea, nos diga buenos dias, buenas tardes o buenas noches# #De seis a catorce, son buenos das;de catorce a veinte son buenas tardes; y de 20 a 6 son buenas noches# def saludador(): h=input("Dime que hora es?:") if (h>=6 and h<14): pr...
0db870abe8b05b6b1f5c3031fad4cf6c7348c8d9
pcebollada/Python
/Ejercicios de clase/Posible problema de examen.py
337
3.734375
4
def cualessonpares(): suma=0 numero=input("Dime un numero de cuatro, cinco o seis cifras: ") while numero>10: aux=numero%10 if aux%2==0: suma=suma+1 numero=numero/10 print "Hay",suma,"numeros pares" print "PEPE" cualessonpares() #nos piden que cuente lo...
e3f15adeb2d3d6a746ad57bf0a1818972a47da30
pcebollada/Python
/Ejercicios Gmail/12.py
664
3.75
4
#30 dlares si el coche lleva mal aparcado ms de 1 hora #aparcar mal menos de 1 hora no es una infraccin #suplemento de 5 dolares por hora si la infraccin supera las 24 horas # programa del tiempo que lleva mal estacionado, diciendo si es o no infraccin #y coste def chivato(): n=input("Dime cuanto lleva mal ap...
6c128bf37136503b9736d9475991bdf9ecb7b086
pcebollada/Python
/Teoria y ejercicios variados/2.py
1,017
3.90625
4
n=0 def pepe(): print "hola" print "adios" j=10 return j n= pepe() print n #sacamos la variable j de la funcion y luego la asignamos a n #si imprimieramos j, nos saldra error xq le hemos cambiado el nombre pepe () print n def pepa(n2): print "hola" print "adios" j=n...
be149b81104b61c8c7f475af4dccd0f6ce7ad467
Aditya7861/Self
/wiki_age.py
647
3.875
4
#This is my first Web Scraping Script to find #age of a person using wikipedia import requests from bs4 import BeautifulSoup name=raw_input('Enter his name:-') get_space_indices=name.find(" ") new_name=name[:get_space_indices]+'_'+name[get_space_indices+1:] #print(new_name) url='https://en.wikipedia.org/wiki/{}'.for...
c28a46c26aeb2c196812a81f3b2fe24f9fb00cd1
TianJin93/Tian-Jin-s-Study-Work
/C343Fall2015/project3/BST.py
7,241
3.75
4
from stack import ArrayStack class BSTNode: def __init__(self, key, left=None, right=None, parent = None): self.key = key self.left = left self.right = right self.parent = parent def less_than(x, y): return x < y class Bi...
fb6823ec662a4965287088e2b8fffb24e119907f
MankaranSingh/Basic-Data-structures-and-algorithms
/stack_linklist.py
1,295
3.921875
4
class node: def __init__(self, value): self.data = value self.next = None class linkstack: def __init__(self): self.top=None def push(self, value): if self.top=None: self.top=node(value) print('Value added') else: temp=...
72eba544e40ffea5f76f1c947f910c06c36f4a14
robertroath/simple_py_pass_cracker
/simple_py_pass_cracker.py
186
3.625
4
import sys import crypt passfile=open('rockyou.txt','r') for word in passfile.readlines(); if (crypt.crypt(word.strip()."MS")==sys.argv[1]); print "password is "+word
1179eb9fe7592233ab8f7710a9ce8086584f6f82
danieldan0/python_roguelike
/input_handlers.py
1,117
3.703125
4
def handle_keys(user_input): """ Keyboard input handler. :param user_input: user_input :return: dict """ key_char = user_input.char if user_input.key == 'UP' or key_char == 'k': return {'move': (0, -1)} elif user_input.key == 'DOWN' or key_char == 'j': return {'move': (...
db92d6c44041067b4166da11227060bff483a822
qiangayz/MyCode
/面向对象/继承1.py
1,151
3.890625
4
#coding=utf-8 class people(object): # def __init__(self): # self.age = 45 # print('People') def sleep(self): print(123) class Relation(object): def __init__(self): print('Relation') class Man(people,Relation): def __init__(self): super(Man,self).__init__() #这里继承...
a9da012c7ece76d59743d65516f1a92b917605c1
qiangayz/MyCode
/面向对象/面向对象1.py
2,898
3.65625
4
#coding=utf-8 """ class 类 #对一类拥有相同属性的对象的抽象、蓝图、原型,在类中定义了这些对象都具备的属性、共同方法 object对象 一个对象就是一个类的实例化模型,一个类必须经过实例化后才能在程序中调用,一个类可以实例化多个对象 类的三大特性: 1、封装 在类中对数据赋值。内部调用对外部用户是透明的、里面包含着类的数据和方法、类似一个胶囊或者容器 2、继承 一个类可以派生出子类,在这个父类中定义的方法属性可以被子类继承 3、多态 例:老板让所有员工开始工作,老板只需要说开始工作,而不需要对各类员工下达任务、类似财务部、行政部、技术部等、 即一个接口,多种实现。 编程的两大原则: 1、写重复代码是非常不好的...
afe57d491c70b4d7fe60ab136edb9f6d4bb046e7
qiangayz/MyCode
/迭代器与生成器/迭代器与生成器.py
2,052
3.96875
4
#coding=utf-8 """ 1、列表生成式 """ list1 = [i for i in range(10)] print list1 """生成器 generator 只有在调用的时候才会生成相应的数值、只记录当前位置, 只有一个__next__方法.python2.7里面是next()一般不用此方法,会使用for循环来遍历生成器 """ list1 = (i for i in range(10)) print list1 # # # a= 1 # b=2 # a,b = b,a+b # #相当于 # t = (b,a+b) # a = t[0] # b = t[1] #生成器函数实例 def fib(value):...
31cef582ca308ee84b00d81d520530f208cd4b96
ruckserve/JuniorDevs
/algorithms/binary_search/binary_iterative2.py
622
4.09375
4
#!/usr/bin/env python import string alpha = list(string.ascii_lowercase) def find_letter(letter, alpha=alpha) : start = 0 end = len(alpha) while start != end : midpoint = start + ((end - start) / 2) if letter > alpha[midpoint] : start = midpoint + 1 continue ...
fbe662baa95c428543e7146a04a73fa7810b4030
JoonasMaanonen/towerDefence
/PopUpMenu.py
2,066
3.9375
4
import pygame, sys from pygame.locals import * BLACK = ( 0, 0, 0) RED = ( 255, 0, 0) WHITE = ( 255, 255, 255) GREEN = ( 0, 255, 0) PURPLE = ( 128, 0, 128) SCREENWIDTH = 1024 SCREENHEIGHT = 768 HALFWIDTH = SCREENWIDTH / 2 HALFHEIGHT = SCREENHEIGHT / 2 class PopUpMenu: def __init...
89ad4d5bc45d360e666eb2c8b7928cde2725ea4b
alankemboi/Hacktober-Fest-GDSC-Kisii
/Programming_Languages/Python/Node.py
568
4.0625
4
# Python program to introduce Binary Tree # A class that represents an individual node in a # Binary Tree class Node: def __init__(self,data): self.left = None self.right = None self.data = data # create root root = Node(1) root.left = Node(2) root.right = Node(3) root.left.left = Node(4) ...
6d8422fdf6ac862c22d8af679c6b3f8b0c9f9914
firdoussaleheen/VOLTA-WebApp
/fix_multisim/circuit_tracer.py
2,448
3.5625
4
#!/usr/bin/env python ''' Python program to convert a Multisim netlist to an acceptable format for circuit tracing User's notes: The circuit tracer is only concerned with node & name Inputs: infile - Path to Multisim netlist Outputs: outfile - Converted file Written by Zack Smith 2-05-15 ''' # Necessary Impor...
ca6799f6194eeaa553db2563b3d063f635d6d058
Mathisxy123/PythonCrashCourse
/exercises/PyExercises/NameSurnameEx19.py
304
4.0625
4
##write a function sum_dict() that takes a dictionary as an argument ##and returns the sum of the keys ##bonus point: sum only floats and ints, without errors for other data types ##write a function merge_dict() that merges two dicts def sum_dict(dictionary): def merge_dict(dict1, dict2):
1c35c5f9af5edaf228bf4f2d15e54f16a6c5aca4
Mathisxy123/PythonCrashCourse
/What we did in class/test_import/get_divisors.py
501
3.78125
4
def get_div(integer): """ Return list of divisors of integer. :param integer: int :return: list """ divisors = [num for num in range(2, int(integer**0.5)+1) if integer % num == 0] rem_divisors = [int(integer/num) for num in divisors] divisors += rem_divisors divisors.append(...
69875b047f586c2617d61feaef23fffef5391e51
dayna138/dayna138
/game.py
592
3.515625
4
# coding: utf-8 from random import randint def game(): password=randint(1,99) guess=-1 _min=1 _max=99 while guess!=password: guess=int(input('請輸入數字:')) if guess>password: _max = guess print('答案介於',_min,'~',_max,'之間') elif guess<password: _...
6ec94984ba6accc3ca219f3abf1391b4a1dfd686
Philip-Crowther/ml-implementations
/naive_bayes_classifier.py
4,474
3.734375
4
# naive_bayes_classifier.py - implementation of the naive bayes classification algorithm from collections import Counter class NaiveBayesClassifier: def __init__(self): """ Naive Bayes Classifier Class ===================== Attributes: ------------- proposition_pri...
d336343c8be6197e8de0e7d3e8d01122cb7c0c61
progo/summer
/runtests.py
5,524
3.875
4
#!/usr/bin/python import unittest from reader import Summer class SummerTestCase(unittest.TestCase): def setUp(self): self.s = Summer() def assert_input(self, input, output): result = self.s.readline(input) self.assertEqual(result, output) def ensure_input(self, input): re...
b1bc5e746141fdbefb74f8281a12e88a6743a53a
keatinge/Project-Euler-Python
/1.py
240
3.921875
4
# Find the sum of all the multiples of 3 or 5 below 1000. multiplesBelow = [] #list of multiples of 3 or 5 below 1000 for i in range (1, 1000): if i % 3 == 0 or i % 5 == 0: multiplesBelow.append(i) print(sum(multiplesBelow)) #233168
951b85d124d0922d23089a625ac2ae057f2802ee
keatinge/Project-Euler-Python
/14.py
425
3.5
4
def get_output_chain_len(startingNum): n = startingNum length = 0 while 1: length += 1 if n == 1: break if n % 2 == 0: n = n / 2 else: n = (3 * n) + 1 return length maxLen = 0 maxStartingNum = 0 for i in range(1, 1000000): print(i) currentLength = get_output_chain_len(i) if currentLen...
5253599aa98ef4900197ef5616ceb94936048fe2
K23Nikhil/PythonBasicToAdvance
/Program13.py
507
4.125
4
#Write a program that asks the user how many Fibonnaci numbers to generate and then generates them. # Take this opportunity to think about how you can use functions. startIndex = 0 endIndex = 10 FabSer = [] i = 1 if startIndex ==1: FabSer.append(startIndex) FabSer.append(startIndex) else: FabS...
7ac53f93a4cccea3bbb03fed6c767336a4d1c50e
K23Nikhil/PythonBasicToAdvance
/Program20.py
704
3.8125
4
def GetNumber(): inputNo = input("Please Enter a number which you want to search on List: ") inputNo = int(inputNo) return inputNo def SearchNoInList(): NumbersList = [1,4,5,34,23,51,90,45,87,66,54,38,97,18,76] print("Availbel List:",NumbersList) SearchNo = GetNumber() Numbers...
8929a0b3e7d0dcbf04f6bc907de9f9aece86c9d1
spoorthyandhe/project-98
/game.py
885
4.34375
4
import random print(" Number guessing game :") number = random.randint(1,9) chances = 0 print ("Guess a number (between 1 and 9): ") # while loop to count the umbers of changes while chances <5: guess = int(input("Enter your guess: ")) #compare the user enteres number with the number if gue...
aeddacf2a57fca2ccaa150804d40380e94b54233
braldanago/Ciencias3---Libros-y-parqueadero
/parqueadero.py
2,035
4.0625
4
# -*- coding: utf-8 -*- listado=[["123abc","20152020","1900"],["156abc","20152020","1900"], ["198abc","20152020","1600"],["014abc","20152020","1800"], ["258abc","20152020","1200"],["369abc","20152020","1000"]] class Cola: """ Representa una cola con operaciones de encolar, desencolar y ...
eee1e2c122921b6088129dd1c274707462f279f3
DhileasHeywood/adventure_game
/game.py
3,013
4.0625
4
import entry_room import tree_room_ import table_room import death import finished class Engine: # place_map MUST be a Map object, or the play function won't work. DO NOT FORGET THIS. def __init__(self, place_map): self.place_map = place_map # This function is what runs the game. Every time you ...
ef05347532b0eab4ddede67797e8a39725fefc07
Mfrakso/Week3
/FiberOptic If_Statements.py
1,895
4.4375
4
''' File: FiberOptic If_Statments.py Name: Mohammed A. Frakso Date: 14/12/2019 Course: DSC_510 - Introduction to Programming Desc: Programe calculates the need of fiber optic cable and evaluate a bulk discount for a user Usage : This program is built to take the 'Company Name' and 'required length(in feet)' of optic c...
0ba045195555c1d496930901a2af368d510cff72
hujiaodigua/Computer_Mathematics_Lesson
/exp0_count_triangle_area.py
1,326
3.84375
4
import math #此处三条边长由三点求得 a_x = float(input('输入a点的x坐标: ')) a_y = float(input('输入a点的y坐标: ')) b_x = float(input('输入b点的x坐标: ')) b_y = float(input('输入b点的y坐标: ')) c_x = float(input('输入c点的x坐标: ')) c_y = float(input('输入c点的y坐标: ')) #计算三条边长 ab = math.sqrt((a_x - b_x)*(a_x - b_x) + (a_y - b_y)*(a_y - b_y)) print...
a61ea93f140b2b5b8c28fe673ba4f9b2ad8793c5
EclipseJDk/stepik-autotests-course
/chapter2/less_2_2_1_dropdown.py
2,278
3.75
4
import time, os # webdriver это и есть набор команд для управления браузером from selenium import webdriver # инициализируем драйвер браузера. После этой команды вы должны увидеть новое открытое окно браузера driver = webdriver.Chrome() # команда time.sleep устанавливает паузу в 5 секунд, чтобы мы успели увидеть, чт...
c823c91169213237d5029dbda03a1650788574b0
Jacob-xyb/Python_Online_learning
/bilibili_fishc_python基础/003_文字游戏(break-if).py
311
3.9375
4
bingo = "小甲鱼是帅哥" answer = input("请输入小甲鱼最想听的一句话") while True: if answer == bingo: break answer = input("抱歉,错了,请重新输入(答案正确才能退出游戏):") print("哎呀,帅哦~") print("您真是小甲鱼肚子里的蛔虫啊^_^")
154b938583b64ce8b65c4c9c1e795bceb26f9b81
noegodinho/EC
/TTP/fitness.py
2,241
3.59375
4
def fitness(numCities, numItems, x, z, distanceMatrix, weightValueItems, availabilityItems, vMax, vMin, knapsackWeight, coefficient, dropRate): #If the first city in the tour is not 1, return 0 if x[0] != 1: return 0 times_item = [-1]*numItems Wc = 0 vc = 0 time_total = 0 items_not_in_city = 0 #Calculate ...
ea17d0d98e64c444106d0c018c8ac171a84c3b32
pangyang1/Python-OOP
/Python OOP/bike.py
794
4.15625
4
class Bike(): """docstring for Bike.""" def __init__(self,price,max_speed,miles): self.price = price self.max_speed =max_speed self.miles = 0 def displayinfo(self): print "The price is $" + str(self.price) + ". The max speed is " + str(self.max_speed) + ". The total miles are...
308e3d795d1af77514eb99e56fb819457d845b5b
femtokot/iterators
/iterator.py
705
3.671875
4
class RangeIterator: def __iter__(self): return self def __init__(self, start, stop, step): if step == 0: raise ValueError("Step should not be zero") self.start = start self.stop = stop self.step = step self.current = self.start def __next__(self...
e30e64ec2137ee9656dec931d3130db9c8d94b8a
IeuanOwen/Exercism
/Python/armstrong-numbers/armstrong_numbers.py
245
3.75
4
def is_armstrong_number(number): power = len(str(number)) numbers = [int(n) for n in str(number)] powered_nums = sum([num ** power for num in numbers]) if powered_nums == number: return True else: return False
b38b3a2082f4da3dc269982aab04ac935a5e96bd
IeuanOwen/Exercism
/Python/triangle/triangle.py
1,087
4.25
4
import itertools def valid_sides(sides): """This function validates the input list""" if any(side == 0 for side in sides): return False for x, y, z in itertools.combinations(sides, 3): if (x + y) < z or (y + z) < x or (z + x) < y: return False else: return True def...
9f865f967c9a164b95c49e5f84b17d5d0204c5f8
IeuanOwen/Exercism
/Python/prime-factors/prime_factors.py
428
4.1875
4
"""Return a list of all the prime factors of a number.""" def factors(startnum): prime_factors = [] factor = 2 # Begin with a Divisor of 2 while startnum > 1: if startnum % factor == 0: prime_factors.append(factor) startnum /= factor # divide the startnum by the factor ...
110a90581e675712325579c1fc32553e94b8b615
ZainKabir/rf_simulator
/gui/localize.py
959
3.59375
4
import numpy as np def solve(t1, t2): """ Substitute values in solutions of ellipse equations to localize users. For details on where these equations come from, go to notebooks folder and see `localizer.ipynb`. Parameters ---------- tof1: float TOF of receive antenna 1. tof2...
375e0bf125558618bb74238ec40264ce59ca9344
Jeevan-Palo/oops-python
/Polymorphism.py
1,050
4.5
4
# Polymorphism achieved through Overloading and Overriding # Overriding - Two methods with the same name but doing different tasks, one method overrides the other # It is achieved via Inheritance class Testing: def manual(self): print('Automation Tester with 5 years Experience') class ManualTest(Testing)...
d44257d11f6cc9635ed74d8d2d506ca082ea0bb9
NAVYSHUNTA/shunta.py
/math/prime/relatively.py
1,211
3.703125
4
import math import time class Sentence: def __init__(self, time_long, word): self.time_long = time_long self.word = word self.my_list = list(self.word) def sentence(self): for i in range(0, len(self.word) - 1): print(self.my_list[i], end = "", flush = True) ...
6a9d32182069c04f93a15329ef48df4affdcdd67
arjunjanamatti/ThinkStatsBook
/learn_async/1.py
530
3.578125
4
import asyncio import time def square_num(num): return num**2 async def count(num): print(f'Square of {num}: {square_num(num)}') await asyncio.sleep(0.00000001) print(f'Square of {num+5}: {square_num(num+5)}') async def main(num): await asyncio.gather(count(num), count(num), count(num)) if __n...
1c060a8320ecf2b9998bc1fdee4ea69eea10cc52
ahansen2014/VigenereCracker
/crackerUI.py
3,937
3.953125
4
from Tkinter import * from tkFileDialog import askopenfilename, asksaveasfilename from crackerFunctions import * def load_button_handler(): ''' This is a simple function to read the contents of a text file and display them in a text widget. :return: Nothing is returned. ''' try: file...
2aec2b0c22de1f9173ea40f9969445609d05eaa5
chenwenjie1011/Python_Self_Learning
/fibonacci.py
244
3.625
4
def fib(n): if n < 3: return 1 return fib(n - 1) + fib(n - 2) def fib2(n, count=3, prevPrev=1, prev=1): if n < 3: return n if count > n: return prev return fib2(n, count + 1, prev, prevPrev + prev)
f6f44a563bbcab01f70189c5dd76ead0c6fd4817
NAvkhimovich/nespython2018hw1
/AvkhimovichN_HomeAssignment1.py
2,380
3.703125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Sep 9 14:01:20 2018 @author: nik_avkhimovich """ import pandas as pd import numpy as np import matplotlib.pyplot as plt pd.set_option('max_columns', 50) %matplotlib inline %cd ~/Desktop/NES_MAEE2020/Modul 1/Data Analysis in Python/Home Assignment/Dat...
7278985deacc373fb86791ed56455ded1492b659
Ttttt47/Maze-solver
/Dfs/stk.py
504
3.515625
4
class Stk(object): def __init__(self): self.L = [] def push(self, a): # type: (object) -> object """ :rtype: object """ try: self.L.append(a) return True except: print("error in push") return...
cc50929915eae260da1160b515b30cbea4268108
MicheSi/Data-Structures
/binary_search_tree/sll_queue.py
2,213
4.1875
4
class Node: def __init__(self, value=None, next_node=None): # the value at this linked list node self.value = value # reference to the next node in the list self.next_node = next_node def get_value(self): return self.value def get_next(self): return self.next_node def set_next(self, n...
e2204a24201850e54bfb3c72d5bf6945bf1179eb
tyMarking/Algebra
/Algebra.py
617
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Nov 3 09:52:53 2017 @author: tymarking """ from .operator import Operator, Opps, Times, Plus, Minus, Divide, Power from constant import Constant def main(): equation = input("enter equation to solve: ") print("Your equation is " +str(equat...
0b50ad5a8c2cf1cd29029d8bf5381e21deec9d51
cayresb/python-poo
/ProjetoSQlite_BrunoCayres/database.py
3,104
4.03125
4
import sqlite3 class BancoDeDados: """Classe que representa o banco de dados (database) da aplicação""" def __init__(self, nome='banco.db'): self.nome, self.conexao = nome, None def conecta(self): """Conecta passando o nome do arquivo""" self.conexao = sqlite3.connect(self.nome) def desconecta...
78530424804e0f0cb964eb2ea98ec557981d9d9d
FabioZTessitore/learning_pygame
/projects/0003_falling.py
2,131
3.703125
4
# 0003_falling.py # Simulation of a falling body # # Frame # -1 < x < 1 # 0 < y < 10m # # Screen Size # Width 640 # Height 480 # # The ball start at rest at y = h meters # # Screen coordinates: # xs = 1/2 (x + 1) 640 = 320 * (x + 1) # ys = 480 (1 - y/10) # frames per second FPS = 30 # ball real position h = 7 x, y =...
cc43fe93c685054b06b7ef623a366f4730495413
FabioZTessitore/learning_pygame
/da_riordinare/0100_tetris/block.py
1,115
3.546875
4
import pygame from colors import BLACK class Block: def __init__(self, size=0): self.size = size def canMove(self, pos, delta, boardWidth, boardHeight): x, y = pos dx, dy = delta return (0 <= x+dx < boardWidth) and (0 <= y+dy < boardHeight) def draw(self, screen, pos, col...
ab0f814f2cdf52b1eddc652d9795024b11b19db3
r-arun/word
/trie.py
2,486
3.796875
4
import random class Node(): def __init__(self): self.dic={} self.value='' self.size=0 class Trie(): def __init__(self): self.root=Node() def recursiveInsert(self,node,value,final): if(value==''): node.value=final return car=value[0] cdr=value[1:] if(not node.dic.has_key(car)): node.dic[car]...
7021c790cc1d8187d8bef2a70fd6bbf0f2b73f00
r-arun/word
/spaceStrip.py
670
3.640625
4
def strip(word): small=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] big=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','(','"',"'"] alpha=small alpha.extend(big) ind=0 while ind<(len(word)): if...
4cb91386eedb100af7f4d311d673bdb9b0e7bcca
xiaoxue11/interview
/03_deal_with_data/03_copy_deep.py
1,829
3.75
4
import copy def copy_attr(s): s1 = copy.copy(s) s2 = copy.deepcopy(s) return s1, s2 # immutable data type # int a = 3 b = 3 c, d = copy_attr(a) print(a is b) print(a is c) print(a is d) print('*' * 20 + 'int') # str a = 'python' b = 'python' c, d = copy_attr(a) print(a is b) print(a is c) print(a is d) ...
6765bab5b2ea8989921918f51346f76aa2986eab
his1devil/lintcode-note
/lastpositionoftarget.py
650
3.9375
4
#! /usr/bin/env python # -*- coding: utf-8 -*- class Solution(object): """ Find the last position of a target number in a sorted array """ def lastPosition(self, A, target): if A is None or len(A) == 0: return -1 start, end = 0, len(A) - 1 while start+1 < end: ...
572e08a21a64a898d60e2bd26bec4f350da44d65
his1devil/lintcode-note
/flattenlist.py
449
4.1875
4
#! /usr/bin/env python # -*- coding: utf-8 -*- class Solution(object): """ Given a list, each element in the list can be a list or integer. Flatten it into a simply list with integers. 递归 """ def flatten(self, nestedList): result = [] if isinstance(nestedList, int): ...
cd54caff7a61f615fd855cc9a012871652fb4c2a
his1devil/lintcode-note
/rotatestring.py
1,055
4.25
4
#! /usr/bin/env python # -*- coding: utf-8 -*- class Solution(object): """ Given a string and an offset, rotate string by offset. (rotate from left to right) offset=2 => "fgabcde" """ def rotateString(self, s, offset): # 防止offset越界,offset 对len(s)取模 if s is None or len(s) == 0: ...
980e81dc08450774f5cfcb0d0ed43672a8eb9d74
ruby923923/Sinica-Biological-Python-Homework
/HW07/grade_dict.py
1,387
3.765625
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: import numpy as np database = {} print("input name and grade. Terminated when name is'OK'") while 1: name = input('Enter name:') if name == 'OK': break elif name in database: print('Already in database') else: grade = float(inp...
16874395898119b59fbbe01b936fe19609658ce3
4161726f6e/chatbot
/chatbot.py
3,253
3.765625
4
import nltk import numpy as np import random import string # to process standard python strings import sys import warnings if not sys.warnoptions: warnings.simplefilter("ignore") f=open('chatbot.txt','r',errors = 'ignore') raw=f.read() raw=raw.lower()# converts to lowercase nltk.download('punkt', quiet=True) # fi...
aebfd3d94d4972d2b7341d3bddcc192c3c6b582b
ridwanur18/Projects
/CarbonFootprintCalculator/footprint_services.py
2,849
3.5625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Oct 1 02:22:14 2019 @author: ridwanur18 """ # COMP 202 A1: Part 2 # Footprint of utilities & university # Author: Ridwanur Rahman # ID: 260828139 import doctest from unit_conversion import * INCOMPLETE = -1 #########################################...
b8bd8d0046e1b6babbfe444bc9a8b041336cb7d2
ridwanur18/Projects
/BrailleTranslator/Archive/to_unicode.py
4,894
3.875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Oct 13 20:29:53 2019 @author: ridwanur18 """ # COMP 202 Assignment 2 Part 3 # Author: Ridwanur Rahman # Student ID: 260828139 import doctest INCOMPLETE = -1 def ostring_to_raisedpos(s): ''' (str) -> str Convert a braille letter represented b...
87b523062a3cd348da4cf2c4413158d67cc17469
zxl1987/ISTE432Project
/Project/Model/handleException.py
1,639
3.75
4
class handleException: option=1 userinput='' def __init__(self, option, userInput): self.option = option self.userInput = userInput self.inputError def inputError(self): ## Handle error if user enter city name if self.option == 1: if ',' in self.use...
46c458e68b184f07b9b7bf207d86e23744bda42f
amirmirzaeimoghadam/PYTHON
/Ex5/069.py
169
3.984375
4
countries = ("IRAN","USA","CHINE","RUSSIA","GERMANY") print(countries) country = input("plz enter your name country from countries") print(countries.index(country))
b8e321250df27a38a1d2a429d572155f92b5bde6
amirmirzaeimoghadam/PYTHON
/Ex5/074.py
350
3.6875
4
list_colour = ['zard','nili','meshki','sefid','narenji','banafsh','keremi','ghermez','sabz','abi'] one_num = int(input("lotfan yek adad bein 0 ta 4 vared kon")) two_num = int(input("lotfan yekadad bein 5 ta 9 vard konid")) list_colour2 = [] for i in range(one_num , two_num+1): list_colour2.append(list_colour[i...
3eaa45155d8f2a96a032b3c19262d386869119aa
amirmirzaeimoghadam/PYTHON
/Ex4/018.py
157
4.03125
4
Num = int(input('Please enter a number: ')) if Num < 10: print('Too low') elif 10 <= Num <= 20: print('Correct') else: print('Too high')
a46bbd4c198f73913e02a0cbb88d56fe9b5f7a1e
guimafelipe/whiteflag
/whiteFlag.py
2,389
3.828125
4
import pygame class WhiteFlag: """Create a WhiteFlag, the game's main character""" epsilon = 10 pos = { 'x':0, 'y':0 } def __init__(self, coordinates): """Define the main features of the character""" self.size = 50 self.hp = 100 ...
f4f0f3af9ba4c903c64dbaae7e15c32508c6b0ab
Jordan-Chapman/ConwaysGame
/OLD/conway.py
4,092
3.703125
4
# A python example of conways game of life. # Note that in board reading, the y coordinate goes before the x coordinate. # This is caused by the way indexing works when arrays are inside arrays. import random import pygame import time class Game(object): Sleep = True sleeptime = 0.1 sizex = 400 # Width ...
3c59bbf2fc9fb731fb7ea374879127d7fe9ebfea
PulsatingGenius/extracting-primes-between-given-range-
/main.py
366
3.5625
4
import numpy as np import math def get_primes(n_min, n_max): result = [] for x in range (max(n_min,2),n_max): has_factor = False for p in range(2, int(np.sqrt(x))+1): if x % p ==0: has_factor = True break if not has_factor: result...
b61263e17e5bc1af8a5da9be6fc867a1138aa7ea
FFFutureflo/CodingChallenges
/codeforces/800/Watermelon800.py
356
3.953125
4
""" https://codeforces.com/problemset/problem/4/A """ def function(n): answer = "" if(n % 2 == 0 and n > 2): answer = "YES" else: answer = "NO" print(answer) return answer if __name__ == "__main__": n = int(input()) function(n) """ Read n as an Int input If n % 2 == 0 ...
fab291ecbc2d7dffb7bb6ada1e135ebba14050fc
FFFutureflo/CodingChallenges
/codeforces/600+700/600LoveAs.py
493
3.890625
4
import sys """ https://codeforces.com/problemset/problem/867/A """ if __name__ == "__main__": string = input() length = len(string) numberAs = string.count("a") if(numberAs > (length/2)): print(str(length)) else: print(str(numberAs*2-1)) """ Lies einen String ein Hol dir die L...
a87203e97def98d91c14c64550d1a3f69cf0c9cd
FFFutureflo/CodingChallenges
/codeforces/600+700/700Presents.py
540
3.671875
4
import sys """ https://codeforces.com/problemset/problem/136/A """ if __name__ == "__main__": n = int(input()) x = input().split() x = list(map(int, x)) answer = "" for i in range(1, (n+1)): answer = answer + str((x.index(i) + 1)) if i < n: answer = answer + " " ...
eed83a0ce634bab6cbc71c90ba5a689dd960e2ba
FFFutureflo/CodingChallenges
/codeforces/600+700/700FrogJumping.py
806
3.578125
4
import sys """ https://codeforces.com/problemset/problem/1077/A """ if __name__ == "__main__": i = int(input()) main_list = [] while(i > 0): n = input().split() n = list(map(int, n)) main_list.append(n) i = i-1 for x in main_list: k_half = x[2]//2 a =...
3f43368d674bd6dd77f0f18afe4a3e9f886a2aa5
moon-hotel/MachineLearningWithMe
/AllBooKCode/Chapter04/16_regularized_regression.py
2,891
3.53125
4
import numpy as np import matplotlib.pyplot as plt np.random.seed(1) def make_data(): n_train, n_test, n_features = 50, 100, 100 w, b = np.ones((n_features, 1)) * 0.2, 2 np.random.seed(1) x = np.random.normal(size=(n_train + n_test, n_features)) y = np.matmul(x, w) + b y += np.random.normal(s...
6e3dafc8373e742cbf88375f6402555176919120
moon-hotel/MachineLearningWithMe
/AllBooKCode/Chapter08/C24_example_gradient_boost_cla.py
1,653
3.515625
4
""" 文件名: AllBooKCode/Chapter08/C24_example_gradient_boost_cla.py 创建时间: 2022/11/6 8:47 上午 星期日 作 者: @空字符 公众号: @月来客栈 知 乎: @月来客栈 https://www.zhihu.com/people/the_lastest """ from C22_manual_gradient_boost_cla import negative_gradient from C22_manual_gradient_boost_cla import objective_function import numpy as np def exa...
4246b515a5fad530731da1f250a4200bdfca943f
moon-hotel/MachineLearningWithMe
/Archived/01_LinearRegression/402_init_weight.py
624
3.625
4
from matplotlib import pyplot as plt import numpy as np from mpl_toolkits.mplot3d import Axes3D def plot_surface(): fig = plt.figure() ax = Axes3D(fig) X = np.arange(-4, 4, 0.25) Y = np.arange(-4, 4, 0.25) X, Y = np.meshgrid(X, Y) Z = X ** 2 + Y ** 2+2*Y + 5 ax.plot_surface(X, Y, Z, rstri...
5f8236af9d39523ce57c8a85602ceb7d07e98adc
moon-hotel/MachineLearningWithMe
/Archived/01_LinearRegression/201_train.py
576
3.609375
4
from sklearn.datasets import load_boston from sklearn.linear_model import LinearRegression def load_data(): data = load_boston() x = data.data y = data.target return x, y def train(x, y): print('X的形状:',x.shape) model = LinearRegression() model.fit(x,y) print("权重为:",model.coef_) p...
a8d0f6d714efec5d435f2c009c2dbc3a08026144
MelancholyMing/TF_learning
/testfile/t6.py
247
3.671875
4
import argparse parser = argparse.ArgumentParser(description='姓名') parser.add_argument('param1', type=str,help='名') parser.add_argument('param2', type=str,help='姓') args = parser.parse_args() #打印姓名 print(args.param1+args.param2)
8528c7da0416c33c881ec5016ba7eb08f0f5a593
Hwang-Junsu/py-study
/contine,break.py
303
3.6875
4
absent = [2,5] # 결석 no_book = [7] #책을 깜빡했음 for student in range (1,11): #1,2,3,4,5,6,7,8,9,10 if student in absent: continue elif student in no_book: print(f"오늘 수업 여기까지. {no_book}는 교무실로 따라와.") break print(f"{student}, 책을 읽어봐.")
1da1ee2c0da343dc2581dccec2c06e91cd0f9c0a
Andzo/mypackage
/tests/test.py
1,555
3.671875
4
from mypackage import recursion from mypackage import sorting def test_sum_array(): """ making sure sum_array works correctly """ assert recursion.sum_array([1,2,3,4]) == 10, 'incorrect' assert recursion.sum_array([4,-2,0,2.5]) == 4.5, 'incorrect' assert recursion.sum_array([0,0]) == 0, 'incorr...
050dfcca80d8483d2d27a3e62da9ebb665c9b959
cxbrooks/wiki-power-plant-production-table
/wiki-power-plant-production-table.py
6,670
3.5
4
#!/opt/local/bin/python3 """ wiki-power-plant-production-table.py Generate a Wikipedia table of electrical production data for a power plant. """ import datetime import requests from io import StringIO S = requests.Session() URL = "http://api.eia.gov/series/" ''' Return the Electrical Information Admi...
085d5c24334cf9577b6d8aff540a4b592e18773e
gamentionkray/Python-Basic-Coding
/TOH.py
623
3.765625
4
n = int(input("Enter number of discs: ")) source = list(reversed(range(1, n+1))) dest = [] support = [] counter = 0 def towerOfHanoi(n, source, dest, support): global counter if n > 0: towerOfHanoi(n - 1, source, support, dest) print(("Initial condition = " if counter == 0 else "Step " + ...
35357f2e604583badc145538b5f93e101d07d2f4
MasonJoran/U3L14
/RPS.py
3,985
4.0625
4
import time import random print('-'*65) print() print('I am Game-Bot! ') print('You will be playing Rock, Paper, Scissors against me today! I hope you are ready.') print() print() playing = True while playing: print() print('I am Game-Bot! ') print('You will be playing Rock, Paper, Scissors against me today! I ...
662776976e6212e04c4b6eabbcb512b4c2b9496f
vinnycassio/Estudos
/Desafio028.py
325
3.65625
4
import random n1 = int(0) n2 = int(1) n3 = int(2) n4 = int(3) n5 = int(4) n6 = int(5) lista = [n1,n2,n3,n4,n5] n = random.choice(lista) n0 = int(input('Qual número o computador escolheu?')) if n0 == n: print('Você acertou, PARABÉNS!') else: print("Você perdeu, o número escolhido foi {}!".format(n))
7dc88d851fcfe4fb20ffe9ccdd6505fe7be35a0e
vinnycassio/Estudos
/Desafio024.py
161
3.84375
4
#verifica se a cidade incia com santo independente da forma escrita cid = str(input('Qual cidade você nasceu?')).strip() print(cid[:5].upper() == 'SANTO')
f034bd3a6feb05562a0682fe8805194d3034d759
vinnycassio/Estudos
/Desafio010.py
216
3.78125
4
n1 = str(input('Qual o seu nome?')) v1 = float(input('Qual valor em reais você tem em sua carteira?')) d = float(3.27) d1 = float (v1/d) print('Olá{} tudo bem? Você tem ${:.2f} Dolares!'.format(n1,d1))
6c78661c73b2892e248eff64a7395e6b1e84359b
paulmagnus/CSPy
/mjenkins-programs/windchill.py
447
4.3125
4
def windChill(): print 'Welcome to the windchill calculator!' temperature = input("Enter the temperature: ") windspeed = input("Enter the wind speed: ") windchill = 35.74 + (0.6215 * temperature) - (35.75 * (windspeed ** 0.16)) + (0.4275 * temperature * (windspeed ** 0.16)) print 'At ' + str(temperature) + ' degre...
0fe97f69f2cdcf55d793c7c6a6a52d30450c693e
paulmagnus/CSPy
/Games-2017/34/Game.py
23,200
4.09375
4
""" ******************************************************************************* File: Game.py Author: Sarah Keefe Partner: Assignment: Project 6 Date: 4/30/17 Description: This file ...
4ed0a9d946371764afc750adb35e65e9bbe51a14
paulmagnus/CSPy
/Games-2017/18/Game.py
34,521
3.578125
4
""" ******************************************************************************* *File: Game.py * * * *Author: Haley Taft ...
2038ec7b29465f506331c5934e6317442a282045
paulmagnus/CSPy
/Games-2017/8/Game.py
33,027
3.984375
4
""" **************************************************************************** FILE: Game.py AUTHOR: Chengqi Guo PARTNER: None ASSIGNMENT: Project 6 DATE: 04/06/2017 DESCRIPTION: Scrabble. The followings are what makes it different from a real game: It checks for words added, but only following the rules below...
fd8809831149570c0750c8d612f2bd99c0d31479
katyduncan/pythonintro
/lesson2/8IntegersFloats.py
409
4.1875
4
# Check data type print(type(3)) print(type(4.3)) # whole number float print(type(4.)) # operation involving int and float always results in float print(3 + 2.5) # cut decimal off float to convert to int print(int(49.7)) # 49 no rounding occurs # add .0 to convert int to float print( float(3520 + 3239)) # 6759.0 #...