blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
377988ff38e51ca12eaa3c71e981fce42ef27d69
QPC-WORLDWIDE/supybot_fixes
/plugins/Dict/local/dictclient.py
12,361
3.640625
4
# Client for the DICT protocol (RFC2229) # # Copyright (C) 2002 John Goerzen # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) ...
91400f93957a7686c7b287a8be543718ba0210ec
aikachin/python_work-exercises-
/demo_5_3.py
869
3.609375
4
#!usr/bin/python # -*- coding:utf-8 -*- # test 5-3 alien_color = 'green' if alien_color == 'green': print("Player A has got 5 points.") elif alien_color == 'yellow': print("Player A has got 10 points.") elif alien_color == 'red': print("Player A has got 15 points.") # test 5-6 age = 32 if age<2: print("He is a ch...
0ff92cd7eb15b09a2d56fb2dc325eb97bf75b7a4
szhx/Python
/University projects/a06/a06q3.py
612
4.125
4
import check # is_palidrome(s) returns if the given string s is in palidrome form # is_palidrome: Str -> Bool # Example: is_palindrome('aba') => True def is_palindrome(s): if len(s) == 0 or len(s) == 1: return True while len(s) > 1: if s[0] == s[-1]: return True else: ...
bcfa6c2d01eb0dc8bddd436dc3c832c847728a71
AdamZhouSE/pythonHomework
/Code/CodeRecords/2525/60678/304558.py
278
3.8125
4
string = eval(input()) + eval(input()) + eval(input()) if string == [1,2,3,3,3,4,5,6,50,10,40,70]: print(120) elif string == [1, 1, 1, 2, 3, 4, 5, 6, 4]: print(6) elif string == [1, 2, 3, 4, 6, 3, 5, 10, 6, 9, 20, 20, 100, 70, 60]: print(150) else: print(string)
e754cddc63067cfe5e85d6bbd847b53edb41f2e1
Ritvik19/CodeBook
/data/CodeChef/CHEFSQ.py
245
3.5625
4
for i in range(int(input())): seql = int(input()) seq = [int(e) for e in input().split(" ")] sbsql = int(input()) sbsq = [int(e) for e in input().split(" ")] if sbsq in seq: print("Yes") else: print("No")
69ac7c1e4804c803e51d4c4f24060e8b9082a6b2
ManikhweSchool/Introduction-To-Java-Programming
/Python/For Loops/Exercise 2.5.9/Exercise_2_5_9b.py
436
3.90625
4
numberOfFib = eval(input('Enter Number Of Elements : ')) if numberOfFib<=0: print('Start Over : Invalid Input.') elif numberOfFib==1: print(1) elif numberOfFib==2: print('1,1') else: fib1 = 1 fib2 = 1 fib = fib1 + fib2 print(fib1,fib2,fib,sep=',',end='') for index in range(numberO...
f1c08d68a1c1ba64ea7b8959a778f533c6662195
bopopescu/python-1
/m8_tuple_set_dict/arbitrary_args.py
552
3.90625
4
def greet(*names): for name in names: print("Hello",name) greet('TOM','HOME','JERRY','ILLY') tuple1 = ('tom','home','kiki','nina') greet(*tuple1) list1 = ['tom','home','kiki','nina'] greet(*list1) str1 = 'python' greet(*str1) def stu (**data): for key,value in data.items(): print("{} is {}".fo...
fe350cc72634ed783ba5c0fedc3bb75485f96e01
HyunjoonCho/problem_solving
/hackerrank/sorting/FraudulentActivityNotifications.py
1,407
3.65625
4
import math import os import random import re import sys # # Complete the 'activityNotifications' function below. # # The function is expected to return an INTEGER. # The function accepts following parameters: # 1. INTEGER_ARRAY expenditure # 2. INTEGER d # def activityNotifications(expenditure, d): # Write you...
33d5c793edc16290d7f96962a97982d8c1914d90
shahidul2k9/problem-solution
/leetcode/654. Maximum Binary Tree.py
859
3.734375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right from typing import List class Solution: def constructMaximumBinaryTree(self, nums: List[int]) -> Optional[TreeNode]: ...
627a78c3247a7cbf33532ad02ee238ba7d26cfe4
AbdulMoiz22/multiplication-table
/table.py
163
4.15625
4
print ('Program for generating table of a user entered number') num = int(input('Enter number : ')) for i in range(1, 11): print(num,'x',i,'=',num*i)
f82551419c9eaeeeb12e38da46ba4888eb0b8045
amanjaiswalofficial/100-Days-Code-Challenge
/code/python/day-26/StringSplitJoin.py
76
3.546875
4
s=str(input()) splitted=s.split(' ') joined='-'.join(splitted) print(joined)
3e1f3a03b0a09b86f9812e7080e6bcd04cee70a0
dases/recursion_examples
/factorialEmulateRecursion.py
988
3.890625
4
callStack = [] # The explicit call stack, which holds "frame objects". callStack.append({'returnAddr': 'start', 'number': 5}) # "Call" the "factorial() function" returnValue = None while len(callStack) > 0: # The body of the "factorial() function": number = callStack[-1]['number'] # Set number parameter. ...
c49ff99ec08d8f63a01e7d0350ced8ce1b36271d
jhwgarden/my_password
/dev/reformat_accounts.py
839
3.59375
4
""" script to convert existing csv account format to yaml """ import yaml if __name__=="__main__": try: import sys if len(sys.argv) < 2: raise RuntimeError("Please enter filename") filename=sys.argv[1] import os if not os.path.isfile(filename): raise...
253fbe24a1f8378e47ef8cbb5673c1bf3c077714
eunice-pereira/DC-python-fundamentals
/python101/med_1.py
492
4.03125
4
# tip calculator bill = float(input("Total bill amount?:")) tip = 0 while tip == 0: serv = input("Level of service? Enter good, fair, or bad:") if serv == "good": tip = float(bill * .2) elif serv == "fair": tip = float(bill * .15) elif serv == "bad": tip = float(bill * ....
0f39504524e19388a0bfd60237b04389558386b6
itb-ie/feb172020
/max_4_num.py
343
3.984375
4
numbers=[] count=0 while True: if count >= 4: break number= input("Enter a number: ") try: number= int(number) except: print("That was not a number") continue #We have a proper number numbers.append(number) count += 1 numbers.sort() print("The maximum is {} "...
dae48fc9df6e6f61daf08e863ad635bb3ab5f00f
20190314511/python
/samples/basic algorirthm.py
922
3.5625
4
#------------------------------------------------------------------------------- # Name: # Purpose: # # Author: abeliu # # Created: 09/09/2014 # Copyright: (c) abeliu 2014 # Licence: <your licence> #------------------------------------------------------------------------------- def main(): RingOut(2...
27f736cd922396aa8b7618d35320616665a08212
PaulSayantan/problem-solving
/HACKERRANK/Problem Solving/Implementation/Kangaroo/kangaroo.py
519
3.84375
4
def kangaroo(x1, v1, x2, v2) -> str: if v1 == v2: return 'NO' if x2 > x1 and v2 > v1: return 'NO' while True: x1 = x1 + v1 x2 = x2 + v2 print(x1, x2) if x1 > x2: return 'NO' if x1 == x2: return 'YES' if __name__ == '__m...
0d344ce4a32ca7c3aa454e4e38ca2cb401881954
SamTombling/guesstheword
/main.py
11,973
4.53125
5
# This is a basic game called "Guess The Word", set up for two players. Player One must first enter a word, # then Player Two must guess this word a letter at a time. For every letter that Player Two gets wrong, a shape will # be drawn which will, after 8 wrong attempts, add up to a drawing of an ambulance, causing P...
d2070fe0348d793e0f8491bffa6259cb004199ff
wintryJK/python_project
/day15/03 global与nonlocal.py
865
4.09375
4
""" @作者: egon老湿 @微信:18611453110 @专栏: https://zhuanlan.zhihu.com/c_1189883314197168128 """ # 示范1: # x=111 # # def func(): # x=222 # # func() # print(x) # 示范2:如果再局部想要修改全局的名字对应的值(不可变类型),需要用global # x=111 # # def func(): # global x # 声明x这个名字是全局的名字,不要再造新的名字了 # x=222 # # func() # print(x) # 示范3: # l=[111,222] ...
adc2ed97103f4df91a574cb8e660593205e4f998
FWRobins/PCAP
/invertBinaryTree.py
885
3.609375
4
import math # tree = [1,2,2,3,3,None,3,4,4,4,4,4,None,None,4] # # height = int(math.log2(len(tree)+1)) # # newtree = [] # # depth = 1 # # for i in range(height): # templist = tree[depth-1:depth*2-1] # templist.reverse() # for i in templist: # newtree.append(i) # depth *=2 # # print(newtree) cla...
561d6813230f8745ceabbb9df50b1ea23b92f3a0
hoangqwe159/DoVietHoang-C4T5
/homework_4/serious_ex2.py
435
3.953125
4
prices = { "banana": 4, "apple": 2, "orange": 1.5, "pear": 3 } stock = { "banana": 6, "apple": 0, "orange": 32, "pear": 15 } total = 0 for key, value in prices.items(): print(key) print("price : ", value) print("stock : ", stock[key]) print(20 * '*') money = value * ...
75d8ec9144dca7307fe0eaf5c13646f49d06f219
HarshithaKP/Python-practice-questions-
/27.py
367
4.4375
4
# Implement a progam to convert the input string to lower case ( without using standard library) def lowercase(string): result = '' for char in string: if ord(char) <=90: result += chr(ord(char) + 32) print(result) def main(): string=input("Enter any string in uppercase :") lowercas...
8ddec43060744370f0c513a6d64a7e04bd85442f
amankumarsinha/python-basics
/more_about_list.py
509
3.8125
4
#generate list with range fun #something about pop() #index method # pass list to afunction n = list(range(1,11)) print(n) print(n.pop())# returns the deleted item print(n.index(5))# return the position of the given number fist occurance print(n.index(5,3))# you can assing from where to search print(n....
3a0525c235b6c76e4d9d9934a5b6b00f8ff52e80
melisarv/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/models/rectangle.py
3,306
3.84375
4
#!/usr/bin/python3 '''Class Rectangle''' from models.base import Base class Rectangle(Base): '''definition Class Rectangle''' def __init__(self, width, height, x=0, y=0, id=None): '''instance initialization method''' super().__init__(id) self.width = width self.height = height...
ceddd62125b30eef5180b51d89cb7b7437175c4e
rester71/Fibonacci
/main.py
488
3.734375
4
#Sucesión de Fibonacci def main(): #Esta Sucesión tiene la siguiente forma # 0 1 1 2 3 5 8 13 21 34 55 ... """versión facil con listas(arreglos)""" tamaño = 10 lista = [] #agrego los dos primeros numeros a la lista lista.append(0) lista.append(1) for i in range(0, tamaño): if...
c16d194491267ef6013039cd7dc8d6ef2c6c0fe2
MXYLR/Full-Speed-Python-Exercises-Answer
/我确定的答案/dict1.py
2,397
4.3125
4
#!/usr/bin/env python3 #coding= utf-8 ''' 字典部分练习: 先定义一个Python字典: 1. ages = { 2. "Peter": 10, 3. "Isabel": 11, 4. "Anna": 9, 5. "Thomas": 10, 6. "Bob": 10, 7. "Joseph": 11, 8. "Maria": 12, 9. "Gabriel": 10, 10.} 1. 这个字典中有多少个同学?可以参考下len函数。 2. 写一个...
c8ed17514e89aab925f4548595418c4f84d2980b
ceucomputing/olevel
/ch04/programs/11_password_2.py
168
3.765625
4
text = input("Enter text: ") if text == "P@55w0rd": print("Yes") print("Correct Password") else: print("No") print("Wrong Password") print("Goodbye")
cb41107c149e1decef7f1c2dc5fb5052e1447f03
ZBr14n/Algorithms-Data-Structures-in-Python
/Python exercise/recursions.py
679
3.78125
4
# -*- coding: utf-8 -*- """ Created on Thu Jun 13 10:48:46 2019 @author: brlam Input: 3 Output: ( ( () ) ) , ( () () ) , ( () ) () , () ( () ) , () () () """ def recurse(n): string="" count=0 if string == "()()()" or n==0: return string ...
e05ce0388d0be6842d82150ba54d3190b5cb9a33
KotRom/pythonProject1
/New folder/005_functional_programming/functions.py
335
3.828125
4
def squares(x): y = x ** 2 y_string = 'Square of ' + str(x) + ' is ' + str(y) + '.' return y_string def double(x): y = x * 2 y_string = 'Double of ' + str(x) + ' is ' + str(y) + '.' return y_string def tripple(x): y = x * 3 y_string = 'Tripple of ' + str(x) + ' is ' + str(y) + '.' ...
d546f88affba5d48d4ec452733ece43b1395c673
OfficialCube/python_class
/majorLoop.py
2,195
3.859375
4
# magicians = ["kike", "toke","romoke", "labake", "folake","amaka","caitlyn","tayo","tosin","richard","godfrey"] # for magician in magicians: # print(magician) # for magician in magicians: # print(magician.title() + ", that was a great Trick") # squares = [] # for value in range(1,11): # square = value ...
0d5fee6e9891384ec95ef16c15cac80dc79d7e83
paulo-caixeta/Curso_Python-CursoEmVideo-Guanabara
/ex030.py
177
4.1875
4
numero = int(input('Digite um número inteiro: ')) if numero % 2 != 0: print('{} é um número impar'.format(numero)) else: print('{} é um número par'.format(numero))
a8a2b76894cd5f6b94980cf2daad52d3dc42c9c9
jaykepeters/Python
/text2binary.py
120
4.09375
4
#!/usr/bin/env python import binascii a = raw_input("Enter Some Text: ") print(' '.join(format(ord(x), 'b') for x in a))
3d7cdbb64b99d5a7c4a1331681e23069ff80eb8a
p-cap/algo-data-structures
/SinglyLinkedLists/python/DoublyLinked.py
861
3.765625
4
class PcapDoublyLinkedList(object): def __init__(self): self.head = None class PcapNode(): def __init__(self, value): self.value = value self.next = None self.previous = None # decalred the list pcapList = PcapDoublyLinkedList() # declared the nodes pcapHead = PcapNode("Uno"...
c9ef3326b25e7b64efd6e68de3afbf931568b5de
quickeee/Coding-Bootcamp
/Coding Bootcamp/Projects/07_09_2016 The Maze Challenge/MazeChallenge.py.py
7,638
4.28125
4
#Start of the algorithm... Inserting the maze dimensions... n = input("Please enter the dimensions of the maze in a format of: X ") #Check in order the maze will be bigger than 2x2 and also that a user cannot enter negative dimensions... while int(n) < 2: print ("The dimensions of the maze have to be >= 2!! please ...
6c978d973b848ac707eff2e593b2eb681b879cce
chrislee35/yaratool
/yaratool/duplicate_detector.py
831
3.71875
4
class DuplicateDetector: def __init__(self): self.rules = {} def check(self, rule): """ check(rule) takes in a YaraRule object and checks if it's a duplicate input: a YaraRule output: list of any duplicates (via hash or name) that is know this update...
a003f11e5e84f55671e3e06d25ec82d7f5f16bdb
purplewove/sudoku_solver
/components.py
6,922
3.6875
4
from numpy import matrix, concatenate from collections import namedtuple from math import sqrt from copy import deepcopy ''' Created on Oct 7, 2015 @author: templetonc ''' Location = namedtuple('Location', ['x', 'y']) class Board(): def __init__(self, dimension): assert sqrt(dimension) % 1 == 0 ...
05dfa0f8c764ae4e60a36821e6c50b8b9c21aece
replu/atcoder
/abc/abc066/B/main.py
652
3.75
4
#!/usr/bin/env python3 import sys def solve(S: str): for i in range(len(S)-2, 0, -2): h = i // 2 left = S[0:h] right = S[h:i] if left == right: print(i) break return # Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use ...
01bd937cf01d9621a08db336e5dac4cab874af58
JIACHENG135/leetcode2
/run.py
747
3.5
4
# -*- coding: utf-8 -*- """ Created on Fri Nov 16 19:39:29 2018 @author: ljc """ def run_mn(m,n): results = [] i = 1 j = 1 def run(i,j,m,n,result,results): print(result) while i< m or j<n: if j==n and i<m: # print(i,j) result.app...
b6a4a6072989cb7cf34b83195e92104e342bf9f5
nithin-vijayan/xpython
/exercises/rectangles/rectangles_test.py
1,697
3.71875
4
import unittest from rectangles import count class WordTest(unittest.TestCase): def test_zero_area_1(self): self.assertEqual(count(), 0) def test_zero_area_2(self): lines = "" self.assertEqual(count(lines), 0) def test_empty_area(self): lines = " " self.assertEqu...
4c4e0e79151cc4a1d9952f9a8d7eb2c4e33e080f
elianemaciel/programa_talentos_nl_2019
/exercicios/david10.py
693
4.25
4
"""Faça um Programa que peça os 3 lados de um triângulo. O programa deverá informar se os valores podem ser um triângulo. Indique, caso os lados formem um triângulo, se o mesmo é: equilátero, isósceles ou escaleno.""" lado1 = float(input("Digite lado 1: ")) lado2 = float(input("Digite lado 2: ")) lado3 = float(input(...
2354f996ef2ed3322f7fc75174329a6eac013cfe
lealb/leetcode
/python/5_Longest_Palindromic_Substring.py
681
3.6875
4
# encoding:utf-8 class Solution: def longestPalindrome(self, s: str) -> str: """ 暴力破解,O(n^3) Time Limit Exceeded """ m = '' str_length = len(s) if str_length == 1: return s for i in range(str_length): for j in range(str_length+1): ...
ff1e32be38eba0b67efb02719aae2506529f3748
james-soohyun/CodingDojoAssignments
/Python/Assignments/9072017/classActivity.py
495
3.65625
4
class Superhero(): def __init__(self,name,city,powers): self.name=name self.city=city self.powers=powers def talk(self): print "I'm Batman" return self newHero = Superhero("Brandon","Spanaway","telekinesis") print newHero batman = Superhero("Batman", "Gotham", "rich") batman.talk() batman.talk().talk() ...
98ead1877a56662be3d7774c6cace0d3c30f16ae
timisenman/python
/projects/MITpy/queues.py
2,802
4.125
4
### Queues ### #Queueing Policy: Rules that determines who/what goes first in a queue #Priority Queueing: Customer is assigned a priority, and the Customer #with the highest priority goes first, regardless of order of arrival. #Queue ADT: uses FIFO priority #Priority Queue ADT: uses priority queueing class Queue: ...
70d43e2a16af2f16f2f7ffe0d0e208d9bd9fe79c
Innanov/sensors-challenge
/main.py
800
3.5
4
def on_button_pressed_a(): if led.brightness() < 100: basic.show_leds(""" . . . . . # # . # # # # # # # . # # # . . # # # . """) soundExpression.twinkle.play() else: pass input.on_button_pressed(Button.A, on_button_p...
88fc56780085ef51e88a25a933dd3d5f32c51e89
tungtd95/ml-implementation
/gradient_descent_linear_regression.py
1,269
3.53125
4
import plot_helper as plt def train(training_data, alpha): # init some random value for theta theta0 = 27 theta1 = 7 m = len(training_data) print("start training...") while True: theta0_temp = theta0 - alpha * _cal_derivative_partial_theta_0(training_data, theta0, theta1) / m ...
5cb8d53605bc28f515480995d6edb180b1782707
Hacnine/Python-Programming
/Python Advanced Prog/Python Advanced Prog/sort_wth_module.py
713
3.625
4
from operator import itemgetter, attrgetter student_tuples = [ ('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10), ] sorted_tuple_itemgetter = sorted(student_tuples, key=itemgetter(1, 0), reverse=True) # sorted_tuple_attrgetter = sorted(student_tuples, key=attrgetter('grade', 'age')) print(sorted...
ed7884ebeb4d47ecc36634324876690f7494f89a
haohao201100/GitTest
/Object Oriented Programming/Dog.py
1,287
3.90625
4
class Dog: def __init__(self,name,age,gender): self.name = name self.age = age self.gender = gender print('(Initialized Dog:{})'.format(self.name)) def bark(self): print('Name:"{}" Age:"{}" Gender:"{}"'.format (self.name,self.age,self.gender),end="") class Shamoyed(Dog): def __init__(self, name, a...
d7feddcb2f937aebd42481946927d070aaa7cc43
mkseth4774/ine-guide-to-network-programmability-python-course-files
/testExample1.py
651
3.796875
4
#!/usr/bin/env python3 ## ## attempts = 0 magicWord = 'cisco' boolPassword = False while not boolPassword: if attempts > 4: break word = input('Pl enter the magic word :') attempts += 1 if word != magicWord: print('No! But you are getting close. You have ' + str(5 - attempts) + ' attempts le...
85213ae0071b9f2d5caf92488a5eea6a4e2bb444
jbrudvik/sublime-sum
/sum.py
2,191
3.59375
4
# -*- coding: utf-8 -*- import re try: import sublime import sublime_plugin class SumCommand(sublime_plugin.TextCommand): def run(self, edit): # Create new buffer that never reports dirty status sum_view = self.view.window().new_file() sum_view.set_name('Sum') ...
ec351ad74b8c9181782b9c5fc237361ef937cff7
simplewebby/Python_dictionary
/spring_2017.py
3,008
3.78125
4
#1 for i in range(1): for j in range(1): print(i, j, end = "") #2 m2Date = '2017-03-27' freq = -1 position = 0 while freq != 1: x = m2Date[position] freq = m2Date.count(x) position = int(freq) print(position) #3 s = 'Newark' print(s[:-3]) #4 def vehicleSound(vehicle, sound): for l...
a32d9acb981044d37d19018a898219d4ead76a27
euxuoh/leetcode
/python/tree/kth-smallest-element-in-bst.py
1,252
3.90625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ 230. Kth Smallest Element in a BST Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume k is always valid, 1 ≤ k ≤ BST's total elements. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @author: houxue @date...
7f7a6de1b5917e1585081e3815ecec089de8ee74
Lucimore/JetBrains-Zookeeper
/Problems/Favor/task.py
101
3.796875
4
number = int(input()) answer = 0 while number > 0: answer += number number -= 1 print(answer)
c7b2f77b04e245ca40b0e1947786b801050ef431
coremedy/Python-Algorithms-DataStructure
/Python-Algorithms-DataStructure/src/general_problems/numbers/convert_from_decimal_larger_bases.py
1,058
4.09375
4
''' Created on 2014-12-13 Copyright info: The code here comes, directly or indirectly, from Mari Wahl and her great Python book. I'm not the original owner of the code. Thanks Mari for her great work! ''' def convert_from_decimal_larger_bases(number, base): strings = '0123...
a739f0ea5ae4642b560c773902837ddce6acf1d5
Telomeraz/ProjectEulerAnswers
/9_Special_Pythagorean_triplet.py
1,090
4.03125
4
# A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, # # a**2 + b**2 = c**2 # For example, 3**2 + 4**2 = 9 + 16 = 25 = 5**2. # # There exists exactly one Pythagorean triplet for which a + b + c = 1000. # Find the product abc. # Tembelce bir çözüm oldu :) a = 3 b = 4 c = 5 while ...
921a5661d97379ff96caeb27c1e04342067524dc
ACSLab-CWNU/Problem-Solving
/실5)2750번-수 정렬하기.py
367
3.703125
4
N = int(input()) numbers = [] for _ in range(N): numbers.append(int(input())) for i in range(len(numbers)-1): min = i for j in range(i+1,len(numbers)): if numbers[j] < numbers[min]: min = j tmp = numbers[i] numbers[i] = numbers[min] numbers[min] = tmp ...
9722ac51bb75fa42a046b427c77b8f92fff4de34
Shtykina/Python_basics
/lesson_6/cw6_4.py
1,519
4.125
4
class Car: def __init__(self, name, speed, color, is_police=True): self.name = name self.speed = speed self.color = color self.is_police = is_police def go(self): return f'Your {self.name} has started.' def stop(self): return f'Your {self.name} has stopped.'...
ce54c753addfe3ddf595f931e77b95ab3b65d1fc
XidongHuang/PythonStudy
/excerises/ex37.py
585
3.609375
4
"""************************************************************************* > File Name: ex37.py > Author: XidongHuang (Tony) > Mail: xidonghuang@gmail.com > Created Time: Mon 3 Oct 17:53:34 2016 ************************************************************************""" # -*- coding: utf-8 -*- st...
a5175bca59604dfd628ca2739b71342638e3f197
Kermort/b5.9
/b5.9.py
2,432
4.03125
4
import time class Stopwatch: """класс "секундомер" как секундомер пока не работает, но умеет замерять скорость работы функций через контекстный менеджер и как декоратор """ def __init__(self, num_runs=10): self.num_runs = num_runs def __enter__(self): self.total_time = 0 ...
2d35aed39921bbea6cf9e259d62d47f77ee55209
ViacheslavNebrat/Homework1
/2.py
2,594
4.1875
4
def create_new_contact(): name = input('enter name') try: add_new_contact_to_base(name) number = input('enter number') add_new_contact_to_base(name, number) except ValueError: while True: action_ = input('Contact already exist. Would you want to update con...
0a903cf9e6cb40b734dcb9b82a4c1f2df046ee36
xkal36/design_of_computer_programs
/Unit2/subpalindrome.py
2,050
4.03125
4
# -------------- # User Instructions # # Write a function, longest_subpalindrome_slice(text) that takes # a string as input and returns the i and j indices that # correspond to the beginning and end indices of the longest # palindrome in the string. # # Grading Notes: # # You will only be marked correct if your fu...
7ca75802a9a8031f295af4cb48d6b92a895b99d0
shiveshsky/datastructures
/bst/sorted_array_to_bst.py
566
3.546875
4
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def sortedArrayToBST(self, A): if len(A)==0: return None if len(A)==1: return TreeNode(A[0]) mid = (len(A))//2 left = self.sorte...
ed36fbdc4b4f91a712a5a257ab9b52a3ca8bbcb7
PythonXiaobai1/python_project_1
/Task4.py
1,153
3.78125
4
""" 下面的文件将会从csv文件中读取读取短信与电话记录, 你将在以后的课程中了解更多有关读取文件的知识。 """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ 任务4: 电话公司希望辨认出可能正在用于进行电话推销的电话号码。 找出所有可能的电话推销员: 这样的电话总是向其他人拨出电话, 但从来不发短信...
ba9172ab267c432bb13b0d8ba354f0ca57c75e53
daniel-reich/ubiquitous-fiesta
/NbZ2cMeEfH3KpQRku_3.py
252
3.859375
4
def portion_happy(numbers): happy=0 if numbers[0]==numbers[1]: happy+=1 if numbers[-1]==numbers[-2]: happy+=1 for i in range(1,len(numbers)-1): if numbers[i]==numbers[i-1] or numbers[i]==numbers[i+1]: happy+=1 return happy/len(numbers)
fbb13fd201a1154336766c0d53f1c186a03ace7f
frclasso/revisao_Python_modulo1
/cap04-tipos-variaveis/listas_tuplas_dicts.py
1,605
4.65625
5
#!/usr/bin/env python3 print('Listas_________') minhaLista = ['ABCD', 2.33, 'efgh', 'bola', 'copo'] print(minhaLista[0]) print(minhaLista[1]) print(minhaLista[2]) print(minhaLista[-1]) #Adicionando um elemento no final da lista utilizamos append minhaLista.append('Fogo') print(minhaLista) # Para adicionar e escolher...
aed1662ba3c0f70abc5b3939bf05330337505fdd
merimem/Data-Structures
/Arrays/leftRotate.py
406
3.671875
4
def leftRotatebyOne(T, n): temp = T[0] for i in range(n-1): print(T[i],"+", T[i+1]) T[i]=T[i+1] T[n-1] = temp print(T) def leftRotate(T,d, n): for i in range(d): leftRotatebyOne(T, n) def printArray(T, n): for i in range(n): print(T[i]) T = [1, 2, 3, 4, 5, 6,...
bb0ccbc2dfb6e21cc9d8196729c0286588b700ee
joolink96/Python
/__init__.py
532
3.796875
4
#__init__은 생성자를 의미 class Unit: def __init__(self,name,hp,damage): self.name=name self.hp=hp self.damage=damage print("{0}유닛이 생성 되었습니다" .format(self.name)) print("체력 {0}, 공격력 {1}" .format(self.hp,self.damage)) marine1= Unit("마린",40,5) #객체 marine2= Unit("마린",40,5...
ac56d4903f91b26bceda36ead120fc3d59b3a930
king-menin/AaDSaP3_fZtH
/L3/code/coding_size.py
617
3.625
4
import sys import chardet beer = "🍺 some" print([sys.getsizeof(beer[:index]) for index in range(len(beer) + 1)]) easy = "easy" изич = "изич" 易易易易 = "易易易易" print([sys.getsizeof(easy[:index]) for index in range(len(easy) + 1)]) print([sys.getsizeof(изич[:index]) for index in range(len(изич) + 1)]) print([sys.getsizeof...
82f02cc24aa04619826d0b51457e2bc9103beb72
mattcosta5651/CSCI247-Python
/Exams/Exam 5/PetStore.py
1,708
3.890625
4
import json import Functions #reads JSON from a file def readFile(filename): products = "" for line in open(filename): line = line.strip() products = products+line return json.loads(products) #maps categories to list of products in category def mapCategories(json): d = {} for obj in json: if not(obj.get(...
15f8becc118c0149ef2ec88ca749224c3faf8fc0
ed1rac/Mini-Curso-de-Python-3.0
/Fontes/Estruturas de Dados/pesquisa_binaria-RBONTIN001ET.py
909
3.890625
4
# coding=utf-8 def exibe_lista(lista): #for i in lista: print(lista) def pesquisa_binaria(lista, item): primeiro = 0 ultimo = len(lista) - 1 while primeiro <= ultimo: meio = int((primeiro + ultimo) / 2) chute = lista[meio] if chute == item: return meio i...
345075b8a0be533cca019337a852bf0eaeca90a5
njuro/advent-of-code-2017
/day7/tower.py
3,429
3.8125
4
''' https://adventofcode.com/2017/day/7 ''' import re from collections import defaultdict class Program: def __init__(self, name, weight, children): self.name = name self.weight = int(weight) # Weight of this program + weight of all his children self.total_weight = self.weight ...
db6a53ed85092d9a815de88ee8c8ca07ae191daa
gaogep/LeetCode
/剑指offer/15.机器人的运动范围.py
1,288
3.5
4
# 地上有一个m行n列的方格,一个机器人从坐标(0, 0)的格子开始 # 移动,它可以每次向上下左右移动一格,但不能进入行坐标和列坐标 # 之和大于K的格子.例如,当K为18的时候,机器人能够进入方格 # (35, 37),因为3+5+3+7=18.但它不能进入方格(35, 38) # 因为3+5+3+8=19,请问该机器人能够到达多少个给子 def movingCount(rows, cols, k): if k < 0 or rows <= 0 or cols <= 0: return 0 visited = [[False for col in range(cols)] for row in...
428a890ca3e6c1ec58c15b04078ac284ce2d46b0
kriti-ixix/python-10
/python/loops.py
271
3.828125
4
count=0 while count<5: print(count) count=count+1 l=list(range(3,30,3)) print(l) for x in range(1,6): print(x) for x in range(65,91,1): print(chr(x),end=' ') count=35 for x in range(0,10): count=count-1 if x==2: break print(count)
f8a694383539c599911f49c6f75b280755d2aa0a
hutu23/machine-learning
/mooc/demo/python/程序控制语句.py
466
3.890625
4
""" 选择结构^^^ 条件分支语句 *if 判断条件: if语句块 *if-else 语句 if 判断条件: else : *if-elif_else 语句 if x<y: elif x>y: else: if 条件表达式 打印较大的值 print(a if a>b else b) 循环条件^^^ *while 循环条件: 循环体 *for for 标识符 in 可迭代对象: 循环体 *range()函数 range(起始数字,结束数字,步长) sum=0 for i in range(101): sum+=i print('1~100 sum:',sum) """
fa91e1f028411998c3454065153168058e24ebdd
UX404/Leetcode-Exercises
/#290 Word Pattern.py
1,711
4.125
4
''' Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str. Example 1: Input: pattern = "abba", str = "dog cat cat dog" Output: true Example 2: Input:pattern = "abba", str = "dog c...
ae0a9b7f0450fa15612a7f699c68b3fcaa95fec3
Emanhamza75/Python_course
/6_if.py
2,078
3.953125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Author : Ahmed Shaaban Date : Sep 13, 2021 Purpose: demonstrating if condition """ x=4 if (x>0): print("x is larger than zero") #%% # on blocks # if block statment "must" be indented. decision = True if (decision == False): print("We are using Python") ...
feeb0ce229086ff32212da36550fa45aa35a3d53
ranakhalil/CarND-Path-Planning-Project
/excercies/search.py
7,254
3.9375
4
from collections import deque # ---------- # User Instructions: # # Define a function, search() that returns a list # in the form of [optimal path length, row, col]. For # the grid shown below, your function should output # [11, 4, 5]. # # If there is no valid path from the start point # to the goal, your fun...
e634d123f63a9a1de7e6ee5fceb21b1705dafe4e
bigming2018/naver_ds_competition
/Python_For_Everyone/Chapter07/ex_04.py
734
3.75
4
# 파일 내용 검색하기 fhand = open('C:\\Users\\Administrator\\Desktop\\hello.txt') for line in fhand: if line.startswith('텍스트'): print(line) fhand2 = open('C:\\Users\\Administrator\\Desktop\\hello.txt') for line2 in fhand2: line2 = line2.rstrip() # 오른쪽 공백 제거 if line2.startswith('텍스트'): print(line2)...
acbf2c237585ab7023daa470ac481bb5a1ecf8f0
Gabriel-Marinho-CA/Python-
/Python/aula 1 - CFB/aula01.py
2,209
4.34375
4
# Artibuindo variaveis, ele é divido por linhas, da pra atribuir maiis de uma variavel em um mesmo nome ex: nome = gabriel nome = 123, pra ysar isso na mesma linha tem que usar o ;# Nome = "Gabriel" Curso = "Ciencia da cc" print(Nome + " do curso " + Curso) #concatenação = ' + '# if 10>2: print('maior') #...
dddefd891609376ec0ba3bcdcc6d07a4b8b70cb8
Onelky/DevOps-Calc
/calc.py
517
3.65625
4
class Calculadora: def sumar(self, num1, num2): if num1 < 0 or num2 < 0: return 'False' return num1 + num2 def restar(self, num1, num2): if num1 < 0 or num2 < 0: return 'False' return num1 - num2 def multiplicar(self, num1, num2): if num1 < 0...
04fb88f9968ae4ec3abe4f2a34c5b46bacb45a19
LouisU/practice
/leetcode/1011.py
2,370
3.5
4
# -*- coding: utf-8 -*- # author = "Louis" # 传送带上的包裹必须在 D 天内从一个港口运送到另一个港口。 # 传送带上的第 i个包裹的重量为weights[i]。每一天,我们都会按给出重量的顺序往传送带上装载包裹。我们装载的重量不会超过船的最大运载重量。 # # 返回能在 D 天内将传送带上的所有包裹送达的船的最低运载能力。 # # # 示例 1: # # 输入:weights = [1,2,3,4,5,6,7,8,9,10], D = 5 # 输出:15 # 解释: # 船舶最低载重 15 就能够在 5 天内送达所有包裹,如下所示: # 第 1 天:1, 2, 3, 4, 5 # 第 ...
84a8aad2e365965eef7040f49e65d941e0b530ed
bryanbernigen/ITBSem1
/Python/Tubes1/Source Code ATM/A_daftar.py
4,111
4.03125
4
''' Daftar user baru ''' #KAMUS #username = string #pin, NIK, lahir = int #saldo = float #conn = deklarasi koneksi kedatabase #c = cursor untuk database #ALGORITMA def start(): import os import sqlite3 import time # innitiate connection conn = sqlite3.connect('data.db') # create a cursor ...
320ec08caf6b7151ad31ab38105ed816568794ef
kundan4U/Python
/Core Python/Array_Input2.py
246
3.8125
4
# Input using while Loop from array import * stu_roll=array('i',[]) n=int(input("PLease Enter how many Element you want")) i,j=0,0 while i<n: stu_roll.append(int(input("Enter Element"))) i+=1 while j<n: print(stu_roll[j]) j+=1 print(stu_roll)
e855100b37d42632562355f4c555c950bd9ff47a
NoswinBenny/learningtkinter
/learningtkinter.py
502
3.8125
4
import tkinter from tkinter import StringVar, ttk root = tkinter.Tk() name = tkinter.StringVar() name_entry = ttk.Entry(textvariable=name) display_name = StringVar() display_name.set('your name is') label = ttk.Label(root, textvariable=name) def add(): global name name = display_name...
acf8884936c260d911064e393be8b6f13802b556
sondotat123/fix_homework2
/vẽ_rùa2.py
359
3.96875
4
from turtle import * speed(0) for i in range (6): forward(100) left(360/6) color("red") for i in range (5): forward(100) left(360/5) color("blue") for i in range (4): forward(100) left(90) color("red") for i in range (3): forward(100) left(120) color("blue") mainloop()...
785b5ff72f9c5876c5a26b4706511741b62c6f9e
szeitlin/interviewprep
/string_repeats.py
2,479
3.984375
4
""" Lilah has a string, s, of lowercase English letters that she repeated infinitely many times. Given an integer, n, find and print the number of letter a's in the first n letters of Lilah's infinite string. For example, if the string s='abcac' and n=10, the substring we consider is 'abcacabcac', the first 10 charac...
5e29b8d93cbc8843aa9b4ce620af657dd0c90e61
rkguptaaa/PythonProgram
/calculate_age.py
162
3.953125
4
from datetime import date birth_year = input("Please enter your birth year: ") current_year = date.today().year age = current_year - int(birth_year) print(age)
f5fc411bdffefbb5ad0908f975074c26ba8f1966
bidulkin/Havard-CS50--2019-Solutions
/Pset6/bleep/bleep.py
973
3.578125
4
from cs50 import get_string from sys import argv def main(): # check the number of command-line arguments check(argv) # dictionary dictionary = argv[1] # load the dictionary List = load(dictionary) # get text fro the user text = get_string("What message would you like to censor?\n"...
5dcede4165b01956321c88b6413f5550c08b5587
gabriellaec/desoft-analise-exercicios
/backup/user_174/ch35_2020_10_01_20_30_33_390052.py
187
3.828125
4
lista=[] i=0 while i<len(lista): numeros=int(input("Que numeros?") if numeros[i]==0: lista.append=[numeros[i]] print(lista)
952b0bdd42b368314ca2d740252e3f2ec08bb164
nayulbak1/TIL
/07_swea/2019.py
83
3.671875
4
N = int(input()) a = 1 for i in range(N): print(a, end=' ') a *= 2 print(a)
afbb3543993ed3824a97cbdefea0a84ea6d3fb17
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/bob/3cc5bb44f2e048938a271d19544c6ea2.py
465
3.515625
4
def nothing(arg): return True if arg is None or arg.strip() == '' else False def shouting(arg): return True if arg.isupper() else False def question(arg): return True if arg.strip().endswith('?') else False def hey(arg=None): response = 'Whatever.' if nothing(arg): response = 'Fine. Be...
8eb203987088dc8abd45823e36a07bdf70c74c7d
adsteen/growthcurves_frontend
/growthcurves.py
1,266
3.78125
4
# Intro python script to use streamlit to deal with modeling # Currently copied from streamlit plotting example import streamlit as st import pandas as pd import numpy as np # Leftover; I'm not really sure what these do progress_bar = st.sidebar.progress(0) status_text = st.sidebar.empty() # Title the app st.title("...
a9be18dd79a9be7e68746963ef5a7cff8370c535
Sharovatov-N/Python
/lesson3/3dz4.py
1,365
4.25
4
""" Программа принимает действительное положительное число ​ x и целое отрицательное число y​ . Необходимо выполнить возведение числа ​ x в степень ​ y​ . Задание необходимо реализовать в виде функции ​ my_func(x, y)​ . При решении задания необходимо обойтись без встроенной функции возведения числа в степень. Подсказка...
1ded8c5907965dc23782f43ef538319455284aa8
arunachalamev/PythonProgramming
/Algorithms/LeetCode/L1272removeInterval.py
927
3.90625
4
# Given a sorted list of disjoint intervals, each interval intervals[i] = [a, b] represents the # set of real numbers x such that a <= x < b. # We remove the intersections between any interval in intervals and the interval toBeRemoved. # Return a sorted list of intervals after all such removals. def removeInterval(in...
9d97913fe5c2657fb88deeea84298ec8512f9d83
Jinsaeng/CS-Python
/al4995_Hw_01_q3.py
353
3.6875
4
#3 #a) def sum_squares(n): total = 0 for x in range(n): total += x**2 return total #b) return sum([x**2 for x in range(n)]) #c) def sum_odd_square(n): total = 0 for x in range(n): if x%2 == 1: total += x**2 return total #d) return sum([x**2 ...
87d6f12766b82e0851e6b6a4a6de6f02acd456b3
Bishwamitra1/learningapythoncode
/writeread.py
360
3.875
4
file = open('input.txt','w') # open the file file.write('first text,dhdhfdhfk,sddsdsdd\n') # write to the file file =open('input.txt', 'a') # open the file to append mode file.write('Adding text,sdfsdsd,sdfsdfsd\n') file =open('input.txt', 'r') # open the file in read mode content = file.read() # read the content o...
727453d0e87461fd99acb11fe06682d81e471f1f
brandoneng000/LeetCode
/medium/809.py
703
3.546875
4
from typing import List class Solution: def expressiveWords(self, s: str, words: List[str]) -> int: def helper(word: str, s: str): j = 0 for i in range(len(s)): if j < len(word) and s[i] == word[j]: j += 1 elif s[i - 1: i + 2] != s...
909651b0e6a7c4170c97800dcfaddc7167a62197
shunz/Python-100-Days_Practice
/Day05/prime.py
338
3.53125
4
''' 输出100以内的所有素数 素数指的是只能被1和自身整除的正整数(不包括1) ''' count = 0 ranges = 200 for n in range(1, ranges): for f in range(2, n): if n % f == 0: break else: print(n, end=' ') count += 1 print('\n%d以内的素数一共%d个' % (ranges, count))
5766e5d302a7345f549830ae06ae6bed861ad28b
Mikle100500/Knowledge
/unit_test_cars_list_class.py
928
3.625
4
import unittest from class_cars import find_car, Car cars_list = [ Car("BMW", "M5"), Car("BMW", "M3"), Car("Porsche", "911"), Car("Mercedes", "G63"), Car("Morgan", "Aero"), Car("Alpha Romeo", "Julette"), ] class TestCarsList(unittest.TestCase): def test_bmw(self): filter_bmw = fin...
f435e1753a5888e9f786f578988e27187dd1a526
olanlab/python-bootcamp
/13-gui/gui-05.py
606
3.796875
4
import tkinter as tk from tkinter import messagebox root = tk.Tk() def show_info(): messagebox.showinfo("Information", "This is an info message!") def show_warning(): messagebox.showwarning("Warning", "This is a warning message!") def show_error(): messagebox.showerror("Error", "This is an error message...
64a985eadacca78ece5462a9b730e899596834bb
nidhiatwork/Python_Coding_Practice
/Stacks_Queues/04-queue-via-stacks-my.py
529
4.09375
4
""" Implement a queue using two stacks. """ class QueueViaStacks: def __init__(self): self.in_stack = [] self.out_stack=[] def push(self, item): self.in_stack.append(item) def remove(self): if len(self.out_stack)==0: while len(self.in_stack)...