blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
7fb7aa6324e74179d86498a8e575280621df28ca
gwuah/ds-algorithms
/leetcode/search-matrix.py
494
4.03125
4
def search_matrix(matrix, target): for row in matrix: last_element = row[-1] if last_element > target: for element in row: if element == target: return True elif last_element == target: return True return False matrix = [[1, 3...
e2d8f5e804f783e56d281f6c3cb6b6346d18e924
shchrbkv/python-oop
/task5/terminal.py
2,008
3.65625
4
import os import threading from pizza import Pepperoni, BBQ, Seafood from order import Order from handout import Handout class Terminal: menu = [Pepperoni(), BBQ(), Seafood()] def greet(self): os.system("clear") print("{:-^40}".format("Welcome to Pizza Time")) def start(self, code): ...
ac88240149a6377fedacfc3a157973c287512196
etasycandy/Python
/Workshop5/Project_page165_166/Project_05_page166.py
2,112
4.28125
4
""" Author: Tran Dinh Hoang Date: 16/08/2021 Program: Project_05_page166.py Problem: 5. In Chapter 4, we developed an algorithm for converting from binary to decimal. You can generalize this algorithm to work for a representation in any base. Instead of using a power of 2, this time you use a ...
fda54f609aed5dce2c91cdd22eec7cc9868dc9ac
sairajbhise98/Python-Study
/Data Structures in Python/Heap/heap.py
1,041
3.796875
4
''' ------------------------------------------------------------- Code By : Sairaj Bhise Topic : Data Structures and Algorithms (Heap Data Structure) ------------------------------------------------------------- ''' def heapify(arr,n,i) : largest = i l = 2*i + 1 r = 2*i + 2 if l<n and arr[i] < arr[l]: large...
6a4a679906d5b148b3c94cffca4fec8abdc2f234
Toshiyana/atcoder_study
/ABC/B_problems/150.py
353
3.578125
4
# 自分の回答(なぜかRE) # N = int(input()) # S = input() # count = 0 # for i in range(N): # if S[i] == 'A': # if S[i+1] == 'B': # if S[i+2] == 'C': # count += 1 # print(count) # 他人の模範回答 N = int(input()) S = input() t = 'ABC' count = 0 for i in range(N-2): if S[i:i+3] == t: count += 1 print(count)
149aed7c5a6ccca131683aeecb70beb33c2c1638
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_135/1270.py
1,600
3.53125
4
def magic(case, first_ans, second_ans, first_square, second_square): first_line = first_square[first_ans - 1] second_line = second_square[second_ans - 1] ans = -1 counter = 0 for number in first_line: if number in second_line: counter += 1 ans = number if cou...
8de6b29ba2a3c5462410cbb4bcb48cd9ea7bbfd2
uday4a9/python
/ds/sll_lib.py
2,316
4
4
from functools import wraps import sys def read_value(): a = input("Enter a value to insert in list: ") return a class Node: _value = 123123 __v2 = 321 def __init__(self, val): self._data = val self._next = None self.__v3 = 123 def get_value(self): return self....
de6f68918689e0312ec0c2c7d6665f70e38d0e98
narutoamu/SPOJSolutions
/BEENUMS.py
177
3.71875
4
import math while(1): x=input() if x == - 1: break x=(4*x-1)/3 if int(math.sqrt(x))**2 == x: print "Y" else: print "N"
39e9261d28102758dc4a4e8249c3a44b3aecfb14
class-yoo/practice02
/practice02.py
2,621
3.734375
4
# 문제2. 다음과 같은 텍스트에서 모든 태그를 제외한 텍스트만 출력하세요. # s = """ # <html> # <body style='background-color:#ffff'> # <h4>Click</h4> # <a href='http://www.python.org'>Here</a> # <p> # To connect to the most powerful tools in the world. # </p> # </body> # </html>""" # # exceptTag ='...
3a419d704acc510f0b8f967cc19d268596c1527a
airtoxin/mymodule
/stablesort.py
2,706
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from numpy import array def stable_sort_by_column(arr, column_index, element_index=None): u""" stable matrix sorting using column key. input: arr: numpy 2D or (3D) array. If arr is 3D, we assume most inner array as stable ele...
c6c214a1d26fcdec2f19720aeb4f5f08c774f503
skyeaaron/ICU
/SampleInputs/gzip_file.py
540
3.9375
4
""" Gzip a file. For example, python gzip.file input_file.txt will gzip input_file.txt to input_file.txt.gz """ import gzip, sys def convert_to_gzip(input_filename, output_filename, input_encoding = 'utf-8', output_encoding = 'utf-8'): """ given an input text file gzip it """ with open(input_f...
2b5ec0059f23938457f4ff2f1a78c21d487e7e29
SachinPitale/Python3
/Python-2021/17.Functions/4.function-with-simple-argument.py
700
3.984375
4
""" def get_result(num): #Parameter and positional argument result=num+10 print(f"final result of num is {result}") return None def main(): num=eval(input("Enter your number: ")) get_result(num) #Argument return None main() """ def get_add(p,q): result=p+q print(f"The addition of ...
4dbd7d3735c71513e4344ffaf4fa0cebb320ef35
github641/python-journey
/IpReverse.py
712
3.65625
4
def tranFromIPToInt(strIP): lst = strIP.split(".") if len(lst) != 4: return "error ip" return int(lst[0]) * (256 ** 3) + int(lst[1]) * (256 ** 2) +\ int(lst[2]) * 256 + int(lst[3]) def tranFromIntToIP(strInt): ip1 = 0 ip2 = 0 ip3 = 0 ip4 = 0 ip1 = int(strInt) / (256 **...
f740f11765f2123c78e0c69ed66b27083f69b374
lt910702lt/python
/day05/02 作业讲解.py
6,426
3.640625
4
#######第一题:写代码,有如下列表,按照要求实现每一个功能 #li = ["alex", "WuSir", "ritian", "barry", "wenzhou"] # # 1)、计算列表的长度并输出 # print(len(li)) # # 2)、列表中追加元素“seven”,并输出添加后的列表 # li.append("seven") # print(li) # # 3)、请在列表的第一个位置插入元素“Tony”,并输出添加后的列表 # li.insert(0, "Tony") # print(li) # # 4)、请修改列表的第2个位置的元素为“Kelly”,并输出修改后的列表 # li[1] = li[1].r...
1d15d0e9a49b7ef60ba7910fef96b4add5634aa0
chuzyrepo/pythonstudy
/demo20180604/format.py
1,144
3.875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #在Python中,采用的格式化方式和C语言是一致的,用%实现,举例如下: print('hello, %s' % 'world') #%运算符就是用来格式化字符串的。在字符串内部,%s表示用字符串替换,%d表示用整数替换, # 有几个%?占位符,后面就跟几个变量或者值,顺序要对应好。如果只有一个%?,括号可以省略。 print('hi %s,you have $%d'%('张三',100000)) #格式化整数和浮点数还可以指定是否补0和整数与小数的位数: print('%2d-%02d' % (3, 1))#%2d意为以固定的两位位宽来...
97718678a848e93cdf447301c113777621aa473c
polly-rm/python_advanced
/4.Exercise-Comprehensions.py
4,781
3.671875
4
# 1.Word Filter # result = [el for el in input().split() if len(el) % 2 == 0] # for word in result: # print(word) # 2.Words Lengths # result = {word: len(word) for word in input().split(', ')} # final = [f'{key} -> {value}' for key,value in result.items()] # print(', '.join(final)) # 3.Capitals # cou...
a533edf2f91a854679ccddc5226bf56862c2f727
ljrdemail/AID1810
/PythonBasic/Day08/exec6.py
320
3.703125
4
L = list() def input_number(num): return L.append(num) while True: num = int(input("请输入整数,以负数结束:")) if (num < 0): break else: input_number(num) print("列表为:",L) print("最大值为:", max(L)) print("最小值为:", min(L)) print("和为:", sum(L))
8279936b0d5d63ef1827256932f943eec1c2e84e
garciaha/DE_daily_challenges
/2020-07-08/concert.py
1,360
4.375
4
""" Concert Seats Create a function that determines whether each seat can "see" the front-stage. A number can "see" the front-stage if it is strictly greater than the number before it. Everyone can see the front-stage in the example below: FRONT STAGE ------------ [[1, 2, 3, 2, 1, 1], [2, 4, 4, 3, 2, 2], [5, 5, 5, 5,...
38e71de37925b3bee6c6a8453ea60f8ca1486c3c
casssax/make_ff
/Scripts/sub_scripts.py
2,656
3.578125
4
import csv import sys def fill_zero_length(fields): for e in range(len(fields)): if fields[e] == 0: fields[e] = 10 return fields def max_length(data): first_flag = 1 fields = [] for get_line in data: line = list(get_line) if first_flag == 1: for i in...
82ecc3e32e7940422238046cd7aa788979c51f9c
KurinchiMalar/DataStructures
/Stacks/Stack.py
1,115
4.125
4
from LinkedLists.ListNode import ListNode class Stack: def __init__(self,head=None): self.head = head self.size = 0 def push(self,data): newnode = ListNode(data) newnode.set_next(self.head) self.head = newnode self.size = self.size + 1 def pop(self): ...
1664b4e465dee4c24c2274aa04a494b7d7314d1d
ceteongvanness/100-Days-of-Code-Python
/Day 5 - Beginner - Python Loops/3. Adding Even Numbers/main.py
329
4.125
4
total_height = 0 for height in student_heights: total_height += height print(f"total height = {total_height}") number_of_students = 0 for student in student_heights: number_of_students += 1 print(f"number of students = {number_of_students}") average_height = round(total_height / number_of_students) print(averag...
1ff053604ad0e3d5508dd993f9c47e5d76e1d380
urazbayevr/Pythonchik
/btcmp_self_study/File_IO/CSV_reader.py
1,089
3.90625
4
# THIS DOES READ THE FILE BUT IT DOESN'T PARSE IT! # BAD!!!!!! #with open("fighters.csv") as file: # data = file.read() # Using reader # from csv import reader # with open("fighters.csv") as file: # csv_reader = reader(file) # next(csv_reader) #To skip the headers # for fighter in csv_reader: # # Each...
b79de13ef7ae6e4a9f469855b8278032fc836a9f
thiago-ximenes/curso-python
/pythonexercicios/ex025.py
138
3.828125
4
nome = str(input('Digite o nome de uma pessoa: ')).strip() print('It is {} that has Silva in the name!'.format('Silva' in nome.title()))
9d75dbf4e1c21a7917d107d2797f7cb91af93b7b
FangyangJz/Black_Horse_Python_Code
/第一章 python基础/02 python基础_days07/function_多值参数求和.py
421
4.09375
4
# !/usr/bin/env python # -*- coding:utf-8 -*- # author: Fangyang time:2017/11/13 def sum_numbers(*args): num = 0 print (args) for n in args: num += n return num result = sum_numbers(1,2,3,4,5) print result def sum_numbers_cmp(args): #这里 num = 0 print (args) for n in args...
3707aaec786a745c7343f19704b5666a1a001529
pauladam2001/Sem1_FundamentalsOfProgramming
/a4-pauladam2001/src/domain/entity.py
2,995
3.640625
4
""" Domain file includes code for entity management entity = number, transaction, expense etc. """ def set_newValue(contestantNumber, problemNumber, newValue, listOfContestants): """ Sets a new value for a given problem input: contestantNumber - the position of the contestant problemN...
f61ba2fdb135aa17619c1b9832ff764ac554a058
brijkishorsoni1210/library-management-system
/lib_man_sys.py
4,467
3.5
4
import datetime import os class LMS: def __init__(self,list_of_books,library_name): self.list_of_books="List_of_books.txt" self.library_name=library_name self.books_dict={} Id=101 with open(self.list_of_books) as bk: content=bk.readlines() for li...
ecd07767c66ce60d577f8b82f311eebcd180aabb
nurgalix/CoursePython
/anagrammav2.py
2,021
4.03125
4
import random WORDS = ("пайтоннеговно", "превысокомногорассмотрительствующий", "тысячадевятьсотвосьмидесятидевятимиллиметровый", "водогрязеторфопарафинолечение", "человеконенавистничество", "папич") word = random.choice(WORDS) jumble = "" correct = word attempt = 1 temp = 0 ...
6c4dd0b36ff01e6261f3be4aa5c2f68514926f92
kporcelainluv/1_month_commit
/5_day/5_1.py
237
3.71875
4
def update_dictionary(d, key, value): new_key = int(key)*2 if key in d: d[key] += [value] if key not in d: if new_key not in d: d[new_key] = [value] else: d[new_key] += [value]
010ffd53a3858f3970f476c7029274cbd7145a0f
ivenpoker/Python-Projects
/Projects/Online Workouts/w3resource/Basic - Part-I/program-144.py
1,248
4.5
4
#!/usr/bin/env python3 ####################################################################################### # # # Program purpose: Check if an variable is of integer type or string type. # # Program Author : Happi ...
c1a22c939ff90ed3b2dbb566830e7bae7c0c4ecf
laloxxx20/Ant-Colony
/place.py
1,154
3.71875
4
class Place(object): value = 0 position = (0, 0) neighbors = [] value_pheromone = 0 prev_neighbor = None # Place object value_to_up_phero = 0.1 def __init__(self, pos, value, neighbors): self.position = pos self.value = value self.neighbors = neighbors def set...
7615bd44ef8f50b0779bf68b1f234d9db6b5d7d5
yang4978/Coding-Interviews
/2 - Basic Knowledge/0013. Implement strStr().py
361
3.640625
4
class Solution: """ @param source: @param target: @return: return the index """ def strStr(self, source, target): if(len(source)==0 and len(target)==0): return 0 result = -1 for i in range(len(source)): if(source[i:i+len(target)]==target): ...
2360506764d57b9af4c31f79f3d91a12d9e9baf6
tohanyich/Algorithms-theory-and-practice
/haffman_encoding.py
3,939
3.640625
4
import heapq from collections import Counter class Node: def __init__(self, left=None, right=None, data=None, value=None, code=''): self.left = left self.right = right self.data = data self.value = value self.code = code def __str__(self): return 'Node ['+str(...
9455a4ec8080467bb93c72bf507dcdbda454fa61
smoil-ali/Word-Order
/Word Order.py
197
3.5
4
from collections import defaultdict d = defaultdict(list) for x in range(int(input())): y=input() d[y].append(1) print(len(d)) for i,j in d.items(): print(sum(j),end=" ")
a6bcda3810e234b407939058dac21d034d8ba114
Zu1uDe1ta/Personal-Project-The-First-Troll-Under-The-Bridge
/exam1/gregorian_cal_utils.py
506
4.34375
4
def is_leap_year(year: int) -> bool: """ Given a year, this function returns a boolean indicating whether or not it is a leap year. :param year: an integer indicating a year. :return: A boolean indicating whether or not the year parameter is a leap year. """ if year % 4 == 0: if year % ...
87d1db6ca9af94a34ba4cdd74311ebd96bfbb15f
anatrevis/xaman
/utils.py
5,296
4.125
4
import datetime import re def extract_date(input, app): """Verify if user input contains one and only one valid date and extracts it from string. :param input: string with input from the user :param app: flask app used for system logging :return: boolean that indicates if date is within range """...
01094b8a4268491022850be92d175bb2214ee19c
dg5921096/Books-solutions
/Python-For-Everyone-Horstmann/Chapter6-Lists/P6.18.py
1,577
4.15625
4
# It is a well-researched fact that men in a rest room generally prefer to maximize # their distance from already occupied stalls, by occupying the middle of the longest # sequence of unoccupied places. # For example, consider the situation where ten stalls are empty. # _ _ _ _ _ _ _ _ _ _ # The first visitor will ...
cd6d234f6649ebcaca343a782149baf95021fd98
dimitar-daskalov/SoftUni-Courses
/python_advanced/labs_and_homeworks/01_lists_as_stacks_and_queues_exercise/10_cups_and_bottles.py
817
3.59375
4
from collections import deque cups_queue = deque(int(cup) for cup in input().split()) bottles_list = [int(bottle) for bottle in input().split()] wasted_water = 0 are_filled = True current_cup = cups_queue[0] while cups_queue: current_bottle = bottles_list[-1] if current_bottle - current_cup >= 0: wa...
421879ec85d22de86099aba61df9efcf1df71261
NallamilliRageswari/Python
/Square_of_sorted_array.py
645
4.25
4
''' Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order. Example 1: Input: nums = [-4,-1,0,3,10] Output: [0,1,9,16,100] Explanation: After squaring, the array becomes [16,1,0,9,100]. After sorting, it becomes [0,1,9,16,100]....
fff7795d319f61a550286809925c0c053364f96d
NHTdz/baitapthem
/list_getfirstsecond.py
150
3.5
4
list = [77,53,457,108,98,23,55] list_new = sorted(list) print("First score is:" + str(list_new[-1])) print("First score is:" + str(list_new[-2]))
5d1316339baaa3d3610dbb8ed564ce641756ba9b
jashidsany/Learning-Python
/LCodecademy Lesson 10 Classes/LA10.10_Self.py
1,127
4.125
4
# If we were creating a search engine, and we wanted to create classes for each separate entry we could return. We’d do that like this: # class SearchEngineEntry: # def __init__(self, url): # self.url = url # codecademy = SearchEngineEntry("www.codecademy.com") # wikipedia = SearchEngineEntry("www.wikipedia.or...
2f9d8f3eebf4f3b45b4977e673b6a7fd1dbc7e5f
wmmxk/Nuts_bolts_python_programming
/package/basic_pkg/foo/level2/another_mod.py
90
3.546875
4
def add(a, b): print("modify 4") return a+b+1 def multiply(a, b): return a*b
d4717404b1ec9f963765bf1ad9c10d4f63e8617d
commGom/pythonStudy
/알고리즘withPy/카카오기출/2단계_level/뉴스클러스터링.py
774
3.5
4
def solution(str1, str2): answer = 0 str1=str1.lower() str2=str2.lower() str1_=[] str2_=[] for i in range(len(str1)-1): if str1[i].isalpha() and str1[i+1].isalpha(): str1_.append(str1[i]+str1[i+1]) for i in range(len(str2)-1): if str2[i].isalpha() and str2[i+1].is...
9d23c5b5bdbff8332c8d169e5f009c4b2cfc928e
rkovrigin/crypto
/task1.py
4,552
3.640625
4
""" Let us see what goes wrong when a stream cipher key is used more than once. Below are eleven hex-encoded ciphertexts that are the result of encrypting eleven plaintexts with a stream cipher, all with the same stream cipher key. Your goal is to decrypt the last ciphertext, and submit the secret message within it as ...
e083be8b703974cb33388e739314ef2491cd5ff2
frainfreeze/studying
/home/old/python/014.py
231
3.8125
4
def front_times(str, n): if n>=0: if len(str)<3: return str*n return str[:3]*n print(front_times('Chocolate', 2)) #'ChoCho' print(front_times('Chocolate', 3)) #'ChoChoCho' print(front_times('Abc', 3)) #'AbcAbcAbc'
18348b5ecefe399f7ffa76bb6227ce4e38156413
ShengHow95/basic-algorithm-examples
/palindrome_permutation.py
591
3.90625
4
palin_perm = "Tact Coa" not_palin_perm = "This is not palindrome permutation" def is_panlindrome_permutation(s): s = s.replace(" ", "").lower() ht = dict() for i in s: if i in ht: ht[i] += 1 else: ht[i] = 1 odd_count = 0 for key, value in ht.items(): ...
6645119540baad9744c0149d2afa2d5f9c13a2a5
pydevjason/Python-VS-code
/class_str_and_repr_methods.py
264
3.71875
4
class Card(): def __init__(self, rank, suit): self.rank = rank self.suit = suit def __str__(self): return f"{self.rank} of {self.suit}" def __repr__(self): return f"Card('{self.rank}', '{self.suit}')" c = Card("Ace", "Spades") print(c) print(repr(c))
3eb72a7054419f9a2374201011fceac231feecf9
syurskyi/Algorithms_and_Data_Structure
/_algorithms_challenges/leetcode/LeetCode/964 Least Operators to Express Number.py
2,708
4.21875
4
#!/usr/bin/python3 """ Given a single positive integer x, we will write an expression of the form x (op1) x (op2) x (op3) x ... where each operator op1, op2, etc. is either addition, subtraction, multiplication, or division (+, -, *, or /). For example, with x = 3, we might write 3 * 3 / 3 + 3 - 3 which is a value of ...
720667900e9990fb8af11b7972fe71e37cdc9f5f
adi1201239/b
/Q_1.py
179
3.734375
4
a = 40; b = 10; print("Addition of two number", a+b) print("Subtraction of two number", a-b) print("Multiplication of two number", a*b) print("Division of two number", a/b)
e98685864b2cdddaa2979d9d64fcf61fa07178fb
mozi-h/TicTacToe2
/mode2.py
3,796
3.734375
4
from os import system game = [0, 0, 0, 0, 0, 0, 0, 0, 0] char_lookup = {0: "-", 1: "X", 2: "O"} turn = 1 not_turn = [0, 2, 1] to_check = [ # Combinations of fiels a player needs to own to win [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6] ] def cls(): system(...
e89251de8d98197ee8dc05a305cb0e9e076fe66e
nikhilmborkar/fsdse-python-assignment-1
/square_of_numbers.py
167
3.578125
4
def squareOfNumbers(n): square_of_numbers = {} for i in range(1, n+1): square = i*i square_of_numbers[i] = square return square_of_numbers
8b21746260ec87df5c12d36f349ad44275f9dcc1
Vadskye/rise-gen
/rise_gen/combat.py
7,564
3.6875
4
#!/usr/bin/env python3 import argparse from rise_gen.creature import Creature import cProfile from pprint import pprint class CreatureGroup(object): """A CreatureGroup is a group of creatures that acts like a single creature """ # TODO: move dead creatures to the end of the array when they die def __init...
c2b7874fa24a0c58fa65831b44175de2423401bd
g-hurst/Python-For-Teenagers-Learn-to-Program-Like-a-Superhero-codes
/pygame animation.py
2,753
3.59375
4
import pygame from pygame.locals import * import sys import random pygame.init() # varriables gameQuit = False move_x = 300 move_y = 300 #creating colors stored in tuples colorWHITE = (255, 255, 255) colorBLACK = (0, 0, 0) colorRED = (255, 0, 0) # creates and names the window that is created gameW...
dd1199d0424531068d907ac702239bcb8cf5fbbd
zjwyx/python
/day05/02_字典.py
2,383
3.84375
4
# dic = { # '太白':{'name':'太白金星','age':18,'sex':'男'}, # 'python22期':['主管梁','大壮'] # } # 键必须是不可变的数据类型 int str # 值可以是任意数据类型,对象 # 字典在3.5之前时无序的 # 字典在3.6版本初建字典的顺序排列 # 字典的优点:查询速度非常快,存储关联型的数据 # 字典的缺点:以空间换时间 # 字典的创建方式 # 方式一: # dic = dict((('one',1),('two',2),('three',3))) # print(dic) # 方法二: # dic = dict(one = 1,two=...
b2ae20973445522b94b71212cd975c1b2b469663
ShiinaMashiro1314/Project-Euler
/Python/381.py
294
3.734375
4
import math def is_prime(x): if(x <= 1): return False if(x == 2): return True for i in xrange(2,int(math.floor(math.sqrt(x)))+1): if(x % i == 0): return False return True result = 0 for i in xrange(5,100): if(is_prime(i)): result += i - 101%i print (i - 101%i) print result
609e12af50ebea7535ac2665ae93079a2a08b6fd
daisyang/data_structure_and_algorithm
/Merge2sortedlist.py
466
4
4
# You are given two sorted arrays, A and B, and A has a large enough buffer at the end to hold B. Write a method to merge B into A in sorted order. def Merge(a,b,m,n): if b is None: return a ind1 = m -1 ind2 =n -1 ind = ind1+ind2+1 while (ind>=0): if ind1 >=0 and a[ind1] > b[ind2]: a[ind]=a[ind1] ind1-=1...
033293c5486cb0a55c3debbe50afcea74c3a947f
manuelcerdas/python_projects
/PlotMovies/classifier.py
1,135
3.53125
4
import numpy as np def classify0 (newPoint, dataSet, labels, k): # Get the ammount of rows in the data set numRows = dataSet.shape[0] #Create a matrix the same size as the data set, but in this case all the rows are the new point newSet = np.tile (newPoint,(numRows,1)) # we use Eu...
83a2faad463d579002f7c673a90ac9d4b65fb36b
amani021/python100d
/day_39.py
214
4.0625
4
#-------- DAY 39 "exercise1" -------- def rec(num, power): if power > 0: result = num * rec(num, power-1) else: result = 1 return result print('The result of 5 x 5 x 5 is:', rec(5, 3))
ba8cd9b8cf699e00ae7865fab95cdc16a20dac93
julienemo/exo_headfirst
/11-jeu_de_vie.py
593
3.75
4
def set_grid(length, width): grid = [0] * length for i in range(length): grid[i] = [0] * width return grid # def count(): def decide_next(n, count): if n == 0: if count == 3: n = 1 else: n = 0 else: if (count > 3) or (count < 2): ...
38aa843a83904894f86e1c447fcdb138b281a370
luckeyme74/tuples
/tuples_practice.py
2,274
4.40625
4
# 12.1 # Create a tuple filled with 5 numbers assign it to the variable n n = ('2', '4', '6', '8', '10') # the ( ) are optional # Create a tuple named tup using the tuple function tup = tuple() # Create a tuple named first and pass it your first name first = tuple('Jenny',) # print the first lette...
aa1b08d0d82a7865d94fd06f9b98c4b8468923d5
MeganathanR/Mega
/case44.py
97
3.609375
4
def num(n): if n in range(1,10): print( "yes") else : print("no") num(9)
183ff08e72916b817864d350e9ed850ccc983162
dnth/Malaysia_License_Plate_Generator
/main.py
2,511
3.546875
4
from fake_plate_generator import Generator import argparse import os ''' Parameters for generators: 1. state (string) = The first alphabets for car plate based on state and territory, must enter full state name Example: "Perak": "A", "Selangor": "B", "Pahang": "C", "Kelantan": "D", "Putrajaya": "F", "Johor"...
d91b59ab8550ee5cc7f2d2c6c5e88da53ed7144d
steview-d/practicepython-org-exercises
/practice_python_org/18_cows_bulls.py
815
3.546875
4
from random import randint def compare(guess, answer): bullcow = [0, 0] for x in range(4): if guess[x] == answer[x]: bullcow[0] += 1 else: bullcow[1] += 1 return bullcow if __name__ == "__main__": answer = ''.join([str(randint(0,9)) for x in range(4)]) coun...
b3ea8d3797a5c55700589cf590a320e8111a4cb4
hgdsraj/pqueue
/pqueue/pqueue/cli.py
570
3.609375
4
import click import sqlite3 conn = sqlite3.connect('queue.db') c = conn.cursor() @click.command() @click.argument('command', default='world', required=False) @click.option('-m', required=False, prompt='Your name', help='The message to push.') @click.command() @click.argument('w', default='world', required=False) @cli...
389a0eeb65e984713ab701e46474ab7d26ca55b5
nickxu/firstPython
/字符串重复多次.py
144
3.875
4
# coding:utf-8 print("words"*3) word = "it's a looooooong loop" num = 12 bang_str = 'bang!' total_result = bang_str * (len(word) - num) print(total_result)
896f1275f4ec13ba74bfd476ff2f38df11bc0d85
ruthlee/combo_opto
/digraph_class.py
2,009
4.0625
4
# goal: implement an adjacency list class for a digraph given a list of inputs that connect two vertices. # We want methods for adding edges by inputting two integers, i.e., 1, 2 means that vertices 1 and 2 are connected. # since class edge: def __init__(self, v, w, weight): self.v = v self.w = ...
c8a52b0cd1fe28e74acccc900e884187715b1961
YeoYeJi0430/Python
/chap5_3.py
1,007
3.921875
4
""" a,b=10,20 print("swap 전", end="") print("a",a,"b",b) a,b=b,a print("swap 후", end="") print("a",a,"b",b) """ """ def call_10_times(func): for i in range(10): func() def print_hello(): print("Hello World") call_10_times(print_hello) """ """ # def power(item): # return item*item #power = la...
0883c8ac348f0edfae849927c0e466c5e8c2aa7c
RameezFridie/Python-String-manip
/amazon.py
2,485
4.40625
4
# ================= BONUS Optional Task ================== # Create a Python file called "amazon.py" in this folder. # Write code to read the content of the text file input.txt. # For each line in input.txt, write a new line in the new text file output.txt that computes the answer to some operation on a list of numb...
3f81f6e2490fcc4e6f7f1f0a40830a8941561a88
PeteMcNie/Playground-Typescript-React-Python
/freeCodeCamp2.py
4,949
3.5
4
from flask import Flask app = Flask(__name__) @app.route('/') def python(): myFile = open('data.txt') for each_line in myFile: print(each_line) a_file = open('data.txt') line_count = 0 for new_line in a_file: line_count += 1 print('Line count', line_count) the_file = ope...
6cf271f3348e29d6d89ba9c33fc8399472ac0cb2
alinasansevich/hello-world
/black_friday_must_do.py
785
3.9375
4
# Inspired by the book "Automate the boring stuff with Python" def print_list(items_dict, left_width, right_width): print('SHOPPING LIST'.center(left_width + right_width, '-')) for k, v in items_dict.items(): print(k.title().ljust(left_width, '.') + str(v).rjust(right_width, ' ')) black_friday_wish_li...
0e8ddff2f59cf42b6d27c89f8832c33dd3aaab86
USCO-CO/test
/guess.py
717
3.859375
4
from random import randint def getRandomNumber (): return (randint(0,100)) def askUser (): num = raw_input("Give me a number: ") return int(num) def compGetNum (): return (randint(0,100)) count = 1 correct = False print "Welcome to the guessing game. Try to pick a number between 1 and 100 before the comput...
107497743ad5d5edb4f1183e32f90b50166abbc9
JaimePazLopes/dailyCodingProblem
/problem047.py
2,338
3.84375
4
# Problem #47 [Easy] # Given a array of numbers representing the stock prices of a company in chronological order, # write a function that calculates the maximum profit you could have made from buying and selling that stock once. # You must buy before you can sell it. # # For example, given [9, 11, 8, 5, 7, 10], y...
7cbd4fcf8326f01a51def77e8dc8584b5a98d4a1
serg-myst/GEEK_Lessons
/Lesson 3/korzhov_sergey_lesson_3_task_3.py
844
3.8125
4
def my_func(*args): my_dict = {} for name in args: """Отбираем имена по первой букве в цикле filter(lambda el: el[:1] == name[:1]""" my_dict.update({name[:1]: list(filter(lambda el: el[:1] == name[:1], args))}) return my_dict result = my_func('Марья', 'Иван', 'Света', 'Петя', 'Марсель', '...
4389e4edd9797bb6584988b59d17f7acb51983a1
TheIrresistible/Python_Advanced_ITEA
/5/3.py
593
3.796875
4
class File: def __init__(self, name, action): self.name = name self.action = action self.status = 1 def __enter__(self): self.file = open(f'{self.name}', f'{self.action}') if self.status == 1: return self.file raise ValueError def __exit__(self,...
a51bf5a90f3b187283e95a7eb6a693ee07ab2524
dipo7/gitload
/rough2.py
392
3.734375
4
def number_palondrome(x, y=0, z=0): steps = 1 y = str(x) y = y[::-1] z = x + int(y) end_sum = True while end_sum: if z == int(str(z)[::-1]): end_sum = False return(steps, z) else: x, y, z = z, str(x)[::-1], x + int(y) number_palondr...
9ac3559f256fad5ff6b2e750bcad512fbcc5c5cc
imzeki/coconut
/maths.py
1,279
4.03125
4
""" Stores math equations and formulas inside """ class EMC2Error(BaseException): """ Error called when EMC2 gone wrong """ pass pi = 3.1415926535897932385 e = 2.7182818284590452354 sqrt2 = 1.4142135623730950488 sqrt5 = 2.2360679774997896964 phi = 1.6180339887498948482 ln2 = 0.69314...
d5290cdf0322731aeb02562035ba6f84246b4f7c
treasureb/Python
/day9/map.py
274
3.890625
4
#-*- coding: utf-8 -*- #map()接收一个函数f和一个list #通过f一次作用在list的每个元素上 def f(x): return x*x print map(f,[1,2,3,4,5,6,7,8,9]) def format_name(s): return s[0].upper()+s[1:].lower() print map(format_name,['adma','LISA','barT'])
786e1e1e027f3e01cebd46dd3154e935e5d83e64
hanhuyeny2k/holbertonschool-web_back_end
/0x0D-NoSQL/11-schools_by_topic.py
267
3.625
4
#!/usr/bin/env python3 """function that returns the list of school having a specific topic""" import pymongo def schools_by_topic(mongo_collection, topic): """query documents in collection""" return mongo_collection.find( {"topics": topic} )
12a76639711736e8a773560a8d96ea6d91455884
avinash-rath/pythonlab
/numpat.py
120
3.734375
4
n = 1 while n <= 9: k = 1 while k <= n: print(n, end='') k = k+1 print(end='\n') n = n+1
ab94061b34a40e4df6d9cbc5e5c4af5db50a417c
papayetoo/StudyinPython
/LeetCode/repeated_substring_pattern.py
487
3.5
4
class Solution: def repeatedSubstringPattern(self, s: str) -> bool: halfLength = len(s) // 2 + 1 for i in range(halfLength, 0, -1): subStr = s[:i] if subStr * (len(s) // len(subStr)) == s: return True return False def repeatedSubstringPattern2(s...
64a2aa835d7e892ad7f278b36377fe6de42f5d82
agabhi017/Algortihmic-Toolbox
/Week 3/q7_max_salary_v2.py
643
4.0625
4
import os import numpy as np def compare_numbers(num1, num2) : combo1 = num1 + num2 combo2 = num2 + num1 if combo1 >= combo2 : return num1 else : return num2 def largest_number(numbers) : largest_numb = [] while len(numbers) > 0 : largest_val = numbers[0] ...
779c28f0f3eca0b3c840d5c3aa5456721c82369d
ofirn21-meet/meet2019y1lab5
/lab_5.py
118
3.859375
4
x,y,z = (3,4,5) print(x+y+z) my_tuple = (3,4,5) print(my_tuple+my_tuple) my_tuple[0]=17 print(my_tuple) x=17 print(x)
9e812ec9ca55fd853f83cd7c375734184c918520
iamrishap/PythonBits
/IVCorner/iress/string_change.py
2,877
4
4
''' You will be given 2 strings and need to make the changes below based on the words “nice” and “niece” and others. String 1- if its nice = insert because you’re putting in an extra e to make niece String 2- niece to nice = delete the extra e String 3: form to from = swap String 4: if its identical String 5: imposs...
79634e67a479e3f268b9061c6174a21919d55ad0
26tanishabanik/Interview-Coding-Questions
/Arrays/MergeTwoSortedArraysWithoutExtraSpace.py
507
4.125
4
""" Given two sorted arrays sort them accordingly with out extra space i.e O(1) Input: ar1[] = {1, 5, 9, 10, 15, 20}; ar2[] = {2, 3, 8, 13}; Output: ar1[] = {1, 2, 3, 5, 8, 9} ar2[] = {10, 13, 15, 20} """ def Merge(a1, a2, n1, n2): for i in range(n1): if a1[i] > a2[0]: a1[i],...
076aba45a5bc725ea97ff099a9a100e079512fec
vunguyenq/adventofcode2019
/00.Code_Template.py
777
3.578125
4
import datetime exec_part = 1 # which part to execute exec_test_case = 1 # 1 = test input; 0 = real puzzle input # Puzzle input INPUT_TEST = ''' ''' INPUT = ''' ''' def parse_input(input): return input.split('\n') def part1(input): result = 0 return result def part2(input): result = 0 return res...
515edaf757665263225289c6415b48417bc9eb5c
stefifm/parciales
/p4_aed_bruera_stefania_59149_1k10/registro.py
2,034
3.578125
4
""" Registro del tipo Mueble """ class Mueble: """ Registro del tipo Mueble """ def __init__(self, cod, nom, pre, tip_mu, mat_pri): self.codigo = cod self.nombre = nom self.precio = pre self.tipo_mueble = tip_mu self.mat_prima = mat_pri def ca...
8f8bacb7c0238db9768c9b6c8d460e44621c3cef
ramwin/leetcode
/reshape_the_matrix.py
1,554
3.59375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Xiang Wang @ 2017-05-24 16:42:05 import unittest class Solution(object): def matrixReshape(self, nums, r, c): if len(nums) == 0: # nums = [] if c == 0: return [[]] * r else: return [] if len(...
2c5842ca2ba75871738a8da5f46bb3edb75a5c72
pymft/mft-vanak
/S09/methods/string_methods.py
438
3.8125
4
text = """April is the cruellest month, breeding Lilacs out of the dead land, mixing Memory and desire, stirring Dull roots with spring rain.""" # res = "hello".capitalize() # res = "hello".upper() res = text.title() print(res) num = text.count("the") print(num) indx = text.find("the", 10) print(indx) words = text.lo...
9ff069b3a4beb61919870a1a1298122de3aa1717
RubennCastilloo/master-python
/10-sets-diccionarios/sets.py
231
3.53125
4
""" SET es un tipo de dato, para tener una colección de valores, pero no tiene ni indice ni orden """ personas = { "Ruben", "Abisai", "Alexandra" } personas.add("Nayelli") personas.remove("Abisai") print(personas)
954c274b8b2a4e673fbdb551220e8521db297820
suganthicj/gangac
/gangac.py
176
3.671875
4
from datetime import datetime s1 = '10:04:00' s2 = '11:03:11' # for example format = '%H:%M:%S' time = datetime.strptime(s2, format) - datetime.strptime(s1, format) print time
cbbd4370df7fe13e72d8a6cd2ee4149b4a7ad950
Breynerr/taller-30-abril
/ejercicio#14.py
264
3.8125
4
#calcular la velocidad final aceleracion=float(input("introduce la aceleracion en m/s = ")) tiempo=float(input("introducel el tiempo deseado en segundos = ")) velocidadfinal= (0 + aceleracion)*tiempo print("la velocidad final es = ", velocidadfinal, str ("m/s"))
f3c36f1e46acf5365a1f56da2b14668181551f73
ChrisBentley/cl-draw
/canvas.py
2,554
4.34375
4
""" A canvas class that allows the user to create a canvas of size x,y and draw on it. """ class Canvas(object): def __init__(self, w, h): self.width = w self.height = h # Initialize a canvas of size x by y, filled with spaces self.canvas = [[' ' for x in range(w + 2)] for y in r...
dc81c69446ec8cb8475dd6b3c411f5baefe8258d
romanvoiers/Python
/WorkingWithNumbers.py
860
4.375
4
from math import * # imports more math functions. Also called a module my_num = 27 my_abs_num = -10 print(1, 2, 3, 4) print(5 + 5) # Don't need variables to do math print(10 * (5 + 5)) print(10 * 5 + 5) # Order of operations print(10 % 3) # Spits out the remainder print(my_num) # Prints out the variable print(s...
46d14590841b11c7f56d9f64ada98b4674ef4198
grumpy13/python-foundations
/cashier.py
538
3.90625
4
items = [] item_name = input("Item (enter 'done' when finished): ") while item_name != 'done': price = float(input("Price: ")) quantity = int(input("Quantity: ")) items.append({"name": item_name, "price": price, "quantity": quantity}) item_name = input("Item (enter 'done' when finished): ") print("\...
1d2ac5721b98c046aa30f33ce73977f866e6434d
isensen/PythonBasic
/Tutorials/29_0_常用内建模块(collections).py
2,366
3.78125
4
#coding=utf-8 ''' Python之所以自称“batteries included”,就是因为内置了许多非常有用的模块,无需额外安装和配置,即可直接使用。 ''' __author__ = 'isenen' #--------------------------[collections]----------------------------- # collections是Python内建的一个集合模块,提供了许多有用的集合类 # 我们知道tuple可以表示不变集合,例如,一个点的二维坐标就可以表示成: p = (1, 2) # 但是,看到(1, 2),很难看出这个tuple是用来表示一个坐标的。 # 定义一个cl...
697ba3aa40a21e1b0e9fb4eb24f8c9171c2a93ff
zz-zhang/some_leetcode_question
/source code/257. Binary Tree Paths.py
751
3.59375
4
from utils import TreeNode from typing import List, Optional class Solution: def binaryTreePaths(self, root: Optional[TreeNode]) -> List[str]: self.res = [] self.dfs(root, '') self.res = [s[2:] for s in self.res] return self.res def dfs(self, node, path): new_path = f'{...
7f9b1e1f2167291c7c4339916a940cbd0289124c
ChemelAA/scientific_python
/scientific_python/d_scipy/optimize.py
3,894
3.515625
4
#!/usr/bin/env python3 # This file contains examples of usage of scipy.optimize module from __future__ import division import numpy as np from numpy.testing import assert_allclose from scipy import optimize # -- root -- # `root` is a function that solves a vector equation f(x) = 0. It providing # interface to var...
9b329683a0fc0f7a011ed5b9face2803e3732b2a
TiborUdvari/Python
/src/Exercice1/conversionTemperatureLigneCommande.py
563
3.71875
4
import sys if(len(sys.argv)!=3): sys.exit("Not the good argument count ... Read the man page, oh wait there isn't one :)") try: temperature = float(sys.argv[1]) conversionVers = str(sys.argv[2]) except ValueError: sys.exit("Should be program.py {NUMBER} {F or C}") if conversionVers != 'C' and conver...
cd262b3a03ed06bd03854ac921739a7de64fa178
lalitsharma16/python
/cowANDbulls.py
1,321
3.828125
4
#!/usr/bin/python import random def compare_num(number, user_guess): cowbull = [0,0] # cow , bull for i in range(len(number)): if number[i] == user_guess[i]: cowbull[1] += 1 else: cowbull[0] += 1 return cowbull if __name__=="__main__": playing = True num...
5285ee882c0ac51baaf71eb222045b12cc08b0b7
GuilhermoCampos/Curso-Python3-curso-em-video
/Pythonteste/test/calculadoradeporcentagem.py
269
3.828125
4
valor = float(input('Digite o Valor que quer aplicar o desconto: R$')) desci = float(input('Digite o desconto que quer aplicar: ')) descf = desci / 100 final = valor - (descf * valor) print('O valor R${} com {}% de desconto será R${:.2f}'.format(valor, desci, final))
4e2c1ab074a704f63ffc452f74fb02956c142595
Dohyun-l/python_basic
/test/test18.py
953
3.625
4
def open_account(): print("새로운 계좌가 생성되었습니다.") open_account() def deposit(balance, money): print("입금이 완료되었습니다. 잔액은 {}원 입니다.".format(balance + money)) return balance + money def withdraw(balance, money): if balance >= money: # 잔액이 출금보다 많으면 print("출금이 완료되었습니다. 잔액은 {}원 입니다.".format(balance-money)...