blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2b1722cd1358365072b4c647ebd0a44b9c083d8c
Signa-ling/Competitive-Programming-Solution
/AtCoder/ABC/ABC162/ABC162_B.py
158
3.703125
4
n = int(input()) ans = 0 for i in range(1, n+1): if i%3==0 and i%5==0: continue elif i%3==0: continue elif i%5==0: continue ans+=i print(ans)
e7a2610c5c3e66e5a151b584434e03c3f4a1b41b
DataEdgeSystems/Project
/Python/Scripts/inhml.py
492
3.8125
4
class A: def __init__(self): print 'init obj of A class' def disp(self): print 'disp in A class' class B(A): def __init__(self): A.__init__(self) print 'init obj of B class' def disp(self): A.disp(self) print 'disp in B class' class C(B): def _...
31f292621af342d500fb51a1c00b309fe3da9520
gianbianchi/Uniso
/Ago-24-2021/Python/ex007.py
142
3.984375
4
tempC = float(input("Qual a temperatura em Celsius? ")) tempF = (9*tempC + 160)/5 print("A temperatura em Fahrenheit é: {}".format(tempF))
b4092ba066dc962b651545199df76f7fa7edee78
Bibin22/pythonpgms
/Tutorials/Class Prgms/static and instance variable.py
229
3.828125
4
class Car: wheels = 4 def __init__(self): self.car ="BMW" self.mil =12 c1 = Car() c2 = Car() c1.car = "Audi" c1.mil = 19 Car.wheels = 17 print(c1.car, c1.mil, Car.wheels) print(c2.car, c2.mil, Car.wheels)
5a2c863cd177dc3a305fee96c3bc8e3c879524cf
Technicoryx/python_strings_inbuilt_functions
/string_04.py
382
3.96875
4
"""Below Python Programme demonstrate casefold functions in a string""" string = "PYTHON IS AWESOME" # print lowercase string print("Lowercase string:", string.casefold()) firstString = "der Fluß" secondString = "der Fluss" # ß is equivalent to ss if firstString.casefold() == secondString.casefold(): print('The s...
047e4393383bfaea72753cf1e4208c797a951301
RonnyJiang/Python_PyCharm
/MapReduce/mapreduceTest.py
1,888
3.78125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @desc:mapreduce的练习题 @author: Ronny @contact: set@aliyun.com @site: www.lemon.pub @software: PyCharm @since:python 3.5.2(32bit) on 2016/11/9.0:59 """ '''练习①:利用map()函数,把用户输入的不规范的英文名字,变为首字母大写,其他小写的规范名字。''' # 输入:['adam', 'LISA', 'barT'],输出:['Adam', 'Lisa', 'Bart']: d...
90de1d12dbabb014edb77b66c42c23848dac38ec
BitorqubitT/ADT
/Hashtable/DoublyLinkedList.py
1,713
3.734375
4
class DoublyLinkedListNode: def __init__(self, searchKey, newItem): self.searchKey = searchKey self.data = self.searchKey, newItem self.next = None self.prev = None class DoublyLinkedList: def __init__(self): self.head = None # no need for tail as always the next point...
ef451fb13f42559b46be5b8fd01fda0bd0365953
andyd0/foobar
/level_3/fuel_injection_perfection.py
970
3.75
4
# Fuel Injection Perfection def solution(n): # Python will convert n to bignum if necessary so 309 digits should # be fine n = int(n) count = 0 while n > 1: # Last bit of a binary number indicates whether the number is odd # if the last bit is 1, it's odd. n & to 1 will lead to either 1 or 0 if ...
be87d7d6412dc1a7f596ddfc948bc92202c31a18
andresnunes/Projetos_Python
/Projetos_Python/Exercicios-Livro-PythonForEverybody/6Ex5.py
390
4.53125
5
''' Exercise 5: Take the following Python code that stores a string: str = 'X-DSPAM-Confidence:0.8475' Use find and string slicing to extract the portion of the string after the colon character and then use the float function to convert the extracted string into a floating point number. ''' str = 'X-DSPAM-Confidence:0...
ccc9971579e361226403e3d74ae7ae88ad202601
viverbungag/Codewars
/Integers-Recreation One.py
430
3.609375
4
def list_squared(m, n): # your code ans = [] for x in range(m, n): div = 0 for y in range(1, int((x**0.5)+1)): if x % y == 0: if(x / y == y): div += (y**2) else: div += (y**2) + ((x/y)**2) if (int(di...
9699225c8d0681ae1fbf50a9e87a299407f5ed0f
lishuchen/Algorithms
/lintcode/132_Word_Search_II.py
1,521
3.859375
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- class TrieNode: def __init__(self): self.dct = dict() self.is_end = False class Solution: # @param board, a list of lists of 1 length string # @param words: A list of string # @return: A list of string def wordSearchII(self, board, wor...
af16f54c735cff24631d45c8e0ced7de7e40aefe
marcobakos/python-by-examples
/zipfile/zip.py
1,518
3.90625
4
#!/usr/bin/python # # Copyright (C) 2014 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WIT...
5c24ab5e11286fd383c14b872451d6bcbc5924f4
anirudhjayaraman/Project-Euler-Solutions
/euler13.py
400
3.59375
4
# Read the problem matrix into an array in python filename = 'euler13.txt' with open(filename, "r") as ins: array = [] for line in ins: array.append(line) # Convert the array into an array of integers newArray = [] for i in array: newArray.append(int(i)) # Sum up the array and print the first 10 nu...
f5dfb150280ea6ccbfd0cf5c69b0a0784b8c724d
WilliamHdz/Tareas_Proyectos
/PYTHON/P07.py
1,478
3.640625
4
flag = True while flag == True: archivo = open("Salida_P07.txt","a") print("") print("####################################################################") print("# 1. CALCULAR EL FACTORIAL DE UN NÚMERO DIVISIBLE ENTRE 7 ---- (f) #") print("# 2. HISTORIAL ----------------------------------------------- (h) #") ...
e3c398cd033c81858e227d1f2e296cff1e87385e
rohitr84/project-euler-py
/python/src/Set_1_to_25/Problem_25.py
1,164
4.0625
4
#!/usr/bin/python # # Problem 25 # # Find the first term in the Fibonacci sequence to # contain 1000 digits. import unittest class Test_Problem_25(unittest.TestCase): def test_first_fibonacci_with_2_digits(self): """ """ self.assertEqual(7, first_term_in_fibonacci_sequence_with_n_digits(2)) def test_first_...
6c99da2077daba547994e87adf5b6f31fd33c96c
mplanchard/recipes
/python/decorators/decorator_with_or_without_args.py
4,023
4.3125
4
""" The following illustrates the flow of execution for a flexible decorator that be called either be called, with/without arguments, e.g. ``@decorate()`` or ``@decorate('foo')``, or used as a raw decorator, e.g. ``@decorate``. Rather than ``callable()``, if you expect a callable object might be passed to your decorat...
f90804b775b25e02452dff247c1cb0a602766e46
harrylewis/exercism
/python/parallel-letter-frequency/parallel_letter_frequency.py
290
3.75
4
def calculate(text_input): counts = {} for group in text_input: for char in group.lower(): if char.isalpha(): if char in counts: counts[char] += 1 else: counts[char] = 1 return counts
6a7b344ed8a41007e35b51362660805bf9554d63
largomst/HackerRank-Algorithms
/Implementation/Kangaroo.py
392
3.53125
4
x1, v1, x2, v2 = input().strip().split(' ') x1, v1, x2, v2 = int(x1), int(v1), int(x2), int(v2) result = 'NO' if x1 < x2 and v1 > v2: while x1 < x2: x1 += v1 x2 += v2 if x1 == x2: result = 'YES' elif x1 > x2 and v1 < v2: while x1 > x2: x1 += v1 x2 += v2 ...
947ef339489ddfb6ba1234af8ee4874152f6a89c
lbenet/ValidiPy
/src/python/jet.py
2,761
3.78125
4
# -*- coding:utf-8 -*- """The x in the argument of functions is actually an object which is itself a derivative pair""" import numpy as math # NB import numpy as np class Jet: """Multidim jet""" def __init__(self, valor, deriv=0.0): self.valor = valor self.deriv = deriv def __add__(se...
797055c6a2c9c69f477a6cfe78c4a25074068dec
abhianshi/Natural-Language-Processing
/Dependency Parser/Dependency_Parser.py
11,823
3.65625
4
# Natural Language Processing # Assignment - 1 # Creator : Abhianshu Singla # NID : ab808557 # Used Atom for writing python Script # Python version - 3.5.2 # While running, it takes two inputs - the file paths of source file and target file # import statements import sys # Reading the arguments from the terminal and...
6e3e08affb4abb1d38f8bfecfe9668c8cdad0965
komiamiko/fc-ezalia
/src/algorithm.py
2,026
4.125
4
""" Pure algorithms, not specific to an application. """ class UnionFind(object): """ Union-find data structure, also known as disjoint set. Only works on a range of integers [0, n). All operations are permitted to mutate the underlying list. """ def __init__(self, n): """ Make ...
2a69963a7baff5c6eb2b28fc1ea72b4cfbf4efa7
sgriffith3/PythonBasics7-22-19
/in.py
269
4.09375
4
#!/usr/bin/env python3 import pdb my_text = "I want to ride a donkey down the Grand Canyon trails" count = 0 pdb.set_trace() if "an" in my_text: print("There is an 'an' in your text") for letter in my_text: if "a" == letter: count += 1 print(count)
7c23acba0ea89e261f74000124675e267a122a89
sunnnwo86/Python_test
/lambda.py
446
3.953125
4
power = lambda x : x*x under_3 = lambda x: x<3 list_input_a = [1,2,3,4,5] output_a = map(power,list_input_a) print("#map함수의 실행결과 ") print("map(power, list_input_a):", output_a) print("map(power, list_input_a):", list(output_a)) print() output_b = filter(under_3, list_input_a) print("#filter() 함수의 실행 결과") print("fi...
69076e3d2a44c7c36affc5fdb3d83e0d514f4dec
shhuan/algorithms
/leetcode/easy/Longest_Common_Prefix.py
1,150
3.5
4
# -*- coding: utf-8 -*- """ created by huash at 2015-04-12 18:31 Write a function to find the longest common prefix string amongst an array of strings. """ __author__ = 'huash' import sys import os class Solution: # @return a string def longestCommonPrefix(self, strs): # 44ms if not strs...
c4e817f17416a7f0417c53f512d9b146509895f6
cherryzoe/Leetcode
/621. Task Scheduler.py
2,503
3.90625
4
# Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks.Tasks could be done without original order. Each task could be done in one interval. For each interval, CPU could finish one task or just be idle. # However, there is a non-negat...
d2aa2bd7b0faa2b94bead3686848c6202102a553
aishahanif666/Working_with_Conditionals
/Even or odd.py
371
4.25
4
print("IDENTIFY EVEN OR ODD NUMBER:\n") a = int(input("Enter number: ")) if (a%2 == 0): print("It's an even number!") else: print("This number is odd!") print("\nIDENTIFY POSITIVE OR NEGATIVE NUMBER:\n") b = int(input("Enter number: ")) if (b<0): print("Neagative number") elif (a>0): print...
4092fee6ace4f471f78828c2031084f8eda865cd
wowalid/doku-solver
/input.py
1,113
3.71875
4
size = int(input("Size (or sudoku)?")) blocks = [] cells = [] if size == 'sudoku': print "Awaiting sudoku set values..." while True: b = [] v = raw_input("Value?") if v == "": break b.append("%s=" % (v,)) c_str = raw_input("Cell?") if c_str == "": break ...
da27b5818c5b913bb5fb7efc8e0c4f35af052665
bbog/Project-Euler-Problems
/3/solve.py
681
4
4
''' URL: http://projecteuler.net/problem=3 The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? ''' def getLargestPrimeFactor(number): # first version was slow as hell, so... let's cheat a little : D # credits: http://primes.utm.edu/lists/small/100000.txt ...
77abf8589d92ca2d99ea1cf8566b9c686e2398d9
akaraboyun/Python-Examples
/kuvvet.py
122
3.78125
4
a = int(input("a: ")) b = int(input("b: ")) toplam = 1 for i in range(b): toplam *= a print("Sonuç:",toplam)
19cef77cf7d5bee183d14d79beaa1d5234d6dac5
sebas494/Proyecto-final
/proyecto.py
30,851
3.546875
4
print("Parqueadero pontificia universidad javeriana cali\n" ) def opcion_1 (opciones1): import json archivo = open("usuarios.json", "r+", encoding = "utf-8") usuariosJson = json.load(archivo) #archivo2=open("Pisos.json", "r+", encoding = "utf-8") #PisosJson = json.load(ar...
614964298088ee50bc7b88e2c4e03eb8c86b009e
TakanoriHasebe/DeepLearning
/ManufactureDeepLearning/temp/make-affine.py
1,207
3.578125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Mar 23 11:12:48 2017 @author: Takanori """ """ Affine """ import numpy as np X = np.random.rand(1, 2) # print(X.shape) # print(X) W = np.random.rand(2, 3) B = np.random.rand(1, 3) # print(W.shape) Y = np.dot(X, W) + B # print(Y.shape) print(Y) class...
18834a2e10d205704950357c3c21369fb4589cb4
JediChou/jedichou-study-algo
/onlinejudge/leetcode/quiz00258/quiz00258-a1.py
1,118
3.71875
4
import unittest class Solution: def addDigits(self, num: int) -> int: if num < 10: return num return self.addDigits(sum([int(d) for d in str(num)])) class Quiz00258(unittest.TestCase): def test_Less10(self): answer = Solution() self.assertEqual(answer.addDigits(1), ...
26b2d57d398cb9d5a43e895dd47a514771436838
mjutzi/TikzTuringSimulator
/core/tape_expansion.py
1,269
3.6875
4
import collections def left_of_expandable(index, list, placeholder=None): new_index = index - 1 while new_index < 0: list.insert(0, placeholder) new_index += 1 return new_index def left_of_unexpandable(index, list, placeholder=None): new_index = index - 1 if new_index < 0: ...
fa6d1859bebff07e7952f42094d753e19911d730
daniel-reich/ubiquitous-fiesta
/LanWAvTtQetP5xyDu_6.py
294
3.53125
4
def coins_div(lst): if sum(lst)%3: return False dtbs = {(0,0,0)} #set of possible distributions with inital subset of coins coor = [0,1,2] for cn in lst: dtbs = dtbs.union({tuple(d[i]+cn*(i==j) for i in coor) for j in coor for d in dtbs}) m=sum(lst)//3 return (m,m,m) in dtbs
d6cacc7a88a1248cd03c84274d2c5b706b36b7f6
Cactiw/Dark-Desire-Order-Bot
/castle_files/libs/message_group.py
1,599
3.71875
4
""" Здесь находятся классы и методы для работы с группами сообщений - сообщения, которые должны быть отправлены строго в определённом порядке, но асинхронно """ from threading import Lock, RLock from multiprocessing import Queue from queue import Empty lock = Lock() message_groups = {} message_groups_locks = {} group...
f94f5f952c32bf0416089d2bdba644df2b5e69b3
moonlightshadow123/leetcode_solutions
/string/125-Valid-Palindrome/high_low.py
911
3.65625
4
class Solution(object): def isPalindrome(self, s): """ :type s: str :rtype: bool """ def isAlpha(char): if ord(char) >= ord('A') and ord(char) <= ord('Z'): return True elif ord(char) >= ord('a') and ord(char) <= ord('z'): ...
f279f64bd84040a8165edc3d50f435e0211f4c1e
zebasare/Ejercicio_Clases_y_Objetos
/main.py
1,376
3.96875
4
import math class Punto: def __init__(self,x=0,y=0): self.x=x self.y=y def __str__(self): return f"Punto ubicado en {self.x,self.y}" def cuadrante(self): if self.x>0 and self.y>0: print("El punto esta en el primer cuadrante") elif self.x<0 and self.y>0: print("El punto es...
001fc09cc6409080a6b0cdd303ab999581b0bed4
elcarmen/PythonLearning
/[3] BasicLogIn.py
331
3.6875
4
username = "User1211" # I'll upgrade username and password as a data folder password = "vexy1189" userlogin = input("Username: ") userpassword = input("Password: ") if(username == userlogin) and (userpassword == password): print("successful") else: print(''' Wrong username or password You can sign up ...
e6eeb8243f29630ff4562e3ee2fa5b2ad0e4c8ce
Xuyuanp/LeetCode
/python/climbingStairs.py
764
4.0625
4
#! /usr/bin/env python class Solution: # @param n, an integer # @return aan integer def climbStairs(self, n): if n < 3: return n steps = [0 for i in range(n + 1)] steps[1] = 1 steps[2] = 2 i = 3 while i <= n: steps[i] = steps[i - 1] + ...
485f22853438b8a36d2f9aba2805c445746b05e5
DarioBernardo/hackerrank_exercises
/arrays/merge_two_arrays.py
658
4.09375
4
from typing import List def merge(nums1: List[int], nums2: List[int]) -> None: """ Do not return anything, modify nums1 in-place instead. """ n2_pointer = len(nums2)-1 n1_pointer = len(nums1)-1-len(nums2) current_pos = len(nums1)-1 while current_pos >= 0: num1_val = nums1[n1_point...
6bdefad690a3328dbd624923ba387c6243170b8d
talk2mat2/newpyrepo
/pygame.py
2,772
4
4
# pygame, this is modified number guessing game written in python def Easy(): # function for easy game max_trial = 6 answer = 5 guess_count = 0 guess = None print('level 1 (easy mode)') while guess != answer and guess_count < max_trial: try: print(f'you have {...
c9637c7e63795840497ee23040436b2df824d197
onlyrobot/Tool
/code/maze_generation_prim_algorithm.py
2,586
3.734375
4
# maze generate with prim algorithm import random import turtle VISITED = 1 PATH = 1 ROW, COL = 30, 30 DIRS = [(-1, 0), (0, 1), (1, 0), (0, -1)] maze = [[[0, 0, 0, 0, 0] for i in range(COL)] for i in range(ROW)] START, END = (0, 0), (ROW - 1, COL - 1) que = [START] def cross_border(cell): return cell[0] < 0 or cell...
dc3c7e0b4e1be22a84496d46f3de5528f428fc0a
cmgrier/BeachBotsMQP
/base_bot/src/base_bot/MeshAnalyzer.py
17,441
3.578125
4
#!/usr/bin/env python3 import pyzed.sl as sl import time import rospy import math from support.Constants import * # works with the given mesh data to produce useful information class MeshAnalyzer: def __init__(self, mesh): self.mesh = mesh """ VERTICES """ # returns the lowest vertices ...
1663ed2b9c40a347ca117ae87bfbb658a9a08ed1
jaewie/algorithms
/python/tests/collection/test_dynamic_array.py
2,245
3.515625
4
import unittest from collection.dynamic_array import DynamicArray class TestDynamicArray(unittest.TestCase): def setUp(self): self.arr = DynamicArray() def test_constructor(self): self.assertTrue(self.arr.is_empty()) self.assertEquals(0, len(self.arr)) def test_one_append(self):...
bad38b18f34faa65be3cbba18753b7897f6ca479
denysdenys77/battle_simulator
/helpers/geometric_average_helper.py
369
3.75
4
from typing import List class GeometricHelper: @staticmethod def get_geometric_average(items: List[float]) -> float: """Returns geometric average of int items in list.""" multiply = 1 n = len(items) for i in items: multiply = multiply * i geometric_mean =...
d0e08a188e2d65352349ceb1742a3966eabde253
caihedongorder/PythonEx
/PythonApplication1/PythonApplication1/module1.py
302
3.578125
4
import PythonApplication1 import os c = PythonApplication1.test(); c.a = 100 c.b = 101 class test1(PythonApplication1.test): def __init__(self): self.c = 100 return super(test1, self).__init__() d = test1() d.a = 100 d.b = 100 d.c = 10 print("a:{c.a},b:{c.b}".format(c = c))
7bbd51b638b1c274950e9c6f56302c73e2dcfd17
reinaldoboas/Curso_em_Video_Python
/Mundo_1/desafio017.py
643
4.125
4
### Curso em Vídeo - Exercicio: desafio017.py ### Link: https://www.youtube.com/watch?v=vmPW9iWsYkY&list=PLvE-ZAFRgX8hnECDn1v9HNTI71veL3oW0&index=26 ### Faça um programa que leia o comprimento do cateto oposto e do cateto adjacente de um triângulo retângulo, ### calcule e mostre o comprimento da hipotenusa. # Importan...
bb94f37015b85fe0c8d6cacf93161bf67a37765d
wh2353/Rosalind_Solutions_in_Python
/Bioinformatics Textbook Track/BA9J/BA9J_Smart_way.py
708
3.9375
4
''' Smart Way of implementing BWT reversal: instead of indexing letters from first and last column, let first column equal to range(len(seq)), then sorted alphabetically based on the letters in the input seq, the index and the content of the first column can be served as the previous first and last column ''' def burr...
226d147fbc1b0edd56290c0c326eaff12d457647
JamesHeal/PAT-AdvancedLevel-for-Zhejiang-University
/Advanced/1001.py
676
4.0625
4
#coding:utf-8 #次方的表示方法 lower_margin = -10 ** 6 upper_margin = 10 ** 6 if __name__ == '__main__': #split()是用来识别空格 #直接input()输入的是class类型 a, b = input().split() A = int(a) B = int(b) if type(A) is not int: print('the type of "a" is wrong') elif type(B) is not int: print('the t...
f363cfbe640b304c6119945a210c1ae277fb833e
tong-zeng/collocations
/mutual_info/ngrams.py
415
3.515625
4
#!/usr/bin/env python import sys if not len(sys.argv)==2: raise "expected NGRAM_LENGTH" ngram_len = int(sys.argv[1]) for line in sys.stdin: tokens = line.strip().split() if ngram_len == 1: for token in tokens: print token else: if len(tokens) < ngram_len: continue ...
d034203626132935911e15ea07363877d4ce20b6
adrian-chen/ai3202
/Assignment3/aStar.py
7,458
3.84375
4
import argparse import math WIDTH = 10 HEIGHT = 8 def read_graph(f, g, height): # Read file, then create nodes in graph g for each entry in the matrix list_index = 0 # We read from top to bottom y = height-1 for line in f: if line: # Keeps track of x coordinate (read in order) ...
68ef0a2d78b65a9a6a12cff39fd399bdb74c5d10
rcarasek/Aprendendo-Python
/fibonacci.py
286
4.03125
4
def fibonacci(num): a = 0 sequencia = [0, 1] while a < num-1: print(sequencia) proximo = sequencia[a] + sequencia[a + 1] sequencia.append(proximo) a = a + 1 return sequencia x = input('Quantos itens?') x = int(x) fibonacci(x) print(x)
db1e37012d7afb3ebf52f36cbabf9b1fb72d5166
ChrisVelasco0312/misionTicUTP_class
/Ciclo_1_fundamentos/Unidad_4/Clase_11/orden_superior.py
265
3.546875
4
# función map numeros = [num for num in range(1, 101)] doble = list( map(lambda numero: numero * 2, numeros) ) # print(numeros) # print(doble) # función filter filtrada = list(filter(lambda numero: numero > 20 and numero < 55, numeros)) print(filtrada)
c871bdc5156d0647f58c33b0224585edbf77e96f
MARGARITADO/Mision_04
/Software.py
1,438
4.125
4
#Autor: Martha Margarita Dorantes Cordero #Calcular total de paquetes def calcularTotal(numPaquetes) : #Función que realiza la operación requerida para calcular el total a pagar con el descuento aplicable. total = (numPaquetes * 2300) - calcularDescuento(numPaquetes) return total def calcularDescuento(...
6976e016fa332643ea0b9b3996e6d66ab3ad5a93
AiZhanghan/Algorithms-Fourth-Edition
/code/chapter1/Queue.py
1,335
4.15625
4
from collections import deque class Queue: """基于collections.deque""" def __init__(self): """创建空队列""" self.queue = deque() def enqueue(self, item): """添加一个元素 Args: item: Item """ self.queue.append(item) def dequeue(self): ""...
17d0a5b8659c4812b6819b533792dba9c15b4537
kyclark/tiny_python_projects
/16_scrambler/solution.py
1,989
4
4
#!/usr/bin/env python3 """Scramble the letters of words""" import argparse import os import re import random # -------------------------------------------------- def get_args(): """Get command-line arguments""" parser = argparse.ArgumentParser( description='Scramble the letters of words', fo...
3ca37d98a5ffa754fd7596b065d870729f279849
juniweb/TIL
/Python/PythonForBeginners_Microsoft/exm_errorHandling.py
418
3.890625
4
# Syntax error # if x == y # print('x is equals y') # Runtime error x = 42 y = 0 try: print(x / y) except ZeroDivisionError as e: # Optionally, log e something print('Sorry, something went wrong') except: print('Something really went wrong') finally: print('This always runs on success or failur...
0661f17891131140f4a1c28fe5f95454e43ab28c
Aniketthani/Python-Tkinter-Tutorial-With-Begginer-Level-Projects
/2buttons.py
441
4.03125
4
from tkinter import * root=Tk() # function for button onclick def click(): label=Label(root,text="You clicked Me") label.pack() #Creating a Button mybutton=Button(root,text="Click Me" , pady="50", padx="100" , command=click,fg="blue", bg="orange") # for disabling a button disabled_button=Button(root,text="Th...
5f1352fcf465f30756428c561d6297753dc7c573
kevin-d-mcewan/ClassExamples
/Chap10_OOP/PropertiesForDataAccess.py
1,478
3.53125
4
#PropertiesForDataAccess.py from timewithproperties import Time """ Create a TIME obj. TIME's __init__ method has HOUR, MIN and SECOND params, each w/default value of 0.""" # Here, specify the HR and MIN-SEC def to 0: wake_up = Time(hour=6, minute=30) print(wake_up) print('------------------------------------------...
15295a4207c183b64d1ae77ae39a78ac3d1b254a
qamarilyas/Demo
/stringValidator.py
198
3.546875
4
str='aB2' print(any(i.isalnum() for i in str)) print(any(i.isalpha() for i in str)) print(any(i.isdecimal() for i in str)) print(any(i.islower() for i in str)) print(any(i.upper() for i in str))
176892211bfb33f2bd057831bcb4322871ce7df3
diego-mr/FATEC-MECATRONICA-0791821037-DIEGO
/LTP1-2020-2/PRATICA03/exercicio02.py
290
4.1875
4
#Escreva um programa permita o usuário informa uma temperatura em graus Celsius e converta ela para graus Fahrenheit valor_celsius = float(input('inserir o valor do grau em celsius:')) valor_Fahrenheit = 1.8 * valor_celsius + 32 print('valor convertido em Fahrenheit', valor_Fahrenheit)
d41f4d9fa1171a9d1ddfd2e917252b623776a633
vaishaliyosini/Python_Concepts
/16.list_compr.py
1,077
4.03125
4
nums = [1, 2, 3, 4, 5, 6, 7] # traditional for loop l = [] for n in nums: l.append(n) print(l) # prints '[1, 2, 3, 4, 5, 6, 7]' # meet list comprehension l = [n for n in nums] print(l) # prints '[1, 2, 3, 4, 5, 6, 7]' # get square of each number l = [n*n for n in nums] print(l) # prints '[1, 4, 9, ...
c0d0f5b167152b9baf5e6de66ad8d95da3bf800b
AdityaShidlyali/Python
/Learn_Python/Chapter_5/4_delete_data_in_lists.py
453
4.25
4
# to delete the data in the list there are two methods # 1st is based on the index number and 2nd one is based on the element specified # 1st method list_1 = ["apple", "mango", "chickoo", "banana", "grapes"] del list_1[2] print(list_1) list_1.pop(2) # 2 here is the index number of the list print(list_1) # without men...
46f649da5b853ccf866699a617adaa5028ad314a
antoinemadec/test
/python/programming_exercises/q4/q4.py
626
4.34375
4
#!/usr/bin/env python3 print("""https://raw.githubusercontent.com/zhiwehu/Python-programming-exercises/master/100%2B%20Python%20challenging%20programming%20exercises.txt Question: Write a program which accepts a sequence of comma-separated numbers from console and generate a list and a tuple which contains every ...
4227366a6b9d50aa3811051b2807878882ceb324
hanyinggg/python
/Scripts/sort/Quicksort.py
700
3.6875
4
# -*- coding: utf-8 -*- """ Created on Fri May 11 14:56:12 2018 @author: hand """ import random def QuickSort(myList,left,right): if left >= right: return myList low = left high =right base = myList[left] while left < right: while (left < right) and (myList[right]>=base): ...
dfff61fc16a06bcb1032efc1348431a3176dae01
Anshul-GH/freelance_projects
/category_linkedin_learning/python_advanced_skills/Ex_Files_Learning_Python_Upd/Exercise Files/Ch2/loops_start.py
286
3.90625
4
# # Example file for working with loops # def main(): x = 0 # define a while loop # define a for loop # use a for loop over a collection # use the break and continue statements #using the enumerate() function to get index if __name__ == "__main__": main()
387008a77142bbd385a7f2e84a89118b013babce
NemesLaszlo/Pac-Man_MQTT
/player.py
4,266
3.828125
4
import pygame from settings import * vec = pygame.math.Vector2 class Player: """ Player class with the methods and parameters. """ def __init__(self, app, position): """ Constructor of the Player, with the parameters. """ self.app = app self.grid_posit...
dd83631940854cc85b251751b52690413e884126
CharlotteKuang/algorithm
/LeetCode/160.IntersectionOfTwoLinkedLists/Solution.py
1,198
3.875
4
import pdb # Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def getIntersectionNode(self, headA, headB): """ :type head1, head1: ListNode :rtype: ListNode """ if not headA or not headB: return None p = headA ...
8d20b56da4ddf5efcec6b365dc2384d9bf5bb94c
MdouglasJCU/Sandbox
/count_vowels.py
206
4.0625
4
name = input("Pleas enter your name") vowel_count = 0 for i in name: if i in "aeiouAEIOU": vowel_count += 1 print("Out of {} letters, {} has {} vowels".format(len(name), name, vowel_count))
702a45cf96e966ac87a806ee7f570b7fdeec24f6
omar-ouhibi/gomycodeedition
/q3.py
102
4.21875
4
#Q3 n = int(input("type a number")) if n%2 != 0: print('its odd') else: print('its even')
04ce7cd8efae424721f61b6fd365510a684cedd5
JulyKikuAkita/PythonPrac
/cs15211/ValidateIPAddress.py
4,981
3.90625
4
__source__ = 'https://github.com/kamyu104/LeetCode/blob/master/Python/validate-ip-address.py' # Time: O(1) # Space: O(1) # # Description: 468. Validate IP Address # # Write a function to check whether an input string is a valid IPv4 address or IPv6 address or neither. # # IPv4 addresses are canonically represented in ...
1cfd30d9f890543a32273605ad31e2530aa7ffe9
BrianArmstrong/Dojo_Assignments
/Python/Python Fundamentals/Multiples_Sum_Average.py
401
4.21875
4
#Multiples Part 1 (prints all of the numbers from 1 to 1000) for x in range(1,1001): print x #Multiples Part 2 (prints all of the multiples of 5 from 5 to 1000) for x in range(5,1001,5): print x #Sum list (sums up all of the list) a = [1,2,5,10,255,3] print sum(a) #Average List (take the sum of the list and divide i...
72034559c29386d6a036948c6495ceaa5a03f641
doug460/AI-1-Spring2018
/HW1/breadthFirst.py
5,101
3.84375
4
''' Created on Feb 6, 2018 This is the breadth first search program for AI 1 The first two arguments are the main parts of this program the goal and the initial state @author: dabrown ''' import numpy as np from inputs import goal, initialState # number of nodes expanded expanded = 0 # this function turns the c...
513415b5161b0dabfcf1389e9af0733685158c20
htingwang/HandsOnAlgoDS
/LeetCode/0289.Game-Of-Life/Game-Of-Life.py
1,243
3.578125
4
class Solution(object): def gameOfLife(self, board): """ :type board: List[List[int]] :rtype: None Do not return anything, modify board in-place instead. """ for i in range(len(board)): for j in range(len(board[0])): neighbors = 0; ...
8d614a7e9ccf369aca75b0dbd477af75424b6302
mathvolcano/leetcode
/1133_largestUniqueNumber.py
387
3.609375
4
""" 1133. Largest Unique Number https://leetcode.com/problems/largest-unique-number/ """ class Solution: def largestUniqueNumber(self, A: List[int]) -> int: # O(n) because we have to count every element from collections import Counter counts = Counter(A) keys = [x for x in counts if...
1e32c37427cacfe51c24eeb9928fde3bd64b0d1b
vivekpabani/CodeEval
/easy/delta times/delta_times.py
1,317
3.6875
4
#!/usr/bin/env python """ Problem Definition : """ __author__ = 'vivek' import sys def main(): test_cases = open(sys.argv[1], 'r') for test in test_cases: data = [[int(j) for j in i.split(':')] for i in test.strip().split()] date1, date2 = data[0], data[1] if date1[0] != dat...
0c6f6284a29aee805c872c55e12fa3b5f1e54f4b
anantpanthri/PythonSelfPractice
/FlowerSquare.py
1,890
4.03125
4
import turtle #this function will draw a flower in a window def draw_flower(sonu): sonu.shape("turtle") sonu.color("red") sonu.speed(0) for i in range(1, 40): sonu.forward(50) sonu.left(60) sonu.forward(50) sonu.left(120) sonu.forward(50) son...
c8a5cfaaf3336648608e1ed376056f2e23e963a7
W1nU/algorithm
/first/10216.py
855
3.5
4
# 09 32 import sys input = sys.stdin.readline import math def union(a, b): root_a = find(a) root_b = find(b) if root_a != root_b: sets[root_a] = root_b def find(a): parent = sets[a] if parent == a: return parent else: root = find(parent) sets[parent] ...
638707311ff0585391ed836895e58391260feb2f
daniel-reich/turbo-robot
/zqr6f8dRD84K8Lvzk_4.py
1,771
4.09375
4
""" As stated on the [On-Line Encyclopedia of Integer Sequences](https://oeis.org/A003215): > The hexagonal lattice is the familiar 2-dimensional lattice in which each > point has 6 neighbors. A **centered hexagonal number** is a centered figurate number that represents a hexagon with a dot in the center and all o...
98ef87e8cd1db024cb0808e0dd7df7c907caf346
bluestreakxmu/PythonExercises
/FlashCardChallenge/quizzer.py
1,352
3.65625
4
import random from sys import argv import os def read_flashcard_file(filename): """Get the questions from a fixed flash card file""" filepath = "cardrepository/" + filename if not os.path.isfile(filepath): print("Not a valid file name!!") exit() flash_card_dict = {} with open(file...
1d7806ed27c2eac22564b98d9703df9ff593fcf9
purusottam234/Python-Class
/Day 5/exercise.py
678
4.21875
4
# 1. Show that a what occurs if ...elif statement specifies an else before the last elif. grade = 80 if grade >= 90: print("A") elif grade >= 80: print("B") else: print("fail") elif grade >= 70: print("c") # 2. program to implement the if statement grade = 10 if grade >= 40: print("pass") 3....
496eeac3476016bed3676193b1b50101d7d2a3cf
oxanastarazhok/Hometask
/Text_split/Text_split.py
300
3.859375
4
message = ("How are you? Eh, ok. Low or Lower? Ohh.") def find_secret_message(message): secret_message = "" for letter in message: if letter.isupper(): secret_message += letter return secret_message print find_secret_message("How are you? Eh, ok. Low or Lower? Ohh.")
8a6edd829a049a3aef09b16227f4fcd2931874ab
uma-c/CodingProblemSolving
/trees/BST/inorder_successor.py
1,493
3.765625
4
class TreeNode: def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right = right def nextLowestNode(node: 'TreeNode'): while node.left: node = node.left return node def inorderSuccessor(root: 'TreeNode', p: 'TreeNode') -> 'TreeNode': de...
d1a5950862f2bd38af9e15a24ef21717992a5629
Yang-Hyeon-Seo/1stSemester
/python/coffeeMachine_v2.py
2,128
4.25
4
cup={} menu={'Americano':1800, 'Cafe latte':2200, 'Cafe Mocha': 2800} money=0 sum=0 def print_menu(): print(' '+'='*5+'Sookmyung Cafe'+'='*5) print("""1. Select coffee menu 2. Check your order 3. Pay total price 4. Get change""") def print_coffeeMenu(): print('[Cafe Menu]') for coffee,...
d60f2d3f02370be8ea0f3f6792f300ad17843d47
blackbat13/Algorithms-Python
/fractals/binary_tree.py
427
3.90625
4
import turtle def binary_tree(rank: int, length: float) -> None: turtle.forward(length) if rank > 0: turtle.left(45) binary_tree(rank - 1, length / 2) turtle.right(90) binary_tree(rank - 1, length / 2) turtle.left(45) turtle.back(length) turtle.speed(0) turtle.pen...
eb023916054af3c231d5345da95813ef938365e3
mishu-mnp/Calculator
/calculator.py
4,282
3.90625
4
# ****::Calculator Application::***** from tkinter import * from tkinter.font import Font from tkinter import messagebox root = Tk() root.title("Calculator") s = StringVar() entry = Entry(root, textvariable=s, width=40, justify=RIGHT,) entry.place(x=30, y=10) history_label = Label(root, text="History:...
673094c9153453c0bd63bb50dd8df7f44cf0cfe0
nischalshrestha/automatic_wat_discovery
/Notebooks/py/bhavul93/tackle-titanic-with-tensorflow-for-beginners/tackle-titanic-with-tensorflow-for-beginners.py
21,870
3.71875
4
#!/usr/bin/env python # coding: utf-8 # # Tackling Titanic with basic Tensorflow # # In this notebook, we're going to explore the data a bit, and try basic pandas and tensorflow to get the job done. It is meant for beginners, and should help those who're just getting started with kaggle and/or tensorflow. # # **What...
17c565e75aa127c584eb2c4e282d86971a4d92e1
isutare412/python-cookbook
/02_Strings_and_Text/09_normalizing_unicode_text_to_a_standard_representation.py
781
3.515625
4
import unicodedata s1 = 'Spicy Jalape\u00f1o' s2 = 'Spicy Jalapen\u0303o' print(s1) print(s2) print(s1 == s2) # NFC normalization ('C'omposed) t1 = unicodedata.normalize('NFC', s1) t2 = unicodedata.normalize('NFC', s2) print(ascii(t1)) print(ascii(t2)) print(t1 == t2) # NFC normalization ('D'ecomposed) t1 = unicod...
093336a2a4ac0534f7789e2a9bdc4b5bfd7251df
PederBG/sorting_algorithms
/BucketSort.py
963
4.03125
4
""" Works good if the element values in the list is evenly distributed. Argument m is the value of the biggest element in the list. Works by calculating an index from each of the elements and putting it in the right "bucket". Then sort each bucket and collapse the sub lists. RUNTIME: Best: Ω(n + k), Average: Θ(n + ...
463bfc909a069f5a5f650803401dd7df4efa5bca
Introduction-to-Programming-OSOWSKI/2-3-comparisons-BradyDuPaul2023
/main.py
627
3.8125
4
#WRITE YOUR CODE IN THIS FILE def greaterThan(x, y): if x > y: return True else: return False print(greaterThan(1, 10)) def lessThan(x, y): if x < y: return True else: return False print(lessThan(17, 14)) def equalTo(x, y): if x == y: return Tru...
c14e38b014120a712ad0e97adb0ac26588db7ab2
jeykarlokes/complete-reference-to-python3-programs
/python/functions.py
5,928
3.9375
4
# #functions # def printoddoreven(num): # for n in num: # if n%2!=0: # return True # return False # print(printoddoreven([12])) # # default paarameters # # (A,B) IS THE paarameters # # (11,12) IS THE ARGUMENT # def add(a,b): # return a+b # def sub(a,b): # return ...
ee72e60f8511a099f1776a8baffe1f3d0c6ac6f7
soundestmammal/machineLearning
/py_docs_lessons/python-pb/state.py
655
3.8125
4
#Suppose we want to model a bank account with support for deposit #and withdraw operations. One way to do that is by using global st #ate as shown in the following balance = 0 def deposit(amount): global balance balance += amount return balance def withdraw(amount): global balance balance-= amount return bala...
4cb4afdb4f0085c3d53cebc1eca9815f4a7c3bfb
thinkreed/pyf
/ud036/unit2/2_27.py
585
3.546875
4
import os from string import digits def rename_files_in_dir(): files_list = os.listdir(r'/Users/thinkreed/Downloads/prank') print(files_list) current_path = os.getcwd() os.chdir(r'/Users/thinkreed/Downloads/prank') remove_digits = str.maketrans('', '', digits) for file_name in files_list: ...
7dc676b20dcde0038483663c23c76a680bc448b6
wenjiaaa/Leetcode
/P0001_P0500/0852-peak-index-in-a-mountain-array.py
1,684
4.03125
4
""" https://leetcode.com/problems/peak-index-in-a-mountain-array/ 852. Peak Index in a Mountain Array Easy 918 1325 Add to List Share Let's call an array arr a mountain if the following properties hold: arr.length >= 3 There exists some i with 0 < i < arr.length - 1 such that: arr[0] < arr[1] < ... arr[i-1] < arr...
a90374f96d86dcbf6744b200a776f2ec40f722ad
tinkle1129/Leetcode_Solution
/Math/43. Multiply Strings.py
1,066
3.75
4
# - * - coding:utf8 - * - - ########################################### # Author: Tinkle # E-mail: shutingnupt@gmail.com # Name: Multiply Strings.py # Creation Time: 2018/3/22 ########################################### class Solution(object): def multiply(self, num1, num2): """ :type num1: str ...
0a2cee99bc2e4e06a00be96ee57f7446a50fc57a
gary-gggggg/gary
/1-mouth01/day09/exe06.py
230
3.578125
4
"""实际参数 形式参数""" def func01(p1, p2, p3): print(p1) print(p2) print(p3) dict01 = {"p3": 20, "p1": 50, "p2": 35} func01(**dict01) def func02(**kwargs): print(kwargs) func02(p1=88,p3=456,pp=1256)
257b8f83c5b5e616e2d74a83fdde65c2015af179
JRobayo99/Talleres-de-algotimos
/Taller de Estructuras de Control Selectivas/Ejercicio_2.py
316
3.5
4
salrim=int(input("Ingrese el monto del salario mesual:")) if (salrim<=900000): satlr = salrim*0.15 ttst = satlr+salrim print("El salario neto es de : " "{:.0f}".format(ttst)) elif(salrim> 900000): satlr = salrim*0.12 ttst = salrim+satlr print("El salario neto es de : " "{:.0f}".format(ttst))
68602a52b8d9856ea6c2c0bbdef61344bbf686d2
yurifarias/CursoEmVideoPython
/ex023.py
295
3.78125
4
número = int(input('Digite um número de 1 a 9999: ')) uni = número // 1 % 10 dez = número // 10 % 10 cen = número // 100 % 10 mil = número // 1000 % 10 print('Unidades: {}'.format(uni)) print('Dezenas: {}'.format(dez)) print('Centenas: {}'.format(cen)) print('Milhares: {}'.format(mil))
3cf4e6918f3ed9c105ed397c1e6975ce89d24f86
mpenkov/crackingthecodinginterview
/chapter1/problem6.py
808
4.0625
4
# # Given an image represented by an N*N matrix, write a method to rotate the # image by 90 degrees. Can you do this in place? # def swap(m, x1, y1, x2, y2): m[x1][y1], m[x2][y2] = m[x2][y2], m[x1][y1] def transpose(m): N = len(m) for i in xrange(N): for j in xrange(i + 1, N): swap(...
466622f128194101691bb1a3d11623356560025c
xy008areshsu/Leetcode_complete
/python_version/longest_substring_with_at_most_two_distinct_chars.py
2,663
3.78125
4
""" Given a string, find the length of the longest substring T that contains at most 2 distinct characters. T is "ece" which its length is 3. """ #idea : maintain a h_map, keys are each char, and vals are lists of indices of each char, each val is a sorted list, since the index goes from 0 to len(s) - 1 # scan the s...