blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
410b61fccbf81c5c1072ddf47c773a228f64e016
sochic2/TIL
/algorithm/2020_08/p3.py
1,626
3.703125
4
def right_check(left_garo, right_garo): global result if left.index(left_garo) != right.index(right_garo): result = 'False' def garo(): global result for i in range(len(case)): if case[i] in left: stack.append(case[i]) if case[i] in right: if len(stack) ...
694e6e6cc0df7ebc9893462b20be0926d43c187e
RaphaelScho/N-Puzzle
/src/listTest.py
178
3.8125
4
# how to get x (or x-1) elements of a list from the back and in backwards order x = 10 l = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20] print(l[-x:]) print(l[:-x:-1])
fa7972e6297aadbb676d0da7e62dd187d0fdf0ae
sp-merrow/python_fizzbuzz
/FizzBuzz practice.py
247
3.59375
4
fizzBuzz = {3 : 'Fizz', 5 : 'Buzz'} for i in range(1, 101): charStr = '' for f in fizzBuzz.keys(): if i % f == 0: charStr += fizzBuzz[f] if not charStr: print(i) else: print(charStr)
74119dd3afc34c938689b4cae749df33320cb83f
alessandrogums/Desafios_Python_funcoes
/Exercicio.106_CV.py
409
3.703125
4
def ajuda(): while True: print("~" * 30) print(" Sistema de ajuda para Python") print("~" * 30 comando = str(input("Comando ou biblioteca ('fim' para): ") if comando.lower() == "fim": print("~" * 16) print(" Bye-Bye!") print(...
46616896b0f2c9ad3593f91162b1279ea19d12a9
medasaicharan6/Geektrust-Backend-Challenges
/Tame_of_thrones.py
2,393
3.90625
4
import sys import os import string alphabets_list=list(string.ascii_uppercase) '''Creating a dict with kingdom name as keys and its emblem as values''' Name_emblem_dict={'SPACE':'Gorilla','LAND':'Panda','WATER':'octopus', 'ICE':'Mammoth','AIR':'Owl','FIRE':'Dragon'} '''Defining a function...
16643f9f6325cfa696b053c8e9c9101a36abfe4f
sheucke/Pythontutorial
/encapsulation.py
655
3.734375
4
class Animal: def __init__(self, name): self.name = name class Cat(Animal): def details(self): print(self.name) c = Cat("Mycat") c.details() class Vehicle: def __init__(self): pass def Driving(self): print("Driving the Car") def __PrintDetails(self): # privat...
f668533c84a60b0eec233b274af143fabb1757c0
QuentinDuval/PythonExperiments
/dp/StoneGame2.py
1,495
3.8125
4
""" https://leetcode.com/problems/stone-game-ii Alex and Lee continue their games with piles of stones. There are a number of piles arranged in a row, and each pile has a positive integer number of stones piles[i]. The objective of the game is to end with the most stones. Alex and Lee take turns, with Alex starting...
bbdb23a314d4773e857614e1a8be035bd6844937
haochen208/Python
/pyyyy/11 for循环及range()、for循环嵌套及其应用/02range().py
636
4.25
4
# range(起点,终点,步长) # 默认终点取不到 # 默认写法 # for i in range(1,5,1): # print(i) # 步长为1,默认不写 # for j in range(2,6): # print(j) # 起点为0,起点可以不写 # for k in range(6): # print(k) # 步长为负,从右往左取值 # for l in range(5,1,-2): # print(l) # str = "hello python"找出下标对应元素 # 0 h # 1 e # 2 l # 3 l # 4 o ...
38d5fa9c663b1fb34d776a4c2412eb27e7949988
haliphinx/leetcode
/145_BinaryTreePostorderTraversal/python/BTPostOrder.py
648
3.75
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def postorderTraversal(self, root: TreeNode) -> List[int]: ans = [] if None==root: return ans self.re...
2a25d222b3f9071b61b66a3e97781f18c42a1722
CaryJS/fantasy_scraper
/src/old_proj/build_player_stats.py
1,298
3.5
4
# Passing Keys """ ["GP", "CMP", "ATT", "CMP%", "PASSYDS", "PASSAVG", "PASSTD", "INT", "PASSLNG", "SACK", "FUM", "RTG", "QBR" """ # Rushing Keys """ ["GP", "RUSHATT", "RUSHYDS", "RUSHAVG", "RUSHTD", "RUSHLNG", "RUSHFD", "RUSHFUM", "RUSHLST"] """ # Receiving Keys """ ["GP", "REC", "TGTS", "RECYDS", "RECAVG", "R...
65e4acd05e586fe7650643fc68c7216636edbe3f
jarretraim/euler_py
/11-20/12.py
1,115
3.84375
4
#!/usr/bin/env python from __future__ import print_function import sys # NOT DONE # Brute force is too slow # Number of factors is not consistently increasing, so the binary search didn't work def num_factors(triangle): s = sum(xrange(1,triangle+1)) factors = 0 for i in xrange(1, s): if s % i == 0: factor...
3e4676ce756f93e6295812f27f1ecd231dbe2d39
NirmalVatsyayan/dataStructureAlgo
/using_python/arrays/02_find_numbers_with_odd_occurence.py
384
3.90625
4
''' Pre requisite is, there must be only 1 number occuring for odd number of times. ''' def getOddOccurrence(arr): # Initialize result res = 0 # Traverse the array for element in arr: # XOR with the result res = res ^ element return res # Test array arr = [ 2, 3, 5, 4, 5...
4eb976d34dafeaf9afb1b74ee97766e75327b1bc
iankit25/leet_code
/multiply_strings.py
1,568
3.765625
4
#Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. import math class Solution(object): def make_length_equal(self,num1,num2): if len(num1)>len(num2): diff = len(num1) - len(num2) for i in range(diff): num2+='0' else: ...
8ca2f443371551923608fffde3f8d70434ec1f2d
emptybename/Ds-Algo
/heap/problems/k_most_frequent_elements.py
1,413
4.15625
4
""" https://leetcode.com/problems/top-k-frequent-elements/ Given a non-empty array of integers, return the k most frequent elements. Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] Example 2: Input: nums = [1], k = 1 Output: [1] Note: You may assume k is always valid, 1 ≤ k ≤ number of unique elements....
edd7d4d1ed1b1b19d346bdb9321472b66a06c2f7
gogeekness/Python-Code
/Maze.py
4,562
3.875
4
#!/usr/bin/python2.7 -tt #Maze Generator import sys #import pdb import random from random import shuffle, randrange, randint #Globals #base maze 0 elemets maze = [] width = 0 height = 0 startx = 1 starty = 1 # directions for NORTH, EAST, SOUTH, WEST directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] #----------------...
dc14e2006b61b7921831f5fb3191cfee2f6f21ec
mcrobertw/python
/UsandoForParaInstanciar.py
526
3.859375
4
class Estudiante(object): def __init__(self,nombre,edad): self.nombre=nombre self.edad=edad def hola(self): return 'Mi nombre es %s y tengo %i' % (self.nombre,self.edad) lista_de_alumnos = list() for contador in range(10): nombre = "Estudiante %i" % contador e=Estudiante(nombre,con...
fd227224a5cb6cad55379ad2cd3e94c2471849af
NguyenNamDan/nguyennamdan-labs-c4e23
/lab3/start.py
2,249
3.9375
4
# a = int(input("a = ")) # b = int(input("b = ")) # op = input("operation(+,-,*,/): ") # if op == "+": # print(a, "+", b, "=", a + b) # elif op == "-": # print(a, "-", b, "=", a - b) # elif op == "*": # print(a, "*", b, "=", a * b) # elif op == "/": # print(a, "/", b, "=", a / b) # else: # print("...
711a1e26fcbdd043d48b3ca748713b5b33827ecd
TKSanthosh/tutorial-programme
/ExampleProgramme/pythagorasnumbers.py
215
3.90625
4
from math import sqrt n= int(input("Maximum number?")) for a in range(1,n+1): for b in range(a,n): c_square=a**2+b**2 c=int(sqrt(c_square)) if (c_square==c**2): print(a,b,c)
9497927c2692c8611c7b276c7eeafb4dbaac9317
yangzongwu/leetcode
/archives/contest/1003. Check If Word Is Valid After Substitutions.py
283
3.8125
4
class Solution: def isValid(self, S: str) -> bool: if S[0]!='a': return False if len(S)%3!=0: return False while 'abc' in S: S=S.replace('abc','') if not S: return True return False
94330294de27788a48cc4a8fee0d2795e49bd927
saraattia412/basic_python
/abstraction.py
465
3.75
4
from abc import ABC class Shape(ABC): def calculate_area(self): pass class Rectangle(Shape): length = 2 width = 3 def calculate_area(self): return self.length * self.width class Triangle(Shape): length = 2 width = 3 def calculate_area(self): return (self.width * self.length) / 2 rect...
5d52633119ac919bbd7498edc7ea520bfc07a7e5
xxxwarrior/Basic-Design-Patterns-Python
/Iterator/iterator.py
1,106
4.21875
4
""" Iterator is used to iterate over a collection of elements without exposing its implementation. Iterator and Aggregator can be abstract classes and ConcreteIterator and ConcreteAggregator can be added. """ from typing import List, Any class Iterator: def __init__(self, collection: List[Any]) -> Non...
38228e400df4426b0737cabfa7865db03b6f39da
Jamye/algos_py
/challenges_hb/add_linked_lists.py
1,081
4.09375
4
# Add Linked List # Given two linked lists, treat as numbers and add them together. class Node(object): def __init__(self, data=None, next_node=None, head=None): self.data = data self.head = head self.next_node = next_node def get_data(self): return self.data def get...
6a151325163354ae02ed3b1f2132a7a54965c89a
NeelShah18/linalg
/inverse/utils.py
2,251
3.921875
4
import numpy as np from sum import KahanSum from functools import reduce def is_symmetric(A): """ Returns True if A is symmetric. """ return np.allclose(A, A.T) def diagonal(A): """ Grabs the diagonal elements of a square matrix A. """ m = len(A) diag = [] for i in rang...
f0e056b57a879303ce46e21cec0e7a4558928307
kyj960901/smart-alarm
/hackathon/triangulation.py
1,224
3.53125
4
import math #cos to sin def cos_to_sin(a): return (1-a**2)**0.5 #코사인제2법칙을 이용하여 코사인값 def cos2_law(a, b, c): return (b**2+c**2-a**2)/(2*b*c) #두점의 x축에대한 기울기를 사인으로 반환 def gradient_sin(p1, p2): return (p2[1]-p1[1])/distance_2points(p1, p2) #두점의 x축에대한 기울기를 코사인으로 반환 def gradient_cos(p1, p2): return (p2[0]-...
aebdd41ba510c74e62f79d6f63d13518fa28b469
akanksha234/Automation_Python
/interview_question/rotate_list.py
3,355
4.125
4
# rotate list # no time/space requirements # return "rotated" version of input list #rotate a list in any direction depending upon the index def rotate(my_list, num_rotations, direction): length_list = len(my_list) #when the num_of_rotation is greater then the length and is a mulitple of length than li...
980b55ee16b95bc5440cb1bdcb1085f0fc17a3ed
Christymary/pythonprograms
/datacollections/list/sum.py
80
3.53125
4
a=[1,2,3,4,5,6,7,8,9,10] sum=0 for i in a: sum=sum+i print("sum is",sum)
050397552abfba1faead1250b320d040f4fded64
seannewell/web_scraping_practice
/web_scraping_practice.py
1,021
3.515625
4
# web_scraping_practice.py # # This is a .py file that scrapes information from the # blog page on runwayaudio.com and turns it into a # .csv file that can be opened in Excel import requests from bs4 import BeautifulSoup from csv import writer response = requests.get('https://runwayaudio.com/blogs/news') soup = Beaut...
5bc55e3382b0ed202987e4ed5e8a4d39531508b8
Pozas91/tiadas
/models/index_vector.py
5,599
3.703125
4
""" Class that represents a vector with an associated integer index, that can be used, for example, as an identifier. """ import numpy as np from .dominance import Dominance from .vector import Vector class IndexVector: """ Class IndexVector with functions to work with int vectors. """ def __init__(...
600e1f00e7c446feb114f81872f3383090d39796
thishelo/learn-crawler
/learn_urllib2.py
386
3.515625
4
# -*- coding:utf-8 -*- import urllib2 url = raw_input("please input url:") # 构建User-Agent headers = {"User-Agent" : "Mozilla/5.0 (X11; CrOS i686 2268.111.0) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11" } #调用Reques方法 request = urllib2.Request(url, headers = headers) response = urllib2....
dc4c3bf4cc0032fe20d138ea8a5bc0db5328043f
gabialeixo/python-exercises
/exe059.py
1,376
4.4375
4
'''Crie um programa que leia dois valores e mostre o menu na tela: [1] Somar [2] Multiplicar [3] Maior [4] Novos números [5] Sair do programa Seu programa deverá realizar a operação solicitada em cada caso.''' from time import sleep print('=' * 10) print('CONTORANDO') print('=' * 10) num01 = float(input('Digite um v...
14e2ec1891450cd150cfa3abe065860d239648ec
nathsotomayor/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/tests/6-max_integer_test.py
915
4.15625
4
#!/usr/bin/python3 """ Unittest for max_integer """ import unittest max_integer = __import__('6-max_integer').max_integer class TestMaxInteger(unittest.TestCase): """ Defines class to test max integer """ def test_not_a_list(self): """ String arguments in list case """ self.assertEqual(max_int...
d7fec975d41338c5f864ccb789261d30dda825e5
sridhar667/hello-world
/monthinwords.py
455
3.640625
4
s=input() if s[3:5]=='01': print("January") if s[3:5]=='02': print("February") if s[4]=='3': print("March") if s[4]=='4': print("April") if s[4]=='5': print("May") if s[4]=='6': print("June") if s[4]=='7': print("July") if s[4]=='8': print("August") if s[4]=='9': pr...
0e528054c2b22bad8df1b0b34b5120222b2a69d4
chrismcg/machine_learning_ng
/python/ex1_multi.py
2,273
3.6875
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt def read_data(): df = pd.read_csv("../octave/ex1/ex1data2.txt", names=['X1', 'X2', 'y']) x = df.as_matrix(['X1', 'X2']) y = df.as_matrix(['y']) return (x, y) def feature_normalize(x): mu = x.mean(0) sigma = x.std(0) ...
afc18d01c3f2b120fe4b96f138e15cd028d26a32
ilookforme102/PythonViope
/8_2.py
1,544
4.53125
5
# -*- coding: cp1252 -*- ''' The second exercise combines several normal error scenarios into one program. In this exercise, create a program which prompts the user for a file name. Based on user input, open the given file and read the contents into one big string. Then convert this string to an integer and divides th...
3b7403334dac7d133dd22c73641a95ca0c6adda4
Hogusong/CodeFight-Python3
/Trees/traverseTree.py
1,698
4.125
4
# Note: Try to solve this task without using recursion, since this is what you'll be asked to do during an interview. # # Given a binary tree of integers t, return its node values in the following format: # # The first element should be the value of the tree root; # The next elements should be the values of the nodes a...
af955b40354281971b869c2517801fb623f2f7c6
beef-erikson/ProgramArcadeGamesPycharm
/Chapter9/animation.py
1,462
4.3125
4
""" Example of using animation in Pygame Beef Erikson Studios, 2019 """ import pygame # Define some colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) RED = (255, 0, 0) GREEN = (0, 255, 0) BLUE = (0, 0, 255) # Initializes pygame pygame.init() # Open a window at 800x600 resolution screen_size = (800, 600) screen = ...
fad7bb8d7be56c81b86018e58df17eeeb9003a2b
luissergiovaldivia/Python
/paso_de_lista.py
172
3.90625
4
def modifica(a,b): a.append(4) b = b + [4] return b lista1 = [1, 2, 3] lista2 = [1, 2, 3] lista3 = modifica(lista1, lista2) print(lista1) print(lista2) print(lista3)
d63751be3bae3eb0c7a47242a8190f37f4edee07
Storn5/Storn5_Repository
/PythonFiles/Learning/guessTheNumber.py
1,214
4.4375
4
#Guessing the number game import random #Game function, takes a number as argument def game(number): #The number of guesses guesses = 0 print('I am thinking of a number between 1 and 20.') #The game loop starts here while(True): #Each time the player guesses, the number of guesses goes up ...
499f19e0923fc667d191fc68c056f286acf39275
dxc19951001/Everyday_LeetCode
/236.二叉树的最近公共祖先.py
2,026
3.671875
4
# coding=utf-8 """ @project: Everyday_LeetCode @Author:Charles @file: 236.二叉树的最近公共祖先.py @date:2022/12/23 22:46 """ # Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): ...
726733b11f429267098315b8c49ec09ff169e96f
lonely7yk/LeetCode_py
/LeetCode147InsertionSortList.py
1,938
3.890625
4
""" Sort a linked list using insertion sort. A graphical example of insertion sort. The partial sorted list (black) initially contains only the first element in the list. With each iteration one element (red) is removed from the input data and inserted in-place into the sorted list Algorithm of Insertion Sort: ...
1d70f911f76c3e22caae901ec6d18c6e253c715f
mdenko/University-of-Washington-Certificates
/DATASCI 400/milestone_2/MatthewDenko-M02-Script.py
11,983
3.703125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Nov 10 10:00:25 2018 @author: matt.denko """ """Read in the data from a freely available source on the internet. Account for outlier values in numeric columns (at least 1 column). Replace missing numeric data (at least 1 column). Normalize numeric va...
492443620a2fa1e9ba275cb262500494feb16e5b
qcgm1978/py-test
/test/numpy/getRavel.py
328
3.625
4
def getRavel(alist, order): ret = [] # ‘F’ means to index the elements in column-major, Fortran-style order if order == 'F': cols = len(alist[0]) n=0 for i in range(cols): for m in range(len(alist)): ret.append(alist[m][i]) n+=1 return...
0941fc1ca3e142f97aec5d07de772b8659e9b461
ryanjoya/Python-Practice-Unit-15-Practice-Makes-Perfect
/15.15 median.py
202
3.5625
4
def median(lst): lst.sort() if len(lst)==1: return lst[0] elif len(lst)%2 != 0: return lst[(len(lst)+1)/2-1] else: return (lst[len(lst)/2-1]+lst[len(lst)/2])/2.0
3be369bd269f2e3289660d4d9c5bec4f5bd4479f
albertoide/code_eval
/challenges_py2/swap_elements/swap_elements.py
780
3.984375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys def swap_positions(numbers, positions): for i, j in positions: tmp = numbers[i] numbers[i] = numbers[j] numbers[j] = tmp if __name__ == '__main__': with open(sys.argv[1], "r") as file_handler: for line in file_handler:...
c7042e8400fc6d97ba3a4692cd5a106d1beab45e
HunterDietrich/Lists
/main.py
279
3.984375
4
#ARRAY grocery_list = ["apples", "bananas", "grapes", "twix"] print(grocery_list) #INDEXING print(grocery_list[2]) print(grocery_list[0]) #FOREACH LOOP for i in grocery_list: print(i, "2.99") #FOR LOOP for i in range(len(grocery_list)): print(grocery_list[i], "2.99")
4c53bb760af3e1acb8a4998bfa5fa7d06d65e934
jidhu/code
/hw/encode.py
390
4.03125
4
# intialising a String a = 'GeeksforGeeks' print(a) #initialising a byte object c = b'GeeksforGeeks' print(c) #using encode() to encode the String #encoded version of a is stored in d #using ASCII mapping d = a.encode('ASCII') #try 'utf-16' or 'utf-8'(ASCII) print(d) #checking if a is converted to bytes or not if(d==...
29a74ed6bc5573da79d585c7968793404e97f88c
eukap/calcpy
/arithm.py
2,327
4.03125
4
""" arithm.py defines the arithmetic functions that take a list with string elements of decimal numbers and operation signs and return a new list as a result after some processing. """ from decimal import Decimal, InvalidOperation, Overflow def power(lst): """ Execute all raising to a power operations av...
9dca6d8080d336dbc85828a84b4591e036053d31
sukritishah15/DS-Algo-Point
/Python/gcd.py
288
4.03125
4
# Function to find HCF the Using Euclidian algorithm def gcd(x, y): while(y): x, y = y, x % y return x num1 = int(input()) num2 = int(input()) gcd = gcd(num1, num2) print("The GCD is", gcd) """ 4 6 The H.C.F. is 2 """ """ time complexity O(logn) space complexity O(1) """
0061d7e2b6ff1be7ee0d85677b6148e807ef93ac
htmlprogrammist/kege-2021
/tasks_25/solutions/25-107.py
586
3.625
4
from math import sqrt start, end = 153732, 225674 def isPrime( x ): if x <= 1: return False d = 2 while d*d <= x: if x % d == 0: return False d += 1 return True iMinDiff = [] minDiff = 1e10 count = 0 for i in range(start, end+1): q = round(sqrt(i)) D = [2] + list( range(3,...
ce600e15c08da861109d6565c2c95a823f991c73
scdekov/hackbg_exam
/tic-tac-toe/game_test.py
792
3.703125
4
from game import Game import unittest class test_game(unittest.TestCase): def setUp(self): self.game = Game() def test_is_board_clear_at_begginnig(self): expected_result = ['1', '2', '3', '4', '5', '6', '7', '8', '9'] self.assertEqual(expected_result, self.game.board) def test_p...
e31fdd076275149eb24d17b2a1ae6fe721e8dce9
Sleeither1234/T05_HUATAY_CHUNGA
/boleta_16.py
743
4.0625
4
# BOLETA DE VENTA DE UNA TIENDA TECNOLOGIDCA producto_1=input("INGRESE EL NOMBRE DEL PRODUCTO: ") P_U=float(input("INGRESE EL PRECIO UNITARIO DEL PRODUCTO: ")) unidades=int("INGRESE EL NUMERO DE UNIDADES DE SU PRODUCTO") NOMBRE=input("INGRESE EL NOMBRE DEL CLIENTE: ") TOTAL=P_U*unidades IGV=print("CALCULANDO....") IGV=...
e2201fc162236fa63ff3d9b7ae7f2b626f750029
Paandi/LearnPython
/basicModule/datetime_handling.py
1,070
3.796875
4
from datetime import datetime --- To find the execution time now=datetime.today() - adatetime object later=datetime.today() diff=later-now --- only date from datetime import date system_date = date.today() custom_date = date(2019, 4, 13) print(custom_date) date_diff = system_date - custom_date print(date...
6d4485e2c3a588a33b1b825e370f00a5af064cb6
KeithPallo/independent_coursework
/1 - MOOC - Intro to CS & Programming/Problem Set 4/ps4_problem_1.py
1,363
3.765625
4
from ps4a import * def getWordScore(word, n): """ Returns the score for a word. Assumes the word is a valid word. The score for a word is the sum of the points for letters in the word, multiplied by the length of the word, PLUS 50 points if all n letters are used on the first turn. Letters ar...
7bc7186caeff97d378f6894055a71a046a67e2b7
Honwiy/learning_python
/dict_set.py
234
3.578125
4
# -*- coding: utf-8 -*- d = { 'mick':95, 'bob':75, 'tracy':85 } print('d["mick"] =',d['mick']) s1 = set([1, 1, 2, 2, 3, 3]) print(s1) s2 = set([2, 3, 4]) print("s1 & s2 =",s1 & s2) print("s1 | s2 =",s1 | s2)
b6bca8cd4780a1df29a41e6d82b55f74140c8e98
TonyTYO/Sudoku
/qsolver.py
25,723
3.5625
4
""" Algorithms for solving square """ from PyQt5.QtCore import Qt from PyQt5.QtGui import QFont from PyQt5.QtWidgets import QLabel import itertools import Constants as Cons class Solver: def __init__(self, board): self.board = board self.possibles = None self.content = None se...
51e6d1848dcafb11e26ad81bae2606ab6d83343b
SeavantUUz/LC_learning
/pathSum.py
1,268
3.59375
4
# coding: utf-8 __author__ = 'AprocySanae' __date__ = '15/8/15' class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def __str__(self): return str(self.val) def pathSum(root, sum): solutions = [] def one_solution(root, solution, remai...
0a0a2d79d7ab0a512e5850b0d5867c519295aa00
toggame/Python_learn
/第四章/break_test.py
1,992
4
4
for i in range(10): print('i的值为:', i) if i == 2: break # 当i=2时,跳出循环 # i的值为: 0 # i的值为: 1 # i的值为: 2 ############################### for i in range(10): print('i的值为:', i) if i == 2: break else: print('else块:', i) # 该语句在i == 2时不会执行 # i的值为: 0 # else块: 0 # i的值为: 1 # else块: 1 # i的...
f84c7d0f629413fb7b191f7308da9a3f81912211
JCVANKER/anthonyLearnPython
/learning_Python/basis/模块/说明/making_pizzas.py
1,825
3.546875
4
#将函数存储在被称为模块的独立文件中,再将模块导入到主程序中。 #import语句使用模块中的代码 #import语句加模块名,可在程序中使用模块中的所有函数 import pizza #句点表示法:此时函数的调用方式:module_name.function_name() pizza.make_pizza(16,'pepperoni') pizza.make_pizza(12,'mushroom','greem peppers','extra cheese') ''' #导入指定的函数:from module_name import function_0,function_1 from pizza import make_...
34014f7008d6f33ccb64b5a8e222a3c4144b4454
RodoDenDr0n/UCU_labs
/vscode_intro/painting.py
510
3.625
4
from turtle import * d = -1 rainbow = ["red", "orange", "yellow", "green", "blue", "dark blue", "dark violet"] while True: d += 1 if d == 7: d = -1 speed(100000) color(rainbow[d]) right(1) forward(1) circle(100) # a = 0 # b = 0 # for i in range (210): # a += 1 # b += 1 ...
c46fc017beb5cfb0320b6784b0fd44840ba58125
eydertinoco/IFAL_Estrutura_de_Dados
/4. Listas Encadeadas e Deques/menu.py
1,413
3.5
4
from gerenciador import Gerenciador from processo import Processo class Menu: def __init__(self, tamanho_memoria): self.gerenciador = Gerenciador(tamanho_memoria) def criar(self): id = int(input("Digite o id do processo: ")) tamanho = int(input("Digite o tamanho do processo: ")) print("Defina o...
57b01c937f86e08e416327435ff227a2674b4c81
rafaelperazzo/programacao-web
/moodledata/vpl_data/396/usersdata/282/81100/submittedfiles/av1_programa2.py
2,377
3.734375
4
# -*- coding: utf-8 -*- #COMECE AQUI ABAIXO a = int(input('Digite o primeiro numero entre 1 e 99: ')) b = int(input('Digite o segundo numero entre 1 e 99 diferente do anterior: ')) c = int(input('Digite o terceiro numero entre 1 e 99 diferente dos anteriores: ')) d = int(input('Digite o quarto numero entre 1 e 9...
8285850fc194805b7a3a8b400258cd36f3e9eaf1
itkasumy/LNHPython
/day13/06-包装标准类型.py
398
3.734375
4
class List(list): def showMiddle(self): return self[int(len(self) / 2)] def append(self, item): if type(item) is str: super().append(item) else: print('should be str type only') ls = List('helloworld') print(ls, type(ls)) print(list('helloworld'), type(list('he...
e2b87369cafd605b1acc3fc8b4b44fc521d378cb
MaximHirschmann/project-euler-solutions
/Python/043.py
555
3.65625
4
from itertools import permutations # does not check for 5 because only gets divisible-by-5-numbers def isdivisible(s): if s[0] == '0': return False divisors = [2, 3, 5, 7, 11, 13, 17] for i in range(7): if int(s[i+1] + s[i+2] + s[i+3]) % divisors[i] != 0: return False r...
4e419875fc9da273d5da3e2a102df49535d17665
PacktPublishing/Mastering-Python-Scripting-for-System-Administrators-
/Chapter08/print_example.py
222
4.21875
4
# printing a simple string on the screen. print("Hello Python") # Accessing only a value. a = 80 print(a) # printing a string on screen as well as accessing a value. a = 50 b = 30 c = a/b print("The value of c is: ", c)
95f61e60a71af4211b2ebecedd87f99e4295495c
Balu862/everyday_assignments
/day6assignment-26july/26july2021-Kalaiarasi-day6assignment/calx.py
534
3.71875
4
class Calculator(): def add(self,a,b): return a+b def sub(self,a,b): return a-b def mul(self,a,b): return a*b def div(self,a,b): return a/b def floor(self,a,b): return a//b def mod(self,a,b): return a%b def exp(self,a,b): return a**b a=...
754199aea3dd67581cb68e46b38b6f09e7f3e12f
parshuramsail/PYTHON_LEARN
/paresh57/a8.py
523
3.65625
4
#BLACKJACK:given three intigers between 1 and 11,if thier sum is less than or equal to 21,return their sum. #if there sum is exeeds 21 and thers an eleven,reduce sum by 10.finally if the sum(even after adjustments) exeeds 21,return "BUST". #black_jack(5,6,7)==18 #black_jack(9,9,9)==BUST #black_jack(9,9,11)==19 def bla...
d86c9b444933b4c4378a2c2c42ad8d3ed23aa8c1
xuanxuan-good/MyCode
/之前做过的/515.在每个树行中找最大值.py
1,138
3.53125
4
# # @lc app=leetcode.cn id=515 lang=python3 # # [515] 在每个树行中找最大值 # # @lc code=start # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def largestValues(self,...
38a48d991dd1d79f542ba6457915f2ca455d62d1
Aasthaengg/IBMdataset
/Python_codes/p03433/s581214095.py
101
3.640625
4
price = int(input()) yen = int(input()) if price % 500 <= yen: print('Yes') else: print('No')
16aecf3449216e8484f1ed97643591a690236d5d
andreahurtado30/blackjack
/assignment_5_andrea_hurtado.py
3,808
4
4
""" Assignment 5 """ import random import time #Function to add up value of drawn cards def cards_total(*drawn_cards): total = 0 for number in drawn_cards: total += number return total #Dealer's turn function, comes into effect after user stands or gets 21 def dealers_turn(user_car...
39debbf394748b089676a4a778426b7d53a83195
rkTinelli/learn_prog_languages
/Python/Code Exercises/exec_9_21.py
557
3.765625
4
x = 0 while x<= 10: print(str(x) + " ", end='') x=x+1 print("\n"+"While Loop finished") print("------------------------") loopCounter = 0 userAnswer = True while (userAnswer): loopCounter = loopCounter +1 print("Loop interaction number " + str(loopCounter)) answerText = input("Run loop again? [Y/...
66a82b03c0b4c6fbbc2cfe0e5e793116c39b123a
jonathanshi568/BracketEvaluator
/app/databasegene.py
3,414
3.703125
4
"""Defines all the functions related to the database""" from app import db def fetch_todo() -> dict: """Reads all tasks listed in the todo table Returns: A list of dictionaries """ conn = db.connect() query = 'Select * from brackets;' query_results = conn.execute(query).fetchall() ...
1de9187283194c6408fc908973ff22fe79203875
hamidgiwa/helloworld
/number of vowels.py
349
4.1875
4
program to countowel in a string using set def countvowel(str1): c =0 # Creating a set of vowels s = "aeiouAEIOU" v = set(s) #Loop to transverse the alphabet in the given string for alphabet in str: #If alphabet is present # in the set vowel: count = count + 1 ...
61e0bda93a240b789113c9998388484596e4179e
Vigyrious/python_fundamentals
/Data_Types-and-Variables-Exercise/Print_Part-of-the-ASCII_Table.py
103
3.75
4
range1 = int(input()) range2 = int(input()) for i in range(range1, range2+1): print(chr(i),end=" ")
74ad7a0a01dfe47d7cc22d88478b8cc9b97d8083
Aasthaengg/IBMdataset
/Python_codes/p02812/s896751797.py
95
3.703125
4
n = int(input()) s = input() s = s.replace("ABC", "") # print(s) print(int((n - len(s))/3))
7f726c380165bce570158fbabb5234fb3d6ed782
premkasula/python
/dam4.py
248
3.609375
4
bol=bool(input("Enter boolen:")) t=int(input("Enter time in hours:")) def parrot_trouble(bol,t): if t<7: return True elif t>20: return True else: return False print(parrot_trouble(bol,t))
cb02a7b82390a4faf4e377fbe4981e3f31bf9dc4
rer3/Coursera_RiceUni
/IIPP/IIPP_Assignments/IIPP2_Project3_Stopwatch.py
11,530
4.0625
4
""" Rice University / Coursera: Intro to Interactive Programming in Python (Part 1) Week 3: Project 3 Stopwatch """ #================================================================= # All code for this assignment is shown below with only essential imports. # Code provided by Rice University has been modified whenever ...
16a7a4622d7e735b37a7c929f98c950ae33849d5
venkatsgithub1/Python
/str_format_tricks.py
1,164
4.46875
4
print("The age of {0} is {1}".format('John Doe',32)) # Same delimeter argument is used twice and refers to # word 'Doe'. print("{0} {1} and {2} {1} are not related I guess.".format('John','Doe','Jane')) # If field names are used in sequence, they can be omitted. print("{} is a {}".format('Python','language')) # Named...
aeccbfdc8c87fa4d277c044308bf12467c8a2261
alpha-kwhn/Baekjun
/Kwan/2292.py
231
3.796875
4
bee = int(input()) num = 1 while True: tmp = (3 * num * num) + (3 * num) + 1 if bee == 1: print(1) break elif bee <= tmp: print(num + 1) break else: num = num + 1
d538e8ea24fcb026cf0d2410d855f894a10f8c2f
LeiLu199/assignment6
/ml4713/assignment6.py
1,632
4.125
4
# -*- coding: utf-8 -*- """ This is Programming for Data Science Homework6 script file. Mengfei Li (ml4713) """ import sys import re from interval_functions import * def main(): """In the main function, the user is asked to input a series of intervals which are automatically coverted to a list. After the i...
c54691ffec67df8652b167598c0f1285fc1f372b
kouddy3004/learnPython
/BasicPython/basicProgramming/sdeSet/arraysSet.py
1,464
3.609375
4
import copy class ArraySets(): def findTriplets(self,inputArray): print("Find Triplets") print("Input "+str(inputArray)) list=[] for i in range(len(inputArray)): a=inputArray[i] for j in inputArray: if a is not j: b=a+j ...
d0129e68cc09f847f071b095a6c2fa9804c8ba3f
dvasilev7/PYTHON-FUNDAMENTALS
/Lists/09. Hello, France.py
826
3.71875
4
items = input() budget = float(input()) items_list = items.split("|") profit = 0 new_price_list = [] for item in items_list: item_type, price = item.split("->") price = float(price) if item_type == "Clothes" and price > 50.00: continue elif item_type == "Shoes" and price > 35.00: ...
8041e4cfe6060ec53a19a091d98516cae62f2fa4
AjayiSamuel/hackerrank-submissions
/Python/nested_list.py
1,397
3.640625
4
# students = [['Harry', 37.21], ['Berry', 37.21], ['Tina', 37.2], ['Akriti', 41], ['Harsh', 39]] def second_lowest_grade_finder(students): scores = [] second_min_score = None for i in range(len(students)): scores.append(students[i][1]) scores.sort(reverse=False) for i in range(len(scores...
2561a91639ffa4809fb0fed26e1e307f5b69b01a
grgc25/Tareas
/partial2_2.py
190
3.90625
4
def triangulo(p): for p in range(0,p+1,1): print("T"*p) for p in range(p-1,0,-1): print("T"*p) p=int(input("Cual quieres que sea el tamano maximo del triangulo? -> ")) triangulo(p)
8c222767087eca14609eefff474f17c768fce8f9
minotaur423/Python3
/summer_69.py
218
3.703125
4
def summer_69(arr): new_arr = [] for num in arr: if num not in range(6,10): new_arr.append(num) else: continue return sum(new_arr) print(summer_69([2, 1, 6, 9, 11]))
3b96b8f4f32ecefef5bb9b7a5b97318617944368
cmruhari/007royalmech2018
/dec.py
101
4.125
4
i=10 while i>=1: print(i) i=i-1 #printing numbers in decreasing order using while loop
ef6a1b02ec88a3711679a7c6c4cbb2747fb88faa
pzelenin92/learning_programming
/Stepik/Algorithms_theory_and_practice_course_217/2/2.2/2.2.7/2.2.7.py
272
3.890625
4
def fib_digit(n): a0,a1,i=0,1,2 if n==1: a2=1 else: while i<=n: a2=(a0+a1)%10 a0,a1=a1,a2 i+=1 return a2 def main(): n = int(input()) print(fib_digit(n)) if __name__ == "__main__": main()
01141b0ce231e0046c8cb9d8193703ac1c0d324f
Lance0404/my_leetcode_study_group
/python/medium/add-two-numbers.py
1,090
3.65625
4
""" https://leetcode.com/problems/add-two-numbers/ Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) Output: 7 -> 0 -> 8 Explanation: 342 + 465 = 807. Runtime: 72 ms, faster than 52.43% of Python3 online submissions for Add Two Numbers. Memory Usage: 12.7 MB, less than 100.00% of Python3 online submissions for Add Two Numbers. ""...
9ec7780f6ed5d0949cc85a1953cd3c83f686913b
Sonnenlicht/BasicPython
/formatstr.py
110
3.671875
4
#! python3 # format decimal places program cost = 5.5 val = round(cost/1, 2) print('$' + str("%.2f" % val))
78c3c60223caca16fa6f986e6e8862414941cbdf
dheeproject/collections
/sumpair.py
237
4.09375
4
testlist=[(4,5),(6,1),(3,6),(4,3),(2,5)] """ here we are finding the pairs which have sum equal to a particular value k """ k=int(input("Enter choice for sum of pairs")) for a,b in testlist: if a+b==k: print(a,b)
1c5c78aa073f12e741954efe9a31431a276d4135
oschre7741/pygame-graphics
/pygame-graphics-master/pygame_mini_project.py
4,163
3.546875
4
# Imports import pygame import math import random # Initialize game engine pygame.init() # Window SIZE = (800, 600) TITLE = "I wish I Could Do This But I Live In South Carolina" screen = pygame.display.set_mode(SIZE) pygame.display.set_caption(TITLE) # Timer clock = pygame.time.Clock() refresh_ra...
f58cdbf01235ec0685669c9b1085f5389238601d
MKhalusova/TweetCleaner
/src/tweet_cleanup_script.py
1,868
3.65625
4
# -*- coding: utf-8 -*- """ This script removes old tweets and stores them in sqlite """ import tweepy from datetime import datetime import sqlite3 # Twitter Constants: add your own API_KEY = '' API_SECRET = '' ACCESS_TOKEN = '' ACCESS_SECRET = '' USER_NAME = '' # Local Constants: add your own sqlite_file_path = '' ...
2d505ba3848acde63b5184cb9000d57f160c06d2
utsaimin/PythonProjectChapter08
/Praktikum04.py
641
3.953125
4
#menu awal namaSayur = ('kangkung', 'bayam', 'salada', 'wortel') print('Menu : ') A = 'A. = Tambah data sayur' B = 'B. = Hapus data sayur' C = 'C. = Tampilkan data sayur' print(A) print(B) print(C) #input pilihan pilihan = input('Pilihan anda : ') if (pilihan == 'A'): print(namaSayur) x = list(namaSayur) t...
a73c51fc8e0d150db9a0f1ad2aa3b4fdc3379bf4
rkandekar/python
/DurgaSir/e_string_datatype.py
860
3.796875
4
# Any sequency of character enclose within ('') single quotes or ("") double quote or tripple single quote ('''''') or tripple double quote("""""") s="nam" t='name' print(s,"\n",t) # recomended sigle quite # for multiline use tripple sinle or double quotes u='''tripple single quotes''' print(u) complex_str...
2dba290327b186c52b42efb52b9cdc3187ac8a70
gabriellaec/desoft-analise-exercicios
/backup/user_027/ch32_2019_03_08_18_15_06_072074.py
151
4.0625
4
duv = input("Você têm dúvidas?") if duv == "não": print("Até a próxima") while duv != "não": duv = input("Você têm dúvidas?")
5d6d300e04d055f8752c7a201ee8d44acba2a47e
emmas0507/lintcode
/validate_complete_binary_tree.py
1,180
4
4
# count the number of nodes, and then order nodes by their level, from left to right # to see if all index from 0 to the number of nodes all filled class Node(object): def __init__(self, value, left=None, right=None): self.value = value self.left = left self.right = right def count_number_...
6a02007b98cfda4ca6655724eed65342e5adcfd3
siawyoung/practice
/problems/smallest-substring-contained-in-set.py
1,215
3.953125
4
# You are given a set of unique characters and a string. # Find the smallest substring of the string containing all the characters in the set. # ex: # Set : [a, b, c] # String : "abbcbcba" # Result: "cba" from collections import defaultdict def smallest_substring(char_set, string): hash_map = defaultdict(int...
6e078bf4bd1c4819a833c4939c97158755adc065
FarhadIslamMim/Python-OOP
/Meta_Characters.py
1,322
3.5625
4
import re pattern=r"colo.r" if re.match(pattern,"colour"): print("match") else: print("not march") pattern=r"colo...r" if re.match(pattern,"coloubr"): print("match") else: print("not march") pattern1=r"^colo.r$" if re.match(pattern1,"colour"): print("match") else: print("not m...
eeb8ce90e772e4af8e505fd06a975fea970d32f9
jason12360/AID1803
/pbase/day11/student.py
576
4.03125
4
# 练习: # 写一个函数,在函数内部读取学生姓名,并存入列表中,通过两种方式返回学生姓名数据,并打印出来 # 方式1,通过返回值返回数据 # 方式2,通过参数返回数据 # def get_names(x = []): # L = [] # while True: # name = input('请输入姓名:') # if not name: # break # L.append(name) # x[:] = L # return L # n = get_names() # print(n) n = [] get_names(n) print(n) def get_names(L = [])...
7fdf4d844e91c3d1043c93f601fa28bcd9a1c32a
GiovannaPazello/Projetos-em-Python
/Lista 1/Exercicio 7.py
535
4.0625
4
'''Escrever um algoritmo para ler as dimensões de uma cozinha (comprimento, largura e altura), calcular e escrever a quantidade de caixas de azulejos para azulejar todas as paredes (considere que não será descontada a área ocupada por portas e janelas). Cada caixa de azulejos possui 2 metros quadrados.''' c = float(in...
3e5d922fdc3f17c3819ce1d0b6e73044ebb4736d
atkm/reed-modeling
/simulation_simple/simple_sim.py
3,070
3.75
4
import sys import scipy as sp import numpy as np np.set_printoptions(precision = 5, suppress = True) ## *see corresponding update to the graph* ## - changed transition probabilities in Circle from 1/3 to 1/2, to reflect the graph. ## - added rough waiting line functionality to probablistic(). It now takes a ##...