blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
0779cbca5ae57181f533535517ea16934c339e78
zyzyzy520/AIproject
/exp4bonus.py
16,603
3.84375
4
''' 子句集消解实验 ''' ''' ->:> 析取:% 合取:^ 全称:@ 存在:# ''' dict = {} symbol = 0 # 1.消去>蕴涵项 a>b变为~a%b def del_inlclue(orign): ind = 0 flag=0 orignStack=[] right_bracket = 0 while (ind < len(orign)): orignStack.append(orign[ind]) if ((ind+1<len(orign)) and (orign[ind+1]=='>...
045bd36ce3f34426871ab98762cf8ed4fac22d39
Hansindu-M/Country_name-Python-
/country_name.py
391
3.578125
4
#pip install phonenumbers import phonenumbers #geocoder: to know the specific #location to that number from phonenumbers import geocoder phone_number = phonenumbers.parse("+14453678564") #USA phone number example: +1********** #SL phone number example: +94********** #this will print the country ...
87b7a3c8e8d5e48c307cc8e154ec04d4182eabf3
GabrielCernei/codewars
/kyu8/Persistent_Bugger.py
428
3.75
4
# https://www.codewars.com/kata/persistent-bugger/train/python def persistence(n): count = 0 tempN = [int(d) for d in str(n)] print("Original List: " + str(tempN)) while len(tempN) > 1: product = 1 for x in tempN: product *= x print("Product: " + str(product)) tempN = [int(d) for d in st...
b3facc57e8f25fe47cbd1b12d94d98403d490c9a
GabrielCernei/codewars
/kyu6/Duplicate_Encoder.py
596
4.15625
4
# https://www.codewars.com/kata/duplicate-encoder/train/python ''' The goal of this exercise is to convert a string to a new string where each character in the new string is "(" if that character appears only once in the original string, or ")" if that character appears more than once in the original string. Ignore ...
2811c2f7ad8732f43ab8498fb10ba05d8e6ad1e6
GabrielCernei/codewars
/kyu6/Opposite_Array.py
342
4.15625
4
# https://www.codewars.com/kata/opposite-array/train/python ''' Given an array of numbers, create a function called oppositeArray that returns an array of numbers that are the additive inverse (opposite or negative) of the original. If the original array is empty, return it. ''' def opposite_list(numbers): return...
370ba58f96b7d8fbfc713bd3942325ddd764bf3d
GabrielCernei/codewars
/kyu7/Maximum_Product.py
219
3.53125
4
# https://www.codewars.com/kata/maximum-product/train/python def adjacent_element_product(array): result = [] for i in range(0,len(array)-1): result.append(array[i] * array[i+1]) return max(result)
a6a080fb2533127f519db676050b09186f88b086
GabrielCernei/codewars
/kyu6/Consonant_Value.py
385
3.6875
4
# https://www.codewars.com/kata/consonant-value/train/python ''' Given a lowercase string that has alphabetic characters only and no spaces, return the highest value of consonant substrings. Consonants are any letters of the alpahabet except "aeiou". ''' import re def solve(s): return max(sum(ord(char) for char in...
81ce2422dd7c012e67f0393782c41fcd62e4747f
GabrielCernei/codewars
/kyu8/Needle_In_Haystack.py
168
3.671875
4
# https://www.codewars.com/kata/a-needle-in-the-haystack/train/python def find_needle(haystack): return f"found the needle at position {haystack.index('needle')}"
1f6a0baf7c5382ae4e4775935ef9bf27282ce5d9
GabrielCernei/codewars
/kyu6/Pre_Fizz_Buzz_Workout.py
399
3.671875
4
# https://www.codewars.com/kata/pre-fizzbuzz-workout-number-1/train/python ''' Your inputs: a positive integer, n, greater than or equal to one. n is provided, you have NO CONTROL over its value. Your expected outputs: an array of positive integers from 1 to n Your job is to write an algorithm that gets you from the i...
61e909280a67b37ae7f53ace4915e2ef3b51ba67
GabrielCernei/codewars
/kyu6/To_Weird_Case.py
859
4.5625
5
# https://www.codewars.com/kata/weird-string-case/train/python ''' Note: The instructions are not very clear on this one, and I wasted a lot of time just trying to figure out what was expected. The goal is to alternate the case on *EACH WORD* of the string, with the first letter being uppercase. You will not pass al...
5e328a9b21fb6d29c87cb13a505ffa9045f4f9c2
GabrielCernei/codewars
/kyu8/Is_There_A_Vowel_In_There.py
263
3.734375
4
# https://www.codewars.com/kata/is-there-a-vowel-in-there/train/python def is_vow(inp): arr = [] vowels = {97: 'a', 101: 'e', 105: 'i', 111: 'o', 117: 'u'} for i in inp: arr.append(vowels[i]) if i in vowels else arr.append(i) return arr
e10dd263b50b0f9bcae11454ee4f6881ca9097fb
GabrielCernei/codewars
/kyu8/Count_By_X.py
193
3.640625
4
# https://www.codewars.com/kata/count-by-x/train/python def count_by(x, n): """ Return a sequence of numbers counting by `x` `n` times. """ return list(range(x, x * n + 1, x))
e8738a6488b14d98062fd5f9683199558b4cb395
GabrielCernei/codewars
/kyu8/Find_Me.py
159
3.5625
4
# https://www.codewars.com/kata/find-me/train/python def find_me(s): r = s.lower().find('me') if r == -1: return "i am not there" return r
fb3dbfbba87769c33761ca7d356a3ff9a30c6fd4
GabrielCernei/codewars
/kyu7/Spacify.py
228
3.828125
4
# https://www.codewars.com/kata/spacify/train/python ''' Modify the spacify function so that it returns the given string with spaces insertedbetween each character. ''' def spacify(string): return ' '.join(list(string))
f24570eeca7abe176d75cbd94245fd5db47cf656
GabrielCernei/codewars
/kyu7/Product_Of_Maximums_Of_Array.py
286
3.765625
4
# https://www.codewars.com/kata/product-of-maximums-of-array-array-series-number-2/train/python def max_product(lst, n_largest_elements): largest_items = sorted(lst)[-n_largest_elements:] product = 1 for number in largest_items: product *= number return product
76bfc227eac7c5b514f0be64c5bdcf2e2bb866a6
AkitsukiM/Closet-of-Akitsuki
/Code_Library_C_Cpp/primenum.py
658
3.578125
4
import datetime import math isEND = False n = int(input("No.n Prime Number, n:\n")) sup = int(n * math.log2(n)) t1 = datetime.datetime.now() a = [True] * sup a[0] = False a[1] = False a[2] = True count = 1 # 素数个数计数 k = 3 # 素数列素数指示器 i = 3 # 素数倍乘筛法指示器 while True: j = 3 while j < sup / i: a[i * j] = False # 素数倍乘筛...
edf89f38b5d12de37559514939d6796d9d71a617
ankiwoong/COS_PRO_LV2
/2급_10_initial_code.py
1,231
3.609375
4
''' 1. 문제 분석 - 공식을 확인 - 총합 : 모든 값을 더한 값 - 평균 : 총합을 개수로 나눈 것 - '~ 이하'는 <= 연산으로 표현 / 작거나 같은 / 같거나 작은 2. 필요한 기능(문법)적 요소들 추리기 def solution(data): total = sum(data) average = len(data) / total cnt = 0 for d in data: if d <= average: cnt += 1 return cnt ''' def solution(data): to...
ae87fdd79ecb119485fc285e04894d848a3080f8
adkanyer/CS361Lab6
/ListTests.py
2,250
3.5
4
import unittest from ListUI import * class UserDoesNotExistException(Exception): pass class TestList(unittest.TestCase): def setUp(self): self.listui = ListUI() self.listui.users = [{"username": "ExistingUser", "password": "12345", "current": False, "wishlist": []}] def get_user_names(s...
0e26c6bb0da2b0e5546e86aa6b2cb6ba09b27ccf
enajeeb/python3-practice
/PythonClass/answer_files/exercises/sorting.py
711
4.1875
4
# coding: utf-8 ''' TODO: 1. Create a function called sort_by_filename() that takes a path and returns the filename. - Hint: You can use the string's split() function to split the path on the '/' character. 2. Use sorted() to print a sorted copy of the list, using sort_by_filename as the sorting function. ''' p...
ad4ba655493fb9be334ea4b23ae52a179fde539b
enajeeb/python3-practice
/PythonClass/class_files/exercises/tuples.py
1,635
4.03125
4
# coding: utf-8 ''' Tuples A tuple is a light-weight list that is immutable. It's used to quickly pass around related values, and often to represent a row from a database or spreadsheet. Documentation: http://www.tutorialspoint.com/python/python_tuples.htm ''' # Basic tuples animals = ('frog', 'bird', 'horse') pr...
c09cdf2e94f9060f285d01e110dc2fc48f2db496
enajeeb/python3-practice
/PythonClass/class_files/exercises/lists.py
688
4.34375
4
# coding: utf-8 ''' Lists Lists have an order to their items, and are changeable (mutable). Documentation: https://docs.python.org/2/tutorial/introduction.html#lists ''' # Square brackets create an empty list. animals = [] # The append() function adds an item to the end of the list. animals.append('cat') animals...
cffa20e72d74c07324bac4fdd490bac5218dae9a
enajeeb/python3-practice
/PythonClass/class_files/exercises/functions.py
552
4.40625
4
# coding: utf-8 ''' Useful functions for the Python classs. ''' ''' TODO: 1. Create a function called words(). 2. The function should take a text argument, and use the string's split() function to return a list of the words found in the text. The syntax for defining a function is: def func_name(arg...
dd18b7dbf8cf814f889a497c4565dcb3b1d12719
drnodev/CSEPC110
/meal_price_calculator.py
1,349
4.15625
4
""" File:meal_price_calculator.py Author: NO Purspose: Compute the price of a meal as follows by asking for the price of child and adult meals, the number of each, and then the sales tax rate. Use these values to determine the total price of the meal. Then, ask for the payment amount and compute the amount of chan...
dddb9825283337cd715ed560cc2c52235c94c46a
minoskt/ComedyParser
/ComedyParser/playComedy.py
2,429
3.71875
4
#!/usr/bin/env python # A filename is expected as the first command-line argument. import sys import json import os from ComedyParser import ComedyParser def askInput(parser): # ask for the user input userinput = raw_input('Command: ') # Quit command if userinput == "quit": # stop the pa...
8d4b41e04a2843ccfa22c47dc8a4920fce796ac8
minoskt/ComedyParser
/ComedyParser/Robot.py
1,605
3.84375
4
class Robot: '''Outputs of the Robot''' def __init__(self): self.head = Head() self.torso = Torso() self.arm_left = Arm("left") self.arm_right = Arm("right") class Head: def __init__(self): # ids self.nod = "87" self.turn = "116" self.rol...
1084da01bc27df8e646ce8700076e404111e2cce
jofoks/Density-Plot
/main.py
2,526
3.5625
4
import pandas as pds from collections import deque Atoms = pds.read_csv('Data/Periodic Table of Elements.csv') # Delete Unimportant Data for this project del Atoms['Year'] del Atoms['Discoverer'] Molecules = pds.read_csv('Data/Molecules.csv') # A Dataframe only containing 3 columns: Atoms_short = Atoms[['AtomicMass'...
afc822b816c22279980bf704cc018006a3480377
danieldugas/Vitrified-Code
/Python/interet.py
930
3.515625
4
items = {'oui', 'non'} the_choice = 0 while the_choice == 0: for i in range(30): print("\r\n") choice = input("Interessé? \r\n\r\n\r\n\r\n\r\n\r\n\r\n ********* \r\n\r\nVotre choix: ") if choice in items: the_choice = choice else: print("Je ne parle pas cette langue, bar...
2eec4c27eb42437ae8aa434bff5ad68da7d0db8d
dharmik-thakkar/GeekyStuff
/src/data_structures/nodes.py
181
3.625
4
class Node(object): """ Class representing a node for linked list, stack, queue, etc. """ def __init__(self, key): self.data = key self.next = None
34d1b04da6b5d81196185ffc463956b644c62b36
threecuptea/python3
/Bfs.py
2,327
3.671875
4
from collections import deque num_row = 0 num_col = 0 obstacles = [] #East, south, west, north moves = [(0, 1), (1, 0), (0, -1), (-1, 0)] def find_next_point(curr, r_diff, c_diff): r, c = curr if (c_diff != 0): while (True): next = c + c_diff if (next < 0 or next == num_col or ...
58e20b843d125bcfbea9e9d446b18dcc16dc45ba
LucasHenriqueAbreu/introducaoprogramaca
/jogod_da_velha.py
5,746
3.890625
4
pos1 = None pos2 = None pos3 = None pos4 = None pos5 = None pos6 = None pos7 = None pos8 = None pos9 = None def mostrar_tabuleiro(): print(''' | | {0} | {1} | {2} ____|_____|_____ | | {3} | {4} | {5} ____|_____|_____ | | {6} | {7...
cb0e31e188413edb6c8f66728e0a4caae84d4049
LucasHenriqueAbreu/introducaoprogramaca
/exercicio41.py
136
4.09375
4
soma = 0 for i in range(0, 6): numero = int(input('Informe um número')) if numero % 2 == 0: soma += numero print(soma)
a90c6a4910e4c959057a6662dfb76c08fa123931
LucasHenriqueAbreu/introducaoprogramaca
/exercicios.py
777
4.15625
4
# Desenvolva um programa que leia quatro valores pelo teclado e guarde-os em uma tupla. No final, mostre: # A) Quantas vezes apareceu o valor 9. # B) Em que posição foi digitado o primeiro valor 3. # C) Quais foram os números pares. valores = ( int(input('Informe um número: ')), int(input('Informe um número: ...
37d7f45bc255232f52a45f162e1ac3e3097acb1a
LucasHenriqueAbreu/introducaoprogramaca
/exercicio40.py
143
3.9375
4
numero = int(input('Informe um número para ver sua tabuada: ')) for i in range(1, 11): print('{} X {} = {}'.format(i, numero, i * numero))
cce6f64f9d45bbf480b5df8cf13ebad111b77c71
LucasHenriqueAbreu/introducaoprogramaca
/funcoes.py
494
3.84375
4
def soma(num1, num2): return num1 + num2 def subtracao(num1, num2): return num1 - num2 def multiplicacao(num1, num2): return num1 * num2 def divisao(num1, num2): return num1 / num2 def calculadora(num1, num2): som = soma(num1, num2) sub = subtracao(num1, num2) mul = multiplicacao(num1, n...
1582bc897940022a9411b15fd877349ad20aabf6
1lch2/PythonExercise
/leetcode/binary_tree/102.py
1,423
4.09375
4
# 给你一个二叉树,请你返回其按 层序遍历 得到的节点值。 # (即逐层地,从左到右访问所有节点)。 # 示例: # 二叉树:[3,9,20,null,null,15,7], # 3 # / \ # 9 20 # / \ # 15 7 # 返回其层次遍历结果: # [ # [3], # [9,20], # [15,7] # ] from typing import List # Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x ...
06bfdbdd856236de4271328b2b047f6b23112dd6
1lch2/PythonExercise
/leetcode/back_track/17.py
1,646
3.53125
4
# 给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合。 # 给出数字到字母的映射如下(与电话按键相同)。注意 1 不对应任何字母。 # 1 2 3 # ABC DEF # 4 5 6 # GHI JKL MNO # 7 8 9 # PQRS TUV WXYZ # 示例: # 输入:"23" # 输出:["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]. # 说明: # 尽管上面的答案是按字典序排列的,但是你可以任意选择答案输出的...
af60422eaf81b7eb6a88451df9355a7b7d9b9f71
1lch2/PythonExercise
/leetcode/string/165.py
1,857
3.578125
4
# 比较两个版本号 version1 和 version2。 # 如果 version1 > version2 返回 1,如果 version1 < version2 返回 -1, 除此之外返回 0。 # 你可以假设版本字符串非空,并且只包含数字和 . 字符。 #  . 字符不代表小数点,而是用于分隔数字序列。 # 例如,2.5 不是“两个半”,也不是“差一半到三”,而是第二版中的第五个小版本。 # 你可以假设版本号的每一级的默认修订版号为 0。 # 例如,版本号 3.4 的第一级(大版本)和第二级(小版本)修订号分别为 3 和 4。其第三级和第四级修订号均为 0。 #   # 示例 1: # 输入: version1 = ...
885c9983145721419418ee9445f7ed6ae5d0329b
1lch2/PythonExercise
/code_challenges/Netease_2019_代价.py
1,160
3.953125
4
# 你有3个需要完成的任务,完成这3个任务是需要付出代价的。 # 首先,你可以不花任何代价的完成一个任务; # 然后,在完成了第i个任务之后,你可以花费|Ai - Aj|的代价完成第j个任务。|x|代表x的绝对值。 # 计算出完成所有任务的最小代价。 # 输入描述: # 一行3个整数A1,A2,A3,每个数字之间用一个空格分隔。所有数字都是整数,并且在[1,100]范围内。 # 输出描述: # 一个整数,代表最小的代价。 # 输入例子1: # 1 6 3 # 输出例子1: # 5 # 输入例子2: # 10 10 10 # 输出例子2: # 0 def calculateCost(data: list) -> int:...
5f4792ea1ff421c1925c7937ff4ef1de979f3dc8
1lch2/PythonExercise
/leetcode/search/35.py
1,014
3.703125
4
# 给定一个排序数组和一个目标值,在数组中找到目标值,并返回其索引。 # 如果目标值不存在于数组中,返回它将会被按顺序插入的位置。 # 你可以假设数组中无重复元素。 # 示例 1: # 输入: [1,3,5,6], 5 # 输出: 2 # 示例 2: # 输入: [1,3,5,6], 2 # 输出: 1 # 示例 3: # 输入: [1,3,5,6], 7 # 输出: 4 # 示例 4: # 输入: [1,3,5,6], 0 # 输出: 0 class Solution: def searchInsert(self, nums: List[int], target: int) -> int: lo...
336c3f54250b74825da01b52717be854cca019fb
1lch2/PythonExercise
/leetcode/back_track/47.py
2,055
3.578125
4
# 给定一个可包含重复数字的序列,返回所有不重复的全排列。 # 示例: # 输入: [1,1,2] # 输出: # [ # [1,1,2], # [1,2,1], # [2,1,1] # ] from typing import List class Solution: def permuteUnique(self, nums: List[int]) -> List[List[int]]: # 同一层之间迭代,不同层之间递归向下进入 # "112" # / | \ # 1 1 2 # / \ ...
42be8259fb9359fdbb43a3ed2fcf23337a57bb9f
1lch2/PythonExercise
/leetcode/binary_tree/144.py
1,245
4.03125
4
# 给定一个二叉树,返回它的 前序 遍历。 #  示例: # 输入: [1,null,2,3] # 1 # \ # 2 # / # 3 # 输出: [1,2,3] # 进阶: 递归算法很简单,你可以通过迭代算法完成吗? # Definition for a binary tree node. from typing import List class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None # http...
9b53ed6565d589e92dde90dd6b41415cc1bcc69a
1lch2/PythonExercise
/leetcode/string/9.py
966
3.890625
4
# 判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。 # 示例 1: # 输入: 121 # 输出: true # 示例 2: # 输入: -121 # 输出: false # 解释: 从左向右读, 为 -121 。 从右向左读, 为 121- 。因此它不是一个回文数。 # 示例 3: # 输入: 10 # 输出: false # 解释: 从右向左读, 为 01 。因此它不是一个回文数。 # 进阶: # 你能不将整数转为字符串来解决这个问题吗? # 骚操作 class Solution: def isPalindrome(self, x: int) -> bool: ...
d77ce93806a81b2448cc4f98ad6b2336bbcd1bf3
1lch2/PythonExercise
/data_structures/linkedlist.py
3,298
4.3125
4
class ListNode: """Node of a linked list. Attributes: val: Value of the node. next: Pointer of the node, default: None. """ def __init__(self, x: int): self.val = x self.next = None def printnode(self): """Print the linked list in string format. eg...
ecdf2540b01d6a3ff6d7309e5ecc9603b02e2f04
1lch2/PythonExercise
/leetcode/sort/350.py
2,359
3.9375
4
# 给定两个数组,编写一个函数来计算它们的交集。 # 示例 1: # 输入:nums1 = [1,2,2,1], nums2 = [2,2] # 输出:[2,2] # 示例 2: # 输入:nums1 = [4,9,5], nums2 = [9,4,9,8,4] # 输出:[4,9] # 说明: # 输出结果中每个元素出现的次数,应与元素在两个数组中出现次数的最小值一致。 # 我们可以不考虑输出结果的顺序。 # 进阶: # 如果给定的数组已经排好序呢?你将如何优化你的算法? # 如果 nums1 的大小比 nums2 小很多,哪种方法更优? # 如果 nums2 的元素存储在磁盘上,磁盘内存是有限的, # 并且你不能一次加载...
68bfd7b822803eacd40fa8f468328155bb66c181
Pvredev/Options-Trading-Strategies-in-Python
/Turtle Trading.py
2,845
3.5
4
# Let's Start #Import the necesary libraries # To get the closing prices data from pandas_datareader import data as pdr import yfinance as yf yf.pdr_override() # Plotting data import matplotlib.pyplot as plt import seaborn #data Manipulation import numpy as np import pandas as pd # Define a func...
cdfd3d57aacdc83f58a998e3928e7ec9f9d0b807
bledzinski/programowanie-sieciowe
/Case studies/case2.py
321
3.84375
4
# Create a simple IF function that compares two values and prints result. nativeVLAN = "1" dataVLAN = "100" vlan = input("Podaj VLAN: ") if vlan == nativeVLAN: print("Podany VLAN jest natywnym VLANEM.") elif vlan == dataVLAN: print("Podany VLAN jest data VLANEM.") else: print("Brak VLANow o tym numerze.")...
00345c7f72f5052c337e49781c21b29eb10bcf38
hgs3896/hyuaistudy
/matrix.py
823
3.546875
4
# written in Python 3.5.3 def matrix_add(lhs, rhs): if len(lhs) != len(rhs) or len(lhs[0]) != len(rhs[0]): return result = [] m = len(lhs) n = len(lhs[0]) for i in range(m): row = [] for j in range(n): row.append(lhs[i][j] + rhs[i][j]) ...
2411cc5f4701eed4270c2c726ef02234b82e9d2f
LiFuche/gloryload
/chapter习题01/practice02.py
195
3.5
4
num = [] for i in range(4): num.append(int(input("please input number:"))) result = num[0] + num[1] -num[2] * num[3] print("%d + %d - %d * %d = %d" % (num[0], num[1], num[2], num[3], result))
2958c3fc081aea18305d10dfb621df2f7d636e54
LiFuche/gloryload
/chapter习题01/practice01.py
194
4.3125
4
# coding=utf-8 ascii_num = int(input("please input a num(1~127):")) if (ascii_num < 1) or (ascii_num > 127): print("num not in 1~127!") else: print("%s--->%s" % (ascii_num,chr(ascii_num)))
2a790559f8cdd8f02e639434afc06e8332efe52c
LiFuche/gloryload
/chapter习题01/practice10.py
230
3.734375
4
# filename: practice10.py # coding=utf-8 number = int(input("请输入一个数字:")) if number % 3 == 0 and number % 5 == 0: print("%d能同时被3和5整除" % number) else: print("%d不能同时被3和5整除" % number)
fa55b48d9050a744c7c058c0af42fde8da847939
LiFuche/gloryload
/chapter习题01/practice19.py
183
3.953125
4
def factorial(n): if n > 1: return n * factorial(n-1) else: return 1 number = int(input("请输入一个整数:")) print("%d的阶乘是:%s" % (number, factorial(number)))
8495a9dbe1024ac7a056e8343948b62e531ad4f7
Naval30/datastructures
/stack.py
414
3.875
4
class stack: def __init__(self): self.items = [] def isEmpty(self): return(len(self.items) == 0) def push(self,data): self.items.append(data) def pop(self): return self.items.pop() def peek(self): return self.items[-1] def size(self): return len(self.items) s = stack() s.push(5) s.push...
c4439de8adcca58392f66d6b5e7b694c910fa373
aurum-king/GeeksForGeeks-DSA-2
/04 Recursion/4.01 Print 1 to N without Loop.py
98
3.640625
4
n = int(input()) def num(n): if n == 0: return num(n-1) print(n, end = " ") num(n)
66e2da8da672ff4ac6d5d078b31dfe12448adad0
aurum-king/GeeksForGeeks-DSA-2
/05 Arrays/Basic/3 array leaders.py
330
3.78125
4
arr = [5,3,20,15,8,3] n = len(arr) max = -999999 for i in range(n-1,-1,-1): if arr[i] > max: print(arr[i], end = " ") # you can use stack and then print to get in the same order max = arr[i] # Leader of an array are the elements in which no element on the right side of teh element is greater than that...
121d14a3a8baf96f99fca40be1f9a449b426cec2
aurum-king/GeeksForGeeks-DSA-2
/04 Recursion/4.13 decimal to binary.py
90
3.671875
4
def binary(n): if n == 0: return binary(n//2) print(n%2, end = " ") binary(10)
61697917c4c908e1f3ab83c620b1fa8a8f56270b
bani4/python101
/CorrectBrackets.py
333
3.6875
4
data=input() #() remove def remove_neighbour(sent): sent=sent.replace("()", "") a=sent.find('(') b=sent.find(')') if (b-a)==1 and (a!=-1 and b!=-1): return remove_neighbour(sent) else: return sent #(()) data=remove_neighbour(data) if data=="": print(True) else: ...
75c3e8417a48c8908691d804719278abc472360c
MashaOfficial/myfirstprojects
/Mathematic.py
2,012
3.671875
4
# Интерполяция полиномом Лагранжа # f(x) = 0,835x^(3) - 0.592x на [1;8] import numpy as np import matplotlib.pyplot as plt # Зададим степень интерполяционного полинома и границы интерполяционного отрезка [a,b] n = 10 a, b = 1, 8 # Построим равномерную интерполяционную сетку из n+1 узлов на заданном отрезке x = ...
4b1a1146fa950fa4123e98f23136347e17169a70
faruk9984/Digital_clock
/main.py
549
3.875
4
# Digital Clock with Python from tkinter import Label,Tk import time app_window=Tk() app_window.title('Digital clock') app_window.geometry('420x150') app_window.resizable(1,1) text_font=('Boulder',68,'bold') background='#f2e750' foreground='#363529' broder_width=25 label=Label(app_window,font=text_font,bg=backgroun...
d71ae61237c418d51cdf4f4085d4835e77bbe2b9
CmdBianchi/UNINTER.06-FUCTIONS.Class.6.1
/main.py
3,656
4.0625
4
######################################################################## #-------------> Exercicio 01 | TUPAS mochila = ('Machado', 'Camisa', 'Bacon', 'Abacate') print(mochila) ('Machado', 'Camisa', 'Bacon', 'Abacate') print(mochila[0]) #print do elemento 1 - Indice 0 print(mochila[2]) #Print do elemento 3 - Indice ...
7678627b28f7e53bd975acb8bc8bb936cacf6a06
alexNgari/hackerrank
/AdvancedArrayConstruction/advanced_array_construction.py
701
3.515625
4
#!/bin/python3 import os import sys # # Complete the arrayConstruction function below. # def arrayConstruction(n, s, k): # arrayOfArrays = [] if s>k: tempArray = [1 for i in range(k)] tempArray[-1] = s - (k-1) arrayOfArrays.append(tempArray) for i in range(k-1): ...
ea6ad9331eff1ad7a65e30303ad4606219bd67e0
pravsingh/Algorithm-Implementations
/Binary_Search/Python/jcla1/binary_search.py
568
3.96875
4
# Expects the array to be sorted def binary_search(arr, target): if len(arr) < 1: return -1 middle = int(len(arr) / 2) middle_value = arr[middle] if middle_value > target: return binary_search(arr[:middle], target) elif middle_value < target: v = binary_search(arr[middle + ...
9f5512a1a2f5b524c90bc111506dd75a65970a88
pravsingh/Algorithm-Implementations
/Bozosort/Python/jcla1/bozosort.py
284
3.703125
4
from random import randint # Works by, if not sorted yet, picking 2 random indicies # and swapping the 2 elements def bozosort(arr): while not sorted(arr) == arr: a, b = randint(0, len(arr)-1), randint(0, len(arr)-1) arr[a], arr[b] = arr[b], arr[a] return arr
f6a45bc5a5796aca761a8b329421d4c15bd8b919
pravsingh/Algorithm-Implementations
/Hamming_Code/Python/AlexMathew/HammingCode.py
1,809
3.78125
4
""" AUTHOR : Alex Mathew EMAIL : alexmathew003@gmail.com There is a lot I can do to improve this implementation. """ """For a given binary word, print out its corresponding Hamming Coded word""" import math def FindKeyBits(n): keyBits=[] pad = int(math.ceil(math.log(n)/math.log(2))) for i in xrange(1, n+1):...
bf0bf3793e41189cb7c3f5a9973e80ad623e91da
pravsingh/Algorithm-Implementations
/Vigenere_Cipher/Python/Valery S/VigenereCipher.py
1,468
3.78125
4
import string class VigenereCipher: def __init__(self): self._alphabet = string.uppercase[:26] def cipher(self, word, key): if len(word) != len(key): raise ValueError('Key should be same length as encrypted word!') word_letter_indexes = zip(self._alphabet_indexes(word), se...
d0e894d5669fada9163daf28bfa74fd747dcfc65
pravsingh/Algorithm-Implementations
/Kruskal_Minimum_Spanning_Tree/Python/paveldedik/kruskal.py
1,471
4.0625
4
class DisjointSet(object): """Simple implementation of disjoint-set data structure.""" def __init__(self, key): self.key = key self.parent = None self.rank = 0 def __eq__(self, other): if isinstance(other, type(self)): return self.key == other.key return...
3f610f888bf44de3597ce62ba709f05fcf0c49e3
pravsingh/Algorithm-Implementations
/Fisher-Yates/Python/jcla1/fisher_yates.py
305
3.5
4
from random import randrange # Note, this shuffle modifies the original array def fisher_yates(arr): m = len(arr) while m: i = randrange(m) m -= 1 arr[i], arr[m] = arr[m], arr[i] return arr if __name__ == '__main__': arr = range(50) print fisher_yates(arr)
f4ef2fbc89717a7b48b6ea7cb4140df9b65a81d6
pravsingh/Algorithm-Implementations
/String_to_int/Python/tdoly/string_to_int.py
512
4.09375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' File: string_to_int.py Author: tdoly Description: string convert to int without a library, For example, int('111') ''' def parseInt(number): if len(number) < 1: return None nums = [(ord(number[-(i+1)])-48) * 10**i for i in range(len(number))] retur...
bf2412b4b32dcc5a6f3ca5ab9e8e42e028ac3a21
pravsingh/Algorithm-Implementations
/Binary_Search_Tree/Python/dalleng/bst_test.py
2,451
3.71875
4
import unittest from bst import BinarySearchTree class BinarySearchTreeTest(unittest.TestCase): def test_insertion(self): tree = BinarySearchTree() tree.insert(8) tree.insert(3) tree.insert(10) tree.insert(1) tree.insert(6) tree.insert(4) tree.insert(...
3c395ecd316a32caad83b833ad75de75cebd67cd
tyrone-dev/python
/class_attr_defn_order.py
6,662
3.640625
4
#!/usr/bin/env python """ Implementing functionality to list Python Object attributes in definition order """ from collections import OrderedDict from odict import odict import struct ## what does object do here?? #class first(object): # #def __init__(self, *args, **kwargs): # # self._attrs = OrderedDict(*...
d9564864630aef5e0b0ef837afd8615aceb6efb3
tyrone-dev/python
/argparse_tut.py
2,985
3.890625
4
#!/usr/bin/env python # above - shebang line #! ensures that the correct interpreter is used to execute the script #argparse test #import argparse module import argparse # create argument parser object # add description when creating arg parser object # this object holds all the information necessary to parse comma...
8c105421ad47ad6e48fdc4cc3a9282282e39bd97
Abirii/A-head-on-collision-prevention-system
/server.py
1,899
3.8125
4
''' Server: listen to requests from client (cars). Make from each request thread object, each tread get current location and share this location with all the other threads create_socket() - Create a Socket (TCP) bind_socket() - Binding the socket and listening for connections accepting_connections() - Handlin...
7ccf5d7aea790b567dcb889e558c152ea66e9a56
garyyli/Unit4
/multiply.py
367
4.09375
4
#Gary Li #10/26/2017 #multiply.py from random import randint i=0 while i<6: def multiply(randint(1,12),randint(1,12)): answer = int(input('What is the answer?: ')) if answer == randint(1,12)*randint(1,12): i = i+1 else: print('Sorry, that is incorrect.') print('You...
d8cb7dc35f1f3e47a6be8524766b6727ec2f95dd
sayan19967/Python_workspace
/Python Application programming practice/Class and Static methods.py
4,212
4.53125
5
#A method defined inside a class is bound to its object, by default. #However, if the method is bound to a Class, then it is known as classmethod. #Example 1 defines the method getCirclesCount, #bound to an object of Circle class. ##class Circle(object): ## no_of_circles = 0 ## def __init__(self, radius):...
844344450154b2caacee4af1a0530e14781b9ace
sayan19967/Python_workspace
/Python Application programming practice/Context Managers.py
2,410
4.59375
5
#A Context Manager allows a programmer to perform required activities, #automatically, while entering or exiting a Context. #For example, opening a file, doing few file operations, #and closing the file is manged using Context Manager as shown below. ##with open('a.txt', 'r') as fp: ## ## content = fp.read...
bcca01467706dc452068cfe620132a7a960d5636
ravinthiranpartheepan1407/Data-Science-Projects
/Neural Network/MLP_classification_binary.py
2,403
3.765625
4
# Multilayer perceptron import keras from keras.models import Sequential from keras.layers import Dense, Dropout, Activation from keras import optimizers from sklearn.metrics import confusion_matrix from sklearn.metrics import classification_report import numpy # Sequential - simplest type of model, a lin...
1826fe5958200340a1de6f20f450133035f77cd3
cdever01/molssi_devops_uf
/molssi_devops_uf/molssi_math.py
1,556
4
4
""" molssi_math.py sample project for molssi workshop Some math functions. """ def mean(num_list): """ calculate mean/average from a list of numbers. Parameters ----------- num_list : list The list to take the average of Returns ----------- mean_list : float The ...
c1594fe7488ed25aca35c72df5aa692e134f6011
RockfordFaurot/Git_Python
/Threading.py
1,708
3.59375
4
#create 100 widgites as fast as possible: #get several workers to make a widget include a delay for each worker: #start by writing to difrent documents, #then write to the same document onec you get that figured out. import time import threading #set up a file to read and write to: #file needs to already exist in ...
de9deb8861ef3f5a9177c2d72773edc937a099de
Sindhu983/Dictionary
/saral3.py
208
3.75
4
my_dict = { 'data1':100, 'data2': -54, 'data3': 247 } # c=my_dict.values() # total=sum(c) # print(total) sum=0 for i in my_dict.values(): sum=sum+i print(sum)
12a47f7912c609c5b0b89eb141b7463e70d7f9f6
Sindhu983/Dictionary
/saral8.py
457
3.875
4
# dic1=[] # dic2=[] # dic={} # num=int(input("enter the number :")) # i=1 # while i<=num: # student=input("enter the name :") # marks=int(input("enter the number :")) # dic1.append(student) # dic2.append(marks) # i+=1 # j=0 # while j<len(dic1): # dic[dic1[j]]=dic2[j] # j+=1 # print(dic) dic...
1758d3ca0ac2a39aae4f83e87246555d88a69d07
Sindhu983/Dictionary
/w3resource5.py
201
3.53125
4
# dic = {1: 1, 2: 4, 3: 9, 4: 16, 5: 25} # for i in dic.items(): # print(i) list=[1,1,1,2,3,3,4,5,5] my_dict={} for i in range(len(list)): my_dict[list[i]]=list.count(list[i]) print(my_dict)
2cbdfb1664ba177a2dba497a11e8c6cc20ae046e
Sindhu983/Dictionary
/saral7.py
283
4.0625
4
dic={ "first":"1", "second": "2", "third": "1", "four": "5", "five":"5", "six":"9", "seven":"7" } result={} for key,value in dic.items(): if value not in result.values(): result[key]=value print(result)
fc38b288716f26b64ab9a5008e1b9f542f6de6f8
rafaelcascalho/workshop-cawem-2019
/Exemplos/swith_case.py
330
4.03125
4
num = int(input('Digite um número : ')) print('O número digitado é...') if num > 1000: print('Maior que 1000') elif num > 500: print('Menor que 1000 e maior que 500') elif num > 250: print('Menor que 500 e maior que 250') elif num > 100: print('Menor que 250 e maior que 100') else: print('Menor qu...
a8aa2da3e3d94bebb2d2d5ae25065516d007da6f
paulaCrismaru/cateow
/cateow/utils.py
5,140
3.546875
4
from __future__ import absolute_import import re from cateow import constants class CateowException(Exception): pass def split_text_in_lines(text): """Splits text in lines of a length specified in the constants file. Args: text (str): the text to be split in lines Returns: List o...
7f1bd2bd09797c2cf6295db9acd6aed1f24ee0c1
andresdeinnocentiis/connect4-python
/connect_4.py
8,759
3.890625
4
""" CONNECT 4 by @andresdeinnocentiis """ from colorama import Fore class Board(object): def __init__(self): pass def createBoard(self): board = [] for line in range(15): row = [] if line % 2 != 0: for column in range(15): ...
f17f80962975220ff78e20ad5c09cb25b2b8a181
Q-ro/Advent-of-code
/Day 5/adv_day5_a.py
2,507
4.09375
4
''' Author: Andres Mrad (Q-ro) Date: Tuesday 17/December/2019 @ 19:33:20 Description: Solution to Day 5 puzzle (Part 1) ''' # Imports import random # Reads the file and returns it contents def fileReader(path): with open(path, "r") as filehandle: filecontent = filehandle.read() return filecontent # ...
baef544efc97fab5a7ce87d4a9ccff5fae67b5f8
DeepthiTabithaBennet/Py_Conversions_Temperature
/Celsius_to_Farenheit.py
397
4.28125
4
#TASK : #Convert the given temperature to Farenheit #(Celsius * 9/5) + 32 = Farenheit #INPUT FORMAT : #Temperature in Celsius #OUTPUT FORMAT : #Temperature in Farenheit #__________________________________________________________________________________# Celsius = float(input()) x = Celsius * 9.0 y = x / 5.0...
8564a36451cfa5a43cee6f90e62d3eb968aadc55
ajax711/Homework
/Programming/tut7/string_game.py
322
3.734375
4
import string_check as a sent=str(input("Enter a sentence :")) words=sent.split(" ") while len(words)!=8: sent=str(input("Enter a sentence :")) words=sent.split(" ") print (a.avoid(words[0],words[1])) print (a.uses_only(words[4],words[5])) print (a.uses_all(words[2],words[3])) print (a.is_alphabetic(words[6])...
836187ca366cc2839783fbdc61a9d9f849469e53
ajax711/Homework
/Programming/tut7/7.py
192
3.828125
4
def pattern(x,str1,str2): for i in range(1,x+1): print(str1,end="") print(str2*i, end="") n=int(input("Length")) str1=str(input("Str1")) str2=str(input("Str2")) pattern(n,str1,str2)
1e5b1b3a6233a4eda09c495e328d0e590e0eb956
ajax711/Homework
/Programming/Ass1/q3.py
516
4.03125
4
import math def perf_sq(n): k=math.sqrt(n) if k/int(k) != 1: return "It is not a perfect square" else: return 'It is a perfect square' def perf_num(n): a=1 for i in range(1,n): if n%i==0: a=a+i if a==n: return 'It is a perfect number' else:...
ce139d934c632cc539d81e369540cb420380b1fe
ajax711/Homework
/Programming/test.py
118
3.609375
4
a = [[0]*n]*m print (a) for i in range(n): for j in range(m): a[i][j]=(input("enter a number") print(a[2][4])
d21ee05d6b00f464646d48ef45c47708e922a2f0
shohag000/consoleapp
/foodSelectGame.py
2,163
3.859375
4
import random fakeDBList = ["Chowmein","Chicken tandoori roll",'Shawarma roll',"Sandwich"] newfakeDBList = [] print("==========================================================================") i = 0 k = 0 for singlefakeDBList in fakeDBList: i += 1 print(" No.",i," ", singlefakeDBList) print(" Do y...
998ad791113fc9afb6256ae1ee8eccc59c2884da
bhuynh1103/breakout
/ball.py
1,712
3.53125
4
from pygame.draw import * from constants import * from random import uniform class Ball: def __init__(self): self.w = screenSize * .02 self.x = screenSize // 2 - self.w // 2 self.y = self.x + GUISize self.speed = 7.5 self.xspeed = 0 self.yspeed = -1 self.rel...
e19879fb648480142523d8b8f695fd379b159327
zl6977/BasicKnowledge
/LeetCode/LeetCodePython/566.py
706
3.609375
4
# -*- coding: utf-8 -*- class Solution: def matrixReshape(self, nums, r, c): """ :type nums: List[List[int]] :type r: int :type c: int :rtype: List[List[int]] """ origin_r = len(nums) # 行 origin_c = len(nums[0]) # 列 if origin_c * origin_r =...
7384732c14baa656b237ac8c1b09eb0f80478997
hernbrem/TYK2CodeAAA
/Andrew/Chapter 1/YourName.py
538
3.640625
4
#YourName.py name = input("What is your name?\n") print("Hi, ", name) FavoriteColor = input("What is your favorite color?\n") HowDoing = input("How are you?\n") FavoriteAnimal = input("What is your favorite animal?\n") FavoritePottyWord = input("What is your favorite potty verb that ends in -ed?\n") FavoriteShape = i...
81eccca3e13efaf255a41a92b5f7ee203a6aca41
Elzwawi/Core_Concepts
/Objects.py
2,689
4.4375
4
# A class to order custom made jeans # Programming with objects enables attributes and methods to be implemented # automatically. The user only needs to know that methods exist to use them # User can focus on completing tasks rather than operation details # Difference between functions and objects: Objects contain stat...
f85d01d6166584b65c782a9c061218c075b682ee
tytyrytyty/adventofcode2016
/day1/task2.py
1,161
4
4
#!/usr/bin/python import sys class Position: numberOfDirection = 4 def __init__(self, x, y, direction): self.x = x self.y = y self.direction = direction def move(self, turn, distance): if turn == 'L': if self.direction == 0: self.direction = self.numberOfDirection-1 else: self.direction -= 1 ...
df8d860662fe2981ab9c5a3f2a6d1fd83609a742
Jon-117/py.projects
/prime numbers.py
289
3.765625
4
high_n=float(input("prime numbers up to...")) num = 0 while True: num+=1 ''' numcheck=num % range(0,(high_n+1.0)) if numcheck.is_integer(): print(num) ''' print(num) ''' i=0 while True: False i+= 1 if i == ((i/i) and (i/1)) : print(i) '''
e9a66076aa0f3f34aec0c7b17644ce140e8d1d54
ebracho/project-euler
/24/factoradic.py
791
3.765625
4
#!/usr/bin/env python3 from math import factorial # Returns the factoradic representatin of decimal n # Ex: factoradic(11) => [1,2,1,0] # ie [1*3! + 2*2! + 1*1! + 0*0!] def factoradic(n,pad=0): res = [] radices = [1] while radices[-1] < n: radices.append(radices[-1] * (len(radices) + 1)) while radices: radix...
fbe909c69ed98c46929cdf210ce06a2475d5031d
SavannahFloyd/CITA-280-FINAL
/time.py
451
3.734375
4
import time def timer(timerSeconds): timer = timerSeconds print (timer) time.sleep(1) for i in range(timer): timer = timer - 1 print(timer) time.sleep(1) ## if playerSprite gets a time boost: ## timer = timer + 5 if timer == 0: ##or player ...
aac3cf4e235cb361b976b70d9d4fa4e75a96c0d9
Shubzedm007/Hactoberfest-accepted
/TicTacToe/tic_tac_toe.py
2,688
4.09375
4
def display_board(user_placements): ''' display a 3*3 board with choices filled by players ''' print('\n' * 50) for row in range(0, 3): print('|' + ' '*2,end='') for element in range(0, 3): print(f'{user_placements[row * 3 + element]}{" " * 2}|',end='') print...