blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
499d826186d1026478681793d9ff45a314e66be7
Sedaca/Curso-Phyton
/Exercicio5.py
385
3.9375
4
5+3*2 5**2 9**2 81**(1/2) 14//2 14%2 nome = input('Qual o seu nome?') print('Prazer em te conhecer, {}!'.format(nome)) print('Prazer em te conhecer, {:30}!'.format(nome)) print('Prazer em te conhecer, {:>30}!'.format(nome)) print('Prazer em te conhecer, {:<30}!'.format(nome)) print('Prazer em te conhecer, {:^30}!'.for...
87c0a0ccdd61e55c7bb0e76debcfb3fbba5590b0
JoshuaYang-Taiwan/CodeFights
/Interview Practice/Arrays/isCryptSolution.py
379
3.71875
4
def isCryptSolution(crypt, solution): d = dict(solution) a = "".join([d[w] for w in crypt[0]]) b = "".join([d[w] for w in crypt[1]]) c = "".join([d[w] for w in crypt[2]]) notLeadingZero = lambda numStr : False if len(numStr) > 1 and numStr[0] is "0" else True return notLeadingZero(a) and notLead...
d5d7e8ba81351974ee2af375f342dc52495fb329
serdarsari/Python
/Üçgen veya Dörtgenin Özel Şekilliğini Kontrol Eden Program/geometriksekil.py
1,132
3.6875
4
print(""" **************************** Üçgen veya Dörtgenin Şeklini Bulan Program **************************** Üçgenin tipini hesaplamak için 1'e basın Dikdörtgenin tipini hesaplamak için 2'ye basın """) girdi=input("Seçin yapın : ") if girdi =="1": x=int(input("1.Kenarı girin : ")) y=int(input("2.Kenarı giri...
ef02972525e5ba222115857a01be0133591898f7
gaojccn/python_study
/2-baseVariable.py
1,776
4.34375
4
#!/usr/bin/python # -*- coding: utf-8 -*- # Python的注释是 #打头 (单行注释) # 1.基本类型变量 counter = 100 # 整型变量 miles = 1000.0 # 浮点型变量 name = "wonderful" # 字符串 a, b, c = 1, 2, 3 # 多个变量一起赋值 print("整型变量counter=", counter) print('浮点型变量 miles=', miles) print('字符串 name=', name) print('把miles转为整型int =', int(miles)) # int()是类型转换 p...
98236d2174d716b37229cf13d1b8152cd1b6a457
wxzoro1/MyPractise
/python/liaoscode/测试.py
611
3.78125
4
'''from hello import Hello h = Hello() h.hello() print(type(Hello)) print(type(h)) def fn(self, name='world'): print('Hello,%s.'%name) Hello = type('Hello',(object,),dict(hello=fn)) #type 创建Hello class 1.class名2.支持多重继承3.函数绑定 h = Hello h.hello() print(tyoe(Hello)) print(type(h))''' class ListMetaclass(type): ...
29c0e2f7f4625c401b7567b92222c17bc8fa2e74
Cheget/python
/1stLession/4.py
536
3.734375
4
inputed_value = input('Введите число: ') print(f'Вы ввели: {inputed_value}') while inputed_value.isdigit()==False: inputed_value = input('Строка должна содержать только цифры. Введите число: ') numbers = list(inputed_value) i = 0 result = numbers[i] while i < len(numbers): if numbers[i] > result: ...
73049169270e855b2eeb8ff7ef0334bd05bd0cdf
JoseManuelCruzSanchez/DAW-PHYTON
/ej_9.py
2,650
3.921875
4
#Escribir una clase Python que permita las siguientes funciones: (10 puntos) #• Añadir un número a la lista #• Vaciar la lista de números #• Ordenar de menor a mayor #• Ordenar de mayor a menor #• Calcular la media de la lista de números #• Calcular mediana de la lista de números #• Obtener una lista de números ...
a165308ec4d2f77c02c56d1ad9aa3fccbd530fca
tamyrds/Exercicios-Python
/Mundo_2_Python/Decisao/exerc05.py
141
3.703125
4
F = float(input('Qual é a temperatura em graus Fahrenheit ')) conversor = 5 * ((F-32) / 9) print(f'A temperatura em celcius é {conversor}')
e4f5a2ea9f14117ab7c27790cd696a7fdf6e5355
hakan7AA/MacGyver3
/macgyver.py
10,136
3.71875
4
"""Pygame, methods.py and classes.py importation.""" import pygame from pygame.locals import * from classes import * from methods import * # Initialization of pygame pygame.init() # Initialization window and graphic library window = pygame.display.set_mode((450, 450)) background = pygame.image.load('ressource/backgr...
fb1782ef96704f9bbcbb7ed67d54f7257eacfe7a
harrycampaz/reviewing-python
/Basic/condicionales.py
1,151
4.125
4
#If sencillo print("Inicia la Super App") nota_alumno = input("Introduce la nota: ") def check(nota): valoracion = "Aprobado" if nota < 5: valoracion = "Reprobado" return valoracion print(check(int(nota_alumno))) # if else print("verificacion if else") edad = int(input("Introduce la edad: ")) ...
9a741de1e3118bd5ba28db565c904130c0412d8d
DipalModi18/PythonTutorial
/TCP/NetworkingServer.py
747
3.71875
4
# Sockets are the endpoints of a bidirectional communications channel. # Sockets may communicate within a process, between processes on the same machine, # or between processes on different continents. import socket serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) host = socket.gethos...
a734ce65a209d2cec7f2da883c97a8666b98e2d6
varunhari/turtle-
/demo.py
323
3.59375
4
from turtle import * setup() t1= Turtle() colors =["red","blue", "yellow","green","purple","orange"] import random t1.up() t1.goto(-200,0) t1.down() t1.width(5) t1.hideturtle() t1.speed(0) for i in range(9001): colorchoice=random.choice(colors) t1.color(colorchoice) t1.forward(400) t1.right(187) ...
ebf643b2b3d7c1030b4248bc887b46f6f29f19be
xingguangmicai/CompSci
/6.001x Introduction to Computer Science and Programming using Python 1/Pset2.py
851
4.21875
4
b= 'bob' x=0 #setuping up the search to look at the letters index for a string the size of bob in s y= 3 #'''''''' counterforbob=0 #intalizing counter bob found numberofduds = 0 #intalizing counter for duds for string in s: while (x<=len(s)): #test for loop to go through entirety of letters contained in string ...
62029cbaf9658915afb102c375463a4c5026a9db
ydkulks/ML
/Regressions/PLR.py
1,463
3.78125
4
# Polynomial Linear Regression import random import matplotlib as mp mp.use('TkAgg') import matplotlib.pyplot as plt import numpy as np def main(): x=[1.41, 2.21, 3.06, 7.13, 11.25, 13.06, 14.31, 15.28] y=[2.39, 5.90, 10.29, 16.24, 14.29, 10.50, 6.23, 2.87] #x=[] #y=[] #x,y=data(x,y) print...
80407c4a82c4921f6a06b23f334f0b92981e8e2e
tylertamalunas/MoshYoutube
/Mosh-youtube/Lessons/tuples.py
204
3.734375
4
# tuples are like lists, but you cannot change them at all numbers = (1, 2, 3) print(numbers[0]) # below gives error numbers[0] = 10 # tuples are better if you do not want to accidentally change a list
bbf36a28adcc59d6a777174cbf726046f074a036
JulienBouchardIT/Pi-Car
/motor_control.py
1,137
3.5625
4
import RPi.GPIO as GPIO from time import sleep in1 = 24 in2 = 23 en = 25 pause = 1 duty = 100 # 12v to 6v; Duty cycle, see: https://lastminuteengineers.com/l298n-dc-stepper-driver-arduino-tutorial/ pause_demo = 1 GPIO.cleanup() GPIO.setmode(GPIO.BCM) GPIO.setup(in1, GPIO.OUT) GPIO.setup(in2, GPIO.OUT) GPIO.setup(en...
c8f0797ddea0cef7b7c46f09dce28d0c14eac3c8
PawelKonczalski/pythonFromScratch
/lists/operationsAndFunctionsOnLists.py
902
4.09375
4
# len() - length # .append(arg) - add # .extend([tab]) - extend # .insert(index, what) - insert # .index(what) - index of a given item # sort(reverse = False) - sorting in ascending order # max( ) # min( ) # .count( ) - how many times something occurs # .pop() - delete last item # .remove( ) - Delete the f...
85c6fe179f5c18908a784aab5dc55a9d66c11f0e
hieugomeister/ASU
/CST100/Chapter_12/Chapter_12/Ch_12_Solutions/Ch_12_Projects/12.10/testdirected.py
1,014
3.515625
4
""" File: testdirected.py Project 12.10 Tests +, ==, in, and clone operations. """ from graph import LinkedDirectedGraph # Create a directed graph using an adjacency list g = LinkedDirectedGraph("ABCD") # Insert edges with different weights and print the graph g.addEdge("A", "B", 1) g.addEdge("B", "C", 3) g.addEdge...
e28b58356c3c08e1b0c4ef33ff1972946ed86590
digitaldna4/helloworld
/wikidocs-net/fourcalc.py
1,305
3.765625
4
""" https://wikidocs.net/28 Class, Input, String Day 2 (4/2) """ class FourCalc: def __init__(self, first, second): self.first = first self.second = second def setdata(self, first, second): self.first = first self.second = second def add(self): res...
bb946afefa75754fd94ae4634514ed35c3efa67a
yh-habosol/Algorithm
/LeeBros/basic/원점으로부터 거리.py
268
3.671875
4
def distance(a, b): return abs(a) + abs(b) N = int(input()) dists = [] for i in range(N): a, b = map(int, input().split()) dist = distance(a, b) dists.append((dist, i+1)) dists.sort(key = lambda x: (x[0], x[1])) for dist in dists: print(dist[1])
c91291840d5f27e8c2db42b2199d0fc220a9a4d8
ViktorKarpilov/Study_reposytory_with_structure
/Small-stydy-things_and-tasks-from-amis/fifth_task.py
164
4.15625
4
number = int(input("Enter number: ")) print("The next number for"+str(number)+" is"+str(number+1)) print("The previous number for"+str(number)+" is"+str(number-1))
9f0338dd2f9b073423f847761444e8b2da5ae0fe
arko-sayantan/Python-for-practice
/3/OOP in python circle.py
699
4.3125
4
class Circle(): # class object attribute pi = 3.14 # user defined attribute def __init__(self,radius = 1): self.radius = radius # method def circumference(self): cir = 2 * Circle.pi * self.radius # you can call pi using class becau...
bdf3293fdb810d82db6f2acbc2c4703e2eb5d508
haidfs/LeetCode
/Hot100/反转字符串中的单词II.py
572
3.75
4
class Solution: def reverseWords(self, s: str) -> str: s = list(map(lambda x: self.reverse_word(x), s.split())) return " ".join(s) def reverse_word(self, s): n = len(s) if n % 2 == 0: end_index = n // 2 else: end_index = n // 2 + 1 s = lis...
992c9ac6e40ef328292c63e55cffb7c907174545
changeYe/hello
/classUse.py
2,188
3.5
4
# class Player(): # def __init__(self,name,age): # self.name = name # self.age = age # # def print_info(self): # print(' 姓名 %s 年龄 %s ' %(self.name,self.age)) # # user1 = Player('张三',18) # user2 = Player('李四',28) # user1.print_info() # user2.print_info() # class Player(): # def __in...
f484ed8850f62ea51c0e7bdf1b9c20da1dd23cf8
larrischen/PythonExerciseCode
/Character Input.py
776
4.125
4
""" Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old. """ def ask(): name = input('Please enter your name:') age = input('Please enter your age:') if int(age) < 1: print('Invaild...
a10ac939fe096e9cff6214f28f95c4df32fed9be
mellosilvajp/projetos_unipampa
/teste github/calcula_fatorial_exponencial.py
729
4.0625
4
#http://www.facom.ufu.br/~backes/gbt017/ListaPython07.pdf #Faça uma função recursiva que receba um numero inteiro positivo N e retorne o fatorial exponencial desse numero. # Um fatorial exponencial é um inteiro positivo N elevado à potencia de N-1, que por sua vez é elevado # à potencia de N-2 e assim em diante. Ou s...
83c8b18ad1fff2ded02720c3cb97631cadb88014
gedda68/Python
/and1.py
115
3.640625
4
x = [1, 2, 3] if 1 in x: print("Yes") else: print("No") if 4 in x: print("Yes") else: print("No")
6d22d96b9b4c7897cce2db2d2d5b0cfb786a1104
mei-t/algorithm_study
/cracking_the_coding_interview/4-5.py
995
3.90625
4
import sys class TreeNode(object): def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right = right def bst_check(root): return is_bst(root, -sys.maxsize - 1, sys.maxsize) def is_bst(node, min_num, max_num): if not node: return True ...
0f1e00d2ab503a41e99130b6df59a17878a8ff98
roger-pan/python-labs
/02_basic_datatypes/02_05_convert.py
621
4.46875
4
''' Demonstrate how to: 1) Convert an int to a float 2) Convert a float to an int 3) Perform floor division using a float and an int. 4) Use two user inputted values to perform multiplication. Take note of what information is lost when some conversions take place. ''' # Convert an int to a floa...
15f4ec44657097829c7af1465c315fc7e272c2a0
planga82/KeepCodingPracticasPython
/KC_EJ28.py
531
3.515625
4
def pintar_rectangulo(lado): pintarFilaInferiorYSuperior(lado) for x in range(lado): pintarFilaIntermedia(lado) pintarFilaInferiorYSuperior(lado) def pintarFilaInferiorYSuperior(n): salida = '' for x in range(n): salida = salida + 'X' print(salida) def pintarFilaIntermedia(n):...
88ceef131d96d13f34f582f9c9d8a7c5f49de0d7
jwtiyar/PyHardWay
/ex15.py
432
3.65625
4
txt = open(test.txt) print(f"here is your file {filename}") print(txt.read()) print("Type name of file: ") file_again = input() txt_again = open(file_again) print(txt_again.read()) txt.close() txt_again.close() #Eme xom nwsywme be bekarhenany tenha input bo testy xom: print("Type file name: ") nawyfile = input()...
4cf070865f7d505119b60c5e35ef4511b090f5e3
harshu1470/100DaysOfCode
/100DaysOfCode/Day3/array_operation.py
242
3.5625
4
#array opration's from array import * array1 = [1,2,4,5,6,7] a1= array('i',array1) print(a1[3]) a1.insert(1,20) print(a1.index(20)) a2 = array('i',[2,4,22,1,2,3]) a1[4]= 80 for c in a1: print(c,'\n') a3=a1 + a2 for i in a3: print(i)
eaaf6aef6e823e8dae0b408426d9d1656e8a3068
ananthuk7/Luminar-Python
/data collections/set/sets/addinset.py
112
3.6875
4
set1 = set() n = int(input("enter the limit")) for i in range(0, n): set1.add(input("enter")) print(set1)
1186d0e02fb3c3d4e049cde7caa6eba6db5deff9
mrinalCodeStore/pyRepo
/variablesAndDataTypes.py
538
3.984375
4
a=5 x=-9 b=4.5 c='Mrinal' print(type(a)) #prints the datatype of the variable print(type(b)) #all the data is object ...but its not strong OOP as it doesnot support strong encapsulation print(type(c)) d=a+a print (d) print(type(d)) e=c+c print(e) print(type(e)) f=a+b #implicit type convers...
f1e27650d4fa80460c82de45cdd298d17af3ce3f
MichaMican/SpongebobMemeSpellHelper
/start.py
883
3.5625
4
#!/usr/bin/env python3 from pynput.keyboard import Key, Controller import time import random random.seed(int(round(time.time() * 1000))) keyboard = Controller() timeToSleep = 0 randomMode = False while(timeToSleep <= 0 or randomMode): try: userInput = input("Enter time between capslock presses in millise...
0292b7faaa245442ad5d0342259c51b3fd8c3f0c
rakesh90084/practice
/square.py
180
3.78125
4
n1=int(input("enter the no :")) n2=int(input("enter the no :")) n3=int(input("enter the no :")) list1=[n1,n2,n3] def square(a): return a**2 print(list(map(square,list1)))
d85031cddcc6ebafcb89381937e5a74053ba8490
kushagra414/Python
/excs1.py
346
4.03125
4
print"This is similar to \nC" #print"But at same time it is diiferent" #print"Like in python you dont ned to terminate every command" print "in python you do not need to write the data types of the variables you use" #print"This somewhat let us focus on programing rather on small things" #print"I love python" pri...
98699779792566ebfaece37e789e95b5a0e3456d
aog11/python-training
/scripts/countdown.py
369
3.65625
4
# Chapter 15 # Simple Countdown Program Project #! python3 # Importing the needed modules import time, os, subprocess timeLeft = 60 while timeLeft > 0: print(timeLeft, end='') time.sleep(1) timeLeft-= 1 # Going to the location of alarm.wav os.chdir('') # At the end of the countdown, play a sound file s...
b0383ccf48a967e8fef179452ed2e6199e9ffbc4
gabrielavirna/interactive_python
/problem_solving_with_algs_and_data_struct/chp2_analysis/anagram_detection.py
6,792
4.1875
4
""" Anagram detection problem for strings ------------------------------------- - One string is an anagram of another if the second is simply a rearrangement of the first. E.g. 'heart' and 'earth' are anagrams. The strings 'python' and 'typhon' are anagrams as well. - A good example problem for showing algorithms...
4a11eb2e231fde9bd0e56753ab13d40bd49ece8c
MaxyMoos/exercism_python
/phone-number/python/phone-number/phone.py
479
3.6875
4
class Phone(): def checkPhoneNumber(self, number): digits = [i for i in number if i.isdigit()] if len(digits) == 10: return "".join(digits) elif len(digits) == 11 and digits[0] == "1": return "".join(digits[1:]) else: return "0" * 10 def __init__(self, number): self.number = self.checkPhoneNumber...
973bc1379ef10269b6c30e7d537708f37eba8c0e
ChangxingJiang/LeetCode
/0801-0900/0861/0861_Python_1.py
1,106
3.609375
4
from typing import List class Solution: def matrixScore(self, A: List[List[int]]) -> int: s1, s2 = len(A), len(A[0]) def reverse_row(ii): for jj in range(s2): A[ii][jj] = 1 if A[ii][jj] == 0 else 0 def reverse_col(jj): for ii in range(s1): ...
7570f805e83dd9d1824834e2b78315b4bdc29066
aravind-sundaresan/python-snippets
/Interview_Questions/anagram_check.py
612
4.3125
4
# Question: Check if 2 strings are Anagrams import collections def sorted_check(first_string, second_string): if sorted(first_string) == sorted(second_string): print("Yes, these are anagrams") else: print("No, these aren't anagrams") def counter_check(first_string, second_string): if collections.Counter(fir...
e16c0d2da1f315f95c496a7be9b1f94524a7b1bb
Penk13/tutorial-python-telusko
/36 - Global Keyword in Python (Global vs Local Variable).py
1,737
4.1875
4
# 36 - GLOBAL KEYWORD IN PYTHON (GLOBAL VS LOCAL VARIABLE) print('=========== 1 ===========') a = 10 #global variable def something(): a = 15 #local variable print(a) print(a) something() print() print('=========== 2 ===========') b = 20 def something2(): print(b) #access the global variable insid...
4a0a18b3e285b220b2f778c2e650c20dddb0b6ce
2legit/python-anandology
/modules/2.py
622
4.1875
4
""" Write a program extcount.py to count number of files for each extension in the given directory. The program should take a directory name as argument and print count and extension for each available file extension. """ def extcount(files): dictn={} for i in files: dictn[ext(i)]=dictn.get(ext(i),0)+1 return ...
76060be3fe0628cf11bb27e46d707ae138d5c90d
AidanGlickman/Advent-2020
/day21/solution.py
1,847
3.59375
4
def readFoods(inpath="input.txt"): with open(inpath, "r") as infile: foodStrs = infile.read().splitlines() foods = [] for line in foodStrs: tokens = line.split(" (contains ") ingredients = set(tokens[0].split()) allergens = set(tokens[1][:-1].split(", ")) ...
9eb5aa80f493aef3a003b6414e2c9603ab532c2f
sbburton/madlibs_atbs
/main.py
928
4.28125
4
#! python3 # Makes a silly madlibs from pathlib import Path print('What text file would you like to madlib?') inFile = open(input()) fileString = inFile.read() inFile.close() # Split String into list for analysis wordList = fileString.split() # Find words to replace in list, replace them with user input for i in ran...
9a73bcb0cd1828be6e422350db2e1578d5c85e00
UWPCE-PythonCert-ClassRepos/SP_Online_PY210
/students/alexander_boone/lesson03/exercises/list_lab.py
2,548
4.34375
4
#!/usr/bin/env python3 # Note: Unsure if list from beginning or end of series 1 should be used for later series. # I reused the list from the end of series 1 in later series. # --------------------------------------------------- SERIES 1 ----------------------------------------------------- print("------------...
940effa2427b5bb874c80b0e5e75621c8d7a4660
BaruaSourav/Gale-Shapely-Implementation
/galeshapely.py
3,458
3.78125
4
import numpy as np import pandas as pd import random import time ''' stable_match(k,n,H,S,Hi,Si) returns tuple (matches,rounds) matches - is a list, where the indeices are hospitals and values are the matched students. rounds - is a integer denoting the number of rounds needed to find stable match of all the hos...
d1d4ae8e69bec2b92b6022b8877bc83bf67297a9
36-650-Fall-2020/fp-unit-test-assignment-YixuanLuo98
/src/readers.py
862
3.5625
4
import functions * def print_death_rate(data, name, region): if data is us: data = data else: data = data[data[region] == name] print("The death rate till now is ", death_rate(data)) def print_covid_information(data, date, name, region): print("Date: " + date) print("The total num...
326845ffa20370fc83524dcf8f4f52426519a79a
bamb4boy/RandomPythonProjects
/loopsExamples.py
527
4.4375
4
#For loop to print number between 1-11 """ for i in range(1,11): print (i) """ #While loop example for printing a number that is lesser and equal to 10 and after printing adding 1 to the printed number """ i=1 while i <=10: print (i) i +=1 """ #if loop example to check if what is a compared t...
193e65d4e2570cb35fcaea474dd51c8846908a9a
thakur8630/python_codes
/palindrom.py
191
4.03125
4
N=int(input("enter the number")) n=N rev=0 while(N>0): R=N%10 rev=rev*10+R N=N//10 if(n==rev): print("palindrom number") else: print("this is not palindrom")
b74e5bf0171c7aa5df67616abfec6911949efb1f
denisotree/education
/algorithm_python/lesson03/task_02.py
767
3.796875
4
import random # Во втором массиве сохранить индексы четных элементов первого массива. Например, если дан массив # со значениями 8, 3, 15, 6, 4, 2, то во второй массив надо заполнить значениями 1, 4, 5, 6 # (или 0, 3, 4, 5 – если индексация начинается с нуля), т.к. именно в этих позициях первого массива стоят четные чи...
91dad3e2ccabb3281f7aa325ff8ef23fb65a3578
fabiorfc/Exercicios-Python
/Python-Brasil/3-EstruturaDeRepeticao/ex_15.py
459
3.765625
4
# -*- coding: utf-8 -*- """ 15 - A série de Fibonacci é formada pela seqüência 1,1,2,3,5,8,13,21,34,55,... Faça um programa capaz de gerar a série até o n−ésimo termo. """ #Input dos dados n = int(input('Insira o valor limite n: ')) serie_x1 = 0 serie_x2 = 1 #Cálculos print(serie_x2) for x in range(0, n-1...
d9a710753d05f930b935815661ae1d91902ca7cd
toneiobufon/Python_Practice
/various/almostIncreasing.py
542
3.765625
4
def almostIncreasing(sequence): for i in range(len(sequence)-1): if sequence[i+1] <= sequence[i]: if (i== 0 or sequence[i+1] > sequence[i-1]): sequence.pop(i) else: sequence.pop(i+1) for e in range(len(sequence)-1): ...
79465f0b49c32f0bb12992c23823f6265339a18a
FirstDove/biji
/test1/page2/IO_test.py
1,291
3.71875
4
#!/usr/bin/env python # -*- coding: utf8 -*- # str = raw_input('请输入:') # print str # a = input('请输入==>') # print a import os # open(name[, mode, buffering]) # name: 是一个包含了你要访问的文件名称的字符串值 # mode: 文件打开模式 默认为只读 # buffering: 0,1,负数, 大于1 # 0: 不会有寄存 # 1: 会寄存行 # 负数: 寄存区的缓冲大小为系统设置 # 大于1:寄存区的缓冲...
f3e584f5ddea7f94127093587639e1da3abbe0d1
lidianxiang/leetcode_in_python
/数组/219-存在重复元素II.py
1,321
3.671875
4
""" 给定一个整数数组和一个整数 k,判断数组中是否存在两个不同的索引 i 和 j,使得 nums [i] = nums [j],并且 i 和 j 的差的绝对值最大为 k。 示例 1: 输入: nums = [1,2,3,1], k = 3 输出: true 示例 2: 输入: nums = [1,0,1,1], k = 1 输出: true 示例 3: 输入: nums = [1,2,3,1,2,3], k = 2 输出: false """ class Solution: """哈希""" def containsNearbyDuplicate(self, nums, k): #...
96c09ac183899ecd13a818fa810033fe831510f4
avigail-oron/sandbox
/src/ex/exercises.py
3,162
3.578125
4
''' Created on Mar 16, 2017 @author: maint ''' from __builtin__ import str """ Exercise 4 """ from random import random def divisors(): num = int(input("Enter a number to find its divisors: ")) potentials = range(1, num+1) answer = [] for x in potentials: if num % x == 0: answer.a...
4cfb922b75731f013525700356824704a8981b5e
tanij/dt-exercises
/image_processing/mooc-image/packages/mooc/src/exercise.py
795
3.796875
4
#!/usr/bin/env python # coding: utf-8 # # Canny Edge detector # # Some notes on the topic of the exercise <br><br> # # # Link to the videos related to the exercise <br> # # # ### Task 1 # <br> # Write the Canny edge detector function in the cell below. # # Do not change the name of the function. # # In[ ]: ...
214c2fe97696a27618b847e4c68103fe85be2c54
dzhao14/Tabula-Rasa-AI
/game.py
2,481
3.828125
4
from board import Board import numpy as np class Game(object): """ Represents a game of tic-tac-toe. This is composed of a board and two players. Player 1 plays with X's (1s). Player -1 plays with O's (0s). At each point of the game, the board is flipped such that the player who acts is ...
1cf7badbfd41ca318bf4c99cf2bd469f130b510a
laddeyboy/DC-exercises
/python/dictionary_exercises/wordSummary.py
465
3.8125
4
def word_histogram(paragraph): text = paragraph.lower().split() my_dict = {} for words in text: if words in my_dict: #the word is already in the dictionary add 1 my_dict[words] = my_dict[words] + 1 else: #the word does not exist in the ditionsary ...
e8b3aea9b511b479d7306338137c2b6c653217ed
swang2000/CdataS
/Practice/practice.py
18,934
3.890625
4
''' Preorder to Postorder Show Topic Tags Amazon Given an array representing preorder traversal of BST, print its postorder traversal. Input: The first line of input contains an integer T denoting the number of test cases. The first line of each test case is N,N is the size of array. The second line of each ...
e8b17ee2610c55dc2996c5df8b85d896f4535f97
emag-notes/automatestuff-ja
/ch03/validateNumber.py
203
3.546875
4
print('整数を入力してください:') try: input_num = int(input()) print('入力値: ' + str(input())) except ValueError: print('入力された値は整数ではありません。')
1a8590e43272324339a27f987b84119b78ea78e8
farhad-dalirani/AUT_Pattern_Recognition
/patternRecognition2/problem3/problem3.py
7,029
3.6875
4
######################################################################## # Problem 3- needed functions and given data set ######################################################################## def covariance_matrix(samples): """ This function gets some samples and return its covariance matrix :param sam...
109c3365b9175ba93f2fb7b648944b4d539be3c3
Ajay2521/Python
/BASICS/break.py
936
4.03125
4
#In this lets see about the "control statements" in Python Program. #Control statement is used to make a control flow in the program. #The different type of control statement in python is #1) break #2) continue #3) pass #Lets now see about "break" control statement in python #break is control stat...
06e89f87be96f3c440d4e66f06ea73fbdc085a40
AbhishekVarshney98/Python
/Rest API using Flask/test.py
366
3.796875
4
def validBookObject(bookObject): if("name" in bookObject and "price" in bookObject and "isbn" in bookObject): return True else: return False valid_object={ 'name':'F', 'price':6.99, 'isbn':123123123 } missing_price={ 'name':'F', 'isbn':12341234 } missing_name={ 'price'...
76132ab50a84704194c777b8eae6668f93442d72
jaceyshome/fpo.py
/src/fpo.py
44,849
3.546875
4
import json import copy def ap(fns, list): ''' ## FPO.ap(...) Produces a new list that is a concatenation of sub-lists, each produced by calling FPO.map(..) with each mapper function and the main list. ### Arguments: fns: a list of functions list: a list ### Returns: a li...
29ea1ae187c2113e95632f55685d8eb23c92c41e
hirtiganto/The-Nature-of-Code-Examples-Python
/chp01_vectors/NOC_1_2_bouncingball_vectors/NOC_1_2_bouncingball_vectors.pyde
709
3.6875
4
# The Nature of Code # Daniel Shiffman # http://natureofcode.com # Example 1-2: Bouncing Ball, with PVector! def setup(): size(200, 200) background(255) global location, velocity location = PVector(100, 100) velocity = PVector(2.5, 5) def draw(): noStroke() fill(255, 10) rect(0, 0, w...
608406112d60f291ba6d2e50c5df2cb344c6fe24
mwnickerson/python-crash-course
/chapter_8/archive_messages.py
539
3.640625
4
# Archive Messages # Chapter 8 exercise 11 # function that sends messages while retaining the original list def send_messages(new_messages, sent_messages): while new_messages: outbox_message = new_messages.pop() print(f'Sending "{outbox_message}"') sent_messages.append(outbox_message) new_m...
0e4d23c738bfdeee7b6f3cda02b0055150ea433f
onkgp/Projects
/Jump To Python/List_170220.py
3,646
3.953125
4
# 리스트의 유형 a = [ ] b = [1, 2, 3] c = ['Life', 'is', 'too', 'short'] d = [1, 2, 'Life', 'is'] e = [1, 2, ['Life', 'is']] # 리스트의 인덱싱 a = [1, 2, 3] print(a) #변수 a 출력 print(a[0]) #변수 a의 첫번째 요소값을 출력 print(a[2]) #변수 a의 세번째 요소값을 출력 print(a[0]+a[2]) #첫번째와 세번째 요소값을 더해서 출력 a = [1, 2, 3, ['a', 'b', 'c']] print(a[3]) print(a[-1]...
3920918aba3804628fdb9c81fb8697ba8642086a
Camiloasc1/AstronomyUNAL
/CelestialMechanics/util.py
2,690
3.640625
4
from typing import List, Tuple import numpy as np def cross(a: List[float], b: List[float]) -> List[float]: """ np.cross(a, b) keeping the units :param a: vector a :type a: list :param b: vector b :type b: list :return: np.cross(a, b) :rtype: list """ return np.cross(a, b) * ...
a2ec14f826b7e4bfe69c3f664727852c2b5d801a
Wolverinepb007/Python_Assignments
/Conv_Sum/validation.py
266
4.0625
4
def ValidNum(number): while number<0 or number>255: print("\n") print("Invalid Input!!") number=int(input("Please enter valid number (0 to 255): ")) return number
3214822de3df1d4bc409ad2a15db196747149414
nshagam/Python_Practice
/ListOverlapComprehensions.py
880
4.09375
4
# This week’s exercise is going to be revisiting an old exercise (see Exercise 5), # except require the solution in a different way. # # Take two lists, say for example these two: # # a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] # b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] # and write a program that returns...
669b5a0ba25b8a84361dffcdaae7ca59d2a4291a
douzhenjun/python_work
/highs_lows.py
1,156
3.6875
4
import csv from matplotlib import pyplot as plt from datetime import datetime filename = 'sitka_weather_2014.csv' with open(filename) as f: reader = csv.reader(f) header_row = next(reader) for index, column_header in enumerate(header_row): print(index, column_header) dates, highs, lows = [], [], [] for ro...
d21b95057ad84d868995f98ed59add2f77c806b9
ashryaagr/ML-SIG-2019-tasks
/GA and NN/neural_net.py
15,471
3.9375
4
""" SEE neural_nets.ipynb NOTEBOOK FOR SOLUTIONS """ """ Resources: * https://youtu.be/aircAruvnKk * http://neuralnetworksanddeeplearning.com/ * playground.tensorflow.org """ """ TASK 1 INSTRUCTIONS: There are 11 TODOS in this python file Fill each one of those appropriately and you will have a working neural ...
19f0673aff33acc1dddcd940e6e80ec28676a2cd
fernandojoses/tkinter-starter
/main.py
2,159
4.28125
4
# A starter program for Python with Tkinter from tkinter import * # import Tkinter library window = Tk() # Create the application window window.title("Welcome to Fernando's Window") # Add a label with the text "Hello" lbl = Label(window, text="Hello! You clicked the green little run button didnt you!",font=("A...
a242f8674809631ee54ac4908b95411e8e3a5082
vmture01/rush_leetcode
/simple/一堆数组的动态和.py
1,020
3.59375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @File : test1.py # @Author: vmture # @Date : 2020/8/31 # @Desc : 一堆数组的动态和 #https://leetcode-cn.com/problems/running-sum-of-1d-array/ # 示例 1: # # 输入:nums = [1,2,3,4] # 输出:[1,3,6,10] # 解释:动态和计算过程为 [1, 1+2, 1+2+3, 1+2+3+4] 。 # 示例 2: # # 输入:nums = [1,1,1,1,1] # 输出:[1,2,3...
46d63825dced51c84c85e5579acdf5aa5be9f530
RokKos/Gimnazijska-snov-matematike
/pascalgen.py
1,316
3.828125
4
import sys def pascal(n): """ Yield up to row ``n`` of Pascal's triangle, one row at a time. The first row is row 0. """ if not isinstance (n, int): raise TypeError ('n must be an integer') if n < 0: raise ValueError ('n must be an integer >= 0') def newrow(row): ...
9507e5b1bb777974a4439ae637b438a7f425ac43
Xilma/Lynn
/Python Practice/main.py
1,801
4.40625
4
#imports the module Calculator from the calculator file from calculator import Calculator #creates an object of the Calculator class calculate = Calculator() #calls the __str__ method that returns my name print(calculate) #calculates the sum def addNumbers(): input_string = input("Enter the numbers you want ...
67ac182112b5643a55a082342685770fd758e122
daniel-reich/turbo-robot
/6brSyFwWnb9Msu7kX_24.py
690
4.46875
4
""" Write a function that sorts the **positive numbers** in **ascending order** , and keeps the **negative numbers** untouched. ### Examples pos_neg_sort([6, 3, -2, 5, -8, 2, -2]) ➞ [2, 3, -2, 5, -8, 6, -2] pos_neg_sort([6, 5, 4, -1, 3, 2, -1, 1]) ➞ [1, 2, 3, -1, 4, 5, -1, 6] pos_neg_sort([-5...
9937ac7c6b2b6d00fae96ad7b20cff811b1686d8
geometryolife/Python_Learning
/PythonCC/Chapter10/pra/t3_guest.py
617
3.828125
4
print("----------访客----------") # 编写一个程序,提示用户输入其名字;用户做出响应后,将其 # 名字写入到文件guest.txt中。 def get_name(): """获取用户的姓和名,并返回全名""" first = input("Please enter your first name: ") last = input("Please enter your last name: ") full_name = first.title() + " " + last.title() return full_name def guest(): ...
2519036d1667ffe27a70cb6e30af11b73b63d9bf
timHollingsworth/hackerRank
/alternating_characters.py
741
4.03125
4
""" Shashank likes strings in which consecutive characters are different. For example, he likes ABABA, while he doesn't like ABAA. Given a string containing characters and only, he wants to change it into a string he likes. To do this, he is allowed to delete the characters in the string. Your task is to find the mi...
c153265f135443503135171384da72833cb2d9b7
WoolinChoi/WoolinChoi.github.io
/jupyter/cWebConn/c_beautifulsoup_class/Ex02_seletor.py
810
3.59375
4
""" BeautifulSoup 모듈에서 - HTML의 구조(=트리구조)에서 요소를 검색할 때 : find() / find_all() - CSS 선택자 검색할 때 : select() / select_one() """ from bs4 import BeautifulSoup html = """ <html><body> <div id='course'> <h1>빅데이터 과정</h1> </div> <div id='subjects'> <ul class='subs...
234e48c08a7f5c82f483f0abf2ba9976a4522d08
Ckingbigdata/cn_labs
/labs/02_basic_datatypes/02_02_days_seconds.py
408
4.34375
4
''' Write a script that takes in a number in days from the user between 1 and 1,000,000,000 and convert it to seconds. NOTE: We will use the input() funtion to collect users input. An example is demonstrated below. ''' days = int (input ("Please enter a number in days between 1 and 1,000,000,000: ")) seconds = int (...
412e2228c42ecdd818ffc52c0ebad6ef7e5035ad
vid083/dsa
/Python_Youtube/type.py
241
4.1875
4
value = int(input('Input a value: ')) if type(value) == str: print(value, 'is a string') elif type(value) == int: print(value, 'is a integer') elif type(value) == list: print(value, 'is a list') else: print(value, 'is none')
36d1eba309dd270ac46e12ddfe44e443e7a652d1
VitalyGladyshev/Alg_Ess
/les_1_task_1.py
677
4.15625
4
# ДЗ к Уроку №1 Гладышев ВВ """ Задание №1 Выполнить логические побитовые операции «И», «ИЛИ» и др. над числами 5 и 6. Выполнить над числом 5 побитовый сдвиг вправо и влево на два знака. """ print(f"Побитовое И: 5&6 = {5&6}") print(f"Побитовое ИЛИ: 5|6 = {5|6}") print(f"Побитовое исключающее ИЛИ: 5^6 = {5^6}") print...
51fe8fbdd8c873a4d007f319210fd601a665ca3c
ranie2019/PythonLivro
/ex4.1.py
217
3.875
4
a = int(input('primeiro valor: ')) b = int(input('seundo valor valor: ')) if a > b: print('o primeiro valor e maior') if b > a: print('o segunda valoe e maior') # se os valores forem iguais nao acontece nada
3c306c4c396d1fb7be51bc42624781a374305bf8
imtiaz-rahi/Py-CheckiO
/Electronic Station/Army Battles/best-2.py
1,678
4.21875
4
# https://py.checkio.org/mission/army-battles/publications/Phil15/python-3/army-with-3-properties-is_alive-warrior-pop/ class Warrior: """Define a warrior.""" def __init__(self): self.health = 50 self.attack = 5 @property def is_alive(self) -> bool: return self.health > 0 class ...
772fcc0505e358f44187687e1fc0d4a95337f24c
piksel/advent_of_code_2016
/advall-python/d12.py
2,328
3.5
4
src = "d12_input.txt" def parseInstr(s): instr = [] for index, val in enumerate(s): if index == 0: instr.append(val) elif val == 'a': instr.append(0) elif val == 'b': instr.append(1) elif val == 'c': instr.append(2) elif va...
d37c37aa9129f61c2cf3abef9e7659be06e5b818
twoLoop-40/think-python
/ch13/ex13-8.py
1,531
3.640625
4
def match_prefix(prefix, t, k): ''' t : list from k to len(prefix) Check if prefix match t[k:k + len(prefix)] ''' ln = len(t) ln_p = len(prefix) if ln < k + ln_p: return False elif prefix == tuple(t[k:k+ln_p]): return True else : return False def make...
cc72b5eebe93f6f15ca9b9d2d85e3680d911753c
dimistsaousis/coursera
/Algorithms & Data Structures Specialisation/Algorithmic Toolbox/Week5_Dynamic Programming part 1/2_primitive_calculator.py
1,123
3.78125
4
""" Task. Given an integer 𝑛, compute the minimum number of operations needed to obtain the number 𝑛 starting from the number 1. Input Format. The input consists of a single integer 1 ≤ 𝑛 ≤ 106. Output Format. In the first line, output the minimum number 𝑘 of operations needed to get 𝑛 from 1. In the second line...
16c7a30d6275e21a57e523ebd44c97d72a9135ed
jmchilton/cloudman
/cm/util/bunch.py
1,123
3.5625
4
class Bunch(object): """ http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52308 Often we want to just collect a bunch of stuff together, naming each item of the bunch; a dictionary's OK for that, but a small do-nothing class is even handier, and prettier to use. """ def __init__(self, **...
3b958d3fa1c0bccd782f5c82858c253360b24453
hellstrikes13/sudipython
/triangular_series.py
129
3.78125
4
def tri(n): tri = 0 count = 0 while count < n: count = count + 1 tri = tri + count print "%r\t %r"%(count,tri) tri(5)
4906486bf5d1acbcdb58b661c2451f41f2f7e8d4
micnem/developers_institute
/Week4/Day2/xp/ex6.py
74
3.96875
4
name = "" while name != "Michael": name = input("What is your name?")
ac174cd86aaf3189a91e0d174ccb8427c596247f
Magical-Man/Python
/Learning Python/parameters_practice.py
317
3.6875
4
from sys import argv script, first, second, third = argv name = input("Hello there! What is your name?") age = int(input("How old are you?")) print("So you told me, ", first) print("You told me, ", second) print("And you told me, ", third) print("So you're name is %s, and you are %s years old" % (name, age))
89a000100b05914cac892d01d9d226438c8842d3
Seben0fnine/MyWork
/Euler_prob4.py
447
4.03125
4
## Finds the largest palindrome number obtained after multiplying two three digit numbers def is_palindrome(str): if str== reversed(str): return True return False def reverse_int(n): return int(str(n)[::-1]) n=10201 for i in range(999, 100, -1): for j in range(i,100, -1): num=i*j ...
e416e5c0f69838893b96f483144a59afc4482d80
ChoiHyeongGeun/ScriptProgramming
/Practice/#2/Problem 4.1.py
851
3.765625
4
# 4.1 # math 모듈 사용 import math # a, b, c 를 입력받는다. a, b, c = eval(input("a, b, c를 입력하세요 : ")) # 판별식을 d에 저장한다. d = b*b - 4*a*c # 만약 판별식이 양수이면 if d > 0 : # 첫 번째 실근을 구한다. r1 = (-b + math.sqrt(d)) / 2*a # 두 번째 실근을 구한다. r2 = (-b - math.sqrt(d)) / 2*a # 두 실근을 출력한다. print("실근은", fo...
beb26046a2cefdab7deaa2501e303a50d723dca7
ZeroMin-K/HonGong_Python
/chapter04/enumerate_195p.py
401
4.25
4
example_list = ["elementA", "elementB", "elementC"] print("# simple print") print(example_list) print() print("# print using enumerate() ") print(enumerate(example_list)) print() print("# print using list()") print(list(enumerate(example_list))) print() print("# combine with repetition") for i, value...
99e2357759e5e7f7aff974baeac97fce69b7e21a
good5dog5/code-vault
/leetCode/permutation.py
724
3.578125
4
#!/usr/bin/env python3 # Jordan huang<good5dog5@gmail.com> import os import sys import subprocess # Input: [1,1,2] # Output: # [ # [1,1,2], # [1,2,1], # [2,1,1] # ] def rotate(input, level, is_visited, combination, result): if (level == len(is_visited)): result.append(combinati...
e3623167f63461d31be37852c8cd4eff57d4eb3f
Brokenshire/codewars-projects
/Python/six_kyu/unique_in_order.py
1,209
4.1875
4
# Python solution for 'Unique In Order' codewars question. # Level: 6 kyu # Tags: Fundamentals, Advanced Language Features, and Algorithms. # Author: Jack Brokenshire # Date: 18/03/2020 import unittest def unique_in_order(iterable): """ Implement the function unique_in_order which takes as argument a sequenc...
3bf056a966ad395b03e0bdcb4b327c3ff11b16a2
LarisaOvchinnikova/Python
/try except/try.py
643
4.03125
4
try: x = int("a") print(x) except ValueError: print("Wrong Value") print("I still work") try: y = 5 / 0 print(y) except ZeroDivisionError: print("Zero divizion") print("I still work") try: print("qwe") x = int(6) print(x) f = open("b.txt") except NameError as error: prin...