blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
f166ebfb983486de4edfc8f25a8fe4070c7af6b3
paulmcaruana/Dictionaries_and_sets
/fruit.py
733
4.25
4
fruit = {"orange": "a sweet, orange, citrus fruit", "apple": "good for making cider", "lemon": "a sour, yellow citrus fruit", "grape": "a small, sweet fruit growing in bunches", "Lime": "a sour green citrus fruit"} print(fruit) veg = {"cabbage": "every child's favourite", "s...
d1009e780e0f321483c33555eb40499688daf173
FreedomFrog/pdxcodeguild
/python/blackjack/deck.py
805
3.71875
4
import card import random ranks = ["ace", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "jack", "queen", "king"] suits = ["Clubs", "Diamonds", "Hearts", "Spades"] class Deck: def __init__(self, an_int=1): self.contents = [] self.num_decks = an_int self.make_ca...
a06d5f6a3a21913617b5081ef8f373348e28f10e
akwls/PythonTest
/Part14. 리스트 더 알아보기/slice.py
393
3.71875
4
rainbow = ["빨", "주", "노", "초", "파", "남", "보"] # red_colors가 ["빨", "주", "노"]의 값을 가지도록 rainbow를 slice하세요. red_colors = rainbow[:3] #blue_colors가 ["파", "남", "보"]의 값을 가지도록 rainbow를 slice하세요. blue_colors = rainbow[4:] print("red_colors의 값 : {}".format(red_colors)) print("blue_colors의 값 : {}".format(blue_colors))
31674848f49216608d5c06a4128b22ef84cb451f
andreinaoliveira/Exercicios-Python
/Exercicios/077 - Contando vogais em Tupla.py
466
4.1875
4
# Exercício Python 077 - Contando vogais em Tupla # Crie um programa que tenha uma tupla com várias palavras (não usar acentos). # Depois disso, você deve mostrar, para cada palavra, quais são as suas vogais. frutas = ('banana', 'abacate', 'pera', 'uva', 'abacaxi') for palavra in frutas: print(f'Palavra {pa...
b66c2a156100c0cc5ca88e51197d90d7291a320f
hopensic/LearnPython
/src/leecode/tree_medium_1038(3).py
943
3.5
4
# Definition for a binary tree node. from leecode.common.commons import buildTree, TreeNode d = {} lst = [] class Solution: def bstToGst(self, root: TreeNode) -> TreeNode: d.clear() lst.clear() self.traverse(root) d[lst[0]] = lst[0] for x in lst[1:]: d[x] = d[x...
6989eff4ff464c91b353c416165c401d6d9bf3d5
patchiu/math-programmmmm
/interpolation/Newton interpolation.py
959
4.125
4
import numpy as np def newtonsDividedDifference(x_data,y_data): """Calculates the coeffisients of the interpolatiol polynomial from n data points using Newton's divided difference. Parameters: x_data: float arr. All the x-values of the data set. y_data: float arr. All the y-valu...
1008b56a4936b2ce98682b1a91c3d6084f33c403
souhaiebtar/CSV-Special-Character-Remover
/SCR.py
988
4.34375
4
#------------------------------------------------------------------------------- # Name: Special Characters Remover # Purpose: A stright forward way to remove special characters or any other character defined by the user for CSV # files. # # Author: Haytham Amin # # Created: 16/05/201...
ee7d098406d8159261820eb13fcee55443affb4c
excaliburnan/SolutionsOnLeetcodeForZZW
/2_AddTwoNumbers/addTwoNumbers.py
773
3.703125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: if not l1: return l2 if not l2: return l1 curNode = ListNode(0) p, q...
707a5e324c1fe249b0891d976595340597fe8b1a
yang4978/LintCode
/0463. Sort Integers.py
295
3.53125
4
class Solution: """ @param A: an integer array @return: nothing """ def sortIntegers(self, A): n = len(A) for i in range(n,0,-1): for j in range(1,i): if(A[j-1]>A[j]): A[j-1],A[j] = A[j],A[j-1] return A
b19a7152bdf4b501d0366bc9a53ec07485624515
gaodelade/MachineLearning_at_FLT
/02_Supervised/01_Regression/03_Polynomial_Linear_Regression/source.py
2,347
4.1875
4
''' Polynomial Linear Regression ''' # ***** Polynomial-Linear-Regression Intution ***** # Here, we have a simple formula: `y = b0 + b1.x1 + b2.x1^2 + ... + bn.x1^n` # where, x = independent variable # y = dependent variable # b1, b2, ... = quantifier of how `y` will change with the unit change in `x`. ...
7ed24f70a0444c664456a4c6920e0a16270737c0
axura/shadow_alice
/test08.py
220
3.9375
4
#!/usr/bin/python #testing break and continue functions x = 0 while x <= 10: if x % 4 == 0: print "divisible by 4" x += 1 elif x % 3 == 0: print "divisible by 3" continue elif x > 8: break else: x += 1
46d82e91545dd648e8c40e14064adfce5a71e04a
ErenBtrk/Python-Fundamentals
/Pandas/PandasDataSeries/Exercise5.py
371
4
4
''' 5. Write a Pandas program to convert a dictionary to a Pandas series. ''' dict1 = {"First Name" : ["Kevin","Lebron","Kobe","Michael"], "Last Name" : ["Durant","James","Bryant","Jordan"], "Team" : ["Brooklyn Nets","Los Angeles Lakers","Los Angeles Lakers","Chicago Bulls"] } import pandas a...
816c04c7cc93fd96828e070ef6a904b9d7f83c5d
JonasAraujoP/Python
/modularização/desafio107/desafio107.py
399
3.578125
4
import moeda print('-=-'*12) valor = float(input('Digite o preço: R$ ')) taxa = float(input('Informe a taxa: ')) print('-=-'*12) print(f'Aumento de {taxa}% sobre R${valor} = R${moeda.aumentar(valor, taxa)}') print(f'Diminuição de {taxa}% sobre R${valor} = R${moeda.diminuir(valor, taxa)}') print(f'Dobro de R${valor} = R...
ba8ac3e26048a31a3689bd5e1ff34fb92e632bd1
stanislavkozlovski/data_structures_feb_2016
/SoftUni/Advanced Tree Structures/binary_heap_tests.py
903
3.6875
4
import unittest from binary_heap import BinaryHeap class BinaryHeapTests(unittest.TestCase): def test_build_heap_extract_all_elements_should_return_sorted_elements(self): nums = [3, 4, -1, 15, 2, 77, -3, 4, 12] heap = BinaryHeap(nums) result = [] expected = [77, 15, 12, 4, 4, 3, 2,...
2a2fcf84d93e05e0c72042dd3ee2ca978ed2dc28
prajaktabhosale68121/learning_python
/variable.py
1,021
4.0625
4
# Question : How to create variable name = 'prajakta' print(name) # Question : How to assign value to variable a='20' print(a) # Question : How to print variable a1='20' print(a1) # Question : How to contact a string variable and print a2='prajakta' b2='bhosale' c2= a2+b2 print(c2) # Question : How to add two numbe...
1d730868eddabe87a347af1cc7d1e5e8ac82da30
Elsie0312/pycharm_code
/magic-8-ball.py
514
3.734375
4
import random, sys ans = True while ans: question = input("Ask a question…if you dare") answers = random.randint(1,6) if question == "q": sys.exit() elif answers == 1: print("NO") elif answers == 2: print("Yaaaasssss") elif answers == 3: pri...
8a6a56bb857c5bd820a17e0d1c12c02c6d135bf3
boluocat/core-python-programming
/最小数组合.py
490
3.59375
4
''' 输入:数组字用英文逗号隔开。 输出: 1、选取数组中的三个数字组合成最小数输出 2、如果数组中的数字个数小于3,则采用全部数字进行组合输出,输出最小值 例如: #输入 32,435,6,543,654 #输出 324356 ''' a = list(input().split(',')) c = sorted(map(int,a))[0:3] d = list(map(str,c)) b = '' e = '' if len(a) <=3: for i in sorted(a): b = b+i print(b) else: for j in sorted(d): e...
f606649153018af62f2521f526054c1a7c413dda
rohitrastogi/Interview-Prep
/solns/num_islands.py
994
3.734375
4
def num_islands(matrix): num_rows = len(matrix) num_cols = len(matrix[0]) queue = [] count = 0 def is_valid(row, col): return not (row < 0 or row == num_rows or col < 0 or col == num_cols) def bfs(): queue.append( (row, col) ) matrix[row][col] = 0 ...
557774540471ef26ad43910cb054987a20e0f939
RajMadhok/python-
/credit and debit.py
632
4.15625
4
balance=20000 operation=int(input("Press 1 for Credit and 2 for Debit: ")) print("ur balance is:",balance) trans_amount=int(input("Enter the Amount:")) i=1 while i<=3: if operation==1: credit=balance+trans_amount print("Your Current balance is: ",credit) print("Amount Credited: ",trans_amount) ...
9fc5ca14231325b2a0b0f8957f71e6d473afc1d8
tberhanu/green_book
/ch1_Arrays&Strings/rotate_matrix.py
723
3.984375
4
from copy import deepcopy def rotated_matrix(matrix): '''matrix = [ [ , , ], [ , , ], [ , , ] ] is list of lists''' '''matrix = [ [(0,0) , (0,1) , (0,2)], [(1,0) , (1,1) , (1,2)], [(2,0) , (2,1) , (2,2)] ]''' '''rotated_ matrix = [ [(2,0) , (1,0) , (0,0)], ...
8814169ecb7e155092f7876927911b2f268bc9df
aamir7shahab/FellowshipPrograms
/Logical Programs/StopWatch.py
924
3.84375
4
import time from math import floor class StopWatch: @staticmethod def startTime(): start = time.time() return start @staticmethod def stopTime(): stop = time.time() return stop @staticmethod def elapsedTime(start, end): elapsedTime = (end - start) ...
ae611a2d541ca43641b3a943ab1d92888f833814
HalfMoonFatty/Interview-Questions
/467. Unique Substrings in Wraparound String.py
2,337
4.03125
4
''' Problem: Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so s will look like this: "...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....". Now we have another string p. Your job is to find out how many unique non-empty substrings of p are present in s. In ...
3a761e72e8d57b4ee149c0df9d473b4c7c8dac90
vannt010391/vspro_final0905
/media/New Text Document.py
276
3.5
4
def chan(a): if a % 2 == 0: return True else: return False # a = input() a = '127' sc = 0 sl = 0 for i in a: if chan(int(i)): sc += int(i) sl += int(i) if sl % sc == 0: print('YES') else: print('NO')
22a82b6c590fed87cb677c0f1b958950af27b5e7
typhoon93/python3learning
/TicTacToe_Project.py
6,639
4.09375
4
from IPython.display import ( clear_output, ) # this function can clear the output so we don't have clutter import time # using time.sleep in the code so we don't have issues with input sequence display in jypiter from random import randint # used to randomly assign first player board = [[" ", " ", " "], [" ", ...
e6cf429b6ce1b0052c48cbe72aebbee70670ed19
nyck33/coding_practice
/Python/leetcode/dfs_bfs.py
705
3.703125
4
graph = {1:[2,4], 2:[1,3], 3:[3,4],4:[1,3]} def dfs(g, s=1): g[0] = [0] stack = [] visited = [0 for x in range(len(g))] stack.append(s) while stack: u = stack.pop(-1) visited[u] = 1 edges = g[u] for v in edges: if not visited[v]: stack.a...
0e2c73177a0bb32644bb881acdde09b084c2a52f
Jinsaeng/CS-Python
/al4995_hw6.py
3,852
3.875
4
##def print_shifted_triangle(n,m,symbol): ## matrix = ""; ## for i in range(2*n): ## if i % 2 == 0: ## j = 0 ## else: ## j = i ## line = (" " * m) + ((2* n-i) * " ")+ (j * symbol) + "\n" ## matrix +=line ## return matrix ##def print_pine_tree(n, symbo...
1d955e5ee15e926c49bcc1cea4fb0ed48dfb9fd8
rusalforever/python-course-alphabet
/relational_database/homework.py
9,417
3.578125
4
from typing import List def task_1_add_new_record_to_db(con) -> None: """ Add a record for a new customer from Singapore { 'customer_name': 'Thomas', 'contactname': 'David', 'address': 'Some Address', 'city': 'London', 'postalcode': '774', 'country': 'Singap...
c285bbe04ed02ee521ca13794264915943e84554
HsiangHung/Code-Challenges
/leetcode_solution/string/438.Find_All_Anagrams_in_a_String.py
1,123
3.6875
4
# 438. Find All Anagrams in a String # class Solution: def findAnagrams(self, s: str, p: str) -> List[int]: ''' looping s as s[:3], s[1:4], s[1:5], ...... when new letter comes in, add it in dict, and remove the oldest letter. and check s_dict == p_dict ''' p_dict = s...
78b012ce19e3b837eb3ec1983e483b20dec89404
tjsaotome65/sec430-python
/module-06/chatclient.py
3,937
3.765625
4
""" File: chatclient.py Project 10.10 This module defines the ChatClient class, which provides a window for a chatroom conversation. """ from socket import * from codecs import decode from breezypythongui import EasyFrame HOST = "localhost" PORT = 5000 ADDRESS = (HOST, PORT) BUFSIZE = 1024 CODE = "ascii" class ChatC...
d260aceda5958d58d4d9ea13016d108a8d32e9ea
chanyoonzhu/leetcode-python
/1790-Check_if_One_String_Swap_Can_Make_Strings_Equal.py
249
3.5625
4
""" - Array - O(n), O(1) """ class Solution: def areAlmostEqual(self, s1: str, s2: str) -> bool: diffs = [(c1, c2) for c1, c2 in zip(s1, s2) if c1 != c2] return not diffs or len(diffs) == 2 and diffs[0][::-1] == diffs[1]
aed896860a6d872454269cee6e60b49e23e184c7
boraseoksoon/DailyCommit
/CrackingCodingInterview/Python/20170301_crackingCodingInterview.py
9,661
4.0625
4
#!/usr/bin/python # Q1. anagram : a word, phrase, or name formed by rearranging the letters of another, such as cinema, formed from iceman. # Write a method to decide if two strings are anagram or not. if a one string is a permutation of another string. Qstring1 = "LIsTEn" Qstring2 = "sLienT" def anagram(str1, st...
829b68a4cffd7f3addae14a9ca92130378312f9f
OhOverLord/loft-Python
/Алгоритмы_ теория и практика. Структуры данных/(1.2.3)Simulation_network_packet.py
2,385
4.09375
4
""" Симуляция обработки сетевых пакетов Sample Input 1: 1 0 Sample Output 1: Sample Input 2: 1 1 0 0 Sample Output 2: 0 Sample Input 3: 1 1 0 1 Sample Output 3: 0 """ class Queue: """ Класс для создания очереди """ def __init__(self): """ Конструктор класса с созданием списка "...
a2a77dba795ba39cd596e1975bc97f2bbaf14f3f
howardl2/practice
/palindrome_num.py
1,284
4.1875
4
# Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. # Example 1: # Input: 121 # Output: true # Example 2: # Input: -121 # Output: false # Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palin...
e015977ed62850ea64e24b39f93650012346d744
ekohilas/comp2041_prac_soln
/version_1/q4.py
614
3.96875
4
import re import sys def round_match(match): # group 0 is the entire match return str(round(float(match.group(0)))) for line in sys.stdin: # re.sub will do a regex replacement with specified string. # to do additional expressions, we can pass in a function that will # handle the match and return ...
2f685ba54c27c7937688f77789260ea5dde709e7
JoyC14/notes
/HW5/BFS_06170241.py
903
3.640625
4
#!/usr/bin/env python # coding: utf-8 # In[4]: from collections import defaultdict class Graph: def __init__(self): self.graph = defaultdict(list) def addEdge(self,u,v): self.graph[u].append(v) def BFS(self, s): state2 = [] queue = [s] whil...
d67f0c3e827060bd5b0bfda467cb4393f4b5f821
BrodyCur/python_fundamentals1
/exercise3.py
590
3.8125
4
print("What is your name?") user_name = input() print("Hello, {}".format(user_name)) secret_password = "please" print("What's the password?") password_attempt = input() correct_or_not = (password_attempt == secret_password) print("That's {}".format(correct_or_not)) print("How many cookies have been eaten?") eaten ...
13a6fbb232f3029a889dad96800fbbc1dac20b99
daniel-reich/turbo-robot
/2nciiXZN4HCuNEmAi_13.py
1,419
3.90625
4
""" The nesting of lists can be viewed indirectly as curves and barriers of the real data embedded in lists, thus, defeats the very purpose of directly accessing them thru indexes and slices. In this challenge, a function is required to **flatten those curves** (i.e. level, iron, compress, raze, topple) and expose t...
4fe651b79c2c04fe30bf0ebc49af0c256082de08
Cherietabb/python_algorithms
/pet_test.py
728
4.15625
4
__author__ = 'Cherie Tabb' import pet def make_list(): pet_list = [] for count in range(1, 2): name = input("Enter your pet's name: ") animal_type = input("What pet_type of pet is it: ") age = int(input('Enter the age of your pet: ')) new_pet = pet.Pet(name, animal_type, age)...
bbdfddac759c36df02e3f41c7c4aad0688235bb2
arijit1410/cs498
/assignment2/models/neural_net.py
10,977
4.03125
4
"""Neural network model.""" from typing import Sequence import numpy as np class NeuralNetwork: """A multi-layer fully-connected neural network. The net has an input dimension of N, a hidden layer dimension of H, and performs classification over C classes. We train the network with a cross-entropy loss ...
c4ffe9f905667c5465d98cf4560b5c5c3bda9041
sevgo/Programming101
/week1/the_final_round/count_words.py
477
4.3125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def count_words(arr): """Counts words in a list and returns a dictionary of the type {"word":count} """ unique = set(arr) words = {} for element in unique: words[element] = 0 for el in unique: for e in arr: if e == el:...
21cf231232cf42e9e30f99db0f3645f4d790faf5
xwzl/python
/python/src/com/python/learn/obj/ClassExtend.py
4,361
4.125
4
# 继承是面向对象的三大特征之一,也是实现代码复用的重要手段。继承经常用于创建和现有类功能类似的新类,又或是新类只需要在现有类基础上添加一些成员(属性和方法),但又不想直接将现有类代码 # 复制给新类。 # # 例如,有一个 Shape 类,该类的 draw() 方法可以在屏幕上画出指定的形状,现在需要创建一个 Rectangle 类,要求此类不但可以在屏幕上画出指定的形状,还可以计算出所画形状的面积。要创建这 # 样的 Rectangle 类,除了将 draw() 方法直接复制到新类中,并添加计算面积的方法,其实还有更简单的方法,即让 Rectangle 类继承 Shape 类,这样当 Rectangle 类对象调用 draw()...
addf439650324b961f83d0ad44298431761cd0d1
vansoares/challenges_solutions
/educative.io/algorithms-in-python/sorting/bubble-sort.py
560
4.125
4
def bubble_sort(lst): is_not_sorted = False array_size = len(lst) index = 0 while not is_not_sorted: changed = False for i in range(array_size-1): if i+1 >= array_size: continue current = lst[i] next = lst[i+1] ...
0e8cdf2c90821eb42e1a593d38c5b50b72d9f9c5
zanariah8/Starting_Out_with_Python
/chapter_05/rectangle.py
427
3.828125
4
# the rectangle module has functions that performs # calculations related to rectangle # the area function accepts a rectangle's width and # length as arguments and returns the rectangle's area def area(width, length): return width * length # the perimeter function accepts a rectangle's width # and length as a...
01677a7c933fa163221e27a8bea963a35b8888be
oddsorevans/eveCalc
/main.py
2,991
4.34375
4
# get current day and find distance from give holiday (christmas) in this case from datetime import date import json #made a global to be used in functions holidayList = [] #finds the distance between 2 dates. Prints distance for testing def dateDistance(date, holiday): distance = abs(date - holiday).days pr...
38911ac68c8478b8dfe07ea708b8f5df11a59f57
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_203/547.py
1,583
3.796875
4
def contain(matriz, char): for r in matriz: if char in r: return True return False def print_mat(matriz): for r in matriz: print(''.join(r)) def change_direita(matriz, char, r, c): lim = len(matriz[0]) - 1 while c<lim and matriz[r][c+1] == '?': c += 1 ...
967be1f8566036398185c1586cab28c510b60759
dustinsnoap/code-challenges
/python/missing_number.py
1,214
3.8125
4
# Given an array nums containing n distinct numbers taken from 0, 1, 2, ..., n, return the one that is missing from the array. # Follow up: Could you implement a solution using only constant extra space complexity and linear runtime complexity? # Example 1: # Input: nums = [3,0,1] # Output: 2 # Example 2: # I...
9246f2d852f477afcaadb6d9ea1f538cc02d87cc
jeanggabriel/jean-scripts
/curso em video/array.py
182
3.671875
4
while True: a = str(input('nome:')) b = str(input('telefone: ')) c = str(input('cpf: ')) d= [a ,b ,c] for i in (a,b,c,d): print(i) break
e439ece96da236dd2c4f50d67a3831624844bb7e
JuDaGoRo/grup05
/ejesuma.py
211
3.828125
4
print ("Escriba el limite superior de la suma") n = int (input()) suma = 0 # desde que numero comienza el ciclo for i in range (1, n +1): suma = suma + i # Esto es igual a decir "suma = suma + 1 print (suma)
4b3187694d3f43ef8b7ee834c64e18fad6e4b5d3
DSXiangLi/Leetcode_python
/script/[662]二叉树最大宽度.py
2,352
4
4
# 给定一个二叉树,编写一个函数来获取这个树的最大宽度。树的宽度是所有层中的最大宽度。这个二叉树与满二叉树(full binary tree)结构相同,但一些节 # 点为空。 # # 每一层的宽度被定义为两个端点(该层最左和最右的非空节点,两端点间的null节点也计入长度)之间的长度。 # # 示例 1: # # # 输入: # # 1 # / \ # 3 2 # / \ \ # 5 3 9 # # 输出: 4 # 解释: 最大值出现在树的第 3 层,宽度为 4 (5,3,null,9)。...
092bd9ab615cf0970301c7df2e126f91b3511140
Vampir007one/Python
/Kalmykov_Practical_5/quest17.py
359
3.984375
4
from math import sqrt partialSum = 0 partialSumSquares = 0 n = 0 number = int(input("Введите число: ")) while number != 0: n += 1 partialSum += number partialSumSquares += number ** 2 number = int(input("Введите число: ")) answer = sqrt((partialSumSquares - partialSum ** 2 / n) / (n - 1)) print("Ответ:"...
66a81b6ebccfaae8022462d95bf9ae5ddde7ef0a
OnsJannet/holbertonschool-web_back_end
/0x00-python_variable_annotations/5-sum_list.py
368
4.03125
4
#!/usr/bin/env python3 ''' takes a list input_list of floats as argument and returns their sum as a float. ''' from typing import List def sum_list(input_list: List[float]) -> float: '''returns the sum of a list of floats Args: input_list (float): [list of floats] Returns: float: [sum of...
d85fa9097f2df522bdb488cdf50255ca48e53dd0
YifanC86/hrinf-development
/2020-2021/DEV2/Chapter 1B/BA04.py
231
3.546875
4
def breakUp4DigitNumber(num): digit4 = num % 10 num = num // 10 digit3 = num % 10 num = num // 10 digit2 = num % 10 num = num // 10 digit1 = num % 10 num = num // 10 print() input = 123 breakUp4DigitNumber(input)
b302806221377a29e3d973cc8613fb97a669e610
wxl789/python
/Day06/1-代码/基础内容/17-作业.py
1,668
3.703125
4
# 1、 # 1.1、从控制台输入两个数,输出较大的那个数 # 1.2、从控制台输入三个数,输出较大的那个数 # 不准使用max min ''' a = input() b = input() numA = int(a) numB = int(b) if a > b: print(a) else: print(b) ''' ''' a = int(input()) b = int(input()) c = int(input()) if a >= b and a >= c: print(a) if b >= a and b >= c: print(b) if c >= b and ...
61813e43dbfb6c4be84104f9e042207ef3beeb2e
sohitmiglani/Applications-in-Python
/Max Heaps.py
931
4.125
4
# This is the algorithm for building and working with heaps, which is a tree-based data structure. # It allows us to build a heap from a given list, extract certain element, add and remove them. def max_heapify(A, i): left = 2 * i + 1 right = 2 * i + 2 largest = i if left < len(A) and A[left] > A[la...
e95f8037552d517853d4170ce68fedd3aae93fab
nyxssmith/damageReport
/main.py
3,375
3.734375
4
import requests from lxml import html import time address = "https://www.reddit.com/r/all/" def checkValidLink(link):#checks if the link will work or not, so we can use this to remove bad links from lists and make sure the program wont error try: page = requests.get(link).text#we get the webpage #print(link,"is ...
a77ee4118dc3985d5b09a1a3257e9f276310d8e9
AadityaDeshpande/PythonAssignments
/Intermediate/IntermediatePython/Assignments/Day2/Q5.py
158
3.921875
4
sentence = 'It is raining cats and dogs' token = sentence.split(" ") print(token) targetList = [ len(word) for word in token ] print(targetList)
3c947d233c597b7b2d57c8b20ca4855f19d9b125
botamochi0x12/Yet-Another-SCP-Wiki-Bot-For-Slack
/wait.py
3,255
3.59375
4
""" Util functions to wait for time to post notifications. """ import time from datetime import datetime, timedelta, timezone from typing import Optional TimeSeconds = float Datetime = datetime # offset from UTC to JST TIMEZONE_OFFSET = (timedelta(hours=9) - timedelta(hours=0)).seconds def wait_until( then: Op...
7dd9ba628edb65afeaa8e83edb3a2d849bc8c768
ragavan98/Numpy-study
/Lec2-Arrays.py
7,961
4.03125
4
import numpy as np # Creating a 0-Dimensional array print("#### Creating a 0-Dimensional array ####") arr0Dimensional = np.array(42) print(arr0Dimensional) # print(type(arr0Dimensional)) it is object type ############################################################################################################...
a607a903d29bf628fe0b7bef4f5ad077233efe5b
waiteb15/py3forsci3day
/date_delta.py
570
3.953125
4
#!/usr/bin/env python import sys from datetime import date, datetime, timedelta, time #date = sys.argv[1] #date = input("Enter date (YYYY-MM-DD):") d1 = '1991-07-02' #d1 = datetime.strptime(date, "%Y-%m-%d") d2 = datetime.now().strftime("%Y-%m-%d") def _days_between(d1, d2): d1 = datetime.strptime(...
861694caeb29e5f89907a2950b7b67175cc2ec6a
alvxyz/PythonClass
/Belajar bersama Kelas Terbuka/Bilangan Prima dan belajar codesaya.py
1,577
3.578125
4
# tentukan batas bilangan prima yang akan dicari Angka = 100 # # # perulangan untuk mengecek bilangan prima # for num in range(2, Angka): # prima = True # for i in range(2, num): # if (num % i == 0): # prima = False # if prima: # print(num) def hitung_tagihan(uang_muka): ...
9972f8d198fe60acae7f422c47bae51aaf91ba22
onetoofree/IT_Masters
/StuffFromLectures/SolutionsFromLabs/Lab3/PrefSuff.py
843
4.3125
4
#prefix/suffix testing LongStr=input("Please enter a long string ") ShortStr=input("Please enter a short string ") longlen=len(LongStr) shortlen=len(ShortStr) if(shortlen>longlen): print("String ",ShortStr," is neither a prefix nor a suffix of string ",LongStr) else: ispref=1 for i in range (0,shortlen): if(...
eac0789333b9034bfd0f1990abcbc4264c8c434c
peltierchip/the_python_workbook_exercises
/chapter_2/exercise_57.py
1,031
4
4
## #Calculate the total cost of a cell phone plan b_cost=15.00 c_mess_add=0.15 c_minu_add=0.25 c_911=0.44 tax=0.05 #Read the number of minutes and text messages used in this month minutes=int(input("Enter the number of minutes used:\n")) messages=int(input("Enter the number of messages used:\n")) #Compute the...
f22ede9fe55778c6e598641b5a153e1589afd399
kanak8278/LeetCode-Practice
/Stacks and Queues/floodFill.py
1,057
3.734375
4
from collections import deque from typing import List class Solution: def floodFill(self, image: List[List[int]], sr: int, sc: int, newColor: int) -> List[List[int]]: q = deque() visited = set() dirs = [(1, 0), (0, 1), (-1, 0), (0, -1)] q.append((sr, sc)) color = image[sr][s...
358169c174ee0c23f4f1c4eaa3c26095d963a83a
WilliamRo/greedy_snake
/Section I/step_1.py
703
4
4
""" If you want to create a game based on whatever programming language, you must decide where to show your user interface. It can be on terminal (sometimes people call it 'command line window' or 'command shell') of course, yet a window on which we can draw whatever shape with whatever color is definitely more prefera...
520055c5d6c0bc95fc1f91cb441e82b34d225d9e
GT-IEEE-Robotics/Simulator2020
/simulator/legos.py
3,651
3.84375
4
""" File: legos.py Author: Ammar Ratnani Last Modified: Ammar on 11/26 """ import pybullet as p from typing import List, Tuple import re from simulator.utilities import Utilities class Legos: """ A class to provide for the importing of legos. Provides functions to import a list of le...
56bad7dc91c35dd8c1ff0b2bb2b986f3b6534a9c
childe/leetcode
/merge-intervals/solution.py
1,412
4
4
# -*- coding: utf-8 -*- ''' https://leetcode-cn.com/problems/merge-intervals/ Given a collection of intervals, merge all overlapping intervals. Example 1: Input: [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6]. Example 2: Inpu...
3b550a112176c96da14e1642ec414d25b43c75e1
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_74/756.py
1,443
3.515625
4
#!/usr/bin/env python3 import sys # drop first line of stdin sys.stdin.readline() for test, line in enumerate(sys.stdin): seq_raw = line.split()[1:] seq = [] orange_queue = [] blue_queue = [] for i in range(0, len(seq_raw), 2): color = seq_raw[i] button = int(seq_raw[i+1]) seq.append((color, button)) if...
f7a0b345f3690cbbf2c63df111609331d20b7955
jsqihui/lintcode
/Binary_Tree_Maximum_Path_Sum.py
903
3.78125
4
""" Definition of TreeNode: class TreeNode: def __init__(self, val): this.val = val this.left, this.right = None, None """ class Solution: """ @param root: The root of binary tree. @return: An integer """ def maxPathSum(self, root): # write your code here maxPath,...
659a8f43baa848318b6f8bd0a36ac35ddfbdf773
rohitgupta29/Python_projects
/Data_Structures/5.Pig_latin.py
246
3.515625
4
# -*- coding: utf-8 -*- """ Created on Mon Aug 10 16:54:36 2020 @author: infom """ def pig_latin(word): if word[0] in 'aeiou': return f'{word}way' return f'{word[1:]}{word[0]}ay' print(pig_latin('python'))
3e1d85091c17f642047403be6a6b7d5eb4e478ea
MehtapIsik/algebra
/tmp.py
196
3.703125
4
# Run example: python tmp.py 4 5 import sys import algebra print(sys.argv) name = sys.argv[0] num1 = float(sys.argv[1]) num2 = float(sys.argv[2]) print(algebra.operations.product(num1, num2))
dda71af28bf3c2406758f0eeea7bb8254f7d0546
ohadsham/AI_HW_3
/q1.py
5,465
3.515625
4
# -*- coding: utf-8 -*- from numpy import log2,inf #general: #each element represent as line of the file. #all features have binary values (true or false) # convert feature name to index in line def featureToIndex(feature): return attributes.index(feature) def makeTree(examples,features,default): if not exam...
a087215bcd32db3a39af230e06bc74d088ca86d5
Parizval/CodeWars
/Mexican Wave/Solution.py
169
3.71875
4
def wave(str): ans = [] for i in range(len(str)): if str[i] == " ": continue ans.append(str[:i] + str[i].upper() + str[i+1:]) return ans
2d4a1b0e038a4b915f3e223be468f46df390fc74
mohit2494/gfg
/languages/python/Input_Output(done)/3. Taking multiple inputs from user in Python.py
1,861
4.40625
4
''' Developer often wants a user to enter multiple values or inputs in one line. In C++/C user can take multiple inputs in one line using scanf but in Python user can take multiple values or inputs in one line by two methods. - using the split() method - using List Comprehension ''' # using split method ''' ...
ea4b3432bb1e15b6b65a6114d62392be2830cf35
Mehr2008/summer-of-qode
/Python/2021/Class 1/Student Code/Avie Lal/main.py
192
3.765625
4
Tea1 = input('Tea from shop one =\n') Tea1 = int(Tea1) Tea1 = Tea1*15 T2 = input('Tea from shop 2 =\n') T2 = int(T2) T2 = T2*30 Tea_total = Tea1 + T2; print("Total bill =",Tea_total," Rupees")
8ebb57ff4fa439ed1ad44b9617f6458ca8ecf64c
libinlovexin/web_project
/test/orderDict.py
741
3.75
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from collections import OrderedDict class lastUpdateOrderedDict(OrderedDict): def __init__(self,max): super(lastUpdateOrderedDict,self).__init__() self._max = max def __setitem__(self,key,value): containsKey = 1 if key in self else 0 #假如超过长度,删除第一个进入的元素 if ...
50eb449a51438b6154a6ae47b82990ac28023dfa
luizfernandosantoss/Curso-alura
/Python/Primeiro curso Python/forca.py
4,525
3.671875
4
import random def jogar(): imprime_abertura(); palavra_secreta = escolher_palavra(); letras_acertadas = quantidade_letras(palavra_secreta); enforcou = False acertou = False erros = 0; chutes=[]; while (not enforcou and not acertou): chute = pede_chute(); if (c...
dc2f2ff8952f60e860e0fef387b25d42296cd2bd
SatoKeiju/AtCoder-Python3
/ABC152/e.py
370
3.671875
4
# ACできてない!! def main(): from fractions import gcd n = int(input()) num_list = tuple(map(int, input().split())) l = 1 for num in num_list: l *= num // gcd(l, num) answer = 0 for num in num_list: answer += l // num answer %= 10 ** 9 + 7 print(int(answer)) if...
b259aa8602eebb68764568615a94abe834c99ae3
hminah0215/Baekjoon_step
/step1/2588.py
308
3.546875
4
# 세자리 수 곱하기 세자리 수 일때 단계별 계산값 a = int(input()) # 기본값 b = list(input()) # 곱할값을 list로 저장 c1 = a * int(b[2]) # a * 곱셈할 값의 일의자리 수 c2 = a * int(b[1]) c3 = a * int(b[0]) answer = (c1 + (c2*10) + (c3*100)) print(c1, c2, c3, answer)
4c3f222af60d3be0a3c20d3b62367063e796eab2
HeydarO/Python-Crash-Course-
/Chapter4_Working with Lists/square.py
609
4.1875
4
#finding square of the each number between 1 and 10 using list() and range() functions squares = [] for value in range(1,11): square = value ** 2 squares.append(square) print(squares) #improving code and get the same result as above: squares = [] for value in range(1,11): squares.append(value ** 2) print(s...
185ced4c8e270f5f1d39909e04103c215dcf35c0
AkylbekMelisov/classes
/week4/day3/classes_task1.py
3,164
3.859375
4
class Car: wheels = 4 def __init__(self, name, year, color, model, is_crashed): self.name = name self.year = year self.color = color self.model = model self.is_crashed = is_crashed self.fuel = 100 self.run = 0 self.speed = 0 self.V = 20 ...
239e404666f128301d0634fa5b8e238b7ef58fb4
zhengxiaochen/cognitivetwins
/transDomin.py
540
3.71875
4
# 转换数据维度 import pandas table = pandas.DataFrame() for i in range(max(input_table['Iteration'])+1): #input_table_1.loc[input_table_1['Iteration']==i] #input_table_2.loc[input_table_2['Iteration']==i] print(i) if i == 0: table = pandas.DataFrame(columns = [str(i)], data = input_table.loc[input_table['I...
e1afa698123d5c7ca1b804bb347baa7108342de7
syurskyi/Python_Topics
/045_functions/005_decorators/_exercises/_templates/2/019_A Few Real World Examples_Timing Functions.py
1,022
3.65625
4
# _____ fun___ # _____ ti__ # # ___ timer func # """Print the runtime of the decorated function""" # ??.? ? # ___ wrapper_timer $ $$ # start_time _ ti__.p00_cou00 # 1 # value _ ? $ $$ # end_time _ ti__.p00_cou00__ # 2 # run_time _ e... - s... # 3 # print _*F...
ac87736b1e98b46d9f20ee7925c0416f1bcaebd8
David970804/CSCI2040Python
/LAB2code/test_scripts/p1.py
966
3.75
4
units=['I','V'] tens=['X','L'] hundreds=['C','D'] thousands=['M'] digit=[units,tens,hundreds,thousands] def roman_number(n): num_of_digits=0 n_digits = [] roman_num="" if n<=0 or n>9999: return 'Number is out of range' while n>0: n_digits.append(n%10) n = n//10 #for each digit of a number, the conversion lo...
0cfe54474368433890f7a5edcbb0ee2d1356e037
shaswat-99/tathastu_week_of_code
/Day1/Program4.py
288
3.953125
4
#Program 4 of Tathastu-Week of Code by shaswat-99 cp=float(input("Enter Cost Price of the Product ")) sp=float(input("Enter Selling Price of the Product ")) profit=sp-cp print(f"Profit= {profit}") new_sp=1.05*profit+cp print(f" Selling Price after 5% extra profit on product = {new_sp}")
957e19fd197b2c184cc8d42b211d25c79dc0115b
zl1fly/note-taker
/notetaker.py
940
3.71875
4
#!/usr/bin/python import time import os ## Declared vars. ## This is the file it writes the notes to. filename = "logfile.txt" ## This a the loop var which will keep the loop going loop = 1 ## Enter the loop and continue until loop != 1 while (loop == 1): ## Clear the Screen and prompt to enter there text os.syst...
3286cbc3754d3c1c3705e0282ffa3032dde4a8e7
webturing/PythonProgramming_20DS123
/lec08-function/Primer.py
356
3.875
4
def is_prime(n): if n < 2: return False # patch for i in range(2, n): if n % i == 0: return False return True print(True == is_prime(13)) print(False == is_prime(25)) print(False == is_prime(9)) print(True == is_prime(2)) print(False == is_prime(1)) for n in range(1, 100): if is_...
9802967b3b939d8d9c5aca5271f7952c900db206
bl0rch1d/cs50_hw
/python/bleep/bleep.py
740
3.703125
4
import sys def parse_dictionary(filename): result = [] with open(filename, mode='r') as f: for word in f: result.append(word.strip()) return result def main(): if len(sys.argv) != 2: print('Usage: python bleep.py dictionary') exit(1) dicti...
d309ca15942fcb464c186b67789fce3b4f4854cf
Dmitry314/lingustic
/untitled1.py
843
3.609375
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Fri Mar 9 20:51:05 2018 @author: dmitriy """ import numpy as np def get_one_text(my_file): with open(my_file) as f: read_data = f.read() return read_data def get_dict(): data = get_one_text('ozgegov/oz/ozgegov.txt') re...
83803d1105fc15b8e81d525c8541b272b2c01d21
manunapo/blackjack-game
/classes/deck.py
553
3.875
4
import random from classes.card import Card suits = ('Hearts', 'Diamonds', 'Spades', 'Clubs') ranks = ('Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Jack', 'Queen', 'King', 'Ace') class Deck: def __init__(self): self.all_cards = [] for suit in suits: for rank in ranks: self.all...
9d9600fedff52553c50535d3c9769d71055ddfb0
pradoz/leetcode_pset
/py/remove_outer_parenthesis.py
1,254
3.765625
4
''' ex1: Input: "(()())(())" Output: "()()()" ex2: Input: "(()())(())(()(()))" Output: "()()()()(())" ex3: Input: "()()" Output: "" ''' # Time/Space: O(n), where n is the number of parenthesis is the string 'parens' class Solution: def removeOuterParentheses(self, parens: str) -> str: res = '' pre...
affa0aa8edb7f2cd5f122766c1549e397d2d3967
jbrownxf/mycode
/mycal/mycal.py
259
4.25
4
#!/usr/bin/python import calendar yr = input('What year is it? ') lilcal = calendar.calendar(yr) print("Here is a tiny calendar:") print(lilcal) if calendar.isleap(yr) == False: print('This is not a leap year') else: print('This year is a leap year')
6b96d16f00b428ec0fb2c44155d7b84141995c1f
monikatrznadel/nauka_pythona
/zadanie13.py
189
3.671875
4
Print('Zadanie 13') ranking = {'name': 'Player1', 'pkt': '10', 'kat': 'junior'} print(ranking['name']) print(ranking['kat']) for i in ranking: print("{0}:{1}".format(i, ranking[i]))
368d0a5f6b6f5f984b3b3ad4b2bfa0acb8846c54
tuxedocat/nlp100
/src/p06.py
627
3.53125
4
# -*- coding: utf-8 -*- """nlp100 in python3""" __author__ = "Yu Sawai (tuxedocat@github.com)" __copyright__ = "Copyright 2015, tuxedocat" __credits__ = ["Naoaki Okazaki", "Inui-Okazaki Lab. at Tohoku University"] __license__ = "MIT" from common.ngram import ngram if __name__ == '__main__': s1 = "paraparaparadi...
209f9f540de3b07951bea2c3ff03a1de710da192
adamburford/COP4533
/COP4533/Assignment 3/quick_string_list.py
1,139
3.6875
4
#Adam Burford #COP4533 #Section 3594 class QuickStringList(): """Quick String List""" def __init__(self): self.__list = [] def __iter__(self): return iter(self.__list) def __getitem__(self, key): return self.__list[key] def __setitem__(self, key, value): ...
317826bf0f6e8fff46a982e8f6c9b0510197cc01
shaoda06/python_work
/Part_I_Basics/exercises/exercise_3_9_dinner_guests.py
436
4.0625
4
# 3-9. Dinner Guests: Working with one of the programs from Exercises 3-4 # through 3-7 (page 46), use len() to print a message indicating the number # of people you are inviting to dinner. names = ['MrrNonsense', 'Tony', 'Tom'] msg = " Would u like to have dinner with me?" print("Hello, " + names[0] + msg) print("He...
0f21e9badc5dd561641125bf4f16d0fc30aba9c0
junyeong-dev/python3-class_arguments
/class-method.py
1,340
3.53125
4
class Car(): def __init__(self, **kwargs): self.wheels = 4 self.doors = 4 self.windows = 4 self.seats = 4 # get("k", "d") : k는 key, d는 default를 가리킴 self.color = kwargs.get("color", "black") self.price = kwargs.get("price", "2000") # method는 class안에 있는 fu...
9f1c4e750b33b2b0b39fc799c68fb642630992de
ZainebPenwala/leetcode-solutions
/replace_ip.py
725
3.796875
4
'''Given a valid (IPv4) IP address, return a defanged version of that IP address. A defanged IP address replaces every period "." with "[.]". Example 1: Input: address = "1.1.1.1" Output: "1[.]1[.]1[.]1" Example 2: Input: address = "255.100.50.0" Output: "255[.]100[.]50[.]0" ''' # Solution 1: without usi...
547d5c35d834f744caf887cd9cc7e3b0f983f905
Algorant/HackerRank
/Python/zeros_and_ones/zeros.py
353
4.09375
4
''' Given the shape of an array in the form of space separated integers, use numpy functions zeros and ones to print an array of the given shape ''' import numpy as np dimensions = tuple(map(int, (input().strip().split())) zeros = np.zeros(dimensions, dtype=np.int) ones = np.ones(dimensions, dtype=np.int...
196f303f8502966785cf4a48b7279b01b4e80862
YJISCOOL/if_condition
/if_condition-temperature.py
316
4.03125
4
temp_unit = input("what is the unit(\'C/\'F): ") temp = int(input("what is the temperature now? ")) if temp_unit == "\'C": temp_F = str(temp * 1.8 + 32) print (temp, temp_unit + ' is equal to ' + temp_F + '\'F') else: temp_C = str((temp - 32) * (5/9)) print (temp, temp_unit + ' is equal to ' + temp_C + '\'C')
6411ebe2b56fa80f00b95effc637d3443d0fd1bd
jyotsanashyama/python-basics
/diwali_discount.py
593
4.125
4
purchase_amt=int(input("Enter the purchase amount(in Rs.):")) if purchase_amt<=400: discount=0 elif purchase_amt<=5000 and purchase_amt>400: discount=400 elif purchase_amt>5000 and purchase_amt<=10000: discount=800 elif purchase_amt>10000 and purchase_amt<=20000: discount=1000 else: discou...