blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
62527a4a9a630027054825f3d25a4dc9ed90fb4f
xiaoluome/algorithm
/Week_01/id_34/leetcode-189.py
1,620
3.859375
4
from typing import List class Solution: # 重伤, 提交代码说是执行时间过长 43333333 def rotate(self, nums: List[int], k: int) -> None: """ Do not return anything, modify nums in-place instead. """ n = len(nums) if n == 0 or n == 1: return if k > n: k =...
4b11ba24810fbcf5f61b3b635630e384f3189475
tarunlalchandani/DjangoPython
/pythonLoops.py
213
4.03125
4
KrsnaNames = {"Mukunda","Govinda","Tirupati"} print(KrsnaNames) print(KrsnaNames) for name in KrsnaNames: print(name) age = 20 while(age<30): print("Hare Krsna") age += 1 for i in range(3,9): print(i)
9e3b4c6752b313508a6ec04c073502b57ab5fe62
Raman5837/Talking-Dictionary
/main.py
10,454
3.671875
4
from os import close from tkinter import * from tkinter import messagebox # to use it in iexit() function. import json from difflib import get_close_matches import pyttsx3 # to initiate python text-to-speech class, we'll create a object of this class. engine = pyttsx3.init() voices = engine.getProperty('voice...
8f754555f25a4e1d09d0390e22bbe6e042ecc8e7
ForestPride/python-practice
/move-shape.py
683
3.921875
4
from graphics import * def moveShape(shape, newCenter): # get the old center. oldCenter = shape.getCenter() # move the shape to the new center. shape.move(newCenter.getX() - oldCenter.getX(), newCenter.getY() - oldCenter.getY()) def main(): # draw a window win = GraphWin("move the circle",...
407d21fe4a7c0531fd3f9f2ace3e19008639cf06
miroslavgasparek/python_intro
/regressions.py
3,307
3.921875
4
# 28 May 2018 Miroslav Gasparek # Python bootcamp, lesson 37: Performing regressions # Import modules import numpy as np import pandas as pd # We'll use scipy.optimize.curve_fit to do the nonlinear regression import scipy.optimize import matplotlib.pyplot as plt import seaborn as sns rc={'lines.linewidth': 2, 'axes....
2c9da507053689dee6cc34724324521983ea0c8c
miroslavgasparek/python_intro
/numpy_practice.py
1,834
4.125
4
# 21 February 2018 Miroslav Gasparek # Practice with NumPy import numpy as np # Practice 1 # Generate array of 0 to 10 my_ar1 = np.arange(0,11,dtype='float') print(my_ar1) my_ar2 = np.linspace(0,10,11,dtype='float') print(my_ar2) # Practice 2 # Load in data xa_high = np.loadtxt('data/xa_high_food.csv',comments='#')...
e91d8fc8efc690ce20f022f92382d668e372986c
miroslavgasparek/python_intro
/image_proc_practice2.py
7,292
3.71875
4
# 14 July 2018 Miroslav Gasparek # Python bootcamp, lesson 40: Image processing practice with Python # Import modules import numpy as np import matplotlib.pyplot as plt import scipy.ndimage import skimage.io import skimage.segmentation import skimage.morphology # Import some pretty Seaborn settings import seaborn a...
c229d1876e2806036441777368353cb25da31647
chenmengsheng/-
/python资料/F_AKindSorting.py
1,001
3.65625
4
class Rectangle: def __init__(self, _number, _length, _width): self.number, self.length, self.width = _number, _length, _width def __repr__(self): # __repr__ return '%d %d %d' % (self.number, self.length, self.width) def __lt__(self, other): if self.number != other.number:...
23e2a0d9f7d8ca80413df8a5a36800ae70cd046e
chenmengsheng/-
/python资料/五子棋.py
2,586
3.90625
4
# coding: utf-8 import random import sys # 定义棋盘的大小 BOARD_SIZE = int(input('请输入棋盘大小:')) #BOARD_SIZE = int(BOARD_SIZE) high = [] wide = [] num = [] num1 = [] num2 = [] # 定义一个二维列表来充当棋盘 board = [] def initBoard() : # 把每个元素赋为"╋",用于在控制台画出棋盘 for i in range(BOARD_SIZE) : row = ["╋"] * BOARD_SI...
9e0de83bf0cbc251455b0028170753e2660bf9ae
chenmengsheng/-
/python资料/Fraction2.py
598
3.734375
4
import math class Fraction: def __init__(self, _up, _down): # 构造方法 Constructor g = math.gcd(_up, _down) self.up = _up // g self.down = _down // g def __str__(self): return "%d/%d" % (self.up, self.down) def add(self, other):#bad smell c = Fraction(0,...
6cb3659d15e480f08ad3fca096cff7a98e226350
chenmengsheng/-
/python资料/P20/P19.py
415
3.671875
4
''' 19. 从键盘上输入两个不超过32767的整数,试编程序用竖式加法形式显示计算结果。 例如: 输入 123, 85 显示:  123   +   85   -------------     208 ''' a, b = 123, 85 wid = 10 # 宽度 print(('%' + '%d' % wid + 'd') % a) print(('+%' + '%d' % (wid - 1) + 'd') % b) print('-' * wid) print(('%' + '%d' % wid + 'd') % (a + b))
f05a74a96c8113808f01e0d6a341eccb3262f111
pshashank64/tathastu_week_of_code
/day1/program4.py
224
3.84375
4
cp = float(input("Enter the cost price: ")) sp = float(input("Enter the selling: ")) profit = sp - cp newsp = 1.05 * profit + cp print("The profit is", profit) print("new selling price to increase profit by 5% is: ", newsp)
8d3a4af611f5dde4daa4a0f7ecc1bcced8c6d29d
pshashank64/tathastu_week_of_code
/day1/progam3.py
196
4.03125
4
x = float(input("ENter first number: ")) y = float(input("Enter the second number: ")) x = x + y y = x - y x = x - y print("Swapping result: ") print("Number 1 is: ", x) print("Number 2 is: ", y)
877150ed0d4fb9185a633ee923daee0ba3d745e4
nmessa/Raspberry-Pi
/Programming/SimplePython/name4.py
550
4.125
4
# iteration (looping) with selection (conditions) again = True while again: name = raw_input("What is your name? ") print "Hello", name age = int(raw_input("How old are you? ")) newage = age + 1 print "Next year you will be ", newage if age>=5 and age<19: print "You are still in school...
048d3a41084ad1f33b86e558c98ec2a0c582fb95
GuochangYuan/MyPython
/hello.py
161
3.59375
4
if __name__=='__main__': fp=open('test1.txt','w') string=input('please input a string:\n') string=string.upper() fp.write(string) fp.close() print(string)
38c5662d6b91010f45f5628c79e5ef886bdf0133
LuisGomez11/Python
/Corte 1/TALLER #3 - GESTION DE CADENAS Y LISTAS/SextoEjercicio.py
1,451
3.96875
4
def pedirNumero(mensaje): correcto = False num = 0 while(not correcto): try: num = int(input(mensaje)) correcto = True except ValueError: print('Error, digite un numero entero') return num tam = pedirNumero('Digite el numero de datos que ingresara: ')...
7597d5bf1d1218165c986537b815a01ad9cdbdb6
LuisGomez11/Python
/Corte 1/TALLER #3 - GESTION DE CADENAS Y LISTAS/SegundoEjercicio.py
426
3.84375
4
cadena = input('Digite una cadena de texto: ') def numVeces(cadena): contador = 0 for vocal in cadena: if (vocal.upper()=='A' or vocal.upper()=='E' or vocal.upper()=='I' or vocal.upper()=='O' or vocal.upper()=='U'): contador+=1 if contador==0: print("No se encuentra volcales en ...
753122c74d0c5783b87c29158f5bea1407139e6a
LuisGomez11/Python
/Corte 1/TALLER #3 - GESTION DE CADENAS Y LISTAS/OctavoEjercicio.py
856
3.921875
4
def pedirNumero(mensaje): correcto = False num = 0 while(not correcto): try: num = int(input(mensaje)) correcto = True except ValueError: print('Error, digite un numero entero') return num listaFibonacci = [] listaPrimos = [] tam = pedirNumero('Digit...
65514aad9b6130592e8674b4f47a0ec914abbdc1
LuisGomez11/Python
/Corte 1/TALLER #3 - GESTION DE CADENAS Y LISTAS/TercerEjercicio.py
444
3.625
4
cadena = input('Digite una cadena de texto: ') def impDosPrimerosCar(cadena): print('Primeros dos caracteres:',cadena[0:2]) def impTresPrimerosCar(cadena): print('Primeros tres caracteres:',cadena[0:3]) def impCadaDosCar(cadena): print('Cada dos caracteres',cadena[::2]) def impCadenaInv(cadena): print(...
80a517636f48d65292a13af089509a2c3cca4089
VDCasper/GameLife
/proba.py
885
3.546875
4
import numpy as np array_copy = np.array([(0,0,0,1,1,1), (1,1,0,1,0,1), (0,0,0,1,1,1), (1,0,0,1,0,1), (1,0,1,1,0,1), (1,1,0,0,0,0)]) while np.sum(array_copy) > 0: j = 0 while j < 9: i = 0 whi...
20fb4ee755500d04ad055a843c10daa35cdab8b3
vchernoy/coding
/leetcode/medium/clone_graph/clone_graph.py
714
3.609375
4
# Definition for a undirected graph node # class UndirectedGraphNode: # def __init__(self, x): # self.label = x # self.neighbors = [] class Solution: # @param node, a undirected graph node # @return a undirected graph node def cloneGraph(self, node): graph = {} copy = s...
c099d8ea19bd0459fa0a1c0ce9419c6237d7c647
bbeuro132/My_python
/실습자료/oper.py
1,153
4.09375
4
num1 = 3 num2 = 4 print(type(num1)) print('덧셈 :', num1+num2) print('곱셈 :', num1*num2) print('나머지 :', num1%num2) res = num1 + num2 print('res : ', res) res += num1 print('res : ', res) # 비교 연산자 print(num1 > num2) print(num1 < num2) # 논리 연산자 print(num1 > num2 and num1 < num2) print(num1 > num2 or num1 < num2) print...
3c0491e1e79bdbc716907f9713175dce32afada7
bbeuro132/My_python
/실습자료/반복문.py
1,915
3.921875
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: count = 1 while count <= 5: print(count) count+=1 # In[ ]: while True : stuff = input("String to capitalize [type q to quit] : ") if stuff == "q": break print(stuff.capitalize()) # In[ ]: while True: value = input("Integer, please...
f8b7b115d46331ca315b36ef795b5d0a81f0a659
shubhamkkr/SpyChat
/main.py
6,659
3.859375
4
from steganography.steganography import Steganography from datetime import datetime def entry(): name = raw_input("What's your spy name??") if len(name) > 0: print("Yay, the name is good.") salutation = raw_input("What would be your spy salutation, Mr. ,Mrs or Ms.") full_name = salutati...
b35e7b8bf2cdd9c34f0867aab741496aca95478e
anikas1/AnatoLearn
/pMLevel1Comp.py
1,057
3.5625
4
""" Authors: Anika Suman & Ayush Khanna Date: 9/7/21 Class: Math 241 Scientific Computing Professor: Ben Marlin """ import pygame #initializes the pygame workspace pygame.init() #sets the screen size to 960 x 540 pixels screen = pygame.display.set_mode((960, 540)) pygame.display.set_caption('Practice M...
b6b766c81598c8dab4b2c9b3dcb9979cc87409b6
famasoon/kyopro
/atcoder/Children and Candies /solve.py
205
3.890625
4
def sigma(n: int) -> int: sum = 0 if n != 1: sum += n sum += sigma(n-1) else: sum += n return sum return sum n = int(input()) total = sigma(n) print(total)
d8482da6b9983d990da980c3a5edab0c49a28229
arubikira/Python
/function.py
185
3.890625
4
x = int(input('masukkan')) y = int(input('masukkan')) def jumlah(x,y): hasil = x+y return hasil print('hasil dari',x,'+',y,'=', jumlah(x,y)) k = jumlah(2,4)+1 print(k)
1ab66596a2a05802cc2d0461d9098dfb8432dd9c
arubikira/Python
/harmonic number.py
236
3.75
4
angka = int(input('masukkin angka: ')) Total = 0 pembagi=0 #for i in range(1, n): while angka > 0: pembagi+=1 bil = 1/pembagi print(bil) simpan = Total+bil Total = simpan angka-=1 print('hasilnya = ', Total)
bea0c4098b659deba7dd177a49ca8a478f89fc72
kamilam1987/EmergingTechnologies
/python-fundamentals/gcdFunction.py
431
3.78125
4
# Function with two arguments def gcd(a, b): """ Returns the greatest common divisor of a and b """ if a < b: a, b = b, a while b > 0: a, b = b, a % b return a print(gcd(50, 20)) print(gcd(22, 143)) #LCM with two numbers def lcm(a, b): if a > b: a, b = b...
40ba01f5f891bfbfc7dd3b1658cb1915d2d42073
Navyasharma96/tkinter
/tik1.py
293
3.5
4
import tkinter v=tk.Tk() v.title('counting second') Button1=Button(guitext='stop',width='25',command=v.destroy) Button2=Button(guitext='cancle',width='25',command=v.destroy) Button3=Button(guitext='submit',width='25',command=v.destroy) Button1.pack() Button2.pack() Button3.pack() v.mainloop()
9583f9a916001bd02034aa6974e6d0969e6ec3ff
dessHub/binary_search
/test_binary.py
608
3.5
4
class BinarySearch(list): def __init__(self, a, b): super(BinarySearch, self).__init__(range(b, a * b + b, b)) self.length = a def search(self,value): index = 0 dict_obj = {"count":0,"index": 0} first = 0 last = self.length - 1 while last >= first : dict_obj["count"] = dict...
c6c26b0f16f103b34be9c40c83a61d6de3ed5642
Kabi4/AutoMatedStuffWithPython
/rock_paper_sccisors.py
1,808
3.9375
4
import random def play_twice(): play=str(input("Do you want to play again??Y/N: ")).lower() if play=='y': game() elif play=='n': print("Thankyou!! you for playing") else: print("Your output didn't match Y or N please try again!!!") play_twice() def compute...
5e939364601856aa71a1c5e624218b8867629a7e
Teslothorcha/holbertonschool-higher_level_programming
/0x0B-python-input_output/2-read_lines.py
590
3.5
4
#!/usr/bin/python3 def read_lines(filename="", nb_lines=0): c = 0 c_ = 0 with open(filename, encoding="utf-8") as file: for line in file: line = file.readline() if line[-1:] == '\n': c += 1 c += 1 if nb_lines <= 0 or nb_lines >= c: with...
91dc6c6f946fa458ee16d6d806ce6c76386bc9c9
Teslothorcha/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/2-matrix_divided.py
883
3.8125
4
#!/usr/bin/python3 """ This divide a matrix into a given number and return a new matrix """ def matrix_divided(matrix, div): """ checks data accuracy to perfom division """ msg_1 = "matrix must be a matrix (list of lists) of integers/floats" msg_2 = "Each row of the matrix must have the same size"...
cd0c13a1013724e1ec7920a706ee52e2aa0e9a96
Teslothorcha/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/0-add_integer.py
411
4.15625
4
#!/usr/bin/python3 """ This function will add two values casted values if necessary (int/float) and return the addition """ def add_integer(a, b=98): """ check if args are ints to add'em' """ if not isinstance(a, (int, float)): raise TypeError("a must be an integer") if not isinstance(b, (...
729e9edc4bbf1616c53c94eac35675b1a4a37edd
vsmvignesh/pyprograms
/cadbury_problem.py
909
4
4
#!/usr/bin/python import sys def create_combination(l1,l2,b1,b2): tot_count=0 for l in range(l1,l2+1): for b in range(b1,b2+1): ret=count_bars(l,b) print("Chocolate Bar size ({0} x {1}), can be distributed to \"{2}\" children...".format(l,b,ret)) tot_count=tot_count+...
cc67778fcffa07c24fa7ab126f63a0d597398859
valoto/python_trainning
/aula1/script.py
660
3.875
4
#!/usr/bin/python3 print("Hello, world!") var = False if var: print("Var é verdadeiro") else: print("Var é falso") print("Pode apostar nisso!") #Comentario em Linha """Bloco de Comentarios """ print(type(1)) print(type("Igor")) print(type(var)) print(type(1.5)) print(type([])) print(type({})) print(t...
353bb70b7acbbedf2381635d1d554d117edc6b7f
valoto/python_trainning
/aula2/strings.py
780
4.125
4
var = "PYT''\"HON" var = 'PYTH"ON' # TODAS MAIUSCULAS print(var.upper()) # TODAS MINUSCULAS print(var.upper()) # SUBSTITUI T POR X print(var.replace('T', 'X')) # PRIMEIRA LETRA MAIUSCULA0 print(var.title()) # CONTA QUANTIDADE DE LETRAS T print(var.count('T')) # PROCURAR POSIÇÃO DA LETRA T print(var.find('T')) # ...
77865bbaf68b29ecbc5e9c5ece9c2e6f6ce2a9db
elocamp/Fundamentos-de-Problemas-Computacionais
/VA3/pilha.py
867
3.859375
4
class Pilha: def __init__(self): self.lista = [] self.topo = None def __pilha_vazia(self): if self.topo == None: return True else: return False def empilhar(self, valor): self.lista.append(valor) self.topo =...
3e6bd4c07e4ebf9aae3044e62e76532954e58e74
elocamp/Fundamentos-de-Problemas-Computacionais
/lista_linear.py
2,071
3.75
4
class Nodo: def __init__(self, valor): self.valor = valor self.proximo = None def mostrar_nodo(self): print(self.valor) class Lista: def __init__(self): self.primeiro = None def inserir_lista(self, valor): novo = Nodo(valor) novo.p...
9ea0061578d975f5b3480ec73db416db19a5619f
mpernow/eratosthenes
/db_entry.py
3,832
4
4
# Implementation of class for database entry # Author: Marcus Pernow # Date: January 2020 import uuid # For random filenames class DB_Entry(): """ Definition of a database entry. Contains the required fields and methods """ def set_id(self): """ Sets the unique id of the entry, with an increasing counter ...
499570e9e7d06c0f5f19abd984d63c5fd6763123
wbsth/mooc-da
/part05-e12_coefficient_of_determination/src/coefficient_of_determination.py
910
3.671875
4
#!/usr/bin/env python3 import pandas as pd from sklearn import linear_model def coefficient_of_determination(): # loading the data, tab as separator df = pd.read_csv('src/mystery_data.tsv', sep='\t') # different dataframes for X's and Y's columns x = df.loc[:, 'X1':'X5'] y = df.loc[:, 'Y'] ...
09b02405344102c647fd9fe5745b540957d7bd72
wbsth/mooc-da
/part02-e09_rational/src/rational.py
2,219
3.890625
4
#!/usr/bin/env python3 class Rational(object): def __init__(self, numerator, denominator): self.numerator = numerator self.denominator = denominator def __str__(self): return f'{self.numerator}/{self.denominator}' def __add__(self, numb): new_denom = int(self.denominator) ...
5e6e2e5e3d29dc46c9e5a9e7bc49a5172fbbb3cb
wbsth/mooc-da
/part01-e07_areas_of_shapes/src/areas_of_shapes.py
935
4.1875
4
#!/usr/bin/env python3 import math def main(): while True: shape = input('Choose a shape (triangle, rectangle, circle): ') if shape == '': break else: if shape == 'rectangle': r_width = int(input("Give width of the rectangle: ")) r_h...
1bc9afe41a145b0feba124487c65ccb717803f58
SanjoSolutions/tic-tac-toe-solver
/solve_tic_tac_toe.py
3,143
3.5
4
from generate_tic_tac_toe_tree import generate_tic_tac_toe_tree from main import history_to_state, determine_result, Result def create_tic_tac_toe_solving_tree(): tree = generate_tic_tac_toe_tree() calculate_percentages_of_loose_outcomes_recursion(tree.root) return tree def calculate_percentages_of_loos...
3d1b52f962c935e2426483a007fd9cd37839ac31
AravindSK1/Code-Everyday
/01. Python/Day 0018.py
4,120
4.3125
4
""" Singly Linked list 1. class nodes : data, next 2. class linked list: impor 3. add nodes to linked list 4. print linked list """ class Nodes: def __init__(self, data): self.data = data self.next = None # stores the node object class LinkedList: # initialize head as None for...
56ea90dad7f9aac37497e783af60b901bf31da4a
adityaronanki/pytest
/assignment_06.py
1,946
3.734375
4
__author__ = 'Khali' from placeholders import * # instead of returning a list of tuples like zip, generate it incrementally (refer to the generators and iterators lessons) # a tuple at a time. Use exception control flow to write elegant code. def generator_zip(seq1, seq2, *more_seqs): items=[] if le...
a2ba2d26676a7f57245278da36b71572aed3c134
KrastinsE/EDIBO
/Python/dev/history20200813c.py
2,242
3.578125
4
1: def f(): pass 2: f() 3: type(f) 4: def f(): print("Hello") 5: def f(): print("Hello") 6: def f(): print("Hello") 7: f() 8: def g(): a = 22 print(a+3) 9: g() 10: def g(a): print(a+3) 11: g() 12: def g(a): print(a+3) 13: g() 14: g(a) 15: g(20) 16: g() 17: g(...
6e8f6b42a872c1aacf7daf1fc4042213f5c7d008
djmattyg007/IdiotScript
/idiotscript/InstructionList.py
2,581
3.859375
4
class InstructionList(object): ''' An instruction list is the result of parsing an idiotscript script. It may have nested instruction lists, which is the result of branching in the idiotscript. This implementation uses a linked list. ''' def __init__(self): self._head = None ...
f613fa6f9dbf7713a764a6e45f29ef8d67a5f39c
abhishek0chauhan/rock-paper-scissors-game
/main.py
1,431
4.25
4
import random rock = ''' _______ ---' ____) (_____) (_____) (____) ---.__(___) ''' paper = ''' _______ ---' ____)____ ______) _______) _______) ---.__________) ''' scissors = ''' _______ ---' ____)____ ______) __________) (____) -...
28b93baa03b5cde60026d8db53eef1be2078100a
srikanthpragada/09_MAR_2018_PYTHON_DEMO
/assignments/find_positions.py
139
3.625
4
st = "Python Programming is fun" sub = "n" pos = st.find(sub) while pos >= 0: print("Found at ", pos) pos = st.find(sub, pos + 1)
011de1ba4282c802896eb1dcab9dfed9d40e4b1a
srikanthpragada/09_MAR_2018_PYTHON_DEMO
/libdemo/get_country_info.py
253
3.8125
4
import requests code = input("Enter country code :") resp = requests.get("https://restcountries.eu/rest/v2/alpha/" + code) info = resp.json() if 'name' in info: print(info["name"]) print(info["capital"]) else: print("Country Not Found!")
131dadb4a22587791dc04c17e7749d3fefc8b0e6
srikanthpragada/09_MAR_2018_PYTHON_DEMO
/oop/even_iterator.py
466
3.90625
4
class EvenIterator: def __init__(self,start, end): self.start = start if start % 2 == 0 else start + 1 self.end = end def __iter__(self): self.value = self.start return self def __next__(self): if self.value <= self.end: v = self.value self....
afc502fd894e0319fb56f6217f21a3b934829d0c
srikanthpragada/09_MAR_2018_PYTHON_DEMO
/db/add_emp.py
539
3.984375
4
import sqlite3 try: con = sqlite3.connect(r"e:\classroom\python\hr.db") cur = con.cursor() # take input from user ename = input("Enter name :") salary = input("Enter salary : ") dept = input("Enter dept id :") # get next emp id cur.execute("select max(empid) + 1 from emp") empid = ...
7bcab8db6bbb8aac0814cf48b5b97583c14e1d67
srikanthpragada/09_MAR_2018_PYTHON_DEMO
/oop/Product.py
803
3.59375
4
from Account import * class Product: def __init__(self, name, price=None): # instance variables self.__name = name self.__price = price @property def netprice(self): return self.__price * 1.12 def print(self): print('Name ', self.__name) print("Price ",...
49def8344863803a18df98709fa803d5076cc6e7
Roma-coder/Python_Labs
/Lab_4/main.py
914
3.546875
4
from datetime import datetime from patient import Patient patients = [] with open('data.txt', 'r', encoding='utf-8') as dataFile: for line in dataFile: words = line.split(';') p = Patient( words[0], words[1], words[2], datetime(year=int(words[3]), mo...
a0516d0ca0791c8584b51cee2e354113f03a74f1
LFBianchi/pythonWs
/Learning Python/Chap 4/p4e6.py
839
4.125
4
# -*- coding: utf-8 -*- """ Exercise 5 of the Part IV of the book "Learning Python" Function "addDict" - Returns a union of dictionaries Created on Mon Nov 9 11:06:47 2020 @author: lfbia """ def addList(list1, list2): return list1 + list2 def addDict(aurelio, michaellis): D = {} for i in aurelio.keys(): ...
fd089aac91671c8504e125d4e8db6e058c5afda7
LFBianchi/pythonWs
/HackerRank/hashTablesRansomNote.py
1,168
3.765625
4
#!/bin/python3 import math import os import random import re import sys # Complete the checkMagazine function below. """ def checkMagazine(magazine, note): #using dictcomp hashWords = {x: magazine.count(x) for x in set(note)} if list(hashWords.values()).count(0): print('No') else: ha...
474b8dfed6ba1bab4d2f026b025c04407c45d776
LFBianchi/pythonWs
/Learning Python/Chap 3/p3e4d.py
127
3.640625
4
L = [2 ** i for i in range(7)] X = 5 pot = 2 ** X if pot in L: print('at index', L.index(pot)) else: print(X, 'not found')
4957835e457481b3dc71f11f9f6d54d6ba08a01a
LFBianchi/pythonWs
/HackerRank/treeLevelOrderTraversal(while).py
534
3.828125
4
""" Node is defined as self.left (the left child of the node) self.right (the right child of the node) self.info (the value of the node) """ def levelOrder(root): nodeQueue = [root] levelList = [] while nodeQueue: if nodeQueue[0].left: nodeQueue.append(nodeQueue[0].left) if...
89761057d2885d4285e7031cee4c0a230a95ead8
LFBianchi/pythonWs
/HackerRank/nestedLists.py
430
3.75
4
def secondWorst(arr): grades = {} for i in arr: grades[i[0]] = i[1] arr = sorted(list(set(grades.values()))) ans = [i for i in grades if grades[i] == arr[1]] return sorted(ans) if __name__ == '__main__': arr = [] for _ in range(int(input())): name = input() scor...
312967267570056e85591c7224e488a616acc877
LFBianchi/pythonWs
/Learning Python/Chap 4/p4e10.py
833
4.03125
4
# -*- coding: utf-8 -*- """ Exercise 10 of the Part IV of the book "Learning Python" Timing three ways to get the square root of a number Created on Mon Nov 9 16:12:52 2020 @author: lfbia """ #Modified from file timeseqs.py #Test the relative speed of iteration tool alternatives. import sys, math, timer1 as timer #...
26ab425409f7f7944820a460b4676c1cbd54a16d
nasrinsultana014/HackerRank-Python-Problems
/Solutions/Problem08.py
774
3.515625
4
if __name__ == '__main__': x = int(input()) y = int(input()) z = int(input()) n = int(input()) permutationCollection = [] for i in range(x+1): for j in range(y+1): for k in range(z+1): sum = i+j+k if sum != n: oneCombo ...
d3e64c5bfe6b5508c458a2bc76e40fa6ef0f4019
nasrinsultana014/HackerRank-Python-Problems
/Solutions/Problem14.py
536
4.21875
4
def swap_case(s): characters = list(s) convertedCharacters = [] convertedStr = "" for i in range(len(characters)): if characters[i].isupper(): convertedCharacters.append(characters[i].lower()) elif characters[i].islower(): convertedCharacters.append(characters[i]...
e25145805f35e7124c290af6ea774296b6a83a67
DiegoCefalo/GetVidya
/tools/sql_tools.py
5,271
3.53125
4
from config.configuration import engine import pandas as pd def collection(): """ Queries all the games in the database Args: Returns: json with all the games in the database """ query = f""" SELECT * FROM videogame """ datos = pd.read_sql_query(query,engine)...
394988fc43347898e589148f21777263d78b6bc5
Israel0806/python
/Ejercicios-Python/Tarea2/asd.py
468
3.84375
4
##matriz multi def multiplicacion(A,B): C=[] ##m=filas de A, p=filas de B n=co m=3 n=2 p=2 q=3 for k in range(m): C.append([0]*q) for i in range(q): C[k][i]=0 for i in range(m): for j in range(n): for k in range(q): ...
1ac8195b75d4ea99794791ab5bc6e7a502b1fe06
Israel0806/python
/Ejercicios-Python/Tarea recursiva Segovia/Ejer5.py
120
3.875
4
def serie(n): if n==0: return 3 return 3*serie(n-1)+4 n=int(input("Ingrese numero: ")) print (serie(n))
26a225ba03cb7283c98b6a587879f7a0324e895b
Tralo/python_study
/demo/exercise.py
315
3.828125
4
#!/usr/bin/env python # coding=utf-8 weight = 60 height = 1.65 result = weight / (height * height) print('BMI的值为: ',result) if result < 18.5: print('过轻') elif result < 25: print('正常') elif result < 28: print('过重') elif result < 32: print('肥胖') else: print('严重肥胖')
4f28a7b82294ded693713370383e2dfce38063ab
CristyTarantino/toolkitten
/summer-of-code/week-01/wk1-homework-submissions/soc-wk01-cert-cristina-tarantino.py
18,339
4.21875
4
""" Description - Week 1 homework for 1mwtt program Author - Cristina Tarantino Date - July 2018 """ from datetime import datetime from random import randint days_in_year = 365 # year leap. Source https://en.wikipedia.org/wiki/Year#Variation_in_the_length_of_the_year_and_the_day days_in_year_leap = 365.2422 # 60 m...
ae0fe95a834ff25df45e0723c01267dbfb50d638
thonyeh/Linear-Programming
/simplex.py
7,559
3.890625
4
from math import * from time import sleep from numpy import * from Tkinter import * print 'A CONTINUACION INGRESE LOS DATOS DEL PROBLEMA A MINIMIZAR.' print '' def vuelva(): print 'INGRESE LOS DATOS DE OTRO PROBLEMA:' print '' main() def main(): A=[] b=[] cont=0 m=input('Ingrese el numero d...
05babe231f74b03b73717dfebeb7b4146f7b42ce
5hogun-Ormerod/Network-rewiring-methods
/Final_versions.py
3,436
3.90625
4
import networkx as nx import random def Random_Path(G, length, path = []): """ Given a graph, G, this function returns a random path of a given number of edges (length =n). This path is represented by a list of nodes of G [v0,v1,..., vn] such that (vi,vi+1) is an edge. This is done...
56ef840dad7baebf3ef0f8de973dd968a43215b4
jhilmilrsingh/Read-Tweet-Data
/Lab10_Singh_Jhilmil.py
1,126
3.703125
4
import json filename = "tweet_data.txt" file_handle = open(filename) outer_dictionary = json.load(file_handle) tweet_list = outer_dictionary.get("tweet_list") for tweet in tweet_list: print("Tweet:", tweet.get("text")) print("Tweeted at:", tweet.get("created_at")) print("Tweet ID:", tweet.get("id")) ...
f9c8aecfc58fdde84467bb10a3d6147ff012caa8
ranjanrajiv00/python-algo
/string/longest-sub-sequence.py
355
3.890625
4
def longestSubseqWithK(str, k): n = len(str) freq = {} for i in range(n): if str[i] not in freq: freq[str[i]] = 1 else: freq[str[i]] += 1 for i in range(n): if (freq[str[i]] >= k): print(str[i], end="") print("") str = "geekswaforgeekswas...
77a544ec2f00a909d606d7059b7ce0be816c2e7f
ranjanrajiv00/python-algo
/basic/reverse-numbers.py
172
4
4
def reverse(num): result = 0 while num > 0: rem = num % 10 result = result * 10 + rem num = num // 10 return result print(reverse(123))
2798bba307a78bdeb063d36ab752e3ee6b60d791
NuApt/HandGestRecog_CNN
/Training.py
2,512
3.828125
4
# Importing the Keras libraries and packages from keras.models import Sequential from keras.layers import Convolution2D from keras.layers import MaxPooling2D from keras.layers import Flatten from keras.layers import Dense # Step 1 - Building the CNN # Initializing the CNN classifier = Sequential() # First convolutio...
1280c62c354e095dea386fd7f76a37bca5ca4f9b
A-G-U-P-T-A/Penetration-Testing-Tutorial-Series
/python/server.py
614
3.859375
4
#import socket library import socket #creating a socket object using socket() function. s = socket.socket() #creating a port on which the server will listen at. p = 4444 #calling bind() function to bind ip address with port number (important step) s.bind(('', p)) #starting the socket listener mode... s.listen(5) #the 5...
51b2b221c87ad60208a0193f8efa2a15015096a7
saurav2401/30-Day-LeetCoding-Challenge
/week4/day_27.py
1,032
3.546875
4
''' Problem Statement: Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. Example: Input: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 Output: 4 ''' # Solution: class Solution: def maximalSquare(self, matrix: List[List[str]]) -> int: ...
cedafe0094c583651e50ea830a601dee344b77c2
masterdorron/Bones
/Bones_new.py
968
3.5625
4
from tkinter import * class Application(Frame): def say_hi(self): self.label["text"] = "hi there, everyone!" def createWidgets(self): self.f1 = Frame(self) self.f1.pack() self.QUIT = Button(self.f1) self.QUIT["text"] = "QUIT" self.QUIT["fg"] = "re...
039775384439590ad1dc80790deb36d5a4558b6a
oxavelar/NumVis
/numvis.py
6,685
3.765625
4
#!/usr/bin/env python """ Author: Omar Avelar DESCRIPTION =========== Simple class extension of number to add hex and binary chunk representations that allow for faster debugging and data analysis, tested in Python 2.6. EXAMPLE ======= >>> from numvis import NumVis ...
7e77dda0e8c28818dbc42abd6ac958a3268df12e
davide-chiuchiu/Analysis_of_job_opening_rejections
/python_code/text_utilities.py
4,769
3.515625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Sep 1 13:16:18 2020 @author: dabol99 This files contains functions that are useful to preprocess strings for nltk and to build document embeddings. """ # import modules import nltk import re import sklearn import sklearn.cluster import pandas """ t...
36ba5f3b29402750e9d5845e97993959b1dcdde2
vpalex999/lutc_prog_1
/Gui/Tour/Grid/grid4.py
304
3.78125
4
""" простая двухмерная таблица, в корневом окне Tk по умолчанию """ from tkinter import * for i in range(5): for j in range(4): lab = Label(text='{}.{}'.format(i, j), relief=RIDGE) lab.grid(row=i, column=j, sticky=NSEW) mainloop()
b8709b8a2416c8ee6a7ccc04635f9cf04e06bca4
vpalex999/lutc_prog_1
/system/Filetools/scanfile.py
670
3.875
4
def scanner(name, function): file = open(name, 'r') # создать объект файла while True: line = file.readline() # вызов метода файла if not line: break # до конца файла function(line) # вызвать объект функции file.close() def scanner2(name, function): for lin...
b705cbbec15b78f1774990fd0d3d2fabb6c67ef2
vpalex999/lutc_prog_1
/system/streams/teststreams.py
706
3.640625
4
""" читает числа до символа конца файла и выводит их квадраты """ def interact(): print('Hello stream world') # print выводит в sys.stdout while True: try: reply = input('Enter a number>') # input читает из sys.stdin except EOFError: break # исключение при всрече с...
12e1c4cc9e6af3035e4501b2cc7cea6477848d25
kirar2004/LearnPython
/ML_Learning/SelectSort.py
413
3.5625
4
lis = [100, 48, 96, 63, 23, 73, 23, 37, 22, 98, 22, 37, 51, 40, 74, 14, 65, 15, 77, 5] print('The raw list is:\n', lis) l = len(lis) for i in range(0, l - 1): #print('i=', i) for j in range(i + 1, l): #print('j=', j) if lis[j] < lis[i]: temp = lis[j] lis[j] = lis[i] ...
c659518d0f15b41da1ab0354b6bd2d0f1cf24446
che-lor/powerpoint-generator
/create_powerpoint.py
1,254
3.625
4
#!/usr/bin/env python3 from pptx import Presentation import itertools ###################-FILL-OUT-#################### file1 = "name_of_file" file2 = "name_of_file" file3 = "name_of_file" powerpoint_name = "name_of_powerpoint" ################################################# _file1 = file1 + ".txt" _file2 = file2 +...
9bdde279c0bda1dacb365d6c8a641cd0ece69e1c
SerhiiDior/soft_100_task
/100_tasks/unit_test/problems/44.py
121
4.03125
4
string=str(input("Str->")) string=string.upper() if string=="YES": print ("Yes") elif string=="NO": print ("No")
1128eb72f0905b4f13fcf973bfe42357b5f48241
SerhiiDior/soft_100_task
/100_tasks/unit_test/problems/63.py
173
3.703125
4
while True: n=int(input("n=")) if n>0: break else: n=int(input("n=")) sum=0 for i in range(1,n+1): sum+=(i/(i+1)) print("Sum=",round(sum,2))
d9a1212261fda49af86933b9c8425d130a5bddd7
SerhiiDior/soft_100_task
/100_tasks/unit_test/problems/54.py
369
3.921875
4
class Shape: def __init__(self): pass def area(self): return 0 class Square(Shape): def __init__(self,length=0): Shape.__init__(self) self.length=length def area(self): return round((self.length*self.length),2) length=float(input("Length->")) square=Square(len...
49c3d50abdec7e61801914d266f93efedc293fd9
SerhiiDior/soft_100_task
/100_tasks/unit_test/problems/49.py
92
3.53125
4
def pow(a): return a**2 lst=[i for i in range(1,21)] res=list(map(pow,lst)) print(res)
8414a894eeba8e9b3969c2df65813cc53a16a097
SerhiiDior/soft_100_task
/100_tasks/unit_test/test_11_20.py
1,313
3.5
4
import unittest from probElevenTwenty import * class SecondClassTest(unittest.TestCase): def test_four_digit_binary(self): expected = str(1010) input_data = four_digit_binary('0100,0011,1010,1001') self.assertEqual(input_data, expected) def test_even_1000_3000(self): self....
0727c45ce80e9ae2759c86ae802bacacc05b34d5
SerhiiDior/soft_100_task
/100_tasks/unit_test/problems/41.py
92
3.703125
4
def tu(n): tup=tuple(i*i for i in range(1,n+1)) print(tup) n=int(input("n=")) tu(n)
36f184fcc05ec26d049a3372f657f650c0ea788b
SerhiiDior/soft_100_task
/100_tasks/unit_test/problems/91-100.py
1,314
3.5
4
#91 def task_91(): lst=[12,24,35,70,88,120,155] lst.remove(lst[0]) lst.remove(lst[4]) lst.remove(lst[5]) return lst #92 def task_92(): lst=[12,24,35,70,88,120,155] lst.remove(24) return lst #93 def task_93(): lst1=[1,3,6,78,35,55] lst2=[12,24,35,24,88,120,155] res=[] fo...
8d52b36de74353d0950346893a1a8ce3ad0c8ea1
Kazuoryu/Python
/codigo Inicial/While.py
100
3.859375
4
numero = 1 while (numero < 100): print ("El valor de numero es:",numero) numero = numero+1
51d3f75a11dc6b4e49a683157171ed0eaf22ea98
Kazuoryu/Python
/Curso Intermedio/Variable de instancia.py
514
3.875
4
class persona(): #nombre clase edad=18 #variable de clase def __init__(self,nombre,nacionalidad): #variables de instancia self.nombre = nombre #y definicion de la funcion self.nacionalidad = nacionalidad def nadar(self): print("Estoy nadando") persona1 = persona("Dieg...
a4626bd141c432c72b937fb754aa0ac2c3b4bae4
Kazuoryu/Python
/codigo Inicial/tuplas.py
262
3.921875
4
#Diferencia Array vs Tuplas #Mientras que los arrays estan limitados por tipo str, int, var, etc #las tuplas no tienen esa limitacion tupla=(25,1.81,"Diego") print (tupla[2]) indice = 0 while indice< len(tupla): print (tupla[indice]) indice = indice + 1
3d8289043074e4a197b417ce77f32d2f9d2967a9
sobanjawaid26/Python_Playground
/PrimeNumberInRange.py
528
4
4
# Write a program to display PRIME NUMBERS from 1 to n? def isPrime(number): for divisor in range(2, number): if number % divisor == 0: return False return True def primeInRange(number): list = [] isPrime = True for number in range(1,number): for n in range(2,number...
0f28ba6d84069ffabf1a733ca4f4980c28674290
ngoc123321/nguyentuanngoc-c4e-gen30
/session2/baiq.py
480
4.15625
4
weight = float(input('Your weight in kilos: ')) # <=== 79 height = float(input('Your height in meters: ')) # <=== 1.75 BMI = weight / height ** 2 BMI = round(BMI, 1) if BMI < 16: result = 'Severely underweight.' elif 16 < BMI <= 18.5: result = 'Underweight.' elif 18.5 < BMI <= 25: result = 'Normal.' elif 25 < BMI <= 3...
964f47be5d63f75d8302445f6715a4e9c6832d0b
IrinIv/LearnQA_PythonAPI
/tests/ex10.py
198
3.609375
4
def test_phrase(): phrase = input("Set a phrase: ") actual_result = (int(len(phrase))) print(int(len(phrase))) assert actual_result < 15, "The phrase is greater than 15 characters"
6323db65f5ad4d4103801871adbf44f70e9b50c4
Zakaria-Alsahfi/python-tutorial
/python_tutorial/Tuples.py
408
4.09375
4
# tuples are similar to list but we can not modified it # Mutable list_1 = ['History', 'Math', 'Physics', 'CompSci'] list_2 = list_1 print(list_1) print(list_2) list_1[0] = 'Art' print(list_1) print(list_2) # Immutable: it can't be change tuple_1 = ('History', 'Math', 'Physics', 'CompSci') tuple_2 = tuple_1 print(t...
3a64a81655e34290ec26910a9a56ba8019771ffa
rayaherrera/1CodesAndOtherStuffs
/crypto.py
2,309
3.859375
4
# Transposition Cipher # original: this_is_a_secret_message_that_i_want_to_transmit # encrypted:hsi__ertmsaeta__att_rnmtti_sasce_esg_htiwn_otasi def scramble2Encrypt(plainText): evenChars = "" oddChars = "" charCount = 0 for ch in plainText: if charCount % 2 == 0: evenChars = evenC...