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
46b66032cccdd783dabc35635b030c8a279b4956
stephenrods-21/python-test
/circle.py
629
4.0625
4
from math import pi class Circle: def __init__(self, radius=1.0): self.radius = radius def __str__(self): return 'Circle with radius of {:.2f}'.format(self.radius) def get_area(self): return 'Area of circle with radius {0} is {1:.2f}'.format(self.radius, self.radius ** 2 * pi) ...
7248cdf41d9aa9a44446945ebd33bc2362cc5a1c
krishnadhara/programs-venky
/oops_concept/encapsulation/encapsul2.py
244
3.875
4
class person: def __init__(self): self.name = "venkatesh" self.__lname = "babu" def display(self): return self.name+' '+self.__lname p = person() print(p) print(p.name) print(p._person__lname) print(p.display())
e4fc40e212a0bbee9a40c4e1a710418c7245bfc7
mridulrb/Basic-Python-Examples-for-Beginners
/SumDigit.py
150
4.125
4
print ("Sum of Digits") x=input("Enter the number") s=0 while x>=1: k=x%10 s+=k x=x/10 print ("The sum of digits is",s)
ef20ef8eb10198871feb6ed443643f2497828a07
RomanAdriel/AlgoUnoDemo
/Gera/Ejercicios UBA/Funciones/Ejercicio8.py
1,759
3.65625
4
"""Dada una serie de datos de la forma mes (1 a 12, no vienen ordenados), cantidad recaudada (en pesos) y costo total (en pesos), hacer un algoritmo que calcule e imprima cuál fue el mes que arrojó mayor ganancia. La serie termina con mes igual a cero. No se deben guardar los datos. """ def ingresar_datos(): reca...
536541854a3ed21e3a068c5fa16231a0ee47389c
Sprokr/AlgorithmProblems
/GeeksForGeeks/selectionSort.py
522
4.3125
4
# https://www.geeksforgeeks.org/selection-sort/ # complexity O(n^2) def selectionSort(arr): i = 0 for i in range(0,len(arr)): minIndex = i for j in range(i, len(arr)): if arr[j] < arr[minIndex]: minIndex = j tmp = arr[i] arr[i] = arr[minIndex] ...
d3412e0caad3fa0d9ca9c32cbaa9ad594ae94b98
KAY2803/PythonPY1001
/Занятие3/Лабораторные_задания/task2_2/main.py
552
3.96875
4
if __name__ == "__main__": def palindrom(str): # определяет, является ли строка палиндромом str = str.lower() letters = [] new_letters = [] for letter in str: if letter != " " and letter != ",": letters.append(letter) new_letters = letters...
ea33edbf48ed27352e00dd71b1683ea2722ee082
attacker2001/Algorithmic-practice
/Codewars/123.py
1,562
4.375
4
#!/usr/bin/env python # coding=utf-8 """ The galactic games have begun! It's the galactic games! Beings of all worlds come together to compete in several interesting sports, like nroogring, fredling and buzzing (the beefolks love the last one). However, there's also the traditional marathon run. Unfortunately, there...
323681cce1b371b87d1f3e5e4c241524a1035641
d1618033/recursion-tree
/examples.py
1,314
3.671875
4
from recursion_tree import recursion_tree from random import choice @recursion_tree(save_to_file=True) def fibo(n): if n <= 2: return 1 else: return fibo(n - 1) + fibo(n - 2) @recursion_tree(save_to_file=True) def permutations(array, soFar=None): if soFar is None: soFar = [] i...
78d9991c7df74a59d68e00bf08d330e9fd13dd6d
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/224/users/4352/codes/1850_1278.py
476
3.65625
4
from numpy import* from numpy.linalg import* c1 = input("digite a cidade 1:") m = array([[0,2,11,6,15,11,1], [2,0,7,12,4,2,15], [11,7,0,11,8,3,13], [6,12,11,0,10,2,1], [15,4,8,10,0,5,13], [11,2,3,2,5,0,14], [1,15,13,1,13,14,0]]) t = 0 i = 0 j = 1 while (c1 != "-1"): if (i != j): i = int...
b8d6c6e67bb948241778225479d6474ced1d7129
levypan666/lvp_python_learn
/unit_7/parrot_2.py
241
3.515625
4
prompt = "\n Tell me something, and i will repeat it back to you:" prompt +="\n Enter 'quit to end the progtam." active = True while active: message = input(prompt) if message == 'quit': active = False else: print (message)
07bd3cc25ddc88eca7d1e26c1137e7b15f27021e
suriyaganesh97/pythonbasicprogs
/basic/greaterof3.py
305
4.125
4
num1 = int(input('enter no 1 ')) num2 = int(input('enter no 2 ')) num3 = int(input('enter no 3 ')) if (num1 >= num2 and num1 >= num3): print('greater no is',num1) if (num2 >= num3 and num2 >= num1): print('greater no is',num2) if (num3 >= num1 and num3 >= num2): print('greater no is',num3)
8c473faff0e7f5307f3667d6d3fc6ffef38b12a2
vale2201/practicas
/practica 1/version antigua/prueba1.py
119
3.640625
4
print("introduce en primer numero?") x=(int(input())) print("introduce elsegundo numero?") y=int((input())) print (x+y)
9d2969920a090651ac3dc7d10fbdd6f9120a1d79
javis-code/ericundfelix
/lorenz/Quiz(Final).py
3,612
3.703125
4
a = 0 ##########Frage 1########## while True: print(" ") print("Frage 1") print(" ") print("Welche Farbe haben Bananen?") List_1 = ["(A) Blau", "(B) Grün", "(C) Gelb", "(D) Rot"] for item in List_1: print(item) Antwort = input("Ihre Antwort hier (A, B, C oder D): ") if Antwor...
67f4c8383c2ea197990863d7e93b014546d0b2f4
ElisonSherton/python4everybody
/ch2ex5.py
378
4.375
4
# Exercise 5: Write a program which prompts the user for a Celsius temperature, convert the temperature to Fahrenheit, and print out the converted temperature. # Vinayak Nayak # 27/12/2018 # IST 11:52 am Celsius = float(input("Enter the temperature in degrees celsius: ")) Farenheit = Celsius * 1.8 + 32 print(str(Cels...
34864edded22b85eee866ae1b3cd5ddcbfd2f2f6
Huangxx00/isdhw
/01/main.py
181
3.78125
4
for i in range(1,10): print(" "*7*i,end="") for j in range(i,10): a=str.format("{0:1}*{1:1}={2:<3}",i,j,i*j) print(a,end="") print()
a62a0b60221e21713a3faa14302aa2bc6fdce75a
DavidAnacona/MisionTic-Universidad-El-Bosque--Python-
/cadenas.py
1,080
4.28125
4
""" Fundamentos de Programacion Programa que simula los metodos para manejo de cadenas Universidad El Bosque - Min Tic """ reiniciar = "s" while reiniciar=="s": print ("\n\t Universidad El Bosque - Min Tic ") print ("\n\t Aplicacion con Metodos de Cadenas") #Entradas cadena = input("\n\t Digite una se...
7b7f086f3c95ce0cde3474bb2a42202b095c877d
kamleshkalsariya/Python_basic
/DSA/hashtable.py
1,877
3.546875
4
class HashTable: def __init__(self): self.Max = 10 self.arr = [None for i in range(self.Max)] def get_hash(self,key): hash = 0 for char in key: hash += ord(char) return hash % self.Max def __setitem__(self, key, value): h = self.get_h...
6c5440924db0a3f21bac5950f35284938ac07b3c
SantoshKumarSingh64/December-2020-LeetCode-Monthly-Challenge
/D28_ReachANumber.py
1,126
4.21875
4
''' Question Description :- Reach a Number You are standing at position 0 on an infinite number line. There is a goal at position target. On each move, you can either go left or right. During the n-th move (starting from 1), you take n steps. Return the minimum number of steps required to reach the destination. ...
67eaf0416a1da38d80eac948c0d59b60f153d614
EricLin24/SSW810
/HW09_ZiangLin.py
4,547
3.71875
4
"""read the data from each of the three files(students.txt, grade.txt, instructors.txt) and store it in a data structure """ import collections import os from prettytable import PrettyTable class Repository: __slots__ = ['stu', 'ins', 'gra', 'studic', 'insdic'] def __init__(self): self.stu = [] ...
66cb253286b1948f8314cef8826cbf99908856ec
gadsone/genderbias
/backcompare.py
4,097
3.6875
4
import pandas as pd import matplotlib.pyplot as plt import numpy as np from tkinter import Tk, Label, Button import tkinter as tk df = pd.read_csv("genderbias.csv") class MyFirstGUI: def __init__(self, master): self.master = master master.title("Scholarly Hazing") self.labe...
1a04ac70f3eead114287bb22031a83f29b4a794d
pavel-prykhodko96/source
/Python/CrashCourse/Chapter8/8_9_to_8_11.py
488
3.546875
4
#8_9 def show_m(list_m): for m in list_m: print(m) def make_great(list_m): for n in range(len(list_m)): list_m[n] = "Great " + list_m[n] def make_great_no_change(list_m): for n in range(len(list_m)): list_m[n] = "Great " + list_m[n] return list_m magicians = ["Gendalf"...
f40124cdb4a630461f9f32fbfd08e54775a0fbb2
sudhir33/TCS_NQT_Practice
/Integer_roman.py
469
3.75
4
def intToRoman(num): list1 = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1] list2 = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'] roman= '' n=len(list1) for i in range(n): if num<list1[i]: continue ...
f279f64bd84040a8165edc3d50f435e0211f4c1e
zebasare/Ejercicio_Clases_y_Objetos
/main.py
1,376
3.96875
4
import math class Punto: def __init__(self,x=0,y=0): self.x=x self.y=y def __str__(self): return f"Punto ubicado en {self.x,self.y}" def cuadrante(self): if self.x>0 and self.y>0: print("El punto esta en el primer cuadrante") elif self.x<0 and self.y>0: print("El punto es...
66499a2ede128ed6701aeaffc82dd74e8f6eff48
SanjeevPhilip/python_assingments_problems
/jumbled_words.py
726
3.890625
4
import pandas as pd import itertools def sort_list(temp_li): temp_li.sort() temp_li = "".join(temp_li) return temp_li df = pd.read_csv("/usr/share/dict/words",header=None) df["letters"] = (df[0].str.lower()).apply(list) df["letters"] = df["letters"].apply(sort_list) input_text = raw_input('Enter jumbled let...
fbf4c9ffe3572944319d2ea84e17ac3397cf0a6f
andonyan/Python-Advanced
/Lists as Stacks and Queues - Lab/Water Dispenser.py
812
3.796875
4
from collections import deque queue = deque() water_quantity = int(input()) while True: name = input() if name != 'Start' and name != 'End': queue.append(name) else: if name == 'Start': while len(queue) > 0: quantity_required = input().split() if...
57ec10fb850ddb33bda353631857748979f79054
ATLAS-P/Introduction
/Workshop 1/Exercises/Guess the Number/Step 3.py
410
3.765625
4
import random guessed = False N = random.randint(1, 100) def get_guess(): global guessed guess = int(input("What's your guess, sir? ")) if guess == N: print("Whoo! That's correct!") guessed = True elif guess < N: print("Oops. That's too small.") else: print("Oops...
2af4149984573978a4bdc588f4b041fe7587bb9e
rohangala3105/FE_595
/10432287_HW_1_FE_595.py
945
3.796875
4
''' Rohan Gala 10432287 FE 595 HW 1 Python Refresher ''' # Importing numpy for creating the graphs import numpy as np # Importing matplotlib.pyplot for ploting the graphs import matplotlib.pyplot as plt # Taking values from 0 to 360(2pi) for the cycle o...
bb579477790f8d93f12b5239d3dec515d8404188
fausecteam/ctf-gameserver
/src/ctf_gameserver/lib/date_time.py
989
3.65625
4
import datetime def ensure_utc_aware(datetime_or_time): """ Ensures that a datetime or time object is timezone-aware. For naive objects, a new object is returned with its timezone set to UTC. Already timezone-aware objects are returned as-is, without any timezone change or conversion. """ if ...
6d411bd602e15d4ced1d157485121462fdd1e0e1
proleaders/python_problem_solving
/Plus Minus.py
634
3.640625
4
#!/bin/python3 import math import os import random import re import sys # Complete the plusMinus function below. def plusMinus(arr): positive_number = [] negative_number = [] zeroes = [] for i in arr: if i < 0: negative_number.append(i) if i > 0: positive_number...
2b89f3147644410bcce525911efd663bbcc2a561
Minkov/python-oop-2021-02
/decorators/lab/vowels_filter.py
482
3.765625
4
def vowel_filter(func): vowels = set('aeiou' + 'aeiou'.upper()) def wrapper(): result = func() return [c for c in result if c in vowels] return wrapper @vowel_filter def get_letters(): return ["a", "b", "c", "d", "e"] @vowel_filter def get_hello_message(): return f'Hello, I am ...
7c88ae6133534d5c583782446f68d7f5b3e29c55
alejandrocca/machine-learning-projects
/mnist.py
4,415
3.703125
4
''' Name : Xingjia Wang Date : 10/02/2018 Project Name: PyTorch Based MNIST Demo with Linear Models Project Description: A simple machine learning project with a self-built neural network linear model based on the MNIST handwritten number training (60000 samples) and testing datasets (10000 samples.) Training takes ...
12e070af78b92bfdf90ac27f3d81440cacf8aaab
MifengbushiMifeng/Data-Structure-and-Algorithms
/Python/Missing-Number/Math.py
169
3.640625
4
class Math: def missingNumber(self, nums): expected_sum = len(nums)*(len(nums)+1)//2 actual_sum = sum(nums) return expected_sum - actual_sum
d00810642ca021d2ae6af795eccfb6c1ee2fd709
Sequd/python
/Patterns/FactoryMethod.py
733
3.9375
4
class Car: """Base car""" def __init__(self, name): self.name = name def factory(self): if self == "sport": return Sportcar() elif self == "mini": return Minicar() assert 0, "Not found car type: " + self # else: # raise Exception(...
7e70a63ce78f04b076cc8f9cd27a39639d7b2e1c
vladislavbasyk/Lessons
/Python/excepts/raising.py
769
3.71875
4
#!/usr/bin/env python3 class ShotInputException(Exception): # пользовательский класс исключения def __init__(self, length, atleast): Exception.__init__(self) self.length = length self.atleast = atleast try: text = input('Введите что-нибудь:') if len(text) < 3: raise Sho...
44c5ff52ff6ff7e653a8b50aa598dc231f5cb90b
pothedarsuhas/Data-Structures-Algorithms
/lineardatastructures/postfixtoinfix.py
431
3.53125
4
from stack import * e = "*+ABC" st = "" #to convert prefix to infix, reverse the expression, use this same program for i in e: st = i + st print(st) s = stack() operators = "+-*/" for i in st: if i not in operators: s.push(i) elif i in operators: a = s.pop() ...
be104d93262456e9937aa38c986350afa35726ee
mecozma/100DaysOfCode-challenge
/ctci/2/delete-middle-node.py
2,007
3.96875
4
""" Implement an algorithm to delete a node in the middle (i.e., any node but the first and the last node, not necesarily the exact middle) of a singly linked list, given access to that node. Example: Input: the node c from the linked list a->b->c->d->e->f Output: nothing is returned, but the new linked list lo...
5d5dbba221c152d37977315e2fc7f745995dc962
acalio/gnn-diffusion
/cascade-generator/cascade_generator/generator.py
5,277
3.578125
4
import numpy.random as rn from networkit.centrality import DegreeCentrality import tqdm class CascadeGenerator: """Cascade Generator. This class is in charge of running a diffusion process and to collect the output of the propagation. Parameters ---------- influence_graph: networkit Graph o...
0a480c07b73c11000e89cae21aeaea27a7ad3d0d
Matheus-616/Stepik
/lista8: recursão/L8Q2.py
703
3.9375
4
''' [1 ponto] Escreva uma função matriz_2x2_inversa: recebe uma matriz 2×2 e calcula a sua inversa. Retorne None caso a matriz seja singular. Cabeçalho da função: def matriz_2x2_inversa(M): Não se preocupe com a chamada das funções, ou impressão dos resultados, isso será feito automaticamente.   Escreva apenas as ...
00fb551a6cf58e40e2530264669a049ff560d3cf
sjaney/PDX-Code-Guild---Python-Fullstack-Solution
/python/lab15.py
1,508
4.1875
4
# Lab 15 Count Words import requests import string # Make everything lowercase, strip punctuation, split into a list of words. def use_requests(): response = requests.get('https://www.gutenberg.org/files/64214/64214-0.txt') book = response.text.lower() # make everything lowercase return book book = use_...
44e6269a1dec3ef2a13a9449d7d9ff1c4e501369
Sebstar2000/semiprime
/index.py
965
3.875
4
minVal = int(input("Minimum Value:")) maxVal = int(input("Maximum Value:")) primeNumbers = [] semiprime = [] def checkNumber(num): isPrime = True for i in range(2, num): if num % i == 0: isPrime = False if isPrime == True: global primeNumbers primeNumbers...
984469c33fd33b7cfe3d770163580c075506b408
zolcsika71/JBA_Python
/Rock-Paper-Scissors/Problems/Decimal places/main.py
132
3.5625
4
number = float(input()) decimal_places = int(input()) print(f'{number:.{decimal_places}f}') # print(round(number, decimal_places))
3604fe72a2a5c65fcc784b401581321e4c29665f
teja-rostan/DeepExpressionLearner
/data_target.py
3,691
3.6875
4
""" A program for data and target retrieving in right format used by class_learning.py and reg_learning.py """ import pandas as pd import numpy as np from sklearn.preprocessing import OneHotEncoder def get_datatarget(scores_file, delimiter, target_size, problem_type, class_, nn_type): """ Reads a complete fil...
11bf6cda5e9a65bacdd69af2632640ebb35c7f3a
rishabh1994/DSA
/show_me_the_data_structure/pythonFiles/problem_3.py
4,876
3.5625
4
from queue import PriorityQueue import sys class Node: def __init__(self, character, count): self.character = character self.count = count self.left = None self.right = None self.binaryCode = None def __lt__(self, other): return self.count <= other.count def ...
0499226de56c60c225eccac6bfa3bf39dc64fb0a
gerrylwk/Efficient-Matrix-Algorithms
/augGaussLabel.py
1,087
3.609375
4
import numpy as np def augGaussLabel(A): #Gaussian with row labels, to prevent n = len(A) #unnecessary changes in entries with zero pivot elements r = np.arange(n) for i in range(0,n-1): j = i while j <= n-1 and A[r[j]][i] == 0: j += 1 ...
516d8356436ab73ef180e2d4319cf2ba2ca2ce84
s-surineni/atice
/leet_code/find_words_chars.py
396
3.96875
4
from collections import Counter def find_words_chars(words, chars): char_count = Counter(chars) len_sum = 0 for a_word in words: a_word_counter = Counter(a_word) len_sum += len( a_word) if a_word_counter & char_count == a_word_counter else 0 return len_sum words = ["cat",...
3b52d3c9e4da651e79cf5d9f0dec641d83af7762
annazof/LCbasic2021
/Baisc Track/how_to_think/Chapter 3/exercise3.4.4.15.py
378
3.9375
4
#An equilateral triangle import turtle canvas = turtle.Screen() leo = turtle.Turtle() #triangle for i in range(3): leo.forward(50) leo.left(120) #square for i in range(4): leo. forward(100) leo.left(90) #hexagon for i in range(6): leo.forward(80) leo.right(60) #octagon for i in range(8): ...
f4ebe77a4a3dfbeaca07ca2cc356079cb68a9d51
ashish-ucsb/xor_back_propagation
/xor_back_prop.py
2,896
3.5625
4
#!/usr/bin/env python # coding: utf-8 # In[17]: import numpy as np import matplotlib.pyplot as plt import random # In[18]: # Visualization of XOR in 2-D Space plt.plot([1,0], [1,0], 'ro', marker="+", markersize=20, color = 'blue') plt.plot([1,0], [0,1], 'ro', marker="_", markersize=20, color = 'red') plt.axis...
0b62f93f32e16bf81cf30f28b3aa61caa33e16c7
RodolfoContreras/AprendaPython
/Tablas.py
312
3.609375
4
# Tablas.py # Autor: Contreras Galvan Rodolfo Alejandro # Fecha de creación: 02/09/2019 for tabla in range(1,11): encabezado="Tabla del {}" print(encabezado.format(tabla)) print() for tablas in range(1,11): R="{} x {} = {}" print(R.format(tabla,tablas,tabla*tablas)) els...
1b415550094fb8f04a520f03052fd2df80e51451
msaei/coding
/LeetCode/Top Interview Questions/Dynamic Programming/Unique Paths.py
427
3.65625
4
#Unique Paths #https://leetcode.com/explore/interview/card/top-interview-questions-medium/111/dynamic-programming/808 class Solution: def uniquePaths(self, m: int, n: int) -> int: mem = [[1] * n for _ in range(m)] print(mem) for i in range(1, m): for j in range(1, n): ...
968b94ab4baa01221a6b14384dd26a0376ac44ef
lobsangmerc/caldoe
/pythongit.py
2,868
3.9375
4
import os dolar = float(58.5) euro = float(66.8) def operaciones_dolar(): print('1.DOLAR A PESO11111 2.PESO A DOLAR') dolar_op = int(input("Ingrese la operacion que desea realizar: ")) if dolar_op == 1: print('Esta convirtiendo de dolar a peso dominicano') cantidad = int(in...
057d2f1336f7cc460dfdf3ca63e070de0d052e0c
harsh22chauhan/Python-Projects
/basic codes/forloop.py
383
3.90625
4
for i in range(1, 5 ): for j in range(i): print(i, end=' ') print() print(20*"*") for letter in 'Python class': if letter == 'h' or letter == 's': continue print ('Current Letter :', letter) var = 10 print(20*"*") for d in 'Pythonclass': if d == 't' or d == ...
6f06c24cc9eecc85ed6ef6c386520cfcab0eed49
EOppenrieder/HW070172
/Homework3/Exercise11.py
272
4.1875
4
def main(): print("This program converts meter per second (ms)") print ("into kilometers per hour (kmh).") ms = eval(input("Enter your velocity in meter per second: ")) kmh = 3.6 * ms print("Your velocity is",kmh,"kilometers per hour.") main ()
c38d281706e1d4169c01d310c9f782edd87a4393
sambapython/batch46
/log/app.py
1,130
3.890625
4
import logging logging.basicConfig(level=logging.DEBUG, format="%(asctime)s-->>%(levelname)s==>%(message)s", filename="log.txt") logging.info("program started") a=raw_input("Enter a value:") logging.info("Got the a value from the user") b=raw_input("Enter b value:") logging.info("Got the b value from the user")...
b25165259fc4cee754afa12aaa13df9f928f6829
fernandamarr/python-course
/Section 6: Functions/Function-Practice/paper-doll.py
323
4.1875
4
# PAPER DOLL: Given a string, return a string where for every character in the original there are three characters # paper_doll('Hello') --> 'HHHeeellllllooo' # paper_doll('Mississippi') --> 'MMMiiissssssiiippppppiii' def paper_doll(text): result = '' for elem in text: result += elem * 3 return res...
3a9004b2924ba8b97882d44d0c4cef3635e49ee6
acgoularthub/Curso-em-Video-Python
/desafio020.py
311
3.65625
4
from random import shuffle nome1 = str(input('Insira o nome do primeiro aluno: ')) nome2 = str(input('Insira o nome do segundo aluno: ')) nome3 = str(input('Insira o nome do terceiro aluno: ')) nome4 = str(input('Insira o nome do quarto aluno: ')) lista = [nome1,nome2,nome3,nome4] shuffle(lista) print(lista)
26381263286908defa03dd4c230b25dfc8a68ed3
Sqvall/codewars
/python/kyu_4/sudoku_solutions_validator.py
1,046
3.515625
4
""" https://www.codewars.com/kata/529bf0e9bdf7657179000008 """ correct = [i for i in range(1, 10)] def validSolution(board): swap = [[] for _ in range(9)] three = [[] for _ in range(9)] for i in board: for val in range(9): swap[val].append(i[val]) for i in range(0, 9, 3): ...
778b3ed9d06b10c99158889b7079e21e52315dbb
RosanaR2017/PYTHON
/posnegzero.py
923
3.578125
4
import sys import math def number(x): if x==0: return "Cero" return "Positivo" if x > 0 else "Negativo" def main(): try: list=["4","0","-12","0.0","0","-1"] #input("Please, enter only a list of number separated by a comma.If you enter another key the program will end.\n").sp...
55ec61458b3eccecd10d90349b9227721b055559
Senpaistorm/gpasim
/course.py
434
3.71875
4
import Student.py ''' A class that represents a course specified with a course code. ''' class Course(): def __init__(self, code): ''' Initialize a new course specified by the course code. code -> str ''' self.code = code def __str__(self...
2b47ebcaee897541babcb17b45b13245bc4cd3fe
marcushvega/pythonLearning
/marcus_scripts/ex18_MV_args.py
720
4.1875
4
#---This import allows us to use module argv from package sys import sys #---This script exists to demonstrate use of '*args' def unknown_vars(args): print("This script exists to demonstrate use of '*args' as shown below.\n") print(f"This args list contains {len(sys.argv)} variables.\n---------------------------...
829351b0060d1388c1c21a63d7b847e595e21764
halfak/wikidata_usage_tracking
/multi_wiki_wikidata_usage.py
4,589
3.765625
4
""" For each wiki, calculates Wikidata usage and returns a csv containing its usage information. Also returns csv with aggregated results across wikis. Usage: multi_wiki_wikidata_usage (-h|--help) multi_wiki_wikidata_usage --results-directory=<directory_path> --naming-scheme=<scheme> --dump-date=<yyyymmdd> ...
558d337a28fe9da7fcae216a6bec02f4ab0770c9
duxiaobu/data_structure
/20_05_22/判断子序列.py
512
3.546875
4
class Solution: def isSubsequence(self, s: str, t: str) -> bool: s_point = t_point = 0 s_length = len(s) t_length = len(t) while s_point < s_length and t_point < t_length: if s[s_point] == t[t_point]: s_point += 1 t_point += 1 e...
ab135fe8a5e767ede05351d4c9b2c5ec5b28513b
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_200/1457.py
501
3.71875
4
def tidy(num): num = list(num) for i in range(len(num) - 1, 0, -1): if int(num[i]) < int(num[i - 1]): for j in range(i, len(num)): num[j] = '9' num[i] = '9' num[i - 1] = str(int(num[i - 1]) - 1) return str(int(''.join(num))) def main()...
655b236877a07283d99e5adc9bb055e06dc6f149
velenk/Python
/Python语言程序设计基础/科赫曲线绘制.py
837
3.671875
4
import turtle as t def main(): num = input_msg() start() for i in range(3): draw(num, 600) t.right(120) def input_msg(): while True: msg = input('The Koch Number:') if msg: try: num = int(msg) if num > 5: n...
e60860cb26fedeb65ece5f631e55c8cf5d5d1240
JonathanCrt/SIO_Algorithmic_applied
/nb-notes.py
224
3.96875
4
compte=int(input("Combien de notes ?:")) lnotes=[] for i in range (compte): x=float(input("Note :")) lnotes.append (x) print(lnotes) print ("la moyenne des notes est :" , (lnotes.append(x))/compte)
4a8edcefa9e3c44657077f017f35108f13a135ee
Leetcode-101/Leetcode-python
/leetcode/102.二叉树的层序遍历.py
1,386
3.828125
4
# # @lc app=leetcode.cn id=102 lang=python3 # # [102] 二叉树的层序遍历 # # https://leetcode-cn.com/problems/binary-tree-level-order-traversal/description/ # # algorithms # Medium (64.15%) # Likes: 876 # Dislikes: 0 # Total Accepted: 312.6K # Total Submissions: 487.4K # Testcase Example: '[3,9,20,null,null,15,7]' # # 给你一...
bea135ceb282843867a40760a68748ff581de622
euzin4/gex003_algprog
/material/respostas_exercicios/lista10/exe2.py
1,065
4
4
N_linha = 5 #VARIÁVEL GLOBAL - Tamanho das linhas da matriz N_coluna = 4 #VARIÁVEL GLOBAL - Tamanho das colunas da matriz def soma_matriz(matA, matB): #Cálculo da matriz matC (matA + matB) matC = [] for i in range(N_linha): linha = [] for j in range(N_coluna): linha.append(matA[i][j] + matB[i][j]) matC.ap...
0f69801461bba0583ccf39a81731d2eaa3aef29d
serikisaev/serikisaev
/pytz_task.py
1,196
3.6875
4
import pytz import datetime def return_timezones_list(): quantity_timezones = int(input('Сколько нужно временных зон вывести?: ')) count = 0 time_zones_list = [] for country in pytz.country_names: if count == quantity_timezones: break else: time_zo...
33447cab3ae475f55e421e8483c4c1ea9c4a5214
dirceileen/An-lisis-de-Algoritmos
/BubbleSort.py
268
3.875
4
def BubbleSort(Lista): for numPasada in range(len(Lista)-1,0,-1): for i in range(numPasada): if Lista[i]>Lista[i+1]: temp = Lista[i] Lista[i] = Lista[i+1] Lista[i+1] = temp return Lista
273c64f69aebb0b394fd044453b5dbe2c10fa128
WrathTitan/DLNeuralNetwork
/StructuredModel/relu_backward.py
477
4.15625
4
def relu_backward(dA, cache): """ The backward propagation for a single RELU unit. Arguments: dA - post-activation gradient, of any shape cache - 'Z' where we store for computing backward propagation efficiently Returns: dZ - Gradient of the cost with respect to Z """ Z = cache #...
8739024db133b3a3bb68d2f99f1ee00c4907f089
thonrocha/fiap-r
/teste.py
283
3.53125
4
#!/usr/bin/python import csv tipos = ['red', 'white', 'vinho'] with open('BaseWine_Red_e_White.csv', 'rw') as f: data = csv.reader(f, delimiter=';') for l in data: if l[13].lower() in tipos: pass else: print('ERROR ######### FUUUU')
0e0c9e1567eee7a17b65bba2867063d0252575ab
WBReiner/coding_notebooks_python
/CS/paired_prog_CS.py
1,204
3.96875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Oct 17 17:07:43 2018 @author: whitneyreiner """ #make a linked list from scratch # ============================================================================= # Q1 Implement an algorithm to determine if a string has all unique characters. # What if ...
55199b8b1bead4f2e72839012f6254941a01ece1
szhmery/leetcode
/SortingAndSearching/74-Search2DMatrix.py
3,002
3.765625
4
from typing import List import bisect class Solution: # https://www.bilibili.com/video/BV1aK4y1h7Bb def searchMatrix(self, matrix: List[List[int]], target: int) -> bool: R = len(matrix) if R == 0: return False C = len(matrix[0]) if C == 0: return False ...
420d29d9484572fda7353ed7be6eb156bd2d7b96
darshanjoshi16/GTU-Python-PDS
/lab2_2.py
798
4.15625
4
#Lab Assignment 2.2 #Write a Python program to print the series of prime numbers until the number entered by the user. #take the input from user number=int(input("Enter the number: ")) print("-----------------------------------------------------------") print("The Prime Numbers come before "+str(number)+" are:...
9247b6521b3996b9e53e438ba513f77a16720d0c
tanviredu/python_database_oop_coursera
/Class_and_inheritance/second.py
553
3.953125
4
class Employee: ''' this is the class Description''' name = "Ben" designation = "Sales Executive" salesMadeThisWeek = 6 def hasAchivedTarget(self): if self.salesMadeThisWeek >=5: print("Target has been achived") else: print("Target is not achived") #help(E...
1081071038cd4ba56e298fdbf21ccab09643c38a
hakver29/project_euler
/python/problem62.py
465
3.671875
4
def main(): cubes = [''.join(sorted(str(i**3))) for i in range(1,10000)] cubes = sorted(cubes) yolo = [] for i in range(len(cubes)-3): if cubes[i] == cubes[i+1] and cubes[i+1] == cubes[i+2] and cubes[i+2] == cubes[i+3] and cubes[i+3] == cubes[i+4]: yolo.append(cubes[i]) for i i...
e3a45b1403aa4f940753b52790b8aeea8ca8b3e0
clovery410/mycode
/interview_qa/snapchat/task_sequence.py
1,511
3.59375
4
import collections class Task(object): def __init__(self, _id): self._id = _id self.deps = set() class Solution(object): def taskSequence(self, tasks): in_degree = collections.defaultdict(list) out_degree = collections.defaultdict(int) # build graph for ...
0b68b088eaaf44518d6f0d0c149276997027118b
wentingsu/Su_Wenting_spring2017
/Final/codePY/Analysis4.py
3,718
3.65625
4
# coding: utf-8 # # Analysis 4 # # * analyse the variable # * from previous analyses we can find out that the happiness scores difference between Western Europe and Central and Eastern Europe is large. In this analysis, let's find out each how variables influence the outcomes. # In[3]: import pandas as pd # from ...
7947634bf956c047137997d2c9cb2c83e2f646a9
sez07/hangman
/hangman/hangman.py
2,918
4
4
import random def hangman(): list_of_words=['newyork','chicago','houston','philadelphia','dallas','atlanta','fresno','columbus','indianapolis','portland','miami','orlando','greensboro'] word=random.choice(list_of_words) turns=10 guessmade='' valid_entry=set('abcdefghijklmnopqrstuvwxyz') while ...
40110fe47181f8c5c296f5f1b7e4aef1e13e075f
igorbeduin/reinforcement-maze
/mazegen.py
1,517
3.84375
4
# From http://code.activestate.com/recipes/578356-random-maze-generator/ # Modified to use numpy and return maze instead of saving it as an image. # Random Maze Generator using Depth-first Search # http://en.wikipedia.org/wiki/Maze_generation_algorithm # FB - 20121214 import random import numpy as np def make_maze(...
ec5327bcb6376e6ef5250dd1c531c05f893b926e
zdurczok/hard_way
/ex16_1/test_sorting1.py
942
3.921875
4
import sorting from random import randint max_numbers = 30 def random_list(count): numbers = [] for i in range(count, 0, -1): numbers.append(randint(0, 10000)) return numbers def test_bubble_sort(): numbers = random_list(max_numbers) lista1 = sorted(numbers) lista2 = sorting.bubble_s...
eb1da6b45d2a27d5f91c8da43d383d51113dd3f3
mdLearning/mnist
/src/networkMnist.py
5,731
3.8125
4
''' Created on Dec 1, 2017 @author: lyf ''' #-*- coding:utf-8 -*- class Network(object): def __init__(self,sizes): """ the list '''sizes'''contains the number of neurons in the respective layers of the network. for example,if the list was [2,3,1] the it would be a three-layer networ...
b8bc2e13c8c949bb807e1c9b784da2a7aebac1d4
Thirumurugan-12/Python-programs-11th
/Find the row sum and column sum of all the elements list stored as a nested list..py
307
3.65625
4
l=eval(input("Enter the nested list")) m=len(l) # no of rows n=len(l[0]) #no of coloums for i in range(m): rs=0 for j in range(n): rs+=l[i][j] print("Sum of",i,"row",rs) for j in range(n): cs=0 for i in range(m): cs+=l[i][j] print("Sum of",j,"col",cs)
cc374058fd353742bc0579f26b272f60704350d0
henrylin2008/Coding_Problems
/DS and Algorithms/recursion.py
271
3.9375
4
# recursion: it needs the base case, and recursive calls on same function of last 2 positions # Fibonacci Sequence def get_fib(position): if position == 0 or position == 1: # base case return position return get_fib(position - 1) + get_fib(position - 2)
e93df79a583a7808b595f2914693255fd65d66fc
negative0101/Python-OOP
/9.Testing/Lab/2.py
1,544
3.625
4
class Cat: def __init__(self, name): self.name = name self.fed = False self.sleepy = False self.size = 0 def eat(self): if self.fed: raise Exception("Already fed.") self.fed = True self.sleepy = True self.size += 1 d...
e6e1fa653cc44f8ee78b0707577ba3942b1bdedd
arfu2016/DuReader
/wiki-word2vec/pca.py
4,294
3.6875
4
""" @Project : DuReader @Module : pca.py @Author : Deco [deco@cubee.com] @Created : 5/24/18 1:16 PM @Desc : In Depth: Principal Component Analysis https://jakevdp.github.io/PythonDataScienceHandbook/05.09-principal-component-analysis.html PCA and proportion of variance explained: https://stats.stackexc...
689775ad2e7d622e93db95c88f9585512aeb1f45
WeijieH/ProjectEuler
/PythonScripts/Smallest_multiple.py
747
4.125
4
''' 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? ''' from math import log def smallest_multiple(num): result = 1 for i in range(2, num + 1): ...
a41697c6cededbf1cfc611cc715b66d922df5739
nithish-kumar-t/Algorithms-Assignment
/knapsack.py
810
3.734375
4
# Uses python3 import sys import numpy def optimal_weight(W, w): # write your code here #w.sort() #w = w[::-1] result = 0 c1 = W r1 = len(w) # the above function initializes a 2D Array of size mXn with Zeroes using Numpy value = numpy.zeros((r1+1 , c1+1)) for i in range(r1+1): ...
4eb5121d7bab76272f0337ae75f8d9c5f00bc99d
mingyue33/python_base
/04-python基础-if、while、for等/3-我和媳妇去银行办业务.py
278
3.6875
4
#1. 询问媳妇是否去银行 a = input("亲爱的,您去银行么? 1:去 2:不去") #2. 询问自己是否去银行 b = input("自己有时间去银行么? 1:去 2:不去") #3. 判断是否去银行办事 if a=="1" and b=="1": print("可以办理业务")
038271316634aa2e4b624557a394064f136739bb
Moukthika-sai-satya-karinki/python-programs
/min_3_nums.py
304
4.125
4
#python program for min of three numbers a=int(input("enter the first number")) b=int(input("enter the second number")) c=int(input("enter the third number")) if(a<b and a<c): print(a,'a is smallest') if(b<a and b<c): print(b,'b is smallest') else: print(c,'c is smallest')
855eecdd6723c29c3d64a60c33f1847342292e3d
giuper/teaching
/OldClasses/ALGO20/04-Back/Codice/maze.py
3,188
3.71875
4
from back import BackTrack class Maze(BackTrack): #does not handle cycles in the maze MOVES=[[0,0],[-1,0],[0,1],[1,0],[0,-1]] #moves #0 --> Dummy move #1 --> North #2 --> East #3 --> South #4 --> West ## EXIT/FINISH -1 ## LIBERO 0 ## BLOCCATO 1 ## VISITATO ...
5ce80c6d41c76c48aa0c37267096eb7864a8f746
SasView/sasmodels
/sasmodels/models/power_law.py
1,768
3.546875
4
#power_law model #conversion of PowerLawAbsModel.py #converted by Steve King, Dec 2015 r""" This model calculates a simple power law with a flat background. Definition ---------- .. math:: I(q) = \text{scale} \cdot q^{-\text{power}} + \text{background} Note the minus sign in front of the exponent. The exponent...
731412e1f46d5adc5cc3d2dcc735808f24639757
piksa13/ChallengingTasks4beginners
/ChallengingTask_level_3/22freq_keys.py
494
4.125
4
freq = {} # frequency of words in text line = input("Enter you text here: ") for word in line.split(): word = word.lower() freq[word] = freq.get(word, 0) + 1 # It checks whether the value for word is already there if not it defaults to 0, only for dicts words = freq.keys() numb = freq.values() # freq.items()...
98127d8d6a62cf5c9d7bb62cfb5b884679fd5287
elliotpalmer/plotly-mapping-alpha
/python-plotly-v1/utils/json_helpers.py
431
3.765625
4
def write_json_to_file(json_data, filename, separators=(',',':')): """ Write JSON data to a .json file """ import json file = open(filename, 'w') file.write(json.dumps(json_data,separators=separators)) def read_json_from_file(json_file): """ Read to a Python dictionary from a .json file...
9eff0c12da107274c6a9577a2a0c9ad61d7cf58b
Mansurjon1112/FOR-for-sikl-operatoriga-oid-masalalar-40-ta-masala
/For16.py
462
3.609375
4
# -*- coding: utf-8 -*- """ For16. n butun soni va a haqiqiy soni berilgan (n > 0). Bir sikldan foydalanib a ning 1 dan n gacha bo’lgan barcha darajalarini chiqaruvchi programma tuzilsin. Created on Thu Jun 24 19:37:20 2021 @author: Mansurjon Kamolov """ a = float(input('a = ')) n = int(input('n = ')) ku...
433db01b27fcdbbe46a3e1a2fb0253e220d414a7
shasha9/python-scripts
/prime.py
945
4.125
4
# Enter your code here. Read input from STDIN. Print output to STDOUT import math def isPrime(n): if n<1 or n>2*(10**9): return 0 if n == 1: return 0 if n == 2: return 1 for i in range(2,n): if n%i == 0: return 0 return 1 def isPrime...
2869980770d9406d202f564ea80002612a1928e9
Ducbx/algorithm-training
/Blue/Session 05 - String/Codeforces_499B.py
2,824
3.71875
4
# Problem from Codeforces # http://codeforces.com/problemset/problem/499/B # You have a new professor of graph theory and he speaks very quickly. You come up with the following plan to keep up with his lecture and make notes. # # You know two languages, and the professor is giving the lecture in the first one. The wor...
605b81f7461216c5b301fddb2c7b535aed7279f3
saradaprasad/py
/py_basics_problems/list_min_max_number.py
178
3.625
4
def find_min_num(): print("min") def find_max_num(): print("max") if __name__ == "__main__": lst=[10,20,30,40,50,60,70,80,90] find_min_num() find_max_num()
739ce04a04600eb695086898c0de5c5a376b389c
amitsaha/notes
/articles/data_python_c/listings_py/mut.py
553
3.71875
4
#!/usr/bin/env python # mutable data types: dictionary, list. from __future__ import print_function dict() print('dict: {0}'.format(id(dict()))) list() print('list: {0}'.format(id(list()))) def func(): d = dict() print('dict: {0}'.format(id(d))) l = list() print('list: {0}'.format(id(l))) cl...
d78b16caaaf6a9da56b4d0a4c7c79662bf894037
yzl232/code_training_leet_code
/Decode Ways.py
1,464
3.796875
4
''' A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given an encoded message containing digits, determine the total number of ways to decode it. For example, Given encoded message "12", it could be decoded as "AB" (1 2) or "L" (12). The...
a9007ae3bd8000654120a7fadcbfa766d4259a2f
Kriti231999/Looping.py
/Positive .py
835
3.984375
4
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> Org_list = input("Enter list:"): SyntaxError: invalid syntax >>> Org_list = int (input("enter list:")) enter list:-3,2,1,4,-5 Traceback (mo...