blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
c4a64c953dcc1979c102d9996ef98b24821d5488
jiapei100/Stereo
/micropython/tests/basics/class_super_object.py
289
3.90625
4
# Calling object.__init__() via super().__init__ class Test(object): def __init__(self): super().__init__() print("Test.__init__") t = Test() class Test2: def __init__(self): super().__init__() print("Test2.__init__") t = Test2()
70db772eeb168177ab7835a193d8d623781f282b
jiapei100/Stereo
/micropython/tests/basics/try_finally_return.py
356
3.515625
4
def func1(): try: return "it worked" finally: print("finally 1") print(func1()) def func2(): try: return "it worked" finally: print("finally 2") def func3(): try: s = func2() return s + ", did this work?" finally: pr...
e38a524cae260824f2516cc5454079cc50c9bb4a
jiapei100/Stereo
/micropython/tests/bytecode/mp-tests/listcomp5.py
334
3.5625
4
# nested ifs x = [a for a in l if a if a + 1] x = [a for a in l if a if a + 1 if a + 2] # nested for loops x = [a for a in l for l in ls] x = [a for ls in lss for l in ls for a in l] x = [a for a in l for l in ls for ls in lss] # nested ifs and for loops x = [a for a in l if a for l in ls if l if a for ls i...
d1de7a3aa42986317c9f492f478775d6a5903c4b
jiapei100/Stereo
/micropython/tests/basics/string_compare.py
846
3.6875
4
print("" == "") print("" > "") print("" < "") print("" == "1") print("1" == "") print("" > "1") print("1" > "") print("" < "1") print("1" < "") print("" >= "1") print("1" >= "") print("" <= "1") print("1" <= "") print("1" == "1") print("1" != "1") print("1" == "2") print("1" == "10") print("1" > "1...
8cd6975d227ac6d7979e0864f6851adbb124d514
jiapei100/Stereo
/micropython/tests/io/file_with.py
459
3.546875
4
f = open("io/data/file1") with f as f2: print(f2.read()) # File should be closed try: f.read() except: # Note: CPython and us throw different exception trying to read from # close file. print("can't read file after with") # Regression test: test that exception in with initializatio...
ee735d24745e9ee8a313b6f10ef303b528f9f4b0
Razgrizaces/lcode-euler
/cassidoo/patternMatch.py
1,133
3.984375
4
#**Write a function where given a pattern string like "ABCCA" and an input string like "redyellowbluebluered", return true if and only if there's a one to one mapping of letters in the pattern to substrings of the input.** # > patternMatch('ABA', 'keyboardkey') # true # > patternMatch('AA', 'fishyfish') # ...
2f20f1199ce4beb30f6d3258b63a8e433f564d6b
Razgrizaces/lcode-euler
/lcode/4.py
945
4.125
4
#median of two sorted arrays #merge sort algo def mergeSort(m): if len(m) <= 1: return m left = [] right = [] i = 0 for x in m: if i < (len(m)/2): left.append(x) else: right.append(x) i = i+1 left = mergeSort(left) right = mergeSort(right) return merge(left,right) def merge(left, right): res...
9e2a5a0aa6faa48e399b5e6c0d921aa814295c5a
AdityaWadichar/IvLabs
/Python/Autograder_Exercise_4(6).py
262
3.78125
4
#Autograder Exercise 4.6 def computepay(h,r): hh=float(h) rr=float(r) if hh<=40: pay=hh*rr else: pay=(40*rr)+(hh-40)*rr*1.5 return pay hrs = input("Enter Hours:") rate = input("Enter rate:") p = computepay(hrs,rate) print(p)
f8bf28062ea9a8df7e90a1384d8ece44ffac9314
amisha1garg/Strings_in_python
/Anagram.py
1,487
4.1875
4
# Given two strings a and b consisting of lowercase characters. The task is to check whether two given strings are an anagram of each other or not. An anagram of a string is another string that contains the same characters, only the order of characters can be different. For example, “act” and “tac” are an anagram of ea...
1cafa2dda3dccd0f5f057e87a0a638f1b3d18372
amisha1garg/Strings_in_python
/RemoveSpaces.py
582
4.28125
4
# Given a string, remove spaces from it. # # Example 1: # # Input: # S = "geeks for geeks" # Output: geeksforgeeks # Explanation: All the spaces have been # removed. # User function Template for python3 class Solution: def modify(self, s): # code here return s.replace(' ', '') ...
492b9e530cdd89abc5f57a0f4c285ae3155fb3b1
amisha1garg/Strings_in_python
/ParenthesisChecker.py
1,883
3.71875
4
# Given an expression string x. Examine whether the pairs and the orders of “{“,”}”,”(“,”)”,”[“,”]” are correct in exp. # For example, the function should return 'true' for exp = “[()]{}{[()()]()}” and 'false' for exp = “[(])”. # # Example 1: # # Input: # {([])} # Output: # true # Explanation: # { ( [ ] ) }. ...
8e9247d7f0f7ddd2e5261e289f43cc6f0a442b0e
amisha1garg/Strings_in_python
/longestSubstringContaining'1'.py
1,110
3.921875
4
# Given a function that takes a binary string. The task is to return the longest size of contiguous substring containing only ‘1’. # # Input: # The first line of input contains an integer T denoting the no of test cases.Then T test cases follow. Each test case contains a string S. # # Output: # For each test case...
65e1439889a3e43ac72fd0ae936401a0254a7e4e
amisha1garg/Strings_in_python
/ReversingTheVowels.py
1,010
4.15625
4
# Given a string consisting of lowercase english alphabets, reverse only the vowels present in it and print the resulting string. # # Example 1: # # Input: # S = "geeksforgeeks" # Output: geeksforgeeks # Explanation: The vowels are: e, e, o, e, e # Reverse of these is also e, e, o, e, e. #User function Templ...
2e9b6389eb728b55e9a1c11ecebf30de726dd66e
henriquedeziderio/dns-registering
/DNS-register.py
2,843
4.3125
4
# Back-end code - DNS simple subset # Developer: Henrique da Silva Deziderio # This program records a DNS name in a list that acknowledge A, AAAA, CNAME and TXT and add the new register in the list. # It can delete a DNS already registered, except the originals, and check all DNS registered # Opening file and creating...
59b46ea671147b71c53992b69b5e6adf3fd94329
gaojianshuai/vpc-ui
/pycharm_practice/Python_Object/python_object_01.py
713
3.796875
4
#coding=utf-8 class Turtle: #Python中的类名约定以大写字母开头 #特征的描述称为属性,在代码层面来看其实就是变量 color = 'green' weight = 10 legs = 4 shell = True mouth = '大嘴' #方法实际就是函数,通过调用这些函数来完成基本某些动作 def climb(self): print("我正在努力的向前爬") def run(self): print("我正在飞快的向前跑") def bite(self): ...
fde9f0cb0f301ddd0593896d608ba0cffd085695
gaojianshuai/vpc-ui
/pycharm_practice/pycharm_practice_random/pycharm_practice_random1.py
724
3.65625
4
#coding=utf-8 """ 功能:模拟掷色子 作者:高建帅 日期:07/04/2019 版本:1.0 新增功能:获取每个元素胡索引和value """ import random def roll_dice(): """ 模拟掷色子 """ roll = random.randint(1, 6) return roll def main(): total_times = 100 #初始化列表 [0, 0, 0, 0, 0, 0,] result_list = [0] * 6 for i in range(tot...
79da49f774fcf6080a08ed132f4310a1b70bf4ed
gaojianshuai/vpc-ui
/pycharm_practice/pycharm_practice_passwd/pycharm_practice_passwd6.py
3,027
3.5
4
#coding=utf-8 """ 功能:判断密码强弱 作者:高建帅 日期:07/04/2019 版本:6.0 新增功能:限制密码次数,循环终止break:跳出整个循环 continue:跳出本次循环,执行下一次循环 新增功能:保存密码到文件中(操作文件(打开,读写,关闭)) 新增功能:读取文件 新增功能:将相关方法封装成一个整体(面向对象编程OOP)定义一个passwd工具类 新增功能:定义一个文件操作工具类 """ class PasswdTool: """ 密码工具类 """ def __init__(self, ...
309cb5d346cde75bebca3b4eed1c25c2781fac86
ranjithkumar97/Validation
/tasks6.py
730
4.03125
4
class station: def __init__(self, station_id, station_name): self.station_id=station_id self.station_name=station_name def setstation_id(self, station_id): self.station_id=station_id def getstation_id(self): return self.station_id def setstation_name(self, station_name)...
bfa670f09f772dd231f70d1d07280773693092e6
StefenYin/BicycleThesis
/constraint/geometry.py
1,545
3.71875
4
""" Geometry description of steady turning: 1, turning radius of two wheels: Rr, Rf; (in model.py) 2, relative position of front wheel contact point fn to rear wheel dn: fn_dn_x, fn_dn_y; (in model.py) 3, the position of total mass center, tmc, of the bicycle relative to dn: tmc_dn_x, tmc_dn_y, Rc(turning radius ...
efc00a46399cf69bc3805294f1bf935961f53483
ROMEOXU/driving
/driving.py
252
4.03125
4
ask = input('are you driving? ') speed = input('what is your speed? ') speed = int(speed) if ask == 'yes': if speed >= 55: print('drive safe') else: print('hurry up') elif ask == 'no': print('just drive') else: print('only tell me yes or no')
3635eea64f1509bf04495b9063fe58da9d34c5d6
kikniknik/information-retrieval
/src/boolean_expression_parse.py
1,761
3.65625
4
# -*- coding: utf-8 -*- from pyparsing import infixNotation, opAssoc, Word, alphanums class BooleanExpressionParser: """ Boolean expression parser """ def __init__(self, evalfn, NOTevalfunc): """ :param evalfn: Function that will be called with argument a boolean operand for each boo...
d7bb3f4e1fbef4208ec8ca90972b5f67552c2278
rester71/ArbolBinario
/binario.py
1,794
3.921875
4
#Implementacion de un algoritmo de ordenamiento Arbol binario #Se necesita una clase nodo, para actual como una estructura class Nodo(object): def __init__(self,valor): self.izquierdo = None self.valor = valor self.derecho = None class arbolBinario(object): #Simple variable donde se al...
12cd4ec0dbabcde575f35cf4ee22e2918867ffeb
OvaizAli/Dynamic-Programming-Algorithms-
/Web/main.py
9,517
3.546875
4
import eel # E:/5th Semester/Fall 2020/ALGO/Sir Zeshan/Dynamic-Programming-Algorithms-/Web eel.init('E:/5th Semester/Fall 2020/ALGO/Sir Zeshan/Dynamic-Programming-Algorithms-/Web') # eel.init('C:/Users/Zaeem Ahmed/Desktop/algo project/Dynamic-Programming-Algorithms-/Web') @eel.expose def showInput(inputFile): f = ...
3cd777c25d13922a923fd26f38b32c8881c69ddf
navya-dev/credit-card-validator
/valid_card_checker.py
575
3.609375
4
import re PATTERN=r"^(?!.*([0-9])(?:-?\1){3})[456][0-9]{3}(-?)[0-9]{4}\2[0-9]{4}\2[0-9]{4}$" def is_valid_card(sequence): if re.search(PATTERN, sequence): print('Valid') return 'Valid' else: print('Invalid') return 'Invalid' if _name_ == '_main_': cards = ['4123456789123...
05b49d50493fe306f5d5cb9414103f021141c967
santosh507/My-CodeBase
/DecoratorTest.py
863
3.8125
4
''' Created on May 14, 2018 @author: hegdes ''' def wrapper(f): list = [] def fun(l): # complete the function # complete the function for number in l: if len(number) == 10: list.append('+91 '+number[0:5]+' '+number[5:]) elif num...
c60e6a3310fc024326808cdee23aed53118b39d1
Ride-sharing-CS-581/Project
/source_code/temp.py
1,122
4.03125
4
import pandas as pd def select_Rides_pool(): """selects all the rides in pool Pool starting time is the first ride which is is in the list Input : pool start time Output : Rides that are in the pool""" data = pd.read_csv('temp.csv') #Lenght of the pool window pool_time = 5 #datafra...
9728bbb2903b0007ed6be61f8b3b9bbd21b32edb
5703863336/python
/python/插入排序.py
564
3.65625
4
#插入排序 def inser_sort(alist): for i in range(1,len(alist)): for j in range(i,0,-1): if alist[j]<alist[j-1]: alist[j],alist[j-1] = alist[j-1],alist[j] #二分查找 def erfen(alist,item): if not alist: return False n = len(alist) mid = n // 2 if alist[mid] ==item: ...
e3c42f9f86f34ac28a9b833688266b0b3d06e74c
hudsonjoe/codebin
/repeating a tast.py
217
3.796875
4
r=1 print("welcome") print("you got to choose a option") while(r!=0): b=input("1.college,2.vacation,q.to quit") if (b!='q'): r=1 else: print("end") break
9100919084a84c2cabd5268e2dfd0b03d75e2813
gksmfthskan/Python
/Day_9-22(1).py
224
3.65625
4
import turtle pen = turtle.Pen() def 직사각형(X, Y): for _ in range(2): pen.fd(X) pen.left(90) pen.fd(Y) pen.left(90) 직사각형(300, 200) 직사각형(100,100) turtle.mainloop()
0f9a97217d12d1e10b153982e214045708bd7cdd
gksmfthskan/Python
/ch2_example3.py
187
3.8125
4
import turtle X = turtle.Turtle() X.pensize(3) n = int(turtle.numinput("", "숫자를 입력하시오:")) i = 0 for i in range(n): X.forward(70) X.left(360/n) turtle.mainloop()
58f1511cce83282cd9f9de1ac096e5f29d4e6a67
Beatalux/Python-Study
/Web_Scrapping/save.py
311
3.578125
4
import csv #place, title,time,pay,date def save_to_file(jobs,c): file=open(f"{c}.csv",mode="w") writer=csv.writer(file) writer.writerow(["place","title","time","pay","date"]) if jobs==None: writer.writerow(["No info"]) return for job in jobs: writer.writerow(list(job.values())) return
faf4759997585f649b3b27a4da8a9d4ba0a1d960
ArnoldTingSu/python
/_python/python_fundamentals/hello_world.py
747
4.34375
4
# 1. TASK print "Hello World" print("Hello World") # 2a. Store your name in a variable, use it to print the string: "Hello {{your name}}" name = "Arnold" print("Hello",name) #with a comma print("Hello " + name) #with a + # 3. Store your favorite number in a variable, and then use it to print the string “Hello {{num}}!...
dd86867159a5fda5cf628f1b279be496f02d32a3
unaizaansari7/Assigment-1-2-3
/Assignment 2/find occurances of all character in a string.py
354
3.90625
4
str1 = "Astrology" all_char = {} for i in str1: if i in all_char: all_char[i] += 1 else: all_char[i] = 1 print ("Count of all characters in Astrology is :\n " + str(all_char)) a = str1.find("o") print(a) a = str1.f...
94d3cc2cd76f367ea854d519e0a0cf1ad6d54a18
supassxu/pythonfile
/test_oo/myoo_04.py
696
3.75
4
from copy import deepcopy, copy class Man: def eat(self): print('饿了,吃饭了!') class Chinese(Man): def eat(self): print('使用筷子吃饭!') class English(Man): def eat(self): print('使用刀叉吃饭!') class Indian(Man): def eat(self): print('使用手吃饭!') c = Chinese() c1 = copy(c) print(id(c...
79ad53ee0ceea5e83a3f6f0eae71ff16b5931ecb
supassxu/pythonfile
/gui/mypygui_06.py
1,404
3.640625
4
# encoding=utf-8 """ 一个经典的GUI程序 """ from tkinter import * from tkinter import messagebox class Application(Frame): """一个经典的GUI程序的类的写法""" def __init__(self, master=None): super().__init__(master) # 调用父类构造对象 self.master = master self.pack() self.createWidget() def createWi...
38a2578129da9ee2ccfb96772a13cfe790c07048
supassxu/pythonfile
/test/testturtle1.py
375
3.640625
4
import math import turtle x1, y1 = 100, 100 x2, y2 = 100, -100 x3, y3 = -100, -100 x4, y4 = -100, 100 # 绘制折线 turtle.penup() turtle.goto(x1, y1) turtle.pendown() turtle.goto(x2, y2) turtle.goto(x3, y3) turtle.goto(x4, y4) # 计算起始点和终点的距离 distance = math.sqrt((x1 - x4) ** 2 + (y1 - y4) ** 2) turtle.write(distance) print...
3c58fcdd65037722496dc44335e7621ceddfc5d4
supassxu/pythonfile
/test_oo/myoo_03.py
974
3.984375
4
import copy #继承 class Person: def __init__(self,name,age): self.name = name self.age = age def say_name(self): print('I hive know idea about my name!:{0}'.format(self.name)) def say_age(self): print('How old are you!:{0}'.format(self.age)) class Student(Person): def ...
ad2600898abe222aae7c78418faf9b4713ec7d8a
asafzimp/zi18n
/AppleStringFileCounter/main.py
3,018
4.1875
4
__author__ = 'Asaf Peleg' # encoding=utf8 import argparse import sys # Logic: # Run the script with the name of the .strings file as the argument. It will look at all strings that are NOT # enclosed in /* or */ and then count the words, and output them to the screen. reload(sys) sys.setdefaultencoding('utf8') de...
f274b73dd3159bc761af11b7e5d95c48e5566dec
Gleider/banco-bit-ufpel
/servidor/cadastro.py
1,313
3.8125
4
import clientes def menuPrincipal(): while True: print('\n') titulo = 'Banco bitUfpel' print("=" * len(titulo), titulo, "=" * len(titulo), sep="\n") print("[1] - Criar Banco de Dados (caso não exista)\n[2] - Cadastrar Nova Conta\n[3] - Logar\n[4] - Sair") op = input("Opção: ...
72503a35f2d7449c7c357dad75da80c293f75a83
taroserigano/The-Modern-Python-3-Bootcamp-1
/S08 Boolean and Conditional Logic/ex12.py
1,743
3.953125
4
# NO TOUCHING ====================================== from random import choice, randint # randomly assigns values to these four variables actually_sick = choice([True, False]) kinda_sick = choice([True, False]) hate_your_job = choice([True, False]) sick_days = randint(0, 10) # NO TOUCHING ===========================...
27e7828eda80647001730ba39490bfc56f14abb1
zym0101/zym0101.github.io
/Python/005-3D_love/love.py
1,682
3.625
4
import matplotlib.pyplot as plt import numpy as np def heart_3d(x, y, z): return (x**2 + (9 / 4) * y**2 + z**2 - 1)**3 - x**2 * z**3 - (9 / 80) * y**2 * z**3 def plot_implicit(fn, bbox=(-1.5, 1.5)): ''' create a plot of an implicit function fn ...implicit function (plot where fn==...
a69e4fa471e7889b6e30dd8cd3c5bc8d77f70cfa
TopShares/Python
/Algorithm/test.py
83
3.75
4
def sum(lists): t = 0 for i in lists: t += i return t print(sum([1,2,5,2,3]))
4b988589a32ea55bdc791048768cd38e3dfcbafe
asadugalib/URI-Solution
/Python3/uri 1131.py
674
3.703125
4
#1131 num_game = 0 inter = 0 gremio = 0 draw = 0 new_game = True while new_game: num_game += 1 x, y = list(map(int, input().split())) if x > y: inter += 1 elif x < y: gremio += 1 else: draw += 1 while True: print("Novo grenal (1-sim 2-nao)") d = i...
6da42b6449450a3e22f4a09670437642c60e3d12
asadugalib/URI-Solution
/Python3/uri 1064.py
269
3.765625
4
#1064 number= [] pos=0 s=0 for i in range(6): number.append(float(input())) for i in range(len(number)): test = 0+number[i] if test > 0: pos+=1 s+= number[i] test = 0 avg = s/pos print("{} valores positivos\n{:.1f}".format(pos,avg))
572d7e7ed4152897cf292cc5b979b468dcda3573
asadugalib/URI-Solution
/Python3/uri 1021.py
738
3.78125
4
#1021 def money(total,note): num_notes = int(total / note) return num_notes N = eval(input()) total=float("%0.2f"%N) if total>= 0 or total <= 10000000.00: notes = [100, 50, 20, 10, 5, 2] coins = [1.00, 0.50, 0.25, 0.10, 0.05, 0.01] print ("NOTAS:") for i in range(len(notes)): nu...
6a63b1ed6e358ea835c525fa98c715d0a6c9fdb0
asadugalib/URI-Solution
/Python3/uri 1018.py
338
3.671875
4
#1018 def money(total,note): num_notes = total // note return num_notes total = int (input()) notes = [100, 50, 20, 10, 5, 2, 1] num_notes = [] print (total) for i in range(len(notes)): num_notes.append(money(total,notes[i])) total = total % notes[i] print ("{} nota(s) de R$ {},00".format(num_no...
d4f2de981b181ab67c6f106ec25fea73299dbe94
asadugalib/URI-Solution
/Python3/uri 1176 Fibonacci Array.py
294
3.828125
4
#1176 Fibonacci Array def fibonacci(pos): t1 = 0 t2 = 1 fib = 0 for i in range(pos): fib = t2 t2 = t1+t2 t1 = fib return fib test = int(input()) for i in range(test): pos = int(input()) x = fibonacci(pos) print("Fib(%d) = %d"%(pos,x))
85c912cff0a04d9e59c27bfe1822b174d25db5e7
asadugalib/URI-Solution
/Python3/uri 1158 Sum of Consecutive Odd Numbers III.py
341
3.53125
4
#1158 Sum of Consecutive Odd Numbers III test = int(input()) count = 0 while count < test: x, y = list(map(int, input().split())) odd_sum = 0 while y > 0: if x % 2 != 0: odd_sum += x else: odd_sum += x+1 y -= 1 x += 2 print(odd_...
697fa803495cfb3b2f7a6885e7785a6d24663aa3
asadugalib/URI-Solution
/Python3/uri 1134.py
371
3.609375
4
#1134 Alcohol = 0 Gasoline = 0 Diesel = 0 while True: user_input = int(input()) if user_input == 1: Alcohol += 1 elif user_input == 2: Gasoline += 1 elif user_input == 3: Diesel += 1 elif user_input == 4: break print("MUITO OBRIGADO\nAlcool: {}\nGasolina: ...
38d1274faed37170fd14b2101c7663ed9f9fecd6
asadugalib/URI-Solution
/Python3/uri 1478 Square Matrix II.py
650
3.71875
4
#1478 Square Matrix II while True: num = int(input()) if num <= 0: break array = [[1 for i in range(num)] for j in range(num)] for i in range(num): up_val = 1 low_val = i + 1 for j in range(num): if i < j: up_val += 1 array[i][...
28961899cd585ff292858eb33daac11012effc31
asadugalib/URI-Solution
/Python3/uri 1015.py
177
3.609375
4
#1015 import math p1 = input().split(" ") p2 = input().split(" ") distance = math.sqrt((float(p2[0])-float(p1[0]))**2+(float(p2[1])-float(p1[1]))**2) print("%0.4f"%distance)
0818c86baaf9e49ad3504ec2a9adb2fa5fce0a43
Stetcha/tictac
/tictac.py
3,355
3.796875
4
#!/usr/bin/python3 import os class tictac(): def __init__(self): self.player = "Player 1" self.marker = '' self.status="Playing ......" self.detect = "Win not detected" self.game = [[0,0,0], [0,0,0], [0,0,0],] def play(self): player1 = 'X' player2 = 'Y' if ...
3432b927695aa2561b129a087c6a3a611bc6eeaf
lorischl-otter/Sprint-Challenge--Intro-Python
/src/cityreader/cityreader.py
4,263
4.1875
4
# Create a class to hold a city location. Call the class "City". It should have # fields for name, lat and lon (representing latitude and longitude). import csv class City: def __init__(self, name, lat, lon): self.name = name self.lat = lat self.lon = lon def __str__(self): re...
a37b4a301199c714281cbe860d23751989a31947
tyrvi/evo_layout
/src/graph.py
5,276
3.5
4
import numpy as np from util import RoomTypes, pause import random from numpy.random import choice class Graph: """A Graph is a list of vertices and a list of edges""" def __init__(self, V=[], E=[]): self.V = V self.E = E self.points = [] self.room_types = [] for v in V...
0d04ef23559c3230bcbfdb7ed48e370b8a567df4
jchh1998/Practical-one
/bmi.py
408
4.15625
4
__author__ = 'dhs' weight = input("Please enter your weight") height = input("Please enter your height") w = float(weight) h = float(height) bmi = round(w/(h*h),5) print("Your BMI is", bmi) if bmi <= 18.5: print("You're underweight please eat more") if 18.5 < bmi < 24.9: print("Your Weight and height go wel...
c1e0f659818363402c3110a8db5945c5ab87c236
rapid7/icon-integrations-validators
/icon_validator/timing.py
398
3.6875
4
from datetime import datetime def time_now(): return datetime.utcnow() def format_time(start, end): """ Returns the time delta of two datetimes in a millisecond floating point number. :param start: Start datetime :param end: End dtaetime :return: the milliseconds between start and end, as a ...
50140a152d3ab3dbbef595e10108ee928123e821
unwaltch/Some_Python
/Pygame_Examples/Ball_1.py
3,066
3.671875
4
# -*- coding: utf-8 -*- """ Created on Thu Oct 15 17:22:23 2020 @author: Mehmet Akıncı """ import pygame import math from decimal import Decimal class Ball(): def __init__(self,velocity,position): self.velocity = velocity self.position = position self.radius...
10292be875414fde1718d92abdb2852baed44bb8
AndrewB4y/holbertonschool-low_level_programming
/0x1C-makefiles/5-island_perimeter.py
1,067
4.125
4
#!/usr/bin/python3 """ Island Perimeter module """ def island_perimeter(grid): """ islan_perimeter(grid) Function that returns the perimeter of the island described in @grid grid is a list of list of integers: 0 represents a water zone 1 represents a land zone One cell is a ...
f9181a98172723f6d657868e8596ff2d5a636ded
puja-pj/Automation_using_python
/merge_and_split_pdf.py
1,968
3.671875
4
import PyPDF2 """This script includes two functionalities 1.Merge PDF's 2.Split PDF's This script can also be used as module """ #Merge PDF Functionality def merge_pdf(merge_file1,merge_file2): #Create PdfFileMerger object to merge merge = PyPDF2.PdfFileMerger() #Append the files to PdfFileM...
261e69918ad6bc21f8fc0f4cc7a215ebe087df44
sadiquemohd/data_analytics
/python_math /lab/matrix/task1.py
433
4.15625
4
""" 1. Пусть дана матрица чисел размером NхN. Представьте данную матрицу ввиде списка. Выведите результат сложения всех элементов матрицы """ def matrixToList(matrix): result = [] for i in matrix: result += i return result matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] print(sum(matrixToList(matrix...
58e42040f1f152242c6945ba32e9c7c8c30b1ca3
sadiquemohd/data_analytics
/python_math /lab/struct/task3.py
705
3.890625
4
""" Добавьте к задаче No6 для словаря возможность (без преобразования словаря обратно в список) изменить возраст студента. """ from lab.struct.task1 import listToDic list = [[123, 'Ivanov', 18,'1443'],[324, 'Petrov', 21, '1223a'],[332, 'Sidorov', 21, '4445']] students = listToDic(list) def changeAge(students): ...
69084b82a0d439635f35575d18a2b6c2eb328adf
sadiquemohd/data_analytics
/python_math /lab/struct/task2.py
873
3.984375
4
""" Добавьте к задаче No6для словаря возможность (без преобразования словаря обратно в список) изменить группу студента. Поиск по «ФИО» («ФИО» студента и новый номер группы необходимо ввести с клавиатуры) """ from lab.struct.task1 import listToDic list = [[123, 'Ivanov', 18,'1443'],[324, 'Petrov', 21, '1223a'],[332,...
8ddbb0b8dc733bf29bdf14ca9703cea3e38be5db
mmalekzadeh/replacement-autoencoder
/opportunity/om3_build_sections_dataset.py
3,710
3.578125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created in September 2017 This module builds a new dataset from training and testing timseries dataset. It selects a size for its sliding window and iteratively take a section from original data and store it in a new three-dimensional matrix. @author: mmalekzadeh """...
81834b6710fc91bc64f52814312d1bb6a898665e
EddiePueb1/Python-Problems-GDS
/python/Week_2.py
2,472
4.21875
4
# VERY EASY: Write a function named min that takes two arguments and returns their minimum. first_value = int(input('Value 1: ')) second_value = int(input('Value 2: ')) def min(val1, val2): if val1 < val2: return val1 else: return val2 print(min(first_value, second_value)) # EASY: Create an array of st...
0f26072301ffd5b054a20a68bdcc42e61a359706
suraj19/Hackerrank-Codes
/program25.py
741
3.765625
4
'''The first line contains two space-separated integers n and d, the size of a and the number of left rotations you must perform. The second line contains n space-separated integers a[i]. Output Format Print a single line of n space-separated integers denoting the final state of the array after performing d left...
f8e72443fcf953e464f85625632e4a336b60c7e4
suraj19/Hackerrank-Codes
/program18.py
1,095
3.796875
4
'''There is an array of n integers. There are also disjoint sets, A and B, each containing m integers. You like all the integers in set A and dislike all the integers in set B. Your initial happiness is 0. For each i integer in the array, if i∈A, you add 1 to your happiness. If i∈B, you add -1 to your happiness. Ot...
49eef9b329943810a3e74d3f060ae570b6c272fe
Cassio-4/URI-Online-Judge
/python/Begginer/1070.py
139
3.90625
4
X = int(input()) if X % 2 != 0: for i in range(X, X+12, 2): print(i) else: for i in range(X+1, X+13, 2): print(i)
47c7fae66740d1b01a9ac089b13c9dda8b3e49c2
sunshineDrizzle/CommonTools
/commontool/algorithm/string.py
2,026
4.125
4
def _filling(string, fillers_list, fillers, strings): """ do filling Parameters: ----------- string: string A string that may contain several placeholders {}. fillers_list: list Each element is a collection of fillers named fillers_c. Each fillers_c works on its correspo...
4bb0af817512b525816a68069664a597dfe36ae3
8dspaces/blog_8dspaces
/Python_exercise/NGram.py
613
3.671875
4
class NGram(object): def __init__(self, text, n=3): self.length = None self.n = n self.table = {} self.parse_text(text) def parse_text(self, text): chars = ' ' * self.n # initial sequence of spaces with length n for letter in (" ".join(text.split()) + " "): ...
05a17231b849659dd43a9ebd725acd4afd7a8772
uttamk/katas
/roman_numerals/python/roman_numerals/converter.py
1,380
3.5
4
from roman_numerals import single_numeral_to_decimal_map from roman_numerals.types import RomanNumeral, SingleRomanNumeral, Decimal from roman_numerals.validations import validate_numeral, validate_subtraction def convert_to_decimal(roman_numeral: RomanNumeral) -> Decimal: validate_numeral(roman_numeral) reve...
f4317c6c246375fc32f5e91a8a3c2b7de46036ab
atpathak/ATLAS
/Physics_Analysis/LFV_area/LFVlephad/share/script/xmlparser.py
9,963
3.9375
4
#!/usr/bin/env python2 import ROOT class RootElementNotSingularException(Exception): pass class XMLNode(object): """ Representation of a xml node. """ def __init__(self, name, content=None, attributes=None, children=None): """ Constructor of a base XMLNode. All the information of ...
3954cdbcff29f2a2bacbe78b090144f308f7b329
richastats/pdsnd_github
/bikeshare.py
7,224
4.5
4
import time import pandas as pd import numpy as np def get_filters(): """ Asks users to specify name of the city, month, and day they want to analyze. Returns: (str) city - name of the city to analyze (str) month - name of the month to filter by, or "all" to apply no month filter ...
4e44d7d1f80a960f82b559e4c92dd6067e4b9425
alejandrok93/code-challenges
/python/print_elemnts_linked_list.py
758
4
4
def printLinkedList(head): curr_node = head while curr_node is not None: print(curr_node.data) curr_node = curr_node.next class SinglyLinkedListNode: def __init__(self, data, next=None): self.data = data self.next = next class SinglyLinkedList: def __init__(self, head=None, tail...
90ad0e3ae811d727b635271e75f1ed96a431e80d
gdeluca1/assignment_11
/src/tests/point_test.py
3,147
3.671875
4
import unittest import random from ..point import Point class TestPointClass(unittest.TestCase): def setUp(self): pass def test_add(self): point_a = Point(10, 27) point_b = Point(5, 7) point_c = point_a + point_b point_d = point_b + point_a self.assertEqual(po...
c0d96d31e097c7a783a61b8beaa126d469e4af4e
joecummings/isi-test
/create_wiki_dataset/code/create_wiki_dataset_by_category.py
2,293
3.625
4
""" Module to create new dataset of Wikipedia article IDs based on a Wikipedia category. These IDs should then by matched to a JSON dump of Wikipedia articles using the script `format_wikipedia.py`. Makes use of the Wikipedia-Python API: https://wikipedia-api.readthedocs.io/en/latest/API.html """ import argparse from...
41e1d0d5f5ac5c2a4935dae4170ead239cd2006f
Auroral-on/python-builtin-function
/第09章-类、实例/isinstance().py
1,705
4.3125
4
# isinstance(object, classinfo) # 如果参数 object 是参数 classinfo 的实例或者是其 (直接、间接或 虚拟) 子类则返回 True。 如果 object 不是给定类型的对象,函数将总是返回 False。 如果 classinfo 是类型对象元组(或由其他此类元组递归组成的元组),那么如果 object 是其中任何一个类型的实例就返回 True。 如果 classinfo 既不是类型,也不是类型元组或类型元组的元组,则将引发 TypeError 异常 # 如果参数 object 是参数 classinfo 的实例或者是其 (直接、间接或 虚拟) 子类则返回 True。 print(f...
d9a1440ec4b6024c3a75b9e9de15d8f28d824935
Auroral-on/python-builtin-function
/第14章-属性列表、变量字典、属性字典/dir().py
3,214
3.953125
4
# dir([object]) # 如果没有实参,则返回当前本地作用域中的名称列表。如果有实参,它会尝试返回该对象的有效属性列表。 # 如果没有实参,则返回当前本地作用域中的名称列表。 print(f'{ dir() = }') # 如果有实参,它会尝试返回该对象的有效属性列表。 class C: a = 0 def f(self): pass print(f'{ dir(C) = }') # # 如果对象有一个名为 __dir__() 的方法,那么该方法将被调用,并且必须返回一个属性列表。这允许实现自定义 __getattr__() 或 __getattribute__() 函数的对象能够自定义 ...
788a396e9fed211342081d4f78b3c31605cd0a8c
Auroral-on/python-builtin-function
/第09章-类、实例/type().py
1,944
4.0625
4
# class type(object) # class type(name, bases, dict) # 传入一个参数时,返回 object 的类型。 返回值是一个 type 对象,通常与 object.__class__ 所返回的对象相同。 # 传入一个参数时,返回 object 的类型。 返回值是一个 type 对象,通常与 object.__class__ 所返回的对象相同。 print(f'{ type("test") = }') print(f'{ type(type("test")) = }') print(f'{ "test".__class__ = }') print(f'{ "test".__class__ ...
e739d27263126eae5af849b3a4522a30a2adc3a8
Auroral-on/python-builtin-function
/第18章-切片/slice().py
1,900
4.125
4
# class slice(stop) # class slice(start, stop[, step]) # slice # 返回一个表示由 range(start, stop, step) 所指定索引集的 slice 对象。 其中 start 和 step 参数默认为 None。 切片对象具有仅会返回对应参数值(或其默认值)的只读数据属性 start, stop 和 step。 它们没有其他的显式功能;不过它们会被 NumPy 以及其他第三方扩展所使用。 切片对象也会在使用扩展索引语法时被生成。 例如: a[start:stop:step] 或 a[start:stop, i]。 请参阅 itertools.islice() ...
d215d58e466f19cced4747c6a674d4a7aca544a1
Auroral-on/python-builtin-function
/第07章-可迭代对象、迭代器/map().py
1,478
4.28125
4
# map(function, iterable, ...) # 返回一个将 function 应用于 iterable 中每一项并输出其结果的迭代器。 如果传入了额外的 iterable 参数,function 必须接受相同个数的实参并被应用于从所有可迭代对象中并行获取的项。 当有多个可迭代对象时,最短的可迭代对象耗尽则整个迭代就将结束。 对于函数的输入已经是参数元组的情况,请参阅 itertools.starmap()。 # 返回一个将 function 应用于 iterable 中每一项并输出其结果的迭代器。 def func(elem): return elem**2 print(f'{ map(func, [1,...
4a458a6b25ad43cd121ef4e447e1f9cd125d96bf
Auroral-on/python-builtin-function
/第03章-进制转换/bin().py
1,069
4.09375
4
# bin(x) # 将一个整数转变为一个前缀为“0b”的二进制字符串。结果是一个合法的 Python 表达式。如果 x 不是 Python 的 int 对象,那它需要定义 __index__() 方法返回一个整数。一些例子: # 将一个整数转变为一个前缀为“0b”的二进制字符串。 print(f'{ bin(3) = }') print(f'{ bin(-3) = }') print(f'{ bin(0) = }') print(f'{ bin(0b11) = }') print(f'{ bin(0o10) = }') print(f'{ bin(0x7f) = }') # 结果是一个合法的 Python 表达式。 print(...
d51181e6dbbffea148ff4b237cd05405f1455b9a
Auroral-on/python-builtin-function
/第16章-super/super().py
4,350
3.6875
4
# super([type[, object-or-type]]) # super # super() -> same as super(__class__, <first argument>) # super(type) -> unbound super object # super(type, obj) -> bound super object; requires isinstance(obj, type) # super(type, type2) -> bound super object; requires issubclass(type2, type) class B: def test(...
adbf8906eba22aa2b276ffae36f117fc11ae7d64
Auroral-on/python-builtin-function
/第07章-可迭代对象、迭代器/iter().py
2,473
3.921875
4
# iter(object[, sentinel]) sentinel 哨兵 # iter # iter(iterable) -> iterator # iter(callable, sentinel) -> iterator # 根据是否存在第二个实参,第一个实参的解释是非常不同的。如果没有第二个实参,object 必须是支持迭代协议(有 __iter__() 方法)的集合对象,或必须支持序列协议(有 __getitem__() 方法,且数字参数从 0 开始)。 lis = ['a', 'b', 'c'] print(f'{ hasattr(lis, "__iter__") = }') print(f'{ iter(li...
6b9a428a54397d66a59d751ee075a53e318a8025
ChenPaulYu/alogrithms-python
/sorting/04.quickSort.py
683
3.96875
4
unsortlist = [2,8,7,1,3,5,6,4,2] def partition(List,start,end): print(start,end,List) compareBase = List[end] partitionIndex = start-1 # initial is -1 for x in range(start,end): if(List[x]<compareBase): partitionIndex = partitionIndex + 1 List[partitionIndex],List[x] = List[x],List[partitionIndex] del L...
e7384b97e8604f80523a55fc523299ec1e34a7ab
whorst/ID_Scanner
/PycharmProjects/Python2ClassPractice/unt.py
349
3.5
4
__author__ = 'Willy' class car (object): __engine = None __wheel = None __transmission = None def __init__(self, eng,whe, trans): self.__engine = eng self.__wheel = whe self.__transmission = trans def getWheel(self): return self.__wheel ford = car(4, 4, 4) prin...
f71d3fd0e51b91b9d291b670e6b76c929fcc655a
whorst/ID_Scanner
/PycharmProjects/Assignment2/test.py
784
3.703125
4
__author__ = 'Willy' a = "howardmoe" b = "howardcurly" c = "finelary" g = [c,a,b] float("100") print(float("100")) exit(0) print(g) for q in range (len(g)-1): for j in range(q): if (g[j]>g[j+1]): temp = g[j] g[j] = g[j+1] g[j+1] = temp print(g) if b < a : ...
6f2b5a54ef0e65e869bafeea292b5fde10225cb5
whorst/ID_Scanner
/PycharmProjects/HelloPython.py/PlayAround.py
2,561
3.921875
4
__author__ = 'Willy' import os import sys import random source = {} def selection_sort(list): for z in range(len(list)): #print(z) #z has one added to it every time there's an iteration y = z for i in range(z,len(list)): #This piece of code check the iteration @ z and the comparisons ar...
80d91afc17e34d1819fdc319c4d2ad558667e061
Abourass/zookeeper
/Problems/Factorial/task.py
113
3.59375
4
number = int(input().strip()) output = 1 while number != 0: output *= number number -= 1 print(output)
abcd42b0d494ca7cc949dbf222021c5262c2e542
Abourass/zookeeper
/Problems/Very odd/task.py
118
3.75
4
# put your python code here dividend = int(input()) divider = int(input()) print(int((dividend / divider) % 2) == 1)
7a4c4c581bb2ac4a3024602cc5ba9866b672ec23
MichaelMedford/skysight
/skysight/dither.py
6,569
4.0625
4
#! /usr/bin/env python # """ Slew translations and/or rotations to be applied to a a single Camera or to a list of Cameras. """ from itertools import combinations class Slew: """ Class for the geometric manipulation of Camera objects. Each Camera object is created from the *camera.Camera* class and can ...
2907489c1f72d65378526692aab53ed6a70fede9
manueltorrez/basics-python-project
/string.py
327
3.9375
4
string = "I am the game" print(string[0]) # -1 and so on can be used to len(string) print(string[2:4]) # prints "am" #Format print("Today I had {0} cups of {1}".format(3, "coffe")) print('prices: ({x}, {y}, {z})'.format(x = 2.0, y = 1.5, z = 5)) print('The {vehicle} had {0} crashes in {1} months'.format(5,6,vehicle = ...
5336cc03d62650f7dad03e8b5644f3c3f241df28
YarlyMadrid/Codigo_Python
/Ejercicios Decisiones.py
4,690
3.9375
4
print("EJERCICIO 1\n") def ejercicio1(numero): if (numero % 10) == 4: return True else: return False print(ejercicio1(154)) print("\nEJERCICIO 2 \n") def ejercicio2(numero): if (numero >= 100)and(numero < 1000): return "El número tiene 3 digitos" else: ...
bec0f1776475f596855a96599b90646217a7c274
fmoor/quilt_colors
/quilt_colors.py
4,036
3.75
4
from itertools import chain from random import shuffle, seed from typing import TypeVar, Tuple, Union, Any, Set, Iterable, Iterator seed() Color = TypeVar('Color') def assign_color(color: Color, quilt: Tuple[Tuple[Union[Color, None], ...], ...], x: int, y: int) -> T...
dfd7c376f6927221e126170f737411ad708059ee
vishrantgupta/hackerrank_solution
/kangaroo_by_editorial.py
489
3.609375
4
# If v1 <= v2, they will never meet. # We just need to check if a solution exists for the following equation: # # x1 + t*v1 == x2 + t*v2 # # This is equivalent to checking if (x2 - x1) % (v1 - v2) == 0 x1, v1, x2, v2 = map(int, raw_input().split()) X = [x1, v1] Y = [x2, v2] back = min(X, Y) fwd = max(X, Y) dist = fwd[...
72b2cfbfc0ca9bba47f48a2c50e8e58287191d83
vkoprivica/100_Days_of_Python
/days_28-30_regex/regex_ipynb.py
3,078
3.796875
4
import re import pprint from collections import Counter text = "Awesome, I am doing the #100DaysOfCode challenge" # print(text.startswith("Awesome")) # print(text.endswith("challenge")) # print("100daysofcode" in text.lower()) # print(text.replace("100", "200")) # print(re.search(r"I am", text)) # print(re.match(r"I...
8a4b1c1627ecf2b21d43d06ee15e0269e602e64c
kasteion/python-web-learning-route
/03-python-basics/src/conversor2.py
186
3.671875
4
dolares = input("¿Cuántos dolares tienes?: ") dolares = float(dolares) valorDelDolar = 7.73 quetzales = str(round(dolares * valorDelDolar, 2)) print("Tienes Q", quetzales, "Quetzales")
df14f0936eb47e03fdccaa790995613e91fe7912
borisboychev/SoftUni
/Python_OOP_Softuni/Iterators_Generators_Lab/venv/squares.py
142
3.6875
4
def squares(n): current_num = 1 while current_num <= n: yield current_num**2 current_num += 1 print(list(squares(5)))
aba7d409a3127765c4167bceb0535e03bdd62c0c
borisboychev/SoftUni
/Python_Advanced_Softuni/File_Handling_Exercises/venv/file_manipulator/file_manipulator.py
1,027
3.578125
4
import os while True: arg = input().split('-') if arg[0] == 'End': break if arg[0] == 'Create': file_name = arg[1] with open(file_name, 'w') as file: file.write('') elif arg[0] == 'Add': file_name = arg[1] with open(file_name , 'a') as file: ...
88976476be897879675cd9ffeca5729f33405f5d
borisboychev/SoftUni
/Python_OOP_Softuni/Exam_Prep_02AprilExam/tests/test_beginner.py
1,211
3.765625
4
import unittest from project.player.beginner import Beginner class TestBeginner(unittest.TestCase): def test_set_attr(self): p1 = Beginner('player1') self.assertEqual('player1', p1.username) self.assertEqual(50, p1.health) self.assertEqual("Beginner", p1.__class__.__name__) ...
e354c72700085dbfb0acada8c6a694ca8fced1df
borisboychev/SoftUni
/Python_Advanced_Softuni/Tuples_And_Sets_Excercise/venv/phonebook.py
424
3.8125
4
contacts = {} text_input = input().split('-') while len(text_input) != 1: name = text_input[0] number = text_input[1] contacts[name] = number text_input = input().split('-') n = int(text_input[0]) for _ in range(n): contact_name = input() if contact_name in contacts: print(f'{contact...