blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
9fb09590a1b9a2cc3a3e5d30d389cccc01db900b
JJBaktha/Iterations
/Iteration Stretch and challenge 1.py
329
4.1875
4
#Jeeson Baktha #Iteration Stretch and challenge 1 #22 October 2014 number = int(input("Please enter an integer to display the squares to\n")) squared_numbers=[] for count in range (1,number+1): squared_number = count * count squared_numbers.append(squared_number) print(squared_numbers)...
d86352a72561accc3fbeef00e47ef67cd64063da
huangy10/MyLeetCode
/2-add-two-numbers/woodyhuang.py
776
3.796875
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def addTwoNumbers(self, l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode """ x, y = l1, l...
3f34fea9040871991248637e735afd7f592ba91e
chenzhiyuan0713/Leetcode
/Easy/Q64.py
1,017
3.75
4
''' 剑指 Offer 15. 二进制中1的个数 请实现一个函数,输入一个整数(以二进制串形式),输出该数二进制表示中 1 的个数。例如,把 9 表示成二进制是 1001,有 2 位是 1。因此,如果输入 9,则该函数输出 2。 示例 1: 输入:00000000000000000000000000001011 输出:3 解释:输入的二进制串 00000000000000000000000000001011 中,共有三位为 '1'。 示例 2: 输入:00000000000000000000000010000000 输出:1 解释:输入的二进制串 00000000000000000000000010000000 中,共有...
65a5b84507a33540579c31ae5d3342366158519c
nju04zq/algorithm_code
/medium/073_Set_Matrix_Zeroes/set_matrix_zeroes_1.py
1,885
3.65625
4
class Solution(object): def set_matrix_row_zero(self, matrix, n, i): for j in xrange(n): matrix[i][j] = 0 def set_matrix_col_zero(self, matrix, m, j): for i in xrange(m): matrix[i][j] = 0 def is_set_row0_zero(self, matrix, n): for j in xrange(n): ...
f09e52caa6ea77cd9783a853bf3ff53ea07566eb
Maopos/Basic_Python
/011_Funciones/11.06_funciones_recursivas.py
1,952
4.34375
4
# Funciones recursivas print('======================') print() print('=== Funciones Recursivas ===') # 4! = 1 * 2 * 3 * 4 = 24 # 5! = 1 * 2 * 3 * 4 * 5 = 120 def factorial_iterativo(n): ''' Calcula el factorial de un numero. (Enfoque iterativo) Parameters: n: numero de factorial a calcular ...
a9d49ff7f92402c7d2d0fcfa3b446da09a3f4e40
AKumanov/Multidimensional_Lists
/Multidimensional Lists/Excercise/present_delivery.py
3,065
3.515625
4
def get_next_move(dirs, r, c): if dirs == "up": return r - 1, c elif dirs == "down": return r + 1, c elif dirs == "left": return r, c - 1 return r, c + 1 def in_range(r, c, size): return 0 <= r < size and 0 <= c < size count_of_presents = int(input()) size = int(input()) ...
0c4b94393594f8acfd1d9870d55316f8fd6d1b2d
SANDHIYA11/myproject
/B36.py
406
3.90625
4
n=input("Enter the number or character or special character:") c=0 for i in n: if(i=='!' or i=='@' or i=='#' or i=='$' or i=='%' or i=='^' or i=='&' or i=='*' or i=='(' or i==')' or i=='_' or i=='-' or i=='+' or i=='=' or i=='{' or i=='}' or i=='[' or i==']' or i=='|' or i=='\' or i==':' or i==';' or i=='"' or i=='''...
e752b2873123ed38f822761ae0e1ae168724f0c4
Acapellia/Algorithm
/Python/Code2011/201117_Union.py
731
3.90625
4
def findParent(parent,x): if parent[x] != x: return findParent(parent,parent[x]) return parent[x] def unionParent(parent,x,y): x = findParent(parent,x) y = findParent(parent,y) if x < y: parent[y] = x else: parent[x] = y v, e = map(int, input().split()) pare...
7d89ae8e9051bdfa93d4e0adfd026267e63f52d2
zhangxw1986/vscode-python
/learn_python/33访问限制.py
1,311
3.90625
4
# -*- coding: utf-8 -*- #第一行是保证文件直接在unix、linux、mac上直接执行;第二行注释表示使用UTF-8编码 '32 类和实例' #任何文件的第一个字符串,表示模块的文档注释 __author__ = 'zhangxw1986' #表示作者 #以上就是python模块的标准文件模板;接下来才是真正的文件 class Student(object): def __init__(self,name,score): self.__name = name self.__score = score def printScore(self):...
2e55050fb86845e51f4b3e8f2e352a43118a3d93
gelapro/arkademy
/python-untuk-pemula2/app.py
555
4.1875
4
# method/function operator = raw_input("Please input operator (+ - * /): ") first_number = raw_input("#1: ") second_number = raw_input("#2: ") first_number = int(first_number) second_number = int(second_number) def calculate(operator, number1, number2): if operator == "+": return number1 + numb...
949ad16490677e9eec20feea560f4df20f7851c5
ecc56/ClassworkSpring2021
/blood_tests.py
1,886
3.6875
4
def interface(): print("Blood Test Analysis") while True: print("\nOptions") print("1 - HDL") print("2 - LDL") print("3 - Total Cholesterol") print("9 - Quit") choice = input("Enter an option: ") if choice == "9": return elif choice == ...
6c96bade3f8b57e5d9b898c287c4d38c2b0759d3
Sanjivkumar100/i-30-workshop
/task 4 9.py
170
3.96875
4
def fact(n): factorial=1 for i in range(1,n+1): factorial*=i print(f"factoial of {n}:{factorial}") a=int(input("Enter a number:")) fact(a)
7bb901859438bbe9700d50945cfaf1b2913cc769
pengyuhou/git_test1
/leetcode/217. 存在重复元素.py
267
3.765625
4
class Solution: def containsDuplicate(self, nums): if len(nums)-len(set(nums)): return True else: return False if __name__ == "__main__": nums = [1,1,1,3,3,4,3,2,4,2] print(Solution().containsDuplicate(nums))
5de1d51d32fcac4430497b1945cd94e9485fe827
prodkuredo/school
/0310_2.py
439
3.609375
4
import random n = 20 a = [] for i in range(n): a.append(random.randint(1, 10)) print(a) for i in range(n): l = i for j in range(i, n): if a[j] > a[l]: l = j a[i], a[l] = a[l], a[i] def qwerty(a): for i in range(len(a)): k = a.count(a[i]) if k > 1: ...
58a1d600ef5f8819c96e868b8bf49a3da121d87a
hbibz-deploy/CTF
/caesar.py
2,685
4.46875
4
#!/usr/bin/env python def getMode(): """ Collecting mode of use: (case insensitive) Encrypt: You can input encrypt or e Descrypt: You can input decrypt or d This function requires no arguments and returns the mode in type string. """ while True: print('Decrypt/Encrypt/quit...
96a8973c37b559403aec3b602f68015f4806fdf2
HighHopes/codewars
/7kyu/Very even Numbers.py
567
4.28125
4
"""Description: #Task: Write a function that returns true if the number is a "Very Even" number. If the number is odd, it is not a "Very Even" number. If the number is even, return whether the sum of the digits is a "Very Even" number. #Examples: input(88) => returns false -> 8 + 8 = 16 -> 1 + 6 = 7 => 7 is odd ...
7e969e305fd9a44ca6cd700b20fb0c2a764c1583
dheerosaur/leetcode-practice
/python/88.merge-sorted-array.py
1,052
4.15625
4
""" Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional elements from nums2. """ from ty...
83bf2512bebf5486e8faed5331c0b5af5d51c7af
ihaku4/leetcode
/length_of_last_word.py
470
3.828125
4
class Solution: # @param s, a string # @return an integer def lengthOfLastWord(self, s): end = len(s) - 1 while end >= 0 and s[end] == ' ': end -= 1 lenLast = 0 while end >= 0 and s[end] != ' ': lenLast += 1 end -= 1 return lenLast ...
35b9a268aa8cadf2eff875e375b4d8ff0023e3df
i5-2/pentium-triple-core
/simple_board.py
23,125
3.703125
4
""" simple_board.py Implements a basic Go board with functions to: - initialize to a given board size - check if a move is legal - play a move The board uses a 1-dimensional representation with padding """ import random import numpy as np from board_util import GoBoardUtil, BLACK, WHITE, EMPTY, BORDER, \ ...
effd5e859cbf07a495eb02ae56cf48e5f63e2dbb
Bruce-zhangyuyang/Leetcode
/easy/374猜数字大小.py
313
3.5
4
# 思路:二分法进行查找 def guessNumber(self, n: int) -> int: start = 1 end = n + 1 while guess((start + end)//2) !=0: if guess((start + end)//2) == -1: end = (start + end)//2 else: start = (start + end)//2 return (start + end)//2 n = 10, pick = 6
2e146ab5b099594cfec2a41c1d885b3fd965b267
romataukin/geekbrains
/les_01/3.py
399
4.0625
4
#Узнайте у пользователя число n. # Найдите сумму чисел n + nn + nnn. # Например, пользователь ввёл число 3. # Считаем 3 + 33 + 333 = 369 num_1 = input('Сколько будет n+nn+nnn=? Задай n: ') num_2 = (num_1+num_1) num_3 = (num_1+num_1+num_1) print(('Ответ:'), int(num_1)+int(num_2)+int(num_3))
7b09f3ba320e2ad04d71f959dfa5fcb8f3dfd5e9
Noviceprogrammer1101/python_code_test
/educoder_tesst/数据库.py
2,725
4.125
4
import sqlite3 import os def create(sql): '''建立表COMPANY''' conn = sqlite3.connect(sql) # print("open database successfully") c = conn.cursor() c.execute('''CREATE TABLE COMPANY (ID INT PRIMARY KEY NOT NULL, NAME TEXT NOT NULL, AGE INT ...
facb9c3191146fe83e3ef1b5a1b07babb450db14
olivar16/weatherDataApp
/beautifulsoup/get-weather-data.py
825
3.53125
4
import urllib2 from bs4 import BeautifulSoup #create/open a file f = open("weatherdata.txt", "w"); #Months January to December for m in range(1,13): # First to last day of the month for d in range(1,32): if (m==2 and d>28): break elif(m in [4,6,9,11] and d>30): break ...
4656a1faade5fc09f74ced2648d5aaf0743e4ba6
HarshaDatascientist/todo-ml
/ML-For-Beginners/101-introduction-to-classical-machine-learning/microsoft_custom_linear_regressor.py
2,166
3.859375
4
from sklearn.base import BaseEstimator from scipy.optimize import minimize import numpy as np class MicrosoftCustomLinearRegressor(BaseEstimator): ''' This class runs linear regression using any custom error function. Example use: ``` X = ... y = ... my_error_function = lambda y,y_pr...
fba84639ad02c865daee7874e9f8e6e3f45b78bf
AishwaryalakshmiSureshKumar/DS-Algo
/tree_isMirror.py
732
3.578125
4
def isMirrorUtil(root1, root2): if root1 is None and root2 is None: return True if root1 is not None and root2 is not None: if root1.data==root2.data: return (isMirrorUtil(root1.left, root2.right) and isMirrorUtil(root1.right, root2.left)) else: return False ...
45e732b07270cae23aa3004ded904668ba92b0d0
psgeisa/python_eXcript
/Excript - Aula 19 - Return.py
359
3.703125
4
""" def soma(): return 10 print(soma()) def soma(x,y): num = x*y return num print("teste") print(soma(10,20)) #Valores empacotados def func(): return 1,2 a, b = func() print(a) print(b) """ def potencia(x): quadrado = x**2 cubo = x**3 return quadrado, cubo q,c...
beccdfea6d458589ad59a4b717517fd05e80a1cf
masatana/snip
/python/str_format.py
334
3.703125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # ref. http://www.python-course.eu/python3_formatted_output.php # => Art: 453, Price per unit: 59.06 print("Art: {0:5d}, Price per unit: {1:8.2f}".format(453, 59.058)) # =>Art: 453, Price per unit: 59.06 print("Art: {a:5d}, Price per unit: {p:8.2f}".format(a=45...
c01ff4c01a9e8656e9bda83e848710760de00778
krishnamurthyav/python
/functional/LeapYear.py
557
3.828125
4
""" ****************************************************************************** * Purpose: Take four digit number of year from user and find it is leap year or not. * @author: Krishna Murthy A V * @version: 1.0 * @since: 26-2-2019 * ****************************************************************************** "...
fd374c666986e474085e23a84b8badb7ed9e3b63
nina-mir/w3-python-excercises
/pandas/DataSeries.py
1,046
4.21875
4
import pandas as pd import numpy as np # 1. Write a Pandas program to create and display a one-dimensional array-like object containing an array of # data using Pandas module. def prob_1(arr): return pd.Series(arr) data = [10,20,"nina"] print(prob_1(data)) index=["CA", "OZ", "MJ"] john = pd.Series(data, inde...
59f03c82437edb364703b280b107a78d34db5c11
kunaljha5/MITx_6.00.1x_Introduction_to_Computer_Science_and_Programming_Using_Python
/newton_raphson.py
461
3.921875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jun 18 11:45:23 2018 @author: ejhakun """ epsilon = 0.01 y = 81.0 guess = y//2.0 num_guess = 0 ####( g - (g^2 -k)/2g) ####(cx^2 + k) #### directive 2xc #### x^2 + k >> 2x while abs(guess*guess -y) >= epsilon: num_guess += 1 guess = guess ...
e202bd24f49bc6197d00d17fc1f7b0360d47dd4b
RhysDeimel/code_challenges
/advent_of_code/2021/02/solutions.py
1,682
3.8125
4
from dataclasses import dataclass def parse(puzzle_input): data = [] for line in puzzle_input.rstrip().split("\n"): command, value = line.split(" ") data.append((command, int(value))) return data @dataclass class FirstComputer: program: list[tuple[str, int]] horizontal: int = 0 ...
207b6cae330c98fb328692d63220e1a24421cf5c
henningward/ProjectEuler
/problem_020.py
529
3.609375
4
import time import numpy as np # https://projecteuler.net/problem=20 # Factorial digit sum def split_int_to_list(word): listofints = [] listofstrings = [char for char in str(word)] for i in range(0, len(listofstrings)): listofints.append(int(listofstrings[i])) return listofints def problem20()...
9da596345bcc8d1699f04dd060eef5808998e761
shilpapantula/python_programming_tutorials
/find_anagrams.py
617
3.921875
4
list_of_words = ['yerbu', 'buena', 'cali', 'roar', 'ubrey', 'ilac', 'raor'] def find_anagrams(list): words_sorted = {} for word in list: words_sorted[word] = ('').join(sorted(word)) anagrams = [] sorted_anagrams = [] count_sorted = {} for key, val in words_sorted.items(): if val in count_sorted: coun...
ba893f82fbdd67a4972bc68819787ab885406693
lmarchesani/IDF_Resources
/Calendar/IFFCalendar.py
7,013
4.09375
4
#! /usr/bin/env python3 #Lucas Marchesani from tkinter import * class MyFirstGUI: def __init__(self, root): self.root = root self.root.title("My Stupid Calendar") root.geometry("800x600") Frame_1 = Frame(self.root) Frame_1.grid() Frame_2 = Frame(Frame_...
91fb7b818723c247f5eb371868d4f5b222aa2b05
Prema15A/python
/largest.py
131
3.875
4
nom1,nom2,nom3=input().split() if(nom1>nom2 and nom1>nom3): print("n1") elif(nom2>nom3): print("n2") else: print("n3")
15e280a0ce22737ea9a79131ac3a59af93c6aaae
JonasG2/Curso-Em-Video-Python
/ex003.py
258
3.859375
4
# -------- QUANTIDADE DE TINTA POR M² -------- # n1 = float(input("Digite a altura da sua parede: ")) n2 = float(input("Digite o comprimento da sua parede: ")) a = n1 * n2 q = a / 2 print("A area e igual a {} m² e voce ira usar {}l de tinta.".format(a,q))
401b175a03b1c890a477a2a254a60fba3424a7b2
richard-durham/AdventOfCode
/Advent_day5.py
826
4.09375
4
''' From www.adventofcode.com Day 5 questions ''' import re with open('day5.txt', 'r') as input_words: list_of_words = input_words.readlines() nice_words = 0 naughty_words = 0 count = 0 vowls = 0 letters_2x = 0 naughty_letters = 0 def illegal_letters(word): if 'ab' in word or 'cd' in word or 'pq' in word ...
36ddbbe0cde0ac57f265edfe0a5fc910beee0e3a
fatihtaparli/phyton
/coding detection.py
521
3.53125
4
# import a library to detect encodings import chardet import glob # for every text file, print the file name & a gues of its file encoding print("File".ljust(33), "Encoding") for filename in glob.glob('./Texte/*.txt'): with open(filename, 'rb') as rawdata: result = chardet.detect(rawdata.read()) print(...
3bf8da33653bdfdfef4cfe3b1f056d67dbb8a188
mosemb/PythonRefresherMIT
/Week2/newtonraphson.py
378
4.25
4
""" Finding the square root using the Newton Raphson Method """ epsilon = 0.01 y = 25 #Number whose square root am looking for guess = y/2.0 num_guesses = 0 while abs(guess*guess-y)>=epsilon: num_guesses=num_guesses+1 guess = guess-(((guess**2)-y)/(2*guess)) print("num_guesses "+ str(num_guesses)) print("th...
823095aca5f0031c7409c86b861bf27170ceef4c
bedermau5/amis_python
/km72/Bederman_Andrey/11/task2.py
1,447
4.125
4
def CreateList(x): """ This function create list with elements Args: element:integer number x:integer number Returns: List with elements Raises: ValueError Examples: >>>print(CreateList(2) >>>Enter element: 5 >...
a4755af331bfcf7430bf00e2a0230acd7aaee468
cikent/Python-Projects
/LPTHW/ex36-DesigningAndDebugging-IfForWhileDebugLoops.py
6,871
4.3125
4
''' The wonderful world of Pokemon ''' # create a list with the Pokemon the player currently owns player_owned_pokemon = [] rival_owned_pokemon = [] # debug print # print(player_owned_pokemon) # Function for the Pokemon Intro def pokemon_intro(): print("\nWelcome to the world of Pokemon!") print("Today you get to ...
5b928224cdc50725a8513dd3a264e3d7b0584be8
vladinlove/study
/quickSort.py
475
4.15625
4
import random def quickSort(array): '''Function for quick int list sort''' if len(array) < 2: return array else: pivot = array[0] less = [i for i in array[1:] if i <= pivot] greater = [i for i in array[1:] if i > pivot] return quickSort(less) + [pivot] + quickSort(gr...
d3b79da3bfd5974deaf636ba5b07fe2887b93e7b
KJeanpol/Analisis-Numerico-para-Ingenieria
/general.py
4,637
3.515625
4
import numpy as np import matplotlib.pyplot as plt import sympy from sympy import symbols, Eq, solve def evaluarXY(funcion,varx,vary): x,y,z = sympy.symbols ('x y z') Fxy=sympy.sympify(funcion).subs({x:varx, y:vary}) return float(Fxy) def evaluar(funcion,varx): """Evalúa una función dependiente de X...
697432215f8e3a9eec28d4fcbcbf712ad0c3501c
Jatin666/tinkter
/try4.py
392
3.625
4
from tkinter import * top=Tk() cv = Canvas(top, height = 300, width = 300) coord = 10, 10, 250, 250 cv.create_rectangle(coord, outline = "red", fill='blue') cv.create_line(1,275,260,275,fill = 'orange', width=5) cv.create_oval(200,200,50,50, fill='yellow') cv.create_text(125,225,text='Hello World',font=("Arial",20),fi...
3fcca641e02226befe1dc80714f91fb3a7a7cd8a
Ioana-Ionel/ClassBook-with-GUI
/domain.py
2,505
4
4
class Student: def __init__(self, lastName="", firstName="", registrationNr = 0, className=0): self.lastName = lastName self.firstName = firstName self.registrationNr = registrationNr self.className = className self.subjects = [] def __repr__(self): return "{},...
f1bc576bf63cf3d5b54bca2e1c285de01e0edcf7
fcbsd/PyClubGit
/many_days_of_week.py
473
4.0625
4
#! /usr/bin/env python3 # -*- coding: utf-8 -*- print("Task 4:part 2\n") my_day=input("What's your favourite day of the week? ") if my_day== "Monday": print("Mondays are my least favourite day of the week, I'm surprised you like them") elif my_day== "Sunday": print("I love", my_day+"s!") elif my_day== "Thursday...
fe65f78756f73d1e5c4b5417c14628c9410ff9da
emielver/project-euler-hacking
/Problem243v2.py
1,868
3.765625
4
# Python 3 program to calculate # Euler's Totient Function # using Euler's product formula def phi(n) : result = n # Initialize result as n # Consider all prime factors # of n and for every prime # factor p, multiply result with (1 - 1 / p) p = 2 while(p * p<= n) : ...
990ffb1b1187324a3c9f56b87e7098b21e908a7a
laiqjafri/LeetCode
/problems/01306_jump_game_iii.py
1,313
4.0625
4
# 1306. Jump Game III # Medium # # 1164 # # 37 # # Add to List # # Share # Given an array of non-negative integers arr, you are initially positioned at start index of the array. When you are at index i, you can jump to i + arr[i] or i - arr[i], check if you can reach to any index with value 0. # # Notice that you can n...
3628e7e67b8208df4bc59152923a21806371af93
dasherinuk/classwork
/2020-10-31/classwork2.py
289
3.703125
4
array=[] Amount_input=int(input("Enter the amount of elements")) for i in range (0,Amount_input): element_input=int(input("Enter your element")) array.append(element_input) for i in range (len(array)): if i%2==0: array[i]+=1 else: array[i]-=1 print(array)
765aed8f53a717b9bfcbac1485a69421e6d10632
mihirverma7781/Python-Scripts
/chap2/strings.py
238
3.828125
4
first_name = "mihir" last_name = "verma" full_name = first_name+" "+last_name #concadination print(full_name) # we can not add string with number but we can concat it print(full_name+" "+ str(7781)) #string converion print(full_name*3 )
6c0f70550c8a7d922b42400381b7a10cab4a1a8c
linxuping/tools
/python/date.py
576
3.671875
4
''' >>> import datetime >>> str = '2012-11-19' >>> date_time = datetime.datetime.strptime(str,'%Y-%m-%d') >>> date_time datetime.datetime(2012, 11, 19, 0, 0) >>> date_time - datetime.timedelta(days=1) datetime.datetime(2012, 11, 18, 0, 0) >>> date_time.strftime('%Y-%m-%d') '2012-11-19' ''' def get_y...
e813a83740b00c8edfd545ed60a797ccd6635322
russella26/JimmysMomBot
/uwu.py
1,245
4.0625
4
# Function to convert into UwU text def generateUwU(input_text): # the length of the input text length = len(input_text) # variable declaration for the output text output_text = '' # check the cases for every individual character for i in range(length): # initialize the variables ...
398f069511a9893d7fdaf6d89d8adaa4d715b9f4
Ricky-Millar/100-days-of-python
/day_17_Start/main.py
1,158
3.890625
4
class user: def __init__(self, num_of_legs, height, poopoo_index, name): #this function is ran whenever this class is given to a new variable. self.legnum = num_of_legs self.height = height #It is standard to keep the inouts and the atribute with the same name self.poodex = poopoo_i...
4e62cc6411a47d91d18220e60bb345ff70821fae
Ludmylla28/PythonFundamentos
/MeusCodigos/cap05/cap05-04.py
562
4.21875
4
#neste documento aprenderemos sobre herança #criando a classe animal - mãe class Animal(): def __init__(self): print("Animal Criado") def Identif(self): print("Animal") def Comer(self): print("Comendo") #criando a classe cachorro - filha class Cachorro(Animal): def __init...
cbe8763a1fb29fcc5e7ab169d750d9eb1533877f
gsidhu/Linear_Algebra_Library
/Library.py
10,599
4.25
4
## Linear Algebra Library ## MIT License, 2014 Gurjot S. Sidhu class matrix(object): def __init__(self, string): ''' Returns a 2-D matrix from a string of data. Example: >>> A = matrix("1 2 3;4 5 6; 7 8 9") >>> A.show() [1, 2, 3] [4, 5, 6] ...
d72a921e54a7ec1a7c1e5221e007f564b152ae61
Levintsky/topcoder
/python/leetcode/linked_list/430_flatten_multilevel_dllist.py
2,176
4.34375
4
""" 430. Flatten a Multilevel Doubly Linked List (Medium) You are given a doubly linked list which in addition to the next and previous pointers, it could have a child pointer, which may or may not point to a separate doubly linked list. These child lists may have one or more children of their own, and so on, to pr...
9e45062f6e2c89e42ec4124a6cd66396b6f4fab5
ficksjr/programas-no-desktop
/Aula Python - Curso em video/Exercícios/desafiosiniciais/desafio024.py
219
3.828125
4
# Exercício Python 24: Crie um programa que leia o nome de uma cidade diga se ela começa ou não com o nome “SANTO”. s = str(input('Me diga uma cidade do Brasil: ')) s = s.lower() print(s.startswith('santo'))
07d6d8be20518eb431054e6ff1edf95cb02859d7
Alfred-N/MachineLearningAdv-Assignment1
/PCA.py
944
3.53125
4
import numpy as np import matplotlib.pyplot as plt from sklearn.decomposition import PCA import matplotlib.pyplot as plt import matplotlib.cm as cm from dataFunctions import readDataFile from dataFunctions import normalizeFeature from dataFunctions import centerData #Python implementation of PCA. Uses numpy, matplotl...
455bb13b6d7be8ad336dbc3e86f9075a7cf3252e
ObliqueMotion/ml-group-project
/game_objects/reward.py
787
3.546875
4
from game_objects.cell import CellType # Direction represents the four options that the snake has to move in. class reward(): empty = None snake = None apple = None def __init__(self): self.empty = 0 self.snake = -1 self.apple = 50 # type_of_cell describes the type of cel...
3fff0cbc94e339408a3cda028ba67227f5e907ba
crystallistic/wallbreakers-hw
/week2/36.py
1,463
3.65625
4
class Solution(object): def isValidSudoku(self, board): """ :type board: List[List[str]] :rtype: bool """ width = len(board) rows = {i:set() for i in range(width)} cols = {j:set() for j in range(width)} boxes = [[set() for _ in range(width//3)] for _ i...
231c2609bfa8fb743b97772d6396ceda2b236a3b
ShounakNR/DataStructuresAndAlgoECE573
/HW1/Q4/Q4.py
252
3.796875
4
def furDistance (list1): lowest = highest = list1[0] for i in list1: if i<lowest: lowest = i if i> highest: highest = i return highest-lowest list2 = [1,2,3,4,5,5,6,7,78,8] print(furDistance(list2))
02cb9ce5aff195449f3ccc993766f81ffd56a868
rdauncey/CS50_problem_set_solutions
/pset6/readability.py
2,230
3.828125
4
from cs50 import get_string from numpy import round def main(): text = get_string("Text: ") # Word, letter and sentence count words, letters, sentences = count_wls(text) # Avg letters & sentences per 100 words: count * (100 / words) L = letters * (100 / words) S = sentences * (100 / words) ...
3ac6f22b169a4bf42ccedd87a4c550b139e4e6b0
PulakshG/CS-50-AI
/Week - 0/Tic-Tac-Toe/tictactoe.py
6,725
3.90625
4
""" Tic Tac Toe Player PULAKSH """ import math import copy X = "X" O = "O" EMPTY = None def initial_state(): """ Returns starting state of the board. """ return [[EMPTY, EMPTY, EMPTY], [EMPTY, EMPTY, EMPTY], [EMPTY, EMPTY, EMPTY]] def player(board): """ Returns pla...
d125d823713c0ea03d27f6e95c69809841a9f74d
luoguanghao/bioinfo_algo_script
/combinatorial pattern matching/Inverse Burrows-Wheeler Transform.py
1,264
3.734375
4
''' Inverse Burrows-Wheeler Transform Problem: Reconstruct a string from its Burrows-Wheeler transform. Input: A string Transform (with a single "$ " symbol). Output: The string Text such that BWT(Text) = Transform. Code Challenge: Solve the Inverse Burrows-Wheeler Transform Problem. ------------------- Samp...
786caebaa584391ca558d6b69470ed2a08405994
joaohfgarcia/python
/uniesp_p2/prova1_q2.py
954
3.65625
4
def diaDoProgramador(aa): if (aa <= 1917) and (aa%4 == 0): return(f"[Ano Bissexto] O Dia do Programador, 256º dia do ano, ocorreu em 12.09.{aa}") elif (aa <= 1917) and (aa%4 != 0): return(f"[Não é Ano Bissexto] O Dia do Programador, 256º dia do ano, ocorreu em 13.09.{aa}") elif (aa == 1918...
ceddf6f444cd207946d995ac903458cd9fc5c841
othmanben01/functional-programming
/recursion_book/1-sumArray/sum.py
747
4.125
4
# This program helps you to calculate the sum of the elements of a list def sum_list_length_1(A): if len(A) == 0: return 0 else: return sum_list_length_1(A[0:len(A) - 1]) + A[len(A) - 1] def sum_list_length_2(A): if len(A) == 0: return 0 else: return A[0] + sum_list_le...
7bed420b550708283ad2f78a70513054ddebe2ed
kaiete/edit-cli
/editcli.py
2,011
3.765625
4
appname = "App name: {name}".format(name="Edit CLI") import random print(appname) openfile = str(input("What is the path of the file? ")) editoropen = str(input("Do you want to add to, overwrite, view the file, create it or corrupt the file? a/o/v/c/cr respectively ")) if editoropen == "v": print("Opening file...")...
48b7fff6434a39829bdcb7cdd23d92ddd6a29e35
Totoro2205/for_my_shiny_students
/lesson_5/homework/hw_5_5.py
599
3.90625
4
""" 5. Создать (программно) текстовый файл, записать в него программно набор чисел, разделенных пробелами. Программа должна подсчитывать сумму чисел в файле и выводить ее на экран. """ with open("task_4.txt", "w") as f_o: num = f"{input('Введите числа через пробел: ')}" f_o.write(num) with open("task_4.txt", "r...
0ef02006e336852f52e3b54a0e1dc495c94483a7
unfit-raven/yolo-octo
/CST100 Object Oriented Software Development/Random Programs/sublime_test.py
165
3.9375
4
print("Hello World!") print("Let's have some fun with Python!") print() print("Let's make a loop that'll print out 1 through 10:") for i in range(1, 11): print(i)
6e084fea8f2a816aad7de8bdf7ffeecf49a3338f
ZanyeEast/ISAT252
/lab6.py
1,022
4.03125
4
""" Lab 6. for loop and range function """ #3.1 printing numbers 0 through 6 excluding 3 and 6 for each_num in range(6): if each_num != 3: print(each_num) #3.2 Printing 5! fact = 1 for factorial in range(1,6): fact = fact * factorial print(fact) #3.3 Printing sum of range(1,6) num1=0 for num in ra...
2f93eb4a0cc9eb0952d19e0cb4807c44f9206413
hianp/Exercicios_Curso_em_video_Py
/Ex015.py
168
3.53125
4
dias = int(input('Quantos dais alugados? ')) km = float(input('Quantos km rodado? ')) pago = (dias + 60) + (km * 0.15) print(f'O total a pagar é de R${pago:.2f}')
3c0f6674128f48c0811c658d850fe65340232ae6
SamyamS/Cannibal-AI-solver
/heappriority.py
402
3.640625
4
# -*- coding: utf-8 -*- import heapq class PriorityQueue: def __init__(self): self.elements = [] self.counter = 0 def empty(self): return len(self.elements) == 0 def put(self, item, priority): heapq.heappush(self.elements, (priority,self.counter ,item)) se...
30c1cf201429e5c4c41dd30e35dfe5954fa1fa27
muhammad-rajib/python3-exercises
/exercise_26.py
312
3.625
4
# Function Parameter def function(x,z,y=10): """ if i declare the defult value of any perameter then after all perameter value must will be a default value """ print("x=",x,"y=",y,"z=",z) function(x=1,y=2,z=3) a=5 b=6 function(x=a,z=b) a=3 b=4 c=6 function(y=a,x=b,z=c) a=10 function(x=a)
19c386a290ceda608dc5036fb14acd84a07343b9
leninmedeiros/modelmutualsupport
/state.py
4,026
3.640625
4
class State(): """This class represents a state. It can be either an input or a transitional state. Input states can be seen as triggers that start the computation of the model. They are used as parameters, then they remain constant over time unless the user decides to change their values. Transitional ...
11642cf8163c93ff5e741443a1f08ca70cb93239
ikramulkayes/University_Practice
/practice13.py
455
3.546875
4
word = input("Enter a number: ") word = word.split(", ") count = 0 sum1 = 0 sum2 = 0 lst1 = [] lst2 = [] for i in word: for k in i: k = int(k) if count % 2 ==0: sum1 += k else: sum2 += k count += 1 if sum1 == sum2: lst1.append(int(i)) else: ...
09cda0d9d71224375f2a1f57293d4c7d90766fb0
artur92/FractionsChallenges
/CommonMethods/Parser.py
852
4.0625
4
import argparse class InputParser: @staticmethod def parser_input(): """ This method will check if the parameters need for the application are correct and example on how to input data in the script is main.py -i '1_4/7 * 9_1/8' :return: the input parameter pass as -i or --inp...
819e220d52ce188e2cafca972254b9e263a00042
Darshan1917/python_complete
/demo2.py
389
3.59375
4
# -*- coding: utf-8 -*- """ Created on Mon Feb 5 13:19:21 2018 @author: dumapath """ from tkinter import * root = Tk() label1 = Label(root,text="Enter firstname") label2 = Label(root,text="Enter lastname") entry1 = Entry(root) entry2 = Entry(root) label1.grid(row=0,column=0) label2.grid(row=1,column=0) entry1.gr...
f9ce262125851fc253a80cb808aa2bcb20aeb304
alik604/Miscellaneous
/pyLib_math+Stat/myMathLib.py
1,656
3.6875
4
import math ''' def __init__(self): self.name = name ''' class myMathLib: def __init__(self): self.LinearAlg = self.LinearAlg() class LinearAlg(): def norm(self, u): return self.magnitude(u) def magnitude(self, u): return math.sqrt(sum([pow(x, ...
f082ebdf5eed274475c7a7603d326e48e9b4f01f
Daviner2017/amis_python
/km72/Podolsky_David/9/task1.py
242
4.09375
4
def distance(x1, y1, x2, y2): return (((x2-x1)**2)+((y2-y1)**2))**0.5 x1=float(input("x1=")) y1=float(input("y1=")) x2=float(input("x2=")) y2=float(input("y2=")) print("The distance between two dots =", round(distance(x1, y1, x2, y2),3))
f7dbbc94a0b704c3ba591337d344e9e45c17c23b
daniel-reich/turbo-robot
/tfbKAYwHq2ot2FK3i_15.py
917
4.15625
4
""" Let's define a non-repeating integer as one whose digits are all distinct. 97653 is non-repeating while 97252 is not (it has two 2's). Among the binary numbers, there are only two positive non-repeating integers: 1 and 10. Ternary (base 3) has ten: 1, 2, 10, 20, 12, 21, 102, 201, 120, 210. Write a function that...
5fcbdba77939b15880fef66d98c519b8c19ae666
sarangspadalkar/Weird-Encoder
/decoder.py
773
3.515625
4
def decoder(encodedValues): totalBits = 32 lengthEachBit = 8 original_string = "" for value in encodedValues: ascii_arr = [0 for j in range(totalBits)] binValue = bin(int(value))[2:].zfill(totalBits) j = 0 for i in range(len(binValue)): k = i if j ...
4166300963ef552bf0094c440d7b26aa04247b6d
Vanya-Rusin/lavbs-5
/Завдання 1.py
126
3.625
4
n = int(input("введіть значення n:")) S = 0 while n >= 1: S += (2*n)**2+(2*n+1)**3 n -= 1 print(S)
2fbfc4184a6001a72f7db25d53cbe240641b658a
swathythadukkassery/60DaysOfCode
/LinkedList/oddEven.py
685
3.734375
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def oddEvenList(self, head: ListNode) -> ListNode: if head == None or head.next==None or head.next.next == None: return head ...
c4af412e1a781ab6445cddb05ec77b147919706a
hugoleonardodev/learning
/python/desafio-004-Python.py
289
3.875
4
# Desafio 004 Python Prof Guanabara # Make a code wich receives a input (int, float, bool, str) and # show its type # print(type(var)) show the type of var, var.is___() isalpha, isalnum, isdecimal, isdigit var = input('Type a info: ') print(type(var)) print('Is a string?', var.isalpha())
12052b89a5674151e02708d42084a951d01c211f
cmychina/Leetcode
/leetcode_栈_最小栈.py
888
4.03125
4
class MinStack: def __init__(self): """ initialize your data structure here. """ self.mystack=[] self.minstack=[] def push(self, x: int) -> None: self.mystack.append(x) if not self.minstack: self.minstack.append(x) elif self.minstack[...
57bcfaf94ded6aea575086bbf5cfcbc00ddb22a2
Timofey-Lutsenko/Python_Algos
/Урок 1. Практическое задание/104.py
1,073
3.75
4
import datetime import random user_data_1 = input('Enter the beginning ' 'of the range for a random value: ') user_data_2 = input('Enter end of range for random value: ') now = datetime.datetime.now() tmp = now.microsecond try: if user_data_1.isalpha() and user_data_2.isalpha(): ...
7330caee10d878ab9bc3fb86cd56a23b86696784
arsaikia/Data_Structures_and_Algorithms
/Data Structures and Algorithms/Python/Algo Expert/Ceaser Cypher Encryptor.py
618
3.703125
4
# O(n) Time || O(n) Space # NOTE : FOR ALPHABET SIZE > 26 {large alphabet size} the size of alphabet will come into the picture for complexity analysis def ceaserCypher( string, key ): newString = [] newKey = key % 26 for ch in string: newString.append(getNewLetters(ch, newKey)) return ''.join(n...
02ce51265b540f359a8e93584d9a0ba158e8c1b7
joysn/leetcode
/leetcode_9_palindrome_number.py
1,572
4.1875
4
# 9. Palindrome Number # Given an integer x, return true if x is palindrome integer. # An integer is a palindrome when it reads the same backward as forward. # For example, 121 is a palindrome while 123 is not. # Example 1: # Input: x = 121 # Output: true # Explanation: 121 reads as 121 from left to right and ...
d73dc827ca9783157d013f37c3f01a01a868c227
jcorn2/Project-Euler
/prob23.py
893
3.671875
4
import math UPPERLIMIT = 28123 def findProperDivisors(n): #always have 1 as proper divisior factors = set([1]) #loop to find possible factors for i in range(2,int(math.sqrt(float(n)) + 1)): #check if i divides n evenly if(n % i == 0): #found 2 proper divisors factors.add(i) factors.add(n // i) re...
97df2242ad5db34e5931dec0ca92bbf0d0d2518b
chandanakm/python
/fileassignment.py
1,933
3.609375
4
visitedlist=[] duplicate=[] unique=[] inputfile=open(r'D:\Desktop\Python_assignments\Python_Assignment_1\data.txt','r') data=inputfile.readlines() print("INPUT DATA:\n",data) print("\n") '''-----------------------#unique and duplicate---------------------------------''' outputfile=open(r'D:\Desktop\Python_a...
542e340f84a7a124c0a64a5069e2c92308f44272
Sathyasree-Sundaravel/sathya
/Program_to_print_the_number_of_repetitions_of_K.py
138
3.65625
4
#Program to print the number of repetitions of K N,K=input().split() N=int(N) K=int(K) L=list(map(int,input().split())) print(L.count(K))
01661b662cfcaacc1c8a82c48eeab831c39fb28c
DANUSHRAJ/Skillrack-Daily-Challenge-And-Daily-Test
/Library Books & Requests.py
1,899
3.671875
4
Library Books & Requests In a library, B books are kept on a shelf. The books are numbered 1 to B and are arranged from left to right on the shelf. If a student wants to read a book (using the book number), the book can be taken from the shelf and it must be inserted to the left when the student returns the bo...
ceb24a3e05ed31e8f713a59c7c7008306c964440
jxhangithub/lintcode
/Medium/7. Serialize and Deserialize Binary Tree/Solution.py
2,609
3.953125
4
""" Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ from collections import deque class Solution: """ @param root: An object of TreeNode, denote the root of the binary tree. This method will be invoked first, you sho...
b1d75efb8ecc7e630ebf169f32e994d19d443f47
DDDYuan/advent-of-code-2020
/tasks/day12.py
2,390
3.71875
4
from utils import read_input raw = read_input.read_input_strings('day12') def parse_command(command): return command[0], int(command[1:]) def move(instruction, value, facing): if instruction == 'L': return 0, 0, value if instruction == 'R': return 0, 0, -value if instruction == 'N':...
8d84879503b64fedd40e9710d29aefb08e21c4a8
gwthmsb/hackerRank
/30_days_challenge/Day11_2D_Arrays.py
3,081
4.40625
4
""" Today, we're building on our knowledge of Arrays by adding another dimension. Check out the Tutorial tab for learning materials and an instructional video! Context Given a 2D Array, A : 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 We define an hourglass in A to be a subset of values ...
ed2d0f483eeb9c58b71f46bcb217f4ac67a2dadc
Vipulsajjanwar/turtles
/3.py
121
3.90625
4
import turtle t= turtle.Turtle() t.color("red") for side in range(100): t.forward(10*side) t.left(360/3)
663a025e2e6f0ba41a0ff59b6934d3588622c0b8
Oladunsi/TicTacToe
/UNderstanding OOP.py
328
3.640625
4
class Cirle(object): pi = 3.14 def __init__(self,radius=1): self.radius = radius def Area(self): return Cirle.pi * (self.radius**2) def _radius(self,rad): self.rad = rad self.radius = rad circle = Cirle(radius = 40) print(circl...
c7f53112bc0c39fa1875fcbdb6b88f07124634fe
BartoszKopec/wsb-pios-python
/src/2020-05-28_raport.py
2,245
4.3125
4
list = ['a', 'b', 'c', 'c'] # stworzenie kolekcji która ma 4 elementy print(list) setFromList = set(list) # stworzenie zbioru z kolekcji który ma 3 elementy, ponieważ zostały zignorowane dane powtarzające się print(setFromList) setFromList.add('d') print(setFromList) setFromList.remove('a') print(setFromList) # dodanie...
8403aed271e3de98fdbd2e1b7faa95979525e9a9
Mrzhaohan/python-one
/hanshu/diguifeibo.py
294
3.765625
4
def fb(n,list_num=[1,1]): i=0 if n>2: while i<n: list_num.insert(i+2,list_num[i]+list_num[i+1]) i+=1 else: print(list_num) return list_num[n-1] else: return list_num[0] if __name__ == '__main__': print(fb(5))
c671df9133fe2be7b9ba85c8bd4101532a684784
aishwarya9879/python-learnings
/ifsyntax.py
378
3.859375
4
def operation(a,b,operation): #operationmath(a=1, b=22, operation="mul") if False: return a+b elif True: return a-b elif True: return a*b else : return a+b temp = operation(1,2,"add") print(temp) temp = operation(11,2,"sub") print(temp) temp = operation(1,22,"mu...