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
8b0f30175df00431d84c890746e2cb66d692eec9
djalma21/maratona
/Treino Atividade 3.py
630
3.84375
4
#3 - Faça um Programa que leia um número e exiba o dia correspondente da semana. #(1-Domingo, 2- Segunda, etc.), se digitar outro valor deve aparecer valor inválido. dia_semana = int(input('Digite um número correspondente a semana, ex: 1-Domingo, 2-Segunda e etc:')) if dia_semana == 1: print('É domingo') elif di...
c8de22cbd9a1535e0ad87b799dc1f604c246c33f
djalma21/maratona
/Treino Atividade 4.py
1,309
4.1875
4
#Faça um programa que faça 5 perguntas para uma pessoa sobre um crime. As perguntas são: #"Telefonou para a vítima?" #"Esteve no local do crime?" #"Mora perto da vítima?" #"Devia para a vítima?" #"Já trabalhou com a vítima?" #O programa deve no final emitir uma classificação sobre a participação da pessoa no crime. #Se...
d0702dc6875c9cb8b203466bec00631fc5a89461
Abishekthp/Simple_Assignments
/Assigmnet_1/10Sum_of_odd_integer_from_N_Numbers.py
304
4.03125
4
#READ N & N NUMBERS AND FIND THE SUM OF ODD INTEGERS n=int(input('Enter n:')) sum=0 for i in range(0,n): N=int(input('Give N:')) if(N%2!=0): sum=sum+N print('Sum of Odd numbers:',sum) """ GIVE 4 NUMBERS. NUMERS ARE 233,234,255,257 SUM WILL BE 233+234+255=745 """
e51c78c3e21eb1c6a1624bd113fa1d94ab353293
Abishekthp/Simple_Assignments
/Assigmnet_1/11Factor_and_largest_factor_of_a_Number.py
247
4.25
4
#FIND THE FACTORS OF A NUMBER AND PRINT THE LARGEST FACTOR n=int(input('Enter the number:')) l=0 print('Factors are:') for i in range(1,n): if(n%i==0): print(i) if(i>l): l=i print('largest factor:',l)
5a785b753368931d6113634176eeb610a67e78f2
yasaman-bahrami/GDD-analysis
/src/drawMinMaxPlot.py
1,648
3.671875
4
import numpy as np import matplotlib.pyplot as plt import argparse import os from getCSVData import getCSVData """ producing MIN/MAX plots for the city as input""" def savePlot(stationId, cityName): for i in range(len(stationId)): #draw min and max plots base on ongoing path FL_Path= (os.getcwd()+'/CSVD...
d76f0845f20a165da176729f80db1123942d34bb
yasaman-bahrami/GDD-analysis
/src/downloadData.py
2,014
3.625
4
import os import wget import argparse import numpy as np import pandas as pd from saveCSVData import saveCSVData import pdb """ If there is no errors, this function will download and then save a csv file that has the required columns for our further computation and plots. """ # Read csv file def cleanData(cityD...
02a63e9dd5a0bb1c5ff8e4a2de691696030f8f17
HolyCoffee00/python_books
/python_books/py_crash/chaper_7/cities.py
273
4.03125
4
prompt = "\nPlease enter the names of the cities that you have visited:" prompt += "\nTo finish the program, enter (quit) " while True: city = input(prompt) if city == "quit": break else: print("i'd love to go to " + city.title() + "!")
9db36b88191861353321686f4209406196385ae1
HolyCoffee00/python_books
/python_books/py_crash/chaper_7/greeter.py
267
4.21875
4
name = input("Please tell me your name: ") print("Hello, " + name.title() + "!") prompt = "If you tell us who you are i will personalize the message: " prompt += "\nWhat is your firtst name: " name = input(prompt) print("Hello, " + name.title() + "!")
80f484744a969f69acaf4860b778f490b5e6324c
HolyCoffee00/python_books
/python_books/py_crash/chapter_6/no_te_mates.py
142
3.65625
4
pregunta_input = input("¿Como te sientes?\n").lower() pregunta = pregunta_input if pregunta == "mal": print("No te mates yo te quiero")
4367bdff831e79e80752b569ae81dca79c1b7bc6
HolyCoffee00/python_books
/python_books/py_crash/chapter_4/million_excersice.py
430
3.859375
4
million = [value for value in range(1,1000001)] maximum_number = max(million) minimum_number = min(million) adding_number = sum(million) result = [maximum_number , minimum_number , adding_number] print(result) print("\n") for oddnumber in range(1,21,2): print(oddnumber) print("\n") for threes in range(3,31,3): prin...
4c9035079090722863de90e5fdfc20b679566216
KIIIIK/FluentPython
/第五章 一等函数/5.1 把函数视作对象.py
246
3.8125
4
def factorial(n): """returns n!""" return 1 if n < 2 else n * factorial(n-1) factorial(42) factorial.__doc__ type(factorial) help(factorial) fact = factorial fact fact(5) map(factorial, range(11)) list(map(fact, range(11)))
a5e18c4ec24bacd3a44fc5610f6175bb21d8063f
coderjingtao/faceai
/pic_draw_face_outline.py
845
4.0625
4
#coding=utf-8 #Draw the outline of a face #对图片基于face_recognition库的人脸轮廓描绘 import face_recognition from PIL import Image, ImageDraw # load one picture with a face into the array of numpy image = face_recognition.load_image_file('D:/jingtao.jpg') # search for all the characteristics of the face face_landmark_l...
641bc163c4df0ede1e29ad5a42f3fdf159538bf3
47AnasAhmed/Class-Assignments
/3.21.py
160
3.6875
4
print("Anas Ahmed") print("(18B-116-CS),Sec-A") print("Practice Problem 3.21") number = [2,3,8,7,-1,-10,-6] for i in number: if i%2==0: print(i)
e650bfbbbf52bdca37c65ec9851cd25c0dcbe35b
47AnasAhmed/Class-Assignments
/3.27.py
162
3.59375
4
print("Anas Ahmed") print("(18B-116-CS),Sec-A") print("Practice Problem 3.27") w = eval(input("enter a +ve integer: ")) for z in range (0, w*5,w): print(z)
ca9d3d2d8f149beb74a67192d74c437aad92714c
47AnasAhmed/Class-Assignments
/3.3(B).py
282
3.578125
4
print("Anas Ahmed") print("(18B-116-CS),Sec-A") print("Practice Problem 3.3(b)") list_ticket = eval(input("Enter Your Ticket NO#:")) list_lottery = eval(input("Enter your Lottery NO#:")) if list_ticket==list_lottery: print("YOU WON! :)") else: print("Sorry Try AGAIN")
1bf8ad175beff44cde1bdfb1144fb0230e3d8b08
rolaulten/ChickenPI
/DoorControll.py
1,510
3.515625
4
# Script to open a chicken door. # writen by Dorian Goettler, free to use unter the MIT licence. # Requires: GPO, time. import RPi.GPIO as GPIO import time import datetime from suntime import Sun, SunTimeException # Setup the gpio pins so that we can controll them. FOr this we are using pins 20 and 21. GPIO.setmod...
a465ff1b6ba75113cf54994758f21d2b250b6126
MaAlexHr/Practica10
/bibliotecas.py
683
3.8125
4
""" Programador Hernandez Rojas Mara Practica 10 Este programa muestra como importar bibliotecas en python Primera Forma Importa absolutamente todo en la biblioteca y cuando lo ocupas te refieres a las funciones iniciando por el nombre de la biblioteca """ import math x = math.cos(math.pi) #print(x) """ Segunda forma...
3e06bd66e4c8e1afe26bb858af51af66de835166
cookiebrains/NumberSolver
/main.py
4,731
3.625
4
import operator from itertools import permutations OPERATIONS = { "add": operator.add, "mul": operator.mul, "sub": operator.sub, "div": operator.truediv, } SYMBOLS = { "add": "+", "mul": "*", "sub": "-", "div": "/", } def _get_groupings(nums): if len(nums) == 1: yield num...
f58ad48501d9a0a3bf2d2fcb239a1e2ca6ad9870
neilkazimierzsheridan/sqlite3
/sq2.py
1,070
4.1875
4
#sqlite part 2 import sqlite3 conn = sqlite3.connect('customer2.db') c = conn.cursor() #create the cursor instance #c.execute(" SELECT rowid, * FROM customers") #rowid to get autogenerated primary key, this is element 0 now ## USING THE WHERE CLAUSE SEARCHING #c.execute(" SELECT rowid, * FROM c...
25048f89acfe966d1aaf8b3197ecfacdcac903b6
nspin/moodle-crawler
/myydle/uniq.py
362
3.765625
4
from collections import deque class UniQ(object): def __init__(self): self.deque = deque() self.seen = set() def en(self, x): if x not in self.seen: self.deque.append(x) self.seen.add(x) def de(self): return self.deque.popleft() def is_empty(s...
c8b4fea6ce31a3e357437a0d294a933e8a756b68
PES-Innovation-Lab/git-practice-workshop
/2020-test.py
244
3.515625
4
import time def test(x, y): if(y==0): return x return test(y, y%x) for i in range(0, 10): print('GCD of {} with 2 : '.format(i), test(2, 10)) for i in range(0, 10): print('GCD of {} with 2 : '.format(i), test(2, 10))
dc69b29ecab4063195ef60e9bd5c6b770525ce47
mk-in/python
/Unsorted/rockpaperscissor.py
3,714
3.703125
4
# Rock , paper , scissor game import os import random # globals0 rps = ('r', 'p', 's') choiceYes = ('Y', 'y') choiceNo = ('N', 'n') # game class rpsGame: playerScore = 0 aiScore = 0 def getPlayerName(self): rpsGame.playerName = input('Enter your name: ') def showScore(self): ...
d68d54a0459f6d21266d1ae20f9b1bcf89e7139f
tchallagulla/python-learning
/variables.py
776
4.0625
4
#Variables are containers for storing data values. #Unlike other programming languages, Python has no command for declaring a variable. #A variable is created the moment you first assign a value to it. # creating variables: variables are used to store values. # 1: x= 5 y= "teju" # 2: data type of assigned variables ...
7e62abd27eca1a251771405f2d1c2ad64a581a79
DIVIGL1/ML-DL-scripts
/time series regression/autocorelation, mov avg etc/doubleExponentialSmoothing.py
2,955
3.609375
4
# Load modules from __future__ import print_function import os import pandas as pd import numpy as np from matplotlib import pyplot as plt #Read dataset into a pandas.DataFrame beer_df = pd.read_csv('datasets/quarterly-beer-production-in-aus-March 1956-June 1994.csv') #Display shape of the dataset print('Shape of th...
cb7f069f17d3813d4e63840db06f9bb0d08cf929
OSGeoLabBp/tutorials
/hungarian/python/code/circle.py
846
4.15625
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- import math from point import Point class Circle(Point): """ class for 2D circles """ def __init__(self, x=0, y=0, p=2, r=1): super(Circle, self).__init__(x, y, p) self.r = r def __str__(self): return ("{0:." + str(self.p) + "f}, {1...
b5865743c7097de4e3cd68fef57a52509ef0e0ea
OSGeoLabBp/tutorials
/english/img_processing/code/histogram_matching.py
7,922
3.578125
4
#!/usr/bin/env python ''' Welcome to the Histogram Matching Program! Given a source image and a reference image, this program returns a modified version of the source image that matches the histogram of the reference image. Image Requirements: - Source image must be color. - Reference image must be color. -...
644335a0226c0b9a54aeb7b689e8452e0705466a
ddib-ccde/pyforneteng2020
/week1/exercise2.py
1,106
4.1875
4
# Print an empty line print(f"") # Ask user for an IP address and store as string ipaddr = input("Please enter an IP address: ") # Split the IP address into four parts and store in a list ipaddr_split = ipaddr.split(".") # Print an empty line print(f"") # Print the header with centered text (^) and width 15 print(f"{...
a2b6d6a8a1106add558545ec802d4de611c37b14
ddib-ccde/pyforneteng2020
/week1/exercise3.py
378
3.71875
4
# Define IPv6 addresses ip_address = "2001:db8:1234:1234::1" IP_ADDR = "2001:db8:1234:1234::2" ipv6_address = "2001:db8:1234:1234::3" # Compare if first variable equals second variable print(f"Is {ip_address} = {IP_ADDR} - {ip_address == IP_ADDR}") # Compare if first variable is not equal to third variable print(f"Is ...
475dff03c04ed513a6f70ca2f6f88d0f2a5a0467
enzoandreacchio/masses_molaires
/Python/list.py
242
3.703125
4
import random size = input("Taille de l'échantillon : ") size = int(size) a = str() tab = [] i=0 while i < size: tab.append(random.randrange(11)) i+=1 i=0 nb = tab[i] while i < len(tab)-1: i+=1 nb += tab[i] nb = nb/(len(tab)) print(nb)
cfc1efe42992c6cee94bf7e998bef83095f288cd
enzoandreacchio/masses_molaires
/Python/division(par 0).py
250
3.671875
4
def f(a,b): try: e = a/b except: print("Il y a un problème avec les données") else: print(a , " / " , b , " = " , e) print("Dans ce programme, on va tester des divisions") a = input("a = ") a = int(a) b = input("b = ") b = int(b) f(a,b)
32f24a3dcdc7e7b4ca10c934db22a692b4b34513
zeuslawl/pau_martin
/Programacio/python/Jocs_Cartes_I_Daus/pedra-paper-tissores-lagarto-spock/lagarto-spock-bucle.py
1,081
3.65625
4
#!/usr/bin/python # coding: utf8 from random import randint import os Sortir = False while (Sortir == False): huma = raw_input("Que quieres jugar?: Piedra, Papel, Tijeras, Lagarto o Spock: ") machine = randint(1,5) if machine == 1: maquina = "Tijeras" if machine == 2: maquina = "Piedra" if machine == 3:...
431a30c516506114adb3a63ef140d1e7613c806c
zeuslawl/pau_martin
/Programacio/python/ejercicio-swap.py_ejercicio-menu-calc.py_ejercicio-mayor.py/ejercicio-mayor/ejercicio-mayor.py
425
3.953125
4
#!/usr/bin/python # coding: utf8 import os os.system('clear') print "" Var1=raw_input("Digues un nombre: ") print "" Var2=raw_input("Digues un altre nombre: ") print "" if ( Var1 > Var2 ): print str(Var1) + " és més gran que " + str(Var2) print "" else: if ( Var1 == Var2 ): print str(Var1) + " és igual a ...
d40e6a0baa4379e0afe1dd8eacf7e2b44ee37ca5
zeuslawl/pau_martin
/Programacio/python/Superior/Estructures_Seqüencials/Estructures_Seqüencials_Ex14.py
759
4.21875
4
#!/usr/bin/python3 # -*-coding: utf8-*- # Pau Martín Arnau # isx46420653 # 11/10/18 # Primera versió # Demanar un nombre de base i convertir els nombres de 3 xifres # d'aquella base a un nombre decimal. # Entrar un numero enter > 0 que sigui la base, també entrar 3 nombres enters > 0 i # que el nombre no sigui maj...
c4e09fe0fbda35fae5e8c0f27baef503d2ce77b3
zeuslawl/pau_martin
/Programacio/python/Superior/Estructures_Seqüencials/Estructures_Seqüencials_Ex6.py
383
3.78125
4
#!/usr/bin/python3 # -*-coding: utf8-*- # Pau Martín Arnau # isx46420653 # 11/10/18 # Primera versió # Un programa que faci la conversió de centímetres a polzades. (1cm == 0,39737p) # Entrar un numero float que seran els centimetres, el resultat serà # la conversió a polzades. cm = float(input("Quants centímetres v...
fce0da67f3967458e405a8934a58a6d9d4ae4053
zeuslawl/pau_martin
/Programacio/python/Superior/Estructures_Seqüencials/Estructures_Seqüencials_Ex11.py
353
3.96875
4
#!/usr/bin/python3 # -*-coding: utf8-*- # Pau Martín Arnau # isx46420653 # 11/10/18 # Primera versió # Un programa que faci la conversió de Lliures a KG. (1KG == 2.2046 L) # Entrar un numero float que seran les lliures, el resultat serà # la conversió a KG. ll = float(input("Quantes lliures vols? ")) print (ll, "l...
ad7a8704fdc738c00868f9dd50607f1d9bd0d9a5
GAURAV-GAMBHIR/pythoncode
/5.8.py
243
3.625
4
print("\n\n") list4 = [input("Enter element : ") for x in range(10)] x = input("\nEnter element to be deleted : ") for y in range(len(list4)): if x==list4[y] : del list4[y] break; print("After deletion : ",list4)
1d9174ea48f7685df67ab36c817ab72f1c1f0f7e
GAURAV-GAMBHIR/pythoncode
/3.A2.py
238
4.21875
4
a=(12,14,14,11,87,43,78) print("smallest element is",min(a)) print("largest element is",max(a)) finding product of all element in tuple result=1 for x in a: result=result*x print("product of all element in tuple is: ",result)
2d8296946edc97182227012d504623906dda21fd
GAURAV-GAMBHIR/pythoncode
/6.4.py
131
3.984375
4
def cal_pow(x,y): print(x,'^',y,'=',x**y) x = int(input(" \nEnter num : ")) y = int(input("Enter pow : ")) cal_pow(x,y)
5b42e92e85dc7daa98685a87e0d8e2e0e4a70fdb
Justobe/pytorch_learn
/RNNLM/data_preprocess.py
605
3.609375
4
def get_data_list(filename): #filename = "Hamlet.txt" symbol_list = [',', '.', '!', '?', '-', ':', ';', '\n'] symbol = '\'' f = open(filename,"r+") all_data = f.read() for chr in symbol_list: all_data = all_data.replace(chr, " ") tmp_list = all_data.split(" ") symbol_list.appe...
84c7a0cca3d24ad81349013ba9490446f4447995
ddobik/Introduction-Python
/Lesson_3/lesson3_1_1.py
163
4.28125
4
x = int(input('Enter three digit number: ')) digit_3 = x % 10 x = x // 10 digit_2 = x % 10 x = x // 10 print('Sum of digits of a number :', x + digit_2 + digit_3)
4a17b813c5ec84c146861d1a0210048ad6162af7
ddobik/Introduction-Python
/Lesson_2/lesson2_7.py
266
4.0625
4
stars = [] x = int(input('Enter number of stars: ')) for element in range(x): if element <= x: element += 1 stars.append(element) for element in range(x): stars[element] = '*' # print(*stars) for element in stars: print(element, end='')
5dda6f74cdb6d17620d1222030e998748d74087e
ddobik/Introduction-Python
/Lesson_3/lesson3_6.py
262
3.84375
4
x1 = int(input('Enter x1:')) y1 = int(input('Enter y1:')) x2 = int(input('Enter x2:')) y2 = int(input('Enter y2:')) if abs(x1 - x2) == 1 and abs(y1 - y2) == 2: print('Yes') elif abs(x1 - x2) == 2 and abs(y1 - y2) == 1: print('Yes') else: print('No')
aff4f2ec1a0b65c013cd3507de73d5cc9bd18fbf
ddobik/Introduction-Python
/Lesson_3/lesson3_4.py
112
3.578125
4
list_of_six: range = range(100, 202, 6) for x in list_of_six: if x % 5 == 0 and x<=150: print(x)
c6df819a465084cbaf0ad8de72c2e554a3898a37
Bishwajit05/DS-Algos-Python
/Recursion/CoinChangeProblemRecursion.py
1,649
4.25
4
# Implement coin change problem # Author: Pradeep K. Pant, ppant@cpan.org # Given a target amount n and a list (array) of distinct coin values, what's the fewest coins needed to make the # change amount. # 1+1+1+1+1+1+1+1+1+1 # 5 + 1+1+1+1+1 # 5+5 # 10 # With 1 coin being the minimum amount. # Solution strategy: # Thi...
cd49cf9074247537a3d29e2ba4d9ad0dea5634c2
Bishwajit05/DS-Algos-Python
/LinkedLists/DoublyLinkedListImple.py
733
4.34375
4
# Doubly Linked List class implementation # Author: Pradeep K. Pant, ppant@cpan.org # Implement basic skeleton for a doubly Linked List # Initialize linked list class class DoublyLinkedListNode(object): def __init__(self,value): self.value = value self.prev_node = None self.next_node = ...
a75396b7a5bbd99390cb90c02857f63c0fc99df4
Bishwajit05/DS-Algos-Python
/Sorting/InsertionSortImple.py
938
4.21875
4
# Insertion Sort Implementation # Author: Pradeep K. Pant, https://pradeeppant.com # Insertion sort always maintains a sorted sub list in the lower portion of the list # Each new item is then "inserted" back into the previous sublist such that the # sorted sub list is one item larger # Complexity O(n2) square # Re...
4ce6d7ff07ffd9a199d96f8c522a4c043c1e9043
erien/algorithms
/mergeSort/python/main.py
2,430
4.34375
4
"""Example implementation of the merge sort algorithm""" TO_SORT = "../../toSort.txt" SORTED = "../../sorted.txt" def read_table_from_file(path: str) -> list: """Reads table from a file and creates appropriate table... I mean list! Args: path: Path to the file Returns: Read table ...
cf63ac1b392a009d0cd50d538ee188e58227a611
gitamolsrivastav/PycharmProjects
/stringSearch1.py
326
3.71875
4
def bruteSearch(text, pattern): i = 0 n = len(text) m = len(pattern) c = 0 diff = n-m while i <= diff: j =0 while j < m and pattern[j] == text[i+j]: j += 1 if j == m: c += 1 i += 1 return c print(bruteSearch("ABCDEFGHEFGTEFG", "EFG...
1ca1bce923a19d6a4849714705a181aee7e6e142
gitamolsrivastav/PycharmProjects
/untitled/test.py
128
3.78125
4
sum=0 for i in range(10): sum=sum+i print (sum) list1= [1,2,3,4,5,6] squares=[num*num for num in list1] print(squares)
bf9c926bf95aa09258f08953412555f51d76ecef
chenghuang2016/computationalphysics_N2013301020125
/chapter1/chapter1.py
990
3.75
4
import numpy as np import matplotlib.pyplot as plt #to import matplotlib's package v=[] #velocity t=[] #time a=10 #assign a value to a b=1 #assign a value to b dt=0.1 #time step v.append(0) #assign a value to first item of v[] t.append(0) #assign a value to first item of t[] end_time=9 #...
569c170f0472869db416dcf2655c97b0a3e8c58f
nakanishi-akitaka/python2018_backup
/1018/python_if_elif_else.py
2,057
4.09375
4
# -*- coding: utf-8 -*- """ https://note.nkmk.me/python-if-elif-else/ Created on Thu Oct 18 13:20:31 2018 @author: Akitaka """ def if_test(num): if num > 100: print('100 < num') elif num > 50: print('50 < num <= 100') elif num > 0: print('0 < num <= 50') elif num...
b259ff92b89f19178ac61519baaf994b80b807d2
nakanishi-akitaka/python2018_backup
/1018/python_function_annotations_typing.py
1,034
3.75
4
# -*- coding: utf-8 -*- """ https://note.nkmk.me/python-function-annotations-typing/ Created on Thu Oct 18 14:12:50 2018 @author: Akitaka """ def func(x, y): return x * y print(func('abc', 3)) print(func(4, 3)) def func_annotations(x: 'description-x', y: 'description-y') -> 'description-return': ...
c84840d398d14fa17f97d8debb3750673fa9c361
nakanishi-akitaka/python2018_backup
/1024/03.04_missing_values.py
1,617
3.765625
4
# -*- coding: utf-8 -*- """ https://jakevdp.github.io/PythonDataScienceHandbook/03.04-missing-values.html Created on Wed Oct 24 14:12:42 2018 @author: Akitaka """ # Trade-Offs in Missing Data Conventions # Missing Data in Pandas ## None:Pythonic missing data #%% import numpy as np import pandas as pd vals...
438ac94d16bbcd7c88c4f963852dff756aec513b
nakanishi-akitaka/python2018_backup
/0618/kennardstonealgorithm/demo_kennardstonealgorithm.py
1,093
3.796875
4
# -*- coding: utf-8 -*- %reset -f """ @author: Hiromasa Kaneko Demonstration of Kennard-Stone algorighm """ import matplotlib.pyplot as plt import numpy as np import kennardstonealgorithm number_of_samples = 50 number_of_selected_samples = 20 # generate samples 0f samples for demonstration X = np.ran...
ce066f1ddad110165ed6ceb5215b017e5d326b07
nakanishi-akitaka/python2018_backup
/1019/02.06_boolean_arrays_and_masks.py
2,464
3.546875
4
# -*- coding: utf-8 -*- """ https://jakevdp.github.io/PythonDataScienceHandbook/02.06-boolean-arrays-and-masks.html Created on Fri Oct 19 14:23:28 2018 @author: Akitaka """ import numpy as np import pandas as pdf rainfall = pd.read_csv('Seattle2014.csv')['PRCP'].values inches = rainfall / 254.0 inches.sha...
ae1ed9d19bf7880f1c161c50f9b9711fd5ec9f5a
nakanishi-akitaka/python2018_backup
/1026/python_string_line_break.py
1,725
3.59375
4
# -*- coding: utf-8 -*- """ https://note.nkmk.me/python-string-line-break/ Created on Fri Oct 26 11:42:14 2018 @author: Akitaka """ s = "Line1\nLine2\nLine3" print(s) s = "Line1\r\nLine2\r\nLine3" print(s) s = '''Line1 Line2 Line3''' print(s) s = ''' Line1 Line2 Line3 ''' pr...
1e26b582441ad129129ff8cbc23fe8b61db8cc39
nakanishi-akitaka/python2018_backup
/1019/python_list_comprehension.py
1,653
3.84375
4
# -*- coding: utf-8 -*- """ https://note.nkmk.me/python-list-comprehension/ Created on Fri Oct 19 12:11:24 2018 @author: Akitaka """ squares = [i**2 for i in range(5)] print(squares) squares = [] for i in range(5): squares.append(i**2) print(squares) #%% odds = [i for i in range(10) if i % 2 =...
793f063cdc0368f0fde435430eaf4095f15f4909
nakanishi-akitaka/python2018_backup
/1025/python_dict_add_update.py
573
3.515625
4
# -*- coding: utf-8 -*- """ https://note.nkmk.me/python-dict-add-update/ Created on Thu Oct 25 10:56:23 2018 @author: Akitaka """ d = {'k1': 1, 'k2': 2} d['k3'] = 3 print(d) d['k1'] = 100 print(d) #%% d1 = {'k1': 1, 'k2': 2} d2 = {'k1': 100, 'k3': 3, 'k4': 4} d1.update(d2) print(d1) d = {'k1': 1...
da656139e50db31e008ae3fb75273d2fae9f8a14
nakanishi-akitaka/python2018_backup
/1030/python_fractions_usage.py
1,851
3.546875
4
# -*- coding: utf-8 -*- """ https://note.nkmk.me/python-fractions-usage/ Created on Tue Oct 30 11:59:04 2018 @author: Akitaka """ from fractions import Fraction print(Fraction(1, 3)) # 1/3 print(Fraction(2, 6)) # 1/3 print(Fraction(3)) # 3 #%% print(Fraction(0.25)) # 1/4 print(Fraction(0.33)...
d3d57dbcde978689fb4122a9266b9ea44a4674c7
mapatelian/holbertonschool-higher_level_programming
/0x0B-python-input_output/3-write_file.py
323
4.25
4
#!/usr/bin/python3 def write_file(filename="", text=""): """Writes a string to a text file Args: filename (str): name of the file text (str): string to be input """ with open(filename, 'w', encoding='utf-8') as filie: characters = filie.write(text) return characte...
ec92ebb83400693ea92230c152ec34b490eb1703
mapatelian/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/0-add_integer.py
475
4.28125
4
#!/usr/bin/python3 def add_integer(a, b=98): """Function that adds two integers. Args: a (int): first integer b (int): second integer Return: sum of the arguments """ if isinstance(a, int) is False and isinstance(a, float) is False: raise TypeError("a must be an i...
fc38d3638b51c84d95b206b769d58739ebef40db
mapatelian/holbertonschool-higher_level_programming
/0x0B-python-input_output/1-number_of_lines.py
270
3.65625
4
#!/usr/bin/python3 def number_of_lines(filename=""): """Counts number of lines Args: filename (str): name of the file """ lines = 0 with open(filename) as filie: for linie in filie: lines += 1 return lines
acf85c1dae18cff881547f333fd36114a70e6601
mapatelian/holbertonschool-higher_level_programming
/0x0B-python-input_output/0-read_file.py
284
4.125
4
#!/usr/bin/python3 def read_file(filename=""): """Reads a text file in UTF-8, prints to stdout Args: filename (str): name of the file """ with open(filename, 'r', encoding='utf-8') as filie: for linie in filie: print(linie, end='')
1763529021e75f71607840c1ce49339c434112dc
mengnan1994/Surrender-to-Reality
/py/1015_numbers_with_1_repeated_digit.py
756
4.0625
4
""" Given a positive integer N, return the number of positive integers less than or equal to N that have at least 1 repeated digit. Example 1: Input: 20 Output: 1 Explanation: The only positive number (<= 20) with at least 1 repeated digit is 11. Example 2: Input: 100 Output: 10 Explanation: The positive numbers ...
cd4ec491be044b97c1360f955d8a4c20a66b9f39
mengnan1994/Surrender-to-Reality
/py/0300_longest_increasing_subsequence.py
2,039
3.8125
4
""" Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Input: [10,9,2,5,3,7,101,18] Output: 4 Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4. Note: There may be more than one LIS combination, it is only necessary for you to re...
17ca1e709eb2cc761116f4543d1361224a86aa47
mengnan1994/Surrender-to-Reality
/py/0621_task_scheduler.py
4,135
4.03125
4
""" Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks. Tasks could be done without original order. Each task could be done in one interval. For each interval, CPU could finish one task or just be idle. However, there is a non-n...
8d0d1c0d0fa04cf810d95fc3c9b251889e995142
mengnan1994/Surrender-to-Reality
/py/0079_word_search.py
1,888
4.03125
4
""" Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once. Example: board = [ ['A','B','C','E'], ['S','F'...
dce4b8aff5e18241e90057acd685bb08802dbd0b
mengnan1994/Surrender-to-Reality
/py/0547_friend_circles.py
3,054
4.09375
4
""" There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, then A is an indirect friend of C. And we defined a friend circle is a group of students who are direct or indirect fri...
8ba426ea97d109147f9d107caf8d3dc82301ff8a
mengnan1994/Surrender-to-Reality
/py/0201_bitwise_and_of_number_range.py
781
3.75
4
""" Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive. Example 1: Input: [5,7] Output: 4 Example 2: Input: [0,1] Output: 0 """ class Solution: def range_bitwise_and(self, m, n): """ 找到 m n 高位连续全 1 的公共部分 """ INT_MA...
36e10e320d6d33593c6a6e9d4fef2340b014339c
mengnan1994/Surrender-to-Reality
/Amazon/vo/my_split.py
457
3.828125
4
def my_split(string, break_pattern): if not string: return [] res = [] start = 0 while start < len(string): end = start while end < len(string) and end - start < len(break_pattern) and string[end] != break_pattern[end - start]: end += 1 res.append(string[start...
6af953862456fe776b538c1556b926e3517695b0
mengnan1994/Surrender-to-Reality
/py/1027_longest_arithmetic_sequence.py
2,592
3.703125
4
""" Given an array A of integers, return the length of the longest arithmetic subsequence in A. Recall that a subsequence of A is a list A[i_1], A[i_2], ..., A[i_k] with 0 <= i_1 < i_2 < ... < i_k <= A.length - 1, and that a sequence B is arithmetic if B[i+1] - B[i] are all the same value (for 0 <= i < B.length -...
674c2d28f821d04ef77b55ae2d8fb8d586e48b28
mengnan1994/Surrender-to-Reality
/py/0774_minimize_max_distance_to_gas_station.py
5,632
3.890625
4
""" On a horizontal number line, we have gas stations at positions stations[0], stations[1], ..., stations[N-1], where N = stations.length. Now, we add K more gas stations so that D, the maximum distance between adjacent gas stations, is minimized. Return the smallest possible value of D. Example: Input: stations = [1...
34b8a172741a2c74ab46a016320e351d2b2c96e2
mengnan1994/Surrender-to-Reality
/py/0741_cherry_pickup.py
6,679
4.21875
4
""" In a N x N grid representing a field of cherries, each cell is one of three possible integers. 0 means the cell is empty, so you can pass through; 1 means the cell contains a cherry, that you can pick up and pass through; -1 means the cell contains a thorn that blocks your way. Your task is to collect maximum num...
67953406305cf5edd64b1f6419a3f686d8ff231a
mengnan1994/Surrender-to-Reality
/py/0518_coin_change_ii.py
2,028
3.859375
4
""" You are given coins of different denominations and a total amount of money. Write a function to compute the number of combinations that make up that amount. You may assume that you have infinite number of each kind of coin. Example 1: Input: amount = 5, coins = [1, 2, 5] Output: 4 Explanation: there are four way...
202bade662bbd859d43c58c1ed371c2c1a0eaf85
mengnan1994/Surrender-to-Reality
/py/0073_set_matrix_zeroes.py
1,615
4.1875
4
""" Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Example 1: Input: [ [1,1,1], [1,0,1], [1,1,1] ] Output: [ [1,0,1], [0,0,0], [1,0,1] ] Example 2: Input: [ [0,1,2,0], [3,4,5,2], [1,3,1,5] ] Output: [ [0,0,0,0], [0,4,5,0]...
6df2a4a01f4fea7e109cf186a6e24753ccd1d1fc
mengnan1994/Surrender-to-Reality
/py/0986_interval_list_intersections.py
1,155
3.578125
4
# Definition for an interval. class Interval: def __init__(self, s=0, e=0): self.start = s self.end = e class Solution: def intervalIntersection(self, A: 'List[Interval]', B: 'List[Interval]') -> 'List[Interval]': if not A or not B: return [] ia = ib = 0 res...
7125c6d0b439a1ebdb177e3aff1482978a99f9ea
mengnan1994/Surrender-to-Reality
/py/1028_recover_a_tree_from_preorder_traversal.py
1,624
3.96875
4
""" We run a preorder depth first search on the root of a binary tree. At each node in this traversal, we output D dashes (where D is the depth of this node), then we output the value of this node. (If the depth of a node is D, the depth of its immediate child is D+1. The depth of the root node is 0.) If a node ha...
dbb8650adc7e732575c33a032004fce683831afa
mengnan1994/Surrender-to-Reality
/py/0646_maximum_length_of_pair_chain.py
1,531
4.28125
4
""" You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. Now, we define a pair (c, d) can follow another pair (a, b) if and only if b < c. Chain of pairs can be formed in this fashion. Given a set of pairs, find the length longest chain which can be formed. You n...
4b46ee573621eef0102127a7b374702a39b4987f
mengnan1994/Surrender-to-Reality
/Amazon/vo/SHIT/041_different_ways_to_add_parenthesis.py
786
3.71875
4
class AddParen(object): def diff_ways(self, expr): try: return int(expr) except: res = [] for i, char in expr: if char in "+-*/": left_operands = self.diff_ways(expr[:i]) right_operands = self.diff_ways(expr[...
60994cfe15582c269491eccbe156747ba5a6e41e
mengnan1994/Surrender-to-Reality
/py/0449_serialize_and_deserialize_bst.py
2,730
3.796875
4
""" Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment. Design an algorithm to serialize and deseria...
6109e08e127c59aa0699d6b7d06e8f65fb1893d7
mengnan1994/Surrender-to-Reality
/py/0151_reverse_words_in_string.py
880
4.375
4
""" Given an input string, reverse the string word by word. Example: Input: "the sky is blue", Output: "blue is sky the". Note: A word is defined as a sequence of non-space characters. Input string may contain leading or trailing spaces. However, your reversed string should not contain leading or trailing spaces. You...
7df424b508611a73c2d34e88541fd8235a0b85f4
mengnan1994/Surrender-to-Reality
/py/0054_spiral_matrix.py
936
3.671875
4
class Solution: def spiralOrder(self, matrix): m = len(matrix) if m == 0: return [] if m == 1: return matrix[0] result = [] flag = "right" print("SHIS") while not len(matrix) == 0 and not len(matrix[0]) == 0: if fla...
39a3284ed87ea811d32f05ba45f749d65968738c
mengnan1994/Surrender-to-Reality
/Amazon/vo/longest_increasing_substring.py
691
3.75
4
class LongestIncreasingSubstring(object): def find_lis(self, string): if len(string) < 2: return string stack = [] max_lis = "" for char in string: print(stack, char, max_lis) if not stack: stack.append(char) elif char.l...
9a77d229e85309f8560dfc23c060622a3429b8c6
mengnan1994/Surrender-to-Reality
/py/0039_combination_sum.py
1,310
3.765625
4
""" Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target. The same repeated number may be chosen from candidates unlimited number of times. Note: All numbers (including target) will b...
aa067900dc8c3409cfe508c5efb1eb80a0bb1a93
mengnan1994/Surrender-to-Reality
/py/0224_basic_calculator.py
5,545
4.3125
4
""" Implement a basic calculator to evaluate a simple expression string. The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and empty spaces . Example 1: Input: "1 + 1" Output: 2 Example 2: Input: " 2-1 + 2 " Output: 3 Example 3: Input: "(1+(4+5+2)-...
ba2b3cc217ee04dd6100f51e137425d064c40c3f
mengnan1994/Surrender-to-Reality
/py/0307_range_sum_query.py
1,676
3.96875
4
""" Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. The update(i, val) function modifies nums by updating the element at index i to val. Example: Given nums = [1, 3, 5] sumRange(0, 2) -> 9 update(1, 2) sumRange(0, 2) -> 8 Note: The array is only modifiable by th...
b284ad8f74531a343a387f35e167f6a884e3fb29
mengnan1994/Surrender-to-Reality
/Amazon/vo/traverse_with_budget.py
906
3.515625
4
import sys sys.path.append("../..") from playground.TreePlayground import BinaryTreeUtil, TreeNode def traverse_with_budget(root, budget): import collections if not root: return 0 queue = [root] cnt = 0 level = 1 ternimate = False while queue: temp_queue = [] for ...
09a4bc3f63a7ee69c1f145e76513e0d0228c6314
mengnan1994/Surrender-to-Reality
/Amazon/vo/SHIT/047_group_anagrams.py
439
3.515625
4
class AnagramsUtil(object): def group(self, words): import collections def _encode(word): encoding = [0] * 26 for char in word: encoding[ord(char) - ord('a')] += 1 return tuple(encoding) counter = collections.defaultdict(list) for...
18666814c170eba13d440049282e31f6adbf3806
mengnan1994/Surrender-to-Reality
/py/0041_first_missing_positive.py
2,919
3.859375
4
""" Given an unsorted integer array, find the smallest missing positive integer. Example 1: Input: [1,2,0] Output: 3 Example 2: Input: [3,4,-1,1] Output: 2 Example 3: Input: [7,8,9,11,12] Output: 1 Note: Your algorithm should run in O(n) time and uses constant extra space. 0854 -> 1010 (66) ac 13.19% """ class So...
af0bef46532b1e7251fc28f9c8813ed368e27fda
mengnan1994/Surrender-to-Reality
/Amazon/vo/OOD/Singleton.py
313
3.53125
4
class Singleton(object): _instance = None def __new__(cls, *args, **kwargs): if not cls._instance: cls._instance = super(Singleton, cls).__new__(cls, *args, **kwargs) return cls._instance class Instance(Singleton): a = 100 a = Instance() b = Instance() print(a is b)
c5aee92c11398519052dc00825cbacd7c12b4ddf
mengnan1994/Surrender-to-Reality
/py/0402_remove_k_digits.py
2,333
3.734375
4
""" Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. Note: 1. The length of num is less than 10002 and will be ≥ k. 2. The given num does not contain any leading zero. Example 1: Input: num = "1432219", k = 3 Output: "1219" Ex...
e62c328a44082b98ec071956086a84ac68f25871
mengnan1994/Surrender-to-Reality
/py/0862_shortest_subarray_sum_at_least_k.py
1,107
3.8125
4
""" Return the length of the shortest, non-empty, contiguous subarray of A with sum at least K. If there is no non-empty subarray with sum at least K, return -1. Example 1: Input: A = [1], K = 1 Output: 1 Example 2: Input: A = [1,2], K = 4 Output: -1 Example 3: Input: A = [2,-1,2], K = 3 Output: 3 Note: 1. 1 <= A...
40042792515af1f36829f92aaa330ac6cb17555e
mengnan1994/Surrender-to-Reality
/py/0186_reverse_words_in_a_string_ii.py
1,254
4.25
4
""" Given an input string , reverse the string word by word. Example: Input: ["t","h","e"," ","s","k","y"," ","i","s"," ","b","l","u","e"] Output: ["b","l","u","e"," ","i","s"," ","s","k","y"," ","t","h","e"] Note: A word is defined as a sequence of non-space characters. The input string does not contain leading ...
ded18bde62c9775b53cf58a4646b4c3c02b26f11
mengnan1994/Surrender-to-Reality
/py/0138_copy_list_with_random_pointer.py
2,622
3.9375
4
""" A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy of the list. SCORE: 1930 -> 1946 1 attempt (re) 100% """ # Definition for singly-linked list with a random pointer. class RandomListNode(object): def __init...
92e3a390be5408463e122b9f188c0d6a4a56c2b4
mengnan1994/Surrender-to-Reality
/py/0049_group_anagrams.py
1,245
4.0625
4
""" Given an array of strings, group anagrams together. Example: Input: ["eat", "tea", "tan", "ate", "nat", "bat"], Output: [ ["ate","eat","tea"], ["nat","tan"], ["bat"] ] SCORE: 1950 -> 2004 -> 2010 TLE ac 40.03 """ import collections class Solution(object): def group_anagrams(self, strs): ...
5b23711adaf892909b6209c782cead04b7d52722
mengnan1994/Surrender-to-Reality
/py/0097_interleaving_strings.py
3,518
3.9375
4
""" Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. Example 1: Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac" Output: true Example 2: Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbbaccc" Output: false """ import numpy as np class Solution(object): def is_interleave_dp(self, ...
2f49b448e55de701569925e9f71c956bd6e1dcdf
mengnan1994/Surrender-to-Reality
/py/0098_valid_binary_search_tree.py
1,395
4.1875
4
""" Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: 1. The left subtree of a node contains only nodes with keys less than the node's key. 2. The right subtree of a node contains only nodes with keys greater than the node's key. 3. Both the left and right ...
83943d7da7860592c34b57ec9ee3df26d3f01de0
dhbandler/Projects
/HangmanGraphics.py
4,572
3.6875
4
#Daniel Bandler #4/4/18 #HangmanGraphics.py --- makes a hangman game graphically from ggame import * from random import randint def pickWord(): #Selects the word num = randint(0,1) choices = ["praetor", "purgatory", "perestroika","airport","realpolitik","beelzebub","fraternal","schadenfreude","intelligen...
9e8720197d8f2144046315ac25520431fbab8d7f
Takato-Nakaseko/TK
/Parking/parkingArea.py
1,188
3.5
4
#Reserve import parking as pk class ParkingArea: def __init__(self): pk1 = pk.Parking() pk2 = pk.Parking() pk3 = pk.Parking() pk4 = pk.Parking() self.__area = [] self.__area.append(pk1) self.__area.append(pk2) self.__area.append(pk3) ...
edd0fa92f5ee53fb114cb39361c00a0882cc12e6
ARTIC-TTS-experiments/2021-ICASSP
/lib/densenet.py
2,121
3.515625
4
from keras.layers import BatchNormalization, Dropout, Flatten, Dense, Activation import numpy as np # Function for creating a dense layer(s) def dense_block(layer, n_neurons, flatten=True, inner_activation='relu', last_activation='sigmoid', batch_norm=True, batch_norm_after_activation=True, dropout=No...