blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
6cfae8d48991272e8d60668d24bc298b74f90764
eischaire/my_homeworks
/programming_HWs/svoystvachisel.py
311
3.828125
4
a = input('введите число а: ') b = input('введите число b: ') c = input('введите число c: ') a = int(a) b = int(b) c = int(c) if (a + b) == c : print('a+b=c') else : print('a+b=/=c') if (a*c)==(0-b) : print('a*c+b=0') else : print('a*c+b=/=0')
b539826103d35c8f0068054db4dad791ce736568
eischaire/my_homeworks
/programming_HWs/HW for 10.01.17/program.py
2,169
3.609375
4
import random def arr_form(text) : file = open(text, 'r', encoding="utf-8") arr = file.read() arr = arr.split(' ') file.close() return arr def vocals(PoS) : V = 0 for letter in PoS: if letter in 'аоуыэяёюиеАОУЫЭЯЁЮИЕ' : V += 1 return V def nounword(n_...
f13ec269ee332356d8a168dbc0821076091204fc
maxiuw/ML
/knn_proj/knnproj.py
1,730
3.53125
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns from sklearn.preprocessing import StandardScaler from sklearn.model_selection import train_test_split from sklearn.neighbors import KNeighborsClassifier from sklearn.metrics import classification_report,confusion_matrix ...
90538856bf9178cd1a8b783ab0ed94e682f1493e
SunnyCat2013/mimic-tf
/mimic_tf.py
2,855
3.625
4
class Graph(): def __init__(self): self.Placerholder = [] self.Variable = [] self.Operator = [] self.Constant = [] def as_default(self): global _default_graph _default_graph = self ''' what's the point of default graph? Since there is no use of _default_graph? '...
118aaad7084f3c2bfe0018585ba5b84d40815b30
CharlesHehe/leetcode
/NoteTest/review.py
1,302
3.796875
4
# Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: final_node = ListNode() def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: n = 0 return self.addN(l1, l2, ListNode(), n)...
898e966b830e4425dbec735723384778df9d9ac8
CharlesHehe/leetcode
/3/Majority Element.py
347
3.609375
4
# Input: [2,2,1,1,1,2,2] # Output: 2 from typing import List from collections import defaultdict class Solution: def majorityElement(self, nums: List[int]) -> int: d = defaultdict(int) for i in nums: d[i] += 1 if d[i] > len(nums) // 2: return i Solution()....
ab7e2e65f6006f72c7ded9e79f49c77c3d081346
CharlesHehe/leetcode
/2/Middle of the Linked List.py
358
3.765625
4
# Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def middleNode(self, head: ListNode) -> ListNode: a = b = head while b: if b.next is None: break b = b.next.next ...
619a30daf68d8a227370acc6b5d90ac157f564b9
CharlesHehe/leetcode
/Linked List/*Delete Node in a Linked List.py
722
3.859375
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def deleteNode(self, node: ListNode): """ :type node: ListNode :rtype: void Do not return anything, modify node in-place instead. """ ...
c2b86521677999b160ac97f005fd405ea8607bb0
CharlesHehe/leetcode
/Hash Table/Single Number Easy.py
1,097
3.890625
4
# Given a non-empty array of integers, every element appears twice except for one. # Find that single one. # # Your algorithm should have a linear runtime complexity. # Could you implement it without using extra memory? # # Example 1: # # Input: [2,2,1] # Output: 1 from typing import List from _collections import defau...
35932af0730adbf65cf065106ba03d2a62c191d1
Rajarajansama/PYTHON
/multiples.py
117
4.15625
4
#multiple of given number no=int(input('enter no: ')) i=int(input('enter no:')) while no<=i: print(no) no*=3
e5b28f4d5b958a4b675502ff928119b20d67f5d7
Rajarajansama/PYTHON
/transpose-matrix.py
330
3.859375
4
l = [['a','b','c'], ['d','e','f'], ['g','h','i'] ] print("before transposing matrix ") for i in range(len(l)): ll = l[i] for j in range(len(ll)): print(l[i][j], end=' ') print() print() print("After transposing matrix ") for i in range(len(l)): ll = l[i] for j in range(len(ll)): print(l[j][i], end=' ') ...
cfd8276cedbf35d4542948135e6c68c986d00c89
Coadiey/Python-Projects
/Python programs/PA7.py
2,214
4.15625
4
# Author: Coadiey Bryan # CLID: C00039405 # Course/Section: CMPS 150 – Section 003 # Assignment: PA7 # Date Assigned: Friday, November 17, 2017 # Date/Time Due: Wednesday, November 22, 2017 –- 11:55 pm #Description: This program is just a simple class setup that changes the output into a string based on the input...
f7b33dcf3871b1a37a4e50430127e86593ef949e
renzDef/holistic-Quiz
/question_service.py
4,855
3.765625
4
class Questions: def __init__(self,gestellteFragen): #Object von Questions init mit object(0) self.gestellteFragen = gestellteFragen def frage1(self): #Erste Frage usw.. print("Wie lange habe ich gebraucht mir diese Frage auszudenke...
7713164280f6733d072ad02e09bc19aa450e361c
SP18-Introduction-Computer-Science/map-and-lists-biren3008
/Assignment2.py
546
4.375
4
# List and Map Biren 3008 # Create a List number = [] number.append([1,2,3,'List','Map']) n = number[0] print("List : ") print(n) print("List Elements are") for listElem in n : print(listElem) # Create a Map myMap = {0 : "List", 1 : "Map", 2 : "Biren_3008"} print("Map Dictionary with Value :...
96672006f4ee0b8ce9cb023f0f14c9a5eb385b71
EmreTekinalp/PythonLibrary
/src/design_pattern/factory_pattern.py
1,791
4.1875
4
""" @author: Emre Tekinalp @contact: e.tekinalp@icloud.com @since: May 28th 2016 @brief: Example of the factory pattern. Unit tests to be found under: test/unit/test_factory_pattern.py """ from abc import abstractmethod class Connection(object): """Connection class.""" @abstractmethod ...
a922797ce23acb3f2efc7ed1b1a5c7a442b30929
hereticalcoral/Machine-Learning-Practice
/Numpy/Numpy函数例子.py
27,404
4.71875
5
#例子来源: https://www.tutorialspoint.com/numpy # minimum dimensions import numpy as np a = np.array([1, 2, 3,4,5], ndmin = 2) print a ##ndarray.shape and reshape :This array attribute returns a tuple consisting of array dimensions. It can also be used to resize the array. import numpy as np a = np.array([[1,2,3],[4...
10bd5e8f7018dd2f7a25e0202c68c05b21dd58aa
vismay94/Problem-Solving
/LeetCodePython/Easy/twoSum.py
546
3.875
4
# Given an array of integers, return indices of the two numbers such that they add up to a specific target. # You may assume that each input would have exactly one solution, and you may not use the same element twice. def twosum(target, values): dict = {} for i in range(len(values)): valuetofind = tar...
c41d1fe9eb09ae1356a9247e7fe9e94f1cd1b527
Raghavendra-Gali/CompetitiveProgramming
/Week1/Day5/Programs/rotationpoint.py
299
3.640625
4
def findrotationpoint(array): if len(array)==0: return elif len(array)==1: return 0 else: low,high=0,len(array)-1 while low<=high: mid=(low+high)//2 if array[mid]<array[mid-1] and array[mid]<array[mid+1]: return mid low=mid+1 if mid+1==high: return high return -1
54c4d04bacda003aa2ca1e5b971cb3904c5e22b2
Raghavendra-Gali/CompetitiveProgramming
/Week2/Day2/Programs/bracket_validator.py
1,409
3.875
4
import unittest def is_valid(code): # Determine if the input code is valid stack=[] for i in range(len(code)): if code[i]=="(" or code[i]=="{" or code[i]=="[": stack.append(code[i]) elif code[i]==")" or code[i]=="}" or code[i]=="]": if len(stack)>0: ...
66f0e50241bf515e33c48f5d543aa5b631f084be
Raghavendra-Gali/CompetitiveProgramming
/Week3/Exam/HammingDistance.py
511
3.5
4
def convertToBinary(integer): st = "{0:b}".format(integer) print("convertToBinary",st) return st def addZero(integer,n): # print("integer",n,integer) st = n*"0" st+=integer # print("addZero",st) return st if __name__ == '__main__': a = 1 b = 4 c,d="","" c=convertToBinary(a) d = convertToBinary(b) ...
368b33debeaf5fbfec24a6504b4eba9531403030
Bongio03/TPSIT
/Code/Code1.py
1,184
4.3125
4
''' Implementare i metodi enqueue() e dequeue()  e creare un programma che permetta all’utente di riempire una coda di numeri interi di lunghezza arbitraria. Successivamente testare la funzione dequeue per svuotare la coda. ''' def dequeue(queue): #Funzione per svuotare la coda return queu...
be59c4fd499ef9dc52c5139036b84c93069229bb
Polovnevya/python_algoritms
/Lesson_1/task_7.py
1,136
3.890625
4
""" По длинам трех отрезков, введенных пользователем, определить возможность существования треугольника, составленного из этих отрезков https://drive.google.com/file/d/1Ui2yipbPwl4C9ZbY4KEk6VSmB2YBMh-k/view?usp=sharing """ segment_1 = float(input('Введите длинну первого отрезка ')) segment_2 = float(input('Введите ...
839e28e2208e6df0aa33bb9766877cf3d2ba8131
ortizfer/DeepFind
/catkin_ws/src/deepfind_package/scripts/test_codes/ahrs_unit_test.py
965
3.59375
4
import unittest import time #variable declaration init_val = 0.0 avg_value = 0.0 l_values = [] current_angle = 0.0 def ahr(): # read from imu & save it to init_val for i in range(0, 10): # adds different values to the list l_values.append() for n in range(1, 10): avg_value = avg_v...
31b0456c397dbdc6d74139a932f582e3f854f00f
dancoe6/test-scripts
/main.py
467
3.515625
4
from powerOutage import * from api import * durationOff = eval(input("Off duration: ")) durationOn = eval(input("On duration: ")) cycles = eval(input("Cycles (0 will run indefinitely: ")) if(cycles == 0): print("Test will run indefinitely with ",durationOff," seconds on and",durationOn,"seconds off.") else: pr...
55289f09c34b7e4227cd3ed2682af21477107696
Alekzsss/chess
/chess_set.py
13,629
3.625
4
from chess_board import ChessBoard from piece import Pawn, Rook, Bishop, Knight, King, Queen class ChessSet: def __init__(self): self.board = ChessBoard(self) self.pieces = [Pawn(self, "white", item) for item in [i + "2" for i in "abcdefgh"]] self.pieces.extend([Pawn(self, "black", item) f...
f9ff6527ee3c680cefc70bb37a49ba2465005b51
kirushpeter/flask-udemy-tut
/python-level1/pypy.py
2,426
4.25
4
""" #numbers print("hello world") print(1/2) print(2**7) my_dogs = 2 a = 10 print(a) a = a + a print(a) puppies = 6 weight = 2 total = puppies * weight print(total) #strings print(len("hello")) #indexing mystring = "abcdefghij" print(mystring[-1]) print(mystring[0:7:2])#start is included start stop and ...
1174d892b292c785d96e91f0e727e9b269330e37
iAmNawa/learning-python
/numbers.py
2,331
3.5
4
print(2**3) # 2*2*2 - 8 print(2//4) # return integer rounded down - 0 print(5//4) # return integer rounded down - 1 print(6%4) # returns remainder - 2 # Math functions ceil(x) Returns the smallest integer greater than or equal to x. copysign(x, y) Returns x with the sign of y fabs(x) Returns the absolute value of x fa...
14f85d940a00a86ff60e3e1788d97756e7494ba2
Hossain-Shah/Project
/AI & ML/Word ladder.py
589
4
4
import numpy as np wordlist="hello how are you can you read this without punctuation do you think this is something what is the meaning of life".split() wordlist=[word for word in wordlist if len(word) == 3] wordlist=[word for word in wordlist if word[0].islower()] wordlist=[word for word in wordlist if word.isalph...
8780d68faec5133713c307f39ec6da18fa72899c
nirajbhatta24/My-first-project
/programming/area of rectangle.py
144
3.921875
4
l=float(input("Enter the lenth of rectangle")) b=float(input("Enter the breadth of rectangle")) area=l*b print("The area of rectangle is",area)
cee84c55e15fa76301393ee39e5a09c78929bdb0
gayeon111/study
/1월1일.py
199
3.546875
4
y=int(input("입력:")) sum=0 for x in range(1,y): if(x%4==0 and x%100!=0 or x%400==0): sum+= 365 else: sum+=354 print("y년의 1월 1일은", sum+1, "번째 날입니다.")
9f905390c9bb7cfdf7c8c59b7a1caa7dae8be615
derekkuo0727/I-256_Final_Project
/Divi/plot_forest_multioutput.py
4,437
3.65625
4
# import numpy as np # from sklearn.datasets import make_classification # from sklearn.ensemble import ExtraTreesClassifier # Build a classification task using 3 informative features # X, y = make_classification(n_samples=1000, # n_features=10, # n_informative=3, ...
4c75a5b66e3358d55f290590562872079509a934
willzhang05/random-scripts
/python/get_trivia.py
1,155
3.625
4
#!/usr/bin/python3 ## This script retrieves a set of trivia questions from opentdb.com. Used to generate trivia questions for a Hereford College trivia night. import requests import pprint import urllib API_URL="https://opentdb.com/api.php?amount=12&type=multiple&category=#&encode=url3986&difficulty=medium" #categorie...
45510428c4984ac3ff42c204393bce6e7372ea90
farahnazihah/DDP1-2019
/Lab1/challenge1.py
800
4.15625
4
import turtle turtle.speed(20) #drawing a circle turtle.color('yellow') turtle.begin_fill() turtle.circle(100) turtle.end_fill() turtle.penup() turtle.forward(40) turtle.left(90) turtle.forward(120) turtle.right(90) #drawing two eyes turtle.color('black') turtle.begin_fill() turtle.circle(10) tu...
b98e56a6e39592d972d6e9c82138df1c751962ec
farahnazihah/DDP1-2019
/Lab7/latihan16.py
400
3.703125
4
n_cat = int(input('Banyaknya kucing yang hadir: ')) all_cat = {} for i in range(n_cat): # mengelompokkan kucing berdasarkan angkatan temp = input().split(' ') name_cat, year_cat = temp if year_cat in all_cat: lst = all_cat[year_cat] lst.append(name_cat) all_cat[year_cat] = lst else: all_...
f012f769c432e89beb13bd910f98149215a169b5
farahnazihah/DDP1-2019
/Lab5/latihan14.py
857
3.71875
4
# membuka file namaFile = input("masukan nama file: ") f = open(namaFile, 'r') for baris in range(int(f.readline())): nama = str(f.readline()[:-1]) print("Nama : ", nama,) title = f.readline().title() print("Title : ", title, end='') _class = f.readline() print("Class : ", _class, end='') ...
eeb0f0366684a36245718065c8858f43f70736f7
danielstaal/project
/code/chips_exe.py
2,117
4.15625
4
''' Executable file Chips & Circuits Date: 26/05/2016 Daniel Staal This program allows the user to choose a print, netlist, search methods and a filename to output the result To execute this program: python chips_exe.py ''' import astar3D import netlists import time import sys if __name__ == "__main__": ...
bc942afc23dddae005fa3cbf050b9521f6b2fde8
wulfebw/muzero
/muzero/utils.py
429
3.671875
4
import numpy as np def categorical_sample(d): """Randomly sample a value from a discrete set based on provided probabilities. Args: d: A dictionary mapping choices to probabilities. Returns: One of the possible choices. """ choice_probs = list(d.items()) probs = [t[1] for...
ce7930492820f9aa452bacce0cb308c4ba56dbcc
AnubisAbydos/Final-Project
/BoardGame/BoardGame/player.py
4,439
3.765625
4
""" Project Name: BoardGame File Name: player.py Author: Lex Hall Last Updated: 7/29/19 Python Version: 3.6 """ from random import * import AIController import infoObjects class PlayerInfo(object): def __init__(self, color): self.isNPC = False self.isAlive = True self.color = color ...
44040175ec756cfc0ec6b62edc2edf5e3d3ec747
jamestiotio/esc
/cohort/week08/Fuzzing/calculator-grammar-fuzzing.py
2,003
3.609375
4
import secrets # Use a global limit to prevent an infinite loop and expanding forever GLOBAL_LIMIT, CURRENT_EXPANSION_LENGTH = 1000, 0 def fuzz_expr(): global GLOBAL_LIMIT, CURRENT_EXPANSION_LENGTH if CURRENT_EXPANSION_LENGTH < GLOBAL_LIMIT: return secrets.choice(["Expr + Term", "Expr - Term", "Term"...
918147298e4a3185bb729d99a771ef79f97f49ff
agucadiz/pro
/python/ejercicios/programacion_orientada_a_objetos/tienda/linea.py
886
3.9375
4
class Linea(): """ Clase Linea --- La clase linea representa una linea dentro de una factura, compuesta """ def __init__(self, articulo, cantidad): """Constructor de la clase Linea""" self.__articulo = articulo self.__cantidad = cantidad def __repr__(self): r...
b463baad9aadf9e826db34695528123fe3d0e74d
agucadiz/pro
/python/scripts/prog_estructurada/palindromo.py
573
3.765625
4
cadena = 'A ti no, bonita' def palindromo(s): # Descomponemos la frase con str.split() palabras = s.split() # Eliminamos puntuaciones con str.strip() lista_plana = [] for p in palabras: q = p.strip('.').strip(',') lista_plana.append(q) frase_plana = ''.join(lista_plana) ...
618b44461f00b4e2037233bd7cae42343dbd96ea
agucadiz/pro
/python/scripts/prog_estructurada/pasa_pasa.py
403
3.578125
4
def pasa_pasa(num1, num2): nums = [num1, num2] for i in range(2): # convertimos a cadena nums[i] = str(nums[i]) # separamos los digitos y creamos una lista nums[i] =' '.join(nums[i]).split() nums[1].append(nums[0].pop(-1)) # volvemos a unir la lista y la convertimos a ente...
e9f4a45b57e8c4e1466f6a517d9d954312eeb3fe
agucadiz/pro
/python/scripts/prog_funcional_II/recursivas/range_suma.py
198
3.5
4
""" # range_suma(r: range) -> int función que calcula la suma de los elementos de un rango """ range_suma = lambda r: 0 if r == range(0, 0) else \ r[0] + range_suma(r[1:])
e85e97b39a6fe4c623d7ba39f5978a9264460c50
abdoukercode/projects
/python/csv/google_stock.py
1,525
3.734375
4
import csv from datetime import datetime #print(dir(csv)) path = "/home/abdou/project/python/csv/Google Stock Market Data - google_stock_data.csv" # open file file = open(path, newline='') #parse data in the file reader = csv.reader(file) # extract first line which does not contain data header = next(reader) # read t...
7fb7818ea012b783862f6455ff4019ddf7db6989
abdoukercode/projects
/python/simple-tricks/context-manager.py
435
3.734375
4
from sqlite3 import connect with connect('test.db') as conn: cur = conn.cursor() cur.execute('create table thepoints(x int, y int)') cur.execute('insert into thepoints (x,y) values(1,1)') cur.execute('insert into thepoints (x,y) values(1,2)') cur.execute('insert into thepoints (x,y) values(2,1)') ...
1f32a7062a40bc6e14c6c0f7ba17d065746feb7c
josh-perry/ProjectEuler
/problem 1.py
439
4.21875
4
# Problem 1: Multiples of 3 and 5 # If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. # The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000. def euler_1(): total = 0 for i in range(1, 1000): if i % 3 == 0 or i % 5 == ...
afeb13048b41c04911346a8ac3fe2e3aea227f73
tubackkhoa/opencv-tensorflow-all
/src/AlphaBlending/alphaBlend.py
1,278
3.53125
4
# Copyright 2017 by Sunita Nayak <nayak.sunita@gmail.com> import cv2 import click import os @click.command() @click.option('--imagepath', prompt="image path", default='./', help='The image path.') def main(imagepath): """Alpha blending.""" # Read the foreground image with alpha channel f...
7d8574643fb59d2ad32afe9ff15c59a8c50a2b34
Pablomos2501/ejercios_logica
/años.py
1,724
3.703125
4
from tkinter import * from tkinter import messagebox def comparar(): diferencia = fecha1.get() - fecha2.get() if diferencia == 1: messagebox.showinfo("",f"Desde el año {fecha2.get()} ha pasado 1 año.") elif diferencia > 1: messagebox.showinfo("",f"Desde el año {fecha2.get()} han pasado {fe...
8fe814c13b59181b164266424c40a1c2f9c83175
matthewslouismarie/fanalyzer
/core/checkers.py
334
3.5
4
from os import walk from os.path import split def is_folder_name_valid(path: str) -> bool: """Verify rule 1.""" (head, tail) = split(path) return tail == 'fnc3' def does_folder_only_contain_files(path: str) -> bool: """Verify rule 2.""" (dirpath, dirnames, dirfiles) = next(walk(path)) return d...
2e7dd4bfc582cb713c24e836e9484cb930fb9211
alex-knaub/math-adventures-python
/processing/polygon/polygon.pyde
299
3.5
4
def setup(): size(600, 600) def draw(): translate(width/2, height/2) polygon(5,100) def polygon(sides, sz): beginShape() step = radians(360/sides) for i in range(sides): vertex(sz*cos(step*i), sz*sin(step*i)) endShape(CLOSE)
b98043ed1614fd129922b75945bf4fd21b2f899d
alex-knaub/math-adventures-python
/src/gauss.py
1,526
3.640625
4
def _gauss(A): m = len(A) n = len(A[0]) for j,row in enumerate(A): #diagonal term to be 1 #by dividing row by diagonal term if row[j] != 0: divisor = row[j] for i, term in enumerate(row): row[i] = term / divisor #add the other ro...
2fef7326d1232e998077d7518b823980e7570f3e
WeiShiwei/machine-learning-notes
/algorithms/chapter1-string/alg2-单词拆分.py
1,617
3.609375
4
# 单词拆分 # 给定一个非空字符串 s 和一个包含非空单词列表的字典 wordDict,判定 s 是否可以被空格拆分为一个或多个在字典中出现的单词。 # 说明: # 拆分时可以重复使用字典中的单词。 # 你可以假设字典中没有重复的单词。 # 示例 1: # 输入: s = "leetcode", wordDict = ["leet", "code"] # 输出: true # 解释: 返回 true 因为 "leetcode" 可以被拆分成 "leet code"。 # 示例 2: # 输入: s = "applepenapple", wordDict = ["apple", "pen"] # 输出: true # 解...
e380955b464d3f3611536c43f7ca84b534dc3f82
vsquareg/Sentry
/overlay.py
2,563
3.5
4
import cv2 # Not actually necessary if you just want to create an image. import numpy as np # # def overlay_image_alpha(img, img_overlay, pos, alpha_mask): # """Overlay img_overlay on top of img at the position specified by # pos and blend using alpha_mask. # # Alpha mask must contain values within the ran...
1b6db1cea4d09bf51be80fd9561238ba17908ef7
arunabh15091989/fsdse-python-assignment-17
/build.py
292
3.515625
4
import operator def solution_asc(dic): ''' Enter your code here ''' # return sorted(dic.items(), reverse=True, key= lambda x:x[1]) return sorted(dic.items()) def solution_desc(dic): ''' Enter your code here ''' return sorted(dic.items(), reverse = True)
8a9a35ef7343de850e1c88db258d9dd84b9a5930
jacholt/ud036_StarterCode
/media.py
2,082
3.609375
4
import webbrowser import httplib import json class Movie(): def __init__(self,movie_title): """ Definition of films, based on their name. Creation of film objects, based on thier name. Populating title, description, poster art and video link. The class initially returns video in...
e9bf9202428c1b7114b3a6e43c9a9bf5507441ed
Wolokin/Text-Algorithms
/Lab4/modules/lcs.py
1,682
3.671875
4
from enum import Enum class Step(Enum): MATCH = 0 LEFT = 1 UP = 2 def lcs(s1, s2): n = len(s1) m = len(s2) length = [[0 for i in range(m + 1)] for j in range(n + 1)] path = [[0 for i in range(m + 1)] for j in range(n + 1)] for i in range(n + 1): length[i][0] = 0 path[...
37f5244c546c54f5e22c0657fd17e1b6525c1f62
DevAnuragGarg/Python-Learning-Basics
/basics01/esacpechar.py
537
4.09375
4
split_string = "This string has been \nsplit over\nseveral\nlines" print(split_string) tabbed_string = "1\t2\t3\t" print(tabbed_string) print('Hello what\'s the situation like. He\'s is not responding') print("Hello what's the situation like. He's is not responding") print("""Hello what's the situation like. He's is ...
0aefd308d1dc483990e5e2d4609d5f77b096b9cc
DevAnuragGarg/Python-Learning-Basics
/flowControl02/challenge.py
294
3.78125
4
options = """Please choose your option from the list below: 1.\tLearn python 2.\tLearn java 3.\tGo swimming 4.\tHave dinner 5.\tGo to bed 0.\tExit""" while True: choice = input() if choice == "0": break elif choice in "12345": print("You chose {}".format(choice))
c8be9844b8199db60b8ef8def650ffe00ddaa820
DevAnuragGarg/Python-Learning-Basics
/listsTuples03/outliers.py
1,050
3.6875
4
# deleting the value from the list data = [4, 5, 105, 110, 146, 159, 163, 179, 183, 200, 256, 323, 435] print(data) # deleting the items first 2 # del data[0:2] print(data) # this will not do anything as it is out of scope del data[16:] print(data) min_valid = 100 max_valid = 200 # for index, value in enumerate(dat...
42ed0f897f77b816402e321d7398f5f1e2ccdb8d
jiyglee/Python
/Ch04/p85.py
164
4.28125
4
""" chapter04.lecture.step02_list.py """ # (1) 단일 list 예 lst = [1, 2, 3, 4, 5] print(lst) print( type(lst)) for i in lst : print(lst[:i]) # i전까지
df0d57c8c97594478d3e02d9163f45303435483f
christianr98/Python-code
/aplicacion1.py
2,702
3.515625
4
#|||||||||||||||||Implementación de #|||||||||||||||||||Árbol Binario #||||||||||||||||||||en Python3 class ArbolBin: def __init__(self,valor=None, izq=None, der=None): if valor is None: self.valor=None else: self.valor=valor self.izq=izq self.der=der ...
9bd527abfaad89101c712676bfa95882319cae37
knishioka/monday-stats
/monday_stats/board.py
2,003
3.59375
4
import pandas as pd from .group import Group from .item import Item class Board: """Monday board class.""" def __init__(self, board_id, board_name, items=[]): """Initialize board. Args: board_id (str): board id. board_name (str): board name items (list): ...
4a7216470e990b279eff91c0d8c14b6fc8bf8726
brworkit/brworkit-tools
/brworkittools/utils/email_validator.py
236
3.703125
4
import re def is_valid_email(email, regex): if email is None: return False if not isinstance(email, str): return False if email.strip() == "": return False return re.search(regex, email.lower())
88ad3d2f0ac2ef047dbc57c8c174e37ba93c5549
wking/BEXML
/libBEXML/DictViewOfList.py
2,075
3.75
4
# DictViewOfList # Provide a dictionary view of a list # (C) 2012 Niall Douglas http://www.nedproductions.biz/ # Created: April 2012 from collections import MutableMapping, Iterator class DictViewOfList(MutableMapping): """Provides a mutable dictionary view of a two-tuple list. This lets you return a...
80d42f241d0d7c632eb037df4d99aa3d5f5da0f0
cortezmb/Phonebook-App
/myfile.py
428
3.734375
4
import pickle phonebook_dict = {'Alice': '(703) 493-1834', 'Bob': '(857) 384-1234', 'Elizabeth': '(484) 584-2923'} # you need to load data into dictionary before asking what user wants to do with open('phonebook.pickle', 'wb') as fh: #Not sure why I used dump function instead of load. Need to ask DiR pickle.d...
fadbc99789364f86cb15fc9831294d18b8aabf7b
dobryi/Algorithms
/sorting/shell_sort.py
948
3.75
4
import random def shell_sort(seq): sedgewick, n = [], len(seq) for i in range(n): if i % 2 == 0: sedgewick.append(9 * pow(2, i) - 9 * pow(2, i // 2) + 1) else: sedgewick.append(8 * pow(2, i) - 6 * pow(2, (i + 1) // 2) + 1) if 3 * sedgewick[-1] > n: b...
c681ffce2e50a5c78409704c6abce55bc40bcb85
dobryi/Algorithms
/sorting/bubble_sort.py
483
3.703125
4
import random def bubble_sort(seq): swapped, n = True, len(seq) while swapped: swapped = False for i in range(n - 1): if seq[i] > seq[i + 1]: seq[i], seq[i + 1] = seq[i + 1], seq[i] swapped = True n -= 1 return seq test_seq = [random.ran...
85ac5d3cb9b7986341d6e91da578718697e88828
hzhu3142/Leetcode
/code/324.py
1,933
3.703125
4
class Solution: def wiggleSort(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ nums.sort() n = (len(nums)+1)//2 nums[::2],nums[1::2] = nums[:n][::-1], nums[n:][::-1] #quick selections + virtual ...
b39d4b5d7c0df9a15e3cb97158a3d4b6d3c956d5
hzhu3142/Leetcode
/code/99.py
1,374
3.71875
4
# Method 1 recursion class Solution: def recoverTree(self, root: TreeNode) -> None: """ Do not return anything, modify root in-place instead. """ def inorder(root): if not root: return nonlocal x, y, pre inorder(root.left) ...
64d583aad994ccc9911b74661c2e44c19f45ee21
anildoferreira/CursoPython-PyCharm
/exercicios/aula16.py
574
4
4
lanche = ('Hamburguer', 'Suco', 'Pizza', 'Pudim') '''print(lanche) print(sorted(lanche)) for fila in lanche: print(f'Eu vou comer {fila}') print('Comi pra caramba!')''' for cont in range(0, len(lanche)): print(f'Eu vou comer {lanche[cont]} na posição {cont}') print('Comi pra caramba!') '''for pos, fila in en...
72f3706a8a264a684947e9c0531a3540b6c4d387
anildoferreira/CursoPython-PyCharm
/exercicios/aula7-ex015.py
202
3.515625
4
kmRodados = float(input('Quantos km vc rodou? ')) diasUsados = int(input('Durante quantos dias? ')) pagar = kmRodados * 0.15 + diasUsados * 60 print('O valor a se pagar é de R$ {:.2f}'.format(pagar))
439e51d4feeb8198a794448e2587171340e7c17d
anildoferreira/CursoPython-PyCharm
/exercicios/aula12-ex040.py
365
3.90625
4
nota1 = float(input('Digite sua primeira nota: ')) nota2 = float(input('Digite sua segunda nota: ')) media = (nota1 + nota2) / 2 print('\033[7mA primeira NOTA sendo {}, e a SEGUNDA sendo {}, a média do aluno será {}\033[m'.format(nota1, nota2, media)) if media < 5: print('REPROVADO') elif media >= 7: print('AP...
3f925fff4944188c7cb5bbe649ebdda6ad9eea64
anildoferreira/CursoPython-PyCharm
/exercicios/aula10-ex029.py
281
3.796875
4
velocidade = float(input('Lendo a velocidade do carro: ')) if velocidade > 80: print('Você foi multado') limite = 80 multa = (velocidade - limite) valorMulta = 7 * multa print('O valor da sua multa é de {}'.format(valorMulta)) print('Dirija com segurança!')
0b6c9dbec3913fdad860b47df5d0c21016c3d5ff
anildoferreira/CursoPython-PyCharm
/exercicios/aula16-ex076.py
450
3.546875
4
listagem = ('Borracha', 1.75, 'Lápis', 1.00, 'Caderno', 10.00, 'Apontador', 2.00, 'Estojo', 5.00, 'Caneta', 2.50, 'Livros', 99.00) print('-=' * 20) print(f'{"LISTAGEM DE PRODUTOS":^40}') print('-=' * 20) for pos in range(0, len(listagem)): if ...
383e0e12fa3a32996e5e00646650643532077fa7
anildoferreira/CursoPython-PyCharm
/exercicios/aula12.py
225
4.0625
4
nome = str(input('Digite o seu nome: ')) if nome == 'ANILDO': print('Eu te encontrei :)') elif nome in 'Pedro Paulo Bruno': print('Seu nome é bem popular!') else: print("{}, não é quem eu estou procurando!".format(nome))
384aadf17828c4532839b76f91a640e26fae7917
anildoferreira/CursoPython-PyCharm
/exercicios/aula9-ex026.py
282
3.890625
4
frase = str(input('Digite a sua frase: ')).strip().upper() print('A letra (a) aparece {} vezes na sua frase'.format(frase.count('A'))) print('A letra (a) aparece na posição {}'.format(frase.find('A')+1)) print('A última letra aparece na posição {}'.format(frase.rfind('A')+1))
18e849256f760e78ad0680125d7ebc2350f5fbdc
anildoferreira/CursoPython-PyCharm
/exercicios/aula13-ex055.py
436
3.84375
4
print('░' * 21) print('CALCULANDO < e > PESO') print('░' * 21) maior = 0 menor = 0 for p in range(1, 6): peso = float(input('Qual é o peso da {}ª pessoa? '.format(p))) if p == 1: maior = peso menor = peso else: if peso > maior: maior = peso if peso < menor: ...
5fb0d73c5d2ebbaf55cf0bb8d3c5dc792415efec
anildoferreira/CursoPython-PyCharm
/exercicios/aula13-ex046.py
258
3.71875
4
from time import sleep print('-=' * 15) print('\033[7mCONTAGEM REGRESSIVA PARA FOGOS\033[m') print('-=' * 15) n = int(input('Digite um número de 1 à 10 para contagem Regressiva: ')) for c in range(n, -1, -1): print(c) sleep(1) print('pow! pow!')
7f38aca703e5e5f2a0cba5e43682ebbafe2634dc
anildoferreira/CursoPython-PyCharm
/exercicios/aula17-ex082.py
558
3.65625
4
lista = [] listaPar = [] listaImpar = [] continuar = ' ' c = n = 0 while continuar not in 'Nn': c += 1 n = int(input(f'Digite o {c}º número: ')) lista.append(n) if 0 == n % 2: listaPar.append(n) else: listaImpar.append(n) while True: continuar = str(input('Quer continuar?...
dd53818f5b9d65a254f497f40284e4f008d28b75
y-akinobu/AOJ_to_Kotonoha
/trans_ITP1_8_A/mxg7y_ITP1_8_A_kotonoha.py
859
3.546875
4
[#Document [# '! python3']][#Document [# 'toggling_cases.py']] # 入力された文字列をxとする x = input() # ''をrstとする rst = '' # xの各要素を順にcとして、繰り返す for c in x : # cの全てが英大文字のとき、 if c.isupper() : # ([[#Name 'rst'], [#MethodExpr recv: [#Name 'c']name: [#Name 'lower']params: [#Arguments '']]],) [[#Name 'rst'], [#MethodExpr re...
b90d703cc204c6b578ebb21a6d66be90687db300
y-akinobu/AOJ_to_Kotonoha
/trans_NTL_1_C/kinako_shinonome_NTL_1_C_kotonoha.py
597
3.5625
4
# mathモジュールを用いる import math # 入力された文字列の整数値をnとする n = int(input()) # 'map(整数,{{入力された文字列を空白で分割した列}})のリストをaとする a = list(map(int,input().split())) # aの最初値をlcmとする lcm = a[0] # '1からn未満までの数列の各要素を順にiとして、繰り返す for i in range(1,n) : # lcmをxとする x = lcm # a(i)をyとする y = a[i] # ({{xにyを掛けた値}})の組をmath.gcd(x,y)で割った商をlcmとする l...
fb5d3d1479f41c9bc81e3af22b632b2198c4d1e3
y-akinobu/AOJ_to_Kotonoha
/trans_NTL_1_C/kyk_hm_99_NTL_1_C_kotonoha.py
570
3.65625
4
# fractionsモジュールを用いる import fractions # 入力された文字列の整数値をNとする N = int(input()) # 'map(整数,{{入力された文字列を空白で分割した列}})のリストをdataとする data = list(map(int,input().split())) # dataの最初値をxとする x = data[0] # '1からN未満までの数列の各要素を順にiとして、繰り返す for i in range(1, N) : # xにdata(i)を掛けた値をfractions.gcd(x, data[i])で割った商をxとする x = x * data[i] // fra...
fff74ecc5d38b65159f30792a9ea8b75225c0f6f
y-akinobu/AOJ_to_Kotonoha
/trans_ITP1_8_A/kyuna_ITP1_8_A_kotonoha.py
264
3.75
4
# {{入力された文字列の各要素をcとし、(c.upper()とc.lower())からなる列({{cの全てが英大文字かどうか}})の列}}を文字列''で連結した文字列を出力する print(''.join([c.upper(), c.lower()][c.isupper()] for c in input()))
1c0cdb43749fecd83a51ed495989fe33326f155a
y-akinobu/AOJ_to_Kotonoha
/trans_ITP1_8_A/yreb_ITP1_8_A_kotonoha.py
197
3.53125
4
# 入力された文字列をLとする L = input() # Lの英大文字を英小文字、英小文字を英大文字に変換した文字列をMとする M = L.swapcase() # Mを出力する print(M)
3c2cba63109fef2deb29c9fbd408306e17de763d
y-akinobu/AOJ_to_Kotonoha
/trans_ALDS1_1_B/aaa119_ALDS1_1_B_kotonoha.py
439
3.828125
4
[#Document [# 'coding: utf-8']][#Document [# '77']] # map(整数,入力された文字列を空白で分割した列)を展開し順にxとyとする x,y = map(int,input().split()) # xがyより小さいとき、 if x<y : # xとyを入れ替える x, y = y, x # xをyで割った余りが0と等しくない間、繰り返す while x%y != 0 : # yとxをyで割った余りをxとyとする x,y = y,x%y # yを出力する print(y)
7a5c12ae0f16c8bde151007f076f7ddbee94d1fb
y-akinobu/AOJ_to_Kotonoha
/trans_ITP1_8_A/yoheikikuta_ITP1_8_A_kotonoha.py
454
3.65625
4
# 識別子が"__main__"のとき、 if __name__ == "__main__" : # 入力された文字列をinput_strとする input_str = input() # ({{{{sの全てが英小文字の}}とき{{sを英大文字に変換した文字列}}、そうでなければ{{input_strの各要素をsとし、s.lower() の列}}}})からなる列を文字列""で連結した文字列を出力する print("".join([s.upper() if s.islower() else s.lower() for s in input_str]))
ff08d720700dcb04d897e49ddc11e2b16d33466d
y-akinobu/AOJ_to_Kotonoha
/trans_NTL_1_C/momiji6_NTL_1_C_kotonoha.py
865
3.5625
4
# 関数gを[#FuncParam [#ParamDecl name: [#Name 'a']][#ParamDecl name: [#Name 'b']]]のパラメータを持つように定義する def g (a, b) : # bの間、繰り返す while b : # bとaをbで割った余りをaとbとする a, b = b, a%b # aを関数出力とする return a # 入力された文字列の整数値をnとする n = int(input()) # 'map(整数,{{入力された文字列を空白で分割した列}})のリストをaとする a = list(map(int, input().split())) ...
70bd0d45a3cb2f3dec689684c8ebbe1e4a690b12
y-akinobu/AOJ_to_Kotonoha
/trans_ALDS1_1_B/y1721_ALDS1_1_B_kotonoha.py
1,142
3.703125
4
# 関数gcdを[#FuncParam [#ParamDecl name: [#Name 'a']][#ParamDecl name: [#Name 'b']]]のパラメータを持つように定義する def gcd (a, b) : # [#MultiString '"calculate the greatest common divisor of a, b\n\n >>> gcd(54, 20)\n 2\n >>> gcd(147, 105)\n 21\n >>> gcd(100000002, 39273000)\n 114\n "'] "calculate the greatest ...
7b179f0d4d9d94c623cfe0f755e46472d8eba22e
y-akinobu/AOJ_to_Kotonoha
/trans_ALDS1_1_B/htkb_ALDS1_1_B_kotonoha.py
876
3.671875
4
# 関数gdcを[#FuncParam [#ParamDecl name: [#Name 'a']][#ParamDecl name: [#Name 'b']]]のパラメータを持つように定義する def gdc (a,b) :[#Document [# 'print("%d, %d"%(a,b))']] # aとbの最小値が0のとき、 if min(a,b) == 0 : # aを関数出力とする return a # () else :[#Else [#Block [#Return expr: [#ApplyExpr name: [#Name 'gdc']params: [#Arguments [#A...
374a83db53e9f1204dcdd3fd01439533c4e897a9
normanorteg/ICA-Python
/Marioscappini/begin/main.py
433
3.546875
4
from tkinter import * root = Tk(); topFrame = Frame(root) topFrame.pack() bottomFrame = Frame(root) bottomFrame.pack(side=BOTTOM) bottom1 = Button(topFrame,text="Buttom",fg="red") bottom3 = Button(topFrame,text="Buttom",fg="red") bottom4 = Button(topFrame,text="Buttom",fg="red") bottom2 = Button(bottomFrame,text="...
4eff39f917896385964cd8b7a0cf95a4313ff2ac
khoipn1504/Practices
/Pycharm_edu/Rock-paper-scissors/special_way.py
1,241
3.96875
4
import random user_name = input('Enter your name: ') print('Hello, {}'.format(user_name)) option = input().split(',') if option == ['']: option = ['rock', 'scissors', 'paper'] rule = ('rock', 'fire', 'scissors', 'snake', 'human', 'tree', 'wolf', 'sponge', 'paper', 'air', 'water', 'dragon', 'devil', 'ligh...
1412cbae4b163d0b4644e7708eccdfffa9ade4cb
khoipn1504/Practices
/Pycharm_edu/Hang Man/p2.py
157
3.9375
4
print("H A N G M A N") question = "python" ans = input("Guess the word: ") if ans == question: print("You survived!") else: print("You are hanged!")
31ad8bc8bc8d6d31094ab97cb1582d78cbb8363b
khoipn1504/Practices
/Data Structures/Sorting and Selection/InsertSort.py
282
3.953125
4
def insertSort(inputList): for i in range(1, len(inputList)): while i > 0 and inputList[i] < inputList[i-1]: inputList[i], inputList[i-1] = inputList[i-1], inputList[i] i -= 1 return inputList print(insertSort([1, 4, 2, 3, 9, 8, 7, 6, 5]))
5f046618b7c307efab1b8c6ccbafe06a4afc4e93
khoipn1504/Practices
/Data Structures/Sorting and Selection/MergeSort.py
678
4.125
4
def merge(S1, S2, S): # merge 2 sorted lists S1 and S2 into properly list S i = j = 0 while i+j < len(S): if j == len(S2) or (i < len(S1) and S1[i] < S2[j]): S[i+j] = S1[i] # copy ith element of S1 as next item of S i += 1 else: S[i+j] = S2[j] ...
185c6d7c2c6c20e460475d3ec178449fbc378db8
aditeyabaral/The-Amateur-Scientist-2019
/Enigma/Rounds/Caesar.py
218
3.984375
4
plain = input("Enter plaintext : ").upper() n = int(input("Enter shift : ")) cipher = '' temp = plain.split() for i in temp: for j in i: cipher+=chr((ord(j) + n-65) % 26 + 65) cipher+=' ' print(cipher)
d29ecf48e49fbb22ecde81b20a1602e278cd43aa
chrishorras/chrishorras.github.io
/HorrasChristopher_hw2.py
10,962
4.34375
4
# README: # * Edit this file where noted to complete exercises. # * DO NOT change function names or your code will not pass test cases. # * Output must match the reference solution's output EXACTLY, examples of # reference solution output will be provided throughout the document. # Exercise 2-6 # PROMPT(S) (Exam...
efc18652465e1ee03361604ace872f777e282482
hhe0/Leetcode
/Easy/0400-0499/0496/python/Solution.py
643
3.5
4
class Solution: def nextGreaterElement(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: List[int] """ res = [] for num in nums1: index = nums2.index(num) + 1 while index < len(nums2): if n...
f48e542fca628f89f6f413360073755db1787076
hhe0/Leetcode
/Easy/0001-0099/0066/Solution.py
456
3.625
4
class Solution: def plusOne(self, digits): """ :type digits: List[int] :rtype: List[int] """ i = 0 num = 0 while i < len(digits): num = num * 10 + digits[i] i = i + 1 numstr = str(num+1) numlist = [] for numchar ...
fe5d3ac6b0adc59f55c367c06a9e6eb795bdf6ff
hhe0/Leetcode
/Easy/0800-0899/0896/python/Solution.py
826
3.53125
4
class Solution: def isMonotonic(self, A): """ :type A: List[int] :rtype: bool """ if not A: return False if len(A) == 1: return True increment = False flag = False for i in range(1, len(A)): if not flag and ...
b0fd34abea792b50ceb6e80ab6a6cf6b12bb333e
hhe0/Leetcode
/Easy/0001-0099/0014/python/Solution.py
710
3.625
4
class Solution: def longestCommonPrefix(self, strs): """ :type strs: List[str] :rtype: str """ if not strs: return '' common = strs[0] for i in range(1, len(strs)): common = self.getCommonStr(common, strs[i]) if not common:...